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/Jamfile4
-rw-r--r--src/3rdparty/freetype/src/autofit/afangles.c125
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.c177
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.cin39
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.dat337
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.h203
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.hin142
-rw-r--r--src/3rdparty/freetype/src/autofit/afcjk.c1071
-rw-r--r--src/3rdparty/freetype/src/autofit/afcjk.h113
-rw-r--r--src/3rdparty/freetype/src/autofit/afcover.h105
-rw-r--r--src/3rdparty/freetype/src/autofit/afdummy.c47
-rw-r--r--src/3rdparty/freetype/src/autofit/afdummy.h8
-rw-r--r--src/3rdparty/freetype/src/autofit/aferrors.h3
-rw-r--r--src/3rdparty/freetype/src/autofit/afglobal.c406
-rw-r--r--src/3rdparty/freetype/src/autofit/afglobal.h103
-rw-r--r--src/3rdparty/freetype/src/autofit/afhints.c791
-rw-r--r--src/3rdparty/freetype/src/autofit/afhints.h288
-rw-r--r--src/3rdparty/freetype/src/autofit/afindic.c98
-rw-r--r--src/3rdparty/freetype/src/autofit/afindic.h9
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin.c1455
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin.h92
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin2.c435
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin2.h10
-rw-r--r--src/3rdparty/freetype/src/autofit/afloader.c158
-rw-r--r--src/3rdparty/freetype/src/autofit/afloader.h42
-rw-r--r--src/3rdparty/freetype/src/autofit/afmodule.c271
-rw-r--r--src/3rdparty/freetype/src/autofit/afmodule.h24
-rw-r--r--src/3rdparty/freetype/src/autofit/afpic.c142
-rw-r--r--src/3rdparty/freetype/src/autofit/afpic.h77
-rw-r--r--src/3rdparty/freetype/src/autofit/afranges.c220
-rw-r--r--src/3rdparty/freetype/src/autofit/afranges.h41
-rw-r--r--src/3rdparty/freetype/src/autofit/afscript.h139
-rw-r--r--src/3rdparty/freetype/src/autofit/afstyles.h164
-rw-r--r--src/3rdparty/freetype/src/autofit/aftypes.h524
-rw-r--r--src/3rdparty/freetype/src/autofit/afwarp.c64
-rw-r--r--src/3rdparty/freetype/src/autofit/afwrtsys.h52
-rw-r--r--src/3rdparty/freetype/src/autofit/autofit.c9
-rw-r--r--src/3rdparty/freetype/src/autofit/hbshim.c545
-rw-r--r--src/3rdparty/freetype/src/autofit/hbshim.h56
-rw-r--r--src/3rdparty/freetype/src/autofit/rules.mk14
-rw-r--r--src/3rdparty/freetype/src/base/basepic.c73
-rw-r--r--src/3rdparty/freetype/src/base/basepic.h58
-rw-r--r--src/3rdparty/freetype/src/base/ftadvanc.c39
-rw-r--r--src/3rdparty/freetype/src/base/ftbase.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftbase.h12
-rw-r--r--src/3rdparty/freetype/src/base/ftbbox.c512
-rw-r--r--src/3rdparty/freetype/src/base/ftbdf.c43
-rw-r--r--src/3rdparty/freetype/src/base/ftbitmap.c271
-rw-r--r--src/3rdparty/freetype/src/base/ftcalc.c540
-rw-r--r--src/3rdparty/freetype/src/base/ftcid.c8
-rw-r--r--src/3rdparty/freetype/src/base/ftdbgmem.c111
-rw-r--r--src/3rdparty/freetype/src/base/ftdebug.c30
-rw-r--r--src/3rdparty/freetype/src/base/ftfstype.c4
-rw-r--r--src/3rdparty/freetype/src/base/ftgloadr.c14
-rw-r--r--src/3rdparty/freetype/src/base/ftglyph.c124
-rw-r--r--src/3rdparty/freetype/src/base/ftgxval.c35
-rw-r--r--src/3rdparty/freetype/src/base/ftinit.c132
-rw-r--r--src/3rdparty/freetype/src/base/ftlcdfil.c85
-rw-r--r--src/3rdparty/freetype/src/base/ftmac.c104
-rw-r--r--src/3rdparty/freetype/src/base/ftmm.c50
-rw-r--r--src/3rdparty/freetype/src/base/ftobjs.c1105
-rw-r--r--src/3rdparty/freetype/src/base/ftotval.c17
-rw-r--r--src/3rdparty/freetype/src/base/ftoutln.c357
-rw-r--r--src/3rdparty/freetype/src/base/ftpatent.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftpfr.c28
-rw-r--r--src/3rdparty/freetype/src/base/ftpic.c15
-rw-r--r--src/3rdparty/freetype/src/base/ftrfork.c164
-rw-r--r--src/3rdparty/freetype/src/base/ftsnames.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftstream.c142
-rw-r--r--src/3rdparty/freetype/src/base/ftstroke.c900
-rw-r--r--src/3rdparty/freetype/src/base/ftsynth.c41
-rw-r--r--src/3rdparty/freetype/src/base/ftsystem.c32
-rw-r--r--src/3rdparty/freetype/src/base/fttrigon.c368
-rw-r--r--src/3rdparty/freetype/src/base/fttype1.c69
-rw-r--r--src/3rdparty/freetype/src/base/ftutil.c142
-rw-r--r--src/3rdparty/freetype/src/base/ftwinfnt.c22
-rw-r--r--src/3rdparty/freetype/src/base/md5.c296
-rw-r--r--src/3rdparty/freetype/src/base/md5.h45
-rw-r--r--src/3rdparty/freetype/src/base/rules.mk16
-rw-r--r--src/3rdparty/freetype/src/bdf/README4
-rw-r--r--src/3rdparty/freetype/src/bdf/bdf.h8
-rw-r--r--src/3rdparty/freetype/src/bdf/bdfdrivr.c116
-rw-r--r--src/3rdparty/freetype/src/bdf/bdfdrivr.h2
-rw-r--r--src/3rdparty/freetype/src/bdf/bdferror.h3
-rw-r--r--src/3rdparty/freetype/src/bdf/bdflib.c520
-rw-r--r--src/3rdparty/freetype/src/bzip2/Jamfile19
-rw-r--r--src/3rdparty/freetype/src/bzip2/ftbzip2.c519
-rw-r--r--src/3rdparty/freetype/src/bzip2/rules.mk63
-rw-r--r--src/3rdparty/freetype/src/cache/Jamfile4
-rw-r--r--src/3rdparty/freetype/src/cache/ftcbasic.c370
-rw-r--r--src/3rdparty/freetype/src/cache/ftccache.c116
-rw-r--r--src/3rdparty/freetype/src/cache/ftccache.h82
-rw-r--r--src/3rdparty/freetype/src/cache/ftccback.h11
-rw-r--r--src/3rdparty/freetype/src/cache/ftccmap.c141
-rw-r--r--src/3rdparty/freetype/src/cache/ftcerror.h3
-rw-r--r--src/3rdparty/freetype/src/cache/ftcglyph.c20
-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/ftcmanag.c105
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmanag.h8
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmru.c12
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmru.h4
-rw-r--r--src/3rdparty/freetype/src/cache/ftcsbits.c43
-rw-r--r--src/3rdparty/freetype/src/cache/ftcsbits.h9
-rw-r--r--src/3rdparty/freetype/src/cff/cf2arrst.c241
-rw-r--r--src/3rdparty/freetype/src/cff/cf2arrst.h100
-rw-r--r--src/3rdparty/freetype/src/cff/cf2blues.c579
-rw-r--r--src/3rdparty/freetype/src/cff/cf2blues.h185
-rw-r--r--src/3rdparty/freetype/src/cff/cf2error.c52
-rw-r--r--src/3rdparty/freetype/src/cff/cf2error.h119
-rw-r--r--src/3rdparty/freetype/src/cff/cf2fixed.h95
-rw-r--r--src/3rdparty/freetype/src/cff/cf2font.c512
-rw-r--r--src/3rdparty/freetype/src/cff/cf2font.h116
-rw-r--r--src/3rdparty/freetype/src/cff/cf2ft.c691
-rw-r--r--src/3rdparty/freetype/src/cff/cf2ft.h147
-rw-r--r--src/3rdparty/freetype/src/cff/cf2glue.h144
-rw-r--r--src/3rdparty/freetype/src/cff/cf2hints.c1847
-rw-r--r--src/3rdparty/freetype/src/cff/cf2hints.h289
-rw-r--r--src/3rdparty/freetype/src/cff/cf2intrp.c1545
-rw-r--r--src/3rdparty/freetype/src/cff/cf2intrp.h83
-rw-r--r--src/3rdparty/freetype/src/cff/cf2read.c112
-rw-r--r--src/3rdparty/freetype/src/cff/cf2read.h68
-rw-r--r--src/3rdparty/freetype/src/cff/cf2stack.c205
-rw-r--r--src/3rdparty/freetype/src/cff/cf2stack.h106
-rw-r--r--src/3rdparty/freetype/src/cff/cf2types.h78
-rw-r--r--src/3rdparty/freetype/src/cff/cff.c13
-rw-r--r--src/3rdparty/freetype/src/cff/cffcmap.c43
-rw-r--r--src/3rdparty/freetype/src/cff/cffdrivr.c352
-rw-r--r--src/3rdparty/freetype/src/cff/cfferrs.h3
-rw-r--r--src/3rdparty/freetype/src/cff/cffgload.c414
-rw-r--r--src/3rdparty/freetype/src/cff/cffgload.h41
-rw-r--r--src/3rdparty/freetype/src/cff/cffload.c341
-rw-r--r--src/3rdparty/freetype/src/cff/cffload.h18
-rw-r--r--src/3rdparty/freetype/src/cff/cffobjs.c342
-rw-r--r--src/3rdparty/freetype/src/cff/cffobjs.h14
-rw-r--r--src/3rdparty/freetype/src/cff/cffparse.c548
-rw-r--r--src/3rdparty/freetype/src/cff/cffparse.h6
-rw-r--r--src/3rdparty/freetype/src/cff/cffpic.c123
-rw-r--r--src/3rdparty/freetype/src/cff/cffpic.h90
-rw-r--r--src/3rdparty/freetype/src/cff/cfftoken.h114
-rw-r--r--src/3rdparty/freetype/src/cff/cfftypes.h30
-rw-r--r--src/3rdparty/freetype/src/cff/rules.mk26
-rw-r--r--src/3rdparty/freetype/src/cid/ciderrs.h3
-rw-r--r--src/3rdparty/freetype/src/cid/cidgload.c17
-rw-r--r--src/3rdparty/freetype/src/cid/cidload.c95
-rw-r--r--src/3rdparty/freetype/src/cid/cidobjs.c26
-rw-r--r--src/3rdparty/freetype/src/cid/cidparse.c16
-rw-r--r--src/3rdparty/freetype/src/cid/cidparse.h22
-rw-r--r--src/3rdparty/freetype/src/cid/cidriver.c32
-rw-r--r--src/3rdparty/freetype/src/cid/cidriver.h2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvbsln.c56
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvcommn.c335
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvcommn.h97
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxverror.h8
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvfeat.c67
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvjust.c275
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvkern.c218
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvlcar.c36
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmod.c12
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmod.h2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort.c76
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort.h14
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort0.c32
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort1.c69
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort2.c81
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort4.c18
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort5.c39
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx.c51
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx.h10
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx0.c24
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx1.c57
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx2.c86
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx4.c4
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx5.c42
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvopbd.c32
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvprop.c70
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvtrak.c65
-rw-r--r--src/3rdparty/freetype/src/gzip/ftgzip.c147
-rw-r--r--src/3rdparty/freetype/src/gzip/inftrees.c10
-rw-r--r--src/3rdparty/freetype/src/gzip/rules.mk57
-rw-r--r--src/3rdparty/freetype/src/gzip/zconf.h7
-rw-r--r--src/3rdparty/freetype/src/gzip/zlib.h7
-rw-r--r--src/3rdparty/freetype/src/lzw/ftlzw.c35
-rw-r--r--src/3rdparty/freetype/src/lzw/ftzopen.c26
-rw-r--r--src/3rdparty/freetype/src/lzw/ftzopen.h2
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvbase.c50
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvcommn.c170
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvcommn.h158
-rw-r--r--src/3rdparty/freetype/src/otvalid/otverror.h5
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvgdef.c36
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvgpos.c186
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvgsub.c108
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvjstf.c83
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvmath.c75
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvmod.c14
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvmod.h2
-rw-r--r--src/3rdparty/freetype/src/pcf/README26
-rw-r--r--src/3rdparty/freetype/src/pcf/pcf.h6
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfdrivr.c146
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfdrivr.h2
-rw-r--r--src/3rdparty/freetype/src/pcf/pcferror.h3
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfread.c260
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfutil.c12
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrcmap.c23
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrdrivr.c36
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrdrivr.h2
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrerror.h3
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrgload.c50
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrload.c35
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrobjs.c42
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrsbit.c22
-rw-r--r--src/3rdparty/freetype/src/psaux/afmparse.c52
-rw-r--r--src/3rdparty/freetype/src/psaux/afmparse.h3
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxerr.h3
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxmod.c2
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxmod.h2
-rw-r--r--src/3rdparty/freetype/src/psaux/psconv.c227
-rw-r--r--src/3rdparty/freetype/src/psaux/psconv.h10
-rw-r--r--src/3rdparty/freetype/src/psaux/psobjs.c174
-rw-r--r--src/3rdparty/freetype/src/psaux/t1cmap.c30
-rw-r--r--src/3rdparty/freetype/src/psaux/t1decode.c238
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshalgo.c32
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshalgo.h11
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshglob.c59
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshglob.h4
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshmod.c17
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshnterr.h3
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshpic.c45
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshpic.h24
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshrec.c54
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshrec.h4
-rw-r--r--src/3rdparty/freetype/src/pshinter/rules.mk7
-rw-r--r--src/3rdparty/freetype/src/psnames/psmodule.c74
-rw-r--r--src/3rdparty/freetype/src/psnames/psnamerr.h3
-rw-r--r--src/3rdparty/freetype/src/psnames/pspic.c70
-rw-r--r--src/3rdparty/freetype/src/psnames/pspic.h32
-rw-r--r--src/3rdparty/freetype/src/psnames/pstables.h5787
-rw-r--r--src/3rdparty/freetype/src/psnames/rules.mk11
-rw-r--r--src/3rdparty/freetype/src/raster/ftmisc.h37
-rw-r--r--src/3rdparty/freetype/src/raster/ftraster.c298
-rw-r--r--src/3rdparty/freetype/src/raster/ftrend1.c47
-rw-r--r--src/3rdparty/freetype/src/raster/rasterrs.h3
-rw-r--r--src/3rdparty/freetype/src/raster/rastpic.c68
-rw-r--r--src/3rdparty/freetype/src/raster/rastpic.h33
-rw-r--r--src/3rdparty/freetype/src/raster/rules.mk5
-rw-r--r--src/3rdparty/freetype/src/sfnt/pngshim.c377
-rw-r--r--src/3rdparty/freetype/src/sfnt/pngshim.h49
-rw-r--r--src/3rdparty/freetype/src/sfnt/rules.mk11
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfdriver.c370
-rw-r--r--src/3rdparty/freetype/src/sfnt/sferrors.h5
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfnt.c3
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfntpic.c126
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfntpic.h90
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfobjs.c635
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttbdf.c16
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttcmap.c507
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttcmap.h109
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttcmapc.h19
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttkern.c14
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttload.c144
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttmtx.c216
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttmtx.h4
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttpost.c90
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttsbit.c2253
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttsbit.h22
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttsbit0.c1011
-rw-r--r--src/3rdparty/freetype/src/smooth/ftgrays.c633
-rw-r--r--src/3rdparty/freetype/src/smooth/ftsmerrs.h3
-rw-r--r--src/3rdparty/freetype/src/smooth/ftsmooth.c188
-rw-r--r--src/3rdparty/freetype/src/smooth/ftspic.c79
-rw-r--r--src/3rdparty/freetype/src/smooth/ftspic.h38
-rw-r--r--src/3rdparty/freetype/src/smooth/rules.mk5
-rw-r--r--src/3rdparty/freetype/src/tools/afblue.pl548
-rw-r--r--src/3rdparty/freetype/src/tools/apinames.c55
-rw-r--r--src/3rdparty/freetype/src/tools/chktrcmp.py4
-rw-r--r--src/3rdparty/freetype/src/tools/cordic.py62
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/content.py229
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/docmaker.py39
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/formatter.py73
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/sources.py236
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/tohtml.py478
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/utils.py81
-rw-r--r--src/3rdparty/freetype/src/tools/ftrandom/README2
-rw-r--r--src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c38
-rw-r--r--src/3rdparty/freetype/src/tools/glnames.py214
-rw-r--r--src/3rdparty/freetype/src/tools/test_afm.c2
-rw-r--r--src/3rdparty/freetype/src/tools/test_bbox.c34
-rw-r--r--src/3rdparty/freetype/src/tools/test_trig.c98
-rw-r--r--src/3rdparty/freetype/src/truetype/rules.mk12
-rw-r--r--src/3rdparty/freetype/src/truetype/truetype.c3
-rw-r--r--src/3rdparty/freetype/src/truetype/ttdriver.c186
-rw-r--r--src/3rdparty/freetype/src/truetype/tterrors.h3
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgload.c890
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgload.h5
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgxvar.c130
-rw-r--r--src/3rdparty/freetype/src/truetype/ttinterp.c2676
-rw-r--r--src/3rdparty/freetype/src/truetype/ttinterp.h111
-rw-r--r--src/3rdparty/freetype/src/truetype/ttobjs.c545
-rw-r--r--src/3rdparty/freetype/src/truetype/ttobjs.h43
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpic.c74
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpic.h48
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpload.c83
-rw-r--r--src/3rdparty/freetype/src/truetype/ttsubpix.c1011
-rw-r--r--src/3rdparty/freetype/src/truetype/ttsubpix.h110
-rw-r--r--src/3rdparty/freetype/src/type1/t1afm.c28
-rw-r--r--src/3rdparty/freetype/src/type1/t1driver.c468
-rw-r--r--src/3rdparty/freetype/src/type1/t1driver.h2
-rw-r--r--src/3rdparty/freetype/src/type1/t1errors.h3
-rw-r--r--src/3rdparty/freetype/src/type1/t1gload.c90
-rw-r--r--src/3rdparty/freetype/src/type1/t1gload.h10
-rw-r--r--src/3rdparty/freetype/src/type1/t1load.c272
-rw-r--r--src/3rdparty/freetype/src/type1/t1objs.c84
-rw-r--r--src/3rdparty/freetype/src/type1/t1objs.h31
-rw-r--r--src/3rdparty/freetype/src/type1/t1parse.c76
-rw-r--r--src/3rdparty/freetype/src/type1/t1tokens.h2
-rw-r--r--src/3rdparty/freetype/src/type42/t42drivr.c62
-rw-r--r--src/3rdparty/freetype/src/type42/t42drivr.h2
-rw-r--r--src/3rdparty/freetype/src/type42/t42error.h3
-rw-r--r--src/3rdparty/freetype/src/type42/t42objs.c135
-rw-r--r--src/3rdparty/freetype/src/type42/t42objs.h22
-rw-r--r--src/3rdparty/freetype/src/type42/t42parse.c159
-rw-r--r--src/3rdparty/freetype/src/winfonts/fnterrs.h3
-rw-r--r--src/3rdparty/freetype/src/winfonts/winfnt.c205
-rw-r--r--src/3rdparty/freetype/src/winfonts/winfnt.h2
324 files changed, 37955 insertions, 16893 deletions
diff --git a/src/3rdparty/freetype/src/Jamfile b/src/3rdparty/freetype/src/Jamfile
index 76ee0f46e6..1cc06858c0 100644
--- a/src/3rdparty/freetype/src/Jamfile
+++ b/src/3rdparty/freetype/src/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src Jamfile
#
-# Copyright 2001, 2002 by
+# Copyright 2001, 2002, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -11,7 +11,7 @@
SubDir FT2_TOP $(FT2_SRC_DIR) ;
-# The file <freetype/internal/internal.h> is used to define macros that are
+# The file <internal/internal.h> is used to define macros that are
# later used in #include statements. It needs to be parsed in order to
# record these definitions.
#
diff --git a/src/3rdparty/freetype/src/autofit/afangles.c b/src/3rdparty/freetype/src/autofit/afangles.c
index e2360d157d..f8b095bef3 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, 2004, 2005, 2006 by */
+/* Copyright 2003-2006, 2011-2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,66 +20,6 @@
#include "aftypes.h"
-#if 0
-
- FT_LOCAL_DEF( FT_Int )
- af_corner_is_flat( FT_Pos x_in,
- FT_Pos y_in,
- FT_Pos x_out,
- FT_Pos y_out )
- {
- FT_Pos ax = x_in;
- FT_Pos ay = y_in;
-
- FT_Pos d_in, d_out, d_corner;
-
-
- if ( ax < 0 )
- ax = -ax;
- if ( ay < 0 )
- ay = -ay;
- d_in = ax + ay;
-
- ax = x_out;
- if ( ax < 0 )
- ax = -ax;
- ay = y_out;
- if ( ay < 0 )
- ay = -ay;
- d_out = ax + ay;
-
- ax = x_out + x_in;
- if ( ax < 0 )
- ax = -ax;
- ay = y_out + y_in;
- if ( ay < 0 )
- ay = -ay;
- d_corner = ax + ay;
-
- return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
- }
-
-
- FT_LOCAL_DEF( FT_Int )
- af_corner_orientation( FT_Pos x_in,
- FT_Pos y_in,
- FT_Pos x_out,
- FT_Pos y_out )
- {
- FT_Pos delta;
-
-
- delta = x_in * y_out - y_in * x_out;
-
- if ( delta == 0 )
- return 0;
- else
- return 1 - 2 * ( delta < 0 );
- }
-
-#endif
-
-
/*
* We are not using `af_angle_atan' anymore, but we keep the source
* code below just in case...
@@ -255,7 +195,7 @@
{
for ( j = i; j > 0; j-- )
{
- if ( table[j] > table[j - 1] )
+ if ( table[j] >= table[j - 1] )
break;
swap = table[j];
@@ -267,18 +207,26 @@
FT_LOCAL_DEF( void )
- af_sort_widths( FT_UInt count,
- AF_Width table )
+ af_sort_and_quantize_widths( FT_UInt* count,
+ AF_Width table,
+ FT_Pos threshold )
{
FT_UInt i, j;
+ FT_UInt cur_idx;
+ FT_Pos cur_val;
+ FT_Pos sum;
AF_WidthRec swap;
- for ( i = 1; i < count; i++ )
+ if ( *count == 1 )
+ return;
+
+ /* sort */
+ for ( i = 1; i < *count; i++ )
{
for ( j = i; j > 0; j-- )
{
- if ( table[j].org > table[j - 1].org )
+ if ( table[j].org >= table[j - 1].org )
break;
swap = table[j];
@@ -286,6 +234,51 @@
table[j - 1] = swap;
}
}
+
+ cur_idx = 0;
+ cur_val = table[cur_idx].org;
+
+ /* compute and use mean values for clusters not larger than */
+ /* `threshold'; this is very primitive and might not yield */
+ /* the best result, but normally, using reference character */
+ /* `o', `*count' is 2, so the code below is fully sufficient */
+ for ( i = 1; i < *count; i++ )
+ {
+ if ( table[i].org - cur_val > threshold ||
+ i == *count - 1 )
+ {
+ sum = 0;
+
+ /* fix loop for end of array */
+ if ( table[i].org - cur_val <= threshold &&
+ i == *count - 1 )
+ i++;
+
+ for ( j = cur_idx; j < i; j++ )
+ {
+ sum += table[j].org;
+ table[j].org = 0;
+ }
+ table[cur_idx].org = sum / j;
+
+ if ( i < *count - 1 )
+ {
+ cur_idx = i + 1;
+ cur_val = table[cur_idx].org;
+ }
+ }
+ }
+
+ cur_idx = 1;
+
+ /* compress array to remove zero values */
+ for ( i = 1; i < *count; i++ )
+ {
+ if ( table[i].org )
+ table[cur_idx++] = table[i];
+ }
+
+ *count = cur_idx;
}
diff --git a/src/3rdparty/freetype/src/autofit/afblue.c b/src/3rdparty/freetype/src/autofit/afblue.c
new file mode 100644
index 0000000000..811226eac3
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afblue.c
@@ -0,0 +1,177 @@
+/* This file has been generated by the Perl script `afblue.pl', */
+/* using data from file `afblue.dat'. */
+
+/***************************************************************************/
+/* */
+/* afblue.c */
+/* */
+/* Auto-fitter data for blue strings (body). */
+/* */
+/* Copyright 2013 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 "aftypes.h"
+
+
+ FT_LOCAL_ARRAY_DEF( char )
+ af_blue_strings[] =
+ {
+ /* */
+ '\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',
+ '\xE0', '\xA4', '\x95', '\xE0', '\xA4', '\xAE', '\xE0', '\xA4', '\x85', '\xE0', '\xA4', '\x86', '\xE0', '\xA4', '\xA5', '\xE0', '\xA4', '\xA7', '\xE0', '\xA4', '\xAD', '\xE0', '\xA4', '\xB6', /* क म अ आ थ ध भ श */
+ '\0',
+ '\xE0', '\xA4', '\x88', '\xE0', '\xA4', '\x90', '\xE0', '\xA4', '\x93', '\xE0', '\xA4', '\x94', '\xE0', '\xA4', '\xBF', '\xE0', '\xA5', '\x80', '\xE0', '\xA5', '\x8B', '\xE0', '\xA5', '\x8C', /* ई ऐ ओ औ ि ी ो ौ */
+ '\0',
+ '\xE0', '\xA4', '\x95', '\xE0', '\xA4', '\xAE', '\xE0', '\xA4', '\x85', '\xE0', '\xA4', '\x86', '\xE0', '\xA4', '\xA5', '\xE0', '\xA4', '\xA7', '\xE0', '\xA4', '\xAD', '\xE0', '\xA4', '\xB6', /* क म अ आ थ ध भ श */
+ '\0',
+ '\xE0', '\xA5', '\x81', '\xE0', '\xA5', '\x83', /* ु ृ */
+ '\0',
+ '\xCE', '\x93', '\xCE', '\x92', '\xCE', '\x95', '\xCE', '\x96', '\xCE', '\x98', '\xCE', '\x9F', '\xCE', '\xA9', /* ΓΒΕΖΘΟΩ */
+ '\0',
+ '\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',
+ '\xCE', '\xB1', '\xCE', '\xB5', '\xCE', '\xB9', '\xCE', '\xBF', '\xCF', '\x80', '\xCF', '\x83', '\xCF', '\x84', '\xCF', '\x89', /* αειοπστω */
+ '\0',
+ '\xCE', '\xB2', '\xCE', '\xB3', '\xCE', '\xB7', '\xCE', '\xBC', '\xCF', '\x81', '\xCF', '\x86', '\xCF', '\x87', '\xCF', '\x88', /* βγημρφχψ */
+ '\0',
+ '\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', /* בטכםסצ */
+ '\0',
+ '\xD7', '\xA7', '\xD7', '\x9A', '\xD7', '\x9F', '\xD7', '\xA3', '\xD7', '\xA5', /* קךןףץ */
+ '\0',
+ 'T', 'H', 'E', 'Z', 'O', 'C', 'Q', 'S', /* THEZOCQS */
+ '\0',
+ 'H', 'E', 'Z', 'L', 'O', 'C', 'U', 'S', /* HEZLOCUS */
+ '\0',
+ 'f', 'i', 'j', 'k', 'd', 'b', 'h', /* fijkdbh */
+ '\0',
+ 'x', 'z', 'r', 'o', 'e', 's', 'c', /* xzroesc */
+ '\0',
+ 'p', 'q', 'g', 'j', 'y', /* pqgjy */
+ '\0',
+ '\xE0', '\xB0', '\x87', '\xE0', '\xB0', '\x8C', '\xE0', '\xB0', '\x99', '\xE0', '\xB0', '\x9E', '\xE0', '\xB0', '\xA3', '\xE0', '\xB0', '\xB1', '\xE0', '\xB1', '\xAF', /* ఇ ఌ ఙ ఞ ణ ఱ ౯ */
+ '\0',
+ '\xE0', '\xB0', '\x85', '\xE0', '\xB0', '\x95', '\xE0', '\xB0', '\x9A', '\xE0', '\xB0', '\xB0', '\xE0', '\xB0', '\xBD', '\xE0', '\xB1', '\xA8', '\xE0', '\xB1', '\xAC', /* అ క చ ర ఽ ౨ ౬ */
+#ifdef AF_CONFIG_OPTION_CJK
+ '\0',
+ '\xE4', '\xBB', '\x96', '\xE4', '\xBB', '\xAC', '\xE4', '\xBD', '\xA0', '\xE4', '\xBE', '\x86', '\xE5', '\x80', '\x91', '\xE5', '\x88', '\xB0', '\xE5', '\x92', '\x8C', '\xE5', '\x9C', '\xB0', /* 他们你來們到和地 */
+ '\xE5', '\xAF', '\xB9', '\xE5', '\xB0', '\x8D', '\xE5', '\xB0', '\xB1', '\xE5', '\xB8', '\xAD', '\xE6', '\x88', '\x91', '\xE6', '\x97', '\xB6', '\xE6', '\x99', '\x82', '\xE6', '\x9C', '\x83', /* 对對就席我时時會 */
+ '\xE6', '\x9D', '\xA5', '\xE7', '\x82', '\xBA', '\xE8', '\x83', '\xBD', '\xE8', '\x88', '\xB0', '\xE8', '\xAA', '\xAA', '\xE8', '\xAF', '\xB4', '\xE8', '\xBF', '\x99', '\xE9', '\x80', '\x99', /* 来為能舰說说这這 */
+ '\xE9', '\xBD', '\x8A', '|', /* 齊 | */
+ '\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', /* 间 */
+#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
+#endif /* AF_CONFIG_OPTION_CJK */
+ '\0',
+
+ };
+
+
+ /* stringsets are specific to styles */
+ FT_LOCAL_ARRAY_DEF( AF_Blue_StringRec )
+ af_blue_stringsets[] =
+ {
+ /* */
+ { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM, 0 },
+ { AF_BLUE_STRING_CYRILLIC_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_CYRILLIC_SMALL, 0 },
+ { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_DEVANAGARI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_DEVANAGARI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_DEVANAGARI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_NEUTRAL |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_DEVANAGARI_BASE, 0 },
+ { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_GREEK_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 },
+ { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GREEK_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_GREEK_SMALL, 0 },
+ { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_LONG },
+ { AF_BLUE_STRING_HEBREW_BOTTOM, 0 },
+ { AF_BLUE_STRING_HEBREW_DESCENDER, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 },
+ { AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_LATIN_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_LATIN_SMALL, 0 },
+ { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_TELUGU_BOTTOM, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+#ifdef AF_CONFIG_OPTION_CJK
+ { AF_BLUE_STRING_CJK_TOP, AF_BLUE_PROPERTY_CJK_TOP },
+ { AF_BLUE_STRING_CJK_BOTTOM, 0 },
+#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
+ { AF_BLUE_STRING_CJK_LEFT, AF_BLUE_PROPERTY_CJK_HORIZ },
+ { AF_BLUE_STRING_CJK_RIGHT, AF_BLUE_PROPERTY_CJK_HORIZ |
+ AF_BLUE_PROPERTY_CJK_RIGHT },
+#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
+ { AF_BLUE_STRING_MAX, 0 },
+#endif /* AF_CONFIG_OPTION_CJK */
+
+ };
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afblue.cin b/src/3rdparty/freetype/src/autofit/afblue.cin
new file mode 100644
index 0000000000..c6762bec30
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afblue.cin
@@ -0,0 +1,39 @@
+/***************************************************************************/
+/* */
+/* afblue.c */
+/* */
+/* Auto-fitter data for blue strings (body). */
+/* */
+/* Copyright 2013 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 "aftypes.h"
+
+
+ FT_LOCAL_ARRAY_DEF( char )
+ af_blue_strings[] =
+ {
+ /* */
+@AF_BLUE_STRINGS_ARRAY@
+ };
+
+
+ /* stringsets are specific to styles */
+ FT_LOCAL_ARRAY_DEF( AF_Blue_StringRec )
+ af_blue_stringsets[] =
+ {
+ /* */
+@AF_BLUE_STRINGSETS_ARRAY@
+ };
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afblue.dat b/src/3rdparty/freetype/src/autofit/afblue.dat
new file mode 100644
index 0000000000..3f98c13b24
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afblue.dat
@@ -0,0 +1,337 @@
+// afblue.dat
+//
+// Auto-fitter data for blue strings.
+//
+// Copyright 2013, 2014 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.
+
+
+// This file contains data specific to blue zones. It gets processed by
+// a script to simulate `jagged arrays', with enumeration values holding
+// offsets into the arrays.
+//
+// The format of the file is rather simple: A section starts with three
+// 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).
+//
+// 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
+// remaining lines the corresponding array data.
+//
+// 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.
+//
+// - Data blocks enclosed in balanced braces, which get copied verbatim and
+// which can span multiple lines. The opening brace of a block must be
+// the first character of a line (ignoring whitespace), and the closing
+// brace the last (ignoring whitespace also). The script appends a comma
+// character after each block and counts the number of blocks to set the
+// enumeration values.
+//
+// A section can contain either strings only or data blocks only.
+//
+// A comment line starts with `//'; it gets removed. A preprocessor
+// directive line (using the standard syntax of `cpp') starts with `#' and
+// gets copied verbatim to both the enumeration and the array. Whitespace
+// outside of a string is insignificant.
+//
+// Preprocessor directives are ignored while the script computes maximum
+// 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
+// characters, not bytes.
+
+
+// The blue zone string data, to be used in the blue stringsets below.
+
+AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
+
+ AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP
+ "БВЕПЗОСЭ"
+ AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
+ "БВЕШЗОСЭ"
+ AF_BLUE_STRING_CYRILLIC_SMALL
+ "хпншезос"
+ AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
+ "руф"
+
+ // we separate the letters with spaces to avoid ligatures;
+ // this is just for convenience to simplify reading
+ AF_BLUE_STRING_DEVANAGARI_BASE
+ "क म अ आ थ ध भ श"
+ AF_BLUE_STRING_DEVANAGARI_TOP
+ "ई ऐ ओ औ ि ी ो ौ"
+ // note that some fonts have extreme variation in the height of the
+ // round head elements; for this reason we also define the `base'
+ // blue zone, which must be always present
+ AF_BLUE_STRING_DEVANAGARI_HEAD
+ "क म अ आ थ ध भ श"
+ AF_BLUE_STRING_DEVANAGARI_BOTTOM
+ "ु ृ"
+
+ AF_BLUE_STRING_GREEK_CAPITAL_TOP
+ "ΓΒΕΖΘΟΩ"
+ 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_HEBREW_TOP
+ "בדהחךכםס"
+ AF_BLUE_STRING_HEBREW_BOTTOM
+ "בטכםסצ"
+ AF_BLUE_STRING_HEBREW_DESCENDER
+ "קךןףץ"
+
+ AF_BLUE_STRING_LATIN_CAPITAL_TOP
+ "THEZOCQS"
+ AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM
+ "HEZLOCUS"
+ AF_BLUE_STRING_LATIN_SMALL_F_TOP
+ "fijkdbh"
+ AF_BLUE_STRING_LATIN_SMALL
+ "xzroesc"
+ AF_BLUE_STRING_LATIN_SMALL_DESCENDER
+ "pqgjy"
+
+ // we separate the letters with spaces to avoid ligatures;
+ // this is just for convenience to simplify reading
+ AF_BLUE_STRING_TELUGU_TOP
+ "ఇ ఌ ఙ ఞ ణ ఱ ౯"
+
+ AF_BLUE_STRING_TELUGU_BOTTOM
+ "అ క చ ర ఽ ౨ ౬"
+
+#ifdef AF_CONFIG_OPTION_CJK
+
+ AF_BLUE_STRING_CJK_TOP
+ "他们你來們到和地"
+ "对對就席我时時會"
+ "来為能舰說说这這"
+ "齊 |"
+ "军同已愿既星是景"
+ "民照现現理用置要"
+ "軍那配里開雷露面"
+ "顾"
+ 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 */
+
+#endif /* AF_CONFIG_OPTION_CJK */
+
+
+// The blue zone stringsets, as used in the script styles, cf. `afstyles.h'.
+//
+// The AF_BLUE_PROPERTY_XXX flags are defined in `afblue.h'; here some
+// explanations.
+//
+// A blue zone in general is defined by a reference and an overshoot line.
+// During the hinting process, all coordinate values between those two lines
+// are set equal to the reference value, provided that the blue zone is not
+// wider than 0.75 pixels (otherwise the blue zone gets ignored). All
+// entries must have `AF_BLUE_STRING_MAX' as the final line.
+//
+// During the glyph analysis, edges are sorted from bottom to top, and then
+// sequentially checked, edge by edge, against the blue zones in the order
+// given below.
+//
+//
+// latin auto-hinter
+// -----------------
+//
+// Characters in a blue string are automatically classified as having a flat
+// (reference) or a round (overshoot) extremum. The blue zone is then set
+// up by the mean values of all flat extrema and all round extrema,
+// respectively. Only horizontal blue zones (i.e., adjusting vertical
+// coordinate values) are supported.
+//
+// For the latin auto-hinter, the overshoot should be larger than the
+// reference for top zones, and vice versa for bottom zones.
+//
+// LATIN_TOP
+// Take the maximum flat and round coordinate values of the blue string
+// characters for computing the blue zone's reference and overshoot
+// values.
+//
+// If not set, take the minimum values.
+//
+// LATIN_NEUTRAL
+// Ignore round extrema and define the blue zone with flat values only.
+// Both top and bottom of contours can match. This is useful for
+// scripts like Devanagari where vowel signs attach to the base
+// character and are implemented as components of composite glyphs.
+//
+// If not set, both round and flat extrema are taken into account.
+// Additionally, only the top or the bottom of a contour can match,
+// depending on the LATIN_TOP flag.
+//
+// Neutral blue zones should always follow non-neutral blue zones.
+//
+// LATIN_X_HEIGHT
+// Scale all glyphs vertically from the corresponding script to make the
+// reference line of this blue zone align on the grid. The scaling
+// takes place before all other blue zones get aligned to the grid.
+// Only one blue character string of a script style can have this flag.
+//
+// LATIN_LONG
+// Apply an additional constraint for blue zone values: Don't
+// necessarily use the extremum as-is but a segment of the topmost (or
+// bottommost) contour that is longer than a heuristic threshold, and
+// which is not too far away vertically from the real extremum. This
+// ensures that small bumps in the outline are ignored (for example, the
+// `vertical serifs' found in many Hebrew glyph designs).
+//
+// The segment must be at least EM/25 font units long, and the distance
+// to the extremum must be smaller than EM/4.
+//
+//
+// cjk auto-hinter
+// ---------------
+//
+// Characters in a blue string are *not* automatically classified. Instead,
+// first come the characters used for the overshoot value, then the
+// character `|', then the characters used for the reference value. The
+// blue zone is then set up by the mean values of all reference values and
+// all overshoot values, respectively. Both horizontal and vertical blue
+// zones (i.e., adjusting vertical and horizontal coordinate values,
+// respectively) are supported.
+//
+// For the cjk auto-hinter, the overshoot should be smaller than the
+// reference for top zones, and vice versa for bottom zones.
+//
+// CJK_TOP
+// Take the maximum flat and round coordinate values of the blue string
+// characters. If not set, take the minimum values.
+//
+// CJK_RIGHT
+// A synonym for CJK_TOP. If CJK_HORIZ is set, this flag indicates the
+// right blue zone, taking horizontal maximum values.
+//
+// CJK_HORIZ
+// Define a blue zone for horizontal hinting (i.e., vertical blue
+// zones). If not set, this is a blue zone for vertical hinting.
+
+
+AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
+
+ AF_BLUE_STRINGSET_CYRL
+ { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM, 0 }
+ { AF_BLUE_STRING_CYRILLIC_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_CYRILLIC_SMALL, 0 }
+ { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_DEVA
+ { AF_BLUE_STRING_DEVANAGARI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_DEVANAGARI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_DEVANAGARI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_NEUTRAL |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_DEVANAGARI_BASE, 0 }
+ { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_GREK
+ { AF_BLUE_STRING_GREEK_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 }
+ { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GREEK_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_GREEK_SMALL, 0 }
+ { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_HEBR
+ { AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_LONG }
+ { AF_BLUE_STRING_HEBREW_BOTTOM, 0 }
+ { AF_BLUE_STRING_HEBREW_DESCENDER, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_LATN
+ { AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 }
+ { AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_LATIN_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_LATIN_SMALL, 0 }
+ { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_TELU
+ { AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_TELUGU_BOTTOM, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+#ifdef AF_CONFIG_OPTION_CJK
+
+ AF_BLUE_STRINGSET_HANI
+ { AF_BLUE_STRING_CJK_TOP, AF_BLUE_PROPERTY_CJK_TOP }
+ { AF_BLUE_STRING_CJK_BOTTOM, 0 }
+#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
+ { AF_BLUE_STRING_CJK_LEFT, AF_BLUE_PROPERTY_CJK_HORIZ }
+ { AF_BLUE_STRING_CJK_RIGHT, AF_BLUE_PROPERTY_CJK_HORIZ |
+ AF_BLUE_PROPERTY_CJK_RIGHT }
+#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
+ { AF_BLUE_STRING_MAX, 0 }
+
+#endif /* AF_CONFIG_OPTION_CJK */
+
+
+// END
diff --git a/src/3rdparty/freetype/src/autofit/afblue.h b/src/3rdparty/freetype/src/autofit/afblue.h
new file mode 100644
index 0000000000..a86184191d
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afblue.h
@@ -0,0 +1,203 @@
+/* This file has been generated by the Perl script `afblue.pl', */
+/* using data from file `afblue.dat'. */
+
+/***************************************************************************/
+/* */
+/* afblue.h */
+/* */
+/* Auto-fitter data for blue strings (specification). */
+/* */
+/* Copyright 2013, 2014 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 __AFBLUE_H__
+#define __AFBLUE_H__
+
+
+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 ); \
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** B L U E S T R I N G S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* At the bottommost level, we define strings for finding blue zones. */
+
+
+#define AF_BLUE_STRING_MAX_LEN 51
+
+ /* The AF_Blue_String enumeration values are offsets into the */
+ /* `af_blue_strings' array. */
+
+ typedef enum AF_Blue_String_
+ {
+ AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 0,
+ AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 17,
+ AF_BLUE_STRING_CYRILLIC_SMALL = 34,
+ AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 51,
+ AF_BLUE_STRING_DEVANAGARI_BASE = 58,
+ AF_BLUE_STRING_DEVANAGARI_TOP = 83,
+ AF_BLUE_STRING_DEVANAGARI_HEAD = 108,
+ AF_BLUE_STRING_DEVANAGARI_BOTTOM = 133,
+ AF_BLUE_STRING_GREEK_CAPITAL_TOP = 140,
+ AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 155,
+ AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 168,
+ AF_BLUE_STRING_GREEK_SMALL = 181,
+ AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 198,
+ AF_BLUE_STRING_HEBREW_TOP = 215,
+ AF_BLUE_STRING_HEBREW_BOTTOM = 232,
+ AF_BLUE_STRING_HEBREW_DESCENDER = 245,
+ AF_BLUE_STRING_LATIN_CAPITAL_TOP = 256,
+ AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 265,
+ AF_BLUE_STRING_LATIN_SMALL_F_TOP = 274,
+ AF_BLUE_STRING_LATIN_SMALL = 282,
+ AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 290,
+ AF_BLUE_STRING_TELUGU_TOP = 296,
+ AF_BLUE_STRING_TELUGU_BOTTOM = 318,
+ af_blue_1_1 = 339,
+#ifdef AF_CONFIG_OPTION_CJK
+ AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
+ AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 153,
+ af_blue_1_1_1 = af_blue_1_1 + 304,
+#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
+ AF_BLUE_STRING_CJK_LEFT = af_blue_1_1_1 + 1,
+ AF_BLUE_STRING_CJK_RIGHT = af_blue_1_1_1 + 153,
+ af_blue_1_1_2 = af_blue_1_1_1 + 304,
+#else
+ af_blue_1_1_2 = af_blue_1_1_1 + 0,
+#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
+ af_blue_1_2 = af_blue_1_1_2 + 0,
+#else
+ af_blue_1_2 = af_blue_1_1 + 0,
+#endif /* AF_CONFIG_OPTION_CJK */
+
+
+ AF_BLUE_STRING_MAX /* do not remove */
+
+ } AF_Blue_String;
+
+
+ FT_LOCAL_ARRAY( char )
+ af_blue_strings[];
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** B L U E S T R I N G S E T S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* The next level is to group blue strings into style-specific sets. */
+
+
+ /* Properties are specific to a writing system. We assume that a given */
+ /* blue string can't be used in more than a single writing system, which */
+ /* is a safe bet. */
+#define AF_BLUE_PROPERTY_LATIN_TOP ( 1 << 0 ) /* must have value 1 */
+#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1 << 1 )
+#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1 << 2 )
+#define AF_BLUE_PROPERTY_LATIN_LONG ( 1 << 3 )
+
+#define AF_BLUE_PROPERTY_CJK_TOP ( 1 << 0 ) /* must have value 1 */
+#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1 << 1 ) /* must have value 2 */
+#define AF_BLUE_PROPERTY_CJK_RIGHT AF_BLUE_PROPERTY_CJK_TOP
+
+
+#define AF_BLUE_STRINGSET_MAX_LEN 7
+
+ /* The AF_Blue_Stringset enumeration values are offsets into the */
+ /* `af_blue_stringsets' array. */
+
+ typedef enum AF_Blue_Stringset_
+ {
+ AF_BLUE_STRINGSET_CYRL = 0,
+ AF_BLUE_STRINGSET_DEVA = 6,
+ AF_BLUE_STRINGSET_GREK = 12,
+ AF_BLUE_STRINGSET_HEBR = 19,
+ AF_BLUE_STRINGSET_LATN = 23,
+ AF_BLUE_STRINGSET_TELU = 30,
+ af_blue_2_1 = 33,
+#ifdef AF_CONFIG_OPTION_CJK
+ AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
+ af_blue_2_1_1 = af_blue_2_1 + 2,
+#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
+ af_blue_2_1_2 = af_blue_2_1_1 + 2,
+#else
+ af_blue_2_1_2 = af_blue_2_1_1 + 0,
+#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
+ af_blue_2_2 = af_blue_2_1_2 + 1,
+#else
+ af_blue_2_2 = af_blue_2_1 + 0,
+#endif /* AF_CONFIG_OPTION_CJK */
+
+
+ AF_BLUE_STRINGSET_MAX /* do not remove */
+
+ } AF_Blue_Stringset;
+
+
+ typedef struct AF_Blue_StringRec_
+ {
+ AF_Blue_String string;
+ FT_UShort properties;
+
+ } AF_Blue_StringRec;
+
+
+ FT_LOCAL_ARRAY( AF_Blue_StringRec )
+ af_blue_stringsets[];
+
+/* */
+
+FT_END_HEADER
+
+
+#endif /* __AFBLUE_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afblue.hin b/src/3rdparty/freetype/src/autofit/afblue.hin
new file mode 100644
index 0000000000..0b4b48d7fe
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afblue.hin
@@ -0,0 +1,142 @@
+/***************************************************************************/
+/* */
+/* afblue.h */
+/* */
+/* Auto-fitter data for blue strings (specification). */
+/* */
+/* Copyright 2013, 2014 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 __AFBLUE_H__
+#define __AFBLUE_H__
+
+
+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 ); \
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** B L U E S T R I N G S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* At the bottommost level, we define strings for finding blue zones. */
+
+
+#define AF_BLUE_STRING_MAX_LEN @AF_BLUE_STRING_MAX_LEN@
+
+ /* The AF_Blue_String enumeration values are offsets into the */
+ /* `af_blue_strings' array. */
+
+ typedef enum AF_Blue_String_
+ {
+@AF_BLUE_STRING_ENUM@
+
+ AF_BLUE_STRING_MAX /* do not remove */
+
+ } AF_Blue_String;
+
+
+ FT_LOCAL_ARRAY( char )
+ af_blue_strings[];
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** B L U E S T R I N G S E T S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* The next level is to group blue strings into style-specific sets. */
+
+
+ /* Properties are specific to a writing system. We assume that a given */
+ /* blue string can't be used in more than a single writing system, which */
+ /* is a safe bet. */
+#define AF_BLUE_PROPERTY_LATIN_TOP ( 1 << 0 ) /* must have value 1 */
+#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1 << 1 )
+#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1 << 2 )
+#define AF_BLUE_PROPERTY_LATIN_LONG ( 1 << 3 )
+
+#define AF_BLUE_PROPERTY_CJK_TOP ( 1 << 0 ) /* must have value 1 */
+#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1 << 1 ) /* must have value 2 */
+#define AF_BLUE_PROPERTY_CJK_RIGHT AF_BLUE_PROPERTY_CJK_TOP
+
+
+#define AF_BLUE_STRINGSET_MAX_LEN @AF_BLUE_STRINGSET_MAX_LEN@
+
+ /* The AF_Blue_Stringset enumeration values are offsets into the */
+ /* `af_blue_stringsets' array. */
+
+ typedef enum AF_Blue_Stringset_
+ {
+@AF_BLUE_STRINGSET_ENUM@
+
+ AF_BLUE_STRINGSET_MAX /* do not remove */
+
+ } AF_Blue_Stringset;
+
+
+ typedef struct AF_Blue_StringRec_
+ {
+ AF_Blue_String string;
+ FT_UShort properties;
+
+ } AF_Blue_StringRec;
+
+
+ FT_LOCAL_ARRAY( AF_Blue_StringRec )
+ af_blue_stringsets[];
+
+/* */
+
+FT_END_HEADER
+
+
+#endif /* __AFBLUE_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afcjk.c b/src/3rdparty/freetype/src/autofit/afcjk.c
index bab0c42bad..048e0e7d02 100644
--- a/src/3rdparty/freetype/src/autofit/afcjk.c
+++ b/src/3rdparty/freetype/src/autofit/afcjk.c
@@ -2,9 +2,9 @@
/* */
/* afcjk.c */
/* */
-/* Auto-fitter hinting routines for CJK script (body). */
+/* Auto-fitter hinting routines for CJK writing system (body). */
/* */
-/* Copyright 2006, 2007, 2008, 2009 by */
+/* Copyright 2006-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,22 +22,39 @@
*
*/
-#include "aftypes.h"
+#include <ft2build.h>
+#include FT_ADVANCES_H
+#include FT_INTERNAL_DEBUG_H
+
+#include "afglobal.h"
+#include "afpic.h"
#include "aflatin.h"
#ifdef AF_CONFIG_OPTION_CJK
+#undef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
+
#include "afcjk.h"
#include "aferrors.h"
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
#include "afwarp.h"
#endif
/*************************************************************************/
+ /* */
+ /* 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_afcjk
+
+
+ /*************************************************************************/
/*************************************************************************/
/***** *****/
/***** C J K G L O B A L M E T R I C S *****/
@@ -45,59 +62,625 @@
/*************************************************************************/
/*************************************************************************/
+
+ /* Basically the Latin version with AF_CJKMetrics */
+ /* to replace AF_LatinMetrics. */
+
+ FT_LOCAL_DEF( void )
+ af_cjk_metrics_init_widths( AF_CJKMetrics metrics,
+ FT_Face face )
+ {
+ /* scan the array of segments in each direction */
+ AF_GlyphHintsRec hints[1];
+
+
+ FT_TRACE5(( "\n"
+ "cjk standard widths computation (style `%s')\n"
+ "===================================================\n"
+ "\n",
+ af_style_names[metrics->root.style_class->style] ));
+
+ af_glyph_hints_init( hints, face->memory );
+
+ metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
+ metrics->axis[AF_DIMENSION_VERT].width_count = 0;
+
+ {
+ FT_Error error;
+ FT_ULong glyph_index;
+ FT_Long y_offset;
+ int dim;
+ AF_CJKMetricsRec dummy[1];
+ AF_Scaler scaler = &dummy->root.scaler;
+
+#ifdef FT_CONFIG_OPTION_PIC
+ AF_FaceGlobals globals = metrics->root.globals;
+#endif
+
+ AF_StyleClass style_class = metrics->root.style_class;
+ AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
+ [style_class->script];
+
+ FT_UInt32 standard_char;
+
+
+ standard_char = script_class->standard_char1;
+ af_get_char_index( &metrics->root,
+ standard_char,
+ &glyph_index,
+ &y_offset );
+ if ( !glyph_index )
+ {
+ 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;
+ }
+
+ FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
+ standard_char, glyph_index ));
+
+ error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
+ if ( error || face->glyph->outline.n_points <= 0 )
+ goto Exit;
+
+ FT_ZERO( dummy );
+
+ dummy->units_per_em = metrics->units_per_em;
+
+ scaler->x_scale = 0x10000L;
+ scaler->y_scale = 0x10000L;
+ scaler->x_delta = 0;
+ scaler->y_delta = 0;
+
+ scaler->face = face;
+ scaler->render_mode = FT_RENDER_MODE_NORMAL;
+ scaler->flags = 0;
+
+ af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
+
+ error = af_glyph_hints_reload( hints, &face->glyph->outline );
+ if ( error )
+ goto Exit;
+
+ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
+ {
+ AF_CJKAxis axis = &metrics->axis[dim];
+ AF_AxisHints axhints = &hints->axis[dim];
+ AF_Segment seg, limit, link;
+ FT_UInt num_widths = 0;
+
+
+ error = af_latin_hints_compute_segments( hints,
+ (AF_Dimension)dim );
+ if ( error )
+ goto Exit;
+
+ af_latin_hints_link_segments( hints,
+ 0,
+ NULL,
+ (AF_Dimension)dim );
+
+ seg = axhints->segments;
+ limit = seg + axhints->num_segments;
+
+ for ( ; seg < limit; seg++ )
+ {
+ link = seg->link;
+
+ /* we only consider stem segments there! */
+ if ( link && link->link == seg && link > seg )
+ {
+ FT_Pos dist;
+
+
+ dist = seg->pos - link->pos;
+ if ( dist < 0 )
+ dist = -dist;
+
+ if ( num_widths < AF_CJK_MAX_WIDTHS )
+ axis->widths[num_widths++].org = dist;
+ }
+ }
+
+ /* this also replaces multiple almost identical stem widths */
+ /* with a single one (the value 100 is heuristic) */
+ af_sort_and_quantize_widths( &num_widths, axis->widths,
+ dummy->units_per_em / 100 );
+ axis->width_count = num_widths;
+ }
+
+ Exit:
+ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
+ {
+ AF_CJKAxis axis = &metrics->axis[dim];
+ FT_Pos stdw;
+
+
+ stdw = ( axis->width_count > 0 ) ? axis->widths[0].org
+ : AF_LATIN_CONSTANT( metrics, 50 );
+
+ /* let's try 20% of the smallest width */
+ axis->edge_distance_threshold = stdw / 5;
+ axis->standard_width = stdw;
+ axis->extra_light = 0;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_UInt i;
+
+
+ FT_TRACE5(( "%s widths:\n",
+ dim == AF_DIMENSION_VERT ? "horizontal"
+ : "vertical" ));
+
+ FT_TRACE5(( " %d (standard)", axis->standard_width ));
+ for ( i = 1; i < axis->width_count; i++ )
+ FT_TRACE5(( " %d", axis->widths[i].org ));
+
+ FT_TRACE5(( "\n" ));
+ }
+#endif
+ }
+ }
+
+ FT_TRACE5(( "\n" ));
+
+ af_glyph_hints_done( hints );
+ }
+
+
+ /* Find all blue zones. */
+
+ static void
+ af_cjk_metrics_init_blues( AF_CJKMetrics metrics,
+ FT_Face face )
+ {
+ FT_Pos fills[AF_BLUE_STRING_MAX_LEN];
+ FT_Pos flats[AF_BLUE_STRING_MAX_LEN];
+
+ FT_Int num_fills;
+ FT_Int num_flats;
+
+ FT_Bool fill;
+
+ AF_CJKBlue blue;
+ FT_Error error;
+ AF_CJKAxis axis;
+ FT_Outline outline;
+
+ AF_StyleClass sc = metrics->root.style_class;
+
+ AF_Blue_Stringset bss = sc->blue_stringset;
+ const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
+
+
+ /* we walk over the blue character strings as specified in the */
+ /* style's entry in the `af_blue_stringset' array, computing its */
+ /* extremum points (depending on the string properties) */
+
+ FT_TRACE5(( "cjk blue zones computation\n"
+ "==========================\n"
+ "\n" ));
+
+ for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
+ {
+ const char* p = &af_blue_strings[bs->string];
+ FT_Pos* blue_ref;
+ FT_Pos* blue_shoot;
+
+
+ if ( AF_CJK_IS_HORIZ_BLUE( bs ) )
+ axis = &metrics->axis[AF_DIMENSION_HORZ];
+ else
+ axis = &metrics->axis[AF_DIMENSION_VERT];
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_String* cjk_blue_name[4] =
+ {
+ (FT_String*)"bottom", /* -- , -- */
+ (FT_String*)"top", /* -- , TOP */
+ (FT_String*)"left", /* HORIZ, -- */
+ (FT_String*)"right" /* HORIZ, TOP */
+ };
+
+
+ FT_TRACE5(( "blue zone %d (%s):\n",
+ axis->blue_count,
+ cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
+ AF_CJK_IS_TOP_BLUE( bs ) ] ));
+ }
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+ num_fills = 0;
+ num_flats = 0;
+
+ fill = 1; /* start with characters that define fill values */
+ FT_TRACE5(( " [overshoot values]\n" ));
+
+ 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;
+
+
+ GET_UTF8_CHAR( ch, p );
+
+ /* switch to characters that define flat values */
+ if ( ch == '|' )
+ {
+ fill = 0;
+ FT_TRACE5(( " [reference values]\n" ));
+ continue;
+ }
+
+ /* load the character in the face -- skip unknown or empty ones */
+ af_get_char_index( &metrics->root, ch, &glyph_index, &y_offset );
+ if ( glyph_index == 0 )
+ {
+ FT_TRACE5(( " U+%04lX unavailable\n", ch ));
+ continue;
+ }
+
+ error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
+ outline = face->glyph->outline;
+ if ( error || outline.n_points <= 0 )
+ {
+ FT_TRACE5(( " U+%04lX contains no outlines\n", ch ));
+ continue;
+ }
+
+ /* now compute min or max point indices and coordinates */
+ points = outline.points;
+ best_point = -1;
+ best_pos = 0; /* make compiler happy */
+
+ {
+ FT_Int nn;
+ FT_Int first = 0;
+ FT_Int last = -1;
+
+
+ for ( nn = 0; nn < outline.n_contours; first = last + 1, nn++ )
+ {
+ 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 */
+ /* which are way outside of the glyph's real outline. */
+ if ( last <= first )
+ continue;
+
+ if ( AF_CJK_IS_HORIZ_BLUE( bs ) )
+ {
+ if ( AF_CJK_IS_RIGHT_BLUE( bs ) )
+ {
+ for ( pp = first; pp <= last; pp++ )
+ if ( best_point < 0 || points[pp].x > best_pos )
+ {
+ best_point = pp;
+ best_pos = points[pp].x;
+ }
+ }
+ else
+ {
+ for ( pp = first; pp <= last; pp++ )
+ if ( best_point < 0 || points[pp].x < best_pos )
+ {
+ best_point = pp;
+ best_pos = points[pp].x;
+ }
+ }
+ }
+ else
+ {
+ if ( AF_CJK_IS_TOP_BLUE( bs ) )
+ {
+ for ( pp = first; pp <= last; pp++ )
+ if ( best_point < 0 || points[pp].y > best_pos )
+ {
+ best_point = pp;
+ best_pos = points[pp].y;
+ }
+ }
+ else
+ {
+ for ( pp = first; pp <= last; pp++ )
+ if ( best_point < 0 || points[pp].y < best_pos )
+ {
+ best_point = pp;
+ best_pos = points[pp].y;
+ }
+ }
+ }
+ }
+
+ FT_TRACE5(( " U+%04lX: best_pos = %5ld\n", ch, best_pos ));
+ }
+
+ if ( fill )
+ fills[num_fills++] = best_pos;
+ else
+ flats[num_flats++] = best_pos;
+ }
+
+ if ( num_flats == 0 && num_fills == 0 )
+ {
+ /*
+ * we couldn't find a single glyph to compute this blue zone,
+ * we will simply ignore it then
+ */
+ FT_TRACE5(( " empty\n" ));
+ continue;
+ }
+
+ /* we have computed the contents of the `fill' and `flats' tables, */
+ /* now determine the reference and overshoot position of the blue -- */
+ /* we simply take the median value after a simple sort */
+ af_sort_pos( num_fills, fills );
+ af_sort_pos( num_flats, flats );
+
+ blue = &axis->blues[axis->blue_count];
+ blue_ref = &blue->ref.org;
+ blue_shoot = &blue->shoot.org;
+
+ axis->blue_count++;
+
+ if ( num_flats == 0 )
+ {
+ *blue_ref =
+ *blue_shoot = fills[num_fills / 2];
+ }
+ else if ( num_fills == 0 )
+ {
+ *blue_ref =
+ *blue_shoot = flats[num_flats / 2];
+ }
+ else
+ {
+ *blue_ref = fills[num_fills / 2];
+ *blue_shoot = flats[num_flats / 2];
+ }
+
+ /* make sure blue_ref >= blue_shoot for top/right or */
+ /* vice versa for bottom/left */
+ if ( *blue_shoot != *blue_ref )
+ {
+ FT_Pos ref = *blue_ref;
+ FT_Pos shoot = *blue_shoot;
+ FT_Bool under_ref = FT_BOOL( shoot < ref );
+
+
+ /* AF_CJK_IS_TOP_BLUE covers `right' and `top' */
+ if ( AF_CJK_IS_TOP_BLUE( bs ) ^ under_ref )
+ {
+ *blue_ref =
+ *blue_shoot = ( shoot + ref ) / 2;
+
+ FT_TRACE5(( " [reference smaller than overshoot,"
+ " taking mean value]\n" ));
+ }
+ }
+
+ blue->flags = 0;
+ if ( AF_CJK_IS_TOP_BLUE( bs ) )
+ blue->flags |= AF_CJK_BLUE_TOP;
+
+ FT_TRACE5(( " -> reference = %ld\n"
+ " overshoot = %ld\n",
+ *blue_ref, *blue_shoot ));
+ }
+
+ FT_TRACE5(( "\n" ));
+
+ return;
+ }
+
+
+ /* Basically the Latin version with type AF_CJKMetrics for metrics. */
+
+ FT_LOCAL_DEF( void )
+ 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;
+
+
+ /* digit `0' is 0x30 in all supported charmaps */
+ for ( i = 0x30; i <= 0x39; i++ )
+ {
+ FT_ULong glyph_index;
+ FT_Long y_offset;
+
+
+ af_get_char_index( &metrics->root, i, &glyph_index, &y_offset );
+ if ( glyph_index == 0 )
+ continue;
+
+ if ( FT_Get_Advance( face, glyph_index,
+ FT_LOAD_NO_SCALE |
+ FT_LOAD_NO_HINTING |
+ FT_LOAD_IGNORE_TRANSFORM,
+ &advance ) )
+ continue;
+
+ if ( started )
+ {
+ if ( advance != old_advance )
+ {
+ same_width = 0;
+ break;
+ }
+ }
+ else
+ {
+ old_advance = advance;
+ started = 1;
+ }
+ }
+
+ metrics->root.digits_have_same_width = same_width;
+ }
+
+
+ /* Initialize global metrics. */
+
FT_LOCAL_DEF( FT_Error )
- af_cjk_metrics_init( AF_LatinMetrics metrics,
- FT_Face face )
+ af_cjk_metrics_init( AF_CJKMetrics metrics,
+ FT_Face face )
{
FT_CharMap oldmap = face->charmap;
metrics->units_per_em = face->units_per_EM;
- /* TODO are there blues? */
-
- if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
- face->charmap = NULL;
- else
+ if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
{
- /* latin's version would suffice */
- af_latin_metrics_init_widths( metrics, face, 0x7530 );
- af_latin_metrics_check_digits( metrics, face );
+ af_cjk_metrics_init_widths( metrics, face );
+ af_cjk_metrics_init_blues( metrics, face );
+ af_cjk_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
-
- return AF_Err_Ok;
+ return FT_Err_Ok;
}
+ /* Adjust scaling value, then scale and shift widths */
+ /* and blue zones (if applicable) for given dimension. */
+
static void
- af_cjk_metrics_scale_dim( AF_LatinMetrics metrics,
- AF_Scaler scaler,
- AF_Dimension dim )
+ af_cjk_metrics_scale_dim( AF_CJKMetrics metrics,
+ AF_Scaler scaler,
+ AF_Dimension dim )
{
- AF_LatinAxis axis;
-
+ FT_Fixed scale;
+ FT_Pos delta;
+ AF_CJKAxis axis;
+ FT_UInt nn;
- axis = &metrics->axis[dim];
if ( dim == AF_DIMENSION_HORZ )
{
- axis->scale = scaler->x_scale;
- axis->delta = scaler->x_delta;
+ scale = scaler->x_scale;
+ delta = scaler->x_delta;
}
else
{
- axis->scale = scaler->y_scale;
- axis->delta = scaler->y_delta;
+ scale = scaler->y_scale;
+ delta = scaler->y_delta;
+ }
+
+ axis = &metrics->axis[dim];
+
+ if ( axis->org_scale == scale && axis->org_delta == delta )
+ return;
+
+ axis->org_scale = scale;
+ axis->org_delta = delta;
+
+ axis->scale = scale;
+ axis->delta = delta;
+
+ /* scale the blue zones */
+ for ( nn = 0; nn < axis->blue_count; nn++ )
+ {
+ AF_CJKBlue blue = &axis->blues[nn];
+ FT_Pos dist;
+
+
+ blue->ref.cur = FT_MulFix( blue->ref.org, scale ) + delta;
+ blue->ref.fit = blue->ref.cur;
+ blue->shoot.cur = FT_MulFix( blue->shoot.org, scale ) + delta;
+ blue->shoot.fit = blue->shoot.cur;
+ blue->flags &= ~AF_CJK_BLUE_ACTIVE;
+
+ /* a blue zone is only active if it is less than 3/4 pixels tall */
+ dist = FT_MulFix( blue->ref.org - blue->shoot.org, scale );
+ if ( dist <= 48 && dist >= -48 )
+ {
+ FT_Pos delta1, delta2;
+
+
+ blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
+
+ /* shoot is under shoot for cjk */
+ delta1 = FT_DivFix( blue->ref.fit, scale ) - blue->shoot.org;
+ delta2 = delta1;
+ if ( delta1 < 0 )
+ delta2 = -delta2;
+
+ delta2 = FT_MulFix( delta2, scale );
+
+ FT_TRACE5(( "delta: %d", delta1 ));
+ if ( delta2 < 32 )
+ delta2 = 0;
+#if 0
+ else if ( delta2 < 64 )
+ delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & ~31 );
+#endif
+ else
+ delta2 = FT_PIX_ROUND( delta2 );
+ FT_TRACE5(( "/%d\n", delta2 ));
+
+ if ( delta1 < 0 )
+ delta2 = -delta2;
+
+ blue->shoot.fit = blue->ref.fit - delta2;
+
+ FT_TRACE5(( ">> active cjk blue zone %c%d[%ld/%ld]:\n"
+ " ref: cur=%.2f fit=%.2f\n"
+ " shoot: cur=%.2f fit=%.2f\n",
+ ( dim == AF_DIMENSION_HORZ ) ? 'H' : 'V',
+ nn, blue->ref.org, blue->shoot.org,
+ blue->ref.cur / 64.0, blue->ref.fit / 64.0,
+ blue->shoot.cur / 64.0, blue->shoot.fit / 64.0 ));
+
+ blue->flags |= AF_CJK_BLUE_ACTIVE;
+ }
}
}
+ /* Scale global values in both directions. */
+
FT_LOCAL_DEF( void )
- af_cjk_metrics_scale( AF_LatinMetrics metrics,
- AF_Scaler scaler )
+ af_cjk_metrics_scale( AF_CJKMetrics metrics,
+ AF_Scaler scaler )
{
+ /* we copy the whole structure since the x and y scaling values */
+ /* are not modified, contrary to e.g. the `latin' auto-hinter */
metrics->root.scaler = *scaler;
af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
@@ -113,6 +696,9 @@
/*************************************************************************/
/*************************************************************************/
+
+ /* Walk over all contours and compute its segments. */
+
static FT_Error
af_cjk_hints_compute_segments( AF_GlyphHints hints,
AF_Dimension dim )
@@ -134,7 +720,7 @@
{
AF_Point pt = seg->first;
AF_Point last = seg->last;
- AF_Flags f0 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL);
+ AF_Flags f0 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
AF_Flags f1;
@@ -143,7 +729,7 @@
for ( ; pt != last; f0 = f1 )
{
pt = pt->next;
- f1 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL);
+ f1 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
if ( !f0 && !f1 )
break;
@@ -153,7 +739,7 @@
}
}
- return AF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -179,10 +765,6 @@
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
- /* the fake segments are for metrics hinting only */
- if ( seg1->first == seg1->last )
- continue;
-
if ( seg1->dir != major_dir )
continue;
@@ -327,9 +909,9 @@
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = hints->memory;
- AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim];
+ AF_CJKAxis laxis = &((AF_CJKMetrics)hints->metrics)->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
@@ -369,7 +951,7 @@
for ( seg = segments; seg < segment_limit; seg++ )
{
- AF_Edge found = 0;
+ AF_Edge found = NULL;
FT_Pos best = 0xFFFFU;
FT_Int ee;
@@ -397,14 +979,15 @@
/* can make a single edge. */
if ( link )
{
- AF_Segment seg1 = edge->first;
- AF_Segment link1;
+ AF_Segment seg1 = edge->first;
FT_Pos dist2 = 0;
do
{
- link1 = seg1->link;
+ AF_Segment link1 = seg1->link;
+
+
if ( link1 )
{
dist2 = AF_SEGMENT_DIST( link, link1 );
@@ -441,10 +1024,11 @@
edge->first = seg;
edge->last = seg;
+ edge->dir = seg->dir;
edge->fpos = seg->pos;
- edge->opos = edge->pos = FT_MulFix( seg->pos, scale );
+ edge->opos = FT_MulFix( seg->pos, scale );
+ edge->pos = edge->opos;
seg->edge_next = seg;
- edge->dir = seg->dir;
}
else
{
@@ -456,25 +1040,26 @@
}
}
- /*********************************************************************/
- /* */
- /* Good, we now compute each edge's properties according to segments */
- /* found on its position. Basically, these are as follows. */
- /* */
- /* - edge's main direction */
- /* - stem edge, serif edge or both (which defaults to stem then) */
- /* - rounded edge, straight or both (which defaults to straight) */
- /* - link for edge */
- /* */
- /*********************************************************************/
-
- /* first of all, set the `edge' field in each segment -- this is */
- /* required in order to compute edge links */
- /* */
- /* Note that removing this loop and setting the `edge' field of each */
- /* segment directly in the code above slows down execution speed for */
- /* some reasons on platforms like the Sun. */
+ /******************************************************************/
+ /* */
+ /* Good, we now compute each edge's properties according to the */
+ /* segments found on its position. Basically, these are */
+ /* */
+ /* - the edge's main direction */
+ /* - stem edge, serif edge or both (which defaults to stem then) */
+ /* - rounded edge, straight or both (which defaults to straight) */
+ /* - link for edge */
+ /* */
+ /******************************************************************/
+
+ /* first of all, set the `edge' field in each segment -- this is */
+ /* required in order to compute edge links */
+ /*
+ * Note that removing this loop and setting the `edge' field of each
+ * segment directly in the code above slows down execution speed for
+ * some reasons on platforms like the Sun.
+ */
{
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
@@ -583,6 +1168,8 @@
}
+ /* Detect segments and edges for given dimension. */
+
static FT_Error
af_cjk_hints_detect_features( AF_GlyphHints hints,
AF_Dimension dim )
@@ -601,15 +1188,106 @@
}
+ /* Compute all edges which lie within blue zones. */
+
+ FT_LOCAL_DEF( void )
+ af_cjk_hints_compute_blue_edges( AF_GlyphHints hints,
+ AF_CJKMetrics metrics,
+ AF_Dimension dim )
+ {
+ AF_AxisHints axis = &hints->axis[dim];
+ AF_Edge edge = axis->edges;
+ AF_Edge edge_limit = edge + axis->num_edges;
+ AF_CJKAxis cjk = &metrics->axis[dim];
+ FT_Fixed scale = cjk->scale;
+ FT_Pos best_dist0; /* initial threshold */
+
+
+ /* compute the initial threshold as a fraction of the EM size */
+ best_dist0 = FT_MulFix( metrics->units_per_em / 40, scale );
+
+ if ( best_dist0 > 64 / 2 ) /* maximum 1/2 pixel */
+ best_dist0 = 64 / 2;
+
+ /* compute which blue zones are active, i.e. have their scaled */
+ /* size < 3/4 pixels */
+
+ /* If the distant between an edge and a blue zone is shorter than */
+ /* best_dist0, set the blue zone for the edge. Then search for */
+ /* the blue zone with the smallest best_dist to the edge. */
+
+ for ( ; edge < edge_limit; edge++ )
+ {
+ FT_UInt bb;
+ AF_Width best_blue = NULL;
+ FT_Pos best_dist = best_dist0;
+
+
+ for ( bb = 0; bb < cjk->blue_count; bb++ )
+ {
+ AF_CJKBlue blue = cjk->blues + bb;
+ FT_Bool is_top_right_blue, is_major_dir;
+
+
+ /* skip inactive blue zones (i.e., those that are too small) */
+ if ( !( blue->flags & AF_CJK_BLUE_ACTIVE ) )
+ continue;
+
+ /* if it is a top zone, check for right edges -- if it is a bottom */
+ /* zone, check for left edges */
+ /* */
+ /* of course, that's for TrueType */
+ is_top_right_blue =
+ (FT_Byte)( ( blue->flags & AF_CJK_BLUE_TOP ) != 0 );
+ is_major_dir =
+ FT_BOOL( edge->dir == axis->major_dir );
+
+ /* if it is a top zone, the edge must be against the major */
+ /* direction; if it is a bottom zone, it must be in the major */
+ /* direction */
+ if ( is_top_right_blue ^ is_major_dir )
+ {
+ FT_Pos dist;
+ AF_Width compare;
+
+
+ /* Compare the edge to the closest blue zone type */
+ if ( FT_ABS( edge->fpos - blue->ref.org ) >
+ FT_ABS( edge->fpos - blue->shoot.org ) )
+ compare = &blue->shoot;
+ else
+ compare = &blue->ref;
+
+ dist = edge->fpos - compare->org;
+ if ( dist < 0 )
+ dist = -dist;
+
+ dist = FT_MulFix( dist, scale );
+ if ( dist < best_dist )
+ {
+ best_dist = dist;
+ best_blue = compare;
+ }
+ }
+ }
+
+ if ( best_blue )
+ edge->blue_edge = best_blue;
+ }
+ }
+
+
+ /* Initalize hinting engine. */
+
FT_LOCAL_DEF( FT_Error )
- af_cjk_hints_init( AF_GlyphHints hints,
- AF_LatinMetrics metrics )
+ af_cjk_hints_init( AF_GlyphHints hints,
+ AF_CJKMetrics metrics )
{
FT_Render_Mode mode;
FT_UInt32 scaler_flags, other_flags;
- af_glyph_hints_rescale( hints, (AF_ScriptMetrics)metrics );
+ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
/*
* correct x_scale and y_scale when needed, since they may have
@@ -623,7 +1301,7 @@
/* compute flags depending on render mode, etc. */
mode = metrics->root.scaler.render_mode;
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
#endif
@@ -659,7 +1337,7 @@
hints->scaler_flags = scaler_flags;
hints->other_flags = other_flags;
- return 0;
+ return FT_Err_Ok;
}
@@ -671,8 +1349,8 @@
/*************************************************************************/
/*************************************************************************/
- /* snap a given width in scaled coordinates to one of the */
- /* current standard widths */
+ /* Snap a given width in scaled coordinates to one of the */
+ /* current standard widths. */
static FT_Pos
af_cjk_snap_width( AF_Width widths,
@@ -719,7 +1397,9 @@
}
- /* compute the snapped width of a given stem */
+ /* Compute the snapped width of a given stem. */
+ /* There is a lot of voodoo in this function; changing the hard-coded */
+ /* parameters influence the whole hinting process. */
static FT_Pos
af_cjk_compute_stem_width( AF_GlyphHints hints,
@@ -728,11 +1408,11 @@
AF_Edge_Flags base_flags,
AF_Edge_Flags stem_flags )
{
- AF_LatinMetrics metrics = (AF_LatinMetrics) hints->metrics;
- AF_LatinAxis axis = & metrics->axis[dim];
- FT_Pos dist = width;
- FT_Int sign = 0;
- FT_Int vertical = ( dim == AF_DIMENSION_VERT );
+ AF_CJKMetrics metrics = (AF_CJKMetrics)hints->metrics;
+ AF_CJKAxis axis = &metrics->axis[dim];
+ FT_Pos dist = width;
+ FT_Int sign = 0;
+ FT_Bool vertical = FT_BOOL( dim == AF_DIMENSION_VERT );
FT_UNUSED( base_flags );
FT_UNUSED( stem_flags );
@@ -840,7 +1520,7 @@
}
- /* align one stem edge relative to the previous stem edge */
+ /* Align one stem edge relative to the previous stem edge. */
static void
af_cjk_align_linked_edge( AF_GlyphHints hints,
@@ -857,9 +1537,18 @@
stem_edge->pos = base_edge->pos + fitted_width;
+
+ FT_TRACE5(( " CJKLINK: edge %d @%d (opos=%.2f) linked to %.2f,"
+ " dist was %.2f, now %.2f\n",
+ stem_edge - hints->axis[dim].edges, stem_edge->fpos,
+ stem_edge->opos / 64.0, stem_edge->pos / 64.0,
+ dist / 64.0, fitted_width / 64.0 ));
}
+ /* Shift the coordinates of the `serif' edge by the same amount */
+ /* as the corresponding `base' edge has been moved already. */
+
static void
af_cjk_align_serif_edge( AF_GlyphHints hints,
AF_Edge base,
@@ -958,7 +1647,7 @@
goto Exit;
}
- offset = cur_len % 64;
+ offset = cur_len & 63;
if ( offset < 32 )
{
@@ -1013,6 +1702,8 @@
}
+ /* The main grid-fitting routine. */
+
static void
af_cjk_hint_edges( AF_GlyphHints hints,
AF_Dimension dim )
@@ -1025,7 +1716,75 @@
AF_Edge anchor = 0;
FT_Pos delta = 0;
FT_Int skipped = 0;
+ FT_Bool has_last_stem = FALSE;
+ FT_Pos last_stem_pos = 0;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_UInt num_actions = 0;
+#endif
+
+
+ FT_TRACE5(( "cjk %s edge hinting (style `%s')\n",
+ dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
+ af_style_names[hints->metrics->style_class->style] ));
+
+ /* we begin by aligning all stems relative to the blue zone */
+
+ if ( AF_HINTS_DO_BLUES( hints ) )
+ {
+ for ( edge = edges; edge < edge_limit; edge++ )
+ {
+ AF_Width blue;
+ AF_Edge edge1, edge2;
+
+
+ if ( edge->flags & AF_EDGE_DONE )
+ continue;
+
+ blue = edge->blue_edge;
+ edge1 = NULL;
+ edge2 = edge->link;
+
+ if ( blue )
+ {
+ edge1 = edge;
+ }
+ else if ( edge2 && edge2->blue_edge )
+ {
+ blue = edge2->blue_edge;
+ edge1 = edge2;
+ edge2 = edge;
+ }
+
+ if ( !edge1 )
+ continue;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_TRACE5(( " CJKBLUE: edge %d @%d (opos=%.2f) snapped to %.2f,"
+ " was %.2f\n",
+ edge1 - edges, edge1->fpos, edge1->opos / 64.0,
+ blue->fit / 64.0, edge1->pos / 64.0 ));
+
+ num_actions++;
+#endif
+
+ edge1->pos = blue->fit;
+ edge1->flags |= AF_EDGE_DONE;
+
+ if ( edge2 && !edge2->blue_edge )
+ {
+ af_cjk_align_linked_edge( hints, dim, edge1, edge2 );
+ edge2->flags |= AF_EDGE_DONE;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions++;
+#endif
+ }
+ if ( !anchor )
+ anchor = edge;
+ }
+ }
/* now we align all stem edges. */
for ( edge = edges; edge < edge_limit; edge++ )
@@ -1044,12 +1803,54 @@
continue;
}
+ /* Some CJK characters have so many stems that
+ * the hinter is likely to merge two adjacent ones.
+ * To solve this problem, if either edge of a stem
+ * is too close to the previous one, we avoid
+ * aligning the two edges, but rather interpolate
+ * their locations at the end of this function in
+ * order to preserve the space between the stems.
+ */
+ if ( has_last_stem &&
+ ( edge->pos < last_stem_pos + 64 ||
+ edge2->pos < last_stem_pos + 64 ) )
+ {
+ skipped++;
+ continue;
+ }
+
/* now align the stem */
+ /* this should not happen, but it's better to be safe */
+ if ( edge2->blue_edge )
+ {
+ FT_TRACE5(( "ASSERTION FAILED for edge %d\n", edge2-edges ));
+
+ af_cjk_align_linked_edge( hints, dim, edge2, edge );
+ edge->flags |= AF_EDGE_DONE;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions++;
+#endif
+
+ continue;
+ }
+
if ( edge2 < edge )
{
af_cjk_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions++;
+#endif
+
+ /* We rarely reaches here it seems;
+ * usually the two edges belonging
+ * to one stem are marked as DONE together
+ */
+ has_last_stem = TRUE;
+ last_stem_pos = edge->pos;
continue;
}
@@ -1142,6 +1943,8 @@
anchor = edge;
edge->flags |= AF_EDGE_DONE;
edge2->flags |= AF_EDGE_DONE;
+ has_last_stem = TRUE;
+ last_stem_pos = edge2->pos;
}
/* make sure that lowercase m's maintain their symmetry */
@@ -1209,7 +2012,7 @@
}
if ( !skipped )
- return;
+ goto Exit;
/*
* now hint the remaining edges (serifs and single) in order
@@ -1229,7 +2032,7 @@
}
if ( !skipped )
- return;
+ goto Exit;
for ( edge = edges; edge < edge_limit; edge++ )
{
@@ -1267,6 +2070,16 @@
}
}
}
+
+ Exit:
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !num_actions )
+ FT_TRACE5(( " (none)\n" ));
+ FT_TRACE5(( "\n" ));
+#endif
+
+ return;
}
@@ -1360,10 +2173,12 @@
}
+ /* Apply the complete hinting algorithm to a CJK glyph. */
+
FT_LOCAL_DEF( FT_Error )
- af_cjk_hints_apply( AF_GlyphHints hints,
- FT_Outline* outline,
- AF_LatinMetrics metrics )
+ af_cjk_hints_apply( AF_GlyphHints hints,
+ FT_Outline* outline,
+ AF_CJKMetrics metrics )
{
FT_Error error;
int dim;
@@ -1371,7 +2186,7 @@
FT_UNUSED( metrics );
- error = af_glyph_hints_reload( hints, outline, 0 );
+ error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;
@@ -1381,6 +2196,8 @@
error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ );
if ( error )
goto Exit;
+
+ af_cjk_hints_compute_blue_edges( hints, metrics, AF_DIMENSION_HORZ );
}
if ( AF_HINTS_DO_VERTICAL( hints ) )
@@ -1388,6 +2205,8 @@
error = af_cjk_hints_detect_features( hints, AF_DIMENSION_VERT );
if ( error )
goto Exit;
+
+ af_cjk_hints_compute_blue_edges( hints, metrics, AF_DIMENSION_VERT );
}
/* grid-fit the outline */
@@ -1397,7 +2216,7 @@
( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) )
{
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
if ( dim == AF_DIMENSION_HORZ &&
metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL )
{
@@ -1406,11 +2225,13 @@
FT_Pos delta;
- af_warper_compute( &warper, hints, dim, &scale, &delta );
- af_glyph_hints_scale_dim( hints, dim, scale, delta );
+ af_warper_compute( &warper, hints, (AF_Dimension)dim,
+ &scale, &delta );
+ af_glyph_hints_scale_dim( hints, (AF_Dimension)dim,
+ scale, delta );
continue;
}
-#endif /* AF_USE_WARPER */
+#endif /* AF_CONFIG_OPTION_USE_WARPER */
af_cjk_hint_edges( hints, (AF_Dimension)dim );
af_cjk_align_edge_points( hints, (AF_Dimension)dim );
@@ -1441,71 +2262,41 @@
/*************************************************************************/
- static const AF_Script_UniRangeRec af_cjk_uniranges[] =
- {
-#if 0
- AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
-#endif
- AF_UNIRANGE_REC( 0x2E80UL, 0x2EFFUL ), /* CJK Radicals Supplement */
- AF_UNIRANGE_REC( 0x2F00UL, 0x2FDFUL ), /* Kangxi Radicals */
- 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( 0x31A0UL, 0x31BFUL ), /* Bopomofo Extended */
- AF_UNIRANGE_REC( 0x31C0UL, 0x31EFUL ), /* CJK Strokes */
- AF_UNIRANGE_REC( 0x31F0UL, 0x31FFUL ), /* Katakana Phonetic Extensions */
- AF_UNIRANGE_REC( 0x3200UL, 0x32FFUL ), /* Enclosed CJK Letters and Months */
- 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( 0xF900UL, 0xFAFFUL ), /* CJK Compatibility Ideographs */
- AF_UNIRANGE_REC( 0xFE30UL, 0xFE4FUL ), /* CJK Compatibility Forms */
- AF_UNIRANGE_REC( 0xFF00UL, 0xFFEFUL ), /* Halfwidth and Fullwidth Forms */
- AF_UNIRANGE_REC( 0x20000UL, 0x2A6DFUL ), /* CJK Unified Ideographs Extension B */
- AF_UNIRANGE_REC( 0x2F800UL, 0x2FA1FUL ), /* CJK Compatibility Ideographs Supplement */
- AF_UNIRANGE_REC( 0UL, 0UL )
- };
-
-
- AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
- AF_SCRIPT_CJK,
- af_cjk_uniranges,
-
- sizeof( AF_LatinMetricsRec ),
-
- (AF_Script_InitMetricsFunc) af_cjk_metrics_init,
- (AF_Script_ScaleMetricsFunc)af_cjk_metrics_scale,
- (AF_Script_DoneMetricsFunc) NULL,
-
- (AF_Script_InitHintsFunc) af_cjk_hints_init,
- (AF_Script_ApplyHintsFunc) af_cjk_hints_apply
+ AF_DEFINE_WRITING_SYSTEM_CLASS(
+ af_cjk_writing_system_class,
+
+ AF_WRITING_SYSTEM_CJK,
+
+ sizeof ( AF_CJKMetricsRec ),
+
+ (AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init,
+ (AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale,
+ (AF_WritingSystem_DoneMetricsFunc) NULL,
+
+ (AF_WritingSystem_InitHintsFunc) af_cjk_hints_init,
+ (AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply
)
+
#else /* !AF_CONFIG_OPTION_CJK */
- static const AF_Script_UniRangeRec af_cjk_uniranges[] =
- {
- AF_UNIRANGE_REC( 0UL, 0UL )
- };
+ AF_DEFINE_WRITING_SYSTEM_CLASS(
+ af_cjk_writing_system_class,
- AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
- AF_SCRIPT_CJK,
- af_cjk_uniranges,
+ AF_WRITING_SYSTEM_CJK,
- sizeof( AF_LatinMetricsRec ),
+ sizeof ( AF_CJKMetricsRec ),
- (AF_Script_InitMetricsFunc) NULL,
- (AF_Script_ScaleMetricsFunc)NULL,
- (AF_Script_DoneMetricsFunc) NULL,
+ (AF_WritingSystem_InitMetricsFunc) NULL,
+ (AF_WritingSystem_ScaleMetricsFunc)NULL,
+ (AF_WritingSystem_DoneMetricsFunc) NULL,
- (AF_Script_InitHintsFunc) NULL,
- (AF_Script_ApplyHintsFunc) NULL
+ (AF_WritingSystem_InitHintsFunc) NULL,
+ (AF_WritingSystem_ApplyHintsFunc) NULL
)
+
#endif /* !AF_CONFIG_OPTION_CJK */
diff --git a/src/3rdparty/freetype/src/autofit/afcjk.h b/src/3rdparty/freetype/src/autofit/afcjk.h
index 0b20d4ae35..4dd4f39177 100644
--- a/src/3rdparty/freetype/src/autofit/afcjk.h
+++ b/src/3rdparty/freetype/src/autofit/afcjk.h
@@ -2,9 +2,9 @@
/* */
/* afcjk.h */
/* */
-/* Auto-fitter hinting routines for CJK script (specification). */
+/* Auto-fitter hinting routines for CJK writing system (specification). */
/* */
-/* Copyright 2006, 2007 by */
+/* Copyright 2006, 2007, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,32 +20,119 @@
#define __AFCJK_H__
#include "afhints.h"
+#include "aflatin.h"
FT_BEGIN_HEADER
- /* the CJK-specific script class */
+ /* the CJK-specific writing system */
- AF_DECLARE_SCRIPT_CLASS(af_cjk_script_class)
+ AF_DECLARE_WRITING_SYSTEM_CLASS( af_cjk_writing_system_class )
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** C J K G L O B A L M E T R I C S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*
+ * CJK glyphs tend to fill the square. So we have both vertical and
+ * horizontal blue zones. But some glyphs have flat bounding strokes that
+ * leave some space between neighbour glyphs.
+ */
+
+#define AF_CJK_IS_TOP_BLUE( b ) \
+ ( (b)->properties & AF_BLUE_PROPERTY_CJK_TOP )
+#define AF_CJK_IS_HORIZ_BLUE( b ) \
+ ( (b)->properties & AF_BLUE_PROPERTY_CJK_HORIZ )
+#define AF_CJK_IS_RIGHT_BLUE AF_CJK_IS_TOP_BLUE
+
+#define AF_CJK_MAX_WIDTHS 16
+
+
+ enum
+ {
+ AF_CJK_BLUE_ACTIVE = 1 << 0, /* set if zone height is <= 3/4px */
+ AF_CJK_BLUE_TOP = 1 << 1, /* result of AF_CJK_IS_TOP_BLUE */
+ AF_CJK_BLUE_ADJUSTMENT = 1 << 2, /* used for scale adjustment */
+ /* optimization */
+ AF_CJK_BLUE_FLAG_MAX
+ };
+
+
+ typedef struct AF_CJKBlueRec_
+ {
+ AF_WidthRec ref;
+ AF_WidthRec shoot; /* undershoot */
+ FT_UInt flags;
+
+ } AF_CJKBlueRec, *AF_CJKBlue;
+
+
+ typedef struct AF_CJKAxisRec_
+ {
+ FT_Fixed scale;
+ FT_Pos delta;
+
+ FT_UInt width_count; /* number of used widths */
+ AF_WidthRec widths[AF_CJK_MAX_WIDTHS]; /* widths array */
+ FT_Pos edge_distance_threshold; /* used for creating edges */
+ FT_Pos standard_width; /* the default stem thickness */
+ FT_Bool extra_light; /* is standard width very light? */
+
+ /* used for horizontal metrics too for CJK */
+ FT_Bool control_overshoot;
+ FT_UInt blue_count;
+ AF_CJKBlueRec blues[AF_BLUE_STRINGSET_MAX];
+
+ FT_Fixed org_scale;
+ FT_Pos org_delta;
+
+ } AF_CJKAxisRec, *AF_CJKAxis;
+
+
+ typedef struct AF_CJKMetricsRec_
+ {
+ AF_StyleMetricsRec root;
+ FT_UInt units_per_em;
+ AF_CJKAxisRec axis[AF_DIMENSION_MAX];
+
+ } AF_CJKMetricsRec, *AF_CJKMetrics;
+
+
+#ifdef AF_CONFIG_OPTION_CJK
FT_LOCAL( FT_Error )
- af_cjk_metrics_init( AF_LatinMetrics metrics,
- FT_Face face );
+ af_cjk_metrics_init( AF_CJKMetrics metrics,
+ FT_Face face );
FT_LOCAL( void )
- af_cjk_metrics_scale( AF_LatinMetrics metrics,
- AF_Scaler scaler );
+ af_cjk_metrics_scale( AF_CJKMetrics metrics,
+ AF_Scaler scaler );
FT_LOCAL( FT_Error )
- af_cjk_hints_init( AF_GlyphHints hints,
- AF_LatinMetrics metrics );
+ af_cjk_hints_init( AF_GlyphHints hints,
+ AF_CJKMetrics metrics );
FT_LOCAL( FT_Error )
- af_cjk_hints_apply( AF_GlyphHints hints,
- FT_Outline* outline,
- AF_LatinMetrics metrics );
+ af_cjk_hints_apply( AF_GlyphHints hints,
+ FT_Outline* outline,
+ AF_CJKMetrics metrics );
+
+ /* shared; called from afindic.c */
+ FT_LOCAL( void )
+ af_cjk_metrics_check_digits( AF_CJKMetrics metrics,
+ FT_Face face );
+
+ FT_LOCAL( void )
+ af_cjk_metrics_init_widths( AF_CJKMetrics metrics,
+ FT_Face face );
+#endif /* AF_CONFIG_OPTION_CJK */
+
/* */
diff --git a/src/3rdparty/freetype/src/autofit/afcover.h b/src/3rdparty/freetype/src/autofit/afcover.h
new file mode 100644
index 0000000000..d5ac96944a
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afcover.h
@@ -0,0 +1,105 @@
+/***************************************************************************/
+/* */
+/* afcover.h */
+/* */
+/* Auto-fitter coverages (specification only). */
+/* */
+/* Copyright 2013, 2014 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. */
+/* */
+/***************************************************************************/
+
+
+ /* This header file can be included multiple times. */
+ /* Define `COVERAGE' as needed. */
+
+
+ /* Add new coverages here. The first and second arguments are the */
+ /* coverage name in lowercase and uppercase, respectively, followed */
+ /* by a description string. The last four arguments are the four */
+ /* characters defining the corresponding OpenType feature. */
+
+#if 0
+ /* XXX: It's not possible to define blue zone characters in advance. */
+ COVERAGE( alternative_fractions, ALTERNATIVE_FRACTIONS,
+ "alternative fractions",
+ 'a', 'f', 'r', 'c' )
+#endif
+
+ COVERAGE( petite_capitals_from_capitals, PETITE_CAPITALS_FROM_CAPITALS,
+ "petite capitals from capitals",
+ 'c', '2', 'c', 'p' )
+
+ COVERAGE( small_capitals_from_capitals, SMALL_CAPITALS_FROM_CAPITALS,
+ "small capitals from capitals",
+ 'c', '2', 's', 'c' )
+
+#if 0
+ /* XXX: Only digits are in this coverage, however, both normal style */
+ /* and oldstyle representation forms are possible. */
+ COVERAGE( denominators, DENOMINATORS,
+ "denominators",
+ 'd', 'n', 'o', 'm' )
+#endif
+
+#if 0
+ /* XXX: It's not possible to define blue zone characters in advance. */
+ COVERAGE( fractions, FRACTIONS,
+ "fractions",
+ 'f', 'r', 'a', 'c' )
+#endif
+
+#if 0
+ /* XXX: Only digits are in this coverage, however, both normal style */
+ /* and oldstyle representation forms are possible. */
+ COVERAGE( numerators, NUMERATORS,
+ "numerators",
+ 'n', 'u', 'm', 'r' )
+#endif
+
+ COVERAGE( ordinals, ORDINALS,
+ "ordinals",
+ 'o', 'r', 'd', 'n' )
+
+ COVERAGE( petite_capitals, PETITE_CAPITALS,
+ "petite capitals",
+ 'p', 'c', 'a', 'p' )
+
+ COVERAGE( ruby, RUBY,
+ "ruby",
+ 'r', 'u', 'b', 'y' )
+
+ COVERAGE( scientific_inferiors, SCIENTIFIC_INFERIORS,
+ "scientific inferiors",
+ 's', 'i', 'n', 'f' )
+
+ COVERAGE( small_capitals, SMALL_CAPITALS,
+ "small capitals",
+ 's', 'm', 'c', 'p' )
+
+ COVERAGE( subscript, SUBSCRIPT,
+ "subscript",
+ 's', 'u', 'b', 's' )
+
+ COVERAGE( superscript, SUPERSCRIPT,
+ "superscript",
+ 's', 'u', 'p', 's' )
+
+ COVERAGE( titling, TITLING,
+ "titling",
+ 't', 'i', 't', 'l' )
+
+#if 0
+ /* to be always excluded */
+ COVERAGE(nalt, 'n', 'a', 'l', 't'); /* Alternate Annotation Forms (?) */
+ COVERAGE(ornm, 'o', 'r', 'n', 'm'); /* Ornaments (?) */
+#endif
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afdummy.c b/src/3rdparty/freetype/src/autofit/afdummy.c
index 42b2fcb216..f8702a109e 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, 2004, 2005 by */
+/* Copyright 2003-2005, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,15 +19,21 @@
#include "afdummy.h"
#include "afhints.h"
+#include "aferrors.h"
static FT_Error
- af_dummy_hints_init( AF_GlyphHints hints,
- AF_ScriptMetrics metrics )
+ af_dummy_hints_init( AF_GlyphHints hints,
+ AF_StyleMetrics metrics )
{
- af_glyph_hints_rescale( hints,
- metrics );
- return 0;
+ af_glyph_hints_rescale( hints, metrics );
+
+ hints->x_scale = metrics->scaler.x_scale;
+ hints->y_scale = metrics->scaler.y_scale;
+ hints->x_delta = metrics->scaler.x_delta;
+ hints->y_delta = metrics->scaler.y_delta;
+
+ return FT_Err_Ok;
}
@@ -35,25 +41,30 @@
af_dummy_hints_apply( AF_GlyphHints hints,
FT_Outline* outline )
{
- FT_UNUSED( hints );
- FT_UNUSED( outline );
+ FT_Error error;
+
- return 0;
+ error = af_glyph_hints_reload( hints, outline );
+ if ( !error )
+ af_glyph_hints_save( hints, outline );
+
+ return error;
}
- AF_DEFINE_SCRIPT_CLASS(af_dummy_script_class,
- AF_SCRIPT_NONE,
- NULL,
+ AF_DEFINE_WRITING_SYSTEM_CLASS(
+ af_dummy_writing_system_class,
+
+ AF_WRITING_SYSTEM_DUMMY,
- sizeof( AF_ScriptMetricsRec ),
+ sizeof ( AF_StyleMetricsRec ),
- (AF_Script_InitMetricsFunc) NULL,
- (AF_Script_ScaleMetricsFunc)NULL,
- (AF_Script_DoneMetricsFunc) NULL,
+ (AF_WritingSystem_InitMetricsFunc) NULL,
+ (AF_WritingSystem_ScaleMetricsFunc)NULL,
+ (AF_WritingSystem_DoneMetricsFunc) NULL,
- (AF_Script_InitHintsFunc) af_dummy_hints_init,
- (AF_Script_ApplyHintsFunc) af_dummy_hints_apply
+ (AF_WritingSystem_InitHintsFunc) af_dummy_hints_init,
+ (AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply
)
diff --git a/src/3rdparty/freetype/src/autofit/afdummy.h b/src/3rdparty/freetype/src/autofit/afdummy.h
index b69ef437fe..ad1b0d3abb 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, 2004, 2005 by */
+/* Copyright 2003-2005, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,11 +25,9 @@
FT_BEGIN_HEADER
- /* A dummy script metrics class used when no hinting should
- * be performed. This is the default for non-latin glyphs!
- */
+ /* A dummy writing system used when no hinting should be performed. */
- AF_DECLARE_SCRIPT_CLASS(af_dummy_script_class)
+ AF_DECLARE_WRITING_SYSTEM_CLASS( af_dummy_writing_system_class )
/* */
diff --git a/src/3rdparty/freetype/src/autofit/aferrors.h b/src/3rdparty/freetype/src/autofit/aferrors.h
index c2ed5fe2ab..50e1a22dd5 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 by */
+/* Copyright 2005, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX AF_Err_
#define FT_ERR_BASE FT_Mod_Err_Autofit
diff --git a/src/3rdparty/freetype/src/autofit/afglobal.c b/src/3rdparty/freetype/src/autofit/afglobal.c
index ac293619d3..a54c20c023 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, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2003-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,133 +17,215 @@
#include "afglobal.h"
-#include "afdummy.h"
-#include "aflatin.h"
-#include "afcjk.h"
-#include "afindic.h"
-#include "afpic.h"
+#include "afranges.h"
+#include "hbshim.h"
+#include FT_INTERNAL_DEBUG_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_afglobal
+
+
+ /* get writing system specific header files */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) /* empty */
+#include "afwrtsys.h"
#include "aferrors.h"
+#include "afpic.h"
+
+
+#undef SCRIPT
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+ AF_DEFINE_SCRIPT_CLASS( \
+ af_ ## s ## _script_class, \
+ AF_SCRIPT_ ## S, \
+ af_ ## s ## _uniranges, \
+ sc1, sc2, sc3 )
+
+#include "afscript.h"
+
+
+#undef STYLE
+#define STYLE( s, S, d, ws, sc, ss, c ) \
+ AF_DEFINE_STYLE_CLASS( \
+ af_ ## s ## _style_class, \
+ AF_STYLE_ ## S, \
+ ws, \
+ sc, \
+ ss, \
+ c )
+
+#include "afstyles.h"
-#ifdef FT_OPTION_AUTOFIT2
-#include "aflatin2.h"
-#endif
#ifndef FT_CONFIG_OPTION_PIC
-/* when updating this table, don't forget to update
- AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) \
+ &af_ ## ws ## _writing_system_class,
- /* populate this list when you add new scripts */
- static AF_ScriptClass const af_script_classes[] =
+ FT_LOCAL_ARRAY_DEF( AF_WritingSystemClass )
+ af_writing_system_classes[] =
{
- &af_dummy_script_class,
-#ifdef FT_OPTION_AUTOFIT2
- &af_latin2_script_class,
-#endif
- &af_latin_script_class,
- &af_cjk_script_class,
- &af_indic_script_class,
+
+#include "afwrtsys.h"
+
NULL /* do not remove */
};
-#endif /* FT_CONFIG_OPTION_PIC */
- /* index of default script in `af_script_classes' */
-#define AF_SCRIPT_LIST_DEFAULT 2
- /* a bit mask indicating an uncovered glyph */
-#define AF_SCRIPT_LIST_NONE 0x7F
- /* if this flag is set, we have an ASCII digit */
-#define AF_DIGIT 0x80
+#undef SCRIPT
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+ &af_ ## s ## _script_class,
+
+ FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
+ af_script_classes[] =
+ {
+
+#include "afscript.h"
+
+ NULL /* do not remove */
+ };
- /*
- * Note that glyph_scripts[] is used to map each glyph into
- * an index into the `af_script_classes' array.
- *
- */
- typedef struct AF_FaceGlobalsRec_
+#undef STYLE
+#define STYLE( s, S, d, ws, sc, ss, c ) \
+ &af_ ## s ## _style_class,
+
+ FT_LOCAL_ARRAY_DEF( AF_StyleClass )
+ af_style_classes[] =
{
- FT_Face face;
- FT_Long glyph_count; /* same as face->num_glyphs */
- FT_Byte* glyph_scripts;
- AF_ScriptMetrics metrics[AF_SCRIPT_MAX];
+#include "afstyles.h"
+
+ NULL /* do not remove */
+ };
+
+#endif /* !FT_CONFIG_OPTION_PIC */
+
- } AF_FaceGlobalsRec;
+#ifdef FT_DEBUG_LEVEL_TRACE
+#undef STYLE
+#define STYLE( s, S, d, ws, sc, ss, c ) #s,
+
+ FT_LOCAL_ARRAY_DEF( char* )
+ af_style_names[] =
+ {
+
+#include "afstyles.h"
+
+ };
- /* Compute the script index of each glyph within a given face. */
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+
+ /* Compute the style index of each glyph within a given face. */
static FT_Error
- af_face_globals_compute_script_coverage( AF_FaceGlobals globals )
+ af_face_globals_compute_style_coverage( AF_FaceGlobals globals )
{
- FT_Error error = AF_Err_Ok;
+ FT_Error error;
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
- FT_Byte* gscripts = globals->glyph_scripts;
- FT_UInt ss, i;
+ FT_Byte* gstyles = globals->glyph_styles;
+ FT_UInt ss;
+ FT_UInt i;
+ FT_UInt dflt = ~0U; /* a non-valid value */
- /* the value 255 means `uncovered glyph' */
- FT_MEM_SET( globals->glyph_scripts,
- AF_SCRIPT_LIST_NONE,
+ /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
+ FT_MEM_SET( globals->glyph_styles,
+ AF_STYLE_UNASSIGNED,
globals->glyph_count );
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
if ( error )
{
- /*
- * Ignore this error; we simply use the default script.
- * XXX: Shouldn't we rather disable hinting?
- */
- error = AF_Err_Ok;
+ /*
+ * Ignore this error; we simply use the fallback style.
+ * XXX: Shouldn't we rather disable hinting?
+ */
+ error = FT_Err_Ok;
goto Exit;
}
- /* scan each script in a Unicode charmap */
- for ( ss = 0; AF_SCRIPT_CLASSES_GET[ss]; ss++ )
+ /* scan each style in a Unicode charmap */
+ for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
{
- AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[ss];
+ AF_StyleClass style_class =
+ AF_STYLE_CLASSES_GET[ss];
+ AF_ScriptClass script_class =
+ AF_SCRIPT_CLASSES_GET[style_class->script];
AF_Script_UniRange range;
- if ( clazz->script_uni_ranges == NULL )
+ if ( script_class->script_uni_ranges == NULL )
continue;
/*
- * Scan all unicode points in the range and set the corresponding
- * glyph script index.
+ * Scan all Unicode points in the range and set the corresponding
+ * glyph style index.
*/
- for ( range = clazz->script_uni_ranges; range->first != 0; range++ )
+ if ( style_class->coverage == AF_COVERAGE_DEFAULT )
{
- FT_ULong charcode = range->first;
- FT_UInt gindex;
-
+ if ( (FT_UInt)style_class->script ==
+ globals->module->default_script )
+ dflt = ss;
- gindex = FT_Get_Char_Index( face, charcode );
-
- if ( gindex != 0 &&
- gindex < (FT_ULong)globals->glyph_count &&
- gscripts[gindex] == AF_SCRIPT_LIST_NONE )
+ for ( range = script_class->script_uni_ranges;
+ range->first != 0;
+ range++ )
{
- gscripts[gindex] = (FT_Byte)ss;
- }
+ FT_ULong charcode = range->first;
+ FT_UInt gindex;
- for (;;)
- {
- charcode = FT_Get_Next_Char( face, charcode, &gindex );
- if ( gindex == 0 || charcode > range->last )
- break;
+ gindex = FT_Get_Char_Index( face, charcode );
- if ( gindex < (FT_ULong)globals->glyph_count &&
- gscripts[gindex] == AF_SCRIPT_LIST_NONE )
+ if ( gindex != 0 &&
+ gindex < (FT_ULong)globals->glyph_count &&
+ gstyles[gindex] == AF_STYLE_UNASSIGNED )
+ gstyles[gindex] = (FT_Byte)ss;
+
+ for (;;)
{
- gscripts[gindex] = (FT_Byte)ss;
+ charcode = FT_Get_Next_Char( face, charcode, &gindex );
+
+ if ( gindex == 0 || charcode > range->last )
+ break;
+
+ if ( gindex < (FT_ULong)globals->glyph_count &&
+ gstyles[gindex] == AF_STYLE_UNASSIGNED )
+ gstyles[gindex] = (FT_Byte)ss;
}
}
}
+ else
+ {
+ /* get glyphs not directly addressable by cmap */
+ af_get_coverage( globals, style_class, gstyles );
+ }
+ }
+
+ /* 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 */
+ 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 );
}
/* mark ASCII digits */
@@ -153,25 +235,68 @@
if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
- gscripts[gindex] |= AF_DIGIT;
+ gstyles[gindex] |= AF_DIGIT;
}
Exit:
/*
- * By default, all uncovered glyphs are set to the latin script.
+ * By default, all uncovered glyphs are set to the fallback style.
* XXX: Shouldn't we disable hinting or do something similar?
*/
+ if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED )
{
FT_Long nn;
for ( nn = 0; nn < globals->glyph_count; nn++ )
{
- if ( gscripts[nn] == AF_SCRIPT_LIST_NONE )
- gscripts[nn] = AF_SCRIPT_LIST_DEFAULT;
+ if ( ( gstyles[nn] & ~AF_DIGIT ) == AF_STYLE_UNASSIGNED )
+ {
+ gstyles[nn] &= ~AF_STYLE_UNASSIGNED;
+ gstyles[nn] |= globals->module->fallback_style;
+ }
+ }
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+ FT_TRACE4(( "\n"
+ "style coverage\n"
+ "==============\n"
+ "\n" ));
+
+ for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
+ {
+ AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
+ FT_UInt count = 0;
+ FT_Long idx;
+
+
+ FT_TRACE4(( "%s:\n", af_style_names[style_class->style] ));
+
+ for ( idx = 0; idx < globals->glyph_count; idx++ )
+ {
+ if ( ( gstyles[idx] & ~AF_DIGIT ) == style_class->style )
+ {
+ if ( !( count % 10 ) )
+ FT_TRACE4(( " " ));
+
+ FT_TRACE4(( " %d", idx ));
+ count++;
+
+ if ( !( count % 10 ) )
+ FT_TRACE4(( "\n" ));
+ }
}
+
+ if ( !count )
+ FT_TRACE4(( " (none)\n" ));
+ if ( count % 10 )
+ FT_TRACE4(( "\n" ));
}
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
FT_Set_Charmap( face, old_charmap );
return error;
}
@@ -179,30 +304,39 @@
FT_LOCAL_DEF( FT_Error )
af_face_globals_new( FT_Face face,
- AF_FaceGlobals *aglobals )
+ AF_FaceGlobals *aglobals,
+ AF_Module module )
{
FT_Error error;
FT_Memory memory;
- AF_FaceGlobals globals;
+ AF_FaceGlobals globals = NULL;
memory = face->memory;
- if ( !FT_ALLOC( globals, sizeof ( *globals ) +
- face->num_glyphs * sizeof ( FT_Byte ) ) )
- {
- globals->face = face;
- globals->glyph_count = face->num_glyphs;
- globals->glyph_scripts = (FT_Byte*)( globals + 1 );
+ if ( FT_ALLOC( globals, sizeof ( *globals ) +
+ face->num_glyphs * sizeof ( FT_Byte ) ) )
+ goto Exit;
- error = af_face_globals_compute_script_coverage( globals );
- if ( error )
- {
- af_face_globals_free( globals );
- globals = NULL;
- }
+ globals->face = face;
+ globals->glyph_count = face->num_glyphs;
+ globals->glyph_styles = (FT_Byte*)( globals + 1 );
+ globals->module = module;
+
+#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
+ globals->hb_font = hb_ft_font_create( face, NULL );
+#endif
+
+ error = af_face_globals_compute_style_coverage( globals );
+ if ( error )
+ {
+ af_face_globals_free( globals );
+ globals = NULL;
}
+ else
+ globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX;
+ Exit:
*aglobals = globals;
return error;
}
@@ -217,25 +351,31 @@
FT_UInt nn;
- for ( nn = 0; nn < AF_SCRIPT_MAX; nn++ )
+ for ( nn = 0; nn < AF_STYLE_MAX; nn++ )
{
if ( globals->metrics[nn] )
{
- AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[nn];
+ AF_StyleClass style_class =
+ AF_STYLE_CLASSES_GET[nn];
+ AF_WritingSystemClass writing_system_class =
+ AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
- FT_ASSERT( globals->metrics[nn]->clazz == clazz );
-
- if ( clazz->script_metrics_done )
- clazz->script_metrics_done( globals->metrics[nn] );
+ if ( writing_system_class->style_metrics_done )
+ writing_system_class->style_metrics_done( globals->metrics[nn] );
FT_FREE( globals->metrics[nn] );
}
}
- globals->glyph_count = 0;
- globals->glyph_scripts = NULL; /* no need to free this one! */
- globals->face = NULL;
+#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
+ hb_font_destroy( globals->hb_font );
+ globals->hb_font = NULL;
+#endif
+
+ globals->glyph_count = 0;
+ globals->glyph_styles = NULL; /* no need to free this one! */
+ globals->face = NULL;
FT_FREE( globals );
}
@@ -243,60 +383,64 @@
FT_LOCAL_DEF( FT_Error )
- af_face_globals_get_metrics( AF_FaceGlobals globals,
- FT_UInt gindex,
- FT_UInt options,
- AF_ScriptMetrics *ametrics )
+ af_face_globals_get_metrics( AF_FaceGlobals globals,
+ FT_UInt gindex,
+ FT_UInt options,
+ AF_StyleMetrics *ametrics )
{
- AF_ScriptMetrics metrics = NULL;
- FT_UInt gidx;
- AF_ScriptClass clazz;
- FT_UInt script = options & 15;
- const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
- sizeof ( AF_SCRIPT_CLASSES_GET[0] );
- FT_Error error = AF_Err_Ok;
+ AF_StyleMetrics metrics = NULL;
+
+ AF_Style style = (AF_Style)options;
+ AF_WritingSystemClass writing_system_class;
+ AF_StyleClass style_class;
+
+ FT_Error error = FT_Err_Ok;
if ( gindex >= (FT_ULong)globals->glyph_count )
{
- error = AF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
- gidx = script;
- if ( gidx == 0 || gidx + 1 >= script_max )
- gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_LIST_NONE;
+ /* if we have a forced style (via `options'), use it, */
+ /* otherwise look into `glyph_styles' array */
+ if ( style == AF_STYLE_NONE_DFLT || style + 1 >= AF_STYLE_MAX )
+ style = (AF_Style)( globals->glyph_styles[gindex] &
+ AF_STYLE_UNASSIGNED );
- clazz = AF_SCRIPT_CLASSES_GET[gidx];
- if ( script == 0 )
- script = clazz->script;
+ style_class = AF_STYLE_CLASSES_GET[style];
+ writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET
+ [style_class->writing_system];
- metrics = globals->metrics[clazz->script];
+ metrics = globals->metrics[style];
if ( metrics == NULL )
{
- /* create the global metrics object when needed */
+ /* create the global metrics object if necessary */
FT_Memory memory = globals->face->memory;
- if ( FT_ALLOC( metrics, clazz->script_metrics_size ) )
+ if ( FT_ALLOC( metrics, writing_system_class->style_metrics_size ) )
goto Exit;
- metrics->clazz = clazz;
+ metrics->style_class = style_class;
+ metrics->globals = globals;
- if ( clazz->script_metrics_init )
+ if ( writing_system_class->style_metrics_init )
{
- error = clazz->script_metrics_init( metrics, globals->face );
+ error = writing_system_class->style_metrics_init( metrics,
+ globals->face );
if ( error )
{
- if ( clazz->script_metrics_done )
- clazz->script_metrics_done( metrics );
+ if ( writing_system_class->style_metrics_done )
+ writing_system_class->style_metrics_done( metrics );
FT_FREE( metrics );
goto Exit;
}
}
- globals->metrics[clazz->script] = metrics;
+ globals->metrics[style] = metrics;
}
Exit:
@@ -311,7 +455,7 @@
FT_UInt gindex )
{
if ( gindex < (FT_ULong)globals->glyph_count )
- return (FT_Bool)( globals->glyph_scripts[gindex] & AF_DIGIT );
+ return (FT_Bool)( globals->glyph_styles[gindex] & AF_DIGIT );
return (FT_Bool)0;
}
diff --git a/src/3rdparty/freetype/src/autofit/afglobal.h b/src/3rdparty/freetype/src/autofit/afglobal.h
index 2a68e19607..38d8d69528 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, 2004, 2005, 2007, 2009 by */
+/* Copyright 2003-2005, 2007, 2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,16 +17,71 @@
/***************************************************************************/
-#ifndef __AF_GLOBAL_H__
-#define __AF_GLOBAL_H__
+#ifndef __AFGLOBAL_H__
+#define __AFGLOBAL_H__
#include "aftypes.h"
+#include "afmodule.h"
+#include "hbshim.h"
FT_BEGIN_HEADER
+ FT_LOCAL_ARRAY( AF_WritingSystemClass )
+ af_writing_system_classes[];
+
+
+#undef SCRIPT
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+ AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
+
+#include "afscript.h"
+
+ FT_LOCAL_ARRAY( AF_ScriptClass )
+ af_script_classes[];
+
+
+#undef STYLE
+#define STYLE( s, S, d, ws, sc, ss, c ) \
+ AF_DECLARE_STYLE_CLASS( af_ ## s ## _style_class )
+
+#include "afstyles.h"
+
+ FT_LOCAL_ARRAY( AF_StyleClass )
+ af_style_classes[];
+
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_LOCAL_ARRAY( char* )
+ af_style_names[];
+#endif
+
+
+ /*
+ * Default values and flags for both autofitter globals (found in
+ * AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
+ */
+
+ /* index of fallback style in `af_style_classes' */
+#ifdef AF_CONFIG_OPTION_CJK
+#define AF_STYLE_FALLBACK AF_STYLE_HANI_DFLT
+#else
+#define AF_STYLE_FALLBACK AF_STYLE_NONE_DFLT
+#endif
+ /* default script for OpenType; ignored if HarfBuzz isn't used */
+#define AF_SCRIPT_DEFAULT AF_SCRIPT_LATN
+ /* a bit mask indicating an uncovered glyph */
+#define AF_STYLE_UNASSIGNED 0x7F
+ /* if this flag is set, we have an ASCII digit */
+#define AF_DIGIT 0x80
+
+ /* `increase-x-height' property */
+#define AF_PROP_INCREASE_X_HEIGHT_MIN 6
+#define AF_PROP_INCREASE_X_HEIGHT_MAX 0
+
+
/************************************************************************/
/************************************************************************/
/***** *****/
@@ -37,21 +92,45 @@ FT_BEGIN_HEADER
/*
- * model the global hints data for a given face, decomposed into
- * script-specific items
+ * Note that glyph_styles[] maps each glyph to an index into the
+ * `af_style_classes' array.
+ *
*/
- typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
+ typedef struct AF_FaceGlobalsRec_
+ {
+ FT_Face face;
+ FT_Long glyph_count; /* same as face->num_glyphs */
+ FT_Byte* glyph_styles;
+
+#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
+ hb_font_t* hb_font;
+#endif
+
+ /* per-face auto-hinter properties */
+ FT_UInt increase_x_height;
+ AF_StyleMetrics metrics[AF_STYLE_MAX];
+
+ AF_Module module; /* to access global properties */
+
+ } AF_FaceGlobalsRec;
+
+
+ /*
+ * model the global hints data for a given face, decomposed into
+ * style-specific items
+ */
FT_LOCAL( FT_Error )
af_face_globals_new( FT_Face face,
- AF_FaceGlobals *aglobals );
+ AF_FaceGlobals *aglobals,
+ AF_Module module );
FT_LOCAL( FT_Error )
- af_face_globals_get_metrics( AF_FaceGlobals globals,
- FT_UInt gindex,
- FT_UInt options,
- AF_ScriptMetrics *ametrics );
+ af_face_globals_get_metrics( AF_FaceGlobals globals,
+ FT_UInt gindex,
+ FT_UInt options,
+ AF_StyleMetrics *ametrics );
FT_LOCAL( void )
af_face_globals_free( AF_FaceGlobals globals );
@@ -65,7 +144,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AF_GLOBALS_H__ */
+#endif /* __AFGLOBAL_H__ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afhints.c b/src/3rdparty/freetype/src/autofit/afhints.c
index fe38fba995..f3cc50f202 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, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2003-2007, 2009-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,14 +19,27 @@
#include "afhints.h"
#include "aferrors.h"
#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_DEBUG_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_afhints
+
+
+ /* Get new segment for given axis. */
+
FT_LOCAL_DEF( FT_Error )
af_axis_hints_new_segment( AF_AxisHints axis,
FT_Memory memory,
AF_Segment *asegment )
{
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
AF_Segment segment = NULL;
@@ -39,7 +52,7 @@
if ( old_max >= big_max )
{
- error = AF_Err_Out_Of_Memory;
+ error = FT_THROW( Out_Of_Memory );
goto Exit;
}
@@ -61,14 +74,17 @@
}
+ /* Get new edge for given axis, direction, and position, */
+ /* without initializing the edge itself. */
+
FT_LOCAL( FT_Error )
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
AF_Direction dir,
FT_Memory memory,
- AF_Edge *aedge )
+ AF_Edge *anedge )
{
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
AF_Edge edge = NULL;
AF_Edge edges;
@@ -82,7 +98,7 @@
if ( old_max >= big_max )
{
- error = AF_Err_Out_Of_Memory;
+ error = FT_THROW( Out_Of_Memory );
goto Exit;
}
@@ -115,20 +131,27 @@
axis->num_edges++;
- FT_ZERO( edge );
- edge->fpos = (FT_Short)fpos;
- edge->dir = (FT_Char)dir;
-
Exit:
- *aedge = edge;
+ *anedge = edge;
return error;
}
-#ifdef AF_DEBUG
+#ifdef FT_DEBUG_AUTOFIT
#include FT_CONFIG_STANDARD_LIBRARY_H
+ /* The dump functions are used in the `ftgrid' demo program, too. */
+#define AF_DUMP( varformat ) \
+ do \
+ { \
+ if ( to_stdout ) \
+ printf varformat; \
+ else \
+ FT_TRACE7( varformat ); \
+ } while ( 0 )
+
+
static const char*
af_dir_str( AF_Direction dir )
{
@@ -157,41 +180,41 @@
}
-#define AF_INDEX_NUM( ptr, base ) ( (ptr) ? ( (ptr) - (base) ) : -1 )
+#define AF_INDEX_NUM( ptr, base ) (int)( (ptr) ? ( (ptr) - (base) ) : -1 )
+#ifdef __cplusplus
+ extern "C" {
+#endif
void
- af_glyph_hints_dump_points( AF_GlyphHints hints )
+ 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;
- printf( "Table of points:\n" );
- printf( " [ index | xorg | yorg | xscale | yscale "
- "| xfit | yfit | flags ]\n" );
+ AF_DUMP(( "Table of points:\n"
+ " [ index | xorg | yorg | xscale | yscale"
+ " | xfit | yfit | flags ]\n" ));
for ( point = points; point < limit; point++ )
- {
- printf( " [ %5d | %5d | %5d | %-5.2f | %-5.2f "
- "| %-5.2f | %-5.2f | %c%c%c%c%c%c ]\n",
- point - points,
- point->fx,
- point->fy,
- point->ox/64.0,
- point->oy/64.0,
- point->x/64.0,
- point->y/64.0,
- ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' ',
- ( point->flags & AF_FLAG_INFLECTION ) ? 'i' : ' ',
- ( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ',
- ( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ',
- ( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ',
- ( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' ');
- }
- printf( "\n" );
+ AF_DUMP(( " [ %5d | %5d | %5d | %6.2f | %6.2f"
+ " | %5.2f | %5.2f | %c ]\n",
+ AF_INDEX_NUM( point, points ),
+ point->fx,
+ point->fy,
+ point->ox / 64.0,
+ point->oy / 64.0,
+ point->x / 64.0,
+ point->y / 64.0,
+ ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' '));
+ AF_DUMP(( "\n" ));
}
+#ifdef __cplusplus
+ }
+#endif
static const char*
@@ -216,15 +239,20 @@
if ( pos == 0 )
return "normal";
- temp[pos] = 0;
+ temp[pos] = '\0';
return temp;
}
- /* A function to dump the array of linked segments. */
+ /* Dump the array of linked segments. */
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
void
- af_glyph_hints_dump_segments( AF_GlyphHints hints )
+ af_glyph_hints_dump_segments( AF_GlyphHints hints,
+ FT_Bool to_stdout )
{
FT_Int dimension;
@@ -232,36 +260,130 @@
for ( dimension = 1; dimension >= 0; dimension-- )
{
AF_AxisHints axis = &hints->axis[dimension];
+ AF_Point points = hints->points;
+ AF_Edge edges = axis->edges;
AF_Segment segments = axis->segments;
AF_Segment limit = segments + axis->num_segments;
AF_Segment seg;
- printf ( "Table of %s segments:\n",
- dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
- printf ( " [ index | pos | dir | link | serif |"
- " height | extra | flags ]\n" );
+ 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" ));
+ else
+ AF_DUMP(( " (none)\n" ));
for ( seg = segments; seg < limit; seg++ )
- {
- printf ( " [ %5d | %5.2g | %5s | %4d | %5d | %5d | %5d | %s ]\n",
- seg - segments,
- dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0
- : (int)seg->first->oy / 64.0,
- af_dir_str( (AF_Direction)seg->dir ),
- AF_INDEX_NUM( seg->link, segments ),
- AF_INDEX_NUM( seg->serif, segments ),
- seg->height,
- seg->height - ( seg->max_coord - seg->min_coord ),
- af_edge_flags_to_string( seg->flags ) );
- }
- printf( "\n" );
+ AF_DUMP(( " [ %5d | %5.2g | %5s | %4d"
+ " | %4d | %4d | %5d | %4d"
+ " | %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,
+ 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 ),
+ seg->height,
+ seg->height - ( seg->max_coord - seg->min_coord ),
+ af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) ));
+ AF_DUMP(( "\n" ));
}
}
+#ifdef __cplusplus
+ }
+#endif
+
+
+ /* Fetch number of segments. */
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+ FT_Error
+ af_glyph_hints_get_num_segments( AF_GlyphHints hints,
+ FT_Int dimension,
+ FT_Int* num_segments )
+ {
+ AF_Dimension dim;
+ AF_AxisHints axis;
+
+
+ dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
+
+ axis = &hints->axis[dim];
+ *num_segments = axis->num_segments;
+
+ return FT_Err_Ok;
+ }
+#ifdef __cplusplus
+ }
+#endif
+
+
+ /* Fetch offset of segments into user supplied offset array. */
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+ FT_Error
+ af_glyph_hints_get_segment_offset( AF_GlyphHints hints,
+ FT_Int dimension,
+ FT_Int idx,
+ FT_Pos *offset,
+ FT_Bool *is_blue,
+ FT_Pos *blue_offset )
+ {
+ AF_Dimension dim;
+ AF_AxisHints axis;
+ AF_Segment seg;
+
+
+ if ( !offset )
+ return FT_THROW( Invalid_Argument );
+
+ dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
+
+ axis = &hints->axis[dim];
+
+ if ( idx < 0 || idx >= axis->num_segments )
+ return FT_THROW( Invalid_Argument );
+
+ seg = &axis->segments[idx];
+ *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->ox
+ : seg->first->oy;
+ 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;
+ else
+ *blue_offset = 0;
+
+ return FT_Err_Ok;
+ }
+#ifdef __cplusplus
+ }
+#endif
+
+ /* Dump the array of linked edges. */
+#ifdef __cplusplus
+ extern "C" {
+#endif
void
- af_glyph_hints_dump_edges( AF_GlyphHints hints )
+ af_glyph_hints_dump_edges( AF_GlyphHints hints,
+ FT_Bool to_stdout )
{
FT_Int dimension;
@@ -276,60 +398,43 @@
/*
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
- * since they have constant a X coordinate.
+ * since they have a constant X coordinate.
*/
- printf ( "Table of %s edges:\n",
- dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
- printf ( " [ index | pos | dir | link |"
- " serif | blue | opos | pos | flags ]\n" );
+ AF_DUMP(( "Table of %s edges:\n",
+ dimension == AF_DIMENSION_HORZ ? "vertical"
+ : "horizontal" ));
+ if ( axis->num_edges )
+ AF_DUMP(( " [ index | pos | dir | link"
+ " | serif | blue | opos | pos | flags ]\n" ));
+ else
+ AF_DUMP(( " (none)\n" ));
for ( edge = edges; edge < limit; edge++ )
- {
- printf ( " [ %5d | %5.2g | %5s | %4d |"
- " %5d | %c | %5.2f | %5.2f | %s ]\n",
- 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 ),
- edge->blue_edge ? 'y' : 'n',
- edge->opos / 64.0,
- edge->pos / 64.0,
- af_edge_flags_to_string( edge->flags ) );
- }
- printf( "\n" );
+ AF_DUMP(( " [ %5d | %5.2g | %5s | %4d"
+ " | %5d | %c | %5.2f | %5.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 ),
+ edge->blue_edge ? 'y' : 'n',
+ edge->opos / 64.0,
+ edge->pos / 64.0,
+ af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) ));
+ AF_DUMP(( "\n" ));
}
}
-
-#else /* !AF_DEBUG */
-
- /* these empty stubs are only used to link the `ftgrid' test program */
- /* when debugging is disabled */
-
- void
- af_glyph_hints_dump_points( AF_GlyphHints hints )
- {
- FT_UNUSED( hints );
- }
-
-
- void
- af_glyph_hints_dump_segments( AF_GlyphHints hints )
- {
- FT_UNUSED( hints );
+#ifdef __cplusplus
}
+#endif
+#undef AF_DUMP
- void
- af_glyph_hints_dump_edges( AF_GlyphHints hints )
- {
- FT_UNUSED( hints );
- }
+#endif /* !FT_DEBUG_AUTOFIT */
-#endif /* !AF_DEBUG */
+ /* Compute the direction value of a given vector. */
- /* compute the direction value of a given vector */
FT_LOCAL_DEF( AF_Direction )
af_direction_compute( FT_Pos dx,
FT_Pos dy )
@@ -369,6 +474,8 @@
}
}
+ /* return no direction if arm lengths differ too much */
+ /* (value 14 is heuristic, corresponding to approx. 4.1 degrees) */
ss *= 14;
if ( FT_ABS( ll ) <= FT_ABS( ss ) )
dir = AF_DIR_NONE;
@@ -377,120 +484,6 @@
}
- /* compute all inflex points in a given glyph */
-
- static void
- af_glyph_hints_compute_inflections( AF_GlyphHints hints )
- {
- AF_Point* contour = hints->contours;
- AF_Point* contour_limit = contour + hints->num_contours;
-
-
- /* do each contour separately */
- for ( ; contour < contour_limit; contour++ )
- {
- AF_Point point = contour[0];
- AF_Point first = point;
- AF_Point start = point;
- AF_Point end = point;
- AF_Point before;
- AF_Point after;
- FT_Pos in_x, in_y, out_x, out_y;
- AF_Angle orient_prev, orient_cur;
- FT_Int finished = 0;
-
-
- /* compute first segment in contour */
- first = point;
-
- start = end = first;
- do
- {
- end = end->next;
- if ( end == first )
- goto Skip;
-
- in_x = end->fx - start->fx;
- in_y = end->fy - start->fy;
-
- } while ( in_x == 0 && in_y == 0 );
-
- /* extend the segment start whenever possible */
- before = start;
- do
- {
- do
- {
- start = before;
- before = before->prev;
- if ( before == first )
- goto Skip;
-
- out_x = start->fx - before->fx;
- out_y = start->fy - before->fy;
-
- } while ( out_x == 0 && out_y == 0 );
-
- orient_prev = ft_corner_orientation( in_x, in_y, out_x, out_y );
-
- } while ( orient_prev == 0 );
-
- first = start;
-
- in_x = out_x;
- in_y = out_y;
-
- /* now process all segments in the contour */
- do
- {
- /* first, extend current segment's end whenever possible */
- after = end;
- do
- {
- do
- {
- end = after;
- after = after->next;
- if ( after == first )
- finished = 1;
-
- out_x = after->fx - end->fx;
- out_y = after->fy - end->fy;
-
- } while ( out_x == 0 && out_y == 0 );
-
- orient_cur = ft_corner_orientation( in_x, in_y, out_x, out_y );
-
- } while ( orient_cur == 0 );
-
- if ( ( orient_prev + orient_cur ) == 0 )
- {
- /* we have an inflection point here */
- do
- {
- start->flags |= AF_FLAG_INFLECTION;
- start = start->next;
-
- } while ( start != end );
-
- start->flags |= AF_FLAG_INFLECTION;
- }
-
- start = end;
- end = after;
-
- orient_prev = orient_cur;
- in_x = out_x;
- in_y = out_y;
-
- } while ( !finished );
-
- Skip:
- ;
- }
- }
-
-
FT_LOCAL_DEF( void )
af_glyph_hints_init( AF_GlyphHints hints,
FT_Memory memory )
@@ -503,58 +496,62 @@
FT_LOCAL_DEF( void )
af_glyph_hints_done( AF_GlyphHints hints )
{
- if ( hints && hints->memory )
- {
- FT_Memory memory = hints->memory;
- int dim;
+ FT_Memory memory = hints->memory;
+ int dim;
- /*
- * note that we don't need to free the segment and edge
- * buffers, since they are really within the hints->points array
- */
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- AF_AxisHints axis = &hints->axis[dim];
+ if ( !( hints && hints->memory ) )
+ return;
+ /*
+ * note that we don't need to free the segment and edge
+ * buffers since they are really within the hints->points array
+ */
+ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
+ {
+ AF_AxisHints axis = &hints->axis[dim];
- axis->num_segments = 0;
- axis->max_segments = 0;
- FT_FREE( axis->segments );
- axis->num_edges = 0;
- axis->max_edges = 0;
- FT_FREE( axis->edges );
- }
+ axis->num_segments = 0;
+ axis->max_segments = 0;
+ FT_FREE( axis->segments );
- FT_FREE( hints->contours );
- hints->max_contours = 0;
- hints->num_contours = 0;
+ axis->num_edges = 0;
+ axis->max_edges = 0;
+ FT_FREE( axis->edges );
+ }
- FT_FREE( hints->points );
- hints->num_points = 0;
- hints->max_points = 0;
+ FT_FREE( hints->contours );
+ hints->max_contours = 0;
+ hints->num_contours = 0;
- hints->memory = NULL;
- }
+ FT_FREE( hints->points );
+ hints->num_points = 0;
+ hints->max_points = 0;
+
+ hints->memory = NULL;
}
+ /* Reset metrics. */
+
FT_LOCAL_DEF( void )
- af_glyph_hints_rescale( AF_GlyphHints hints,
- AF_ScriptMetrics metrics )
+ af_glyph_hints_rescale( AF_GlyphHints hints,
+ AF_StyleMetrics metrics )
{
hints->metrics = metrics;
hints->scaler_flags = metrics->scaler.flags;
}
+ /* Recompute all AF_Point in AF_GlyphHints from the definitions */
+ /* in a source outline. */
+
FT_LOCAL_DEF( FT_Error )
af_glyph_hints_reload( AF_GlyphHints hints,
- FT_Outline* outline,
- FT_Bool get_inflections )
+ FT_Outline* outline )
{
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
AF_Point points;
FT_UInt old_max, new_max;
FT_Fixed x_scale = hints->x_scale;
@@ -572,12 +569,12 @@
hints->axis[1].num_segments = 0;
hints->axis[1].num_edges = 0;
- /* first of all, reallocate the contours array when necessary */
+ /* first of all, reallocate the contours array if necessary */
new_max = (FT_UInt)outline->n_contours;
old_max = hints->max_contours;
if ( new_max > old_max )
{
- new_max = ( new_max + 3 ) & ~3;
+ new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
goto Exit;
@@ -594,7 +591,7 @@
old_max = hints->max_points;
if ( new_max > old_max )
{
- new_max = ( new_max + 2 + 7 ) & ~7;
+ new_max = ( new_max + 2 + 7 ) & ~7; /* round up to a multiple of 8 */
if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
goto Exit;
@@ -639,15 +636,16 @@
{
FT_Vector* vec = outline->points;
char* tag = outline->tags;
- AF_Point first = points;
AF_Point end = points + outline->contours[0];
AF_Point prev = end;
FT_Int contour_index = 0;
- FT_UNUSED( first );
for ( point = points; point < point_limit; point++, vec++, tag++ )
{
+ point->in_dir = (FT_Char)AF_DIR_NONE;
+ point->out_dir = (FT_Char)AF_DIR_NONE;
+
point->fx = (FT_Short)vec->x;
point->fy = (FT_Short)vec->y;
point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
@@ -662,7 +660,7 @@
point->flags = AF_FLAG_CUBIC;
break;
default:
- point->flags = 0;
+ point->flags = AF_FLAG_NONE;
}
point->prev = prev;
@@ -673,15 +671,14 @@
{
if ( ++contour_index < outline->n_contours )
{
- first = point + 1;
- end = points + outline->contours[contour_index];
- prev = end;
+ end = points + outline->contours[contour_index];
+ prev = end;
}
}
}
}
- /* set-up the contours array */
+ /* set up the contours array */
{
AF_Point* contour = hints->contours;
AF_Point* contour_limit = contour + hints->num_contours;
@@ -696,72 +693,239 @@
}
}
- /* compute directions of in & out vectors */
{
- AF_Point first = points;
- AF_Point prev = NULL;
- FT_Pos in_x = 0;
- FT_Pos in_y = 0;
- AF_Direction in_dir = AF_DIR_NONE;
+ /*
+ * Compute directions of `in' and `out' vectors.
+ *
+ * Note that distances between points that are very near to each
+ * other are accumulated. In other words, the auto-hinter
+ * prepends the small vectors between near points to the first
+ * non-near vector. All intermediate points are tagged as
+ * weak; the directions are adjusted also to be equal to the
+ * accumulated one.
+ */
+
+ /* value 20 in `near_limit' is heuristic */
+ FT_UInt units_per_em = hints->metrics->scaler.face->units_per_EM;
+ FT_Int near_limit = 20 * units_per_em / 2048;
+ FT_Int near_limit2 = 2 * near_limit - 1;
+
+ AF_Point* contour;
+ AF_Point* contour_limit = hints->contours + hints->num_contours;
+
+
+ for ( contour = hints->contours; contour < contour_limit; contour++ )
+ {
+ AF_Point first = *contour;
+ AF_Point next, prev, curr;
+ FT_Pos out_x, out_y;
- for ( point = points; point < point_limit; point++ )
- {
- AF_Point next;
- FT_Pos out_x, out_y;
+ FT_Bool is_first;
- if ( point == first )
+ /* since the first point of a contour could be part of a */
+ /* series of near points, go backwards to find the first */
+ /* non-near point and adjust `first' */
+
+ point = first;
+ prev = first->prev;
+
+ while ( prev != first )
{
- prev = first->prev;
- in_x = first->fx - prev->fx;
- in_y = first->fy - prev->fy;
- in_dir = af_direction_compute( in_x, in_y );
- first = prev + 1;
+ out_x = point->fx - prev->fx;
+ out_y = point->fy - prev->fy;
+
+ /*
+ * We use Taxicab metrics to measure the vector length.
+ *
+ * Note that the accumulated distances so far could have the
+ * opposite direction of the distance measured here. For this
+ * reason we use `near_limit2' for the comparison to get a
+ * non-near point even in the worst case.
+ */
+ if ( FT_ABS( out_x ) + FT_ABS( out_y ) >= near_limit2 )
+ break;
+
+ point = prev;
+ prev = prev->prev;
+ }
+
+ /* adjust first point */
+ first = point;
+
+ /* now loop over all points of the contour to get */
+ /* `in' and `out' vector directions */
+
+ curr = first;
+
+ /*
+ * We abuse the `u' and `v' fields to store index deltas to the
+ * next and previous non-near point, respectively.
+ *
+ * To avoid problems with not having non-near points, we point to
+ * `first' by default as the next non-near point.
+ *
+ */
+ curr->u = (FT_Pos)( first - curr );
+ first->v = -curr->u;
+
+ out_x = 0;
+ out_y = 0;
+
+ is_first = 1;
+
+ for ( point = first;
+ point != first || is_first;
+ point = point->next )
+ {
+ AF_Direction out_dir;
+
+
+ is_first = 0;
+
+ next = point->next;
+
+ out_x += next->fx - point->fx;
+ out_y += next->fy - point->fy;
+
+ if ( FT_ABS( out_x ) + FT_ABS( out_y ) < near_limit )
+ {
+ next->flags |= AF_FLAG_WEAK_INTERPOLATION;
+ continue;
+ }
+
+ curr->u = (FT_Pos)( next - curr );
+ next->v = -curr->u;
+
+ out_dir = af_direction_compute( out_x, out_y );
+
+ /* adjust directions for all points inbetween; */
+ /* the loop also updates position of `curr' */
+ curr->out_dir = (FT_Char)out_dir;
+ for ( curr = curr->next; curr != next; curr = curr->next )
+ {
+ curr->in_dir = (FT_Char)out_dir;
+ curr->out_dir = (FT_Char)out_dir;
+ }
+ next->in_dir = (FT_Char)out_dir;
+
+ curr->u = (FT_Pos)( first - curr );
+ first->v = -curr->u;
+
+ out_x = 0;
+ out_y = 0;
}
+ }
+
+ /*
+ * The next step is to `simplify' an outline's topology so that we
+ * can identify local extrema more reliably: A series of
+ * non-horizontal or non-vertical vectors pointing into the same
+ * quadrant are handled as a single, long vector. From a
+ * topological point of the view, the intermediate points are of no
+ * interest and thus tagged as weak.
+ */
+
+ for ( point = points; point < point_limit; point++ )
+ {
+ if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
+ continue;
+
+ if ( point->in_dir == AF_DIR_NONE &&
+ point->out_dir == AF_DIR_NONE )
+ {
+ /* check whether both vectors point into the same quadrant */
+
+ FT_Pos in_x, in_y;
+ FT_Pos out_x, out_y;
+
+ AF_Point next_u = point + point->u;
+ AF_Point prev_v = point + point->v;
- point->in_dir = (FT_Char)in_dir;
- next = point->next;
- out_x = next->fx - point->fx;
- out_y = next->fy - point->fy;
+ in_x = point->fx - prev_v->fx;
+ in_y = point->fy - prev_v->fy;
- in_dir = af_direction_compute( out_x, out_y );
- point->out_dir = (FT_Char)in_dir;
+ out_x = next_u->fx - point->fx;
+ out_y = next_u->fy - point->fy;
- if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) )
+ if ( ( in_x ^ out_x ) >= 0 && ( in_y ^ out_y ) >= 0 )
+ {
+ /* yes, so tag current point as weak */
+ /* and update index deltas */
+
+ point->flags |= AF_FLAG_WEAK_INTERPOLATION;
+
+ prev_v->u = (FT_Pos)( next_u - prev_v );
+ next_u->v = -prev_v->u;
+ }
+ }
+ }
+
+ /*
+ * Finally, check for remaining weak points. Everything else not
+ * collected in edges so far is then implicitly classified as strong
+ * points.
+ */
+
+ for ( point = points; point < point_limit; point++ )
+ {
+ if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
+ continue;
+
+ if ( point->flags & AF_FLAG_CONTROL )
{
+ /* control points are always weak */
Is_Weak_Point:
point->flags |= AF_FLAG_WEAK_INTERPOLATION;
}
else if ( point->out_dir == point->in_dir )
{
if ( point->out_dir != AF_DIR_NONE )
+ {
+ /* current point lies on a horizontal or */
+ /* vertical segment (but doesn't start or end it) */
goto Is_Weak_Point;
+ }
- if ( ft_corner_is_flat( in_x, in_y, out_x, out_y ) )
- goto Is_Weak_Point;
+ {
+ AF_Point next_u = point + point->u;
+ AF_Point prev_v = point + point->v;
+
+
+ if ( ft_corner_is_flat( point->fx - prev_v->fx,
+ point->fy - prev_v->fy,
+ next_u->fx - point->fx,
+ next_u->fy - point->fy ) )
+ {
+ /* either the `in' or the `out' vector is much more */
+ /* dominant than the other one, so tag current point */
+ /* as weak and update index deltas */
+
+ prev_v->u = (FT_Pos)( next_u - prev_v );
+ next_u->v = -prev_v->u;
+
+ goto Is_Weak_Point;
+ }
+ }
}
else if ( point->in_dir == -point->out_dir )
+ {
+ /* current point forms a spike */
goto Is_Weak_Point;
-
- in_x = out_x;
- in_y = out_y;
- prev = point;
+ }
}
}
}
- /* compute inflection points -- */
- /* disabled due to no longer perceived benefits */
- if ( 0 && get_inflections )
- af_glyph_hints_compute_inflections( hints );
-
Exit:
return error;
}
+ /* Store the hinted outline in an FT_Outline structure. */
+
FT_LOCAL_DEF( void )
af_glyph_hints_save( AF_GlyphHints hints,
FT_Outline* outline )
@@ -794,6 +958,9 @@
****************************************************************/
+ /* Align all points of an edge to the same coordinate value, */
+ /* either horizontally or vertically. */
+
FT_LOCAL_DEF( void )
af_glyph_hints_align_edge_points( AF_GlyphHints hints,
AF_Dimension dim )
@@ -827,7 +994,6 @@
break;
point = point->next;
-
}
}
}
@@ -867,8 +1033,8 @@
****************************************************************/
- /* hint the strong points -- this is equivalent to the TrueType `IP' */
- /* hinting instruction */
+ /* Hint the strong points -- this is equivalent to the TrueType `IP' */
+ /* hinting instruction. */
FT_LOCAL_DEF( void )
af_glyph_hints_align_strong_points( AF_GlyphHints hints,
@@ -905,8 +1071,7 @@
/* if this point is candidate to weak interpolation, we */
/* interpolate it after all strong points have been processed */
- if ( ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) &&
- !( point->flags & AF_FLAG_INFLECTION ) )
+ if ( ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) )
continue;
if ( dim == AF_DIMENSION_VERT )
@@ -950,11 +1115,12 @@
max = edge_limit - edges;
#if 1
- /* for small edge counts, a linear search is better */
+ /* for a small number of edges, a linear search is better */
if ( max <= 8 )
{
FT_PtrDist nn;
+
for ( nn = 0; nn < max; nn++ )
if ( edges[nn].fpos >= u )
break;
@@ -986,6 +1152,7 @@
}
}
+ /* point is not on an edge */
{
AF_Edge before = edges + min - 1;
AF_Edge after = edges + min + 0;
@@ -1021,6 +1188,10 @@
****************************************************************/
+ /* Shift the original coordinates of all points between `p1' and */
+ /* `p2' to get hinted coordinates, using the same difference as */
+ /* given by `ref'. */
+
static void
af_iup_shift( AF_Point p1,
AF_Point p2,
@@ -1029,6 +1200,7 @@
AF_Point p;
FT_Pos delta = ref->u - ref->v;
+
if ( delta == 0 )
return;
@@ -1040,6 +1212,13 @@
}
+ /* Interpolate the original coordinates of all points between `p1' and */
+ /* `p2' to get hinted coordinates, using `ref1' and `ref2' as the */
+ /* reference points. The `u' and `v' members are the current and */
+ /* original coordinate values, respectively. */
+ /* */
+ /* Details can be found in the TrueType bytecode specification. */
+
static void
af_iup_interp( AF_Point p1,
AF_Point p2,
@@ -1108,6 +1287,9 @@
}
+ /* Hint the weak points -- this is equivalent to the TrueType `IUP' */
+ /* hinting instruction. */
+
FT_LOCAL_DEF( void )
af_glyph_hints_align_weak_points( AF_GlyphHints hints,
AF_Dimension dim )
@@ -1145,8 +1327,6 @@
}
}
- point = points;
-
for ( ; contour < contour_limit; contour++ )
{
AF_Point first_touched, last_touched;
@@ -1169,21 +1349,21 @@
}
first_touched = point;
- last_touched = point;
for (;;)
{
- FT_ASSERT( point <= end_point &&
+ FT_ASSERT( point <= end_point &&
( point->flags & touch_flag ) != 0 );
- /* skip any touched neighbhours */
- while ( point < end_point && ( point[1].flags & touch_flag ) != 0 )
+ /* skip any touched neighbours */
+ while ( point < end_point &&
+ ( point[1].flags & touch_flag ) != 0 )
point++;
last_touched = point;
/* find the next touched point, if any */
- point ++;
+ point++;
for (;;)
{
if ( point > end_point )
@@ -1203,9 +1383,8 @@
EndContour:
/* special case: only one point was touched */
if ( last_touched == first_touched )
- {
af_iup_shift( first_point, end_point, first_touched );
- }
+
else /* interpolate the last part */
{
if ( last_touched < end_point )
@@ -1235,7 +1414,9 @@
}
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
+
+ /* Apply (small) warp scale and warp delta for given dimension. */
FT_LOCAL_DEF( void )
af_glyph_hints_scale_dim( AF_GlyphHints hints,
@@ -1260,6 +1441,6 @@
}
}
-#endif /* AF_USE_WARPER */
+#endif /* AF_CONFIG_OPTION_USE_WARPER */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afhints.h b/src/3rdparty/freetype/src/autofit/afhints.h
index 675826835a..92101de7ca 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, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 2003-2008, 2010-2012, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,10 +25,10 @@
FT_BEGIN_HEADER
- /*
- * The definition of outline glyph hints. These are shared by all
- * script analysis routines (until now).
- */
+ /*
+ * The definition of outline glyph hints. These are shared by all
+ * writing system analysis routines (until now).
+ */
typedef enum AF_Dimension_
{
@@ -55,6 +55,157 @@ FT_BEGIN_HEADER
} AF_Direction;
+ /*
+ * The following explanations are mostly taken from the article
+ *
+ * Real-Time Grid Fitting of Typographic Outlines
+ *
+ * by David Turner and Werner Lemberg
+ *
+ * http://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
+ *
+ * with appropriate updates.
+ *
+ *
+ * Segments
+ *
+ * `af_{cjk,latin,...}_hints_compute_segments' are the functions to
+ * find segments in an outline.
+ *
+ * A segment is a series of at least two consecutive points that are
+ * approximately aligned along a coordinate axis. The analysis to do
+ * so is specific to a writing system.
+ *
+ *
+ * Edges
+ *
+ * `af_{cjk,latin,...}_hints_compute_edges' are the functions to find
+ * edges.
+ *
+ * As soon as segments are defined, the auto-hinter groups them into
+ * edges. An edge corresponds to a single position on the main
+ * dimension that collects one or more segments (allowing for a small
+ * threshold).
+ *
+ * As an example, the `latin' writing system first tries to grid-fit
+ * edges, then to align segments on the edges unless it detects that
+ * they form a serif.
+ *
+ *
+ * A H
+ * | |
+ * | |
+ * | |
+ * | |
+ * C | | F
+ * +------<-----+ +-----<------+
+ * | B G |
+ * | |
+ * | |
+ * +--------------->------------------+
+ * D E
+ *
+ *
+ * Stems
+ *
+ * Stems are detected by `af_{cjk,latin,...}_hint_edges'.
+ *
+ * Segments need to be `linked' to other ones in order to detect stems.
+ * A stem is made of two segments that face each other in opposite
+ * directions and that are sufficiently close to each other. Using
+ * vocabulary from the TrueType specification, stem segments form a
+ * `black distance'.
+ *
+ * In the above ASCII drawing, the horizontal segments are BC, DE, and
+ * FG; the vertical segments are AB, CD, EF, and GH.
+ *
+ * Each segment has at most one `best' candidate to form a black
+ * distance, or no candidate at all. Notice that two distinct segments
+ * can have the same candidate, which frequently means a serif.
+ *
+ * A stem is recognized by the following condition:
+ *
+ * best segment_1 = segment_2 && best segment_2 = segment_1
+ *
+ * The best candidate is stored in field `link' in structure
+ * `AF_Segment'.
+ *
+ * In the above ASCII drawing, the best candidate for both AB and CD is
+ * GH, while the best candidate for GH is AB. Similarly, the best
+ * candidate for EF and GH is AB, while the best candidate for AB is
+ * GH.
+ *
+ * The detection and handling of stems is dependent on the writing
+ * system.
+ *
+ *
+ * Serifs
+ *
+ * Serifs are detected by `af_{cjk,latin,...}_hint_edges'.
+ *
+ * In comparison to a stem, a serif (as handled by the auto-hinter
+ * module that takes care of the `latin' writing system) has
+ *
+ * best segment_1 = segment_2 && best segment_2 != segment_1
+ *
+ * where segment_1 corresponds to the serif segment (CD and EF in the
+ * above ASCII drawing).
+ *
+ * The best candidate is stored in field `serif' in structure
+ * `AF_Segment' (and `link' is set to NULL).
+ *
+ *
+ * Touched points
+ *
+ * A point is called `touched' if it has been processed somehow by the
+ * auto-hinter. It basically means that it shouldn't be moved again
+ * (or moved only under certain constraints to preserve the already
+ * applied processing).
+ *
+ *
+ * Flat and round segments
+ *
+ * Segments are `round' or `flat', depending on the series of points
+ * that define them. A segment is round if the next and previous point
+ * of an extremum (which can be either a single point or sequence of
+ * points) are both conic or cubic control points. Otherwise, a
+ * segment with an extremum is flat.
+ *
+ *
+ * Strong Points
+ *
+ * Experience has shown that points not part of an edge need to be
+ * interpolated linearly between their two closest edges, even if these
+ * are not part of the contour of those particular points. Typical
+ * candidates for this are
+ *
+ * - angle points (i.e., points where the `in' and `out' direction
+ * differ greatly)
+ *
+ * - inflection points (i.e., where the `in' and `out' angles are the
+ * same, but the curvature changes sign) [currently, such points
+ * aren't handled specially in the auto-hinter]
+ *
+ * `af_glyph_hints_align_strong_points' is the function that takes
+ * care of such situations; it is equivalent to the TrueType `IP'
+ * hinting instruction.
+ *
+ *
+ * Weak Points
+ *
+ * Other points in the outline must be interpolated using the
+ * coordinates of their previous and next unfitted contour neighbours.
+ * These are called `weak points' and are touched by the function
+ * `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP'
+ * hinting instruction. Typical candidates are control points and
+ * points on the contour without a major direction.
+ *
+ * The major effect is to reduce possible distortion caused by
+ * alignment of edges and strong points, thus weak points are processed
+ * after strong points.
+ */
+
+
/* point hint flags */
typedef enum AF_Flags_
{
@@ -65,23 +216,12 @@ FT_BEGIN_HEADER
AF_FLAG_CUBIC = 1 << 1,
AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
- /* point extremum flags */
- AF_FLAG_EXTREMA_X = 1 << 2,
- AF_FLAG_EXTREMA_Y = 1 << 3,
-
- /* point roundness flags */
- AF_FLAG_ROUND_X = 1 << 4,
- AF_FLAG_ROUND_Y = 1 << 5,
-
/* point touch flags */
- AF_FLAG_TOUCH_X = 1 << 6,
- AF_FLAG_TOUCH_Y = 1 << 7,
+ AF_FLAG_TOUCH_X = 1 << 2,
+ AF_FLAG_TOUCH_Y = 1 << 3,
/* candidates for weak interpolation have this flag set */
- AF_FLAG_WEAK_INTERPOLATION = 1 << 8,
-
- /* all inflection points in the outline have this flag set */
- AF_FLAG_INFLECTION = 1 << 9
+ AF_FLAG_WEAK_INTERPOLATION = 1 << 4
} AF_Flags;
@@ -89,10 +229,11 @@ FT_BEGIN_HEADER
/* edge hint flags */
typedef enum AF_Edge_Flags_
{
- AF_EDGE_NORMAL = 0,
- AF_EDGE_ROUND = 1 << 0,
- AF_EDGE_SERIF = 1 << 1,
- AF_EDGE_DONE = 1 << 2
+ AF_EDGE_NORMAL = 0,
+ AF_EDGE_ROUND = 1 << 0,
+ AF_EDGE_SERIF = 1 << 1,
+ AF_EDGE_DONE = 1 << 2,
+ AF_EDGE_NEUTRAL = 1 << 3 /* set if edge aligns to a neutral blue zone */
} AF_Edge_Flags;
@@ -109,7 +250,7 @@ FT_BEGIN_HEADER
FT_Char out_dir; /* direction of outwards vector */
FT_Pos ox, oy; /* original, scaled position */
- FT_Short fx, fy; /* original, unscaled position (font units) */
+ FT_Short fx, fy; /* original, unscaled position (in font units) */
FT_Pos x, y; /* current position */
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
@@ -137,84 +278,80 @@ FT_BEGIN_HEADER
FT_Pos score; /* used during stem matching */
FT_Pos len; /* used during stem matching */
- AF_Point first; /* first point in edge segment */
- AF_Point last; /* last point in edge segment */
- AF_Point* contour; /* ptr to first point of segment's contour */
+ AF_Point first; /* first point in edge segment */
+ AF_Point last; /* last point in edge segment */
} AF_SegmentRec;
typedef struct AF_EdgeRec_
{
- FT_Short fpos; /* original, unscaled position (font units) */
- FT_Pos opos; /* original, scaled position */
- FT_Pos pos; /* current position */
+ FT_Short fpos; /* original, unscaled position (in font units) */
+ FT_Pos opos; /* original, scaled position */
+ FT_Pos pos; /* current position */
FT_Byte flags; /* edge flags */
FT_Char dir; /* edge direction */
FT_Fixed scale; /* used to speed up interpolation between edges */
- AF_Width blue_edge; /* non-NULL if this is a blue edge */
- AF_Edge link;
- AF_Edge serif;
- FT_Short num_linked;
+ 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 */
- FT_Int score;
-
- AF_Segment first;
- AF_Segment last;
+ AF_Segment first; /* first segment in edge */
+ AF_Segment last; /* last segment in edge */
} AF_EdgeRec;
typedef struct AF_AxisHintsRec_
{
- FT_Int num_segments;
- FT_Int max_segments;
- AF_Segment segments;
+ FT_Int num_segments; /* number of used segments */
+ FT_Int max_segments; /* number of allocated segments */
+ AF_Segment segments; /* segments array */
#ifdef AF_SORT_SEGMENTS
FT_Int mid_segments;
#endif
- FT_Int num_edges;
- FT_Int max_edges;
- AF_Edge edges;
+ FT_Int num_edges; /* number of used edges */
+ FT_Int max_edges; /* number of allocated edges */
+ AF_Edge edges; /* edges array */
- AF_Direction major_dir;
+ AF_Direction major_dir; /* either vertical or horizontal */
} AF_AxisHintsRec, *AF_AxisHints;
typedef struct AF_GlyphHintsRec_
{
- FT_Memory memory;
+ FT_Memory memory;
- FT_Fixed x_scale;
- FT_Pos x_delta;
+ FT_Fixed x_scale;
+ FT_Pos x_delta;
- FT_Fixed y_scale;
- FT_Pos y_delta;
+ FT_Fixed y_scale;
+ FT_Pos y_delta;
- FT_Pos edge_distance_threshold;
+ FT_Int max_points; /* number of allocated points */
+ FT_Int num_points; /* number of used points */
+ AF_Point points; /* points array */
- FT_Int max_points;
- FT_Int num_points;
- AF_Point points;
+ FT_Int max_contours; /* number of allocated contours */
+ FT_Int num_contours; /* number of used contours */
+ AF_Point* contours; /* contours array */
- FT_Int max_contours;
- FT_Int num_contours;
- AF_Point* contours;
+ AF_AxisHintsRec axis[AF_DIMENSION_MAX];
- AF_AxisHintsRec axis[AF_DIMENSION_MAX];
+ FT_UInt32 scaler_flags; /* copy of scaler flags */
+ FT_UInt32 other_flags; /* free for style-specific */
+ /* implementations */
+ AF_StyleMetrics metrics;
- FT_UInt32 scaler_flags; /* copy of scaler flags */
- FT_UInt32 other_flags; /* free for script-specific */
- /* implementations */
- AF_ScriptMetrics metrics;
+ FT_Pos xmin_delta; /* used for warping */
+ FT_Pos xmax_delta;
- FT_Pos xmin_delta; /* used for warping */
- FT_Pos xmax_delta;
-
} AF_GlyphHintsRec;
@@ -222,7 +359,7 @@ FT_BEGIN_HEADER
#define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) )
-#ifdef AF_DEBUG
+#ifdef FT_DEBUG_AUTOFIT
#define AF_HINTS_DO_HORIZONTAL( h ) \
( !_af_debug_disable_horz_hints && \
@@ -237,7 +374,7 @@ FT_BEGIN_HEADER
#define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
-#else /* !AF_DEBUG */
+#else /* !FT_DEBUG_AUTOFIT */
#define AF_HINTS_DO_HORIZONTAL( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL )
@@ -250,7 +387,7 @@ FT_BEGIN_HEADER
#define AF_HINTS_DO_BLUES( h ) 1
-#endif /* !AF_DEBUG */
+#endif /* !FT_DEBUG_AUTOFIT */
FT_LOCAL( AF_Direction )
@@ -274,20 +411,13 @@ FT_BEGIN_HEADER
af_glyph_hints_init( AF_GlyphHints hints,
FT_Memory memory );
-
-
- /*
- * recompute all AF_Point in a AF_GlyphHints from the definitions
- * in a source outline
- */
FT_LOCAL( void )
- af_glyph_hints_rescale( AF_GlyphHints hints,
- AF_ScriptMetrics metrics );
+ af_glyph_hints_rescale( AF_GlyphHints hints,
+ AF_StyleMetrics metrics );
FT_LOCAL( FT_Error )
af_glyph_hints_reload( AF_GlyphHints hints,
- FT_Outline* outline,
- FT_Bool get_inflections );
+ FT_Outline* outline );
FT_LOCAL( void )
af_glyph_hints_save( AF_GlyphHints hints,
@@ -305,7 +435,7 @@ FT_BEGIN_HEADER
af_glyph_hints_align_weak_points( AF_GlyphHints hints,
AF_Dimension dim );
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
FT_LOCAL( void )
af_glyph_hints_scale_dim( AF_GlyphHints hints,
AF_Dimension dim,
diff --git a/src/3rdparty/freetype/src/autofit/afindic.c b/src/3rdparty/freetype/src/autofit/afindic.c
index 1d9e9eafba..197881b614 100644
--- a/src/3rdparty/freetype/src/autofit/afindic.c
+++ b/src/3rdparty/freetype/src/autofit/afindic.c
@@ -2,9 +2,9 @@
/* */
/* afindic.c */
/* */
-/* Auto-fitter hinting routines for Indic scripts (body). */
+/* Auto-fitter hinting routines for Indic writing system (body). */
/* */
-/* Copyright 2007 by */
+/* Copyright 2007, 2011-2013 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, */
@@ -27,23 +27,42 @@
#include "afcjk.h"
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
#include "afwarp.h"
#endif
static FT_Error
- af_indic_metrics_init( AF_LatinMetrics metrics,
- FT_Face face )
+ af_indic_metrics_init( AF_CJKMetrics metrics,
+ FT_Face face )
{
- /* use CJK routines */
- return af_cjk_metrics_init( metrics, face );
+ /* skip blue zone init in CJK routines */
+ FT_CharMap oldmap = face->charmap;
+
+
+ metrics->units_per_em = face->units_per_EM;
+
+ if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
+ face->charmap = NULL;
+ else
+ {
+ af_cjk_metrics_init_widths( metrics, face );
+#if 0
+ /* either need indic specific blue_chars[] or just skip blue zones */
+ af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
+#endif
+ af_cjk_metrics_check_digits( metrics, face );
+ }
+
+ FT_Set_Charmap( face, oldmap );
+
+ return FT_Err_Ok;
}
static void
- af_indic_metrics_scale( AF_LatinMetrics metrics,
- AF_Scaler scaler )
+ af_indic_metrics_scale( AF_CJKMetrics metrics,
+ AF_Scaler scaler )
{
/* use CJK routines */
af_cjk_metrics_scale( metrics, scaler );
@@ -51,8 +70,8 @@
static FT_Error
- af_indic_hints_init( AF_GlyphHints hints,
- AF_LatinMetrics metrics )
+ af_indic_hints_init( AF_GlyphHints hints,
+ AF_CJKMetrics metrics )
{
/* use CJK routines */
return af_cjk_hints_init( hints, metrics );
@@ -60,9 +79,9 @@
static FT_Error
- af_indic_hints_apply( AF_GlyphHints hints,
- FT_Outline* outline,
- AF_LatinMetrics metrics)
+ af_indic_hints_apply( AF_GlyphHints hints,
+ FT_Outline* outline,
+ AF_CJKMetrics metrics )
{
/* use CJK routines */
return af_cjk_hints_apply( hints, outline, metrics );
@@ -78,52 +97,41 @@
/*************************************************************************/
- static const AF_Script_UniRangeRec af_indic_uniranges[] =
- {
-#if 0
- AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
-#endif
- AF_UNIRANGE_REC( 0x0900UL, 0x0DFFUL), /* Indic Range */
- AF_UNIRANGE_REC( 0UL, 0UL)
- };
-
+ AF_DEFINE_WRITING_SYSTEM_CLASS(
+ af_indic_writing_system_class,
- AF_DEFINE_SCRIPT_CLASS(af_indic_script_class,
- AF_SCRIPT_INDIC,
- af_indic_uniranges,
+ AF_WRITING_SYSTEM_INDIC,
- sizeof( AF_LatinMetricsRec ),
+ sizeof ( AF_CJKMetricsRec ),
- (AF_Script_InitMetricsFunc) af_indic_metrics_init,
- (AF_Script_ScaleMetricsFunc)af_indic_metrics_scale,
- (AF_Script_DoneMetricsFunc) NULL,
+ (AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init,
+ (AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale,
+ (AF_WritingSystem_DoneMetricsFunc) NULL,
- (AF_Script_InitHintsFunc) af_indic_hints_init,
- (AF_Script_ApplyHintsFunc) af_indic_hints_apply
+ (AF_WritingSystem_InitHintsFunc) af_indic_hints_init,
+ (AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply
)
+
#else /* !AF_CONFIG_OPTION_INDIC */
- static const AF_Script_UniRangeRec af_indic_uniranges[] =
- {
- { 0, 0 }
- };
+ AF_DEFINE_WRITING_SYSTEM_CLASS(
+ af_indic_writing_system_class,
- AF_DEFINE_SCRIPT_CLASS(af_indic_script_class,
- AF_SCRIPT_INDIC,
- af_indic_uniranges,
+ AF_WRITING_SYSTEM_INDIC,
- sizeof( AF_LatinMetricsRec ),
+ sizeof ( AF_CJKMetricsRec ),
- (AF_Script_InitMetricsFunc) NULL,
- (AF_Script_ScaleMetricsFunc)NULL,
- (AF_Script_DoneMetricsFunc) NULL,
+ (AF_WritingSystem_InitMetricsFunc) NULL,
+ (AF_WritingSystem_ScaleMetricsFunc)NULL,
+ (AF_WritingSystem_DoneMetricsFunc) NULL,
- (AF_Script_InitHintsFunc) NULL,
- (AF_Script_ApplyHintsFunc) NULL
+ (AF_WritingSystem_InitHintsFunc) NULL,
+ (AF_WritingSystem_ApplyHintsFunc) NULL
)
+
#endif /* !AF_CONFIG_OPTION_INDIC */
diff --git a/src/3rdparty/freetype/src/autofit/afindic.h b/src/3rdparty/freetype/src/autofit/afindic.h
index 662a982200..9e13cf7e3f 100644
--- a/src/3rdparty/freetype/src/autofit/afindic.h
+++ b/src/3rdparty/freetype/src/autofit/afindic.h
@@ -2,9 +2,10 @@
/* */
/* afindic.h */
/* */
-/* Auto-fitter hinting routines for Indic scripts (specification). */
+/* Auto-fitter hinting routines for Indic writing system */
+/* (specification). */
/* */
-/* Copyright 2007 by */
+/* Copyright 2007, 2012, 2013 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, */
@@ -25,9 +26,9 @@
FT_BEGIN_HEADER
- /* the Indic-specific script class */
+ /* the `indic' writing system */
- AF_DECLARE_SCRIPT_CLASS(af_indic_script_class)
+ AF_DECLARE_WRITING_SYSTEM_CLASS( af_indic_writing_system_class )
/* */
diff --git a/src/3rdparty/freetype/src/autofit/aflatin.c b/src/3rdparty/freetype/src/autofit/aflatin.c
index e6882d5e7b..36a36896fb 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin.c
+++ b/src/3rdparty/freetype/src/autofit/aflatin.c
@@ -2,9 +2,9 @@
/* */
/* aflatin.c */
/* */
-/* Auto-fitter hinting routines for latin script (body). */
+/* Auto-fitter hinting routines for latin writing system (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2003-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,17 +18,30 @@
#include <ft2build.h>
#include FT_ADVANCES_H
+#include FT_INTERNAL_DEBUG_H
+#include "afglobal.h"
+#include "afpic.h"
#include "aflatin.h"
#include "aferrors.h"
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
#include "afwarp.h"
#endif
/*************************************************************************/
+ /* */
+ /* 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_aflatin
+
+
+ /*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L O B A L M E T R I C S *****/
@@ -36,31 +49,91 @@
/*************************************************************************/
/*************************************************************************/
+
+ /* Find segments and links, compute all stem widths, and initialize */
+ /* standard width and height for the glyph with given charcode. */
+
FT_LOCAL_DEF( void )
af_latin_metrics_init_widths( AF_LatinMetrics metrics,
- FT_Face face,
- FT_ULong charcode )
+ FT_Face face )
{
/* scan the array of segments in each direction */
AF_GlyphHintsRec hints[1];
+ FT_TRACE5(( "\n"
+ "latin standard widths computation (style `%s')\n"
+ "=====================================================\n"
+ "\n",
+ af_style_names[metrics->root.style_class->style] ));
+
af_glyph_hints_init( hints, face->memory );
metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
metrics->axis[AF_DIMENSION_VERT].width_count = 0;
{
- FT_Error error;
- FT_UInt glyph_index;
- int dim;
- AF_LatinMetricsRec dummy[1];
- AF_Scaler scaler = &dummy->root.scaler;
+ FT_Error error;
+ FT_ULong glyph_index;
+ FT_Long y_offset;
+ int dim;
+ AF_LatinMetricsRec dummy[1];
+ AF_Scaler scaler = &dummy->root.scaler;
+
+#ifdef FT_CONFIG_OPTION_PIC
+ AF_FaceGlobals globals = metrics->root.globals;
+#endif
+ AF_StyleClass style_class = metrics->root.style_class;
+ AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
+ [style_class->script];
- glyph_index = FT_Get_Char_Index( face, charcode );
- if ( glyph_index == 0 )
- goto Exit;
+ FT_UInt32 standard_char;
+
+
+ /*
+ * 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.
+ */
+
+ standard_char = script_class->standard_char1;
+ af_get_char_index( &metrics->root,
+ standard_char,
+ &glyph_index,
+ &y_offset );
+ if ( !glyph_index )
+ {
+ 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;
+ }
+
+ FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
+ standard_char, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
@@ -69,15 +142,19 @@
FT_ZERO( dummy );
dummy->units_per_em = metrics->units_per_em;
- scaler->x_scale = scaler->y_scale = 0x10000L;
- scaler->x_delta = scaler->y_delta = 0;
+
+ scaler->x_scale = 0x10000L;
+ scaler->y_scale = 0x10000L;
+ scaler->x_delta = 0;
+ scaler->y_delta = 0;
+
scaler->face = face;
scaler->render_mode = FT_RENDER_MODE_NORMAL;
scaler->flags = 0;
- af_glyph_hints_rescale( hints, (AF_ScriptMetrics)dummy );
+ af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
- error = af_glyph_hints_reload( hints, &face->glyph->outline, 0 );
+ error = af_glyph_hints_reload( hints, &face->glyph->outline );
if ( error )
goto Exit;
@@ -94,7 +171,15 @@
if ( error )
goto Exit;
+ /*
+ * We assume that the glyphs selected for the stem width
+ * computation are `featureless' enough so that the linking
+ * algorithm works fine without adjustments of its scoring
+ * function.
+ */
af_latin_hints_link_segments( hints,
+ 0,
+ NULL,
(AF_Dimension)dim );
seg = axhints->segments;
@@ -115,113 +200,180 @@
dist = -dist;
if ( num_widths < AF_LATIN_MAX_WIDTHS )
- axis->widths[ num_widths++ ].org = dist;
+ axis->widths[num_widths++].org = dist;
}
}
- af_sort_widths( num_widths, axis->widths );
+ /* this also replaces multiple almost identical stem widths */
+ /* with a single one (the value 100 is heuristic) */
+ af_sort_and_quantize_widths( &num_widths, axis->widths,
+ dummy->units_per_em / 100 );
axis->width_count = num_widths;
}
- Exit:
+ Exit:
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_LatinAxis axis = &metrics->axis[dim];
FT_Pos stdw;
- stdw = ( axis->width_count > 0 )
- ? axis->widths[0].org
- : AF_LATIN_CONSTANT( metrics, 50 );
+ stdw = ( axis->width_count > 0 ) ? axis->widths[0].org
+ : AF_LATIN_CONSTANT( metrics, 50 );
/* let's try 20% of the smallest width */
axis->edge_distance_threshold = stdw / 5;
axis->standard_width = stdw;
axis->extra_light = 0;
- }
- }
- af_glyph_hints_done( hints );
- }
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_UInt i;
+ FT_TRACE5(( "%s widths:\n",
+ dim == AF_DIMENSION_VERT ? "horizontal"
+ : "vertical" ));
-#define AF_LATIN_MAX_TEST_CHARACTERS 12
+ FT_TRACE5(( " %d (standard)", axis->standard_width ));
+ for ( i = 1; i < axis->width_count; i++ )
+ FT_TRACE5(( " %d", axis->widths[i].org ));
+ FT_TRACE5(( "\n" ));
+ }
+#endif
+ }
+ }
+
+ FT_TRACE5(( "\n" ));
+
+ af_glyph_hints_done( hints );
+ }
- static const char af_latin_blue_chars[AF_LATIN_MAX_BLUES]
- [AF_LATIN_MAX_TEST_CHARACTERS + 1] =
- {
- "THEZOCQS",
- "HEZLOCUS",
- "fijkdbh",
- "xzroesc",
- "xzroesc",
- "pqgjy"
- };
+ /* Find all blue zones. Flat segments give the reference points, */
+ /* round segments the overshoot positions. */
static void
af_latin_metrics_init_blues( AF_LatinMetrics metrics,
FT_Face face )
{
- FT_Pos flats [AF_LATIN_MAX_TEST_CHARACTERS];
- FT_Pos rounds[AF_LATIN_MAX_TEST_CHARACTERS];
+ FT_Pos flats [AF_BLUE_STRING_MAX_LEN];
+ FT_Pos rounds[AF_BLUE_STRING_MAX_LEN];
+
FT_Int num_flats;
FT_Int num_rounds;
- FT_Int bb;
+
AF_LatinBlue blue;
FT_Error error;
- AF_LatinAxis axis = &metrics->axis[AF_DIMENSION_VERT];
- FT_GlyphSlot glyph = face->glyph;
+ AF_LatinAxis axis = &metrics->axis[AF_DIMENSION_VERT];
+ FT_Outline outline;
+
+ AF_StyleClass sc = metrics->root.style_class;
+ AF_Blue_Stringset bss = sc->blue_stringset;
+ const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
- /* we compute the blues simply by loading each character from the */
- /* 'af_latin_blue_chars[blues]' string, then compute its top-most or */
- /* bottom-most points (depending on `AF_IS_TOP_BLUE') */
- AF_LOG(( "blue zones computation\n" ));
- AF_LOG(( "------------------------------------------------\n" ));
+ /* we walk over the blue character strings as specified in the */
+ /* style's entry in the `af_blue_stringset' array */
- for ( bb = 0; bb < AF_LATIN_BLUE_MAX; bb++ )
+ FT_TRACE5(( "latin blue zones computation\n"
+ "============================\n"
+ "\n" ));
+
+ for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
{
- const char* p = af_latin_blue_chars[bb];
- const char* limit = p + AF_LATIN_MAX_TEST_CHARACTERS;
+ const char* p = &af_blue_strings[bs->string];
FT_Pos* blue_ref;
FT_Pos* blue_shoot;
- AF_LOG(( "blue %3d: ", bb ));
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_Bool have_flag = 0;
+
+
+ FT_TRACE5(( "blue zone %d", axis->blue_count ));
+
+ if ( bs->properties )
+ {
+ FT_TRACE5(( " (" ));
+
+ if ( AF_LATIN_IS_TOP_BLUE( bs ) )
+ {
+ FT_TRACE5(( "top" ));
+ have_flag = 1;
+ }
+
+ if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
+ {
+ if ( have_flag )
+ FT_TRACE5(( ", " ));
+ FT_TRACE5(( "neutral" ));
+ have_flag = 1;
+ }
+
+ if ( AF_LATIN_IS_X_HEIGHT_BLUE( bs ) )
+ {
+ if ( have_flag )
+ FT_TRACE5(( ", " ));
+ FT_TRACE5(( "small top" ));
+ have_flag = 1;
+ }
+
+ if ( AF_LATIN_IS_LONG_BLUE( bs ) )
+ {
+ if ( have_flag )
+ FT_TRACE5(( ", " ));
+ FT_TRACE5(( "long" ));
+ }
+
+ FT_TRACE5(( ")" ));
+ }
+
+ FT_TRACE5(( ":\n" ));
+ }
+#endif /* FT_DEBUG_LEVEL_TRACE */
num_flats = 0;
num_rounds = 0;
- for ( ; p < limit && *p; p++ )
+ while ( *p )
{
- FT_UInt glyph_index;
- FT_Pos best_y; /* same as points.y */
- FT_Int best_point, best_first, best_last;
+ 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;
- AF_LOG(( "'%c'", *p ));
+ GET_UTF8_CHAR( ch, p );
/* load the character in the face -- skip unknown or empty ones */
- glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p );
+ af_get_char_index( &metrics->root, ch, &glyph_index, &y_offset );
if ( glyph_index == 0 )
+ {
+ FT_TRACE5(( " U+%04lX unavailable\n", ch ));
continue;
+ }
- error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
- if ( error || glyph->outline.n_points <= 0 )
+ error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
+ outline = face->glyph->outline;
+ if ( error || outline.n_points <= 0 )
+ {
+ FT_TRACE5(( " U+%04lX contains no outlines\n", ch ));
continue;
+ }
/* now compute min or max point indices and coordinates */
- points = glyph->outline.points;
- best_point = -1;
- best_y = 0; /* make compiler happy */
- best_first = 0; /* ditto */
- best_last = 0; /* ditto */
+ 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;
@@ -229,21 +381,21 @@
FT_Int last = -1;
- for ( nn = 0; nn < glyph->outline.n_contours; first = last+1, nn++ )
+ for ( nn = 0; nn < outline.n_contours; first = last + 1, nn++ )
{
FT_Int old_best_point = best_point;
FT_Int pp;
- last = glyph->outline.contours[nn];
+ last = outline.contours[nn];
/* Avoid single-point contours since they are never rasterized. */
/* In some fonts, they correspond to mark attachment points */
- /* which are way outside of the glyph's real outline. */
+ /* that are way outside of the glyph's real outline. */
if ( last <= first )
- continue;
+ continue;
- if ( AF_LATIN_IS_TOP_BLUE( bb ) )
+ if ( AF_LATIN_IS_TOP_BLUE( bs ) )
{
for ( pp = first; pp <= last; pp++ )
if ( best_point < 0 || points[pp].y > best_y )
@@ -264,11 +416,10 @@
if ( best_point != old_best_point )
{
- best_first = first;
- best_last = last;
+ best_contour_first = first;
+ best_contour_last = last;
}
}
- AF_LOG(( "%5d", best_y ));
}
/* now check whether the point belongs to a straight or round */
@@ -276,47 +427,297 @@
/* 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;
- /* now look for the previous and next points that are not on the */
- /* same Y coordinate. Threshold the `closeness'... */
+ best_segment_first = best_point;
+ best_segment_last = best_point;
+
+ 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;
+ }
+
+ /* 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_first )
+ if ( prev > best_contour_first )
prev--;
else
- prev = best_last;
+ prev = best_contour_last;
- dist = points[prev].y - best_y;
- if ( dist < -5 || dist > 5 )
- break;
+ 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;
+
+ best_segment_first = prev;
+
+ 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;
+ }
} while ( prev != best_point );
do
{
- if ( next < best_last )
+ if ( next < best_contour_last )
next++;
else
- next = best_first;
+ next = best_contour_first;
- dist = points[next].y - best_y;
- if ( dist < -5 || dist > 5 )
- break;
+ dist = FT_ABS( points[next].y - best_y );
+ if ( dist > 5 )
+ if ( FT_ABS( points[next].x - best_x ) <= 20 * dist )
+ break;
+
+ 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 );
- /* now, set the `round' flag depending on the segment's kind */
- round = FT_BOOL(
- FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_CURVE_TAG_ON ||
- FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_CURVE_TAG_ON );
+ 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 )
+ {
+ /* heuristic threshold value */
+ FT_Pos height_threshold = metrics->units_per_em / 4;
+
+ 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;
+
+ FT_Bool left2right;
+
+
+ /* compute direction */
+ prev = best_point;
+
+ do
+ {
+ if ( prev > best_contour_first )
+ prev--;
+ else
+ prev = best_contour_last;
+
+ if ( points[prev].x != best_x )
+ break;
+
+ } while ( prev != best_point );
+
+ /* 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;
+
+ do
+ {
+ FT_Bool l2r;
+ FT_Pos d;
+
+
+ if ( !hit )
+ {
+ /* no hit; adjust first point */
+ first = last;
+
+ /* 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;
+ }
+
+ hit = 1;
+ }
+
+ if ( last < best_contour_last )
+ last++;
+ else
+ last = best_contour_first;
+
+ if ( FT_ABS( best_y - points[first].y ) > height_threshold )
+ {
+ /* vertical distance too large */
+ hit = 0;
+ continue;
+ }
+
+ /* 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;
+ }
+
+ if ( FT_CURVE_TAG( outline.tags[last] ) == FT_CURVE_TAG_ON )
+ {
+ p_last = last;
+ if ( p_first < 0 )
+ p_first = last;
+ }
+
+ l2r = FT_BOOL( points[first].x < points[last].x );
+ d = FT_ABS( points[last].x - points[first].x );
+
+ if ( l2r == left2right &&
+ d >= length_threshold )
+ {
+ /* 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;
+ }
+
+ p_last = last;
+
+ if ( FT_CURVE_TAG( outline.tags[last] ) ==
+ FT_CURVE_TAG_ON )
+ {
+ p_last = last;
+ if ( p_first < 0 )
+ p_first = last;
+ }
+
+ } while ( last != best_segment_first );
+
+ best_y = points[first].y;
+
+ best_segment_first = first;
+ best_segment_last = last;
+
+ best_on_point_first = p_first;
+ best_on_point_last = p_last;
+
+ break;
+ }
+
+ } while ( last != best_segment_first );
+ }
+ }
+
+ /* 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 upem/8 (value 8 is heuristic) */
+ /* 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_UInt)( FT_ABS( points[best_on_point_last].x -
+ points[best_on_point_first].x ) ) >
+ metrics->units_per_em / 8 )
+ 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 );
- AF_LOG(( "%c ", round ? 'r' : 'f' ));
+ 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" ));
}
if ( round )
@@ -325,15 +726,13 @@
flats[num_flats++] = best_y;
}
- AF_LOG(( "\n" ));
-
if ( num_flats == 0 && num_rounds == 0 )
{
/*
* we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then
*/
- AF_LOG(( "empty\n" ));
+ FT_TRACE5(( " empty\n" ));
continue;
}
@@ -343,9 +742,9 @@
af_sort_pos( num_rounds, rounds );
af_sort_pos( num_flats, flats );
- blue = & axis->blues[axis->blue_count];
- blue_ref = & blue->ref.org;
- blue_shoot = & blue->shoot.org;
+ blue = &axis->blues[axis->blue_count];
+ blue_ref = &blue->ref.org;
+ blue_shoot = &blue->shoot.org;
axis->blue_count++;
@@ -361,7 +760,7 @@
}
else
{
- *blue_ref = flats[num_flats / 2];
+ *blue_ref = flats [num_flats / 2];
*blue_shoot = rounds[num_rounds / 2];
}
@@ -375,29 +774,43 @@
FT_Bool over_ref = FT_BOOL( shoot > ref );
- if ( AF_LATIN_IS_TOP_BLUE( bb ) ^ over_ref )
- *blue_shoot = *blue_ref = ( shoot + ref ) / 2;
+ if ( AF_LATIN_IS_TOP_BLUE( bs ) ^ over_ref )
+ {
+ *blue_ref =
+ *blue_shoot = ( shoot + ref ) / 2;
+
+ FT_TRACE5(( " [overshoot smaller than reference,"
+ " taking mean value]\n" ));
+ }
}
blue->flags = 0;
- if ( AF_LATIN_IS_TOP_BLUE( bb ) )
+ if ( AF_LATIN_IS_TOP_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_TOP;
+ if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
+ blue->flags |= AF_LATIN_BLUE_NEUTRAL;
/*
* The following flag is used later to adjust the y and x scales
* in order to optimize the pixel grid alignment of the top of small
* letters.
*/
- if ( bb == AF_LATIN_BLUE_SMALL_TOP )
+ if ( AF_LATIN_IS_X_HEIGHT_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_ADJUSTMENT;
- AF_LOG(( "-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot ));
+ FT_TRACE5(( " -> reference = %ld\n"
+ " overshoot = %ld\n",
+ *blue_ref, *blue_shoot ));
}
+ FT_TRACE5(( "\n" ));
+
return;
}
+ /* Check whether all ASCII digits have the same advance width. */
+
FT_LOCAL_DEF( void )
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face )
@@ -407,14 +820,14 @@
FT_Fixed advance, old_advance = 0;
- /* check whether all ASCII digits have the same advance width; */
- /* digit `0' is 0x30 in all supported charmaps */
+ /* digit `0' is 0x30 in all supported charmaps */
for ( i = 0x30; i <= 0x39; i++ )
{
- FT_UInt glyph_index;
+ FT_ULong glyph_index;
+ FT_Long y_offset;
- glyph_index = FT_Get_Char_Index( face, i );
+ af_get_char_index( &metrics->root, i, &glyph_index, &y_offset );
if ( glyph_index == 0 )
continue;
@@ -444,47 +857,32 @@
}
+ /* Initialize global metrics. */
+
FT_LOCAL_DEF( FT_Error )
af_latin_metrics_init( AF_LatinMetrics metrics,
FT_Face face )
{
- FT_Error error = AF_Err_Ok;
FT_CharMap oldmap = face->charmap;
- FT_UInt ee;
-
- static const FT_Encoding latin_encodings[] =
- {
- FT_ENCODING_UNICODE,
- FT_ENCODING_APPLE_ROMAN,
- FT_ENCODING_ADOBE_STANDARD,
- FT_ENCODING_ADOBE_LATIN_1,
- FT_ENCODING_NONE /* end of list */
- };
metrics->units_per_em = face->units_per_EM;
- /* do we have a latin charmap in there? */
- for ( ee = 0; latin_encodings[ee] != FT_ENCODING_NONE; ee++ )
- {
- error = FT_Select_Charmap( face, latin_encodings[ee] );
- if ( !error )
- break;
- }
-
- if ( !error )
+ if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
{
- /* For now, compute the standard width and height from the `o'. */
- af_latin_metrics_init_widths( metrics, face, 'o' );
+ af_latin_metrics_init_widths( metrics, face );
af_latin_metrics_init_blues( metrics, face );
af_latin_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
- return AF_Err_Ok;
+ return FT_Err_Ok;
}
+ /* Adjust scaling value, then scale and shift widths */
+ /* and blue zones (if applicable) for given dimension. */
+
static void
af_latin_metrics_scale_dim( AF_LatinMetrics metrics,
AF_Scaler scaler,
@@ -535,9 +933,26 @@
if ( blue )
{
- FT_Pos scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
- FT_Pos fitted = ( scaled + 40 ) & ~63;
+ FT_Pos scaled;
+ FT_Pos threshold;
+ FT_Pos fitted;
+ FT_UInt limit;
+ FT_UInt ppem;
+
+
+ scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
+ ppem = metrics->root.scaler.face->size->metrics.x_ppem;
+ limit = metrics->root.globals->increase_x_height;
+ threshold = 40;
+ /* if the `increase-x-height' property is active, */
+ /* we round up much more often */
+ if ( limit &&
+ ppem <= limit &&
+ ppem >= AF_PROP_INCREASE_X_HEIGHT_MIN )
+ threshold = 52;
+
+ fitted = ( scaled + threshold ) & ~63;
if ( scaled != fitted )
{
@@ -552,6 +967,17 @@
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 ));
}
}
}
@@ -571,7 +997,11 @@
metrics->root.scaler.y_delta = delta;
}
- /* scale the standard widths */
+ FT_TRACE5(( "%s widths (style `%s')\n",
+ dim == AF_DIMENSION_HORZ ? "horizontal" : "vertical",
+ af_style_names[metrics->root.style_class->style] ));
+
+ /* scale the widths */
for ( nn = 0; nn < axis->width_count; nn++ )
{
AF_Width width = axis->widths + nn;
@@ -579,15 +1009,31 @@
width->cur = FT_MulFix( width->org, scale );
width->fit = width->cur;
+
+ FT_TRACE5(( " %d scaled to %.2f\n",
+ width->org,
+ width->cur / 64.0 ));
}
+ FT_TRACE5(( "\n" ));
+
/* an extra-light axis corresponds to a standard width that is */
- /* smaller than 0.75 pixels */
+ /* smaller than 5/8 pixels */
axis->extra_light =
(FT_Bool)( FT_MulFix( axis->standard_width, scale ) < 32 + 8 );
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( axis->extra_light )
+ FT_TRACE5(( "`%s' style is extra light (at current resolution)\n"
+ "\n",
+ af_style_names[metrics->root.style_class->style] ));
+#endif
+
if ( dim == AF_DIMENSION_VERT )
{
+ FT_TRACE5(( "blue zones (style `%s')\n",
+ af_style_names[metrics->root.style_class->style] ));
+
/* scale the blue zones */
for ( nn = 0; nn < axis->blue_count; nn++ )
{
@@ -605,9 +1051,17 @@
dist = FT_MulFix( blue->ref.org - blue->shoot.org, scale );
if ( dist <= 48 && dist >= -48 )
{
- FT_Pos delta1, delta2;
+#if 0
+ FT_Pos delta1;
+#endif
+ FT_Pos delta2;
+
+ /* use discrete values for blue zone widths */
+#if 0
+
+ /* generic, original code */
delta1 = blue->shoot.org - blue->ref.org;
delta2 = delta1;
if ( delta1 < 0 )
@@ -628,19 +1082,57 @@
blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
blue->shoot.fit = blue->ref.fit + delta2;
+#else
+
+ /* simplified version due to abs(dist) <= 48 */
+ delta2 = dist;
+ if ( dist < 0 )
+ delta2 = -delta2;
+
+ if ( delta2 < 32 )
+ delta2 = 0;
+ else if ( delta2 < 48 )
+ delta2 = 32;
+ else
+ delta2 = 64;
+
+ if ( dist < 0 )
+ delta2 = -delta2;
+
+ blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
+ blue->shoot.fit = blue->ref.fit - delta2;
+
+#endif
+
blue->flags |= AF_LATIN_BLUE_ACTIVE;
+
+ 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)" ));
}
}
}
}
+ /* Scale global values in both directions. */
+
FT_LOCAL_DEF( void )
af_latin_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler )
{
metrics->root.scaler.render_mode = scaler->render_mode;
metrics->root.scaler.face = scaler->face;
+ metrics->root.scaler.flags = scaler->flags;
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
@@ -655,18 +1147,21 @@
/*************************************************************************/
/*************************************************************************/
+
+ /* Walk over all contours and compute its segments. */
+
FT_LOCAL_DEF( FT_Error )
af_latin_hints_compute_segments( AF_GlyphHints hints,
AF_Dimension dim )
{
- AF_AxisHints axis = &hints->axis[dim];
- FT_Memory memory = hints->memory;
- FT_Error error = AF_Err_Ok;
- AF_Segment segment = NULL;
- AF_SegmentRec seg0;
- AF_Point* contour = hints->contours;
- AF_Point* contour_limit = contour + hints->num_contours;
- AF_Direction major_dir, segment_dir;
+ AF_AxisHints axis = &hints->axis[dim];
+ FT_Memory memory = hints->memory;
+ FT_Error error = FT_Err_Ok;
+ AF_Segment segment = NULL;
+ AF_SegmentRec seg0;
+ AF_Point* contour = hints->contours;
+ AF_Point* contour_limit = contour + hints->num_contours;
+ AF_Direction major_dir, segment_dir;
FT_ZERO( &seg0 );
@@ -762,7 +1257,7 @@
/* a segment is round if either its first or last point */
/* is a control point */
if ( ( segment->first->flags | point->flags ) &
- AF_FLAG_CONTROL )
+ AF_FLAG_CONTROL )
segment->flags |= AF_EDGE_ROUND;
/* compute segment size */
@@ -781,7 +1276,7 @@
on_edge = 0;
segment = NULL;
- /* fallthrough */
+ /* fall through */
}
}
@@ -798,18 +1293,19 @@
/* this is the start of a new segment! */
segment_dir = (AF_Direction)point->out_dir;
- /* clear all segment fields */
error = af_axis_hints_new_segment( axis, memory, &segment );
if ( error )
goto Exit;
- segment[0] = seg0;
+ /* clear all segment fields */
+ segment[0] = seg0;
+
segment->dir = (FT_Char)segment_dir;
min_pos = max_pos = point->u;
segment->first = point;
segment->last = point;
- segment->contour = contour;
- on_edge = 1;
+
+ on_edge = 1;
}
point = point->next;
@@ -818,8 +1314,8 @@
} /* contours */
- /* now slightly increase the height of segments when this makes */
- /* sense -- this is used to better detect and ignore serifs */
+ /* now slightly increase the height of segments if this makes */
+ /* sense -- this is used to better detect and ignore serifs */
{
AF_Segment segments = axis->segments;
AF_Segment segments_end = segments + axis->num_segments;
@@ -833,9 +1329,6 @@
FT_Pos last_v = last->v;
- if ( first == last )
- continue;
-
if ( first_v < last_v )
{
AF_Point p;
@@ -874,76 +1367,129 @@
}
+ /* Link segments to form stems and serifs. If `width_count' and */
+ /* `widths' are non-zero, use them to fine-tune the scoring function. */
+
FT_LOCAL_DEF( void )
af_latin_hints_link_segments( AF_GlyphHints hints,
+ FT_UInt width_count,
+ AF_WidthRec* widths,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
- FT_Pos len_threshold, len_score;
+ FT_Pos len_threshold, len_score, dist_score, max_width;
AF_Segment seg1, seg2;
+ if ( width_count )
+ max_width = widths[width_count - 1].org;
+ else
+ max_width = 0;
+
+ /* a heuristic value to set up a minimum value for overlapping */
len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 );
if ( len_threshold == 0 )
len_threshold = 1;
+ /* a heuristic value to weight lengths */
len_score = AF_LATIN_CONSTANT( hints->metrics, 6000 );
+ /* a heuristic value to weight distances (no call to */
+ /* AF_LATIN_CONSTANT needed, since we work on multiples */
+ /* of the stem width) */
+ dist_score = 3000;
+
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
- /* the fake segments are introduced to hint the metrics -- */
- /* we must never link them to anything */
- if ( seg1->dir != axis->major_dir || seg1->first == seg1->last )
+ if ( seg1->dir != axis->major_dir )
continue;
+ /* search for stems having opposite directions, */
+ /* with seg1 to the `left' of seg2 */
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
- if ( seg1->dir + seg2->dir == 0 && seg2->pos > seg1->pos )
+ {
+ FT_Pos pos1 = seg1->pos;
+ FT_Pos pos2 = seg2->pos;
+
+
+ if ( seg1->dir + seg2->dir == 0 && pos2 > pos1 )
{
- FT_Pos pos1 = seg1->pos;
- FT_Pos pos2 = seg2->pos;
- FT_Pos dist = pos2 - pos1;
+ /* compute distance between the two segments */
+ FT_Pos min = seg1->min_coord;
+ FT_Pos max = seg1->max_coord;
+ FT_Pos len;
- if ( dist < 0 )
- dist = -dist;
+ if ( min < seg2->min_coord )
+ min = seg2->min_coord;
+
+ if ( max > seg2->max_coord )
+ max = seg2->max_coord;
+ /* compute maximum coordinate difference of the two segments */
+ /* (this is, how much they overlap) */
+ len = max - min;
+ if ( len >= len_threshold )
{
- FT_Pos min = seg1->min_coord;
- FT_Pos max = seg1->max_coord;
- FT_Pos len, score;
+ /*
+ * The score is the sum of two demerits indicating the
+ * `badness' of a fit, measured along the segments' main axis
+ * and orthogonal to it, respectively.
+ *
+ * o The less overlapping along the main axis, the worse it
+ * is, causing a larger demerit.
+ *
+ * o The nearer the orthogonal distance to a stem width, the
+ * better it is, causing a smaller demerit. For simplicity,
+ * however, we only increase the demerit for values that
+ * exceed the largest stem width.
+ */
+
+ FT_Pos dist = pos2 - pos1;
+
+ FT_Pos dist_demerit, score;
+
+
+ if ( max_width )
+ {
+ /* distance demerits are based on multiples of `max_width'; */
+ /* we scale by 1024 for getting more precision */
+ FT_Pos delta = ( dist << 10 ) / max_width - ( 1 << 10 );
- if ( min < seg2->min_coord )
- min = seg2->min_coord;
+ if ( delta > 10000 )
+ dist_demerit = 32000;
+ else if ( delta > 0 )
+ dist_demerit = delta * delta / dist_score;
+ else
+ dist_demerit = 0;
+ }
+ else
+ dist_demerit = dist; /* default if no widths available */
- if ( max > seg2->max_coord )
- max = seg2->max_coord;
+ score = dist_demerit + len_score / len;
- len = max - min;
- if ( len >= len_threshold )
+ /* and we search for the smallest score */
+ if ( score < seg1->score )
{
- score = dist + len_score / len;
-
- if ( score < seg1->score )
- {
- seg1->score = score;
- seg1->link = seg2;
- }
+ seg1->score = score;
+ seg1->link = seg2;
+ }
- if ( score < seg2->score )
- {
- seg2->score = score;
- seg2->link = seg1;
- }
+ if ( score < seg2->score )
+ {
+ seg2->score = score;
+ seg2->link = seg1;
}
}
}
+ }
}
- /* now, compute the `serif' segments */
+ /* now compute the `serif' segments, cf. explanations in `afhints.h' */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
seg2 = seg1->link;
@@ -960,12 +1506,14 @@
}
+ /* Link segments to edges, using feature analysis for selection. */
+
FT_LOCAL_DEF( FT_Error )
af_latin_hints_compute_edges( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = hints->memory;
AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim];
@@ -973,7 +1521,9 @@
AF_Segment segment_limit = segments + axis->num_segments;
AF_Segment seg;
+#if 0
AF_Direction up_dir;
+#endif
FT_Fixed scale;
FT_Pos edge_distance_threshold;
FT_Pos segment_length_threshold;
@@ -984,11 +1534,13 @@
scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
: hints->y_scale;
+#if 0
up_dir = ( dim == AF_DIMENSION_HORZ ) ? AF_DIR_UP
: AF_DIR_RIGHT;
+#endif
/*
- * We ignore all segments that are less than 1 pixels in length,
+ * 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.
*/
@@ -999,20 +1551,21 @@
/*********************************************************************/
/* */
- /* We will begin by generating a sorted table of edges for the */
- /* current direction. To do so, we simply scan each segment and try */
- /* to find an edge in our table that corresponds to its position. */
+ /* We begin by generating a sorted table of edges for the current */
+ /* direction. To do so, we simply scan each segment and try to find */
+ /* an edge in our table that corresponds to its position. */
/* */
/* If no edge is found, we create and insert a new edge in the */
/* sorted table. Otherwise, we simply add the segment to the edge's */
- /* list which will be processed in the second step to compute the */
+ /* list which gets processed in the second step to compute the */
/* edge's properties. */
/* */
- /* Note that the edges table is sorted along the segment/edge */
+ /* Note that the table of edges is sorted along the segment/edge */
/* position. */
/* */
/*********************************************************************/
+ /* assure that edge distance threshold is at most 0.25px */
edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold,
scale );
if ( edge_distance_threshold > 64 / 4 )
@@ -1023,7 +1576,7 @@
for ( seg = segments; seg < segment_limit; seg++ )
{
- AF_Edge found = 0;
+ AF_Edge found = NULL;
FT_Int ee;
@@ -1072,9 +1625,10 @@
edge->first = seg;
edge->last = seg;
- edge->fpos = seg->pos;
edge->dir = seg->dir;
- edge->opos = edge->pos = FT_MulFix( seg->pos, scale );
+ edge->fpos = seg->pos;
+ edge->opos = FT_MulFix( seg->pos, scale );
+ edge->pos = edge->opos;
seg->edge_next = seg;
}
else
@@ -1088,17 +1642,17 @@
}
- /*********************************************************************/
- /* */
- /* Good, we will now compute each edge's properties according to */
- /* segments found on its position. Basically, these are: */
- /* */
- /* - edge's main direction */
- /* - stem edge, serif edge or both (which defaults to stem then) */
- /* - rounded edge, straight or both (which defaults to straight) */
- /* - link for edge */
- /* */
- /*********************************************************************/
+ /******************************************************************/
+ /* */
+ /* Good, we now compute each edge's properties according to the */
+ /* segments found on its position. Basically, these are */
+ /* */
+ /* - the edge's main direction */
+ /* - stem edge, serif edge or both (which defaults to stem then) */
+ /* - rounded edge, straight or both (which defaults to straight) */
+ /* - link for edge */
+ /* */
+ /******************************************************************/
/* first of all, set the `edge' field in each segment -- this is */
/* required in order to compute edge links */
@@ -1126,13 +1680,15 @@
} while ( seg != edge->first );
}
- /* now, compute each edge properties */
+ /* now compute each edge properties */
for ( edge = edges; edge < edge_limit; edge++ )
{
FT_Int is_round = 0; /* does it contain round segments? */
FT_Int is_straight = 0; /* does it contain straight segments? */
+#if 0
FT_Pos ups = 0; /* number of upwards segments */
FT_Pos downs = 0; /* number of downwards segments */
+#endif
seg = edge->first;
@@ -1148,11 +1704,13 @@
else
is_straight++;
+#if 0
/* check for segment direction */
if ( seg->dir == up_dir )
- ups += seg->max_coord-seg->min_coord;
+ ups += seg->max_coord - seg->min_coord;
else
- downs += seg->max_coord-seg->min_coord;
+ downs += seg->max_coord - seg->min_coord;
+#endif
/* check for links -- if seg->serif is set, then seg->link must */
/* be ignored */
@@ -1228,7 +1786,7 @@
edge->dir = 0; /* both up and down! */
#endif
- /* gets rid of serifs if link is set */
+ /* get rid of serifs if link is set */
/* XXX: This gets rid of many unpleasant artefacts! */
/* Example: the `c' in cour.pfa at size 13 */
@@ -1242,8 +1800,12 @@
}
+ /* Detect segments and edges for given dimension. */
+
FT_LOCAL_DEF( FT_Error )
af_latin_hints_detect_features( AF_GlyphHints hints,
+ FT_UInt width_count,
+ AF_WidthRec* widths,
AF_Dimension dim )
{
FT_Error error;
@@ -1252,22 +1814,25 @@
error = af_latin_hints_compute_segments( hints, dim );
if ( !error )
{
- af_latin_hints_link_segments( hints, dim );
+ af_latin_hints_link_segments( hints, width_count, widths, dim );
error = af_latin_hints_compute_edges( hints, dim );
}
+
return error;
}
+ /* Compute all edges which lie within blue zones. */
+
FT_LOCAL_DEF( void )
af_latin_hints_compute_blue_edges( AF_GlyphHints hints,
AF_LatinMetrics metrics )
{
- AF_AxisHints axis = &hints->axis[ AF_DIMENSION_VERT ];
+ AF_AxisHints axis = &hints->axis[AF_DIMENSION_VERT];
AF_Edge edge = axis->edges;
AF_Edge edge_limit = edge + axis->num_edges;
- AF_LatinAxis latin = &metrics->axis[ AF_DIMENSION_VERT ];
+ AF_LatinAxis latin = &metrics->axis[AF_DIMENSION_VERT];
FT_Fixed scale = latin->scale;
@@ -1277,38 +1842,43 @@
/* for each horizontal edge search the blue zone which is closest */
for ( ; edge < edge_limit; edge++ )
{
- FT_Int bb;
- AF_Width best_blue = NULL;
- FT_Pos best_dist; /* initial threshold */
+ FT_UInt bb;
+ AF_Width best_blue = NULL;
+ FT_Bool best_blue_is_neutral = 0;
+ FT_Pos best_dist; /* initial threshold */
/* compute the initial threshold as a fraction of the EM size */
+ /* (the value 40 is heuristic) */
best_dist = FT_MulFix( metrics->units_per_em / 40, scale );
+ /* assure a minimum distance of 0.5px */
if ( best_dist > 64 / 2 )
best_dist = 64 / 2;
- for ( bb = 0; bb < AF_LATIN_BLUE_MAX; bb++ )
+ for ( bb = 0; bb < latin->blue_count; bb++ )
{
AF_LatinBlue blue = latin->blues + bb;
- FT_Bool is_top_blue, is_major_dir;
+ FT_Bool is_top_blue, is_neutral_blue, is_major_dir;
- /* skip inactive blue zones (i.e., those that are too small) */
+ /* skip inactive blue zones (i.e., those that are too large) */
if ( !( blue->flags & AF_LATIN_BLUE_ACTIVE ) )
continue;
- /* if it is a top zone, check for right edges -- if it is a bottom */
- /* zone, check for left edges */
- /* */
- /* of course, that's for TrueType */
- is_top_blue = (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_TOP ) != 0 );
- is_major_dir = FT_BOOL( edge->dir == axis->major_dir );
-
- /* if it is a top zone, the edge must be against the major */
- /* direction; if it is a bottom zone, it must be in the major */
- /* direction */
- if ( is_top_blue ^ is_major_dir )
+ /* if it is a top zone, check for right edges (against the major */
+ /* direction); if it is a bottom zone, check for left edges (in */
+ /* the major direction) -- this assumes the TrueType convention */
+ /* for the orientation of contours */
+ is_top_blue =
+ (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_TOP ) != 0 );
+ is_neutral_blue =
+ (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_NEUTRAL ) != 0);
+ is_major_dir =
+ FT_BOOL( edge->dir == axis->major_dir );
+
+ /* neutral blue zones are handled for both directions */
+ if ( is_top_blue ^ is_major_dir || is_neutral_blue )
{
FT_Pos dist;
@@ -1321,21 +1891,25 @@
dist = FT_MulFix( dist, scale );
if ( dist < best_dist )
{
- best_dist = dist;
- best_blue = & blue->ref;
+ best_dist = dist;
+ best_blue = &blue->ref;
+ best_blue_is_neutral = is_neutral_blue;
}
- /* now, compare it to the overshoot position if the edge is */
- /* rounded, and if the edge is over the reference position of a */
- /* top zone, or under the reference position of a bottom zone */
- if ( edge->flags & AF_EDGE_ROUND && dist != 0 )
+ /* now compare it to the overshoot position and check whether */
+ /* the edge is rounded, and whether the edge is over the */
+ /* reference position of a top zone, or under the reference */
+ /* position of a bottom zone (provided we don't have a */
+ /* neutral blue zone) */
+ if ( edge->flags & AF_EDGE_ROUND &&
+ dist != 0 &&
+ !is_neutral_blue )
{
FT_Bool is_under_ref = FT_BOOL( edge->fpos < blue->ref.org );
if ( is_top_blue ^ is_under_ref )
{
- blue = latin->blues + bb;
dist = edge->fpos - blue->shoot.org;
if ( dist < 0 )
dist = -dist;
@@ -1343,8 +1917,9 @@
dist = FT_MulFix( dist, scale );
if ( dist < best_dist )
{
- best_dist = dist;
- best_blue = & blue->shoot;
+ best_dist = dist;
+ best_blue = &blue->shoot;
+ best_blue_is_neutral = is_neutral_blue;
}
}
}
@@ -1352,11 +1927,17 @@
}
if ( best_blue )
+ {
edge->blue_edge = best_blue;
+ if ( best_blue_is_neutral )
+ edge->flags |= AF_EDGE_NEUTRAL;
+ }
}
}
+ /* Initalize hinting engine. */
+
static FT_Error
af_latin_hints_init( AF_GlyphHints hints,
AF_LatinMetrics metrics )
@@ -1366,11 +1947,11 @@
FT_Face face = metrics->root.scaler.face;
- af_glyph_hints_rescale( hints, (AF_ScriptMetrics)metrics );
+ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
/*
* correct x_scale and y_scale if needed, since they may have
- * been modified `af_latin_metrics_scale_dim' above
+ * been modified by `af_latin_metrics_scale_dim' above
*/
hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
@@ -1380,11 +1961,9 @@
/* compute flags depending on render mode, etc. */
mode = metrics->root.scaler.render_mode;
-#if 0 /* #ifdef AF_USE_WARPER */
+#if 0 /* #ifdef AF_CONFIG_OPTION_USE_WARPER */
if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
- {
metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
- }
#endif
scaler_flags = hints->scaler_flags;
@@ -1417,14 +1996,14 @@
* In `light' hinting 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 ||
+ ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
hints->scaler_flags = scaler_flags;
hints->other_flags = other_flags;
- return 0;
+ return FT_Err_Ok;
}
@@ -1436,8 +2015,8 @@
/*************************************************************************/
/*************************************************************************/
- /* snap a given width in scaled coordinates to one of the */
- /* current standard widths */
+ /* Snap a given width in scaled coordinates to one of the */
+ /* current standard widths. */
static FT_Pos
af_latin_snap_width( AF_Width widths,
@@ -1484,7 +2063,9 @@
}
- /* compute the snapped width of a given stem */
+ /* Compute the snapped width of a given stem, ignoring very thin ones. */
+ /* There is a lot of voodoo in this function; changing the hard-coded */
+ /* parameters influence the whole hinting process. */
static FT_Pos
af_latin_compute_stem_width( AF_GlyphHints hints,
@@ -1493,15 +2074,15 @@
AF_Edge_Flags base_flags,
AF_Edge_Flags stem_flags )
{
- AF_LatinMetrics metrics = (AF_LatinMetrics) hints->metrics;
- AF_LatinAxis axis = & metrics->axis[dim];
+ AF_LatinMetrics metrics = (AF_LatinMetrics)hints->metrics;
+ AF_LatinAxis axis = &metrics->axis[dim];
FT_Pos dist = width;
FT_Int sign = 0;
FT_Int vertical = ( dim == AF_DIMENSION_VERT );
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ||
- axis->extra_light )
+ axis->extra_light )
return width;
if ( dist < 0 )
@@ -1516,11 +2097,12 @@
/* smooth hinting process: very lightly quantize the stem width */
/* leave the widths of serifs alone */
-
- if ( ( stem_flags & AF_EDGE_SERIF ) && vertical && ( dist < 3 * 64 ) )
+ if ( ( stem_flags & AF_EDGE_SERIF ) &&
+ vertical &&
+ ( dist < 3 * 64 ) )
goto Done_Width;
- else if ( ( base_flags & AF_EDGE_ROUND ) )
+ else if ( base_flags & AF_EDGE_ROUND )
{
if ( dist < 80 )
dist = 64;
@@ -1534,21 +2116,18 @@
/* compare to standard width */
- if ( axis->width_count > 0 )
- {
- delta = dist - axis->widths[0].cur;
+ delta = dist - axis->widths[0].cur;
- if ( delta < 0 )
- delta = -delta;
+ if ( delta < 0 )
+ delta = -delta;
- if ( delta < 40 )
- {
- dist = axis->widths[0].cur;
- if ( dist < 48 )
- dist = 48;
+ if ( delta < 40 )
+ {
+ dist = axis->widths[0].cur;
+ if ( dist < 48 )
+ dist = 48;
- goto Done_Width;
- }
+ goto Done_Width;
}
if ( dist < 3 * 64 )
@@ -1575,6 +2154,7 @@
else
{
/* strong hinting process: snap the stem width to integer pixels */
+
FT_Pos org_dist = dist;
@@ -1627,7 +2207,7 @@
if ( delta < 0 )
delta = -delta;
- if (delta >= 16)
+ if ( delta >= 16 )
{
dist = org_dist;
if ( dist < 48 )
@@ -1649,7 +2229,7 @@
}
- /* align one stem edge relative to the previous stem edge */
+ /* Align one stem edge relative to the previous stem edge. */
static void
af_latin_align_linked_edge( AF_GlyphHints hints,
@@ -1667,13 +2247,16 @@
stem_edge->pos = base_edge->pos + fitted_width;
- AF_LOG(( "LINK: edge %d (opos=%.2f) linked to (%.2f), "
- "dist was %.2f, now %.2f\n",
- stem_edge-hints->axis[dim].edges, stem_edge->opos / 64.0,
- stem_edge->pos / 64.0, dist / 64.0, fitted_width / 64.0 ));
+ FT_TRACE5(( " LINK: edge %d (opos=%.2f) linked to %.2f,"
+ " dist was %.2f, now %.2f\n",
+ stem_edge - hints->axis[dim].edges, stem_edge->opos / 64.0,
+ stem_edge->pos / 64.0, dist / 64.0, fitted_width / 64.0 ));
}
+ /* Shift the coordinates of the `serif' edge by the same amount */
+ /* as the corresponding `base' edge has been moved already. */
+
static void
af_latin_align_serif_edge( AF_GlyphHints hints,
AF_Edge base,
@@ -1681,7 +2264,7 @@
{
FT_UNUSED( hints );
- serif->pos = base->pos + (serif->opos - base->opos);
+ serif->pos = base->pos + ( serif->opos - base->opos );
}
@@ -1696,6 +2279,8 @@
/*************************************************************************/
+ /* The main grid-fitting routine. */
+
FT_LOCAL_DEF( void )
af_latin_hint_edges( AF_GlyphHints hints,
AF_Dimension dim )
@@ -1705,9 +2290,17 @@
AF_Edge edge_limit = edges + axis->num_edges;
FT_PtrDist n_edges;
AF_Edge edge;
- AF_Edge anchor = 0;
+ AF_Edge anchor = NULL;
FT_Int has_serifs = 0;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_UInt num_actions = 0;
+#endif
+
+
+ FT_TRACE5(( "latin %s edge hinting (style `%s')\n",
+ dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
+ af_style_names[hints->metrics->style_class->style] ));
/* we begin by aligning all stems relative to the blue zone */
/* if needed -- that's only for horizontal edges */
@@ -1717,20 +2310,47 @@
for ( edge = edges; edge < edge_limit; edge++ )
{
AF_Width blue;
- AF_Edge edge1, edge2;
+ AF_Edge edge1, edge2; /* these edges form the stem to check */
if ( edge->flags & AF_EDGE_DONE )
continue;
- blue = edge->blue_edge;
edge1 = NULL;
edge2 = edge->link;
- if ( blue )
+ /*
+ * If a stem contains both a neutral and a non-neutral blue zone,
+ * skip the neutral one. Otherwise, outlines with different
+ * directions might be incorrectly aligned at the same vertical
+ * position.
+ *
+ * If we have two neutral blue zones, skip one of them.
+ *
+ */
+ if ( edge->blue_edge && edge2 && edge2->blue_edge )
{
- edge1 = edge;
+ FT_Byte neutral = edge->flags & AF_EDGE_NEUTRAL;
+ FT_Byte neutral2 = edge2->flags & AF_EDGE_NEUTRAL;
+
+
+ if ( ( neutral && neutral2 ) || neutral2 )
+ {
+ edge2->blue_edge = NULL;
+ edge2->flags &= ~AF_EDGE_NEUTRAL;
+ }
+ else if ( neutral )
+ {
+ edge->blue_edge = NULL;
+ edge->flags &= ~AF_EDGE_NEUTRAL;
+ }
}
+
+ blue = edge->blue_edge;
+ if ( blue )
+ edge1 = edge;
+
+ /* flip edges if the other edge is aligned to a blue zone */
else if ( edge2 && edge2->blue_edge )
{
blue = edge2->blue_edge;
@@ -1741,10 +2361,20 @@
if ( !edge1 )
continue;
- AF_LOG(( "BLUE: edge %d (opos=%.2f) snapped to (%.2f), "
- "was (%.2f)\n",
- edge1-edges, edge1->opos / 64.0, blue->fit / 64.0,
- edge1->pos / 64.0 ));
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !anchor )
+ FT_TRACE5(( " BLUE_ANCHOR: edge %d (opos=%.2f) snapped to %.2f,"
+ " was %.2f (anchor=edge %d)\n",
+ edge1 - edges, edge1->opos / 64.0, blue->fit / 64.0,
+ edge1->pos / 64.0, edge - edges ));
+ else
+ FT_TRACE5(( " BLUE: edge %d (opos=%.2f) snapped to %.2f,"
+ " was %.2f\n",
+ edge1 - edges, edge1->opos / 64.0, blue->fit / 64.0,
+ edge1->pos / 64.0 ));
+
+ num_actions++;
+#endif
edge1->pos = blue->fit;
edge1->flags |= AF_EDGE_DONE;
@@ -1753,6 +2383,10 @@
{
af_latin_align_linked_edge( hints, dim, edge1, edge2 );
edge2->flags |= AF_EDGE_DONE;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions++;
+#endif
}
if ( !anchor )
@@ -1760,8 +2394,8 @@
}
}
- /* now we will align all stem edges, trying to maintain the */
- /* relative order of stems in the glyph */
+ /* now we align all other stem edges, trying to maintain the */
+ /* relative order of stems in the glyph */
for ( edge = edges; edge < edge_limit; edge++ )
{
AF_Edge edge2;
@@ -1783,15 +2417,21 @@
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge )
{
- AF_LOG(( "ASSERTION FAILED for edge %d\n", edge2-edges ));
+ FT_TRACE5(( " ASSERTION FAILED for edge %d\n", edge2 - edges ));
af_latin_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions++;
+#endif
continue;
}
if ( !anchor )
{
+ /* if we reach this if clause, no stem has been aligned yet */
+
FT_Pos org_len, org_center, cur_len;
FT_Pos cur_pos1, error1, error2, u_off, d_off;
@@ -1801,10 +2441,19 @@
hints, dim, org_len,
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
+
+ /* some voodoo to specially round edges for small stem widths; */
+ /* the idea is to align the center of a stem, then shifting */
+ /* the stem edges to suitable positions */
if ( cur_len <= 64 )
- u_off = d_off = 32;
+ {
+ /* width <= 1px */
+ u_off = 32;
+ d_off = 32;
+ }
else
{
+ /* 1px < width < 1.5px */
u_off = 38;
d_off = 26;
}
@@ -1812,7 +2461,6 @@
if ( cur_len < 96 )
{
org_center = edge->opos + ( org_len >> 1 );
-
cur_pos1 = FT_PIX_ROUND( org_center );
error1 = org_center - ( cur_pos1 - u_off );
@@ -1834,16 +2482,20 @@
else
edge->pos = FT_PIX_ROUND( edge->opos );
- AF_LOG(( "ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f) "
- "snapped to (%.2f) (%.2f)\n",
- edge-edges, edge->opos / 64.0,
- edge2-edges, edge2->opos / 64.0,
- edge->pos / 64.0, edge2->pos / 64.0 ));
- anchor = edge;
-
+ anchor = edge;
edge->flags |= AF_EDGE_DONE;
+ FT_TRACE5(( " ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f)"
+ " snapped to %.2f and %.2f\n",
+ edge - edges, edge->opos / 64.0,
+ edge2 - edges, edge2->opos / 64.0,
+ edge->pos / 64.0, edge2->pos / 64.0 ));
+
af_latin_align_linked_edge( hints, dim, edge, edge2 );
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions += 2;
+#endif
}
else
{
@@ -1856,12 +2508,18 @@
org_center = org_pos + ( org_len >> 1 );
cur_len = af_latin_compute_stem_width(
- hints, dim, org_len,
- (AF_Edge_Flags)edge->flags,
- (AF_Edge_Flags)edge2->flags );
+ hints, dim, org_len,
+ (AF_Edge_Flags)edge->flags,
+ (AF_Edge_Flags)edge2->flags );
if ( edge2->flags & AF_EDGE_DONE )
+ {
+ FT_TRACE5(( " ADJUST: edge %d (pos=%.2f) moved to %.2f\n",
+ edge - edges, edge->pos / 64.0,
+ ( edge2->pos - cur_len ) / 64.0 ));
+
edge->pos = edge2->pos - cur_len;
+ }
else if ( cur_len < 96 )
{
@@ -1870,8 +2528,11 @@
cur_pos1 = FT_PIX_ROUND( org_center );
- if (cur_len <= 64 )
- u_off = d_off = 32;
+ if ( cur_len <= 64 )
+ {
+ u_off = 32;
+ d_off = 32;
+ }
else
{
u_off = 38;
@@ -1894,12 +2555,13 @@
edge->pos = cur_pos1 - cur_len / 2;
edge2->pos = cur_pos1 + cur_len / 2;
- AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) "
- "snapped to (%.2f) and (%.2f)\n",
- edge-edges, edge->opos / 64.0,
- edge2-edges, edge2->opos / 64.0,
- edge->pos / 64.0, edge2->pos / 64.0 ));
+ FT_TRACE5(( " STEM: edge %d (opos=%.2f) linked to %d (opos=%.2f)"
+ " snapped to %.2f and %.2f\n",
+ edge - edges, edge->opos / 64.0,
+ edge2 - edges, edge2->opos / 64.0,
+ edge->pos / 64.0, edge2->pos / 64.0 ));
}
+
else
{
org_pos = anchor->pos + ( edge->opos - anchor->opos );
@@ -1911,33 +2573,42 @@
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
- cur_pos1 = FT_PIX_ROUND( org_pos );
- delta1 = cur_pos1 + ( cur_len >> 1 ) - org_center;
+ cur_pos1 = FT_PIX_ROUND( org_pos );
+ delta1 = cur_pos1 + ( cur_len >> 1 ) - org_center;
if ( delta1 < 0 )
delta1 = -delta1;
- cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len;
- delta2 = cur_pos2 + ( cur_len >> 1 ) - org_center;
+ cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len;
+ delta2 = cur_pos2 + ( cur_len >> 1 ) - org_center;
if ( delta2 < 0 )
delta2 = -delta2;
edge->pos = ( delta1 < delta2 ) ? cur_pos1 : cur_pos2;
edge2->pos = edge->pos + cur_len;
- AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) "
- "snapped to (%.2f) and (%.2f)\n",
- edge-edges, edge->opos / 64.0,
- edge2-edges, edge2->opos / 64.0,
- edge->pos / 64.0, edge2->pos / 64.0 ));
+ FT_TRACE5(( " STEM: edge %d (opos=%.2f) linked to %d (opos=%.2f)"
+ " snapped to %.2f and %.2f\n",
+ edge - edges, edge->opos / 64.0,
+ edge2 - edges, edge2->opos / 64.0,
+ edge->pos / 64.0, edge2->pos / 64.0 ));
}
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions++;
+#endif
+
edge->flags |= AF_EDGE_DONE;
edge2->flags |= AF_EDGE_DONE;
if ( edge > edges && edge->pos < edge[-1].pos )
{
- AF_LOG(( "BOUND: %d (pos=%.2f) to (%.2f)\n",
- edge-edges, edge->pos / 64.0, edge[-1].pos / 64.0 ));
+#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 ));
+
+ num_actions++;
+#endif
+
edge->pos = edge[-1].pos;
}
}
@@ -2031,18 +2702,19 @@
if ( delta < 64 + 16 )
{
af_latin_align_serif_edge( hints, edge->serif, edge );
- AF_LOG(( "SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f) "
- "aligned to (%.2f)\n",
- edge-edges, edge->opos / 64.0,
- edge->serif - edges, edge->serif->opos / 64.0,
- edge->pos / 64.0 ));
+ FT_TRACE5(( " SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f)"
+ " aligned to %.2f\n",
+ edge - edges, edge->opos / 64.0,
+ edge->serif - edges, edge->serif->opos / 64.0,
+ edge->pos / 64.0 ));
}
else if ( !anchor )
{
- AF_LOG(( "SERIF_ANCHOR: edge %d (opos=%.2f) snapped to (%.2f)\n",
- edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
edge->pos = FT_PIX_ROUND( edge->opos );
anchor = edge;
+ FT_TRACE5(( " SERIF_ANCHOR: edge %d (opos=%.2f)"
+ " snapped to %.2f\n",
+ edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
}
else
{
@@ -2067,35 +2739,65 @@
FT_MulDiv( edge->opos - before->opos,
after->pos - before->pos,
after->opos - before->opos );
- AF_LOG(( "SERIF_LINK1: edge %d (opos=%.2f) snapped to (%.2f) "
- "from %d (opos=%.2f)\n",
- edge-edges, edge->opos / 64.0,
- edge->pos / 64.0, before - edges,
- before->opos / 64.0 ));
+
+ FT_TRACE5(( " SERIF_LINK1: edge %d (opos=%.2f) snapped to %.2f"
+ " from %d (opos=%.2f)\n",
+ edge - edges, edge->opos / 64.0,
+ edge->pos / 64.0,
+ before - edges, before->opos / 64.0 ));
}
else
{
edge->pos = anchor->pos +
( ( edge->opos - anchor->opos + 16 ) & ~31 );
- AF_LOG(( "SERIF_LINK2: edge %d (opos=%.2f) snapped to (%.2f)\n",
- edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
+ FT_TRACE5(( " SERIF_LINK2: edge %d (opos=%.2f)"
+ " snapped to %.2f\n",
+ edge - edges, edge->opos / 64.0, edge->pos / 64.0 ));
}
}
+#ifdef FT_DEBUG_LEVEL_TRACE
+ num_actions++;
+#endif
edge->flags |= AF_EDGE_DONE;
if ( edge > edges && edge->pos < edge[-1].pos )
+ {
+#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 ));
+
+ num_actions++;
+#endif
edge->pos = edge[-1].pos;
+ }
if ( edge + 1 < edge_limit &&
edge[1].flags & AF_EDGE_DONE &&
edge->pos > edge[1].pos )
+ {
+#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 ));
+
+ num_actions++;
+#endif
+
edge->pos = edge[1].pos;
+ }
}
}
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !num_actions )
+ FT_TRACE5(( " (none)\n" ));
+ FT_TRACE5(( "\n" ));
+#endif
}
+ /* Apply the complete hinting algorithm to a latin glyph. */
+
static FT_Error
af_latin_hints_apply( AF_GlyphHints hints,
FT_Outline* outline,
@@ -2104,27 +2806,37 @@
FT_Error error;
int dim;
+ AF_LatinAxis axis;
- error = af_glyph_hints_reload( hints, outline, 1 );
+
+ error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;
/* analyze glyph outline */
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
if ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ||
- AF_HINTS_DO_HORIZONTAL( hints ) )
+ AF_HINTS_DO_HORIZONTAL( hints ) )
#else
if ( AF_HINTS_DO_HORIZONTAL( hints ) )
#endif
{
- error = af_latin_hints_detect_features( hints, AF_DIMENSION_HORZ );
+ axis = &metrics->axis[AF_DIMENSION_HORZ];
+ error = af_latin_hints_detect_features( hints,
+ axis->width_count,
+ axis->widths,
+ AF_DIMENSION_HORZ );
if ( error )
goto Exit;
}
if ( AF_HINTS_DO_VERTICAL( hints ) )
{
- error = af_latin_hints_detect_features( hints, AF_DIMENSION_VERT );
+ axis = &metrics->axis[AF_DIMENSION_VERT];
+ error = af_latin_hints_detect_features( hints,
+ axis->width_count,
+ axis->widths,
+ AF_DIMENSION_VERT );
if ( error )
goto Exit;
@@ -2134,17 +2846,19 @@
/* grid-fit the outline */
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
-#ifdef AF_USE_WARPER
- if ( ( dim == AF_DIMENSION_HORZ &&
- metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ) )
+#ifdef AF_CONFIG_OPTION_USE_WARPER
+ if ( dim == AF_DIMENSION_HORZ &&
+ metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT )
{
AF_WarperRec warper;
FT_Fixed scale;
FT_Pos delta;
- af_warper_compute( &warper, hints, dim, &scale, &delta );
- af_glyph_hints_scale_dim( hints, dim, scale, delta );
+ af_warper_compute( &warper, hints, (AF_Dimension)dim,
+ &scale, &delta );
+ af_glyph_hints_scale_dim( hints, (AF_Dimension)dim,
+ scale, delta );
continue;
}
#endif
@@ -2158,6 +2872,7 @@
af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
}
}
+
af_glyph_hints_save( hints, outline );
Exit:
@@ -2174,53 +2889,19 @@
/*************************************************************************/
- /* XXX: this should probably fine tuned to differentiate better between */
- /* scripts... */
+ AF_DEFINE_WRITING_SYSTEM_CLASS(
+ af_latin_writing_system_class,
- static const AF_Script_UniRangeRec af_latin_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0020UL, 0x007FUL ), /* Basic Latin (no control chars) */
- AF_UNIRANGE_REC( 0x00A0UL, 0x00FFUL ), /* Latin-1 Supplement (no control chars) */
- AF_UNIRANGE_REC( 0x0100UL, 0x017FUL ), /* Latin Extended-A */
- AF_UNIRANGE_REC( 0x0180UL, 0x024FUL ), /* Latin Extended-B */
- AF_UNIRANGE_REC( 0x0250UL, 0x02AFUL ), /* IPA Extensions */
- AF_UNIRANGE_REC( 0x02B0UL, 0x02FFUL ), /* Spacing Modifier Letters */
- AF_UNIRANGE_REC( 0x0300UL, 0x036FUL ), /* Combining Diacritical Marks */
- AF_UNIRANGE_REC( 0x0370UL, 0x03FFUL ), /* Greek and Coptic */
- AF_UNIRANGE_REC( 0x0400UL, 0x04FFUL ), /* Cyrillic */
- AF_UNIRANGE_REC( 0x0500UL, 0x052FUL ), /* Cyrillic Supplement */
- AF_UNIRANGE_REC( 0x1D00UL, 0x1D7FUL ), /* Phonetic Extensions */
- AF_UNIRANGE_REC( 0x1D80UL, 0x1DBFUL ), /* Phonetic Extensions Supplement */
- AF_UNIRANGE_REC( 0x1DC0UL, 0x1DFFUL ), /* Combining Diacritical Marks Supplement */
- AF_UNIRANGE_REC( 0x1E00UL, 0x1EFFUL ), /* Latin Extended Additional */
- AF_UNIRANGE_REC( 0x1F00UL, 0x1FFFUL ), /* Greek Extended */
- AF_UNIRANGE_REC( 0x2000UL, 0x206FUL ), /* General Punctuation */
- AF_UNIRANGE_REC( 0x2070UL, 0x209FUL ), /* Superscripts and Subscripts */
- AF_UNIRANGE_REC( 0x20A0UL, 0x20CFUL ), /* Currency Symbols */
- AF_UNIRANGE_REC( 0x2150UL, 0x218FUL ), /* Number Forms */
- AF_UNIRANGE_REC( 0x2460UL, 0x24FFUL ), /* Enclosed Alphanumerics */
- AF_UNIRANGE_REC( 0x2C60UL, 0x2C7FUL ), /* Latin Extended-C */
- AF_UNIRANGE_REC( 0x2DE0UL, 0x2DFFUL ), /* Cyrillic Extended-A */
- AF_UNIRANGE_REC( 0xA640UL, 0xA69FUL ), /* Cyrillic Extended-B */
- AF_UNIRANGE_REC( 0xA720UL, 0xA7FFUL ), /* Latin Extended-D */
- AF_UNIRANGE_REC( 0xFB00UL, 0xFB06UL ), /* Alphab. Present. Forms (Latin Ligs) */
- AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ), /* Mathematical Alphanumeric Symbols */
- AF_UNIRANGE_REC( 0UL, 0UL )
- };
-
-
- AF_DEFINE_SCRIPT_CLASS(af_latin_script_class,
- AF_SCRIPT_LATIN,
- af_latin_uniranges,
-
- sizeof( AF_LatinMetricsRec ),
-
- (AF_Script_InitMetricsFunc) af_latin_metrics_init,
- (AF_Script_ScaleMetricsFunc)af_latin_metrics_scale,
- (AF_Script_DoneMetricsFunc) NULL,
-
- (AF_Script_InitHintsFunc) af_latin_hints_init,
- (AF_Script_ApplyHintsFunc) af_latin_hints_apply
+ AF_WRITING_SYSTEM_LATIN,
+
+ sizeof ( AF_LatinMetricsRec ),
+
+ (AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init,
+ (AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale,
+ (AF_WritingSystem_DoneMetricsFunc) NULL,
+
+ (AF_WritingSystem_InitHintsFunc) af_latin_hints_init,
+ (AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply
)
diff --git a/src/3rdparty/freetype/src/autofit/aflatin.h b/src/3rdparty/freetype/src/autofit/aflatin.h
index 660b10c83f..2c0bfca18b 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin.h
+++ b/src/3rdparty/freetype/src/autofit/aflatin.h
@@ -2,9 +2,10 @@
/* */
/* aflatin.h */
/* */
-/* Auto-fitter hinting routines for latin script (specification). */
+/* Auto-fitter hinting routines for latin writing system */
+/* (specification). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2003-2007, 2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,14 +25,13 @@
FT_BEGIN_HEADER
+ /* the `latin' writing system */
- /* the latin-specific script class */
+ AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin_writing_system_class )
- AF_DECLARE_SCRIPT_CLASS(af_latin_script_class)
-
-/* constants are given with units_per_em == 2048 in mind */
-#define AF_LATIN_CONSTANT( metrics, c ) \
+ /* constants are given with units_per_em == 2048 in mind */
+#define AF_LATIN_CONSTANT( metrics, c ) \
( ( (c) * (FT_Long)( (AF_LatinMetrics)(metrics) )->units_per_em ) / 2048 )
@@ -46,40 +46,30 @@ FT_BEGIN_HEADER
/*
* The following declarations could be embedded in the file `aflatin.c';
- * they have been made semi-public to allow alternate script hinters to
- * re-use some of them.
+ * they have been made semi-public to allow alternate writing system
+ * hinters to re-use some of them.
*/
- /* Latin (global) metrics management */
-
- enum
- {
- AF_LATIN_BLUE_CAPITAL_TOP,
- AF_LATIN_BLUE_CAPITAL_BOTTOM,
- AF_LATIN_BLUE_SMALL_F_TOP,
- AF_LATIN_BLUE_SMALL_TOP,
- AF_LATIN_BLUE_SMALL_BOTTOM,
- AF_LATIN_BLUE_SMALL_MINOR,
-
- AF_LATIN_BLUE_MAX
- };
-
-
-#define AF_LATIN_IS_TOP_BLUE( b ) ( (b) == AF_LATIN_BLUE_CAPITAL_TOP || \
- (b) == AF_LATIN_BLUE_SMALL_F_TOP || \
- (b) == AF_LATIN_BLUE_SMALL_TOP )
+#define AF_LATIN_IS_TOP_BLUE( b ) \
+ ( (b)->properties & AF_BLUE_PROPERTY_LATIN_TOP )
+#define AF_LATIN_IS_NEUTRAL_BLUE( b ) \
+ ( (b)->properties & AF_BLUE_PROPERTY_LATIN_NEUTRAL )
+#define AF_LATIN_IS_X_HEIGHT_BLUE( b ) \
+ ( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT )
+#define AF_LATIN_IS_LONG_BLUE( b ) \
+ ( (b)->properties & AF_BLUE_PROPERTY_LATIN_LONG )
#define AF_LATIN_MAX_WIDTHS 16
-#define AF_LATIN_MAX_BLUES AF_LATIN_BLUE_MAX
enum
{
- AF_LATIN_BLUE_ACTIVE = 1 << 0,
- AF_LATIN_BLUE_TOP = 1 << 1,
- AF_LATIN_BLUE_ADJUSTMENT = 1 << 2, /* used for scale adjustment */
- /* optimization */
+ AF_LATIN_BLUE_ACTIVE = 1 << 0, /* set if zone height is <= 3/4px */
+ AF_LATIN_BLUE_TOP = 1 << 1, /* set if we have a top blue zone */
+ AF_LATIN_BLUE_NEUTRAL = 1 << 2, /* set if we have neutral blue zone */
+ AF_LATIN_BLUE_ADJUSTMENT = 1 << 3, /* used for scale adjustment */
+ /* optimization */
AF_LATIN_BLUE_FLAG_MAX
};
@@ -98,16 +88,15 @@ FT_BEGIN_HEADER
FT_Fixed scale;
FT_Pos delta;
- FT_UInt width_count;
- AF_WidthRec widths[AF_LATIN_MAX_WIDTHS];
- FT_Pos edge_distance_threshold;
- FT_Pos standard_width;
- FT_Bool extra_light;
+ FT_UInt width_count; /* number of used widths */
+ AF_WidthRec widths[AF_LATIN_MAX_WIDTHS]; /* widths array */
+ FT_Pos edge_distance_threshold; /* used for creating edges */
+ FT_Pos standard_width; /* the default stem thickness */
+ FT_Bool extra_light; /* is standard width very light? */
/* ignored for horizontal metrics */
- FT_Bool control_overshoot;
FT_UInt blue_count;
- AF_LatinBlueRec blues[AF_LATIN_BLUE_MAX];
+ AF_LatinBlueRec blues[AF_BLUE_STRINGSET_MAX];
FT_Fixed org_scale;
FT_Pos org_delta;
@@ -117,9 +106,9 @@ FT_BEGIN_HEADER
typedef struct AF_LatinMetricsRec_
{
- AF_ScriptMetricsRec root;
- FT_UInt units_per_em;
- AF_LatinAxisRec axis[AF_DIMENSION_MAX];
+ AF_StyleMetricsRec root;
+ FT_UInt units_per_em;
+ AF_LatinAxisRec axis[AF_DIMENSION_MAX];
} AF_LatinMetricsRec, *AF_LatinMetrics;
@@ -134,8 +123,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
af_latin_metrics_init_widths( AF_LatinMetrics metrics,
- FT_Face face,
- FT_ULong charcode );
+ FT_Face face );
FT_LOCAL( void )
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
@@ -175,31 +163,27 @@ FT_BEGIN_HEADER
/*
- * This shouldn't normally be exported. However, other scripts might
- * like to use this function as-is.
+ * The next functions shouldn't normally be exported. However, other
+ * writing systems might like to use these functions as-is.
*/
FT_LOCAL( FT_Error )
af_latin_hints_compute_segments( AF_GlyphHints hints,
AF_Dimension dim );
- /*
- * This shouldn't normally be exported. However, other scripts might
- * want to use this function as-is.
- */
FT_LOCAL( void )
af_latin_hints_link_segments( AF_GlyphHints hints,
+ FT_UInt width_count,
+ AF_WidthRec* widths,
AF_Dimension dim );
- /*
- * This shouldn't normally be exported. However, other scripts might
- * want to use this function as-is.
- */
FT_LOCAL( FT_Error )
af_latin_hints_compute_edges( AF_GlyphHints hints,
AF_Dimension dim );
FT_LOCAL( FT_Error )
af_latin_hints_detect_features( AF_GlyphHints hints,
+ FT_UInt width_count,
+ AF_WidthRec* widths,
AF_Dimension dim );
/* */
diff --git a/src/3rdparty/freetype/src/autofit/aflatin2.c b/src/3rdparty/freetype/src/autofit/aflatin2.c
index 5cbeb296b5..07590b380c 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin2.c
+++ b/src/3rdparty/freetype/src/autofit/aflatin2.c
@@ -1,10 +1,10 @@
/***************************************************************************/
/* */
-/* aflatin.c */
+/* aflatin2.c */
/* */
-/* Auto-fitter hinting routines for latin script (body). */
+/* Auto-fitter hinting routines for latin writing system (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2003-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,18 +18,30 @@
#include FT_ADVANCES_H
+#include "afglobal.h"
#include "aflatin.h"
#include "aflatin2.h"
#include "aferrors.h"
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
#include "afwarp.h"
#endif
+
+ /*************************************************************************/
+ /* */
+ /* 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_aflatin2
+
+
FT_LOCAL_DEF( FT_Error )
af_latin2_hints_compute_segments( AF_GlyphHints hints,
- AF_Dimension dim );
+ AF_Dimension dim );
FT_LOCAL_DEF( void )
af_latin2_hints_link_segments( AF_GlyphHints hints,
@@ -45,8 +57,7 @@
FT_LOCAL_DEF( void )
af_latin2_metrics_init_widths( AF_LatinMetrics metrics,
- FT_Face face,
- FT_ULong charcode )
+ FT_Face face )
{
/* scan the array of segments in each direction */
AF_GlyphHintsRec hints[1];
@@ -65,7 +76,9 @@
AF_Scaler scaler = &dummy->root.scaler;
- glyph_index = FT_Get_Char_Index( face, charcode );
+ glyph_index = FT_Get_Char_Index(
+ face,
+ metrics->root.style_class->standard_char );
if ( glyph_index == 0 )
goto Exit;
@@ -82,9 +95,9 @@
scaler->render_mode = FT_RENDER_MODE_NORMAL;
scaler->flags = 0;
- af_glyph_hints_rescale( hints, (AF_ScriptMetrics)dummy );
+ af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
- error = af_glyph_hints_reload( hints, &face->glyph->outline, 0 );
+ error = af_glyph_hints_reload( hints, &face->glyph->outline );
if ( error )
goto Exit;
@@ -122,7 +135,7 @@
dist = -dist;
if ( num_widths < AF_LATIN_MAX_WIDTHS )
- axis->widths[ num_widths++ ].org = dist;
+ axis->widths[num_widths++].org = dist;
}
}
@@ -156,7 +169,8 @@
#define AF_LATIN_MAX_TEST_CHARACTERS 12
- static const char af_latin2_blue_chars[AF_LATIN_MAX_BLUES][AF_LATIN_MAX_TEST_CHARACTERS+1] =
+ static const char af_latin2_blue_chars[AF_LATIN_MAX_BLUES]
+ [AF_LATIN_MAX_TEST_CHARACTERS+1] =
{
"THEZOCQS",
"HEZLOCUS",
@@ -169,7 +183,7 @@
static void
af_latin2_metrics_init_blues( AF_LatinMetrics metrics,
- FT_Face face )
+ FT_Face face )
{
FT_Pos flats [AF_LATIN_MAX_TEST_CHARACTERS];
FT_Pos rounds[AF_LATIN_MAX_TEST_CHARACTERS];
@@ -182,12 +196,12 @@
FT_GlyphSlot glyph = face->glyph;
- /* we compute the blues simply by loading each character from the */
+ /* we compute the blues simply by loading each character from the */
/* 'af_latin2_blue_chars[blues]' string, then compute its top-most or */
- /* bottom-most points (depending on `AF_IS_TOP_BLUE') */
+ /* bottom-most points (depending on `AF_IS_TOP_BLUE') */
- AF_LOG(( "blue zones computation\n" ));
- AF_LOG(( "------------------------------------------------\n" ));
+ FT_TRACE5(( "blue zones computation\n"
+ "======================\n\n" ));
for ( bb = 0; bb < AF_LATIN_BLUE_MAX; bb++ )
{
@@ -197,7 +211,7 @@
FT_Pos* blue_shoot;
- AF_LOG(( "blue %3d: ", bb ));
+ FT_TRACE5(( "blue zone %d:\n", bb ));
num_flats = 0;
num_rounds = 0;
@@ -210,8 +224,6 @@
FT_Bool round;
- AF_LOG(( "'%c'", *p ));
-
/* load the character in the face -- skip unknown or empty ones */
glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p );
if ( glyph_index == 0 )
@@ -273,13 +285,14 @@
best_last = last;
}
}
- AF_LOG(( "%5d", best_y ));
+ FT_TRACE5(( " %c %d", *p, best_y ));
}
/* 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 */
{
+ FT_Pos best_x = points[best_point].x;
FT_Int start, end, prev, next;
FT_Pos dist;
@@ -290,13 +303,16 @@
do
{
- prev = start-1;
+ prev = start - 1;
if ( prev < best_first )
prev = best_last;
- dist = points[prev].y - best_y;
- if ( dist < -5 || dist > 5 )
- break;
+ 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;
start = prev;
@@ -304,13 +320,14 @@
do
{
- next = end+1;
+ next = end + 1;
if ( next > best_last )
next = best_first;
- dist = points[next].y - best_y;
- if ( dist < -5 || dist > 5 )
- break;
+ dist = FT_ABS( points[next].y - best_y );
+ if ( dist > 5 )
+ if ( FT_ABS( points[next].x - best_x ) <= 20 * dist )
+ break;
end = next;
@@ -321,7 +338,7 @@
FT_CURVE_TAG( glyph->outline.tags[start] ) != FT_CURVE_TAG_ON ||
FT_CURVE_TAG( glyph->outline.tags[ end ] ) != FT_CURVE_TAG_ON );
- AF_LOG(( "%c ", round ? 'r' : 'f' ));
+ FT_TRACE5(( " (%s)\n", round ? "round" : "flat" ));
}
if ( round )
@@ -330,15 +347,13 @@
flats[num_flats++] = best_y;
}
- AF_LOG(( "\n" ));
-
if ( num_flats == 0 && num_rounds == 0 )
{
/*
* we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then
*/
- AF_LOG(( "empty\n" ));
+ FT_TRACE5(( " empty\n" ));
continue;
}
@@ -381,7 +396,13 @@
if ( AF_LATIN_IS_TOP_BLUE( bb ) ^ over_ref )
- *blue_shoot = *blue_ref = ( shoot + ref ) / 2;
+ {
+ *blue_ref =
+ *blue_shoot = ( shoot + ref ) / 2;
+
+ FT_TRACE5(( " [overshoot smaller than reference,"
+ " taking mean value]\n" ));
+ }
}
blue->flags = 0;
@@ -389,14 +410,16 @@
blue->flags |= AF_LATIN_BLUE_TOP;
/*
- * The following flags is used later to adjust the y and x scales
+ * The following flag is used later to adjust the y and x scales
* in order to optimize the pixel grid alignment of the top of small
* letters.
*/
- if ( bb == AF_LATIN_BLUE_SMALL_TOP )
+ if ( AF_LATIN_IS_X_HEIGHT_BLUE( bb ) )
blue->flags |= AF_LATIN_BLUE_ADJUSTMENT;
- AF_LOG(( "-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot ));
+ FT_TRACE5(( " -> reference = %ld\n"
+ " overshoot = %ld\n",
+ *blue_ref, *blue_shoot ));
}
return;
@@ -451,9 +474,9 @@
FT_LOCAL_DEF( FT_Error )
af_latin2_metrics_init( AF_LatinMetrics metrics,
- FT_Face face )
+ FT_Face face )
{
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_CharMap oldmap = face->charmap;
FT_UInt ee;
@@ -479,21 +502,20 @@
if ( !error )
{
- /* For now, compute the standard width and height from the `o'. */
- af_latin2_metrics_init_widths( metrics, face, 'o' );
+ af_latin2_metrics_init_widths( metrics, face );
af_latin2_metrics_init_blues( metrics, face );
af_latin2_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
- return AF_Err_Ok;
+ return FT_Err_Ok;
}
static void
af_latin2_metrics_scale_dim( AF_LatinMetrics metrics,
- AF_Scaler scaler,
- AF_Dimension dim )
+ AF_Scaler scaler,
+ AF_Dimension dim )
{
FT_Fixed scale;
FT_Pos delta;
@@ -541,13 +563,35 @@
if ( blue )
{
- FT_Pos scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
- FT_Pos fitted = ( scaled + 40 ) & ~63;
+ FT_Pos scaled;
+ FT_Pos threshold;
+ FT_Pos fitted;
+ FT_UInt limit;
+ FT_UInt ppem;
+
+
+ scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
+ ppem = metrics->root.scaler.face->size->metrics.x_ppem;
+ limit = metrics->root.globals->increase_x_height;
+ threshold = 40;
+
+ /* if the `increase-x-height' property is active, */
+ /* we round up much more often */
+ if ( limit &&
+ ppem <= limit &&
+ ppem >= AF_PROP_INCREASE_X_HEIGHT_MIN )
+ threshold = 52;
+
+ fitted = ( scaled + threshold ) & ~63;
#if 1
- if ( scaled != fitted ) {
+ if ( scaled != fitted )
+ {
scale = FT_MulDiv( scale, fitted, scaled );
- AF_LOG(( "== scaled x-top = %.2g fitted = %.2g, scaling = %.4g\n", scaled/64.0, fitted/64.0, (fitted*1.0)/scaled ));
+ FT_TRACE5(( "== scaled x-top = %.2g"
+ " fitted = %.2g, scaling = %.4g\n",
+ scaled / 64.0, fitted / 64.0,
+ ( fitted * 1.0 ) / scaled ));
}
#endif
}
@@ -578,7 +622,7 @@
}
/* an extra-light axis corresponds to a standard width that is */
- /* smaller than 0.75 pixels */
+ /* smaller than 5/8 pixels */
axis->extra_light =
(FT_Bool)( FT_MulFix( axis->standard_width, scale ) < 32 + 8 );
@@ -623,9 +667,11 @@
blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
blue->shoot.fit = blue->ref.fit + delta2;
- AF_LOG(( ">> activating blue zone %d: ref.cur=%.2g ref.fit=%.2g shoot.cur=%.2g shoot.fit=%.2g\n",
- nn, blue->ref.cur/64.0, blue->ref.fit/64.0,
- blue->shoot.cur/64.0, blue->shoot.fit/64.0 ));
+ FT_TRACE5(( ">> activating blue zone %d:"
+ " ref.cur=%.2g ref.fit=%.2g"
+ " shoot.cur=%.2g shoot.fit=%.2g\n",
+ nn, blue->ref.cur / 64.0, blue->ref.fit / 64.0,
+ blue->shoot.cur / 64.0, blue->shoot.fit / 64.0 ));
blue->flags |= AF_LATIN_BLUE_ACTIVE;
}
@@ -636,10 +682,11 @@
FT_LOCAL_DEF( void )
af_latin2_metrics_scale( AF_LatinMetrics metrics,
- AF_Scaler scaler )
+ AF_Scaler scaler )
{
metrics->root.scaler.render_mode = scaler->render_mode;
metrics->root.scaler.face = scaler->face;
+ metrics->root.scaler.flags = scaler->flags;
af_latin2_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
af_latin2_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
@@ -658,11 +705,11 @@
FT_LOCAL_DEF( FT_Error )
af_latin2_hints_compute_segments( AF_GlyphHints hints,
- AF_Dimension dim )
+ AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
FT_Memory memory = hints->memory;
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
AF_Segment segment = NULL;
AF_SegmentRec seg0;
AF_Point* contour = hints->contours;
@@ -778,18 +825,17 @@
segment->dir = first->out_dir;
segment->first = first;
segment->last = point;
- segment->contour = contour;
- segment->pos = (FT_Short)(( min_u + max_u ) >> 1);
+ segment->pos = (FT_Short)( ( min_u + max_u ) >> 1 );
segment->min_coord = (FT_Short) min_v;
segment->max_coord = (FT_Short) max_v;
- segment->height = (FT_Short)(max_v - min_v);
+ segment->height = (FT_Short)( max_v - min_v );
/* a segment is round if it doesn't have successive */
/* on-curve points. */
{
AF_Point pt = first;
AF_Point last = point;
- AF_Flags f0 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL);
+ AF_Flags f0 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
AF_Flags f1;
@@ -798,7 +844,7 @@
for ( ; pt != last; f0 = f1 )
{
pt = pt->next;
- f1 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL);
+ f1 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
if ( !f0 && !f1 )
break;
@@ -815,7 +861,7 @@
break;
/* jump to the start of the next segment, if any */
- while ( FT_ABS(point->out_dir) != major_dir )
+ while ( FT_ABS( point->out_dir ) != major_dir )
{
point = point->next;
@@ -844,9 +890,6 @@
FT_Pos last_v = last->v;
- if ( first == last )
- continue;
-
if ( first_v < last_v )
{
p = first->prev;
@@ -883,16 +926,17 @@
FT_UInt count = axis->num_segments;
FT_UInt ii, jj;
- for (ii = 0; ii < count; ii++)
+ for ( ii = 0; ii < count; ii++ )
{
if ( segments[ii].dir > 0 )
{
- for (jj = ii+1; jj < count; jj++)
+ for ( jj = ii + 1; jj < count; jj++ )
{
if ( segments[jj].dir < 0 )
{
AF_SegmentRec tmp;
+
tmp = segments[ii];
segments[ii] = segments[jj];
segments[jj] = tmp;
@@ -916,7 +960,7 @@
FT_LOCAL_DEF( void )
af_latin2_hints_link_segments( AF_GlyphHints hints,
- AF_Dimension dim )
+ AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
@@ -937,7 +981,7 @@
#ifdef AF_SORT_SEGMENTS
for ( seg1 = segments; seg1 < segment_mid; seg1++ )
{
- if ( seg1->dir != axis->major_dir || seg1->first == seg1->last )
+ if ( seg1->dir != axis->major_dir )
continue;
for ( seg2 = segment_mid; seg2 < segment_limit; seg2++ )
@@ -945,9 +989,7 @@
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
- /* the fake segments are introduced to hint the metrics -- */
- /* we must never link them to anything */
- if ( seg1->dir != axis->major_dir || seg1->first == seg1->last )
+ if ( seg1->dir != axis->major_dir )
continue;
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
@@ -1016,10 +1058,10 @@
FT_LOCAL_DEF( FT_Error )
af_latin2_hints_compute_edges( AF_GlyphHints hints,
- AF_Dimension dim )
+ AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = hints->memory;
AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim];
@@ -1053,7 +1095,7 @@
if ( dim == AF_DIMENSION_HORZ )
{
if ( laxis->width_count > 0 )
- segment_length_threshold = (laxis->standard_width * 10 ) >> 4;
+ segment_length_threshold = ( laxis->standard_width * 10 ) >> 4;
else
segment_length_threshold = FT_DivFix( 64, hints->y_scale );
}
@@ -1099,10 +1141,11 @@
{
FT_Pos dist = seg->serif->pos - seg->pos;
- if (dist < 0)
+
+ if ( dist < 0 )
dist = -dist;
- if (dist >= laxis->standard_width >> 1)
+ if ( dist >= laxis->standard_width >> 1 )
{
/* unlink this serif, it is too distant from its reference stem */
seg->serif = NULL;
@@ -1136,7 +1179,8 @@
/* insert a new edge in the list and */
/* sort according to the position */
- error = af_axis_hints_new_edge( axis, seg->pos, seg->dir, memory, &edge );
+ error = af_axis_hints_new_edge( axis, seg->pos, seg->dir,
+ memory, &edge );
if ( error )
goto Exit;
@@ -1145,9 +1189,10 @@
edge->first = seg;
edge->last = seg;
- edge->fpos = seg->pos;
edge->dir = seg->dir;
- edge->opos = edge->pos = FT_MulFix( seg->pos, scale );
+ edge->fpos = seg->pos;
+ edge->opos = FT_MulFix( seg->pos, scale );
+ edge->pos = edge->opos;
seg->edge_next = seg;
}
else
@@ -1204,8 +1249,10 @@
{
FT_Int is_round = 0; /* does it contain round segments? */
FT_Int is_straight = 0; /* does it contain straight segments? */
+#if 0
FT_Pos ups = 0; /* number of upwards segments */
FT_Pos downs = 0; /* number of downwards segments */
+#endif
seg = edge->first;
@@ -1221,11 +1268,13 @@
else
is_straight++;
+#if 0
/* check for segment direction */
if ( seg->dir == up_dir )
ups += seg->max_coord-seg->min_coord;
else
downs += seg->max_coord-seg->min_coord;
+#endif
/* check for links -- if seg->serif is set, then seg->link must */
/* be ignored */
@@ -1317,7 +1366,7 @@
FT_LOCAL_DEF( FT_Error )
af_latin2_hints_detect_features( AF_GlyphHints hints,
- AF_Dimension dim )
+ AF_Dimension dim )
{
FT_Error error;
@@ -1335,12 +1384,12 @@
FT_LOCAL_DEF( void )
af_latin2_hints_compute_blue_edges( AF_GlyphHints hints,
- AF_LatinMetrics metrics )
+ AF_LatinMetrics metrics )
{
- AF_AxisHints axis = &hints->axis[ AF_DIMENSION_VERT ];
+ AF_AxisHints axis = &hints->axis[AF_DIMENSION_VERT];
AF_Edge edge = axis->edges;
AF_Edge edge_limit = edge + axis->num_edges;
- AF_LatinAxis latin = &metrics->axis[ AF_DIMENSION_VERT ];
+ AF_LatinAxis latin = &metrics->axis[AF_DIMENSION_VERT];
FT_Fixed scale = latin->scale;
FT_Pos best_dist0; /* initial threshold */
@@ -1395,7 +1444,7 @@
compare = &blue->ref;
dist = edge->fpos - compare->org;
- if (dist < 0)
+ if ( dist < 0 )
dist = -dist;
dist = FT_MulFix( dist, scale );
@@ -1441,14 +1490,14 @@
static FT_Error
af_latin2_hints_init( AF_GlyphHints hints,
- AF_LatinMetrics metrics )
+ AF_LatinMetrics metrics )
{
FT_Render_Mode mode;
FT_UInt32 scaler_flags, other_flags;
FT_Face face = metrics->root.scaler.face;
- af_glyph_hints_rescale( hints, (AF_ScriptMetrics)metrics );
+ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
/*
* correct x_scale and y_scale if needed, since they may have
@@ -1462,7 +1511,7 @@
/* compute flags depending on render mode, etc. */
mode = metrics->root.scaler.render_mode;
-#if 0 /* #ifdef AF_USE_WARPER */
+#if 0 /* #ifdef AF_CONFIG_OPTION_USE_WARPER */
if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
{
metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
@@ -1499,8 +1548,8 @@
* In `light' hinting 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 ||
+ ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
hints->scaler_flags = scaler_flags;
@@ -1523,8 +1572,8 @@
static FT_Pos
af_latin2_snap_width( AF_Width widths,
- FT_Int count,
- FT_Pos width )
+ FT_Int count,
+ FT_Pos width )
{
int n;
FT_Pos best = 64 + 32 + 2;
@@ -1570,10 +1619,10 @@
static FT_Pos
af_latin2_compute_stem_width( AF_GlyphHints hints,
- AF_Dimension dim,
- FT_Pos width,
- AF_Edge_Flags base_flags,
- AF_Edge_Flags stem_flags )
+ AF_Dimension dim,
+ FT_Pos width,
+ AF_Edge_Flags base_flags,
+ AF_Edge_Flags stem_flags )
{
AF_LatinMetrics metrics = (AF_LatinMetrics) hints->metrics;
AF_LatinAxis axis = & metrics->axis[dim];
@@ -1581,8 +1630,8 @@
FT_Int sign = 0;
FT_Int vertical = ( dim == AF_DIMENSION_VERT );
+ FT_UNUSED( base_flags );
- FT_UNUSED(base_flags);
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ||
axis->extra_light )
@@ -1712,7 +1761,7 @@
if ( delta < 0 )
delta = -delta;
- if (delta >= 16)
+ if ( delta >= 16 )
{
dist = org_dist;
if ( dist < 48 )
@@ -1738,9 +1787,9 @@
static void
af_latin2_align_linked_edge( AF_GlyphHints hints,
- AF_Dimension dim,
- AF_Edge base_edge,
- AF_Edge stem_edge )
+ AF_Dimension dim,
+ AF_Edge base_edge,
+ AF_Edge stem_edge )
{
FT_Pos dist = stem_edge->opos - base_edge->opos;
@@ -1752,21 +1801,21 @@
stem_edge->pos = base_edge->pos + fitted_width;
- AF_LOG(( "LINK: edge %d (opos=%.2f) linked to (%.2f), "
- "dist was %.2f, now %.2f\n",
- stem_edge-hints->axis[dim].edges, stem_edge->opos / 64.0,
- stem_edge->pos / 64.0, dist / 64.0, fitted_width / 64.0 ));
+ FT_TRACE5(( "LINK: edge %d (opos=%.2f) linked to (%.2f), "
+ "dist was %.2f, now %.2f\n",
+ stem_edge-hints->axis[dim].edges, stem_edge->opos / 64.0,
+ stem_edge->pos / 64.0, dist / 64.0, fitted_width / 64.0 ));
}
static void
af_latin2_align_serif_edge( AF_GlyphHints hints,
- AF_Edge base,
- AF_Edge serif )
+ AF_Edge base,
+ AF_Edge serif )
{
FT_UNUSED( hints );
- serif->pos = base->pos + (serif->opos - base->opos);
+ serif->pos = base->pos + ( serif->opos - base->opos );
}
@@ -1783,7 +1832,7 @@
FT_LOCAL_DEF( void )
af_latin2_hint_edges( AF_GlyphHints hints,
- AF_Dimension dim )
+ AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
@@ -1795,7 +1844,8 @@
- AF_LOG(( "==== hinting %s edges =====\n", dim == AF_DIMENSION_HORZ ? "vertical" : "horizontal" ));
+ FT_TRACE5(( "==== hinting %s edges =====\n",
+ dim == AF_DIMENSION_HORZ ? "vertical" : "horizontal" ));
/* we begin by aligning all stems relative to the blue zone */
/* if needed -- that's only for horizontal edges */
@@ -1829,10 +1879,10 @@
if ( !edge1 )
continue;
- AF_LOG(( "BLUE: edge %d (opos=%.2f) snapped to (%.2f), "
- "was (%.2f)\n",
- edge1-edges, edge1->opos / 64.0, blue->fit / 64.0,
- edge1->pos / 64.0 ));
+ FT_TRACE5(( "BLUE: edge %d (opos=%.2f) snapped to (%.2f), "
+ "was (%.2f)\n",
+ edge1-edges, edge1->opos / 64.0, blue->fit / 64.0,
+ edge1->pos / 64.0 ));
edge1->pos = blue->fit;
edge1->flags |= AF_EDGE_DONE;
@@ -1847,9 +1897,10 @@
{
anchor = edge;
- anchor_drift = (anchor->pos - anchor->opos);
- if (edge2)
- anchor_drift = (anchor_drift + (edge2->pos - edge2->opos)) >> 1;
+ anchor_drift = ( anchor->pos - anchor->opos );
+ if ( edge2 )
+ anchor_drift = ( anchor_drift +
+ ( edge2->pos - edge2->opos ) ) >> 1;
}
}
}
@@ -1877,7 +1928,7 @@
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge )
{
- AF_LOG(( "ASSERTION FAILED for edge %d\n", edge2-edges ));
+ FT_TRACE5(( "ASSERTION FAILED for edge %d\n", edge2-edges ));
af_latin2_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
@@ -1928,11 +1979,11 @@
else
edge->pos = FT_PIX_ROUND( edge->opos );
- AF_LOG(( "ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f) "
- "snapped to (%.2f) (%.2f)\n",
- edge-edges, edge->opos / 64.0,
- edge2-edges, edge2->opos / 64.0,
- edge->pos / 64.0, edge2->pos / 64.0 ));
+ FT_TRACE5(( "ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f)"
+ " snapped to (%.2f) (%.2f)\n",
+ edge-edges, edge->opos / 64.0,
+ edge2-edges, edge2->opos / 64.0,
+ edge->pos / 64.0, edge2->pos / 64.0 ));
anchor = edge;
edge->flags |= AF_EDGE_DONE;
@@ -1941,10 +1992,10 @@
edge2->flags |= AF_EDGE_DONE;
- anchor_drift = ( (anchor->pos - anchor->opos) +
- (edge2->pos - edge2->opos)) >> 1;
+ anchor_drift = ( ( anchor->pos - anchor->opos ) +
+ ( edge2->pos - edge2->opos ) ) >> 1;
- AF_LOG(( "DRIFT: %.2f\n", anchor_drift/64.0 ));
+ FT_TRACE5(( "DRIFT: %.2f\n", anchor_drift/64.0 ));
}
else
{
@@ -1961,15 +2012,16 @@
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
- org_left = org_pos + ((org_len - cur_len) >> 1);
- org_right = org_pos + ((org_len + cur_len) >> 1);
+ org_left = org_pos + ( ( org_len - cur_len ) >> 1 );
+ org_right = org_pos + ( ( org_len + cur_len ) >> 1 );
- AF_LOG(( "ALIGN: left=%.2f right=%.2f ", org_left/64.0, org_right/64.0 ));
+ FT_TRACE5(( "ALIGN: left=%.2f right=%.2f ",
+ org_left / 64.0, org_right / 64.0 ));
cur_center = org_center;
if ( edge2->flags & AF_EDGE_DONE )
{
- AF_LOG(( "\n" ));
+ FT_TRACE5(( "\n" ));
edge->pos = edge2->pos - cur_len;
}
else
@@ -1984,18 +2036,18 @@
/* note: don't even try to fit tiny stems */
if ( cur_len < 32 )
{
- AF_LOG(( "tiny stem\n" ));
+ FT_TRACE5(( "tiny stem\n" ));
goto AlignStem;
}
/* if the span is within a single pixel, don't touch it */
- if ( FT_PIX_FLOOR(org_left) == FT_PIX_CEIL(org_right) )
+ if ( FT_PIX_FLOOR( org_left ) == FT_PIX_CEIL( org_right ) )
{
- AF_LOG(( "single pixel stem\n" ));
+ FT_TRACE5(( "single pixel stem\n" ));
goto AlignStem;
}
- if (cur_len <= 96)
+ if ( cur_len <= 96 )
{
/* we want to avoid the absolute worst case which is
* when the left and right edges of the span each represent
@@ -2003,43 +2055,43 @@
* to 25/75%, since this is much more pleasant to the eye with
* very acceptable distortion
*/
- FT_Pos frac_left = (org_left) & 63;
- FT_Pos frac_right = (org_right) & 63;
+ FT_Pos frac_left = org_left & 63;
+ FT_Pos frac_right = org_right & 63;
if ( frac_left >= 22 && frac_left <= 42 &&
frac_right >= 22 && frac_right <= 42 )
{
org = frac_left;
- fit = (org <= 32) ? 16 : 48;
- delta = FT_ABS(fit - org);
+ fit = ( org <= 32 ) ? 16 : 48;
+ delta = FT_ABS( fit - org );
displacements[count] = fit - org;
scores[count++] = delta;
- AF_LOG(( "dispA=%.2f (%d) ", (fit - org)/64.0, delta ));
+ FT_TRACE5(( "dispA=%.2f (%d) ", ( fit - org ) / 64.0, delta ));
org = frac_right;
- fit = (org <= 32) ? 16 : 48;
- delta = FT_ABS(fit - org);
+ fit = ( org <= 32 ) ? 16 : 48;
+ delta = FT_ABS( fit - org );
displacements[count] = fit - org;
scores[count++] = delta;
- AF_LOG(( "dispB=%.2f (%d) ", (fit - org)/64.0, delta ));
+ FT_TRACE5(( "dispB=%.2f (%d) ", ( fit - org ) / 64.0, delta ));
}
}
/* snapping the left edge to the grid */
org = org_left;
- fit = FT_PIX_ROUND(org);
- delta = FT_ABS(fit - org);
+ fit = FT_PIX_ROUND( org );
+ delta = FT_ABS( fit - org );
displacements[count] = fit - org;
scores[count++] = delta;
- AF_LOG(( "dispC=%.2f (%d) ", (fit - org)/64.0, delta ));
+ FT_TRACE5(( "dispC=%.2f (%d) ", ( fit - org ) / 64.0, delta ));
/* snapping the right edge to the grid */
org = org_right;
- fit = FT_PIX_ROUND(org);
- delta = FT_ABS(fit - org);
+ fit = FT_PIX_ROUND( org );
+ delta = FT_ABS( fit - org );
displacements[count] = fit - org;
scores[count++] = delta;
- AF_LOG(( "dispD=%.2f (%d) ", (fit - org)/64.0, delta ));
+ FT_TRACE5(( "dispD=%.2f (%d) ", ( fit - org ) / 64.0, delta ));
/* now find the best displacement */
{
@@ -2047,9 +2099,9 @@
FT_Pos best_disp = displacements[0];
FT_UInt nn;
- for (nn = 1; nn < count; nn++)
+ for ( nn = 1; nn < count; nn++ )
{
- if (scores[nn] < best_score)
+ if ( scores[nn] < best_score )
{
best_score = scores[nn];
best_disp = displacements[nn];
@@ -2058,27 +2110,28 @@
cur_center = org_center + best_disp;
}
- AF_LOG(( "\n" ));
+ FT_TRACE5(( "\n" ));
}
AlignStem:
- edge->pos = cur_center - (cur_len >> 1);
+ edge->pos = cur_center - ( cur_len >> 1 );
edge2->pos = edge->pos + cur_len;
- AF_LOG(( "STEM1: %d (opos=%.2f) to %d (opos=%.2f) "
- "snapped to (%.2f) and (%.2f), org_len = %.2f cur_len=%.2f\n",
- edge-edges, edge->opos / 64.0,
- edge2-edges, edge2->opos / 64.0,
- edge->pos / 64.0, edge2->pos / 64.0,
- org_len / 64.0, cur_len / 64.0 ));
+ FT_TRACE5(( "STEM1: %d (opos=%.2f) to %d (opos=%.2f)"
+ " snapped to (%.2f) and (%.2f),"
+ " org_len=%.2f cur_len=%.2f\n",
+ edge-edges, edge->opos / 64.0,
+ edge2-edges, edge2->opos / 64.0,
+ edge->pos / 64.0, edge2->pos / 64.0,
+ org_len / 64.0, cur_len / 64.0 ));
edge->flags |= AF_EDGE_DONE;
edge2->flags |= AF_EDGE_DONE;
if ( edge > edges && edge->pos < edge[-1].pos )
{
- AF_LOG(( "BOUND: %d (pos=%.2f) to (%.2f)\n",
- edge-edges, edge->pos / 64.0, edge[-1].pos / 64.0 ));
+ FT_TRACE5(( "BOUND: %d (pos=%.2f) to (%.2f)\n",
+ edge-edges, edge->pos / 64.0, edge[-1].pos / 64.0 ));
edge->pos = edge[-1].pos;
}
}
@@ -2178,16 +2231,17 @@
if ( delta < 64 + 16 )
{
af_latin2_align_serif_edge( hints, edge->serif, edge );
- AF_LOG(( "SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f) "
- "aligned to (%.2f)\n",
- edge-edges, edge->opos / 64.0,
- edge->serif - edges, edge->serif->opos / 64.0,
- edge->pos / 64.0 ));
+ FT_TRACE5(( "SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f)"
+ " aligned to (%.2f)\n",
+ edge-edges, edge->opos / 64.0,
+ edge->serif - edges, edge->serif->opos / 64.0,
+ edge->pos / 64.0 ));
}
else if ( !anchor )
{
- AF_LOG(( "SERIF_ANCHOR: edge %d (opos=%.2f) snapped to (%.2f)\n",
- edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
+ FT_TRACE5(( "SERIF_ANCHOR: edge %d (opos=%.2f)"
+ " snapped to (%.2f)\n",
+ edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
edge->pos = FT_PIX_ROUND( edge->opos );
anchor = edge;
}
@@ -2214,15 +2268,19 @@
FT_MulDiv( edge->opos - before->opos,
after->pos - before->pos,
after->opos - before->opos );
- AF_LOG(( "SERIF_LINK1: edge %d (opos=%.2f) snapped to (%.2f) from %d (opos=%.2f)\n",
- edge-edges, edge->opos / 64.0, edge->pos / 64.0, before - edges, before->opos / 64.0 ));
+ FT_TRACE5(( "SERIF_LINK1: edge %d (opos=%.2f) snapped to (%.2f)"
+ " from %d (opos=%.2f)\n",
+ edge-edges, edge->opos / 64.0, edge->pos / 64.0,
+ before - edges, before->opos / 64.0 ));
}
else
{
- edge->pos = anchor->pos + (( edge->opos - anchor->opos + 16) & ~31);
+ edge->pos = anchor->pos +
+ ( ( edge->opos - anchor->opos + 16 ) & ~31 );
- AF_LOG(( "SERIF_LINK2: edge %d (opos=%.2f) snapped to (%.2f)\n",
- edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
+ FT_TRACE5(( "SERIF_LINK2: edge %d (opos=%.2f)"
+ " snapped to (%.2f)\n",
+ edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
}
}
@@ -2242,19 +2300,19 @@
static FT_Error
af_latin2_hints_apply( AF_GlyphHints hints,
- FT_Outline* outline,
- AF_LatinMetrics metrics )
+ FT_Outline* outline,
+ AF_LatinMetrics metrics )
{
FT_Error error;
int dim;
- error = af_glyph_hints_reload( hints, outline, 1 );
+ error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;
/* analyze glyph outline */
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
if ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ||
AF_HINTS_DO_HORIZONTAL( hints ) )
#else
@@ -2278,7 +2336,7 @@
/* grid-fit the outline */
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
if ( ( dim == AF_DIMENSION_HORZ &&
metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ) )
{
@@ -2318,26 +2376,19 @@
/*************************************************************************/
- static const AF_Script_UniRangeRec af_latin2_uniranges[] =
- {
- AF_UNIRANGE_REC( 32UL, 127UL ), /* XXX: TODO: Add new Unicode ranges here! */
- AF_UNIRANGE_REC( 160UL, 255UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
- };
-
+ AF_DEFINE_WRITING_SYSTEM_CLASS(
+ af_latin2_writing_system_class,
- AF_DEFINE_SCRIPT_CLASS(af_latin2_script_class,
- AF_SCRIPT_LATIN2,
- af_latin2_uniranges,
+ AF_WRITING_SYSTEM_LATIN2,
- sizeof( AF_LatinMetricsRec ),
+ sizeof ( AF_LatinMetricsRec ),
- (AF_Script_InitMetricsFunc) af_latin2_metrics_init,
- (AF_Script_ScaleMetricsFunc)af_latin2_metrics_scale,
- (AF_Script_DoneMetricsFunc) NULL,
+ (AF_WritingSystem_InitMetricsFunc) af_latin2_metrics_init,
+ (AF_WritingSystem_ScaleMetricsFunc)af_latin2_metrics_scale,
+ (AF_WritingSystem_DoneMetricsFunc) NULL,
- (AF_Script_InitHintsFunc) af_latin2_hints_init,
- (AF_Script_ApplyHintsFunc) af_latin2_hints_apply
+ (AF_WritingSystem_InitHintsFunc) af_latin2_hints_init,
+ (AF_WritingSystem_ApplyHintsFunc) af_latin2_hints_apply
)
diff --git a/src/3rdparty/freetype/src/autofit/aflatin2.h b/src/3rdparty/freetype/src/autofit/aflatin2.h
index 925c6214db..b5d252a91b 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin2.h
+++ b/src/3rdparty/freetype/src/autofit/aflatin2.h
@@ -2,9 +2,10 @@
/* */
/* aflatin2.h */
/* */
-/* Auto-fitter hinting routines for latin script (specification). */
+/* Auto-fitter hinting routines for latin writing system */
+/* (specification). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 by */
+/* Copyright 2003-2007, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,9 +26,10 @@
FT_BEGIN_HEADER
- /* the latin-specific script class */
+ /* the `latin' writing system */
+
+ AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin2_writing_system_class )
- AF_DECLARE_SCRIPT_CLASS(af_latin2_script_class)
/* */
diff --git a/src/3rdparty/freetype/src/autofit/afloader.c b/src/3rdparty/freetype/src/autofit/afloader.c
index 6dd9f2a314..fb15c87f0e 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, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2003-2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,31 +16,41 @@
/***************************************************************************/
+#include "afglobal.h"
#include "afloader.h"
#include "afhints.h"
-#include "afglobal.h"
#include "aferrors.h"
+#include "afmodule.h"
+#include "afpic.h"
+ /* Initialize glyph loader. */
+
FT_LOCAL_DEF( FT_Error )
- af_loader_init( AF_Loader loader,
- FT_Memory memory )
+ af_loader_init( AF_Module module )
{
+ AF_Loader loader = module->loader;
+ FT_Memory memory = module->root.library->memory;
+
+
FT_ZERO( loader );
af_glyph_hints_init( &loader->hints, memory );
-#ifdef AF_DEBUG
+#ifdef FT_DEBUG_AUTOFIT
_af_debug_hints = &loader->hints;
#endif
return FT_GlyphLoader_New( memory, &loader->gloader );
}
+ /* Reset glyph loader and compute globals if necessary. */
+
FT_LOCAL_DEF( FT_Error )
- af_loader_reset( AF_Loader loader,
+ af_loader_reset( AF_Module module,
FT_Face face )
{
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
+ AF_Loader loader = module->loader;
loader->face = face;
@@ -50,7 +60,7 @@
if ( loader->globals == NULL )
{
- error = af_face_globals_new( face, &loader->globals );
+ error = af_face_globals_new( face, &loader->globals, module );
if ( !error )
{
face->autohint.data =
@@ -64,15 +74,20 @@
}
+ /* Finalize glyph loader. */
+
FT_LOCAL_DEF( void )
- af_loader_done( AF_Loader loader )
+ af_loader_done( AF_Module module )
{
+ AF_Loader loader = module->loader;
+
+
af_glyph_hints_done( &loader->hints );
loader->face = NULL;
loader->globals = NULL;
-#ifdef AF_DEBUG
+#ifdef FT_DEBUG_AUTOFIT
_af_debug_hints = NULL;
#endif
FT_GlyphLoader_Done( loader->gloader );
@@ -80,6 +95,10 @@
}
+ /* Load a single glyph component. This routine calls itself */
+ /* recursively, if necessary, and does the main work of */
+ /* `af_loader_load_glyph.' */
+
static FT_Error
af_loader_load_g( AF_Loader loader,
AF_Scaler scaler,
@@ -90,13 +109,15 @@
FT_Error error;
FT_Face face = loader->face;
FT_GlyphLoader gloader = loader->gloader;
- AF_ScriptMetrics metrics = loader->metrics;
+ AF_StyleMetrics metrics = loader->metrics;
AF_GlyphHints hints = &loader->hints;
FT_GlyphSlot slot = face->glyph;
FT_Slot_Internal internal = slot->internal;
+ FT_Int32 flags;
- error = FT_Load_Glyph( face, glyph_index, load_flags );
+ flags = load_flags | FT_LOAD_LINEAR_DESIGN;
+ error = FT_Load_Glyph( face, glyph_index, flags );
if ( error )
goto Exit;
@@ -110,14 +131,10 @@
loader->trans_delta = internal->glyph_delta;
inverse = loader->trans_matrix;
- FT_Matrix_Invert( &inverse );
- FT_Vector_Transform( &loader->trans_delta, &inverse );
+ if ( !FT_Matrix_Invert( &inverse ) )
+ FT_Vector_Transform( &loader->trans_delta, &inverse );
}
- /* set linear metrics */
- slot->linearHoriAdvance = slot->metrics.horiAdvance;
- slot->linearVertAdvance = slot->metrics.vertAdvance;
-
switch ( slot->format )
{
case FT_GLYPH_FORMAT_OUTLINE:
@@ -127,8 +144,8 @@
loader->trans_delta.x,
loader->trans_delta.y );
- /* copy the outline points in the loader's current */
- /* extra points which is used to keep original glyph coordinates */
+ /* copy the outline points in the loader's current */
+ /* extra points which are used to keep original glyph coordinates */
error = FT_GLYPHLOADER_CHECK_POINTS( gloader,
slot->outline.n_points + 4,
slot->outline.n_contours );
@@ -164,13 +181,23 @@
/* now load the slot image into the auto-outline and run the */
/* automatic hinting process */
- if ( metrics->clazz->script_hints_apply )
- metrics->clazz->script_hints_apply( hints,
- &gloader->current.outline,
- metrics );
+ {
+#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];
- /* we now need to hint the metrics according to the change in */
- /* width/positioning that occurred during the hinting process */
+
+ if ( writing_system_class->style_hints_apply )
+ writing_system_class->style_hints_apply( hints,
+ &gloader->current.outline,
+ 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 )
{
FT_Pos old_rsb, old_lsb, new_lsb;
@@ -265,7 +292,7 @@
gloader->current.num_subglyphs = num_subglyphs;
num_base_subgs = gloader->base.num_subglyphs;
- /* now, read each subglyph independently */
+ /* now read each subglyph independently */
for ( nn = 0; nn < num_subglyphs; nn++ )
{
FT_Vector pp1, pp2;
@@ -291,12 +318,7 @@
/* recompute subglyph pointer */
subglyph = gloader->base.subglyphs + num_base_subgs + nn;
- if ( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS )
- {
- pp1 = loader->pp1;
- pp2 = loader->pp2;
- }
- else
+ if ( !( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS ) )
{
loader->pp1 = pp1;
loader->pp2 = pp2;
@@ -305,7 +327,7 @@
num_points = gloader->base.outline.n_points;
num_new_points = num_points - num_base_points;
- /* now perform the transform required for this subglyph */
+ /* now perform the transformation required for this subglyph */
if ( subglyph->flags & ( FT_SUBGLYPH_FLAG_SCALE |
FT_SUBGLYPH_FLAG_XY_SCALE |
@@ -333,14 +355,14 @@
if ( start_point + k >= num_base_points ||
l >= (FT_UInt)num_new_points )
{
- error = AF_Err_Invalid_Composite;
+ error = FT_THROW( Invalid_Composite );
goto Exit;
}
l += num_base_points;
- /* for now, only use the current point coordinates; */
- /* we may consider another approach in the near future */
+ /* for now, only use the current point coordinates; */
+ /* we eventually may consider another approach */
p1 = gloader->base.outline.points + start_point + k;
p2 = gloader->base.outline.points + start_point + l;
@@ -371,7 +393,7 @@
default:
/* we don't support other formats (yet?) */
- error = AF_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
}
Hint_Metrics:
@@ -423,9 +445,10 @@
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
x_scale );
#else
- if ( FT_IS_FIXED_WIDTH( slot->face ) ||
- ( af_face_globals_is_digit( loader->globals, glyph_index ) &&
- metrics->digits_have_same_width ) )
+ 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 ) ) )
{
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
metrics->scaler.x_scale );
@@ -444,7 +467,7 @@
#endif
slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
- metrics->scaler.y_scale );
+ metrics->scaler.y_scale );
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
@@ -455,32 +478,37 @@
if ( error )
goto Exit;
- slot->outline = internal->loader->base.outline;
+ /* 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;
+
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
-#ifdef DEBUG_HINTER
- af_debug_hinter = hinter;
-#endif
-
Exit:
return error;
}
+ /* Load a glyph. */
+
FT_LOCAL_DEF( FT_Error )
- af_loader_load_glyph( AF_Loader loader,
+ af_loader_load_glyph( AF_Module module,
FT_Face face,
FT_UInt gindex,
- FT_UInt32 load_flags )
+ FT_Int32 load_flags )
{
FT_Error error;
- FT_Size size = face->size;
+ FT_Size size = face->size;
+ AF_Loader loader = module->loader;
AF_ScalerRec scaler;
if ( !size )
- return AF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Size_Handle );
FT_ZERO( &scaler );
@@ -493,37 +521,45 @@
scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
scaler.flags = 0; /* XXX: fix this */
- error = af_loader_reset( loader, face );
+ error = af_loader_reset( module, face );
if ( !error )
{
- AF_ScriptMetrics metrics;
- FT_UInt options = 0;
+ AF_StyleMetrics metrics;
+ FT_UInt options = AF_STYLE_NONE_DFLT;
#ifdef FT_OPTION_AUTOFIT2
- /* XXX: undocumented hook to activate the latin2 hinter */
+ /* XXX: undocumented hook to activate the latin2 writing system */
if ( load_flags & ( 1UL << 20 ) )
- options = 2;
+ options = AF_STYLE_LTN2_DFLT;
#endif
error = af_face_globals_get_metrics( loader->globals, gindex,
options, &metrics );
if ( !error )
{
+#ifdef FT_CONFIG_OPTION_PIC
+ AF_FaceGlobals globals = loader->globals;
+#endif
+ AF_StyleClass style_class = metrics->style_class;
+ AF_WritingSystemClass writing_system_class =
+ AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
+
+
loader->metrics = metrics;
- if ( metrics->clazz->script_metrics_scale )
- metrics->clazz->script_metrics_scale( metrics, &scaler );
+ if ( writing_system_class->style_metrics_scale )
+ writing_system_class->style_metrics_scale( metrics, &scaler );
else
metrics->scaler = scaler;
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;
- if ( metrics->clazz->script_hints_init )
+ if ( writing_system_class->style_hints_init )
{
- error = metrics->clazz->script_hints_init( &loader->hints,
- metrics );
+ error = writing_system_class->style_hints_init( &loader->hints,
+ metrics );
if ( error )
goto Exit;
}
diff --git a/src/3rdparty/freetype/src/autofit/afloader.h b/src/3rdparty/freetype/src/autofit/afloader.h
index fa67c10ffe..9601e24fce 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, 2004, 2005 by */
+/* Copyright 2003-2005, 2011-2013 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 __AF_LOADER_H__
-#define __AF_LOADER_H__
+#ifndef __AFLOADER_H__
+#define __AFLOADER_H__
#include "afhints.h"
#include "afglobal.h"
@@ -25,13 +25,26 @@
FT_BEGIN_HEADER
- typedef struct AF_LoaderRec_
+ typedef struct AF_ModuleRec_* AF_Module;
+
+ /*
+ * The autofitter module's (global) data structure to communicate with
+ * actual fonts. If necessary, `local' data like the current face, the
+ * current face's auto-hint data, or the current glyph's parameters
+ * relevant to auto-hinting are `swapped in'. Cf. functions like
+ * `af_loader_reset' and `af_loader_load_g'.
+ */
+
+ typedef struct AF_LoaderRec_
{
- FT_Face face; /* current face */
- AF_FaceGlobals globals; /* current face globals */
- FT_GlyphLoader gloader; /* glyph loader */
+ /* current face data */
+ FT_Face face;
+ AF_FaceGlobals globals;
+
+ /* current glyph data */
+ FT_GlyphLoader gloader;
AF_GlyphHintsRec hints;
- AF_ScriptMetrics metrics;
+ AF_StyleMetrics metrics;
FT_Bool transformed;
FT_Matrix trans_matrix;
FT_Vector trans_delta;
@@ -43,31 +56,30 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
- af_loader_init( AF_Loader loader,
- FT_Memory memory );
+ af_loader_init( AF_Module module );
FT_LOCAL( FT_Error )
- af_loader_reset( AF_Loader loader,
+ af_loader_reset( AF_Module module,
FT_Face face );
FT_LOCAL( void )
- af_loader_done( AF_Loader loader );
+ af_loader_done( AF_Module module );
FT_LOCAL( FT_Error )
- af_loader_load_glyph( AF_Loader loader,
+ af_loader_load_glyph( AF_Module module,
FT_Face face,
FT_UInt gindex,
- FT_UInt32 load_flags );
+ FT_Int32 load_flags );
/* */
FT_END_HEADER
-#endif /* __AF_LOADER_H__ */
+#endif /* __AFLOADER_H__ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afmodule.c b/src/3rdparty/freetype/src/autofit/afmodule.c
index ec2d707c9f..641e03ea2b 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, 2004, 2005, 2006 by */
+/* Copyright 2003-2006, 2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,12 +16,13 @@
/***************************************************************************/
+#include "afglobal.h"
#include "afmodule.h"
#include "afloader.h"
+#include "aferrors.h"
#include "afpic.h"
-#ifdef AF_DEBUG
- int _af_debug;
+#ifdef FT_DEBUG_AUTOFIT
int _af_debug_disable_horz_hints;
int _af_debug_disable_vert_hints;
int _af_debug_disable_blue_hints;
@@ -29,66 +30,280 @@
#endif
#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_DEBUG_H
+#include FT_AUTOHINTER_H
+#include FT_SERVICE_PROPERTIES_H
- typedef struct FT_AutofitterRec_
+ /*************************************************************************/
+ /* */
+ /* 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_afmodule
+
+
+ static FT_Error
+ af_property_get_face_globals( FT_Face face,
+ AF_FaceGlobals* aglobals,
+ AF_Module module )
+ {
+ FT_Error error = FT_Err_Ok;
+ AF_FaceGlobals globals;
+
+
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
+
+ globals = (AF_FaceGlobals)face->autohint.data;
+ if ( !globals )
+ {
+ /* trigger computation of the global style data */
+ /* in case it hasn't been done yet */
+ error = af_face_globals_new( face, &globals, module );
+ if ( !error )
+ {
+ face->autohint.data =
+ (FT_Pointer)globals;
+ face->autohint.finalizer =
+ (FT_Generic_Finalizer)af_face_globals_free;
+ }
+ }
+
+ if ( !error )
+ *aglobals = globals;
+
+ return error;
+ }
+
+
+ static FT_Error
+ af_property_set( FT_Module ft_module,
+ const char* property_name,
+ const void* value )
+ {
+ FT_Error error = FT_Err_Ok;
+ AF_Module module = (AF_Module)ft_module;
+
+
+ if ( !ft_strcmp( property_name, "fallback-script" ) )
+ {
+ FT_UInt* fallback_script = (FT_UInt*)value;
+
+ FT_UInt ss;
+
+
+ /* We translate the fallback script to a fallback style that uses */
+ /* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */
+ /* coverage value. */
+ for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
+ {
+ AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
+
+
+ if ( (FT_UInt)style_class->script == *fallback_script &&
+ style_class->coverage == AF_COVERAGE_DEFAULT )
+ {
+ module->fallback_style = ss;
+ break;
+ }
+ }
+
+ if ( !AF_STYLE_CLASSES_GET[ss] )
+ {
+ FT_TRACE0(( "af_property_set: Invalid value %d for property `%s'\n",
+ fallback_script, property_name ));
+ return FT_THROW( Invalid_Argument );
+ }
+
+ return error;
+ }
+ else if ( !ft_strcmp( property_name, "default-script" ) )
+ {
+ FT_UInt* default_script = (FT_UInt*)value;
+
+
+ module->default_script = *default_script;
+
+ return error;
+ }
+ else if ( !ft_strcmp( property_name, "increase-x-height" ) )
+ {
+ FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
+ AF_FaceGlobals globals;
+
+
+ error = af_property_get_face_globals( prop->face, &globals, module );
+ if ( !error )
+ globals->increase_x_height = prop->limit;
+
+ return error;
+ }
+
+ FT_TRACE0(( "af_property_set: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ static FT_Error
+ af_property_get( FT_Module ft_module,
+ const char* property_name,
+ void* value )
+ {
+ FT_Error error = FT_Err_Ok;
+ AF_Module module = (AF_Module)ft_module;
+ FT_UInt fallback_style = module->fallback_style;
+ FT_UInt default_script = module->default_script;
+
+
+ if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
+ {
+ FT_Prop_GlyphToScriptMap* prop = (FT_Prop_GlyphToScriptMap*)value;
+ AF_FaceGlobals globals;
+
+
+ error = af_property_get_face_globals( prop->face, &globals, module );
+ if ( !error )
+ prop->map = globals->glyph_styles;
+
+ return error;
+ }
+ else if ( !ft_strcmp( property_name, "fallback-script" ) )
+ {
+ FT_UInt* val = (FT_UInt*)value;
+
+ AF_StyleClass style_class = AF_STYLE_CLASSES_GET[fallback_style];
+
+
+ *val = style_class->script;
+
+ return error;
+ }
+ else if ( !ft_strcmp( property_name, "default-script" ) )
+ {
+ FT_UInt* val = (FT_UInt*)value;
+
+
+ *val = default_script;
+
+ return error;
+ }
+ else if ( !ft_strcmp( property_name, "increase-x-height" ) )
+ {
+ FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
+ AF_FaceGlobals globals;
+
+
+ error = af_property_get_face_globals( prop->face, &globals, module );
+ if ( !error )
+ prop->limit = globals->increase_x_height;
+
+ return error;
+ }
+
+
+ FT_TRACE0(( "af_property_get: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ af_service_properties,
+ (FT_Properties_SetFunc)af_property_set,
+ (FT_Properties_GetFunc)af_property_get )
+
+
+ FT_DEFINE_SERVICEDESCREC1(
+ af_services,
+ FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET )
+
+
+ FT_CALLBACK_DEF( FT_Module_Interface )
+ af_get_interface( FT_Module module,
+ const char* module_interface )
{
- FT_ModuleRec root;
- AF_LoaderRec loader[1];
+ /* AF_SERVICES_GET dereferences `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_Library library;
+
+
+ if ( !module )
+ return NULL;
+ library = module->library;
+ if ( !library )
+ return NULL;
+#else
+ FT_UNUSED( module );
+#endif
- } FT_AutofitterRec, *FT_Autofitter;
+ return ft_service_list_lookup( AF_SERVICES_GET, module_interface );
+ }
FT_CALLBACK_DEF( FT_Error )
- af_autofitter_init( FT_Autofitter module )
+ af_autofitter_init( FT_Module ft_module ) /* AF_Module */
{
- return af_loader_init( module->loader, module->root.library->memory );
+ AF_Module module = (AF_Module)ft_module;
+
+
+ module->fallback_style = AF_STYLE_FALLBACK;
+ module->default_script = AF_SCRIPT_DEFAULT;
+
+ return af_loader_init( module );
}
FT_CALLBACK_DEF( void )
- af_autofitter_done( FT_Autofitter module )
+ af_autofitter_done( FT_Module ft_module ) /* AF_Module */
{
- af_loader_done( module->loader );
+ AF_Module module = (AF_Module)ft_module;
+
+
+ af_loader_done( module );
}
FT_CALLBACK_DEF( FT_Error )
- af_autofitter_load_glyph( FT_Autofitter module,
- FT_GlyphSlot slot,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
+ af_autofitter_load_glyph( AF_Module module,
+ FT_GlyphSlot slot,
+ FT_Size size,
+ FT_UInt glyph_index,
+ FT_Int32 load_flags )
{
FT_UNUSED( size );
- return af_loader_load_glyph( module->loader, slot->face,
+ return af_loader_load_glyph( module, slot->face,
glyph_index, load_flags );
}
- FT_DEFINE_AUTOHINTER_SERVICE(af_autofitter_service,
- NULL,
- NULL,
- NULL,
- (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph
- )
+ FT_DEFINE_AUTOHINTER_INTERFACE(
+ af_autofitter_interface,
+ NULL, /* reset_face */
+ NULL, /* get_global_hints */
+ NULL, /* done_global_hints */
+ (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph ) /* load_glyph */
+
- FT_DEFINE_MODULE(autofit_module_class,
+ FT_DEFINE_MODULE(
+ autofit_module_class,
FT_MODULE_HINTER,
- sizeof ( FT_AutofitterRec ),
+ sizeof ( AF_ModuleRec ),
"autofitter",
0x10000L, /* version 1.0 of the autofitter */
0x20000L, /* requires FreeType 2.0 or above */
- (const void*)&AF_AF_AUTOFITTER_SERVICE_GET,
+ (const void*)&AF_INTERFACE_GET,
(FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done,
- (FT_Module_Requester) NULL
- )
+ (FT_Module_Requester) af_get_interface )
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afmodule.h b/src/3rdparty/freetype/src/autofit/afmodule.h
index d9792399b6..20b7b9f665 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, 2004, 2005 by */
+/* Copyright 2003-2005, 2009, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,9 +23,31 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_MODULE_H
+#include "afloader.h"
+
FT_BEGIN_HEADER
+
+ /*
+ * This is the `extended' FT_Module structure which holds the
+ * autofitter's global data. Right before hinting a glyph, the data
+ * specific to the glyph's face (blue zones, stem widths, etc.) are
+ * loaded into `loader' (see function `af_loader_reset').
+ */
+
+ typedef struct AF_ModuleRec_
+ {
+ FT_ModuleRec root;
+
+ FT_UInt fallback_style;
+ FT_UInt default_script;
+
+ AF_LoaderRec loader[1];
+
+ } AF_ModuleRec;
+
+
FT_DECLARE_MODULE(autofit_module_class)
diff --git a/src/3rdparty/freetype/src/autofit/afpic.c b/src/3rdparty/freetype/src/autofit/afpic.c
index 76822c301a..cb29fd79fe 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 by */
+/* Copyright 2009-2014 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,72 +20,132 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "afpic.h"
+#include "afglobal.h"
+#include "aferrors.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from afmodule.c */
- void FT_Init_Class_af_autofitter_service( FT_Library, FT_AutoHinter_ServiceRec*);
+ FT_Error
+ FT_Create_Class_af_services( FT_Library library,
+ FT_ServiceDescRec** output_class );
- /* forward declaration of PIC init functions from script classes */
-#include "aflatin.h"
-#include "aflatin2.h"
-#include "afcjk.h"
-#include "afdummy.h"
-#include "afindic.h"
+ void
+ FT_Destroy_Class_af_services( FT_Library library,
+ FT_ServiceDescRec* clazz );
void
- autofit_module_class_pic_free( FT_Library library )
+ FT_Init_Class_af_service_properties( FT_Service_PropertiesRec* clazz );
+
+ void FT_Init_Class_af_autofitter_interface(
+ FT_Library library,
+ FT_AutoHinter_InterfaceRec* clazz );
+
+
+ /* forward declaration of PIC init functions from writing system classes */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) /* empty */
+
+#include "afwrtsys.h"
+
+
+ void
+ autofit_module_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->autofit )
{
- FT_FREE( pic_container->autofit );
+ AFModulePIC* container = (AFModulePIC*)pic_container->autofit;
+
+
+ if ( container->af_services )
+ FT_Destroy_Class_af_services( library,
+ container->af_services );
+ container->af_services = NULL;
+
+ FT_FREE( container );
pic_container->autofit = NULL;
}
}
+
FT_Error
- autofit_module_class_pic_init( FT_Library library )
+ autofit_module_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_UInt ss;
- FT_Error error = FT_Err_Ok;
- AFModulePIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_UInt ss;
+ FT_Error error = FT_Err_Ok;
+ AFModulePIC* container = NULL;
+ FT_Memory memory = library->memory;
+
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->autofit = container;
- /* initialize pointer table - this is how the module usually expects this data */
- for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
- {
- container->af_script_classes[ss] = &container->af_script_classes_rec[ss];
- }
- container->af_script_classes[AF_SCRIPT_CLASSES_COUNT-1] = NULL;
-
- /* add call to initialization function when you add new scripts */
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ error = FT_Create_Class_af_services( library,
+ &container->af_services );
+ if ( error )
+ goto Exit;
+
+ FT_Init_Class_af_service_properties( &container->af_service_properties );
+
+ for ( ss = 0; ss < AF_WRITING_SYSTEM_MAX; ss++ )
+ container->af_writing_system_classes[ss] =
+ &container->af_writing_system_classes_rec[ss];
+ container->af_writing_system_classes[AF_WRITING_SYSTEM_MAX] = NULL;
+
+ for ( ss = 0; ss < AF_SCRIPT_MAX; ss++ )
+ container->af_script_classes[ss] =
+ &container->af_script_classes_rec[ss];
+ container->af_script_classes[AF_SCRIPT_MAX] = NULL;
+
+ for ( ss = 0; ss < AF_STYLE_MAX; ss++ )
+ container->af_style_classes[ss] =
+ &container->af_style_classes_rec[ss];
+ container->af_style_classes[AF_STYLE_MAX] = NULL;
+
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) \
+ FT_Init_Class_af_ ## ws ## _writing_system_class( \
+ &container->af_writing_system_classes_rec[ss++] );
+
ss = 0;
- FT_Init_Class_af_dummy_script_class(&container->af_script_classes_rec[ss++]);
-#ifdef FT_OPTION_AUTOFIT2
- FT_Init_Class_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
-#endif
- FT_Init_Class_af_latin_script_class(&container->af_script_classes_rec[ss++]);
- FT_Init_Class_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
- FT_Init_Class_af_indic_script_class(&container->af_script_classes_rec[ss++]);
-
- FT_Init_Class_af_autofitter_service(library, &container->af_autofitter_service);
-
-/*Exit:*/
- if(error)
- autofit_module_class_pic_free(library);
+#include "afwrtsys.h"
+
+#undef SCRIPT
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+ FT_Init_Class_af_ ## s ## _script_class( \
+ &container->af_script_classes_rec[ss++] );
+
+ ss = 0;
+#include "afscript.h"
+
+#undef STYLE
+#define STYLE( s, S, d, ws, sc, bss, c ) \
+ FT_Init_Class_af_ ## s ## _style_class( \
+ &container->af_style_classes_rec[ss++] );
+
+ ss = 0;
+#include "afstyles.h"
+
+ FT_Init_Class_af_autofitter_interface(
+ library, &container->af_autofitter_interface );
+
+ Exit:
+ if ( error )
+ autofit_module_class_pic_free( library );
return error;
}
-
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/autofit/afpic.h b/src/3rdparty/freetype/src/autofit/afpic.h
index 80e62d39a9..9a68b4a5a2 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 by */
+/* Copyright 2009, 2011-2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,38 +19,79 @@
#ifndef __AFPIC_H__
#define __AFPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
+
#ifndef FT_CONFIG_OPTION_PIC
-#define AF_SCRIPT_CLASSES_GET af_script_classes
-#define AF_AF_AUTOFITTER_SERVICE_GET af_autofitter_service
+#define AF_SERVICES_GET af_services
+#define AF_SERVICE_PROPERTIES_GET af_service_properties
+
+#define AF_WRITING_SYSTEM_CLASSES_GET af_writing_system_classes
+#define AF_SCRIPT_CLASSES_GET af_script_classes
+#define AF_STYLE_CLASSES_GET af_style_classes
+#define AF_INTERFACE_GET af_autofitter_interface
#else /* FT_CONFIG_OPTION_PIC */
+ /* some include files required for members of AFModulePIC */
+#include FT_SERVICE_PROPERTIES_H
+
#include "aftypes.h"
-/* increase these when you add new scripts, and update autofit_module_class_pic_init */
-#ifdef FT_OPTION_AUTOFIT2
- #define AF_SCRIPT_CLASSES_COUNT 6
-#else
- #define AF_SCRIPT_CLASSES_COUNT 5
-#endif
-#define AF_SCRIPT_CLASSES_REC_COUNT (AF_SCRIPT_CLASSES_COUNT-1)
- typedef struct AFModulePIC_
+ typedef struct AFModulePIC_
{
- AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
- AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
- FT_AutoHinter_ServiceRec af_autofitter_service;
+ FT_ServiceDescRec* af_services;
+ FT_Service_PropertiesRec af_service_properties;
+
+ AF_WritingSystemClass af_writing_system_classes
+ [AF_WRITING_SYSTEM_MAX + 1];
+ AF_WritingSystemClassRec af_writing_system_classes_rec
+ [AF_WRITING_SYSTEM_MAX];
+
+ AF_ScriptClass af_script_classes
+ [AF_SCRIPT_MAX + 1];
+ AF_ScriptClassRec af_script_classes_rec
+ [AF_SCRIPT_MAX];
+
+ AF_StyleClass af_style_classes
+ [AF_STYLE_MAX + 1];
+ AF_StyleClassRec af_style_classes_rec
+ [AF_STYLE_MAX];
+
+ FT_AutoHinter_InterfaceRec af_autofitter_interface;
+
} AFModulePIC;
-#define GET_PIC(lib) ((AFModulePIC*)((lib)->pic_container.autofit))
-#define AF_SCRIPT_CLASSES_GET (GET_PIC(FT_FACE_LIBRARY(globals->face))->af_script_classes)
-#define AF_AF_AUTOFITTER_SERVICE_GET (GET_PIC(library)->af_autofitter_service)
+
+#define GET_PIC( lib ) \
+ ( (AFModulePIC*)((lib)->pic_container.autofit) )
+
+#define AF_SERVICES_GET \
+ ( GET_PIC( library )->af_services )
+#define AF_SERVICE_PROPERTIES_GET \
+ ( GET_PIC( library )->af_service_properties )
+
+#define AF_WRITING_SYSTEM_CLASSES_GET \
+ ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_writing_system_classes )
+#define AF_SCRIPT_CLASSES_GET \
+ ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_script_classes )
+#define AF_STYLE_CLASSES_GET \
+ ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_style_classes )
+#define AF_INTERFACE_GET \
+ ( GET_PIC( library )->af_autofitter_interface )
+
+
+ /* see afpic.c for the implementation */
+ void
+ autofit_module_class_pic_free( FT_Library library );
+
+ FT_Error
+ autofit_module_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/autofit/afranges.c b/src/3rdparty/freetype/src/autofit/afranges.c
new file mode 100644
index 0000000000..b2c504d426
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afranges.c
@@ -0,0 +1,220 @@
+/***************************************************************************/
+/* */
+/* afranges.c */
+/* */
+/* Auto-fitter Unicode script ranges (body). */
+/* */
+/* Copyright 2013, 2014 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 "afranges.h"
+
+
+ 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 )
+ };
+
+ /* there are some characters in the Devanagari Unicode block that are */
+ /* generic to Indic scripts; we omit them so that their presence doesn't */
+ /* trigger Devanagari */
+
+ const AF_Script_UniRangeRec af_deva_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0900UL, 0x093BUL ), /* Devanagari */
+ /* omitting U+093C nukta */
+ AF_UNIRANGE_REC( 0x093DUL, 0x0950UL ),
+ /* omitting U+0951 udatta, U+0952 anudatta */
+ AF_UNIRANGE_REC( 0x0953UL, 0x0963UL ),
+ /* omitting U+0964 danda, U+0965 double danda */
+ AF_UNIRANGE_REC( 0x0966UL, 0x097FUL ),
+ AF_UNIRANGE_REC( 0x20B9UL, 0x20B9UL ), /* (new) Rupee sign */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_grek_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0370UL, 0x03FFUL ), /* Greek and Coptic */
+ AF_UNIRANGE_REC( 0x1F00UL, 0x1FFFUL ), /* Greek Extended */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ 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 )
+ };
+
+ const AF_Script_UniRangeRec af_latn_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0020UL, 0x007FUL ), /* Basic Latin (no control chars) */
+ AF_UNIRANGE_REC( 0x00A0UL, 0x00FFUL ), /* Latin-1 Supplement (no control chars) */
+ AF_UNIRANGE_REC( 0x0100UL, 0x017FUL ), /* Latin Extended-A */
+ AF_UNIRANGE_REC( 0x0180UL, 0x024FUL ), /* Latin Extended-B */
+ AF_UNIRANGE_REC( 0x0250UL, 0x02AFUL ), /* IPA Extensions */
+ AF_UNIRANGE_REC( 0x02B0UL, 0x02FFUL ), /* Spacing Modifier Letters */
+ AF_UNIRANGE_REC( 0x0300UL, 0x036FUL ), /* Combining Diacritical Marks */
+ AF_UNIRANGE_REC( 0x1D00UL, 0x1D7FUL ), /* Phonetic Extensions */
+ AF_UNIRANGE_REC( 0x1D80UL, 0x1DBFUL ), /* Phonetic Extensions Supplement */
+ AF_UNIRANGE_REC( 0x1DC0UL, 0x1DFFUL ), /* Combining Diacritical Marks Supplement */
+ AF_UNIRANGE_REC( 0x1E00UL, 0x1EFFUL ), /* Latin Extended Additional */
+ AF_UNIRANGE_REC( 0x2000UL, 0x206FUL ), /* General Punctuation */
+ AF_UNIRANGE_REC( 0x2070UL, 0x209FUL ), /* Superscripts and Subscripts */
+ AF_UNIRANGE_REC( 0x20A0UL, 0x20B8UL ), /* Currency Symbols ... */
+ AF_UNIRANGE_REC( 0x20BAUL, 0x20CFUL ), /* ... except new Rupee sign */
+ AF_UNIRANGE_REC( 0x2150UL, 0x218FUL ), /* Number Forms */
+ AF_UNIRANGE_REC( 0x2460UL, 0x24FFUL ), /* Enclosed Alphanumerics */
+ AF_UNIRANGE_REC( 0x2C60UL, 0x2C7FUL ), /* Latin Extended-C */
+ AF_UNIRANGE_REC( 0x2E00UL, 0x2E7FUL ), /* Supplemental Punctuation */
+ AF_UNIRANGE_REC( 0xA720UL, 0xA7FFUL ), /* Latin Extended-D */
+ AF_UNIRANGE_REC( 0xFB00UL, 0xFB06UL ), /* Alphab. Present. Forms (Latin Ligs) */
+ AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ), /* Mathematical Alphanumeric Symbols */
+ AF_UNIRANGE_REC( 0x1F100UL, 0x1F1FFUL ), /* Enclosed Alphanumeric Supplement */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_none_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_telu_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0C00UL, 0x0C7FUL ), /* Telugu */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+#ifdef AF_CONFIG_OPTION_INDIC
+
+ const AF_Script_UniRangeRec af_beng_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0980UL, 0x09FFUL ), /* Bengali */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_gujr_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0A80UL, 0x0AFFUL ), /* Gujarati */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_guru_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0A00UL, 0x0A7FUL ), /* Gurmukhi */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_knda_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0C80UL, 0x0CFFUL ), /* Kannada */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_limb_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x1900UL, 0x194FUL ), /* Limbu */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_mlym_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0D00UL, 0x0D7FUL ), /* Malayalam */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_orya_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0B00UL, 0x0B7FUL ), /* Oriya */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_sinh_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0D80UL, 0x0DFFUL ), /* Sinhala */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_sund_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x1B80UL, 0x1BBFUL ), /* Sundanese */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_sylo_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0xA800UL, 0xA82FUL ), /* Syloti Nagri */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_taml_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0B80UL, 0x0BFFUL ), /* Tamil */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+ const AF_Script_UniRangeRec af_tibt_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0F00UL, 0x0FFFUL ), /* Tibetan */
+ AF_UNIRANGE_REC( 0UL, 0UL )
+ };
+
+#endif /* !AF_CONFIG_OPTION_INDIC */
+
+#ifdef AF_CONFIG_OPTION_CJK
+
+ /* this corresponds to Unicode 6.0 */
+
+ 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( 0x3200UL, 0x32FFUL ), /* Enclosed CJK Letters and Months */
+ 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( 0x1F200UL, 0x1F2FFUL ), /* Enclosed Ideographic Supplement */
+ 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 )
+ };
+
+#endif /* !AF_CONFIG_OPTION_CJK */
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afranges.h b/src/3rdparty/freetype/src/autofit/afranges.h
new file mode 100644
index 0000000000..fe5b2aa7c1
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afranges.h
@@ -0,0 +1,41 @@
+/***************************************************************************/
+/* */
+/* afranges.h */
+/* */
+/* Auto-fitter Unicode script ranges (specification). */
+/* */
+/* Copyright 2013, 2014 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 __AFRANGES_H__
+#define __AFRANGES_H__
+
+
+#include "aftypes.h"
+
+
+FT_BEGIN_HEADER
+
+#undef SCRIPT
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+ extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[];
+
+#include "afscript.h"
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __AFRANGES_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afscript.h b/src/3rdparty/freetype/src/autofit/afscript.h
new file mode 100644
index 0000000000..efe8754df8
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afscript.h
@@ -0,0 +1,139 @@
+/***************************************************************************/
+/* */
+/* afscript.h */
+/* */
+/* Auto-fitter scripts (specification only). */
+/* */
+/* Copyright 2013, 2014 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. */
+/* */
+/***************************************************************************/
+
+
+ /* The following part can be included multiple times. */
+ /* Define `SCRIPT' as needed. */
+
+
+ /* Add new scripts here. The first and second arguments are the */
+ /* script name in lowercase and uppercase, respectively, followed */
+ /* by a description string. Then comes the corresponding HarfBuzz */
+ /* script name tag, followed by a string of standard characters (to */
+ /* derive the standard width and height of stems). */
+
+ SCRIPT( cyrl, CYRL,
+ "Cyrillic",
+ HB_SCRIPT_CYRILLIC,
+ 0x43E, 0x41E, 0x0 ) /* оО */
+
+ SCRIPT( deva, DEVA,
+ "Devanagari",
+ HB_SCRIPT_DEVANAGARI,
+ 0x920, 0x935, 0x91F ) /* ठ व ट */
+
+ SCRIPT( grek, GREK,
+ "Greek",
+ HB_SCRIPT_GREEK,
+ 0x3BF, 0x39F, 0x0 ) /* οΟ */
+
+ SCRIPT( hebr, HEBR,
+ "Hebrew",
+ HB_SCRIPT_HEBREW,
+ 0x5DD, 0x0, 0x0 ) /* ם */
+
+ SCRIPT( latn, LATN,
+ "Latin",
+ HB_SCRIPT_LATIN,
+ 'o', 'O', '0' )
+
+ SCRIPT( none, NONE,
+ "no script",
+ HB_SCRIPT_INVALID,
+ 0x0, 0x0, 0x0 )
+
+ /* there are no simple forms for letters; we thus use two digit shapes */
+ SCRIPT( telu, TELU,
+ "Telugu",
+ HB_SCRIPT_TELUGU,
+ 0xC66, 0xC67, 0x0 ) /* ౦ ౧ */
+
+#ifdef AF_CONFIG_OPTION_INDIC
+
+ SCRIPT( beng, BENG,
+ "Bengali",
+ HB_SCRIPT_BENGALI,
+ 'o', 0x0, 0x0 ) /* XXX */
+
+ 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 */
+
+ SCRIPT( limb, LIMB,
+ "Limbu",
+ HB_SCRIPT_LIMBU,
+ 'o', 0x0, 0x0 ) /* XXX */
+
+ SCRIPT( mlym, MLYM,
+ "Malayalam",
+ HB_SCRIPT_MALAYALAM,
+ 'o', 0x0, 0x0 ) /* 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 */
+
+ SCRIPT( sylo, SYLO,
+ "Syloti Nagri",
+ HB_SCRIPT_SYLOTI_NAGRI,
+ 'o', 0x0, 0x0 ) /* XXX */
+
+ SCRIPT( taml, TAML,
+ "Tamil",
+ HB_SCRIPT_TAMIL,
+ 'o', 0x0, 0x0 ) /* XXX */
+
+ SCRIPT( tibt, TIBT,
+ "Tibetan",
+ HB_SCRIPT_TIBETAN,
+ 'o', 0x0, 0x0 ) /* XXX */
+
+#endif /* AF_CONFIG_OPTION_INDIC */
+
+#ifdef AF_CONFIG_OPTION_CJK
+
+ SCRIPT( hani, HANI,
+ "CJKV ideographs",
+ HB_SCRIPT_HAN,
+ 0x7530, 0x56D7, 0x0 ) /* 田囗 */
+
+#endif /* AF_CONFIG_OPTION_CJK */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afstyles.h b/src/3rdparty/freetype/src/autofit/afstyles.h
new file mode 100644
index 0000000000..f14d354ccb
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afstyles.h
@@ -0,0 +1,164 @@
+/***************************************************************************/
+/* */
+/* afstyles.h */
+/* */
+/* Auto-fitter styles (specification only). */
+/* */
+/* Copyright 2013, 2014 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. */
+/* */
+/***************************************************************************/
+
+
+ /* The following part can be included multiple times. */
+ /* Define `STYLE' as needed. */
+
+
+ /* Add new styles here. The first and second arguments are the */
+ /* style name in lowercase and uppercase, respectively, followed */
+ /* by a description string. The next arguments are the */
+ /* corresponding writing system, script, blue stringset, and */
+ /* coverage. */
+ /* */
+ /* Note that styles using `AF_COVERAGE_DEFAULT' should always */
+ /* come after styles with other coverages. */
+ /* */
+ /* Example: */
+ /* */
+ /* STYLE( cyrl_dflt, CYRL_DFLT, */
+ /* "Cyrillic default style", */
+ /* AF_WRITING_SYSTEM_LATIN, */
+ /* AF_SCRIPT_CYRL, */
+ /* AF_BLUE_STRINGSET_CYRL, */
+ /* AF_COVERAGE_DEFAULT ) */
+
+#undef STYLE_LATIN
+#define STYLE_LATIN( s, S, f, F, ds, df, C ) \
+ STYLE( s ## _ ## f, S ## _ ## F, \
+ ds " " df " style", \
+ AF_WRITING_SYSTEM_LATIN, \
+ AF_SCRIPT_ ## S, \
+ AF_BLUE_STRINGSET_ ## S, \
+ AF_COVERAGE_ ## C )
+
+#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 ) \
+ STYLE_LATIN( s, S, c2sc, C2SC, ds, \
+ "small capticals from capitals", \
+ SMALL_CAPITALS_FROM_CAPITALS ) \
+ STYLE_LATIN( s, S, ordn, ORDN, ds, \
+ "ordinals", \
+ ORDINALS ) \
+ STYLE_LATIN( s, S, pcap, PCAP, ds, \
+ "petite capitals", \
+ PETITE_CAPITALS ) \
+ STYLE_LATIN( s, S, sinf, SINF, ds, \
+ "scientific inferiors", \
+ SCIENTIFIC_INFERIORS ) \
+ STYLE_LATIN( s, S, smcp, SMCP, ds, \
+ "small capitals", \
+ SMALL_CAPITALS ) \
+ STYLE_LATIN( s, S, subs, SUBS, ds, \
+ "subscript", \
+ SUBSCRIPT ) \
+ STYLE_LATIN( s, S, sups, SUPS, ds, \
+ "superscript", \
+ SUPERSCRIPT ) \
+ STYLE_LATIN( s, S, titl, TITL, ds, \
+ "titling", \
+ TITLING ) \
+ STYLE_LATIN( s, S, dflt, DFLT, ds, \
+ "default", \
+ DEFAULT )
+
+ META_STYLE_LATIN( cyrl, CYRL, "Cyrillic" )
+
+ META_STYLE_LATIN( grek, GREK, "Greek" )
+
+ STYLE( hebr_dflt, HEBR_DFLT,
+ "Hebrew default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_HEBR,
+ AF_BLUE_STRINGSET_HEBR,
+ AF_COVERAGE_DEFAULT )
+ META_STYLE_LATIN( latn, LATN, "Latin" )
+
+ STYLE( deva_dflt, DEVA_DFLT,
+ "Devanagari default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_DEVA,
+ AF_BLUE_STRINGSET_DEVA,
+ AF_COVERAGE_DEFAULT )
+
+#ifdef FT_OPTION_AUTOFIT2
+ STYLE( ltn2_dflt, LTN2_DFLT,
+ "Latin 2 default style",
+ AF_WRITING_SYSTEM_LATIN2,
+ AF_SCRIPT_LATN,
+ AF_BLUE_STRINGSET_LATN,
+ AF_COVERAGE_DEFAULT )
+#endif
+
+ STYLE( none_dflt, NONE_DFLT,
+ "no style",
+ AF_WRITING_SYSTEM_DUMMY,
+ AF_SCRIPT_NONE,
+ (AF_Blue_Stringset)0,
+ AF_COVERAGE_DEFAULT )
+
+ STYLE( telu_dflt, TELU_DFLT,
+ "Telugu default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_TELU,
+ AF_BLUE_STRINGSET_TELU,
+ AF_COVERAGE_DEFAULT )
+
+#ifdef AF_CONFIG_OPTION_INDIC
+
+ /* no blue stringset support for the Indic writing system yet */
+#undef STYLE_DEFAULT_INDIC
+#define STYLE_DEFAULT_INDIC( s, S, d ) \
+ STYLE( s ## _dflt, S ## _DFLT, \
+ d " default style", \
+ AF_WRITING_SYSTEM_INDIC, \
+ AF_SCRIPT_ ## S, \
+ (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 */
+
+#ifdef AF_CONFIG_OPTION_CJK
+
+ STYLE( hani_dflt, HANI_DFLT,
+ "CJKV ideographs default style",
+ AF_WRITING_SYSTEM_CJK,
+ AF_SCRIPT_HANI,
+ AF_BLUE_STRINGSET_HANI,
+ AF_COVERAGE_DEFAULT )
+
+#endif /* AF_CONFIG_OPTION_CJK */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/aftypes.h b/src/3rdparty/freetype/src/autofit/aftypes.h
index 5574f0c302..61badd1b8d 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, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2003-2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,15 +20,12 @@
*
* The auto-fitter is a complete rewrite of the old auto-hinter.
* Its main feature is the ability to differentiate between different
- * scripts in order to apply language-specific rules.
+ * writing systems and scripts in order to apply specific rules.
*
* The code has also been compartmentized into several entities that
* should make algorithmic experimentation easier than with the old
* code.
*
- * Finally, we get rid of the Catharon license, since this code is
- * released under the FreeType one.
- *
*************************************************************************/
@@ -42,6 +39,8 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
+#include "afblue.h"
+
FT_BEGIN_HEADER
@@ -53,26 +52,16 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
-#define xxAF_USE_WARPER /* only define to use warp hinting */
-#define xxAF_DEBUG
-
-#ifdef AF_DEBUG
+#ifdef FT_DEBUG_AUTOFIT
#include FT_CONFIG_STANDARD_LIBRARY_H
-#define AF_LOG( x ) do { if ( _af_debug ) printf x; } while ( 0 )
-
-extern int _af_debug;
extern int _af_debug_disable_horz_hints;
extern int _af_debug_disable_vert_hints;
extern int _af_debug_disable_blue_hints;
extern void* _af_debug_hints;
-#else /* !AF_DEBUG */
-
-#define AF_LOG( x ) do { } while ( 0 ) /* nothing */
-
-#endif /* !AF_DEBUG */
+#endif /* FT_DEBUG_AUTOFIT */
/*************************************************************************/
@@ -97,8 +86,9 @@ extern void* _af_debug_hints;
FT_Pos* table );
FT_LOCAL( void )
- af_sort_widths( FT_UInt count,
- AF_Width widths );
+ af_sort_and_quantize_widths( FT_UInt* count,
+ AF_Width widths,
+ FT_Pos threshold );
/*************************************************************************/
@@ -159,36 +149,11 @@ extern void* _af_debug_hints;
FT_END_STMNT
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** O U T L I N E S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
/* opaque handle to glyph-specific hints -- see `afhints.h' for more
* details
*/
typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
- /* This structure is used to model an input glyph outline to
- * the auto-hinter. The latter will set the `hints' field
- * depending on the glyph's script.
- */
- typedef struct AF_OutlineRec_
- {
- FT_Face face;
- FT_Outline outline;
- FT_UInt outline_resolution;
-
- FT_Int advance;
- FT_UInt metrics_resolution;
-
- AF_GlyphHints hints;
-
- } AF_OutlineRec;
-
/*************************************************************************/
/*************************************************************************/
@@ -232,87 +197,124 @@ extern void* _af_debug_hints;
(a)->y_delta == (b)->y_delta )
+ typedef struct AF_StyleMetricsRec_* AF_StyleMetrics;
+
+ /* This function parses an FT_Face to compute global metrics for
+ * a specific style.
+ */
+ typedef FT_Error
+ (*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics metrics,
+ FT_Face face );
+
+ typedef void
+ (*AF_WritingSystem_ScaleMetricsFunc)( AF_StyleMetrics metrics,
+ AF_Scaler scaler );
+
+ typedef void
+ (*AF_WritingSystem_DoneMetricsFunc)( AF_StyleMetrics metrics );
+
+
+ typedef FT_Error
+ (*AF_WritingSystem_InitHintsFunc)( AF_GlyphHints hints,
+ AF_StyleMetrics metrics );
+
+ typedef void
+ (*AF_WritingSystem_ApplyHintsFunc)( AF_GlyphHints hints,
+ FT_Outline* outline,
+ AF_StyleMetrics metrics );
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
- /***** S C R I P T S *****/
+ /***** W R I T I N G S Y S T E M S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
- * The list of know scripts. Each different script corresponds to the
- * following information:
- *
- * - A set of Unicode ranges to test whether the face supports the
- * script.
- *
- * - A specific global analyzer that will compute global metrics
- * specific to the script.
+ * For the auto-hinter, a writing system consists of multiple scripts that
+ * can be handled similarly *in a typographical way*; the relationship is
+ * not based on history. For example, both the Greek and the unrelated
+ * Armenian scripts share the same features like ascender, descender,
+ * x-height, etc. Essentially, a writing system is covered by a
+ * submodule of the auto-fitter; it contains
*
- * - A specific glyph analyzer that will compute segments and
- * edges for each glyph covered by the script.
+ * - a specific global analyzer that computes global metrics specific to
+ * the script (based on script-specific characters to identify ascender
+ * height, x-height, etc.),
*
- * - A specific grid-fitting algorithm that will distort the
- * scaled glyph outline according to the results of the glyph
- * analyzer.
+ * - a specific glyph analyzer that computes segments and edges for each
+ * glyph covered by the script,
*
- * Note that a given analyzer and/or grid-fitting algorithm can be
- * used by more than one script.
+ * - a specific grid-fitting algorithm that distorts the scaled glyph
+ * outline according to the results of the glyph analyzer.
*/
- typedef enum AF_Script_
+#define __AFWRTSYS_H__ /* don't load header files */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) \
+ AF_WRITING_SYSTEM_ ## WS,
+
+ /* The list of known writing systems. */
+ typedef enum AF_WritingSystem_
{
- AF_SCRIPT_NONE = 0,
- AF_SCRIPT_LATIN = 1,
- AF_SCRIPT_CJK = 2,
- AF_SCRIPT_INDIC = 3,
-#ifdef FT_OPTION_AUTOFIT2
- AF_SCRIPT_LATIN2,
-#endif
- /* add new scripts here. Don't forget to update the list in */
- /* `afglobal.c'. */
+#include "afwrtsys.h"
- AF_SCRIPT_MAX /* do not remove */
+ AF_WRITING_SYSTEM_MAX /* do not remove */
- } AF_Script;
+ } AF_WritingSystem;
+#undef __AFWRTSYS_H__
- typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
- typedef struct AF_ScriptMetricsRec_
+ typedef struct AF_WritingSystemClassRec_
{
- AF_ScriptClass clazz;
- AF_ScalerRec scaler;
- FT_Bool digits_have_same_width;
+ AF_WritingSystem writing_system;
- } AF_ScriptMetricsRec, *AF_ScriptMetrics;
+ FT_Offset style_metrics_size;
+ AF_WritingSystem_InitMetricsFunc style_metrics_init;
+ AF_WritingSystem_ScaleMetricsFunc style_metrics_scale;
+ AF_WritingSystem_DoneMetricsFunc style_metrics_done;
+ AF_WritingSystem_InitHintsFunc style_hints_init;
+ AF_WritingSystem_ApplyHintsFunc style_hints_apply;
- /* This function parses an FT_Face to compute global metrics for
- * a specific script.
+ } AF_WritingSystemClassRec;
+
+ typedef const AF_WritingSystemClassRec* AF_WritingSystemClass;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** S C R I P T S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*
+ * Each script is associated with a set of Unicode ranges that gets used
+ * to test whether the font face supports the script.
+ *
+ * We use four-letter script tags from the OpenType specification,
+ * extended by `NONE', which indicates `no script'.
*/
- typedef FT_Error
- (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics,
- FT_Face face );
- typedef void
- (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics,
- AF_Scaler scaler );
+#undef SCRIPT
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+ AF_SCRIPT_ ## S,
- typedef void
- (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics );
+ /* The list of known scripts. */
+ typedef enum AF_Script_
+ {
+#include "afscript.h"
- typedef FT_Error
- (*AF_Script_InitHintsFunc)( AF_GlyphHints hints,
- AF_ScriptMetrics metrics );
+ AF_SCRIPT_MAX /* do not remove */
- typedef void
- (*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints,
- FT_Outline* outline,
- AF_ScriptMetrics metrics );
+ } AF_Script;
typedef struct AF_Script_UniRangeRec_
@@ -324,73 +326,303 @@ extern void* _af_debug_hints;
#define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
- typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
+ typedef const AF_Script_UniRangeRec* AF_Script_UniRange;
typedef struct AF_ScriptClassRec_
{
- AF_Script script;
- AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
+ AF_Script script;
- FT_Offset script_metrics_size;
- AF_Script_InitMetricsFunc script_metrics_init;
- AF_Script_ScaleMetricsFunc script_metrics_scale;
- AF_Script_DoneMetricsFunc script_metrics_done;
+ AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
- AF_Script_InitHintsFunc script_hints_init;
- AF_Script_ApplyHintsFunc script_hints_apply;
+ FT_UInt32 standard_char1; /* for default width and height */
+ FT_UInt32 standard_char2; /* ditto */
+ FT_UInt32 standard_char3; /* ditto */
} AF_ScriptClassRec;
-/* Declare and define vtables for classes */
+ typedef const AF_ScriptClassRec* AF_ScriptClass;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** C O V E R A G E S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*
+ * Usually, a font contains more glyphs than can be addressed by its
+ * character map.
+ *
+ * In the PostScript font world, encoding vectors specific to a given
+ * task are used to select such glyphs, and these glyphs can be often
+ * recognized by having a suffix in its glyph names. For example, a
+ * superscript glyph `A' might be called `A.sup'. Unfortunately, this
+ * naming scheme is not standardized and thus unusable for us.
+ *
+ * In the OpenType world, a better solution was invented, namely
+ * `features', which cleanly separate a character's input encoding from
+ * the corresponding glyph's appearance, and which don't use glyph names
+ * at all. For our purposes, and slightly generalized, an OpenType
+ * feature is a name of a mapping that maps character codes to
+ * non-standard glyph indices (features get used for other things also).
+ * For example, the `sups' feature provides superscript glyphs, thus
+ * mapping character codes like `A' or `B' to superscript glyph
+ * representation forms. How this mapping happens is completely
+ * uninteresting to us.
+ *
+ * For the auto-hinter, a `coverage' represents all glyphs of an OpenType
+ * feature collected in a set (as listed below) that can be hinted
+ * together. To continue the above example, superscript glyphs must not
+ * be hinted together with normal glyphs because the blue zones
+ * completely differ.
+ *
+ * Note that FreeType itself doesn't compute coverages; it only provides
+ * the glyphs addressable by the default Unicode character map. Instead,
+ * we use the HarfBuzz library (if available), which has many functions
+ * exactly for this purpose.
+ *
+ * AF_COVERAGE_DEFAULT is special: It should cover everything that isn't
+ * listed separately (including the glyphs addressable by the character
+ * map). In case HarfBuzz isn't available, it exactly covers the glyphs
+ * addressable by the character map.
+ *
+ */
+
+#undef COVERAGE
+#define COVERAGE( name, NAME, description, \
+ tag1, tag2, tag3, tag4 ) \
+ AF_COVERAGE_ ## NAME,
+
+
+ typedef enum AF_Coverage_
+ {
+#include "afcover.h"
+
+ AF_COVERAGE_DEFAULT
+
+ } AF_Coverage;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** S T Y L E S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*
+ * The topmost structure for modelling the auto-hinter glyph input data
+ * is a `style class', grouping everything together.
+ */
+
+#undef STYLE
+#define STYLE( s, S, d, ws, sc, ss, c ) \
+ AF_STYLE_ ## S,
+
+ /* The list of known styles. */
+ typedef enum AF_Style_
+ {
+
+#include "afstyles.h"
+
+ AF_STYLE_MAX /* do not remove */
+
+ } AF_Style;
+
+
+ typedef struct AF_StyleClassRec_
+ {
+ AF_Style style;
+
+ AF_WritingSystem writing_system;
+ AF_Script script;
+ AF_Blue_Stringset blue_stringset;
+ AF_Coverage coverage;
+
+ } AF_StyleClassRec;
+
+ typedef const AF_StyleClassRec* AF_StyleClass;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** S T Y L E M E T R I C S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
+
+ /* This is the main structure that combines everything. Autofit modules */
+ /* specific to writing systems derive their structures from it, for */
+ /* example `AF_LatinMetrics'. */
+
+ typedef struct AF_StyleMetricsRec_
+ {
+ AF_StyleClass style_class;
+ AF_ScalerRec scaler;
+ FT_Bool digits_have_same_width;
+
+ AF_FaceGlobals globals; /* to access properties */
+
+ } AF_StyleMetricsRec;
+
+
+ /* Declare and define vtables for classes */
#ifndef FT_CONFIG_OPTION_PIC
-#define AF_DECLARE_SCRIPT_CLASS(script_class) \
- FT_CALLBACK_TABLE const AF_ScriptClassRec \
+#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
+ FT_CALLBACK_TABLE const AF_WritingSystemClassRec \
+ writing_system_class;
+
+#define AF_DEFINE_WRITING_SYSTEM_CLASS( \
+ writing_system_class, \
+ system, \
+ m_size, \
+ m_init, \
+ m_scale, \
+ m_done, \
+ h_init, \
+ h_apply ) \
+ FT_CALLBACK_TABLE_DEF \
+ const AF_WritingSystemClassRec writing_system_class = \
+ { \
+ system, \
+ \
+ m_size, \
+ \
+ m_init, \
+ m_scale, \
+ m_done, \
+ \
+ h_init, \
+ h_apply \
+ };
+
+
+#define AF_DECLARE_SCRIPT_CLASS( script_class ) \
+ FT_CALLBACK_TABLE const AF_ScriptClassRec \
script_class;
-#define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
- m_init, m_scale, m_done, h_init, h_apply) \
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec \
- script_class = \
- { \
- script_, \
- ranges, \
- \
- m_size, \
- \
- m_init, \
- m_scale, \
- m_done, \
- \
- h_init, \
- h_apply \
+#define AF_DEFINE_SCRIPT_CLASS( \
+ script_class, \
+ script, \
+ ranges, \
+ std_char1, \
+ std_char2, \
+ std_char3 ) \
+ FT_CALLBACK_TABLE_DEF \
+ const AF_ScriptClassRec script_class = \
+ { \
+ script, \
+ ranges, \
+ std_char1, \
+ std_char2, \
+ std_char3 \
};
-#else
-
-#define AF_DECLARE_SCRIPT_CLASS(script_class) \
- FT_LOCAL(void) \
- FT_Init_Class_##script_class(AF_ScriptClassRec* ac);
-
-#define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
- m_init, m_scale, m_done, h_init, h_apply) \
- FT_LOCAL_DEF(void) \
- FT_Init_Class_##script_class(AF_ScriptClassRec* ac) \
- { \
- ac->script = script_; \
- ac->script_uni_ranges = ranges; \
- \
- ac->script_metrics_size = m_size; \
- \
- ac->script_metrics_init = m_init; \
- ac->script_metrics_scale = m_scale; \
- ac->script_metrics_done = m_done; \
- \
- ac->script_hints_init = h_init; \
- ac->script_hints_apply = h_apply; \
+
+#define AF_DECLARE_STYLE_CLASS( style_class ) \
+ FT_CALLBACK_TABLE const AF_StyleClassRec \
+ style_class;
+
+#define AF_DEFINE_STYLE_CLASS( \
+ style_class, \
+ style, \
+ writing_system, \
+ script, \
+ blue_stringset, \
+ coverage ) \
+ FT_CALLBACK_TABLE_DEF \
+ const AF_StyleClassRec style_class = \
+ { \
+ style, \
+ writing_system, \
+ script, \
+ blue_stringset, \
+ coverage \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
+ FT_LOCAL( void ) \
+ FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac );
+
+#define AF_DEFINE_WRITING_SYSTEM_CLASS( \
+ writing_system_class, \
+ system, \
+ m_size, \
+ m_init, \
+ m_scale, \
+ m_done, \
+ h_init, \
+ h_apply ) \
+ FT_LOCAL_DEF( void ) \
+ FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ) \
+ { \
+ ac->writing_system = system; \
+ \
+ 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_hints_init = h_init; \
+ ac->style_hints_apply = h_apply; \
+ }
+
+
+#define AF_DECLARE_SCRIPT_CLASS( script_class ) \
+ FT_LOCAL( void ) \
+ FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac );
+
+#define AF_DEFINE_SCRIPT_CLASS( \
+ script_class, \
+ script_, \
+ ranges, \
+ std_char1, \
+ std_char2, \
+ std_char3 ) \
+ FT_LOCAL_DEF( void ) \
+ FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
+ { \
+ ac->script = script_; \
+ ac->script_uni_ranges = ranges; \
+ ac->standard_char1 = std_char1; \
+ ac->standard_char2 = std_char2; \
+ ac->standard_char3 = std_char3; \
}
-#endif
+
+
+#define AF_DECLARE_STYLE_CLASS( style_class ) \
+ FT_LOCAL( void ) \
+ FT_Init_Class_ ## style_class( AF_StyleClassRec* ac );
+
+#define AF_DEFINE_STYLE_CLASS( \
+ style_class, \
+ style_, \
+ writing_system_, \
+ script_, \
+ blue_stringset_, \
+ coverage_ ) \
+ FT_LOCAL_DEF( void ) \
+ FT_Init_Class_ ## style_class( AF_StyleClassRec* ac ) \
+ { \
+ ac->style = style_; \
+ ac->writing_system = writing_system_; \
+ ac->script = script_; \
+ ac->blue_stringset = blue_stringset_; \
+ ac->coverage = coverage_; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
/* */
diff --git a/src/3rdparty/freetype/src/autofit/afwarp.c b/src/3rdparty/freetype/src/autofit/afwarp.c
index f5bb9b18ad..34a97ffc57 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, 2007 by */
+/* Copyright 2006, 2007, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,10 +16,30 @@
/***************************************************************************/
+ /*
+ * The idea of the warping code is to slightly scale and shift a glyph
+ * within a single dimension so that as much of its segments are aligned
+ * (more or less) on the grid. To find out the optimal scaling and
+ * shifting value, various parameter combinations are tried and scored.
+ */
+
#include "afwarp.h"
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
+
+ /*************************************************************************/
+ /* */
+ /* 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_afwarp
+
+ /* The weights cover the range 0/64 - 63/64 of a pixel. Obviously, */
+ /* values around a half pixel (which means exactly between two grid */
+ /* lines) gets the worst weight. */
#if 1
static const AF_WarpScore
af_warper_weights[64] =
@@ -43,6 +63,11 @@
#endif
+ /* Score segments for a given `scale' and `delta' in the range */
+ /* `xx1' to `xx2', and store the best result in `warper'. If */
+ /* the new best score is equal to the old one, prefer the */
+ /* value with a smaller distortion (around `base_distort'). */
+
static void
af_warper_compute_line_best( AF_Warper warper,
FT_Fixed scale,
@@ -82,12 +107,12 @@
if ( idx_min < 0 || idx_min > idx_max || idx_max > 64 )
{
- AF_LOG(( "invalid indices:\n"
- " min=%d max=%d, xx1=%ld xx2=%ld,\n"
- " x1min=%ld x1max=%ld, x2min=%ld x2max=%ld\n",
- idx_min, idx_max, xx1, xx2,
- warper->x1min, warper->x1max,
- warper->x2min, warper->x2max ));
+ FT_TRACE5(( "invalid indices:\n"
+ " min=%d max=%d, xx1=%ld xx2=%ld,\n"
+ " x1min=%ld x1max=%ld, x2min=%ld x2max=%ld\n",
+ idx_min, idx_max, xx1, xx2,
+ warper->x1min, warper->x1max,
+ warper->x2min, warper->x2max ));
return;
}
}
@@ -100,6 +125,7 @@
FT_Int idx;
+ /* score the length of the segments for the given range */
for ( idx = idx_min; idx <= idx_max; idx++, y++ )
scores[idx] += af_warper_weights[y & 63] * len;
}
@@ -115,9 +141,9 @@
AF_WarpScore distort = base_distort + ( idx - idx0 );
- if ( score > warper->best_score ||
+ if ( score > warper->best_score ||
( score == warper->best_score &&
- distort < warper->best_distort ) )
+ distort < warper->best_distort ) )
{
warper->best_score = score;
warper->best_distort = distort;
@@ -129,6 +155,9 @@
}
+ /* Compute optimal scaling and delta values for a given glyph and */
+ /* dimension. */
+
FT_LOCAL_DEF( void )
af_warper_compute( AF_Warper warper,
AF_GlyphHints hints,
@@ -215,6 +244,7 @@
warper->t1 = AF_WARPER_FLOOR( warper->x1 );
warper->t2 = AF_WARPER_CEIL( warper->x2 );
+ /* examine a half pixel wide range around the maximum coordinates */
warper->x1min = warper->x1 & ~31;
warper->x1max = warper->x1min + 32;
warper->x2min = warper->x2 & ~31;
@@ -234,10 +264,12 @@
warper->x2min = warper->x2;
}
+ /* examine (at most) a pixel wide range around the natural width */
warper->wmin = warper->x2min - warper->x1max;
warper->wmax = warper->x2max - warper->x1min;
#if 1
+ /* some heuristics to reduce the number of widths to be examined */
{
int margin = 16;
@@ -273,6 +305,8 @@
FT_Pos xx1, xx2;
+ /* compute min and max positions for given width, */
+ /* assuring that they stay within the coordinate ranges */
xx1 = warper->x1;
xx2 = warper->x2;
if ( w >= warper->w0 )
@@ -304,6 +338,7 @@
else
base_distort += xx2 - warper->x2;
+ /* give base distortion a greater weight while scoring */
base_distort *= 10;
new_scale = org_scale + FT_DivFix( w - warper->w0, X2 - X1 );
@@ -317,7 +352,7 @@
{
FT_Fixed best_scale = warper->best_scale;
FT_Pos best_delta = warper->best_delta;
-
+
hints->xmin_delta = FT_MulFix( X1, best_scale - org_scale )
+ best_delta;
@@ -329,10 +364,11 @@
}
}
-#else /* !AF_USE_WARPER */
+#else /* !AF_CONFIG_OPTION_USE_WARPER */
-char af_warper_dummy = 0; /* make compiler happy */
+ /* ANSI C doesn't like empty source files */
+ typedef int _af_warp_dummy;
-#endif /* !AF_USE_WARPER */
+#endif /* !AF_CONFIG_OPTION_USE_WARPER */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afwrtsys.h b/src/3rdparty/freetype/src/autofit/afwrtsys.h
new file mode 100644
index 0000000000..8aa2ed9e6b
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afwrtsys.h
@@ -0,0 +1,52 @@
+/***************************************************************************/
+/* */
+/* afwrtsys.h */
+/* */
+/* Auto-fitter writing systems (specification only). */
+/* */
+/* Copyright 2013 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 __AFWRTSYS_H__
+#define __AFWRTSYS_H__
+
+ /* Since preprocessor directives can't create other preprocessor */
+ /* directives, we have to include the header files manually. */
+
+#include "afdummy.h"
+#include "aflatin.h"
+#include "afcjk.h"
+#include "afindic.h"
+#ifdef FT_OPTION_AUTOFIT2
+#include "aflatin2.h"
+#endif
+
+#endif /* __AFWRTSYS_H__ */
+
+
+ /* The following part can be included multiple times. */
+ /* Define `WRITING_SYSTEM' as needed. */
+
+
+ /* Add new writing systems here. The arguments are the writing system */
+ /* name in lowercase and uppercase, respectively. */
+
+ WRITING_SYSTEM( dummy, DUMMY )
+ WRITING_SYSTEM( latin, LATIN )
+ WRITING_SYSTEM( cjk, CJK )
+ WRITING_SYSTEM( indic, INDIC )
+#ifdef FT_OPTION_AUTOFIT2
+ WRITING_SYSTEM( latin2, LATIN2 )
+#endif
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/autofit.c b/src/3rdparty/freetype/src/autofit/autofit.c
index 83b613e79b..e2b9934e4b 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, 2004, 2005, 2006, 2007 by */
+/* Copyright 2003-2007, 2011, 2013 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 <ft2build.h>
#include "afpic.c"
#include "afangles.c"
+#include "afblue.c"
#include "afglobal.c"
#include "afhints.c"
+#include "afranges.c"
+
#include "afdummy.c"
#include "aflatin.c"
#ifdef FT_OPTION_AUTOFIT2
@@ -31,10 +34,12 @@
#include "afcjk.c"
#include "afindic.c"
+#include "hbshim.c"
+
#include "afloader.c"
#include "afmodule.c"
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
#include "afwarp.c"
#endif
diff --git a/src/3rdparty/freetype/src/autofit/hbshim.c b/src/3rdparty/freetype/src/autofit/hbshim.c
new file mode 100644
index 0000000000..a705cef000
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/hbshim.c
@@ -0,0 +1,545 @@
+/***************************************************************************/
+/* */
+/* hbshim.c */
+/* */
+/* HarfBuzz interface for accessing OpenType features (body). */
+/* */
+/* Copyright 2013, 2014 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 "afglobal.h"
+#include "aftypes.h"
+#include "hbshim.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_afharfbuzz
+
+
+ /*
+ * 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, sc1, sc2, sc3 ) h,
+
+
+ static const hb_script_t scripts[] =
+ {
+#include "afscript.h"
+ };
+
+
+ FT_Error
+ af_get_coverage( AF_FaceGlobals globals,
+ AF_StyleClass style_class,
+ FT_Byte* gstyles )
+ {
+ hb_face_t* face;
+
+ hb_set_t* gsub_lookups; /* GSUB lookups for a given script */
+ hb_set_t* gsub_glyphs; /* glyphs covered by GSUB lookups */
+ hb_set_t* gpos_lookups; /* GPOS lookups for a given script */
+ hb_set_t* gpos_glyphs; /* 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 );
+
+ gsub_lookups = hb_set_create();
+ gsub_glyphs = hb_set_create();
+ gpos_lookups = hb_set_create();
+ gpos_glyphs = hb_set_create();
+
+ 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 ( style_class->script == globals->module->default_script &&
+ style_class->coverage == AF_COVERAGE_DEFAULT )
+ {
+ 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
+ {
+ if ( script_tags[1] == HB_OT_TAG_DEFAULT_SCRIPT )
+ script_tags[1] = HB_TAG_NONE;
+ }
+
+ 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 */
+
+ hb_ot_layout_collect_lookups( face,
+ HB_OT_TAG_GPOS,
+ script_tags,
+ NULL,
+ coverage_tags,
+ gpos_lookups );
+
+ FT_TRACE4(( "GSUB lookups (style `%s'):\n"
+ " ",
+ af_style_names[style_class->style] ));
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ count = 0;
+#endif
+
+ for ( idx = -1; 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] ));
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ count = 0;
+#endif
+
+ for ( idx = -1; 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 = -1; 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 = -1; 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_Byte)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 */
+ };
+
+
+ FT_Error
+ af_get_char_index( AF_StyleMetrics metrics,
+ FT_ULong charcode,
+ FT_ULong *codepoint,
+ FT_Long *y_offset )
+ {
+ AF_StyleClass style_class;
+
+ const hb_feature_t* feature;
+
+ FT_ULong in_idx, out_idx;
+
+
+ if ( !metrics )
+ return FT_THROW( Invalid_Argument );
+
+ in_idx = FT_Get_Char_Index( metrics->globals->face, charcode );
+
+ style_class = metrics->style_class;
+
+ feature = features[style_class->coverage];
+
+ if ( feature )
+ {
+ FT_UInt upem = metrics->globals->face->units_per_EM;
+
+ hb_font_t* font = metrics->globals->hb_font;
+ hb_buffer_t* buf = hb_buffer_create();
+
+ uint32_t c = (uint32_t)charcode;
+
+ hb_glyph_info_t* ginfo;
+ hb_glyph_position_t* gpos;
+ unsigned int gcount;
+
+
+ /* we shape at a size of units per EM; this means font units */
+ hb_font_set_scale( font, upem, upem );
+
+ /* XXX: is this sufficient for a single character of any script? */
+ hb_buffer_set_direction( buf, HB_DIRECTION_LTR );
+ hb_buffer_set_script( buf, scripts[style_class->script] );
+
+ /* we add one character to `buf' ... */
+ hb_buffer_add_utf32( buf, &c, 1, 0, 1 );
+
+ /* ... and apply one feature */
+ hb_shape( font, buf, feature, 1 );
+
+ ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
+ gpos = hb_buffer_get_glyph_positions( buf, &gcount );
+
+ out_idx = ginfo[0].codepoint;
+
+ /* getting the same index indicates no substitution, */
+ /* which means that the glyph isn't available in the feature */
+ if ( in_idx == out_idx )
+ {
+ *codepoint = 0;
+ *y_offset = 0;
+ }
+ else
+ {
+ *codepoint = out_idx;
+ *y_offset = gpos[0].y_offset;
+ }
+
+ hb_buffer_destroy( buf );
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( gcount > 1 )
+ FT_TRACE1(( "af_get_char_index:"
+ " input character mapped to multiple glyphs\n" ));
+#endif
+ }
+ else
+ {
+ *codepoint = in_idx;
+ *y_offset = 0;
+ }
+
+ return FT_Err_Ok;
+ }
+
+
+#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
+
+
+ FT_Error
+ af_get_coverage( AF_FaceGlobals globals,
+ AF_StyleClass style_class,
+ FT_Byte* gstyles )
+ {
+ FT_UNUSED( globals );
+ FT_UNUSED( style_class );
+ FT_UNUSED( gstyles );
+
+ return FT_Err_Ok;
+ }
+
+
+ FT_Error
+ af_get_char_index( AF_StyleMetrics metrics,
+ FT_ULong charcode,
+ FT_ULong *codepoint,
+ FT_Long *y_offset )
+ {
+ FT_Face face;
+
+
+ if ( !metrics )
+ return FT_THROW( Invalid_Argument );
+
+ face = metrics->globals->face;
+
+ *codepoint = FT_Get_Char_Index( face, charcode );
+ *y_offset = 0;
+
+ return FT_Err_Ok;
+ }
+
+
+#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/hbshim.h b/src/3rdparty/freetype/src/autofit/hbshim.h
new file mode 100644
index 0000000000..02f1513f67
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/hbshim.h
@@ -0,0 +1,56 @@
+/***************************************************************************/
+/* */
+/* hbshim.h */
+/* */
+/* HarfBuzz interface for accessing OpenType features (specification). */
+/* */
+/* Copyright 2013 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 __HBSHIM_H__
+#define __HBSHIM_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_get_coverage( AF_FaceGlobals globals,
+ AF_StyleClass style_class,
+ FT_Byte* gstyles );
+
+ FT_Error
+ af_get_char_index( AF_StyleMetrics metrics,
+ FT_ULong charcode,
+ FT_ULong *codepoint,
+ FT_Long *y_offset );
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __HBSHIM_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/rules.mk b/src/3rdparty/freetype/src/autofit/rules.mk
index 017489d9e0..658f04ea59 100644
--- a/src/3rdparty/freetype/src/autofit/rules.mk
+++ b/src/3rdparty/freetype/src/autofit/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2003, 2004, 2005, 2006, 2007 by
+# Copyright 2003-2007, 2011, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -26,6 +26,7 @@ AUTOF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(AUTOF_DIR))
# AUTOF driver sources (i.e., C files)
#
AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
+ $(AUTOF_DIR)/afblue.c \
$(AUTOF_DIR)/afcjk.c \
$(AUTOF_DIR)/afdummy.c \
$(AUTOF_DIR)/afglobal.c \
@@ -34,13 +35,20 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
$(AUTOF_DIR)/aflatin.c \
$(AUTOF_DIR)/afloader.c \
$(AUTOF_DIR)/afmodule.c \
- $(AUTOF_DIR)/afwarp.c
+ $(AUTOF_DIR)/afpic.c \
+ $(AUTOF_DIR)/afranges.c \
+ $(AUTOF_DIR)/afwarp.c \
+ $(AUTOF_DIR)/hbshim.c
# AUTOF driver headers
#
AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \
+ $(AUTOF_DIR)/afcover.h \
+ $(AUTOF_DIR)/aferrors.h \
+ $(AUTOF_DIR)/afscript.h \
+ $(AUTOF_DIR)/afstyles.h \
$(AUTOF_DIR)/aftypes.h \
- $(AUTOF_DIR)/aferrors.h
+ $(AUTOF_DIR)/afwrtsys.h
# AUTOF driver object(s)
diff --git a/src/3rdparty/freetype/src/base/basepic.c b/src/3rdparty/freetype/src/base/basepic.c
index c0bccb6959..aeb6fd5777 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 by */
+/* Copyright 2009, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,24 +21,42 @@
#include FT_INTERNAL_OBJECTS_H
#include "basepic.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftglyph.c */
- void FT_Init_Class_ft_outline_glyph_class(FT_Glyph_Class*);
- void FT_Init_Class_ft_bitmap_glyph_class(FT_Glyph_Class*);
+ void
+ FT_Init_Class_ft_outline_glyph_class( FT_Glyph_Class* clazz );
+
+ void
+ FT_Init_Class_ft_bitmap_glyph_class( FT_Glyph_Class* clazz );
+
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
+ /* forward declaration of PIC init function from ftrfork.c */
+ /* (not modularized) */
+ void
+ FT_Init_Table_ft_raccess_guess_table( ft_raccess_guess_rec* record );
+#endif
/* forward declaration of PIC init functions from ftinit.c */
- FT_Error ft_create_default_module_classes(FT_Library);
- void ft_destroy_default_module_classes(FT_Library);
+ FT_Error
+ ft_create_default_module_classes( FT_Library library );
+
+ void
+ ft_destroy_default_module_classes( FT_Library library );
+
void
- ft_base_pic_free( FT_Library library )
+ ft_base_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->base )
{
- /* Destroy default module classes (in case FT_Add_Default_Modules was used) */
+ /* destroy default module classes */
+ /* (in case FT_Add_Default_Modules was used) */
ft_destroy_default_module_classes( library );
FT_FREE( pic_container->base );
@@ -48,17 +66,18 @@
FT_Error
- ft_base_pic_init( FT_Library library )
+ ft_base_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- BasePIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ BasePIC* container = NULL;
+ FT_Memory memory = library->memory;
+
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->base = container;
/* initialize default modules list and pointers */
@@ -66,17 +85,23 @@
if ( error )
goto Exit;
- /* initialize pointer table - this is how the module usually expects this data */
- FT_Init_Class_ft_outline_glyph_class(&container->ft_outline_glyph_class);
- FT_Init_Class_ft_bitmap_glyph_class(&container->ft_bitmap_glyph_class);
-
-Exit:
- if(error)
- ft_base_pic_free(library);
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ FT_Init_Class_ft_outline_glyph_class(
+ &container->ft_outline_glyph_class );
+ FT_Init_Class_ft_bitmap_glyph_class(
+ &container->ft_bitmap_glyph_class );
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
+ FT_Init_Table_ft_raccess_guess_table(
+ (ft_raccess_guess_rec*)&container->ft_raccess_guess_table );
+#endif
+
+ Exit:
+ if ( error )
+ ft_base_pic_free( library );
return error;
}
-
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/base/basepic.h b/src/3rdparty/freetype/src/base/basepic.h
index bb17745769..329d7c8fd6 100644
--- a/src/3rdparty/freetype/src/base/basepic.h
+++ b/src/3rdparty/freetype/src/base/basepic.h
@@ -19,40 +19,68 @@
#ifndef __BASEPIC_H__
#define __BASEPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class
-#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class
-#define FT_DEFAULT_MODULES_GET ft_default_modules
+
+#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class
+#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class
+#define FT_DEFAULT_MODULES_GET ft_default_modules
+
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#define FT_RACCESS_GUESS_TABLE_GET ft_raccess_guess_table
+#endif
#else /* FT_CONFIG_OPTION_PIC */
#include FT_GLYPH_H
- typedef struct BasePIC_
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#include FT_INTERNAL_RFORK_H
+#endif
+
+
+ typedef struct BasePIC_
{
- FT_Module_Class** default_module_classes;
- FT_Glyph_Class ft_outline_glyph_class;
- FT_Glyph_Class ft_bitmap_glyph_class;
+ FT_Module_Class** default_module_classes;
+ FT_Glyph_Class ft_outline_glyph_class;
+ FT_Glyph_Class ft_bitmap_glyph_class;
+
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+ ft_raccess_guess_rec ft_raccess_guess_table[FT_RACCESS_N_RULES];
+#endif
+
} BasePIC;
-#define GET_PIC(lib) ((BasePIC*)((lib)->pic_container.base))
-#define FT_OUTLINE_GLYPH_CLASS_GET (&GET_PIC(library)->ft_outline_glyph_class)
-#define FT_BITMAP_GLYPH_CLASS_GET (&GET_PIC(library)->ft_bitmap_glyph_class)
-#define FT_DEFAULT_MODULES_GET (GET_PIC(library)->default_module_classes)
+#define GET_PIC( lib ) ( (BasePIC*)( (lib)->pic_container.base ) )
+
+#define FT_OUTLINE_GLYPH_CLASS_GET \
+ ( &GET_PIC( library )->ft_outline_glyph_class )
+#define FT_BITMAP_GLYPH_CLASS_GET \
+ ( &GET_PIC( library )->ft_bitmap_glyph_class )
+#define FT_DEFAULT_MODULES_GET \
+ ( GET_PIC( library )->default_module_classes )
+
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#define FT_RACCESS_GUESS_TABLE_GET \
+ ( GET_PIC( library )->ft_raccess_guess_table )
+#endif
+
+
+ /* see basepic.c for the implementation */
void
- ft_base_pic_free( FT_Library library );
+ ft_base_pic_free( FT_Library library );
FT_Error
- ft_base_pic_init( FT_Library library );
+ ft_base_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
- /* */
+
+ /* */
FT_END_HEADER
diff --git a/src/3rdparty/freetype/src/base/ftadvanc.c b/src/3rdparty/freetype/src/base/ftadvanc.c
index 8ab7fcb927..18884efe19 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, 2009 by */
+/* Copyright 2008, 2009, 2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_ADVANCES_H
#include FT_INTERNAL_OBJECTS_H
@@ -35,7 +37,7 @@
return FT_Err_Ok;
if ( face->size == NULL )
- return FT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Size_Handle );
if ( flags & FT_LOAD_VERTICAL_LAYOUT )
scale = face->size->metrics.y_scale;
@@ -76,10 +78,13 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !padvance )
+ return FT_THROW( Invalid_Argument );
if ( gindex >= (FT_UInt)face->num_glyphs )
- return FT_Err_Invalid_Glyph_Index;
+ return FT_THROW( Invalid_Glyph_Index );
func = face->driver->clazz->get_advances;
if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) )
@@ -91,7 +96,7 @@
if ( !error )
return _ft_face_scale_advances( face, padvance, 1, flags );
- if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) )
+ if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;
}
@@ -114,12 +119,15 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !padvances )
+ return FT_THROW( Invalid_Argument );
num = (FT_UInt)face->num_glyphs;
end = start + count;
if ( start >= num || end < start || end > num )
- return FT_Err_Invalid_Glyph_Index;
+ return FT_THROW( Invalid_Glyph_Index );
if ( count == 0 )
return FT_Err_Ok;
@@ -129,16 +137,16 @@
{
error = func( face, start, count, flags, padvances );
if ( !error )
- goto Exit;
+ return _ft_face_scale_advances( face, padvances, count, flags );
- if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) )
+ if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;
}
error = FT_Err_Ok;
if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
for ( nn = 0; nn < count; nn++ )
@@ -147,16 +155,13 @@
if ( error )
break;
+ /* scale from 26.6 to 16.16 */
padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
- ? face->glyph->advance.y
- : face->glyph->advance.x;
+ ? face->glyph->advance.y << 10
+ : face->glyph->advance.x << 10;
}
- if ( error )
- return error;
-
- Exit:
- return _ft_face_scale_advances( face, padvances, count, flags );
+ return error;
}
diff --git a/src/3rdparty/freetype/src/base/ftbase.c b/src/3rdparty/freetype/src/base/ftbase.c
index 6a27ea95a6..5e5d70ec4b 100644
--- a/src/3rdparty/freetype/src/base/ftbase.c
+++ b/src/3rdparty/freetype/src/base/ftbase.c
@@ -34,7 +34,7 @@
#include "fttrigon.c"
#include "ftutil.c"
-#if defined( FT_MACINTOSH ) && !defined ( DARWIN_NO_CARBON )
+#ifdef FT_MACINTOSH
#include "ftmac.c"
#endif
diff --git a/src/3rdparty/freetype/src/base/ftbase.h b/src/3rdparty/freetype/src/base/ftbase.h
index 1dc49f3bdf..51a1db18b8 100644
--- a/src/3rdparty/freetype/src/base/ftbase.h
+++ b/src/3rdparty/freetype/src/base/ftbase.h
@@ -49,6 +49,18 @@ FT_BEGIN_HEADER
FT_Face *aface );
+#if defined( FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK ) && \
+ !defined( FT_MACINTOSH )
+ /* Mac OS X/Darwin kernel often changes recommended method to access */
+ /* the resource fork and older methods makes the kernel issue the */
+ /* warning of deprecated method. To calm it down, the methods based */
+ /* on Darwin VFS should be grouped and skip the rest methods after */
+ /* the case the resource is opened but found to lack a font in it. */
+ FT_LOCAL( FT_Bool )
+ ft_raccess_rule_by_darwin_vfs( FT_Library library, FT_UInt rule_index );
+#endif
+
+
FT_END_HEADER
#endif /* __FTBASE_H__ */
diff --git a/src/3rdparty/freetype/src/base/ftbbox.c b/src/3rdparty/freetype/src/base/ftbbox.c
index 4b8e9112fe..f9a17517ec 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-2001, 2002, 2004, 2006, 2010 by */
+/* Copyright 1996-2002, 2004, 2006, 2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -25,6 +25,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_BBOX_H
#include FT_IMAGE_H
#include FT_OUTLINE_H
@@ -40,16 +42,35 @@
} TBBox_Rec;
+#define FT_UPDATE_BBOX( p, bbox ) \
+ FT_BEGIN_STMNT \
+ if ( p->x < bbox.xMin ) \
+ bbox.xMin = p->x; \
+ if ( p->x > bbox.xMax ) \
+ bbox.xMax = p->x; \
+ if ( p->y < bbox.yMin ) \
+ bbox.yMin = p->y; \
+ if ( p->y > bbox.yMax ) \
+ bbox.yMax = p->y; \
+ FT_END_STMNT
+
+#define CHECK_X( p, bbox ) \
+ ( p->x < bbox.xMin || p->x > bbox.xMax )
+
+#define CHECK_Y( p, bbox ) \
+ ( p->y < bbox.yMin || p->y > bbox.yMax )
+
+
/*************************************************************************/
/* */
/* <Function> */
/* BBox_Move_To */
/* */
/* <Description> */
- /* This function is used as a `move_to' and `line_to' emitter during */
+ /* This function is used as a `move_to' emitter during */
/* FT_Outline_Decompose(). It simply records the destination point */
- /* in `user->last'; no further computations are necessary since we */
- /* use the cbox as the starting bbox which must be refined. */
+ /* in `user->last'. We also update bbox in case contour starts with */
+ /* an implicit `on' point. */
/* */
/* <Input> */
/* to :: A pointer to the destination vector. */
@@ -64,17 +85,42 @@
BBox_Move_To( FT_Vector* to,
TBBox_Rec* user )
{
+ FT_UPDATE_BBOX( to, user->bbox );
+
user->last = *to;
return 0;
}
-#define CHECK_X( p, bbox ) \
- ( p->x < bbox.xMin || p->x > bbox.xMax )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* BBox_Line_To */
+ /* */
+ /* <Description> */
+ /* This function is used as a `line_to' emitter during */
+ /* FT_Outline_Decompose(). It simply records the destination point */
+ /* in `user->last'; no further computations are necessary because */
+ /* bbox already contains both explicit ends of the line segment. */
+ /* */
+ /* <Input> */
+ /* to :: A pointer to the destination vector. */
+ /* */
+ /* <InOut> */
+ /* user :: A pointer to the current walk context. */
+ /* */
+ /* <Return> */
+ /* Always 0. Needed for the interface only. */
+ /* */
+ static int
+ BBox_Line_To( FT_Vector* to,
+ TBBox_Rec* user )
+ {
+ user->last = *to;
-#define CHECK_Y( p, bbox ) \
- ( p->y < bbox.yMin || p->y > bbox.yMax )
+ return 0;
+ }
/*************************************************************************/
@@ -83,7 +129,7 @@
/* BBox_Conic_Check */
/* */
/* <Description> */
- /* Finds the extrema of a 1-dimensional conic Bezier curve and update */
+ /* Find the extrema of a 1-dimensional conic Bezier curve and update */
/* a bounding range. This version uses direct computation, as it */
/* doesn't need square roots. */
/* */
@@ -106,30 +152,19 @@
FT_Pos* min,
FT_Pos* max )
{
- if ( y1 <= y3 && y2 == y1 ) /* flat arc */
- goto Suite;
-
- if ( y1 < y3 )
- {
- if ( y2 >= y1 && y2 <= y3 ) /* ascending arc */
- goto Suite;
- }
- else
- {
- if ( y2 >= y3 && y2 <= y1 ) /* descending arc */
- {
- y2 = y1;
- y1 = y3;
- y3 = y2;
- goto Suite;
- }
- }
-
- y1 = y3 = y1 - FT_MulDiv( y2 - y1, y2 - y1, y1 - 2*y2 + y3 );
-
- Suite:
- if ( y1 < *min ) *min = y1;
- if ( y3 > *max ) *max = y3;
+ /* This function is only called when a control off-point is outside */
+ /* the bbox that contains all on-points. It finds a local extremum */
+ /* within the segment, equal to (y1*y3 - y2*y2)/(y1 - 2*y2 + y3). */
+ /* Or, offsetting from y2, we get */
+
+ y1 -= y2;
+ y3 -= y2;
+ y2 += FT_MulDiv( y1, y3, y1 + y3 );
+
+ if ( y2 < *min )
+ *min = y2;
+ if ( y2 > *max )
+ *max = y2;
}
@@ -164,8 +199,8 @@
FT_Vector* to,
TBBox_Rec* user )
{
- /* we don't need to check `to' since it is always an `on' point, thus */
- /* within the bbox */
+ /* in case `to' is implicit and not included in bbox yet */
+ FT_UPDATE_BBOX( to, user->bbox );
if ( CHECK_X( control, user->bbox ) )
BBox_Conic_Check( user->last.x,
@@ -193,9 +228,9 @@
/* BBox_Cubic_Check */
/* */
/* <Description> */
- /* Finds the extrema of a 1-dimensional cubic Bezier curve and */
- /* updates a bounding range. This version uses splitting because we */
- /* don't want to use square roots and extra accuracy. */
+ /* Find the extrema of a 1-dimensional cubic Bezier curve and */
+ /* update a bounding range. This version uses iterative splitting */
+ /* because it is faster than the exact solution with square roots. */
/* */
/* <Input> */
/* p1 :: The start coordinate. */
@@ -211,294 +246,117 @@
/* */
/* max :: The address of the current maximum. */
/* */
-
-#if 0
-
- static void
- BBox_Cubic_Check( FT_Pos p1,
- FT_Pos p2,
- FT_Pos p3,
- FT_Pos p4,
- FT_Pos* min,
- FT_Pos* max )
+ static FT_Pos
+ cubic_peak( FT_Pos q1,
+ FT_Pos q2,
+ FT_Pos q3,
+ FT_Pos q4 )
{
- FT_Pos stack[32*3 + 1], *arc;
-
-
- arc = stack;
-
- arc[0] = p1;
- arc[1] = p2;
- arc[2] = p3;
- arc[3] = p4;
-
- do
+ FT_Pos peak = 0;
+ FT_Int shift;
+
+ /* This function finds a peak of a cubic segment if it is above 0 */
+ /* using iterative bisection of the segment, or returns 0. */
+ /* The fixed-point arithmetic of bisection is inherently stable */
+ /* but may loose accuracy in the two lowest bits. To compensate, */
+ /* we upscale the segment if there is room. Large values may need */
+ /* to be downscaled to avoid overflows during bisection. */
+ /* It is called with either q2 or q3 positive, which is necessary */
+ /* for the peak to exist and avoids undefined FT_MSB. */
+
+ shift = 27 -
+ FT_MSB( FT_ABS( q1 ) | FT_ABS( q2 ) | FT_ABS( q3 ) | FT_ABS( q4 ) );
+
+ if ( shift > 0 )
{
- FT_Pos y1 = arc[0];
- FT_Pos y2 = arc[1];
- FT_Pos y3 = arc[2];
- FT_Pos y4 = arc[3];
-
+ /* upscaling too much just wastes time */
+ if ( shift > 2 )
+ shift = 2;
+
+ q1 <<= shift;
+ q2 <<= shift;
+ q3 <<= shift;
+ q4 <<= shift;
+ }
+ else
+ {
+ q1 >>= -shift;
+ q2 >>= -shift;
+ q3 >>= -shift;
+ q4 >>= -shift;
+ }
- if ( y1 == y4 )
+ /* for a peak to exist above 0, the cubic segment must have */
+ /* at least one of its control off-points above 0. */
+ while ( q2 > 0 || q3 > 0 )
+ {
+ /* determine which half contains the maximum and split */
+ if ( q1 + q2 > q3 + q4 ) /* first half */
{
- if ( y1 == y2 && y1 == y3 ) /* flat */
- goto Test;
+ q4 = q4 + q3;
+ q3 = q3 + q2;
+ q2 = q2 + q1;
+ q4 = q4 + q3;
+ q3 = q3 + q2;
+ q4 = ( q4 + q3 ) / 8;
+ q3 = q3 / 4;
+ q2 = q2 / 2;
}
- else if ( y1 < y4 )
+ else /* second half */
{
- if ( y2 >= y1 && y2 <= y4 && y3 >= y1 && y3 <= y4 ) /* ascending */
- goto Test;
+ q1 = q1 + q2;
+ q2 = q2 + q3;
+ q3 = q3 + q4;
+ q1 = q1 + q2;
+ q2 = q2 + q3;
+ q1 = ( q1 + q2 ) / 8;
+ q2 = q2 / 4;
+ q3 = q3 / 2;
}
- else
+
+ /* check whether either end reached the maximum */
+ if ( q1 == q2 && q1 >= q3 )
{
- if ( y2 >= y4 && y2 <= y1 && y3 >= y4 && y3 <= y1 ) /* descending */
- {
- y2 = y1;
- y1 = y4;
- y4 = y2;
- goto Test;
- }
+ peak = q1;
+ break;
}
+ if ( q3 == q4 && q2 <= q4 )
+ {
+ peak = q4;
+ break;
+ }
+ }
- /* unknown direction -- split the arc in two */
- arc[6] = y4;
- arc[1] = y1 = ( y1 + y2 ) / 2;
- arc[5] = y4 = ( y4 + y3 ) / 2;
- y2 = ( y2 + y3 ) / 2;
- arc[2] = y1 = ( y1 + y2 ) / 2;
- arc[4] = y4 = ( y4 + y2 ) / 2;
- arc[3] = ( y1 + y4 ) / 2;
-
- arc += 3;
- goto Suite;
-
- Test:
- if ( y1 < *min ) *min = y1;
- if ( y4 > *max ) *max = y4;
- arc -= 3;
-
- Suite:
- ;
- } while ( arc >= stack );
- }
-
-#else
-
- static void
- test_cubic_extrema( FT_Pos y1,
- FT_Pos y2,
- FT_Pos y3,
- FT_Pos y4,
- FT_Fixed u,
- FT_Pos* min,
- FT_Pos* max )
- {
- /* FT_Pos a = y4 - 3*y3 + 3*y2 - y1; */
- FT_Pos b = y3 - 2*y2 + y1;
- FT_Pos c = y2 - y1;
- FT_Pos d = y1;
- FT_Pos y;
- FT_Fixed uu;
-
- FT_UNUSED ( y4 );
-
-
- /* The polynomial is */
- /* */
- /* P(x) = a*x^3 + 3b*x^2 + 3c*x + d , */
- /* */
- /* dP/dx = 3a*x^2 + 6b*x + 3c . */
- /* */
- /* However, we also have */
- /* */
- /* dP/dx(u) = 0 , */
- /* */
- /* which implies by subtraction that */
- /* */
- /* P(u) = b*u^2 + 2c*u + d . */
-
- if ( u > 0 && u < 0x10000L )
- {
- uu = FT_MulFix( u, u );
- y = d + FT_MulFix( c, 2*u ) + FT_MulFix( b, uu );
+ if ( shift > 0 )
+ peak >>= shift;
+ else
+ peak <<= -shift;
- if ( y < *min ) *min = y;
- if ( y > *max ) *max = y;
- }
+ return peak;
}
static void
- BBox_Cubic_Check( FT_Pos y1,
- FT_Pos y2,
- FT_Pos y3,
- FT_Pos y4,
+ BBox_Cubic_Check( FT_Pos p1,
+ FT_Pos p2,
+ FT_Pos p3,
+ FT_Pos p4,
FT_Pos* min,
FT_Pos* max )
{
- /* always compare first and last points */
- if ( y1 < *min ) *min = y1;
- else if ( y1 > *max ) *max = y1;
+ /* This function is only called when a control off-point is outside */
+ /* the bbox that contains all on-points. So at least one of the */
+ /* conditions below holds and cubic_peak is called with at least one */
+ /* non-zero argument. */
- if ( y4 < *min ) *min = y4;
- else if ( y4 > *max ) *max = y4;
+ if ( p2 > *max || p3 > *max )
+ *max += cubic_peak( p1 - *max, p2 - *max, p3 - *max, p4 - *max );
- /* now, try to see if there are split points here */
- if ( y1 <= y4 )
- {
- /* flat or ascending arc test */
- if ( y1 <= y2 && y2 <= y4 && y1 <= y3 && y3 <= y4 )
- return;
- }
- else /* y1 > y4 */
- {
- /* descending arc test */
- if ( y1 >= y2 && y2 >= y4 && y1 >= y3 && y3 >= y4 )
- return;
- }
-
- /* There are some split points. Find them. */
- {
- FT_Pos a = y4 - 3*y3 + 3*y2 - y1;
- FT_Pos b = y3 - 2*y2 + y1;
- FT_Pos c = y2 - y1;
- FT_Pos d;
- FT_Fixed t;
-
-
- /* We need to solve `ax^2+2bx+c' here, without floating points! */
- /* The trick is to normalize to a different representation in order */
- /* to use our 16.16 fixed point routines. */
- /* */
- /* We compute FT_MulFix(b,b) and FT_MulFix(a,c) after normalization. */
- /* These values must fit into a single 16.16 value. */
- /* */
- /* We normalize a, b, and c to `8.16' fixed float values to ensure */
- /* that its product is held in a `16.16' value. */
-
- {
- FT_ULong t1, t2;
- int shift = 0;
-
-
- /* The following computation is based on the fact that for */
- /* any value `y', if `n' is the position of the most */
- /* significant bit of `abs(y)' (starting from 0 for the */
- /* least significant bit), then `y' is in the range */
- /* */
- /* -2^n..2^n-1 */
- /* */
- /* We want to shift `a', `b', and `c' concurrently in order */
- /* to ensure that they all fit in 8.16 values, which maps */
- /* to the integer range `-2^23..2^23-1'. */
- /* */
- /* Necessarily, we need to shift `a', `b', and `c' so that */
- /* the most significant bit of its absolute values is at */
- /* _most_ at position 23. */
- /* */
- /* We begin by computing `t1' as the bitwise `OR' of the */
- /* absolute values of `a', `b', `c'. */
-
- t1 = (FT_ULong)( ( a >= 0 ) ? a : -a );
- t2 = (FT_ULong)( ( b >= 0 ) ? b : -b );
- t1 |= t2;
- t2 = (FT_ULong)( ( c >= 0 ) ? c : -c );
- t1 |= t2;
-
- /* Now we can be sure that the most significant bit of `t1' */
- /* is the most significant bit of either `a', `b', or `c', */
- /* depending on the greatest integer range of the particular */
- /* variable. */
- /* */
- /* Next, we compute the `shift', by shifting `t1' as many */
- /* times as necessary to move its MSB to position 23. This */
- /* corresponds to a value of `t1' that is in the range */
- /* 0x40_0000..0x7F_FFFF. */
- /* */
- /* Finally, we shift `a', `b', and `c' by the same amount. */
- /* This ensures that all values are now in the range */
- /* -2^23..2^23, i.e., they are now expressed as 8.16 */
- /* fixed-float numbers. This also means that we are using */
- /* 24 bits of precision to compute the zeros, independently */
- /* of the range of the original polynomial coefficients. */
- /* */
- /* This algorithm should ensure reasonably accurate values */
- /* for the zeros. Note that they are only expressed with */
- /* 16 bits when computing the extrema (the zeros need to */
- /* be in 0..1 exclusive to be considered part of the arc). */
-
- if ( t1 == 0 ) /* all coefficients are 0! */
- return;
-
- if ( t1 > 0x7FFFFFUL )
- {
- do
- {
- shift++;
- t1 >>= 1;
-
- } while ( t1 > 0x7FFFFFUL );
-
- /* this loses some bits of precision, but we use 24 of them */
- /* for the computation anyway */
- a >>= shift;
- b >>= shift;
- c >>= shift;
- }
- else if ( t1 < 0x400000UL )
- {
- do
- {
- shift++;
- t1 <<= 1;
-
- } while ( t1 < 0x400000UL );
-
- a <<= shift;
- b <<= shift;
- c <<= shift;
- }
- }
-
- /* handle a == 0 */
- if ( a == 0 )
- {
- if ( b != 0 )
- {
- t = - FT_DivFix( c, b ) / 2;
- test_cubic_extrema( y1, y2, y3, y4, t, min, max );
- }
- }
- else
- {
- /* solve the equation now */
- d = FT_MulFix( b, b ) - FT_MulFix( a, c );
- if ( d < 0 )
- return;
-
- if ( d == 0 )
- {
- /* there is a single split point at -b/a */
- t = - FT_DivFix( b, a );
- test_cubic_extrema( y1, y2, y3, y4, t, min, max );
- }
- else
- {
- /* there are two solutions; we need to filter them */
- d = FT_SqrtFixed( (FT_Int32)d );
- t = - FT_DivFix( b - d, a );
- test_cubic_extrema( y1, y2, y3, y4, t, min, max );
-
- t = - FT_DivFix( b + d, a );
- test_cubic_extrema( y1, y2, y3, y4, t, min, max );
- }
- }
- }
+ /* now flip the signs to update the minimum */
+ if ( p2 < *min || p3 < *min )
+ *min -= cubic_peak( *min - p1, *min - p2, *min - p3, *min - p4 );
}
-#endif
-
/*************************************************************************/
/* */
@@ -534,8 +392,9 @@
FT_Vector* to,
TBBox_Rec* user )
{
- /* we don't need to check `to' since it is always an `on' point, thus */
- /* within the bbox */
+ /* We don't need to check `to' since it is always an on-point, */
+ /* thus within the bbox. Only segments with an off-point outside */
+ /* the bbox can possibly reach new extreme values. */
if ( CHECK_X( control1, user->bbox ) ||
CHECK_X( control2, user->bbox ) )
@@ -560,31 +419,35 @@
return 0;
}
-FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
+
+ FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
(FT_Outline_MoveTo_Func) BBox_Move_To,
- (FT_Outline_LineTo_Func) BBox_Move_To,
+ (FT_Outline_LineTo_Func) BBox_Line_To,
(FT_Outline_ConicTo_Func)BBox_Conic_To,
(FT_Outline_CubicTo_Func)BBox_Cubic_To,
0, 0
)
+
/* documentation is in ftbbox.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Get_BBox( FT_Outline* outline,
FT_BBox *abbox )
{
- FT_BBox cbox;
- FT_BBox bbox;
+ FT_BBox cbox = { 0x7FFFFFFFL, 0x7FFFFFFFL,
+ -0x7FFFFFFFL, -0x7FFFFFFFL };
+ FT_BBox bbox = { 0x7FFFFFFFL, 0x7FFFFFFFL,
+ -0x7FFFFFFFL, -0x7FFFFFFFL };
FT_Vector* vec;
FT_UShort n;
if ( !abbox )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( !outline )
- return FT_Err_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
/* if outline is empty, return (0,0,0,0) */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
@@ -599,32 +462,13 @@ FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
/* coincide, we exit immediately. */
vec = outline->points;
- bbox.xMin = bbox.xMax = cbox.xMin = cbox.xMax = vec->x;
- bbox.yMin = bbox.yMax = cbox.yMin = cbox.yMax = vec->y;
- vec++;
- for ( n = 1; n < outline->n_points; n++ )
+ for ( n = 0; n < outline->n_points; n++ )
{
- FT_Pos x = vec->x;
- FT_Pos y = vec->y;
-
-
- /* update control box */
- if ( x < cbox.xMin ) cbox.xMin = x;
- if ( x > cbox.xMax ) cbox.xMax = x;
-
- if ( y < cbox.yMin ) cbox.yMin = y;
- if ( y > cbox.yMax ) cbox.yMax = y;
+ FT_UPDATE_BBOX( vec, cbox);
if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON )
- {
- /* update bbox for `on' points only */
- if ( x < bbox.xMin ) bbox.xMin = x;
- if ( x > bbox.xMax ) bbox.xMax = x;
-
- if ( y < bbox.yMin ) bbox.yMin = y;
- if ( y > bbox.yMax ) bbox.yMax = y;
- }
+ FT_UPDATE_BBOX( vec, bbox);
vec++;
}
diff --git a/src/3rdparty/freetype/src/base/ftbdf.c b/src/3rdparty/freetype/src/base/ftbdf.c
index d29adf09dd..d9dcbad5ed 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, 2003, 2004 by */
+/* Copyright 2002-2004, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_BDF_H
@@ -32,19 +34,18 @@
const char* encoding = NULL;
const char* registry = NULL;
+ FT_Service_BDF service;
- error = FT_Err_Invalid_Argument;
-
- if ( face )
- {
- FT_Service_BDF service;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
- FT_FACE_FIND_SERVICE( face, service, BDF );
+ FT_FACE_FIND_SERVICE( face, service, BDF );
- if ( service && service->get_charset_id )
- error = service->get_charset_id( face, &encoding, &registry );
- }
+ if ( service && service->get_charset_id )
+ error = service->get_charset_id( face, &encoding, &registry );
+ else
+ error = FT_THROW( Invalid_Argument );
if ( acharset_encoding )
*acharset_encoding = encoding;
@@ -65,23 +66,25 @@
{
FT_Error error;
+ FT_Service_BDF service;
- error = FT_Err_Invalid_Argument;
- aproperty->type = BDF_PROPERTY_TYPE_NONE;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
- if ( face )
- {
- FT_Service_BDF service;
+ if ( !aproperty )
+ return FT_THROW( Invalid_Argument );
+ aproperty->type = BDF_PROPERTY_TYPE_NONE;
- FT_FACE_FIND_SERVICE( face, service, BDF );
+ FT_FACE_FIND_SERVICE( face, service, BDF );
- if ( service && service->get_property )
- error = service->get_property( face, prop_name, aproperty );
- }
+ if ( service && service->get_property )
+ error = service->get_property( face, prop_name, aproperty );
+ else
+ error = FT_THROW( Invalid_Argument );
- return error;
+ return error;
}
diff --git a/src/3rdparty/freetype/src/base/ftbitmap.c b/src/3rdparty/freetype/src/base/ftbitmap.c
index 46fcce6136..19a1a80795 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, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2004-2009, 2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_BITMAP_H
#include FT_IMAGE_H
#include FT_INTERNAL_OBJECTS_H
@@ -31,7 +33,8 @@
FT_EXPORT_DEF( void )
FT_Bitmap_New( FT_Bitmap *abitmap )
{
- *abitmap = null_bitmap;
+ if ( abitmap )
+ *abitmap = null_bitmap;
}
@@ -42,25 +45,42 @@
const FT_Bitmap *source,
FT_Bitmap *target)
{
- FT_Memory memory = library->memory;
+ FT_Memory memory;
FT_Error error = FT_Err_Ok;
- FT_Int pitch = source->pitch;
- FT_ULong size;
+ FT_Int pitch;
+ FT_ULong size;
+
+ FT_Int source_pitch_sign, target_pitch_sign;
+
+
+ if ( !library )
+ return FT_THROW( Invalid_Library_Handle );
+
+ if ( !source || !target )
+ return FT_THROW( Invalid_Argument );
if ( source == target )
return FT_Err_Ok;
+ source_pitch_sign = source->pitch < 0 ? -1 : 1;
+ target_pitch_sign = target->pitch < 0 ? -1 : 1;
+
if ( source->buffer == NULL )
{
*target = *source;
+ if ( source_pitch_sign != target_pitch_sign )
+ target->pitch = -target->pitch;
return FT_Err_Ok;
}
+ memory = library->memory;
+ pitch = source->pitch;
+
if ( pitch < 0 )
pitch = -pitch;
- size = (FT_ULong)( pitch * source->rows );
+ size = (FT_ULong)pitch * source->rows;
if ( target->buffer )
{
@@ -68,9 +88,9 @@
FT_ULong target_size;
- if ( target_pitch < 0 )
+ if ( target_pitch < 0 )
target_pitch = -target_pitch;
- target_size = (FT_ULong)( target_pitch * target->rows );
+ target_size = (FT_ULong)target_pitch * target->rows;
if ( target_size != size )
(void)FT_QREALLOC( target->buffer, target_size, size );
@@ -87,13 +107,35 @@
*target = *source;
target->buffer = p;
- FT_MEM_COPY( target->buffer, source->buffer, size );
+ if ( source_pitch_sign == target_pitch_sign )
+ FT_MEM_COPY( target->buffer, source->buffer, size );
+ else
+ {
+ /* take care of bitmap flow */
+ FT_UInt i;
+ FT_Byte* s = source->buffer;
+ FT_Byte* t = target->buffer;
+
+
+ t += pitch * ( target->rows - 1 );
+
+ for ( i = target->rows; i > 0; i-- )
+ {
+ FT_ARRAY_COPY( t, s, pitch );
+
+ s += pitch;
+ t -= pitch;
+ }
+ }
}
return error;
}
+ /* Enlarge `bitmap' horizontally and vertically by `xpixels' */
+ /* and `ypixels', respectively. */
+
static FT_Error
ft_bitmap_assure_buffer( FT_Memory memory,
FT_Bitmap* bitmap,
@@ -104,8 +146,8 @@
int pitch;
int new_pitch;
FT_UInt bpp;
- FT_Int i, width, height;
- unsigned char* buffer;
+ FT_UInt i, width, height;
+ unsigned char* buffer = NULL;
width = bitmap->width;
@@ -135,24 +177,24 @@
new_pitch = ( width + xpixels );
break;
default:
- return FT_Err_Invalid_Glyph_Format;
+ return FT_THROW( Invalid_Glyph_Format );
}
/* if no need to allocate memory */
if ( ypixels == 0 && new_pitch <= pitch )
{
/* zero the padding */
- FT_Int bit_width = pitch * 8;
- FT_Int bit_last = ( width + xpixels ) * bpp;
+ FT_UInt bit_width = pitch * 8;
+ FT_UInt bit_last = ( width + xpixels ) * bpp;
if ( bit_last < bit_width )
{
FT_Byte* line = bitmap->buffer + ( bit_last >> 3 );
FT_Byte* end = bitmap->buffer + pitch;
- FT_Int shift = bit_last & 7;
+ FT_UInt shift = bit_last & 7;
FT_UInt mask = 0xFF00U >> shift;
- FT_Int count = height;
+ FT_UInt count = height;
for ( ; count > 0; count--, line += pitch, end += pitch )
@@ -166,19 +208,22 @@
write++;
}
if ( write < end )
- FT_MEM_ZERO( write, end-write );
+ FT_MEM_ZERO( write, end - write );
}
}
return FT_Err_Ok;
}
+ /* otherwise allocate new buffer */
if ( FT_QALLOC_MULT( buffer, new_pitch, bitmap->rows + ypixels ) )
return error;
+ /* new rows get added at the top of the bitmap, */
+ /* thus take care of the flow direction */
if ( bitmap->pitch > 0 )
{
- FT_Int len = ( width * bpp + 7 ) >> 3;
+ FT_UInt len = ( width * bpp + 7 ) >> 3;
for ( i = 0; i < bitmap->rows; i++ )
@@ -187,7 +232,7 @@
}
else
{
- FT_Int len = ( width * bpp + 7 ) >> 3;
+ FT_UInt len = ( width * bpp + 7 ) >> 3;
for ( i = 0; i < bitmap->rows; i++ )
@@ -218,27 +263,28 @@
{
FT_Error error;
unsigned char* p;
- FT_Int i, x, y, pitch;
+ FT_Int i, x, pitch;
+ FT_UInt y;
FT_Int xstr, ystr;
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !bitmap || !bitmap->buffer )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) ||
( ( FT_PIX_ROUND( yStrength ) >> 6 ) > FT_INT_MAX ) )
- return FT_Err_Invalid_Argument;
-
+ return FT_THROW( Invalid_Argument );
+
xstr = (FT_Int)FT_PIX_ROUND( xStrength ) >> 6;
ystr = (FT_Int)FT_PIX_ROUND( yStrength ) >> 6;
if ( xstr == 0 && ystr == 0 )
return FT_Err_Ok;
else if ( xstr < 0 || ystr < 0 )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
switch ( bitmap->pixel_mode )
{
@@ -246,17 +292,11 @@
case FT_PIXEL_MODE_GRAY4:
{
FT_Bitmap tmp;
- FT_Int align;
-
- if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY2 )
- align = ( bitmap->width + xstr + 3 ) / 4;
- else
- align = ( bitmap->width + xstr + 1 ) / 2;
+ /* convert to 8bpp */
FT_Bitmap_New( &tmp );
-
- error = FT_Bitmap_Convert( library, bitmap, &tmp, align );
+ error = FT_Bitmap_Convert( library, bitmap, &tmp, 1 );
if ( error )
return error;
@@ -277,12 +317,17 @@
case FT_PIXEL_MODE_LCD_V:
ystr *= 3;
break;
+
+ case FT_PIXEL_MODE_BGRA:
+ /* We don't embolden color glyphs. */
+ return FT_Err_Ok;
}
error = ft_bitmap_assure_buffer( library->memory, bitmap, xstr, ystr );
if ( error )
return error;
+ /* take care of bitmap flow */
pitch = bitmap->pitch;
if ( pitch > 0 )
p = bitmap->buffer + pitch * ystr;
@@ -303,7 +348,7 @@
*/
for ( x = pitch - 1; x >= 0; x-- )
{
- unsigned char tmp;
+ unsigned char tmp;
tmp = p[x];
@@ -318,7 +363,7 @@
p[x] |= p[x - 1] << ( 8 - i );
#if 0
- if ( p[x] == 0xff )
+ if ( p[x] == 0xFF )
break;
#endif
}
@@ -328,12 +373,12 @@
{
if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
{
- p[x] = (unsigned char)(bitmap->num_grays - 1);
+ p[x] = (unsigned char)( bitmap->num_grays - 1 );
break;
}
else
{
- p[x] = (unsigned char)(p[x] + p[x-i]);
+ p[x] = (unsigned char)( p[x] + p[x - i] );
if ( p[x] == bitmap->num_grays - 1 )
break;
}
@@ -369,6 +414,52 @@
}
+ static FT_Byte
+ ft_gray_for_premultiplied_srgb_bgra( const FT_Byte* bgra )
+ {
+ FT_UInt a = bgra[3];
+ FT_UInt l;
+
+
+ /* Short-circuit transparent color to avoid division by zero. */
+ if ( !a )
+ return 0;
+
+ /*
+ * Luminosity for sRGB is defined using ~0.2126,0.7152,0.0722
+ * coefficients for RGB channels *on the linear colors*.
+ * 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
+ *
+ * We do the computation with integers only, applying a gamma of 2.0.
+ * We guarantee 32-bit arithmetic to avoid overflow but the resulting
+ * luminosity fits into 16 bits.
+ *
+ */
+
+ l = ( 4732UL /* 0.0722 * 65536 */ * bgra[0] * bgra[0] +
+ 46871UL /* 0.7152 * 65536 */ * bgra[1] * bgra[1] +
+ 13933UL /* 0.2126 * 65536 */ * bgra[2] * bgra[2] ) >> 16;
+
+ /*
+ * Final transparency can be determined as follows.
+ *
+ * - If alpha is zero, we want 0.
+ * - If alpha is zero and luminosity is zero, we want 255.
+ * - If alpha is zero and luminosity is one, we want 0.
+ *
+ * So the formula is a * (1 - l) = a - l * a.
+ *
+ * We still need to undo premultiplication by dividing l by a*a.
+ *
+ */
+
+ return (FT_Byte)( a - l / a );
+ }
+
+
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
@@ -380,9 +471,15 @@
FT_Error error = FT_Err_Ok;
FT_Memory memory;
+ FT_Byte* s;
+ FT_Byte* t;
+
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
+
+ if ( !source || !target )
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
@@ -394,14 +491,17 @@
case FT_PIXEL_MODE_GRAY4:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
+ case FT_PIXEL_MODE_BGRA:
{
- FT_Int pad;
- FT_Long old_size;
+ FT_Int pad, old_target_pitch, target_pitch;
+ FT_ULong old_size;
+
+ old_target_pitch = target->pitch;
+ if ( old_target_pitch < 0 )
+ old_target_pitch = -old_target_pitch;
- old_size = target->rows * target->pitch;
- if ( old_size < 0 )
- old_size = -old_size;
+ old_size = target->rows * old_target_pitch;
target->pixel_mode = FT_PIXEL_MODE_GRAY;
target->rows = source->rows;
@@ -415,26 +515,39 @@
pad = alignment - pad;
}
- target->pitch = source->width + pad;
+ target_pitch = source->width + pad;
- if ( target->rows * target->pitch > old_size &&
+ if ( target_pitch > 0 &&
+ (FT_ULong)target->rows > FT_ULONG_MAX / target_pitch )
+ return FT_THROW( Invalid_Argument );
+
+ if ( target->rows * target_pitch > old_size &&
FT_QREALLOC( target->buffer,
- old_size, target->rows * target->pitch ) )
+ old_size, target->rows * target_pitch ) )
return error;
+
+ target->pitch = target->pitch < 0 ? -target_pitch : target_pitch;
}
break;
default:
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
+ s = source->buffer;
+ t = target->buffer;
+
+ /* take care of bitmap flow */
+ if ( source->pitch < 0 )
+ s -= source->pitch * ( source->rows - 1 );
+ if ( target->pitch < 0 )
+ t -= target->pitch * ( target->rows - 1 );
+
switch ( source->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
{
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_UInt i;
target->num_grays = 2;
@@ -443,7 +556,7 @@
{
FT_Byte* ss = s;
FT_Byte* tt = t;
- FT_Int j;
+ FT_UInt j;
/* get the full bytes */
@@ -491,12 +604,8 @@
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
{
- FT_Int width = source->width;
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int s_pitch = source->pitch;
- FT_Int t_pitch = target->pitch;
- FT_Int i;
+ FT_Int width = source->width;
+ FT_UInt i;
target->num_grays = 256;
@@ -505,8 +614,8 @@
{
FT_ARRAY_COPY( t, s, width );
- s += s_pitch;
- t += t_pitch;
+ s += source->pitch;
+ t += target->pitch;
}
}
break;
@@ -514,9 +623,7 @@
case FT_PIXEL_MODE_GRAY2:
{
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_UInt i;
target->num_grays = 4;
@@ -525,7 +632,7 @@
{
FT_Byte* ss = s;
FT_Byte* tt = t;
- FT_Int j;
+ FT_UInt j;
/* get the full bytes */
@@ -566,9 +673,7 @@
case FT_PIXEL_MODE_GRAY4:
{
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_UInt i;
target->num_grays = 16;
@@ -577,7 +682,7 @@
{
FT_Byte* ss = s;
FT_Byte* tt = t;
- FT_Int j;
+ FT_UInt j;
/* get the full bytes */
@@ -603,6 +708,34 @@
break;
+ case FT_PIXEL_MODE_BGRA:
+ {
+ FT_UInt i;
+
+
+ target->num_grays = 256;
+
+ for ( i = source->rows; i > 0; i-- )
+ {
+ FT_Byte* ss = s;
+ FT_Byte* tt = t;
+ FT_UInt j;
+
+
+ for ( j = source->width; j > 0; j-- )
+ {
+ tt[0] = ft_gray_for_premultiplied_srgb_bgra( ss );
+
+ ss += 4;
+ tt += 1;
+ }
+
+ s += source->pitch;
+ t += target->pitch;
+ }
+ }
+ break;
+
default:
;
}
@@ -646,10 +779,10 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !bitmap )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
diff --git a/src/3rdparty/freetype/src/base/ftcalc.c b/src/3rdparty/freetype/src/base/ftcalc.c
index 3892fabfe9..57f796803d 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-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
+/* Copyright 1996-2006, 2008, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -34,21 +34,19 @@
#include <ft2build.h>
#include FT_GLYPH_H
+#include FT_TRIGONOMETRY_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
-#ifdef FT_MULFIX_INLINED
+
+#ifdef FT_MULFIX_ASSEMBLER
#undef FT_MulFix
#endif
-/* we need to define a 64-bits data type here */
-
-#ifdef FT_LONG64
-
- typedef FT_INT64 FT_Int64;
+/* we need to emulate a 64-bit data type if a real one isn't available */
-#else
+#ifndef FT_LONG64
typedef struct FT_Int64_
{
@@ -57,7 +55,7 @@
} FT_Int64;
-#endif /* FT_LONG64 */
+#endif /* !FT_LONG64 */
/*************************************************************************/
@@ -70,6 +68,16 @@
#define FT_COMPONENT trace_calc
+ /* transfer sign leaving a positive number */
+#define FT_MOVE_SIGN( x, s ) \
+ FT_BEGIN_STMNT \
+ if ( x < 0 ) \
+ { \
+ x = -x; \
+ s = -s; \
+ } \
+ FT_END_STMNT
+
/* The following three functions are available regardless of whether */
/* FT_LONG64 is defined. */
@@ -78,8 +86,8 @@
FT_EXPORT_DEF( FT_Fixed )
FT_RoundFix( FT_Fixed a )
{
- return ( a >= 0 ) ? ( a + 0x8000L ) & ~0xFFFFL
- : -((-a + 0x8000L ) & ~0xFFFFL );
+ return a >= 0 ? ( a + 0x8000L ) & ~0xFFFFL
+ : -((-a + 0x8000L ) & ~0xFFFFL );
}
@@ -88,8 +96,8 @@
FT_EXPORT_DEF( FT_Fixed )
FT_CeilFix( FT_Fixed a )
{
- return ( a >= 0 ) ? ( a + 0xFFFFL ) & ~0xFFFFL
- : -((-a + 0xFFFFL ) & ~0xFFFFL );
+ return a >= 0 ? ( a + 0xFFFFL ) & ~0xFFFFL
+ : -((-a + 0xFFFFL ) & ~0xFFFFL );
}
@@ -98,43 +106,65 @@
FT_EXPORT_DEF( FT_Fixed )
FT_FloorFix( FT_Fixed a )
{
- return ( a >= 0 ) ? a & ~0xFFFFL
- : -((-a) & ~0xFFFFL );
+ return a >= 0 ? a & ~0xFFFFL
+ : -((-a) & ~0xFFFFL );
}
+#ifndef FT_MSB
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
+ FT_BASE_DEF ( FT_Int )
+ FT_MSB( FT_UInt32 z )
+ {
+ FT_Int shift = 0;
- /* documentation is in ftcalc.h */
- FT_EXPORT_DEF( FT_Int32 )
- FT_Sqrt32( FT_Int32 x )
- {
- FT_UInt32 val, root, newroot, mask;
+ /* determine msb bit index in `shift' */
+ if ( z & 0xFFFF0000UL )
+ {
+ z >>= 16;
+ shift += 16;
+ }
+ if ( z & 0x0000FF00UL )
+ {
+ z >>= 8;
+ shift += 8;
+ }
+ if ( z & 0x000000F0UL )
+ {
+ z >>= 4;
+ shift += 4;
+ }
+ if ( z & 0x0000000CUL )
+ {
+ z >>= 2;
+ shift += 2;
+ }
+ if ( z & 0x00000002UL )
+ {
+ /* z >>= 1; */
+ shift += 1;
+ }
+ return shift;
+ }
- root = 0;
- mask = (FT_UInt32)0x40000000UL;
- val = (FT_UInt32)x;
+#endif /* !FT_MSB */
- do
- {
- newroot = root + mask;
- if ( newroot <= val )
- {
- val -= newroot;
- root = newroot + mask;
- }
- root >>= 1;
- mask >>= 2;
+ /* documentation is in ftcalc.h */
- } while ( mask != 0 );
+ FT_BASE_DEF( FT_Fixed )
+ FT_Hypot( FT_Fixed x,
+ FT_Fixed y )
+ {
+ FT_Vector v;
- return root;
- }
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
+ v.x = x;
+ v.y = y;
+
+ return FT_Vector_Length( &v );
+ }
#ifdef FT_LONG64
@@ -147,24 +177,21 @@
FT_Long b,
FT_Long c )
{
- FT_Int s;
+ FT_Int s = 1;
FT_Long d;
- s = 1;
- if ( a < 0 ) { a = -a; s = -1; }
- if ( b < 0 ) { b = -b; s = -s; }
- if ( c < 0 ) { c = -c; s = -s; }
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
+ FT_MOVE_SIGN( c, s );
d = (FT_Long)( c > 0 ? ( (FT_Int64)a * b + ( c >> 1 ) ) / c
: 0x7FFFFFFFL );
- return ( s > 0 ) ? d : -d;
+ return s < 0 ? -d : d;
}
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Long )
@@ -172,23 +199,20 @@
FT_Long b,
FT_Long c )
{
- FT_Int s;
+ FT_Int s = 1;
FT_Long d;
- s = 1;
- if ( a < 0 ) { a = -a; s = -1; }
- if ( b < 0 ) { b = -b; s = -s; }
- if ( c < 0 ) { c = -c; s = -s; }
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
+ FT_MOVE_SIGN( c, s );
d = (FT_Long)( c > 0 ? (FT_Int64)a * b / c
: 0x7FFFFFFFL );
- return ( s > 0 ) ? d : -d;
+ return s < 0 ? -d : d;
}
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
/* documentation is in freetype.h */
@@ -206,21 +230,12 @@
FT_Long c;
- if ( a < 0 )
- {
- a = -a;
- s = -1;
- }
-
- if ( b < 0 )
- {
- b = -b;
- s = -s;
- }
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
c = (FT_Long)( ( (FT_Int64)a * b + 0x8000L ) >> 16 );
- return ( s > 0 ) ? c : -c;
+ return s < 0 ? -c : c;
#endif /* FT_MULFIX_ASSEMBLER */
}
@@ -232,21 +247,17 @@
FT_DivFix( FT_Long a,
FT_Long b )
{
- FT_Int32 s;
- FT_UInt32 q;
+ FT_Int s = 1;
+ FT_Long q;
- s = 1;
- if ( a < 0 ) { a = -a; s = -1; }
- if ( b < 0 ) { b = -b; s = -s; }
- if ( b == 0 )
- /* check for division by 0 */
- q = 0x7FFFFFFFL;
- else
- /* compute result directly */
- q = (FT_UInt32)( ( ( (FT_Int64)a << 16 ) + ( b >> 1 ) ) / b );
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
- return ( s < 0 ? -(FT_Long)q : (FT_Long)q );
+ q = (FT_Long)( b > 0 ? ( ( (FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b
+ : 0x7FFFFFFFL );
+
+ return s < 0 ? -q : q;
}
@@ -294,25 +305,30 @@
FT_Int i;
- q = 0;
- r = hi;
-
- if ( r >= y )
+ if ( hi >= y )
return (FT_UInt32)0x7FFFFFFFL;
- i = 32;
+ /* We shift as many bits as we can into the high register, perform */
+ /* 32-bit division with modulo there, then work through the remaining */
+ /* bits with long division. This optimization is especially noticeable */
+ /* for smaller dividends that barely use the high register. */
+
+ i = 31 - FT_MSB( hi );
+ r = ( hi << i ) | ( lo >> ( 32 - i ) ); lo <<= i; /* left 64-bit shift */
+ q = r / y;
+ r -= q * y; /* remainder */
+
+ i = 32 - i; /* bits remaining in low register */
do
{
- r <<= 1;
q <<= 1;
- r |= lo >> 31;
+ r = ( r << 1 ) | ( lo >> 31 ); lo <<= 1;
- if ( r >= (FT_UInt32)y )
+ if ( r >= y )
{
r -= y;
q |= 1;
}
- lo <<= 1;
} while ( --i );
return q;
@@ -324,7 +340,7 @@
FT_Int64* y,
FT_Int64 *z )
{
- register FT_UInt32 lo, hi;
+ FT_UInt32 lo, hi;
lo = x->lo + y->lo;
@@ -335,99 +351,134 @@
}
- /* documentation is in freetype.h */
-
- /* The FT_MulDiv function has been optimized thanks to ideas from */
- /* Graham Asher. The trick is to optimize computation when everything */
- /* fits within 32-bits (a rather common case). */
+ /* The FT_MulDiv function has been optimized thanks to ideas from */
+ /* Graham Asher and Alexei Podtelezhnikov. The trick is to optimize */
+ /* a rather common case when everything fits within 32-bits. */
+ /* */
+ /* We compute 'a*b+c/2', then divide it by 'c' (all positive values). */
+ /* */
+ /* The product of two positive numbers never exceeds the square of */
+ /* its mean values. Therefore, we always avoid the overflow by */
+ /* imposing */
+ /* */
+ /* (a + b) / 2 <= sqrt(X - c/2) , */
/* */
- /* we compute 'a*b+c/2', then divide it by 'c'. (positive values) */
+ /* where X = 2^32 - 1, the maximum unsigned 32-bit value, and using */
+ /* unsigned arithmetic. Now we replace `sqrt' with a linear function */
+ /* that is smaller or equal for all values of c in the interval */
+ /* [0;X/2]; it should be equal to sqrt(X) and sqrt(3X/4) at the */
+ /* endpoints. Substituting the linear solution and explicit numbers */
+ /* we get */
/* */
- /* 46340 is FLOOR(SQRT(2^31-1)). */
+ /* a + b <= 131071.99 - c / 122291.84 . */
/* */
- /* if ( a <= 46340 && b <= 46340 ) then ( a*b <= 0x7FFEA810 ) */
+ /* In practice, we should use a faster and even stronger inequality */
/* */
- /* 0x7FFFFFFF - 0x7FFEA810 = 0x157F0 */
+ /* a + b <= 131071 - (c >> 16) */
/* */
- /* if ( c < 0x157F0*2 ) then ( a*b+c/2 <= 0x7FFFFFFF ) */
+ /* or, alternatively, */
/* */
- /* and 2*0x157F0 = 176096 */
+ /* a + b <= 129894 - (c >> 17) . */
/* */
+ /* FT_MulFix, on the other hand, is optimized for a small value of */
+ /* the first argument, when the second argument can be much larger. */
+ /* This can be achieved by scaling the second argument and the limit */
+ /* in the above inequalities. For example, */
+ /* */
+ /* a + (b >> 8) <= (131071 >> 4) */
+ /* */
+ /* covers the practical range of use. The actual test below is a bit */
+ /* tighter to avoid the border case overflows. */
+ /* */
+ /* In the case of FT_DivFix, the exact overflow check */
+ /* */
+ /* a << 16 <= X - c/2 */
+ /* */
+ /* is scaled down by 2^16 and we use */
+ /* */
+ /* a <= 65535 - (c >> 17) . */
+
+ /* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Long )
FT_MulDiv( FT_Long a,
FT_Long b,
FT_Long c )
{
- long s;
+ FT_Int s = 1;
/* XXX: this function does not allow 64-bit arguments */
if ( a == 0 || b == c )
return a;
- s = a; a = FT_ABS( a );
- s ^= b; b = FT_ABS( b );
- s ^= c; c = FT_ABS( c );
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
+ FT_MOVE_SIGN( c, s );
+
+ if ( c == 0 )
+ a = 0x7FFFFFFFL;
- if ( a <= 46340L && b <= 46340L && c <= 176095L && c > 0 )
- a = ( a * b + ( c >> 1 ) ) / c;
+ else if ( (FT_ULong)a + b <= 129894UL - ( c >> 17 ) )
+ a = ( (FT_ULong)a * b + ( c >> 1 ) ) / c;
- else if ( c > 0 )
+ else
{
FT_Int64 temp, temp2;
- ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
+ ft_multo64( a, b, &temp );
temp2.hi = 0;
- temp2.lo = (FT_UInt32)(c >> 1);
+ temp2.lo = c >> 1;
+
FT_Add64( &temp, &temp2, &temp );
- a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
+
+ /* last attempt to ditch long division */
+ a = temp.hi == 0 ? temp.lo / c
+ : ft_div64by32( temp.hi, temp.lo, c );
}
- else
- a = 0x7FFFFFFFL;
- return ( s < 0 ? -a : a );
+ return s < 0 ? -a : a;
}
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
FT_BASE_DEF( FT_Long )
FT_MulDiv_No_Round( FT_Long a,
FT_Long b,
FT_Long c )
{
- long s;
+ FT_Int s = 1;
if ( a == 0 || b == c )
return a;
- s = a; a = FT_ABS( a );
- s ^= b; b = FT_ABS( b );
- s ^= c; c = FT_ABS( c );
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
+ FT_MOVE_SIGN( c, s );
+
+ if ( c == 0 )
+ a = 0x7FFFFFFFL;
- if ( a <= 46340L && b <= 46340L && c > 0 )
- a = a * b / c;
+ else if ( (FT_ULong)a + b <= 131071UL )
+ a = (FT_ULong)a * b / c;
- else if ( c > 0 )
+ else
{
FT_Int64 temp;
- ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
- a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
+ ft_multo64( a, b, &temp );
+
+ /* last attempt to ditch long division */
+ a = temp.hi == 0 ? temp.lo / c
+ : ft_div64by32( temp.hi, temp.lo, c );
}
- else
- a = 0x7FFFFFFFL;
- return ( s < 0 ? -a : a );
+ return s < 0 ? -a : a;
}
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
/* documentation is in freetype.h */
@@ -464,7 +515,7 @@
* Unfortunately, it doesn't work (at least not portably).
*
* It makes the assumption that right-shift on a negative signed value
- * fills the leftmost bits by copying the sign bit. This is wrong.
+ * fills the leftmost bits by copying the sign bit. This is wrong.
* According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
* the result of right-shift of a negative signed value is
* implementation-defined. At least one implementation fills the
@@ -481,7 +532,7 @@
ua = (FT_ULong)a;
ub = (FT_ULong)b;
- if ( ua <= 2048 && ub <= 1048576L )
+ if ( ua + ( ub >> 8 ) <= 8190UL )
ua = ( ua * ub + 0x8000U ) >> 16;
else
{
@@ -499,20 +550,20 @@
#else /* 0 */
- FT_Long s;
+ FT_Int s = 1;
FT_ULong ua, ub;
if ( a == 0 || b == 0x10000L )
return a;
- s = a; a = FT_ABS( a );
- s ^= b; b = FT_ABS( b );
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
ua = (FT_ULong)a;
ub = (FT_ULong)b;
- if ( ua <= 2048 && ub <= 1048576L )
+ if ( ua + ( ub >> 8 ) <= 8190UL )
ua = ( ua * ub + 0x8000UL ) >> 16;
else
{
@@ -523,7 +574,7 @@
( ( al * ( ub & 0xFFFFUL ) + 0x8000UL ) >> 16 );
}
- return ( s < 0 ? -(FT_Long)ua : (FT_Long)ua );
+ return s < 0 ? -(FT_Long)ua : (FT_Long)ua;
#endif /* 0 */
@@ -536,161 +587,43 @@
FT_DivFix( FT_Long a,
FT_Long b )
{
- FT_Int32 s;
- FT_UInt32 q;
+ FT_Int s = 1;
+ FT_Long q;
/* XXX: this function does not allow 64-bit arguments */
- s = (FT_Int32)a; a = FT_ABS( a );
- s ^= (FT_Int32)b; b = FT_ABS( b );
+
+ FT_MOVE_SIGN( a, s );
+ FT_MOVE_SIGN( b, s );
if ( b == 0 )
{
/* check for division by 0 */
- q = (FT_UInt32)0x7FFFFFFFL;
+ q = 0x7FFFFFFFL;
}
- else if ( ( a >> 16 ) == 0 )
+ else if ( a <= 65535L - ( b >> 17 ) )
{
/* compute result directly */
- q = (FT_UInt32)( (a << 16) + (b >> 1) ) / (FT_UInt32)b;
+ q = (FT_Long)( ( ( (FT_ULong)a << 16 ) + ( b >> 1 ) ) / b );
}
else
{
/* we need more bits; we have to do it by hand */
FT_Int64 temp, temp2;
- temp.hi = (FT_Int32) (a >> 16);
- temp.lo = (FT_UInt32)(a << 16);
- temp2.hi = 0;
- temp2.lo = (FT_UInt32)( b >> 1 );
- FT_Add64( &temp, &temp2, &temp );
- q = ft_div64by32( temp.hi, temp.lo, (FT_Int32)b );
- }
-
- return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
- }
-
-
-#if 0
-
- /* documentation is in ftcalc.h */
-
- FT_EXPORT_DEF( void )
- FT_MulTo64( FT_Int32 x,
- FT_Int32 y,
- FT_Int64 *z )
- {
- FT_Int32 s;
-
-
- s = x; x = FT_ABS( x );
- s ^= y; y = FT_ABS( y );
-
- ft_multo64( x, y, z );
-
- if ( s < 0 )
- {
- z->lo = (FT_UInt32)-(FT_Int32)z->lo;
- z->hi = ~z->hi + !( z->lo );
- }
- }
-
- /* apparently, the second version of this code is not compiled correctly */
- /* on Mac machines with the MPW C compiler.. tsk, tsk, tsk... */
-
-#if 1
-
- FT_EXPORT_DEF( FT_Int32 )
- FT_Div64by32( FT_Int64* x,
- FT_Int32 y )
- {
- FT_Int32 s;
- FT_UInt32 q, r, i, lo;
-
-
- s = x->hi;
- if ( s < 0 )
- {
- x->lo = (FT_UInt32)-(FT_Int32)x->lo;
- x->hi = ~x->hi + !x->lo;
- }
- s ^= y; y = FT_ABS( y );
-
- /* Shortcut */
- if ( x->hi == 0 )
- {
- if ( y > 0 )
- q = x->lo / y;
- else
- q = 0x7FFFFFFFL;
-
- return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
- }
-
- r = x->hi;
- lo = x->lo;
-
- if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here */
- return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
- /* Return Max/Min Int32 if division overflow. */
- /* This includes division by zero! */
- q = 0;
- for ( i = 0; i < 32; i++ )
- {
- r <<= 1;
- q <<= 1;
- r |= lo >> 31;
-
- if ( r >= (FT_UInt32)y )
- {
- r -= y;
- q |= 1;
- }
- lo <<= 1;
- }
-
- return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
- }
-
-#else /* 0 */
-
- FT_EXPORT_DEF( FT_Int32 )
- FT_Div64by32( FT_Int64* x,
- FT_Int32 y )
- {
- FT_Int32 s;
- FT_UInt32 q;
-
-
- s = x->hi;
- if ( s < 0 )
- {
- x->lo = (FT_UInt32)-(FT_Int32)x->lo;
- x->hi = ~x->hi + !x->lo;
- }
- s ^= y; y = FT_ABS( y );
-
- /* Shortcut */
- if ( x->hi == 0 )
- {
- if ( y > 0 )
- q = ( x->lo + ( y >> 1 ) ) / y;
- else
- q = 0x7FFFFFFFL;
+ temp.hi = a >> 16;
+ temp.lo = a << 16;
+ temp2.hi = 0;
+ temp2.lo = b >> 1;
- return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
+ FT_Add64( &temp, &temp2, &temp );
+ q = (FT_Long)ft_div64by32( temp.hi, temp.lo, b );
}
- q = ft_div64by32( x->hi, x->lo, y );
-
- return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
+ return s < 0 ? -q : q;
}
-#endif /* 0 */
-
-#endif /* 0 */
-
#endif /* FT_LONG64 */
@@ -726,14 +659,14 @@
if ( !matrix )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* compute discriminant */
delta = FT_MulFix( matrix->xx, matrix->yy ) -
FT_MulFix( matrix->xy, matrix->yx );
if ( !delta )
- return FT_Err_Invalid_Argument; /* matrix can't be inverted */
+ return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */
matrix->xy = - FT_DivFix( matrix->xy, delta );
matrix->yx = - FT_DivFix( matrix->yx, delta );
@@ -799,6 +732,8 @@
}
+#if 0
+
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Int32 )
@@ -833,6 +768,8 @@
return (FT_Int32)root;
}
+#endif /* 0 */
+
/* documentation is in ftcalc.h */
@@ -922,35 +859,40 @@
FT_Pos out_x,
FT_Pos out_y )
{
- FT_Pos ax = in_x;
- FT_Pos ay = in_y;
-
- FT_Pos d_in, d_out, d_corner;
-
-
- if ( ax < 0 )
- ax = -ax;
- if ( ay < 0 )
- ay = -ay;
- d_in = ax + ay;
-
- ax = out_x;
- if ( ax < 0 )
- ax = -ax;
- ay = out_y;
- if ( ay < 0 )
- ay = -ay;
- d_out = ax + ay;
-
- ax = out_x + in_x;
- if ( ax < 0 )
- ax = -ax;
- ay = out_y + in_y;
- if ( ay < 0 )
- ay = -ay;
- d_corner = ax + ay;
-
- return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
+ FT_Pos ax = in_x + out_x;
+ FT_Pos ay = in_y + out_y;
+
+ FT_Pos d_in, d_out, d_hypot;
+
+
+ /* The idea of this function is to compare the length of the */
+ /* hypotenuse with the `in' and `out' length. The `corner' */
+ /* represented by `in' and `out' is flat if the hypotenuse's */
+ /* length isn't too large. */
+ /* */
+ /* This approach has the advantage that the angle between */
+ /* `in' and `out' is not checked. In case one of the two */
+ /* vectors is `dominant', this is, much larger than the */
+ /* other vector, we thus always have a flat corner. */
+ /* */
+ /* hypotenuse */
+ /* x---------------------------x */
+ /* \ / */
+ /* \ / */
+ /* in \ / out */
+ /* \ / */
+ /* o */
+ /* Point */
+
+ d_in = FT_HYPOT( in_x, in_y );
+ d_out = FT_HYPOT( out_x, out_y );
+ d_hypot = FT_HYPOT( ax, ay );
+
+ /* now do a simple length comparison: */
+ /* */
+ /* d_in + d_out < 17/16 d_hypot */
+
+ return ( d_in + d_out - d_hypot ) < ( d_hypot >> 4 );
}
diff --git a/src/3rdparty/freetype/src/base/ftcid.c b/src/3rdparty/freetype/src/base/ftcid.c
index 733aae1475..741879d922 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, 2009 by Derek Clegg, Michael Toftdal. */
+/* Copyright 2007, 2009, 2013 by Derek Clegg, Michael Toftdal. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -35,7 +35,7 @@
FT_Int s = 0;
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( face )
{
@@ -65,7 +65,7 @@
FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
FT_Bool *is_cid )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_Bool ic = 0;
@@ -92,7 +92,7 @@
FT_UInt glyph_index,
FT_UInt *cid )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_UInt c = 0;
diff --git a/src/3rdparty/freetype/src/base/ftdbgmem.c b/src/3rdparty/freetype/src/base/ftdbgmem.c
index 160269d192..6fb86fe77d 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, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2001-2006, 2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -47,7 +47,7 @@
typedef struct FT_MemTableRec_* FT_MemTable;
-#define FT_MEM_VAL( addr ) ((FT_ULong)(FT_Pointer)( addr ))
+#define FT_MEM_VAL( addr ) ((FT_PtrDist)(FT_Pointer)( addr ))
/*
* This structure holds statistics for a single allocation/release
@@ -275,7 +275,7 @@
for ( i = 0; i < table->size; i++ )
{
FT_MemNode node, next, *pnode;
- FT_ULong hash;
+ FT_PtrDist hash;
node = table->buckets[i];
@@ -344,85 +344,80 @@
ft_mem_table_destroy( FT_MemTable table )
{
FT_ULong i;
+ FT_Long leak_count = 0;
+ FT_ULong leaks = 0;
FT_DumpMemory( table->memory );
- if ( table )
+ /* remove all blocks from the table, revealing leaked ones */
+ for ( i = 0; i < table->size; i++ )
{
- FT_Long leak_count = 0;
- FT_ULong leaks = 0;
+ FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
- /* remove all blocks from the table, revealing leaked ones */
- for ( i = 0; i < table->size; i++ )
+ while ( node )
{
- FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
+ next = node->link;
+ node->link = 0;
-
- while ( node )
+ if ( node->size > 0 )
{
- next = node->link;
- node->link = 0;
-
- if ( node->size > 0 )
- {
- printf(
- "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
- node->address, node->size,
- FT_FILENAME( node->source->file_name ),
- node->source->line_no );
+ printf(
+ "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
+ node->address, node->size,
+ FT_FILENAME( node->source->file_name ),
+ node->source->line_no );
- leak_count++;
- leaks += node->size;
+ leak_count++;
+ leaks += node->size;
- ft_mem_table_free( table, node->address );
- }
+ ft_mem_table_free( table, node->address );
+ }
- node->address = NULL;
- node->size = 0;
+ node->address = NULL;
+ node->size = 0;
- ft_mem_table_free( table, node );
- node = next;
- }
- table->buckets[i] = 0;
+ ft_mem_table_free( table, node );
+ node = next;
}
+ table->buckets[i] = 0;
+ }
- ft_mem_table_free( table, table->buckets );
- table->buckets = NULL;
-
- table->size = 0;
- table->nodes = 0;
+ ft_mem_table_free( table, table->buckets );
+ table->buckets = NULL;
- /* remove all sources */
- for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
- {
- FT_MemSource source, next;
+ table->size = 0;
+ table->nodes = 0;
+ /* remove all sources */
+ for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
+ {
+ FT_MemSource source, next;
- for ( source = table->sources[i]; source != NULL; source = next )
- {
- next = source->link;
- ft_mem_table_free( table, source );
- }
- table->sources[i] = NULL;
+ for ( source = table->sources[i]; source != NULL; source = next )
+ {
+ next = source->link;
+ ft_mem_table_free( table, source );
}
- printf(
- "FreeType: total memory allocations = %ld\n", table->alloc_total );
- printf(
- "FreeType: maximum memory footprint = %ld\n", table->alloc_max );
+ table->sources[i] = NULL;
+ }
- ft_mem_table_free( table, table );
+ printf( "FreeType: total memory allocations = %ld\n",
+ table->alloc_total );
+ printf( "FreeType: maximum memory footprint = %ld\n",
+ table->alloc_max );
- if ( leak_count > 0 )
- ft_mem_debug_panic(
- "FreeType: %ld bytes of memory leaked in %ld blocks\n",
- leaks, leak_count );
+ ft_mem_table_free( table, table );
- printf( "FreeType: no memory leaks detected\n" );
- }
+ if ( leak_count > 0 )
+ ft_mem_debug_panic(
+ "FreeType: %ld bytes of memory leaked in %ld blocks\n",
+ leaks, leak_count );
+
+ printf( "FreeType: no memory leaks detected\n" );
}
@@ -430,7 +425,7 @@
ft_mem_table_get_nodep( FT_MemTable table,
FT_Byte* address )
{
- FT_ULong hash;
+ FT_PtrDist hash;
FT_MemNode *pnode, node;
diff --git a/src/3rdparty/freetype/src/base/ftdebug.c b/src/3rdparty/freetype/src/base/ftdebug.c
index 2adbeabeb2..39ac6add05 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-2001, 2002, 2004, 2008 by */
+/* Copyright 1996-2001, 2002, 2004, 2008, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -51,7 +51,8 @@
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
- FT_Message( const char* fmt, ... )
+ FT_Message( const char* fmt,
+ ... )
{
va_list ap;
@@ -65,7 +66,8 @@
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
- FT_Panic( const char* fmt, ... )
+ FT_Panic( const char* fmt,
+ ... )
{
va_list ap;
@@ -77,6 +79,21 @@
exit( EXIT_FAILURE );
}
+
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( int )
+ FT_Throw( FT_Error error,
+ int line,
+ const char* file )
+ {
+ FT_UNUSED( error );
+ FT_UNUSED( line );
+ FT_UNUSED( file );
+
+ return 0;
+ }
+
#endif /* FT_DEBUG_LEVEL_ERROR */
@@ -135,7 +152,7 @@
/* the memory and stream components which are set to 7 and 5, */
/* respectively. */
/* */
- /* See the file <include/freetype/internal/fttrace.h> for details of the */
+ /* See the file <include/internal/fttrace.h> for details of the */
/* available toggle names. */
/* */
/* The level must be between 0 and 7; 0 means quiet (except for serious */
@@ -164,6 +181,9 @@
while ( *p && *p != ':' )
p++;
+ if ( !*p )
+ break;
+
if ( *p == ':' && p > q )
{
FT_Int n, i, len = (FT_Int)( p - q );
@@ -192,7 +212,7 @@
p++;
if ( *p )
{
- level = *p++ - '0';
+ level = *p - '0';
if ( level < 0 || level > 7 )
level = -1;
}
diff --git a/src/3rdparty/freetype/src/base/ftfstype.c b/src/3rdparty/freetype/src/base/ftfstype.c
index d0ef7b7c1b..6b49ef8371 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, 2009 by */
+/* Copyright 2008, 2009, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -51,7 +51,7 @@
/* look at FSType before fsType for Type42 */
- if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, ft_sfnt_os2 ) ) != NULL &&
+ if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, FT_SFNT_OS2 ) ) != NULL &&
os2->version != 0xFFFFU )
return os2->fsType;
diff --git a/src/3rdparty/freetype/src/base/ftgloadr.c b/src/3rdparty/freetype/src/base/ftgloadr.c
index ac0010ddd8..3cc5c7a805 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, 2003, 2004, 2005, 2006 by */
+/* Copyright 2002-2006, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_GLYPH_LOADER_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_OBJECTS_H
@@ -69,7 +70,7 @@
FT_GlyphLoader_New( FT_Memory memory,
FT_GlyphLoader *aloader )
{
- FT_GlyphLoader loader;
+ FT_GlyphLoader loader = NULL;
FT_Error error;
@@ -219,7 +220,7 @@
new_max = FT_PAD_CEIL( new_max, 8 );
if ( new_max > FT_OUTLINE_POINTS_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
@@ -251,7 +252,7 @@
new_max = FT_PAD_CEIL( new_max, 4 );
if ( new_max > FT_OUTLINE_CONTOURS_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
goto Exit;
@@ -264,6 +265,9 @@
FT_GlyphLoader_Adjust_Points( loader );
Exit:
+ if ( error )
+ FT_GlyphLoader_Reset( loader );
+
return error;
}
@@ -318,7 +322,7 @@
}
- /* add current glyph to the base image - and prepare for another */
+ /* add current glyph to the base image -- and prepare for another */
FT_BASE_DEF( void )
FT_GlyphLoader_Add( FT_GlyphLoader loader )
{
diff --git a/src/3rdparty/freetype/src/base/ftglyph.c b/src/3rdparty/freetype/src/base/ftglyph.c
index 3505d6dde9..ac178c41be 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-2001, 2002, 2003, 2004, 2005, 2007, 2008 by */
+/* Copyright 1996-2005, 2007, 2008, 2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
@@ -65,7 +67,7 @@
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
{
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
@@ -166,7 +168,7 @@
/* check format in glyph slot */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
{
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
@@ -254,7 +256,7 @@
}
- FT_DEFINE_GLYPH( ft_outline_glyph_class,
+ FT_DEFINE_GLYPH( ft_outline_glyph_class,
sizeof ( FT_OutlineGlyphRec ),
FT_GLYPH_FORMAT_OUTLINE,
@@ -282,7 +284,7 @@
{
FT_Memory memory = library->memory;
FT_Error error;
- FT_Glyph glyph;
+ FT_Glyph glyph = NULL;
*aglyph = 0;
@@ -312,17 +314,17 @@
/* check arguments */
- if ( !target )
+ if ( !target || !source || !source->clazz )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
- *target = 0;
+ *target = NULL;
if ( !source || !source->clazz )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -357,16 +359,16 @@
FT_Error error;
FT_Glyph glyph;
- const FT_Glyph_Class* clazz = 0;
+ const FT_Glyph_Class* clazz = NULL;
if ( !slot )
- return FT_Err_Invalid_Slot_Handle;
+ return FT_THROW( Invalid_Slot_Handle );
library = slot->library;
if ( !aglyph )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* if it is a bitmap, that's easy :-) */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
@@ -388,7 +390,7 @@
if ( !clazz )
{
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
@@ -422,15 +424,16 @@
FT_Matrix* matrix,
FT_Vector* delta )
{
- const FT_Glyph_Class* clazz;
- FT_Error error = FT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( !glyph || !glyph->clazz )
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
else
{
- clazz = glyph->clazz;
+ const FT_Glyph_Class* clazz = glyph->clazz;
+
+
if ( clazz->glyph_transform )
{
/* transform glyph image */
@@ -441,7 +444,7 @@
FT_Vector_Transform( &glyph->advance, matrix );
}
else
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
}
return error;
}
@@ -464,38 +467,33 @@
if ( !glyph || !glyph->clazz )
return;
- else
+
+ clazz = glyph->clazz;
+ if ( !clazz->glyph_bbox )
+ return;
+
+ /* retrieve bbox in 26.6 coordinates */
+ clazz->glyph_bbox( glyph, acbox );
+
+ /* perform grid fitting if needed */
+ if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
+ bbox_mode == FT_GLYPH_BBOX_PIXELS )
{
- clazz = glyph->clazz;
- if ( !clazz->glyph_bbox )
- return;
- else
- {
- /* retrieve bbox in 26.6 coordinates */
- clazz->glyph_bbox( glyph, acbox );
-
- /* perform grid fitting if needed */
- if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
- bbox_mode == FT_GLYPH_BBOX_PIXELS )
- {
- acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
- acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
- acbox->xMax = FT_PIX_CEIL( acbox->xMax );
- acbox->yMax = FT_PIX_CEIL( acbox->yMax );
- }
-
- /* convert to integer pixels if needed */
- if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
- bbox_mode == FT_GLYPH_BBOX_PIXELS )
- {
- acbox->xMin >>= 6;
- acbox->yMin >>= 6;
- acbox->xMax >>= 6;
- acbox->yMax >>= 6;
- }
- }
+ acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
+ acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
+ acbox->xMax = FT_PIX_CEIL( acbox->xMax );
+ acbox->yMax = FT_PIX_CEIL( acbox->yMax );
+ }
+
+ /* convert to integer pixels if needed */
+ if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
+ bbox_mode == FT_GLYPH_BBOX_PIXELS )
+ {
+ acbox->xMin >>= 6;
+ acbox->yMin >>= 6;
+ acbox->xMax >>= 6;
+ acbox->yMax >>= 6;
}
- return;
}
@@ -510,47 +508,47 @@
FT_GlyphSlotRec dummy;
FT_GlyphSlot_InternalRec dummy_internal;
FT_Error error = FT_Err_Ok;
- FT_Glyph glyph;
+ FT_Glyph b, glyph;
FT_BitmapGlyph bitmap = NULL;
-
const FT_Glyph_Class* clazz;
-#ifdef FT_CONFIG_OPTION_PIC
- FT_Library library = FT_GLYPH( glyph )->library;
-#endif
+ /* FT_BITMAP_GLYPH_CLASS_GET dereferences `library' in PIC mode */
+ FT_Library library;
/* check argument */
if ( !the_glyph )
goto Bad;
-
- /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
- /* then calling FT_Render_Glyph_Internal() */
-
glyph = *the_glyph;
if ( !glyph )
goto Bad;
- clazz = glyph->clazz;
+ clazz = glyph->clazz;
+ library = glyph->library;
+ if ( !library || !clazz )
+ goto Bad;
/* when called with a bitmap glyph, do nothing and return successfully */
if ( clazz == FT_BITMAP_GLYPH_CLASS_GET )
goto Exit;
- if ( !clazz || !clazz->glyph_prepare )
+ if ( !clazz->glyph_prepare )
goto Bad;
+ /* 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 ) );
dummy.internal = &dummy_internal;
- dummy.library = glyph->library;
+ dummy.library = library;
dummy.format = clazz->glyph_format;
/* create result bitmap glyph */
- error = ft_new_glyph( glyph->library, FT_BITMAP_GLYPH_CLASS_GET,
- (FT_Glyph*)(void*)&bitmap );
+ error = ft_new_glyph( library, FT_BITMAP_GLYPH_CLASS_GET, &b );
if ( error )
goto Exit;
+ bitmap = (FT_BitmapGlyph)b;
#if 1
/* if `origin' is set, translate the glyph image */
@@ -600,7 +598,7 @@
return error;
Bad:
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
diff --git a/src/3rdparty/freetype/src/base/ftgxval.c b/src/3rdparty/freetype/src/base/ftgxval.c
index 32662bed87..a65f4c879b 100644
--- a/src/3rdparty/freetype/src/base/ftgxval.c
+++ b/src/3rdparty/freetype/src/base/ftgxval.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for validating TrueTyepGX/AAT tables (body). */
/* */
-/* Copyright 2004, 2005, 2006 by */
+/* Copyright 2004-2006, 2010, 2013, 2014 by */
/* Masatake YAMATO, Redhat K.K, */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -26,6 +26,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_GX_VALIDATE_H
@@ -44,13 +46,13 @@
if ( !face )
{
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
- if ( tables == NULL )
+ if ( !tables )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -62,7 +64,7 @@
tables,
table_length );
else
- error = FT_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
@@ -73,8 +75,13 @@
FT_TrueTypeGX_Free( FT_Face face,
FT_Bytes table )
{
- FT_Memory memory = FT_FACE_MEMORY( face );
+ FT_Memory memory;
+
+
+ if ( !face )
+ return;
+ memory = FT_FACE_MEMORY( face );
FT_FREE( table );
}
@@ -91,13 +98,13 @@
if ( !face )
{
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
- if ( ckern_table == NULL )
+ if ( !ckern_table )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -108,7 +115,7 @@
validation_flags,
ckern_table );
else
- error = FT_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
@@ -119,7 +126,13 @@
FT_ClassicKern_Free( FT_Face face,
FT_Bytes table )
{
- FT_Memory memory = FT_FACE_MEMORY( face );
+ FT_Memory memory;
+
+
+ if ( !face )
+ return;
+
+ memory = FT_FACE_MEMORY( face );
FT_FREE( table );
diff --git a/src/3rdparty/freetype/src/base/ftinit.c b/src/3rdparty/freetype/src/base/ftinit.c
index f94f25a83c..c4c88201a1 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-2001, 2002, 2005, 2007, 2009 by */
+/* Copyright 1996-2002, 2005, 2007, 2009, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,8 +23,8 @@
/* FT_Add_Default_Modules(): */
/* This function is used to add the set of default modules to a */
/* fresh new library object. The set is taken from the header file */
- /* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */
- /* Build System' for more information. */
+ /* `config/ftmodule.h'. See the document `FreeType 2.0 Build */
+ /* System' for more information. */
/* */
/* FT_Init_FreeType(): */
/* This function creates a system object for the current platform, */
@@ -54,8 +54,10 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_init
+
#ifndef FT_CONFIG_OPTION_PIC
+
#undef FT_USE_MODULE
#ifdef __cplusplus
#define FT_USE_MODULE( type, x ) extern "C" const type x;
@@ -63,10 +65,8 @@
#define FT_USE_MODULE( type, x ) extern const type x;
#endif
-
#include FT_CONFIG_MODULES_H
-
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x),
@@ -77,8 +77,10 @@
0
};
+
#else /* FT_CONFIG_OPTION_PIC */
+
#ifdef __cplusplus
#define FT_EXTERNC extern "C"
#else
@@ -87,42 +89,51 @@
/* declare the module's class creation/destruction functions */
#undef FT_USE_MODULE
-#define FT_USE_MODULE( type, x ) \
- FT_EXTERNC FT_Error FT_Create_Class_##x( FT_Library library, FT_Module_Class** output_class ); \
- FT_EXTERNC void FT_Destroy_Class_##x( FT_Library library, FT_Module_Class* clazz );
+#define FT_USE_MODULE( type, x ) \
+ FT_EXTERNC FT_Error \
+ FT_Create_Class_ ## x( FT_Library library, \
+ FT_Module_Class* *output_class ); \
+ FT_EXTERNC void \
+ FT_Destroy_Class_ ## x( FT_Library library, \
+ FT_Module_Class* clazz );
#include FT_CONFIG_MODULES_H
-
/* count all module classes */
#undef FT_USE_MODULE
-#define FT_USE_MODULE( type, x ) MODULE_CLASS_##x,
+#define FT_USE_MODULE( type, x ) MODULE_CLASS_ ## x,
- enum {
+ enum
+ {
#include FT_CONFIG_MODULES_H
FT_NUM_MODULE_CLASSES
};
- /* destroy all module classes */
+ /* destroy all module classes */
#undef FT_USE_MODULE
-#define FT_USE_MODULE( type, x ) \
- if ( classes[i] ) { FT_Destroy_Class_##x(library, classes[i]); } \
- i++; \
+#define FT_USE_MODULE( type, x ) \
+ if ( classes[i] ) \
+ { \
+ FT_Destroy_Class_ ## x( library, classes[i] ); \
+ } \
+ i++;
+
FT_BASE_DEF( void )
ft_destroy_default_module_classes( FT_Library library )
{
- FT_Module_Class** classes;
- FT_Memory memory;
- FT_UInt i;
- BasePIC* pic_container = (BasePIC*)library->pic_container.base;
+ FT_Module_Class* *classes;
+ FT_Memory memory;
+ FT_UInt i;
+ BasePIC* pic_container = (BasePIC*)library->pic_container.base;
+
if ( !pic_container->default_module_classes )
return;
- memory = library->memory;
+ memory = library->memory;
classes = pic_container->default_module_classes;
- i = 0;
+ i = 0;
#include FT_CONFIG_MODULES_H
@@ -130,30 +141,37 @@
pic_container->default_module_classes = 0;
}
+
/* initialize all module classes and the pointer table */
#undef FT_USE_MODULE
-#define FT_USE_MODULE( type, x ) \
- error = FT_Create_Class_##x(library, &clazz); \
- if (error) goto Exit; \
+#define FT_USE_MODULE( type, x ) \
+ error = FT_Create_Class_ ## x( library, &clazz ); \
+ if ( error ) \
+ goto Exit; \
classes[i++] = clazz;
+
FT_BASE_DEF( FT_Error )
ft_create_default_module_classes( FT_Library library )
{
- FT_Error error;
- FT_Memory memory;
- FT_Module_Class** classes;
- FT_Module_Class* clazz;
- FT_UInt i;
- BasePIC* pic_container = (BasePIC*)library->pic_container.base;
-
- memory = library->memory;
+ FT_Error error;
+ FT_Memory memory;
+ FT_Module_Class* *classes = NULL;
+ FT_Module_Class* clazz;
+ FT_UInt i;
+ BasePIC* pic_container = (BasePIC*)library->pic_container.base;
+
+
+ memory = library->memory;
+
pic_container->default_module_classes = 0;
- if ( FT_ALLOC(classes, sizeof(FT_Module_Class*) * (FT_NUM_MODULE_CLASSES + 1) ) )
+ if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) *
+ ( FT_NUM_MODULE_CLASSES + 1 ) ) )
return error;
+
/* initialize all pointers to 0, especially the last one */
- for (i = 0; i < FT_NUM_MODULE_CLASSES; i++)
+ for ( i = 0; i < FT_NUM_MODULE_CLASSES; i++ )
classes[i] = 0;
classes[FT_NUM_MODULE_CLASSES] = 0;
@@ -161,16 +179,19 @@
#include FT_CONFIG_MODULES_H
-Exit:
- if (error) ft_destroy_default_module_classes( library );
- else pic_container->default_module_classes = classes;
+ Exit:
+ if ( error )
+ ft_destroy_default_module_classes( library );
+ else
+ pic_container->default_module_classes = classes;
- return error;
+ return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
+
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( void )
@@ -180,9 +201,18 @@ Exit:
const FT_Module_Class* const* cur;
- /* test for valid `library' delayed to FT_Add_Module() */
+ /* FT_DEFAULT_MODULES_GET dereferences `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+ if ( !library )
+ return;
+#endif
+
+ /* GCC 4.6 warns the type difference:
+ * FT_Module_Class** != const FT_Module_Class* const*
+ */
+ cur = (const FT_Module_Class* const*)FT_DEFAULT_MODULES_GET;
- cur = FT_DEFAULT_MODULES_GET;
+ /* test for valid `library' delayed to FT_Add_Module() */
while ( *cur )
{
error = FT_Add_Module( library, *cur );
@@ -205,6 +235,8 @@ Exit:
FT_Memory memory;
+ /* check of `alibrary' delayed to `FT_New_Library' */
+
/* First of all, allocate a new system object -- this function is part */
/* of the system-specific component, i.e. `ftsystem.c'. */
@@ -212,7 +244,7 @@ Exit:
if ( !memory )
{
FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
/* build a library out of it, then fill it with the set of */
@@ -233,17 +265,19 @@ Exit:
FT_EXPORT_DEF( FT_Error )
FT_Done_FreeType( FT_Library library )
{
- if ( library )
- {
- FT_Memory memory = library->memory;
+ FT_Memory memory;
- /* Discard the library object */
- FT_Done_Library( library );
+ if ( !library )
+ return FT_THROW( Invalid_Library_Handle );
- /* discard memory manager */
- FT_Done_Memory( memory );
- }
+ memory = library->memory;
+
+ /* Discard the library object */
+ FT_Done_Library( library );
+
+ /* discard memory manager */
+ FT_Done_Memory( memory );
return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/base/ftlcdfil.c b/src/3rdparty/freetype/src/base/ftlcdfil.c
index 80640111c4..d8bcbbf1d2 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, 2008, 2009 by */
+/* Copyright 2006, 2008-2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_LCD_FILTER_H
#include FT_IMAGE_H
#include FT_INTERNAL_OBJECTS_H
@@ -44,9 +46,16 @@
FT_Byte* line = bitmap->buffer;
+ /* take care of bitmap flow */
+ if ( bitmap->pitch < 0 )
+ line -= bitmap->pitch * ( bitmap->rows - 1 );
+
+ /* `fir' and `pix' must be at least 32 bit wide, since the sum of */
+ /* the values in `weights' can exceed 0xFF */
+
for ( ; height > 0; height--, line += bitmap->pitch )
{
- FT_UInt fir[5];
+ FT_UInt fir[4]; /* below, `pix' is used as the 5th element */
FT_UInt val1, xx;
@@ -55,7 +64,6 @@
fir[1] = weights[3] * val1;
fir[2] = weights[4] * val1;
fir[3] = 0;
- fir[4] = 0;
val1 = line[1];
fir[0] += weights[1] * val1;
@@ -76,7 +84,7 @@
fir[3] = weights[4] * val;
pix >>= 8;
- pix |= -( pix >> 8 );
+ pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
line[xx - 2] = (FT_Byte)pix;
}
@@ -85,11 +93,11 @@
pix = fir[0] >> 8;
- pix |= -( pix >> 8 );
+ pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
line[xx - 2] = (FT_Byte)pix;
pix = fir[1] >> 8;
- pix |= -( pix >> 8 );
+ pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
line[xx - 1] = (FT_Byte)pix;
}
}
@@ -102,10 +110,14 @@
FT_Int pitch = bitmap->pitch;
+ /* take care of bitmap flow */
+ if ( bitmap->pitch < 0 )
+ column -= bitmap->pitch * ( bitmap->rows - 1 );
+
for ( ; width > 0; width--, column++ )
{
FT_Byte* col = column;
- FT_UInt fir[5];
+ FT_UInt fir[4]; /* below, `pix' is used as the 5th element */
FT_UInt val1, yy;
@@ -114,7 +126,6 @@
fir[1] = weights[3] * val1;
fir[2] = weights[4] * val1;
fir[3] = 0;
- fir[4] = 0;
col += pitch;
val1 = col[0];
@@ -137,7 +148,7 @@
fir[3] = weights[4] * val;
pix >>= 8;
- pix |= -( pix >> 8 );
+ pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
col[-2 * pitch] = (FT_Byte)pix;
col += pitch;
}
@@ -147,11 +158,11 @@
pix = fir[0] >> 8;
- pix |= -( pix >> 8 );
+ pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
col[-2 * pitch] = (FT_Byte)pix;
pix = fir[1] >> 8;
- pix |= -( pix >> 8 );
+ pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
col[-pitch] = (FT_Byte)pix;
}
}
@@ -187,6 +198,10 @@
FT_Byte* line = bitmap->buffer;
+ /* take care of bitmap flow */
+ if ( bitmap->pitch < 0 )
+ line -= bitmap->pitch * ( bitmap->rows - 1 );
+
for ( ; height > 0; height--, line += pitch )
{
FT_UInt xx;
@@ -226,6 +241,10 @@
FT_Byte* column = bitmap->buffer;
+ /* take care of bitmap flow */
+ if ( bitmap->pitch < 0 )
+ column -= bitmap->pitch * ( bitmap->rows - 1 );
+
for ( ; width > 0; width--, column++ )
{
FT_Byte* col = column;
@@ -267,19 +286,35 @@
FT_EXPORT_DEF( FT_Error )
- FT_Library_SetLcdFilter( FT_Library library,
- FT_LcdFilter filter )
+ FT_Library_SetLcdFilterWeights( FT_Library library,
+ unsigned char *weights )
+ {
+ if ( !library )
+ return FT_THROW( Invalid_Library_Handle );
+
+ if ( !weights )
+ return FT_THROW( Invalid_Argument );
+
+ ft_memcpy( library->lcd_weights, weights, 5 );
+
+ return FT_Err_Ok;
+ }
+
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Library_SetLcdFilter( FT_Library library,
+ FT_LcdFilter filter )
{
static const FT_Byte light_filter[5] =
- { 0, 85, 86, 85, 0 };
+ { 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 };
- if ( library == NULL )
- return FT_Err_Invalid_Argument;
+ if ( !library )
+ return FT_THROW( Invalid_Library_Handle );
switch ( filter )
{
@@ -326,23 +361,35 @@
#endif
default:
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
library->lcd_filter = filter;
- return 0;
+
+ return FT_Err_Ok;
}
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
FT_EXPORT_DEF( FT_Error )
+ FT_Library_SetLcdFilterWeights( FT_Library library,
+ unsigned char *weights )
+ {
+ FT_UNUSED( library );
+ FT_UNUSED( weights );
+
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+
+ FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )
{
FT_UNUSED( library );
FT_UNUSED( filter );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
diff --git a/src/3rdparty/freetype/src/base/ftmac.c b/src/3rdparty/freetype/src/base/ftmac.c
index 63f927d57d..5301ab44fc 100644
--- a/src/3rdparty/freetype/src/base/ftmac.c
+++ b/src/3rdparty/freetype/src/base/ftmac.c
@@ -8,8 +8,7 @@
/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */
/* classic platforms built by MPW. */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, */
-/* 2009 by */
+/* Copyright 1996-2009, 2013, 2014 by */
/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -119,6 +118,8 @@
#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,
@@ -129,7 +130,7 @@
FT_UNUSED( pathSpec );
FT_UNUSED( face_index );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
@@ -144,7 +145,7 @@
{
#if defined( MAC_OS_X_VERSION_10_5 ) && \
( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
-
+
OSStatus err;
err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
@@ -188,10 +189,10 @@
CFRelease( cf_fontName );
if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
/* face_index calculation by searching preceding fontIDs */
/* with same FSRef */
@@ -226,12 +227,15 @@
FT_Error err;
+ if ( !fontName || !face_index )
+ return FT_THROW( Invalid_Argument) ;
+
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( FT_Err_Ok != err )
+ if ( err )
return err;
if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
return FT_Err_Ok;
}
@@ -249,19 +253,22 @@
FT_UNUSED( pathSpec );
FT_UNUSED( face_index );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
#else
FSRef ref;
FT_Error err;
+ if ( !fontName || !face_index )
+ return FT_THROW( Invalid_Argument );
+
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( FT_Err_Ok != err )
+ if ( err )
return err;
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
pathSpec, NULL ) )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
return FT_Err_Ok;
#endif
@@ -277,7 +284,7 @@
if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
/* at present, no support for dfont format */
err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
@@ -357,11 +364,9 @@
count_faces_scalable( char* fond_data )
{
AsscEntry* assoc;
- FamRec* fond;
short i, face, face_all;
- fond = (FamRec*)fond_data;
face_all = EndianS16_BtoN( *( (short *)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
@@ -441,9 +446,10 @@
style = (StyleTable*)p;
p += sizeof ( StyleTable );
string_count = EndianS16_BtoN( *(short*)(p) );
+ string_count = FT_MIN( 64, string_count );
p += sizeof ( short );
- for ( i = 0; i < string_count && i < 64; i++ )
+ for ( i = 0; i < string_count; i++ )
{
names[i] = p;
p += names[i][0];
@@ -460,7 +466,7 @@
ps_name[ps_name_len] = 0;
}
if ( style->indexes[face_index] > 1 &&
- style->indexes[face_index] <= FT_MIN( string_count, 64 ) )
+ style->indexes[face_index] <= string_count )
{
unsigned char* suffixes = names[style->indexes[face_index] - 1];
@@ -506,17 +512,17 @@
/* We should not extract parent directory by string manipulation. */
if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, &par_ref ) )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* now we have absolute dirname in path_lwfn */
ft_strcat( (char *)path_lwfn, "/" );
@@ -525,11 +531,11 @@
path_lwfn[dirname_len + base_lwfn[0]] = '\0';
if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, NULL ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
return FT_Err_Ok;
}
@@ -555,7 +561,7 @@
{
err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
buff, sizeof ( buff ) );
- if ( FT_Err_Ok == err )
+ if ( !err )
have_lwfn = 1;
}
@@ -618,7 +624,7 @@
/* detect integer overflows */
if ( total_size < old_total_size )
{
- error = FT_Err_Array_Too_Large;
+ error = FT_THROW( Array_Too_Large );
goto Error;
}
@@ -703,7 +709,7 @@
if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
pfb_data = NULL;
pfb_size = 0;
@@ -738,7 +744,7 @@
sfnt = GetResource( TTAG_sfnt, sfnt_id );
if ( sfnt == NULL )
- return FT_Err_Invalid_Handle;
+ return FT_THROW( Invalid_Handle );
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
@@ -795,23 +801,26 @@
FT_Long face_index,
FT_Face* aface )
{
- FT_Error error = FT_Err_Cannot_Open_Resource;
+ FT_Error error = FT_ERR( Cannot_Open_Resource );
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
- short num_faces_in_res, num_faces_in_fond;
+ short num_faces_in_res;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
UseResFile( res_ref );
if ( ResError() )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
{
+ short num_faces_in_fond;
+
+
fond = Get1IndResource( TTAG_FOND, res_index );
if ( ResError() )
break;
@@ -826,7 +835,7 @@
}
CloseResFile( res_ref );
- if ( FT_Err_Ok == error && NULL != aface && NULL != *aface )
+ if ( !error && aface && *aface )
(*aface)->num_faces = num_faces_in_res;
return error;
}
@@ -850,9 +859,11 @@
FT_Error error = FT_Err_Ok;
+ /* check of `library' and `aface' delayed to `FT_New_Face_From_XXX' */
+
GetResInfo( fond, &fond_id, &fond_type, fond_name );
if ( ResError() != noErr || fond_type != TTAG_FOND )
- return FT_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
@@ -881,7 +892,7 @@
error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
path_lwfn, sizeof ( path_lwfn ) );
- if ( FT_Err_Ok == error )
+ if ( !error )
have_lwfn = 1;
}
}
@@ -892,10 +903,10 @@
face_index,
aface );
else
- error = FT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
found_no_lwfn_file:
- if ( have_sfnt && FT_Err_Ok != error )
+ if ( have_sfnt && error )
error = FT_New_Face_From_SFNT( library,
sfnt_id,
face_index,
@@ -959,9 +970,8 @@
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
if ( !pathname )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
- error = FT_Err_Ok;
*aface = NULL;
/* try resourcefork based font: LWFN, FFIL */
@@ -996,16 +1006,20 @@
{
FT_Error error;
FT_Open_Args args;
- OSErr err;
- UInt8 pathname[PATH_MAX];
+
+ OSErr err;
+ UInt8 pathname[PATH_MAX];
+ /* check of `library' and `aface' delayed to */
+ /* `FT_New_Face_From_Resource' */
+
if ( !ref )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
if ( err )
- error = FT_Err_Cannot_Open_Resource;
+ error = FT_THROW( Cannot_Open_Resource );
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
if ( error != 0 || *aface != NULL )
@@ -1041,17 +1055,21 @@
FT_UNUSED( face_index );
FT_UNUSED( aface );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
#else
FSRef ref;
+ /* check of `library' and `aface' delayed to `FT_New_Face_From_FSRef' */
+
if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
else
return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
#endif
}
+#endif /* FT_MACINTOSH */
+
/* END */
diff --git a/src/3rdparty/freetype/src/base/ftmm.c b/src/3rdparty/freetype/src/base/ftmm.c
index 0307729811..056680bd60 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-2001, 2003, 2004, 2009 by */
+/* Copyright 1996-2001, 2003, 2004, 2009, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_MULTIPLE_MASTERS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
@@ -42,9 +44,9 @@
*aservice = NULL;
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
{
@@ -70,10 +72,15 @@
FT_Service_MultiMasters service;
+ /* check of `face' delayed to `ft_face_get_mm_service' */
+
+ if ( !amaster )
+ return FT_THROW( Invalid_Argument );
+
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->get_mm )
error = service->get_mm( face, amaster );
}
@@ -92,10 +99,15 @@
FT_Service_MultiMasters service;
+ /* check of `face' delayed to `ft_face_get_mm_service' */
+
+ if ( !amaster )
+ return FT_THROW( Invalid_Argument );
+
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->get_mm_var )
error = service->get_mm_var( face, amaster );
}
@@ -115,10 +127,15 @@
FT_Service_MultiMasters service;
+ /* check of `face' delayed to `ft_face_get_mm_service' */
+
+ if ( !coords )
+ return FT_THROW( Invalid_Argument );
+
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_mm_design )
error = service->set_mm_design( face, num_coords, coords );
}
@@ -138,10 +155,15 @@
FT_Service_MultiMasters service;
+ /* check of `face' delayed to `ft_face_get_mm_service' */
+
+ if ( !coords )
+ return FT_THROW( Invalid_Argument );
+
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_var_design )
error = service->set_var_design( face, num_coords, coords );
}
@@ -161,10 +183,15 @@
FT_Service_MultiMasters service;
+ /* check of `face' delayed to `ft_face_get_mm_service' */
+
+ if ( !coords )
+ return FT_THROW( Invalid_Argument );
+
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_mm_blend )
error = service->set_mm_blend( face, num_coords, coords );
}
@@ -187,10 +214,15 @@
FT_Service_MultiMasters service;
+ /* check of `face' delayed to `ft_face_get_mm_service' */
+
+ if ( !coords )
+ return FT_THROW( Invalid_Argument );
+
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_mm_blend )
error = service->set_mm_blend( face, num_coords, coords );
}
diff --git a/src/3rdparty/freetype/src/base/ftobjs.c b/src/3rdparty/freetype/src/base/ftobjs.c
index 3403188594..ee15a016c7 100644
--- a/src/3rdparty/freetype/src/base/ftobjs.c
+++ b/src/3rdparty/freetype/src/base/ftobjs.c
@@ -4,8 +4,7 @@
/* */
/* The FreeType private base classes (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
-/* 2010 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,8 +28,8 @@
#include FT_TRUETYPE_TABLES_H
#include FT_TRUETYPE_TAGS_H
#include FT_TRUETYPE_IDS_H
-#include FT_OUTLINE_H
+#include FT_SERVICE_PROPERTIES_H
#include FT_SERVICE_SFNT_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_GLYPH_DICT_H
@@ -42,6 +41,30 @@
#include "ftbase.h"
#endif
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+#include FT_BITMAP_H
+
+#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
+ /* We disable the warning `conversion from XXX to YYY, */
+ /* possible loss of data' in order to compile cleanly with */
+ /* the maximum level of warnings: `md5.c' is non-FreeType */
+ /* code, and it gets used during development builds only. */
+#pragma warning( push )
+#pragma warning( disable : 4244 )
+#endif /* _MSC_VER */
+
+ /* it's easiest to include `md5.c' directly */
+#include "md5.c"
+
+#if defined( _MSC_VER )
+#pragma warning( pop )
+#endif
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+
#define GRID_FIT_METRICS
@@ -132,18 +155,18 @@
{
FT_Error error;
FT_Memory memory;
- FT_Stream stream;
+ FT_Stream stream = NULL;
*astream = 0;
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !args )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
- memory = library->memory;
+ memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
@@ -157,6 +180,9 @@
(const FT_Byte*)args->memory_base,
args->memory_size );
}
+
+#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
+
else if ( args->flags & FT_OPEN_PATHNAME )
{
/* create a normal system stream */
@@ -172,8 +198,11 @@
FT_FREE( stream );
stream = args->stream;
}
+
+#endif
+
else
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
if ( error )
FT_FREE( stream );
@@ -230,11 +259,11 @@
static FT_Error
ft_glyphslot_init( FT_GlyphSlot slot )
{
- FT_Driver driver = slot->face->driver;
- FT_Driver_Class clazz = driver->clazz;
- FT_Memory memory = driver->root.memory;
- FT_Error error = FT_Err_Ok;
- FT_Slot_Internal internal;
+ FT_Driver driver = slot->face->driver;
+ FT_Driver_Class clazz = driver->clazz;
+ FT_Memory memory = driver->root.memory;
+ FT_Error error = FT_Err_Ok;
+ FT_Slot_Internal internal = NULL;
slot->library = driver->root.library;
@@ -376,11 +405,14 @@
FT_Driver driver;
FT_Driver_Class clazz;
FT_Memory memory;
- FT_GlyphSlot slot;
+ FT_GlyphSlot slot = NULL;
- if ( !face || !face->driver )
- return FT_Err_Invalid_Argument;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !face->driver )
+ return FT_THROW( Invalid_Argument );
driver = face->driver;
clazz = driver->clazz;
@@ -441,6 +473,10 @@
else
prev->next = cur->next;
+ /* finalize client-specific data */
+ if ( slot->generic.finalizer )
+ slot->generic.finalizer( slot );
+
ft_glyphslot_done( slot );
FT_FREE( slot );
break;
@@ -475,6 +511,7 @@
internal->transform_matrix.xy = 0;
internal->transform_matrix.yx = 0;
internal->transform_matrix.yy = 0x10000L;
+
matrix = &internal->transform_matrix;
}
else
@@ -490,6 +527,7 @@
{
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
+
delta = &internal->transform_delta;
}
else
@@ -562,10 +600,11 @@
FT_Library library;
FT_Bool autohint = FALSE;
FT_Module hinter;
+ TT_Face ttface = (TT_Face)face;
if ( !face || !face->size || !face->glyph )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
/* The validity test for `glyph_index' is performed by the */
/* font drivers. */
@@ -602,7 +641,8 @@
* - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
* have a native font hinter.
*
- * - Otherwise, auto-hint for LIGHT hinting mode.
+ * - Otherwise, auto-hint for LIGHT hinting mode or if there isn't
+ * any hinting bytecode in the TrueType/OpenType font.
*
* - Exception: The font is `tricky' and requires the native hinter to
* load properly.
@@ -614,7 +654,8 @@
FT_DRIVER_IS_SCALABLE( driver ) &&
FT_DRIVER_USES_OUTLINES( driver ) &&
!FT_IS_TRICKY( face ) &&
- ( ( face->internal->transform_matrix.yx == 0 &&
+ ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) ||
+ ( face->internal->transform_matrix.yx == 0 &&
face->internal->transform_matrix.xx != 0 ) ||
( face->internal->transform_matrix.xx == 0 &&
face->internal->transform_matrix.yx != 0 ) ) )
@@ -627,15 +668,27 @@
FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
- if ( mode == FT_RENDER_MODE_LIGHT ||
- face->internal->ignore_unpatented_hinter )
+ /* the check for `num_locations' assures that we actually */
+ /* test for instructions in a TTF and not in a CFF-based OTF */
+ /* */
+ /* since `maxSizeOfInstructions' might be unreliable, we */
+ /* 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 ||
+ ( FT_IS_SFNT( face ) &&
+ ttface->num_locations &&
+ ttface->max_profile.maxSizeOfInstructions == 0 &&
+ ttface->font_program_size == 0 &&
+ ttface->cvt_program_size == 0 ) )
autohint = TRUE;
}
}
if ( autohint )
{
- FT_AutoHinter_Service hinting;
+ FT_AutoHinter_Interface hinting;
/* try to load embedded bitmaps first if available */
@@ -664,7 +717,7 @@
internal->transform_flags = 0;
/* load auto-hinted outline */
- hinting = (FT_AutoHinter_Service)hinter->clazz->module_interface;
+ hinting = (FT_AutoHinter_Interface)hinter->clazz->module_interface;
error = hinting->load_glyph( (FT_AutoHinter)hinter,
slot, face->size,
@@ -745,11 +798,11 @@
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
/* apply `standard' transformation if no renderer is available */
- if ( &internal->transform_matrix )
+ if ( internal->transform_flags & 1 )
FT_Outline_Transform( &slot->outline,
&internal->transform_matrix );
- if ( &internal->transform_delta )
+ if ( internal->transform_flags & 2 )
FT_Outline_Translate( &slot->outline,
internal->transform_delta.x,
internal->transform_delta.y );
@@ -798,7 +851,7 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
glyph_index = (FT_UInt)char_code;
if ( face->charmap )
@@ -949,7 +1002,7 @@
first = face->charmaps;
if ( !first )
- return FT_Err_Invalid_CharMap_Handle;
+ return FT_THROW( Invalid_CharMap_Handle );
/*
* The original TrueType specification(s) only specified charmap
@@ -1011,7 +1064,7 @@
}
}
- return FT_Err_Invalid_CharMap_Handle;
+ return FT_THROW( Invalid_CharMap_Handle );
}
@@ -1064,7 +1117,8 @@
/* */
static FT_Error
open_face( FT_Driver driver,
- FT_Stream stream,
+ FT_Stream *astream,
+ FT_Bool external_stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter* params,
@@ -1072,10 +1126,11 @@
{
FT_Memory memory;
FT_Driver_Class clazz;
- FT_Face face = 0;
- FT_Error error, error2;
+ FT_Face face = NULL;
FT_Face_Internal internal = NULL;
+ FT_Error error, error2;
+
clazz = driver->clazz;
memory = driver->root.memory;
@@ -1084,15 +1139,19 @@
if ( FT_ALLOC( face, clazz->face_object_size ) )
goto Fail;
+ face->driver = driver;
+ face->memory = memory;
+ face->stream = *astream;
+
+ /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
+ if ( external_stream )
+ face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
+
if ( FT_NEW( internal ) )
goto Fail;
face->internal = internal;
- face->driver = driver;
- face->memory = memory;
- face->stream = stream;
-
#ifdef FT_CONFIG_OPTION_INCREMENTAL
{
int i;
@@ -1108,11 +1167,12 @@
#endif
if ( clazz->init_face )
- error = clazz->init_face( stream,
+ error = clazz->init_face( *astream,
face,
(FT_Int)face_index,
num_params,
params );
+ *astream = face->stream; /* Stream may have been changed. */
if ( error )
goto Fail;
@@ -1123,7 +1183,7 @@
/* is returned. */
/* no error should happen, but we want to play safe */
- if ( error2 && error2 != FT_Err_Invalid_CharMap_Handle )
+ if ( error2 && FT_ERR_NEQ( error2, Invalid_CharMap_Handle ) )
{
error = error2;
goto Fail;
@@ -1135,7 +1195,7 @@
if ( error )
{
destroy_charmaps( face, memory );
- if ( clazz->done_face && face )
+ if ( clazz->done_face )
clazz->done_face( face );
FT_FREE( internal );
FT_FREE( face );
@@ -1149,7 +1209,7 @@
/* there's a Mac-specific extended implementation of FT_New_Face() */
/* in src/base/ftmac.c */
-#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON )
+#ifndef FT_MACINTOSH
/* documentation is in freetype.h */
@@ -1162,9 +1222,9 @@
FT_Open_Args args;
- /* test for valid `library' and `aface' delayed to FT_Open_Face() */
+ /* test for valid `library' and `aface' delayed to `FT_Open_Face' */
if ( !pathname )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
@@ -1173,7 +1233,7 @@
return FT_Open_Face( library, &args, face_index, aface );
}
-#endif /* defined( FT_MACINTOSH ) && !defined( DARWIN_NO_CARBON ) */
+#endif
/* documentation is in freetype.h */
@@ -1188,9 +1248,9 @@
FT_Open_Args args;
- /* test for valid `library' and `face' delayed to FT_Open_Face() */
+ /* test for valid `library' and `face' delayed to `FT_Open_Face' */
if ( !file_base )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
args.flags = FT_OPEN_MEMORY;
args.memory_base = file_base;
@@ -1258,14 +1318,14 @@
{
FT_Error error;
FT_Memory memory;
- FT_Stream stream;
+ FT_Stream stream = NULL;
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !base )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*astream = 0;
memory = library->memory;
@@ -1379,7 +1439,7 @@
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag != TTAG_typ1 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
if ( FT_READ_USHORT( numTables ) )
return error;
@@ -1416,7 +1476,7 @@
if ( face_index >= 0 && pstable_index == face_index )
return FT_Err_Ok;
}
- return FT_Err_Table_Missing;
+ return FT_THROW( Table_Missing );
}
@@ -1433,7 +1493,7 @@
FT_ULong offset, length;
FT_Long pos;
FT_Bool is_sfnt_cid;
- FT_Byte* sfnt_ps;
+ FT_Byte* sfnt_ps = NULL;
FT_UNUSED( num_params );
FT_UNUSED( params );
@@ -1462,7 +1522,7 @@
error = open_face_from_buffer( library,
sfnt_ps,
length,
- face_index < 0 ? face_index : 0,
+ FT_MIN( face_index, 0 ),
is_sfnt_cid ? "cid" : "type1",
aface );
Exit:
@@ -1470,7 +1530,7 @@
FT_Error error1;
- if ( error == FT_Err_Unknown_File_Format )
+ if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
error1 = FT_Stream_Seek( stream, pos );
if ( error1 )
@@ -1482,7 +1542,7 @@
}
-#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON )
+#ifndef FT_MACINTOSH
/* The resource header says we've got resource_cnt `POST' (type1) */
/* resources in this file. They all need to be coalesced into */
@@ -1498,13 +1558,13 @@
FT_Long face_index,
FT_Face *aface )
{
- FT_Error error = FT_Err_Cannot_Open_Resource;
+ FT_Error error = FT_ERR( Cannot_Open_Resource );
FT_Memory memory = library->memory;
- FT_Byte* pfb_data;
+ FT_Byte* pfb_data = NULL;
int i, type, flags;
- FT_Long len;
- FT_Long pfb_len, pfb_pos, pfb_lenpos;
- FT_Long rlen, temp;
+ FT_ULong len;
+ FT_ULong pfb_len, pfb_pos, pfb_lenpos;
+ FT_ULong rlen, temp;
if ( face_index == -1 )
@@ -1520,11 +1580,34 @@
error = FT_Stream_Seek( stream, offsets[i] );
if ( error )
goto Exit;
- if ( FT_READ_LONG( temp ) )
+ if ( FT_READ_ULONG( temp ) )
+ goto Exit;
+
+ /* FT2 allocator takes signed long buffer length,
+ * too large value causing overflow should be checked
+ */
+ FT_TRACE4(( " POST fragment #%d: length=0x%08x\n",
+ i, temp));
+ if ( 0x7FFFFFFFUL < temp || pfb_len + temp + 6 < pfb_len )
+ {
+ FT_TRACE2(( " too long fragment length makes"
+ " pfb_len confused: temp=0x%08x\n", temp ));
+ error = FT_THROW( Invalid_Offset );
goto Exit;
+ }
+
pfb_len += temp + 6;
}
+ FT_TRACE2(( " total buffer size to concatenate %d"
+ " POST fragments: 0x%08x\n",
+ resource_cnt, pfb_len + 2));
+ if ( pfb_len + 2 < 6 ) {
+ FT_TRACE2(( " too long fragment length makes"
+ " pfb_len confused: pfb_len=0x%08x\n", pfb_len ));
+ error = FT_THROW( Array_Too_Large );
+ goto Exit;
+ }
if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
goto Exit;
@@ -1544,15 +1627,46 @@
error = FT_Stream_Seek( stream, offsets[i] );
if ( error )
goto Exit2;
- if ( FT_READ_LONG( rlen ) )
- goto Exit;
+ if ( FT_READ_ULONG( rlen ) )
+ goto Exit2;
+
+ /* FT2 allocator takes signed long buffer length,
+ * too large fragment length causing overflow should be checked
+ */
+ if ( 0x7FFFFFFFUL < rlen )
+ {
+ error = FT_THROW( Invalid_Offset );
+ goto Exit2;
+ }
+
if ( FT_READ_USHORT( flags ) )
- goto Exit;
- rlen -= 2; /* the flags are part of the resource */
+ goto Exit2;
+ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
+ i, offsets[i], rlen, flags ));
+
+ error = FT_ERR( Array_Too_Large );
+ /* postpone the check of rlen longer than buffer until FT_Stream_Read() */
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ {
+ FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n", i ));
+ continue;
+ }
+
+ /* the flags are part of the resource, so rlen >= 2. */
+ /* but some fonts declare rlen = 0 for empty fragment */
+ if ( rlen > 2 )
+ rlen -= 2;
+ else
+ rlen = 0;
+
if ( ( flags >> 8 ) == type )
len += rlen;
else
{
+ FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer"
+ " 0x%p + 0x%08x\n", i, pfb_data, pfb_lenpos ));
+ if ( pfb_lenpos + 3 > pfb_len + 2 )
+ goto Exit2;
pfb_data[pfb_lenpos ] = (FT_Byte)( len );
pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
@@ -1561,6 +1675,10 @@
if ( ( flags >> 8 ) == 5 ) /* End of font mark */
break;
+ FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer"
+ " 0x%p + 0x%08x\n", i, pfb_data, pfb_pos ));
+ if ( pfb_pos + 6 > pfb_len + 2 )
+ goto Exit2;
pfb_data[pfb_pos++] = 0x80;
type = flags >> 8;
@@ -1574,13 +1692,25 @@
pfb_data[pfb_pos++] = 0;
}
+ if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
+ goto Exit2;
+
+ FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer"
+ " 0x%p + 0x%08x\n", i, rlen, pfb_data, pfb_pos ));
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
+ if ( error )
+ goto Exit2;
pfb_pos += rlen;
}
+ error = FT_ERR( Array_Too_Large );
+ if ( pfb_pos + 2 > pfb_len + 2 )
+ goto Exit2;
pfb_data[pfb_pos++] = 0x80;
pfb_data[pfb_pos++] = 3;
+ 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 );
@@ -1594,6 +1724,13 @@
aface );
Exit2:
+ if ( error == FT_ERR( Array_Too_Large ) )
+ FT_TRACE2(( " Abort due to too-short buffer to store"
+ " all POST fragments\n" ));
+ else if ( error == FT_ERR( Invalid_Offset ) )
+ FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" ));
+ if ( error )
+ error = FT_ERR( Cannot_Open_Resource );
FT_FREE( pfb_data );
Exit:
@@ -1615,7 +1752,7 @@
FT_Face *aface )
{
FT_Memory memory = library->memory;
- FT_Byte* sfnt_data;
+ FT_Byte* sfnt_data = NULL;
FT_Error error;
FT_Long flag_offset;
FT_Long rlen;
@@ -1626,7 +1763,7 @@
if ( face_index == -1 )
face_index = 0;
if ( face_index >= resource_cnt )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
flag_offset = offsets[face_index];
error = FT_Stream_Seek( stream, flag_offset );
@@ -1636,7 +1773,7 @@
if ( FT_READ_LONG( rlen ) )
goto Exit;
if ( rlen == -1 )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
error = open_face_PS_from_sfnt_stream( library,
stream,
@@ -1693,9 +1830,10 @@
if ( error )
return error;
+ /* POST resources must be sorted to concatenate properly */
error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdara_pos,
- TTAG_POST,
+ TTAG_POST, TRUE,
&data_offsets, &count );
if ( !error )
{
@@ -1708,9 +1846,11 @@
return error;
}
+ /* 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,
- TTAG_sfnt,
+ TTAG_sfnt, FALSE,
&data_offsets, &count );
if ( !error )
{
@@ -1743,7 +1883,7 @@
if ( NULL == stream )
- return FT_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
error = FT_Stream_Seek( stream, 0 );
if ( error )
@@ -1760,7 +1900,7 @@
header[ 1] > 33 ||
header[63] != 0 ||
header[2 + header[1]] != 0 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
dlen = ( header[0x53] << 24 ) |
( header[0x54] << 16 ) |
@@ -1770,7 +1910,7 @@
rlen = ( header[0x57] << 24 ) |
( header[0x58] << 16 ) |
( header[0x59] << 8 ) |
- header[0x5a];
+ header[0x5A];
#endif /* 0 */
offset = 128 + ( ( dlen + 127 ) & ~127 );
@@ -1793,12 +1933,13 @@
#define FT_COMPONENT trace_raccess
FT_Memory memory = library->memory;
- FT_Error error = FT_Err_Unknown_File_Format;
+ FT_Error error = FT_ERR( Unknown_File_Format );
int i;
char * file_names[FT_RACCESS_N_RULES];
FT_Long offsets[FT_RACCESS_N_RULES];
FT_Error errors[FT_RACCESS_N_RULES];
+ FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */
FT_Open_Args args2;
FT_Stream stream2 = 0;
@@ -1809,6 +1950,15 @@
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
+ is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i );
+ if ( is_darwin_vfs && vfs_rfork_has_no_font )
+ {
+ FT_TRACE3(( "Skip rule %d: darwin vfs resource fork"
+ " is already checked and"
+ " no font is found\n", i ));
+ continue;
+ }
+
if ( errors[i] )
{
FT_TRACE3(( "Error[%d] has occurred in rule %d\n", errors[i], i ));
@@ -1822,6 +1972,9 @@
i, args2.pathname, offsets[i] ));
error = FT_Stream_New( library, &args2, &stream2 );
+ if ( is_darwin_vfs && FT_ERR_EQ( error, Cannot_Open_Stream ) )
+ vfs_rfork_has_no_font = TRUE;
+
if ( error )
{
FT_TRACE3(( "failed\n" ));
@@ -1836,6 +1989,8 @@
if ( !error )
break;
+ else if ( is_darwin_vfs )
+ vfs_rfork_has_no_font = TRUE;
}
for (i = 0; i < FT_RACCESS_N_RULES; i++)
@@ -1846,7 +2001,7 @@
/* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */
if ( error )
- error = FT_Err_Unknown_File_Format;
+ error = FT_ERR( Unknown_File_Format );
return error;
@@ -1875,7 +2030,7 @@
error = IsMacBinary( library, stream, face_index, aface );
- if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format )
+ if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
#undef FT_COMPONENT
@@ -1892,9 +2047,9 @@
}
- if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ||
- FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) &&
- ( args->flags & FT_OPEN_PATHNAME ) )
+ if ( ( FT_ERR_EQ( error, Unknown_File_Format ) ||
+ FT_ERR_EQ( error, Invalid_Stream_Operation ) ) &&
+ ( args->flags & FT_OPEN_PATHNAME ) )
error = load_face_in_embedded_rfork( library, stream,
face_index, aface, args );
return error;
@@ -1913,21 +2068,20 @@
FT_Face *aface )
{
FT_Error error;
- FT_Driver driver;
- FT_Memory memory;
- FT_Stream stream = 0;
- FT_Face face = 0;
- FT_ListNode node = 0;
+ FT_Driver driver = NULL;
+ FT_Memory memory = NULL;
+ FT_Stream stream = NULL;
+ FT_Face face = NULL;
+ FT_ListNode node = NULL;
FT_Bool external_stream;
FT_Module* cur;
FT_Module* limit;
- /* test for valid `library' delayed to */
- /* FT_Stream_New() */
+ /* test for valid `library' delayed to `FT_Stream_New' */
if ( ( !aface && face_index >= 0 ) || !args )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
args->stream );
@@ -1958,24 +2112,25 @@
params = args->params;
}
- error = open_face( driver, stream, face_index,
+ error = open_face( driver, &stream, external_stream, face_index,
num_params, params, &face );
if ( !error )
goto Success;
}
else
- error = FT_Err_Invalid_Handle;
+ error = FT_THROW( Invalid_Handle );
FT_Stream_Free( stream, external_stream );
goto Fail;
}
else
{
+ error = FT_ERR( Missing_Module );
+
/* check each font driver for an appropriate format */
cur = library->modules;
limit = cur + library->num_modules;
-
for ( ; cur < limit; cur++ )
{
/* not all modules are font drivers, so check... */
@@ -1993,14 +2148,14 @@
params = args->params;
}
- error = open_face( driver, stream, face_index,
+ error = open_face( driver, &stream, external_stream, face_index,
num_params, params, &face );
if ( !error )
goto Success;
#ifdef FT_CONFIG_OPTION_MAC_FONTS
if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
- FT_ERROR_BASE( error ) == FT_Err_Table_Missing )
+ FT_ERR_EQ( error, Table_Missing ) )
{
/* TrueType but essential tables are missing */
if ( FT_Stream_Seek( stream, 0 ) )
@@ -2020,39 +2175,39 @@
}
#endif
- if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
+ if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
goto Fail3;
}
}
- Fail3:
- /* If we are on the mac, and we get an FT_Err_Invalid_Stream_Operation */
- /* it may be because we have an empty data fork, so we need to check */
- /* the resource fork. */
- if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream &&
- FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format &&
- FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation )
- goto Fail2;
+ Fail3:
+ /* If we are on the mac, and we get an */
+ /* FT_Err_Invalid_Stream_Operation it may be because we have an */
+ /* empty data fork, so we need to check the resource fork. */
+ if ( FT_ERR_NEQ( error, Cannot_Open_Stream ) &&
+ FT_ERR_NEQ( error, Unknown_File_Format ) &&
+ FT_ERR_NEQ( error, Invalid_Stream_Operation ) )
+ goto Fail2;
#if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS )
- 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;
- }
+ 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_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
- goto Fail2;
+ if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
+ goto Fail2;
#endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */
/* no driver is able to handle this format */
- error = FT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
Fail2:
FT_Stream_Free( stream, external_stream );
@@ -2062,10 +2217,6 @@
Success:
FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" ));
- /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
- if ( external_stream )
- face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
-
/* add the face object to its driver's list */
if ( FT_NEW( node ) )
goto Fail;
@@ -2141,6 +2292,8 @@
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
+
+ internal->refcount = 1;
}
if ( aface )
@@ -2151,7 +2304,10 @@
goto Exit;
Fail:
- FT_Done_Face( face );
+ if ( node )
+ FT_Done_Face( face ); /* face must be in the driver's list */
+ else if ( face )
+ destroy_face( memory, face, driver );
Exit:
FT_TRACE4(( "FT_Open_Face: Return %d\n", error ));
@@ -2169,10 +2325,10 @@
FT_Open_Args open;
- /* test for valid `face' delayed to FT_Attach_Stream() */
+ /* test for valid `face' delayed to `FT_Attach_Stream' */
if ( !filepathname )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
open.stream = NULL;
open.flags = FT_OPEN_PATHNAME;
@@ -2195,14 +2351,14 @@
FT_Driver_Class clazz;
- /* test for valid `parameters' delayed to FT_Stream_New() */
+ /* test for valid `parameters' delayed to `FT_Stream_New' */
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
driver = face->driver;
if ( !driver )
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
error = FT_Stream_New( driver->root.library, parameters, &stream );
if ( error )
@@ -2211,7 +2367,7 @@
/* we implement FT_Attach_Stream in each driver through the */
/* `attach_file' interface */
- error = FT_Err_Unimplemented_Feature;
+ error = FT_ERR( Unimplemented_Feature );
clazz = driver->clazz;
if ( clazz->attach_file )
error = clazz->attach_file( face, stream );
@@ -2229,6 +2385,20 @@
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
+ FT_Reference_Face( FT_Face face )
+ {
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
+
+ face->internal->refcount++;
+
+ return FT_Err_Ok;
+ }
+
+
+ /* documentation is in freetype.h */
+
+ FT_EXPORT_DEF( FT_Error )
FT_Done_Face( FT_Face face )
{
FT_Error error;
@@ -2237,25 +2407,32 @@
FT_ListNode node;
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_ERR( Invalid_Face_Handle );
if ( face && face->driver )
{
- driver = face->driver;
- memory = driver->root.memory;
-
- /* find face in driver's list */
- node = FT_List_Find( &driver->faces_list, face );
- if ( node )
+ face->internal->refcount--;
+ if ( face->internal->refcount > 0 )
+ error = FT_Err_Ok;
+ else
{
- /* remove face object from the driver's list */
- FT_List_Remove( &driver->faces_list, node );
- FT_FREE( node );
+ driver = face->driver;
+ memory = driver->root.memory;
- /* now destroy the object proper */
- destroy_face( memory, face, driver );
- error = FT_Err_Ok;
+ /* find face in driver's list */
+ node = FT_List_Find( &driver->faces_list, face );
+ if ( node )
+ {
+ /* remove face object from the driver's list */
+ FT_List_Remove( &driver->faces_list, node );
+ FT_FREE( node );
+
+ /* now destroy the object proper */
+ destroy_face( memory, face, driver );
+ error = FT_Err_Ok;
+ }
}
}
+
return error;
}
@@ -2276,13 +2453,13 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !asize )
- return FT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Argument );
if ( !face->driver )
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
*asize = 0;
@@ -2334,15 +2511,15 @@
if ( !size )
- return FT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Size_Handle );
face = size->face;
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
driver = face->driver;
if ( !driver )
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
memory = driver->root.memory;
@@ -2363,7 +2540,7 @@
destroy_size( memory, size, driver );
}
else
- error = FT_Err_Invalid_Size_Handle;
+ error = FT_THROW( Invalid_Size_Handle );
return error;
}
@@ -2382,11 +2559,11 @@
if ( !FT_HAS_FIXED_SIZES( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
/* FT_Bitmap_Size doesn't provide enough info... */
if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
w = FT_REQUEST_WIDTH ( req );
h = FT_REQUEST_HEIGHT( req );
@@ -2409,6 +2586,8 @@
if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width )
{
+ FT_TRACE3(( "FT_Match_Size: bitmap strike %d matches\n", i ));
+
if ( size_index )
*size_index = (FT_ULong)i;
@@ -2416,7 +2595,7 @@
}
}
- return FT_Err_Invalid_Pixel_Size;
+ return FT_THROW( Invalid_Pixel_Size );
}
@@ -2514,6 +2693,18 @@
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 ));
}
@@ -2622,6 +2813,18 @@
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 ));
}
@@ -2635,15 +2838,41 @@
if ( !face || !FT_HAS_FIXED_SIZES( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( strike_index < 0 || strike_index >= face->num_fixed_sizes )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
clazz = face->driver->clazz;
if ( clazz->select_size )
- return clazz->select_size( face->size, (FT_ULong)strike_index );
+ {
+ FT_Error error;
+
+
+ error = clazz->select_size( face->size, (FT_ULong)strike_index );
+
+#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
+
+ return error;
+ }
FT_Select_Metrics( face, (FT_ULong)strike_index );
@@ -2662,16 +2891,42 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !req || req->width < 0 || req->height < 0 ||
req->type >= FT_SIZE_REQUEST_TYPE_MAX )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
clazz = face->driver->clazz;
if ( clazz->request_size )
- return clazz->request_size( face->size, req );
+ {
+ 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;
+ }
/*
* The reason that a driver doesn't have `request_size' defined is
@@ -2689,9 +2944,6 @@
if ( error )
return error;
- FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n",
- strike_index ));
-
return FT_Select_Size( face, (FT_Int)strike_index );
}
@@ -2713,6 +2965,8 @@
FT_Size_RequestRec req;
+ /* check of `face' delayed to `FT_Request_Size' */
+
if ( !char_width )
char_width = char_height;
else if ( !char_height )
@@ -2751,6 +3005,8 @@
FT_Size_RequestRec req;
+ /* check of `face' delayed to `FT_Request_Size' */
+
if ( pixel_width == 0 )
pixel_width = pixel_height;
else if ( pixel_height == 0 )
@@ -2791,10 +3047,10 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !akerning )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
driver = face->driver;
@@ -2850,14 +3106,14 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !akerning )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
FT_FACE_FIND_SERVICE( face, service, KERNING );
if ( !service )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
error = service->get_track( face,
point_size,
@@ -2879,10 +3135,10 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( encoding == FT_ENCODING_NONE )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */
/* charmap available, i.e., one with UCS-4 characters, if possible. */
@@ -2893,7 +3149,7 @@
cur = face->charmaps;
if ( !cur )
- return FT_Err_Invalid_CharMap_Handle;
+ return FT_THROW( Invalid_CharMap_Handle );
limit = cur + face->num_charmaps;
@@ -2906,7 +3162,7 @@
}
}
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -2921,13 +3177,14 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
cur = face->charmaps;
- if ( !cur )
- return FT_Err_Invalid_CharMap_Handle;
+ if ( !cur || !charmap )
+ return FT_THROW( Invalid_CharMap_Handle );
+
if ( FT_Get_CMap_Format( charmap ) == 14 )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
limit = cur + face->num_charmaps;
@@ -2936,10 +3193,11 @@
if ( cur[0] == charmap )
{
face->charmap = cur[0];
- return 0;
+ return FT_Err_Ok;
}
}
- return FT_Err_Invalid_Argument;
+
+ return FT_THROW( Invalid_Argument );
}
@@ -2951,6 +3209,9 @@
FT_Int i;
+ if ( !charmap || !charmap->face )
+ return -1;
+
for ( i = 0; i < charmap->face->num_charmaps; i++ )
if ( charmap->face->charmaps[i] == charmap )
break;
@@ -2966,7 +3227,7 @@
{
FT_CMap_Class clazz = cmap->clazz;
FT_Face face = cmap->charmap.face;
- FT_Memory memory = FT_FACE_MEMORY(face);
+ FT_Memory memory = FT_FACE_MEMORY( face );
if ( clazz->done )
@@ -3031,11 +3292,11 @@
FT_Error error = FT_Err_Ok;
FT_Face face;
FT_Memory memory;
- FT_CMap cmap;
+ FT_CMap cmap = NULL;
if ( clazz == NULL || charmap == NULL || charmap->face == NULL )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
face = charmap->face;
memory = FT_FACE_MEMORY( face );
@@ -3095,7 +3356,7 @@
}
result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode );
}
- return result;
+ return result;
}
@@ -3109,14 +3370,15 @@
FT_UInt gindex = 0;
- if ( face && face->charmap )
+ /* only do something if we have a charmap, and we have glyphs at all */
+ if ( face && face->charmap && face->num_glyphs )
{
gindex = FT_Get_Char_Index( face, 0 );
- if ( gindex == 0 )
+ if ( gindex == 0 || gindex >= (FT_UInt)face->num_glyphs )
result = FT_Get_Next_Char( face, 0, &gindex );
}
- if ( agindex )
+ if ( agindex )
*agindex = gindex;
return result;
@@ -3134,13 +3396,18 @@
FT_UInt gindex = 0;
- if ( face && face->charmap )
+ if ( face && face->charmap && face->num_glyphs )
{
FT_UInt32 code = (FT_UInt32)charcode;
FT_CMap cmap = FT_CMAP( face->charmap );
- gindex = cmap->clazz->char_next( cmap, &code );
+ do
+ {
+ gindex = cmap->clazz->char_next( cmap, &code );
+
+ } while ( gindex >= (FT_UInt)face->num_glyphs );
+
result = ( gindex == 0 ) ? 0 : code;
}
@@ -3161,8 +3428,9 @@
FT_UInt result = 0;
- if ( face && face->charmap &&
- face->charmap->encoding == FT_ENCODING_UNICODE )
+ if ( face &&
+ face->charmap &&
+ face->charmap->encoding == FT_ENCODING_UNICODE )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
FT_CMap ucmap = FT_CMAP( face->charmap );
@@ -3340,7 +3608,9 @@
FT_UInt result = 0;
- if ( face && FT_HAS_GLYPH_NAMES( face ) )
+ if ( face &&
+ FT_HAS_GLYPH_NAMES( face ) &&
+ glyph_name )
{
FT_Service_GlyphDict service;
@@ -3365,27 +3635,30 @@
FT_Pointer buffer,
FT_UInt buffer_max )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error;
+ FT_Service_GlyphDict service;
- /* clean up buffer */
- if ( buffer && buffer_max > 0 )
- ((FT_Byte*)buffer)[0] = 0;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
- if ( face &&
- (FT_Long)glyph_index <= face->num_glyphs &&
- FT_HAS_GLYPH_NAMES( face ) )
- {
- FT_Service_GlyphDict service;
+ if ( !buffer || buffer_max == 0 )
+ return FT_THROW( Invalid_Argument );
+
+ /* clean up buffer */
+ ((FT_Byte*)buffer)[0] = '\0';
+ if ( (FT_Long)glyph_index >= face->num_glyphs )
+ return FT_THROW( Invalid_Glyph_Index );
- FT_FACE_LOOKUP_SERVICE( face,
- service,
- GLYPH_DICT );
+ if ( !FT_HAS_GLYPH_NAMES( face ) )
+ return FT_THROW( Invalid_Argument );
- if ( service && service->get_name )
- error = service->get_name( face, glyph_index, buffer, buffer_max );
- }
+ FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT );
+ if ( service && service->get_name )
+ error = service->get_name( face, glyph_index, buffer, buffer_max );
+ else
+ error = FT_THROW( Invalid_Argument );
return error;
}
@@ -3426,7 +3699,7 @@
FT_Get_Sfnt_Table( FT_Face face,
FT_Sfnt_Tag tag )
{
- void* table = 0;
+ void* table = NULL;
FT_Service_SFNT_Table service;
@@ -3454,11 +3727,11 @@
if ( !face || !FT_IS_SFNT( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
return service->load_table( face, tag, offset, buffer, length );
}
@@ -3476,12 +3749,14 @@
FT_ULong offset;
+ /* test for valid `length' delayed to `service->table_info' */
+
if ( !face || !FT_IS_SFNT( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
return service->table_info( face, table_index, tag, &offset, length );
}
@@ -3543,12 +3818,12 @@
FT_Face face;
- if ( size == NULL )
- return FT_Err_Invalid_Argument;
+ if ( !size )
+ return FT_THROW( Invalid_Size_Handle );
face = size->face;
- if ( face == NULL || face->driver == NULL )
- return FT_Err_Invalid_Argument;
+ if ( !face || !face->driver )
+ return FT_THROW( Invalid_Face_Handle );
/* we don't need anything more complex than that; all size objects */
/* are already listed by the face */
@@ -3645,7 +3920,7 @@
FT_Library library = module->library;
FT_Memory memory = library->memory;
FT_Error error;
- FT_ListNode node;
+ FT_ListNode node = NULL;
if ( FT_NEW( node ) )
@@ -3661,7 +3936,7 @@
/* allocate raster object if needed */
if ( clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
- clazz->raster_class->raster_new )
+ clazz->raster_class->raster_new )
{
error = clazz->raster_class->raster_new( memory, &render->raster );
if ( error )
@@ -3690,11 +3965,17 @@
static void
ft_remove_renderer( FT_Module module )
{
- FT_Library library = module->library;
- FT_Memory memory = library->memory;
+ FT_Library library;
+ FT_Memory memory;
FT_ListNode node;
+ library = module->library;
+ if ( !library )
+ return;
+
+ memory = library->memory;
+
node = FT_List_Find( &library->renderers, module );
if ( node )
{
@@ -3702,7 +3983,8 @@
/* release raster object, if any */
- if ( render->raster )
+ if ( render->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
+ render->raster )
render->clazz->raster_class->raster_done( render->raster );
/* remove from list */
@@ -3720,7 +4002,7 @@
FT_Get_Renderer( FT_Library library,
FT_Glyph_Format format )
{
- /* test for valid `library' delayed to FT_Lookup_Renderer() */
+ /* test for valid `library' delayed to `FT_Lookup_Renderer' */
return FT_Lookup_Renderer( library, format, 0 );
}
@@ -3737,17 +4019,31 @@
FT_ListNode node;
FT_Error error = FT_Err_Ok;
+ FT_Renderer_SetModeFunc set_mode;
+
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ {
+ error = FT_THROW( Invalid_Library_Handle );
+ goto Exit;
+ }
if ( !renderer )
- return FT_Err_Invalid_Argument;
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ if ( num_params > 0 && !parameters )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
node = FT_List_Find( &library->renderers, renderer );
if ( !node )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -3756,17 +4052,14 @@
if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE )
library->cur_renderer = renderer;
- if ( num_params > 0 )
- {
- FT_Renderer_SetModeFunc set_mode = renderer->clazz->set_mode;
-
+ set_mode = renderer->clazz->set_mode;
- for ( ; num_params > 0; num_params-- )
- {
- error = set_mode( renderer, parameters->tag, parameters->data );
- if ( error )
- break;
- }
+ for ( ; num_params > 0; num_params-- )
+ {
+ error = set_mode( renderer, parameters->tag, parameters->data );
+ if ( error )
+ break;
+ parameters++;
}
Exit:
@@ -3804,12 +4097,12 @@
else
renderer = FT_Lookup_Renderer( library, slot->format, &node );
- error = FT_Err_Unimplemented_Feature;
+ error = FT_ERR( Unimplemented_Feature );
while ( renderer )
{
error = renderer->render( renderer, slot, render_mode, NULL );
- if ( !error ||
- FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )
+ if ( !error ||
+ FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
break;
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
@@ -3825,10 +4118,57 @@
/* if we changed the current renderer for the glyph image format */
/* we need to select it as the next current one */
if ( !error && update && renderer )
- FT_Set_Renderer( library, renderer, 0, 0 );
+ {
+ error = FT_Set_Renderer( library, renderer, 0, 0 );
+ if ( error )
+ break;
+ }
}
}
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_bitmap
+
+ /* we convert to a single bitmap format for computing the checksum */
+ if ( !error )
+ {
+ FT_Bitmap bitmap;
+ FT_Error err;
+
+
+ FT_Bitmap_New( &bitmap );
+
+ /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
+ err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
+ if ( !err )
+ {
+ MD5_CTX ctx;
+ unsigned char md5[16];
+ int i;
+
+
+ MD5_Init( &ctx);
+ MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch );
+ MD5_Final( md5, &ctx );
+
+ FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n"
+ " ",
+ bitmap.rows, bitmap.pitch ));
+ for ( i = 0; i < 16; i++ )
+ FT_TRACE3(( "%02X", md5[i] ));
+ FT_TRACE3(( "\n" ));
+ }
+
+ FT_Bitmap_Done( library, &bitmap );
+ }
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_objs
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
return error;
}
@@ -3842,8 +4182,8 @@
FT_Library library;
- if ( !slot )
- return FT_Err_Invalid_Argument;
+ if ( !slot || !slot->face )
+ return FT_THROW( Invalid_Argument );
library = FT_FACE_LIBRARY( slot->face );
@@ -3874,10 +4214,10 @@
/* all child faces. */
/* */
/* <InOut> */
- /* module :: A handle to the target driver object. */
+ /* module :: A handle to the target driver object. */
/* */
/* <Note> */
- /* The driver _must_ be LOCKED! */
+ /* The driver _must_ be LOCKED! */
/* */
static void
Destroy_Module( FT_Module module )
@@ -3887,10 +4227,6 @@
FT_Library library = module->library;
- /* finalize client-data - before anything else */
- if ( module->generic.finalizer )
- module->generic.finalizer( module );
-
if ( library && library->auto_hinter == module )
library->auto_hinter = 0;
@@ -3927,14 +4263,14 @@
FREETYPE_MINOR )
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !clazz )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* check freetype version */
if ( clazz->module_requires > FREETYPE_VER_FIXED )
- return FT_Err_Invalid_Version;
+ return FT_THROW( Invalid_Version );
/* look for a module with the same name in the library's table */
for ( nn = 0; nn < library->num_modules; nn++ )
@@ -3944,7 +4280,7 @@
{
/* this installed module has the same name, compare their versions */
if ( clazz->module_version <= module->clazz->module_version )
- return FT_Err_Lower_Module_Version;
+ return FT_THROW( Lower_Module_Version );
/* remove the module from our list, then exit the loop to replace */
/* it by our new version.. */
@@ -3958,7 +4294,7 @@
if ( library->num_modules >= FT_MAX_MODULES )
{
- error = FT_Err_Too_Many_Drivers;
+ error = FT_THROW( Too_Many_Drivers );
goto Exit;
}
@@ -4029,7 +4365,9 @@
FT_Renderer renderer = FT_RENDERER( module );
- if ( renderer->raster )
+ if ( renderer->clazz &&
+ renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
+ renderer->raster )
renderer->clazz->raster_class->raster_done( renderer->raster );
}
@@ -4044,7 +4382,7 @@
FT_Get_Module( FT_Library library,
const char* module_name )
{
- FT_Module result = 0;
+ FT_Module result = NULL;
FT_Module* cur;
FT_Module* limit;
@@ -4089,23 +4427,23 @@
{
FT_Pointer result = NULL;
+
if ( module )
{
FT_ASSERT( module->clazz && module->clazz->get_interface );
- /* first, look for the service in the module
- */
+ /* first, look for the service in the module */
if ( module->clazz->get_interface )
result = module->clazz->get_interface( module, service_id );
if ( result == NULL )
{
- /* we didn't find it, look in all other modules then
- */
+ /* we didn't find it, look in all other modules then */
FT_Library library = module->library;
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
+
for ( ; cur < limit; cur++ )
{
if ( cur[0] != module )
@@ -4136,7 +4474,7 @@
/* try to find the module from the table, then remove it from there */
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( module )
{
@@ -4165,7 +4503,119 @@
}
}
}
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
+ }
+
+
+ static FT_Error
+ ft_property_do( FT_Library library,
+ const FT_String* module_name,
+ const FT_String* property_name,
+ void* value,
+ FT_Bool set )
+ {
+ FT_Module* cur;
+ FT_Module* limit;
+ FT_Module_Interface interface;
+
+ FT_Service_Properties service;
+
+#ifdef FT_DEBUG_LEVEL_ERROR
+ const FT_String* set_name = "FT_Property_Set";
+ const FT_String* get_name = "FT_Property_Get";
+ const FT_String* func_name = set ? set_name : get_name;
+#endif
+
+ FT_Bool missing_func;
+
+
+ if ( !library )
+ return FT_THROW( Invalid_Library_Handle );
+
+ if ( !module_name || !property_name || !value )
+ return FT_THROW( Invalid_Argument );
+
+ cur = library->modules;
+ limit = cur + library->num_modules;
+
+ /* search module */
+ for ( ; cur < limit; cur++ )
+ if ( !ft_strcmp( cur[0]->clazz->module_name, module_name ) )
+ break;
+
+ if ( cur == limit )
+ {
+ FT_ERROR(( "%s: can't find module `%s'\n",
+ func_name, module_name ));
+ return FT_THROW( Missing_Module );
+ }
+
+ /* check whether we have a service interface */
+ if ( !cur[0]->clazz->get_interface )
+ {
+ FT_ERROR(( "%s: module `%s' doesn't support properties\n",
+ func_name, module_name ));
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+ /* search property service */
+ interface = cur[0]->clazz->get_interface( cur[0],
+ FT_SERVICE_ID_PROPERTIES );
+ if ( !interface )
+ {
+ FT_ERROR(( "%s: module `%s' doesn't support properties\n",
+ func_name, module_name ));
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+ service = (FT_Service_Properties)interface;
+
+ if ( set )
+ missing_func = (FT_Bool)( !service->set_property );
+ else
+ missing_func = (FT_Bool)( !service->get_property );
+
+ if ( missing_func )
+ {
+ FT_ERROR(( "%s: property service of module `%s' is broken\n",
+ func_name, module_name ));
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+ return set ? service->set_property( cur[0], property_name, value )
+ : service->get_property( cur[0], property_name, value );
+ }
+
+
+ /* documentation is in ftmodapi.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Property_Set( FT_Library library,
+ const FT_String* module_name,
+ const FT_String* property_name,
+ const void* value )
+ {
+ return ft_property_do( library,
+ module_name,
+ property_name,
+ (void*)value,
+ TRUE );
+ }
+
+
+ /* documentation is in ftmodapi.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Property_Get( FT_Library library,
+ const FT_String* module_name,
+ const FT_String* property_name,
+ void* value )
+ {
+ return ft_property_do( library,
+ module_name,
+ property_name,
+ value,
+ FALSE );
}
@@ -4185,15 +4635,29 @@
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
+ FT_Reference_Library( FT_Library library )
+ {
+ if ( !library )
+ return FT_THROW( Invalid_Library_Handle );
+
+ library->refcount++;
+
+ return FT_Err_Ok;
+ }
+
+
+ /* documentation is in ftmodapi.h */
+
+ FT_EXPORT_DEF( FT_Error )
FT_New_Library( FT_Memory memory,
FT_Library *alibrary )
{
- FT_Library library = 0;
+ FT_Library library = NULL;
FT_Error error;
- if ( !memory )
- return FT_Err_Invalid_Argument;
+ if ( !memory || !alibrary )
+ return FT_THROW( Invalid_Argument );
#ifdef FT_DEBUG_LEVEL_ERROR
/* init debugging support */
@@ -4224,6 +4688,8 @@
library->version_minor = FREETYPE_MINOR;
library->version_patch = FREETYPE_PATCH;
+ library->refcount = 1;
+
/* That's ok now */
*alibrary = library;
@@ -4278,42 +4744,62 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
- memory = library->memory;
+ library->refcount--;
+ if ( library->refcount > 0 )
+ goto Exit;
- /* Discard client-data */
- if ( library->generic.finalizer )
- library->generic.finalizer( library );
+ memory = library->memory;
- /* Close all faces in the library. If we don't do
- * this, we can have some subtle memory leaks.
+ /*
+ * Close all faces in the library. If we don't do this, we can have
+ * some subtle memory leaks.
+ *
* Example:
*
* - the cff font driver uses the pshinter module in cff_size_done
* - if the pshinter module is destroyed before the cff font driver,
* opened FT_Face objects managed by the driver are not properly
* destroyed, resulting in a memory leak
+ *
+ * Some faces are dependent on other faces, like Type42 faces that
+ * depend on TrueType faces synthesized internally.
+ *
+ * The order of drivers should be specified in driver_name[].
*/
{
- FT_UInt n;
+ FT_UInt m, n;
+ const char* driver_name[] = { "type42", NULL };
- for ( n = 0; n < library->num_modules; n++ )
+ for ( m = 0;
+ m < sizeof ( driver_name ) / sizeof ( driver_name[0] );
+ m++ )
{
- FT_Module module = library->modules[n];
- FT_List faces;
+ for ( n = 0; n < library->num_modules; n++ )
+ {
+ FT_Module module = library->modules[n];
+ const char* module_name = module->clazz->module_name;
+ FT_List faces;
- if ( ( module->clazz->module_flags & FT_MODULE_FONT_DRIVER ) == 0 )
- continue;
+ if ( driver_name[m] &&
+ ft_strcmp( module_name, driver_name[m] ) != 0 )
+ continue;
- faces = &FT_DRIVER(module)->faces_list;
- while ( faces->head )
- {
- FT_Done_Face( FT_FACE( faces->head->data ) );
- if ( faces->head )
- FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
+ if ( ( module->clazz->module_flags & FT_MODULE_FONT_DRIVER ) == 0 )
+ continue;
+
+ FT_TRACE7(( "FT_Done_Library: close faces for %s\n", module_name ));
+
+ faces = &FT_DRIVER( module )->faces_list;
+ while ( faces->head )
+ {
+ FT_Done_Face( FT_FACE( faces->head->data ) );
+ if ( faces->head )
+ FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
+ }
}
}
}
@@ -4355,6 +4841,8 @@
#endif
FT_FREE( library );
+
+ Exit:
return FT_Err_Ok;
}
@@ -4403,69 +4891,7 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_BASE_DEF( FT_Error )
- ft_stub_set_char_sizes( FT_Size size,
- FT_F26Dot6 width,
- FT_F26Dot6 height,
- FT_UInt horz_res,
- FT_UInt vert_res )
- {
- FT_Size_RequestRec req;
- FT_Driver driver = size->face->driver;
-
-
- if ( driver->clazz->request_size )
- {
- req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
- req.width = width;
- req.height = height;
-
- if ( horz_res == 0 )
- horz_res = vert_res;
-
- if ( vert_res == 0 )
- vert_res = horz_res;
-
- if ( horz_res == 0 )
- horz_res = vert_res = 72;
-
- req.horiResolution = horz_res;
- req.vertResolution = vert_res;
-
- return driver->clazz->request_size( size, &req );
- }
-
- return 0;
- }
-
-
- FT_BASE_DEF( FT_Error )
- ft_stub_set_pixel_sizes( FT_Size size,
- FT_UInt width,
- FT_UInt height )
- {
- FT_Size_RequestRec req;
- FT_Driver driver = size->face->driver;
-
-
- if ( driver->clazz->request_size )
- {
- req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
- req.width = width << 6;
- req.height = height << 6;
- req.horiResolution = 0;
- req.vertResolution = 0;
-
- return driver->clazz->request_size( size, &req );
- }
-
- return 0;
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
+ /* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
@@ -4476,10 +4902,11 @@
FT_Int *p_arg2,
FT_Matrix *p_transform )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
- if ( glyph != NULL &&
+ if ( glyph &&
+ glyph->subglyphs &&
glyph->format == FT_GLYPH_FORMAT_COMPOSITE &&
sub_index < glyph->num_subglyphs )
{
@@ -4491,6 +4918,8 @@
*p_arg1 = subg->arg1;
*p_arg2 = subg->arg2;
*p_transform = subg->transform;
+
+ error = FT_Err_Ok;
}
return error;
diff --git a/src/3rdparty/freetype/src/base/ftotval.c b/src/3rdparty/freetype/src/base/ftotval.c
index 20ed686eee..5fc73d76ab 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, 2006, 2008 by */
+/* Copyright 2004, 2006, 2008, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,6 +16,8 @@
/***************************************************************************/
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_OPENTYPE_VALIDATE_H
#include FT_OPENTYPE_VALIDATE_H
@@ -38,7 +40,7 @@
if ( !face )
{
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
@@ -48,7 +50,7 @@
GSUB_table &&
JSTF_table ) )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -63,7 +65,7 @@
GSUB_table,
JSTF_table );
else
- error = FT_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
@@ -74,8 +76,13 @@
FT_OpenType_Free( FT_Face face,
FT_Bytes table )
{
- FT_Memory memory = FT_FACE_MEMORY( face );
+ FT_Memory memory;
+
+
+ if ( !face )
+ return;
+ memory = FT_FACE_MEMORY( face );
FT_FREE( table );
}
diff --git a/src/3rdparty/freetype/src/base/ftoutln.c b/src/3rdparty/freetype/src/base/ftoutln.c
index b69df84c04..8749d64ce7 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
+/* Copyright 1996-2008, 2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,6 +26,7 @@
#include <ft2build.h>
#include FT_OUTLINE_H
#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
#include FT_TRIGONOMETRY_H
@@ -72,8 +73,11 @@
FT_Pos delta;
- if ( !outline || !func_interface )
- return FT_Err_Invalid_Argument;
+ if ( !outline )
+ return FT_THROW( Invalid_Outline );
+
+ if ( !func_interface )
+ return FT_THROW( Invalid_Argument );
shift = func_interface->shift;
delta = func_interface->delta;
@@ -127,7 +131,7 @@
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
- v_last = v_start;
+ /* v_last = v_start; */
}
point--;
tags--;
@@ -286,7 +290,7 @@
return error;
Invalid_Outline:
- return FT_Err_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
}
@@ -300,10 +304,17 @@
if ( !anoutline || !memory )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*anoutline = null_outline;
+ if ( numContours < 0 ||
+ (FT_UInt)numContours > numPoints )
+ return FT_THROW( Invalid_Argument );
+
+ if ( numPoints > FT_OUTLINE_POINTS_MAX )
+ return FT_THROW( Array_Too_Large );
+
if ( FT_NEW_ARRAY( anoutline->points, numPoints ) ||
FT_NEW_ARRAY( anoutline->tags, numPoints ) ||
FT_NEW_ARRAY( anoutline->contours, numContours ) )
@@ -332,7 +343,7 @@
FT_Outline *anoutline )
{
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
return FT_Outline_New_Internal( library->memory, numPoints,
numContours, anoutline );
@@ -354,7 +365,7 @@
/* empty glyph? */
if ( n_points == 0 && n_contours == 0 )
- return 0;
+ return FT_Err_Ok;
/* check point and contour counts */
if ( n_points <= 0 || n_contours <= 0 )
@@ -376,11 +387,11 @@
goto Bad;
/* XXX: check the tags array */
- return 0;
+ return FT_Err_Ok;
}
Bad:
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -393,10 +404,12 @@
FT_Int is_owner;
- if ( !source || !target ||
- source->n_points != target->n_points ||
+ if ( !source || !target )
+ return FT_THROW( Invalid_Outline );
+
+ if ( source->n_points != target->n_points ||
source->n_contours != target->n_contours )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( source == target )
return FT_Err_Ok;
@@ -422,20 +435,21 @@
FT_Outline_Done_Internal( FT_Memory memory,
FT_Outline* outline )
{
- if ( memory && outline )
- {
- if ( outline->flags & FT_OUTLINE_OWNER )
- {
- FT_FREE( outline->points );
- FT_FREE( outline->tags );
- FT_FREE( outline->contours );
- }
- *outline = null_outline;
+ if ( !outline )
+ return FT_THROW( Invalid_Outline );
- return FT_Err_Ok;
+ if ( !memory )
+ return FT_THROW( Invalid_Argument );
+
+ if ( outline->flags & FT_OUTLINE_OWNER )
+ {
+ FT_FREE( outline->points );
+ FT_FREE( outline->tags );
+ FT_FREE( outline->contours );
}
- else
- return FT_Err_Invalid_Argument;
+ *outline = null_outline;
+
+ return FT_Err_Ok;
}
@@ -448,7 +462,7 @@
/* check for valid `outline' in FT_Outline_Done_Internal() */
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
return FT_Outline_Done_Internal( library->memory, outline );
}
@@ -568,11 +582,13 @@
{
char* p = outline->tags + first;
char* q = outline->tags + last;
- char swap;
while ( p < q )
{
+ char swap;
+
+
swap = *p;
*p = *q;
*q = swap;
@@ -602,21 +618,24 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
- if ( !outline || !params )
- return FT_Err_Invalid_Argument;
+ if ( !outline )
+ return FT_THROW( Invalid_Outline );
+
+ if ( !params )
+ return FT_THROW( Invalid_Argument );
renderer = library->cur_renderer;
node = library->renderers.head;
params->source = (void*)outline;
- error = FT_Err_Cannot_Render_Glyph;
+ error = FT_ERR( Cannot_Render_Glyph );
while ( renderer )
{
error = renderer->raster_render( renderer->raster, params );
- if ( !error || FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )
+ if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
break;
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
@@ -633,7 +652,7 @@
/* if we changed the current renderer for the glyph image format */
/* we need to select it as the next current one */
if ( !error && update && renderer )
- FT_Set_Renderer( library, renderer, 0, 0 );
+ error = FT_Set_Renderer( library, renderer, 0, 0 );
return error;
}
@@ -650,9 +669,9 @@
if ( !abitmap )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
- /* other checks are delayed to FT_Outline_Render() */
+ /* other checks are delayed to `FT_Outline_Render' */
params.target = abitmap;
params.flags = 0;
@@ -713,7 +732,8 @@
#if 0
#define FT_OUTLINE_GET_CONTOUR( outline, c, first, last ) \
- do { \
+ do \
+ { \
(first) = ( c > 0 ) ? (outline)->points + \
(outline)->contours[c - 1] + 1 \
: (outline)->points; \
@@ -771,7 +791,7 @@
return 1;
}
- return ( n % 2 );
+ return n & 1;
}
@@ -882,85 +902,126 @@
FT_Outline_Embolden( FT_Outline* outline,
FT_Pos strength )
{
+ return FT_Outline_EmboldenXY( outline, strength, strength );
+ }
+
+
+ /* documentation is in ftoutln.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Outline_EmboldenXY( FT_Outline* outline,
+ FT_Pos xstrength,
+ FT_Pos ystrength )
+ {
FT_Vector* points;
FT_Vector v_prev, v_first, v_next, v_cur;
- FT_Angle rotate, angle_in, angle_out;
FT_Int c, n, first;
FT_Int orientation;
if ( !outline )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Outline );
- strength /= 2;
- if ( strength == 0 )
+ xstrength /= 2;
+ ystrength /= 2;
+ if ( xstrength == 0 && ystrength == 0 )
return FT_Err_Ok;
orientation = FT_Outline_Get_Orientation( outline );
if ( orientation == FT_ORIENTATION_NONE )
{
if ( outline->n_contours )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
else
return FT_Err_Ok;
}
- if ( orientation == FT_ORIENTATION_TRUETYPE )
- rotate = -FT_ANGLE_PI2;
- else
- rotate = FT_ANGLE_PI2;
-
points = outline->points;
first = 0;
for ( c = 0; c < outline->n_contours; c++ )
{
- int last = outline->contours[c];
+ FT_Vector in, out, shift;
+ FT_Fixed l_in, l_out, l, q, d;
+ int last = outline->contours[c];
v_first = points[first];
v_prev = points[last];
v_cur = v_first;
- for ( n = first; n <= last; n++ )
+ /* compute incoming normalized vector */
+ in.x = v_cur.x - v_prev.x;
+ in.y = v_cur.y - v_prev.y;
+ l_in = FT_Vector_Length( &in );
+ if ( l_in )
{
- FT_Vector in, out;
- FT_Angle angle_diff;
- FT_Pos d;
- FT_Fixed scale;
-
+ in.x = FT_DivFix( in.x, l_in );
+ in.y = FT_DivFix( in.y, l_in );
+ }
+ for ( n = first; n <= last; n++ )
+ {
if ( n < last )
v_next = points[n + 1];
else
v_next = v_first;
- /* compute the in and out vectors */
- in.x = v_cur.x - v_prev.x;
- in.y = v_cur.y - v_prev.y;
-
+ /* compute outgoing normalized vector */
out.x = v_next.x - v_cur.x;
out.y = v_next.y - v_cur.y;
+ l_out = FT_Vector_Length( &out );
+ if ( l_out )
+ {
+ out.x = FT_DivFix( out.x, l_out );
+ out.y = FT_DivFix( out.y, l_out );
+ }
- angle_in = FT_Atan2( in.x, in.y );
- angle_out = FT_Atan2( out.x, out.y );
- angle_diff = FT_Angle_Diff( angle_in, angle_out );
- scale = FT_Cos( angle_diff / 2 );
+ d = FT_MulFix( in.x, out.x ) + FT_MulFix( in.y, out.y );
- if ( scale < 0x4000L && scale > -0x4000L )
- in.x = in.y = 0;
- else
+ /* shift only if turn is less than ~160 degrees */
+ if ( d > -0xF000L )
{
- d = FT_DivFix( strength, scale );
+ d = d + 0x10000L;
+
+ /* shift components are aligned along lateral bisector */
+ /* and directed according to the outline orientation. */
+ shift.x = in.y + out.y;
+ shift.y = in.x + out.x;
+
+ if ( orientation == FT_ORIENTATION_TRUETYPE )
+ shift.x = -shift.x;
+ else
+ shift.y = -shift.y;
+
+ /* restrict shift magnitude to better handle collapsing segments */
+ q = FT_MulFix( out.x, in.y ) - FT_MulFix( out.y, in.x );
+ if ( orientation == FT_ORIENTATION_TRUETYPE )
+ q = -q;
+
+ l = FT_MIN( l_in, l_out );
- FT_Vector_From_Polar( &in, d, angle_in + angle_diff / 2 - rotate );
+ /* non-strict inequalities avoid divide-by-zero when q == l == 0 */
+ if ( FT_MulFix( xstrength, q ) <= FT_MulFix( d, l ) )
+ shift.x = FT_MulDiv( shift.x, xstrength, d );
+ else
+ shift.x = FT_MulDiv( shift.x, l, q );
+
+
+ if ( FT_MulFix( ystrength, q ) <= FT_MulFix( d, l ) )
+ shift.y = FT_MulDiv( shift.y, ystrength, d );
+ else
+ shift.y = FT_MulDiv( shift.y, l, q );
}
+ else
+ shift.x = shift.y = 0;
- outline->points[n].x = v_cur.x + strength + in.x;
- outline->points[n].y = v_cur.y + strength + in.y;
+ outline->points[n].x = v_cur.x + xstrength + shift.x;
+ outline->points[n].y = v_cur.y + ystrength + shift.y;
- v_prev = v_cur;
- v_cur = v_next;
+ in = out;
+ l_in = l_out;
+ v_cur = v_next;
}
first = last + 1;
@@ -975,22 +1036,12 @@
FT_EXPORT_DEF( FT_Orientation )
FT_Outline_Get_Orientation( FT_Outline* outline )
{
- FT_Pos xmin = 32768L;
- FT_Pos xmin_ymin = 32768L;
- FT_Pos xmin_ymax = -32768L;
- FT_Vector* xmin_first = NULL;
- FT_Vector* xmin_last = NULL;
-
- short* contour;
-
- FT_Vector* first;
- FT_Vector* last;
- FT_Vector* prev;
- FT_Vector* point;
-
- int i;
- FT_Pos ray_y[3];
- FT_Orientation result[3];
+ FT_BBox cbox;
+ FT_Int xshift, yshift;
+ FT_Vector* points;
+ FT_Vector v_prev, v_cur;
+ FT_Int c, n, first;
+ FT_Pos area = 0;
if ( !outline || outline->n_points <= 0 )
@@ -1001,127 +1052,45 @@
/* cubic or quadratic curves, this test deals with the polygon */
/* only which is spanned up by the control points. */
- first = outline->points;
- for ( contour = outline->contours;
- contour < outline->contours + outline->n_contours;
- contour++, first = last + 1 )
- {
- FT_Pos contour_xmin = 32768L;
- FT_Pos contour_xmax = -32768L;
- FT_Pos contour_ymin = 32768L;
- FT_Pos contour_ymax = -32768L;
-
+ FT_Outline_Get_CBox( outline, &cbox );
- last = outline->points + *contour;
+ /* Handle collapsed outlines to avoid undefined FT_MSB. */
+ if ( cbox.xMin == cbox.xMax || cbox.yMin == cbox.yMax )
+ return FT_ORIENTATION_NONE;
- /* skip degenerate contours */
- if ( last < first + 2 )
- continue;
+ xshift = FT_MSB( FT_ABS( cbox.xMax ) | FT_ABS( cbox.xMin ) ) - 14;
+ xshift = FT_MAX( xshift, 0 );
- for ( point = first; point <= last; ++point )
- {
- if ( point->x < contour_xmin )
- contour_xmin = point->x;
+ yshift = FT_MSB( cbox.yMax - cbox.yMin ) - 14;
+ yshift = FT_MAX( yshift, 0 );
- if ( point->x > contour_xmax )
- contour_xmax = point->x;
-
- if ( point->y < contour_ymin )
- contour_ymin = point->y;
-
- if ( point->y > contour_ymax )
- contour_ymax = point->y;
- }
-
- if ( contour_xmin < xmin &&
- contour_xmin != contour_xmax &&
- contour_ymin != contour_ymax )
- {
- xmin = contour_xmin;
- xmin_ymin = contour_ymin;
- xmin_ymax = contour_ymax;
- xmin_first = first;
- xmin_last = last;
- }
- }
-
- if ( xmin == 32768L )
- return FT_ORIENTATION_TRUETYPE;
-
- ray_y[0] = ( xmin_ymin * 3 + xmin_ymax ) >> 2;
- ray_y[1] = ( xmin_ymin + xmin_ymax ) >> 1;
- ray_y[2] = ( xmin_ymin + xmin_ymax * 3 ) >> 2;
+ points = outline->points;
- for ( i = 0; i < 3; i++ )
+ first = 0;
+ for ( c = 0; c < outline->n_contours; c++ )
{
- FT_Pos left_x;
- FT_Pos right_x;
- FT_Vector* left1;
- FT_Vector* left2;
- FT_Vector* right1;
- FT_Vector* right2;
-
+ FT_Int last = outline->contours[c];
- RedoRay:
- left_x = 32768L;
- right_x = -32768L;
- left1 = left2 = right1 = right2 = NULL;
+ v_prev = points[last];
- prev = xmin_last;
- for ( point = xmin_first; point <= xmin_last; prev = point, ++point )
+ for ( n = first; n <= last; n++ )
{
- FT_Pos tmp_x;
-
-
- if ( point->y == ray_y[i] || prev->y == ray_y[i] )
- {
- ray_y[i]++;
- goto RedoRay;
- }
-
- if ( ( point->y < ray_y[i] && prev->y < ray_y[i] ) ||
- ( point->y > ray_y[i] && prev->y > ray_y[i] ) )
- continue;
-
- tmp_x = FT_MulDiv( point->x - prev->x,
- ray_y[i] - prev->y,
- point->y - prev->y ) + prev->x;
-
- if ( tmp_x < left_x )
- {
- left_x = tmp_x;
- left1 = prev;
- left2 = point;
- }
-
- if ( tmp_x > right_x )
- {
- right_x = tmp_x;
- right1 = prev;
- right2 = point;
- }
+ v_cur = points[n];
+ area += ( ( v_cur.y - v_prev.y ) >> yshift ) *
+ ( ( v_cur.x + v_prev.x ) >> xshift );
+ v_prev = v_cur;
}
- if ( left1 && right1 )
- {
- if ( left1->y < left2->y && right1->y > right2->y )
- result[i] = FT_ORIENTATION_TRUETYPE;
- else if ( left1->y > left2->y && right1->y < right2->y )
- result[i] = FT_ORIENTATION_POSTSCRIPT;
- else
- result[i] = FT_ORIENTATION_NONE;
- }
+ first = last + 1;
}
- if ( result[0] != FT_ORIENTATION_NONE &&
- ( result[0] == result[1] || result[0] == result[2] ) )
- return result[0];
-
- if ( result[1] != FT_ORIENTATION_NONE && result[1] == result[2] )
- return result[1];
-
- return FT_ORIENTATION_TRUETYPE;
+ if ( area > 0 )
+ return FT_ORIENTATION_POSTSCRIPT;
+ else if ( area < 0 )
+ return FT_ORIENTATION_TRUETYPE;
+ else
+ return FT_ORIENTATION_NONE;
}
diff --git a/src/3rdparty/freetype/src/base/ftpatent.c b/src/3rdparty/freetype/src/base/ftpatent.c
index 501cab52ca..82b42f0343 100644
--- a/src/3rdparty/freetype/src/base/ftpatent.c
+++ b/src/3rdparty/freetype/src/base/ftpatent.c
@@ -269,7 +269,7 @@
#if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \
- !defined( TT_CONFIG_OPTION_BYTECODE_INTEPRETER )
+ !defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER )
if ( face && FT_IS_SFNT( face ) )
{
result = !face->internal->ignore_unpatented_hinter;
diff --git a/src/3rdparty/freetype/src/base/ftpfr.c b/src/3rdparty/freetype/src/base/ftpfr.c
index f9592bb1bb..7425abe33c 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, 2003, 2004, 2008 by */
+/* Copyright 2002-2004, 2008, 2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,6 +16,8 @@
/***************************************************************************/
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_PFR_H
@@ -24,10 +26,11 @@
static FT_Service_PfrMetrics
ft_pfr_check( FT_Face face )
{
- FT_Service_PfrMetrics service;
+ FT_Service_PfrMetrics service = NULL;
- FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
+ if ( face )
+ FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
return service;
}
@@ -47,7 +50,7 @@
if ( !face )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Face_Handle );
service = ft_pfr_check( face );
if ( service )
@@ -83,7 +86,7 @@
if ( ametrics_y_scale )
*ametrics_y_scale = y_scale;
- error = FT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
}
return error;
@@ -103,7 +106,10 @@
if ( !face )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !avector )
+ return FT_THROW( Invalid_Argument );
service = ft_pfr_check( face );
if ( service )
@@ -127,14 +133,18 @@
FT_Service_PfrMetrics service;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !aadvance )
+ return FT_THROW( Invalid_Argument );
+
service = ft_pfr_check( face );
if ( service )
- {
error = service->get_advance( face, gindex, aadvance );
- }
else
/* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
return error;
}
diff --git a/src/3rdparty/freetype/src/base/ftpic.c b/src/3rdparty/freetype/src/base/ftpic.c
index d5271a9726..9bd92f785a 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 by */
+/* Copyright 2009, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,15 +26,16 @@
/* documentation is in ftpic.h */
FT_BASE_DEF( FT_Error )
- ft_pic_container_init( FT_Library library )
+ ft_pic_container_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error;
- FT_MEM_SET( pic_container, 0, sizeof(*pic_container) );
+
+ FT_MEM_SET( pic_container, 0, sizeof ( *pic_container ) );
error = ft_base_pic_init( library );
- if(error)
+ if ( error )
return error;
return FT_Err_Ok;
@@ -43,7 +44,7 @@
/* Destroy the contents of the container. */
FT_BASE_DEF( void )
- ft_pic_container_destroy( FT_Library library )
+ ft_pic_container_destroy( FT_Library library )
{
ft_base_pic_free( library );
}
diff --git a/src/3rdparty/freetype/src/base/ftrfork.c b/src/3rdparty/freetype/src/base/ftrfork.c
index 133c2de057..efe24d6eee 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, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2004-2010, 2013, 2014 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */
@@ -28,7 +28,8 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_RFORK_H
-
+#include "basepic.h"
+#include "ftbase.h"
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
@@ -86,7 +87,7 @@
/* map_len = head[12] .. head[15] */
if ( *rdata_pos + rdata_len != map_pos || map_pos == rfork_offset )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
error = FT_Stream_Seek( stream, map_pos );
if ( error )
@@ -108,7 +109,7 @@
allmatch = 0;
}
if ( !allzeros && !allmatch )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
/* If we have reached this point then it is probably a mac resource */
/* file. Now, does it contain any interesting resources? */
@@ -121,7 +122,7 @@
if ( FT_READ_USHORT( type_list ) )
return error;
if ( type_list == -1 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
error = FT_Stream_Seek( stream, map_pos + type_list );
if ( error )
@@ -151,6 +152,7 @@
FT_Long map_offset,
FT_Long rdata_pos,
FT_Long tag,
+ FT_Bool sort_by_res_id,
FT_Long **offsets,
FT_Long *count )
{
@@ -159,10 +161,11 @@
FT_Long tag_internal, rpos;
FT_Memory memory = library->memory;
FT_Long temp;
- FT_Long *offsets_internal;
- FT_RFork_Ref *ref;
+ FT_Long *offsets_internal = NULL;
+ FT_RFork_Ref *ref = NULL;
+ FT_TRACE3(( "\n" ));
error = FT_Stream_Seek( stream, map_offset );
if ( error )
return error;
@@ -179,10 +182,12 @@
return error;
FT_TRACE2(( "Resource tags: %c%c%c%c\n",
- (char)( 0xff & ( tag_internal >> 24 ) ),
- (char)( 0xff & ( tag_internal >> 16 ) ),
- (char)( 0xff & ( tag_internal >> 8 ) ),
- (char)( 0xff & ( tag_internal >> 0 ) ) ));
+ (char)( 0xFF & ( tag_internal >> 24 ) ),
+ (char)( 0xFF & ( tag_internal >> 16 ) ),
+ (char)( 0xFF & ( tag_internal >> 8 ) ),
+ (char)( 0xFF & ( tag_internal >> 0 ) ) ));
+ FT_TRACE3(( " : subcount=%d, suboffset=0x%04x\n",
+ subcnt, rpos ));
if ( tag_internal == tag )
{
@@ -208,11 +213,24 @@
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 ));
}
- ft_qsort( ref, *count, sizeof ( FT_RFork_Ref ),
- ( int(*)(const void*, const void*) )
- ft_raccess_sort_ref_by_id );
+ if (sort_by_res_id)
+ {
+ ft_qsort( ref, *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 ) {
+ 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 ) )
goto Exit;
@@ -233,7 +251,7 @@
}
}
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
}
@@ -253,14 +271,6 @@
/*************************************************************************/
/*************************************************************************/
- typedef FT_Error
- (*raccess_guess_func)( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
-
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
@@ -325,6 +335,20 @@
FT_Long *result_offset );
+ CONST_FT_RFORK_RULE_ARRAY_BEGIN(ft_raccess_guess_table,
+ ft_raccess_guess_rec)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_double, apple_double)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_single, apple_single)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_ufs_export, darwin_ufs_export)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_newvfs, darwin_newvfs)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_hfsplus, darwin_hfsplus)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(vfat, vfat)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_cap, linux_cap)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_double, linux_double)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_netatalk, linux_netatalk)
+ CONST_FT_RFORK_RULE_ARRAY_END
+
+
/*************************************************************************/
/**** ****/
/**** Helper functions ****/
@@ -348,7 +372,6 @@
const char *original_name,
const char *insertion );
-
FT_BASE_DEF( void )
FT_Raccess_Guess( FT_Library library,
FT_Stream stream,
@@ -357,21 +380,8 @@
FT_Long *offsets,
FT_Error *errors )
{
- FT_Long i;
-
+ FT_Int i;
- raccess_guess_func funcs[FT_RACCESS_N_RULES] =
- {
- raccess_guess_apple_double,
- raccess_guess_apple_single,
- raccess_guess_darwin_ufs_export,
- raccess_guess_darwin_newvfs,
- raccess_guess_darwin_hfsplus,
- raccess_guess_vfat,
- raccess_guess_linux_cap,
- raccess_guess_linux_double,
- raccess_guess_linux_netatalk,
- };
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
@@ -384,14 +394,50 @@
if ( errors[i] )
continue ;
- errors[i] = (funcs[i])( library, stream, base_name,
- &(new_names[i]), &(offsets[i]) );
+ errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library,
+ stream, base_name,
+ &(new_names[i]),
+ &(offsets[i]) );
}
return;
}
+#ifndef FT_MACINTOSH
+ static FT_RFork_Rule
+ raccess_get_rule_type_from_rule_index( FT_Library library,
+ FT_UInt rule_index )
+ {
+ FT_UNUSED( library );
+
+ if ( rule_index >= FT_RACCESS_N_RULES )
+ return FT_RFork_Rule_invalid;
+
+ return FT_RACCESS_GUESS_TABLE_GET[rule_index].type;
+ }
+
+
+ /*
+ * For this function, refer ftbase.h.
+ */
+ FT_LOCAL_DEF( FT_Bool )
+ ft_raccess_rule_by_darwin_vfs( FT_Library library,
+ FT_UInt rule_index )
+ {
+ switch( raccess_get_rule_type_from_rule_index( library, rule_index ) )
+ {
+ case FT_RFork_Rule_darwin_newvfs:
+ case FT_RFork_Rule_darwin_hfsplus:
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ }
+#endif
+
+
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
@@ -407,7 +453,7 @@
*result_file_name = NULL;
if ( NULL == stream )
- return FT_Err_Cannot_Open_Stream;
+ return FT_THROW( Cannot_Open_Stream );
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
@@ -429,7 +475,7 @@
*result_file_name = NULL;
if ( NULL == stream )
- return FT_Err_Cannot_Open_Stream;
+ return FT_THROW( Cannot_Open_Stream );
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
@@ -453,7 +499,7 @@
memory = library->memory;
newpath = raccess_make_file_name( memory, base_file_name, "._" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
@@ -477,9 +523,9 @@
Only meaningful on systems with hfs+ drivers (or Macs).
*/
FT_Error error;
- char* newpath;
+ char* newpath = NULL;
FT_Memory memory;
- FT_Long base_file_len = ft_strlen( base_file_name );
+ FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
FT_UNUSED( stream );
@@ -487,7 +533,7 @@
memory = library->memory;
if ( base_file_len + 6 > FT_INT_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_ALLOC( newpath, base_file_len + 6 ) )
return error;
@@ -513,9 +559,9 @@
Only meaningful on systems with Mac OS X (> 10.1).
*/
FT_Error error;
- char* newpath;
+ char* newpath = NULL;
FT_Memory memory;
- FT_Long base_file_len = ft_strlen( base_file_name );
+ FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
FT_UNUSED( stream );
@@ -523,7 +569,7 @@
memory = library->memory;
if ( base_file_len + 18 > FT_INT_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_ALLOC( newpath, base_file_len + 18 ) )
return error;
@@ -556,7 +602,7 @@
newpath = raccess_make_file_name( memory, base_file_name,
"resource.frk/" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
*result_file_name = newpath;
*result_offset = 0;
@@ -582,7 +628,7 @@
newpath = raccess_make_file_name( memory, base_file_name, ".resource/" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
*result_file_name = newpath;
*result_offset = 0;
@@ -609,7 +655,7 @@
newpath = raccess_make_file_name( memory, base_file_name, "%" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
@@ -641,7 +687,7 @@
newpath = raccess_make_file_name( memory, base_file_name,
".AppleDouble/" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
@@ -680,7 +726,7 @@
if ( FT_READ_LONG( magic_from_stream ) )
return error;
if ( magic_from_stream != magic )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
if ( FT_READ_LONG( version_number ) )
return error;
@@ -693,7 +739,7 @@
if ( FT_READ_USHORT( n_of_entries ) )
return error;
if ( n_of_entries == 0 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
for ( i = 0; i < n_of_entries; i++ )
{
@@ -716,7 +762,7 @@
}
}
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
}
@@ -751,7 +797,7 @@
const char *original_name,
const char *insertion )
{
- char* new_name;
+ char* new_name = NULL;
const char* tmp;
const char* slash;
size_t new_length;
@@ -799,7 +845,7 @@
FT_Long *offsets,
FT_Error *errors )
{
- int i;
+ FT_Int i;
FT_UNUSED( library );
FT_UNUSED( stream );
@@ -810,7 +856,7 @@
{
new_names[i] = NULL;
offsets[i] = 0;
- errors[i] = FT_Err_Unimplemented_Feature;
+ errors[i] = FT_ERR( Unimplemented_Feature );
}
}
diff --git a/src/3rdparty/freetype/src/base/ftsnames.c b/src/3rdparty/freetype/src/base/ftsnames.c
index 3447888ca2..260e91c148 100644
--- a/src/3rdparty/freetype/src/base/ftsnames.c
+++ b/src/3rdparty/freetype/src/base/ftsnames.c
@@ -44,7 +44,7 @@
FT_UInt idx,
FT_SfntName *aname )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
if ( aname && face && FT_IS_SFNT( face ) )
diff --git a/src/3rdparty/freetype/src/base/ftstream.c b/src/3rdparty/freetype/src/base/ftstream.c
index b638599dbc..759fd8fc07 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-2001, 2002, 2004, 2005, 2006, 2008, 2009 by */
+/* Copyright 2000-2002, 2004-2006, 2008-2011, 2013 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 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
}
/* note that seeking to the first position after the file is valid */
@@ -78,7 +78,7 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
if ( !error )
@@ -93,7 +93,7 @@
FT_Long distance )
{
if ( distance < 0 )
- return FT_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
return FT_Stream_Seek( stream, (FT_ULong)( stream->pos + distance ) );
}
@@ -131,7 +131,7 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
- return FT_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
}
if ( stream->read )
@@ -153,7 +153,7 @@
" invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
return error;
@@ -246,6 +246,18 @@
/* allocate the frame in memory */
FT_Memory memory = stream->memory;
+
+ /* simple sanity check */
+ if ( count > stream->size )
+ {
+ FT_ERROR(( "FT_Stream_EnterFrame:"
+ " frame size (%lu) larger than stream size (%lu)\n",
+ count, stream->size ));
+
+ error = FT_THROW( Invalid_Stream_Operation );
+ goto Exit;
+ }
+
#ifdef FT_DEBUG_MEMORY
/* assume _ft_debug_file and _ft_debug_lineno are already set */
stream->base = (unsigned char*)ft_mem_qalloc( memory, count, &error );
@@ -265,7 +277,7 @@
count, read_bytes ));
FT_FREE( stream->base );
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
stream->cursor = stream->base;
stream->limit = stream->cursor + count;
@@ -275,13 +287,13 @@
{
/* check current and new position */
if ( stream->pos >= stream->size ||
- stream->pos + count > stream->size )
+ stream->size - stream->pos < count )
{
FT_ERROR(( "FT_Stream_EnterFrame:"
" invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
@@ -342,8 +354,8 @@
}
- FT_BASE_DEF( FT_Short )
- FT_Stream_GetShort( FT_Stream stream )
+ FT_BASE_DEF( FT_UShort )
+ FT_Stream_GetUShort( FT_Stream stream )
{
FT_Byte* p;
FT_Short result;
@@ -354,15 +366,15 @@
result = 0;
p = stream->cursor;
if ( p + 1 < stream->limit )
- result = FT_NEXT_SHORT( p );
+ result = FT_NEXT_USHORT( p );
stream->cursor = p;
return result;
}
- FT_BASE_DEF( FT_Short )
- FT_Stream_GetShortLE( FT_Stream stream )
+ FT_BASE_DEF( FT_UShort )
+ FT_Stream_GetUShortLE( FT_Stream stream )
{
FT_Byte* p;
FT_Short result;
@@ -373,15 +385,15 @@
result = 0;
p = stream->cursor;
if ( p + 1 < stream->limit )
- result = FT_NEXT_SHORT_LE( p );
+ result = FT_NEXT_USHORT_LE( p );
stream->cursor = p;
return result;
}
- FT_BASE_DEF( FT_Long )
- FT_Stream_GetOffset( FT_Stream stream )
+ FT_BASE_DEF( FT_ULong )
+ FT_Stream_GetUOffset( FT_Stream stream )
{
FT_Byte* p;
FT_Long result;
@@ -392,14 +404,14 @@
result = 0;
p = stream->cursor;
if ( p + 2 < stream->limit )
- result = FT_NEXT_OFF3( p );
+ result = FT_NEXT_UOFF3( p );
stream->cursor = p;
return result;
}
- FT_BASE_DEF( FT_Long )
- FT_Stream_GetLong( FT_Stream stream )
+ FT_BASE_DEF( FT_ULong )
+ FT_Stream_GetULong( FT_Stream stream )
{
FT_Byte* p;
FT_Long result;
@@ -410,14 +422,14 @@
result = 0;
p = stream->cursor;
if ( p + 3 < stream->limit )
- result = FT_NEXT_LONG( p );
+ result = FT_NEXT_ULONG( p );
stream->cursor = p;
return result;
}
- FT_BASE_DEF( FT_Long )
- FT_Stream_GetLongLE( FT_Stream stream )
+ FT_BASE_DEF( FT_ULong )
+ FT_Stream_GetULongLE( FT_Stream stream )
{
FT_Byte* p;
FT_Long result;
@@ -428,7 +440,7 @@
result = 0;
p = stream->cursor;
if ( p + 3 < stream->limit )
- result = FT_NEXT_LONG_LE( p );
+ result = FT_NEXT_ULONG_LE( p );
stream->cursor = p;
return result;
}
@@ -462,7 +474,7 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
+ *error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadChar:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -471,8 +483,8 @@
}
- FT_BASE_DEF( FT_Short )
- FT_Stream_ReadShort( FT_Stream stream,
+ FT_BASE_DEF( FT_UShort )
+ FT_Stream_ReadUShort( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[2];
@@ -499,7 +511,7 @@
}
if ( p )
- result = FT_NEXT_SHORT( p );
+ result = FT_NEXT_USHORT( p );
}
else
goto Fail;
@@ -509,8 +521,8 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadShort:"
+ *error = FT_THROW( Invalid_Stream_Operation );
+ FT_ERROR(( "FT_Stream_ReadUShort:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -518,8 +530,8 @@
}
- FT_BASE_DEF( FT_Short )
- FT_Stream_ReadShortLE( FT_Stream stream,
+ FT_BASE_DEF( FT_UShort )
+ FT_Stream_ReadUShortLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[2];
@@ -546,7 +558,7 @@
}
if ( p )
- result = FT_NEXT_SHORT_LE( p );
+ result = FT_NEXT_USHORT_LE( p );
}
else
goto Fail;
@@ -556,8 +568,8 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadShortLE:"
+ *error = FT_THROW( Invalid_Stream_Operation );
+ FT_ERROR(( "FT_Stream_ReadUShortLE:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -565,8 +577,8 @@
}
- FT_BASE_DEF( FT_Long )
- FT_Stream_ReadOffset( FT_Stream stream,
+ FT_BASE_DEF( FT_ULong )
+ FT_Stream_ReadUOffset( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[3];
@@ -593,7 +605,7 @@
}
if ( p )
- result = FT_NEXT_OFF3( p );
+ result = FT_NEXT_UOFF3( p );
}
else
goto Fail;
@@ -603,8 +615,8 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadOffset:"
+ *error = FT_THROW( Invalid_Stream_Operation );
+ FT_ERROR(( "FT_Stream_ReadUOffset:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -612,8 +624,8 @@
}
- FT_BASE_DEF( FT_Long )
- FT_Stream_ReadLong( FT_Stream stream,
+ FT_BASE_DEF( FT_ULong )
+ FT_Stream_ReadULong( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[4];
@@ -640,7 +652,7 @@
}
if ( p )
- result = FT_NEXT_LONG( p );
+ result = FT_NEXT_ULONG( p );
}
else
goto Fail;
@@ -650,8 +662,8 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadLong:"
+ *error = FT_THROW( Invalid_Stream_Operation );
+ FT_ERROR(( "FT_Stream_ReadULong:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -659,8 +671,8 @@
}
- FT_BASE_DEF( FT_Long )
- FT_Stream_ReadLongLE( FT_Stream stream,
+ FT_BASE_DEF( FT_ULong )
+ FT_Stream_ReadULongLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[4];
@@ -687,7 +699,7 @@
}
if ( p )
- result = FT_NEXT_LONG_LE( p );
+ result = FT_NEXT_ULONG_LE( p );
}
else
goto Fail;
@@ -697,8 +709,8 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadLongLE:"
+ *error = FT_THROW( Invalid_Stream_Operation );
+ FT_ERROR(( "FT_Stream_ReadULongLE:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -715,8 +727,12 @@
FT_Bool frame_accessed = 0;
FT_Byte* cursor;
- if ( !fields || !stream )
- return FT_Err_Invalid_Argument;
+
+ if ( !fields )
+ return FT_THROW( Invalid_Argument );
+
+ if ( !stream )
+ return FT_THROW( Invalid_Stream_Handle );
cursor = stream->cursor;
@@ -748,7 +764,7 @@
if ( cursor + len > stream->limit )
{
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
@@ -764,43 +780,43 @@
case ft_frame_byte:
case ft_frame_schar: /* read a single byte */
- value = FT_NEXT_BYTE(cursor);
+ value = FT_NEXT_BYTE( cursor );
sign_shift = 24;
break;
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;
case ft_frame_short_le:
case ft_frame_ushort_le: /* read a 2-byte little-endian short */
- value = FT_NEXT_USHORT_LE(cursor);
+ value = FT_NEXT_USHORT_LE( cursor );
sign_shift = 16;
break;
case ft_frame_long_be:
case ft_frame_ulong_be: /* read a 4-byte big-endian long */
- value = FT_NEXT_ULONG(cursor);
+ value = FT_NEXT_ULONG( cursor );
sign_shift = 0;
break;
case ft_frame_long_le:
case ft_frame_ulong_le: /* read a 4-byte little-endian long */
- value = FT_NEXT_ULONG_LE(cursor);
+ value = FT_NEXT_ULONG_LE( cursor );
sign_shift = 0;
break;
case ft_frame_off3_be:
case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
- value = FT_NEXT_UOFF3(cursor);
+ value = FT_NEXT_UOFF3( cursor );
sign_shift = 8;
break;
case ft_frame_off3_le:
case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
- value = FT_NEXT_UOFF3_LE(cursor);
+ value = FT_NEXT_UOFF3_LE( cursor );
sign_shift = 8;
break;
@@ -819,15 +835,15 @@
p = (FT_Byte*)structure + fields->offset;
switch ( fields->size )
{
- case (8 / FT_CHAR_BIT):
+ case ( 8 / FT_CHAR_BIT ):
*(FT_Byte*)p = (FT_Byte)value;
break;
- case (16 / FT_CHAR_BIT):
+ case ( 16 / FT_CHAR_BIT ):
*(FT_UShort*)p = (FT_UShort)value;
break;
- case (32 / FT_CHAR_BIT):
+ case ( 32 / FT_CHAR_BIT ):
*(FT_UInt32*)p = (FT_UInt32)value;
break;
diff --git a/src/3rdparty/freetype/src/base/ftstroke.c b/src/3rdparty/freetype/src/base/ftstroke.c
index 75bcbded6a..5fc41fc8fa 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, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by */
+/* Copyright 2002-2006, 2008-2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -34,7 +34,7 @@
return o == FT_ORIENTATION_TRUETYPE ? FT_STROKER_BORDER_RIGHT
- : FT_STROKER_BORDER_LEFT ;
+ : FT_STROKER_BORDER_LEFT;
}
@@ -47,20 +47,21 @@
return o == FT_ORIENTATION_TRUETYPE ? FT_STROKER_BORDER_LEFT
- : FT_STROKER_BORDER_RIGHT ;
+ : FT_STROKER_BORDER_RIGHT;
}
- /***************************************************************************/
- /***************************************************************************/
- /***** *****/
- /***** BEZIER COMPUTATIONS *****/
- /***** *****/
- /***************************************************************************/
- /***************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** BEZIER COMPUTATIONS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
#define FT_SMALL_CONIC_THRESHOLD ( FT_ANGLE_PI / 6 )
-#define FT_SMALL_CUBIC_THRESHOLD ( FT_ANGLE_PI / 6 )
+#define FT_SMALL_CUBIC_THRESHOLD ( FT_ANGLE_PI / 8 )
+
#define FT_EPSILON 2
#define FT_IS_SMALL( x ) ( (x) > -FT_EPSILON && (x) < FT_EPSILON )
@@ -69,7 +70,7 @@
static FT_Pos
ft_pos_abs( FT_Pos x )
{
- return x >= 0 ? x : -x ;
+ return x >= 0 ? x : -x;
}
@@ -114,18 +115,28 @@
if ( close1 )
{
if ( close2 )
- *angle_in = *angle_out = 0;
+ {
+ /* basically a point; */
+ /* do nothing to retain original direction */
+ }
else
- *angle_in = *angle_out = FT_Atan2( d2.x, d2.y );
- }
- else if ( close2 )
- {
- *angle_in = *angle_out = FT_Atan2( d1.x, d1.y );
+ {
+ *angle_in =
+ *angle_out = FT_Atan2( d2.x, d2.y );
+ }
}
- else
+ else /* !close1 */
{
- *angle_in = FT_Atan2( d1.x, d1.y );
- *angle_out = FT_Atan2( d2.x, d2.y );
+ if ( close2 )
+ {
+ *angle_in =
+ *angle_out = FT_Atan2( d1.x, d1.y );
+ }
+ else
+ {
+ *angle_in = FT_Atan2( d1.x, d1.y );
+ *angle_out = FT_Atan2( d2.x, d2.y );
+ }
}
theta = ft_pos_abs( FT_Angle_Diff( *angle_in, *angle_out ) );
@@ -162,6 +173,17 @@
}
+ /* Return the average of `angle1' and `angle2'. */
+ /* This gives correct result even if `angle1' and `angle2' */
+ /* have opposite signs. */
+ static FT_Angle
+ ft_angle_mean( FT_Angle angle1,
+ FT_Angle angle2 )
+ {
+ return angle1 + FT_Angle_Diff( angle1, angle2 ) / 2;
+ }
+
+
static FT_Bool
ft_cubic_is_small_enough( FT_Vector* base,
FT_Angle *angle_in,
@@ -184,34 +206,70 @@
close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y );
close3 = FT_IS_SMALL( d3.x ) && FT_IS_SMALL( d3.y );
- if ( close1 || close3 )
+ if ( close1 )
{
if ( close2 )
{
- /* basically a point */
- *angle_in = *angle_out = *angle_mid = 0;
- }
- else if ( close1 )
- {
- *angle_in = *angle_mid = FT_Atan2( d2.x, d2.y );
- *angle_out = FT_Atan2( d3.x, d3.y );
+ if ( close3 )
+ {
+ /* basically a point; */
+ /* do nothing to retain original direction */
+ }
+ else /* !close3 */
+ {
+ *angle_in =
+ *angle_mid =
+ *angle_out = FT_Atan2( d3.x, d3.y );
+ }
}
- else /* close2 */
+ else /* !close2 */
{
- *angle_in = FT_Atan2( d1.x, d1.y );
- *angle_mid = *angle_out = FT_Atan2( d2.x, d2.y );
+ if ( close3 )
+ {
+ *angle_in =
+ *angle_mid =
+ *angle_out = FT_Atan2( d2.x, d2.y );
+ }
+ else /* !close3 */
+ {
+ *angle_in =
+ *angle_mid = FT_Atan2( d2.x, d2.y );
+ *angle_out = FT_Atan2( d3.x, d3.y );
+ }
}
}
- else if ( close2 )
+ else /* !close1 */
{
- *angle_in = *angle_mid = FT_Atan2( d1.x, d1.y );
- *angle_out = FT_Atan2( d3.x, d3.y );
- }
- else
- {
- *angle_in = FT_Atan2( d1.x, d1.y );
- *angle_mid = FT_Atan2( d2.x, d2.y );
- *angle_out = FT_Atan2( d3.x, d3.y );
+ if ( close2 )
+ {
+ if ( close3 )
+ {
+ *angle_in =
+ *angle_mid =
+ *angle_out = FT_Atan2( d1.x, d1.y );
+ }
+ else /* !close3 */
+ {
+ *angle_in = FT_Atan2( d1.x, d1.y );
+ *angle_out = FT_Atan2( d3.x, d3.y );
+ *angle_mid = ft_angle_mean( *angle_in, *angle_out );
+ }
+ }
+ else /* !close2 */
+ {
+ if ( close3 )
+ {
+ *angle_in = FT_Atan2( d1.x, d1.y );
+ *angle_mid =
+ *angle_out = FT_Atan2( d2.x, d2.y );
+ }
+ else /* !close3 */
+ {
+ *angle_in = FT_Atan2( d1.x, d1.y );
+ *angle_mid = FT_Atan2( d2.x, d2.y );
+ *angle_out = FT_Atan2( d3.x, d3.y );
+ }
+ }
}
theta1 = ft_pos_abs( FT_Angle_Diff( *angle_in, *angle_mid ) );
@@ -222,13 +280,13 @@
}
- /***************************************************************************/
- /***************************************************************************/
- /***** *****/
- /***** STROKE BORDERS *****/
- /***** *****/
- /***************************************************************************/
- /***************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** STROKE BORDERS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
typedef enum FT_StrokeTags_
{
@@ -239,7 +297,7 @@
} FT_StrokeTags;
-#define FT_STROKE_TAG_BEGIN_END (FT_STROKE_TAG_BEGIN|FT_STROKE_TAG_END)
+#define FT_STROKE_TAG_BEGIN_END ( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END )
typedef struct FT_StrokeBorderRec_
{
@@ -247,7 +305,7 @@
FT_UInt max_points;
FT_Vector* points;
FT_Byte* tags;
- FT_Bool movable;
+ FT_Bool movable; /* TRUE for ends of lineto borders */
FT_Int start; /* index of current sub-path start point */
FT_Memory memory;
FT_Bool valid;
@@ -368,6 +426,12 @@
}
else
{
+ /* don't add zero-length lineto */
+ if ( border->num_points > 0 &&
+ FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) &&
+ FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) )
+ return error;
+
/* add one point */
error = ft_stroke_border_grow( border, 1 );
if ( !error )
@@ -403,6 +467,7 @@
FT_Vector* vec = border->points + border->num_points;
FT_Byte* tag = border->tags + border->num_points;
+
vec[0] = *control;
vec[1] = *to;
@@ -411,7 +476,9 @@
border->num_points += 2;
}
+
border->movable = FALSE;
+
return error;
}
@@ -444,7 +511,9 @@
border->num_points += 3;
}
+
border->movable = FALSE;
+
return error;
}
@@ -530,7 +599,7 @@
if ( border->start >= 0 )
ft_stroke_border_close( border, FALSE );
- border->start = border->num_points;
+ border->start = border->num_points;
border->movable = FALSE;
return ft_stroke_border_lineto( border, to, FALSE );
@@ -673,38 +742,41 @@
}
}
- outline->n_points = (short)( outline->n_points + border->num_points );
+ outline->n_points = (short)( outline->n_points + border->num_points );
FT_ASSERT( FT_Outline_Check( outline ) == 0 );
}
- /***************************************************************************/
- /***************************************************************************/
- /***** *****/
- /***** STROKER *****/
- /***** *****/
- /***************************************************************************/
- /***************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** STROKER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
#define FT_SIDE_TO_ROTATE( s ) ( FT_ANGLE_PI2 - (s) * FT_ANGLE_PI )
typedef struct FT_StrokerRec_
{
- FT_Angle angle_in;
- FT_Angle angle_out;
- FT_Vector center;
- FT_Bool first_point;
- FT_Bool subpath_open;
- FT_Angle subpath_angle;
- FT_Vector subpath_start;
+ FT_Angle angle_in; /* direction into curr join */
+ FT_Angle angle_out; /* direction out of join */
+ FT_Vector center; /* current position */
+ FT_Fixed line_length; /* length of last lineto */
+ FT_Bool first_point; /* is this the start? */
+ FT_Bool subpath_open; /* is the subpath open? */
+ FT_Angle subpath_angle; /* subpath start direction */
+ FT_Vector subpath_start; /* subpath start position */
+ FT_Fixed subpath_line_length; /* subpath start lineto len */
+ FT_Bool handle_wide_strokes; /* use wide strokes logic? */
FT_Stroker_LineCap line_cap;
FT_Stroker_LineJoin line_join;
+ FT_Stroker_LineJoin line_join_saved;
FT_Fixed miter_limit;
FT_Fixed radius;
- FT_Bool valid;
FT_StrokeBorderRec borders[2];
FT_Library library;
@@ -717,13 +789,16 @@
FT_Stroker_New( FT_Library library,
FT_Stroker *astroker )
{
- FT_Error error;
+ FT_Error error; /* assigned in FT_NEW */
FT_Memory memory;
- FT_Stroker stroker;
+ FT_Stroker stroker = NULL;
if ( !library )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Library_Handle );
+
+ if ( !astroker )
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
@@ -734,7 +809,9 @@
ft_stroke_border_init( &stroker->borders[0], memory );
ft_stroke_border_init( &stroker->borders[1], memory );
}
+
*astroker = stroker;
+
return error;
}
@@ -748,11 +825,22 @@
FT_Stroker_LineJoin line_join,
FT_Fixed miter_limit )
{
+ if ( !stroker )
+ return;
+
stroker->radius = radius;
stroker->line_cap = line_cap;
stroker->line_join = line_join;
stroker->miter_limit = miter_limit;
+ /* ensure miter limit has sensible value */
+ if ( stroker->miter_limit < 0x10000L )
+ stroker->miter_limit = 0x10000L;
+
+ /* save line join style: */
+ /* line join style can be temporarily changed when stroking curves */
+ stroker->line_join_saved = line_join;
+
FT_Stroker_Rewind( stroker );
}
@@ -789,7 +877,7 @@
}
- /* creates a circular arc at a corner or cap */
+ /* create a circular arc at a corner or cap */
static FT_Error
ft_stroker_arcto( FT_Stroker stroker,
FT_Int side )
@@ -816,7 +904,7 @@
}
- /* adds a cap at the end of an opened path */
+ /* add a cap at the end of an opened path */
static FT_Error
ft_stroker_cap( FT_Stroker stroker,
FT_Angle angle,
@@ -830,6 +918,7 @@
/* add a round cap */
stroker->angle_in = angle;
stroker->angle_out = angle + FT_ANGLE_PI;
+
error = ft_stroker_arcto( stroker, side );
}
else if ( stroker->line_cap == FT_STROKER_LINECAP_SQUARE )
@@ -882,7 +971,7 @@
delta.x += stroker->center.x;
delta.y += stroker->center.y;
- error = ft_stroke_border_lineto( border, &delta, FALSE );
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
}
Exit:
@@ -893,40 +982,53 @@
/* process an inside corner, i.e. compute intersection */
static FT_Error
ft_stroker_inside( FT_Stroker stroker,
- FT_Int side)
+ FT_Int side,
+ FT_Fixed line_length )
{
FT_StrokeBorder border = stroker->borders + side;
FT_Angle phi, theta, rotate;
- FT_Fixed length, thcos, sigma;
+ FT_Fixed length, thcos;
FT_Vector delta;
FT_Error error = FT_Err_Ok;
+ FT_Bool intersect; /* use intersection of lines? */
rotate = FT_SIDE_TO_ROTATE( side );
- /* compute median angle */
- theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
- if ( theta == FT_ANGLE_PI )
- theta = rotate;
+ theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out ) / 2;
+
+ /* Only intersect borders if between two lineto's and both */
+ /* lines are long enough (line_length is zero for curves). */
+ if ( !border->movable || line_length == 0 )
+ intersect = FALSE;
else
- theta = theta / 2;
+ {
+ /* compute minimum required length of lines */
+ FT_Fixed min_length = ft_pos_abs( FT_MulFix( stroker->radius,
+ FT_Tan( theta ) ) );
- phi = stroker->angle_in + theta;
- thcos = FT_Cos( theta );
- sigma = FT_MulFix( stroker->miter_limit, thcos );
+ intersect = FT_BOOL( min_length &&
+ stroker->line_length >= min_length &&
+ line_length >= min_length );
+ }
- /* TODO: find better criterion to switch off the optimization */
- if ( sigma < 0x10000L )
+ if ( !intersect )
{
FT_Vector_From_Polar( &delta, stroker->radius,
stroker->angle_out + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
+
border->movable = FALSE;
}
else
{
+ /* compute median angle */
+ phi = stroker->angle_in + theta;
+
+ thcos = FT_Cos( theta );
+
length = FT_DivFix( stroker->radius, thcos );
FT_Vector_From_Polar( &delta, length, phi + rotate );
@@ -943,7 +1045,8 @@
/* process an outside corner, i.e. compute bevel/miter/round */
static FT_Error
ft_stroker_outside( FT_Stroker stroker,
- FT_Int side )
+ FT_Int side,
+ FT_Fixed line_length )
{
FT_StrokeBorder border = stroker->borders + side;
FT_Error error;
@@ -954,79 +1057,118 @@
error = ft_stroker_arcto( stroker, side );
else
{
- /* this is a mitered or beveled corner */
- FT_Fixed sigma, radius = stroker->radius;
- FT_Angle theta, phi;
- FT_Fixed thcos;
- FT_Bool miter;
+ /* this is a mitered (pointed) or beveled (truncated) corner */
+ FT_Fixed sigma = 0, radius = stroker->radius;
+ FT_Angle theta = 0, phi = 0;
+ FT_Fixed thcos = 0;
+ FT_Bool bevel, fixed_bevel;
rotate = FT_SIDE_TO_ROTATE( side );
- miter = FT_BOOL( stroker->line_join == FT_STROKER_LINEJOIN_MITER );
- theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
- if ( theta == FT_ANGLE_PI )
+ bevel =
+ FT_BOOL( stroker->line_join == FT_STROKER_LINEJOIN_BEVEL );
+
+ fixed_bevel =
+ FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_MITER_VARIABLE );
+
+ if ( !bevel )
{
- theta = rotate;
- phi = stroker->angle_in;
+ theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
+
+ if ( theta == FT_ANGLE_PI )
+ {
+ theta = rotate;
+ phi = stroker->angle_in;
+ }
+ else
+ {
+ theta /= 2;
+ phi = stroker->angle_in + theta + rotate;
+ }
+
+ thcos = FT_Cos( theta );
+ sigma = FT_MulFix( stroker->miter_limit, thcos );
+
+ /* is miter limit exceeded? */
+ if ( sigma < 0x10000L )
+ {
+ /* don't create variable bevels for very small deviations; */
+ /* FT_Sin(x) = 0 for x <= 57 */
+ if ( fixed_bevel || ft_pos_abs( theta ) > 57 )
+ bevel = TRUE;
+ }
}
- else
+
+ if ( bevel ) /* this is a bevel (broken angle) */
{
- theta = theta / 2;
- phi = stroker->angle_in + theta + rotate;
- }
+ if ( fixed_bevel )
+ {
+ /* the outer corners are simply joined together */
+ FT_Vector delta;
- thcos = FT_Cos( theta );
- sigma = FT_MulFix( stroker->miter_limit, thcos );
- /* FT_Sin(x) = 0 for x <= 57 */
- if ( sigma >= 0x10000L || ft_pos_abs( theta ) <= 57 )
- miter = FALSE;
+ /* add bevel */
+ FT_Vector_From_Polar( &delta,
+ radius,
+ stroker->angle_out + rotate );
+ delta.x += stroker->center.x;
+ delta.y += stroker->center.y;
- if ( miter ) /* this is a miter (broken angle) */
- {
- FT_Vector middle, delta;
- FT_Fixed length;
+ border->movable = FALSE;
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ }
+ else /* variable bevel */
+ {
+ /* the miter is truncated */
+ FT_Vector middle, delta;
+ FT_Fixed length;
- /* compute middle point */
- FT_Vector_From_Polar( &middle,
- FT_MulFix( radius, stroker->miter_limit ),
- phi );
- middle.x += stroker->center.x;
- middle.y += stroker->center.y;
+ /* compute middle point */
+ FT_Vector_From_Polar( &middle,
+ FT_MulFix( radius, stroker->miter_limit ),
+ phi );
+ middle.x += stroker->center.x;
+ middle.y += stroker->center.y;
- /* compute first angle point */
- length = FT_MulFix( radius,
- FT_DivFix( 0x10000L - sigma,
- ft_pos_abs( FT_Sin( theta ) ) ) );
+ /* compute first angle point */
+ length = FT_MulDiv( radius, 0x10000L - sigma,
+ ft_pos_abs( FT_Sin( theta ) ) );
- FT_Vector_From_Polar( &delta, length, phi + rotate );
- delta.x += middle.x;
- delta.y += middle.y;
+ FT_Vector_From_Polar( &delta, length, phi + rotate );
+ delta.x += middle.x;
+ delta.y += middle.y;
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ if ( error )
+ goto Exit;
- /* compute second angle point */
- FT_Vector_From_Polar( &delta, length, phi - rotate );
- delta.x += middle.x;
- delta.y += middle.y;
+ /* compute second angle point */
+ FT_Vector_From_Polar( &delta, length, phi - rotate );
+ delta.x += middle.x;
+ delta.y += middle.y;
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ if ( error )
+ goto Exit;
- /* finally, add a movable end point */
- FT_Vector_From_Polar( &delta, radius, stroker->angle_out + rotate );
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
+ /* finally, add an end point; only needed if not lineto */
+ /* (line_length is zero for curves) */
+ if ( line_length == 0 )
+ {
+ FT_Vector_From_Polar( &delta,
+ radius,
+ stroker->angle_out + rotate );
- error = ft_stroke_border_lineto( border, &delta, TRUE );
- }
+ delta.x += stroker->center.x;
+ delta.y += stroker->center.y;
- else /* this is a bevel (intersection) */
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ }
+ }
+ }
+ else /* this is a miter (intersection) */
{
FT_Fixed length;
FT_Vector delta;
@@ -1042,13 +1184,18 @@
if ( error )
goto Exit;
- /* now add end point */
- FT_Vector_From_Polar( &delta, stroker->radius,
- stroker->angle_out + rotate );
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
+ /* now add an end point; only needed if not lineto */
+ /* (line_length is zero for curves) */
+ if ( line_length == 0 )
+ {
+ FT_Vector_From_Polar( &delta,
+ stroker->radius,
+ stroker->angle_out + rotate );
+ delta.x += stroker->center.x;
+ delta.y += stroker->center.y;
- error = ft_stroke_border_lineto( border, &delta, TRUE );
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ }
}
}
@@ -1058,7 +1205,8 @@
static FT_Error
- ft_stroker_process_corner( FT_Stroker stroker )
+ ft_stroker_process_corner( FT_Stroker stroker,
+ FT_Fixed line_length )
{
FT_Error error = FT_Err_Ok;
FT_Angle turn;
@@ -1079,12 +1227,12 @@
inside_side = 1;
/* process the inside side */
- error = ft_stroker_inside( stroker, inside_side );
+ error = ft_stroker_inside( stroker, inside_side, line_length );
if ( error )
goto Exit;
/* process the outside side */
- error = ft_stroker_outside( stroker, 1 - inside_side );
+ error = ft_stroker_outside( stroker, 1 - inside_side, line_length );
Exit:
return error;
@@ -1095,7 +1243,8 @@
/* start of the subpath */
static FT_Error
ft_stroker_subpath_start( FT_Stroker stroker,
- FT_Angle start_angle )
+ FT_Angle start_angle,
+ FT_Fixed line_length )
{
FT_Vector delta;
FT_Vector point;
@@ -1120,9 +1269,11 @@
border++;
error = ft_stroke_border_moveto( border, &point );
- /* save angle for last cap */
- stroker->subpath_angle = start_angle;
- stroker->first_point = FALSE;
+ /* save angle, position, and line length for last join */
+ /* (line_length is zero for curves) */
+ stroker->subpath_angle = start_angle;
+ stroker->first_point = FALSE;
+ stroker->subpath_line_length = line_length;
Exit:
return error;
@@ -1140,10 +1291,22 @@
FT_Vector delta;
FT_Angle angle;
FT_Int side;
+ FT_Fixed line_length;
+
+
+ if ( !stroker || !to )
+ return FT_THROW( Invalid_Argument );
delta.x = to->x - stroker->center.x;
delta.y = to->y - stroker->center.y;
+ /* a zero-length lineto is a no-op; avoid creating a spurious corner */
+ if ( delta.x == 0 && delta.y == 0 )
+ goto Exit;
+
+ /* compute length of line */
+ line_length = FT_Vector_Length( &delta );
+
angle = FT_Atan2( delta.x, delta.y );
FT_Vector_From_Polar( &delta, stroker->radius, angle + FT_ANGLE_PI2 );
@@ -1153,7 +1316,7 @@
/* This is the first segment of a subpath. We need to */
/* add a point to each border at their respective starting */
/* point locations. */
- error = ft_stroker_subpath_start( stroker, angle );
+ error = ft_stroker_subpath_start( stroker, angle, line_length );
if ( error )
goto Exit;
}
@@ -1161,13 +1324,12 @@
{
/* process the current corner */
stroker->angle_out = angle;
- error = ft_stroker_process_corner( stroker );
+ error = ft_stroker_process_corner( stroker, line_length );
if ( error )
goto Exit;
}
/* now add a line segment to both the `inside' and `outside' paths */
-
for ( border = stroker->borders, side = 1; side >= 0; side--, border++ )
{
FT_Vector point;
@@ -1176,6 +1338,7 @@
point.x = to->x + delta.x;
point.y = to->y + delta.y;
+ /* the ends of lineto borders are movable */
error = ft_stroke_border_lineto( border, &point, TRUE );
if ( error )
goto Exit;
@@ -1184,8 +1347,9 @@
delta.y = -delta.y;
}
- stroker->angle_in = angle;
- stroker->center = *to;
+ stroker->angle_in = angle;
+ stroker->center = *to;
+ stroker->line_length = line_length;
Exit:
return error;
@@ -1203,10 +1367,26 @@
FT_Vector bez_stack[34];
FT_Vector* arc;
FT_Vector* limit = bez_stack + 30;
- FT_Angle start_angle;
FT_Bool first_arc = TRUE;
+ if ( !stroker || !control || !to )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ /* if all control points are coincident, this is a no-op; */
+ /* avoid creating a spurious corner */
+ if ( FT_IS_SMALL( stroker->center.x - control->x ) &&
+ FT_IS_SMALL( stroker->center.y - control->y ) &&
+ FT_IS_SMALL( control->x - to->x ) &&
+ FT_IS_SMALL( control->y - to->y ) )
+ {
+ stroker->center = *to;
+ goto Exit;
+ }
+
arc = bez_stack;
arc[0] = *to;
arc[1] = *control;
@@ -1217,11 +1397,15 @@
FT_Angle angle_in, angle_out;
- angle_in = angle_out = 0; /* remove compiler warnings */
+ /* initialize with current direction */
+ angle_in = angle_out = stroker->angle_in;
if ( arc < limit &&
!ft_conic_is_small_enough( arc, &angle_in, &angle_out ) )
{
+ if ( stroker->first_point )
+ stroker->angle_in = angle_in;
+
ft_conic_split( arc );
arc += 2;
continue;
@@ -1231,32 +1415,54 @@
{
first_arc = FALSE;
- start_angle = angle_in;
-
/* process corner if necessary */
if ( stroker->first_point )
- error = ft_stroker_subpath_start( stroker, start_angle );
+ error = ft_stroker_subpath_start( stroker, angle_in, 0 );
else
{
- stroker->angle_out = start_angle;
- error = ft_stroker_process_corner( stroker );
+ stroker->angle_out = angle_in;
+ error = ft_stroker_process_corner( stroker, 0 );
}
}
+ else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
+ FT_SMALL_CONIC_THRESHOLD / 4 )
+ {
+ /* if the deviation from one arc to the next is too great, */
+ /* add a round corner */
+ stroker->center = arc[2];
+ stroker->angle_out = angle_in;
+ stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
+
+ error = ft_stroker_process_corner( stroker, 0 );
+
+ /* reinstate line join style */
+ stroker->line_join = stroker->line_join_saved;
+ }
+
+ if ( error )
+ goto Exit;
/* the arc's angle is small enough; we can add it directly to each */
/* border */
{
- FT_Vector ctrl, end;
- FT_Angle theta, phi, rotate;
- FT_Fixed length;
- FT_Int side;
+ FT_Vector ctrl, end;
+ FT_Angle theta, phi, rotate, alpha0 = 0;
+ FT_Fixed length;
+ FT_StrokeBorder border;
+ FT_Int side;
theta = FT_Angle_Diff( angle_in, angle_out ) / 2;
phi = angle_in + theta;
length = FT_DivFix( stroker->radius, FT_Cos( theta ) );
- for ( side = 0; side <= 1; side++ )
+ /* compute direction of original arc */
+ if ( stroker->handle_wide_strokes )
+ alpha0 = FT_Atan2( arc[0].x - arc[2].x, arc[0].y - arc[2].y );
+
+ for ( border = stroker->borders, side = 0;
+ side <= 1;
+ side++, border++ )
{
rotate = FT_SIDE_TO_ROTATE( side );
@@ -1270,8 +1476,70 @@
end.x += arc[0].x;
end.y += arc[0].y;
- error = ft_stroke_border_conicto( stroker->borders + side,
- &ctrl, &end );
+ if ( stroker->handle_wide_strokes )
+ {
+ FT_Vector start;
+ FT_Angle alpha1;
+
+
+ /* determine whether the border radius is greater than the */
+ /* radius of curvature of the original arc */
+ start = border->points[border->num_points - 1];
+
+ alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
+
+ /* is the direction of the border arc opposite to */
+ /* that of the original arc? */
+ if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
+ FT_ANGLE_PI / 2 )
+ {
+ FT_Angle beta, gamma;
+ FT_Vector bvec, delta;
+ FT_Fixed blen, sinA, sinB, alen;
+
+
+ /* use the sine rule to find the intersection point */
+ beta = FT_Atan2( arc[2].x - start.x, arc[2].y - start.y );
+ gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
+
+ bvec.x = end.x - start.x;
+ bvec.y = end.y - start.y;
+
+ blen = FT_Vector_Length( &bvec );
+
+ sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
+ sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
+
+ alen = FT_MulDiv( blen, sinA, sinB );
+
+ FT_Vector_From_Polar( &delta, alen, beta );
+ delta.x += start.x;
+ delta.y += start.y;
+
+ /* circumnavigate the negative sector backwards */
+ border->movable = FALSE;
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ if ( error )
+ goto Exit;
+ error = ft_stroke_border_lineto( border, &end, FALSE );
+ if ( error )
+ goto Exit;
+ error = ft_stroke_border_conicto( border, &ctrl, &start );
+ if ( error )
+ goto Exit;
+ /* and then move to the endpoint */
+ error = ft_stroke_border_lineto( border, &end, FALSE );
+ if ( error )
+ goto Exit;
+
+ continue;
+ }
+
+ /* else fall through */
+ }
+
+ /* simply add an arc */
+ error = ft_stroke_border_conicto( border, &ctrl, &end );
if ( error )
goto Exit;
}
@@ -1279,8 +1547,7 @@
arc -= 2;
- if ( arc < bez_stack )
- stroker->angle_in = angle_out;
+ stroker->angle_in = angle_out;
}
stroker->center = *to;
@@ -1302,10 +1569,28 @@
FT_Vector bez_stack[37];
FT_Vector* arc;
FT_Vector* limit = bez_stack + 32;
- FT_Angle start_angle;
FT_Bool first_arc = TRUE;
+ if ( !stroker || !control1 || !control2 || !to )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ /* if all control points are coincident, this is a no-op; */
+ /* avoid creating a spurious corner */
+ if ( FT_IS_SMALL( stroker->center.x - control1->x ) &&
+ FT_IS_SMALL( stroker->center.y - control1->y ) &&
+ FT_IS_SMALL( control1->x - control2->x ) &&
+ FT_IS_SMALL( control1->y - control2->y ) &&
+ FT_IS_SMALL( control2->x - to->x ) &&
+ FT_IS_SMALL( control2->y - to->y ) )
+ {
+ stroker->center = *to;
+ goto Exit;
+ }
+
arc = bez_stack;
arc[0] = *to;
arc[1] = *control2;
@@ -1317,13 +1602,16 @@
FT_Angle angle_in, angle_mid, angle_out;
- /* remove compiler warnings */
- angle_in = angle_out = angle_mid = 0;
+ /* initialize with current direction */
+ angle_in = angle_out = angle_mid = stroker->angle_in;
if ( arc < limit &&
!ft_cubic_is_small_enough( arc, &angle_in,
&angle_mid, &angle_out ) )
{
+ if ( stroker->first_point )
+ stroker->angle_in = angle_in;
+
ft_cubic_split( arc );
arc += 3;
continue;
@@ -1334,36 +1622,56 @@
first_arc = FALSE;
/* process corner if necessary */
- start_angle = angle_in;
-
if ( stroker->first_point )
- error = ft_stroker_subpath_start( stroker, start_angle );
+ error = ft_stroker_subpath_start( stroker, angle_in, 0 );
else
{
- stroker->angle_out = start_angle;
- error = ft_stroker_process_corner( stroker );
+ stroker->angle_out = angle_in;
+ error = ft_stroker_process_corner( stroker, 0 );
}
- if ( error )
- goto Exit;
}
+ else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
+ FT_SMALL_CUBIC_THRESHOLD / 4 )
+ {
+ /* if the deviation from one arc to the next is too great, */
+ /* add a round corner */
+ stroker->center = arc[3];
+ stroker->angle_out = angle_in;
+ stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
+
+ error = ft_stroker_process_corner( stroker, 0 );
+
+ /* reinstate line join style */
+ stroker->line_join = stroker->line_join_saved;
+ }
+
+ if ( error )
+ goto Exit;
/* the arc's angle is small enough; we can add it directly to each */
/* border */
{
- FT_Vector ctrl1, ctrl2, end;
- FT_Angle theta1, phi1, theta2, phi2, rotate;
- FT_Fixed length1, length2;
- FT_Int side;
+ FT_Vector ctrl1, ctrl2, end;
+ FT_Angle theta1, phi1, theta2, phi2, rotate, alpha0 = 0;
+ FT_Fixed length1, length2;
+ FT_StrokeBorder border;
+ FT_Int side;
- theta1 = ft_pos_abs( angle_mid - angle_in ) / 2;
- theta2 = ft_pos_abs( angle_out - angle_mid ) / 2;
- phi1 = (angle_mid + angle_in ) / 2;
- phi2 = (angle_mid + angle_out ) / 2;
+ theta1 = FT_Angle_Diff( angle_in, angle_mid ) / 2;
+ theta2 = FT_Angle_Diff( angle_mid, angle_out ) / 2;
+ phi1 = ft_angle_mean( angle_in, angle_mid );
+ phi2 = ft_angle_mean( angle_mid, angle_out );
length1 = FT_DivFix( stroker->radius, FT_Cos( theta1 ) );
length2 = FT_DivFix( stroker->radius, FT_Cos( theta2 ) );
- for ( side = 0; side <= 1; side++ )
+ /* compute direction of original arc */
+ if ( stroker->handle_wide_strokes )
+ alpha0 = FT_Atan2( arc[0].x - arc[3].x, arc[0].y - arc[3].y );
+
+ for ( border = stroker->borders, side = 0;
+ side <= 1;
+ side++, border++ )
{
rotate = FT_SIDE_TO_ROTATE( side );
@@ -1381,16 +1689,81 @@
end.x += arc[0].x;
end.y += arc[0].y;
- error = ft_stroke_border_cubicto( stroker->borders + side,
- &ctrl1, &ctrl2, &end );
+ if ( stroker->handle_wide_strokes )
+ {
+ FT_Vector start;
+ FT_Angle alpha1;
+
+
+ /* determine whether the border radius is greater than the */
+ /* radius of curvature of the original arc */
+ start = border->points[border->num_points - 1];
+
+ alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
+
+ /* is the direction of the border arc opposite to */
+ /* that of the original arc? */
+ if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
+ FT_ANGLE_PI / 2 )
+ {
+ FT_Angle beta, gamma;
+ FT_Vector bvec, delta;
+ FT_Fixed blen, sinA, sinB, alen;
+
+
+ /* use the sine rule to find the intersection point */
+ beta = FT_Atan2( arc[3].x - start.x, arc[3].y - start.y );
+ gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
+
+ bvec.x = end.x - start.x;
+ bvec.y = end.y - start.y;
+
+ blen = FT_Vector_Length( &bvec );
+
+ sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
+ sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
+
+ alen = FT_MulDiv( blen, sinA, sinB );
+
+ FT_Vector_From_Polar( &delta, alen, beta );
+ delta.x += start.x;
+ delta.y += start.y;
+
+ /* circumnavigate the negative sector backwards */
+ border->movable = FALSE;
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ if ( error )
+ goto Exit;
+ error = ft_stroke_border_lineto( border, &end, FALSE );
+ if ( error )
+ goto Exit;
+ error = ft_stroke_border_cubicto( border,
+ &ctrl2,
+ &ctrl1,
+ &start );
+ if ( error )
+ goto Exit;
+ /* and then move to the endpoint */
+ error = ft_stroke_border_lineto( border, &end, FALSE );
+ if ( error )
+ goto Exit;
+
+ continue;
+ }
+
+ /* else fall through */
+ }
+
+ /* simply add an arc */
+ error = ft_stroke_border_cubicto( border, &ctrl1, &ctrl2, &end );
if ( error )
goto Exit;
}
}
arc -= 3;
- if ( arc < bez_stack )
- stroker->angle_in = angle_out;
+
+ stroker->angle_in = angle_out;
}
stroker->center = *to;
@@ -1407,6 +1780,9 @@
FT_Vector* to,
FT_Bool open )
{
+ if ( !stroker || !to )
+ return FT_THROW( Invalid_Argument );
+
/* We cannot process the first point, because there is not enough */
/* information regarding its corner/cap. The latter will be processed */
/* in the `FT_Stroker_EndSubPath' routine. */
@@ -1415,9 +1791,21 @@
stroker->center = *to;
stroker->subpath_open = open;
+ /* Determine if we need to check whether the border radius is greater */
+ /* than the radius of curvature of a curve, to handle this case */
+ /* specially. This is only required if bevel joins or butt caps may */
+ /* be created, because round & miter joins and round & square caps */
+ /* cover the negative sector created with wide strokes. */
+ stroker->handle_wide_strokes =
+ FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_ROUND ||
+ ( stroker->subpath_open &&
+ stroker->line_cap == FT_STROKER_LINECAP_BUTT ) );
+
/* record the subpath start point for each border */
stroker->subpath_start = *to;
+ stroker->angle_in = 0;
+
return FT_Err_Ok;
}
@@ -1447,6 +1835,7 @@
FT_Vector* src_point = left->points + left->num_points - 1;
FT_Byte* src_tag = left->tags + left->num_points - 1;
+
while ( src_point >= left->points + left->start )
{
*dst_point = *src_point;
@@ -1456,14 +1845,14 @@
dst_tag[0] &= ~FT_STROKE_TAG_BEGIN_END;
else
{
- FT_Byte ttag = (FT_Byte)( dst_tag[0] & FT_STROKE_TAG_BEGIN_END );
+ FT_Byte ttag =
+ (FT_Byte)( dst_tag[0] & FT_STROKE_TAG_BEGIN_END );
/* switch begin/end tags if necessary */
if ( ttag == FT_STROKE_TAG_BEGIN ||
ttag == FT_STROKE_TAG_END )
dst_tag[0] ^= FT_STROKE_TAG_BEGIN_END;
-
}
src_point--;
@@ -1494,10 +1883,17 @@
FT_Error error = FT_Err_Ok;
+ if ( !stroker )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
if ( stroker->subpath_open )
{
FT_StrokeBorder right = stroker->borders;
+
/* All right, this is an opened path, we need to add a cap between */
/* right & left, add the reverse of left, then add a final cap */
/* between left & right. */
@@ -1526,13 +1922,14 @@
FT_Angle turn;
FT_Int inside_side;
+
/* close the path if needed */
if ( stroker->center.x != stroker->subpath_start.x ||
stroker->center.y != stroker->subpath_start.y )
{
- error = FT_Stroker_LineTo( stroker, &stroker->subpath_start );
- if ( error )
- goto Exit;
+ error = FT_Stroker_LineTo( stroker, &stroker->subpath_start );
+ if ( error )
+ goto Exit;
}
/* process the corner */
@@ -1550,19 +1947,23 @@
if ( turn < 0 )
inside_side = 1;
- error = ft_stroker_inside( stroker, inside_side );
+ error = ft_stroker_inside( stroker,
+ inside_side,
+ stroker->subpath_line_length );
if ( error )
goto Exit;
/* process the outside side */
- error = ft_stroker_outside( stroker, 1 - inside_side );
+ error = ft_stroker_outside( stroker,
+ 1 - inside_side,
+ stroker->subpath_line_length );
if ( error )
goto Exit;
}
/* then end our two subpaths */
- ft_stroke_border_close( stroker->borders + 0, TRUE );
- ft_stroke_border_close( stroker->borders + 1, FALSE );
+ ft_stroke_border_close( stroker->borders + 0, FALSE );
+ ft_stroke_border_close( stroker->borders + 1, TRUE );
}
Exit:
@@ -1584,7 +1985,7 @@
if ( !stroker || border > 1 )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -1613,6 +2014,12 @@
FT_Error error;
+ if ( !stroker )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
error = ft_stroke_border_get_counts( stroker->borders + 0,
&count1, &count2 );
if ( error )
@@ -1627,8 +2034,12 @@
num_contours = count2 + count4;
Exit:
- *anum_points = num_points;
- *anum_contours = num_contours;
+ if ( anum_points )
+ *anum_points = num_points;
+
+ if ( anum_contours )
+ *anum_contours = num_contours;
+
return error;
}
@@ -1640,6 +2051,9 @@
FT_StrokerBorder border,
FT_Outline* outline )
{
+ if ( !stroker || !outline )
+ return;
+
if ( border == FT_STROKER_BORDER_LEFT ||
border == FT_STROKER_BORDER_RIGHT )
{
@@ -1684,13 +2098,16 @@
FT_Error error;
- FT_Int n; /* index of contour in outline */
- FT_UInt first; /* index of first point in contour */
- FT_Int tag; /* current point's state */
+ FT_Int n; /* index of contour in outline */
+ FT_UInt first; /* index of first point in contour */
+ FT_Int tag; /* current point's state */
+
+ if ( !outline )
+ return FT_THROW( Invalid_Outline );
- if ( !outline || !stroker )
- return FT_Err_Invalid_Argument;
+ if ( !stroker )
+ return FT_THROW( Invalid_Argument );
FT_Stroker_Rewind( stroker );
@@ -1851,9 +2268,13 @@
if ( error )
goto Exit;
- error = FT_Stroker_EndSubPath( stroker );
- if ( error )
- goto Exit;
+ /* don't try to end the path if no segments have been generated */
+ if ( !stroker->first_point )
+ {
+ error = FT_Stroker_EndSubPath( stroker );
+ if ( error )
+ goto Exit;
+ }
first = last + 1;
}
@@ -1864,12 +2285,13 @@
return error;
Invalid_Outline:
- return FT_Err_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
}
-/* declare an extern to access ft_outline_glyph_class global allocated
- in ftglyph.c, and use the FT_OUTLINE_GLYPH_CLASS_GET macro to access
- it when FT_CONFIG_OPTION_PIC is defined */
+
+ /* declare an extern to access `ft_outline_glyph_class' globally */
+ /* allocated in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */
+ /* macro to access it when FT_CONFIG_OPTION_PIC is defined */
#ifndef FT_CONFIG_OPTION_PIC
extern const FT_Glyph_Class ft_outline_glyph_class;
#endif
@@ -1883,16 +2305,20 @@
FT_Stroker stroker,
FT_Bool destroy )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
- FT_Library library = stroker->library;
- FT_UNUSED(library);
- if ( pglyph == NULL )
+ /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
+ FT_Library library = stroker->library;
+
+ FT_UNUSED( library );
+
+
+ if ( !pglyph )
goto Exit;
glyph = *pglyph;
- if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
+ if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
goto Exit;
{
@@ -1907,7 +2333,7 @@
}
{
- FT_OutlineGlyph oglyph = (FT_OutlineGlyph) glyph;
+ FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
FT_Outline* outline = &oglyph->outline;
FT_UInt num_points, num_contours;
@@ -1916,7 +2342,7 @@
if ( error )
goto Fail;
- (void)FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
+ FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
FT_Outline_Done( glyph->library, outline );
@@ -1957,16 +2383,20 @@
FT_Bool inside,
FT_Bool destroy )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
- FT_Library library = stroker->library;
- FT_UNUSED(library);
- if ( pglyph == NULL )
+ /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
+ FT_Library library = stroker->library;
+
+ FT_UNUSED( library );
+
+
+ if ( !pglyph )
goto Exit;
glyph = *pglyph;
- if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
+ if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
goto Exit;
{
@@ -1981,7 +2411,7 @@
}
{
- FT_OutlineGlyph oglyph = (FT_OutlineGlyph) glyph;
+ FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
FT_StrokerBorder border;
FT_Outline* outline = &oglyph->outline;
FT_UInt num_points, num_contours;
@@ -2000,8 +2430,8 @@
if ( error )
goto Fail;
- (void)FT_Stroker_GetBorderCounts( stroker, border,
- &num_points, &num_contours );
+ FT_Stroker_GetBorderCounts( stroker, border,
+ &num_points, &num_contours );
FT_Outline_Done( glyph->library, outline );
diff --git a/src/3rdparty/freetype/src/base/ftsynth.c b/src/3rdparty/freetype/src/base/ftsynth.c
index ba3c633e28..0567bd537a 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-2001, 2002, 2003, 2004, 2005, 2006, 2010 by */
+/* Copyright 2000-2006, 2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -33,6 +33,7 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_synth
+
/*************************************************************************/
/*************************************************************************/
/**** ****/
@@ -47,8 +48,13 @@
FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
{
FT_Matrix transform;
- FT_Outline* outline = &slot->outline;
+ FT_Outline* outline;
+
+
+ if ( !slot )
+ return;
+ outline = &slot->outline;
/* only oblique outline glyphs */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
@@ -62,7 +68,7 @@
transform.xx = 0x10000L;
transform.yx = 0x00000L;
- transform.xy = 0x06000L;
+ transform.xy = 0x0366AL;
transform.yy = 0x10000L;
FT_Outline_Transform( outline, &transform );
@@ -72,7 +78,7 @@
/*************************************************************************/
/*************************************************************************/
/**** ****/
- /**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/
+ /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
@@ -83,14 +89,20 @@
FT_EXPORT_DEF( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
{
- FT_Library library = slot->library;
- FT_Face face = slot->face;
+ FT_Library library;
+ FT_Face face;
FT_Error error;
FT_Pos xstr, ystr;
+ if ( !slot )
+ return;
+
+ library = slot->library;
+ face = slot->face;
+
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
- slot->format != FT_GLYPH_FORMAT_BITMAP )
+ slot->format != FT_GLYPH_FORMAT_BITMAP )
return;
/* some reasonable strength */
@@ -99,16 +111,9 @@
ystr = xstr;
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
- {
- /* ignore error */
- (void)FT_Outline_Embolden( &slot->outline, xstr );
+ FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
- /* this is more than enough for most glyphs; if you need accurate */
- /* values, you have to call FT_Outline_Get_CBox */
- xstr = xstr * 2;
- ystr = xstr;
- }
- else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
+ else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
{
/* round to full pixels */
xstr &= ~63;
@@ -145,11 +150,9 @@
slot->metrics.width += xstr;
slot->metrics.height += ystr;
- slot->metrics.horiBearingY += ystr;
slot->metrics.horiAdvance += xstr;
- slot->metrics.vertBearingX -= xstr / 2;
- slot->metrics.vertBearingY += ystr;
slot->metrics.vertAdvance += ystr;
+ slot->metrics.horiBearingY += ystr;
/* XXX: 16-bit overflow case must be excluded before here */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
diff --git a/src/3rdparty/freetype/src/base/ftsystem.c b/src/3rdparty/freetype/src/base/ftsystem.c
index 4d06d6db5c..2c6ddac10c 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-2001, 2002, 2006, 2008, 2009 by */
+/* Copyright 1996-2002, 2006, 2008-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -137,6 +137,7 @@
/* */
/*************************************************************************/
+#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
/*************************************************************************/
/* */
@@ -192,7 +193,9 @@
/* count :: The number of bytes to read from the stream. */
/* */
/* <Return> */
- /* The number of bytes actually read. */
+ /* The number of bytes actually read. If `count' is zero (this is, */
+ /* the function is used for seeking), a non-zero return value */
+ /* indicates an error. */
/* */
FT_CALLBACK_DEF( unsigned long )
ft_ansi_stream_io( FT_Stream stream,
@@ -203,6 +206,9 @@
FT_FILE* file;
+ if ( !count && offset > stream->size )
+ return 1;
+
file = STREAM_FILE( stream );
if ( stream->pos != offset )
@@ -222,7 +228,14 @@
if ( !stream )
- return FT_Err_Invalid_Stream_Handle;
+ return FT_THROW( Invalid_Stream_Handle );
+
+ stream->descriptor.pointer = NULL;
+ stream->pathname.pointer = (char*)filepathname;
+ stream->base = 0;
+ stream->pos = 0;
+ stream->read = NULL;
+ stream->close = NULL;
file = ft_fopen( filepathname, "rb" );
if ( !file )
@@ -230,17 +243,21 @@
FT_ERROR(( "FT_Stream_Open:"
" could not open `%s'\n", filepathname ));
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
}
ft_fseek( file, 0, SEEK_END );
stream->size = ft_ftell( file );
+ if ( !stream->size )
+ {
+ FT_ERROR(( "FT_Stream_Open:" ));
+ FT_ERROR(( " opened `%s' but zero-sized\n", filepathname ));
+ ft_fclose( file );
+ return FT_THROW( Cannot_Open_Stream );
+ }
ft_fseek( file, 0, SEEK_SET );
stream->descriptor.pointer = file;
- stream->pathname.pointer = (char*)filepathname;
- stream->pos = 0;
-
stream->read = ft_ansi_stream_io;
stream->close = ft_ansi_stream_close;
@@ -251,6 +268,7 @@
return FT_Err_Ok;
}
+#endif /* !FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
#ifdef FT_DEBUG_MEMORY
diff --git a/src/3rdparty/freetype/src/base/fttrigon.c b/src/3rdparty/freetype/src/base/fttrigon.c
index fdf433ab86..22b7ecf1bf 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, 2002, 2003, 2004, 2005 by */
+/* Copyright 2001-2005, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -15,169 +15,146 @@
/* */
/***************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* This is a fixed-point CORDIC implementation of trigonometric */
+ /* functions as well as transformations between Cartesian and polar */
+ /* coordinates. The angles are represented as 16.16 fixed-point values */
+ /* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that */
+ /* only vectors longer than 2^16*180/pi (or at least 22 bits) on a */
+ /* discrete Cartesian grid can have the same or better angular */
+ /* resolution. Therefore, to maintain this precision, some functions */
+ /* require an interim upscaling of the vectors, whereas others operate */
+ /* with 24-bit long vectors directly. */
+ /* */
+ /*************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_CALC_H
#include FT_TRIGONOMETRY_H
- /* the following is 0.2715717684432231 * 2^30 */
-#define FT_TRIG_COSCALE 0x11616E8EUL
+ /* the Cordic shrink factor 0.858785336480436 * 2^32 */
+#define FT_TRIG_SCALE 0xDBD95B16UL
+
+ /* the highest bit in overflow-safe vector components, */
+ /* MSB of 0.858785336480436 * sqrt(0.5) * 2^30 */
+#define FT_TRIG_SAFE_MSB 29
/* this table was generated for FT_PI = 180L << 16, i.e. degrees */
#define FT_TRIG_MAX_ITERS 23
- static const FT_Fixed
- ft_trig_arctan_table[24] =
+ static const FT_Angle
+ ft_trig_arctan_table[] =
{
- 4157273L, 2949120L, 1740967L, 919879L, 466945L, 234379L, 117304L,
- 58666L, 29335L, 14668L, 7334L, 3667L, 1833L, 917L, 458L, 229L, 115L,
+ 1740967L, 919879L, 466945L, 234379L, 117304L, 58666L, 29335L,
+ 14668L, 7334L, 3667L, 1833L, 917L, 458L, 229L, 115L,
57L, 29L, 14L, 7L, 4L, 2L, 1L
};
- /* the Cordic shrink factor, multiplied by 2^32 */
-#define FT_TRIG_SCALE 1166391785UL /* 0x4585BA38UL */
-
-#ifdef FT_CONFIG_HAS_INT64
+#ifdef FT_LONG64
/* multiply a given value by the CORDIC shrink factor */
static FT_Fixed
ft_trig_downscale( FT_Fixed val )
{
- FT_Fixed s;
- FT_Int64 v;
+ FT_Int s = 1;
- s = val;
- val = ( val >= 0 ) ? val : -val;
+ if ( val < 0 )
+ {
+ val = -val;
+ s = -1;
+ }
- v = ( val * (FT_Int64)FT_TRIG_SCALE ) + 0x100000000UL;
- val = (FT_Fixed)( v >> 32 );
+ /* 0x40000000 comes from regression analysis between true */
+ /* and CORDIC hypotenuse, so it minimizes the error */
+ val = (FT_Fixed)( ( (FT_Int64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
- return ( s >= 0 ) ? val : -val;
+ return s < 0 ? -val : val;
}
-#else /* !FT_CONFIG_HAS_INT64 */
+#else /* !FT_LONG64 */
/* multiply a given value by the CORDIC shrink factor */
static FT_Fixed
ft_trig_downscale( FT_Fixed val )
{
- FT_Fixed s;
- FT_UInt32 v1, v2, k1, k2, hi, lo1, lo2, lo3;
+ FT_Int s = 1;
+ FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
+
+ if ( val < 0 )
+ {
+ val = -val;
+ s = -1;
+ }
+
+ lo1 = val & 0x0000FFFFU;
+ hi1 = val >> 16;
+ lo2 = FT_TRIG_SCALE & 0x0000FFFFU;
+ hi2 = FT_TRIG_SCALE >> 16;
- s = val;
- val = ( val >= 0 ) ? val : -val;
+ lo = lo1 * lo2;
+ i1 = lo1 * hi2;
+ i2 = lo2 * hi1;
+ hi = hi1 * hi2;
- v1 = (FT_UInt32)val >> 16;
- v2 = (FT_UInt32)(val & 0xFFFFL);
+ /* Check carry overflow of i1 + i2 */
+ i1 += i2;
+ hi += (FT_UInt32)( i1 < i2 ) << 16;
- k1 = (FT_UInt32)FT_TRIG_SCALE >> 16; /* constant */
- k2 = (FT_UInt32)(FT_TRIG_SCALE & 0xFFFFL); /* constant */
+ hi += i1 >> 16;
+ i1 = i1 << 16;
- hi = k1 * v1;
- lo1 = k1 * v2 + k2 * v1; /* can't overflow */
+ /* Check carry overflow of i1 + lo */
+ lo += i1;
+ hi += ( lo < i1 );
- lo2 = ( k2 * v2 ) >> 16;
- lo3 = ( lo1 >= lo2 ) ? lo1 : lo2;
- lo1 += lo2;
+ /* 0x40000000 comes from regression analysis between true */
+ /* and CORDIC hypotenuse, so it minimizes the error */
- hi += lo1 >> 16;
- if ( lo1 < lo3 )
- hi += (FT_UInt32)0x10000UL;
+ /* Check carry overflow of lo + 0x40000000 */
+ lo += 0x40000000UL;
+ hi += ( lo < 0x40000000UL );
val = (FT_Fixed)hi;
- return ( s >= 0 ) ? val : -val;
+ return s < 0 ? -val : val;
}
-#endif /* !FT_CONFIG_HAS_INT64 */
+#endif /* !FT_LONG64 */
+ /* undefined and never called for zero vector */
static FT_Int
ft_trig_prenorm( FT_Vector* vec )
{
- FT_Fixed x, y, z;
- FT_Int shift;
+ FT_Pos x, y;
+ FT_Int shift;
x = vec->x;
y = vec->y;
- z = ( ( x >= 0 ) ? x : - x ) | ( (y >= 0) ? y : -y );
- shift = 0;
-
-#if 1
- /* determine msb bit index in `shift' */
- if ( z >= ( 1L << 16 ) )
- {
- z >>= 16;
- shift += 16;
- }
- if ( z >= ( 1L << 8 ) )
- {
- z >>= 8;
- shift += 8;
- }
- if ( z >= ( 1L << 4 ) )
- {
- z >>= 4;
- shift += 4;
- }
- if ( z >= ( 1L << 2 ) )
- {
- z >>= 2;
- shift += 2;
- }
- if ( z >= ( 1L << 1 ) )
- {
- z >>= 1;
- shift += 1;
- }
+ shift = FT_MSB( FT_ABS( x ) | FT_ABS( y ) );
- if ( shift <= 27 )
+ if ( shift <= FT_TRIG_SAFE_MSB )
{
- shift = 27 - shift;
- vec->x = x << shift;
- vec->y = y << shift;
+ shift = FT_TRIG_SAFE_MSB - shift;
+ vec->x = (FT_Pos)( (FT_ULong)x << shift );
+ vec->y = (FT_Pos)( (FT_ULong)y << shift );
}
else
{
- shift -= 27;
+ shift -= FT_TRIG_SAFE_MSB;
vec->x = x >> shift;
vec->y = y >> shift;
shift = -shift;
}
-#else /* 0 */
-
- if ( z < ( 1L << 27 ) )
- {
- do
- {
- shift++;
- z <<= 1;
- } while ( z < ( 1L << 27 ) );
- vec->x = x << shift;
- vec->y = y << shift;
- }
- else if ( z > ( 1L << 28 ) )
- {
- do
- {
- shift++;
- z >>= 1;
- } while ( z > ( 1L << 28 ) );
-
- vec->x = x >> shift;
- vec->y = y >> shift;
- shift = -shift;
- }
-
-#endif /* 0 */
-
return shift;
}
@@ -187,65 +164,50 @@
FT_Angle theta )
{
FT_Int i;
- FT_Fixed x, y, xtemp;
- const FT_Fixed *arctanptr;
+ FT_Fixed x, y, xtemp, b;
+ const FT_Angle *arctanptr;
x = vec->x;
y = vec->y;
- /* Get angle between -90 and 90 degrees */
- while ( theta <= -FT_ANGLE_PI2 )
+ /* Rotate inside [-PI/4,PI/4] sector */
+ while ( theta < -FT_ANGLE_PI4 )
{
- x = -x;
- y = -y;
- theta += FT_ANGLE_PI;
+ xtemp = y;
+ y = -x;
+ x = xtemp;
+ theta += FT_ANGLE_PI2;
}
- while ( theta > FT_ANGLE_PI2 )
+ while ( theta > FT_ANGLE_PI4 )
{
- x = -x;
- y = -y;
- theta -= FT_ANGLE_PI;
+ xtemp = -y;
+ y = x;
+ x = xtemp;
+ theta -= FT_ANGLE_PI2;
}
- /* Initial pseudorotation, with left shift */
arctanptr = ft_trig_arctan_table;
- if ( theta < 0 )
- {
- xtemp = x + ( y << 1 );
- y = y - ( x << 1 );
- x = xtemp;
- theta += *arctanptr++;
- }
- else
- {
- xtemp = x - ( y << 1 );
- y = y + ( x << 1 );
- x = xtemp;
- theta -= *arctanptr++;
- }
-
- /* Subsequent pseudorotations, with right shifts */
- i = 0;
- do
+ /* Pseudorotations, with right shifts */
+ for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
{
if ( theta < 0 )
{
- xtemp = x + ( y >> i );
- y = y - ( x >> i );
+ xtemp = x + ( ( y + b ) >> i );
+ y = y - ( ( x + b ) >> i );
x = xtemp;
theta += *arctanptr++;
}
else
{
- xtemp = x - ( y >> i );
- y = y + ( x >> i );
+ xtemp = x - ( ( y + b ) >> i );
+ y = y + ( ( x + b ) >> i );
x = xtemp;
theta -= *arctanptr++;
}
- } while ( ++i < FT_TRIG_MAX_ITERS );
+ }
vec->x = x;
vec->y = y;
@@ -255,72 +217,74 @@
static void
ft_trig_pseudo_polarize( FT_Vector* vec )
{
- FT_Fixed theta;
- FT_Fixed yi, i;
- FT_Fixed x, y;
- const FT_Fixed *arctanptr;
+ FT_Angle theta;
+ FT_Int i;
+ FT_Fixed x, y, xtemp, b;
+ const FT_Angle *arctanptr;
x = vec->x;
y = vec->y;
- /* Get the vector into the right half plane */
- theta = 0;
- if ( x < 0 )
- {
- x = -x;
- y = -y;
- theta = 2 * FT_ANGLE_PI2;
- }
-
- if ( y > 0 )
- theta = - theta;
-
- arctanptr = ft_trig_arctan_table;
-
- if ( y < 0 )
+ /* Get the vector into [-PI/4,PI/4] sector */
+ if ( y > x )
{
- /* Rotate positive */
- yi = y + ( x << 1 );
- x = x - ( y << 1 );
- y = yi;
- theta -= *arctanptr++; /* Subtract angle */
+ if ( y > -x )
+ {
+ theta = FT_ANGLE_PI2;
+ xtemp = y;
+ y = -x;
+ x = xtemp;
+ }
+ else
+ {
+ theta = y > 0 ? FT_ANGLE_PI : -FT_ANGLE_PI;
+ x = -x;
+ y = -y;
+ }
}
else
{
- /* Rotate negative */
- yi = y - ( x << 1 );
- x = x + ( y << 1 );
- y = yi;
- theta += *arctanptr++; /* Add angle */
+ if ( y < -x )
+ {
+ theta = -FT_ANGLE_PI2;
+ xtemp = -y;
+ y = x;
+ x = xtemp;
+ }
+ else
+ {
+ theta = 0;
+ }
}
- i = 0;
- do
+ arctanptr = ft_trig_arctan_table;
+
+ /* Pseudorotations, with right shifts */
+ for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
{
- if ( y < 0 )
+ if ( y > 0 )
{
- /* Rotate positive */
- yi = y + ( x >> i );
- x = x - ( y >> i );
- y = yi;
- theta -= *arctanptr++;
+ xtemp = x + ( ( y + b ) >> i );
+ y = y - ( ( x + b ) >> i );
+ x = xtemp;
+ theta += *arctanptr++;
}
else
{
- /* Rotate negative */
- yi = y - ( x >> i );
- x = x + ( y >> i );
- y = yi;
- theta += *arctanptr++;
+ xtemp = x - ( ( y + b ) >> i );
+ y = y + ( ( x + b ) >> i );
+ x = xtemp;
+ theta -= *arctanptr++;
}
- } while ( ++i < FT_TRIG_MAX_ITERS );
+ }
- /* round theta */
+ /* round theta to acknowledge its error that mostly comes */
+ /* from accumulated rounding errors in the arctan table */
if ( theta >= 0 )
- theta = FT_PAD_ROUND( theta, 32 );
+ theta = FT_PAD_ROUND( theta, 16 );
else
- theta = -FT_PAD_ROUND( -theta, 32 );
+ theta = -FT_PAD_ROUND( -theta, 16 );
vec->x = x;
vec->y = theta;
@@ -335,11 +299,11 @@
FT_Vector v;
- v.x = FT_TRIG_COSCALE >> 2;
+ v.x = FT_TRIG_SCALE >> 8;
v.y = 0;
ft_trig_pseudo_rotate( &v, angle );
- return v.x / ( 1 << 12 );
+ return ( v.x + 0x80L ) >> 8;
}
@@ -360,7 +324,7 @@
FT_Vector v;
- v.x = FT_TRIG_COSCALE >> 2;
+ v.x = FT_TRIG_SCALE >> 8;
v.y = 0;
ft_trig_pseudo_rotate( &v, angle );
@@ -395,11 +359,14 @@
FT_Vector_Unit( FT_Vector* vec,
FT_Angle angle )
{
- vec->x = FT_TRIG_COSCALE >> 2;
+ if ( !vec )
+ return;
+
+ vec->x = FT_TRIG_SCALE >> 8;
vec->y = 0;
ft_trig_pseudo_rotate( vec, angle );
- vec->x >>= 12;
- vec->y >>= 12;
+ vec->x = ( vec->x + 0x80L ) >> 8;
+ vec->y = ( vec->y + 0x80L ) >> 8;
}
@@ -421,6 +388,9 @@
FT_Vector v;
+ if ( !vec )
+ return;
+
v.x = vec->x;
v.y = vec->y;
@@ -442,8 +412,8 @@
else
{
shift = -shift;
- vec->x = v.x << shift;
- vec->y = v.y << shift;
+ vec->x = (FT_Pos)( (FT_ULong)v.x << shift );
+ vec->y = (FT_Pos)( (FT_ULong)v.y << shift );
}
}
}
@@ -458,16 +428,19 @@
FT_Vector v;
+ if ( !vec )
+ return 0;
+
v = *vec;
/* handle trivial cases */
if ( v.x == 0 )
{
- return ( v.y >= 0 ) ? v.y : -v.y;
+ return FT_ABS( v.y );
}
else if ( v.y == 0 )
{
- return ( v.x >= 0 ) ? v.x : -v.x;
+ return FT_ABS( v.x );
}
/* general case */
@@ -479,7 +452,7 @@
if ( shift > 0 )
return ( v.x + ( 1 << ( shift - 1 ) ) ) >> shift;
- return v.x << -shift;
+ return (FT_Fixed)( (FT_UInt32)v.x << -shift );
}
@@ -494,6 +467,9 @@
FT_Vector v;
+ if ( !vec || !length || !angle )
+ return;
+
v = *vec;
if ( v.x == 0 && v.y == 0 )
@@ -504,7 +480,8 @@
v.x = ft_trig_downscale( v.x );
- *length = ( shift >= 0 ) ? ( v.x >> shift ) : ( v.x << -shift );
+ *length = shift >= 0 ? ( v.x >> shift )
+ : (FT_Fixed)( (FT_UInt32)v.x << -shift );
*angle = v.y;
}
@@ -516,6 +493,9 @@
FT_Fixed length,
FT_Angle angle )
{
+ if ( !vec )
+ return;
+
vec->x = length;
vec->y = 0;
diff --git a/src/3rdparty/freetype/src/base/fttype1.c b/src/3rdparty/freetype/src/base/fttype1.c
index 3975584db8..47af19afb0 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, 2003, 2004 by */
+/* Copyright 2002-2004, 2011, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_SERVICE_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
@@ -28,19 +29,22 @@
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfoRec* afont_info )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error;
+ FT_Service_PsInfo service;
- if ( face )
- {
- FT_Service_PsInfo service = NULL;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
+ if ( !afont_info )
+ return FT_THROW( Invalid_Argument );
- FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
+ FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
- if ( service && service->ps_get_font_info )
- error = service->ps_get_font_info( face, afont_info );
- }
+ if ( service && service->ps_get_font_info )
+ error = service->ps_get_font_info( face, afont_info );
+ else
+ error = FT_THROW( Invalid_Argument );
return error;
}
@@ -51,8 +55,8 @@
FT_EXPORT_DEF( FT_Int )
FT_Has_PS_Glyph_Names( FT_Face face )
{
- FT_Int result = 0;
- FT_Service_PsInfo service = NULL;
+ FT_Int result = 0;
+ FT_Service_PsInfo service;
if ( face )
@@ -73,21 +77,50 @@
FT_Get_PS_Font_Private( FT_Face face,
PS_PrivateRec* afont_private )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error;
+ FT_Service_PsInfo service;
- if ( face )
- {
- FT_Service_PsInfo service = NULL;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !afont_private )
+ return FT_THROW( Invalid_Argument );
+
+ FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
+ if ( service && service->ps_get_font_private )
+ error = service->ps_get_font_private( face, afont_private );
+ else
+ error = FT_THROW( Invalid_Argument );
+
+ return error;
+ }
+
+ /* documentation is in t1tables.h */
+
+ FT_EXPORT_DEF( FT_Long )
+ FT_Get_PS_Font_Value( FT_Face face,
+ PS_Dict_Keys key,
+ FT_UInt idx,
+ void *value,
+ FT_Long value_len )
+ {
+ FT_Int result = 0;
+ FT_Service_PsInfo service = NULL;
+
+
+ if ( face )
+ {
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
- if ( service && service->ps_get_font_private )
- error = service->ps_get_font_private( face, afont_private );
+ if ( service && service->ps_get_font_value )
+ result = service->ps_get_font_value( face, key, idx,
+ value, value_len );
}
- return error;
+ return result;
}
diff --git a/src/3rdparty/freetype/src/base/ftutil.c b/src/3rdparty/freetype/src/base/ftutil.c
index 5f77be557a..56e2800eb6 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, 2004, 2005, 2006, 2007 by */
+/* Copyright 2002, 2004-2007, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -75,12 +75,12 @@
{
block = memory->alloc( memory, size );
if ( block == NULL )
- error = FT_Err_Out_Of_Memory;
+ error = FT_THROW( Out_Of_Memory );
}
else if ( size < 0 )
{
/* may help catch/prevent security issues */
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
*p_error = error;
@@ -98,6 +98,7 @@
{
FT_Error error = FT_Err_Ok;
+
block = ft_mem_qrealloc( memory, item_size,
cur_count, new_count, block, &error );
if ( !error && new_count > cur_count )
@@ -127,7 +128,7 @@
if ( cur_count < 0 || new_count < 0 || item_size < 0 )
{
/* may help catch/prevent nasty security issues */
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
else if ( new_count == 0 || item_size == 0 )
{
@@ -136,7 +137,7 @@
}
else if ( new_count > FT_INT_MAX/item_size )
{
- error = FT_Err_Array_Too_Large;
+ error = FT_THROW( Array_Too_Large );
}
else if ( cur_count == 0 )
{
@@ -153,7 +154,7 @@
block2 = memory->realloc( memory, cur_size, new_size, block );
if ( block2 == NULL )
- error = FT_Err_Out_Of_Memory;
+ error = FT_THROW( Out_Of_Memory );
else
block = block2;
}
@@ -244,6 +245,9 @@
FT_ListNode cur;
+ if ( !list )
+ return NULL;
+
cur = list->head;
while ( cur )
{
@@ -253,7 +257,7 @@
cur = cur->next;
}
- return (FT_ListNode)0;
+ return NULL;
}
@@ -263,8 +267,13 @@
FT_List_Add( FT_List list,
FT_ListNode node )
{
- FT_ListNode before = list->tail;
+ FT_ListNode before;
+
+
+ if ( !list || !node )
+ return;
+ before = list->tail;
node->next = 0;
node->prev = before;
@@ -284,8 +293,13 @@
FT_List_Insert( FT_List list,
FT_ListNode node )
{
- FT_ListNode after = list->head;
+ FT_ListNode after;
+
+
+ if ( !list || !node )
+ return;
+ after = list->head;
node->next = after;
node->prev = 0;
@@ -308,6 +322,9 @@
FT_ListNode before, after;
+ if ( !list || !node )
+ return;
+
before = node->prev;
after = node->next;
@@ -332,6 +349,9 @@
FT_ListNode before, after;
+ if ( !list || !node )
+ return;
+
before = node->prev;
after = node->next;
@@ -356,14 +376,19 @@
/* documentation is in ftlist.h */
FT_EXPORT_DEF( FT_Error )
- FT_List_Iterate( FT_List list,
- FT_List_Iterator iterator,
- void* user )
+ FT_List_Iterate( FT_List list,
+ FT_List_Iterator iterator,
+ void* user )
{
- FT_ListNode cur = list->head;
+ FT_ListNode cur;
FT_Error error = FT_Err_Ok;
+ if ( !list || !iterator )
+ return FT_THROW( Invalid_Argument );
+
+ cur = list->head;
+
while ( cur )
{
FT_ListNode next = cur->next;
@@ -391,6 +416,9 @@
FT_ListNode cur;
+ if ( !list || !memory )
+ return;
+
cur = list->head;
while ( cur )
{
@@ -410,92 +438,4 @@
}
- FT_BASE_DEF( FT_UInt32 )
- ft_highpow2( FT_UInt32 value )
- {
- FT_UInt32 value2;
-
-
- /*
- * We simply clear the lowest bit in each iteration. When
- * we reach 0, we know that the previous value was our result.
- */
- for ( ;; )
- {
- value2 = value & (value - 1); /* clear lowest bit */
- if ( value2 == 0 )
- break;
-
- value = value2;
- }
- return value;
- }
-
-
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_BASE_DEF( FT_Error )
- FT_Alloc( FT_Memory memory,
- FT_Long size,
- void* *P )
- {
- FT_Error error;
-
-
- (void)FT_ALLOC( *P, size );
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_QAlloc( FT_Memory memory,
- FT_Long size,
- void* *p )
- {
- FT_Error error;
-
-
- (void)FT_QALLOC( *p, size );
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Realloc( FT_Memory memory,
- FT_Long current,
- FT_Long size,
- void* *P )
- {
- FT_Error error;
-
-
- (void)FT_REALLOC( *P, current, size );
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_QRealloc( FT_Memory memory,
- FT_Long current,
- FT_Long size,
- void* *p )
- {
- FT_Error error;
-
-
- (void)FT_QREALLOC( *p, current, size );
- return error;
- }
-
-
- FT_BASE_DEF( void )
- FT_Free( FT_Memory memory,
- void* *P )
- {
- if ( *P )
- FT_MEM_FREE( *P );
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
/* END */
diff --git a/src/3rdparty/freetype/src/base/ftwinfnt.c b/src/3rdparty/freetype/src/base/ftwinfnt.c
index bc2e90e1f6..8e337fbe53 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, 2004 by */
+/* Copyright 2003, 2004, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_WINFONTS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_WINFNT_H
@@ -32,17 +33,18 @@
FT_Error error;
- error = FT_Err_Invalid_Argument;
+ if ( !face )
+ return FT_THROW( Invalid_Face_Handle );
- if ( face != NULL )
- {
- FT_FACE_LOOKUP_SERVICE( face, service, WINFNT );
+ if ( !header )
+ return FT_THROW( Invalid_Argument );
- if ( service != NULL )
- {
- error = service->get_header( face, header );
- }
- }
+ FT_FACE_LOOKUP_SERVICE( face, service, WINFNT );
+
+ if ( service )
+ error = service->get_header( face, header );
+ else
+ error = FT_THROW( Invalid_Argument );
return error;
}
diff --git a/src/3rdparty/freetype/src/base/md5.c b/src/3rdparty/freetype/src/base/md5.c
new file mode 100644
index 0000000000..52d96accd3
--- /dev/null
+++ b/src/3rdparty/freetype/src/base/md5.c
@@ -0,0 +1,296 @@
+/*
+ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
+ * MD5 Message-Digest Algorithm (RFC 1321).
+ *
+ * Homepage:
+ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
+ *
+ * Author:
+ * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
+ *
+ * This software was written by Alexander Peslyak in 2001. No copyright is
+ * claimed, and the software is hereby placed in the public domain.
+ * In case this attempt to disclaim copyright and place the software in the
+ * public domain is deemed null and void, then the software is
+ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
+ * general public under the following terms:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
+ *
+ * (This is a heavily cut-down "BSD license".)
+ *
+ * This differs from Colin Plumb's older public domain implementation in that
+ * no exactly 32-bit integer data type is required (any 32-bit or wider
+ * unsigned integer data type will do), there's no compile-time endianness
+ * configuration, and the function prototypes match OpenSSL's. No code from
+ * Colin Plumb's implementation has been reused; this comment merely compares
+ * the properties of the two independent implementations.
+ *
+ * The primary goals of this implementation are portability and ease of use.
+ * It is meant to be fast, but not as fast as possible. Some known
+ * optimizations are not included to reduce source code size and avoid
+ * compile-time configuration.
+ */
+
+#ifndef HAVE_OPENSSL
+
+#include <string.h>
+
+#include "md5.h"
+
+/*
+ * The basic MD5 functions.
+ *
+ * F and G are optimized compared to their RFC 1321 definitions for
+ * architectures that lack an AND-NOT instruction, just like in Colin Plumb's
+ * implementation.
+ */
+#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
+#define H(x, y, z) (((x) ^ (y)) ^ (z))
+#define H2(x, y, z) ((x) ^ ((y) ^ (z)))
+#define I(x, y, z) ((y) ^ ((x) | ~(z)))
+
+/*
+ * The MD5 transformation for all four rounds.
+ */
+#define STEP(f, a, b, c, d, x, t, s) \
+ (a) += f((b), (c), (d)) + (x) + (t); \
+ (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
+ (a) += (b);
+
+/*
+ * 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.
+ */
+#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
+#define SET(n) \
+ (*(MD5_u32plus *)&ptr[(n) * 4])
+#define GET(n) \
+ SET(n)
+#else
+#define SET(n) \
+ (ctx->block[(n)] = \
+ (MD5_u32plus)ptr[(n) * 4] | \
+ ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
+ ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
+ ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
+#define GET(n) \
+ (ctx->block[(n)])
+#endif
+
+/*
+ * 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)
+{
+ const unsigned char *ptr;
+ MD5_u32plus a, b, c, d;
+ MD5_u32plus saved_a, saved_b, saved_c, saved_d;
+
+ ptr = (const unsigned char *)data;
+
+ a = ctx->a;
+ b = ctx->b;
+ c = ctx->c;
+ d = ctx->d;
+
+ do {
+ saved_a = a;
+ saved_b = b;
+ saved_c = c;
+ saved_d = d;
+
+/* Round 1 */
+ STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
+ STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
+ STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
+ STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
+ STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
+ STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
+ STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
+ STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
+ STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
+ STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
+ STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
+ STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
+ STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
+ STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
+ STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
+ STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
+
+/* Round 2 */
+ STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
+ STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
+ STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
+ STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
+ STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
+ STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
+ STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
+ STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
+ STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
+ STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
+ STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
+ STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
+ STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
+ STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
+ STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
+ STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
+
+/* Round 3 */
+ STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
+ STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
+ STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
+ STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
+ STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
+ STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
+ STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
+ STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
+ STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
+ STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
+ STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
+ STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
+ STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
+ STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
+ STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
+ STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
+
+/* Round 4 */
+ STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
+ STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
+ STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
+ STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
+ STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
+ STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
+ STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
+ STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
+ STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
+ STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
+ STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
+ STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
+ STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
+ STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
+ STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
+ STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
+
+ a += saved_a;
+ b += saved_b;
+ c += saved_c;
+ d += saved_d;
+
+ ptr += 64;
+ } while (size -= 64);
+
+ ctx->a = a;
+ ctx->b = b;
+ ctx->c = c;
+ ctx->d = d;
+
+ return ptr;
+}
+
+void MD5_Init(MD5_CTX *ctx)
+{
+ ctx->a = 0x67452301;
+ ctx->b = 0xefcdab89;
+ ctx->c = 0x98badcfe;
+ ctx->d = 0x10325476;
+
+ ctx->lo = 0;
+ ctx->hi = 0;
+}
+
+void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
+{
+ MD5_u32plus saved_lo;
+ unsigned long used, available;
+
+ saved_lo = ctx->lo;
+ if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
+ ctx->hi++;
+ ctx->hi += size >> 29;
+
+ used = saved_lo & 0x3f;
+
+ if (used) {
+ available = 64 - used;
+
+ if (size < available) {
+ memcpy(&ctx->buffer[used], data, size);
+ return;
+ }
+
+ memcpy(&ctx->buffer[used], data, available);
+ data = (const unsigned char *)data + available;
+ size -= available;
+ body(ctx, ctx->buffer, 64);
+ }
+
+ if (size >= 64) {
+ data = body(ctx, data, size & ~(unsigned long)0x3f);
+ size &= 0x3f;
+ }
+
+ memcpy(ctx->buffer, data, size);
+}
+
+void MD5_Final(unsigned char *result, MD5_CTX *ctx)
+{
+ unsigned long used, available;
+
+ used = ctx->lo & 0x3f;
+
+ ctx->buffer[used++] = 0x80;
+
+ available = 64 - used;
+
+ if (available < 8) {
+ memset(&ctx->buffer[used], 0, available);
+ body(ctx, ctx->buffer, 64);
+ used = 0;
+ available = 64;
+ }
+
+ 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;
+
+ 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;
+
+ memset(ctx, 0, sizeof(*ctx));
+}
+
+#endif
diff --git a/src/3rdparty/freetype/src/base/md5.h b/src/3rdparty/freetype/src/base/md5.h
new file mode 100644
index 0000000000..2da44bf355
--- /dev/null
+++ b/src/3rdparty/freetype/src/base/md5.h
@@ -0,0 +1,45 @@
+/*
+ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
+ * MD5 Message-Digest Algorithm (RFC 1321).
+ *
+ * Homepage:
+ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
+ *
+ * Author:
+ * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
+ *
+ * This software was written by Alexander Peslyak in 2001. No copyright is
+ * claimed, and the software is hereby placed in the public domain.
+ * In case this attempt to disclaim copyright and place the software in the
+ * public domain is deemed null and void, then the software is
+ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
+ * general public under the following terms:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
+ *
+ * See md5.c for more information.
+ */
+
+#ifdef HAVE_OPENSSL
+#include <openssl/md5.h>
+#elif !defined(_MD5_H)
+#define _MD5_H
+
+/* Any 32-bit or wider unsigned integer data type will do */
+typedef unsigned int MD5_u32plus;
+
+typedef struct {
+ MD5_u32plus lo, hi;
+ MD5_u32plus a, b, c, d;
+ unsigned char buffer[64];
+ MD5_u32plus block[16];
+} MD5_CTX;
+
+extern void MD5_Init(MD5_CTX *ctx);
+extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
+extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
+
+#endif
diff --git a/src/3rdparty/freetype/src/base/rules.mk b/src/3rdparty/freetype/src/base/rules.mk
index 10f578abc8..cbd810732b 100644
--- a/src/3rdparty/freetype/src/base/rules.mk
+++ b/src/3rdparty/freetype/src/base/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by
+# Copyright 1996-2000, 2002-2009, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -19,8 +19,8 @@
# BASE_OBJ_S: The single-object base layer.
# BASE_OBJ_M: A list of all objects for a multiple-objects build.
# BASE_EXT_OBJ: A list of base layer extensions, i.e., components found
-# in `freetype/src/base' which are not compiled within the
-# base layer proper.
+# in `src/base' which are not compiled within the base
+# layer proper.
BASE_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SRC_DIR)/base)
@@ -33,12 +33,14 @@ BASE_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SRC_DIR)/base)
# All files listed here should be included in `ftbase.c' (for a `single'
# build).
#
-BASE_SRC := $(BASE_DIR)/ftadvanc.c \
+BASE_SRC := $(BASE_DIR)/basepic.c \
+ $(BASE_DIR)/ftadvanc.c \
$(BASE_DIR)/ftcalc.c \
$(BASE_DIR)/ftdbgmem.c \
$(BASE_DIR)/ftgloadr.c \
$(BASE_DIR)/ftobjs.c \
$(BASE_DIR)/ftoutln.c \
+ $(BASE_DIR)/ftpic.c \
$(BASE_DIR)/ftrfork.c \
$(BASE_DIR)/ftsnames.c \
$(BASE_DIR)/ftstream.c \
@@ -50,7 +52,11 @@ ifneq ($(ftmac_c),)
BASE_SRC += $(BASE_DIR)/$(ftmac_c)
endif
-BASE_H := $(BASE_DIR)/ftbase.h
+# for simplicity, we also handle `md5.c' (which gets included by `ftobjs.h')
+BASE_H := $(BASE_DIR)/basepic.h \
+ $(BASE_DIR)/ftbase.h \
+ $(BASE_DIR)/md5.c \
+ $(BASE_DIR)/md5.h
# Base layer `extensions' sources
#
diff --git a/src/3rdparty/freetype/src/bdf/README b/src/3rdparty/freetype/src/bdf/README
index e3f2ae3861..b761aba2b2 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/asn/developer/PDFS/TN/5005.BDF_Spec.pdf
+ http://partners.adobe.com/public/developer/en/font/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
@@ -119,7 +119,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*** Portions of the driver (that is, bdflib.c and bdf.h):
Copyright 2000 Computing Research Labs, New Mexico State University
-Copyright 2001-2002 Francesco Zappa Nardelli
+Copyright 2001-2002, 2011 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"),
diff --git a/src/3rdparty/freetype/src/bdf/bdf.h b/src/3rdparty/freetype/src/bdf/bdf.h
index 561b4158a5..d11be6f147 100644
--- a/src/3rdparty/freetype/src/bdf/bdf.h
+++ b/src/3rdparty/freetype/src/bdf/bdf.h
@@ -1,6 +1,6 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001, 2002, 2003, 2004 Francesco Zappa Nardelli
+ * Copyright 2001-2004, 2011 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"),
@@ -226,8 +226,10 @@ FT_BEGIN_HEADER
void* internal; /* Internal data for the font. */
- unsigned long nmod[2048]; /* Bitmap indicating modified glyphs. */
- unsigned long umod[2048]; /* Bitmap indicating modified */
+ /* The size of the next two arrays must be in sync with the */
+ /* size of the `have' array in the `bdf_parse_t' structure. */
+ unsigned long nmod[34816]; /* Bitmap indicating modified glyphs. */
+ unsigned long umod[34816]; /* Bitmap indicating modified */
/* unencoded glyphs. */
unsigned short modified; /* Boolean indicating font modified. */
unsigned short bpp; /* Bits per pixel. */
diff --git a/src/3rdparty/freetype/src/bdf/bdfdrivr.c b/src/3rdparty/freetype/src/bdf/bdfdrivr.c
index 631ec460e7..55a428c1b6 100644
--- a/src/3rdparty/freetype/src/bdf/bdfdrivr.c
+++ b/src/3rdparty/freetype/src/bdf/bdfdrivr.c
@@ -2,7 +2,7 @@
FreeType font driver for bdf files
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by
+ Copyright (C) 2001-2008, 2011, 2013, 2014 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -30,6 +30,7 @@ THE SOFTWARE.
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H
#include FT_BDF_H
+#include FT_TRUETYPE_IDS_H
#include FT_SERVICE_BDF_H
#include FT_SERVICE_XFREE86_NAME_H
@@ -71,7 +72,7 @@ THE SOFTWARE.
cmap->num_encodings = face->bdffont->glyphs_used;
cmap->encodings = face->en_table;
- return BDF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -181,7 +182,7 @@ THE SOFTWARE.
}
- FT_CALLBACK_TABLE_DEF
+ static
const FT_CMap_ClassRec bdf_cmap_class =
{
sizeof ( BDF_CMapRec ),
@@ -197,7 +198,7 @@ THE SOFTWARE.
static FT_Error
bdf_interpret_style( BDF_Face bdf )
{
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Face face = FT_FACE( bdf );
FT_Memory memory = face->memory;
bdf_font_t* font = bdf->bdffont;
@@ -242,8 +243,6 @@ THE SOFTWARE.
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
strings[0] = (char *)(prop->value.atom);
- len = 0;
-
for ( len = 0, nn = 0; nn < 4; nn++ )
{
lengths[nn] = 0;
@@ -331,8 +330,6 @@ THE SOFTWARE.
FT_FREE( bdfface->available_sizes );
FT_FREE( face->bdffont );
-
- FT_TRACE4(( "BDF_Face_Done: done face\n" ));
}
@@ -343,7 +340,7 @@ THE SOFTWARE.
FT_Int num_params,
FT_Parameter* params )
{
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
BDF_Face face = (BDF_Face)bdfface;
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -352,9 +349,10 @@ THE SOFTWARE.
FT_UNUSED( num_params );
FT_UNUSED( params );
- FT_UNUSED( face_index );
+ FT_TRACE2(( "BDF driver\n" ));
+
if ( FT_STREAM_SEEK( 0 ) )
goto Exit;
@@ -364,9 +362,9 @@ THE SOFTWARE.
options.font_spacing = BDF_PROPORTIONAL;
error = bdf_load_font( stream, memory, &options, &font );
- if ( error == BDF_Err_Missing_Startfont_Field )
+ if ( FT_ERR_EQ( error, Missing_Startfont_Field ) )
{
- FT_TRACE2(( "[not a valid BDF file]\n" ));
+ FT_TRACE2(( " not a BDF file\n" ));
goto Fail;
}
else if ( error )
@@ -374,22 +372,36 @@ 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.
+ * 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
+ * opened by the specified driver.
+ */
+ if ( face_index > 0 ) {
+ FT_ERROR(( "BDF_Face_Init: invalid face index\n" ));
+ BDF_Face_Done( bdfface );
+ return FT_THROW( Invalid_Argument );
+ }
+
{
bdf_property_t* prop = NULL;
- FT_TRACE4(( "number of glyphs: %d (%d)\n",
+ FT_TRACE4(( " number of glyphs: allocated %d (used %d)\n",
font->glyphs_size,
font->glyphs_used ));
- FT_TRACE4(( "number of unencoded glyphs: %d (%d)\n",
+ FT_TRACE4(( " number of unencoded glyphs: allocated %d (used %d)\n",
font->unencoded_size,
font->unencoded_used ));
bdfface->num_faces = 1;
bdfface->face_index = 0;
- bdfface->face_flags = FT_FACE_FLAG_FIXED_SIZES |
- FT_FACE_FLAG_HORIZONTAL |
- FT_FACE_FLAG_FAST_GLYPHS;
+
+ bdfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
+ FT_FACE_FLAG_HORIZONTAL |
+ FT_FACE_FLAG_FAST_GLYPHS;
prop = bdf_get_font_property( font, "SPACING" );
if ( prop && prop->format == BDF_ATOM &&
@@ -481,7 +493,7 @@ THE SOFTWARE.
for ( n = 0; n < font->glyphs_size; n++ )
{
(face->en_table[n]).enc = cur[n].encoding;
- FT_TRACE4(( "idx %d, val 0x%lX\n", n, cur[n].encoding ));
+ FT_TRACE4(( " idx %d, val 0x%lX\n", n, cur[n].encoding ));
(face->en_table[n]).glyph = (FT_Short)n;
if ( cur[n].encoding == font->default_char )
@@ -489,7 +501,8 @@ THE SOFTWARE.
if ( n < FT_UINT_MAX )
face->default_glyph = (FT_UInt)n;
else
- FT_TRACE1(( "idx %d is too large for this system\n", n ));
+ FT_TRACE1(( "BDF_Face_Init:"
+ " idx %d is too large for this system\n", n ));
}
}
}
@@ -540,14 +553,15 @@ THE SOFTWARE.
charmap.face = FT_FACE( face );
charmap.encoding = FT_ENCODING_NONE;
- charmap.platform_id = 0;
- charmap.encoding_id = 0;
+ /* initial platform/encoding should indicate unset status? */
+ charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
+ charmap.encoding_id = TT_APPLE_ID_DEFAULT;
if ( unicode_charmap )
{
charmap.encoding = FT_ENCODING_UNICODE;
- charmap.platform_id = 3;
- charmap.encoding_id = 1;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
}
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
@@ -571,8 +585,8 @@ THE SOFTWARE.
charmap.face = FT_FACE( face );
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
- charmap.platform_id = 7;
- charmap.encoding_id = 0;
+ charmap.platform_id = TT_PLATFORM_ADOBE;
+ charmap.encoding_id = TT_ADOBE_ID_STANDARD;
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
@@ -588,7 +602,7 @@ THE SOFTWARE.
Fail:
BDF_Face_Done( bdfface );
- return BDF_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
}
@@ -605,7 +619,7 @@ THE SOFTWARE.
size->metrics.descender = -bdffont->font_descent << 6;
size->metrics.max_advance = bdffont->bbx.width << 6;
- return BDF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -616,7 +630,7 @@ THE SOFTWARE.
FT_Face face = size->face;
FT_Bitmap_Size* bsize = face->available_sizes;
bdf_font_t* bdffont = ( (BDF_Face)face )->bdffont;
- FT_Error error = BDF_Err_Invalid_Pixel_Size;
+ FT_Error error = FT_ERR( Invalid_Pixel_Size );
FT_Long height;
@@ -627,17 +641,17 @@ THE SOFTWARE.
{
case FT_SIZE_REQUEST_TYPE_NOMINAL:
if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
- error = BDF_Err_Ok;
+ error = FT_Err_Ok;
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
if ( height == ( bdffont->font_ascent +
bdffont->font_descent ) )
- error = BDF_Err_Ok;
+ error = FT_Err_Ok;
break;
default:
- error = BDF_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
break;
}
@@ -657,7 +671,7 @@ THE SOFTWARE.
{
BDF_Face bdf = (BDF_Face)FT_SIZE_FACE( size );
FT_Face face = FT_FACE( bdf );
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Bitmap* bitmap = &slot->bitmap;
bdf_glyph_t glyph;
int bpp = bdf->bdffont->bpp;
@@ -665,12 +679,20 @@ THE SOFTWARE.
FT_UNUSED( load_flags );
- if ( !face || glyph_index >= (FT_UInt)face->num_glyphs )
+ if ( !face )
+ {
+ error = FT_THROW( Invalid_Face_Handle );
+ goto Exit;
+ }
+
+ if ( glyph_index >= (FT_UInt)face->num_glyphs )
{
- error = BDF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
+ FT_TRACE1(( "BDF_Glyph_Load: glyph index %d\n", glyph_index ));
+
/* index 0 is the undefined glyph */
if ( glyph_index == 0 )
glyph_index = bdf->default_glyph;
@@ -759,8 +781,8 @@ THE SOFTWARE.
case BDF_INTEGER:
if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
{
- FT_TRACE1(( "bdf_get_bdf_property: " ));
- FT_TRACE1(( "too large integer 0x%x is truncated\n" ));
+ FT_TRACE1(( "bdf_get_bdf_property:"
+ " too large integer 0x%x is truncated\n" ));
}
aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
aproperty->u.integer = (FT_Int32)prop->value.l;
@@ -769,8 +791,8 @@ THE SOFTWARE.
case BDF_CARDINAL:
if ( prop->value.ul > 0xFFFFFFFFUL )
{
- FT_TRACE1(( "bdf_get_bdf_property: " ));
- FT_TRACE1(( "too large cardinal 0x%x is truncated\n" ));
+ FT_TRACE1(( "bdf_get_bdf_property:"
+ " too large cardinal 0x%x is truncated\n" ));
}
aproperty->type = BDF_PROPERTY_TYPE_CARDINAL;
aproperty->u.cardinal = (FT_UInt32)prop->value.ul;
@@ -783,7 +805,7 @@ THE SOFTWARE.
}
Fail:
- return BDF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -845,9 +867,9 @@ THE SOFTWARE.
0,
- (FT_Module_Constructor)0,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) bdf_driver_requester
+ 0, /* FT_Module_Constructor */
+ 0, /* FT_Module_Destructor */
+ bdf_driver_requester
},
sizeof ( BDF_FaceRec ),
@@ -861,15 +883,11 @@ THE SOFTWARE.
0, /* FT_Slot_InitFunc */
0, /* FT_Slot_DoneFunc */
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
BDF_Glyph_Load,
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
+ 0, /* FT_Face_GetKerningFunc */
+ 0, /* FT_Face_AttachFunc */
+ 0, /* FT_Face_GetAdvancesFunc */
BDF_Size_Request,
BDF_Size_Select
diff --git a/src/3rdparty/freetype/src/bdf/bdfdrivr.h b/src/3rdparty/freetype/src/bdf/bdfdrivr.h
index db7093bb45..ca0dae50d2 100644
--- a/src/3rdparty/freetype/src/bdf/bdfdrivr.h
+++ b/src/3rdparty/freetype/src/bdf/bdfdrivr.h
@@ -38,7 +38,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
typedef struct BDF_encoding_el_
diff --git a/src/3rdparty/freetype/src/bdf/bdferror.h b/src/3rdparty/freetype/src/bdf/bdferror.h
index b27fa333bb..ea545aca06 100644
--- a/src/3rdparty/freetype/src/bdf/bdferror.h
+++ b/src/3rdparty/freetype/src/bdf/bdferror.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2001, 2002 Francesco Zappa Nardelli
+ * Copyright 2001, 2002, 2012 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"),
@@ -33,6 +33,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX BDF_Err_
#define FT_ERR_BASE FT_Mod_Err_BDF
diff --git a/src/3rdparty/freetype/src/bdf/bdflib.c b/src/3rdparty/freetype/src/bdf/bdflib.c
index 5fa5868c71..abcfdee7be 100644
--- a/src/3rdparty/freetype/src/bdf/bdflib.c
+++ b/src/3rdparty/freetype/src/bdf/bdflib.c
@@ -1,6 +1,6 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+ * Copyright 2001-2014
* Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -169,6 +169,55 @@
sizeof ( _bdf_properties[0] );
+ /* An auxiliary macro to parse properties, to be used in conditionals. */
+ /* It behaves like `strncmp' but also tests the following character */
+ /* whether it is a whitespace or NULL. */
+ /* `property' is a constant string of length `n' to compare with. */
+#define _bdf_strncmp( name, property, n ) \
+ ( ft_strncmp( name, property, n ) || \
+ !( name[n] == ' ' || \
+ name[n] == '\0' || \
+ name[n] == '\n' || \
+ name[n] == '\r' || \
+ name[n] == '\t' ) )
+
+ /* Auto correction messages. */
+#define ACMSG1 "FONT_ASCENT property missing. " \
+ "Added `FONT_ASCENT %hd'.\n"
+#define ACMSG2 "FONT_DESCENT property missing. " \
+ "Added `FONT_DESCENT %hd'.\n"
+#define ACMSG3 "Font width != actual width. Old: %hd New: %hd.\n"
+#define ACMSG4 "Font left bearing != actual left bearing. " \
+ "Old: %hd New: %hd.\n"
+#define ACMSG5 "Font ascent != actual ascent. Old: %hd New: %hd.\n"
+#define ACMSG6 "Font descent != actual descent. Old: %hd New: %hd.\n"
+#define ACMSG7 "Font height != actual height. Old: %hd New: %hd.\n"
+#define ACMSG8 "Glyph scalable width (SWIDTH) adjustments made.\n"
+#define ACMSG9 "SWIDTH field missing at line %ld. Set automatically.\n"
+#define ACMSG10 "DWIDTH field missing at line %ld. Set to glyph width.\n"
+#define ACMSG11 "SIZE bits per pixel field adjusted to %hd.\n"
+#define ACMSG12 "Duplicate encoding %ld (%s) changed to unencoded.\n"
+#define ACMSG13 "Glyph %ld extra rows removed.\n"
+#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"
+
+ /* Error messages. */
+#define ERRMSG1 "[line %ld] Missing `%s' line.\n"
+#define ERRMSG2 "[line %ld] Font header corrupted or missing fields.\n"
+#define ERRMSG3 "[line %ld] Font glyphs corrupted or missing fields.\n"
+#define ERRMSG4 "[line %ld] BBX too big.\n"
+#define ERRMSG5 "[line %ld] `%s' value too big.\n"
+#define ERRMSG6 "[line %ld] Input line too long.\n"
+#define ERRMSG7 "[line %ld] Font name too long.\n"
+#define ERRMSG8 "[line %ld] Invalid `%s' value.\n"
+#define ERRMSG9 "[line %ld] Invalid keyword.\n"
+
+ /* Debug messages. */
+#define DBGMSG1 " [%6ld] %s" /* no \n */
+#define DBGMSG2 " (0x%lX)\n"
+
+
/*************************************************************************/
/* */
/* Hash table utilities for the properties. */
@@ -217,7 +266,7 @@
{
hashnode* obp = ht->table, *bp, *nbp;
int i, sz = ht->size;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
ht->size <<= 1;
@@ -245,8 +294,8 @@
hash_init( hashtable* ht,
FT_Memory memory )
{
- int sz = INITIAL_HT_SIZE;
- FT_Error error = BDF_Err_Ok;
+ int sz = INITIAL_HT_SIZE;
+ FT_Error error = FT_Err_Ok;
ht->size = sz;
@@ -285,8 +334,9 @@
hashtable* ht,
FT_Memory memory )
{
- hashnode nn, *bp = hash_bucket( key, ht );
- FT_Error error = BDF_Err_Ok;
+ hashnode nn;
+ hashnode* bp = hash_bucket( key, ht );
+ FT_Error error = FT_Err_Ok;
nn = *bp;
@@ -377,7 +427,8 @@
bdf_font_t* font;
bdf_options_t* opts;
- unsigned long have[2048];
+ unsigned long have[34816]; /* must be in sync with `nmod' and `umod' */
+ /* arrays from `bdf_font_t' structure */
_bdf_list_t list;
FT_Memory memory;
@@ -418,20 +469,20 @@
_bdf_list_ensure( _bdf_list_t* list,
unsigned long num_items ) /* same as _bdf_list_t.used */
{
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( num_items > list->size )
{
unsigned long oldsize = list->size; /* same as _bdf_list_t.size */
- unsigned long newsize = oldsize + ( oldsize >> 1 ) + 4;
+ unsigned long newsize = oldsize + ( oldsize >> 1 ) + 5;
unsigned long bigsize = (unsigned long)( FT_INT_MAX / sizeof ( char* ) );
FT_Memory memory = list->memory;
if ( oldsize == bigsize )
{
- error = BDF_Err_Out_Of_Memory;
+ error = FT_THROW( Out_Of_Memory );
goto Exit;
}
else if ( newsize < oldsize || newsize > bigsize )
@@ -470,13 +521,18 @@
}
+ /* An empty string for empty fields. */
+
+ static const char empty[1] = { 0 }; /* XXX eliminate this */
+
+
static char *
_bdf_list_join( _bdf_list_t* list,
int c,
unsigned long *alen )
{
unsigned long i, j;
- char *fp, *dp;
+ char* dp;
*alen = 0;
@@ -487,24 +543,26 @@
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
{
- fp = list->field[i];
+ char* fp = list->field[i];
+
+
while ( *fp )
dp[j++] = *fp++;
if ( i + 1 < list->used )
dp[j++] = (char)c;
}
- dp[j] = 0;
+ if ( dp != empty )
+ dp[j] = 0;
*alen = j;
return dp;
}
- /* An empty string for empty fields. */
-
- static const char empty[1] = { 0 }; /* XXX eliminate this */
-
+ /* The code below ensures that we have at least 4 + 1 `field' */
+ /* elements in `list' (which are possibly NULL) so that we */
+ /* don't have to check the number of fields in most cases. */
static FT_Error
_bdf_list_split( _bdf_list_t* list,
@@ -515,11 +573,19 @@
int mult, final_empty;
char *sp, *ep, *end;
char seps[32];
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* Initialize the list. */
list->used = 0;
+ if ( list->size )
+ {
+ list->field[0] = (char*)empty;
+ list->field[1] = (char*)empty;
+ list->field[2] = (char*)empty;
+ list->field[3] = (char*)empty;
+ list->field[4] = (char*)empty;
+ }
/* If the line is empty, then simply return. */
if ( linelen == 0 || line[0] == 0 )
@@ -530,7 +596,7 @@
/* this, so an error is signaled. */
if ( separators == 0 || *separators == 0 )
{
- error = BDF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -616,14 +682,14 @@
unsigned long lineno, buf_size;
int refill, hold, to_skip;
ptrdiff_t bytes, start, end, cursor, avail;
- char* buf = 0;
+ char* buf = 0;
FT_Memory memory = stream->memory;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( callback == 0 )
{
- error = BDF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -637,7 +703,6 @@
lineno = 1;
buf[0] = 0;
start = 0;
- end = 0;
avail = 0;
cursor = 0;
refill = 1;
@@ -648,8 +713,9 @@
{
if ( refill )
{
- bytes = (ptrdiff_t)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
- (FT_ULong)(buf_size - cursor) );
+ bytes = (ptrdiff_t)FT_Stream_TryRead(
+ stream, (FT_Byte*)buf + cursor,
+ (FT_ULong)( buf_size - cursor ) );
avail = cursor + bytes;
cursor = 0;
refill = 0;
@@ -685,7 +751,8 @@
if ( buf_size >= 65536UL ) /* limit ourselves to 64KByte */
{
- error = BDF_Err_Invalid_Argument;
+ FT_ERROR(( "_bdf_readstream: " ERRMSG6, lineno ));
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -700,7 +767,7 @@
{
bytes = avail - start;
- FT_MEM_COPY( buf, buf + start, bytes );
+ FT_MEM_MOVE( buf, buf + start, bytes );
cursor = bytes;
avail -= bytes;
@@ -714,11 +781,15 @@
hold = buf[end];
buf[end] = 0;
- /* XXX: Use encoding independent value for 0x1a */
- if ( buf[start] != '#' && buf[start] != 0x1a && end > start )
+ /* XXX: Use encoding independent value for 0x1A */
+ if ( buf[start] != '#' && buf[start] != 0x1A && end > start )
{
- error = (*cb)( buf + start, end - start, lineno,
+ error = (*cb)( buf + start, (unsigned long)( end - start ), lineno,
(void*)&cb, client_data );
+ /* Redo if we have encountered CHARS without properties. */
+ if ( error == -1 )
+ error = (*cb)( buf + start, (unsigned long)( end - start ), lineno,
+ (void*)&cb, client_data );
if ( error )
break;
}
@@ -752,17 +823,17 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const unsigned char odigits[32] =
{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -770,7 +841,7 @@
static const unsigned char ddigits[32] =
{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -778,16 +849,13 @@
static const unsigned char hdigits[32] =
{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03,
- 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
+ 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-#define isdigok( m, d ) (m[(d) >> 3] & ( 1 << ( (d) & 7 ) ) )
-
-
/* Routine to convert an ASCII string into an unsigned long integer. */
static unsigned long
_bdf_atoul( char* s,
@@ -825,7 +893,7 @@
s += 2;
}
- for ( v = 0; isdigok( dmap, *s ); s++ )
+ for ( v = 0; sbitset( dmap, *s ); s++ )
v = v * base + a2i[(int)*s];
if ( end != 0 )
@@ -880,7 +948,7 @@
s += 2;
}
- for ( v = 0; isdigok( dmap, *s ); s++ )
+ for ( v = 0; sbitset( dmap, *s ); s++ )
v = v * base + a2i[(int)*s];
if ( end != 0 )
@@ -935,7 +1003,7 @@
s += 2;
}
- for ( v = 0; isdigok( dmap, *s ); s++ )
+ for ( v = 0; sbitset( dmap, *s ); s++ )
v = (short)( v * base + a2i[(int)*s] );
if ( end != 0 )
@@ -974,10 +1042,10 @@
size_t n;
bdf_property_t* p;
FT_Memory memory = font->memory;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
- /* First check to see if the property has */
+ /* First check whether the property has */
/* already been added or not. If it has, then */
/* simply ignore it. */
if ( hash_lookup( name, &(font->proptbl) ) )
@@ -993,7 +1061,7 @@
n = ft_strlen( name ) + 1;
if ( n > FT_ULONG_MAX )
- return BDF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( FT_NEW_ARRAY( p->name, n ) )
goto Exit;
@@ -1073,33 +1141,6 @@
#define _BDF_GLYPH_HEIGHT_CHECK 0x80000000UL
- /* Auto correction messages. */
-#define ACMSG1 "FONT_ASCENT property missing. " \
- "Added \"FONT_ASCENT %hd\".\n"
-#define ACMSG2 "FONT_DESCENT property missing. " \
- "Added \"FONT_DESCENT %hd\".\n"
-#define ACMSG3 "Font width != actual width. Old: %hd New: %hd.\n"
-#define ACMSG4 "Font left bearing != actual left bearing. " \
- "Old: %hd New: %hd.\n"
-#define ACMSG5 "Font ascent != actual ascent. Old: %hd New: %hd.\n"
-#define ACMSG6 "Font descent != actual descent. Old: %hd New: %hd.\n"
-#define ACMSG7 "Font height != actual height. Old: %hd New: %hd.\n"
-#define ACMSG8 "Glyph scalable width (SWIDTH) adjustments made.\n"
-#define ACMSG9 "SWIDTH field missing at line %ld. Set automatically.\n"
-#define ACMSG10 "DWIDTH field missing at line %ld. Set to glyph width.\n"
-#define ACMSG11 "SIZE bits per pixel field adjusted to %hd.\n"
-#define ACMSG12 "Duplicate encoding %ld (%s) changed to unencoded.\n"
-#define ACMSG13 "Glyph %ld extra rows removed.\n"
-#define ACMSG14 "Glyph %ld extra columns removed.\n"
-#define ACMSG15 "Incorrect glyph count: %ld indicated but %ld found.\n"
-
- /* Error messages. */
-#define ERRMSG1 "[line %ld] Missing \"%s\" line.\n"
-#define ERRMSG2 "[line %ld] Font header corrupted or missing fields.\n"
-#define ERRMSG3 "[line %ld] Font glyphs corrupted or missing fields.\n"
-#define ERRMSG4 "[line %ld] BBX too big.\n"
-
-
static FT_Error
_bdf_add_comment( bdf_font_t* font,
char* comment,
@@ -1107,7 +1148,7 @@
{
char* cp;
FT_Memory memory = font->memory;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( FT_RENEW_ARRAY( font->comments,
@@ -1131,18 +1172,21 @@
/* default specified in the options. */
static FT_Error
_bdf_set_default_spacing( bdf_font_t* font,
- bdf_options_t* opts )
+ bdf_options_t* opts,
+ unsigned long lineno )
{
size_t len;
char name[256];
_bdf_list_t list;
FT_Memory memory;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
+
+ FT_UNUSED( lineno ); /* only used in debug mode */
if ( font == 0 || font->name == 0 || font->name[0] == 0 )
{
- error = BDF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -1156,13 +1200,14 @@
/* Limit ourselves to 256 characters in the font name. */
if ( len >= 256 )
{
- error = BDF_Err_Invalid_Argument;
+ FT_ERROR(( "_bdf_set_default_spacing: " ERRMSG7, lineno ));
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
FT_MEM_COPY( name, font->name, len );
- error = _bdf_list_split( &list, (char *)"-", name, len );
+ error = _bdf_list_split( &list, (char *)"-", name, (unsigned long)len );
if ( error )
goto Fail;
@@ -1235,7 +1280,8 @@
ep = line + linelen;
/* Trim the leading whitespace if it exists. */
- *sp++ = 0;
+ if ( *sp )
+ *sp++ = 0;
while ( *sp &&
( *sp == ' ' || *sp == '\t' ) )
sp++;
@@ -1259,18 +1305,21 @@
static FT_Error
- _bdf_add_property( bdf_font_t* font,
- char* name,
- char* value )
+ _bdf_add_property( bdf_font_t* font,
+ char* name,
+ char* value,
+ unsigned long lineno )
{
size_t propid;
hashnode hn;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
+ FT_UNUSED( lineno ); /* only used in debug mode */
- /* First, check to see if the property already exists in the font. */
+
+ /* First, check whether the property already exists in the font. */
if ( ( hn = hash_lookup( name, (hashtable *)font->internal ) ) != 0 )
{
/* The property already exists in the font, so simply replace */
@@ -1371,7 +1420,8 @@
/* If the property happens to be a comment, then it doesn't need */
/* to be added to the internal hash table. */
- if ( ft_memcmp( name, "COMMENT", 7 ) != 0 ) {
+ if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
+ {
/* Add the property to the font property table. */
error = hash_insert( fp->name,
font->props_used,
@@ -1388,17 +1438,18 @@
/* FONT_ASCENT and FONT_DESCENT need to be assigned if they are */
/* present, and the SPACING property should override the default */
/* spacing. */
- if ( ft_memcmp( name, "DEFAULT_CHAR", 12 ) == 0 )
+ if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
font->default_char = fp->value.l;
- else if ( ft_memcmp( name, "FONT_ASCENT", 11 ) == 0 )
+ else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.l;
- else if ( ft_memcmp( name, "FONT_DESCENT", 12 ) == 0 )
+ else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
font->font_descent = fp->value.l;
- else if ( ft_memcmp( name, "SPACING", 7 ) == 0 )
+ else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
{
if ( !fp->value.atom )
{
- error = BDF_Err_Invalid_File_Format;
+ FT_ERROR(( "_bdf_add_property: " ERRMSG8, lineno, "SPACING" ));
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1439,7 +1490,7 @@
bdf_font_t* font;
FT_Memory memory;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( call_data );
FT_UNUSED( lineno ); /* only used in debug mode */
@@ -1451,7 +1502,7 @@
memory = font->memory;
/* Check for a comment. */
- if ( ft_memcmp( line, "COMMENT", 7 ) == 0 )
+ if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
{
linelen -= 7;
@@ -1468,10 +1519,10 @@
/* The very first thing expected is the number of glyphs. */
if ( !( p->flags & _BDF_GLYPHS ) )
{
- if ( ft_memcmp( line, "CHARS", 5 ) != 0 )
+ if ( _bdf_strncmp( line, "CHARS", 5 ) != 0 )
{
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "CHARS" ));
- error = BDF_Err_Missing_Chars_Field;
+ error = FT_THROW( Missing_Chars_Field );
goto Exit;
}
@@ -1486,9 +1537,10 @@
/* Limit ourselves to 1,114,112 glyphs in the font (this is the */
/* number of code points available in Unicode). */
- if ( p->cnt >= 1114112UL )
+ if ( p->cnt >= 0x110000UL )
{
- error = BDF_Err_Invalid_Argument;
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG5, lineno, "CHARS" ));
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -1501,8 +1553,16 @@
}
/* Check for the ENDFONT field. */
- if ( ft_memcmp( line, "ENDFONT", 7 ) == 0 )
+ if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
{
+ if ( p->flags & _BDF_GLYPH_BITS )
+ {
+ /* Missing ENDCHAR field. */
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+ error = FT_THROW( Corrupted_Font_Glyphs );
+ goto Exit;
+ }
+
/* Sort the glyphs by encoding. */
ft_qsort( (char *)font->glyphs,
font->glyphs_used,
@@ -1515,7 +1575,7 @@
}
/* Check for the ENDCHAR field. */
- if ( ft_memcmp( line, "ENDCHAR", 7 ) == 0 )
+ if ( _bdf_strncmp( line, "ENDCHAR", 7 ) == 0 )
{
p->glyph_enc = 0;
p->flags &= ~_BDF_GLYPH_BITS;
@@ -1523,15 +1583,15 @@
goto Exit;
}
- /* Check to see whether a glyph is being scanned but should be */
- /* ignored because it is an unencoded glyph. */
+ /* Check whether a glyph is being scanned but should be */
+ /* ignored because it is an unencoded glyph. */
if ( ( p->flags & _BDF_GLYPH ) &&
p->glyph_enc == -1 &&
p->opts->keep_unencoded == 0 )
goto Exit;
/* Check for the STARTCHAR field. */
- if ( ft_memcmp( line, "STARTCHAR", 9 ) == 0 )
+ if ( _bdf_strncmp( line, "STARTCHAR", 9 ) == 0 )
{
/* Set the character name in the parse info first until the */
/* encoding can be checked for an unencoded character. */
@@ -1547,7 +1607,8 @@
if ( !s )
{
- error = BDF_Err_Invalid_File_Format;
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG8, lineno, "STARTCHAR" ));
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1558,17 +1619,19 @@
p->flags |= _BDF_GLYPH;
+ FT_TRACE4(( DBGMSG1, lineno, s ));
+
goto Exit;
}
/* Check for the ENCODING field. */
- if ( ft_memcmp( line, "ENCODING", 8 ) == 0 )
+ if ( _bdf_strncmp( line, "ENCODING", 8 ) == 0 )
{
if ( !( p->flags & _BDF_GLYPH ) )
{
/* Missing STARTCHAR field. */
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "STARTCHAR" ));
- error = BDF_Err_Missing_Startchar_Field;
+ error = FT_THROW( Missing_Startchar_Field );
goto Exit;
}
@@ -1578,17 +1641,34 @@
p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 );
- /* Check that the encoding is in the range [0,65536] because */
- /* otherwise p->have (a bitmap with static size) overflows. */
- if ( (size_t)p->glyph_enc >= sizeof ( p->have ) * 8 )
+ /* Normalize negative encoding values. The specification only */
+ /* allows -1, but we can be more generous here. */
+ if ( p->glyph_enc < -1 )
+ p->glyph_enc = -1;
+
+ /* 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 );
+
+ if ( p->glyph_enc < -1 )
+ p->glyph_enc = -1;
+
+ FT_TRACE4(( DBGMSG2, p->glyph_enc ));
+
+ /* Check that the encoding is in the Unicode range because */
+ /* otherwise p->have (a bitmap with static size) overflows. */
+ if ( p->glyph_enc > 0 &&
+ (size_t)p->glyph_enc >= sizeof ( p->have ) /
+ sizeof ( unsigned long ) * 32 )
{
- error = BDF_Err_Invalid_File_Format;
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG5, lineno, "ENCODING" ));
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
- /* Check to see whether this encoding has already been encountered. */
- /* If it has then change it to unencoded so it gets added if */
- /* indicated. */
+ /* Check whether this encoding has already been encountered. */
+ /* If it has then change it to unencoded so it gets added if */
+ /* indicated. */
if ( p->glyph_enc >= 0 )
{
if ( _bdf_glyph_modified( p->have, p->glyph_enc ) )
@@ -1627,8 +1707,8 @@
}
else
{
- /* Unencoded glyph. Check to see whether it should */
- /* be added or not. */
+ /* Unencoded glyph. Check whether it should */
+ /* be added or not. */
if ( p->opts->keep_unencoded != 0 )
{
/* Allocate the next unencoded glyph. */
@@ -1669,7 +1749,7 @@
else
glyph = font->glyphs + ( font->glyphs_used - 1 );
- /* Check to see whether a bitmap is being constructed. */
+ /* Check whether a bitmap is being constructed. */
if ( p->flags & _BDF_BITMAP )
{
/* If there are more rows than are specified in the glyph metrics, */
@@ -1694,19 +1774,32 @@
for ( i = 0; i < nibbles; i++ )
{
c = line[i];
+ if ( !sbitset( hdigits, c ) )
+ break;
*bp = (FT_Byte)( ( *bp << 4 ) + a2i[c] );
if ( i + 1 < nibbles && ( i & 1 ) )
*++bp = 0;
}
+ /* If any line has not enough columns, */
+ /* indicate they have been padded with zero bits. */
+ if ( i < nibbles &&
+ !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) )
+ {
+ FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG16, glyph->encoding ));
+ p->flags |= _BDF_GLYPH_WIDTH_CHECK;
+ font->modified = 1;
+ }
+
/* Remove possible garbage at the right. */
mask_index = ( glyph->bbx.width * p->font->bpp ) & 7;
if ( glyph->bbx.width )
*bp &= nibble_mask[mask_index];
/* If any line has extra columns, indicate they have been removed. */
- if ( ( line[nibbles] == '0' || a2i[(int)line[nibbles]] != 0 ) &&
- !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) )
+ if ( i == nibbles &&
+ sbitset( hdigits, line[nibbles] ) &&
+ !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) )
{
FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG14, glyph->encoding ));
p->flags |= _BDF_GLYPH_WIDTH_CHECK;
@@ -1718,15 +1811,10 @@
}
/* Expect the SWIDTH (scalable width) field next. */
- if ( ft_memcmp( line, "SWIDTH", 6 ) == 0 )
+ if ( _bdf_strncmp( line, "SWIDTH", 6 ) == 0 )
{
if ( !( p->flags & _BDF_ENCODING ) )
- {
- /* Missing ENCODING field. */
- FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENCODING" ));
- error = BDF_Err_Missing_Encoding_Field;
- goto Exit;
- }
+ goto Missing_Encoding;
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
@@ -1739,8 +1827,11 @@
}
/* Expect the DWIDTH (scalable width) field next. */
- if ( ft_memcmp( line, "DWIDTH", 6 ) == 0 )
+ if ( _bdf_strncmp( line, "DWIDTH", 6 ) == 0 )
{
+ if ( !( p->flags & _BDF_ENCODING ) )
+ goto Missing_Encoding;
+
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -1764,8 +1855,11 @@
}
/* Expect the BBX field next. */
- if ( ft_memcmp( line, "BBX", 3 ) == 0 )
+ if ( _bdf_strncmp( line, "BBX", 3 ) == 0 )
{
+ if ( !( p->flags & _BDF_ENCODING ) )
+ goto Missing_Encoding;
+
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -1829,7 +1923,7 @@
}
/* And finally, gather up the bitmap. */
- if ( ft_memcmp( line, "BITMAP", 6 ) == 0 )
+ if ( _bdf_strncmp( line, "BITMAP", 6 ) == 0 )
{
unsigned long bitmap_size;
@@ -1838,18 +1932,18 @@
{
/* Missing BBX field. */
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "BBX" ));
- error = BDF_Err_Missing_Bbx_Field;
+ error = FT_THROW( Missing_Bbx_Field );
goto Exit;
}
/* Allocate enough space for the bitmap. */
- glyph->bpr = ( glyph->bbx.width * p->font->bpp + 7 ) >> 3;
+ glyph->bpr = ( glyph->bbx.width * p->font->bpp + 7 ) >> 3;
bitmap_size = glyph->bpr * glyph->bbx.height;
- if ( bitmap_size > 0xFFFFU )
+ if ( glyph->bpr > 0xFFFFU || bitmap_size > 0xFFFFU )
{
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG4, lineno ));
- error = BDF_Err_Bbx_Too_Big;
+ error = FT_THROW( Bbx_Too_Big );
goto Exit;
}
else
@@ -1864,9 +1958,19 @@
goto Exit;
}
- error = BDF_Err_Invalid_File_Format;
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG9, lineno ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+
+ Missing_Encoding:
+ /* Missing ENCODING field. */
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENCODING" ));
+ error = FT_THROW( Missing_Encoding_Field );
Exit:
+ if ( error && ( p->flags & _BDF_GLYPH ) )
+ FT_FREE( p->glyph_name );
+
return error;
}
@@ -1885,7 +1989,7 @@
char* name;
char* value;
char nbuf[128];
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( lineno );
@@ -1894,7 +1998,7 @@
p = (_bdf_parse_t *) client_data;
/* Check for the end of the properties. */
- if ( ft_memcmp( line, "ENDPROPERTIES", 13 ) == 0 )
+ if ( _bdf_strncmp( line, "ENDPROPERTIES", 13 ) == 0 )
{
/* If the FONT_ASCENT or FONT_DESCENT properties have not been */
/* encountered yet, then make sure they are added as properties and */
@@ -1906,7 +2010,8 @@
{
p->font->font_ascent = p->font->bbx.ascent;
ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
- error = _bdf_add_property( p->font, (char *)"FONT_ASCENT", nbuf );
+ error = _bdf_add_property( p->font, (char *)"FONT_ASCENT",
+ nbuf, lineno );
if ( error )
goto Exit;
@@ -1918,7 +2023,8 @@
{
p->font->font_descent = p->font->bbx.descent;
ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
- error = _bdf_add_property( p->font, (char *)"FONT_DESCENT", nbuf );
+ error = _bdf_add_property( p->font, (char *)"FONT_DESCENT",
+ nbuf, lineno );
if ( error )
goto Exit;
@@ -1933,24 +2039,24 @@
}
/* Ignore the _XFREE86_GLYPH_RANGES properties. */
- if ( ft_memcmp( line, "_XFREE86_GLYPH_RANGES", 21 ) == 0 )
+ if ( _bdf_strncmp( line, "_XFREE86_GLYPH_RANGES", 21 ) == 0 )
goto Exit;
/* Handle COMMENT fields and properties in a special way to preserve */
/* the spacing. */
- if ( ft_memcmp( line, "COMMENT", 7 ) == 0 )
+ if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
{
name = value = line;
value += 7;
if ( *value )
*value++ = 0;
- error = _bdf_add_property( p->font, name, value );
+ error = _bdf_add_property( p->font, name, value, lineno );
if ( error )
goto Exit;
}
else if ( _bdf_is_atom( line, linelen, &name, &value, p->font ) )
{
- error = _bdf_add_property( p->font, name, value );
+ error = _bdf_add_property( p->font, name, value, lineno );
if ( error )
goto Exit;
}
@@ -1964,7 +2070,7 @@
_bdf_list_shift( &p->list, 1 );
value = _bdf_list_join( &p->list, ' ', &vlen );
- error = _bdf_add_property( p->font, name, value );
+ error = _bdf_add_property( p->font, name, value, lineno );
if ( error )
goto Exit;
}
@@ -1989,7 +2095,7 @@
char *s;
FT_Memory memory = NULL;
- FT_Error error = BDF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( lineno ); /* only used in debug mode */
@@ -2002,7 +2108,7 @@
/* Check for a comment. This is done to handle those fonts that have */
/* comments before the STARTFONT line for some reason. */
- if ( ft_memcmp( line, "COMMENT", 7 ) == 0 )
+ if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
{
if ( p->opts->keep_comments != 0 && p->font != 0 )
{
@@ -2028,10 +2134,11 @@
{
memory = p->memory;
- if ( ft_memcmp( line, "STARTFONT", 9 ) != 0 )
+ if ( _bdf_strncmp( line, "STARTFONT", 9 ) != 0 )
{
- /* No STARTFONT field is a good indication of a problem. */
- error = BDF_Err_Missing_Startfont_Field;
+ /* we don't emit an error message since this code gets */
+ /* explicitly caught one level higher */
+ error = FT_THROW( Missing_Startfont_Field );
goto Exit;
}
@@ -2075,8 +2182,16 @@
}
/* Check for the start of the properties. */
- if ( ft_memcmp( line, "STARTPROPERTIES", 15 ) == 0 )
+ if ( _bdf_strncmp( line, "STARTPROPERTIES", 15 ) == 0 )
{
+ if ( !( p->flags & _BDF_FONT_BBX ) )
+ {
+ /* Missing the FONTBOUNDINGBOX field. */
+ FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
+ error = FT_THROW( Missing_Fontboundingbox_Field );
+ goto Exit;
+ }
+
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -2084,7 +2199,10 @@
p->cnt = p->font->props_size = _bdf_atoul( p->list.field[1], 0, 10 );
if ( FT_NEW_ARRAY( p->font->props, p->cnt ) )
+ {
+ p->font->props_size = 0;
goto Exit;
+ }
p->flags |= _BDF_PROPS;
*next = _bdf_parse_properties;
@@ -2093,13 +2211,13 @@
}
/* Check for the FONTBOUNDINGBOX field. */
- if ( ft_memcmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
+ 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" ));
- error = BDF_Err_Missing_Size_Field;
+ error = FT_THROW( Missing_Size_Field );
goto Exit;
}
@@ -2124,7 +2242,7 @@
}
/* The next thing to check for is the FONT field. */
- if ( ft_memcmp( line, "FONT", 4 ) == 0 )
+ if ( _bdf_strncmp( line, "FONT", 4 ) == 0 )
{
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
@@ -2135,17 +2253,21 @@
if ( !s )
{
- error = BDF_Err_Invalid_File_Format;
+ FT_ERROR(( "_bdf_parse_start: " ERRMSG8, lineno, "FONT" ));
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
+ /* Allowing multiple `FONT' lines (which is invalid) doesn't hurt... */
+ FT_FREE( p->font->name );
+
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->font->name, s, slen + 1 );
/* If the font name is an XLFD name, set the spacing to the one in */
/* the font name. If there is no spacing fall back on the default. */
- error = _bdf_set_default_spacing( p->font, p->opts );
+ error = _bdf_set_default_spacing( p->font, p->opts, lineno );
if ( error )
goto Exit;
@@ -2155,13 +2277,13 @@
}
/* Check for the SIZE field. */
- if ( ft_memcmp( line, "SIZE", 4 ) == 0 )
+ if ( _bdf_strncmp( line, "SIZE", 4 ) == 0 )
{
if ( !( p->flags & _BDF_FONT_NAME ) )
{
/* Missing the FONT field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONT" ));
- error = BDF_Err_Missing_Font_Field;
+ error = FT_THROW( Missing_Font_Field );
goto Exit;
}
@@ -2208,7 +2330,49 @@
goto Exit;
}
- error = BDF_Err_Invalid_File_Format;
+ /* Check for the CHARS field -- font properties are optional */
+ if ( _bdf_strncmp( line, "CHARS", 5 ) == 0 )
+ {
+ char nbuf[128];
+
+
+ if ( !( p->flags & _BDF_FONT_BBX ) )
+ {
+ /* Missing the FONTBOUNDINGBOX field. */
+ FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
+ error = FT_THROW( Missing_Fontboundingbox_Field );
+ goto Exit;
+ }
+
+ /* Add the two standard X11 properties which are required */
+ /* for compiling fonts. */
+ p->font->font_ascent = p->font->bbx.ascent;
+ ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
+ error = _bdf_add_property( p->font, (char *)"FONT_ASCENT",
+ nbuf, lineno );
+ if ( error )
+ goto Exit;
+ FT_TRACE2(( "_bdf_parse_properties: " ACMSG1, p->font->bbx.ascent ));
+
+ p->font->font_descent = p->font->bbx.descent;
+ ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
+ error = _bdf_add_property( p->font, (char *)"FONT_DESCENT",
+ nbuf, lineno );
+ if ( error )
+ goto Exit;
+ FT_TRACE2(( "_bdf_parse_properties: " ACMSG2, p->font->bbx.descent ));
+
+ p->font->modified = 1;
+
+ *next = _bdf_parse_glyphs;
+
+ /* A special return value. */
+ error = -1;
+ goto Exit;
+ }
+
+ FT_ERROR(( "_bdf_parse_start: " ERRMSG9, lineno ));
+ error = FT_THROW( Invalid_File_Format );
Exit:
return error;
@@ -2229,10 +2393,10 @@
bdf_font_t* *font )
{
unsigned long lineno = 0; /* make compiler happy */
- _bdf_parse_t *p;
+ _bdf_parse_t *p = NULL;
- FT_Memory memory = extmemory;
- FT_Error error = BDF_Err_Ok;
+ FT_Memory memory = extmemory; /* needed for FT_NEW */
+ FT_Error error = FT_Err_Ok;
if ( FT_NEW( p ) )
@@ -2254,7 +2418,6 @@
{
/* If the font is not proportional, set the font's monowidth */
/* field to the width of the font bounding box. */
- memory = p->font->memory;
if ( p->font->spacing != BDF_PROPORTIONAL )
p->font->monowidth = p->font->bbx.width;
@@ -2320,22 +2483,20 @@
if ( p->flags & _BDF_START )
{
+ /* The ENDFONT field was never reached or did not exist. */
+ if ( !( p->flags & _BDF_GLYPHS ) )
{
- /* The ENDFONT field was never reached or did not exist. */
- if ( !( p->flags & _BDF_GLYPHS ) )
- {
- /* Error happened while parsing header. */
- FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
- error = BDF_Err_Corrupted_Font_Header;
- goto Exit;
- }
- else
- {
- /* Error happened when parsing glyphs. */
- FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno ));
- error = BDF_Err_Corrupted_Font_Glyphs;
- goto Exit;
- }
+ /* Error happened while parsing header. */
+ FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
+ error = FT_THROW( Corrupted_Font_Header );
+ goto Exit;
+ }
+ else
+ {
+ /* Error happened when parsing glyphs. */
+ FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno ));
+ error = FT_THROW( Corrupted_Font_Glyphs );
+ goto Exit;
}
}
@@ -2344,7 +2505,8 @@
/* Make sure the comments are NULL terminated if they exist. */
memory = p->font->memory;
- if ( p->font->comments_len > 0 ) {
+ if ( p->font->comments_len > 0 )
+ {
if ( FT_RENEW_ARRAY( p->font->comments,
p->font->comments_len,
p->font->comments_len + 1 ) )
@@ -2353,8 +2515,8 @@
p->font->comments[p->font->comments_len] = 0;
}
}
- else if ( error == BDF_Err_Ok )
- error = BDF_Err_Invalid_File_Format;
+ else if ( error == FT_Err_Ok )
+ error = FT_THROW( Invalid_File_Format );
*font = p->font;
@@ -2448,8 +2610,8 @@
hash_free( &(font->proptbl), memory );
/* Free up the user defined properties. */
- for (prop = font->user_props, i = 0;
- i < font->nuser_props; i++, prop++ )
+ for ( prop = font->user_props, i = 0;
+ i < font->nuser_props; i++, prop++ )
{
FT_FREE( prop->name );
if ( prop->format == BDF_ATOM )
diff --git a/src/3rdparty/freetype/src/bzip2/Jamfile b/src/3rdparty/freetype/src/bzip2/Jamfile
new file mode 100644
index 0000000000..3da986dce6
--- /dev/null
+++ b/src/3rdparty/freetype/src/bzip2/Jamfile
@@ -0,0 +1,19 @@
+# FreeType 2 src/bzip2 Jamfile
+#
+# Copyright 2010 by
+# Joel Klinghed
+#
+# Based on src/lzw/Jamfile, Copyright 2004, 2006 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.
+
+SubDir FT2_TOP $(FT2_SRC_DIR) bzip2 ;
+
+Library $(FT2_LIB) : ftbzip2.c ;
+
+# end of src/bzip2 Jamfile
diff --git a/src/3rdparty/freetype/src/bzip2/ftbzip2.c b/src/3rdparty/freetype/src/bzip2/ftbzip2.c
new file mode 100644
index 0000000000..7e406b1612
--- /dev/null
+++ b/src/3rdparty/freetype/src/bzip2/ftbzip2.c
@@ -0,0 +1,519 @@
+/***************************************************************************/
+/* */
+/* ftbzip2.c */
+/* */
+/* FreeType support for .bz2 compressed files. */
+/* */
+/* This optional component relies on libbz2. It should mainly be used to */
+/* parse compressed PCF fonts, as found with many X11 server */
+/* distributions. */
+/* */
+/* Copyright 2010, 2012-2014 by */
+/* Joel Klinghed. */
+/* */
+/* Based on src/gzip/ftgzip.c, Copyright 2002 - 2010 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_INTERNAL_MEMORY_H
+#include FT_INTERNAL_STREAM_H
+#include FT_INTERNAL_DEBUG_H
+#include FT_BZIP2_H
+#include FT_CONFIG_STANDARD_LIBRARY_H
+
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#undef FT_ERR_PREFIX
+#define FT_ERR_PREFIX Bzip2_Err_
+#define FT_ERR_BASE FT_Mod_Err_Bzip2
+
+#include FT_ERRORS_H
+
+
+#ifdef FT_CONFIG_OPTION_USE_BZIP2
+
+#ifdef FT_CONFIG_OPTION_PIC
+#error "bzip2 code does not support PIC yet"
+#endif
+
+#define BZ_NO_STDIO /* Do not need FILE */
+#include <bzlib.h>
+
+
+/***************************************************************************/
+/***************************************************************************/
+/***** *****/
+/***** B Z I P 2 M E M O R Y M A N A G E M E N T *****/
+/***** *****/
+/***************************************************************************/
+/***************************************************************************/
+
+ /* it is better to use FreeType memory routines instead of raw
+ 'malloc/free' */
+
+ typedef void *(* alloc_func)(void*, int, int);
+ typedef void (* free_func)(void*, void*);
+
+ static void*
+ ft_bzip2_alloc( FT_Memory memory,
+ int items,
+ int size )
+ {
+ FT_ULong sz = (FT_ULong)size * items;
+ FT_Error error;
+ FT_Pointer p = NULL;
+
+
+ (void)FT_ALLOC( p, sz );
+ return p;
+ }
+
+
+ static void
+ ft_bzip2_free( FT_Memory memory,
+ void* address )
+ {
+ FT_MEM_FREE( address );
+ }
+
+
+/***************************************************************************/
+/***************************************************************************/
+/***** *****/
+/***** B Z I P 2 F I L E D E S C R I P T O R *****/
+/***** *****/
+/***************************************************************************/
+/***************************************************************************/
+
+#define FT_BZIP2_BUFFER_SIZE 4096
+
+ typedef struct FT_BZip2FileRec_
+ {
+ FT_Stream source; /* parent/source stream */
+ FT_Stream stream; /* embedding stream */
+ FT_Memory memory; /* memory allocator */
+ bz_stream bzstream; /* bzlib input stream */
+
+ FT_Byte input[FT_BZIP2_BUFFER_SIZE]; /* input read buffer */
+
+ FT_Byte buffer[FT_BZIP2_BUFFER_SIZE]; /* output buffer */
+ FT_ULong pos; /* position in output */
+ FT_Byte* cursor;
+ FT_Byte* limit;
+
+ } FT_BZip2FileRec, *FT_BZip2File;
+
+
+ /* check and skip .bz2 header - we don't support `transparent' compression */
+ static FT_Error
+ ft_bzip2_check_header( FT_Stream stream )
+ {
+ FT_Error error = FT_Err_Ok;
+ FT_Byte head[4];
+
+
+ if ( FT_STREAM_SEEK( 0 ) ||
+ FT_STREAM_READ( head, 4 ) )
+ goto Exit;
+
+ /* head[0] && head[1] are the magic numbers; */
+ /* head[2] is the version, and head[3] the blocksize */
+ if ( head[0] != 0x42 ||
+ head[1] != 0x5A ||
+ head[2] != 0x68 ) /* only support bzip2 (huffman) */
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ Exit:
+ return error;
+ }
+
+
+ static FT_Error
+ ft_bzip2_file_init( FT_BZip2File zip,
+ FT_Stream stream,
+ FT_Stream source )
+ {
+ bz_stream* bzstream = &zip->bzstream;
+ FT_Error error = FT_Err_Ok;
+
+
+ zip->stream = stream;
+ zip->source = source;
+ zip->memory = stream->memory;
+
+ zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
+ zip->cursor = zip->limit;
+ zip->pos = 0;
+
+ /* check .bz2 header */
+ {
+ stream = source;
+
+ error = ft_bzip2_check_header( stream );
+ if ( error )
+ goto Exit;
+
+ if ( FT_STREAM_SEEK( 0 ) )
+ goto Exit;
+ }
+
+ /* initialize bzlib */
+ bzstream->bzalloc = (alloc_func)ft_bzip2_alloc;
+ bzstream->bzfree = (free_func) ft_bzip2_free;
+ bzstream->opaque = zip->memory;
+
+ bzstream->avail_in = 0;
+ bzstream->next_in = (char*)zip->buffer;
+
+ if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK ||
+ bzstream->next_in == NULL )
+ error = FT_THROW( Invalid_File_Format );
+
+ Exit:
+ return error;
+ }
+
+
+ static void
+ ft_bzip2_file_done( FT_BZip2File zip )
+ {
+ bz_stream* bzstream = &zip->bzstream;
+
+
+ BZ2_bzDecompressEnd( bzstream );
+
+ /* clear the rest */
+ bzstream->bzalloc = NULL;
+ bzstream->bzfree = NULL;
+ bzstream->opaque = NULL;
+ bzstream->next_in = NULL;
+ bzstream->next_out = NULL;
+ bzstream->avail_in = 0;
+ bzstream->avail_out = 0;
+
+ zip->memory = NULL;
+ zip->source = NULL;
+ zip->stream = NULL;
+ }
+
+
+ static FT_Error
+ ft_bzip2_file_reset( FT_BZip2File zip )
+ {
+ FT_Stream stream = zip->source;
+ FT_Error error;
+
+
+ if ( !FT_STREAM_SEEK( 0 ) )
+ {
+ bz_stream* bzstream = &zip->bzstream;
+
+
+ BZ2_bzDecompressEnd( bzstream );
+
+ bzstream->avail_in = 0;
+ bzstream->next_in = (char*)zip->input;
+ bzstream->avail_out = 0;
+ bzstream->next_out = (char*)zip->buffer;
+
+ zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
+ zip->cursor = zip->limit;
+ zip->pos = 0;
+
+ BZ2_bzDecompressInit( bzstream, 0, 0 );
+ }
+
+ return error;
+ }
+
+
+ static FT_Error
+ ft_bzip2_file_fill_input( FT_BZip2File zip )
+ {
+ bz_stream* bzstream = &zip->bzstream;
+ FT_Stream stream = zip->source;
+ FT_ULong size;
+
+
+ if ( stream->read )
+ {
+ size = stream->read( stream, stream->pos, zip->input,
+ FT_BZIP2_BUFFER_SIZE );
+ if ( size == 0 )
+ return FT_THROW( Invalid_Stream_Operation );
+ }
+ else
+ {
+ size = stream->size - stream->pos;
+ if ( size > FT_BZIP2_BUFFER_SIZE )
+ size = FT_BZIP2_BUFFER_SIZE;
+
+ if ( size == 0 )
+ return FT_THROW( Invalid_Stream_Operation );
+
+ FT_MEM_COPY( zip->input, stream->base + stream->pos, size );
+ }
+ stream->pos += size;
+
+ bzstream->next_in = (char*)zip->input;
+ bzstream->avail_in = size;
+
+ return FT_Err_Ok;
+ }
+
+
+ static FT_Error
+ ft_bzip2_file_fill_output( FT_BZip2File zip )
+ {
+ bz_stream* bzstream = &zip->bzstream;
+ FT_Error error = FT_Err_Ok;
+
+
+ zip->cursor = zip->buffer;
+ bzstream->next_out = (char*)zip->cursor;
+ bzstream->avail_out = FT_BZIP2_BUFFER_SIZE;
+
+ while ( bzstream->avail_out > 0 )
+ {
+ int err;
+
+
+ if ( bzstream->avail_in == 0 )
+ {
+ error = ft_bzip2_file_fill_input( zip );
+ if ( error )
+ break;
+ }
+
+ err = BZ2_bzDecompress( bzstream );
+
+ if ( err == BZ_STREAM_END )
+ {
+ zip->limit = (FT_Byte*)bzstream->next_out;
+ if ( zip->limit == zip->cursor )
+ error = FT_THROW( Invalid_Stream_Operation );
+ break;
+ }
+ else if ( err != BZ_OK )
+ {
+ error = FT_THROW( Invalid_Stream_Operation );
+ break;
+ }
+ }
+
+ return error;
+ }
+
+
+ /* fill output buffer; `count' must be <= FT_BZIP2_BUFFER_SIZE */
+ static FT_Error
+ ft_bzip2_file_skip_output( FT_BZip2File zip,
+ FT_ULong count )
+ {
+ FT_Error error = FT_Err_Ok;
+ FT_ULong delta;
+
+
+ for (;;)
+ {
+ delta = (FT_ULong)( zip->limit - zip->cursor );
+ if ( delta >= count )
+ delta = count;
+
+ zip->cursor += delta;
+ zip->pos += delta;
+
+ count -= delta;
+ if ( count == 0 )
+ break;
+
+ error = ft_bzip2_file_fill_output( zip );
+ if ( error )
+ break;
+ }
+
+ return error;
+ }
+
+
+ static FT_ULong
+ ft_bzip2_file_io( FT_BZip2File zip,
+ FT_ULong pos,
+ FT_Byte* buffer,
+ FT_ULong count )
+ {
+ FT_ULong result = 0;
+ FT_Error error;
+
+
+ /* Reset inflate stream if we're seeking backwards. */
+ /* Yes, that is not too efficient, but it saves memory :-) */
+ if ( pos < zip->pos )
+ {
+ error = ft_bzip2_file_reset( zip );
+ if ( error )
+ goto Exit;
+ }
+
+ /* skip unwanted bytes */
+ if ( pos > zip->pos )
+ {
+ error = ft_bzip2_file_skip_output( zip, (FT_ULong)( pos - zip->pos ) );
+ if ( error )
+ goto Exit;
+ }
+
+ if ( count == 0 )
+ goto Exit;
+
+ /* now read the data */
+ for (;;)
+ {
+ FT_ULong delta;
+
+
+ delta = (FT_ULong)( zip->limit - zip->cursor );
+ if ( delta >= count )
+ delta = count;
+
+ FT_MEM_COPY( buffer, zip->cursor, delta );
+ buffer += delta;
+ result += delta;
+ zip->cursor += delta;
+ zip->pos += delta;
+
+ count -= delta;
+ if ( count == 0 )
+ break;
+
+ error = ft_bzip2_file_fill_output( zip );
+ if ( error )
+ break;
+ }
+
+ Exit:
+ return result;
+ }
+
+
+/***************************************************************************/
+/***************************************************************************/
+/***** *****/
+/***** B Z E M B E D D I N G S T R E A M *****/
+/***** *****/
+/***************************************************************************/
+/***************************************************************************/
+
+ static void
+ ft_bzip2_stream_close( FT_Stream stream )
+ {
+ FT_BZip2File zip = (FT_BZip2File)stream->descriptor.pointer;
+ FT_Memory memory = stream->memory;
+
+
+ if ( zip )
+ {
+ /* finalize bzip file descriptor */
+ ft_bzip2_file_done( zip );
+
+ FT_FREE( zip );
+
+ stream->descriptor.pointer = NULL;
+ }
+ }
+
+
+ static FT_ULong
+ ft_bzip2_stream_io( FT_Stream stream,
+ FT_ULong pos,
+ FT_Byte* buffer,
+ FT_ULong count )
+ {
+ FT_BZip2File zip = (FT_BZip2File)stream->descriptor.pointer;
+
+
+ return ft_bzip2_file_io( zip, pos, buffer, count );
+ }
+
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Stream_OpenBzip2( FT_Stream stream,
+ FT_Stream source )
+ {
+ FT_Error error;
+ FT_Memory memory;
+ FT_BZip2File zip = NULL;
+
+
+ if ( !stream || !source )
+ {
+ error = FT_THROW( Invalid_Stream_Handle );
+ goto Exit;
+ }
+
+ memory = source->memory;
+
+ /*
+ * check the header right now; this prevents allocating unnecessary
+ * objects when we don't need them
+ */
+ error = ft_bzip2_check_header( source );
+ if ( error )
+ goto Exit;
+
+ FT_ZERO( stream );
+ stream->memory = memory;
+
+ if ( !FT_QNEW( zip ) )
+ {
+ error = ft_bzip2_file_init( zip, stream, source );
+ if ( error )
+ {
+ FT_FREE( zip );
+ goto Exit;
+ }
+
+ stream->descriptor.pointer = zip;
+ }
+
+ stream->size = 0x7FFFFFFFL; /* don't know the real size! */
+ stream->pos = 0;
+ stream->base = 0;
+ stream->read = ft_bzip2_stream_io;
+ stream->close = ft_bzip2_stream_close;
+
+ Exit:
+ return error;
+ }
+
+#else /* !FT_CONFIG_OPTION_USE_BZIP2 */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Stream_OpenBzip2( FT_Stream stream,
+ FT_Stream source )
+ {
+ FT_UNUSED( stream );
+ FT_UNUSED( source );
+
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+#endif /* !FT_CONFIG_OPTION_USE_BZIP2 */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/bzip2/rules.mk b/src/3rdparty/freetype/src/bzip2/rules.mk
new file mode 100644
index 0000000000..0ff2628b4a
--- /dev/null
+++ b/src/3rdparty/freetype/src/bzip2/rules.mk
@@ -0,0 +1,63 @@
+#
+# FreeType 2 BZIP2 support configuration rules
+#
+
+# Copyright 2010 by
+# Joel Klinghed.
+#
+# Based on src/lzw/rules.mk, Copyright 2004-2006 by
+# Albert Chin-A-Young.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+
+# BZIP2 driver directory
+#
+BZIP2_DIR := $(SRC_DIR)/bzip2
+
+
+# compilation flags for the driver
+#
+BZIP2_COMPILE := $(FT_COMPILE)
+
+
+# BZIP2 support sources (i.e., C files)
+#
+BZIP2_DRV_SRC := $(BZIP2_DIR)/ftbzip2.c
+
+# BZIP2 driver object(s)
+#
+# BZIP2_DRV_OBJ_M is used during `multi' builds
+# BZIP2_DRV_OBJ_S is used during `single' builds
+#
+BZIP2_DRV_OBJ_M := $(OBJ_DIR)/ftbzip2.$O
+BZIP2_DRV_OBJ_S := $(OBJ_DIR)/ftbzip2.$O
+
+# BZIP2 support source file for single build
+#
+BZIP2_DRV_SRC_S := $(BZIP2_DIR)/ftbzip2.c
+
+
+# BZIP2 support - single object
+#
+$(BZIP2_DRV_OBJ_S): $(BZIP2_DRV_SRC_S) $(BZIP2_DRV_SRC) $(FREETYPE_H) $(BZIP2_DRV_H)
+ $(BZIP2_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(BZIP2_DRV_SRC_S))
+
+
+# BZIP2 support - multiple objects
+#
+$(OBJ_DIR)/%.$O: $(BZIP2_DIR)/%.c $(FREETYPE_H) $(BZIP2_DRV_H)
+ $(BZIP2_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
+
+
+# update main driver object lists
+#
+DRV_OBJS_S += $(BZIP2_DRV_OBJ_S)
+DRV_OBJS_M += $(BZIP2_DRV_OBJ_M)
+
+
+# EOF
diff --git a/src/3rdparty/freetype/src/cache/Jamfile b/src/3rdparty/freetype/src/cache/Jamfile
index 340cff7742..6563991375 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, 2003, 2004 by
+# Copyright 2001, 2003, 2004, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -11,7 +11,7 @@
SubDir FT2_TOP $(FT2_SRC_DIR) cache ;
-# The file <freetype/ftcache.h> contains some macro definitions that are
+# The file <ftcache.h> contains some macro definitions that are
# later used in #include statements related to the cache sub-system. It
# needs to be parsed through a HDRMACRO rule for macro definitions.
#
diff --git a/src/3rdparty/freetype/src/cache/ftcbasic.c b/src/3rdparty/freetype/src/cache/ftcbasic.c
index ebc8871ccc..6bad39d912 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, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2003-2007, 2009-2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_CACHE_H
#include "ftcglyph.h"
@@ -29,44 +30,6 @@
#define FT_COMPONENT trace_cache
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /*
- * These structures correspond to the FTC_Font and FTC_ImageDesc types
- * that were defined in version 2.1.7.
- */
- typedef struct FTC_OldFontRec_
- {
- FTC_FaceID face_id;
- FT_UShort pix_width;
- FT_UShort pix_height;
-
- } FTC_OldFontRec, *FTC_OldFont;
-
-
- typedef struct FTC_OldImageDescRec_
- {
- FTC_OldFontRec font;
- FT_UInt32 flags;
-
- } FTC_OldImageDescRec, *FTC_OldImageDesc;
-
-
- /*
- * Notice that FTC_OldImageDescRec and FTC_ImageTypeRec are nearly
- * identical, bit-wise. The only difference is that the `width' and
- * `height' fields are expressed as 16-bit integers in the old structure,
- * and as normal `int' in the new one.
- *
- * We are going to perform a weird hack to detect which structure is
- * being passed to the image and sbit caches. If the new structure's
- * `width' is larger than 0x10000, we assume that we are really receiving
- * an FTC_OldImageDesc.
- */
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
/*
* Basic Families
*
@@ -147,10 +110,9 @@
return result;
if ( (FT_ULong)face->num_glyphs > FT_UINT_MAX || 0 > face->num_glyphs )
- {
- FT_TRACE1(( "ftc_basic_family_get_count: too large number of glyphs " ));
- FT_TRACE1(( "in this face, truncated\n", face->num_glyphs ));
- }
+ FT_TRACE1(( "ftc_basic_family_get_count:"
+ " too large number of glyphs in this face, truncated\n",
+ face->num_glyphs ));
if ( !error )
result = (FT_UInt)face->num_glyphs;
@@ -225,7 +187,7 @@
}
}
else
- error = FTC_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
}
@@ -237,7 +199,8 @@
FT_CALLBACK_DEF( FT_Bool )
ftc_basic_gnode_compare_faceid( FTC_Node ftcgnode,
FT_Pointer ftcface_id,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_GNode gnode = (FTC_GNode)ftcgnode;
FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
@@ -245,6 +208,8 @@
FT_Bool result;
+ if ( list_changed )
+ *list_changed = FALSE;
result = FT_BOOL( family->attrs.scaler.face_id == face_id );
if ( result )
{
@@ -263,7 +228,7 @@
*
*/
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_IFamilyClassRec ftc_basic_image_family_class =
{
{
@@ -277,7 +242,7 @@
};
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_GCacheClassRec ftc_basic_image_cache_class =
{
{
@@ -318,13 +283,13 @@
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_Error error;
- FT_UInt32 hash;
+ FT_PtrDist hash;
- /* some argument checks are delayed to FTC_Cache_Lookup */
+ /* some argument checks are delayed to `FTC_Cache_Lookup' */
if ( !aglyph )
{
- error = FTC_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -332,38 +297,15 @@
if ( anode )
*anode = NULL;
-#if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU )
-
- /*
- * This one is a major hack used to detect whether we are passed a
- * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one.
- */
- if ( (FT_ULong)type->width >= 0x10000L )
- {
- FTC_OldImageDesc desc = (FTC_OldImageDesc)type;
-
-
- query.attrs.scaler.face_id = desc->font.face_id;
- query.attrs.scaler.width = desc->font.pix_width;
- query.attrs.scaler.height = desc->font.pix_height;
- query.attrs.load_flags = desc->flags;
- }
- else
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
- {
- if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
- {
- FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
- FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
- }
+ if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+ FT_TRACE1(( "FTC_ImageCache_Lookup:"
+ " higher bits in load_flags 0x%x are dropped\n",
+ type->flags & ~((FT_ULong)FT_UINT_MAX) ));
- query.attrs.scaler.face_id = type->face_id;
- query.attrs.scaler.width = type->width;
- query.attrs.scaler.height = type->height;
- query.attrs.load_flags = (FT_UInt)type->flags;
- }
+ query.attrs.scaler.face_id = type->face_id;
+ query.attrs.scaler.width = type->width;
+ query.attrs.scaler.height = type->height;
+ query.attrs.load_flags = (FT_UInt)type->flags;
query.attrs.scaler.pixel = 1;
query.attrs.scaler.x_res = 0; /* make compilers happy */
@@ -414,13 +356,13 @@
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_Error error;
- FT_UInt32 hash;
+ FT_PtrDist hash;
- /* some argument checks are delayed to FTC_Cache_Lookup */
+ /* some argument checks are delayed to `FTC_Cache_Lookup' */
if ( !aglyph || !scaler )
{
- error = FTC_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -428,12 +370,11 @@
if ( anode )
*anode = NULL;
- /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
+ /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */
if ( load_flags > FT_UINT_MAX )
- {
- FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
- FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
- }
+ FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
+ " higher bits in load_flags 0x%x are dropped\n",
+ load_flags & ~((FT_ULong)FT_UINT_MAX) ));
query.attrs.scaler = scaler[0];
query.attrs.load_flags = (FT_UInt)load_flags;
@@ -463,148 +404,17 @@
}
-
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /* yet another backwards-legacy structure */
- typedef struct FTC_OldImage_Desc_
- {
- FTC_FontRec font;
- FT_UInt image_type;
-
- } FTC_OldImage_Desc;
-
-
-#define FTC_OLD_IMAGE_FORMAT( x ) ( (x) & 7 )
-
-
-#define ftc_old_image_format_bitmap 0x0000
-#define ftc_old_image_format_outline 0x0001
-
-#define ftc_old_image_format_mask 0x000F
-
-#define ftc_old_image_flag_monochrome 0x0010
-#define ftc_old_image_flag_unhinted 0x0020
-#define ftc_old_image_flag_autohinted 0x0040
-#define ftc_old_image_flag_unscaled 0x0080
-#define ftc_old_image_flag_no_sbits 0x0100
-
- /* monochrome bitmap */
-#define ftc_old_image_mono ftc_old_image_format_bitmap | \
- ftc_old_image_flag_monochrome
-
- /* anti-aliased bitmap */
-#define ftc_old_image_grays ftc_old_image_format_bitmap
-
- /* scaled outline */
-#define ftc_old_image_outline ftc_old_image_format_outline
-
-
- static void
- ftc_image_type_from_old_desc( FTC_ImageType typ,
- FTC_OldImage_Desc* desc )
- {
- typ->face_id = desc->font.face_id;
- typ->width = desc->font.pix_width;
- typ->height = desc->font.pix_height;
-
- /* convert image type flags to load flags */
- {
- FT_UInt load_flags = FT_LOAD_DEFAULT;
- FT_UInt type = desc->image_type;
-
-
- /* determine load flags, depending on the font description's */
- /* image type */
-
- if ( FTC_OLD_IMAGE_FORMAT( type ) == ftc_old_image_format_bitmap )
- {
- if ( type & ftc_old_image_flag_monochrome )
- load_flags |= FT_LOAD_MONOCHROME;
-
- /* disable embedded bitmaps loading if necessary */
- if ( type & ftc_old_image_flag_no_sbits )
- load_flags |= FT_LOAD_NO_BITMAP;
- }
- else
- {
- /* we want an outline, don't load embedded bitmaps */
- load_flags |= FT_LOAD_NO_BITMAP;
-
- if ( type & ftc_old_image_flag_unscaled )
- load_flags |= FT_LOAD_NO_SCALE;
- }
-
- /* always render glyphs to bitmaps */
- load_flags |= FT_LOAD_RENDER;
-
- if ( type & ftc_old_image_flag_unhinted )
- load_flags |= FT_LOAD_NO_HINTING;
-
- if ( type & ftc_old_image_flag_autohinted )
- load_flags |= FT_LOAD_FORCE_AUTOHINT;
-
- typ->flags = load_flags;
- }
- }
-
-
- FT_EXPORT( FT_Error )
- FTC_Image_Cache_New( FTC_Manager manager,
- FTC_ImageCache *acache );
-
- FT_EXPORT( FT_Error )
- FTC_Image_Cache_Lookup( FTC_ImageCache icache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FT_Glyph *aglyph );
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Image_Cache_New( FTC_Manager manager,
- FTC_ImageCache *acache )
- {
- return FTC_ImageCache_New( manager, (FTC_ImageCache*)acache );
- }
-
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Image_Cache_Lookup( FTC_ImageCache icache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FT_Glyph *aglyph )
- {
- FTC_ImageTypeRec type0;
-
-
- if ( !desc )
- return FTC_Err_Invalid_Argument;
-
- ftc_image_type_from_old_desc( &type0, desc );
-
- return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
- &type0,
- gindex,
- aglyph,
- NULL );
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
- /*
- *
- * basic small bitmap cache
- *
- */
-
+ /*
+ *
+ * basic small bitmap cache
+ *
+ */
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_SFamilyClassRec ftc_basic_sbit_family_class =
{
{
- sizeof( FTC_BasicFamilyRec ),
+ sizeof ( FTC_BasicFamilyRec ),
ftc_basic_family_compare,
ftc_basic_family_init,
0, /* FTC_MruNode_ResetFunc */
@@ -615,7 +425,7 @@
};
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_GCacheClassRec ftc_basic_sbit_cache_class =
{
{
@@ -656,49 +466,27 @@
FT_Error error;
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
- FT_UInt32 hash;
+ FT_PtrDist hash;
if ( anode )
*anode = NULL;
- /* other argument checks delayed to FTC_Cache_Lookup */
+ /* other argument checks delayed to `FTC_Cache_Lookup' */
if ( !ansbit )
- return FTC_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*ansbit = NULL;
-#if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU )
+ if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+ FT_TRACE1(( "FTC_ImageCache_Lookup:"
+ " higher bits in load_flags 0x%x are dropped\n",
+ type->flags & ~((FT_ULong)FT_UINT_MAX) ));
- /* This one is a major hack used to detect whether we are passed a
- * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one.
- */
- if ( (FT_ULong)type->width >= 0x10000L )
- {
- FTC_OldImageDesc desc = (FTC_OldImageDesc)type;
-
-
- query.attrs.scaler.face_id = desc->font.face_id;
- query.attrs.scaler.width = desc->font.pix_width;
- query.attrs.scaler.height = desc->font.pix_height;
- query.attrs.load_flags = desc->flags;
- }
- else
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
- {
- if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
- {
- FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
- FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
- }
-
- query.attrs.scaler.face_id = type->face_id;
- query.attrs.scaler.width = type->width;
- query.attrs.scaler.height = type->height;
- query.attrs.load_flags = (FT_UInt)type->flags;
- }
+ query.attrs.scaler.face_id = type->face_id;
+ query.attrs.scaler.width = type->width;
+ query.attrs.scaler.height = type->height;
+ query.attrs.load_flags = (FT_UInt)type->flags;
query.attrs.scaler.pixel = 1;
query.attrs.scaler.x_res = 0; /* make compilers happy */
@@ -753,24 +541,23 @@
FT_Error error;
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
- FT_UInt32 hash;
+ FT_PtrDist hash;
if ( anode )
*anode = NULL;
- /* other argument checks delayed to FTC_Cache_Lookup */
+ /* other argument checks delayed to `FTC_Cache_Lookup' */
if ( !ansbit || !scaler )
- return FTC_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*ansbit = NULL;
- /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
+ /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */
if ( load_flags > FT_UINT_MAX )
- {
- FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
- FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
- }
+ FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
+ " higher bits in load_flags 0x%x are dropped\n",
+ load_flags & ~((FT_ULong)FT_UINT_MAX) ));
query.attrs.scaler = scaler[0];
query.attrs.load_flags = (FT_UInt)load_flags;
@@ -803,49 +590,4 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_EXPORT( FT_Error )
- FTC_SBit_Cache_New( FTC_Manager manager,
- FTC_SBitCache *acache );
-
- FT_EXPORT( FT_Error )
- FTC_SBit_Cache_Lookup( FTC_SBitCache cache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FTC_SBit *ansbit );
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_SBit_Cache_New( FTC_Manager manager,
- FTC_SBitCache *acache )
- {
- return FTC_SBitCache_New( manager, (FTC_SBitCache*)acache );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_SBit_Cache_Lookup( FTC_SBitCache cache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FTC_SBit *ansbit )
- {
- FTC_ImageTypeRec type0;
-
-
- if ( !desc )
- return FT_Err_Invalid_Argument;
-
- ftc_image_type_from_old_desc( &type0, desc );
-
- return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
- &type0,
- gindex,
- ansbit,
- NULL );
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftccache.c b/src/3rdparty/freetype/src/cache/ftccache.c
index 463addd99b..f20dd4502c 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2000-2007, 2009-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -32,7 +32,7 @@
#define FTC_HASH_MIN_LOAD 1
#define FTC_HASH_SUB_LOAD ( FTC_HASH_MAX_LOAD - FTC_HASH_MIN_LOAD )
-/* this one _must_ be a power of 2! */
+ /* this one _must_ be a power of 2! */
#define FTC_HASH_INITIAL_SIZE 8
@@ -83,6 +83,25 @@
(FTC_MruNode)node );
}
+
+ /* get a top bucket for specified hash from cache,
+ * body for FTC_NODE__TOP_FOR_HASH( cache, hash )
+ */
+ FT_LOCAL_DEF( FTC_Node* )
+ ftc_get_top_node_for_hash( FTC_Cache cache,
+ FT_PtrDist hash )
+ {
+ FTC_Node* pnode;
+ FT_UInt idx;
+
+
+ idx = (FT_UInt)( hash & cache->mask );
+ if ( idx < cache->p )
+ idx = (FT_UInt)( hash & ( 2 * cache->mask + 1 ) );
+ pnode = cache->buckets + idx;
+ return pnode;
+ }
+
#endif /* !FTC_INLINE */
@@ -96,9 +115,9 @@
for (;;)
{
FTC_Node node, *pnode;
- FT_UFast p = cache->p;
- FT_UFast mask = cache->mask;
- FT_UFast count = mask + p + 1; /* number of buckets */
+ FT_UFast p = cache->p;
+ FT_UFast mask = cache->mask;
+ FT_UFast count = mask + p + 1; /* number of buckets */
/* do we need to shrink the buckets array? */
@@ -117,7 +136,8 @@
/* if we can't expand the array, leave immediately */
- if ( FT_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) )
+ if ( FT_RENEW_ARRAY( cache->buckets,
+ ( mask + 1 ) * 2, ( mask + 1 ) * 4 ) )
break;
}
@@ -191,7 +211,9 @@
cache->slack -= FTC_HASH_MAX_LOAD;
cache->p = p;
}
- else /* the hash table is balanced */
+
+ /* otherwise, the hash table is balanced */
+ else
break;
}
}
@@ -202,16 +224,9 @@
ftc_node_hash_unlink( FTC_Node node0,
FTC_Cache cache )
{
- FTC_Node *pnode;
- FT_UInt idx;
+ FTC_Node *pnode = FTC_NODE__TOP_FOR_HASH( cache, node0->hash );
- idx = (FT_UInt)( node0->hash & cache->mask );
- if ( idx < cache->p )
- idx = (FT_UInt)( node0->hash & ( 2 * cache->mask + 1 ) );
-
- pnode = cache->buckets + idx;
-
for (;;)
{
FTC_Node node = *pnode;
@@ -242,15 +257,8 @@
ftc_node_hash_link( FTC_Node node,
FTC_Cache cache )
{
- FTC_Node *pnode;
- FT_UInt idx;
-
+ FTC_Node *pnode = FTC_NODE__TOP_FOR_HASH( cache, node->hash );
- idx = (FT_UInt)( node->hash & cache->mask );
- if ( idx < cache->p )
- idx = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) );
-
- pnode = cache->buckets + idx;
node->link = *pnode;
*pnode = node;
@@ -261,11 +269,7 @@
/* remove a node from the cache manager */
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- FT_BASE_DEF( void )
-#else
FT_LOCAL_DEF( void )
-#endif
ftc_node_destroy( FTC_Node node,
FTC_Manager manager )
{
@@ -346,7 +350,7 @@
static void
FTC_Cache_Clear( FTC_Cache cache )
{
- if ( cache )
+ if ( cache && cache->buckets )
{
FTC_Manager manager = cache->manager;
FT_UFast i;
@@ -410,11 +414,11 @@
static void
ftc_cache_add( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FTC_Node node )
{
- node->hash = hash;
- node->cache_index = (FT_UInt16) cache->index;
+ node->hash = hash;
+ node->cache_index = (FT_UInt16)cache->index;
node->ref_count = 0;
ftc_node_hash_link( node, cache );
@@ -438,7 +442,7 @@
FT_LOCAL_DEF( FT_Error )
FTC_Cache_NewNode( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode )
{
@@ -456,7 +460,7 @@
{
error = cache->clazz.node_new( &node, query, cache );
}
- FTC_CACHE_TRYLOOP_END();
+ FTC_CACHE_TRYLOOP_END( NULL );
if ( error )
node = NULL;
@@ -477,40 +481,59 @@
FT_LOCAL_DEF( FT_Error )
FTC_Cache_Lookup( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode )
{
- FT_UFast idx;
FTC_Node* bucket;
FTC_Node* pnode;
FTC_Node node;
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
+ FT_Bool list_changed = FALSE;
FTC_Node_CompareFunc compare = cache->clazz.node_compare;
if ( cache == NULL || anode == NULL )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
- idx = hash & cache->mask;
- if ( idx < cache->p )
- idx = hash & ( cache->mask * 2 + 1 );
+ /* Go to the `top' node of the list sharing same masked hash */
+ bucket = pnode = FTC_NODE__TOP_FOR_HASH( cache, hash );
- bucket = cache->buckets + idx;
- pnode = bucket;
+ /* 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 )
goto NewNode;
- if ( node->hash == hash && compare( node, query, cache ) )
+ if ( node->hash == hash &&
+ compare( node, query, cache, &list_changed ) )
break;
pnode = &node->link;
}
+ if ( list_changed )
+ {
+ /* Update bucket by modified linked list */
+ bucket = pnode = FTC_NODE__TOP_FOR_HASH( cache, hash );
+
+ /* Update pnode by modified linked list */
+ while ( *pnode != node )
+ {
+ if ( *pnode == NULL )
+ {
+ FT_ERROR(( "FTC_Cache_Lookup: oops!!! node missing\n" ));
+ goto NewNode;
+ }
+ else
+ pnode = &((*pnode)->link);
+ }
+ }
+
+ /* Reorder the list to move the found node to the `top' */
if ( node != *bucket )
{
*pnode = node->link;
@@ -527,6 +550,7 @@
ftc_node_mru_up( node, manager );
}
*anode = node;
+
return error;
NewNode:
@@ -545,7 +569,7 @@
FTC_Node frees = NULL;
- count = cache->p + cache->mask;
+ count = cache->p + cache->mask + 1;
for ( i = 0; i < count; i++ )
{
FTC_Node* bucket = cache->buckets + i;
@@ -555,12 +579,14 @@
for ( ;; )
{
FTC_Node node = *pnode;
+ FT_Bool list_changed = FALSE;
if ( node == NULL )
break;
- if ( cache->clazz.node_remove_faceid( node, face_id, cache ) )
+ if ( cache->clazz.node_remove_faceid( node, face_id,
+ cache, &list_changed ) )
{
*pnode = node->link;
node->link = frees;
diff --git a/src/3rdparty/freetype/src/cache/ftccache.h b/src/3rdparty/freetype/src/cache/ftccache.h
index 2082bc4f4f..4155f320e0 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2000-2007, 2009-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,6 +24,9 @@
FT_BEGIN_HEADER
+#define _FTC_FACE_ID_HASH( i ) \
+ ((FT_PtrDist)(( (FT_PtrDist)(i) >> 3 ) ^ ( (FT_PtrDist)(i) << 7 )))
+
/* handle to cache object */
typedef struct FTC_CacheRec_* FTC_Cache;
@@ -56,7 +59,7 @@ FT_BEGIN_HEADER
{
FTC_MruNodeRec mru; /* circular mru list pointer */
FTC_Node link; /* used for hashing */
- FT_UInt32 hash; /* used for hashing too */
+ FT_PtrDist hash; /* used for hashing too */
FT_UShort cache_index; /* index of cache the node belongs to */
FT_Short ref_count; /* reference count for this node */
@@ -69,11 +72,18 @@ FT_BEGIN_HEADER
#define FTC_NODE__NEXT( x ) FTC_NODE( (x)->mru.next )
#define FTC_NODE__PREV( x ) FTC_NODE( (x)->mru.prev )
-
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- FT_BASE( void )
- ftc_node_destroy( FTC_Node node,
- FTC_Manager manager );
+#ifdef FTC_INLINE
+#define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
+ ( ( cache )->buckets + \
+ ( ( ( ( hash ) & ( cache )->mask ) < ( cache )->p ) \
+ ? ( ( hash ) & ( ( cache )->mask * 2 + 1 ) ) \
+ : ( ( hash ) & ( cache )->mask ) ) )
+#else
+ FT_LOCAL( FTC_Node* )
+ ftc_get_top_node_for_hash( FTC_Cache cache,
+ FT_PtrDist hash );
+#define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
+ ftc_get_top_node_for_hash( ( cache ), ( hash ) )
#endif
@@ -99,7 +109,8 @@ FT_BEGIN_HEADER
typedef FT_Bool
(*FTC_Node_CompareFunc)( FTC_Node node,
FT_Pointer key,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed );
typedef void
@@ -159,7 +170,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
FTC_Cache_Done( FTC_Cache cache );
- /* Call this function to lookup the cache. If no corresponding
+ /* Call this function to look up the cache. If no corresponding
* node is found, a new one is automatically created. This function
* is capable of flushing the cache adequately to make room for the
* new cache object.
@@ -168,20 +179,20 @@ FT_BEGIN_HEADER
#ifndef FTC_INLINE
FT_LOCAL( FT_Error )
FTC_Cache_Lookup( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode );
#endif
FT_LOCAL( FT_Error )
FTC_Cache_NewNode( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode );
/* Remove all nodes that relate to a given face_id. This is useful
* when un-installing fonts. Note that if a cache node relates to
- * the face_id, but is locked (i.e., has `ref_count > 0'), the node
+ * the face_id but is locked (i.e., has `ref_count > 0'), the node
* will _not_ be destroyed, but its internal face_id reference will
* be modified.
*
@@ -200,30 +211,51 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
FTC_Node *_bucket, *_pnode, _node; \
FTC_Cache _cache = FTC_CACHE(cache); \
- FT_UInt32 _hash = (FT_UInt32)(hash); \
+ FT_PtrDist _hash = (FT_PtrDist)(hash); \
FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \
- FT_UFast _idx; \
+ FT_Bool _list_changed = FALSE; \
\
\
- error = 0; \
+ error = FT_Err_Ok; \
node = NULL; \
- _idx = _hash & _cache->mask; \
- if ( _idx < _cache->p ) \
- _idx = _hash & ( _cache->mask*2 + 1 ); \
\
- _bucket = _pnode = _cache->buckets + _idx; \
+ /* Go to the `top' node of the list sharing same masked 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->hash == _hash && _nodcomp( _node, query, _cache ) ) \
+ if ( _node->hash == _hash && \
+ _nodcomp( _node, query, _cache, &_list_changed ) ) \
break; \
\
_pnode = &_node->link; \
} \
\
+ if ( _list_changed ) \
+ { \
+ /* Update _bucket by possibly modified linked list */ \
+ _bucket = _pnode = FTC_NODE__TOP_FOR_HASH( _cache, _hash ); \
+ \
+ /* Update _pnode by possibly modified linked list */ \
+ while ( *_pnode != _node ) \
+ { \
+ if ( *_pnode == NULL ) \
+ { \
+ FT_ERROR(( "FTC_CACHE_LOOKUP_CMP: oops!!! node missing\n" )); \
+ goto _NewNode; \
+ } \
+ else \
+ _pnode = &((*_pnode)->link); \
+ } \
+ } \
+ \
+ /* Reorder the list to move the found node to the `top' */ \
if ( _node != *_bucket ) \
{ \
*_pnode = _node->link; \
@@ -231,6 +263,7 @@ FT_BEGIN_HEADER
*_bucket = _node; \
} \
\
+ /* Update MRU list */ \
{ \
FTC_Manager _manager = _cache->manager; \
void* _nl = &_manager->nodes_list; \
@@ -265,7 +298,7 @@ FT_BEGIN_HEADER
* loop to flush the cache repeatedly in case of memory overflows.
*
* It is used when creating a new cache node, or within a lookup
- * that needs to allocate data (e.g., the sbit cache lookup).
+ * that needs to allocate data (e.g. the sbit cache lookup).
*
* Example:
*
@@ -287,11 +320,14 @@ FT_BEGIN_HEADER
FT_UInt _try_done;
-#define FTC_CACHE_TRYLOOP_END() \
- if ( !error || error != FT_Err_Out_Of_Memory ) \
+#define FTC_CACHE_TRYLOOP_END( list_changed ) \
+ if ( !error || FT_ERR_NEQ( error, Out_Of_Memory ) ) \
break; \
\
_try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
+ if ( _try_done > 0 && ( list_changed ) ) \
+ *(FT_Bool*)( list_changed ) = TRUE; \
+ \
if ( _try_done == 0 ) \
break; \
\
diff --git a/src/3rdparty/freetype/src/cache/ftccback.h b/src/3rdparty/freetype/src/cache/ftccback.h
index 4d0818db27..9528279273 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, 2005, 2006 by */
+/* Copyright 2004-2006, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -57,13 +57,15 @@
FT_LOCAL( FT_Bool )
ftc_snode_compare( FTC_Node snode,
FT_Pointer gquery,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed );
FT_LOCAL( FT_Bool )
ftc_gnode_compare( FTC_Node gnode,
FT_Pointer gquery,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed );
FT_LOCAL( FT_Error )
@@ -79,11 +81,10 @@
FT_LOCAL( void )
ftc_cache_done( FTC_Cache cache );
-#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
FT_LOCAL( void )
ftc_node_destroy( FTC_Node node,
FTC_Manager manager );
-#endif
+
#endif /* __FTCCBACK_H__ */
diff --git a/src/3rdparty/freetype/src/cache/ftccmap.c b/src/3rdparty/freetype/src/cache/ftccmap.c
index a802b0557c..ab223663bb 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2000-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,7 @@
#include FT_CACHE_H
#include "ftcmanag.h"
#include FT_INTERNAL_MEMORY_H
+#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include "ftccback.h"
@@ -30,43 +31,6 @@
#define FT_COMPONENT trace_cache
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- typedef enum FTC_OldCMapType_
- {
- FTC_OLD_CMAP_BY_INDEX = 0,
- FTC_OLD_CMAP_BY_ENCODING = 1,
- FTC_OLD_CMAP_BY_ID = 2
-
- } FTC_OldCMapType;
-
-
- typedef struct FTC_OldCMapIdRec_
- {
- FT_UInt platform;
- FT_UInt encoding;
-
- } FTC_OldCMapIdRec, *FTC_OldCMapId;
-
-
- typedef struct FTC_OldCMapDescRec_
- {
- FTC_FaceID face_id;
- FTC_OldCMapType type;
-
- union
- {
- FT_UInt index;
- FT_Encoding encoding;
- FTC_OldCMapIdRec id;
-
- } u;
-
- } FTC_OldCMapDescRec, *FTC_OldCMapDesc;
-
-#endif /* FT_CONFIG_OLD_INTERNALS */
-
-
/*************************************************************************/
/* */
/* Each FTC_CMapNode contains a simple array to map a range of character */
@@ -86,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 */
@@ -119,7 +83,7 @@
/* if (indices[n] == FTC_CMAP_UNKNOWN), we assume that the corresponding */
/* glyph indices haven't been queried through FT_Get_Glyph_Index() yet */
-#define FTC_CMAP_UNKNOWN ( (FT_UInt16)-1 )
+#define FTC_CMAP_UNKNOWN (FT_UInt16)~0
/*************************************************************************/
@@ -153,7 +117,7 @@
FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
FT_Error error;
FT_Memory memory = cache->memory;
- FTC_CMapNode node;
+ FTC_CMapNode node = NULL;
FT_UInt nn;
@@ -189,13 +153,16 @@
FT_CALLBACK_DEF( FT_Bool )
ftc_cmap_node_compare( FTC_Node ftcnode,
FT_Pointer ftcquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_CMapNode node = (FTC_CMapNode)ftcnode;
FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
FT_UNUSED( cache );
+ if ( list_changed )
+ *list_changed = FALSE;
if ( node->face_id == query->face_id &&
node->cmap_index == query->cmap_index )
{
@@ -212,12 +179,16 @@
FT_CALLBACK_DEF( FT_Bool )
ftc_cmap_node_remove_faceid( FTC_Node ftcnode,
FT_Pointer ftcface_id,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_CMapNode node = (FTC_CMapNode)ftcnode;
FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
FT_UNUSED( cache );
+
+ if ( list_changed )
+ *list_changed = FALSE;
return FT_BOOL( node->face_id == face_id );
}
@@ -231,7 +202,7 @@
/*************************************************************************/
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_CacheClassRec ftc_cmap_cache_class =
{
ftc_cmap_node_new,
@@ -258,21 +229,6 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /*
- * Unfortunately, it is not possible to support binary backwards
- * compatibility in the cmap cache. The FTC_CMapCache_Lookup signature
- * changes were too deep, and there is no clever hackish way to detect
- * what kind of structure we are being passed.
- *
- * On the other hand it seems that no production code is using this
- * function on Unix distributions.
- */
-
-#endif
-
-
/* documentation is in ftcache.h */
FT_EXPORT_DEF( FT_UInt )
@@ -286,7 +242,7 @@
FTC_Node node;
FT_Error error;
FT_UInt gindex = 0;
- FT_UInt32 hash;
+ FT_PtrDist hash;
FT_Int no_cmap_change = 0;
@@ -307,65 +263,12 @@
return 0;
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /*
- * Detect a call from a rogue client that thinks it is linking
- * to FreeType 2.1.7. This is possible because the third parameter
- * is then a character code, and we have never seen any font with
- * more than a few charmaps, so if the index is very large...
- *
- * It is also very unlikely that a rogue client is interested
- * in Unicode values 0 to 15.
- *
- * NOTE: The original threshold was 4, but we found a font from the
- * Adobe Acrobat Reader Pack, named `KozMinProVI-Regular.otf',
- * which contains more than 5 charmaps.
- */
- if ( cmap_index >= 16 && !no_cmap_change )
- {
- FTC_OldCMapDesc desc = (FTC_OldCMapDesc) face_id;
-
-
- char_code = (FT_UInt32)cmap_index;
- query.face_id = desc->face_id;
-
-
- switch ( desc->type )
- {
- case FTC_OLD_CMAP_BY_INDEX:
- query.cmap_index = desc->u.index;
- query.char_code = (FT_UInt32)cmap_index;
- break;
-
- case FTC_OLD_CMAP_BY_ENCODING:
- {
- FT_Face face;
-
-
- error = FTC_Manager_LookupFace( cache->manager, desc->face_id,
- &face );
- if ( error )
- return 0;
-
- FT_Select_Charmap( face, desc->u.encoding );
-
- return FT_Get_Char_Index( face, char_code );
- }
-
- default:
- return 0;
- }
- }
- else
+ if ( !face_id )
+ return 0;
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
- {
- query.face_id = face_id;
- query.cmap_index = (FT_UInt)cmap_index;
- query.char_code = char_code;
- }
+ query.face_id = face_id;
+ query.cmap_index = (FT_UInt)cmap_index;
+ query.char_code = char_code;
hash = FTC_CMAP_HASH( face_id, cmap_index, char_code );
@@ -384,7 +287,7 @@
/* something rotten can happen with rogue clients */
if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >=
FTC_CMAP_INDICES_MAX ) )
- return 0;
+ return 0; /* XXX: should return appropriate error */
gindex = FTC_CMAP_NODE( node )->indices[char_code -
FTC_CMAP_NODE( node )->first];
diff --git a/src/3rdparty/freetype/src/cache/ftcerror.h b/src/3rdparty/freetype/src/cache/ftcerror.h
index 5998d42daf..0e055709bb 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX FTC_Err_
#define FT_ERR_BASE FT_Mod_Err_Cache
diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.c b/src/3rdparty/freetype/src/cache/ftcglyph.c
index a9ab0c319f..441e177238 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-2001, 2003, 2004, 2006, 2009 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2009, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_OBJECTS_H
#include FT_CACHE_H
#include "ftcglyph.h"
#include FT_ERRORS_H
@@ -64,25 +65,34 @@
FT_LOCAL_DEF( FT_Bool )
ftc_gnode_compare( FTC_Node ftcgnode,
FT_Pointer ftcgquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_GNode gnode = (FTC_GNode)ftcgnode;
FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
FT_UNUSED( cache );
+ if ( list_changed )
+ *list_changed = FALSE;
return FT_BOOL( gnode->family == gquery->family &&
gnode->gindex == gquery->gindex );
}
+#ifdef FTC_INLINE
+
FT_LOCAL_DEF( FT_Bool )
FTC_GNode_Compare( FTC_GNode gnode,
- FTC_GQuery gquery )
+ FTC_GQuery gquery,
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
- return ftc_gnode_compare( FTC_NODE( gnode ), gquery, NULL );
+ return ftc_gnode_compare( FTC_NODE( gnode ), gquery,
+ cache, list_changed );
}
+#endif
/*************************************************************************/
/*************************************************************************/
@@ -175,7 +185,7 @@
FT_LOCAL_DEF( FT_Error )
FTC_GCache_Lookup( FTC_GCache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_UInt gindex,
FTC_GQuery query,
FTC_Node *anode )
diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.h b/src/3rdparty/freetype/src/cache/ftcglyph.h
index c18f9c3af3..5fed19cb8f 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-2001, 2003, 2004, 2006, 2007 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2007, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -180,12 +180,18 @@ FT_BEGIN_HEADER
FT_UInt gindex, /* glyph index for node */
FTC_Family family );
+#ifdef FTC_INLINE
+
/* returns TRUE iff the query's glyph index correspond to the node; */
/* this assumes that the `family' and `hash' fields of the query are */
/* already correctly set */
FT_LOCAL( FT_Bool )
FTC_GNode_Compare( FTC_GNode gnode,
- FTC_GQuery gquery );
+ FTC_GQuery gquery,
+ FTC_Cache cache,
+ FT_Bool* list_changed );
+
+#endif
/* call this function to clear a node's family -- this is necessary */
/* to implement the `node_remove_faceid' cache method correctly */
@@ -254,7 +260,7 @@ FT_BEGIN_HEADER
#ifndef FTC_INLINE
FT_LOCAL( FT_Error )
FTC_GCache_Lookup( FTC_GCache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_UInt gindex,
FTC_GQuery query,
FTC_Node *anode );
@@ -307,7 +313,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
\
error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \
- FTC_GQUERY( query ), node ); \
+ FTC_GQUERY( query ), &node ); \
\
FT_END_STMNT
diff --git a/src/3rdparty/freetype/src/cache/ftcimage.c b/src/3rdparty/freetype/src/cache/ftcimage.c
index 417daf2aae..c242ece021 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-2001, 2003, 2004, 2006 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
{
FT_Memory memory = cache->memory;
FT_Error error;
- FTC_INode inode;
+ FTC_INode inode = NULL;
if ( !FT_NEW( inode ) )
diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.c b/src/3rdparty/freetype/src/cache/ftcmanag.c
index f2a298e7d9..fff7a08827 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-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
+/* Copyright 2000-2006, 2008-2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,7 +28,7 @@
#ifdef FT_CONFIG_OPTION_PIC
#error "cache system does not support PIC yet"
-#endif
+#endif
#undef FT_COMPONENT
@@ -151,7 +151,7 @@
}
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_MruListClassRec ftc_size_list_class =
{
sizeof ( FTC_SizeNodeRec ),
@@ -186,13 +186,13 @@
FTC_MruNode mrunode;
- if ( asize == NULL )
- return FTC_Err_Invalid_Argument;
+ if ( !asize || !scaler )
+ return FT_THROW( Invalid_Argument );
*asize = NULL;
if ( !manager )
- return FTC_Err_Invalid_Cache_Handle;
+ return FT_THROW( Invalid_Cache_Handle );
#ifdef FTC_INLINE
@@ -290,7 +290,7 @@
}
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_MruListClassRec ftc_face_list_class =
{
sizeof ( FTC_FaceNodeRec),
@@ -313,13 +313,13 @@
FTC_MruNode mrunode;
- if ( aface == NULL )
- return FTC_Err_Invalid_Argument;
+ if ( !aface || !face_id )
+ return FT_THROW( Invalid_Argument );
*aface = NULL;
if ( !manager )
- return FTC_Err_Invalid_Cache_Handle;
+ return FT_THROW( Invalid_Cache_Handle );
/* we break encapsulation for the sake of speed */
#ifdef FTC_INLINE
@@ -364,7 +364,10 @@
if ( !library )
- return FTC_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
+
+ if ( !amanager || !requester )
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
@@ -451,12 +454,13 @@
FT_EXPORT_DEF( void )
FTC_Manager_Reset( FTC_Manager manager )
{
- if ( manager )
- {
- FTC_MruList_Reset( &manager->sizes );
- FTC_MruList_Reset( &manager->faces );
- }
- /* XXX: FIXME: flush the caches? */
+ if ( !manager )
+ return;
+
+ FTC_MruList_Reset( &manager->sizes );
+ FTC_MruList_Reset( &manager->faces );
+
+ FTC_Manager_FlushN( manager, manager->num_nodes );
}
@@ -473,7 +477,7 @@
/* check node weights */
if ( first )
{
- FT_ULong weight = 0;
+ FT_Offset weight = 0;
node = first;
@@ -575,7 +579,7 @@
FTC_CacheClass clazz,
FTC_Cache *acache )
{
- FT_Error error = FTC_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FTC_Cache cache = NULL;
@@ -586,7 +590,7 @@
if ( manager->num_caches >= FTC_MAX_CACHES )
{
- error = FTC_Err_Too_Many_Caches;
+ error = FT_THROW( Too_Many_Caches );
FT_ERROR(( "FTC_Manager_RegisterCache:"
" too many registered caches\n" ));
goto Exit;
@@ -666,11 +670,15 @@
{
FT_UInt nn;
+
+ if ( !manager || !face_id )
+ return;
+
/* this will remove all FTC_SizeNode that correspond to
* the face_id as well
*/
FTC_MruList_RemoveSelection( &manager->faces,
- (FTC_MruNode_CompareFunc)NULL,
+ ftc_face_node_compare,
face_id );
for ( nn = 0; nn < manager->num_caches; nn++ )
@@ -684,60 +692,11 @@
FTC_Node_Unref( FTC_Node node,
FTC_Manager manager )
{
- if ( node && (FT_UInt)node->cache_index < manager->num_caches )
+ if ( node &&
+ manager &&
+ (FT_UInt)node->cache_index < manager->num_caches )
node->ref_count--;
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Manager_Lookup_Face( FTC_Manager manager,
- FTC_FaceID face_id,
- FT_Face *aface )
- {
- return FTC_Manager_LookupFace( manager, face_id, aface );
- }
-
-
- FT_EXPORT( FT_Error )
- FTC_Manager_Lookup_Size( FTC_Manager manager,
- FTC_Font font,
- FT_Face *aface,
- FT_Size *asize )
- {
- FTC_ScalerRec scaler;
- FT_Error error;
- FT_Size size;
- FT_Face face;
-
-
- scaler.face_id = font->face_id;
- scaler.width = font->pix_width;
- scaler.height = font->pix_height;
- scaler.pixel = TRUE;
- scaler.x_res = 0;
- scaler.y_res = 0;
-
- error = FTC_Manager_LookupSize( manager, &scaler, &size );
- if ( error )
- {
- face = NULL;
- size = NULL;
- }
- else
- face = size->face;
-
- if ( aface )
- *aface = face;
-
- if ( asize )
- *asize = size;
-
- return error;
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.h b/src/3rdparty/freetype/src/cache/ftcmanag.h
index 3fdc2c773b..0aec33c584 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-2001, 2003, 2004, 2006 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -94,8 +94,8 @@ FT_BEGIN_HEADER
FT_Memory memory;
FTC_Node nodes_list;
- FT_ULong max_weight;
- FT_ULong cur_weight;
+ FT_Offset max_weight;
+ FT_Offset cur_weight;
FT_UInt num_nodes;
FTC_Cache caches[FTC_MAX_CACHES];
@@ -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 ) ) )
diff --git a/src/3rdparty/freetype/src/cache/ftcmru.c b/src/3rdparty/freetype/src/cache/ftcmru.c
index 9944b58980..dc8b4cc397 100644
--- a/src/3rdparty/freetype/src/cache/ftcmru.c
+++ b/src/3rdparty/freetype/src/cache/ftcmru.c
@@ -161,7 +161,7 @@
*plist = NULL;
}
else if ( node == first )
- *plist = next;
+ *plist = next;
}
@@ -238,7 +238,7 @@
FTC_MruNode *anode )
{
FT_Error error;
- FTC_MruNode node;
+ FTC_MruNode node = NULL;
FT_Memory memory = list->memory;
@@ -264,14 +264,14 @@
list->clazz.node_done( node, list->data );
}
else if ( FT_ALLOC( node, list->clazz.node_size ) )
- goto Exit;
+ goto Exit;
error = list->clazz.node_init( node, key, list->data );
if ( error )
goto Fail;
- FTC_MruNode_Prepend( &list->nodes, node );
- list->num_nodes++;
+ FTC_MruNode_Prepend( &list->nodes, node );
+ list->num_nodes++;
Exit:
*anode = node;
@@ -316,7 +316,7 @@
if ( list->clazz.node_done )
- list->clazz.node_done( node, list->data );
+ list->clazz.node_done( node, list->data );
FT_FREE( node );
}
diff --git a/src/3rdparty/freetype/src/cache/ftcmru.h b/src/3rdparty/freetype/src/cache/ftcmru.h
index 5739439f45..6fccf11781 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-2001, 2003, 2004, 2005, 2006 by */
+/* Copyright 2000-2001, 2003-2006, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -166,7 +166,7 @@ FT_BEGIN_HEADER
FTC_MruNode _first, _node; \
\
\
- error = 0; \
+ error = FT_Err_Ok; \
_first = *(_pfirst); \
_node = NULL; \
\
diff --git a/src/3rdparty/freetype/src/cache/ftcsbits.c b/src/3rdparty/freetype/src/cache/ftcsbits.c
index 60d46aa7a0..59727d16e2 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-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2000-2006, 2009-2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -116,7 +116,7 @@
if ( (FT_UInt)(gindex - gnode->gindex) >= snode->count )
{
FT_ERROR(( "ftc_snode_load: invalid glyph index" ));
- return FTC_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
sbit = snode->sbits + ( gindex - gnode->gindex );
@@ -142,12 +142,12 @@
goto BadGlyph;
}
- /* Check that our values fit into 8-bit containers! */
+ /* Check whether our values fit into 8-bit containers! */
/* If this is not the case, our bitmap is too large */
/* and we will leave it as `missing' with sbit.buffer = 0 */
-#define CHECK_CHAR( d ) ( temp = (FT_Char)d, temp == d )
-#define CHECK_BYTE( d ) ( temp = (FT_Byte)d, temp == d )
+#define CHECK_CHAR( d ) ( temp = (FT_Char)d, (FT_Int) temp == (FT_Int) d )
+#define CHECK_BYTE( d ) ( temp = (FT_Byte)d, (FT_UInt)temp == (FT_UInt)d )
/* horizontal advance in pixels */
xadvance = ( slot->advance.x + 32 ) >> 6;
@@ -160,7 +160,11 @@
!CHECK_CHAR( slot->bitmap_top ) ||
!CHECK_CHAR( xadvance ) ||
!CHECK_CHAR( yadvance ) )
+ {
+ FT_TRACE2(( "ftc_snode_load:"
+ " glyph too large for small bitmap cache\n"));
goto BadGlyph;
+ }
sbit->width = (FT_Byte)bitmap->width;
sbit->height = (FT_Byte)bitmap->rows;
@@ -185,13 +189,13 @@
/* we mark unloaded glyphs with `sbit.buffer == 0' */
/* and `width == 255', `height == 0' */
/* */
- if ( error && error != FTC_Err_Out_Of_Memory )
+ if ( error && FT_ERR_NEQ( error, Out_Of_Memory ) )
{
BadGlyph:
sbit->width = 255;
sbit->height = 0;
sbit->buffer = NULL;
- error = 0;
+ error = FT_Err_Ok;
if ( asize )
*asize = 0;
}
@@ -213,12 +217,13 @@
FTC_SFamilyClass clazz = FTC_CACHE__SFAMILY_CLASS( cache );
FT_UInt total;
+ FT_UInt node_count;
total = clazz->family_get_count( family, cache->manager );
if ( total == 0 || gindex >= total )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -235,6 +240,10 @@
FTC_GNode_Init( FTC_GNODE( snode ), start, family );
snode->count = count;
+ for ( node_count = 0; node_count < count; node_count++ )
+ {
+ snode->sbits[node_count].width = 255;
+ }
error = ftc_snode_load( snode,
cache->manager,
@@ -315,7 +324,8 @@
FT_LOCAL_DEF( FT_Bool )
ftc_snode_compare( FTC_Node ftcsnode,
FT_Pointer ftcgquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_SNode snode = (FTC_SNode)ftcsnode;
FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
@@ -324,6 +334,8 @@
FT_Bool result;
+ if (list_changed)
+ *list_changed = FALSE;
result = FT_BOOL( gnode->family == gquery->family &&
(FT_UInt)( gindex - gnode->gindex ) < snode->count );
if ( result )
@@ -364,7 +376,7 @@
*
*/
- if ( sbit->buffer == NULL && sbit->width != 255 )
+ if ( sbit->buffer == NULL && sbit->width == 255 )
{
FT_ULong size;
FT_Error error;
@@ -377,7 +389,7 @@
{
error = ftc_snode_load( snode, cache->manager, gindex, &size );
}
- FTC_CACHE_TRYLOOP_END();
+ FTC_CACHE_TRYLOOP_END( list_changed );
ftcsnode->ref_count--; /* unlock the node */
@@ -392,13 +404,18 @@
}
+#ifdef FTC_INLINE
+
FT_LOCAL_DEF( FT_Bool )
FTC_SNode_Compare( FTC_SNode snode,
FTC_GQuery gquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
- return ftc_snode_compare( FTC_NODE( snode ), gquery, cache );
+ return ftc_snode_compare( FTC_NODE( snode ), gquery,
+ cache, list_changed );
}
+#endif
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcsbits.h b/src/3rdparty/freetype/src/cache/ftcsbits.h
index 6261745f1e..df55dca806 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-2001, 2002, 2003, 2006 by */
+/* Copyright 2000-2001, 2002, 2003, 2006, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -83,10 +83,15 @@ FT_BEGIN_HEADER
#endif
+#ifdef FTC_INLINE
+
FT_LOCAL( FT_Bool )
FTC_SNode_Compare( FTC_SNode snode,
FTC_GQuery gquery,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed);
+
+#endif
/* */
diff --git a/src/3rdparty/freetype/src/cff/cf2arrst.c b/src/3rdparty/freetype/src/cff/cf2arrst.c
new file mode 100644
index 0000000000..c8d6f13098
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2arrst.c
@@ -0,0 +1,241 @@
+/***************************************************************************/
+/* */
+/* cf2arrst.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 "cf2ft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "cf2glue.h"
+#include "cf2arrst.h"
+
+#include "cf2error.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 != NULL );
+
+ /* 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 != NULL );
+
+ 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 != NULL );
+
+ {
+ FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
+ FT_Memory memory = arrstack->memory; /* for FT_REALLOC */
+
+ FT_Long newSize = (FT_Long)( numElements * arrstack->sizeItem );
+
+
+ if ( numElements > 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 != NULL );
+
+ 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 != NULL );
+
+ arrstack->count = 0;
+ }
+
+
+ /* current number of items */
+ FT_LOCAL_DEF( size_t )
+ cf2_arrstack_size( const CF2_ArrStack arrstack )
+ {
+ FT_ASSERT( arrstack != NULL );
+
+ return arrstack->count;
+ }
+
+
+ FT_LOCAL_DEF( void* )
+ cf2_arrstack_getBuffer( const CF2_ArrStack arrstack )
+ {
+ FT_ASSERT( arrstack != NULL );
+
+ 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 != NULL );
+
+ 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 != NULL );
+
+ 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 != NULL );
+
+ {
+ 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/cff/cf2arrst.h b/src/3rdparty/freetype/src/cff/cf2arrst.h
new file mode 100644
index 0000000000..ff5ad8b126
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2arrst.h
@@ -0,0 +1,100 @@
+/***************************************************************************/
+/* */
+/* cf2arrst.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 __CF2ARRST_H__
+#define __CF2ARRST_H__
+
+
+#include "cf2error.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 /* __CF2ARRST_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2blues.c b/src/3rdparty/freetype/src/cff/cf2blues.c
new file mode 100644
index 0000000000..250f89e0df
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2blues.c
@@ -0,0 +1,579 @@
+/***************************************************************************/
+/* */
+/* cf2blues.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 "cf2ft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "cf2blues.h"
+#include "cf2hints.h"
+#include "cf2font.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 */
+ CFF_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 = 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 = 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( 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( 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( 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_floatToFixed( .6 ) -
+ FT_MulDiv( cf2_floatToFixed ( .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 ( ( blues->zone[i].csBottomEdge - csFuzz ) <=
+ bottomHintEdge->csCoord &&
+ bottomHintEdge->csCoord <=
+ ( blues->zone[i].csTopEdge + csFuzz ) )
+ {
+ /* bottom edge captured by bottom zone */
+
+ if ( blues->suppressOvershoot )
+ dsNew = blues->zone[i].dsFlatEdge;
+
+ else if ( ( 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 = dsNew - bottomHintEdge->dsCoord;
+ captured = TRUE;
+
+ break;
+ }
+ }
+
+ if ( !blues->zone[i].bottomZone && cf2_hint_isTop( topHintEdge ) )
+ {
+ if ( ( blues->zone[i].csBottomEdge - csFuzz ) <=
+ topHintEdge->csCoord &&
+ topHintEdge->csCoord <=
+ ( blues->zone[i].csTopEdge + csFuzz ) )
+ {
+ /* top edge captured by top zone */
+
+ if ( blues->suppressOvershoot )
+ dsNew = blues->zone[i].dsFlatEdge;
+
+ else if ( ( 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 = dsNew - topHintEdge->dsCoord;
+ captured = TRUE;
+
+ break;
+ }
+ }
+ }
+
+ if ( captured )
+ {
+ /* move both edges and flag them `locked' */
+ if ( cf2_hint_isValid( bottomHintEdge ) )
+ {
+ bottomHintEdge->dsCoord += dsMove;
+ cf2_hint_lock( bottomHintEdge );
+ }
+
+ if ( cf2_hint_isValid( topHintEdge ) )
+ {
+ topHintEdge->dsCoord += dsMove;
+ cf2_hint_lock( topHintEdge );
+ }
+ }
+
+ return captured;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2blues.h b/src/3rdparty/freetype/src/cff/cf2blues.h
new file mode 100644
index 0000000000..2f38fcad8f
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2blues.h
@@ -0,0 +1,185 @@
+/***************************************************************************/
+/* */
+/* cf2blues.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 __CF2BLUES_H__
+#define __CF2BLUES_H__
+
+
+#include "cf2glue.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_floatToFixed( 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 /* __CF2BLUES_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2error.c b/src/3rdparty/freetype/src/cff/cf2error.c
new file mode 100644
index 0000000000..b5595a3d1f
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2error.c
@@ -0,0 +1,52 @@
+/***************************************************************************/
+/* */
+/* cf2error.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 "cf2ft.h"
+#include "cf2error.h"
+
+
+ FT_LOCAL_DEF( void )
+ cf2_setError( FT_Error* error,
+ FT_Error value )
+ {
+ if ( error && *error == 0 )
+ *error = value;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2error.h b/src/3rdparty/freetype/src/cff/cf2error.h
new file mode 100644
index 0000000000..6453ebcb7b
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2error.h
@@ -0,0 +1,119 @@
+/***************************************************************************/
+/* */
+/* cf2error.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 __CF2ERROR_H__
+#define __CF2ERROR_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 "cf2ft.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 perservation 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 propogate 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 /* __CF2ERROR_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2fixed.h b/src/3rdparty/freetype/src/cff/cf2fixed.h
new file mode 100644
index 0000000000..ed1452a7da
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2fixed.h
@@ -0,0 +1,95 @@
+/***************************************************************************/
+/* */
+/* cf2fixed.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 __CF2FIXED_H__
+#define __CF2FIXED_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 0x10000L
+#define CF2_FIXED_EPSILON 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)( ( (x) + 0x8000 ) & 0xFFFF0000L ) )
+#define cf2_floatToFixed( f ) \
+ ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) )
+#define cf2_fixedAbs( x ) \
+ ( (x) < 0 ? -(x) : (x) )
+#define cf2_fixedFloor( x ) \
+ ( (CF2_Fixed)( (x) & 0xFFFF0000L ) )
+#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 /* __CF2FIXED_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2font.c b/src/3rdparty/freetype/src/cff/cf2font.c
new file mode 100644
index 0000000000..83fd348f2d
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2font.c
@@ -0,0 +1,512 @@
+/***************************************************************************/
+/* */
+/* cf2font.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 "cf2ft.h"
+
+#include "cf2glue.h"
+#include "cf2font.h"
+#include "cf2error.h"
+#include "cf2intrp.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_floatToFixed( .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 */
+
+ /* 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 */
+ CFF_Decoder* decoder = font->decoder;
+
+ FT_Bool needExtraSetup = FALSE;
+
+ /* character space units */
+ CF2_Fixed boldenX = font->syntheticEmboldeningAmountX;
+ CF2_Fixed boldenY = font->syntheticEmboldeningAmountY;
+
+ CFF_SubFont subFont;
+ CF2_Fixed ppem;
+
+
+ /* 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 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 > 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 );
+ }
+ }
+
+
+ /* 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/cff/cf2font.h b/src/3rdparty/freetype/src/cff/cf2font.h
new file mode 100644
index 0000000000..d8860ce8ed
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2font.h
@@ -0,0 +1,116 @@
+/***************************************************************************/
+/* */
+/* cf2font.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 __CF2FONT_H__
+#define __CF2FONT_H__
+
+
+#include "cf2ft.h"
+#include "cf2blues.h"
+
+
+FT_BEGIN_HEADER
+
+
+#define CF2_OPERAND_STACK_SIZE 48
+#define CF2_MAX_SUBR 10 /* maximum subroutine nesting */
+
+
+ /* typedef is in `cf2glue.h' */
+ struct CF2_FontRec_
+ {
+ FT_Memory memory;
+ FT_Error error; /* shared error for this instance */
+
+ 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 */
+
+ 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 */
+ CFF_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_LOCAL( FT_Error )
+ cf2_getGlyphOutline( CF2_Font font,
+ CF2_Buffer charstring,
+ const CF2_Matrix* transform,
+ CF2_F16Dot16* glyphWidth );
+
+
+FT_END_HEADER
+
+
+#endif /* __CF2FONT_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2ft.c b/src/3rdparty/freetype/src/cff/cf2ft.c
new file mode 100644
index 0000000000..ebba4694ce
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2ft.c
@@ -0,0 +1,691 @@
+/***************************************************************************/
+/* */
+/* cf2ft.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 "cf2ft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "cf2font.h"
+#include "cf2error.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 )
+ {
+ CFF_Decoder* decoder = outline->decoder;
+
+
+ FT_ASSERT( decoder );
+
+ 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;
+
+
+ (void)memory;
+ }
+ }
+
+
+ /********************************************/
+ /* */
+ /* 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;
+ CFF_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 */
+ cff_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;
+ CFF_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 = cff_builder_start_point( builder,
+ params->pt0.x,
+ params->pt0.y );
+ if ( error )
+ {
+ if ( !*callbacks->error )
+ *callbacks->error = error;
+ return;
+ }
+ }
+
+ /* `cff_builder_add_point1' includes a check_points call for one point */
+ error = cff_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;
+ CFF_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 = cff_builder_start_point( builder,
+ params->pt0.x,
+ params->pt0.y );
+ if ( error )
+ {
+ if ( !*callbacks->error )
+ *callbacks->error = error;
+ return;
+ }
+ }
+
+ /* prepare room for 3 points: 2 off-curve, 1 on-curve */
+ error = cff_check_points( builder, 3 );
+ if ( error )
+ {
+ if ( !*callbacks->error )
+ *callbacks->error = error;
+ return;
+ }
+
+ cff_builder_add_point( builder,
+ params->pt1.x,
+ params->pt1.y, 0 );
+ cff_builder_add_point( builder,
+ params->pt2.x,
+ params->pt2.y, 0 );
+ cff_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_MEM_ZERO( outline, sizeof ( CF2_OutlineRec ) );
+
+ 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( CFF_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 = ( decoder->builder.glyph->x_scale + 32 ) / 64;
+ *y_scale = ( 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( CFF_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->builder.face );
+ FT_ASSERT( decoder->builder.face->root.units_per_EM );
+
+ return decoder->builder.face->root.units_per_EM;
+ }
+
+
+ /* Main entry point: Render one glyph. */
+ FT_LOCAL_DEF( FT_Error )
+ cf2_decoder_parse_charstrings( CFF_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_ULong charstring_len )
+ {
+ FT_Memory memory;
+ FT_Error error = FT_Err_Ok;
+ CF2_Font font;
+
+
+ FT_ASSERT( decoder && decoder->cff );
+
+ memory = decoder->builder.memory;
+
+ /* CF2 data is saved here across glyphs */
+ font = (CF2_Font)decoder->cff->cf2_instance.data;
+
+ /* on first glyph, allocate instance structure */
+ if ( decoder->cff->cf2_instance.data == NULL )
+ {
+ decoder->cff->cf2_instance.finalizer =
+ (FT_Generic_Finalizer)cf2_free_instance;
+
+ if ( FT_ALLOC( decoder->cff->cf2_instance.data,
+ sizeof ( CF2_FontRec ) ) )
+ return FT_THROW( Out_Of_Memory );
+
+ font = (CF2_Font)decoder->cff->cf2_instance.data;
+
+ font->memory = memory;
+
+ /* 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 */
+
+ CFF_Builder* builder = &decoder->builder;
+ CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face );
+
+ /* 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 );
+
+ font->renderingFlags = 0;
+ if ( hinted )
+ font->renderingFlags |= CF2_FlagsHinted;
+ if ( scaled && !driver->no_stem_darkening )
+ 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( CFF_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ return decoder->current_subfont;
+ }
+
+
+ /* get `y_ppem' from `CFF_Size' */
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_getPpemY( CFF_Decoder* decoder )
+ {
+ FT_ASSERT( decoder &&
+ decoder->builder.face &&
+ decoder->builder.face->root.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->root.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( CFF_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( CFF_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( CFF_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( CFF_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( CFF_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( CFF_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( CFF_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( CFF_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( CFF_Decoder* decoder,
+ CF2_UInt idx,
+ CF2_Buffer buf )
+ {
+ FT_ASSERT( decoder );
+
+ FT_ZERO( buf );
+
+ idx += 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( CFF_Decoder* decoder,
+ CF2_UInt code,
+ CF2_Buffer buf )
+ {
+ CF2_Int gid;
+ FT_Byte* charstring;
+ FT_ULong len;
+ FT_Error error;
+
+
+ FT_ASSERT( decoder );
+
+ FT_ZERO( buf );
+
+ gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code );
+ if ( gid < 0 )
+ return FT_THROW( Invalid_Glyph_Format );
+
+ error = cff_get_glyph_data( decoder->builder.face,
+ 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( CFF_Decoder* decoder,
+ CF2_Buffer buf )
+ {
+ FT_ASSERT( decoder );
+
+ cff_free_glyph_data( decoder->builder.face,
+ (FT_Byte**)&buf->start,
+ (FT_ULong)( buf->end - buf->start ) );
+ }
+
+
+ FT_LOCAL_DEF( CF2_Int )
+ cf2_initLocalRegionBuffer( CFF_Decoder* decoder,
+ CF2_UInt idx,
+ CF2_Buffer buf )
+ {
+ FT_ASSERT( decoder );
+
+ FT_ZERO( buf );
+
+ idx += decoder->locals_bias;
+ if ( idx >= decoder->num_locals )
+ return TRUE; /* error */
+
+ FT_ASSERT( decoder->locals );
+
+ buf->start =
+ buf->ptr = decoder->locals[idx];
+ buf->end = decoder->locals[idx + 1];
+
+ return FALSE; /* success */
+ }
+
+
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_getDefaultWidthX( CFF_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( CFF_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 )
+ {
+ CFF_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 )
+ {
+ CFF_Decoder* decoder = outline->decoder;
+
+
+ FT_ASSERT( decoder );
+
+ cff_builder_close_contour( &decoder->builder );
+
+ FT_GlyphLoader_Add( decoder->builder.loader );
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2ft.h b/src/3rdparty/freetype/src/cff/cf2ft.h
new file mode 100644
index 0000000000..731da3ca8c
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2ft.h
@@ -0,0 +1,147 @@
+/***************************************************************************/
+/* */
+/* cf2ft.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 __CF2FT_H__
+#define __CF2FT_H__
+
+
+#include "cf2types.h"
+
+
+ /* TODO: disable asserts for now */
+#define CF2_NDEBUG
+
+
+#include FT_SYSTEM_H
+
+#include "cf2glue.h"
+#include "cffgload.h" /* for CFF_Decoder */
+
+
+FT_BEGIN_HEADER
+
+
+ FT_LOCAL( FT_Error )
+ cf2_decoder_parse_charstrings( CFF_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_ULong charstring_len );
+
+ FT_LOCAL( CFF_SubFont )
+ cf2_getSubfont( CFF_Decoder* decoder );
+
+
+ FT_LOCAL( CF2_Fixed )
+ cf2_getPpemY( CFF_Decoder* decoder );
+ FT_LOCAL( CF2_Fixed )
+ cf2_getStdVW( CFF_Decoder* decoder );
+ FT_LOCAL( CF2_Fixed )
+ cf2_getStdHW( CFF_Decoder* decoder );
+
+ FT_LOCAL( void )
+ cf2_getBlueMetrics( CFF_Decoder* decoder,
+ CF2_Fixed* blueScale,
+ CF2_Fixed* blueShift,
+ CF2_Fixed* blueFuzz );
+ FT_LOCAL( void )
+ cf2_getBlueValues( CFF_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+ FT_LOCAL( void )
+ cf2_getOtherBlues( CFF_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+ FT_LOCAL( void )
+ cf2_getFamilyBlues( CFF_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+ FT_LOCAL( void )
+ cf2_getFamilyOtherBlues( CFF_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+
+ FT_LOCAL( CF2_Int )
+ cf2_getLanguageGroup( CFF_Decoder* decoder );
+
+ FT_LOCAL( CF2_Int )
+ cf2_initGlobalRegionBuffer( CFF_Decoder* decoder,
+ CF2_UInt idx,
+ CF2_Buffer buf );
+ FT_LOCAL( FT_Error )
+ cf2_getSeacComponent( CFF_Decoder* decoder,
+ CF2_UInt code,
+ CF2_Buffer buf );
+ FT_LOCAL( void )
+ cf2_freeSeacComponent( CFF_Decoder* decoder,
+ CF2_Buffer buf );
+ FT_LOCAL( CF2_Int )
+ cf2_initLocalRegionBuffer( CFF_Decoder* decoder,
+ CF2_UInt idx,
+ CF2_Buffer buf );
+
+ FT_LOCAL( CF2_Fixed )
+ cf2_getDefaultWidthX( CFF_Decoder* decoder );
+ FT_LOCAL( CF2_Fixed )
+ cf2_getNominalWidthX( CFF_Decoder* decoder );
+
+
+ /*
+ * FreeType client outline
+ *
+ * process output from the charstring interpreter
+ */
+ typedef struct CF2_OutlineRec_
+ {
+ CF2_OutlineCallbacksRec root; /* base class must be first */
+ CFF_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 /* __CF2FT_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2glue.h b/src/3rdparty/freetype/src/cff/cf2glue.h
new file mode 100644
index 0000000000..a24da39e93
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2glue.h
@@ -0,0 +1,144 @@
+/***************************************************************************/
+/* */
+/* cf2glue.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 __CF2GLUE_H__
+#define __CF2GLUE_H__
+
+
+/* common includes for other modules */
+#include "cf2error.h"
+#include "cf2fixed.h"
+#include "cf2arrst.h"
+#include "cf2read.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 /* __CF2GLUE_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2hints.c b/src/3rdparty/freetype/src/cff/cf2hints.c
new file mode 100644
index 0000000000..040d193f31
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2hints.c
@@ -0,0 +1,1847 @@
+/***************************************************************************/
+/* */
+/* cf2hints.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 "cf2ft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "cf2glue.h"
+#include "cf2font.h"
+#include "cf2hints.h"
+#include "cf2intrp.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 ) * ( ( y2 - y1 ) >> 16 ) -
+ ( y1 >> 16 ) * ( ( 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 = 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 += 2 * font->darkenY;
+
+ 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;
+ }
+
+
+ /* 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 FT_MulFix( 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 FT_MulFix( 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 >=
+ 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 <=
+ 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 <=
+ 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 += move;
+ if ( isPair )
+ 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(
+ hintmap->edge[i].dsCoord - hintmap->edge[i - 1].dsCoord,
+ 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(
+ hintmap->edge[j].dsCoord - hintmap->edge[j - 1].dsCoord,
+ 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 >=
+ hintmap->edge[j].dsCoord + hintMove->moveUp + CF2_MIN_COUNTER )
+ {
+ /* there is more room now, move edge up */
+ hintmap->edge[j].dsCoord += hintMove->moveUp;
+
+ if ( cf2_hint_isPair( &hintmap->edge[j] ) )
+ {
+ FT_ASSERT( j > 0 );
+ 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 */
+ FT_ASSERT( !isPair ||
+ topHintEdge->csCoord >= bottomHintEdge->csCoord );
+
+ /* linear search to find index value of insertion point */
+ indexInsert = 0;
+ for ( ; indexInsert < hintmap->count; indexInsert++ )
+ {
+ if ( hintmap->edge[indexInsert].csCoord >= firstHintEdge->csCoord )
+ break;
+ }
+
+ /*
+ * 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,
+ ( secondHintEdge->csCoord +
+ firstHintEdge->csCoord ) / 2 );
+ CF2_Fixed halfWidth = FT_MulFix(
+ ( secondHintEdge->csCoord -
+ firstHintEdge->csCoord ) / 2,
+ hintmap->scale );
+
+
+ firstHintEdge->dsCoord = midpoint - halfWidth;
+ secondHintEdge->dsCoord = 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_Int iSrc = hintmap->count - 1;
+ CF2_Int iDst = isPair ? hintmap->count + 1 : hintmap->count;
+
+ CF2_Int 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;
+
+ if ( isPair )
+ {
+ /* insert second edge */
+ hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */
+ hintmap->count += 1;
+ }
+ }
+
+ 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 ) )
+ 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;
+ }
+ }
+
+ /*
+ * 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 );
+
+ /* 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_floatToFixed( 0.1f );
+
+ 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 = FT_MulFix( glyphpath->scaleX, x ) +
+ FT_MulFix( glyphpath->scaleC, y );
+ pt.y = cf2_hintmap_map( hintmap, y );
+
+ ppt->x = FT_MulFix( glyphpath->font->outerTransform.a, pt.x ) +
+ FT_MulFix( glyphpath->font->outerTransform.c, pt.y ) +
+ glyphpath->fractionalTranslation.x;
+ ppt->y = FT_MulFix( glyphpath->font->outerTransform.b, pt.x ) +
+ 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
+ * http://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( u2->x - u1->x );
+ u.y = CF2_CS_SCALE( u2->y - u1->y );
+ v.x = CF2_CS_SCALE( v2->x - v1->x );
+ v.y = CF2_CS_SCALE( v2->y - v1->y );
+ w.x = CF2_CS_SCALE( v1->x - u1->x );
+ w.y = CF2_CS_SCALE( 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 = u1->x + FT_MulFix( s, u2->x - u1->x );
+ intersection->y = u1->y + FT_MulFix( s, 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( intersection->x - u1->x ) < glyphpath->snapThreshold )
+ intersection->x = u1->x;
+ if ( u1->y == u2->y &&
+ cf2_fixedAbs( intersection->y - u1->y ) < glyphpath->snapThreshold )
+ intersection->y = u1->y;
+
+ if ( v1->x == v2->x &&
+ cf2_fixedAbs( intersection->x - v1->x ) < glyphpath->snapThreshold )
+ intersection->x = v1->x;
+ if ( v1->y == v2->y &&
+ cf2_fixedAbs( 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 - ( u2->x + v1->x ) / 2 ) >
+ glyphpath->miterLimit ||
+ cf2_fixedAbs( intersection->y - ( 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 = x2 - x1;
+ CF2_Fixed dy = y2 - y1;
+
+
+ /* note: negative offsets don't work here; negate deltas to change */
+ /* quadrants, below */
+ if ( glyphpath->font->reverseWinding )
+ {
+ dx = -dx;
+ dy = -dy;
+ }
+
+ *x = *y = 0;
+
+ if ( !glyphpath->darken )
+ return;
+
+ /* add momentum for this path element */
+ 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 > 2 * dy )
+ {
+ /* +x */
+ *x = 0;
+ *y = 0;
+ }
+ else if ( dy > 2 * dx )
+ {
+ /* +y */
+ *x = glyphpath->xOffset;
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* +x +y */
+ *x = FT_MulFix( cf2_floatToFixed( 0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ),
+ glyphpath->yOffset );
+ }
+ }
+ else
+ {
+ /* fourth quadrant, +x -y */
+
+ if ( dx > -2 * dy )
+ {
+ /* +x */
+ *x = 0;
+ *y = 0;
+ }
+ else if ( -dy > 2 * dx )
+ {
+ /* -y */
+ *x = -glyphpath->xOffset;
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* +x -y */
+ *x = FT_MulFix( cf2_floatToFixed( -0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ),
+ glyphpath->yOffset );
+ }
+ }
+ }
+ else
+ {
+ if ( dy >= 0 )
+ {
+ /* second quadrant, -x +y */
+
+ if ( -dx > 2 * dy )
+ {
+ /* -x */
+ *x = 0;
+ *y = 2 * glyphpath->yOffset;
+ }
+ else if ( dy > -2 * dx )
+ {
+ /* +y */
+ *x = glyphpath->xOffset;
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* -x +y */
+ *x = FT_MulFix( cf2_floatToFixed( 0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_floatToFixed( 1.0 + 0.7 ),
+ glyphpath->yOffset );
+ }
+ }
+ else
+ {
+ /* third quadrant, -x -y */
+
+ if ( -dx > -2 * dy )
+ {
+ /* -x */
+ *x = 0;
+ *y = 2 * glyphpath->yOffset;
+ }
+ else if ( -dy > -2 * dx )
+ {
+ /* -y */
+ *x = -glyphpath->xOffset;
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* -x -y */
+ *x = FT_MulFix( cf2_floatToFixed( -0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_floatToFixed( 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 = glyphpath->currentCS.x + xOffset;
+ P0.y = glyphpath->currentCS.y + yOffset;
+ P1.x = x + xOffset;
+ P1.y = 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 +=
+ cf2_getWindingMomentum( x1, y1, x2, y2 );
+
+ /* construct offset points */
+ P0.x = glyphpath->currentCS.x + xOffset1;
+ P0.y = glyphpath->currentCS.y + yOffset1;
+ P1.x = x1 + xOffset1;
+ P1.y = y1 + yOffset1;
+ /* note: preserve angle of final segment by using offset3 at both ends */
+ P2.x = x2 + xOffset3;
+ P2.y = y2 + yOffset3;
+ P3.x = x3 + xOffset3;
+ P3.y = 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/cff/cf2hints.h b/src/3rdparty/freetype/src/cff/cf2hints.h
new file mode 100644
index 0000000000..f25d91bf89
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2hints.h
@@ -0,0 +1,289 @@
+/***************************************************************************/
+/* */
+/* cf2hints.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 __CF2HINTS_H__
+#define __CF2HINTS_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/horzizontal 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 /* __CF2HINTS_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2intrp.c b/src/3rdparty/freetype/src/cff/cf2intrp.c
new file mode 100644
index 0000000000..a26960669f
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2intrp.c
@@ -0,0 +1,1545 @@
+/***************************************************************************/
+/* */
+/* cf2intrp.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 "cf2ft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "cf2glue.h"
+#include "cf2font.h"
+#include "cf2stack.h"
+#include "cf2hints.h"
+
+#include "cf2error.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_cf2interp
+
+
+ /* some operators are not implemented yet */
+#define CF2_FIXME FT_TRACE4(( "cf2_interpT2CharString:" \
+ " operator not implemented yet\n" ))
+
+
+
+ FT_LOCAL_DEF( void )
+ cf2_hintmask_init( CF2_HintMask hintmask,
+ FT_Error* error )
+ {
+ 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_cmdRESERVED_9, /* 9 */
+ cf2_cmdCALLSUBR, /* 10 */
+ cf2_cmdRETURN, /* 11 */
+ cf2_cmdESC, /* 12 */
+ cf2_cmdRESERVED_13, /* 13 */
+ cf2_cmdENDCHAR, /* 14 */
+ cf2_cmdRESERVED_15, /* 15 */
+ cf2_cmdRESERVED_16, /* 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_escRESERVED_1, /* 1 */
+ cf2_escRESERVED_2, /* 2 */
+ cf2_escAND, /* 3 */
+ cf2_escOR, /* 4 */
+ cf2_escNOT, /* 5 */
+ cf2_escRESERVED_6, /* 6 */
+ cf2_escRESERVED_7, /* 7 */
+ 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_escRESERVED_16, /* 16 */
+ cf2_escRESERVED_17, /* 17 */
+ 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_escRESERVED_33, /* 33 */
+ cf2_escHFLEX, /* 34 */
+ cf2_escFLEX, /* 35 */
+ cf2_escHFLEX1, /* 36 */
+ cf2_escFLEX1 /* 37 */
+ };
+
+
+ /* `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 ( hasWidthArg && ! *haveWidth )
+ *width = 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 += cf2_stack_getReal( opStack, i );
+ stemhint.max =
+ 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 index;
+ FT_Bool isHFlex;
+ CF2_Int top, i, j;
+
+
+ vals[0] = *curX;
+ vals[1] = *curY;
+ index = 0;
+ isHFlex = readFromStack[9] == FALSE;
+ top = isHFlex ? 9 : 10;
+
+ for ( i = 0; i < top; i++ )
+ {
+ vals[i + 2] = vals[i];
+ if ( readFromStack[i] )
+ vals[i + 2] += cf2_stack_getReal( opStack, index++ );
+ }
+
+ if ( isHFlex )
+ vals[9 + 2] = *curY;
+
+ if ( doConditionalLastRead )
+ {
+ FT_Bool lastIsX = (FT_Bool)( cf2_fixedAbs( vals[10] - *curX ) >
+ cf2_fixedAbs( vals[11] - *curY ) );
+ CF2_Fixed lastVal = cf2_stack_getReal( opStack, index );
+
+
+ if ( lastIsX )
+ {
+ vals[12] = vals[10] + lastVal;
+ vals[13] = *curY;
+ }
+ else
+ {
+ vals[12] = *curX;
+ vals[13] = vals[11] + lastVal;
+ }
+ }
+ else
+ {
+ if ( readFromStack[10] )
+ vals[12] = vals[10] + cf2_stack_getReal( opStack, index++ );
+ else
+ vals[12] = *curX;
+
+ if ( readFromStack[11] )
+ vals[13] = vals[11] + cf2_stack_getReal( opStack, index );
+ 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];
+ }
+
+
+ /*
+ * `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 */
+ CFF_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 );
+
+ /* save this for hinting seac accents */
+ CF2_Fixed hintOriginY = curY;
+
+ CF2_Stack opStack = NULL;
+ FT_Byte op1; /* first opcode byte */
+
+ /* 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;
+
+
+ /* 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.
+ *
+ */
+ haveWidth = 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 */
+ opStack = cf2_stack_init( memory, error );
+ 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 ( cf2_buf_isEnd( charstring ) )
+ {
+ /* If we've reached the end of the charstring, simulate a */
+ /* cf2_cmdRETURN or cf2_cmdENDCHAR. */
+ 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 );
+
+ /* 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_9:
+ case cf2_cmdRESERVED_13:
+ case cf2_cmdRESERVED_15:
+ case cf2_cmdRESERVED_16:
+ case cf2_cmdRESERVED_17:
+ /* we may get here if we have a prior error */
+ FT_TRACE4(( " unknown op (%d)\n", op1 ));
+ break;
+
+ case cf2_cmdHSTEMHM:
+ case cf2_cmdHSTEM:
+ FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" ));
+
+ /* never add hints after the mask is computed */
+ if ( cf2_hintmask_isValid( &hintMask ) )
+ {
+ FT_TRACE4(( "cf2_interpT2CharString:"
+ " invalid horizontal hint mask\n" ));
+ break;
+ }
+
+ cf2_doStems( font,
+ opStack,
+ &hStemHintArray,
+ width,
+ &haveWidth,
+ 0 );
+
+ if ( font->decoder->width_only )
+ goto exit;
+
+ break;
+
+ case cf2_cmdVSTEMHM:
+ case cf2_cmdVSTEM:
+ FT_TRACE4(( op1 == cf2_cmdVSTEMHM ? " vstemhm\n" : " vstem\n" ));
+
+ /* never add hints after the mask is computed */
+ if ( cf2_hintmask_isValid( &hintMask ) )
+ {
+ FT_TRACE4(( "cf2_interpT2CharString:"
+ " invalid vertical hint mask\n" ));
+ break;
+ }
+
+ cf2_doStems( font,
+ opStack,
+ &vStemHintArray,
+ width,
+ &haveWidth,
+ 0 );
+
+ if ( font->decoder->width_only )
+ goto exit;
+
+ break;
+
+ case cf2_cmdVMOVETO:
+ FT_TRACE4(( " vmoveto\n" ));
+
+ if ( cf2_stack_count( opStack ) > 1 && !haveWidth )
+ *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX;
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( font->decoder->width_only )
+ goto exit;
+
+ curY += cf2_stack_popFixed( opStack );
+
+ cf2_glyphpath_moveTo( &glyphPath, curX, curY );
+
+ break;
+
+ case cf2_cmdRLINETO:
+ {
+ CF2_UInt index;
+ CF2_UInt count = cf2_stack_count( opStack );
+
+
+ FT_TRACE4(( " rlineto\n" ));
+
+ for ( index = 0; index < count; index += 2 )
+ {
+ curX += cf2_stack_getReal( opStack, index + 0 );
+ curY += cf2_stack_getReal( opStack, index + 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 index;
+ CF2_UInt count = cf2_stack_count( opStack );
+
+ FT_Bool isX = op1 == cf2_cmdHLINETO;
+
+
+ FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" ));
+
+ for ( index = 0; index < count; index++ )
+ {
+ CF2_Fixed v = cf2_stack_getReal( opStack, index );
+
+
+ if ( isX )
+ curX += v;
+ else
+ 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 index = 0;
+
+
+ FT_TRACE4(( op1 == cf2_cmdRCURVELINE ? " rcurveline\n"
+ : " rrcurveto\n" ));
+
+ while ( index + 6 <= count )
+ {
+ CF2_Fixed x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
+ CF2_Fixed y1 = cf2_stack_getReal( opStack, index + 1 ) + curY;
+ CF2_Fixed x2 = cf2_stack_getReal( opStack, index + 2 ) + x1;
+ CF2_Fixed y2 = cf2_stack_getReal( opStack, index + 3 ) + y1;
+ CF2_Fixed x3 = cf2_stack_getReal( opStack, index + 4 ) + x2;
+ CF2_Fixed y3 = cf2_stack_getReal( opStack, index + 5 ) + y2;
+
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ index += 6;
+ }
+
+ if ( op1 == cf2_cmdRCURVELINE )
+ {
+ curX += cf2_stack_getReal( opStack, index + 0 );
+ curY += cf2_stack_getReal( opStack, index + 1 );
+
+ cf2_glyphpath_lineTo( &glyphPath, curX, curY );
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdCALLGSUBR:
+ case cf2_cmdCALLSUBR:
+ {
+ CF2_UInt subrIndex;
+
+
+ FT_TRACE4(( op1 == cf2_cmdCALLGSUBR ? " callgsubr"
+ : " callsubr" ));
+
+ if ( charstringIndex > CF2_MAX_SUBR )
+ {
+ /* 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,
+ charstringIndex + 1 );
+
+ /* set up the new CFF region and pointer */
+ subrIndex = cf2_stack_popInt( opStack );
+
+ switch ( op1 )
+ {
+ case cf2_cmdCALLGSUBR:
+ FT_TRACE4(( "(%d)\n", subrIndex + decoder->globals_bias ));
+
+ if ( cf2_initGlobalRegionBuffer( decoder,
+ subrIndex,
+ charstring ) )
+ {
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* subroutine lookup or stream error */
+ }
+ break;
+
+ default:
+ /* cf2_cmdCALLSUBR */
+ FT_TRACE4(( "(%d)\n", subrIndex + decoder->locals_bias ));
+
+ if ( cf2_initLocalRegionBuffer( decoder,
+ subrIndex,
+ 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\n" ));
+
+ 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,
+ --charstringIndex );
+ continue; /* do not clear the stack */
+
+ case cf2_cmdESC:
+ {
+ FT_Byte op2 = (FT_Byte)cf2_buf_readByte( charstring );
+
+
+ switch ( op2 )
+ {
+ case cf2_escDOTSECTION:
+ /* something about `flip type of locking' -- ignore it */
+ FT_TRACE4(( " dotsection\n" ));
+
+ break;
+
+ /* TODO: should these operators be supported? */
+ case cf2_escAND: /* in spec */
+ FT_TRACE4(( " and\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escOR: /* in spec */
+ FT_TRACE4(( " or\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escNOT: /* in spec */
+ FT_TRACE4(( " not\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escABS: /* in spec */
+ FT_TRACE4(( " abs\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escADD: /* in spec */
+ FT_TRACE4(( " add\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escSUB: /* in spec */
+ FT_TRACE4(( " sub\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escDIV: /* in spec */
+ FT_TRACE4(( " div\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escNEG: /* in spec */
+ FT_TRACE4(( " neg\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escEQ: /* in spec */
+ FT_TRACE4(( " eq\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escDROP: /* in spec */
+ FT_TRACE4(( " drop\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escPUT: /* in spec */
+ FT_TRACE4(( " put\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escGET: /* in spec */
+ FT_TRACE4(( " get\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escIFELSE: /* in spec */
+ FT_TRACE4(( " ifelse\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escRANDOM: /* in spec */
+ FT_TRACE4(( " random\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escMUL: /* in spec */
+ FT_TRACE4(( " mul\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escSQRT: /* in spec */
+ FT_TRACE4(( " sqrt\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escDUP: /* in spec */
+ FT_TRACE4(( " dup\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escEXCH: /* in spec */
+ FT_TRACE4(( " exch\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escINDEX: /* in spec */
+ FT_TRACE4(( " index\n" ));
+
+ CF2_FIXME;
+ break;
+
+ case cf2_escROLL: /* in spec */
+ FT_TRACE4(( " roll\n" ));
+
+ CF2_FIXME;
+ break;
+
+ 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;
+
+ case cf2_escRESERVED_1:
+ case cf2_escRESERVED_2:
+ case cf2_escRESERVED_6:
+ case cf2_escRESERVED_7:
+ case cf2_escRESERVED_8:
+ case cf2_escRESERVED_13:
+ case cf2_escRESERVED_16:
+ case cf2_escRESERVED_17:
+ case cf2_escRESERVED_19:
+ case cf2_escRESERVED_25:
+ case cf2_escRESERVED_31:
+ case cf2_escRESERVED_32:
+ case cf2_escRESERVED_33:
+ default:
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+
+ }; /* end of switch statement checking `op2' */
+
+ } /* case cf2_cmdESC */
+ break;
+
+ case cf2_cmdENDCHAR:
+ FT_TRACE4(( " endchar\n" ));
+
+ if ( cf2_stack_count( opStack ) == 1 ||
+ cf2_stack_count( opStack ) == 5 )
+ {
+ if ( !haveWidth )
+ *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX;
+ }
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( font->decoder->width_only )
+ goto exit;
+
+ /* close path if still open */
+ cf2_glyphpath_closeOpenPath( &glyphPath );
+
+ if ( cf2_stack_count( opStack ) > 1 )
+ {
+ /* must be either 4 or 5 -- */
+ /* this is a (deprecated) implied `seac' operator */
+
+ CF2_UInt achar;
+ CF2_UInt 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 ( font->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 ( cf2_stack_count( opStack ) > 2 && !haveWidth )
+ *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX;
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( font->decoder->width_only )
+ goto exit;
+
+ curY += cf2_stack_popFixed( opStack );
+ curX += cf2_stack_popFixed( opStack );
+
+ cf2_glyphpath_moveTo( &glyphPath, curX, curY );
+
+ break;
+
+ case cf2_cmdHMOVETO:
+ FT_TRACE4(( " hmoveto\n" ));
+
+ if ( cf2_stack_count( opStack ) > 1 && !haveWidth )
+ *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX;
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( font->decoder->width_only )
+ goto exit;
+
+ curX += cf2_stack_popFixed( opStack );
+
+ cf2_glyphpath_moveTo( &glyphPath, curX, curY );
+
+ break;
+
+ case cf2_cmdRLINECURVE:
+ {
+ CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt index = 0;
+
+
+ FT_TRACE4(( " rlinecurve\n" ));
+
+ while ( index + 6 < count )
+ {
+ curX += cf2_stack_getReal( opStack, index + 0 );
+ curY += cf2_stack_getReal( opStack, index + 1 );
+
+ cf2_glyphpath_lineTo( &glyphPath, curX, curY );
+ index += 2;
+ }
+
+ while ( index < count )
+ {
+ CF2_Fixed x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
+ CF2_Fixed y1 = cf2_stack_getReal( opStack, index + 1 ) + curY;
+ CF2_Fixed x2 = cf2_stack_getReal( opStack, index + 2 ) + x1;
+ CF2_Fixed y2 = cf2_stack_getReal( opStack, index + 3 ) + y1;
+ CF2_Fixed x3 = cf2_stack_getReal( opStack, index + 4 ) + x2;
+ CF2_Fixed y3 = cf2_stack_getReal( opStack, index + 5 ) + y2;
+
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ index += 6;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdVVCURVETO:
+ {
+ CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt index = 0;
+
+
+ FT_TRACE4(( " vvcurveto\n" ));
+
+ while ( index < count )
+ {
+ CF2_Fixed x1, y1, x2, y2, x3, y3;
+
+
+ if ( ( count - index ) & 1 )
+ {
+ x1 = cf2_stack_getReal( opStack, index ) + curX;
+
+ ++index;
+ }
+ else
+ x1 = curX;
+
+ y1 = cf2_stack_getReal( opStack, index + 0 ) + curY;
+ x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
+ x3 = x2;
+ y3 = cf2_stack_getReal( opStack, index + 3 ) + y2;
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ index += 4;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdHHCURVETO:
+ {
+ CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt index = 0;
+
+
+ FT_TRACE4(( " hhcurveto\n" ));
+
+ while ( index < count )
+ {
+ CF2_Fixed x1, y1, x2, y2, x3, y3;
+
+
+ if ( ( count - index ) & 1 )
+ {
+ y1 = cf2_stack_getReal( opStack, index ) + curY;
+
+ ++index;
+ }
+ else
+ y1 = curY;
+
+ x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
+ x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
+ x3 = cf2_stack_getReal( opStack, index + 3 ) + x2;
+ y3 = y2;
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ index += 4;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdVHCURVETO:
+ case cf2_cmdHVCURVETO:
+ {
+ CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt index = 0;
+
+ FT_Bool alternate = op1 == cf2_cmdHVCURVETO;
+
+
+ FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" ));
+
+ while ( index < count )
+ {
+ CF2_Fixed x1, x2, x3, y1, y2, y3;
+
+
+ if ( alternate )
+ {
+ x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
+ y1 = curY;
+ x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
+ y3 = cf2_stack_getReal( opStack, index + 3 ) + y2;
+
+ if ( count - index == 5 )
+ {
+ x3 = cf2_stack_getReal( opStack, index + 4 ) + x2;
+
+ ++index;
+ }
+ else
+ x3 = x2;
+
+ alternate = FALSE;
+ }
+ else
+ {
+ x1 = curX;
+ y1 = cf2_stack_getReal( opStack, index + 0 ) + curY;
+ x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
+ x3 = cf2_stack_getReal( opStack, index + 3 ) + x2;
+
+ if ( count - index == 5 )
+ {
+ y3 = cf2_stack_getReal( opStack, index + 4 ) + y2;
+
+ ++index;
+ }
+ else
+ y3 = y2;
+
+ alternate = TRUE;
+ }
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ index += 4;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdEXTENDEDNMBR:
+ {
+ CF2_Int v;
+
+
+ v = (FT_Short)( ( cf2_buf_readByte( charstring ) << 8 ) |
+ cf2_buf_readByte( charstring ) );
+
+ 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;
+
+
+ v = (CF2_Fixed)
+ ( ( (FT_UInt32)cf2_buf_readByte( charstring ) << 24 ) |
+ ( (FT_UInt32)cf2_buf_readByte( charstring ) << 16 ) |
+ ( (FT_UInt32)cf2_buf_readByte( charstring ) << 8 ) |
+ (FT_UInt32)cf2_buf_readByte( charstring ) );
+
+ FT_TRACE4(( " %.2f", 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 );
+
+ /* 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/cff/cf2intrp.h b/src/3rdparty/freetype/src/cff/cf2intrp.h
new file mode 100644
index 0000000000..b5d8947838
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2intrp.h
@@ -0,0 +1,83 @@
+/***************************************************************************/
+/* */
+/* cf2font.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 __CF2INTRP_H__
+#define __CF2INTRP_H__
+
+
+#include "cf2ft.h"
+#include "cf2hints.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 /* __CF2INTRP_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2read.c b/src/3rdparty/freetype/src/cff/cf2read.c
new file mode 100644
index 0000000000..2b429e3eeb
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2read.c
@@ -0,0 +1,112 @@
+/***************************************************************************/
+/* */
+/* cf2read.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 "cf2ft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "cf2glue.h"
+
+#include "cf2error.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/cff/cf2read.h b/src/3rdparty/freetype/src/cff/cf2read.h
new file mode 100644
index 0000000000..7ef7c8c149
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2read.h
@@ -0,0 +1,68 @@
+/***************************************************************************/
+/* */
+/* cf2read.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 __CF2READ_H__
+#define __CF2READ_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 /* __CF2READ_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2stack.c b/src/3rdparty/freetype/src/cff/cf2stack.c
new file mode 100644
index 0000000000..8332b5d91a
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2stack.c
@@ -0,0 +1,205 @@
+/***************************************************************************/
+/* */
+/* cf2stack.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 "cf2ft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "cf2glue.h"
+#include "cf2font.h"
+#include "cf2stack.h"
+
+#include "cf2error.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_Error error = FT_Err_Ok; /* for FT_QNEW */
+
+ CF2_Stack stack = NULL;
+
+
+ if ( !FT_QNEW( stack ) )
+ {
+ /* initialize the structure; FT_QNEW zeroes it */
+ stack->memory = memory;
+ stack->error = e;
+ stack->top = &stack->buffer[0]; /* empty stack */
+ }
+
+ return stack;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_stack_free( CF2_Stack stack )
+ {
+ if ( stack )
+ {
+ FT_Memory memory = stack->memory;
+
+
+ /* 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[0] );
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_stack_pushInt( CF2_Stack stack,
+ CF2_Int val )
+ {
+ if ( stack->top == &stack->buffer[CF2_OPERAND_STACK_SIZE] )
+ {
+ 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[CF2_OPERAND_STACK_SIZE] )
+ {
+ 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[0] )
+ {
+ 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[0] )
+ {
+ 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 ) <= CF2_OPERAND_STACK_SIZE );
+
+ 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;
+ }
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_stack_clear( CF2_Stack stack )
+ {
+ stack->top = &stack->buffer[0];
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2stack.h b/src/3rdparty/freetype/src/cff/cf2stack.h
new file mode 100644
index 0000000000..7d6d1961fe
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2stack.h
@@ -0,0 +1,106 @@
+/***************************************************************************/
+/* */
+/* cf2stack.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 __CF2STACK_H__
+#define __CF2STACK_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_OPERAND_STACK_SIZE];
+ CF2_StackNumber* top;
+
+ } CF2_StackRec, *CF2_Stack;
+
+
+ FT_LOCAL( CF2_Stack )
+ cf2_stack_init( FT_Memory memory,
+ FT_Error* error );
+ 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_clear( CF2_Stack stack );
+
+
+FT_END_HEADER
+
+
+#endif /* __CF2STACK_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cf2types.h b/src/3rdparty/freetype/src/cff/cf2types.h
new file mode 100644
index 0000000000..ac6a02266e
--- /dev/null
+++ b/src/3rdparty/freetype/src/cff/cf2types.h
@@ -0,0 +1,78 @@
+/***************************************************************************/
+/* */
+/* cf2types.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 __CF2TYPES_H__
+#define __CF2TYPES_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 /* __CF2TYPES_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/cff/cff.c b/src/3rdparty/freetype/src/cff/cff.c
index fccfd442f5..c3840b5838 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-2001, 2002 by */
+/* Copyright 1996-2001, 2002, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,6 +19,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
+
#include "cffpic.c"
#include "cffdrivr.c"
#include "cffparse.c"
@@ -27,4 +28,14 @@
#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 46d603e3a8..52248b2b9a 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, 2003, 2004, 2005, 2006, 2007 by */
+/* Copyright 2002-2007, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,6 +16,8 @@
/***************************************************************************/
+#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include "cffcmap.h"
#include "cffload.h"
@@ -31,12 +33,15 @@
/*************************************************************************/
FT_CALLBACK_DEF( FT_Error )
- cff_cmap_encoding_init( CFF_CMapStd cmap )
+ cff_cmap_encoding_init( CFF_CMapStd cmap,
+ FT_Pointer pointer )
{
TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
CFF_Font cff = (CFF_Font)face->extra.data;
CFF_Encoding encoding = &cff->encoding;
+ FT_UNUSED( pointer );
+
cmap->gids = encoding->codes;
@@ -120,32 +125,21 @@
/*************************************************************************/
FT_CALLBACK_DEF( const char* )
- cff_sid_to_glyph_name( TT_Face face,
- FT_UInt idx )
+ cff_sid_to_glyph_name( TT_Face face,
+ FT_UInt idx )
{
- CFF_Font cff = (CFF_Font)face->extra.data;
- CFF_Charset charset = &cff->charset;
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
- FT_UInt sid = charset->sids[idx];
+ CFF_Font cff = (CFF_Font)face->extra.data;
+ CFF_Charset charset = &cff->charset;
+ FT_UInt sid = charset->sids[idx];
- return cff_index_get_sid_string( &cff->string_index, sid, psnames );
- }
-
-
- FT_CALLBACK_DEF( void )
- cff_sid_free_glyph_name( TT_Face face,
- const char* gname )
- {
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( gname );
+ return cff_index_get_sid_string( cff, sid );
}
FT_CALLBACK_DEF( FT_Error )
- cff_cmap_unicode_init( PS_Unicodes unicodes )
+ cff_cmap_unicode_init( PS_Unicodes unicodes,
+ FT_Pointer pointer )
{
TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -153,16 +147,19 @@
CFF_Charset charset = &cff->charset;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
+ FT_UNUSED( pointer );
+
/* can't build Unicode map for CID-keyed font */
+ /* because we don't know glyph names. */
if ( !charset->sids )
- return CFF_Err_Invalid_Argument;
+ return FT_THROW( No_Unicode_Glyph_Name );
return psnames->unicodes_init( memory,
unicodes,
cff->num_glyphs,
(PS_GetGlyphNameFunc)&cff_sid_to_glyph_name,
- (PS_FreeGlyphNameFunc)&cff_sid_free_glyph_name,
+ (PS_FreeGlyphNameFunc)NULL,
(FT_Pointer)face );
}
diff --git a/src/3rdparty/freetype/src/cff/cffdrivr.c b/src/3rdparty/freetype/src/cff/cffdrivr.c
index dad0b65d8b..3e8898e343 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,7 +22,6 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_SERVICE_CID_H
-#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
@@ -38,6 +37,8 @@
#include FT_SERVICE_XFREE86_NAME_H
#include FT_SERVICE_GLYPH_DICT_H
+#include FT_SERVICE_PROPERTIES_H
+#include FT_CFF_DRIVER_H
/*************************************************************************/
@@ -116,7 +117,7 @@
if ( sfnt )
kerning->x = sfnt->get_kerning( face, left_glyph, right_glyph );
- return CFF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -126,7 +127,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* Load_Glyph */
+ /* cff_glyph_load */
/* */
/* <Description> */
/* A driver method used to load a glyph within a given glyph slot. */
@@ -150,10 +151,10 @@
/* FreeType error code. 0 means success. */
/* */
FT_CALLBACK_DEF( FT_Error )
- Load_Glyph( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */
- FT_Size cffsize, /* CFF_Size */
- FT_UInt glyph_index,
- FT_Int32 load_flags )
+ cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */
+ FT_Size cffsize, /* CFF_Size */
+ FT_UInt glyph_index,
+ FT_Int32 load_flags )
{
FT_Error error;
CFF_GlyphSlot slot = (CFF_GlyphSlot)cffslot;
@@ -161,7 +162,9 @@
if ( !slot )
- return CFF_Err_Invalid_Slot_Handle;
+ return FT_THROW( Invalid_Slot_Handle );
+
+ FT_TRACE1(( "cff_glyph_load: glyph index %d\n", glyph_index ));
/* check whether we want a scaled outline or bitmap */
if ( !size )
@@ -175,7 +178,7 @@
{
/* these two objects must have the same parent */
if ( cffsize->face != cffslot->face )
- return CFF_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
}
/* now load the glyph outline if necessary */
@@ -196,7 +199,7 @@
FT_Fixed* advances )
{
FT_UInt nn;
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_GlyphSlot slot = face->glyph;
@@ -204,7 +207,7 @@
for ( nn = 0; nn < count; nn++ )
{
- error = Load_Glyph( slot, face->size, start + nn, flags );
+ error = cff_glyph_load( slot, face->size, start + nn, flags );
if ( error )
break;
@@ -228,22 +231,19 @@
FT_Pointer buffer,
FT_UInt buffer_max )
{
- CFF_Font font = (CFF_Font)face->extra.data;
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_String* gname;
- FT_UShort sid;
- FT_Service_PsCMaps psnames;
- FT_Error error;
+ CFF_Font font = (CFF_Font)face->extra.data;
+ FT_String* gname;
+ FT_UShort sid;
+ FT_Error error;
- FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
- if ( !psnames )
+ if ( !font->psnames )
{
FT_ERROR(( "cff_get_glyph_name:"
" cannot get glyph name from CFF & CEF fonts\n"
" "
" without the `PSNames' module\n" ));
- error = CFF_Err_Unknown_File_Format;
+ error = FT_THROW( Missing_Module );
goto Exit;
}
@@ -251,13 +251,12 @@
sid = font->charset.sids[glyph_index];
/* now, lookup the name itself */
- gname = cff_index_get_sid_string( &font->string_index, sid, psnames );
+ gname = cff_index_get_sid_string( font, sid );
if ( gname )
FT_STRCPYN( buffer, gname, buffer_max );
- FT_FREE( gname );
- error = CFF_Err_Ok;
+ error = FT_Err_Ok;
Exit:
return error;
@@ -271,11 +270,9 @@
CFF_Font cff;
CFF_Charset charset;
FT_Service_PsCMaps psnames;
- FT_Memory memory = FT_FACE_MEMORY( face );
FT_String* name;
FT_UShort sid;
FT_UInt i;
- FT_Int result;
cff = (CFF_FontRec *)face->extra.data;
@@ -290,19 +287,14 @@
sid = charset->sids[i];
if ( sid > 390 )
- name = cff_index_get_name( &cff->string_index, sid - 391 );
+ name = cff_index_get_string( cff, sid - 391 );
else
name = (FT_String *)psnames->adobe_std_strings( sid );
if ( !name )
continue;
- result = ft_strcmp( glyph_name, name );
-
- if ( sid > 390 )
- FT_FREE( name );
-
- if ( !result )
+ if ( !ft_strcmp( glyph_name, name ) )
return i;
}
@@ -310,7 +302,8 @@
}
- FT_DEFINE_SERVICE_GLYPHDICTREC(cff_service_glyph_dict,
+ FT_DEFINE_SERVICE_GLYPHDICTREC(
+ cff_service_glyph_dict,
(FT_GlyphDict_GetNameFunc) cff_get_glyph_name,
(FT_GlyphDict_NameIndexFunc)cff_get_name_index
)
@@ -338,30 +331,24 @@
if ( cff && cff->font_info == NULL )
{
- CFF_FontRecDict dict = &cff->top_font.font_dict;
- PS_FontInfoRec *font_info;
- FT_Memory memory = face->root.memory;
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
+ CFF_FontRecDict dict = &cff->top_font.font_dict;
+ PS_FontInfoRec *font_info = NULL;
+ FT_Memory memory = face->root.memory;
if ( FT_ALLOC( font_info, sizeof ( *font_info ) ) )
goto Fail;
- font_info->version = cff_index_get_sid_string( &cff->string_index,
- dict->version,
- psnames );
- font_info->notice = cff_index_get_sid_string( &cff->string_index,
- dict->notice,
- psnames );
- font_info->full_name = cff_index_get_sid_string( &cff->string_index,
- dict->full_name,
- psnames );
- font_info->family_name = cff_index_get_sid_string( &cff->string_index,
- dict->family_name,
- psnames );
- font_info->weight = cff_index_get_sid_string( &cff->string_index,
- dict->weight,
- psnames );
+ font_info->version = cff_index_get_sid_string( cff,
+ dict->version );
+ font_info->notice = cff_index_get_sid_string( cff,
+ dict->notice );
+ font_info->full_name = cff_index_get_sid_string( cff,
+ dict->full_name );
+ font_info->family_name = cff_index_get_sid_string( cff,
+ dict->family_name );
+ font_info->weight = cff_index_get_sid_string( cff,
+ dict->weight );
font_info->italic_angle = dict->italic_angle;
font_info->is_fixed_pitch = dict->is_fixed_pitch;
font_info->underline_position = (FT_Short)dict->underline_position;
@@ -378,11 +365,13 @@
}
- FT_DEFINE_SERVICE_PSINFOREC(cff_service_ps_info,
+ 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_GetFontPrivateFunc)NULL, /* unsupported with CFF fonts */
+ (PS_GetFontValueFunc) NULL /* not implemented */
)
@@ -401,7 +390,8 @@
}
- FT_DEFINE_SERVICE_PSFONTNAMEREC(cff_service_ps_name,
+ FT_DEFINE_SERVICE_PSFONTNAMEREC(
+ cff_service_ps_name,
(FT_PsName_GetFunc)cff_get_ps_name
)
@@ -421,16 +411,17 @@
TT_CMapInfo *cmap_info )
{
FT_CMap cmap = FT_CMAP( charmap );
- FT_Error error = CFF_Err_Ok;
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Library library = FT_FACE_LIBRARY( face );
+ FT_Error error = FT_Err_Ok;
+
+ FT_Face face = FT_CMAP_FACE( cmap );
+ FT_Library library = FT_FACE_LIBRARY( face );
cmap_info->language = 0;
cmap_info->format = 0;
- if ( cmap->clazz != &FT_CFF_CMAP_ENCODING_CLASS_REC_GET &&
- cmap->clazz != &FT_CFF_CMAP_UNICODE_CLASS_REC_GET )
+ 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 =
@@ -446,7 +437,8 @@
}
- FT_DEFINE_SERVICE_TTCMAPSREC(cff_service_get_cmap_info,
+ FT_DEFINE_SERVICE_TTCMAPSREC(
+ cff_service_get_cmap_info,
(TT_CMap_Info_GetFunc)cff_get_cmap_info
)
@@ -461,37 +453,34 @@
const char* *ordering,
FT_Int *supplement )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
CFF_Font cff = (CFF_Font)face->extra.data;
if ( cff )
{
- CFF_FontRecDict dict = &cff->top_font.font_dict;
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
+ CFF_FontRecDict dict = &cff->top_font.font_dict;
if ( dict->cid_registry == 0xFFFFU )
{
- error = CFF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Fail;
}
if ( registry )
{
if ( cff->registry == NULL )
- cff->registry = cff_index_get_sid_string( &cff->string_index,
- dict->cid_registry,
- psnames );
+ cff->registry = cff_index_get_sid_string( cff,
+ dict->cid_registry );
*registry = cff->registry;
}
-
+
if ( ordering )
{
if ( cff->ordering == NULL )
- cff->ordering = cff_index_get_sid_string( &cff->string_index,
- dict->cid_ordering,
- psnames );
+ cff->ordering = cff_index_get_sid_string( cff,
+ dict->cid_ordering );
*ordering = cff->ordering;
}
@@ -509,7 +498,7 @@
*supplement = (FT_Int)dict->cid_supplement;
}
}
-
+
Fail:
return error;
}
@@ -519,7 +508,7 @@
cff_get_is_cid( CFF_Face face,
FT_Bool *is_cid )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
CFF_Font cff = (CFF_Font)face->extra.data;
@@ -543,7 +532,7 @@
FT_UInt glyph_index,
FT_UInt *cid )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
CFF_Font cff;
@@ -557,13 +546,13 @@
if ( dict->cid_registry == 0xFFFFU )
{
- error = CFF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Fail;
}
if ( glyph_index > cff->num_glyphs )
{
- error = CFF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Fail;
}
@@ -578,13 +567,147 @@
}
- FT_DEFINE_SERVICE_CIDREC(cff_service_cid_info,
+ 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
)
+ /*
+ * PROPERTY SERVICE
+ *
+ */
+ static FT_Error
+ cff_property_set( FT_Module module, /* CFF_Driver */
+ const char* property_name,
+ const void* value )
+ {
+ FT_Error error = FT_Err_Ok;
+ CFF_Driver driver = (CFF_Driver)module;
+
+
+ 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 error;
+ }
+ else if ( !ft_strcmp( property_name, "hinting-engine" ) )
+ {
+ FT_UInt* hinting_engine = (FT_UInt*)value;
+
+
+#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;
+
+
+ driver->no_stem_darkening = *no_stem_darkening;
+
+ return error;
+ }
+
+ FT_TRACE0(( "cff_property_set: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ static FT_Error
+ cff_property_get( FT_Module module, /* CFF_Driver */
+ const char* property_name,
+ const void* value )
+ {
+ FT_Error error = FT_Err_Ok;
+ CFF_Driver driver = (CFF_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(( "cff_property_get: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ cff_service_properties,
+ (FT_Properties_SetFunc)cff_property_set,
+ (FT_Properties_GetFunc)cff_property_get )
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -596,42 +719,64 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
+
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
- FT_DEFINE_SERVICEDESCREC6(cff_services,
+ FT_DEFINE_SERVICEDESCREC7(
+ cff_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
- FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_GLYPH_DICT, &FT_CFF_SERVICE_GLYPH_DICT_GET,
- FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
- FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_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
)
#else
- FT_DEFINE_SERVICEDESCREC5(cff_services,
+ FT_DEFINE_SERVICEDESCREC6(
+ cff_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
- FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
- FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_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
)
#endif
+
FT_CALLBACK_DEF( FT_Module_Interface )
cff_get_interface( FT_Module driver, /* CFF_Driver */
const char* module_interface )
{
+ FT_Library library;
FT_Module sfnt;
FT_Module_Interface result;
- result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
+ /* CFF_SERVICES_GET dereferences `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+ if ( !driver )
+ return NULL;
+ library = driver->library;
+ if ( !library )
+ return NULL;
+#endif
+
+ result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface );
if ( result != NULL )
- return result;
+ return result;
+ /* `driver' is not yet evaluated in non-PIC mode */
+#ifndef FT_CONFIG_OPTION_PIC
if ( !driver )
return NULL;
+ library = driver->library;
+ if ( !library )
+ return NULL;
+#endif
/* we pass our request to the `sfnt' module */
- sfnt = FT_Get_Module( driver->library, "sfnt" );
+ sfnt = FT_Get_Module( library, "sfnt" );
return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
}
@@ -645,12 +790,14 @@
#define CFF_SIZE_SELECT 0
#endif
- FT_DEFINE_DRIVER(cff_driver_class,
+ FT_DEFINE_DRIVER(
+ cff_driver_class,
+
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
- sizeof( CFF_DriverRec ),
+ sizeof ( CFF_DriverRec ),
"cff",
0x10000L,
0x20000L,
@@ -662,9 +809,9 @@
cff_get_interface,
/* now the specific driver fields */
- sizeof( TT_FaceRec ),
- sizeof( CFF_SizeRec ),
- sizeof( CFF_GlyphSlotRec ),
+ sizeof ( TT_FaceRec ),
+ sizeof ( CFF_SizeRec ),
+ sizeof ( CFF_GlyphSlotRec ),
cff_face_init,
cff_face_done,
@@ -673,14 +820,11 @@
cff_slot_init,
cff_slot_done,
- ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
- ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
- Load_Glyph,
+ cff_glyph_load,
cff_get_kerning,
- 0, /* FT_Face_AttachFunc */
- cff_get_advances, /* FT_Face_GetAdvancesFunc */
+ 0, /* FT_Face_AttachFunc */
+ cff_get_advances,
cff_size_request,
diff --git a/src/3rdparty/freetype/src/cff/cfferrs.h b/src/3rdparty/freetype/src/cff/cfferrs.h
index 1b2a5c95c8..801d73ec6b 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX CFF_Err_
#define FT_ERR_BASE FT_Mod_Err_CFF
diff --git a/src/3rdparty/freetype/src/cff/cffgload.c b/src/3rdparty/freetype/src/cff/cffgload.c
index 9330c05882..758a3d3bbd 100644
--- a/src/3rdparty/freetype/src/cff/cffgload.c
+++ b/src/3rdparty/freetype/src/cff/cffgload.c
@@ -4,8 +4,7 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
-/* 2010 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,11 +21,12 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_OUTLINE_H
-#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+#include FT_CFF_DRIVER_H
#include "cffobjs.h"
#include "cffload.h"
#include "cffgload.h"
+#include "cf2ft.h" /* for cf2_decoder_parse_charstrings */
#include "cfferrs.h"
@@ -41,6 +41,8 @@
#define FT_COMPONENT trace_cffgload
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+
typedef enum CFF_Operator_
{
cff_op_unknown = 0,
@@ -211,6 +213,8 @@
2 /* setcurrentpoint */
};
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
+
/*************************************************************************/
/*************************************************************************/
@@ -394,7 +398,7 @@
/* initialize Type2 decoder */
decoder->cff = cff;
- decoder->num_globals = cff->num_global_subrs;
+ 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,
@@ -414,7 +418,7 @@
CFF_Builder *builder = &decoder->builder;
CFF_Font cff = (CFF_Font)builder->face->extra.data;
CFF_SubFont sub = &cff->top_font;
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* manage CID fonts */
@@ -426,11 +430,11 @@
if ( fd_index >= cff->num_subfonts )
{
FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
- FT_TRACE4(( "glyph index %d (subfont %d):\n", glyph_index, fd_index ));
+ FT_TRACE3(( " in subfont %d:\n", fd_index ));
sub = cff->subfonts[fd_index];
@@ -443,12 +447,8 @@
builder->hints_globals = (void *)internal->subfonts[fd_index];
}
}
-#ifdef FT_DEBUG_LEVEL_TRACE
- else
- FT_TRACE4(( "glyph index %d:\n", glyph_index ));
-#endif
- decoder->num_locals = sub->num_local_subrs;
+ 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,
@@ -457,22 +457,24 @@
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 */
- static FT_Error
- check_points( CFF_Builder* builder,
- FT_Int count )
+ 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 */
- static void
+ FT_LOCAL_DEF( void )
cff_builder_add_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y,
@@ -486,9 +488,22 @@
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 );
+
- point->x = x >> 16;
- point->y = y >> 16;
+ 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 );
}
@@ -497,7 +512,7 @@
/* check space for a new on-curve point, then add it */
- static FT_Error
+ FT_LOCAL_DEF( FT_Error )
cff_builder_add_point1( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
@@ -505,7 +520,7 @@
FT_Error error;
- error = check_points( builder, 1 );
+ error = cff_check_points( builder, 1 );
if ( !error )
cff_builder_add_point( builder, x, y, 1 );
@@ -524,7 +539,7 @@
if ( !builder->load_points )
{
outline->n_contours++;
- return CFF_Err_Ok;
+ return FT_Err_Ok;
}
error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
@@ -542,12 +557,12 @@
/* if a path was begun, add its first on-curve point */
- static FT_Error
+ FT_LOCAL_DEF( FT_Error )
cff_builder_start_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* test whether we are building a new contour */
@@ -564,7 +579,7 @@
/* close the current contour */
- static void
+ FT_LOCAL_DEF( void )
cff_builder_close_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
@@ -609,7 +624,7 @@
}
- static FT_Int
+ FT_LOCAL_DEF( FT_Int )
cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
FT_Int charcode )
{
@@ -638,7 +653,7 @@
}
- static FT_Error
+ FT_LOCAL_DEF( FT_Error )
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
FT_Byte** pointer,
@@ -674,7 +689,7 @@
}
- static void
+ FT_LOCAL_DEF( void )
cff_free_glyph_data( TT_Face face,
FT_Byte** pointer,
FT_ULong length )
@@ -688,7 +703,7 @@
/* callback function. */
if ( face->root.internal->incremental_interface )
{
- FT_Data data;
+ FT_Data data;
data.pointer = *pointer;
@@ -709,6 +724,8 @@
}
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+
static FT_Error
cff_operator_seac( CFF_Decoder* decoder,
FT_Pos asb,
@@ -730,7 +747,7 @@
if ( decoder->seac )
{
FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
- return CFF_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
adx += decoder->builder.left_bearing.x;
@@ -758,7 +775,7 @@
{
FT_ERROR(( "cff_operator_seac:"
" invalid seac character code arguments\n" ));
- return CFF_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
/* If we are trying to load a composite glyph, do not load the */
@@ -812,10 +829,10 @@
charstring_len );
decoder->seac = FALSE;
+ cff_free_glyph_data( face, &charstring, charstring_len );
+
if ( error )
goto Exit;
-
- cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Save the left bearing, advance and glyph width of the base */
@@ -842,10 +859,10 @@
charstring_len );
decoder->seac = FALSE;
+ cff_free_glyph_data( face, &charstring, charstring_len );
+
if ( error )
goto Exit;
-
- cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Restore the left side bearing, advance and glyph width */
@@ -927,7 +944,7 @@
limit = zone->limit = charstring_base + charstring_len;
ip = zone->cursor = zone->base;
- error = CFF_Err_Ok;
+ error = FT_Err_Ok;
x = builder->pos_x;
y = builder->pos_y;
@@ -955,11 +972,14 @@
/* 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_Short)ip[0] << 8 ) | ip[1] );
+ val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] );
ip += 2;
}
else if ( v < 247 )
@@ -980,10 +1000,10 @@
{
if ( ip + 3 >= limit )
goto Syntax_Error;
- val = ( (FT_Int32)ip[0] << 24 ) |
- ( (FT_Int32)ip[1] << 16 ) |
- ( (FT_Int32)ip[2] << 8 ) |
- ip[3];
+ 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;
@@ -991,12 +1011,12 @@
if ( decoder->top - stack >= CFF_MAX_OPERANDS )
goto Stack_Overflow;
- val <<= shift;
+ val = (FT_Int32)( (FT_UInt32)val << shift );
*decoder->top++ = val;
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !( val & 0xFFFFL ) )
- FT_TRACE4(( " %ld", (FT_Int32)( val >> 16 ) ));
+ FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) ));
else
FT_TRACE4(( " %.2f", val / 65536.0 ));
#endif
@@ -1160,8 +1180,8 @@
op = cff_op_flex1;
break;
default:
- /* decrement ip for syntax error message */
- ip--;
+ FT_TRACE4(( " unknown op (12, %d)\n", v ));
+ break;
}
}
break;
@@ -1214,11 +1234,12 @@
op = cff_op_hvcurveto;
break;
default:
+ FT_TRACE4(( " unknown op (%d)\n", v ));
break;
}
if ( op == cff_op_unknown )
- goto Syntax_Error;
+ continue;
/* check arguments */
req_args = cff_argument_counts[op];
@@ -1340,6 +1361,14 @@
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 )
@@ -1358,20 +1387,18 @@
FT_UInt maskbyte;
- FT_TRACE4(( " (maskbytes: " ));
+ FT_TRACE4(( " (maskbytes:" ));
for ( maskbyte = 0;
- maskbyte < (FT_UInt)(( decoder->num_hints + 7 ) >> 3);
+ maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 );
maskbyte++, ip++ )
- FT_TRACE4(( "0x%02X", *ip ));
+ FT_TRACE4(( " 0x%02X", *ip ));
FT_TRACE4(( ")\n" ));
}
#else
ip += ( decoder->num_hints + 7 ) >> 3;
#endif
- if ( ip >= limit )
- goto Syntax_Error;
args = stack;
break;
@@ -1406,8 +1433,8 @@
case cff_op_rlineto:
FT_TRACE4(( " rlineto\n" ));
- if ( cff_builder_start_point ( builder, x, y ) ||
- check_points( builder, num_args / 2 ) )
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, num_args / 2 ) )
goto Fail;
if ( num_args < 2 )
@@ -1433,11 +1460,16 @@
FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n"
: " vlineto\n" ));
- if ( num_args < 1 )
+ if ( num_args < 0 )
goto Stack_Underflow;
- if ( cff_builder_start_point ( builder, x, y ) ||
- check_points( builder, num_args ) )
+ /* 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;
@@ -1470,8 +1502,8 @@
nargs = num_args - num_args % 6;
- if ( cff_builder_start_point ( builder, x, y ) ||
- check_points( builder, nargs / 2 ) )
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, nargs / 2 ) )
goto Fail;
args -= nargs;
@@ -1503,11 +1535,9 @@
goto Stack_Underflow;
/* if num_args isn't of the form 4n or 4n+1, */
- /* we reduce it to 4n+1 */
+ /* we enforce it by clearing the second bit */
- nargs = num_args - num_args % 4;
- if ( num_args - nargs > 0 )
- nargs += 1;
+ nargs = num_args & ~2;
if ( cff_builder_start_point( builder, x, y ) )
goto Fail;
@@ -1521,7 +1551,7 @@
nargs--;
}
- if ( check_points( builder, 3 * ( nargs / 4 ) ) )
+ if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
goto Fail;
while ( args < decoder->top )
@@ -1550,11 +1580,9 @@
goto Stack_Underflow;
/* if num_args isn't of the form 4n or 4n+1, */
- /* we reduce it to 4n+1 */
+ /* we enforce it by clearing the second bit */
- nargs = num_args - num_args % 4;
- if ( num_args - nargs > 0 )
- nargs += 1;
+ nargs = num_args & ~2;
if ( cff_builder_start_point( builder, x, y ) )
goto Fail;
@@ -1567,7 +1595,7 @@
nargs--;
}
- if ( check_points( builder, 3 * ( nargs / 4 ) ) )
+ if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
goto Fail;
while ( args < decoder->top )
@@ -1602,14 +1630,12 @@
goto Stack_Underflow;
/* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */
- /* we reduce it to the largest one which fits */
+ /* we enforce it by clearing the second bit */
- nargs = num_args - num_args % 4;
- if ( num_args - nargs > 0 )
- nargs += 1;
+ nargs = num_args & ~2;
args -= nargs;
- if ( check_points( builder, ( nargs / 4 ) * 3 ) )
+ if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) )
goto Stack_Underflow;
phase = ( op == cff_op_hvcurveto );
@@ -1662,8 +1688,8 @@
nargs = num_args & ~1;
num_lines = ( nargs - 6 ) / 2;
- if ( cff_builder_start_point( builder, x, y ) ||
- check_points( builder, num_lines + 3 ) )
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, num_lines + 3 ) )
goto Fail;
args -= nargs;
@@ -1707,8 +1733,8 @@
nargs = nargs - nargs % 6 + 2;
num_curves = ( nargs - 2 ) / 6;
- if ( cff_builder_start_point ( builder, x, y ) ||
- check_points( builder, num_curves * 3 + 2 ) )
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, num_curves * 3 + 2 ) )
goto Fail;
args -= nargs;
@@ -1748,7 +1774,7 @@
/* -- make sure we have enough space for the start point if it */
/* needs to be added */
if ( cff_builder_start_point( builder, x, y ) ||
- check_points( builder, 6 ) )
+ cff_check_points( builder, 6 ) )
goto Fail;
/* record the starting point's y position for later use */
@@ -1797,7 +1823,7 @@
/* adding six more points; 4 control points, 2 on-curve points */
if ( cff_builder_start_point( builder, x, y ) ||
- check_points( builder, 6 ) )
+ cff_check_points( builder, 6 ) )
goto Fail;
/* record the starting point's y-position for later use */
@@ -1850,7 +1876,7 @@
/* adding six more points; 4 control points, 2 on-curve points */
if ( cff_builder_start_point( builder, x, y ) ||
- check_points( builder, 6 ) )
+ cff_check_points( builder, 6 ) )
goto Fail;
/* record the starting point's x, y position for later use */
@@ -1913,7 +1939,7 @@
FT_TRACE4(( " flex\n" ));
if ( cff_builder_start_point( builder, x, y ) ||
- check_points( builder, 6 ) )
+ cff_check_points( builder, 6 ) )
goto Fail;
for ( count = 6; count > 0; count-- )
@@ -1953,6 +1979,7 @@
/* 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 ),
@@ -1962,9 +1989,6 @@
}
else
{
- if ( !error )
- error = CFF_Err_Ok;
-
cff_builder_close_contour( builder );
/* close hints recording session */
@@ -1975,10 +1999,12 @@
goto Syntax_Error;
/* apply hints to the loaded glyph outline now */
- hinter->apply( hinter->hints,
- builder->current,
- (PSH_Globals)builder->hints_globals,
- decoder->hint_mode );
+ error = hinter->apply( hinter->hints,
+ builder->current,
+ (PSH_Globals)builder->hints_globals,
+ decoder->hint_mode );
+ if ( error )
+ goto Fail;
}
/* add current outline to the glyph slot */
@@ -2275,7 +2301,11 @@
/* 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:
@@ -2285,6 +2315,22 @@
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;
@@ -2445,10 +2491,13 @@
FT_ERROR(( " %d", ip[0] ));
FT_ERROR(( "\n" ));
- return CFF_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
- decoder->top = args;
+ decoder->top = args;
+
+ if ( decoder->top - stack >= CFF_MAX_OPERANDS )
+ goto Stack_Overflow;
} /* general operator processing */
@@ -2461,17 +2510,19 @@
Syntax_Error:
FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" ));
- return CFF_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
Stack_Underflow:
FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" ));
- return CFF_Err_Too_Few_Arguments;
+ return FT_THROW( Too_Few_Arguments );
Stack_Overflow:
FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" ));
- return CFF_Err_Stack_Overflow;
+ return FT_THROW( Stack_Overflow );
}
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
+
/*************************************************************************/
/*************************************************************************/
@@ -2498,7 +2549,7 @@
cff_compute_max_advance( TT_Face face,
FT_Int* max_advance )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
CFF_Decoder decoder;
FT_Int glyph_index;
CFF_Font cff = (CFF_Font)face->other;
@@ -2536,12 +2587,12 @@
}
/* ignore the error if one has occurred -- skip to next glyph */
- error = CFF_Err_Ok;
+ error = FT_Err_Ok;
}
*max_advance = decoder.builder.advance.x;
- return CFF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2557,7 +2608,7 @@
FT_Error error;
CFF_Decoder decoder;
TT_Face face = (TT_Face)glyph->root.face;
- FT_Bool hinting, force_scaling;
+ FT_Bool hinting, scaled, force_scaling;
CFF_Font cff = (CFF_Font)face->extra.data;
FT_Matrix font_matrix;
@@ -2578,11 +2629,11 @@
glyph_index = cff_charset_cid_to_gindex( &cff->charset,
glyph_index );
if ( glyph_index == 0 )
- return CFF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
}
else if ( glyph_index >= cff->num_glyphs )
- return CFF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@@ -2625,6 +2676,11 @@
if ( !error )
{
+ FT_Bool has_vertical_info;
+ FT_UShort advance;
+ FT_Short dummy;
+
+
glyph->root.outline.n_points = 0;
glyph->root.outline.n_contours = 0;
@@ -2651,6 +2707,39 @@
glyph->root.bitmap_left = metrics.horiBearingX;
glyph->root.bitmap_top = metrics.horiBearingY;
}
+
+ /* compute linear advance widths */
+
+ (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 0,
+ glyph_index,
+ &dummy,
+ &advance );
+ glyph->root.linearHoriAdvance = advance;
+
+ has_vertical_info = FT_BOOL(
+ face->vertical_info &&
+ face->vertical.number_Of_VMetrics > 0 );
+
+ /* get the vertical metrics from the vtmx table if we have one */
+ if ( has_vertical_info )
+ {
+ (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
+ glyph_index,
+ &dummy,
+ &advance );
+ glyph->root.linearVertAdvance = advance;
+ }
+ else
+ {
+ /* make up vertical ones */
+ if ( face->os2.version != 0xFFFFU )
+ glyph->root.linearVertAdvance = (FT_Pos)
+ ( face->os2.sTypoAscender - face->os2.sTypoDescender );
+ else
+ glyph->root.linearVertAdvance = (FT_Pos)
+ ( face->horizontal.Ascender - face->horizontal.Descender );
+ }
+
return error;
}
}
@@ -2660,7 +2749,7 @@
/* return immediately if we only want the embedded bitmaps */
if ( load_flags & FT_LOAD_SBITS_ONLY )
- return CFF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* if we have a CID subfont, use its matrix (which has already */
/* been multiplied with the root matrix) */
@@ -2668,11 +2757,16 @@
/* this scaling is only relevant if the PS hinter isn't active */
if ( cff->num_subfonts )
{
- FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
- glyph_index );
+ FT_ULong top_upm, sub_upm;
+ FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
+ glyph_index );
- FT_ULong top_upm = cff->top_font.font_dict.units_per_em;
- FT_ULong sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
+
+ if ( fd_index >= cff->num_subfonts )
+ fd_index = (FT_Byte)( cff->num_subfonts - 1 );
+
+ top_upm = cff->top_font.font_dict.units_per_em;
+ sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
@@ -2695,12 +2789,21 @@
glyph->root.outline.n_points = 0;
glyph->root.outline.n_contours = 0;
- hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
- ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+ /* top-level code ensures that FT_LOAD_NO_HINTING is set */
+ /* if FT_LOAD_NO_SCALE is active */
+ hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+ scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
+ glyph->hint = hinting;
+ glyph->scaled = scaled;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
{
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face );
+#endif
+
+
FT_Byte* charstring;
FT_ULong charstring_len;
@@ -2717,48 +2820,79 @@
/* now load the unscaled outline */
error = cff_get_glyph_data( face, glyph_index,
&charstring, &charstring_len );
- if ( !error )
+ if ( error )
+ goto Glyph_Build_Finished;
+
+ error = cff_decoder_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 );
+ else
+#endif
{
- error = cff_decoder_prepare( &decoder, size, glyph_index );
- if ( !error )
+ error = cf2_decoder_parse_charstrings( &decoder,
+ charstring,
+ charstring_len );
+
+ /* 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 ) )
{
- error = cff_decoder_parse_charstrings( &decoder,
+ /* 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) */
+ hinting = FALSE;
+ force_scaling = TRUE;
+ glyph->hint = hinting;
+
+ error = cf2_decoder_parse_charstrings( &decoder,
charstring,
charstring_len );
+ }
+ }
- cff_free_glyph_data( face, &charstring, charstring_len );
+ cff_free_glyph_data( face, &charstring, charstring_len );
+ if ( error )
+ goto Glyph_Build_Finished;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* Control data and length may not be available for incremental */
- /* fonts. */
- if ( face->root.internal->incremental_interface )
- {
- glyph->root.control_data = 0;
- glyph->root.control_len = 0;
- }
- else
+ /* Control data and length may not be available for incremental */
+ /* fonts. */
+ if ( face->root.internal->incremental_interface )
+ {
+ glyph->root.control_data = 0;
+ glyph->root.control_len = 0;
+ }
+ else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- /* We set control_data and control_len if charstrings is loaded. */
- /* See how charstring loads at cff_index_access_element() in */
- /* cffload.c. */
- {
- CFF_Index csindex = &cff->charstrings_index;
+ /* We set control_data and control_len if charstrings is loaded. */
+ /* See how charstring loads at cff_index_access_element() in */
+ /* cffload.c. */
+ {
+ CFF_Index csindex = &cff->charstrings_index;
- if ( csindex->offsets )
- {
- glyph->root.control_data = csindex->bytes +
- csindex->offsets[glyph_index] - 1;
- glyph->root.control_len = charstring_len;
- }
- }
+ if ( csindex->offsets )
+ {
+ glyph->root.control_data = csindex->bytes +
+ csindex->offsets[glyph_index] - 1;
+ glyph->root.control_len = charstring_len;
}
}
- /* save new glyph tables */
- cff_builder_done( &decoder.builder );
+ Glyph_Build_Finished:
+ /* save new glyph tables, if no error */
+ if ( !error )
+ cff_builder_done( &decoder.builder );
+ /* XXX: anything to do for broken glyph entry? */
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -2819,14 +2953,8 @@
glyph->root.linearHoriAdvance = decoder.glyph_width;
glyph->root.internal->glyph_transformed = 0;
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- has_vertical_info = FT_BOOL( face->vertical_info &&
- face->vertical.number_Of_VMetrics > 0 &&
- face->vertical.long_metrics );
-#else
has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 );
-#endif
/* get the vertical metrics from the vtmx table if we have one */
if ( has_vertical_info )
@@ -2835,10 +2963,10 @@
FT_UShort vertAdvance = 0;
- ( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
- glyph_index,
- &vertBearingY,
- &vertAdvance );
+ (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
+ glyph_index,
+ &vertBearingY,
+ &vertAdvance );
metrics->vertBearingY = vertBearingY;
metrics->vertAdvance = vertAdvance;
}
@@ -2919,7 +3047,7 @@
if ( has_vertical_info )
metrics->vertBearingX = metrics->horiBearingX -
metrics->horiAdvance / 2;
- else
+ else
{
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
ft_synthesize_vertical_metrics( metrics,
diff --git a/src/3rdparty/freetype/src/cff/cffgload.h b/src/3rdparty/freetype/src/cff/cffgload.h
index 38937be5c1..41df7db692 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-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2004, 2006-2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -106,6 +106,41 @@ FT_BEGIN_HEADER
} 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,
+ FT_Byte** pointer,
+ FT_ULong* length );
+ FT_LOCAL( void )
+ cff_free_glyph_data( TT_Face face,
+ FT_Byte** pointer,
+ FT_ULong length );
+
+
/* execution context charstring zone */
typedef struct CFF_Decoder_Zone_
@@ -156,6 +191,8 @@ FT_BEGIN_HEADER
FT_Bool seac;
+ CFF_SubFont current_subfont; /* for current glyph_index */
+
} CFF_Decoder;
@@ -181,10 +218,12 @@ 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,
diff --git a/src/3rdparty/freetype/src/cff/cffload.c b/src/3rdparty/freetype/src/cff/cffload.c
index 64d1395723..d9bec5966b 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,7 +20,6 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_STREAM_H
-#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_TRUETYPE_TAGS_H
#include FT_TYPE1_TABLES_H
@@ -251,7 +250,7 @@
if ( offsize < 1 || offsize > 4 )
{
- error = FT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -270,7 +269,7 @@
if ( size == 0 )
{
- error = CFF_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -319,7 +318,7 @@
static FT_Error
cff_index_load_offsets( CFF_Index idx )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Stream stream = idx->stream;
FT_Memory memory = stream->memory;
@@ -377,18 +376,22 @@
}
- /* allocate a table containing pointers to an index's elements */
+ /* Allocate a table containing pointers to an index's elements. */
+ /* The `pool' argument makes this function convert the index */
+ /* entries to C-style strings (this is, NULL-terminated). */
static FT_Error
cff_index_get_pointers( CFF_Index idx,
- FT_Byte*** table )
+ FT_Byte*** table,
+ FT_Byte** pool )
{
- FT_Error error = CFF_Err_Ok;
- FT_Memory memory = idx->stream->memory;
- FT_ULong n, offset, old_offset;
- FT_Byte** t;
+ FT_Error error = FT_Err_Ok;
+ FT_Memory memory = idx->stream->memory;
+ FT_Byte** t = NULL;
+ FT_Byte* new_bytes = NULL;
- *table = 0;
+
+ *table = NULL;
if ( idx->offsets == NULL )
{
@@ -397,28 +400,65 @@
goto Exit;
}
- if ( idx->count > 0 && !FT_NEW_ARRAY( t, idx->count + 1 ) )
+ if ( idx->count > 0 &&
+ !FT_NEW_ARRAY( t, idx->count + 1 ) &&
+ ( !pool || !FT_ALLOC( new_bytes,
+ idx->data_size + idx->count ) ) )
{
- old_offset = 1;
- for ( n = 0; n <= idx->count; n++ )
+ FT_ULong n, cur_offset;
+ FT_ULong extra = 0;
+ FT_Byte* org_bytes = idx->bytes;
+
+
+ /* at this point, `idx->offsets' can't be NULL */
+ cur_offset = idx->offsets[0] - 1;
+
+ /* sanity check */
+ if ( cur_offset != 0 )
+ {
+ FT_TRACE0(( "cff_index_get_pointers:"
+ " invalid first offset value %d set to zero\n",
+ cur_offset ));
+ cur_offset = 0;
+ }
+
+ if ( !pool )
+ t[0] = org_bytes + cur_offset;
+ else
+ t[0] = new_bytes + cur_offset;
+
+ for ( n = 1; n <= idx->count; n++ )
{
- /* at this point, `idx->offsets' can't be NULL */
- offset = idx->offsets[n];
- if ( !offset )
- offset = old_offset;
+ FT_ULong next_offset = idx->offsets[n] - 1;
+
/* two sanity checks for invalid offset tables */
- else if ( offset < old_offset )
- offset = old_offset;
+ if ( next_offset < cur_offset )
+ next_offset = cur_offset;
+ else if ( next_offset > idx->data_size )
+ next_offset = idx->data_size;
- else if ( offset - 1 >= idx->data_size && n < idx->count )
- offset = old_offset;
+ if ( !pool )
+ t[n] = org_bytes + next_offset;
+ else
+ {
+ t[n] = new_bytes + next_offset + extra;
- t[n] = idx->bytes + offset - 1;
+ if ( next_offset != cur_offset )
+ {
+ FT_MEM_COPY( t[n - 1], org_bytes + cur_offset, t[n] - t[n - 1] );
+ t[n][0] = '\0';
+ t[n] += 1;
+ extra++;
+ }
+ }
- old_offset = offset;
+ cur_offset = next_offset;
}
*table = t;
+
+ if ( pool )
+ *pool = new_bytes;
}
Exit:
@@ -432,7 +472,7 @@
FT_Byte** pbytes,
FT_ULong* pbyte_len )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( idx && idx->count > element )
@@ -479,6 +519,18 @@
}
}
+ /* XXX: should check off2 does not exceed the end of this entry; */
+ /* at present, only truncate off2 at the end of this stream */
+ if ( off2 > stream->size + 1 ||
+ idx->data_offset > stream->size - off2 + 1 )
+ {
+ FT_ERROR(( "cff_index_access_element:"
+ " offset to next entry (%d)"
+ " exceeds the end of stream (%d)\n",
+ off2, stream->size - idx->data_offset + 1 ));
+ off2 = stream->size - idx->data_offset + 1;
+ }
+
/* access element */
if ( off1 && off2 > off1 )
{
@@ -505,7 +557,7 @@
}
}
else
- error = CFF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
Exit:
return error;
@@ -526,10 +578,12 @@
}
+ /* get an entry from Name INDEX */
FT_LOCAL_DEF( FT_String* )
- cff_index_get_name( CFF_Index idx,
- FT_UInt element )
+ cff_index_get_name( CFF_Font font,
+ FT_UInt element )
{
+ CFF_Index idx = &font->name_index;
FT_Memory memory = idx->stream->memory;
FT_Byte* bytes;
FT_ULong byte_len;
@@ -553,42 +607,35 @@
}
+ /* get an entry from String INDEX */
FT_LOCAL_DEF( FT_String* )
- cff_index_get_sid_string( CFF_Index idx,
- FT_UInt sid,
- FT_Service_PsCMaps psnames )
+ cff_index_get_string( CFF_Font font,
+ FT_UInt element )
+ {
+ return ( element < font->num_strings )
+ ? (FT_String*)font->strings[element]
+ : NULL;
+ }
+
+
+ FT_LOCAL_DEF( FT_String* )
+ cff_index_get_sid_string( CFF_Font font,
+ FT_UInt sid )
{
/* value 0xFFFFU indicates a missing dictionary entry */
if ( sid == 0xFFFFU )
- return 0;
+ return NULL;
/* if it is not a standard string, return it */
if ( sid > 390 )
- return cff_index_get_name( idx, sid - 391 );
+ return cff_index_get_string( font, sid - 391 );
/* CID-keyed CFF fonts don't have glyph names */
- if ( !psnames )
- return 0;
-
- /* that's a standard string, fetch a copy from the PSName module */
- {
- FT_String* name = 0;
- const char* adobe_name = psnames->adobe_std_strings( sid );
-
-
- if ( adobe_name )
- {
- FT_Memory memory = idx->stream->memory;
- FT_Error error;
+ if ( !font->psnames )
+ return NULL;
-
- (void)FT_STRDUP( name, adobe_name );
-
- FT_UNUSED( error );
- }
-
- return name;
- }
+ /* this is a standard string */
+ return (FT_String *)font->psnames->adobe_std_strings( sid );
}
@@ -642,6 +689,13 @@
if ( FT_READ_USHORT( num_ranges ) )
goto Exit;
+ if ( !num_ranges )
+ {
+ FT_TRACE0(( "CFF_Load_FD_Select: empty FDSelect array\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
fdselect->data_size = num_ranges * 3 + 2;
Load_Data:
@@ -650,7 +704,7 @@
break;
default: /* hmm... that's wrong */
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
Exit:
@@ -672,7 +726,7 @@
break;
case 3:
- /* first, compare to cache */
+ /* first, compare to the cache */
if ( (FT_UInt)( glyph_index - fdselect->cache_first ) <
fdselect->cache_count )
{
@@ -680,7 +734,7 @@
break;
}
- /* then, lookup the ranges array */
+ /* then, look up the ranges array */
{
FT_Byte* p = fdselect->data;
FT_Byte* p_limit = p + fdselect->data_size;
@@ -703,7 +757,7 @@
/* update cache */
fdselect->cache_first = first;
- fdselect->cache_count = limit-first;
+ fdselect->cache_count = limit - first;
fdselect->cache_fd = fd2;
break;
}
@@ -744,11 +798,12 @@
goto Exit;
for ( i = 0; i < num_glyphs; i++ )
+ {
if ( charset->sids[i] > max_cid )
max_cid = charset->sids[i];
- max_cid++;
+ }
- if ( FT_NEW_ARRAY( charset->cids, max_cid ) )
+ if ( FT_NEW_ARRAY( charset->cids, (FT_ULong)max_cid + 1 ) )
goto Exit;
/* When multiple GIDs map to the same CID, we choose the lowest */
@@ -772,7 +827,7 @@
FT_UInt result = 0;
- if ( cid < charset->max_cid )
+ if ( cid <= charset->max_cid )
result = charset->cids[cid];
return result;
@@ -812,7 +867,7 @@
FT_Bool invert )
{
FT_Memory memory = stream->memory;
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UShort glyph_sid;
@@ -846,20 +901,7 @@
goto Exit;
for ( j = 1; j < num_glyphs; j++ )
- {
- FT_UShort sid = FT_GET_USHORT();
-
-
- /* this constant is given in the CFF specification */
- if ( sid < 65000L )
- charset->sids[j] = sid;
- else
- {
- FT_TRACE0(( "cff_charset_load:"
- " invalid SID value %d set to zero\n", sid ));
- charset->sids[j] = 0;
- }
- }
+ charset->sids[j] = FT_GET_USHORT();
FT_FRAME_EXIT();
}
@@ -892,18 +934,12 @@
goto Exit;
}
- /* check whether the range contains at least one valid glyph; */
- /* the constant is given in the CFF specification */
- if ( glyph_sid >= 65000L ) {
- FT_ERROR(( "cff_charset_load: invalid SID range\n" ));
- error = CFF_Err_Invalid_File_Format;
- goto Exit;
- }
-
/* try to rescue some of the SIDs if `nleft' is too large */
- if ( nleft > 65000L - 1L || glyph_sid >= 65000L - nleft ) {
- FT_ERROR(( "cff_charset_load: invalid SID range trimmed\n" ));
- nleft = ( FT_UInt )( 65000L - 1L - glyph_sid );
+ if ( glyph_sid > 0xFFFFL - nleft )
+ {
+ FT_ERROR(( "cff_charset_load: invalid SID range trimmed"
+ " nleft=%d -> %d\n", nleft, 0xFFFFL - glyph_sid ));
+ nleft = ( FT_UInt )( 0xFFFFL - glyph_sid );
}
/* Fill in the range of sids -- `nleft + 1' glyphs. */
@@ -915,7 +951,7 @@
default:
FT_ERROR(( "cff_charset_load: invalid table format\n" ));
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
}
@@ -938,7 +974,7 @@
{
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
"predefined charset (Adobe ISO-Latin)\n" ));
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -956,7 +992,7 @@
{
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
"predefined charset (Adobe Expert)\n" ));
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -974,7 +1010,7 @@
{
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
"predefined charset (Adobe Expert Subset)\n" ));
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -988,7 +1024,7 @@
break;
default:
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
}
@@ -1029,7 +1065,7 @@
FT_ULong base_offset,
FT_ULong offset )
{
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt count;
FT_UInt j;
FT_UShort glyph_sid;
@@ -1039,7 +1075,7 @@
/* Check for charset->sids. If we do not have this, we fail. */
if ( !charset->sids )
{
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1159,7 +1195,7 @@
default:
FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1240,9 +1276,7 @@
if ( gid != 0 )
{
encoding->codes[j] = (FT_UShort)gid;
-
- if ( encoding->count < j + 1 )
- encoding->count = j + 1;
+ encoding->count = j + 1;
}
else
{
@@ -1254,7 +1288,7 @@
default:
FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
- error = CFF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
}
@@ -1287,7 +1321,7 @@
/* set defaults */
FT_MEM_ZERO( top, sizeof ( *top ) );
- top->underline_position = -100L << 16;
+ top->underline_position = -( 100L << 16 );
top->underline_thickness = 50L << 16;
top->charstring_type = 2;
top->font_matrix.xx = 0x10000L;
@@ -1310,7 +1344,10 @@
error = cff_index_access_element( idx, font_index, &dict, &dict_len );
if ( !error )
+ {
+ FT_TRACE4(( " top dictionary:\n" ));
error = cff_parser_run( &parser, dict, dict + dict_len );
+ }
cff_index_forget_element( idx, &dict );
@@ -1339,6 +1376,7 @@
FT_FRAME_ENTER( font->font_dict.private_size ) )
goto Exit;
+ FT_TRACE4(( " private dictionary:\n" ));
error = cff_parser_run( &parser,
(FT_Byte*)stream->cursor,
(FT_Byte*)stream->limit );
@@ -1361,9 +1399,8 @@
if ( error )
goto Exit;
- font->num_local_subrs = font->local_subrs_index.count;
error = cff_index_get_pointers( &font->local_subrs_index,
- &font->local_subrs );
+ &font->local_subrs, NULL );
if ( error )
goto Exit;
}
@@ -1409,9 +1446,12 @@
FT_Memory memory = stream->memory;
FT_ULong base_offset;
CFF_FontRecDict dict;
+ CFF_IndexRec string_index;
+ FT_Int subfont_index;
FT_ZERO( font );
+ FT_ZERO( &string_index );
font->stream = stream;
font->memory = memory;
@@ -1427,8 +1467,8 @@
font->header_size < 4 ||
font->absolute_offsize > 4 )
{
- FT_TRACE2(( "[not a CFF font header]\n" ));
- error = CFF_Err_Unknown_File_Format;
+ FT_TRACE2(( " not a CFF font header\n" ));
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -1438,22 +1478,49 @@
/* read the name, top dict, string and global subrs index */
if ( FT_SET_ERROR( cff_index_init( &font->name_index,
- stream, 0 ) ) ||
+ stream, 0 ) ) ||
FT_SET_ERROR( cff_index_init( &font->font_dict_index,
- stream, 0 ) ) ||
- FT_SET_ERROR( cff_index_init( &font->string_index,
- stream, 0 ) ) ||
+ stream, 0 ) ) ||
+ FT_SET_ERROR( cff_index_init( &string_index,
+ stream, 1 ) ) ||
FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
- stream, 1 ) ) )
+ stream, 1 ) ) ||
+ FT_SET_ERROR( cff_index_get_pointers( &string_index,
+ &font->strings,
+ &font->string_pool ) ) )
goto Exit;
- /* well, we don't really forget the `disabled' fonts... */
- font->num_faces = font->name_index.count;
- if ( face_index >= (FT_Int)font->num_faces )
+ font->num_strings = string_index.count;
+
+ if ( pure_cff )
+ {
+ /* well, we don't really forget the `disabled' fonts... */
+ subfont_index = face_index;
+
+ if ( subfont_index >= (FT_Int)font->name_index.count )
+ {
+ FT_ERROR(( "cff_font_load:"
+ " invalid subfont index for pure CFF font (%d)\n",
+ subfont_index ));
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ font->num_faces = font->name_index.count;
+ }
+ else
{
- FT_ERROR(( "cff_font_load: incorrect face index = %d\n",
- face_index ));
- error = CFF_Err_Invalid_Argument;
+ subfont_index = 0;
+
+ if ( font->name_index.count > 1 )
+ {
+ FT_ERROR(( "cff_font_load:"
+ " invalid CFF font with multiple subfonts\n"
+ " "
+ " in SFNT wrapper\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
}
/* in case of a font format check, simply exit now */
@@ -1461,9 +1528,10 @@
goto Exit;
/* now, parse the top-level font dictionary */
+ FT_TRACE4(( "parsing top-level\n" ));
error = cff_subfont_load( &font->top_font,
&font->font_dict_index,
- face_index,
+ subfont_index,
stream,
base_offset,
library );
@@ -1481,7 +1549,7 @@
if ( dict->cid_registry != 0xFFFFU )
{
CFF_IndexRec fd_index;
- CFF_SubFont sub;
+ CFF_SubFont sub = NULL;
FT_UInt idx;
@@ -1513,6 +1581,7 @@
for ( idx = 0; idx < fd_index.count; idx++ )
{
sub = font->subfonts[idx];
+ FT_TRACE4(( "parsing subfont %u\n", idx ));
error = cff_subfont_load( sub, &fd_index, idx,
stream, base_offset, library );
if ( error )
@@ -1538,16 +1607,14 @@
if ( dict->charstrings_offset == 0 )
{
FT_ERROR(( "cff_font_load: no charstrings offset\n" ));
- error = CFF_Err_Unknown_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
- /* explicit the global subrs */
- font->num_global_subrs = font->global_subrs_index.count;
- font->num_glyphs = font->charstrings_index.count;
+ font->num_glyphs = font->charstrings_index.count;
error = cff_index_get_pointers( &font->global_subrs_index,
- &font->global_subrs ) ;
+ &font->global_subrs, NULL );
if ( error )
goto Exit;
@@ -1579,9 +1646,11 @@
/* get the font name (/CIDFontName for CID-keyed fonts, */
/* /FontName otherwise) */
- font->font_name = cff_index_get_name( &font->name_index, face_index );
+ font->font_name = cff_index_get_name( font, subfont_index );
Exit:
+ cff_index_done( &string_index );
+
return error;
}
@@ -1594,7 +1663,6 @@
cff_index_done( &font->global_subrs_index );
- cff_index_done( &font->string_index );
cff_index_done( &font->font_dict_index );
cff_index_done( &font->name_index );
cff_index_done( &font->charstrings_index );
@@ -1617,21 +1685,18 @@
CFF_Done_FD_Select( &font->fd_select, font->stream );
- if (font->font_info != NULL)
- {
- FT_FREE( font->font_info->version );
- FT_FREE( font->font_info->notice );
- FT_FREE( font->font_info->full_name );
- FT_FREE( font->font_info->family_name );
- FT_FREE( font->font_info->weight );
- FT_FREE( font->font_info );
- }
+ FT_FREE( font->font_info );
- FT_FREE( font->registry );
- FT_FREE( font->ordering );
-
- FT_FREE( font->global_subrs );
FT_FREE( font->font_name );
+ FT_FREE( font->global_subrs );
+ FT_FREE( font->strings );
+ FT_FREE( font->string_pool );
+
+ if ( font->cf2_instance.finalizer )
+ {
+ font->cf2_instance.finalizer( font->cf2_instance.data );
+ FT_FREE( font->cf2_instance.data );
+ }
}
diff --git a/src/3rdparty/freetype/src/cff/cffload.h b/src/3rdparty/freetype/src/cff/cffload.h
index 2b313acf06..804961964b 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-2001, 2002, 2003, 2007, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,7 +22,6 @@
#include <ft2build.h>
#include "cfftypes.h"
-#include FT_SERVICE_POSTSCRIPT_CMAPS_H
FT_BEGIN_HEADER
@@ -32,13 +31,12 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_String* )
- cff_index_get_name( CFF_Index idx,
- FT_UInt element );
+ cff_index_get_string( CFF_Font font,
+ FT_UInt element );
FT_LOCAL( FT_String* )
- cff_index_get_sid_string( CFF_Index idx,
- FT_UInt sid,
- FT_Service_PsCMaps psnames );
+ cff_index_get_sid_string( CFF_Font font,
+ FT_UInt sid );
FT_LOCAL( FT_Error )
@@ -51,6 +49,10 @@ FT_BEGIN_HEADER
cff_index_forget_element( CFF_Index idx,
FT_Byte** pbytes );
+ FT_LOCAL( FT_String* )
+ cff_index_get_name( CFF_Font font,
+ FT_UInt element );
+
FT_LOCAL( FT_UInt )
cff_charset_cid_to_gindex( CFF_Charset charset,
@@ -58,7 +60,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
- cff_font_load( FT_Library library,
+ cff_font_load( FT_Library library,
FT_Stream stream,
FT_Int face_index,
CFF_Font font,
diff --git a/src/3rdparty/freetype/src/cff/cffobjs.c b/src/3rdparty/freetype/src/cff/cffobjs.c
index bd56c4ba11..da3d0190fe 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_STREAM_H
@@ -24,14 +25,15 @@
#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_SFNT_H
-#include FT_SERVICE_POSTSCRIPT_CMAPS_H
-#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+#include FT_CFF_DRIVER_H
+
#include "cffobjs.h"
#include "cffload.h"
#include "cffcmap.h"
-#include "cfferrs.h"
#include "cffpic.h"
+#include "cfferrs.h"
+
/*************************************************************************/
/* */
@@ -58,7 +60,7 @@
{
CFF_Face face = (CFF_Face)size->root.face;
CFF_Font font = (CFF_Font)face->extra.data;
- PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
+ PSHinter_Service pshinter = font->pshinter;
FT_Module module;
@@ -155,7 +157,7 @@
cff_size_init( FT_Size cffsize ) /* CFF_Size */
{
CFF_Size size = (CFF_Size)cffsize;
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size );
@@ -163,7 +165,7 @@
{
CFF_Face face = (CFF_Face)cffsize->face;
CFF_Font font = (CFF_Font)face->extra.data;
- CFF_Internal internal;
+ CFF_Internal internal = NULL;
PS_PrivateRec priv;
FT_Memory memory = cffsize->face->memory;
@@ -255,7 +257,7 @@
}
}
- return CFF_Err_Ok;
+ return FT_Err_Ok;
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
@@ -327,7 +329,7 @@
}
}
- return CFF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -349,7 +351,7 @@
{
CFF_Face face = (CFF_Face)slot->face;
CFF_Font font = (CFF_Font)face->extra.data;
- PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
+ PSHinter_Service pshinter = font->pshinter;
if ( pshinter )
@@ -369,7 +371,7 @@
}
}
- return CFF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -395,6 +397,87 @@
}
+ /* Strip all subset prefixes of the form `ABCDEF+'. Usually, there */
+ /* is only one, but font names like `APCOOG+JFABTD+FuturaBQ-Bold' */
+ /* have been seen in the wild. */
+
+ static void
+ remove_subset_prefix( FT_String* name )
+ {
+ FT_Int32 idx = 0;
+ FT_Int32 length = (FT_Int32)strlen( name ) + 1;
+ FT_Bool continue_search = 1;
+
+
+ while ( continue_search )
+ {
+ if ( length >= 7 && name[6] == '+' )
+ {
+ for ( idx = 0; idx < 6; idx++ )
+ {
+ /* ASCII uppercase letters */
+ if ( !( 'A' <= name[idx] && name[idx] <= 'Z' ) )
+ continue_search = 0;
+ }
+
+ if ( continue_search )
+ {
+ for ( idx = 7; idx < length; idx++ )
+ name[idx - 7] = name[idx];
+ length -= 7;
+ }
+ }
+ else
+ continue_search = 0;
+ }
+ }
+
+
+ /* Remove the style part from the family name (if present). */
+
+ static void
+ remove_style( FT_String* family_name,
+ const FT_String* style_name )
+ {
+ FT_Int32 family_name_length, style_name_length;
+
+
+ family_name_length = (FT_Int32)strlen( family_name );
+ style_name_length = (FT_Int32)strlen( style_name );
+
+ if ( family_name_length > style_name_length )
+ {
+ FT_Int idx;
+
+
+ for ( idx = 1; idx <= style_name_length; ++idx )
+ {
+ if ( family_name[family_name_length - idx] !=
+ style_name[style_name_length - idx] )
+ break;
+ }
+
+ if ( idx > style_name_length )
+ {
+ /* family_name ends with style_name; remove it */
+ idx = family_name_length - style_name_length - 1;
+
+ /* also remove special characters */
+ /* between real family name and style */
+ while ( idx > 0 &&
+ ( family_name[idx] == '-' ||
+ family_name[idx] == ' ' ||
+ family_name[idx] == '_' ||
+ family_name[idx] == '+' ) )
+ --idx;
+
+ if ( idx > 0 )
+ family_name[idx + 1] = '\0';
+ }
+ }
+ }
+
+
FT_LOCAL_DEF( FT_Error )
cff_face_init( FT_Stream stream,
FT_Face cffface, /* CFF_Face */
@@ -402,34 +485,31 @@
FT_Int num_params,
FT_Parameter* params )
{
- CFF_Face face = (CFF_Face)cffface;
+ CFF_Face face = (CFF_Face)cffface;
FT_Error error;
SFNT_Service sfnt;
FT_Service_PsCMaps psnames;
PSHinter_Service pshinter;
FT_Bool pure_cff = 1;
FT_Bool sfnt_format = 0;
- FT_Library library = cffface->driver->root.library;
+ FT_Library library = cffface->driver->root.library;
-#if 0
- FT_FACE_FIND_GLOBAL_SERVICE( face, sfnt, SFNT );
- FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_NAMES );
- FT_FACE_FIND_GLOBAL_SERVICE( face, pshinter, POSTSCRIPT_HINTER );
-
- if ( !sfnt )
- goto Bad_Format;
-#else
sfnt = (SFNT_Service)FT_Get_Module_Interface(
library, "sfnt" );
if ( !sfnt )
- goto Bad_Format;
+ {
+ FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
pshinter = (PSHinter_Service)FT_Get_Module_Interface(
library, "pshinter" );
-#endif
+
+ FT_TRACE2(( "CFF driver\n" ));
/* create input stream from resource */
if ( FT_STREAM_SEEK( 0 ) )
@@ -441,21 +521,14 @@
{
if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */
{
- FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
- goto Bad_Format;
+ FT_TRACE2(( " not an OpenType/CFF font\n" ));
+ error = FT_THROW( Unknown_File_Format );
+ goto Exit;
}
/* if we are performing a simple font format check, exit immediately */
if ( face_index < 0 )
- return CFF_Err_Ok;
-
- /* UNDOCUMENTED! A CFF in an SFNT can have only a single font. */
- if ( face_index > 0 )
- {
- FT_ERROR(( "cff_face_init: invalid face index\n" ));
- error = CFF_Err_Invalid_Argument;
- goto Exit;
- }
+ return FT_Err_Ok;
sfnt_format = 1;
@@ -467,7 +540,8 @@
pure_cff = 0;
/* load font directory */
- error = sfnt->load_face( stream, face, 0, num_params, params );
+ error = sfnt->load_face( stream, face, face_index,
+ num_params, params );
if ( error )
goto Exit;
}
@@ -477,10 +551,6 @@
error = sfnt->load_cmap( face, stream );
if ( error )
goto Exit;
-
- /* XXX: we don't load the GPOS table, as OpenType Layout */
- /* support will be added later to a layout library on top of */
- /* FreeType 2 */
}
/* now load the CFF part of the file */
@@ -493,12 +563,12 @@
/* rewind to start of file; we are going to load a pure-CFF font */
if ( FT_STREAM_SEEK( 0 ) )
goto Exit;
- error = CFF_Err_Ok;
+ error = FT_Err_Ok;
}
/* now load and parse the CFF table in the file */
{
- CFF_Font cff;
+ CFF_Font cff = NULL;
CFF_FontRecDict dict;
FT_Memory memory = cffface->memory;
FT_Int32 flags;
@@ -514,7 +584,7 @@
goto Exit;
cff->pshinter = pshinter;
- cff->psnames = (void*)psnames;
+ cff->psnames = psnames;
cffface->face_index = face_index;
@@ -534,10 +604,29 @@
" cannot open CFF & CEF fonts\n"
" "
" without the `PSNames' module\n" ));
- goto Bad_Format;
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_UInt idx;
+ FT_String* s;
+
+
+ FT_TRACE4(( "SIDs\n" ));
+
+ /* dump string index, including default strings for convenience */
+ for ( idx = 0; idx < cff->num_strings + 390; idx++ )
+ {
+ s = cff_index_get_sid_string( cff, idx );
+ if ( s )
+ FT_TRACE4((" %5d %s\n", idx, s ));
+ }
}
+#endif /* FT_DEBUG_LEVEL_TRACE */
- if ( !dict->units_per_em )
+ if ( !dict->has_font_matrix )
dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM;
/* Normalize the font matrix so that `matrix->xx' is 1; the */
@@ -582,26 +671,32 @@
FT_Fixed temp;
- if ( sub->units_per_em )
+ if ( sub->has_font_matrix )
{
FT_Long scaling;
- if ( top->units_per_em > 1 && sub->units_per_em > 1 )
- scaling = FT_MIN( top->units_per_em, sub->units_per_em );
- else
- scaling = 1;
-
- FT_Matrix_Multiply_Scaled( &top->font_matrix,
- &sub->font_matrix,
- scaling );
- FT_Vector_Transform_Scaled( &sub->font_offset,
- &top->font_matrix,
- scaling );
-
- sub->units_per_em = FT_MulDiv( sub->units_per_em,
- top->units_per_em,
- scaling );
+ /* if we have a top-level matrix, */
+ /* concatenate the subfont matrix */
+
+ if ( top->has_font_matrix )
+ {
+ if ( top->units_per_em > 1 && sub->units_per_em > 1 )
+ scaling = FT_MIN( top->units_per_em, sub->units_per_em );
+ else
+ scaling = 1;
+
+ FT_Matrix_Multiply_Scaled( &top->font_matrix,
+ &sub->font_matrix,
+ scaling );
+ FT_Vector_Transform_Scaled( &sub->font_offset,
+ &top->font_matrix,
+ scaling );
+
+ sub->units_per_em = FT_MulDiv( sub->units_per_em,
+ top->units_per_em,
+ scaling );
+ }
}
else
{
@@ -620,16 +715,6 @@
{
*upm = FT_DivFix( *upm, temp );
- /* if *upm is larger than 100*1000 we divide by 1000 -- */
- /* this can happen if e.g. there is no top-font FontMatrix */
- /* and the subfont FontMatrix already contains the complete */
- /* scaling for the subfont (see section 5.11 of the PLRM) */
-
- /* 100 is a heuristic value */
-
- if ( *upm > 100L * 1000L )
- *upm = ( *upm + 500 ) / 1000;
-
matrix->xx = FT_DivFix( matrix->xx, temp );
matrix->yx = FT_DivFix( matrix->yx, temp );
matrix->xy = FT_DivFix( matrix->xy, temp );
@@ -652,7 +737,7 @@
/* compute number of glyphs */
if ( dict->cid_registry != 0xFFFFU )
- cffface->num_glyphs = cff->charset.max_cid;
+ cffface->num_glyphs = cff->charset.max_cid + 1;
else
cffface->num_glyphs = cff->charstrings_index.count;
@@ -678,24 +763,22 @@
(FT_Short)( dict->underline_thickness >> 16 );
/* retrieve font family & style name */
- cffface->family_name = cff_index_get_name( &cff->name_index,
- face_index );
-
+ cffface->family_name = cff_index_get_name( cff, face_index );
if ( cffface->family_name )
{
- char* full = cff_index_get_sid_string( &cff->string_index,
- dict->full_name,
- psnames );
+ char* full = cff_index_get_sid_string( cff,
+ dict->full_name );
char* fullp = full;
char* family = cffface->family_name;
- char* family_name = 0;
+ char* family_name = NULL;
+
+ remove_subset_prefix( cffface->family_name );
if ( dict->family_name )
{
- family_name = cff_index_get_sid_string( &cff->string_index,
- dict->family_name,
- psnames);
+ family_name = cff_index_get_sid_string( cff,
+ dict->family_name );
if ( family_name )
family = family_name;
}
@@ -735,26 +818,24 @@
/* case, the remaining string in `fullp' will be used as */
/* the style name. */
style_name = cff_strcpy( memory, fullp );
+
+ /* remove the style part from the family name (if present) */
+ remove_style( cffface->family_name, style_name );
}
break;
}
-
- if ( family_name )
- FT_FREE( family_name );
- FT_FREE( full );
}
}
else
{
char *cid_font_name =
- cff_index_get_sid_string( &cff->string_index,
- dict->cid_font_name,
- psnames );
+ cff_index_get_sid_string( cff,
+ dict->cid_font_name );
/* do we have a `/FontName' for a CID-keyed font? */
if ( cid_font_name )
- cffface->family_name = cid_font_name;
+ cffface->family_name = cff_strcpy( memory, cid_font_name );
}
if ( style_name )
@@ -767,25 +848,25 @@
/* */
/* Compute face flags. */
/* */
- flags = (FT_UInt32)( FT_FACE_FLAG_SCALABLE | /* scalable outlines */
- FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
- FT_FACE_FLAG_HINTER ); /* has native hinter */
+ flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
+ FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
+ FT_FACE_FLAG_HINTER; /* has native hinter */
if ( sfnt_format )
- flags |= (FT_UInt32)FT_FACE_FLAG_SFNT;
+ flags |= FT_FACE_FLAG_SFNT;
/* fixed width font? */
if ( dict->is_fixed_pitch )
- flags |= (FT_UInt32)FT_FACE_FLAG_FIXED_WIDTH;
+ flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
#if 0
/* kerning available? */
if ( face->kern_pairs )
- flags |= (FT_UInt32)FT_FACE_FLAG_KERNING;
+ flags |= FT_FACE_FLAG_KERNING;
#endif
- cffface->face_flags = flags;
+ cffface->face_flags |= flags;
/*******************************************************************/
/* */
@@ -797,16 +878,14 @@
flags |= FT_STYLE_FLAG_ITALIC;
{
- char *weight = cff_index_get_sid_string( &cff->string_index,
- dict->weight,
- psnames );
+ char *weight = cff_index_get_sid_string( cff,
+ dict->weight );
if ( weight )
if ( !ft_strcmp( weight, "Bold" ) ||
!ft_strcmp( weight, "Black" ) )
flags |= FT_STYLE_FLAG_BOLD;
- FT_FREE( weight );
}
/* double check */
@@ -849,13 +928,14 @@
{
cmap = cffface->charmaps[nn];
- /* Windows Unicode (3,1)? */
- if ( cmap->platform_id == 3 && cmap->encoding_id == 1 )
+ /* Windows Unicode? */
+ if ( cmap->platform_id == TT_PLATFORM_MICROSOFT &&
+ cmap->encoding_id == TT_MS_ID_UNICODE_CS )
goto Skip_Unicode;
- /* Deprecated Unicode platform id? */
- if ( cmap->platform_id == 0 )
- goto Skip_Unicode; /* Standard Unicode (deprecated) */
+ /* Apple Unicode platform id? */
+ if ( cmap->platform_id == TT_PLATFORM_APPLE_UNICODE )
+ goto Skip_Unicode; /* Apple Unicode */
}
/* since CID-keyed fonts don't contain glyph names, we can't */
@@ -865,13 +945,18 @@
/* we didn't find a Unicode charmap -- synthesize one */
cmaprec.face = cffface;
- cmaprec.platform_id = 3;
- cmaprec.encoding_id = 1;
+ cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
+ cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
cmaprec.encoding = FT_ENCODING_UNICODE;
nn = (FT_UInt)cffface->num_charmaps;
- FT_CMap_New( &FT_CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, &cmaprec, NULL );
+ error = FT_CMap_New( &CFF_CMAP_UNICODE_CLASS_REC_GET, NULL,
+ &cmaprec, NULL );
+ if ( error &&
+ FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
+ goto Exit;
+ error = FT_Err_Ok;
/* if no Unicode charmap was previously selected, select this one */
if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps )
@@ -884,38 +969,34 @@
cmaprec.face = cffface;
- cmaprec.platform_id = 7; /* Adobe platform id */
+ cmaprec.platform_id = TT_PLATFORM_ADOBE; /* Adobe platform id */
if ( encoding->offset == 0 )
{
cmaprec.encoding_id = TT_ADOBE_ID_STANDARD;
cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD;
- clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
+ clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET;
}
else if ( encoding->offset == 1 )
{
cmaprec.encoding_id = TT_ADOBE_ID_EXPERT;
cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT;
- clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
+ clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET;
}
else
{
cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM;
cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM;
- clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
+ clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET;
}
- FT_CMap_New( clazz, NULL, &cmaprec, NULL );
+ error = FT_CMap_New( clazz, NULL, &cmaprec, NULL );
}
}
}
Exit:
return error;
-
- Bad_Format:
- error = CFF_Err_Unknown_File_Format;
- goto Exit;
}
@@ -950,16 +1031,35 @@
FT_LOCAL_DEF( FT_Error )
- cff_driver_init( FT_Module module )
+ cff_driver_init( FT_Module module ) /* CFF_Driver */
{
- FT_UNUSED( module );
+ CFF_Driver driver = (CFF_Driver)module;
+
+
+ /* set default property values, cf. `ftcffdrv.h' */
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ driver->hinting_engine = FT_CFF_HINTING_FREETYPE;
+#else
+ driver->hinting_engine = FT_CFF_HINTING_ADOBE;
+#endif
+
+ driver->no_stem_darkening = FALSE;
+
+ driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
+ driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
+ driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
+ driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
+ driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
+ driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
+ driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
+ driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
- return CFF_Err_Ok;
+ return FT_Err_Ok;
}
FT_LOCAL_DEF( void )
- cff_driver_done( FT_Module module )
+ cff_driver_done( FT_Module module ) /* CFF_Driver */
{
FT_UNUSED( module );
}
diff --git a/src/3rdparty/freetype/src/cff/cffobjs.h b/src/3rdparty/freetype/src/cff/cffobjs.h
index 3c81cee009..dfbf9a96b0 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-2001, 2002, 2003, 2004, 2006, 2007, 2008 by */
+/* Copyright 1996-2004, 2006-2008, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -112,12 +112,16 @@ FT_BEGIN_HEADER
/***********************************************************************/
/* */
- /* TrueType driver class. */
+ /* CFF driver class. */
/* */
typedef struct CFF_DriverRec_
{
FT_DriverRec root;
- void* extension_component;
+
+ FT_UInt hinting_engine;
+ FT_Bool no_stem_darkening;
+
+ FT_Int darken_params[8];
} CFF_DriverRec;
@@ -167,10 +171,10 @@ FT_BEGIN_HEADER
/* Driver functions */
/* */
FT_LOCAL( FT_Error )
- cff_driver_init( FT_Module module );
+ cff_driver_init( FT_Module module ); /* CFF_Driver */
FT_LOCAL( void )
- cff_driver_done( FT_Module module );
+ cff_driver_done( FT_Module module ); /* CFF_Driver */
FT_END_HEADER
diff --git a/src/3rdparty/freetype/src/cff/cffparse.c b/src/3rdparty/freetype/src/cff/cffparse.c
index 01266a193d..c79ab623dc 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-2001, 2002, 2003, 2004, 2007, 2008, 2009 by */
+/* Copyright 1996-2004, 2007-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -35,8 +35,6 @@
#define FT_COMPONENT trace_cffparse
-
-
FT_LOCAL_DEF( void )
cff_parser_init( CFF_Parser parser,
FT_UInt code,
@@ -67,19 +65,17 @@
if ( p + 2 > limit )
goto Bad;
- val = (FT_Short)( ( (FT_Int)p[0] << 8 ) | p[1] );
- p += 2;
+ val = (FT_Short)( ( (FT_UShort)p[0] << 8 ) | p[1] );
}
else if ( v == 29 )
{
if ( p + 4 > limit )
goto Bad;
- val = ( (FT_Long)p[0] << 24 ) |
- ( (FT_Long)p[1] << 16 ) |
- ( (FT_Long)p[2] << 8 ) |
- p[3];
- p += 4;
+ val = (FT_Long)( ( (FT_ULong)p[0] << 24 ) |
+ ( (FT_ULong)p[1] << 16 ) |
+ ( (FT_ULong)p[2] << 8 ) |
+ (FT_ULong)p[3] );
}
else if ( v < 247 )
{
@@ -91,7 +87,6 @@
goto Bad;
val = ( v - 247 ) * 256 + p[0] + 108;
- p++;
}
else
{
@@ -99,7 +94,6 @@
goto Bad;
val = -( v - 251 ) * 256 - p[0] - 108;
- p++;
}
Exit:
@@ -107,6 +101,7 @@
Bad:
val = 0;
+ FT_TRACE4(( "!!!END OF DATA:!!!" ));
goto Exit;
}
@@ -137,26 +132,23 @@
FT_UInt nib;
FT_UInt phase;
- FT_Long result, number, rest, exponent;
- FT_Int sign = 0, exponent_sign = 0;
+ FT_Long result, number, exponent;
+ FT_Int sign = 0, exponent_sign = 0, have_overflow = 0;
FT_Long exponent_add, integer_length, fraction_length;
if ( scaling )
- *scaling = 0;
+ *scaling = 0;
result = 0;
number = 0;
- rest = 0;
exponent = 0;
exponent_add = 0;
integer_length = 0;
fraction_length = 0;
- FT_UNUSED( rest );
-
/* First of all, read the integer part. */
phase = 4;
@@ -170,7 +162,7 @@
/* Make sure we don't read past the end. */
if ( p >= limit )
- goto Exit;
+ goto Bad;
}
/* Get the nibble. */
@@ -196,7 +188,7 @@
}
/* Read fraction part, if any. */
- if ( nib == 0xa )
+ if ( nib == 0xA )
for (;;)
{
/* If we entered this iteration with phase == 4, we need */
@@ -207,7 +199,7 @@
/* Make sure we don't read past the end. */
if ( p >= limit )
- goto Exit;
+ goto Bad;
}
/* Get the nibble. */
@@ -246,7 +238,7 @@
/* Make sure we don't read past the end. */
if ( p >= limit )
- goto Exit;
+ goto Bad;
}
/* Get the nibble. */
@@ -255,17 +247,28 @@
if ( nib >= 10 )
break;
- exponent = exponent * 10 + nib;
-
/* Arbitrarily limit exponent. */
if ( exponent > 1000 )
- goto Exit;
+ have_overflow = 1;
+ else
+ exponent = exponent * 10 + nib;
}
if ( exponent_sign )
exponent = -exponent;
}
+ if ( !number )
+ goto Exit;
+
+ if ( have_overflow )
+ {
+ if ( exponent_sign )
+ goto Underflow;
+ else
+ goto Overflow;
+ }
+
/* We don't check `power_ten' and `exponent_add'. */
exponent += power_ten + exponent_add;
@@ -291,20 +294,25 @@
/* Make `scaling' as small as possible. */
new_fraction_length = FT_MIN( exponent, 5 );
- exponent -= new_fraction_length;
shift = new_fraction_length - fraction_length;
- number *= power_tens[shift];
- if ( number > 0x7FFFL )
+ if ( shift > 0 )
{
- number /= 10;
- exponent += 1;
+ exponent -= new_fraction_length;
+ number *= power_tens[shift];
+ if ( number > 0x7FFFL )
+ {
+ number /= 10;
+ exponent += 1;
+ }
}
+ else
+ exponent -= fraction_length;
}
else
exponent -= fraction_length;
- result = number << 16;
+ result = (FT_Long)( (FT_ULong)number << 16 );
*scaling = exponent;
}
}
@@ -327,16 +335,25 @@
integer_length += exponent;
fraction_length -= exponent;
- /* Check for overflow and underflow. */
- if ( FT_ABS( integer_length ) > 5 )
- goto Exit;
+ if ( integer_length > 5 )
+ goto Overflow;
+ if ( integer_length < -5 )
+ goto Underflow;
/* Remove non-significant digits. */
- if ( integer_length < 0 ) {
+ if ( integer_length < 0 )
+ {
number /= power_tens[-integer_length];
fraction_length += integer_length;
}
+ /* this can only happen if exponent was non-zero */
+ if ( fraction_length == 10 )
+ {
+ number /= 10;
+ fraction_length -= 1;
+ }
+
/* Convert into 16.16 format. */
if ( fraction_length > 0 )
{
@@ -350,17 +367,32 @@
number *= power_tens[-fraction_length];
if ( number > 0x7FFFL )
- goto Exit;
+ goto Overflow;
- result = number << 16;
+ result = (FT_Long)( (FT_ULong)number << 16 );
}
}
+ Exit:
if ( sign )
result = -result;
- Exit:
return result;
+
+ Overflow:
+ result = 0x7FFFFFFFL;
+ FT_TRACE4(( "!!!OVERFLOW:!!!" ));
+ goto Exit;
+
+ Underflow:
+ result = 0;
+ FT_TRACE4(( "!!!UNDERFLOW:!!!" ));
+ goto Exit;
+
+ Bad:
+ result = 0;
+ FT_TRACE4(( "!!!END OF DATA:!!!" ));
+ goto Exit;
}
@@ -375,10 +407,44 @@
/* read a floating point number, either integer or real */
static FT_Fixed
+ do_fixed( FT_Byte** d,
+ FT_Long scaling )
+ {
+ if ( **d == 30 )
+ return cff_parse_real( d[0], d[1], scaling, NULL );
+ else
+ {
+ FT_Long val = cff_parse_integer( d[0], d[1] );
+
+
+ if ( scaling )
+ val *= power_tens[scaling];
+
+ if ( val > 0x7FFF )
+ {
+ val = 0x7FFFFFFFL;
+ goto Overflow;
+ }
+ else if ( val < -0x7FFF )
+ {
+ val = -0x7FFFFFFFL;
+ goto Overflow;
+ }
+
+ return (FT_Long)( (FT_ULong)val << 16 );
+
+ Overflow:
+ FT_TRACE4(( "!!!OVERFLOW:!!!" ));
+ return val;
+ }
+ }
+
+
+ /* read a floating point number, either integer or real */
+ static FT_Fixed
cff_parse_fixed( FT_Byte** d )
{
- return **d == 30 ? cff_parse_real( d[0], d[1], 0, NULL )
- : cff_parse_integer( d[0], d[1] ) << 16;
+ return do_fixed( d, 0 );
}
@@ -388,9 +454,7 @@
cff_parse_fixed_scaled( FT_Byte** d,
FT_Long scaling )
{
- return **d == 30 ? cff_parse_real( d[0], d[1], scaling, NULL )
- : ( cff_parse_integer( d[0], d[1] ) *
- power_tens[scaling] ) << 16;
+ return do_fixed( d, scaling );
}
@@ -433,7 +497,7 @@
else
{
*scaling = 0;
- return number << 16;
+ return (FT_Long)( (FT_ULong)number << 16 );
}
}
}
@@ -447,7 +511,7 @@
FT_Vector* offset = &dict->font_offset;
FT_ULong* upm = &dict->units_per_em;
FT_Byte** data = parser->stack;
- FT_Error error = CFF_Err_Stack_Underflow;
+ FT_Error error = FT_ERR( Stack_Underflow );
if ( parser->top >= parser->stack + 6 )
@@ -455,7 +519,9 @@
FT_Long scaling;
- error = CFF_Err_Ok;
+ error = FT_Err_Ok;
+
+ dict->has_font_matrix = TRUE;
/* We expect a well-formed font matrix, this is, the matrix elements */
/* `xx' and `yy' are of approximately the same magnitude. To avoid */
@@ -470,9 +536,15 @@
if ( scaling < 0 || scaling > 9 )
{
/* Return default matrix in case of unlikely values. */
+
+ FT_TRACE1(( "cff_parse_font_matrix:"
+ " strange scaling value for xx element (%d),\n"
+ " "
+ " using default matrix\n", scaling ));
+
matrix->xx = 0x10000L;
matrix->yx = 0;
- matrix->yx = 0;
+ matrix->xy = 0;
matrix->yy = 0x10000L;
offset->x = 0;
offset->y = 0;
@@ -488,6 +560,14 @@
offset->y = cff_parse_fixed_scaled( data, scaling );
*upm = power_tens[scaling];
+
+ FT_TRACE4(( " [%f %f %f %f %f %f]\n",
+ (double)matrix->xx / *upm / 65536,
+ (double)matrix->xy / *upm / 65536,
+ (double)matrix->yx / *upm / 65536,
+ (double)matrix->yy / *upm / 65536,
+ (double)offset->x / *upm / 65536,
+ (double)offset->y / *upm / 65536 ));
}
Exit:
@@ -504,7 +584,7 @@
FT_Error error;
- error = CFF_Err_Stack_Underflow;
+ error = FT_ERR( Stack_Underflow );
if ( parser->top >= parser->stack + 4 )
{
@@ -512,7 +592,13 @@
bbox->yMin = FT_RoundFix( cff_parse_fixed( data++ ) );
bbox->xMax = FT_RoundFix( cff_parse_fixed( data++ ) );
bbox->yMax = FT_RoundFix( cff_parse_fixed( data ) );
- error = CFF_Err_Ok;
+ error = FT_Err_Ok;
+
+ FT_TRACE4(( " [%d %d %d %d]\n",
+ bbox->xMin / 65536,
+ bbox->yMin / 65536,
+ bbox->xMax / 65536,
+ bbox->yMax / 65536 ));
}
return error;
@@ -527,13 +613,16 @@
FT_Error error;
- error = CFF_Err_Stack_Underflow;
+ error = FT_ERR( Stack_Underflow );
if ( parser->top >= parser->stack + 2 )
{
dict->private_size = cff_parse_num( data++ );
dict->private_offset = cff_parse_num( data );
- error = CFF_Err_Ok;
+ FT_TRACE4(( " %lu %lu\n",
+ dict->private_size, dict->private_offset ));
+
+ error = FT_Err_Ok;
}
return error;
@@ -548,73 +637,83 @@
FT_Error error;
- error = CFF_Err_Stack_Underflow;
+ error = FT_ERR( Stack_Underflow );
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( data++ );
+ dict->cid_ordering = (FT_UInt)cff_parse_num( data++ );
if ( **data == 30 )
FT_TRACE1(( "cff_parse_cid_ros: real supplement is rounded\n" ));
dict->cid_supplement = cff_parse_num( data );
if ( dict->cid_supplement < 0 )
FT_TRACE1(( "cff_parse_cid_ros: negative supplement %d is found\n",
dict->cid_supplement ));
- error = CFF_Err_Ok;
+ error = FT_Err_Ok;
+
+ FT_TRACE4(( " %d %d %d\n",
+ dict->cid_registry,
+ dict->cid_ordering,
+ dict->cid_supplement ));
}
return error;
}
-#define CFF_FIELD_NUM( code, name ) \
- CFF_FIELD( code, name, cff_kind_num )
-#define CFF_FIELD_FIXED( code, name ) \
- CFF_FIELD( code, name, cff_kind_fixed )
-#define CFF_FIELD_FIXED_1000( code, name ) \
- CFF_FIELD( code, name, cff_kind_fixed_thousand )
-#define CFF_FIELD_STRING( code, name ) \
- CFF_FIELD( code, name, cff_kind_string )
-#define CFF_FIELD_BOOL( code, name ) \
- CFF_FIELD( code, name, cff_kind_bool )
-#define CFF_FIELD_DELTA( code, name, max ) \
- CFF_FIELD( code, name, cff_kind_delta )
+#define CFF_FIELD_NUM( code, name, id ) \
+ CFF_FIELD( code, name, id, cff_kind_num )
+#define CFF_FIELD_FIXED( code, name, id ) \
+ CFF_FIELD( code, name, id, cff_kind_fixed )
+#define CFF_FIELD_FIXED_1000( code, name, id ) \
+ CFF_FIELD( code, name, id, cff_kind_fixed_thousand )
+#define CFF_FIELD_STRING( code, name, id ) \
+ CFF_FIELD( code, name, id, cff_kind_string )
+#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
-#define CFF_FIELD_CALLBACK( code, name ) \
- { \
- cff_kind_callback, \
- code | CFFCODE, \
- 0, 0, \
- cff_parse_ ## name, \
- 0, 0 \
- },
#undef CFF_FIELD
-#define CFF_FIELD( code, name, kind ) \
- { \
- kind, \
- code | CFFCODE, \
- FT_FIELD_OFFSET( name ), \
- FT_FIELD_SIZE( name ), \
- 0, 0, 0 \
+#undef CFF_FIELD_DELTA
+
+
+#ifndef FT_DEBUG_LEVEL_TRACE
+
+
+#define CFF_FIELD_CALLBACK( code, name, id ) \
+ { \
+ cff_kind_callback, \
+ code | CFFCODE, \
+ 0, 0, \
+ cff_parse_ ## name, \
+ 0, 0 \
},
-#undef CFF_FIELD_DELTA
-#define CFF_FIELD_DELTA( code, name, max ) \
- { \
- cff_kind_delta, \
- code | CFFCODE, \
- FT_FIELD_OFFSET( name ), \
- FT_FIELD_SIZE_DELTA( name ), \
- 0, \
- max, \
- FT_FIELD_OFFSET( num_ ## name ) \
- },
+#define CFF_FIELD( code, name, id, kind ) \
+ { \
+ kind, \
+ code | CFFCODE, \
+ FT_FIELD_OFFSET( name ), \
+ FT_FIELD_SIZE( name ), \
+ 0, 0, 0 \
+ },
+
+#define CFF_FIELD_DELTA( code, name, max, id ) \
+ { \
+ cff_kind_delta, \
+ code | CFFCODE, \
+ FT_FIELD_OFFSET( name ), \
+ FT_FIELD_SIZE_DELTA( name ), \
+ 0, \
+ max, \
+ FT_FIELD_OFFSET( num_ ## name ) \
+ },
static const CFF_Field_Handler cff_field_handlers[] =
{
@@ -625,83 +724,200 @@
};
+#else /* FT_DEBUG_LEVEL_TRACE */
+
+
+
+#define CFF_FIELD_CALLBACK( code, name, id ) \
+ { \
+ cff_kind_callback, \
+ code | CFFCODE, \
+ 0, 0, \
+ cff_parse_ ## name, \
+ 0, 0, \
+ id \
+ },
+
+#define CFF_FIELD( code, name, id, kind ) \
+ { \
+ kind, \
+ code | CFFCODE, \
+ FT_FIELD_OFFSET( name ), \
+ FT_FIELD_SIZE( name ), \
+ 0, 0, 0, \
+ id \
+ },
+
+#define CFF_FIELD_DELTA( code, name, max, id ) \
+ { \
+ cff_kind_delta, \
+ code | CFFCODE, \
+ FT_FIELD_OFFSET( name ), \
+ FT_FIELD_SIZE_DELTA( name ), \
+ 0, \
+ max, \
+ FT_FIELD_OFFSET( num_ ## name ), \
+ id \
+ },
+
+ static const CFF_Field_Handler cff_field_handlers[] =
+ {
+
+#include "cfftoken.h"
+
+ { 0, 0, 0, 0, 0, 0, 0, 0 }
+ };
+
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+
#else /* FT_CONFIG_OPTION_PIC */
- void FT_Destroy_Class_cff_field_handlers(FT_Library library, CFF_Field_Handler* clazz)
+
+ void
+ FT_Destroy_Class_cff_field_handlers( FT_Library library,
+ CFF_Field_Handler* clazz )
{
- FT_Memory memory = library->memory;
+ FT_Memory memory = library->memory;
+
+
if ( clazz )
FT_FREE( clazz );
}
- FT_Error FT_Create_Class_cff_field_handlers(FT_Library library, CFF_Field_Handler** output_class)
+
+ FT_Error
+ FT_Create_Class_cff_field_handlers( FT_Library library,
+ CFF_Field_Handler** output_class )
{
- CFF_Field_Handler* clazz;
- FT_Error error;
- FT_Memory memory = library->memory;
- int i=0;
+ CFF_Field_Handler* clazz = NULL;
+ FT_Error error;
+ FT_Memory memory = library->memory;
+
+ int i = 0;
+
#undef CFF_FIELD
+#define CFF_FIELD( code, name, id, kind ) i++;
#undef CFF_FIELD_DELTA
+#define CFF_FIELD_DELTA( code, name, max, id ) i++;
#undef CFF_FIELD_CALLBACK
-#define CFF_FIELD_CALLBACK( code, name ) i++;
-#define CFF_FIELD( code, name, kind ) i++;
-#define CFF_FIELD_DELTA( code, name, max ) i++;
+#define CFF_FIELD_CALLBACK( code, name, id ) i++;
#include "cfftoken.h"
- i++;/*{ 0, 0, 0, 0, 0, 0, 0 }*/
- if ( FT_ALLOC( clazz, sizeof(CFF_Field_Handler)*i ) )
+ i++; /* { 0, 0, 0, 0, 0, 0, 0 } */
+
+ if ( FT_ALLOC( clazz, sizeof ( CFF_Field_Handler ) * i ) )
return error;
- i=0;
-#undef CFF_FIELD
-#undef CFF_FIELD_DELTA
+ i = 0;
+
+
+#ifndef FT_DEBUG_LEVEL_TRACE
+
+
#undef CFF_FIELD_CALLBACK
+#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \
+ clazz[i].kind = cff_kind_callback; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = 0; \
+ clazz[i].size = 0; \
+ clazz[i].reader = cff_parse_ ## name_; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ i++;
+
+#undef CFF_FIELD
+#define CFF_FIELD( code_, name_, id_, kind_ ) \
+ clazz[i].kind = kind_; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
+ clazz[i].size = FT_FIELD_SIZE( name_ ); \
+ clazz[i].reader = 0; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ i++; \
+
+#undef CFF_FIELD_DELTA
+#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \
+ clazz[i].kind = cff_kind_delta; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
+ clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
+ clazz[i].reader = 0; \
+ clazz[i].array_max = max_; \
+ clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
+ i++;
+
+#include "cfftoken.h"
+
+ clazz[i].kind = 0;
+ clazz[i].code = 0;
+ clazz[i].offset = 0;
+ clazz[i].size = 0;
+ clazz[i].reader = 0;
+ clazz[i].array_max = 0;
+ clazz[i].count_offset = 0;
-#define CFF_FIELD_CALLBACK( code_, name_ ) \
- clazz[i].kind = cff_kind_callback; \
- clazz[i].code = code_ | CFFCODE; \
- clazz[i].offset = 0; \
- clazz[i].size = 0; \
- clazz[i].reader = cff_parse_ ## name_; \
- clazz[i].array_max = 0; \
- clazz[i].count_offset = 0; \
- i++;
+
+#else /* FT_DEBUG_LEVEL_TRACE */
+
+
+#undef CFF_FIELD_CALLBACK
+#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \
+ clazz[i].kind = cff_kind_callback; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = 0; \
+ clazz[i].size = 0; \
+ clazz[i].reader = cff_parse_ ## name_; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ clazz[i].id = id_; \
+ i++;
#undef CFF_FIELD
-#define CFF_FIELD( code_, name_, kind_ ) \
- clazz[i].kind = kind_; \
- clazz[i].code = code_ | CFFCODE; \
- clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
- clazz[i].size = FT_FIELD_SIZE( name_ ); \
- clazz[i].reader = 0; \
- clazz[i].array_max = 0; \
- clazz[i].count_offset = 0; \
- i++; \
+#define CFF_FIELD( code_, name_, id_, kind_ ) \
+ clazz[i].kind = kind_; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
+ clazz[i].size = FT_FIELD_SIZE( name_ ); \
+ clazz[i].reader = 0; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ clazz[i].id = id_; \
+ i++; \
#undef CFF_FIELD_DELTA
-#define CFF_FIELD_DELTA( code_, name_, max_ ) \
- clazz[i].kind = cff_kind_delta; \
- clazz[i].code = code_ | CFFCODE; \
- clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
- clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
- clazz[i].reader = 0; \
- clazz[i].array_max = max_; \
- clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
- i++;
+#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \
+ clazz[i].kind = cff_kind_delta; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
+ clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
+ clazz[i].reader = 0; \
+ clazz[i].array_max = max_; \
+ clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
+ clazz[i].id = id_; \
+ i++;
#include "cfftoken.h"
- clazz[i].kind = 0;
- clazz[i].code = 0;
- clazz[i].offset = 0;
- clazz[i].size = 0;
- clazz[i].reader = 0;
- clazz[i].array_max = 0;
+ clazz[i].kind = 0;
+ clazz[i].code = 0;
+ clazz[i].offset = 0;
+ clazz[i].size = 0;
+ clazz[i].reader = 0;
+ clazz[i].array_max = 0;
clazz[i].count_offset = 0;
+ clazz[i].id = 0;
+
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
*output_class = clazz;
+
return FT_Err_Ok;
}
@@ -715,9 +931,9 @@
FT_Byte* limit )
{
FT_Byte* p = start;
- FT_Error error = CFF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Library library = parser->library;
- FT_UNUSED(library);
+ FT_UNUSED( library );
parser->top = parser->stack;
@@ -789,7 +1005,7 @@
}
code = code | parser->object_code;
- for ( field = FT_CFF_FIELD_HANDLERS_GET; field->kind; field++ )
+ for ( field = CFF_FIELD_HANDLERS_GET; field->kind; field++ )
{
if ( field->code == (FT_Int)code )
{
@@ -798,6 +1014,10 @@
FT_Byte* q = (FT_Byte*)parser->object + field->offset;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_TRACE4(( " %s", field->id ));
+#endif
+
/* check that we have enough arguments -- except for */
/* delta encoded arrays, which can be empty */
if ( field->kind != cff_kind_delta && num_args < 1 )
@@ -836,6 +1056,34 @@
default: /* for 64-bit systems */
*(FT_Long*)q = val;
}
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ switch ( field->kind )
+ {
+ case cff_kind_bool:
+ FT_TRACE4(( " %s\n", val ? "true" : "false" ));
+ break;
+
+ case cff_kind_string:
+ FT_TRACE4(( " %ld (SID)\n", val ));
+ break;
+
+ case cff_kind_num:
+ FT_TRACE4(( " %ld\n", val ));
+ break;
+
+ case cff_kind_fixed:
+ FT_TRACE4(( " %f\n", (double)val / 65536 ));
+ break;
+
+ case cff_kind_fixed_thousand:
+ FT_TRACE4(( " %f\n", (double)val / 65536 / 1000 ));
+
+ default:
+ ; /* never reached */
+ }
+#endif
+
break;
case cff_kind_delta:
@@ -849,6 +1097,8 @@
if ( num_args > field->array_max )
num_args = field->array_max;
+ FT_TRACE4(( " [" ));
+
/* store count */
*qcount = (FT_Byte)num_args;
@@ -874,9 +1124,13 @@
*(FT_Long*)q = val;
}
+ FT_TRACE4(( " %ld", val ));
+
q += field->size;
num_args--;
}
+
+ FT_TRACE4(( "]\n" ));
}
break;
@@ -903,15 +1157,15 @@
return error;
Stack_Overflow:
- error = CFF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
Stack_Underflow:
- error = CFF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
Syntax_Error:
- error = CFF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
diff --git a/src/3rdparty/freetype/src/cff/cffparse.h b/src/3rdparty/freetype/src/cff/cffparse.h
index 7e2c00a044..61d91ed2e2 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-2001, 2002, 2003 by */
+/* Copyright 1996-2003, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -90,6 +90,10 @@ FT_BEGIN_HEADER
FT_UInt array_max;
FT_UInt count_offset;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ const char* id;
+#endif
+
} CFF_Field_Handler;
diff --git a/src/3rdparty/freetype/src/cff/cffpic.c b/src/3rdparty/freetype/src/cff/cffpic.c
index 568956d6a9..f22e4f0d53 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 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,77 +19,116 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
+#include "cffcmap.h"
#include "cffpic.h"
+#include "cfferrs.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from cffdrivr.c */
- FT_Error FT_Create_Class_cff_services( FT_Library, FT_ServiceDescRec**);
- void FT_Destroy_Class_cff_services( FT_Library, FT_ServiceDescRec*);
- void FT_Init_Class_cff_service_ps_info( FT_Library, FT_Service_PsInfoRec*);
- void FT_Init_Class_cff_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
- void FT_Init_Class_cff_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
- void FT_Init_Class_cff_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
- void FT_Init_Class_cff_service_cid_info( FT_Library, FT_Service_CIDRec*);
+ FT_Error
+ FT_Create_Class_cff_services( FT_Library library,
+ FT_ServiceDescRec** output_class );
+ void
+ FT_Destroy_Class_cff_services( FT_Library library,
+ FT_ServiceDescRec* clazz );
+ void
+ FT_Init_Class_cff_service_ps_info( FT_Library library,
+ FT_Service_PsInfoRec* clazz );
+ void
+ FT_Init_Class_cff_service_glyph_dict( FT_Library library,
+ FT_Service_GlyphDictRec* clazz );
+ void
+ FT_Init_Class_cff_service_ps_name( FT_Library library,
+ FT_Service_PsFontNameRec* clazz );
+ void
+ FT_Init_Class_cff_service_get_cmap_info( FT_Library library,
+ FT_Service_TTCMapsRec* clazz );
+ void
+ FT_Init_Class_cff_service_cid_info( FT_Library library,
+ FT_Service_CIDRec* clazz );
/* forward declaration of PIC init functions from cffparse.c */
- FT_Error FT_Create_Class_cff_field_handlers( FT_Library, CFF_Field_Handler**);
- void FT_Destroy_Class_cff_field_handlers( FT_Library, CFF_Field_Handler*);
+ FT_Error
+ FT_Create_Class_cff_field_handlers( FT_Library library,
+ CFF_Field_Handler** output_class );
+ void
+ FT_Destroy_Class_cff_field_handlers( FT_Library library,
+ CFF_Field_Handler* clazz );
- /* forward declaration of PIC init functions from cffcmap.c */
- void FT_Init_Class_cff_cmap_encoding_class_rec( FT_Library, FT_CMap_ClassRec*);
- void FT_Init_Class_cff_cmap_unicode_class_rec( FT_Library, FT_CMap_ClassRec*);
void
- cff_driver_class_pic_free( FT_Library library )
+ cff_driver_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->cff )
{
- CffModulePIC* container = (CffModulePIC*)pic_container->cff;
- if(container->cff_services)
- FT_Destroy_Class_cff_services(library, container->cff_services);
+ CffModulePIC* container = (CffModulePIC*)pic_container->cff;
+
+
+ if ( container->cff_services )
+ FT_Destroy_Class_cff_services( library,
+ container->cff_services );
container->cff_services = NULL;
- if(container->cff_field_handlers)
- FT_Destroy_Class_cff_field_handlers(library, container->cff_field_handlers);
+ if ( container->cff_field_handlers )
+ FT_Destroy_Class_cff_field_handlers(
+ library, container->cff_field_handlers );
container->cff_field_handlers = NULL;
FT_FREE( container );
pic_container->cff = NULL;
}
}
+
FT_Error
- cff_driver_class_pic_init( FT_Library library )
+ cff_driver_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- CffModulePIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ CffModulePIC* container = NULL;
+ FT_Memory memory = library->memory;
+
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->cff = container;
- /* initialize pointer table - this is how the module usually expects this data */
- error = FT_Create_Class_cff_services(library, &container->cff_services);
- if(error)
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ error = FT_Create_Class_cff_services( library,
+ &container->cff_services );
+ if ( error )
goto Exit;
- error = FT_Create_Class_cff_field_handlers(library, &container->cff_field_handlers);
- if(error)
+
+ error = FT_Create_Class_cff_field_handlers(
+ library, &container->cff_field_handlers );
+ if ( error )
goto Exit;
- FT_Init_Class_cff_service_ps_info(library, &container->cff_service_ps_info);
- FT_Init_Class_cff_service_glyph_dict(library, &container->cff_service_glyph_dict);
- FT_Init_Class_cff_service_ps_name(library, &container->cff_service_ps_name);
- FT_Init_Class_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info);
- FT_Init_Class_cff_service_cid_info(library, &container->cff_service_cid_info);
- FT_Init_Class_cff_cmap_encoding_class_rec(library, &container->cff_cmap_encoding_class_rec);
- FT_Init_Class_cff_cmap_unicode_class_rec(library, &container->cff_cmap_unicode_class_rec);
-Exit:
- if(error)
- cff_driver_class_pic_free(library);
+
+ FT_Init_Class_cff_service_ps_info(
+ library, &container->cff_service_ps_info );
+ FT_Init_Class_cff_service_glyph_dict(
+ library, &container->cff_service_glyph_dict );
+ FT_Init_Class_cff_service_ps_name(
+ library, &container->cff_service_ps_name );
+ FT_Init_Class_cff_service_get_cmap_info(
+ library, &container->cff_service_get_cmap_info );
+ FT_Init_Class_cff_service_cid_info(
+ library, &container->cff_service_cid_info );
+ FT_Init_Class_cff_cmap_encoding_class_rec(
+ library, &container->cff_cmap_encoding_class_rec );
+ FT_Init_Class_cff_cmap_unicode_class_rec(
+ library, &container->cff_cmap_unicode_class_rec );
+
+ Exit:
+ if ( error )
+ cff_driver_class_pic_free( library );
return error;
}
diff --git a/src/3rdparty/freetype/src/cff/cffpic.h b/src/3rdparty/freetype/src/cff/cffpic.h
index e29d068134..50bab4c173 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 by */
+/* Copyright 2009, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,21 +19,24 @@
#ifndef __CFFPIC_H__
#define __CFFPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
+
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_CFF_SERVICE_PS_INFO_GET cff_service_ps_info
-#define FT_CFF_SERVICE_GLYPH_DICT_GET cff_service_glyph_dict
-#define FT_CFF_SERVICE_PS_NAME_GET cff_service_ps_name
-#define FT_CFF_SERVICE_GET_CMAP_INFO_GET cff_service_get_cmap_info
-#define FT_CFF_SERVICE_CID_INFO_GET cff_service_cid_info
-#define FT_CFF_SERVICES_GET cff_services
-#define FT_CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec
-#define FT_CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec
-#define FT_CFF_FIELD_HANDLERS_GET cff_field_handlers
+
+#define CFF_SERVICE_PS_INFO_GET cff_service_ps_info
+#define CFF_SERVICE_GLYPH_DICT_GET cff_service_glyph_dict
+#define CFF_SERVICE_PS_NAME_GET cff_service_ps_name
+#define CFF_SERVICE_GET_CMAP_INFO_GET cff_service_get_cmap_info
+#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_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
#else /* FT_CONFIG_OPTION_PIC */
@@ -43,30 +46,55 @@ FT_BEGIN_HEADER
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
#include FT_SERVICE_CID_H
+#include FT_SERVICE_PROPERTIES_H
- typedef struct CffModulePIC_
+
+ 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_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_CMap_ClassRec cff_cmap_encoding_class_rec;
+ FT_CMap_ClassRec cff_cmap_unicode_class_rec;
+
} CffModulePIC;
-#define GET_PIC(lib) ((CffModulePIC*)((lib)->pic_container.cff))
-#define FT_CFF_SERVICE_PS_INFO_GET (GET_PIC(library)->cff_service_ps_info)
-#define FT_CFF_SERVICE_GLYPH_DICT_GET (GET_PIC(library)->cff_service_glyph_dict)
-#define FT_CFF_SERVICE_PS_NAME_GET (GET_PIC(library)->cff_service_ps_name)
-#define FT_CFF_SERVICE_GET_CMAP_INFO_GET (GET_PIC(library)->cff_service_get_cmap_info)
-#define FT_CFF_SERVICE_CID_INFO_GET (GET_PIC(library)->cff_service_cid_info)
-#define FT_CFF_SERVICES_GET (GET_PIC(library)->cff_services)
-#define FT_CFF_CMAP_ENCODING_CLASS_REC_GET (GET_PIC(library)->cff_cmap_encoding_class_rec)
-#define FT_CFF_CMAP_UNICODE_CLASS_REC_GET (GET_PIC(library)->cff_cmap_unicode_class_rec)
-#define FT_CFF_FIELD_HANDLERS_GET (GET_PIC(library)->cff_field_handlers)
+
+#define GET_PIC( lib ) \
+ ( (CffModulePIC*)( (lib)->pic_container.cff ) )
+
+#define CFF_SERVICE_PS_INFO_GET \
+ ( GET_PIC( library )->cff_service_ps_info )
+#define CFF_SERVICE_GLYPH_DICT_GET \
+ ( GET_PIC( library )->cff_service_glyph_dict )
+#define CFF_SERVICE_PS_NAME_GET \
+ ( GET_PIC( library )->cff_service_ps_name )
+#define CFF_SERVICE_GET_CMAP_INFO_GET \
+ ( GET_PIC( library )->cff_service_get_cmap_info )
+#define CFF_SERVICE_CID_INFO_GET \
+ ( GET_PIC( library )->cff_service_cid_info )
+#define CFF_SERVICE_PROPERTIES_GET \
+ ( GET_PIC( library )->cff_service_properties )
+#define CFF_SERVICES_GET \
+ ( GET_PIC( library )->cff_services )
+#define CFF_CMAP_ENCODING_CLASS_REC_GET \
+ ( GET_PIC( library )->cff_cmap_encoding_class_rec )
+#define CFF_CMAP_UNICODE_CLASS_REC_GET \
+ ( GET_PIC( library )->cff_cmap_unicode_class_rec )
+#define CFF_FIELD_HANDLERS_GET \
+ ( GET_PIC( library )->cff_field_handlers )
+
+ /* see cffpic.c for the implementation */
+ void
+ cff_driver_class_pic_free( FT_Library library );
+
+ FT_Error
+ cff_driver_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/cff/cfftoken.h b/src/3rdparty/freetype/src/cff/cfftoken.h
index 6bb27d5caf..bcb4276a78 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-2001, 2002, 2003 by */
+/* Copyright 1996-2003, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,48 +22,48 @@
#undef CFFCODE
#define CFFCODE CFFCODE_TOPDICT
- CFF_FIELD_STRING ( 0, version )
- CFF_FIELD_STRING ( 1, notice )
- CFF_FIELD_STRING ( 0x100, copyright )
- CFF_FIELD_STRING ( 2, full_name )
- CFF_FIELD_STRING ( 3, family_name )
- CFF_FIELD_STRING ( 4, weight )
- CFF_FIELD_BOOL ( 0x101, is_fixed_pitch )
- CFF_FIELD_FIXED ( 0x102, italic_angle )
- CFF_FIELD_FIXED ( 0x103, underline_position )
- CFF_FIELD_FIXED ( 0x104, underline_thickness )
- CFF_FIELD_NUM ( 0x105, paint_type )
- CFF_FIELD_NUM ( 0x106, charstring_type )
- CFF_FIELD_CALLBACK( 0x107, font_matrix )
- CFF_FIELD_NUM ( 13, unique_id )
- CFF_FIELD_CALLBACK( 5, font_bbox )
- CFF_FIELD_NUM ( 0x108, stroke_width )
- CFF_FIELD_NUM ( 15, charset_offset )
- CFF_FIELD_NUM ( 16, encoding_offset )
- CFF_FIELD_NUM ( 17, charstrings_offset )
- CFF_FIELD_CALLBACK( 18, private_dict )
- CFF_FIELD_NUM ( 0x114, synthetic_base )
- CFF_FIELD_STRING ( 0x115, embedded_postscript )
+ CFF_FIELD_STRING ( 0, version, "Version" )
+ CFF_FIELD_STRING ( 1, notice, "Notice" )
+ CFF_FIELD_STRING ( 0x100, copyright, "Copyright" )
+ CFF_FIELD_STRING ( 2, full_name, "FullName" )
+ CFF_FIELD_STRING ( 3, family_name, "FamilyName" )
+ CFF_FIELD_STRING ( 4, weight, "Weight" )
+ CFF_FIELD_BOOL ( 0x101, is_fixed_pitch, "isFixedPitch" )
+ CFF_FIELD_FIXED ( 0x102, italic_angle, "ItalicAngle" )
+ CFF_FIELD_FIXED ( 0x103, underline_position, "UnderlinePosition" )
+ CFF_FIELD_FIXED ( 0x104, underline_thickness, "UnderlineThickness" )
+ CFF_FIELD_NUM ( 0x105, paint_type, "PaintType" )
+ CFF_FIELD_NUM ( 0x106, charstring_type, "CharstringType" )
+ CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" )
+ CFF_FIELD_NUM ( 13, unique_id, "UniqueID" )
+ CFF_FIELD_CALLBACK( 5, font_bbox, "FontBBox" )
+ CFF_FIELD_NUM ( 0x108, stroke_width, "StrokeWidth" )
+ CFF_FIELD_NUM ( 15, charset_offset, "charset" )
+ CFF_FIELD_NUM ( 16, encoding_offset, "Encoding" )
+ CFF_FIELD_NUM ( 17, charstrings_offset, "CharStrings" )
+ CFF_FIELD_CALLBACK( 18, private_dict, "Private" )
+ CFF_FIELD_NUM ( 0x114, synthetic_base, "SyntheticBase" )
+ CFF_FIELD_STRING ( 0x115, embedded_postscript, "PostScript" )
#if 0
- CFF_FIELD_STRING ( 0x116, base_font_name )
- CFF_FIELD_DELTA ( 0x117, base_font_blend, 16 )
- CFF_FIELD_CALLBACK( 0x118, multiple_master )
- CFF_FIELD_CALLBACK( 0x119, blend_axis_types )
+ CFF_FIELD_STRING ( 0x116, base_font_name, "BaseFontName" )
+ CFF_FIELD_DELTA ( 0x117, base_font_blend, 16, "BaseFontBlend" )
+ CFF_FIELD_CALLBACK( 0x118, multiple_master, "MultipleMaster" )
+ CFF_FIELD_CALLBACK( 0x119, blend_axis_types, "BlendAxisTypes" )
#endif
- CFF_FIELD_CALLBACK( 0x11E, cid_ros )
- CFF_FIELD_NUM ( 0x11F, cid_font_version )
- CFF_FIELD_NUM ( 0x120, cid_font_revision )
- CFF_FIELD_NUM ( 0x121, cid_font_type )
- CFF_FIELD_NUM ( 0x122, cid_count )
- CFF_FIELD_NUM ( 0x123, cid_uid_base )
- CFF_FIELD_NUM ( 0x124, cid_fd_array_offset )
- CFF_FIELD_NUM ( 0x125, cid_fd_select_offset )
- CFF_FIELD_STRING ( 0x126, cid_font_name )
+ CFF_FIELD_CALLBACK( 0x11E, cid_ros, "ROS" )
+ CFF_FIELD_NUM ( 0x11F, cid_font_version, "CIDFontVersion" )
+ CFF_FIELD_NUM ( 0x120, cid_font_revision, "CIDFontRevision" )
+ CFF_FIELD_NUM ( 0x121, cid_font_type, "CIDFontType" )
+ CFF_FIELD_NUM ( 0x122, cid_count, "CIDCount" )
+ CFF_FIELD_NUM ( 0x123, cid_uid_base, "UIDBase" )
+ CFF_FIELD_NUM ( 0x124, cid_fd_array_offset, "FDArray" )
+ CFF_FIELD_NUM ( 0x125, cid_fd_select_offset, "FDSelect" )
+ CFF_FIELD_STRING ( 0x126, cid_font_name, "FontName" )
#if 0
- CFF_FIELD_NUM ( 0x127, chameleon )
+ CFF_FIELD_NUM ( 0x127, chameleon, "Chameleon" )
#endif
@@ -72,26 +72,26 @@
#undef CFFCODE
#define CFFCODE CFFCODE_PRIVATE
- CFF_FIELD_DELTA ( 6, blue_values, 14 )
- CFF_FIELD_DELTA ( 7, other_blues, 10 )
- CFF_FIELD_DELTA ( 8, family_blues, 14 )
- CFF_FIELD_DELTA ( 9, family_other_blues, 10 )
- CFF_FIELD_FIXED_1000( 0x109, blue_scale )
- CFF_FIELD_NUM ( 0x10A, blue_shift )
- CFF_FIELD_NUM ( 0x10B, blue_fuzz )
- CFF_FIELD_NUM ( 10, standard_width )
- CFF_FIELD_NUM ( 11, standard_height )
- CFF_FIELD_DELTA ( 0x10C, snap_widths, 13 )
- CFF_FIELD_DELTA ( 0x10D, snap_heights, 13 )
- CFF_FIELD_BOOL ( 0x10E, force_bold )
- CFF_FIELD_FIXED ( 0x10F, force_bold_threshold )
- CFF_FIELD_NUM ( 0x110, lenIV )
- CFF_FIELD_NUM ( 0x111, language_group )
- CFF_FIELD_FIXED ( 0x112, expansion_factor )
- CFF_FIELD_NUM ( 0x113, initial_random_seed )
- CFF_FIELD_NUM ( 19, local_subrs_offset )
- CFF_FIELD_NUM ( 20, default_width )
- CFF_FIELD_NUM ( 21, nominal_width )
+ 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_BOOL ( 0x10E, force_bold, "ForceBold" )
+ CFF_FIELD_FIXED ( 0x10F, force_bold_threshold, "ForceBoldThreshold" )
+ CFF_FIELD_NUM ( 0x110, lenIV, "lenIV" )
+ CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
+ CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
+ CFF_FIELD_NUM ( 0x113, initial_random_seed, "initialRandomSeed" )
+ CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
+ CFF_FIELD_NUM ( 20, default_width, "defaultWidthX" )
+ CFF_FIELD_NUM ( 21, nominal_width, "nominalWidthX" )
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cfftypes.h b/src/3rdparty/freetype/src/cff/cfftypes.h
index df92e9a1ac..8727446664 100644
--- a/src/3rdparty/freetype/src/cff/cfftypes.h
+++ b/src/3rdparty/freetype/src/cff/cfftypes.h
@@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008 by */
+/* Copyright 1996-2003, 2006-2008, 2010-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,6 +24,9 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TYPE1_TABLES_H
+#include FT_INTERNAL_SERVICE_H
+#include FT_SERVICE_POSTSCRIPT_CMAPS_H
+#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
@@ -114,6 +117,7 @@ FT_BEGIN_HEADER
FT_Int paint_type;
FT_Int charstring_type;
FT_Matrix font_matrix;
+ FT_Bool has_font_matrix;
FT_ULong units_per_em; /* temporarily used as scaling value also */
FT_Vector font_offset;
FT_ULong unique_id;
@@ -204,14 +208,12 @@ FT_BEGIN_HEADER
CFF_PrivateRec private_dict;
CFF_IndexRec local_subrs_index;
- FT_UInt num_local_subrs;
- FT_Byte** local_subrs;
+ FT_Byte** local_subrs; /* array of pointers into Local Subrs INDEX data */
} CFF_SubFontRec, *CFF_SubFont;
- /* maximum number of sub-fonts in a CID-keyed file */
-#define CFF_MAX_CID_FONTS 32
+#define CFF_MAX_CID_FONTS 256
typedef struct CFF_FontRec_
@@ -229,7 +231,6 @@ FT_BEGIN_HEADER
CFF_IndexRec name_index;
CFF_IndexRec top_dict_index;
- CFF_IndexRec string_index;
CFF_IndexRec global_subrs_index;
CFF_EncodingRec encoding;
@@ -241,9 +242,15 @@ FT_BEGIN_HEADER
CFF_IndexRec local_subrs_index;
FT_String* font_name;
- FT_UInt num_global_subrs;
+
+ /* array of pointers into Global Subrs INDEX data */
FT_Byte** global_subrs;
+ /* array of pointers into String INDEX data stored at string_pool */
+ FT_UInt num_strings;
+ FT_Byte** strings;
+ FT_Byte* string_pool;
+
CFF_SubFontRec top_font;
FT_UInt num_subfonts;
CFF_SubFont subfonts[CFF_MAX_CID_FONTS];
@@ -251,10 +258,10 @@ FT_BEGIN_HEADER
CFF_FDSelectRec fd_select;
/* interface to PostScript hinter */
- void* pshinter;
+ PSHinter_Service pshinter;
/* interface to Postscript Names service */
- void* psnames;
+ FT_Service_PsCMaps psnames;
/* since version 2.3.0 */
PS_FontInfoRec* font_info; /* font info dictionary */
@@ -262,7 +269,10 @@ FT_BEGIN_HEADER
/* since version 2.3.6 */
FT_String* registry;
FT_String* ordering;
-
+
+ /* since version 2.4.12 */
+ FT_Generic cf2_instance;
+
} CFF_FontRec, *CFF_Font;
diff --git a/src/3rdparty/freetype/src/cff/rules.mk b/src/3rdparty/freetype/src/cff/rules.mk
index 4100c80687..13115c2550 100644
--- a/src/3rdparty/freetype/src/cff/rules.mk
+++ b/src/3rdparty/freetype/src/cff/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2001, 2003 by
+# Copyright 1996-2001, 2003, 2011, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -23,19 +23,33 @@ CFF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(CFF_DIR))
# CFF driver sources (i.e., C files)
#
-CFF_DRV_SRC := $(CFF_DIR)/cffobjs.c \
- $(CFF_DIR)/cffload.c \
+CFF_DRV_SRC := $(CFF_DIR)/cffcmap.c \
+ $(CFF_DIR)/cffdrivr.c \
$(CFF_DIR)/cffgload.c \
+ $(CFF_DIR)/cffload.c \
+ $(CFF_DIR)/cffobjs.c \
$(CFF_DIR)/cffparse.c \
- $(CFF_DIR)/cffcmap.c \
- $(CFF_DIR)/cffdrivr.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 driver headers
#
CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \
+ $(CFF_DIR)/cfferrs.h \
$(CFF_DIR)/cfftoken.h \
$(CFF_DIR)/cfftypes.h \
- $(CFF_DIR)/cfferrs.h
+ $(CFF_DIR)/cf2fixed.h \
+ $(CFF_DIR)/cf2glue.h \
+ $(CFF_DIR)/cf2types.h
# CFF driver object(s)
diff --git a/src/3rdparty/freetype/src/cid/ciderrs.h b/src/3rdparty/freetype/src/cid/ciderrs.h
index 01813e1898..ef13155504 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX CID_Err_
#define FT_ERR_BASE FT_Mod_Err_CID
diff --git a/src/3rdparty/freetype/src/cid/cidgload.c b/src/3rdparty/freetype/src/cid/cidgload.c
index ea61b4e128..7febab81c4 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
+/* Copyright 1996-2007, 2009, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -46,7 +46,7 @@
FT_Byte* p;
FT_UInt fd_select;
FT_Stream stream = face->cid_stream;
- FT_Error error = CID_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* charstring = 0;
FT_Memory memory = face->root.memory;
FT_ULong glyph_length = 0;
@@ -58,7 +58,7 @@
#endif
- FT_TRACE4(( "cid_load_glyph: glyph index %d\n", glyph_index ));
+ FT_TRACE1(( "cid_load_glyph: glyph index %d\n", glyph_index ));
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -117,7 +117,7 @@
if ( fd_select >= (FT_UInt)cid->num_dicts )
{
- error = CID_Err_Invalid_Offset;
+ error = FT_THROW( Invalid_Offset );
goto Exit;
}
if ( glyph_length == 0 )
@@ -258,7 +258,7 @@
psaux->t1_decoder_funcs->done( &decoder );
- return CID_Err_Ok;
+ return FT_Err_Ok;
}
@@ -272,7 +272,6 @@
FT_Int32 load_flags )
{
CID_GlyphSlot glyph = (CID_GlyphSlot)cidglyph;
- CID_Size size = (CID_Size)cidsize;
FT_Error error;
T1_DecoderRec decoder;
CID_Face face = (CID_Face)cidglyph->face;
@@ -285,7 +284,7 @@
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
{
- error = CID_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -375,7 +374,7 @@
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
- if ( size && cidsize->metrics.y_ppem < 24 )
+ if ( cidsize->metrics.y_ppem < 24 )
cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
/* apply the font matrix */
@@ -427,7 +426,7 @@
metrics->horiBearingX = cbox.xMin;
metrics->horiBearingY = cbox.yMax;
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
/* make up vertical ones */
ft_synthesize_vertical_metrics( metrics,
diff --git a/src/3rdparty/freetype/src/cid/cidload.c b/src/3rdparty/freetype/src/cid/cidload.c
index 3bb359446f..1cda0eee7a 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-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 1996-2006, 2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,7 +42,7 @@
cid_get_offset( FT_Byte* *start,
FT_Byte offsize )
{
- FT_Long result;
+ FT_ULong result;
FT_Byte* p = *start;
@@ -53,7 +53,7 @@
}
*start = p;
- return result;
+ return (FT_Long)result;
}
@@ -110,11 +110,11 @@
CID_FaceDict dict;
- if ( parser->num_dict < 0 )
+ if ( parser->num_dict < 0 || parser->num_dict >= cid->num_dicts )
{
FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n",
keyword->ident ));
- error = CID_Err_Syntax_Error;
+ error = FT_THROW( Syntax_Error );
goto Exit;
}
@@ -147,32 +147,44 @@
FT_CALLBACK_DEF( FT_Error )
- parse_font_matrix( CID_Face face,
- CID_Parser* parser )
+ cid_parse_font_matrix( CID_Face face,
+ CID_Parser* parser )
{
- FT_Matrix* matrix;
- FT_Vector* offset;
CID_FaceDict dict;
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
FT_Fixed temp_scale;
- if ( parser->num_dict >= 0 )
+ if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
{
+ FT_Matrix* matrix;
+ FT_Vector* offset;
+ FT_Int result;
+
+
dict = face->cid.font_dicts + parser->num_dict;
matrix = &dict->font_matrix;
offset = &dict->font_offset;
- (void)cid_parser_to_fixed_array( parser, 6, temp, 3 );
+ result = cid_parser_to_fixed_array( parser, 6, temp, 3 );
+
+ if ( result < 6 )
+ return FT_THROW( Invalid_File_Format );
temp_scale = FT_ABS( temp[3] );
- /* Set units per EM based on FontMatrix values. We set the value to */
- /* `1000/temp_scale', because temp_scale was already multiplied by */
- /* 1000 (in `t1_tofixed', from psobjs.c). */
- root->units_per_EM = (FT_UShort)( FT_DivFix( 0x10000L,
- FT_DivFix( temp_scale, 1000 ) ) );
+ if ( temp_scale == 0 )
+ {
+ FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" ));
+ return FT_THROW( Invalid_File_Format );
+ }
+
+ /* Set Units per EM based on FontMatrix values. We set the value to */
+ /* 1000 / temp_scale, because temp_scale was already multiplied by */
+ /* 1000 (in t1_tofixed, from psobjs.c). */
+
+ root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp[3] */
if ( temp_scale != 0x10000L )
@@ -182,7 +194,7 @@
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = 0x10000L;
+ temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
@@ -195,8 +207,7 @@
offset->y = temp[5] >> 16;
}
- return CID_Err_Ok; /* this is a callback function; */
- /* we must return an error code */
+ return FT_Err_Ok;
}
@@ -206,7 +217,7 @@
{
CID_FaceInfo cid = &face->cid;
FT_Memory memory = face->root.memory;
- FT_Error error = CID_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Long num_dicts;
@@ -249,7 +260,7 @@
CID_FaceDict dict;
- if ( parser->num_dict >= 0 )
+ if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
{
dict = face->cid.font_dicts + parser->num_dict;
@@ -257,7 +268,7 @@
dict->private_dict.expansion_factor = dict->expansion_factor;
}
- return CID_Err_Ok;
+ return FT_Err_Ok;
}
@@ -268,7 +279,7 @@
#include "cidtoken.h"
T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 )
- T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix, 0 )
+ T1_FIELD_CALLBACK( "FontMatrix", cid_parse_font_matrix, 0 )
T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 )
{ 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 }
@@ -286,7 +297,7 @@
parser->root.cursor = base;
parser->root.limit = base + size;
- parser->root.error = CID_Err_Ok;
+ parser->root.error = FT_Err_Ok;
{
FT_Byte* cur = base;
@@ -413,12 +424,25 @@
FT_Byte* p;
+ /* Check for possible overflow. */
+ if ( num_subrs == FT_UINT_MAX )
+ {
+ error = FT_THROW( Syntax_Error );
+ goto Fail;
+ }
+
/* reallocate offsets array if needed */
if ( num_subrs + 1 > max_offsets )
{
FT_UInt new_max = FT_PAD_CEIL( num_subrs + 1, 4 );
+ if ( new_max <= max_offsets )
+ {
+ error = FT_THROW( Syntax_Error );
+ goto Fail;
+ }
+
if ( FT_RENEW_ARRAY( offsets, max_offsets, new_max ) )
goto Fail;
@@ -436,6 +460,11 @@
FT_FRAME_EXIT();
+ /* offsets must be ordered */
+ for ( count = 1; count <= num_subrs; count++ )
+ if ( offsets[count - 1] > offsets[count] )
+ goto Fail;
+
/* now, compute the size of subrs charstrings, */
/* allocate, and read them */
data_len = offsets[num_subrs] - offsets[0];
@@ -495,8 +524,8 @@
static void
- t1_init_loader( CID_Loader* loader,
- CID_Face face )
+ cid_init_loader( CID_Loader* loader,
+ CID_Face face )
{
FT_UNUSED( face );
@@ -504,8 +533,8 @@
}
- static void
- t1_done_loader( CID_Loader* loader )
+ static void
+ cid_done_loader( CID_Loader* loader )
{
CID_Parser* parser = &loader->parser;
@@ -553,7 +582,7 @@
if ( size == 0 )
{
- error = CID_Err_Syntax_Error;
+ error = FT_THROW( Syntax_Error );
goto Exit;
}
@@ -586,7 +615,7 @@
}
else
{
- error = CID_Err_Syntax_Error;
+ error = FT_THROW( Syntax_Error );
goto Exit;
}
@@ -606,7 +635,7 @@
p++;
}
- error = CID_Err_Ok;
+ error = FT_Err_Ok;
Exit:
return error;
@@ -623,7 +652,7 @@
FT_Error error;
- t1_init_loader( &loader, face );
+ cid_init_loader( &loader, face );
parser = &loader.parser;
error = cid_parser_new( parser, face->root.stream, face->root.memory,
@@ -664,7 +693,7 @@
error = cid_read_subrs( face );
Exit:
- t1_done_loader( &loader );
+ cid_done_loader( &loader );
return error;
}
diff --git a/src/3rdparty/freetype/src/cid/cidobjs.c b/src/3rdparty/freetype/src/cid/cidobjs.c
index 82678af0d4..5932ffa973 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-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
+/* Copyright 1996-2006, 2008, 2010-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -131,7 +131,7 @@
cid_size_init( FT_Size cidsize ) /* CID_Size */
{
CID_Size size = (CID_Size)cidsize;
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size );
@@ -169,7 +169,7 @@
size->metrics.y_scale,
0, 0 );
- return CID_Err_Ok;
+ return FT_Err_Ok;
}
@@ -299,6 +299,13 @@
psaux = (PSAux_Service)FT_Get_Module_Interface(
FT_FACE_LIBRARY( face ), "psaux" );
+ if ( !psaux )
+ {
+ FT_ERROR(( "cid_face_init: cannot access `psaux' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
+
face->psaux = psaux;
}
@@ -311,6 +318,8 @@
face->pshinter = pshinter;
}
+ FT_TRACE2(( "CID driver\n" ));
+
/* open the tokenizer; this will also check the font format */
if ( FT_STREAM_SEEK( 0 ) )
goto Exit;
@@ -328,7 +337,7 @@
if ( face_index != 0 )
{
FT_ERROR(( "cid_face_init: invalid face index\n" ));
- error = CID_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -346,9 +355,10 @@
cidface->num_charmaps = 0;
cidface->face_index = face_index;
- cidface->face_flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
- FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
- FT_FACE_FLAG_HINTER; /* has native hinter */
+
+ cidface->face_flags |= FT_FACE_FLAG_SCALABLE | /* scalable outlines */
+ FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
+ FT_FACE_FLAG_HINTER; /* has native hinter */
if ( info->is_fixed_pitch )
cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
@@ -457,7 +467,7 @@
{
FT_UNUSED( driver );
- return CID_Err_Ok;
+ return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/cid/cidparse.c b/src/3rdparty/freetype/src/cid/cidparse.c
index efed618f5a..d8476cdae8 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 1996-2007, 2009, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -73,8 +73,8 @@
if ( ft_strncmp( (char *)stream->cursor,
"%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
{
- FT_TRACE2(( "[not a valid CID-keyed font]\n" ));
- error = CID_Err_Unknown_File_Format;
+ FT_TRACE2(( " not a CID-keyed font\n" ));
+ error = FT_THROW( Unknown_File_Format );
}
FT_FRAME_EXIT();
@@ -99,7 +99,7 @@
if ( stream_len == 0 )
{
FT_TRACE2(( "cid_parser_new: no `StartData' keyword found\n" ));
- error = CID_Err_Unknown_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -117,12 +117,12 @@
if ( p[0] == 'S' && ft_strncmp( (char*)p, "StartData", 9 ) == 0 )
{
/* save offset of binary data after `StartData' */
- offset += p - buffer + 10;
+ offset += (FT_ULong)( p - buffer + 10 );
goto Found;
}
else if ( p[1] == 's' && ft_strncmp( (char*)p, "/sfnts", 6 ) == 0 )
{
- offset += p - buffer + 7;
+ offset += (FT_ULong)( p - buffer + 7 );
goto Found;
}
}
@@ -178,14 +178,12 @@
if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 )
parser->binary_length = ft_atol( (const char *)arg2 );
- limit = parser->root.limit;
- cur = parser->root.cursor;
goto Exit;
}
else if ( cur[1] == 's' && ft_strncmp( (char*)cur, "/sfnts", 6 ) == 0 )
{
FT_TRACE2(( "cid_parser_new: cannot handle Type 11 fonts\n" ));
- error = CID_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
diff --git a/src/3rdparty/freetype/src/cid/cidparse.h b/src/3rdparty/freetype/src/cid/cidparse.h
index ca37deab93..f27be65a60 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-2001, 2002, 2003, 2004 by */
+/* Copyright 1996-2004, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -92,26 +92,26 @@ FT_BEGIN_HEADER
/* */
/*************************************************************************/
-#define cid_parser_skip_spaces( p ) \
+#define cid_parser_skip_spaces( p ) \
(p)->root.funcs.skip_spaces( &(p)->root )
-#define cid_parser_skip_PS_token( p ) \
+#define cid_parser_skip_PS_token( p ) \
(p)->root.funcs.skip_PS_token( &(p)->root )
-#define cid_parser_to_int( p ) (p)->root.funcs.to_int( &(p)->root )
-#define cid_parser_to_fixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
+#define cid_parser_to_int( p ) (p)->root.funcs.to_int( &(p)->root )
+#define cid_parser_to_fixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
-#define cid_parser_to_coord_array( p, m, c ) \
+#define cid_parser_to_coord_array( p, m, c ) \
(p)->root.funcs.to_coord_array( &(p)->root, m, c )
-#define cid_parser_to_fixed_array( p, m, f, t ) \
+#define cid_parser_to_fixed_array( p, m, f, t ) \
(p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
-#define cid_parser_to_token( p, t ) \
+#define cid_parser_to_token( p, t ) \
(p)->root.funcs.to_token( &(p)->root, t )
-#define cid_parser_to_token_array( p, t, m, c ) \
+#define cid_parser_to_token_array( p, t, m, c ) \
(p)->root.funcs.to_token_array( &(p)->root, t, m, c )
-#define cid_parser_load_field( p, f, o ) \
+#define cid_parser_load_field( p, f, o ) \
(p)->root.funcs.load_field( &(p)->root, f, o, 0, 0 )
-#define cid_parser_load_field_table( p, f, o ) \
+#define cid_parser_load_field_table( p, f, o ) \
(p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 )
diff --git a/src/3rdparty/freetype/src/cid/cidriver.c b/src/3rdparty/freetype/src/cid/cidriver.c
index 3a2d22532a..6132a27763 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-2001, 2002, 2003, 2004, 2006, 2008, 2009 by */
+/* Copyright 1996-2004, 2006, 2008, 2009, 2011, 2013 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 @@
{
*afont_info = ((CID_Face)face)->cid.font_info;
- return CID_Err_Ok;
+ return FT_Err_Ok;
}
static FT_Error
@@ -83,7 +83,7 @@
{
*afont_extra = ((CID_Face)face)->font_extra;
- return CID_Err_Ok;
+ return FT_Err_Ok;
}
static const FT_Service_PsInfoRec cid_service_ps_info =
@@ -91,7 +91,8 @@
(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_GetFontPrivateFunc)NULL, /* unsupported */
+ (PS_GetFontValueFunc) NULL /* not implemented */
};
@@ -110,14 +111,14 @@
if ( registry )
*registry = cid->registry;
-
+
if ( ordering )
*ordering = cid->ordering;
if ( supplement )
*supplement = cid->supplement;
-
- return CID_Err_Ok;
+
+ return FT_Err_Ok;
}
@@ -125,7 +126,7 @@
cid_get_is_cid( CID_Face face,
FT_Bool *is_cid )
{
- FT_Error error = CID_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( face );
@@ -141,7 +142,7 @@
FT_UInt glyph_index,
FT_UInt *cid )
{
- FT_Error error = CID_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( face );
@@ -195,7 +196,7 @@
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
- sizeof( FT_DriverRec ),
+ sizeof ( FT_DriverRec ),
"t1cid", /* module name */
0x10000L, /* version 1.0 of driver */
0x20000L, /* requires FreeType 2.0 */
@@ -208,9 +209,9 @@
},
/* then the other font drivers fields */
- sizeof( CID_FaceRec ),
- sizeof( CID_SizeRec ),
- sizeof( CID_GlyphSlotRec ),
+ sizeof ( CID_FaceRec ),
+ sizeof ( CID_SizeRec ),
+ sizeof ( CID_GlyphSlotRec ),
cid_face_init,
cid_face_done,
@@ -220,11 +221,6 @@
cid_slot_init,
cid_slot_done,
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
-
cid_slot_load_glyph,
0, /* FT_Face_GetKerningFunc */
diff --git a/src/3rdparty/freetype/src/cid/cidriver.h b/src/3rdparty/freetype/src/cid/cidriver.h
index c7f424bb38..3c45e06886 100644
--- a/src/3rdparty/freetype/src/cid/cidriver.h
+++ b/src/3rdparty/freetype/src/cid/cidriver.h
@@ -28,7 +28,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_CALLBACK_TABLE
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvbsln.c b/src/3rdparty/freetype/src/gxvalid/gxvbsln.c
index 3d10031563..d16511876a 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvbsln.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvbsln.c
@@ -72,10 +72,10 @@
static void
gxv_bsln_LookupValue_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_UShort v = value_p->u;
- FT_UShort* ctlPoints;
+ FT_UShort v = value_p->u;
+ FT_UShort* ctlPoints;
FT_UNUSED( glyph );
@@ -124,7 +124,7 @@
gxv_bsln_LookupFmt4_transit( FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p;
FT_Bytes limit;
@@ -135,7 +135,7 @@
offset = (FT_UShort)( base_value_p->u +
( relative_gindex * sizeof ( FT_UShort ) ) );
- p = valid->lookuptbl_head + offset;
+ p = gxvalid->lookuptbl_head + offset;
limit = lookuptbl_limit;
GXV_LIMIT_CHECK( 2 );
@@ -148,7 +148,7 @@
static void
gxv_bsln_parts_fmt0_validate( FT_Bytes tables,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = tables;
@@ -158,7 +158,7 @@
/* deltas */
GXV_LIMIT_CHECK( 2 * GXV_BSLN_VALUE_COUNT );
- valid->table_data = NULL; /* No ctlPoints here. */
+ gxvalid->table_data = NULL; /* No ctlPoints here. */
GXV_EXIT;
}
@@ -167,7 +167,7 @@
static void
gxv_bsln_parts_fmt1_validate( FT_Bytes tables,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = tables;
@@ -175,15 +175,15 @@
GXV_NAME_ENTER( "parts format 1" );
/* deltas */
- gxv_bsln_parts_fmt0_validate( p, limit, valid );
+ gxv_bsln_parts_fmt0_validate( p, limit, gxvalid );
/* mappingData */
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_bsln_LookupValue_validate;
- valid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_bsln_LookupValue_validate;
+ gxvalid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
gxv_LookupTable_validate( p + 2 * GXV_BSLN_VALUE_COUNT,
limit,
- valid );
+ gxvalid );
GXV_EXIT;
}
@@ -192,7 +192,7 @@
static void
gxv_bsln_parts_fmt2_validate( FT_Bytes tables,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = tables;
@@ -211,7 +211,7 @@
stdGlyph = FT_NEXT_USHORT( p );
GXV_TRACE(( " (stdGlyph = %u)\n", stdGlyph ));
- gxv_glyphid_validate( stdGlyph, valid );
+ gxv_glyphid_validate( stdGlyph, gxvalid );
/* Record the position of ctlPoints */
GXV_BSLN_DATA( ctlPoints_p ) = p;
@@ -226,7 +226,7 @@
FT_INVALID_DATA;
}
else
- gxv_ctlPoint_validate( stdGlyph, (FT_Short)ctlPoint, valid );
+ gxv_ctlPoint_validate( stdGlyph, (FT_Short)ctlPoint, gxvalid );
}
GXV_EXIT;
@@ -236,7 +236,7 @@
static void
gxv_bsln_parts_fmt3_validate( FT_Bytes tables,
FT_Bytes limit,
- GXV_Validator valid)
+ GXV_Validator gxvalid)
{
FT_Bytes p = tables;
@@ -244,15 +244,15 @@
GXV_NAME_ENTER( "parts format 3" );
/* stdGlyph + ctlPoints */
- gxv_bsln_parts_fmt2_validate( p, limit, valid );
+ gxv_bsln_parts_fmt2_validate( p, limit, gxvalid );
/* mappingData */
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_bsln_LookupValue_validate;
- valid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_bsln_LookupValue_validate;
+ gxvalid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
gxv_LookupTable_validate( p + ( 2 + 2 * GXV_BSLN_VALUE_COUNT ),
limit,
- valid );
+ gxvalid );
GXV_EXIT;
}
@@ -271,8 +271,8 @@
FT_Face face,
FT_Validator ftvalid )
{
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_bsln_DataRec bslnrec;
GXV_bsln_Data bsln = &bslnrec;
@@ -293,9 +293,9 @@
};
- valid->root = ftvalid;
- valid->table_data = bsln;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = bsln;
+ gxvalid->face = face;
FT_TRACE3(( "validating `bsln' table\n" ));
GXV_INIT;
@@ -320,7 +320,7 @@
bsln->defaultBaseline = defaultBaseline;
- fmt_funcs_table[format]( p, limit, valid );
+ fmt_funcs_table[format]( p, limit, gxvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvcommn.c b/src/3rdparty/freetype/src/gxvalid/gxvcommn.c
index de7ce6fdef..8e72a72f4e 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, 2005, 2009 */
+/* Copyright 2004, 2005, 2009, 2010, 2013 */
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -65,7 +65,7 @@
FT_UShort* buff,
FT_UInt nmemb,
FT_UShort limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UInt i;
@@ -130,7 +130,7 @@
FT_ULong* buff,
FT_UInt nmemb,
FT_ULong limit,
- GXV_Validator valid)
+ GXV_Validator gxvalid)
{
FT_UInt i;
@@ -182,7 +182,7 @@
FT_Bytes limit,
FT_Byte* min,
FT_Byte* max,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -202,7 +202,7 @@
*max = (FT_Byte)FT_MAX( *max, val );
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
}
@@ -211,7 +211,7 @@
FT_Bytes limit,
FT_UShort* min,
FT_UShort* max,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -231,7 +231,7 @@
*max = (FT_Byte)FT_MAX( *max, val );
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
}
@@ -256,7 +256,7 @@
static void
gxv_BinSrchHeader_check_consistency( GXV_BinSrchHeader* binSrchHeader,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort searchRange;
FT_UShort entrySelector;
@@ -304,8 +304,7 @@
binSrchHeader->unitSize, binSrchHeader->nUnits,
searchRange, entrySelector, rangeShift ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
}
}
@@ -330,7 +329,7 @@
FT_Bytes limit,
FT_UShort* unitSize_p,
FT_UShort* nUnits_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_BinSrchHeader binSrchHeader;
@@ -360,7 +359,7 @@
binSrchHeader.rangeShift = FT_NEXT_USHORT( p );
GXV_TRACE(( "nUnits %d\n", binSrchHeader.nUnits ));
- gxv_BinSrchHeader_check_consistency( &binSrchHeader, valid );
+ gxv_BinSrchHeader_check_consistency( &binSrchHeader, gxvalid );
if ( *unitSize_p == 0 )
*unitSize_p = binSrchHeader.unitSize;
@@ -368,7 +367,7 @@
if ( *nUnits_p == 0 )
*nUnits_p = binSrchHeader.nUnits;
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -423,7 +422,7 @@
static void
gxv_LookupTable_fmt0_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort i;
@@ -433,25 +432,24 @@
GXV_NAME_ENTER( "LookupTable format 0" );
- GXV_LIMIT_CHECK( 2 * valid->face->num_glyphs );
+ GXV_LIMIT_CHECK( 2 * gxvalid->face->num_glyphs );
- for ( i = 0; i < valid->face->num_glyphs; i++ )
+ for ( i = 0; i < gxvalid->face->num_glyphs; i++ )
{
GXV_LIMIT_CHECK( 2 );
if ( p + 2 >= limit ) /* some fonts have too-short fmt0 array */
{
GXV_TRACE(( "too short, glyphs %d - %d are missing\n",
- i, valid->face->num_glyphs ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ i, gxvalid->face->num_glyphs ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
break;
}
- value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
- valid->lookupval_func( i, &value, valid );
+ value = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
+ gxvalid->lookupval_func( i, &value, gxvalid );
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -475,12 +473,12 @@
static void
gxv_LookupTable_fmt2_skip_endmarkers( FT_Bytes table,
FT_UShort unitSize,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
- while ( ( p + 4 ) < valid->root->limit )
+ while ( ( p + 4 ) < gxvalid->root->limit )
{
if ( p[0] != 0xFF || p[1] != 0xFF || /* lastGlyph */
p[2] != 0xFF || p[3] != 0xFF ) /* firstGlyph */
@@ -488,14 +486,14 @@
p += unitSize;
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
}
static void
gxv_LookupTable_fmt2_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort gid;
@@ -511,8 +509,8 @@
GXV_NAME_ENTER( "LookupTable format 2" );
unitSize = nUnits = 0;
- gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, valid );
- p += valid->subtable_length;
+ gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, gxvalid );
+ p += gxvalid->subtable_length;
GXV_UNITSIZE_VALIDATE( "format2", unitSize, nUnits, 6 );
@@ -521,18 +519,17 @@
GXV_LIMIT_CHECK( 2 + 2 + 2 );
lastGlyph = FT_NEXT_USHORT( p );
firstGlyph = FT_NEXT_USHORT( p );
- value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
+ value = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
- gxv_glyphid_validate( firstGlyph, valid );
- gxv_glyphid_validate( lastGlyph, valid );
+ gxv_glyphid_validate( firstGlyph, gxvalid );
+ gxv_glyphid_validate( lastGlyph, gxvalid );
if ( lastGlyph < gid )
{
GXV_TRACE(( "reverse ordered segment specification:"
" lastGlyph[%d]=%d < lastGlyph[%d]=%d\n",
unit, lastGlyph, unit - 1 , gid ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
if ( lastGlyph < firstGlyph )
@@ -540,10 +537,9 @@
GXV_TRACE(( "reverse ordered range specification at unit %d:",
" lastGlyph %d < firstGlyph %d ",
unit, lastGlyph, firstGlyph ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
- if ( valid->root->level == FT_VALIDATE_TIGHT )
+ if ( gxvalid->root->level == FT_VALIDATE_TIGHT )
continue; /* ftxvalidator silently skips such an entry */
FT_TRACE4(( "continuing with exchanged values\n" ));
@@ -553,13 +549,13 @@
}
for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
- valid->lookupval_func( gid, &value, valid );
+ gxvalid->lookupval_func( gid, &value, gxvalid );
}
- gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
- p += valid->subtable_length;
+ gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, gxvalid );
+ p += gxvalid->subtable_length;
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -568,7 +564,7 @@
static void
gxv_LookupTable_fmt4_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort unit;
@@ -585,8 +581,8 @@
GXV_NAME_ENTER( "LookupTable format 4" );
unitSize = nUnits = 0;
- gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, valid );
- p += valid->subtable_length;
+ gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, gxvalid );
+ p += gxvalid->subtable_length;
GXV_UNITSIZE_VALIDATE( "format4", unitSize, nUnits, 6 );
@@ -596,16 +592,15 @@
lastGlyph = FT_NEXT_USHORT( p );
firstGlyph = FT_NEXT_USHORT( p );
- gxv_glyphid_validate( firstGlyph, valid );
- gxv_glyphid_validate( lastGlyph, valid );
+ gxv_glyphid_validate( firstGlyph, gxvalid );
+ gxv_glyphid_validate( lastGlyph, gxvalid );
if ( lastGlyph < gid )
{
GXV_TRACE(( "reverse ordered segment specification:"
" lastGlyph[%d]=%d < lastGlyph[%d]=%d\n",
unit, lastGlyph, unit - 1 , gid ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
if ( lastGlyph < firstGlyph )
@@ -613,10 +608,9 @@
GXV_TRACE(( "reverse ordered range specification at unit %d:",
" lastGlyph %d < firstGlyph %d ",
unit, lastGlyph, firstGlyph ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
- if ( valid->root->level == FT_VALIDATE_TIGHT )
+ if ( gxvalid->root->level == FT_VALIDATE_TIGHT )
continue; /* ftxvalidator silently skips such an entry */
FT_TRACE4(( "continuing with exchanged values\n" ));
@@ -630,19 +624,19 @@
for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
{
- value = valid->lookupfmt4_trans( (FT_UShort)( gid - firstGlyph ),
+ value = gxvalid->lookupfmt4_trans( (FT_UShort)( gid - firstGlyph ),
&base_value,
limit,
- valid );
+ gxvalid );
- valid->lookupval_func( gid, &value, valid );
+ gxvalid->lookupval_func( gid, &value, gxvalid );
}
}
- gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
- p += valid->subtable_length;
+ gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, gxvalid );
+ p += gxvalid->subtable_length;
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -651,26 +645,26 @@
static void
gxv_LookupTable_fmt6_skip_endmarkers( FT_Bytes table,
FT_UShort unitSize,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
- while ( p < valid->root->limit )
+ while ( p < gxvalid->root->limit )
{
if ( p[0] != 0xFF || p[1] != 0xFF )
break;
p += unitSize;
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
}
static void
gxv_LookupTable_fmt6_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort unit;
@@ -685,8 +679,8 @@
GXV_NAME_ENTER( "LookupTable format 6" );
unitSize = nUnits = 0;
- gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, valid );
- p += valid->subtable_length;
+ gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, gxvalid );
+ p += gxvalid->subtable_length;
GXV_UNITSIZE_VALIDATE( "format6", unitSize, nUnits, 4 );
@@ -694,9 +688,9 @@
{
GXV_LIMIT_CHECK( 2 + 2 );
glyph = FT_NEXT_USHORT( p );
- value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
+ value = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
- if ( gxv_glyphid_validate( glyph, valid ) )
+ if ( gxv_glyphid_validate( glyph, gxvalid ) )
GXV_TRACE(( " endmarker found within defined range"
" (entry %d < nUnits=%d)\n",
unit, nUnits ));
@@ -705,18 +699,17 @@
{
GXV_TRACE(( "current gid 0x%04x < previous gid 0x%04x\n",
glyph, prev_glyph ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
prev_glyph = glyph;
- valid->lookupval_func( glyph, &value, valid );
+ gxvalid->lookupval_func( glyph, &value, gxvalid );
}
- gxv_LookupTable_fmt6_skip_endmarkers( p, unitSize, valid );
- p += valid->subtable_length;
+ gxv_LookupTable_fmt6_skip_endmarkers( p, unitSize, gxvalid );
+ p += gxvalid->subtable_length;
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -725,7 +718,7 @@
static void
gxv_LookupTable_fmt8_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort i;
@@ -742,18 +735,18 @@
firstGlyph = FT_NEXT_USHORT( p );
glyphCount = FT_NEXT_USHORT( p );
- gxv_glyphid_validate( firstGlyph, valid );
- gxv_glyphid_validate( (FT_UShort)( firstGlyph + glyphCount ), valid );
+ gxv_glyphid_validate( firstGlyph, gxvalid );
+ gxv_glyphid_validate( (FT_UShort)( firstGlyph + glyphCount ), gxvalid );
/* valueArray */
for ( i = 0; i < glyphCount; i++ )
{
GXV_LIMIT_CHECK( 2 );
- value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
- valid->lookupval_func( (FT_UShort)( firstGlyph + i ), &value, valid );
+ value = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
+ gxvalid->lookupval_func( (FT_UShort)( firstGlyph + i ), &value, gxvalid );
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -761,7 +754,7 @@
FT_LOCAL_DEF( void )
gxv_LookupTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort format;
@@ -785,7 +778,7 @@
GXV_NAME_ENTER( "LookupTable" );
/* lookuptbl_head may be used in fmt4 transit function. */
- valid->lookuptbl_head = table;
+ gxvalid->lookuptbl_head = table;
/* format */
GXV_LIMIT_CHECK( 2 );
@@ -799,10 +792,10 @@
if ( func == NULL )
FT_INVALID_FORMAT;
- func( p, limit, valid );
- p += valid->subtable_length;
+ func( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -818,7 +811,7 @@
FT_LOCAL_DEF( FT_Int )
gxv_glyphid_validate( FT_UShort gid,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Face face;
@@ -829,13 +822,12 @@
return 1;
}
- face = valid->face;
+ face = gxvalid->face;
if ( face->num_glyphs < gid )
{
GXV_TRACE(( " gxv_glyphid_check() gid overflow: num_glyphs %d < %d\n",
face->num_glyphs, gid ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
return 0;
@@ -853,7 +845,7 @@
FT_LOCAL_DEF( void )
gxv_ctlPoint_validate( FT_UShort gid,
FT_Short ctl_point,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Face face;
FT_Error error;
@@ -863,7 +855,7 @@
short n_points;
- face = valid->face;
+ face = gxvalid->face;
error = FT_Load_Glyph( face,
gid,
@@ -893,7 +885,7 @@
gxv_sfntName_validate( FT_UShort name_index,
FT_UShort min_index,
FT_UShort max_index,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_SfntName name;
FT_UInt i;
@@ -905,10 +897,10 @@
if ( name_index < min_index || max_index < name_index )
FT_INVALID_FORMAT;
- nnames = FT_Get_Sfnt_Name_Count( valid->face );
+ nnames = FT_Get_Sfnt_Name_Count( gxvalid->face );
for ( i = 0; i < nnames; i++ )
{
- if ( FT_Get_Sfnt_Name( valid->face, i, &name ) != FT_Err_Ok )
+ if ( FT_Get_Sfnt_Name( gxvalid->face, i, &name ) != FT_Err_Ok )
continue ;
if ( name.name_id == name_index )
@@ -952,7 +944,7 @@
FT_UShort* length_p,
FT_UShort stateSize,
FT_Byte* maxClassID_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_Bytes limit = table + *length_p;
@@ -973,7 +965,7 @@
if ( !nGlyphs )
goto Out;
- gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs ), valid );
+ gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs ), gxvalid );
{
FT_Byte nGlyphInClass[256];
@@ -1030,9 +1022,9 @@
FT_UShort stateSize,
FT_Byte* maxState_p,
FT_Byte* maxEntry_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_Bytes p = table;
+ FT_Bytes p = table;
FT_Bytes limit = table + *length_p;
FT_Byte clazz;
FT_Byte entry;
@@ -1084,7 +1076,7 @@
FT_Byte maxClassID,
FT_Bytes statetable_table,
FT_Bytes statetable_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_Bytes limit = table + *length_p;
@@ -1101,8 +1093,7 @@
if ( ( maxEntry + 1 ) * entrySize > *length_p )
{
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_TOO_SHORT;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_TOO_SHORT );
/* ftxvalidator and FontValidator both warn and continue */
maxEntry = (FT_Byte)( *length_p / entrySize - 1 );
@@ -1126,8 +1117,7 @@
{
GXV_TRACE(( " newState offset 0x%04x is out of stateArray\n",
newState ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_OFFSET;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
continue;
}
@@ -1135,8 +1125,7 @@
{
GXV_TRACE(( " newState offset 0x%04x is not aligned to %d-classes\n",
newState, 1 + maxClassID ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_OFFSET;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
continue;
}
@@ -1173,18 +1162,17 @@
break;
default:
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_FORMAT;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
goto Exit;
}
- if ( NULL != valid->statetable.entry_validate_func )
- valid->statetable.entry_validate_func( state,
- flags,
- &glyphOffset,
- statetable_table,
- statetable_limit,
- valid );
+ if ( NULL != gxvalid->statetable.entry_validate_func )
+ gxvalid->statetable.entry_validate_func( state,
+ flags,
+ &glyphOffset,
+ statetable_table,
+ statetable_limit,
+ gxvalid );
}
Exit:
@@ -1204,7 +1192,7 @@
FT_UShort* classTable_length_p,
FT_UShort* stateArray_length_p,
FT_UShort* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort o[3];
FT_UShort* l[3];
@@ -1218,14 +1206,14 @@
l[1] = stateArray_length_p;
l[2] = entryTable_length_p;
- gxv_set_length_by_ushort_offset( o, l, buff, 3, table_size, valid );
+ gxv_set_length_by_ushort_offset( o, l, buff, 3, table_size, gxvalid );
}
FT_LOCAL_DEF( void )
gxv_StateTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort stateSize;
FT_UShort classTable; /* offset to Class(Sub)Table */
@@ -1262,11 +1250,11 @@
if ( stateSize > 0xFF )
FT_INVALID_DATA;
- if ( valid->statetable.optdata_load_func != NULL )
- valid->statetable.optdata_load_func( p, limit, valid );
+ if ( gxvalid->statetable.optdata_load_func != NULL )
+ gxvalid->statetable.optdata_load_func( p, limit, gxvalid );
- if ( valid->statetable.subtable_setup_func != NULL)
- setup_func = valid->statetable.subtable_setup_func;
+ if ( gxvalid->statetable.subtable_setup_func != NULL)
+ setup_func = gxvalid->statetable.subtable_setup_func;
else
setup_func = gxv_StateTable_subtable_setup;
@@ -1277,7 +1265,7 @@
&classTable_length,
&stateArray_length,
&entryTable_length,
- valid );
+ gxvalid );
GXV_TRACE(( "StateTable Subtables\n" ));
@@ -1286,7 +1274,7 @@
&classTable_length,
stateSize,
&maxClassID,
- valid );
+ gxvalid );
else
maxClassID = (FT_Byte)( stateSize - 1 );
@@ -1297,10 +1285,12 @@
stateSize,
&maxState,
&maxEntry,
- valid );
+ gxvalid );
else
{
+#if 0
maxState = 1; /* 0:start of text, 1:start of line are predefined */
+#endif
maxEntry = 0;
}
@@ -1316,7 +1306,7 @@
maxClassID,
table,
limit,
- valid );
+ gxvalid );
GXV_EXIT;
}
@@ -1332,7 +1322,7 @@
FT_ULong* classTable_length_p,
FT_ULong* stateArray_length_p,
FT_ULong* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_ULong o[3];
FT_ULong* l[3];
@@ -1346,21 +1336,21 @@
l[1] = stateArray_length_p;
l[2] = entryTable_length_p;
- gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, valid );
+ gxv_set_length_by_ulong_offset( o, l, buff, 3, table_size, gxvalid );
}
static void
gxv_XClassTable_lookupval_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UNUSED( glyph );
- if ( value_p->u >= valid->xstatetable.nClasses )
+ if ( value_p->u >= gxvalid->xstatetable.nClasses )
FT_INVALID_DATA;
- if ( value_p->u > valid->xstatetable.maxClassID )
- valid->xstatetable.maxClassID = value_p->u;
+ if ( value_p->u > gxvalid->xstatetable.maxClassID )
+ gxvalid->xstatetable.maxClassID = value_p->u;
}
@@ -1394,7 +1384,7 @@
gxv_XClassTable_lookupfmt4_transit( FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p;
FT_Bytes limit;
@@ -1405,7 +1395,7 @@
offset = (FT_UShort)( base_value_p->u +
relative_gindex * sizeof ( FT_UShort ) );
- p = valid->lookuptbl_head + offset;
+ p = gxvalid->lookuptbl_head + offset;
limit = lookuptbl_limit;
GXV_LIMIT_CHECK ( 2 );
@@ -1422,7 +1412,7 @@
FT_ULong stateSize,
FT_UShort* maxState_p,
FT_UShort* maxEntry_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_Bytes limit = table + *length_p;
@@ -1473,7 +1463,7 @@
FT_UShort maxClassID,
FT_Bytes xstatetable_table,
FT_Bytes xstatetable_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_Bytes limit = table + *length_p;
@@ -1503,8 +1493,7 @@
{
GXV_TRACE(( " newState index 0x%04x points out of stateArray\n",
newState_idx ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_OFFSET;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
}
state = (FT_UShort)( newState_idx / ( 1 + maxClassID ) );
@@ -1513,8 +1502,7 @@
FT_TRACE4(( "-> new state = %d (supposed)\n"
"but newState index 0x%04x is not aligned to %d-classes\n",
state, newState_idx, 1 + maxClassID ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_OFFSET;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
}
switch ( GXV_GLYPHOFFSET_FMT( xstatetable ) )
@@ -1548,18 +1536,17 @@
break;
default:
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_FORMAT;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
goto Exit;
}
- if ( NULL != valid->xstatetable.entry_validate_func )
- valid->xstatetable.entry_validate_func( state,
- flags,
- &glyphOffset,
- xstatetable_table,
- xstatetable_limit,
- valid );
+ if ( NULL != gxvalid->xstatetable.entry_validate_func )
+ gxvalid->xstatetable.entry_validate_func( state,
+ flags,
+ &glyphOffset,
+ xstatetable_table,
+ xstatetable_limit,
+ gxvalid );
}
Exit:
@@ -1572,7 +1559,7 @@
FT_LOCAL_DEF( void )
gxv_XStateTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/* StateHeader members */
FT_ULong classTable; /* offset to Class(Sub)Table */
@@ -1595,26 +1582,26 @@
GXV_TRACE(( "XStateTable header\n" ));
GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 );
- valid->xstatetable.nClasses = FT_NEXT_ULONG( p );
+ gxvalid->xstatetable.nClasses = FT_NEXT_ULONG( p );
classTable = FT_NEXT_ULONG( p );
stateArray = FT_NEXT_ULONG( p );
entryTable = FT_NEXT_ULONG( p );
- GXV_TRACE(( "nClasses =0x%08x\n", valid->xstatetable.nClasses ));
+ GXV_TRACE(( "nClasses =0x%08x\n", gxvalid->xstatetable.nClasses ));
GXV_TRACE(( "offset to classTable=0x%08x\n", classTable ));
GXV_TRACE(( "offset to stateArray=0x%08x\n", stateArray ));
GXV_TRACE(( "offset to entryTable=0x%08x\n", entryTable ));
- if ( valid->xstatetable.nClasses > 0xFFFFU )
+ if ( gxvalid->xstatetable.nClasses > 0xFFFFU )
FT_INVALID_DATA;
GXV_TRACE(( "StateTable Subtables\n" ));
- if ( valid->xstatetable.optdata_load_func != NULL )
- valid->xstatetable.optdata_load_func( p, limit, valid );
+ if ( gxvalid->xstatetable.optdata_load_func != NULL )
+ gxvalid->xstatetable.optdata_load_func( p, limit, gxvalid );
- if ( valid->xstatetable.subtable_setup_func != NULL )
- setup_func = valid->xstatetable.subtable_setup_func;
+ if ( gxvalid->xstatetable.subtable_setup_func != NULL )
+ setup_func = gxvalid->xstatetable.subtable_setup_func;
else
setup_func = gxv_XStateTable_subtable_setup;
@@ -1625,38 +1612,42 @@
&classTable_length,
&stateArray_length,
&entryTable_length,
- valid );
+ gxvalid );
if ( classTable != 0 )
{
- valid->xstatetable.maxClassID = 0;
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_XClassTable_lookupval_validate;
- valid->lookupfmt4_trans = gxv_XClassTable_lookupfmt4_transit;
+ gxvalid->xstatetable.maxClassID = 0;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_XClassTable_lookupval_validate;
+ gxvalid->lookupfmt4_trans = gxv_XClassTable_lookupfmt4_transit;
gxv_LookupTable_validate( table + classTable,
table + classTable + classTable_length,
- valid );
- if ( valid->subtable_length < classTable_length )
- classTable_length = valid->subtable_length;
+ gxvalid );
+#if 0
+ if ( gxvalid->subtable_length < classTable_length )
+ classTable_length = gxvalid->subtable_length;
+#endif
}
else
{
/* XXX: check range? */
- valid->xstatetable.maxClassID =
- (FT_UShort)( valid->xstatetable.nClasses - 1 );
+ gxvalid->xstatetable.maxClassID =
+ (FT_UShort)( gxvalid->xstatetable.nClasses - 1 );
}
if ( stateArray != 0 )
gxv_XStateArray_validate( table + stateArray,
&stateArray_length,
- valid->xstatetable.maxClassID,
- valid->xstatetable.nClasses,
+ gxvalid->xstatetable.maxClassID,
+ gxvalid->xstatetable.nClasses,
&maxState,
&maxEntry,
- valid );
+ gxvalid );
else
{
+#if 0
maxState = 1; /* 0:start of text, 1:start of line are predefined */
+#endif
maxEntry = 0;
}
@@ -1668,10 +1659,10 @@
&entryTable_length,
maxEntry,
stateArray_length,
- valid->xstatetable.maxClassID,
+ gxvalid->xstatetable.maxClassID,
table,
limit,
- valid );
+ gxvalid );
GXV_EXIT;
}
@@ -1719,16 +1710,16 @@
const FT_String* name,
GXV_odtect_Range odtect )
{
- odtect->range[ odtect->nRanges ].start = start;
- odtect->range[ odtect->nRanges ].length = length;
- odtect->range[ odtect->nRanges ].name = (FT_String*)name;
+ odtect->range[odtect->nRanges].start = start;
+ odtect->range[odtect->nRanges].length = length;
+ odtect->range[odtect->nRanges].name = (FT_String*)name;
odtect->nRanges++;
}
FT_LOCAL_DEF( void )
gxv_odtect_validate( GXV_odtect_Range odtect,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UInt i, j;
@@ -1742,6 +1733,7 @@
odtect->range[j].start,
odtect->range[j].length ) )
{
+#ifdef FT_DEBUG_LEVEL_TRACE
if ( odtect->range[i].name || odtect->range[j].name )
GXV_TRACE(( "found overlap between range %d and range %d\n",
i, j ));
@@ -1749,6 +1741,7 @@
GXV_TRACE(( "found overlap between `%s' and `%s\'\n",
odtect->range[i].name,
odtect->range[j].name ));
+#endif
FT_INVALID_OFFSET;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvcommn.h b/src/3rdparty/freetype/src/gxvalid/gxvcommn.h
index 404c07ffad..f1143457ff 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvcommn.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvcommn.h
@@ -4,7 +4,8 @@
/* */
/* TrueTypeGX/AAT common tables validation (specification). */
/* */
-/* Copyright 2004, 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
+/* Copyright 2004, 2005, 2012, 2014 */
+/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -51,6 +52,19 @@
FT_BEGIN_HEADER
+ /* some variables are not evaluated or only used in trace */
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+#define GXV_LOAD_TRACE_VARS
+#else
+#undef GXV_LOAD_TRACE_VARS
+#endif
+
+#undef GXV_LOAD_UNUSED_VARS /* debug purpose */
+
+#define IS_PARANOID_VALIDATION ( gxvalid->root->level >= FT_VALIDATE_PARANOID )
+#define GXV_SET_ERR_IF_PARANOID( err ) { if ( IS_PARANOID_VALIDATION ) ( err ); }
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -67,7 +81,7 @@ FT_BEGIN_HEADER
typedef void
(*GXV_Validate_Func)( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
/* ====================== LookupTable Validator ======================== */
@@ -92,13 +106,13 @@ FT_BEGIN_HEADER
typedef void
(*GXV_Lookup_Value_Validate_Func)( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
typedef GXV_LookupValueDesc
(*GXV_Lookup_Fmt4_Transit_Func)( FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
/* ====================== StateTable Validator ========================= */
@@ -117,10 +131,10 @@ FT_BEGIN_HEADER
#define GXV_GLYPHOFFSET_FMT( table ) \
- ( valid->table.entry_glyphoffset_fmt )
+ ( gxvalid->table.entry_glyphoffset_fmt )
#define GXV_GLYPHOFFSET_SIZE( table ) \
- ( valid->table.entry_glyphoffset_fmt / 2 )
+ ( gxvalid->table.entry_glyphoffset_fmt / 2 )
/* ----------------------- 16bit StateTable ---------------------------- */
@@ -146,7 +160,7 @@ FT_BEGIN_HEADER
FT_UShort* classTable_length_p,
FT_UShort* stateArray_length_p,
FT_UShort* entryTable_length_p,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
typedef void
(*GXV_StateTable_Entry_Validate_Func)(
@@ -155,12 +169,12 @@ FT_BEGIN_HEADER
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes statetable_table,
FT_Bytes statetable_limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
typedef void
(*GXV_StateTable_OptData_Load_Func)( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
typedef struct GXV_StateTable_ValidatorRec_
{
@@ -188,7 +202,7 @@ FT_BEGIN_HEADER
FT_ULong* classTable_length_p,
FT_ULong* stateArray_length_p,
FT_ULong* entryTable_length_p,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
typedef void
(*GXV_XStateTable_Entry_Validate_Func)(
@@ -197,7 +211,7 @@ FT_BEGIN_HEADER
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes xstatetable_table,
FT_Bytes xstatetable_limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
typedef GXV_StateTable_OptData_Load_Func GXV_XStateTable_OptData_Load_Func;
@@ -234,6 +248,9 @@ FT_BEGIN_HEADER
GXV_Lookup_Fmt4_Transit_Func lookupfmt4_trans;
FT_Bytes lookuptbl_head;
+ FT_UShort min_gid;
+ FT_UShort max_gid;
+
GXV_StateTable_ValidatorRec statetable;
GXV_XStateTable_ValidatorRec xstatetable;
@@ -246,35 +263,35 @@ FT_BEGIN_HEADER
#define GXV_TABLE_DATA( tag, field ) \
- ( ( (GXV_ ## tag ## _Data)valid->table_data )->field )
+ ( ( (GXV_ ## tag ## _Data)gxvalid->table_data )->field )
#undef FT_INVALID_
-#define FT_INVALID_( _prefix, _error ) \
- ft_validator_error( valid->root, _prefix ## _error )
+#define FT_INVALID_( _error ) \
+ ft_validator_error( gxvalid->root, FT_THROW( _error ) )
#define GXV_LIMIT_CHECK( _count ) \
FT_BEGIN_STMNT \
- if ( p + _count > ( limit? limit : valid->root->limit ) ) \
+ if ( p + _count > ( limit? limit : gxvalid->root->limit ) ) \
FT_INVALID_TOO_SHORT; \
FT_END_STMNT
#ifdef FT_DEBUG_LEVEL_TRACE
-#define GXV_INIT valid->debug_indent = 0
+#define GXV_INIT gxvalid->debug_indent = 0
#define GXV_NAME_ENTER( name ) \
FT_BEGIN_STMNT \
- valid->debug_indent += 2; \
- FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
+ gxvalid->debug_indent += 2; \
+ FT_TRACE4(( "%*.s", gxvalid->debug_indent, 0 )); \
FT_TRACE4(( "%s table\n", name )); \
FT_END_STMNT
-#define GXV_EXIT valid->debug_indent -= 2
+#define GXV_EXIT gxvalid->debug_indent -= 2
#define GXV_TRACE( s ) \
FT_BEGIN_STMNT \
- FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
+ FT_TRACE4(( "%*.s", gxvalid->debug_indent, 0 )); \
FT_TRACE4( s ); \
FT_END_STMNT
@@ -300,8 +317,8 @@ FT_BEGIN_HEADER
#define GXV_32BIT_ALIGNMENT_VALIDATE( a ) \
FT_BEGIN_STMNT \
{ \
- if ( 0 != ( (a) % 4 ) ) \
- FT_INVALID_OFFSET ; \
+ if ( (a) & 3 ) \
+ FT_INVALID_OFFSET; \
} \
FT_END_STMNT
@@ -332,7 +349,7 @@ FT_BEGIN_HEADER
\
\
for ( b = p; b < (FT_Bytes)p + len; b++ ) \
- if ( 0x40 < *b && *b < 0x7e ) \
+ if ( 0x40 < *b && *b < 0x7E ) \
FT_TRACE1(("%c", *b)) ; \
else \
FT_TRACE1(("\\x%02x", *b)) ; \
@@ -356,12 +373,12 @@ FT_BEGIN_HEADER
FT_Bytes limit,
FT_UShort* unitSize_p,
FT_UShort* nUnits_p,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_LookupTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
/*************************************************************************/
@@ -374,7 +391,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Int )
gxv_glyphid_validate( FT_UShort gid,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
/*************************************************************************/
@@ -388,7 +405,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
gxv_ctlPoint_validate( FT_UShort gid,
FT_Short ctl_point,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
/*************************************************************************/
@@ -403,7 +420,7 @@ FT_BEGIN_HEADER
gxv_sfntName_validate( FT_UShort name_index,
FT_UShort min_index,
FT_UShort max_index,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
/*************************************************************************/
@@ -422,7 +439,7 @@ FT_BEGIN_HEADER
FT_UShort* classTable_length_p,
FT_UShort* stateArray_length_p,
FT_UShort* entryTable_length_p,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_XStateTable_subtable_setup( FT_ULong table_size,
@@ -432,17 +449,17 @@ FT_BEGIN_HEADER
FT_ULong* classTable_length_p,
FT_ULong* stateArray_length_p,
FT_ULong* entryTable_length_p,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_StateTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_XStateTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
/*************************************************************************/
@@ -458,14 +475,14 @@ FT_BEGIN_HEADER
FT_Bytes limit,
FT_Byte* min,
FT_Byte* max,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_array_getlimits_ushort( FT_Bytes table,
FT_Bytes limit,
FT_UShort* min,
FT_UShort* max,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_set_length_by_ushort_offset( FT_UShort* offset,
@@ -473,7 +490,7 @@ FT_BEGIN_HEADER
FT_UShort* buff,
FT_UInt nmemb,
FT_UShort limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_set_length_by_ulong_offset( FT_ULong* offset,
@@ -481,19 +498,19 @@ FT_BEGIN_HEADER
FT_ULong* buff,
FT_UInt nmemb,
FT_ULong limit,
- GXV_Validator valid);
+ GXV_Validator gxvalid);
#define GXV_SUBTABLE_OFFSET_CHECK( _offset ) \
FT_BEGIN_STMNT \
- if ( (_offset) > valid->subtable_length ) \
+ if ( (_offset) > gxvalid->subtable_length ) \
FT_INVALID_OFFSET; \
FT_END_STMNT
#define GXV_SUBTABLE_LIMIT_CHECK( _count ) \
FT_BEGIN_STMNT \
- if ( ( p + (_count) - valid->subtable_start ) > \
- valid->subtable_length ) \
+ if ( ( p + (_count) - gxvalid->subtable_start ) > \
+ gxvalid->subtable_length ) \
FT_INVALID_TOO_SHORT; \
FT_END_STMNT
@@ -539,7 +556,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
gxv_odtect_validate( GXV_odtect_Range odtect,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
#define GXV_ODTECT( n, odtect ) \
diff --git a/src/3rdparty/freetype/src/gxvalid/gxverror.h b/src/3rdparty/freetype/src/gxvalid/gxverror.h
index 0196199227..c573b72de7 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxverror.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxverror.h
@@ -4,7 +4,8 @@
/* */
/* TrueTypeGX/AAT validation module error codes (specification only). */
/* */
-/* Copyright 2004, 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
+/* Copyright 2004, 2005, 2012-2013 */
+/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -38,10 +39,9 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX GXV_Err_
-#define FT_ERR_BASE FT_Mod_Err_GXV
-
-#define FT_KEEP_ERR_PREFIX
+#define FT_ERR_BASE FT_Mod_Err_GXvalid
#include FT_ERRORS_H
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvfeat.c b/src/3rdparty/freetype/src/gxvalid/gxvfeat.c
index 002fec6d6b..69298b2869 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, 2005, 2008 by */
+/* Copyright 2004, 2005, 2008, 2012 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -82,7 +82,7 @@
gxv_feat_registry_validate( FT_UShort feature,
FT_UShort nSettings,
FT_Bool exclusive,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_NAME_ENTER( "feature in registry" );
@@ -92,8 +92,7 @@
{
GXV_TRACE(( "feature number %d is out of range %d\n",
feature, gxv_feat_registry_length ));
- if ( valid->root->level == FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
goto Exit;
}
@@ -101,8 +100,7 @@
{
GXV_TRACE(( "feature number %d is in defined range but doesn't exist\n",
feature ));
- if ( valid->root->level == FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
goto Exit;
}
@@ -110,7 +108,7 @@
{
/* Don't use here. Apple is reserved. */
GXV_TRACE(( "feature number %d is reserved by Apple\n", feature ));
- if ( valid->root->level >= FT_VALIDATE_TIGHT )
+ if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
FT_INVALID_DATA;
}
@@ -119,7 +117,7 @@
GXV_TRACE(( "feature %d: nSettings %d != defined nSettings %d\n",
feature, nSettings,
gxv_feat_registry[feature].nSettings ));
- if ( valid->root->level >= FT_VALIDATE_TIGHT )
+ if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
FT_INVALID_DATA;
}
@@ -127,7 +125,7 @@
{
GXV_TRACE(( "exclusive flag %d differs from predefined value\n",
exclusive ));
- if ( valid->root->level >= FT_VALIDATE_TIGHT )
+ if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
FT_INVALID_DATA;
}
@@ -139,7 +137,7 @@
static void
gxv_feat_name_index_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -155,7 +153,7 @@
gxv_sfntName_validate( (FT_UShort)nameIndex,
255,
32768U,
- valid );
+ gxvalid );
GXV_EXIT;
}
@@ -165,7 +163,7 @@
gxv_feat_setting_validate( FT_Bytes table,
FT_Bytes limit,
FT_Bool exclusive,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort setting;
@@ -178,10 +176,10 @@
setting = FT_NEXT_USHORT( p );
/* If we have exclusive setting, the setting should be odd. */
- if ( exclusive && ( setting % 2 ) == 0 )
+ if ( exclusive && ( setting & 1 ) == 0 )
FT_INVALID_DATA;
- gxv_feat_name_index_validate( p, limit, valid );
+ gxv_feat_name_index_validate( p, limit, gxvalid );
GXV_FEAT_DATA( setting ) = setting;
@@ -192,7 +190,7 @@
static void
gxv_feat_name_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UInt reserved_size = GXV_FEAT_DATA( reserved_size );
@@ -222,9 +220,8 @@
if ( settingTable < reserved_size )
FT_INVALID_OFFSET;
- if ( valid->root->level == FT_VALIDATE_PARANOID &&
- ( featureFlags & GXV_FEAT_MASK_UNUSED ) == 0 )
- FT_INVALID_DATA;
+ if ( ( featureFlags & GXV_FEAT_MASK_UNUSED ) == 0 )
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
exclusive = FT_BOOL( featureFlags & GXV_FEAT_MASK_EXCLUSIVE_SETTINGS );
if ( exclusive )
@@ -243,18 +240,17 @@
FT_INVALID_FORMAT;
}
- gxv_feat_registry_validate( feature, nSettings, exclusive, valid );
+ gxv_feat_registry_validate( feature, nSettings, exclusive, gxvalid );
- gxv_feat_name_index_validate( p, limit, valid );
+ gxv_feat_name_index_validate( p, limit, gxvalid );
- p = valid->root->base + settingTable;
+ p = gxvalid->root->base + settingTable;
for ( last_setting = -1, i = 0; i < nSettings; i++ )
{
- gxv_feat_setting_validate( p, limit, exclusive, valid );
+ gxv_feat_setting_validate( p, limit, exclusive, gxvalid );
- if ( valid->root->level == FT_VALIDATE_PARANOID &&
- (FT_Int)GXV_FEAT_DATA( setting ) <= last_setting )
- FT_INVALID_FORMAT;
+ if ( (FT_Int)GXV_FEAT_DATA( setting ) <= last_setting )
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
last_setting = (FT_Int)GXV_FEAT_DATA( setting );
/* setting + nameIndex */
@@ -278,8 +274,8 @@
FT_Face face,
FT_Validator ftvalid )
{
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_feat_DataRec featrec;
GXV_feat_Data feat = &featrec;
@@ -293,9 +289,9 @@
FT_Int last_feature;
- valid->root = ftvalid;
- valid->table_data = feat;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = feat;
+ gxvalid->face = face;
FT_TRACE3(( "validating `feat' table\n" ));
GXV_INIT;
@@ -312,8 +308,8 @@
featureNameCount = FT_NEXT_USHORT( p );
GXV_TRACE(( " (featureNameCount = %d)\n", featureNameCount ));
- if ( valid->root->level != FT_VALIDATE_PARANOID )
- p += 6; /* skip (none) and (none) */
+ if ( !( IS_PARANOID_VALIDATION ) )
+ p += 6; /* skip (none) and (none) */
else
{
if ( FT_NEXT_USHORT( p ) != 0 )
@@ -327,11 +323,10 @@
for ( last_feature = -1, i = 0; i < featureNameCount; i++ )
{
- gxv_feat_name_validate( p, limit, valid );
+ gxv_feat_name_validate( p, limit, gxvalid );
- if ( valid->root->level == FT_VALIDATE_PARANOID &&
- (FT_Int)GXV_FEAT_DATA( feature ) <= last_feature )
- FT_INVALID_FORMAT;
+ if ( (FT_Int)GXV_FEAT_DATA( feature ) <= last_feature )
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
last_feature = GXV_FEAT_DATA( feature );
p += 2 + 2 + 4 + 2 + 2;
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvjust.c b/src/3rdparty/freetype/src/gxvalid/gxvjust.c
index e14f946f2d..24c26a5655 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 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
+/* Copyright 2005, 2014 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -65,40 +65,69 @@
#define GXV_JUST_DATA( a ) GXV_TABLE_DATA( just, a )
+ /* GX just table does not define their subset of GID */
+ static void
+ gxv_just_check_max_gid( FT_UShort gid,
+ const FT_String* msg_tag,
+ GXV_Validator gxvalid )
+ {
+ if ( gid < gxvalid->face->num_glyphs )
+ return;
+
+ GXV_TRACE(( "just table includes too large %s"
+ " GID=%d > %d (in maxp)\n",
+ msg_tag, gid, gxvalid->face->num_glyphs ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
+ }
+
+
static void
gxv_just_wdp_entry_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_ULong justClass;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_Fixed beforeGrowLimit;
FT_Fixed beforeShrinkGrowLimit;
FT_Fixed afterGrowLimit;
FT_Fixed afterShrinkGrowLimit;
FT_UShort growFlags;
FT_UShort shrinkFlags;
+#endif
GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 + 4 + 2 + 2 );
justClass = FT_NEXT_ULONG( p );
+#ifndef GXV_LOAD_UNUSED_VARS
+ p += 4 + 4 + 4 + 4 + 2 + 2;
+#else
beforeGrowLimit = FT_NEXT_ULONG( p );
beforeShrinkGrowLimit = FT_NEXT_ULONG( p );
afterGrowLimit = FT_NEXT_ULONG( p );
afterShrinkGrowLimit = FT_NEXT_ULONG( p );
growFlags = FT_NEXT_USHORT( p );
shrinkFlags = FT_NEXT_USHORT( p );
+#endif
- /* TODO: decode flags for human readability */
+ /* According to Apple spec, only 7bits in justClass is used */
+ if ( ( justClass & 0xFFFFFF80UL ) != 0 )
+ {
+ GXV_TRACE(( "just table includes non-zero value"
+ " in unused justClass higher bits"
+ " of WidthDeltaPair" ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
+ }
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
}
static void
gxv_just_wdc_entry_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_ULong count, i;
@@ -109,18 +138,18 @@
for ( i = 0; i < count; i++ )
{
GXV_TRACE(( "validating wdc pair %d/%d\n", i + 1, count ));
- gxv_just_wdp_entry_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_just_wdp_entry_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
}
static void
gxv_just_widthDeltaClusters_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table ;
FT_Bytes wdc_end = table + GXV_JUST_DATA( wdc_offset_max );
@@ -134,11 +163,11 @@
for ( i = 0; p <= wdc_end; i++ )
{
- gxv_just_wdc_entry_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_just_wdc_entry_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -147,14 +176,15 @@
static void
gxv_just_actSubrecord_type0_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_Fixed lowerLimit;
FT_Fixed upperLimit;
-
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort order;
+#endif
FT_UShort decomposedCount;
FT_UInt i;
@@ -163,9 +193,20 @@
GXV_LIMIT_CHECK( 4 + 4 + 2 + 2 );
lowerLimit = FT_NEXT_ULONG( p );
upperLimit = FT_NEXT_ULONG( p );
+#ifdef GXV_LOAD_UNUSED_VARS
order = FT_NEXT_USHORT( p );
+#else
+ p += 2;
+#endif
decomposedCount = FT_NEXT_USHORT( p );
+ if ( lowerLimit >= upperLimit )
+ {
+ GXV_TRACE(( "just table includes invalid range spec:"
+ " lowerLimit(%d) > upperLimit(%d)\n" ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
+ }
+
for ( i = 0; i < decomposedCount; i++ )
{
FT_UShort glyphs;
@@ -173,16 +214,17 @@
GXV_LIMIT_CHECK( 2 );
glyphs = FT_NEXT_USHORT( p );
+ gxv_just_check_max_gid( glyphs, "type0:glyphs", gxvalid );
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
}
static void
gxv_just_actSubrecord_type1_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort addGlyph;
@@ -191,34 +233,47 @@
GXV_LIMIT_CHECK( 2 );
addGlyph = FT_NEXT_USHORT( p );
- valid->subtable_length = p - table;
+ gxv_just_check_max_gid( addGlyph, "type1:addGlyph", gxvalid );
+
+ gxvalid->subtable_length = p - table;
}
static void
gxv_just_actSubrecord_type2_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
- FT_Fixed substThreshhold; /* Apple misspelled "Threshhold" */
+#ifdef GXV_LOAD_UNUSED_VARS
+ FT_Fixed substThreshhold; /* Apple misspelled "Threshhold" */
+#endif
FT_UShort addGlyph;
FT_UShort substGlyph;
GXV_LIMIT_CHECK( 4 + 2 + 2 );
+#ifdef GXV_LOAD_UNUSED_VARS
substThreshhold = FT_NEXT_ULONG( p );
+#else
+ p += 4;
+#endif
addGlyph = FT_NEXT_USHORT( p );
substGlyph = FT_NEXT_USHORT( p );
- valid->subtable_length = p - table;
+ if ( addGlyph != 0xFFFF )
+ gxv_just_check_max_gid( addGlyph, "type2:addGlyph", gxvalid );
+
+ gxv_just_check_max_gid( substGlyph, "type2:substGlyph", gxvalid );
+
+ gxvalid->subtable_length = p - table;
}
static void
gxv_just_actSubrecord_type4_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_ULong variantsAxis;
@@ -233,14 +288,29 @@
noStretchValue = FT_NEXT_ULONG( p );
maximumLimit = FT_NEXT_ULONG( p );
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
+
+ if ( variantsAxis != 0x64756374L ) /* 'duct' */
+ GXV_TRACE(( "variantsAxis 0x%08x is non default value",
+ variantsAxis ));
+
+ if ( minimumLimit > noStretchValue )
+ GXV_TRACE(( "type4:minimumLimit 0x%08x > noStretchValue 0x%08x\n",
+ minimumLimit, noStretchValue ));
+ else if ( noStretchValue > maximumLimit )
+ GXV_TRACE(( "type4:noStretchValue 0x%08x > maximumLimit 0x%08x\n",
+ noStretchValue, maximumLimit ));
+ else if ( !IS_PARANOID_VALIDATION )
+ return;
+
+ FT_INVALID_DATA;
}
static void
gxv_just_actSubrecord_type5_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort flags;
@@ -251,7 +321,12 @@
flags = FT_NEXT_USHORT( p );
glyph = FT_NEXT_USHORT( p );
- valid->subtable_length = p - table;
+ if ( flags )
+ GXV_TRACE(( "type5: nonzero value 0x%04x in unused flags\n",
+ flags ));
+ gxv_just_check_max_gid( glyph, "type5:glyph", gxvalid );
+
+ gxvalid->subtable_length = p - table;
}
@@ -259,7 +334,7 @@
static void
gxv_just_actSubrecord_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort actionClass;
@@ -274,22 +349,26 @@
actionType = FT_NEXT_USHORT( p );
actionLength = FT_NEXT_ULONG( p );
+ /* actionClass is related with justClass using 7bit only */
+ if ( ( actionClass & 0xFF80 ) != 0 )
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
+
if ( actionType == 0 )
- gxv_just_actSubrecord_type0_validate( p, limit, valid );
+ gxv_just_actSubrecord_type0_validate( p, limit, gxvalid );
else if ( actionType == 1 )
- gxv_just_actSubrecord_type1_validate( p, limit, valid );
+ gxv_just_actSubrecord_type1_validate( p, limit, gxvalid );
else if ( actionType == 2 )
- gxv_just_actSubrecord_type2_validate( p, limit, valid );
+ gxv_just_actSubrecord_type2_validate( p, limit, gxvalid );
else if ( actionType == 3 )
; /* Stretch glyph action: no actionData */
else if ( actionType == 4 )
- gxv_just_actSubrecord_type4_validate( p, limit, valid );
+ gxv_just_actSubrecord_type4_validate( p, limit, gxvalid );
else if ( actionType == 5 )
- gxv_just_actSubrecord_type5_validate( p, limit, valid );
+ gxv_just_actSubrecord_type5_validate( p, limit, gxvalid );
else
FT_INVALID_DATA;
- valid->subtable_length = actionLength;
+ gxvalid->subtable_length = actionLength;
GXV_EXIT;
}
@@ -298,7 +377,7 @@
static void
gxv_just_pcActionRecord_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_ULong actionCount;
@@ -311,11 +390,11 @@
for ( i = 0; i < actionCount; i++ )
{
- gxv_just_actSubrecord_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_just_actSubrecord_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -324,7 +403,7 @@
static void
gxv_just_pcTable_LookupValue_entry_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UNUSED( glyph );
@@ -338,19 +417,19 @@
static void
gxv_just_pcLookupTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_Bytes p = table;
+ FT_Bytes p = table;
GXV_NAME_ENTER( "just pcLookupTable" );
GXV_JUST_DATA( pc_offset_max ) = 0x0000;
GXV_JUST_DATA( pc_offset_min ) = 0xFFFFU;
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_just_pcTable_LookupValue_entry_validate;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_just_pcTable_LookupValue_entry_validate;
- gxv_LookupTable_validate( p, limit, valid );
+ gxv_LookupTable_validate( p, limit, gxvalid );
/* subtable_length is set by gxv_LookupTable_validate() */
@@ -361,20 +440,20 @@
static void
gxv_just_postcompTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_NAME_ENTER( "just postcompTable" );
- gxv_just_pcLookupTable_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_just_pcLookupTable_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
- gxv_just_pcActionRecord_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_just_pcActionRecord_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -387,33 +466,37 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
+ /* TODO: validate markClass & currentClass */
FT_UShort setMark;
FT_UShort dontAdvance;
FT_UShort markClass;
FT_UShort currentClass;
+#endif
FT_UNUSED( state );
FT_UNUSED( glyphOffset_p );
FT_UNUSED( table );
FT_UNUSED( limit );
- FT_UNUSED( valid );
-
+ FT_UNUSED( gxvalid );
+#ifndef GXV_LOAD_UNUSED_VARS
+ FT_UNUSED( flags );
+#else
setMark = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
markClass = (FT_UShort)( ( flags >> 7 ) & 0x7F );
currentClass = (FT_UShort)( flags & 0x7F );
-
- /* TODO: validate markClass & currentClass */
+#endif
}
static void
gxv_just_justClassTable_validate ( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort length;
@@ -428,18 +511,24 @@
coverage = FT_NEXT_USHORT( p );
subFeatureFlags = FT_NEXT_ULONG( p );
- GXV_TRACE(( " justClassTable: coverage = 0x%04x (%s)",
- coverage,
- ( 0x4000 & coverage ) == 0 ? "ascending" : "descending" ));
+ GXV_TRACE(( " justClassTable: coverage = 0x%04x (%s) ", coverage ));
+ if ( ( coverage & 0x4000 ) == 0 )
+ GXV_TRACE(( "ascending\n" ));
+ else
+ GXV_TRACE(( "descending\n" ));
+
+ if ( subFeatureFlags )
+ GXV_TRACE(( " justClassTable: nonzero value (0x%08x)"
+ " in unused subFeatureFlags\n", subFeatureFlags ));
- valid->statetable.optdata = NULL;
- valid->statetable.optdata_load_func = NULL;
- valid->statetable.subtable_setup_func = NULL;
- valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
- valid->statetable.entry_validate_func =
+ gxvalid->statetable.optdata = NULL;
+ gxvalid->statetable.optdata_load_func = NULL;
+ gxvalid->statetable.subtable_setup_func = NULL;
+ gxvalid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
+ gxvalid->statetable.entry_validate_func =
gxv_just_classTable_entry_validate;
- gxv_StateTable_validate( p, table + length, valid );
+ gxv_StateTable_validate( p, table + length, gxvalid );
/* subtable_length is set by gxv_LookupTable_validate() */
@@ -450,7 +539,7 @@
static void
gxv_just_wdcTable_LookupValue_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UNUSED( glyph );
@@ -464,7 +553,7 @@
static void
gxv_just_justData_lookuptable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -472,10 +561,10 @@
GXV_JUST_DATA( wdc_offset_max ) = 0x0000;
GXV_JUST_DATA( wdc_offset_min ) = 0xFFFFU;
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_just_wdcTable_LookupValue_validate;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_just_wdcTable_LookupValue_validate;
- gxv_LookupTable_validate( p, limit, valid );
+ gxv_LookupTable_validate( p, limit, gxvalid );
/* subtable_length is set by gxv_LookupTable_validate() */
@@ -489,7 +578,7 @@
static void
gxv_just_justData_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/*
* following 3 offsets are measured from the start of `just'
@@ -515,36 +604,36 @@
GXV_TRACE(( " (wdcTableOffset = 0x%04x)\n", wdcTableOffset ));
GXV_TRACE(( " (pcTableOffset = 0x%04x)\n", pcTableOffset ));
- gxv_just_justData_lookuptable_validate( p, limit, valid );
- gxv_odtect_add_range( p, valid->subtable_length,
+ gxv_just_justData_lookuptable_validate( p, limit, gxvalid );
+ gxv_odtect_add_range( p, gxvalid->subtable_length,
"just_LookupTable", odtect );
if ( wdcTableOffset )
{
gxv_just_widthDeltaClusters_validate(
- valid->root->base + wdcTableOffset, limit, valid );
- gxv_odtect_add_range( valid->root->base + wdcTableOffset,
- valid->subtable_length, "just_wdcTable", odtect );
+ gxvalid->root->base + wdcTableOffset, limit, gxvalid );
+ gxv_odtect_add_range( gxvalid->root->base + wdcTableOffset,
+ gxvalid->subtable_length, "just_wdcTable", odtect );
}
if ( pcTableOffset )
{
- gxv_just_postcompTable_validate( valid->root->base + pcTableOffset,
- limit, valid );
- gxv_odtect_add_range( valid->root->base + pcTableOffset,
- valid->subtable_length, "just_pcTable", odtect );
+ gxv_just_postcompTable_validate( gxvalid->root->base + pcTableOffset,
+ limit, gxvalid );
+ gxv_odtect_add_range( gxvalid->root->base + pcTableOffset,
+ gxvalid->subtable_length, "just_pcTable", odtect );
}
if ( justClassTableOffset )
{
gxv_just_justClassTable_validate(
- valid->root->base + justClassTableOffset, limit, valid );
- gxv_odtect_add_range( valid->root->base + justClassTableOffset,
- valid->subtable_length, "just_justClassTable",
+ gxvalid->root->base + justClassTableOffset, limit, gxvalid );
+ gxv_odtect_add_range( gxvalid->root->base + justClassTableOffset,
+ gxvalid->subtable_length, "just_justClassTable",
odtect );
}
- gxv_odtect_validate( odtect, valid );
+ gxv_odtect_validate( odtect, gxvalid );
GXV_EXIT;
}
@@ -557,10 +646,9 @@
{
FT_Bytes p = table;
FT_Bytes limit = 0;
- FT_Offset table_size;
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_just_DataRec justrec;
GXV_just_Data just = &justrec;
@@ -574,15 +662,14 @@
GXV_ODTECT_INIT( odtect );
- valid->root = ftvalid;
- valid->table_data = just;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = just;
+ gxvalid->face = face;
FT_TRACE3(( "validating `just' table\n" ));
GXV_INIT;
- limit = valid->root->limit;
- table_size = limit - table;
+ limit = gxvalid->root->limit;
GXV_LIMIT_CHECK( 4 + 2 + 2 + 2 );
version = FT_NEXT_ULONG( p );
@@ -609,19 +696,19 @@
/* validate justData */
if ( 0 < horizOffset )
{
- gxv_just_justData_validate( table + horizOffset, limit, valid );
- gxv_odtect_add_range( table + horizOffset, valid->subtable_length,
+ gxv_just_justData_validate( table + horizOffset, limit, gxvalid );
+ gxv_odtect_add_range( table + horizOffset, gxvalid->subtable_length,
"horizJustData", odtect );
}
if ( 0 < vertOffset )
{
- gxv_just_justData_validate( table + vertOffset, limit, valid );
- gxv_odtect_add_range( table + vertOffset, valid->subtable_length,
+ gxv_just_justData_validate( table + vertOffset, limit, gxvalid );
+ gxv_odtect_add_range( table + vertOffset, gxvalid->subtable_length,
"vertJustData", odtect );
}
- gxv_odtect_validate( odtect, valid );
+ gxv_odtect_validate( odtect, gxvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvkern.c b/src/3rdparty/freetype/src/gxvalid/gxvkern.c
index 2137db842a..787e3db830 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, 2005, 2006, 2007 */
+/* Copyright 2004-2007, 2013 */
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -79,20 +79,20 @@
#define GXV_KERN_DATA( field ) GXV_TABLE_DATA( kern, field )
-#define KERN_IS_CLASSIC( valid ) \
+#define KERN_IS_CLASSIC( gxvalid ) \
( KERN_VERSION_CLASSIC == GXV_KERN_DATA( version ) )
-#define KERN_IS_NEW( valid ) \
+#define KERN_IS_NEW( gxvalid ) \
( KERN_VERSION_NEW == GXV_KERN_DATA( version ) )
-#define KERN_DIALECT( valid ) \
+#define KERN_DIALECT( gxvalid ) \
GXV_KERN_DATA( dialect_request )
-#define KERN_ALLOWS_MS( valid ) \
- ( KERN_DIALECT( valid ) & KERN_DIALECT_MS )
-#define KERN_ALLOWS_APPLE( valid ) \
- ( KERN_DIALECT( valid ) & KERN_DIALECT_APPLE )
+#define KERN_ALLOWS_MS( gxvalid ) \
+ ( KERN_DIALECT( gxvalid ) & KERN_DIALECT_MS )
+#define KERN_ALLOWS_APPLE( gxvalid ) \
+ ( KERN_DIALECT( gxvalid ) & KERN_DIALECT_APPLE )
-#define GXV_KERN_HEADER_SIZE ( KERN_IS_NEW( valid ) ? 8 : 4 )
-#define GXV_KERN_SUBTABLE_HEADER_SIZE ( KERN_IS_NEW( valid ) ? 8 : 6 )
+#define GXV_KERN_HEADER_SIZE ( KERN_IS_NEW( gxvalid ) ? 8 : 4 )
+#define GXV_KERN_SUBTABLE_HEADER_SIZE ( KERN_IS_NEW( gxvalid ) ? 8 : 6 )
/*************************************************************************/
@@ -110,7 +110,7 @@
gxv_kern_subtable_fmt0_pairs_validate( FT_Bytes table,
FT_Bytes limit,
FT_UShort nPairs,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort i;
@@ -127,16 +127,18 @@
{
FT_UShort gid_left;
FT_UShort gid_right;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_Short kernValue;
+#endif
/* left */
gid_left = FT_NEXT_USHORT( p );
- gxv_glyphid_validate( gid_left, valid );
+ gxv_glyphid_validate( gid_left, gxvalid );
/* right */
gid_right = FT_NEXT_USHORT( p );
- gxv_glyphid_validate( gid_right, valid );
+ gxv_glyphid_validate( gid_right, gxvalid );
/* Pairs of left and right GIDs must be unique and sorted. */
GXV_TRACE(( "left gid = %u, right gid = %u\n", gid_left, gid_right ));
@@ -156,7 +158,11 @@
FT_INVALID_DATA;
/* skip the kern value */
+#ifdef GXV_LOAD_UNUSED_VARS
kernValue = FT_NEXT_SHORT( p );
+#else
+ p += 2;
+#endif
}
GXV_EXIT;
@@ -165,7 +171,7 @@
static void
gxv_kern_subtable_fmt0_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table + GXV_KERN_SUBTABLE_HEADER_SIZE;
@@ -180,10 +186,10 @@
/* nPairs, searchRange, entrySelector, rangeShift */
GXV_LIMIT_CHECK( 2 + 2 + 2 + 2 );
- gxv_BinSrchHeader_validate( p, limit, &unitSize, &nPairs, valid );
+ gxv_BinSrchHeader_validate( p, limit, &unitSize, &nPairs, gxvalid );
p += 2 + 2 + 2 + 2;
- gxv_kern_subtable_fmt0_pairs_validate( p, limit, nPairs, valid );
+ gxv_kern_subtable_fmt0_pairs_validate( p, limit, nPairs, gxvalid );
GXV_EXIT;
}
@@ -203,11 +209,11 @@
static void
gxv_kern_subtable_fmt1_valueTable_load( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_kern_fmt1_StateOptRecData optdata =
- (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
+ (GXV_kern_fmt1_StateOptRecData)gxvalid->statetable.optdata;
GXV_LIMIT_CHECK( 2 );
@@ -226,14 +232,14 @@
FT_UShort* classTable_length_p,
FT_UShort* stateArray_length_p,
FT_UShort* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort o[4];
FT_UShort *l[4];
FT_UShort buff[5];
GXV_kern_fmt1_StateOptRecData optdata =
- (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
+ (GXV_kern_fmt1_StateOptRecData)gxvalid->statetable.optdata;
o[0] = classTable;
@@ -245,7 +251,7 @@
l[2] = entryTable_length_p;
l[3] = &(optdata->valueTable_length);
- gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, valid );
+ gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, gxvalid );
}
@@ -259,25 +265,31 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort push;
FT_UShort dontAdvance;
+#endif
FT_UShort valueOffset;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort kernAction;
FT_UShort kernValue;
+#endif
FT_UNUSED( state );
FT_UNUSED( glyphOffset_p );
+#ifdef GXV_LOAD_UNUSED_VARS
push = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
+#endif
valueOffset = (FT_UShort)( flags & 0x3FFF );
{
GXV_kern_fmt1_StateOptRecData vt_rec =
- (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
+ (GXV_kern_fmt1_StateOptRecData)gxvalid->statetable.optdata;
FT_Bytes p;
@@ -288,8 +300,10 @@
limit = table + vt_rec->valueTable + vt_rec->valueTable_length;
GXV_LIMIT_CHECK( 2 + 2 );
+#ifdef GXV_LOAD_UNUSED_VARS
kernAction = FT_NEXT_USHORT( p );
kernValue = FT_NEXT_USHORT( p );
+#endif
}
}
@@ -297,7 +311,7 @@
static void
gxv_kern_subtable_fmt1_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_kern_fmt1_StateOptRec vt_rec;
@@ -305,18 +319,18 @@
GXV_NAME_ENTER( "kern subtable format 1" );
- valid->statetable.optdata =
+ gxvalid->statetable.optdata =
&vt_rec;
- valid->statetable.optdata_load_func =
+ gxvalid->statetable.optdata_load_func =
gxv_kern_subtable_fmt1_valueTable_load;
- valid->statetable.subtable_setup_func =
+ gxvalid->statetable.subtable_setup_func =
gxv_kern_subtable_fmt1_subtable_setup;
- valid->statetable.entry_glyphoffset_fmt =
+ gxvalid->statetable.entry_glyphoffset_fmt =
GXV_GLYPHOFFSET_NONE;
- valid->statetable.entry_validate_func =
+ gxvalid->statetable.entry_validate_func =
gxv_kern_subtable_fmt1_entry_validate;
- gxv_StateTable_validate( p, limit, valid );
+ gxv_StateTable_validate( p, limit, gxvalid );
GXV_EXIT;
}
@@ -359,7 +373,7 @@
gxv_kern_subtable_fmt2_clstbl_validate( FT_Bytes table,
FT_Bytes limit,
GXV_kern_ClassSpec spec,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
const FT_String* tag = GXV_KERN_FMT2_DATA( class_tag[spec] );
GXV_odtect_Range odtect = GXV_KERN_FMT2_DATA( odtect );
@@ -377,13 +391,13 @@
GXV_TRACE(( " %s firstGlyph=%d, nGlyphs=%d\n",
tag, firstGlyph, nGlyphs ));
- gxv_glyphid_validate( firstGlyph, valid );
- gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs - 1 ), valid );
+ gxv_glyphid_validate( firstGlyph, gxvalid );
+ gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs - 1 ), gxvalid );
gxv_array_getlimits_ushort( p, p + ( 2 * nGlyphs ),
&( GXV_KERN_FMT2_DATA( offset_min[spec] ) ),
&( GXV_KERN_FMT2_DATA( offset_max[spec] ) ),
- valid );
+ gxvalid );
gxv_odtect_add_range( table, 2 * nGlyphs, tag, odtect );
@@ -394,7 +408,7 @@
static void
gxv_kern_subtable_fmt2_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_ODTECT( 3, odtect );
GXV_kern_subtable_fmt2_DataRec fmt2_rec =
@@ -425,10 +439,10 @@
GXV_LIMIT_CHECK( GXV_KERN_FMT2_DATA( array ) );
gxv_kern_subtable_fmt2_clstbl_validate( table + leftOffsetTable, limit,
- GXV_KERN_CLS_L, valid );
+ GXV_KERN_CLS_L, gxvalid );
gxv_kern_subtable_fmt2_clstbl_validate( table + rightOffsetTable, limit,
- GXV_KERN_CLS_R, valid );
+ GXV_KERN_CLS_R, gxvalid );
if ( GXV_KERN_FMT2_DATA( offset_min[GXV_KERN_CLS_L] ) +
GXV_KERN_FMT2_DATA( offset_min[GXV_KERN_CLS_R] )
@@ -441,7 +455,7 @@
- GXV_KERN_FMT2_DATA( array ),
"array", odtect );
- gxv_odtect_validate( odtect, valid );
+ gxv_odtect_validate( odtect, gxvalid );
GXV_EXIT;
}
@@ -452,7 +466,7 @@
static void
gxv_kern_subtable_fmt3_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table + GXV_KERN_SUBTABLE_HEADER_SIZE;
FT_UShort glyphCount;
@@ -471,14 +485,16 @@
rightClassCount = FT_NEXT_BYTE( p );
flags = FT_NEXT_BYTE( p );
- if ( valid->face->num_glyphs != glyphCount )
+ if ( gxvalid->face->num_glyphs != glyphCount )
{
GXV_TRACE(( "maxGID=%d, but glyphCount=%d\n",
- valid->face->num_glyphs, glyphCount ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ gxvalid->face->num_glyphs, glyphCount ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
+ if ( flags != 0 )
+ GXV_TRACE(( "kern subtable fmt3 has nonzero value"
+ " (%d) in unused flag\n", flags ));
/*
* just skip kernValue[kernValueCount]
*/
@@ -493,8 +509,8 @@
GXV_LIMIT_CHECK( glyphCount );
- gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, valid );
- p += valid->subtable_length;
+ gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, gxvalid );
+ p += gxvalid->subtable_length;
if ( leftClassCount < max )
FT_INVALID_DATA;
@@ -508,8 +524,8 @@
GXV_LIMIT_CHECK( glyphCount );
- gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, valid );
- p += valid->subtable_length;
+ gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, gxvalid );
+ p += gxvalid->subtable_length;
if ( rightClassCount < max )
FT_INVALID_DATA;
@@ -533,7 +549,7 @@
}
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -542,23 +558,27 @@
static FT_Bool
gxv_kern_coverage_new_apple_validate( FT_UShort coverage,
FT_UShort* format,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/* new Apple-dialect */
+#ifdef GXV_LOAD_TRACE_VARS
FT_Bool kernVertical;
FT_Bool kernCrossStream;
FT_Bool kernVariation;
+#endif
- FT_UNUSED( valid );
+ FT_UNUSED( gxvalid );
/* reserved bits = 0 */
if ( coverage & 0x1FFC )
- return 0;
+ return FALSE;
+#ifdef GXV_LOAD_TRACE_VARS
kernVertical = FT_BOOL( ( coverage >> 15 ) & 1 );
kernCrossStream = FT_BOOL( ( coverage >> 14 ) & 1 );
kernVariation = FT_BOOL( ( coverage >> 13 ) & 1 );
+#endif
*format = (FT_UShort)( coverage & 0x0003 );
@@ -568,30 +588,34 @@
GXV_TRACE(( "kerning values in Apple format subtable are ignored\n" ));
- return 1;
+ return TRUE;
}
static FT_Bool
gxv_kern_coverage_classic_apple_validate( FT_UShort coverage,
FT_UShort* format,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/* classic Apple-dialect */
+#ifdef GXV_LOAD_TRACE_VARS
FT_Bool horizontal;
FT_Bool cross_stream;
+#endif
/* check expected flags, but don't check if MS-dialect is impossible */
- if ( !( coverage & 0xFD00 ) && KERN_ALLOWS_MS( valid ) )
- return 0;
+ if ( !( coverage & 0xFD00 ) && KERN_ALLOWS_MS( gxvalid ) )
+ return FALSE;
/* reserved bits = 0 */
if ( coverage & 0x02FC )
- return 0;
+ return FALSE;
+#ifdef GXV_LOAD_TRACE_VARS
horizontal = FT_BOOL( ( coverage >> 15 ) & 1 );
cross_stream = FT_BOOL( ( coverage >> 13 ) & 1 );
+#endif
*format = (FT_UShort)( coverage & 0x0003 );
@@ -601,36 +625,40 @@
/* format 1 requires GX State Machine, too new for classic */
if ( *format == 1 )
- return 0;
+ return FALSE;
GXV_TRACE(( "kerning values in Apple format subtable are ignored\n" ));
- return 1;
+ return TRUE;
}
static FT_Bool
gxv_kern_coverage_classic_microsoft_validate( FT_UShort coverage,
FT_UShort* format,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/* classic Microsoft-dialect */
+#ifdef GXV_LOAD_TRACE_VARS
FT_Bool horizontal;
FT_Bool minimum;
FT_Bool cross_stream;
FT_Bool override;
+#endif
- FT_UNUSED( valid );
+ FT_UNUSED( gxvalid );
/* reserved bits = 0 */
if ( coverage & 0xFDF0 )
- return 0;
+ return FALSE;
+#ifdef GXV_LOAD_TRACE_VARS
horizontal = FT_BOOL( coverage & 1 );
minimum = FT_BOOL( ( coverage >> 1 ) & 1 );
cross_stream = FT_BOOL( ( coverage >> 2 ) & 1 );
override = FT_BOOL( ( coverage >> 3 ) & 1 );
+#endif
*format = (FT_UShort)( ( coverage >> 8 ) & 0x0003 );
@@ -643,7 +671,7 @@
GXV_TRACE((
"kerning values in Microsoft format 2 subtable are ignored\n" ));
- return 1;
+ return TRUE;
}
@@ -658,7 +686,7 @@
static GXV_kern_Dialect
gxv_kern_coverage_validate( FT_UShort coverage,
FT_UShort* format,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_kern_Dialect result = KERN_DIALECT_UNKNOWN;
@@ -667,33 +695,33 @@
GXV_TRACE(( "interprete coverage 0x%04x by Apple style\n", coverage ));
- if ( KERN_IS_NEW( valid ) )
+ if ( KERN_IS_NEW( gxvalid ) )
{
if ( gxv_kern_coverage_new_apple_validate( coverage,
format,
- valid ) )
+ gxvalid ) )
{
result = KERN_DIALECT_APPLE;
goto Exit;
}
}
- if ( KERN_IS_CLASSIC( valid ) && KERN_ALLOWS_APPLE( valid ) )
+ if ( KERN_IS_CLASSIC( gxvalid ) && KERN_ALLOWS_APPLE( gxvalid ) )
{
if ( gxv_kern_coverage_classic_apple_validate( coverage,
format,
- valid ) )
+ gxvalid ) )
{
result = KERN_DIALECT_APPLE;
goto Exit;
}
}
- if ( KERN_IS_CLASSIC( valid ) && KERN_ALLOWS_MS( valid ) )
+ if ( KERN_IS_CLASSIC( gxvalid ) && KERN_ALLOWS_MS( gxvalid ) )
{
if ( gxv_kern_coverage_classic_microsoft_validate( coverage,
format,
- valid ) )
+ gxvalid ) )
{
result = KERN_DIALECT_MS;
goto Exit;
@@ -711,13 +739,17 @@
static void
gxv_kern_subtable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
+#ifdef GXV_LOAD_TRACE_VARS
FT_UShort version = 0; /* MS only: subtable version, unused */
+#endif
FT_ULong length; /* MS: 16bit, Apple: 32bit*/
FT_UShort coverage;
+#ifdef GXV_LOAD_TRACE_VARS
FT_UShort tupleIndex = 0; /* Apple only */
+#endif
FT_UShort u16[2];
FT_UShort format = 255; /* subtable format */
@@ -729,26 +761,38 @@
u16[1] = FT_NEXT_USHORT( p ); /* Apple: length_lo MS: length */
coverage = FT_NEXT_USHORT( p );
- switch ( gxv_kern_coverage_validate( coverage, &format, valid ) )
+ switch ( gxv_kern_coverage_validate( coverage, &format, gxvalid ) )
{
case KERN_DIALECT_MS:
+#ifdef GXV_LOAD_TRACE_VARS
version = u16[0];
+#endif
length = u16[1];
+#ifdef GXV_LOAD_TRACE_VARS
tupleIndex = 0;
+#endif
GXV_TRACE(( "Subtable version = %d\n", version ));
GXV_TRACE(( "Subtable length = %d\n", length ));
break;
case KERN_DIALECT_APPLE:
+#ifdef GXV_LOAD_TRACE_VARS
version = 0;
+#endif
length = ( u16[0] << 16 ) + u16[1];
+#ifdef GXV_LOAD_TRACE_VARS
tupleIndex = 0;
+#endif
GXV_TRACE(( "Subtable length = %d\n", length ));
- if ( KERN_IS_NEW( valid ) )
+ if ( KERN_IS_NEW( gxvalid ) )
{
GXV_LIMIT_CHECK( 2 );
+#ifdef GXV_LOAD_TRACE_VARS
tupleIndex = FT_NEXT_USHORT( p );
+#else
+ p += 2;
+#endif
GXV_TRACE(( "Subtable tupleIndex = %d\n", tupleIndex ));
}
break;
@@ -762,18 +806,18 @@
/* formats 1, 2, 3 require the position of the start of this subtable */
if ( format == 0 )
- gxv_kern_subtable_fmt0_validate( table, table + length, valid );
+ gxv_kern_subtable_fmt0_validate( table, table + length, gxvalid );
else if ( format == 1 )
- gxv_kern_subtable_fmt1_validate( table, table + length, valid );
+ gxv_kern_subtable_fmt1_validate( table, table + length, gxvalid );
else if ( format == 2 )
- gxv_kern_subtable_fmt2_validate( table, table + length, valid );
+ gxv_kern_subtable_fmt2_validate( table, table + length, gxvalid );
else if ( format == 3 )
- gxv_kern_subtable_fmt3_validate( table, table + length, valid );
+ gxv_kern_subtable_fmt3_validate( table, table + length, gxvalid );
else
FT_INVALID_DATA;
Exit:
- valid->subtable_length = length;
+ gxvalid->subtable_length = length;
GXV_EXIT;
}
@@ -793,8 +837,8 @@
GXV_kern_Dialect dialect_request,
FT_Validator ftvalid )
{
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_kern_DataRec kernrec;
GXV_kern_Data kern = &kernrec;
@@ -806,13 +850,13 @@
FT_UInt i;
- valid->root = ftvalid;
- valid->table_data = kern;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = kern;
+ gxvalid->face = face;
FT_TRACE3(( "validating `kern' table\n" ));
GXV_INIT;
- KERN_DIALECT( valid ) = dialect_request;
+ KERN_DIALECT( gxvalid ) = dialect_request;
GXV_LIMIT_CHECK( 2 );
GXV_KERN_DATA( version ) = (GXV_kern_Version)FT_NEXT_USHORT( p );
@@ -821,12 +865,12 @@
if ( 0x0001 < GXV_KERN_DATA( version ) )
FT_INVALID_FORMAT;
- else if ( KERN_IS_CLASSIC( valid ) )
+ else if ( KERN_IS_CLASSIC( gxvalid ) )
{
GXV_LIMIT_CHECK( 2 );
nTables = FT_NEXT_USHORT( p );
}
- else if ( KERN_IS_NEW( valid ) )
+ else if ( KERN_IS_NEW( gxvalid ) )
{
if ( classic_only )
FT_INVALID_FORMAT;
@@ -842,8 +886,8 @@
{
GXV_TRACE(( "validating subtable %d/%d\n", i, nTables ));
/* p should be 32bit-aligned? */
- gxv_kern_subtable_validate( p, 0, valid );
- p += valid->subtable_length;
+ gxv_kern_subtable_validate( p, 0, gxvalid );
+ p += gxvalid->subtable_length;
}
FT_TRACE4(( "\n" ));
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvlcar.c b/src/3rdparty/freetype/src/gxvalid/gxvlcar.c
index f14fa5b131..48308b0246 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvlcar.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvlcar.c
@@ -67,14 +67,14 @@
static void
gxv_lcar_partial_validate( FT_UShort partial,
FT_UShort glyph,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_NAME_ENTER( "partial" );
if ( GXV_LCAR_DATA( format ) != 1 )
goto Exit;
- gxv_ctlPoint_validate( glyph, partial, valid );
+ gxv_ctlPoint_validate( glyph, partial, gxvalid );
Exit:
GXV_EXIT;
@@ -84,10 +84,10 @@
static void
gxv_lcar_LookupValue_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_Bytes p = valid->root->base + value_p->u;
- FT_Bytes limit = valid->root->limit;
+ FT_Bytes p = gxvalid->root->base + value_p->u;
+ FT_Bytes limit = gxvalid->root->limit;
FT_UShort count;
FT_Short partial;
FT_UShort i;
@@ -102,7 +102,7 @@
for ( i = 0; i < count; i++ )
{
partial = FT_NEXT_SHORT( p );
- gxv_lcar_partial_validate( partial, glyph, valid );
+ gxv_lcar_partial_validate( partial, glyph, gxvalid );
}
GXV_EXIT;
@@ -148,7 +148,7 @@
gxv_lcar_LookupFmt4_transit( FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p;
FT_Bytes limit;
@@ -160,8 +160,8 @@
/* XXX: check range? */
offset = (FT_UShort)( base_value_p->u +
relative_gindex * sizeof ( FT_UShort ) );
- p = valid->root->base + offset;
- limit = valid->root->limit;
+ p = gxvalid->root->base + offset;
+ limit = gxvalid->root->limit;
GXV_LIMIT_CHECK ( 2 );
value.u = FT_NEXT_USHORT( p );
@@ -185,8 +185,8 @@
{
FT_Bytes p = table;
FT_Bytes limit = 0;
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_lcar_DataRec lcarrec;
GXV_lcar_Data lcar = &lcarrec;
@@ -194,9 +194,9 @@
FT_Fixed version;
- valid->root = ftvalid;
- valid->table_data = lcar;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = lcar;
+ gxvalid->face = face;
FT_TRACE3(( "validating `lcar' table\n" ));
GXV_INIT;
@@ -211,10 +211,10 @@
if ( GXV_LCAR_DATA( format ) > 1 )
FT_INVALID_FORMAT;
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_lcar_LookupValue_validate;
- valid->lookupfmt4_trans = gxv_lcar_LookupFmt4_transit;
- gxv_LookupTable_validate( p, limit, valid );
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_lcar_LookupValue_validate;
+ gxvalid->lookupfmt4_trans = gxv_lcar_LookupFmt4_transit;
+ gxv_LookupTable_validate( p, limit, gxvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmod.c b/src/3rdparty/freetype/src/gxvalid/gxvmod.c
index b2b16b1ff3..278d47688a 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, 2005, 2006 */
+/* Copyright 2004-2006, 2013 */
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -58,8 +58,8 @@
error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len );
- if ( error == GXV_Err_Table_Missing )
- return GXV_Err_Ok;
+ if ( FT_ERR_EQ( error, Table_Missing ) )
+ return FT_Err_Ok;
if ( error )
goto Exit;
@@ -112,7 +112,7 @@
{
FT_Memory volatile memory = FT_FACE_MEMORY( face );
- FT_Error error = GXV_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ValidatorRec volatile valid;
FT_UInt i;
@@ -200,7 +200,7 @@
/* without volatile on `error' GCC 4.1.1. emits: */
/* warning: variable 'error' might be clobbered by 'longjmp' or 'vfork' */
/* this warning seems spurious but --- */
- FT_Error volatile error = GXV_Err_Ok;
+ FT_Error volatile error;
FT_ValidatorRec volatile valid;
@@ -269,7 +269,7 @@
const FT_Module_Class gxv_module_class =
{
0,
- sizeof( FT_ModuleRec ),
+ sizeof ( FT_ModuleRec ),
"gxvalid",
0x10000L,
0x20000L,
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmod.h b/src/3rdparty/freetype/src/gxvalid/gxvmod.h
index d912a8f838..22732ba992 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmod.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmod.h
@@ -36,7 +36,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Module_Class ) gxv_module_class;
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort.c b/src/3rdparty/freetype/src/gxvalid/gxvmort.c
index 0aa066339d..55ff5a851e 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 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
+/* Copyright 2005, 2013 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -40,23 +40,21 @@
static void
gxv_mort_feature_validate( GXV_mort_feature f,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
if ( f->featureType >= gxv_feat_registry_length )
{
GXV_TRACE(( "featureType %d is out of registered range, "
"setting %d is unchecked\n",
f->featureType, f->featureSetting ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
}
else if ( !gxv_feat_registry[f->featureType].existence )
{
GXV_TRACE(( "featureType %d is within registered area "
"but undefined, setting %d is unchecked\n",
f->featureType, f->featureSetting ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
}
else
{
@@ -74,8 +72,7 @@
if ( f->featureSetting > nSettings_max )
{
GXV_TRACE(( "out of defined range %d", nSettings_max ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
}
GXV_TRACE(( "\n" ));
}
@@ -92,7 +89,7 @@
gxv_mort_featurearray_validate( FT_Bytes table,
FT_Bytes limit,
FT_ULong nFeatureFlags,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_ULong i;
@@ -109,23 +106,24 @@
f.enableFlags = FT_NEXT_ULONG( p );
f.disableFlags = FT_NEXT_ULONG( p );
- gxv_mort_feature_validate( &f, valid );
+ gxv_mort_feature_validate( &f, gxvalid );
}
if ( !IS_GXV_MORT_FEATURE_OFF( f ) )
FT_INVALID_DATA;
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
FT_LOCAL_DEF( void )
gxv_mort_coverage_validate( FT_UShort coverage,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_UNUSED( valid );
+ FT_UNUSED( gxvalid );
+#ifdef FT_DEBUG_LEVEL_TRACE
if ( coverage & 0x8000U )
GXV_TRACE(( " this subtable is for vertical text only\n" ));
else
@@ -144,6 +142,7 @@
if ( coverage & 0x1FF8 )
GXV_TRACE(( " coverage has non-zero bits in reserved area\n" ));
+#endif
}
@@ -151,7 +150,7 @@
gxv_mort_subtables_validate( FT_Bytes table,
FT_Bytes limit,
FT_UShort nSubtables,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -166,17 +165,20 @@
};
- GXV_Validate_Func func;
- FT_UShort i;
+ FT_UShort i;
GXV_NAME_ENTER( "subtables in a chain" );
for ( i = 0; i < nSubtables; i++ )
{
+ GXV_Validate_Func func;
+
FT_UShort length;
FT_UShort coverage;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_ULong subFeatureFlags;
+#endif
FT_UInt type;
FT_UInt rest;
@@ -184,7 +186,11 @@
GXV_LIMIT_CHECK( 2 + 2 + 4 );
length = FT_NEXT_USHORT( p );
coverage = FT_NEXT_USHORT( p );
+#ifdef GXV_LOAD_UNUSED_VARS
subFeatureFlags = FT_NEXT_ULONG( p );
+#else
+ p += 4;
+#endif
GXV_TRACE(( "validating chain subtable %d/%d (%d bytes)\n",
i + 1, nSubtables, length ));
@@ -192,7 +198,7 @@
rest = length - ( 2 + 2 + 4 );
GXV_LIMIT_CHECK( rest );
- gxv_mort_coverage_validate( coverage, valid );
+ gxv_mort_coverage_validate( coverage, gxvalid );
if ( type > 5 )
FT_INVALID_FORMAT;
@@ -201,12 +207,13 @@
if ( func == NULL )
GXV_TRACE(( "morx type %d is reserved\n", type ));
- func( p, p + rest, valid );
+ func( p, p + rest, gxvalid );
p += rest;
+ /* TODO: validate subFeatureFlags */
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -215,10 +222,12 @@
static void
gxv_mort_chain_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_ULong defaultFlags;
+#endif
FT_ULong chainLength;
FT_UShort nFeatureFlags;
FT_UShort nSubtables;
@@ -227,17 +236,22 @@
GXV_NAME_ENTER( "mort chain header" );
GXV_LIMIT_CHECK( 4 + 4 + 2 + 2 );
+#ifdef GXV_LOAD_UNUSED_VARS
defaultFlags = FT_NEXT_ULONG( p );
+#else
+ p += 4;
+#endif
chainLength = FT_NEXT_ULONG( p );
nFeatureFlags = FT_NEXT_USHORT( p );
nSubtables = FT_NEXT_USHORT( p );
gxv_mort_featurearray_validate( p, table + chainLength,
- nFeatureFlags, valid );
- p += valid->subtable_length;
- gxv_mort_subtables_validate( p, table + chainLength, nSubtables, valid );
- valid->subtable_length = chainLength;
+ nFeatureFlags, gxvalid );
+ p += gxvalid->subtable_length;
+ gxv_mort_subtables_validate( p, table + chainLength, nSubtables, gxvalid );
+ gxvalid->subtable_length = chainLength;
+ /* TODO: validate defaultFlags */
GXV_EXIT;
}
@@ -247,8 +261,8 @@
FT_Face face,
FT_Validator ftvalid )
{
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
FT_Bytes p = table;
FT_Bytes limit = 0;
FT_ULong version;
@@ -256,9 +270,9 @@
FT_ULong i;
- valid->root = ftvalid;
- valid->face = face;
- limit = valid->root->limit;
+ gxvalid->root = ftvalid;
+ gxvalid->face = face;
+ limit = gxvalid->root->limit;
FT_TRACE3(( "validating `mort' table\n" ));
GXV_INIT;
@@ -274,8 +288,8 @@
{
GXV_TRACE(( "validating chain %d/%d\n", i + 1, nChains ));
GXV_32BIT_ALIGNMENT_VALIDATE( p - table );
- gxv_mort_chain_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_mort_chain_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
}
FT_TRACE4(( "\n" ));
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort.h b/src/3rdparty/freetype/src/gxvalid/gxvmort.h
index 1e5a1f5ab6..8e62e52dbf 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort.h
@@ -55,36 +55,36 @@
gxv_mort_featurearray_validate( FT_Bytes table,
FT_Bytes limit,
FT_ULong nFeatureFlags,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_mort_coverage_validate( FT_UShort coverage,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_mort_subtable_type0_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_mort_subtable_type1_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_mort_subtable_type2_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_mort_subtable_type4_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_mort_subtable_type5_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
#endif /* __GXVMORT_H__ */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort0.c b/src/3rdparty/freetype/src/gxvalid/gxvmort0.c
index 0453062f63..f19016efdb 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort0.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort0.c
@@ -67,7 +67,7 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort markFirst;
FT_UShort dontAdvance;
@@ -98,10 +98,24 @@
GXV_TRACE(( " %02d", verb ));
GXV_TRACE(( " %s\n", GXV_Mort_IndicScript_Msg[verb] ));
+ if ( markFirst > 0 && markLast > 0 )
+ {
+ GXV_TRACE(( " [odd] a glyph is marked as the first and last"
+ " in Indic rearrangement\n" ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
+ }
+
+ if ( markFirst > 0 && dontAdvance > 0 )
+ {
+ GXV_TRACE(( " [odd] the first glyph is marked as dontAdvance"
+ " in Indic rearrangement\n" ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
+ }
+
if ( 0 < reserved )
{
GXV_TRACE(( " non-zero bits found in reserved range\n" ));
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
}
else
GXV_TRACE(( "\n" ));
@@ -111,7 +125,7 @@
FT_LOCAL_DEF( void )
gxv_mort_subtable_type0_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -121,14 +135,14 @@
GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE );
- valid->statetable.optdata = NULL;
- valid->statetable.optdata_load_func = NULL;
- valid->statetable.subtable_setup_func = NULL;
- valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
- valid->statetable.entry_validate_func =
+ gxvalid->statetable.optdata = NULL;
+ gxvalid->statetable.optdata_load_func = NULL;
+ gxvalid->statetable.subtable_setup_func = NULL;
+ gxvalid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
+ gxvalid->statetable.entry_validate_func =
gxv_mort_subtable_type0_entry_validate;
- gxv_StateTable_validate( p, limit, valid );
+ gxv_StateTable_validate( p, limit, gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort1.c b/src/3rdparty/freetype/src/gxvalid/gxvmort1.c
index 696d85032d..0189504edf 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort1.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort1.c
@@ -53,12 +53,12 @@
static void
gxv_mort_subtable_type1_substitutionTable_load( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_mort_subtable_type1_StateOptRecData optdata =
- (GXV_mort_subtable_type1_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type1_StateOptRecData)gxvalid->statetable.optdata;
GXV_LIMIT_CHECK( 2 );
@@ -74,14 +74,14 @@
FT_UShort* classTable_length_p,
FT_UShort* stateArray_length_p,
FT_UShort* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort o[4];
FT_UShort *l[4];
FT_UShort buff[5];
GXV_mort_subtable_type1_StateOptRecData optdata =
- (GXV_mort_subtable_type1_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type1_StateOptRecData)gxvalid->statetable.optdata;
o[0] = classTable;
@@ -93,7 +93,7 @@
l[2] = entryTable_length_p;
l[3] = &( optdata->substitutionTable_length );
- gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, valid );
+ gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, gxvalid );
}
@@ -102,12 +102,10 @@
FT_Short wordOffset,
const FT_String* tag,
FT_Byte state,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort substTable;
FT_UShort substTable_limit;
- FT_UShort min_gid;
- FT_UShort max_gid;
FT_UNUSED( tag );
FT_UNUSED( state );
@@ -115,15 +113,16 @@
substTable =
((GXV_mort_subtable_type1_StateOptRec *)
- (valid->statetable.optdata))->substitutionTable;
+ (gxvalid->statetable.optdata))->substitutionTable;
substTable_limit =
(FT_UShort)( substTable +
((GXV_mort_subtable_type1_StateOptRec *)
- (valid->statetable.optdata))->substitutionTable_length );
+ (gxvalid->statetable.optdata))->substitutionTable_length );
- min_gid = (FT_UShort)( ( substTable - wordOffset * 2 ) / 2 );
- max_gid = (FT_UShort)( ( substTable_limit - wordOffset * 2 ) / 2 );
- max_gid = (FT_UShort)( FT_MAX( max_gid, valid->face->num_glyphs ) );
+ gxvalid->min_gid = (FT_UShort)( ( substTable - wordOffset * 2 ) / 2 );
+ gxvalid->max_gid = (FT_UShort)( ( substTable_limit - wordOffset * 2 ) / 2 );
+ gxvalid->max_gid = (FT_UShort)( FT_MAX( gxvalid->max_gid,
+ gxvalid->face->num_glyphs ) );
/* XXX: check range? */
@@ -138,10 +137,12 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort setMark;
FT_UShort dontAdvance;
+#endif
FT_UShort reserved;
FT_Short markOffset;
FT_Short currentOffset;
@@ -150,8 +151,10 @@
FT_UNUSED( limit );
+#ifdef GXV_LOAD_UNUSED_VARS
setMark = (FT_UShort)( flags >> 15 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
+#endif
reserved = (FT_Short)( flags & 0x3FFF );
markOffset = (FT_Short)( glyphOffset_p->ul >> 16 );
@@ -160,31 +163,30 @@
if ( 0 < reserved )
{
GXV_TRACE(( " non-zero bits found in reserved range\n" ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
}
gxv_mort_subtable_type1_offset_to_subst_validate( markOffset,
"markOffset",
state,
- valid );
+ gxvalid );
gxv_mort_subtable_type1_offset_to_subst_validate( currentOffset,
"currentOffset",
state,
- valid );
+ gxvalid );
}
static void
gxv_mort_subtable_type1_substTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort num_gids = (FT_UShort)(
((GXV_mort_subtable_type1_StateOptRec *)
- (valid->statetable.optdata))->substitutionTable_length / 2 );
+ (gxvalid->statetable.optdata))->substitutionTable_length / 2 );
FT_UShort i;
@@ -200,13 +202,12 @@
if ( dst_gid >= 0xFFFFU )
continue;
- if ( dst_gid > valid->face->num_glyphs )
+ if ( dst_gid < gxvalid->min_gid || gxvalid->max_gid < dst_gid )
{
- GXV_TRACE(( "substTable include too large gid[%d]=%d >"
- " max defined gid #%d\n",
- i, dst_gid, valid->face->num_glyphs ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_GLYPH_ID;
+ GXV_TRACE(( "substTable include a strange gid[%d]=%d >"
+ " out of define range (%d..%d)\n",
+ i, dst_gid, gxvalid->min_gid, gxvalid->max_gid ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
}
@@ -222,7 +223,7 @@
FT_LOCAL_DEF( void )
gxv_mort_subtable_type1_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -233,23 +234,23 @@
GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE );
- valid->statetable.optdata =
+ gxvalid->statetable.optdata =
&st_rec;
- valid->statetable.optdata_load_func =
+ gxvalid->statetable.optdata_load_func =
gxv_mort_subtable_type1_substitutionTable_load;
- valid->statetable.subtable_setup_func =
+ gxvalid->statetable.subtable_setup_func =
gxv_mort_subtable_type1_subtable_setup;
- valid->statetable.entry_glyphoffset_fmt =
+ gxvalid->statetable.entry_glyphoffset_fmt =
GXV_GLYPHOFFSET_ULONG;
- valid->statetable.entry_validate_func =
+ gxvalid->statetable.entry_validate_func =
gxv_mort_subtable_type1_entry_validate;
- gxv_StateTable_validate( p, limit, valid );
+ gxv_StateTable_validate( p, limit, gxvalid );
gxv_mort_subtable_type1_substTable_validate(
table + st_rec.substitutionTable,
table + st_rec.substitutionTable + st_rec.substitutionTable_length,
- valid );
+ gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort2.c b/src/3rdparty/freetype/src/gxvalid/gxvmort2.c
index 6f77cf39ce..099ffd48c9 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort2.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort2.c
@@ -57,11 +57,11 @@
static void
gxv_mort_subtable_type2_opttable_load( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_Bytes p = table;
+ FT_Bytes p = table;
GXV_mort_subtable_type2_StateOptRecData optdata =
- (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
GXV_LIMIT_CHECK( 2 + 2 + 2 );
@@ -86,14 +86,14 @@
FT_UShort *classTable_length_p,
FT_UShort *stateArray_length_p,
FT_UShort *entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UShort o[6];
FT_UShort *l[6];
FT_UShort buff[7];
GXV_mort_subtable_type2_StateOptRecData optdata =
- (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
GXV_NAME_ENTER( "subtable boundaries setup" );
@@ -111,7 +111,7 @@
l[4] = &(optdata->componentTable_length);
l[5] = &(optdata->ligatureTable_length);
- gxv_set_length_by_ushort_offset( o, l, buff, 6, table_size, valid );
+ gxv_set_length_by_ushort_offset( o, l, buff, 6, table_size, gxvalid );
GXV_TRACE(( "classTable: offset=0x%04x length=0x%04x\n",
classTable, *classTable_length_p ));
@@ -137,11 +137,11 @@
gxv_mort_subtable_type2_ligActionOffset_validate(
FT_Bytes table,
FT_UShort ligActionOffset,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/* access ligActionTable */
GXV_mort_subtable_type2_StateOptRecData optdata =
- (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
FT_Bytes lat_base = table + optdata->ligActionTable;
FT_Bytes p = table + ligActionOffset;
@@ -155,8 +155,7 @@
ligActionOffset, lat_base - p ));
/* FontValidator, ftxvalidator, ftxdumperfuser warn but continue */
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_OFFSET;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
}
else if ( lat_limit < p )
{
@@ -164,23 +163,46 @@
ligActionOffset, p - lat_limit ));
/* FontValidator, ftxvalidator, ftxdumperfuser warn but continue */
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_OFFSET;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
}
else
{
/* validate entry in ligActionTable */
FT_ULong lig_action;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort last;
FT_UShort store;
+#endif
FT_ULong offset;
lig_action = FT_NEXT_ULONG( p );
+#ifdef GXV_LOAD_UNUSED_VARS
last = (FT_UShort)( ( lig_action >> 31 ) & 1 );
store = (FT_UShort)( ( lig_action >> 30 ) & 1 );
+#endif
+ /* Apple spec defines this offset as a word offset */
offset = lig_action & 0x3FFFFFFFUL;
+ if ( offset * 2 < optdata->ligatureTable )
+ {
+ GXV_TRACE(( "too short offset 0x%08x:"
+ " 2 x offset < ligatureTable (%d byte rewind)\n",
+ offset, optdata->ligatureTable - offset * 2 ));
+
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
+ } else if ( offset * 2 >
+ optdata->ligatureTable + optdata->ligatureTable_length )
+ {
+ GXV_TRACE(( "too long offset 0x%08x:"
+ " 2 x offset > ligatureTable + ligatureTable_length"
+ " (%d byte overrun)\n",
+ offset,
+ optdata->ligatureTable + optdata->ligatureTable_length
+ - offset * 2 ));
+
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
+ }
}
}
@@ -192,10 +214,12 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort setComponent;
FT_UShort dontAdvance;
+#endif
FT_UShort offset;
FT_UNUSED( state );
@@ -203,23 +227,25 @@
FT_UNUSED( limit );
+#ifdef GXV_LOAD_UNUSED_VARS
setComponent = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
+#endif
offset = (FT_UShort)( flags & 0x3FFFU );
if ( 0 < offset )
gxv_mort_subtable_type2_ligActionOffset_validate( table, offset,
- valid );
+ gxvalid );
}
static void
gxv_mort_subtable_type2_ligatureTable_validate( FT_Bytes table,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_mort_subtable_type2_StateOptRecData optdata =
- (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
FT_Bytes p = table + optdata->ligatureTable;
FT_Bytes limit = table + optdata->ligatureTable
@@ -237,6 +263,9 @@
GXV_LIMIT_CHECK( 2 );
lig_gid = FT_NEXT_USHORT( p );
+
+ if ( gxvalid->face->num_glyphs < lig_gid )
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
}
GXV_EXIT;
@@ -246,7 +275,7 @@
FT_LOCAL_DEF( void )
gxv_mort_subtable_type2_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -257,23 +286,23 @@
GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE );
- valid->statetable.optdata =
+ gxvalid->statetable.optdata =
&lig_rec;
- valid->statetable.optdata_load_func =
+ gxvalid->statetable.optdata_load_func =
gxv_mort_subtable_type2_opttable_load;
- valid->statetable.subtable_setup_func =
+ gxvalid->statetable.subtable_setup_func =
gxv_mort_subtable_type2_subtable_setup;
- valid->statetable.entry_glyphoffset_fmt =
+ gxvalid->statetable.entry_glyphoffset_fmt =
GXV_GLYPHOFFSET_NONE;
- valid->statetable.entry_validate_func =
+ gxvalid->statetable.entry_validate_func =
gxv_mort_subtable_type2_entry_validate;
- gxv_StateTable_validate( p, limit, valid );
+ gxv_StateTable_validate( p, limit, gxvalid );
- p += valid->subtable_length;
- gxv_mort_subtable_type2_ligatureTable_validate( table, valid );
+ p += gxvalid->subtable_length;
+ gxv_mort_subtable_type2_ligatureTable_validate( table, gxvalid );
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort4.c b/src/3rdparty/freetype/src/gxvalid/gxvmort4.c
index 83470988c0..9e86af4dd5 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort4.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort4.c
@@ -41,11 +41,11 @@
static void
gxv_mort_subtable_type4_lookupval_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UNUSED( glyph );
- gxv_glyphid_validate( value_p->u, valid );
+ gxv_glyphid_validate( value_p->u, gxvalid );
}
/*
@@ -80,7 +80,7 @@
FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p;
FT_Bytes limit;
@@ -91,7 +91,7 @@
offset = (FT_UShort)( base_value_p->u +
relative_gindex * sizeof ( FT_UShort ) );
- p = valid->lookuptbl_head + offset;
+ p = gxvalid->lookuptbl_head + offset;
limit = lookuptbl_limit;
GXV_LIMIT_CHECK( 2 );
@@ -104,7 +104,7 @@
FT_LOCAL_DEF( void )
gxv_mort_subtable_type4_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -112,11 +112,11 @@
GXV_NAME_ENTER( "mort chain subtable type4 "
"(Non-Contextual Glyph Substitution)" );
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_mort_subtable_type4_lookupval_validate;
- valid->lookupfmt4_trans = gxv_mort_subtable_type4_lookupfmt4_transit;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_mort_subtable_type4_lookupval_validate;
+ gxvalid->lookupfmt4_trans = gxv_mort_subtable_type4_lookupfmt4_transit;
- gxv_LookupTable_validate( p, limit, valid );
+ gxv_LookupTable_validate( p, limit, gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort5.c b/src/3rdparty/freetype/src/gxvalid/gxvmort5.c
index ec0bcb634d..9498b10855 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort5.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort5.c
@@ -70,10 +70,10 @@
FT_UShort* classTable_length_p,
FT_UShort* stateArray_length_p,
FT_UShort* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_mort_subtable_type5_StateOptRecData optdata =
- (GXV_mort_subtable_type5_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type5_StateOptRecData)gxvalid->statetable.optdata;
gxv_StateTable_subtable_setup( table_size,
@@ -83,7 +83,7 @@
classTable_length_p,
stateArray_length_p,
entryTable_length_p,
- valid );
+ gxvalid );
optdata->classTable = classTable;
optdata->stateArray = stateArray;
@@ -100,7 +100,7 @@
FT_UShort count,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/*
* We don't know the range of insertion-glyph-list.
@@ -109,7 +109,7 @@
FT_Bytes p = table + offset;
GXV_mort_subtable_type5_StateOptRecData optdata =
- (GXV_mort_subtable_type5_StateOptRecData)valid->statetable.optdata;
+ (GXV_mort_subtable_type5_StateOptRecData)gxvalid->statetable.optdata;
if ( optdata->classTable < offset &&
offset < optdata->classTable + *(optdata->classTable_length_p) )
@@ -121,6 +121,9 @@
offset < optdata->entryTable + *(optdata->entryTable_length_p) )
GXV_TRACE(( " offset runs into EntryTable" ));
+#ifndef GXV_LOAD_TRACE_VARS
+ GXV_LIMIT_CHECK( count * 2 );
+#else
while ( p < table + offset + ( count * 2 ) )
{
FT_UShort insert_glyphID;
@@ -130,8 +133,8 @@
insert_glyphID = FT_NEXT_USHORT( p );
GXV_TRACE(( " 0x%04x", insert_glyphID ));
}
-
GXV_TRACE(( "\n" ));
+#endif
}
@@ -142,14 +145,16 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_Bool setMark;
FT_Bool dontAdvance;
FT_Bool currentIsKashidaLike;
FT_Bool markedIsKashidaLike;
FT_Bool currentInsertBefore;
FT_Bool markedInsertBefore;
+#endif
FT_Byte currentInsertCount;
FT_Byte markedInsertCount;
FT_UShort currentInsertList;
@@ -158,12 +163,14 @@
FT_UNUSED( state );
+#ifdef GXV_LOAD_UNUSED_VARS
setMark = FT_BOOL( ( flags >> 15 ) & 1 );
dontAdvance = FT_BOOL( ( flags >> 14 ) & 1 );
currentIsKashidaLike = FT_BOOL( ( flags >> 13 ) & 1 );
markedIsKashidaLike = FT_BOOL( ( flags >> 12 ) & 1 );
currentInsertBefore = FT_BOOL( ( flags >> 11 ) & 1 );
markedInsertBefore = FT_BOOL( ( flags >> 10 ) & 1 );
+#endif
currentInsertCount = (FT_Byte)( ( flags >> 5 ) & 0x1F );
markedInsertCount = (FT_Byte)( flags & 0x001F );
@@ -177,7 +184,7 @@
currentInsertCount,
table,
limit,
- valid );
+ gxvalid );
}
if ( 0 != markedInsertList && 0 != markedInsertCount )
@@ -186,7 +193,7 @@
markedInsertCount,
table,
limit,
- valid );
+ gxvalid );
}
}
@@ -194,7 +201,7 @@
FT_LOCAL_DEF( void )
gxv_mort_subtable_type5_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -206,18 +213,18 @@
GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE );
- valid->statetable.optdata =
+ gxvalid->statetable.optdata =
et;
- valid->statetable.optdata_load_func =
+ gxvalid->statetable.optdata_load_func =
NULL;
- valid->statetable.subtable_setup_func =
+ gxvalid->statetable.subtable_setup_func =
gxv_mort_subtable_type5_subtable_setup;
- valid->statetable.entry_glyphoffset_fmt =
+ gxvalid->statetable.entry_glyphoffset_fmt =
GXV_GLYPHOFFSET_ULONG;
- valid->statetable.entry_validate_func =
+ gxvalid->statetable.entry_validate_func =
gxv_mort_subtable_type5_entry_validate;
- gxv_StateTable_validate( p, limit, valid );
+ gxv_StateTable_validate( p, limit, gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx.c
index f8ba5b985d..96dba631c4 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, 2008 by */
+/* Copyright 2005, 2008, 2013 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -42,7 +42,7 @@
gxv_morx_subtables_validate( FT_Bytes table,
FT_Bytes limit,
FT_UShort nSubtables,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -57,8 +57,6 @@
};
- GXV_Validate_Func func;
-
FT_UShort i;
@@ -66,9 +64,13 @@
for ( i = 0; i < nSubtables; i++ )
{
+ GXV_Validate_Func func;
+
FT_ULong length;
FT_ULong coverage;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_ULong subFeatureFlags;
+#endif
FT_ULong type;
FT_ULong rest;
@@ -76,7 +78,11 @@
GXV_LIMIT_CHECK( 4 + 4 + 4 );
length = FT_NEXT_ULONG( p );
coverage = FT_NEXT_ULONG( p );
+#ifdef GXV_LOAD_UNUSED_VARS
subFeatureFlags = FT_NEXT_ULONG( p );
+#else
+ p += 4;
+#endif
GXV_TRACE(( "validating chain subtable %d/%d (%d bytes)\n",
i + 1, nSubtables, length ));
@@ -87,7 +93,7 @@
/* morx coverage consists of mort_coverage & 16bit padding */
gxv_mort_coverage_validate( (FT_UShort)( ( coverage >> 16 ) | coverage ),
- valid );
+ gxvalid );
if ( type > 5 )
FT_INVALID_FORMAT;
@@ -95,12 +101,13 @@
if ( func == NULL )
GXV_TRACE(( "morx type %d is reserved\n", type ));
- func( p, p + rest, valid );
+ func( p, p + rest, gxvalid );
+ /* TODO: subFeatureFlags should be unique in a table? */
p += rest;
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -109,10 +116,12 @@
static void
gxv_morx_chain_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_ULong defaultFlags;
+#endif
FT_ULong chainLength;
FT_ULong nFeatureFlags;
FT_ULong nSubtables;
@@ -121,22 +130,28 @@
GXV_NAME_ENTER( "morx chain header" );
GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 );
+#ifdef GXV_LOAD_UNUSED_VARS
defaultFlags = FT_NEXT_ULONG( p );
+#else
+ p += 4;
+#endif
chainLength = FT_NEXT_ULONG( p );
nFeatureFlags = FT_NEXT_ULONG( p );
nSubtables = FT_NEXT_ULONG( p );
/* feature-array of morx is same with that of mort */
- gxv_mort_featurearray_validate( p, limit, nFeatureFlags, valid );
- p += valid->subtable_length;
+ gxv_mort_featurearray_validate( p, limit, nFeatureFlags, gxvalid );
+ p += gxvalid->subtable_length;
if ( nSubtables >= 0x10000L )
FT_INVALID_DATA;
gxv_morx_subtables_validate( p, table + chainLength,
- (FT_UShort)nSubtables, valid );
+ (FT_UShort)nSubtables, gxvalid );
+
+ gxvalid->subtable_length = chainLength;
- valid->subtable_length = chainLength;
+ /* TODO: defaultFlags should be compared with the flags in tables */
GXV_EXIT;
}
@@ -147,8 +162,8 @@
FT_Face face,
FT_Validator ftvalid )
{
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
FT_Bytes p = table;
FT_Bytes limit = 0;
FT_ULong version;
@@ -156,8 +171,8 @@
FT_ULong i;
- valid->root = ftvalid;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->face = face;
FT_TRACE3(( "validating `morx' table\n" ));
GXV_INIT;
@@ -173,8 +188,8 @@
{
GXV_TRACE(( "validating chain %d/%d\n", i + 1, nChains ));
GXV_32BIT_ALIGNMENT_VALIDATE( p - table );
- gxv_morx_chain_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_morx_chain_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
}
FT_TRACE4(( "\n" ));
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx.h b/src/3rdparty/freetype/src/gxvalid/gxvmorx.h
index 28c1a44f6f..9ed907acd7 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx.h
@@ -38,27 +38,27 @@
FT_LOCAL( void )
gxv_morx_subtable_type0_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_morx_subtable_type1_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_morx_subtable_type2_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_morx_subtable_type4_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
FT_LOCAL( void )
gxv_morx_subtable_type5_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid );
+ GXV_Validator gxvalid );
#endif /* __GXVMORX_H__ */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c
index 0159c5aef7..db165f4e89 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c
@@ -45,13 +45,17 @@
GXV_XStateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort markFirst;
FT_UShort dontAdvance;
FT_UShort markLast;
+#endif
FT_UShort reserved;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort verb;
+#endif
FT_UNUSED( state );
FT_UNUSED( glyphOffset_p );
@@ -59,12 +63,16 @@
FT_UNUSED( limit );
+#ifdef GXV_LOAD_UNUSED_VARS
markFirst = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
markLast = (FT_UShort)( ( flags >> 13 ) & 1 );
+#endif
reserved = (FT_UShort)( flags & 0x1FF0 );
+#ifdef GXV_LOAD_UNUSED_VARS
verb = (FT_UShort)( flags & 0x000F );
+#endif
if ( 0 < reserved )
{
@@ -77,7 +85,7 @@
FT_LOCAL_DEF( void )
gxv_morx_subtable_type0_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -87,14 +95,14 @@
GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE );
- valid->xstatetable.optdata = NULL;
- valid->xstatetable.optdata_load_func = NULL;
- valid->xstatetable.subtable_setup_func = NULL;
- valid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
- valid->xstatetable.entry_validate_func =
+ gxvalid->xstatetable.optdata = NULL;
+ gxvalid->xstatetable.optdata_load_func = NULL;
+ gxvalid->xstatetable.subtable_setup_func = NULL;
+ gxvalid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
+ gxvalid->xstatetable.entry_validate_func =
gxv_morx_subtable_type0_entry_validate;
- gxv_XStateTable_validate( p, limit, valid );
+ gxv_XStateTable_validate( p, limit, gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c
index e1c162fa0c..49f53d1854 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c
@@ -55,12 +55,12 @@
static void
gxv_morx_subtable_type1_substitutionTable_load( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_morx_subtable_type1_StateOptRecData optdata =
- (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
GXV_LIMIT_CHECK( 2 );
@@ -76,14 +76,14 @@
FT_ULong* classTable_length_p,
FT_ULong* stateArray_length_p,
FT_ULong* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_ULong o[4];
FT_ULong *l[4];
FT_ULong buff[5];
GXV_morx_subtable_type1_StateOptRecData optdata =
- (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
o[0] = classTable;
@@ -95,7 +95,7 @@
l[2] = entryTable_length_p;
l[3] = &(optdata->substitutionTable_length);
- gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, valid );
+ gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, gxvalid );
}
@@ -106,24 +106,28 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_TRACE_VARS
FT_UShort setMark;
FT_UShort dontAdvance;
+#endif
FT_UShort reserved;
FT_Short markIndex;
FT_Short currentIndex;
GXV_morx_subtable_type1_StateOptRecData optdata =
- (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
FT_UNUSED( state );
FT_UNUSED( table );
FT_UNUSED( limit );
+#ifdef GXV_LOAD_TRACE_VARS
setMark = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
+#endif
reserved = (FT_UShort)( flags & 0x3FFF );
@@ -136,8 +140,7 @@
if ( 0 < reserved )
{
GXV_TRACE(( " non-zero bits found in reserved range\n" ));
- if ( valid->root->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
}
GXV_TRACE(( "markIndex = %d, currentIndex = %d\n",
@@ -156,13 +159,13 @@
static void
gxv_morx_subtable_type1_LookupValue_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_UNUSED( glyph ); /* for the non-debugging case */
GXV_TRACE(( "morx subtable type1 subst.: %d -> %d\n", glyph, value_p->u ));
- if ( value_p->u > valid->face->num_glyphs )
+ if ( value_p->u > gxvalid->face->num_glyphs )
FT_INVALID_GLYPH_ID;
}
@@ -172,7 +175,7 @@
FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p;
FT_Bytes limit;
@@ -183,7 +186,7 @@
offset = (FT_UShort)( base_value_p->u +
relative_gindex * sizeof ( FT_UShort ) );
- p = valid->lookuptbl_head + offset;
+ p = gxvalid->lookuptbl_head + offset;
limit = lookuptbl_limit;
GXV_LIMIT_CHECK ( 2 );
@@ -199,19 +202,19 @@
static void
gxv_morx_subtable_type1_substitutionTable_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort i;
GXV_morx_subtable_type1_StateOptRecData optdata =
- (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
/* TODO: calculate offset/length for each lookupTables */
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_morx_subtable_type1_LookupValue_validate;
- valid->lookupfmt4_trans = gxv_morx_subtable_type1_LookupFmt4_transit;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_morx_subtable_type1_LookupValue_validate;
+ gxvalid->lookupfmt4_trans = gxv_morx_subtable_type1_LookupFmt4_transit;
for ( i = 0; i < optdata->substitutionTable_num_lookupTables; i++ )
{
@@ -221,7 +224,7 @@
GXV_LIMIT_CHECK( 4 );
offset = FT_NEXT_ULONG( p );
- gxv_LookupTable_validate( table + offset, limit, valid );
+ gxv_LookupTable_validate( table + offset, limit, gxvalid );
}
/* TODO: overlapping of lookupTables in substitutionTable */
@@ -236,7 +239,7 @@
FT_LOCAL_DEF( void )
gxv_morx_subtable_type1_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -249,23 +252,23 @@
st_rec.substitutionTable_num_lookupTables = 0;
- valid->xstatetable.optdata =
+ gxvalid->xstatetable.optdata =
&st_rec;
- valid->xstatetable.optdata_load_func =
+ gxvalid->xstatetable.optdata_load_func =
gxv_morx_subtable_type1_substitutionTable_load;
- valid->xstatetable.subtable_setup_func =
+ gxvalid->xstatetable.subtable_setup_func =
gxv_morx_subtable_type1_subtable_setup;
- valid->xstatetable.entry_glyphoffset_fmt =
+ gxvalid->xstatetable.entry_glyphoffset_fmt =
GXV_GLYPHOFFSET_ULONG;
- valid->xstatetable.entry_validate_func =
+ gxvalid->xstatetable.entry_validate_func =
gxv_morx_subtable_type1_entry_validate;
- gxv_XStateTable_validate( p, limit, valid );
+ gxv_XStateTable_validate( p, limit, gxvalid );
gxv_morx_subtable_type1_substitutionTable_validate(
table + st_rec.substitutionTable,
table + st_rec.substitutionTable + st_rec.substitutionTable_length,
- valid );
+ gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c
index b4bb3353f6..e44445d141 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 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
+/* Copyright 2005, 2013 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -58,12 +58,12 @@
static void
gxv_morx_subtable_type2_opttable_load( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_morx_subtable_type2_StateOptRecData optdata =
- (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
GXV_LIMIT_CHECK( 4 + 4 + 4 );
@@ -88,14 +88,14 @@
FT_ULong* classTable_length_p,
FT_ULong* stateArray_length_p,
FT_ULong* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_ULong o[6];
FT_ULong* l[6];
FT_ULong buff[7];
GXV_morx_subtable_type2_StateOptRecData optdata =
- (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
GXV_NAME_ENTER( "subtable boundaries setup" );
@@ -113,7 +113,7 @@
l[4] = &(optdata->componentTable_length);
l[5] = &(optdata->ligatureTable_length);
- gxv_set_length_by_ulong_offset( o, l, buff, 6, table_size, valid );
+ gxv_set_length_by_ulong_offset( o, l, buff, 6, table_size, gxvalid );
GXV_TRACE(( "classTable: offset=0x%08x length=0x%08x\n",
classTable, *classTable_length_p ));
@@ -142,11 +142,11 @@
gxv_morx_subtable_type2_ligActionIndex_validate(
FT_Bytes table,
FT_UShort ligActionIndex,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/* access ligActionTable */
GXV_morx_subtable_type2_StateOptRecData optdata =
- (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
FT_Bytes lat_base = table + optdata->ligActionTable;
FT_Bytes p = lat_base +
@@ -168,16 +168,52 @@
{
/* validate entry in ligActionTable */
FT_ULong lig_action;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort last;
FT_UShort store;
+#endif
FT_ULong offset;
+ FT_Long gid_limit;
lig_action = FT_NEXT_ULONG( p );
+#ifdef GXV_LOAD_UNUSED_VARS
last = (FT_UShort)( ( lig_action >> 31 ) & 1 );
store = (FT_UShort)( ( lig_action >> 30 ) & 1 );
+#endif
offset = lig_action & 0x3FFFFFFFUL;
+
+ /* this offset is 30-bit signed value to add to GID */
+ /* it is different from the location offset in mort */
+ if ( ( offset & 0x3FFF0000UL ) == 0x3FFF0000UL )
+ { /* negative offset */
+ gid_limit = gxvalid->face->num_glyphs - ( offset & 0x0000FFFFUL );
+ if ( gid_limit > 0 )
+ return;
+
+ GXV_TRACE(( "ligature action table includes"
+ " too negative offset moving all GID"
+ " below defined range: 0x%04x\n",
+ offset & 0xFFFFU ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
+ }
+ else if ( ( offset & 0x3FFF0000UL ) == 0x00000000UL )
+ { /* positive offset */
+ if ( (FT_Long)offset < gxvalid->face->num_glyphs )
+ return;
+
+ GXV_TRACE(( "ligature action table includes"
+ " too large offset moving all GID"
+ " over defined range: 0x%04x\n",
+ offset & 0xFFFFU ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
+ }
+
+ GXV_TRACE(( "ligature action table includes"
+ " invalid offset to add to 16-bit GID:"
+ " 0x%08x\n", offset ));
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
}
}
@@ -189,11 +225,13 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort setComponent;
FT_UShort dontAdvance;
FT_UShort performAction;
+#endif
FT_UShort reserved;
FT_UShort ligActionIndex;
@@ -201,9 +239,11 @@
FT_UNUSED( limit );
+#ifdef GXV_LOAD_UNUSED_VARS
setComponent = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
performAction = (FT_UShort)( ( flags >> 13 ) & 1 );
+#endif
reserved = (FT_UShort)( flags & 0x1FFF );
ligActionIndex = glyphOffset_p->u;
@@ -213,16 +253,16 @@
if ( 0 < ligActionIndex )
gxv_morx_subtable_type2_ligActionIndex_validate(
- table, ligActionIndex, valid );
+ table, ligActionIndex, gxvalid );
}
static void
gxv_morx_subtable_type2_ligatureTable_validate( FT_Bytes table,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_morx_subtable_type2_StateOptRecData optdata =
- (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
FT_Bytes p = table + optdata->ligatureTable;
FT_Bytes limit = table + optdata->ligatureTable
@@ -241,6 +281,8 @@
GXV_LIMIT_CHECK( 2 );
lig_gid = FT_NEXT_USHORT( p );
+ if ( lig_gid < gxvalid->face->num_glyphs )
+ GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
}
}
@@ -251,7 +293,7 @@
FT_LOCAL_DEF( void )
gxv_morx_subtable_type2_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -262,21 +304,23 @@
GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE2_HEADER_SIZE );
- valid->xstatetable.optdata =
+ gxvalid->xstatetable.optdata =
&lig_rec;
- valid->xstatetable.optdata_load_func =
+ gxvalid->xstatetable.optdata_load_func =
gxv_morx_subtable_type2_opttable_load;
- valid->xstatetable.subtable_setup_func =
+ gxvalid->xstatetable.subtable_setup_func =
gxv_morx_subtable_type2_subtable_setup;
- valid->xstatetable.entry_glyphoffset_fmt =
+ gxvalid->xstatetable.entry_glyphoffset_fmt =
GXV_GLYPHOFFSET_USHORT;
- valid->xstatetable.entry_validate_func =
+ gxvalid->xstatetable.entry_validate_func =
gxv_morx_subtable_type2_entry_validate;
- gxv_XStateTable_validate( p, limit, valid );
+ gxv_XStateTable_validate( p, limit, gxvalid );
- p += valid->subtable_length;
- gxv_morx_subtable_type2_ligatureTable_validate( table, valid );
+#if 0
+ p += gxvalid->subtable_length;
+#endif
+ gxv_morx_subtable_type2_ligatureTable_validate( table, gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c
index c0d2f78e39..68ab678492 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c
@@ -41,12 +41,12 @@
FT_LOCAL_DEF( void )
gxv_morx_subtable_type4_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_NAME_ENTER( "morx chain subtable type4 "
"(Non-Contextual Glyph Substitution)" );
- gxv_mort_subtable_type4_validate( table, limit, valid );
+ gxv_mort_subtable_type4_validate( table, limit, gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c
index 5e3a16437e..5e095dd380 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c
@@ -64,12 +64,12 @@
static void
gxv_morx_subtable_type5_insertionGlyphList_load( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
GXV_morx_subtable_type5_StateOptRecData optdata =
- (GXV_morx_subtable_type5_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type5_StateOptRecData)gxvalid->xstatetable.optdata;
GXV_LIMIT_CHECK( 4 );
@@ -85,14 +85,14 @@
FT_ULong* classTable_length_p,
FT_ULong* stateArray_length_p,
FT_ULong* entryTable_length_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_ULong o[4];
FT_ULong* l[4];
FT_ULong buff[5];
GXV_morx_subtable_type5_StateOptRecData optdata =
- (GXV_morx_subtable_type5_StateOptRecData)valid->xstatetable.optdata;
+ (GXV_morx_subtable_type5_StateOptRecData)gxvalid->xstatetable.optdata;
o[0] = classTable;
@@ -104,7 +104,7 @@
l[2] = entryTable_length_p;
l[3] = &(optdata->insertionGlyphList_length);
- gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, valid );
+ gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, gxvalid );
}
@@ -113,11 +113,14 @@
FT_UShort count,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_Bytes p = table + table_index * 2;
+ FT_Bytes p = table + table_index * 2;
+#ifndef GXV_LOAD_TRACE_VARS
+ GXV_LIMIT_CHECK( count * 2 );
+#else
while ( p < table + count * 2 + table_index * 2 )
{
FT_UShort insert_glyphID;
@@ -129,6 +132,7 @@
}
GXV_TRACE(( "\n" ));
+#endif
}
@@ -139,14 +143,16 @@
GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_Bool setMark;
FT_Bool dontAdvance;
FT_Bool currentIsKashidaLike;
FT_Bool markedIsKashidaLike;
FT_Bool currentInsertBefore;
FT_Bool markedInsertBefore;
+#endif
FT_Byte currentInsertCount;
FT_Byte markedInsertCount;
FT_Byte currentInsertList;
@@ -155,12 +161,14 @@
FT_UNUSED( state );
+#ifdef GXV_LOAD_UNUSED_VARS
setMark = FT_BOOL( ( flags >> 15 ) & 1 );
dontAdvance = FT_BOOL( ( flags >> 14 ) & 1 );
currentIsKashidaLike = FT_BOOL( ( flags >> 13 ) & 1 );
markedIsKashidaLike = FT_BOOL( ( flags >> 12 ) & 1 );
currentInsertBefore = FT_BOOL( ( flags >> 11 ) & 1 );
markedInsertBefore = FT_BOOL( ( flags >> 10 ) & 1 );
+#endif
currentInsertCount = (FT_Byte)( ( flags >> 5 ) & 0x1F );
markedInsertCount = (FT_Byte)( flags & 0x001F );
@@ -172,20 +180,20 @@
gxv_morx_subtable_type5_InsertList_validate( currentInsertList,
currentInsertCount,
table, limit,
- valid );
+ gxvalid );
if ( markedInsertList && 0 != markedInsertCount )
gxv_morx_subtable_type5_InsertList_validate( markedInsertList,
markedInsertCount,
table, limit,
- valid );
+ gxvalid );
}
FT_LOCAL_DEF( void )
gxv_morx_subtable_type5_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
@@ -197,18 +205,18 @@
GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE );
- valid->xstatetable.optdata =
+ gxvalid->xstatetable.optdata =
et;
- valid->xstatetable.optdata_load_func =
+ gxvalid->xstatetable.optdata_load_func =
gxv_morx_subtable_type5_insertionGlyphList_load;
- valid->xstatetable.subtable_setup_func =
+ gxvalid->xstatetable.subtable_setup_func =
gxv_morx_subtable_type5_subtable_setup;
- valid->xstatetable.entry_glyphoffset_fmt =
+ gxvalid->xstatetable.entry_glyphoffset_fmt =
GXV_GLYPHOFFSET_ULONG;
- valid->xstatetable.entry_validate_func =
+ gxvalid->xstatetable.entry_validate_func =
gxv_morx_subtable_type5_entry_validate;
- gxv_XStateTable_validate( p, limit, valid );
+ gxv_XStateTable_validate( p, limit, gxvalid );
GXV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvopbd.c b/src/3rdparty/freetype/src/gxvalid/gxvopbd.c
index e125060946..ab0cd72bf2 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvopbd.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvopbd.c
@@ -68,11 +68,11 @@
static void
gxv_opbd_LookupValue_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
/* offset in LookupTable is measured from the head of opbd table */
- FT_Bytes p = valid->root->base + value_p->u;
- FT_Bytes limit = valid->root->limit;
+ FT_Bytes p = gxvalid->root->base + value_p->u;
+ FT_Bytes limit = gxvalid->root->limit;
FT_Short delta_value;
int i;
@@ -90,7 +90,7 @@
if ( delta_value == -1 )
continue;
- gxv_ctlPoint_validate( glyph, delta_value, valid );
+ gxv_ctlPoint_validate( glyph, delta_value, gxvalid );
}
else /* format 0, value is distance */
continue;
@@ -134,12 +134,12 @@
gxv_opbd_LookupFmt4_transit( FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
GXV_LookupValueDesc value;
FT_UNUSED( lookuptbl_limit );
- FT_UNUSED( valid );
+ FT_UNUSED( gxvalid );
/* XXX: check range? */
value.u = (FT_UShort)( base_value_p->u +
@@ -162,8 +162,8 @@
FT_Face face,
FT_Validator ftvalid )
{
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_opbd_DataRec opbdrec;
GXV_opbd_Data opbd = &opbdrec;
FT_Bytes p = table;
@@ -172,9 +172,9 @@
FT_ULong version;
- valid->root = ftvalid;
- valid->table_data = opbd;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = opbd;
+ gxvalid->face = face;
FT_TRACE3(( "validating `opbd' table\n" ));
GXV_INIT;
@@ -196,12 +196,12 @@
if ( 0x0001 < GXV_OPBD_DATA( format ) )
FT_INVALID_FORMAT;
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_opbd_LookupValue_validate;
- valid->lookupfmt4_trans = gxv_opbd_LookupFmt4_transit;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_opbd_LookupValue_validate;
+ gxvalid->lookupfmt4_trans = gxv_opbd_LookupFmt4_transit;
- gxv_LookupTable_validate( p, limit, valid );
- p += valid->subtable_length;
+ gxv_LookupTable_validate( p, limit, gxvalid );
+ p += gxvalid->subtable_length;
if ( p > table + GXV_OPBD_DATA( valueOffset_min ) )
{
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvprop.c b/src/3rdparty/freetype/src/gxvalid/gxvprop.c
index 66c3ab7404..aa5c8eed31 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvprop.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvprop.c
@@ -75,7 +75,7 @@
static void
gxv_prop_zero_advance_validate( FT_UShort gid,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Face face;
FT_Error error;
@@ -84,7 +84,7 @@
GXV_NAME_ENTER( "zero advance" );
- face = valid->face;
+ face = gxvalid->face;
error = FT_Load_Glyph( face,
gid,
@@ -96,7 +96,10 @@
if ( glyph->advance.x != (FT_Pos)0 ||
glyph->advance.y != (FT_Pos)0 )
+ {
+ GXV_TRACE(( " found non-zero advance in zero-advance glyph\n" ));
FT_INVALID_DATA;
+ }
GXV_EXIT;
}
@@ -106,10 +109,10 @@
static void
gxv_prop_property_validate( FT_UShort property,
FT_UShort glyph,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
if ( glyph != 0 && ( property & GXV_PROP_FLOATER ) )
- gxv_prop_zero_advance_validate( glyph, valid );
+ gxv_prop_zero_advance_validate( glyph, gxvalid );
if ( property & GXV_PROP_USE_COMPLEMENTARY_BRACKET )
{
@@ -119,7 +122,10 @@
offset = (FT_UShort)( property & GXV_PROP_COMPLEMENTARY_BRACKET_OFFSET );
if ( offset == 0 )
- FT_INVALID_DATA;
+ {
+ GXV_TRACE(( " found zero offset to property\n" ));
+ FT_INVALID_OFFSET;
+ }
complement = (char)( offset >> 8 );
if ( complement & 0x08 )
@@ -131,12 +137,15 @@
/* The gid for complement must be greater than 0 */
if ( glyph <= complement )
+ {
+ GXV_TRACE(( " found non-positive glyph complement\n" ));
FT_INVALID_DATA;
+ }
}
else
{
/* The gid for complement must be the face. */
- gxv_glyphid_validate( (FT_UShort)( glyph + complement ), valid );
+ gxv_glyphid_validate( (FT_UShort)( glyph + complement ), gxvalid );
}
}
else
@@ -150,18 +159,27 @@
if ( property & GXV_PROP_ATTACHING_TO_RIGHT )
{
if ( GXV_PROP_DATA( version ) == 0x00010000UL )
+ {
+ GXV_TRACE(( " found older version (1.0) in new version table\n" ));
FT_INVALID_DATA;
+ }
}
if ( property & GXV_PROP_RESERVED )
+ {
+ GXV_TRACE(( " found non-zero bits in reserved bits\n" ));
FT_INVALID_DATA;
+ }
if ( ( property & GXV_PROP_DIRECTIONALITY_CLASS ) > 11 )
{
/* TODO: Too restricted. Use the validation level. */
if ( GXV_PROP_DATA( version ) == 0x00010000UL ||
GXV_PROP_DATA( version ) == 0x00020000UL )
+ {
+ GXV_TRACE(( " found too old version in directionality class\n" ));
FT_INVALID_DATA;
+ }
}
}
@@ -169,9 +187,9 @@
static void
gxv_prop_LookupValue_validate( FT_UShort glyph,
GXV_LookupValueCPtr value_p,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- gxv_prop_property_validate( value_p->u, glyph, valid );
+ gxv_prop_property_validate( value_p->u, glyph, gxvalid );
}
@@ -206,7 +224,7 @@
gxv_prop_LookupFmt4_transit( FT_UShort relative_gindex,
GXV_LookupValueCPtr base_value_p,
FT_Bytes lookuptbl_limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p;
FT_Bytes limit;
@@ -215,8 +233,8 @@
/* XXX: check range? */
offset = (FT_UShort)( base_value_p->u +
- relative_gindex * sizeof( FT_UShort ) );
- p = valid->lookuptbl_head + offset;
+ relative_gindex * sizeof ( FT_UShort ) );
+ p = gxvalid->lookuptbl_head + offset;
limit = lookuptbl_limit;
GXV_LIMIT_CHECK ( 2 );
@@ -241,8 +259,8 @@
{
FT_Bytes p = table;
FT_Bytes limit = 0;
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_prop_DataRec proprec;
GXV_prop_Data prop = &proprec;
@@ -252,9 +270,9 @@
FT_UShort defaultProp;
- valid->root = ftvalid;
- valid->table_data = prop;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = prop;
+ gxvalid->face = face;
FT_TRACE3(( "validating `prop' table\n" ));
GXV_INIT;
@@ -264,18 +282,28 @@
format = FT_NEXT_USHORT( p );
defaultProp = FT_NEXT_USHORT( p );
+ GXV_TRACE(( " version 0x%08x\n", version ));
+ GXV_TRACE(( " format 0x%04x\n", format ));
+ GXV_TRACE(( " defaultProp 0x%04x\n", defaultProp ));
+
/* only versions 1.0, 2.0, 3.0 are defined (1996) */
if ( version != 0x00010000UL &&
version != 0x00020000UL &&
version != 0x00030000UL )
+ {
+ GXV_TRACE(( " found unknown version\n" ));
FT_INVALID_FORMAT;
+ }
/* only formats 0x0000, 0x0001 are defined (1996) */
if ( format > 1 )
+ {
+ GXV_TRACE(( " found unknown format\n" ));
FT_INVALID_FORMAT;
+ }
- gxv_prop_property_validate( defaultProp, 0, valid );
+ gxv_prop_property_validate( defaultProp, 0, gxvalid );
if ( format == 0 )
{
@@ -287,11 +315,11 @@
/* format == 1 */
GXV_PROP_DATA( version ) = version;
- valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
- valid->lookupval_func = gxv_prop_LookupValue_validate;
- valid->lookupfmt4_trans = gxv_prop_LookupFmt4_transit;
+ gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+ gxvalid->lookupval_func = gxv_prop_LookupValue_validate;
+ gxvalid->lookupfmt4_trans = gxv_prop_LookupFmt4_transit;
- gxv_LookupTable_validate( p, limit, valid );
+ gxv_LookupTable_validate( p, limit, gxvalid );
Exit:
FT_TRACE4(( "\n" ));
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvtrak.c b/src/3rdparty/freetype/src/gxvalid/gxvtrak.c
index df3fd15c0b..3ec1a56739 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvtrak.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvtrak.c
@@ -93,14 +93,14 @@
gxv_trak_trackTable_validate( FT_Bytes table,
FT_Bytes limit,
FT_UShort nTracks,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
- FT_Bytes p = table;
+ FT_Bytes p = table;
- FT_Fixed track;
+ FT_Fixed track, t;
FT_UShort nameIndex;
FT_UShort offset;
- FT_UShort i;
+ FT_UShort i, j;
GXV_NAME_ENTER( "trackTable" );
@@ -108,9 +108,11 @@
GXV_TRAK_DATA( trackValueOffset_min ) = 0xFFFFU;
GXV_TRAK_DATA( trackValueOffset_max ) = 0x0000;
+ GXV_LIMIT_CHECK( nTracks * ( 4 + 2 + 2 ) );
+
for ( i = 0; i < nTracks; i ++ )
{
- GXV_LIMIT_CHECK( 4 + 2 + 2 );
+ p = table + i * ( 4 + 2 + 2 );
track = FT_NEXT_LONG( p );
nameIndex = FT_NEXT_USHORT( p );
offset = FT_NEXT_USHORT( p );
@@ -120,10 +122,19 @@
if ( offset > GXV_TRAK_DATA( trackValueOffset_max ) )
GXV_TRAK_DATA( trackValueOffset_max ) = offset;
- gxv_sfntName_validate( nameIndex, 256, 32767, valid );
+ gxv_sfntName_validate( nameIndex, 256, 32767, gxvalid );
+
+ for ( j = i; j < nTracks; j ++ )
+ {
+ p = table + j * ( 4 + 2 + 2 );
+ t = FT_NEXT_LONG( p );
+ if ( t == track )
+ GXV_TRACE(( "duplicated entries found for track value 0x%x\n",
+ track ));
+ }
}
- valid->subtable_length = p - table;
+ gxvalid->subtable_length = p - table;
GXV_EXIT;
}
@@ -131,7 +142,7 @@
static void
gxv_trak_trackData_validate( FT_Bytes table,
FT_Bytes limit,
- GXV_Validator valid )
+ GXV_Validator gxvalid )
{
FT_Bytes p = table;
FT_UShort nTracks;
@@ -153,31 +164,31 @@
gxv_odtect_add_range( table, p - table, "trackData header", odtect );
/* validate trackTable */
- gxv_trak_trackTable_validate( p, limit, nTracks, valid );
- gxv_odtect_add_range( p, valid->subtable_length,
+ gxv_trak_trackTable_validate( p, limit, nTracks, gxvalid );
+ gxv_odtect_add_range( p, gxvalid->subtable_length,
"trackTable", odtect );
/* sizeTable is array of FT_Fixed, don't check contents */
- p = valid->root->base + sizeTableOffset;
+ p = gxvalid->root->base + sizeTableOffset;
GXV_LIMIT_CHECK( nSizes * 4 );
gxv_odtect_add_range( p, nSizes * 4, "sizeTable", odtect );
/* validate trackValueOffet */
- p = valid->root->base + GXV_TRAK_DATA( trackValueOffset_min );
+ p = gxvalid->root->base + GXV_TRAK_DATA( trackValueOffset_min );
if ( limit - p < nTracks * nSizes * 2 )
GXV_TRACE(( "too short trackValue array\n" ));
- p = valid->root->base + GXV_TRAK_DATA( trackValueOffset_max );
+ p = gxvalid->root->base + GXV_TRAK_DATA( trackValueOffset_max );
GXV_LIMIT_CHECK( nSizes * 2 );
- gxv_odtect_add_range( valid->root->base
+ gxv_odtect_add_range( gxvalid->root->base
+ GXV_TRAK_DATA( trackValueOffset_min ),
GXV_TRAK_DATA( trackValueOffset_max )
- GXV_TRAK_DATA( trackValueOffset_min )
+ nSizes * 2,
"trackValue array", odtect );
- gxv_odtect_validate( odtect, valid );
+ gxv_odtect_validate( odtect, gxvalid );
GXV_EXIT;
}
@@ -198,10 +209,9 @@
{
FT_Bytes p = table;
FT_Bytes limit = 0;
- FT_Offset table_size;
- GXV_ValidatorRec validrec;
- GXV_Validator valid = &validrec;
+ GXV_ValidatorRec gxvalidrec;
+ GXV_Validator gxvalid = &gxvalidrec;
GXV_trak_DataRec trakrec;
GXV_trak_Data trak = &trakrec;
@@ -215,12 +225,11 @@
GXV_ODTECT( 3, odtect );
GXV_ODTECT_INIT( odtect );
- valid->root = ftvalid;
- valid->table_data = trak;
- valid->face = face;
+ gxvalid->root = ftvalid;
+ gxvalid->table_data = trak;
+ gxvalid->face = face;
- limit = valid->root->limit;
- table_size = limit - table;
+ limit = gxvalid->root->limit;
FT_TRACE3(( "validating `trak' table\n" ));
GXV_INIT;
@@ -256,19 +265,19 @@
/* validate trackData */
if ( 0 < horizOffset )
{
- gxv_trak_trackData_validate( table + horizOffset, limit, valid );
- gxv_odtect_add_range( table + horizOffset, valid->subtable_length,
+ gxv_trak_trackData_validate( table + horizOffset, limit, gxvalid );
+ gxv_odtect_add_range( table + horizOffset, gxvalid->subtable_length,
"horizJustData", odtect );
}
if ( 0 < vertOffset )
{
- gxv_trak_trackData_validate( table + vertOffset, limit, valid );
- gxv_odtect_add_range( table + vertOffset, valid->subtable_length,
+ gxv_trak_trackData_validate( table + vertOffset, limit, gxvalid );
+ gxv_odtect_add_range( table + vertOffset, gxvalid->subtable_length,
"vertJustData", odtect );
}
- gxv_odtect_validate( odtect, valid );
+ gxv_odtect_validate( odtect, gxvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/gzip/ftgzip.c b/src/3rdparty/freetype/src/gzip/ftgzip.c
index 6f0c515723..2d4200d9fa 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, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2002-2006, 2009-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -32,6 +32,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Gzip_Err_
#define FT_ERR_BASE FT_Mod_Err_Gzip
@@ -42,7 +43,7 @@
#ifdef FT_CONFIG_OPTION_PIC
#error "gzip code does not support PIC yet"
-#endif
+#endif
#ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB
@@ -67,6 +68,15 @@
#undef SLOW
#define SLOW 1 /* we can't use asm-optimized sources here! */
+#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
+ /* We disable the warning `conversion from XXX to YYY, */
+ /* possible loss of data' in order to compile cleanly with */
+ /* the maximum level of warnings: zlib is non-FreeType */
+ /* code. */
+#pragma warning( push )
+#pragma warning( disable : 4244 )
+#endif /* _MSC_VER */
+
/* Urgh. `inflate_mask' must not be declared twice -- C++ doesn't like
this. We temporarily disable it and load all necessary header files. */
#define NO_INFLATE_MASK
@@ -86,6 +96,10 @@
#include "inflate.c"
#include "adler32.c"
+#if defined( _MSC_VER )
+#pragma warning( pop )
+#endif
+
#endif /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */
@@ -107,7 +121,7 @@
{
FT_ULong sz = (FT_ULong)size * items;
FT_Error error;
- FT_Pointer p;
+ FT_Pointer p = NULL;
(void)FT_ALLOC( p, sz );
@@ -194,12 +208,12 @@
/* head[0] && head[1] are the magic numbers; */
/* head[2] is the method, and head[3] the flags */
- if ( head[0] != 0x1f ||
- head[1] != 0x8b ||
+ if ( head[0] != 0x1F ||
+ head[1] != 0x8B ||
head[2] != Z_DEFLATED ||
(head[3] & FT_GZIP_RESERVED) )
{
- error = Gzip_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -261,7 +275,7 @@
FT_Stream source )
{
z_stream* zstream = &zip->zstream;
- FT_Error error = Gzip_Err_Ok;
+ FT_Error error = FT_Err_Ok;
zip->stream = stream;
@@ -293,7 +307,7 @@
if ( inflateInit2( zstream, -MAX_WBITS ) != Z_OK ||
zstream->next_in == NULL )
- error = Gzip_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
Exit:
return error;
@@ -364,7 +378,7 @@
size = stream->read( stream, stream->pos, zip->input,
FT_GZIP_BUFFER_SIZE );
if ( size == 0 )
- return Gzip_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
}
else
{
@@ -373,7 +387,7 @@
size = FT_GZIP_BUFFER_SIZE;
if ( size == 0 )
- return Gzip_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
FT_MEM_COPY( zip->input, stream->base + stream->pos, size );
}
@@ -382,7 +396,7 @@
zstream->next_in = zip->input;
zstream->avail_in = size;
- return Gzip_Err_Ok;
+ return FT_Err_Ok;
}
@@ -390,7 +404,7 @@
ft_gzip_file_fill_output( FT_GZipFile zip )
{
z_stream* zstream = &zip->zstream;
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
zip->cursor = zip->buffer;
@@ -415,12 +429,12 @@
{
zip->limit = zstream->next_out;
if ( zip->limit == zip->cursor )
- error = Gzip_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
break;
}
else if ( err != Z_OK )
{
- error = Gzip_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
break;
}
}
@@ -434,7 +448,7 @@
ft_gzip_file_skip_output( FT_GZipFile zip,
FT_ULong count )
{
- FT_Error error = Gzip_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ULong delta;
@@ -571,7 +585,7 @@
old_pos = stream->pos;
if ( !FT_Stream_Seek( stream, stream->size - 4 ) )
{
- result = (FT_ULong)FT_Stream_ReadLong( stream, &error );
+ result = FT_Stream_ReadULong( stream, &error );
if ( error )
result = 0;
@@ -582,15 +596,25 @@
}
+ /* documentation is in ftgzip.h */
+
FT_EXPORT_DEF( FT_Error )
FT_Stream_OpenGzip( FT_Stream stream,
FT_Stream source )
{
FT_Error error;
- FT_Memory memory = source->memory;
- FT_GZipFile zip;
+ FT_Memory memory;
+ FT_GZipFile zip = NULL;
+ if ( !stream || !source )
+ {
+ error = FT_THROW( Invalid_Stream_Handle );
+ goto Exit;
+ }
+
+ memory = source->memory;
+
/*
* check the header right now; this prevents allocating un-necessary
* objects when we don't need them
@@ -628,7 +652,7 @@
if ( zip_size != 0 && zip_size < 40 * 1024 )
{
- FT_Byte* zip_buff;
+ FT_Byte* zip_buff = NULL;
if ( !FT_ALLOC( zip_buff, zip_size ) )
@@ -656,7 +680,7 @@
ft_gzip_file_io( zip, 0, NULL, 0 );
FT_FREE( zip_buff );
}
- error = 0;
+ error = FT_Err_Ok;
}
}
@@ -670,7 +694,69 @@
return error;
}
-#else /* !FT_CONFIG_OPTION_USE_ZLIB */
+
+ /* documentation is in ftgzip.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Gzip_Uncompress( FT_Memory memory,
+ FT_Byte* output,
+ FT_ULong* output_len,
+ const FT_Byte* input,
+ FT_ULong input_len )
+ {
+ z_stream stream;
+ int err;
+
+
+ /* check for `input' delayed to `inflate' */
+
+ if ( !memory || ! output_len || !output )
+ return FT_THROW( Invalid_Argument );
+
+ /* this function is modeled after zlib's `uncompress' function */
+
+ stream.next_in = (Bytef*)input;
+ stream.avail_in = (uInt)input_len;
+
+ stream.next_out = output;
+ stream.avail_out = (uInt)*output_len;
+
+ stream.zalloc = (alloc_func)ft_gzip_alloc;
+ stream.zfree = (free_func) ft_gzip_free;
+ stream.opaque = memory;
+
+ err = inflateInit2( &stream, MAX_WBITS );
+ if ( err != Z_OK )
+ return FT_THROW( Invalid_Argument );
+
+ err = inflate( &stream, Z_FINISH );
+ if ( err != Z_STREAM_END )
+ {
+ inflateEnd( &stream );
+ if ( err == Z_OK )
+ err = Z_BUF_ERROR;
+ }
+ else
+ {
+ *output_len = stream.total_out;
+
+ err = inflateEnd( &stream );
+ }
+
+ if ( err == Z_MEM_ERROR )
+ return FT_THROW( Out_Of_Memory );
+
+ if ( err == Z_BUF_ERROR )
+ return FT_THROW( Array_Too_Large );
+
+ if ( err == Z_DATA_ERROR )
+ return FT_THROW( Invalid_Table );
+
+ return FT_Err_Ok;
+ }
+
+
+#else /* !FT_CONFIG_OPTION_USE_ZLIB */
FT_EXPORT_DEF( FT_Error )
FT_Stream_OpenGzip( FT_Stream stream,
@@ -679,7 +765,24 @@
FT_UNUSED( stream );
FT_UNUSED( source );
- return Gzip_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Gzip_Uncompress( FT_Memory memory,
+ FT_Byte* output,
+ FT_ULong* output_len,
+ const FT_Byte* input,
+ FT_ULong input_len )
+ {
+ FT_UNUSED( memory );
+ FT_UNUSED( output );
+ FT_UNUSED( output_len );
+ FT_UNUSED( input );
+ FT_UNUSED( input_len );
+
+ return FT_THROW( Unimplemented_Feature );
}
#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
diff --git a/src/3rdparty/freetype/src/gzip/inftrees.c b/src/3rdparty/freetype/src/gzip/inftrees.c
index ef53652168..56f52b1701 100644
--- a/src/3rdparty/freetype/src/gzip/inftrees.c
+++ b/src/3rdparty/freetype/src/gzip/inftrees.c
@@ -115,16 +115,16 @@ uIntf *v /* working area: values in order of bit length */
uInt f; /* i repeats in table every f entries */
int g; /* maximum code length */
int h; /* table level */
- register uInt i; /* counter, current code */
- register uInt j; /* counter */
- register int k; /* number of bits in current code */
+ uInt i; /* counter, current code */
+ uInt j; /* counter */
+ int k; /* number of bits in current code */
int l; /* bits per table (returned in m) */
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
- register uIntf *p; /* pointer into c[], b[], or v[] */
+ uIntf *p; /* pointer into c[], b[], or v[] */
inflate_huft *q; /* points to current table */
struct inflate_huft_s r; /* table entry for structure assignment */
inflate_huft *u[BMAX]; /* table stack */
- register int w; /* bits before this table == (l * h) */
+ int w; /* bits before this table == (l * h) */
uInt x[BMAX+1]; /* bit offsets, then code stack */
uIntf *xp; /* pointer into x */
int y; /* number of dummy codes added */
diff --git a/src/3rdparty/freetype/src/gzip/rules.mk b/src/3rdparty/freetype/src/gzip/rules.mk
index d2a43a6a89..37cd991765 100644
--- a/src/3rdparty/freetype/src/gzip/rules.mk
+++ b/src/3rdparty/freetype/src/gzip/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002, 2003 by
+# Copyright 2002, 2003, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -27,49 +27,52 @@ else
endif
-# gzip support sources (i.e., C files)
+# gzip support sources
#
-GZIP_DRV_SRC := $(GZIP_DIR)/ftgzip.c
-
-# gzip support headers
+# 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).
+# However, it doesn't harm if we add everything as a dependency
+# unconditionally.
#
-GZIP_DRV_H :=
+GZIP_DRV_SRCS := $(GZIP_DIR)/adler32.c \
+ $(GZIP_DIR)/infblock.c \
+ $(GZIP_DIR)/infblock.h \
+ $(GZIP_DIR)/infcodes.c \
+ $(GZIP_DIR)/infcodes.h \
+ $(GZIP_DIR)/inffixed.h \
+ $(GZIP_DIR)/inflate.c \
+ $(GZIP_DIR)/inftrees.c \
+ $(GZIP_DIR)/inftrees.h \
+ $(GZIP_DIR)/infutil.c \
+ $(GZIP_DIR)/infutil.h \
+ $(GZIP_DIR)/zconf.h \
+ $(GZIP_DIR)/zlib.h \
+ $(GZIP_DIR)/zutil.c \
+ $(GZIP_DIR)/zutil.h
# gzip driver object(s)
#
-# GZIP_DRV_OBJ_M is used during `multi' builds
-# GZIP_DRV_OBJ_S is used during `single' builds
-#
-ifeq ($(SYSTEM_ZLIB),)
- GZIP_DRV_OBJ_M := $(GZIP_DRV_SRC:$(GZIP_DIR)/%.c=$(OBJ_DIR)/%.$O)
-else
- GZIP_DRV_OBJ_M := $(OBJ_DIR)/ftgzip.$O
-endif
-GZIP_DRV_OBJ_S := $(OBJ_DIR)/ftgzip.$O
-
-# gzip support source file for single build
+# GZIP_DRV_OBJ is used during both `single' and `multi' builds
#
-GZIP_DRV_SRC_S := $(GZIP_DIR)/ftgzip.c
+GZIP_DRV_OBJ := $(OBJ_DIR)/ftgzip.$O
-# gzip support - single object
+# gzip main source file
#
-$(GZIP_DRV_OBJ_S): $(GZIP_DRV_SRC_S) $(GZIP_DRV_SRC) $(FREETYPE_H) \
- $(GZIP_DRV_H)
- $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(GZIP_DRV_SRC_S))
+GZIP_DRV_SRC := $(GZIP_DIR)/ftgzip.c
-# gzip support - multiple objects
+# gzip support - object
#
-$(OBJ_DIR)/%.$O: $(GZIP_DIR)/%.c $(FREETYPE_H) $(GZIP_DRV_H)
- $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
+$(GZIP_DRV_OBJ): $(GZIP_DRV_SRC) $(GZIP_DRV_SRCS) $(FREETYPE_H)
+ $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(GZIP_DRV_SRC))
# update main driver object lists
#
-DRV_OBJS_S += $(GZIP_DRV_OBJ_S)
-DRV_OBJS_M += $(GZIP_DRV_OBJ_M)
+DRV_OBJS_S += $(GZIP_DRV_OBJ)
+DRV_OBJS_M += $(GZIP_DRV_OBJ)
# EOF
diff --git a/src/3rdparty/freetype/src/gzip/zconf.h b/src/3rdparty/freetype/src/gzip/zconf.h
index bdaf57e300..3abf0ba03b 100644
--- a/src/3rdparty/freetype/src/gzip/zconf.h
+++ b/src/3rdparty/freetype/src/gzip/zconf.h
@@ -5,11 +5,6 @@
/* @(#) $Id$ */
-#if defined(__ARMCC__) || defined(__CC_ARM)
-/* Ultra ugly hack that convinces RVCT to use the systems zlib */
-#include <stdapis/zconf.h>
-#else /* defined(__ARMCC__) || defined(__CC_ARM) */
-
#ifndef _ZCONF_H
#define _ZCONF_H
@@ -287,5 +282,3 @@ typedef uLong FAR uLongf;
#endif
#endif /* _ZCONF_H */
-
-#endif /* defined(__ARMCC__) || defined(__CC_ARM) */
diff --git a/src/3rdparty/freetype/src/gzip/zlib.h b/src/3rdparty/freetype/src/gzip/zlib.h
index 0f98fdcbd3..50d0d3f146 100644
--- a/src/3rdparty/freetype/src/gzip/zlib.h
+++ b/src/3rdparty/freetype/src/gzip/zlib.h
@@ -28,11 +28,6 @@
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
*/
-#if defined(__ARMCC__) || defined(__CC_ARM)
-/* Ultra ugly hack that convinces RVCT to use the systems zlib */
-#include <stdapis/zlib.h>
-#else /* defined(__ARMCC__) || defined(__CC_ARM) */
-
#ifndef _ZLIB_H
#define _ZLIB_H
@@ -833,5 +828,3 @@ ZEXTERN(int) inflateInit2_ OF((z_streamp strm, int windowBits,
#endif
#endif /* _ZLIB_H */
-
-#endif /* defined(__ARMCC__) || defined(__CC_ARM) */
diff --git a/src/3rdparty/freetype/src/lzw/ftlzw.c b/src/3rdparty/freetype/src/lzw/ftlzw.c
index 6e57dedb97..e1b3564a5f 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, 2005, 2006, 2009, 2010 by */
+/* Copyright 2004-2006, 2009, 2010, 2012-2014 by */
/* Albert Chin-A-Young. */
/* */
/* Based on code in src/gzip/ftgzip.c, Copyright 2004 by */
@@ -34,6 +34,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX LZW_Err_
#define FT_ERR_BASE FT_Mod_Err_LZW
@@ -44,7 +45,7 @@
#ifdef FT_CONFIG_OPTION_PIC
#error "lzw code does not support PIC yet"
-#endif
+#endif
#include "ftzopen.h"
@@ -95,9 +96,9 @@
goto Exit;
/* head[0] && head[1] are the magic numbers */
- if ( head[0] != 0x1f ||
- head[1] != 0x9d )
- error = LZW_Err_Invalid_File_Format;
+ if ( head[0] != 0x1F ||
+ head[1] != 0x9D )
+ error = FT_THROW( Invalid_File_Format );
Exit:
return error;
@@ -110,7 +111,7 @@
FT_Stream source )
{
FT_LzwState lzw = &zip->lzw;
- FT_Error error = LZW_Err_Ok;
+ FT_Error error;
zip->stream = stream;
@@ -171,7 +172,7 @@
{
FT_LzwState lzw = &zip->lzw;
FT_ULong count;
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
zip->cursor = zip->buffer;
@@ -181,7 +182,7 @@
zip->limit = zip->cursor + count;
if ( count == 0 )
- error = LZW_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
return error;
}
@@ -192,7 +193,7 @@
ft_lzw_file_skip_output( FT_LZWFile zip,
FT_ULong count )
{
- FT_Error error = LZW_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* first, we skip what we can from the output buffer */
@@ -223,7 +224,7 @@
if ( numread < delta )
{
/* not enough bytes */
- error = LZW_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
break;
}
@@ -348,10 +349,18 @@
FT_Stream source )
{
FT_Error error;
- FT_Memory memory = source->memory;
- FT_LZWFile zip;
+ FT_Memory memory;
+ FT_LZWFile zip = NULL;
+ if ( !stream || !source )
+ {
+ error = FT_THROW( Invalid_Stream_Handle );
+ goto Exit;
+ }
+
+ memory = source->memory;
+
/*
* Check the header right now; this prevents allocation of a huge
* LZWFile object (400 KByte of heap memory) if not necessary.
@@ -402,7 +411,7 @@
FT_UNUSED( stream );
FT_UNUSED( source );
- return LZW_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
diff --git a/src/3rdparty/freetype/src/lzw/ftzopen.c b/src/3rdparty/freetype/src/lzw/ftzopen.c
index 8bc65c8f57..d7a64576ba 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, 2006, 2007, 2009 by David Turner. */
+/* Copyright 2005-2007, 2009, 2011 by David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -124,6 +124,15 @@
old_size = 0;
}
+ /* requirement of the character stack larger than 1<<LZW_MAX_BITS */
+ /* implies bug in the decompression code */
+ if ( new_size > ( 1 << LZW_MAX_BITS ) )
+ {
+ new_size = 1 << LZW_MAX_BITS;
+ if ( new_size == old_size )
+ return -1;
+ }
+
if ( FT_RENEW_ARRAY( state->stack, old_size, new_size ) )
return -1;
@@ -279,7 +288,7 @@
: state->max_free + 1;
c = ft_lzwstate_get_code( state );
- if ( c < 0 )
+ if ( c < 0 || c > 255 )
goto Eof;
old_code = old_char = (FT_UInt)c;
@@ -312,11 +321,12 @@
/* why not LZW_FIRST-256 ? */
state->free_ent = ( LZW_FIRST - 1 ) - 256;
state->buf_clear = 1;
- c = ft_lzwstate_get_code( state );
- if ( c < 0 )
- goto Eof;
- code = (FT_UInt)c;
+ /* not quite right, but at least more predictable */
+ old_code = 0;
+ old_char = 0;
+
+ goto NextCode;
}
in_code = code; /* save code for later */
@@ -326,6 +336,10 @@
/* special case for KwKwKwK */
if ( code - 256U >= state->free_ent )
{
+ /* corrupted LZW stream */
+ if ( code - 256U > state->free_ent )
+ goto Eof;
+
FTLZW_STACK_PUSH( old_char );
code = old_code;
}
diff --git a/src/3rdparty/freetype/src/lzw/ftzopen.h b/src/3rdparty/freetype/src/lzw/ftzopen.h
index f7d2936be2..cdc8fd7c1a 100644
--- a/src/3rdparty/freetype/src/lzw/ftzopen.h
+++ b/src/3rdparty/freetype/src/lzw/ftzopen.h
@@ -41,7 +41,7 @@
#define LZW_CLEAR 256
#define LZW_FIRST 257
-#define LZW_BIT_MASK 0x1f
+#define LZW_BIT_MASK 0x1F
#define LZW_BLOCK_MASK 0x80
#define LZW_MASK( n ) ( ( 1U << (n) ) - 1U )
diff --git a/src/3rdparty/freetype/src/otvalid/otvbase.c b/src/3rdparty/freetype/src/otvalid/otvbase.c
index d742d2dc95..4f9d2fa256 100644
--- a/src/3rdparty/freetype/src/otvalid/otvbase.c
+++ b/src/3rdparty/freetype/src/otvalid/otvbase.c
@@ -32,7 +32,7 @@
static void
otv_BaseCoord_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt BaseCoordFormat;
@@ -58,7 +58,7 @@
case 3: /* BaseCoordFormat3 */
OTV_LIMIT_CHECK( 2 );
/* DeviceTable */
- otv_Device_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_Device_validate( table + FT_NEXT_USHORT( p ), otvalid );
break;
default:
@@ -71,7 +71,7 @@
static void
otv_BaseTagList_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt BaseTagCount;
@@ -93,7 +93,7 @@
static void
otv_BaseValues_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt BaseCoordCount;
@@ -112,7 +112,7 @@
/* BaseCoord */
for ( ; BaseCoordCount > 0; BaseCoordCount-- )
- otv_BaseCoord_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_BaseCoord_validate( table + FT_NEXT_USHORT( p ), otvalid );
OTV_EXIT;
}
@@ -120,7 +120,7 @@
static void
otv_MinMax_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt table_size;
@@ -144,11 +144,11 @@
OTV_SIZE_CHECK( MinCoord );
if ( MinCoord )
- otv_BaseCoord_validate( table + MinCoord, valid );
+ otv_BaseCoord_validate( table + MinCoord, otvalid );
OTV_SIZE_CHECK( MaxCoord );
if ( MaxCoord )
- otv_BaseCoord_validate( table + MaxCoord, valid );
+ otv_BaseCoord_validate( table + MaxCoord, otvalid );
OTV_LIMIT_CHECK( FeatMinMaxCount * 8 );
@@ -162,11 +162,11 @@
OTV_SIZE_CHECK( MinCoord );
if ( MinCoord )
- otv_BaseCoord_validate( table + MinCoord, valid );
+ otv_BaseCoord_validate( table + MinCoord, otvalid );
OTV_SIZE_CHECK( MaxCoord );
if ( MaxCoord )
- otv_BaseCoord_validate( table + MaxCoord, valid );
+ otv_BaseCoord_validate( table + MaxCoord, otvalid );
}
OTV_EXIT;
@@ -175,7 +175,7 @@
static void
otv_BaseScript_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt table_size;
@@ -198,11 +198,11 @@
OTV_SIZE_CHECK( BaseValues );
if ( BaseValues )
- otv_BaseValues_validate( table + BaseValues, valid );
+ otv_BaseValues_validate( table + BaseValues, otvalid );
OTV_SIZE_CHECK( DefaultMinMax );
if ( DefaultMinMax )
- otv_MinMax_validate( table + DefaultMinMax, valid );
+ otv_MinMax_validate( table + DefaultMinMax, otvalid );
OTV_LIMIT_CHECK( BaseLangSysCount * 6 );
@@ -211,7 +211,7 @@
{
p += 4; /* skip BaseLangSysTag */
- otv_MinMax_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_MinMax_validate( table + FT_NEXT_USHORT( p ), otvalid );
}
OTV_EXIT;
@@ -220,7 +220,7 @@
static void
otv_BaseScriptList_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt BaseScriptCount;
@@ -241,7 +241,7 @@
p += 4; /* skip BaseScriptTag */
/* BaseScript */
- otv_BaseScript_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_BaseScript_validate( table + FT_NEXT_USHORT( p ), otvalid );
}
OTV_EXIT;
@@ -250,7 +250,7 @@
static void
otv_Axis_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt table_size;
@@ -267,10 +267,10 @@
OTV_SIZE_CHECK( BaseTagList );
if ( BaseTagList )
- otv_BaseTagList_validate( table + BaseTagList, valid );
+ otv_BaseTagList_validate( table + BaseTagList, otvalid );
/* BaseScriptList */
- otv_BaseScriptList_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_BaseScriptList_validate( table + FT_NEXT_USHORT( p ), otvalid );
OTV_EXIT;
}
@@ -280,16 +280,16 @@
otv_BASE_validate( FT_Bytes table,
FT_Validator ftvalid )
{
- OTV_ValidatorRec validrec;
- OTV_Validator valid = &validrec;
- FT_Bytes p = table;
+ OTV_ValidatorRec otvalidrec;
+ OTV_Validator otvalid = &otvalidrec;
+ FT_Bytes p = table;
FT_UInt table_size;
OTV_OPTIONAL_TABLE( HorizAxis );
OTV_OPTIONAL_TABLE( VertAxis );
- valid->root = ftvalid;
+ otvalid->root = ftvalid;
FT_TRACE3(( "validating BASE table\n" ));
OTV_INIT;
@@ -304,12 +304,12 @@
OTV_OPTIONAL_OFFSET( HorizAxis );
OTV_SIZE_CHECK( HorizAxis );
if ( HorizAxis )
- otv_Axis_validate( table + HorizAxis, valid );
+ otv_Axis_validate( table + HorizAxis, otvalid );
OTV_OPTIONAL_OFFSET( VertAxis );
OTV_SIZE_CHECK( VertAxis );
if ( VertAxis )
- otv_Axis_validate( table + VertAxis, valid );
+ otv_Axis_validate( table + VertAxis, otvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvcommn.c b/src/3rdparty/freetype/src/otvalid/otvcommn.c
index a4f885b51f..3c3de63ca9 100644
--- a/src/3rdparty/freetype/src/otvalid/otvcommn.c
+++ b/src/3rdparty/freetype/src/otvalid/otvcommn.c
@@ -39,7 +39,7 @@
FT_LOCAL_DEF( void )
otv_Coverage_validate( FT_Bytes table,
- OTV_Validator valid,
+ OTV_Validator otvalid,
FT_Int expected_count )
{
FT_Bytes p = table;
@@ -74,7 +74,7 @@
gid = FT_NEXT_USHORT( p );
- if ( gid >= valid->glyph_count )
+ if ( gid >= otvalid->glyph_count )
FT_INVALID_GLYPH_ID;
}
@@ -104,7 +104,7 @@
if ( Start > End || StartCoverageIndex != total )
FT_INVALID_DATA;
- if ( End >= valid->glyph_count )
+ if ( End >= otvalid->glyph_count )
FT_INVALID_GLYPH_ID;
if ( n > 0 && Start <= last )
@@ -219,7 +219,7 @@
FT_LOCAL_DEF( void )
otv_ClassDef_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt ClassFormat;
@@ -249,7 +249,7 @@
OTV_LIMIT_CHECK( GlyphCount * 2 ); /* ClassValueArray */
- if ( StartGlyph + GlyphCount - 1 >= valid->glyph_count )
+ if ( StartGlyph + GlyphCount - 1 >= otvalid->glyph_count )
FT_INVALID_GLYPH_ID;
}
break;
@@ -276,7 +276,7 @@
if ( Start > End || ( n > 0 && Start <= last ) )
FT_INVALID_DATA;
- if ( End >= valid->glyph_count )
+ if ( End >= otvalid->glyph_count )
FT_INVALID_GLYPH_ID;
last = End;
@@ -305,7 +305,7 @@
FT_LOCAL_DEF( void )
otv_Device_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt StartSize, EndSize, DeltaFormat, count;
@@ -339,12 +339,12 @@
/*************************************************************************/
/*************************************************************************/
- /* uses valid->type_count */
- /* uses valid->type_funcs */
+ /* uses otvalid->type_count */
+ /* uses otvalid->type_funcs */
FT_LOCAL_DEF( void )
otv_Lookup_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt LookupType, SubTableCount;
@@ -360,10 +360,10 @@
OTV_TRACE(( " (type %d)\n", LookupType ));
- if ( LookupType == 0 || LookupType > valid->type_count )
+ if ( LookupType == 0 || LookupType > otvalid->type_count )
FT_INVALID_DATA;
- validate = valid->type_funcs[LookupType - 1];
+ validate = otvalid->type_funcs[LookupType - 1];
OTV_TRACE(( " (SubTableCount = %d)\n", SubTableCount ));
@@ -371,7 +371,7 @@
/* SubTable */
for ( ; SubTableCount > 0; SubTableCount-- )
- validate( table + FT_NEXT_USHORT( p ), valid );
+ validate( table + FT_NEXT_USHORT( p ), otvalid );
OTV_EXIT;
}
@@ -381,7 +381,7 @@
FT_LOCAL_DEF( void )
otv_LookupList_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt LookupCount;
@@ -396,11 +396,11 @@
OTV_LIMIT_CHECK( LookupCount * 2 );
- valid->lookup_count = LookupCount;
+ otvalid->lookup_count = LookupCount;
/* Lookup */
for ( ; LookupCount > 0; LookupCount-- )
- otv_Lookup_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_Lookup_validate( table + FT_NEXT_USHORT( p ), otvalid );
OTV_EXIT;
}
@@ -421,11 +421,11 @@
/*************************************************************************/
/*************************************************************************/
- /* uses valid->lookup_count */
+ /* uses otvalid->lookup_count */
FT_LOCAL_DEF( void )
otv_Feature_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt LookupCount;
@@ -443,7 +443,7 @@
/* LookupListIndex */
for ( ; LookupCount > 0; LookupCount-- )
- if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->lookup_count )
FT_INVALID_DATA;
OTV_EXIT;
@@ -457,12 +457,12 @@
}
- /* sets valid->lookup_count */
+ /* sets otvalid->lookup_count */
FT_LOCAL_DEF( void )
otv_FeatureList_validate( FT_Bytes table,
FT_Bytes lookups,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt FeatureCount;
@@ -477,7 +477,7 @@
OTV_LIMIT_CHECK( FeatureCount * 2 );
- valid->lookup_count = otv_LookupList_get_count( lookups );
+ otvalid->lookup_count = otv_LookupList_get_count( lookups );
/* FeatureRecord */
for ( ; FeatureCount > 0; FeatureCount-- )
@@ -485,7 +485,7 @@
p += 4; /* skip FeatureTag */
/* Feature */
- otv_Feature_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_Feature_validate( table + FT_NEXT_USHORT( p ), otvalid );
}
OTV_EXIT;
@@ -501,11 +501,11 @@
/*************************************************************************/
- /* uses valid->extra1 (number of features) */
+ /* uses otvalid->extra1 (number of features) */
FT_LOCAL_DEF( void )
otv_LangSys_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt ReqFeatureIndex;
@@ -522,14 +522,14 @@
OTV_TRACE(( " (ReqFeatureIndex = %d)\n", ReqFeatureIndex ));
OTV_TRACE(( " (FeatureCount = %d)\n", FeatureCount ));
- if ( ReqFeatureIndex != 0xFFFFU && ReqFeatureIndex >= valid->extra1 )
+ if ( ReqFeatureIndex != 0xFFFFU && ReqFeatureIndex >= otvalid->extra1 )
FT_INVALID_DATA;
OTV_LIMIT_CHECK( FeatureCount * 2 );
/* FeatureIndex */
for ( ; FeatureCount > 0; FeatureCount-- )
- if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
FT_INVALID_DATA;
OTV_EXIT;
@@ -546,7 +546,7 @@
FT_LOCAL_DEF( void )
otv_Script_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_UInt DefaultLangSys, LangSysCount;
FT_Bytes p = table;
@@ -561,7 +561,7 @@
OTV_TRACE(( " (LangSysCount = %d)\n", LangSysCount ));
if ( DefaultLangSys != 0 )
- otv_LangSys_validate( table + DefaultLangSys, valid );
+ otv_LangSys_validate( table + DefaultLangSys, otvalid );
OTV_LIMIT_CHECK( LangSysCount * 6 );
@@ -571,19 +571,19 @@
p += 4; /* skip LangSysTag */
/* LangSys */
- otv_LangSys_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_LangSys_validate( table + FT_NEXT_USHORT( p ), otvalid );
}
OTV_EXIT;
}
- /* sets valid->extra1 (number of features) */
+ /* sets otvalid->extra1 (number of features) */
FT_LOCAL_DEF( void )
otv_ScriptList_validate( FT_Bytes table,
FT_Bytes features,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_UInt ScriptCount;
FT_Bytes p = table;
@@ -598,14 +598,14 @@
OTV_LIMIT_CHECK( ScriptCount * 6 );
- valid->extra1 = otv_Feature_get_count( features );
+ otvalid->extra1 = otv_Feature_get_count( features );
/* ScriptRecord */
for ( ; ScriptCount > 0; ScriptCount-- )
{
p += 4; /* skip ScriptTag */
- otv_Script_validate( table + FT_NEXT_USHORT( p ), valid ); /* Script */
+ otv_Script_validate( table + FT_NEXT_USHORT( p ), otvalid ); /* Script */
}
OTV_EXIT;
@@ -640,7 +640,7 @@
FT_LOCAL_DEF( void )
otv_x_Ox( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Count;
@@ -656,13 +656,13 @@
OTV_LIMIT_CHECK( Count * 2 );
- valid->nesting_level++;
- func = valid->func[valid->nesting_level];
+ otvalid->nesting_level++;
+ func = otvalid->func[otvalid->nesting_level];
for ( ; Count > 0; Count-- )
- func( table + FT_NEXT_USHORT( p ), valid );
+ func( table + FT_NEXT_USHORT( p ), otvalid );
- valid->nesting_level--;
+ otvalid->nesting_level--;
OTV_EXIT;
}
@@ -670,7 +670,7 @@
FT_LOCAL_DEF( void )
otv_u_C_x_Ox( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Count, Coverage;
@@ -687,27 +687,27 @@
OTV_TRACE(( " (Count = %d)\n", Count ));
- otv_Coverage_validate( table + Coverage, valid, Count );
+ otv_Coverage_validate( table + Coverage, otvalid, Count );
OTV_LIMIT_CHECK( Count * 2 );
- valid->nesting_level++;
- func = valid->func[valid->nesting_level];
+ otvalid->nesting_level++;
+ func = otvalid->func[otvalid->nesting_level];
for ( ; Count > 0; Count-- )
- func( table + FT_NEXT_USHORT( p ), valid );
+ func( table + FT_NEXT_USHORT( p ), otvalid );
- valid->nesting_level--;
+ otvalid->nesting_level--;
OTV_EXIT;
}
- /* uses valid->extra1 (if > 0: array value limit) */
+ /* uses otvalid->extra1 (if > 0: array value limit) */
FT_LOCAL_DEF( void )
otv_x_ux( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Count;
@@ -722,10 +722,10 @@
OTV_LIMIT_CHECK( Count * 2 );
- if ( valid->extra1 )
+ if ( otvalid->extra1 )
{
for ( ; Count > 0; Count-- )
- if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
FT_INVALID_DATA;
}
@@ -736,11 +736,11 @@
/* `ux' in the function's name is not really correct since only x-1 */
/* elements are tested */
- /* uses valid->extra1 (array value limit) */
+ /* uses otvalid->extra1 (array value limit) */
FT_LOCAL_DEF( void )
otv_x_y_ux_sy( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Count1, Count2;
@@ -766,7 +766,7 @@
if ( FT_NEXT_USHORT( p ) >= Count1 )
FT_INVALID_DATA;
- if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
FT_INVALID_DATA;
}
@@ -777,11 +777,11 @@
/* `uy' in the function's name is not really correct since only y-1 */
/* elements are tested */
- /* uses valid->extra1 (array value limit) */
+ /* uses otvalid->extra1 (array value limit) */
FT_LOCAL_DEF( void )
otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt BacktrackCount, InputCount, LookaheadCount;
@@ -825,7 +825,7 @@
if ( FT_NEXT_USHORT( p ) >= InputCount )
FT_INVALID_DATA;
- if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
FT_INVALID_DATA;
}
@@ -833,11 +833,11 @@
}
- /* sets valid->extra1 (valid->lookup_count) */
+ /* sets otvalid->extra1 (valid->lookup_count) */
FT_LOCAL_DEF( void )
otv_u_O_O_x_Onx( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Coverage, ClassDef, ClassSetCount;
@@ -855,14 +855,14 @@
OTV_TRACE(( " (ClassSetCount = %d)\n", ClassSetCount ));
- otv_Coverage_validate( table + Coverage, valid, -1 );
- otv_ClassDef_validate( table + ClassDef, valid );
+ otv_Coverage_validate( table + Coverage, otvalid, -1 );
+ otv_ClassDef_validate( table + ClassDef, otvalid );
OTV_LIMIT_CHECK( ClassSetCount * 2 );
- valid->nesting_level++;
- func = valid->func[valid->nesting_level];
- valid->extra1 = valid->lookup_count;
+ otvalid->nesting_level++;
+ func = otvalid->func[otvalid->nesting_level];
+ otvalid->extra1 = otvalid->lookup_count;
for ( ; ClassSetCount > 0; ClassSetCount-- )
{
@@ -870,20 +870,20 @@
if ( offset )
- func( table + offset, valid );
+ func( table + offset, otvalid );
}
- valid->nesting_level--;
+ otvalid->nesting_level--;
OTV_EXIT;
}
- /* uses valid->lookup_count */
+ /* uses otvalid->lookup_count */
FT_LOCAL_DEF( void )
otv_u_x_y_Ox_sy( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt GlyphCount, Count, count1;
@@ -903,14 +903,14 @@
OTV_LIMIT_CHECK( GlyphCount * 2 + Count * 4 );
for ( count1 = GlyphCount; count1 > 0; count1-- )
- otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+ otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
for ( ; Count > 0; Count-- )
{
if ( FT_NEXT_USHORT( p ) >= GlyphCount )
FT_INVALID_DATA;
- if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->lookup_count )
FT_INVALID_DATA;
}
@@ -918,11 +918,11 @@
}
- /* sets valid->extra1 (valid->lookup_count) */
+ /* sets otvalid->extra1 (valid->lookup_count) */
FT_LOCAL_DEF( void )
otv_u_O_O_O_O_x_Onx( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Coverage;
@@ -944,17 +944,17 @@
OTV_TRACE(( " (ChainClassSetCount = %d)\n", ChainClassSetCount ));
- otv_Coverage_validate( table + Coverage, valid, -1 );
+ otv_Coverage_validate( table + Coverage, otvalid, -1 );
- otv_ClassDef_validate( table + BacktrackClassDef, valid );
- otv_ClassDef_validate( table + InputClassDef, valid );
- otv_ClassDef_validate( table + LookaheadClassDef, valid );
+ otv_ClassDef_validate( table + BacktrackClassDef, otvalid );
+ otv_ClassDef_validate( table + InputClassDef, otvalid );
+ otv_ClassDef_validate( table + LookaheadClassDef, otvalid );
OTV_LIMIT_CHECK( ChainClassSetCount * 2 );
- valid->nesting_level++;
- func = valid->func[valid->nesting_level];
- valid->extra1 = valid->lookup_count;
+ otvalid->nesting_level++;
+ func = otvalid->func[otvalid->nesting_level];
+ otvalid->extra1 = otvalid->lookup_count;
for ( ; ChainClassSetCount > 0; ChainClassSetCount-- )
{
@@ -962,20 +962,20 @@
if ( offset )
- func( table + offset, valid );
+ func( table + offset, otvalid );
}
- valid->nesting_level--;
+ otvalid->nesting_level--;
OTV_EXIT;
}
- /* uses valid->lookup_count */
+ /* uses otvalid->lookup_count */
FT_LOCAL_DEF( void )
otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt BacktrackGlyphCount, InputGlyphCount, LookaheadGlyphCount;
@@ -994,7 +994,7 @@
OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 );
for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- )
- otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+ otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
InputGlyphCount = FT_NEXT_USHORT( p );
@@ -1003,7 +1003,7 @@
OTV_LIMIT_CHECK( InputGlyphCount * 2 + 2 );
for ( count1 = InputGlyphCount; count1 > 0; count1-- )
- otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+ otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
LookaheadGlyphCount = FT_NEXT_USHORT( p );
@@ -1012,7 +1012,7 @@
OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 );
for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- )
- otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+ otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
count2 = FT_NEXT_USHORT( p );
@@ -1025,7 +1025,7 @@
if ( FT_NEXT_USHORT( p ) >= InputGlyphCount )
FT_INVALID_DATA;
- if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->lookup_count )
FT_INVALID_DATA;
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvcommn.h b/src/3rdparty/freetype/src/otvalid/otvcommn.h
index 898887fc95..5c93ba7eff 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, 2005, 2007, 2009 by */
+/* Copyright 2004, 2005, 2007, 2009, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -39,7 +39,7 @@ FT_BEGIN_HEADER
typedef struct OTV_ValidatorRec_* OTV_Validator;
typedef void (*OTV_Validate_Func)( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
typedef struct OTV_ValidatorRec_
{
@@ -67,8 +67,8 @@ FT_BEGIN_HEADER
#undef FT_INVALID_
-#define FT_INVALID_( _prefix, _error ) \
- ft_validator_error( valid->root, _prefix ## _error )
+#define FT_INVALID_( _error ) \
+ ft_validator_error( otvalid->root, FT_THROW( _error ) )
#define OTV_OPTIONAL_TABLE( _table ) FT_UShort _table; \
FT_Bytes _table ## _p
@@ -81,7 +81,7 @@ FT_BEGIN_HEADER
#define OTV_LIMIT_CHECK( _count ) \
FT_BEGIN_STMNT \
- if ( p + (_count) > valid->root->limit ) \
+ if ( p + (_count) > otvalid->root->limit ) \
FT_INVALID_TOO_SHORT; \
FT_END_STMNT
@@ -89,7 +89,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
if ( _size > 0 && _size < table_size ) \
{ \
- if ( valid->root->level == FT_VALIDATE_PARANOID ) \
+ if ( otvalid->root->level == FT_VALIDATE_PARANOID ) \
FT_INVALID_OFFSET; \
else \
{ \
@@ -117,79 +117,79 @@ FT_BEGIN_HEADER
#ifdef FT_DEBUG_LEVEL_TRACE
-#define OTV_NEST1( x ) \
- FT_BEGIN_STMNT \
- valid->nesting_level = 0; \
- valid->func[0] = OTV_FUNC( x ); \
- valid->debug_function_name[0] = OTV_NAME( x ); \
+#define OTV_NEST1( x ) \
+ FT_BEGIN_STMNT \
+ otvalid->nesting_level = 0; \
+ otvalid->func[0] = OTV_FUNC( x ); \
+ otvalid->debug_function_name[0] = OTV_NAME( x ); \
FT_END_STMNT
-#define OTV_NEST2( x, y ) \
- FT_BEGIN_STMNT \
- valid->nesting_level = 0; \
- valid->func[0] = OTV_FUNC( x ); \
- valid->func[1] = OTV_FUNC( y ); \
- valid->debug_function_name[0] = OTV_NAME( x ); \
- valid->debug_function_name[1] = OTV_NAME( y ); \
+#define OTV_NEST2( x, y ) \
+ FT_BEGIN_STMNT \
+ otvalid->nesting_level = 0; \
+ otvalid->func[0] = OTV_FUNC( x ); \
+ otvalid->func[1] = OTV_FUNC( y ); \
+ otvalid->debug_function_name[0] = OTV_NAME( x ); \
+ otvalid->debug_function_name[1] = OTV_NAME( y ); \
FT_END_STMNT
-#define OTV_NEST3( x, y, z ) \
- FT_BEGIN_STMNT \
- valid->nesting_level = 0; \
- valid->func[0] = OTV_FUNC( x ); \
- valid->func[1] = OTV_FUNC( y ); \
- valid->func[2] = OTV_FUNC( z ); \
- valid->debug_function_name[0] = OTV_NAME( x ); \
- valid->debug_function_name[1] = OTV_NAME( y ); \
- valid->debug_function_name[2] = OTV_NAME( z ); \
+#define OTV_NEST3( x, y, z ) \
+ FT_BEGIN_STMNT \
+ otvalid->nesting_level = 0; \
+ otvalid->func[0] = OTV_FUNC( x ); \
+ otvalid->func[1] = OTV_FUNC( y ); \
+ otvalid->func[2] = OTV_FUNC( z ); \
+ otvalid->debug_function_name[0] = OTV_NAME( x ); \
+ otvalid->debug_function_name[1] = OTV_NAME( y ); \
+ otvalid->debug_function_name[2] = OTV_NAME( z ); \
FT_END_STMNT
-#define OTV_INIT valid->debug_indent = 0
+#define OTV_INIT otvalid->debug_indent = 0
-#define OTV_ENTER \
- FT_BEGIN_STMNT \
- valid->debug_indent += 2; \
- FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
- FT_TRACE4(( "%s table\n", \
- valid->debug_function_name[valid->nesting_level] )); \
+#define OTV_ENTER \
+ FT_BEGIN_STMNT \
+ otvalid->debug_indent += 2; \
+ FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \
+ FT_TRACE4(( "%s table\n", \
+ otvalid->debug_function_name[otvalid->nesting_level] )); \
FT_END_STMNT
-#define OTV_NAME_ENTER( name ) \
- FT_BEGIN_STMNT \
- valid->debug_indent += 2; \
- FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
- FT_TRACE4(( "%s table\n", name )); \
+#define OTV_NAME_ENTER( name ) \
+ FT_BEGIN_STMNT \
+ otvalid->debug_indent += 2; \
+ FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \
+ FT_TRACE4(( "%s table\n", name )); \
FT_END_STMNT
-#define OTV_EXIT valid->debug_indent -= 2
+#define OTV_EXIT otvalid->debug_indent -= 2
-#define OTV_TRACE( s ) \
- FT_BEGIN_STMNT \
- FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
- FT_TRACE4( s ); \
+#define OTV_TRACE( s ) \
+ FT_BEGIN_STMNT \
+ FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \
+ FT_TRACE4( s ); \
FT_END_STMNT
#else /* !FT_DEBUG_LEVEL_TRACE */
-#define OTV_NEST1( x ) \
- FT_BEGIN_STMNT \
- valid->nesting_level = 0; \
- valid->func[0] = OTV_FUNC( x ); \
+#define OTV_NEST1( x ) \
+ FT_BEGIN_STMNT \
+ otvalid->nesting_level = 0; \
+ otvalid->func[0] = OTV_FUNC( x ); \
FT_END_STMNT
-#define OTV_NEST2( x, y ) \
- FT_BEGIN_STMNT \
- valid->nesting_level = 0; \
- valid->func[0] = OTV_FUNC( x ); \
- valid->func[1] = OTV_FUNC( y ); \
+#define OTV_NEST2( x, y ) \
+ FT_BEGIN_STMNT \
+ otvalid->nesting_level = 0; \
+ otvalid->func[0] = OTV_FUNC( x ); \
+ otvalid->func[1] = OTV_FUNC( y ); \
FT_END_STMNT
-#define OTV_NEST3( x, y, z ) \
- FT_BEGIN_STMNT \
- valid->nesting_level = 0; \
- valid->func[0] = OTV_FUNC( x ); \
- valid->func[1] = OTV_FUNC( y ); \
- valid->func[2] = OTV_FUNC( z ); \
+#define OTV_NEST3( x, y, z ) \
+ FT_BEGIN_STMNT \
+ otvalid->nesting_level = 0; \
+ otvalid->func[0] = OTV_FUNC( x ); \
+ otvalid->func[1] = OTV_FUNC( y ); \
+ otvalid->func[2] = OTV_FUNC( z ); \
FT_END_STMNT
#define OTV_INIT do { } while ( 0 )
@@ -202,7 +202,7 @@ FT_BEGIN_HEADER
#endif /* !FT_DEBUG_LEVEL_TRACE */
-#define OTV_RUN valid->func[0]
+#define OTV_RUN otvalid->func[0]
/*************************************************************************/
@@ -215,7 +215,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_Coverage_validate( FT_Bytes table,
- OTV_Validator valid,
+ OTV_Validator otvalid,
FT_Int expected_count );
/* return first covered glyph */
@@ -241,7 +241,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_ClassDef_validate( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/*************************************************************************/
@@ -254,7 +254,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_Device_validate( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/*************************************************************************/
@@ -267,11 +267,11 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_Lookup_validate( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
FT_LOCAL( void )
otv_LookupList_validate( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/*************************************************************************/
@@ -284,13 +284,13 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_Feature_validate( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/* lookups must already be validated */
FT_LOCAL( void )
otv_FeatureList_validate( FT_Bytes table,
FT_Bytes lookups,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/*************************************************************************/
@@ -303,7 +303,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_LangSys_validate( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/*************************************************************************/
@@ -316,13 +316,13 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_Script_validate( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/* features must already be validated */
FT_LOCAL( void )
otv_ScriptList_validate( FT_Bytes table,
FT_Bytes features,
- OTV_Validator valid );
+ OTV_Validator otvalid );
/*************************************************************************/
@@ -349,7 +349,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_x_Ox ( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define AlternateSubstFormat1Func otv_u_C_x_Ox
#define ChainContextPosFormat1Func otv_u_C_x_Ox
@@ -361,7 +361,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_u_C_x_Ox( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define AlternateSetFunc otv_x_ux
#define AttachPointFunc otv_x_ux
@@ -372,7 +372,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_x_ux( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define PosClassRuleFunc otv_x_y_ux_sy
#define PosRuleFunc otv_x_y_ux_sy
@@ -381,7 +381,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_x_y_ux_sy( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define ChainPosClassRuleFunc otv_x_ux_y_uy_z_uz_p_sp
#define ChainPosRuleFunc otv_x_ux_y_uy_z_uz_p_sp
@@ -390,35 +390,35 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define ContextPosFormat2Func otv_u_O_O_x_Onx
#define ContextSubstFormat2Func otv_u_O_O_x_Onx
FT_LOCAL( void )
otv_u_O_O_x_Onx( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define ContextPosFormat3Func otv_u_x_y_Ox_sy
#define ContextSubstFormat3Func otv_u_x_y_Ox_sy
FT_LOCAL( void )
otv_u_x_y_Ox_sy( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define ChainContextPosFormat2Func otv_u_O_O_O_O_x_Onx
#define ChainContextSubstFormat2Func otv_u_O_O_O_O_x_Onx
FT_LOCAL( void )
otv_u_O_O_O_O_x_Onx( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
#define ChainContextPosFormat3Func otv_u_x_Ox_y_Oy_z_Oz_p_sp
#define ChainContextSubstFormat3Func otv_u_x_Ox_y_Oy_z_Oz_p_sp
FT_LOCAL( void )
otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes table,
- OTV_Validator valid );
+ OTV_Validator otvalid );
FT_LOCAL( FT_UInt )
diff --git a/src/3rdparty/freetype/src/otvalid/otverror.h b/src/3rdparty/freetype/src/otvalid/otverror.h
index 041b538368..b6f00c9dba 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, 2005 by */
+/* Copyright 2004, 2005, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,11 +30,10 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX OTV_Err_
#define FT_ERR_BASE FT_Mod_Err_OTvalid
-#define FT_KEEP_ERR_PREFIX
-
#include FT_ERRORS_H
#endif /* __OTVERROR_H__ */
diff --git a/src/3rdparty/freetype/src/otvalid/otvgdef.c b/src/3rdparty/freetype/src/otvalid/otvgdef.c
index 3633ad0de1..e60ef363d8 100644
--- a/src/3rdparty/freetype/src/otvalid/otvgdef.c
+++ b/src/3rdparty/freetype/src/otvalid/otvgdef.c
@@ -45,7 +45,7 @@
static void
otv_O_x_Ox( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_Bytes Coverage;
@@ -61,20 +61,20 @@
OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
- otv_Coverage_validate( Coverage, valid, GlyphCount );
+ otv_Coverage_validate( Coverage, otvalid, GlyphCount );
if ( GlyphCount != otv_Coverage_get_count( Coverage ) )
FT_INVALID_DATA;
OTV_LIMIT_CHECK( GlyphCount * 2 );
- valid->nesting_level++;
- func = valid->func[valid->nesting_level];
- valid->extra1 = 0;
+ otvalid->nesting_level++;
+ func = otvalid->func[otvalid->nesting_level];
+ otvalid->extra1 = 0;
for ( ; GlyphCount > 0; GlyphCount-- )
- func( table + FT_NEXT_USHORT( p ), valid );
+ func( table + FT_NEXT_USHORT( p ), otvalid );
- valid->nesting_level--;
+ otvalid->nesting_level--;
OTV_EXIT;
}
@@ -92,7 +92,7 @@
static void
otv_CaretValue_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt CaretValueFormat;
@@ -122,7 +122,7 @@
OTV_LIMIT_CHECK( 2 );
/* DeviceTable */
- otv_Device_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_Device_validate( table + FT_NEXT_USHORT( p ), otvalid );
break;
default:
@@ -141,7 +141,7 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->glyph_count */
+ /* sets otvalid->glyph_count */
FT_LOCAL_DEF( void )
otv_GDEF_validate( FT_Bytes table,
@@ -150,8 +150,8 @@
FT_UInt glyph_count,
FT_Validator ftvalid )
{
- OTV_ValidatorRec validrec;
- OTV_Validator valid = &validrec;
+ OTV_ValidatorRec otvalidrec;
+ OTV_Validator otvalid = &otvalidrec;
FT_Bytes p = table;
FT_UInt table_size;
FT_Bool need_MarkAttachClassDef;
@@ -162,7 +162,7 @@
OTV_OPTIONAL_TABLE( MarkAttachClassDef );
- valid->root = ftvalid;
+ otvalid->root = ftvalid;
FT_TRACE3(( "validating GDEF table\n" ));
OTV_INIT;
@@ -186,19 +186,19 @@
else
table_size = 10; /* OpenType < 1.2 */
- valid->glyph_count = glyph_count;
+ otvalid->glyph_count = glyph_count;
OTV_OPTIONAL_OFFSET( GlyphClassDef );
OTV_SIZE_CHECK( GlyphClassDef );
if ( GlyphClassDef )
- otv_ClassDef_validate( table + GlyphClassDef, valid );
+ otv_ClassDef_validate( table + GlyphClassDef, otvalid );
OTV_OPTIONAL_OFFSET( AttachListOffset );
OTV_SIZE_CHECK( AttachListOffset );
if ( AttachListOffset )
{
OTV_NEST2( AttachList, AttachPoint );
- OTV_RUN( table + AttachListOffset, valid );
+ OTV_RUN( table + AttachListOffset, otvalid );
}
OTV_OPTIONAL_OFFSET( LigCaretListOffset );
@@ -206,7 +206,7 @@
if ( LigCaretListOffset )
{
OTV_NEST3( LigCaretList, LigGlyph, CaretValue );
- OTV_RUN( table + LigCaretListOffset, valid );
+ OTV_RUN( table + LigCaretListOffset, otvalid );
}
if ( need_MarkAttachClassDef )
@@ -214,7 +214,7 @@
OTV_OPTIONAL_OFFSET( MarkAttachClassDef );
OTV_SIZE_CHECK( MarkAttachClassDef );
if ( MarkAttachClassDef )
- otv_ClassDef_validate( table + MarkAttachClassDef, valid );
+ otv_ClassDef_validate( table + MarkAttachClassDef, otvalid );
}
FT_TRACE4(( "\n" ));
diff --git a/src/3rdparty/freetype/src/otvalid/otvgpos.c b/src/3rdparty/freetype/src/otvalid/otvgpos.c
index 49b46183a3..1a9dbaaa03 100644
--- a/src/3rdparty/freetype/src/otvalid/otvgpos.c
+++ b/src/3rdparty/freetype/src/otvalid/otvgpos.c
@@ -57,7 +57,7 @@
static void
otv_x_sxy( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Count, count1, table_size;
@@ -71,26 +71,26 @@
OTV_TRACE(( " (Count = %d)\n", Count ));
- OTV_LIMIT_CHECK( Count * valid->extra1 * 2 );
+ OTV_LIMIT_CHECK( Count * otvalid->extra1 * 2 );
- table_size = Count * valid->extra1 * 2 + 2;
+ table_size = Count * otvalid->extra1 * 2 + 2;
for ( ; Count > 0; Count-- )
- for ( count1 = valid->extra1; count1 > 0; count1-- )
+ for ( count1 = otvalid->extra1; count1 > 0; count1-- )
{
OTV_OPTIONAL_TABLE( anchor_offset );
OTV_OPTIONAL_OFFSET( anchor_offset );
- if ( valid->extra2 )
+ if ( otvalid->extra2 )
{
OTV_SIZE_CHECK( anchor_offset );
if ( anchor_offset )
- otv_Anchor_validate( table + anchor_offset, valid );
+ otv_Anchor_validate( table + anchor_offset, otvalid );
}
else
- otv_Anchor_validate( table + anchor_offset, valid );
+ otv_Anchor_validate( table + anchor_offset, otvalid );
}
OTV_EXIT;
@@ -101,11 +101,11 @@
#define MarkLigPosFormat1Func otv_u_O_O_u_O_O
#define MarkMarkPosFormat1Func otv_u_O_O_u_O_O
- /* sets valid->extra1 (class count) */
+ /* sets otvalid->extra1 (class count) */
static void
otv_u_O_O_u_O_O( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt Coverage1, Coverage2, ClassCount;
@@ -124,18 +124,18 @@
Array1 = FT_NEXT_USHORT( p );
Array2 = FT_NEXT_USHORT( p );
- otv_Coverage_validate( table + Coverage1, valid, -1 );
- otv_Coverage_validate( table + Coverage2, valid, -1 );
+ otv_Coverage_validate( table + Coverage1, otvalid, -1 );
+ otv_Coverage_validate( table + Coverage2, otvalid, -1 );
- otv_MarkArray_validate( table + Array1, valid );
+ otv_MarkArray_validate( table + Array1, otvalid );
- valid->nesting_level++;
- func = valid->func[valid->nesting_level];
- valid->extra1 = ClassCount;
+ otvalid->nesting_level++;
+ func = otvalid->func[otvalid->nesting_level];
+ otvalid->extra1 = ClassCount;
- func( table + Array2, valid );
+ func( table + Array2, otvalid );
- valid->nesting_level--;
+ otvalid->nesting_level--;
OTV_EXIT;
}
@@ -163,12 +163,12 @@
}
- /* uses valid->extra3 (pointer to base table) */
+ /* uses otvalid->extra3 (pointer to base table) */
static void
otv_ValueRecord_validate( FT_Bytes table,
FT_UInt format,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt count;
@@ -222,11 +222,11 @@
/* ValueRecord is part of an array -- getting the correct table */
/* size is probably not worth the trouble */
- table_size = p - valid->extra3;
+ table_size = p - otvalid->extra3;
OTV_SIZE_CHECK( device );
if ( device )
- otv_Device_validate( valid->extra3 + device, valid );
+ otv_Device_validate( otvalid->extra3 + device, otvalid );
}
format >>= 1;
}
@@ -245,7 +245,7 @@
static void
otv_Anchor_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt AnchorFormat;
@@ -285,11 +285,11 @@
OTV_SIZE_CHECK( XDeviceTable );
if ( XDeviceTable )
- otv_Device_validate( table + XDeviceTable, valid );
+ otv_Device_validate( table + XDeviceTable, otvalid );
OTV_SIZE_CHECK( YDeviceTable );
if ( YDeviceTable )
- otv_Device_validate( table + YDeviceTable, valid );
+ otv_Device_validate( table + YDeviceTable, otvalid );
}
break;
@@ -311,7 +311,7 @@
static void
otv_MarkArray_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt MarkCount;
@@ -331,7 +331,7 @@
{
p += 2; /* skip Class */
/* MarkAnchor */
- otv_Anchor_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_Anchor_validate( table + FT_NEXT_USHORT( p ), otvalid );
}
OTV_EXIT;
@@ -346,11 +346,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra3 (pointer to base table) */
+ /* sets otvalid->extra3 (pointer to base table) */
static void
otv_SinglePos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -363,7 +363,7 @@
OTV_TRACE(( " (format %d)\n", PosFormat ));
- valid->extra3 = table;
+ otvalid->extra3 = table;
switch ( PosFormat )
{
@@ -376,8 +376,8 @@
Coverage = FT_NEXT_USHORT( p );
ValueFormat = FT_NEXT_USHORT( p );
- otv_Coverage_validate( table + Coverage, valid, -1 );
- otv_ValueRecord_validate( p, ValueFormat, valid ); /* Value */
+ otv_Coverage_validate( table + Coverage, otvalid, -1 );
+ otv_ValueRecord_validate( p, ValueFormat, otvalid ); /* Value */
}
break;
@@ -395,14 +395,14 @@
len_value = otv_value_length( ValueFormat );
- otv_Coverage_validate( table + Coverage, valid, ValueCount );
+ otv_Coverage_validate( table + Coverage, otvalid, ValueCount );
OTV_LIMIT_CHECK( ValueCount * len_value );
/* Value */
for ( ; ValueCount > 0; ValueCount-- )
{
- otv_ValueRecord_validate( p, ValueFormat, valid );
+ otv_ValueRecord_validate( p, ValueFormat, otvalid );
p += len_value;
}
}
@@ -428,7 +428,7 @@
otv_PairSet_validate( FT_Bytes table,
FT_UInt format1,
FT_UInt format2,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt value_len1, value_len2, PairValueCount;
@@ -452,11 +452,11 @@
p += 2; /* skip SecondGlyph */
if ( format1 )
- otv_ValueRecord_validate( p, format1, valid ); /* Value1 */
+ otv_ValueRecord_validate( p, format1, otvalid ); /* Value1 */
p += value_len1;
if ( format2 )
- otv_ValueRecord_validate( p, format2, valid ); /* Value2 */
+ otv_ValueRecord_validate( p, format2, otvalid ); /* Value2 */
p += value_len2;
}
@@ -464,11 +464,11 @@
}
- /* sets valid->extra3 (pointer to base table) */
+ /* sets otvalid->extra3 (pointer to base table) */
static void
otv_PairPos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -481,7 +481,7 @@
OTV_TRACE(( " (format %d)\n", PosFormat ));
- valid->extra3 = table;
+ otvalid->extra3 = table;
switch ( PosFormat )
{
@@ -498,14 +498,14 @@
OTV_TRACE(( " (PairSetCount = %d)\n", PairSetCount ));
- otv_Coverage_validate( table + Coverage, valid, -1 );
+ otv_Coverage_validate( table + Coverage, otvalid, -1 );
OTV_LIMIT_CHECK( PairSetCount * 2 );
/* PairSetOffset */
for ( ; PairSetCount > 0; PairSetCount-- )
otv_PairSet_validate( table + FT_NEXT_USHORT( p ),
- ValueFormat1, ValueFormat2, valid );
+ ValueFormat1, ValueFormat2, otvalid );
}
break;
@@ -530,9 +530,9 @@
len_value1 = otv_value_length( ValueFormat1 );
len_value2 = otv_value_length( ValueFormat2 );
- otv_Coverage_validate( table + Coverage, valid, -1 );
- otv_ClassDef_validate( table + ClassDef1, valid );
- otv_ClassDef_validate( table + ClassDef2, valid );
+ otv_Coverage_validate( table + Coverage, otvalid, -1 );
+ otv_ClassDef_validate( table + ClassDef1, otvalid );
+ otv_ClassDef_validate( table + ClassDef2, otvalid );
OTV_LIMIT_CHECK( ClassCount1 * ClassCount2 *
( len_value1 + len_value2 ) );
@@ -545,12 +545,12 @@
{
if ( ValueFormat1 )
/* Value1 */
- otv_ValueRecord_validate( p, ValueFormat1, valid );
+ otv_ValueRecord_validate( p, ValueFormat1, otvalid );
p += len_value1;
if ( ValueFormat2 )
/* Value2 */
- otv_ValueRecord_validate( p, ValueFormat2, valid );
+ otv_ValueRecord_validate( p, ValueFormat2, otvalid );
p += len_value2;
}
}
@@ -575,7 +575,7 @@
static void
otv_CursivePos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -605,7 +605,7 @@
OTV_TRACE(( " (EntryExitCount = %d)\n", EntryExitCount ));
- otv_Coverage_validate( table + Coverage, valid, EntryExitCount );
+ otv_Coverage_validate( table + Coverage, otvalid, EntryExitCount );
OTV_LIMIT_CHECK( EntryExitCount * 4 );
@@ -619,11 +619,11 @@
OTV_SIZE_CHECK( EntryAnchor );
if ( EntryAnchor )
- otv_Anchor_validate( table + EntryAnchor, valid );
+ otv_Anchor_validate( table + EntryAnchor, otvalid );
OTV_SIZE_CHECK( ExitAnchor );
if ( ExitAnchor )
- otv_Anchor_validate( table + ExitAnchor, valid );
+ otv_Anchor_validate( table + ExitAnchor, otvalid );
}
}
break;
@@ -647,11 +647,11 @@
/* UNDOCUMENTED (in OpenType 1.5): */
/* BaseRecord tables can contain NULL pointers. */
- /* sets valid->extra2 (1) */
+ /* sets otvalid->extra2 (1) */
static void
otv_MarkBasePos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -667,9 +667,9 @@
switch ( PosFormat )
{
case 1:
- valid->extra2 = 1;
+ otvalid->extra2 = 1;
OTV_NEST2( MarkBasePosFormat1, BaseArray );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -688,11 +688,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra2 (1) */
+ /* sets otvalid->extra2 (1) */
static void
otv_MarkLigPos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -708,9 +708,9 @@
switch ( PosFormat )
{
case 1:
- valid->extra2 = 1;
+ otvalid->extra2 = 1;
OTV_NEST3( MarkLigPosFormat1, LigatureArray, LigatureAttach );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -729,11 +729,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra2 (0) */
+ /* sets otvalid->extra2 (0) */
static void
otv_MarkMarkPos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -749,9 +749,9 @@
switch ( PosFormat )
{
case 1:
- valid->extra2 = 0;
+ otvalid->extra2 = 0;
OTV_NEST2( MarkMarkPosFormat1, Mark2Array );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -770,11 +770,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra1 (lookup count) */
+ /* sets otvalid->extra1 (lookup count) */
static void
otv_ContextPos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -794,9 +794,9 @@
/* context rules since even invalid glyph indices/classes return */
/* meaningful results */
- valid->extra1 = valid->lookup_count;
+ otvalid->extra1 = otvalid->lookup_count;
OTV_NEST3( ContextPosFormat1, PosRuleSet, PosRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 2:
@@ -805,12 +805,12 @@
/* meaningful results */
OTV_NEST3( ContextPosFormat2, PosClassSet, PosClassRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 3:
OTV_NEST1( ContextPosFormat3 );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -829,11 +829,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra1 (lookup count) */
+ /* sets otvalid->extra1 (lookup count) */
static void
otv_ChainContextPos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -853,10 +853,10 @@
/* context rules since even invalid glyph indices/classes return */
/* meaningful results */
- valid->extra1 = valid->lookup_count;
+ otvalid->extra1 = otvalid->lookup_count;
OTV_NEST3( ChainContextPosFormat1,
ChainPosRuleSet, ChainPosRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 2:
@@ -866,12 +866,12 @@
OTV_NEST3( ChainContextPosFormat2,
ChainPosClassSet, ChainPosClassRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 3:
OTV_NEST1( ChainContextPosFormat3 );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -890,11 +890,11 @@
/*************************************************************************/
/*************************************************************************/
- /* uses valid->type_funcs */
+ /* uses otvalid->type_funcs */
static void
otv_ExtensionPos_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt PosFormat;
@@ -923,8 +923,8 @@
if ( ExtensionLookupType == 0 || ExtensionLookupType >= 9 )
FT_INVALID_DATA;
- validate = valid->type_funcs[ExtensionLookupType - 1];
- validate( table + ExtensionOffset, valid );
+ validate = otvalid->type_funcs[ExtensionLookupType - 1];
+ validate( table + ExtensionOffset, otvalid );
}
break;
@@ -950,17 +950,17 @@
};
- /* sets valid->type_count */
- /* sets valid->type_funcs */
+ /* sets otvalid->type_count */
+ /* sets otvalid->type_funcs */
FT_LOCAL_DEF( void )
otv_GPOS_subtable_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
- valid->type_count = 9;
- valid->type_funcs = (OTV_Validate_Func*)otv_gpos_validate_funcs;
+ otvalid->type_count = 9;
+ otvalid->type_funcs = (OTV_Validate_Func*)otv_gpos_validate_funcs;
- otv_Lookup_validate( table, valid );
+ otv_Lookup_validate( table, otvalid );
}
@@ -972,7 +972,7 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->glyph_count */
+ /* sets otvalid->glyph_count */
FT_LOCAL_DEF( void )
otv_GPOS_validate( FT_Bytes table,
@@ -980,12 +980,12 @@
FT_Validator ftvalid )
{
OTV_ValidatorRec validrec;
- OTV_Validator valid = &validrec;
+ OTV_Validator otvalid = &validrec;
FT_Bytes p = table;
FT_UInt ScriptList, FeatureList, LookupList;
- valid->root = ftvalid;
+ otvalid->root = ftvalid;
FT_TRACE3(( "validating GPOS table\n" ));
OTV_INIT;
@@ -999,16 +999,16 @@
FeatureList = FT_NEXT_USHORT( p );
LookupList = FT_NEXT_USHORT( p );
- valid->type_count = 9;
- valid->type_funcs = (OTV_Validate_Func*)otv_gpos_validate_funcs;
- valid->glyph_count = glyph_count;
+ otvalid->type_count = 9;
+ otvalid->type_funcs = (OTV_Validate_Func*)otv_gpos_validate_funcs;
+ otvalid->glyph_count = glyph_count;
otv_LookupList_validate( table + LookupList,
- valid );
+ otvalid );
otv_FeatureList_validate( table + FeatureList, table + LookupList,
- valid );
+ otvalid );
otv_ScriptList_validate( table + ScriptList, table + FeatureList,
- valid );
+ otvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvgsub.c b/src/3rdparty/freetype/src/otvalid/otvgsub.c
index ed499d1e92..024b8ca68c 100644
--- a/src/3rdparty/freetype/src/otvalid/otvgsub.c
+++ b/src/3rdparty/freetype/src/otvalid/otvgsub.c
@@ -38,11 +38,11 @@
/*************************************************************************/
/*************************************************************************/
- /* uses valid->glyph_count */
+ /* uses otvalid->glyph_count */
static void
otv_SingleSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt SubstFormat;
@@ -68,14 +68,14 @@
Coverage = table + FT_NEXT_USHORT( p );
DeltaGlyphID = FT_NEXT_SHORT( p );
- otv_Coverage_validate( Coverage, valid, -1 );
+ otv_Coverage_validate( Coverage, otvalid, -1 );
idx = otv_Coverage_get_first( Coverage ) + DeltaGlyphID;
if ( idx < 0 )
FT_INVALID_DATA;
idx = otv_Coverage_get_last( Coverage ) + DeltaGlyphID;
- if ( (FT_UInt)idx >= valid->glyph_count )
+ if ( (FT_UInt)idx >= otvalid->glyph_count )
FT_INVALID_DATA;
}
break;
@@ -91,13 +91,13 @@
OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
- otv_Coverage_validate( table + Coverage, valid, GlyphCount );
+ otv_Coverage_validate( table + Coverage, otvalid, GlyphCount );
OTV_LIMIT_CHECK( GlyphCount * 2 );
/* Substitute */
for ( ; GlyphCount > 0; GlyphCount-- )
- if ( FT_NEXT_USHORT( p ) >= valid->glyph_count )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->glyph_count )
FT_INVALID_GLYPH_ID;
}
break;
@@ -118,11 +118,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra1 (glyph count) */
+ /* sets otvalid->extra1 (glyph count) */
static void
otv_MultipleSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt SubstFormat;
@@ -138,9 +138,9 @@
switch ( SubstFormat )
{
case 1:
- valid->extra1 = valid->glyph_count;
+ otvalid->extra1 = otvalid->glyph_count;
OTV_NEST2( MultipleSubstFormat1, Sequence );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -159,11 +159,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra1 (glyph count) */
+ /* sets otvalid->extra1 (glyph count) */
static void
otv_AlternateSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt SubstFormat;
@@ -179,9 +179,9 @@
switch ( SubstFormat )
{
case 1:
- valid->extra1 = valid->glyph_count;
+ otvalid->extra1 = otvalid->glyph_count;
OTV_NEST2( AlternateSubstFormat1, AlternateSet );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -202,11 +202,11 @@
#define LigatureFunc otv_Ligature_validate
- /* uses valid->glyph_count */
+ /* uses otvalid->glyph_count */
static void
otv_Ligature_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt LigatureGlyph, CompCount;
@@ -216,7 +216,7 @@
OTV_LIMIT_CHECK( 4 );
LigatureGlyph = FT_NEXT_USHORT( p );
- if ( LigatureGlyph >= valid->glyph_count )
+ if ( LigatureGlyph >= otvalid->glyph_count )
FT_INVALID_DATA;
CompCount = FT_NEXT_USHORT( p );
@@ -238,7 +238,7 @@
static void
otv_LigatureSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt SubstFormat;
@@ -255,7 +255,7 @@
{
case 1:
OTV_NEST3( LigatureSubstFormat1, LigatureSet, Ligature );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -274,11 +274,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra1 (lookup count) */
+ /* sets otvalid->extra1 (lookup count) */
static void
otv_ContextSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt SubstFormat;
@@ -298,9 +298,9 @@
/* context rules since even invalid glyph indices/classes return */
/* meaningful results */
- valid->extra1 = valid->lookup_count;
+ otvalid->extra1 = otvalid->lookup_count;
OTV_NEST3( ContextSubstFormat1, SubRuleSet, SubRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 2:
@@ -309,12 +309,12 @@
/* meaningful results */
OTV_NEST3( ContextSubstFormat2, SubClassSet, SubClassRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 3:
OTV_NEST1( ContextSubstFormat3 );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -333,11 +333,11 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->extra1 (lookup count) */
+ /* sets otvalid->extra1 (lookup count) */
static void
otv_ChainContextSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt SubstFormat;
@@ -357,10 +357,10 @@
/* context rules since even invalid glyph indices/classes return */
/* meaningful results */
- valid->extra1 = valid->lookup_count;
+ otvalid->extra1 = otvalid->lookup_count;
OTV_NEST3( ChainContextSubstFormat1,
ChainSubRuleSet, ChainSubRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 2:
@@ -370,12 +370,12 @@
OTV_NEST3( ChainContextSubstFormat2,
ChainSubClassSet, ChainSubClassRule );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
case 3:
OTV_NEST1( ChainContextSubstFormat3 );
- OTV_RUN( table, valid );
+ OTV_RUN( table, otvalid );
break;
default:
@@ -394,11 +394,11 @@
/*************************************************************************/
/*************************************************************************/
- /* uses valid->type_funcs */
+ /* uses otvalid->type_funcs */
static void
otv_ExtensionSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt SubstFormat;
@@ -429,8 +429,8 @@
ExtensionLookupType > 8 )
FT_INVALID_DATA;
- validate = valid->type_funcs[ExtensionLookupType - 1];
- validate( table + ExtensionOffset, valid );
+ validate = otvalid->type_funcs[ExtensionLookupType - 1];
+ validate( table + ExtensionOffset, otvalid );
}
break;
@@ -450,11 +450,11 @@
/*************************************************************************/
/*************************************************************************/
- /* uses valid->glyph_count */
+ /* uses otvalid->glyph_count */
static void
otv_ReverseChainSingleSubst_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table, Coverage;
FT_UInt SubstFormat;
@@ -477,12 +477,12 @@
OTV_TRACE(( " (BacktrackGlyphCount = %d)\n", BacktrackGlyphCount ));
- otv_Coverage_validate( Coverage, valid, -1 );
+ otv_Coverage_validate( Coverage, otvalid, -1 );
OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 );
for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- )
- otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+ otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
LookaheadGlyphCount = FT_NEXT_USHORT( p );
@@ -491,7 +491,7 @@
OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 );
for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- )
- otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+ otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
GlyphCount = FT_NEXT_USHORT( p );
@@ -504,7 +504,7 @@
/* Substitute */
for ( ; GlyphCount > 0; GlyphCount-- )
- if ( FT_NEXT_USHORT( p ) >= valid->glyph_count )
+ if ( FT_NEXT_USHORT( p ) >= otvalid->glyph_count )
FT_INVALID_DATA;
break;
@@ -538,22 +538,22 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->type_count */
- /* sets valid->type_funcs */
- /* sets valid->glyph_count */
+ /* sets otvalid->type_count */
+ /* sets otvalid->type_funcs */
+ /* sets otvalid->glyph_count */
FT_LOCAL_DEF( void )
otv_GSUB_validate( FT_Bytes table,
FT_UInt glyph_count,
FT_Validator ftvalid )
{
- OTV_ValidatorRec validrec;
- OTV_Validator valid = &validrec;
- FT_Bytes p = table;
+ OTV_ValidatorRec otvalidrec;
+ OTV_Validator otvalid = &otvalidrec;
+ FT_Bytes p = table;
FT_UInt ScriptList, FeatureList, LookupList;
- valid->root = ftvalid;
+ otvalid->root = ftvalid;
FT_TRACE3(( "validating GSUB table\n" ));
OTV_INIT;
@@ -567,16 +567,16 @@
FeatureList = FT_NEXT_USHORT( p );
LookupList = FT_NEXT_USHORT( p );
- valid->type_count = 8;
- valid->type_funcs = (OTV_Validate_Func*)otv_gsub_validate_funcs;
- valid->glyph_count = glyph_count;
+ otvalid->type_count = 8;
+ otvalid->type_funcs = (OTV_Validate_Func*)otv_gsub_validate_funcs;
+ otvalid->glyph_count = glyph_count;
otv_LookupList_validate( table + LookupList,
- valid );
+ otvalid );
otv_FeatureList_validate( table + FeatureList, table + LookupList,
- valid );
+ otvalid );
otv_ScriptList_validate( table + ScriptList, table + FeatureList,
- valid );
+ otvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvjstf.c b/src/3rdparty/freetype/src/otvalid/otvjstf.c
index a616a23432..f273be8bbc 100644
--- a/src/3rdparty/freetype/src/otvalid/otvjstf.c
+++ b/src/3rdparty/freetype/src/otvalid/otvjstf.c
@@ -34,13 +34,13 @@
#define JstfPriorityFunc otv_JstfPriority_validate
#define JstfLookupFunc otv_GPOS_subtable_validate
- /* uses valid->extra1 (GSUB lookup count) */
- /* uses valid->extra2 (GPOS lookup count) */
- /* sets valid->extra1 (counter) */
+ /* uses otvalid->extra1 (GSUB lookup count) */
+ /* uses otvalid->extra2 (GPOS lookup count) */
+ /* sets otvalid->extra1 (counter) */
static void
otv_JstfPriority_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt table_size;
@@ -63,34 +63,34 @@
OTV_LIMIT_CHECK( 20 );
- gsub_lookup_count = valid->extra1;
- gpos_lookup_count = valid->extra2;
+ gsub_lookup_count = otvalid->extra1;
+ gpos_lookup_count = otvalid->extra2;
table_size = 20;
- valid->extra1 = gsub_lookup_count;
+ otvalid->extra1 = gsub_lookup_count;
OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB );
OTV_SIZE_CHECK( ShrinkageEnableGSUB );
if ( ShrinkageEnableGSUB )
- otv_x_ux( table + ShrinkageEnableGSUB, valid );
+ otv_x_ux( table + ShrinkageEnableGSUB, otvalid );
OTV_OPTIONAL_OFFSET( ShrinkageDisableGSUB );
OTV_SIZE_CHECK( ShrinkageDisableGSUB );
if ( ShrinkageDisableGSUB )
- otv_x_ux( table + ShrinkageDisableGSUB, valid );
+ otv_x_ux( table + ShrinkageDisableGSUB, otvalid );
- valid->extra1 = gpos_lookup_count;
+ otvalid->extra1 = gpos_lookup_count;
OTV_OPTIONAL_OFFSET( ShrinkageEnableGPOS );
OTV_SIZE_CHECK( ShrinkageEnableGPOS );
if ( ShrinkageEnableGPOS )
- otv_x_ux( table + ShrinkageEnableGPOS, valid );
+ otv_x_ux( table + ShrinkageEnableGPOS, otvalid );
OTV_OPTIONAL_OFFSET( ShrinkageDisableGPOS );
OTV_SIZE_CHECK( ShrinkageDisableGPOS );
if ( ShrinkageDisableGPOS )
- otv_x_ux( table + ShrinkageDisableGPOS, valid );
+ otv_x_ux( table + ShrinkageDisableGPOS, otvalid );
OTV_OPTIONAL_OFFSET( ShrinkageJstfMax );
OTV_SIZE_CHECK( ShrinkageJstfMax );
@@ -98,32 +98,32 @@
{
/* XXX: check lookup types? */
OTV_NEST2( JstfMax, JstfLookup );
- OTV_RUN( table + ShrinkageJstfMax, valid );
+ OTV_RUN( table + ShrinkageJstfMax, otvalid );
}
- valid->extra1 = gsub_lookup_count;
+ otvalid->extra1 = gsub_lookup_count;
OTV_OPTIONAL_OFFSET( ExtensionEnableGSUB );
OTV_SIZE_CHECK( ExtensionEnableGSUB );
if ( ExtensionEnableGSUB )
- otv_x_ux( table + ExtensionEnableGSUB, valid );
+ otv_x_ux( table + ExtensionEnableGSUB, otvalid );
OTV_OPTIONAL_OFFSET( ExtensionDisableGSUB );
OTV_SIZE_CHECK( ExtensionDisableGSUB );
if ( ExtensionDisableGSUB )
- otv_x_ux( table + ExtensionDisableGSUB, valid );
+ otv_x_ux( table + ExtensionDisableGSUB, otvalid );
- valid->extra1 = gpos_lookup_count;
+ otvalid->extra1 = gpos_lookup_count;
OTV_OPTIONAL_OFFSET( ExtensionEnableGPOS );
OTV_SIZE_CHECK( ExtensionEnableGPOS );
if ( ExtensionEnableGPOS )
- otv_x_ux( table + ExtensionEnableGPOS, valid );
+ otv_x_ux( table + ExtensionEnableGPOS, otvalid );
OTV_OPTIONAL_OFFSET( ExtensionDisableGPOS );
OTV_SIZE_CHECK( ExtensionDisableGPOS );
if ( ExtensionDisableGPOS )
- otv_x_ux( table + ExtensionDisableGPOS, valid );
+ otv_x_ux( table + ExtensionDisableGPOS, otvalid );
OTV_OPTIONAL_OFFSET( ExtensionJstfMax );
OTV_SIZE_CHECK( ExtensionJstfMax );
@@ -131,22 +131,22 @@
{
/* XXX: check lookup types? */
OTV_NEST2( JstfMax, JstfLookup );
- OTV_RUN( table + ExtensionJstfMax, valid );
+ OTV_RUN( table + ExtensionJstfMax, otvalid );
}
- valid->extra1 = gsub_lookup_count;
- valid->extra2 = gpos_lookup_count;
+ otvalid->extra1 = gsub_lookup_count;
+ otvalid->extra2 = gpos_lookup_count;
OTV_EXIT;
}
- /* sets valid->extra (glyph count) */
- /* sets valid->func1 (otv_JstfPriority_validate) */
+ /* sets otvalid->extra (glyph count) */
+ /* sets otvalid->func1 (otv_JstfPriority_validate) */
static void
otv_JstfScript_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt table_size;
@@ -170,16 +170,16 @@
OTV_SIZE_CHECK( ExtGlyph );
if ( ExtGlyph )
{
- valid->extra1 = valid->glyph_count;
+ otvalid->extra1 = otvalid->glyph_count;
OTV_NEST1( ExtenderGlyph );
- OTV_RUN( table + ExtGlyph, valid );
+ OTV_RUN( table + ExtGlyph, otvalid );
}
OTV_SIZE_CHECK( DefJstfLangSys );
if ( DefJstfLangSys )
{
OTV_NEST2( JstfLangSys, JstfPriority );
- OTV_RUN( table + DefJstfLangSys, valid );
+ OTV_RUN( table + DefJstfLangSys, otvalid );
}
OTV_LIMIT_CHECK( 6 * JstfLangSysCount );
@@ -190,16 +190,16 @@
{
p += 4; /* skip JstfLangSysTag */
- OTV_RUN( table + FT_NEXT_USHORT( p ), valid );
+ OTV_RUN( table + FT_NEXT_USHORT( p ), otvalid );
}
OTV_EXIT;
}
- /* sets valid->extra1 (GSUB lookup count) */
- /* sets valid->extra2 (GPOS lookup count) */
- /* sets valid->glyph_count */
+ /* sets otvalid->extra1 (GSUB lookup count) */
+ /* sets otvalid->extra2 (GPOS lookup count) */
+ /* sets otvalid->glyph_count */
FT_LOCAL_DEF( void )
otv_JSTF_validate( FT_Bytes table,
@@ -208,13 +208,14 @@
FT_UInt glyph_count,
FT_Validator ftvalid )
{
- OTV_ValidatorRec validrec;
- OTV_Validator valid = &validrec;
+ OTV_ValidatorRec otvalidrec;
+ OTV_Validator otvalid = &otvalidrec;
FT_Bytes p = table;
FT_UInt JstfScriptCount;
- valid->root = ftvalid;
+ otvalid->root = ftvalid;
+
FT_TRACE3(( "validating JSTF table\n" ));
OTV_INIT;
@@ -231,16 +232,16 @@
OTV_LIMIT_CHECK( JstfScriptCount * 6 );
if ( gsub )
- valid->extra1 = otv_GSUBGPOS_get_Lookup_count( gsub );
+ otvalid->extra1 = otv_GSUBGPOS_get_Lookup_count( gsub );
else
- valid->extra1 = 0;
+ otvalid->extra1 = 0;
if ( gpos )
- valid->extra2 = otv_GSUBGPOS_get_Lookup_count( gpos );
+ otvalid->extra2 = otv_GSUBGPOS_get_Lookup_count( gpos );
else
- valid->extra2 = 0;
+ otvalid->extra2 = 0;
- valid->glyph_count = glyph_count;
+ otvalid->glyph_count = glyph_count;
/* JstfScriptRecord */
for ( ; JstfScriptCount > 0; JstfScriptCount-- )
@@ -248,7 +249,7 @@
p += 4; /* skip JstfScriptTag */
/* JstfScript */
- otv_JstfScript_validate( table + FT_NEXT_USHORT( p ), valid );
+ otv_JstfScript_validate( table + FT_NEXT_USHORT( p ), otvalid );
}
FT_TRACE4(( "\n" ));
diff --git a/src/3rdparty/freetype/src/otvalid/otvmath.c b/src/3rdparty/freetype/src/otvalid/otvmath.c
index 50ed10cf28..d1791f8deb 100644
--- a/src/3rdparty/freetype/src/otvalid/otvmath.c
+++ b/src/3rdparty/freetype/src/otvalid/otvmath.c
@@ -44,7 +44,7 @@
static void
otv_MathConstants_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt i;
@@ -66,7 +66,7 @@
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
- otv_Device_validate( table + DeviceTableOffset, valid );
+ otv_Device_validate( table + DeviceTableOffset, otvalid );
}
OTV_EXIT;
@@ -84,7 +84,7 @@
static void
otv_MathItalicsCorrectionInfo_validate( FT_Bytes table,
- OTV_Validator valid,
+ OTV_Validator otvalid,
FT_Int isItalic )
{
FT_Bytes p = table;
@@ -108,7 +108,7 @@
table_size = 4 + 4 * cnt;
OTV_SIZE_CHECK( Coverage );
- otv_Coverage_validate( table + Coverage, valid, cnt );
+ otv_Coverage_validate( table + Coverage, otvalid, cnt );
for ( i = 0; i < cnt; ++i )
{
@@ -116,7 +116,7 @@
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
- otv_Device_validate( table + DeviceTableOffset, valid );
+ otv_Device_validate( table + DeviceTableOffset, otvalid );
}
OTV_EXIT;
@@ -133,7 +133,7 @@
static void
otv_MathKern_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt i, cnt, table_size;
@@ -157,7 +157,7 @@
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
- otv_Device_validate( table + DeviceTableOffset, valid );
+ otv_Device_validate( table + DeviceTableOffset, otvalid );
}
/* One more Kerning value */
@@ -167,7 +167,7 @@
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
- otv_Device_validate( table + DeviceTableOffset, valid );
+ otv_Device_validate( table + DeviceTableOffset, otvalid );
}
OTV_EXIT;
@@ -176,7 +176,7 @@
static void
otv_MathKernInfo_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt i, j, cnt, table_size;
@@ -196,7 +196,7 @@
table_size = 4 + 8 * cnt;
OTV_SIZE_CHECK( Coverage );
- otv_Coverage_validate( table + Coverage, valid, cnt );
+ otv_Coverage_validate( table + Coverage, otvalid, cnt );
for ( i = 0; i < cnt; ++i )
{
@@ -205,7 +205,7 @@
OTV_OPTIONAL_OFFSET( MKRecordOffset );
OTV_SIZE_CHECK( MKRecordOffset );
if ( MKRecordOffset )
- otv_MathKern_validate( table + MKRecordOffset, valid );
+ otv_MathKern_validate( table + MKRecordOffset, otvalid );
}
}
@@ -223,7 +223,7 @@
static void
otv_MathGlyphInfo_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt MathItalicsCorrectionInfo, MathTopAccentAttachment;
@@ -241,21 +241,22 @@
if ( MathItalicsCorrectionInfo )
otv_MathItalicsCorrectionInfo_validate(
- table + MathItalicsCorrectionInfo, valid, TRUE );
+ table + MathItalicsCorrectionInfo, otvalid, TRUE );
/* Italic correction and Top Accent Attachment have the same format */
if ( MathTopAccentAttachment )
otv_MathItalicsCorrectionInfo_validate(
- table + MathTopAccentAttachment, valid, FALSE );
+ table + MathTopAccentAttachment, otvalid, FALSE );
- if ( ExtendedShapeCoverage ) {
+ if ( ExtendedShapeCoverage )
+ {
OTV_NAME_ENTER( "ExtendedShapeCoverage" );
- otv_Coverage_validate( table + ExtendedShapeCoverage, valid, -1 );
+ otv_Coverage_validate( table + ExtendedShapeCoverage, otvalid, -1 );
OTV_EXIT;
}
if ( MathKernInfo )
- otv_MathKernInfo_validate( table + MathKernInfo, valid );
+ otv_MathKernInfo_validate( table + MathKernInfo, otvalid );
OTV_EXIT;
}
@@ -271,7 +272,7 @@
static void
otv_GlyphAssembly_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt pcnt, table_size;
@@ -293,7 +294,7 @@
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
- otv_Device_validate( table + DeviceTableOffset, valid );
+ otv_Device_validate( table + DeviceTableOffset, otvalid );
for ( i = 0; i < pcnt; ++i )
{
@@ -301,7 +302,7 @@
gid = FT_NEXT_USHORT( p );
- if ( gid >= valid->glyph_count )
+ if ( gid >= otvalid->glyph_count )
FT_INVALID_GLYPH_ID;
p += 2*4; /* skip the Start, End, Full, and Flags fields */
}
@@ -312,7 +313,7 @@
static void
otv_MathGlyphConstruction_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt vcnt, table_size;
@@ -337,14 +338,14 @@
gid = FT_NEXT_USHORT( p );
- if ( gid >= valid->glyph_count )
+ if ( gid >= otvalid->glyph_count )
FT_INVALID_GLYPH_ID;
p += 2; /* skip the size */
}
OTV_SIZE_CHECK( GlyphAssembly );
if ( GlyphAssembly )
- otv_GlyphAssembly_validate( table+GlyphAssembly, valid );
+ otv_GlyphAssembly_validate( table+GlyphAssembly, otvalid );
/* OTV_EXIT; */
}
@@ -352,7 +353,7 @@
static void
otv_MathVariants_validate( FT_Bytes table,
- OTV_Validator valid )
+ OTV_Validator otvalid )
{
FT_Bytes p = table;
FT_UInt vcnt, hcnt, i, table_size;
@@ -377,24 +378,24 @@
OTV_SIZE_CHECK( VCoverage );
if ( VCoverage )
- otv_Coverage_validate( table + VCoverage, valid, vcnt );
+ otv_Coverage_validate( table + VCoverage, otvalid, vcnt );
OTV_SIZE_CHECK( HCoverage );
if ( HCoverage )
- otv_Coverage_validate( table + HCoverage, valid, hcnt );
+ otv_Coverage_validate( table + HCoverage, otvalid, hcnt );
for ( i = 0; i < vcnt; ++i )
{
OTV_OPTIONAL_OFFSET( Offset );
OTV_SIZE_CHECK( Offset );
- otv_MathGlyphConstruction_validate( table + Offset, valid );
+ otv_MathGlyphConstruction_validate( table + Offset, otvalid );
}
for ( i = 0; i < hcnt; ++i )
{
OTV_OPTIONAL_OFFSET( Offset );
OTV_SIZE_CHECK( Offset );
- otv_MathGlyphConstruction_validate( table + Offset, valid );
+ otv_MathGlyphConstruction_validate( table + Offset, otvalid );
}
OTV_EXIT;
@@ -409,20 +410,20 @@
/*************************************************************************/
/*************************************************************************/
- /* sets valid->glyph_count */
+ /* sets otvalid->glyph_count */
FT_LOCAL_DEF( void )
otv_MATH_validate( FT_Bytes table,
FT_UInt glyph_count,
FT_Validator ftvalid )
{
- OTV_ValidatorRec validrec;
- OTV_Validator valid = &validrec;
- FT_Bytes p = table;
+ OTV_ValidatorRec otvalidrec;
+ OTV_Validator otvalid = &otvalidrec;
+ FT_Bytes p = table;
FT_UInt MathConstants, MathGlyphInfo, MathVariants;
- valid->root = ftvalid;
+ otvalid->root = ftvalid;
FT_TRACE3(( "validating MATH table\n" ));
OTV_INIT;
@@ -436,14 +437,14 @@
MathGlyphInfo = FT_NEXT_USHORT( p );
MathVariants = FT_NEXT_USHORT( p );
- valid->glyph_count = glyph_count;
+ otvalid->glyph_count = glyph_count;
otv_MathConstants_validate( table + MathConstants,
- valid );
+ otvalid );
otv_MathGlyphInfo_validate( table + MathGlyphInfo,
- valid );
+ otvalid );
otv_MathVariants_validate ( table + MathVariants,
- valid );
+ otvalid );
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvmod.c b/src/3rdparty/freetype/src/otvalid/otvmod.c
index 3248564560..37c6e869dd 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, 2005, 2006, 2007, 2008 by */
+/* Copyright 2004-2008, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -49,8 +49,8 @@
error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len );
- if ( error == OTV_Err_Table_Missing )
- return OTV_Err_Ok;
+ if ( FT_ERR_EQ( error, Table_Missing ) )
+ return FT_Err_Ok;
if ( error )
goto Exit;
@@ -73,7 +73,7 @@
FT_Bytes *ot_gsub,
FT_Bytes *ot_jstf )
{
- FT_Error error = OTV_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* volatile base;
FT_Byte* volatile gdef;
FT_Byte* volatile gpos;
@@ -214,7 +214,8 @@
*ot_jstf = (FT_Bytes)jstf;
Exit:
- if ( error ) {
+ if ( error )
+ {
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -224,6 +225,7 @@
FT_FREE( gsub );
FT_FREE( jstf );
}
+
{
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -264,7 +266,7 @@
const FT_Module_Class otv_module_class =
{
0,
- sizeof( FT_ModuleRec ),
+ sizeof ( FT_ModuleRec ),
"otvalid",
0x10000L,
0x20000L,
diff --git a/src/3rdparty/freetype/src/otvalid/otvmod.h b/src/3rdparty/freetype/src/otvalid/otvmod.h
index 573b2a0c4b..f7e1550787 100644
--- a/src/3rdparty/freetype/src/otvalid/otvmod.h
+++ b/src/3rdparty/freetype/src/otvalid/otvmod.h
@@ -29,7 +29,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Module_Class ) otv_module_class;
diff --git a/src/3rdparty/freetype/src/pcf/README b/src/3rdparty/freetype/src/pcf/README
index cc1480b2d2..10eff15fbe 100644
--- a/src/3rdparty/freetype/src/pcf/README
+++ b/src/3rdparty/freetype/src/pcf/README
@@ -31,29 +31,11 @@ on linux/alpha.
Encodings
*********
-The variety of encodings that accompanies pcf fonts appears to encompass the
-small set defined in freetype.h. On the other hand, each pcf font defines
-two properties that specify encoding and registry.
+Use `FT_Get_BDF_Charset_ID' to access the encoding and registry.
-I decided to make these two properties directly accessible, leaving to the
-client application the work of interpreting them. For instance:
-
- #include "pcftypes.h" /* include/freetype/internal/pcftypes.h */
-
- FT_Face face;
- PCF_Public_Face pcfface;
-
- FT_New_Face( library,..., &face );
-
- pcfface = (PCF_Public_Face)face;
-
- if ((pcfface->charset_registry == "ISO10646") &&
- (pcfface->charset_encoding) == "1")) [..]
-
-Thus the driver always export `ft_encoding_none' as
-face->charmap.encoding. FT_Get_Char_Index() behavior is unmodified, that
-is, it converts the ULong value given as argument into the corresponding
-glyph number.
+The driver always exports `ft_encoding_none' as face->charmap.encoding.
+FT_Get_Char_Index() behavior is unmodified, that is, it converts the ULong
+value given as argument into the corresponding glyph number.
Known problems
diff --git a/src/3rdparty/freetype/src/pcf/pcf.h b/src/3rdparty/freetype/src/pcf/pcf.h
index 1cd56c13a4..af0ffc3378 100644
--- a/src/3rdparty/freetype/src/pcf/pcf.h
+++ b/src/3rdparty/freetype/src/pcf/pcf.h
@@ -2,7 +2,7 @@
FreeType font driver for pcf fonts
- Copyright (C) 2000, 2001, 2002, 2003, 2006 by
+ Copyright (C) 2000, 2001, 2002, 2003, 2006, 2010 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -136,8 +136,8 @@ FT_BEGIN_HEADER
{
FT_FaceRec root;
- FT_StreamRec gzip_stream;
- FT_Stream gzip_source;
+ FT_StreamRec comp_stream;
+ FT_Stream comp_source;
char* charset_encoding;
char* charset_registry;
diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.c b/src/3rdparty/freetype/src/pcf/pcfdrivr.c
index b34e542aeb..96f6912ba9 100644
--- a/src/3rdparty/freetype/src/pcf/pcfdrivr.c
+++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.c
@@ -2,7 +2,7 @@
FreeType font driver for pcf files
- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by
+ Copyright (C) 2000-2004, 2006-2011, 2013, 2014 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -32,8 +32,10 @@ THE SOFTWARE.
#include FT_INTERNAL_OBJECTS_H
#include FT_GZIP_H
#include FT_LZW_H
+#include FT_BZIP2_H
#include FT_ERRORS_H
#include FT_BDF_H
+#include FT_TRUETYPE_IDS_H
#include "pcf.h"
#include "pcfdrivr.h"
@@ -81,7 +83,7 @@ THE SOFTWARE.
cmap->num_encodings = (FT_UInt)face->nencodings;
cmap->encodings = face->encodings;
- return PCF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -187,7 +189,7 @@ THE SOFTWARE.
}
- FT_CALLBACK_TABLE_DEF
+ static
const FT_CMap_ClassRec pcf_cmap_class =
{
sizeof ( PCF_CMapRec ),
@@ -216,24 +218,24 @@ THE SOFTWARE.
FT_FREE( face->metrics );
/* free properties */
+ if ( face->properties )
{
- PCF_Property prop;
- FT_Int i;
+ FT_Int i;
- if ( face->properties )
+ for ( i = 0; i < face->nprops; i++ )
{
- for ( i = 0; i < face->nprops; i++ )
- {
- prop = &face->properties[i];
+ PCF_Property prop = &face->properties[i];
- if ( prop ) {
- FT_FREE( prop->name );
- if ( prop->isString )
- FT_FREE( prop->value.atom );
- }
+
+ if ( prop )
+ {
+ FT_FREE( prop->name );
+ if ( prop->isString )
+ FT_FREE( prop->value.atom );
}
}
+
FT_FREE( face->properties );
}
@@ -244,13 +246,11 @@ THE SOFTWARE.
FT_FREE( face->charset_encoding );
FT_FREE( face->charset_registry );
- FT_TRACE4(( "PCF_Face_Done: done face\n" ));
-
- /* close gzip/LZW stream if any */
- if ( pcfface->stream == &face->gzip_stream )
+ /* close compressed stream if any */
+ if ( pcfface->stream == &face->comp_stream )
{
- FT_Stream_Close( &face->gzip_stream );
- pcfface->stream = face->gzip_source;
+ FT_Stream_Close( &face->comp_stream );
+ pcfface->stream = face->comp_source;
}
}
@@ -263,20 +263,22 @@ THE SOFTWARE.
FT_Parameter* params )
{
PCF_Face face = (PCF_Face)pcfface;
- FT_Error error = PCF_Err_Ok;
+ FT_Error error;
FT_UNUSED( num_params );
FT_UNUSED( params );
- FT_UNUSED( face_index );
+ FT_TRACE2(( "PCF driver\n" ));
+
error = pcf_load_font( stream, face );
if ( error )
{
PCF_Face_Done( pcfface );
-#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \
- defined( FT_CONFIG_OPTION_USE_LZW )
+#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \
+ defined( FT_CONFIG_OPTION_USE_LZW ) || \
+ defined( FT_CONFIG_OPTION_USE_BZIP2 )
#ifdef FT_CONFIG_OPTION_USE_ZLIB
{
@@ -284,8 +286,8 @@ THE SOFTWARE.
/* this didn't work, try gzip support! */
- error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream );
- if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature )
+ error2 = FT_Stream_OpenGzip( &face->comp_stream, stream );
+ if ( FT_ERR_EQ( error2, Unimplemented_Feature ) )
goto Fail;
error = error2;
@@ -299,19 +301,34 @@ THE SOFTWARE.
/* this didn't work, try LZW support! */
- error3 = FT_Stream_OpenLZW( &face->gzip_stream, stream );
- if ( FT_ERROR_BASE( error3 ) == FT_Err_Unimplemented_Feature )
+ error3 = FT_Stream_OpenLZW( &face->comp_stream, stream );
+ if ( FT_ERR_EQ( error3, Unimplemented_Feature ) )
goto Fail;
error = error3;
}
#endif /* FT_CONFIG_OPTION_USE_LZW */
+#ifdef FT_CONFIG_OPTION_USE_BZIP2
+ if ( error )
+ {
+ FT_Error error4;
+
+
+ /* this didn't work, try Bzip2 support! */
+ error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream );
+ if ( FT_ERR_EQ( error4, Unimplemented_Feature ) )
+ goto Fail;
+
+ error = error4;
+ }
+#endif /* FT_CONFIG_OPTION_USE_BZIP2 */
+
if ( error )
goto Fail;
- face->gzip_source = stream;
- pcfface->stream = &face->gzip_stream;
+ face->comp_source = stream;
+ pcfface->stream = &face->comp_stream;
stream = pcfface->stream;
@@ -319,13 +336,27 @@ THE SOFTWARE.
if ( error )
goto Fail;
-#else /* !(FT_CONFIG_OPTION_USE_ZLIB || FT_CONFIG_OPTION_USE_LZW) */
+#else /* !(FT_CONFIG_OPTION_USE_ZLIB ||
+ FT_CONFIG_OPTION_USE_LZW ||
+ FT_CONFIG_OPTION_USE_BZIP2) */
goto Fail;
#endif
}
+ /* PCF could not have multiple face in 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
+ * opened by the specified driver.
+ */
+ if ( face_index > 0 ) {
+ FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
+ PCF_Face_Done( pcfface );
+ return FT_THROW( Invalid_Argument );
+ }
+
/* set up charmap */
{
FT_String *charset_registry = face->charset_registry;
@@ -358,14 +389,15 @@ THE SOFTWARE.
charmap.face = FT_FACE( face );
charmap.encoding = FT_ENCODING_NONE;
- charmap.platform_id = 0;
- charmap.encoding_id = 0;
+ /* initial platform/encoding should indicate unset status? */
+ charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
+ charmap.encoding_id = TT_APPLE_ID_DEFAULT;
if ( unicode_charmap )
{
charmap.encoding = FT_ENCODING_UNICODE;
- charmap.platform_id = 3;
- charmap.encoding_id = 1;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
}
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
@@ -382,9 +414,9 @@ THE SOFTWARE.
return error;
Fail:
- FT_TRACE2(( "[not a valid PCF file]\n" ));
+ FT_TRACE2(( " not a PCF file\n" ));
PCF_Face_Done( pcfface );
- error = PCF_Err_Unknown_File_Format; /* error */
+ error = FT_THROW( Unknown_File_Format ); /* error */
goto Exit;
}
@@ -402,7 +434,7 @@ THE SOFTWARE.
size->metrics.descender = -accel->fontDescent << 6;
size->metrics.max_advance = accel->maxbounds.characterWidth << 6;
- return PCF_Err_Ok;
+ return FT_Err_Ok;
}
@@ -412,7 +444,7 @@ THE SOFTWARE.
{
PCF_Face face = (PCF_Face)size->face;
FT_Bitmap_Size* bsize = size->face->available_sizes;
- FT_Error error = PCF_Err_Invalid_Pixel_Size;
+ FT_Error error = FT_ERR( Invalid_Pixel_Size );
FT_Long height;
@@ -423,17 +455,17 @@ THE SOFTWARE.
{
case FT_SIZE_REQUEST_TYPE_NOMINAL:
if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
- error = PCF_Err_Ok;
+ error = FT_Err_Ok;
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
if ( height == ( face->accel.fontAscent +
face->accel.fontDescent ) )
- error = PCF_Err_Ok;
+ error = FT_Err_Ok;
break;
default:
- error = PCF_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
break;
}
@@ -452,7 +484,7 @@ THE SOFTWARE.
{
PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
FT_Stream stream;
- FT_Error error = PCF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Bitmap* bitmap = &slot->bitmap;
PCF_Metric metric;
FT_Offset bytes;
@@ -460,11 +492,17 @@ THE SOFTWARE.
FT_UNUSED( load_flags );
- FT_TRACE4(( "load_glyph %d ---", glyph_index ));
+ FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index ));
- if ( !face || glyph_index >= (FT_UInt)face->root.num_glyphs )
+ if ( !face )
{
- error = PCF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Face_Handle );
+ goto Exit;
+ }
+
+ if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
+ {
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -504,13 +542,13 @@ THE SOFTWARE.
break;
default:
- return PCF_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
}
/* XXX: to do: are there cases that need repadding the bitmap? */
bytes = bitmap->pitch * bitmap->rows;
- error = ft_glyphslot_alloc_bitmap( slot, bytes );
+ error = ft_glyphslot_alloc_bitmap( slot, (FT_ULong)bytes );
if ( error )
goto Exit;
@@ -554,8 +592,6 @@ THE SOFTWARE.
( face->accel.fontAscent +
face->accel.fontDescent ) << 6 );
- FT_TRACE4(( " --- ok\n" ));
-
Exit:
return error;
}
@@ -600,7 +636,7 @@ THE SOFTWARE.
return 0;
}
- return PCF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -661,8 +697,8 @@ THE SOFTWARE.
0,
- 0,
- 0,
+ 0, /* FT_Module_Constructor */
+ 0, /* FT_Module_Destructor */
pcf_driver_requester
},
@@ -677,10 +713,6 @@ THE SOFTWARE.
0, /* FT_Slot_InitFunc */
0, /* FT_Slot_DoneFunc */
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
PCF_Glyph_Load,
0, /* FT_Face_GetKerningFunc */
diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.h b/src/3rdparty/freetype/src/pcf/pcfdrivr.h
index a81d7309e5..54614951b5 100644
--- a/src/3rdparty/freetype/src/pcf/pcfdrivr.h
+++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.h
@@ -35,7 +35,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Driver_ClassRec ) pcf_driver_class;
diff --git a/src/3rdparty/freetype/src/pcf/pcferror.h b/src/3rdparty/freetype/src/pcf/pcferror.h
index d75c067aa6..e51fff8ea6 100644
--- a/src/3rdparty/freetype/src/pcf/pcferror.h
+++ b/src/3rdparty/freetype/src/pcf/pcferror.h
@@ -4,7 +4,7 @@
/* */
/* PCF error codes (specification only). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PCF_Err_
#define FT_ERR_BASE FT_Mod_Err_PCF
diff --git a/src/3rdparty/freetype/src/pcf/pcfread.c b/src/3rdparty/freetype/src/pcf/pcfread.c
index 08becf99ce..a29a9e371b 100644
--- a/src/3rdparty/freetype/src/pcf/pcfread.c
+++ b/src/3rdparty/freetype/src/pcf/pcfread.c
@@ -2,7 +2,7 @@
FreeType font driver for pcf fonts
- Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by
+ Copyright 2000-2010, 2012-2014 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -78,7 +78,7 @@ THE SOFTWARE.
FT_FRAME_START( 16 ),
FT_FRAME_ULONG_LE( type ),
FT_FRAME_ULONG_LE( format ),
- FT_FRAME_ULONG_LE( size ),
+ FT_FRAME_ULONG_LE( size ), /* rounded up to a multiple of 4 */
FT_FRAME_ULONG_LE( offset ),
FT_FRAME_END
};
@@ -92,21 +92,23 @@ THE SOFTWARE.
PCF_Toc toc = &face->toc;
PCF_Table tables;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_UInt n;
+ FT_ULong size;
- if ( FT_STREAM_SEEK ( 0 ) ||
- FT_STREAM_READ_FIELDS ( pcf_toc_header, toc ) )
- return PCF_Err_Cannot_Open_Resource;
+
+ if ( FT_STREAM_SEEK( 0 ) ||
+ FT_STREAM_READ_FIELDS( pcf_toc_header, toc ) )
+ return FT_THROW( Cannot_Open_Resource );
if ( toc->version != PCF_FILE_VERSION ||
toc->count > FT_ARRAY_MAX( face->toc.tables ) ||
toc->count == 0 )
- return PCF_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )
- return PCF_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
tables = face->toc.tables;
for ( n = 0; n < toc->count; n++ )
@@ -144,13 +146,62 @@ THE SOFTWARE.
if ( ( tables[i].size > tables[i + 1].offset ) ||
( tables[i].offset > tables[i + 1].offset - tables[i].size ) )
- return PCF_Err_Invalid_Offset;
+ {
+ error = FT_THROW( Invalid_Offset );
+ goto Exit;
+ }
}
if ( !have_change )
break;
}
+ /*
+ * We now check whether the `size' and `offset' values are reasonable:
+ * `offset' + `size' must not exceed the stream size.
+ *
+ * Note, however, that X11's `pcfWriteFont' routine (used by the
+ * `bdftopcf' program to create PDF font files) has two special
+ * features.
+ *
+ * - It always assigns the accelerator table a size of 100 bytes in the
+ * TOC, regardless of its real size, which can vary between 34 and 72
+ * bytes.
+ *
+ * - Due to the way the routine is designed, it ships out the last font
+ * table with its real size, ignoring the TOC's size value. Since
+ * the TOC size values are always rounded up to a multiple of 4, the
+ * difference can be up to three bytes for all tables except the
+ * accelerator table, for which the difference can be as large as 66
+ * bytes.
+ *
+ */
+
+ tables = face->toc.tables;
+ size = stream->size;
+
+ for ( n = 0; n < toc->count - 1; n++ )
+ {
+ /* we need two checks to avoid overflow */
+ if ( ( tables->size > size ) ||
+ ( tables->offset > size - tables->size ) )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+ tables++;
+ }
+
+ /* only check `tables->offset' for last table element ... */
+ if ( ( tables->offset > size ) )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+ /* ... and adjust `tables->size' to the real value if necessary */
+ if ( tables->size > size - tables->offset )
+ tables->size = size - tables->offset;
+
#ifdef FT_DEBUG_LEVEL_TRACE
{
@@ -181,7 +232,7 @@ THE SOFTWARE.
#endif
- return PCF_Err_Ok;
+ return FT_Err_Ok;
Exit:
FT_FREE( face->toc.tables );
@@ -248,7 +299,7 @@ THE SOFTWARE.
FT_ULong format,
PCF_Metric metric )
{
- FT_Error error = PCF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
@@ -294,7 +345,7 @@ THE SOFTWARE.
FT_ULong *aformat,
FT_ULong *asize )
{
- FT_Error error = PCF_Err_Invalid_File_Format;
+ FT_Error error = FT_ERR( Invalid_File_Format );
FT_ULong i;
@@ -303,20 +354,20 @@ THE SOFTWARE.
{
if ( stream->pos > tables[i].offset )
{
- error = PCF_Err_Invalid_Stream_Skip;
+ error = FT_THROW( Invalid_Stream_Skip );
goto Fail;
}
if ( FT_STREAM_SKIP( tables[i].offset - stream->pos ) )
{
- error = PCF_Err_Invalid_Stream_Skip;
+ error = FT_THROW( Invalid_Stream_Skip );
goto Fail;
}
*asize = tables[i].size;
*aformat = tables[i].format;
- return PCF_Err_Ok;
+ return FT_Err_Ok;
}
Fail:
@@ -398,11 +449,11 @@ THE SOFTWARE.
PCF_Face face )
{
PCF_ParseProperty props = 0;
- PCF_Property properties;
+ PCF_Property properties = NULL;
FT_ULong nprops, i;
FT_ULong format, size;
FT_Error error;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_ULong string_size;
FT_String* strings = 0;
@@ -441,7 +492,7 @@ THE SOFTWARE.
/* rough estimate */
if ( nprops > size / PCF_PROPERTY_SIZE )
{
- error = PCF_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Bail;
}
@@ -474,7 +525,7 @@ THE SOFTWARE.
i = 4 - ( nprops & 3 );
if ( FT_STREAM_SKIP( i ) )
{
- error = PCF_Err_Invalid_Stream_Skip;
+ error = FT_THROW( Invalid_Stream_Skip );
goto Bail;
}
}
@@ -491,11 +542,12 @@ THE SOFTWARE.
/* rough estimate */
if ( string_size > size - nprops * PCF_PROPERTY_SIZE )
{
- error = PCF_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Bail;
}
- if ( FT_NEW_ARRAY( strings, string_size ) )
+ /* allocate one more byte so that we have a final null byte */
+ if ( FT_NEW_ARRAY( strings, string_size + 1 ) )
goto Bail;
error = FT_Stream_Read( stream, (FT_Byte*)strings, string_size );
@@ -515,7 +567,7 @@ THE SOFTWARE.
if ( ( name_offset < 0 ) ||
( (FT_ULong)name_offset > string_size ) )
{
- error = PCF_Err_Invalid_Offset;
+ error = FT_THROW( Invalid_Offset );
goto Bail;
}
@@ -534,7 +586,7 @@ THE SOFTWARE.
if ( ( value_offset < 0 ) ||
( (FT_ULong)value_offset > string_size ) )
{
- error = PCF_Err_Invalid_Offset;
+ error = FT_THROW( Invalid_Offset );
goto Bail;
}
@@ -551,7 +603,7 @@ THE SOFTWARE.
}
}
- error = PCF_Err_Ok;
+ error = FT_Err_Ok;
Bail:
FT_FREE( props );
@@ -565,10 +617,10 @@ THE SOFTWARE.
pcf_get_metrics( FT_Stream stream,
PCF_Face face )
{
- FT_Error error = PCF_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Error error;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
- PCF_Metric metrics = 0;
+ PCF_Metric metrics = 0;
FT_ULong nmetrics, i;
@@ -586,7 +638,7 @@ THE SOFTWARE.
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) &&
!PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) )
- return PCF_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
{
@@ -603,10 +655,13 @@ THE SOFTWARE.
(void)FT_READ_USHORT_LE( nmetrics );
}
if ( error )
- return PCF_Err_Invalid_File_Format;
+ 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 ));
@@ -615,36 +670,52 @@ THE SOFTWARE.
if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
{
if ( nmetrics > size / PCF_METRIC_SIZE )
- return PCF_Err_Invalid_Table;
+ return FT_THROW( Invalid_Table );
}
else
{
if ( nmetrics > size / PCF_COMPRESSED_METRIC_SIZE )
- return PCF_Err_Invalid_Table;
+ return FT_THROW( Invalid_Table );
}
if ( FT_NEW_ARRAY( face->metrics, nmetrics ) )
- return PCF_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
metrics = face->metrics;
- for ( i = 0; i < nmetrics; i++ )
+ for ( i = 0; i < nmetrics; i++, metrics++ )
{
- error = pcf_get_metric( stream, format, metrics + i );
+ error = pcf_get_metric( stream, format, metrics );
- metrics[i].bits = 0;
+ metrics->bits = 0;
FT_TRACE5(( " idx %d: width=%d, "
"lsb=%d, rsb=%d, ascent=%d, descent=%d, swidth=%d\n",
i,
- ( metrics + i )->characterWidth,
- ( metrics + i )->leftSideBearing,
- ( metrics + i )->rightSideBearing,
- ( metrics + i )->ascent,
- ( metrics + i )->descent,
- ( metrics + i )->attributes ));
+ metrics->characterWidth,
+ metrics->leftSideBearing,
+ metrics->rightSideBearing,
+ metrics->ascent,
+ metrics->descent,
+ metrics->attributes ));
if ( error )
break;
+
+ /* sanity checks -- those values are used in `PCF_Glyph_Load' to */
+ /* compute a glyph's bitmap dimensions, thus setting them to zero in */
+ /* case of an error disables this particular glyph only */
+ if ( metrics->rightSideBearing < metrics->leftSideBearing ||
+ metrics->ascent + metrics->descent < 0 )
+ {
+ metrics->characterWidth = 0;
+ metrics->leftSideBearing = 0;
+ metrics->rightSideBearing = 0;
+ metrics->ascent = 0;
+ metrics->descent = 0;
+
+ FT_TRACE0(( "pcf_get_metrics:"
+ " invalid metrics for glyph %d\n", i ));
+ }
}
if ( error )
@@ -659,9 +730,9 @@ THE SOFTWARE.
pcf_get_bitmaps( FT_Stream stream,
PCF_Face face )
{
- FT_Error error = PCF_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
- FT_Long* offsets;
+ FT_Error error;
+ FT_Memory memory = FT_FACE( face )->memory;
+ FT_Long* offsets = NULL;
FT_Long bitmapSizes[GLYPHPADOPTIONS];
FT_ULong format, size;
FT_ULong nbitmaps, i, sizebitmaps = 0;
@@ -689,15 +760,15 @@ THE SOFTWARE.
FT_Stream_ExitFrame( stream );
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
- return PCF_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
FT_TRACE4(( "pcf_get_bitmaps:\n" ));
FT_TRACE4(( " number of bitmaps: %d\n", nbitmaps ));
- /* XXX: PCF_Face->nmetrics is singed FT_Long, see pcf.h */
- if ( face->nmetrics < 0 || nbitmaps != ( FT_ULong )face->nmetrics )
- return PCF_Err_Invalid_File_Format;
+ /* XXX: PCF_Face->nmetrics is signed FT_Long, see pcf.h */
+ if ( face->nmetrics < 0 || nbitmaps != (FT_ULong)face->nmetrics )
+ return FT_THROW( Invalid_File_Format );
if ( FT_NEW_ARRAY( offsets, nbitmaps ) )
return error;
@@ -761,14 +832,14 @@ THE SOFTWARE.
pcf_get_encodings( FT_Stream stream,
PCF_Face face )
{
- FT_Error error = PCF_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Error error;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
int firstCol, lastCol;
int firstRow, lastRow;
int nencoding, encodingOffset;
- int i, j;
- PCF_Encoding tmpEncoding, encoding = 0;
+ int i, j, k;
+ PCF_Encoding encoding = NULL;
error = pcf_seek_to_table_type( stream,
@@ -806,7 +877,16 @@ THE SOFTWARE.
FT_Stream_ExitFrame( stream );
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
- return PCF_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
+
+ /* sanity checks */
+ if ( firstCol < 0 ||
+ firstCol > lastCol ||
+ lastCol > 0xFF ||
+ firstRow < 0 ||
+ firstRow > lastRow ||
+ lastRow > 0xFF )
+ return FT_THROW( Invalid_Table );
FT_TRACE4(( "pdf_get_encodings:\n" ));
@@ -815,56 +895,47 @@ THE SOFTWARE.
nencoding = ( lastCol - firstCol + 1 ) * ( lastRow - firstRow + 1 );
- if ( FT_NEW_ARRAY( tmpEncoding, nencoding ) )
- return PCF_Err_Out_Of_Memory;
+ if ( FT_NEW_ARRAY( encoding, nencoding ) )
+ return FT_THROW( Out_Of_Memory );
error = FT_Stream_EnterFrame( stream, 2 * nencoding );
if ( error )
goto Bail;
- for ( i = 0, j = 0 ; i < nencoding; i++ )
+ k = 0;
+ for ( i = firstRow; i <= lastRow; i++ )
{
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- encodingOffset = FT_GET_SHORT();
- else
- encodingOffset = FT_GET_SHORT_LE();
-
- if ( encodingOffset != -1 )
+ for ( j = firstCol; j <= lastCol; j++ )
{
- tmpEncoding[j].enc = ( ( ( i / ( lastCol - firstCol + 1 ) ) +
- firstRow ) * 256 ) +
- ( ( i % ( lastCol - firstCol + 1 ) ) +
- firstCol );
+ if ( PCF_BYTE_ORDER( format ) == MSBFirst )
+ encodingOffset = FT_GET_SHORT();
+ else
+ encodingOffset = FT_GET_SHORT_LE();
- tmpEncoding[j].glyph = (FT_Short)encodingOffset;
+ if ( encodingOffset != -1 )
+ {
+ encoding[k].enc = i * 256 + j;
+ encoding[k].glyph = (FT_Short)encodingOffset;
- FT_TRACE5(( " code %d (0x%04X): idx %d\n",
- tmpEncoding[j].enc, tmpEncoding[j].enc,
- tmpEncoding[j].glyph ));
+ FT_TRACE5(( " code %d (0x%04X): idx %d\n",
+ encoding[k].enc, encoding[k].enc, encoding[k].glyph ));
- j++;
+ k++;
+ }
}
}
FT_Stream_ExitFrame( stream );
- if ( FT_NEW_ARRAY( encoding, j ) )
+ if ( FT_RENEW_ARRAY( encoding, nencoding, k ) )
goto Bail;
- for ( i = 0; i < j; i++ )
- {
- encoding[i].enc = tmpEncoding[i].enc;
- encoding[i].glyph = tmpEncoding[i].glyph;
- }
-
- face->nencodings = j;
+ face->nencodings = k;
face->encodings = encoding;
- FT_FREE( tmpEncoding );
return error;
Bail:
FT_FREE( encoding );
- FT_FREE( tmpEncoding );
return error;
}
@@ -919,7 +990,7 @@ THE SOFTWARE.
FT_ULong type )
{
FT_ULong format, size;
- FT_Error error = PCF_Err_Ok;
+ FT_Error error;
PCF_Accel accel = &face->accel;
@@ -990,7 +1061,7 @@ THE SOFTWARE.
static FT_Error
pcf_interpret_style( PCF_Face pcf )
{
- FT_Error error = PCF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Face face = FT_FACE( pcf );
FT_Memory memory = face->memory;
@@ -1019,20 +1090,20 @@ THE SOFTWARE.
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
{
face->style_flags |= FT_STYLE_FLAG_BOLD;
- strings[1] = (char *)"Bold";
+ strings[1] = (char*)"Bold";
}
prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[3] = (char *)(prop->value.atom);
+ strings[3] = (char*)( prop->value.atom );
prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[0] = (char *)(prop->value.atom);
+ strings[0] = (char*)( prop->value.atom );
for ( len = 0, nn = 0; nn < 4; nn++ )
{
@@ -1046,7 +1117,7 @@ THE SOFTWARE.
if ( len == 0 )
{
- strings[0] = (char *)"Regular";
+ strings[0] = (char*)"Regular";
lengths[0] = ft_strlen( strings[0] );
len = lengths[0] + 1;
}
@@ -1084,7 +1155,7 @@ THE SOFTWARE.
for ( mm = 0; mm < len; mm++ )
- if (s[mm] == ' ')
+ if ( s[mm] == ' ' )
s[mm] = '-';
}
@@ -1101,8 +1172,8 @@ THE SOFTWARE.
pcf_load_font( FT_Stream stream,
PCF_Face face )
{
- FT_Error error = PCF_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Error error;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_Bool hasBDFAccelerators;
@@ -1158,9 +1229,10 @@ THE SOFTWARE.
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;
+
+ root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
+ FT_FACE_FLAG_HORIZONTAL |
+ FT_FACE_FLAG_FAST_GLYPHS;
if ( face->accel.constantWidth )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
@@ -1264,7 +1336,7 @@ THE SOFTWARE.
{
/* This is done to respect the behaviour of the original */
/* PCF font driver. */
- error = PCF_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
return error;
diff --git a/src/3rdparty/freetype/src/pcf/pcfutil.c b/src/3rdparty/freetype/src/pcf/pcfutil.c
index b91274f935..0451ee8def 100644
--- a/src/3rdparty/freetype/src/pcf/pcfutil.c
+++ b/src/3rdparty/freetype/src/pcf/pcfutil.c
@@ -66,11 +66,11 @@ in this Software without prior written authorization from The Open Group.
TwoByteSwap( unsigned char* buf,
size_t nbytes )
{
- unsigned char c;
-
-
for ( ; nbytes >= 2; nbytes -= 2, buf += 2 )
{
+ unsigned char c;
+
+
c = buf[0];
buf[0] = buf[1];
buf[1] = c;
@@ -85,11 +85,11 @@ in this Software without prior written authorization from The Open Group.
FourByteSwap( unsigned char* buf,
size_t nbytes )
{
- unsigned char c;
-
-
for ( ; nbytes >= 4; nbytes -= 4, buf += 4 )
{
+ unsigned char c;
+
+
c = buf[0];
buf[0] = buf[3];
buf[3] = c;
diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.c b/src/3rdparty/freetype/src/pfr/pfrcmap.c
index 9c8f9ed8eb..90ba0105ea 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, 2007, 2009 by */
+/* Copyright 2002, 2007, 2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,6 +16,8 @@
/***************************************************************************/
+#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include "pfrcmap.h"
#include "pfrobjs.h"
@@ -23,11 +25,14 @@
FT_CALLBACK_DEF( FT_Error )
- pfr_cmap_init( PFR_CMap cmap )
+ pfr_cmap_init( PFR_CMap cmap,
+ FT_Pointer pointer )
{
- FT_Error error = PFR_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap );
+ FT_UNUSED( pointer );
+
cmap->num_chars = face->phy_font.num_chars;
cmap->chars = face->phy_font.chars;
@@ -42,7 +47,7 @@
{
if ( cmap->chars[n - 1].char_code >= cmap->chars[n].char_code )
{
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
}
@@ -65,14 +70,16 @@
pfr_cmap_char_index( PFR_CMap cmap,
FT_UInt32 char_code )
{
- FT_UInt min = 0;
- FT_UInt max = cmap->num_chars;
- FT_UInt mid;
- PFR_Char gchar;
+ FT_UInt min = 0;
+ FT_UInt max = cmap->num_chars;
while ( min < max )
{
+ PFR_Char gchar;
+ FT_UInt mid;
+
+
mid = min + ( max - min ) / 2;
gchar = cmap->chars + mid;
diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.c b/src/3rdparty/freetype/src/pfr/pfrdrivr.c
index 15cca9854e..db66281acd 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, 2003, 2004, 2006, 2008 by */
+/* Copyright 2002-2004, 2006, 2008, 2010, 2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,7 +37,7 @@
PFR_PhyFont phys = &face->phy_font;
- pfr_face_get_kerning( pfrface, left, right, avector );
+ (void)pfr_face_get_kerning( pfrface, left, right, avector );
/* convert from metrics to outline units when necessary */
if ( phys->outline_resolution != phys->metrics_resolution )
@@ -51,7 +51,7 @@
phys->metrics_resolution );
}
- return PFR_Err_Ok;
+ return FT_Err_Ok;
}
@@ -66,7 +66,7 @@
FT_Pos *anadvance )
{
PFR_Face face = (PFR_Face)pfrface;
- FT_Error error = PFR_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
*anadvance = 0;
@@ -84,7 +84,7 @@
if ( gindex < phys->num_chars )
{
*anadvance = phys->chars[gindex].advance;
- error = 0;
+ error = FT_Err_Ok;
}
}
@@ -130,11 +130,11 @@
if ( ametrics_y_scale )
*ametrics_y_scale = y_scale;
- return PFR_Err_Ok;
+ return FT_Err_Ok;
}
- FT_CALLBACK_TABLE_DEF
+ static
const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
{
pfr_get_metrics,
@@ -173,7 +173,7 @@
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE,
- sizeof( FT_DriverRec ),
+ sizeof ( FT_DriverRec ),
"pfr",
0x10000L,
@@ -181,14 +181,14 @@
NULL,
- 0,
- 0,
+ 0, /* FT_Module_Constructor */
+ 0, /* FT_Module_Destructor */
pfr_get_service
},
- sizeof( PFR_FaceRec ),
- sizeof( PFR_SizeRec ),
- sizeof( PFR_SlotRec ),
+ sizeof ( PFR_FaceRec ),
+ sizeof ( PFR_SizeRec ),
+ sizeof ( PFR_SlotRec ),
pfr_face_init,
pfr_face_done,
@@ -197,17 +197,13 @@
pfr_slot_init,
pfr_slot_done,
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
pfr_slot_load,
pfr_get_kerning,
0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
- 0, /* FT_Size_RequestFunc */
- 0, /* FT_Size_SelectFunc */
+ 0, /* FT_Face_GetAdvancesFunc */
+ 0, /* FT_Size_RequestFunc */
+ 0, /* FT_Size_SelectFunc */
};
diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.h b/src/3rdparty/freetype/src/pfr/pfrdrivr.h
index da0a1aa634..75f86c5cdd 100644
--- a/src/3rdparty/freetype/src/pfr/pfrdrivr.h
+++ b/src/3rdparty/freetype/src/pfr/pfrdrivr.h
@@ -28,7 +28,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Driver_ClassRec ) pfr_driver_class;
diff --git a/src/3rdparty/freetype/src/pfr/pfrerror.h b/src/3rdparty/freetype/src/pfr/pfrerror.h
index 2e1c401dd2..94dc8c5e1c 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 by */
+/* Copyright 2002, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PFR_Err_
#define FT_ERR_BASE FT_Mod_Err_PFR
diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.c b/src/3rdparty/freetype/src/pfr/pfrgload.c
index 6fe6e4225a..2ce093779c 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, 2003, 2005, 2007 by */
+/* Copyright 2002, 2003, 2005, 2007, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -135,7 +135,7 @@
/* check that we have begun a new path */
if ( !glyph->path_begun )
{
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" ));
goto Exit;
}
@@ -171,7 +171,7 @@
/* check that we have begun a new path */
if ( !glyph->path_begun )
{
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" ));
goto Exit;
}
@@ -248,7 +248,7 @@
FT_Byte* p,
FT_Byte* limit )
{
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = glyph->loader->memory;
FT_UInt flags, x_count, y_count, i, count, mask;
FT_Int x;
@@ -268,8 +268,8 @@
{
PFR_CHECK( 1 );
count = PFR_NEXT_BYTE( p );
- x_count = ( count & 15 );
- y_count = ( count >> 4 );
+ x_count = count & 15;
+ y_count = count >> 4;
}
else
{
@@ -388,7 +388,7 @@
case 2: /* horizontal line to */
FT_TRACE6(( "- horizontal line to cx.%d", format_low ));
- if ( format_low > x_count )
+ if ( format_low >= x_count )
goto Failure;
pos[0].x = glyph->x_control[format_low];
pos[0].y = pos[3].y;
@@ -398,7 +398,7 @@
case 3: /* vertical line to */
FT_TRACE6(( "- vertical line to cy.%d", format_low ));
- if ( format_low > y_count )
+ if ( format_low >= y_count )
goto Failure;
pos[0].x = pos[3].x;
pos[0].y = glyph->y_control[format_low];
@@ -440,7 +440,7 @@
case 0: /* 8-bit index */
PFR_CHECK( 1 );
idx = PFR_NEXT_BYTE( p );
- if ( idx > x_count )
+ if ( idx >= x_count )
goto Failure;
cur->x = glyph->x_control[idx];
FT_TRACE7(( " cx#%d", idx ));
@@ -470,7 +470,7 @@
case 0: /* 8-bit index */
PFR_CHECK( 1 );
idx = PFR_NEXT_BYTE( p );
- if ( idx > y_count )
+ if ( idx >= y_count )
goto Failure;
cur->y = glyph->y_control[idx];
FT_TRACE7(( " cy#%d", idx ));
@@ -546,7 +546,7 @@
Failure:
Too_Short:
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_glyph_load_simple: invalid glyph data\n" ));
goto Exit;
}
@@ -558,7 +558,7 @@
FT_Byte* p,
FT_Byte* limit )
{
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
FT_GlyphLoader loader = glyph->loader;
FT_Memory memory = loader->memory;
PFR_SubGlyph subglyph;
@@ -598,6 +598,16 @@
FT_UInt new_max = ( org_count + count + 3 ) & (FT_UInt)-4;
+ /* we arbitrarily limit the number of subglyphs */
+ /* to avoid endless recursion */
+ if ( new_max > 64 )
+ {
+ error = FT_THROW( Invalid_Table );
+ FT_ERROR(( "pfr_glyph_load_compound:"
+ " too many compound glyphs components\n" ));
+ goto Exit;
+ }
+
if ( FT_RENEW_ARRAY( glyph->subs, glyph->max_subs, new_max ) )
goto Exit;
@@ -699,7 +709,7 @@
Failure:
Too_Short:
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_glyph_load_compound: invalid glyph data\n" ));
goto Exit;
}
@@ -743,6 +753,9 @@
count = glyph->num_subs - old_count;
+ FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n",
+ count, offset ));
+
/* now, load each individual glyph */
for ( n = 0; n < count; n++ )
{
@@ -750,6 +763,8 @@
PFR_SubGlyph subglyph;
+ FT_TRACE4(( " subglyph %d:\n", n ));
+
subglyph = glyph->subs + old_count + n;
old_points = base->n_points;
@@ -757,7 +772,7 @@
subglyph->gps_offset,
subglyph->gps_size );
if ( error )
- goto Exit;
+ break;
/* note that `glyph->subs' might have been re-allocated */
subglyph = glyph->subs + old_count + n;
@@ -791,9 +806,13 @@
/* proceed to next sub-glyph */
}
+
+ FT_TRACE4(( "end compound glyph with %d elements\n", count ));
}
else
{
+ FT_TRACE4(( "simple glyph (offset %lu)\n", offset ));
+
/* load a simple glyph */
error = pfr_glyph_load_simple( glyph, p, limit );
@@ -805,9 +824,6 @@
}
-
-
-
FT_LOCAL_DEF( FT_Error )
pfr_glyph_load( PFR_Glyph glyph,
FT_Stream stream,
diff --git a/src/3rdparty/freetype/src/pfr/pfrload.c b/src/3rdparty/freetype/src/pfr/pfrload.c
index bc5c035f3d..f68d016392 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, 2003, 2004, 2005, 2007, 2009 by */
+/* Copyright 2002-2005, 2007, 2009, 2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -49,7 +49,7 @@
PFR_ExtraItem item_list,
FT_Pointer item_data )
{
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
FT_Byte* p = *pp;
FT_UInt num_items, item_type, item_size;
@@ -91,7 +91,7 @@
Too_Short:
FT_ERROR(( "pfr_extra_items_parse: invalid extra items table\n" ));
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -179,7 +179,7 @@
if ( header->signature != 0x50465230L || /* "PFR0" */
header->version > 4 ||
header->header_size < 58 ||
- header->signature2 != 0x0d0a ) /* CR/LF */
+ header->signature2 != 0x0D0A ) /* CR/LF */
{
result = 0;
}
@@ -236,7 +236,7 @@
goto Exit;
if ( idx >= num_log_fonts )
- return PFR_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( FT_STREAM_SKIP( idx * 5 ) ||
FT_READ_USHORT( size ) ||
@@ -329,7 +329,7 @@
Too_Short:
FT_ERROR(( "pfr_log_font_load: invalid logical font table\n" ));
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Fail;
}
@@ -353,7 +353,7 @@
PFR_Strike strike;
FT_UInt flags0;
FT_UInt n, count, size1;
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
PFR_CHECK( 5 );
@@ -427,7 +427,7 @@
return error;
Too_Short:
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_extra_item_load_bitmap_info:"
" invalid bitmap info table\n" ));
goto Exit;
@@ -449,7 +449,7 @@
FT_Byte* limit,
PFR_PhyFont phy_font )
{
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = phy_font->memory;
FT_PtrDist len = limit - p;
@@ -476,8 +476,8 @@
PFR_PhyFont phy_font )
{
FT_UInt count, num_vert, num_horz;
- FT_Int* snaps;
- FT_Error error = 0;
+ FT_Int* snaps = NULL;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = phy_font->memory;
@@ -506,7 +506,7 @@
return error;
Too_Short:
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_exta_item_load_stem_snaps:"
" invalid stem snaps table\n" ));
goto Exit;
@@ -520,8 +520,8 @@
FT_Byte* limit,
PFR_PhyFont phy_font )
{
- PFR_KernItem item;
- FT_Error error = 0;
+ PFR_KernItem item = NULL;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = phy_font->memory;
@@ -604,7 +604,7 @@
Too_Short:
FT_FREE( item );
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_extra_item_load_kerning_pairs:"
" invalid kerning pairs table\n" ));
goto Exit;
@@ -631,7 +631,7 @@
FT_Memory memory,
FT_String* *astring )
{
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
FT_String* result = NULL;
FT_UInt n, ok;
@@ -813,7 +813,6 @@
phy_font->ascent = PFR_NEXT_SHORT( q );
phy_font->descent = PFR_NEXT_SHORT( q );
phy_font->leading = PFR_NEXT_SHORT( q );
- q += 16;
break;
case 3:
@@ -932,7 +931,7 @@
return error;
Too_Short:
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_phy_font_load: invalid physical font table\n" ));
goto Fail;
}
diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.c b/src/3rdparty/freetype/src/pfr/pfrobjs.c
index 56d617d880..0c89242c74 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, 2003, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 2002-2008, 2010-2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,6 +23,8 @@
#include "pfrsbit.h"
#include FT_OUTLINE_H
#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_CALC_H
+#include FT_TRUETYPE_IDS_H
#include "pfrerror.h"
@@ -76,6 +78,8 @@
FT_UNUSED( params );
+ FT_TRACE2(( "PFR driver\n" ));
+
/* load the header and check it */
error = pfr_header_load( &face->header, stream );
if ( error )
@@ -83,8 +87,8 @@
if ( !pfr_header_check( &face->header ) )
{
- FT_TRACE4(( "pfr_face_init: not a valid PFR font\n" ));
- error = PFR_Err_Unknown_File_Format;
+ FT_TRACE2(( " not a PFR font\n" ));
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -108,7 +112,7 @@
if ( face_index >= pfrface->num_faces )
{
FT_ERROR(( "pfr_face_init: invalid face index\n" ));
- error = PFR_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -134,7 +138,8 @@
pfrface->face_index = face_index;
pfrface->num_glyphs = phy_font->num_chars + 1;
- pfrface->face_flags = FT_FACE_FLAG_SCALABLE;
+
+ 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 */
@@ -147,7 +152,16 @@
break;
if ( nn == phy_font->num_chars )
- pfrface->face_flags = 0; /* not scalable */
+ {
+ if ( phy_font->num_strikes > 0 )
+ pfrface->face_flags = 0; /* not scalable */
+ else
+ {
+ FT_ERROR(( "pfr_face_init: font doesn't contain glyphs\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+ }
}
if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
@@ -243,11 +257,11 @@
charmap.face = pfrface;
- charmap.platform_id = 3;
- charmap.encoding_id = 1;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
- FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
+ error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
@@ -312,12 +326,14 @@
FT_ULong gps_offset;
+ FT_TRACE1(( "pfr_slot_load: glyph index %d\n", gindex ));
+
if ( gindex > 0 )
gindex--;
if ( !face || gindex >= face->phy_font.num_chars )
{
- error = PFR_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -331,7 +347,7 @@
if ( load_flags & FT_LOAD_SBITS_ONLY )
{
- error = PFR_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -456,7 +472,7 @@
FT_Vector* kerning )
{
PFR_Face face = (PFR_Face)pfrface;
- FT_Error error = PFR_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PFR_PhyFont phy_font = &face->phy_font;
FT_UInt32 code1, code2, pair;
@@ -500,7 +516,7 @@
{
FT_UInt count = item->pair_count;
FT_UInt size = item->pair_size;
- FT_UInt power = (FT_UInt)ft_highpow2( (FT_UInt32)count );
+ FT_UInt power = 1 << FT_MSB( count );
FT_UInt probe = power * size;
FT_UInt extra = count - power;
FT_Byte* base = stream->cursor;
diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.c b/src/3rdparty/freetype/src/pfr/pfrsbit.c
index d2f17dc9ce..979bf78a26 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, 2003, 2006, 2009 by */
+/* Copyright 2002, 2003, 2006, 2009, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -59,7 +59,7 @@
if ( !decreasing )
{
- writer->line += writer->pitch * ( target->rows-1 );
+ writer->line += writer->pitch * ( target->rows - 1 );
writer->pitch = -writer->pitch;
}
}
@@ -353,7 +353,7 @@
FT_Long *aadvance,
FT_UInt *aformat )
{
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
FT_Byte flags;
FT_Char b;
FT_Byte* p = *pdata;
@@ -471,7 +471,7 @@
return error;
Too_Short:
- error = PFR_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
FT_ERROR(( "pfr_load_bitmap_metrics: invalid glyph data\n" ));
goto Exit;
}
@@ -484,7 +484,7 @@
FT_Bool decreasing,
FT_Bitmap* target )
{
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
PFR_BitWriterRec writer;
@@ -508,7 +508,7 @@
default:
FT_ERROR(( "pfr_read_bitmap_data: invalid image type\n" ));
- error = PFR_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
}
@@ -560,7 +560,7 @@
}
/* couldn't find it */
- return PFR_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
Found_Strike:
@@ -593,7 +593,7 @@
if ( gps_size == 0 )
{
/* Could not find a bitmap program string for this glyph */
- error = PFR_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
}
@@ -636,12 +636,14 @@
* which causes a size truncation, because truncated
* size properties makes bitmap glyph broken.
*/
- if ( xpos > FT_INT_MAX || ( ypos + ysize ) > FT_INT_MAX )
+ if ( xpos > FT_INT_MAX || xpos < FT_INT_MIN ||
+ ysize > FT_INT_MAX || ypos + ysize > FT_INT_MAX ||
+ ypos + (FT_Long)ysize < FT_INT_MIN )
{
FT_TRACE1(( "pfr_slot_load_bitmap:" ));
FT_TRACE1(( "huge bitmap glyph %dx%d over FT_GlyphSlot\n",
xpos, ypos ));
- error = PFR_Err_Invalid_Pixel_Size;
+ error = FT_THROW( Invalid_Pixel_Size );
}
if ( !error )
diff --git a/src/3rdparty/freetype/src/psaux/afmparse.c b/src/3rdparty/freetype/src/psaux/afmparse.c
index 91a17e2362..6a40e110dc 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, 2007, 2008, 2009 by */
+/* Copyright 2006-2010, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include "afmparse.h"
@@ -119,7 +120,6 @@
afm_stream_read_one( AFM_Stream stream )
{
char* str;
- int ch;
afm_stream_skip_spaces( stream );
@@ -130,7 +130,9 @@
while ( 1 )
{
- ch = AFM_GETC();
+ int ch = AFM_GETC();
+
+
if ( AFM_IS_SPACE( ch ) )
break;
else if ( AFM_IS_NEWLINE( ch ) )
@@ -159,7 +161,6 @@
afm_stream_read_string( AFM_Stream stream )
{
char* str;
- int ch;
afm_stream_skip_spaces( stream );
@@ -171,7 +172,9 @@
/* scan to eol */
while ( 1 )
{
- ch = AFM_GETC();
+ int ch = AFM_GETC();
+
+
if ( AFM_IS_NEWLINE( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOL;
@@ -527,7 +530,7 @@
FT_Byte* base,
FT_Byte* limit )
{
- AFM_Stream stream;
+ AFM_Stream stream = NULL;
FT_Error error;
@@ -545,7 +548,7 @@
parser->FontInfo = NULL;
parser->get_index = NULL;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
@@ -572,10 +575,10 @@
{
*aint = val.u.i;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
else
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -631,16 +634,13 @@
tk->max_ptsize = shared_vals[3].u.f;
tk->max_kern = shared_vals[4].u.f;
- /* is this correct? */
- if ( tk->degree < 0 && tk->min_kern > 0 )
- tk->min_kern = -tk->min_kern;
break;
case AFM_TOKEN_ENDTRACKKERN:
case AFM_TOKEN_ENDKERNDATA:
case AFM_TOKEN_ENDFONTMETRICS:
fi->NumTrackKern = n + 1;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case AFM_TOKEN_UNKNOWN:
break;
@@ -651,7 +651,7 @@
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -754,9 +754,9 @@
case AFM_TOKEN_ENDFONTMETRICS:
fi->NumKernPair = n + 1;
ft_qsort( fi->KernPairs, fi->NumKernPair,
- sizeof( AFM_KernPairRec ),
+ sizeof ( AFM_KernPairRec ),
afm_compare_kern_pairs );
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case AFM_TOKEN_UNKNOWN:
break;
@@ -767,7 +767,7 @@
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -798,7 +798,7 @@
case AFM_TOKEN_ENDKERNDATA:
case AFM_TOKEN_ENDFONTMETRICS:
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case AFM_TOKEN_UNKNOWN:
break;
@@ -809,7 +809,7 @@
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -835,11 +835,11 @@
if ( token == end_section || token == AFM_TOKEN_ENDFONTMETRICS )
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -848,19 +848,19 @@
{
FT_Memory memory = parser->memory;
AFM_FontInfo fi = parser->FontInfo;
- FT_Error error = PSaux_Err_Syntax_Error;
+ FT_Error error = FT_ERR( Syntax_Error );
char* key;
FT_Offset len;
FT_Int metrics_sets = 0;
if ( !fi )
- return PSaux_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
key = afm_parser_next_key( parser, 1, &len );
if ( !key || len != 16 ||
ft_strncmp( key, "StartFontMetrics", 16 ) != 0 )
- return PSaux_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
{
@@ -875,7 +875,7 @@
if ( metrics_sets != 0 && metrics_sets != 2 )
{
- error = PSaux_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
goto Fail;
}
@@ -941,7 +941,7 @@
/* fall through since we only support kern data */
case AFM_TOKEN_ENDFONTMETRICS:
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
default:
break;
diff --git a/src/3rdparty/freetype/src/psaux/afmparse.h b/src/3rdparty/freetype/src/psaux/afmparse.h
index de2a530b2f..35d96046c5 100644
--- a/src/3rdparty/freetype/src/psaux/afmparse.h
+++ b/src/3rdparty/freetype/src/psaux/afmparse.h
@@ -56,7 +56,8 @@ FT_BEGIN_HEADER
typedef struct AFM_ValueRec_
{
enum AFM_ValueType_ type;
- union {
+ union
+ {
char* s;
FT_Fixed f;
FT_Int i;
diff --git a/src/3rdparty/freetype/src/psaux/psauxerr.h b/src/3rdparty/freetype/src/psaux/psauxerr.h
index d0baa3cbb9..d52375f8cb 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSaux_Err_
#define FT_ERR_BASE FT_Mod_Err_PSaux
diff --git a/src/3rdparty/freetype/src/psaux/psauxmod.c b/src/3rdparty/freetype/src/psaux/psauxmod.c
index 4c3579f7b8..4b1249d49b 100644
--- a/src/3rdparty/freetype/src/psaux/psauxmod.c
+++ b/src/3rdparty/freetype/src/psaux/psauxmod.c
@@ -123,7 +123,7 @@
const FT_Module_Class psaux_module_class =
{
0,
- sizeof( FT_ModuleRec ),
+ sizeof ( FT_ModuleRec ),
"psaux",
0x20000L,
0x20000L,
diff --git a/src/3rdparty/freetype/src/psaux/psauxmod.h b/src/3rdparty/freetype/src/psaux/psauxmod.h
index 35e042dbce..1217236924 100644
--- a/src/3rdparty/freetype/src/psaux/psauxmod.h
+++ b/src/3rdparty/freetype/src/psaux/psauxmod.h
@@ -28,7 +28,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class;
diff --git a/src/3rdparty/freetype/src/psaux/psconv.c b/src/3rdparty/freetype/src/psaux/psconv.c
index 1531d8f0fb..22e8cf2d14 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, 2008, 2009 by */
+/* Copyright 2006, 2008, 2009, 2012-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,11 +18,22 @@
#include <ft2build.h>
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_DEBUG_H
#include "psconv.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_psconv
+
+
/* The following array is used by various functions to quickly convert */
/* digits (both decimal and non-decimal) into numbers. */
@@ -69,18 +80,29 @@
#endif /* 'A' == 193 */
- FT_LOCAL_DEF( FT_Int )
+ FT_LOCAL_DEF( FT_Long )
PS_Conv_Strtol( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int base )
+ FT_Long base )
{
FT_Byte* p = *cursor;
- FT_Int num = 0;
- FT_Bool sign = 0;
+ FT_Long num = 0;
+ FT_Bool sign = 0;
+ FT_Bool have_overflow = 0;
+
+ FT_Long num_limit;
+ FT_Char c_limit;
- if ( p == limit || base < 2 || base > 36 )
+
+ if ( p >= limit )
+ goto Bad;
+
+ if ( base < 2 || base > 36 )
+ {
+ FT_TRACE4(( "!!!INVALID BASE:!!!" ));
return 0;
+ }
if ( *p == '-' || *p == '+' )
{
@@ -88,9 +110,12 @@
p++;
if ( p == limit )
- return 0;
+ goto Bad;
}
+ num_limit = 0x7FFFFFFFL / base;
+ c_limit = (FT_Char)( 0x7FFFFFFFL % base );
+
for ( ; p < limit; p++ )
{
FT_Char c;
@@ -99,59 +124,89 @@
if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
break;
- c = ft_char_table[*p & 0x7f];
+ c = ft_char_table[*p & 0x7F];
if ( c < 0 || c >= base )
break;
- num = num * base + c;
+ if ( num > num_limit || ( num == num_limit && c > c_limit ) )
+ have_overflow = 1;
+ else
+ num = num * base + c;
+ }
+
+ *cursor = p;
+
+ if ( have_overflow )
+ {
+ num = 0x7FFFFFFFL;
+ FT_TRACE4(( "!!!OVERFLOW:!!!" ));
}
if ( sign )
num = -num;
- *cursor = p;
-
return num;
+
+ Bad:
+ FT_TRACE4(( "!!!END OF DATA:!!!" ));
+ return 0;
}
- FT_LOCAL_DEF( FT_Int )
+ FT_LOCAL_DEF( FT_Long )
PS_Conv_ToInt( FT_Byte** cursor,
FT_Byte* limit )
{
- FT_Byte* p;
- FT_Int num;
+ FT_Byte* p = *cursor;
+ FT_Byte* curp;
+
+ FT_Long num;
- num = PS_Conv_Strtol( cursor, limit, 10 );
- p = *cursor;
+ curp = p;
+ num = PS_Conv_Strtol( &p, limit, 10 );
+
+ if ( p == curp )
+ return 0;
if ( p < limit && *p == '#' )
{
- *cursor = p + 1;
+ p++;
- return PS_Conv_Strtol( cursor, limit, num );
+ curp = p;
+ num = PS_Conv_Strtol( &p, limit, num );
+
+ if ( p == curp )
+ return 0;
}
- else
- return num;
+
+ *cursor = p;
+
+ return num;
}
FT_LOCAL_DEF( FT_Fixed )
PS_Conv_ToFixed( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int power_ten )
+ FT_Long power_ten )
{
FT_Byte* p = *cursor;
- FT_Fixed integral;
- FT_Long decimal = 0, divider = 1;
- FT_Bool sign = 0;
+ FT_Byte* curp;
+ FT_Fixed integral = 0;
+ FT_Long decimal = 0;
+ FT_Long divider = 1;
- if ( p == limit )
- return 0;
+ FT_Bool sign = 0;
+ FT_Bool have_overflow = 0;
+ FT_Bool have_underflow = 0;
+
+
+ if ( p >= limit )
+ goto Bad;
if ( *p == '-' || *p == '+' )
{
@@ -159,13 +214,23 @@
p++;
if ( p == limit )
- return 0;
+ goto Bad;
}
+ /* read the integer part */
if ( *p != '.' )
- integral = PS_Conv_ToInt( &p, limit ) << 16;
- else
- integral = 0;
+ {
+ curp = p;
+ integral = PS_Conv_ToInt( &p, limit );
+
+ if ( p == curp )
+ return 0;
+
+ if ( integral > 0x7FFF )
+ have_overflow = 1;
+ else
+ integral = (FT_Fixed)( (FT_UInt32)integral << 16 );
+ }
/* read the decimal part */
if ( p < limit && *p == '.' )
@@ -180,23 +245,20 @@
if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
break;
- c = ft_char_table[*p & 0x7f];
+ c = ft_char_table[*p & 0x7F];
if ( c < 0 || c >= 10 )
break;
- if ( !integral && power_ten > 0 )
+ /* only add digit if we don't overflow */
+ if ( divider < 0xCCCCCCCL && decimal < 0xCCCCCCCL )
{
- power_ten--;
decimal = decimal * 10 + c;
- }
- else
- {
- if ( divider < 10000000L )
- {
- decimal = decimal * 10 + c;
+
+ if ( !integral && power_ten > 0 )
+ power_ten--;
+ else
divider *= 10;
- }
}
}
}
@@ -204,33 +266,94 @@
/* read exponent, if any */
if ( p + 1 < limit && ( *p == 'e' || *p == 'E' ) )
{
+ FT_Long exponent;
+
+
p++;
- power_ten += PS_Conv_ToInt( &p, limit );
+
+ curp = p;
+ exponent = PS_Conv_ToInt( &p, limit );
+
+ if ( curp == p )
+ return 0;
+
+ /* arbitrarily limit exponent */
+ if ( exponent > 1000 )
+ have_overflow = 1;
+ else if ( exponent < -1000 )
+ have_underflow = 1;
+ else
+ power_ten += exponent;
}
+ *cursor = p;
+
+ if ( !integral && !decimal )
+ return 0;
+
+ if ( have_overflow )
+ goto Overflow;
+ if ( have_underflow )
+ goto Underflow;
+
while ( power_ten > 0 )
{
+ if ( integral >= 0xCCCCCCCL )
+ goto Overflow;
integral *= 10;
- decimal *= 10;
+
+ if ( decimal >= 0xCCCCCCCL )
+ {
+ if ( divider == 1 )
+ goto Overflow;
+ divider /= 10;
+ }
+ else
+ decimal *= 10;
+
power_ten--;
}
while ( power_ten < 0 )
{
integral /= 10;
- divider *= 10;
+ if ( divider < 0xCCCCCCCL )
+ divider *= 10;
+ else
+ decimal /= 10;
+
+ if ( !integral && !decimal )
+ goto Underflow;
+
power_ten++;
}
if ( decimal )
- integral += FT_DivFix( decimal, divider );
+ {
+ decimal = FT_DivFix( decimal, divider );
+ /* it's not necessary to check this addition for overflow */
+ /* due to the structure of the real number representation */
+ integral += decimal;
+ }
+ Exit:
if ( sign )
integral = -integral;
- *cursor = p;
-
return integral;
+
+ Bad:
+ FT_TRACE4(( "!!!END OF DATA:!!!" ));
+ return 0;
+
+ Overflow:
+ integral = 0x7FFFFFFFL;
+ FT_TRACE4(( "!!!OVERFLOW:!!!" ));
+ goto Exit;
+
+ Underflow:
+ FT_TRACE4(( "!!!UNDERFLOW:!!!" ));
+ return 0;
}
@@ -346,7 +469,11 @@
#if 1
- p = *cursor;
+ p = *cursor;
+
+ if ( p >= limit )
+ return 0;
+
if ( n > (FT_UInt)( limit - p ) )
n = (FT_UInt)( limit - p );
@@ -394,7 +521,7 @@
if ( *p OP 0x80 )
break;
- c = ft_char_table[*p & 0x7f];
+ c = ft_char_table[*p & 0x7F];
if ( (unsigned)c >= 16 )
break;
@@ -434,6 +561,10 @@
#if 1
p = *cursor;
+
+ if ( p >= limit )
+ return 0;
+
if ( n > (FT_UInt)(limit - p) )
n = (FT_UInt)(limit - p);
diff --git a/src/3rdparty/freetype/src/psaux/psconv.h b/src/3rdparty/freetype/src/psaux/psconv.h
index 84854ba0d1..d91c762210 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 by */
+/* Copyright 2006, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,20 +26,20 @@
FT_BEGIN_HEADER
- FT_LOCAL( FT_Int )
+ FT_LOCAL( FT_Long )
PS_Conv_Strtol( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int base );
+ FT_Long base );
- FT_LOCAL( FT_Int )
+ FT_LOCAL( FT_Long )
PS_Conv_ToInt( FT_Byte** cursor,
FT_Byte* limit );
FT_LOCAL( FT_Fixed )
PS_Conv_ToFixed( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int power_ten );
+ FT_Long power_ten );
#if 0
FT_LOCAL( FT_UInt )
diff --git a/src/3rdparty/freetype/src/psaux/psobjs.c b/src/3rdparty/freetype/src/psaux/psobjs.c
index fe8398ae38..7ec3b4cf5f 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -113,8 +113,8 @@
static FT_Error
- reallocate_t1_table( PS_Table table,
- FT_Long new_size )
+ reallocate_t1_table( PS_Table table,
+ FT_Offset new_size )
{
FT_Memory memory = table->memory;
FT_Byte* old_base = table->block;
@@ -138,7 +138,7 @@
table->capacity = new_size;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
@@ -173,25 +173,25 @@
if ( idx < 0 || idx >= table->max_elems )
{
FT_ERROR(( "ps_table_add: invalid index\n" ));
- return PSaux_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
if ( length < 0 )
{
FT_ERROR(( "ps_table_add: invalid length\n" ));
- return PSaux_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
/* grow the base block if needed */
if ( table->cursor + length > table->capacity )
{
- FT_Error error;
- FT_Offset new_size = table->capacity;
- FT_Long in_offset;
+ FT_Error error;
+ FT_Offset new_size = table->capacity;
+ FT_PtrDist in_offset;
- in_offset = (FT_Long)((FT_Byte*)object - table->block);
- if ( (FT_ULong)in_offset >= table->capacity )
+ in_offset = (FT_Byte*)object - table->block;
+ if ( in_offset < 0 || (FT_Offset)in_offset >= table->capacity )
in_offset = -1;
while ( new_size < table->cursor + length )
@@ -216,7 +216,7 @@
FT_MEM_COPY( table->block + table->cursor, object, length );
table->cursor += length;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
@@ -341,7 +341,7 @@
{
FT_Byte* cur = *acur;
FT_Int embed = 0;
- FT_Error error = PSaux_Err_Invalid_File_Format;
+ FT_Error error = FT_ERR( Invalid_File_Format );
unsigned int i;
@@ -397,7 +397,7 @@
embed--;
if ( embed == 0 )
{
- error = PSaux_Err_Ok;
+ error = FT_Err_Ok;
break;
}
}
@@ -416,7 +416,7 @@
FT_Byte* limit )
{
FT_Byte* cur = *acur;
- FT_Error err = PSaux_Err_Ok;
+ FT_Error err = FT_Err_Ok;
while ( ++cur < limit )
@@ -433,7 +433,7 @@
if ( cur < limit && *cur != '>' )
{
FT_ERROR(( "skip_string: missing closing delimiter `>'\n" ));
- err = PSaux_Err_Invalid_File_Format;
+ err = FT_THROW( Invalid_File_Format );
}
else
cur++;
@@ -456,12 +456,12 @@
{
FT_Byte* cur;
FT_Int embed = 0;
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ASSERT( **acur == '{' );
- for ( cur = *acur; cur < limit && error == PSaux_Err_Ok; ++cur )
+ for ( cur = *acur; cur < limit && error == FT_Err_Ok; ++cur )
{
switch ( *cur )
{
@@ -494,7 +494,7 @@
end:
if ( embed != 0 )
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
*acur = cur;
@@ -519,7 +519,7 @@
FT_Byte* cur = parser->cursor;
FT_Byte* limit = parser->limit;
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
skip_spaces( &cur, limit ); /* this also skips comments */
@@ -567,7 +567,7 @@
{
FT_ERROR(( "ps_parser_skip_PS_token:"
" unexpected closing delimiter `>'\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
cur++;
@@ -589,7 +589,7 @@
}
Exit:
- if ( cur == parser->cursor )
+ if ( cur < limit && cur == parser->cursor )
{
FT_ERROR(( "ps_parser_skip_PS_token:"
" current token is `%c' which is self-delimiting\n"
@@ -597,7 +597,7 @@
" but invalid at this point\n",
*cur ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
parser->error = error;
@@ -644,7 +644,7 @@
token->type = T1_TOKEN_TYPE_STRING;
token->start = cur;
- if ( skip_literal_string( &cur, limit ) == PSaux_Err_Ok )
+ if ( skip_literal_string( &cur, limit ) == FT_Err_Ok )
token->limit = cur;
break;
@@ -653,7 +653,7 @@
token->type = T1_TOKEN_TYPE_ARRAY;
token->start = cur;
- if ( skip_procedure( &cur, limit ) == PSaux_Err_Ok )
+ if ( skip_procedure( &cur, limit ) == FT_Err_Ok )
token->limit = cur;
break;
@@ -847,6 +847,8 @@
/* first character must be a delimiter or a part of a number */
/* NB: `values' can be NULL if we just want to skip the */
/* array; in this case we ignore `max_values' */
+ /* */
+ /* return number of successfully parsed values */
static FT_Int
ps_tofixedarray( FT_Byte* *acur,
@@ -1027,12 +1029,13 @@
FT_UInt max_objects,
FT_ULong* pflags )
{
- T1_TokenRec token;
- FT_Byte* cur;
- FT_Byte* limit;
- FT_UInt count;
- FT_UInt idx;
- FT_Error error;
+ T1_TokenRec token;
+ FT_Byte* cur;
+ FT_Byte* limit;
+ FT_UInt count;
+ FT_UInt idx;
+ FT_Error error;
+ T1_FieldType type;
/* this also skips leading whitespace */
@@ -1045,8 +1048,10 @@
cur = token.start;
limit = token.limit;
+ type = field->type;
+
/* we must detect arrays in /FontBBox */
- if ( field->type == T1_FIELD_TYPE_BBOX )
+ if ( type == T1_FIELD_TYPE_BBOX )
{
T1_TokenRec token2;
FT_Byte* old_cur = parser->cursor;
@@ -1062,17 +1067,21 @@
parser->limit = old_limit;
if ( token2.type == T1_TOKEN_TYPE_ARRAY )
+ {
+ type = T1_FIELD_TYPE_MM_BBOX;
goto FieldArray;
+ }
}
else if ( token.type == T1_TOKEN_TYPE_ARRAY )
{
+ count = max_objects;
+
FieldArray:
/* if this is an array and we have no blend, an error occurs */
if ( max_objects == 0 )
goto Fail;
- count = max_objects;
- idx = 1;
+ idx = 1;
/* don't include delimiters */
cur++;
@@ -1088,7 +1097,7 @@
skip_spaces( &cur, limit );
- switch ( field->type )
+ switch ( type )
{
case T1_FIELD_TYPE_BOOL:
val = ps_tobool( &cur, limit );
@@ -1160,7 +1169,7 @@
" "
" but found token of type %d instead\n",
token.type ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1193,11 +1202,11 @@
result = ps_tofixedarray( &cur, limit, 4, temp, 0 );
- if ( result < 0 )
+ if ( result < 4 )
{
FT_ERROR(( "ps_parser_load_field:"
" expected four integers in bounding box\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1208,6 +1217,54 @@
}
break;
+ case T1_FIELD_TYPE_MM_BBOX:
+ {
+ FT_Memory memory = parser->memory;
+ FT_Fixed* temp;
+ FT_Int result;
+ FT_UInt i;
+
+
+ if ( FT_NEW_ARRAY( temp, max_objects * 4 ) )
+ goto Exit;
+
+ for ( i = 0; i < 4; i++ )
+ {
+ result = ps_tofixedarray( &cur, limit, max_objects,
+ temp + i * max_objects, 0 );
+ if ( result < 0 || (FT_UInt)result < max_objects )
+ {
+ FT_ERROR(( "ps_parser_load_field:"
+ " expected %d integers in the %s subarray\n"
+ " "
+ " of /FontBBox in the /Blend dictionary\n",
+ max_objects,
+ i == 0 ? "first"
+ : ( i == 1 ? "second"
+ : ( i == 2 ? "third"
+ : "fourth" ) ) ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ skip_spaces( &cur, limit );
+ }
+
+ for ( i = 0; i < max_objects; i++ )
+ {
+ FT_BBox* bbox = (FT_BBox*)objects[i];
+
+
+ bbox->xMin = FT_RoundFix( temp[i ] );
+ bbox->yMin = FT_RoundFix( temp[i + max_objects] );
+ bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] );
+ bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] );
+ }
+
+ FT_FREE( temp );
+ }
+ break;
+
default:
/* an error occurred */
goto Fail;
@@ -1221,13 +1278,13 @@
FT_UNUSED( pflags );
#endif
- error = PSaux_Err_Ok;
+ error = FT_Err_Ok;
Exit:
return error;
Fail:
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1245,7 +1302,7 @@
T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS];
T1_Token token;
FT_Int num_elements;
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* old_cursor;
FT_Byte* old_limit;
T1_FieldRec fieldrec = *(T1_Field)field;
@@ -1260,7 +1317,7 @@
T1_MAX_TABLE_ELEMENTS, &num_elements );
if ( num_elements < 0 )
{
- error = PSaux_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( (FT_UInt)num_elements > field->array_max )
@@ -1281,7 +1338,15 @@
{
parser->cursor = token->start;
parser->limit = token->limit;
- ps_parser_load_field( parser, &fieldrec, objects, max_objects, 0 );
+
+ error = ps_parser_load_field( parser,
+ &fieldrec,
+ objects,
+ max_objects,
+ 0 );
+ if ( error )
+ break;
+
fieldrec.offset += fieldrec.size;
}
@@ -1317,7 +1382,7 @@
FT_Long* pnum_bytes,
FT_Bool delimiters )
{
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* cur;
@@ -1332,7 +1397,7 @@
if ( *cur != '<' )
{
FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1349,7 +1414,7 @@
if ( cur < parser->limit && *cur != '>' )
{
FT_ERROR(( "ps_parser_to_bytes: Missing closing delimiter `>'\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1419,7 +1484,7 @@
FT_Byte* limit,
FT_Memory memory )
{
- parser->error = PSaux_Err_Ok;
+ parser->error = FT_Err_Ok;
parser->base = base;
parser->limit = limit;
parser->cursor = base;
@@ -1588,10 +1653,17 @@
FT_Error error;
+ /* this might happen in invalid fonts */
+ if ( !outline )
+ {
+ FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" ));
+ return FT_THROW( Invalid_File_Format );
+ }
+
if ( !builder->load_points )
{
outline->n_contours++;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
@@ -1614,14 +1686,14 @@
FT_Pos x,
FT_Pos y )
{
- FT_Error error = PSaux_Err_Invalid_File_Format;
+ FT_Error error = FT_ERR( Invalid_File_Format );
/* test whether we are building a new contour */
if ( builder->parse_state == T1_Parse_Have_Path )
- error = PSaux_Err_Ok;
- else if ( builder->parse_state == T1_Parse_Have_Moveto )
+ error = FT_Err_Ok;
+ else
{
builder->parse_state = T1_Parse_Have_Path;
error = t1_builder_add_contour( builder );
diff --git a/src/3rdparty/freetype/src/psaux/t1cmap.c b/src/3rdparty/freetype/src/psaux/t1cmap.c
index f933e4da88..fb1353ae0f 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, 2003, 2006, 2007 by */
+/* Copyright 2002, 2003, 2006, 2007, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -120,8 +120,12 @@
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_standard_init( T1_CMapStd cmap )
+ t1_cmap_standard_init( T1_CMapStd cmap,
+ FT_Pointer pointer )
{
+ FT_UNUSED( pointer );
+
+
t1_cmap_std_init( cmap, 0 );
return 0;
}
@@ -142,8 +146,12 @@
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_expert_init( T1_CMapStd cmap )
+ t1_cmap_expert_init( T1_CMapStd cmap,
+ FT_Pointer pointer )
{
+ FT_UNUSED( pointer );
+
+
t1_cmap_std_init( cmap, 1 );
return 0;
}
@@ -172,11 +180,14 @@
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_custom_init( T1_CMapCustom cmap )
+ t1_cmap_custom_init( T1_CMapCustom cmap,
+ FT_Pointer pointer )
{
T1_Face face = (T1_Face)FT_CMAP_FACE( cmap );
T1_Encoding encoding = &face->type1.encoding;
+ FT_UNUSED( pointer );
+
cmap->first = encoding->code_first;
cmap->count = (FT_UInt)( encoding->code_last - cmap->first );
@@ -264,25 +275,28 @@
/*************************************************************************/
FT_CALLBACK_DEF( const char * )
- t1_get_glyph_name( T1_Face face,
- FT_UInt idx )
+ psaux_get_glyph_name( T1_Face face,
+ FT_UInt idx )
{
return face->type1.glyph_names[idx];
}
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_unicode_init( PS_Unicodes unicodes )
+ t1_cmap_unicode_init( PS_Unicodes unicodes,
+ FT_Pointer pointer )
{
T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes );
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
+ FT_UNUSED( pointer );
+
return psnames->unicodes_init( memory,
unicodes,
face->type1.num_glyphs,
- (PS_GetGlyphNameFunc)&t1_get_glyph_name,
+ (PS_GetGlyphNameFunc)&psaux_get_glyph_name,
(PS_FreeGlyphNameFunc)NULL,
(FT_Pointer)face );
}
diff --git a/src/3rdparty/freetype/src/psaux/t1decode.c b/src/3rdparty/freetype/src/psaux/t1decode.c
index 31554ff1ba..d67a05ebca 100644
--- a/src/3rdparty/freetype/src/psaux/t1decode.c
+++ b/src/3rdparty/freetype/src/psaux/t1decode.c
@@ -4,8 +4,7 @@
/* */
/* PostScript Type 1 decoding routines (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
-/* 2010 by */
+/* Copyright 2000-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,6 +27,8 @@
#include "psauxerr.h"
+/* ensure proper sign extension */
+#define Fix2Int( f ) ( (FT_Int)(FT_Short)( (f) >> 16 ) )
/*************************************************************************/
/* */
@@ -198,13 +199,19 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
T1_Face face = (T1_Face)decoder->builder.face;
-#endif
+#endif
if ( decoder->seac )
{
FT_ERROR(( "t1operator_seac: invalid nested seac\n" ));
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
+ }
+
+ if ( decoder->builder.metrics_only )
+ {
+ FT_ERROR(( "t1operator_seac: unexpected seac\n" ));
+ return FT_THROW( Syntax_Error );
}
/* seac weirdness */
@@ -221,7 +228,7 @@
{
FT_ERROR(( "t1operator_seac:"
" glyph names table not available in this font\n" ));
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -242,7 +249,7 @@
{
FT_ERROR(( "t1operator_seac:"
" invalid seac character code arguments\n" ));
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
/* if we are trying to load a composite glyph, do not load the */
@@ -373,15 +380,6 @@
#endif
- /* we don't want to touch the source code -- use macro trick */
-#define start_point t1_builder_start_point
-#define check_points t1_builder_check_points
-#define add_point t1_builder_add_point
-#define add_point1 t1_builder_add_point1
-#define add_contour t1_builder_add_contour
-#define close_contour t1_builder_close_contour
-
-
/* compute random seed from stack address of parameter */
seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^
(FT_PtrDist)(char*)&decoder ^
@@ -405,10 +403,10 @@
FT_ASSERT( ( decoder->len_buildchar == 0 ) ==
( decoder->buildchar == NULL ) );
- if ( decoder->len_buildchar > 0 )
+ if ( decoder->buildchar && decoder->len_buildchar > 0 )
ft_memset( &decoder->buildchar[0],
0,
- sizeof( decoder->buildchar[0] ) * decoder->len_buildchar );
+ sizeof ( decoder->buildchar[0] ) * decoder->len_buildchar );
FT_TRACE4(( "\n"
"Start charstring\n" ));
@@ -417,7 +415,7 @@
limit = zone->limit = charstring_base + charstring_len;
ip = zone->cursor = zone->base;
- error = PSaux_Err_Ok;
+ error = FT_Err_Ok;
x = orig_x = builder->pos_x;
y = orig_y = builder->pos_y;
@@ -567,10 +565,10 @@
goto Syntax_Error;
}
- value = (FT_Int32)( ( (FT_Long)ip[0] << 24 ) |
- ( (FT_Long)ip[1] << 16 ) |
- ( (FT_Long)ip[2] << 8 ) |
- ip[3] );
+ 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 */
@@ -593,7 +591,7 @@
else
{
if ( !large_int )
- value <<= 16;
+ value = (FT_Int32)( (FT_UInt32)value << 16 );
}
break;
@@ -613,13 +611,13 @@
}
if ( ip[-2] < 251 )
- value = ( ( (FT_Int32)ip[-2] - 247 ) << 8 ) + ip[-1] + 108;
+ value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108;
else
- value = -( ( ( (FT_Int32)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 );
+ value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 );
}
if ( !large_int )
- value <<= 16;
+ value = (FT_Int32)( (FT_UInt32)value << 16 );
}
else
{
@@ -671,7 +669,7 @@
if ( large_int )
FT_TRACE4(( " %ld", value ));
else
- FT_TRACE4(( " %ld", (FT_Int32)( value >> 16 ) ));
+ FT_TRACE4(( " %ld", Fix2Int( value ) ));
#endif
*top++ = value;
@@ -693,8 +691,8 @@
top -= 2;
- subr_no = (FT_Int)( top[1] >> 16 );
- arg_cnt = (FT_Int)( top[0] >> 16 );
+ subr_no = Fix2Int( top[1] );
+ arg_cnt = Fix2Int( top[0] );
/***********************************************************/
/* */
@@ -733,14 +731,34 @@
switch ( subr_no )
{
+ case 0: /* end flex feature */
+ if ( arg_cnt != 3 )
+ goto Unexpected_OtherSubr;
+
+ if ( decoder->flex_state == 0 ||
+ decoder->num_flex_vectors != 7 )
+ {
+ FT_ERROR(( "t1_decoder_parse_charstrings:"
+ " unexpected flex end\n" ));
+ goto Syntax_Error;
+ }
+
+ /* the two `results' are popped by the following setcurrentpoint */
+ top[0] = x;
+ top[1] = y;
+ known_othersubr_result_cnt = 2;
+ break;
+
case 1: /* start flex feature */
if ( arg_cnt != 0 )
goto Unexpected_OtherSubr;
decoder->flex_state = 1;
decoder->num_flex_vectors = 0;
- if ( start_point( builder, x, y ) ||
- check_points( builder, 6 ) )
+ 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;
@@ -752,34 +770,25 @@
if ( arg_cnt != 0 )
goto Unexpected_OtherSubr;
+ if ( decoder->flex_state == 0 )
+ {
+ FT_ERROR(( "t1_decoder_parse_charstrings:"
+ " missing flex start\n" ));
+ goto Syntax_Error;
+ }
+
/* 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 )
- add_point( builder,
- x,
- y,
- (FT_Byte)( idx == 3 || idx == 6 ) );
+ t1_builder_add_point( builder,
+ x,
+ y,
+ (FT_Byte)( idx == 3 || idx == 6 ) );
}
break;
- case 0: /* end flex feature */
- if ( arg_cnt != 3 )
- goto Unexpected_OtherSubr;
-
- if ( decoder->flex_state == 0 ||
- decoder->num_flex_vectors != 7 )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected flex end\n" ));
- goto Syntax_Error;
- }
-
- /* the two `results' are popped by the following setcurrentpoint */
- known_othersubr_result_cnt = 2;
- break;
-
case 3: /* change hints */
if ( arg_cnt != 1 )
goto Unexpected_OtherSubr;
@@ -823,17 +832,18 @@
goto Syntax_Error;
}
- /* we want to compute: */
+ /* We want to compute */
+ /* */
+ /* a0*w0 + a1*w1 + ... + ak*wk */
/* */
- /* a0*w0 + a1*w1 + ... + ak*wk */
+ /* but we only have a0, a1-a0, a2-a0, ..., ak-a0. */
/* */
- /* but we only have the a0, a1-a0, a2-a0, .. ak-a0 */
- /* however, given that w0 + w1 + ... + wk == 1, we can */
- /* rewrite it easily as: */
+ /* However, given that w0 + w1 + ... + wk == 1, we can */
+ /* rewrite it easily as */
/* */
- /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk */
+ /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + ... + (ak-a0)*wk */
/* */
- /* where k == num_designs-1 */
+ /* where k == num_designs-1. */
/* */
/* I guess that's why it's written in this `compact' */
/* form. */
@@ -867,7 +877,7 @@
if ( arg_cnt != 1 || blend == NULL )
goto Unexpected_OtherSubr;
- idx = (FT_Int)( top[0] >> 16 );
+ idx = Fix2Int( top[0] );
if ( idx < 0 ||
idx + blend->num_designs > decoder->len_buildchar )
@@ -876,7 +886,7 @@
ft_memcpy( &decoder->buildchar[idx],
blend->weight_vector,
blend->num_designs *
- sizeof( blend->weight_vector[0] ) );
+ sizeof ( blend->weight_vector[0] ) );
}
break;
@@ -935,7 +945,7 @@
if ( arg_cnt != 2 || blend == NULL )
goto Unexpected_OtherSubr;
- idx = (FT_Int)( top[1] >> 16 );
+ idx = Fix2Int( top[1] );
if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
goto Unexpected_OtherSubr;
@@ -956,7 +966,7 @@
if ( arg_cnt != 1 || blend == NULL )
goto Unexpected_OtherSubr;
- idx = (FT_Int)( top[0] >> 16 );
+ idx = Fix2Int( top[0] );
if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
goto Unexpected_OtherSubr;
@@ -1014,11 +1024,15 @@
break;
default:
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unknown othersubr [%d %d], wish me luck\n",
- arg_cnt, subr_no ));
- unknown_othersubr_result_cnt = arg_cnt;
- break;
+ if ( arg_cnt >= 0 && subr_no >= 0 )
+ {
+ FT_ERROR(( "t1_decoder_parse_charstrings:"
+ " unknown othersubr [%d %d], wish me luck\n",
+ arg_cnt, subr_no ));
+ unknown_othersubr_result_cnt = arg_cnt;
+ break;
+ }
+ /* fall through */
Unexpected_OtherSubr:
FT_ERROR(( "t1_decoder_parse_charstrings:"
@@ -1075,7 +1089,7 @@
case op_endchar:
FT_TRACE4(( " endchar\n" ));
- close_contour( builder );
+ t1_builder_close_contour( builder );
/* close hints recording session */
if ( hinter )
@@ -1084,10 +1098,12 @@
goto Syntax_Error;
/* apply hints to the loaded glyph outline now */
- hinter->apply( hinter->hints,
- builder->current,
- (PSH_Globals)builder->hints_globals,
- decoder->hint_mode );
+ error = hinter->apply( hinter->hints,
+ builder->current,
+ (PSH_Globals)builder->hints_globals,
+ decoder->hint_mode );
+ if ( error )
+ goto Fail;
}
/* add current outline to the glyph slot */
@@ -1105,7 +1121,7 @@
FT_TRACE4(( "BuildCharArray = [ " ));
for ( i = 0; i < decoder->len_buildchar; ++i )
- FT_TRACE4(( "%d ", decoder->buildchar[ i ] ));
+ FT_TRACE4(( "%d ", decoder->buildchar[i] ));
FT_TRACE4(( "]\n" ));
}
@@ -1115,7 +1131,7 @@
FT_TRACE4(( "\n" ));
/* return now! */
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case op_hsbw:
FT_TRACE4(( " hsbw" ));
@@ -1135,7 +1151,7 @@
/* the glyph's metrics (lsb + advance width), not load the */
/* rest of it; so exit immediately */
if ( builder->metrics_only )
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
break;
@@ -1144,8 +1160,8 @@
top[0],
top[1],
top[2],
- (FT_Int)( top[3] >> 16 ),
- (FT_Int)( top[4] >> 16 ) );
+ Fix2Int( top[3] ),
+ Fix2Int( top[4] ) );
case op_sbw:
FT_TRACE4(( " sbw" ));
@@ -1164,7 +1180,7 @@
/* the glyph's metrics (lsb + advance width), not load the */
/* rest of it; so exit immediately */
if ( builder->metrics_only )
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
break;
@@ -1174,7 +1190,7 @@
/* if there is no path, `closepath' is a no-op */
if ( builder->parse_state == T1_Parse_Have_Path ||
builder->parse_state == T1_Parse_Have_Moveto )
- close_contour( builder );
+ t1_builder_close_contour( builder );
builder->parse_state = T1_Parse_Have_Width;
break;
@@ -1182,7 +1198,8 @@
case op_hlineto:
FT_TRACE4(( " hlineto" ));
- if ( start_point( builder, x, y ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
@@ -1203,30 +1220,34 @@
case op_hvcurveto:
FT_TRACE4(( " hvcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok ||
+ ( error = t1_builder_check_points( builder, 3 ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[1];
y += top[2];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
y += top[3];
- add_point( builder, x, y, 1 );
+ t1_builder_add_point( builder, x, y, 1 );
break;
case op_rlineto:
FT_TRACE4(( " rlineto" ));
- if ( start_point( builder, x, y ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
y += top[1];
Add_Line:
- if ( add_point1( builder, x, y ) )
+ if ( ( error = t1_builder_add_point1( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
break;
@@ -1246,43 +1267,48 @@
case op_rrcurveto:
FT_TRACE4(( " rrcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok ||
+ ( error = t1_builder_check_points( builder, 3 ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
y += top[1];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[2];
y += top[3];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[4];
y += top[5];
- add_point( builder, x, y, 1 );
+ t1_builder_add_point( builder, x, y, 1 );
break;
case op_vhcurveto:
FT_TRACE4(( " vhcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok ||
+ ( error = t1_builder_check_points( builder, 3 ) )
+ != FT_Err_Ok )
goto Fail;
y += top[0];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[1];
y += top[2];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[3];
- add_point( builder, x, y, 1 );
+ t1_builder_add_point( builder, x, y, 1 );
break;
case op_vlineto:
FT_TRACE4(( " vlineto" ));
- if ( start_point( builder, x, y ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
y += top[0];
@@ -1319,7 +1345,7 @@
FT_TRACE4(( " callsubr" ));
- idx = (FT_Int)( top[0] >> 16 );
+ idx = Fix2Int( top[0] );
if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs )
{
FT_ERROR(( "t1_decoder_parse_charstrings:"
@@ -1480,8 +1506,12 @@
goto Syntax_Error;
}
else
+ ...
#endif
- decoder->flex_state = 0;
+
+ x = top[0];
+ y = top[1];
+ decoder->flex_state = 0;
break;
case op_unknown15:
@@ -1517,10 +1547,10 @@
return error;
Syntax_Error:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
Stack_Underflow:
- return PSaux_Err_Stack_Underflow;
+ return FT_THROW( Stack_Underflow );
}
@@ -1557,7 +1587,7 @@
{
FT_ERROR(( "t1_decoder_init:"
" the `psnames' module is not available\n" ));
- return PSaux_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
decoder->psnames = psnames;
@@ -1577,7 +1607,7 @@
decoder->funcs = t1_decoder_funcs;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/pshinter/pshalgo.c b/src/3rdparty/freetype/src/pshinter/pshalgo.c
index 417dcee547..644c76d101 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, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001-2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -401,13 +401,13 @@
FT_Fixed delta,
FT_Int dimension )
{
- PSH_Hint hint;
- FT_UInt count;
+ FT_UInt count;
for ( count = 0; count < table->max_hints; count++ )
{
- hint = table->hints + count;
+ PSH_Hint hint = table->hints + count;
+
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
@@ -562,7 +562,7 @@
else if ( len > 0 )
{
/* This is a very small stem; we simply align it to the
- * pixel grid, trying to find the minimal displacement.
+ * pixel grid, trying to find the minimum displacement.
*
* left = pos
* right = pos + len
@@ -1161,8 +1161,8 @@
int result = PSH_DIR_NONE;
- ax = ( dx >= 0 ) ? dx : -dx;
- ay = ( dy >= 0 ) ? dy : -dy;
+ ax = FT_ABS( dx );
+ ay = FT_ABS( dy );
if ( ay * 12 < ax )
{
@@ -1406,7 +1406,6 @@
point = first;
before = point;
- after = point;
do
{
@@ -1690,7 +1689,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1700,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
@@ -1856,12 +1860,10 @@
point->cur_u = hint->cur_pos + hint->cur_len +
FT_MulFix( delta - hint->org_len, scale );
- else if ( hint->org_len > 0 )
+ else /* hint->org_len > 0 */
point->cur_u = hint->cur_pos +
FT_MulDiv( delta, hint->cur_len,
hint->org_len );
- else
- point->cur_u = hint->cur_pos;
}
psh_point_set_fitted( point );
}
@@ -2076,8 +2078,6 @@
start = first;
do
{
- point = first;
-
/* skip consecutive fitted points */
for (;;)
{
@@ -2190,7 +2190,7 @@
/* something to do? */
if ( outline->n_points == 0 || outline->n_contours == 0 )
- return PSH_Err_Ok;
+ return FT_Err_Ok;
#ifdef DEBUG_HINTER
diff --git a/src/3rdparty/freetype/src/pshinter/pshalgo.h b/src/3rdparty/freetype/src/pshinter/pshalgo.h
index 1a248a7052..c70f31ea94 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, 2002, 2003, 2008 by */
+/* Copyright 2001-2003, 2008, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,7 +22,6 @@
#include "pshrec.h"
#include "pshglob.h"
-#include FT_TRIGONOMETRY_H
FT_BEGIN_HEADER
@@ -168,8 +167,6 @@ FT_BEGIN_HEADER
FT_UInt flags2;
FT_Char dir_in;
FT_Char dir_out;
- FT_Angle angle_in;
- FT_Angle angle_out;
PSH_Hint hint;
FT_Pos org_u;
FT_Pos org_v;
@@ -186,12 +183,6 @@ FT_BEGIN_HEADER
} PSH_PointRec;
-#define PSH_POINT_EQUAL_ORG( a, b ) ( (a)->org_u == (b)->org_u && \
- (a)->org_v == (b)->org_v )
-
-#define PSH_POINT_ANGLE( a, b ) FT_Atan2( (b)->org_u - (a)->org_u, \
- (b)->org_v - (a)->org_v )
-
typedef struct PSH_ContourRec_
{
PSH_Point start;
diff --git a/src/3rdparty/freetype/src/pshinter/pshglob.c b/src/3rdparty/freetype/src/pshinter/pshglob.c
index 8a69aa1e84..1bcc481b9b 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, 2002, 2003, 2004, 2006 by */
+/* Copyright 2001-2004, 2006, 2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -522,6 +522,28 @@
}
+ /* calculate the maximum height of given blue zones */
+ static FT_Short
+ psh_calc_max_height( FT_UInt num,
+ const FT_Short* values,
+ FT_Short cur_max )
+ {
+ FT_UInt count;
+
+
+ for ( count = 0; count < num; count += 2 )
+ {
+ FT_Short cur_height = values[count + 1] - values[count];
+
+
+ if ( cur_height > cur_max )
+ cur_max = cur_height;
+ }
+
+ return cur_max;
+ }
+
+
FT_LOCAL_DEF( void )
psh_blues_snap_stem( PSH_Blues blues,
FT_Int stem_top,
@@ -624,7 +646,7 @@
T1_Private* priv,
PSH_Globals *aglobals )
{
- PSH_Globals globals;
+ PSH_Globals globals = NULL;
FT_Error error;
@@ -684,7 +706,32 @@
priv->family_blues, priv->num_family_other_blues,
priv->family_other_blues, priv->blue_fuzz, 1 );
- globals->blues.blue_scale = priv->blue_scale;
+ /* limit the BlueScale value to `1 / max_of_blue_zone_heights' */
+ {
+ FT_Fixed max_scale;
+ FT_Short max_height = 1;
+
+
+ max_height = psh_calc_max_height( priv->num_blue_values,
+ priv->blue_values,
+ max_height );
+ max_height = psh_calc_max_height( priv->num_other_blues,
+ priv->other_blues,
+ max_height );
+ max_height = psh_calc_max_height( priv->num_family_blues,
+ priv->family_blues,
+ max_height );
+ max_height = psh_calc_max_height( priv->num_family_other_blues,
+ priv->family_other_blues,
+ max_height );
+
+ /* BlueScale is scaled 1000 times */
+ max_scale = FT_DivFix( 1000, max_height );
+ globals->blues.blue_scale = priv->blue_scale < max_scale
+ ? priv->blue_scale
+ : max_scale;
+ }
+
globals->blues.blue_shift = priv->blue_shift;
globals->blues.blue_fuzz = priv->blue_fuzz;
@@ -703,14 +750,14 @@
}
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
psh_globals_set_scale( PSH_Globals globals,
FT_Fixed x_scale,
FT_Fixed y_scale,
FT_Fixed x_delta,
FT_Fixed y_delta )
{
- PSH_Dimension dim = &globals->dimension[0];
+ PSH_Dimension dim;
dim = &globals->dimension[0];
@@ -733,8 +780,6 @@
psh_globals_scale_widths( globals, 1 );
psh_blues_scale_zones( &globals->blues, y_scale, y_delta );
}
-
- return 0;
}
diff --git a/src/3rdparty/freetype/src/pshinter/pshglob.h b/src/3rdparty/freetype/src/pshinter/pshglob.h
index c511626157..94d972a940 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, 2002, 2003 by */
+/* Copyright 2001, 2002, 2003, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -167,7 +167,7 @@ FT_BEGIN_HEADER
FT_Int org_width );
#endif
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
psh_globals_set_scale( PSH_Globals globals,
FT_Fixed x_scale,
FT_Fixed y_scale,
diff --git a/src/3rdparty/freetype/src/pshinter/pshmod.c b/src/3rdparty/freetype/src/pshinter/pshmod.c
index 91da5d7e6b..cdeaca18c9 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, 2002, 2007 by */
+/* Copyright 2001, 2002, 2007, 2009, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -93,14 +93,15 @@
}
- FT_DEFINE_PSHINTER_INTERFACE(pshinter_interface,
+ 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(pshinter_module_class,
+ FT_DEFINE_MODULE(
+ pshinter_module_class,
0,
sizeof ( PS_Hinter_ModuleRec ),
@@ -108,11 +109,11 @@
0x10000L,
0x20000L,
- &FTPSHINTER_INTERFACE_GET, /* module-specific interface */
+ &PSHINTER_INTERFACE_GET, /* module-specific interface */
(FT_Module_Constructor)ps_hinter_init,
(FT_Module_Destructor) ps_hinter_done,
- (FT_Module_Requester) 0 /* no additional interface for now */
- )
+ (FT_Module_Requester) NULL ) /* no additional interface for now */
+
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/pshnterr.h b/src/3rdparty/freetype/src/pshinter/pshnterr.h
index 3c0029fbf3..7cc180f0ca 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 by */
+/* Copyright 2003, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSH_Err_
#define FT_ERR_BASE FT_Mod_Err_PShinter
diff --git a/src/3rdparty/freetype/src/pshinter/pshpic.c b/src/3rdparty/freetype/src/pshinter/pshpic.c
index 51a0879888..568f4ac4b0 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 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,17 +20,23 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "pshpic.h"
+#include "pshnterr.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from pshmod.c */
- void FT_Init_Class_pshinter_interface( FT_Library, PSHinter_Interface*);
+ void
+ FT_Init_Class_pshinter_interface( FT_Library library,
+ PSHinter_Interface* clazz );
void
- pshinter_module_class_pic_free( FT_Library library )
+ pshinter_module_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->pshinter )
{
FT_FREE( pic_container->pshinter );
@@ -38,30 +44,33 @@
}
}
+
FT_Error
- pshinter_module_class_pic_init( FT_Library library )
+ pshinter_module_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- PSHinterPIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ PSHinterPIC* container = NULL;
+ FT_Memory memory = library->memory;
+
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->pshinter = container;
-
+
/* add call to initialization function when you add new scripts */
- FT_Init_Class_pshinter_interface(library, &container->pshinter_interface);
+ FT_Init_Class_pshinter_interface(
+ library, &container->pshinter_interface );
+
+ if ( error )
+ pshinter_module_class_pic_free( library );
-/*Exit:*/
- if(error)
- pshinter_module_class_pic_free(library);
return error;
}
-
#endif /* FT_CONFIG_OPTION_PIC */
+
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/pshpic.h b/src/3rdparty/freetype/src/pshinter/pshpic.h
index 3555d8e851..b46f853113 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 by */
+/* Copyright 2009, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,27 +19,37 @@
#ifndef __PSHPIC_H__
#define __PSHPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
+
#ifndef FT_CONFIG_OPTION_PIC
-#define FTPSHINTER_INTERFACE_GET pshinter_interface
+#define PSHINTER_INTERFACE_GET pshinter_interface
#else /* FT_CONFIG_OPTION_PIC */
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
- typedef struct PSHinterPIC_
+ typedef struct PSHinterPIC_
{
- PSHinter_Interface pshinter_interface;
+ PSHinter_Interface pshinter_interface;
+
} PSHinterPIC;
-#define GET_PIC(lib) ((PSHinterPIC*)((lib)->pic_container.autofit))
-#define FTPSHINTER_INTERFACE_GET (GET_PIC(library)->pshinter_interface)
+#define GET_PIC( lib ) ( (PSHinterPIC*)( (lib)->pic_container.pshinter ) )
+
+#define PSHINTER_INTERFACE_GET ( GET_PIC( library )->pshinter_interface )
+
+ /* see pshpic.c for the implementation */
+ void
+ pshinter_module_class_pic_free( FT_Library library );
+
+ FT_Error
+ pshinter_module_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/pshinter/pshrec.c b/src/3rdparty/freetype/src/pshinter/pshrec.c
index 0910cc5e6a..73a18ffd64 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, 2002, 2003, 2004, 2007, 2009 by */
+/* Copyright 2001-2004, 2007, 2009, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -64,7 +64,7 @@
{
FT_UInt old_max = table->max_hints;
FT_UInt new_max = count;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
@@ -83,7 +83,7 @@
FT_Memory memory,
PS_Hint *ahint )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt count;
PS_Hint hint = 0;
@@ -139,7 +139,7 @@
{
FT_UInt old_max = ( mask->max_bits + 7 ) >> 3;
FT_UInt new_max = ( count + 7 ) >> 3;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
@@ -186,7 +186,7 @@
FT_Int idx,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* p;
@@ -236,7 +236,7 @@
{
FT_UInt old_max = table->max_masks;
FT_UInt new_max = count;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
@@ -256,7 +256,7 @@
PS_Mask *amask )
{
FT_UInt count;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PS_Mask mask = 0;
@@ -287,7 +287,7 @@
FT_Memory memory,
PS_Mask *amask )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt count;
PS_Mask mask;
@@ -316,7 +316,7 @@
FT_UInt bit_count,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error;
PS_Mask mask;
@@ -384,7 +384,7 @@
FT_UInt count;
- count = ( count1 <= count2 ) ? count1 : count2;
+ count = FT_MIN( count1, count2 );
for ( ; count >= 8; count -= 8 )
{
if ( p1[0] & p2[0] )
@@ -409,7 +409,7 @@
FT_Memory memory )
{
FT_UInt temp;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* swap index1 and index2 so that index1 < index2 */
@@ -499,7 +499,7 @@
FT_Memory memory )
{
FT_Int index1, index2;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
@@ -561,7 +561,7 @@
FT_Memory memory )
{
PS_Mask mask;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* get last hint mask */
@@ -583,12 +583,13 @@
FT_UInt end_point )
{
FT_UInt count = dim->masks.num_masks;
- PS_Mask mask;
if ( count > 0 )
{
- mask = dim->masks.masks + count - 1;
+ PS_Mask mask = dim->masks.masks + count - 1;
+
+
mask->end_point = end_point;
}
}
@@ -621,7 +622,7 @@
FT_UInt end_point,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error;
/* reset current mask, if any */
@@ -646,7 +647,7 @@
FT_Memory memory,
FT_Int *aindex )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt flags = 0;
@@ -717,7 +718,7 @@
FT_Int hint3,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt count = dim->counters.num_masks;
PS_Mask counter = dim->counters.masks;
@@ -791,18 +792,17 @@
ps_dimension_done( &hints->dimension[0], memory );
ps_dimension_done( &hints->dimension[1], memory );
- hints->error = PSH_Err_Ok;
+ hints->error = FT_Err_Ok;
hints->memory = 0;
}
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
ps_hints_init( PS_Hints hints,
FT_Memory memory )
{
FT_MEM_ZERO( hints, sizeof ( *hints ) );
hints->memory = memory;
- return PSH_Err_Ok;
}
@@ -815,7 +815,7 @@
{
case PS_HINT_TYPE_1:
case PS_HINT_TYPE_2:
- hints->error = PSH_Err_Ok;
+ hints->error = FT_Err_Ok;
hints->hint_type = hint_type;
ps_dimension_init( &hints->dimension[0] );
@@ -823,7 +823,7 @@
break;
default:
- hints->error = PSH_Err_Invalid_Argument;
+ hints->error = FT_THROW( Invalid_Argument );
hints->hint_type = hint_type;
FT_TRACE0(( "ps_hints_open: invalid charstring type\n" ));
@@ -894,7 +894,7 @@
FT_Int dimension,
FT_Fixed* stems )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( !hints->error )
@@ -938,7 +938,7 @@
else
{
FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" ));
- error = PSH_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Fail;
}
}
@@ -956,7 +956,7 @@
ps_hints_t1reset( PS_Hints hints,
FT_UInt end_point )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( !hints->error )
@@ -979,7 +979,7 @@
else
{
/* invalid hint type */
- error = PSH_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Fail;
}
}
diff --git a/src/3rdparty/freetype/src/pshinter/pshrec.h b/src/3rdparty/freetype/src/pshinter/pshrec.h
index dcb3197f94..a88fe6e834 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, 2002, 2003, 2006, 2008 by */
+/* Copyright 2001, 2002, 2003, 2006, 2008, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -141,7 +141,7 @@ FT_BEGIN_HEADER
/* */
/* initialize hints recorder */
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
ps_hints_init( PS_Hints hints,
FT_Memory memory );
diff --git a/src/3rdparty/freetype/src/pshinter/rules.mk b/src/3rdparty/freetype/src/pshinter/rules.mk
index 57773394ac..888ece1058 100644
--- a/src/3rdparty/freetype/src/pshinter/rules.mk
+++ b/src/3rdparty/freetype/src/pshinter/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2001, 2003 by
+# Copyright 2001, 2003, 2011 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -25,10 +25,11 @@ PSHINTER_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PSHINTER_DIR))
# PSHINTER driver sources (i.e., C files)
#
-PSHINTER_DRV_SRC := $(PSHINTER_DIR)/pshrec.c \
+PSHINTER_DRV_SRC := $(PSHINTER_DIR)/pshalgo.c \
$(PSHINTER_DIR)/pshglob.c \
$(PSHINTER_DIR)/pshmod.c \
- $(PSHINTER_DIR)/pshalgo.c
+ $(PSHINTER_DIR)/pshpic.c \
+ $(PSHINTER_DIR)/pshrec.c
# PSHINTER driver headers
diff --git a/src/3rdparty/freetype/src/psnames/psmodule.c b/src/3rdparty/freetype/src/psnames/psmodule.c
index 00b363f8bb..42c9aff27b 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-2001, 2002, 2003, 2005, 2006, 2007, 2008 by */
+/* Copyright 1996-2003, 2005-2008, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
@@ -366,16 +367,18 @@
if ( count == 0 )
{
+ /* No unicode chars here! */
FT_FREE( table->maps );
if ( !error )
- error = PSnames_Err_Invalid_Argument; /* No unicode chars here! */
+ error = FT_THROW( No_Unicode_Glyph_Name );
}
- else {
+ else
+ {
/* Reallocate if the number of used entries is much smaller. */
if ( count < num_glyphs / 2 )
{
(void)FT_RENEW_ARRAY( table->maps, num_glyphs, count );
- error = PSnames_Err_Ok;
+ error = FT_Err_Ok;
}
/* Sort the table in increasing order of unicode values, */
@@ -519,7 +522,9 @@
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
- FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface,
+
+ 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,
@@ -529,54 +534,64 @@
(PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
t1_standard_encoding,
- t1_expert_encoding
- )
+ t1_expert_encoding )
#else
- FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface,
- 0,
- 0,
- 0,
- 0,
+ 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,
t1_standard_encoding,
- t1_expert_encoding
- )
+ t1_expert_encoding )
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
- FT_DEFINE_SERVICEDESCREC1(pscmaps_services,
- FT_SERVICE_ID_POSTSCRIPT_CMAPS, &FT_PSCMAPS_INTERFACE_GET
- )
-
-
+ FT_DEFINE_SERVICEDESCREC1(
+ pscmaps_services,
+ FT_SERVICE_ID_POSTSCRIPT_CMAPS, &PSCMAPS_INTERFACE_GET )
static FT_Pointer
psnames_get_service( FT_Module module,
const char* service_id )
{
+ /* PSCMAPS_SERVICES_GET dereferences `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_Library library;
+
+
+ if ( !module )
+ return NULL;
+ library = module->library;
+ if ( !library )
+ return NULL;
+#else
FT_UNUSED( module );
+#endif
- return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id );
+ return ft_service_list_lookup( PSCMAPS_SERVICES_GET, service_id );
}
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
#ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#define PUT_PS_NAMES_SERVICE(a) 0
+#define PUT_PS_NAMES_SERVICE( a ) NULL
#else
-#define PUT_PS_NAMES_SERVICE(a) a
+#define PUT_PS_NAMES_SERVICE( a ) a
#endif
- FT_DEFINE_MODULE(psnames_module_class,
-
+ FT_DEFINE_MODULE(
+ psnames_module_class,
+
0, /* this is not a font driver, nor a renderer */
sizeof ( FT_ModuleRec ),
@@ -584,12 +599,11 @@
0x10000L, /* driver version */
0x20000L, /* driver requires FreeType 2 or above */
- PUT_PS_NAMES_SERVICE((void*)&FT_PSCMAPS_INTERFACE_GET), /* module specific interface */
- (FT_Module_Constructor)0,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) PUT_PS_NAMES_SERVICE(psnames_get_service)
- )
-
+ 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 ) )
/* END */
diff --git a/src/3rdparty/freetype/src/psnames/psnamerr.h b/src/3rdparty/freetype/src/psnames/psnamerr.h
index ae1541d960..acda7f967e 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSnames_Err_
#define FT_ERR_BASE FT_Mod_Err_PSnames
diff --git a/src/3rdparty/freetype/src/psnames/pspic.c b/src/3rdparty/freetype/src/psnames/pspic.c
index ed7dadda39..3820f65a74 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 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,53 +20,73 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "pspic.h"
+#include "psnamerr.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from psmodule.c */
- FT_Error FT_Create_Class_pscmaps_services( FT_Library, FT_ServiceDescRec**);
- void FT_Destroy_Class_pscmaps_services( FT_Library, FT_ServiceDescRec*);
- void FT_Init_Class_pscmaps_interface( FT_Library, FT_Service_PsCMapsRec*);
+ FT_Error
+ FT_Create_Class_pscmaps_services( FT_Library library,
+ FT_ServiceDescRec** output_class );
+ void
+ FT_Destroy_Class_pscmaps_services( FT_Library library,
+ FT_ServiceDescRec* clazz );
void
- psnames_module_class_pic_free( FT_Library library )
+ FT_Init_Class_pscmaps_interface( FT_Library library,
+ FT_Service_PsCMapsRec* clazz );
+
+
+ void
+ psnames_module_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->psnames )
{
- PSModulePIC* container = (PSModulePIC*)pic_container->psnames;
- if(container->pscmaps_services)
- FT_Destroy_Class_pscmaps_services(library, container->pscmaps_services);
+ PSModulePIC* container = (PSModulePIC*)pic_container->psnames;
+
+
+ if ( container->pscmaps_services )
+ FT_Destroy_Class_pscmaps_services( library,
+ container->pscmaps_services );
container->pscmaps_services = NULL;
FT_FREE( container );
pic_container->psnames = NULL;
}
}
+
FT_Error
- psnames_module_class_pic_init( FT_Library library )
+ psnames_module_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- PSModulePIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ PSModulePIC* container = NULL;
+ FT_Memory memory = library->memory;
+
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->psnames = container;
- /* initialize pointer table - this is how the module usually expects this data */
- error = FT_Create_Class_pscmaps_services(library, &container->pscmaps_services);
- if(error)
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ error = FT_Create_Class_pscmaps_services(
+ library, &container->pscmaps_services );
+ if ( error )
goto Exit;
- FT_Init_Class_pscmaps_interface(library, &container->pscmaps_interface);
-
-Exit:
- if(error)
- psnames_module_class_pic_free(library);
+ FT_Init_Class_pscmaps_interface( library,
+ &container->pscmaps_interface );
+
+ Exit:
+ if ( error )
+ psnames_module_class_pic_free( library );
return error;
}
diff --git a/src/3rdparty/freetype/src/psnames/pspic.h b/src/3rdparty/freetype/src/psnames/pspic.h
index 75a14fdcb9..6ff002c603 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 by */
+/* Copyright 2009, 2012 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,28 +19,40 @@
#ifndef __PSPIC_H__
#define __PSPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_PSCMAPS_SERVICES_GET pscmaps_services
-#define FT_PSCMAPS_INTERFACE_GET pscmaps_interface
+
+#define PSCMAPS_SERVICES_GET pscmaps_services
+#define PSCMAPS_INTERFACE_GET pscmaps_interface
#else /* FT_CONFIG_OPTION_PIC */
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
- typedef struct PSModulePIC_
+ typedef struct PSModulePIC_
{
- FT_ServiceDescRec* pscmaps_services;
- FT_Service_PsCMapsRec pscmaps_interface;
+ FT_ServiceDescRec* pscmaps_services;
+ FT_Service_PsCMapsRec pscmaps_interface;
+
} PSModulePIC;
-#define GET_PIC(lib) ((PSModulePIC*)((lib)->pic_container.psnames))
-#define FT_PSCMAPS_SERVICES_GET (GET_PIC(library)->pscmaps_services)
-#define FT_PSCMAPS_INTERFACE_GET (GET_PIC(library)->pscmaps_interface)
+
+#define GET_PIC( lib ) \
+ ( (PSModulePIC*)((lib)->pic_container.psnames) )
+#define PSCMAPS_SERVICES_GET ( GET_PIC( library )->pscmaps_services )
+#define PSCMAPS_INTERFACE_GET ( GET_PIC( library )->pscmaps_interface )
+
+
+ /* see pspic.c for the implementation */
+ void
+ psnames_module_class_pic_free( FT_Library library );
+
+ FT_Error
+ psnames_module_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/psnames/pstables.h b/src/3rdparty/freetype/src/psnames/pstables.h
index 1521e9c285..0a6637f985 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, 2008 by */
+/* Copyright 2005, 2008, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -564,15 +564,15 @@
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
- static const unsigned char ft_adobe_glyph_list[54791L] =
+ static const unsigned char ft_adobe_glyph_list[55997L] =
{
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,
22,110, 23, 32, 23, 71, 24, 77, 27,156, 29, 73, 31,247, 32,107,
- 32,222, 33, 55, 34,154, 35,218, 53, 84, 59,196, 68, 6, 75,183,
- 83,178, 88,135, 93,242,101,165,109,185,111, 55,117,254,123, 73,
- 130,238,138,206,145, 31,153,182,156,189,163,249,178,221,193, 17,
- 197, 99,199,240,204, 27,204,155,210,100, 65,143, 0, 65, 0,140,
+ 32,222, 33, 55, 34,154, 35,218, 58, 10, 64,122, 72,188, 80,109,
+ 88,104, 93, 61, 98,168,106, 91,114,111,115,237,122,180,127,255,
+ 135,164,143,132,149,213,158,108,161,115,168,175,183,147,197,199,
+ 202, 25,204,166,208,209,209, 81,215, 26, 65,143, 0, 65, 0,140,
0,175, 0,193, 1, 15, 1,147, 1,233, 1,251, 2, 7, 2, 40,
2, 57, 2, 82, 2, 91, 2,128, 2,136, 2,154, 69,131, 0,198,
0,150, 0,158, 0,167,225,227,245,244,101,128, 1,252,237,225,
@@ -1139,2858 +1139,2933 @@
233,243,227,249,242,233,236,236,233, 99,128, 4,220,236,233,238,
229,226,229,236,239,119,128, 30,148,237,239,238,239,243,240,225,
227,101,128,255, 58,115, 2, 35,203, 35,210,237,225,236,108,128,
- 247,122,244,242,239,235,101,128, 1,181, 97,149, 0, 97, 36, 8,
- 36,144, 37, 35, 37,211, 38, 55, 38, 91, 45, 10, 45, 47, 45, 74,
- 46, 43, 46, 81, 47,170, 47,242, 48,197, 48,206, 49, 79, 51, 87,
- 52, 77, 52,124, 53, 19, 53, 33, 97, 7, 36, 24, 36, 34, 36, 41,
- 36, 48, 36, 73, 36, 89, 36,100,226,229,238,231,225,236,105,128,
- 9,134,227,245,244,101,128, 0,225,228,229,246, 97,128, 9, 6,
- 231,117, 2, 36, 55, 36, 64,234,225,242,225,244,105,128, 10,134,
- 242,237,245,235,232,105,128, 10, 6,237,225,244,242,225,231,245,
- 242,237,245,235,232,105,128, 10, 62,242,245,243,241,245,225,242,
- 101,128, 51, 3,246,239,247,229,236,243,233,231,110, 3, 36,116,
- 36,126, 36,133,226,229,238,231,225,236,105,128, 9,190,228,229,
- 246, 97,128, 9, 62,231,245,234,225,242,225,244,105,128, 10,190,
- 98, 4, 36,154, 36,195, 36,204, 36,214,226,242,229,246,233,225,
- 244,233,239,110, 2, 36,169, 36,184,237,225,242,235,225,242,237,
- 229,238,233,225,110,128, 5, 95,243,233,231,238,228,229,246, 97,
- 128, 9,112,229,238,231,225,236,105,128, 9,133,239,240,239,237,
- 239,230,111,128, 49, 26,242,229,246,101,134, 1, 3, 36,233, 36,
- 241, 36,252, 37, 7, 37, 15, 37, 27,225,227,245,244,101,128, 30,
- 175,227,249,242,233,236,236,233, 99,128, 4,209,228,239,244,226,
- 229,236,239,119,128, 30,183,231,242,225,246,101,128, 30,177,232,
- 239,239,235,225,226,239,246,101,128, 30,179,244,233,236,228,101,
- 128, 30,181, 99, 4, 37, 45, 37, 52, 37,131, 37,201,225,242,239,
- 110,128, 1,206,233,242, 99, 2, 37, 60, 37, 65,236,101,128, 36,
- 208,245,237,230,236,229,120,133, 0,226, 37, 84, 37, 92, 37,103,
- 37,111, 37,123,225,227,245,244,101,128, 30,165,228,239,244,226,
- 229,236,239,119,128, 30,173,231,242,225,246,101,128, 30,167,232,
- 239,239,235,225,226,239,246,101,128, 30,169,244,233,236,228,101,
- 128, 30,171,245,244,101,133, 0,180, 37,147, 37,158, 37,175, 37,
- 182, 37,191,226,229,236,239,247,227,237, 98,128, 3, 23, 99, 2,
- 37,164, 37,169,237, 98,128, 3, 1,239,237, 98,128, 3, 1,228,
- 229,246, 97,128, 9, 84,236,239,247,237,239,100,128, 2,207,244,
- 239,238,229,227,237, 98,128, 3, 65,249,242,233,236,236,233, 99,
- 128, 4, 48,100, 5, 37,223, 37,233, 37,247, 37,253, 38, 31,226,
- 236,231,242,225,246,101,128, 2, 1,228,225,235,231,245,242,237,
- 245,235,232,105,128, 10,113,229,246, 97,128, 9, 5,233,229,242,
- 229,243,233,115,130, 0,228, 38, 11, 38, 22,227,249,242,233,236,
- 236,233, 99,128, 4,211,237,225,227,242,239,110,128, 1,223,239,
- 116, 2, 38, 38, 38, 46,226,229,236,239,119,128, 30,161,237,225,
- 227,242,239,110,128, 1,225,101,131, 0,230, 38, 65, 38, 73, 38,
- 82,225,227,245,244,101,128, 1,253,235,239,242,229,225,110,128,
- 49, 80,237,225,227,242,239,110,128, 1,227,230,233,105, 6, 38,
- 107, 38,127, 41, 64, 41, 70, 41, 85, 44,185, 48, 2, 38,113, 38,
- 120,176,178,176, 56,128, 32, 21,184,185,180, 49,128, 32,164,177,
- 48, 3, 38,136, 40,160, 41, 39, 48, 9, 38,156, 38,176, 38,238,
- 39, 44, 39,106, 39,168, 39,230, 40, 36, 40, 98, 49, 3, 38,164,
- 38,168, 38,172, 55,128, 4, 16, 56,128, 4, 17, 57,128, 4, 18,
- 50, 10, 38,198, 38,202, 38,206, 38,210, 38,214, 38,218, 38,222,
- 38,226, 38,230, 38,234, 48,128, 4, 19, 49,128, 4, 20, 50,128,
- 4, 21, 51,128, 4, 1, 52,128, 4, 22, 53,128, 4, 23, 54,128,
- 4, 24, 55,128, 4, 25, 56,128, 4, 26, 57,128, 4, 27, 51, 10,
- 39, 4, 39, 8, 39, 12, 39, 16, 39, 20, 39, 24, 39, 28, 39, 32,
- 39, 36, 39, 40, 48,128, 4, 28, 49,128, 4, 29, 50,128, 4, 30,
- 51,128, 4, 31, 52,128, 4, 32, 53,128, 4, 33, 54,128, 4, 34,
- 55,128, 4, 35, 56,128, 4, 36, 57,128, 4, 37, 52, 10, 39, 66,
- 39, 70, 39, 74, 39, 78, 39, 82, 39, 86, 39, 90, 39, 94, 39, 98,
- 39,102, 48,128, 4, 38, 49,128, 4, 39, 50,128, 4, 40, 51,128,
- 4, 41, 52,128, 4, 42, 53,128, 4, 43, 54,128, 4, 44, 55,128,
- 4, 45, 56,128, 4, 46, 57,128, 4, 47, 53, 10, 39,128, 39,132,
- 39,136, 39,140, 39,144, 39,148, 39,152, 39,156, 39,160, 39,164,
- 48,128, 4,144, 49,128, 4, 2, 50,128, 4, 3, 51,128, 4, 4,
- 52,128, 4, 5, 53,128, 4, 6, 54,128, 4, 7, 55,128, 4, 8,
- 56,128, 4, 9, 57,128, 4, 10, 54, 10, 39,190, 39,194, 39,198,
- 39,202, 39,206, 39,210, 39,214, 39,218, 39,222, 39,226, 48,128,
- 4, 11, 49,128, 4, 12, 50,128, 4, 14, 51,128,246,196, 52,128,
- 246,197, 53,128, 4, 48, 54,128, 4, 49, 55,128, 4, 50, 56,128,
- 4, 51, 57,128, 4, 52, 55, 10, 39,252, 40, 0, 40, 4, 40, 8,
- 40, 12, 40, 16, 40, 20, 40, 24, 40, 28, 40, 32, 48,128, 4, 53,
- 49,128, 4, 81, 50,128, 4, 54, 51,128, 4, 55, 52,128, 4, 56,
- 53,128, 4, 57, 54,128, 4, 58, 55,128, 4, 59, 56,128, 4, 60,
- 57,128, 4, 61, 56, 10, 40, 58, 40, 62, 40, 66, 40, 70, 40, 74,
- 40, 78, 40, 82, 40, 86, 40, 90, 40, 94, 48,128, 4, 62, 49,128,
- 4, 63, 50,128, 4, 64, 51,128, 4, 65, 52,128, 4, 66, 53,128,
- 4, 67, 54,128, 4, 68, 55,128, 4, 69, 56,128, 4, 70, 57,128,
- 4, 71, 57, 10, 40,120, 40,124, 40,128, 40,132, 40,136, 40,140,
- 40,144, 40,148, 40,152, 40,156, 48,128, 4, 72, 49,128, 4, 73,
- 50,128, 4, 74, 51,128, 4, 75, 52,128, 4, 76, 53,128, 4, 77,
- 54,128, 4, 78, 55,128, 4, 79, 56,128, 4,145, 57,128, 4, 82,
- 49, 4, 40,170, 40,232, 40,237, 41, 7, 48, 10, 40,192, 40,196,
- 40,200, 40,204, 40,208, 40,212, 40,216, 40,220, 40,224, 40,228,
- 48,128, 4, 83, 49,128, 4, 84, 50,128, 4, 85, 51,128, 4, 86,
- 52,128, 4, 87, 53,128, 4, 88, 54,128, 4, 89, 55,128, 4, 90,
- 56,128, 4, 91, 57,128, 4, 92,177, 48,128, 4, 94, 52, 4, 40,
- 247, 40,251, 40,255, 41, 3, 53,128, 4, 15, 54,128, 4, 98, 55,
- 128, 4,114, 56,128, 4,116, 57, 5, 41, 19, 41, 23, 41, 27, 41,
- 31, 41, 35, 50,128,246,198, 51,128, 4, 95, 52,128, 4, 99, 53,
- 128, 4,115, 54,128, 4,117, 56, 2, 41, 45, 41, 59, 51, 2, 41,
- 51, 41, 55, 49,128,246,199, 50,128,246,200,180, 54,128, 4,217,
- 178,185, 57,128, 32, 14,179, 48, 2, 41, 77, 41, 81, 48,128, 32,
- 15, 49,128, 32, 13,181, 55, 7, 41,102, 41,172, 42,237, 43, 58,
- 44, 15, 44,108, 44,179, 51, 2, 41,108, 41,122, 56, 2, 41,114,
- 41,118, 49,128, 6,106, 56,128, 6, 12, 57, 8, 41,140, 41,144,
- 41,148, 41,152, 41,156, 41,160, 41,164, 41,168, 50,128, 6, 96,
- 51,128, 6, 97, 52,128, 6, 98, 53,128, 6, 99, 54,128, 6,100,
- 55,128, 6,101, 56,128, 6,102, 57,128, 6,103, 52, 7, 41,188,
- 41,220, 42, 26, 42, 88, 42,120, 42,176, 42,232, 48, 5, 41,200,
- 41,204, 41,208, 41,212, 41,216, 48,128, 6,104, 49,128, 6,105,
- 51,128, 6, 27, 55,128, 6, 31, 57,128, 6, 33, 49, 10, 41,242,
- 41,246, 41,250, 41,254, 42, 2, 42, 6, 42, 10, 42, 14, 42, 18,
- 42, 22, 48,128, 6, 34, 49,128, 6, 35, 50,128, 6, 36, 51,128,
- 6, 37, 52,128, 6, 38, 53,128, 6, 39, 54,128, 6, 40, 55,128,
- 6, 41, 56,128, 6, 42, 57,128, 6, 43, 50, 10, 42, 48, 42, 52,
- 42, 56, 42, 60, 42, 64, 42, 68, 42, 72, 42, 76, 42, 80, 42, 84,
- 48,128, 6, 44, 49,128, 6, 45, 50,128, 6, 46, 51,128, 6, 47,
- 52,128, 6, 48, 53,128, 6, 49, 54,128, 6, 50, 55,128, 6, 51,
- 56,128, 6, 52, 57,128, 6, 53, 51, 5, 42,100, 42,104, 42,108,
- 42,112, 42,116, 48,128, 6, 54, 49,128, 6, 55, 50,128, 6, 56,
- 51,128, 6, 57, 52,128, 6, 58, 52, 9, 42,140, 42,144, 42,148,
- 42,152, 42,156, 42,160, 42,164, 42,168, 42,172, 48,128, 6, 64,
- 49,128, 6, 65, 50,128, 6, 66, 51,128, 6, 67, 52,128, 6, 68,
- 53,128, 6, 69, 54,128, 6, 70, 56,128, 6, 72, 57,128, 6, 73,
- 53, 9, 42,196, 42,200, 42,204, 42,208, 42,212, 42,216, 42,220,
- 42,224, 42,228, 48,128, 6, 74, 49,128, 6, 75, 50,128, 6, 76,
- 51,128, 6, 77, 52,128, 6, 78, 53,128, 6, 79, 54,128, 6, 80,
- 55,128, 6, 81, 56,128, 6, 82,183, 48,128, 6, 71, 53, 3, 42,
- 245, 43, 21, 43, 53, 48, 5, 43, 1, 43, 5, 43, 9, 43, 13, 43,
- 17, 53,128, 6,164, 54,128, 6,126, 55,128, 6,134, 56,128, 6,
- 152, 57,128, 6,175, 49, 5, 43, 33, 43, 37, 43, 41, 43, 45, 43,
- 49, 49,128, 6,121, 50,128, 6,136, 51,128, 6,145, 52,128, 6,
- 186, 57,128, 6,210,179, 52,128, 6,213, 54, 7, 43, 74, 43, 79,
- 43, 84, 43, 89, 43,127, 43,189, 43,251,179, 54,128, 32,170,180,
- 53,128, 5,190,181, 56,128, 5,195, 54, 6, 43,103, 43,107, 43,
- 111, 43,115, 43,119, 43,123, 52,128, 5,208, 53,128, 5,209, 54,
- 128, 5,210, 55,128, 5,211, 56,128, 5,212, 57,128, 5,213, 55,
- 10, 43,149, 43,153, 43,157, 43,161, 43,165, 43,169, 43,173, 43,
- 177, 43,181, 43,185, 48,128, 5,214, 49,128, 5,215, 50,128, 5,
- 216, 51,128, 5,217, 52,128, 5,218, 53,128, 5,219, 54,128, 5,
- 220, 55,128, 5,221, 56,128, 5,222, 57,128, 5,223, 56, 10, 43,
- 211, 43,215, 43,219, 43,223, 43,227, 43,231, 43,235, 43,239, 43,
- 243, 43,247, 48,128, 5,224, 49,128, 5,225, 50,128, 5,226, 51,
- 128, 5,227, 52,128, 5,228, 53,128, 5,229, 54,128, 5,230, 55,
- 128, 5,231, 56,128, 5,232, 57,128, 5,233, 57, 3, 44, 3, 44,
- 7, 44, 11, 48,128, 5,234, 52,128,251, 42, 53,128,251, 43, 55,
- 4, 44, 25, 44, 39, 44, 59, 44, 64, 48, 2, 44, 31, 44, 35, 48,
- 128,251, 75, 53,128,251, 31, 49, 3, 44, 47, 44, 51, 44, 55, 54,
- 128, 5,240, 55,128, 5,241, 56,128, 5,242,178, 51,128,251, 53,
- 57, 7, 44, 80, 44, 84, 44, 88, 44, 92, 44, 96, 44,100, 44,104,
- 51,128, 5,180, 52,128, 5,181, 53,128, 5,182, 54,128, 5,187,
- 55,128, 5,184, 56,128, 5,183, 57,128, 5,176, 56, 3, 44,116,
- 44,160, 44,165, 48, 7, 44,132, 44,136, 44,140, 44,144, 44,148,
- 44,152, 44,156, 48,128, 5,178, 49,128, 5,177, 50,128, 5,179,
- 51,128, 5,194, 52,128, 5,193, 54,128, 5,185, 55,128, 5,188,
- 179, 57,128, 5,189, 52, 2, 44,171, 44,175, 49,128, 5,191, 50,
- 128, 5,192,185,178, 57,128, 2,188, 54, 3, 44,193, 44,252, 45,
- 3, 49, 4, 44,203, 44,219, 44,225, 44,246, 50, 2, 44,209, 44,
- 214,180, 56,128, 33, 5,184, 57,128, 33, 19,179,181, 50,128, 33,
- 22,181, 55, 3, 44,234, 44,238, 44,242, 51,128, 32, 44, 52,128,
- 32, 45, 53,128, 32, 46,182,182, 52,128, 32, 12,179,177,182, 55,
- 128, 6,109,180,185,179, 55,128, 2,189,103, 2, 45, 16, 45, 23,
- 242,225,246,101,128, 0,224,117, 2, 45, 29, 45, 38,234,225,242,
- 225,244,105,128, 10,133,242,237,245,235,232,105,128, 10, 5,104,
- 2, 45, 53, 45, 63,233,242,225,231,225,238, 97,128, 48, 66,239,
- 239,235,225,226,239,246,101,128, 30,163,105, 7, 45, 90, 45,115,
- 45,122, 45,134, 45,159, 45,175, 45,255, 98, 2, 45, 96, 45,105,
- 229,238,231,225,236,105,128, 9,144,239,240,239,237,239,230,111,
- 128, 49, 30,228,229,246, 97,128, 9, 16,229,227,249,242,233,236,
- 236,233, 99,128, 4,213,231,117, 2, 45,141, 45,150,234,225,242,
- 225,244,105,128, 10,144,242,237,245,235,232,105,128, 10, 16,237,
- 225,244,242,225,231,245,242,237,245,235,232,105,128, 10, 72,110,
- 5, 45,187, 45,196, 45,210, 45,226, 45,241,225,242,225,226,233,
- 99,128, 6, 57,230,233,238,225,236,225,242,225,226,233, 99,128,
- 254,202,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
- 254,203,237,229,228,233,225,236,225,242,225,226,233, 99,128,254,
- 204,246,229,242,244,229,228,226,242,229,246,101,128, 2, 3,246,
- 239,247,229,236,243,233,231,110, 3, 46, 15, 46, 25, 46, 32,226,
- 229,238,231,225,236,105,128, 9,200,228,229,246, 97,128, 9, 72,
- 231,245,234,225,242,225,244,105,128, 10,200,107, 2, 46, 49, 46,
- 73,225,244,225,235,225,238, 97,129, 48,162, 46, 61,232,225,236,
- 230,247,233,228,244,104,128,255,113,239,242,229,225,110,128, 49,
- 79,108, 3, 46, 89, 47,145, 47,154,101, 2, 46, 95, 47,140,102,
- 136, 5,208, 46,115, 46,124, 46,139, 46,153, 46,242, 47, 0, 47,
- 111, 47,125,225,242,225,226,233, 99,128, 6, 39,228,225,231,229,
- 243,232,232,229,226,242,229,119,128,251, 48,230,233,238,225,236,
- 225,242,225,226,233, 99,128,254,142,104, 2, 46,159, 46,234,225,
- 237,250, 97, 2, 46,168, 46,201,225,226,239,246,101, 2, 46,178,
- 46,187,225,242,225,226,233, 99,128, 6, 35,230,233,238,225,236,
- 225,242,225,226,233, 99,128,254,132,226,229,236,239,119, 2, 46,
- 211, 46,220,225,242,225,226,233, 99,128, 6, 37,230,233,238,225,
- 236,225,242,225,226,233, 99,128,254,136,229,226,242,229,119,128,
- 5,208,236,225,237,229,228,232,229,226,242,229,119,128,251, 79,
- 237, 97, 2, 47, 7, 47, 43,228,228,225,225,226,239,246,101, 2,
- 47, 20, 47, 29,225,242,225,226,233, 99,128, 6, 34,230,233,238,
- 225,236,225,242,225,226,233, 99,128,254,130,235,243,245,242, 97,
- 4, 47, 57, 47, 66, 47, 80, 47, 96,225,242,225,226,233, 99,128,
- 6, 73,230,233,238,225,236,225,242,225,226,233, 99,128,254,240,
- 233,238,233,244,233,225,236,225,242,225,226,233, 99,128,254,243,
- 237,229,228,233,225,236,225,242,225,226,233, 99,128,254,244,240,
- 225,244,225,232,232,229,226,242,229,119,128,251, 46,241,225,237,
- 225,244,243,232,229,226,242,229,119,128,251, 47,240,104,128, 33,
- 53,236,229,241,245,225,108,128, 34, 76,240,232, 97,129, 3,177,
- 47,162,244,239,238,239,115,128, 3,172,109, 4, 47,180, 47,188,
- 47,199, 47,233,225,227,242,239,110,128, 1, 1,239,238,239,243,
- 240,225,227,101,128,255, 65,240,229,242,243,225,238,100,130, 0,
- 38, 47,213, 47,225,237,239,238,239,243,240,225,227,101,128,255,
- 6,243,237,225,236,108,128,247, 38,243,241,245,225,242,101,128,
- 51,194,110, 4, 47,252, 48, 7, 48,129, 48,139,226,239,240,239,
- 237,239,230,111,128, 49, 34,103, 4, 48, 17, 48, 28, 48, 42, 48,
- 121,226,239,240,239,237,239,230,111,128, 49, 36,235,232,225,238,
- 235,232,245,244,232,225,105,128, 14, 90,236,101,131, 34, 32, 48,
- 53, 48,106, 48,113,226,242,225,227,235,229,116, 2, 48, 65, 48,
- 85,236,229,230,116,129, 48, 8, 48, 74,246,229,242,244,233,227,
- 225,108,128,254, 63,242,233,231,232,116,129, 48, 9, 48, 95,246,
- 229,242,244,233,227,225,108,128,254, 64,236,229,230,116,128, 35,
- 41,242,233,231,232,116,128, 35, 42,243,244,242,239,109,128, 33,
- 43,239,244,229,236,229,233, 97,128, 3,135,117, 2, 48,145, 48,
- 157,228,225,244,244,225,228,229,246, 97,128, 9, 82,243,246,225,
- 242, 97, 3, 48,169, 48,179, 48,186,226,229,238,231,225,236,105,
- 128, 9,130,228,229,246, 97,128, 9, 2,231,245,234,225,242,225,
- 244,105,128, 10,130,239,231,239,238,229,107,128, 1, 5,112, 3,
- 48,214, 48,238, 49, 12, 97, 2, 48,220, 48,232,225,244,239,243,
- 241,245,225,242,101,128, 51, 0,242,229,110,128, 36,156,239,243,
- 244,242,239,240,232,101, 2, 48,251, 49, 6,225,242,237,229,238,
- 233,225,110,128, 5, 90,237,239,100,128, 2,188,112, 2, 49, 18,
- 49, 23,236,101,128,248,255,242,111, 2, 49, 30, 49, 38,225,227,
- 232,229,115,128, 34, 80,120, 2, 49, 44, 49, 64,229,241,245,225,
- 108,129, 34, 72, 49, 54,239,242,233,237,225,231,101,128, 34, 82,
- 233,237,225,244,229,236,249,229,241,245,225,108,128, 34, 69,114,
- 4, 49, 89, 49,116, 49,120, 49,165,225,229, 97, 2, 49, 97, 49,
- 107,229,235,239,242,229,225,110,128, 49,142,235,239,242,229,225,
- 110,128, 49,141, 99,128, 35, 18,105, 2, 49,126, 49,140,231,232,
- 244,232,225,236,230,242,233,238,103,128, 30,154,238,103,130, 0,
- 229, 49,149, 49,157,225,227,245,244,101,128, 1,251,226,229,236,
- 239,119,128, 30, 1,242,239,119, 8, 49,185, 49,192, 50, 65, 50,
- 131, 50,181, 50,236, 51, 3, 51, 78,226,239,244,104,128, 33,148,
- 100, 3, 49,200, 49,239, 50, 30,225,243,104, 4, 49,212, 49,219,
- 49,226, 49,234,228,239,247,110,128, 33,227,236,229,230,116,128,
- 33,224,242,233,231,232,116,128, 33,226,245,112,128, 33,225,226,
- 108, 5, 49,252, 50, 3, 50, 10, 50, 17, 50, 25,226,239,244,104,
- 128, 33,212,228,239,247,110,128, 33,211,236,229,230,116,128, 33,
- 208,242,233,231,232,116,128, 33,210,245,112,128, 33,209,239,247,
- 110,131, 33,147, 50, 42, 50, 49, 50, 57,236,229,230,116,128, 33,
- 153,242,233,231,232,116,128, 33,152,247,232,233,244,101,128, 33,
- 233,104, 2, 50, 71, 50,122,229,225,100, 4, 50, 83, 50, 93, 50,
- 103, 50,114,228,239,247,238,237,239,100,128, 2,197,236,229,230,
- 244,237,239,100,128, 2,194,242,233,231,232,244,237,239,100,128,
- 2,195,245,240,237,239,100,128, 2,196,239,242,233,250,229,120,
- 128,248,231,236,229,230,116,131, 33,144, 50,144, 50,161, 50,173,
- 228,226,108,129, 33,208, 50,152,243,244,242,239,235,101,128, 33,
- 205,239,246,229,242,242,233,231,232,116,128, 33,198,247,232,233,
- 244,101,128, 33,230,242,233,231,232,116,132, 33,146, 50,197, 50,
- 209, 50,217, 50,228,228,226,236,243,244,242,239,235,101,128, 33,
- 207,232,229,225,246,121,128, 39,158,239,246,229,242,236,229,230,
- 116,128, 33,196,247,232,233,244,101,128, 33,232,244,225, 98, 2,
- 50,244, 50,251,236,229,230,116,128, 33,228,242,233,231,232,116,
- 128, 33,229,245,112,132, 33,145, 51, 16, 51, 44, 51, 62, 51, 70,
- 100, 2, 51, 22, 51, 34,110,129, 33,149, 51, 28,226,243,101,128,
- 33,168,239,247,238,226,225,243,101,128, 33,168,236,229,230,116,
- 129, 33,150, 51, 53,239,230,228,239,247,110,128, 33,197,242,233,
- 231,232,116,128, 33,151,247,232,233,244,101,128, 33,231,246,229,
- 242,244,229,120,128,248,230,115, 5, 51, 99, 51,175, 51,220, 52,
- 47, 52, 57, 99, 2, 51,105, 51,157,233,105, 2, 51,112, 51,135,
- 227,233,242,227,245,109,129, 0, 94, 51,123,237,239,238,239,243,
- 240,225,227,101,128,255, 62,244,233,236,228,101,129, 0,126, 51,
- 145,237,239,238,239,243,240,225,227,101,128,255, 94,242,233,240,
- 116,129, 2, 81, 51,166,244,245,242,238,229,100,128, 2, 82,237,
- 225,236,108, 2, 51,184, 51,195,232,233,242,225,231,225,238, 97,
- 128, 48, 65,235,225,244,225,235,225,238, 97,129, 48,161, 51,208,
- 232,225,236,230,247,233,228,244,104,128,255,103,244,229,242,233,
- 115, 2, 51,230, 52, 43,107,131, 0, 42, 51,240, 52, 12, 52, 35,
- 97, 2, 51,246, 52, 4,236,244,239,238,229,225,242,225,226,233,
- 99,128, 6,109,242,225,226,233, 99,128, 6,109,109, 2, 52, 18,
- 52, 24,225,244,104,128, 34, 23,239,238,239,243,240,225,227,101,
- 128,255, 10,243,237,225,236,108,128,254, 97,109,128, 32, 66,245,
- 240,229,242,233,239,114,128,246,233,249,237,240,244,239,244,233,
- 227,225,236,236,249,229,241,245,225,108,128, 34, 67,116,132, 0,
- 64, 52, 89, 52, 96, 52,108, 52,116,233,236,228,101,128, 0,227,
- 237,239,238,239,243,240,225,227,101,128,255, 32,243,237,225,236,
- 108,128,254,107,245,242,238,229,100,128, 2, 80,117, 6, 52,138,
- 52,163, 52,170, 52,195, 52,215, 52,231, 98, 2, 52,144, 52,153,
- 229,238,231,225,236,105,128, 9,148,239,240,239,237,239,230,111,
- 128, 49, 32,228,229,246, 97,128, 9, 20,231,117, 2, 52,177, 52,
- 186,234,225,242,225,244,105,128, 10,148,242,237,245,235,232,105,
- 128, 10, 20,236,229,238,231,244,232,237,225,242,235,226,229,238,
- 231,225,236,105,128, 9,215,237,225,244,242,225,231,245,242,237,
- 245,235,232,105,128, 10, 76,246,239,247,229,236,243,233,231,110,
- 3, 52,247, 53, 1, 53, 8,226,229,238,231,225,236,105,128, 9,
- 204,228,229,246, 97,128, 9, 76,231,245,234,225,242,225,244,105,
- 128, 10,204,246,225,231,242,225,232,225,228,229,246, 97,128, 9,
- 61,121, 2, 53, 39, 53, 51,226,225,242,237,229,238,233,225,110,
- 128, 5, 97,233,110,130, 5,226, 53, 60, 53, 75,225,236,244,239,
- 238,229,232,229,226,242,229,119,128,251, 32,232,229,226,242,229,
- 119,128, 5,226, 98,144, 0, 98, 53,120, 53,255, 54, 10, 54, 19,
- 54, 44, 55, 85, 55,147, 55,220, 57,146, 57,158, 57,201, 57,209,
- 57,219, 59, 89, 59,113, 59,122, 97, 7, 53,136, 53,146, 53,170,
- 53,177, 53,202, 53,226, 53,237,226,229,238,231,225,236,105,128,
- 9,172,227,235,243,236,225,243,104,129, 0, 92, 53,158,237,239,
- 238,239,243,240,225,227,101,128,255, 60,228,229,246, 97,128, 9,
- 44,231,117, 2, 53,184, 53,193,234,225,242,225,244,105,128, 10,
- 172,242,237,245,235,232,105,128, 10, 44,104, 2, 53,208, 53,218,
- 233,242,225,231,225,238, 97,128, 48,112,244,244,232,225,105,128,
- 14, 63,235,225,244,225,235,225,238, 97,128, 48,208,114,129, 0,
- 124, 53,243,237,239,238,239,243,240,225,227,101,128,255, 92,226,
- 239,240,239,237,239,230,111,128, 49, 5,227,233,242,227,236,101,
- 128, 36,209,228,239,116, 2, 54, 27, 54, 36,225,227,227,229,238,
- 116,128, 30, 3,226,229,236,239,119,128, 30, 5,101, 6, 54, 58,
- 54, 79, 54,102, 54,244, 54,255, 55, 11,225,237,229,228,243,233,
- 248,244,229,229,238,244,232,238,239,244,229,115,128, 38,108, 99,
- 2, 54, 85, 54, 92,225,245,243,101,128, 34, 53,249,242,233,236,
- 236,233, 99,128, 4, 49,104, 5, 54,114, 54,123, 54,137, 54,167,
- 54,226,225,242,225,226,233, 99,128, 6, 40,230,233,238,225,236,
- 225,242,225,226,233, 99,128,254,144,105, 2, 54,143, 54,158,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,254,145,242,225,
- 231,225,238, 97,128, 48,121,237,101, 2, 54,174, 54,187,228,233,
- 225,236,225,242,225,226,233, 99,128,254,146,229,237,105, 2, 54,
- 195, 54,210,238,233,244,233,225,236,225,242,225,226,233, 99,128,
- 252,159,243,239,236,225,244,229,228,225,242,225,226,233, 99,128,
- 252, 8,238,239,239,238,230,233,238,225,236,225,242,225,226,233,
- 99,128,252,109,235,225,244,225,235,225,238, 97,128, 48,217,238,
- 225,242,237,229,238,233,225,110,128, 5, 98,116,132, 5,209, 55,
- 23, 55, 43, 55, 63, 55, 72, 97,129, 3,178, 55, 29,243,249,237,
- 226,239,236,231,242,229,229,107,128, 3,208,228,225,231,229,243,
- 104,129,251, 49, 55, 54,232,229,226,242,229,119,128,251, 49,232,
- 229,226,242,229,119,128, 5,209,242,225,230,229,232,229,226,242,
- 229,119,128,251, 76,104, 2, 55, 91, 55,141, 97, 3, 55, 99, 55,
- 109, 55,116,226,229,238,231,225,236,105,128, 9,173,228,229,246,
- 97,128, 9, 45,231,117, 2, 55,123, 55,132,234,225,242,225,244,
- 105,128, 10,173,242,237,245,235,232,105,128, 10, 45,239,239,107,
- 128, 2, 83,105, 5, 55,159, 55,170, 55,181, 55,195, 55,209,232,
- 233,242,225,231,225,238, 97,128, 48,115,235,225,244,225,235,225,
- 238, 97,128, 48,211,236,225,226,233,225,236,227,236,233,227,107,
- 128, 2,152,238,228,233,231,245,242,237,245,235,232,105,128, 10,
- 2,242,245,243,241,245,225,242,101,128, 51, 49,108, 3, 55,228,
- 57,129, 57,140, 97, 2, 55,234, 57,124,227,107, 6, 55,249, 56,
- 2, 56, 39, 56,188, 56,243, 57, 39,227,233,242,227,236,101,128,
- 37,207,100, 2, 56, 8, 56, 17,233,225,237,239,238,100,128, 37,
- 198,239,247,238,240,239,233,238,244,233,238,231,244,242,233,225,
- 238,231,236,101,128, 37,188,108, 2, 56, 45, 56,148,101, 2, 56,
- 51, 56, 87,230,244,240,239,233,238,244,233,238,103, 2, 56, 66,
- 56, 76,240,239,233,238,244,229,114,128, 37,196,244,242,233,225,
- 238,231,236,101,128, 37,192,238,244,233,227,245,236,225,242,226,
- 242,225,227,235,229,116, 2, 56,107, 56,127,236,229,230,116,129,
- 48, 16, 56,116,246,229,242,244,233,227,225,108,128,254, 59,242,
- 233,231,232,116,129, 48, 17, 56,137,246,229,242,244,233,227,225,
- 108,128,254, 60,239,247,229,114, 2, 56,157, 56,172,236,229,230,
- 244,244,242,233,225,238,231,236,101,128, 37,227,242,233,231,232,
- 244,244,242,233,225,238,231,236,101,128, 37,226,114, 2, 56,194,
- 56,205,229,227,244,225,238,231,236,101,128, 37,172,233,231,232,
- 244,240,239,233,238,244,233,238,103, 2, 56,222, 56,232,240,239,
- 233,238,244,229,114,128, 37,186,244,242,233,225,238,231,236,101,
- 128, 37,182,115, 3, 56,251, 57, 25, 57, 33,109, 2, 57, 1, 57,
- 13,225,236,236,243,241,245,225,242,101,128, 37,170,233,236,233,
- 238,231,230,225,227,101,128, 38, 59,241,245,225,242,101,128, 37,
- 160,244,225,114,128, 38, 5,245,240,112, 2, 57, 47, 57, 85,229,
- 114, 2, 57, 54, 57, 69,236,229,230,244,244,242,233,225,238,231,
- 236,101,128, 37,228,242,233,231,232,244,244,242,233,225,238,231,
- 236,101,128, 37,229,239,233,238,244,233,238,103, 2, 57, 97, 57,
- 113,243,237,225,236,236,244,242,233,225,238,231,236,101,128, 37,
- 180,244,242,233,225,238,231,236,101,128, 37,178,238,107,128, 36,
- 35,233,238,229,226,229,236,239,119,128, 30, 7,239,227,107,128,
- 37,136,237,239,238,239,243,240,225,227,101,128,255, 66,111, 3,
- 57,166, 57,179, 57,190,226,225,233,237,225,233,244,232,225,105,
- 128, 14, 26,232,233,242,225,231,225,238, 97,128, 48,124,235,225,
- 244,225,235,225,238, 97,128, 48,220,240,225,242,229,110,128, 36,
- 157,241,243,241,245,225,242,101,128, 51,195,114, 4, 57,229, 58,
- 223, 59, 40, 59, 79,225, 99, 2, 57,236, 58,130,101, 3, 57,244,
- 57,249, 58, 61,229,120,128,248,244,236,229,230,116,133, 0,123,
- 58, 10, 58, 15, 58, 37, 58, 45, 58, 50,226,116,128,248,243,109,
- 2, 58, 21, 58, 26,233,100,128,248,242,239,238,239,243,240,225,
- 227,101,128,255, 91,243,237,225,236,108,128,254, 91,244,112,128,
- 248,241,246,229,242,244,233,227,225,108,128,254, 55,242,233,231,
- 232,116,133, 0,125, 58, 79, 58, 84, 58,106, 58,114, 58,119,226,
- 116,128,248,254,109, 2, 58, 90, 58, 95,233,100,128,248,253,239,
- 238,239,243,240,225,227,101,128,255, 93,243,237,225,236,108,128,
- 254, 92,244,112,128,248,252,246,229,242,244,233,227,225,108,128,
- 254, 56,235,229,116, 2, 58,138, 58,180,236,229,230,116,132, 0,
- 91, 58,153, 58,158, 58,163, 58,175,226,116,128,248,240,229,120,
- 128,248,239,237,239,238,239,243,240,225,227,101,128,255, 59,244,
- 112,128,248,238,242,233,231,232,116,132, 0, 93, 58,196, 58,201,
- 58,206, 58,218,226,116,128,248,251,229,120,128,248,250,237,239,
- 238,239,243,240,225,227,101,128,255, 61,244,112,128,248,249,229,
- 246,101,131, 2,216, 58,235, 58,246, 58,252,226,229,236,239,247,
- 227,237, 98,128, 3, 46,227,237, 98,128, 3, 6,233,238,246,229,
- 242,244,229,100, 3, 59, 11, 59, 22, 59, 28,226,229,236,239,247,
- 227,237, 98,128, 3, 47,227,237, 98,128, 3, 17,228,239,245,226,
- 236,229,227,237, 98,128, 3, 97,233,228,231,101, 2, 59, 49, 59,
- 60,226,229,236,239,247,227,237, 98,128, 3, 42,233,238,246,229,
- 242,244,229,228,226,229,236,239,247,227,237, 98,128, 3, 58,239,
- 235,229,238,226,225,114,128, 0,166,115, 2, 59, 95, 59,103,244,
- 242,239,235,101,128, 1,128,245,240,229,242,233,239,114,128,246,
- 234,244,239,240,226,225,114,128, 1,131,117, 3, 59,130, 59,141,
- 59,152,232,233,242,225,231,225,238, 97,128, 48,118,235,225,244,
- 225,235,225,238, 97,128, 48,214,236,108, 2, 59,159, 59,189,229,
- 116,130, 32, 34, 59,168, 59,178,233,238,246,229,242,243,101,128,
- 37,216,239,240,229,242,225,244,239,114,128, 34, 25,243,229,249,
- 101,128, 37,206, 99,143, 0, 99, 59,230, 60,179, 60,190, 60,254,
- 61, 29, 61,122, 63, 33, 64, 17, 64,117, 64,166, 67,158, 67,166,
- 67,176, 67,188, 67,221, 97, 9, 59,250, 60, 5, 60, 15, 60, 22,
- 60, 29, 60, 54, 60, 64, 60,116, 60,125,225,242,237,229,238,233,
- 225,110,128, 5,110,226,229,238,231,225,236,105,128, 9,154,227,
- 245,244,101,128, 1, 7,228,229,246, 97,128, 9, 26,231,117, 2,
- 60, 36, 60, 45,234,225,242,225,244,105,128, 10,154,242,237,245,
- 235,232,105,128, 10, 26,236,243,241,245,225,242,101,128, 51,136,
- 238,228,242,225,226,233,238,228,117, 4, 60, 82, 60, 92, 60, 98,
- 60,105,226,229,238,231,225,236,105,128, 9,129,227,237, 98,128,
- 3, 16,228,229,246, 97,128, 9, 1,231,245,234,225,242,225,244,
- 105,128, 10,129,240,243,236,239,227,107,128, 33,234,114, 3, 60,
- 133, 60,139, 60,165,229,239,102,128, 33, 5,239,110,130, 2,199,
- 60,148, 60,159,226,229,236,239,247,227,237, 98,128, 3, 44,227,
- 237, 98,128, 3, 12,242,233,225,231,229,242,229,244,245,242,110,
- 128, 33,181,226,239,240,239,237,239,230,111,128, 49, 24, 99, 4,
- 60,200, 60,207, 60,226, 60,248,225,242,239,110,128, 1, 13,229,
- 228,233,236,236, 97,129, 0,231, 60,218,225,227,245,244,101,128,
- 30, 9,233,242, 99, 2, 60,234, 60,239,236,101,128, 36,210,245,
- 237,230,236,229,120,128, 1, 9,245,242,108,128, 2, 85,100, 2,
- 61, 4, 61, 20,239,116,129, 1, 11, 61, 11,225,227,227,229,238,
- 116,128, 1, 11,243,241,245,225,242,101,128, 51,197,101, 2, 61,
- 35, 61, 51,228,233,236,236, 97,129, 0,184, 61, 45,227,237, 98,
- 128, 3, 39,238,116,132, 0,162, 61, 64, 61, 88, 61,100, 61,111,
- 105, 2, 61, 70, 61, 78,231,242,225,228,101,128, 33, 3,238,230,
- 229,242,233,239,114,128,246,223,237,239,238,239,243,240,225,227,
- 101,128,255,224,239,236,228,243,244,249,236,101,128,247,162,243,
- 245,240,229,242,233,239,114,128,246,224,104, 5, 61,134, 61,197,
- 61,208, 62,136, 62,228, 97, 4, 61,144, 61,155, 61,165, 61,172,
- 225,242,237,229,238,233,225,110,128, 5,121,226,229,238,231,225,
- 236,105,128, 9,155,228,229,246, 97,128, 9, 27,231,117, 2, 61,
- 179, 61,188,234,225,242,225,244,105,128, 10,155,242,237,245,235,
- 232,105,128, 10, 27,226,239,240,239,237,239,230,111,128, 49, 20,
- 101, 6, 61,222, 61,242, 62, 10, 62, 78, 62, 90, 62,111,225,226,
- 235,232,225,243,233,225,238,227,249,242,233,236,236,233, 99,128,
- 4,189, 99, 2, 61,248, 62, 0,235,237,225,242,107,128, 39, 19,
- 249,242,233,236,236,233, 99,128, 4, 71,100, 2, 62, 16, 62, 60,
- 229,243,227,229,238,228,229,114, 2, 62, 29, 62, 49,225,226,235,
- 232,225,243,233,225,238,227,249,242,233,236,236,233, 99,128, 4,
- 191,227,249,242,233,236,236,233, 99,128, 4,183,233,229,242,229,
- 243,233,243,227,249,242,233,236,236,233, 99,128, 4,245,232,225,
- 242,237,229,238,233,225,110,128, 5,115,235,232,225,235,225,243,
- 243,233,225,238,227,249,242,233,236,236,233, 99,128, 4,204,246,
- 229,242,244,233,227,225,236,243,244,242,239,235,229,227,249,242,
- 233,236,236,233, 99,128, 4,185,105,129, 3,199, 62,142,229,245,
- 227,104, 4, 62,155, 62,190, 62,205, 62,214, 97, 2, 62,161, 62,
- 176,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,119,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 23,227,233,
- 242,227,236,229,235,239,242,229,225,110,128, 50,105,235,239,242,
- 229,225,110,128, 49, 74,240,225,242,229,238,235,239,242,229,225,
- 110,128, 50, 9,111, 2, 62,234, 63, 28,227,104, 3, 62,243, 63,
- 9, 63, 19,225,110, 2, 62,250, 63, 2,231,244,232,225,105,128,
- 14, 10,244,232,225,105,128, 14, 8,233,238,231,244,232,225,105,
- 128, 14, 9,239,229,244,232,225,105,128, 14, 12,239,107,128, 1,
- 136,105, 2, 63, 39, 63,141,229,245, 99, 5, 63, 53, 63, 88, 63,
- 103, 63,112, 63,126, 97, 2, 63, 59, 63, 74,227,233,242,227,236,
- 229,235,239,242,229,225,110,128, 50,118,240,225,242,229,238,235,
- 239,242,229,225,110,128, 50, 22,227,233,242,227,236,229,235,239,
- 242,229,225,110,128, 50,104,235,239,242,229,225,110,128, 49, 72,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 8,245,240,
- 225,242,229,238,235,239,242,229,225,110,128, 50, 28,242, 99, 2,
- 63,148, 63,243,236,101,132, 37,203, 63,161, 63,172, 63,177, 63,
- 201,237,245,236,244,233,240,236,121,128, 34,151,239,116,128, 34,
- 153,112, 2, 63,183, 63,189,236,245,115,128, 34,149,239,243,244,
- 225,236,237,225,242,107,128, 48, 54,247,233,244,104, 2, 63,210,
- 63,226,236,229,230,244,232,225,236,230,226,236,225,227,107,128,
- 37,208,242,233,231,232,244,232,225,236,230,226,236,225,227,107,
- 128, 37,209,245,237,230,236,229,120,130, 2,198, 64, 0, 64, 11,
- 226,229,236,239,247,227,237, 98,128, 3, 45,227,237, 98,128, 3,
- 2,108, 3, 64, 25, 64, 31, 64, 85,229,225,114,128, 35, 39,233,
- 227,107, 4, 64, 43, 64, 54, 64, 63, 64, 73,225,236,246,229,239,
- 236,225,114,128, 1,194,228,229,238,244,225,108,128, 1,192,236,
- 225,244,229,242,225,108,128, 1,193,242,229,244,242,239,230,236,
- 229,120,128, 1,195,245, 98,129, 38, 99, 64, 92,243,245,233,116,
- 2, 64,101, 64,109,226,236,225,227,107,128, 38, 99,247,232,233,
- 244,101,128, 38,103,109, 3, 64,125, 64,139, 64,150,227,245,226,
- 229,228,243,241,245,225,242,101,128, 51,164,239,238,239,243,240,
- 225,227,101,128,255, 67,243,241,245,225,242,229,228,243,241,245,
- 225,242,101,128, 51,160,111, 8, 64,184, 64,195, 65, 26, 65,224,
- 66,253, 67, 28, 67,135, 67,144,225,242,237,229,238,233,225,110,
- 128, 5,129,236,239,110,131, 0, 58, 64,207, 64,232, 64,251,237,
- 239,110, 2, 64,215, 64,223,229,244,225,242,121,128, 32,161,239,
- 243,240,225,227,101,128,255, 26,115, 2, 64,238, 64,244,233,231,
- 110,128, 32,161,237,225,236,108,128,254, 85,244,242,233,225,238,
- 231,245,236,225,114, 2, 65, 10, 65, 20,232,225,236,230,237,239,
- 100,128, 2,209,237,239,100,128, 2,208,109, 2, 65, 32, 65,217,
- 237, 97,134, 0, 44, 65, 49, 65,113, 65,124, 65,136, 65,166, 65,
- 189, 97, 3, 65, 57, 65, 83, 65, 91,226,239,246,101, 2, 65, 66,
- 65, 72,227,237, 98,128, 3, 19,242,233,231,232,244,227,237, 98,
- 128, 3, 21,227,227,229,238,116,128,246,195,114, 2, 65, 97, 65,
- 104,225,226,233, 99,128, 6, 12,237,229,238,233,225,110,128, 5,
- 93,233,238,230,229,242,233,239,114,128,246,225,237,239,238,239,
- 243,240,225,227,101,128,255, 12,242,229,246,229,242,243,229,100,
- 2, 65,149, 65,160,225,226,239,246,229,227,237, 98,128, 3, 20,
- 237,239,100,128, 2,189,115, 2, 65,172, 65,179,237,225,236,108,
- 128,254, 80,245,240,229,242,233,239,114,128,246,226,244,245,242,
- 238,229,100, 2, 65,200, 65,211,225,226,239,246,229,227,237, 98,
- 128, 3, 18,237,239,100,128, 2,187,240,225,243,115,128, 38, 60,
- 110, 2, 65,230, 65,239,231,242,245,229,238,116,128, 34, 69,116,
- 2, 65,245, 66, 3,239,245,242,233,238,244,229,231,242,225,108,
- 128, 34, 46,242,239,108,142, 35, 3, 66, 37, 66, 43, 66, 58, 66,
- 73, 66,117, 66,162, 66,176, 66,181, 66,186, 66,191, 66,197, 66,
- 202, 66,243, 66,248,193,195, 75,128, 0, 6, 66, 2, 66, 49, 66,
- 54,197, 76,128, 0, 7, 83,128, 0, 8, 67, 2, 66, 64, 66, 69,
- 193, 78,128, 0, 24, 82,128, 0, 13, 68, 3, 66, 81, 66,107, 66,
- 112, 67, 4, 66, 91, 66, 95, 66, 99, 66,103, 49,128, 0, 17, 50,
- 128, 0, 18, 51,128, 0, 19, 52,128, 0, 20,197, 76,128, 0,127,
- 204, 69,128, 0, 16, 69, 5, 66,129, 66,133, 66,138, 66,143, 66,
- 148, 77,128, 0, 25,206, 81,128, 0, 5,207, 84,128, 0, 4,211,
- 67,128, 0, 27, 84, 2, 66,154, 66,158, 66,128, 0, 23, 88,128,
- 0, 3, 70, 2, 66,168, 66,172, 70,128, 0, 12, 83,128, 0, 28,
- 199, 83,128, 0, 29,200, 84,128, 0, 9,204, 70,128, 0, 10,206,
- 193, 75,128, 0, 21,210, 83,128, 0, 30, 83, 5, 66,214, 66,218,
- 66,228, 66,233, 66,238, 73,128, 0, 15, 79,129, 0, 14, 66,224,
- 84,128, 0, 2,212, 88,128, 0, 1,213, 66,128, 0, 26,217, 78,
- 128, 0, 22,213, 83,128, 0, 31,214, 84,128, 0, 11,240,249,242,
- 233,231,232,116,129, 0,169, 67, 9,115, 2, 67, 15, 67, 21,225,
- 238,115,128,248,233,229,242,233,102,128,246,217,114, 2, 67, 34,
- 67,118,238,229,242,226,242,225,227,235,229,116, 2, 67, 49, 67,
- 83,236,229,230,116,130, 48, 12, 67, 60, 67, 72,232,225,236,230,
- 247,233,228,244,104,128,255, 98,246,229,242,244,233,227,225,108,
- 128,254, 65,242,233,231,232,116,130, 48, 13, 67, 95, 67,107,232,
- 225,236,230,247,233,228,244,104,128,255, 99,246,229,242,244,233,
- 227,225,108,128,254, 66,240,239,242,225,244,233,239,238,243,241,
- 245,225,242,101,128, 51,127,243,241,245,225,242,101,128, 51,199,
- 246,229,242,235,231,243,241,245,225,242,101,128, 51,198,240,225,
- 242,229,110,128, 36,158,242,245,250,229,233,242,111,128, 32,162,
- 243,244,242,229,244,227,232,229,100,128, 2,151,245,114, 2, 67,
- 195, 67,213,236,121, 2, 67,202, 67,208,225,238,100,128, 34,207,
- 239,114,128, 34,206,242,229,238,227,121,128, 0,164,249,114, 4,
- 67,232, 67,240, 67,247, 67,255,194,242,229,246,101,128,246,209,
- 198,236,229,120,128,246,210,226,242,229,246,101,128,246,212,230,
- 236,229,120,128,246,213,100,146, 0,100, 68, 46, 69,184, 70,208,
- 71, 12, 71,188, 72,142, 72,204, 73,133, 73,146, 73,155, 73,181,
- 73,206, 73,215, 75, 26, 75, 34, 75, 45, 75, 65, 75, 93, 97, 11,
- 68, 70, 68, 81, 68, 91, 68,163, 68,226, 68,237, 68,248, 69, 61,
- 69,123, 69,129, 69,159,225,242,237,229,238,233,225,110,128, 5,
- 100,226,229,238,231,225,236,105,128, 9,166,100, 5, 68,103, 68,
- 112, 68,118, 68,132, 68,148,225,242,225,226,233, 99,128, 6, 54,
- 229,246, 97,128, 9, 38,230,233,238,225,236,225,242,225,226,233,
- 99,128,254,190,233,238,233,244,233,225,236,225,242,225,226,233,
- 99,128,254,191,237,229,228,233,225,236,225,242,225,226,233, 99,
- 128,254,192,103, 3, 68,171, 68,188, 68,202,229,243,104,129, 5,
- 188, 68,179,232,229,226,242,229,119,128, 5,188,231,229,114,129,
- 32, 32, 68,196,228,226,108,128, 32, 33,117, 2, 68,208, 68,217,
- 234,225,242,225,244,105,128, 10,166,242,237,245,235,232,105,128,
- 10, 38,232,233,242,225,231,225,238, 97,128, 48, 96,235,225,244,
- 225,235,225,238, 97,128, 48,192,108, 3, 69, 0, 69, 9, 69, 47,
- 225,242,225,226,233, 99,128, 6, 47,229,116,130, 5,211, 69, 18,
- 69, 38,228,225,231,229,243,104,129,251, 51, 69, 29,232,229,226,
- 242,229,119,128,251, 51,232,229,226,242,229,119,128, 5,211,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,170,237,237, 97,
- 3, 69, 71, 69, 80, 69, 92,225,242,225,226,233, 99,128, 6, 79,
- 236,239,247,225,242,225,226,233, 99,128, 6, 79,244,225,238, 97,
- 2, 69,101, 69,115,236,244,239,238,229,225,242,225,226,233, 99,
- 128, 6, 76,242,225,226,233, 99,128, 6, 76,238,228, 97,128, 9,
- 100,242,231, 97, 2, 69,137, 69,146,232,229,226,242,229,119,128,
- 5,167,236,229,230,244,232,229,226,242,229,119,128, 5,167,243,
- 233,225,240,238,229,245,237,225,244,225,227,249,242,233,236,236,
- 233,227,227,237, 98,128, 4,133, 98, 3, 69,192, 70,189, 70,199,
- 108, 9, 69,212, 69,220, 70, 77, 70, 85, 70,101, 70,112, 70,130,
- 70,144, 70,155,199,242,225,246,101,128,246,211, 97, 2, 69,226,
- 70, 27,238,231,236,229,226,242,225,227,235,229,116, 2, 69,242,
- 70, 6,236,229,230,116,129, 48, 10, 69,251,246,229,242,244,233,
- 227,225,108,128,254, 61,242,233,231,232,116,129, 48, 11, 70, 16,
- 246,229,242,244,233,227,225,108,128,254, 62,114, 2, 70, 33, 70,
- 54,227,232,233,238,246,229,242,244,229,228,226,229,236,239,247,
- 227,237, 98,128, 3, 43,242,239,119, 2, 70, 62, 70, 69,236,229,
- 230,116,128, 33,212,242,233,231,232,116,128, 33,210,228,225,238,
- 228, 97,128, 9,101,231,242,225,246,101,129,246,214, 70, 95,227,
- 237, 98,128, 3, 15,233,238,244,229,231,242,225,108,128, 34, 44,
- 236,239,247,236,233,238,101,129, 32, 23, 70,124,227,237, 98,128,
- 3, 51,239,246,229,242,236,233,238,229,227,237, 98,128, 3, 63,
- 240,242,233,237,229,237,239,100,128, 2,186,246,229,242,244,233,
- 227,225,108, 2, 70,168, 70,174,226,225,114,128, 32, 22,236,233,
- 238,229,225,226,239,246,229,227,237, 98,128, 3, 14,239,240,239,
- 237,239,230,111,128, 49, 9,243,241,245,225,242,101,128, 51,200,
- 99, 4, 70,218, 70,225, 70,234, 71, 5,225,242,239,110,128, 1,
- 15,229,228,233,236,236, 97,128, 30, 17,233,242, 99, 2, 70,242,
- 70,247,236,101,128, 36,211,245,237,230,236,229,248,226,229,236,
- 239,119,128, 30, 19,242,239,225,116,128, 1, 17,100, 4, 71, 22,
- 71,103, 71,113, 71,164, 97, 4, 71, 32, 71, 42, 71, 49, 71, 74,
- 226,229,238,231,225,236,105,128, 9,161,228,229,246, 97,128, 9,
- 33,231,117, 2, 71, 56, 71, 65,234,225,242,225,244,105,128, 10,
- 161,242,237,245,235,232,105,128, 10, 33,108, 2, 71, 80, 71, 89,
- 225,242,225,226,233, 99,128, 6,136,230,233,238,225,236,225,242,
- 225,226,233, 99,128,251,137,228,232,225,228,229,246, 97,128, 9,
- 92,232, 97, 3, 71,122, 71,132, 71,139,226,229,238,231,225,236,
- 105,128, 9,162,228,229,246, 97,128, 9, 34,231,117, 2, 71,146,
- 71,155,234,225,242,225,244,105,128, 10,162,242,237,245,235,232,
- 105,128, 10, 34,239,116, 2, 71,171, 71,180,225,227,227,229,238,
- 116,128, 30, 11,226,229,236,239,119,128, 30, 13,101, 8, 71,206,
- 72, 3, 72, 10, 72, 35, 72, 45, 72, 56, 72,101, 72,137, 99, 2,
- 71,212, 71,249,233,237,225,236,243,229,240,225,242,225,244,239,
- 114, 2, 71,230, 71,239,225,242,225,226,233, 99,128, 6,107,240,
- 229,242,243,233,225,110,128, 6,107,249,242,233,236,236,233, 99,
- 128, 4, 52,231,242,229,101,128, 0,176,232,105, 2, 72, 17, 72,
- 26,232,229,226,242,229,119,128, 5,173,242,225,231,225,238, 97,
- 128, 48,103,233,227,239,240,244,233, 99,128, 3,239,235,225,244,
- 225,235,225,238, 97,128, 48,199,108, 2, 72, 62, 72, 85,229,244,
- 101, 2, 72, 70, 72, 77,236,229,230,116,128, 35, 43,242,233,231,
- 232,116,128, 35, 38,244, 97,129, 3,180, 72, 92,244,245,242,238,
- 229,100,128, 1,141,238,239,237,233,238,225,244,239,242,237,233,
- 238,245,243,239,238,229,238,245,237,229,242,225,244,239,242,226,
- 229,238,231,225,236,105,128, 9,248,250,104,128, 2,164,104, 2,
- 72,148, 72,198, 97, 3, 72,156, 72,166, 72,173,226,229,238,231,
- 225,236,105,128, 9,167,228,229,246, 97,128, 9, 39,231,117, 2,
- 72,180, 72,189,234,225,242,225,244,105,128, 10,167,242,237,245,
- 235,232,105,128, 10, 39,239,239,107,128, 2, 87,105, 6, 72,218,
- 73, 11, 73, 71, 73, 82, 73, 93, 73,103, 97, 2, 72,224, 72,246,
- 236,249,244,233,235,225,244,239,238,239,115,129, 3,133, 72,240,
- 227,237, 98,128, 3, 68,237,239,238,100,129, 38,102, 72,255,243,
- 245,233,244,247,232,233,244,101,128, 38, 98,229,242,229,243,233,
- 115,133, 0,168, 73, 30, 73, 38, 73, 49, 73, 55, 73, 63,225,227,
- 245,244,101,128,246,215,226,229,236,239,247,227,237, 98,128, 3,
- 36,227,237, 98,128, 3, 8,231,242,225,246,101,128,246,216,244,
- 239,238,239,115,128, 3,133,232,233,242,225,231,225,238, 97,128,
- 48, 98,235,225,244,225,235,225,238, 97,128, 48,194,244,244,239,
- 237,225,242,107,128, 48, 3,246,105, 2, 73,110, 73,121,228,101,
- 129, 0,247, 73,117,115,128, 34, 35,243,233,239,238,243,236,225,
- 243,104,128, 34, 21,234,229,227,249,242,233,236,236,233, 99,128,
- 4, 82,235,243,232,225,228,101,128, 37,147,108, 2, 73,161, 73,
- 172,233,238,229,226,229,236,239,119,128, 30, 15,243,241,245,225,
- 242,101,128, 51,151,109, 2, 73,187, 73,195,225,227,242,239,110,
- 128, 1, 17,239,238,239,243,240,225,227,101,128,255, 68,238,226,
- 236,239,227,107,128, 37,132,111, 10, 73,237, 73,249, 74, 3, 74,
- 14, 74, 25, 74, 97, 74,102, 74,113, 74,228, 74,254,227,232,225,
- 228,225,244,232,225,105,128, 14, 14,228,229,235,244,232,225,105,
- 128, 14, 20,232,233,242,225,231,225,238, 97,128, 48,105,235,225,
- 244,225,235,225,238, 97,128, 48,201,236,236,225,114,132, 0, 36,
- 74, 40, 74, 51, 74, 63, 74, 74,233,238,230,229,242,233,239,114,
- 128,246,227,237,239,238,239,243,240,225,227,101,128,255, 4,239,
- 236,228,243,244,249,236,101,128,247, 36,115, 2, 74, 80, 74, 87,
- 237,225,236,108,128,254,105,245,240,229,242,233,239,114,128,246,
- 228,238,103,128, 32,171,242,245,243,241,245,225,242,101,128, 51,
- 38,116, 6, 74,127, 74,144, 74,166, 74,177, 74,209, 74,216,225,
- 227,227,229,238,116,129, 2,217, 74,138,227,237, 98,128, 3, 7,
- 226,229,236,239,247, 99, 2, 74,155, 74,160,237, 98,128, 3, 35,
- 239,237, 98,128, 3, 35,235,225,244,225,235,225,238, 97,128, 48,
- 251,236,229,243,115, 2, 74,186, 74,190,105,128, 1, 49,106,129,
- 246,190, 74,196,243,244,242,239,235,229,232,239,239,107,128, 2,
- 132,237,225,244,104,128, 34,197,244,229,228,227,233,242,227,236,
- 101,128, 37,204,245,226,236,229,249,239,228,240,225,244,225,104,
- 129,251, 31, 74,245,232,229,226,242,229,119,128,251, 31,247,238,
- 244,225,227,107, 2, 75, 9, 75, 20,226,229,236,239,247,227,237,
- 98,128, 3, 30,237,239,100,128, 2,213,240,225,242,229,110,128,
- 36,159,243,245,240,229,242,233,239,114,128,246,235,116, 2, 75,
- 51, 75, 57,225,233,108,128, 2, 86,239,240,226,225,114,128, 1,
- 140,117, 2, 75, 71, 75, 82,232,233,242,225,231,225,238, 97,128,
- 48,101,235,225,244,225,235,225,238, 97,128, 48,197,122,132, 1,
- 243, 75,105, 75,114, 75,133, 75,170,225,236,244,239,238,101,128,
- 2,163, 99, 2, 75,120, 75,127,225,242,239,110,128, 1,198,245,
- 242,108,128, 2,165,101, 2, 75,139, 75,159,225,226,235,232,225,
- 243,233,225,238,227,249,242,233,236,236,233, 99,128, 4,225,227,
- 249,242,233,236,236,233, 99,128, 4, 85,232,229,227,249,242,233,
- 236,236,233, 99,128, 4, 95,101,151, 0,101, 75,233, 75,252, 76,
- 30, 77, 4, 77, 66, 77, 99, 77,111, 77,134, 77,187, 79, 43, 79,
- 101, 79,203, 80, 63, 80,198, 81, 17, 81, 48, 81,110, 81,163, 82,
- 98, 82,231, 82,251, 83, 39, 83,130, 97, 2, 75,239, 75,246,227,
- 245,244,101,128, 0,233,242,244,104,128, 38, 65, 98, 3, 76, 4,
- 76, 13, 76, 23,229,238,231,225,236,105,128, 9,143,239,240,239,
- 237,239,230,111,128, 49, 28,242,229,246,101,128, 1, 21, 99, 5,
- 76, 42, 76,115, 76,129, 76,161, 76,250, 97, 2, 76, 48, 76,109,
- 238,228,242, 97, 3, 76, 59, 76, 66, 76, 77,228,229,246, 97,128,
- 9, 13,231,245,234,225,242,225,244,105,128, 10,141,246,239,247,
- 229,236,243,233,231,110, 2, 76, 91, 76, 98,228,229,246, 97,128,
- 9, 69,231,245,234,225,242,225,244,105,128, 10,197,242,239,110,
- 128, 1, 27,229,228,233,236,236,225,226,242,229,246,101,128, 30,
- 29,104, 2, 76,135, 76,146,225,242,237,229,238,233,225,110,128,
- 5,101,249,233,247,238,225,242,237,229,238,233,225,110,128, 5,
- 135,233,242, 99, 2, 76,169, 76,174,236,101,128, 36,212,245,237,
- 230,236,229,120,134, 0,234, 76,195, 76,203, 76,211, 76,222, 76,
- 230, 76,242,225,227,245,244,101,128, 30,191,226,229,236,239,119,
- 128, 30, 25,228,239,244,226,229,236,239,119,128, 30,199,231,242,
- 225,246,101,128, 30,193,232,239,239,235,225,226,239,246,101,128,
- 30,195,244,233,236,228,101,128, 30,197,249,242,233,236,236,233,
- 99,128, 4, 84,100, 4, 77, 14, 77, 24, 77, 30, 77, 40,226,236,
- 231,242,225,246,101,128, 2, 5,229,246, 97,128, 9, 15,233,229,
- 242,229,243,233,115,128, 0,235,239,116,130, 1, 23, 77, 49, 77,
- 58,225,227,227,229,238,116,128, 1, 23,226,229,236,239,119,128,
- 30,185,101, 2, 77, 72, 77, 83,231,245,242,237,245,235,232,105,
- 128, 10, 15,237,225,244,242,225,231,245,242,237,245,235,232,105,
- 128, 10, 71,230,227,249,242,233,236,236,233, 99,128, 4, 68,103,
- 2, 77,117, 77,124,242,225,246,101,128, 0,232,245,234,225,242,
- 225,244,105,128, 10,143,104, 4, 77,144, 77,155, 77,166, 77,176,
- 225,242,237,229,238,233,225,110,128, 5,103,226,239,240,239,237,
- 239,230,111,128, 49, 29,233,242,225,231,225,238, 97,128, 48, 72,
- 239,239,235,225,226,239,246,101,128, 30,187,105, 4, 77,197, 77,
- 208, 79, 10, 79, 25,226,239,240,239,237,239,230,111,128, 49, 31,
- 231,232,116,142, 0, 56, 77,242, 77,251, 78, 5, 78, 35, 78, 42,
- 78, 80, 78,105, 78,150, 78,184, 78,196, 78,207, 78,240, 78,248,
- 79, 3,225,242,225,226,233, 99,128, 6,104,226,229,238,231,225,
- 236,105,128, 9,238,227,233,242,227,236,101,129, 36,103, 78, 16,
- 233,238,246,229,242,243,229,243,225,238,243,243,229,242,233,102,
- 128, 39,145,228,229,246, 97,128, 9,110,229,229,110, 2, 78, 50,
- 78, 59,227,233,242,227,236,101,128, 36,113,112, 2, 78, 65, 78,
- 72,225,242,229,110,128, 36,133,229,242,233,239,100,128, 36,153,
- 231,117, 2, 78, 87, 78, 96,234,225,242,225,244,105,128, 10,238,
- 242,237,245,235,232,105,128, 10,110,104, 2, 78,111, 78,137, 97,
- 2, 78,117, 78,128,227,235,225,242,225,226,233, 99,128, 6,104,
- 238,231,250,232,239,117,128, 48, 40,238,239,244,229,226,229,225,
- 237,229,100,128, 38,107,105, 2, 78,156, 78,174,228,229,239,231,
- 242,225,240,232,233,227,240,225,242,229,110,128, 50, 39,238,230,
- 229,242,233,239,114,128, 32,136,237,239,238,239,243,240,225,227,
- 101,128,255, 24,239,236,228,243,244,249,236,101,128,247, 56,112,
- 2, 78,213, 78,220,225,242,229,110,128, 36,123,229,114, 2, 78,
- 227, 78,233,233,239,100,128, 36,143,243,233,225,110,128, 6,248,
- 242,239,237,225,110,128, 33,119,243,245,240,229,242,233,239,114,
- 128, 32,120,244,232,225,105,128, 14, 88,238,246,229,242,244,229,
- 228,226,242,229,246,101,128, 2, 7,239,244,233,230,233,229,228,
- 227,249,242,233,236,236,233, 99,128, 4,101,107, 2, 79, 49, 79,
- 73,225,244,225,235,225,238, 97,129, 48,168, 79, 61,232,225,236,
- 230,247,233,228,244,104,128,255,116,111, 2, 79, 79, 79, 94,238,
- 235,225,242,231,245,242,237,245,235,232,105,128, 10,116,242,229,
- 225,110,128, 49, 84,108, 3, 79,109, 79,120, 79,181,227,249,242,
- 233,236,236,233, 99,128, 4, 59,101, 2, 79,126, 79,133,237,229,
- 238,116,128, 34, 8,246,229,110, 3, 79,143, 79,152, 79,173,227,
- 233,242,227,236,101,128, 36,106,112, 2, 79,158, 79,165,225,242,
- 229,110,128, 36,126,229,242,233,239,100,128, 36,146,242,239,237,
- 225,110,128, 33,122,236,233,240,243,233,115,129, 32, 38, 79,192,
- 246,229,242,244,233,227,225,108,128, 34,238,109, 5, 79,215, 79,
- 243, 79,254, 80, 18, 80, 29,225,227,242,239,110,130, 1, 19, 79,
- 227, 79,235,225,227,245,244,101,128, 30, 23,231,242,225,246,101,
- 128, 30, 21,227,249,242,233,236,236,233, 99,128, 4, 60,228,225,
- 243,104,129, 32, 20, 80, 7,246,229,242,244,233,227,225,108,128,
- 254, 49,239,238,239,243,240,225,227,101,128,255, 69,112, 2, 80,
- 35, 80, 55,232,225,243,233,243,237,225,242,235,225,242,237,229,
- 238,233,225,110,128, 5, 91,244,249,243,229,116,128, 34, 5,110,
- 6, 80, 77, 80, 88, 80, 99, 80,143, 80,175, 80,190,226,239,240,
- 239,237,239,230,111,128, 49, 35,227,249,242,233,236,236,233, 99,
- 128, 4, 61,100, 2, 80,105, 80,124,225,243,104,129, 32, 19, 80,
- 113,246,229,242,244,233,227,225,108,128,254, 50,229,243,227,229,
- 238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,163,103,
- 130, 1, 75, 80,151, 80,162,226,239,240,239,237,239,230,111,128,
- 49, 37,232,229,227,249,242,233,236,236,233, 99,128, 4,165,232,
- 239,239,235,227,249,242,233,236,236,233, 99,128, 4,200,243,240,
- 225,227,101,128, 32, 2,111, 3, 80,206, 80,214, 80,223,231,239,
- 238,229,107,128, 1, 25,235,239,242,229,225,110,128, 49, 83,240,
- 229,110,130, 2, 91, 80,233, 80,242,227,236,239,243,229,100,128,
- 2,154,242,229,246,229,242,243,229,100,130, 2, 92, 81, 1, 81,
- 10,227,236,239,243,229,100,128, 2, 94,232,239,239,107,128, 2,
- 93,112, 2, 81, 23, 81, 30,225,242,229,110,128, 36,160,243,233,
- 236,239,110,129, 3,181, 81, 40,244,239,238,239,115,128, 3,173,
- 241,117, 2, 81, 55, 81, 99,225,108,130, 0, 61, 81, 64, 81, 76,
- 237,239,238,239,243,240,225,227,101,128,255, 29,115, 2, 81, 82,
- 81, 89,237,225,236,108,128,254,102,245,240,229,242,233,239,114,
- 128, 32,124,233,246,225,236,229,238,227,101,128, 34, 97,114, 3,
- 81,118, 81,129, 81,140,226,239,240,239,237,239,230,111,128, 49,
- 38,227,249,242,233,236,236,233, 99,128, 4, 64,229,246,229,242,
- 243,229,100,129, 2, 88, 81,152,227,249,242,233,236,236,233, 99,
- 128, 4, 77,115, 6, 81,177, 81,188, 81,208, 82, 33, 82, 78, 82,
- 88,227,249,242,233,236,236,233, 99,128, 4, 65,228,229,243,227,
- 229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,171,
- 104,132, 2,131, 81,220, 81,227, 82, 2, 82, 17,227,245,242,108,
- 128, 2,134,239,242,116, 2, 81,235, 81,242,228,229,246, 97,128,
- 9, 14,246,239,247,229,236,243,233,231,238,228,229,246, 97,128,
- 9, 70,242,229,246,229,242,243,229,228,236,239,239,112,128, 1,
- 170,243,241,245,225,244,242,229,246,229,242,243,229,100,128, 2,
- 133,237,225,236,108, 2, 82, 42, 82, 53,232,233,242,225,231,225,
- 238, 97,128, 48, 71,235,225,244,225,235,225,238, 97,129, 48,167,
- 82, 66,232,225,236,230,247,233,228,244,104,128,255,106,244,233,
- 237,225,244,229,100,128, 33, 46,245,240,229,242,233,239,114,128,
- 246,236,116, 5, 82,110, 82,136, 82,140, 82,157, 82,223, 97,130,
- 3,183, 82,118, 82,128,242,237,229,238,233,225,110,128, 5,104,
- 244,239,238,239,115,128, 3,174,104,128, 0,240,233,236,228,101,
- 129, 30,189, 82,149,226,229,236,239,119,128, 30, 27,238,225,232,
- 244, 97, 3, 82,169, 82,201, 82,210,230,239,245,235,104, 2, 82,
- 179, 82,188,232,229,226,242,229,119,128, 5,145,236,229,230,244,
- 232,229,226,242,229,119,128, 5,145,232,229,226,242,229,119,128,
- 5,145,236,229,230,244,232,229,226,242,229,119,128, 5,145,245,
- 242,238,229,100,128, 1,221,117, 2, 82,237, 82,246,235,239,242,
- 229,225,110,128, 49, 97,242,111,128, 32,172,246,239,247,229,236,
- 243,233,231,110, 3, 83, 11, 83, 21, 83, 28,226,229,238,231,225,
- 236,105,128, 9,199,228,229,246, 97,128, 9, 71,231,245,234,225,
- 242,225,244,105,128, 10,199,120, 2, 83, 45, 83,118,227,236,225,
- 109,132, 0, 33, 83, 60, 83, 71, 83, 98, 83,110,225,242,237,229,
- 238,233,225,110,128, 5, 92,100, 2, 83, 77, 83, 82,226,108,128,
- 32, 60,239,247,110,129, 0,161, 83, 90,243,237,225,236,108,128,
- 247,161,237,239,238,239,243,240,225,227,101,128,255, 1,243,237,
- 225,236,108,128,247, 33,233,243,244,229,238,244,233,225,108,128,
- 34, 3,250,104,131, 2,146, 83,141, 83,160, 83,171, 99, 2, 83,
- 147, 83,154,225,242,239,110,128, 1,239,245,242,108,128, 2,147,
- 242,229,246,229,242,243,229,100,128, 1,185,244,225,233,108,128,
- 1,186,102,140, 0,102, 83,206, 84, 32, 84, 43, 84, 52, 84, 64,
- 84,167, 84,183, 86,191, 86,204, 86,230, 88,107, 88,115, 97, 4,
- 83,216, 83,223, 83,234, 83,245,228,229,246, 97,128, 9, 94,231,
- 245,242,237,245,235,232,105,128, 10, 94,232,242,229,238,232,229,
- 233,116,128, 33, 9,244,232, 97, 3, 83,255, 84, 8, 84, 20,225,
- 242,225,226,233, 99,128, 6, 78,236,239,247,225,242,225,226,233,
- 99,128, 6, 78,244,225,238,225,242,225,226,233, 99,128, 6, 75,
- 226,239,240,239,237,239,230,111,128, 49, 8,227,233,242,227,236,
- 101,128, 36,213,228,239,244,225,227,227,229,238,116,128, 30, 31,
- 101, 3, 84, 72, 84,150, 84,160,104, 4, 84, 82, 84,105, 84,119,
- 84,135,225,114, 2, 84, 89, 84, 96,225,226,233, 99,128, 6, 65,
- 237,229,238,233,225,110,128, 5,134,230,233,238,225,236,225,242,
- 225,226,233, 99,128,254,210,233,238,233,244,233,225,236,225,242,
- 225,226,233, 99,128,254,211,237,229,228,233,225,236,225,242,225,
- 226,233, 99,128,254,212,233,227,239,240,244,233, 99,128, 3,229,
- 237,225,236,101,128, 38, 64,102,130,251, 0, 84,175, 84,179,105,
- 128,251, 3,108,128,251, 4,105,136,251, 1, 84,203, 84,243, 84,
- 254, 85, 20, 85,142, 85,159, 85,167, 85,180,230,244,229,229,110,
- 2, 84,213, 84,222,227,233,242,227,236,101,128, 36,110,112, 2,
- 84,228, 84,235,225,242,229,110,128, 36,130,229,242,233,239,100,
- 128, 36,150,231,245,242,229,228,225,243,104,128, 32, 18,236,236,
- 229,100, 2, 85, 7, 85, 13,226,239,120,128, 37,160,242,229,227,
- 116,128, 37,172,238,225,108, 5, 85, 34, 85, 73, 85, 90, 85,107,
- 85,123,235,225,102,130, 5,218, 85, 44, 85, 64,228,225,231,229,
- 243,104,129,251, 58, 85, 55,232,229,226,242,229,119,128,251, 58,
- 232,229,226,242,229,119,128, 5,218,237,229,109,129, 5,221, 85,
- 81,232,229,226,242,229,119,128, 5,221,238,245,110,129, 5,223,
- 85, 98,232,229,226,242,229,119,128, 5,223,240,101,129, 5,227,
- 85,114,232,229,226,242,229,119,128, 5,227,244,243,225,228,105,
- 129, 5,229, 85,133,232,229,226,242,229,119,128, 5,229,242,243,
- 244,244,239,238,229,227,232,233,238,229,243,101,128, 2,201,243,
- 232,229,249,101,128, 37,201,244,225,227,249,242,233,236,236,233,
- 99,128, 4,115,246,101,142, 0, 53, 85,213, 85,222, 85,232, 86,
- 6, 86, 13, 86, 23, 86, 48, 86, 75, 86,109, 86,121, 86,132, 86,
- 165, 86,173, 86,184,225,242,225,226,233, 99,128, 6,101,226,229,
- 238,231,225,236,105,128, 9,235,227,233,242,227,236,101,129, 36,
- 100, 85,243,233,238,246,229,242,243,229,243,225,238,243,243,229,
- 242,233,102,128, 39,142,228,229,246, 97,128, 9,107,229,233,231,
- 232,244,232,115,128, 33, 93,231,117, 2, 86, 30, 86, 39,234,225,
- 242,225,244,105,128, 10,235,242,237,245,235,232,105,128, 10,107,
- 232, 97, 2, 86, 55, 86, 66,227,235,225,242,225,226,233, 99,128,
- 6,101,238,231,250,232,239,117,128, 48, 37,105, 2, 86, 81, 86,
- 99,228,229,239,231,242,225,240,232,233,227,240,225,242,229,110,
- 128, 50, 36,238,230,229,242,233,239,114,128, 32,133,237,239,238,
- 239,243,240,225,227,101,128,255, 21,239,236,228,243,244,249,236,
- 101,128,247, 53,112, 2, 86,138, 86,145,225,242,229,110,128, 36,
- 120,229,114, 2, 86,152, 86,158,233,239,100,128, 36,140,243,233,
- 225,110,128, 6,245,242,239,237,225,110,128, 33,116,243,245,240,
- 229,242,233,239,114,128, 32,117,244,232,225,105,128, 14, 85,108,
- 129,251, 2, 86,197,239,242,233,110,128, 1,146,109, 2, 86,210,
- 86,221,239,238,239,243,240,225,227,101,128,255, 70,243,241,245,
- 225,242,101,128, 51,153,111, 4, 86,240, 87, 6, 87, 18, 87, 25,
- 230, 97, 2, 86,247, 86,255,238,244,232,225,105,128, 14, 31,244,
- 232,225,105,128, 14, 29,238,231,237,225,238,244,232,225,105,128,
- 14, 79,242,225,236,108,128, 34, 0,245,114,142, 0, 52, 87, 58,
- 87, 67, 87, 77, 87,107, 87,114, 87,139, 87,166, 87,200, 87,212,
- 87,231, 87,242, 88, 19, 88, 27, 88, 38,225,242,225,226,233, 99,
- 128, 6,100,226,229,238,231,225,236,105,128, 9,234,227,233,242,
- 227,236,101,129, 36, 99, 87, 88,233,238,246,229,242,243,229,243,
- 225,238,243,243,229,242,233,102,128, 39,141,228,229,246, 97,128,
- 9,106,231,117, 2, 87,121, 87,130,234,225,242,225,244,105,128,
- 10,234,242,237,245,235,232,105,128, 10,106,232, 97, 2, 87,146,
- 87,157,227,235,225,242,225,226,233, 99,128, 6,100,238,231,250,
- 232,239,117,128, 48, 36,105, 2, 87,172, 87,190,228,229,239,231,
- 242,225,240,232,233,227,240,225,242,229,110,128, 50, 35,238,230,
- 229,242,233,239,114,128, 32,132,237,239,238,239,243,240,225,227,
- 101,128,255, 20,238,245,237,229,242,225,244,239,242,226,229,238,
- 231,225,236,105,128, 9,247,239,236,228,243,244,249,236,101,128,
- 247, 52,112, 2, 87,248, 87,255,225,242,229,110,128, 36,119,229,
- 114, 2, 88, 6, 88, 12,233,239,100,128, 36,139,243,233,225,110,
- 128, 6,244,242,239,237,225,110,128, 33,115,243,245,240,229,242,
- 233,239,114,128, 32,116,116, 2, 88, 44, 88, 82,229,229,110, 2,
- 88, 52, 88, 61,227,233,242,227,236,101,128, 36,109,112, 2, 88,
- 67, 88, 74,225,242,229,110,128, 36,129,229,242,233,239,100,128,
- 36,149,104, 2, 88, 88, 88, 93,225,105,128, 14, 84,244,239,238,
- 229,227,232,233,238,229,243,101,128, 2,203,240,225,242,229,110,
- 128, 36,161,242, 97, 2, 88,122, 88,130,227,244,233,239,110,128,
- 32, 68,238, 99,128, 32,163,103,144, 0,103, 88,171, 89,117, 89,
- 140, 89,201, 89,218, 90,139, 91,132, 91,217, 91,230, 92, 88, 92,
- 113, 92,141, 92,163, 93,108, 93,130, 93,232, 97, 9, 88,191, 88,
- 201, 88,208, 88,215, 89, 23, 89, 48, 89, 59, 89, 70, 89,104,226,
- 229,238,231,225,236,105,128, 9,151,227,245,244,101,128, 1,245,
- 228,229,246, 97,128, 9, 23,102, 4, 88,225, 88,234, 88,248, 89,
- 8,225,242,225,226,233, 99,128, 6,175,230,233,238,225,236,225,
- 242,225,226,233, 99,128,251,147,233,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,251,148,237,229,228,233,225,236,225,242,
- 225,226,233, 99,128,251,149,231,117, 2, 89, 30, 89, 39,234,225,
- 242,225,244,105,128, 10,151,242,237,245,235,232,105,128, 10, 23,
- 232,233,242,225,231,225,238, 97,128, 48, 76,235,225,244,225,235,
- 225,238, 97,128, 48,172,237,237, 97,130, 3,179, 89, 80, 89, 93,
- 236,225,244,233,238,243,237,225,236,108,128, 2, 99,243,245,240,
- 229,242,233,239,114,128, 2,224,238,231,233,225,227,239,240,244,
- 233, 99,128, 3,235, 98, 2, 89,123, 89,133,239,240,239,237,239,
- 230,111,128, 49, 13,242,229,246,101,128, 1, 31, 99, 4, 89,150,
- 89,157, 89,166, 89,188,225,242,239,110,128, 1,231,229,228,233,
- 236,236, 97,128, 1, 35,233,242, 99, 2, 89,174, 89,179,236,101,
- 128, 36,214,245,237,230,236,229,120,128, 1, 29,239,237,237,225,
- 225,227,227,229,238,116,128, 1, 35,228,239,116,129, 1, 33, 89,
- 209,225,227,227,229,238,116,128, 1, 33,101, 6, 89,232, 89,243,
- 89,254, 90, 9, 90, 28, 90,130,227,249,242,233,236,236,233, 99,
- 128, 4, 51,232,233,242,225,231,225,238, 97,128, 48, 82,235,225,
- 244,225,235,225,238, 97,128, 48,178,239,237,229,244,242,233,227,
- 225,236,236,249,229,241,245,225,108,128, 34, 81,114, 3, 90, 36,
- 90, 85, 90, 95,229,243,104, 3, 90, 46, 90, 61, 90, 70,225,227,
- 227,229,238,244,232,229,226,242,229,119,128, 5,156,232,229,226,
- 242,229,119,128, 5,243,237,245,241,228,225,237,232,229,226,242,
- 229,119,128, 5,157,237,225,238,228,226,236,115,128, 0,223,243,
- 232,225,249,233,109, 2, 90,106, 90,121,225,227,227,229,238,244,
- 232,229,226,242,229,119,128, 5,158,232,229,226,242,229,119,128,
- 5,244,244,225,237,225,242,107,128, 48, 19,104, 5, 90,151, 91,
- 28, 91, 91, 91,116, 91,122, 97, 4, 90,161, 90,171, 90,194, 90,
- 219,226,229,238,231,225,236,105,128, 9,152,100, 2, 90,177, 90,
- 188,225,242,237,229,238,233,225,110,128, 5,114,229,246, 97,128,
- 9, 24,231,117, 2, 90,201, 90,210,234,225,242,225,244,105,128,
- 10,152,242,237,245,235,232,105,128, 10, 24,233,110, 4, 90,230,
- 90,239, 90,253, 91, 13,225,242,225,226,233, 99,128, 6, 58,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,206,233,238,233,
- 244,233,225,236,225,242,225,226,233, 99,128,254,207,237,229,228,
- 233,225,236,225,242,225,226,233, 99,128,254,208,101, 3, 91, 36,
- 91, 57, 91, 74,237,233,228,228,236,229,232,239,239,235,227,249,
- 242,233,236,236,233, 99,128, 4,149,243,244,242,239,235,229,227,
- 249,242,233,236,236,233, 99,128, 4,147,245,240,244,245,242,238,
- 227,249,242,233,236,236,233, 99,128, 4,145,232, 97, 2, 91, 98,
- 91,105,228,229,246, 97,128, 9, 90,231,245,242,237,245,235,232,
- 105,128, 10, 90,239,239,107,128, 2, 96,250,243,241,245,225,242,
- 101,128, 51,147,105, 3, 91,140, 91,151, 91,162,232,233,242,225,
- 231,225,238, 97,128, 48, 78,235,225,244,225,235,225,238, 97,128,
- 48,174,109, 2, 91,168, 91,179,225,242,237,229,238,233,225,110,
- 128, 5, 99,229,108,130, 5,210, 91,188, 91,208,228,225,231,229,
- 243,104,129,251, 50, 91,199,232,229,226,242,229,119,128,251, 50,
- 232,229,226,242,229,119,128, 5,210,234,229,227,249,242,233,236,
- 236,233, 99,128, 4, 83,236,239,244,244,225,108, 2, 91,241, 92,
- 2,233,238,246,229,242,244,229,228,243,244,242,239,235,101,128,
- 1,190,243,244,239,112,132, 2,148, 92, 17, 92, 28, 92, 34, 92,
- 66,233,238,246,229,242,244,229,100,128, 2,150,237,239,100,128,
- 2,192,242,229,246,229,242,243,229,100,130, 2,149, 92, 49, 92,
- 55,237,239,100,128, 2,193,243,245,240,229,242,233,239,114,128,
- 2,228,243,244,242,239,235,101,129, 2,161, 92, 77,242,229,246,
- 229,242,243,229,100,128, 2,162,109, 2, 92, 94, 92,102,225,227,
- 242,239,110,128, 30, 33,239,238,239,243,240,225,227,101,128,255,
- 71,111, 2, 92,119, 92,130,232,233,242,225,231,225,238, 97,128,
- 48, 84,235,225,244,225,235,225,238, 97,128, 48,180,240, 97, 2,
- 92,148, 92,154,242,229,110,128, 36,162,243,241,245,225,242,101,
- 128, 51,172,114, 2, 92,169, 93, 10, 97, 2, 92,175, 92,183,228,
- 233,229,238,116,128, 34, 7,246,101,134, 0, 96, 92,200, 92,211,
- 92,228, 92,235, 92,244, 93, 0,226,229,236,239,247,227,237, 98,
- 128, 3, 22, 99, 2, 92,217, 92,222,237, 98,128, 3, 0,239,237,
- 98,128, 3, 0,228,229,246, 97,128, 9, 83,236,239,247,237,239,
- 100,128, 2,206,237,239,238,239,243,240,225,227,101,128,255, 64,
- 244,239,238,229,227,237, 98,128, 3, 64,229,225,244,229,114,132,
- 0, 62, 93, 26, 93, 45, 93, 57, 93,100,229,241,245,225,108,129,
- 34,101, 93, 36,239,242,236,229,243,115,128, 34,219,237,239,238,
- 239,243,240,225,227,101,128,255, 30,111, 2, 93, 63, 93, 89,114,
- 2, 93, 69, 93, 82,229,241,245,233,246,225,236,229,238,116,128,
- 34,115,236,229,243,115,128, 34,119,246,229,242,229,241,245,225,
- 108,128, 34,103,243,237,225,236,108,128,254,101,115, 2, 93,114,
- 93,122,227,242,233,240,116,128, 2, 97,244,242,239,235,101,128,
- 1,229,117, 4, 93,140, 93,151, 93,208, 93,219,232,233,242,225,
- 231,225,238, 97,128, 48, 80,233,108, 2, 93,158, 93,183,236,229,
- 237,239,116, 2, 93,168, 93,175,236,229,230,116,128, 0,171,242,
- 233,231,232,116,128, 0,187,243,233,238,231,108, 2, 93,193, 93,
- 200,236,229,230,116,128, 32, 57,242,233,231,232,116,128, 32, 58,
- 235,225,244,225,235,225,238, 97,128, 48,176,242,225,237,245,243,
- 241,245,225,242,101,128, 51, 24,249,243,241,245,225,242,101,128,
- 51,201,104,144, 0,104, 94, 22, 96,164, 96,199, 96,236, 97, 20,
- 98,164, 98,184, 99,149, 99,161, 99,173,100,241,100,249,101, 4,
- 101, 13,101, 93,101, 97, 97, 13, 94, 50, 94, 89, 94, 99, 94,129,
- 94,154, 94,232, 94,244, 95, 13, 95, 28, 95, 57, 95, 70, 95,128,
- 95,137, 97, 2, 94, 56, 94, 75,226,235,232,225,243,233,225,238,
- 227,249,242,233,236,236,233, 99,128, 4,169,236,244,239,238,229,
- 225,242,225,226,233, 99,128, 6,193,226,229,238,231,225,236,105,
- 128, 9,185,228,101, 2, 94,106, 94,124,243,227,229,238,228,229,
- 242,227,249,242,233,236,236,233, 99,128, 4,179,246, 97,128, 9,
- 57,231,117, 2, 94,136, 94,145,234,225,242,225,244,105,128, 10,
- 185,242,237,245,235,232,105,128, 10, 57,104, 4, 94,164, 94,173,
- 94,187, 94,217,225,242,225,226,233, 99,128, 6, 45,230,233,238,
- 225,236,225,242,225,226,233, 99,128,254,162,105, 2, 94,193, 94,
- 208,238,233,244,233,225,236,225,242,225,226,233, 99,128,254,163,
- 242,225,231,225,238, 97,128, 48,111,237,229,228,233,225,236,225,
- 242,225,226,233, 99,128,254,164,233,244,245,243,241,245,225,242,
- 101,128, 51, 42,235,225,244,225,235,225,238, 97,129, 48,207, 95,
- 1,232,225,236,230,247,233,228,244,104,128,255,138,236,225,238,
- 244,231,245,242,237,245,235,232,105,128, 10, 77,237,250, 97, 2,
- 95, 36, 95, 45,225,242,225,226,233, 99,128, 6, 33,236,239,247,
- 225,242,225,226,233, 99,128, 6, 33,238,231,245,236,230,233,236,
- 236,229,114,128, 49,100,114, 2, 95, 76, 95, 92,228,243,233,231,
- 238,227,249,242,233,236,236,233, 99,128, 4, 74,240,239,239,110,
- 2, 95,101, 95,114,236,229,230,244,226,225,242,226,245,112,128,
- 33,188,242,233,231,232,244,226,225,242,226,245,112,128, 33,192,
- 243,241,245,225,242,101,128, 51,202,244,225,102, 3, 95,147, 95,
- 239, 96, 74,240,225,244,225,104,134, 5,178, 95,167, 95,172, 95,
- 186, 95,195, 95,210, 95,226,177, 54,128, 5,178, 50, 2, 95,178,
- 95,182, 51,128, 5,178,102,128, 5,178,232,229,226,242,229,119,
- 128, 5,178,238,225,242,242,239,247,232,229,226,242,229,119,128,
- 5,178,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
- 5,178,247,233,228,229,232,229,226,242,229,119,128, 5,178,241,
- 225,237,225,244,115,135, 5,179, 96, 6, 96, 11, 96, 16, 96, 21,
- 96, 30, 96, 45, 96, 61,177, 98,128, 5,179,178, 56,128, 5,179,
- 179, 52,128, 5,179,232,229,226,242,229,119,128, 5,179,238,225,
- 242,242,239,247,232,229,226,242,229,119,128, 5,179,241,245,225,
- 242,244,229,242,232,229,226,242,229,119,128, 5,179,247,233,228,
- 229,232,229,226,242,229,119,128, 5,179,243,229,231,239,108,135,
- 5,177, 96, 96, 96,101, 96,106, 96,111, 96,120, 96,135, 96,151,
- 177, 55,128, 5,177,178, 52,128, 5,177,179, 48,128, 5,177,232,
- 229,226,242,229,119,128, 5,177,238,225,242,242,239,247,232,229,
- 226,242,229,119,128, 5,177,241,245,225,242,244,229,242,232,229,
- 226,242,229,119,128, 5,177,247,233,228,229,232,229,226,242,229,
- 119,128, 5,177, 98, 3, 96,172, 96,177, 96,187,225,114,128, 1,
- 39,239,240,239,237,239,230,111,128, 49, 15,242,229,246,229,226,
- 229,236,239,119,128, 30, 43, 99, 2, 96,205, 96,214,229,228,233,
- 236,236, 97,128, 30, 41,233,242, 99, 2, 96,222, 96,227,236,101,
- 128, 36,215,245,237,230,236,229,120,128, 1, 37,100, 2, 96,242,
- 96,252,233,229,242,229,243,233,115,128, 30, 39,239,116, 2, 97,
- 3, 97, 12,225,227,227,229,238,116,128, 30, 35,226,229,236,239,
- 119,128, 30, 37,101,136, 5,212, 97, 40, 97, 73, 97, 93, 98, 66,
- 98, 82, 98,127, 98,136, 98,149,225,242,116,129, 38,101, 97, 48,
- 243,245,233,116, 2, 97, 57, 97, 65,226,236,225,227,107,128, 38,
- 101,247,232,233,244,101,128, 38, 97,228,225,231,229,243,104,129,
- 251, 52, 97, 84,232,229,226,242,229,119,128,251, 52,104, 6, 97,
- 107, 97,135, 97,143, 97,193, 97,239, 98, 32, 97, 2, 97,113, 97,
- 127,236,244,239,238,229,225,242,225,226,233, 99,128, 6,193,242,
- 225,226,233, 99,128, 6, 71,229,226,242,229,119,128, 5,212,230,
- 233,238,225,236, 97, 2, 97,154, 97,185,236,116, 2, 97,161, 97,
- 173,239,238,229,225,242,225,226,233, 99,128,251,167,244,247,239,
- 225,242,225,226,233, 99,128,254,234,242,225,226,233, 99,128,254,
- 234,232,225,237,250,225,225,226,239,246,101, 2, 97,208, 97,222,
- 230,233,238,225,236,225,242,225,226,233, 99,128,251,165,233,243,
- 239,236,225,244,229,228,225,242,225,226,233, 99,128,251,164,105,
- 2, 97,245, 98, 23,238,233,244,233,225,236, 97, 2, 98, 1, 98,
- 15,236,244,239,238,229,225,242,225,226,233, 99,128,251,168,242,
- 225,226,233, 99,128,254,235,242,225,231,225,238, 97,128, 48,120,
- 237,229,228,233,225,236, 97, 2, 98, 44, 98, 58,236,244,239,238,
- 229,225,242,225,226,233, 99,128,251,169,242,225,226,233, 99,128,
- 254,236,233,243,229,233,229,242,225,243,241,245,225,242,101,128,
- 51,123,107, 2, 98, 88, 98,112,225,244,225,235,225,238, 97,129,
- 48,216, 98,100,232,225,236,230,247,233,228,244,104,128,255,141,
- 245,244,225,225,242,245,243,241,245,225,242,101,128, 51, 54,238,
- 231,232,239,239,107,128, 2,103,242,245,244,245,243,241,245,225,
- 242,101,128, 51, 57,116,129, 5,215, 98,155,232,229,226,242,229,
- 119,128, 5,215,232,239,239,107,129, 2,102, 98,173,243,245,240,
- 229,242,233,239,114,128, 2,177,105, 4, 98,194, 99, 23, 99, 34,
- 99, 59,229,245,104, 4, 98,206, 98,241, 99, 0, 99, 9, 97, 2,
- 98,212, 98,227,227,233,242,227,236,229,235,239,242,229,225,110,
- 128, 50,123,240,225,242,229,238,235,239,242,229,225,110,128, 50,
- 27,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,109,
- 235,239,242,229,225,110,128, 49, 78,240,225,242,229,238,235,239,
- 242,229,225,110,128, 50, 13,232,233,242,225,231,225,238, 97,128,
- 48,114,235,225,244,225,235,225,238, 97,129, 48,210, 99, 47,232,
- 225,236,230,247,233,228,244,104,128,255,139,242,233,113,134, 5,
- 180, 99, 77, 99, 82, 99, 96, 99,105, 99,120, 99,136,177, 52,128,
- 5,180, 50, 2, 99, 88, 99, 92, 49,128, 5,180,100,128, 5,180,
- 232,229,226,242,229,119,128, 5,180,238,225,242,242,239,247,232,
- 229,226,242,229,119,128, 5,180,241,245,225,242,244,229,242,232,
- 229,226,242,229,119,128, 5,180,247,233,228,229,232,229,226,242,
- 229,119,128, 5,180,236,233,238,229,226,229,236,239,119,128, 30,
- 150,237,239,238,239,243,240,225,227,101,128,255, 72,111, 9, 99,
- 193, 99,204, 99,228, 99,253,100, 85,100, 98,100,184,100,224,100,
- 235,225,242,237,229,238,233,225,110,128, 5,112,232,105, 2, 99,
- 211, 99,219,240,244,232,225,105,128, 14, 43,242,225,231,225,238,
- 97,128, 48,123,235,225,244,225,235,225,238, 97,129, 48,219, 99,
- 241,232,225,236,230,247,233,228,244,104,128,255,142,236,225,109,
- 135, 5,185,100, 17,100, 22,100, 27,100, 32,100, 41,100, 56,100,
- 72,177, 57,128, 5,185,178, 54,128, 5,185,179, 50,128, 5,185,
- 232,229,226,242,229,119,128, 5,185,238,225,242,242,239,247,232,
- 229,226,242,229,119,128, 5,185,241,245,225,242,244,229,242,232,
- 229,226,242,229,119,128, 5,185,247,233,228,229,232,229,226,242,
- 229,119,128, 5,185,238,239,235,232,245,235,244,232,225,105,128,
- 14, 46,111, 2,100,104,100,174,107, 4,100,114,100,126,100,132,
- 100,154,225,226,239,246,229,227,239,237, 98,128, 3, 9,227,237,
- 98,128, 3, 9,240,225,236,225,244,225,236,233,250,229,228,226,
- 229,236,239,247,227,237, 98,128, 3, 33,242,229,244,242,239,230,
- 236,229,248,226,229,236,239,247,227,237, 98,128, 3, 34,238,243,
- 241,245,225,242,101,128, 51, 66,114, 2,100,190,100,217,105, 2,
- 100,196,100,205,227,239,240,244,233, 99,128, 3,233,250,239,238,
- 244,225,236,226,225,114,128, 32, 21,238,227,237, 98,128, 3, 27,
- 244,243,240,242,233,238,231,115,128, 38,104,245,243,101,128, 35,
- 2,240,225,242,229,110,128, 36,163,243,245,240,229,242,233,239,
- 114,128, 2,176,244,245,242,238,229,100,128, 2,101,117, 4,101,
- 23,101, 34,101, 47,101, 72,232,233,242,225,231,225,238, 97,128,
- 48,117,233,233,244,239,243,241,245,225,242,101,128, 51, 51,235,
- 225,244,225,235,225,238, 97,129, 48,213,101, 60,232,225,236,230,
- 247,233,228,244,104,128,255,140,238,231,225,242,245,237,236,225,
- 245,116,129, 2,221,101, 87,227,237, 98,128, 3, 11,118,128, 1,
- 149,249,240,232,229,110,132, 0, 45,101,113,101,124,101,136,101,
- 159,233,238,230,229,242,233,239,114,128,246,229,237,239,238,239,
- 243,240,225,227,101,128,255, 13,115, 2,101,142,101,149,237,225,
- 236,108,128,254, 99,245,240,229,242,233,239,114,128,246,230,244,
- 247,111,128, 32, 16,105,149, 0,105,101,211,101,234,102, 12,102,
- 59,105,197,106, 61,106, 98,106,125,107, 31,107, 35,107, 73,107,
- 95,107,179,108, 88,108,163,108,171,108,184,109, 15,109, 72,109,
- 100,109,144,225, 99, 2,101,218,101,224,245,244,101,128, 0,237,
- 249,242,233,236,236,233, 99,128, 4, 79, 98, 3,101,242,101,251,
- 102, 5,229,238,231,225,236,105,128, 9,135,239,240,239,237,239,
- 230,111,128, 49, 39,242,229,246,101,128, 1, 45, 99, 3,102, 20,
- 102, 27,102, 49,225,242,239,110,128, 1,208,233,242, 99, 2,102,
- 35,102, 40,236,101,128, 36,216,245,237,230,236,229,120,128, 0,
- 238,249,242,233,236,236,233, 99,128, 4, 86,100, 4,102, 69,102,
- 79,105,154,105,187,226,236,231,242,225,246,101,128, 2, 9,101,
- 2,102, 85,105,149,239,231,242,225,240,104, 7,102,106,102,120,
- 102,133,105, 62,105, 93,105,106,105,118,229,225,242,244,232,227,
- 233,242,227,236,101,128, 50,143,230,233,242,229,227,233,242,227,
- 236,101,128, 50,139,233, 99, 14,102,164,102,180,103, 23,103, 77,
- 103,143,103,172,103,188,103,245,104, 38,104, 50,104, 77,104,144,
- 105, 26,105, 55,225,236,236,233,225,238,227,229,240,225,242,229,
- 110,128, 50, 63, 99, 4,102,190,102,201,102,215,102,222,225,236,
- 236,240,225,242,229,110,128, 50, 58,229,238,244,242,229,227,233,
- 242,227,236,101,128, 50,165,236,239,243,101,128, 48, 6,111, 3,
- 102,230,102,245,103, 9,237,237, 97,129, 48, 1,102,238,236,229,
- 230,116,128,255,100,238,231,242,225,244,245,236,225,244,233,239,
- 238,240,225,242,229,110,128, 50, 55,242,242,229,227,244,227,233,
- 242,227,236,101,128, 50,163,101, 3,103, 31,103, 43,103, 60,225,
- 242,244,232,240,225,242,229,110,128, 50, 47,238,244,229,242,240,
- 242,233,243,229,240,225,242,229,110,128, 50, 61,248,227,229,236,
- 236,229,238,244,227,233,242,227,236,101,128, 50,157,102, 2,103,
- 83,103, 98,229,243,244,233,246,225,236,240,225,242,229,110,128,
- 50, 64,105, 2,103,104,103,133,238,225,238,227,233,225,108, 2,
- 103,116,103,125,227,233,242,227,236,101,128, 50,150,240,225,242,
- 229,110,128, 50, 54,242,229,240,225,242,229,110,128, 50, 43,104,
- 2,103,149,103,160,225,246,229,240,225,242,229,110,128, 50, 50,
- 233,231,232,227,233,242,227,236,101,128, 50,164,233,244,229,242,
- 225,244,233,239,238,237,225,242,107,128, 48, 5,108, 3,103,196,
- 103,222,103,234,225,226,239,114, 2,103,205,103,214,227,233,242,
- 227,236,101,128, 50,152,240,225,242,229,110,128, 50, 56,229,230,
- 244,227,233,242,227,236,101,128, 50,167,239,247,227,233,242,227,
- 236,101,128, 50,166,109, 2,103,251,104, 27,101, 2,104, 1,104,
- 16,228,233,227,233,238,229,227,233,242,227,236,101,128, 50,169,
- 244,225,236,240,225,242,229,110,128, 50, 46,239,239,238,240,225,
- 242,229,110,128, 50, 42,238,225,237,229,240,225,242,229,110,128,
- 50, 52,112, 2,104, 56,104, 64,229,242,233,239,100,128, 48, 2,
- 242,233,238,244,227,233,242,227,236,101,128, 50,158,114, 2,104,
- 83,104,131,101, 3,104, 91,104,102,104,117,225,227,232,240,225,
- 242,229,110,128, 50, 67,240,242,229,243,229,238,244,240,225,242,
- 229,110,128, 50, 57,243,239,245,242,227,229,240,225,242,229,110,
- 128, 50, 62,233,231,232,244,227,233,242,227,236,101,128, 50,168,
- 115, 5,104,156,104,185,104,199,104,224,104,252,101, 2,104,162,
- 104,175,227,242,229,244,227,233,242,227,236,101,128, 50,153,236,
- 230,240,225,242,229,110,128, 50, 66,239,227,233,229,244,249,240,
- 225,242,229,110,128, 50, 51,112, 2,104,205,104,211,225,227,101,
- 128, 48, 0,229,227,233,225,236,240,225,242,229,110,128, 50, 53,
- 116, 2,104,230,104,241,239,227,235,240,225,242,229,110,128, 50,
- 49,245,228,249,240,225,242,229,110,128, 50, 59,117, 2,105, 2,
- 105, 11,238,240,225,242,229,110,128, 50, 48,240,229,242,246,233,
- 243,229,240,225,242,229,110,128, 50, 60,119, 2,105, 32,105, 44,
- 225,244,229,242,240,225,242,229,110,128, 50, 44,239,239,228,240,
- 225,242,229,110,128, 50, 45,250,229,242,111,128, 48, 7,109, 2,
- 105, 68,105, 81,229,244,225,236,227,233,242,227,236,101,128, 50,
- 142,239,239,238,227,233,242,227,236,101,128, 50,138,238,225,237,
- 229,227,233,242,227,236,101,128, 50,148,243,245,238,227,233,242,
- 227,236,101,128, 50,144,119, 2,105,124,105,137,225,244,229,242,
- 227,233,242,227,236,101,128, 50,140,239,239,228,227,233,242,227,
- 236,101,128, 50,141,246, 97,128, 9, 7,233,229,242,229,243,233,
- 115,130, 0,239,105,168,105,176,225,227,245,244,101,128, 30, 47,
- 227,249,242,233,236,236,233, 99,128, 4,229,239,244,226,229,236,
- 239,119,128, 30,203,101, 3,105,205,105,221,105,232,226,242,229,
- 246,229,227,249,242,233,236,236,233, 99,128, 4,215,227,249,242,
- 233,236,236,233, 99,128, 4, 53,245,238,103, 4,105,244,106, 23,
- 106, 38,106, 47, 97, 2,105,250,106, 9,227,233,242,227,236,229,
- 235,239,242,229,225,110,128, 50,117,240,225,242,229,238,235,239,
- 242,229,225,110,128, 50, 21,227,233,242,227,236,229,235,239,242,
- 229,225,110,128, 50,103,235,239,242,229,225,110,128, 49, 71,240,
- 225,242,229,238,235,239,242,229,225,110,128, 50, 7,103, 2,106,
- 67,106, 74,242,225,246,101,128, 0,236,117, 2,106, 80,106, 89,
- 234,225,242,225,244,105,128, 10,135,242,237,245,235,232,105,128,
- 10, 7,104, 2,106,104,106,114,233,242,225,231,225,238, 97,128,
- 48, 68,239,239,235,225,226,239,246,101,128, 30,201,105, 8,106,
- 143,106,153,106,164,106,171,106,196,106,212,106,227,106,243,226,
- 229,238,231,225,236,105,128, 9,136,227,249,242,233,236,236,233,
- 99,128, 4, 56,228,229,246, 97,128, 9, 8,231,117, 2,106,178,
- 106,187,234,225,242,225,244,105,128, 10,136,242,237,245,235,232,
- 105,128, 10, 8,237,225,244,242,225,231,245,242,237,245,235,232,
- 105,128, 10, 64,238,246,229,242,244,229,228,226,242,229,246,101,
- 128, 2, 11,243,232,239,242,244,227,249,242,233,236,236,233, 99,
- 128, 4, 57,246,239,247,229,236,243,233,231,110, 3,107, 3,107,
- 13,107, 20,226,229,238,231,225,236,105,128, 9,192,228,229,246,
- 97,128, 9, 64,231,245,234,225,242,225,244,105,128, 10,192,106,
- 128, 1, 51,107, 2,107, 41,107, 65,225,244,225,235,225,238, 97,
- 129, 48,164,107, 53,232,225,236,230,247,233,228,244,104,128,255,
- 114,239,242,229,225,110,128, 49, 99,108, 2,107, 79,107, 84,228,
- 101,128, 2,220,245,249,232,229,226,242,229,119,128, 5,172,109,
- 2,107,101,107,168, 97, 3,107,109,107,129,107,154,227,242,239,
- 110,129, 1, 43,107,118,227,249,242,233,236,236,233, 99,128, 4,
- 227,231,229,239,242,225,240,240,242,239,248,233,237,225,244,229,
- 236,249,229,241,245,225,108,128, 34, 83,244,242,225,231,245,242,
- 237,245,235,232,105,128, 10, 63,239,238,239,243,240,225,227,101,
- 128,255, 73,110, 5,107,191,107,201,107,210,107,222,108, 50,227,
- 242,229,237,229,238,116,128, 34, 6,230,233,238,233,244,121,128,
- 34, 30,233,225,242,237,229,238,233,225,110,128, 5,107,116, 2,
- 107,228,108, 40,101, 2,107,234,108, 29,231,242,225,108,131, 34,
- 43,107,247,108, 9,108, 14, 98, 2,107,253,108, 5,239,244,244,
- 239,109,128, 35, 33,116,128, 35, 33,229,120,128,248,245,116, 2,
- 108, 20,108, 25,239,112,128, 35, 32,112,128, 35, 32,242,243,229,
- 227,244,233,239,110,128, 34, 41,233,243,241,245,225,242,101,128,
- 51, 5,118, 3,108, 58,108, 67,108, 76,226,245,236,236,229,116,
- 128, 37,216,227,233,242,227,236,101,128, 37,217,243,237,233,236,
- 229,230,225,227,101,128, 38, 59,111, 3,108, 96,108,107,108,115,
- 227,249,242,233,236,236,233, 99,128, 4, 81,231,239,238,229,107,
- 128, 1, 47,244, 97,131, 3,185,108,126,108,147,108,155,228,233,
- 229,242,229,243,233,115,129, 3,202,108,139,244,239,238,239,115,
- 128, 3,144,236,225,244,233,110,128, 2,105,244,239,238,239,115,
- 128, 3,175,240,225,242,229,110,128, 36,164,242,233,231,245,242,
- 237,245,235,232,105,128, 10,114,115, 4,108,194,108,239,108,253,
- 109, 5,237,225,236,108, 2,108,203,108,214,232,233,242,225,231,
- 225,238, 97,128, 48, 67,235,225,244,225,235,225,238, 97,129, 48,
- 163,108,227,232,225,236,230,247,233,228,244,104,128,255,104,243,
- 232,225,242,226,229,238,231,225,236,105,128, 9,250,244,242,239,
- 235,101,128, 2,104,245,240,229,242,233,239,114,128,246,237,116,
- 2,109, 21,109, 55,229,242,225,244,233,239,110, 2,109, 33,109,
- 44,232,233,242,225,231,225,238, 97,128, 48,157,235,225,244,225,
- 235,225,238, 97,128, 48,253,233,236,228,101,129, 1, 41,109, 64,
- 226,229,236,239,119,128, 30, 45,117, 2,109, 78,109, 89,226,239,
- 240,239,237,239,230,111,128, 49, 41,227,249,242,233,236,236,233,
- 99,128, 4, 78,246,239,247,229,236,243,233,231,110, 3,109,116,
- 109,126,109,133,226,229,238,231,225,236,105,128, 9,191,228,229,
- 246, 97,128, 9, 63,231,245,234,225,242,225,244,105,128, 10,191,
- 250,232,233,244,243, 97, 2,109,155,109,166,227,249,242,233,236,
- 236,233, 99,128, 4,117,228,226,236,231,242,225,246,229,227,249,
- 242,233,236,236,233, 99,128, 4,119,106,138, 0,106,109,209,110,
- 16,110, 27,110, 77,110, 93,110,206,111, 19,111, 24,111, 36,111,
- 44, 97, 4,109,219,109,230,109,240,109,247,225,242,237,229,238,
- 233,225,110,128, 5,113,226,229,238,231,225,236,105,128, 9,156,
- 228,229,246, 97,128, 9, 28,231,117, 2,109,254,110, 7,234,225,
- 242,225,244,105,128, 10,156,242,237,245,235,232,105,128, 10, 28,
- 226,239,240,239,237,239,230,111,128, 49, 16, 99, 3,110, 35,110,
- 42,110, 64,225,242,239,110,128, 1,240,233,242, 99, 2,110, 50,
- 110, 55,236,101,128, 36,217,245,237,230,236,229,120,128, 1, 53,
- 242,239,243,243,229,228,244,225,233,108,128, 2,157,228,239,244,
- 236,229,243,243,243,244,242,239,235,101,128, 2, 95,101, 3,110,
- 101,110,112,110,177,227,249,242,233,236,236,233, 99,128, 4, 88,
- 229,109, 4,110,123,110,132,110,146,110,162,225,242,225,226,233,
- 99,128, 6, 44,230,233,238,225,236,225,242,225,226,233, 99,128,
- 254,158,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
- 254,159,237,229,228,233,225,236,225,242,225,226,233, 99,128,254,
- 160,104, 2,110,183,110,192,225,242,225,226,233, 99,128, 6,152,
- 230,233,238,225,236,225,242,225,226,233, 99,128,251,139,104, 2,
- 110,212,111, 6, 97, 3,110,220,110,230,110,237,226,229,238,231,
- 225,236,105,128, 9,157,228,229,246, 97,128, 9, 29,231,117, 2,
- 110,244,110,253,234,225,242,225,244,105,128, 10,157,242,237,245,
- 235,232,105,128, 10, 29,229,232,225,242,237,229,238,233,225,110,
- 128, 5,123,233,115,128, 48, 4,237,239,238,239,243,240,225,227,
- 101,128,255, 74,240,225,242,229,110,128, 36,165,243,245,240,229,
- 242,233,239,114,128, 2,178,107,146, 0,107,111, 95,113,184,113,
- 195,114, 1,114, 12,114,102,114,116,115,224,116,164,116,177,116,
- 203,116,252,117,134,117,156,117,169,117,192,117,234,117,244, 97,
- 12,111,121,111,153,111,175,111,205,112, 63,112, 88,112,118,112,
- 143,112,249,113, 7,113,130,113,159, 98, 2,111,127,111,144,225,
- 243,232,235,233,242,227,249,242,233,236,236,233, 99,128, 4,161,
- 229,238,231,225,236,105,128, 9,149, 99, 2,111,159,111,165,245,
- 244,101,128, 30, 49,249,242,233,236,236,233, 99,128, 4, 58,228,
- 101, 2,111,182,111,200,243,227,229,238,228,229,242,227,249,242,
- 233,236,236,233, 99,128, 4,155,246, 97,128, 9, 21,102,135, 5,
- 219,111,223,111,232,111,252,112, 10,112, 19,112, 35,112, 50,225,
- 242,225,226,233, 99,128, 6, 67,228,225,231,229,243,104,129,251,
- 59,111,243,232,229,226,242,229,119,128,251, 59,230,233,238,225,
- 236,225,242,225,226,233, 99,128,254,218,232,229,226,242,229,119,
- 128, 5,219,233,238,233,244,233,225,236,225,242,225,226,233, 99,
- 128,254,219,237,229,228,233,225,236,225,242,225,226,233, 99,128,
- 254,220,242,225,230,229,232,229,226,242,229,119,128,251, 77,231,
- 117, 2,112, 70,112, 79,234,225,242,225,244,105,128, 10,149,242,
- 237,245,235,232,105,128, 10, 21,104, 2,112, 94,112,104,233,242,
- 225,231,225,238, 97,128, 48, 75,239,239,235,227,249,242,233,236,
- 236,233, 99,128, 4,196,235,225,244,225,235,225,238, 97,129, 48,
- 171,112,131,232,225,236,230,247,233,228,244,104,128,255,118,112,
- 2,112,149,112,170,240, 97,129, 3,186,112,156,243,249,237,226,
- 239,236,231,242,229,229,107,128, 3,240,249,229,239,245,110, 3,
- 112,182,112,196,112,230,237,233,229,245,237,235,239,242,229,225,
- 110,128, 49,113,112, 2,112,202,112,217,232,233,229,245,240,232,
- 235,239,242,229,225,110,128, 49,132,233,229,245,240,235,239,242,
- 229,225,110,128, 49,120,243,243,225,238,231,240,233,229,245,240,
- 235,239,242,229,225,110,128, 49,121,242,239,242,233,233,243,241,
- 245,225,242,101,128, 51, 13,115, 5,113, 19,113, 63,113, 78,113,
- 86,113,114,232,233,228,225,225,245,244,111, 2,113, 32,113, 41,
- 225,242,225,226,233, 99,128, 6, 64,238,239,243,233,228,229,226,
- 229,225,242,233,238,231,225,242,225,226,233, 99,128, 6, 64,237,
- 225,236,236,235,225,244,225,235,225,238, 97,128, 48,245,241,245,
- 225,242,101,128, 51,132,242, 97, 2,113, 93,113,102,225,242,225,
- 226,233, 99,128, 6, 80,244,225,238,225,242,225,226,233, 99,128,
- 6, 77,244,242,239,235,229,227,249,242,233,236,236,233, 99,128,
- 4,159,244,225,232,233,242,225,240,242,239,236,239,238,231,237,
- 225,242,235,232,225,236,230,247,233,228,244,104,128,255,112,246,
- 229,242,244,233,227,225,236,243,244,242,239,235,229,227,249,242,
- 233,236,236,233, 99,128, 4,157,226,239,240,239,237,239,230,111,
- 128, 49, 14, 99, 4,113,205,113,227,113,236,113,244, 97, 2,113,
- 211,113,221,236,243,241,245,225,242,101,128, 51,137,242,239,110,
- 128, 1,233,229,228,233,236,236, 97,128, 1, 55,233,242,227,236,
- 101,128, 36,218,239,237,237,225,225,227,227,229,238,116,128, 1,
- 55,228,239,244,226,229,236,239,119,128, 30, 51,101, 4,114, 22,
- 114, 49,114, 74,114, 86,104, 2,114, 28,114, 39,225,242,237,229,
- 238,233,225,110,128, 5,132,233,242,225,231,225,238, 97,128, 48,
- 81,235,225,244,225,235,225,238, 97,129, 48,177,114, 62,232,225,
- 236,230,247,233,228,244,104,128,255,121,238,225,242,237,229,238,
- 233,225,110,128, 5,111,243,237,225,236,236,235,225,244,225,235,
- 225,238, 97,128, 48,246,231,242,229,229,238,236,225,238,228,233,
- 99,128, 1, 56,104, 6,114,130,115, 3,115, 14,115, 39,115,126,
- 115,214, 97, 5,114,142,114,152,114,163,114,170,114,195,226,229,
- 238,231,225,236,105,128, 9,150,227,249,242,233,236,236,233, 99,
- 128, 4, 69,228,229,246, 97,128, 9, 22,231,117, 2,114,177,114,
- 186,234,225,242,225,244,105,128, 10,150,242,237,245,235,232,105,
- 128, 10, 22,104, 4,114,205,114,214,114,228,114,244,225,242,225,
- 226,233, 99,128, 6, 46,230,233,238,225,236,225,242,225,226,233,
- 99,128,254,166,233,238,233,244,233,225,236,225,242,225,226,233,
- 99,128,254,167,237,229,228,233,225,236,225,242,225,226,233, 99,
- 128,254,168,229,233,227,239,240,244,233, 99,128, 3,231,232, 97,
- 2,115, 21,115, 28,228,229,246, 97,128, 9, 89,231,245,242,237,
- 245,235,232,105,128, 10, 89,233,229,245,235,104, 4,115, 53,115,
- 88,115,103,115,112, 97, 2,115, 59,115, 74,227,233,242,227,236,
- 229,235,239,242,229,225,110,128, 50,120,240,225,242,229,238,235,
- 239,242,229,225,110,128, 50, 24,227,233,242,227,236,229,235,239,
- 242,229,225,110,128, 50,106,235,239,242,229,225,110,128, 49, 75,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 10,111, 4,
- 115,136,115,185,115,195,115,200,235,104, 4,115,147,115,156,115,
- 165,115,175,225,233,244,232,225,105,128, 14, 2,239,238,244,232,
- 225,105,128, 14, 5,245,225,244,244,232,225,105,128, 14, 3,247,
- 225,233,244,232,225,105,128, 14, 4,237,245,244,244,232,225,105,
- 128, 14, 91,239,107,128, 1,153,242,225,235,232,225,238,231,244,
- 232,225,105,128, 14, 6,250,243,241,245,225,242,101,128, 51,145,
- 105, 4,115,234,115,245,116, 14,116, 63,232,233,242,225,231,225,
- 238, 97,128, 48, 77,235,225,244,225,235,225,238, 97,129, 48,173,
- 116, 2,232,225,236,230,247,233,228,244,104,128,255,119,242,111,
- 3,116, 23,116, 38,116, 54,231,245,242,225,237,245,243,241,245,
- 225,242,101,128, 51, 21,237,229,229,244,239,242,245,243,241,245,
- 225,242,101,128, 51, 22,243,241,245,225,242,101,128, 51, 20,249,
- 229,239,107, 5,116, 78,116,113,116,128,116,137,116,151, 97, 2,
- 116, 84,116, 99,227,233,242,227,236,229,235,239,242,229,225,110,
- 128, 50,110,240,225,242,229,238,235,239,242,229,225,110,128, 50,
- 14,227,233,242,227,236,229,235,239,242,229,225,110,128, 50, 96,
- 235,239,242,229,225,110,128, 49, 49,240,225,242,229,238,235,239,
- 242,229,225,110,128, 50, 0,243,233,239,243,235,239,242,229,225,
- 110,128, 49, 51,234,229,227,249,242,233,236,236,233, 99,128, 4,
- 92,108, 2,116,183,116,194,233,238,229,226,229,236,239,119,128,
- 30, 53,243,241,245,225,242,101,128, 51,152,109, 3,116,211,116,
- 225,116,236,227,245,226,229,228,243,241,245,225,242,101,128, 51,
- 166,239,238,239,243,240,225,227,101,128,255, 75,243,241,245,225,
- 242,229,228,243,241,245,225,242,101,128, 51,162,111, 5,117, 8,
- 117, 34,117, 72,117, 84,117, 98,104, 2,117, 14,117, 24,233,242,
- 225,231,225,238, 97,128, 48, 83,237,243,241,245,225,242,101,128,
- 51,192,235, 97, 2,117, 41,117, 49,233,244,232,225,105,128, 14,
- 1,244,225,235,225,238, 97,129, 48,179,117, 60,232,225,236,230,
- 247,233,228,244,104,128,255,122,239,240,239,243,241,245,225,242,
- 101,128, 51, 30,240,240,225,227,249,242,233,236,236,233, 99,128,
- 4,129,114, 2,117,104,117,124,229,225,238,243,244,225,238,228,
- 225,242,228,243,249,237,226,239,108,128, 50,127,239,238,233,243,
- 227,237, 98,128, 3, 67,240, 97, 2,117,141,117,147,242,229,110,
- 128, 36,166,243,241,245,225,242,101,128, 51,170,243,233,227,249,
- 242,233,236,236,233, 99,128, 4,111,116, 2,117,175,117,184,243,
- 241,245,225,242,101,128, 51,207,245,242,238,229,100,128, 2,158,
- 117, 2,117,198,117,209,232,233,242,225,231,225,238, 97,128, 48,
- 79,235,225,244,225,235,225,238, 97,129, 48,175,117,222,232,225,
- 236,230,247,233,228,244,104,128,255,120,246,243,241,245,225,242,
- 101,128, 51,184,247,243,241,245,225,242,101,128, 51,190,108,146,
- 0,108,118, 38,120, 65,120, 94,120,160,120,198,121, 94,121,103,
- 121,119,121,143,121,161,122, 23,122, 64,122,199,122,207,122,240,
- 122,249,123, 1,123, 63, 97, 7,118, 54,118, 64,118, 71,118, 78,
- 118,103,118,119,120, 53,226,229,238,231,225,236,105,128, 9,178,
- 227,245,244,101,128, 1, 58,228,229,246, 97,128, 9, 50,231,117,
- 2,118, 85,118, 94,234,225,242,225,244,105,128, 10,178,242,237,
- 245,235,232,105,128, 10, 50,235,235,232,225,238,231,249,225,239,
- 244,232,225,105,128, 14, 69,109, 10,118,141,119, 80,119, 97,119,
- 135,119,149,119,168,119,184,119,204,119,224,119,247, 97, 2,118,
- 147,119, 72,236,229,102, 4,118,159,118,173,119, 9,119, 26,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,252,232,225,237,
- 250, 97, 2,118,183,118,224,225,226,239,246,101, 2,118,193,118,
- 207,230,233,238,225,236,225,242,225,226,233, 99,128,254,248,233,
- 243,239,236,225,244,229,228,225,242,225,226,233, 99,128,254,247,
- 226,229,236,239,119, 2,118,234,118,248,230,233,238,225,236,225,
- 242,225,226,233, 99,128,254,250,233,243,239,236,225,244,229,228,
- 225,242,225,226,233, 99,128,254,249,233,243,239,236,225,244,229,
- 228,225,242,225,226,233, 99,128,254,251,237,225,228,228,225,225,
- 226,239,246,101, 2,119, 41,119, 55,230,233,238,225,236,225,242,
- 225,226,233, 99,128,254,246,233,243,239,236,225,244,229,228,225,
- 242,225,226,233, 99,128,254,245,242,225,226,233, 99,128, 6, 68,
- 226,228, 97,129, 3,187,119, 88,243,244,242,239,235,101,128, 1,
- 155,229,100,130, 5,220,119,106,119,126,228,225,231,229,243,104,
- 129,251, 60,119,117,232,229,226,242,229,119,128,251, 60,232,229,
- 226,242,229,119,128, 5,220,230,233,238,225,236,225,242,225,226,
- 233, 99,128,254,222,232,225,232,233,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,252,202,233,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,254,223,234,229,229,237,233,238,233,244,
- 233,225,236,225,242,225,226,233, 99,128,252,201,235,232,225,232,
- 233,238,233,244,233,225,236,225,242,225,226,233, 99,128,252,203,
- 236,225,237,232,229,232,233,243,239,236,225,244,229,228,225,242,
- 225,226,233, 99,128,253,242,237,101, 2,119,254,120, 11,228,233,
- 225,236,225,242,225,226,233, 99,128,254,224,229,109, 2,120, 18,
- 120, 37,232,225,232,233,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,253,136,233,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,252,204,242,231,229,227,233,242,227,236,101,128, 37,
- 239, 98, 3,120, 73,120, 78,120, 84,225,114,128, 1,154,229,236,
- 116,128, 2,108,239,240,239,237,239,230,111,128, 49, 12, 99, 4,
- 120,104,120,111,120,120,120,147,225,242,239,110,128, 1, 62,229,
- 228,233,236,236, 97,128, 1, 60,233,242, 99, 2,120,128,120,133,
- 236,101,128, 36,219,245,237,230,236,229,248,226,229,236,239,119,
- 128, 30, 61,239,237,237,225,225,227,227,229,238,116,128, 1, 60,
- 228,239,116,130, 1, 64,120,170,120,179,225,227,227,229,238,116,
- 128, 1, 64,226,229,236,239,119,129, 30, 55,120,189,237,225,227,
- 242,239,110,128, 30, 57,101, 3,120,206,120,244,121, 89,230,116,
- 2,120,213,120,229,225,238,231,236,229,225,226,239,246,229,227,
- 237, 98,128, 3, 26,244,225,227,235,226,229,236,239,247,227,237,
- 98,128, 3, 24,243,115,132, 0, 60,121, 1,121, 23,121, 35,121,
- 81,229,241,245,225,108,129, 34,100,121, 11,239,242,231,242,229,
- 225,244,229,114,128, 34,218,237,239,238,239,243,240,225,227,101,
- 128,255, 28,111, 2,121, 41,121, 70,114, 2,121, 47,121, 60,229,
- 241,245,233,246,225,236,229,238,116,128, 34,114,231,242,229,225,
- 244,229,114,128, 34,118,246,229,242,229,241,245,225,108,128, 34,
- 102,243,237,225,236,108,128,254,100,250,104,128, 2,110,230,226,
- 236,239,227,107,128, 37,140,232,239,239,235,242,229,244,242,239,
- 230,236,229,120,128, 2,109,105, 2,121,125,121,130,242, 97,128,
- 32,164,247,238,225,242,237,229,238,233,225,110,128, 5,108,106,
- 129, 1,201,121,149,229,227,249,242,233,236,236,233, 99,128, 4,
- 89,108,132,246,192,121,173,121,197,121,208,121,217, 97, 2,121,
- 179,121,186,228,229,246, 97,128, 9, 51,231,245,234,225,242,225,
- 244,105,128, 10,179,233,238,229,226,229,236,239,119,128, 30, 59,
- 236,225,228,229,246, 97,128, 9, 52,246,239,227,225,236,233, 99,
- 3,121,231,121,241,121,248,226,229,238,231,225,236,105,128, 9,
- 225,228,229,246, 97,128, 9, 97,246,239,247,229,236,243,233,231,
- 110, 2,122, 6,122, 16,226,229,238,231,225,236,105,128, 9,227,
- 228,229,246, 97,128, 9, 99,109, 3,122, 31,122, 44,122, 55,233,
- 228,228,236,229,244,233,236,228,101,128, 2,107,239,238,239,243,
- 240,225,227,101,128,255, 76,243,241,245,225,242,101,128, 51,208,
- 111, 6,122, 78,122, 90,122,132,122,143,122,149,122,191,227,232,
- 245,236,225,244,232,225,105,128, 14, 44,231,233,227,225,108, 3,
- 122,102,122,108,122,127,225,238,100,128, 34, 39,238,239,116,129,
- 0,172,122,116,242,229,246,229,242,243,229,100,128, 35, 16,239,
- 114,128, 34, 40,236,233,238,231,244,232,225,105,128, 14, 37,238,
- 231,115,128, 1,127,247,236,233,238,101, 2,122,159,122,182, 99,
- 2,122,165,122,177,229,238,244,229,242,236,233,238,101,128,254,
- 78,237, 98,128, 3, 50,228,225,243,232,229,100,128,254, 77,250,
- 229,238,231,101,128, 37,202,240,225,242,229,110,128, 36,167,115,
- 3,122,215,122,222,122,230,236,225,243,104,128, 1, 66,241,245,
- 225,242,101,128, 33, 19,245,240,229,242,233,239,114,128,246,238,
- 244,243,232,225,228,101,128, 37,145,245,244,232,225,105,128, 14,
- 38,246,239,227,225,236,233, 99, 3,123, 15,123, 25,123, 32,226,
- 229,238,231,225,236,105,128, 9,140,228,229,246, 97,128, 9, 12,
- 246,239,247,229,236,243,233,231,110, 2,123, 46,123, 56,226,229,
- 238,231,225,236,105,128, 9,226,228,229,246, 97,128, 9, 98,248,
- 243,241,245,225,242,101,128, 51,211,109,144, 0,109,123,109,125,
- 218,125,243,126, 14,126, 39,127, 92,127,114,128,169,128,199,128,
- 248,129, 99,129,121,129,146,129,155,130,182,130,210, 97, 12,123,
- 135,123,145,123,209,123,216,123,241,124, 33,125,125,125,150,125,
- 155,125,169,125,181,125,186,226,229,238,231,225,236,105,128, 9,
- 174, 99, 2,123,151,123,203,242,239,110,132, 0,175,123,165,123,
- 176,123,182,123,191,226,229,236,239,247,227,237, 98,128, 3, 49,
- 227,237, 98,128, 3, 4,236,239,247,237,239,100,128, 2,205,237,
- 239,238,239,243,240,225,227,101,128,255,227,245,244,101,128, 30,
- 63,228,229,246, 97,128, 9, 46,231,117, 2,123,223,123,232,234,
- 225,242,225,244,105,128, 10,174,242,237,245,235,232,105,128, 10,
- 46,104, 2,123,247,124, 23,225,240,225,235,104, 2,124, 1,124,
- 10,232,229,226,242,229,119,128, 5,164,236,229,230,244,232,229,
- 226,242,229,119,128, 5,164,233,242,225,231,225,238, 97,128, 48,
- 126,105, 5,124, 45,124,114,124,177,124,207,125,113,227,232,225,
- 244,244,225,247, 97, 3,124, 60,124, 91,124, 98,236,239,119, 2,
- 124, 68,124, 79,236,229,230,244,244,232,225,105,128,248,149,242,
- 233,231,232,244,244,232,225,105,128,248,148,244,232,225,105,128,
- 14, 75,245,240,240,229,242,236,229,230,244,244,232,225,105,128,
- 248,147,229,107, 3,124,123,124,154,124,161,236,239,119, 2,124,
- 131,124,142,236,229,230,244,244,232,225,105,128,248,140,242,233,
- 231,232,244,244,232,225,105,128,248,139,244,232,225,105,128, 14,
- 72,245,240,240,229,242,236,229,230,244,244,232,225,105,128,248,
- 138,232,225,238,225,235,225,116, 2,124,189,124,200,236,229,230,
- 244,244,232,225,105,128,248,132,244,232,225,105,128, 14, 49,116,
- 3,124,215,124,243,125, 50,225,233,235,232,117, 2,124,225,124,
- 236,236,229,230,244,244,232,225,105,128,248,137,244,232,225,105,
- 128, 14, 71,232,111, 3,124,252,125, 27,125, 34,236,239,119, 2,
- 125, 4,125, 15,236,229,230,244,244,232,225,105,128,248,143,242,
- 233,231,232,244,244,232,225,105,128,248,142,244,232,225,105,128,
- 14, 73,245,240,240,229,242,236,229,230,244,244,232,225,105,128,
- 248,141,242,105, 3,125, 59,125, 90,125, 97,236,239,119, 2,125,
- 67,125, 78,236,229,230,244,244,232,225,105,128,248,146,242,233,
- 231,232,244,244,232,225,105,128,248,145,244,232,225,105,128, 14,
- 74,245,240,240,229,242,236,229,230,244,244,232,225,105,128,248,
- 144,249,225,237,239,235,244,232,225,105,128, 14, 70,235,225,244,
- 225,235,225,238, 97,129, 48,222,125,138,232,225,236,230,247,233,
- 228,244,104,128,255,143,236,101,128, 38, 66,238,243,249,239,238,
- 243,241,245,225,242,101,128, 51, 71,241,225,230,232,229,226,242,
- 229,119,128, 5,190,242,115,128, 38, 66,115, 2,125,192,125,210,
- 239,242,225,227,233,242,227,236,229,232,229,226,242,229,119,128,
- 5,175,241,245,225,242,101,128, 51,131, 98, 2,125,224,125,234,
- 239,240,239,237,239,230,111,128, 49, 7,243,241,245,225,242,101,
- 128, 51,212, 99, 2,125,249,126, 1,233,242,227,236,101,128, 36,
- 220,245,226,229,228,243,241,245,225,242,101,128, 51,165,228,239,
- 116, 2,126, 22,126, 31,225,227,227,229,238,116,128, 30, 65,226,
- 229,236,239,119,128, 30, 67,101, 7,126, 55,126,182,126,193,126,
- 208,126,233,127, 14,127, 26,101, 2,126, 61,126,169,109, 4,126,
- 71,126, 80,126, 94,126,110,225,242,225,226,233, 99,128, 6, 69,
- 230,233,238,225,236,225,242,225,226,233, 99,128,254,226,233,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,254,227,237,101,
- 2,126,117,126,130,228,233,225,236,225,242,225,226,233, 99,128,
- 254,228,229,237,105, 2,126,138,126,153,238,233,244,233,225,236,
- 225,242,225,226,233, 99,128,252,209,243,239,236,225,244,229,228,
- 225,242,225,226,233, 99,128,252, 72,244,239,242,245,243,241,245,
- 225,242,101,128, 51, 77,232,233,242,225,231,225,238, 97,128, 48,
- 129,233,250,233,229,242,225,243,241,245,225,242,101,128, 51,126,
- 235,225,244,225,235,225,238, 97,129, 48,225,126,221,232,225,236,
- 230,247,233,228,244,104,128,255,146,109,130, 5,222,126,241,127,
- 5,228,225,231,229,243,104,129,251, 62,126,252,232,229,226,242,
- 229,119,128,251, 62,232,229,226,242,229,119,128, 5,222,238,225,
- 242,237,229,238,233,225,110,128, 5,116,242,235,232, 97, 3,127,
- 37,127, 46,127, 79,232,229,226,242,229,119,128, 5,165,235,229,
- 230,245,236, 97, 2,127, 57,127, 66,232,229,226,242,229,119,128,
- 5,166,236,229,230,244,232,229,226,242,229,119,128, 5,166,236,
- 229,230,244,232,229,226,242,229,119,128, 5,165,104, 2,127, 98,
- 127,104,239,239,107,128, 2,113,250,243,241,245,225,242,101,128,
- 51,146,105, 6,127,128,127,165,128, 46,128, 57,128, 82,128,139,
- 228,100, 2,127,135,127,160,236,229,228,239,244,235,225,244,225,
- 235,225,238,225,232,225,236,230,247,233,228,244,104,128,255,101,
- 239,116,128, 0,183,229,245,109, 5,127,179,127,214,127,229,127,
- 238,128, 33, 97, 2,127,185,127,200,227,233,242,227,236,229,235,
- 239,242,229,225,110,128, 50,114,240,225,242,229,238,235,239,242,
- 229,225,110,128, 50, 18,227,233,242,227,236,229,235,239,242,229,
- 225,110,128, 50,100,235,239,242,229,225,110,128, 49, 65,112, 2,
- 127,244,128, 20, 97, 2,127,250,128, 8,238,243,233,239,243,235,
- 239,242,229,225,110,128, 49,112,242,229,238,235,239,242,229,225,
- 110,128, 50, 4,233,229,245,240,235,239,242,229,225,110,128, 49,
- 110,243,233,239,243,235,239,242,229,225,110,128, 49,111,232,233,
- 242,225,231,225,238, 97,128, 48,127,235,225,244,225,235,225,238,
- 97,129, 48,223,128, 70,232,225,236,230,247,233,228,244,104,128,
- 255,144,238,117, 2,128, 89,128,134,115,132, 34, 18,128,101,128,
- 112,128,121,128,127,226,229,236,239,247,227,237, 98,128, 3, 32,
- 227,233,242,227,236,101,128, 34,150,237,239,100,128, 2,215,240,
- 236,245,115,128, 34, 19,244,101,128, 32, 50,242,105, 2,128,146,
- 128,160,226,225,225,242,245,243,241,245,225,242,101,128, 51, 74,
- 243,241,245,225,242,101,128, 51, 73,108, 2,128,175,128,190,239,
- 238,231,236,229,231,244,245,242,238,229,100,128, 2,112,243,241,
- 245,225,242,101,128, 51,150,109, 3,128,207,128,221,128,232,227,
- 245,226,229,228,243,241,245,225,242,101,128, 51,163,239,238,239,
- 243,240,225,227,101,128,255, 77,243,241,245,225,242,229,228,243,
- 241,245,225,242,101,128, 51,159,111, 5,129, 4,129, 30,129, 55,
- 129, 65,129, 74,104, 2,129, 10,129, 20,233,242,225,231,225,238,
- 97,128, 48,130,237,243,241,245,225,242,101,128, 51,193,235,225,
- 244,225,235,225,238, 97,129, 48,226,129, 43,232,225,236,230,247,
- 233,228,244,104,128,255,147,236,243,241,245,225,242,101,128, 51,
- 214,237,225,244,232,225,105,128, 14, 33,246,229,242,243,243,241,
- 245,225,242,101,129, 51,167,129, 89,228,243,241,245,225,242,101,
- 128, 51,168,240, 97, 2,129,106,129,112,242,229,110,128, 36,168,
- 243,241,245,225,242,101,128, 51,171,115, 2,129,127,129,136,243,
- 241,245,225,242,101,128, 51,179,245,240,229,242,233,239,114,128,
- 246,239,244,245,242,238,229,100,128, 2,111,117,141, 0,181,129,
- 185,129,189,129,199,129,223,129,233,129,255,130, 10,130, 35,130,
- 58,130, 68,130, 98,130,162,130,172, 49,128, 0,181,225,243,241,
- 245,225,242,101,128, 51,130,227,104, 2,129,206,129,216,231,242,
- 229,225,244,229,114,128, 34,107,236,229,243,115,128, 34,106,230,
- 243,241,245,225,242,101,128, 51,140,103, 2,129,239,129,246,242,
- 229,229,107,128, 3,188,243,241,245,225,242,101,128, 51,141,232,
- 233,242,225,231,225,238, 97,128, 48,128,235,225,244,225,235,225,
- 238, 97,129, 48,224,130, 23,232,225,236,230,247,233,228,244,104,
- 128,255,145,108, 2,130, 41,130, 50,243,241,245,225,242,101,128,
- 51,149,244,233,240,236,121,128, 0,215,237,243,241,245,225,242,
- 101,128, 51,155,238,225,104, 2,130, 76,130, 85,232,229,226,242,
- 229,119,128, 5,163,236,229,230,244,232,229,226,242,229,119,128,
- 5,163,115, 2,130,104,130,153,233, 99, 3,130,113,130,130,130,
- 141,225,236,238,239,244,101,129, 38,106,130,124,228,226,108,128,
- 38,107,230,236,225,244,243,233,231,110,128, 38,109,243,232,225,
- 242,240,243,233,231,110,128, 38,111,243,241,245,225,242,101,128,
- 51,178,246,243,241,245,225,242,101,128, 51,182,247,243,241,245,
- 225,242,101,128, 51,188,118, 2,130,188,130,201,237,229,231,225,
- 243,241,245,225,242,101,128, 51,185,243,241,245,225,242,101,128,
- 51,183,119, 2,130,216,130,229,237,229,231,225,243,241,245,225,
- 242,101,128, 51,191,243,241,245,225,242,101,128, 51,189,110,150,
- 0,110,131, 30,131,164,131,188,131,254,132, 23,132, 81,132, 91,
- 132,158,132,201,134,235,134,253,135, 22,135, 53,135, 79,135,144,
- 137,126,137,134,137,159,137,167,138,135,138,145,138,155, 97, 8,
- 131, 48,131, 68,131, 75,131, 82,131,107,131,118,131,143,131,155,
- 98, 2,131, 54,131, 63,229,238,231,225,236,105,128, 9,168,236,
- 97,128, 34, 7,227,245,244,101,128, 1, 68,228,229,246, 97,128,
- 9, 40,231,117, 2,131, 89,131, 98,234,225,242,225,244,105,128,
- 10,168,242,237,245,235,232,105,128, 10, 40,232,233,242,225,231,
- 225,238, 97,128, 48,106,235,225,244,225,235,225,238, 97,129, 48,
- 202,131,131,232,225,236,230,247,233,228,244,104,128,255,133,240,
- 239,243,244,242,239,240,232,101,128, 1, 73,243,241,245,225,242,
- 101,128, 51,129, 98, 2,131,170,131,180,239,240,239,237,239,230,
- 111,128, 49, 11,243,240,225,227,101,128, 0,160, 99, 4,131,198,
- 131,205,131,214,131,241,225,242,239,110,128, 1, 72,229,228,233,
- 236,236, 97,128, 1, 70,233,242, 99, 2,131,222,131,227,236,101,
- 128, 36,221,245,237,230,236,229,248,226,229,236,239,119,128, 30,
- 75,239,237,237,225,225,227,227,229,238,116,128, 1, 70,228,239,
- 116, 2,132, 6,132, 15,225,227,227,229,238,116,128, 30, 69,226,
- 229,236,239,119,128, 30, 71,101, 3,132, 31,132, 42,132, 67,232,
- 233,242,225,231,225,238, 97,128, 48,109,235,225,244,225,235,225,
- 238, 97,129, 48,205,132, 55,232,225,236,230,247,233,228,244,104,
- 128,255,136,247,243,232,229,241,229,236,243,233,231,110,128, 32,
- 170,230,243,241,245,225,242,101,128, 51,139,103, 2,132, 97,132,
- 147, 97, 3,132,105,132,115,132,122,226,229,238,231,225,236,105,
- 128, 9,153,228,229,246, 97,128, 9, 25,231,117, 2,132,129,132,
- 138,234,225,242,225,244,105,128, 10,153,242,237,245,235,232,105,
- 128, 10, 25,239,238,231,245,244,232,225,105,128, 14, 7,104, 2,
- 132,164,132,174,233,242,225,231,225,238, 97,128, 48,147,239,239,
- 107, 2,132,182,132,189,236,229,230,116,128, 2,114,242,229,244,
- 242,239,230,236,229,120,128, 2,115,105, 4,132,211,133,124,133,
- 135,133,193,229,245,110, 7,132,229,133, 8,133, 40,133, 54,133,
- 63,133, 96,133,109, 97, 2,132,235,132,250,227,233,242,227,236,
- 229,235,239,242,229,225,110,128, 50,111,240,225,242,229,238,235,
- 239,242,229,225,110,128, 50, 15,227,105, 2,133, 15,133, 27,229,
- 245,227,235,239,242,229,225,110,128, 49, 53,242,227,236,229,235,
- 239,242,229,225,110,128, 50, 97,232,233,229,245,232,235,239,242,
- 229,225,110,128, 49, 54,235,239,242,229,225,110,128, 49, 52,240,
- 97, 2,133, 70,133, 84,238,243,233,239,243,235,239,242,229,225,
- 110,128, 49,104,242,229,238,235,239,242,229,225,110,128, 50, 1,
- 243,233,239,243,235,239,242,229,225,110,128, 49,103,244,233,235,
- 229,245,244,235,239,242,229,225,110,128, 49,102,232,233,242,225,
- 231,225,238, 97,128, 48,107,107, 2,133,141,133,165,225,244,225,
- 235,225,238, 97,129, 48,203,133,153,232,225,236,230,247,233,228,
- 244,104,128,255,134,232,225,232,233,116, 2,133,175,133,186,236,
- 229,230,244,244,232,225,105,128,248,153,244,232,225,105,128, 14,
- 77,238,101,141, 0, 57,133,224,133,233,133,243,134, 17,134, 24,
- 134, 49,134, 76,134,110,134,122,134,133,134,166,134,174,134,185,
- 225,242,225,226,233, 99,128, 6,105,226,229,238,231,225,236,105,
- 128, 9,239,227,233,242,227,236,101,129, 36,104,133,254,233,238,
+ 247,122,244,242,239,235,101,128, 1,181, 97,158, 0, 97, 36, 26,
+ 38,154, 39, 4, 39, 68, 39,132, 39,196, 40, 4, 40, 68, 40,126,
+ 40,190, 41, 70, 41,217, 42,137, 42,237, 43, 17, 49,192, 49,229,
+ 50, 0, 50,225, 51, 7, 52, 96, 52,168, 53,123, 53,132, 54, 5,
+ 56, 13, 57, 3, 57, 50, 57,201, 57,215, 49,138, 39, 1, 36, 50,
+ 36,114, 36,154, 36,218, 37, 26, 37, 90, 37,154, 37,218, 38, 26,
+ 38, 90, 48,138, 39, 33, 36, 74, 36, 78, 36, 82, 36, 86, 36, 90,
+ 36, 94, 36, 98, 36,102, 36,106, 36,110, 48,128, 39, 94, 49,128,
+ 39, 97, 50,128, 39, 98, 51,128, 39, 99, 52,128, 39,100, 53,128,
+ 39, 16, 54,128, 39,101, 55,128, 39,102, 56,128, 39,103, 57,128,
+ 38, 96, 49,134, 38, 27, 36,130, 36,134, 36,138, 36,142, 36,146,
+ 36,150, 48,128, 38,101, 49,128, 38,102, 50,128, 38, 99, 55,128,
+ 39, 9, 56,128, 39, 8, 57,128, 39, 7, 50,138, 38, 30, 36,178,
+ 36,182, 36,186, 36,190, 36,194, 36,198, 36,202, 36,206, 36,210,
+ 36,214, 48,128, 36, 96, 49,128, 36, 97, 50,128, 36, 98, 51,128,
+ 36, 99, 52,128, 36,100, 53,128, 36,101, 54,128, 36,102, 55,128,
+ 36,103, 56,128, 36,104, 57,128, 36,105, 51,138, 39, 12, 36,242,
+ 36,246, 36,250, 36,254, 37, 2, 37, 6, 37, 10, 37, 14, 37, 18,
+ 37, 22, 48,128, 39,118, 49,128, 39,119, 50,128, 39,120, 51,128,
+ 39,121, 52,128, 39,122, 53,128, 39,123, 54,128, 39,124, 55,128,
+ 39,125, 56,128, 39,126, 57,128, 39,127, 52,138, 39, 13, 37, 50,
+ 37, 54, 37, 58, 37, 62, 37, 66, 37, 70, 37, 74, 37, 78, 37, 82,
+ 37, 86, 48,128, 39,128, 49,128, 39,129, 50,128, 39,130, 51,128,
+ 39,131, 52,128, 39,132, 53,128, 39,133, 54,128, 39,134, 55,128,
+ 39,135, 56,128, 39,136, 57,128, 39,137, 53,138, 39, 14, 37,114,
+ 37,118, 37,122, 37,126, 37,130, 37,134, 37,138, 37,142, 37,146,
+ 37,150, 48,128, 39,138, 49,128, 39,139, 50,128, 39,140, 51,128,
+ 39,141, 52,128, 39,142, 53,128, 39,143, 54,128, 39,144, 55,128,
+ 39,145, 56,128, 39,146, 57,128, 39,147, 54,138, 39, 15, 37,178,
+ 37,182, 37,186, 37,190, 37,194, 37,198, 37,202, 37,206, 37,210,
+ 37,214, 48,128, 39,148, 49,128, 33,146, 50,128, 39,163, 51,128,
+ 33,148, 52,128, 33,149, 53,128, 39,153, 54,128, 39,155, 55,128,
+ 39,156, 56,128, 39,157, 57,128, 39,158, 55,138, 39, 17, 37,242,
+ 37,246, 37,250, 37,254, 38, 2, 38, 6, 38, 10, 38, 14, 38, 18,
+ 38, 22, 48,128, 39,159, 49,128, 39,160, 50,128, 39,161, 51,128,
+ 39,162, 52,128, 39,164, 53,128, 39,165, 54,128, 39,166, 55,128,
+ 39,167, 56,128, 39,168, 57,128, 39,169, 56,138, 39, 18, 38, 50,
+ 38, 54, 38, 58, 38, 62, 38, 66, 38, 70, 38, 74, 38, 78, 38, 82,
+ 38, 86, 48,128, 39,171, 49,128, 39,173, 50,128, 39,175, 51,128,
+ 39,178, 52,128, 39,179, 53,128, 39,181, 54,128, 39,184, 55,128,
+ 39,186, 56,128, 39,187, 57,128, 39,188, 57,138, 39, 19, 38,114,
+ 38,118, 38,122, 38,126, 38,130, 38,134, 38,138, 38,142, 38,146,
+ 38,150, 48,128, 39,189, 49,128, 39,190, 50,128, 39,154, 51,128,
+ 39,170, 52,128, 39,182, 53,128, 39,185, 54,128, 39,152, 55,128,
+ 39,180, 56,128, 39,183, 57,128, 39,172, 50,138, 39, 2, 38,178,
+ 38,224, 38,228, 38,232, 38,236, 38,240, 38,244, 38,248, 38,252,
+ 39, 0, 48,135, 39, 20, 38,196, 38,200, 38,204, 38,208, 38,212,
+ 38,216, 38,220, 48,128, 39,174, 49,128, 39,177, 50,128, 39, 3,
+ 51,128, 39, 80, 52,128, 39, 82, 53,128, 39,110, 54,128, 39,112,
+ 49,128, 39, 21, 50,128, 39, 22, 51,128, 39, 23, 52,128, 39, 24,
+ 53,128, 39, 25, 54,128, 39, 26, 55,128, 39, 27, 56,128, 39, 28,
+ 57,128, 39, 34, 51,138, 39, 4, 39, 28, 39, 32, 39, 36, 39, 40,
+ 39, 44, 39, 48, 39, 52, 39, 56, 39, 60, 39, 64, 48,128, 39, 35,
+ 49,128, 39, 36, 50,128, 39, 37, 51,128, 39, 38, 52,128, 39, 39,
+ 53,128, 38, 5, 54,128, 39, 41, 55,128, 39, 42, 56,128, 39, 43,
+ 57,128, 39, 44, 52,138, 38, 14, 39, 92, 39, 96, 39,100, 39,104,
+ 39,108, 39,112, 39,116, 39,120, 39,124, 39,128, 48,128, 39, 45,
+ 49,128, 39, 46, 50,128, 39, 47, 51,128, 39, 48, 52,128, 39, 49,
+ 53,128, 39, 50, 54,128, 39, 51, 55,128, 39, 52, 56,128, 39, 53,
+ 57,128, 39, 54, 53,138, 39, 6, 39,156, 39,160, 39,164, 39,168,
+ 39,172, 39,176, 39,180, 39,184, 39,188, 39,192, 48,128, 39, 55,
+ 49,128, 39, 56, 50,128, 39, 57, 51,128, 39, 58, 52,128, 39, 59,
+ 53,128, 39, 60, 54,128, 39, 61, 55,128, 39, 62, 56,128, 39, 63,
+ 57,128, 39, 64, 54,138, 39, 29, 39,220, 39,224, 39,228, 39,232,
+ 39,236, 39,240, 39,244, 39,248, 39,252, 40, 0, 48,128, 39, 65,
+ 49,128, 39, 66, 50,128, 39, 67, 51,128, 39, 68, 52,128, 39, 69,
+ 53,128, 39, 70, 54,128, 39, 71, 55,128, 39, 72, 56,128, 39, 73,
+ 57,128, 39, 74, 55,138, 39, 30, 40, 28, 40, 32, 40, 36, 40, 40,
+ 40, 44, 40, 48, 40, 52, 40, 56, 40, 60, 40, 64, 48,128, 39, 75,
+ 49,128, 37,207, 50,128, 39, 77, 51,128, 37,160, 52,128, 39, 79,
+ 53,128, 39, 81, 54,128, 37,178, 55,128, 37,188, 56,128, 37,198,
+ 57,128, 39, 86, 56,137, 39, 31, 40, 90, 40, 94, 40, 98, 40,102,
+ 40,106, 40,110, 40,114, 40,118, 40,122, 49,128, 37,215, 50,128,
+ 39, 88, 51,128, 39, 89, 52,128, 39, 90, 53,128, 39,111, 54,128,
+ 39,113, 55,128, 39,114, 56,128, 39,115, 57,128, 39,104, 57,138,
+ 39, 32, 40,150, 40,154, 40,158, 40,162, 40,166, 40,170, 40,174,
+ 40,178, 40,182, 40,186, 48,128, 39,105, 49,128, 39,108, 50,128,
+ 39,109, 51,128, 39,106, 52,128, 39,107, 53,128, 39,116, 54,128,
+ 39,117, 55,128, 39, 91, 56,128, 39, 92, 57,128, 39, 93, 97, 7,
+ 40,206, 40,216, 40,223, 40,230, 40,255, 41, 15, 41, 26,226,229,
+ 238,231,225,236,105,128, 9,134,227,245,244,101,128, 0,225,228,
+ 229,246, 97,128, 9, 6,231,117, 2, 40,237, 40,246,234,225,242,
+ 225,244,105,128, 10,134,242,237,245,235,232,105,128, 10, 6,237,
+ 225,244,242,225,231,245,242,237,245,235,232,105,128, 10, 62,242,
+ 245,243,241,245,225,242,101,128, 51, 3,246,239,247,229,236,243,
+ 233,231,110, 3, 41, 42, 41, 52, 41, 59,226,229,238,231,225,236,
+ 105,128, 9,190,228,229,246, 97,128, 9, 62,231,245,234,225,242,
+ 225,244,105,128, 10,190, 98, 4, 41, 80, 41,121, 41,130, 41,140,
+ 226,242,229,246,233,225,244,233,239,110, 2, 41, 95, 41,110,237,
+ 225,242,235,225,242,237,229,238,233,225,110,128, 5, 95,243,233,
+ 231,238,228,229,246, 97,128, 9,112,229,238,231,225,236,105,128,
+ 9,133,239,240,239,237,239,230,111,128, 49, 26,242,229,246,101,
+ 134, 1, 3, 41,159, 41,167, 41,178, 41,189, 41,197, 41,209,225,
+ 227,245,244,101,128, 30,175,227,249,242,233,236,236,233, 99,128,
+ 4,209,228,239,244,226,229,236,239,119,128, 30,183,231,242,225,
+ 246,101,128, 30,177,232,239,239,235,225,226,239,246,101,128, 30,
+ 179,244,233,236,228,101,128, 30,181, 99, 4, 41,227, 41,234, 42,
+ 57, 42,127,225,242,239,110,128, 1,206,233,242, 99, 2, 41,242,
+ 41,247,236,101,128, 36,208,245,237,230,236,229,120,133, 0,226,
+ 42, 10, 42, 18, 42, 29, 42, 37, 42, 49,225,227,245,244,101,128,
+ 30,165,228,239,244,226,229,236,239,119,128, 30,173,231,242,225,
+ 246,101,128, 30,167,232,239,239,235,225,226,239,246,101,128, 30,
+ 169,244,233,236,228,101,128, 30,171,245,244,101,133, 0,180, 42,
+ 73, 42, 84, 42,101, 42,108, 42,117,226,229,236,239,247,227,237,
+ 98,128, 3, 23, 99, 2, 42, 90, 42, 95,237, 98,128, 3, 1,239,
+ 237, 98,128, 3, 1,228,229,246, 97,128, 9, 84,236,239,247,237,
+ 239,100,128, 2,207,244,239,238,229,227,237, 98,128, 3, 65,249,
+ 242,233,236,236,233, 99,128, 4, 48,100, 5, 42,149, 42,159, 42,
+ 173, 42,179, 42,213,226,236,231,242,225,246,101,128, 2, 1,228,
+ 225,235,231,245,242,237,245,235,232,105,128, 10,113,229,246, 97,
+ 128, 9, 5,233,229,242,229,243,233,115,130, 0,228, 42,193, 42,
+ 204,227,249,242,233,236,236,233, 99,128, 4,211,237,225,227,242,
+ 239,110,128, 1,223,239,116, 2, 42,220, 42,228,226,229,236,239,
+ 119,128, 30,161,237,225,227,242,239,110,128, 1,225,101,131, 0,
+ 230, 42,247, 42,255, 43, 8,225,227,245,244,101,128, 1,253,235,
+ 239,242,229,225,110,128, 49, 80,237,225,227,242,239,110,128, 1,
+ 227,230,233,105, 6, 43, 33, 43, 53, 45,246, 45,252, 46, 11, 49,
+ 111, 48, 2, 43, 39, 43, 46,176,178,176, 56,128, 32, 21,184,185,
+ 180, 49,128, 32,164,177, 48, 3, 43, 62, 45, 86, 45,221, 48, 9,
+ 43, 82, 43,102, 43,164, 43,226, 44, 32, 44, 94, 44,156, 44,218,
+ 45, 24, 49, 3, 43, 90, 43, 94, 43, 98, 55,128, 4, 16, 56,128,
+ 4, 17, 57,128, 4, 18, 50, 10, 43,124, 43,128, 43,132, 43,136,
+ 43,140, 43,144, 43,148, 43,152, 43,156, 43,160, 48,128, 4, 19,
+ 49,128, 4, 20, 50,128, 4, 21, 51,128, 4, 1, 52,128, 4, 22,
+ 53,128, 4, 23, 54,128, 4, 24, 55,128, 4, 25, 56,128, 4, 26,
+ 57,128, 4, 27, 51, 10, 43,186, 43,190, 43,194, 43,198, 43,202,
+ 43,206, 43,210, 43,214, 43,218, 43,222, 48,128, 4, 28, 49,128,
+ 4, 29, 50,128, 4, 30, 51,128, 4, 31, 52,128, 4, 32, 53,128,
+ 4, 33, 54,128, 4, 34, 55,128, 4, 35, 56,128, 4, 36, 57,128,
+ 4, 37, 52, 10, 43,248, 43,252, 44, 0, 44, 4, 44, 8, 44, 12,
+ 44, 16, 44, 20, 44, 24, 44, 28, 48,128, 4, 38, 49,128, 4, 39,
+ 50,128, 4, 40, 51,128, 4, 41, 52,128, 4, 42, 53,128, 4, 43,
+ 54,128, 4, 44, 55,128, 4, 45, 56,128, 4, 46, 57,128, 4, 47,
+ 53, 10, 44, 54, 44, 58, 44, 62, 44, 66, 44, 70, 44, 74, 44, 78,
+ 44, 82, 44, 86, 44, 90, 48,128, 4,144, 49,128, 4, 2, 50,128,
+ 4, 3, 51,128, 4, 4, 52,128, 4, 5, 53,128, 4, 6, 54,128,
+ 4, 7, 55,128, 4, 8, 56,128, 4, 9, 57,128, 4, 10, 54, 10,
+ 44,116, 44,120, 44,124, 44,128, 44,132, 44,136, 44,140, 44,144,
+ 44,148, 44,152, 48,128, 4, 11, 49,128, 4, 12, 50,128, 4, 14,
+ 51,128,246,196, 52,128,246,197, 53,128, 4, 48, 54,128, 4, 49,
+ 55,128, 4, 50, 56,128, 4, 51, 57,128, 4, 52, 55, 10, 44,178,
+ 44,182, 44,186, 44,190, 44,194, 44,198, 44,202, 44,206, 44,210,
+ 44,214, 48,128, 4, 53, 49,128, 4, 81, 50,128, 4, 54, 51,128,
+ 4, 55, 52,128, 4, 56, 53,128, 4, 57, 54,128, 4, 58, 55,128,
+ 4, 59, 56,128, 4, 60, 57,128, 4, 61, 56, 10, 44,240, 44,244,
+ 44,248, 44,252, 45, 0, 45, 4, 45, 8, 45, 12, 45, 16, 45, 20,
+ 48,128, 4, 62, 49,128, 4, 63, 50,128, 4, 64, 51,128, 4, 65,
+ 52,128, 4, 66, 53,128, 4, 67, 54,128, 4, 68, 55,128, 4, 69,
+ 56,128, 4, 70, 57,128, 4, 71, 57, 10, 45, 46, 45, 50, 45, 54,
+ 45, 58, 45, 62, 45, 66, 45, 70, 45, 74, 45, 78, 45, 82, 48,128,
+ 4, 72, 49,128, 4, 73, 50,128, 4, 74, 51,128, 4, 75, 52,128,
+ 4, 76, 53,128, 4, 77, 54,128, 4, 78, 55,128, 4, 79, 56,128,
+ 4,145, 57,128, 4, 82, 49, 4, 45, 96, 45,158, 45,163, 45,189,
+ 48, 10, 45,118, 45,122, 45,126, 45,130, 45,134, 45,138, 45,142,
+ 45,146, 45,150, 45,154, 48,128, 4, 83, 49,128, 4, 84, 50,128,
+ 4, 85, 51,128, 4, 86, 52,128, 4, 87, 53,128, 4, 88, 54,128,
+ 4, 89, 55,128, 4, 90, 56,128, 4, 91, 57,128, 4, 92,177, 48,
+ 128, 4, 94, 52, 4, 45,173, 45,177, 45,181, 45,185, 53,128, 4,
+ 15, 54,128, 4, 98, 55,128, 4,114, 56,128, 4,116, 57, 5, 45,
+ 201, 45,205, 45,209, 45,213, 45,217, 50,128,246,198, 51,128, 4,
+ 95, 52,128, 4, 99, 53,128, 4,115, 54,128, 4,117, 56, 2, 45,
+ 227, 45,241, 51, 2, 45,233, 45,237, 49,128,246,199, 50,128,246,
+ 200,180, 54,128, 4,217,178,185, 57,128, 32, 14,179, 48, 2, 46,
+ 3, 46, 7, 48,128, 32, 15, 49,128, 32, 13,181, 55, 7, 46, 28,
+ 46, 98, 47,163, 47,240, 48,197, 49, 34, 49,105, 51, 2, 46, 34,
+ 46, 48, 56, 2, 46, 40, 46, 44, 49,128, 6,106, 56,128, 6, 12,
+ 57, 8, 46, 66, 46, 70, 46, 74, 46, 78, 46, 82, 46, 86, 46, 90,
+ 46, 94, 50,128, 6, 96, 51,128, 6, 97, 52,128, 6, 98, 53,128,
+ 6, 99, 54,128, 6,100, 55,128, 6,101, 56,128, 6,102, 57,128,
+ 6,103, 52, 7, 46,114, 46,146, 46,208, 47, 14, 47, 46, 47,102,
+ 47,158, 48, 5, 46,126, 46,130, 46,134, 46,138, 46,142, 48,128,
+ 6,104, 49,128, 6,105, 51,128, 6, 27, 55,128, 6, 31, 57,128,
+ 6, 33, 49, 10, 46,168, 46,172, 46,176, 46,180, 46,184, 46,188,
+ 46,192, 46,196, 46,200, 46,204, 48,128, 6, 34, 49,128, 6, 35,
+ 50,128, 6, 36, 51,128, 6, 37, 52,128, 6, 38, 53,128, 6, 39,
+ 54,128, 6, 40, 55,128, 6, 41, 56,128, 6, 42, 57,128, 6, 43,
+ 50, 10, 46,230, 46,234, 46,238, 46,242, 46,246, 46,250, 46,254,
+ 47, 2, 47, 6, 47, 10, 48,128, 6, 44, 49,128, 6, 45, 50,128,
+ 6, 46, 51,128, 6, 47, 52,128, 6, 48, 53,128, 6, 49, 54,128,
+ 6, 50, 55,128, 6, 51, 56,128, 6, 52, 57,128, 6, 53, 51, 5,
+ 47, 26, 47, 30, 47, 34, 47, 38, 47, 42, 48,128, 6, 54, 49,128,
+ 6, 55, 50,128, 6, 56, 51,128, 6, 57, 52,128, 6, 58, 52, 9,
+ 47, 66, 47, 70, 47, 74, 47, 78, 47, 82, 47, 86, 47, 90, 47, 94,
+ 47, 98, 48,128, 6, 64, 49,128, 6, 65, 50,128, 6, 66, 51,128,
+ 6, 67, 52,128, 6, 68, 53,128, 6, 69, 54,128, 6, 70, 56,128,
+ 6, 72, 57,128, 6, 73, 53, 9, 47,122, 47,126, 47,130, 47,134,
+ 47,138, 47,142, 47,146, 47,150, 47,154, 48,128, 6, 74, 49,128,
+ 6, 75, 50,128, 6, 76, 51,128, 6, 77, 52,128, 6, 78, 53,128,
+ 6, 79, 54,128, 6, 80, 55,128, 6, 81, 56,128, 6, 82,183, 48,
+ 128, 6, 71, 53, 3, 47,171, 47,203, 47,235, 48, 5, 47,183, 47,
+ 187, 47,191, 47,195, 47,199, 53,128, 6,164, 54,128, 6,126, 55,
+ 128, 6,134, 56,128, 6,152, 57,128, 6,175, 49, 5, 47,215, 47,
+ 219, 47,223, 47,227, 47,231, 49,128, 6,121, 50,128, 6,136, 51,
+ 128, 6,145, 52,128, 6,186, 57,128, 6,210,179, 52,128, 6,213,
+ 54, 7, 48, 0, 48, 5, 48, 10, 48, 15, 48, 53, 48,115, 48,177,
+ 179, 54,128, 32,170,180, 53,128, 5,190,181, 56,128, 5,195, 54,
+ 6, 48, 29, 48, 33, 48, 37, 48, 41, 48, 45, 48, 49, 52,128, 5,
+ 208, 53,128, 5,209, 54,128, 5,210, 55,128, 5,211, 56,128, 5,
+ 212, 57,128, 5,213, 55, 10, 48, 75, 48, 79, 48, 83, 48, 87, 48,
+ 91, 48, 95, 48, 99, 48,103, 48,107, 48,111, 48,128, 5,214, 49,
+ 128, 5,215, 50,128, 5,216, 51,128, 5,217, 52,128, 5,218, 53,
+ 128, 5,219, 54,128, 5,220, 55,128, 5,221, 56,128, 5,222, 57,
+ 128, 5,223, 56, 10, 48,137, 48,141, 48,145, 48,149, 48,153, 48,
+ 157, 48,161, 48,165, 48,169, 48,173, 48,128, 5,224, 49,128, 5,
+ 225, 50,128, 5,226, 51,128, 5,227, 52,128, 5,228, 53,128, 5,
+ 229, 54,128, 5,230, 55,128, 5,231, 56,128, 5,232, 57,128, 5,
+ 233, 57, 3, 48,185, 48,189, 48,193, 48,128, 5,234, 52,128,251,
+ 42, 53,128,251, 43, 55, 4, 48,207, 48,221, 48,241, 48,246, 48,
+ 2, 48,213, 48,217, 48,128,251, 75, 53,128,251, 31, 49, 3, 48,
+ 229, 48,233, 48,237, 54,128, 5,240, 55,128, 5,241, 56,128, 5,
+ 242,178, 51,128,251, 53, 57, 7, 49, 6, 49, 10, 49, 14, 49, 18,
+ 49, 22, 49, 26, 49, 30, 51,128, 5,180, 52,128, 5,181, 53,128,
+ 5,182, 54,128, 5,187, 55,128, 5,184, 56,128, 5,183, 57,128,
+ 5,176, 56, 3, 49, 42, 49, 86, 49, 91, 48, 7, 49, 58, 49, 62,
+ 49, 66, 49, 70, 49, 74, 49, 78, 49, 82, 48,128, 5,178, 49,128,
+ 5,177, 50,128, 5,179, 51,128, 5,194, 52,128, 5,193, 54,128,
+ 5,185, 55,128, 5,188,179, 57,128, 5,189, 52, 2, 49, 97, 49,
+ 101, 49,128, 5,191, 50,128, 5,192,185,178, 57,128, 2,188, 54,
+ 3, 49,119, 49,178, 49,185, 49, 4, 49,129, 49,145, 49,151, 49,
+ 172, 50, 2, 49,135, 49,140,180, 56,128, 33, 5,184, 57,128, 33,
+ 19,179,181, 50,128, 33, 22,181, 55, 3, 49,160, 49,164, 49,168,
+ 51,128, 32, 44, 52,128, 32, 45, 53,128, 32, 46,182,182, 52,128,
+ 32, 12,179,177,182, 55,128, 6,109,180,185,179, 55,128, 2,189,
+ 103, 2, 49,198, 49,205,242,225,246,101,128, 0,224,117, 2, 49,
+ 211, 49,220,234,225,242,225,244,105,128, 10,133,242,237,245,235,
+ 232,105,128, 10, 5,104, 2, 49,235, 49,245,233,242,225,231,225,
+ 238, 97,128, 48, 66,239,239,235,225,226,239,246,101,128, 30,163,
+ 105, 7, 50, 16, 50, 41, 50, 48, 50, 60, 50, 85, 50,101, 50,181,
+ 98, 2, 50, 22, 50, 31,229,238,231,225,236,105,128, 9,144,239,
+ 240,239,237,239,230,111,128, 49, 30,228,229,246, 97,128, 9, 16,
+ 229,227,249,242,233,236,236,233, 99,128, 4,213,231,117, 2, 50,
+ 67, 50, 76,234,225,242,225,244,105,128, 10,144,242,237,245,235,
+ 232,105,128, 10, 16,237,225,244,242,225,231,245,242,237,245,235,
+ 232,105,128, 10, 72,110, 5, 50,113, 50,122, 50,136, 50,152, 50,
+ 167,225,242,225,226,233, 99,128, 6, 57,230,233,238,225,236,225,
+ 242,225,226,233, 99,128,254,202,233,238,233,244,233,225,236,225,
+ 242,225,226,233, 99,128,254,203,237,229,228,233,225,236,225,242,
+ 225,226,233, 99,128,254,204,246,229,242,244,229,228,226,242,229,
+ 246,101,128, 2, 3,246,239,247,229,236,243,233,231,110, 3, 50,
+ 197, 50,207, 50,214,226,229,238,231,225,236,105,128, 9,200,228,
+ 229,246, 97,128, 9, 72,231,245,234,225,242,225,244,105,128, 10,
+ 200,107, 2, 50,231, 50,255,225,244,225,235,225,238, 97,129, 48,
+ 162, 50,243,232,225,236,230,247,233,228,244,104,128,255,113,239,
+ 242,229,225,110,128, 49, 79,108, 3, 51, 15, 52, 71, 52, 80,101,
+ 2, 51, 21, 52, 66,102,136, 5,208, 51, 41, 51, 50, 51, 65, 51,
+ 79, 51,168, 51,182, 52, 37, 52, 51,225,242,225,226,233, 99,128,
+ 6, 39,228,225,231,229,243,232,232,229,226,242,229,119,128,251,
+ 48,230,233,238,225,236,225,242,225,226,233, 99,128,254,142,104,
+ 2, 51, 85, 51,160,225,237,250, 97, 2, 51, 94, 51,127,225,226,
+ 239,246,101, 2, 51,104, 51,113,225,242,225,226,233, 99,128, 6,
+ 35,230,233,238,225,236,225,242,225,226,233, 99,128,254,132,226,
+ 229,236,239,119, 2, 51,137, 51,146,225,242,225,226,233, 99,128,
+ 6, 37,230,233,238,225,236,225,242,225,226,233, 99,128,254,136,
+ 229,226,242,229,119,128, 5,208,236,225,237,229,228,232,229,226,
+ 242,229,119,128,251, 79,237, 97, 2, 51,189, 51,225,228,228,225,
+ 225,226,239,246,101, 2, 51,202, 51,211,225,242,225,226,233, 99,
+ 128, 6, 34,230,233,238,225,236,225,242,225,226,233, 99,128,254,
+ 130,235,243,245,242, 97, 4, 51,239, 51,248, 52, 6, 52, 22,225,
+ 242,225,226,233, 99,128, 6, 73,230,233,238,225,236,225,242,225,
+ 226,233, 99,128,254,240,233,238,233,244,233,225,236,225,242,225,
+ 226,233, 99,128,254,243,237,229,228,233,225,236,225,242,225,226,
+ 233, 99,128,254,244,240,225,244,225,232,232,229,226,242,229,119,
+ 128,251, 46,241,225,237,225,244,243,232,229,226,242,229,119,128,
+ 251, 47,240,104,128, 33, 53,236,229,241,245,225,108,128, 34, 76,
+ 240,232, 97,129, 3,177, 52, 88,244,239,238,239,115,128, 3,172,
+ 109, 4, 52,106, 52,114, 52,125, 52,159,225,227,242,239,110,128,
+ 1, 1,239,238,239,243,240,225,227,101,128,255, 65,240,229,242,
+ 243,225,238,100,130, 0, 38, 52,139, 52,151,237,239,238,239,243,
+ 240,225,227,101,128,255, 6,243,237,225,236,108,128,247, 38,243,
+ 241,245,225,242,101,128, 51,194,110, 4, 52,178, 52,189, 53, 55,
+ 53, 65,226,239,240,239,237,239,230,111,128, 49, 34,103, 4, 52,
+ 199, 52,210, 52,224, 53, 47,226,239,240,239,237,239,230,111,128,
+ 49, 36,235,232,225,238,235,232,245,244,232,225,105,128, 14, 90,
+ 236,101,131, 34, 32, 52,235, 53, 32, 53, 39,226,242,225,227,235,
+ 229,116, 2, 52,247, 53, 11,236,229,230,116,129, 48, 8, 53, 0,
+ 246,229,242,244,233,227,225,108,128,254, 63,242,233,231,232,116,
+ 129, 48, 9, 53, 21,246,229,242,244,233,227,225,108,128,254, 64,
+ 236,229,230,116,128, 35, 41,242,233,231,232,116,128, 35, 42,243,
+ 244,242,239,109,128, 33, 43,239,244,229,236,229,233, 97,128, 3,
+ 135,117, 2, 53, 71, 53, 83,228,225,244,244,225,228,229,246, 97,
+ 128, 9, 82,243,246,225,242, 97, 3, 53, 95, 53,105, 53,112,226,
+ 229,238,231,225,236,105,128, 9,130,228,229,246, 97,128, 9, 2,
+ 231,245,234,225,242,225,244,105,128, 10,130,239,231,239,238,229,
+ 107,128, 1, 5,112, 3, 53,140, 53,164, 53,194, 97, 2, 53,146,
+ 53,158,225,244,239,243,241,245,225,242,101,128, 51, 0,242,229,
+ 110,128, 36,156,239,243,244,242,239,240,232,101, 2, 53,177, 53,
+ 188,225,242,237,229,238,233,225,110,128, 5, 90,237,239,100,128,
+ 2,188,112, 2, 53,200, 53,205,236,101,128,248,255,242,111, 2,
+ 53,212, 53,220,225,227,232,229,115,128, 34, 80,120, 2, 53,226,
+ 53,246,229,241,245,225,108,129, 34, 72, 53,236,239,242,233,237,
+ 225,231,101,128, 34, 82,233,237,225,244,229,236,249,229,241,245,
+ 225,108,128, 34, 69,114, 4, 54, 15, 54, 42, 54, 46, 54, 91,225,
+ 229, 97, 2, 54, 23, 54, 33,229,235,239,242,229,225,110,128, 49,
+ 142,235,239,242,229,225,110,128, 49,141, 99,128, 35, 18,105, 2,
+ 54, 52, 54, 66,231,232,244,232,225,236,230,242,233,238,103,128,
+ 30,154,238,103,130, 0,229, 54, 75, 54, 83,225,227,245,244,101,
+ 128, 1,251,226,229,236,239,119,128, 30, 1,242,239,119, 8, 54,
+ 111, 54,118, 54,247, 55, 57, 55,107, 55,162, 55,185, 56, 4,226,
+ 239,244,104,128, 33,148,100, 3, 54,126, 54,165, 54,212,225,243,
+ 104, 4, 54,138, 54,145, 54,152, 54,160,228,239,247,110,128, 33,
+ 227,236,229,230,116,128, 33,224,242,233,231,232,116,128, 33,226,
+ 245,112,128, 33,225,226,108, 5, 54,178, 54,185, 54,192, 54,199,
+ 54,207,226,239,244,104,128, 33,212,228,239,247,110,128, 33,211,
+ 236,229,230,116,128, 33,208,242,233,231,232,116,128, 33,210,245,
+ 112,128, 33,209,239,247,110,131, 33,147, 54,224, 54,231, 54,239,
+ 236,229,230,116,128, 33,153,242,233,231,232,116,128, 33,152,247,
+ 232,233,244,101,128, 33,233,104, 2, 54,253, 55, 48,229,225,100,
+ 4, 55, 9, 55, 19, 55, 29, 55, 40,228,239,247,238,237,239,100,
+ 128, 2,197,236,229,230,244,237,239,100,128, 2,194,242,233,231,
+ 232,244,237,239,100,128, 2,195,245,240,237,239,100,128, 2,196,
+ 239,242,233,250,229,120,128,248,231,236,229,230,116,131, 33,144,
+ 55, 70, 55, 87, 55, 99,228,226,108,129, 33,208, 55, 78,243,244,
+ 242,239,235,101,128, 33,205,239,246,229,242,242,233,231,232,116,
+ 128, 33,198,247,232,233,244,101,128, 33,230,242,233,231,232,116,
+ 132, 33,146, 55,123, 55,135, 55,143, 55,154,228,226,236,243,244,
+ 242,239,235,101,128, 33,207,232,229,225,246,121,128, 39,158,239,
+ 246,229,242,236,229,230,116,128, 33,196,247,232,233,244,101,128,
+ 33,232,244,225, 98, 2, 55,170, 55,177,236,229,230,116,128, 33,
+ 228,242,233,231,232,116,128, 33,229,245,112,132, 33,145, 55,198,
+ 55,226, 55,244, 55,252,100, 2, 55,204, 55,216,110,129, 33,149,
+ 55,210,226,243,101,128, 33,168,239,247,238,226,225,243,101,128,
+ 33,168,236,229,230,116,129, 33,150, 55,235,239,230,228,239,247,
+ 110,128, 33,197,242,233,231,232,116,128, 33,151,247,232,233,244,
+ 101,128, 33,231,246,229,242,244,229,120,128,248,230,115, 5, 56,
+ 25, 56,101, 56,146, 56,229, 56,239, 99, 2, 56, 31, 56, 83,233,
+ 105, 2, 56, 38, 56, 61,227,233,242,227,245,109,129, 0, 94, 56,
+ 49,237,239,238,239,243,240,225,227,101,128,255, 62,244,233,236,
+ 228,101,129, 0,126, 56, 71,237,239,238,239,243,240,225,227,101,
+ 128,255, 94,242,233,240,116,129, 2, 81, 56, 92,244,245,242,238,
+ 229,100,128, 2, 82,237,225,236,108, 2, 56,110, 56,121,232,233,
+ 242,225,231,225,238, 97,128, 48, 65,235,225,244,225,235,225,238,
+ 97,129, 48,161, 56,134,232,225,236,230,247,233,228,244,104,128,
+ 255,103,244,229,242,233,115, 2, 56,156, 56,225,107,131, 0, 42,
+ 56,166, 56,194, 56,217, 97, 2, 56,172, 56,186,236,244,239,238,
+ 229,225,242,225,226,233, 99,128, 6,109,242,225,226,233, 99,128,
+ 6,109,109, 2, 56,200, 56,206,225,244,104,128, 34, 23,239,238,
+ 239,243,240,225,227,101,128,255, 10,243,237,225,236,108,128,254,
+ 97,109,128, 32, 66,245,240,229,242,233,239,114,128,246,233,249,
+ 237,240,244,239,244,233,227,225,236,236,249,229,241,245,225,108,
+ 128, 34, 67,116,132, 0, 64, 57, 15, 57, 22, 57, 34, 57, 42,233,
+ 236,228,101,128, 0,227,237,239,238,239,243,240,225,227,101,128,
+ 255, 32,243,237,225,236,108,128,254,107,245,242,238,229,100,128,
+ 2, 80,117, 6, 57, 64, 57, 89, 57, 96, 57,121, 57,141, 57,157,
+ 98, 2, 57, 70, 57, 79,229,238,231,225,236,105,128, 9,148,239,
+ 240,239,237,239,230,111,128, 49, 32,228,229,246, 97,128, 9, 20,
+ 231,117, 2, 57,103, 57,112,234,225,242,225,244,105,128, 10,148,
+ 242,237,245,235,232,105,128, 10, 20,236,229,238,231,244,232,237,
+ 225,242,235,226,229,238,231,225,236,105,128, 9,215,237,225,244,
+ 242,225,231,245,242,237,245,235,232,105,128, 10, 76,246,239,247,
+ 229,236,243,233,231,110, 3, 57,173, 57,183, 57,190,226,229,238,
+ 231,225,236,105,128, 9,204,228,229,246, 97,128, 9, 76,231,245,
+ 234,225,242,225,244,105,128, 10,204,246,225,231,242,225,232,225,
+ 228,229,246, 97,128, 9, 61,121, 2, 57,221, 57,233,226,225,242,
+ 237,229,238,233,225,110,128, 5, 97,233,110,130, 5,226, 57,242,
+ 58, 1,225,236,244,239,238,229,232,229,226,242,229,119,128,251,
+ 32,232,229,226,242,229,119,128, 5,226, 98,144, 0, 98, 58, 46,
+ 58,181, 58,192, 58,201, 58,226, 60, 11, 60, 73, 60,146, 62, 72,
+ 62, 84, 62,127, 62,135, 62,145, 64, 15, 64, 39, 64, 48, 97, 7,
+ 58, 62, 58, 72, 58, 96, 58,103, 58,128, 58,152, 58,163,226,229,
+ 238,231,225,236,105,128, 9,172,227,235,243,236,225,243,104,129,
+ 0, 92, 58, 84,237,239,238,239,243,240,225,227,101,128,255, 60,
+ 228,229,246, 97,128, 9, 44,231,117, 2, 58,110, 58,119,234,225,
+ 242,225,244,105,128, 10,172,242,237,245,235,232,105,128, 10, 44,
+ 104, 2, 58,134, 58,144,233,242,225,231,225,238, 97,128, 48,112,
+ 244,244,232,225,105,128, 14, 63,235,225,244,225,235,225,238, 97,
+ 128, 48,208,114,129, 0,124, 58,169,237,239,238,239,243,240,225,
+ 227,101,128,255, 92,226,239,240,239,237,239,230,111,128, 49, 5,
+ 227,233,242,227,236,101,128, 36,209,228,239,116, 2, 58,209, 58,
+ 218,225,227,227,229,238,116,128, 30, 3,226,229,236,239,119,128,
+ 30, 5,101, 6, 58,240, 59, 5, 59, 28, 59,170, 59,181, 59,193,
+ 225,237,229,228,243,233,248,244,229,229,238,244,232,238,239,244,
+ 229,115,128, 38,108, 99, 2, 59, 11, 59, 18,225,245,243,101,128,
+ 34, 53,249,242,233,236,236,233, 99,128, 4, 49,104, 5, 59, 40,
+ 59, 49, 59, 63, 59, 93, 59,152,225,242,225,226,233, 99,128, 6,
+ 40,230,233,238,225,236,225,242,225,226,233, 99,128,254,144,105,
+ 2, 59, 69, 59, 84,238,233,244,233,225,236,225,242,225,226,233,
+ 99,128,254,145,242,225,231,225,238, 97,128, 48,121,237,101, 2,
+ 59,100, 59,113,228,233,225,236,225,242,225,226,233, 99,128,254,
+ 146,229,237,105, 2, 59,121, 59,136,238,233,244,233,225,236,225,
+ 242,225,226,233, 99,128,252,159,243,239,236,225,244,229,228,225,
+ 242,225,226,233, 99,128,252, 8,238,239,239,238,230,233,238,225,
+ 236,225,242,225,226,233, 99,128,252,109,235,225,244,225,235,225,
+ 238, 97,128, 48,217,238,225,242,237,229,238,233,225,110,128, 5,
+ 98,116,132, 5,209, 59,205, 59,225, 59,245, 59,254, 97,129, 3,
+ 178, 59,211,243,249,237,226,239,236,231,242,229,229,107,128, 3,
+ 208,228,225,231,229,243,104,129,251, 49, 59,236,232,229,226,242,
+ 229,119,128,251, 49,232,229,226,242,229,119,128, 5,209,242,225,
+ 230,229,232,229,226,242,229,119,128,251, 76,104, 2, 60, 17, 60,
+ 67, 97, 3, 60, 25, 60, 35, 60, 42,226,229,238,231,225,236,105,
+ 128, 9,173,228,229,246, 97,128, 9, 45,231,117, 2, 60, 49, 60,
+ 58,234,225,242,225,244,105,128, 10,173,242,237,245,235,232,105,
+ 128, 10, 45,239,239,107,128, 2, 83,105, 5, 60, 85, 60, 96, 60,
+ 107, 60,121, 60,135,232,233,242,225,231,225,238, 97,128, 48,115,
+ 235,225,244,225,235,225,238, 97,128, 48,211,236,225,226,233,225,
+ 236,227,236,233,227,107,128, 2,152,238,228,233,231,245,242,237,
+ 245,235,232,105,128, 10, 2,242,245,243,241,245,225,242,101,128,
+ 51, 49,108, 3, 60,154, 62, 55, 62, 66, 97, 2, 60,160, 62, 50,
+ 227,107, 6, 60,175, 60,184, 60,221, 61,114, 61,169, 61,221,227,
+ 233,242,227,236,101,128, 37,207,100, 2, 60,190, 60,199,233,225,
+ 237,239,238,100,128, 37,198,239,247,238,240,239,233,238,244,233,
+ 238,231,244,242,233,225,238,231,236,101,128, 37,188,108, 2, 60,
+ 227, 61, 74,101, 2, 60,233, 61, 13,230,244,240,239,233,238,244,
+ 233,238,103, 2, 60,248, 61, 2,240,239,233,238,244,229,114,128,
+ 37,196,244,242,233,225,238,231,236,101,128, 37,192,238,244,233,
+ 227,245,236,225,242,226,242,225,227,235,229,116, 2, 61, 33, 61,
+ 53,236,229,230,116,129, 48, 16, 61, 42,246,229,242,244,233,227,
+ 225,108,128,254, 59,242,233,231,232,116,129, 48, 17, 61, 63,246,
+ 229,242,244,233,227,225,108,128,254, 60,239,247,229,114, 2, 61,
+ 83, 61, 98,236,229,230,244,244,242,233,225,238,231,236,101,128,
+ 37,227,242,233,231,232,244,244,242,233,225,238,231,236,101,128,
+ 37,226,114, 2, 61,120, 61,131,229,227,244,225,238,231,236,101,
+ 128, 37,172,233,231,232,244,240,239,233,238,244,233,238,103, 2,
+ 61,148, 61,158,240,239,233,238,244,229,114,128, 37,186,244,242,
+ 233,225,238,231,236,101,128, 37,182,115, 3, 61,177, 61,207, 61,
+ 215,109, 2, 61,183, 61,195,225,236,236,243,241,245,225,242,101,
+ 128, 37,170,233,236,233,238,231,230,225,227,101,128, 38, 59,241,
+ 245,225,242,101,128, 37,160,244,225,114,128, 38, 5,245,240,112,
+ 2, 61,229, 62, 11,229,114, 2, 61,236, 61,251,236,229,230,244,
+ 244,242,233,225,238,231,236,101,128, 37,228,242,233,231,232,244,
+ 244,242,233,225,238,231,236,101,128, 37,229,239,233,238,244,233,
+ 238,103, 2, 62, 23, 62, 39,243,237,225,236,236,244,242,233,225,
+ 238,231,236,101,128, 37,180,244,242,233,225,238,231,236,101,128,
+ 37,178,238,107,128, 36, 35,233,238,229,226,229,236,239,119,128,
+ 30, 7,239,227,107,128, 37,136,237,239,238,239,243,240,225,227,
+ 101,128,255, 66,111, 3, 62, 92, 62,105, 62,116,226,225,233,237,
+ 225,233,244,232,225,105,128, 14, 26,232,233,242,225,231,225,238,
+ 97,128, 48,124,235,225,244,225,235,225,238, 97,128, 48,220,240,
+ 225,242,229,110,128, 36,157,241,243,241,245,225,242,101,128, 51,
+ 195,114, 4, 62,155, 63,149, 63,222, 64, 5,225, 99, 2, 62,162,
+ 63, 56,101, 3, 62,170, 62,175, 62,243,229,120,128,248,244,236,
+ 229,230,116,133, 0,123, 62,192, 62,197, 62,219, 62,227, 62,232,
+ 226,116,128,248,243,109, 2, 62,203, 62,208,233,100,128,248,242,
+ 239,238,239,243,240,225,227,101,128,255, 91,243,237,225,236,108,
+ 128,254, 91,244,112,128,248,241,246,229,242,244,233,227,225,108,
+ 128,254, 55,242,233,231,232,116,133, 0,125, 63, 5, 63, 10, 63,
+ 32, 63, 40, 63, 45,226,116,128,248,254,109, 2, 63, 16, 63, 21,
+ 233,100,128,248,253,239,238,239,243,240,225,227,101,128,255, 93,
+ 243,237,225,236,108,128,254, 92,244,112,128,248,252,246,229,242,
+ 244,233,227,225,108,128,254, 56,235,229,116, 2, 63, 64, 63,106,
+ 236,229,230,116,132, 0, 91, 63, 79, 63, 84, 63, 89, 63,101,226,
+ 116,128,248,240,229,120,128,248,239,237,239,238,239,243,240,225,
+ 227,101,128,255, 59,244,112,128,248,238,242,233,231,232,116,132,
+ 0, 93, 63,122, 63,127, 63,132, 63,144,226,116,128,248,251,229,
+ 120,128,248,250,237,239,238,239,243,240,225,227,101,128,255, 61,
+ 244,112,128,248,249,229,246,101,131, 2,216, 63,161, 63,172, 63,
+ 178,226,229,236,239,247,227,237, 98,128, 3, 46,227,237, 98,128,
+ 3, 6,233,238,246,229,242,244,229,100, 3, 63,193, 63,204, 63,
+ 210,226,229,236,239,247,227,237, 98,128, 3, 47,227,237, 98,128,
+ 3, 17,228,239,245,226,236,229,227,237, 98,128, 3, 97,233,228,
+ 231,101, 2, 63,231, 63,242,226,229,236,239,247,227,237, 98,128,
+ 3, 42,233,238,246,229,242,244,229,228,226,229,236,239,247,227,
+ 237, 98,128, 3, 58,239,235,229,238,226,225,114,128, 0,166,115,
+ 2, 64, 21, 64, 29,244,242,239,235,101,128, 1,128,245,240,229,
+ 242,233,239,114,128,246,234,244,239,240,226,225,114,128, 1,131,
+ 117, 3, 64, 56, 64, 67, 64, 78,232,233,242,225,231,225,238, 97,
+ 128, 48,118,235,225,244,225,235,225,238, 97,128, 48,214,236,108,
+ 2, 64, 85, 64,115,229,116,130, 32, 34, 64, 94, 64,104,233,238,
+ 246,229,242,243,101,128, 37,216,239,240,229,242,225,244,239,114,
+ 128, 34, 25,243,229,249,101,128, 37,206, 99,143, 0, 99, 64,156,
+ 65,105, 65,116, 65,180, 65,211, 66, 48, 67,215, 68,199, 69, 43,
+ 69, 92, 72, 84, 72, 92, 72,102, 72,114, 72,147, 97, 9, 64,176,
+ 64,187, 64,197, 64,204, 64,211, 64,236, 64,246, 65, 42, 65, 51,
+ 225,242,237,229,238,233,225,110,128, 5,110,226,229,238,231,225,
+ 236,105,128, 9,154,227,245,244,101,128, 1, 7,228,229,246, 97,
+ 128, 9, 26,231,117, 2, 64,218, 64,227,234,225,242,225,244,105,
+ 128, 10,154,242,237,245,235,232,105,128, 10, 26,236,243,241,245,
+ 225,242,101,128, 51,136,238,228,242,225,226,233,238,228,117, 4,
+ 65, 8, 65, 18, 65, 24, 65, 31,226,229,238,231,225,236,105,128,
+ 9,129,227,237, 98,128, 3, 16,228,229,246, 97,128, 9, 1,231,
+ 245,234,225,242,225,244,105,128, 10,129,240,243,236,239,227,107,
+ 128, 33,234,114, 3, 65, 59, 65, 65, 65, 91,229,239,102,128, 33,
+ 5,239,110,130, 2,199, 65, 74, 65, 85,226,229,236,239,247,227,
+ 237, 98,128, 3, 44,227,237, 98,128, 3, 12,242,233,225,231,229,
+ 242,229,244,245,242,110,128, 33,181,226,239,240,239,237,239,230,
+ 111,128, 49, 24, 99, 4, 65,126, 65,133, 65,152, 65,174,225,242,
+ 239,110,128, 1, 13,229,228,233,236,236, 97,129, 0,231, 65,144,
+ 225,227,245,244,101,128, 30, 9,233,242, 99, 2, 65,160, 65,165,
+ 236,101,128, 36,210,245,237,230,236,229,120,128, 1, 9,245,242,
+ 108,128, 2, 85,100, 2, 65,186, 65,202,239,116,129, 1, 11, 65,
+ 193,225,227,227,229,238,116,128, 1, 11,243,241,245,225,242,101,
+ 128, 51,197,101, 2, 65,217, 65,233,228,233,236,236, 97,129, 0,
+ 184, 65,227,227,237, 98,128, 3, 39,238,116,132, 0,162, 65,246,
+ 66, 14, 66, 26, 66, 37,105, 2, 65,252, 66, 4,231,242,225,228,
+ 101,128, 33, 3,238,230,229,242,233,239,114,128,246,223,237,239,
+ 238,239,243,240,225,227,101,128,255,224,239,236,228,243,244,249,
+ 236,101,128,247,162,243,245,240,229,242,233,239,114,128,246,224,
+ 104, 5, 66, 60, 66,123, 66,134, 67, 62, 67,154, 97, 4, 66, 70,
+ 66, 81, 66, 91, 66, 98,225,242,237,229,238,233,225,110,128, 5,
+ 121,226,229,238,231,225,236,105,128, 9,155,228,229,246, 97,128,
+ 9, 27,231,117, 2, 66,105, 66,114,234,225,242,225,244,105,128,
+ 10,155,242,237,245,235,232,105,128, 10, 27,226,239,240,239,237,
+ 239,230,111,128, 49, 20,101, 6, 66,148, 66,168, 66,192, 67, 4,
+ 67, 16, 67, 37,225,226,235,232,225,243,233,225,238,227,249,242,
+ 233,236,236,233, 99,128, 4,189, 99, 2, 66,174, 66,182,235,237,
+ 225,242,107,128, 39, 19,249,242,233,236,236,233, 99,128, 4, 71,
+ 100, 2, 66,198, 66,242,229,243,227,229,238,228,229,114, 2, 66,
+ 211, 66,231,225,226,235,232,225,243,233,225,238,227,249,242,233,
+ 236,236,233, 99,128, 4,191,227,249,242,233,236,236,233, 99,128,
+ 4,183,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
+ 99,128, 4,245,232,225,242,237,229,238,233,225,110,128, 5,115,
+ 235,232,225,235,225,243,243,233,225,238,227,249,242,233,236,236,
+ 233, 99,128, 4,204,246,229,242,244,233,227,225,236,243,244,242,
+ 239,235,229,227,249,242,233,236,236,233, 99,128, 4,185,105,129,
+ 3,199, 67, 68,229,245,227,104, 4, 67, 81, 67,116, 67,131, 67,
+ 140, 97, 2, 67, 87, 67,102,227,233,242,227,236,229,235,239,242,
+ 229,225,110,128, 50,119,240,225,242,229,238,235,239,242,229,225,
+ 110,128, 50, 23,227,233,242,227,236,229,235,239,242,229,225,110,
+ 128, 50,105,235,239,242,229,225,110,128, 49, 74,240,225,242,229,
+ 238,235,239,242,229,225,110,128, 50, 9,111, 2, 67,160, 67,210,
+ 227,104, 3, 67,169, 67,191, 67,201,225,110, 2, 67,176, 67,184,
+ 231,244,232,225,105,128, 14, 10,244,232,225,105,128, 14, 8,233,
+ 238,231,244,232,225,105,128, 14, 9,239,229,244,232,225,105,128,
+ 14, 12,239,107,128, 1,136,105, 2, 67,221, 68, 67,229,245, 99,
+ 5, 67,235, 68, 14, 68, 29, 68, 38, 68, 52, 97, 2, 67,241, 68,
+ 0,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,118,
+ 240,225,242,229,238,235,239,242,229,225,110,128, 50, 22,227,233,
+ 242,227,236,229,235,239,242,229,225,110,128, 50,104,235,239,242,
+ 229,225,110,128, 49, 72,240,225,242,229,238,235,239,242,229,225,
+ 110,128, 50, 8,245,240,225,242,229,238,235,239,242,229,225,110,
+ 128, 50, 28,242, 99, 2, 68, 74, 68,169,236,101,132, 37,203, 68,
+ 87, 68, 98, 68,103, 68,127,237,245,236,244,233,240,236,121,128,
+ 34,151,239,116,128, 34,153,112, 2, 68,109, 68,115,236,245,115,
+ 128, 34,149,239,243,244,225,236,237,225,242,107,128, 48, 54,247,
+ 233,244,104, 2, 68,136, 68,152,236,229,230,244,232,225,236,230,
+ 226,236,225,227,107,128, 37,208,242,233,231,232,244,232,225,236,
+ 230,226,236,225,227,107,128, 37,209,245,237,230,236,229,120,130,
+ 2,198, 68,182, 68,193,226,229,236,239,247,227,237, 98,128, 3,
+ 45,227,237, 98,128, 3, 2,108, 3, 68,207, 68,213, 69, 11,229,
+ 225,114,128, 35, 39,233,227,107, 4, 68,225, 68,236, 68,245, 68,
+ 255,225,236,246,229,239,236,225,114,128, 1,194,228,229,238,244,
+ 225,108,128, 1,192,236,225,244,229,242,225,108,128, 1,193,242,
+ 229,244,242,239,230,236,229,120,128, 1,195,245, 98,129, 38, 99,
+ 69, 18,243,245,233,116, 2, 69, 27, 69, 35,226,236,225,227,107,
+ 128, 38, 99,247,232,233,244,101,128, 38,103,109, 3, 69, 51, 69,
+ 65, 69, 76,227,245,226,229,228,243,241,245,225,242,101,128, 51,
+ 164,239,238,239,243,240,225,227,101,128,255, 67,243,241,245,225,
+ 242,229,228,243,241,245,225,242,101,128, 51,160,111, 8, 69,110,
+ 69,121, 69,208, 70,150, 71,179, 71,210, 72, 61, 72, 70,225,242,
+ 237,229,238,233,225,110,128, 5,129,236,239,110,131, 0, 58, 69,
+ 133, 69,158, 69,177,237,239,110, 2, 69,141, 69,149,229,244,225,
+ 242,121,128, 32,161,239,243,240,225,227,101,128,255, 26,115, 2,
+ 69,164, 69,170,233,231,110,128, 32,161,237,225,236,108,128,254,
+ 85,244,242,233,225,238,231,245,236,225,114, 2, 69,192, 69,202,
+ 232,225,236,230,237,239,100,128, 2,209,237,239,100,128, 2,208,
+ 109, 2, 69,214, 70,143,237, 97,134, 0, 44, 69,231, 70, 39, 70,
+ 50, 70, 62, 70, 92, 70,115, 97, 3, 69,239, 70, 9, 70, 17,226,
+ 239,246,101, 2, 69,248, 69,254,227,237, 98,128, 3, 19,242,233,
+ 231,232,244,227,237, 98,128, 3, 21,227,227,229,238,116,128,246,
+ 195,114, 2, 70, 23, 70, 30,225,226,233, 99,128, 6, 12,237,229,
+ 238,233,225,110,128, 5, 93,233,238,230,229,242,233,239,114,128,
+ 246,225,237,239,238,239,243,240,225,227,101,128,255, 12,242,229,
+ 246,229,242,243,229,100, 2, 70, 75, 70, 86,225,226,239,246,229,
+ 227,237, 98,128, 3, 20,237,239,100,128, 2,189,115, 2, 70, 98,
+ 70,105,237,225,236,108,128,254, 80,245,240,229,242,233,239,114,
+ 128,246,226,244,245,242,238,229,100, 2, 70,126, 70,137,225,226,
+ 239,246,229,227,237, 98,128, 3, 18,237,239,100,128, 2,187,240,
+ 225,243,115,128, 38, 60,110, 2, 70,156, 70,165,231,242,245,229,
+ 238,116,128, 34, 69,116, 2, 70,171, 70,185,239,245,242,233,238,
+ 244,229,231,242,225,108,128, 34, 46,242,239,108,142, 35, 3, 70,
+ 219, 70,225, 70,240, 70,255, 71, 43, 71, 88, 71,102, 71,107, 71,
+ 112, 71,117, 71,123, 71,128, 71,169, 71,174,193,195, 75,128, 0,
+ 6, 66, 2, 70,231, 70,236,197, 76,128, 0, 7, 83,128, 0, 8,
+ 67, 2, 70,246, 70,251,193, 78,128, 0, 24, 82,128, 0, 13, 68,
+ 3, 71, 7, 71, 33, 71, 38, 67, 4, 71, 17, 71, 21, 71, 25, 71,
+ 29, 49,128, 0, 17, 50,128, 0, 18, 51,128, 0, 19, 52,128, 0,
+ 20,197, 76,128, 0,127,204, 69,128, 0, 16, 69, 5, 71, 55, 71,
+ 59, 71, 64, 71, 69, 71, 74, 77,128, 0, 25,206, 81,128, 0, 5,
+ 207, 84,128, 0, 4,211, 67,128, 0, 27, 84, 2, 71, 80, 71, 84,
+ 66,128, 0, 23, 88,128, 0, 3, 70, 2, 71, 94, 71, 98, 70,128,
+ 0, 12, 83,128, 0, 28,199, 83,128, 0, 29,200, 84,128, 0, 9,
+ 204, 70,128, 0, 10,206,193, 75,128, 0, 21,210, 83,128, 0, 30,
+ 83, 5, 71,140, 71,144, 71,154, 71,159, 71,164, 73,128, 0, 15,
+ 79,129, 0, 14, 71,150, 84,128, 0, 2,212, 88,128, 0, 1,213,
+ 66,128, 0, 26,217, 78,128, 0, 22,213, 83,128, 0, 31,214, 84,
+ 128, 0, 11,240,249,242,233,231,232,116,129, 0,169, 71,191,115,
+ 2, 71,197, 71,203,225,238,115,128,248,233,229,242,233,102,128,
+ 246,217,114, 2, 71,216, 72, 44,238,229,242,226,242,225,227,235,
+ 229,116, 2, 71,231, 72, 9,236,229,230,116,130, 48, 12, 71,242,
+ 71,254,232,225,236,230,247,233,228,244,104,128,255, 98,246,229,
+ 242,244,233,227,225,108,128,254, 65,242,233,231,232,116,130, 48,
+ 13, 72, 21, 72, 33,232,225,236,230,247,233,228,244,104,128,255,
+ 99,246,229,242,244,233,227,225,108,128,254, 66,240,239,242,225,
+ 244,233,239,238,243,241,245,225,242,101,128, 51,127,243,241,245,
+ 225,242,101,128, 51,199,246,229,242,235,231,243,241,245,225,242,
+ 101,128, 51,198,240,225,242,229,110,128, 36,158,242,245,250,229,
+ 233,242,111,128, 32,162,243,244,242,229,244,227,232,229,100,128,
+ 2,151,245,114, 2, 72,121, 72,139,236,121, 2, 72,128, 72,134,
+ 225,238,100,128, 34,207,239,114,128, 34,206,242,229,238,227,121,
+ 128, 0,164,249,114, 4, 72,158, 72,166, 72,173, 72,181,194,242,
+ 229,246,101,128,246,209,198,236,229,120,128,246,210,226,242,229,
+ 246,101,128,246,212,230,236,229,120,128,246,213,100,146, 0,100,
+ 72,228, 74,110, 75,134, 75,194, 76,114, 77, 68, 77,130, 78, 59,
+ 78, 72, 78, 81, 78,107, 78,132, 78,141, 79,208, 79,216, 79,227,
+ 79,247, 80, 19, 97, 11, 72,252, 73, 7, 73, 17, 73, 89, 73,152,
+ 73,163, 73,174, 73,243, 74, 49, 74, 55, 74, 85,225,242,237,229,
+ 238,233,225,110,128, 5,100,226,229,238,231,225,236,105,128, 9,
+ 166,100, 5, 73, 29, 73, 38, 73, 44, 73, 58, 73, 74,225,242,225,
+ 226,233, 99,128, 6, 54,229,246, 97,128, 9, 38,230,233,238,225,
+ 236,225,242,225,226,233, 99,128,254,190,233,238,233,244,233,225,
+ 236,225,242,225,226,233, 99,128,254,191,237,229,228,233,225,236,
+ 225,242,225,226,233, 99,128,254,192,103, 3, 73, 97, 73,114, 73,
+ 128,229,243,104,129, 5,188, 73,105,232,229,226,242,229,119,128,
+ 5,188,231,229,114,129, 32, 32, 73,122,228,226,108,128, 32, 33,
+ 117, 2, 73,134, 73,143,234,225,242,225,244,105,128, 10,166,242,
+ 237,245,235,232,105,128, 10, 38,232,233,242,225,231,225,238, 97,
+ 128, 48, 96,235,225,244,225,235,225,238, 97,128, 48,192,108, 3,
+ 73,182, 73,191, 73,229,225,242,225,226,233, 99,128, 6, 47,229,
+ 116,130, 5,211, 73,200, 73,220,228,225,231,229,243,104,129,251,
+ 51, 73,211,232,229,226,242,229,119,128,251, 51,232,229,226,242,
+ 229,119,128, 5,211,230,233,238,225,236,225,242,225,226,233, 99,
+ 128,254,170,237,237, 97, 3, 73,253, 74, 6, 74, 18,225,242,225,
+ 226,233, 99,128, 6, 79,236,239,247,225,242,225,226,233, 99,128,
+ 6, 79,244,225,238, 97, 2, 74, 27, 74, 41,236,244,239,238,229,
+ 225,242,225,226,233, 99,128, 6, 76,242,225,226,233, 99,128, 6,
+ 76,238,228, 97,128, 9,100,242,231, 97, 2, 74, 63, 74, 72,232,
+ 229,226,242,229,119,128, 5,167,236,229,230,244,232,229,226,242,
+ 229,119,128, 5,167,243,233,225,240,238,229,245,237,225,244,225,
+ 227,249,242,233,236,236,233,227,227,237, 98,128, 4,133, 98, 3,
+ 74,118, 75,115, 75,125,108, 9, 74,138, 74,146, 75, 3, 75, 11,
+ 75, 27, 75, 38, 75, 56, 75, 70, 75, 81,199,242,225,246,101,128,
+ 246,211, 97, 2, 74,152, 74,209,238,231,236,229,226,242,225,227,
+ 235,229,116, 2, 74,168, 74,188,236,229,230,116,129, 48, 10, 74,
+ 177,246,229,242,244,233,227,225,108,128,254, 61,242,233,231,232,
+ 116,129, 48, 11, 74,198,246,229,242,244,233,227,225,108,128,254,
+ 62,114, 2, 74,215, 74,236,227,232,233,238,246,229,242,244,229,
+ 228,226,229,236,239,247,227,237, 98,128, 3, 43,242,239,119, 2,
+ 74,244, 74,251,236,229,230,116,128, 33,212,242,233,231,232,116,
+ 128, 33,210,228,225,238,228, 97,128, 9,101,231,242,225,246,101,
+ 129,246,214, 75, 21,227,237, 98,128, 3, 15,233,238,244,229,231,
+ 242,225,108,128, 34, 44,236,239,247,236,233,238,101,129, 32, 23,
+ 75, 50,227,237, 98,128, 3, 51,239,246,229,242,236,233,238,229,
+ 227,237, 98,128, 3, 63,240,242,233,237,229,237,239,100,128, 2,
+ 186,246,229,242,244,233,227,225,108, 2, 75, 94, 75,100,226,225,
+ 114,128, 32, 22,236,233,238,229,225,226,239,246,229,227,237, 98,
+ 128, 3, 14,239,240,239,237,239,230,111,128, 49, 9,243,241,245,
+ 225,242,101,128, 51,200, 99, 4, 75,144, 75,151, 75,160, 75,187,
+ 225,242,239,110,128, 1, 15,229,228,233,236,236, 97,128, 30, 17,
+ 233,242, 99, 2, 75,168, 75,173,236,101,128, 36,211,245,237,230,
+ 236,229,248,226,229,236,239,119,128, 30, 19,242,239,225,116,128,
+ 1, 17,100, 4, 75,204, 76, 29, 76, 39, 76, 90, 97, 4, 75,214,
+ 75,224, 75,231, 76, 0,226,229,238,231,225,236,105,128, 9,161,
+ 228,229,246, 97,128, 9, 33,231,117, 2, 75,238, 75,247,234,225,
+ 242,225,244,105,128, 10,161,242,237,245,235,232,105,128, 10, 33,
+ 108, 2, 76, 6, 76, 15,225,242,225,226,233, 99,128, 6,136,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,251,137,228,232,225,
+ 228,229,246, 97,128, 9, 92,232, 97, 3, 76, 48, 76, 58, 76, 65,
+ 226,229,238,231,225,236,105,128, 9,162,228,229,246, 97,128, 9,
+ 34,231,117, 2, 76, 72, 76, 81,234,225,242,225,244,105,128, 10,
+ 162,242,237,245,235,232,105,128, 10, 34,239,116, 2, 76, 97, 76,
+ 106,225,227,227,229,238,116,128, 30, 11,226,229,236,239,119,128,
+ 30, 13,101, 8, 76,132, 76,185, 76,192, 76,217, 76,227, 76,238,
+ 77, 27, 77, 63, 99, 2, 76,138, 76,175,233,237,225,236,243,229,
+ 240,225,242,225,244,239,114, 2, 76,156, 76,165,225,242,225,226,
+ 233, 99,128, 6,107,240,229,242,243,233,225,110,128, 6,107,249,
+ 242,233,236,236,233, 99,128, 4, 52,231,242,229,101,128, 0,176,
+ 232,105, 2, 76,199, 76,208,232,229,226,242,229,119,128, 5,173,
+ 242,225,231,225,238, 97,128, 48,103,233,227,239,240,244,233, 99,
+ 128, 3,239,235,225,244,225,235,225,238, 97,128, 48,199,108, 2,
+ 76,244, 77, 11,229,244,101, 2, 76,252, 77, 3,236,229,230,116,
+ 128, 35, 43,242,233,231,232,116,128, 35, 38,244, 97,129, 3,180,
+ 77, 18,244,245,242,238,229,100,128, 1,141,238,239,237,233,238,
+ 225,244,239,242,237,233,238,245,243,239,238,229,238,245,237,229,
+ 242,225,244,239,242,226,229,238,231,225,236,105,128, 9,248,250,
+ 104,128, 2,164,104, 2, 77, 74, 77,124, 97, 3, 77, 82, 77, 92,
+ 77, 99,226,229,238,231,225,236,105,128, 9,167,228,229,246, 97,
+ 128, 9, 39,231,117, 2, 77,106, 77,115,234,225,242,225,244,105,
+ 128, 10,167,242,237,245,235,232,105,128, 10, 39,239,239,107,128,
+ 2, 87,105, 6, 77,144, 77,193, 77,253, 78, 8, 78, 19, 78, 29,
+ 97, 2, 77,150, 77,172,236,249,244,233,235,225,244,239,238,239,
+ 115,129, 3,133, 77,166,227,237, 98,128, 3, 68,237,239,238,100,
+ 129, 38,102, 77,181,243,245,233,244,247,232,233,244,101,128, 38,
+ 98,229,242,229,243,233,115,133, 0,168, 77,212, 77,220, 77,231,
+ 77,237, 77,245,225,227,245,244,101,128,246,215,226,229,236,239,
+ 247,227,237, 98,128, 3, 36,227,237, 98,128, 3, 8,231,242,225,
+ 246,101,128,246,216,244,239,238,239,115,128, 3,133,232,233,242,
+ 225,231,225,238, 97,128, 48, 98,235,225,244,225,235,225,238, 97,
+ 128, 48,194,244,244,239,237,225,242,107,128, 48, 3,246,105, 2,
+ 78, 36, 78, 47,228,101,129, 0,247, 78, 43,115,128, 34, 35,243,
+ 233,239,238,243,236,225,243,104,128, 34, 21,234,229,227,249,242,
+ 233,236,236,233, 99,128, 4, 82,235,243,232,225,228,101,128, 37,
+ 147,108, 2, 78, 87, 78, 98,233,238,229,226,229,236,239,119,128,
+ 30, 15,243,241,245,225,242,101,128, 51,151,109, 2, 78,113, 78,
+ 121,225,227,242,239,110,128, 1, 17,239,238,239,243,240,225,227,
+ 101,128,255, 68,238,226,236,239,227,107,128, 37,132,111, 10, 78,
+ 163, 78,175, 78,185, 78,196, 78,207, 79, 23, 79, 28, 79, 39, 79,
+ 154, 79,180,227,232,225,228,225,244,232,225,105,128, 14, 14,228,
+ 229,235,244,232,225,105,128, 14, 20,232,233,242,225,231,225,238,
+ 97,128, 48,105,235,225,244,225,235,225,238, 97,128, 48,201,236,
+ 236,225,114,132, 0, 36, 78,222, 78,233, 78,245, 79, 0,233,238,
+ 230,229,242,233,239,114,128,246,227,237,239,238,239,243,240,225,
+ 227,101,128,255, 4,239,236,228,243,244,249,236,101,128,247, 36,
+ 115, 2, 79, 6, 79, 13,237,225,236,108,128,254,105,245,240,229,
+ 242,233,239,114,128,246,228,238,103,128, 32,171,242,245,243,241,
+ 245,225,242,101,128, 51, 38,116, 6, 79, 53, 79, 70, 79, 92, 79,
+ 103, 79,135, 79,142,225,227,227,229,238,116,129, 2,217, 79, 64,
+ 227,237, 98,128, 3, 7,226,229,236,239,247, 99, 2, 79, 81, 79,
+ 86,237, 98,128, 3, 35,239,237, 98,128, 3, 35,235,225,244,225,
+ 235,225,238, 97,128, 48,251,236,229,243,115, 2, 79,112, 79,116,
+ 105,128, 1, 49,106,129,246,190, 79,122,243,244,242,239,235,229,
+ 232,239,239,107,128, 2,132,237,225,244,104,128, 34,197,244,229,
+ 228,227,233,242,227,236,101,128, 37,204,245,226,236,229,249,239,
+ 228,240,225,244,225,104,129,251, 31, 79,171,232,229,226,242,229,
+ 119,128,251, 31,247,238,244,225,227,107, 2, 79,191, 79,202,226,
+ 229,236,239,247,227,237, 98,128, 3, 30,237,239,100,128, 2,213,
+ 240,225,242,229,110,128, 36,159,243,245,240,229,242,233,239,114,
+ 128,246,235,116, 2, 79,233, 79,239,225,233,108,128, 2, 86,239,
+ 240,226,225,114,128, 1,140,117, 2, 79,253, 80, 8,232,233,242,
+ 225,231,225,238, 97,128, 48,101,235,225,244,225,235,225,238, 97,
+ 128, 48,197,122,132, 1,243, 80, 31, 80, 40, 80, 59, 80, 96,225,
+ 236,244,239,238,101,128, 2,163, 99, 2, 80, 46, 80, 53,225,242,
+ 239,110,128, 1,198,245,242,108,128, 2,165,101, 2, 80, 65, 80,
+ 85,225,226,235,232,225,243,233,225,238,227,249,242,233,236,236,
+ 233, 99,128, 4,225,227,249,242,233,236,236,233, 99,128, 4, 85,
+ 232,229,227,249,242,233,236,236,233, 99,128, 4, 95,101,151, 0,
+ 101, 80,159, 80,178, 80,212, 81,186, 81,248, 82, 25, 82, 37, 82,
+ 60, 82,113, 83,225, 84, 27, 84,129, 84,245, 85,124, 85,199, 85,
+ 230, 86, 36, 86, 89, 87, 24, 87,157, 87,177, 87,221, 88, 56, 97,
+ 2, 80,165, 80,172,227,245,244,101,128, 0,233,242,244,104,128,
+ 38, 65, 98, 3, 80,186, 80,195, 80,205,229,238,231,225,236,105,
+ 128, 9,143,239,240,239,237,239,230,111,128, 49, 28,242,229,246,
+ 101,128, 1, 21, 99, 5, 80,224, 81, 41, 81, 55, 81, 87, 81,176,
+ 97, 2, 80,230, 81, 35,238,228,242, 97, 3, 80,241, 80,248, 81,
+ 3,228,229,246, 97,128, 9, 13,231,245,234,225,242,225,244,105,
+ 128, 10,141,246,239,247,229,236,243,233,231,110, 2, 81, 17, 81,
+ 24,228,229,246, 97,128, 9, 69,231,245,234,225,242,225,244,105,
+ 128, 10,197,242,239,110,128, 1, 27,229,228,233,236,236,225,226,
+ 242,229,246,101,128, 30, 29,104, 2, 81, 61, 81, 72,225,242,237,
+ 229,238,233,225,110,128, 5,101,249,233,247,238,225,242,237,229,
+ 238,233,225,110,128, 5,135,233,242, 99, 2, 81, 95, 81,100,236,
+ 101,128, 36,212,245,237,230,236,229,120,134, 0,234, 81,121, 81,
+ 129, 81,137, 81,148, 81,156, 81,168,225,227,245,244,101,128, 30,
+ 191,226,229,236,239,119,128, 30, 25,228,239,244,226,229,236,239,
+ 119,128, 30,199,231,242,225,246,101,128, 30,193,232,239,239,235,
+ 225,226,239,246,101,128, 30,195,244,233,236,228,101,128, 30,197,
+ 249,242,233,236,236,233, 99,128, 4, 84,100, 4, 81,196, 81,206,
+ 81,212, 81,222,226,236,231,242,225,246,101,128, 2, 5,229,246,
+ 97,128, 9, 15,233,229,242,229,243,233,115,128, 0,235,239,116,
+ 130, 1, 23, 81,231, 81,240,225,227,227,229,238,116,128, 1, 23,
+ 226,229,236,239,119,128, 30,185,101, 2, 81,254, 82, 9,231,245,
+ 242,237,245,235,232,105,128, 10, 15,237,225,244,242,225,231,245,
+ 242,237,245,235,232,105,128, 10, 71,230,227,249,242,233,236,236,
+ 233, 99,128, 4, 68,103, 2, 82, 43, 82, 50,242,225,246,101,128,
+ 0,232,245,234,225,242,225,244,105,128, 10,143,104, 4, 82, 70,
+ 82, 81, 82, 92, 82,102,225,242,237,229,238,233,225,110,128, 5,
+ 103,226,239,240,239,237,239,230,111,128, 49, 29,233,242,225,231,
+ 225,238, 97,128, 48, 72,239,239,235,225,226,239,246,101,128, 30,
+ 187,105, 4, 82,123, 82,134, 83,192, 83,207,226,239,240,239,237,
+ 239,230,111,128, 49, 31,231,232,116,142, 0, 56, 82,168, 82,177,
+ 82,187, 82,217, 82,224, 83, 6, 83, 31, 83, 76, 83,110, 83,122,
+ 83,133, 83,166, 83,174, 83,185,225,242,225,226,233, 99,128, 6,
+ 104,226,229,238,231,225,236,105,128, 9,238,227,233,242,227,236,
+ 101,129, 36,103, 82,198,233,238,246,229,242,243,229,243,225,238,
+ 243,243,229,242,233,102,128, 39,145,228,229,246, 97,128, 9,110,
+ 229,229,110, 2, 82,232, 82,241,227,233,242,227,236,101,128, 36,
+ 113,112, 2, 82,247, 82,254,225,242,229,110,128, 36,133,229,242,
+ 233,239,100,128, 36,153,231,117, 2, 83, 13, 83, 22,234,225,242,
+ 225,244,105,128, 10,238,242,237,245,235,232,105,128, 10,110,104,
+ 2, 83, 37, 83, 63, 97, 2, 83, 43, 83, 54,227,235,225,242,225,
+ 226,233, 99,128, 6,104,238,231,250,232,239,117,128, 48, 40,238,
+ 239,244,229,226,229,225,237,229,100,128, 38,107,105, 2, 83, 82,
+ 83,100,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
+ 110,128, 50, 39,238,230,229,242,233,239,114,128, 32,136,237,239,
+ 238,239,243,240,225,227,101,128,255, 24,239,236,228,243,244,249,
+ 236,101,128,247, 56,112, 2, 83,139, 83,146,225,242,229,110,128,
+ 36,123,229,114, 2, 83,153, 83,159,233,239,100,128, 36,143,243,
+ 233,225,110,128, 6,248,242,239,237,225,110,128, 33,119,243,245,
+ 240,229,242,233,239,114,128, 32,120,244,232,225,105,128, 14, 88,
+ 238,246,229,242,244,229,228,226,242,229,246,101,128, 2, 7,239,
+ 244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128, 4,
+ 101,107, 2, 83,231, 83,255,225,244,225,235,225,238, 97,129, 48,
+ 168, 83,243,232,225,236,230,247,233,228,244,104,128,255,116,111,
+ 2, 84, 5, 84, 20,238,235,225,242,231,245,242,237,245,235,232,
+ 105,128, 10,116,242,229,225,110,128, 49, 84,108, 3, 84, 35, 84,
+ 46, 84,107,227,249,242,233,236,236,233, 99,128, 4, 59,101, 2,
+ 84, 52, 84, 59,237,229,238,116,128, 34, 8,246,229,110, 3, 84,
+ 69, 84, 78, 84, 99,227,233,242,227,236,101,128, 36,106,112, 2,
+ 84, 84, 84, 91,225,242,229,110,128, 36,126,229,242,233,239,100,
+ 128, 36,146,242,239,237,225,110,128, 33,122,236,233,240,243,233,
+ 115,129, 32, 38, 84,118,246,229,242,244,233,227,225,108,128, 34,
+ 238,109, 5, 84,141, 84,169, 84,180, 84,200, 84,211,225,227,242,
+ 239,110,130, 1, 19, 84,153, 84,161,225,227,245,244,101,128, 30,
+ 23,231,242,225,246,101,128, 30, 21,227,249,242,233,236,236,233,
+ 99,128, 4, 60,228,225,243,104,129, 32, 20, 84,189,246,229,242,
+ 244,233,227,225,108,128,254, 49,239,238,239,243,240,225,227,101,
+ 128,255, 69,112, 2, 84,217, 84,237,232,225,243,233,243,237,225,
+ 242,235,225,242,237,229,238,233,225,110,128, 5, 91,244,249,243,
+ 229,116,128, 34, 5,110, 6, 85, 3, 85, 14, 85, 25, 85, 69, 85,
+ 101, 85,116,226,239,240,239,237,239,230,111,128, 49, 35,227,249,
+ 242,233,236,236,233, 99,128, 4, 61,100, 2, 85, 31, 85, 50,225,
+ 243,104,129, 32, 19, 85, 39,246,229,242,244,233,227,225,108,128,
+ 254, 50,229,243,227,229,238,228,229,242,227,249,242,233,236,236,
+ 233, 99,128, 4,163,103,130, 1, 75, 85, 77, 85, 88,226,239,240,
+ 239,237,239,230,111,128, 49, 37,232,229,227,249,242,233,236,236,
+ 233, 99,128, 4,165,232,239,239,235,227,249,242,233,236,236,233,
+ 99,128, 4,200,243,240,225,227,101,128, 32, 2,111, 3, 85,132,
+ 85,140, 85,149,231,239,238,229,107,128, 1, 25,235,239,242,229,
+ 225,110,128, 49, 83,240,229,110,130, 2, 91, 85,159, 85,168,227,
+ 236,239,243,229,100,128, 2,154,242,229,246,229,242,243,229,100,
+ 130, 2, 92, 85,183, 85,192,227,236,239,243,229,100,128, 2, 94,
+ 232,239,239,107,128, 2, 93,112, 2, 85,205, 85,212,225,242,229,
+ 110,128, 36,160,243,233,236,239,110,129, 3,181, 85,222,244,239,
+ 238,239,115,128, 3,173,241,117, 2, 85,237, 86, 25,225,108,130,
+ 0, 61, 85,246, 86, 2,237,239,238,239,243,240,225,227,101,128,
+ 255, 29,115, 2, 86, 8, 86, 15,237,225,236,108,128,254,102,245,
+ 240,229,242,233,239,114,128, 32,124,233,246,225,236,229,238,227,
+ 101,128, 34, 97,114, 3, 86, 44, 86, 55, 86, 66,226,239,240,239,
+ 237,239,230,111,128, 49, 38,227,249,242,233,236,236,233, 99,128,
+ 4, 64,229,246,229,242,243,229,100,129, 2, 88, 86, 78,227,249,
+ 242,233,236,236,233, 99,128, 4, 77,115, 6, 86,103, 86,114, 86,
+ 134, 86,215, 87, 4, 87, 14,227,249,242,233,236,236,233, 99,128,
+ 4, 65,228,229,243,227,229,238,228,229,242,227,249,242,233,236,
+ 236,233, 99,128, 4,171,104,132, 2,131, 86,146, 86,153, 86,184,
+ 86,199,227,245,242,108,128, 2,134,239,242,116, 2, 86,161, 86,
+ 168,228,229,246, 97,128, 9, 14,246,239,247,229,236,243,233,231,
+ 238,228,229,246, 97,128, 9, 70,242,229,246,229,242,243,229,228,
+ 236,239,239,112,128, 1,170,243,241,245,225,244,242,229,246,229,
+ 242,243,229,100,128, 2,133,237,225,236,108, 2, 86,224, 86,235,
+ 232,233,242,225,231,225,238, 97,128, 48, 71,235,225,244,225,235,
+ 225,238, 97,129, 48,167, 86,248,232,225,236,230,247,233,228,244,
+ 104,128,255,106,244,233,237,225,244,229,100,128, 33, 46,245,240,
+ 229,242,233,239,114,128,246,236,116, 5, 87, 36, 87, 62, 87, 66,
+ 87, 83, 87,149, 97,130, 3,183, 87, 44, 87, 54,242,237,229,238,
+ 233,225,110,128, 5,104,244,239,238,239,115,128, 3,174,104,128,
+ 0,240,233,236,228,101,129, 30,189, 87, 75,226,229,236,239,119,
+ 128, 30, 27,238,225,232,244, 97, 3, 87, 95, 87,127, 87,136,230,
+ 239,245,235,104, 2, 87,105, 87,114,232,229,226,242,229,119,128,
+ 5,145,236,229,230,244,232,229,226,242,229,119,128, 5,145,232,
+ 229,226,242,229,119,128, 5,145,236,229,230,244,232,229,226,242,
+ 229,119,128, 5,145,245,242,238,229,100,128, 1,221,117, 2, 87,
+ 163, 87,172,235,239,242,229,225,110,128, 49, 97,242,111,128, 32,
+ 172,246,239,247,229,236,243,233,231,110, 3, 87,193, 87,203, 87,
+ 210,226,229,238,231,225,236,105,128, 9,199,228,229,246, 97,128,
+ 9, 71,231,245,234,225,242,225,244,105,128, 10,199,120, 2, 87,
+ 227, 88, 44,227,236,225,109,132, 0, 33, 87,242, 87,253, 88, 24,
+ 88, 36,225,242,237,229,238,233,225,110,128, 5, 92,100, 2, 88,
+ 3, 88, 8,226,108,128, 32, 60,239,247,110,129, 0,161, 88, 16,
+ 243,237,225,236,108,128,247,161,237,239,238,239,243,240,225,227,
+ 101,128,255, 1,243,237,225,236,108,128,247, 33,233,243,244,229,
+ 238,244,233,225,108,128, 34, 3,250,104,131, 2,146, 88, 67, 88,
+ 86, 88, 97, 99, 2, 88, 73, 88, 80,225,242,239,110,128, 1,239,
+ 245,242,108,128, 2,147,242,229,246,229,242,243,229,100,128, 1,
+ 185,244,225,233,108,128, 1,186,102,140, 0,102, 88,132, 88,214,
+ 88,225, 88,234, 88,246, 89, 93, 89,109, 91,117, 91,130, 91,156,
+ 93, 33, 93, 41, 97, 4, 88,142, 88,149, 88,160, 88,171,228,229,
+ 246, 97,128, 9, 94,231,245,242,237,245,235,232,105,128, 10, 94,
+ 232,242,229,238,232,229,233,116,128, 33, 9,244,232, 97, 3, 88,
+ 181, 88,190, 88,202,225,242,225,226,233, 99,128, 6, 78,236,239,
+ 247,225,242,225,226,233, 99,128, 6, 78,244,225,238,225,242,225,
+ 226,233, 99,128, 6, 75,226,239,240,239,237,239,230,111,128, 49,
+ 8,227,233,242,227,236,101,128, 36,213,228,239,244,225,227,227,
+ 229,238,116,128, 30, 31,101, 3, 88,254, 89, 76, 89, 86,104, 4,
+ 89, 8, 89, 31, 89, 45, 89, 61,225,114, 2, 89, 15, 89, 22,225,
+ 226,233, 99,128, 6, 65,237,229,238,233,225,110,128, 5,134,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,254,210,233,238,233,
+ 244,233,225,236,225,242,225,226,233, 99,128,254,211,237,229,228,
+ 233,225,236,225,242,225,226,233, 99,128,254,212,233,227,239,240,
+ 244,233, 99,128, 3,229,237,225,236,101,128, 38, 64,102,130,251,
+ 0, 89,101, 89,105,105,128,251, 3,108,128,251, 4,105,136,251,
+ 1, 89,129, 89,169, 89,180, 89,202, 90, 68, 90, 85, 90, 93, 90,
+ 106,230,244,229,229,110, 2, 89,139, 89,148,227,233,242,227,236,
+ 101,128, 36,110,112, 2, 89,154, 89,161,225,242,229,110,128, 36,
+ 130,229,242,233,239,100,128, 36,150,231,245,242,229,228,225,243,
+ 104,128, 32, 18,236,236,229,100, 2, 89,189, 89,195,226,239,120,
+ 128, 37,160,242,229,227,116,128, 37,172,238,225,108, 5, 89,216,
+ 89,255, 90, 16, 90, 33, 90, 49,235,225,102,130, 5,218, 89,226,
+ 89,246,228,225,231,229,243,104,129,251, 58, 89,237,232,229,226,
+ 242,229,119,128,251, 58,232,229,226,242,229,119,128, 5,218,237,
+ 229,109,129, 5,221, 90, 7,232,229,226,242,229,119,128, 5,221,
+ 238,245,110,129, 5,223, 90, 24,232,229,226,242,229,119,128, 5,
+ 223,240,101,129, 5,227, 90, 40,232,229,226,242,229,119,128, 5,
+ 227,244,243,225,228,105,129, 5,229, 90, 59,232,229,226,242,229,
+ 119,128, 5,229,242,243,244,244,239,238,229,227,232,233,238,229,
+ 243,101,128, 2,201,243,232,229,249,101,128, 37,201,244,225,227,
+ 249,242,233,236,236,233, 99,128, 4,115,246,101,142, 0, 53, 90,
+ 139, 90,148, 90,158, 90,188, 90,195, 90,205, 90,230, 91, 1, 91,
+ 35, 91, 47, 91, 58, 91, 91, 91, 99, 91,110,225,242,225,226,233,
+ 99,128, 6,101,226,229,238,231,225,236,105,128, 9,235,227,233,
+ 242,227,236,101,129, 36,100, 90,169,233,238,246,229,242,243,229,
+ 243,225,238,243,243,229,242,233,102,128, 39,142,228,229,246, 97,
+ 128, 9,107,229,233,231,232,244,232,115,128, 33, 93,231,117, 2,
+ 90,212, 90,221,234,225,242,225,244,105,128, 10,235,242,237,245,
+ 235,232,105,128, 10,107,232, 97, 2, 90,237, 90,248,227,235,225,
+ 242,225,226,233, 99,128, 6,101,238,231,250,232,239,117,128, 48,
+ 37,105, 2, 91, 7, 91, 25,228,229,239,231,242,225,240,232,233,
+ 227,240,225,242,229,110,128, 50, 36,238,230,229,242,233,239,114,
+ 128, 32,133,237,239,238,239,243,240,225,227,101,128,255, 21,239,
+ 236,228,243,244,249,236,101,128,247, 53,112, 2, 91, 64, 91, 71,
+ 225,242,229,110,128, 36,120,229,114, 2, 91, 78, 91, 84,233,239,
+ 100,128, 36,140,243,233,225,110,128, 6,245,242,239,237,225,110,
+ 128, 33,116,243,245,240,229,242,233,239,114,128, 32,117,244,232,
+ 225,105,128, 14, 85,108,129,251, 2, 91,123,239,242,233,110,128,
+ 1,146,109, 2, 91,136, 91,147,239,238,239,243,240,225,227,101,
+ 128,255, 70,243,241,245,225,242,101,128, 51,153,111, 4, 91,166,
+ 91,188, 91,200, 91,207,230, 97, 2, 91,173, 91,181,238,244,232,
+ 225,105,128, 14, 31,244,232,225,105,128, 14, 29,238,231,237,225,
+ 238,244,232,225,105,128, 14, 79,242,225,236,108,128, 34, 0,245,
+ 114,142, 0, 52, 91,240, 91,249, 92, 3, 92, 33, 92, 40, 92, 65,
+ 92, 92, 92,126, 92,138, 92,157, 92,168, 92,201, 92,209, 92,220,
+ 225,242,225,226,233, 99,128, 6,100,226,229,238,231,225,236,105,
+ 128, 9,234,227,233,242,227,236,101,129, 36, 99, 92, 14,233,238,
246,229,242,243,229,243,225,238,243,243,229,242,233,102,128, 39,
- 146,228,229,246, 97,128, 9,111,231,117, 2,134, 31,134, 40,234,
- 225,242,225,244,105,128, 10,239,242,237,245,235,232,105,128, 10,
- 111,232, 97, 2,134, 56,134, 67,227,235,225,242,225,226,233, 99,
- 128, 6,105,238,231,250,232,239,117,128, 48, 41,105, 2,134, 82,
- 134,100,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
- 110,128, 50, 40,238,230,229,242,233,239,114,128, 32,137,237,239,
- 238,239,243,240,225,227,101,128,255, 25,239,236,228,243,244,249,
- 236,101,128,247, 57,112, 2,134,139,134,146,225,242,229,110,128,
- 36,124,229,114, 2,134,153,134,159,233,239,100,128, 36,144,243,
- 233,225,110,128, 6,249,242,239,237,225,110,128, 33,120,243,245,
- 240,229,242,233,239,114,128, 32,121,116, 2,134,191,134,229,229,
- 229,110, 2,134,199,134,208,227,233,242,227,236,101,128, 36,114,
- 112, 2,134,214,134,221,225,242,229,110,128, 36,134,229,242,233,
- 239,100,128, 36,154,232,225,105,128, 14, 89,106,129, 1,204,134,
- 241,229,227,249,242,233,236,236,233, 99,128, 4, 90,235,225,244,
- 225,235,225,238, 97,129, 48,243,135, 10,232,225,236,230,247,233,
- 228,244,104,128,255,157,108, 2,135, 28,135, 42,229,231,242,233,
- 231,232,244,236,239,238,103,128, 1,158,233,238,229,226,229,236,
- 239,119,128, 30, 73,109, 2,135, 59,135, 70,239,238,239,243,240,
- 225,227,101,128,255, 78,243,241,245,225,242,101,128, 51,154,110,
- 2,135, 85,135,135, 97, 3,135, 93,135,103,135,110,226,229,238,
- 231,225,236,105,128, 9,163,228,229,246, 97,128, 9, 35,231,117,
- 2,135,117,135,126,234,225,242,225,244,105,128, 10,163,242,237,
- 245,235,232,105,128, 10, 35,238,225,228,229,246, 97,128, 9, 41,
- 111, 6,135,158,135,169,135,194,135,235,136,187,137,114,232,233,
- 242,225,231,225,238, 97,128, 48,110,235,225,244,225,235,225,238,
- 97,129, 48,206,135,182,232,225,236,230,247,233,228,244,104,128,
- 255,137,110, 3,135,202,135,218,135,227,226,242,229,225,235,233,
- 238,231,243,240,225,227,101,128, 0,160,229,238,244,232,225,105,
- 128, 14, 19,245,244,232,225,105,128, 14, 25,239,110, 7,135,252,
- 136, 5,136, 19,136, 53,136, 69,136,110,136,169,225,242,225,226,
- 233, 99,128, 6, 70,230,233,238,225,236,225,242,225,226,233, 99,
- 128,254,230,231,232,245,238,238, 97, 2,136, 30,136, 39,225,242,
- 225,226,233, 99,128, 6,186,230,233,238,225,236,225,242,225,226,
- 233, 99,128,251,159,233,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,254,231,234,229,229,237,105, 2,136, 79,136, 94,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,252,210,243,239,
- 236,225,244,229,228,225,242,225,226,233, 99,128,252, 75,237,101,
- 2,136,117,136,130,228,233,225,236,225,242,225,226,233, 99,128,
- 254,232,229,237,105, 2,136,138,136,153,238,233,244,233,225,236,
- 225,242,225,226,233, 99,128,252,213,243,239,236,225,244,229,228,
- 225,242,225,226,233, 99,128,252, 78,238,239,239,238,230,233,238,
- 225,236,225,242,225,226,233, 99,128,252,141,116, 7,136,203,136,
- 214,136,243,137, 22,137, 34,137, 54,137, 80,227,239,238,244,225,
- 233,238,115,128, 34, 12,101, 2,136,220,136,236,236,229,237,229,
- 238,116,129, 34, 9,136,231,239,102,128, 34, 9,241,245,225,108,
- 128, 34, 96,231,242,229,225,244,229,114,129, 34,111,136,255,238,
- 239,114, 2,137, 7,137, 15,229,241,245,225,108,128, 34,113,236,
- 229,243,115,128, 34,121,233,228,229,238,244,233,227,225,108,128,
- 34, 98,236,229,243,115,129, 34,110,137, 43,238,239,242,229,241,
- 245,225,108,128, 34,112,112, 2,137, 60,137, 70,225,242,225,236,
- 236,229,108,128, 34, 38,242,229,227,229,228,229,115,128, 34,128,
- 243,117, 3,137, 89,137, 96,137,105,226,243,229,116,128, 34,132,
- 227,227,229,229,228,115,128, 34,129,240,229,242,243,229,116,128,
- 34,133,247,225,242,237,229,238,233,225,110,128, 5,118,240,225,
- 242,229,110,128, 36,169,115, 2,137,140,137,149,243,241,245,225,
- 242,101,128, 51,177,245,240,229,242,233,239,114,128, 32,127,244,
- 233,236,228,101,128, 0,241,117,132, 3,189,137,179,137,190,138,
- 15,138, 98,232,233,242,225,231,225,238, 97,128, 48,108,107, 2,
- 137,196,137,220,225,244,225,235,225,238, 97,129, 48,204,137,208,
- 232,225,236,230,247,233,228,244,104,128,255,135,244, 97, 3,137,
- 229,137,239,137,246,226,229,238,231,225,236,105,128, 9,188,228,
- 229,246, 97,128, 9, 60,231,117, 2,137,253,138, 6,234,225,242,
- 225,244,105,128, 10,188,242,237,245,235,232,105,128, 10, 60,109,
- 2,138, 21,138, 55,226,229,242,243,233,231,110,130, 0, 35,138,
- 35,138, 47,237,239,238,239,243,240,225,227,101,128,255, 3,243,
- 237,225,236,108,128,254, 95,229,114, 2,138, 62,138, 94,225,236,
- 243,233,231,110, 2,138, 73,138, 81,231,242,229,229,107,128, 3,
- 116,236,239,247,229,242,231,242,229,229,107,128, 3,117,111,128,
- 33, 22,110,130, 5,224,138,106,138,126,228,225,231,229,243,104,
- 129,251, 64,138,117,232,229,226,242,229,119,128,251, 64,232,229,
- 226,242,229,119,128, 5,224,246,243,241,245,225,242,101,128, 51,
- 181,247,243,241,245,225,242,101,128, 51,187,249, 97, 3,138,164,
- 138,174,138,181,226,229,238,231,225,236,105,128, 9,158,228,229,
- 246, 97,128, 9, 30,231,117, 2,138,188,138,197,234,225,242,225,
- 244,105,128, 10,158,242,237,245,235,232,105,128, 10, 30,111,147,
- 0,111,138,248,139, 14,139, 92,140, 6,140, 78,140, 93,140,133,
- 141, 0,141, 21,141, 59,141, 70,141,248,143, 82,143,146,143,179,
- 143,225,144, 98,144,145,144,157, 97, 2,138,254,139, 5,227,245,
- 244,101,128, 0,243,238,231,244,232,225,105,128, 14, 45, 98, 4,
- 139, 24,139, 66,139, 75,139, 85,225,242,242,229,100,130, 2,117,
- 139, 36,139, 47,227,249,242,233,236,236,233, 99,128, 4,233,228,
- 233,229,242,229,243,233,243,227,249,242,233,236,236,233, 99,128,
- 4,235,229,238,231,225,236,105,128, 9,147,239,240,239,237,239,
- 230,111,128, 49, 27,242,229,246,101,128, 1, 79, 99, 3,139,100,
- 139,173,139,252, 97, 2,139,106,139,167,238,228,242, 97, 3,139,
- 117,139,124,139,135,228,229,246, 97,128, 9, 17,231,245,234,225,
- 242,225,244,105,128, 10,145,246,239,247,229,236,243,233,231,110,
- 2,139,149,139,156,228,229,246, 97,128, 9, 73,231,245,234,225,
- 242,225,244,105,128, 10,201,242,239,110,128, 1,210,233,242, 99,
- 2,139,181,139,186,236,101,128, 36,222,245,237,230,236,229,120,
- 133, 0,244,139,205,139,213,139,224,139,232,139,244,225,227,245,
- 244,101,128, 30,209,228,239,244,226,229,236,239,119,128, 30,217,
- 231,242,225,246,101,128, 30,211,232,239,239,235,225,226,239,246,
- 101,128, 30,213,244,233,236,228,101,128, 30,215,249,242,233,236,
- 236,233, 99,128, 4, 62,100, 4,140, 16,140, 39,140, 45,140, 68,
- 226,108, 2,140, 23,140, 31,225,227,245,244,101,128, 1, 81,231,
- 242,225,246,101,128, 2, 13,229,246, 97,128, 9, 19,233,229,242,
- 229,243,233,115,129, 0,246,140, 57,227,249,242,233,236,236,233,
- 99,128, 4,231,239,244,226,229,236,239,119,128, 30,205,101,129,
- 1, 83,140, 84,235,239,242,229,225,110,128, 49, 90,103, 3,140,
- 101,140,116,140,123,239,238,229,107,129, 2,219,140,110,227,237,
- 98,128, 3, 40,242,225,246,101,128, 0,242,245,234,225,242,225,
- 244,105,128, 10,147,104, 4,140,143,140,154,140,164,140,242,225,
- 242,237,229,238,233,225,110,128, 5,133,233,242,225,231,225,238,
- 97,128, 48, 74,111, 2,140,170,140,180,239,235,225,226,239,246,
- 101,128, 30,207,242,110,133, 1,161,140,195,140,203,140,214,140,
- 222,140,234,225,227,245,244,101,128, 30,219,228,239,244,226,229,
- 236,239,119,128, 30,227,231,242,225,246,101,128, 30,221,232,239,
- 239,235,225,226,239,246,101,128, 30,223,244,233,236,228,101,128,
- 30,225,245,238,231,225,242,245,237,236,225,245,116,128, 1, 81,
- 105,129, 1,163,141, 6,238,246,229,242,244,229,228,226,242,229,
- 246,101,128, 2, 15,107, 2,141, 27,141, 51,225,244,225,235,225,
- 238, 97,129, 48,170,141, 39,232,225,236,230,247,233,228,244,104,
- 128,255,117,239,242,229,225,110,128, 49, 87,236,229,232,229,226,
- 242,229,119,128, 5,171,109, 6,141, 84,141,112,141,119,141,208,
- 141,219,141,237,225,227,242,239,110,130, 1, 77,141, 96,141,104,
- 225,227,245,244,101,128, 30, 83,231,242,225,246,101,128, 30, 81,
- 228,229,246, 97,128, 9, 80,229,231, 97,133, 3,201,141,135,141,
- 139,141,150,141,164,141,180, 49,128, 3,214,227,249,242,233,236,
- 236,233, 99,128, 4, 97,236,225,244,233,238,227,236,239,243,229,
- 100,128, 2,119,242,239,245,238,228,227,249,242,233,236,236,233,
- 99,128, 4,123,116, 2,141,186,141,201,233,244,236,239,227,249,
- 242,233,236,236,233, 99,128, 4,125,239,238,239,115,128, 3,206,
- 231,245,234,225,242,225,244,105,128, 10,208,233,227,242,239,110,
- 129, 3,191,141,229,244,239,238,239,115,128, 3,204,239,238,239,
- 243,240,225,227,101,128,255, 79,238,101,145, 0, 49,142, 31,142,
- 40,142, 50,142, 80,142,105,142,114,142,123,142,148,142,182,142,
- 216,142,228,142,247,143, 2,143, 35,143, 45,143, 53,143, 64,225,
- 242,225,226,233, 99,128, 6, 97,226,229,238,231,225,236,105,128,
- 9,231,227,233,242,227,236,101,129, 36, 96,142, 61,233,238,246,
- 229,242,243,229,243,225,238,243,243,229,242,233,102,128, 39,138,
- 100, 2,142, 86,142, 92,229,246, 97,128, 9,103,239,244,229,238,
- 236,229,225,228,229,114,128, 32, 36,229,233,231,232,244,104,128,
- 33, 91,230,233,244,244,229,100,128,246,220,231,117, 2,142,130,
- 142,139,234,225,242,225,244,105,128, 10,231,242,237,245,235,232,
- 105,128, 10,103,232, 97, 3,142,157,142,168,142,173,227,235,225,
- 242,225,226,233, 99,128, 6, 97,236,102,128, 0,189,238,231,250,
- 232,239,117,128, 48, 33,105, 2,142,188,142,206,228,229,239,231,
- 242,225,240,232,233,227,240,225,242,229,110,128, 50, 32,238,230,
- 229,242,233,239,114,128, 32,129,237,239,238,239,243,240,225,227,
- 101,128,255, 17,238,245,237,229,242,225,244,239,242,226,229,238,
- 231,225,236,105,128, 9,244,239,236,228,243,244,249,236,101,128,
- 247, 49,112, 2,143, 8,143, 15,225,242,229,110,128, 36,116,229,
- 114, 2,143, 22,143, 28,233,239,100,128, 36,136,243,233,225,110,
- 128, 6,241,241,245,225,242,244,229,114,128, 0,188,242,239,237,
- 225,110,128, 33,112,243,245,240,229,242,233,239,114,128, 0,185,
- 244,104, 2,143, 71,143, 76,225,105,128, 14, 81,233,242,100,128,
- 33, 83,111, 3,143, 90,143,124,143,140,103, 2,143, 96,143,114,
- 239,238,229,107,129, 1,235,143,105,237,225,227,242,239,110,128,
- 1,237,245,242,237,245,235,232,105,128, 10, 19,237,225,244,242,
- 225,231,245,242,237,245,235,232,105,128, 10, 75,240,229,110,128,
- 2, 84,112, 3,143,154,143,161,143,172,225,242,229,110,128, 36,
- 170,229,238,226,245,236,236,229,116,128, 37,230,244,233,239,110,
- 128, 35, 37,114, 2,143,185,143,214,100, 2,143,191,143,202,230,
- 229,237,233,238,233,238,101,128, 0,170,237,225,243,227,245,236,
- 233,238,101,128, 0,186,244,232,239,231,239,238,225,108,128, 34,
- 31,115, 5,143,237,144, 13,144, 30,144, 75,144, 88,232,239,242,
- 116, 2,143,246,143,253,228,229,246, 97,128, 9, 18,246,239,247,
- 229,236,243,233,231,238,228,229,246, 97,128, 9, 74,236,225,243,
- 104,129, 0,248,144, 22,225,227,245,244,101,128, 1,255,237,225,
- 236,108, 2,144, 39,144, 50,232,233,242,225,231,225,238, 97,128,
- 48, 73,235,225,244,225,235,225,238, 97,129, 48,169,144, 63,232,
- 225,236,230,247,233,228,244,104,128,255,107,244,242,239,235,229,
- 225,227,245,244,101,128, 1,255,245,240,229,242,233,239,114,128,
- 246,240,116, 2,144,104,144,115,227,249,242,233,236,236,233, 99,
- 128, 4,127,233,236,228,101,130, 0,245,144,126,144,134,225,227,
- 245,244,101,128, 30, 77,228,233,229,242,229,243,233,115,128, 30,
- 79,245,226,239,240,239,237,239,230,111,128, 49, 33,118, 2,144,
- 163,144,244,229,114, 2,144,170,144,236,236,233,238,101,131, 32,
- 62,144,183,144,206,144,229, 99, 2,144,189,144,201,229,238,244,
- 229,242,236,233,238,101,128,254, 74,237, 98,128, 3, 5,100, 2,
- 144,212,144,220,225,243,232,229,100,128,254, 73,226,236,247,225,
- 246,121,128,254, 76,247,225,246,121,128,254, 75,243,227,239,242,
- 101,128, 0,175,239,247,229,236,243,233,231,110, 3,145, 3,145,
- 13,145, 20,226,229,238,231,225,236,105,128, 9,203,228,229,246,
- 97,128, 9, 75,231,245,234,225,242,225,244,105,128, 10,203,112,
- 145, 0,112,145, 69,147,197,147,208,147,217,147,229,149,154,149,
- 164,150,156,151,175,152, 9,152, 35,152,166,152,174,153, 76,153,
- 134,153,162,153,172, 97, 14,145, 99,145,131,145,141,145,148,145,
- 155,145,203,145,214,145,228,145,239,146, 30,146, 44,147, 56,147,
- 95,147,185, 97, 2,145,105,145,117,237,240,243,243,241,245,225,
- 242,101,128, 51,128,243,229,238,244,239,243,241,245,225,242,101,
- 128, 51, 43,226,229,238,231,225,236,105,128, 9,170,227,245,244,
- 101,128, 30, 85,228,229,246, 97,128, 9, 42,103, 2,145,161,145,
- 179,101, 2,145,167,145,174,228,239,247,110,128, 33,223,245,112,
- 128, 33,222,117, 2,145,185,145,194,234,225,242,225,244,105,128,
- 10,170,242,237,245,235,232,105,128, 10, 42,232,233,242,225,231,
- 225,238, 97,128, 48,113,233,249,225,238,238,239,233,244,232,225,
- 105,128, 14, 47,235,225,244,225,235,225,238, 97,128, 48,209,108,
- 2,145,245,146, 14,225,244,225,236,233,250,225,244,233,239,238,
- 227,249,242,233,236,236,233,227,227,237, 98,128, 4,132,239,227,
- 232,235,225,227,249,242,233,236,236,233, 99,128, 4,192,238,243,
- 233,239,243,235,239,242,229,225,110,128, 49,127,114, 3,146, 52,
- 146, 73,147, 45, 97, 2,146, 58,146, 66,231,242,225,240,104,128,
- 0,182,236,236,229,108,128, 34, 37,229,110, 2,146, 80,146,190,
- 236,229,230,116,136, 0, 40,146,103,146,118,146,123,146,128,146,
- 139,146,151,146,174,146,179,225,236,244,239,238,229,225,242,225,
- 226,233, 99,128,253, 62,226,116,128,248,237,229,120,128,248,236,
- 233,238,230,229,242,233,239,114,128, 32,141,237,239,238,239,243,
- 240,225,227,101,128,255, 8,115, 2,146,157,146,164,237,225,236,
- 108,128,254, 89,245,240,229,242,233,239,114,128, 32,125,244,112,
- 128,248,235,246,229,242,244,233,227,225,108,128,254, 53,242,233,
- 231,232,116,136, 0, 41,146,214,146,229,146,234,146,239,146,250,
- 147, 6,147, 29,147, 34,225,236,244,239,238,229,225,242,225,226,
- 233, 99,128,253, 63,226,116,128,248,248,229,120,128,248,247,233,
- 238,230,229,242,233,239,114,128, 32,142,237,239,238,239,243,240,
- 225,227,101,128,255, 9,115, 2,147, 12,147, 19,237,225,236,108,
- 128,254, 90,245,240,229,242,233,239,114,128, 32,126,244,112,128,
- 248,246,246,229,242,244,233,227,225,108,128,254, 54,244,233,225,
- 236,228,233,230,102,128, 34, 2,115, 3,147, 64,147, 75,147, 87,
- 229,241,232,229,226,242,229,119,128, 5,192,232,244,225,232,229,
- 226,242,229,119,128, 5,153,241,245,225,242,101,128, 51,169,244,
- 225,104,134, 5,183,147,113,147,127,147,132,147,141,147,156,147,
- 172, 49, 2,147,119,147,123, 49,128, 5,183,100,128, 5,183,178,
- 97,128, 5,183,232,229,226,242,229,119,128, 5,183,238,225,242,
- 242,239,247,232,229,226,242,229,119,128, 5,183,241,245,225,242,
- 244,229,242,232,229,226,242,229,119,128, 5,183,247,233,228,229,
- 232,229,226,242,229,119,128, 5,183,250,229,242,232,229,226,242,
- 229,119,128, 5,161,226,239,240,239,237,239,230,111,128, 49, 6,
- 227,233,242,227,236,101,128, 36,223,228,239,244,225,227,227,229,
- 238,116,128, 30, 87,101,137, 5,228,147,251,148, 6,148, 26,148,
- 38,148, 58,148,160,148,171,148,192,149,147,227,249,242,233,236,
- 236,233, 99,128, 4, 63,228,225,231,229,243,104,129,251, 68,148,
- 17,232,229,226,242,229,119,128,251, 68,229,250,233,243,241,245,
- 225,242,101,128, 51, 59,230,233,238,225,236,228,225,231,229,243,
- 232,232,229,226,242,229,119,128,251, 67,104, 5,148, 70,148, 93,
- 148,101,148,115,148,145,225,114, 2,148, 77,148, 84,225,226,233,
- 99,128, 6,126,237,229,238,233,225,110,128, 5,122,229,226,242,
- 229,119,128, 5,228,230,233,238,225,236,225,242,225,226,233, 99,
- 128,251, 87,105, 2,148,121,148,136,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,251, 88,242,225,231,225,238, 97,128, 48,
- 122,237,229,228,233,225,236,225,242,225,226,233, 99,128,251, 89,
- 235,225,244,225,235,225,238, 97,128, 48,218,237,233,228,228,236,
- 229,232,239,239,235,227,249,242,233,236,236,233, 99,128, 4,167,
- 114, 5,148,204,148,216,149, 2,149,123,149,136,225,230,229,232,
- 229,226,242,229,119,128,251, 78,227,229,238,116,131, 0, 37,148,
- 229,148,238,148,250,225,242,225,226,233, 99,128, 6,106,237,239,
- 238,239,243,240,225,227,101,128,255, 5,243,237,225,236,108,128,
- 254,106,105, 2,149, 8,149,105,239,100,134, 0, 46,149, 25,149,
- 36,149, 47,149, 59,149, 70,149, 82,225,242,237,229,238,233,225,
- 110,128, 5,137,227,229,238,244,229,242,229,100,128, 0,183,232,
- 225,236,230,247,233,228,244,104,128,255, 97,233,238,230,229,242,
- 233,239,114,128,246,231,237,239,238,239,243,240,225,227,101,128,
- 255, 14,115, 2,149, 88,149, 95,237,225,236,108,128,254, 82,245,
- 240,229,242,233,239,114,128,246,232,243,240,239,237,229,238,233,
- 231,242,229,229,235,227,237, 98,128, 3, 66,240,229,238,228,233,
- 227,245,236,225,114,128, 34,165,244,232,239,245,243,225,238,100,
- 128, 32, 48,243,229,244, 97,128, 32,167,230,243,241,245,225,242,
- 101,128, 51,138,104, 3,149,172,149,222,150,103, 97, 3,149,180,
- 149,190,149,197,226,229,238,231,225,236,105,128, 9,171,228,229,
- 246, 97,128, 9, 43,231,117, 2,149,204,149,213,234,225,242,225,
- 244,105,128, 10,171,242,237,245,235,232,105,128, 10, 43,105,133,
- 3,198,149,236,149,240,150, 70,150, 78,150, 89, 49,128, 3,213,
- 229,245,240,104, 4,149,253,150, 32,150, 47,150, 56, 97, 2,150,
- 3,150, 18,227,233,242,227,236,229,235,239,242,229,225,110,128,
- 50,122,240,225,242,229,238,235,239,242,229,225,110,128, 50, 26,
- 227,233,242,227,236,229,235,239,242,229,225,110,128, 50,108,235,
- 239,242,229,225,110,128, 49, 77,240,225,242,229,238,235,239,242,
- 229,225,110,128, 50, 12,236,225,244,233,110,128, 2,120,238,244,
- 232,245,244,232,225,105,128, 14, 58,243,249,237,226,239,236,231,
- 242,229,229,107,128, 3,213,111, 3,150,111,150,116,150,142,239,
- 107,128, 1,165,240,104, 2,150,123,150,132,225,238,244,232,225,
- 105,128, 14, 30,245,238,231,244,232,225,105,128, 14, 28,243,225,
- 237,240,232,225,239,244,232,225,105,128, 14, 32,105,133, 3,192,
- 150,170,151,126,151,137,151,148,151,162,229,245,112, 6,150,186,
- 150,221,150,253,151, 25,151, 39,151, 91, 97, 2,150,192,150,207,
- 227,233,242,227,236,229,235,239,242,229,225,110,128, 50,115,240,
- 225,242,229,238,235,239,242,229,225,110,128, 50, 19,227,105, 2,
- 150,228,150,240,229,245,227,235,239,242,229,225,110,128, 49,118,
- 242,227,236,229,235,239,242,229,225,110,128, 50,101,107, 2,151,
- 3,151, 17,233,249,229,239,235,235,239,242,229,225,110,128, 49,
- 114,239,242,229,225,110,128, 49, 66,240,225,242,229,238,235,239,
- 242,229,225,110,128, 50, 5,243,233,239,115, 2,151, 48,151, 76,
- 107, 2,151, 54,151, 68,233,249,229,239,235,235,239,242,229,225,
- 110,128, 49,116,239,242,229,225,110,128, 49, 68,244,233,235,229,
- 245,244,235,239,242,229,225,110,128, 49,117,116, 2,151, 97,151,
- 112,232,233,229,245,244,232,235,239,242,229,225,110,128, 49,119,
- 233,235,229,245,244,235,239,242,229,225,110,128, 49,115,232,233,
- 242,225,231,225,238, 97,128, 48,116,235,225,244,225,235,225,238,
- 97,128, 48,212,243,249,237,226,239,236,231,242,229,229,107,128,
- 3,214,247,242,225,242,237,229,238,233,225,110,128, 5,131,236,
- 245,115,132, 0, 43,151,189,151,200,151,209,151,242,226,229,236,
- 239,247,227,237, 98,128, 3, 31,227,233,242,227,236,101,128, 34,
- 149,109, 2,151,215,151,222,233,238,245,115,128, 0,177,111, 2,
- 151,228,151,232,100,128, 2,214,238,239,243,240,225,227,101,128,
- 255, 11,115, 2,151,248,151,255,237,225,236,108,128,254, 98,245,
- 240,229,242,233,239,114,128, 32,122,109, 2,152, 15,152, 26,239,
- 238,239,243,240,225,227,101,128,255, 80,243,241,245,225,242,101,
- 128, 51,216,111, 5,152, 47,152, 58,152,125,152,136,152,146,232,
- 233,242,225,231,225,238, 97,128, 48,125,233,238,244,233,238,231,
- 233,238,228,229,120, 4,152, 78,152, 90,152,102,152,115,228,239,
- 247,238,247,232,233,244,101,128, 38, 31,236,229,230,244,247,232,
- 233,244,101,128, 38, 28,242,233,231,232,244,247,232,233,244,101,
- 128, 38, 30,245,240,247,232,233,244,101,128, 38, 29,235,225,244,
- 225,235,225,238, 97,128, 48,221,240,236,225,244,232,225,105,128,
- 14, 27,243,244,225,236,237,225,242,107,129, 48, 18,152,159,230,
- 225,227,101,128, 48, 32,240,225,242,229,110,128, 36,171,114, 3,
- 152,182,152,208,152,233,101, 2,152,188,152,196,227,229,228,229,
- 115,128, 34,122,243,227,242,233,240,244,233,239,110,128, 33, 30,
- 233,237,101, 2,152,216,152,222,237,239,100,128, 2,185,242,229,
- 246,229,242,243,229,100,128, 32, 53,111, 4,152,243,152,250,153,
- 4,153, 17,228,245,227,116,128, 34, 15,234,229,227,244,233,246,
- 101,128, 35, 5,236,239,238,231,229,228,235,225,238, 97,128, 48,
- 252,112, 2,153, 23,153, 60,101, 2,153, 29,153, 36,236,236,239,
- 114,128, 35, 24,242,243,117, 2,153, 44,153, 51,226,243,229,116,
- 128, 34,130,240,229,242,243,229,116,128, 34,131,239,242,244,233,
- 239,110,129, 34, 55,153, 71,225,108,128, 34, 29,115, 2,153, 82,
- 153,125,105,130, 3,200,153, 90,153,101,227,249,242,233,236,236,
- 233, 99,128, 4,113,236,233,240,238,229,245,237,225,244,225,227,
- 249,242,233,236,236,233,227,227,237, 98,128, 4,134,243,241,245,
- 225,242,101,128, 51,176,117, 2,153,140,153,151,232,233,242,225,
- 231,225,238, 97,128, 48,119,235,225,244,225,235,225,238, 97,128,
- 48,215,246,243,241,245,225,242,101,128, 51,180,247,243,241,245,
- 225,242,101,128, 51,186,113,136, 0,113,153,202,154,251,155, 6,
- 155, 15,155, 22,155, 34,155, 72,155, 80, 97, 4,153,212,153,235,
- 154, 43,154,234,100, 2,153,218,153,224,229,246, 97,128, 9, 88,
- 237,225,232,229,226,242,229,119,128, 5,168,102, 4,153,245,153,
- 254,154, 12,154, 28,225,242,225,226,233, 99,128, 6, 66,230,233,
- 238,225,236,225,242,225,226,233, 99,128,254,214,233,238,233,244,
- 233,225,236,225,242,225,226,233, 99,128,254,215,237,229,228,233,
- 225,236,225,242,225,226,233, 99,128,254,216,237,225,244,115,136,
- 5,184,154, 66,154, 86,154,100,154,105,154,110,154,119,154,134,
- 154,221, 49, 3,154, 74,154, 78,154, 82, 48,128, 5,184, 97,128,
- 5,184, 99,128, 5,184, 50, 2,154, 92,154, 96, 55,128, 5,184,
- 57,128, 5,184,179, 51,128, 5,184,228,101,128, 5,184,232,229,
- 226,242,229,119,128, 5,184,238,225,242,242,239,247,232,229,226,
- 242,229,119,128, 5,184,113, 2,154,140,154,206,225,244,225,110,
- 4,154,153,154,162,154,177,154,193,232,229,226,242,229,119,128,
- 5,184,238,225,242,242,239,247,232,229,226,242,229,119,128, 5,
- 184,241,245,225,242,244,229,242,232,229,226,242,229,119,128, 5,
- 184,247,233,228,229,232,229,226,242,229,119,128, 5,184,245,225,
- 242,244,229,242,232,229,226,242,229,119,128, 5,184,247,233,228,
- 229,232,229,226,242,229,119,128, 5,184,242,238,229,249,240,225,
- 242,225,232,229,226,242,229,119,128, 5,159,226,239,240,239,237,
- 239,230,111,128, 49, 17,227,233,242,227,236,101,128, 36,224,232,
- 239,239,107,128, 2,160,237,239,238,239,243,240,225,227,101,128,
- 255, 81,239,102,130, 5,231,155, 43,155, 63,228,225,231,229,243,
- 104,129,251, 71,155, 54,232,229,226,242,229,119,128,251, 71,232,
- 229,226,242,229,119,128, 5,231,240,225,242,229,110,128, 36,172,
- 117, 4,155, 90,155,102,155,191,156, 22,225,242,244,229,242,238,
- 239,244,101,128, 38,105,226,245,244,115,135, 5,187,155,123,155,
- 128,155,133,155,138,155,147,155,162,155,178,177, 56,128, 5,187,
- 178, 53,128, 5,187,179, 49,128, 5,187,232,229,226,242,229,119,
- 128, 5,187,238,225,242,242,239,247,232,229,226,242,229,119,128,
- 5,187,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
- 5,187,247,233,228,229,232,229,226,242,229,119,128, 5,187,229,
- 243,244,233,239,110,133, 0, 63,155,210,155,233,155,250,156, 2,
- 156, 14,225,114, 2,155,217,155,224,225,226,233, 99,128, 6, 31,
- 237,229,238,233,225,110,128, 5, 94,228,239,247,110,129, 0,191,
- 155,242,243,237,225,236,108,128,247,191,231,242,229,229,107,128,
- 3,126,237,239,238,239,243,240,225,227,101,128,255, 31,243,237,
- 225,236,108,128,247, 63,239,244,101, 4,156, 34,156,105,156,125,
- 156,154,228,226,108,133, 0, 34,156, 50,156, 57,156, 64,156, 76,
- 156, 97,226,225,243,101,128, 32, 30,236,229,230,116,128, 32, 28,
- 237,239,238,239,243,240,225,227,101,128,255, 2,240,242,233,237,
- 101,129, 48, 30,156, 86,242,229,246,229,242,243,229,100,128, 48,
- 29,242,233,231,232,116,128, 32, 29,236,229,230,116,129, 32, 24,
- 156,114,242,229,246,229,242,243,229,100,128, 32, 27,114, 2,156,
- 131,156,141,229,246,229,242,243,229,100,128, 32, 27,233,231,232,
- 116,129, 32, 25,156,150,110,128, 1, 73,243,233,238,231,108, 2,
- 156,164,156,171,226,225,243,101,128, 32, 26,101,129, 0, 39,156,
- 177,237,239,238,239,243,240,225,227,101,128,255, 7,114,145, 0,
- 114,156,227,157,231,157,242,158, 33,158, 84,159,101,159,125,159,
- 220,161,254,162, 35,162, 47,162,101,162,109,163, 15,163, 26,163,
- 61,163,161, 97, 11,156,251,157, 6,157, 16,157, 23,157, 88,157,
- 104,157,129,157,140,157,165,157,188,157,225,225,242,237,229,238,
- 233,225,110,128, 5,124,226,229,238,231,225,236,105,128, 9,176,
- 227,245,244,101,128, 1, 85,100, 4,157, 33,157, 39,157, 53,157,
- 79,229,246, 97,128, 9, 48,233,227,225,108,129, 34, 26,157, 48,
- 229,120,128,248,229,239,246,229,242,243,243,241,245,225,242,101,
- 129, 51,174,157, 69,228,243,241,245,225,242,101,128, 51,175,243,
- 241,245,225,242,101,128, 51,173,230,101,129, 5,191,157, 95,232,
- 229,226,242,229,119,128, 5,191,231,117, 2,157,111,157,120,234,
- 225,242,225,244,105,128, 10,176,242,237,245,235,232,105,128, 10,
- 48,232,233,242,225,231,225,238, 97,128, 48,137,235,225,244,225,
- 235,225,238, 97,129, 48,233,157,153,232,225,236,230,247,233,228,
- 244,104,128,255,151,236,239,247,229,242,228,233,225,231,239,238,
- 225,236,226,229,238,231,225,236,105,128, 9,241,109, 2,157,194,
- 157,217,233,228,228,236,229,228,233,225,231,239,238,225,236,226,
- 229,238,231,225,236,105,128, 9,240,243,232,239,242,110,128, 2,
- 100,244,233,111,128, 34, 54,226,239,240,239,237,239,230,111,128,
- 49, 22, 99, 4,157,252,158, 3,158, 12,158, 20,225,242,239,110,
- 128, 1, 89,229,228,233,236,236, 97,128, 1, 87,233,242,227,236,
- 101,128, 36,225,239,237,237,225,225,227,227,229,238,116,128, 1,
- 87,100, 2,158, 39,158, 49,226,236,231,242,225,246,101,128, 2,
- 17,239,116, 2,158, 56,158, 65,225,227,227,229,238,116,128, 30,
- 89,226,229,236,239,119,129, 30, 91,158, 75,237,225,227,242,239,
- 110,128, 30, 93,101, 6,158, 98,158,143,158,178,158,233,159, 2,
- 159, 35,102, 2,158,104,158,117,229,242,229,238,227,229,237,225,
- 242,107,128, 32, 59,236,229,248,243,117, 2,158,127,158,134,226,
- 243,229,116,128, 34,134,240,229,242,243,229,116,128, 34,135,231,
- 233,243,244,229,114, 2,158,154,158,159,229,100,128, 0,174,115,
- 2,158,165,158,171,225,238,115,128,248,232,229,242,233,102,128,
- 246,218,104, 3,158,186,158,209,158,223,225,114, 2,158,193,158,
- 200,225,226,233, 99,128, 6, 49,237,229,238,233,225,110,128, 5,
- 128,230,233,238,225,236,225,242,225,226,233, 99,128,254,174,233,
- 242,225,231,225,238, 97,128, 48,140,235,225,244,225,235,225,238,
- 97,129, 48,236,158,246,232,225,236,230,247,233,228,244,104,128,
- 255,154,243,104,130, 5,232,159, 11,159, 26,228,225,231,229,243,
- 232,232,229,226,242,229,119,128,251, 72,232,229,226,242,229,119,
- 128, 5,232,118, 3,159, 43,159, 56,159, 88,229,242,243,229,228,
- 244,233,236,228,101,128, 34, 61,233, 97, 2,159, 63,159, 72,232,
- 229,226,242,229,119,128, 5,151,237,245,231,242,225,243,232,232,
- 229,226,242,229,119,128, 5,151,236,239,231,233,227,225,236,238,
- 239,116,128, 35, 16,230,233,243,232,232,239,239,107,129, 2,126,
- 159,114,242,229,246,229,242,243,229,100,128, 2,127,104, 2,159,
- 131,159,154, 97, 2,159,137,159,147,226,229,238,231,225,236,105,
- 128, 9,221,228,229,246, 97,128, 9, 93,111,131, 3,193,159,164,
- 159,193,159,207,239,107,129, 2,125,159,171,244,245,242,238,229,
- 100,129, 2,123,159,182,243,245,240,229,242,233,239,114,128, 2,
- 181,243,249,237,226,239,236,231,242,229,229,107,128, 3,241,244,
- 233,227,232,239,239,235,237,239,100,128, 2,222,105, 6,159,234,
- 161, 22,161, 68,161, 79,161,104,161,240,229,245,108, 9,160, 0,
- 160, 35,160, 50,160, 64,160,110,160,124,160,210,160,223,161, 2,
- 97, 2,160, 6,160, 21,227,233,242,227,236,229,235,239,242,229,
- 225,110,128, 50,113,240,225,242,229,238,235,239,242,229,225,110,
- 128, 50, 17,227,233,242,227,236,229,235,239,242,229,225,110,128,
- 50, 99,232,233,229,245,232,235,239,242,229,225,110,128, 49, 64,
- 107, 2,160, 70,160,102,233,249,229,239,107, 2,160, 80,160, 89,
- 235,239,242,229,225,110,128, 49, 58,243,233,239,243,235,239,242,
- 229,225,110,128, 49,105,239,242,229,225,110,128, 49, 57,237,233,
- 229,245,237,235,239,242,229,225,110,128, 49, 59,112, 3,160,132,
- 160,164,160,179, 97, 2,160,138,160,152,238,243,233,239,243,235,
- 239,242,229,225,110,128, 49,108,242,229,238,235,239,242,229,225,
- 110,128, 50, 3,232,233,229,245,240,232,235,239,242,229,225,110,
- 128, 49, 63,233,229,245,112, 2,160,188,160,197,235,239,242,229,
- 225,110,128, 49, 60,243,233,239,243,235,239,242,229,225,110,128,
- 49,107,243,233,239,243,235,239,242,229,225,110,128, 49, 61,116,
- 2,160,229,160,244,232,233,229,245,244,232,235,239,242,229,225,
- 110,128, 49, 62,233,235,229,245,244,235,239,242,229,225,110,128,
- 49,106,249,229,239,242,233,238,232,233,229,245,232,235,239,242,
- 229,225,110,128, 49,109,231,232,116, 2,161, 30,161, 38,225,238,
- 231,236,101,128, 34, 31,116, 2,161, 44,161, 58,225,227,235,226,
- 229,236,239,247,227,237, 98,128, 3, 25,242,233,225,238,231,236,
- 101,128, 34,191,232,233,242,225,231,225,238, 97,128, 48,138,235,
- 225,244,225,235,225,238, 97,129, 48,234,161, 92,232,225,236,230,
- 247,233,228,244,104,128,255,152,110, 2,161,110,161,226,103,131,
- 2,218,161,120,161,131,161,137,226,229,236,239,247,227,237, 98,
- 128, 3, 37,227,237, 98,128, 3, 10,232,225,236,102, 2,161,146,
- 161,192,236,229,230,116,131, 2,191,161,159,161,170,161,181,225,
- 242,237,229,238,233,225,110,128, 5, 89,226,229,236,239,247,227,
- 237, 98,128, 3, 28,227,229,238,244,229,242,229,100,128, 2,211,
- 242,233,231,232,116,130, 2,190,161,204,161,215,226,229,236,239,
- 247,227,237, 98,128, 3, 57,227,229,238,244,229,242,229,100,128,
- 2,210,246,229,242,244,229,228,226,242,229,246,101,128, 2, 19,
- 244,244,239,242,245,243,241,245,225,242,101,128, 51, 81,108, 2,
- 162, 4,162, 15,233,238,229,226,229,236,239,119,128, 30, 95,239,
- 238,231,236,229,103,129, 2,124,162, 26,244,245,242,238,229,100,
- 128, 2,122,237,239,238,239,243,240,225,227,101,128,255, 82,111,
- 3,162, 55,162, 66,162, 91,232,233,242,225,231,225,238, 97,128,
- 48,141,235,225,244,225,235,225,238, 97,129, 48,237,162, 79,232,
- 225,236,230,247,233,228,244,104,128,255,155,242,245,225,244,232,
- 225,105,128, 14, 35,240,225,242,229,110,128, 36,173,114, 3,162,
- 117,162,153,162,183, 97, 3,162,125,162,135,162,142,226,229,238,
- 231,225,236,105,128, 9,220,228,229,246, 97,128, 9, 49,231,245,
- 242,237,245,235,232,105,128, 10, 92,229,104, 2,162,160,162,169,
- 225,242,225,226,233, 99,128, 6,145,230,233,238,225,236,225,242,
- 225,226,233, 99,128,251,141,246,239,227,225,236,233, 99, 4,162,
- 199,162,209,162,216,162,227,226,229,238,231,225,236,105,128, 9,
- 224,228,229,246, 97,128, 9, 96,231,245,234,225,242,225,244,105,
- 128, 10,224,246,239,247,229,236,243,233,231,110, 3,162,243,162,
- 253,163, 4,226,229,238,231,225,236,105,128, 9,196,228,229,246,
- 97,128, 9, 68,231,245,234,225,242,225,244,105,128, 10,196,243,
- 245,240,229,242,233,239,114,128,246,241,116, 2,163, 32,163, 40,
- 226,236,239,227,107,128, 37,144,245,242,238,229,100,129, 2,121,
- 163, 50,243,245,240,229,242,233,239,114,128, 2,180,117, 4,163,
- 71,163, 82,163,107,163,154,232,233,242,225,231,225,238, 97,128,
- 48,139,235,225,244,225,235,225,238, 97,129, 48,235,163, 95,232,
- 225,236,230,247,233,228,244,104,128,255,153,112, 2,163,113,163,
- 148,229,101, 2,163,120,163,134,237,225,242,235,226,229,238,231,
- 225,236,105,128, 9,242,243,233,231,238,226,229,238,231,225,236,
- 105,128, 9,243,233,225,104,128,246,221,244,232,225,105,128, 14,
- 36,246,239,227,225,236,233, 99, 4,163,177,163,187,163,194,163,
- 205,226,229,238,231,225,236,105,128, 9,139,228,229,246, 97,128,
- 9, 11,231,245,234,225,242,225,244,105,128, 10,139,246,239,247,
- 229,236,243,233,231,110, 3,163,221,163,231,163,238,226,229,238,
- 231,225,236,105,128, 9,195,228,229,246, 97,128, 9, 67,231,245,
- 234,225,242,225,244,105,128, 10,195,115,147, 0,115,164, 35,166,
- 5,166, 16,166,142,166,181,169,123,169,134,172, 21,174,159,174,
- 205,174,232,175,167,175,234,177, 11,177, 21,177,207,178, 24,178,
- 194,178,204, 97, 9,164, 55,164, 65,164, 86,164,158,164,183,164,
- 194,164,219,164,251,165, 35,226,229,238,231,225,236,105,128, 9,
- 184,227,245,244,101,129, 1, 91,164, 74,228,239,244,225,227,227,
- 229,238,116,128, 30,101,100, 5,164, 98,164,107,164,113,164,127,
- 164,143,225,242,225,226,233, 99,128, 6, 53,229,246, 97,128, 9,
- 56,230,233,238,225,236,225,242,225,226,233, 99,128,254,186,233,
- 238,233,244,233,225,236,225,242,225,226,233, 99,128,254,187,237,
- 229,228,233,225,236,225,242,225,226,233, 99,128,254,188,231,117,
- 2,164,165,164,174,234,225,242,225,244,105,128, 10,184,242,237,
- 245,235,232,105,128, 10, 56,232,233,242,225,231,225,238, 97,128,
- 48, 85,235,225,244,225,235,225,238, 97,129, 48,181,164,207,232,
- 225,236,230,247,233,228,244,104,128,255,123,236,236,225,236,236,
- 225,232,239,245,225,236,225,249,232,229,247,225,243,225,236,236,
- 225,237,225,242,225,226,233, 99,128,253,250,237,229,235,104,130,
- 5,225,165, 6,165, 26,228,225,231,229,243,104,129,251, 65,165,
- 17,232,229,226,242,229,119,128,251, 65,232,229,226,242,229,119,
- 128, 5,225,242, 97, 5,165, 48,165,122,165,130,165,180,165,188,
- 97, 5,165, 60,165, 68,165, 76,165,107,165,115,225,244,232,225,
- 105,128, 14, 50,229,244,232,225,105,128, 14, 65,233,237,225,233,
- 109, 2,165, 86,165, 97,225,236,225,233,244,232,225,105,128, 14,
- 68,245,225,238,244,232,225,105,128, 14, 67,237,244,232,225,105,
- 128, 14, 51,244,232,225,105,128, 14, 48,229,244,232,225,105,128,
- 14, 64,105, 3,165,138,165,162,165,173,105, 2,165,144,165,155,
- 236,229,230,244,244,232,225,105,128,248,134,244,232,225,105,128,
- 14, 53,236,229,230,244,244,232,225,105,128,248,133,244,232,225,
- 105,128, 14, 52,239,244,232,225,105,128, 14, 66,117, 3,165,196,
- 165,246,165,253,101, 3,165,204,165,228,165,239,101, 2,165,210,
- 165,221,236,229,230,244,244,232,225,105,128,248,136,244,232,225,
- 105,128, 14, 55,236,229,230,244,244,232,225,105,128,248,135,244,
- 232,225,105,128, 14, 54,244,232,225,105,128, 14, 56,245,244,232,
- 225,105,128, 14, 57,226,239,240,239,237,239,230,111,128, 49, 25,
- 99, 5,166, 28,166, 49,166, 58,166,107,166,129,225,242,239,110,
- 129, 1, 97,166, 37,228,239,244,225,227,227,229,238,116,128, 30,
- 103,229,228,233,236,236, 97,128, 1, 95,232,247, 97,131, 2, 89,
- 166, 70,166, 81,166,100,227,249,242,233,236,236,233, 99,128, 4,
- 217,228,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
- 99,128, 4,219,232,239,239,107,128, 2, 90,233,242, 99, 2,166,
- 115,166,120,236,101,128, 36,226,245,237,230,236,229,120,128, 1,
- 93,239,237,237,225,225,227,227,229,238,116,128, 2, 25,228,239,
- 116, 2,166,150,166,159,225,227,227,229,238,116,128, 30, 97,226,
- 229,236,239,119,129, 30, 99,166,169,228,239,244,225,227,227,229,
- 238,116,128, 30,105,101, 9,166,201,166,217,166,252,167, 61,167,
- 164,167,191,167,216,168, 41,168, 68,225,231,245,236,236,226,229,
- 236,239,247,227,237, 98,128, 3, 60, 99, 2,166,223,166,245,239,
- 238,100,129, 32, 51,166,231,244,239,238,229,227,232,233,238,229,
- 243,101,128, 2,202,244,233,239,110,128, 0,167,229,110, 4,167,
- 7,167, 16,167, 30,167, 46,225,242,225,226,233, 99,128, 6, 51,
- 230,233,238,225,236,225,242,225,226,233, 99,128,254,178,233,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,254,179,237,229,
- 228,233,225,236,225,242,225,226,233, 99,128,254,180,231,239,108,
- 135, 5,182,167, 81,167, 95,167,100,167,109,167,124,167,140,167,
- 151, 49, 2,167, 87,167, 91, 51,128, 5,182,102,128, 5,182,178,
- 99,128, 5,182,232,229,226,242,229,119,128, 5,182,238,225,242,
- 242,239,247,232,229,226,242,229,119,128, 5,182,241,245,225,242,
- 244,229,242,232,229,226,242,229,119,128, 5,182,244,225,232,229,
- 226,242,229,119,128, 5,146,247,233,228,229,232,229,226,242,229,
- 119,128, 5,182,104, 2,167,170,167,181,225,242,237,229,238,233,
- 225,110,128, 5,125,233,242,225,231,225,238, 97,128, 48, 91,235,
- 225,244,225,235,225,238, 97,129, 48,187,167,204,232,225,236,230,
- 247,233,228,244,104,128,255,126,237,105, 2,167,223,168, 10,227,
- 239,236,239,110,131, 0, 59,167,237,167,246,168, 2,225,242,225,
- 226,233, 99,128, 6, 27,237,239,238,239,243,240,225,227,101,128,
- 255, 27,243,237,225,236,108,128,254, 84,246,239,233,227,229,228,
- 237,225,242,235,235,225,238, 97,129, 48,156,168, 29,232,225,236,
- 230,247,233,228,244,104,128,255,159,238,116, 2,168, 48,168, 58,
- 233,243,241,245,225,242,101,128, 51, 34,239,243,241,245,225,242,
- 101,128, 51, 35,246,229,110,142, 0, 55,168,102,168,111,168,121,
- 168,151,168,158,168,168,168,193,168,220,168,254,169, 10,169, 21,
- 169, 54,169, 62,169, 73,225,242,225,226,233, 99,128, 6,103,226,
- 229,238,231,225,236,105,128, 9,237,227,233,242,227,236,101,129,
- 36,102,168,132,233,238,246,229,242,243,229,243,225,238,243,243,
- 229,242,233,102,128, 39,144,228,229,246, 97,128, 9,109,229,233,
- 231,232,244,232,115,128, 33, 94,231,117, 2,168,175,168,184,234,
- 225,242,225,244,105,128, 10,237,242,237,245,235,232,105,128, 10,
- 109,232, 97, 2,168,200,168,211,227,235,225,242,225,226,233, 99,
- 128, 6,103,238,231,250,232,239,117,128, 48, 39,105, 2,168,226,
- 168,244,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
- 110,128, 50, 38,238,230,229,242,233,239,114,128, 32,135,237,239,
- 238,239,243,240,225,227,101,128,255, 23,239,236,228,243,244,249,
- 236,101,128,247, 55,112, 2,169, 27,169, 34,225,242,229,110,128,
- 36,122,229,114, 2,169, 41,169, 47,233,239,100,128, 36,142,243,
- 233,225,110,128, 6,247,242,239,237,225,110,128, 33,118,243,245,
- 240,229,242,233,239,114,128, 32,119,116, 2,169, 79,169,117,229,
- 229,110, 2,169, 87,169, 96,227,233,242,227,236,101,128, 36,112,
- 112, 2,169,102,169,109,225,242,229,110,128, 36,132,229,242,233,
- 239,100,128, 36,152,232,225,105,128, 14, 87,230,244,232,249,240,
- 232,229,110,128, 0,173,104, 7,169,150,170,124,170,135,170,149,
- 171, 94,171,107,172, 15, 97, 6,169,164,169,175,169,185,169,196,
- 170, 83,170,108,225,242,237,229,238,233,225,110,128, 5,119,226,
- 229,238,231,225,236,105,128, 9,182,227,249,242,233,236,236,233,
- 99,128, 4, 72,100, 2,169,202,170, 42,228, 97, 4,169,213,169,
- 222,169,253,170, 11,225,242,225,226,233, 99,128, 6, 81,228,225,
- 237,237, 97, 2,169,232,169,241,225,242,225,226,233, 99,128,252,
- 97,244,225,238,225,242,225,226,233, 99,128,252, 94,230,225,244,
- 232,225,225,242,225,226,233, 99,128,252, 96,235,225,243,242, 97,
- 2,170, 21,170, 30,225,242,225,226,233, 99,128,252, 98,244,225,
- 238,225,242,225,226,233, 99,128,252, 95,101,132, 37,146,170, 54,
- 170, 61,170, 69,170, 78,228,225,242,107,128, 37,147,236,233,231,
- 232,116,128, 37,145,237,229,228,233,245,109,128, 37,146,246, 97,
- 128, 9, 54,231,117, 2,170, 90,170, 99,234,225,242,225,244,105,
- 128, 10,182,242,237,245,235,232,105,128, 10, 54,236,243,232,229,
- 236,229,244,232,229,226,242,229,119,128, 5,147,226,239,240,239,
- 237,239,230,111,128, 49, 21,227,232,225,227,249,242,233,236,236,
- 233, 99,128, 4, 73,101, 4,170,159,170,224,170,234,170,251,229,
- 110, 4,170,170,170,179,170,193,170,209,225,242,225,226,233, 99,
- 128, 6, 52,230,233,238,225,236,225,242,225,226,233, 99,128,254,
- 182,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,254,
- 183,237,229,228,233,225,236,225,242,225,226,233, 99,128,254,184,
- 233,227,239,240,244,233, 99,128, 3,227,241,229,108,129, 32,170,
- 170,242,232,229,226,242,229,119,128, 32,170,246, 97,134, 5,176,
- 171, 12,171, 27,171, 41,171, 50,171, 65,171, 81, 49, 2,171, 18,
- 171, 23,177, 53,128, 5,176, 53,128, 5,176, 50, 2,171, 33,171,
- 37, 50,128, 5,176,101,128, 5,176,232,229,226,242,229,119,128,
- 5,176,238,225,242,242,239,247,232,229,226,242,229,119,128, 5,
- 176,241,245,225,242,244,229,242,232,229,226,242,229,119,128, 5,
- 176,247,233,228,229,232,229,226,242,229,119,128, 5,176,232,225,
- 227,249,242,233,236,236,233, 99,128, 4,187,105, 2,171,113,171,
- 124,237,225,227,239,240,244,233, 99,128, 3,237,110,131, 5,233,
- 171,134,171,217,171,226,100, 2,171,140,171,206,225,231,229,243,
- 104,130,251, 73,171,152,171,161,232,229,226,242,229,119,128,251,
- 73,115, 2,171,167,171,187,232,233,238,228,239,116,129,251, 44,
- 171,178,232,229,226,242,229,119,128,251, 44,233,238,228,239,116,
- 129,251, 45,171,197,232,229,226,242,229,119,128,251, 45,239,244,
- 232,229,226,242,229,119,128, 5,193,232,229,226,242,229,119,128,
- 5,233,115, 2,171,232,171,252,232,233,238,228,239,116,129,251,
- 42,171,243,232,229,226,242,229,119,128,251, 42,233,238,228,239,
- 116,129,251, 43,172, 6,232,229,226,242,229,119,128,251, 43,239,
- 239,107,128, 2,130,105, 8,172, 39,172, 83,172, 94,172,119,172,
- 149,172,157,172,170,173, 85,231,237, 97,131, 3,195,172, 51,172,
- 55,172, 63, 49,128, 3,194,230,233,238,225,108,128, 3,194,236,
- 245,238,225,244,229,243,249,237,226,239,236,231,242,229,229,107,
- 128, 3,242,232,233,242,225,231,225,238, 97,128, 48, 87,235,225,
- 244,225,235,225,238, 97,129, 48,183,172,107,232,225,236,230,247,
- 233,228,244,104,128,255,124,236,245,113, 2,172,127,172,136,232,
- 229,226,242,229,119,128, 5,189,236,229,230,244,232,229,226,242,
- 229,119,128, 5,189,237,233,236,225,114,128, 34, 60,238,228,239,
- 244,232,229,226,242,229,119,128, 5,194,239,115, 6,172,185,172,
- 220,172,252,173, 24,173, 38,173, 70, 97, 2,172,191,172,206,227,
- 233,242,227,236,229,235,239,242,229,225,110,128, 50,116,240,225,
- 242,229,238,235,239,242,229,225,110,128, 50, 20,227,105, 2,172,
- 227,172,239,229,245,227,235,239,242,229,225,110,128, 49,126,242,
- 227,236,229,235,239,242,229,225,110,128, 50,102,107, 2,173, 2,
- 173, 16,233,249,229,239,235,235,239,242,229,225,110,128, 49,122,
- 239,242,229,225,110,128, 49, 69,238,233,229,245,238,235,239,242,
- 229,225,110,128, 49,123,112, 2,173, 44,173, 57,225,242,229,238,
- 235,239,242,229,225,110,128, 50, 6,233,229,245,240,235,239,242,
- 229,225,110,128, 49,125,244,233,235,229,245,244,235,239,242,229,
- 225,110,128, 49,124,120,141, 0, 54,173,115,173,124,173,134,173,
- 164,173,171,173,196,173,223,174, 1,174, 13,174, 24,174, 57,174,
- 65,174, 76,225,242,225,226,233, 99,128, 6,102,226,229,238,231,
- 225,236,105,128, 9,236,227,233,242,227,236,101,129, 36,101,173,
- 145,233,238,246,229,242,243,229,243,225,238,243,243,229,242,233,
- 102,128, 39,143,228,229,246, 97,128, 9,108,231,117, 2,173,178,
- 173,187,234,225,242,225,244,105,128, 10,236,242,237,245,235,232,
- 105,128, 10,108,232, 97, 2,173,203,173,214,227,235,225,242,225,
- 226,233, 99,128, 6,102,238,231,250,232,239,117,128, 48, 38,105,
- 2,173,229,173,247,228,229,239,231,242,225,240,232,233,227,240,
- 225,242,229,110,128, 50, 37,238,230,229,242,233,239,114,128, 32,
- 134,237,239,238,239,243,240,225,227,101,128,255, 22,239,236,228,
- 243,244,249,236,101,128,247, 54,112, 2,174, 30,174, 37,225,242,
- 229,110,128, 36,121,229,114, 2,174, 44,174, 50,233,239,100,128,
- 36,141,243,233,225,110,128, 6,246,242,239,237,225,110,128, 33,
- 117,243,245,240,229,242,233,239,114,128, 32,118,116, 2,174, 82,
- 174,153,229,229,110, 2,174, 90,174,132, 99, 2,174, 96,174,104,
- 233,242,227,236,101,128, 36,111,245,242,242,229,238,227,249,228,
- 229,238,239,237,233,238,225,244,239,242,226,229,238,231,225,236,
- 105,128, 9,249,112, 2,174,138,174,145,225,242,229,110,128, 36,
- 131,229,242,233,239,100,128, 36,151,232,225,105,128, 14, 86,108,
- 2,174,165,174,185,225,243,104,129, 0, 47,174,173,237,239,238,
- 239,243,240,225,227,101,128,255, 15,239,238,103,129, 1,127,174,
- 193,228,239,244,225,227,227,229,238,116,128, 30,155,109, 2,174,
- 211,174,221,233,236,229,230,225,227,101,128, 38, 58,239,238,239,
- 243,240,225,227,101,128,255, 83,111, 6,174,246,175, 40,175, 51,
- 175, 76,175,121,175,132,102, 2,174,252,175, 10,240,225,243,245,
- 241,232,229,226,242,229,119,128, 5,195,116, 2,175, 16,175, 25,
- 232,249,240,232,229,110,128, 0,173,243,233,231,238,227,249,242,
- 233,236,236,233, 99,128, 4, 76,232,233,242,225,231,225,238, 97,
- 128, 48, 93,235,225,244,225,235,225,238, 97,129, 48,189,175, 64,
- 232,225,236,230,247,233,228,244,104,128,255,127,236,233,228,245,
- 115, 2,175, 86,175,103,236,239,238,231,239,246,229,242,236,225,
- 249,227,237, 98,128, 3, 56,243,232,239,242,244,239,246,229,242,
- 236,225,249,227,237, 98,128, 3, 55,242,245,243,233,244,232,225,
- 105,128, 14, 41,115, 3,175,140,175,150,175,158,225,236,225,244,
- 232,225,105,128, 14, 40,239,244,232,225,105,128, 14, 11,245,225,
- 244,232,225,105,128, 14, 42,240, 97, 3,175,176,175,196,175,228,
- 227,101,129, 0, 32,175,183,232,225,227,235,225,242,225,226,233,
- 99,128, 0, 32,228,101,129, 38, 96,175,203,243,245,233,116, 2,
- 175,212,175,220,226,236,225,227,107,128, 38, 96,247,232,233,244,
- 101,128, 38,100,242,229,110,128, 36,174,241,245,225,242,101, 11,
- 176, 6,176, 17,176, 31,176, 56,176, 73,176, 99,176,114,176,147,
- 176,174,176,230,176,245,226,229,236,239,247,227,237, 98,128, 3,
- 59, 99, 2,176, 23,176, 27, 99,128, 51,196,109,128, 51,157,228,
- 233,225,231,239,238,225,236,227,242,239,243,243,232,225,244,227,
- 232,230,233,236,108,128, 37,169,232,239,242,233,250,239,238,244,
- 225,236,230,233,236,108,128, 37,164,107, 2,176, 79,176, 83,103,
- 128, 51,143,109,129, 51,158,176, 89,227,225,240,233,244,225,108,
- 128, 51,206,108, 2,176,105,176,109,110,128, 51,209,239,103,128,
- 51,210,109, 4,176,124,176,128,176,133,176,137,103,128, 51,142,
- 233,108,128, 51,213,109,128, 51,156,243,241,245,225,242,229,100,
- 128, 51,161,239,242,244,232,239,231,239,238,225,236,227,242,239,
- 243,243,232,225,244,227,232,230,233,236,108,128, 37,166,245,240,
- 240,229,114, 2,176,184,176,207,236,229,230,244,244,239,236,239,
- 247,229,242,242,233,231,232,244,230,233,236,108,128, 37,167,242,
- 233,231,232,244,244,239,236,239,247,229,242,236,229,230,244,230,
- 233,236,108,128, 37,168,246,229,242,244,233,227,225,236,230,233,
- 236,108,128, 37,165,247,232,233,244,229,247,233,244,232,243,237,
- 225,236,236,226,236,225,227,107,128, 37,163,242,243,241,245,225,
- 242,101,128, 51,219,115, 2,177, 27,177,197, 97, 4,177, 37,177,
- 47,177, 54,177, 65,226,229,238,231,225,236,105,128, 9,183,228,
- 229,246, 97,128, 9, 55,231,245,234,225,242,225,244,105,128, 10,
- 183,238,103, 8,177, 84,177, 98,177,112,177,126,177,141,177,155,
- 177,169,177,182,227,233,229,245,227,235,239,242,229,225,110,128,
- 49, 73,232,233,229,245,232,235,239,242,229,225,110,128, 49,133,
- 233,229,245,238,231,235,239,242,229,225,110,128, 49,128,235,233,
- 249,229,239,235,235,239,242,229,225,110,128, 49, 50,238,233,229,
- 245,238,235,239,242,229,225,110,128, 49,101,240,233,229,245,240,
- 235,239,242,229,225,110,128, 49, 67,243,233,239,243,235,239,242,
- 229,225,110,128, 49, 70,244,233,235,229,245,244,235,239,242,229,
- 225,110,128, 49, 56,245,240,229,242,233,239,114,128,246,242,116,
- 2,177,213,177,236,229,242,236,233,238,103,129, 0,163,177,224,
- 237,239,238,239,243,240,225,227,101,128,255,225,242,239,235,101,
- 2,177,245,178, 6,236,239,238,231,239,246,229,242,236,225,249,
- 227,237, 98,128, 3, 54,243,232,239,242,244,239,246,229,242,236,
- 225,249,227,237, 98,128, 3, 53,117, 7,178, 40,178, 72,178, 94,
- 178,105,178,146,178,156,178,160,226,243,229,116,130, 34,130,178,
- 51,178, 62,238,239,244,229,241,245,225,108,128, 34,138,239,242,
- 229,241,245,225,108,128, 34,134, 99, 2,178, 78,178, 86,227,229,
- 229,228,115,128, 34,123,232,244,232,225,116,128, 34, 11,232,233,
- 242,225,231,225,238, 97,128, 48, 89,107, 2,178,111,178,135,225,
- 244,225,235,225,238, 97,129, 48,185,178,123,232,225,236,230,247,
- 233,228,244,104,128,255,125,245,238,225,242,225,226,233, 99,128,
- 6, 82,237,237,225,244,233,239,110,128, 34, 17,110,128, 38, 60,
- 240,229,242,243,229,116,130, 34,131,178,173,178,184,238,239,244,
- 229,241,245,225,108,128, 34,139,239,242,229,241,245,225,108,128,
- 34,135,246,243,241,245,225,242,101,128, 51,220,249,239,245,247,
- 225,229,242,225,243,241,245,225,242,101,128, 51,124,116,144, 0,
- 116,179, 1,180, 10,180, 31,180,174,180,214,183, 6,186,144,187,
- 219,187,231,187,243,189, 20,189, 45,189,131,190, 55,190,239,191,
- 73, 97, 10,179, 23,179, 33,179, 54,179, 61,179, 86,179,164,179,
- 181,179,206,179,220,179,224,226,229,238,231,225,236,105,128, 9,
- 164,227,107, 2,179, 40,179, 47,228,239,247,110,128, 34,164,236,
- 229,230,116,128, 34,163,228,229,246, 97,128, 9, 36,231,117, 2,
- 179, 68,179, 77,234,225,242,225,244,105,128, 10,164,242,237,245,
- 235,232,105,128, 10, 36,104, 4,179, 96,179,105,179,119,179,149,
- 225,242,225,226,233, 99,128, 6, 55,230,233,238,225,236,225,242,
- 225,226,233, 99,128,254,194,105, 2,179,125,179,140,238,233,244,
- 233,225,236,225,242,225,226,233, 99,128,254,195,242,225,231,225,
- 238, 97,128, 48, 95,237,229,228,233,225,236,225,242,225,226,233,
- 99,128,254,196,233,243,249,239,245,229,242,225,243,241,245,225,
- 242,101,128, 51,125,235,225,244,225,235,225,238, 97,129, 48,191,
- 179,194,232,225,236,230,247,233,228,244,104,128,255,128,244,247,
- 229,229,236,225,242,225,226,233, 99,128, 6, 64,117,128, 3,196,
- 118,130, 5,234,179,232,180, 1,228,225,231,229,115,129,251, 74,
- 179,242,104,129,251, 74,179,248,232,229,226,242,229,119,128,251,
- 74,232,229,226,242,229,119,128, 5,234, 98, 2,180, 16,180, 21,
- 225,114,128, 1,103,239,240,239,237,239,230,111,128, 49, 10, 99,
- 6,180, 45,180, 52,180, 59,180, 68,180,134,180,161,225,242,239,
- 110,128, 1,101,227,245,242,108,128, 2,168,229,228,233,236,236,
- 97,128, 1, 99,232,229,104, 4,180, 80,180, 89,180,103,180,119,
- 225,242,225,226,233, 99,128, 6,134,230,233,238,225,236,225,242,
- 225,226,233, 99,128,251,123,233,238,233,244,233,225,236,225,242,
- 225,226,233, 99,128,251,124,237,229,228,233,225,236,225,242,225,
- 226,233, 99,128,251,125,233,242, 99, 2,180,142,180,147,236,101,
- 128, 36,227,245,237,230,236,229,248,226,229,236,239,119,128, 30,
- 113,239,237,237,225,225,227,227,229,238,116,128, 1, 99,100, 2,
- 180,180,180,190,233,229,242,229,243,233,115,128, 30,151,239,116,
- 2,180,197,180,206,225,227,227,229,238,116,128, 30,107,226,229,
- 236,239,119,128, 30,109,101, 9,180,234,180,245,181, 9,182, 19,
- 182, 44,182,108,182,175,182,180,182,232,227,249,242,233,236,236,
- 233, 99,128, 4, 66,228,229,243,227,229,238,228,229,242,227,249,
- 242,233,236,236,233, 99,128, 4,173,104, 7,181, 25,181, 34,181,
- 48,181, 88,181,118,181,159,182, 1,225,242,225,226,233, 99,128,
- 6, 42,230,233,238,225,236,225,242,225,226,233, 99,128,254,150,
- 232,225,232,105, 2,181, 57,181, 72,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,252,162,243,239,236,225,244,229,228,225,
- 242,225,226,233, 99,128,252, 12,105, 2,181, 94,181,109,238,233,
- 244,233,225,236,225,242,225,226,233, 99,128,254,151,242,225,231,
- 225,238, 97,128, 48,102,234,229,229,237,105, 2,181,128,181,143,
- 238,233,244,233,225,236,225,242,225,226,233, 99,128,252,161,243,
- 239,236,225,244,229,228,225,242,225,226,233, 99,128,252, 11,109,
- 2,181,165,181,199,225,242,226,245,244, 97, 2,181,176,181,185,
- 225,242,225,226,233, 99,128, 6, 41,230,233,238,225,236,225,242,
- 225,226,233, 99,128,254,148,101, 2,181,205,181,218,228,233,225,
- 236,225,242,225,226,233, 99,128,254,152,229,237,105, 2,181,226,
- 181,241,238,233,244,233,225,236,225,242,225,226,233, 99,128,252,
- 164,243,239,236,225,244,229,228,225,242,225,226,233, 99,128,252,
- 14,238,239,239,238,230,233,238,225,236,225,242,225,226,233, 99,
- 128,252,115,235,225,244,225,235,225,238, 97,129, 48,198,182, 32,
- 232,225,236,230,247,233,228,244,104,128,255,131,108, 2,182, 50,
- 182, 69,229,240,232,239,238,101,129, 33, 33,182, 61,226,236,225,
- 227,107,128, 38, 14,233,243,232, 97, 2,182, 78,182, 93,231,229,
- 228,239,236,225,232,229,226,242,229,119,128, 5,160,241,229,244,
- 225,238,225,232,229,226,242,229,119,128, 5,169,110, 4,182,118,
- 182,127,182,146,182,167,227,233,242,227,236,101,128, 36,105,233,
- 228,229,239,231,242,225,240,232,233,227,240,225,242,229,110,128,
- 50, 41,112, 2,182,152,182,159,225,242,229,110,128, 36,125,229,
- 242,233,239,100,128, 36,145,242,239,237,225,110,128, 33,121,243,
- 104,128, 2,167,116,131, 5,216,182,190,182,210,182,219,228,225,
- 231,229,243,104,129,251, 56,182,201,232,229,226,242,229,119,128,
- 251, 56,232,229,226,242,229,119,128, 5,216,243,229,227,249,242,
- 233,236,236,233, 99,128, 4,181,246,233,114, 2,182,240,182,249,
- 232,229,226,242,229,119,128, 5,155,236,229,230,244,232,229,226,
- 242,229,119,128, 5,155,104, 6,183, 20,183,172,184, 38,184,170,
- 185, 77,186,134, 97, 5,183, 32,183, 42,183, 49,183, 74,183,103,
- 226,229,238,231,225,236,105,128, 9,165,228,229,246, 97,128, 9,
- 37,231,117, 2,183, 56,183, 65,234,225,242,225,244,105,128, 10,
- 165,242,237,245,235,232,105,128, 10, 37,108, 2,183, 80,183, 89,
- 225,242,225,226,233, 99,128, 6, 48,230,233,238,225,236,225,242,
- 225,226,233, 99,128,254,172,238,244,232,225,235,232,225,116, 3,
- 183,118,183,149,183,156,236,239,119, 2,183,126,183,137,236,229,
- 230,244,244,232,225,105,128,248,152,242,233,231,232,244,244,232,
- 225,105,128,248,151,244,232,225,105,128, 14, 76,245,240,240,229,
- 242,236,229,230,244,244,232,225,105,128,248,150,101, 3,183,180,
- 183,244,184, 11,104, 4,183,190,183,199,183,213,183,229,225,242,
- 225,226,233, 99,128, 6, 43,230,233,238,225,236,225,242,225,226,
- 233, 99,128,254,154,233,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,254,155,237,229,228,233,225,236,225,242,225,226,233,
- 99,128,254,156,242,101, 2,183,251,184, 4,229,248,233,243,244,
- 115,128, 34, 3,230,239,242,101,128, 34, 52,244, 97,130, 3,184,
- 184, 20,184, 24, 49,128, 3,209,243,249,237,226,239,236,231,242,
- 229,229,107,128, 3,209,105, 2,184, 44,184,130,229,245,244,104,
- 4,184, 57,184, 92,184,107,184,116, 97, 2,184, 63,184, 78,227,
- 233,242,227,236,229,235,239,242,229,225,110,128, 50,121,240,225,
- 242,229,238,235,239,242,229,225,110,128, 50, 25,227,233,242,227,
- 236,229,235,239,242,229,225,110,128, 50,107,235,239,242,229,225,
- 110,128, 49, 76,240,225,242,229,238,235,239,242,229,225,110,128,
- 50, 11,242,244,229,229,110, 2,184,140,184,149,227,233,242,227,
- 236,101,128, 36,108,112, 2,184,155,184,162,225,242,229,110,128,
- 36,128,229,242,233,239,100,128, 36,148,111, 6,184,184,184,201,
- 184,206,184,220,184,225,185, 22,238,225,238,231,237,239,238,244,
- 232,239,244,232,225,105,128, 14, 17,239,107,128, 1,173,240,232,
- 245,244,232,225,239,244,232,225,105,128, 14, 18,242,110,128, 0,
- 254,244,104, 3,184,234,185, 2,185, 12, 97, 2,184,240,184,250,
- 232,225,238,244,232,225,105,128, 14, 23,238,244,232,225,105,128,
- 14, 16,239,238,231,244,232,225,105,128, 14, 24,245,238,231,244,
- 232,225,105,128, 14, 22,245,243,225,238,100, 2,185, 32,185, 43,
- 227,249,242,233,236,236,233, 99,128, 4,130,243,243,229,240,225,
- 242,225,244,239,114, 2,185, 58,185, 67,225,242,225,226,233, 99,
- 128, 6,108,240,229,242,243,233,225,110,128, 6,108,242,229,101,
- 144, 0, 51,185,115,185,124,185,134,185,164,185,171,185,181,185,
- 206,185,233,186, 11,186, 23,186, 42,186, 53,186, 86,186,108,186,
- 116,186,127,225,242,225,226,233, 99,128, 6, 99,226,229,238,231,
- 225,236,105,128, 9,233,227,233,242,227,236,101,129, 36, 98,185,
- 145,233,238,246,229,242,243,229,243,225,238,243,243,229,242,233,
- 102,128, 39,140,228,229,246, 97,128, 9,105,229,233,231,232,244,
- 232,115,128, 33, 92,231,117, 2,185,188,185,197,234,225,242,225,
- 244,105,128, 10,233,242,237,245,235,232,105,128, 10,105,232, 97,
- 2,185,213,185,224,227,235,225,242,225,226,233, 99,128, 6, 99,
- 238,231,250,232,239,117,128, 48, 35,105, 2,185,239,186, 1,228,
- 229,239,231,242,225,240,232,233,227,240,225,242,229,110,128, 50,
- 34,238,230,229,242,233,239,114,128, 32,131,237,239,238,239,243,
- 240,225,227,101,128,255, 19,238,245,237,229,242,225,244,239,242,
- 226,229,238,231,225,236,105,128, 9,246,239,236,228,243,244,249,
- 236,101,128,247, 51,112, 2,186, 59,186, 66,225,242,229,110,128,
- 36,118,229,114, 2,186, 73,186, 79,233,239,100,128, 36,138,243,
- 233,225,110,128, 6,243,241,245,225,242,244,229,242,115,129, 0,
- 190,186, 99,229,237,228,225,243,104,128,246,222,242,239,237,225,
- 110,128, 33,114,243,245,240,229,242,233,239,114,128, 0,179,244,
- 232,225,105,128, 14, 83,250,243,241,245,225,242,101,128, 51,148,
- 105, 7,186,160,186,171,187, 30,187,128,187,140,187,189,187,206,
- 232,233,242,225,231,225,238, 97,128, 48, 97,107, 2,186,177,186,
- 201,225,244,225,235,225,238, 97,129, 48,193,186,189,232,225,236,
- 230,247,233,228,244,104,128,255,129,229,245,116, 4,186,213,186,
- 248,187, 7,187, 16, 97, 2,186,219,186,234,227,233,242,227,236,
- 229,235,239,242,229,225,110,128, 50,112,240,225,242,229,238,235,
- 239,242,229,225,110,128, 50, 16,227,233,242,227,236,229,235,239,
- 242,229,225,110,128, 50, 98,235,239,242,229,225,110,128, 49, 55,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 2,236,228,
- 101,133, 2,220,187, 46,187, 57,187, 74,187, 86,187,114,226,229,
- 236,239,247,227,237, 98,128, 3, 48, 99, 2,187, 63,187, 68,237,
- 98,128, 3, 3,239,237, 98,128, 3, 3,228,239,245,226,236,229,
- 227,237, 98,128, 3, 96,111, 2,187, 92,187,102,240,229,242,225,
- 244,239,114,128, 34, 60,246,229,242,236,225,249,227,237, 98,128,
- 3, 52,246,229,242,244,233,227,225,236,227,237, 98,128, 3, 62,
- 237,229,243,227,233,242,227,236,101,128, 34,151,112, 2,187,146,
- 187,176,229,232, 97, 2,187,154,187,163,232,229,226,242,229,119,
- 128, 5,150,236,229,230,244,232,229,226,242,229,119,128, 5,150,
- 240,233,231,245,242,237,245,235,232,105,128, 10,112,244,236,239,
- 227,249,242,233,236,236,233,227,227,237, 98,128, 4,131,247,238,
- 225,242,237,229,238,233,225,110,128, 5,127,236,233,238,229,226,
- 229,236,239,119,128, 30,111,237,239,238,239,243,240,225,227,101,
- 128,255, 84,111, 7,188, 3,188, 14,188, 25,188, 50,188,170,188,
- 182,189, 10,225,242,237,229,238,233,225,110,128, 5,105,232,233,
- 242,225,231,225,238, 97,128, 48,104,235,225,244,225,235,225,238,
- 97,129, 48,200,188, 38,232,225,236,230,247,233,228,244,104,128,
- 255,132,110, 3,188, 58,188,156,188,161,101, 4,188, 68,188,137,
- 188,144,188,150,226,225,114, 4,188, 80,188,109,188,119,188,128,
- 229,248,244,242, 97, 2,188, 90,188,100,232,233,231,232,237,239,
- 100,128, 2,229,236,239,247,237,239,100,128, 2,233,232,233,231,
- 232,237,239,100,128, 2,230,236,239,247,237,239,100,128, 2,232,
- 237,233,228,237,239,100,128, 2,231,230,233,246,101,128, 1,189,
- 243,233,120,128, 1,133,244,247,111,128, 1,168,239,115,128, 3,
- 132,243,241,245,225,242,101,128, 51, 39,240,225,244,225,235,244,
- 232,225,105,128, 14, 15,242,244,239,233,243,229,243,232,229,236,
- 236,226,242,225,227,235,229,116, 2,188,205,188,235,236,229,230,
- 116,130, 48, 20,188,216,188,224,243,237,225,236,108,128,254, 93,
- 246,229,242,244,233,227,225,108,128,254, 57,242,233,231,232,116,
- 130, 48, 21,188,247,188,255,243,237,225,236,108,128,254, 94,246,
- 229,242,244,233,227,225,108,128,254, 58,244,225,239,244,232,225,
- 105,128, 14, 21,240, 97, 2,189, 27,189, 39,236,225,244,225,236,
- 232,239,239,107,128, 1,171,242,229,110,128, 36,175,114, 3,189,
- 53,189, 84,189, 99,225,228,229,237,225,242,107,129, 33, 34,189,
- 65,115, 2,189, 71,189, 77,225,238,115,128,248,234,229,242,233,
- 102,128,246,219,229,244,242,239,230,236,229,248,232,239,239,107,
- 128, 2,136,233,225,103, 4,189,111,189,116,189,121,189,126,228,
- 110,128, 37,188,236,102,128, 37,196,242,116,128, 37,186,245,112,
- 128, 37,178,115,132, 2,166,189,143,189,182,190, 32,190, 45,225,
- 228,105,130, 5,230,189,153,189,173,228,225,231,229,243,104,129,
- 251, 70,189,164,232,229,226,242,229,119,128,251, 70,232,229,226,
- 242,229,119,128, 5,230,101, 2,189,188,189,199,227,249,242,233,
- 236,236,233, 99,128, 4, 70,242,101,134, 5,181,189,216,189,230,
- 189,235,189,244,190, 3,190, 19, 49, 2,189,222,189,226, 50,128,
- 5,181,101,128, 5,181,178, 98,128, 5,181,232,229,226,242,229,
- 119,128, 5,181,238,225,242,242,239,247,232,229,226,242,229,119,
- 128, 5,181,241,245,225,242,244,229,242,232,229,226,242,229,119,
- 128, 5,181,247,233,228,229,232,229,226,242,229,119,128, 5,181,
- 232,229,227,249,242,233,236,236,233, 99,128, 4, 91,245,240,229,
- 242,233,239,114,128,246,243,116, 4,190, 65,190,115,190,180,190,
- 231, 97, 3,190, 73,190, 83,190, 90,226,229,238,231,225,236,105,
- 128, 9,159,228,229,246, 97,128, 9, 31,231,117, 2,190, 97,190,
- 106,234,225,242,225,244,105,128, 10,159,242,237,245,235,232,105,
- 128, 10, 31,229,104, 4,190,126,190,135,190,149,190,165,225,242,
- 225,226,233, 99,128, 6,121,230,233,238,225,236,225,242,225,226,
- 233, 99,128,251,103,233,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,251,104,237,229,228,233,225,236,225,242,225,226,233,
- 99,128,251,105,232, 97, 3,190,189,190,199,190,206,226,229,238,
- 231,225,236,105,128, 9,160,228,229,246, 97,128, 9, 32,231,117,
- 2,190,213,190,222,234,225,242,225,244,105,128, 10,160,242,237,
- 245,235,232,105,128, 10, 32,245,242,238,229,100,128, 2,135,117,
- 3,190,247,191, 2,191, 27,232,233,242,225,231,225,238, 97,128,
- 48,100,235,225,244,225,235,225,238, 97,129, 48,196,191, 15,232,
- 225,236,230,247,233,228,244,104,128,255,130,243,237,225,236,108,
- 2,191, 37,191, 48,232,233,242,225,231,225,238, 97,128, 48, 99,
- 235,225,244,225,235,225,238, 97,129, 48,195,191, 61,232,225,236,
- 230,247,233,228,244,104,128,255,111,119, 2,191, 79,191,184,101,
- 2,191, 85,191,133,236,246,101, 3,191, 95,191,104,191,125,227,
- 233,242,227,236,101,128, 36,107,112, 2,191,110,191,117,225,242,
- 229,110,128, 36,127,229,242,233,239,100,128, 36,147,242,239,237,
- 225,110,128, 33,123,238,244,121, 3,191,143,191,152,191,163,227,
- 233,242,227,236,101,128, 36,115,232,225,238,231,250,232,239,117,
- 128, 83, 68,112, 2,191,169,191,176,225,242,229,110,128, 36,135,
- 229,242,233,239,100,128, 36,155,111,142, 0, 50,191,216,191,225,
- 191,235,192, 9,192, 61,192, 86,192,113,192,147,192,159,192,178,
- 192,189,192,222,192,230,192,254,225,242,225,226,233, 99,128, 6,
- 98,226,229,238,231,225,236,105,128, 9,232,227,233,242,227,236,
- 101,129, 36, 97,191,246,233,238,246,229,242,243,229,243,225,238,
- 243,243,229,242,233,102,128, 39,139,100, 2,192, 15,192, 21,229,
- 246, 97,128, 9,104,239,116, 2,192, 28,192, 39,229,238,236,229,
- 225,228,229,114,128, 32, 37,236,229,225,228,229,114,129, 32, 37,
- 192, 50,246,229,242,244,233,227,225,108,128,254, 48,231,117, 2,
- 192, 68,192, 77,234,225,242,225,244,105,128, 10,232,242,237,245,
- 235,232,105,128, 10,104,232, 97, 2,192, 93,192,104,227,235,225,
- 242,225,226,233, 99,128, 6, 98,238,231,250,232,239,117,128, 48,
- 34,105, 2,192,119,192,137,228,229,239,231,242,225,240,232,233,
- 227,240,225,242,229,110,128, 50, 33,238,230,229,242,233,239,114,
- 128, 32,130,237,239,238,239,243,240,225,227,101,128,255, 18,238,
- 245,237,229,242,225,244,239,242,226,229,238,231,225,236,105,128,
- 9,245,239,236,228,243,244,249,236,101,128,247, 50,112, 2,192,
- 195,192,202,225,242,229,110,128, 36,117,229,114, 2,192,209,192,
- 215,233,239,100,128, 36,137,243,233,225,110,128, 6,242,242,239,
- 237,225,110,128, 33,113,115, 2,192,236,192,244,244,242,239,235,
- 101,128, 1,187,245,240,229,242,233,239,114,128, 0,178,244,104,
- 2,193, 5,193, 10,225,105,128, 14, 82,233,242,228,115,128, 33,
- 84,117,145, 0,117,193, 55,193, 63,193,104,193,161,194, 43,194,
- 80,194,203,194,219,195, 14,195, 84,195,165,195,174,196, 37,196,
- 61,196,169,196,197,197, 55,225,227,245,244,101,128, 0,250, 98,
- 4,193, 73,193, 78,193, 87,193, 97,225,114,128, 2,137,229,238,
- 231,225,236,105,128, 9,137,239,240,239,237,239,230,111,128, 49,
- 40,242,229,246,101,128, 1,109, 99, 3,193,112,193,119,193,151,
- 225,242,239,110,128, 1,212,233,242, 99, 2,193,127,193,132,236,
- 101,128, 36,228,245,237,230,236,229,120,129, 0,251,193,143,226,
- 229,236,239,119,128, 30,119,249,242,233,236,236,233, 99,128, 4,
- 67,100, 5,193,173,193,184,193,207,193,213,194, 33,225,244,244,
- 225,228,229,246, 97,128, 9, 81,226,108, 2,193,191,193,199,225,
- 227,245,244,101,128, 1,113,231,242,225,246,101,128, 2, 21,229,
- 246, 97,128, 9, 9,233,229,242,229,243,233,115,133, 0,252,193,
- 233,193,241,193,249,194, 16,194, 24,225,227,245,244,101,128, 1,
- 216,226,229,236,239,119,128, 30,115, 99, 2,193,255,194, 6,225,
- 242,239,110,128, 1,218,249,242,233,236,236,233, 99,128, 4,241,
- 231,242,225,246,101,128, 1,220,237,225,227,242,239,110,128, 1,
- 214,239,244,226,229,236,239,119,128, 30,229,103, 2,194, 49,194,
- 56,242,225,246,101,128, 0,249,117, 2,194, 62,194, 71,234,225,
- 242,225,244,105,128, 10,137,242,237,245,235,232,105,128, 10, 9,
- 104, 3,194, 88,194, 98,194,176,233,242,225,231,225,238, 97,128,
- 48, 70,111, 2,194,104,194,114,239,235,225,226,239,246,101,128,
- 30,231,242,110,133, 1,176,194,129,194,137,194,148,194,156,194,
- 168,225,227,245,244,101,128, 30,233,228,239,244,226,229,236,239,
- 119,128, 30,241,231,242,225,246,101,128, 30,235,232,239,239,235,
- 225,226,239,246,101,128, 30,237,244,233,236,228,101,128, 30,239,
- 245,238,231,225,242,245,237,236,225,245,116,129, 1,113,194,192,
- 227,249,242,233,236,236,233, 99,128, 4,243,233,238,246,229,242,
- 244,229,228,226,242,229,246,101,128, 2, 23,107, 3,194,227,194,
- 251,195, 6,225,244,225,235,225,238, 97,129, 48,166,194,239,232,
- 225,236,230,247,233,228,244,104,128,255,115,227,249,242,233,236,
- 236,233, 99,128, 4,121,239,242,229,225,110,128, 49, 92,109, 2,
- 195, 20,195, 73, 97, 2,195, 26,195, 59,227,242,239,110,130, 1,
- 107,195, 37,195, 48,227,249,242,233,236,236,233, 99,128, 4,239,
- 228,233,229,242,229,243,233,115,128, 30,123,244,242,225,231,245,
- 242,237,245,235,232,105,128, 10, 65,239,238,239,243,240,225,227,
- 101,128,255, 85,110, 2,195, 90,195,145,228,229,242,243,227,239,
- 242,101,132, 0, 95,195,109,195,115,195,127,195,138,228,226,108,
- 128, 32, 23,237,239,238,239,243,240,225,227,101,128,255, 63,246,
- 229,242,244,233,227,225,108,128,254, 51,247,225,246,121,128,254,
- 79,105, 2,195,151,195,156,239,110,128, 34, 42,246,229,242,243,
- 225,108,128, 34, 0,239,231,239,238,229,107,128, 1,115,112, 5,
- 195,186,195,193,195,201,195,216,196, 11,225,242,229,110,128, 36,
- 176,226,236,239,227,107,128, 37,128,240,229,242,228,239,244,232,
- 229,226,242,229,119,128, 5,196,243,233,236,239,110,131, 3,197,
- 195,230,195,251,196, 3,228,233,229,242,229,243,233,115,129, 3,
- 203,195,243,244,239,238,239,115,128, 3,176,236,225,244,233,110,
- 128, 2,138,244,239,238,239,115,128, 3,205,244,225,227,107, 2,
- 196, 20,196, 31,226,229,236,239,247,227,237, 98,128, 3, 29,237,
- 239,100,128, 2,212,114, 2,196, 43,196, 55,225,231,245,242,237,
- 245,235,232,105,128, 10,115,233,238,103,128, 1,111,115, 3,196,
- 69,196, 84,196,129,232,239,242,244,227,249,242,233,236,236,233,
- 99,128, 4, 94,237,225,236,108, 2,196, 93,196,104,232,233,242,
- 225,231,225,238, 97,128, 48, 69,235,225,244,225,235,225,238, 97,
- 129, 48,165,196,117,232,225,236,230,247,233,228,244,104,128,255,
- 105,244,242,225,233,231,232,116, 2,196,141,196,152,227,249,242,
- 233,236,236,233, 99,128, 4,175,243,244,242,239,235,229,227,249,
- 242,233,236,236,233, 99,128, 4,177,244,233,236,228,101,130, 1,
- 105,196,181,196,189,225,227,245,244,101,128, 30,121,226,229,236,
- 239,119,128, 30,117,117, 5,196,209,196,219,196,226,196,251,197,
- 11,226,229,238,231,225,236,105,128, 9,138,228,229,246, 97,128,
- 9, 10,231,117, 2,196,233,196,242,234,225,242,225,244,105,128,
- 10,138,242,237,245,235,232,105,128, 10, 10,237,225,244,242,225,
- 231,245,242,237,245,235,232,105,128, 10, 66,246,239,247,229,236,
- 243,233,231,110, 3,197, 27,197, 37,197, 44,226,229,238,231,225,
- 236,105,128, 9,194,228,229,246, 97,128, 9, 66,231,245,234,225,
- 242,225,244,105,128, 10,194,246,239,247,229,236,243,233,231,110,
- 3,197, 71,197, 81,197, 88,226,229,238,231,225,236,105,128, 9,
- 193,228,229,246, 97,128, 9, 65,231,245,234,225,242,225,244,105,
- 128, 10,193,118,139, 0,118,197,125,198, 17,198, 26,198, 37,198,
- 222,198,229,199, 71,199, 83,199,183,199,191,199,212, 97, 4,197,
- 135,197,142,197,167,197,178,228,229,246, 97,128, 9, 53,231,117,
- 2,197,149,197,158,234,225,242,225,244,105,128, 10,181,242,237,
- 245,235,232,105,128, 10, 53,235,225,244,225,235,225,238, 97,128,
- 48,247,118,132, 5,213,197,190,197,217,197,249,198, 5,228,225,
- 231,229,243,104,130,251, 53,197,203,197,208,182, 53,128,251, 53,
- 232,229,226,242,229,119,128,251, 53,104, 2,197,223,197,231,229,
- 226,242,229,119,128, 5,213,239,236,225,109,129,251, 75,197,240,
- 232,229,226,242,229,119,128,251, 75,246,225,246,232,229,226,242,
- 229,119,128, 5,240,249,239,228,232,229,226,242,229,119,128, 5,
- 241,227,233,242,227,236,101,128, 36,229,228,239,244,226,229,236,
- 239,119,128, 30,127,101, 6,198, 51,198, 62,198,126,198,137,198,
- 143,198,210,227,249,242,233,236,236,233, 99,128, 4, 50,104, 4,
- 198, 72,198, 81,198, 95,198,111,225,242,225,226,233, 99,128, 6,
- 164,230,233,238,225,236,225,242,225,226,233, 99,128,251,107,233,
- 238,233,244,233,225,236,225,242,225,226,233, 99,128,251,108,237,
- 229,228,233,225,236,225,242,225,226,233, 99,128,251,109,235,225,
- 244,225,235,225,238, 97,128, 48,249,238,245,115,128, 38, 64,242,
- 244,233,227,225,108, 2,198,154,198,160,226,225,114,128, 0,124,
- 236,233,238,101, 4,198,173,198,184,198,195,198,204,225,226,239,
- 246,229,227,237, 98,128, 3, 13,226,229,236,239,247,227,237, 98,
- 128, 3, 41,236,239,247,237,239,100,128, 2,204,237,239,100,128,
- 2,200,247,225,242,237,229,238,233,225,110,128, 5,126,232,239,
- 239,107,128, 2,139,105, 3,198,237,198,248,199, 31,235,225,244,
- 225,235,225,238, 97,128, 48,248,242,225,237, 97, 3,199, 3,199,
- 13,199, 20,226,229,238,231,225,236,105,128, 9,205,228,229,246,
- 97,128, 9, 77,231,245,234,225,242,225,244,105,128, 10,205,243,
- 225,242,231, 97, 3,199, 43,199, 53,199, 60,226,229,238,231,225,
- 236,105,128, 9,131,228,229,246, 97,128, 9, 3,231,245,234,225,
- 242,225,244,105,128, 10,131,237,239,238,239,243,240,225,227,101,
- 128,255, 86,111, 3,199, 91,199,102,199,172,225,242,237,229,238,
- 233,225,110,128, 5,120,233,227,229,100, 2,199,111,199,147,233,
- 244,229,242,225,244,233,239,110, 2,199,125,199,136,232,233,242,
- 225,231,225,238, 97,128, 48,158,235,225,244,225,235,225,238, 97,
- 128, 48,254,237,225,242,235,235,225,238, 97,129, 48,155,199,160,
- 232,225,236,230,247,233,228,244,104,128,255,158,235,225,244,225,
- 235,225,238, 97,128, 48,250,240,225,242,229,110,128, 36,177,116,
- 2,199,197,199,204,233,236,228,101,128, 30,125,245,242,238,229,
- 100,128, 2,140,117, 2,199,218,199,229,232,233,242,225,231,225,
- 238, 97,128, 48,148,235,225,244,225,235,225,238, 97,128, 48,244,
- 119,143, 0,119,200, 18,200,251,201, 5,201, 28,201, 68,201,135,
- 201,143,203,114,203,155,203,167,203,242,203,250,204, 1,204, 12,
- 204, 21, 97, 8,200, 36,200, 43,200, 53,200, 64,200,102,200,134,
- 200,146,200,182,227,245,244,101,128, 30,131,229,235,239,242,229,
- 225,110,128, 49, 89,232,233,242,225,231,225,238, 97,128, 48,143,
- 107, 2,200, 70,200, 94,225,244,225,235,225,238, 97,129, 48,239,
- 200, 82,232,225,236,230,247,233,228,244,104,128,255,156,239,242,
- 229,225,110,128, 49, 88,243,237,225,236,108, 2,200,112,200,123,
- 232,233,242,225,231,225,238, 97,128, 48,142,235,225,244,225,235,
- 225,238, 97,128, 48,238,244,244,239,243,241,245,225,242,101,128,
- 51, 87,118, 2,200,152,200,160,229,228,225,243,104,128, 48, 28,
- 249,245,238,228,229,242,243,227,239,242,229,246,229,242,244,233,
- 227,225,108,128,254, 52,119, 3,200,190,200,199,200,213,225,242,
- 225,226,233, 99,128, 6, 72,230,233,238,225,236,225,242,225,226,
- 233, 99,128,254,238,232,225,237,250,225,225,226,239,246,101, 2,
- 200,228,200,237,225,242,225,226,233, 99,128, 6, 36,230,233,238,
- 225,236,225,242,225,226,233, 99,128,254,134,226,243,241,245,225,
- 242,101,128, 51,221,227,233,242, 99, 2,201, 14,201, 19,236,101,
- 128, 36,230,245,237,230,236,229,120,128, 1,117,100, 2,201, 34,
- 201, 44,233,229,242,229,243,233,115,128, 30,133,239,116, 2,201,
- 51,201, 60,225,227,227,229,238,116,128, 30,135,226,229,236,239,
- 119,128, 30,137,101, 4,201, 78,201, 89,201,101,201,125,232,233,
- 242,225,231,225,238, 97,128, 48,145,233,229,242,243,244,242,225,
- 243,115,128, 33, 24,107, 2,201,107,201,117,225,244,225,235,225,
- 238, 97,128, 48,241,239,242,229,225,110,128, 49, 94,239,235,239,
- 242,229,225,110,128, 49, 93,231,242,225,246,101,128, 30,129,232,
- 233,244,101, 8,201,164,201,173,202, 1,202, 91,202,175,202,220,
- 203, 16,203, 72,226,245,236,236,229,116,128, 37,230, 99, 2,201,
- 179,201,199,233,242,227,236,101,129, 37,203,201,189,233,238,246,
- 229,242,243,101,128, 37,217,239,242,238,229,242,226,242,225,227,
- 235,229,116, 2,201,216,201,236,236,229,230,116,129, 48, 14,201,
- 225,246,229,242,244,233,227,225,108,128,254, 67,242,233,231,232,
- 116,129, 48, 15,201,246,246,229,242,244,233,227,225,108,128,254,
- 68,100, 2,202, 7,202, 48,233,225,237,239,238,100,129, 37,199,
- 202, 18,227,239,238,244,225,233,238,233,238,231,226,236,225,227,
- 235,243,237,225,236,236,228,233,225,237,239,238,100,128, 37,200,
- 239,247,238,240,239,233,238,244,233,238,103, 2,202, 64,202, 80,
- 243,237,225,236,236,244,242,233,225,238,231,236,101,128, 37,191,
- 244,242,233,225,238,231,236,101,128, 37,189,236,101, 2,202, 98,
- 202,140,230,244,240,239,233,238,244,233,238,103, 2,202,113,202,
- 129,243,237,225,236,236,244,242,233,225,238,231,236,101,128, 37,
- 195,244,242,233,225,238,231,236,101,128, 37,193,238,244,233,227,
- 245,236,225,242,226,242,225,227,235,229,116, 2,202,160,202,167,
- 236,229,230,116,128, 48, 22,242,233,231,232,116,128, 48, 23,242,
- 233,231,232,244,240,239,233,238,244,233,238,103, 2,202,193,202,
- 209,243,237,225,236,236,244,242,233,225,238,231,236,101,128, 37,
- 185,244,242,233,225,238,231,236,101,128, 37,183,115, 3,202,228,
- 203, 2,203, 10,109, 2,202,234,202,246,225,236,236,243,241,245,
- 225,242,101,128, 37,171,233,236,233,238,231,230,225,227,101,128,
- 38, 58,241,245,225,242,101,128, 37,161,244,225,114,128, 38, 6,
- 116, 2,203, 22,203, 33,229,236,229,240,232,239,238,101,128, 38,
- 15,239,242,244,239,233,243,229,243,232,229,236,236,226,242,225,
- 227,235,229,116, 2,203, 57,203, 64,236,229,230,116,128, 48, 24,
- 242,233,231,232,116,128, 48, 25,245,240,240,239,233,238,244,233,
- 238,103, 2,203, 87,203,103,243,237,225,236,236,244,242,233,225,
- 238,231,236,101,128, 37,181,244,242,233,225,238,231,236,101,128,
- 37,179,105, 2,203,120,203,131,232,233,242,225,231,225,238, 97,
- 128, 48,144,107, 2,203,137,203,147,225,244,225,235,225,238, 97,
- 128, 48,240,239,242,229,225,110,128, 49, 95,237,239,238,239,243,
- 240,225,227,101,128,255, 87,111, 4,203,177,203,188,203,213,203,
- 231,232,233,242,225,231,225,238, 97,128, 48,146,235,225,244,225,
- 235,225,238, 97,129, 48,242,203,201,232,225,236,230,247,233,228,
- 244,104,128,255,102,110,129, 32,169,203,219,237,239,238,239,243,
- 240,225,227,101,128,255,230,247,225,229,238,244,232,225,105,128,
- 14, 39,240,225,242,229,110,128, 36,178,242,233,238,103,128, 30,
- 152,243,245,240,229,242,233,239,114,128, 2,183,244,245,242,238,
- 229,100,128, 2,141,249,238,110,128, 1,191,120,137, 0,120,204,
- 49,204, 60,204, 71,204, 80,204,107,204,120,204,124,204,136,204,
- 144,225,226,239,246,229,227,237, 98,128, 3, 61,226,239,240,239,
- 237,239,230,111,128, 49, 18,227,233,242,227,236,101,128, 36,231,
- 100, 2,204, 86,204, 96,233,229,242,229,243,233,115,128, 30,141,
- 239,244,225,227,227,229,238,116,128, 30,139,229,232,225,242,237,
- 229,238,233,225,110,128, 5,109,105,128, 3,190,237,239,238,239,
- 243,240,225,227,101,128,255, 88,240,225,242,229,110,128, 36,179,
- 243,245,240,229,242,233,239,114,128, 2,227,121,143, 0,121,204,
- 189,205,148,205,171,205,211,207,177,207,185,207,202,208, 10,208,
- 22,209, 19,209, 59,209, 71,209, 82,209,103,210, 76, 97, 11,204,
- 213,204,225,204,235,204,242,204,249,205, 3,205, 28,205, 39,205,
- 77,205, 90,205,136,225,228,239,243,241,245,225,242,101,128, 51,
- 78,226,229,238,231,225,236,105,128, 9,175,227,245,244,101,128,
- 0,253,228,229,246, 97,128, 9, 47,229,235,239,242,229,225,110,
- 128, 49, 82,231,117, 2,205, 10,205, 19,234,225,242,225,244,105,
- 128, 10,175,242,237,245,235,232,105,128, 10, 47,232,233,242,225,
- 231,225,238, 97,128, 48,132,107, 2,205, 45,205, 69,225,244,225,
- 235,225,238, 97,129, 48,228,205, 57,232,225,236,230,247,233,228,
- 244,104,128,255,148,239,242,229,225,110,128, 49, 81,237,225,235,
- 235,225,238,244,232,225,105,128, 14, 78,243,237,225,236,108, 2,
- 205,100,205,111,232,233,242,225,231,225,238, 97,128, 48,131,235,
- 225,244,225,235,225,238, 97,129, 48,227,205,124,232,225,236,230,
- 247,233,228,244,104,128,255,108,244,227,249,242,233,236,236,233,
- 99,128, 4, 99,227,233,242, 99, 2,205,157,205,162,236,101,128,
- 36,232,245,237,230,236,229,120,128, 1,119,100, 2,205,177,205,
- 187,233,229,242,229,243,233,115,128, 0,255,239,116, 2,205,194,
- 205,203,225,227,227,229,238,116,128, 30,143,226,229,236,239,119,
- 128, 30,245,101, 7,205,227,206,235,206,244,207, 6,207, 38,207,
- 114,207,165,104, 8,205,245,205,254,206, 32,206, 46,206,119,206,
- 135,206,194,206,212,225,242,225,226,233, 99,128, 6, 74,226,225,
- 242,242,229,101, 2,206, 9,206, 18,225,242,225,226,233, 99,128,
- 6,210,230,233,238,225,236,225,242,225,226,233, 99,128,251,175,
- 230,233,238,225,236,225,242,225,226,233, 99,128,254,242,232,225,
- 237,250,225,225,226,239,246,101, 4,206, 65,206, 74,206, 88,206,
- 104,225,242,225,226,233, 99,128, 6, 38,230,233,238,225,236,225,
- 242,225,226,233, 99,128,254,138,233,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,254,139,237,229,228,233,225,236,225,242,
- 225,226,233, 99,128,254,140,233,238,233,244,233,225,236,225,242,
- 225,226,233, 99,128,254,243,237,101, 2,206,142,206,155,228,233,
- 225,236,225,242,225,226,233, 99,128,254,244,229,237,105, 2,206,
- 163,206,178,238,233,244,233,225,236,225,242,225,226,233, 99,128,
- 252,221,243,239,236,225,244,229,228,225,242,225,226,233, 99,128,
- 252, 88,238,239,239,238,230,233,238,225,236,225,242,225,226,233,
- 99,128,252,148,244,232,242,229,229,228,239,244,243,226,229,236,
- 239,247,225,242,225,226,233, 99,128, 6,209,235,239,242,229,225,
- 110,128, 49, 86,110,129, 0,165,206,250,237,239,238,239,243,240,
- 225,227,101,128,255,229,111, 2,207, 12,207, 21,235,239,242,229,
- 225,110,128, 49, 85,242,233,238,232,233,229,245,232,235,239,242,
- 229,225,110,128, 49,134,114, 3,207, 46,207, 82,207, 94,225,232,
- 226,229,238,249,239,237,111, 2,207, 60,207, 69,232,229,226,242,
- 229,119,128, 5,170,236,229,230,244,232,229,226,242,229,119,128,
- 5,170,233,227,249,242,233,236,236,233, 99,128, 4, 75,245,228,
+ 141,228,229,246, 97,128, 9,106,231,117, 2, 92, 47, 92, 56,234,
+ 225,242,225,244,105,128, 10,234,242,237,245,235,232,105,128, 10,
+ 106,232, 97, 2, 92, 72, 92, 83,227,235,225,242,225,226,233, 99,
+ 128, 6,100,238,231,250,232,239,117,128, 48, 36,105, 2, 92, 98,
+ 92,116,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
+ 110,128, 50, 35,238,230,229,242,233,239,114,128, 32,132,237,239,
+ 238,239,243,240,225,227,101,128,255, 20,238,245,237,229,242,225,
+ 244,239,242,226,229,238,231,225,236,105,128, 9,247,239,236,228,
+ 243,244,249,236,101,128,247, 52,112, 2, 92,174, 92,181,225,242,
+ 229,110,128, 36,119,229,114, 2, 92,188, 92,194,233,239,100,128,
+ 36,139,243,233,225,110,128, 6,244,242,239,237,225,110,128, 33,
+ 115,243,245,240,229,242,233,239,114,128, 32,116,116, 2, 92,226,
+ 93, 8,229,229,110, 2, 92,234, 92,243,227,233,242,227,236,101,
+ 128, 36,109,112, 2, 92,249, 93, 0,225,242,229,110,128, 36,129,
+ 229,242,233,239,100,128, 36,149,104, 2, 93, 14, 93, 19,225,105,
+ 128, 14, 84,244,239,238,229,227,232,233,238,229,243,101,128, 2,
+ 203,240,225,242,229,110,128, 36,161,242, 97, 2, 93, 48, 93, 56,
+ 227,244,233,239,110,128, 32, 68,238, 99,128, 32,163,103,144, 0,
+ 103, 93, 97, 94, 43, 94, 66, 94,127, 94,144, 95, 65, 96, 58, 96,
+ 143, 96,156, 97, 14, 97, 39, 97, 67, 97, 89, 98, 34, 98, 56, 98,
+ 158, 97, 9, 93,117, 93,127, 93,134, 93,141, 93,205, 93,230, 93,
+ 241, 93,252, 94, 30,226,229,238,231,225,236,105,128, 9,151,227,
+ 245,244,101,128, 1,245,228,229,246, 97,128, 9, 23,102, 4, 93,
+ 151, 93,160, 93,174, 93,190,225,242,225,226,233, 99,128, 6,175,
+ 230,233,238,225,236,225,242,225,226,233, 99,128,251,147,233,238,
+ 233,244,233,225,236,225,242,225,226,233, 99,128,251,148,237,229,
+ 228,233,225,236,225,242,225,226,233, 99,128,251,149,231,117, 2,
+ 93,212, 93,221,234,225,242,225,244,105,128, 10,151,242,237,245,
+ 235,232,105,128, 10, 23,232,233,242,225,231,225,238, 97,128, 48,
+ 76,235,225,244,225,235,225,238, 97,128, 48,172,237,237, 97,130,
+ 3,179, 94, 6, 94, 19,236,225,244,233,238,243,237,225,236,108,
+ 128, 2, 99,243,245,240,229,242,233,239,114,128, 2,224,238,231,
+ 233,225,227,239,240,244,233, 99,128, 3,235, 98, 2, 94, 49, 94,
+ 59,239,240,239,237,239,230,111,128, 49, 13,242,229,246,101,128,
+ 1, 31, 99, 4, 94, 76, 94, 83, 94, 92, 94,114,225,242,239,110,
+ 128, 1,231,229,228,233,236,236, 97,128, 1, 35,233,242, 99, 2,
+ 94,100, 94,105,236,101,128, 36,214,245,237,230,236,229,120,128,
+ 1, 29,239,237,237,225,225,227,227,229,238,116,128, 1, 35,228,
+ 239,116,129, 1, 33, 94,135,225,227,227,229,238,116,128, 1, 33,
+ 101, 6, 94,158, 94,169, 94,180, 94,191, 94,210, 95, 56,227,249,
+ 242,233,236,236,233, 99,128, 4, 51,232,233,242,225,231,225,238,
+ 97,128, 48, 82,235,225,244,225,235,225,238, 97,128, 48,178,239,
+ 237,229,244,242,233,227,225,236,236,249,229,241,245,225,108,128,
+ 34, 81,114, 3, 94,218, 95, 11, 95, 21,229,243,104, 3, 94,228,
+ 94,243, 94,252,225,227,227,229,238,244,232,229,226,242,229,119,
+ 128, 5,156,232,229,226,242,229,119,128, 5,243,237,245,241,228,
+ 225,237,232,229,226,242,229,119,128, 5,157,237,225,238,228,226,
+ 236,115,128, 0,223,243,232,225,249,233,109, 2, 95, 32, 95, 47,
+ 225,227,227,229,238,244,232,229,226,242,229,119,128, 5,158,232,
+ 229,226,242,229,119,128, 5,244,244,225,237,225,242,107,128, 48,
+ 19,104, 5, 95, 77, 95,210, 96, 17, 96, 42, 96, 48, 97, 4, 95,
+ 87, 95, 97, 95,120, 95,145,226,229,238,231,225,236,105,128, 9,
+ 152,100, 2, 95,103, 95,114,225,242,237,229,238,233,225,110,128,
+ 5,114,229,246, 97,128, 9, 24,231,117, 2, 95,127, 95,136,234,
+ 225,242,225,244,105,128, 10,152,242,237,245,235,232,105,128, 10,
+ 24,233,110, 4, 95,156, 95,165, 95,179, 95,195,225,242,225,226,
+ 233, 99,128, 6, 58,230,233,238,225,236,225,242,225,226,233, 99,
+ 128,254,206,233,238,233,244,233,225,236,225,242,225,226,233, 99,
+ 128,254,207,237,229,228,233,225,236,225,242,225,226,233, 99,128,
+ 254,208,101, 3, 95,218, 95,239, 96, 0,237,233,228,228,236,229,
+ 232,239,239,235,227,249,242,233,236,236,233, 99,128, 4,149,243,
+ 244,242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,147,
+ 245,240,244,245,242,238,227,249,242,233,236,236,233, 99,128, 4,
+ 145,232, 97, 2, 96, 24, 96, 31,228,229,246, 97,128, 9, 90,231,
+ 245,242,237,245,235,232,105,128, 10, 90,239,239,107,128, 2, 96,
+ 250,243,241,245,225,242,101,128, 51,147,105, 3, 96, 66, 96, 77,
+ 96, 88,232,233,242,225,231,225,238, 97,128, 48, 78,235,225,244,
+ 225,235,225,238, 97,128, 48,174,109, 2, 96, 94, 96,105,225,242,
+ 237,229,238,233,225,110,128, 5, 99,229,108,130, 5,210, 96,114,
+ 96,134,228,225,231,229,243,104,129,251, 50, 96,125,232,229,226,
+ 242,229,119,128,251, 50,232,229,226,242,229,119,128, 5,210,234,
+ 229,227,249,242,233,236,236,233, 99,128, 4, 83,236,239,244,244,
+ 225,108, 2, 96,167, 96,184,233,238,246,229,242,244,229,228,243,
+ 244,242,239,235,101,128, 1,190,243,244,239,112,132, 2,148, 96,
+ 199, 96,210, 96,216, 96,248,233,238,246,229,242,244,229,100,128,
+ 2,150,237,239,100,128, 2,192,242,229,246,229,242,243,229,100,
+ 130, 2,149, 96,231, 96,237,237,239,100,128, 2,193,243,245,240,
+ 229,242,233,239,114,128, 2,228,243,244,242,239,235,101,129, 2,
+ 161, 97, 3,242,229,246,229,242,243,229,100,128, 2,162,109, 2,
+ 97, 20, 97, 28,225,227,242,239,110,128, 30, 33,239,238,239,243,
+ 240,225,227,101,128,255, 71,111, 2, 97, 45, 97, 56,232,233,242,
+ 225,231,225,238, 97,128, 48, 84,235,225,244,225,235,225,238, 97,
+ 128, 48,180,240, 97, 2, 97, 74, 97, 80,242,229,110,128, 36,162,
+ 243,241,245,225,242,101,128, 51,172,114, 2, 97, 95, 97,192, 97,
+ 2, 97,101, 97,109,228,233,229,238,116,128, 34, 7,246,101,134,
+ 0, 96, 97,126, 97,137, 97,154, 97,161, 97,170, 97,182,226,229,
+ 236,239,247,227,237, 98,128, 3, 22, 99, 2, 97,143, 97,148,237,
+ 98,128, 3, 0,239,237, 98,128, 3, 0,228,229,246, 97,128, 9,
+ 83,236,239,247,237,239,100,128, 2,206,237,239,238,239,243,240,
+ 225,227,101,128,255, 64,244,239,238,229,227,237, 98,128, 3, 64,
+ 229,225,244,229,114,132, 0, 62, 97,208, 97,227, 97,239, 98, 26,
+ 229,241,245,225,108,129, 34,101, 97,218,239,242,236,229,243,115,
+ 128, 34,219,237,239,238,239,243,240,225,227,101,128,255, 30,111,
+ 2, 97,245, 98, 15,114, 2, 97,251, 98, 8,229,241,245,233,246,
+ 225,236,229,238,116,128, 34,115,236,229,243,115,128, 34,119,246,
+ 229,242,229,241,245,225,108,128, 34,103,243,237,225,236,108,128,
+ 254,101,115, 2, 98, 40, 98, 48,227,242,233,240,116,128, 2, 97,
+ 244,242,239,235,101,128, 1,229,117, 4, 98, 66, 98, 77, 98,134,
+ 98,145,232,233,242,225,231,225,238, 97,128, 48, 80,233,108, 2,
+ 98, 84, 98,109,236,229,237,239,116, 2, 98, 94, 98,101,236,229,
+ 230,116,128, 0,171,242,233,231,232,116,128, 0,187,243,233,238,
+ 231,108, 2, 98,119, 98,126,236,229,230,116,128, 32, 57,242,233,
+ 231,232,116,128, 32, 58,235,225,244,225,235,225,238, 97,128, 48,
+ 176,242,225,237,245,243,241,245,225,242,101,128, 51, 24,249,243,
+ 241,245,225,242,101,128, 51,201,104,144, 0,104, 98,204,101, 90,
+ 101,125,101,162,101,202,103, 90,103,110,104, 75,104, 87,104, 99,
+ 105,167,105,175,105,186,105,195,106, 19,106, 23, 97, 13, 98,232,
+ 99, 15, 99, 25, 99, 55, 99, 80, 99,158, 99,170, 99,195, 99,210,
+ 99,239, 99,252,100, 54,100, 63, 97, 2, 98,238, 99, 1,226,235,
+ 232,225,243,233,225,238,227,249,242,233,236,236,233, 99,128, 4,
+ 169,236,244,239,238,229,225,242,225,226,233, 99,128, 6,193,226,
+ 229,238,231,225,236,105,128, 9,185,228,101, 2, 99, 32, 99, 50,
+ 243,227,229,238,228,229,242,227,249,242,233,236,236,233, 99,128,
+ 4,179,246, 97,128, 9, 57,231,117, 2, 99, 62, 99, 71,234,225,
+ 242,225,244,105,128, 10,185,242,237,245,235,232,105,128, 10, 57,
+ 104, 4, 99, 90, 99, 99, 99,113, 99,143,225,242,225,226,233, 99,
+ 128, 6, 45,230,233,238,225,236,225,242,225,226,233, 99,128,254,
+ 162,105, 2, 99,119, 99,134,238,233,244,233,225,236,225,242,225,
+ 226,233, 99,128,254,163,242,225,231,225,238, 97,128, 48,111,237,
+ 229,228,233,225,236,225,242,225,226,233, 99,128,254,164,233,244,
+ 245,243,241,245,225,242,101,128, 51, 42,235,225,244,225,235,225,
+ 238, 97,129, 48,207, 99,183,232,225,236,230,247,233,228,244,104,
+ 128,255,138,236,225,238,244,231,245,242,237,245,235,232,105,128,
+ 10, 77,237,250, 97, 2, 99,218, 99,227,225,242,225,226,233, 99,
+ 128, 6, 33,236,239,247,225,242,225,226,233, 99,128, 6, 33,238,
+ 231,245,236,230,233,236,236,229,114,128, 49,100,114, 2,100, 2,
+ 100, 18,228,243,233,231,238,227,249,242,233,236,236,233, 99,128,
+ 4, 74,240,239,239,110, 2,100, 27,100, 40,236,229,230,244,226,
+ 225,242,226,245,112,128, 33,188,242,233,231,232,244,226,225,242,
+ 226,245,112,128, 33,192,243,241,245,225,242,101,128, 51,202,244,
+ 225,102, 3,100, 73,100,165,101, 0,240,225,244,225,104,134, 5,
+ 178,100, 93,100, 98,100,112,100,121,100,136,100,152,177, 54,128,
+ 5,178, 50, 2,100,104,100,108, 51,128, 5,178,102,128, 5,178,
+ 232,229,226,242,229,119,128, 5,178,238,225,242,242,239,247,232,
+ 229,226,242,229,119,128, 5,178,241,245,225,242,244,229,242,232,
+ 229,226,242,229,119,128, 5,178,247,233,228,229,232,229,226,242,
+ 229,119,128, 5,178,241,225,237,225,244,115,135, 5,179,100,188,
+ 100,193,100,198,100,203,100,212,100,227,100,243,177, 98,128, 5,
+ 179,178, 56,128, 5,179,179, 52,128, 5,179,232,229,226,242,229,
+ 119,128, 5,179,238,225,242,242,239,247,232,229,226,242,229,119,
+ 128, 5,179,241,245,225,242,244,229,242,232,229,226,242,229,119,
+ 128, 5,179,247,233,228,229,232,229,226,242,229,119,128, 5,179,
+ 243,229,231,239,108,135, 5,177,101, 22,101, 27,101, 32,101, 37,
+ 101, 46,101, 61,101, 77,177, 55,128, 5,177,178, 52,128, 5,177,
+ 179, 48,128, 5,177,232,229,226,242,229,119,128, 5,177,238,225,
+ 242,242,239,247,232,229,226,242,229,119,128, 5,177,241,245,225,
+ 242,244,229,242,232,229,226,242,229,119,128, 5,177,247,233,228,
+ 229,232,229,226,242,229,119,128, 5,177, 98, 3,101, 98,101,103,
+ 101,113,225,114,128, 1, 39,239,240,239,237,239,230,111,128, 49,
+ 15,242,229,246,229,226,229,236,239,119,128, 30, 43, 99, 2,101,
+ 131,101,140,229,228,233,236,236, 97,128, 30, 41,233,242, 99, 2,
+ 101,148,101,153,236,101,128, 36,215,245,237,230,236,229,120,128,
+ 1, 37,100, 2,101,168,101,178,233,229,242,229,243,233,115,128,
+ 30, 39,239,116, 2,101,185,101,194,225,227,227,229,238,116,128,
+ 30, 35,226,229,236,239,119,128, 30, 37,101,136, 5,212,101,222,
+ 101,255,102, 19,102,248,103, 8,103, 53,103, 62,103, 75,225,242,
+ 116,129, 38,101,101,230,243,245,233,116, 2,101,239,101,247,226,
+ 236,225,227,107,128, 38,101,247,232,233,244,101,128, 38, 97,228,
+ 225,231,229,243,104,129,251, 52,102, 10,232,229,226,242,229,119,
+ 128,251, 52,104, 6,102, 33,102, 61,102, 69,102,119,102,165,102,
+ 214, 97, 2,102, 39,102, 53,236,244,239,238,229,225,242,225,226,
+ 233, 99,128, 6,193,242,225,226,233, 99,128, 6, 71,229,226,242,
+ 229,119,128, 5,212,230,233,238,225,236, 97, 2,102, 80,102,111,
+ 236,116, 2,102, 87,102, 99,239,238,229,225,242,225,226,233, 99,
+ 128,251,167,244,247,239,225,242,225,226,233, 99,128,254,234,242,
+ 225,226,233, 99,128,254,234,232,225,237,250,225,225,226,239,246,
+ 101, 2,102,134,102,148,230,233,238,225,236,225,242,225,226,233,
+ 99,128,251,165,233,243,239,236,225,244,229,228,225,242,225,226,
+ 233, 99,128,251,164,105, 2,102,171,102,205,238,233,244,233,225,
+ 236, 97, 2,102,183,102,197,236,244,239,238,229,225,242,225,226,
+ 233, 99,128,251,168,242,225,226,233, 99,128,254,235,242,225,231,
+ 225,238, 97,128, 48,120,237,229,228,233,225,236, 97, 2,102,226,
+ 102,240,236,244,239,238,229,225,242,225,226,233, 99,128,251,169,
+ 242,225,226,233, 99,128,254,236,233,243,229,233,229,242,225,243,
+ 241,245,225,242,101,128, 51,123,107, 2,103, 14,103, 38,225,244,
+ 225,235,225,238, 97,129, 48,216,103, 26,232,225,236,230,247,233,
+ 228,244,104,128,255,141,245,244,225,225,242,245,243,241,245,225,
+ 242,101,128, 51, 54,238,231,232,239,239,107,128, 2,103,242,245,
+ 244,245,243,241,245,225,242,101,128, 51, 57,116,129, 5,215,103,
+ 81,232,229,226,242,229,119,128, 5,215,232,239,239,107,129, 2,
+ 102,103, 99,243,245,240,229,242,233,239,114,128, 2,177,105, 4,
+ 103,120,103,205,103,216,103,241,229,245,104, 4,103,132,103,167,
+ 103,182,103,191, 97, 2,103,138,103,153,227,233,242,227,236,229,
+ 235,239,242,229,225,110,128, 50,123,240,225,242,229,238,235,239,
+ 242,229,225,110,128, 50, 27,227,233,242,227,236,229,235,239,242,
+ 229,225,110,128, 50,109,235,239,242,229,225,110,128, 49, 78,240,
+ 225,242,229,238,235,239,242,229,225,110,128, 50, 13,232,233,242,
+ 225,231,225,238, 97,128, 48,114,235,225,244,225,235,225,238, 97,
+ 129, 48,210,103,229,232,225,236,230,247,233,228,244,104,128,255,
+ 139,242,233,113,134, 5,180,104, 3,104, 8,104, 22,104, 31,104,
+ 46,104, 62,177, 52,128, 5,180, 50, 2,104, 14,104, 18, 49,128,
+ 5,180,100,128, 5,180,232,229,226,242,229,119,128, 5,180,238,
+ 225,242,242,239,247,232,229,226,242,229,119,128, 5,180,241,245,
+ 225,242,244,229,242,232,229,226,242,229,119,128, 5,180,247,233,
+ 228,229,232,229,226,242,229,119,128, 5,180,236,233,238,229,226,
+ 229,236,239,119,128, 30,150,237,239,238,239,243,240,225,227,101,
+ 128,255, 72,111, 9,104,119,104,130,104,154,104,179,105, 11,105,
+ 24,105,110,105,150,105,161,225,242,237,229,238,233,225,110,128,
+ 5,112,232,105, 2,104,137,104,145,240,244,232,225,105,128, 14,
+ 43,242,225,231,225,238, 97,128, 48,123,235,225,244,225,235,225,
+ 238, 97,129, 48,219,104,167,232,225,236,230,247,233,228,244,104,
+ 128,255,142,236,225,109,135, 5,185,104,199,104,204,104,209,104,
+ 214,104,223,104,238,104,254,177, 57,128, 5,185,178, 54,128, 5,
+ 185,179, 50,128, 5,185,232,229,226,242,229,119,128, 5,185,238,
+ 225,242,242,239,247,232,229,226,242,229,119,128, 5,185,241,245,
+ 225,242,244,229,242,232,229,226,242,229,119,128, 5,185,247,233,
+ 228,229,232,229,226,242,229,119,128, 5,185,238,239,235,232,245,
+ 235,244,232,225,105,128, 14, 46,111, 2,105, 30,105,100,107, 4,
+ 105, 40,105, 52,105, 58,105, 80,225,226,239,246,229,227,239,237,
+ 98,128, 3, 9,227,237, 98,128, 3, 9,240,225,236,225,244,225,
+ 236,233,250,229,228,226,229,236,239,247,227,237, 98,128, 3, 33,
+ 242,229,244,242,239,230,236,229,248,226,229,236,239,247,227,237,
+ 98,128, 3, 34,238,243,241,245,225,242,101,128, 51, 66,114, 2,
+ 105,116,105,143,105, 2,105,122,105,131,227,239,240,244,233, 99,
+ 128, 3,233,250,239,238,244,225,236,226,225,114,128, 32, 21,238,
+ 227,237, 98,128, 3, 27,244,243,240,242,233,238,231,115,128, 38,
+ 104,245,243,101,128, 35, 2,240,225,242,229,110,128, 36,163,243,
+ 245,240,229,242,233,239,114,128, 2,176,244,245,242,238,229,100,
+ 128, 2,101,117, 4,105,205,105,216,105,229,105,254,232,233,242,
+ 225,231,225,238, 97,128, 48,117,233,233,244,239,243,241,245,225,
+ 242,101,128, 51, 51,235,225,244,225,235,225,238, 97,129, 48,213,
+ 105,242,232,225,236,230,247,233,228,244,104,128,255,140,238,231,
+ 225,242,245,237,236,225,245,116,129, 2,221,106, 13,227,237, 98,
+ 128, 3, 11,118,128, 1,149,249,240,232,229,110,132, 0, 45,106,
+ 39,106, 50,106, 62,106, 85,233,238,230,229,242,233,239,114,128,
+ 246,229,237,239,238,239,243,240,225,227,101,128,255, 13,115, 2,
+ 106, 68,106, 75,237,225,236,108,128,254, 99,245,240,229,242,233,
+ 239,114,128,246,230,244,247,111,128, 32, 16,105,149, 0,105,106,
+ 137,106,160,106,194,106,241,110,123,110,243,111, 24,111, 51,111,
+ 213,111,217,111,255,112, 21,112,105,113, 14,113, 89,113, 97,113,
+ 110,113,197,113,254,114, 26,114, 70,225, 99, 2,106,144,106,150,
+ 245,244,101,128, 0,237,249,242,233,236,236,233, 99,128, 4, 79,
+ 98, 3,106,168,106,177,106,187,229,238,231,225,236,105,128, 9,
+ 135,239,240,239,237,239,230,111,128, 49, 39,242,229,246,101,128,
+ 1, 45, 99, 3,106,202,106,209,106,231,225,242,239,110,128, 1,
+ 208,233,242, 99, 2,106,217,106,222,236,101,128, 36,216,245,237,
+ 230,236,229,120,128, 0,238,249,242,233,236,236,233, 99,128, 4,
+ 86,100, 4,106,251,107, 5,110, 80,110,113,226,236,231,242,225,
+ 246,101,128, 2, 9,101, 2,107, 11,110, 75,239,231,242,225,240,
+ 104, 7,107, 32,107, 46,107, 59,109,244,110, 19,110, 32,110, 44,
+ 229,225,242,244,232,227,233,242,227,236,101,128, 50,143,230,233,
+ 242,229,227,233,242,227,236,101,128, 50,139,233, 99, 14,107, 90,
+ 107,106,107,205,108, 3,108, 69,108, 98,108,114,108,171,108,220,
+ 108,232,109, 3,109, 70,109,208,109,237,225,236,236,233,225,238,
+ 227,229,240,225,242,229,110,128, 50, 63, 99, 4,107,116,107,127,
+ 107,141,107,148,225,236,236,240,225,242,229,110,128, 50, 58,229,
+ 238,244,242,229,227,233,242,227,236,101,128, 50,165,236,239,243,
+ 101,128, 48, 6,111, 3,107,156,107,171,107,191,237,237, 97,129,
+ 48, 1,107,164,236,229,230,116,128,255,100,238,231,242,225,244,
+ 245,236,225,244,233,239,238,240,225,242,229,110,128, 50, 55,242,
+ 242,229,227,244,227,233,242,227,236,101,128, 50,163,101, 3,107,
+ 213,107,225,107,242,225,242,244,232,240,225,242,229,110,128, 50,
+ 47,238,244,229,242,240,242,233,243,229,240,225,242,229,110,128,
+ 50, 61,248,227,229,236,236,229,238,244,227,233,242,227,236,101,
+ 128, 50,157,102, 2,108, 9,108, 24,229,243,244,233,246,225,236,
+ 240,225,242,229,110,128, 50, 64,105, 2,108, 30,108, 59,238,225,
+ 238,227,233,225,108, 2,108, 42,108, 51,227,233,242,227,236,101,
+ 128, 50,150,240,225,242,229,110,128, 50, 54,242,229,240,225,242,
+ 229,110,128, 50, 43,104, 2,108, 75,108, 86,225,246,229,240,225,
+ 242,229,110,128, 50, 50,233,231,232,227,233,242,227,236,101,128,
+ 50,164,233,244,229,242,225,244,233,239,238,237,225,242,107,128,
+ 48, 5,108, 3,108,122,108,148,108,160,225,226,239,114, 2,108,
+ 131,108,140,227,233,242,227,236,101,128, 50,152,240,225,242,229,
+ 110,128, 50, 56,229,230,244,227,233,242,227,236,101,128, 50,167,
+ 239,247,227,233,242,227,236,101,128, 50,166,109, 2,108,177,108,
+ 209,101, 2,108,183,108,198,228,233,227,233,238,229,227,233,242,
+ 227,236,101,128, 50,169,244,225,236,240,225,242,229,110,128, 50,
+ 46,239,239,238,240,225,242,229,110,128, 50, 42,238,225,237,229,
+ 240,225,242,229,110,128, 50, 52,112, 2,108,238,108,246,229,242,
+ 233,239,100,128, 48, 2,242,233,238,244,227,233,242,227,236,101,
+ 128, 50,158,114, 2,109, 9,109, 57,101, 3,109, 17,109, 28,109,
+ 43,225,227,232,240,225,242,229,110,128, 50, 67,240,242,229,243,
+ 229,238,244,240,225,242,229,110,128, 50, 57,243,239,245,242,227,
+ 229,240,225,242,229,110,128, 50, 62,233,231,232,244,227,233,242,
+ 227,236,101,128, 50,168,115, 5,109, 82,109,111,109,125,109,150,
+ 109,178,101, 2,109, 88,109,101,227,242,229,244,227,233,242,227,
+ 236,101,128, 50,153,236,230,240,225,242,229,110,128, 50, 66,239,
+ 227,233,229,244,249,240,225,242,229,110,128, 50, 51,112, 2,109,
+ 131,109,137,225,227,101,128, 48, 0,229,227,233,225,236,240,225,
+ 242,229,110,128, 50, 53,116, 2,109,156,109,167,239,227,235,240,
+ 225,242,229,110,128, 50, 49,245,228,249,240,225,242,229,110,128,
+ 50, 59,117, 2,109,184,109,193,238,240,225,242,229,110,128, 50,
+ 48,240,229,242,246,233,243,229,240,225,242,229,110,128, 50, 60,
+ 119, 2,109,214,109,226,225,244,229,242,240,225,242,229,110,128,
+ 50, 44,239,239,228,240,225,242,229,110,128, 50, 45,250,229,242,
+ 111,128, 48, 7,109, 2,109,250,110, 7,229,244,225,236,227,233,
+ 242,227,236,101,128, 50,142,239,239,238,227,233,242,227,236,101,
+ 128, 50,138,238,225,237,229,227,233,242,227,236,101,128, 50,148,
+ 243,245,238,227,233,242,227,236,101,128, 50,144,119, 2,110, 50,
+ 110, 63,225,244,229,242,227,233,242,227,236,101,128, 50,140,239,
+ 239,228,227,233,242,227,236,101,128, 50,141,246, 97,128, 9, 7,
+ 233,229,242,229,243,233,115,130, 0,239,110, 94,110,102,225,227,
+ 245,244,101,128, 30, 47,227,249,242,233,236,236,233, 99,128, 4,
+ 229,239,244,226,229,236,239,119,128, 30,203,101, 3,110,131,110,
+ 147,110,158,226,242,229,246,229,227,249,242,233,236,236,233, 99,
+ 128, 4,215,227,249,242,233,236,236,233, 99,128, 4, 53,245,238,
+ 103, 4,110,170,110,205,110,220,110,229, 97, 2,110,176,110,191,
+ 227,233,242,227,236,229,235,239,242,229,225,110,128, 50,117,240,
+ 225,242,229,238,235,239,242,229,225,110,128, 50, 21,227,233,242,
+ 227,236,229,235,239,242,229,225,110,128, 50,103,235,239,242,229,
+ 225,110,128, 49, 71,240,225,242,229,238,235,239,242,229,225,110,
+ 128, 50, 7,103, 2,110,249,111, 0,242,225,246,101,128, 0,236,
+ 117, 2,111, 6,111, 15,234,225,242,225,244,105,128, 10,135,242,
+ 237,245,235,232,105,128, 10, 7,104, 2,111, 30,111, 40,233,242,
+ 225,231,225,238, 97,128, 48, 68,239,239,235,225,226,239,246,101,
+ 128, 30,201,105, 8,111, 69,111, 79,111, 90,111, 97,111,122,111,
+ 138,111,153,111,169,226,229,238,231,225,236,105,128, 9,136,227,
+ 249,242,233,236,236,233, 99,128, 4, 56,228,229,246, 97,128, 9,
+ 8,231,117, 2,111,104,111,113,234,225,242,225,244,105,128, 10,
+ 136,242,237,245,235,232,105,128, 10, 8,237,225,244,242,225,231,
+ 245,242,237,245,235,232,105,128, 10, 64,238,246,229,242,244,229,
+ 228,226,242,229,246,101,128, 2, 11,243,232,239,242,244,227,249,
+ 242,233,236,236,233, 99,128, 4, 57,246,239,247,229,236,243,233,
+ 231,110, 3,111,185,111,195,111,202,226,229,238,231,225,236,105,
+ 128, 9,192,228,229,246, 97,128, 9, 64,231,245,234,225,242,225,
+ 244,105,128, 10,192,106,128, 1, 51,107, 2,111,223,111,247,225,
+ 244,225,235,225,238, 97,129, 48,164,111,235,232,225,236,230,247,
+ 233,228,244,104,128,255,114,239,242,229,225,110,128, 49, 99,108,
+ 2,112, 5,112, 10,228,101,128, 2,220,245,249,232,229,226,242,
+ 229,119,128, 5,172,109, 2,112, 27,112, 94, 97, 3,112, 35,112,
+ 55,112, 80,227,242,239,110,129, 1, 43,112, 44,227,249,242,233,
+ 236,236,233, 99,128, 4,227,231,229,239,242,225,240,240,242,239,
+ 248,233,237,225,244,229,236,249,229,241,245,225,108,128, 34, 83,
+ 244,242,225,231,245,242,237,245,235,232,105,128, 10, 63,239,238,
+ 239,243,240,225,227,101,128,255, 73,110, 5,112,117,112,127,112,
+ 136,112,148,112,232,227,242,229,237,229,238,116,128, 34, 6,230,
+ 233,238,233,244,121,128, 34, 30,233,225,242,237,229,238,233,225,
+ 110,128, 5,107,116, 2,112,154,112,222,101, 2,112,160,112,211,
+ 231,242,225,108,131, 34, 43,112,173,112,191,112,196, 98, 2,112,
+ 179,112,187,239,244,244,239,109,128, 35, 33,116,128, 35, 33,229,
+ 120,128,248,245,116, 2,112,202,112,207,239,112,128, 35, 32,112,
+ 128, 35, 32,242,243,229,227,244,233,239,110,128, 34, 41,233,243,
+ 241,245,225,242,101,128, 51, 5,118, 3,112,240,112,249,113, 2,
+ 226,245,236,236,229,116,128, 37,216,227,233,242,227,236,101,128,
+ 37,217,243,237,233,236,229,230,225,227,101,128, 38, 59,111, 3,
+ 113, 22,113, 33,113, 41,227,249,242,233,236,236,233, 99,128, 4,
+ 81,231,239,238,229,107,128, 1, 47,244, 97,131, 3,185,113, 52,
+ 113, 73,113, 81,228,233,229,242,229,243,233,115,129, 3,202,113,
+ 65,244,239,238,239,115,128, 3,144,236,225,244,233,110,128, 2,
+ 105,244,239,238,239,115,128, 3,175,240,225,242,229,110,128, 36,
+ 164,242,233,231,245,242,237,245,235,232,105,128, 10,114,115, 4,
+ 113,120,113,165,113,179,113,187,237,225,236,108, 2,113,129,113,
+ 140,232,233,242,225,231,225,238, 97,128, 48, 67,235,225,244,225,
+ 235,225,238, 97,129, 48,163,113,153,232,225,236,230,247,233,228,
+ 244,104,128,255,104,243,232,225,242,226,229,238,231,225,236,105,
+ 128, 9,250,244,242,239,235,101,128, 2,104,245,240,229,242,233,
+ 239,114,128,246,237,116, 2,113,203,113,237,229,242,225,244,233,
+ 239,110, 2,113,215,113,226,232,233,242,225,231,225,238, 97,128,
+ 48,157,235,225,244,225,235,225,238, 97,128, 48,253,233,236,228,
+ 101,129, 1, 41,113,246,226,229,236,239,119,128, 30, 45,117, 2,
+ 114, 4,114, 15,226,239,240,239,237,239,230,111,128, 49, 41,227,
+ 249,242,233,236,236,233, 99,128, 4, 78,246,239,247,229,236,243,
+ 233,231,110, 3,114, 42,114, 52,114, 59,226,229,238,231,225,236,
+ 105,128, 9,191,228,229,246, 97,128, 9, 63,231,245,234,225,242,
+ 225,244,105,128, 10,191,250,232,233,244,243, 97, 2,114, 81,114,
+ 92,227,249,242,233,236,236,233, 99,128, 4,117,228,226,236,231,
+ 242,225,246,229,227,249,242,233,236,236,233, 99,128, 4,119,106,
+ 138, 0,106,114,135,114,198,114,209,115, 3,115, 19,115,132,115,
+ 201,115,206,115,218,115,226, 97, 4,114,145,114,156,114,166,114,
+ 173,225,242,237,229,238,233,225,110,128, 5,113,226,229,238,231,
+ 225,236,105,128, 9,156,228,229,246, 97,128, 9, 28,231,117, 2,
+ 114,180,114,189,234,225,242,225,244,105,128, 10,156,242,237,245,
+ 235,232,105,128, 10, 28,226,239,240,239,237,239,230,111,128, 49,
+ 16, 99, 3,114,217,114,224,114,246,225,242,239,110,128, 1,240,
+ 233,242, 99, 2,114,232,114,237,236,101,128, 36,217,245,237,230,
+ 236,229,120,128, 1, 53,242,239,243,243,229,228,244,225,233,108,
+ 128, 2,157,228,239,244,236,229,243,243,243,244,242,239,235,101,
+ 128, 2, 95,101, 3,115, 27,115, 38,115,103,227,249,242,233,236,
+ 236,233, 99,128, 4, 88,229,109, 4,115, 49,115, 58,115, 72,115,
+ 88,225,242,225,226,233, 99,128, 6, 44,230,233,238,225,236,225,
+ 242,225,226,233, 99,128,254,158,233,238,233,244,233,225,236,225,
+ 242,225,226,233, 99,128,254,159,237,229,228,233,225,236,225,242,
+ 225,226,233, 99,128,254,160,104, 2,115,109,115,118,225,242,225,
+ 226,233, 99,128, 6,152,230,233,238,225,236,225,242,225,226,233,
+ 99,128,251,139,104, 2,115,138,115,188, 97, 3,115,146,115,156,
+ 115,163,226,229,238,231,225,236,105,128, 9,157,228,229,246, 97,
+ 128, 9, 29,231,117, 2,115,170,115,179,234,225,242,225,244,105,
+ 128, 10,157,242,237,245,235,232,105,128, 10, 29,229,232,225,242,
+ 237,229,238,233,225,110,128, 5,123,233,115,128, 48, 4,237,239,
+ 238,239,243,240,225,227,101,128,255, 74,240,225,242,229,110,128,
+ 36,165,243,245,240,229,242,233,239,114,128, 2,178,107,146, 0,
+ 107,116, 21,118,110,118,121,118,183,118,194,119, 28,119, 42,120,
+ 150,121, 90,121,103,121,129,121,178,122, 60,122, 82,122, 95,122,
+ 118,122,160,122,170, 97, 12,116, 47,116, 79,116,101,116,131,116,
+ 245,117, 14,117, 44,117, 69,117,175,117,189,118, 56,118, 85, 98,
+ 2,116, 53,116, 70,225,243,232,235,233,242,227,249,242,233,236,
+ 236,233, 99,128, 4,161,229,238,231,225,236,105,128, 9,149, 99,
+ 2,116, 85,116, 91,245,244,101,128, 30, 49,249,242,233,236,236,
+ 233, 99,128, 4, 58,228,101, 2,116,108,116,126,243,227,229,238,
+ 228,229,242,227,249,242,233,236,236,233, 99,128, 4,155,246, 97,
+ 128, 9, 21,102,135, 5,219,116,149,116,158,116,178,116,192,116,
+ 201,116,217,116,232,225,242,225,226,233, 99,128, 6, 67,228,225,
+ 231,229,243,104,129,251, 59,116,169,232,229,226,242,229,119,128,
+ 251, 59,230,233,238,225,236,225,242,225,226,233, 99,128,254,218,
+ 232,229,226,242,229,119,128, 5,219,233,238,233,244,233,225,236,
+ 225,242,225,226,233, 99,128,254,219,237,229,228,233,225,236,225,
+ 242,225,226,233, 99,128,254,220,242,225,230,229,232,229,226,242,
+ 229,119,128,251, 77,231,117, 2,116,252,117, 5,234,225,242,225,
+ 244,105,128, 10,149,242,237,245,235,232,105,128, 10, 21,104, 2,
+ 117, 20,117, 30,233,242,225,231,225,238, 97,128, 48, 75,239,239,
+ 235,227,249,242,233,236,236,233, 99,128, 4,196,235,225,244,225,
+ 235,225,238, 97,129, 48,171,117, 57,232,225,236,230,247,233,228,
+ 244,104,128,255,118,112, 2,117, 75,117, 96,240, 97,129, 3,186,
+ 117, 82,243,249,237,226,239,236,231,242,229,229,107,128, 3,240,
+ 249,229,239,245,110, 3,117,108,117,122,117,156,237,233,229,245,
+ 237,235,239,242,229,225,110,128, 49,113,112, 2,117,128,117,143,
+ 232,233,229,245,240,232,235,239,242,229,225,110,128, 49,132,233,
+ 229,245,240,235,239,242,229,225,110,128, 49,120,243,243,225,238,
+ 231,240,233,229,245,240,235,239,242,229,225,110,128, 49,121,242,
+ 239,242,233,233,243,241,245,225,242,101,128, 51, 13,115, 5,117,
+ 201,117,245,118, 4,118, 12,118, 40,232,233,228,225,225,245,244,
+ 111, 2,117,214,117,223,225,242,225,226,233, 99,128, 6, 64,238,
+ 239,243,233,228,229,226,229,225,242,233,238,231,225,242,225,226,
+ 233, 99,128, 6, 64,237,225,236,236,235,225,244,225,235,225,238,
+ 97,128, 48,245,241,245,225,242,101,128, 51,132,242, 97, 2,118,
+ 19,118, 28,225,242,225,226,233, 99,128, 6, 80,244,225,238,225,
+ 242,225,226,233, 99,128, 6, 77,244,242,239,235,229,227,249,242,
+ 233,236,236,233, 99,128, 4,159,244,225,232,233,242,225,240,242,
+ 239,236,239,238,231,237,225,242,235,232,225,236,230,247,233,228,
+ 244,104,128,255,112,246,229,242,244,233,227,225,236,243,244,242,
+ 239,235,229,227,249,242,233,236,236,233, 99,128, 4,157,226,239,
+ 240,239,237,239,230,111,128, 49, 14, 99, 4,118,131,118,153,118,
+ 162,118,170, 97, 2,118,137,118,147,236,243,241,245,225,242,101,
+ 128, 51,137,242,239,110,128, 1,233,229,228,233,236,236, 97,128,
+ 1, 55,233,242,227,236,101,128, 36,218,239,237,237,225,225,227,
+ 227,229,238,116,128, 1, 55,228,239,244,226,229,236,239,119,128,
+ 30, 51,101, 4,118,204,118,231,119, 0,119, 12,104, 2,118,210,
+ 118,221,225,242,237,229,238,233,225,110,128, 5,132,233,242,225,
+ 231,225,238, 97,128, 48, 81,235,225,244,225,235,225,238, 97,129,
+ 48,177,118,244,232,225,236,230,247,233,228,244,104,128,255,121,
+ 238,225,242,237,229,238,233,225,110,128, 5,111,243,237,225,236,
+ 236,235,225,244,225,235,225,238, 97,128, 48,246,231,242,229,229,
+ 238,236,225,238,228,233, 99,128, 1, 56,104, 6,119, 56,119,185,
+ 119,196,119,221,120, 52,120,140, 97, 5,119, 68,119, 78,119, 89,
+ 119, 96,119,121,226,229,238,231,225,236,105,128, 9,150,227,249,
+ 242,233,236,236,233, 99,128, 4, 69,228,229,246, 97,128, 9, 22,
+ 231,117, 2,119,103,119,112,234,225,242,225,244,105,128, 10,150,
+ 242,237,245,235,232,105,128, 10, 22,104, 4,119,131,119,140,119,
+ 154,119,170,225,242,225,226,233, 99,128, 6, 46,230,233,238,225,
+ 236,225,242,225,226,233, 99,128,254,166,233,238,233,244,233,225,
+ 236,225,242,225,226,233, 99,128,254,167,237,229,228,233,225,236,
+ 225,242,225,226,233, 99,128,254,168,229,233,227,239,240,244,233,
+ 99,128, 3,231,232, 97, 2,119,203,119,210,228,229,246, 97,128,
+ 9, 89,231,245,242,237,245,235,232,105,128, 10, 89,233,229,245,
+ 235,104, 4,119,235,120, 14,120, 29,120, 38, 97, 2,119,241,120,
+ 0,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,120,
+ 240,225,242,229,238,235,239,242,229,225,110,128, 50, 24,227,233,
+ 242,227,236,229,235,239,242,229,225,110,128, 50,106,235,239,242,
+ 229,225,110,128, 49, 75,240,225,242,229,238,235,239,242,229,225,
+ 110,128, 50, 10,111, 4,120, 62,120,111,120,121,120,126,235,104,
+ 4,120, 73,120, 82,120, 91,120,101,225,233,244,232,225,105,128,
+ 14, 2,239,238,244,232,225,105,128, 14, 5,245,225,244,244,232,
+ 225,105,128, 14, 3,247,225,233,244,232,225,105,128, 14, 4,237,
+ 245,244,244,232,225,105,128, 14, 91,239,107,128, 1,153,242,225,
+ 235,232,225,238,231,244,232,225,105,128, 14, 6,250,243,241,245,
+ 225,242,101,128, 51,145,105, 4,120,160,120,171,120,196,120,245,
+ 232,233,242,225,231,225,238, 97,128, 48, 77,235,225,244,225,235,
+ 225,238, 97,129, 48,173,120,184,232,225,236,230,247,233,228,244,
+ 104,128,255,119,242,111, 3,120,205,120,220,120,236,231,245,242,
+ 225,237,245,243,241,245,225,242,101,128, 51, 21,237,229,229,244,
+ 239,242,245,243,241,245,225,242,101,128, 51, 22,243,241,245,225,
+ 242,101,128, 51, 20,249,229,239,107, 5,121, 4,121, 39,121, 54,
+ 121, 63,121, 77, 97, 2,121, 10,121, 25,227,233,242,227,236,229,
+ 235,239,242,229,225,110,128, 50,110,240,225,242,229,238,235,239,
+ 242,229,225,110,128, 50, 14,227,233,242,227,236,229,235,239,242,
+ 229,225,110,128, 50, 96,235,239,242,229,225,110,128, 49, 49,240,
+ 225,242,229,238,235,239,242,229,225,110,128, 50, 0,243,233,239,
+ 243,235,239,242,229,225,110,128, 49, 51,234,229,227,249,242,233,
+ 236,236,233, 99,128, 4, 92,108, 2,121,109,121,120,233,238,229,
+ 226,229,236,239,119,128, 30, 53,243,241,245,225,242,101,128, 51,
+ 152,109, 3,121,137,121,151,121,162,227,245,226,229,228,243,241,
+ 245,225,242,101,128, 51,166,239,238,239,243,240,225,227,101,128,
+ 255, 75,243,241,245,225,242,229,228,243,241,245,225,242,101,128,
+ 51,162,111, 5,121,190,121,216,121,254,122, 10,122, 24,104, 2,
+ 121,196,121,206,233,242,225,231,225,238, 97,128, 48, 83,237,243,
+ 241,245,225,242,101,128, 51,192,235, 97, 2,121,223,121,231,233,
+ 244,232,225,105,128, 14, 1,244,225,235,225,238, 97,129, 48,179,
+ 121,242,232,225,236,230,247,233,228,244,104,128,255,122,239,240,
+ 239,243,241,245,225,242,101,128, 51, 30,240,240,225,227,249,242,
+ 233,236,236,233, 99,128, 4,129,114, 2,122, 30,122, 50,229,225,
+ 238,243,244,225,238,228,225,242,228,243,249,237,226,239,108,128,
+ 50,127,239,238,233,243,227,237, 98,128, 3, 67,240, 97, 2,122,
+ 67,122, 73,242,229,110,128, 36,166,243,241,245,225,242,101,128,
+ 51,170,243,233,227,249,242,233,236,236,233, 99,128, 4,111,116,
+ 2,122,101,122,110,243,241,245,225,242,101,128, 51,207,245,242,
+ 238,229,100,128, 2,158,117, 2,122,124,122,135,232,233,242,225,
+ 231,225,238, 97,128, 48, 79,235,225,244,225,235,225,238, 97,129,
+ 48,175,122,148,232,225,236,230,247,233,228,244,104,128,255,120,
+ 246,243,241,245,225,242,101,128, 51,184,247,243,241,245,225,242,
+ 101,128, 51,190,108,146, 0,108,122,220,124,247,125, 20,125, 86,
+ 125,124,126, 20,126, 29,126, 45,126, 69,126, 87,126,205,126,246,
+ 127,125,127,133,127,166,127,175,127,183,127,245, 97, 7,122,236,
+ 122,246,122,253,123, 4,123, 29,123, 45,124,235,226,229,238,231,
+ 225,236,105,128, 9,178,227,245,244,101,128, 1, 58,228,229,246,
+ 97,128, 9, 50,231,117, 2,123, 11,123, 20,234,225,242,225,244,
+ 105,128, 10,178,242,237,245,235,232,105,128, 10, 50,235,235,232,
+ 225,238,231,249,225,239,244,232,225,105,128, 14, 69,109, 10,123,
+ 67,124, 6,124, 23,124, 61,124, 75,124, 94,124,110,124,130,124,
+ 150,124,173, 97, 2,123, 73,123,254,236,229,102, 4,123, 85,123,
+ 99,123,191,123,208,230,233,238,225,236,225,242,225,226,233, 99,
+ 128,254,252,232,225,237,250, 97, 2,123,109,123,150,225,226,239,
+ 246,101, 2,123,119,123,133,230,233,238,225,236,225,242,225,226,
+ 233, 99,128,254,248,233,243,239,236,225,244,229,228,225,242,225,
+ 226,233, 99,128,254,247,226,229,236,239,119, 2,123,160,123,174,
+ 230,233,238,225,236,225,242,225,226,233, 99,128,254,250,233,243,
+ 239,236,225,244,229,228,225,242,225,226,233, 99,128,254,249,233,
+ 243,239,236,225,244,229,228,225,242,225,226,233, 99,128,254,251,
+ 237,225,228,228,225,225,226,239,246,101, 2,123,223,123,237,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,254,246,233,243,239,
+ 236,225,244,229,228,225,242,225,226,233, 99,128,254,245,242,225,
+ 226,233, 99,128, 6, 68,226,228, 97,129, 3,187,124, 14,243,244,
+ 242,239,235,101,128, 1,155,229,100,130, 5,220,124, 32,124, 52,
+ 228,225,231,229,243,104,129,251, 60,124, 43,232,229,226,242,229,
+ 119,128,251, 60,232,229,226,242,229,119,128, 5,220,230,233,238,
+ 225,236,225,242,225,226,233, 99,128,254,222,232,225,232,233,238,
+ 233,244,233,225,236,225,242,225,226,233, 99,128,252,202,233,238,
+ 233,244,233,225,236,225,242,225,226,233, 99,128,254,223,234,229,
+ 229,237,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
+ 252,201,235,232,225,232,233,238,233,244,233,225,236,225,242,225,
+ 226,233, 99,128,252,203,236,225,237,232,229,232,233,243,239,236,
+ 225,244,229,228,225,242,225,226,233, 99,128,253,242,237,101, 2,
+ 124,180,124,193,228,233,225,236,225,242,225,226,233, 99,128,254,
+ 224,229,109, 2,124,200,124,219,232,225,232,233,238,233,244,233,
+ 225,236,225,242,225,226,233, 99,128,253,136,233,238,233,244,233,
+ 225,236,225,242,225,226,233, 99,128,252,204,242,231,229,227,233,
+ 242,227,236,101,128, 37,239, 98, 3,124,255,125, 4,125, 10,225,
+ 114,128, 1,154,229,236,116,128, 2,108,239,240,239,237,239,230,
+ 111,128, 49, 12, 99, 4,125, 30,125, 37,125, 46,125, 73,225,242,
+ 239,110,128, 1, 62,229,228,233,236,236, 97,128, 1, 60,233,242,
+ 99, 2,125, 54,125, 59,236,101,128, 36,219,245,237,230,236,229,
+ 248,226,229,236,239,119,128, 30, 61,239,237,237,225,225,227,227,
+ 229,238,116,128, 1, 60,228,239,116,130, 1, 64,125, 96,125,105,
+ 225,227,227,229,238,116,128, 1, 64,226,229,236,239,119,129, 30,
+ 55,125,115,237,225,227,242,239,110,128, 30, 57,101, 3,125,132,
+ 125,170,126, 15,230,116, 2,125,139,125,155,225,238,231,236,229,
+ 225,226,239,246,229,227,237, 98,128, 3, 26,244,225,227,235,226,
+ 229,236,239,247,227,237, 98,128, 3, 24,243,115,132, 0, 60,125,
+ 183,125,205,125,217,126, 7,229,241,245,225,108,129, 34,100,125,
+ 193,239,242,231,242,229,225,244,229,114,128, 34,218,237,239,238,
+ 239,243,240,225,227,101,128,255, 28,111, 2,125,223,125,252,114,
+ 2,125,229,125,242,229,241,245,233,246,225,236,229,238,116,128,
+ 34,114,231,242,229,225,244,229,114,128, 34,118,246,229,242,229,
+ 241,245,225,108,128, 34,102,243,237,225,236,108,128,254,100,250,
+ 104,128, 2,110,230,226,236,239,227,107,128, 37,140,232,239,239,
+ 235,242,229,244,242,239,230,236,229,120,128, 2,109,105, 2,126,
+ 51,126, 56,242, 97,128, 32,164,247,238,225,242,237,229,238,233,
+ 225,110,128, 5,108,106,129, 1,201,126, 75,229,227,249,242,233,
+ 236,236,233, 99,128, 4, 89,108,132,246,192,126, 99,126,123,126,
+ 134,126,143, 97, 2,126,105,126,112,228,229,246, 97,128, 9, 51,
+ 231,245,234,225,242,225,244,105,128, 10,179,233,238,229,226,229,
+ 236,239,119,128, 30, 59,236,225,228,229,246, 97,128, 9, 52,246,
+ 239,227,225,236,233, 99, 3,126,157,126,167,126,174,226,229,238,
+ 231,225,236,105,128, 9,225,228,229,246, 97,128, 9, 97,246,239,
+ 247,229,236,243,233,231,110, 2,126,188,126,198,226,229,238,231,
+ 225,236,105,128, 9,227,228,229,246, 97,128, 9, 99,109, 3,126,
+ 213,126,226,126,237,233,228,228,236,229,244,233,236,228,101,128,
+ 2,107,239,238,239,243,240,225,227,101,128,255, 76,243,241,245,
+ 225,242,101,128, 51,208,111, 6,127, 4,127, 16,127, 58,127, 69,
+ 127, 75,127,117,227,232,245,236,225,244,232,225,105,128, 14, 44,
+ 231,233,227,225,108, 3,127, 28,127, 34,127, 53,225,238,100,128,
+ 34, 39,238,239,116,129, 0,172,127, 42,242,229,246,229,242,243,
+ 229,100,128, 35, 16,239,114,128, 34, 40,236,233,238,231,244,232,
+ 225,105,128, 14, 37,238,231,115,128, 1,127,247,236,233,238,101,
+ 2,127, 85,127,108, 99, 2,127, 91,127,103,229,238,244,229,242,
+ 236,233,238,101,128,254, 78,237, 98,128, 3, 50,228,225,243,232,
+ 229,100,128,254, 77,250,229,238,231,101,128, 37,202,240,225,242,
+ 229,110,128, 36,167,115, 3,127,141,127,148,127,156,236,225,243,
+ 104,128, 1, 66,241,245,225,242,101,128, 33, 19,245,240,229,242,
+ 233,239,114,128,246,238,244,243,232,225,228,101,128, 37,145,245,
+ 244,232,225,105,128, 14, 38,246,239,227,225,236,233, 99, 3,127,
+ 197,127,207,127,214,226,229,238,231,225,236,105,128, 9,140,228,
+ 229,246, 97,128, 9, 12,246,239,247,229,236,243,233,231,110, 2,
+ 127,228,127,238,226,229,238,231,225,236,105,128, 9,226,228,229,
+ 246, 97,128, 9, 98,248,243,241,245,225,242,101,128, 51,211,109,
+ 144, 0,109,128, 35,130,144,130,169,130,196,130,221,132, 18,132,
+ 40,133, 95,133,125,133,174,134, 25,134, 47,134, 72,134, 81,135,
+ 108,135,136, 97, 12,128, 61,128, 71,128,135,128,142,128,167,128,
+ 215,130, 51,130, 76,130, 81,130, 95,130,107,130,112,226,229,238,
+ 231,225,236,105,128, 9,174, 99, 2,128, 77,128,129,242,239,110,
+ 132, 0,175,128, 91,128,102,128,108,128,117,226,229,236,239,247,
+ 227,237, 98,128, 3, 49,227,237, 98,128, 3, 4,236,239,247,237,
+ 239,100,128, 2,205,237,239,238,239,243,240,225,227,101,128,255,
+ 227,245,244,101,128, 30, 63,228,229,246, 97,128, 9, 46,231,117,
+ 2,128,149,128,158,234,225,242,225,244,105,128, 10,174,242,237,
+ 245,235,232,105,128, 10, 46,104, 2,128,173,128,205,225,240,225,
+ 235,104, 2,128,183,128,192,232,229,226,242,229,119,128, 5,164,
+ 236,229,230,244,232,229,226,242,229,119,128, 5,164,233,242,225,
+ 231,225,238, 97,128, 48,126,105, 5,128,227,129, 40,129,103,129,
+ 133,130, 39,227,232,225,244,244,225,247, 97, 3,128,242,129, 17,
+ 129, 24,236,239,119, 2,128,250,129, 5,236,229,230,244,244,232,
+ 225,105,128,248,149,242,233,231,232,244,244,232,225,105,128,248,
+ 148,244,232,225,105,128, 14, 75,245,240,240,229,242,236,229,230,
+ 244,244,232,225,105,128,248,147,229,107, 3,129, 49,129, 80,129,
+ 87,236,239,119, 2,129, 57,129, 68,236,229,230,244,244,232,225,
+ 105,128,248,140,242,233,231,232,244,244,232,225,105,128,248,139,
+ 244,232,225,105,128, 14, 72,245,240,240,229,242,236,229,230,244,
+ 244,232,225,105,128,248,138,232,225,238,225,235,225,116, 2,129,
+ 115,129,126,236,229,230,244,244,232,225,105,128,248,132,244,232,
+ 225,105,128, 14, 49,116, 3,129,141,129,169,129,232,225,233,235,
+ 232,117, 2,129,151,129,162,236,229,230,244,244,232,225,105,128,
+ 248,137,244,232,225,105,128, 14, 71,232,111, 3,129,178,129,209,
+ 129,216,236,239,119, 2,129,186,129,197,236,229,230,244,244,232,
+ 225,105,128,248,143,242,233,231,232,244,244,232,225,105,128,248,
+ 142,244,232,225,105,128, 14, 73,245,240,240,229,242,236,229,230,
+ 244,244,232,225,105,128,248,141,242,105, 3,129,241,130, 16,130,
+ 23,236,239,119, 2,129,249,130, 4,236,229,230,244,244,232,225,
+ 105,128,248,146,242,233,231,232,244,244,232,225,105,128,248,145,
+ 244,232,225,105,128, 14, 74,245,240,240,229,242,236,229,230,244,
+ 244,232,225,105,128,248,144,249,225,237,239,235,244,232,225,105,
+ 128, 14, 70,235,225,244,225,235,225,238, 97,129, 48,222,130, 64,
+ 232,225,236,230,247,233,228,244,104,128,255,143,236,101,128, 38,
+ 66,238,243,249,239,238,243,241,245,225,242,101,128, 51, 71,241,
+ 225,230,232,229,226,242,229,119,128, 5,190,242,115,128, 38, 66,
+ 115, 2,130,118,130,136,239,242,225,227,233,242,227,236,229,232,
+ 229,226,242,229,119,128, 5,175,241,245,225,242,101,128, 51,131,
+ 98, 2,130,150,130,160,239,240,239,237,239,230,111,128, 49, 7,
+ 243,241,245,225,242,101,128, 51,212, 99, 2,130,175,130,183,233,
+ 242,227,236,101,128, 36,220,245,226,229,228,243,241,245,225,242,
+ 101,128, 51,165,228,239,116, 2,130,204,130,213,225,227,227,229,
+ 238,116,128, 30, 65,226,229,236,239,119,128, 30, 67,101, 7,130,
+ 237,131,108,131,119,131,134,131,159,131,196,131,208,101, 2,130,
+ 243,131, 95,109, 4,130,253,131, 6,131, 20,131, 36,225,242,225,
+ 226,233, 99,128, 6, 69,230,233,238,225,236,225,242,225,226,233,
+ 99,128,254,226,233,238,233,244,233,225,236,225,242,225,226,233,
+ 99,128,254,227,237,101, 2,131, 43,131, 56,228,233,225,236,225,
+ 242,225,226,233, 99,128,254,228,229,237,105, 2,131, 64,131, 79,
+ 238,233,244,233,225,236,225,242,225,226,233, 99,128,252,209,243,
+ 239,236,225,244,229,228,225,242,225,226,233, 99,128,252, 72,244,
+ 239,242,245,243,241,245,225,242,101,128, 51, 77,232,233,242,225,
+ 231,225,238, 97,128, 48,129,233,250,233,229,242,225,243,241,245,
+ 225,242,101,128, 51,126,235,225,244,225,235,225,238, 97,129, 48,
+ 225,131,147,232,225,236,230,247,233,228,244,104,128,255,146,109,
+ 130, 5,222,131,167,131,187,228,225,231,229,243,104,129,251, 62,
+ 131,178,232,229,226,242,229,119,128,251, 62,232,229,226,242,229,
+ 119,128, 5,222,238,225,242,237,229,238,233,225,110,128, 5,116,
+ 242,235,232, 97, 3,131,219,131,228,132, 5,232,229,226,242,229,
+ 119,128, 5,165,235,229,230,245,236, 97, 2,131,239,131,248,232,
+ 229,226,242,229,119,128, 5,166,236,229,230,244,232,229,226,242,
+ 229,119,128, 5,166,236,229,230,244,232,229,226,242,229,119,128,
+ 5,165,104, 2,132, 24,132, 30,239,239,107,128, 2,113,250,243,
+ 241,245,225,242,101,128, 51,146,105, 6,132, 54,132, 91,132,228,
+ 132,239,133, 8,133, 65,228,100, 2,132, 61,132, 86,236,229,228,
+ 239,244,235,225,244,225,235,225,238,225,232,225,236,230,247,233,
+ 228,244,104,128,255,101,239,116,128, 0,183,229,245,109, 5,132,
+ 105,132,140,132,155,132,164,132,215, 97, 2,132,111,132,126,227,
+ 233,242,227,236,229,235,239,242,229,225,110,128, 50,114,240,225,
+ 242,229,238,235,239,242,229,225,110,128, 50, 18,227,233,242,227,
+ 236,229,235,239,242,229,225,110,128, 50,100,235,239,242,229,225,
+ 110,128, 49, 65,112, 2,132,170,132,202, 97, 2,132,176,132,190,
+ 238,243,233,239,243,235,239,242,229,225,110,128, 49,112,242,229,
+ 238,235,239,242,229,225,110,128, 50, 4,233,229,245,240,235,239,
+ 242,229,225,110,128, 49,110,243,233,239,243,235,239,242,229,225,
+ 110,128, 49,111,232,233,242,225,231,225,238, 97,128, 48,127,235,
+ 225,244,225,235,225,238, 97,129, 48,223,132,252,232,225,236,230,
+ 247,233,228,244,104,128,255,144,238,117, 2,133, 15,133, 60,115,
+ 132, 34, 18,133, 27,133, 38,133, 47,133, 53,226,229,236,239,247,
+ 227,237, 98,128, 3, 32,227,233,242,227,236,101,128, 34,150,237,
+ 239,100,128, 2,215,240,236,245,115,128, 34, 19,244,101,128, 32,
+ 50,242,105, 2,133, 72,133, 86,226,225,225,242,245,243,241,245,
+ 225,242,101,128, 51, 74,243,241,245,225,242,101,128, 51, 73,108,
+ 2,133,101,133,116,239,238,231,236,229,231,244,245,242,238,229,
+ 100,128, 2,112,243,241,245,225,242,101,128, 51,150,109, 3,133,
+ 133,133,147,133,158,227,245,226,229,228,243,241,245,225,242,101,
+ 128, 51,163,239,238,239,243,240,225,227,101,128,255, 77,243,241,
+ 245,225,242,229,228,243,241,245,225,242,101,128, 51,159,111, 5,
+ 133,186,133,212,133,237,133,247,134, 0,104, 2,133,192,133,202,
+ 233,242,225,231,225,238, 97,128, 48,130,237,243,241,245,225,242,
+ 101,128, 51,193,235,225,244,225,235,225,238, 97,129, 48,226,133,
+ 225,232,225,236,230,247,233,228,244,104,128,255,147,236,243,241,
+ 245,225,242,101,128, 51,214,237,225,244,232,225,105,128, 14, 33,
+ 246,229,242,243,243,241,245,225,242,101,129, 51,167,134, 15,228,
+ 243,241,245,225,242,101,128, 51,168,240, 97, 2,134, 32,134, 38,
+ 242,229,110,128, 36,168,243,241,245,225,242,101,128, 51,171,115,
+ 2,134, 53,134, 62,243,241,245,225,242,101,128, 51,179,245,240,
+ 229,242,233,239,114,128,246,239,244,245,242,238,229,100,128, 2,
+ 111,117,141, 0,181,134,111,134,115,134,125,134,149,134,159,134,
+ 181,134,192,134,217,134,240,134,250,135, 24,135, 88,135, 98, 49,
+ 128, 0,181,225,243,241,245,225,242,101,128, 51,130,227,104, 2,
+ 134,132,134,142,231,242,229,225,244,229,114,128, 34,107,236,229,
+ 243,115,128, 34,106,230,243,241,245,225,242,101,128, 51,140,103,
+ 2,134,165,134,172,242,229,229,107,128, 3,188,243,241,245,225,
+ 242,101,128, 51,141,232,233,242,225,231,225,238, 97,128, 48,128,
+ 235,225,244,225,235,225,238, 97,129, 48,224,134,205,232,225,236,
+ 230,247,233,228,244,104,128,255,145,108, 2,134,223,134,232,243,
+ 241,245,225,242,101,128, 51,149,244,233,240,236,121,128, 0,215,
+ 237,243,241,245,225,242,101,128, 51,155,238,225,104, 2,135, 2,
+ 135, 11,232,229,226,242,229,119,128, 5,163,236,229,230,244,232,
+ 229,226,242,229,119,128, 5,163,115, 2,135, 30,135, 79,233, 99,
+ 3,135, 39,135, 56,135, 67,225,236,238,239,244,101,129, 38,106,
+ 135, 50,228,226,108,128, 38,107,230,236,225,244,243,233,231,110,
+ 128, 38,109,243,232,225,242,240,243,233,231,110,128, 38,111,243,
+ 241,245,225,242,101,128, 51,178,246,243,241,245,225,242,101,128,
+ 51,182,247,243,241,245,225,242,101,128, 51,188,118, 2,135,114,
+ 135,127,237,229,231,225,243,241,245,225,242,101,128, 51,185,243,
+ 241,245,225,242,101,128, 51,183,119, 2,135,142,135,155,237,229,
+ 231,225,243,241,245,225,242,101,128, 51,191,243,241,245,225,242,
+ 101,128, 51,189,110,150, 0,110,135,212,136, 90,136,114,136,180,
+ 136,205,137, 7,137, 17,137, 84,137,127,139,161,139,179,139,204,
+ 139,235,140, 5,140, 70,142, 52,142, 60,142, 85,142, 93,143, 61,
+ 143, 71,143, 81, 97, 8,135,230,135,250,136, 1,136, 8,136, 33,
+ 136, 44,136, 69,136, 81, 98, 2,135,236,135,245,229,238,231,225,
+ 236,105,128, 9,168,236, 97,128, 34, 7,227,245,244,101,128, 1,
+ 68,228,229,246, 97,128, 9, 40,231,117, 2,136, 15,136, 24,234,
+ 225,242,225,244,105,128, 10,168,242,237,245,235,232,105,128, 10,
+ 40,232,233,242,225,231,225,238, 97,128, 48,106,235,225,244,225,
+ 235,225,238, 97,129, 48,202,136, 57,232,225,236,230,247,233,228,
+ 244,104,128,255,133,240,239,243,244,242,239,240,232,101,128, 1,
+ 73,243,241,245,225,242,101,128, 51,129, 98, 2,136, 96,136,106,
+ 239,240,239,237,239,230,111,128, 49, 11,243,240,225,227,101,128,
+ 0,160, 99, 4,136,124,136,131,136,140,136,167,225,242,239,110,
+ 128, 1, 72,229,228,233,236,236, 97,128, 1, 70,233,242, 99, 2,
+ 136,148,136,153,236,101,128, 36,221,245,237,230,236,229,248,226,
+ 229,236,239,119,128, 30, 75,239,237,237,225,225,227,227,229,238,
+ 116,128, 1, 70,228,239,116, 2,136,188,136,197,225,227,227,229,
+ 238,116,128, 30, 69,226,229,236,239,119,128, 30, 71,101, 3,136,
+ 213,136,224,136,249,232,233,242,225,231,225,238, 97,128, 48,109,
+ 235,225,244,225,235,225,238, 97,129, 48,205,136,237,232,225,236,
+ 230,247,233,228,244,104,128,255,136,247,243,232,229,241,229,236,
+ 243,233,231,110,128, 32,170,230,243,241,245,225,242,101,128, 51,
+ 139,103, 2,137, 23,137, 73, 97, 3,137, 31,137, 41,137, 48,226,
+ 229,238,231,225,236,105,128, 9,153,228,229,246, 97,128, 9, 25,
+ 231,117, 2,137, 55,137, 64,234,225,242,225,244,105,128, 10,153,
+ 242,237,245,235,232,105,128, 10, 25,239,238,231,245,244,232,225,
+ 105,128, 14, 7,104, 2,137, 90,137,100,233,242,225,231,225,238,
+ 97,128, 48,147,239,239,107, 2,137,108,137,115,236,229,230,116,
+ 128, 2,114,242,229,244,242,239,230,236,229,120,128, 2,115,105,
+ 4,137,137,138, 50,138, 61,138,119,229,245,110, 7,137,155,137,
+ 190,137,222,137,236,137,245,138, 22,138, 35, 97, 2,137,161,137,
+ 176,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,111,
+ 240,225,242,229,238,235,239,242,229,225,110,128, 50, 15,227,105,
+ 2,137,197,137,209,229,245,227,235,239,242,229,225,110,128, 49,
+ 53,242,227,236,229,235,239,242,229,225,110,128, 50, 97,232,233,
+ 229,245,232,235,239,242,229,225,110,128, 49, 54,235,239,242,229,
+ 225,110,128, 49, 52,240, 97, 2,137,252,138, 10,238,243,233,239,
+ 243,235,239,242,229,225,110,128, 49,104,242,229,238,235,239,242,
+ 229,225,110,128, 50, 1,243,233,239,243,235,239,242,229,225,110,
+ 128, 49,103,244,233,235,229,245,244,235,239,242,229,225,110,128,
+ 49,102,232,233,242,225,231,225,238, 97,128, 48,107,107, 2,138,
+ 67,138, 91,225,244,225,235,225,238, 97,129, 48,203,138, 79,232,
+ 225,236,230,247,233,228,244,104,128,255,134,232,225,232,233,116,
+ 2,138,101,138,112,236,229,230,244,244,232,225,105,128,248,153,
+ 244,232,225,105,128, 14, 77,238,101,141, 0, 57,138,150,138,159,
+ 138,169,138,199,138,206,138,231,139, 2,139, 36,139, 48,139, 59,
+ 139, 92,139,100,139,111,225,242,225,226,233, 99,128, 6,105,226,
+ 229,238,231,225,236,105,128, 9,239,227,233,242,227,236,101,129,
+ 36,104,138,180,233,238,246,229,242,243,229,243,225,238,243,243,
+ 229,242,233,102,128, 39,146,228,229,246, 97,128, 9,111,231,117,
+ 2,138,213,138,222,234,225,242,225,244,105,128, 10,239,242,237,
+ 245,235,232,105,128, 10,111,232, 97, 2,138,238,138,249,227,235,
+ 225,242,225,226,233, 99,128, 6,105,238,231,250,232,239,117,128,
+ 48, 41,105, 2,139, 8,139, 26,228,229,239,231,242,225,240,232,
+ 233,227,240,225,242,229,110,128, 50, 40,238,230,229,242,233,239,
+ 114,128, 32,137,237,239,238,239,243,240,225,227,101,128,255, 25,
+ 239,236,228,243,244,249,236,101,128,247, 57,112, 2,139, 65,139,
+ 72,225,242,229,110,128, 36,124,229,114, 2,139, 79,139, 85,233,
+ 239,100,128, 36,144,243,233,225,110,128, 6,249,242,239,237,225,
+ 110,128, 33,120,243,245,240,229,242,233,239,114,128, 32,121,116,
+ 2,139,117,139,155,229,229,110, 2,139,125,139,134,227,233,242,
+ 227,236,101,128, 36,114,112, 2,139,140,139,147,225,242,229,110,
+ 128, 36,134,229,242,233,239,100,128, 36,154,232,225,105,128, 14,
+ 89,106,129, 1,204,139,167,229,227,249,242,233,236,236,233, 99,
+ 128, 4, 90,235,225,244,225,235,225,238, 97,129, 48,243,139,192,
+ 232,225,236,230,247,233,228,244,104,128,255,157,108, 2,139,210,
+ 139,224,229,231,242,233,231,232,244,236,239,238,103,128, 1,158,
+ 233,238,229,226,229,236,239,119,128, 30, 73,109, 2,139,241,139,
+ 252,239,238,239,243,240,225,227,101,128,255, 78,243,241,245,225,
+ 242,101,128, 51,154,110, 2,140, 11,140, 61, 97, 3,140, 19,140,
+ 29,140, 36,226,229,238,231,225,236,105,128, 9,163,228,229,246,
+ 97,128, 9, 35,231,117, 2,140, 43,140, 52,234,225,242,225,244,
+ 105,128, 10,163,242,237,245,235,232,105,128, 10, 35,238,225,228,
+ 229,246, 97,128, 9, 41,111, 6,140, 84,140, 95,140,120,140,161,
+ 141,113,142, 40,232,233,242,225,231,225,238, 97,128, 48,110,235,
+ 225,244,225,235,225,238, 97,129, 48,206,140,108,232,225,236,230,
+ 247,233,228,244,104,128,255,137,110, 3,140,128,140,144,140,153,
+ 226,242,229,225,235,233,238,231,243,240,225,227,101,128, 0,160,
+ 229,238,244,232,225,105,128, 14, 19,245,244,232,225,105,128, 14,
+ 25,239,110, 7,140,178,140,187,140,201,140,235,140,251,141, 36,
+ 141, 95,225,242,225,226,233, 99,128, 6, 70,230,233,238,225,236,
+ 225,242,225,226,233, 99,128,254,230,231,232,245,238,238, 97, 2,
+ 140,212,140,221,225,242,225,226,233, 99,128, 6,186,230,233,238,
+ 225,236,225,242,225,226,233, 99,128,251,159,233,238,233,244,233,
+ 225,236,225,242,225,226,233, 99,128,254,231,234,229,229,237,105,
+ 2,141, 5,141, 20,238,233,244,233,225,236,225,242,225,226,233,
+ 99,128,252,210,243,239,236,225,244,229,228,225,242,225,226,233,
+ 99,128,252, 75,237,101, 2,141, 43,141, 56,228,233,225,236,225,
+ 242,225,226,233, 99,128,254,232,229,237,105, 2,141, 64,141, 79,
+ 238,233,244,233,225,236,225,242,225,226,233, 99,128,252,213,243,
+ 239,236,225,244,229,228,225,242,225,226,233, 99,128,252, 78,238,
+ 239,239,238,230,233,238,225,236,225,242,225,226,233, 99,128,252,
+ 141,116, 7,141,129,141,140,141,169,141,204,141,216,141,236,142,
+ 6,227,239,238,244,225,233,238,115,128, 34, 12,101, 2,141,146,
+ 141,162,236,229,237,229,238,116,129, 34, 9,141,157,239,102,128,
+ 34, 9,241,245,225,108,128, 34, 96,231,242,229,225,244,229,114,
+ 129, 34,111,141,181,238,239,114, 2,141,189,141,197,229,241,245,
+ 225,108,128, 34,113,236,229,243,115,128, 34,121,233,228,229,238,
+ 244,233,227,225,108,128, 34, 98,236,229,243,115,129, 34,110,141,
+ 225,238,239,242,229,241,245,225,108,128, 34,112,112, 2,141,242,
+ 141,252,225,242,225,236,236,229,108,128, 34, 38,242,229,227,229,
+ 228,229,115,128, 34,128,243,117, 3,142, 15,142, 22,142, 31,226,
+ 243,229,116,128, 34,132,227,227,229,229,228,115,128, 34,129,240,
+ 229,242,243,229,116,128, 34,133,247,225,242,237,229,238,233,225,
+ 110,128, 5,118,240,225,242,229,110,128, 36,169,115, 2,142, 66,
+ 142, 75,243,241,245,225,242,101,128, 51,177,245,240,229,242,233,
+ 239,114,128, 32,127,244,233,236,228,101,128, 0,241,117,132, 3,
+ 189,142,105,142,116,142,197,143, 24,232,233,242,225,231,225,238,
+ 97,128, 48,108,107, 2,142,122,142,146,225,244,225,235,225,238,
+ 97,129, 48,204,142,134,232,225,236,230,247,233,228,244,104,128,
+ 255,135,244, 97, 3,142,155,142,165,142,172,226,229,238,231,225,
+ 236,105,128, 9,188,228,229,246, 97,128, 9, 60,231,117, 2,142,
+ 179,142,188,234,225,242,225,244,105,128, 10,188,242,237,245,235,
+ 232,105,128, 10, 60,109, 2,142,203,142,237,226,229,242,243,233,
+ 231,110,130, 0, 35,142,217,142,229,237,239,238,239,243,240,225,
+ 227,101,128,255, 3,243,237,225,236,108,128,254, 95,229,114, 2,
+ 142,244,143, 20,225,236,243,233,231,110, 2,142,255,143, 7,231,
+ 242,229,229,107,128, 3,116,236,239,247,229,242,231,242,229,229,
+ 107,128, 3,117,111,128, 33, 22,110,130, 5,224,143, 32,143, 52,
+ 228,225,231,229,243,104,129,251, 64,143, 43,232,229,226,242,229,
+ 119,128,251, 64,232,229,226,242,229,119,128, 5,224,246,243,241,
+ 245,225,242,101,128, 51,181,247,243,241,245,225,242,101,128, 51,
+ 187,249, 97, 3,143, 90,143,100,143,107,226,229,238,231,225,236,
+ 105,128, 9,158,228,229,246, 97,128, 9, 30,231,117, 2,143,114,
+ 143,123,234,225,242,225,244,105,128, 10,158,242,237,245,235,232,
+ 105,128, 10, 30,111,147, 0,111,143,174,143,196,144, 18,144,188,
+ 145, 4,145, 19,145, 59,145,182,145,203,145,241,145,252,146,174,
+ 148, 8,148, 72,148,105,148,151,149, 24,149, 71,149, 83, 97, 2,
+ 143,180,143,187,227,245,244,101,128, 0,243,238,231,244,232,225,
+ 105,128, 14, 45, 98, 4,143,206,143,248,144, 1,144, 11,225,242,
+ 242,229,100,130, 2,117,143,218,143,229,227,249,242,233,236,236,
+ 233, 99,128, 4,233,228,233,229,242,229,243,233,243,227,249,242,
+ 233,236,236,233, 99,128, 4,235,229,238,231,225,236,105,128, 9,
+ 147,239,240,239,237,239,230,111,128, 49, 27,242,229,246,101,128,
+ 1, 79, 99, 3,144, 26,144, 99,144,178, 97, 2,144, 32,144, 93,
+ 238,228,242, 97, 3,144, 43,144, 50,144, 61,228,229,246, 97,128,
+ 9, 17,231,245,234,225,242,225,244,105,128, 10,145,246,239,247,
+ 229,236,243,233,231,110, 2,144, 75,144, 82,228,229,246, 97,128,
+ 9, 73,231,245,234,225,242,225,244,105,128, 10,201,242,239,110,
+ 128, 1,210,233,242, 99, 2,144,107,144,112,236,101,128, 36,222,
+ 245,237,230,236,229,120,133, 0,244,144,131,144,139,144,150,144,
+ 158,144,170,225,227,245,244,101,128, 30,209,228,239,244,226,229,
+ 236,239,119,128, 30,217,231,242,225,246,101,128, 30,211,232,239,
+ 239,235,225,226,239,246,101,128, 30,213,244,233,236,228,101,128,
+ 30,215,249,242,233,236,236,233, 99,128, 4, 62,100, 4,144,198,
+ 144,221,144,227,144,250,226,108, 2,144,205,144,213,225,227,245,
+ 244,101,128, 1, 81,231,242,225,246,101,128, 2, 13,229,246, 97,
+ 128, 9, 19,233,229,242,229,243,233,115,129, 0,246,144,239,227,
+ 249,242,233,236,236,233, 99,128, 4,231,239,244,226,229,236,239,
+ 119,128, 30,205,101,129, 1, 83,145, 10,235,239,242,229,225,110,
+ 128, 49, 90,103, 3,145, 27,145, 42,145, 49,239,238,229,107,129,
+ 2,219,145, 36,227,237, 98,128, 3, 40,242,225,246,101,128, 0,
+ 242,245,234,225,242,225,244,105,128, 10,147,104, 4,145, 69,145,
+ 80,145, 90,145,168,225,242,237,229,238,233,225,110,128, 5,133,
+ 233,242,225,231,225,238, 97,128, 48, 74,111, 2,145, 96,145,106,
+ 239,235,225,226,239,246,101,128, 30,207,242,110,133, 1,161,145,
+ 121,145,129,145,140,145,148,145,160,225,227,245,244,101,128, 30,
+ 219,228,239,244,226,229,236,239,119,128, 30,227,231,242,225,246,
+ 101,128, 30,221,232,239,239,235,225,226,239,246,101,128, 30,223,
+ 244,233,236,228,101,128, 30,225,245,238,231,225,242,245,237,236,
+ 225,245,116,128, 1, 81,105,129, 1,163,145,188,238,246,229,242,
+ 244,229,228,226,242,229,246,101,128, 2, 15,107, 2,145,209,145,
+ 233,225,244,225,235,225,238, 97,129, 48,170,145,221,232,225,236,
+ 230,247,233,228,244,104,128,255,117,239,242,229,225,110,128, 49,
+ 87,236,229,232,229,226,242,229,119,128, 5,171,109, 6,146, 10,
+ 146, 38,146, 45,146,134,146,145,146,163,225,227,242,239,110,130,
+ 1, 77,146, 22,146, 30,225,227,245,244,101,128, 30, 83,231,242,
+ 225,246,101,128, 30, 81,228,229,246, 97,128, 9, 80,229,231, 97,
+ 133, 3,201,146, 61,146, 65,146, 76,146, 90,146,106, 49,128, 3,
+ 214,227,249,242,233,236,236,233, 99,128, 4, 97,236,225,244,233,
+ 238,227,236,239,243,229,100,128, 2,119,242,239,245,238,228,227,
+ 249,242,233,236,236,233, 99,128, 4,123,116, 2,146,112,146,127,
+ 233,244,236,239,227,249,242,233,236,236,233, 99,128, 4,125,239,
+ 238,239,115,128, 3,206,231,245,234,225,242,225,244,105,128, 10,
+ 208,233,227,242,239,110,129, 3,191,146,155,244,239,238,239,115,
+ 128, 3,204,239,238,239,243,240,225,227,101,128,255, 79,238,101,
+ 145, 0, 49,146,213,146,222,146,232,147, 6,147, 31,147, 40,147,
+ 49,147, 74,147,108,147,142,147,154,147,173,147,184,147,217,147,
+ 227,147,235,147,246,225,242,225,226,233, 99,128, 6, 97,226,229,
+ 238,231,225,236,105,128, 9,231,227,233,242,227,236,101,129, 36,
+ 96,146,243,233,238,246,229,242,243,229,243,225,238,243,243,229,
+ 242,233,102,128, 39,138,100, 2,147, 12,147, 18,229,246, 97,128,
+ 9,103,239,244,229,238,236,229,225,228,229,114,128, 32, 36,229,
+ 233,231,232,244,104,128, 33, 91,230,233,244,244,229,100,128,246,
+ 220,231,117, 2,147, 56,147, 65,234,225,242,225,244,105,128, 10,
+ 231,242,237,245,235,232,105,128, 10,103,232, 97, 3,147, 83,147,
+ 94,147, 99,227,235,225,242,225,226,233, 99,128, 6, 97,236,102,
+ 128, 0,189,238,231,250,232,239,117,128, 48, 33,105, 2,147,114,
+ 147,132,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
+ 110,128, 50, 32,238,230,229,242,233,239,114,128, 32,129,237,239,
+ 238,239,243,240,225,227,101,128,255, 17,238,245,237,229,242,225,
+ 244,239,242,226,229,238,231,225,236,105,128, 9,244,239,236,228,
+ 243,244,249,236,101,128,247, 49,112, 2,147,190,147,197,225,242,
+ 229,110,128, 36,116,229,114, 2,147,204,147,210,233,239,100,128,
+ 36,136,243,233,225,110,128, 6,241,241,245,225,242,244,229,114,
+ 128, 0,188,242,239,237,225,110,128, 33,112,243,245,240,229,242,
+ 233,239,114,128, 0,185,244,104, 2,147,253,148, 2,225,105,128,
+ 14, 81,233,242,100,128, 33, 83,111, 3,148, 16,148, 50,148, 66,
+ 103, 2,148, 22,148, 40,239,238,229,107,129, 1,235,148, 31,237,
+ 225,227,242,239,110,128, 1,237,245,242,237,245,235,232,105,128,
+ 10, 19,237,225,244,242,225,231,245,242,237,245,235,232,105,128,
+ 10, 75,240,229,110,128, 2, 84,112, 3,148, 80,148, 87,148, 98,
+ 225,242,229,110,128, 36,170,229,238,226,245,236,236,229,116,128,
+ 37,230,244,233,239,110,128, 35, 37,114, 2,148,111,148,140,100,
+ 2,148,117,148,128,230,229,237,233,238,233,238,101,128, 0,170,
+ 237,225,243,227,245,236,233,238,101,128, 0,186,244,232,239,231,
+ 239,238,225,108,128, 34, 31,115, 5,148,163,148,195,148,212,149,
+ 1,149, 14,232,239,242,116, 2,148,172,148,179,228,229,246, 97,
+ 128, 9, 18,246,239,247,229,236,243,233,231,238,228,229,246, 97,
+ 128, 9, 74,236,225,243,104,129, 0,248,148,204,225,227,245,244,
+ 101,128, 1,255,237,225,236,108, 2,148,221,148,232,232,233,242,
+ 225,231,225,238, 97,128, 48, 73,235,225,244,225,235,225,238, 97,
+ 129, 48,169,148,245,232,225,236,230,247,233,228,244,104,128,255,
+ 107,244,242,239,235,229,225,227,245,244,101,128, 1,255,245,240,
+ 229,242,233,239,114,128,246,240,116, 2,149, 30,149, 41,227,249,
+ 242,233,236,236,233, 99,128, 4,127,233,236,228,101,130, 0,245,
+ 149, 52,149, 60,225,227,245,244,101,128, 30, 77,228,233,229,242,
+ 229,243,233,115,128, 30, 79,245,226,239,240,239,237,239,230,111,
+ 128, 49, 33,118, 2,149, 89,149,170,229,114, 2,149, 96,149,162,
+ 236,233,238,101,131, 32, 62,149,109,149,132,149,155, 99, 2,149,
+ 115,149,127,229,238,244,229,242,236,233,238,101,128,254, 74,237,
+ 98,128, 3, 5,100, 2,149,138,149,146,225,243,232,229,100,128,
+ 254, 73,226,236,247,225,246,121,128,254, 76,247,225,246,121,128,
+ 254, 75,243,227,239,242,101,128, 0,175,239,247,229,236,243,233,
+ 231,110, 3,149,185,149,195,149,202,226,229,238,231,225,236,105,
+ 128, 9,203,228,229,246, 97,128, 9, 75,231,245,234,225,242,225,
+ 244,105,128, 10,203,112,145, 0,112,149,251,152,123,152,134,152,
+ 143,152,155,154, 80,154, 90,155, 82,156,101,156,191,156,217,157,
+ 92,157,100,158, 2,158, 60,158, 88,158, 98, 97, 14,150, 25,150,
+ 57,150, 67,150, 74,150, 81,150,129,150,140,150,154,150,165,150,
+ 212,150,226,151,238,152, 21,152,111, 97, 2,150, 31,150, 43,237,
+ 240,243,243,241,245,225,242,101,128, 51,128,243,229,238,244,239,
+ 243,241,245,225,242,101,128, 51, 43,226,229,238,231,225,236,105,
+ 128, 9,170,227,245,244,101,128, 30, 85,228,229,246, 97,128, 9,
+ 42,103, 2,150, 87,150,105,101, 2,150, 93,150,100,228,239,247,
+ 110,128, 33,223,245,112,128, 33,222,117, 2,150,111,150,120,234,
+ 225,242,225,244,105,128, 10,170,242,237,245,235,232,105,128, 10,
+ 42,232,233,242,225,231,225,238, 97,128, 48,113,233,249,225,238,
+ 238,239,233,244,232,225,105,128, 14, 47,235,225,244,225,235,225,
+ 238, 97,128, 48,209,108, 2,150,171,150,196,225,244,225,236,233,
+ 250,225,244,233,239,238,227,249,242,233,236,236,233,227,227,237,
+ 98,128, 4,132,239,227,232,235,225,227,249,242,233,236,236,233,
+ 99,128, 4,192,238,243,233,239,243,235,239,242,229,225,110,128,
+ 49,127,114, 3,150,234,150,255,151,227, 97, 2,150,240,150,248,
+ 231,242,225,240,104,128, 0,182,236,236,229,108,128, 34, 37,229,
+ 110, 2,151, 6,151,116,236,229,230,116,136, 0, 40,151, 29,151,
+ 44,151, 49,151, 54,151, 65,151, 77,151,100,151,105,225,236,244,
+ 239,238,229,225,242,225,226,233, 99,128,253, 62,226,116,128,248,
+ 237,229,120,128,248,236,233,238,230,229,242,233,239,114,128, 32,
+ 141,237,239,238,239,243,240,225,227,101,128,255, 8,115, 2,151,
+ 83,151, 90,237,225,236,108,128,254, 89,245,240,229,242,233,239,
+ 114,128, 32,125,244,112,128,248,235,246,229,242,244,233,227,225,
+ 108,128,254, 53,242,233,231,232,116,136, 0, 41,151,140,151,155,
+ 151,160,151,165,151,176,151,188,151,211,151,216,225,236,244,239,
+ 238,229,225,242,225,226,233, 99,128,253, 63,226,116,128,248,248,
+ 229,120,128,248,247,233,238,230,229,242,233,239,114,128, 32,142,
+ 237,239,238,239,243,240,225,227,101,128,255, 9,115, 2,151,194,
+ 151,201,237,225,236,108,128,254, 90,245,240,229,242,233,239,114,
+ 128, 32,126,244,112,128,248,246,246,229,242,244,233,227,225,108,
+ 128,254, 54,244,233,225,236,228,233,230,102,128, 34, 2,115, 3,
+ 151,246,152, 1,152, 13,229,241,232,229,226,242,229,119,128, 5,
+ 192,232,244,225,232,229,226,242,229,119,128, 5,153,241,245,225,
+ 242,101,128, 51,169,244,225,104,134, 5,183,152, 39,152, 53,152,
+ 58,152, 67,152, 82,152, 98, 49, 2,152, 45,152, 49, 49,128, 5,
+ 183,100,128, 5,183,178, 97,128, 5,183,232,229,226,242,229,119,
+ 128, 5,183,238,225,242,242,239,247,232,229,226,242,229,119,128,
+ 5,183,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
+ 5,183,247,233,228,229,232,229,226,242,229,119,128, 5,183,250,
+ 229,242,232,229,226,242,229,119,128, 5,161,226,239,240,239,237,
+ 239,230,111,128, 49, 6,227,233,242,227,236,101,128, 36,223,228,
+ 239,244,225,227,227,229,238,116,128, 30, 87,101,137, 5,228,152,
+ 177,152,188,152,208,152,220,152,240,153, 86,153, 97,153,118,154,
+ 73,227,249,242,233,236,236,233, 99,128, 4, 63,228,225,231,229,
+ 243,104,129,251, 68,152,199,232,229,226,242,229,119,128,251, 68,
+ 229,250,233,243,241,245,225,242,101,128, 51, 59,230,233,238,225,
+ 236,228,225,231,229,243,232,232,229,226,242,229,119,128,251, 67,
+ 104, 5,152,252,153, 19,153, 27,153, 41,153, 71,225,114, 2,153,
+ 3,153, 10,225,226,233, 99,128, 6,126,237,229,238,233,225,110,
+ 128, 5,122,229,226,242,229,119,128, 5,228,230,233,238,225,236,
+ 225,242,225,226,233, 99,128,251, 87,105, 2,153, 47,153, 62,238,
+ 233,244,233,225,236,225,242,225,226,233, 99,128,251, 88,242,225,
+ 231,225,238, 97,128, 48,122,237,229,228,233,225,236,225,242,225,
+ 226,233, 99,128,251, 89,235,225,244,225,235,225,238, 97,128, 48,
+ 218,237,233,228,228,236,229,232,239,239,235,227,249,242,233,236,
+ 236,233, 99,128, 4,167,114, 5,153,130,153,142,153,184,154, 49,
+ 154, 62,225,230,229,232,229,226,242,229,119,128,251, 78,227,229,
+ 238,116,131, 0, 37,153,155,153,164,153,176,225,242,225,226,233,
+ 99,128, 6,106,237,239,238,239,243,240,225,227,101,128,255, 5,
+ 243,237,225,236,108,128,254,106,105, 2,153,190,154, 31,239,100,
+ 134, 0, 46,153,207,153,218,153,229,153,241,153,252,154, 8,225,
+ 242,237,229,238,233,225,110,128, 5,137,227,229,238,244,229,242,
+ 229,100,128, 0,183,232,225,236,230,247,233,228,244,104,128,255,
+ 97,233,238,230,229,242,233,239,114,128,246,231,237,239,238,239,
+ 243,240,225,227,101,128,255, 14,115, 2,154, 14,154, 21,237,225,
+ 236,108,128,254, 82,245,240,229,242,233,239,114,128,246,232,243,
+ 240,239,237,229,238,233,231,242,229,229,235,227,237, 98,128, 3,
+ 66,240,229,238,228,233,227,245,236,225,114,128, 34,165,244,232,
+ 239,245,243,225,238,100,128, 32, 48,243,229,244, 97,128, 32,167,
+ 230,243,241,245,225,242,101,128, 51,138,104, 3,154, 98,154,148,
+ 155, 29, 97, 3,154,106,154,116,154,123,226,229,238,231,225,236,
+ 105,128, 9,171,228,229,246, 97,128, 9, 43,231,117, 2,154,130,
+ 154,139,234,225,242,225,244,105,128, 10,171,242,237,245,235,232,
+ 105,128, 10, 43,105,133, 3,198,154,162,154,166,154,252,155, 4,
+ 155, 15, 49,128, 3,213,229,245,240,104, 4,154,179,154,214,154,
+ 229,154,238, 97, 2,154,185,154,200,227,233,242,227,236,229,235,
+ 239,242,229,225,110,128, 50,122,240,225,242,229,238,235,239,242,
+ 229,225,110,128, 50, 26,227,233,242,227,236,229,235,239,242,229,
+ 225,110,128, 50,108,235,239,242,229,225,110,128, 49, 77,240,225,
+ 242,229,238,235,239,242,229,225,110,128, 50, 12,236,225,244,233,
+ 110,128, 2,120,238,244,232,245,244,232,225,105,128, 14, 58,243,
+ 249,237,226,239,236,231,242,229,229,107,128, 3,213,111, 3,155,
+ 37,155, 42,155, 68,239,107,128, 1,165,240,104, 2,155, 49,155,
+ 58,225,238,244,232,225,105,128, 14, 30,245,238,231,244,232,225,
+ 105,128, 14, 28,243,225,237,240,232,225,239,244,232,225,105,128,
+ 14, 32,105,133, 3,192,155, 96,156, 52,156, 63,156, 74,156, 88,
+ 229,245,112, 6,155,112,155,147,155,179,155,207,155,221,156, 17,
+ 97, 2,155,118,155,133,227,233,242,227,236,229,235,239,242,229,
+ 225,110,128, 50,115,240,225,242,229,238,235,239,242,229,225,110,
+ 128, 50, 19,227,105, 2,155,154,155,166,229,245,227,235,239,242,
+ 229,225,110,128, 49,118,242,227,236,229,235,239,242,229,225,110,
+ 128, 50,101,107, 2,155,185,155,199,233,249,229,239,235,235,239,
+ 242,229,225,110,128, 49,114,239,242,229,225,110,128, 49, 66,240,
+ 225,242,229,238,235,239,242,229,225,110,128, 50, 5,243,233,239,
+ 115, 2,155,230,156, 2,107, 2,155,236,155,250,233,249,229,239,
+ 235,235,239,242,229,225,110,128, 49,116,239,242,229,225,110,128,
+ 49, 68,244,233,235,229,245,244,235,239,242,229,225,110,128, 49,
+ 117,116, 2,156, 23,156, 38,232,233,229,245,244,232,235,239,242,
+ 229,225,110,128, 49,119,233,235,229,245,244,235,239,242,229,225,
+ 110,128, 49,115,232,233,242,225,231,225,238, 97,128, 48,116,235,
+ 225,244,225,235,225,238, 97,128, 48,212,243,249,237,226,239,236,
+ 231,242,229,229,107,128, 3,214,247,242,225,242,237,229,238,233,
+ 225,110,128, 5,131,236,245,115,132, 0, 43,156,115,156,126,156,
+ 135,156,168,226,229,236,239,247,227,237, 98,128, 3, 31,227,233,
+ 242,227,236,101,128, 34,149,109, 2,156,141,156,148,233,238,245,
+ 115,128, 0,177,111, 2,156,154,156,158,100,128, 2,214,238,239,
+ 243,240,225,227,101,128,255, 11,115, 2,156,174,156,181,237,225,
+ 236,108,128,254, 98,245,240,229,242,233,239,114,128, 32,122,109,
+ 2,156,197,156,208,239,238,239,243,240,225,227,101,128,255, 80,
+ 243,241,245,225,242,101,128, 51,216,111, 5,156,229,156,240,157,
+ 51,157, 62,157, 72,232,233,242,225,231,225,238, 97,128, 48,125,
+ 233,238,244,233,238,231,233,238,228,229,120, 4,157, 4,157, 16,
+ 157, 28,157, 41,228,239,247,238,247,232,233,244,101,128, 38, 31,
+ 236,229,230,244,247,232,233,244,101,128, 38, 28,242,233,231,232,
+ 244,247,232,233,244,101,128, 38, 30,245,240,247,232,233,244,101,
+ 128, 38, 29,235,225,244,225,235,225,238, 97,128, 48,221,240,236,
+ 225,244,232,225,105,128, 14, 27,243,244,225,236,237,225,242,107,
+ 129, 48, 18,157, 85,230,225,227,101,128, 48, 32,240,225,242,229,
+ 110,128, 36,171,114, 3,157,108,157,134,157,159,101, 2,157,114,
+ 157,122,227,229,228,229,115,128, 34,122,243,227,242,233,240,244,
+ 233,239,110,128, 33, 30,233,237,101, 2,157,142,157,148,237,239,
+ 100,128, 2,185,242,229,246,229,242,243,229,100,128, 32, 53,111,
+ 4,157,169,157,176,157,186,157,199,228,245,227,116,128, 34, 15,
+ 234,229,227,244,233,246,101,128, 35, 5,236,239,238,231,229,228,
+ 235,225,238, 97,128, 48,252,112, 2,157,205,157,242,101, 2,157,
+ 211,157,218,236,236,239,114,128, 35, 24,242,243,117, 2,157,226,
+ 157,233,226,243,229,116,128, 34,130,240,229,242,243,229,116,128,
+ 34,131,239,242,244,233,239,110,129, 34, 55,157,253,225,108,128,
+ 34, 29,115, 2,158, 8,158, 51,105,130, 3,200,158, 16,158, 27,
+ 227,249,242,233,236,236,233, 99,128, 4,113,236,233,240,238,229,
+ 245,237,225,244,225,227,249,242,233,236,236,233,227,227,237, 98,
+ 128, 4,134,243,241,245,225,242,101,128, 51,176,117, 2,158, 66,
+ 158, 77,232,233,242,225,231,225,238, 97,128, 48,119,235,225,244,
+ 225,235,225,238, 97,128, 48,215,246,243,241,245,225,242,101,128,
+ 51,180,247,243,241,245,225,242,101,128, 51,186,113,136, 0,113,
+ 158,128,159,177,159,188,159,197,159,204,159,216,159,254,160, 6,
+ 97, 4,158,138,158,161,158,225,159,160,100, 2,158,144,158,150,
+ 229,246, 97,128, 9, 88,237,225,232,229,226,242,229,119,128, 5,
+ 168,102, 4,158,171,158,180,158,194,158,210,225,242,225,226,233,
+ 99,128, 6, 66,230,233,238,225,236,225,242,225,226,233, 99,128,
+ 254,214,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
+ 254,215,237,229,228,233,225,236,225,242,225,226,233, 99,128,254,
+ 216,237,225,244,115,136, 5,184,158,248,159, 12,159, 26,159, 31,
+ 159, 36,159, 45,159, 60,159,147, 49, 3,159, 0,159, 4,159, 8,
+ 48,128, 5,184, 97,128, 5,184, 99,128, 5,184, 50, 2,159, 18,
+ 159, 22, 55,128, 5,184, 57,128, 5,184,179, 51,128, 5,184,228,
+ 101,128, 5,184,232,229,226,242,229,119,128, 5,184,238,225,242,
+ 242,239,247,232,229,226,242,229,119,128, 5,184,113, 2,159, 66,
+ 159,132,225,244,225,110, 4,159, 79,159, 88,159,103,159,119,232,
+ 229,226,242,229,119,128, 5,184,238,225,242,242,239,247,232,229,
+ 226,242,229,119,128, 5,184,241,245,225,242,244,229,242,232,229,
+ 226,242,229,119,128, 5,184,247,233,228,229,232,229,226,242,229,
+ 119,128, 5,184,245,225,242,244,229,242,232,229,226,242,229,119,
+ 128, 5,184,247,233,228,229,232,229,226,242,229,119,128, 5,184,
+ 242,238,229,249,240,225,242,225,232,229,226,242,229,119,128, 5,
+ 159,226,239,240,239,237,239,230,111,128, 49, 17,227,233,242,227,
+ 236,101,128, 36,224,232,239,239,107,128, 2,160,237,239,238,239,
+ 243,240,225,227,101,128,255, 81,239,102,130, 5,231,159,225,159,
+ 245,228,225,231,229,243,104,129,251, 71,159,236,232,229,226,242,
+ 229,119,128,251, 71,232,229,226,242,229,119,128, 5,231,240,225,
+ 242,229,110,128, 36,172,117, 4,160, 16,160, 28,160,117,160,204,
+ 225,242,244,229,242,238,239,244,101,128, 38,105,226,245,244,115,
+ 135, 5,187,160, 49,160, 54,160, 59,160, 64,160, 73,160, 88,160,
+ 104,177, 56,128, 5,187,178, 53,128, 5,187,179, 49,128, 5,187,
+ 232,229,226,242,229,119,128, 5,187,238,225,242,242,239,247,232,
+ 229,226,242,229,119,128, 5,187,241,245,225,242,244,229,242,232,
+ 229,226,242,229,119,128, 5,187,247,233,228,229,232,229,226,242,
+ 229,119,128, 5,187,229,243,244,233,239,110,133, 0, 63,160,136,
+ 160,159,160,176,160,184,160,196,225,114, 2,160,143,160,150,225,
+ 226,233, 99,128, 6, 31,237,229,238,233,225,110,128, 5, 94,228,
+ 239,247,110,129, 0,191,160,168,243,237,225,236,108,128,247,191,
+ 231,242,229,229,107,128, 3,126,237,239,238,239,243,240,225,227,
+ 101,128,255, 31,243,237,225,236,108,128,247, 63,239,244,101, 4,
+ 160,216,161, 31,161, 51,161, 80,228,226,108,133, 0, 34,160,232,
+ 160,239,160,246,161, 2,161, 23,226,225,243,101,128, 32, 30,236,
+ 229,230,116,128, 32, 28,237,239,238,239,243,240,225,227,101,128,
+ 255, 2,240,242,233,237,101,129, 48, 30,161, 12,242,229,246,229,
+ 242,243,229,100,128, 48, 29,242,233,231,232,116,128, 32, 29,236,
+ 229,230,116,129, 32, 24,161, 40,242,229,246,229,242,243,229,100,
+ 128, 32, 27,114, 2,161, 57,161, 67,229,246,229,242,243,229,100,
+ 128, 32, 27,233,231,232,116,129, 32, 25,161, 76,110,128, 1, 73,
+ 243,233,238,231,108, 2,161, 90,161, 97,226,225,243,101,128, 32,
+ 26,101,129, 0, 39,161,103,237,239,238,239,243,240,225,227,101,
+ 128,255, 7,114,145, 0,114,161,153,162,157,162,168,162,215,163,
+ 10,164, 27,164, 51,164,146,166,180,166,217,166,229,167, 27,167,
+ 35,167,197,167,208,167,243,168, 87, 97, 11,161,177,161,188,161,
+ 198,161,205,162, 14,162, 30,162, 55,162, 66,162, 91,162,114,162,
+ 151,225,242,237,229,238,233,225,110,128, 5,124,226,229,238,231,
+ 225,236,105,128, 9,176,227,245,244,101,128, 1, 85,100, 4,161,
+ 215,161,221,161,235,162, 5,229,246, 97,128, 9, 48,233,227,225,
+ 108,129, 34, 26,161,230,229,120,128,248,229,239,246,229,242,243,
+ 243,241,245,225,242,101,129, 51,174,161,251,228,243,241,245,225,
+ 242,101,128, 51,175,243,241,245,225,242,101,128, 51,173,230,101,
+ 129, 5,191,162, 21,232,229,226,242,229,119,128, 5,191,231,117,
+ 2,162, 37,162, 46,234,225,242,225,244,105,128, 10,176,242,237,
+ 245,235,232,105,128, 10, 48,232,233,242,225,231,225,238, 97,128,
+ 48,137,235,225,244,225,235,225,238, 97,129, 48,233,162, 79,232,
+ 225,236,230,247,233,228,244,104,128,255,151,236,239,247,229,242,
+ 228,233,225,231,239,238,225,236,226,229,238,231,225,236,105,128,
+ 9,241,109, 2,162,120,162,143,233,228,228,236,229,228,233,225,
+ 231,239,238,225,236,226,229,238,231,225,236,105,128, 9,240,243,
+ 232,239,242,110,128, 2,100,244,233,111,128, 34, 54,226,239,240,
+ 239,237,239,230,111,128, 49, 22, 99, 4,162,178,162,185,162,194,
+ 162,202,225,242,239,110,128, 1, 89,229,228,233,236,236, 97,128,
+ 1, 87,233,242,227,236,101,128, 36,225,239,237,237,225,225,227,
+ 227,229,238,116,128, 1, 87,100, 2,162,221,162,231,226,236,231,
+ 242,225,246,101,128, 2, 17,239,116, 2,162,238,162,247,225,227,
+ 227,229,238,116,128, 30, 89,226,229,236,239,119,129, 30, 91,163,
+ 1,237,225,227,242,239,110,128, 30, 93,101, 6,163, 24,163, 69,
+ 163,104,163,159,163,184,163,217,102, 2,163, 30,163, 43,229,242,
+ 229,238,227,229,237,225,242,107,128, 32, 59,236,229,248,243,117,
+ 2,163, 53,163, 60,226,243,229,116,128, 34,134,240,229,242,243,
+ 229,116,128, 34,135,231,233,243,244,229,114, 2,163, 80,163, 85,
+ 229,100,128, 0,174,115, 2,163, 91,163, 97,225,238,115,128,248,
+ 232,229,242,233,102,128,246,218,104, 3,163,112,163,135,163,149,
+ 225,114, 2,163,119,163,126,225,226,233, 99,128, 6, 49,237,229,
+ 238,233,225,110,128, 5,128,230,233,238,225,236,225,242,225,226,
+ 233, 99,128,254,174,233,242,225,231,225,238, 97,128, 48,140,235,
+ 225,244,225,235,225,238, 97,129, 48,236,163,172,232,225,236,230,
+ 247,233,228,244,104,128,255,154,243,104,130, 5,232,163,193,163,
+ 208,228,225,231,229,243,232,232,229,226,242,229,119,128,251, 72,
+ 232,229,226,242,229,119,128, 5,232,118, 3,163,225,163,238,164,
+ 14,229,242,243,229,228,244,233,236,228,101,128, 34, 61,233, 97,
+ 2,163,245,163,254,232,229,226,242,229,119,128, 5,151,237,245,
+ 231,242,225,243,232,232,229,226,242,229,119,128, 5,151,236,239,
+ 231,233,227,225,236,238,239,116,128, 35, 16,230,233,243,232,232,
+ 239,239,107,129, 2,126,164, 40,242,229,246,229,242,243,229,100,
+ 128, 2,127,104, 2,164, 57,164, 80, 97, 2,164, 63,164, 73,226,
+ 229,238,231,225,236,105,128, 9,221,228,229,246, 97,128, 9, 93,
+ 111,131, 3,193,164, 90,164,119,164,133,239,107,129, 2,125,164,
+ 97,244,245,242,238,229,100,129, 2,123,164,108,243,245,240,229,
+ 242,233,239,114,128, 2,181,243,249,237,226,239,236,231,242,229,
+ 229,107,128, 3,241,244,233,227,232,239,239,235,237,239,100,128,
+ 2,222,105, 6,164,160,165,204,165,250,166, 5,166, 30,166,166,
+ 229,245,108, 9,164,182,164,217,164,232,164,246,165, 36,165, 50,
+ 165,136,165,149,165,184, 97, 2,164,188,164,203,227,233,242,227,
+ 236,229,235,239,242,229,225,110,128, 50,113,240,225,242,229,238,
+ 235,239,242,229,225,110,128, 50, 17,227,233,242,227,236,229,235,
+ 239,242,229,225,110,128, 50, 99,232,233,229,245,232,235,239,242,
+ 229,225,110,128, 49, 64,107, 2,164,252,165, 28,233,249,229,239,
+ 107, 2,165, 6,165, 15,235,239,242,229,225,110,128, 49, 58,243,
+ 233,239,243,235,239,242,229,225,110,128, 49,105,239,242,229,225,
+ 110,128, 49, 57,237,233,229,245,237,235,239,242,229,225,110,128,
+ 49, 59,112, 3,165, 58,165, 90,165,105, 97, 2,165, 64,165, 78,
+ 238,243,233,239,243,235,239,242,229,225,110,128, 49,108,242,229,
+ 238,235,239,242,229,225,110,128, 50, 3,232,233,229,245,240,232,
+ 235,239,242,229,225,110,128, 49, 63,233,229,245,112, 2,165,114,
+ 165,123,235,239,242,229,225,110,128, 49, 60,243,233,239,243,235,
+ 239,242,229,225,110,128, 49,107,243,233,239,243,235,239,242,229,
+ 225,110,128, 49, 61,116, 2,165,155,165,170,232,233,229,245,244,
+ 232,235,239,242,229,225,110,128, 49, 62,233,235,229,245,244,235,
+ 239,242,229,225,110,128, 49,106,249,229,239,242,233,238,232,233,
+ 229,245,232,235,239,242,229,225,110,128, 49,109,231,232,116, 2,
+ 165,212,165,220,225,238,231,236,101,128, 34, 31,116, 2,165,226,
+ 165,240,225,227,235,226,229,236,239,247,227,237, 98,128, 3, 25,
+ 242,233,225,238,231,236,101,128, 34,191,232,233,242,225,231,225,
+ 238, 97,128, 48,138,235,225,244,225,235,225,238, 97,129, 48,234,
+ 166, 18,232,225,236,230,247,233,228,244,104,128,255,152,110, 2,
+ 166, 36,166,152,103,131, 2,218,166, 46,166, 57,166, 63,226,229,
+ 236,239,247,227,237, 98,128, 3, 37,227,237, 98,128, 3, 10,232,
+ 225,236,102, 2,166, 72,166,118,236,229,230,116,131, 2,191,166,
+ 85,166, 96,166,107,225,242,237,229,238,233,225,110,128, 5, 89,
+ 226,229,236,239,247,227,237, 98,128, 3, 28,227,229,238,244,229,
+ 242,229,100,128, 2,211,242,233,231,232,116,130, 2,190,166,130,
+ 166,141,226,229,236,239,247,227,237, 98,128, 3, 57,227,229,238,
+ 244,229,242,229,100,128, 2,210,246,229,242,244,229,228,226,242,
+ 229,246,101,128, 2, 19,244,244,239,242,245,243,241,245,225,242,
+ 101,128, 51, 81,108, 2,166,186,166,197,233,238,229,226,229,236,
+ 239,119,128, 30, 95,239,238,231,236,229,103,129, 2,124,166,208,
+ 244,245,242,238,229,100,128, 2,122,237,239,238,239,243,240,225,
+ 227,101,128,255, 82,111, 3,166,237,166,248,167, 17,232,233,242,
+ 225,231,225,238, 97,128, 48,141,235,225,244,225,235,225,238, 97,
+ 129, 48,237,167, 5,232,225,236,230,247,233,228,244,104,128,255,
+ 155,242,245,225,244,232,225,105,128, 14, 35,240,225,242,229,110,
+ 128, 36,173,114, 3,167, 43,167, 79,167,109, 97, 3,167, 51,167,
+ 61,167, 68,226,229,238,231,225,236,105,128, 9,220,228,229,246,
+ 97,128, 9, 49,231,245,242,237,245,235,232,105,128, 10, 92,229,
+ 104, 2,167, 86,167, 95,225,242,225,226,233, 99,128, 6,145,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,251,141,246,239,227,
+ 225,236,233, 99, 4,167,125,167,135,167,142,167,153,226,229,238,
+ 231,225,236,105,128, 9,224,228,229,246, 97,128, 9, 96,231,245,
+ 234,225,242,225,244,105,128, 10,224,246,239,247,229,236,243,233,
+ 231,110, 3,167,169,167,179,167,186,226,229,238,231,225,236,105,
+ 128, 9,196,228,229,246, 97,128, 9, 68,231,245,234,225,242,225,
+ 244,105,128, 10,196,243,245,240,229,242,233,239,114,128,246,241,
+ 116, 2,167,214,167,222,226,236,239,227,107,128, 37,144,245,242,
+ 238,229,100,129, 2,121,167,232,243,245,240,229,242,233,239,114,
+ 128, 2,180,117, 4,167,253,168, 8,168, 33,168, 80,232,233,242,
+ 225,231,225,238, 97,128, 48,139,235,225,244,225,235,225,238, 97,
+ 129, 48,235,168, 21,232,225,236,230,247,233,228,244,104,128,255,
+ 153,112, 2,168, 39,168, 74,229,101, 2,168, 46,168, 60,237,225,
+ 242,235,226,229,238,231,225,236,105,128, 9,242,243,233,231,238,
+ 226,229,238,231,225,236,105,128, 9,243,233,225,104,128,246,221,
+ 244,232,225,105,128, 14, 36,246,239,227,225,236,233, 99, 4,168,
+ 103,168,113,168,120,168,131,226,229,238,231,225,236,105,128, 9,
+ 139,228,229,246, 97,128, 9, 11,231,245,234,225,242,225,244,105,
+ 128, 10,139,246,239,247,229,236,243,233,231,110, 3,168,147,168,
+ 157,168,164,226,229,238,231,225,236,105,128, 9,195,228,229,246,
+ 97,128, 9, 67,231,245,234,225,242,225,244,105,128, 10,195,115,
+ 147, 0,115,168,217,170,187,170,198,171, 68,171,107,174, 49,174,
+ 60,176,203,179, 85,179,131,179,158,180, 93,180,160,181,193,181,
+ 203,182,133,182,206,183,120,183,130, 97, 9,168,237,168,247,169,
+ 12,169, 84,169,109,169,120,169,145,169,177,169,217,226,229,238,
+ 231,225,236,105,128, 9,184,227,245,244,101,129, 1, 91,169, 0,
+ 228,239,244,225,227,227,229,238,116,128, 30,101,100, 5,169, 24,
+ 169, 33,169, 39,169, 53,169, 69,225,242,225,226,233, 99,128, 6,
+ 53,229,246, 97,128, 9, 56,230,233,238,225,236,225,242,225,226,
+ 233, 99,128,254,186,233,238,233,244,233,225,236,225,242,225,226,
+ 233, 99,128,254,187,237,229,228,233,225,236,225,242,225,226,233,
+ 99,128,254,188,231,117, 2,169, 91,169,100,234,225,242,225,244,
+ 105,128, 10,184,242,237,245,235,232,105,128, 10, 56,232,233,242,
+ 225,231,225,238, 97,128, 48, 85,235,225,244,225,235,225,238, 97,
+ 129, 48,181,169,133,232,225,236,230,247,233,228,244,104,128,255,
+ 123,236,236,225,236,236,225,232,239,245,225,236,225,249,232,229,
+ 247,225,243,225,236,236,225,237,225,242,225,226,233, 99,128,253,
+ 250,237,229,235,104,130, 5,225,169,188,169,208,228,225,231,229,
+ 243,104,129,251, 65,169,199,232,229,226,242,229,119,128,251, 65,
+ 232,229,226,242,229,119,128, 5,225,242, 97, 5,169,230,170, 48,
+ 170, 56,170,106,170,114, 97, 5,169,242,169,250,170, 2,170, 33,
+ 170, 41,225,244,232,225,105,128, 14, 50,229,244,232,225,105,128,
+ 14, 65,233,237,225,233,109, 2,170, 12,170, 23,225,236,225,233,
+ 244,232,225,105,128, 14, 68,245,225,238,244,232,225,105,128, 14,
+ 67,237,244,232,225,105,128, 14, 51,244,232,225,105,128, 14, 48,
+ 229,244,232,225,105,128, 14, 64,105, 3,170, 64,170, 88,170, 99,
+ 105, 2,170, 70,170, 81,236,229,230,244,244,232,225,105,128,248,
+ 134,244,232,225,105,128, 14, 53,236,229,230,244,244,232,225,105,
+ 128,248,133,244,232,225,105,128, 14, 52,239,244,232,225,105,128,
+ 14, 66,117, 3,170,122,170,172,170,179,101, 3,170,130,170,154,
+ 170,165,101, 2,170,136,170,147,236,229,230,244,244,232,225,105,
+ 128,248,136,244,232,225,105,128, 14, 55,236,229,230,244,244,232,
+ 225,105,128,248,135,244,232,225,105,128, 14, 54,244,232,225,105,
+ 128, 14, 56,245,244,232,225,105,128, 14, 57,226,239,240,239,237,
+ 239,230,111,128, 49, 25, 99, 5,170,210,170,231,170,240,171, 33,
+ 171, 55,225,242,239,110,129, 1, 97,170,219,228,239,244,225,227,
+ 227,229,238,116,128, 30,103,229,228,233,236,236, 97,128, 1, 95,
+ 232,247, 97,131, 2, 89,170,252,171, 7,171, 26,227,249,242,233,
+ 236,236,233, 99,128, 4,217,228,233,229,242,229,243,233,243,227,
+ 249,242,233,236,236,233, 99,128, 4,219,232,239,239,107,128, 2,
+ 90,233,242, 99, 2,171, 41,171, 46,236,101,128, 36,226,245,237,
+ 230,236,229,120,128, 1, 93,239,237,237,225,225,227,227,229,238,
+ 116,128, 2, 25,228,239,116, 2,171, 76,171, 85,225,227,227,229,
+ 238,116,128, 30, 97,226,229,236,239,119,129, 30, 99,171, 95,228,
+ 239,244,225,227,227,229,238,116,128, 30,105,101, 9,171,127,171,
+ 143,171,178,171,243,172, 90,172,117,172,142,172,223,172,250,225,
+ 231,245,236,236,226,229,236,239,247,227,237, 98,128, 3, 60, 99,
+ 2,171,149,171,171,239,238,100,129, 32, 51,171,157,244,239,238,
+ 229,227,232,233,238,229,243,101,128, 2,202,244,233,239,110,128,
+ 0,167,229,110, 4,171,189,171,198,171,212,171,228,225,242,225,
+ 226,233, 99,128, 6, 51,230,233,238,225,236,225,242,225,226,233,
+ 99,128,254,178,233,238,233,244,233,225,236,225,242,225,226,233,
+ 99,128,254,179,237,229,228,233,225,236,225,242,225,226,233, 99,
+ 128,254,180,231,239,108,135, 5,182,172, 7,172, 21,172, 26,172,
+ 35,172, 50,172, 66,172, 77, 49, 2,172, 13,172, 17, 51,128, 5,
+ 182,102,128, 5,182,178, 99,128, 5,182,232,229,226,242,229,119,
+ 128, 5,182,238,225,242,242,239,247,232,229,226,242,229,119,128,
+ 5,182,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
+ 5,182,244,225,232,229,226,242,229,119,128, 5,146,247,233,228,
+ 229,232,229,226,242,229,119,128, 5,182,104, 2,172, 96,172,107,
+ 225,242,237,229,238,233,225,110,128, 5,125,233,242,225,231,225,
+ 238, 97,128, 48, 91,235,225,244,225,235,225,238, 97,129, 48,187,
+ 172,130,232,225,236,230,247,233,228,244,104,128,255,126,237,105,
+ 2,172,149,172,192,227,239,236,239,110,131, 0, 59,172,163,172,
+ 172,172,184,225,242,225,226,233, 99,128, 6, 27,237,239,238,239,
+ 243,240,225,227,101,128,255, 27,243,237,225,236,108,128,254, 84,
+ 246,239,233,227,229,228,237,225,242,235,235,225,238, 97,129, 48,
+ 156,172,211,232,225,236,230,247,233,228,244,104,128,255,159,238,
+ 116, 2,172,230,172,240,233,243,241,245,225,242,101,128, 51, 34,
+ 239,243,241,245,225,242,101,128, 51, 35,246,229,110,142, 0, 55,
+ 173, 28,173, 37,173, 47,173, 77,173, 84,173, 94,173,119,173,146,
+ 173,180,173,192,173,203,173,236,173,244,173,255,225,242,225,226,
+ 233, 99,128, 6,103,226,229,238,231,225,236,105,128, 9,237,227,
+ 233,242,227,236,101,129, 36,102,173, 58,233,238,246,229,242,243,
+ 229,243,225,238,243,243,229,242,233,102,128, 39,144,228,229,246,
+ 97,128, 9,109,229,233,231,232,244,232,115,128, 33, 94,231,117,
+ 2,173,101,173,110,234,225,242,225,244,105,128, 10,237,242,237,
+ 245,235,232,105,128, 10,109,232, 97, 2,173,126,173,137,227,235,
+ 225,242,225,226,233, 99,128, 6,103,238,231,250,232,239,117,128,
+ 48, 39,105, 2,173,152,173,170,228,229,239,231,242,225,240,232,
+ 233,227,240,225,242,229,110,128, 50, 38,238,230,229,242,233,239,
+ 114,128, 32,135,237,239,238,239,243,240,225,227,101,128,255, 23,
+ 239,236,228,243,244,249,236,101,128,247, 55,112, 2,173,209,173,
+ 216,225,242,229,110,128, 36,122,229,114, 2,173,223,173,229,233,
+ 239,100,128, 36,142,243,233,225,110,128, 6,247,242,239,237,225,
+ 110,128, 33,118,243,245,240,229,242,233,239,114,128, 32,119,116,
+ 2,174, 5,174, 43,229,229,110, 2,174, 13,174, 22,227,233,242,
+ 227,236,101,128, 36,112,112, 2,174, 28,174, 35,225,242,229,110,
+ 128, 36,132,229,242,233,239,100,128, 36,152,232,225,105,128, 14,
+ 87,230,244,232,249,240,232,229,110,128, 0,173,104, 7,174, 76,
+ 175, 50,175, 61,175, 75,176, 20,176, 33,176,197, 97, 6,174, 90,
+ 174,101,174,111,174,122,175, 9,175, 34,225,242,237,229,238,233,
+ 225,110,128, 5,119,226,229,238,231,225,236,105,128, 9,182,227,
+ 249,242,233,236,236,233, 99,128, 4, 72,100, 2,174,128,174,224,
+ 228, 97, 4,174,139,174,148,174,179,174,193,225,242,225,226,233,
+ 99,128, 6, 81,228,225,237,237, 97, 2,174,158,174,167,225,242,
+ 225,226,233, 99,128,252, 97,244,225,238,225,242,225,226,233, 99,
+ 128,252, 94,230,225,244,232,225,225,242,225,226,233, 99,128,252,
+ 96,235,225,243,242, 97, 2,174,203,174,212,225,242,225,226,233,
+ 99,128,252, 98,244,225,238,225,242,225,226,233, 99,128,252, 95,
+ 101,132, 37,146,174,236,174,243,174,251,175, 4,228,225,242,107,
+ 128, 37,147,236,233,231,232,116,128, 37,145,237,229,228,233,245,
+ 109,128, 37,146,246, 97,128, 9, 54,231,117, 2,175, 16,175, 25,
+ 234,225,242,225,244,105,128, 10,182,242,237,245,235,232,105,128,
+ 10, 54,236,243,232,229,236,229,244,232,229,226,242,229,119,128,
+ 5,147,226,239,240,239,237,239,230,111,128, 49, 21,227,232,225,
+ 227,249,242,233,236,236,233, 99,128, 4, 73,101, 4,175, 85,175,
+ 150,175,160,175,177,229,110, 4,175, 96,175,105,175,119,175,135,
+ 225,242,225,226,233, 99,128, 6, 52,230,233,238,225,236,225,242,
+ 225,226,233, 99,128,254,182,233,238,233,244,233,225,236,225,242,
+ 225,226,233, 99,128,254,183,237,229,228,233,225,236,225,242,225,
+ 226,233, 99,128,254,184,233,227,239,240,244,233, 99,128, 3,227,
+ 241,229,108,129, 32,170,175,168,232,229,226,242,229,119,128, 32,
+ 170,246, 97,134, 5,176,175,194,175,209,175,223,175,232,175,247,
+ 176, 7, 49, 2,175,200,175,205,177, 53,128, 5,176, 53,128, 5,
+ 176, 50, 2,175,215,175,219, 50,128, 5,176,101,128, 5,176,232,
+ 229,226,242,229,119,128, 5,176,238,225,242,242,239,247,232,229,
+ 226,242,229,119,128, 5,176,241,245,225,242,244,229,242,232,229,
+ 226,242,229,119,128, 5,176,247,233,228,229,232,229,226,242,229,
+ 119,128, 5,176,232,225,227,249,242,233,236,236,233, 99,128, 4,
+ 187,105, 2,176, 39,176, 50,237,225,227,239,240,244,233, 99,128,
+ 3,237,110,131, 5,233,176, 60,176,143,176,152,100, 2,176, 66,
+ 176,132,225,231,229,243,104,130,251, 73,176, 78,176, 87,232,229,
+ 226,242,229,119,128,251, 73,115, 2,176, 93,176,113,232,233,238,
+ 228,239,116,129,251, 44,176,104,232,229,226,242,229,119,128,251,
+ 44,233,238,228,239,116,129,251, 45,176,123,232,229,226,242,229,
+ 119,128,251, 45,239,244,232,229,226,242,229,119,128, 5,193,232,
+ 229,226,242,229,119,128, 5,233,115, 2,176,158,176,178,232,233,
+ 238,228,239,116,129,251, 42,176,169,232,229,226,242,229,119,128,
+ 251, 42,233,238,228,239,116,129,251, 43,176,188,232,229,226,242,
+ 229,119,128,251, 43,239,239,107,128, 2,130,105, 8,176,221,177,
+ 9,177, 20,177, 45,177, 75,177, 83,177, 96,178, 11,231,237, 97,
+ 131, 3,195,176,233,176,237,176,245, 49,128, 3,194,230,233,238,
+ 225,108,128, 3,194,236,245,238,225,244,229,243,249,237,226,239,
+ 236,231,242,229,229,107,128, 3,242,232,233,242,225,231,225,238,
+ 97,128, 48, 87,235,225,244,225,235,225,238, 97,129, 48,183,177,
+ 33,232,225,236,230,247,233,228,244,104,128,255,124,236,245,113,
+ 2,177, 53,177, 62,232,229,226,242,229,119,128, 5,189,236,229,
+ 230,244,232,229,226,242,229,119,128, 5,189,237,233,236,225,114,
+ 128, 34, 60,238,228,239,244,232,229,226,242,229,119,128, 5,194,
+ 239,115, 6,177,111,177,146,177,178,177,206,177,220,177,252, 97,
+ 2,177,117,177,132,227,233,242,227,236,229,235,239,242,229,225,
+ 110,128, 50,116,240,225,242,229,238,235,239,242,229,225,110,128,
+ 50, 20,227,105, 2,177,153,177,165,229,245,227,235,239,242,229,
+ 225,110,128, 49,126,242,227,236,229,235,239,242,229,225,110,128,
+ 50,102,107, 2,177,184,177,198,233,249,229,239,235,235,239,242,
+ 229,225,110,128, 49,122,239,242,229,225,110,128, 49, 69,238,233,
+ 229,245,238,235,239,242,229,225,110,128, 49,123,112, 2,177,226,
+ 177,239,225,242,229,238,235,239,242,229,225,110,128, 50, 6,233,
+ 229,245,240,235,239,242,229,225,110,128, 49,125,244,233,235,229,
+ 245,244,235,239,242,229,225,110,128, 49,124,120,141, 0, 54,178,
+ 41,178, 50,178, 60,178, 90,178, 97,178,122,178,149,178,183,178,
+ 195,178,206,178,239,178,247,179, 2,225,242,225,226,233, 99,128,
+ 6,102,226,229,238,231,225,236,105,128, 9,236,227,233,242,227,
+ 236,101,129, 36,101,178, 71,233,238,246,229,242,243,229,243,225,
+ 238,243,243,229,242,233,102,128, 39,143,228,229,246, 97,128, 9,
+ 108,231,117, 2,178,104,178,113,234,225,242,225,244,105,128, 10,
+ 236,242,237,245,235,232,105,128, 10,108,232, 97, 2,178,129,178,
+ 140,227,235,225,242,225,226,233, 99,128, 6,102,238,231,250,232,
+ 239,117,128, 48, 38,105, 2,178,155,178,173,228,229,239,231,242,
+ 225,240,232,233,227,240,225,242,229,110,128, 50, 37,238,230,229,
+ 242,233,239,114,128, 32,134,237,239,238,239,243,240,225,227,101,
+ 128,255, 22,239,236,228,243,244,249,236,101,128,247, 54,112, 2,
+ 178,212,178,219,225,242,229,110,128, 36,121,229,114, 2,178,226,
+ 178,232,233,239,100,128, 36,141,243,233,225,110,128, 6,246,242,
+ 239,237,225,110,128, 33,117,243,245,240,229,242,233,239,114,128,
+ 32,118,116, 2,179, 8,179, 79,229,229,110, 2,179, 16,179, 58,
+ 99, 2,179, 22,179, 30,233,242,227,236,101,128, 36,111,245,242,
+ 242,229,238,227,249,228,229,238,239,237,233,238,225,244,239,242,
+ 226,229,238,231,225,236,105,128, 9,249,112, 2,179, 64,179, 71,
+ 225,242,229,110,128, 36,131,229,242,233,239,100,128, 36,151,232,
+ 225,105,128, 14, 86,108, 2,179, 91,179,111,225,243,104,129, 0,
+ 47,179, 99,237,239,238,239,243,240,225,227,101,128,255, 15,239,
+ 238,103,129, 1,127,179,119,228,239,244,225,227,227,229,238,116,
+ 128, 30,155,109, 2,179,137,179,147,233,236,229,230,225,227,101,
+ 128, 38, 58,239,238,239,243,240,225,227,101,128,255, 83,111, 6,
+ 179,172,179,222,179,233,180, 2,180, 47,180, 58,102, 2,179,178,
+ 179,192,240,225,243,245,241,232,229,226,242,229,119,128, 5,195,
+ 116, 2,179,198,179,207,232,249,240,232,229,110,128, 0,173,243,
+ 233,231,238,227,249,242,233,236,236,233, 99,128, 4, 76,232,233,
+ 242,225,231,225,238, 97,128, 48, 93,235,225,244,225,235,225,238,
+ 97,129, 48,189,179,246,232,225,236,230,247,233,228,244,104,128,
+ 255,127,236,233,228,245,115, 2,180, 12,180, 29,236,239,238,231,
+ 239,246,229,242,236,225,249,227,237, 98,128, 3, 56,243,232,239,
+ 242,244,239,246,229,242,236,225,249,227,237, 98,128, 3, 55,242,
+ 245,243,233,244,232,225,105,128, 14, 41,115, 3,180, 66,180, 76,
+ 180, 84,225,236,225,244,232,225,105,128, 14, 40,239,244,232,225,
+ 105,128, 14, 11,245,225,244,232,225,105,128, 14, 42,240, 97, 3,
+ 180,102,180,122,180,154,227,101,129, 0, 32,180,109,232,225,227,
+ 235,225,242,225,226,233, 99,128, 0, 32,228,101,129, 38, 96,180,
+ 129,243,245,233,116, 2,180,138,180,146,226,236,225,227,107,128,
+ 38, 96,247,232,233,244,101,128, 38,100,242,229,110,128, 36,174,
+ 241,245,225,242,101, 11,180,188,180,199,180,213,180,238,180,255,
+ 181, 25,181, 40,181, 73,181,100,181,156,181,171,226,229,236,239,
+ 247,227,237, 98,128, 3, 59, 99, 2,180,205,180,209, 99,128, 51,
+ 196,109,128, 51,157,228,233,225,231,239,238,225,236,227,242,239,
+ 243,243,232,225,244,227,232,230,233,236,108,128, 37,169,232,239,
+ 242,233,250,239,238,244,225,236,230,233,236,108,128, 37,164,107,
+ 2,181, 5,181, 9,103,128, 51,143,109,129, 51,158,181, 15,227,
+ 225,240,233,244,225,108,128, 51,206,108, 2,181, 31,181, 35,110,
+ 128, 51,209,239,103,128, 51,210,109, 4,181, 50,181, 54,181, 59,
+ 181, 63,103,128, 51,142,233,108,128, 51,213,109,128, 51,156,243,
+ 241,245,225,242,229,100,128, 51,161,239,242,244,232,239,231,239,
+ 238,225,236,227,242,239,243,243,232,225,244,227,232,230,233,236,
+ 108,128, 37,166,245,240,240,229,114, 2,181,110,181,133,236,229,
+ 230,244,244,239,236,239,247,229,242,242,233,231,232,244,230,233,
+ 236,108,128, 37,167,242,233,231,232,244,244,239,236,239,247,229,
+ 242,236,229,230,244,230,233,236,108,128, 37,168,246,229,242,244,
+ 233,227,225,236,230,233,236,108,128, 37,165,247,232,233,244,229,
+ 247,233,244,232,243,237,225,236,236,226,236,225,227,107,128, 37,
+ 163,242,243,241,245,225,242,101,128, 51,219,115, 2,181,209,182,
+ 123, 97, 4,181,219,181,229,181,236,181,247,226,229,238,231,225,
+ 236,105,128, 9,183,228,229,246, 97,128, 9, 55,231,245,234,225,
+ 242,225,244,105,128, 10,183,238,103, 8,182, 10,182, 24,182, 38,
+ 182, 52,182, 67,182, 81,182, 95,182,108,227,233,229,245,227,235,
+ 239,242,229,225,110,128, 49, 73,232,233,229,245,232,235,239,242,
+ 229,225,110,128, 49,133,233,229,245,238,231,235,239,242,229,225,
+ 110,128, 49,128,235,233,249,229,239,235,235,239,242,229,225,110,
+ 128, 49, 50,238,233,229,245,238,235,239,242,229,225,110,128, 49,
+ 101,240,233,229,245,240,235,239,242,229,225,110,128, 49, 67,243,
+ 233,239,243,235,239,242,229,225,110,128, 49, 70,244,233,235,229,
+ 245,244,235,239,242,229,225,110,128, 49, 56,245,240,229,242,233,
+ 239,114,128,246,242,116, 2,182,139,182,162,229,242,236,233,238,
+ 103,129, 0,163,182,150,237,239,238,239,243,240,225,227,101,128,
+ 255,225,242,239,235,101, 2,182,171,182,188,236,239,238,231,239,
+ 246,229,242,236,225,249,227,237, 98,128, 3, 54,243,232,239,242,
+ 244,239,246,229,242,236,225,249,227,237, 98,128, 3, 53,117, 7,
+ 182,222,182,254,183, 20,183, 31,183, 72,183, 82,183, 86,226,243,
+ 229,116,130, 34,130,182,233,182,244,238,239,244,229,241,245,225,
+ 108,128, 34,138,239,242,229,241,245,225,108,128, 34,134, 99, 2,
+ 183, 4,183, 12,227,229,229,228,115,128, 34,123,232,244,232,225,
+ 116,128, 34, 11,232,233,242,225,231,225,238, 97,128, 48, 89,107,
+ 2,183, 37,183, 61,225,244,225,235,225,238, 97,129, 48,185,183,
+ 49,232,225,236,230,247,233,228,244,104,128,255,125,245,238,225,
+ 242,225,226,233, 99,128, 6, 82,237,237,225,244,233,239,110,128,
+ 34, 17,110,128, 38, 60,240,229,242,243,229,116,130, 34,131,183,
+ 99,183,110,238,239,244,229,241,245,225,108,128, 34,139,239,242,
+ 229,241,245,225,108,128, 34,135,246,243,241,245,225,242,101,128,
+ 51,220,249,239,245,247,225,229,242,225,243,241,245,225,242,101,
+ 128, 51,124,116,144, 0,116,183,183,184,192,184,213,185,100,185,
+ 140,187,188,191, 70,192,145,192,157,192,169,193,202,193,227,194,
+ 57,194,237,195,165,195,255, 97, 10,183,205,183,215,183,236,183,
+ 243,184, 12,184, 90,184,107,184,132,184,146,184,150,226,229,238,
+ 231,225,236,105,128, 9,164,227,107, 2,183,222,183,229,228,239,
+ 247,110,128, 34,164,236,229,230,116,128, 34,163,228,229,246, 97,
+ 128, 9, 36,231,117, 2,183,250,184, 3,234,225,242,225,244,105,
+ 128, 10,164,242,237,245,235,232,105,128, 10, 36,104, 4,184, 22,
+ 184, 31,184, 45,184, 75,225,242,225,226,233, 99,128, 6, 55,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,254,194,105, 2,184,
+ 51,184, 66,238,233,244,233,225,236,225,242,225,226,233, 99,128,
+ 254,195,242,225,231,225,238, 97,128, 48, 95,237,229,228,233,225,
+ 236,225,242,225,226,233, 99,128,254,196,233,243,249,239,245,229,
+ 242,225,243,241,245,225,242,101,128, 51,125,235,225,244,225,235,
+ 225,238, 97,129, 48,191,184,120,232,225,236,230,247,233,228,244,
+ 104,128,255,128,244,247,229,229,236,225,242,225,226,233, 99,128,
+ 6, 64,117,128, 3,196,118,130, 5,234,184,158,184,183,228,225,
+ 231,229,115,129,251, 74,184,168,104,129,251, 74,184,174,232,229,
+ 226,242,229,119,128,251, 74,232,229,226,242,229,119,128, 5,234,
+ 98, 2,184,198,184,203,225,114,128, 1,103,239,240,239,237,239,
+ 230,111,128, 49, 10, 99, 6,184,227,184,234,184,241,184,250,185,
+ 60,185, 87,225,242,239,110,128, 1,101,227,245,242,108,128, 2,
+ 168,229,228,233,236,236, 97,128, 1, 99,232,229,104, 4,185, 6,
+ 185, 15,185, 29,185, 45,225,242,225,226,233, 99,128, 6,134,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,251,123,233,238,233,
+ 244,233,225,236,225,242,225,226,233, 99,128,251,124,237,229,228,
+ 233,225,236,225,242,225,226,233, 99,128,251,125,233,242, 99, 2,
+ 185, 68,185, 73,236,101,128, 36,227,245,237,230,236,229,248,226,
+ 229,236,239,119,128, 30,113,239,237,237,225,225,227,227,229,238,
+ 116,128, 1, 99,100, 2,185,106,185,116,233,229,242,229,243,233,
+ 115,128, 30,151,239,116, 2,185,123,185,132,225,227,227,229,238,
+ 116,128, 30,107,226,229,236,239,119,128, 30,109,101, 9,185,160,
+ 185,171,185,191,186,201,186,226,187, 34,187,101,187,106,187,158,
+ 227,249,242,233,236,236,233, 99,128, 4, 66,228,229,243,227,229,
+ 238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,173,104,
+ 7,185,207,185,216,185,230,186, 14,186, 44,186, 85,186,183,225,
+ 242,225,226,233, 99,128, 6, 42,230,233,238,225,236,225,242,225,
+ 226,233, 99,128,254,150,232,225,232,105, 2,185,239,185,254,238,
+ 233,244,233,225,236,225,242,225,226,233, 99,128,252,162,243,239,
+ 236,225,244,229,228,225,242,225,226,233, 99,128,252, 12,105, 2,
+ 186, 20,186, 35,238,233,244,233,225,236,225,242,225,226,233, 99,
+ 128,254,151,242,225,231,225,238, 97,128, 48,102,234,229,229,237,
+ 105, 2,186, 54,186, 69,238,233,244,233,225,236,225,242,225,226,
+ 233, 99,128,252,161,243,239,236,225,244,229,228,225,242,225,226,
+ 233, 99,128,252, 11,109, 2,186, 91,186,125,225,242,226,245,244,
+ 97, 2,186,102,186,111,225,242,225,226,233, 99,128, 6, 41,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,254,148,101, 2,186,
+ 131,186,144,228,233,225,236,225,242,225,226,233, 99,128,254,152,
+ 229,237,105, 2,186,152,186,167,238,233,244,233,225,236,225,242,
+ 225,226,233, 99,128,252,164,243,239,236,225,244,229,228,225,242,
+ 225,226,233, 99,128,252, 14,238,239,239,238,230,233,238,225,236,
+ 225,242,225,226,233, 99,128,252,115,235,225,244,225,235,225,238,
+ 97,129, 48,198,186,214,232,225,236,230,247,233,228,244,104,128,
+ 255,131,108, 2,186,232,186,251,229,240,232,239,238,101,129, 33,
+ 33,186,243,226,236,225,227,107,128, 38, 14,233,243,232, 97, 2,
+ 187, 4,187, 19,231,229,228,239,236,225,232,229,226,242,229,119,
+ 128, 5,160,241,229,244,225,238,225,232,229,226,242,229,119,128,
+ 5,169,110, 4,187, 44,187, 53,187, 72,187, 93,227,233,242,227,
+ 236,101,128, 36,105,233,228,229,239,231,242,225,240,232,233,227,
+ 240,225,242,229,110,128, 50, 41,112, 2,187, 78,187, 85,225,242,
+ 229,110,128, 36,125,229,242,233,239,100,128, 36,145,242,239,237,
+ 225,110,128, 33,121,243,104,128, 2,167,116,131, 5,216,187,116,
+ 187,136,187,145,228,225,231,229,243,104,129,251, 56,187,127,232,
+ 229,226,242,229,119,128,251, 56,232,229,226,242,229,119,128, 5,
+ 216,243,229,227,249,242,233,236,236,233, 99,128, 4,181,246,233,
+ 114, 2,187,166,187,175,232,229,226,242,229,119,128, 5,155,236,
+ 229,230,244,232,229,226,242,229,119,128, 5,155,104, 6,187,202,
+ 188, 98,188,220,189, 96,190, 3,191, 60, 97, 5,187,214,187,224,
+ 187,231,188, 0,188, 29,226,229,238,231,225,236,105,128, 9,165,
+ 228,229,246, 97,128, 9, 37,231,117, 2,187,238,187,247,234,225,
+ 242,225,244,105,128, 10,165,242,237,245,235,232,105,128, 10, 37,
+ 108, 2,188, 6,188, 15,225,242,225,226,233, 99,128, 6, 48,230,
+ 233,238,225,236,225,242,225,226,233, 99,128,254,172,238,244,232,
+ 225,235,232,225,116, 3,188, 44,188, 75,188, 82,236,239,119, 2,
+ 188, 52,188, 63,236,229,230,244,244,232,225,105,128,248,152,242,
+ 233,231,232,244,244,232,225,105,128,248,151,244,232,225,105,128,
+ 14, 76,245,240,240,229,242,236,229,230,244,244,232,225,105,128,
+ 248,150,101, 3,188,106,188,170,188,193,104, 4,188,116,188,125,
+ 188,139,188,155,225,242,225,226,233, 99,128, 6, 43,230,233,238,
+ 225,236,225,242,225,226,233, 99,128,254,154,233,238,233,244,233,
+ 225,236,225,242,225,226,233, 99,128,254,155,237,229,228,233,225,
+ 236,225,242,225,226,233, 99,128,254,156,242,101, 2,188,177,188,
+ 186,229,248,233,243,244,115,128, 34, 3,230,239,242,101,128, 34,
+ 52,244, 97,130, 3,184,188,202,188,206, 49,128, 3,209,243,249,
+ 237,226,239,236,231,242,229,229,107,128, 3,209,105, 2,188,226,
+ 189, 56,229,245,244,104, 4,188,239,189, 18,189, 33,189, 42, 97,
+ 2,188,245,189, 4,227,233,242,227,236,229,235,239,242,229,225,
+ 110,128, 50,121,240,225,242,229,238,235,239,242,229,225,110,128,
+ 50, 25,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,
+ 107,235,239,242,229,225,110,128, 49, 76,240,225,242,229,238,235,
+ 239,242,229,225,110,128, 50, 11,242,244,229,229,110, 2,189, 66,
+ 189, 75,227,233,242,227,236,101,128, 36,108,112, 2,189, 81,189,
+ 88,225,242,229,110,128, 36,128,229,242,233,239,100,128, 36,148,
+ 111, 6,189,110,189,127,189,132,189,146,189,151,189,204,238,225,
+ 238,231,237,239,238,244,232,239,244,232,225,105,128, 14, 17,239,
+ 107,128, 1,173,240,232,245,244,232,225,239,244,232,225,105,128,
+ 14, 18,242,110,128, 0,254,244,104, 3,189,160,189,184,189,194,
+ 97, 2,189,166,189,176,232,225,238,244,232,225,105,128, 14, 23,
+ 238,244,232,225,105,128, 14, 16,239,238,231,244,232,225,105,128,
+ 14, 24,245,238,231,244,232,225,105,128, 14, 22,245,243,225,238,
+ 100, 2,189,214,189,225,227,249,242,233,236,236,233, 99,128, 4,
+ 130,243,243,229,240,225,242,225,244,239,114, 2,189,240,189,249,
+ 225,242,225,226,233, 99,128, 6,108,240,229,242,243,233,225,110,
+ 128, 6,108,242,229,101,144, 0, 51,190, 41,190, 50,190, 60,190,
+ 90,190, 97,190,107,190,132,190,159,190,193,190,205,190,224,190,
+ 235,191, 12,191, 34,191, 42,191, 53,225,242,225,226,233, 99,128,
+ 6, 99,226,229,238,231,225,236,105,128, 9,233,227,233,242,227,
+ 236,101,129, 36, 98,190, 71,233,238,246,229,242,243,229,243,225,
+ 238,243,243,229,242,233,102,128, 39,140,228,229,246, 97,128, 9,
+ 105,229,233,231,232,244,232,115,128, 33, 92,231,117, 2,190,114,
+ 190,123,234,225,242,225,244,105,128, 10,233,242,237,245,235,232,
+ 105,128, 10,105,232, 97, 2,190,139,190,150,227,235,225,242,225,
+ 226,233, 99,128, 6, 99,238,231,250,232,239,117,128, 48, 35,105,
+ 2,190,165,190,183,228,229,239,231,242,225,240,232,233,227,240,
+ 225,242,229,110,128, 50, 34,238,230,229,242,233,239,114,128, 32,
+ 131,237,239,238,239,243,240,225,227,101,128,255, 19,238,245,237,
+ 229,242,225,244,239,242,226,229,238,231,225,236,105,128, 9,246,
+ 239,236,228,243,244,249,236,101,128,247, 51,112, 2,190,241,190,
+ 248,225,242,229,110,128, 36,118,229,114, 2,190,255,191, 5,233,
+ 239,100,128, 36,138,243,233,225,110,128, 6,243,241,245,225,242,
+ 244,229,242,115,129, 0,190,191, 25,229,237,228,225,243,104,128,
+ 246,222,242,239,237,225,110,128, 33,114,243,245,240,229,242,233,
+ 239,114,128, 0,179,244,232,225,105,128, 14, 83,250,243,241,245,
+ 225,242,101,128, 51,148,105, 7,191, 86,191, 97,191,212,192, 54,
+ 192, 66,192,115,192,132,232,233,242,225,231,225,238, 97,128, 48,
+ 97,107, 2,191,103,191,127,225,244,225,235,225,238, 97,129, 48,
+ 193,191,115,232,225,236,230,247,233,228,244,104,128,255,129,229,
+ 245,116, 4,191,139,191,174,191,189,191,198, 97, 2,191,145,191,
+ 160,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,112,
+ 240,225,242,229,238,235,239,242,229,225,110,128, 50, 16,227,233,
+ 242,227,236,229,235,239,242,229,225,110,128, 50, 98,235,239,242,
+ 229,225,110,128, 49, 55,240,225,242,229,238,235,239,242,229,225,
+ 110,128, 50, 2,236,228,101,133, 2,220,191,228,191,239,192, 0,
+ 192, 12,192, 40,226,229,236,239,247,227,237, 98,128, 3, 48, 99,
+ 2,191,245,191,250,237, 98,128, 3, 3,239,237, 98,128, 3, 3,
+ 228,239,245,226,236,229,227,237, 98,128, 3, 96,111, 2,192, 18,
+ 192, 28,240,229,242,225,244,239,114,128, 34, 60,246,229,242,236,
+ 225,249,227,237, 98,128, 3, 52,246,229,242,244,233,227,225,236,
+ 227,237, 98,128, 3, 62,237,229,243,227,233,242,227,236,101,128,
+ 34,151,112, 2,192, 72,192,102,229,232, 97, 2,192, 80,192, 89,
+ 232,229,226,242,229,119,128, 5,150,236,229,230,244,232,229,226,
+ 242,229,119,128, 5,150,240,233,231,245,242,237,245,235,232,105,
+ 128, 10,112,244,236,239,227,249,242,233,236,236,233,227,227,237,
+ 98,128, 4,131,247,238,225,242,237,229,238,233,225,110,128, 5,
+ 127,236,233,238,229,226,229,236,239,119,128, 30,111,237,239,238,
+ 239,243,240,225,227,101,128,255, 84,111, 7,192,185,192,196,192,
+ 207,192,232,193, 96,193,108,193,192,225,242,237,229,238,233,225,
+ 110,128, 5,105,232,233,242,225,231,225,238, 97,128, 48,104,235,
+ 225,244,225,235,225,238, 97,129, 48,200,192,220,232,225,236,230,
+ 247,233,228,244,104,128,255,132,110, 3,192,240,193, 82,193, 87,
+ 101, 4,192,250,193, 63,193, 70,193, 76,226,225,114, 4,193, 6,
+ 193, 35,193, 45,193, 54,229,248,244,242, 97, 2,193, 16,193, 26,
+ 232,233,231,232,237,239,100,128, 2,229,236,239,247,237,239,100,
+ 128, 2,233,232,233,231,232,237,239,100,128, 2,230,236,239,247,
+ 237,239,100,128, 2,232,237,233,228,237,239,100,128, 2,231,230,
+ 233,246,101,128, 1,189,243,233,120,128, 1,133,244,247,111,128,
+ 1,168,239,115,128, 3,132,243,241,245,225,242,101,128, 51, 39,
+ 240,225,244,225,235,244,232,225,105,128, 14, 15,242,244,239,233,
+ 243,229,243,232,229,236,236,226,242,225,227,235,229,116, 2,193,
+ 131,193,161,236,229,230,116,130, 48, 20,193,142,193,150,243,237,
+ 225,236,108,128,254, 93,246,229,242,244,233,227,225,108,128,254,
+ 57,242,233,231,232,116,130, 48, 21,193,173,193,181,243,237,225,
+ 236,108,128,254, 94,246,229,242,244,233,227,225,108,128,254, 58,
+ 244,225,239,244,232,225,105,128, 14, 21,240, 97, 2,193,209,193,
+ 221,236,225,244,225,236,232,239,239,107,128, 1,171,242,229,110,
+ 128, 36,175,114, 3,193,235,194, 10,194, 25,225,228,229,237,225,
+ 242,107,129, 33, 34,193,247,115, 2,193,253,194, 3,225,238,115,
+ 128,248,234,229,242,233,102,128,246,219,229,244,242,239,230,236,
+ 229,248,232,239,239,107,128, 2,136,233,225,103, 4,194, 37,194,
+ 42,194, 47,194, 52,228,110,128, 37,188,236,102,128, 37,196,242,
+ 116,128, 37,186,245,112,128, 37,178,115,132, 2,166,194, 69,194,
+ 108,194,214,194,227,225,228,105,130, 5,230,194, 79,194, 99,228,
+ 225,231,229,243,104,129,251, 70,194, 90,232,229,226,242,229,119,
+ 128,251, 70,232,229,226,242,229,119,128, 5,230,101, 2,194,114,
+ 194,125,227,249,242,233,236,236,233, 99,128, 4, 70,242,101,134,
+ 5,181,194,142,194,156,194,161,194,170,194,185,194,201, 49, 2,
+ 194,148,194,152, 50,128, 5,181,101,128, 5,181,178, 98,128, 5,
+ 181,232,229,226,242,229,119,128, 5,181,238,225,242,242,239,247,
+ 232,229,226,242,229,119,128, 5,181,241,245,225,242,244,229,242,
+ 232,229,226,242,229,119,128, 5,181,247,233,228,229,232,229,226,
+ 242,229,119,128, 5,181,232,229,227,249,242,233,236,236,233, 99,
+ 128, 4, 91,245,240,229,242,233,239,114,128,246,243,116, 4,194,
+ 247,195, 41,195,106,195,157, 97, 3,194,255,195, 9,195, 16,226,
+ 229,238,231,225,236,105,128, 9,159,228,229,246, 97,128, 9, 31,
+ 231,117, 2,195, 23,195, 32,234,225,242,225,244,105,128, 10,159,
+ 242,237,245,235,232,105,128, 10, 31,229,104, 4,195, 52,195, 61,
+ 195, 75,195, 91,225,242,225,226,233, 99,128, 6,121,230,233,238,
+ 225,236,225,242,225,226,233, 99,128,251,103,233,238,233,244,233,
+ 225,236,225,242,225,226,233, 99,128,251,104,237,229,228,233,225,
+ 236,225,242,225,226,233, 99,128,251,105,232, 97, 3,195,115,195,
+ 125,195,132,226,229,238,231,225,236,105,128, 9,160,228,229,246,
+ 97,128, 9, 32,231,117, 2,195,139,195,148,234,225,242,225,244,
+ 105,128, 10,160,242,237,245,235,232,105,128, 10, 32,245,242,238,
+ 229,100,128, 2,135,117, 3,195,173,195,184,195,209,232,233,242,
+ 225,231,225,238, 97,128, 48,100,235,225,244,225,235,225,238, 97,
+ 129, 48,196,195,197,232,225,236,230,247,233,228,244,104,128,255,
+ 130,243,237,225,236,108, 2,195,219,195,230,232,233,242,225,231,
+ 225,238, 97,128, 48, 99,235,225,244,225,235,225,238, 97,129, 48,
+ 195,195,243,232,225,236,230,247,233,228,244,104,128,255,111,119,
+ 2,196, 5,196,110,101, 2,196, 11,196, 59,236,246,101, 3,196,
+ 21,196, 30,196, 51,227,233,242,227,236,101,128, 36,107,112, 2,
+ 196, 36,196, 43,225,242,229,110,128, 36,127,229,242,233,239,100,
+ 128, 36,147,242,239,237,225,110,128, 33,123,238,244,121, 3,196,
+ 69,196, 78,196, 89,227,233,242,227,236,101,128, 36,115,232,225,
+ 238,231,250,232,239,117,128, 83, 68,112, 2,196, 95,196,102,225,
+ 242,229,110,128, 36,135,229,242,233,239,100,128, 36,155,111,142,
+ 0, 50,196,142,196,151,196,161,196,191,196,243,197, 12,197, 39,
+ 197, 73,197, 85,197,104,197,115,197,148,197,156,197,180,225,242,
+ 225,226,233, 99,128, 6, 98,226,229,238,231,225,236,105,128, 9,
+ 232,227,233,242,227,236,101,129, 36, 97,196,172,233,238,246,229,
+ 242,243,229,243,225,238,243,243,229,242,233,102,128, 39,139,100,
+ 2,196,197,196,203,229,246, 97,128, 9,104,239,116, 2,196,210,
+ 196,221,229,238,236,229,225,228,229,114,128, 32, 37,236,229,225,
+ 228,229,114,129, 32, 37,196,232,246,229,242,244,233,227,225,108,
+ 128,254, 48,231,117, 2,196,250,197, 3,234,225,242,225,244,105,
+ 128, 10,232,242,237,245,235,232,105,128, 10,104,232, 97, 2,197,
+ 19,197, 30,227,235,225,242,225,226,233, 99,128, 6, 98,238,231,
+ 250,232,239,117,128, 48, 34,105, 2,197, 45,197, 63,228,229,239,
+ 231,242,225,240,232,233,227,240,225,242,229,110,128, 50, 33,238,
+ 230,229,242,233,239,114,128, 32,130,237,239,238,239,243,240,225,
+ 227,101,128,255, 18,238,245,237,229,242,225,244,239,242,226,229,
+ 238,231,225,236,105,128, 9,245,239,236,228,243,244,249,236,101,
+ 128,247, 50,112, 2,197,121,197,128,225,242,229,110,128, 36,117,
+ 229,114, 2,197,135,197,141,233,239,100,128, 36,137,243,233,225,
+ 110,128, 6,242,242,239,237,225,110,128, 33,113,115, 2,197,162,
+ 197,170,244,242,239,235,101,128, 1,187,245,240,229,242,233,239,
+ 114,128, 0,178,244,104, 2,197,187,197,192,225,105,128, 14, 82,
+ 233,242,228,115,128, 33, 84,117,145, 0,117,197,237,197,245,198,
+ 30,198, 87,198,225,199, 6,199,129,199,145,199,196,200, 10,200,
+ 91,200,100,200,219,200,243,201, 95,201,123,201,237,225,227,245,
+ 244,101,128, 0,250, 98, 4,197,255,198, 4,198, 13,198, 23,225,
+ 114,128, 2,137,229,238,231,225,236,105,128, 9,137,239,240,239,
+ 237,239,230,111,128, 49, 40,242,229,246,101,128, 1,109, 99, 3,
+ 198, 38,198, 45,198, 77,225,242,239,110,128, 1,212,233,242, 99,
+ 2,198, 53,198, 58,236,101,128, 36,228,245,237,230,236,229,120,
+ 129, 0,251,198, 69,226,229,236,239,119,128, 30,119,249,242,233,
+ 236,236,233, 99,128, 4, 67,100, 5,198, 99,198,110,198,133,198,
+ 139,198,215,225,244,244,225,228,229,246, 97,128, 9, 81,226,108,
+ 2,198,117,198,125,225,227,245,244,101,128, 1,113,231,242,225,
+ 246,101,128, 2, 21,229,246, 97,128, 9, 9,233,229,242,229,243,
+ 233,115,133, 0,252,198,159,198,167,198,175,198,198,198,206,225,
+ 227,245,244,101,128, 1,216,226,229,236,239,119,128, 30,115, 99,
+ 2,198,181,198,188,225,242,239,110,128, 1,218,249,242,233,236,
+ 236,233, 99,128, 4,241,231,242,225,246,101,128, 1,220,237,225,
+ 227,242,239,110,128, 1,214,239,244,226,229,236,239,119,128, 30,
+ 229,103, 2,198,231,198,238,242,225,246,101,128, 0,249,117, 2,
+ 198,244,198,253,234,225,242,225,244,105,128, 10,137,242,237,245,
+ 235,232,105,128, 10, 9,104, 3,199, 14,199, 24,199,102,233,242,
+ 225,231,225,238, 97,128, 48, 70,111, 2,199, 30,199, 40,239,235,
+ 225,226,239,246,101,128, 30,231,242,110,133, 1,176,199, 55,199,
+ 63,199, 74,199, 82,199, 94,225,227,245,244,101,128, 30,233,228,
+ 239,244,226,229,236,239,119,128, 30,241,231,242,225,246,101,128,
+ 30,235,232,239,239,235,225,226,239,246,101,128, 30,237,244,233,
+ 236,228,101,128, 30,239,245,238,231,225,242,245,237,236,225,245,
+ 116,129, 1,113,199,118,227,249,242,233,236,236,233, 99,128, 4,
+ 243,233,238,246,229,242,244,229,228,226,242,229,246,101,128, 2,
+ 23,107, 3,199,153,199,177,199,188,225,244,225,235,225,238, 97,
+ 129, 48,166,199,165,232,225,236,230,247,233,228,244,104,128,255,
+ 115,227,249,242,233,236,236,233, 99,128, 4,121,239,242,229,225,
+ 110,128, 49, 92,109, 2,199,202,199,255, 97, 2,199,208,199,241,
+ 227,242,239,110,130, 1,107,199,219,199,230,227,249,242,233,236,
+ 236,233, 99,128, 4,239,228,233,229,242,229,243,233,115,128, 30,
+ 123,244,242,225,231,245,242,237,245,235,232,105,128, 10, 65,239,
+ 238,239,243,240,225,227,101,128,255, 85,110, 2,200, 16,200, 71,
+ 228,229,242,243,227,239,242,101,132, 0, 95,200, 35,200, 41,200,
+ 53,200, 64,228,226,108,128, 32, 23,237,239,238,239,243,240,225,
+ 227,101,128,255, 63,246,229,242,244,233,227,225,108,128,254, 51,
+ 247,225,246,121,128,254, 79,105, 2,200, 77,200, 82,239,110,128,
+ 34, 42,246,229,242,243,225,108,128, 34, 0,239,231,239,238,229,
+ 107,128, 1,115,112, 5,200,112,200,119,200,127,200,142,200,193,
+ 225,242,229,110,128, 36,176,226,236,239,227,107,128, 37,128,240,
+ 229,242,228,239,244,232,229,226,242,229,119,128, 5,196,243,233,
+ 236,239,110,131, 3,197,200,156,200,177,200,185,228,233,229,242,
+ 229,243,233,115,129, 3,203,200,169,244,239,238,239,115,128, 3,
+ 176,236,225,244,233,110,128, 2,138,244,239,238,239,115,128, 3,
+ 205,244,225,227,107, 2,200,202,200,213,226,229,236,239,247,227,
+ 237, 98,128, 3, 29,237,239,100,128, 2,212,114, 2,200,225,200,
+ 237,225,231,245,242,237,245,235,232,105,128, 10,115,233,238,103,
+ 128, 1,111,115, 3,200,251,201, 10,201, 55,232,239,242,244,227,
+ 249,242,233,236,236,233, 99,128, 4, 94,237,225,236,108, 2,201,
+ 19,201, 30,232,233,242,225,231,225,238, 97,128, 48, 69,235,225,
+ 244,225,235,225,238, 97,129, 48,165,201, 43,232,225,236,230,247,
+ 233,228,244,104,128,255,105,244,242,225,233,231,232,116, 2,201,
+ 67,201, 78,227,249,242,233,236,236,233, 99,128, 4,175,243,244,
+ 242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,177,244,
+ 233,236,228,101,130, 1,105,201,107,201,115,225,227,245,244,101,
+ 128, 30,121,226,229,236,239,119,128, 30,117,117, 5,201,135,201,
+ 145,201,152,201,177,201,193,226,229,238,231,225,236,105,128, 9,
+ 138,228,229,246, 97,128, 9, 10,231,117, 2,201,159,201,168,234,
+ 225,242,225,244,105,128, 10,138,242,237,245,235,232,105,128, 10,
+ 10,237,225,244,242,225,231,245,242,237,245,235,232,105,128, 10,
+ 66,246,239,247,229,236,243,233,231,110, 3,201,209,201,219,201,
+ 226,226,229,238,231,225,236,105,128, 9,194,228,229,246, 97,128,
+ 9, 66,231,245,234,225,242,225,244,105,128, 10,194,246,239,247,
+ 229,236,243,233,231,110, 3,201,253,202, 7,202, 14,226,229,238,
+ 231,225,236,105,128, 9,193,228,229,246, 97,128, 9, 65,231,245,
+ 234,225,242,225,244,105,128, 10,193,118,139, 0,118,202, 51,202,
+ 199,202,208,202,219,203,148,203,155,203,253,204, 9,204,109,204,
+ 117,204,138, 97, 4,202, 61,202, 68,202, 93,202,104,228,229,246,
+ 97,128, 9, 53,231,117, 2,202, 75,202, 84,234,225,242,225,244,
+ 105,128, 10,181,242,237,245,235,232,105,128, 10, 53,235,225,244,
+ 225,235,225,238, 97,128, 48,247,118,132, 5,213,202,116,202,143,
+ 202,175,202,187,228,225,231,229,243,104,130,251, 53,202,129,202,
+ 134,182, 53,128,251, 53,232,229,226,242,229,119,128,251, 53,104,
+ 2,202,149,202,157,229,226,242,229,119,128, 5,213,239,236,225,
+ 109,129,251, 75,202,166,232,229,226,242,229,119,128,251, 75,246,
+ 225,246,232,229,226,242,229,119,128, 5,240,249,239,228,232,229,
+ 226,242,229,119,128, 5,241,227,233,242,227,236,101,128, 36,229,
+ 228,239,244,226,229,236,239,119,128, 30,127,101, 6,202,233,202,
+ 244,203, 52,203, 63,203, 69,203,136,227,249,242,233,236,236,233,
+ 99,128, 4, 50,104, 4,202,254,203, 7,203, 21,203, 37,225,242,
+ 225,226,233, 99,128, 6,164,230,233,238,225,236,225,242,225,226,
+ 233, 99,128,251,107,233,238,233,244,233,225,236,225,242,225,226,
+ 233, 99,128,251,108,237,229,228,233,225,236,225,242,225,226,233,
+ 99,128,251,109,235,225,244,225,235,225,238, 97,128, 48,249,238,
+ 245,115,128, 38, 64,242,244,233,227,225,108, 2,203, 80,203, 86,
+ 226,225,114,128, 0,124,236,233,238,101, 4,203, 99,203,110,203,
+ 121,203,130,225,226,239,246,229,227,237, 98,128, 3, 13,226,229,
+ 236,239,247,227,237, 98,128, 3, 41,236,239,247,237,239,100,128,
+ 2,204,237,239,100,128, 2,200,247,225,242,237,229,238,233,225,
+ 110,128, 5,126,232,239,239,107,128, 2,139,105, 3,203,163,203,
+ 174,203,213,235,225,244,225,235,225,238, 97,128, 48,248,242,225,
+ 237, 97, 3,203,185,203,195,203,202,226,229,238,231,225,236,105,
+ 128, 9,205,228,229,246, 97,128, 9, 77,231,245,234,225,242,225,
+ 244,105,128, 10,205,243,225,242,231, 97, 3,203,225,203,235,203,
+ 242,226,229,238,231,225,236,105,128, 9,131,228,229,246, 97,128,
+ 9, 3,231,245,234,225,242,225,244,105,128, 10,131,237,239,238,
+ 239,243,240,225,227,101,128,255, 86,111, 3,204, 17,204, 28,204,
+ 98,225,242,237,229,238,233,225,110,128, 5,120,233,227,229,100,
+ 2,204, 37,204, 73,233,244,229,242,225,244,233,239,110, 2,204,
+ 51,204, 62,232,233,242,225,231,225,238, 97,128, 48,158,235,225,
+ 244,225,235,225,238, 97,128, 48,254,237,225,242,235,235,225,238,
+ 97,129, 48,155,204, 86,232,225,236,230,247,233,228,244,104,128,
+ 255,158,235,225,244,225,235,225,238, 97,128, 48,250,240,225,242,
+ 229,110,128, 36,177,116, 2,204,123,204,130,233,236,228,101,128,
+ 30,125,245,242,238,229,100,128, 2,140,117, 2,204,144,204,155,
+ 232,233,242,225,231,225,238, 97,128, 48,148,235,225,244,225,235,
+ 225,238, 97,128, 48,244,119,143, 0,119,204,200,205,177,205,187,
+ 205,210,205,250,206, 61,206, 69,208, 40,208, 81,208, 93,208,168,
+ 208,176,208,183,208,194,208,203, 97, 8,204,218,204,225,204,235,
+ 204,246,205, 28,205, 60,205, 72,205,108,227,245,244,101,128, 30,
+ 131,229,235,239,242,229,225,110,128, 49, 89,232,233,242,225,231,
+ 225,238, 97,128, 48,143,107, 2,204,252,205, 20,225,244,225,235,
+ 225,238, 97,129, 48,239,205, 8,232,225,236,230,247,233,228,244,
+ 104,128,255,156,239,242,229,225,110,128, 49, 88,243,237,225,236,
+ 108, 2,205, 38,205, 49,232,233,242,225,231,225,238, 97,128, 48,
+ 142,235,225,244,225,235,225,238, 97,128, 48,238,244,244,239,243,
+ 241,245,225,242,101,128, 51, 87,118, 2,205, 78,205, 86,229,228,
+ 225,243,104,128, 48, 28,249,245,238,228,229,242,243,227,239,242,
+ 229,246,229,242,244,233,227,225,108,128,254, 52,119, 3,205,116,
+ 205,125,205,139,225,242,225,226,233, 99,128, 6, 72,230,233,238,
+ 225,236,225,242,225,226,233, 99,128,254,238,232,225,237,250,225,
+ 225,226,239,246,101, 2,205,154,205,163,225,242,225,226,233, 99,
+ 128, 6, 36,230,233,238,225,236,225,242,225,226,233, 99,128,254,
+ 134,226,243,241,245,225,242,101,128, 51,221,227,233,242, 99, 2,
+ 205,196,205,201,236,101,128, 36,230,245,237,230,236,229,120,128,
+ 1,117,100, 2,205,216,205,226,233,229,242,229,243,233,115,128,
+ 30,133,239,116, 2,205,233,205,242,225,227,227,229,238,116,128,
+ 30,135,226,229,236,239,119,128, 30,137,101, 4,206, 4,206, 15,
+ 206, 27,206, 51,232,233,242,225,231,225,238, 97,128, 48,145,233,
+ 229,242,243,244,242,225,243,115,128, 33, 24,107, 2,206, 33,206,
+ 43,225,244,225,235,225,238, 97,128, 48,241,239,242,229,225,110,
+ 128, 49, 94,239,235,239,242,229,225,110,128, 49, 93,231,242,225,
+ 246,101,128, 30,129,232,233,244,101, 8,206, 90,206, 99,206,183,
+ 207, 17,207,101,207,146,207,198,207,254,226,245,236,236,229,116,
+ 128, 37,230, 99, 2,206,105,206,125,233,242,227,236,101,129, 37,
+ 203,206,115,233,238,246,229,242,243,101,128, 37,217,239,242,238,
+ 229,242,226,242,225,227,235,229,116, 2,206,142,206,162,236,229,
+ 230,116,129, 48, 14,206,151,246,229,242,244,233,227,225,108,128,
+ 254, 67,242,233,231,232,116,129, 48, 15,206,172,246,229,242,244,
+ 233,227,225,108,128,254, 68,100, 2,206,189,206,230,233,225,237,
+ 239,238,100,129, 37,199,206,200,227,239,238,244,225,233,238,233,
+ 238,231,226,236,225,227,235,243,237,225,236,236,228,233,225,237,
+ 239,238,100,128, 37,200,239,247,238,240,239,233,238,244,233,238,
+ 103, 2,206,246,207, 6,243,237,225,236,236,244,242,233,225,238,
+ 231,236,101,128, 37,191,244,242,233,225,238,231,236,101,128, 37,
+ 189,236,101, 2,207, 24,207, 66,230,244,240,239,233,238,244,233,
+ 238,103, 2,207, 39,207, 55,243,237,225,236,236,244,242,233,225,
+ 238,231,236,101,128, 37,195,244,242,233,225,238,231,236,101,128,
+ 37,193,238,244,233,227,245,236,225,242,226,242,225,227,235,229,
+ 116, 2,207, 86,207, 93,236,229,230,116,128, 48, 22,242,233,231,
+ 232,116,128, 48, 23,242,233,231,232,244,240,239,233,238,244,233,
+ 238,103, 2,207,119,207,135,243,237,225,236,236,244,242,233,225,
+ 238,231,236,101,128, 37,185,244,242,233,225,238,231,236,101,128,
+ 37,183,115, 3,207,154,207,184,207,192,109, 2,207,160,207,172,
+ 225,236,236,243,241,245,225,242,101,128, 37,171,233,236,233,238,
+ 231,230,225,227,101,128, 38, 58,241,245,225,242,101,128, 37,161,
+ 244,225,114,128, 38, 6,116, 2,207,204,207,215,229,236,229,240,
+ 232,239,238,101,128, 38, 15,239,242,244,239,233,243,229,243,232,
+ 229,236,236,226,242,225,227,235,229,116, 2,207,239,207,246,236,
+ 229,230,116,128, 48, 24,242,233,231,232,116,128, 48, 25,245,240,
+ 240,239,233,238,244,233,238,103, 2,208, 13,208, 29,243,237,225,
+ 236,236,244,242,233,225,238,231,236,101,128, 37,181,244,242,233,
+ 225,238,231,236,101,128, 37,179,105, 2,208, 46,208, 57,232,233,
+ 242,225,231,225,238, 97,128, 48,144,107, 2,208, 63,208, 73,225,
+ 244,225,235,225,238, 97,128, 48,240,239,242,229,225,110,128, 49,
+ 95,237,239,238,239,243,240,225,227,101,128,255, 87,111, 4,208,
+ 103,208,114,208,139,208,157,232,233,242,225,231,225,238, 97,128,
+ 48,146,235,225,244,225,235,225,238, 97,129, 48,242,208,127,232,
+ 225,236,230,247,233,228,244,104,128,255,102,110,129, 32,169,208,
+ 145,237,239,238,239,243,240,225,227,101,128,255,230,247,225,229,
+ 238,244,232,225,105,128, 14, 39,240,225,242,229,110,128, 36,178,
+ 242,233,238,103,128, 30,152,243,245,240,229,242,233,239,114,128,
+ 2,183,244,245,242,238,229,100,128, 2,141,249,238,110,128, 1,
+ 191,120,137, 0,120,208,231,208,242,208,253,209, 6,209, 33,209,
+ 46,209, 50,209, 62,209, 70,225,226,239,246,229,227,237, 98,128,
+ 3, 61,226,239,240,239,237,239,230,111,128, 49, 18,227,233,242,
+ 227,236,101,128, 36,231,100, 2,209, 12,209, 22,233,229,242,229,
+ 243,233,115,128, 30,141,239,244,225,227,227,229,238,116,128, 30,
+ 139,229,232,225,242,237,229,238,233,225,110,128, 5,109,105,128,
+ 3,190,237,239,238,239,243,240,225,227,101,128,255, 88,240,225,
+ 242,229,110,128, 36,179,243,245,240,229,242,233,239,114,128, 2,
+ 227,121,143, 0,121,209,115,210, 74,210, 97,210,137,212,103,212,
+ 111,212,128,212,192,212,204,213,201,213,241,213,253,214, 8,214,
+ 29,215, 2, 97, 11,209,139,209,151,209,161,209,168,209,175,209,
+ 185,209,210,209,221,210, 3,210, 16,210, 62,225,228,239,243,241,
+ 245,225,242,101,128, 51, 78,226,229,238,231,225,236,105,128, 9,
+ 175,227,245,244,101,128, 0,253,228,229,246, 97,128, 9, 47,229,
+ 235,239,242,229,225,110,128, 49, 82,231,117, 2,209,192,209,201,
+ 234,225,242,225,244,105,128, 10,175,242,237,245,235,232,105,128,
+ 10, 47,232,233,242,225,231,225,238, 97,128, 48,132,107, 2,209,
+ 227,209,251,225,244,225,235,225,238, 97,129, 48,228,209,239,232,
+ 225,236,230,247,233,228,244,104,128,255,148,239,242,229,225,110,
+ 128, 49, 81,237,225,235,235,225,238,244,232,225,105,128, 14, 78,
+ 243,237,225,236,108, 2,210, 26,210, 37,232,233,242,225,231,225,
+ 238, 97,128, 48,131,235,225,244,225,235,225,238, 97,129, 48,227,
+ 210, 50,232,225,236,230,247,233,228,244,104,128,255,108,244,227,
+ 249,242,233,236,236,233, 99,128, 4, 99,227,233,242, 99, 2,210,
+ 83,210, 88,236,101,128, 36,232,245,237,230,236,229,120,128, 1,
+ 119,100, 2,210,103,210,113,233,229,242,229,243,233,115,128, 0,
+ 255,239,116, 2,210,120,210,129,225,227,227,229,238,116,128, 30,
+ 143,226,229,236,239,119,128, 30,245,101, 7,210,153,211,161,211,
+ 170,211,188,211,220,212, 40,212, 91,104, 8,210,171,210,180,210,
+ 214,210,228,211, 45,211, 61,211,120,211,138,225,242,225,226,233,
+ 99,128, 6, 74,226,225,242,242,229,101, 2,210,191,210,200,225,
+ 242,225,226,233, 99,128, 6,210,230,233,238,225,236,225,242,225,
+ 226,233, 99,128,251,175,230,233,238,225,236,225,242,225,226,233,
+ 99,128,254,242,232,225,237,250,225,225,226,239,246,101, 4,210,
+ 247,211, 0,211, 14,211, 30,225,242,225,226,233, 99,128, 6, 38,
+ 230,233,238,225,236,225,242,225,226,233, 99,128,254,138,233,238,
+ 233,244,233,225,236,225,242,225,226,233, 99,128,254,139,237,229,
+ 228,233,225,236,225,242,225,226,233, 99,128,254,140,233,238,233,
+ 244,233,225,236,225,242,225,226,233, 99,128,254,243,237,101, 2,
+ 211, 68,211, 81,228,233,225,236,225,242,225,226,233, 99,128,254,
+ 244,229,237,105, 2,211, 89,211,104,238,233,244,233,225,236,225,
+ 242,225,226,233, 99,128,252,221,243,239,236,225,244,229,228,225,
+ 242,225,226,233, 99,128,252, 88,238,239,239,238,230,233,238,225,
+ 236,225,242,225,226,233, 99,128,252,148,244,232,242,229,229,228,
+ 239,244,243,226,229,236,239,247,225,242,225,226,233, 99,128, 6,
+ 209,235,239,242,229,225,110,128, 49, 86,110,129, 0,165,211,176,
+ 237,239,238,239,243,240,225,227,101,128,255,229,111, 2,211,194,
+ 211,203,235,239,242,229,225,110,128, 49, 85,242,233,238,232,233,
+ 229,245,232,235,239,242,229,225,110,128, 49,134,114, 3,211,228,
+ 212, 8,212, 20,225,232,226,229,238,249,239,237,111, 2,211,242,
+ 211,251,232,229,226,242,229,119,128, 5,170,236,229,230,244,232,
+ 229,226,242,229,119,128, 5,170,233,227,249,242,233,236,236,233,
+ 99,128, 4, 75,245,228,233,229,242,229,243,233,243,227,249,242,
+ 233,236,236,233, 99,128, 4,249,243,233,229,245,238,103, 3,212,
+ 53,212, 62,212, 78,235,239,242,229,225,110,128, 49,129,240,225,
+ 238,243,233,239,243,235,239,242,229,225,110,128, 49,131,243,233,
+ 239,243,235,239,242,229,225,110,128, 49,130,244,233,246,232,229,
+ 226,242,229,119,128, 5,154,231,242,225,246,101,128, 30,243,232,
+ 239,239,107,129, 1,180,212,120,225,226,239,246,101,128, 30,247,
+ 105, 5,212,140,212,151,212,162,212,171,212,179,225,242,237,229,
+ 238,233,225,110,128, 5,117,227,249,242,233,236,236,233, 99,128,
+ 4, 87,235,239,242,229,225,110,128, 49, 98,238,249,225,238,103,
+ 128, 38, 47,247,238,225,242,237,229,238,233,225,110,128, 5,130,
+ 237,239,238,239,243,240,225,227,101,128,255, 89,111, 7,212,220,
+ 213, 34,213, 45,213, 55,213, 93,213,139,213,148,100,131, 5,217,
+ 212,230,212,250,213, 3,228,225,231,229,243,104,129,251, 57,212,
+ 241,232,229,226,242,229,119,128,251, 57,232,229,226,242,229,119,
+ 128, 5,217,249,239,100, 2,213, 11,213, 20,232,229,226,242,229,
+ 119,128, 5,242,240,225,244,225,232,232,229,226,242,229,119,128,
+ 251, 31,232,233,242,225,231,225,238, 97,128, 48,136,233,235,239,
+ 242,229,225,110,128, 49,137,107, 2,213, 61,213, 85,225,244,225,
+ 235,225,238, 97,129, 48,232,213, 73,232,225,236,230,247,233,228,
+ 244,104,128,255,150,239,242,229,225,110,128, 49, 91,243,237,225,
+ 236,108, 2,213,103,213,114,232,233,242,225,231,225,238, 97,128,
+ 48,135,235,225,244,225,235,225,238, 97,129, 48,231,213,127,232,
+ 225,236,230,247,233,228,244,104,128,255,110,244,231,242,229,229,
+ 107,128, 3,243,121, 2,213,154,213,191, 97, 2,213,160,213,170,
+ 229,235,239,242,229,225,110,128, 49,136,107, 2,213,176,213,184,
+ 239,242,229,225,110,128, 49,135,244,232,225,105,128, 14, 34,233,
+ 238,231,244,232,225,105,128, 14, 13,112, 2,213,207,213,214,225,
+ 242,229,110,128, 36,180,239,231,229,231,242,225,237,237,229,238,
+ 105,129, 3,122,213,230,231,242,229,229,235,227,237, 98,128, 3,
+ 69,114,129, 1,166,213,247,233,238,103,128, 30,153,243,245,240,
+ 229,242,233,239,114,128, 2,184,116, 2,214, 14,214, 21,233,236,
+ 228,101,128, 30,249,245,242,238,229,100,128, 2,142,117, 5,214,
+ 41,214, 52,214, 62,214,100,214,232,232,233,242,225,231,225,238,
+ 97,128, 48,134,233,235,239,242,229,225,110,128, 49,140,107, 2,
+ 214, 68,214, 92,225,244,225,235,225,238, 97,129, 48,230,214, 80,
+ 232,225,236,230,247,233,228,244,104,128,255,149,239,242,229,225,
+ 110,128, 49, 96,115, 3,214,108,214,146,214,187,226,233,103, 2,
+ 214,116,214,127,227,249,242,233,236,236,233, 99,128, 4,107,233,
+ 239,244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128,
+ 4,109,236,233,244,244,236,101, 2,214,157,214,168,227,249,242,
+ 233,236,236,233, 99,128, 4,103,233,239,244,233,230,233,229,228,
+ 227,249,242,233,236,236,233, 99,128, 4,105,237,225,236,108, 2,
+ 214,196,214,207,232,233,242,225,231,225,238, 97,128, 48,133,235,
+ 225,244,225,235,225,238, 97,129, 48,229,214,220,232,225,236,230,
+ 247,233,228,244,104,128,255,109,249,101, 2,214,239,214,248,235,
+ 239,242,229,225,110,128, 49,139,239,235,239,242,229,225,110,128,
+ 49,138,249, 97, 2,215, 9,215, 19,226,229,238,231,225,236,105,
+ 128, 9,223,228,229,246, 97,128, 9, 95,122,142, 0,122,215, 58,
+ 216, 66,216, 77,216,120,216,147,217,182,218, 34,218, 76,218, 88,
+ 218,100,218,128,218,136,218,152,218,161, 97, 10,215, 80,215, 91,
+ 215, 98,215,105,215,116,215,194,215,224,215,235,216, 15,216, 27,
+ 225,242,237,229,238,233,225,110,128, 5,102,227,245,244,101,128,
+ 1,122,228,229,246, 97,128, 9, 91,231,245,242,237,245,235,232,
+ 105,128, 10, 91,104, 4,215,126,215,135,215,149,215,179,225,242,
+ 225,226,233, 99,128, 6, 56,230,233,238,225,236,225,242,225,226,
+ 233, 99,128,254,198,105, 2,215,155,215,170,238,233,244,233,225,
+ 236,225,242,225,226,233, 99,128,254,199,242,225,231,225,238, 97,
+ 128, 48, 86,237,229,228,233,225,236,225,242,225,226,233, 99,128,
+ 254,200,233,110, 2,215,201,215,210,225,242,225,226,233, 99,128,
+ 6, 50,230,233,238,225,236,225,242,225,226,233, 99,128,254,176,
+ 235,225,244,225,235,225,238, 97,128, 48,182,241,229,102, 2,215,
+ 243,216, 1,231,225,228,239,236,232,229,226,242,229,119,128, 5,
+ 149,241,225,244,225,238,232,229,226,242,229,119,128, 5,148,242,
+ 241,225,232,229,226,242,229,119,128, 5,152,249,233,110,130, 5,
+ 214,216, 37,216, 57,228,225,231,229,243,104,129,251, 54,216, 48,
+ 232,229,226,242,229,119,128,251, 54,232,229,226,242,229,119,128,
+ 5,214,226,239,240,239,237,239,230,111,128, 49, 23, 99, 3,216,
+ 85,216, 92,216,114,225,242,239,110,128, 1,126,233,242, 99, 2,
+ 216,100,216,105,236,101,128, 36,233,245,237,230,236,229,120,128,
+ 30,145,245,242,108,128, 2,145,228,239,116,130, 1,124,216,130,
+ 216,139,225,227,227,229,238,116,128, 1,124,226,229,236,239,119,
+ 128, 30,147,101, 6,216,161,216,172,216,215,216,226,216,237,217,
+ 177,227,249,242,233,236,236,233, 99,128, 4, 55,100, 2,216,178,
+ 216,197,229,243,227,229,238,228,229,242,227,249,242,233,236,236,
+ 233, 99,128, 4,153,233,229,242,229,243,233,243,227,249,242,233,
+ 236,236,233, 99,128, 4,223,232,233,242,225,231,225,238, 97,128,
+ 48, 92,235,225,244,225,235,225,238, 97,128, 48,188,242,111,140,
+ 0, 48,217, 10,217, 19,217, 29,217, 36,217, 61,217, 74,217, 85,
+ 217, 97,217,108,217,118,217,129,217,136,225,242,225,226,233, 99,
+ 128, 6, 96,226,229,238,231,225,236,105,128, 9,230,228,229,246,
+ 97,128, 9,102,231,117, 2,217, 43,217, 52,234,225,242,225,244,
+ 105,128, 10,230,242,237,245,235,232,105,128, 10,102,232,225,227,
+ 235,225,242,225,226,233, 99,128, 6, 96,233,238,230,229,242,233,
+ 239,114,128, 32,128,237,239,238,239,243,240,225,227,101,128,255,
+ 16,239,236,228,243,244,249,236,101,128,247, 48,240,229,242,243,
+ 233,225,110,128, 6,240,243,245,240,229,242,233,239,114,128, 32,
+ 112,244,232,225,105,128, 14, 80,247,233,228,244,104, 3,217,148,
+ 217,157,217,169,234,239,233,238,229,114,128,254,255,238,239,238,
+ 234,239,233,238,229,114,128, 32, 12,243,240,225,227,101,128, 32,
+ 11,244, 97,128, 3,182,104, 2,217,188,217,199,226,239,240,239,
+ 237,239,230,111,128, 49, 19,101, 4,217,209,217,220,217,236,217,
+ 247,225,242,237,229,238,233,225,110,128, 5,106,226,242,229,246,
+ 229,227,249,242,233,236,236,233, 99,128, 4,194,227,249,242,233,
+ 236,236,233, 99,128, 4, 54,100, 2,217,253,218, 16,229,243,227,
+ 229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,151,
233,229,242,229,243,233,243,227,249,242,233,236,236,233, 99,128,
- 4,249,243,233,229,245,238,103, 3,207,127,207,136,207,152,235,
- 239,242,229,225,110,128, 49,129,240,225,238,243,233,239,243,235,
- 239,242,229,225,110,128, 49,131,243,233,239,243,235,239,242,229,
- 225,110,128, 49,130,244,233,246,232,229,226,242,229,119,128, 5,
- 154,231,242,225,246,101,128, 30,243,232,239,239,107,129, 1,180,
- 207,194,225,226,239,246,101,128, 30,247,105, 5,207,214,207,225,
- 207,236,207,245,207,253,225,242,237,229,238,233,225,110,128, 5,
- 117,227,249,242,233,236,236,233, 99,128, 4, 87,235,239,242,229,
- 225,110,128, 49, 98,238,249,225,238,103,128, 38, 47,247,238,225,
- 242,237,229,238,233,225,110,128, 5,130,237,239,238,239,243,240,
- 225,227,101,128,255, 89,111, 7,208, 38,208,108,208,119,208,129,
- 208,167,208,213,208,222,100,131, 5,217,208, 48,208, 68,208, 77,
- 228,225,231,229,243,104,129,251, 57,208, 59,232,229,226,242,229,
- 119,128,251, 57,232,229,226,242,229,119,128, 5,217,249,239,100,
- 2,208, 85,208, 94,232,229,226,242,229,119,128, 5,242,240,225,
- 244,225,232,232,229,226,242,229,119,128,251, 31,232,233,242,225,
- 231,225,238, 97,128, 48,136,233,235,239,242,229,225,110,128, 49,
- 137,107, 2,208,135,208,159,225,244,225,235,225,238, 97,129, 48,
- 232,208,147,232,225,236,230,247,233,228,244,104,128,255,150,239,
- 242,229,225,110,128, 49, 91,243,237,225,236,108, 2,208,177,208,
- 188,232,233,242,225,231,225,238, 97,128, 48,135,235,225,244,225,
- 235,225,238, 97,129, 48,231,208,201,232,225,236,230,247,233,228,
- 244,104,128,255,110,244,231,242,229,229,107,128, 3,243,121, 2,
- 208,228,209, 9, 97, 2,208,234,208,244,229,235,239,242,229,225,
- 110,128, 49,136,107, 2,208,250,209, 2,239,242,229,225,110,128,
- 49,135,244,232,225,105,128, 14, 34,233,238,231,244,232,225,105,
- 128, 14, 13,112, 2,209, 25,209, 32,225,242,229,110,128, 36,180,
- 239,231,229,231,242,225,237,237,229,238,105,129, 3,122,209, 48,
- 231,242,229,229,235,227,237, 98,128, 3, 69,114,129, 1,166,209,
- 65,233,238,103,128, 30,153,243,245,240,229,242,233,239,114,128,
- 2,184,116, 2,209, 88,209, 95,233,236,228,101,128, 30,249,245,
- 242,238,229,100,128, 2,142,117, 5,209,115,209,126,209,136,209,
- 174,210, 50,232,233,242,225,231,225,238, 97,128, 48,134,233,235,
- 239,242,229,225,110,128, 49,140,107, 2,209,142,209,166,225,244,
- 225,235,225,238, 97,129, 48,230,209,154,232,225,236,230,247,233,
- 228,244,104,128,255,149,239,242,229,225,110,128, 49, 96,115, 3,
- 209,182,209,220,210, 5,226,233,103, 2,209,190,209,201,227,249,
- 242,233,236,236,233, 99,128, 4,107,233,239,244,233,230,233,229,
- 228,227,249,242,233,236,236,233, 99,128, 4,109,236,233,244,244,
- 236,101, 2,209,231,209,242,227,249,242,233,236,236,233, 99,128,
- 4,103,233,239,244,233,230,233,229,228,227,249,242,233,236,236,
- 233, 99,128, 4,105,237,225,236,108, 2,210, 14,210, 25,232,233,
- 242,225,231,225,238, 97,128, 48,133,235,225,244,225,235,225,238,
- 97,129, 48,229,210, 38,232,225,236,230,247,233,228,244,104,128,
- 255,109,249,101, 2,210, 57,210, 66,235,239,242,229,225,110,128,
- 49,139,239,235,239,242,229,225,110,128, 49,138,249, 97, 2,210,
- 83,210, 93,226,229,238,231,225,236,105,128, 9,223,228,229,246,
- 97,128, 9, 95,122,142, 0,122,210,132,211,140,211,151,211,194,
- 211,221,213, 0,213,108,213,150,213,162,213,174,213,202,213,210,
- 213,226,213,235, 97, 10,210,154,210,165,210,172,210,179,210,190,
- 211, 12,211, 42,211, 53,211, 89,211,101,225,242,237,229,238,233,
- 225,110,128, 5,102,227,245,244,101,128, 1,122,228,229,246, 97,
- 128, 9, 91,231,245,242,237,245,235,232,105,128, 10, 91,104, 4,
- 210,200,210,209,210,223,210,253,225,242,225,226,233, 99,128, 6,
- 56,230,233,238,225,236,225,242,225,226,233, 99,128,254,198,105,
- 2,210,229,210,244,238,233,244,233,225,236,225,242,225,226,233,
- 99,128,254,199,242,225,231,225,238, 97,128, 48, 86,237,229,228,
- 233,225,236,225,242,225,226,233, 99,128,254,200,233,110, 2,211,
- 19,211, 28,225,242,225,226,233, 99,128, 6, 50,230,233,238,225,
- 236,225,242,225,226,233, 99,128,254,176,235,225,244,225,235,225,
- 238, 97,128, 48,182,241,229,102, 2,211, 61,211, 75,231,225,228,
- 239,236,232,229,226,242,229,119,128, 5,149,241,225,244,225,238,
- 232,229,226,242,229,119,128, 5,148,242,241,225,232,229,226,242,
- 229,119,128, 5,152,249,233,110,130, 5,214,211,111,211,131,228,
- 225,231,229,243,104,129,251, 54,211,122,232,229,226,242,229,119,
- 128,251, 54,232,229,226,242,229,119,128, 5,214,226,239,240,239,
- 237,239,230,111,128, 49, 23, 99, 3,211,159,211,166,211,188,225,
- 242,239,110,128, 1,126,233,242, 99, 2,211,174,211,179,236,101,
- 128, 36,233,245,237,230,236,229,120,128, 30,145,245,242,108,128,
- 2,145,228,239,116,130, 1,124,211,204,211,213,225,227,227,229,
- 238,116,128, 1,124,226,229,236,239,119,128, 30,147,101, 6,211,
- 235,211,246,212, 33,212, 44,212, 55,212,251,227,249,242,233,236,
- 236,233, 99,128, 4, 55,100, 2,211,252,212, 15,229,243,227,229,
- 238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,153,233,
- 229,242,229,243,233,243,227,249,242,233,236,236,233, 99,128, 4,
- 223,232,233,242,225,231,225,238, 97,128, 48, 92,235,225,244,225,
- 235,225,238, 97,128, 48,188,242,111,140, 0, 48,212, 84,212, 93,
- 212,103,212,110,212,135,212,148,212,159,212,171,212,182,212,192,
- 212,203,212,210,225,242,225,226,233, 99,128, 6, 96,226,229,238,
- 231,225,236,105,128, 9,230,228,229,246, 97,128, 9,102,231,117,
- 2,212,117,212,126,234,225,242,225,244,105,128, 10,230,242,237,
- 245,235,232,105,128, 10,102,232,225,227,235,225,242,225,226,233,
- 99,128, 6, 96,233,238,230,229,242,233,239,114,128, 32,128,237,
- 239,238,239,243,240,225,227,101,128,255, 16,239,236,228,243,244,
- 249,236,101,128,247, 48,240,229,242,243,233,225,110,128, 6,240,
- 243,245,240,229,242,233,239,114,128, 32,112,244,232,225,105,128,
- 14, 80,247,233,228,244,104, 3,212,222,212,231,212,243,234,239,
- 233,238,229,114,128,254,255,238,239,238,234,239,233,238,229,114,
- 128, 32, 12,243,240,225,227,101,128, 32, 11,244, 97,128, 3,182,
- 104, 2,213, 6,213, 17,226,239,240,239,237,239,230,111,128, 49,
- 19,101, 4,213, 27,213, 38,213, 54,213, 65,225,242,237,229,238,
- 233,225,110,128, 5,106,226,242,229,246,229,227,249,242,233,236,
- 236,233, 99,128, 4,194,227,249,242,233,236,236,233, 99,128, 4,
- 54,100, 2,213, 71,213, 90,229,243,227,229,238,228,229,242,227,
- 249,242,233,236,236,233, 99,128, 4,151,233,229,242,229,243,233,
- 243,227,249,242,233,236,236,233, 99,128, 4,221,105, 3,213,116,
- 213,127,213,138,232,233,242,225,231,225,238, 97,128, 48, 88,235,
- 225,244,225,235,225,238, 97,128, 48,184,238,239,242,232,229,226,
- 242,229,119,128, 5,174,236,233,238,229,226,229,236,239,119,128,
- 30,149,237,239,238,239,243,240,225,227,101,128,255, 90,111, 2,
- 213,180,213,191,232,233,242,225,231,225,238, 97,128, 48, 94,235,
- 225,244,225,235,225,238, 97,128, 48,190,240,225,242,229,110,128,
- 36,181,242,229,244,242,239,230,236,229,248,232,239,239,107,128,
- 2,144,243,244,242,239,235,101,128, 1,182,117, 2,213,241,213,
- 252,232,233,242,225,231,225,238, 97,128, 48, 90,235,225,244,225,
- 235,225,238, 97,128, 48,186
+ 4,221,105, 3,218, 42,218, 53,218, 64,232,233,242,225,231,225,
+ 238, 97,128, 48, 88,235,225,244,225,235,225,238, 97,128, 48,184,
+ 238,239,242,232,229,226,242,229,119,128, 5,174,236,233,238,229,
+ 226,229,236,239,119,128, 30,149,237,239,238,239,243,240,225,227,
+ 101,128,255, 90,111, 2,218,106,218,117,232,233,242,225,231,225,
+ 238, 97,128, 48, 94,235,225,244,225,235,225,238, 97,128, 48,190,
+ 240,225,242,229,110,128, 36,181,242,229,244,242,239,230,236,229,
+ 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
};
diff --git a/src/3rdparty/freetype/src/psnames/rules.mk b/src/3rdparty/freetype/src/psnames/rules.mk
index 06bd161e34..f321de2d64 100644
--- a/src/3rdparty/freetype/src/psnames/rules.mk
+++ b/src/3rdparty/freetype/src/psnames/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2001, 2003 by
+# Copyright 1996-2001, 2003, 2011, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -25,14 +25,15 @@ PSNAMES_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PSNAMES_DIR))
# PSNames driver sources (i.e., C files)
#
-PSNAMES_DRV_SRC := $(PSNAMES_DIR)/psmodule.c
+PSNAMES_DRV_SRC := $(PSNAMES_DIR)/psmodule.c \
+ $(PSNAMES_DIR)/pspic.c
# PSNames driver headers
#
PSNAMES_DRV_H := $(PSNAMES_DRV_SRC:%.c=%.h) \
- $(PSNAMES_DIR)/pstables.h \
- $(PSNAMES_DIR)/psnamerr.h
+ $(PSNAMES_DIR)/psnamerr.h \
+ $(PSNAMES_DIR)/pstables.h
# PSNames driver object(s)
@@ -45,7 +46,7 @@ PSNAMES_DRV_OBJ_S := $(OBJ_DIR)/psnames.$O
# PSNames driver source file for single build
#
-PSNAMES_DRV_SRC_S := $(PSNAMES_DIR)/psmodule.c
+PSNAMES_DRV_SRC_S := $(PSNAMES_DIR)/psnames.c
# PSNames driver - single object
diff --git a/src/3rdparty/freetype/src/raster/ftmisc.h b/src/3rdparty/freetype/src/raster/ftmisc.h
index f04b5404bb..703155a429 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, 2009 by */
+/* Copyright 2005, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -27,6 +27,7 @@
#ifndef __FTMISC_H__
#define __FTMISC_H__
+
/* memset */
#include FT_CONFIG_STANDARD_LIBRARY_H
@@ -35,6 +36,7 @@
#define FT_LOCAL_DEF( x ) static x
+
/* from include/freetype2/fttypes.h */
typedef unsigned char FT_Byte;
@@ -77,12 +79,22 @@
} FT_MemoryRec;
+
/* from src/ftcalc.c */
-#include <inttypes.h>
+#if ( defined _WIN32 || defined _WIN64 )
+
+ typedef __int64 FT_Int64;
+
+#else
+
+#include "inttypes.h"
typedef int64_t FT_Int64;
+#endif
+
+
static FT_Long
FT_MulDiv( FT_Long a,
FT_Long b,
@@ -103,6 +115,27 @@
return ( s > 0 ) ? d : -d;
}
+
+ static FT_Long
+ FT_MulDiv_No_Round( FT_Long a,
+ FT_Long b,
+ FT_Long c )
+ {
+ FT_Int s;
+ FT_Long d;
+
+
+ s = 1;
+ if ( a < 0 ) { a = -a; s = -1; }
+ if ( b < 0 ) { b = -b; s = -s; }
+ if ( c < 0 ) { c = -c; s = -s; }
+
+ d = (FT_Long)( c > 0 ? (FT_Int64)a * b / c
+ : 0x7FFFFFFFL );
+
+ return ( s > 0 ) ? d : -d;
+ }
+
#endif /* __FTMISC_H__ */
diff --git a/src/3rdparty/freetype/src/raster/ftraster.c b/src/3rdparty/freetype/src/raster/ftraster.c
index 23ad592653..b06ac333da 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-2001, 2002, 2003, 2005, 2007, 2008, 2009 by */
+/* Copyright 1996-2003, 2005, 2007-2014 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 @@
/* */
/* - copy `src/raster/ftraster.c' (this file) to your current directory */
/* */
- /* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' */
- /* to your current directory */
+ /* - copy `include/ftimage.h' and `src/raster/ftmisc.h' to your current */
+ /* directory */
/* */
/* - compile `ftraster' with the _STANDALONE_ macro defined, as in */
/* */
@@ -60,7 +60,7 @@
#include <ft2build.h>
#include "ftraster.h"
-#include FT_INTERNAL_CALC_H /* for FT_MulDiv only */
+#include FT_INTERNAL_CALC_H /* for FT_MulDiv and FT_MulDiv_No_Round */
#include "rastpic.h"
@@ -179,6 +179,9 @@
#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 )
/* This macro is used to indicate that a function parameter is unused. */
/* Its purpose is simply to reduce compiler warnings. Note also that */
@@ -187,7 +190,7 @@
#define FT_UNUSED( x ) (x) = (x)
/* Disable the tracing mechanism for simplicity -- developers can */
- /* activate it easily by redefining these two macros. */
+ /* activate it easily by redefining these macros. */
#ifndef FT_ERROR
#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
#endif
@@ -198,6 +201,10 @@
#define FT_TRACE6( x ) do { } while ( 0 ) /* nothing */
#endif
+#ifndef FT_THROW
+#define FT_THROW( e ) FT_ERR_CAT( Raster_Err_, e )
+#endif
+
#define Raster_Err_None 0
#define Raster_Err_Not_Ini -1
#define Raster_Err_Overflow -2
@@ -224,11 +231,11 @@
#include FT_INTERNAL_OBJECTS_H
-#include FT_INTERNAL_DEBUG_H /* for FT_TRACE() and FT_ERROR() */
+#include FT_INTERNAL_DEBUG_H /* for FT_TRACE, FT_ERROR, and FT_THROW */
#include "rasterrs.h"
-#define Raster_Err_None Raster_Err_Ok
+#define Raster_Err_None FT_Err_Ok
#define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized
#define Raster_Err_Overflow Raster_Err_Raster_Overflow
#define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height
@@ -255,7 +262,8 @@
/* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
/* for clipping computations. It simply uses the FT_MulDiv() function */
/* defined in `ftcalc.h'. */
-#define SMulDiv FT_MulDiv
+#define SMulDiv FT_MulDiv
+#define SMulDiv_No_Round FT_MulDiv_No_Round
/* The rasterizer is a very general purpose component; please leave */
/* the following redefinitions there (you never know your target */
@@ -370,18 +378,23 @@
/* Simple record used to implement a stack of bands, required */
/* by the sub-banding mechanism */
- typedef struct TBand_
+ typedef struct black_TBand_
{
Short y_min; /* band's minimum */
Short y_max; /* band's maximum */
- } TBand;
+ } black_TBand;
#define AlignProfileSize \
( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( long ) )
+#undef RAS_ARG
+#undef RAS_ARGS
+#undef RAS_VAR
+#undef RAS_VARS
+
#ifdef FT_STATIC_RASTER
@@ -397,8 +410,8 @@
#else /* !FT_STATIC_RASTER */
-#define RAS_ARGS PWorker worker,
-#define RAS_ARG PWorker worker
+#define RAS_ARGS black_PWorker worker,
+#define RAS_ARG black_PWorker worker
#define RAS_VARS worker,
#define RAS_VAR worker
@@ -409,7 +422,7 @@
#endif /* !FT_STATIC_RASTER */
- typedef struct TWorker_ TWorker, *PWorker;
+ typedef struct black_TWorker_ black_TWorker, *black_PWorker;
/* prototypes used for sweep function dispatch */
@@ -429,26 +442,31 @@
/* NOTE: These operations are only valid on 2's complement processors */
+#undef FLOOR
+#undef CEILING
+#undef TRUNC
+#undef SCALED
#define FLOOR( x ) ( (x) & -ras.precision )
#define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision )
-#define TRUNC( x ) ( (signed long)(x) >> ras.precision_bits )
+#define TRUNC( x ) ( (Long)(x) >> ras.precision_bits )
#define FRAC( x ) ( (x) & ( ras.precision - 1 ) )
-#define SCALED( x ) ( ( (x) << ras.scale_shift ) - ras.precision_half )
+#define SCALED( x ) ( ( (ULong)(x) << ras.scale_shift ) - ras.precision_half )
-#define IS_BOTTOM_OVERSHOOT( x ) ( CEILING( x ) - x >= ras.precision_half )
-#define IS_TOP_OVERSHOOT( x ) ( x - FLOOR( x ) >= ras.precision_half )
+#define IS_BOTTOM_OVERSHOOT( x ) \
+ (Bool)( CEILING( x ) - x >= ras.precision_half )
+#define IS_TOP_OVERSHOOT( x ) \
+ (Bool)( x - FLOOR( x ) >= ras.precision_half )
/* 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. */
- struct TWorker_
+ struct black_TWorker_
{
Int precision_bits; /* precision related variables */
Int precision;
Int precision_half;
- Long precision_mask;
Int precision_shift;
Int precision_step;
Int precision_jitter;
@@ -517,8 +535,8 @@
TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */
- TBand band_stack[16]; /* band stack used for sub-banding */
- Int band_top; /* band stack top */
+ black_TBand band_stack[16]; /* band stack used for sub-banding */
+ Int band_top; /* band stack top */
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
@@ -542,20 +560,20 @@
};
- typedef struct TRaster_
+ typedef struct black_TRaster_
{
- char* buffer;
- long buffer_size;
- void* memory;
- PWorker worker;
- Byte grays[5];
- Short gray_width;
+ char* buffer;
+ long buffer_size;
+ void* memory;
+ black_PWorker worker;
+ Byte grays[5];
+ Short gray_width;
- } TRaster, *PRaster;
+ } black_TRaster, *black_PRaster;
#ifdef FT_STATIC_RASTER
- static TWorker cur_ras;
+ static black_TWorker cur_ras;
#define ras cur_ras
#else /* !FT_STATIC_RASTER */
@@ -647,17 +665,39 @@
/* Set precision variables according to param flag. */
/* */
/* <Input> */
- /* High :: Set to True for high precision (typically for ppem < 18), */
+ /* High :: Set to True for high precision (typically for ppem < 24), */
/* false otherwise. */
/* */
static void
Set_High_Precision( RAS_ARGS Int High )
{
+ /*
+ * `precision_step' is used in `Bezier_Up' to decide when to split a
+ * given y-monotonous Bezier arc that crosses a scanline before
+ * approximating it as a straight segment. The default value of 32 (for
+ * low accuracy) corresponds to
+ *
+ * 32 / 64 == 0.5 pixels ,
+ *
+ * while for the high accuracy case we have
+ *
+ * 256/ (1 << 12) = 0.0625 pixels .
+ *
+ * `precision_jitter' is an epsilon threshold used in
+ * `Vertical_Sweep_Span' to deal with small imperfections in the Bezier
+ * decomposition (after all, we are working with approximations only);
+ * it avoids switching on additional pixels which would cause artifacts
+ * otherwise.
+ *
+ * The value of `precision_jitter' has been determined heuristically.
+ *
+ */
+
if ( High )
{
ras.precision_bits = 12;
ras.precision_step = 256;
- ras.precision_jitter = 50;
+ ras.precision_jitter = 30;
}
else
{
@@ -671,7 +711,6 @@
ras.precision = 1 << ras.precision_bits;
ras.precision_half = ras.precision / 2;
ras.precision_shift = ras.precision_bits - Pixel_Bits;
- ras.precision_mask = -ras.precision;
}
@@ -706,7 +745,7 @@
if ( ras.top >= ras.maxBuff )
{
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
@@ -725,18 +764,18 @@
if ( overshoot )
ras.cProfile->flags |= Overshoot_Bottom;
- FT_TRACE6(( "New ascending profile = %lx\n", (long)ras.cProfile ));
+ FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile ));
break;
case Descending_State:
if ( overshoot )
ras.cProfile->flags |= Overshoot_Top;
- FT_TRACE6(( "New descending profile = %lx\n", (long)ras.cProfile ));
+ FT_TRACE6(( "New descending profile = %p\n", ras.cProfile ));
break;
default:
FT_ERROR(( "New_Profile: invalid profile direction\n" ));
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
return FAILURE;
}
@@ -769,8 +808,7 @@
static Bool
End_Profile( RAS_ARGS Bool overshoot )
{
- Long h;
- PProfile oldProfile;
+ Long h;
h = (Long)( ras.top - ras.cProfile->offset );
@@ -778,14 +816,17 @@
if ( h < 0 )
{
FT_ERROR(( "End_Profile: negative height encountered\n" ));
- ras.error = Raster_Err_Neg_Height;
+ ras.error = FT_THROW( Neg_Height );
return FAILURE;
}
if ( h > 0 )
{
- FT_TRACE6(( "Ending profile %lx, start = %ld, height = %ld\n",
- (long)ras.cProfile, ras.cProfile->start, h ));
+ PProfile oldProfile;
+
+
+ FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
+ ras.cProfile, ras.cProfile->start, h ));
ras.cProfile->height = h;
if ( overshoot )
@@ -811,7 +852,7 @@
if ( ras.top >= ras.maxBuff )
{
FT_TRACE1(( "overflow in End_Profile\n" ));
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
@@ -840,7 +881,7 @@
Insert_Y_Turn( RAS_ARGS Int y )
{
PLong y_turns;
- Int y2, n;
+ Int n;
n = ras.numTurns - 1;
@@ -854,7 +895,9 @@
if ( n >= 0 && y > y_turns[n] )
while ( n >= 0 )
{
- y2 = (Int)y_turns[n];
+ Int y2 = (Int)y_turns[n];
+
+
y_turns[n] = y;
y = y2;
n--;
@@ -865,7 +908,7 @@
ras.maxBuff--;
if ( ras.maxBuff <= ras.top )
{
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
ras.numTurns++;
@@ -890,7 +933,6 @@
static Bool
Finalize_Profile_Table( RAS_ARG )
{
- Int bottom, top;
UShort n;
PProfile p;
@@ -902,6 +944,9 @@
{
while ( n > 0 )
{
+ Int bottom, top;
+
+
if ( n > 1 )
p->link = (PProfile)( p->offset + p->height );
else
@@ -1094,7 +1139,7 @@
return SUCCESS;
else
{
- x1 += FMulDiv( Dx, ras.precision - f1, Dy );
+ x1 += SMulDiv( Dx, ras.precision - f1, Dy );
e1 += 1;
}
}
@@ -1116,20 +1161,20 @@
size = e2 - e1 + 1;
if ( ras.top + size >= ras.maxBuff )
{
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
if ( Dx > 0 )
{
- Ix = ( ras.precision * Dx ) / Dy;
+ Ix = SMulDiv_No_Round( ras.precision, Dx, Dy );
Rx = ( ras.precision * Dx ) % Dy;
Dx = 1;
}
else
{
- Ix = -( ( ras.precision * -Dx ) / Dy );
- Rx = ( ras.precision * -Dx ) % Dy;
+ Ix = -SMulDiv_No_Round( ras.precision, -Dx, Dy );
+ Rx = ( ras.precision * -Dx ) % Dy;
Dx = -1;
}
@@ -1291,7 +1336,7 @@
if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )
{
ras.top = top;
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
@@ -1829,7 +1874,7 @@
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
- v_last = v_start;
+ /* v_last = v_start; */
}
point--;
tags--;
@@ -1931,18 +1976,21 @@
y1 = SCALED( point[-2].y );
x2 = SCALED( point[-1].x );
y2 = SCALED( point[-1].y );
- x3 = SCALED( point[ 0].x );
- y3 = SCALED( point[ 0].y );
if ( flipped )
{
SWAP_( x1, y1 );
SWAP_( x2, y2 );
- SWAP_( x3, y3 );
}
if ( point <= limit )
{
+ x3 = SCALED( point[0].x );
+ y3 = SCALED( point[0].y );
+
+ if ( flipped )
+ SWAP_( x3, y3 );
+
if ( Cubic_To( RAS_VARS x1, y1, x2, y2, x3, y3 ) )
goto Fail;
continue;
@@ -1963,7 +2011,7 @@
return SUCCESS;
Invalid_Outline:
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
Fail:
return FAILURE;
@@ -1992,8 +2040,6 @@
int i;
unsigned start;
- PProfile lastProfile;
-
ras.fProfile = NULL;
ras.joint = FALSE;
@@ -2011,7 +2057,8 @@
for ( i = 0; i < ras.outline.n_contours; i++ )
{
- Bool o;
+ PProfile lastProfile;
+ Bool o;
ras.state = Unknown_State;
@@ -2235,10 +2282,10 @@
PProfile right )
{
Long e1, e2;
- int c1, c2;
- Byte f1, f2;
Byte* target;
+ Int dropOutControl = left->flags & 7;
+
FT_UNUSED( y );
FT_UNUSED( left );
FT_UNUSED( right );
@@ -2248,13 +2295,18 @@
e1 = TRUNC( CEILING( x1 ) );
- if ( x2 - x1 - ras.precision <= ras.precision_jitter )
+ if ( dropOutControl != 2 &&
+ x2 - x1 - ras.precision <= ras.precision_jitter )
e2 = e1;
else
e2 = TRUNC( FLOOR( x2 ) );
if ( e2 >= 0 && e1 < ras.bWidth )
{
+ int c1, c2;
+ Byte f1, f2;
+
+
if ( e1 < 0 )
e1 = 0;
if ( e2 >= ras.bWidth )
@@ -2403,6 +2455,14 @@
return; /* no drop-out control */
}
+ /* undocumented but confirmed: If the drop-out would result in a */
+ /* pixel outside of the bounding box, use the pixel inside of the */
+ /* bounding box instead */
+ if ( pxl < 0 )
+ pxl = e1;
+ else if ( TRUNC( pxl ) >= ras.bWidth )
+ pxl = e2;
+
/* check that the other pixel isn't set */
e1 = pxl == e1 ? e2 : e1;
@@ -2470,32 +2530,35 @@
PProfile left,
PProfile right )
{
- Long e1, e2;
- PByte bits;
- Byte f1;
-
FT_UNUSED( left );
FT_UNUSED( right );
if ( x2 - x1 < ras.precision )
{
+ Long e1, e2;
+
+
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
if ( e1 == e2 )
{
+ Byte f1;
+ PByte bits;
+
+
bits = ras.bTarget + ( y >> 3 );
f1 = (Byte)( 0x80 >> ( y & 7 ) );
e1 = TRUNC( e1 );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
PByte p;
- p = bits - e1*ras.target.pitch;
+ p = bits - e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
p += ( ras.target.rows - 1 ) * ras.target.pitch;
@@ -2579,6 +2642,14 @@
return; /* no drop-out control */
}
+ /* undocumented but confirmed: If the drop-out would result in a */
+ /* pixel outside of the bounding box, use the pixel inside of the */
+ /* bounding box instead */
+ if ( pxl < 0 )
+ pxl = e1;
+ else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
+ pxl = e2;
+
/* check that the other pixel isn't set */
e1 = pxl == e1 ? e2 : e1;
@@ -2591,9 +2662,9 @@
if ( ras.target.pitch > 0 )
bits += ( ras.target.rows - 1 ) * ras.target.pitch;
- if ( e1 >= 0 &&
- e1 < ras.target.rows &&
- *bits & f1 )
+ if ( e1 >= 0 &&
+ (ULong)e1 < ras.target.rows &&
+ *bits & f1 )
return;
}
else
@@ -2605,7 +2676,7 @@
e1 = TRUNC( pxl );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
bits -= e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
@@ -2673,8 +2744,6 @@
static void
Vertical_Gray_Sweep_Step( RAS_ARG )
{
- Int c1, c2;
- PByte pix, bit, bit2;
short* count = (short*)count_table;
Byte* grays;
@@ -2683,6 +2752,9 @@
if ( ras.traceOfs > ras.gray_width )
{
+ PByte pix;
+
+
pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4;
grays = ras.grays;
@@ -2693,6 +2765,9 @@
Int last_bit = last_pixel & 3;
Bool over = 0;
+ Int c1, c2;
+ PByte bit, bit2;
+
if ( ras.gray_max_x >= last_cell && last_bit != 3 )
{
@@ -2785,7 +2860,6 @@
{
Long e1, e2;
PByte pixel;
- Byte color;
/* During the horizontal sweep, we only take care of drop-outs */
@@ -2839,6 +2913,9 @@
if ( e1 >= 0 )
{
+ Byte color;
+
+
if ( x2 - x1 >= ras.precision_half )
color = ras.grays[2];
else
@@ -2916,7 +2993,7 @@
/* check the Y-turns */
if ( ras.numTurns == 0 )
{
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
return FAILURE;
}
@@ -3157,7 +3234,7 @@
if ( ras.band_top >= 7 || k < i )
{
ras.band_top = 0;
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
return ras.error;
}
@@ -3346,14 +3423,14 @@
{
FT_UNUSED_RASTER;
- return Raster_Err_Unsupported;
+ return FT_THROW( Unsupported );
}
#endif /* !FT_RASTER_OPTION_ANTI_ALIASING */
static void
- ft_black_init( PRaster raster )
+ ft_black_init( black_PRaster raster )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
FT_UInt n;
@@ -3381,7 +3458,8 @@
ft_black_new( void* memory,
FT_Raster *araster )
{
- static TRaster the_raster;
+ static black_TRaster the_raster;
+ FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
@@ -3400,15 +3478,15 @@
}
-#else /* _STANDALONE_ */
+#else /* !_STANDALONE_ */
static int
- ft_black_new( FT_Memory memory,
- PRaster *araster )
+ ft_black_new( FT_Memory memory,
+ black_PRaster *araster )
{
- FT_Error error;
- PRaster raster;
+ FT_Error error;
+ black_PRaster raster = NULL;
*araster = 0;
@@ -3425,31 +3503,33 @@
static void
- ft_black_done( PRaster raster )
+ ft_black_done( black_PRaster raster )
{
FT_Memory memory = (FT_Memory)raster->memory;
+
+
FT_FREE( raster );
}
-#endif /* _STANDALONE_ */
+#endif /* !_STANDALONE_ */
static void
- ft_black_reset( PRaster raster,
- char* pool_base,
- long pool_size )
+ ft_black_reset( black_PRaster raster,
+ char* pool_base,
+ long pool_size )
{
if ( raster )
{
- if ( pool_base && pool_size >= (long)sizeof(TWorker) + 2048 )
+ if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 )
{
- PWorker worker = (PWorker)pool_base;
+ black_PWorker worker = (black_PWorker)pool_base;
- raster->buffer = pool_base + ( (sizeof ( *worker ) + 7 ) & ~7 );
- raster->buffer_size = ( ( pool_base + pool_size ) -
- (char*)raster->buffer ) / sizeof ( Long );
+ raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
+ raster->buffer_size = (long)( pool_base + pool_size -
+ (char*)raster->buffer );
raster->worker = worker;
}
else
@@ -3462,8 +3542,8 @@
}
- static void
- ft_black_set_mode( PRaster raster,
+ static int
+ ft_black_set_mode( black_PRaster raster,
unsigned long mode,
const char* palette )
{
@@ -3486,50 +3566,52 @@
FT_UNUSED( palette );
#endif
+
+ return 0;
}
static int
- ft_black_render( PRaster raster,
+ ft_black_render( black_PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
- PWorker worker;
+ black_PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
- return Raster_Err_Not_Ini;
+ return FT_THROW( Not_Ini );
if ( !outline )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return Raster_Err_None;
if ( !outline->contours || !outline->points )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
worker = raster->worker;
/* this version of the raster does not support direct rendering, sorry */
if ( params->flags & FT_RASTER_FLAG_DIRECT )
- return Raster_Err_Unsupported;
+ return FT_THROW( Unsupported );
if ( !target_map )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return Raster_Err_None;
if ( !target_map->buffer )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
ras.outline = *outline;
ras.target = *target_map;
diff --git a/src/3rdparty/freetype/src/raster/ftrend1.c b/src/3rdparty/freetype/src/raster/ftrend1.c
index 1ed8af6121..aa7f6d5664 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-2001, 2002, 2003, 2005, 2006 by */
+/* Copyright 1996-2003, 2005, 2006, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include "ftrend1.h"
@@ -37,7 +38,7 @@
library->raster_pool,
library->raster_pool_size );
- return Raster_Err_Ok;
+ return FT_Err_Ok;
}
@@ -61,12 +62,12 @@
const FT_Matrix* matrix,
const FT_Vector* delta )
{
- FT_Error error = Raster_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
- error = Raster_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -114,7 +115,7 @@
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
- error = Raster_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -124,13 +125,13 @@
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz == &ft_raster1_renderer_class )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz == &ft_raster5_renderer_class )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
#else /* FT_CONFIG_OPTION_PIC */
/* When PIC is enabled, we cannot get to the class object */
@@ -142,13 +143,13 @@
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz->root.module_name[6] == '1' )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz->root.module_name[6] == '5' )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
#endif /* FT_CONFIG_OPTION_PIC */
@@ -161,13 +162,28 @@
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
+ /* undocumented but confirmed: bbox values get rounded */
+#if 1
+ cbox.xMin = FT_PIX_ROUND( cbox.xMin );
+ cbox.yMin = FT_PIX_ROUND( cbox.yMin );
+ cbox.xMax = FT_PIX_ROUND( cbox.xMax );
+ cbox.yMax = FT_PIX_ROUND( cbox.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
width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
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;
@@ -229,10 +245,10 @@
}
- FT_DEFINE_RENDERER(ft_raster1_renderer_class,
-
+ FT_DEFINE_RENDERER( ft_raster1_renderer_class,
+
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"raster1",
0x10000L,
@@ -260,11 +276,10 @@
/* to register it by hand in your application. It should only be */
/* used for backwards-compatibility with FT 1.x anyway. */
/* */
- FT_DEFINE_RENDERER(ft_raster5_renderer_class,
-
-
+ FT_DEFINE_RENDERER( ft_raster5_renderer_class,
+
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"raster5",
0x10000L,
diff --git a/src/3rdparty/freetype/src/raster/rasterrs.h b/src/3rdparty/freetype/src/raster/rasterrs.h
index 5df9a7ab1e..ab85c002a3 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Raster_Err_
#define FT_ERR_BASE FT_Mod_Err_Raster
diff --git a/src/3rdparty/freetype/src/raster/rastpic.c b/src/3rdparty/freetype/src/raster/rastpic.c
index 3c264877b6..5e9f7cc9c4 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 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,21 +20,29 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "rastpic.h"
+#include "rasterrs.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftraster.c */
- void FT_Init_Class_ft_standard_raster(FT_Raster_Funcs*);
+ void
+ FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs );
+
void
- ft_raster1_renderer_class_pic_free( FT_Library library )
+ ft_raster1_renderer_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->raster )
{
- RasterPIC* container = (RasterPIC*)pic_container->raster;
- if(--container->ref_count)
+ RasterPIC* container = (RasterPIC*)pic_container->raster;
+
+
+ if ( --container->ref_count )
return;
FT_FREE( container );
pic_container->raster = NULL;
@@ -43,44 +51,50 @@
FT_Error
- ft_raster1_renderer_class_pic_init( FT_Library library )
+ ft_raster1_renderer_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- RasterPIC* container;
- FT_Memory memory = library->memory;
-
- /* since this function also serve raster5 renderer,
- it implements reference counting */
- if(pic_container->raster)
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ RasterPIC* container = NULL;
+ FT_Memory memory = library->memory;
+
+
+ /* since this function also serves raster5 renderer, */
+ /* it implements reference counting */
+ if ( pic_container->raster )
{
((RasterPIC*)pic_container->raster)->ref_count++;
return error;
}
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->raster = container;
+
container->ref_count = 1;
- /* initialize pointer table - this is how the module usually expects this data */
- FT_Init_Class_ft_standard_raster(&container->ft_standard_raster);
-/*Exit:*/
- if(error)
- ft_raster1_renderer_class_pic_free(library);
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ FT_Init_Class_ft_standard_raster( &container->ft_standard_raster );
+
return error;
}
+
/* re-route these init and free functions to the above functions */
- FT_Error ft_raster5_renderer_class_pic_init(FT_Library library)
+ FT_Error
+ ft_raster5_renderer_class_pic_init( FT_Library library )
{
- return ft_raster1_renderer_class_pic_init(library);
+ return ft_raster1_renderer_class_pic_init( library );
}
- void ft_raster5_renderer_class_pic_free(FT_Library library)
+
+
+ void
+ ft_raster5_renderer_class_pic_free( FT_Library library )
{
- ft_raster1_renderer_class_pic_free(library);
+ ft_raster1_renderer_class_pic_free( library );
}
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/raster/rastpic.h b/src/3rdparty/freetype/src/raster/rastpic.h
index dcd82b8ca8..e0ddba624e 100644
--- a/src/3rdparty/freetype/src/raster/rastpic.h
+++ b/src/3rdparty/freetype/src/raster/rastpic.h
@@ -19,24 +19,43 @@
#ifndef __RASTPIC_H__
#define __RASTPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
+
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_STANDARD_RASTER_GET ft_standard_raster
+
+#define FT_STANDARD_RASTER_GET ft_standard_raster
#else /* FT_CONFIG_OPTION_PIC */
- typedef struct RasterPIC_
+ typedef struct RasterPIC_
{
- int ref_count;
- FT_Raster_Funcs ft_standard_raster;
+ int ref_count;
+ FT_Raster_Funcs ft_standard_raster;
+
} RasterPIC;
-#define GET_PIC(lib) ((RasterPIC*)((lib)->pic_container.raster))
-#define FT_STANDARD_RASTER_GET (GET_PIC(library)->ft_standard_raster)
+
+#define GET_PIC( lib ) \
+ ( (RasterPIC*)( (lib)->pic_container.raster ) )
+#define FT_STANDARD_RASTER_GET ( GET_PIC( library )->ft_standard_raster )
+
+
+ /* see rastpic.c for the implementation */
+ void
+ ft_raster1_renderer_class_pic_free( FT_Library library );
+
+ void
+ ft_raster5_renderer_class_pic_free( FT_Library library );
+
+ FT_Error
+ ft_raster1_renderer_class_pic_init( FT_Library library );
+
+ FT_Error
+ ft_raster5_renderer_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/raster/rules.mk b/src/3rdparty/freetype/src/raster/rules.mk
index 9703b1298a..0e0b5e4ebd 100644
--- a/src/3rdparty/freetype/src/raster/rules.mk
+++ b/src/3rdparty/freetype/src/raster/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2001, 2003, 2008, 2009 by
+# Copyright 1996-2000, 2001, 2003, 2008, 2009, 2011 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -25,7 +25,8 @@ RASTER_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(RASTER_DIR))
# raster driver sources (i.e., C files)
#
RASTER_DRV_SRC := $(RASTER_DIR)/ftraster.c \
- $(RASTER_DIR)/ftrend1.c
+ $(RASTER_DIR)/ftrend1.c \
+ $(RASTER_DIR)/rastpic.c
# raster driver headers
diff --git a/src/3rdparty/freetype/src/sfnt/pngshim.c b/src/3rdparty/freetype/src/sfnt/pngshim.c
new file mode 100644
index 0000000000..9bfcc2a779
--- /dev/null
+++ b/src/3rdparty/freetype/src/sfnt/pngshim.c
@@ -0,0 +1,377 @@
+/***************************************************************************/
+/* */
+/* pngshim.c */
+/* */
+/* PNG Bitmap glyph support. */
+/* */
+/* Copyright 2013, 2014 by Google, Inc. */
+/* Written by Stuart Gill and Behdad Esfahbod. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_STREAM_H
+#include FT_TRUETYPE_TAGS_H
+#include FT_CONFIG_STANDARD_LIBRARY_H
+
+
+#ifdef FT_CONFIG_OPTION_USE_PNG
+
+ /* We always include <stjmp.h>, so make libpng shut up! */
+#define PNG_SKIP_SETJMP_CHECK 1
+#include <png.h>
+#include "pngshim.h"
+
+#include "sferrors.h"
+
+
+ /* This code is freely based on cairo-png.c. There's so many ways */
+ /* to call libpng, and the way cairo does it is defacto standard. */
+
+ static int
+ multiply_alpha( int alpha,
+ int color )
+ {
+ int temp = ( alpha * color ) + 0x80;
+
+
+ return ( temp + ( temp >> 8 ) ) >> 8;
+ }
+
+
+ /* Premultiplies data and converts RGBA bytes => native endian. */
+ static void
+ premultiply_data( png_structp png,
+ png_row_infop row_info,
+ png_bytep data )
+ {
+ unsigned int i;
+
+ FT_UNUSED( png );
+
+
+ for ( i = 0; i < row_info->rowbytes; i += 4 )
+ {
+ unsigned char* base = &data[i];
+ unsigned int alpha = base[3];
+
+
+ if ( alpha == 0 )
+ base[0] = base[1] = base[2] = base[3] = 0;
+
+ else
+ {
+ unsigned int red = base[0];
+ unsigned int green = base[1];
+ unsigned int blue = base[2];
+
+
+ if ( alpha != 0xFF )
+ {
+ red = multiply_alpha( alpha, red );
+ green = multiply_alpha( alpha, green );
+ blue = multiply_alpha( alpha, blue );
+ }
+
+ base[0] = blue;
+ base[1] = green;
+ base[2] = red;
+ base[3] = alpha;
+ }
+ }
+ }
+
+
+ /* Converts RGBx bytes to BGRA. */
+ static void
+ convert_bytes_to_data( png_structp png,
+ png_row_infop row_info,
+ png_bytep data )
+ {
+ unsigned int i;
+
+ FT_UNUSED( png );
+
+
+ for ( i = 0; i < row_info->rowbytes; i += 4 )
+ {
+ unsigned char* base = &data[i];
+ unsigned int red = base[0];
+ unsigned int green = base[1];
+ unsigned int blue = base[2];
+
+
+ base[0] = blue;
+ base[1] = green;
+ base[2] = red;
+ base[3] = 0xFF;
+ }
+ }
+
+
+ /* Use error callback to avoid png writing to stderr. */
+ static void
+ error_callback( png_structp png,
+ png_const_charp error_msg )
+ {
+ FT_Error* error = (FT_Error*)png_get_error_ptr( png );
+
+ FT_UNUSED( error_msg );
+
+
+ *error = FT_THROW( Out_Of_Memory );
+#ifdef PNG_SETJMP_SUPPORTED
+ ft_longjmp( png_jmpbuf( png ), 1 );
+#endif
+ /* if we get here, then we have no choice but to abort ... */
+ }
+
+
+ /* Use warning callback to avoid png writing to stderr. */
+ static void
+ warning_callback( png_structp png,
+ png_const_charp error_msg )
+ {
+ FT_UNUSED( png );
+ FT_UNUSED( error_msg );
+
+ /* Just ignore warnings. */
+ }
+
+
+ static void
+ read_data_from_FT_Stream( png_structp png,
+ png_bytep data,
+ png_size_t length )
+ {
+ FT_Error error;
+ png_voidp p = png_get_io_ptr( png );
+ FT_Stream stream = (FT_Stream)p;
+
+
+ if ( FT_FRAME_ENTER( length ) )
+ {
+ FT_Error* e = (FT_Error*)png_get_error_ptr( png );
+
+
+ *e = FT_THROW( Invalid_Stream_Read );
+ png_error( png, NULL );
+
+ return;
+ }
+
+ memcpy( data, stream->cursor, length );
+
+ FT_FRAME_EXIT();
+ }
+
+
+ FT_LOCAL_DEF( FT_Error )
+ Load_SBit_Png( FT_GlyphSlot slot,
+ FT_Int x_offset,
+ FT_Int y_offset,
+ FT_Int pix_bits,
+ TT_SBit_Metrics metrics,
+ FT_Memory memory,
+ FT_Byte* data,
+ FT_UInt png_len,
+ FT_Bool populate_map_and_metrics )
+ {
+ FT_Bitmap *map = &slot->bitmap;
+ FT_Error error = FT_Err_Ok;
+ FT_StreamRec stream;
+
+ png_structp png;
+ png_infop info;
+ png_uint_32 imgWidth, imgHeight;
+
+ int bitdepth, color_type, interlace;
+ FT_Int i;
+ png_byte* *rows = NULL; /* pacify compiler */
+
+
+ if ( x_offset < 0 ||
+ y_offset < 0 )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ if ( !populate_map_and_metrics &&
+ ( (FT_UInt)x_offset + metrics->width > map->width ||
+ (FT_UInt)y_offset + metrics->height > map->rows ||
+ pix_bits != 32 ||
+ map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ FT_Stream_OpenMemory( &stream, data, png_len );
+
+ png = png_create_read_struct( PNG_LIBPNG_VER_STRING,
+ &error,
+ error_callback,
+ warning_callback );
+ if ( !png )
+ {
+ error = FT_THROW( Out_Of_Memory );
+ goto Exit;
+ }
+
+ info = png_create_info_struct( png );
+ if ( !info )
+ {
+ error = FT_THROW( Out_Of_Memory );
+ png_destroy_read_struct( &png, NULL, NULL );
+ goto Exit;
+ }
+
+ if ( ft_setjmp( png_jmpbuf( png ) ) )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto DestroyExit;
+ }
+
+ png_set_read_fn( png, &stream, read_data_from_FT_Stream );
+
+ png_read_info( png, info );
+ png_get_IHDR( png, info,
+ &imgWidth, &imgHeight,
+ &bitdepth, &color_type, &interlace,
+ NULL, NULL );
+
+ if ( error ||
+ ( !populate_map_and_metrics &&
+ ( (FT_Int)imgWidth != metrics->width ||
+ (FT_Int)imgHeight != metrics->height ) ) )
+ goto DestroyExit;
+
+ if ( populate_map_and_metrics )
+ {
+ FT_Long size;
+
+
+ metrics->width = (FT_Int)imgWidth;
+ metrics->height = (FT_Int)imgHeight;
+
+ map->width = metrics->width;
+ map->rows = metrics->height;
+ map->pixel_mode = FT_PIXEL_MODE_BGRA;
+ map->pitch = map->width * 4;
+ map->num_grays = 256;
+
+ /* reject too large bitmaps similarly to the rasterizer */
+ if ( map->rows > 0x7FFF || map->width > 0x7FFF )
+ {
+ error = FT_THROW( Array_Too_Large );
+ goto DestroyExit;
+ }
+
+ /* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */
+ size = map->rows * map->pitch;
+
+ error = ft_glyphslot_alloc_bitmap( slot, size );
+ if ( error )
+ goto DestroyExit;
+ }
+
+ /* convert palette/gray image to rgb */
+ if ( color_type == PNG_COLOR_TYPE_PALETTE )
+ png_set_palette_to_rgb( png );
+
+ /* expand gray bit depth if needed */
+ if ( color_type == PNG_COLOR_TYPE_GRAY )
+ {
+#if PNG_LIBPNG_VER >= 10209
+ png_set_expand_gray_1_2_4_to_8( png );
+#else
+ png_set_gray_1_2_4_to_8( png );
+#endif
+ }
+
+ /* transform transparency to alpha */
+ if ( png_get_valid(png, info, PNG_INFO_tRNS ) )
+ png_set_tRNS_to_alpha( png );
+
+ if ( bitdepth == 16 )
+ png_set_strip_16( png );
+
+ if ( bitdepth < 8 )
+ png_set_packing( png );
+
+ /* convert grayscale to RGB */
+ if ( color_type == PNG_COLOR_TYPE_GRAY ||
+ color_type == PNG_COLOR_TYPE_GRAY_ALPHA )
+ png_set_gray_to_rgb( png );
+
+ if ( interlace != PNG_INTERLACE_NONE )
+ png_set_interlace_handling( png );
+
+ png_set_filler( png, 0xFF, PNG_FILLER_AFTER );
+
+ /* recheck header after setting EXPAND options */
+ png_read_update_info(png, info );
+ png_get_IHDR( png, info,
+ &imgWidth, &imgHeight,
+ &bitdepth, &color_type, &interlace,
+ NULL, NULL );
+
+ if ( bitdepth != 8 ||
+ !( color_type == PNG_COLOR_TYPE_RGB ||
+ color_type == PNG_COLOR_TYPE_RGB_ALPHA ) )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto DestroyExit;
+ }
+
+ switch ( color_type )
+ {
+ default:
+ /* Shouldn't happen, but fall through. */
+
+ case PNG_COLOR_TYPE_RGB_ALPHA:
+ png_set_read_user_transform_fn( png, premultiply_data );
+ break;
+
+ case PNG_COLOR_TYPE_RGB:
+ /* Humm, this smells. Carry on though. */
+ png_set_read_user_transform_fn( png, convert_bytes_to_data );
+ break;
+ }
+
+ if ( FT_NEW_ARRAY( rows, imgHeight ) )
+ {
+ error = FT_THROW( Out_Of_Memory );
+ goto DestroyExit;
+ }
+
+ for ( i = 0; i < (FT_Int)imgHeight; i++ )
+ rows[i] = map->buffer + ( y_offset + i ) * map->pitch + x_offset * 4;
+
+ png_read_image( png, rows );
+
+ FT_FREE( rows );
+
+ png_read_end( png, info );
+
+ DestroyExit:
+ png_destroy_read_struct( &png, &info, NULL );
+ FT_Stream_Close( &stream );
+
+ Exit:
+ return error;
+ }
+
+#endif /* FT_CONFIG_OPTION_USE_PNG */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/pngshim.h b/src/3rdparty/freetype/src/sfnt/pngshim.h
new file mode 100644
index 0000000000..dc9ecaf918
--- /dev/null
+++ b/src/3rdparty/freetype/src/sfnt/pngshim.h
@@ -0,0 +1,49 @@
+/***************************************************************************/
+/* */
+/* pngshim.h */
+/* */
+/* PNG Bitmap glyph support. */
+/* */
+/* Copyright 2013 by Google, Inc. */
+/* Written by Stuart Gill and Behdad Esfahbod. */
+/* */
+/* 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 __PNGSHIM_H__
+#define __PNGSHIM_H__
+
+
+#include <ft2build.h>
+#include "ttload.h"
+
+
+FT_BEGIN_HEADER
+
+#ifdef FT_CONFIG_OPTION_USE_PNG
+
+ FT_LOCAL( FT_Error )
+ Load_SBit_Png( FT_GlyphSlot slot,
+ FT_Int x_offset,
+ FT_Int y_offset,
+ FT_Int pix_bits,
+ TT_SBit_Metrics metrics,
+ FT_Memory memory,
+ FT_Byte* data,
+ FT_UInt png_len,
+ FT_Bool populate_map_and_metrics );
+
+#endif
+
+FT_END_HEADER
+
+#endif /* __PNGSHIM_H__ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/rules.mk b/src/3rdparty/freetype/src/sfnt/rules.mk
index abda74fcaa..a6c956ab65 100644
--- a/src/3rdparty/freetype/src/sfnt/rules.mk
+++ b/src/3rdparty/freetype/src/sfnt/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by
+# Copyright 1996-2000, 2002-2007, 2009, 2011, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -33,15 +33,14 @@ SFNT_DRV_SRC := $(SFNT_DIR)/ttload.c \
$(SFNT_DIR)/ttkern.c \
$(SFNT_DIR)/ttbdf.c \
$(SFNT_DIR)/sfobjs.c \
- $(SFNT_DIR)/sfdriver.c
+ $(SFNT_DIR)/sfdriver.c \
+ $(SFNT_DIR)/sfntpic.c \
+ $(SFNT_DIR)/pngshim.c
# SFNT driver headers
#
-# Note that ttsbit0.c gets #included by ttsbit.c.
-#
SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h) \
- $(SFNT_DIR)/sferrors.h \
- $(SFNT_DIR)/ttsbit0.c
+ $(SFNT_DIR)/sferrors.h
# SFNT driver object(s)
diff --git a/src/3rdparty/freetype/src/sfnt/sfdriver.c b/src/3rdparty/freetype/src/sfnt/sfdriver.c
index 1097efb86d..badb159dc3 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 1996-2007, 2009-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -50,6 +50,7 @@
#include FT_SERVICE_SFNT_H
#include FT_SERVICE_TT_CMAP_H
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -60,10 +61,10 @@
#define FT_COMPONENT trace_sfdriver
- /*
- * SFNT TABLE SERVICE
- *
- */
+ /*
+ * SFNT TABLE SERVICE
+ *
+ */
static void*
get_sfnt_table( TT_Face face,
@@ -74,36 +75,36 @@
switch ( tag )
{
- case ft_sfnt_head:
+ case FT_SFNT_HEAD:
table = &face->header;
break;
- case ft_sfnt_hhea:
+ case FT_SFNT_HHEA:
table = &face->horizontal;
break;
- case ft_sfnt_vhea:
- table = face->vertical_info ? &face->vertical : 0;
+ case FT_SFNT_VHEA:
+ table = face->vertical_info ? &face->vertical : NULL;
break;
- case ft_sfnt_os2:
- table = face->os2.version == 0xFFFFU ? 0 : &face->os2;
+ case FT_SFNT_OS2:
+ table = face->os2.version == 0xFFFFU ? NULL : &face->os2;
break;
- case ft_sfnt_post:
+ case FT_SFNT_POST:
table = &face->postscript;
break;
- case ft_sfnt_maxp:
+ case FT_SFNT_MAXP:
table = &face->max_profile;
break;
- case ft_sfnt_pclt:
- table = face->pclt.Version ? &face->pclt : 0;
+ case FT_SFNT_PCLT:
+ table = face->pclt.Version ? &face->pclt : NULL;
break;
default:
- table = 0;
+ table = NULL;
}
return table;
@@ -117,33 +118,38 @@
FT_ULong *offset,
FT_ULong *length )
{
- if ( !tag || !offset || !length )
- return SFNT_Err_Invalid_Argument;
+ if ( !offset || !length )
+ return FT_THROW( Invalid_Argument );
- if ( idx >= face->num_tables )
- return SFNT_Err_Table_Missing;
+ if ( !tag )
+ *length = face->num_tables;
+ else
+ {
+ if ( idx >= face->num_tables )
+ return FT_THROW( Table_Missing );
- *tag = face->dir_tables[idx].Tag;
- *offset = face->dir_tables[idx].Offset;
- *length = face->dir_tables[idx].Length;
+ *tag = face->dir_tables[idx].Tag;
+ *offset = face->dir_tables[idx].Offset;
+ *length = face->dir_tables[idx].Length;
+ }
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_SERVICE_SFNT_TABLEREC(sfnt_service_sfnt_table,
+ 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_TableInfoFunc)sfnt_table_info )
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- /*
- * GLYPH DICT SERVICE
- *
- */
+ /*
+ * GLYPH DICT SERVICE
+ *
+ */
static FT_Error
sfnt_get_glyph_name( TT_Face face,
@@ -167,17 +173,18 @@
sfnt_get_name_index( TT_Face face,
FT_String* glyph_name )
{
- FT_Face root = &face->root;
- FT_UInt i, max_gid = FT_UINT_MAX;
+ FT_Face root = &face->root;
+
+ FT_UInt i, max_gid = FT_UINT_MAX;
if ( root->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)root->num_glyphs < FT_UINT_MAX )
+ max_gid = (FT_UInt)root->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, root->num_glyphs ));
for ( i = 0; i < max_gid; i++ )
{
@@ -196,18 +203,19 @@
}
- FT_DEFINE_SERVICE_GLYPHDICTREC(sfnt_service_glyph_dict,
+ FT_DEFINE_SERVICE_GLYPHDICTREC(
+ sfnt_service_glyph_dict,
(FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name,
- (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index
- )
+ (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index )
+
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
- /*
- * POSTSCRIPT NAME SERVICE
- *
- */
+ /*
+ * POSTSCRIPT NAME SERVICE
+ *
+ */
static const char*
sfnt_get_ps_name( TT_Face face )
@@ -249,7 +257,7 @@
FT_Memory memory = face->root.memory;
TT_NameEntryRec* name = face->name_table.names + found_win;
FT_UInt len = name->stringLength / 2;
- FT_Error error = SFNT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
@@ -258,7 +266,7 @@
{
FT_Stream stream = face->name_table.stream;
FT_String* r = (FT_String*)result;
- FT_Byte* p = (FT_Byte*)name->string;
+ FT_Byte* p;
if ( FT_STREAM_SEEK( name->stringOffset ) ||
@@ -291,7 +299,7 @@
FT_Memory memory = face->root.memory;
TT_NameEntryRec* name = face->name_table.names + found_apple;
FT_UInt len = name->stringLength;
- FT_Error error = SFNT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
@@ -319,17 +327,18 @@
return result;
}
- FT_DEFINE_SERVICE_PSFONTNAMEREC(sfnt_service_ps_name,
- (FT_PsName_GetFunc)sfnt_get_ps_name
- )
+
+ FT_DEFINE_SERVICE_PSFONTNAMEREC(
+ sfnt_service_ps_name,
+ (FT_PsName_GetFunc)sfnt_get_ps_name )
/*
* TT CMAP INFO
*/
- FT_DEFINE_SERVICE_TTCMAPSREC(tt_service_get_cmap_info,
- (TT_CMap_Info_GetFunc)tt_get_cmap_info
- )
+ FT_DEFINE_SERVICE_TTCMAPSREC(
+ tt_service_get_cmap_info,
+ (TT_CMap_Info_GetFunc)tt_get_cmap_info )
#ifdef TT_CONFIG_OPTION_BDF
@@ -362,7 +371,7 @@
*acharset_registry = registry.u.atom;
}
else
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
}
@@ -370,10 +379,11 @@
}
- FT_DEFINE_SERVICE_BDFRec(sfnt_service_bdf,
- (FT_BDF_GetCharsetIdFunc) sfnt_get_charset_id,
- (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop
- )
+ FT_DEFINE_SERVICE_BDFRec(
+ sfnt_service_bdf,
+ (FT_BDF_GetCharsetIdFunc)sfnt_get_charset_id,
+ (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop )
+
#endif /* TT_CONFIG_OPTION_BDF */
@@ -383,33 +393,33 @@
*/
#if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF
- FT_DEFINE_SERVICEDESCREC5(sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_GLYPH_DICT, &FT_SFNT_SERVICE_GLYPH_DICT_GET,
- FT_SERVICE_ID_BDF, &FT_SFNT_SERVICE_BDF_GET,
- FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET
- )
+ 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,
+ FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET,
+ FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
#elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- FT_DEFINE_SERVICEDESCREC4(sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_GLYPH_DICT, &FT_SFNT_SERVICE_GLYPH_DICT_GET,
- FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET
- )
+ 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,
+ FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
#elif defined TT_CONFIG_OPTION_BDF
- FT_DEFINE_SERVICEDESCREC4(sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_BDF, &FT_SFNT_SERVICE_BDF_GET,
- FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET
- )
+ 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,
+ FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
#else
- FT_DEFINE_SERVICEDESCREC3(sfnt_services,
- FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET,
- FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET
- )
+ 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 )
#endif
@@ -417,151 +427,38 @@
sfnt_get_interface( FT_Module module,
const char* module_interface )
{
- FT_UNUSED( module );
-
- return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface );
- }
-
-
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_CALLBACK_DEF( FT_Error )
- tt_face_load_sfnt_header_stub( TT_Face face,
- FT_Stream stream,
- FT_Long face_index,
- SFNT_Header header )
- {
- FT_UNUSED( face );
- FT_UNUSED( stream );
- FT_UNUSED( face_index );
- FT_UNUSED( header );
-
- return FT_Err_Unimplemented_Feature;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_face_load_directory_stub( TT_Face face,
- FT_Stream stream,
- SFNT_Header header )
- {
- FT_UNUSED( face );
- FT_UNUSED( stream );
- FT_UNUSED( header );
-
- return FT_Err_Unimplemented_Feature;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_face_load_hdmx_stub( TT_Face face,
- FT_Stream stream )
- {
- FT_UNUSED( face );
- FT_UNUSED( stream );
-
- return FT_Err_Unimplemented_Feature;
- }
-
-
- FT_CALLBACK_DEF( void )
- tt_face_free_hdmx_stub( TT_Face face )
- {
- FT_UNUSED( face );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_face_set_sbit_strike_stub( TT_Face face,
- FT_UInt x_ppem,
- FT_UInt y_ppem,
- FT_ULong* astrike_index )
- {
- /*
- * We simply forge a FT_Size_Request and call the real function
- * that does all the work.
- *
- * This stub might be called by libXfont in the X.Org Xserver,
- * compiled against version 2.1.8 or newer.
- */
-
- FT_Size_RequestRec req;
-
-
- req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
- req.width = (FT_F26Dot6)x_ppem;
- req.height = (FT_F26Dot6)y_ppem;
- req.horiResolution = 0;
- req.vertResolution = 0;
-
- *astrike_index = 0x7FFFFFFFUL;
-
- return tt_face_set_sbit_strike( face, &req, astrike_index );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_face_load_sbit_stub( TT_Face face,
- FT_Stream stream )
- {
- FT_UNUSED( face );
- FT_UNUSED( stream );
-
- /*
- * This function was originally implemented to load the sbit table.
- * However, it has been replaced by `tt_face_load_eblc', and this stub
- * is only there for some rogue clients which would want to call it
- * directly (which doesn't make much sense).
- */
- return FT_Err_Unimplemented_Feature;
- }
-
-
- FT_CALLBACK_DEF( void )
- tt_face_free_sbit_stub( TT_Face face )
- {
- /* nothing to do in this stub */
- FT_UNUSED( face );
- }
+ /* SFNT_SERVICES_GET dereferences `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_Library library;
- FT_CALLBACK_DEF( FT_Error )
- tt_face_load_charmap_stub( TT_Face face,
- void* cmap,
- FT_Stream input )
- {
- FT_UNUSED( face );
- FT_UNUSED( cmap );
- FT_UNUSED( input );
-
- return FT_Err_Unimplemented_Feature;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_face_free_charmap_stub( TT_Face face,
- void* cmap )
- {
- FT_UNUSED( face );
- FT_UNUSED( cmap );
+ if ( !module )
+ return NULL;
+ library = module->library;
+ if ( !library )
+ return NULL;
+#else
+ FT_UNUSED( module );
+#endif
- return 0;
+ return ft_service_list_lookup( SFNT_SERVICES_GET, module_interface );
}
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#define PUT_EMBEDDED_BITMAPS(a) a
+#define PUT_EMBEDDED_BITMAPS( a ) a
#else
-#define PUT_EMBEDDED_BITMAPS(a) 0
+#define PUT_EMBEDDED_BITMAPS( a ) NULL
#endif
+
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#define PUT_PS_NAMES(a) a
+#define PUT_PS_NAMES( a ) a
#else
-#define PUT_PS_NAMES(a) 0
+#define PUT_PS_NAMES( a ) NULL
#endif
- FT_DEFINE_SFNT_INTERFACE(sfnt_interface,
+ FT_DEFINE_SFNT_INTERFACE(
+ sfnt_interface,
tt_face_goto_table,
sfnt_init_face,
@@ -571,9 +468,6 @@
tt_face_load_any,
- tt_face_load_sfnt_header_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
- tt_face_load_directory_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
tt_face_load_head,
tt_face_load_hhea,
tt_face_load_cmap,
@@ -584,68 +478,52 @@
tt_face_load_name,
tt_face_free_name,
- tt_face_load_hdmx_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
- tt_face_free_hdmx_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
tt_face_load_kern,
tt_face_load_gasp,
tt_face_load_pclt,
/* see `ttload.h' */
- PUT_EMBEDDED_BITMAPS(tt_face_load_bhed),
-
- tt_face_set_sbit_strike_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
- tt_face_load_sbit_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
- tt_find_sbit_image, /* FT_CONFIG_OPTION_OLD_INTERNALS */
- tt_load_sbit_metrics, /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
- PUT_EMBEDDED_BITMAPS(tt_face_load_sbit_image),
+ PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
- tt_face_free_sbit_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
+ PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ),
/* see `ttpost.h' */
- PUT_PS_NAMES(tt_face_get_ps_name),
- PUT_PS_NAMES(tt_face_free_ps_names),
-
- tt_face_load_charmap_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
- tt_face_free_charmap_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */
+ PUT_PS_NAMES( tt_face_get_ps_name ),
+ PUT_PS_NAMES( tt_face_free_ps_names ),
/* since version 2.1.8 */
-
tt_face_get_kerning,
/* since version 2.2 */
-
tt_face_load_font_dir,
tt_face_load_hmtx,
/* see `ttsbit.h' and `sfnt.h' */
- PUT_EMBEDDED_BITMAPS(tt_face_load_eblc),
- PUT_EMBEDDED_BITMAPS(tt_face_free_eblc),
+ PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ),
+ PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ),
- PUT_EMBEDDED_BITMAPS(tt_face_set_sbit_strike),
- PUT_EMBEDDED_BITMAPS(tt_face_load_strike_metrics),
+ PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ),
+ PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ),
tt_face_get_metrics
)
- FT_DEFINE_MODULE(sfnt_module_class,
-
+ FT_DEFINE_MODULE(
+ sfnt_module_class,
+
0, /* not a font driver or renderer */
- sizeof( FT_ModuleRec ),
+ sizeof ( FT_ModuleRec ),
"sfnt", /* driver name */
0x10000L, /* driver version 1.0 */
0x20000L, /* driver requires FreeType 2.0 or higher */
- (const void*)&FT_SFNT_INTERFACE_GET, /* module specific interface */
+ (const void*)&SFNT_INTERFACE_GET, /* module specific interface */
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
- (FT_Module_Requester) sfnt_get_interface
- )
+ (FT_Module_Requester) sfnt_get_interface )
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/sferrors.h b/src/3rdparty/freetype/src/sfnt/sferrors.h
index 27f90de285..e981e1d26f 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, 2004 by */
+/* Copyright 2001, 2004, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,11 +29,10 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX SFNT_Err_
#define FT_ERR_BASE FT_Mod_Err_SFNT
-#define FT_KEEP_ERR_PREFIX
-
#include FT_ERRORS_H
#endif /* __SFERRORS_H__ */
diff --git a/src/3rdparty/freetype/src/sfnt/sfnt.c b/src/3rdparty/freetype/src/sfnt/sfnt.c
index fc507b4961..d62ed4e0b5 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-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2006, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,6 +28,7 @@
#include "sfdriver.c"
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+#include "pngshim.c"
#include "ttsbit.c"
#endif
diff --git a/src/3rdparty/freetype/src/sfnt/sfntpic.c b/src/3rdparty/freetype/src/sfnt/sfntpic.c
index fd3cf4e923..b3fb24b3f0 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 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,37 +20,71 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "sfntpic.h"
+#include "sferrors.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from sfdriver.c */
- FT_Error FT_Create_Class_sfnt_services( FT_Library, FT_ServiceDescRec**);
- void FT_Destroy_Class_sfnt_services( FT_Library, FT_ServiceDescRec*);
- void FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec*);
- void FT_Init_Class_sfnt_interface( FT_Library, SFNT_Interface*);
- void FT_Init_Class_sfnt_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
- void FT_Init_Class_sfnt_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
- void FT_Init_Class_tt_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
- void FT_Init_Class_sfnt_service_sfnt_table( FT_Service_SFNT_TableRec*);
+ FT_Error
+ FT_Create_Class_sfnt_services( FT_Library library,
+ FT_ServiceDescRec** output_class );
+ void
+ FT_Destroy_Class_sfnt_services( FT_Library library,
+ FT_ServiceDescRec* clazz );
+ void
+ FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec* clazz );
+ void
+ FT_Init_Class_sfnt_interface( FT_Library library,
+ SFNT_Interface* clazz );
+ void
+ FT_Init_Class_sfnt_service_glyph_dict(
+ FT_Library library,
+ FT_Service_GlyphDictRec* clazz );
+ void
+ FT_Init_Class_sfnt_service_ps_name(
+ FT_Library library,
+ FT_Service_PsFontNameRec* clazz );
+ void
+ FT_Init_Class_tt_service_get_cmap_info(
+ FT_Library library,
+ FT_Service_TTCMapsRec* clazz );
+ void
+ FT_Init_Class_sfnt_service_sfnt_table(
+ FT_Service_SFNT_TableRec* clazz );
+
/* forward declaration of PIC init functions from ttcmap.c */
- FT_Error FT_Create_Class_tt_cmap_classes( FT_Library, TT_CMap_Class**);
- void FT_Destroy_Class_tt_cmap_classes( FT_Library, TT_CMap_Class*);
+ FT_Error
+ FT_Create_Class_tt_cmap_classes( FT_Library library,
+ TT_CMap_Class** output_class );
+ void
+ FT_Destroy_Class_tt_cmap_classes( FT_Library library,
+ TT_CMap_Class* clazz );
+
void
- sfnt_module_class_pic_free( FT_Library library )
+ sfnt_module_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->sfnt )
{
- sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
- if(container->sfnt_services)
- FT_Destroy_Class_sfnt_services(library, container->sfnt_services);
+ sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
+
+
+ if ( container->sfnt_services )
+ FT_Destroy_Class_sfnt_services( library,
+ container->sfnt_services );
container->sfnt_services = NULL;
- if(container->tt_cmap_classes)
- FT_Destroy_Class_tt_cmap_classes(library, container->tt_cmap_classes);
+
+ if ( container->tt_cmap_classes )
+ FT_Destroy_Class_tt_cmap_classes( library,
+ container->tt_cmap_classes );
container->tt_cmap_classes = NULL;
+
FT_FREE( container );
pic_container->sfnt = NULL;
}
@@ -58,43 +92,51 @@
FT_Error
- sfnt_module_class_pic_init( FT_Library library )
+ sfnt_module_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- sfntModulePIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ sfntModulePIC* container = NULL;
+ FT_Memory memory = library->memory;
+
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->sfnt = container;
- /* initialize pointer table - this is how the module usually expects this data */
- error = FT_Create_Class_sfnt_services(library, &container->sfnt_services);
- if(error)
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ error = FT_Create_Class_sfnt_services( library,
+ &container->sfnt_services );
+ if ( error )
goto Exit;
- error = FT_Create_Class_tt_cmap_classes(library, &container->tt_cmap_classes);
- if(error)
+
+ error = FT_Create_Class_tt_cmap_classes( library,
+ &container->tt_cmap_classes );
+ if ( error )
goto Exit;
- FT_Init_Class_sfnt_service_glyph_dict(library, &container->sfnt_service_glyph_dict);
- FT_Init_Class_sfnt_service_ps_name(library, &container->sfnt_service_ps_name);
- FT_Init_Class_tt_service_get_cmap_info(library, &container->tt_service_get_cmap_info);
- FT_Init_Class_sfnt_service_sfnt_table(&container->sfnt_service_sfnt_table);
+
+ FT_Init_Class_sfnt_service_glyph_dict(
+ library, &container->sfnt_service_glyph_dict );
+ FT_Init_Class_sfnt_service_ps_name(
+ library, &container->sfnt_service_ps_name );
+ FT_Init_Class_tt_service_get_cmap_info(
+ library, &container->tt_service_get_cmap_info );
+ FT_Init_Class_sfnt_service_sfnt_table(
+ &container->sfnt_service_sfnt_table );
#ifdef TT_CONFIG_OPTION_BDF
- FT_Init_Class_sfnt_service_bdf(&container->sfnt_service_bdf);
+ FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf );
#endif
- FT_Init_Class_sfnt_interface(library, &container->sfnt_interface);
+ FT_Init_Class_sfnt_interface( library, &container->sfnt_interface );
-Exit:
- if(error)
- sfnt_module_class_pic_free(library);
+ Exit:
+ if ( error )
+ sfnt_module_class_pic_free( library );
return error;
}
-
-
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/sfnt/sfntpic.h b/src/3rdparty/freetype/src/sfnt/sfntpic.h
index 6943b4250a..b09a9141e0 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 by */
+/* Copyright 2009, 2012 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,66 +19,92 @@
#ifndef __SFNTPIC_H__
#define __SFNTPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
- #ifndef FT_CONFIG_OPTION_PIC
-#define FT_SFNT_SERVICES_GET sfnt_services
-#define FT_SFNT_SERVICE_GLYPH_DICT_GET sfnt_service_glyph_dict
-#define FT_SFNT_SERVICE_PS_NAME_GET sfnt_service_ps_name
-#define FT_TT_SERVICE_GET_CMAP_INFO_GET tt_service_get_cmap_info
-#define FT_SFNT_SERVICES_GET sfnt_services
-#define FT_TT_CMAP_CLASSES_GET tt_cmap_classes
-#define FT_SFNT_SERVICE_SFNT_TABLE_GET sfnt_service_sfnt_table
-#define FT_SFNT_SERVICE_BDF_GET sfnt_service_bdf
-#define FT_SFNT_INTERFACE_GET sfnt_interface
+
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define SFNT_SERVICES_GET sfnt_services
+#define SFNT_SERVICE_GLYPH_DICT_GET sfnt_service_glyph_dict
+#define SFNT_SERVICE_PS_NAME_GET sfnt_service_ps_name
+#define TT_SERVICE_CMAP_INFO_GET tt_service_get_cmap_info
+#define SFNT_SERVICES_GET sfnt_services
+#define TT_CMAP_CLASSES_GET tt_cmap_classes
+#define SFNT_SERVICE_SFNT_TABLE_GET sfnt_service_sfnt_table
+#define SFNT_SERVICE_BDF_GET sfnt_service_bdf
+#define SFNT_INTERFACE_GET sfnt_interface
#else /* FT_CONFIG_OPTION_PIC */
-/* some include files required for members of sfntModulePIC */
+ /* some include files required for members of sfntModulePIC */
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_SFNT_H
#include FT_SERVICE_TT_CMAP_H
+
#ifdef TT_CONFIG_OPTION_BDF
#include "ttbdf.h"
#include FT_SERVICE_BDF_H
#endif
+
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include "ttcmap.h"
-typedef struct sfntModulePIC_
+
+ typedef struct sfntModulePIC_
{
- FT_ServiceDescRec* sfnt_services;
- FT_Service_GlyphDictRec sfnt_service_glyph_dict;
+ FT_ServiceDescRec* sfnt_services;
+ FT_Service_GlyphDictRec sfnt_service_glyph_dict;
FT_Service_PsFontNameRec sfnt_service_ps_name;
- FT_Service_TTCMapsRec tt_service_get_cmap_info;
- TT_CMap_Class* tt_cmap_classes;
- FT_Service_SFNT_TableRec sfnt_service_sfnt_table;
+ FT_Service_TTCMapsRec tt_service_get_cmap_info;
+ TT_CMap_Class* tt_cmap_classes;
+ FT_Service_SFNT_TableRec sfnt_service_sfnt_table;
#ifdef TT_CONFIG_OPTION_BDF
- FT_Service_BDFRec sfnt_service_bdf;
+ FT_Service_BDFRec sfnt_service_bdf;
#endif
- SFNT_Interface sfnt_interface;
+ SFNT_Interface sfnt_interface;
+
} sfntModulePIC;
-#define GET_PIC(lib) ((sfntModulePIC*)((lib)->pic_container.sfnt))
-#define FT_SFNT_SERVICES_GET (GET_PIC(library)->sfnt_services)
-#define FT_SFNT_SERVICE_GLYPH_DICT_GET (GET_PIC(library)->sfnt_service_glyph_dict)
-#define FT_SFNT_SERVICE_PS_NAME_GET (GET_PIC(library)->sfnt_service_ps_name)
-#define FT_TT_SERVICE_GET_CMAP_INFO_GET (GET_PIC(library)->tt_service_get_cmap_info)
-#define FT_SFNT_SERVICES_GET (GET_PIC(library)->sfnt_services)
-#define FT_TT_CMAP_CLASSES_GET (GET_PIC(library)->tt_cmap_classes)
-#define FT_SFNT_SERVICE_SFNT_TABLE_GET (GET_PIC(library)->sfnt_service_sfnt_table)
-#define FT_SFNT_SERVICE_BDF_GET (GET_PIC(library)->sfnt_service_bdf)
-#define FT_SFNT_INTERFACE_GET (GET_PIC(library)->sfnt_interface)
+
+#define GET_PIC( lib ) \
+ ( (sfntModulePIC*)( (lib)->pic_container.sfnt ) )
+
+#define SFNT_SERVICES_GET \
+ ( GET_PIC( library )->sfnt_services )
+#define SFNT_SERVICE_GLYPH_DICT_GET \
+ ( GET_PIC( library )->sfnt_service_glyph_dict )
+#define SFNT_SERVICE_PS_NAME_GET \
+ ( GET_PIC( library )->sfnt_service_ps_name )
+#define TT_SERVICE_CMAP_INFO_GET \
+ ( GET_PIC( library )->tt_service_get_cmap_info )
+#define SFNT_SERVICES_GET \
+ ( GET_PIC( library )->sfnt_services )
+#define TT_CMAP_CLASSES_GET \
+ ( GET_PIC( library )->tt_cmap_classes )
+#define SFNT_SERVICE_SFNT_TABLE_GET \
+ ( GET_PIC( library )->sfnt_service_sfnt_table )
+#define SFNT_SERVICE_BDF_GET \
+ ( GET_PIC( library )->sfnt_service_bdf )
+#define SFNT_INTERFACE_GET \
+ ( GET_PIC( library )->sfnt_interface )
+
+
+ /* see sfntpic.c for the implementation */
+ void
+ sfnt_module_class_pic_free( FT_Library library );
+
+ FT_Error
+ sfnt_module_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
-/* */
+ /* */
FT_END_HEADER
diff --git a/src/3rdparty/freetype/src/sfnt/sfobjs.c b/src/3rdparty/freetype/src/sfnt/sfobjs.c
index b74b1a93a9..70b988d650 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 1996-2008, 2010-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,6 +27,7 @@
#include FT_TRUETYPE_TAGS_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SFNT_NAMES_H
+#include FT_GZIP_H
#include "sferrors.h"
#ifdef TT_CONFIG_OPTION_BDF
@@ -50,9 +51,9 @@
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
FT_Memory memory )
{
- FT_String* string;
+ FT_String* string = NULL;
FT_UInt len, code, n;
- FT_Byte* read = (FT_Byte*)entry->string;
+ FT_Byte* read = (FT_Byte*)entry->string;
FT_Error error;
@@ -64,13 +65,17 @@
for ( n = 0; n < len; n++ )
{
code = FT_NEXT_USHORT( read );
+
+ if ( code == 0 )
+ break;
+
if ( code < 32 || code > 127 )
code = '?';
string[n] = (char)code;
}
- string[len] = 0;
+ string[n] = 0;
return string;
}
@@ -81,9 +86,9 @@
tt_name_entry_ascii_from_other( TT_NameEntry entry,
FT_Memory memory )
{
- FT_String* string;
+ FT_String* string = NULL;
FT_UInt len, code, n;
- FT_Byte* read = (FT_Byte*)entry->string;
+ FT_Byte* read = (FT_Byte*)entry->string;
FT_Error error;
@@ -95,13 +100,17 @@
for ( n = 0; n < len; n++ )
{
code = *read++;
+
+ if ( code == 0 )
+ break;
+
if ( code < 32 || code > 127 )
code = '?';
string[n] = (char)code;
}
- string[len] = 0;
+ string[n] = 0;
return string;
}
@@ -137,7 +146,7 @@
FT_String** name )
{
FT_Memory memory = face->root.memory;
- FT_Error error = SFNT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_String* result = NULL;
FT_UShort n;
TT_NameEntryRec* rec;
@@ -160,7 +169,7 @@
/* According to the OpenType 1.3 specification, only Microsoft or */
/* Apple platform IDs might be used in the `name' table. The */
/* `Unicode' platform is reserved for the `cmap' table, and the */
- /* `Iso' one is deprecated. */
+ /* `ISO' one is deprecated. */
/* */
/* However, the Apple TrueType specification doesn't say the same */
/* thing and goes to suggest that all Unicode `name' table entries */
@@ -339,6 +348,383 @@
}
+#define WRITE_USHORT( p, v ) \
+ do \
+ { \
+ *(p)++ = (FT_Byte)( (v) >> 8 ); \
+ *(p)++ = (FT_Byte)( (v) >> 0 ); \
+ \
+ } while ( 0 )
+
+#define WRITE_ULONG( p, v ) \
+ do \
+ { \
+ *(p)++ = (FT_Byte)( (v) >> 24 ); \
+ *(p)++ = (FT_Byte)( (v) >> 16 ); \
+ *(p)++ = (FT_Byte)( (v) >> 8 ); \
+ *(p)++ = (FT_Byte)( (v) >> 0 ); \
+ \
+ } while ( 0 )
+
+
+ static void
+ sfnt_stream_close( FT_Stream stream )
+ {
+ FT_Memory memory = stream->memory;
+
+
+ FT_FREE( stream->base );
+
+ stream->size = 0;
+ stream->base = 0;
+ stream->close = 0;
+ }
+
+
+ FT_CALLBACK_DEF( int )
+ compare_offsets( const void* a,
+ const void* b )
+ {
+ WOFF_Table table1 = *(WOFF_Table*)a;
+ WOFF_Table table2 = *(WOFF_Table*)b;
+
+ FT_ULong offset1 = table1->Offset;
+ FT_ULong offset2 = table2->Offset;
+
+
+ if ( offset1 > offset2 )
+ return 1;
+ else if ( offset1 < offset2 )
+ return -1;
+ else
+ return 0;
+ }
+
+
+ /* Replace `face->root.stream' with a stream containing the extracted */
+ /* SFNT of a WOFF font. */
+
+ static FT_Error
+ woff_open_font( FT_Stream stream,
+ TT_Face face )
+ {
+ FT_Memory memory = stream->memory;
+ FT_Error error = FT_Err_Ok;
+
+ WOFF_HeaderRec woff;
+ WOFF_Table tables = NULL;
+ WOFF_Table* indices = NULL;
+
+ FT_ULong woff_offset;
+
+ FT_Byte* sfnt = NULL;
+ FT_Stream sfnt_stream = NULL;
+
+ FT_Byte* sfnt_header;
+ FT_ULong sfnt_offset;
+
+ FT_Int nn;
+ FT_ULong old_tag = 0;
+
+ static const FT_Frame_Field woff_header_fields[] =
+ {
+#undef FT_STRUCTURE
+#define FT_STRUCTURE WOFF_HeaderRec
+
+ FT_FRAME_START( 44 ),
+ FT_FRAME_ULONG ( signature ),
+ FT_FRAME_ULONG ( flavor ),
+ FT_FRAME_ULONG ( length ),
+ FT_FRAME_USHORT( num_tables ),
+ FT_FRAME_USHORT( reserved ),
+ FT_FRAME_ULONG ( totalSfntSize ),
+ FT_FRAME_USHORT( majorVersion ),
+ FT_FRAME_USHORT( minorVersion ),
+ FT_FRAME_ULONG ( metaOffset ),
+ FT_FRAME_ULONG ( metaLength ),
+ FT_FRAME_ULONG ( metaOrigLength ),
+ FT_FRAME_ULONG ( privOffset ),
+ FT_FRAME_ULONG ( privLength ),
+ FT_FRAME_END
+ };
+
+
+ FT_ASSERT( stream == face->root.stream );
+ FT_ASSERT( FT_STREAM_POS() == 0 );
+
+ if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) )
+ return error;
+
+ /* Make sure we don't recurse back here or hit TTC code. */
+ if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf )
+ return FT_THROW( Invalid_Table );
+
+ /* Miscellaneous checks. */
+ if ( woff.length != stream->size ||
+ woff.num_tables == 0 ||
+ 44 + woff.num_tables * 20UL >= woff.length ||
+ 12 + woff.num_tables * 16UL >= woff.totalSfntSize ||
+ ( woff.totalSfntSize & 3 ) != 0 ||
+ ( woff.metaOffset == 0 && ( woff.metaLength != 0 ||
+ woff.metaOrigLength != 0 ) ) ||
+ ( woff.metaLength != 0 && woff.metaOrigLength == 0 ) ||
+ ( woff.privOffset == 0 && woff.privLength != 0 ) )
+ return FT_THROW( Invalid_Table );
+
+ if ( FT_ALLOC( sfnt, woff.totalSfntSize ) ||
+ FT_NEW( sfnt_stream ) )
+ goto Exit;
+
+ sfnt_header = sfnt;
+
+ /* Write sfnt header. */
+ {
+ FT_UInt searchRange, entrySelector, rangeShift, x;
+
+
+ x = woff.num_tables;
+ entrySelector = 0;
+ while ( x )
+ {
+ x >>= 1;
+ entrySelector += 1;
+ }
+ entrySelector--;
+
+ searchRange = ( 1 << entrySelector ) * 16;
+ rangeShift = woff.num_tables * 16 - searchRange;
+
+ WRITE_ULONG ( sfnt_header, woff.flavor );
+ WRITE_USHORT( sfnt_header, woff.num_tables );
+ WRITE_USHORT( sfnt_header, searchRange );
+ WRITE_USHORT( sfnt_header, entrySelector );
+ WRITE_USHORT( sfnt_header, rangeShift );
+ }
+
+ /* While the entries in the sfnt header must be sorted by the */
+ /* tag value, the tables themselves are not. We thus have to */
+ /* sort them by offset and check that they don't overlap. */
+
+ if ( FT_NEW_ARRAY( tables, woff.num_tables ) ||
+ FT_NEW_ARRAY( indices, woff.num_tables ) )
+ goto Exit;
+
+ FT_TRACE2(( "\n"
+ " tag offset compLen origLen checksum\n"
+ " -------------------------------------------\n" ));
+
+ if ( FT_FRAME_ENTER( 20L * woff.num_tables ) )
+ goto Exit;
+
+ for ( nn = 0; nn < woff.num_tables; nn++ )
+ {
+ WOFF_Table table = tables + nn;
+
+ table->Tag = FT_GET_TAG4();
+ table->Offset = FT_GET_ULONG();
+ table->CompLength = FT_GET_ULONG();
+ table->OrigLength = FT_GET_ULONG();
+ table->CheckSum = FT_GET_ULONG();
+
+ FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n",
+ (FT_Char)( table->Tag >> 24 ),
+ (FT_Char)( table->Tag >> 16 ),
+ (FT_Char)( table->Tag >> 8 ),
+ (FT_Char)( table->Tag ),
+ table->Offset,
+ table->CompLength,
+ table->OrigLength,
+ table->CheckSum ));
+
+ if ( table->Tag <= old_tag )
+ {
+ FT_FRAME_EXIT();
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ old_tag = table->Tag;
+ indices[nn] = table;
+ }
+
+ FT_FRAME_EXIT();
+
+ /* Sort by offset. */
+
+ ft_qsort( indices,
+ woff.num_tables,
+ sizeof ( WOFF_Table ),
+ compare_offsets );
+
+ /* Check offsets and lengths. */
+
+ woff_offset = 44 + woff.num_tables * 20L;
+ sfnt_offset = 12 + woff.num_tables * 16L;
+
+ for ( nn = 0; nn < woff.num_tables; nn++ )
+ {
+ WOFF_Table table = indices[nn];
+
+
+ if ( table->Offset != woff_offset ||
+ table->CompLength > woff.length ||
+ table->Offset > woff.length - table->CompLength ||
+ table->OrigLength > woff.totalSfntSize ||
+ sfnt_offset > woff.totalSfntSize - table->OrigLength ||
+ table->CompLength > table->OrigLength )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ table->OrigOffset = sfnt_offset;
+
+ /* The offsets must be multiples of 4. */
+ woff_offset += ( table->CompLength + 3 ) & ~3;
+ sfnt_offset += ( table->OrigLength + 3 ) & ~3;
+ }
+
+ /*
+ * Final checks!
+ *
+ * We don't decode and check the metadata block.
+ * We don't check table checksums either.
+ * But other than those, I think we implement all
+ * `MUST' checks from the spec.
+ */
+
+ if ( woff.metaOffset )
+ {
+ if ( woff.metaOffset != woff_offset ||
+ woff.metaOffset + woff.metaLength > woff.length )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ /* We have padding only ... */
+ woff_offset += woff.metaLength;
+ }
+
+ if ( woff.privOffset )
+ {
+ /* ... if it isn't the last block. */
+ woff_offset = ( woff_offset + 3 ) & ~3;
+
+ if ( woff.privOffset != woff_offset ||
+ woff.privOffset + woff.privLength > woff.length )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ /* No padding for the last block. */
+ woff_offset += woff.privLength;
+ }
+
+ if ( sfnt_offset != woff.totalSfntSize ||
+ woff_offset != woff.length )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ /* Write the tables. */
+
+ for ( nn = 0; nn < woff.num_tables; nn++ )
+ {
+ WOFF_Table table = tables + nn;
+
+
+ /* Write SFNT table entry. */
+ WRITE_ULONG( sfnt_header, table->Tag );
+ WRITE_ULONG( sfnt_header, table->CheckSum );
+ WRITE_ULONG( sfnt_header, table->OrigOffset );
+ WRITE_ULONG( sfnt_header, table->OrigLength );
+
+ /* Write table data. */
+ if ( FT_STREAM_SEEK( table->Offset ) ||
+ FT_FRAME_ENTER( table->CompLength ) )
+ goto Exit;
+
+ if ( table->CompLength == table->OrigLength )
+ {
+ /* Uncompressed data; just copy. */
+ ft_memcpy( sfnt + table->OrigOffset,
+ stream->cursor,
+ table->OrigLength );
+ }
+ else
+ {
+#ifdef FT_CONFIG_OPTION_USE_ZLIB
+
+ /* Uncompress with zlib. */
+ FT_ULong output_len = table->OrigLength;
+
+
+ error = FT_Gzip_Uncompress( memory,
+ sfnt + table->OrigOffset, &output_len,
+ stream->cursor, table->CompLength );
+ if ( error )
+ goto Exit;
+ if ( output_len != table->OrigLength )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+#else /* !FT_CONFIG_OPTION_USE_ZLIB */
+
+ error = FT_THROW( Unimplemented_Feature );
+ goto Exit;
+
+#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
+ }
+
+ FT_FRAME_EXIT();
+
+ /* We don't check whether the padding bytes in the WOFF file are */
+ /* actually '\0'. For the output, however, we do set them properly. */
+ sfnt_offset = table->OrigOffset + table->OrigLength;
+ while ( sfnt_offset & 3 )
+ {
+ sfnt[sfnt_offset] = '\0';
+ sfnt_offset++;
+ }
+ }
+
+ /* Ok! Finally ready. Swap out stream and return. */
+ FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize );
+ sfnt_stream->memory = stream->memory;
+ sfnt_stream->close = sfnt_stream_close;
+
+ FT_Stream_Free(
+ face->root.stream,
+ ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
+
+ face->root.stream = sfnt_stream;
+
+ face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
+
+ Exit:
+ FT_FREE( tables );
+ FT_FREE( indices );
+
+ if ( error )
+ {
+ FT_FREE( sfnt );
+ FT_Stream_Close( sfnt_stream );
+ FT_FREE( sfnt_stream );
+ }
+
+ return error;
+ }
+
+
+#undef WRITE_USHORT
+#undef WRITE_ULONG
+
+
/* Fill in face->ttc_header. If the font is not a TTC, it is */
/* synthesized into a TTC with one offset table. */
static FT_Error
@@ -356,7 +742,7 @@
FT_FRAME_START( 8 ),
FT_FRAME_LONG( version ),
- FT_FRAME_LONG( count ),
+ FT_FRAME_LONG( count ), /* this is ULong in the specs */
FT_FRAME_END
};
@@ -365,18 +751,38 @@
face->ttc_header.version = 0;
face->ttc_header.count = 0;
+ retry:
offset = FT_STREAM_POS();
if ( FT_READ_ULONG( tag ) )
return error;
+ if ( tag == TTAG_wOFF )
+ {
+ FT_TRACE2(( "sfnt_open_font: file is a WOFF; synthesizing SFNT\n" ));
+
+ if ( FT_STREAM_SEEK( offset ) )
+ return error;
+
+ error = woff_open_font( stream, face );
+ if ( error )
+ return error;
+
+ /* Swap out stream and retry! */
+ stream = face->root.stream;
+ goto retry;
+ }
+
if ( tag != 0x00010000UL &&
tag != TTAG_ttcf &&
tag != TTAG_OTTO &&
tag != TTAG_true &&
tag != TTAG_typ1 &&
tag != 0x00020000UL )
- return SFNT_Err_Unknown_File_Format;
+ {
+ FT_TRACE2(( " not a font using the SFNT container format\n" ));
+ return FT_THROW( Unknown_File_Format );
+ }
face->ttc_header.tag = TTAG_ttcf;
@@ -390,6 +796,17 @@
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
return error;
+ if ( face->ttc_header.count == 0 )
+ return FT_THROW( Invalid_Table );
+
+ /* a rough size estimate: let's conservatively assume that there */
+ /* is just a single table info in each subfont header (12 + 16*1 = */
+ /* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
+ /* size of the TTC header plus `28*count' bytes for all subfont */
+ /* headers */
+ if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
+ return FT_THROW( Array_Too_Large );
+
/* now read the offsets of each font in the file */
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
return error;
@@ -441,7 +858,10 @@
{
sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
- return SFNT_Err_Invalid_File_Format;
+ {
+ FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" ));
+ return FT_THROW( Missing_Module );
+ }
face->sfnt = sfnt;
face->goto_table = sfnt->goto_table;
@@ -449,17 +869,22 @@
FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
+ FT_TRACE2(( "SFNT driver\n" ));
+
error = sfnt_open_font( stream, face );
if ( error )
return error;
+ /* Stream may have changed in sfnt_open_font. */
+ stream = face->root.stream;
+
FT_TRACE2(( "sfnt_init_face: %08p, %ld\n", face, face_index ));
if ( face_index < 0 )
face_index = 0;
if ( face_index >= face->ttc_header.count )
- return SFNT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) )
return error;
@@ -476,42 +901,45 @@
}
-#define LOAD_( x ) \
- do { \
- FT_TRACE2(( "`" #x "' " )); \
- FT_TRACE3(( "-->\n" )); \
- \
- error = sfnt->load_##x( face, stream ); \
- \
- FT_TRACE2(( "%s\n", ( !error ) \
- ? "loaded" \
- : ( error == SFNT_Err_Table_Missing ) \
- ? "missing" \
- : "failed to load" )); \
- FT_TRACE3(( "\n" )); \
+#define LOAD_( x ) \
+ do \
+ { \
+ FT_TRACE2(( "`" #x "' " )); \
+ FT_TRACE3(( "-->\n" )); \
+ \
+ error = sfnt->load_ ## x( face, stream ); \
+ \
+ FT_TRACE2(( "%s\n", ( !error ) \
+ ? "loaded" \
+ : FT_ERR_EQ( error, Table_Missing ) \
+ ? "missing" \
+ : "failed to load" )); \
+ FT_TRACE3(( "\n" )); \
} while ( 0 )
-#define LOADM_( x, vertical ) \
- do { \
- FT_TRACE2(( "`%s" #x "' ", \
- vertical ? "vertical " : "" )); \
- FT_TRACE3(( "-->\n" )); \
- \
- error = sfnt->load_##x( face, stream, vertical ); \
- \
- FT_TRACE2(( "%s\n", ( !error ) \
- ? "loaded" \
- : ( error == SFNT_Err_Table_Missing ) \
- ? "missing" \
- : "failed to load" )); \
- FT_TRACE3(( "\n" )); \
+#define LOADM_( x, vertical ) \
+ do \
+ { \
+ FT_TRACE2(( "`%s" #x "' ", \
+ vertical ? "vertical " : "" )); \
+ FT_TRACE3(( "-->\n" )); \
+ \
+ error = sfnt->load_ ## x( face, stream, vertical ); \
+ \
+ FT_TRACE2(( "%s\n", ( !error ) \
+ ? "loaded" \
+ : FT_ERR_EQ( error, Table_Missing ) \
+ ? "missing" \
+ : "failed to load" )); \
+ FT_TRACE3(( "\n" )); \
} while ( 0 )
-#define GET_NAME( id, field ) \
- do { \
- error = tt_face_get_name( face, TT_NAME_ID_##id, field ); \
- if ( error ) \
- goto Exit; \
+#define GET_NAME( id, field ) \
+ do \
+ { \
+ error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
+ if ( error ) \
+ goto Exit; \
} while ( 0 )
@@ -528,15 +956,17 @@
#endif
FT_Bool has_outline;
FT_Bool is_apple_sbit;
- FT_Bool ignore_preferred_family = FALSE;
+ FT_Bool is_apple_sbix;
+ FT_Bool ignore_preferred_family = FALSE;
FT_Bool ignore_preferred_subfamily = FALSE;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
FT_UNUSED( face_index );
+
/* Check parameters */
-
+
{
FT_Int i;
@@ -571,15 +1001,22 @@
/* 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 != 0 ||
+ tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
+ tt_face_lookup_table( face, TTAG_CFF ) != 0 );
#else
- has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
- tt_face_lookup_table( face, TTAG_CFF ) != 0 );
+ has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
+ tt_face_lookup_table( face, TTAG_CFF ) != 0 );
#endif
is_apple_sbit = 0;
+ is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
+
+ /* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf'
+ * outline rendered on top. We don't support that yet, so just ignore
+ * the 'glyf' outline and advertise it as a bitmap-only font. */
+ if ( is_apple_sbix )
+ has_outline = FALSE;
/* if this font doesn't contain outlines, we try to load */
/* a `bhed' table */
@@ -591,7 +1028,7 @@
/* load the font header (`head' table) if this isn't an Apple */
/* sbit font file */
- if ( !is_apple_sbit )
+ if ( !is_apple_sbit || is_apple_sbix )
{
LOAD_( head );
if ( error )
@@ -600,7 +1037,7 @@
if ( face->header.Units_Per_EM == 0 )
{
- error = SFNT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -628,9 +1065,9 @@
if ( !error )
{
LOADM_( hmtx, 0 );
- if ( error == SFNT_Err_Table_Missing )
+ if ( FT_ERR_EQ( error, Table_Missing ) )
{
- error = SFNT_Err_Hmtx_Table_Missing;
+ error = FT_THROW( Hmtx_Table_Missing );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* If this is an incrementally loaded font and there are */
@@ -640,23 +1077,24 @@
get_glyph_metrics )
{
face->horizontal.number_Of_HMetrics = 0;
- error = SFNT_Err_Ok;
+ error = FT_Err_Ok;
}
#endif
}
}
- else if ( error == SFNT_Err_Table_Missing )
+ else if ( FT_ERR_EQ( error, Table_Missing ) )
{
/* No `hhea' table necessary for SFNT Mac fonts. */
if ( face->format_tag == TTAG_true )
{
FT_TRACE2(( "This is an SFNT Mac font.\n" ));
+
has_outline = 0;
- error = SFNT_Err_Ok;
+ error = FT_Err_Ok;
}
else
{
- error = SFNT_Err_Horiz_Header_Missing;
+ error = FT_THROW( Horiz_Header_Missing );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* If this is an incrementally loaded font and there are */
@@ -666,7 +1104,7 @@
get_glyph_metrics )
{
face->horizontal.number_Of_HMetrics = 0;
- error = SFNT_Err_Ok;
+ error = FT_Err_Ok;
}
#endif
@@ -685,15 +1123,13 @@
face->vertical_info = 1;
}
- if ( error && error != SFNT_Err_Table_Missing )
+ if ( error && FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
LOAD_( os2 );
if ( error )
{
- if ( error != SFNT_Err_Table_Missing )
- goto Exit;
-
+ /* we treat the table as missing if there are any errors */
face->os2.version = 0xFFFFU;
}
}
@@ -709,8 +1145,8 @@
/* 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 ( error == SFNT_Err_Table_Missing )
- error = SFNT_Err_Ok;
+ if ( FT_ERR_EQ( error, Table_Missing ) )
+ error = FT_Err_Ok;
else
goto Exit;
}
@@ -719,7 +1155,7 @@
LOAD_( pclt );
if ( error )
{
- if ( error != SFNT_Err_Table_Missing )
+ if ( FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
face->pclt.Version = 0;
@@ -776,6 +1212,10 @@
/* */
/* Compute face flags. */
/* */
+ if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC ||
+ face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX )
+ flags |= FT_FACE_FLAG_COLOR; /* color glyphs */
+
if ( has_outline == TRUE )
flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
@@ -785,7 +1225,7 @@
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- if ( psnames_error == SFNT_Err_Ok &&
+ if ( !psnames_error &&
face->postscript.FormatType != 0x00030000L )
flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif
@@ -892,11 +1332,7 @@
FT_UInt i, count;
-#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
count = face->sbit_num_strikes;
-#else
- count = (FT_UInt)face->num_sbit_strikes;
-#endif
if ( count > 0 )
{
@@ -908,7 +1344,7 @@
if ( em_size == 0 || face->os2.version == 0xFFFFU )
{
- avgwidth = 0;
+ avgwidth = 1;
em_size = 1;
}
@@ -989,40 +1425,36 @@
/* table cannot be used to compute the text height reliably! */
/* */
- /* The ascender/descender/height are computed from the OS/2 table */
- /* when found. Otherwise, they're taken from the horizontal */
- /* header. */
- /* */
+ /* The ascender and descender are taken from the `hhea' table. */
+ /* If zero, they are taken from the `OS/2' table. */
root->ascender = face->horizontal.Ascender;
root->descender = face->horizontal.Descender;
- root->height = (FT_Short)( root->ascender - root->descender +
- face->horizontal.Line_Gap );
+ root->height = (FT_Short)( root->ascender - root->descender +
+ face->horizontal.Line_Gap );
-#if 0
- /* if the line_gap is 0, we add an extra 15% to the text height -- */
- /* this computation is based on various versions of Times New Roman */
- if ( face->horizontal.Line_Gap == 0 )
- root->height = (FT_Short)( ( root->height * 115 + 50 ) / 100 );
-#endif /* 0 */
-
-#if 0
- /* some fonts have the OS/2 "sTypoAscender", "sTypoDescender" & */
- /* "sTypoLineGap" fields set to 0, like ARIALNB.TTF */
- if ( face->os2.version != 0xFFFFU && root->ascender )
+ if ( !( root->ascender || root->descender ) )
{
- FT_Int height;
-
+ if ( face->os2.version != 0xFFFFU )
+ {
+ if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
+ {
+ root->ascender = face->os2.sTypoAscender;
+ root->descender = face->os2.sTypoDescender;
- root->ascender = face->os2.sTypoAscender;
- root->descender = -face->os2.sTypoDescender;
+ root->height = (FT_Short)( root->ascender - root->descender +
+ face->os2.sTypoLineGap );
+ }
+ else
+ {
+ root->ascender = (FT_Short)face->os2.usWinAscent;
+ root->descender = -(FT_Short)face->os2.usWinDescent;
- height = root->ascender + root->descender + face->os2.sTypoLineGap;
- if ( height > root->height )
- root->height = height;
+ root->height = (FT_UShort)( root->ascender - root->descender );
+ }
+ }
}
-#endif /* 0 */
root->max_advance_width = face->horizontal.advance_Width_Max;
root->max_advance_height = (FT_Short)( face->vertical_info
@@ -1101,7 +1533,6 @@
}
/* freeing the horizontal metrics */
-#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
{
FT_Stream stream = FT_FACE_STREAM( face );
@@ -1111,10 +1542,6 @@
face->horz_metrics_size = 0;
face->vert_metrics_size = 0;
}
-#else
- FT_FREE( face->horizontal.long_metrics );
- FT_FREE( face->horizontal.short_metrics );
-#endif
/* freeing the vertical ones, if any */
if ( face->vertical_info )
diff --git a/src/3rdparty/freetype/src/sfnt/ttbdf.c b/src/3rdparty/freetype/src/sfnt/ttbdf.c
index 206cecee5e..9401dae5f8 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, 2006 by */
+/* Copyright 2005, 2006, 2010, 2013 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 @@
length < 8 ||
FT_FRAME_EXTRACT( length, bdf->table ) )
{
- error = FT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -131,7 +131,7 @@
BadTable:
FT_FRAME_RELEASE( bdf->table );
FT_ZERO( bdf );
- error = FT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -143,7 +143,7 @@
{
TT_BDF bdf = &face->bdf;
FT_Size size = FT_FACE(face)->size;
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
FT_Byte* p;
FT_UInt count;
FT_Byte* strike;
@@ -163,7 +163,7 @@
p = bdf->table + 8;
strike = p + 4 * count;
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( size == NULL || property_name == NULL )
goto Exit;
@@ -215,7 +215,7 @@
{
aprop->type = BDF_PROPERTY_TYPE_ATOM;
aprop->u.atom = (const char*)bdf->strings + value;
- error = 0;
+ error = FT_Err_Ok;
goto Exit;
}
break;
@@ -223,13 +223,13 @@
case 0x02:
aprop->type = BDF_PROPERTY_TYPE_INTEGER;
aprop->u.integer = (FT_Int32)value;
- error = 0;
+ error = FT_Err_Ok;
goto Exit;
case 0x03:
aprop->type = BDF_PROPERTY_TYPE_CARDINAL;
aprop->u.cardinal = value;
- error = 0;
+ error = FT_Err_Ok;
goto Exit;
default:
diff --git a/src/3rdparty/freetype/src/sfnt/ttcmap.c b/src/3rdparty/freetype/src/sfnt/ttcmap.c
index b283f6d162..f54de70691 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2002-2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -56,7 +56,7 @@
FT_Byte* table )
{
cmap->data = table;
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -88,9 +88,15 @@
tt_cmap0_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p = table + 2;
- FT_UInt length = TT_NEXT_USHORT( p );
+ FT_Byte* p;
+ FT_UInt length;
+
+
+ if ( table + 2 + 2 > valid->limit )
+ FT_INVALID_TOO_SHORT;
+ p = table + 2; /* skip format */
+ length = TT_NEXT_USHORT( p );
if ( table + length > valid->limit || length < 262 )
FT_INVALID_TOO_SHORT;
@@ -110,7 +116,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -161,24 +167,28 @@
cmap_info->format = 0;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_TT_CMAP(tt_cmap0_class_rec,
- sizeof ( TT_CMapRec ),
+ 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,
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap0_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap0_char_next,
+
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
- NULL, NULL, NULL, NULL, NULL
- ,
0,
- (TT_CMap_ValidateFunc) tt_cmap0_validate,
- (TT_CMap_Info_GetFunc) tt_cmap0_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap0_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap0_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_0 */
@@ -275,13 +285,20 @@
tt_cmap2_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p = table + 2; /* skip format */
- FT_UInt length = TT_PEEK_USHORT( p );
+ FT_Byte* p;
+ FT_UInt length;
+
FT_UInt n, max_subs;
- FT_Byte* keys; /* keys table */
- FT_Byte* subs; /* sub-headers */
- FT_Byte* glyph_ids; /* glyph ID array */
+ FT_Byte* keys; /* keys table */
+ FT_Byte* subs; /* sub-headers */
+ FT_Byte* glyph_ids; /* glyph ID array */
+
+
+ if ( table + 2 + 2 > valid->limit )
+ FT_INVALID_TOO_SHORT;
+ p = table + 2; /* skip format */
+ length = TT_NEXT_USHORT( p );
if ( table + length > valid->limit || length < 6 + 512 )
FT_INVALID_TOO_SHORT;
@@ -316,9 +333,8 @@
/* parse sub-headers */
for ( n = 0; n <= max_subs; n++ )
{
- FT_UInt first_code, code_count, offset;
- FT_Int delta;
- FT_Byte* ids;
+ FT_UInt first_code, code_count, offset;
+ FT_Int delta;
first_code = TT_NEXT_USHORT( p );
@@ -340,6 +356,9 @@
/* check offset */
if ( offset != 0 )
{
+ FT_Byte* ids;
+
+
ids = p - 2 + offset;
if ( ids < glyph_ids || ids + code_count*2 > table + length )
FT_INVALID_OFFSET;
@@ -365,7 +384,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -537,24 +556,28 @@
cmap_info->format = 2;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_TT_CMAP(tt_cmap2_class_rec,
- sizeof ( TT_CMapRec ),
+ 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,
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap2_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap2_char_next,
+
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
- NULL, NULL, NULL, NULL, NULL
- ,
2,
- (TT_CMap_ValidateFunc) tt_cmap2_validate,
- (TT_CMap_Info_GetFunc) tt_cmap2_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap2_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap2_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_2 */
@@ -662,7 +685,7 @@
cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL;
cmap->cur_gindex = 0;
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -808,16 +831,20 @@
tt_cmap4_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p = table + 2; /* skip format */
- FT_UInt length = TT_NEXT_USHORT( p );
+ FT_Byte* p;
+ FT_UInt length;
+
FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids;
FT_UInt num_segs;
- FT_Error error = SFNT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
- if ( length < 16 )
+ if ( table + 2 + 2 > valid->limit )
FT_INVALID_TOO_SHORT;
+ p = table + 2; /* skip format */
+ length = TT_NEXT_USHORT( p );
+
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -828,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
@@ -1373,23 +1403,27 @@
cmap_info->format = 4;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- 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,
+ 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,
- NULL, NULL, NULL, NULL, NULL
- ,
4,
- (TT_CMap_ValidateFunc) tt_cmap4_validate,
- (TT_CMap_Info_GetFunc) tt_cmap4_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap4_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap4_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_4 */
@@ -1456,7 +1490,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -1532,24 +1566,28 @@
cmap_info->format = 6;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_TT_CMAP(tt_cmap6_class_rec,
- sizeof ( TT_CMapRec ),
+ 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,
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap6_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap6_char_next,
+
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
- NULL, NULL, NULL, NULL, NULL
- ,
6,
- (TT_CMap_ValidateFunc) tt_cmap6_validate,
- (TT_CMap_Info_GetFunc) tt_cmap6_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap6_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap6_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_6 */
@@ -1631,7 +1669,8 @@
p = is32 + 8192; /* skip `is32' array */
num_groups = TT_NEXT_ULONG( p );
- if ( p + num_groups * 12 > valid->limit )
+ /* p + num_groups * 12 > valid->limit ? */
+ if ( num_groups > (FT_UInt32)( valid->limit - p ) / 12 )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
@@ -1656,7 +1695,12 @@
if ( valid->level >= FT_VALIDATE_TIGHT )
{
- if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
+ FT_UInt32 d = end - start;
+
+
+ /* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
+ if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
+ start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
FT_INVALID_GLYPH_ID;
count = (FT_UInt32)( end - start + 1 );
@@ -1700,7 +1744,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -1785,24 +1829,28 @@
cmap_info->format = 8;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_TT_CMAP(tt_cmap8_class_rec,
- sizeof ( TT_CMapRec ),
+ 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,
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc)tt_cmap8_char_index,
- (FT_CMap_CharNextFunc) tt_cmap8_char_next,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
- NULL, NULL, NULL, NULL, NULL
- ,
8,
- (TT_CMap_ValidateFunc) tt_cmap8_validate,
- (TT_CMap_Info_GetFunc) tt_cmap8_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap8_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap8_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_8 */
@@ -1850,7 +1898,9 @@
count = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
- length < 20 + count * 2 )
+ /* length < 20 + count * 2 ? */
+ length < 20 ||
+ ( length - 20 ) / 2 < count )
FT_INVALID_TOO_SHORT;
/* check glyph indices */
@@ -1867,7 +1917,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -1934,24 +1984,28 @@
cmap_info->format = 10;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_TT_CMAP(tt_cmap10_class_rec,
- sizeof ( TT_CMapRec ),
+ 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,
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap10_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap10_char_next,
+
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
- NULL, NULL, NULL, NULL, NULL
- ,
10,
- (TT_CMap_ValidateFunc) tt_cmap10_validate,
- (TT_CMap_Info_GetFunc) tt_cmap10_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap10_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap10_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_10 */
@@ -2010,7 +2064,7 @@
cmap->valid = 0;
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2018,9 +2072,9 @@
tt_cmap12_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p;
- FT_ULong length;
- FT_ULong num_groups;
+ FT_Byte* p;
+ FT_ULong length;
+ FT_ULong num_groups;
if ( table + 16 > valid->limit )
@@ -2033,7 +2087,9 @@
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
- length < 16 + 12 * num_groups )
+ /* length < 16 + 12 * num_groups ? */
+ length < 16 ||
+ ( length - 16 ) / 12 < num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
@@ -2055,7 +2111,12 @@
if ( valid->level >= FT_VALIDATE_TIGHT )
{
- if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
+ FT_UInt32 d = end - start;
+
+
+ /* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
+ if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
+ start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
FT_INVALID_GLYPH_ID;
}
@@ -2063,7 +2124,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2084,8 +2145,6 @@
char_code = cmap->cur_charcode + 1;
- n = cmap->cur_group;
-
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
@@ -2254,24 +2313,28 @@
cmap_info->format = 12;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_TT_CMAP(tt_cmap12_class_rec,
- sizeof ( TT_CMap12Rec ),
+ 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,
+ (FT_CMap_InitFunc) tt_cmap12_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap12_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap12_char_next,
+
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
- NULL, NULL, NULL, NULL, NULL
- ,
12,
- (TT_CMap_ValidateFunc) tt_cmap12_validate,
- (TT_CMap_Info_GetFunc) tt_cmap12_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap12_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap12_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_12 */
@@ -2330,7 +2393,7 @@
cmap->valid = 0;
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2338,9 +2401,9 @@
tt_cmap13_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p;
- FT_ULong length;
- FT_ULong num_groups;
+ FT_Byte* p;
+ FT_ULong length;
+ FT_ULong num_groups;
if ( table + 16 > valid->limit )
@@ -2353,7 +2416,9 @@
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
- length < 16 + 12 * num_groups )
+ /* length < 16 + 12 * num_groups ? */
+ length < 16 ||
+ ( length - 16 ) / 12 < num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
@@ -2383,7 +2448,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2404,8 +2469,6 @@
char_code = cmap->cur_charcode + 1;
- n = cmap->cur_group;
-
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
@@ -2490,7 +2553,6 @@
/* if `char_code' is not in any group, then `mid' is */
/* the group nearest to `char_code' */
- /* */
if ( char_code > end )
{
@@ -2570,24 +2632,28 @@
cmap_info->format = 13;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
- FT_DEFINE_TT_CMAP(tt_cmap13_class_rec,
- sizeof ( TT_CMap13Rec ),
+ 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,
+ (FT_CMap_InitFunc) tt_cmap13_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap13_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap13_char_next,
+
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
- NULL, NULL, NULL, NULL, NULL
- ,
13,
- (TT_CMap_ValidateFunc) tt_cmap13_validate,
- (TT_CMap_Info_GetFunc) tt_cmap13_get_info
- )
+ (TT_CMap_ValidateFunc)tt_cmap13_validate,
+ (TT_CMap_Info_GetFunc)tt_cmap13_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_13 */
@@ -2688,8 +2754,8 @@
FT_UInt32 num_results,
FT_Memory memory )
{
- FT_UInt32 old_max = cmap->max_results;
- FT_Error error = 0;
+ FT_UInt32 old_max = cmap->max_results;
+ FT_Error error = FT_Err_Ok;
if ( num_results > cmap->max_results )
@@ -2713,11 +2779,11 @@
cmap->cmap.data = table;
table += 6;
- cmap->num_selectors = FT_PEEK_ULONG( table );
- cmap->max_results = 0;
- cmap->results = NULL;
+ cmap->num_selectors = FT_PEEK_ULONG( table );
+ cmap->max_results = 0;
+ cmap->results = NULL;
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2725,13 +2791,22 @@
tt_cmap14_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p = table + 2;
- FT_ULong length = TT_NEXT_ULONG( p );
- FT_ULong num_selectors = TT_NEXT_ULONG( p );
+ FT_Byte* p;
+ FT_ULong length;
+ FT_ULong num_selectors;
+
+
+ if ( table + 2 + 4 + 4 > valid->limit )
+ FT_INVALID_TOO_SHORT;
+ p = table + 2;
+ length = TT_NEXT_ULONG( p );
+ num_selectors = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
- length < 10 + 11 * num_selectors )
+ /* length < 10 + 11 * num_selectors ? */
+ length < 10 ||
+ ( length - 10 ) / 11 < num_selectors )
FT_INVALID_TOO_SHORT;
/* check selectors, they must be in increasing order */
@@ -2767,7 +2842,8 @@
FT_ULong lastBase = 0;
- if ( defp + numRanges * 4 > valid->limit )
+ /* defp + numRanges * 4 > valid->limit ? */
+ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numRanges; ++i )
@@ -2787,13 +2863,15 @@
}
/* and the non-default table (these glyphs are specified here) */
- if ( nondefOff != 0 ) {
+ if ( nondefOff != 0 )
+ {
FT_Byte* ndp = table + nondefOff;
FT_ULong numMappings = TT_NEXT_ULONG( ndp );
- FT_ULong i, lastUni = 0;
+ FT_ULong i, lastUni = 0;
- if ( numMappings * 4 > (FT_ULong)( valid->limit - ndp ) )
+ /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */
+ if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numMappings; ++i )
@@ -2818,7 +2896,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2856,7 +2934,7 @@
/* subtable 14 does not define a language field */
cmap_info->language = 0xFFFFFFFFUL;
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -2964,7 +3042,7 @@
tt_cmap14_char_var_index( TT_CMap cmap,
TT_CMap ucmap,
FT_UInt32 charcode,
- FT_UInt32 variantSelector)
+ FT_UInt32 variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
@@ -3105,9 +3183,9 @@
static FT_UInt32*
- tt_cmap14_get_def_chars( TT_CMap cmap,
- FT_Byte* p,
- FT_Memory memory )
+ tt_cmap14_get_def_chars( TT_CMap cmap,
+ FT_Byte* p,
+ FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
@@ -3123,7 +3201,7 @@
for ( q = cmap14->results; numRanges > 0; --numRanges )
{
- FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
+ FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
cnt = FT_NEXT_BYTE( p ) + 1;
@@ -3132,6 +3210,7 @@
q[0] = uni;
uni += 1;
q += 1;
+
} while ( --cnt != 0 );
}
q[0] = 0;
@@ -3175,7 +3254,6 @@
{
FT_Byte *p = tt_cmap14_find_variant( cmap->data + 6,
variantSelector );
- FT_UInt32 *ret;
FT_Int i;
FT_ULong defOff;
FT_ULong nondefOff;
@@ -3209,6 +3287,8 @@
FT_Byte* dp;
FT_UInt di, ni, k;
+ FT_UInt32 *ret;
+
p = cmap->data + nondefOff;
dp = cmap->data + defOff;
@@ -3305,25 +3385,25 @@
}
- FT_DEFINE_TT_CMAP(tt_cmap14_class_rec,
- sizeof ( TT_CMap14Rec ),
+ 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,
- (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,
+ /* 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_Info_GetFunc)tt_cmap14_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_14 */
@@ -3332,43 +3412,55 @@
static const TT_CMap_Class tt_cmap_classes[] =
{
-#define TTCMAPCITEM(a) &a,
+#define TTCMAPCITEM( a ) &a,
#include "ttcmapc.h"
NULL,
};
#else /*FT_CONFIG_OPTION_PIC*/
- void FT_Destroy_Class_tt_cmap_classes(FT_Library library, TT_CMap_Class* clazz)
+ void
+ FT_Destroy_Class_tt_cmap_classes( FT_Library library,
+ TT_CMap_Class* clazz )
{
- FT_Memory memory = library->memory;
+ FT_Memory memory = library->memory;
+
+
if ( clazz )
FT_FREE( clazz );
}
- FT_Error FT_Create_Class_tt_cmap_classes(FT_Library library, TT_CMap_Class** output_class)
+
+ FT_Error
+ FT_Create_Class_tt_cmap_classes( FT_Library library,
+ TT_CMap_Class** output_class )
{
- TT_CMap_Class* clazz;
- TT_CMap_ClassRec* recs;
- FT_Error error;
- FT_Memory memory = library->memory;
- int i = 0;
+ TT_CMap_Class* clazz = NULL;
+ TT_CMap_ClassRec* recs;
+ FT_Error error;
+ FT_Memory memory = library->memory;
+
+ int i = 0;
-#define TTCMAPCITEM(a) i++;
+
+#define TTCMAPCITEM( a ) i++;
#include "ttcmapc.h"
- /* allocate enough space for both the pointers +terminator and the class instances */
- if ( FT_ALLOC( clazz, sizeof(*clazz)*(i+1)+sizeof(TT_CMap_ClassRec)*i ) )
+ /* allocate enough space for both the pointers */
+ /* plus terminator and the class instances */
+ if ( FT_ALLOC( clazz, sizeof ( *clazz ) * ( i + 1 ) +
+ sizeof ( TT_CMap_ClassRec ) * i ) )
return error;
/* the location of the class instances follows the array of pointers */
- recs = (TT_CMap_ClassRec*) (((char*)clazz)+(sizeof(*clazz)*(i+1)));
- i=0;
+ recs = (TT_CMap_ClassRec*)( (char*)clazz +
+ sizeof ( *clazz ) * ( i + 1 ) );
+ i = 0;
#undef TTCMAPCITEM
-#define TTCMAPCITEM(a) \
- FT_Init_Class_##a(&recs[i]); \
- clazz[i] = &recs[i]; \
+#define TTCMAPCITEM( a ) \
+ FT_Init_Class_ ## a( &recs[i] ); \
+ clazz[i] = &recs[i]; \
i++;
#include "ttcmapc.h"
@@ -3391,21 +3483,21 @@
FT_Byte* limit = table + face->cmap_size;
FT_UInt volatile num_cmaps;
FT_Byte* volatile p = table;
- FT_Library library = FT_FACE_LIBRARY(face);
- FT_UNUSED(library);
+ FT_Library library = FT_FACE_LIBRARY( face );
+
+ FT_UNUSED( library );
- if ( p + 4 > limit )
- return SFNT_Err_Invalid_Table;
+ if ( !p || p + 4 > limit )
+ return FT_THROW( Invalid_Table );
/* only recognize format 0 */
if ( TT_NEXT_USHORT( p ) != 0 )
{
- p -= 2;
FT_ERROR(( "tt_face_build_cmaps:"
" unsupported `cmap' table format = %d\n",
- TT_PEEK_USHORT( p ) ));
- return SFNT_Err_Invalid_Table;
+ TT_PEEK_USHORT( p - 2 ) ));
+ return FT_THROW( Invalid_Table );
}
num_cmaps = TT_NEXT_USHORT( p );
@@ -3426,7 +3518,7 @@
{
FT_Byte* volatile cmap = table + offset;
volatile FT_UInt format = TT_PEEK_USHORT( cmap );
- const TT_CMap_Class* volatile pclazz = FT_TT_CMAP_CLASSES_GET;
+ const TT_CMap_Class* volatile pclazz = TT_CMAP_CLASSES_GET;
TT_CMap_Class volatile clazz;
@@ -3436,7 +3528,7 @@
if ( clazz->format == format )
{
volatile TT_ValidatorRec valid;
- volatile FT_Error error = SFNT_Err_Ok;
+ volatile FT_Error error = FT_Err_Ok;
ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
@@ -3444,8 +3536,7 @@
valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
- if ( ft_setjmp(
- *((ft_jmp_buf*)&FT_VALIDATOR( &valid )->jump_buffer) ) == 0 )
+ if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer) == 0 )
{
/* validate this cmap sub-table */
error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
@@ -3456,9 +3547,9 @@
FT_CMap ttcmap;
- /* It might make sense to store the single variation selector */
- /* cmap somewhere special. But it would have to be in the */
- /* public FT_FaceRec, and we can't change that. */
+ /* It might make sense to store the single variation */
+ /* selector cmap somewhere special. But it would have to be */
+ /* in the public FT_FaceRec, and we can't change that. */
if ( !FT_CMap_New( (FT_CMap_Class)clazz,
cmap, &charmap, &ttcmap ) )
@@ -3485,7 +3576,7 @@
}
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/sfnt/ttcmap.h b/src/3rdparty/freetype/src/sfnt/ttcmap.h
index 15a4a21e50..0fde1676bf 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, 2003, 2004, 2005 by */
+/* Copyright 2002-2005, 2009, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -55,46 +55,79 @@ FT_BEGIN_HEADER
} TT_CMap_ClassRec;
+
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_DEFINE_TT_CMAP(class_, size_, init_, done_, char_index_, \
- char_next_, char_var_index_, char_var_default_, variant_list_, \
- charvariant_list_,variantchar_list_, \
- format_, validate_, get_cmap_info_) \
- FT_CALLBACK_TABLE_DEF \
- const TT_CMap_ClassRec class_ = \
- { \
- {size_, init_, done_, char_index_, \
- char_next_, char_var_index_, char_var_default_, variant_list_, \
- charvariant_list_, variantchar_list_}, \
- format_, validate_, get_cmap_info_ \
+#define FT_DEFINE_TT_CMAP( class_, \
+ size_, \
+ init_, \
+ done_, \
+ char_index_, \
+ char_next_, \
+ char_var_index_, \
+ char_var_default_, \
+ variant_list_, \
+ charvariant_list_, \
+ variantchar_list_, \
+ format_, \
+ validate_, \
+ get_cmap_info_ ) \
+ FT_CALLBACK_TABLE_DEF \
+ const TT_CMap_ClassRec class_ = \
+ { \
+ { size_, \
+ init_, \
+ done_, \
+ char_index_, \
+ char_next_, \
+ char_var_index_, \
+ char_var_default_, \
+ variant_list_, \
+ charvariant_list_, \
+ variantchar_list_ \
+ }, \
+ \
+ format_, \
+ validate_, \
+ get_cmap_info_ \
};
-#else /* FT_CONFIG_OPTION_PIC */
-
-#define FT_DEFINE_TT_CMAP(class_, size_, init_, done_, char_index_, \
- char_next_, char_var_index_, char_var_default_, variant_list_, \
- charvariant_list_,variantchar_list_, \
- format_, validate_, get_cmap_info_) \
- void \
- FT_Init_Class_##class_( TT_CMap_ClassRec* clazz ) \
- { \
- clazz->clazz.size = size_; \
- clazz->clazz.init = init_; \
- clazz->clazz.done = done_; \
- clazz->clazz.char_index = char_index_; \
- clazz->clazz.char_next = char_next_; \
- clazz->clazz.char_var_index = char_var_index_; \
- clazz->clazz.char_var_default = char_var_default_; \
- clazz->clazz.variant_list = variant_list_; \
- clazz->clazz.charvariant_list = charvariant_list_; \
- clazz->clazz.variantchar_list = variantchar_list_; \
- clazz->format = format_; \
- clazz->validate = validate_; \
- clazz->get_cmap_info = get_cmap_info_; \
- }
-
-#endif /* FT_CONFIG_OPTION_PIC */
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_TT_CMAP( class_, \
+ size_, \
+ init_, \
+ done_, \
+ char_index_, \
+ char_next_, \
+ char_var_index_, \
+ char_var_default_, \
+ variant_list_, \
+ charvariant_list_, \
+ variantchar_list_, \
+ format_, \
+ validate_, \
+ get_cmap_info_ ) \
+ void \
+ FT_Init_Class_ ## class_( TT_CMap_ClassRec* clazz ) \
+ { \
+ clazz->clazz.size = size_; \
+ clazz->clazz.init = init_; \
+ clazz->clazz.done = done_; \
+ clazz->clazz.char_index = char_index_; \
+ clazz->clazz.char_next = char_next_; \
+ clazz->clazz.char_var_index = char_var_index_; \
+ clazz->clazz.char_var_default = char_var_default_; \
+ clazz->clazz.variant_list = variant_list_; \
+ clazz->clazz.charvariant_list = charvariant_list_; \
+ clazz->clazz.variantchar_list = variantchar_list_; \
+ clazz->format = format_; \
+ clazz->validate = validate_; \
+ clazz->get_cmap_info = get_cmap_info_; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
typedef struct TT_ValidatorRec_
{
@@ -104,7 +137,7 @@ FT_BEGIN_HEADER
} TT_ValidatorRec, *TT_Validator;
-#define TT_VALIDATOR( x ) ((TT_Validator)( x ))
+#define TT_VALIDATOR( x ) ( (TT_Validator)( x ) )
#define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs
diff --git a/src/3rdparty/freetype/src/sfnt/ttcmapc.h b/src/3rdparty/freetype/src/sfnt/ttcmapc.h
index 4c9c6a56f7..2ea204309c 100644
--- a/src/3rdparty/freetype/src/sfnt/ttcmapc.h
+++ b/src/3rdparty/freetype/src/sfnt/ttcmapc.h
@@ -17,39 +17,40 @@
#ifdef TT_CONFIG_CMAP_FORMAT_0
- TTCMAPCITEM(tt_cmap0_class_rec)
+ TTCMAPCITEM( tt_cmap0_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_2
- TTCMAPCITEM(tt_cmap2_class_rec)
+ TTCMAPCITEM( tt_cmap2_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_4
- TTCMAPCITEM(tt_cmap4_class_rec)
+ TTCMAPCITEM( tt_cmap4_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_6
- TTCMAPCITEM(tt_cmap6_class_rec)
+ TTCMAPCITEM( tt_cmap6_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_8
- TTCMAPCITEM(tt_cmap8_class_rec)
+ TTCMAPCITEM( tt_cmap8_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_10
- TTCMAPCITEM(tt_cmap10_class_rec)
+ TTCMAPCITEM( tt_cmap10_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_12
- TTCMAPCITEM(tt_cmap12_class_rec)
+ TTCMAPCITEM( tt_cmap12_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_13
- TTCMAPCITEM(tt_cmap13_class_rec)
+ TTCMAPCITEM( tt_cmap13_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_14
- TTCMAPCITEM(tt_cmap14_class_rec)
+ TTCMAPCITEM( tt_cmap14_class_rec )
#endif
+
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttkern.c b/src/3rdparty/freetype/src/sfnt/ttkern.c
index c1540802b8..455e7b5e3d 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 1996-2007, 2009, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
{
FT_ERROR(( "tt_face_load_kern:"
" kerning table is too small - ignored\n" ));
- error = SFNT_Err_Table_Missing;
+ error = FT_THROW( Table_Missing );
goto Exit;
}
@@ -99,7 +99,7 @@
length = FT_NEXT_USHORT( p );
coverage = FT_NEXT_USHORT( p );
- if ( length <= 6 )
+ if ( length <= 6 + 8 )
break;
p_next += length;
@@ -115,7 +115,7 @@
num_pairs = FT_NEXT_USHORT( p );
p += 6;
- if ( ( p_next - p ) / 6 < (int)num_pairs ) /* handle broken count */
+ if ( ( p_next - p ) < 6 * (int)num_pairs ) /* handle broken count */
num_pairs = (FT_UInt)( ( p_next - p ) / 6 );
avail |= mask;
@@ -183,7 +183,7 @@
FT_UInt right_glyph )
{
FT_Int result = 0;
- FT_UInt count, mask = 1;
+ FT_UInt count, mask;
FT_Byte* p = face->kern_table;
FT_Byte* p_limit = p + face->kern_table_size;
@@ -196,7 +196,7 @@
count--, mask <<= 1 )
{
FT_Byte* base = p;
- FT_Byte* next = base;
+ FT_Byte* next;
FT_UInt version = FT_NEXT_USHORT( p );
FT_UInt length = FT_NEXT_USHORT( p );
FT_UInt coverage = FT_NEXT_USHORT( p );
@@ -220,7 +220,7 @@
num_pairs = FT_NEXT_USHORT( p );
p += 6;
- if ( ( next - p ) / 6 < (int)num_pairs ) /* handle broken count */
+ if ( ( next - p ) < 6 * (int)num_pairs ) /* handle broken count */
num_pairs = (FT_UInt)( ( next - p ) / 6 );
switch ( coverage >> 8 )
diff --git a/src/3rdparty/freetype/src/sfnt/ttload.c b/src/3rdparty/freetype/src/sfnt/ttload.c
index 3ad33bd6d8..8338150abd 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -77,7 +77,8 @@
{
/* For compatibility with Windows, we consider */
/* zero-length tables the same as missing tables. */
- if ( entry->Tag == tag ) {
+ if ( entry->Tag == tag )
+ {
if ( entry->Length != 0 )
{
FT_TRACE4(( "found table.\n" ));
@@ -141,7 +142,7 @@
goto Exit;
}
else
- error = SFNT_Err_Table_Missing;
+ error = FT_THROW( Table_Missing );
Exit:
return error;
@@ -206,7 +207,10 @@
}
/* we ignore invalid tables */
- if ( table.Offset + table.Length > stream->size )
+
+ /* table.Offset + table.Length > stream->size ? */
+ if ( table.Length > stream->size ||
+ table.Offset > stream->size - table.Length )
{
FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
continue;
@@ -235,8 +239,9 @@
*/
if ( table.Length < 0x36 )
{
- FT_TRACE2(( "check_table_dir: `head' table too small\n" ));
- error = SFNT_Err_Table_Missing;
+ FT_TRACE2(( "check_table_dir:"
+ " `head' or `bhed' table too small\n" ));
+ error = FT_THROW( Table_Missing );
goto Exit;
}
@@ -245,12 +250,8 @@
goto Exit;
if ( magic != 0x5F0F3CF5UL )
- {
FT_TRACE2(( "check_table_dir:"
- " no magic number found in `head' table\n"));
- error = SFNT_Err_Table_Missing;
- goto Exit;
- }
+ " invalid magic number in `head' or `bhed' table\n"));
if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) )
goto Exit;
@@ -266,14 +267,14 @@
if ( sfnt->num_tables == 0 )
{
FT_TRACE2(( "check_table_dir: no tables found\n" ));
- error = SFNT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/* if `sing' and `meta' tables are present, there is no `head' table */
if ( has_head || ( has_sing && has_meta ) )
{
- error = SFNT_Err_Ok;
+ error = FT_Err_Ok;
goto Exit;
}
else
@@ -284,7 +285,7 @@
#else
FT_TRACE2(( " neither `head' nor `sing' table found\n" ));
#endif
- error = SFNT_Err_Table_Missing;
+ error = FT_THROW( Table_Missing );
}
Exit:
@@ -352,7 +353,7 @@
#if 0
if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) ||
sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )
- return SFNT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
#endif
/* load the table directory */
@@ -360,14 +361,17 @@
FT_TRACE2(( "-- Number of tables: %10u\n", sfnt.num_tables ));
FT_TRACE2(( "-- Format version: 0x%08lx\n", sfnt.format_tag ));
- /* check first */
- error = check_table_dir( &sfnt, stream );
- if ( error )
+ if ( sfnt.format_tag != TTAG_OTTO )
{
- FT_TRACE2(( "tt_face_load_font_dir:"
- " invalid table directory for TrueType\n" ));
+ /* check first */
+ error = check_table_dir( &sfnt, stream );
+ if ( error )
+ {
+ FT_TRACE2(( "tt_face_load_font_dir:"
+ " invalid table directory for TrueType\n" ));
- goto Exit;
+ goto Exit;
+ }
}
face->num_tables = sfnt.num_tables;
@@ -382,25 +386,33 @@
entry = face->dir_tables;
+ FT_TRACE2(( "\n"
+ " tag offset length checksum\n"
+ " ----------------------------------\n" ));
+
for ( nn = 0; nn < sfnt.num_tables; nn++ )
{
entry->Tag = FT_GET_TAG4();
entry->CheckSum = FT_GET_ULONG();
- entry->Offset = FT_GET_LONG();
- entry->Length = FT_GET_LONG();
+ entry->Offset = FT_GET_ULONG();
+ entry->Length = FT_GET_ULONG();
/* ignore invalid tables */
- if ( entry->Offset + entry->Length > stream->size )
+
+ /* entry->Offset + entry->Length > stream->size ? */
+ if ( entry->Length > stream->size ||
+ entry->Offset > stream->size - entry->Length )
continue;
else
{
- FT_TRACE2(( " %c%c%c%c - %08lx - %08lx\n",
+ FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx\n",
(FT_Char)( entry->Tag >> 24 ),
(FT_Char)( entry->Tag >> 16 ),
(FT_Char)( entry->Tag >> 8 ),
(FT_Char)( entry->Tag ),
entry->Offset,
- entry->Length ));
+ entry->Length,
+ entry->CheckSum ));
entry++;
}
}
@@ -473,7 +485,7 @@
table = tt_face_lookup_table( face, tag );
if ( !table )
{
- error = SFNT_Err_Table_Missing;
+ error = FT_THROW( Table_Missing );
goto Exit;
}
@@ -488,7 +500,7 @@
{
*length = size;
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
if ( length )
@@ -617,7 +629,7 @@
FT_Error error;
TT_MaxProfile* maxProfile = &face->max_profile;
- const FT_Frame_Field maxp_fields[] =
+ static const FT_Frame_Field maxp_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_MaxProfile
@@ -628,7 +640,7 @@
FT_FRAME_END
};
- const FT_Frame_Field maxp_fields_extra[] =
+ static const FT_Frame_Field maxp_fields_extra[] =
{
FT_FRAME_START( 26 ),
FT_FRAME_USHORT( maxPoints ),
@@ -678,9 +690,9 @@
/* broken fonts like `Keystrokes MT' :-( */
/* */
/* We allocate 64 function entries by default when */
- /* the maxFunctionDefs field is null. */
+ /* the maxFunctionDefs value is smaller. */
- if ( maxProfile->maxFunctionDefs == 0 )
+ if ( maxProfile->maxFunctionDefs < 64 )
maxProfile->maxFunctionDefs = 64;
/* we add 4 phantom points later */
@@ -693,6 +705,15 @@
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 ));
@@ -705,7 +726,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* tt_face_load_names */
+ /* tt_face_load_name */
/* */
/* <Description> */
/* Loads the name records. */
@@ -783,7 +804,7 @@
if ( storage_start > storage_limit )
{
FT_ERROR(( "tt_face_load_name: invalid `name' table\n" ));
- error = SFNT_Err_Name_Table_Missing;
+ error = FT_THROW( Name_Table_Missing );
goto Exit;
}
@@ -936,7 +957,7 @@
FT_Error error;
TT_OS2* os2;
- const FT_Frame_Field os2_fields[] =
+ static const FT_Frame_Field os2_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_OS2
@@ -988,7 +1009,8 @@
FT_FRAME_END
};
- const FT_Frame_Field os2_fields_extra[] =
+ /* `OS/2' version 1 and newer */
+ static const FT_Frame_Field os2_fields_extra1[] =
{
FT_FRAME_START( 8 ),
FT_FRAME_ULONG( ulCodePageRange1 ),
@@ -996,7 +1018,8 @@
FT_FRAME_END
};
- const FT_Frame_Field os2_fields_extra2[] =
+ /* `OS/2' version 2 and newer */
+ static const FT_Frame_Field os2_fields_extra2[] =
{
FT_FRAME_START( 10 ),
FT_FRAME_SHORT ( sxHeight ),
@@ -1007,6 +1030,15 @@
FT_FRAME_END
};
+ /* `OS/2' version 5 and newer */
+ static const FT_Frame_Field os2_fields_extra5[] =
+ {
+ FT_FRAME_START( 4 ),
+ FT_FRAME_USHORT( usLowerOpticalPointSize ),
+ FT_FRAME_USHORT( usUpperOpticalPointSize ),
+ FT_FRAME_END
+ };
+
/* We now support old Mac fonts where the OS/2 table doesn't */
/* exist. Simply put, we set the `version' field to 0xFFFF */
@@ -1020,18 +1052,20 @@
if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) )
goto Exit;
- os2->ulCodePageRange1 = 0;
- os2->ulCodePageRange2 = 0;
- os2->sxHeight = 0;
- os2->sCapHeight = 0;
- os2->usDefaultChar = 0;
- os2->usBreakChar = 0;
- os2->usMaxContext = 0;
+ os2->ulCodePageRange1 = 0;
+ os2->ulCodePageRange2 = 0;
+ os2->sxHeight = 0;
+ os2->sCapHeight = 0;
+ os2->usDefaultChar = 0;
+ os2->usBreakChar = 0;
+ os2->usMaxContext = 0;
+ os2->usLowerOpticalPointSize = 0;
+ os2->usUpperOpticalPointSize = 0xFFFF;
if ( os2->version >= 0x0001 )
{
/* only version 1 tables */
- if ( FT_STREAM_READ_FIELDS( os2_fields_extra, os2 ) )
+ if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) )
goto Exit;
if ( os2->version >= 0x0002 )
@@ -1039,6 +1073,13 @@
/* only version 2 tables */
if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) )
goto Exit;
+
+ if ( os2->version >= 0x0005 )
+ {
+ /* only version 5 tables */
+ if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) )
+ goto Exit;
+ }
}
}
@@ -1109,7 +1150,7 @@
FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch
? " yes" : " no" ));
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -1146,6 +1187,7 @@
FT_FRAME_USHORT( Style ),
FT_FRAME_USHORT( TypeFamily ),
FT_FRAME_USHORT( CapHeight ),
+ FT_FRAME_USHORT( SymbolSet ),
FT_FRAME_BYTES ( TypeFace, 16 ),
FT_FRAME_BYTES ( CharacterComplement, 8 ),
FT_FRAME_BYTES ( FileName, 6 ),
@@ -1197,7 +1239,7 @@
FT_Memory memory = stream->memory;
FT_UInt j,num_ranges;
- TT_GaspRange gaspranges;
+ TT_GaspRange gaspranges = NULL;
/* the gasp table is optional */
@@ -1217,18 +1259,18 @@
if ( face->gasp.version >= 2 )
{
face->gasp.numRanges = 0;
- error = SFNT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
num_ranges = face->gasp.numRanges;
FT_TRACE3(( "numRanges: %u\n", num_ranges ));
- if ( FT_QNEW_ARRAY( gaspranges, num_ranges ) ||
- FT_FRAME_ENTER( num_ranges * 4L ) )
+ if ( FT_QNEW_ARRAY( face->gasp.gaspRanges, num_ranges ) ||
+ FT_FRAME_ENTER( num_ranges * 4L ) )
goto Exit;
- face->gasp.gaspRanges = gaspranges;
+ gaspranges = face->gasp.gaspRanges;
for ( j = 0; j < num_ranges; j++ )
{
diff --git a/src/3rdparty/freetype/src/sfnt/ttmtx.c b/src/3rdparty/freetype/src/sfnt/ttmtx.c
index 53e6ac7881..bb319577e2 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, 2007, 2008, 2009 by */
+/* Copyright 2006-2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -35,13 +35,6 @@
#define FT_COMPONENT trace_ttmtx
- /*
- * Unfortunately, we can't enable our memory optimizations if
- * FT_CONFIG_OPTION_OLD_INTERNALS is defined. This is because at least
- * one rogue client (libXfont in the X.Org XServer) is directly accessing
- * the metrics.
- */
-
/*************************************************************************/
/* */
/* <Function> */
@@ -60,8 +53,6 @@
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
-#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
-
FT_LOCAL_DEF( FT_Error )
tt_face_load_hmtx( TT_Face face,
FT_Stream stream,
@@ -97,142 +88,6 @@
return error;
}
-#else /* !FT_CONFIG_OPTION_OLD_INTERNALS */
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_hmtx( TT_Face face,
- FT_Stream stream,
- FT_Bool vertical )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
-
- FT_ULong table_len;
- FT_Long num_shorts, num_longs, num_shorts_checked;
-
- TT_LongMetrics* longs;
- TT_ShortMetrics** shorts;
- FT_Byte* p;
-
-
- if ( vertical )
- {
- void* lm = &face->vertical.long_metrics;
- void** sm = &face->vertical.short_metrics;
-
-
- error = face->goto_table( face, TTAG_vmtx, stream, &table_len );
- if ( error )
- goto Fail;
-
- num_longs = face->vertical.number_Of_VMetrics;
- if ( (FT_ULong)num_longs > table_len / 4 )
- num_longs = (FT_Long)( table_len / 4 );
-
- face->vertical.number_Of_VMetrics = 0;
-
- longs = (TT_LongMetrics*)lm;
- shorts = (TT_ShortMetrics**)sm;
- }
- else
- {
- void* lm = &face->horizontal.long_metrics;
- void** sm = &face->horizontal.short_metrics;
-
-
- error = face->goto_table( face, TTAG_hmtx, stream, &table_len );
- if ( error )
- goto Fail;
-
- num_longs = face->horizontal.number_Of_HMetrics;
- if ( (FT_ULong)num_longs > table_len / 4 )
- num_longs = (FT_Long)( table_len / 4 );
-
- face->horizontal.number_Of_HMetrics = 0;
-
- longs = (TT_LongMetrics*)lm;
- shorts = (TT_ShortMetrics**)sm;
- }
-
- /* never trust derived values */
-
- num_shorts = face->max_profile.numGlyphs - num_longs;
- num_shorts_checked = ( table_len - num_longs * 4L ) / 2;
-
- if ( num_shorts < 0 )
- {
- FT_TRACE0(( "tt_face_load_hmtx:"
- " %cmtx has more metrics than glyphs.\n",
- vertical ? "v" : "h" ));
-
- /* Adobe simply ignores this problem. So we shall do the same. */
-#if 0
- error = vertical ? SFNT_Err_Invalid_Vert_Metrics
- : SFNT_Err_Invalid_Horiz_Metrics;
- goto Exit;
-#else
- num_shorts = 0;
-#endif
- }
-
- if ( FT_QNEW_ARRAY( *longs, num_longs ) ||
- FT_QNEW_ARRAY( *shorts, num_shorts ) )
- goto Fail;
-
- if ( FT_FRAME_ENTER( table_len ) )
- goto Fail;
-
- p = stream->cursor;
-
- {
- TT_LongMetrics cur = *longs;
- TT_LongMetrics limit = cur + num_longs;
-
-
- for ( ; cur < limit; cur++ )
- {
- cur->advance = FT_NEXT_USHORT( p );
- cur->bearing = FT_NEXT_SHORT( p );
- }
- }
-
- /* do we have an inconsistent number of metric values? */
- {
- TT_ShortMetrics* cur = *shorts;
- TT_ShortMetrics* limit = cur +
- FT_MIN( num_shorts, num_shorts_checked );
-
-
- for ( ; cur < limit; cur++ )
- *cur = FT_NEXT_SHORT( p );
-
- /* We fill up the missing left side bearings with the */
- /* last valid value. Since this will occur for buggy CJK */
- /* fonts usually only, nothing serious will happen. */
- if ( num_shorts > num_shorts_checked && num_shorts_checked > 0 )
- {
- FT_Short val = (*shorts)[num_shorts_checked - 1];
-
-
- limit = *shorts + num_shorts;
- for ( ; cur < limit; cur++ )
- *cur = val;
- }
- }
-
- FT_FRAME_EXIT();
-
- if ( vertical )
- face->vertical.number_Of_VMetrics = (FT_UShort)num_longs;
- else
- face->horizontal.number_Of_HMetrics = (FT_UShort)num_longs;
-
- Fail:
- return error;
- }
-
-#endif /* !FT_CONFIG_OPTION_OLD_INTERNALS */
-
/*************************************************************************/
/* */
@@ -260,7 +115,7 @@
FT_Error error;
TT_HoriHeader* header;
- const FT_Frame_Field metrics_header_fields[] =
+ static const FT_Frame_Field metrics_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_HoriHeader
@@ -328,24 +183,25 @@
/* tt_face_get_metrics */
/* */
/* <Description> */
- /* Returns the horizontal or vertical metrics in font units for a */
- /* given glyph. The metrics are the left side bearing (resp. top */
- /* side bearing) and advance width (resp. advance height). */
+ /* Return the horizontal or vertical metrics in font units for a */
+ /* given glyph. The values are the left side bearing (top side */
+ /* bearing for vertical metrics) and advance width (advance height */
+ /* for vertical metrics). */
/* */
/* <Input> */
- /* header :: A pointer to either the horizontal or vertical metrics */
- /* structure. */
+ /* face :: A pointer to the TrueType face structure. */
+ /* */
+ /* vertical :: If set to TRUE, get vertical metrics. */
/* */
- /* idx :: The glyph index. */
+ /* gindex :: The glyph index. */
/* */
/* <Output> */
- /* bearing :: The bearing, either left side or top side. */
+ /* abearing :: The bearing, either left side or top side. */
/* */
- /* advance :: The advance width resp. advance height. */
+ /* aadvance :: The advance width or advance height, depending on */
+ /* the `vertical' flag. */
/* */
-#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
tt_face_get_metrics( TT_Face face,
FT_Bool vertical,
FT_UInt gindex,
@@ -418,51 +274,7 @@
*abearing = 0;
*aadvance = 0;
}
-
- return SFNT_Err_Ok;
}
-#else /* !FT_CONFIG_OPTION_OLD_INTERNALS */
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_get_metrics( TT_Face face,
- FT_Bool vertical,
- FT_UInt gindex,
- FT_Short* abearing,
- FT_UShort* aadvance )
- {
- void* v = &face->vertical;
- void* h = &face->horizontal;
- TT_HoriHeader* header = vertical ? (TT_HoriHeader*)v
- : (TT_HoriHeader*)h;
- TT_LongMetrics longs_m;
- FT_UShort k = header->number_Of_HMetrics;
-
-
- if ( k == 0 ||
- !header->long_metrics ||
- gindex >= (FT_UInt)face->max_profile.numGlyphs )
- {
- *abearing = *aadvance = 0;
- return SFNT_Err_Ok;
- }
-
- if ( gindex < (FT_UInt)k )
- {
- longs_m = (TT_LongMetrics)header->long_metrics + gindex;
- *abearing = longs_m->bearing;
- *aadvance = longs_m->advance;
- }
- else
- {
- *abearing = ((TT_ShortMetrics*)header->short_metrics)[gindex - k];
- *aadvance = ((TT_LongMetrics)header->long_metrics)[k - 1].advance;
- }
-
- return SFNT_Err_Ok;
- }
-
-#endif /* !FT_CONFIG_OPTION_OLD_INTERNALS */
-
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttmtx.h b/src/3rdparty/freetype/src/sfnt/ttmtx.h
index 8b91a113d8..fb040394c0 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 by */
+/* Copyright 2006, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
FT_Bool vertical );
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
tt_face_get_metrics( TT_Face face,
FT_Bool vertical,
FT_UInt gindex,
diff --git a/src/3rdparty/freetype/src/sfnt/ttpost.c b/src/3rdparty/freetype/src/sfnt/ttpost.c
index aa0bf1ec41..99d800549f 100644
--- a/src/3rdparty/freetype/src/sfnt/ttpost.c
+++ b/src/3rdparty/freetype/src/sfnt/ttpost.c
@@ -5,7 +5,7 @@
/* Postcript name table processing for TrueType and OpenType fonts */
/* (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2003, 2006-2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,6 +26,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include "ttpost.h"
@@ -63,12 +64,12 @@
#define MAC_NAME( x ) ( (FT_String*)tt_post_default_names[x] )
- /* the 258 default Mac PS glyph names */
+ /* the 258 default Mac PS glyph names; see file `tools/glnames.py' */
static const FT_String* const tt_post_default_names[258] =
{
/* 0 */
- ".notdef", ".null", "CR", "space", "exclam",
+ ".notdef", ".null", "nonmarkingreturn", "space", "exclam",
"quotedbl", "numbersign", "dollar", "percent", "ampersand",
/* 10 */
"quotesingle", "parenleft", "parenright", "asterisk", "plus",
@@ -119,7 +120,7 @@
"ae", "oslash", "questiondown", "exclamdown", "logicalnot",
"radical", "florin", "approxequal", "Delta", "guillemotleft",
/* 170 */
- "guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde",
+ "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde",
"Otilde", "OE", "oe", "endash", "emdash",
/* 180 */
"quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide",
@@ -143,8 +144,8 @@
"multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf",
"onequarter", "threequarters", "franc", "Gbreve", "gbreve",
/* 250 */
- "Idot", "Scedilla", "scedilla", "Cacute", "cacute",
- "Ccaron", "ccaron", "dmacron",
+ "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute",
+ "Ccaron", "ccaron", "dcroat",
};
@@ -153,7 +154,8 @@
static FT_Error
load_format_20( TT_Face face,
- FT_Stream stream )
+ FT_Stream stream,
+ FT_Long post_limit )
{
FT_Memory memory = stream->memory;
FT_Error error;
@@ -176,7 +178,7 @@
if ( num_glyphs > face->max_profile.numGlyphs )
{
- error = SFNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -230,13 +232,46 @@
FT_UInt len;
- if ( FT_READ_BYTE ( len ) ||
- FT_NEW_ARRAY( name_strings[n], len + 1 ) ||
- FT_STREAM_READ ( name_strings[n], len ) )
+ if ( FT_STREAM_POS() >= post_limit )
+ break;
+ else
+ {
+ FT_TRACE6(( "load_format_20: %d byte left in post table\n",
+ post_limit - FT_STREAM_POS() ));
+
+ if ( FT_READ_BYTE( len ) )
+ goto Fail1;
+ }
+
+ if ( (FT_Int)len > post_limit ||
+ FT_STREAM_POS() > post_limit - (FT_Int)len )
+ {
+ FT_ERROR(( "load_format_20:"
+ " exceeding string length (%d),"
+ " truncating at end of post table (%d byte left)\n",
+ len, post_limit - FT_STREAM_POS() ));
+ len = FT_MAX( 0, post_limit - FT_STREAM_POS() );
+ }
+
+ if ( FT_NEW_ARRAY( name_strings[n], len + 1 ) ||
+ FT_STREAM_READ( name_strings[n], len ) )
goto Fail1;
name_strings[n][len] = '\0';
}
+
+ if ( n < num_names )
+ {
+ FT_ERROR(( "load_format_20:"
+ " all entries in post table are already parsed,"
+ " using NULL names for gid %d - %d\n",
+ n, num_names - 1 ));
+ for ( ; n < num_names; n++ )
+ if ( FT_NEW_ARRAY( name_strings[n], 1 ) )
+ goto Fail1;
+ else
+ name_strings[n][0] = '\0';
+ }
}
/* all right, set table fields and exit successfully */
@@ -249,7 +284,7 @@
table->glyph_indices = glyph_indices;
table->glyph_names = name_strings;
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
Fail1:
{
@@ -271,7 +306,8 @@
static FT_Error
load_format_25( TT_Face face,
- FT_Stream stream )
+ FT_Stream stream,
+ FT_Long post_limit )
{
FT_Memory memory = stream->memory;
FT_Error error;
@@ -279,6 +315,8 @@
FT_Int num_glyphs;
FT_Char* offset_table = 0;
+ FT_UNUSED( post_limit );
+
/* UNDOCUMENTED! This value appears only in the Apple TT specs. */
if ( FT_READ_USHORT( num_glyphs ) )
@@ -287,7 +325,7 @@
/* check the number of glyphs */
if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 )
{
- error = SFNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -307,7 +345,7 @@
if ( idx < 0 || idx > num_glyphs )
{
- error = SFNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
}
@@ -322,7 +360,7 @@
table->offsets = offset_table;
}
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
Fail:
FT_FREE( offset_table );
@@ -338,16 +376,20 @@
FT_Stream stream;
FT_Error error;
FT_Fixed format;
+ FT_ULong post_len;
+ FT_Long post_limit;
/* get a stream for the face's resource */
stream = face->root.stream;
/* seek to the beginning of the PS names table */
- error = face->goto_table( face, TTAG_post, stream, 0 );
+ error = face->goto_table( face, TTAG_post, stream, &post_len );
if ( error )
goto Exit;
+ post_limit = FT_STREAM_POS() + post_len;
+
format = face->postscript.FormatType;
/* go to beginning of subtable */
@@ -356,11 +398,11 @@
/* now read postscript table */
if ( format == 0x00020000L )
- error = load_format_20( face, stream );
+ error = load_format_20( face, stream, post_limit );
else if ( format == 0x00028000L )
- error = load_format_25( face, stream );
+ error = load_format_25( face, stream, post_limit );
else
- error = SFNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
face->postscript_names.loaded = 1;
@@ -446,15 +488,15 @@
if ( !face )
- return SFNT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( idx >= (FT_UInt)face->max_profile.numGlyphs )
- return SFNT_Err_Invalid_Glyph_Index;
+ return FT_THROW( Invalid_Glyph_Index );
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
psnames = (FT_Service_PsCMaps)face->psnames;
if ( !psnames )
- return SFNT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
#endif
names = &face->postscript_names;
@@ -514,7 +556,7 @@
/* nothing to do for format == 0x00030000L */
End:
- return SFNT_Err_Ok;
+ return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/sfnt/ttsbit.c b/src/3rdparty/freetype/src/sfnt/ttsbit.c
index 833bb2add2..c2db96c6d8 100644
--- a/src/3rdparty/freetype/src/sfnt/ttsbit.c
+++ b/src/3rdparty/freetype/src/sfnt/ttsbit.c
@@ -4,9 +4,12 @@
/* */
/* TrueType and OpenType embedded bitmap support (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2005-2009, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
+/* Copyright 2013 by Google, Inc. */
+/* Google Author(s): Behdad Esfahbod. */
+/* */
/* 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 */
@@ -15,29 +18,19 @@
/* */
/***************************************************************************/
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_TRUETYPE_TAGS_H
-
- /*
- * Alas, the memory-optimized sbit loader can't be used when implementing
- * the `old internals' hack
- */
-#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
-
-#include "ttsbit0.c"
-
-#else /* FT_CONFIG_OPTION_OLD_INTERNALS */
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
+#include FT_BITMAP_H
#include "ttsbit.h"
#include "sferrors.h"
+#include "ttmtx.h"
+#include "pngshim.h"
+
/*************************************************************************/
/* */
@@ -49,1398 +42,1352 @@
#define FT_COMPONENT trace_ttsbit
- /*************************************************************************/
- /* */
- /* <Function> */
- /* blit_sbit */
- /* */
- /* <Description> */
- /* Blits a bitmap from an input stream into a given target. Supports */
- /* x and y offsets as well as byte padded lines. */
- /* */
- /* <Input> */
- /* target :: The target bitmap/pixmap. */
- /* */
- /* source :: The input packed bitmap data. */
- /* */
- /* line_bits :: The number of bits per line. */
- /* */
- /* byte_padded :: A flag which is true if lines are byte-padded. */
- /* */
- /* x_offset :: The horizontal offset. */
- /* */
- /* y_offset :: The vertical offset. */
- /* */
- /* <Note> */
- /* IMPORTANT: The x and y offsets are relative to the top corner of */
- /* the target bitmap (unlike the normal TrueType */
- /* convention). A positive y offset indicates a downwards */
- /* direction! */
- /* */
- static void
- blit_sbit( FT_Bitmap* target,
- FT_Byte* source,
- FT_Int line_bits,
- FT_Bool byte_padded,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Int source_height )
+ FT_LOCAL_DEF( FT_Error )
+ tt_face_load_sbit( TT_Face face,
+ FT_Stream stream )
{
- FT_Byte* line_buff;
- FT_Int line_incr;
- FT_Int height;
+ FT_Error error;
+ FT_ULong table_size;
+
- FT_UShort acc;
- FT_UInt loaded;
+ face->sbit_table = NULL;
+ face->sbit_table_size = 0;
+ face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
+ face->sbit_num_strikes = 0;
+
+ error = face->goto_table( face, TTAG_CBLC, stream, &table_size );
+ if ( !error )
+ face->sbit_table_type = TT_SBIT_TABLE_TYPE_CBLC;
+ else
+ {
+ error = face->goto_table( face, TTAG_EBLC, stream, &table_size );
+ if ( error )
+ error = face->goto_table( face, TTAG_bloc, stream, &table_size );
+ if ( !error )
+ face->sbit_table_type = TT_SBIT_TABLE_TYPE_EBLC;
+ }
+
+ if ( error )
+ {
+ error = face->goto_table( face, TTAG_sbix, stream, &table_size );
+ if ( !error )
+ face->sbit_table_type = TT_SBIT_TABLE_TYPE_SBIX;
+ }
+ if ( error )
+ goto Exit;
+ if ( table_size < 8 )
+ {
+ FT_ERROR(( "tt_face_load_sbit_strikes: table too short\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
- /* first of all, compute starting write position */
- line_incr = target->pitch;
- line_buff = target->buffer;
+ switch ( (FT_UInt)face->sbit_table_type )
+ {
+ case TT_SBIT_TABLE_TYPE_EBLC:
+ case TT_SBIT_TABLE_TYPE_CBLC:
+ {
+ FT_Byte* p;
+ FT_Fixed version;
+ FT_ULong num_strikes;
+ FT_UInt count;
- if ( line_incr < 0 )
- line_buff -= line_incr * ( target->rows - 1 );
- line_buff += ( x_offset >> 3 ) + y_offset * line_incr;
+ if ( FT_FRAME_EXTRACT( table_size, face->sbit_table ) )
+ goto Exit;
- /***********************************************************************/
- /* */
- /* We use the extra-classic `accumulator' trick to extract the bits */
- /* from the source byte stream. */
- /* */
- /* Namely, the variable `acc' is a 16-bit accumulator containing the */
- /* last `loaded' bits from the input stream. The bits are shifted to */
- /* the upmost position in `acc'. */
- /* */
- /***********************************************************************/
+ face->sbit_table_size = table_size;
- acc = 0; /* clear accumulator */
- loaded = 0; /* no bits were loaded */
+ p = face->sbit_table;
- for ( height = source_height; height > 0; height-- )
- {
- FT_Byte* cur = line_buff; /* current write cursor */
- FT_Int count = line_bits; /* # of bits to extract per line */
- FT_Byte shift = (FT_Byte)( x_offset & 7 ); /* current write shift */
- FT_Byte space = (FT_Byte)( 8 - shift );
+ version = FT_NEXT_ULONG( p );
+ num_strikes = FT_NEXT_ULONG( p );
+ if ( ( version & 0xFFFF0000UL ) != 0x00020000UL )
+ {
+ error = FT_THROW( Unknown_File_Format );
+ goto Exit;
+ }
- /* first of all, read individual source bytes */
- if ( count >= 8 )
- {
- count -= 8;
+ if ( num_strikes >= 0x10000UL )
{
- do
- {
- FT_Byte val;
-
-
- /* ensure that there are at least 8 bits in the accumulator */
- if ( loaded < 8 )
- {
- acc |= (FT_UShort)((FT_UShort)*source++ << ( 8 - loaded ));
- loaded += 8;
- }
-
- /* now write one byte */
- val = (FT_Byte)( acc >> 8 );
- if ( shift )
- {
- cur[0] |= (FT_Byte)( val >> shift );
- cur[1] |= (FT_Byte)( val << space );
- }
- else
- cur[0] |= val;
-
- cur++;
- acc <<= 8; /* remove bits from accumulator */
- loaded -= 8;
- count -= 8;
-
- } while ( count >= 0 );
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
}
- /* restore `count' to correct value */
- count += 8;
+ /*
+ * Count the number of strikes available in the table. We are a bit
+ * paranoid there and don't trust the data.
+ */
+ count = (FT_UInt)num_strikes;
+ if ( 8 + 48UL * count > table_size )
+ count = (FT_UInt)( ( table_size - 8 ) / 48 );
+
+ face->sbit_num_strikes = count;
}
+ break;
- /* now write remaining bits (count < 8) */
- if ( count > 0 )
+ case TT_SBIT_TABLE_TYPE_SBIX:
{
- FT_Byte val;
+ FT_UShort version;
+ FT_UShort flags;
+ FT_ULong num_strikes;
+ FT_UInt count;
+
+
+ if ( FT_FRAME_ENTER( 8 ) )
+ goto Exit;
+ version = FT_GET_USHORT();
+ flags = FT_GET_USHORT();
+ num_strikes = FT_GET_ULONG();
- /* ensure that there are at least `count' bits in the accumulator */
- if ( (FT_Int)loaded < count )
+ FT_FRAME_EXIT();
+
+ if ( version < 1 )
{
- acc |= (FT_UShort)((FT_UShort)*source++ << ( 8 - loaded ));
- loaded += 8;
+ error = FT_THROW( Unknown_File_Format );
+ goto Exit;
}
- /* now write remaining bits */
- val = (FT_Byte)( ( (FT_Byte)( acc >> 8 ) ) & ~( 0xFF >> count ) );
- cur[0] |= (FT_Byte)( val >> shift );
+ /* Bit 0 must always be `1'. */
+ /* Bit 1 controls the overlay of bitmaps with outlines. */
+ /* All other bits should be zero. */
+ if ( !( flags == 1 || flags == 3 ) ||
+ num_strikes >= 0x10000UL )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
- if ( count > space )
- cur[1] |= (FT_Byte)( val << space );
+ /* we currently don't support bit 1; however, it is better to */
+ /* draw at least something... */
+ if ( flags == 3 )
+ FT_TRACE1(( "tt_face_load_sbit_strikes:"
+ " sbix overlay not supported yet\n"
+ " "
+ " expect bad rendering results\n" ));
+
+ /*
+ * Count the number of strikes available in the table. We are a bit
+ * paranoid there and don't trust the data.
+ */
+ count = (FT_UInt)num_strikes;
+ if ( 8 + 4UL * count > table_size )
+ count = (FT_UInt)( ( table_size - 8 ) / 4 );
+
+ if ( FT_STREAM_SEEK( FT_STREAM_POS() - 8 ) )
+ goto Exit;
- acc <<= count;
- loaded -= count;
- }
+ face->sbit_table_size = 8 + count * 4;
+ if ( FT_FRAME_EXTRACT( face->sbit_table_size, face->sbit_table ) )
+ goto Exit;
- /* now, skip to next line */
- if ( byte_padded )
- {
- acc = 0;
- loaded = 0; /* clear accumulator on byte-padded lines */
+ face->sbit_num_strikes = count;
}
+ break;
+
+ default:
+ error = FT_THROW( Unknown_File_Format );
+ break;
+ }
- line_buff += line_incr;
+ if ( !error )
+ FT_TRACE3(( "sbit_num_strikes: %u\n", face->sbit_num_strikes ));
+
+ return FT_Err_Ok;
+
+ Exit:
+ if ( error )
+ {
+ if ( face->sbit_table )
+ FT_FRAME_RELEASE( face->sbit_table );
+ face->sbit_table_size = 0;
+ face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
}
+
+ return error;
}
- static const FT_Frame_Field sbit_metrics_fields[] =
+ FT_LOCAL_DEF( void )
+ tt_face_free_sbit( TT_Face face )
{
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_SBit_MetricsRec
+ FT_Stream stream = face->root.stream;
- FT_FRAME_START( 8 ),
- FT_FRAME_BYTE( height ),
- FT_FRAME_BYTE( width ),
- FT_FRAME_CHAR( horiBearingX ),
- FT_FRAME_CHAR( horiBearingY ),
- FT_FRAME_BYTE( horiAdvance ),
+ FT_FRAME_RELEASE( face->sbit_table );
+ face->sbit_table_size = 0;
+ face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
+ face->sbit_num_strikes = 0;
+ }
- FT_FRAME_CHAR( vertBearingX ),
- FT_FRAME_CHAR( vertBearingY ),
- FT_FRAME_BYTE( vertAdvance ),
- FT_FRAME_END
- };
+ FT_LOCAL_DEF( FT_Error )
+ tt_face_set_sbit_strike( TT_Face face,
+ FT_Size_Request req,
+ FT_ULong* astrike_index )
+ {
+ return FT_Match_Size( (FT_Face)face, req, 0, astrike_index );
+ }
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Load_SBit_Const_Metrics */
- /* */
- /* <Description> */
- /* Loads the metrics for `EBLC' index tables format 2 and 5. */
- /* */
- /* <Input> */
- /* range :: The target range. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static FT_Error
- Load_SBit_Const_Metrics( TT_SBit_Range range,
- FT_Stream stream )
+
+ FT_LOCAL_DEF( FT_Error )
+ tt_face_load_strike_metrics( TT_Face face,
+ FT_ULong strike_index,
+ FT_Size_Metrics* metrics )
{
- FT_Error error;
+ if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
+ return FT_THROW( Invalid_Argument );
+ switch ( (FT_UInt)face->sbit_table_type )
+ {
+ case TT_SBIT_TABLE_TYPE_EBLC:
+ case TT_SBIT_TABLE_TYPE_CBLC:
+ {
+ FT_Byte* strike;
+
+
+ strike = face->sbit_table + 8 + strike_index * 48;
+
+ metrics->x_ppem = (FT_UShort)strike[44];
+ metrics->y_ppem = (FT_UShort)strike[45];
+
+ metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */
+ metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */
+ metrics->height = metrics->ascender - metrics->descender;
+
+ /* Is this correct? */
+ metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */
+ strike[18] + /* max_width */
+ (FT_Char)strike[23] /* min_advance_SB */
+ ) << 6;
+ return FT_Err_Ok;
+ }
+
+ case TT_SBIT_TABLE_TYPE_SBIX:
+ {
+ FT_Stream stream = face->root.stream;
+ FT_UInt offset, upem;
+ FT_UShort ppem, resolution;
+ TT_HoriHeader *hori;
+ FT_ULong table_size;
+
+ FT_Error error;
+ FT_Byte* p;
- if ( FT_READ_ULONG( range->image_size ) )
- return error;
- return FT_STREAM_READ_FIELDS( sbit_metrics_fields, &range->metrics );
+ 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 )
+ return FT_THROW( Invalid_File_Format );
+
+ if ( FT_STREAM_SEEK( FT_STREAM_POS() + offset ) ||
+ FT_FRAME_ENTER( 4 ) )
+ return error;
+
+ ppem = FT_GET_USHORT();
+ resolution = FT_GET_USHORT();
+
+ FT_UNUSED( resolution ); /* What to do with this? */
+
+ FT_FRAME_EXIT();
+
+ upem = face->header.Units_Per_EM;
+ hori = &face->horizontal;
+
+ metrics->x_ppem = ppem;
+ metrics->y_ppem = ppem;
+
+ 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;
+
+ return error;
+ }
+
+ default:
+ return FT_THROW( Unknown_File_Format );
+ }
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Load_SBit_Range_Codes */
- /* */
- /* <Description> */
- /* Loads the range codes for `EBLC' index tables format 4 and 5. */
- /* */
- /* <Input> */
- /* range :: The target range. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* load_offsets :: A flag whether to load the glyph offset table. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ typedef struct TT_SBitDecoderRec_
+ {
+ TT_Face face;
+ FT_Stream stream;
+ FT_Bitmap* bitmap;
+ TT_SBit_Metrics metrics;
+ FT_Bool metrics_loaded;
+ FT_Bool bitmap_allocated;
+ FT_Byte bit_depth;
+
+ FT_ULong ebdt_start;
+ FT_ULong ebdt_size;
+
+ FT_ULong strike_index_array;
+ FT_ULong strike_index_count;
+ FT_Byte* eblc_base;
+ FT_Byte* eblc_limit;
+
+ } TT_SBitDecoderRec, *TT_SBitDecoder;
+
+
static FT_Error
- Load_SBit_Range_Codes( TT_SBit_Range range,
- FT_Stream stream,
- FT_Bool load_offsets )
+ tt_sbit_decoder_init( TT_SBitDecoder decoder,
+ TT_Face face,
+ FT_ULong strike_index,
+ TT_SBit_MetricsRec* metrics )
{
FT_Error error;
- FT_ULong count, n, size;
- FT_Memory memory = stream->memory;
+ FT_Stream stream = face->root.stream;
+ FT_ULong ebdt_size;
- if ( FT_READ_ULONG( count ) )
+ 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 )
goto Exit;
- range->num_glyphs = count;
+ decoder->face = face;
+ decoder->stream = stream;
+ decoder->bitmap = &face->root.glyph->bitmap;
+ decoder->metrics = metrics;
- /* Allocate glyph offsets table if needed */
- if ( load_offsets )
- {
- if ( FT_NEW_ARRAY( range->glyph_offsets, count ) )
- goto Exit;
+ decoder->metrics_loaded = 0;
+ decoder->bitmap_allocated = 0;
- size = count * 4L;
- }
- else
- size = count * 2L;
+ decoder->ebdt_start = FT_STREAM_POS();
+ decoder->ebdt_size = ebdt_size;
- /* Allocate glyph codes table and access frame */
- if ( FT_NEW_ARRAY ( range->glyph_codes, count ) ||
- FT_FRAME_ENTER( size ) )
- goto Exit;
+ decoder->eblc_base = face->sbit_table;
+ decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
- for ( n = 0; n < count; n++ )
+ /* now find the strike corresponding to the index */
{
- range->glyph_codes[n] = FT_GET_USHORT();
+ FT_Byte* p;
- if ( load_offsets )
- range->glyph_offsets[n] = (FT_ULong)range->image_offset +
- FT_GET_USHORT();
- }
- FT_FRAME_EXIT();
+ if ( 8 + 48 * strike_index + 3 * 4 + 34 + 1 > face->sbit_table_size )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ p = decoder->eblc_base + 8 + 48 * strike_index;
+
+ decoder->strike_index_array = FT_NEXT_ULONG( p );
+ p += 4;
+ decoder->strike_index_count = FT_NEXT_ULONG( p );
+ p += 34;
+ decoder->bit_depth = *p;
+
+ /* decoder->strike_index_array + */
+ /* 8 * decoder->strike_index_count > face->sbit_table_size ? */
+ if ( decoder->strike_index_array > face->sbit_table_size ||
+ decoder->strike_index_count >
+ ( face->sbit_table_size - decoder->strike_index_array ) / 8 )
+ error = FT_THROW( Invalid_File_Format );
+ }
Exit:
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Load_SBit_Range */
- /* */
- /* <Description> */
- /* Loads a given `EBLC' index/range table. */
- /* */
- /* <Input> */
- /* range :: The target range. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static FT_Error
- Load_SBit_Range( TT_SBit_Range range,
- FT_Stream stream )
+ static void
+ tt_sbit_decoder_done( TT_SBitDecoder decoder )
{
- FT_Error error;
- FT_Memory memory = stream->memory;
-
-
- switch( range->index_format )
- {
- case 1: /* variable metrics with 4-byte offsets */
- case 3: /* variable metrics with 2-byte offsets */
- {
- FT_ULong num_glyphs, n;
- FT_Int size_elem;
- FT_Bool large = FT_BOOL( range->index_format == 1 );
+ FT_UNUSED( decoder );
+ }
+ static FT_Error
+ tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder )
+ {
+ FT_Error error = FT_Err_Ok;
+ FT_UInt width, height;
+ FT_Bitmap* map = decoder->bitmap;
+ FT_Long size;
- if ( range->last_glyph < range->first_glyph )
- {
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
- num_glyphs = range->last_glyph - range->first_glyph + 1L;
- range->num_glyphs = num_glyphs;
- num_glyphs++; /* XXX: BEWARE - see spec */
+ if ( !decoder->metrics_loaded )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
- size_elem = large ? 4 : 2;
+ width = decoder->metrics->width;
+ height = decoder->metrics->height;
- if ( FT_NEW_ARRAY( range->glyph_offsets, num_glyphs ) ||
- FT_FRAME_ENTER( num_glyphs * size_elem ) )
- goto Exit;
+ map->width = (int)width;
+ map->rows = (int)height;
- for ( n = 0; n < num_glyphs; n++ )
- range->glyph_offsets[n] = (FT_ULong)( range->image_offset +
- ( large ? FT_GET_ULONG()
- : FT_GET_USHORT() ) );
- FT_FRAME_EXIT();
- }
+ switch ( decoder->bit_depth )
+ {
+ case 1:
+ map->pixel_mode = FT_PIXEL_MODE_MONO;
+ map->pitch = ( map->width + 7 ) >> 3;
+ map->num_grays = 2;
break;
- case 2: /* all glyphs have identical metrics */
- error = Load_SBit_Const_Metrics( range, stream );
+ case 2:
+ map->pixel_mode = FT_PIXEL_MODE_GRAY2;
+ map->pitch = ( map->width + 3 ) >> 2;
+ map->num_grays = 4;
break;
case 4:
- error = Load_SBit_Range_Codes( range, stream, 1 );
+ map->pixel_mode = FT_PIXEL_MODE_GRAY4;
+ map->pitch = ( map->width + 1 ) >> 1;
+ map->num_grays = 16;
break;
- case 5:
- error = Load_SBit_Const_Metrics( range, stream );
- if ( !error )
- error = Load_SBit_Range_Codes( range, stream, 0 );
+ case 8:
+ map->pixel_mode = FT_PIXEL_MODE_GRAY;
+ map->pitch = map->width;
+ map->num_grays = 256;
+ break;
+
+ case 32:
+ map->pixel_mode = FT_PIXEL_MODE_BGRA;
+ map->pitch = map->width * 4;
+ map->num_grays = 256;
break;
default:
- error = SFNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
}
+ size = map->rows * map->pitch;
+
+ /* check that there is no empty image */
+ if ( size == 0 )
+ goto Exit; /* exit successfully! */
+
+ error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size );
+ if ( error )
+ goto Exit;
+
+ decoder->bitmap_allocated = 1;
+
Exit:
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_eblc */
- /* */
- /* <Description> */
- /* Loads the table of embedded bitmap sizes for this face. */
- /* */
- /* <Input> */
- /* face :: The target face object. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_eblc( TT_Face face,
- FT_Stream stream )
+ static FT_Error
+ tt_sbit_decoder_load_metrics( TT_SBitDecoder decoder,
+ FT_Byte* *pp,
+ FT_Byte* limit,
+ FT_Bool big )
{
- FT_Error error = 0;
- FT_Memory memory = stream->memory;
- FT_Fixed version;
- FT_ULong num_strikes;
- FT_ULong table_base;
+ FT_Byte* p = *pp;
+ TT_SBit_Metrics metrics = decoder->metrics;
- static const FT_Frame_Field sbit_line_metrics_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_SBit_LineMetricsRec
-
- /* no FT_FRAME_START */
- FT_FRAME_CHAR( ascender ),
- FT_FRAME_CHAR( descender ),
- FT_FRAME_BYTE( max_width ),
-
- FT_FRAME_CHAR( caret_slope_numerator ),
- FT_FRAME_CHAR( caret_slope_denominator ),
- FT_FRAME_CHAR( caret_offset ),
-
- FT_FRAME_CHAR( min_origin_SB ),
- FT_FRAME_CHAR( min_advance_SB ),
- FT_FRAME_CHAR( max_before_BL ),
- FT_FRAME_CHAR( min_after_BL ),
- FT_FRAME_CHAR( pads[0] ),
- FT_FRAME_CHAR( pads[1] ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field strike_start_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_SBit_StrikeRec
-
- /* no FT_FRAME_START */
- FT_FRAME_ULONG( ranges_offset ),
- FT_FRAME_SKIP_LONG,
- FT_FRAME_ULONG( num_ranges ),
- FT_FRAME_ULONG( color_ref ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field strike_end_fields[] =
- {
- /* no FT_FRAME_START */
- FT_FRAME_USHORT( start_glyph ),
- FT_FRAME_USHORT( end_glyph ),
- FT_FRAME_BYTE ( x_ppem ),
- FT_FRAME_BYTE ( y_ppem ),
- FT_FRAME_BYTE ( bit_depth ),
- FT_FRAME_CHAR ( flags ),
- FT_FRAME_END
- };
+ if ( p + 5 > limit )
+ goto Fail;
- face->num_sbit_strikes = 0;
+ metrics->height = p[0];
+ metrics->width = p[1];
+ metrics->horiBearingX = (FT_Char)p[2];
+ metrics->horiBearingY = (FT_Char)p[3];
+ metrics->horiAdvance = p[4];
- /* this table is optional */
- error = face->goto_table( face, TTAG_EBLC, stream, 0 );
- if ( error )
- error = face->goto_table( face, TTAG_bloc, stream, 0 );
- if ( error )
- goto Exit;
+ p += 5;
+ if ( big )
+ {
+ if ( p + 3 > limit )
+ goto Fail;
- table_base = FT_STREAM_POS();
- if ( FT_FRAME_ENTER( 8L ) )
- goto Exit;
+ metrics->vertBearingX = (FT_Char)p[0];
+ metrics->vertBearingY = (FT_Char)p[1];
+ metrics->vertAdvance = p[2];
- version = FT_GET_LONG();
- num_strikes = FT_GET_ULONG();
+ p += 3;
+ }
+ else
+ {
+ /* avoid uninitialized data in case there is no vertical info -- */
+ metrics->vertBearingX = 0;
+ metrics->vertBearingY = 0;
+ metrics->vertAdvance = 0;
+ }
- FT_FRAME_EXIT();
+ decoder->metrics_loaded = 1;
+ *pp = p;
+ return FT_Err_Ok;
- /* check version number and strike count */
- if ( version != 0x00020000L ||
- num_strikes >= 0x10000L )
- {
- FT_ERROR(( "tt_face_load_sbit_strikes: invalid table version\n" ));
- error = SFNT_Err_Invalid_File_Format;
+ Fail:
+ FT_TRACE1(( "tt_sbit_decoder_load_metrics: broken table\n" ));
+ return FT_THROW( Invalid_Argument );
+ }
- goto Exit;
- }
- /* allocate the strikes table */
- if ( FT_NEW_ARRAY( face->sbit_strikes, num_strikes ) )
- goto Exit;
+ /* forward declaration */
+ static FT_Error
+ tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
+ FT_UInt glyph_index,
+ FT_Int x_pos,
+ FT_Int y_pos );
- face->num_sbit_strikes = num_strikes;
+ typedef FT_Error (*TT_SBitDecoder_LoadFunc)( TT_SBitDecoder decoder,
+ FT_Byte* p,
+ FT_Byte* plimit,
+ FT_Int x_pos,
+ FT_Int y_pos );
- /* now read each strike table separately */
- {
- TT_SBit_Strike strike = face->sbit_strikes;
- FT_ULong count = num_strikes;
+ static FT_Error
+ tt_sbit_decoder_load_byte_aligned( TT_SBitDecoder decoder,
+ FT_Byte* p,
+ FT_Byte* limit,
+ FT_Int x_pos,
+ FT_Int y_pos )
+ {
+ FT_Error error = FT_Err_Ok;
+ FT_Byte* line;
+ FT_Int bit_height, bit_width, pitch, width, height, line_bits, h;
+ FT_Bitmap* bitmap;
- if ( FT_FRAME_ENTER( 48L * num_strikes ) )
- goto Exit;
- while ( count > 0 )
- {
- if ( FT_STREAM_READ_FIELDS( strike_start_fields, strike ) ||
- FT_STREAM_READ_FIELDS( sbit_line_metrics_fields, &strike->hori ) ||
- FT_STREAM_READ_FIELDS( sbit_line_metrics_fields, &strike->vert ) ||
- FT_STREAM_READ_FIELDS( strike_end_fields, strike ) )
- break;
-
- count--;
- strike++;
- }
+ /* check that we can write the glyph into the bitmap */
+ bitmap = decoder->bitmap;
+ bit_width = bitmap->width;
+ bit_height = bitmap->rows;
+ pitch = bitmap->pitch;
+ line = bitmap->buffer;
- FT_FRAME_EXIT();
+ width = decoder->metrics->width;
+ height = decoder->metrics->height;
+
+ line_bits = width * decoder->bit_depth;
+
+ if ( x_pos < 0 || x_pos + width > bit_width ||
+ y_pos < 0 || y_pos + height > bit_height )
+ {
+ FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned:"
+ " invalid bitmap dimensions\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
}
- /* allocate the index ranges for each strike table */
+ if ( p + ( ( line_bits + 7 ) >> 3 ) * height > limit )
{
- TT_SBit_Strike strike = face->sbit_strikes;
- FT_ULong count = num_strikes;
+ FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned: broken bitmap\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+ /* now do the blit */
+ line += y_pos * pitch + ( x_pos >> 3 );
+ x_pos &= 7;
- while ( count > 0 )
+ if ( x_pos == 0 ) /* the easy one */
+ {
+ for ( h = height; h > 0; h--, line += pitch )
{
- TT_SBit_Range range;
- FT_ULong count2 = strike->num_ranges;
-
-
- /* read each range */
- if ( FT_STREAM_SEEK( table_base + strike->ranges_offset ) ||
- FT_FRAME_ENTER( strike->num_ranges * 8L ) )
- goto Exit;
+ FT_Byte* pwrite = line;
+ FT_Int w;
- if ( FT_NEW_ARRAY( strike->sbit_ranges, strike->num_ranges ) )
- goto Exit;
- range = strike->sbit_ranges;
- while ( count2 > 0 )
+ for ( w = line_bits; w >= 8; w -= 8 )
{
- range->first_glyph = FT_GET_USHORT();
- range->last_glyph = FT_GET_USHORT();
- range->table_offset = table_base + strike->ranges_offset +
- FT_GET_ULONG();
- count2--;
- range++;
+ pwrite[0] = (FT_Byte)( pwrite[0] | *p++ );
+ pwrite += 1;
}
- FT_FRAME_EXIT();
+ if ( w > 0 )
+ pwrite[0] = (FT_Byte)( pwrite[0] | ( *p++ & ( 0xFF00U >> w ) ) );
+ }
+ }
+ else /* x_pos > 0 */
+ {
+ for ( h = height; h > 0; h--, line += pitch )
+ {
+ FT_Byte* pwrite = line;
+ FT_Int w;
+ FT_UInt wval = 0;
+
- /* Now, read each index table */
- count2 = strike->num_ranges;
- range = strike->sbit_ranges;
- while ( count2 > 0 )
+ for ( w = line_bits; w >= 8; w -= 8 )
{
- /* Read the header */
- if ( FT_STREAM_SEEK( range->table_offset ) ||
- FT_FRAME_ENTER( 8L ) )
- goto Exit;
+ wval = (FT_UInt)( wval | *p++ );
+ pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
+ pwrite += 1;
+ wval <<= 8;
+ }
- range->index_format = FT_GET_USHORT();
- range->image_format = FT_GET_USHORT();
- range->image_offset = FT_GET_ULONG();
+ if ( w > 0 )
+ wval = (FT_UInt)( wval | ( *p++ & ( 0xFF00U >> w ) ) );
- FT_FRAME_EXIT();
+ /* all bits read and there are `x_pos + w' bits to be written */
- error = Load_SBit_Range( range, stream );
- if ( error )
- goto Exit;
+ pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
- count2--;
- range++;
+ if ( x_pos + w > 8 )
+ {
+ pwrite++;
+ wval <<= 8;
+ pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
}
-
- count--;
- strike++;
}
}
Exit:
+ if ( !error )
+ FT_TRACE3(( "tt_sbit_decoder_load_byte_aligned: loaded\n" ));
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_free_eblc */
- /* */
- /* <Description> */
- /* Releases the embedded bitmap tables. */
- /* */
- /* <Input> */
- /* face :: The target face object. */
- /* */
- FT_LOCAL_DEF( void )
- tt_face_free_eblc( TT_Face face )
+ /*
+ * Load a bit-aligned bitmap (with pointer `p') into a line-aligned bitmap
+ * (with pointer `pwrite'). In the example below, the width is 3 pixel,
+ * and `x_pos' is 1 pixel.
+ *
+ * p p+1
+ * | | |
+ * | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |...
+ * | | |
+ * +-------+ +-------+ +-------+ ...
+ * . . .
+ * . . .
+ * v . .
+ * +-------+ . .
+ * | | .
+ * | 7 6 5 4 3 2 1 0 | .
+ * | | .
+ * pwrite . .
+ * . .
+ * v .
+ * +-------+ .
+ * | |
+ * | 7 6 5 4 3 2 1 0 |
+ * | |
+ * pwrite+1 .
+ * .
+ * v
+ * +-------+
+ * | |
+ * | 7 6 5 4 3 2 1 0 |
+ * | |
+ * pwrite+2
+ *
+ */
+
+ static FT_Error
+ tt_sbit_decoder_load_bit_aligned( TT_SBitDecoder decoder,
+ FT_Byte* p,
+ FT_Byte* limit,
+ FT_Int x_pos,
+ FT_Int y_pos )
{
- FT_Memory memory = face->root.memory;
- TT_SBit_Strike strike = face->sbit_strikes;
- TT_SBit_Strike strike_limit = strike + face->num_sbit_strikes;
+ FT_Error error = FT_Err_Ok;
+ FT_Byte* line;
+ FT_Int bit_height, bit_width, pitch, width, height, line_bits, h, nbits;
+ FT_Bitmap* bitmap;
+ FT_UShort rval;
- if ( strike )
- {
- for ( ; strike < strike_limit; strike++ )
- {
- TT_SBit_Range range = strike->sbit_ranges;
- TT_SBit_Range range_limit = range + strike->num_ranges;
+ /* check that we can write the glyph into the bitmap */
+ bitmap = decoder->bitmap;
+ bit_width = bitmap->width;
+ bit_height = bitmap->rows;
+ pitch = bitmap->pitch;
+ line = bitmap->buffer;
+ width = decoder->metrics->width;
+ height = decoder->metrics->height;
- if ( range )
- {
- for ( ; range < range_limit; range++ )
- {
- /* release the glyph offsets and codes tables */
- /* where appropriate */
- FT_FREE( range->glyph_offsets );
- FT_FREE( range->glyph_codes );
- }
- }
- FT_FREE( strike->sbit_ranges );
- strike->num_ranges = 0;
- }
- FT_FREE( face->sbit_strikes );
+ line_bits = width * decoder->bit_depth;
+
+ if ( x_pos < 0 || x_pos + width > bit_width ||
+ y_pos < 0 || y_pos + height > bit_height )
+ {
+ FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned:"
+ " invalid bitmap dimensions\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
}
- face->num_sbit_strikes = 0;
- }
+ if ( p + ( ( line_bits * height + 7 ) >> 3 ) > limit )
+ {
+ FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned: broken bitmap\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
- FT_LOCAL_DEF( FT_Error )
- tt_face_set_sbit_strike( TT_Face face,
- FT_Size_Request req,
- FT_ULong* astrike_index )
- {
- return FT_Match_Size( (FT_Face)face, req, 0, astrike_index );
- }
+ /* now do the blit */
+ /* adjust `line' to point to the first byte of the bitmap */
+ line += y_pos * pitch + ( x_pos >> 3 );
+ x_pos &= 7;
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_strike_metrics( TT_Face face,
- FT_ULong strike_index,
- FT_Size_Metrics* metrics )
- {
- TT_SBit_Strike strike;
+ /* the higher byte of `rval' is used as a buffer */
+ rval = 0;
+ nbits = 0;
+ for ( h = height; h > 0; h--, line += pitch )
+ {
+ FT_Byte* pwrite = line;
+ FT_Int w = line_bits;
+
+
+ /* handle initial byte (in target bitmap) specially if necessary */
+ if ( x_pos )
+ {
+ w = ( line_bits < 8 - x_pos ) ? line_bits : 8 - x_pos;
+
+ if ( h == height )
+ {
+ rval = *p++;
+ nbits = x_pos;
+ }
+ else if ( nbits < w )
+ {
+ if ( p < limit )
+ rval |= *p++;
+ nbits += 8 - w;
+ }
+ else
+ {
+ rval >>= 8;
+ nbits -= w;
+ }
- if ( strike_index >= face->num_sbit_strikes )
- return SFNT_Err_Invalid_Argument;
+ *pwrite++ |= ( ( rval >> nbits ) & 0xFF ) &
+ ( ~( 0xFF << w ) << ( 8 - w - x_pos ) );
+ rval <<= 8;
- strike = face->sbit_strikes + strike_index;
+ w = line_bits - w;
+ }
- metrics->x_ppem = strike->x_ppem;
- metrics->y_ppem = strike->y_ppem;
+ /* handle medial bytes */
+ for ( ; w >= 8; w -= 8 )
+ {
+ rval |= *p++;
+ *pwrite++ |= ( rval >> nbits ) & 0xFF;
- metrics->ascender = strike->hori.ascender << 6;
- metrics->descender = strike->hori.descender << 6;
+ rval <<= 8;
+ }
- /* XXX: Is this correct? */
- metrics->max_advance = ( strike->hori.min_origin_SB +
- strike->hori.max_width +
- strike->hori.min_advance_SB ) << 6;
+ /* handle final byte if necessary */
+ if ( w > 0 )
+ {
+ if ( nbits < w )
+ {
+ if ( p < limit )
+ rval |= *p++;
+ *pwrite |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
+ nbits += 8 - w;
- metrics->height = metrics->ascender - metrics->descender;
+ rval <<= 8;
+ }
+ else
+ {
+ *pwrite |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
+ nbits -= w;
+ }
+ }
+ }
- return SFNT_Err_Ok;
+ Exit:
+ if ( !error )
+ FT_TRACE3(( "tt_sbit_decoder_load_bit_aligned: loaded\n" ));
+ return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* find_sbit_range */
- /* */
- /* <Description> */
- /* Scans a given strike's ranges and return, for a given glyph */
- /* index, the corresponding sbit range, and `EBDT' offset. */
- /* */
- /* <Input> */
- /* glyph_index :: The glyph index. */
- /* */
- /* strike :: The source/current sbit strike. */
- /* */
- /* <Output> */
- /* arange :: The sbit range containing the glyph index. */
- /* */
- /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means the glyph index was found. */
- /* */
static FT_Error
- find_sbit_range( FT_UInt glyph_index,
- TT_SBit_Strike strike,
- TT_SBit_Range *arange,
- FT_ULong *aglyph_offset )
+ tt_sbit_decoder_load_compound( TT_SBitDecoder decoder,
+ FT_Byte* p,
+ FT_Byte* limit,
+ FT_Int x_pos,
+ FT_Int y_pos )
{
- TT_SBit_RangeRec *range, *range_limit;
+ FT_Error error = FT_Err_Ok;
+ FT_UInt num_components, nn;
+ FT_Char horiBearingX = (FT_Char)decoder->metrics->horiBearingX;
+ FT_Char horiBearingY = (FT_Char)decoder->metrics->horiBearingY;
+ FT_Byte horiAdvance = (FT_Byte)decoder->metrics->horiAdvance;
+ FT_Char vertBearingX = (FT_Char)decoder->metrics->vertBearingX;
+ FT_Char vertBearingY = (FT_Char)decoder->metrics->vertBearingY;
+ FT_Byte vertAdvance = (FT_Byte)decoder->metrics->vertAdvance;
- /* check whether the glyph index is within this strike's */
- /* glyph range */
- if ( glyph_index < (FT_UInt)strike->start_glyph ||
- glyph_index > (FT_UInt)strike->end_glyph )
- goto Fail;
- /* scan all ranges in strike */
- range = strike->sbit_ranges;
- range_limit = range + strike->num_ranges;
- if ( !range )
+ if ( p + 2 > limit )
goto Fail;
- for ( ; range < range_limit; range++ )
+ num_components = FT_NEXT_USHORT( p );
+ if ( p + 4 * num_components > limit )
{
- if ( glyph_index >= (FT_UInt)range->first_glyph &&
- glyph_index <= (FT_UInt)range->last_glyph )
- {
- FT_UShort delta = (FT_UShort)( glyph_index - range->first_glyph );
+ FT_TRACE1(( "tt_sbit_decoder_load_compound: broken table\n" ));
+ goto Fail;
+ }
+ FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d components\n",
+ num_components ));
- switch ( range->index_format )
- {
- case 1:
- case 3:
- *aglyph_offset = range->glyph_offsets[delta];
- break;
-
- case 2:
- *aglyph_offset = range->image_offset +
- range->image_size * delta;
- break;
-
- case 4:
- case 5:
- {
- FT_ULong n;
-
-
- for ( n = 0; n < range->num_glyphs; n++ )
- {
- if ( (FT_UInt)range->glyph_codes[n] == glyph_index )
- {
- if ( range->index_format == 4 )
- *aglyph_offset = range->glyph_offsets[n];
- else
- *aglyph_offset = range->image_offset +
- n * range->image_size;
- goto Found;
- }
- }
- }
+ for ( nn = 0; nn < num_components; nn++ )
+ {
+ FT_UInt gindex = FT_NEXT_USHORT( p );
+ FT_Byte dx = FT_NEXT_BYTE( p );
+ FT_Byte dy = FT_NEXT_BYTE( p );
- /* fall-through */
- default:
- goto Fail;
- }
- Found:
- /* return successfully! */
- *arange = range;
- return SFNT_Err_Ok;
- }
+ /* NB: a recursive call */
+ error = tt_sbit_decoder_load_image( decoder, gindex,
+ x_pos + dx, y_pos + dy );
+ if ( error )
+ break;
}
- Fail:
- *arange = 0;
- *aglyph_offset = 0;
+ FT_TRACE3(( "tt_sbit_decoder_load_compound: done\n" ));
- return SFNT_Err_Invalid_Argument;
- }
+ decoder->metrics->horiBearingX = horiBearingX;
+ decoder->metrics->horiBearingY = horiBearingY;
+ decoder->metrics->horiAdvance = horiAdvance;
+ decoder->metrics->vertBearingX = vertBearingX;
+ decoder->metrics->vertBearingY = vertBearingY;
+ decoder->metrics->vertAdvance = vertAdvance;
+ decoder->metrics->width = (FT_Byte)decoder->bitmap->width;
+ decoder->metrics->height = (FT_Byte)decoder->bitmap->rows;
+ Exit:
+ return error;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_find_sbit_image */
- /* */
- /* <Description> */
- /* Checks whether an embedded bitmap (an `sbit') exists for a given */
- /* glyph, at a given strike. */
- /* */
- /* <Input> */
- /* face :: The target face object. */
- /* */
- /* glyph_index :: The glyph index. */
- /* */
- /* strike_index :: The current strike index. */
- /* */
- /* <Output> */
- /* arange :: The SBit range containing the glyph index. */
- /* */
- /* astrike :: The SBit strike containing the glyph index. */
- /* */
- /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. Returns */
- /* SFNT_Err_Invalid_Argument if no sbit exists for the requested */
- /* glyph. */
- /* */
- FT_LOCAL( FT_Error )
- tt_find_sbit_image( TT_Face face,
- FT_UInt glyph_index,
- FT_ULong strike_index,
- TT_SBit_Range *arange,
- TT_SBit_Strike *astrike,
- FT_ULong *aglyph_offset )
- {
- FT_Error error;
- TT_SBit_Strike strike;
+ Fail:
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
- if ( !face->sbit_strikes ||
- ( face->num_sbit_strikes <= strike_index ) )
- goto Fail;
+#ifdef FT_CONFIG_OPTION_USE_PNG
- strike = &face->sbit_strikes[strike_index];
+ static FT_Error
+ tt_sbit_decoder_load_png( TT_SBitDecoder decoder,
+ FT_Byte* p,
+ FT_Byte* limit,
+ FT_Int x_pos,
+ FT_Int y_pos )
+ {
+ FT_Error error = FT_Err_Ok;
+ FT_ULong png_len;
- error = find_sbit_range( glyph_index, strike,
- arange, aglyph_offset );
- if ( error )
- goto Fail;
- *astrike = strike;
+ if ( limit - p < 4 )
+ {
+ FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
- return SFNT_Err_Ok;
+ png_len = FT_NEXT_ULONG( p );
+ if ( (FT_ULong)( limit - p ) < png_len )
+ {
+ FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
- Fail:
- /* no embedded bitmap for this glyph in face */
- *arange = 0;
- *astrike = 0;
- *aglyph_offset = 0;
+ error = Load_SBit_Png( decoder->face->root.glyph,
+ x_pos,
+ y_pos,
+ decoder->bit_depth,
+ decoder->metrics,
+ decoder->stream->memory,
+ p,
+ png_len,
+ FALSE );
- return SFNT_Err_Invalid_Argument;
+ Exit:
+ if ( !error )
+ FT_TRACE3(( "tt_sbit_decoder_load_png: loaded\n" ));
+ return error;
}
+#endif /* FT_CONFIG_OPTION_USE_PNG */
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_load_sbit_metrics */
- /* */
- /* <Description> */
- /* Gets the big metrics for a given SBit. */
- /* */
- /* <Input> */
- /* stream :: The input stream. */
- /* */
- /* range :: The SBit range containing the glyph. */
- /* */
- /* <Output> */
- /* big_metrics :: A big SBit metrics structure for the glyph. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* The stream cursor must be positioned at the glyph's offset within */
- /* the `EBDT' table before the call. */
- /* */
- /* If the image format uses variable metrics, the stream cursor is */
- /* positioned just after the metrics header in the `EBDT' table on */
- /* function exit. */
- /* */
- FT_LOCAL( FT_Error )
- tt_load_sbit_metrics( FT_Stream stream,
- TT_SBit_Range range,
- TT_SBit_Metrics metrics )
+
+ static FT_Error
+ tt_sbit_decoder_load_bitmap( TT_SBitDecoder decoder,
+ FT_UInt glyph_format,
+ FT_ULong glyph_start,
+ FT_ULong glyph_size,
+ FT_Int x_pos,
+ FT_Int y_pos )
{
- FT_Error error = SFNT_Err_Ok;
+ FT_Error error;
+ FT_Stream stream = decoder->stream;
+ FT_Byte* p;
+ FT_Byte* p_limit;
+ FT_Byte* data;
- switch ( range->image_format )
+ /* seek into the EBDT table now */
+ if ( glyph_start + glyph_size > decoder->ebdt_size )
{
- case 1:
- case 2:
- case 8:
- /* variable small metrics */
- {
- TT_SBit_SmallMetricsRec smetrics;
-
- static const FT_Frame_Field sbit_small_metrics_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_SBit_SmallMetricsRec
-
- FT_FRAME_START( 5 ),
- FT_FRAME_BYTE( height ),
- FT_FRAME_BYTE( width ),
- FT_FRAME_CHAR( bearingX ),
- FT_FRAME_CHAR( bearingY ),
- FT_FRAME_BYTE( advance ),
- FT_FRAME_END
- };
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+ if ( FT_STREAM_SEEK( decoder->ebdt_start + glyph_start ) ||
+ FT_FRAME_EXTRACT( glyph_size, data ) )
+ goto Exit;
- /* read small metrics */
- if ( FT_STREAM_READ_FIELDS( sbit_small_metrics_fields, &smetrics ) )
- goto Exit;
+ p = data;
+ p_limit = p + glyph_size;
- /* convert it to a big metrics */
- metrics->height = smetrics.height;
- metrics->width = smetrics.width;
- metrics->horiBearingX = smetrics.bearingX;
- metrics->horiBearingY = smetrics.bearingY;
- metrics->horiAdvance = smetrics.advance;
-
- /* these metrics are made up at a higher level when */
- /* needed. */
- metrics->vertBearingX = 0;
- metrics->vertBearingY = 0;
- metrics->vertAdvance = 0;
- }
+ /* read the data, depending on the glyph format */
+ switch ( glyph_format )
+ {
+ case 1:
+ case 2:
+ case 8:
+ case 17:
+ error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 0 );
break;
case 6:
case 7:
case 9:
- /* variable big metrics */
- if ( FT_STREAM_READ_FIELDS( sbit_metrics_fields, metrics ) )
- goto Exit;
+ case 18:
+ error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 );
break;
- case 5:
- default: /* constant metrics */
- if ( range->index_format == 2 || range->index_format == 5 )
- *metrics = range->metrics;
- else
- return SFNT_Err_Invalid_File_Format;
- }
-
- Exit:
- return error;
- }
+ default:
+ error = FT_Err_Ok;
+ }
+ if ( error )
+ goto Fail;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* crop_bitmap */
- /* */
- /* <Description> */
- /* Crops a bitmap to its tightest bounding box, and adjusts its */
- /* metrics. */
- /* */
- /* <InOut> */
- /* map :: The bitmap. */
- /* */
- /* metrics :: The corresponding metrics structure. */
- /* */
- static void
- crop_bitmap( FT_Bitmap* map,
- TT_SBit_Metrics metrics )
- {
- /***********************************************************************/
- /* */
- /* In this situation, some bounding boxes of embedded bitmaps are too */
- /* large. We need to crop it to a reasonable size. */
- /* */
- /* --------- */
- /* | | ----- */
- /* | *** | |***| */
- /* | * | | * | */
- /* | * | ------> | * | */
- /* | * | | * | */
- /* | * | | * | */
- /* | *** | |***| */
- /* --------- ----- */
- /* */
- /***********************************************************************/
-
- FT_Int rows, count;
- FT_Long line_len;
- FT_Byte* line;
-
-
- /***********************************************************************/
- /* */
- /* first of all, check the top-most lines of the bitmap, and remove */
- /* them if they're empty. */
- /* */
{
- line = (FT_Byte*)map->buffer;
- rows = map->rows;
- line_len = map->pitch;
+ TT_SBitDecoder_LoadFunc loader;
- for ( count = 0; count < rows; count++ )
+ switch ( glyph_format )
{
- FT_Byte* cur = line;
- FT_Byte* limit = line + line_len;
+ case 1:
+ case 6:
+ loader = tt_sbit_decoder_load_byte_aligned;
+ break;
+ case 2:
+ case 7:
+ {
+ /* Don't trust `glyph_format'. For example, Apple's main Korean */
+ /* system font, `AppleMyungJo.ttf' (version 7.0d2e6), uses glyph */
+ /* format 7, but the data is format 6. We check whether we have */
+ /* an excessive number of bytes in the image: If it is equal to */
+ /* the value for a byte-aligned glyph, use the other loading */
+ /* routine. */
+ /* */
+ /* Note that for some (width,height) combinations, where the */
+ /* width is not a multiple of 8, the sizes for bit- and */
+ /* byte-aligned data are equal, for example (7,7) or (15,6). We */
+ /* then prefer what `glyph_format' specifies. */
+
+ FT_UInt width = decoder->metrics->width;
+ FT_UInt height = decoder->metrics->height;
+
+ FT_UInt bit_size = ( width * height + 7 ) >> 3;
+ FT_UInt byte_size = height * ( ( width + 7 ) >> 3 );
+
+
+ if ( bit_size < byte_size &&
+ byte_size == (FT_UInt)( p_limit - p ) )
+ loader = tt_sbit_decoder_load_byte_aligned;
+ else
+ loader = tt_sbit_decoder_load_bit_aligned;
+ }
+ break;
- for ( ; cur < limit; cur++ )
- if ( cur[0] )
- goto Found_Top;
+ case 5:
+ loader = tt_sbit_decoder_load_bit_aligned;
+ break;
- /* the current line was empty - skip to next one */
- line = limit;
- }
+ case 8:
+ if ( p + 1 > p_limit )
+ goto Fail;
- Found_Top:
- /* check that we have at least one filled line */
- if ( count >= rows )
- goto Empty_Bitmap;
+ p += 1; /* skip padding */
+ /* fall-through */
- /* now, crop the empty upper lines */
- if ( count > 0 )
- {
- line = (FT_Byte*)map->buffer;
+ case 9:
+ loader = tt_sbit_decoder_load_compound;
+ break;
- FT_MEM_MOVE( line, line + count * line_len,
- ( rows - count ) * line_len );
+ case 17: /* small metrics, PNG image data */
+ case 18: /* big metrics, PNG image data */
+ case 19: /* metrics in EBLC, PNG image data */
+#ifdef FT_CONFIG_OPTION_USE_PNG
+ loader = tt_sbit_decoder_load_png;
+ break;
+#else
+ error = FT_THROW( Unimplemented_Feature );
+ goto Fail;
+#endif /* FT_CONFIG_OPTION_USE_PNG */
- metrics->height = (FT_Byte)( metrics->height - count );
- metrics->horiBearingY = (FT_Char)( metrics->horiBearingY - count );
- metrics->vertBearingY = (FT_Char)( metrics->vertBearingY - count );
+ default:
+ error = FT_THROW( Invalid_Table );
+ goto Fail;
+ }
- map->rows -= count;
- rows -= count;
+ if ( !decoder->bitmap_allocated )
+ {
+ error = tt_sbit_decoder_alloc_bitmap( decoder );
+ if ( error )
+ goto Fail;
}
+
+ error = loader( decoder, p, p_limit, x_pos, y_pos );
}
- /***********************************************************************/
- /* */
- /* second, crop the lower lines */
- /* */
- {
- line = (FT_Byte*)map->buffer + ( rows - 1 ) * line_len;
+ Fail:
+ FT_FRAME_RELEASE( data );
- for ( count = 0; count < rows; count++ )
- {
- FT_Byte* cur = line;
- FT_Byte* limit = line + line_len;
+ Exit:
+ return error;
+ }
- for ( ; cur < limit; cur++ )
- if ( cur[0] )
- goto Found_Bottom;
+ static FT_Error
+ tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
+ FT_UInt glyph_index,
+ FT_Int x_pos,
+ FT_Int y_pos )
+ {
+ /*
+ * First, we find the correct strike range that applies to this
+ * glyph index.
+ */
- /* the current line was empty - skip to previous one */
- line -= line_len;
- }
+ 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;
+ FT_UInt start, end, index_format, image_format;
+ FT_ULong image_start = 0, image_end = 0, image_offset;
- Found_Bottom:
- if ( count > 0 )
- {
- metrics->height = (FT_Byte)( metrics->height - count );
- rows -= count;
- map->rows -= count;
- }
- }
- /***********************************************************************/
- /* */
- /* third, get rid of the space on the left side of the glyph */
- /* */
- do
+ for ( ; num_ranges > 0; num_ranges-- )
{
- FT_Byte* limit;
+ start = FT_NEXT_USHORT( p );
+ end = FT_NEXT_USHORT( p );
+ if ( glyph_index >= start && glyph_index <= end )
+ goto FoundRange;
- line = (FT_Byte*)map->buffer;
- limit = line + rows * line_len;
+ p += 4; /* ignore index offset */
+ }
+ goto NoBitmap;
+
+ FoundRange:
+ image_offset = FT_NEXT_ULONG( p );
+
+ /* overflow check */
+ p = decoder->eblc_base + decoder->strike_index_array;
+ if ( image_offset > (FT_ULong)( p_limit - p ) )
+ goto Failure;
+
+ p += image_offset;
+ if ( p + 8 > p_limit )
+ goto NoBitmap;
+
+ /* now find the glyph's location and extend within the ebdt table */
+ index_format = FT_NEXT_USHORT( p );
+ image_format = FT_NEXT_USHORT( p );
+ image_offset = FT_NEXT_ULONG ( p );
- for ( ; line < limit; line += line_len )
- if ( line[0] & 0x80 )
- goto Found_Left;
+ switch ( index_format )
+ {
+ case 1: /* 4-byte offsets relative to `image_offset' */
+ p += 4 * ( glyph_index - start );
+ if ( p + 8 > p_limit )
+ goto NoBitmap;
+
+ image_start = FT_NEXT_ULONG( p );
+ image_end = FT_NEXT_ULONG( p );
- /* shift the whole glyph one pixel to the left */
- line = (FT_Byte*)map->buffer;
- limit = line + rows * line_len;
+ if ( image_start == image_end ) /* missing glyph */
+ goto NoBitmap;
+ break;
- for ( ; line < limit; line += line_len )
+ case 2: /* big metrics, constant image size */
{
- FT_Int n, width = map->width;
- FT_Byte old;
- FT_Byte* cur = line;
+ FT_ULong image_size;
- old = (FT_Byte)(cur[0] << 1);
- for ( n = 8; n < width; n += 8 )
- {
- FT_Byte val;
+ if ( p + 12 > p_limit )
+ goto NoBitmap;
+ image_size = FT_NEXT_ULONG( p );
- val = cur[1];
- cur[0] = (FT_Byte)( old | ( val >> 7 ) );
- old = (FT_Byte)( val << 1 );
- cur++;
- }
- cur[0] = old;
+ if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
+ goto NoBitmap;
+
+ image_start = image_size * ( glyph_index - start );
+ image_end = image_start + image_size;
}
+ break;
- map->width--;
- metrics->horiBearingX++;
- metrics->vertBearingX++;
- metrics->width--;
+ case 3: /* 2-byte offsets relative to 'image_offset' */
+ p += 2 * ( glyph_index - start );
+ if ( p + 4 > p_limit )
+ goto NoBitmap;
- } while ( map->width > 0 );
+ image_start = FT_NEXT_USHORT( p );
+ image_end = FT_NEXT_USHORT( p );
- Found_Left:
+ if ( image_start == image_end ) /* missing glyph */
+ goto NoBitmap;
+ break;
- /***********************************************************************/
- /* */
- /* finally, crop the bitmap width to get rid of the space on the right */
- /* side of the glyph. */
- /* */
- do
- {
- FT_Int right = map->width - 1;
- FT_Byte* limit;
- FT_Byte mask;
+ case 4: /* sparse glyph array with (glyph,offset) pairs */
+ {
+ FT_ULong mm, num_glyphs;
- line = (FT_Byte*)map->buffer + ( right >> 3 );
- limit = line + rows * line_len;
- mask = (FT_Byte)( 0x80 >> ( right & 7 ) );
+ if ( p + 4 > p_limit )
+ goto NoBitmap;
- for ( ; line < limit; line += line_len )
- if ( line[0] & mask )
- goto Found_Right;
+ num_glyphs = FT_NEXT_ULONG( p );
- /* crop the whole glyph to the right */
- map->width--;
- metrics->width--;
+ /* overflow check for p + ( num_glyphs + 1 ) * 4 */
+ if ( p + 4 > p_limit ||
+ num_glyphs > (FT_ULong)( ( ( p_limit - p ) >> 2 ) - 1 ) )
+ goto NoBitmap;
- } while ( map->width > 0 );
+ for ( mm = 0; mm < num_glyphs; mm++ )
+ {
+ FT_UInt gindex = FT_NEXT_USHORT( p );
- Found_Right:
- /* all right, the bitmap was cropped */
- return;
- Empty_Bitmap:
- map->width = 0;
- map->rows = 0;
- map->pitch = 0;
- map->pixel_mode = FT_PIXEL_MODE_MONO;
- }
+ if ( gindex == glyph_index )
+ {
+ image_start = FT_NEXT_USHORT( p );
+ p += 2;
+ image_end = FT_PEEK_USHORT( p );
+ break;
+ }
+ p += 2;
+ }
+ if ( mm >= num_glyphs )
+ goto NoBitmap;
+ }
+ break;
- static FT_Error
- Load_SBit_Single( FT_Bitmap* map,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Int pix_bits,
- FT_UShort image_format,
- TT_SBit_Metrics metrics,
- FT_Stream stream )
- {
- FT_Error error;
+ case 5: /* constant metrics with sparse glyph codes */
+ case 19:
+ {
+ FT_ULong image_size, mm, num_glyphs;
- /* check that the source bitmap fits into the target pixmap */
- if ( x_offset < 0 || x_offset + metrics->width > map->width ||
- y_offset < 0 || y_offset + metrics->height > map->rows )
- {
- error = SFNT_Err_Invalid_Argument;
+ if ( p + 16 > p_limit )
+ goto NoBitmap;
- goto Exit;
- }
+ image_size = FT_NEXT_ULONG( p );
- {
- FT_Int glyph_width = metrics->width;
- FT_Int glyph_height = metrics->height;
- FT_Int glyph_size;
- FT_Int line_bits = pix_bits * glyph_width;
- FT_Bool pad_bytes = 0;
+ if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
+ goto NoBitmap;
+ num_glyphs = FT_NEXT_ULONG( p );
- /* compute size of glyph image */
- switch ( image_format )
- {
- case 1: /* byte-padded formats */
- case 6:
+ /* overflow check for p + 2 * num_glyphs */
+ if ( num_glyphs > (FT_ULong)( ( p_limit - p ) >> 1 ) )
+ goto NoBitmap;
+
+ for ( mm = 0; mm < num_glyphs; mm++ )
{
- FT_Int line_length;
+ FT_UInt gindex = FT_NEXT_USHORT( p );
- switch ( pix_bits )
- {
- case 1:
- line_length = ( glyph_width + 7 ) >> 3;
- break;
- case 2:
- line_length = ( glyph_width + 3 ) >> 2;
+ if ( gindex == glyph_index )
break;
- case 4:
- line_length = ( glyph_width + 1 ) >> 1;
- break;
- default:
- line_length = glyph_width;
- }
-
- glyph_size = glyph_height * line_length;
- pad_bytes = 1;
}
- break;
- case 2:
- case 5:
- case 7:
- line_bits = glyph_width * pix_bits;
- glyph_size = ( glyph_height * line_bits + 7 ) >> 3;
- break;
+ if ( mm >= num_glyphs )
+ goto NoBitmap;
- default: /* invalid format */
- return SFNT_Err_Invalid_File_Format;
+ image_start = image_size * mm;
+ image_end = image_start + image_size;
}
+ break;
- /* Now read data and draw glyph into target pixmap */
- if ( FT_FRAME_ENTER( glyph_size ) )
- goto Exit;
+ default:
+ goto NoBitmap;
+ }
- /* don't forget to multiply `x_offset' by `map->pix_bits' as */
- /* the sbit blitter doesn't make a difference between pixmap */
- /* depths. */
- blit_sbit( map, (FT_Byte*)stream->cursor, line_bits, pad_bytes,
- x_offset * pix_bits, y_offset, metrics->height );
+ if ( image_start > image_end )
+ goto NoBitmap;
- FT_FRAME_EXIT();
- }
+ image_end -= image_start;
+ image_start = image_offset + image_start;
- Exit:
- return error;
+ FT_TRACE3(( "tt_sbit_decoder_load_image:"
+ " found sbit (format %d) for glyph index %d\n",
+ image_format, glyph_index ));
+
+ return tt_sbit_decoder_load_bitmap( decoder,
+ image_format,
+ image_start,
+ image_end,
+ x_pos,
+ y_pos );
+
+ Failure:
+ return FT_THROW( Invalid_Table );
+
+ NoBitmap:
+ FT_TRACE4(( "tt_sbit_decoder_load_image:"
+ " no sbit found for glyph index %d\n", glyph_index ));
+
+ return FT_THROW( Invalid_Argument );
}
static FT_Error
- Load_SBit_Image( TT_SBit_Strike strike,
- TT_SBit_Range range,
- FT_ULong ebdt_pos,
- FT_ULong glyph_offset,
- FT_GlyphSlot slot,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Stream stream,
- TT_SBit_Metrics metrics,
- FT_Int depth )
+ tt_face_load_sbix_image( TT_Face face,
+ FT_ULong strike_index,
+ FT_UInt glyph_index,
+ FT_Stream stream,
+ FT_Bitmap *map,
+ TT_SBit_MetricsRec *metrics )
{
- FT_Memory memory = stream->memory;
- FT_Bitmap* map = &slot->bitmap;
- FT_Error error;
+ FT_UInt sbix_pos, strike_offset, glyph_start, glyph_end;
+ FT_ULong table_size;
+ FT_Int originOffsetX, originOffsetY;
+ FT_Tag graphicType;
+ FT_Int recurse_depth = 0;
+ FT_Error error;
+ FT_Byte* p;
- /* place stream at beginning of glyph data and read metrics */
- if ( FT_STREAM_SEEK( ebdt_pos + glyph_offset ) )
- goto Exit;
+ FT_UNUSED( map );
- error = tt_load_sbit_metrics( stream, range, metrics );
- if ( error )
- goto Exit;
- /* This function is recursive. At the top-level call, we */
- /* compute the dimensions of the higher-level glyph to */
- /* allocate the final pixmap buffer. */
- if ( depth == 0 )
- {
- FT_Long size;
+ metrics->width = 0;
+ metrics->height = 0;
+ p = face->sbit_table + 8 + 4 * strike_index;
+ strike_offset = FT_NEXT_ULONG( p );
- map->width = metrics->width;
- map->rows = metrics->height;
+ error = face->goto_table( face, TTAG_sbix, stream, &table_size );
+ if ( error )
+ return error;
+ sbix_pos = FT_STREAM_POS();
- switch ( strike->bit_depth )
- {
- case 1:
- map->pixel_mode = FT_PIXEL_MODE_MONO;
- map->pitch = ( map->width + 7 ) >> 3;
- break;
+ retry:
+ if ( glyph_index > (FT_UInt)face->root.num_glyphs )
+ return FT_THROW( Invalid_Argument );
- case 2:
- map->pixel_mode = FT_PIXEL_MODE_GRAY2;
- map->pitch = ( map->width + 3 ) >> 2;
- break;
+ if ( strike_offset >= table_size ||
+ table_size - strike_offset < 4 + glyph_index * 4 + 8 )
+ return FT_THROW( Invalid_File_Format );
- case 4:
- map->pixel_mode = FT_PIXEL_MODE_GRAY4;
- map->pitch = ( map->width + 1 ) >> 1;
- break;
+ if ( FT_STREAM_SEEK( sbix_pos + strike_offset + 4 + glyph_index * 4 ) ||
+ FT_FRAME_ENTER( 8 ) )
+ return error;
- case 8:
- map->pixel_mode = FT_PIXEL_MODE_GRAY;
- map->pitch = map->width;
- break;
+ glyph_start = FT_GET_ULONG();
+ glyph_end = FT_GET_ULONG();
- default:
- return SFNT_Err_Invalid_File_Format;
- }
+ FT_FRAME_EXIT();
- size = map->rows * map->pitch;
+ 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( Invalid_File_Format );
- /* check that there is no empty image */
- if ( size == 0 )
- goto Exit; /* exit successfully! */
+ if ( FT_STREAM_SEEK( sbix_pos + strike_offset + glyph_start ) ||
+ FT_FRAME_ENTER( glyph_end - glyph_start ) )
+ return error;
- error = ft_glyphslot_alloc_bitmap( slot, size );
- if (error)
- goto Exit;
- }
+ originOffsetX = FT_GET_SHORT();
+ originOffsetY = FT_GET_SHORT();
- switch ( range->image_format )
- {
- case 1: /* single sbit image - load it */
- case 2:
- case 5:
- case 6:
- case 7:
- return Load_SBit_Single( map, x_offset, y_offset, strike->bit_depth,
- range->image_format, metrics, stream );
+ graphicType = FT_GET_TAG4();
- case 8: /* compound format */
- if ( FT_STREAM_SKIP( 1L ) )
+ switch ( graphicType )
+ {
+ case FT_MAKE_TAG( 'd', 'u', 'p', 'e' ):
+ if ( recurse_depth < 4 )
{
- error = SFNT_Err_Invalid_Stream_Skip;
- goto Exit;
+ glyph_index = FT_GET_USHORT();
+ FT_FRAME_EXIT();
+ recurse_depth++;
+ goto retry;
}
- /* fallthrough */
-
- case 9:
+ error = FT_THROW( Invalid_File_Format );
break;
- default: /* invalid image format */
- return SFNT_Err_Invalid_File_Format;
- }
-
- /* All right, we have a compound format. First of all, read */
- /* the array of elements. */
- {
- TT_SBit_Component components;
- TT_SBit_Component comp;
- FT_UShort num_components, count;
-
-
- if ( FT_READ_USHORT( num_components ) ||
- FT_NEW_ARRAY( components, num_components ) )
- goto Exit;
-
- count = num_components;
+ case FT_MAKE_TAG( 'p', 'n', 'g', ' ' ):
+#ifdef FT_CONFIG_OPTION_USE_PNG
+ error = Load_SBit_Png( face->root.glyph,
+ 0,
+ 0,
+ 32,
+ metrics,
+ stream->memory,
+ stream->cursor,
+ glyph_end - glyph_start - 8,
+ TRUE );
+#else
+ error = FT_THROW( Unimplemented_Feature );
+#endif
+ break;
- if ( FT_FRAME_ENTER( 4L * num_components ) )
- goto Fail_Memory;
+ case FT_MAKE_TAG( 'j', 'p', 'g', ' ' ):
+ case FT_MAKE_TAG( 't', 'i', 'f', 'f' ):
+ case FT_MAKE_TAG( 'r', 'g', 'b', 'l' ): /* used on iOS 7.1 */
+ error = FT_THROW( Unknown_File_Format );
+ break;
- for ( comp = components; count > 0; count--, comp++ )
- {
- comp->glyph_code = FT_GET_USHORT();
- comp->x_offset = FT_GET_CHAR();
- comp->y_offset = FT_GET_CHAR();
- }
+ default:
+ error = FT_THROW( Unimplemented_Feature );
+ break;
+ }
- FT_FRAME_EXIT();
+ FT_FRAME_EXIT();
- /* Now recursively load each element glyph */
- count = num_components;
- comp = components;
- for ( ; count > 0; count--, comp++ )
- {
- TT_SBit_Range elem_range;
- TT_SBit_MetricsRec elem_metrics;
- FT_ULong elem_offset;
+ if ( !error )
+ {
+ FT_Short abearing;
+ FT_UShort aadvance;
- /* find the range for this element */
- error = find_sbit_range( comp->glyph_code,
- strike,
- &elem_range,
- &elem_offset );
- if ( error )
- goto Fail_Memory;
-
- /* now load the element, recursively */
- error = Load_SBit_Image( strike,
- elem_range,
- ebdt_pos,
- elem_offset,
- slot,
- x_offset + comp->x_offset,
- y_offset + comp->y_offset,
- stream,
- &elem_metrics,
- depth + 1 );
- if ( error )
- goto Fail_Memory;
- }
+ tt_face_get_metrics( face, FALSE, glyph_index, &abearing, &aadvance );
- Fail_Memory:
- FT_FREE( components );
+ metrics->horiBearingX = (FT_Short)originOffsetX;
+ metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height );
+ metrics->horiAdvance = (FT_Short)( aadvance *
+ face->root.size->metrics.x_ppem /
+ face->header.Units_Per_EM );
}
- Exit:
return error;
}
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_sbit_image */
- /* */
- /* <Description> */
- /* Loads a given glyph sbit image from the font resource. This also */
- /* returns its metrics. */
- /* */
- /* <Input> */
- /* face :: The target face object. */
- /* */
- /* strike_index :: The current strike index. */
- /* */
- /* glyph_index :: The current glyph index. */
- /* */
- /* load_flags :: The glyph load flags (the code checks for the flag */
- /* FT_LOAD_CROP_BITMAP). */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Output> */
- /* map :: The target pixmap. */
- /* */
- /* metrics :: A big sbit metrics structure for the glyph image. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. Returns an error if no */
- /* glyph sbit exists for the index. */
- /* */
- /* <Note> */
- /* The `map.buffer' field is always freed before the glyph is loaded. */
- /* */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL( FT_Error )
tt_face_load_sbit_image( TT_Face face,
FT_ULong strike_index,
FT_UInt glyph_index,
@@ -1449,59 +1396,71 @@
FT_Bitmap *map,
TT_SBit_MetricsRec *metrics )
{
- FT_Error error;
- FT_ULong ebdt_pos, glyph_offset;
+ FT_Error error = FT_Err_Ok;
- TT_SBit_Strike strike;
- TT_SBit_Range range;
+ switch ( (FT_UInt)face->sbit_table_type )
+ {
+ case TT_SBIT_TABLE_TYPE_EBLC:
+ case TT_SBIT_TABLE_TYPE_CBLC:
+ {
+ TT_SBitDecoderRec decoder[1];
- /* Check whether there is a glyph sbit for the current index */
- error = tt_find_sbit_image( face, glyph_index, strike_index,
- &range, &strike, &glyph_offset );
- if ( error )
- goto Exit;
- /* now, find the location of the `EBDT' table in */
- /* the font file */
- error = face->goto_table( face, TTAG_EBDT, stream, 0 );
- if ( error )
- error = face->goto_table( face, TTAG_bdat, stream, 0 );
- if ( error )
- goto Exit;
+ error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
+ if ( !error )
+ {
+ error = tt_sbit_decoder_load_image( decoder,
+ glyph_index,
+ 0,
+ 0 );
+ tt_sbit_decoder_done( decoder );
+ }
+ }
+ break;
- ebdt_pos = FT_STREAM_POS();
+ case TT_SBIT_TABLE_TYPE_SBIX:
+ error = tt_face_load_sbix_image( face,
+ strike_index,
+ glyph_index,
+ stream,
+ map,
+ metrics );
+ break;
- error = Load_SBit_Image( strike, range, ebdt_pos, glyph_offset,
- face->root.glyph, 0, 0, stream, metrics, 0 );
- if ( error )
- goto Exit;
+ default:
+ error = FT_THROW( Unknown_File_Format );
+ break;
+ }
- /* setup vertical metrics if needed */
- if ( strike->flags & 1 )
+ /* Flatten color bitmaps if color was not requested. */
+ if ( !error &&
+ !( load_flags & FT_LOAD_COLOR ) &&
+ map->pixel_mode == FT_PIXEL_MODE_BGRA )
{
- /* in case of a horizontal strike only */
- FT_Int advance;
+ FT_Bitmap new_map;
+ FT_Library library = face->root.glyph->library;
- advance = strike->hori.ascender - strike->hori.descender;
+ FT_Bitmap_New( &new_map );
- /* some heuristic values */
+ /* Convert to 8bit grayscale. */
+ error = FT_Bitmap_Convert( library, map, &new_map, 1 );
+ if ( error )
+ FT_Bitmap_Done( library, &new_map );
+ else
+ {
+ map->pixel_mode = new_map.pixel_mode;
+ map->pitch = new_map.pitch;
+ map->num_grays = new_map.num_grays;
- metrics->vertBearingX = (FT_Char)(-metrics->width / 2 );
- metrics->vertBearingY = (FT_Char)( ( advance - metrics->height ) / 2 );
- metrics->vertAdvance = (FT_Char)( advance * 12 / 10 );
+ ft_glyphslot_set_bitmap( face->root.glyph, new_map.buffer );
+ face->root.glyph->internal->flags |= FT_GLYPH_OWN_BITMAP;
+ }
}
- /* Crop the bitmap now, unless specified otherwise */
- if ( load_flags & FT_LOAD_CROP_BITMAP )
- crop_bitmap( map, metrics );
-
- Exit:
return error;
}
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-/* END */
+/* EOF */
diff --git a/src/3rdparty/freetype/src/sfnt/ttsbit.h b/src/3rdparty/freetype/src/sfnt/ttsbit.h
index 7ea2af1843..695d0d8d02 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 1996-2008, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,11 +28,11 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
- tt_face_load_eblc( TT_Face face,
+ tt_face_load_sbit( TT_Face face,
FT_Stream stream );
FT_LOCAL( void )
- tt_face_free_eblc( TT_Face face );
+ tt_face_free_sbit( TT_Face face );
FT_LOCAL( FT_Error )
@@ -45,22 +45,6 @@ FT_BEGIN_HEADER
FT_ULong strike_index,
FT_Size_Metrics* metrics );
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- FT_LOCAL( FT_Error )
- tt_find_sbit_image( TT_Face face,
- FT_UInt glyph_index,
- FT_ULong strike_index,
- TT_SBit_Range *arange,
- TT_SBit_Strike *astrike,
- FT_ULong *aglyph_offset );
-
- FT_LOCAL( FT_Error )
- tt_load_sbit_metrics( FT_Stream stream,
- TT_SBit_Range range,
- TT_SBit_Metrics metrics );
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
FT_LOCAL( FT_Error )
tt_face_load_sbit_image( TT_Face face,
FT_ULong strike_index,
diff --git a/src/3rdparty/freetype/src/sfnt/ttsbit0.c b/src/3rdparty/freetype/src/sfnt/ttsbit0.c
deleted file mode 100644
index 38bcf210ea..0000000000
--- a/src/3rdparty/freetype/src/sfnt/ttsbit0.c
+++ /dev/null
@@ -1,1011 +0,0 @@
-/***************************************************************************/
-/* */
-/* ttsbit0.c */
-/* */
-/* TrueType and OpenType embedded bitmap support (body). */
-/* This is a heap-optimized version. */
-/* */
-/* Copyright 2005, 2006, 2007, 2008, 2009 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. */
-/* */
-/***************************************************************************/
-
-
-/* This file is included by ttsbit.c */
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_TRUETYPE_TAGS_H
-#include "ttsbit.h"
-
-#include "sferrors.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_ttsbit
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_eblc( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error = SFNT_Err_Ok;
- FT_Fixed version;
- FT_ULong num_strikes, table_size;
- FT_Byte* p;
- FT_Byte* p_limit;
- FT_UInt count;
-
-
- face->sbit_num_strikes = 0;
-
- /* this table is optional */
- error = face->goto_table( face, TTAG_EBLC, stream, &table_size );
- if ( error )
- error = face->goto_table( face, TTAG_bloc, stream, &table_size );
- if ( error )
- goto Exit;
-
- if ( table_size < 8 )
- {
- FT_ERROR(( "tt_face_load_sbit_strikes: table too short\n" ));
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
- if ( FT_FRAME_EXTRACT( table_size, face->sbit_table ) )
- goto Exit;
-
- face->sbit_table_size = table_size;
-
- p = face->sbit_table;
- p_limit = p + table_size;
-
- version = FT_NEXT_ULONG( p );
- num_strikes = FT_NEXT_ULONG( p );
-
- if ( version != 0x00020000UL || num_strikes >= 0x10000UL )
- {
- FT_ERROR(( "tt_face_load_sbit_strikes: invalid table version\n" ));
- error = SFNT_Err_Invalid_File_Format;
- goto Fail;
- }
-
- /*
- * Count the number of strikes available in the table. We are a bit
- * paranoid there and don't trust the data.
- */
- count = (FT_UInt)num_strikes;
- if ( 8 + 48UL * count > table_size )
- count = (FT_UInt)( ( p_limit - p ) / 48 );
-
- face->sbit_num_strikes = count;
-
- FT_TRACE3(( "sbit_num_strikes: %u\n", count ));
- Exit:
- return error;
-
- Fail:
- FT_FRAME_RELEASE( face->sbit_table );
- face->sbit_table_size = 0;
- goto Exit;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_eblc( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
-
-
- FT_FRAME_RELEASE( face->sbit_table );
- face->sbit_table_size = 0;
- face->sbit_num_strikes = 0;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_set_sbit_strike( TT_Face face,
- FT_Size_Request req,
- FT_ULong* astrike_index )
- {
- return FT_Match_Size( (FT_Face)face, req, 0, astrike_index );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_strike_metrics( TT_Face face,
- FT_ULong strike_index,
- FT_Size_Metrics* metrics )
- {
- FT_Byte* strike;
-
-
- if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
- return SFNT_Err_Invalid_Argument;
-
- strike = face->sbit_table + 8 + strike_index * 48;
-
- metrics->x_ppem = (FT_UShort)strike[44];
- metrics->y_ppem = (FT_UShort)strike[45];
-
- metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */
- metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */
- metrics->height = metrics->ascender - metrics->descender;
-
- /* XXX: Is this correct? */
- metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */
- strike[18] + /* max_width */
- (FT_Char)strike[23] /* min_advance_SB */
- ) << 6;
-
- return SFNT_Err_Ok;
- }
-
-
- typedef struct TT_SBitDecoderRec_
- {
- TT_Face face;
- FT_Stream stream;
- FT_Bitmap* bitmap;
- TT_SBit_Metrics metrics;
- FT_Bool metrics_loaded;
- FT_Bool bitmap_allocated;
- FT_Byte bit_depth;
-
- FT_ULong ebdt_start;
- FT_ULong ebdt_size;
-
- FT_ULong strike_index_array;
- FT_ULong strike_index_count;
- FT_Byte* eblc_base;
- FT_Byte* eblc_limit;
-
- } TT_SBitDecoderRec, *TT_SBitDecoder;
-
-
- static FT_Error
- tt_sbit_decoder_init( TT_SBitDecoder decoder,
- TT_Face face,
- FT_ULong strike_index,
- TT_SBit_MetricsRec* metrics )
- {
- FT_Error error;
- FT_Stream stream = face->root.stream;
- FT_ULong ebdt_size;
-
-
- error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
- if ( error )
- error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
- if ( error )
- goto Exit;
-
- decoder->face = face;
- decoder->stream = stream;
- decoder->bitmap = &face->root.glyph->bitmap;
- decoder->metrics = metrics;
-
- decoder->metrics_loaded = 0;
- decoder->bitmap_allocated = 0;
-
- decoder->ebdt_start = FT_STREAM_POS();
- decoder->ebdt_size = ebdt_size;
-
- decoder->eblc_base = face->sbit_table;
- decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
-
- /* now find the strike corresponding to the index */
- {
- FT_Byte* p;
-
-
- if ( 8 + 48 * strike_index + 3 * 4 + 34 + 1 > face->sbit_table_size )
- {
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
- p = decoder->eblc_base + 8 + 48 * strike_index;
-
- decoder->strike_index_array = FT_NEXT_ULONG( p );
- p += 4;
- decoder->strike_index_count = FT_NEXT_ULONG( p );
- p += 34;
- decoder->bit_depth = *p;
-
- if ( decoder->strike_index_array > face->sbit_table_size ||
- decoder->strike_index_array + 8 * decoder->strike_index_count >
- face->sbit_table_size )
- error = SFNT_Err_Invalid_File_Format;
- }
-
- Exit:
- return error;
- }
-
-
- static void
- tt_sbit_decoder_done( TT_SBitDecoder decoder )
- {
- FT_UNUSED( decoder );
- }
-
-
- static FT_Error
- tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder )
- {
- FT_Error error = SFNT_Err_Ok;
- FT_UInt width, height;
- FT_Bitmap* map = decoder->bitmap;
- FT_Long size;
-
-
- if ( !decoder->metrics_loaded )
- {
- error = SFNT_Err_Invalid_Argument;
- goto Exit;
- }
-
- width = decoder->metrics->width;
- height = decoder->metrics->height;
-
- map->width = (int)width;
- map->rows = (int)height;
-
- switch ( decoder->bit_depth )
- {
- case 1:
- map->pixel_mode = FT_PIXEL_MODE_MONO;
- map->pitch = ( map->width + 7 ) >> 3;
- break;
-
- case 2:
- map->pixel_mode = FT_PIXEL_MODE_GRAY2;
- map->pitch = ( map->width + 3 ) >> 2;
- break;
-
- case 4:
- map->pixel_mode = FT_PIXEL_MODE_GRAY4;
- map->pitch = ( map->width + 1 ) >> 1;
- break;
-
- case 8:
- map->pixel_mode = FT_PIXEL_MODE_GRAY;
- map->pitch = map->width;
- break;
-
- default:
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
- size = map->rows * map->pitch;
-
- /* check that there is no empty image */
- if ( size == 0 )
- goto Exit; /* exit successfully! */
-
- error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size );
- if ( error )
- goto Exit;
-
- decoder->bitmap_allocated = 1;
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- tt_sbit_decoder_load_metrics( TT_SBitDecoder decoder,
- FT_Byte* *pp,
- FT_Byte* limit,
- FT_Bool big )
- {
- FT_Byte* p = *pp;
- TT_SBit_Metrics metrics = decoder->metrics;
-
-
- if ( p + 5 > limit )
- goto Fail;
-
- metrics->height = p[0];
- metrics->width = p[1];
- metrics->horiBearingX = (FT_Char)p[2];
- metrics->horiBearingY = (FT_Char)p[3];
- metrics->horiAdvance = p[4];
-
- p += 5;
- if ( big )
- {
- if ( p + 3 > limit )
- goto Fail;
-
- metrics->vertBearingX = (FT_Char)p[0];
- metrics->vertBearingY = (FT_Char)p[1];
- metrics->vertAdvance = p[2];
-
- p += 3;
- }
-
- decoder->metrics_loaded = 1;
- *pp = p;
- return SFNT_Err_Ok;
-
- Fail:
- return SFNT_Err_Invalid_Argument;
- }
-
-
- /* forward declaration */
- static FT_Error
- tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
- FT_UInt glyph_index,
- 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 );
-
-
- static FT_Error
- tt_sbit_decoder_load_byte_aligned( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* limit,
- FT_Int x_pos,
- FT_Int y_pos )
- {
- FT_Error error = SFNT_Err_Ok;
- FT_Byte* line;
- FT_Int bit_height, bit_width, pitch, width, height, h;
- FT_Bitmap* bitmap;
-
-
- if ( !decoder->bitmap_allocated )
- {
- error = tt_sbit_decoder_alloc_bitmap( decoder );
- if ( error )
- goto Exit;
- }
-
- /* check that we can write the glyph into the bitmap */
- bitmap = decoder->bitmap;
- bit_width = bitmap->width;
- bit_height = bitmap->rows;
- pitch = bitmap->pitch;
- line = bitmap->buffer;
-
- width = decoder->metrics->width;
- height = decoder->metrics->height;
-
- if ( x_pos < 0 || x_pos + width > bit_width ||
- y_pos < 0 || y_pos + height > bit_height )
- {
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
- if ( p + ( ( width + 7 ) >> 3 ) * height > limit )
- {
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
- /* now do the blit */
- line += y_pos * pitch + ( x_pos >> 3 );
- x_pos &= 7;
-
- if ( x_pos == 0 ) /* the easy one */
- {
- for ( h = height; h > 0; h--, line += pitch )
- {
- FT_Byte* write = line;
- FT_Int w;
-
-
- for ( w = width; w >= 8; w -= 8 )
- {
- write[0] = (FT_Byte)( write[0] | *p++ );
- write += 1;
- }
-
- if ( w > 0 )
- write[0] = (FT_Byte)( write[0] | ( *p++ & ( 0xFF00U >> w ) ) );
- }
- }
- else /* x_pos > 0 */
- {
- for ( h = height; h > 0; h--, line += pitch )
- {
- FT_Byte* write = line;
- FT_Int w;
- FT_UInt wval = 0;
-
-
- for ( w = width; w >= 8; w -= 8 )
- {
- wval = (FT_UInt)( wval | *p++ );
- write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
- write += 1;
- wval <<= 8;
- }
-
- if ( w > 0 )
- wval = (FT_UInt)( wval | ( *p++ & ( 0xFF00U >> w ) ) );
-
- /* all bits read and there are `x_pos + w' bits to be written */
-
- write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
-
- if ( x_pos + w > 8 )
- {
- write++;
- wval <<= 8;
- write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- /*
- * Load a bit-aligned bitmap (with pointer `p') into a line-aligned bitmap
- * (with pointer `write'). In the example below, the width is 3 pixel,
- * and `x_pos' is 1 pixel.
- *
- * p p+1
- * | | |
- * | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |...
- * | | |
- * +-------+ +-------+ +-------+ ...
- * . . .
- * . . .
- * v . .
- * +-------+ . .
- * | | .
- * | 7 6 5 4 3 2 1 0 | .
- * | | .
- * write . .
- * . .
- * v .
- * +-------+ .
- * | |
- * | 7 6 5 4 3 2 1 0 |
- * | |
- * write+1 .
- * .
- * v
- * +-------+
- * | |
- * | 7 6 5 4 3 2 1 0 |
- * | |
- * write+2
- *
- */
-
- static FT_Error
- tt_sbit_decoder_load_bit_aligned( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* limit,
- FT_Int x_pos,
- FT_Int y_pos )
- {
- FT_Error error = SFNT_Err_Ok;
- FT_Byte* line;
- FT_Int bit_height, bit_width, pitch, width, height, h, nbits;
- FT_Bitmap* bitmap;
- FT_UShort rval;
-
-
- if ( !decoder->bitmap_allocated )
- {
- error = tt_sbit_decoder_alloc_bitmap( decoder );
- if ( error )
- goto Exit;
- }
-
- /* check that we can write the glyph into the bitmap */
- bitmap = decoder->bitmap;
- bit_width = bitmap->width;
- bit_height = bitmap->rows;
- pitch = bitmap->pitch;
- line = bitmap->buffer;
-
- width = decoder->metrics->width;
- height = decoder->metrics->height;
-
- if ( x_pos < 0 || x_pos + width > bit_width ||
- y_pos < 0 || y_pos + height > bit_height )
- {
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
- if ( p + ( ( width * height + 7 ) >> 3 ) > limit )
- {
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
- /* now do the blit */
-
- /* adjust `line' to point to the first byte of the bitmap */
- line += y_pos * pitch + ( x_pos >> 3 );
- x_pos &= 7;
-
- /* the higher byte of `rval' is used as a buffer */
- rval = 0;
- nbits = 0;
-
- for ( h = height; h > 0; h--, line += pitch )
- {
- FT_Byte* write = line;
- FT_Int w = width;
-
-
- /* handle initial byte (in target bitmap) specially if necessary */
- if ( x_pos )
- {
- w = ( width < 8 - x_pos ) ? width : 8 - x_pos;
-
- if ( h == height )
- {
- rval = *p++;
- nbits = x_pos;
- }
- else if ( nbits < w )
- {
- if ( p < limit )
- rval |= *p++;
- nbits += 8 - w;
- }
- else
- {
- rval >>= 8;
- nbits -= w;
- }
-
- *write++ |= ( ( rval >> nbits ) & 0xFF ) &
- ( ~( 0xFF << w ) << ( 8 - w - x_pos ) );
- rval <<= 8;
-
- w = width - w;
- }
-
- /* handle medial bytes */
- for ( ; w >= 8; w -= 8 )
- {
- rval |= *p++;
- *write++ |= ( rval >> nbits ) & 0xFF;
-
- rval <<= 8;
- }
-
- /* handle final byte if necessary */
- if ( w > 0 )
- {
- if ( nbits < w )
- {
- if ( p < limit )
- rval |= *p++;
- *write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
- nbits += 8 - w;
-
- rval <<= 8;
- }
- else
- {
- *write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
- nbits -= w;
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- tt_sbit_decoder_load_compound( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* limit,
- FT_Int x_pos,
- FT_Int y_pos )
- {
- FT_Error error = SFNT_Err_Ok;
- FT_UInt num_components, nn;
-
- FT_Char horiBearingX = decoder->metrics->horiBearingX;
- FT_Char horiBearingY = decoder->metrics->horiBearingY;
- FT_Byte horiAdvance = decoder->metrics->horiAdvance;
- FT_Char vertBearingX = decoder->metrics->vertBearingX;
- FT_Char vertBearingY = decoder->metrics->vertBearingY;
- FT_Byte vertAdvance = decoder->metrics->vertAdvance;
-
-
- if ( p + 2 > limit )
- goto Fail;
-
- num_components = FT_NEXT_USHORT( p );
- if ( p + 4 * num_components > limit )
- goto Fail;
-
- if ( !decoder->bitmap_allocated )
- {
- error = tt_sbit_decoder_alloc_bitmap( decoder );
- if ( error )
- goto Exit;
- }
-
- for ( nn = 0; nn < num_components; nn++ )
- {
- FT_UInt gindex = FT_NEXT_USHORT( p );
- FT_Byte dx = FT_NEXT_BYTE( p );
- FT_Byte dy = FT_NEXT_BYTE( p );
-
-
- /* NB: a recursive call */
- error = tt_sbit_decoder_load_image( decoder, gindex,
- x_pos + dx, y_pos + dy );
- if ( error )
- break;
- }
-
- decoder->metrics->horiBearingX = horiBearingX;
- decoder->metrics->horiBearingY = horiBearingY;
- decoder->metrics->horiAdvance = horiAdvance;
- decoder->metrics->vertBearingX = vertBearingX;
- decoder->metrics->vertBearingY = vertBearingY;
- decoder->metrics->vertAdvance = vertAdvance;
- decoder->metrics->width = (FT_UInt)decoder->bitmap->width;
- decoder->metrics->height = (FT_UInt)decoder->bitmap->rows;
-
- Exit:
- return error;
-
- Fail:
- error = SFNT_Err_Invalid_File_Format;
- goto Exit;
- }
-
-
- static FT_Error
- tt_sbit_decoder_load_bitmap( TT_SBitDecoder decoder,
- FT_UInt glyph_format,
- FT_ULong glyph_start,
- FT_ULong glyph_size,
- FT_Int x_pos,
- FT_Int y_pos )
- {
- FT_Error error;
- FT_Stream stream = decoder->stream;
- FT_Byte* p;
- FT_Byte* p_limit;
- FT_Byte* data;
-
-
- /* seek into the EBDT table now */
- if ( glyph_start + glyph_size > decoder->ebdt_size )
- {
- error = SFNT_Err_Invalid_Argument;
- goto Exit;
- }
-
- if ( FT_STREAM_SEEK( decoder->ebdt_start + glyph_start ) ||
- FT_FRAME_EXTRACT( glyph_size, data ) )
- goto Exit;
-
- p = data;
- p_limit = p + glyph_size;
-
- /* read the data, depending on the glyph format */
- switch ( glyph_format )
- {
- case 1:
- case 2:
- case 8:
- error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 0 );
- break;
-
- case 6:
- case 7:
- case 9:
- error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 );
- break;
-
- default:
- error = SFNT_Err_Ok;
- }
-
- if ( error )
- goto Fail;
-
- {
- TT_SBitDecoder_LoadFunc loader;
-
-
- switch ( glyph_format )
- {
- case 1:
- case 6:
- loader = tt_sbit_decoder_load_byte_aligned;
- break;
-
- case 2:
- case 5:
- case 7:
- loader = tt_sbit_decoder_load_bit_aligned;
- break;
-
- case 8:
- if ( p + 1 > p_limit )
- goto Fail;
-
- p += 1; /* skip padding */
- /* fall-through */
-
- case 9:
- loader = tt_sbit_decoder_load_compound;
- break;
-
- default:
- goto Fail;
- }
-
- error = loader( decoder, p, p_limit, x_pos, y_pos );
- }
-
- Fail:
- FT_FRAME_RELEASE( data );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
- FT_UInt glyph_index,
- FT_Int x_pos,
- FT_Int y_pos )
- {
- /*
- * 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;
- FT_UInt start, end, index_format, image_format;
- FT_ULong image_start = 0, image_end = 0, image_offset;
-
-
- for ( ; num_ranges > 0; num_ranges-- )
- {
- start = FT_NEXT_USHORT( p );
- end = FT_NEXT_USHORT( p );
-
- if ( glyph_index >= start && glyph_index <= end )
- goto FoundRange;
-
- p += 4; /* ignore index offset */
- }
- goto NoBitmap;
-
- FoundRange:
- image_offset = FT_NEXT_ULONG( p );
-
- /* overflow check */
- if ( decoder->eblc_base + decoder->strike_index_array + image_offset <
- decoder->eblc_base )
- goto Failure;
-
- p = decoder->eblc_base + decoder->strike_index_array + image_offset;
- if ( p + 8 > p_limit )
- goto NoBitmap;
-
- /* now find the glyph's location and extend within the ebdt table */
- index_format = FT_NEXT_USHORT( p );
- image_format = FT_NEXT_USHORT( p );
- image_offset = FT_NEXT_ULONG ( p );
-
- switch ( index_format )
- {
- case 1: /* 4-byte offsets relative to `image_offset' */
- {
- p += 4 * ( glyph_index - start );
- if ( p + 8 > p_limit )
- goto NoBitmap;
-
- image_start = FT_NEXT_ULONG( p );
- image_end = FT_NEXT_ULONG( p );
-
- if ( image_start == image_end ) /* missing glyph */
- goto NoBitmap;
- }
- break;
-
- case 2: /* big metrics, constant image size */
- {
- FT_ULong image_size;
-
-
- if ( p + 12 > p_limit )
- goto NoBitmap;
-
- image_size = FT_NEXT_ULONG( p );
-
- if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
- goto NoBitmap;
-
- image_start = image_size * ( glyph_index - start );
- image_end = image_start + image_size;
- }
- break;
-
- case 3: /* 2-byte offsets relative to 'image_offset' */
- {
- p += 2 * ( glyph_index - start );
- if ( p + 4 > p_limit )
- goto NoBitmap;
-
- image_start = FT_NEXT_USHORT( p );
- image_end = FT_NEXT_USHORT( p );
-
- if ( image_start == image_end ) /* missing glyph */
- goto NoBitmap;
- }
- break;
-
- case 4: /* sparse glyph array with (glyph,offset) pairs */
- {
- FT_ULong mm, num_glyphs;
-
-
- if ( p + 4 > p_limit )
- goto NoBitmap;
-
- num_glyphs = FT_NEXT_ULONG( p );
-
- /* overflow check */
- if ( p + ( num_glyphs + 1 ) * 4 < p )
- goto Failure;
-
- if ( p + ( num_glyphs + 1 ) * 4 > p_limit )
- goto NoBitmap;
-
- for ( mm = 0; mm < num_glyphs; mm++ )
- {
- FT_UInt gindex = FT_NEXT_USHORT( p );
-
-
- if ( gindex == glyph_index )
- {
- image_start = FT_NEXT_USHORT( p );
- p += 2;
- image_end = FT_PEEK_USHORT( p );
- break;
- }
- p += 2;
- }
-
- if ( mm >= num_glyphs )
- goto NoBitmap;
- }
- break;
-
- case 5: /* constant metrics with sparse glyph codes */
- {
- FT_ULong image_size, mm, num_glyphs;
-
-
- if ( p + 16 > p_limit )
- goto NoBitmap;
-
- image_size = FT_NEXT_ULONG( p );
-
- if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
- goto NoBitmap;
-
- num_glyphs = FT_NEXT_ULONG( p );
-
- /* overflow check */
- if ( p + 2 * num_glyphs < p )
- goto Failure;
-
- if ( p + 2 * num_glyphs > p_limit )
- goto NoBitmap;
-
- for ( mm = 0; mm < num_glyphs; mm++ )
- {
- FT_UInt gindex = FT_NEXT_USHORT( p );
-
-
- if ( gindex == glyph_index )
- break;
- }
-
- if ( mm >= num_glyphs )
- goto NoBitmap;
-
- image_start = image_size * mm;
- image_end = image_start + image_size;
- }
- break;
-
- default:
- goto NoBitmap;
- }
-
- if ( image_start > image_end )
- goto NoBitmap;
-
- image_end -= image_start;
- image_start = image_offset + image_start;
-
- return tt_sbit_decoder_load_bitmap( decoder,
- image_format,
- image_start,
- image_end,
- x_pos,
- y_pos );
-
- Failure:
- return SFNT_Err_Invalid_Table;
-
- NoBitmap:
- return SFNT_Err_Invalid_Argument;
- }
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_sbit_image( TT_Face face,
- FT_ULong strike_index,
- FT_UInt glyph_index,
- FT_UInt load_flags,
- FT_Stream stream,
- FT_Bitmap *map,
- TT_SBit_MetricsRec *metrics )
- {
- TT_SBitDecoderRec decoder[1];
- FT_Error error;
-
- FT_UNUSED( load_flags );
- FT_UNUSED( stream );
- FT_UNUSED( map );
-
-
- error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
- if ( !error )
- {
- error = tt_sbit_decoder_load_image( decoder, glyph_index, 0, 0 );
- tt_sbit_decoder_done( decoder );
- }
-
- return error;
- }
-
-/* EOF */
diff --git a/src/3rdparty/freetype/src/smooth/ftgrays.c b/src/3rdparty/freetype/src/smooth/ftgrays.c
index 846e454e66..131ad27a0c 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-2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2000-2003, 2005-2014 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 @@
/* */
/* - copy `src/smooth/ftgrays.c' (this file) to your current directory */
/* */
- /* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */
- /* same directory */
+ /* - copy `include/ftimage.h' and `src/smooth/ftgrays.h' to the same */
+ /* directory */
/* */
/* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */
/* */
@@ -94,6 +94,14 @@
#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_BEGIN_STMNT do {
+#define FT_END_STMNT } while ( 0 )
+
+
/* define this to dump debugging information */
/* #define FT_DEBUG_LEVEL_TRACE */
@@ -103,10 +111,12 @@
#include <stdarg.h>
#endif
+#include <stddef.h>
#include <string.h>
#include <setjmp.h>
#include <limits.h>
#define FT_UINT_MAX UINT_MAX
+#define FT_INT_MAX INT_MAX
#define ft_memset memset
@@ -114,6 +124,8 @@
#define ft_longjmp longjmp
#define ft_jmp_buf jmp_buf
+typedef ptrdiff_t FT_PtrDist;
+
#define ErrRaster_Invalid_Mode -2
#define ErrRaster_Invalid_Outline -1
@@ -150,6 +162,21 @@
va_end( ap );
}
+
+ /* empty function useful for setting a breakpoint to catch errors */
+ int
+ FT_Throw( int error,
+ int line,
+ const char* file )
+ {
+ FT_UNUSED( error );
+ FT_UNUSED( line );
+ FT_UNUSED( file );
+
+ return 0;
+ }
+
+
/* we don't handle tracing levels in stand-alone mode; */
#ifndef FT_TRACE5
#define FT_TRACE5( varformat ) FT_Message varformat
@@ -161,11 +188,19 @@
#define FT_ERROR( varformat ) FT_Message varformat
#endif
+#define FT_THROW( e ) \
+ ( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \
+ __LINE__, \
+ __FILE__ ) | \
+ FT_ERR_CAT( ErrRaster, e ) )
+
#else /* !FT_DEBUG_LEVEL_TRACE */
#define FT_TRACE5( x ) do { } while ( 0 ) /* nothing */
#define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */
#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
+#define FT_THROW( e ) FT_ERR_CAT( ErrRaster_, e )
+
#endif /* !FT_DEBUG_LEVEL_TRACE */
@@ -183,7 +218,7 @@
shift_, \
delta_ \
};
-
+
#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, \
raster_new_, raster_reset_, \
raster_set_mode_, raster_render_, \
@@ -198,6 +233,7 @@
raster_done_ \
};
+
#else /* !_STANDALONE_ */
@@ -211,13 +247,14 @@
#include "ftspic.h"
-#define ErrRaster_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
-#define ErrRaster_Invalid_Outline Smooth_Err_Invalid_Outline
+#define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
+#define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
-#define ErrRaster_Invalid_Argument Smooth_Err_Invalid_Argument
+
#endif /* !_STANDALONE_ */
+
#ifndef FT_MEM_SET
#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
#endif
@@ -228,10 +265,15 @@
/* as usual, for the speed hungry :-) */
+#undef RAS_ARG
+#undef RAS_ARG_
+#undef RAS_VAR
+#undef RAS_VAR_
+
#ifndef FT_STATIC_RASTER
-#define RAS_ARG PWorker worker
-#define RAS_ARG_ PWorker worker,
+#define RAS_ARG gray_PWorker worker
+#define RAS_ARG_ gray_PWorker worker,
#define RAS_VAR worker
#define RAS_VAR_ worker,
@@ -249,6 +291,11 @@
/* must be at least 6 bits! */
#define PIXEL_BITS 8
+#undef FLOOR
+#undef CEILING
+#undef TRUNC
+#undef SCALED
+
#define ONE_PIXEL ( 1L << PIXEL_BITS )
#define PIXEL_MASK ( -1L << PIXEL_BITS )
#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) )
@@ -266,6 +313,40 @@
#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. */
+#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
+ FT_BEGIN_STMNT \
+ (quotient) = (type)( (dividend) / (divisor) ); \
+ (remainder) = (type)( (dividend) % (divisor) ); \
+ if ( (remainder) < 0 ) \
+ { \
+ (quotient)--; \
+ (remainder) += (type)(divisor); \
+ } \
+ FT_END_STMNT
+
+#ifdef __arm__
+ /* Work around a bug specific to GCC which make the compiler fail to */
+ /* 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 */
+#undef FT_DIV_MOD
+#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
+ FT_BEGIN_STMNT \
+ (quotient) = (type)( (dividend) / (divisor) ); \
+ (remainder) = (type)( (dividend) - (quotient) * (divisor) ); \
+ if ( (remainder) < 0 ) \
+ { \
+ (quotient)--; \
+ (remainder) += (type)(divisor); \
+ } \
+ FT_END_STMNT
+#endif /* __arm__ */
+
+
/*************************************************************************/
/* */
/* TYPE DEFINITIONS */
@@ -298,7 +379,7 @@
#endif /* PIXEL_BITS >= 8 */
- /* maximal number of gray spans in a call to the span callback */
+ /* maximum number of gray spans in a call to the span callback */
#define FT_MAX_GRAY_SPANS 32
@@ -306,16 +387,26 @@
typedef struct TCell_
{
- TPos x; /* same with TWorker.ex */
- TCoord cover; /* same with TWorker.cover */
- TArea area;
- PCell next;
+ TPos x; /* same with gray_TWorker.ex */
+ TCoord cover; /* same with gray_TWorker.cover */
+ TArea area;
+ PCell next;
} TCell;
- typedef struct TWorker_
+#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
+ /* We disable the warning `structure was padded due to */
+ /* __declspec(align())' in order to compile cleanly with */
+ /* the maximum level of warnings. */
+#pragma warning( push )
+#pragma warning( disable : 4324 )
+#endif /* _MSC_VER */
+
+ typedef struct gray_TWorker_
{
+ ft_jmp_buf jump_buffer;
+
TCoord ex, ey;
TPos min_ex, max_ex;
TPos min_ey, max_ey;
@@ -325,7 +416,7 @@
TCoord cover;
int invalid;
- PCell cells;
+ PCell cells;
FT_PtrDist max_cells;
FT_PtrDist num_cells;
@@ -350,10 +441,6 @@
int band_size;
int band_shoot;
- int conic_level;
- int cubic_level;
-
- ft_jmp_buf jump_buffer;
void* buffer;
long buffer_size;
@@ -361,25 +448,29 @@
PCell* ycells;
TPos ycount;
- } TWorker, *PWorker;
+ } gray_TWorker, *gray_PWorker;
+
+#if defined( _MSC_VER )
+#pragma warning( pop )
+#endif
#ifndef FT_STATIC_RASTER
#define ras (*worker)
#else
- static TWorker ras;
+ static gray_TWorker ras;
#endif
- typedef struct TRaster_
+ typedef struct gray_TRaster_
{
- void* buffer;
- long buffer_size;
- int band_size;
- void* memory;
- PWorker worker;
+ void* buffer;
+ long buffer_size;
+ int band_size;
+ void* memory;
+ gray_PWorker worker;
- } TRaster, *PRaster;
+ } gray_TRaster, *gray_PRaster;
@@ -494,7 +585,7 @@
static void
gray_record_cell( RAS_ARG )
{
- if ( !ras.invalid && ( ras.area | ras.cover ) )
+ if ( ras.area | ras.cover )
{
PCell cell = gray_find_cell( RAS_VAR );
@@ -543,10 +634,10 @@
ras.area = 0;
ras.cover = 0;
+ ras.ex = ex;
+ ras.ey = ey;
}
- ras.ex = ex;
- ras.ey = ey;
ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey ||
ex >= ras.count_ex );
}
@@ -588,7 +679,7 @@
TPos x2,
TCoord y2 )
{
- TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem;
+ TCoord ex1, ex2, fx1, fx2, delta, mod;
long p, first, dx;
int incr;
@@ -632,13 +723,7 @@
dx = -dx;
}
- delta = (TCoord)( p / dx );
- mod = (TCoord)( p % dx );
- if ( mod < 0 )
- {
- delta--;
- mod += (TCoord)dx;
- }
+ FT_DIV_MOD( TCoord, p, dx, delta, mod );
ras.area += (TArea)(( fx1 + first ) * delta);
ras.cover += delta;
@@ -649,14 +734,11 @@
if ( ex1 != ex2 )
{
- p = ONE_PIXEL * ( y2 - y1 + delta );
- lift = (TCoord)( p / dx );
- rem = (TCoord)( p % dx );
- if ( rem < 0 )
- {
- lift--;
- rem += (TCoord)dx;
- }
+ TCoord lift, rem;
+
+
+ p = ONE_PIXEL * ( y2 - y1 + delta );
+ FT_DIV_MOD( TCoord, p, dx, lift, rem );
mod -= (int)dx;
@@ -706,9 +788,6 @@
dx = to_x - ras.x;
dy = to_y - ras.y;
- /* XXX: we should do something about the trivial case where dx == 0, */
- /* as it happens very often! */
-
/* perform vertical clipping */
{
TCoord min, max;
@@ -787,13 +866,7 @@
dy = -dy;
}
- delta = (int)( p / dy );
- mod = (int)( p % dy );
- if ( mod < 0 )
- {
- delta--;
- mod += (TCoord)dy;
- }
+ FT_DIV_MOD( int, p, dy, delta, mod );
x = ras.x + delta;
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first );
@@ -804,13 +877,7 @@
if ( ey1 != ey2 )
{
p = ONE_PIXEL * dx;
- lift = (int)( p / dy );
- rem = (int)( p % dy );
- if ( rem < 0 )
- {
- lift--;
- rem += (int)dy;
- }
+ FT_DIV_MOD( int, p, dy, lift, rem );
mod -= (int)dy;
while ( ey1 != ey2 )
@@ -870,81 +937,59 @@
const FT_Vector* to )
{
TPos dx, dy;
+ TPos min, max, y;
int top, level;
int* levels;
FT_Vector* arc;
- dx = DOWNSCALE( ras.x ) + to->x - ( control->x << 1 );
- if ( dx < 0 )
- dx = -dx;
- dy = DOWNSCALE( ras.y ) + to->y - ( control->y << 1 );
- if ( dy < 0 )
- dy = -dy;
- if ( dx < dy )
- dx = dy;
-
- level = 1;
- dx = dx / ras.conic_level;
- while ( dx > 0 )
- {
- dx >>= 2;
- level++;
- }
-
- /* a shortcut to speed things up */
- if ( level <= 1 )
- {
- /* we compute the mid-point directly in order to avoid */
- /* calling gray_split_conic() */
- TPos to_x, to_y, mid_x, mid_y;
-
-
- to_x = UPSCALE( to->x );
- to_y = UPSCALE( to->y );
- mid_x = ( ras.x + to_x + 2 * UPSCALE( control->x ) ) / 4;
- mid_y = ( ras.y + to_y + 2 * UPSCALE( control->y ) ) / 4;
-
- gray_render_line( RAS_VAR_ mid_x, mid_y );
- gray_render_line( RAS_VAR_ to_x, to_y );
-
- return;
- }
-
- arc = ras.bez_stack;
- levels = ras.lev_stack;
- top = 0;
- levels[0] = level;
+ 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;
- while ( top >= 0 )
- {
- level = levels[top];
- if ( level > 1 )
- {
- /* check that the arc crosses the current band */
- TPos min, max, y;
+ 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;
- min = max = arc[0].y;
+ y = arc[1].y;
+ if ( y < min ) min = y;
+ if ( y > max ) max = 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[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;
- if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
- goto Draw;
+ level = 0;
+ do
+ {
+ dx >>= 2;
+ level++;
+ } while ( dx > ONE_PIXEL / 4 );
+ levels[0] = level;
+
+ do
+ {
+ level = levels[top];
+ if ( level > 0 )
+ {
gray_split_conic( arc );
arc += 2;
top++;
@@ -953,24 +998,11 @@
}
Draw:
- {
- TPos to_x, to_y, mid_x, mid_y;
-
-
- to_x = arc[0].x;
- to_y = arc[0].y;
- mid_x = ( ras.x + to_x + 2 * arc[1].x ) / 4;
- mid_y = ( ras.y + to_y + 2 * arc[1].y ) / 4;
-
- gray_render_line( RAS_VAR_ mid_x, mid_y );
- gray_render_line( RAS_VAR_ to_x, to_y );
-
- top--;
- arc -= 2;
- }
- }
+ gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
+ top--;
+ arc -= 2;
- return;
+ } while ( top >= 0 );
}
@@ -1007,59 +1039,10 @@
const FT_Vector* control2,
const FT_Vector* to )
{
- TPos dx, dy, da, db;
- int top, level;
- int* levels;
FT_Vector* arc;
+ TPos min, max, y;
- dx = DOWNSCALE( ras.x ) + to->x - ( control1->x << 1 );
- if ( dx < 0 )
- dx = -dx;
- dy = DOWNSCALE( ras.y ) + to->y - ( control1->y << 1 );
- if ( dy < 0 )
- dy = -dy;
- if ( dx < dy )
- dx = dy;
- da = dx;
-
- dx = DOWNSCALE( ras.x ) + to->x - 3 * ( control1->x + control2->x );
- if ( dx < 0 )
- dx = -dx;
- dy = DOWNSCALE( ras.y ) + to->y - 3 * ( control1->x + control2->y );
- if ( dy < 0 )
- dy = -dy;
- if ( dx < dy )
- dx = dy;
- db = dx;
-
- level = 1;
- da = da / ras.cubic_level;
- db = db / ras.conic_level;
- while ( da > 0 || db > 0 )
- {
- da >>= 2;
- db >>= 3;
- level++;
- }
-
- if ( level <= 1 )
- {
- TPos to_x, to_y, mid_x, mid_y;
-
-
- to_x = UPSCALE( to->x );
- to_y = UPSCALE( to->y );
- mid_x = ( ras.x + to_x +
- 3 * UPSCALE( control1->x + control2->x ) ) / 8;
- mid_y = ( ras.y + to_y +
- 3 * UPSCALE( control1->y + control2->y ) ) / 8;
-
- gray_render_line( RAS_VAR_ mid_x, mid_y );
- gray_render_line( RAS_VAR_ to_x, to_y );
- return;
- }
-
arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
@@ -1070,69 +1053,109 @@
arc[3].x = ras.x;
arc[3].y = ras.y;
- levels = ras.lev_stack;
- top = 0;
- levels[0] = level;
+ /* Short-cut the arc that crosses the current band. */
+ min = max = arc[0].y;
- while ( top >= 0 )
+ 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;
+
+ for (;;)
{
- level = levels[top];
- if ( level > 1 )
- {
- /* check that the arc crosses the current band */
- TPos min, max, y;
-
-
- 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 ) < 0 )
- goto Draw;
- gray_split_cubic( arc );
- arc += 3;
- top ++;
- levels[top] = levels[top - 1] = level - 1;
- continue;
- }
+ /* Decide whether to split or draw. See `Rapid Termination */
+ /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */
+ /* F. Hain, at */
+ /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camera-ready%20CISST02%202.pdf */
- Draw:
{
- TPos to_x, to_y, mid_x, mid_y;
+ TPos dx, dy, dx_, dy_;
+ TPos dx1, dy1, dx2, dy2;
+ TPos L, s, s_limit;
- to_x = arc[0].x;
- to_y = arc[0].y;
- mid_x = ( ras.x + to_x + 3 * ( arc[1].x + arc[2].x ) ) / 8;
- mid_y = ( ras.y + to_y + 3 * ( arc[1].y + arc[2].y ) ) / 8;
+ /* 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;
- gray_render_line( RAS_VAR_ mid_x, mid_y );
- gray_render_line( RAS_VAR_ to_x, to_y );
- top --;
- arc -= 3;
+ L = FT_HYPOT( dx_, dy_ );
+
+ /* Avoid possible arithmetic overflow below by splitting. */
+ if ( L > 32767 )
+ goto Split;
+
+ /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */
+ s_limit = L * (TPos)( ONE_PIXEL / 6 );
+
+ /* 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 );
+
+ 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 );
+
+ if ( s > s_limit )
+ goto Split;
+
+ /* 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;
+
+ /* No reason to split. */
+ goto Draw;
}
- }
- return;
- }
+ 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;
+ }
+ }
static int
gray_move_to( const FT_Vector* to,
- PWorker worker )
+ gray_PWorker worker )
{
TPos x, y;
/* record current cell, if any */
- gray_record_cell( RAS_VAR );
+ if ( !ras.invalid )
+ gray_record_cell( RAS_VAR );
/* start to a new position */
x = UPSCALE( to->x );
@@ -1148,7 +1171,7 @@
static int
gray_line_to( const FT_Vector* to,
- PWorker worker )
+ gray_PWorker worker )
{
gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
return 0;
@@ -1158,7 +1181,7 @@
static int
gray_conic_to( const FT_Vector* control,
const FT_Vector* to,
- PWorker worker )
+ gray_PWorker worker )
{
gray_render_conic( RAS_VAR_ control, to );
return 0;
@@ -1169,7 +1192,7 @@
gray_cubic_to( const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to,
- PWorker worker )
+ gray_PWorker worker )
{
gray_render_cubic( RAS_VAR_ control1, control2, to );
return 0;
@@ -1180,7 +1203,7 @@
gray_render_span( int y,
int count,
const FT_Span* spans,
- PWorker worker )
+ gray_PWorker worker )
{
unsigned char* p;
FT_Bitmap* map = &worker->target;
@@ -1189,7 +1212,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
@@ -1233,9 +1256,7 @@
TPos area,
TCoord acount )
{
- FT_Span* span;
- int count;
- int coverage;
+ int coverage;
/* compute the coverage line's coverage, depending on the */
@@ -1277,6 +1298,10 @@
if ( coverage )
{
+ FT_Span* span;
+ int count;
+
+
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
@@ -1315,7 +1340,6 @@
ras.num_gray_spans = 0;
ras.span_y = (int)y;
- count = 0;
span = ras.gray_spans;
}
else
@@ -1406,7 +1430,26 @@
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 */
+
}
@@ -1472,8 +1515,11 @@
TPos delta;
- if ( !outline || !func_interface )
- return ErrRaster_Invalid_Argument;
+ if ( !outline )
+ return FT_THROW( Invalid_Outline );
+
+ if ( !func_interface )
+ return FT_THROW( Invalid_Argument );
shift = func_interface->shift;
delta = func_interface->delta;
@@ -1686,17 +1732,17 @@
return error;
Invalid_Outline:
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
}
#endif /* _STANDALONE_ */
- typedef struct TBand_
+ typedef struct gray_TBand_
{
TPos min, max;
- } TBand;
+ } gray_TBand;
FT_DEFINE_OUTLINE_FUNCS(func_interface,
(FT_Outline_MoveTo_Func) gray_move_to,
@@ -1721,10 +1767,11 @@
if ( ft_setjmp( ras.jump_buffer ) == 0 )
{
error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
- gray_record_cell( RAS_VAR );
+ if ( !ras.invalid )
+ gray_record_cell( RAS_VAR );
}
else
- error = ErrRaster_Memory_Overflow;
+ error = FT_THROW( Memory_Overflow );
return error;
}
@@ -1733,11 +1780,11 @@
static int
gray_convert_glyph( RAS_ARG )
{
- TBand bands[40];
- TBand* volatile band;
- int volatile n, num_bands;
- TPos volatile min, max, max_y;
- FT_BBox* clip;
+ 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 */
@@ -1759,25 +1806,6 @@
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
- /* simple heuristic used to speed up the bezier decomposition -- see */
- /* the code in gray_render_conic() and gray_render_cubic() for more */
- /* details */
- ras.conic_level = 32;
- ras.cubic_level = 16;
-
- {
- int level = 0;
-
-
- if ( ras.count_ex > 24 || ras.count_ey > 24 )
- level++;
- if ( ras.count_ex > 120 || ras.count_ey > 120 )
- level++;
-
- ras.conic_level <<= level;
- ras.cubic_level <<= level;
- }
-
/* set up vertical bands */
num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size );
if ( num_bands == 0 )
@@ -1820,7 +1848,7 @@
cell_start += sizeof ( TCell ) - cell_mod;
cell_end = ras.buffer_size;
- cell_end -= cell_end % sizeof( TCell );
+ cell_end -= cell_end % sizeof ( TCell );
cells_max = (PCell)( (char*)ras.buffer + cell_end );
ras.cells = (PCell)( (char*)ras.buffer + cell_start );
@@ -1887,30 +1915,30 @@
static int
- gray_raster_render( PRaster raster,
+ gray_raster_render( gray_PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
- PWorker worker;
+ gray_PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
- return ErrRaster_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( !outline )
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return 0;
if ( !outline->contours || !outline->points )
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
worker = raster->worker;
@@ -1918,19 +1946,19 @@
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
if ( !target_map )
- return ErrRaster_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return 0;
if ( !target_map->buffer )
- return ErrRaster_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
- return ErrRaster_Invalid_Mode;
+ return FT_THROW( Invalid_Mode );
/* compute clipping box */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
@@ -1984,7 +2012,7 @@
gray_raster_new( void* memory,
FT_Raster* araster )
{
- static TRaster the_raster;
+ static gray_TRaster the_raster;
FT_UNUSED( memory );
@@ -2003,21 +2031,21 @@
FT_UNUSED( raster );
}
-#else /* _STANDALONE_ */
+#else /* !_STANDALONE_ */
static int
gray_raster_new( FT_Memory memory,
FT_Raster* araster )
{
- FT_Error error;
- PRaster raster;
+ FT_Error error;
+ gray_PRaster raster = NULL;
*araster = 0;
- if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) )
+ if ( !FT_ALLOC( raster, sizeof ( gray_TRaster ) ) )
{
raster->memory = memory;
- *araster = (FT_Raster)raster;
+ *araster = (FT_Raster)raster;
}
return error;
@@ -2027,13 +2055,13 @@
static void
gray_raster_done( FT_Raster raster )
{
- FT_Memory memory = (FT_Memory)((PRaster)raster)->memory;
+ FT_Memory memory = (FT_Memory)((gray_PRaster)raster)->memory;
FT_FREE( raster );
}
-#endif /* _STANDALONE_ */
+#endif /* !_STANDALONE_ */
static void
@@ -2041,19 +2069,20 @@
char* pool_base,
long pool_size )
{
- PRaster rast = (PRaster)raster;
+ gray_PRaster rast = (gray_PRaster)raster;
if ( raster )
{
- if ( pool_base && pool_size >= (long)sizeof ( TWorker ) + 2048 )
+ if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 )
{
- PWorker worker = (PWorker)pool_base;
+ gray_PWorker worker = (gray_PWorker)pool_base;
rast->worker = worker;
rast->buffer = pool_base +
- ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) &
+ ( ( sizeof ( gray_TWorker ) +
+ sizeof ( TCell ) - 1 ) &
~( sizeof ( TCell ) - 1 ) );
rast->buffer_size = (long)( ( pool_base + pool_size ) -
(char*)rast->buffer ) &
@@ -2071,12 +2100,26 @@
}
+ static int
+ gray_raster_set_mode( FT_Raster raster,
+ unsigned long mode,
+ void* args )
+ {
+ FT_UNUSED( raster );
+ FT_UNUSED( mode );
+ FT_UNUSED( args );
+
+
+ return 0; /* nothing to do */
+ }
+
+
FT_DEFINE_RASTER_FUNCS(ft_grays_raster,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Raster_New_Func) gray_raster_new,
(FT_Raster_Reset_Func) gray_raster_reset,
- (FT_Raster_Set_Mode_Func)0,
+ (FT_Raster_Set_Mode_Func)gray_raster_set_mode,
(FT_Raster_Render_Func) gray_raster_render,
(FT_Raster_Done_Func) gray_raster_done
)
diff --git a/src/3rdparty/freetype/src/smooth/ftsmerrs.h b/src/3rdparty/freetype/src/smooth/ftsmerrs.h
index 0c2a2ecd90..413d2f1f70 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Smooth_Err_
#define FT_ERR_BASE FT_Mod_Err_Smooth
diff --git a/src/3rdparty/freetype/src/smooth/ftsmooth.c b/src/3rdparty/freetype/src/smooth/ftsmooth.c
index eed6353157..4e2dee562b 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-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2000-2006, 2009-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,12 +61,12 @@
const FT_Matrix* matrix,
const FT_Vector* delta )
{
- FT_Error error = Smooth_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
- error = Smooth_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -103,74 +103,79 @@
FT_Render_Mode required_mode )
{
FT_Error error;
- FT_Outline* outline = NULL;
+ FT_Outline* outline = &slot->outline;
+ FT_Bitmap* bitmap = &slot->bitmap;
+ FT_Memory memory = render->root.memory;
FT_BBox cbox;
- FT_UInt width, height, height_org, width_org, pitch;
- FT_Bitmap* bitmap;
- FT_Memory memory;
- FT_Int hmul = mode == FT_RENDER_MODE_LCD;
- FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
- FT_Pos x_shift, y_shift, x_left, y_top;
+ 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_Raster_Params params;
+ FT_Bool have_outline_shifted = FALSE;
+ FT_Bool have_buffer = FALSE;
+
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
- error = Smooth_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* check mode */
if ( mode != required_mode )
- return Smooth_Err_Cannot_Render_Glyph;
-
- outline = &slot->outline;
+ {
+ error = FT_THROW( Cannot_Render_Glyph );
+ goto Exit;
+ }
- /* translate the outline to the new origin if needed */
if ( origin )
- FT_Outline_Translate( outline, origin->x, origin->y );
+ {
+ x_shift = origin->x;
+ y_shift = origin->y;
+ }
/* compute the control box, and grid fit it */
+ /* taking into account the origin shift */
FT_Outline_Get_CBox( outline, &cbox );
- cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
- cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
- cbox.xMax = FT_PIX_CEIL( cbox.xMax );
- cbox.yMax = FT_PIX_CEIL( cbox.yMax );
+ cbox.xMin = FT_PIX_FLOOR( cbox.xMin + x_shift );
+ cbox.yMin = FT_PIX_FLOOR( cbox.yMin + y_shift );
+ cbox.xMax = FT_PIX_CEIL( cbox.xMax + x_shift );
+ cbox.yMax = FT_PIX_CEIL( cbox.yMax + y_shift );
+
+ x_shift -= cbox.xMin;
+ y_shift -= cbox.yMin;
+
+ x_left = cbox.xMin >> 6;
+ y_top = cbox.yMax >> 6;
- width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
- height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
- bitmap = &slot->bitmap;
- memory = render->root.memory;
+ width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6;
+ height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6;
+#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
width_org = width;
height_org = height;
+#endif
- /* release old bitmap buffer */
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- /* allocate new one */
pitch = width;
if ( hmul )
{
- width = width * 3;
- pitch = FT_PAD_CEIL( width, 4 );
+ width *= 3;
+ pitch = FT_PAD_CEIL( width, 4 );
}
if ( vmul )
height *= 3;
- x_shift = (FT_Int) cbox.xMin;
- y_shift = (FT_Int) cbox.yMin;
- x_left = (FT_Int)( cbox.xMin >> 6 );
- y_top = (FT_Int)( cbox.yMax >> 6 );
-
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
if ( slot->library->lcd_filter_func )
@@ -180,34 +185,61 @@
if ( hmul )
{
- x_shift -= 64 * ( extra >> 1 );
+ x_shift += 64 * ( extra >> 1 );
+ x_left -= extra >> 1;
width += 3 * extra;
pitch = FT_PAD_CEIL( width, 4 );
- x_left -= extra >> 1;
}
if ( vmul )
{
- y_shift -= 64 * ( extra >> 1 );
- height += 3 * extra;
+ y_shift += 64 * ( extra >> 1 );
y_top += extra >> 1;
+ height += 3 * extra;
}
}
#endif
-#if FT_UINT_MAX > 0xFFFFU
+ /*
+ * XXX: on 16bit system, we return an error for huge bitmap
+ * to prevent an overflow.
+ */
+ if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX ||
+ x_left < FT_INT_MIN || y_top < FT_INT_MIN )
+ {
+ error = FT_THROW( Invalid_Pixel_Size );
+ goto Exit;
+ }
- /* Required check is ( pitch * height < FT_ULONG_MAX ), */
- /* but we care realistic cases only. Always pitch <= width. */
- if ( width > 0xFFFFU || height > 0xFFFFU )
+ /* 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: %d x %d\n",
+ FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n",
width, height ));
- return Smooth_Err_Raster_Overflow;
+ error = FT_THROW( Raster_Overflow );
+ goto Exit;
}
-#endif
+ /* release old bitmap buffer */
+ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
+ {
+ FT_FREE( bitmap->buffer );
+ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
+ }
+
+ /* allocate new one */
+ if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
+ goto Exit;
+ else
+ have_buffer = TRUE;
+
+ slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
+
+ slot->format = FT_GLYPH_FORMAT_BITMAP;
+ slot->bitmap_left = (FT_Int)x_left;
+ slot->bitmap_top = (FT_Int)y_top;
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->num_grays = 256;
@@ -216,12 +248,11 @@
bitmap->pitch = pitch;
/* translate outline to render it into the bitmap */
- FT_Outline_Translate( outline, -x_shift, -y_shift );
-
- if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
- goto Exit;
-
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
+ if ( x_shift || y_shift )
+ {
+ FT_Outline_Translate( outline, x_shift, y_shift );
+ have_outline_shifted = TRUE;
+ }
/* set up parameters */
params.target = bitmap;
@@ -265,6 +296,9 @@
vec->y /= 3;
}
+ if ( error )
+ goto Exit;
+
if ( slot->library->lcd_filter_func )
slot->library->lcd_filter_func( bitmap, mode, slot->library );
@@ -272,6 +306,8 @@
/* render outline into bitmap */
error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
/* expand it horizontally */
if ( hmul )
@@ -323,25 +359,19 @@
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
- FT_Outline_Translate( outline, x_shift, y_shift );
-
- /*
- * 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 )
- return Smooth_Err_Invalid_Pixel_Size;
+ /* everything is fine; don't deallocate buffer */
+ have_buffer = FALSE;
- if ( error )
- goto Exit;
-
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = (FT_Int)x_left;
- slot->bitmap_top = (FT_Int)y_top;
+ error = FT_Err_Ok;
Exit:
- if ( outline && origin )
- FT_Outline_Translate( outline, -origin->x, -origin->y );
+ if ( have_outline_shifted )
+ FT_Outline_Translate( outline, -x_shift, -y_shift );
+ if ( have_buffer )
+ {
+ FT_FREE( bitmap->buffer );
+ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
+ }
return error;
}
@@ -398,10 +428,10 @@
}
- FT_DEFINE_RENDERER(ft_smooth_renderer_class,
+ FT_DEFINE_RENDERER( ft_smooth_renderer_class,
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"smooth",
0x10000L,
@@ -425,10 +455,10 @@
)
- FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class,
-
+ FT_DEFINE_RENDERER( ft_smooth_lcd_renderer_class,
+
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"smooth-lcd",
0x10000L,
@@ -451,10 +481,10 @@
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
- FT_DEFINE_RENDERER(ft_smooth_lcdv_renderer_class,
+ FT_DEFINE_RENDERER( ft_smooth_lcdv_renderer_class,
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"smooth-lcdv",
0x10000L,
diff --git a/src/3rdparty/freetype/src/smooth/ftspic.c b/src/3rdparty/freetype/src/smooth/ftspic.c
index aa547fceb6..67a2b8310c 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 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,22 +20,31 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "ftspic.h"
+#include "ftsmerrs.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftgrays.c */
- void FT_Init_Class_ft_grays_raster(FT_Raster_Funcs*);
+ void
+ FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs );
+
void
- ft_smooth_renderer_class_pic_free( FT_Library library )
+ ft_smooth_renderer_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->smooth )
{
- SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
- if(--container->ref_count)
+ SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
+
+
+ if ( --container->ref_count )
return;
+
FT_FREE( container );
pic_container->smooth = NULL;
}
@@ -43,52 +52,64 @@
FT_Error
- ft_smooth_renderer_class_pic_init( FT_Library library )
+ ft_smooth_renderer_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- SmoothPIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ SmoothPIC* container = NULL;
+ FT_Memory memory = library->memory;
+
- /* since this function also serve smooth_lcd and smooth_lcdv renderers,
+ /* since this function also serve smooth_lcd and smooth_lcdv renderers,
it implements reference counting */
- if(pic_container->smooth)
+ if ( pic_container->smooth )
{
((SmoothPIC*)pic_container->smooth)->ref_count++;
return error;
}
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->smooth = container;
+
container->ref_count = 1;
- /* initialize pointer table - this is how the module usually expects this data */
- FT_Init_Class_ft_grays_raster(&container->ft_grays_raster);
-/*Exit:*/
- if(error)
- ft_smooth_renderer_class_pic_free(library);
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ FT_Init_Class_ft_grays_raster( &container->ft_grays_raster );
+
return error;
}
+
/* re-route these init and free functions to the above functions */
- FT_Error ft_smooth_lcd_renderer_class_pic_init(FT_Library library)
+ FT_Error
+ ft_smooth_lcd_renderer_class_pic_init( FT_Library library )
{
- return ft_smooth_renderer_class_pic_init(library);
+ return ft_smooth_renderer_class_pic_init( library );
}
- void ft_smooth_lcd_renderer_class_pic_free(FT_Library library)
+
+
+ void
+ ft_smooth_lcd_renderer_class_pic_free( FT_Library library )
{
- ft_smooth_renderer_class_pic_free(library);
+ ft_smooth_renderer_class_pic_free( library );
}
- FT_Error ft_smooth_lcdv_renderer_class_pic_init(FT_Library library)
+
+
+ FT_Error
+ ft_smooth_lcdv_renderer_class_pic_init( FT_Library library )
{
- return ft_smooth_renderer_class_pic_init(library);
+ return ft_smooth_renderer_class_pic_init( library );
}
- void ft_smooth_lcdv_renderer_class_pic_free(FT_Library library)
+
+
+ void
+ ft_smooth_lcdv_renderer_class_pic_free( FT_Library library )
{
- ft_smooth_renderer_class_pic_free(library);
+ ft_smooth_renderer_class_pic_free( library );
}
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/smooth/ftspic.h b/src/3rdparty/freetype/src/smooth/ftspic.h
index c7e0ce9d89..334b51c3f1 100644
--- a/src/3rdparty/freetype/src/smooth/ftspic.h
+++ b/src/3rdparty/freetype/src/smooth/ftspic.h
@@ -19,24 +19,48 @@
#ifndef __FTSPIC_H__
#define __FTSPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_GRAYS_RASTER_GET ft_grays_raster
+
+#define FT_GRAYS_RASTER_GET ft_grays_raster
#else /* FT_CONFIG_OPTION_PIC */
- typedef struct SmoothPIC_
+ typedef struct SmoothPIC_
{
- int ref_count;
- FT_Raster_Funcs ft_grays_raster;
+ int ref_count;
+ FT_Raster_Funcs ft_grays_raster;
+
} SmoothPIC;
-#define GET_PIC(lib) ((SmoothPIC*)((lib)->pic_container.smooth))
-#define FT_GRAYS_RASTER_GET (GET_PIC(library)->ft_grays_raster)
+
+#define GET_PIC( lib ) \
+ ( (SmoothPIC*)( (lib)->pic_container.smooth ) )
+#define FT_GRAYS_RASTER_GET ( GET_PIC( library )->ft_grays_raster )
+
+
+ /* see ftspic.c for the implementation */
+ void
+ ft_smooth_renderer_class_pic_free( FT_Library library );
+
+ void
+ ft_smooth_lcd_renderer_class_pic_free( FT_Library library );
+
+ void
+ ft_smooth_lcdv_renderer_class_pic_free( FT_Library library );
+
+ FT_Error
+ ft_smooth_renderer_class_pic_init( FT_Library library );
+
+ FT_Error
+ ft_smooth_lcd_renderer_class_pic_init( FT_Library library );
+
+ FT_Error
+ ft_smooth_lcdv_renderer_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/smooth/rules.mk b/src/3rdparty/freetype/src/smooth/rules.mk
index 4f27f01dba..88d0aa53ac 100644
--- a/src/3rdparty/freetype/src/smooth/rules.mk
+++ b/src/3rdparty/freetype/src/smooth/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2001, 2003 by
+# Copyright 1996-2000, 2001, 2003, 2011 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -25,7 +25,8 @@ SMOOTH_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SMOOTH_DIR))
# smooth driver sources (i.e., C files)
#
SMOOTH_DRV_SRC := $(SMOOTH_DIR)/ftgrays.c \
- $(SMOOTH_DIR)/ftsmooth.c
+ $(SMOOTH_DIR)/ftsmooth.c \
+ $(SMOOTH_DIR)/ftspic.c
# smooth driver headers
diff --git a/src/3rdparty/freetype/src/tools/afblue.pl b/src/3rdparty/freetype/src/tools/afblue.pl
new file mode 100644
index 0000000000..60fe6966a8
--- /dev/null
+++ b/src/3rdparty/freetype/src/tools/afblue.pl
@@ -0,0 +1,548 @@
+#! /usr/bin/perl -w
+# -*- Perl -*-
+#
+# afblue.pl
+#
+# Process a blue zone character data file.
+#
+# Copyright 2013, 2014 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.
+
+use strict;
+use warnings;
+use English '-no_match_vars';
+use open ':std', ':encoding(UTF-8)';
+
+
+my $prog = $PROGRAM_NAME;
+$prog =~ s| .* / ||x; # Remove path.
+
+die "usage: $prog datafile < infile > outfile\n" if $#ARGV != 0;
+
+
+my $datafile = $ARGV[0];
+
+my %diversions; # The extracted and massaged data from `datafile'.
+my @else_stack; # Booleans to track else-clauses.
+my @name_stack; # Stack of integers used for names of aux. variables.
+
+my $curr_enum; # Name of the current enumeration.
+my $curr_array; # Name of the current array.
+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 $have_sections = 0; # Boolean; set if start of a section has been seen.
+my $have_strings; # Boolean; set if current section contains strings.
+my $have_blocks; # Boolean; set if current section contains blocks.
+
+my $have_enum_element; # Boolean; set if we have an enumeration element.
+my $in_string; # Boolean; set if a string has been parsed.
+
+my $num_sections = 0; # Number of sections seen so far.
+
+my $last_aux; # Name of last auxiliary variable.
+
+
+# Regular expressions.
+
+# [<ws>] <enum_name> <ws> <array_name> <ws> <max_name> [<ws>] ':' [<ws>] '\n'
+my $section_re = qr/ ^ \s* (\S+) \s+ (\S+) \s+ (\S+) \s* : \s* $ /x;
+
+# [<ws>] <enum_element_name> [<ws>] '\n'
+my $enum_element_re = qr/ ^ \s* ( [A-Za-z0-9_]+ ) \s* $ /x;
+
+# '#' <preprocessor directive> '\n'
+my $preprocessor_re = qr/ ^ \# /x;
+
+# [<ws>] '/' '/' <comment> '\n'
+my $comment_re = qr| ^ \s* // |x;
+
+# empty line
+my $whitespace_only_re = qr/ ^ \s* $ /x;
+
+# [<ws>] '"' <string> '"' [<ws>] '\n' (<string> doesn't contain newlines)
+my $string_re = qr/ ^ \s*
+ " ( (?> (?: (?> [^"\\]+ ) | \\. )* ) ) "
+ \s* $ /x;
+
+# [<ws>] '{' <block> '}' [<ws>] '\n' (<block> can contain newlines)
+my $block_start_re = qr/ ^ \s* \{ /x;
+
+# We need the capturing group for `split' to make it return the separator
+# tokens (i.e., the opening and closing brace) also.
+my $brace_re = qr/ ( [{}] ) /x;
+
+
+sub Warn
+{
+ my $message = shift;
+ warn "$datafile:$INPUT_LINE_NUMBER: warning: $message\n";
+}
+
+
+sub Die
+{
+ my $message = shift;
+ die "$datafile:$INPUT_LINE_NUMBER: error: $message\n";
+}
+
+
+my $warned_before = 0;
+
+sub warn_before
+{
+ Warn("data before first section gets ignored") unless $warned_before;
+ $warned_before = 1;
+}
+
+
+sub strip_newline
+{
+ chomp;
+ s/ \x0D $ //x;
+}
+
+
+sub end_curr_string
+{
+ # Append final null byte to string.
+ if ($have_strings)
+ {
+ push @{$diversions{$curr_array}}, " '\\0',\n" if $in_string;
+
+ $curr_offset++;
+ $in_string = 0;
+ }
+}
+
+
+sub update_max_elem_size
+{
+ if ($curr_elem_size)
+ {
+ my $max = pop @{$diversions{$curr_max}};
+ $max = $curr_elem_size if $curr_elem_size > $max;
+ push @{$diversions{$curr_max}}, $max;
+ }
+}
+
+
+sub convert_non_ascii_char
+{
+ # A UTF-8 character outside of the printable ASCII range, with possibly a
+ # leading backslash character.
+ my $s = shift;
+
+ # Here we count characters, not bytes.
+ $curr_elem_size += length $s;
+
+ utf8::encode($s);
+ $s = uc unpack 'H*', $s;
+
+ $curr_offset += $s =~ s/\G(..)/'\\x$1', /sg;
+
+ return $s;
+}
+
+
+sub convert_ascii_chars
+{
+ # A series of ASCII characters in the printable range.
+ my $s = shift;
+
+ # We ignore spaces.
+ $s =~ s/ //g;
+
+ my $count = $s =~ s/\G(.)/'$1', /g;
+ $curr_offset += $count;
+ $curr_elem_size += $count;
+
+ return $s;
+}
+
+
+sub convert_literal
+{
+ my $s = shift;
+ my $orig = $s;
+
+ # ASCII printables and space
+ my $safe_re = '\x20-\x7E';
+ # ASCII printables and space, no backslash
+ my $safe_no_backslash_re = '\x20-\x5B\x5D-\x7E';
+
+ $s =~ s{
+ (?: \\? ( [^$safe_re] )
+ | ( (?: [$safe_no_backslash_re]
+ | \\ [$safe_re] )+ ) )
+ }
+ {
+ defined($1) ? convert_non_ascii_char($1)
+ : convert_ascii_chars($2)
+ }egx;
+
+ # We assume that `$orig' doesn't contain `*/'
+ return $s . " /* $orig */";
+}
+
+
+sub aux_name
+{
+ return "af_blue_" . $num_sections. "_" . join('_', @name_stack);
+}
+
+
+sub aux_name_next
+{
+ $name_stack[$#name_stack]++;
+ my $name = aux_name();
+ $name_stack[$#name_stack]--;
+
+ return $name;
+}
+
+
+sub enum_val_string
+{
+ # Build string that holds code to save the current offset in an
+ # enumeration element.
+ my $aux = shift;
+
+ my $add = ($last_aux eq "af_blue_" . $num_sections . "_0" )
+ ? ""
+ : "$last_aux + ";
+
+ return " $aux = $add$curr_offset,\n";
+}
+
+
+
+# Process data file.
+
+open(DATA, $datafile) || die "$prog: can't open \`$datafile': $OS_ERROR\n";
+
+while (<DATA>)
+{
+ strip_newline();
+
+ next if /$comment_re/;
+ next if /$whitespace_only_re/;
+
+ if (/$section_re/)
+ {
+ Warn("previous section is empty") if ($have_sections
+ && !$have_strings
+ && !$have_blocks);
+
+ end_curr_string();
+ update_max_elem_size();
+
+ # Save captured groups from `section_re'.
+ $curr_enum = $1;
+ $curr_array = $2;
+ $curr_max = $3;
+
+ $curr_enum_element = "";
+ $curr_offset = 0;
+
+ Warn("overwriting already defined enumeration \`$curr_enum'")
+ if exists($diversions{$curr_enum});
+ Warn("overwriting already defined array \`$curr_array'")
+ if exists($diversions{$curr_array});
+ Warn("overwriting already defined maximum value \`$curr_max'")
+ if exists($diversions{$curr_max});
+
+ $diversions{$curr_enum} = [];
+ $diversions{$curr_array} = [];
+ $diversions{$curr_max} = [];
+
+ push @{$diversions{$curr_max}}, 0;
+
+ @name_stack = ();
+ push @name_stack, 0;
+
+ $have_sections = 1;
+ $have_strings = 0;
+ $have_blocks = 0;
+
+ $have_enum_element = 0;
+ $in_string = 0;
+
+ $num_sections++;
+ $curr_elem_size = 0;
+
+ $last_aux = aux_name();
+
+ next;
+ }
+
+ if (/$preprocessor_re/)
+ {
+ if ($have_sections)
+ {
+ # Having preprocessor conditionals complicates the computation of
+ # correct offset values. We have to introduce auxiliary enumeration
+ # elements with the name `af_blue_<s>_<n1>_<n2>_...' that store
+ # offsets to be used in conditional clauses. `<s>' is the number of
+ # sections seen so far, `<n1>' is the number of `#if' and `#endif'
+ # conditionals seen so far in the topmost level, `<n2>' the number of
+ # `#if' and `#endif' conditionals seen so far one level deeper, etc.
+ # As a consequence, uneven values are used within a clause, and even
+ # values after a clause, since the C standard doesn't allow the
+ # redefinition of an enumeration value. For example, the name
+ # `af_blue_5_1_6' is used to construct enumeration values in the fifth
+ # section after the third (second-level) if-clause within the first
+ # (top-level) if-clause. After the first top-level clause has
+ # finished, `af_blue_5_2' is used. The current offset is then
+ # relative to the value stored in the current auxiliary element.
+
+ if (/ ^ \# \s* if /x)
+ {
+ push @else_stack, 0;
+
+ $name_stack[$#name_stack]++;
+
+ push @{$diversions{$curr_enum}}, enum_val_string(aux_name());
+ $last_aux = aux_name();
+
+ push @name_stack, 0;
+
+ $curr_offset = 0;
+ }
+ elsif (/ ^ \# \s* elif /x)
+ {
+ Die("unbalanced #elif") unless @else_stack;
+
+ pop @name_stack;
+
+ push @{$diversions{$curr_enum}}, enum_val_string(aux_name_next());
+ $last_aux = aux_name();
+
+ push @name_stack, 0;
+
+ $curr_offset = 0;
+ }
+ elsif (/ ^ \# \s* else /x)
+ {
+ my $prev_else = pop @else_stack;
+ Die("unbalanced #else") unless defined($prev_else);
+ Die("#else already seen") if $prev_else;
+ push @else_stack, 1;
+
+ pop @name_stack;
+
+ push @{$diversions{$curr_enum}}, enum_val_string(aux_name_next());
+ $last_aux = aux_name();
+
+ push @name_stack, 0;
+
+ $curr_offset = 0;
+ }
+ elsif (/ ^ (\# \s*) endif /x)
+ {
+ my $prev_else = pop @else_stack;
+ Die("unbalanced #endif") unless defined($prev_else);
+
+ pop @name_stack;
+
+ # If there is no else-clause for an if-clause, we add one. This is
+ # necessary to have correct offsets.
+ if (!$prev_else)
+ {
+ # Use amount of whitespace from `endif'.
+ push @{$diversions{$curr_enum}}, enum_val_string(aux_name_next())
+ . $1 . "else\n";
+ $last_aux = aux_name();
+
+ $curr_offset = 0;
+ }
+
+ $name_stack[$#name_stack]++;
+
+ push @{$diversions{$curr_enum}}, enum_val_string(aux_name());
+ $last_aux = aux_name();
+
+ $curr_offset = 0;
+ }
+
+ # Handle (probably continued) preprocessor lines.
+ CONTINUED_LOOP:
+ {
+ do
+ {
+ strip_newline();
+
+ push @{$diversions{$curr_enum}}, $ARG . "\n";
+ push @{$diversions{$curr_array}}, $ARG . "\n";
+
+ last CONTINUED_LOOP unless / \\ $ /x;
+
+ } while (<DATA>);
+ }
+ }
+ else
+ {
+ warn_before();
+ }
+
+ next;
+ }
+
+ if (/$enum_element_re/)
+ {
+ end_curr_string();
+ update_max_elem_size();
+
+ $curr_enum_element = $1;
+ $have_enum_element = 1;
+ $curr_elem_size = 0;
+
+ next;
+ }
+
+ if (/$string_re/)
+ {
+ if ($have_sections)
+ {
+ Die("strings and blocks can't be mixed in a section") if $have_blocks;
+
+ # Save captured group from `string_re'.
+ my $string = $1;
+
+ if ($have_enum_element)
+ {
+ push @{$diversions{$curr_enum}}, enum_val_string($curr_enum_element);
+ $have_enum_element = 0;
+ }
+
+ $string = convert_literal($string);
+
+ push @{$diversions{$curr_array}}, " $string\n";
+
+ $have_strings = 1;
+ $in_string = 1;
+ }
+ else
+ {
+ warn_before();
+ }
+
+ next;
+ }
+
+ if (/$block_start_re/)
+ {
+ if ($have_sections)
+ {
+ Die("strings and blocks can't be mixed in a section") if $have_strings;
+
+ my $depth = 0;
+ my $block = "";
+ my $block_end = 0;
+
+ # Count braces while getting the block.
+ BRACE_LOOP:
+ {
+ do
+ {
+ strip_newline();
+
+ foreach my $substring (split(/$brace_re/))
+ {
+ if ($block_end)
+ {
+ Die("invalid data after last matching closing brace")
+ if $substring !~ /$whitespace_only_re/;
+ }
+
+ $block .= $substring;
+
+ if ($substring eq '{')
+ {
+ $depth++;
+ }
+ elsif ($substring eq '}')
+ {
+ $depth--;
+
+ $block_end = 1 if $depth == 0;
+ }
+ }
+
+ # If we are here, we have run out of substrings, so get next line
+ # or exit.
+ last BRACE_LOOP if $block_end;
+
+ $block .= "\n";
+
+ } while (<DATA>);
+ }
+
+ if ($have_enum_element)
+ {
+ push @{$diversions{$curr_enum}}, enum_val_string($curr_enum_element);
+ $have_enum_element = 0;
+ }
+
+ push @{$diversions{$curr_array}}, $block . ",\n";
+
+ $curr_offset++;
+ $curr_elem_size++;
+
+ $have_blocks = 1;
+ }
+ else
+ {
+ warn_before();
+ }
+
+ next;
+ }
+
+ # Garbage. We weren't able to parse the data.
+ Die("syntax error");
+}
+
+# Finalize data.
+end_curr_string();
+update_max_elem_size();
+
+
+# Filter stdin to stdout, replacing `@...@' templates.
+
+sub emit_diversion
+{
+ my $diversion_name = shift;
+ return (exists($diversions{$1})) ? "@{$diversions{$1}}"
+ : "@" . $diversion_name . "@";
+}
+
+
+$LIST_SEPARATOR = '';
+
+my $s1 = "This file has been generated by the Perl script \`$prog',";
+my $s1len = length $s1;
+my $s2 = "using data from file \`$datafile'.";
+my $s2len = length $s2;
+my $slen = ($s1len > $s2len) ? $s1len : $s2len;
+
+print "/* " . $s1 . " " x ($slen - $s1len) . " */\n"
+ . "/* " . $s2 . " " x ($slen - $s2len) . " */\n"
+ . "\n";
+
+while (<STDIN>)
+{
+ s/ @ ( [A-Za-z0-9_]+? ) @ / emit_diversion($1) /egx;
+ print;
+}
+
+# EOF
diff --git a/src/3rdparty/freetype/src/tools/apinames.c b/src/3rdparty/freetype/src/tools/apinames.c
index 7f191e19c9..c85df721a0 100644
--- a/src/3rdparty/freetype/src/tools/apinames.c
+++ b/src/3rdparty/freetype/src/tools/apinames.c
@@ -10,7 +10,7 @@
* accepted if you are using GCC for compilation (and probably by
* other compilers too).
*
- * Author: David Turner, 2005, 2006, 2008, 2009
+ * Author: David Turner, 2005, 2006, 2008-2013
*
* This code is explicitly placed into the public domain.
*
@@ -22,7 +22,7 @@
#include <ctype.h>
#define PROGRAM_NAME "apinames"
-#define PROGRAM_VERSION "0.1"
+#define PROGRAM_VERSION "0.2"
#define LINEBUFF_SIZE 1024
@@ -31,7 +31,8 @@ typedef enum OutputFormat_
OUTPUT_LIST = 0, /* output the list of names, one per line */
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_WATCOM_LBC, /* output a Watcom Linker Command File */
+ OUTPUT_NETWARE_IMP /* output a NetWare ImportFile */
} OutputFormat;
@@ -59,8 +60,9 @@ static void
names_add( const char* name,
const char* end )
{
- int nn, len, h;
- Name nm;
+ unsigned int h;
+ int nn, len;
+ Name nm;
if ( end <= name )
return;
@@ -86,7 +88,8 @@ names_add( const char* name,
if ( num_names >= max_names )
{
max_names += (max_names >> 1) + 4;
- the_names = (NameRec*)realloc( the_names, sizeof(the_names[0])*max_names );
+ the_names = (NameRec*)realloc( the_names,
+ sizeof ( the_names[0] ) * max_names );
if ( the_names == NULL )
panic( "not enough memory" );
}
@@ -115,7 +118,8 @@ name_compare( const void* name1,
static void
names_sort( void )
{
- qsort( the_names, (size_t)num_names, sizeof(the_names[0]), name_compare );
+ qsort( the_names, (size_t)num_names,
+ sizeof ( the_names[0] ), name_compare );
}
@@ -126,6 +130,7 @@ names_dump( FILE* out,
{
int nn;
+
switch ( format )
{
case OUTPUT_WINDOWS_DEF:
@@ -150,23 +155,26 @@ names_dump( FILE* out,
case OUTPUT_WATCOM_LBC:
{
- /* we must omit the .dll suffix from the library name */
- char temp[512];
- char* dot;
+ const char* dot;
+
if ( dll_name == NULL )
{
fprintf( stderr,
- "you must provide a DLL name with the -d option !!\n" );
- exit(4);
+ "you must provide a DLL name with the -d option!\n" );
+ exit( 4 );
}
+ /* we must omit the .dll suffix from the library name */
dot = strchr( dll_name, '.' );
if ( dot != NULL )
{
- int len = (dot - dll_name);
- if ( len > (int)(sizeof(temp)-1) )
- len = sizeof(temp)-1;
+ char temp[512];
+ int len = dot - dll_name;
+
+
+ if ( len > (int)( sizeof ( temp ) - 1 ) )
+ len = sizeof ( temp ) - 1;
memcpy( temp, dll_name, len );
temp[len] = 0;
@@ -180,6 +188,16 @@ names_dump( FILE* out,
}
break;
+ case OUTPUT_NETWARE_IMP:
+ {
+ if ( dll_name != NULL )
+ fprintf( out, " (%s)\n", dll_name );
+ for ( nn = 0; nn < num_names - 1; nn++ )
+ fprintf( out, " %s,\n", the_names[nn].name );
+ fprintf( out, " %s\n", the_names[num_names - 1].name );
+ }
+ break;
+
default: /* LIST */
for ( nn = 0; nn < num_names; nn++ )
fprintf( out, "%s\n", the_names[nn].name );
@@ -201,7 +219,7 @@ typedef enum State_
static int
read_header_file( FILE* file, int verbose )
{
- static char buff[ LINEBUFF_SIZE+1 ];
+ static char buff[LINEBUFF_SIZE + 1];
State state = STATE_START;
while ( !feof( file ) )
@@ -304,6 +322,7 @@ usage( void )
" -w : output .DEF file for Visual C++ and Mingw\n"
" -wB : output .DEF file for Borland C++\n"
" -wW : output Watcom Linker Response File\n"
+ " -wN : output NetWare Import File\n"
"\n";
fprintf( stderr,
@@ -387,6 +406,10 @@ int main( int argc, const char* const* argv )
format = OUTPUT_WATCOM_LBC;
break;
+ case 'N':
+ format = OUTPUT_NETWARE_IMP;
+ break;
+
case 0:
break;
diff --git a/src/3rdparty/freetype/src/tools/chktrcmp.py b/src/3rdparty/freetype/src/tools/chktrcmp.py
index d0f342e6bd..ce6500c7e2 100644
--- a/src/3rdparty/freetype/src/tools/chktrcmp.py
+++ b/src/3rdparty/freetype/src/tools/chktrcmp.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# Check trace components in FreeType 2 source.
-# Author: suzuki toshiya, 2009
+# Author: suzuki toshiya, 2009, 2013
#
# This code is explicitly into the public domain.
@@ -15,7 +15,7 @@ USED_COMPONENT = {}
KNOWN_COMPONENT = {}
SRC_FILE_DIRS = [ "src" ]
-TRACE_DEF_FILES = [ "include/freetype/internal/fttrace.h" ]
+TRACE_DEF_FILES = [ "include/internal/fttrace.h" ]
# --------------------------------------------------------------
diff --git a/src/3rdparty/freetype/src/tools/cordic.py b/src/3rdparty/freetype/src/tools/cordic.py
index 3f80c5f09a..6742c90dfe 100644
--- a/src/3rdparty/freetype/src/tools/cordic.py
+++ b/src/3rdparty/freetype/src/tools/cordic.py
@@ -2,65 +2,20 @@
import sys, math
#units = 64*65536.0 # don't change !!
-units = 256
+units = 180 * 2**16
scale = units/math.pi
shrink = 1.0
comma = ""
-def calc_val( x ):
- global units, shrink
- angle = math.atan(x)
- shrink = shrink * math.cos(angle)
- return angle/math.pi * units
-
-def print_val( n, x ):
- global comma
-
- lo = int(x)
- hi = lo + 1
- alo = math.atan(lo)
- ahi = math.atan(hi)
- ax = math.atan(2.0**n)
-
- errlo = abs( alo - ax )
- errhi = abs( ahi - ax )
-
- if ( errlo < errhi ):
- hi = lo
-
- sys.stdout.write( comma + repr( int(hi) ) )
- comma = ", "
-
-
print ""
print "table of arctan( 1/2^n ) for PI = " + repr(units/65536.0) + " units"
-# compute range of "i"
-r = [-1]
-r = r + range(32)
-
-for n in r:
-
- if n >= 0:
- x = 1.0/(2.0**n) # tangent value
- else:
- x = 2.0**(-n)
+for n in range(1,32):
- angle = math.atan(x) # arctangent
- angle2 = angle*scale # arctangent in FT_Angle units
+ x = 0.5**n # tangent value
- # determine which integer value for angle gives the best tangent
- lo = int(angle2)
- hi = lo + 1
- tlo = math.tan(lo/scale)
- thi = math.tan(hi/scale)
-
- errlo = abs( tlo - x )
- errhi = abs( thi - x )
-
- angle2 = hi
- if errlo < errhi:
- angle2 = lo
+ angle = math.atan(x) # arctangent
+ angle2 = round(angle*scale) # arctangent in FT_Angle units
if angle2 <= 0:
break
@@ -68,12 +23,11 @@ for n in r:
sys.stdout.write( comma + repr( int(angle2) ) )
comma = ", "
- shrink = shrink * math.cos( angle2/scale)
-
+ shrink /= math.sqrt( 1 + x*x )
print
print "shrink factor = " + repr( shrink )
-print "shrink factor 2 = " + repr( shrink * (2.0**32) )
-print "expansion factor = " + repr(1/shrink)
+print "shrink factor 2 = " + repr( int( shrink * (2**32) ) )
+print "expansion factor = " + repr( 1/shrink )
print ""
diff --git a/src/3rdparty/freetype/src/tools/docmaker/content.py b/src/3rdparty/freetype/src/tools/docmaker/content.py
index b398955b81..adea6f1d70 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/content.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/content.py
@@ -1,57 +1,81 @@
-# Content (c) 2002, 2004, 2006, 2007, 2008, 2009
-# David Turner <david@freetype.org>
#
-# This file contains routines used to parse the content of documentation
-# comment blocks and build more structured objects out of them.
+# content.py
#
+# Parse comment blocks to build content blocks (library file).
+#
+# Copyright 2002, 2004, 2006-2009, 2012-2014 by
+# David Turner.
+#
+# This file is part of the FreeType project, and may only be used,
+# modified, and distributed under the terms of the FreeType project
+# license, LICENSE.TXT. By continuing to use, modify, or distribute
+# this file you indicate that you have read the license and
+# understand and accept it fully.
+
+#
+# This file contains routines to parse documentation comment blocks,
+# building more structured objects out of them.
+#
+
from sources import *
-from utils import *
+from utils import *
+
import string, re
-# this regular expression is used to detect code sequences. these
-# are simply code fragments embedded in '{' and '}' like in:
#
-# {
-# x = y + z;
-# if ( zookoo == 2 )
-# {
-# foobar();
-# }
-# }
+# Regular expressions to detect code sequences. `Code sequences' are simply
+# code fragments embedded in '{' and '}', as demonstrated in the following
+# example.
+#
+# {
+# x = y + z;
+# if ( zookoo == 2 )
+# {
+# foobar();
+# }
+# }
#
-# note that indentation of the starting and ending accolades must be
-# exactly the same. the code sequence can contain accolades at greater
-# indentation
+# Note that the indentation of the first opening brace and the last closing
+# brace must be exactly the same. The code sequence itself should have a
+# larger indentation than the surrounding braces.
#
re_code_start = re.compile( r"(\s*){\s*$" )
re_code_end = re.compile( r"(\s*)}\s*$" )
-# this regular expression is used to isolate identifiers from
-# other text
#
-re_identifier = re.compile( r'(\w*)' )
-
-
-# we collect macros ending in `_H'; while outputting the object data, we use
-# this info together with the object's file location to emit the appropriate
-# header file macro and name before the object itself
+# A regular expression to isolate identifiers from other text.
#
-re_header_macro = re.compile( r'^#define\s{1,}(\w{1,}_H)\s{1,}<(.*)>' )
+re_identifier = re.compile( r'((?:\w|-)*)' )
-#############################################################################
#
-# The DocCode class is used to store source code lines.
+# We collect macro names ending in `_H' (group 1), as defined in
+# `config/ftheader.h'. While outputting the object data, we use this info
+# together with the object's file location (group 2) to emit the appropriate
+# header file macro and its associated file name before the object itself.
#
-# 'self.lines' contains a set of source code lines that will be dumped as
-# HTML in a <PRE> tag.
+# Example:
#
-# The object is filled line by line by the parser; it strips the leading
-# "margin" space from each input line before storing it in 'self.lines'.
+# #define FT_FREETYPE_H <freetype.h>
#
+re_header_macro = re.compile( r'^#define\s{1,}(\w{1,}_H)\s{1,}<(.*)>' )
+
+
+################################################################
+##
+## DOC CODE CLASS
+##
+## The `DocCode' class is used to store source code lines.
+##
+## `self.lines' contains a set of source code lines that will be dumped as
+## HTML in a <PRE> tag.
+##
+## The object is filled line by line by the parser; it strips the leading
+## `margin' space from each input line before storing it in `self.lines'.
+##
class DocCode:
def __init__( self, margin, lines ):
@@ -77,12 +101,14 @@ class DocCode:
-#############################################################################
-#
-# The DocPara class is used to store "normal" text paragraph.
-#
-# 'self.words' contains the list of words that make up the paragraph
-#
+################################################################
+##
+## DOC PARA CLASS
+##
+## `Normal' text paragraphs are stored in the `DocPara' class.
+##
+## `self.words' contains the list of words that make up the paragraph.
+##
class DocPara:
def __init__( self, lines ):
@@ -123,17 +149,18 @@ class DocPara:
return result
-
-#############################################################################
-#
-# The DocField class is used to store a list containing either DocPara or
-# DocCode objects. Each DocField also has an optional "name" which is used
-# when the object corresponds to a field or value definition
-#
+################################################################
+##
+## DOC FIELD CLASS
+##
+## The `DocField' class stores a list containing either `DocPara' or
+## `DocCode' objects. Each DocField object also has an optional `name'
+## that is used when the object corresponds to a field or value definition.
+##
class DocField:
def __init__( self, name, lines ):
- self.name = name # can be None for normal paragraphs/sources
+ self.name = name # can be `None' for normal paragraphs/sources
self.items = [] # list of items
mode_none = 0 # start parsing mode
@@ -143,14 +170,14 @@ class DocField:
margin = -1 # current code sequence indentation
cur_lines = []
- # now analyze the markup lines to see if they contain paragraphs,
- # code sequences or fields definitions
+ # analyze the markup lines to check whether they contain paragraphs,
+ # code sequences, or fields definitions
#
start = 0
mode = mode_none
for l in lines:
- # are we parsing a code sequence ?
+ # are we parsing a code sequence?
if mode == mode_code:
m = re_code_end.match( l )
if m and len( m.group( 1 ) ) <= margin:
@@ -161,10 +188,10 @@ class DocField:
cur_lines = []
mode = mode_none
else:
- # nope, continue the code sequence
+ # otherwise continue the code sequence
cur_lines.append( l[margin:] )
else:
- # start of code sequence ?
+ # start of code sequence?
m = re_code_start.match( l )
if m:
# save current lines
@@ -222,13 +249,29 @@ class DocField:
return result
-
-# this regular expression is used to detect field definitions
#
-re_field = re.compile( r"\s*(\w*|\w(\w|\.)*\w)\s*::" )
-
-
-
+# A regular expression to detect field definitions.
+#
+# Examples:
+#
+# foo ::
+# foo.bar ::
+#
+re_field = re.compile( r"""
+ \s*
+ (
+ \w*
+ |
+ \w (\w | \.)* \w
+ )
+ \s* ::
+ """, re.VERBOSE )
+
+
+################################################################
+##
+## DOC MARKUP CLASS
+##
class DocMarkup:
def __init__( self, tag, lines ):
@@ -242,7 +285,7 @@ class DocMarkup:
for l in lines:
m = re_field.match( l )
if m:
- # we detected the start of a new field definition
+ # We detected the start of a new field definition.
# first, save the current one
if cur_lines:
@@ -268,15 +311,6 @@ class DocMarkup:
except:
return None
- def get_start( self ):
- try:
- result = ""
- for word in self.fields[0].items[0].words:
- result = result + " " + word
- return result[1:]
- except:
- return "ERROR"
-
def dump( self, margin ):
print " " * margin + "<" + self.tag + ">"
for f in self.fields:
@@ -284,7 +318,10 @@ class DocMarkup:
print " " * margin + "</" + self.tag + ">"
-
+################################################################
+##
+## DOC CHAPTER CLASS
+##
class DocChapter:
def __init__( self, block ):
@@ -300,7 +337,10 @@ class DocChapter:
self.order = []
-
+################################################################
+##
+## DOC SECTION CLASS
+##
class DocSection:
def __init__( self, name = "Other" ):
@@ -329,18 +369,21 @@ class DocSection:
self.title = title
self.abstract = block.get_markup_words( "abstract" )
self.description = block.get_markup_items( "description" )
- self.order = block.get_markup_words( "order" )
+ self.order = block.get_markup_words_all( "order" )
return
def reorder( self ):
self.block_names = sort_order_list( self.block_names, self.order )
-
+################################################################
+##
+## CONTENT PROCESSOR CLASS
+##
class ContentProcessor:
def __init__( self ):
- """initialize a block content processor"""
+ """Initialize a block content processor."""
self.reset()
self.sections = {} # dictionary of documentation sections
@@ -351,8 +394,8 @@ class ContentProcessor:
self.headers = {} # dictionary of header macros
def set_section( self, section_name ):
- """set current section during parsing"""
- if not self.sections.has_key( section_name ):
+ """Set current section during parsing."""
+ if not section_name in self.sections:
section = DocSection( section_name )
self.sections[section_name] = section
self.section = section
@@ -363,15 +406,14 @@ class ContentProcessor:
chapter = DocChapter( block )
self.chapters.append( chapter )
-
def reset( self ):
- """reset the content processor for a new block"""
+ """Reset the content processor for a new block."""
self.markups = []
self.markup = None
self.markup_lines = []
def add_markup( self ):
- """add a new markup section"""
+ """Add a new markup section."""
if self.markup and self.markup_lines:
# get rid of last line of markup if it's empty
@@ -387,8 +429,8 @@ class ContentProcessor:
self.markup_lines = []
def process_content( self, content ):
- """process a block content and return a list of DocMarkup objects
- corresponding to it"""
+ """Process a block content and return a list of DocMarkup objects
+ corresponding to it."""
markup = None
markup_lines = []
first = 1
@@ -446,7 +488,7 @@ class ContentProcessor:
# listed there
for chap in self.chapters:
for sec in chap.order:
- if self.sections.has_key( sec ):
+ if sec in self.sections:
section = self.sections[sec]
section.chapter = chap
section.reorder()
@@ -461,6 +503,7 @@ class ContentProcessor:
others = []
for sec in self.sections.values():
if not sec.chapter:
+ sec.reorder()
others.append( sec )
# create a new special chapter for all remaining sections
@@ -472,7 +515,10 @@ class ContentProcessor:
self.chapters.append( chap )
-
+################################################################
+##
+## DOC BLOCK CLASS
+##
class DocBlock:
def __init__( self, source, follow, processor ):
@@ -549,24 +595,31 @@ class DocBlock:
return self.source.location()
def get_markup( self, tag_name ):
- """return the DocMarkup corresponding to a given tag in a block"""
+ """Return the DocMarkup corresponding to a given tag in a block."""
for m in self.markups:
if m.tag == string.lower( tag_name ):
return m
return None
- def get_markup_name( self, tag_name ):
- """return the name of a given primary markup in a block"""
+ def get_markup_words( self, tag_name ):
try:
m = self.get_markup( tag_name )
- return m.get_name()
+ return m.fields[0].items[0].words
except:
- return None
+ return []
- def get_markup_words( self, tag_name ):
+ def get_markup_words_all( self, tag_name ):
try:
m = self.get_markup( tag_name )
- return m.fields[0].items[0].words
+ words = []
+ for item in m.fields[0].items:
+ # We honour empty lines in an `<Order>' section element by
+ # adding the sentinel `/empty/'. The formatter should then
+ # convert it to an appropriate representation in the
+ # `section_enter' function.
+ words += item.words
+ words.append( "/empty/" )
+ return words
except:
return []
diff --git a/src/3rdparty/freetype/src/tools/docmaker/docmaker.py b/src/3rdparty/freetype/src/tools/docmaker/docmaker.py
index 1d9de9fbff..4fb1abf235 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/docmaker.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/docmaker.py
@@ -1,16 +1,26 @@
#!/usr/bin/env python
#
-# DocMaker (c) 2002, 2004, 2008 David Turner <david@freetype.org>
+# docmaker.py
#
-# This program is a re-write of the original DocMaker took used
-# to generate the API Reference of the FreeType font engine
-# by converting in-source comments into structured HTML.
+# Convert source code markup to HTML documentation.
#
-# This new version is capable of outputting XML data, as well
-# as accepts more liberal formatting options.
+# Copyright 2002, 2004, 2008, 2013, 2014 by
+# David Turner.
#
-# It also uses regular expression matching and substitution
-# to speed things significantly.
+# This file is part of the FreeType project, and may only be used,
+# modified, and distributed under the terms of the FreeType project
+# license, LICENSE.TXT. By continuing to use, modify, or distribute
+# this file you indicate that you have read the license and
+# understand and accept it fully.
+
+#
+# This program is a re-write of the original DocMaker tool used to generate
+# the API Reference of the FreeType font rendering engine by converting
+# in-source comments into structured HTML.
+#
+# This new version is capable of outputting XML data as well as accepting
+# more liberal formatting options. It also uses regular expression matching
+# and substitution to speed up operation significantly.
#
from sources import *
@@ -39,13 +49,13 @@ def usage():
def main( argv ):
- """main program loop"""
+ """Main program loop."""
global output_dir
try:
- opts, args = getopt.getopt( sys.argv[1:], \
- "ht:o:p:", \
+ opts, args = getopt.getopt( sys.argv[1:],
+ "ht:o:p:",
["help", "title=", "output=", "prefix="] )
except getopt.GetoptError:
usage()
@@ -56,7 +66,6 @@ def main( argv ):
sys.exit( 1 )
# process options
- #
project_title = "Project"
project_prefix = None
output_dir = None
@@ -90,7 +99,9 @@ def main( argv ):
# process sections
content_processor.finish()
- formatter = HtmlFormatter( content_processor, project_title, project_prefix )
+ formatter = HtmlFormatter( content_processor,
+ project_title,
+ project_prefix )
formatter.toc_dump()
formatter.index_dump()
@@ -98,9 +109,7 @@ def main( argv ):
# if called from the command line
-#
if __name__ == '__main__':
main( sys.argv )
-
# eof
diff --git a/src/3rdparty/freetype/src/tools/docmaker/formatter.py b/src/3rdparty/freetype/src/tools/docmaker/formatter.py
index f62ce676c1..7152c019d7 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/formatter.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/formatter.py
@@ -1,19 +1,37 @@
-# Formatter (c) 2002, 2004, 2007, 2008 David Turner <david@freetype.org>
#
+# formatter.py
+#
+# Convert parsed content blocks to a structured document (library file).
+#
+# Copyright 2002, 2004, 2007, 2008, 2014 by
+# David Turner.
+#
+# This file is part of the FreeType project, and may only be used,
+# modified, and distributed under the terms of the FreeType project
+# license, LICENSE.TXT. By continuing to use, modify, or distribute
+# this file you indicate that you have read the license and
+# understand and accept it fully.
+
+#
+# This is the base Formatter class. Its purpose is to convert a content
+# processor's data into specific documents (i.e., table of contents, global
+# index, and individual API reference indices).
+#
+# You need to sub-class it to output anything sensible. For example, the
+# file `tohtml.py' contains the definition of the `HtmlFormatter' sub-class
+# to output HTML.
+#
+
from sources import *
from content import *
from utils import *
-# This is the base Formatter class. Its purpose is to convert
-# a content processor's data into specific documents (i.e., table of
-# contents, global index, and individual API reference indices).
-#
-# You need to sub-class it to output anything sensible. For example,
-# the file tohtml.py contains the definition of the HtmlFormatter sub-class
-# used to output -- you guessed it -- HTML.
-#
+################################################################
+##
+## FORMATTER CLASS
+##
class Formatter:
def __init__( self, processor ):
@@ -36,20 +54,22 @@ class Formatter:
self.add_identifier( field.name, block )
self.block_index = self.identifiers.keys()
- self.block_index.sort( index_sort )
+ self.block_index.sort( key = index_key )
def add_identifier( self, name, block ):
- if self.identifiers.has_key( name ):
+ if name in self.identifiers:
# duplicate name!
- sys.stderr.write( \
- "WARNING: duplicate definition for '" + name + "' in " + \
- block.location() + ", previous definition in " + \
- self.identifiers[name].location() + "\n" )
+ sys.stderr.write( "WARNING: duplicate definition for"
+ + " '" + name + "' "
+ + "in " + block.location() + ", "
+ + "previous definition in "
+ + self.identifiers[name].location()
+ + "\n" )
else:
self.identifiers[name] = block
#
- # Formatting the table of contents
+ # formatting the table of contents
#
def toc_enter( self ):
pass
@@ -97,7 +117,7 @@ class Formatter:
close_output( output )
#
- # Formatting the index
+ # formatting the index
#
def index_enter( self ):
pass
@@ -128,7 +148,7 @@ class Formatter:
close_output( output )
#
- # Formatting a section
+ # formatting a section
#
def section_enter( self, section ):
pass
@@ -162,7 +182,22 @@ class Formatter:
self.section_enter( section )
for name in section.block_names:
- block = self.identifiers[name]
+ skip_entry = 0
+ try:
+ block = self.identifiers[name]
+ # `block_names' can contain field names also,
+ # which we filter out
+ for markup in block.markups:
+ if markup.tag == 'values':
+ for field in markup.fields:
+ if field.name == name:
+ skip_entry = 1
+ except:
+ skip_entry = 1 # this happens e.g. for `/empty/' entries
+
+ if skip_entry:
+ continue
+
self.block_enter( block )
for markup in block.markups[1:]: # always ignore first markup!
diff --git a/src/3rdparty/freetype/src/tools/docmaker/sources.py b/src/3rdparty/freetype/src/tools/docmaker/sources.py
index 7b68c07019..61ecc22c40 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/sources.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/sources.py
@@ -1,62 +1,70 @@
-# Sources (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009
-# David Turner <david@freetype.org>
#
+# sources.py
#
-# this file contains definitions of classes needed to decompose
-# C sources files into a series of multi-line "blocks". There are
-# two kinds of blocks:
+# Convert source code comments to multi-line blocks (library file).
#
-# - normal blocks, which contain source code or ordinary comments
+# Copyright 2002-2004, 2006-2009, 2012-2014 by
+# David Turner.
#
-# - documentation blocks, which have restricted formatting, and
-# whose text always start with a documentation markup tag like
-# "<Function>", "<Type>", etc..
+# This file is part of the FreeType project, and may only be used,
+# modified, and distributed under the terms of the FreeType project
+# license, LICENSE.TXT. By continuing to use, modify, or distribute
+# this file you indicate that you have read the license and
+# understand and accept it fully.
+
+#
+# This library file contains definitions of classes needed to decompose C
+# source code files into a series of multi-line `blocks'. There are two
+# kinds of blocks.
#
-# the routines used to process the content of documentation blocks
-# are not contained here, but in "content.py"
+# - Normal blocks, which contain source code or ordinary comments.
#
-# the classes and methods found here only deal with text parsing
-# and basic documentation block extraction
+# - Documentation blocks, which have restricted formatting, and whose text
+# always start with a documentation markup tag like `<Function>',
+# `<Type>', etc.
+#
+# The routines to process the content of documentation blocks are contained
+# in file `content.py'; the classes and methods found here only deal with
+# text parsing and basic documentation block extraction.
#
-import fileinput, re, sys, os, string
+import fileinput, re, sys, os, string
################################################################
##
-## BLOCK FORMAT PATTERN
+## SOURCE BLOCK FORMAT CLASS
+##
+## A simple class containing compiled regular expressions to detect
+## potential documentation format block comments within C source code.
##
-## A simple class containing compiled regular expressions used
-## to detect potential documentation format block comments within
-## C source code
+## The `column' pattern must contain a group to `unbox' the content of
+## documentation comment blocks.
##
-## note that the 'column' pattern must contain a group that will
-## be used to "unbox" the content of documentation comment blocks
+## Later on, paragraphs are converted to long lines, which simplifies the
+## regular expressions that act upon the text.
##
class SourceBlockFormat:
def __init__( self, id, start, column, end ):
- """create a block pattern, used to recognize special documentation blocks"""
+ """Create a block pattern, used to recognize special documentation
+ blocks."""
self.id = id
self.start = re.compile( start, re.VERBOSE )
self.column = re.compile( column, re.VERBOSE )
self.end = re.compile( end, re.VERBOSE )
-
#
-# format 1 documentation comment blocks look like the following:
+# Format 1 documentation comment blocks.
#
-# /************************************/
+# /************************************/ (at least 2 asterisks)
# /* */
# /* */
# /* */
-# /************************************/
+# /************************************/ (at least 2 asterisks)
#
-# we define a few regular expressions here to detect them
-#
-
start = r'''
\s* # any number of whitespace
/\*{2,}/ # followed by '/' and at least two asterisks then '/'
@@ -75,16 +83,13 @@ re_source_block_format1 = SourceBlockFormat( 1, start, column, start )
#
-# format 2 documentation comment blocks look like the following:
+# Format 2 documentation comment blocks.
#
# /************************************ (at least 2 asterisks)
# *
+# * (1 asterisk)
# *
-# *
-# *
-# **/ (1 or more asterisks at the end)
-#
-# we define a few regular expressions here to detect them
+# */ (1 or more asterisks)
#
start = r'''
\s* # any number of whitespace
@@ -93,9 +98,9 @@ start = r'''
'''
column = r'''
- \s* # any number of whitespace
- \*{1}(?!/) # followed by precisely one asterisk not followed by `/'
- (.*) # then anything (group1)
+ \s* # any number of whitespace
+ \*{1}(?![*/]) # followed by precisely one asterisk not followed by `/'
+ (.*) # then anything (group1)
'''
end = r'''
@@ -107,51 +112,101 @@ re_source_block_format2 = SourceBlockFormat( 2, start, column, end )
#
-# the list of supported documentation block formats, we could add new ones
-# relatively easily
+# The list of supported documentation block formats. We could add new ones
+# quite easily.
#
re_source_block_formats = [re_source_block_format1, re_source_block_format2]
#
-# the following regular expressions corresponds to markup tags
-# within the documentation comment blocks. they're equivalent
-# despite their different syntax
+# The following regular expressions correspond to markup tags within the
+# documentation comment blocks. They are equivalent despite their different
+# syntax.
+#
+# A markup tag consists of letters or character `-', to be found in group 1.
#
-# notice how each markup tag _must_ begin a new line
+# Notice that a markup tag _must_ begin a new paragraph.
#
-re_markup_tag1 = re.compile( r'''\s*<(\w*)>''' ) # <xxxx> format
-re_markup_tag2 = re.compile( r'''\s*@(\w*):''' ) # @xxxx: format
+re_markup_tag1 = re.compile( r'''\s*<((?:\w|-)*)>''' ) # <xxxx> format
+re_markup_tag2 = re.compile( r'''\s*@((?:\w|-)*):''' ) # @xxxx: format
#
-# the list of supported markup tags, we could add new ones relatively
-# easily
+# The list of supported markup tags. We could add new ones quite easily.
#
re_markup_tags = [re_markup_tag1, re_markup_tag2]
+
+#
+# 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.
#
-# used to detect a cross-reference, after markup tags have been stripped
+# A cross reference consists of letters, digits, or characters `-' and `_'.
#
-re_crossref = re.compile( r'@(\w*)(.*)' )
+re_crossref = re.compile( r'@((?:\w|-)*)(.*)' ) # @foo
#
-# used to detect italic and bold styles in paragraph text
+# Two regular expressions to detect italic and bold markup, respectively.
+# Group 1 is the markup, group 2 the rest of the line.
#
-re_italic = re.compile( r"_(\w(\w|')*)_(.*)" ) # _italic_
-re_bold = re.compile( r"\*(\w(\w|')*)\*(.*)" ) # *bold*
+# Note that the markup is limited to words consisting of letters, digits,
+# the character `_', or an apostrophe (but not as the first character).
+#
+re_italic = re.compile( r"_(\w(?:\w|')*)_(.*)" ) # _italic_
+re_bold = re.compile( r"\*(\w(?:\w|')*)\*(.*)" ) # *bold*
#
-# used to detect the end of commented source lines
+# This regular expression code to identify an URL has been taken from
+#
+# http://mail.python.org/pipermail/tutor/2002-September/017228.html
#
-re_source_sep = re.compile( r'\s*/\*\s*\*/' )
+# (with slight modifications).
+#
+urls = r'(?:https?|telnet|gopher|file|wais|ftp)'
+ltrs = r'\w'
+gunk = r'/#~:.?+=&%@!\-'
+punc = r'.:?\-'
+any = "%(ltrs)s%(gunk)s%(punc)s" % { 'ltrs' : ltrs,
+ 'gunk' : gunk,
+ 'punc' : punc }
+url = r"""
+ (
+ \b # start at word boundary
+ %(urls)s : # need resource and a colon
+ [%(any)s] +? # followed by one or more of any valid
+ # character, but be conservative and
+ # take only what you need to...
+ (?= # [look-ahead non-consumptive assertion]
+ [%(punc)s]* # either 0 or more punctuation
+ (?: # [non-grouping parentheses]
+ [^%(any)s] | $ # followed by a non-url char
+ # or end of the string
+ )
+ )
+ )
+ """ % {'urls' : urls,
+ 'any' : any,
+ 'punc' : punc }
+
+re_url = re.compile( url, re.VERBOSE | re.MULTILINE )
#
-# used to perform cross-reference within source output
+# A regular expression that stops collection of comments for the current
+# block.
+#
+re_source_sep = re.compile( r'\s*/\*\s*\*/' ) # /* */
+
+#
+# A regular expression to find possible C identifiers while outputting
+# source code verbatim, covering things like `*foo' or `(bar'. Group 1 is
+# the prefix, group 2 the identifier -- since we scan lines from left to
+# right, sequentially splitting the source code into prefix and identifier
+# is fully sufficient for our purposes.
#
re_source_crossref = re.compile( r'(\W*)(\w*)' )
#
-# a list of reserved source keywords
+# A regular expression that matches a list of reserved C source keywords.
#
re_source_keywords = re.compile( '''\\b ( typedef |
struct |
@@ -179,24 +234,16 @@ re_source_keywords = re.compile( '''\\b ( typedef |
##
## SOURCE BLOCK CLASS
##
-## A SourceProcessor is in charge of reading a C source file
-## and decomposing it into a series of different "SourceBlocks".
-## each one of these blocks can be made of the following data:
-##
-## - A documentation comment block that starts with "/**" and
-## whose exact format will be discussed later
+## There are two important fields in a `SourceBlock' object.
##
-## - normal sources lines, including comments
+## self.lines
+## A list of text lines for the corresponding block.
##
-## the important fields in a text block are the following ones:
-##
-## self.lines : a list of text lines for the corresponding block
-##
-## self.content : for documentation comment blocks only, this is the
-## block content that has been "unboxed" from its
-## decoration. This is None for all other blocks
-## (i.e. sources or ordinary comments with no starting
-## markup tag)
+## self.content
+## For documentation comment blocks only, this is the block content
+## that has been `unboxed' from its decoration. This is `None' for all
+## other blocks (i.e., sources or ordinary comments with no starting
+## markup tag)
##
class SourceBlock:
@@ -233,7 +280,7 @@ class SourceBlock:
def location( self ):
return "(" + self.filename + ":" + repr( self.lineno ) + ")"
- # debugging only - not used in normal operations
+ # debugging only -- not used in normal operations
def dump( self ):
if self.content:
print "{{{content start---"
@@ -250,39 +297,38 @@ class SourceBlock:
print line
-
################################################################
##
## SOURCE PROCESSOR CLASS
##
-## The SourceProcessor is in charge of reading a C source file
-## and decomposing it into a series of different "SourceBlock"
-## objects.
+## The `SourceProcessor' is in charge of reading a C source file and
+## decomposing it into a series of different `SourceBlock' objects.
##
-## each one of these blocks can be made of the following data:
+## A SourceBlock object consists of the following data.
##
-## - A documentation comment block that starts with "/**" and
-## whose exact format will be discussed later
+## - A documentation comment block using one of the layouts above. Its
+## exact format will be discussed later.
##
-## - normal sources lines, include comments
+## - Normal sources lines, including comments.
##
##
class SourceProcessor:
def __init__( self ):
- """initialize a source processor"""
+ """Initialize a source processor."""
self.blocks = []
self.filename = None
self.format = None
self.lines = []
def reset( self ):
- """reset a block processor, clean all its blocks"""
+ """Reset a block processor and clean up all its blocks."""
self.blocks = []
self.format = None
def parse_file( self, filename ):
- """parse a C source file, and add its blocks to the processor's list"""
+ """Parse a C source file and add its blocks to the processor's
+ list."""
self.reset()
self.filename = filename
@@ -301,16 +347,16 @@ class SourceProcessor:
self.process_normal_line( line )
else:
if self.format.end.match( line ):
- # that's a normal block end, add it to 'lines' and
- # create a new block
+ # A normal block end. Add it to `lines' and create a
+ # new block
self.lines.append( line )
self.add_block_lines()
elif self.format.column.match( line ):
- # that's a normal column line, add it to 'lines'
+ # A normal column line. Add it to `lines'.
self.lines.append( line )
else:
- # humm.. this is an unexpected block end,
- # create a new block, but don't process the line
+ # An unexpected block end. Create a new block, but
+ # don't process the line.
self.add_block_lines()
# we need to process the line again
@@ -320,7 +366,8 @@ class SourceProcessor:
self.add_block_lines()
def process_normal_line( self, line ):
- """process a normal line and check whether it is the start of a new block"""
+ """Process a normal line and check whether it is the start of a new
+ block."""
for f in re_source_block_formats:
if f.start.match( line ):
self.add_block_lines()
@@ -330,9 +377,12 @@ class SourceProcessor:
self.lines.append( line )
def add_block_lines( self ):
- """add the current accumulated lines and create a new block"""
+ """Add the current accumulated lines and create a new block."""
if self.lines != []:
- block = SourceBlock( self, self.filename, self.lineno, self.lines )
+ block = SourceBlock( self,
+ self.filename,
+ self.lineno,
+ self.lines )
self.blocks.append( block )
self.format = None
@@ -340,7 +390,7 @@ class SourceProcessor:
# debugging only, not used in normal operations
def dump( self ):
- """print all blocks in a processor"""
+ """Print all blocks in a processor."""
for b in self.blocks:
b.dump()
diff --git a/src/3rdparty/freetype/src/tools/docmaker/tohtml.py b/src/3rdparty/freetype/src/tools/docmaker/tohtml.py
index fffa120973..05fc08a92d 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/tohtml.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/tohtml.py
@@ -1,5 +1,19 @@
-# ToHTML (c) 2002, 2003, 2005, 2006, 2007, 2008
-# David Turner <david@freetype.org>
+#
+# tohtml.py
+#
+# A sub-class container of the `Formatter' class to produce HTML.
+#
+# Copyright 2002, 2003, 2005-2008, 2013, 2014 by
+# David Turner.
+#
+# This file is part of the FreeType project, and may only be used,
+# modified, and distributed under the terms of the FreeType project
+# license, LICENSE.TXT. By continuing to use, modify, or distribute
+# this file you indicate that you have read the license and
+# understand and accept it fully.
+
+# The parent class is contained in file `formatter.py'.
+
from sources import *
from content import *
@@ -8,7 +22,7 @@ from formatter import *
import time
-# The following defines the HTML header used by all generated pages.
+# The following strings define the HTML header used by all generated pages.
html_header_1 = """\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
@@ -21,62 +35,125 @@ html_header_1 = """\
html_header_2 = """\
API Reference</title>
<style type="text/css">
+ a:link { color: #0000EF; }
+ a:visited { color: #51188E; }
+ a:hover { color: #FF0000; }
+
body { font-family: Verdana, Geneva, Arial, Helvetica, serif;
color: #000000;
- background: #FFFFFF; }
+ background: #FFFFFF;
+ width: 87%;
+ margin: auto; }
+
+ div.section { width: 75%;
+ margin: auto; }
+ div.section hr { margin: 4ex 0 1ex 0; }
+ div.section h4 { background-color: #EEEEFF;
+ font-size: medium;
+ font-style: oblique;
+ font-weight: bold;
+ margin: 3ex 0 1.5ex 9%;
+ padding: 0.3ex 0 0.3ex 1%; }
+ div.section p { margin: 1.5ex 0 1.5ex 10%; }
+ div.section pre { margin: 3ex 0 3ex 9%;
+ background-color: #D6E8FF;
+ padding: 2ex 0 2ex 1%; }
+ div.section table.fields { width: 90%;
+ margin: 1.5ex 0 1.5ex 10%; }
+ div.section table.toc { width: 95%;
+ margin: 1.5ex 0 1.5ex 5%; }
+ div.timestamp { text-align: center;
+ font-size: 69%;
+ margin: 1.5ex 0 1.5ex 0; }
- p { text-align: justify; }
h1 { text-align: center; }
- li { text-align: justify; }
- td { padding: 0 0.5em 0 0.5em; }
- td.left { padding: 0 0.5em 0 0.5em;
- text-align: left; }
+ h3 { font-size: medium;
+ margin: 4ex 0 1.5ex 0; }
- a:link { color: #0000EF; }
- a:visited { color: #51188E; }
- a:hover { color: #FF0000; }
+ p { text-align: justify; }
+
+ pre.colored { color: blue; }
span.keyword { font-family: monospace;
text-align: left;
white-space: pre;
color: darkblue; }
- pre.colored { color: blue; }
+ table.fields td.val { font-weight: bold;
+ text-align: right;
+ width: 30%;
+ vertical-align: baseline;
+ padding: 1ex 1em 1ex 0; }
+ table.fields td.desc { vertical-align: baseline;
+ padding: 1ex 0 1ex 1em; }
+ table.fields td.desc p:first-child { margin: 0; }
+ table.fields td.desc p { margin: 1.5ex 0 0 0; }
+ table.index { margin: 6ex auto 6ex auto;
+ border: 0;
+ border-collapse: separate;
+ border-spacing: 1em 0.3ex; }
+ table.index tr { padding: 0; }
+ table.index td { padding: 0; }
+ table.index-toc-link { width: 100%;
+ border: 0;
+ border-spacing: 0;
+ margin: 1ex 0 1ex 0; }
+ table.index-toc-link td.left { padding: 0 0.5em 0 0.5em;
+ font-size: 83%;
+ text-align: left; }
+ table.index-toc-link td.middle { padding: 0 0.5em 0 0.5em;
+ font-size: 83%;
+ text-align: center; }
+ table.index-toc-link td.right { padding: 0 0.5em 0 0.5em;
+ font-size: 83%;
+ text-align: right; }
+ table.synopsis { margin: 6ex auto 6ex auto;
+ border: 0;
+ border-collapse: separate;
+ border-spacing: 2em 0.6ex; }
+ table.synopsis tr { padding: 0; }
+ table.synopsis td { padding: 0; }
+ table.toc td.link { width: 30%;
+ text-align: right;
+ vertical-align: baseline;
+ padding: 1ex 1em 1ex 0; }
+ table.toc td.desc { vertical-align: baseline;
+ padding: 1ex 0 1ex 1em;
+ text-align: left; }
+ table.toc td.desc p:first-child { margin: 0;
+ text-align: left; }
+ table.toc td.desc p { margin: 1.5ex 0 0 0;
+ text-align: left; }
- ul.empty { list-style-type: none; }
</style>
</head>
<body>
"""
-html_header_3 = """
-<table align=center><tr><td><font size=-1>[<a href="\
+html_header_3l = """
+<table class="index-toc-link"><tr><td class="left">[<a href="\
"""
-html_header_3i = """
-<table align=center><tr><td width="100%"></td>
-<td><font size=-1>[<a href="\
+html_header_3r = """
+<table class="index-toc-link"><tr><td class="right">[<a href="\
"""
html_header_4 = """\
-">Index</a>]</font></td>
-<td width="100%"></td>
-<td><font size=-1>[<a href="\
+">Index</a>]</td><td class="right">[<a href="\
"""
-html_header_5 = """\
-">TOC</a>]</font></td></tr></table>
-<center><h1>\
+html_header_5t = """\
+">TOC</a>]</td></tr></table>
+<h1>\
"""
-html_header_5t = """\
-">Index</a>]</font></td>
-<td width="100%"></td></tr></table>
-<center><h1>\
+html_header_5i = """\
+">Index</a>]</td></tr></table>
+<h1>\
"""
html_header_6 = """\
- API Reference</h1></center>
+ API Reference</h1>
"""
@@ -87,8 +164,8 @@ html_footer = """\
"""
# The header and footer used for each section.
-section_title_header = "<center><h1>"
-section_title_footer = "</h1></center>"
+section_title_header = "<h1>"
+section_title_footer = "</h1>"
# The header and footer used for code segments.
code_header = '<pre class="colored">'
@@ -99,66 +176,65 @@ para_header = "<p>"
para_footer = "</p>"
# Block header and footer.
-block_header = '<table align=center width="75%"><tr><td>'
+block_header = '<div class="section">'
block_footer_start = """\
-</td></tr></table>
-<hr width="75%">
-<table align=center width="75%"><tr><td><font size=-2>[<a href="\
+<hr>
+<table class="index-toc-link"><tr><td class="left">[<a href="\
"""
block_footer_middle = """\
-">Index</a>]</font></td>
-<td width="100%"></td>
-<td><font size=-2>[<a href="\
+">Index</a>]</td>\
+<td class="middle">[<a href="#">Top</a>]</td>\
+<td class="right">[<a href="\
"""
block_footer_end = """\
-">TOC</a>]</font></td></tr></table>
+">TOC</a>]</td></tr></table></div>
"""
# Description header/footer.
-description_header = '<table align=center width="87%"><tr><td>'
-description_footer = "</td></tr></table><br>"
+description_header = ""
+description_footer = ""
# Marker header/inter/footer combination.
-marker_header = '<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>'
-marker_inter = "</b></em></td></tr><tr><td>"
-marker_footer = "</td></tr></table>"
+marker_header = "<h4>"
+marker_inter = "</h4>"
+marker_footer = ""
# Header location header/footer.
-header_location_header = '<table align=center width="87%"><tr><td>'
-header_location_footer = "</td></tr></table><br>"
+header_location_header = "<p>"
+header_location_footer = "</p>"
# Source code extracts header/footer.
-source_header = '<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>\n'
-source_footer = "\n</pre></table><br>"
+source_header = "<pre>"
+source_footer = "</pre>"
# Chapter header/inter/footer.
-chapter_header = '<br><table align=center width="75%"><tr><td><h2>'
-chapter_inter = '</h2><ul class="empty"><li>'
-chapter_footer = '</li></ul></td></tr></table>'
+chapter_header = """\
+<div class="section">
+<h2>\
+"""
+chapter_inter = '</h2>'
+chapter_footer = '</div>'
# Index footer.
index_footer_start = """\
<hr>
-<table><tr><td width="100%"></td>
-<td><font size=-2>[<a href="\
+<table class="index-toc-link"><tr><td class="right">[<a href="\
"""
index_footer_end = """\
-">TOC</a>]</font></td></tr></table>
+">TOC</a>]</td></tr></table>
"""
# TOC footer.
toc_footer_start = """\
<hr>
-<table><tr><td><font size=-2>[<a href="\
+<table class="index-toc-link"><tr><td class="left">[<a href="\
"""
toc_footer_end = """\
-">Index</a>]</font></td>
-<td width="100%"></td>
-</tr></table>
+">Index</a>]</td></tr></table>
"""
-# source language keyword coloration/styling
+# Source language keyword coloration and styling.
keyword_prefix = '<span class="keyword">'
keyword_suffix = '</span>'
@@ -166,95 +242,78 @@ section_synopsis_header = '<h2>Synopsis</h2>'
section_synopsis_footer = ''
-# Translate a single line of source to HTML. This will convert
-# a "<" into "&lt.", ">" into "&gt.", etc.
+# Translate a single line of source to HTML. This converts `<', `>', and
+# `&' into `&lt;',`&gt;', and `&amp;'.
+#
def html_quote( line ):
- result = string.replace( line, "&", "&amp;" )
- result = string.replace( result, "<", "&lt;" )
- result = string.replace( result, ">", "&gt;" )
+ result = string.replace( line, "&", "&amp;" )
+ result = string.replace( result, "<", "&lt;" )
+ result = string.replace( result, ">", "&gt;" )
return result
-# same as 'html_quote', but ignores left and right brackets
-def html_quote0( line ):
- return string.replace( line, "&", "&amp;" )
-
-
-def dump_html_code( lines, prefix = "" ):
- # clean the last empty lines
- l = len( self.lines )
- while l > 0 and string.strip( self.lines[l - 1] ) == "":
- l = l - 1
-
- # The code footer should be directly appended to the last code
- # line to avoid an additional blank line.
- print prefix + code_header,
- for line in self.lines[0 : l + 1]:
- print '\n' + prefix + html_quote( line ),
- print prefix + code_footer,
-
-
-
+################################################################
+##
+## HTML FORMATTER CLASS
+##
class HtmlFormatter( Formatter ):
def __init__( self, processor, project_title, file_prefix ):
Formatter.__init__( self, processor )
- global html_header_1, html_header_2, html_header_3
- global html_header_4, html_header_5, html_footer
+ global html_header_1
+ global html_header_2
+ global html_header_3l, html_header_3r
+ global html_header_4
+ global html_header_5t, html_header_5i
+ global html_header_6
+ global html_footer
if file_prefix:
file_prefix = file_prefix + "-"
else:
file_prefix = ""
- self.headers = processor.headers
- self.project_title = project_title
- self.file_prefix = file_prefix
- self.html_header = html_header_1 + project_title + \
- html_header_2 + \
- html_header_3 + file_prefix + "index.html" + \
- html_header_4 + file_prefix + "toc.html" + \
- html_header_5 + project_title + \
- html_header_6
-
- self.html_index_header = html_header_1 + project_title + \
- html_header_2 + \
- html_header_3i + file_prefix + "toc.html" + \
- html_header_5 + project_title + \
- html_header_6
-
- self.html_toc_header = html_header_1 + project_title + \
- html_header_2 + \
- html_header_3 + file_prefix + "index.html" + \
- html_header_5t + project_title + \
- html_header_6
-
- self.html_footer = "<center><font size=""-2"">generated on " + \
- time.asctime( time.localtime( time.time() ) ) + \
- "</font></center>" + html_footer
+ self.headers = processor.headers
+ self.project_title = project_title
+ self.file_prefix = file_prefix
+ self.html_header = (
+ html_header_1 + project_title
+ + html_header_2
+ + html_header_3l + file_prefix + "index.html"
+ + html_header_4 + file_prefix + "toc.html"
+ + html_header_5t + project_title
+ + html_header_6 )
+ self.html_index_header = (
+ html_header_1 + project_title
+ + html_header_2
+ + html_header_3r + file_prefix + "toc.html"
+ + html_header_5t + project_title
+ + html_header_6 )
+ self.html_toc_header = (
+ html_header_1 + project_title
+ + html_header_2
+ + html_header_3l + file_prefix + "index.html"
+ + html_header_5i + project_title
+ + html_header_6 )
+ self.html_footer = (
+ '<div class="timestamp">generated on '
+ + time.asctime( time.localtime( time.time() ) )
+ + "</div>" + html_footer )
self.columns = 3
def make_section_url( self, section ):
return self.file_prefix + section.name + ".html"
- def make_block_url( self, block ):
- return self.make_section_url( block.section ) + "#" + block.name
-
- def make_html_words( self, words ):
- """ convert a series of simple words into some HTML text """
- line = ""
- if words:
- line = html_quote( words[0] )
- for w in words[1:]:
- line = line + " " + html_quote( w )
-
- return line
+ def make_block_url( self, block, name = None ):
+ if name == None:
+ name = block.name
+ return self.make_section_url( block.section ) + "#" + name
def make_html_word( self, word ):
- """analyze a simple word to detect cross-references and styling"""
- # look for cross-references
+ """Analyze a simple word to detect cross-references and markup."""
+ # handle cross-references
m = re_crossref.match( word )
if m:
try:
@@ -265,35 +324,38 @@ class HtmlFormatter( Formatter ):
return '<a href="' + url + '">' + name + '</a>' + rest
except:
# we detected a cross-reference to an unknown item
- sys.stderr.write( \
- "WARNING: undefined cross reference '" + name + "'.\n" )
+ sys.stderr.write( "WARNING: undefined cross reference"
+ + " '" + name + "'.\n" )
return '?' + name + '?' + rest
- # look for italics and bolds
+ # handle markup for italic and bold
m = re_italic.match( word )
if m:
name = m.group( 1 )
- rest = m.group( 3 )
+ rest = m.group( 2 )
return '<i>' + name + '</i>' + rest
m = re_bold.match( word )
if m:
name = m.group( 1 )
- rest = m.group( 3 )
+ rest = m.group( 2 )
return '<b>' + name + '</b>' + rest
return html_quote( word )
def make_html_para( self, words ):
- """ convert words of a paragraph into tagged HTML text, handle xrefs """
+ """Convert words of a paragraph into tagged HTML text. Also handle
+ cross references."""
line = ""
if words:
line = self.make_html_word( words[0] )
for word in words[1:]:
line = line + " " + self.make_html_word( word )
+ # handle hyperlinks
+ line = re_url.sub( r'<a href="\1">\1</a>', line )
# convert `...' quotations into real left and right single quotes
- line = re.sub( r"(^|\W)`(.*?)'(\W|$)", \
- r'\1&lsquo;\2&rsquo;\3', \
+ line = re.sub( r"(^|\W)`(.*?)'(\W|$)",
+ r'\1&lsquo;\2&rsquo;\3',
line )
# convert tilde into non-breakable space
line = string.replace( line, "~", "&nbsp;" )
@@ -301,7 +363,7 @@ class HtmlFormatter( Formatter ):
return para_header + line + para_footer
def make_html_code( self, lines ):
- """ convert a code sequence to HTML """
+ """Convert a code sequence to HTML."""
line = code_header + '\n'
for l in lines:
line = line + html_quote( l ) + '\n'
@@ -309,7 +371,7 @@ class HtmlFormatter( Formatter ):
return line + code_footer
def make_html_items( self, items ):
- """ convert a field's content into some valid HTML """
+ """Convert a field's content into HTML."""
lines = []
for item in items:
if item.lines:
@@ -324,7 +386,9 @@ class HtmlFormatter( Formatter ):
def print_html_field( self, field ):
if field.name:
- print "<table><tr valign=top><td><b>" + field.name + "</b></td><td>"
+ print( '<table><tr valign="top"><td><b>'
+ + field.name
+ + "</b></td><td>" )
print self.make_html_items( field.items )
@@ -345,12 +409,24 @@ class HtmlFormatter( Formatter ):
result = result + prefix + '<b>' + name + '</b>'
elif re_source_keywords.match( name ):
# this is a C keyword
- result = result + prefix + keyword_prefix + name + keyword_suffix
- elif self.identifiers.has_key( name ):
+ result = ( result + prefix
+ + keyword_prefix + name + keyword_suffix )
+ elif name in self.identifiers:
# this is a known identifier
block = self.identifiers[name]
- result = result + prefix + '<a href="' + \
- self.make_block_url( block ) + '">' + name + '</a>'
+ id = block.name
+
+ # link to a field ID if possible
+ for markup in block.markups:
+ if markup.tag == 'values':
+ for field in markup.fields:
+ if field.name:
+ id = name
+
+ result = ( result + prefix
+ + '<a href="'
+ + self.make_block_url( block, id )
+ + '">' + name + '</a>' )
else:
result = result + html_quote( line[:length] )
@@ -362,15 +438,11 @@ class HtmlFormatter( Formatter ):
return result
def print_html_field_list( self, fields ):
- print "<p></p>"
- print "<table cellpadding=3 border=0>"
+ print '<table class="fields">'
for field in fields:
- if len( field.name ) > 22:
- print "<tr valign=top><td colspan=0><b>" + field.name + "</b></td></tr>"
- print "<tr valign=top><td></td><td>"
- else:
- print "<tr valign=top><td><b>" + field.name + "</b></td><td>"
-
+ print ( '<tr><td class="val" id="' + field.name + '">'
+ + field.name
+ + '</td><td class="desc">' )
self.print_html_items( field.items )
print "</td></tr>"
print "</table>"
@@ -379,10 +451,9 @@ class HtmlFormatter( Formatter ):
table_fields = []
for field in markup.fields:
if field.name:
- # we begin a new series of field or value definitions, we
- # will record them in the 'table_fields' list before outputting
- # all of them as a single table
- #
+ # We begin a new series of field or value definitions. We
+ # record them in the `table_fields' list before outputting
+ # all of them as a single table.
table_fields.append( field )
else:
if table_fields:
@@ -395,7 +466,7 @@ class HtmlFormatter( Formatter ):
self.print_html_field_list( table_fields )
#
- # Formatting the index
+ # formatting the index
#
def index_enter( self ):
print self.html_index_header
@@ -407,11 +478,11 @@ class HtmlFormatter( Formatter ):
self.index_items[name] = url
def index_exit( self ):
- # block_index already contains the sorted list of index names
+ # `block_index' already contains the sorted list of index names
count = len( self.block_index )
- rows = ( count + self.columns - 1 ) / self.columns
+ rows = ( count + self.columns - 1 ) // self.columns
- print "<table align=center border=0 cellpadding=0 cellspacing=0>"
+ print '<table class="index">'
for r in range( rows ):
line = "<tr>"
for c in range( self.columns ):
@@ -419,7 +490,8 @@ class HtmlFormatter( Formatter ):
if i < count:
bname = self.block_index[r + c * rows]
url = self.index_items[bname]
- line = line + '<td><a href="' + url + '">' + bname + '</a></td>'
+ line = ( line + '<td><a href="' + url + '">'
+ + bname + '</a></td>' )
else:
line = line + '<td></td>'
line = line + "</tr>"
@@ -427,9 +499,9 @@ class HtmlFormatter( Formatter ):
print "</table>"
- print index_footer_start + \
- self.file_prefix + "toc.html" + \
- index_footer_end
+ print( index_footer_start
+ + self.file_prefix + "toc.html"
+ + index_footer_end )
print self.html_footer
@@ -442,21 +514,20 @@ class HtmlFormatter( Formatter ):
Formatter.index_dump( self, index_filename )
#
- # Formatting the table of content
+ # formatting the table of contents
#
def toc_enter( self ):
print self.html_toc_header
- print "<center><h1>Table of Contents</h1></center>"
+ print "<h1>Table of Contents</h1>"
def toc_chapter_enter( self, chapter ):
- print chapter_header + string.join( chapter.title ) + chapter_inter
- print "<table cellpadding=5>"
+ print chapter_header + string.join( chapter.title ) + chapter_inter
+ print '<table class="toc">'
def toc_section_enter( self, section ):
- print '<tr valign=top><td class="left">'
- print '<a href="' + self.make_section_url( section ) + '">' + \
- section.title + '</a></td><td>'
-
+ print ( '<tr><td class="link">'
+ + '<a href="' + self.make_section_url( section ) + '">'
+ + section.title + '</a></td><td class="desc">' )
print self.make_html_para( section.abstract )
def toc_section_exit( self, section ):
@@ -467,14 +538,14 @@ class HtmlFormatter( Formatter ):
print chapter_footer
def toc_index( self, index_filename ):
- print chapter_header + \
- '<a href="' + index_filename + '">Global Index</a>' + \
- chapter_inter + chapter_footer
+ print( chapter_header
+ + '<a href="' + index_filename + '">Global Index</a>'
+ + chapter_inter + chapter_footer )
def toc_exit( self ):
- print toc_footer_start + \
- self.file_prefix + "index.html" + \
- toc_footer_end
+ print( toc_footer_start
+ + self.file_prefix + "index.html"
+ + toc_footer_end )
print self.html_footer
@@ -488,14 +559,12 @@ class HtmlFormatter( Formatter ):
Formatter.toc_dump( self, toc_filename, index_filename )
#
- # Formatting sections
+ # formatting sections
#
def section_enter( self, section ):
print self.html_header
- print section_title_header
- print section.title
- print section_title_footer
+ print section_title_header + section.title + section_title_footer
maxwidth = 0
for b in section.blocks.values():
@@ -503,32 +572,43 @@ class HtmlFormatter( Formatter ):
maxwidth = len( b.name )
width = 70 # XXX magic number
- if maxwidth <> 0:
+ if maxwidth > 0:
# print section synopsis
print section_synopsis_header
- print "<table align=center cellspacing=5 cellpadding=0 border=0>"
+ print '<table class="synopsis">'
- columns = width / maxwidth
+ columns = width // maxwidth
if columns < 1:
columns = 1
count = len( section.block_names )
- rows = ( count + columns - 1 ) / columns
+ # don't handle last entry if it is empty
+ if section.block_names[-1] == "/empty/":
+ count -= 1
+ rows = ( count + columns - 1 ) // columns
for r in range( rows ):
line = "<tr>"
for c in range( columns ):
i = r + c * rows
- line = line + '<td></td><td>'
+ line = line + '<td>'
if i < count:
name = section.block_names[i]
- line = line + '<a href="#' + name + '">' + name + '</a>'
+ if name == "/empty/":
+ # it can happen that a complete row is empty, and
+ # without a proper `filler' the browser might
+ # collapse the row to a much smaller height (or
+ # even omit it completely)
+ line = line + "&nbsp;"
+ else:
+ line = ( line + '<a href="#' + name + '">'
+ + name + '</a>' )
line = line + '</td>'
line = line + "</tr>"
print line
- print "</table><br><br>"
+ print "</table>"
print section_synopsis_footer
print description_header
@@ -540,7 +620,7 @@ class HtmlFormatter( Formatter ):
# place html anchor if needed
if block.name:
- print '<h4><a name="' + block.name + '">' + block.name + '</a></h4>'
+ print( '<h3 id="' + block.name + '">' + block.name + '</h3>' )
# dump the block C source lines now
if block.code:
@@ -548,16 +628,17 @@ class HtmlFormatter( Formatter ):
for f in self.headers.keys():
if block.source.filename.find( f ) >= 0:
header = self.headers[f] + ' (' + f + ')'
- break;
-
+ break
+
# if not header:
-# sys.stderr.write( \
-# 'WARNING: No header macro for ' + block.source.filename + '.\n' )
+# sys.stderr.write(
+# "WARNING: No header macro for"
+# + " '" + block.source.filename + "'.\n" )
if header:
- print header_location_header
- print 'Defined in ' + header + '.'
- print header_location_footer
+ print ( header_location_header
+ + 'Defined in ' + header + '.'
+ + header_location_footer )
print source_header
for l in block.code:
@@ -579,15 +660,16 @@ class HtmlFormatter( Formatter ):
print marker_footer
def block_exit( self, block ):
- print block_footer_start + self.file_prefix + "index.html" + \
- block_footer_middle + self.file_prefix + "toc.html" + \
- block_footer_end
+ print( block_footer_start + self.file_prefix + "index.html"
+ + block_footer_middle + self.file_prefix + "toc.html"
+ + block_footer_end )
def section_exit( self, section ):
print html_footer
def section_dump_all( self ):
for section in self.sections:
- self.section_dump( section, self.file_prefix + section.name + '.html' )
+ self.section_dump( section,
+ self.file_prefix + section.name + '.html' )
# eof
diff --git a/src/3rdparty/freetype/src/tools/docmaker/utils.py b/src/3rdparty/freetype/src/tools/docmaker/utils.py
index 1d96658c7d..b35823ab74 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/utils.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/utils.py
@@ -1,48 +1,42 @@
-# Utils (c) 2002, 2004, 2007, 2008 David Turner <david@freetype.org>
#
-
-import string, sys, os, glob
-
-# current output directory
+# utils.py
#
-output_dir = None
-
-
-# This function is used to sort the index. It is a simple lexicographical
-# sort, except that it places capital letters before lowercase ones.
+# Auxiliary functions for the `docmaker' tool (library file).
#
-def index_sort( s1, s2 ):
- if not s1:
- return -1
-
- if not s2:
- return 1
-
- l1 = len( s1 )
- l2 = len( s2 )
- m1 = string.lower( s1 )
- m2 = string.lower( s2 )
+# Copyright 2002, 2004, 2007, 2008, 2014 by
+# David Turner.
+#
+# This file is part of the FreeType project, and may only be used,
+# modified, and distributed under the terms of the FreeType project
+# license, LICENSE.TXT. By continuing to use, modify, or distribute
+# this file you indicate that you have read the license and
+# understand and accept it fully.
- for i in range( l1 ):
- if i >= l2 or m1[i] > m2[i]:
- return 1
- if m1[i] < m2[i]:
- return -1
+import string, sys, os, glob, itertools
- if s1[i] < s2[i]:
- return -1
- if s1[i] > s2[i]:
- return 1
+# current output directory
+#
+output_dir = None
- if l2 > l1:
- return -1
- return 0
+# A function that generates a sorting key. We want lexicographical order
+# (primary key) except that capital letters are sorted before lowercase
+# ones (secondary key).
+#
+# The primary key is implemented by lowercasing the input. The secondary
+# key is simply the original data appended, character by character. For
+# example, the sort key for `FT_x' is `fFtT__xx', while the sort key for
+# `ft_X' is `fftt__xX'. Since ASCII codes of uppercase letters are
+# numerically smaller than the codes of lowercase letters, `fFtT__xx' gets
+# sorted before `fftt__xX'.
+#
+def index_key( s ):
+ return string.join( itertools.chain( *zip( s.lower(), s ) ) )
-# Sort input_list, placing the elements of order_list in front.
+# Sort `input_list', placing the elements of `order_list' in front.
#
def sort_order_list( input_list, order_list ):
new_list = order_list[:]
@@ -52,9 +46,9 @@ def sort_order_list( input_list, order_list ):
return new_list
-# Open the standard output to a given project documentation file. Use
-# "output_dir" to determine the filename location if necessary and save the
-# old stdout in a tuple that is returned by this function.
+# Divert standard output to a given project documentation file. Use
+# `output_dir' to determine the filename location if necessary and save the
+# old stdout handle in a tuple that is returned by this function.
#
def open_output( filename ):
global output_dir
@@ -69,7 +63,7 @@ def open_output( filename ):
return ( new_file, old_stdout )
-# Close the output that was returned by "close_output".
+# Close the output that was returned by `open_output'.
#
def close_output( output ):
output[0].close()
@@ -83,15 +77,16 @@ def check_output():
if output_dir:
if output_dir != "":
if not os.path.isdir( output_dir ):
- sys.stderr.write( "argument" + " '" + output_dir + "' " + \
- "is not a valid directory" )
+ sys.stderr.write( "argument"
+ + " '" + output_dir + "' "
+ + "is not a valid directory" )
sys.exit( 2 )
else:
output_dir = None
def file_exists( pathname ):
- """checks that a given file exists"""
+ """Check that a given file exists."""
result = 1
try:
file = open( pathname, "r" )
@@ -104,12 +99,12 @@ def file_exists( pathname ):
def make_file_list( args = None ):
- """builds a list of input files from command-line arguments"""
+ """Build a list of input files from command-line arguments."""
file_list = []
# sys.stderr.write( repr( sys.argv[1 :] ) + '\n' )
if not args:
- args = sys.argv[1 :]
+ args = sys.argv[1:]
for pathname in args:
if string.find( pathname, '*' ) >= 0:
diff --git a/src/3rdparty/freetype/src/tools/ftrandom/README b/src/3rdparty/freetype/src/tools/ftrandom/README
index c093f15e81..71bf05323d 100644
--- a/src/3rdparty/freetype/src/tools/ftrandom/README
+++ b/src/3rdparty/freetype/src/tools/ftrandom/README
@@ -43,6 +43,6 @@ Arguments are:
--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.
+ --test <file> Run a single test on a pre-generated testcase.
Done in the current process so it can be debugged
more easily.
diff --git a/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c b/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
index 4daac0dc1d..9a5b632673 100644
--- a/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
+++ b/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2007, 2008 by George Williams */
+/* Copyright (C) 2005, 2007, 2008, 2013 by George Williams */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -184,7 +184,6 @@
{
FT_Library context;
FT_Face face;
- int i, num;
if ( FT_Init_FreeType( &context ) )
@@ -203,6 +202,9 @@
TestFace( face );
else
{
+ int i, num;
+
+
num = face->num_faces;
FT_Done_Face( face );
@@ -327,12 +329,9 @@
FindFonts( char** fontdirs,
char** extensions )
{
- DIR* examples;
- struct dirent* ent;
-
- int i, max;
- char buffer[1025];
- struct stat statb;
+ int i, max;
+ char buffer[1025];
+ struct stat statb;
max = 0;
@@ -340,6 +339,10 @@
for ( i = 0; fontdirs[i] != NULL; ++i )
{
+ DIR* examples;
+ struct dirent* ent;
+
+
examples = opendir( fontdirs[i] );
if ( examples == NULL )
{
@@ -446,9 +449,9 @@
fseek( new, getRandom( 0, item->len - 1 ), SEEK_SET );
if ( item->isbinary )
- putc( getRandom( 0, 0xff ), new );
+ putc( getRandom( 0, 0xFF ), new );
else if ( item->isascii )
- putc( getRandom( 0x20, 0x7e ), new );
+ putc( getRandom( 0x20, 0x7E ), new );
else
{
int hex = getRandom( 0, 15 );
@@ -555,7 +558,6 @@
char** argv )
{
char **dirs, **exts;
- char *pt, *end;
int dcnt = 0, ecnt = 0, rset = false, allexts = false;
int i;
time_t now;
@@ -567,7 +569,10 @@
for ( i = 1; i < argc; ++i )
{
- pt = argv[i];
+ char* pt = argv[i];
+ char* end;
+
+
if ( pt[0] == '-' && pt[1] == '-' )
++pt;
@@ -633,12 +638,21 @@
}
if ( allexts )
+ {
+ free( exts );
exts = NULL;
+ }
else if ( ecnt == 0 )
+ {
+ free( exts );
exts = default_ext_list;
+ }
if ( dcnt == 0 )
+ {
+ free( dirs );
dirs = default_dir_list;
+ }
if ( testfile != NULL )
ExecuteTest( testfile ); /* This should never return */
diff --git a/src/3rdparty/freetype/src/tools/glnames.py b/src/3rdparty/freetype/src/tools/glnames.py
index 55573b22fe..8810bf57f1 100644
--- a/src/3rdparty/freetype/src/tools/glnames.py
+++ b/src/3rdparty/freetype/src/tools/glnames.py
@@ -6,7 +6,7 @@
#
-# Copyright 1996-2000, 2003, 2005, 2007, 2008 by
+# Copyright 1996-2000, 2003, 2005, 2007, 2008, 2011 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/asn/developer/pdfs/tn/5176.CFF.pdf.
+# http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf .
#
sid_standard_names = \
[
@@ -412,11 +412,10 @@ t1_expert_encoding = \
]
-# This data has been taken literally from the file `glyphlist.txt',
-# version 2.0, 22 Sept 2002. It is available from
+# This data has been taken literally from the files `glyphlist.txt'
+# and `zapfdingbats.txt' version 2.0, Sept 2002. It is available from
#
-# http://partners.adobe.com/asn/developer/typeforum/unicodegn.html
-# http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt
+# http://sourceforge.net/adobe/aglfn/
#
adobe_glyph_list = """\
A;0041
@@ -4700,6 +4699,207 @@ zretroflexhook;0290
zstroke;01B6
zuhiragana;305A
zukatakana;30BA
+a100;275E
+a101;2761
+a102;2762
+a103;2763
+a104;2764
+a105;2710
+a106;2765
+a107;2766
+a108;2767
+a109;2660
+a10;2721
+a110;2665
+a111;2666
+a112;2663
+a117;2709
+a118;2708
+a119;2707
+a11;261B
+a120;2460
+a121;2461
+a122;2462
+a123;2463
+a124;2464
+a125;2465
+a126;2466
+a127;2467
+a128;2468
+a129;2469
+a12;261E
+a130;2776
+a131;2777
+a132;2778
+a133;2779
+a134;277A
+a135;277B
+a136;277C
+a137;277D
+a138;277E
+a139;277F
+a13;270C
+a140;2780
+a141;2781
+a142;2782
+a143;2783
+a144;2784
+a145;2785
+a146;2786
+a147;2787
+a148;2788
+a149;2789
+a14;270D
+a150;278A
+a151;278B
+a152;278C
+a153;278D
+a154;278E
+a155;278F
+a156;2790
+a157;2791
+a158;2792
+a159;2793
+a15;270E
+a160;2794
+a161;2192
+a162;27A3
+a163;2194
+a164;2195
+a165;2799
+a166;279B
+a167;279C
+a168;279D
+a169;279E
+a16;270F
+a170;279F
+a171;27A0
+a172;27A1
+a173;27A2
+a174;27A4
+a175;27A5
+a176;27A6
+a177;27A7
+a178;27A8
+a179;27A9
+a17;2711
+a180;27AB
+a181;27AD
+a182;27AF
+a183;27B2
+a184;27B3
+a185;27B5
+a186;27B8
+a187;27BA
+a188;27BB
+a189;27BC
+a18;2712
+a190;27BD
+a191;27BE
+a192;279A
+a193;27AA
+a194;27B6
+a195;27B9
+a196;2798
+a197;27B4
+a198;27B7
+a199;27AC
+a19;2713
+a1;2701
+a200;27AE
+a201;27B1
+a202;2703
+a203;2750
+a204;2752
+a205;276E
+a206;2770
+a20;2714
+a21;2715
+a22;2716
+a23;2717
+a24;2718
+a25;2719
+a26;271A
+a27;271B
+a28;271C
+a29;2722
+a2;2702
+a30;2723
+a31;2724
+a32;2725
+a33;2726
+a34;2727
+a35;2605
+a36;2729
+a37;272A
+a38;272B
+a39;272C
+a3;2704
+a40;272D
+a41;272E
+a42;272F
+a43;2730
+a44;2731
+a45;2732
+a46;2733
+a47;2734
+a48;2735
+a49;2736
+a4;260E
+a50;2737
+a51;2738
+a52;2739
+a53;273A
+a54;273B
+a55;273C
+a56;273D
+a57;273E
+a58;273F
+a59;2740
+a5;2706
+a60;2741
+a61;2742
+a62;2743
+a63;2744
+a64;2745
+a65;2746
+a66;2747
+a67;2748
+a68;2749
+a69;274A
+a6;271D
+a70;274B
+a71;25CF
+a72;274D
+a73;25A0
+a74;274F
+a75;2751
+a76;25B2
+a77;25BC
+a78;25C6
+a79;2756
+a7;271E
+a81;25D7
+a82;2758
+a83;2759
+a84;275A
+a85;276F
+a86;2771
+a87;2772
+a88;2773
+a89;2768
+a8;271F
+a90;2769
+a91;276C
+a92;276D
+a93;276A
+a94;276B
+a95;2774
+a96;2775
+a97;275B
+a98;275C
+a99;275D
+a9;2720
"""
@@ -5067,7 +5267,7 @@ def main():
write( "/* */\n" )
write( "/* PostScript glyph names. */\n" )
write( "/* */\n" )
- write( "/* Copyright 2005, 2008 by */\n" )
+ write( "/* Copyright 2005, 2008, 2011 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" )
diff --git a/src/3rdparty/freetype/src/tools/test_afm.c b/src/3rdparty/freetype/src/tools/test_afm.c
index f5f99363ca..24cd0c4f0e 100644
--- a/src/3rdparty/freetype/src/tools/test_afm.c
+++ b/src/3rdparty/freetype/src/tools/test_afm.c
@@ -118,7 +118,7 @@
if ( argc < 2 )
- return FT_Err_Invalid_Argument;
+ return FT_ERR( Invalid_Argument );
error = FT_Init_FreeType( &library );
if ( error )
diff --git a/src/3rdparty/freetype/src/tools/test_bbox.c b/src/3rdparty/freetype/src/tools/test_bbox.c
index e085c5b3d6..64b82c384b 100644
--- a/src/3rdparty/freetype/src/tools/test_bbox.c
+++ b/src/3rdparty/freetype/src/tools/test_bbox.c
@@ -88,6 +88,26 @@
};
+ /* dummy outline #3 with bbox of [0 100 128 128] precisely */
+ static FT_Vector dummy_vec_3[4] =
+ {
+ XVEC( 100.0, 127.0 ),
+ XVEC( 200.0, 127.0 ),
+ XVEC( 0.0, 136.0 ),
+ XVEC( 0.0, 100.0 )
+ };
+
+ static FT_Outline dummy_outline_3 =
+ {
+ 1,
+ 4,
+ dummy_vec_3,
+ dummy_tag_1,
+ dummy_contour_1,
+ 0
+ };
+
+
static void
dump_outline( FT_Outline* outline )
{
@@ -125,12 +145,14 @@
FT_Outline_Get_CBox( outline, &bbox );
time0 = get_time() - time0;
- printf( "time = %5.2f cbox = [%.2f %.2f %.2f %.2f]\n",
+ printf( "time = %6.3f cbox = [%8.4f %8.4f %8.4f %8.4f]\n",
((double)time0/10000.0),
XVAL( bbox.xMin ),
XVAL( bbox.yMin ),
XVAL( bbox.xMax ),
XVAL( bbox.yMax ) );
+ printf( "cbox_hex = [%08X %08X %08X %08X]\n",
+ bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax );
time0 = get_time();
@@ -138,15 +160,17 @@
FT_Outline_Get_BBox( outline, &bbox );
time0 = get_time() - time0;
- printf( "time = %5.2f bbox = [%.2f %.2f %.2f %.2f]\n",
+ printf( "time = %6.3f bbox = [%8.4f %8.4f %8.4f %8.4f]\n",
((double)time0/10000.0),
XVAL( bbox.xMin ),
XVAL( bbox.yMin ),
XVAL( bbox.xMax ),
XVAL( bbox.yMax ) );
+ printf( "bbox_hex = [%08X %08X %08X %08X]\n",
+ bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax );
}
-#define REPEAT 100000L
+#define REPEAT 1000000L
int main( int argc, char** argv )
{
@@ -155,6 +179,10 @@
printf( "outline #2\n" );
profile_outline( &dummy_outline_2, REPEAT );
+
+ printf( "outline #3\n" );
+ profile_outline( &dummy_outline_3, REPEAT );
+
return 0;
}
diff --git a/src/3rdparty/freetype/src/tools/test_trig.c b/src/3rdparty/freetype/src/tools/test_trig.c
index 8c8a544aa9..99ac1cf174 100644
--- a/src/3rdparty/freetype/src/tools/test_trig.c
+++ b/src/3rdparty/freetype/src/tools/test_trig.c
@@ -8,9 +8,8 @@
#define PI 3.14159265358979323846
#define SPI (PI/FT_ANGLE_PI)
-/* the precision in 16.16 fixed float points of the checks. Expect */
-/* between 2 and 5 noise LSB bits during operations, due to */
-/* rounding errors.. */
+/* the precision in 16.16 fixed-point checks. Expect between 2 and 5 */
+/* noise LSB bits during operations, due to rounding errors.. */
#define THRESHOLD 64
static error = 0;
@@ -18,14 +17,16 @@
static void
test_cos( void )
{
- FT_Fixed f1, f2;
- double d1, d2;
- int i;
+ int i;
- for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+
+ for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
{
+ FT_Fixed f1, f2;
+ double d2;
+
+
f1 = FT_Cos(i);
- d1 = f1/65536.0;
d2 = cos( i*SPI );
f2 = (FT_Fixed)(d2*65536.0);
@@ -39,18 +40,19 @@
}
-
static void
test_sin( void )
{
- FT_Fixed f1, f2;
- double d1, d2;
- int i;
+ int i;
- for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+
+ for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
{
+ FT_Fixed f1, f2;
+ double d2;
+
+
f1 = FT_Sin(i);
- d1 = f1/65536.0;
d2 = sin( i*SPI );
f2 = (FT_Fixed)(d2*65536.0);
@@ -67,14 +69,16 @@
static void
test_tan( void )
{
- FT_Fixed f1, f2;
- double d1, d2;
- int i;
+ int i;
- for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 )
+
+ for ( i = 0; i < FT_ANGLE_PI2 - 0x2000000L; i += 0x10000L )
{
+ FT_Fixed f1, f2;
+ double d2;
+
+
f1 = FT_Tan(i);
- d1 = f1/65536.0;
d2 = tan( i*SPI );
f2 = (FT_Fixed)(d2*65536.0);
@@ -91,12 +95,16 @@
static void
test_atan2( void )
{
- FT_Fixed c2, s2;
- double l, a, c1, s1;
- int i, j;
+ int i;
- for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+
+ for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
{
+ FT_Fixed c2, s2;
+ double l, a, c1, s1;
+ int j;
+
+
l = 5.0;
a = i*SPI;
@@ -118,16 +126,20 @@
}
}
+
static void
test_unit( void )
{
- FT_Vector v;
- double a, c1, s1;
- FT_Fixed c2, s2;
- int i;
+ int i;
+
- for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+ for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
{
+ FT_Vector v;
+ double a, c1, s1;
+ FT_Fixed c2, s2;
+
+
FT_Vector_Unit( &v, i );
a = ( i*SPI );
c1 = cos(a);
@@ -151,12 +163,15 @@
static void
test_length( void )
{
- FT_Vector v;
- FT_Fixed l, l2;
- int i;
+ int i;
+
- for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+ for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
{
+ FT_Vector v;
+ FT_Fixed l, l2;
+
+
l = (FT_Fixed)(500.0*65536.0);
v.x = (FT_Fixed)( l * cos( i*SPI ) );
v.y = (FT_Fixed)( l * sin( i*SPI ) );
@@ -175,19 +190,26 @@
static void
test_rotate( void )
{
- FT_Fixed c2, s2, c4, s4;
- FT_Vector v;
- double l, ra, a, c1, s1, cra, sra, c3, s3;
- int i, j, rotate;
+ int rotate;
+
- for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 )
+ for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000L )
{
+ double ra, cra, sra;
+ int i;
+
+
ra = rotate*SPI;
cra = cos( ra );
sra = sin( ra );
- for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+ for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
{
+ FT_Fixed c2, s2, c4, s4;
+ FT_Vector v;
+ double l, a, c1, s1, c3, s3;
+
+
l = 500.0;
a = i*SPI;
diff --git a/src/3rdparty/freetype/src/truetype/rules.mk b/src/3rdparty/freetype/src/truetype/rules.mk
index 74684260ed..d4b69f578b 100644
--- a/src/3rdparty/freetype/src/truetype/rules.mk
+++ b/src/3rdparty/freetype/src/truetype/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2001, 2003, 2004 by
+# Copyright 1996-2001, 2003-2004, 2011-2012 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -25,12 +25,14 @@ TT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(TT_DIR))
# TrueType driver sources (i.e., C files)
#
-TT_DRV_SRC := $(TT_DIR)/ttobjs.c \
- $(TT_DIR)/ttpload.c \
+TT_DRV_SRC := $(TT_DIR)/ttdriver.c \
$(TT_DIR)/ttgload.c \
+ $(TT_DIR)/ttgxvar.c \
$(TT_DIR)/ttinterp.c \
- $(TT_DIR)/ttgxvar.c \
- $(TT_DIR)/ttdriver.c
+ $(TT_DIR)/ttobjs.c \
+ $(TT_DIR)/ttpic.c \
+ $(TT_DIR)/ttpload.c \
+ $(TT_DIR)/ttsubpix.c
# TrueType driver headers
#
diff --git a/src/3rdparty/freetype/src/truetype/truetype.c b/src/3rdparty/freetype/src/truetype/truetype.c
index 4bd1209787..576912b219 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-2001, 2004, 2006 by */
+/* Copyright 1996-2001, 2004, 2006, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,6 +27,7 @@
#ifdef TT_USE_BYTECODE_INTERPRETER
#include "ttinterp.c"
+#include "ttsubpix.c"
#endif
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
diff --git a/src/3rdparty/freetype/src/truetype/ttdriver.c b/src/3rdparty/freetype/src/truetype/ttdriver.c
index d723b57ae9..ecf4cdcb41 100644
--- a/src/3rdparty/freetype/src/truetype/ttdriver.c
+++ b/src/3rdparty/freetype/src/truetype/ttdriver.c
@@ -4,8 +4,7 @@
/* */
/* TrueType font driver implementation (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
-/* 2010 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +29,8 @@
#include FT_SERVICE_TRUETYPE_ENGINE_H
#include FT_SERVICE_TRUETYPE_GLYF_H
+#include FT_SERVICE_PROPERTIES_H
+#include FT_TRUETYPE_DRIVER_H
#include "ttdriver.h"
#include "ttgload.h"
@@ -53,6 +54,73 @@
#define FT_COMPONENT trace_ttdriver
+ /*
+ * PROPERTY SERVICE
+ *
+ */
+ static FT_Error
+ tt_property_set( FT_Module module, /* TT_Driver */
+ const char* property_name,
+ const void* value )
+ {
+ FT_Error error = FT_Err_Ok;
+ TT_Driver driver = (TT_Driver)module;
+
+
+ if ( !ft_strcmp( property_name, "interpreter-version" ) )
+ {
+ FT_UInt* interpreter_version = (FT_UInt*)value;
+
+
+#ifndef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( *interpreter_version != TT_INTERPRETER_VERSION_35 )
+ error = FT_ERR( Unimplemented_Feature );
+ else
+#endif
+ driver->interpreter_version = *interpreter_version;
+
+ return error;
+ }
+
+ FT_TRACE0(( "tt_property_set: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ static FT_Error
+ tt_property_get( FT_Module module, /* TT_Driver */
+ const char* property_name,
+ const void* value )
+ {
+ FT_Error error = FT_Err_Ok;
+ TT_Driver driver = (TT_Driver)module;
+
+ FT_UInt interpreter_version = driver->interpreter_version;
+
+
+ if ( !ft_strcmp( property_name, "interpreter-version" ) )
+ {
+ FT_UInt* val = (FT_UInt*)value;
+
+
+ *val = interpreter_version;
+
+ return error;
+ }
+
+ FT_TRACE0(( "tt_property_get: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ tt_service_properties,
+ (FT_Properties_SetFunc)tt_property_set,
+ (FT_Properties_GetFunc)tt_property_get )
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -135,8 +203,6 @@
{
FT_UInt nn;
TT_Face face = (TT_Face) ttface;
- FT_Bool check = FT_BOOL(
- !( flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) );
/* XXX: TODO: check for sbits */
@@ -149,7 +215,8 @@
FT_UShort ah;
- TT_Get_VMetrics( face, start + nn, check, &tsb, &ah );
+ /* since we don't need `tsb', we use zero for `yMax' parameter */
+ TT_Get_VMetrics( face, start + nn, 0, &tsb, &ah );
advances[nn] = ah;
}
}
@@ -161,12 +228,12 @@
FT_UShort aw;
- TT_Get_HMetrics( face, start + nn, check, &lsb, &aw );
+ TT_Get_HMetrics( face, start + nn, &lsb, &aw );
advances[nn] = aw;
}
}
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
/*************************************************************************/
@@ -190,7 +257,7 @@
{
TT_Face ttface = (TT_Face)size->face;
TT_Size ttsize = (TT_Size)size;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
ttsize->strike_index = strike_index;
@@ -200,7 +267,7 @@
/* use the scaled metrics, even when tt_size_reset fails */
FT_Select_Metrics( size->face, strike_index );
- tt_size_reset( ttsize );
+ tt_size_reset( ttsize ); /* ignore return value */
}
else
{
@@ -224,7 +291,7 @@
FT_Size_Request req )
{
TT_Size ttsize = (TT_Size)size;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -249,7 +316,10 @@
FT_Request_Metrics( size->face, req );
if ( FT_IS_SCALABLE( size->face ) )
+ {
error = tt_size_reset( ttsize );
+ ttsize->root.metrics = ttsize->metrics;
+ }
return error;
}
@@ -258,7 +328,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* Load_Glyph */
+ /* tt_glyph_load */
/* */
/* <Description> */
/* A driver method used to load a glyph within a given glyph slot. */
@@ -282,10 +352,10 @@
/* FreeType error code. 0 means success. */
/* */
static FT_Error
- Load_Glyph( FT_GlyphSlot ttslot, /* TT_GlyphSlot */
- FT_Size ttsize, /* TT_Size */
- FT_UInt glyph_index,
- FT_Int32 load_flags )
+ tt_glyph_load( FT_GlyphSlot ttslot, /* TT_GlyphSlot */
+ FT_Size ttsize, /* TT_Size */
+ FT_UInt glyph_index,
+ FT_Int32 load_flags )
{
TT_GlyphSlot slot = (TT_GlyphSlot)ttslot;
TT_Size size = (TT_Size)ttsize;
@@ -294,13 +364,13 @@
if ( !slot )
- return TT_Err_Invalid_Slot_Handle;
+ return FT_THROW( Invalid_Slot_Handle );
if ( !size )
- return TT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Size_Handle );
if ( !face )
- return TT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Face_Handle );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( glyph_index >= (FT_UInt)face->num_glyphs &&
@@ -308,12 +378,12 @@
#else
if ( glyph_index >= (FT_UInt)face->num_glyphs )
#endif
- return TT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( load_flags & FT_LOAD_NO_HINTING )
{
/* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT */
- /* are necessary to disable hinting for tricky fonts */
+ /* are necessary to disable hinting for tricky fonts */
if ( FT_IS_TRICKY( face ) )
load_flags &= ~FT_LOAD_NO_HINTING;
@@ -353,13 +423,13 @@
/*************************************************************************/
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICE_MULTIMASTERSREC(tt_service_gx_multi_masters,
+ 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
- )
+ (FT_Set_Var_Design_Func)TT_Set_Var_Design )
#endif
static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine =
@@ -379,42 +449,61 @@
#endif /* TT_USE_BYTECODE_INTERPRETER */
};
- FT_DEFINE_SERVICE_TTGLYFREC(tt_service_truetype_glyf,
- (TT_Glyf_GetLocationFunc)tt_face_get_location
- )
+ FT_DEFINE_SERVICE_TTGLYFREC(
+ tt_service_truetype_glyf,
+ (TT_Glyf_GetLocationFunc)tt_face_get_location )
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICEDESCREC4(tt_services,
+ FT_DEFINE_SERVICEDESCREC5(
+ tt_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE,
- FT_SERVICE_ID_MULTI_MASTERS, &FT_TT_SERVICE_GX_MULTI_MASTERS_GET,
+ 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, &FT_TT_SERVICE_TRUETYPE_GLYF_GET
- )
+ FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET,
+ FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET )
#else
- FT_DEFINE_SERVICEDESCREC3(tt_services,
+ FT_DEFINE_SERVICEDESCREC4(
+ tt_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE,
FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine,
- FT_SERVICE_ID_TT_GLYF, &FT_TT_SERVICE_TRUETYPE_GLYF_GET
- )
+ FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET,
+ FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET )
#endif
+
FT_CALLBACK_DEF( FT_Module_Interface )
tt_get_interface( FT_Module driver, /* TT_Driver */
const char* tt_interface )
{
+ FT_Library library;
FT_Module_Interface result;
FT_Module sfntd;
SFNT_Service sfnt;
- result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface );
+
+ /* TT_SERVICES_GET dereferences `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+ if ( !driver )
+ return NULL;
+ library = driver->library;
+ if ( !library )
+ return NULL;
+#endif
+
+ result = ft_service_list_lookup( TT_SERVICES_GET, tt_interface );
if ( result != NULL )
return result;
+#ifndef FT_CONFIG_OPTION_PIC
if ( !driver )
return NULL;
+ library = driver->library;
+ if ( !library )
+ return NULL;
+#endif
/* only return the default interface from the SFNT module */
- sfntd = FT_Get_Module( driver->library, "sfnt" );
+ sfntd = FT_Get_Module( library, "sfnt" );
if ( sfntd )
{
sfnt = (SFNT_Service)( sfntd->clazz->module_interface );
@@ -429,22 +518,22 @@
/* The FT_DriverInterface structure is defined in ftdriver.h. */
#ifdef TT_USE_BYTECODE_INTERPRETER
-#define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER
+#define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER
#else
-#define TT_HINTER_FLAG 0
+#define TT_HINTER_FLAG 0
#endif
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#define TT_SIZE_SELECT tt_size_select
+#define TT_SIZE_SELECT tt_size_select
#else
-#define TT_SIZE_SELECT 0
+#define TT_SIZE_SELECT 0
#endif
- FT_DEFINE_DRIVER(tt_driver_class,
-
-
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE |
+ FT_DEFINE_DRIVER(
+ tt_driver_class,
+
+ FT_MODULE_FONT_DRIVER |
+ FT_MODULE_DRIVER_SCALABLE |
TT_HINTER_FLAG,
sizeof ( TT_DriverRec ),
@@ -468,15 +557,12 @@
tt_size_init,
tt_size_done,
tt_slot_init,
- 0, /* FT_Slot_DoneFunc */
-
- ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
- ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
+ 0, /* FT_Slot_DoneFunc */
- Load_Glyph,
+ tt_glyph_load,
tt_get_kerning,
- 0, /* FT_Face_AttachFunc */
+ 0, /* FT_Face_AttachFunc */
tt_get_advances,
tt_size_request,
diff --git a/src/3rdparty/freetype/src/truetype/tterrors.h b/src/3rdparty/freetype/src/truetype/tterrors.h
index d317c70e0e..78d138fab2 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX TT_Err_
#define FT_ERR_BASE FT_Mod_Err_TrueType
diff --git a/src/3rdparty/freetype/src/truetype/ttgload.c b/src/3rdparty/freetype/src/truetype/ttgload.c
index 57ea0baa77..c5841c301d 100644
--- a/src/3rdparty/freetype/src/truetype/ttgload.c
+++ b/src/3rdparty/freetype/src/truetype/ttgload.c
@@ -4,8 +4,7 @@
/* */
/* TrueType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
-/* 2010 by */
+/* Copyright 1996-2014 */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,6 +23,7 @@
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_TAGS_H
#include FT_OUTLINE_H
+#include FT_TRUETYPE_DRIVER_H
#include "ttgload.h"
#include "ttpload.h"
@@ -33,6 +33,7 @@
#endif
#include "tterrors.h"
+#include "ttsubpix.h"
/*************************************************************************/
@@ -47,7 +48,7 @@
/*************************************************************************/
/* */
- /* Composite font flags. */
+ /* Composite glyph flags. */
/* */
#define ARGS_ARE_WORDS 0x0001
#define ARGS_ARE_XY_VALUES 0x0002
@@ -66,22 +67,16 @@
/*************************************************************************/
/* */
- /* Returns the horizontal metrics in font units for a given glyph. If */
- /* `check' is true, take care of monospaced fonts by returning the */
- /* advance width maximum. */
+ /* Return the horizontal metrics in font units for a given glyph. */
/* */
FT_LOCAL_DEF( void )
TT_Get_HMetrics( TT_Face face,
FT_UInt idx,
- FT_Bool check,
FT_Short* lsb,
FT_UShort* aw )
{
( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
- if ( check && face->postscript.isFixedPitch )
- *aw = face->horizontal.advance_Width_Max;
-
FT_TRACE5(( " advance width (font units): %d\n", *aw ));
FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
}
@@ -89,80 +84,106 @@
/*************************************************************************/
/* */
- /* Returns the vertical metrics in font units for a given glyph. */
- /* Greg Hitchcock from Microsoft told us that if there were no `vmtx' */
- /* table, typoAscender/Descender from the `OS/2' table would be used */
- /* instead, and if there were no `OS/2' table, use ascender/descender */
- /* from the `hhea' table. But that is not what Microsoft's rasterizer */
- /* apparently does: It uses the ppem value as the advance height, and */
- /* sets the top side bearing to be zero. */
- /* */
- /* The monospace `check' is probably not meaningful here, but we leave */
- /* it in for a consistent interface. */
+ /* Return the vertical metrics in font units for a given glyph. */
+ /* See macro `TT_LOADER_SET_PP' below for explanations. */
/* */
FT_LOCAL_DEF( void )
TT_Get_VMetrics( TT_Face face,
FT_UInt idx,
- FT_Bool check,
+ FT_Pos yMax,
FT_Short* tsb,
FT_UShort* ah )
{
- FT_UNUSED( check );
-
if ( face->vertical_info )
( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
-#if 1 /* Empirically determined, at variance with what MS said */
-
- else
- {
- *tsb = 0;
- *ah = face->root.units_per_EM;
- }
-
-#else /* This is what MS said to do. It isn't what they do, however. */
-
else if ( face->os2.version != 0xFFFFU )
{
- *tsb = face->os2.sTypoAscender;
+ *tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
*ah = face->os2.sTypoAscender - face->os2.sTypoDescender;
}
+
else
{
- *tsb = face->horizontal.Ascender;
+ *tsb = (FT_Short)( face->horizontal.Ascender - yMax );
*ah = face->horizontal.Ascender - face->horizontal.Descender;
}
-#endif
-
FT_TRACE5(( " advance height (font units): %d\n", *ah ));
FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
}
- static void
+ static FT_Error
tt_get_metrics( TT_Loader loader,
FT_UInt glyph_index )
{
- TT_Face face = (TT_Face)loader->face;
+ TT_Face face = (TT_Face)loader->face;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
+#endif
+
+ FT_Error error;
+ FT_Stream stream = loader->stream;
FT_Short left_bearing = 0, top_bearing = 0;
FT_UShort advance_width = 0, advance_height = 0;
+ /* we must preserve the stream position */
+ /* (which gets altered by the metrics functions) */
+ FT_ULong pos = FT_STREAM_POS();
+
TT_Get_HMetrics( face, glyph_index,
- (FT_Bool)!( loader->load_flags &
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
&left_bearing,
&advance_width );
TT_Get_VMetrics( face, glyph_index,
- (FT_Bool)!( loader->load_flags &
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
+ loader->bbox.yMax,
&top_bearing,
&advance_height );
+ if ( FT_STREAM_SEEK( pos ) )
+ return error;
+
+ loader->left_bearing = left_bearing;
+ loader->advance = advance_width;
+ loader->top_bearing = top_bearing;
+ loader->vadvance = advance_height;
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
+ {
+ if ( loader->exec )
+ loader->exec->sph_tweak_flags = 0;
+
+ /* this may not be the right place for this, but it works */
+ if ( loader->exec && loader->exec->ignore_x_mode )
+ sph_set_tweaks( loader, glyph_index );
+ }
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ if ( !loader->linear_def )
+ {
+ loader->linear_def = 1;
+ loader->linear = advance_width;
+ }
+
+ return FT_Err_Ok;
+ }
+
+
#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ static void
+ tt_get_metrics_incr_overrides( TT_Loader loader,
+ FT_UInt glyph_index )
+ {
+ TT_Face face = (TT_Face)loader->face;
+
+ FT_Short left_bearing = 0, top_bearing = 0;
+ FT_UShort advance_width = 0, advance_height = 0;
+
+
/* If this is an incrementally loaded font check whether there are */
/* overriding metrics for this glyph. */
if ( face->root.internal->incremental_interface &&
@@ -172,9 +193,9 @@
FT_Error error;
- metrics.bearing_x = left_bearing;
+ metrics.bearing_x = loader->left_bearing;
metrics.bearing_y = 0;
- metrics.advance = advance_width;
+ metrics.advance = loader->advance;
metrics.advance_v = 0;
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
@@ -190,8 +211,8 @@
/* GWW: Do I do the same for vertical metrics? */
metrics.bearing_x = 0;
- metrics.bearing_y = top_bearing;
- metrics.advance = advance_height;
+ metrics.bearing_y = loader->top_bearing;
+ metrics.advance = loader->vadvance;
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
face->root.internal->incremental_interface->object,
@@ -204,24 +225,24 @@
#endif /* 0 */
+ loader->left_bearing = left_bearing;
+ loader->advance = advance_width;
+ loader->top_bearing = top_bearing;
+ loader->vadvance = advance_height;
+
+ if ( !loader->linear_def )
+ {
+ loader->linear_def = 1;
+ loader->linear = advance_width;
+ }
}
Exit:
+ return;
+ }
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- loader->left_bearing = left_bearing;
- loader->advance = advance_width;
- loader->top_bearing = top_bearing;
- loader->vadvance = advance_height;
-
- if ( !loader->linear_def )
- {
- loader->linear_def = 1;
- loader->linear = advance_width;
- }
- }
-
/*************************************************************************/
/* */
@@ -246,10 +267,6 @@
}
-#undef IS_HINTED
-#define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
-
-
/*************************************************************************/
/* */
/* The following functions are used by default with TrueType fonts. */
@@ -271,7 +288,7 @@
FT_UNUSED( glyph_index );
- FT_TRACE5(( "Glyph %ld\n", glyph_index ));
+ FT_TRACE4(( "Glyph %ld\n", glyph_index ));
/* the following line sets the `error' variable through macros! */
if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) )
@@ -280,7 +297,7 @@
loader->cursor = stream->cursor;
loader->limit = stream->limit;
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -302,7 +319,7 @@
if ( p + 10 > limit )
- return TT_Err_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
loader->n_contours = FT_NEXT_SHORT( p );
@@ -318,7 +335,7 @@
loader->bbox.yMax ));
loader->cursor = p;
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -331,9 +348,9 @@
FT_GlyphLoader gloader = load->gloader;
FT_Int n_contours = load->n_contours;
FT_Outline* outline;
- TT_Face face = (TT_Face)load->face;
FT_UShort n_ins;
FT_Int n_points;
+ FT_ULong tmp;
FT_Byte *flag, *flag_limit;
FT_Byte c, count;
@@ -356,19 +373,21 @@
if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit )
goto Invalid_Outline;
- prev_cont = FT_NEXT_USHORT( p );
+ prev_cont = FT_NEXT_SHORT( p );
if ( n_contours > 0 )
cont[0] = prev_cont;
+ if ( prev_cont < 0 )
+ goto Invalid_Outline;
+
for ( cont++; cont < cont_limit; cont++ )
{
- cont[0] = FT_NEXT_USHORT( p );
+ cont[0] = FT_NEXT_SHORT( p );
if ( cont[0] <= prev_cont )
{
/* unordered contours: this is invalid */
- error = FT_Err_Invalid_Table;
- goto Fail;
+ goto Invalid_Outline;
}
prev_cont = cont[0];
}
@@ -386,13 +405,6 @@
if ( error )
goto Fail;
- /* we'd better check the contours table right now */
- outline = &gloader->current.outline;
-
- for ( cont = outline->contours + 1; cont < cont_limit; cont++ )
- if ( cont[-1] >= cont[0] )
- goto Invalid_Outline;
-
/* reading the bytecode instructions */
load->glyph->control_len = 0;
load->glyph->control_data = 0;
@@ -404,18 +416,11 @@
FT_TRACE5(( " Instructions size: %u\n", n_ins ));
- if ( n_ins > face->max_profile.maxSizeOfInstructions )
- {
- FT_TRACE0(( "TT_Load_Simple_Glyph: too many instructions (%d)\n",
- n_ins ));
- error = TT_Err_Too_Many_Hints;
- goto Fail;
- }
-
+ /* check it */
if ( ( limit - p ) < n_ins )
{
FT_TRACE0(( "TT_Load_Simple_Glyph: instruction count mismatch\n" ));
- error = TT_Err_Too_Many_Hints;
+ error = FT_THROW( Too_Many_Hints );
goto Fail;
}
@@ -423,6 +428,20 @@
if ( IS_HINTED( load->load_flags ) )
{
+ /* we don't trust `maxSizeOfInstructions' in the `maxp' table */
+ /* and thus update the bytecode array size by ourselves */
+
+ tmp = load->exec->glyphSize;
+ error = Update_Max( load->exec->memory,
+ &tmp,
+ sizeof ( FT_Byte ),
+ (void*)&load->exec->glyphIns,
+ n_ins );
+
+ load->exec->glyphSize = (FT_UShort)tmp;
+ if ( error )
+ return error;
+
load->glyph->control_len = n_ins;
load->glyph->control_data = load->exec->glyphIns;
@@ -433,6 +452,8 @@
p += n_ins;
+ outline = &gloader->current.outline;
+
/* reading the point tags */
flag = (FT_Byte*)outline->tags;
flag_limit = flag + n_points;
@@ -543,7 +564,7 @@
return error;
Invalid_Outline:
- error = TT_Err_Invalid_Outline;
+ error = FT_THROW( Invalid_Outline );
goto Fail;
}
@@ -664,7 +685,7 @@
return error;
Invalid_Composite:
- error = TT_Err_Invalid_Composite;
+ error = FT_THROW( Invalid_Composite );
goto Fail;
}
@@ -711,8 +732,12 @@
TT_Hint_Glyph( TT_Loader loader,
FT_Bool is_composite )
{
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ TT_Face face = (TT_Face)loader->face;
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
+#endif
+
TT_GlyphZone zone = &loader->zone;
- FT_Pos origin;
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_UInt n_ins;
@@ -724,19 +749,12 @@
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( loader->glyph->control_len > 0xFFFFL )
{
- FT_TRACE1(( "TT_Hint_Glyph: too long instructions " ));
- FT_TRACE1(( "(0x%lx byte) is truncated\n",
+ FT_TRACE1(( "TT_Hint_Glyph: too long instructions" ));
+ FT_TRACE1(( " (0x%lx byte) is truncated\n",
loader->glyph->control_len ));
}
n_ins = (FT_UInt)( loader->glyph->control_len );
-#endif
- origin = zone->cur[zone->n_points - 4].x;
- origin = FT_PIX_ROUND( origin ) - origin;
- if ( origin )
- translate_array( zone->n_points, zone->cur, origin, 0 );
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
/* save original point position in org */
if ( n_ins > 0 )
FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
@@ -762,9 +780,13 @@
}
#endif
- /* round pp2 and pp4 */
+ /* round phantom points */
+ zone->cur[zone->n_points - 4].x =
+ FT_PIX_ROUND( zone->cur[zone->n_points - 4].x );
zone->cur[zone->n_points - 3].x =
FT_PIX_ROUND( zone->cur[zone->n_points - 3].x );
+ zone->cur[zone->n_points - 2].y =
+ FT_PIX_ROUND( zone->cur[zone->n_points - 2].y );
zone->cur[zone->n_points - 1].y =
FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
@@ -779,10 +801,8 @@
FT_Outline current_outline = gloader->current.outline;
- error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
- loader->exec->glyphIns, n_ins );
- if ( error )
- return error;
+ TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
+ loader->exec->glyphIns, n_ins );
loader->exec->is_composite = is_composite;
loader->exec->pts = *zone;
@@ -802,15 +822,23 @@
#endif
/* save glyph phantom points */
- if ( !loader->preserve_pps )
+ 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_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
- 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];
+ if ( loader->exec->sph_tweak_flags & SPH_TWEAK_DEEMBOLDEN )
+ FT_Outline_EmboldenXY( &loader->gloader->current.outline, -24, 0 );
+
+ 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 */
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -828,7 +856,7 @@
TT_Process_Simple_Glyph( TT_Loader loader )
{
FT_GlyphLoader gloader = loader->gloader;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Outline* outline;
FT_Int n_points;
@@ -886,25 +914,83 @@
loader->zone.n_points + 4 );
}
- /* scale the glyph */
- if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
- FT_Vector* vec = outline->points;
- FT_Vector* limit = outline->points + n_points;
- FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale;
- FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ TT_Face face = (TT_Face)loader->face;
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
+
+ FT_String* family = face->root.family_name;
+ FT_Int ppem = loader->size->metrics.x_ppem;
+ FT_String* style = face->root.style_name;
+ FT_Int x_scale_factor = 1000;
+#endif
+
+ FT_Vector* vec = outline->points;
+ FT_Vector* limit = outline->points + n_points;
+ FT_Fixed x_scale = 0; /* pacify compiler */
+ FT_Fixed y_scale = 0;
- for ( ; vec < limit; vec++ )
+ FT_Bool do_scale = FALSE;
+
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
+ /* scale, but only if enabled and only if TT hinting is being used */
+ if ( IS_HINTED( loader->load_flags ) )
+ x_scale_factor = sph_test_tweak_x_scaling( face,
+ family,
+ ppem,
+ style,
+ loader->glyph_index );
+ /* scale the glyph */
+ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ||
+ x_scale_factor != 1000 )
+ {
+ x_scale = FT_MulDiv( ((TT_Size)loader->size)->metrics.x_scale,
+ x_scale_factor, 1000 );
+ y_scale = ((TT_Size)loader->size)->metrics.y_scale;
+
+ /* compensate for any scaling by de/emboldening; */
+ /* the amount was determined via experimentation */
+ if ( x_scale_factor != 1000 && ppem > 11 )
+ FT_Outline_EmboldenXY( outline,
+ FT_MulFix( 1280 * ppem,
+ 1000 - x_scale_factor ),
+ 0 );
+ do_scale = TRUE;
+ }
+ }
+ else
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ {
+ /* scale the glyph */
+ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
+ {
+ x_scale = ((TT_Size)loader->size)->metrics.x_scale;
+ y_scale = ((TT_Size)loader->size)->metrics.y_scale;
+
+ do_scale = TRUE;
+ }
}
- loader->pp1 = outline->points[n_points - 4];
- loader->pp2 = outline->points[n_points - 3];
- loader->pp3 = outline->points[n_points - 2];
- loader->pp4 = outline->points[n_points - 1];
+ if ( do_scale )
+ {
+ for ( ; vec < limit; vec++ )
+ {
+ vec->x = FT_MulFix( vec->x, x_scale );
+ vec->y = FT_MulFix( vec->y, y_scale );
+ }
+
+ loader->pp1 = outline->points[n_points - 4];
+ loader->pp2 = outline->points[n_points - 3];
+ loader->pp3 = outline->points[n_points - 2];
+ loader->pp4 = outline->points[n_points - 1];
+ }
}
if ( IS_HINTED( loader->load_flags ) )
@@ -971,7 +1057,7 @@
l += num_base_points;
if ( k >= num_base_points ||
l >= num_points )
- return TT_Err_Invalid_Composite;
+ return FT_THROW( Invalid_Composite );
p1 = gloader->base.outline.points + k;
p2 = gloader->base.outline.points + l;
@@ -985,11 +1071,11 @@
y = subglyph->arg2;
if ( !x && !y )
- return TT_Err_Ok;
+ return FT_Err_Ok;
- /* Use a default value dependent on */
- /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old TT */
- /* fonts which don't set the xxx_COMPONENT_OFFSET bit. */
+ /* Use a default value dependent on */
+ /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old */
+ /* TT fonts which don't set the xxx_COMPONENT_OFFSET bit. */
if ( have_scale &&
#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
@@ -1001,10 +1087,10 @@
#if 0
- /*************************************************************************/
- /* */
- /* This algorithm is what Apple documents. But it doesn't work. */
- /* */
+ /*******************************************************************/
+ /* */
+ /* This algorithm is what Apple documents. But it doesn't work. */
+ /* */
int a = subglyph->transform.xx > 0 ? subglyph->transform.xx
: -subglyph->transform.xx;
int b = subglyph->transform.yx > 0 ? subglyph->transform.yx
@@ -1024,28 +1110,22 @@
x = FT_MulFix( x, m );
y = FT_MulFix( y, n );
-#else /* 0 */
+#else /* 1 */
- /*************************************************************************/
- /* */
- /* This algorithm is a guess and works much better than the above. */
- /* */
- FT_Fixed mac_xscale = FT_SqrtFixed(
- (FT_Int32)FT_MulFix( subglyph->transform.xx,
- subglyph->transform.xx ) +
- (FT_Int32)FT_MulFix( subglyph->transform.xy,
- subglyph->transform.xy ) );
- FT_Fixed mac_yscale = FT_SqrtFixed(
- (FT_Int32)FT_MulFix( subglyph->transform.yy,
- subglyph->transform.yy ) +
- (FT_Int32)FT_MulFix( subglyph->transform.yx,
- subglyph->transform.yx ) );
+ /*******************************************************************/
+ /* */
+ /* This algorithm is a guess and works much better than the above. */
+ /* */
+ FT_Fixed mac_xscale = FT_Hypot( subglyph->transform.xx,
+ subglyph->transform.xy );
+ FT_Fixed mac_yscale = FT_Hypot( subglyph->transform.yy,
+ subglyph->transform.yx );
x = FT_MulFix( x, mac_xscale );
y = FT_MulFix( y, mac_yscale );
-#endif /* 0 */
+#endif /* 1 */
}
@@ -1071,7 +1151,7 @@
base_vec + num_base_points,
x, y );
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -1118,7 +1198,8 @@
{
FT_Stream stream = loader->stream;
- FT_UShort n_ins;
+ FT_UShort n_ins, max_ins;
+ FT_ULong tmp;
/* TT_Load_Composite_Glyph only gives us the offset of instructions */
@@ -1130,15 +1211,32 @@
FT_TRACE5(( " Instructions size = %d\n", n_ins ));
/* check it */
- if ( n_ins > ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions )
+ max_ins = ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions;
+ if ( n_ins > max_ins )
{
- FT_TRACE0(( "TT_Process_Composite_Glyph: too many instructions (%d)\n",
- n_ins ));
+ /* don't trust `maxSizeOfInstructions'; */
+ /* only do a rough safety check */
+ if ( (FT_Int)n_ins > loader->byte_len )
+ {
+ FT_TRACE1(( "TT_Process_Composite_Glyph:"
+ " too many instructions (%d) for glyph with length %d\n",
+ n_ins, loader->byte_len ));
+ return FT_THROW( Too_Many_Hints );
+ }
- return TT_Err_Too_Many_Hints;
+ tmp = loader->exec->glyphSize;
+ error = Update_Max( loader->exec->memory,
+ &tmp,
+ sizeof ( FT_Byte ),
+ (void*)&loader->exec->glyphIns,
+ n_ins );
+
+ loader->exec->glyphSize = (FT_UShort)tmp;
+ if ( error )
+ return error;
}
else if ( n_ins == 0 )
- return TT_Err_Ok;
+ return FT_Err_Ok;
if ( FT_STREAM_READ( loader->exec->glyphIns, n_ins ) )
return error;
@@ -1154,7 +1252,7 @@
/* Some points are likely touched during execution of */
/* instructions on components. So let's untouch them. */
- for ( i = start_point; i < loader->zone.n_points; i++ )
+ for ( i = 0; i < loader->zone.n_points; i++ )
loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
loader->zone.n_points += 4;
@@ -1163,21 +1261,131 @@
}
- /* Calculate the four phantom points. */
- /* The first two stand for horizontal origin and advance. */
- /* The last two stand for vertical origin and advance. */
+ /*
+ * Calculate the phantom points
+ *
+ * Defining the right side bearing (rsb) as
+ *
+ * rsb = aw - (lsb + xmax - xmin)
+ *
+ * (with `aw' the advance width, `lsb' the left side bearing, and `xmin'
+ * and `xmax' the glyph's minimum and maximum x value), the OpenType
+ * specification defines the initial position of horizontal phantom points
+ * as
+ *
+ * pp1 = (round(xmin - lsb), 0) ,
+ * pp2 = (round(pp1 + aw), 0) .
+ *
+ * Note that the rounding to the grid (in the device space) is not
+ * documented currently in the specification.
+ *
+ * However, the specification lacks the precise definition of vertical
+ * phantom points. Greg Hitchcock provided the following explanation.
+ *
+ * - a `vmtx' table is present
+ *
+ * For any glyph, the minimum and maximum y values (`ymin' and `ymax')
+ * are given in the `glyf' table, the top side bearing (tsb) and advance
+ * height (ah) are given in the `vmtx' table. The bottom side bearing
+ * (bsb) is then calculated as
+ *
+ * bsb = ah - (tsb + ymax - ymin) ,
+ *
+ * and the initial position of vertical phantom points is
+ *
+ * pp3 = (x, round(ymax + tsb)) ,
+ * pp4 = (x, round(pp3 - ah)) .
+ *
+ * See below for value `x'.
+ *
+ * - no `vmtx' table in the font
+ *
+ * If there is an `OS/2' table, we set
+ *
+ * DefaultAscender = sTypoAscender ,
+ * DefaultDescender = sTypoDescender ,
+ *
+ * otherwise we use data from the `hhea' table:
+ *
+ * DefaultAscender = Ascender ,
+ * DefaultDescender = Descender .
+ *
+ * With these two variables we can now set
+ *
+ * ah = DefaultAscender - sDefaultDescender ,
+ * tsb = DefaultAscender - yMax ,
+ *
+ * and proceed as if a `vmtx' table was present.
+ *
+ * Usually we have
+ *
+ * x = aw / 2 , (1)
+ *
+ * but there is one compatibility case where it can be set to
+ *
+ * x = -DefaultDescender -
+ * ((DefaultAscender - DefaultDescender - aw) / 2) . (2)
+ *
+ * and another one with
+ *
+ * x = 0 . (3)
+ *
+ * In Windows, the history of those values is quite complicated,
+ * depending on the hinting engine (that is, the graphics framework).
+ *
+ * framework from to formula
+ * ----------------------------------------------------------
+ * GDI Windows 98 current (1)
+ * (Windows 2000 for NT)
+ * GDI+ Windows XP Windows 7 (2)
+ * GDI+ Windows 8 current (3)
+ * DWrite Windows 7 current (3)
+ *
+ * For simplicity, FreeType uses (1) for grayscale subpixel hinting and
+ * (3) for everything else.
+ *
+ */
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+#define TT_LOADER_SET_PP( loader ) \
+ do \
+ { \
+ FT_Bool subpixel_ = loader->exec ? loader->exec->subpixel \
+ : 0; \
+ FT_Bool grayscale_ = loader->exec ? loader->exec->grayscale \
+ : 0; \
+ FT_Bool use_aw_2_ = (FT_Bool)( subpixel_ && 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 { \
+ 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)->top_bearing + (loader)->bbox.yMax; \
+ (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 */
+
/*************************************************************************/
/* */
@@ -1194,7 +1402,7 @@
FT_UInt recurse_count,
FT_Bool header_only )
{
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Fixed x_scale, y_scale;
FT_ULong offset;
TT_Face face = (TT_Face)loader->face;
@@ -1217,14 +1425,14 @@
if ( recurse_count > 1 &&
recurse_count > face->max_profile.maxComponentDepth )
{
- error = TT_Err_Invalid_Composite;
+ error = FT_THROW( Invalid_Composite );
goto Exit;
}
/* check glyph index */
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
{
- error = TT_Err_Invalid_Glyph_Index;
+ error = FT_THROW( Invalid_Glyph_Index );
goto Exit;
}
@@ -1241,8 +1449,6 @@
y_scale = 0x10000L;
}
- tt_get_metrics( loader, glyph_index );
-
/* Set `offset' to the start of the glyph relative to the start of */
/* the `glyf' table, and `byte_len' to the length of the glyph in */
/* bytes. */
@@ -1288,7 +1494,7 @@
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
- error = TT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -1302,7 +1508,17 @@
/* read glyph header first */
error = face->read_glyph_header( loader );
- if ( error || header_only )
+ if ( error )
+ goto Exit;
+
+ /* the metrics must be computed after loading the glyph header */
+ /* since we need the glyph's `yMax' value in case the vertical */
+ /* metrics must be emulated */
+ error = tt_get_metrics( loader, glyph_index );
+ if ( error )
+ goto Exit;
+
+ if ( header_only )
goto Exit;
}
@@ -1313,11 +1529,21 @@
loader->bbox.yMin = 0;
loader->bbox.yMax = 0;
+ error = tt_get_metrics( loader, glyph_index );
+ if ( error )
+ goto Exit;
+
if ( header_only )
goto Exit;
+ /* must initialize points before (possibly) overriding */
+ /* glyph metrics from the incremental interface */
TT_LOADER_SET_PP( loader );
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ tt_get_metrics_incr_overrides( loader, glyph_index );
+#endif
+
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
if ( ((TT_Face)(loader->face))->doblend )
@@ -1331,30 +1557,47 @@
if ( error )
goto Exit;
- loader->pp1.x += deltas[0].x; loader->pp1.y += deltas[0].y;
- loader->pp2.x += deltas[1].x; loader->pp2.y += deltas[1].y;
- loader->pp3.x += deltas[2].x; loader->pp3.y += deltas[2].y;
- loader->pp4.x += deltas[3].x; loader->pp4.y += deltas[3].y;
+ loader->pp1.x += deltas[0].x;
+ loader->pp1.y += deltas[0].y;
+ loader->pp2.x += deltas[1].x;
+ loader->pp2.y += deltas[1].y;
+
+ loader->pp3.x += deltas[2].x;
+ loader->pp3.y += deltas[2].y;
+ loader->pp4.x += deltas[3].x;
+ loader->pp4.y += deltas[3].y;
FT_FREE( deltas );
}
-#endif
+#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
+ /* scale phantom points, if necessary; */
+ /* they get rounded in `TT_Hint_Glyph' */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
+ /* pp1.y and pp2.y are always zero */
+
+ loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
+ loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
}
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
goto Exit;
}
+ /* must initialize phantom points before (possibly) overriding */
+ /* glyph metrics from the incremental interface */
TT_LOADER_SET_PP( loader );
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ tt_get_metrics_incr_overrides( loader, glyph_index );
+#endif
+
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
@@ -1421,7 +1664,7 @@
face,
glyph_index,
&deltas,
- gloader->current.num_subglyphs + 4 )) != 0 )
+ gloader->current.num_subglyphs + 4 ) ) != 0 )
goto Exit;
subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs;
@@ -1439,21 +1682,32 @@
}
}
- loader->pp1.x += deltas[i + 0].x; loader->pp1.y += deltas[i + 0].y;
- loader->pp2.x += deltas[i + 1].x; loader->pp2.y += deltas[i + 1].y;
- loader->pp3.x += deltas[i + 2].x; loader->pp3.y += deltas[i + 2].y;
- loader->pp4.x += deltas[i + 3].x; loader->pp4.y += deltas[i + 3].y;
+ loader->pp1.x += deltas[i + 0].x;
+ loader->pp1.y += deltas[i + 0].y;
+ loader->pp2.x += deltas[i + 1].x;
+ loader->pp2.y += deltas[i + 1].y;
+
+ loader->pp3.x += deltas[i + 2].x;
+ loader->pp3.y += deltas[i + 2].y;
+ loader->pp4.x += deltas[i + 3].x;
+ loader->pp4.y += deltas[i + 3].y;
FT_FREE( deltas );
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
+ /* scale phantom points, if necessary; */
+ /* they get rounded in `TT_Hint_Glyph' */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
+ /* pp1.y and pp2.y are always zero */
+
+ loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
+ loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
}
@@ -1481,6 +1735,7 @@
FT_UInt num_base_subgs = gloader->base.num_subglyphs;
FT_Stream old_stream = loader->stream;
+ FT_Int old_byte_len = loader->byte_len;
FT_GlyphLoader_Add( gloader );
@@ -1512,6 +1767,7 @@
/* restore subglyph pointer */
subglyph = gloader->base.subglyphs + num_base_subgs + n;
+ /* restore phantom points if necessary */
if ( !( subglyph->flags & USE_MY_METRICS ) )
{
loader->pp1 = pp[0];
@@ -1531,31 +1787,37 @@
/* (1): exists from the beginning */
/* (2): components that have been loaded so far */
/* (3): the newly loaded component */
- TT_Process_Composite_Component( loader, subglyph, start_point,
- num_base_points );
+ error = TT_Process_Composite_Component( loader,
+ subglyph,
+ start_point,
+ num_base_points );
+ if ( error )
+ goto Exit;
}
- loader->stream = old_stream;
+ loader->stream = old_stream;
+ loader->byte_len = old_byte_len;
/* process the glyph */
loader->ins_pos = ins_pos;
if ( IS_HINTED( loader->load_flags ) &&
-
#ifdef TT_USE_BYTECODE_INTERPRETER
-
subglyph->flags & WE_HAVE_INSTR &&
-
#endif
-
num_points > start_point )
- TT_Process_Composite_Glyph( loader, start_point, start_contour );
-
+ {
+ error = TT_Process_Composite_Glyph( loader,
+ start_point,
+ start_contour );
+ if ( error )
+ goto Exit;
+ }
}
}
else
{
/* invalid composite count (negative but not -1) */
- error = TT_Err_Invalid_Outline;
+ error = FT_THROW( Invalid_Outline );
goto Exit;
}
@@ -1585,11 +1847,15 @@
compute_glyph_metrics( TT_Loader loader,
FT_UInt glyph_index )
{
+ TT_Face face = (TT_Face)loader->face;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
+#endif
+
FT_BBox bbox;
- TT_Face face = (TT_Face)loader->face;
FT_Fixed y_scale;
TT_GlyphSlot glyph = loader->glyph;
- TT_Size size = (TT_Size)loader->size;
+ TT_Size size = (TT_Size)loader->size;
y_scale = 0x10000L;
@@ -1603,23 +1869,7 @@
/* get the device-independent horizontal advance; it is scaled later */
/* by the base layer. */
- {
- FT_Pos advance = loader->linear;
-
-
- /* the flag FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH was introduced to */
- /* correctly support DynaLab fonts, which have an incorrect */
- /* `advance_Width_Max' field! It is used, to my knowledge, */
- /* exclusively in the X-TrueType font server. */
- /* */
- if ( face->postscript.isFixedPitch &&
- ( loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 )
- advance = face->horizontal.advance_Width_Max;
-
- /* we need to return the advance in font units in linearHoriAdvance, */
- /* it will be scaled later by the base layer. */
- glyph->linearHoriAdvance = advance;
- }
+ glyph->linearHoriAdvance = loader->linear;
glyph->metrics.horiBearingX = bbox.xMin;
glyph->metrics.horiBearingY = bbox.yMax;
@@ -1636,8 +1886,30 @@
size->root.metrics.x_ppem,
glyph_index );
- if ( widthp )
- glyph->metrics.horiAdvance = *widthp << 6;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
+ {
+ FT_Bool ignore_x_mode;
+
+
+ ignore_x_mode = FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags ) !=
+ FT_RENDER_MODE_MONO );
+
+ if ( widthp &&
+ ( ( ignore_x_mode && loader->exec->compatible_widths ) ||
+ !ignore_x_mode ||
+ SPH_OPTION_BITMAP_WIDTHS ) )
+ glyph->metrics.horiAdvance = *widthp << 6;
+ }
+ else
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ {
+ if ( widthp )
+ glyph->metrics.horiAdvance = *widthp << 6;
+ }
}
/* set glyph dimensions */
@@ -1814,8 +2086,13 @@
FT_Int32 load_flags,
FT_Bool glyf_table_only )
{
+ FT_Error error;
+
TT_Face face;
FT_Stream stream;
+#ifdef TT_USE_BYTECODE_INTERPRETER
+ FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
+#endif
face = (TT_Face)glyph->face;
@@ -1831,37 +2108,153 @@
TT_ExecContext exec;
FT_Bool grayscale;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
+
+ FT_Bool subpixel = FALSE;
+
+#if 0
+ /* not used yet */
+ FT_Bool compatible_widths;
+ FT_Bool symmetrical_smoothing;
+ FT_Bool bgr;
+ FT_Bool subpixel_positioned;
+#endif
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ FT_Bool reexecute = FALSE;
- if ( !size->cvt_ready )
+
+ if ( size->bytecode_ready < 0 || size->cvt_ready < 0 )
{
- FT_Error error = tt_size_ready_bytecode( size );
+ error = tt_size_ready_bytecode( size, pedantic );
if ( error )
return error;
}
+ else if ( size->bytecode_ready )
+ return size->bytecode_ready;
+ else if ( size->cvt_ready )
+ return size->cvt_ready;
/* query new execution context */
exec = size->debug ? size->context
: ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
if ( !exec )
- return TT_Err_Could_Not_Find_Context;
+ return FT_THROW( Could_Not_Find_Context );
- grayscale =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- TT_Load_Context( exec, face, size );
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
+ {
+ subpixel = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags ) !=
+ FT_RENDER_MODE_MONO ) &&
+ SPH_OPTION_SET_SUBPIXEL );
+
+ if ( subpixel )
+ grayscale = FALSE;
+ else if ( SPH_OPTION_SET_GRAYSCALE )
+ {
+ grayscale = TRUE;
+ subpixel = FALSE;
+ }
+ else
+ grayscale = FALSE;
+
+ if ( FT_IS_TRICKY( glyph->face ) )
+ subpixel = FALSE;
+
+ exec->ignore_x_mode = subpixel || grayscale;
+ exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
+ if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
+ exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
+
+#if 1
+ exec->compatible_widths = SPH_OPTION_SET_COMPATIBLE_WIDTHS;
+ exec->symmetrical_smoothing = FALSE;
+ exec->bgr = FALSE;
+ exec->subpixel_positioned = TRUE;
+#else /* 0 */
+ exec->compatible_widths =
+ FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+ TT_LOAD_COMPATIBLE_WIDTHS );
+ exec->symmetrical_smoothing =
+ FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+ TT_LOAD_SYMMETRICAL_SMOOTHING );
+ exec->bgr =
+ FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+ TT_LOAD_BGR );
+ exec->subpixel_positioned =
+ FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+ TT_LOAD_SUBPIXEL_POSITIONED );
+#endif /* 0 */
+
+ }
+ else
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
- /* a change from mono to grayscale rendering (and vice versa) */
- /* requires a re-execution of the CVT program */
- if ( grayscale != exec->grayscale )
{
- FT_UInt i;
+ grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+ FT_RENDER_MODE_MONO );
+ }
+ error = TT_Load_Context( exec, face, size );
+ if ( error )
+ return error;
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
+ {
+ /* a change from mono to subpixel rendering (and vice versa) */
+ /* requires a re-execution of the CVT program */
+ if ( subpixel != exec->subpixel )
+ {
+ FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
+ " re-executing `prep' table\n" ));
+
+ exec->subpixel = subpixel;
+ reexecute = TRUE;
+ }
+
+ /* a change from mono to grayscale rendering (and vice versa) */
+ /* requires a re-execution of the CVT program */
+ if ( grayscale != exec->grayscale )
+ {
+ FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
+ " re-executing `prep' table\n" ));
+
+ exec->grayscale = grayscale;
+ reexecute = TRUE;
+ }
+ }
+ else
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ {
+ /* a change from mono to grayscale rendering (and vice versa) */
+ /* requires a re-execution of the CVT program */
+ if ( grayscale != exec->grayscale )
+ {
+ FT_TRACE4(( "tt_loader_init: grayscale change,"
+ " re-executing `prep' table\n" ));
+
+ exec->grayscale = grayscale;
+ reexecute = TRUE;
+ }
+ }
+
+ if ( reexecute )
+ {
+ FT_UInt i;
- exec->grayscale = grayscale;
for ( i = 0; i < size->cvt_size; i++ )
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
- tt_size_run_prep( size );
+ error = tt_size_run_prep( size, pedantic );
+ if ( error )
+ return error;
}
/* see whether the cvt program has disabled hinting */
@@ -1892,10 +2285,9 @@
#endif
{
- FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 );
-
+ error = face->goto_table( face, TTAG_glyf, stream, 0 );
- if ( error == TT_Err_Table_Missing )
+ if ( FT_ERR_EQ( error, Table_Missing ) )
loader->glyf_offset = 0;
else if ( error )
{
@@ -1923,7 +2315,7 @@
loader->glyph = (FT_GlyphSlot)glyph;
loader->stream = stream;
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -1960,13 +2352,11 @@
FT_UInt glyph_index,
FT_Int32 load_flags )
{
- TT_Face face;
FT_Error error;
TT_LoaderRec loader;
- face = (TT_Face)glyph->face;
- error = TT_Err_Ok;
+ FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -1980,23 +2370,27 @@
error = load_sbit_image( size, glyph, glyph_index, load_flags );
if ( !error )
{
- FT_Face root = &face->root;
-
-
- if ( FT_IS_SCALABLE( root ) )
+ 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 );
glyph->linearHoriAdvance = loader.linear;
- glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
- loader.vadvance;
- if ( face->postscript.isFixedPitch &&
- ( load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 )
- glyph->linearHoriAdvance = face->horizontal.advance_Width_Max;
+ 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 );
+ if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
+ glyph->metrics.vertAdvance =
+ FT_MulFix( glyph->linearVertAdvance,
+ size->root.metrics.y_scale );
}
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
}
@@ -2004,10 +2398,10 @@
/* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
- return TT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Size_Handle );
if ( load_flags & FT_LOAD_SBITS_ONLY )
- return TT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
if ( error )
@@ -2031,9 +2425,11 @@
glyph->outline = loader.gloader->base.outline;
glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
- /* In case bit 1 of the `flags' field in the `head' table isn't */
- /* set, translate array so that (0,0) is the glyph's origin. */
- if ( ( face->header.Flags & 2 ) == 0 && loader.pp1.x )
+ /* Translate array so that (0,0) is the glyph's origin. Note */
+ /* that this behaviour is independent on the value of bit 1 of */
+ /* the `flags' field in the `head' table -- at least major */
+ /* applications like Acroread indicate that. */
+ if ( loader.pp1.x )
FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
}
@@ -2071,7 +2467,7 @@
#endif /* TT_USE_BYTECODE_INTERPRETER */
- compute_glyph_metrics( &loader, glyph_index );
+ error = compute_glyph_metrics( &loader, glyph_index );
}
/* Set the `high precision' bit flag. */
diff --git a/src/3rdparty/freetype/src/truetype/ttgload.h b/src/3rdparty/freetype/src/truetype/ttgload.h
index 958d67d20d..3f1699e686 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-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
+/* Copyright 1996-2006, 2008, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,14 +37,13 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
TT_Get_HMetrics( TT_Face face,
FT_UInt idx,
- FT_Bool check,
FT_Short* lsb,
FT_UShort* aw );
FT_LOCAL( void )
TT_Get_VMetrics( TT_Face face,
FT_UInt idx,
- FT_Bool check,
+ FT_Pos yMax,
FT_Short* tsb,
FT_UShort* ah );
diff --git a/src/3rdparty/freetype/src/truetype/ttgxvar.c b/src/3rdparty/freetype/src/truetype/ttgxvar.c
index ef25aafb5b..1b35539fe1 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, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2004-2014 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,9 +61,9 @@
#define FT_Stream_FTell( stream ) \
- ( (stream)->cursor - (stream)->base )
+ (FT_ULong)( (stream)->cursor - (stream)->base )
#define FT_Stream_SeekSet( stream, off ) \
- ( (stream)->cursor = (stream)->base+(off) )
+ ( (stream)->cursor = (stream)->base + (off) )
/*************************************************************************/
@@ -91,7 +91,9 @@
/* indicates that there is a delta for every point without needing to */
/* enumerate all of them. */
/* */
-#define ALL_POINTS (FT_UShort*)( -1 )
+
+ /* ensure that value `0' has the same width as a pointer */
+#define ALL_POINTS (FT_UShort*)~(FT_PtrDist)0
#define GX_PT_POINTS_ARE_WORDS 0x80
@@ -123,14 +125,14 @@
ft_var_readpackedpoints( FT_Stream stream,
FT_UInt *point_cnt )
{
- FT_UShort *points;
+ FT_UShort *points = NULL;
FT_Int n;
FT_Int runcnt;
FT_Int i;
FT_Int j;
FT_Int first;
FT_Memory memory = stream->memory;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
@@ -154,7 +156,7 @@
runcnt = runcnt & GX_PT_POINT_RUN_COUNT_MASK;
first = points[i++] = FT_GET_USHORT();
- if ( runcnt < 1 )
+ if ( runcnt < 1 || i + runcnt >= n )
goto Exit;
/* first point not included in runcount */
@@ -165,7 +167,7 @@
{
first = points[i++] = FT_GET_BYTE();
- if ( runcnt < 1 )
+ if ( runcnt < 1 || i + runcnt >= n )
goto Exit;
for ( j = 0; j < runcnt; ++j )
@@ -210,12 +212,12 @@
ft_var_readpackeddeltas( FT_Stream stream,
FT_Offset delta_cnt )
{
- FT_Short *deltas;
+ FT_Short *deltas = NULL;
FT_UInt runcnt;
FT_Offset i;
FT_UInt j;
FT_Memory memory = stream->memory;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
@@ -283,7 +285,7 @@
FT_Memory memory = stream->memory;
GX_Blend blend = face->blend;
GX_AVarSegment segment;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ULong version;
FT_Long axisCount;
FT_Int i, j;
@@ -412,7 +414,7 @@
if ( gvar_head.version != (FT_Long)0x00010000L ||
gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis )
{
- error = TT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -501,11 +503,9 @@
FT_Fixed* im_end_coords )
{
FT_UInt i;
- FT_Fixed apply;
- FT_Fixed temp;
+ FT_Fixed apply = 0x10000L;
- apply = 0x10000L;
for ( i = 0; i < blend->num_axis; ++i )
{
if ( tuple_coords[i] == 0 )
@@ -525,11 +525,10 @@
else if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
/* not an intermediate tuple */
- apply = FT_MulDiv( apply,
+ apply = FT_MulFix( apply,
blend->normalizedcoords[i] > 0
? blend->normalizedcoords[i]
- : -blend->normalizedcoords[i],
- 0x10000L );
+ : -blend->normalizedcoords[i] );
else if ( blend->normalizedcoords[i] <= im_start_coords[i] ||
blend->normalizedcoords[i] >= im_end_coords[i] )
@@ -539,20 +538,14 @@
}
else if ( blend->normalizedcoords[i] < tuple_coords[i] )
- {
- temp = FT_MulDiv( blend->normalizedcoords[i] - im_start_coords[i],
- 0x10000L,
- tuple_coords[i] - im_start_coords[i]);
- apply = FT_MulDiv( apply, temp, 0x10000L );
- }
+ apply = FT_MulDiv( apply,
+ blend->normalizedcoords[i] - im_start_coords[i],
+ tuple_coords[i] - im_start_coords[i] );
else
- {
- temp = FT_MulDiv( im_end_coords[i] - blend->normalizedcoords[i],
- 0x10000L,
- im_end_coords[i] - tuple_coords[i] );
- apply = FT_MulDiv( apply, temp, 0x10000L );
- }
+ apply = FT_MulDiv( apply,
+ im_end_coords[i] - blend->normalizedcoords[i],
+ im_end_coords[i] - tuple_coords[i] );
}
return apply;
@@ -619,10 +612,10 @@
FT_Stream stream = face->root.stream;
FT_Memory memory = face->root.memory;
FT_ULong table_len;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ULong fvar_start;
FT_Int i, j;
- FT_MM_Var* mmvar;
+ FT_MM_Var* mmvar = NULL;
FT_Fixed* next_coords;
FT_String* next_name;
FT_Var_Axis* a;
@@ -682,18 +675,22 @@
if ( fvar_head.version != (FT_Long)0x00010000L ||
fvar_head.countSizePairs != 2 ||
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 )
{
- error = TT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
if ( FT_NEW( face->blend ) )
goto Exit;
- /* XXX: TODO - check for overflows */
+ /* cannot overflow 32-bit arithmetic because of limits above */
face->blend->mmvar_len =
sizeof ( FT_MM_Var ) +
fvar_head.axisCount * sizeof ( FT_Var_Axis ) +
@@ -708,7 +705,7 @@
mmvar->num_axis =
fvar_head.axisCount;
mmvar->num_designs =
- (FT_UInt)-1; /* meaningless in this context; each glyph */
+ ~0U; /* meaningless in this context; each glyph */
/* may have a different number of designs */
/* (or tuples, as called by Apple) */
mmvar->num_namedstyles =
@@ -852,7 +849,7 @@
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
GX_Blend blend;
FT_MM_Var* mmvar;
FT_UInt i;
@@ -880,14 +877,14 @@
if ( num_coords != mmvar->num_axis )
{
- error = TT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
for ( i = 0; i < num_coords; ++i )
if ( coords[i] < -0x00010000L || coords[i] > 0x00010000L )
{
- error = TT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -941,13 +938,13 @@
FT_FREE( face->cvt );
face->cvt = NULL;
- tt_face_load_cvt( face, face->root.stream );
+ error = tt_face_load_cvt( face, face->root.stream );
break;
case mcvt_modify:
/* The original cvt table is in memory. All we need to do is */
/* apply the `cvar' table (if any). */
- tt_face_vary_cvt( face, face->root.stream );
+ error = tt_face_vary_cvt( face, face->root.stream );
break;
case mcvt_retain:
@@ -988,7 +985,7 @@
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Fixed* normalized = NULL;
GX_Blend blend;
FT_MM_Var* mmvar;
@@ -1009,7 +1006,7 @@
if ( num_coords != mmvar->num_axis )
{
- error = TT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -1025,24 +1022,16 @@
{
if ( coords[i] > a->maximum || coords[i] < a->minimum )
{
- error = TT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( coords[i] < a->def )
- {
- normalized[i] = -FT_MulDiv( coords[i] - a->def,
- 0x10000L,
- a->minimum - 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_MulDiv( coords[i] - a->def,
- 0x10000L,
- a->maximum - a->def );
- }
+ normalized[i] = FT_DivFix( coords[i] - a->def, a->maximum - a->def );
}
if ( !blend->avar_checked )
@@ -1057,15 +1046,11 @@
if ( normalized[i] < av->correspondence[j].fromCoord )
{
normalized[i] =
- FT_MulDiv(
- FT_MulDiv(
- normalized[i] - av->correspondence[j - 1].fromCoord,
- 0x10000L,
- av->correspondence[j].fromCoord -
- av->correspondence[j - 1].fromCoord ),
- av->correspondence[j].toCoord -
- av->correspondence[j - 1].toCoord,
- 0x10000L ) +
+ 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;
}
@@ -1137,7 +1122,7 @@
{
FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" ));
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
goto Exit;
}
@@ -1145,7 +1130,7 @@
{
FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" ));
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
goto Exit;
}
@@ -1154,13 +1139,13 @@
{
FT_TRACE2(( "is missing\n" ));
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
goto Exit;
}
if ( FT_FRAME_ENTER( table_len ) )
{
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
goto Exit;
}
@@ -1169,7 +1154,7 @@
{
FT_TRACE2(( "bad table version\n" ));
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
goto FExit;
}
@@ -1321,7 +1306,7 @@
FT_Stream stream = face->root.stream;
FT_Memory memory = stream->memory;
GX_Blend blend = face->blend;
- FT_Vector* delta_xy;
+ FT_Vector* delta_xy = NULL;
FT_Error error;
FT_ULong glyph_start;
@@ -1340,7 +1325,7 @@
if ( !face->doblend || blend == NULL )
- return TT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* to be freed by the caller */
if ( FT_NEW_ARRAY( delta_xy, n_points ) )
@@ -1350,7 +1335,7 @@
if ( glyph_index >= blend->gv_glyphcnt ||
blend->glyphoffsets[glyph_index] ==
blend->glyphoffsets[glyph_index + 1] )
- return TT_Err_Ok; /* no variation data for this glyph */
+ return FT_Err_Ok; /* no variation data for this glyph */
if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] -
@@ -1400,7 +1385,7 @@
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
- error = TT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Fail3;
}
else
@@ -1470,6 +1455,9 @@
{
for ( j = 0; j < point_count; ++j )
{
+ if ( localpoints[j] >= n_points )
+ continue;
+
delta_xy[localpoints[j]].x += FT_MulFix( deltas_x[j], apply );
delta_xy[localpoints[j]].y += FT_MulFix( deltas_y[j], apply );
}
diff --git a/src/3rdparty/freetype/src/truetype/ttinterp.c b/src/3rdparty/freetype/src/truetype/ttinterp.c
index d1769b8d2a..eccd4aaccb 100644
--- a/src/3rdparty/freetype/src/truetype/ttinterp.c
+++ b/src/3rdparty/freetype/src/truetype/ttinterp.c
@@ -4,8 +4,8 @@
/* */
/* TrueType bytecode interpreter (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* Copyright 1996-2014 */
+/* 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 */
@@ -16,25 +16,25 @@
/***************************************************************************/
+/* Greg Hitchcock from Microsoft has helped a lot in resolving unclear */
+/* issues; many thanks! */
+
+
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_TRIGONOMETRY_H
#include FT_SYSTEM_H
+#include FT_TRUETYPE_DRIVER_H
#include "ttinterp.h"
-
#include "tterrors.h"
+#include "ttsubpix.h"
#ifdef TT_USE_BYTECODE_INTERPRETER
-#define TT_MULFIX FT_MulFix
-#define TT_MULDIV FT_MulDiv
-#define TT_MULDIV_NO_ROUND FT_MulDiv_No_Round
-
-
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -48,7 +48,7 @@
/* */
/* 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 maximal number of opcodes defined below. */
+ /* limited to a maximum number of opcodes defined below. */
/* */
#define MAX_RUNNABLE_OPCODES 1000000L
@@ -132,6 +132,11 @@
#define FT_UNUSED_ARG FT_UNUSED_EXEC; FT_UNUSED( args )
+#define SUBPIXEL_HINTING \
+ ( ((TT_Driver)FT_FACE_DRIVER( CUR.face ))->interpreter_version == \
+ TT_INTERPRETER_VERSION_38 )
+
+
/*************************************************************************/
/* */
/* The following macros hide the use of EXEC_ARG and EXEC_ARG_ to */
@@ -167,6 +172,9 @@
#define CUR_Func_round( d, c ) \
CUR.func_round( EXEC_ARG_ d, c )
+#define CUR_Func_cur_ppem() \
+ CUR.func_cur_ppem( EXEC_ARG )
+
#define CUR_Func_read_cvt( index ) \
CUR.func_read_cvt( EXEC_ARG_ index )
@@ -179,12 +187,6 @@
#define CURRENT_Ratio() \
Current_Ratio( EXEC_ARG )
-#define CURRENT_Ppem() \
- Current_Ppem( EXEC_ARG )
-
-#define CUR_Ppem() \
- Cur_PPEM( EXEC_ARG )
-
#define INS_SxVTL( a, b, c, d ) \
Ins_SxVTL( EXEC_ARG_ a, b, c, d )
@@ -223,9 +225,18 @@
/*************************************************************************/
/* */
- /* A simple bounds-checking macro. */
+ /* Two simple bounds-checking macros. */
+ /* */
+#define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) )
+#define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) )
+
+ /*************************************************************************/
+ /* */
+ /* This macro computes (a*2^14)/b and complements TT_MulFix14. */
/* */
-#define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) )
+#define TT_DivFix14( a, b ) \
+ FT_DivFix( a, (b) << 2 )
+
#undef SUCCESS
#define SUCCESS 0
@@ -268,10 +279,7 @@
/* <InOut> */
/* exec :: The target execution context. */
/* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
FT_Long IP )
@@ -295,8 +303,6 @@
exec->codeSize = coderange->size;
exec->IP = IP;
exec->curRange = range;
-
- return TT_Err_Ok;
}
@@ -318,10 +324,7 @@
/* <InOut> */
/* exec :: The target execution context. */
/* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
void* base,
@@ -331,8 +334,6 @@
exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
exec->codeRangeTable[range - 1].size = length;
-
- return TT_Err_Ok;
}
@@ -350,13 +351,7 @@
/* <InOut> */
/* exec :: The target execution context. */
/* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Does not set the Error variable. */
- /* */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range )
{
@@ -364,8 +359,6 @@
exec->codeRangeTable[range - 1].base = NULL;
exec->codeRangeTable[range - 1].size = 0;
-
- return TT_Err_Ok;
}
@@ -389,13 +382,10 @@
/* */
/* memory :: A handle to the parent memory object. */
/* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
TT_Done_Context( TT_ExecContext exec )
{
FT_Memory memory = exec->memory;
@@ -422,8 +412,6 @@
exec->face = NULL;
FT_FREE( exec );
-
- return TT_Err_Ok;
}
@@ -473,11 +461,10 @@
exec->face = NULL;
exec->size = NULL;
- return TT_Err_Ok;
+ return FT_Err_Ok;
Fail_Memory:
- FT_ERROR(( "Init_Context: not enough memory for 0x%08lx\n",
- (FT_Long)exec ));
+ FT_ERROR(( "Init_Context: not enough memory for %p\n", exec ));
TT_Done_Context( exec );
return error;
@@ -508,7 +495,7 @@
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
- static FT_Error
+ FT_LOCAL_DEF( FT_Error )
Update_Max( FT_Memory memory,
FT_ULong* size,
FT_Long multiplier,
@@ -526,7 +513,7 @@
*size = new_max;
}
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -594,6 +581,12 @@
exec->storage = size->storage;
exec->twilight = size->twilight;
+
+ /* 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 ) );
+ exec->zp1 = exec->zp0;
+ exec->zp2 = exec->zp0;
}
/* XXX: We reserve a little more elements on the stack to deal safely */
@@ -627,7 +620,7 @@
exec->instruction_trap = FALSE;
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -645,22 +638,19 @@
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
TT_Save_Context( TT_ExecContext exec,
TT_Size size )
{
FT_Int i;
- /* XXXX: Will probably disappear soon with all the code range */
- /* management, which is now rather obsolete. */
- /* */
+ /* XXX: Will probably disappear soon with all the code range */
+ /* management, which is now rather obsolete. */
+ /* */
size->num_function_defs = exec->numFDefs;
size->num_instruction_defs = exec->numIDefs;
@@ -669,8 +659,6 @@
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
size->codeRangeTable[i] = exec->codeRangeTable[i];
-
- return TT_Err_Ok;
}
@@ -702,12 +690,7 @@
TT_Run_Context( TT_ExecContext exec,
FT_Bool debug )
{
- FT_Error error;
-
-
- if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) )
- != TT_Err_Ok )
- return error;
+ TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 );
exec->zp0 = exec->pts;
exec->zp1 = exec->pts;
@@ -743,7 +726,7 @@
if ( !debug )
return TT_RunIns( exec );
else
- return TT_Err_Ok;
+ return FT_Err_Ok;
#endif
}
@@ -777,16 +760,18 @@
FT_EXPORT_DEF( TT_ExecContext )
TT_New_Context( TT_Driver driver )
{
- TT_ExecContext exec;
- FT_Memory memory;
+ FT_Memory memory;
+ if ( !driver )
+ goto Fail;
+
memory = driver->root.root.memory;
- exec = driver->context;
if ( !driver->context )
{
- FT_Error error;
+ FT_Error error;
+ TT_ExecContext exec;
/* allocate object */
@@ -805,7 +790,6 @@
return driver->context;
Fail:
- FT_FREE( exec );
return NULL;
}
@@ -980,8 +964,8 @@
/* INS_$83 */ PACK( 0, 0 ),
/* INS_$84 */ PACK( 0, 0 ),
/* ScanCTRL */ PACK( 1, 0 ),
- /* SDVPTL[0] */ PACK( 2, 0 ),
- /* SDVPTL[1] */ PACK( 2, 0 ),
+ /* SDPVTL[0] */ PACK( 2, 0 ),
+ /* SDPVTL[1] */ PACK( 2, 0 ),
/* GetINFO */ PACK( 1, 1 ),
/* IDEF */ PACK( 1, 0 ),
/* ROLL */ PACK( 3, 3 ),
@@ -1112,6 +1096,287 @@
};
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+ static
+ const char* const opcode_name[256] =
+ {
+ "SVTCA y",
+ "SVTCA x",
+ "SPvTCA y",
+ "SPvTCA x",
+ "SFvTCA y",
+ "SFvTCA x",
+ "SPvTL ||",
+ "SPvTL +",
+ "SFvTL ||",
+ "SFvTL +",
+ "SPvFS",
+ "SFvFS",
+ "GPV",
+ "GFV",
+ "SFvTPv",
+ "ISECT",
+
+ "SRP0",
+ "SRP1",
+ "SRP2",
+ "SZP0",
+ "SZP1",
+ "SZP2",
+ "SZPS",
+ "SLOOP",
+ "RTG",
+ "RTHG",
+ "SMD",
+ "ELSE",
+ "JMPR",
+ "SCvTCi",
+ "SSwCi",
+ "SSW",
+
+ "DUP",
+ "POP",
+ "CLEAR",
+ "SWAP",
+ "DEPTH",
+ "CINDEX",
+ "MINDEX",
+ "AlignPTS",
+ "INS_$28",
+ "UTP",
+ "LOOPCALL",
+ "CALL",
+ "FDEF",
+ "ENDF",
+ "MDAP[0]",
+ "MDAP[1]",
+
+ "IUP[0]",
+ "IUP[1]",
+ "SHP[0]",
+ "SHP[1]",
+ "SHC[0]",
+ "SHC[1]",
+ "SHZ[0]",
+ "SHZ[1]",
+ "SHPIX",
+ "IP",
+ "MSIRP[0]",
+ "MSIRP[1]",
+ "AlignRP",
+ "RTDG",
+ "MIAP[0]",
+ "MIAP[1]",
+
+ "NPushB",
+ "NPushW",
+ "WS",
+ "RS",
+ "WCvtP",
+ "RCvt",
+ "GC[0]",
+ "GC[1]",
+ "SCFS",
+ "MD[0]",
+ "MD[1]",
+ "MPPEM",
+ "MPS",
+ "FlipON",
+ "FlipOFF",
+ "DEBUG",
+
+ "LT",
+ "LTEQ",
+ "GT",
+ "GTEQ",
+ "EQ",
+ "NEQ",
+ "ODD",
+ "EVEN",
+ "IF",
+ "EIF",
+ "AND",
+ "OR",
+ "NOT",
+ "DeltaP1",
+ "SDB",
+ "SDS",
+
+ "ADD",
+ "SUB",
+ "DIV",
+ "MUL",
+ "ABS",
+ "NEG",
+ "FLOOR",
+ "CEILING",
+ "ROUND[0]",
+ "ROUND[1]",
+ "ROUND[2]",
+ "ROUND[3]",
+ "NROUND[0]",
+ "NROUND[1]",
+ "NROUND[2]",
+ "NROUND[3]",
+
+ "WCvtF",
+ "DeltaP2",
+ "DeltaP3",
+ "DeltaCn[0]",
+ "DeltaCn[1]",
+ "DeltaCn[2]",
+ "SROUND",
+ "S45Round",
+ "JROT",
+ "JROF",
+ "ROFF",
+ "INS_$7B",
+ "RUTG",
+ "RDTG",
+ "SANGW",
+ "AA",
+
+ "FlipPT",
+ "FlipRgON",
+ "FlipRgOFF",
+ "INS_$83",
+ "INS_$84",
+ "ScanCTRL",
+ "SDVPTL[0]",
+ "SDVPTL[1]",
+ "GetINFO",
+ "IDEF",
+ "ROLL",
+ "MAX",
+ "MIN",
+ "ScanTYPE",
+ "InstCTRL",
+ "INS_$8F",
+
+ "INS_$90",
+ "INS_$91",
+ "INS_$92",
+ "INS_$93",
+ "INS_$94",
+ "INS_$95",
+ "INS_$96",
+ "INS_$97",
+ "INS_$98",
+ "INS_$99",
+ "INS_$9A",
+ "INS_$9B",
+ "INS_$9C",
+ "INS_$9D",
+ "INS_$9E",
+ "INS_$9F",
+
+ "INS_$A0",
+ "INS_$A1",
+ "INS_$A2",
+ "INS_$A3",
+ "INS_$A4",
+ "INS_$A5",
+ "INS_$A6",
+ "INS_$A7",
+ "INS_$A8",
+ "INS_$A9",
+ "INS_$AA",
+ "INS_$AB",
+ "INS_$AC",
+ "INS_$AD",
+ "INS_$AE",
+ "INS_$AF",
+
+ "PushB[0]",
+ "PushB[1]",
+ "PushB[2]",
+ "PushB[3]",
+ "PushB[4]",
+ "PushB[5]",
+ "PushB[6]",
+ "PushB[7]",
+ "PushW[0]",
+ "PushW[1]",
+ "PushW[2]",
+ "PushW[3]",
+ "PushW[4]",
+ "PushW[5]",
+ "PushW[6]",
+ "PushW[7]",
+
+ "MDRP[00]",
+ "MDRP[01]",
+ "MDRP[02]",
+ "MDRP[03]",
+ "MDRP[04]",
+ "MDRP[05]",
+ "MDRP[06]",
+ "MDRP[07]",
+ "MDRP[08]",
+ "MDRP[09]",
+ "MDRP[10]",
+ "MDRP[11]",
+ "MDRP[12]",
+ "MDRP[13]",
+ "MDRP[14]",
+ "MDRP[15]",
+
+ "MDRP[16]",
+ "MDRP[17]",
+ "MDRP[18]",
+ "MDRP[19]",
+ "MDRP[20]",
+ "MDRP[21]",
+ "MDRP[22]",
+ "MDRP[23]",
+ "MDRP[24]",
+ "MDRP[25]",
+ "MDRP[26]",
+ "MDRP[27]",
+ "MDRP[28]",
+ "MDRP[29]",
+ "MDRP[30]",
+ "MDRP[31]",
+
+ "MIRP[00]",
+ "MIRP[01]",
+ "MIRP[02]",
+ "MIRP[03]",
+ "MIRP[04]",
+ "MIRP[05]",
+ "MIRP[06]",
+ "MIRP[07]",
+ "MIRP[08]",
+ "MIRP[09]",
+ "MIRP[10]",
+ "MIRP[11]",
+ "MIRP[12]",
+ "MIRP[13]",
+ "MIRP[14]",
+ "MIRP[15]",
+
+ "MIRP[16]",
+ "MIRP[17]",
+ "MIRP[18]",
+ "MIRP[19]",
+ "MIRP[20]",
+ "MIRP[21]",
+ "MIRP[22]",
+ "MIRP[23]",
+ "MIRP[24]",
+ "MIRP[25]",
+ "MIRP[26]",
+ "MIRP[27]",
+ "MIRP[28]",
+ "MIRP[29]",
+ "MIRP[30]",
+ "MIRP[31]"
+ };
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+
static
const FT_Char opcode_length[256] =
{
@@ -1138,8 +1403,107 @@
#undef PACK
-#if 1
+#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
+
+#if defined( __arm__ ) && \
+ ( defined( __thumb2__ ) || !defined( __thumb__ ) )
+
+#define TT_MulFix14 TT_MulFix14_arm
+
+ static FT_Int32
+ TT_MulFix14_arm( FT_Int32 a,
+ FT_Int b )
+ {
+ FT_Int32 t, t2;
+
+
+#if defined( __CC_ARM ) || defined( __ARMCC__ )
+
+ __asm
+ {
+ smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
+ mov a, t, asr #31 /* a = (hi >> 31) */
+ add a, a, #0x2000 /* a += 0x2000 */
+ adds t2, t2, a /* t2 += a */
+ adc t, t, #0 /* t += carry */
+ mov a, t2, lsr #14 /* a = t2 >> 14 */
+ orr a, a, t, lsl #18 /* a |= t << 18 */
+ }
+
+#elif defined( __GNUC__ )
+
+ __asm__ __volatile__ (
+ "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
+ "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
+#if defined( __clang__ ) && defined( __thumb2__ )
+ "add.w %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
+#else
+ "add %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
+#endif
+ "adds %1, %1, %0\n\t" /* %1 += %0 */
+ "adc %2, %2, #0\n\t" /* %2 += carry */
+ "mov %0, %1, lsr #14\n\t" /* %0 = %1 >> 16 */
+ "orr %0, %0, %2, lsl #18\n\t" /* %0 |= %2 << 16 */
+ : "=r"(a), "=&r"(t2), "=&r"(t)
+ : "r"(a), "r"(b)
+ : "cc" );
+
+#endif
+
+ return a;
+ }
+
+#endif /* __arm__ && ( __thumb2__ || !__thumb__ ) */
+
+#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
+
+
+#if defined( __GNUC__ ) && \
+ ( defined( __i386__ ) || defined( __x86_64__ ) )
+
+#define TT_MulFix14 TT_MulFix14_long_long
+
+ /* Temporarily disable the warning that C90 doesn't support `long long'. */
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic push
+#endif
+#pragma GCC diagnostic ignored "-Wlong-long"
+
+ /* This is declared `noinline' because inlining the function results */
+ /* in slower code. The `pure' attribute indicates that the result */
+ /* only depends on the parameters. */
+ static __attribute__(( noinline ))
+ __attribute__(( pure )) FT_Int32
+ TT_MulFix14_long_long( FT_Int32 a,
+ FT_Int b )
+ {
+
+ long long ret = (long long)a * b;
+
+ /* The following line assumes that right shifting of signed values */
+ /* will actually preserve the sign bit. The exact behaviour is */
+ /* undefined, but this is true on x86 and x86_64. */
+ long long tmp = ret >> 63;
+
+
+ ret += 0x2000 + tmp;
+
+ return (FT_Int32)( ret >> 14 );
+ }
+
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic pop
+#endif
+
+#endif /* __GNUC__ && ( __i386__ || __x86_64__ ) */
+
+
+#ifndef TT_MulFix14
+
+ /* Compute (a*b)/2^14 with maximum accuracy and rounding. */
+ /* This is optimized to be faster than calling FT_MulFix() */
+ /* for platforms where sizeof(int) == 2. */
static FT_Int32
TT_MulFix14( FT_Int32 a,
FT_Int b )
@@ -1171,39 +1535,52 @@
return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
}
-#else
+#endif /* !TT_MulFix14 */
- /* compute (a*b)/2^14 with maximal accuracy and rounding */
- static FT_Int32
- TT_MulFix14( FT_Int32 a,
- FT_Int b )
- {
- FT_Int32 m, s, hi;
- FT_UInt32 l, lo;
+#if defined( __GNUC__ ) && \
+ ( defined( __i386__ ) || \
+ defined( __x86_64__ ) || \
+ defined( __arm__ ) )
- /* compute ax*bx as 64-bit value */
- l = (FT_UInt32)( ( a & 0xFFFFU ) * b );
- m = ( a >> 16 ) * b;
+#define TT_DotFix14 TT_DotFix14_long_long
+
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic push
+#endif
+#pragma GCC diagnostic ignored "-Wlong-long"
- lo = l + (FT_UInt32)( m << 16 );
- hi = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo < l );
+ static __attribute__(( pure )) FT_Int32
+ TT_DotFix14_long_long( FT_Int32 ax,
+ FT_Int32 ay,
+ FT_Int bx,
+ FT_Int by )
+ {
+ /* Temporarily disable the warning that C90 doesn't support */
+ /* `long long'. */
- /* divide the result by 2^14 with rounding */
- s = hi >> 31;
- l = lo + (FT_UInt32)s;
- hi += s + ( l < lo );
- lo = l;
+ long long temp1 = (long long)ax * bx;
+ long long temp2 = (long long)ay * by;
- l = lo + 0x2000U;
- hi += l < lo;
- return ( hi << 18 ) | ( l >> 14 );
+ temp1 += temp2;
+ temp2 = temp1 >> 63;
+ temp1 += 0x2000 + temp2;
+
+ return (FT_Int32)( temp1 >> 14 );
+
}
+
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic pop
#endif
+#endif /* __GNUC__ && (__arm__ || __i386__ || __x86_64__) */
+
- /* compute (ax*bx+ay*by)/2^14 with maximal accuracy and rounding */
+#ifndef TT_DotFix14
+
+ /* compute (ax*bx+ay*by)/2^14 with maximum accuracy and rounding */
static FT_Int32
TT_DotFix14( FT_Int32 ax,
FT_Int32 ay,
@@ -1218,14 +1595,14 @@
l = (FT_UInt32)( ( ax & 0xFFFFU ) * bx );
m = ( ax >> 16 ) * bx;
- lo1 = l + (FT_UInt32)( m << 16 );
+ lo1 = l + ( (FT_UInt32)m << 16 );
hi1 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo1 < l );
/* compute ay*by as 64-bit value */
l = (FT_UInt32)( ( ay & 0xFFFFU ) * by );
m = ( ay >> 16 ) * by;
- lo2 = l + (FT_UInt32)( m << 16 );
+ lo2 = l + ( (FT_UInt32)m << 16 );
hi2 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo2 < l );
/* add them */
@@ -1241,98 +1618,10 @@
l = lo + 0x2000U;
hi += ( l < lo );
- return ( hi << 18 ) | ( l >> 14 );
- }
-
-
- /* return length of given vector */
-
-#if 0
-
- static FT_Int32
- TT_VecLen( FT_Int32 x,
- FT_Int32 y )
- {
- FT_Int32 m, hi1, hi2, hi;
- FT_UInt32 l, lo1, lo2, lo;
-
-
- /* compute x*x as 64-bit value */
- lo = (FT_UInt32)( x & 0xFFFFU );
- hi = x >> 16;
-
- l = lo * lo;
- m = hi * lo;
- hi = hi * hi;
-
- lo1 = l + (FT_UInt32)( m << 17 );
- hi1 = hi + ( m >> 15 ) + ( lo1 < l );
-
- /* compute y*y as 64-bit value */
- lo = (FT_UInt32)( y & 0xFFFFU );
- hi = y >> 16;
-
- l = lo * lo;
- m = hi * lo;
- hi = hi * hi;
-
- lo2 = l + (FT_UInt32)( m << 17 );
- hi2 = hi + ( m >> 15 ) + ( lo2 < l );
-
- /* add them to get 'x*x+y*y' as 64-bit value */
- lo = lo1 + lo2;
- hi = hi1 + hi2 + ( lo < lo1 );
-
- /* compute the square root of this value */
- {
- FT_UInt32 root, rem, test_div;
- FT_Int count;
-
-
- root = 0;
-
- {
- rem = 0;
- count = 32;
- do
- {
- rem = ( rem << 2 ) | ( (FT_UInt32)hi >> 30 );
- hi = ( hi << 2 ) | ( lo >> 30 );
- lo <<= 2;
- root <<= 1;
- test_div = ( root << 1 ) + 1;
-
- if ( rem >= test_div )
- {
- rem -= test_div;
- root += 1;
- }
- } while ( --count );
- }
-
- return (FT_Int32)root;
- }
+ return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
}
-#else
-
- /* this version uses FT_Vector_Length which computes the same value */
- /* much, much faster.. */
- /* */
- static FT_F26Dot6
- TT_VecLen( FT_F26Dot6 X,
- FT_F26Dot6 Y )
- {
- FT_Vector v;
-
-
- v.x = X;
- v.y = Y;
-
- return FT_Vector_Length( &v );
- }
-
-#endif
+#endif /* TT_DotFix14 */
/*************************************************************************/
@@ -1371,14 +1660,14 @@
else
{
- FT_Long x, y;
+ FT_F26Dot6 x, y;
- x = TT_MULDIV( CUR.GS.projVector.x,
- CUR.tt_metrics.x_ratio, 0x4000 );
- y = TT_MULDIV( CUR.GS.projVector.y,
- CUR.tt_metrics.y_ratio, 0x4000 );
- CUR.tt_metrics.ratio = TT_VecLen( x, y );
+ x = TT_MulFix14( CUR.tt_metrics.x_ratio,
+ CUR.GS.projVector.x );
+ y = TT_MulFix14( CUR.tt_metrics.y_ratio,
+ CUR.GS.projVector.y );
+ CUR.tt_metrics.ratio = FT_Hypot( x, y );
}
}
}
@@ -1386,10 +1675,17 @@
}
- static FT_Long
+ FT_CALLBACK_DEF( FT_Long )
Current_Ppem( EXEC_OP )
{
- return TT_MULFIX( CUR.tt_metrics.ppem, CURRENT_Ratio() );
+ return CUR.tt_metrics.ppem;
+ }
+
+
+ FT_CALLBACK_DEF( FT_Long )
+ Current_Ppem_Stretched( EXEC_OP )
+ {
+ return FT_MulFix( CUR.tt_metrics.ppem, CURRENT_Ratio() );
}
@@ -1410,7 +1706,7 @@
FT_CALLBACK_DEF( FT_F26Dot6 )
Read_CVT_Stretched( EXEC_OP_ FT_ULong idx )
{
- return TT_MULFIX( CUR.cvt[idx], CURRENT_Ratio() );
+ return FT_MulFix( CUR.cvt[idx], CURRENT_Ratio() );
}
@@ -1496,7 +1792,7 @@
if ( aRange < 1 || aRange > 3 )
{
- CUR.error = TT_Err_Bad_Argument;
+ CUR.error = FT_THROW( Bad_Argument );
return FAILURE;
}
@@ -1504,17 +1800,17 @@
if ( range->base == NULL ) /* invalid coderange */
{
- CUR.error = TT_Err_Invalid_CodeRange;
+ CUR.error = FT_THROW( Invalid_CodeRange );
return FAILURE;
}
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
- /* range, we test for AIP <= Size, instead of AIP < Size. */
+ /* range, we test for aIP <= Size, instead of aIP < Size. */
if ( aIP > range->size )
{
- CUR.error = TT_Err_Code_Overflow;
+ CUR.error = FT_THROW( Code_Overflow );
return FAILURE;
}
@@ -1560,9 +1856,12 @@
if ( v != 0 )
{
- zone->cur[point].x += TT_MULDIV( distance,
- v * 0x10000L,
- CUR.F_dot_P );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( !SUBPIXEL_HINTING ||
+ ( !CUR.ignore_x_mode ||
+ ( CUR.sph_tweak_flags & SPH_TWEAK_ALLOW_X_DMOVE ) ) )
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+ zone->cur[point].x += FT_MulDiv( distance, v, CUR.F_dot_P );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
@@ -1571,9 +1870,7 @@
if ( v != 0 )
{
- zone->cur[point].y += TT_MULDIV( distance,
- v * 0x10000L,
- CUR.F_dot_P );
+ zone->cur[point].y += FT_MulDiv( distance, v, CUR.F_dot_P );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
@@ -1612,16 +1909,12 @@
v = CUR.GS.freeVector.x;
if ( v != 0 )
- zone->org[point].x += TT_MULDIV( distance,
- v * 0x10000L,
- CUR.F_dot_P );
+ zone->org[point].x += FT_MulDiv( distance, v, CUR.F_dot_P );
v = CUR.GS.freeVector.y;
if ( v != 0 )
- zone->org[point].y += TT_MULDIV( distance,
- v * 0x10000L,
- CUR.F_dot_P );
+ zone->org[point].y += FT_MulDiv( distance, v, CUR.F_dot_P );
}
@@ -1642,7 +1935,12 @@
{
FT_UNUSED_EXEC;
- zone->cur[point].x += distance;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( !SUBPIXEL_HINTING ||
+ !CUR.ignore_x_mode )
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+ zone->cur[point].x += distance;
+
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
@@ -1725,10 +2023,11 @@
if ( distance >= 0 )
{
val = distance + compensation;
- if ( distance && val < 0 )
+ if ( val < 0 )
val = 0;
}
- else {
+ else
+ {
val = distance - compensation;
if ( val > 0 )
val = 0;
@@ -1764,10 +2063,8 @@
if ( distance >= 0 )
{
- val = distance + compensation + 32;
- if ( distance && val > 0 )
- val &= ~63;
- else
+ val = FT_PIX_ROUND( distance + compensation );
+ if ( val < 0 )
val = 0;
}
else
@@ -1809,14 +2106,14 @@
if ( distance >= 0 )
{
val = FT_PIX_FLOOR( distance + compensation ) + 32;
- if ( distance && val < 0 )
- val = 0;
+ if ( val < 0 )
+ val = 32;
}
else
{
val = -( FT_PIX_FLOOR( compensation - distance ) + 32 );
if ( val > 0 )
- val = 0;
+ val = -32;
}
return val;
@@ -1850,15 +2147,13 @@
if ( distance >= 0 )
{
- val = distance + compensation;
- if ( distance && val > 0 )
- val &= ~63;
- else
+ val = FT_PIX_FLOOR( distance + compensation );
+ if ( val < 0 )
val = 0;
}
else
{
- val = -( ( compensation - distance ) & -64 );
+ val = -FT_PIX_FLOOR( compensation - distance );
if ( val > 0 )
val = 0;
}
@@ -1894,15 +2189,13 @@
if ( distance >= 0 )
{
- val = distance + compensation + 63;
- if ( distance && val > 0 )
- val &= ~63;
- else
+ val = FT_PIX_CEIL( distance + compensation );
+ if ( val < 0 )
val = 0;
}
else
{
- val = - FT_PIX_CEIL( compensation - distance );
+ val = -FT_PIX_CEIL( compensation - distance );
if ( val > 0 )
val = 0;
}
@@ -1938,10 +2231,8 @@
if ( distance >= 0 )
{
- val = distance + compensation + 16;
- if ( distance && val > 0 )
- val &= ~31;
- else
+ val = FT_PAD_ROUND( distance + compensation, 32 );
+ if ( val < 0 )
val = 0;
}
else
@@ -1988,17 +2279,17 @@
{
val = ( distance - CUR.phase + CUR.threshold + compensation ) &
-CUR.period;
- if ( distance && val < 0 )
- val = 0;
val += CUR.phase;
+ if ( val < 0 )
+ val = CUR.phase;
}
else
{
val = -( ( CUR.threshold - CUR.phase - distance + compensation ) &
-CUR.period );
- if ( val > 0 )
- val = 0;
val -= CUR.phase;
+ if ( val > 0 )
+ val = -CUR.phase;
}
return val;
@@ -2036,17 +2327,17 @@
{
val = ( ( distance - CUR.phase + CUR.threshold + compensation ) /
CUR.period ) * CUR.period;
- if ( distance && val < 0 )
- val = 0;
val += CUR.phase;
+ if ( val < 0 )
+ val = CUR.phase;
}
else
{
val = -( ( ( CUR.threshold - CUR.phase - distance + compensation ) /
CUR.period ) * CUR.period );
- if ( val > 0 )
- val = 0;
val -= CUR.phase;
+ if ( val > 0 )
+ val = -CUR.phase;
}
return val;
@@ -2113,8 +2404,9 @@
/* Sets Super Round parameters. */
/* */
/* <Input> */
- /* GridPeriod :: Grid period */
- /* selector :: SROUND opcode */
+ /* GridPeriod :: The grid period. */
+ /* */
+ /* selector :: The SROUND opcode. */
/* */
static void
SetSuperRound( EXEC_OP_ FT_F26Dot6 GridPeriod,
@@ -2326,13 +2618,10 @@
if ( CUR.GS.dualVector.x == 0x4000 )
CUR.func_dualproj = Project_x;
+ else if ( CUR.GS.dualVector.y == 0x4000 )
+ CUR.func_dualproj = Project_y;
else
- {
- if ( CUR.GS.dualVector.y == 0x4000 )
- CUR.func_dualproj = Project_y;
- else
- CUR.func_dualproj = Dual_Project;
- }
+ CUR.func_dualproj = Dual_Project;
/* Force recalculation of cached aspect ratio */
CUR.tt_metrics.ratio = 0;
@@ -2342,61 +2631,50 @@
#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */
if ( CUR.GS.freeVector.x == 0x4000 )
- CUR.F_dot_P = CUR.GS.projVector.x * 0x10000L;
+ CUR.F_dot_P = CUR.GS.projVector.x;
+ else if ( CUR.GS.freeVector.y == 0x4000 )
+ CUR.F_dot_P = CUR.GS.projVector.y;
else
- {
- if ( CUR.GS.freeVector.y == 0x4000 )
- CUR.F_dot_P = CUR.GS.projVector.y * 0x10000L;
- else
- CUR.F_dot_P = (FT_Long)CUR.GS.projVector.x * CUR.GS.freeVector.x * 4 +
- (FT_Long)CUR.GS.projVector.y * CUR.GS.freeVector.y * 4;
- }
+ CUR.F_dot_P = ( (FT_Long)CUR.GS.projVector.x * CUR.GS.freeVector.x +
+ (FT_Long)CUR.GS.projVector.y * CUR.GS.freeVector.y ) >>
+ 14;
if ( CUR.GS.projVector.x == 0x4000 )
CUR.func_project = (TT_Project_Func)Project_x;
+ else if ( CUR.GS.projVector.y == 0x4000 )
+ CUR.func_project = (TT_Project_Func)Project_y;
else
- {
- if ( CUR.GS.projVector.y == 0x4000 )
- CUR.func_project = (TT_Project_Func)Project_y;
- else
- CUR.func_project = (TT_Project_Func)Project;
- }
+ CUR.func_project = (TT_Project_Func)Project;
if ( CUR.GS.dualVector.x == 0x4000 )
CUR.func_dualproj = (TT_Project_Func)Project_x;
+ else if ( CUR.GS.dualVector.y == 0x4000 )
+ CUR.func_dualproj = (TT_Project_Func)Project_y;
else
- {
- if ( CUR.GS.dualVector.y == 0x4000 )
- CUR.func_dualproj = (TT_Project_Func)Project_y;
- else
- CUR.func_dualproj = (TT_Project_Func)Dual_Project;
- }
+ CUR.func_dualproj = (TT_Project_Func)Dual_Project;
CUR.func_move = (TT_Move_Func)Direct_Move;
CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig;
- if ( CUR.F_dot_P == 0x40000000L )
+ if ( CUR.F_dot_P == 0x4000L )
{
if ( CUR.GS.freeVector.x == 0x4000 )
{
CUR.func_move = (TT_Move_Func)Direct_Move_X;
CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig_X;
}
- else
+ else if ( CUR.GS.freeVector.y == 0x4000 )
{
- if ( CUR.GS.freeVector.y == 0x4000 )
- {
- CUR.func_move = (TT_Move_Func)Direct_Move_Y;
- CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y;
- }
+ CUR.func_move = (TT_Move_Func)Direct_Move_Y;
+ CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y;
}
}
/* at small sizes, F_dot_P can become too small, resulting */
/* in overflows and `spikes' in a number of glyphs like `w'. */
- if ( FT_ABS( CUR.F_dot_P ) < 0x4000000L )
- CUR.F_dot_P = 0x40000000L;
+ if ( FT_ABS( CUR.F_dot_P ) < 0x400L )
+ CUR.F_dot_P = 0x4000L;
/* Disable cached aspect ratio */
CUR.tt_metrics.ratio = 0;
@@ -2425,98 +2703,33 @@
/* In case Vx and Vy are both zero, Normalize() returns SUCCESS, and */
/* R is undefined. */
/* */
-
-
static FT_Bool
Normalize( EXEC_OP_ FT_F26Dot6 Vx,
FT_F26Dot6 Vy,
FT_UnitVector* R )
{
FT_F26Dot6 W;
- FT_Bool S1, S2;
FT_UNUSED_EXEC;
- if ( FT_ABS( Vx ) < 0x10000L && FT_ABS( Vy ) < 0x10000L )
+ if ( FT_ABS( Vx ) < 0x4000L && FT_ABS( Vy ) < 0x4000L )
{
- Vx *= 0x100;
- Vy *= 0x100;
-
- W = TT_VecLen( Vx, Vy );
-
- if ( W == 0 )
+ if ( Vx == 0 && Vy == 0 )
{
/* XXX: UNDOCUMENTED! It seems that it is possible to try */
/* to normalize the vector (0,0). Return immediately. */
return SUCCESS;
}
- R->x = (FT_F2Dot14)FT_MulDiv( Vx, 0x4000L, W );
- R->y = (FT_F2Dot14)FT_MulDiv( Vy, 0x4000L, W );
-
- return SUCCESS;
- }
-
- W = TT_VecLen( Vx, Vy );
-
- Vx = FT_MulDiv( Vx, 0x4000L, W );
- Vy = FT_MulDiv( Vy, 0x4000L, W );
-
- W = Vx * Vx + Vy * Vy;
-
- /* Now, we want that Sqrt( W ) = 0x4000 */
- /* Or 0x10000000 <= W < 0x10004000 */
-
- if ( Vx < 0 )
- {
- Vx = -Vx;
- S1 = TRUE;
- }
- else
- S1 = FALSE;
-
- if ( Vy < 0 )
- {
- Vy = -Vy;
- S2 = TRUE;
- }
- else
- S2 = FALSE;
-
- while ( W < 0x10000000L )
- {
- /* We need to increase W by a minimal amount */
- if ( Vx < Vy )
- Vx++;
- else
- Vy++;
-
- W = Vx * Vx + Vy * Vy;
+ Vx *= 0x4000;
+ Vy *= 0x4000;
}
- while ( W >= 0x10004000L )
- {
- /* We need to decrease W by a minimal amount */
- if ( Vx < Vy )
- Vx--;
- else
- Vy--;
-
- W = Vx * Vx + Vy * Vy;
- }
-
- /* Note that in various cases, we can only */
- /* compute a Sqrt(W) of 0x3FFF, eg. Vx = Vy */
-
- if ( S1 )
- Vx = -Vx;
+ W = FT_Hypot( Vx, Vy );
- if ( S2 )
- Vy = -Vy;
-
- R->x = (FT_F2Dot14)Vx; /* Type conversion */
- R->y = (FT_F2Dot14)Vy; /* Type conversion */
+ R->x = (FT_F2Dot14)TT_DivFix14( Vx, W );
+ R->y = (FT_F2Dot14)TT_DivFix14( Vy, W );
return SUCCESS;
}
@@ -2544,7 +2757,7 @@
BOUNDS( aIdx2, CUR.zp1.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return FAILURE;
}
@@ -2554,6 +2767,17 @@
A = p1->x - p2->x;
B = p1->y - p2->y;
+ /* If p1 == p2, SPVTL and SFVTL behave the same as */
+ /* SPVTCA[X] and SFVTCA[X], respectively. */
+ /* */
+ /* Confirmed by Greg Hitchcock. */
+
+ if ( A == 0 && B == 0 )
+ {
+ A = 0x4000;
+ aOpc = 0;
+ }
+
if ( ( aOpc & 1 ) != 0 )
{
C = B; /* counter clockwise rotation */
@@ -2789,10 +3013,10 @@
CUR.func_round = (TT_Round_Func)Round_Super_45;
-#define DO_SLOOP \
- if ( args[0] < 0 ) \
- CUR.error = TT_Err_Bad_Argument; \
- else \
+#define DO_SLOOP \
+ if ( args[0] < 0 ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ else \
CUR.GS.loop = args[0];
@@ -2808,14 +3032,9 @@
CUR.GS.single_width_cutin = (FT_F26Dot6)args[0];
- /* XXX: UNDOCUMENTED! or bug in the Windows engine? */
- /* */
- /* It seems that the value that is read here is */
- /* expressed in 16.16 format rather than in font */
- /* units. */
- /* */
-#define DO_SSW \
- CUR.GS.single_width_value = (FT_F26Dot6)( args[0] >> 10 );
+#define DO_SSW \
+ CUR.GS.single_width_value = FT_MulFix( args[0], \
+ CUR.tt_metrics.scale );
#define DO_FLIPON \
@@ -2826,19 +3045,22 @@
CUR.GS.auto_flip = FALSE;
-#define DO_SDB \
- CUR.GS.delta_base = (FT_Short)args[0];
+#define DO_SDB \
+ CUR.GS.delta_base = (FT_UShort)args[0];
-#define DO_SDS \
- CUR.GS.delta_shift = (FT_Short)args[0];
+#define DO_SDS \
+ if ( (FT_ULong)args[0] > 6UL ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ else \
+ CUR.GS.delta_shift = (FT_UShort)args[0];
#define DO_MD /* nothing */
-#define DO_MPPEM \
- args[0] = CURRENT_Ppem();
+#define DO_MPPEM \
+ args[0] = CUR_Func_cur_ppem();
/* Note: The pointSize should be irrelevant in a given font program; */
@@ -2850,8 +3072,8 @@
#else
-#define DO_MPS \
- args[0] = CURRENT_Ppem();
+#define DO_MPS \
+ args[0] = CUR_Func_cur_ppem();
#endif /* 0 */
@@ -2879,38 +3101,60 @@
args[0] = CUR.top;
-#define DO_CINDEX \
- { \
- FT_Long L; \
- \
- \
- L = args[0]; \
- \
- if ( L <= 0 || L > CUR.args ) \
- CUR.error = TT_Err_Invalid_Reference; \
- else \
- args[0] = CUR.stack[CUR.args - L]; \
- }
-
-
-#define DO_JROT \
- if ( args[1] != 0 ) \
- { \
- CUR.IP += args[0]; \
- CUR.step_ins = FALSE; \
- }
-
-
-#define DO_JMPR \
- CUR.IP += args[0]; \
+#define DO_CINDEX \
+ { \
+ FT_Long L; \
+ \
+ \
+ L = args[0]; \
+ \
+ if ( L <= 0 || L > CUR.args ) \
+ { \
+ if ( CUR.pedantic_hinting ) \
+ CUR.error = FT_THROW( Invalid_Reference ); \
+ args[0] = 0; \
+ } \
+ else \
+ args[0] = CUR.stack[CUR.args - L]; \
+ }
+
+
+#define DO_JROT \
+ if ( args[1] != 0 ) \
+ { \
+ if ( args[0] == 0 && CUR.args == 0 ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.IP += args[0]; \
+ if ( CUR.IP < 0 || \
+ ( CUR.callTop > 0 && \
+ CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.step_ins = FALSE; \
+ }
+
+
+#define DO_JMPR \
+ if ( args[0] == 0 && CUR.args == 0 ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.IP += args[0]; \
+ if ( CUR.IP < 0 || \
+ ( CUR.callTop > 0 && \
+ CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
CUR.step_ins = FALSE;
-#define DO_JROF \
- if ( args[1] == 0 ) \
- { \
- CUR.IP += args[0]; \
- CUR.step_ins = FALSE; \
+#define DO_JROF \
+ if ( args[1] == 0 ) \
+ { \
+ if ( args[0] == 0 && CUR.args == 0 ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.IP += args[0]; \
+ if ( CUR.IP < 0 || \
+ ( CUR.callTop > 0 && \
+ CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.step_ins = FALSE; \
}
@@ -2968,13 +3212,13 @@
#define DO_DIV \
if ( args[1] == 0 ) \
- CUR.error = TT_Err_Divide_By_Zero; \
+ CUR.error = FT_THROW( Divide_By_Zero ); \
else \
- args[0] = TT_MULDIV_NO_ROUND( args[0], 64L, args[1] );
+ args[0] = FT_MulDiv_No_Round( args[0], 64L, args[1] );
#define DO_MUL \
- args[0] = TT_MULDIV( args[0], args[1], 64L );
+ args[0] = FT_MulDiv( args[0], args[1], 64L );
#define DO_ABS \
@@ -2992,40 +3236,81 @@
#define DO_CEILING \
args[0] = FT_PIX_CEIL( args[0] );
-
-#define DO_RS \
- { \
- FT_ULong I = (FT_ULong)args[0]; \
- \
- \
- if ( BOUNDS( I, CUR.storeSize ) ) \
- { \
- if ( CUR.pedantic_hinting ) \
- { \
- ARRAY_BOUND_ERROR; \
- } \
- else \
- args[0] = 0; \
- } \
- else \
- args[0] = CUR.storage[I]; \
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+#define DO_RS \
+ { \
+ FT_ULong I = (FT_ULong)args[0]; \
+ \
+ \
+ if ( BOUNDSL( I, CUR.storeSize ) ) \
+ { \
+ if ( CUR.pedantic_hinting ) \
+ ARRAY_BOUND_ERROR; \
+ else \
+ args[0] = 0; \
+ } \
+ else \
+ { \
+ /* subpixel hinting - avoid Typeman Dstroke and */ \
+ /* IStroke and Vacuform rounds */ \
+ \
+ if ( SUBPIXEL_HINTING && \
+ CUR.ignore_x_mode && \
+ ( ( I == 24 && \
+ ( CUR.face->sph_found_func_flags & \
+ ( SPH_FDEF_SPACING_1 | \
+ SPH_FDEF_SPACING_2 ) ) ) || \
+ ( I == 22 && \
+ ( CUR.sph_in_func_flags & \
+ SPH_FDEF_TYPEMAN_STROKES ) ) || \
+ ( I == 8 && \
+ ( CUR.face->sph_found_func_flags & \
+ SPH_FDEF_VACUFORM_ROUND_1 ) && \
+ CUR.iup_called ) ) ) \
+ args[0] = 0; \
+ else \
+ args[0] = CUR.storage[I]; \
+ } \
}
+#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+#define DO_RS \
+ { \
+ FT_ULong I = (FT_ULong)args[0]; \
+ \
+ \
+ if ( BOUNDSL( I, CUR.storeSize ) ) \
+ { \
+ if ( CUR.pedantic_hinting ) \
+ { \
+ ARRAY_BOUND_ERROR; \
+ } \
+ else \
+ args[0] = 0; \
+ } \
+ else \
+ args[0] = CUR.storage[I]; \
+ }
-#define DO_WS \
- { \
- FT_ULong I = (FT_ULong)args[0]; \
- \
- \
- if ( BOUNDS( I, CUR.storeSize ) ) \
- { \
- if ( CUR.pedantic_hinting ) \
- { \
- ARRAY_BOUND_ERROR; \
- } \
- } \
- else \
- CUR.storage[I] = args[1]; \
+#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+
+#define DO_WS \
+ { \
+ FT_ULong I = (FT_ULong)args[0]; \
+ \
+ \
+ if ( BOUNDSL( I, CUR.storeSize ) ) \
+ { \
+ if ( CUR.pedantic_hinting ) \
+ { \
+ ARRAY_BOUND_ERROR; \
+ } \
+ } \
+ else \
+ CUR.storage[I] = args[1]; \
}
@@ -3034,7 +3319,7 @@
FT_ULong I = (FT_ULong)args[0]; \
\
\
- if ( BOUNDS( I, CUR.cvtSize ) ) \
+ if ( BOUNDSL( I, CUR.cvtSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
@@ -3053,7 +3338,7 @@
FT_ULong I = (FT_ULong)args[0]; \
\
\
- if ( BOUNDS( I, CUR.cvtSize ) ) \
+ if ( BOUNDSL( I, CUR.cvtSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
@@ -3070,7 +3355,7 @@
FT_ULong I = (FT_ULong)args[0]; \
\
\
- if ( BOUNDS( I, CUR.cvtSize ) ) \
+ if ( BOUNDSL( I, CUR.cvtSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
@@ -3078,12 +3363,12 @@
} \
} \
else \
- CUR.cvt[I] = TT_MULFIX( args[1], CUR.tt_metrics.scale ); \
+ CUR.cvt[I] = FT_MulFix( args[1], CUR.tt_metrics.scale ); \
}
-#define DO_DEBUG \
- CUR.error = TT_Err_Debug_OpCode;
+#define DO_DEBUG \
+ CUR.error = FT_THROW( Debug_OpCode );
#define DO_ROUND \
@@ -3111,10 +3396,10 @@
#undef ARRAY_BOUND_ERROR
-#define ARRAY_BOUND_ERROR \
- { \
- CUR.error = TT_Err_Invalid_Reference; \
- return; \
+#define ARRAY_BOUND_ERROR \
+ { \
+ CUR.error = FT_THROW( Invalid_Reference ); \
+ return; \
}
@@ -4092,17 +4377,19 @@
if ( L <= 0 || L > CUR.args )
{
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Invalid_Reference );
}
+ else
+ {
+ K = CUR.stack[CUR.args - L];
- K = CUR.stack[CUR.args - L];
-
- FT_ARRAY_MOVE( &CUR.stack[CUR.args - L ],
- &CUR.stack[CUR.args - L + 1],
- ( L - 1 ) );
+ FT_ARRAY_MOVE( &CUR.stack[CUR.args - L ],
+ &CUR.stack[CUR.args - L + 1],
+ ( L - 1 ) );
- CUR.stack[CUR.args - 1] = K;
+ CUR.stack[CUR.args - 1] = K;
+ }
}
@@ -4151,7 +4438,7 @@
CUR.length = opcode_length[CUR.opcode];
if ( CUR.length < 0 )
{
- if ( CUR.IP + 1 > CUR.codeSize )
+ if ( CUR.IP + 1 >= CUR.codeSize )
goto Fail_Overflow;
CUR.length = 2 - CUR.length * CUR.code[CUR.IP + 1];
}
@@ -4161,7 +4448,7 @@
}
Fail_Overflow:
- CUR.error = TT_Err_Code_Overflow;
+ CUR.error = FT_THROW( Code_Overflow );
return FAILURE;
}
@@ -4266,6 +4553,106 @@
TT_DefRecord* rec;
TT_DefRecord* limit;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /* arguments to opcodes are skipped by `SKIP_Code' */
+ FT_Byte opcode_pattern[9][12] = {
+ /* #0 inline delta function 1 */
+ {
+ 0x4B, /* PPEM */
+ 0x53, /* GTEQ */
+ 0x23, /* SWAP */
+ 0x4B, /* PPEM */
+ 0x51, /* LTEQ */
+ 0x5A, /* AND */
+ 0x58, /* IF */
+ 0x38, /* SHPIX */
+ 0x1B, /* ELSE */
+ 0x21, /* POP */
+ 0x21, /* POP */
+ 0x59 /* EIF */
+ },
+ /* #1 inline delta function 2 */
+ {
+ 0x4B, /* PPEM */
+ 0x54, /* EQ */
+ 0x58, /* IF */
+ 0x38, /* SHPIX */
+ 0x1B, /* ELSE */
+ 0x21, /* POP */
+ 0x21, /* POP */
+ 0x59 /* EIF */
+ },
+ /* #2 diagonal stroke function */
+ {
+ 0x20, /* DUP */
+ 0x20, /* DUP */
+ 0xB0, /* PUSHB_1 */
+ /* 1 */
+ 0x60, /* ADD */
+ 0x46, /* GC_cur */
+ 0xB0, /* PUSHB_1 */
+ /* 64 */
+ 0x23, /* SWAP */
+ 0x42 /* WS */
+ },
+ /* #3 VacuFormRound function */
+ {
+ 0x45, /* RCVT */
+ 0x23, /* SWAP */
+ 0x46, /* GC_cur */
+ 0x60, /* ADD */
+ 0x20, /* DUP */
+ 0xB0 /* PUSHB_1 */
+ /* 38 */
+ },
+ /* #4 TTFautohint bytecode (old) */
+ {
+ 0x20, /* DUP */
+ 0x64, /* ABS */
+ 0xB0, /* PUSHB_1 */
+ /* 32 */
+ 0x60, /* ADD */
+ 0x66, /* FLOOR */
+ 0x23, /* SWAP */
+ 0xB0 /* PUSHB_1 */
+ },
+ /* #5 spacing function 1 */
+ {
+ 0x01, /* SVTCA_x */
+ 0xB0, /* PUSHB_1 */
+ /* 24 */
+ 0x43, /* RS */
+ 0x58 /* IF */
+ },
+ /* #6 spacing function 2 */
+ {
+ 0x01, /* SVTCA_x */
+ 0x18, /* RTG */
+ 0xB0, /* PUSHB_1 */
+ /* 24 */
+ 0x43, /* RS */
+ 0x58 /* IF */
+ },
+ /* #7 TypeMan Talk DiagEndCtrl function */
+ {
+ 0x01, /* SVTCA_x */
+ 0x20, /* DUP */
+ 0xB0, /* PUSHB_1 */
+ /* 3 */
+ 0x25, /* CINDEX */
+ },
+ /* #8 TypeMan Talk Align */
+ {
+ 0x06, /* SPVTL */
+ 0x7D, /* RDTG */
+ },
+ };
+ FT_UShort opcode_patterns = 9;
+ 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 */
+
/* some font programs are broken enough to redefine functions! */
/* We will then parse the current table. */
@@ -4285,7 +4672,7 @@
/* check that there is enough room for new functions */
if ( CUR.numFDefs >= CUR.maxFDefs )
{
- CUR.error = TT_Err_Too_Many_Function_Defs;
+ CUR.error = FT_THROW( Too_Many_Function_Defs );
return;
}
CUR.numFDefs++;
@@ -4295,31 +4682,153 @@
/* func # must be within unsigned 16-bit integer */
if ( n > 0xFFFFU )
{
- CUR.error = TT_Err_Too_Many_Function_Defs;
+ CUR.error = FT_THROW( Too_Many_Function_Defs );
return;
}
- rec->range = CUR.curRange;
- rec->opc = (FT_UInt16)n;
- rec->start = CUR.IP + 1;
- rec->active = TRUE;
+ rec->range = CUR.curRange;
+ rec->opc = (FT_UInt16)n;
+ rec->start = CUR.IP + 1;
+ rec->active = TRUE;
+ rec->inline_delta = FALSE;
+ rec->sph_fdef_flags = 0x0000;
if ( n > CUR.maxFunc )
CUR.maxFunc = (FT_UInt16)n;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /* 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 )
+ rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_STROKES;
+#endif
+
/* Now skip the whole function definition. */
/* We don't allow nested IDEFS & FDEFs. */
while ( SKIP_Code() == SUCCESS )
{
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ if ( SUBPIXEL_HINTING )
+ {
+ for ( i = 0; i < opcode_patterns; i++ )
+ {
+ if ( opcode_pointer[i] < opcode_size[i] &&
+ CUR.opcode == opcode_pattern[i][opcode_pointer[i]] )
+ {
+ opcode_pointer[i] += 1;
+
+ if ( opcode_pointer[i] == opcode_size[i] )
+ {
+ FT_TRACE7(( "sph: Function %d, opcode ptrn: %d, %s %s\n",
+ i, n,
+ CUR.face->root.family_name,
+ CUR.face->root.style_name ));
+
+ switch ( i )
+ {
+ case 0:
+ rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_1;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_1;
+ break;
+
+ case 1:
+ rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_2;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_2;
+ break;
+
+ case 2:
+ switch ( n )
+ {
+ /* needs to be implemented still */
+ case 58:
+ rec->sph_fdef_flags |= SPH_FDEF_DIAGONAL_STROKE;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_DIAGONAL_STROKE;
+ }
+ break;
+
+ case 3:
+ switch ( n )
+ {
+ case 0:
+ rec->sph_fdef_flags |= SPH_FDEF_VACUFORM_ROUND_1;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_VACUFORM_ROUND_1;
+ }
+ break;
+
+ case 4:
+ /* probably not necessary to detect anymore */
+ rec->sph_fdef_flags |= SPH_FDEF_TTFAUTOHINT_1;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_TTFAUTOHINT_1;
+ break;
+
+ case 5:
+ switch ( n )
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 4:
+ case 7:
+ case 8:
+ rec->sph_fdef_flags |= SPH_FDEF_SPACING_1;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_SPACING_1;
+ }
+ break;
+
+ case 6:
+ switch ( n )
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 4:
+ case 7:
+ case 8:
+ rec->sph_fdef_flags |= SPH_FDEF_SPACING_2;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_SPACING_2;
+ }
+ break;
+
+ case 7:
+ rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
+ break;
+
+ case 8:
+#if 0
+ rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
+ CUR.face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
+#endif
+ break;
+ }
+ opcode_pointer[i] = 0;
+ }
+ }
+
+ else
+ opcode_pointer[i] = 0;
+ }
+
+ /* Set sph_compatibility_mode only when deltas are detected */
+ CUR.face->sph_compatibility_mode =
+ ( ( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) |
+ ( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) );
+ }
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
switch ( CUR.opcode )
{
case 0x89: /* IDEF */
case 0x2C: /* FDEF */
- CUR.error = TT_Err_Nested_DEFS;
+ CUR.error = FT_THROW( Nested_DEFS );
return;
case 0x2D: /* ENDF */
+ rec->end = CUR.IP;
return;
}
}
@@ -4340,9 +4849,13 @@
FT_UNUSED_ARG;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ CUR.sph_in_func_flags = 0x0000;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
if ( CUR.callTop <= 0 ) /* We encountered an ENDF without a call */
{
- CUR.error = TT_Err_ENDF_In_Exec_Stream;
+ CUR.error = FT_THROW( ENDF_In_Exec_Stream );
return;
}
@@ -4357,7 +4870,7 @@
if ( pRec->Cur_Count > 0 )
{
CUR.callTop++;
- CUR.IP = pRec->Cur_Restart;
+ CUR.IP = pRec->Def->start;
}
else
/* Loop through the current function */
@@ -4391,7 +4904,7 @@
/* first of all, check the index */
F = args[0];
- if ( BOUNDS( F, CUR.maxFunc + 1 ) )
+ if ( BOUNDSL( F, CUR.maxFunc + 1 ) )
goto Fail;
/* Except for some old Apple fonts, all functions in a TrueType */
@@ -4424,10 +4937,21 @@
if ( !def->active )
goto Fail;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ ( ( CUR.iup_called &&
+ ( CUR.sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) ) ||
+ ( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) ) )
+ goto Fail;
+ else
+ CUR.sph_in_func_flags = def->sph_fdef_flags;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
/* check the call stack */
if ( CUR.callTop >= CUR.callSize )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
return;
}
@@ -4436,7 +4960,7 @@
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = 1;
- pCrec->Cur_Restart = def->start;
+ pCrec->Def = def;
CUR.callTop++;
@@ -4444,10 +4968,11 @@
def->start );
CUR.step_ins = FALSE;
+
return;
Fail:
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
}
@@ -4467,7 +4992,7 @@
/* first of all, check the index */
F = args[1];
- if ( BOUNDS( F, CUR.maxFunc + 1 ) )
+ if ( BOUNDSL( F, CUR.maxFunc + 1 ) )
goto Fail;
/* Except for some old Apple fonts, all functions in a TrueType */
@@ -4500,10 +5025,19 @@
if ( !def->active )
goto Fail;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ ( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) )
+ goto Fail;
+ else
+ CUR.sph_in_func_flags = def->sph_fdef_flags;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
/* check stack */
if ( CUR.callTop >= CUR.callSize )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
return;
}
@@ -4514,7 +5048,7 @@
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = (FT_Int)args[0];
- pCrec->Cur_Restart = def->start;
+ pCrec->Def = def;
CUR.callTop++;
@@ -4522,10 +5056,11 @@
CUR.step_ins = FALSE;
}
+
return;
Fail:
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
}
@@ -4556,7 +5091,7 @@
/* check that there is enough room for a new instruction */
if ( CUR.numIDefs >= CUR.maxIDefs )
{
- CUR.error = TT_Err_Too_Many_Instruction_Defs;
+ CUR.error = FT_THROW( Too_Many_Instruction_Defs );
return;
}
CUR.numIDefs++;
@@ -4565,12 +5100,12 @@
/* opcode must be unsigned 8-bit integer */
if ( 0 > args[0] || args[0] > 0x00FF )
{
- CUR.error = TT_Err_Too_Many_Instruction_Defs;
+ CUR.error = FT_THROW( Too_Many_Instruction_Defs );
return;
}
def->opc = (FT_Byte)args[0];
- def->start = CUR.IP+1;
+ def->start = CUR.IP + 1;
def->range = CUR.curRange;
def->active = TRUE;
@@ -4586,7 +5121,7 @@
{
case 0x89: /* IDEF */
case 0x2C: /* FDEF */
- CUR.error = TT_Err_Nested_DEFS;
+ CUR.error = FT_THROW( Nested_DEFS );
return;
case 0x2D: /* ENDF */
return;
@@ -4620,7 +5155,7 @@
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
return;
}
@@ -4647,7 +5182,7 @@
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
return;
}
@@ -4677,7 +5212,7 @@
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
return;
}
@@ -4702,7 +5237,7 @@
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
return;
}
@@ -4730,8 +5265,8 @@
/* Opcode range: 0x46-0x47 */
/* Stack: uint32 --> f26.6 */
/* */
- /* BULLSHIT: Measures from the original glyph must be taken along the */
- /* dual projection vector! */
+ /* XXX: UNDOCUMENTED: Measures from the original glyph must be taken */
+ /* along the dual projection vector! */
/* */
static void
Ins_GC( INS_ARG )
@@ -4742,15 +5277,11 @@
L = (FT_ULong)args[0];
- if ( BOUNDS( L, CUR.zp2.n_points ) )
+ if ( BOUNDSL( L, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
- {
- CUR.error = TT_Err_Invalid_Reference;
- return;
- }
- else
- R = 0;
+ CUR.error = FT_THROW( Invalid_Reference );
+ R = 0;
}
else
{
@@ -4786,7 +5317,7 @@
if ( BOUNDS( L, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -4794,8 +5325,8 @@
CUR_Func_move( &CUR.zp2, L, args[1] - K );
- /* not part of the specs, but here for safety */
-
+ /* UNDOCUMENTED! The MS rasterizer does that with */
+ /* twilight points (confirmed by Greg Hitchcock) */
if ( CUR.GS.gep2 == 0 )
CUR.zp2.org[L] = CUR.zp2.cur[L];
}
@@ -4807,14 +5338,14 @@
/* Opcode range: 0x49-0x4A */
/* Stack: uint32 uint32 --> f26.6 */
/* */
- /* BULLSHIT: Measure taken in the original glyph must be along the dual */
- /* projection vector. */
+ /* XXX: UNDOCUMENTED: Measure taken in the original glyph must be along */
+ /* the dual projection vector. */
/* */
- /* Second BULLSHIT: Flag attributes are inverted! */
- /* 0 => measure distance in original outline */
- /* 1 => measure distance in grid-fitted outline */
+ /* XXX: UNDOCUMENTED: Flag attributes are inverted! */
+ /* 0 => measure distance in original outline */
+ /* 1 => measure distance in grid-fitted outline */
/* */
- /* Third one: `zp0 - zp1', and not `zp2 - zp1! */
+ /* XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! */
/* */
static void
Ins_MD( INS_ARG )
@@ -4826,14 +5357,11 @@
K = (FT_UShort)args[1];
L = (FT_UShort)args[0];
- if( BOUNDS( L, CUR.zp0.n_points ) ||
- BOUNDS( K, CUR.zp1.n_points ) )
+ if ( BOUNDS( L, CUR.zp0.n_points ) ||
+ BOUNDS( K, CUR.zp1.n_points ) )
{
if ( CUR.pedantic_hinting )
- {
- CUR.error = TT_Err_Invalid_Reference;
- return;
- }
+ CUR.error = FT_THROW( Invalid_Reference );
D = 0;
}
else
@@ -4842,29 +5370,49 @@
D = CUR_Func_project( CUR.zp0.cur + L, CUR.zp1.cur + K );
else
{
- FT_Vector* vec1 = CUR.zp0.orus + L;
- FT_Vector* vec2 = CUR.zp1.orus + K;
-
+ /* XXX: UNDOCUMENTED: twilight zone special case */
- if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
+ if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 )
{
- /* this should be faster */
+ FT_Vector* vec1 = CUR.zp0.org + L;
+ FT_Vector* vec2 = CUR.zp1.org + K;
+
+
D = CUR_Func_dualproj( vec1, vec2 );
- D = TT_MULFIX( D, CUR.metrics.x_scale );
}
else
{
- FT_Vector vec;
+ FT_Vector* vec1 = CUR.zp0.orus + L;
+ FT_Vector* vec2 = CUR.zp1.orus + K;
+
+
+ if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
+ {
+ /* this should be faster */
+ D = CUR_Func_dualproj( vec1, vec2 );
+ D = FT_MulFix( D, CUR.metrics.x_scale );
+ }
+ else
+ {
+ FT_Vector vec;
- vec.x = TT_MULFIX( vec1->x - vec2->x, CUR.metrics.x_scale );
- vec.y = TT_MULFIX( vec1->y - vec2->y, CUR.metrics.y_scale );
+ vec.x = FT_MulFix( vec1->x - vec2->x, CUR.metrics.x_scale );
+ vec.y = FT_MulFix( vec1->y - vec2->y, CUR.metrics.y_scale );
- D = CUR_fast_dualproj( &vec );
+ D = CUR_fast_dualproj( &vec );
+ }
}
}
}
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode && FT_ABS( D ) == 64 )
+ D += 1;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
args[0] = D;
}
@@ -4879,7 +5427,8 @@
Ins_SDPVTL( INS_ARG )
{
FT_Long A, B, C;
- FT_UShort p1, p2; /* was FT_Int in pas type ERROR */
+ FT_UShort p1, p2; /* was FT_Int in pas type ERROR */
+ FT_Int aOpc = CUR.opcode;
p1 = (FT_UShort)args[1];
@@ -4889,7 +5438,7 @@
BOUNDS( p1, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -4900,9 +5449,20 @@
A = v1->x - v2->x;
B = v1->y - v2->y;
+
+ /* If v1 == v2, SDPVTL behaves the same as */
+ /* SVTCA[X], respectively. */
+ /* */
+ /* Confirmed by Greg Hitchcock. */
+
+ if ( A == 0 && B == 0 )
+ {
+ A = 0x4000;
+ aOpc = 0;
+ }
}
- if ( ( CUR.opcode & 1 ) != 0 )
+ if ( ( aOpc & 1 ) != 0 )
{
C = B; /* counter clockwise rotation */
B = A;
@@ -4918,9 +5478,15 @@
A = v1->x - v2->x;
B = v1->y - v2->y;
+
+ if ( A == 0 && B == 0 )
+ {
+ A = 0x4000;
+ aOpc = 0;
+ }
}
- if ( ( CUR.opcode & 1 ) != 0 )
+ if ( ( aOpc & 1 ) != 0 )
{
C = B; /* counter clockwise rotation */
B = A;
@@ -4956,7 +5522,7 @@
default:
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -4985,7 +5551,7 @@
default:
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -5014,7 +5580,7 @@
default:
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -5043,7 +5609,7 @@
default:
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -5059,7 +5625,7 @@
/*************************************************************************/
/* */
/* INSTCTRL[]: INSTruction ConTRoL */
- /* Opcode range: 0x8e */
+ /* Opcode range: 0x8E */
/* Stack: int32 int32 --> */
/* */
static void
@@ -5074,7 +5640,7 @@
if ( K < 1 || K > 2 )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -5171,8 +5737,9 @@
if ( CUR.top < CUR.GS.loop )
{
- CUR.error = TT_Err_Too_Few_Arguments;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Too_Few_Arguments );
+ goto Fail;
}
while ( CUR.GS.loop > 0 )
@@ -5185,7 +5752,7 @@
{
if ( CUR.pedantic_hinting )
{
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
@@ -5195,6 +5762,7 @@
CUR.GS.loop--;
}
+ Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
@@ -5219,7 +5787,7 @@
BOUNDS( L, CUR.pts.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -5247,7 +5815,7 @@
BOUNDS( L, CUR.pts.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -5281,7 +5849,7 @@
if ( BOUNDS( p, zp.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
*refp = 0;
return FAILURE;
}
@@ -5308,12 +5876,8 @@
else
#endif
{
- *x = TT_MULDIV( d,
- (FT_Long)CUR.GS.freeVector.x * 0x10000L,
- CUR.F_dot_P );
- *y = TT_MULDIV( d,
- (FT_Long)CUR.GS.freeVector.y * 0x10000L,
- CUR.F_dot_P );
+ *x = FT_MulDiv( d, (FT_Long)CUR.GS.freeVector.x, CUR.F_dot_P );
+ *y = FT_MulDiv( d, (FT_Long)CUR.GS.freeVector.y, CUR.F_dot_P );
}
return SUCCESS;
@@ -5382,8 +5946,9 @@
if ( CUR.top < CUR.GS.loop )
{
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) )
@@ -5398,17 +5963,24 @@
{
if ( CUR.pedantic_hinting )
{
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
else
- /* XXX: UNDOCUMENTED! SHP touches the points */
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /* doesn't follow Cleartype spec but produces better result */
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode )
+ MOVE_Zp2_Point( point, 0, dy, TRUE );
+ else
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
MOVE_Zp2_Point( point, dx, dy, TRUE );
CUR.GS.loop--;
}
+ Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
@@ -5420,24 +5992,28 @@
/* Opcode range: 0x34-35 */
/* Stack: uint32 --> */
/* */
+ /* UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) */
+ /* contour in the twilight zone, namely contour number */
+ /* zero which includes all points of it. */
+ /* */
static void
Ins_SHC( INS_ARG )
{
- TT_GlyphZoneRec zp;
- FT_UShort refp;
- FT_F26Dot6 dx,
- dy;
+ TT_GlyphZoneRec zp;
+ FT_UShort refp;
+ FT_F26Dot6 dx, dy;
- FT_Short contour;
- FT_UShort first_point, last_point, i;
+ FT_Short contour, bounds;
+ FT_UShort start, limit, i;
contour = (FT_UShort)args[0];
+ bounds = ( CUR.GS.gep2 == 0 ) ? 1 : CUR.zp2.n_contours;
- if ( BOUNDS( contour, CUR.pts.n_contours ) )
+ if ( BOUNDS( contour, bounds ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -5445,26 +6021,19 @@
return;
if ( contour == 0 )
- first_point = 0;
+ start = 0;
else
- first_point = (FT_UShort)( CUR.pts.contours[contour - 1] + 1 -
- CUR.pts.first_point );
+ start = (FT_UShort)( CUR.zp2.contours[contour - 1] + 1 -
+ CUR.zp2.first_point );
- last_point = (FT_UShort)( CUR.pts.contours[contour] -
- CUR.pts.first_point );
-
- /* XXX: this is probably wrong... at least it prevents memory */
- /* corruption when zp2 is the twilight zone */
- if ( BOUNDS( last_point, CUR.zp2.n_points ) )
- {
- if ( CUR.zp2.n_points > 0 )
- last_point = (FT_UShort)(CUR.zp2.n_points - 1);
- else
- last_point = 0;
- }
+ /* we use the number of points if in the twilight zone */
+ if ( CUR.GS.gep2 == 0 )
+ limit = CUR.zp2.n_points;
+ else
+ limit = (FT_UShort)( CUR.zp2.contours[contour] -
+ CUR.zp2.first_point + 1 );
- /* XXX: UNDOCUMENTED! SHC touches the points */
- for ( i = first_point; i <= last_point; i++ )
+ for ( i = start; i < limit; i++ )
{
if ( zp.cur != CUR.zp2.cur || refp != i )
MOVE_Zp2_Point( i, dx, dy, TRUE );
@@ -5481,37 +6050,37 @@
static void
Ins_SHZ( INS_ARG )
{
- TT_GlyphZoneRec zp;
- FT_UShort refp;
- FT_F26Dot6 dx,
- dy;
+ TT_GlyphZoneRec zp;
+ FT_UShort refp;
+ FT_F26Dot6 dx,
+ dy;
- FT_UShort last_point, i;
+ FT_UShort limit, i;
if ( BOUNDS( args[0], 2 ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) )
return;
- /* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */
- /* Twilight zone has no contours, so use `n_points'. */
- /* Normal zone's `n_points' includes phantoms, so must */
- /* use end of last contour. */
- if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
- last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
+ /* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */
+ /* Twilight zone has no real contours, so use `n_points'. */
+ /* Normal zone's `n_points' includes phantoms, so must */
+ /* use end of last contour. */
+ if ( CUR.GS.gep2 == 0 )
+ limit = (FT_UShort)CUR.zp2.n_points;
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
- last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+ limit = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] + 1 );
else
- last_point = 0;
+ limit = 0;
/* XXX: UNDOCUMENTED! SHZ doesn't touch the points */
- for ( i = 0; i <= last_point; i++ )
+ for ( i = 0; i < limit; i++ )
{
if ( zp.cur != CUR.zp2.cur || refp != i )
MOVE_Zp2_Point( i, dx, dy, FALSE );
@@ -5530,12 +6099,16 @@
{
FT_F26Dot6 dx, dy;
FT_UShort point;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_Int B1, B2;
+#endif
if ( CUR.top < CUR.GS.loop + 1 )
{
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
@@ -5543,13 +6116,13 @@
{
if ( CUR.GS.both_x_axis )
{
- dx = TT_MulFix14( (FT_UInt32)args[0], 0x4000 );
+ dx = (FT_UInt32)args[0];
dy = 0;
}
else
{
dx = 0;
- dy = TT_MulFix14( (FT_UInt32)args[0], 0x4000 );
+ dy = (FT_UInt32)args[0];
}
}
else
@@ -5569,16 +6142,99 @@
{
if ( CUR.pedantic_hinting )
{
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
else
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ {
+ /* If not using ignore_x_mode rendering, allow ZP2 move. */
+ /* If inline deltas aren't allowed, skip ZP2 move. */
+ /* If using ignore_x_mode rendering, allow ZP2 point move if: */
+ /* - freedom vector is y and sph_compatibility_mode is off */
+ /* - the glyph is composite and the move is in the Y direction */
+ /* - the glyph is specifically set to allow SHPIX moves */
+ /* - the move is on a previously Y-touched point */
+
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode )
+ {
+ /* save point for later comparison */
+ if ( CUR.GS.freeVector.y != 0 )
+ B1 = CUR.zp2.cur[point].y;
+ else
+ B1 = CUR.zp2.cur[point].x;
+
+ if ( !CUR.face->sph_compatibility_mode &&
+ CUR.GS.freeVector.y != 0 )
+ {
+ MOVE_Zp2_Point( point, dx, dy, TRUE );
+
+ /* save new point */
+ if ( CUR.GS.freeVector.y != 0 )
+ {
+ B2 = CUR.zp2.cur[point].y;
+
+ /* reverse any disallowed moves */
+ if ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
+ ( B1 & 63 ) != 0 &&
+ ( B2 & 63 ) != 0 &&
+ B1 != B2 )
+ MOVE_Zp2_Point( point, -dx, -dy, TRUE );
+ }
+ }
+ else if ( CUR.face->sph_compatibility_mode )
+ {
+ if ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
+ {
+ dx = FT_PIX_ROUND( B1 + dx ) - B1;
+ dy = FT_PIX_ROUND( B1 + dy ) - B1;
+ }
+
+ /* skip post-iup deltas */
+ if ( CUR.iup_called &&
+ ( ( CUR.sph_in_func_flags & SPH_FDEF_INLINE_DELTA_1 ) ||
+ ( CUR.sph_in_func_flags & SPH_FDEF_INLINE_DELTA_2 ) ) )
+ goto Skip;
+
+ if ( !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) &&
+ ( ( CUR.is_composite && CUR.GS.freeVector.y != 0 ) ||
+ ( CUR.zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y ) ||
+ ( CUR.sph_tweak_flags & SPH_TWEAK_DO_SHPIX ) ) )
+ MOVE_Zp2_Point( point, 0, dy, TRUE );
+
+ /* save new point */
+ if ( CUR.GS.freeVector.y != 0 )
+ {
+ B2 = CUR.zp2.cur[point].y;
+
+ /* reverse any disallowed moves */
+ if ( ( B1 & 63 ) == 0 &&
+ ( B2 & 63 ) != 0 &&
+ B1 != B2 )
+ MOVE_Zp2_Point( point, 0, -dy, TRUE );
+ }
+ }
+ else if ( CUR.sph_in_func_flags & SPH_FDEF_TYPEMAN_DIAGENDCTRL )
+ MOVE_Zp2_Point( point, dx, dy, TRUE );
+ }
+ else
+ MOVE_Zp2_Point( point, dx, dy, TRUE );
+ }
+
+ Skip:
+
+#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
MOVE_Zp2_Point( point, dx, dy, TRUE );
+#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
CUR.GS.loop--;
}
+ Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
@@ -5596,6 +6252,21 @@
FT_UShort point;
FT_F26Dot6 distance;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_F26Dot6 control_value_cutin = 0; /* pacify compiler */
+
+
+ if ( SUBPIXEL_HINTING )
+ {
+ control_value_cutin = CUR.GS.control_value_cutin;
+
+ if ( CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 &&
+ !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+ control_value_cutin = 0;
+ }
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
point = (FT_UShort)args[0];
@@ -5603,13 +6274,13 @@
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
- /* XXX: UNDOCUMENTED! behaviour */
- if ( CUR.GS.gep1 == 0 ) /* if the point that is to be moved */
- /* is in twilight zone */
+ /* UNDOCUMENTED! The MS rasterizer does that with */
+ /* twilight points (confirmed by Greg Hitchcock) */
+ if ( CUR.GS.gep1 == 0 )
{
CUR.zp1.org[point] = CUR.zp0.org[CUR.GS.rp0];
CUR_Func_move_orig( &CUR.zp1, point, args[1] );
@@ -5619,6 +6290,15 @@
distance = CUR_Func_project( CUR.zp1.cur + point,
CUR.zp0.cur + CUR.GS.rp0 );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /* subpixel hinting - make MSIRP respect CVT cut-in; */
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 &&
+ FT_ABS( distance - args[1] ) >= control_value_cutin )
+ distance = args[1];
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
CUR_Func_move( &CUR.zp1, point, args[1] - distance );
CUR.GS.rp1 = CUR.GS.rp0;
@@ -5639,8 +6319,8 @@
Ins_MDAP( INS_ARG )
{
FT_UShort point;
- FT_F26Dot6 cur_dist,
- distance;
+ FT_F26Dot6 cur_dist;
+ FT_F26Dot6 distance;
point = (FT_UShort)args[0];
@@ -5648,17 +6328,25 @@
if ( BOUNDS( point, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
- /* XXX: Is there some undocumented feature while in the */
- /* twilight zone? ? */
if ( ( CUR.opcode & 1 ) != 0 )
{
cur_dist = CUR_fast_project( &CUR.zp0.cur[point] );
- distance = CUR_Func_round( cur_dist,
- CUR.tt_metrics.compensations[0] ) - cur_dist;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 )
+ distance = ROUND_None(
+ cur_dist,
+ CUR.tt_metrics.compensations[0] ) - cur_dist;
+ else
+#endif
+ distance = CUR_Func_round(
+ cur_dist,
+ CUR.tt_metrics.compensations[0] ) - cur_dist;
}
else
distance = 0;
@@ -5681,64 +6369,100 @@
{
FT_ULong cvtEntry;
FT_UShort point;
- FT_F26Dot6 distance,
- org_dist;
+ FT_F26Dot6 distance;
+ FT_F26Dot6 org_dist;
+ FT_F26Dot6 control_value_cutin;
- cvtEntry = (FT_ULong)args[1];
- point = (FT_UShort)args[0];
+ control_value_cutin = CUR.GS.control_value_cutin;
+ cvtEntry = (FT_ULong)args[1];
+ point = (FT_UShort)args[0];
- if ( BOUNDS( point, CUR.zp0.n_points ) ||
- BOUNDS( cvtEntry, CUR.cvtSize ) )
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 &&
+ CUR.GS.freeVector.y == 0 &&
+ !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+ control_value_cutin = 0;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ if ( BOUNDS( point, CUR.zp0.n_points ) ||
+ BOUNDSL( cvtEntry, CUR.cvtSize ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
- /* XXX: UNDOCUMENTED! */
- /* */
- /* The behaviour of an MIAP instruction is quite */
- /* different when used in the twilight zone. */
- /* */
- /* First, no control value cut-in test is performed */
- /* as it would fail anyway. Second, the original */
- /* point, i.e. (org_x,org_y) of zp0.point, is set */
- /* to the absolute, unrounded distance found in */
- /* the CVT. */
- /* */
- /* This is used in the CVT programs of the Microsoft */
- /* fonts Arial, Times, etc., in order to re-adjust */
- /* some key font heights. It allows the use of the */
- /* IP instruction in the twilight zone, which */
- /* otherwise would be `illegal' according to the */
- /* specification. */
- /* */
- /* We implement it with a special sequence for the */
- /* twilight zone. This is a bad hack, but it seems */
- /* to work. */
+ /* UNDOCUMENTED! */
+ /* */
+ /* The behaviour of an MIAP instruction is quite different when used */
+ /* in the twilight zone. */
+ /* */
+ /* First, no control value cut-in test is performed as it would fail */
+ /* anyway. Second, the original point, i.e. (org_x,org_y) of */
+ /* zp0.point, is set to the absolute, unrounded distance found in the */
+ /* CVT. */
+ /* */
+ /* This is used in the CVT programs of the Microsoft fonts Arial, */
+ /* Times, etc., in order to re-adjust some key font heights. It */
+ /* allows the use of the IP instruction in the twilight zone, which */
+ /* otherwise would be invalid according to the specification. */
+ /* */
+ /* We implement it with a special sequence for the twilight zone. */
+ /* This is a bad hack, but it seems to work. */
+ /* */
+ /* Confirmed by Greg Hitchcock. */
distance = CUR_Func_read_cvt( cvtEntry );
if ( CUR.GS.gep0 == 0 ) /* If in twilight zone */
{
- CUR.zp0.org[point].x = TT_MulFix14( (FT_UInt32)distance, CUR.GS.freeVector.x );
- CUR.zp0.org[point].y = TT_MulFix14( (FT_UInt32)distance, CUR.GS.freeVector.y ),
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */
+ /* Determined via experimentation and may be incorrect... */
+ if ( !SUBPIXEL_HINTING ||
+ ( !CUR.ignore_x_mode ||
+ !CUR.face->sph_compatibility_mode ) )
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+ CUR.zp0.org[point].x = TT_MulFix14( (FT_UInt32)distance,
+ CUR.GS.freeVector.x );
+ CUR.zp0.org[point].y = TT_MulFix14( (FT_UInt32)distance,
+ CUR.GS.freeVector.y ),
CUR.zp0.cur[point] = CUR.zp0.org[point];
}
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ ( CUR.sph_tweak_flags & SPH_TWEAK_MIAP_HACK ) &&
+ distance > 0 &&
+ CUR.GS.freeVector.y != 0 )
+ distance = 0;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
org_dist = CUR_fast_project( &CUR.zp0.cur[point] );
- if ( ( CUR.opcode & 1 ) != 0 ) /* rounding and control cutin flag */
+ if ( ( CUR.opcode & 1 ) != 0 ) /* rounding and control cut-in flag */
{
- if ( FT_ABS( distance - org_dist ) > CUR.GS.control_value_cutin )
+ if ( FT_ABS( distance - org_dist ) > control_value_cutin )
distance = org_dist;
- distance = CUR_Func_round( distance, CUR.tt_metrics.compensations[0] );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 )
+ distance = ROUND_None( distance,
+ CUR.tt_metrics.compensations[0] );
+ else
+#endif
+ distance = CUR_Func_round( distance,
+ CUR.tt_metrics.compensations[0] );
}
CUR_Func_move( &CUR.zp0, point, distance - org_dist );
+ Fail:
CUR.GS.rp0 = point;
CUR.GS.rp1 = point;
}
@@ -5754,8 +6478,18 @@
Ins_MDRP( INS_ARG )
{
FT_UShort point;
- FT_F26Dot6 org_dist, distance;
+ FT_F26Dot6 org_dist, distance, minimum_distance;
+
+
+ minimum_distance = CUR.GS.minimum_distance;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 &&
+ !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+ minimum_distance = 0;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
point = (FT_UShort)args[0];
@@ -5763,8 +6497,8 @@
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
/* XXX: Is there some undocumented feature while in the */
@@ -5790,15 +6524,15 @@
{
/* this should be faster */
org_dist = CUR_Func_dualproj( vec1, vec2 );
- org_dist = TT_MULFIX( org_dist, CUR.metrics.x_scale );
+ org_dist = FT_MulFix( org_dist, CUR.metrics.x_scale );
}
else
{
FT_Vector vec;
- vec.x = TT_MULFIX( vec1->x - vec2->x, CUR.metrics.x_scale );
- vec.y = TT_MULFIX( vec1->y - vec2->y, CUR.metrics.y_scale );
+ vec.x = FT_MulFix( vec1->x - vec2->x, CUR.metrics.x_scale );
+ vec.y = FT_MulFix( vec1->y - vec2->y, CUR.metrics.y_scale );
org_dist = CUR_fast_dualproj( &vec );
}
@@ -5818,9 +6552,20 @@
/* round flag */
if ( ( CUR.opcode & 4 ) != 0 )
+ {
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 )
+ distance = ROUND_None(
+ org_dist,
+ CUR.tt_metrics.compensations[CUR.opcode & 3] );
+ else
+#endif
distance = CUR_Func_round(
org_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
+ }
else
distance = ROUND_None(
org_dist,
@@ -5832,13 +6577,13 @@
{
if ( org_dist >= 0 )
{
- if ( distance < CUR.GS.minimum_distance )
- distance = CUR.GS.minimum_distance;
+ if ( distance < minimum_distance )
+ distance = minimum_distance;
}
else
{
- if ( distance > -CUR.GS.minimum_distance )
- distance = -CUR.GS.minimum_distance;
+ if ( distance > -minimum_distance )
+ distance = -minimum_distance;
}
}
@@ -5849,6 +6594,7 @@
CUR_Func_move( &CUR.zp1, point, distance - org_dist );
+ Fail:
CUR.GS.rp1 = CUR.GS.rp0;
CUR.GS.rp2 = point;
@@ -5872,21 +6618,38 @@
FT_F26Dot6 cvt_dist,
distance,
cur_dist,
- org_dist;
-
-
- point = (FT_UShort)args[0];
- cvtEntry = (FT_ULong)( args[1] + 1 );
+ org_dist,
+ control_value_cutin,
+ minimum_distance;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_Int B1 = 0; /* pacify compiler */
+ FT_Int B2 = 0;
+ FT_Bool reverse_move = FALSE;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+
+ minimum_distance = CUR.GS.minimum_distance;
+ control_value_cutin = CUR.GS.control_value_cutin;
+ point = (FT_UShort)args[0];
+ cvtEntry = (FT_ULong)( args[1] + 1 );
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.x != 0 &&
+ !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+ control_value_cutin = minimum_distance = 0;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
if ( BOUNDS( point, CUR.zp1.n_points ) ||
- BOUNDS( cvtEntry, CUR.cvtSize + 1 ) ||
+ BOUNDSL( cvtEntry, CUR.cvtSize + 1 ) ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
if ( !cvtEntry )
@@ -5905,19 +6668,17 @@
cvt_dist = -CUR.GS.single_width_value;
}
- /* XXX: UNDOCUMENTED! -- twilight zone */
-
+ /* UNDOCUMENTED! The MS rasterizer does that with */
+ /* twilight points (confirmed by Greg Hitchcock) */
if ( CUR.GS.gep1 == 0 )
{
CUR.zp1.org[point].x = CUR.zp0.org[CUR.GS.rp0].x +
TT_MulFix14( (FT_UInt32)cvt_dist,
CUR.GS.freeVector.x );
-
CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y +
TT_MulFix14( (FT_UInt32)cvt_dist,
CUR.GS.freeVector.y );
-
- CUR.zp1.cur[point] = CUR.zp0.cur[point];
+ CUR.zp1.cur[point] = CUR.zp1.org[point];
}
org_dist = CUR_Func_dualproj( &CUR.zp1.org[point],
@@ -5933,7 +6694,20 @@
cvt_dist = -cvt_dist;
}
- /* control value cutin and round */
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.freeVector.y != 0 &&
+ ( CUR.sph_tweak_flags & SPH_TWEAK_TIMES_NEW_ROMAN_HACK ) )
+ {
+ if ( cur_dist < -64 )
+ cvt_dist -= 16;
+ else if ( cur_dist > 64 && cur_dist < 84 )
+ cvt_dist += 32;
+ }
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ /* control value cut-in and round */
if ( ( CUR.opcode & 4 ) != 0 )
{
@@ -5941,17 +6715,45 @@
/* refer to the same zone. */
if ( CUR.GS.gep0 == CUR.GS.gep1 )
- if ( FT_ABS( cvt_dist - org_dist ) >= CUR.GS.control_value_cutin )
+ {
+ /* XXX: According to Greg Hitchcock, the following wording is */
+ /* the right one: */
+ /* */
+ /* When the absolute difference between the value in */
+ /* the table [CVT] and the measurement directly from */
+ /* the outline is _greater_ than the cut_in value, the */
+ /* outline measurement is used. */
+ /* */
+ /* This is from `instgly.doc'. The description in */
+ /* `ttinst2.doc', version 1.66, is thus incorrect since */
+ /* it implies `>=' instead of `>'. */
+
+ if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin )
cvt_dist = org_dist;
+ }
distance = CUR_Func_round(
cvt_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
}
else
+ {
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /* do cvt cut-in always in MIRP for sph */
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.GS.gep0 == CUR.GS.gep1 )
+ {
+ if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin )
+ cvt_dist = org_dist;
+ }
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
distance = ROUND_None(
cvt_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
+ }
/* minimum distance test */
@@ -5959,24 +6761,71 @@
{
if ( org_dist >= 0 )
{
- if ( distance < CUR.GS.minimum_distance )
- distance = CUR.GS.minimum_distance;
+ if ( distance < minimum_distance )
+ distance = minimum_distance;
}
else
{
- if ( distance > -CUR.GS.minimum_distance )
- distance = -CUR.GS.minimum_distance;
+ if ( distance > -minimum_distance )
+ distance = -minimum_distance;
}
}
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING )
+ {
+ B1 = CUR.zp1.cur[point].y;
+
+ /* Round moves if necessary */
+ if ( CUR.ignore_x_mode &&
+ CUR.GS.freeVector.y != 0 &&
+ ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) )
+ distance = FT_PIX_ROUND( B1 + distance - cur_dist ) - B1 + cur_dist;
+
+ if ( CUR.ignore_x_mode &&
+ CUR.GS.freeVector.y != 0 &&
+ ( CUR.opcode & 16 ) == 0 &&
+ ( CUR.opcode & 8 ) == 0 &&
+ ( CUR.sph_tweak_flags & SPH_TWEAK_COURIER_NEW_2_HACK ) )
+ distance += 64;
+ }
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
CUR_Func_move( &CUR.zp1, point, distance - cur_dist );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING )
+ {
+ B2 = CUR.zp1.cur[point].y;
+
+ /* Reverse move if necessary */
+ if ( CUR.ignore_x_mode )
+ {
+ if ( CUR.face->sph_compatibility_mode &&
+ CUR.GS.freeVector.y != 0 &&
+ ( B1 & 63 ) == 0 &&
+ ( B2 & 63 ) != 0 )
+ reverse_move = TRUE;
+
+ if ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
+ CUR.GS.freeVector.y != 0 &&
+ ( B2 & 63 ) != 0 &&
+ ( B1 & 63 ) != 0 )
+ reverse_move = TRUE;
+ }
+
+ if ( reverse_move )
+ CUR_Func_move( &CUR.zp1, point, -( distance - cur_dist ) );
+ }
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ Fail:
CUR.GS.rp1 = CUR.GS.rp0;
if ( ( CUR.opcode & 16 ) != 0 )
CUR.GS.rp0 = point;
- /* XXX: UNDOCUMENTED! */
CUR.GS.rp2 = point;
}
@@ -5996,12 +6845,23 @@
FT_UNUSED_ARG;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.iup_called &&
+ ( CUR.sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) )
+ {
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
+ }
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
if ( CUR.top < CUR.GS.loop ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
while ( CUR.GS.loop > 0 )
@@ -6014,7 +6874,7 @@
{
if ( CUR.pedantic_hinting )
{
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
@@ -6029,6 +6889,7 @@
CUR.GS.loop--;
}
+ Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
@@ -6047,7 +6908,7 @@
a0, a1,
b0, b1;
- FT_F26Dot6 discriminant;
+ FT_F26Dot6 discriminant, dotproduct;
FT_F26Dot6 dx, dy,
dax, day,
@@ -6072,10 +6933,12 @@
BOUNDS( point, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
+ /* Cramer's rule */
+
dbx = CUR.zp0.cur[b1].x - CUR.zp0.cur[b0].x;
dby = CUR.zp0.cur[b1].y - CUR.zp0.cur[b0].y;
@@ -6087,15 +6950,25 @@
CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH;
- discriminant = TT_MULDIV( dax, -dby, 0x40 ) +
- TT_MULDIV( day, dbx, 0x40 );
+ discriminant = FT_MulDiv( dax, -dby, 0x40 ) +
+ FT_MulDiv( day, dbx, 0x40 );
+ dotproduct = FT_MulDiv( dax, dbx, 0x40 ) +
+ FT_MulDiv( day, dby, 0x40 );
- if ( FT_ABS( discriminant ) >= 0x40 )
+ /* The discriminant above is actually a cross product of vectors */
+ /* da and db. Together with the dot product, they can be used as */
+ /* surrogates for sine and cosine of the angle between the vectors. */
+ /* Indeed, */
+ /* dotproduct = |da||db|cos(angle) */
+ /* 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 ) )
{
- val = TT_MULDIV( dx, -dby, 0x40 ) + TT_MULDIV( dy, dbx, 0x40 );
+ val = FT_MulDiv( dx, -dby, 0x40 ) + FT_MulDiv( dy, dbx, 0x40 );
- R.x = TT_MULDIV( val, dax, discriminant );
- R.y = TT_MULDIV( val, day, discriminant );
+ R.x = FT_MulDiv( val, dax, discriminant );
+ R.y = FT_MulDiv( val, day, discriminant );
CUR.zp2.cur[point].x = CUR.zp1.cur[a0].x + R.x;
CUR.zp2.cur[point].y = CUR.zp1.cur[a0].y + R.y;
@@ -6132,11 +7005,11 @@
p1 = (FT_UShort)args[0];
p2 = (FT_UShort)args[1];
- if ( BOUNDS( args[0], CUR.zp1.n_points ) ||
- BOUNDS( args[1], CUR.zp0.n_points ) )
+ if ( BOUNDS( p1, CUR.zp1.n_points ) ||
+ BOUNDS( p2, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -6170,8 +7043,9 @@
if ( CUR.top < CUR.GS.loop )
{
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
/*
@@ -6184,8 +7058,8 @@
if ( BOUNDS( CUR.GS.rp1, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
- return;
+ CUR.error = FT_THROW( Invalid_Reference );
+ goto Fail;
}
if ( twilight )
@@ -6210,9 +7084,21 @@
if ( twilight )
old_range = CUR_Func_dualproj( &CUR.zp1.org[CUR.GS.rp2],
orus_base );
- else
+ else if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
old_range = CUR_Func_dualproj( &CUR.zp1.orus[CUR.GS.rp2],
orus_base );
+ else
+ {
+ FT_Vector vec;
+
+
+ vec.x = FT_MulFix( CUR.zp1.orus[CUR.GS.rp2].x - orus_base->x,
+ CUR.metrics.x_scale );
+ vec.y = FT_MulFix( CUR.zp1.orus[CUR.GS.rp2].y - orus_base->y,
+ CUR.metrics.y_scale );
+
+ old_range = CUR_fast_dualproj( &vec );
+ }
cur_range = CUR_Func_project ( &CUR.zp1.cur[CUR.GS.rp2], cur_base );
}
@@ -6228,7 +7114,7 @@
{
if ( CUR.pedantic_hinting )
{
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
continue;
@@ -6236,20 +7122,55 @@
if ( twilight )
org_dist = CUR_Func_dualproj( &CUR.zp2.org[point], orus_base );
- else
+ else if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
org_dist = CUR_Func_dualproj( &CUR.zp2.orus[point], orus_base );
+ else
+ {
+ FT_Vector vec;
- cur_dist = CUR_Func_project ( &CUR.zp2.cur[point], cur_base );
+
+ vec.x = FT_MulFix( CUR.zp2.orus[point].x - orus_base->x,
+ CUR.metrics.x_scale );
+ vec.y = FT_MulFix( CUR.zp2.orus[point].y - orus_base->y,
+ CUR.metrics.y_scale );
+
+ org_dist = CUR_fast_dualproj( &vec );
+ }
+
+ cur_dist = CUR_Func_project( &CUR.zp2.cur[point], cur_base );
if ( org_dist )
- new_dist = ( old_range != 0 )
- ? TT_MULDIV( org_dist, cur_range, old_range )
- : cur_dist;
+ {
+ if ( old_range )
+ new_dist = FT_MulDiv( org_dist, cur_range, old_range );
+ else
+ {
+ /* This is the same as what MS does for the invalid case: */
+ /* */
+ /* delta = (Original_Pt - Original_RP1) - */
+ /* (Current_Pt - Current_RP1) ; */
+ /* */
+ /* In FreeType speak: */
+ /* */
+ /* delta = org_dist - cur_dist . */
+ /* */
+ /* We move `point' by `new_dist - cur_dist' after leaving */
+ /* this block, thus we have */
+ /* */
+ /* new_dist - cur_dist = delta , */
+ /* new_dist - cur_dist = org_dist - cur_dist , */
+ /* new_dist = org_dist . */
+
+ new_dist = org_dist;
+ }
+ }
else
new_dist = 0;
CUR_Func_move( &CUR.zp2, (FT_UShort)point, new_dist - cur_dist );
}
+
+ Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
@@ -6273,7 +7194,7 @@
if ( BOUNDS( point, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
@@ -6402,12 +7323,12 @@
if ( !scale_valid )
{
scale_valid = 1;
- scale = TT_MULDIV( org2 + delta2 - ( org1 + delta1 ),
- 0x10000L, orus2 - orus1 );
+ scale = FT_DivFix( org2 + delta2 - ( org1 + delta1 ),
+ orus2 - orus1 );
}
x = ( org1 + delta1 ) +
- TT_MULFIX( worker->orus[i].x - orus1, scale );
+ FT_MulFix( worker->orus[i].x - orus1, scale );
}
worker->curs[i].x = x;
}
@@ -6462,13 +7383,23 @@
contour = 0;
point = 0;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode )
+ {
+ CUR.iup_called = TRUE;
+ if ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_IUP )
+ return;
+ }
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
do
{
end_point = CUR.pts.contours[contour] - CUR.pts.first_point;
first_point = point;
- if ( CUR.pts.n_points <= end_point )
- end_point = CUR.pts.n_points;
+ if ( BOUNDS ( end_point, CUR.pts.n_points ) )
+ end_point = CUR.pts.n_points - 1;
while ( point <= end_point && ( CUR.pts.tags[point] & mask ) == 0 )
point++;
@@ -6484,12 +7415,11 @@
{
if ( ( CUR.pts.tags[point] & mask ) != 0 )
{
- if ( point > 0 )
- _iup_worker_interpolate( &V,
- cur_touched + 1,
- point - 1,
- cur_touched,
- point );
+ _iup_worker_interpolate( &V,
+ cur_touched + 1,
+ point - 1,
+ cur_touched,
+ point );
cur_touched = point;
}
@@ -6528,10 +7458,20 @@
static void
Ins_DELTAP( INS_ARG )
{
- FT_ULong k, nump;
+ FT_ULong nump, k;
FT_UShort A;
- FT_ULong C;
+ FT_ULong C, P;
FT_Long B;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_UShort B1, B2;
+
+
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.iup_called &&
+ ( CUR.sph_tweak_flags & SPH_TWEAK_NO_DELTAP_AFTER_IUP ) )
+ goto Fail;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
@@ -6543,8 +7483,9 @@
if ( CUR.args < n )
{
- CUR.error = TT_Err_Too_Few_Arguments;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Too_Few_Arguments );
+ n = CUR.args;
}
CUR.args -= n;
@@ -6553,6 +7494,7 @@
}
#endif
+ P = (FT_ULong)CUR_Func_cur_ppem();
nump = (FT_ULong)args[0]; /* some points theoretically may occur more
than once, thus UShort isn't enough */
@@ -6560,8 +7502,10 @@
{
if ( CUR.args < 2 )
{
- CUR.error = TT_Err_Too_Few_Arguments;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Too_Few_Arguments );
+ CUR.args = 0;
+ goto Fail;
}
CUR.args -= 2;
@@ -6595,21 +7539,83 @@
C += CUR.GS.delta_base;
- if ( CURRENT_Ppem() == (FT_Long)C )
+ if ( P == C )
{
B = ( (FT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
- B = B * 64 / ( 1L << CUR.GS.delta_shift );
+ B *= 1L << ( 6 - CUR.GS.delta_shift );
- CUR_Func_move( &CUR.zp0, A, B );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ if ( SUBPIXEL_HINTING )
+ {
+ /*
+ * Allow delta move if
+ *
+ * - not using ignore_x_mode rendering,
+ * - glyph is specifically set to allow it, or
+ * - glyph is composite and freedom vector is not in subpixel
+ * direction.
+ */
+ if ( !CUR.ignore_x_mode ||
+ ( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) ||
+ ( CUR.is_composite && CUR.GS.freeVector.y != 0 ) )
+ CUR_Func_move( &CUR.zp0, A, B );
+
+ /* Otherwise, apply subpixel hinting and compatibility mode */
+ /* rules, always skipping deltas in subpixel direction. */
+ else if ( CUR.ignore_x_mode && CUR.GS.freeVector.y != 0 )
+ {
+ /* save the y value of the point now; compare after move */
+ B1 = (FT_UShort)CUR.zp0.cur[A].y;
+
+ /* Standard subpixel hinting: Allow y move for y-touched */
+ /* points. This messes up DejaVu ... */
+ if ( !CUR.face->sph_compatibility_mode &&
+ ( CUR.zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
+ CUR_Func_move( &CUR.zp0, A, B );
+
+ /* compatibility mode */
+ else if ( CUR.face->sph_compatibility_mode &&
+ !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
+ {
+ if ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
+ B = FT_PIX_ROUND( B1 + B ) - B1;
+
+ /* Allow delta move if using sph_compatibility_mode, */
+ /* IUP has not been called, and point is touched on Y. */
+ if ( !CUR.iup_called &&
+ ( CUR.zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
+ CUR_Func_move( &CUR.zp0, A, B );
+ }
+
+ B2 = (FT_UShort)CUR.zp0.cur[A].y;
+
+ /* Reverse this move if it results in a disallowed move */
+ if ( CUR.GS.freeVector.y != 0 &&
+ ( ( CUR.face->sph_compatibility_mode &&
+ ( B1 & 63 ) == 0 &&
+ ( B2 & 63 ) != 0 ) ||
+ ( ( CUR.sph_tweak_flags &
+ SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) &&
+ ( B1 & 63 ) != 0 &&
+ ( B2 & 63 ) != 0 ) ) )
+ CUR_Func_move( &CUR.zp0, A, -B );
+ }
+ }
+ else
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ CUR_Func_move( &CUR.zp0, A, B );
}
}
else
if ( CUR.pedantic_hinting )
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
}
+ Fail:
CUR.new_top = CUR.args;
}
@@ -6624,7 +7630,7 @@
Ins_DELTAC( INS_ARG )
{
FT_ULong nump, k;
- FT_ULong A, C;
+ FT_ULong A, C, P;
FT_Long B;
@@ -6637,8 +7643,9 @@
if ( CUR.args < n )
{
- CUR.error = TT_Err_Too_Few_Arguments;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Too_Few_Arguments );
+ n = CUR.args;
}
CUR.args -= n;
@@ -6647,14 +7654,17 @@
}
#endif
+ P = (FT_ULong)CUR_Func_cur_ppem();
nump = (FT_ULong)args[0];
for ( k = 1; k <= nump; k++ )
{
if ( CUR.args < 2 )
{
- CUR.error = TT_Err_Too_Few_Arguments;
- return;
+ if ( CUR.pedantic_hinting )
+ CUR.error = FT_THROW( Too_Few_Arguments );
+ CUR.args = 0;
+ goto Fail;
}
CUR.args -= 2;
@@ -6662,11 +7672,11 @@
A = (FT_ULong)CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
- if ( BOUNDS( A, CUR.cvtSize ) )
+ if ( BOUNDSL( A, CUR.cvtSize ) )
{
if ( CUR.pedantic_hinting )
{
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
@@ -6690,18 +7700,19 @@
C += CUR.GS.delta_base;
- if ( CURRENT_Ppem() == (FT_Long)C )
+ if ( P == C )
{
B = ( (FT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
- B = B * 64 / ( 1L << CUR.GS.delta_shift );
+ B *= 1L << ( 6 - CUR.GS.delta_shift );
CUR_Func_move_cvt( A, B );
}
}
}
+ Fail:
CUR.new_top = CUR.args;
}
@@ -6727,22 +7738,109 @@
K = 0;
- /* We return MS rasterizer version 1.7 for the font scaler. */
- if ( ( args[0] & 1 ) != 0 )
- K = 35;
-
- /* Has the glyph been rotated? */
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ /********************************/
+ /* RASTERIZER VERSION */
+ /* Selector Bit: 0 */
+ /* Return Bit(s): 0-7 */
+ /* */
+ if ( SUBPIXEL_HINTING &&
+ ( args[0] & 1 ) != 0 &&
+ CUR.ignore_x_mode )
+ {
+ K = CUR.rasterizer_version;
+ FT_TRACE7(( "Setting rasterizer version %d\n",
+ CUR.rasterizer_version ));
+ }
+ else
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+ if ( ( args[0] & 1 ) != 0 )
+ K = TT_INTERPRETER_VERSION_35;
+
+ /********************************/
+ /* GLYPH ROTATED */
+ /* Selector Bit: 1 */
+ /* Return Bit(s): 8 */
+ /* */
if ( ( args[0] & 2 ) != 0 && CUR.tt_metrics.rotated )
K |= 0x80;
- /* Has the glyph been stretched? */
+ /********************************/
+ /* GLYPH STRETCHED */
+ /* Selector Bit: 2 */
+ /* Return Bit(s): 9 */
+ /* */
if ( ( args[0] & 4 ) != 0 && CUR.tt_metrics.stretched )
K |= 1 << 8;
- /* Are we hinting for grayscale? */
+ /********************************/
+ /* HINTING FOR GRAYSCALE */
+ /* Selector Bit: 5 */
+ /* Return Bit(s): 12 */
+ /* */
if ( ( args[0] & 32 ) != 0 && CUR.grayscale )
K |= 1 << 12;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ if ( SUBPIXEL_HINTING &&
+ CUR.ignore_x_mode &&
+ CUR.rasterizer_version >= TT_INTERPRETER_VERSION_35 )
+ {
+
+ if ( CUR.rasterizer_version >= 37 )
+ {
+ /********************************/
+ /* HINTING FOR SUBPIXEL */
+ /* Selector Bit: 6 */
+ /* Return Bit(s): 13 */
+ /* */
+ if ( ( args[0] & 64 ) != 0 && CUR.subpixel )
+ K |= 1 << 13;
+
+ /********************************/
+ /* COMPATIBLE WIDTHS ENABLED */
+ /* Selector Bit: 7 */
+ /* Return Bit(s): 14 */
+ /* */
+ /* Functionality still needs to be added */
+ if ( ( args[0] & 128 ) != 0 && CUR.compatible_widths )
+ K |= 1 << 14;
+
+ /********************************/
+ /* SYMMETRICAL SMOOTHING */
+ /* Selector Bit: 8 */
+ /* Return Bit(s): 15 */
+ /* */
+ /* Functionality still needs to be added */
+ if ( ( args[0] & 256 ) != 0 && CUR.symmetrical_smoothing )
+ K |= 1 << 15;
+
+ /********************************/
+ /* HINTING FOR BGR? */
+ /* Selector Bit: 9 */
+ /* Return Bit(s): 16 */
+ /* */
+ /* Functionality still needs to be added */
+ if ( ( args[0] & 512 ) != 0 && CUR.bgr )
+ K |= 1 << 16;
+
+ if ( CUR.rasterizer_version >= 38 )
+ {
+ /********************************/
+ /* SUBPIXEL POSITIONED? */
+ /* Selector Bit: 10 */
+ /* Return Bit(s): 17 */
+ /* */
+ /* Functionality still needs to be added */
+ if ( ( args[0] & 1024 ) != 0 && CUR.subpixel_positioned )
+ K |= 1 << 17;
+ }
+ }
+ }
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
args[0] = K;
}
@@ -6765,16 +7863,16 @@
if ( CUR.callTop >= CUR.callSize )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
return;
}
call = CUR.callStack + CUR.callTop++;
call->Caller_Range = CUR.curRange;
- call->Caller_IP = CUR.IP+1;
+ call->Caller_IP = CUR.IP + 1;
call->Cur_Count = 1;
- call->Cur_Restart = def->start;
+ call->Def = def;
INS_Goto_CodeRange( def->range, def->start );
@@ -6783,7 +7881,7 @@
}
}
- CUR.error = TT_Err_Invalid_Opcode;
+ CUR.error = FT_THROW( Invalid_Opcode );
}
@@ -7110,18 +8208,40 @@
FT_EXPORT_DEF( FT_Error )
TT_RunIns( TT_ExecContext exc )
{
- FT_Long ins_counter = 0; /* executed instructions counter */
+ FT_Long ins_counter = 0; /* executed instructions counter */
+ FT_UShort i;
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_Byte opcode_pattern[1][2] = {
+ /* #8 TypeMan Talk Align */
+ {
+ 0x06, /* SPVTL */
+ 0x7D, /* RDTG */
+ },
+ };
+ FT_UShort opcode_patterns = 1;
+ FT_UShort opcode_pointer[1] = { 0 };
+ FT_UShort opcode_size[1] = { 1 };
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#ifdef TT_CONFIG_OPTION_STATIC_RASTER
+ if ( !exc )
+ return FT_THROW( Invalid_Argument );
+
cur = *exc;
#endif
- /* set CVT functions */
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ CUR.iup_called = FALSE;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ /* set PPEM and CVT functions */
CUR.tt_metrics.ratio = 0;
if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem )
{
/* non-square pixels, use the stretched routines */
+ CUR.func_cur_ppem = Current_Ppem_Stretched;
CUR.func_read_cvt = Read_CVT_Stretched;
CUR.func_write_cvt = Write_CVT_Stretched;
CUR.func_move_cvt = Move_CVT_Stretched;
@@ -7129,6 +8249,7 @@
else
{
/* square pixels, use normal routines */
+ CUR.func_cur_ppem = Current_Ppem;
CUR.func_read_cvt = Read_CVT;
CUR.func_write_cvt = Write_CVT;
CUR.func_move_cvt = Move_CVT;
@@ -7141,9 +8262,13 @@
{
CUR.opcode = CUR.code[CUR.IP];
+ FT_TRACE7(( " " ));
+ FT_TRACE7(( opcode_name[CUR.opcode] ));
+ FT_TRACE7(( "\n" ));
+
if ( ( CUR.length = opcode_length[CUR.opcode] ) < 0 )
{
- if ( CUR.IP + 1 > CUR.codeSize )
+ if ( CUR.IP + 1 >= CUR.codeSize )
goto LErrorCodeOverflow_;
CUR.length = 2 - CUR.length * CUR.code[CUR.IP + 1];
@@ -7159,8 +8284,16 @@
/* One can also interpret it as the index of the last argument. */
if ( CUR.args < 0 )
{
- CUR.error = TT_Err_Too_Few_Arguments;
- goto LErrorLabel_;
+ if ( CUR.pedantic_hinting )
+ {
+ CUR.error = FT_THROW( Too_Few_Arguments );
+ goto LErrorLabel_;
+ }
+
+ /* push zeroes onto the stack */
+ for ( i = 0; i < Pop_Push_Count[CUR.opcode] >> 4; i++ )
+ CUR.stack[i] = 0;
+ CUR.args = 0;
}
CUR.new_top = CUR.args + ( Pop_Push_Count[CUR.opcode] & 15 );
@@ -7170,12 +8303,45 @@
/* statement. */
if ( CUR.new_top > CUR.stackSize )
{
- CUR.error = TT_Err_Stack_Overflow;
+ CUR.error = FT_THROW( Stack_Overflow );
goto LErrorLabel_;
}
CUR.step_ins = TRUE;
- CUR.error = TT_Err_Ok;
+ CUR.error = FT_Err_Ok;
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ if ( SUBPIXEL_HINTING )
+ {
+ for ( i = 0; i < opcode_patterns; i++ )
+ {
+ if ( opcode_pointer[i] < opcode_size[i] &&
+ CUR.opcode == opcode_pattern[i][opcode_pointer[i]] )
+ {
+ opcode_pointer[i] += 1;
+
+ if ( opcode_pointer[i] == opcode_size[i] )
+ {
+ FT_TRACE7(( "sph: opcode ptrn: %d, %s %s\n",
+ i,
+ CUR.face->root.family_name,
+ CUR.face->root.style_name ));
+
+ switch ( i )
+ {
+ case 0:
+ break;
+ }
+ opcode_pointer[i] = 0;
+ }
+ }
+ else
+ opcode_pointer[i] = 0;
+ }
+ }
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#ifdef TT_CONFIG_OPTION_INTERPRETER_SWITCH
@@ -7197,7 +8363,7 @@
case 0x04: /* SFvTCA y */
case 0x05: /* SFvTCA x */
{
- FT_Short AA, BB;
+ FT_Short AA, BB;
AA = (FT_Short)( ( opcode & 1 ) << 14 );
@@ -7389,7 +8555,6 @@
Ins_MDAP( EXEC_ARG_ args );
break;
-
case 0x30: /* IUP */
case 0x31: /* IUP */
Ins_IUP( EXEC_ARG_ args );
@@ -7449,7 +8614,7 @@
break;
Set_Invalid_Ref:
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
break;
case 0x43: /* RS */
@@ -7739,11 +8904,12 @@
#endif /* TT_CONFIG_OPTION_INTERPRETER_SWITCH */
- if ( CUR.error != TT_Err_Ok )
+ if ( CUR.error )
{
switch ( CUR.error )
{
- case TT_Err_Invalid_Opcode: /* looking for redefined instructions */
+ /* looking for redefined instructions */
+ case FT_ERR( Invalid_Opcode ):
{
TT_DefRecord* def = CUR.IDefs;
TT_DefRecord* limit = def + CUR.numIDefs;
@@ -7758,7 +8924,7 @@
if ( CUR.callTop >= CUR.callSize )
{
- CUR.error = TT_Err_Invalid_Reference;
+ CUR.error = FT_THROW( Invalid_Reference );
goto LErrorLabel_;
}
@@ -7767,7 +8933,7 @@
callrec->Caller_Range = CUR.curRange;
callrec->Caller_IP = CUR.IP + 1;
callrec->Cur_Count = 1;
- callrec->Cur_Restart = def->start;
+ callrec->Def = def;
if ( INS_Goto_CodeRange( def->range, def->start ) == FAILURE )
goto LErrorLabel_;
@@ -7777,7 +8943,7 @@
}
}
- CUR.error = TT_Err_Invalid_Opcode;
+ CUR.error = FT_THROW( Invalid_Opcode );
goto LErrorLabel_;
#if 0
@@ -7803,14 +8969,14 @@
/* 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 )
- return TT_Err_Execution_Too_Long;
+ return FT_THROW( Execution_Too_Long );
LSuiteLabel_:
if ( CUR.IP >= CUR.codeSize )
{
if ( CUR.callTop > 0 )
{
- CUR.error = TT_Err_Code_Overflow;
+ CUR.error = FT_THROW( Code_Overflow );
goto LErrorLabel_;
}
else
@@ -7824,10 +8990,10 @@
*exc = cur;
#endif
- return TT_Err_Ok;
+ return FT_Err_Ok;
LErrorCodeOverflow_:
- CUR.error = TT_Err_Code_Overflow;
+ CUR.error = FT_THROW( Code_Overflow );
LErrorLabel_:
@@ -7835,6 +9001,18 @@
*exc = cur;
#endif
+ /* If any errors have occurred, function tables may be broken. */
+ /* Force a re-execution of `prep' and `fpgm' tables if no */
+ /* bytecode debugger is run. */
+ if ( CUR.error &&
+ !CUR.instruction_trap &&
+ CUR.curRange == tt_coderange_glyph )
+ {
+ FT_TRACE1(( " The interpreter returned error 0x%x\n", CUR.error ));
+ exc->size->bytecode_ready = -1;
+ exc->size->cvt_ready = -1;
+ }
+
return CUR.error;
}
diff --git a/src/3rdparty/freetype/src/truetype/ttinterp.h b/src/3rdparty/freetype/src/truetype/ttinterp.h
index 07a8972cb3..333decc6a6 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-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
+/* Copyright 1996-2007, 2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -81,6 +81,10 @@ FT_BEGIN_HEADER
(*TT_Project_Func)( EXEC_OP_ FT_Pos dx,
FT_Pos dy );
+ /* getting current ppem. Take care of non-square pixels if necessary */
+ typedef FT_Long
+ (*TT_Cur_Ppem_Func)( EXEC_OP );
+
/* reading a cvt value. Take care of non-square pixels if necessary */
typedef FT_F26Dot6
(*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong idx );
@@ -101,11 +105,54 @@ FT_BEGIN_HEADER
FT_Int Caller_Range;
FT_Long Caller_IP;
FT_Long Cur_Count;
- FT_Long Cur_Restart;
+
+ TT_DefRecord *Def; /* either FDEF or IDEF */
} TT_CallRec, *TT_CallStack;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ /*************************************************************************/
+ /* */
+ /* These structures define rules used to tweak subpixel hinting for */
+ /* various fonts. "", 0, "", NULL value indicates to match any value. */
+ /* */
+
+#define SPH_MAX_NAME_SIZE 32
+#define SPH_MAX_CLASS_MEMBERS 100
+
+ typedef struct SPH_TweakRule_
+ {
+ const char family[SPH_MAX_NAME_SIZE];
+ const FT_UInt ppem;
+ const char style[SPH_MAX_NAME_SIZE];
+ const FT_ULong glyph;
+
+ } SPH_TweakRule;
+
+
+ typedef struct SPH_ScaleRule_
+ {
+ const char family[SPH_MAX_NAME_SIZE];
+ const FT_UInt ppem;
+ const char style[SPH_MAX_NAME_SIZE];
+ const FT_ULong glyph;
+ const FT_ULong scale;
+
+ } SPH_ScaleRule;
+
+
+ typedef struct SPH_Font_Class_
+ {
+ const char name[SPH_MAX_NAME_SIZE];
+ const char member[SPH_MAX_CLASS_MEMBERS][SPH_MAX_NAME_SIZE];
+
+ } SPH_Font_Class;
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+
/*************************************************************************/
/* */
/* The main structure for the interpreter which collects all necessary */
@@ -150,7 +197,7 @@ FT_BEGIN_HEADER
FT_Bool step_ins; /* true if the interpreter must */
/* increment IP after ins. exec */
- FT_Long cvtSize;
+ FT_ULong cvtSize;
FT_Long* cvt;
FT_UInt glyphSize; /* glyph instructions buffer size */
@@ -185,11 +232,6 @@ FT_BEGIN_HEADER
FT_F26Dot6 phase; /* `SuperRounding' */
FT_F26Dot6 threshold;
-#if 0
- /* this seems to be unused */
- FT_Int cur_ppem; /* ppem along the current proj vector */
-#endif
-
FT_Bool instruction_trap; /* If `True', the interpreter will */
/* exit after each instruction */
@@ -211,34 +253,74 @@ FT_BEGIN_HEADER
TT_Move_Func func_move; /* current point move function */
TT_Move_Func func_move_orig; /* move original position function */
+ TT_Cur_Ppem_Func func_cur_ppem; /* get current proj. ppem value */
+
TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
FT_Bool grayscale; /* are we hinting for grayscale? */
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ TT_Round_Func func_round_sphn; /* subpixel rounding function */
+
+ FT_Bool subpixel; /* Using subpixel hinting? */
+ FT_Bool ignore_x_mode; /* Standard rendering mode for */
+ /* subpixel hinting. On if gray */
+ /* or subpixel hinting is on. */
+
+ /* The following 4 aren't fully implemented but here for MS rasterizer */
+ /* compatibility. */
+ FT_Bool compatible_widths; /* compatible widths? */
+ FT_Bool symmetrical_smoothing; /* symmetrical_smoothing? */
+ FT_Bool bgr; /* bgr instead of rgb? */
+ FT_Bool subpixel_positioned; /* subpixel positioned */
+ /* (DirectWrite ClearType)? */
+
+ FT_Int rasterizer_version; /* MS rasterizer version */
+
+ FT_Bool iup_called; /* IUP called for glyph? */
+
+ FT_ULong sph_tweak_flags; /* flags to control */
+ /* hint tweaks */
+
+ FT_ULong sph_in_func_flags; /* flags to indicate if in */
+ /* special functions */
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
} TT_ExecContextRec;
extern const TT_GraphicsState tt_default_graphics_state;
- FT_LOCAL( FT_Error )
+#ifdef TT_USE_BYTECODE_INTERPRETER
+ FT_LOCAL( void )
TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
FT_Long IP );
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
void* base,
FT_Long length );
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range );
+ FT_LOCAL( FT_Error )
+ Update_Max( FT_Memory memory,
+ FT_ULong* size,
+ FT_Long multiplier,
+ void* _pbuff,
+ FT_ULong new_max );
+#endif /* TT_USE_BYTECODE_INTERPRETER */
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -261,7 +343,9 @@ FT_BEGIN_HEADER
FT_EXPORT( TT_ExecContext )
TT_New_Context( TT_Driver driver );
- FT_LOCAL( FT_Error )
+
+#ifdef TT_USE_BYTECODE_INTERPRETER
+ FT_LOCAL( void )
TT_Done_Context( TT_ExecContext exec );
FT_LOCAL( FT_Error )
@@ -269,13 +353,14 @@ FT_BEGIN_HEADER
TT_Face face,
TT_Size size );
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
TT_Save_Context( TT_ExecContext exec,
TT_Size ins );
FT_LOCAL( FT_Error )
TT_Run_Context( TT_ExecContext exec,
FT_Bool debug );
+#endif /* TT_USE_BYTECODE_INTERPRETER */
/*************************************************************************/
diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.c b/src/3rdparty/freetype/src/truetype/ttobjs.c
index 11d662d2d4..4707dfe159 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2013 */
/* 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_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_SFNT_H
+#include FT_TRUETYPE_DRIVER_H
#include "ttgload.h"
#include "ttpload.h"
@@ -146,28 +147,29 @@
/* This list shall be expanded as we find more of them. */
static FT_Bool
- tt_check_trickyness( FT_String* name )
+ tt_check_trickyness_family( FT_String* name )
{
-#define TRICK_NAMES_MAX_CHARACTERS 16
-#define TRICK_NAMES_COUNT 7
- static const char trick_names[TRICK_NAMES_COUNT][TRICK_NAMES_MAX_CHARACTERS+1] =
+
+#define TRICK_NAMES_MAX_CHARACTERS 19
+#define TRICK_NAMES_COUNT 9
+
+ static const char trick_names[TRICK_NAMES_COUNT]
+ [TRICK_NAMES_MAX_CHARACTERS + 1] =
{
- "DFKaiSho-SB", /* dfkaisb.ttf */
+ "DFKaiSho-SB", /* dfkaisb.ttf */
"DFKaiShu",
- "DFKai-SB", /* kaiu.ttf */
- "HuaTianSongTi?", /* htst3.ttf */
- "MingLiU", /* mingliu.ttf & mingliu.ttc */
- "PMingLiU", /* mingliu.ttc */
- "MingLi43", /* mingli.ttf */
+ "DFKai-SB", /* kaiu.ttf */
+ "HuaTianKaiTi?", /* htkt2.ttf */
+ "HuaTianSongTi?", /* htst3.ttf */
+ "Ming(for ISO10646)", /* hkscsiic.ttf & iicore.ttf */
+ "MingLiU", /* mingliu.ttf & mingliu.ttc */
+ "PMingLiU", /* mingliu.ttc */
+ "MingLi43", /* mingli.ttf */
};
- int nn;
+ int nn;
- if ( !name )
- return FALSE;
- /* Note that we only check the face name at the moment; it might */
- /* be worth to do more checks for a few special cases. */
for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ )
if ( ft_strstr( name, trick_names[nn] ) )
return TRUE;
@@ -176,6 +178,307 @@
}
+ /* XXX: This function should be in the `sfnt' module. */
+
+ /* Some PDF generators clear the checksums in the TrueType header table. */
+ /* For example, Quartz ContextPDF clears all entries, or Bullzip PDF */
+ /* Printer clears the entries for subsetted subtables. We thus have to */
+ /* recalculate the checksums where necessary. */
+
+ static FT_UInt32
+ tt_synth_sfnt_checksum( FT_Stream stream,
+ FT_ULong length )
+ {
+ FT_Error error;
+ FT_UInt32 checksum = 0;
+ int i;
+
+
+ if ( FT_FRAME_ENTER( length ) )
+ return 0;
+
+ for ( ; length > 3; length -= 4 )
+ checksum += (FT_UInt32)FT_GET_ULONG();
+
+ for ( i = 3; length > 0; length --, i-- )
+ checksum += (FT_UInt32)( FT_GET_BYTE() << ( i * 8 ) );
+
+ FT_FRAME_EXIT();
+
+ return checksum;
+ }
+
+
+ /* XXX: This function should be in the `sfnt' module. */
+
+ static FT_ULong
+ tt_get_sfnt_checksum( TT_Face face,
+ FT_UShort i )
+ {
+#if 0 /* if we believe the written value, use following part. */
+ if ( face->dir_tables[i].CheckSum )
+ return face->dir_tables[i].CheckSum;
+#endif
+
+ if ( !face->goto_table )
+ return 0;
+
+ if ( face->goto_table( face,
+ face->dir_tables[i].Tag,
+ face->root.stream,
+ NULL ) )
+ return 0;
+
+ return (FT_ULong)tt_synth_sfnt_checksum( face->root.stream,
+ face->dir_tables[i].Length );
+ }
+
+
+ typedef struct tt_sfnt_id_rec_
+ {
+ FT_ULong CheckSum;
+ FT_ULong Length;
+
+ } tt_sfnt_id_rec;
+
+
+ static FT_Bool
+ tt_check_trickyness_sfnt_ids( TT_Face face )
+ {
+#define TRICK_SFNT_IDS_PER_FACE 3
+#define TRICK_SFNT_IDS_NUM_FACES 17
+
+ static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES]
+ [TRICK_SFNT_IDS_PER_FACE] = {
+
+#define TRICK_SFNT_ID_cvt 0
+#define TRICK_SFNT_ID_fpgm 1
+#define TRICK_SFNT_ID_prep 2
+
+ { /* MingLiU 1995 */
+ { 0x05BCF058UL, 0x000002E4UL }, /* cvt */
+ { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
+ { 0xA344A1EAUL, 0x000001E1UL } /* prep */
+ },
+ { /* MingLiU 1996- */
+ { 0x05BCF058UL, 0x000002E4UL }, /* cvt */
+ { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
+ { 0xA344A1EBUL, 0x000001E1UL } /* prep */
+ },
+ { /* DFKaiShu */
+ { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
+ { 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */
+ { 0x13A42602UL, 0x0000007EUL } /* prep */
+ },
+ { /* HuaTianKaiTi */
+ { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */
+ { 0x9C9E48B8UL, 0x0000BEA2UL }, /* fpgm */
+ { 0x70020112UL, 0x00000008UL } /* prep */
+ },
+ { /* HuaTianSongTi */
+ { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */
+ { 0x0A5A0483UL, 0x00017C39UL }, /* fpgm */
+ { 0x70020112UL, 0x00000008UL } /* prep */
+ },
+ { /* NEC fadpop7.ttf */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
+ { 0xA39B58E3UL, 0x0000117CUL } /* prep */
+ },
+ { /* NEC fadrei5.ttf */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x33C41652UL, 0x000000E5UL }, /* fpgm */
+ { 0x26D6C52AUL, 0x00000F6AUL } /* prep */
+ },
+ { /* NEC fangot7.ttf */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x6DB1651DUL, 0x0000019DUL }, /* fpgm */
+ { 0x6C6E4B03UL, 0x00002492UL } /* prep */
+ },
+ { /* NEC fangyo5.ttf */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
+ { 0xDE51FAD0UL, 0x0000117CUL } /* prep */
+ },
+ { /* NEC fankyo5.ttf */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x85E47664UL, 0x000000E5UL }, /* fpgm */
+ { 0xA6C62831UL, 0x00001CAAUL } /* prep */
+ },
+ { /* NEC fanrgo5.ttf */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x2D891CFDUL, 0x0000019DUL }, /* fpgm */
+ { 0xA0604633UL, 0x00001DE8UL } /* prep */
+ },
+ { /* NEC fangot5.ttc */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x40AA774CUL, 0x000001CBUL }, /* fpgm */
+ { 0x9B5CAA96UL, 0x00001F9AUL } /* prep */
+ },
+ { /* NEC fanmin3.ttc */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x0D3DE9CBUL, 0x00000141UL }, /* fpgm */
+ { 0xD4127766UL, 0x00002280UL } /* prep */
+ },
+ { /* NEC FA-Gothic, 1996 */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x4A692698UL, 0x000001F0UL }, /* fpgm */
+ { 0x340D4346UL, 0x00001FCAUL } /* prep */
+ },
+ { /* NEC FA-Minchou, 1996 */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0xCD34C604UL, 0x00000166UL }, /* fpgm */
+ { 0x6CF31046UL, 0x000022B0UL } /* prep */
+ },
+ { /* NEC FA-RoundGothicB, 1996 */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0x5DA75315UL, 0x0000019DUL }, /* fpgm */
+ { 0x40745A5FUL, 0x000022E0UL } /* prep */
+ },
+ { /* NEC FA-RoundGothicM, 1996 */
+ { 0x00000000UL, 0x00000000UL }, /* cvt */
+ { 0xF055FC48UL, 0x000001C2UL }, /* fpgm */
+ { 0x3900DED3UL, 0x00001E18UL } /* prep */
+ }
+ };
+
+ FT_ULong checksum;
+ int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES];
+ FT_Bool has_cvt, has_fpgm, has_prep;
+ FT_UShort i;
+ int j, k;
+
+
+ FT_MEM_SET( num_matched_ids, 0,
+ sizeof ( int ) * TRICK_SFNT_IDS_NUM_FACES );
+ has_cvt = FALSE;
+ has_fpgm = FALSE;
+ has_prep = FALSE;
+
+ for ( i = 0; i < face->num_tables; i++ )
+ {
+ checksum = 0;
+
+ switch( face->dir_tables[i].Tag )
+ {
+ case TTAG_cvt:
+ k = TRICK_SFNT_ID_cvt;
+ has_cvt = TRUE;
+ break;
+
+ case TTAG_fpgm:
+ k = TRICK_SFNT_ID_fpgm;
+ has_fpgm = TRUE;
+ break;
+
+ case TTAG_prep:
+ k = TRICK_SFNT_ID_prep;
+ has_prep = TRUE;
+ break;
+
+ default:
+ continue;
+ }
+
+ for ( j = 0; j < TRICK_SFNT_IDS_NUM_FACES; j++ )
+ if ( face->dir_tables[i].Length == sfnt_id[j][k].Length )
+ {
+ if ( !checksum )
+ checksum = tt_get_sfnt_checksum( face, i );
+
+ if ( sfnt_id[j][k].CheckSum == checksum )
+ num_matched_ids[j]++;
+
+ if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE )
+ return TRUE;
+ }
+ }
+
+ 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] ++;
+ if ( !has_fpgm && !sfnt_id[j][TRICK_SFNT_ID_fpgm].Length )
+ num_matched_ids[j] ++;
+ if ( !has_prep && !sfnt_id[j][TRICK_SFNT_ID_prep].Length )
+ num_matched_ids[j] ++;
+ if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE )
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+ static FT_Bool
+ tt_check_trickyness( FT_Face face )
+ {
+ if ( !face )
+ return FALSE;
+
+ /* For first, check the face name for quick check. */
+ if ( face->family_name &&
+ tt_check_trickyness_family( face->family_name ) )
+ return TRUE;
+
+ /* Type42 fonts may lack `name' tables, we thus try to identify */
+ /* tricky fonts by checking the checksums of Type42-persistent */
+ /* sfnt tables (`cvt', `fpgm', and `prep'). */
+ if ( tt_check_trickyness_sfnt_ids( (TT_Face)face ) )
+ return TRUE;
+
+ return FALSE;
+ }
+
+
+ /* Check whether `.notdef' is the only glyph in the `loca' table. */
+ static FT_Bool
+ tt_check_single_notdef( FT_Face ttface )
+ {
+ FT_Bool result = FALSE;
+
+ TT_Face face = (TT_Face)ttface;
+ FT_UInt asize;
+ FT_ULong i;
+ FT_ULong glyph_index = 0;
+ FT_UInt count = 0;
+
+
+ for( i = 0; i < face->num_locations; i++ )
+ {
+ tt_face_get_location( face, i, &asize );
+ if ( asize > 0 )
+ {
+ count += 1;
+ if ( count > 1 )
+ break;
+ glyph_index = i;
+ }
+ }
+
+ /* Only have a single outline. */
+ if ( count == 1 )
+ {
+ if ( glyph_index == 0 )
+ result = TRUE;
+ else
+ {
+ /* FIXME: Need to test glyphname == .notdef ? */
+ FT_Error error;
+ char buf[8];
+
+
+ error = FT_Get_Glyph_Name( ttface, glyph_index, buf, 8 );
+ if ( !error &&
+ buf[0] == '.' && !ft_strncmp( buf, ".notdef", 8 ) )
+ result = TRUE;
+ }
+ }
+
+ return result;
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -212,10 +515,17 @@
TT_Face face = (TT_Face)ttface;
+ FT_TRACE2(( "TTF driver\n" ));
+
library = ttface->driver->root.library;
- sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
+
+ sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
- goto Bad_Format;
+ {
+ FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
/* create input stream from resource */
if ( FT_STREAM_SEEK( 0 ) )
@@ -223,6 +533,10 @@
/* check that we have a valid TrueType file */
error = sfnt->init_face( stream, face, face_index, num_params, params );
+
+ /* Stream may have changed. */
+ stream = face->root.stream;
+
if ( error )
goto Exit;
@@ -233,7 +547,7 @@
face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */
face->format_tag != TTAG_true ) /* Mac fonts */
{
- FT_TRACE2(( "[not a valid TTF font]\n" ));
+ FT_TRACE2(( " not a TTF font\n" ));
goto Bad_Format;
}
@@ -243,14 +557,14 @@
/* If we are performing a simple font format check, exit immediately. */
if ( face_index < 0 )
- return TT_Err_Ok;
+ return FT_Err_Ok;
/* Load font directory */
error = sfnt->load_face( stream, face, face_index, num_params, params );
if ( error )
goto Exit;
- if ( tt_check_trickyness( ttface->family_name ) )
+ if ( tt_check_trickyness( ttface ) )
ttface->face_flags |= FT_FACE_FLAG_TRICKY;
error = tt_face_load_hdmx( face, stream );
@@ -271,6 +585,20 @@
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 ) )
+ {
+ 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;
+ }
+
#else
if ( !error )
@@ -282,6 +610,19 @@
if ( !error )
error = tt_face_load_prep( face, stream );
+ /* Check the scalable flag based on `loca'. */
+ 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;
+ }
+
#endif
}
@@ -316,7 +657,7 @@
return error;
Bad_Format:
- error = TT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -394,13 +735,16 @@
/* Run the font program. */
/* */
/* <Input> */
- /* size :: A handle to the size object. */
+ /* size :: A handle to the size object. */
+ /* */
+ /* pedantic :: Set if bytecode execution should be pedantic. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- tt_size_run_fpgm( TT_Size size )
+ tt_size_run_fpgm( TT_Size size,
+ FT_Bool pedantic )
{
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
@@ -414,19 +758,23 @@
exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
if ( !exec )
- return TT_Err_Could_Not_Find_Context;
+ return FT_THROW( Could_Not_Find_Context );
- TT_Load_Context( exec, face, size );
+ error = TT_Load_Context( exec, face, size );
+ if ( error )
+ return error;
- exec->callTop = 0;
- exec->top = 0;
+ exec->callTop = 0;
+ exec->top = 0;
exec->period = 64;
exec->phase = 0;
exec->threshold = 0;
exec->instruction_trap = FALSE;
- exec->F_dot_P = 0x10000L;
+ exec->F_dot_P = 0x4000L;
+
+ exec->pedantic_hinting = pedantic;
{
FT_Size_Metrics* metrics = &exec->metrics;
@@ -455,13 +803,15 @@
if ( face->font_program_size > 0 )
{
- error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
+ TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
- if ( !error )
- error = face->interpreter( exec );
+ FT_TRACE4(( "Executing `fpgm' table.\n" ));
+ error = face->interpreter( exec );
}
else
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
+
+ size->bytecode_ready = error;
if ( !error )
TT_Save_Context( exec, size );
@@ -479,13 +829,16 @@
/* Run the control value program. */
/* */
/* <Input> */
- /* size :: A handle to the size object. */
+ /* size :: A handle to the size object. */
+ /* */
+ /* pedantic :: Set if bytecode execution should be pedantic. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- tt_size_run_prep( TT_Size size )
+ tt_size_run_prep( TT_Size size,
+ FT_Bool pedantic )
{
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
@@ -499,15 +852,19 @@
exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
if ( !exec )
- return TT_Err_Could_Not_Find_Context;
+ return FT_THROW( Could_Not_Find_Context );
- TT_Load_Context( exec, face, size );
+ error = TT_Load_Context( exec, face, size );
+ if ( error )
+ return error;
exec->callTop = 0;
exec->top = 0;
exec->instruction_trap = FALSE;
+ exec->pedantic_hinting = pedantic;
+
TT_Set_CodeRange( exec,
tt_coderange_cvt,
face->cvt_program,
@@ -517,13 +874,39 @@
if ( face->cvt_program_size > 0 )
{
- error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
+ TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
+
+ if ( !size->debug )
+ {
+ FT_TRACE4(( "Executing `prep' table.\n" ));
- if ( !error && !size->debug )
error = face->interpreter( exec );
+ }
}
else
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
+
+ size->cvt_ready = error;
+
+ /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */
+ /* graphics state variables to be modified by the CVT program. */
+
+ exec->GS.dualVector.x = 0x4000;
+ exec->GS.dualVector.y = 0;
+ exec->GS.projVector.x = 0x4000;
+ exec->GS.projVector.y = 0x0;
+ exec->GS.freeVector.x = 0x4000;
+ exec->GS.freeVector.y = 0x0;
+
+ exec->GS.rp0 = 0;
+ exec->GS.rp1 = 0;
+ exec->GS.rp2 = 0;
+
+ exec->GS.gep0 = 1;
+ exec->GS.gep1 = 1;
+ exec->GS.gep2 = 1;
+
+ exec->GS.loop = 1;
/* save as default graphics state */
size->GS = exec->GS;
@@ -533,10 +916,6 @@
return error;
}
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
static void
tt_size_done_bytecode( FT_Size ftsize )
@@ -574,28 +953,28 @@
size->max_func = 0;
size->max_ins = 0;
- size->bytecode_ready = 0;
- size->cvt_ready = 0;
+ size->bytecode_ready = -1;
+ size->cvt_ready = -1;
}
/* Initialize bytecode-related fields in the size object. */
/* We do this only if bytecode interpretation is really needed. */
static FT_Error
- tt_size_init_bytecode( FT_Size ftsize )
+ tt_size_init_bytecode( FT_Size ftsize,
+ FT_Bool pedantic )
{
FT_Error error;
TT_Size size = (TT_Size)ftsize;
TT_Face face = (TT_Face)ftsize->face;
FT_Memory memory = face->root.memory;
- FT_Int i;
FT_UShort n_twilight;
TT_MaxProfile* maxp = &face->max_profile;
- size->bytecode_ready = 1;
- size->cvt_ready = 0;
+ size->bytecode_ready = -1;
+ size->cvt_ready = -1;
size->max_function_defs = maxp->maxFunctionDefs;
size->max_instruction_defs = maxp->maxInstructionDefs;
@@ -617,9 +996,11 @@
metrics->rotated = FALSE;
metrics->stretched = FALSE;
- /* set default compensation (all 0) */
- for ( i = 0; i < 4; i++ )
- metrics->compensations[i] = 0;
+ /* set default engine compensation */
+ metrics->compensations[0] = 0; /* gray */
+ metrics->compensations[1] = 0; /* black */
+ metrics->compensations[2] = 0; /* white */
+ metrics->compensations[3] = 0; /* reserved */
}
/* allocate function defs, instruction defs, cvt, and storage area */
@@ -655,7 +1036,7 @@
}
/* Fine, now run the font program! */
- error = tt_size_run_fpgm( size );
+ error = tt_size_run_fpgm( size, pedantic );
Exit:
if ( error )
@@ -666,20 +1047,20 @@
FT_LOCAL_DEF( FT_Error )
- tt_size_ready_bytecode( TT_Size size )
+ tt_size_ready_bytecode( TT_Size size,
+ FT_Bool pedantic )
{
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
- if ( !size->bytecode_ready )
- {
- error = tt_size_init_bytecode( (FT_Size)size );
- if ( error )
- goto Exit;
- }
+ if ( size->bytecode_ready < 0 )
+ error = tt_size_init_bytecode( (FT_Size)size, pedantic );
+
+ if ( error || size->bytecode_ready )
+ goto Exit;
/* rescale CVT when needed */
- if ( !size->cvt_ready )
+ if ( size->cvt_ready < 0 )
{
FT_UInt i;
TT_Face face = (TT_Face)size->root.face;
@@ -705,9 +1086,7 @@
size->GS = tt_default_graphics_state;
- error = tt_size_run_prep( size );
- if ( !error )
- size->cvt_ready = 1;
+ error = tt_size_run_prep( size, pedantic );
}
Exit:
@@ -735,11 +1114,12 @@
tt_size_init( FT_Size ttsize ) /* TT_Size */
{
TT_Size size = (TT_Size)ttsize;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
+
#ifdef TT_USE_BYTECODE_INTERPRETER
- size->bytecode_ready = 0;
- size->cvt_ready = 0;
+ size->bytecode_ready = -1;
+ size->cvt_ready = -1;
#endif
size->ttmetrics.valid = FALSE;
@@ -767,8 +1147,7 @@
#ifdef TT_USE_BYTECODE_INTERPRETER
- if ( size->bytecode_ready )
- tt_size_done_bytecode( ttsize );
+ tt_size_done_bytecode( ttsize );
#endif
size->ttmetrics.valid = FALSE;
@@ -791,7 +1170,7 @@
tt_size_reset( TT_Size size )
{
TT_Face face;
- FT_Error error = TT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Size_Metrics* metrics;
@@ -805,7 +1184,7 @@
*metrics = size->root.metrics;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
- return TT_Err_Invalid_PPem;
+ return FT_THROW( Invalid_PPem );
/* This bit flag, if set, indicates that the ppems must be */
/* rounded to integers. Nearly all TrueType fonts have this bit */
@@ -835,22 +1214,20 @@
size->ttmetrics.scale = metrics->x_scale;
size->ttmetrics.ppem = metrics->x_ppem;
size->ttmetrics.x_ratio = 0x10000L;
- size->ttmetrics.y_ratio = FT_MulDiv( metrics->y_ppem,
- 0x10000L,
+ size->ttmetrics.y_ratio = FT_DivFix( metrics->y_ppem,
metrics->x_ppem );
}
else
{
size->ttmetrics.scale = metrics->y_scale;
size->ttmetrics.ppem = metrics->y_ppem;
- size->ttmetrics.x_ratio = FT_MulDiv( metrics->x_ppem,
- 0x10000L,
+ size->ttmetrics.x_ratio = FT_DivFix( metrics->x_ppem,
metrics->y_ppem );
size->ttmetrics.y_ratio = 0x10000L;
}
#ifdef TT_USE_BYTECODE_INTERPRETER
- size->cvt_ready = 0;
+ size->cvt_ready = -1;
#endif /* TT_USE_BYTECODE_INTERPRETER */
if ( !error )
@@ -884,15 +1261,21 @@
if ( !TT_New_Context( driver ) )
- return TT_Err_Could_Not_Find_Context;
+ return FT_THROW( Could_Not_Find_Context );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ driver->interpreter_version = TT_INTERPRETER_VERSION_38;
#else
+ driver->interpreter_version = TT_INTERPRETER_VERSION_35;
+#endif
+
+#else /* !TT_USE_BYTECODE_INTERPRETER */
FT_UNUSED( ttdriver );
-#endif
+#endif /* !TT_USE_BYTECODE_INTERPRETER */
- return TT_Err_Ok;
+ return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.h b/src/3rdparty/freetype/src/truetype/ttobjs.h
index 30c8669cb2..859164f86b 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -95,8 +95,8 @@ FT_BEGIN_HEADER
FT_F26Dot6 control_value_cutin;
FT_F26Dot6 single_width_cutin;
FT_F26Dot6 single_width_value;
- FT_Short delta_base;
- FT_Short delta_shift;
+ FT_UShort delta_base;
+ FT_UShort delta_shift;
FT_Byte instruct_control;
/* According to Greg Hitchcock from Microsoft, the `scan_control' */
@@ -173,10 +173,13 @@ FT_BEGIN_HEADER
/* */
typedef struct TT_DefRecord_
{
- FT_Int range; /* in which code range is it located? */
- FT_Long start; /* where does it start? */
- FT_UInt opc; /* function #, or instruction code */
- FT_Bool active; /* is it active? */
+ FT_Int range; /* in which code range is it located? */
+ FT_Long start; /* where does it start? */
+ FT_Long end; /* where does it end? */
+ FT_UInt opc; /* function #, or instruction code */
+ FT_Bool active; /* is it active? */
+ FT_Bool inline_delta; /* is function that defines inline delta? */
+ FT_ULong sph_fdef_flags; /* flags to identify special functions */
} TT_DefRecord, *TT_DefArray;
@@ -189,7 +192,7 @@ FT_BEGIN_HEADER
{
FT_Fixed xx, xy; /* transformation matrix coefficients */
FT_Fixed yx, yy;
- FT_F26Dot6 ox, oy; /* offsets */
+ FT_F26Dot6 ox, oy; /* offsets */
} TT_Transform;
@@ -330,8 +333,10 @@ FT_BEGIN_HEADER
FT_Bool debug;
TT_ExecContext context;
- FT_Bool bytecode_ready;
- FT_Bool cvt_ready;
+ /* if negative, `fpgm' (resp. `prep'), wasn't executed yet; */
+ /* otherwise it is the returned error code */
+ FT_Error bytecode_ready;
+ FT_Error cvt_ready;
#endif /* TT_USE_BYTECODE_INTERPRETER */
@@ -344,11 +349,12 @@ FT_BEGIN_HEADER
/* */
typedef struct TT_DriverRec_
{
- FT_DriverRec root;
+ FT_DriverRec root;
+
TT_ExecContext context; /* execution context */
TT_GlyphZoneRec zone; /* glyph loader points zone */
- void* extension_component;
+ FT_UInt interpreter_version;
} TT_DriverRec;
@@ -390,13 +396,16 @@ FT_BEGIN_HEADER
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_LOCAL( FT_Error )
- tt_size_run_fpgm( TT_Size size );
+ tt_size_run_fpgm( TT_Size size,
+ FT_Bool pedantic );
FT_LOCAL( FT_Error )
- tt_size_run_prep( TT_Size size );
+ tt_size_run_prep( TT_Size size,
+ FT_Bool pedantic );
FT_LOCAL( FT_Error )
- tt_size_ready_bytecode( TT_Size size );
+ tt_size_ready_bytecode( TT_Size size,
+ FT_Bool pedantic );
#endif /* TT_USE_BYTECODE_INTERPRETER */
@@ -423,6 +432,10 @@ FT_BEGIN_HEADER
tt_slot_init( FT_GlyphSlot slot );
+ /* auxiliary */
+#define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
+
+
FT_END_HEADER
#endif /* __TTOBJS_H__ */
diff --git a/src/3rdparty/freetype/src/truetype/ttpic.c b/src/3rdparty/freetype/src/truetype/ttpic.c
index 27ec4a1d5e..edefae72c5 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 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,56 +20,78 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "ttpic.h"
+#include "tterrors.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ttdriver.c */
- FT_Error FT_Create_Class_tt_services( FT_Library, FT_ServiceDescRec**);
- void FT_Destroy_Class_tt_services( FT_Library, FT_ServiceDescRec*);
- void FT_Init_Class_tt_service_gx_multi_masters(FT_Service_MultiMastersRec*);
- void FT_Init_Class_tt_service_truetype_glyf(FT_Service_TTGlyfRec*);
+ FT_Error
+ FT_Create_Class_tt_services( FT_Library library,
+ FT_ServiceDescRec** output_class );
+ void
+ FT_Destroy_Class_tt_services( FT_Library library,
+ FT_ServiceDescRec* clazz );
+ void
+ FT_Init_Class_tt_service_gx_multi_masters(
+ FT_Service_MultiMastersRec* sv_mm );
+ void
+ FT_Init_Class_tt_service_truetype_glyf(
+ FT_Service_TTGlyfRec* sv_ttglyf );
+
void
- tt_driver_class_pic_free( FT_Library library )
+ tt_driver_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->truetype )
{
- TTModulePIC* container = (TTModulePIC*)pic_container->truetype;
- if(container->tt_services)
- FT_Destroy_Class_tt_services(library, container->tt_services);
+ TTModulePIC* container = (TTModulePIC*)pic_container->truetype;
+
+
+ if ( container->tt_services )
+ FT_Destroy_Class_tt_services( library, container->tt_services );
container->tt_services = NULL;
FT_FREE( container );
pic_container->truetype = NULL;
}
}
+
FT_Error
- tt_driver_class_pic_init( FT_Library library )
+ tt_driver_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- TTModulePIC* container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ TTModulePIC* container = NULL;
+ FT_Memory memory = library->memory;
+
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->truetype = container;
- /* initialize pointer table - this is how the module usually expects this data */
- error = FT_Create_Class_tt_services(library, &container->tt_services);
- if(error)
+ /* initialize pointer table - this is how the module usually */
+ /* expects this data */
+ error = FT_Create_Class_tt_services( library,
+ &container->tt_services );
+ if ( error )
goto Exit;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_Init_Class_tt_service_gx_multi_masters(&container->tt_service_gx_multi_masters);
+ FT_Init_Class_tt_service_gx_multi_masters(
+ &container->tt_service_gx_multi_masters );
#endif
- FT_Init_Class_tt_service_truetype_glyf(&container->tt_service_truetype_glyf);
-Exit:
- if(error)
- tt_driver_class_pic_free(library);
+ FT_Init_Class_tt_service_truetype_glyf(
+ &container->tt_service_truetype_glyf );
+
+ Exit:
+ if ( error )
+ tt_driver_class_pic_free( library );
return error;
}
diff --git a/src/3rdparty/freetype/src/truetype/ttpic.h b/src/3rdparty/freetype/src/truetype/ttpic.h
index 84de0fee9e..cfb4ee6281 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 by */
+/* Copyright 2009, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,38 +19,60 @@
#ifndef __TTPIC_H__
#define __TTPIC_H__
-
+
FT_BEGIN_HEADER
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_TT_SERVICES_GET tt_services
-#define FT_TT_SERVICE_GX_MULTI_MASTERS_GET tt_service_gx_multi_masters
-#define FT_TT_SERVICE_TRUETYPE_GLYF_GET tt_service_truetype_glyf
+
+#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
#else /* FT_CONFIG_OPTION_PIC */
#include FT_MULTIPLE_MASTERS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
#include FT_SERVICE_TRUETYPE_GLYF_H
+#include FT_SERVICE_PROPERTIES_H
+
- typedef struct TTModulePIC_
+ 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;
#endif
- FT_Service_TTGlyfRec tt_service_truetype_glyf;
+ FT_Service_TTGlyfRec tt_service_truetype_glyf;
+ FT_Service_PropertiesRec tt_service_properties;
+
} TTModulePIC;
-#define GET_PIC(lib) ((TTModulePIC*)((lib)->pic_container.truetype))
-#define FT_TT_SERVICES_GET (GET_PIC(library)->tt_services)
-#define FT_TT_SERVICE_GX_MULTI_MASTERS_GET (GET_PIC(library)->tt_service_gx_multi_masters)
-#define FT_TT_SERVICE_TRUETYPE_GLYF_GET (GET_PIC(library)->tt_service_truetype_glyf)
+
+#define GET_PIC( lib ) \
+ ( (TTModulePIC*)((lib)->pic_container.truetype) )
+#define TT_SERVICES_GET \
+ ( GET_PIC( library )->tt_services )
+#define TT_SERVICE_GX_MULTI_MASTERS_GET \
+ ( GET_PIC( library )->tt_service_gx_multi_masters )
+#define TT_SERVICE_TRUETYPE_GLYF_GET \
+ ( GET_PIC( library )->tt_service_truetype_glyf )
+#define TT_SERVICE_PROPERTIES_GET \
+ ( GET_PIC( library )->tt_service_properties )
+
+
+ /* see ttpic.c for the implementation */
+ void
+ tt_driver_class_pic_free( FT_Library library );
+
+ FT_Error
+ tt_driver_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
/* */
+
FT_END_HEADER
#endif /* __TTPIC_H__ */
diff --git a/src/3rdparty/freetype/src/truetype/ttpload.c b/src/3rdparty/freetype/src/truetype/ttpload.c
index ecdd7376e1..9991925425 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-2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2002, 2004-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -72,7 +72,7 @@
/* it is possible that a font doesn't have a glyf table at all */
/* or its size is zero */
- if ( error == TT_Err_Table_Missing )
+ if ( FT_ERR_EQ( error, Table_Missing ) )
face->glyf_len = 0;
else if ( error )
goto Exit;
@@ -81,7 +81,7 @@
error = face->goto_table( face, TTAG_loca, stream, &table_len );
if ( error )
{
- error = TT_Err_Locations_Missing;
+ error = FT_THROW( Locations_Missing );
goto Exit;
}
@@ -92,7 +92,7 @@
if ( table_len >= 0x40000L )
{
FT_TRACE2(( "table too large\n" ));
- error = TT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
face->num_locations = table_len >> shift;
@@ -104,21 +104,22 @@
if ( table_len >= 0x20000L )
{
FT_TRACE2(( "table too large\n" ));
- error = TT_Err_Invalid_Table;
+ error = FT_THROW( Invalid_Table );
goto Exit;
}
face->num_locations = table_len >> shift;
}
- if ( face->num_locations != (FT_ULong)face->root.num_glyphs )
+ if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 )
{
FT_TRACE2(( "glyph count mismatch! loca: %d, maxp: %d\n",
- face->num_locations, face->root.num_glyphs ));
+ face->num_locations - 1, face->root.num_glyphs ));
/* we only handle the case where `maxp' gives a larger value */
- if ( face->num_locations < (FT_ULong)face->root.num_glyphs )
+ if ( face->num_locations <= (FT_ULong)face->root.num_glyphs )
{
- FT_Long new_loca_len = (FT_Long)face->root.num_glyphs << shift;
+ FT_Long new_loca_len =
+ ( (FT_Long)( face->root.num_glyphs ) + 1 ) << shift;
TT_Table entry = face->dir_tables;
TT_Table limit = entry + face->num_tables;
@@ -137,9 +138,15 @@
dist = diff;
}
+ if ( entry == limit )
+ {
+ /* `loca' is the last table */
+ dist = stream->size - pos;
+ }
+
if ( new_loca_len <= dist )
{
- face->num_locations = face->root.num_glyphs;
+ face->num_locations = face->root.num_glyphs + 1;
table_len = new_loca_len;
FT_TRACE2(( "adjusting num_locations to %d\n",
@@ -203,6 +210,26 @@
}
}
+ /* 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",
+ pos1, gindex, face->glyf_len ));
+ *asize = 0;
+ return 0;
+ }
+
+ 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;
+ }
+
/* The `loca' table must be ordered; it refers to the length of */
/* an entry as the difference between the current and the next */
/* position. However, there do exist (malformed) fonts which */
@@ -269,7 +296,7 @@
face->cvt_size = 0;
face->cvt = NULL;
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
goto Exit;
}
@@ -287,7 +314,7 @@
FT_Short* limit = cur + face->cvt_size;
- for ( ; cur < limit; cur++ )
+ for ( ; cur < limit; cur++ )
*cur = FT_GET_SHORT();
}
@@ -307,7 +334,7 @@
FT_UNUSED( face );
FT_UNUSED( stream );
- return TT_Err_Ok;
+ return FT_Err_Ok;
#endif
}
@@ -348,7 +375,7 @@
{
face->font_program = NULL;
face->font_program_size = 0;
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
FT_TRACE2(( "is missing\n" ));
}
@@ -369,7 +396,7 @@
FT_UNUSED( face );
FT_UNUSED( stream );
- return TT_Err_Ok;
+ return FT_Err_Ok;
#endif
}
@@ -409,7 +436,7 @@
{
face->cvt_program = NULL;
face->cvt_program_size = 0;
- error = TT_Err_Ok;
+ error = FT_Err_Ok;
FT_TRACE2(( "is missing\n" ));
}
@@ -430,7 +457,7 @@
FT_UNUSED( face );
FT_UNUSED( stream );
- return TT_Err_Ok;
+ return FT_Err_Ok;
#endif
}
@@ -468,7 +495,7 @@
/* this table is optional */
error = face->goto_table( face, TTAG_hdmx, stream, &table_size );
if ( error || table_size < 8 )
- return TT_Err_Ok;
+ return FT_Err_Ok;
if ( FT_FRAME_EXTRACT( table_size, face->hdmx_table ) )
goto Exit;
@@ -481,9 +508,9 @@
record_size = FT_NEXT_ULONG( p );
/* The maximum number of bytes in an hdmx device record is the */
- /* maximum number of glyphs + 2; this is 0xFFFF + 2; this is */
- /* the reason why `record_size' is a long (which we read as */
- /* unsigned long for convenience). In practice, two bytes */
+ /* maximum number of glyphs + 2; this is 0xFFFF + 2, thus */
+ /* explaining why `record_size' is a long (which we read as */
+ /* unsigned long for convenience). In practice, two bytes are */
/* sufficient to hold the size value. */
/* */
/* There are at least two fonts, HANNOM-A and HANNOM-B version */
@@ -495,10 +522,12 @@
record_size &= 0xFFFFU;
/* The limit for `num_records' is a heuristic value. */
-
- if ( version != 0 || num_records > 255 || record_size > 0x10001L )
+ if ( version != 0 ||
+ num_records > 255 ||
+ record_size > 0x10001L ||
+ record_size < 4 )
{
- error = TT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -532,10 +561,10 @@
tt_face_free_hdmx( TT_Face face )
{
FT_Stream stream = face->root.stream;
- FT_Memory memory = stream ? stream->memory : NULL;
+ FT_Memory memory = stream->memory;
+
- if ( face->hdmx_record_sizes )
- FT_FREE( face->hdmx_record_sizes );
+ FT_FREE( face->hdmx_record_sizes );
FT_FRAME_RELEASE( face->hdmx_table );
}
diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.c b/src/3rdparty/freetype/src/truetype/ttsubpix.c
new file mode 100644
index 0000000000..ca604518cf
--- /dev/null
+++ b/src/3rdparty/freetype/src/truetype/ttsubpix.c
@@ -0,0 +1,1011 @@
+/***************************************************************************/
+/* */
+/* ttsubpix.c */
+/* */
+/* TrueType Subpixel Hinting. */
+/* */
+/* Copyright 2010-2013 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_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 "ttsubpix.h"
+
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ /*************************************************************************/
+ /* */
+ /* These rules affect how the TT Interpreter does hinting, with the */
+ /* goal of doing subpixel hinting by (in general) ignoring x moves. */
+ /* Some of these rules are fixes that go above and beyond the */
+ /* stated techniques in the MS whitepaper on Cleartype, due to */
+ /* artifacts in many glyphs. So, these rules make some glyphs render */
+ /* better than they do in the MS rasterizer. */
+ /* */
+ /* "" string or 0 int/char indicates to apply to all glyphs. */
+ /* "-" used as dummy placeholders, but any non-matching string works. */
+ /* */
+ /* Some of this could arguably be implemented in fontconfig, however: */
+ /* */
+ /* - Fontconfig can't set things on a glyph-by-glyph basis. */
+ /* - The tweaks that happen here are very low-level, from an average */
+ /* user's point of view and are best implemented in the hinter. */
+ /* */
+ /* The goal is to make the subpixel hinting techniques as generalized */
+ /* as possible across all fonts to prevent the need for extra rules such */
+ /* as these. */
+ /* */
+ /* The rule structure is designed so that entirely new rules can easily */
+ /* be added when a new compatibility feature is discovered. */
+ /* */
+ /* The rule structures could also use some enhancement to handle ranges. */
+ /* */
+ /* ****************** WORK IN PROGRESS ******************* */
+ /* */
+
+ /* These are `classes' of fonts that can be grouped together and used in */
+ /* rules below. A blank entry "" is required at the end of these! */
+#define FAMILY_CLASS_RULES_SIZE 7
+
+ static const SPH_Font_Class FAMILY_CLASS_Rules
+ [FAMILY_CLASS_RULES_SIZE] =
+ {
+ { "MS Legacy Fonts",
+ { "Aharoni",
+ "Andale Mono",
+ "Andalus",
+ "Angsana New",
+ "AngsanaUPC",
+ "Arabic Transparent",
+ "Arial Black",
+ "Arial Narrow",
+ "Arial Unicode MS",
+ "Arial",
+ "Batang",
+ "Browallia New",
+ "BrowalliaUPC",
+ "Comic Sans MS",
+ "Cordia New",
+ "CordiaUPC",
+ "Courier New",
+ "DFKai-SB",
+ "David Transparent",
+ "David",
+ "DilleniaUPC",
+ "Estrangelo Edessa",
+ "EucrosiaUPC",
+ "FangSong_GB2312",
+ "Fixed Miriam Transparent",
+ "FrankRuehl",
+ "Franklin Gothic Medium",
+ "FreesiaUPC",
+ "Garamond",
+ "Gautami",
+ "Georgia",
+ "Gulim",
+ "Impact",
+ "IrisUPC",
+ "JasmineUPC",
+ "KaiTi_GB2312",
+ "KodchiangUPC",
+ "Latha",
+ "Levenim MT",
+ "LilyUPC",
+ "Lucida Console",
+ "Lucida Sans Unicode",
+ "MS Gothic",
+ "MS Mincho",
+ "MV Boli",
+ "Mangal",
+ "Marlett",
+ "Microsoft Sans Serif",
+ "Mingliu",
+ "Miriam Fixed",
+ "Miriam Transparent",
+ "Miriam",
+ "Narkisim",
+ "Palatino Linotype",
+ "Raavi",
+ "Rod Transparent",
+ "Rod",
+ "Shruti",
+ "SimHei",
+ "Simplified Arabic Fixed",
+ "Simplified Arabic",
+ "Simsun",
+ "Sylfaen",
+ "Symbol",
+ "Tahoma",
+ "Times New Roman",
+ "Traditional Arabic",
+ "Trebuchet MS",
+ "Tunga",
+ "Verdana",
+ "Webdings",
+ "Wingdings",
+ "",
+ },
+ },
+ { "Core MS Legacy Fonts",
+ { "Arial Black",
+ "Arial Narrow",
+ "Arial Unicode MS",
+ "Arial",
+ "Comic Sans MS",
+ "Courier New",
+ "Garamond",
+ "Georgia",
+ "Impact",
+ "Lucida Console",
+ "Lucida Sans Unicode",
+ "Microsoft Sans Serif",
+ "Palatino Linotype",
+ "Tahoma",
+ "Times New Roman",
+ "Trebuchet MS",
+ "Verdana",
+ "",
+ },
+ },
+ { "Apple Legacy Fonts",
+ { "Geneva",
+ "Times",
+ "Monaco",
+ "Century",
+ "Chalkboard",
+ "Lobster",
+ "Century Gothic",
+ "Optima",
+ "Lucida Grande",
+ "Gill Sans",
+ "Baskerville",
+ "Helvetica",
+ "Helvetica Neue",
+ "",
+ },
+ },
+ { "Legacy Sans Fonts",
+ { "Andale Mono",
+ "Arial Unicode MS",
+ "Arial",
+ "Century Gothic",
+ "Comic Sans MS",
+ "Franklin Gothic Medium",
+ "Geneva",
+ "Lucida Console",
+ "Lucida Grande",
+ "Lucida Sans Unicode",
+ "Lucida Sans Typewriter",
+ "Microsoft Sans Serif",
+ "Monaco",
+ "Tahoma",
+ "Trebuchet MS",
+ "Verdana",
+ "",
+ },
+ },
+
+ { "Misc Legacy Fonts",
+ { "Dark Courier", "", }, },
+ { "Verdana Clones",
+ { "DejaVu Sans",
+ "Bitstream Vera Sans", "", }, },
+ { "Verdana and Clones",
+ { "DejaVu Sans",
+ "Bitstream Vera Sans",
+ "Verdana", "", }, },
+ };
+
+
+ /* Define this to force natural (i.e. not bitmap-compatible) widths. */
+ /* The default leans strongly towards natural widths except for a few */
+ /* legacy fonts where a selective combination produces nicer results. */
+/* #define FORCE_NATURAL_WIDTHS */
+
+
+ /* Define `classes' of styles that can be grouped together and used in */
+ /* rules below. A blank entry "" is required at the end of these! */
+#define STYLE_CLASS_RULES_SIZE 5
+
+ const SPH_Font_Class STYLE_CLASS_Rules
+ [STYLE_CLASS_RULES_SIZE] =
+ {
+ { "Regular Class",
+ { "Regular",
+ "Book",
+ "Medium",
+ "Roman",
+ "Normal",
+ "",
+ },
+ },
+ { "Regular/Italic Class",
+ { "Regular",
+ "Book",
+ "Medium",
+ "Italic",
+ "Oblique",
+ "Roman",
+ "Normal",
+ "",
+ },
+ },
+ { "Bold/BoldItalic Class",
+ { "Bold",
+ "Bold Italic",
+ "Black",
+ "",
+ },
+ },
+ { "Bold/Italic/BoldItalic Class",
+ { "Bold",
+ "Bold Italic",
+ "Black",
+ "Italic",
+ "Oblique",
+ "",
+ },
+ },
+ { "Regular/Bold Class",
+ { "Regular",
+ "Book",
+ "Medium",
+ "Normal",
+ "Roman",
+ "Bold",
+ "Black",
+ "",
+ },
+ },
+ };
+
+
+ /* Force special legacy fixes for fonts. */
+#define COMPATIBILITY_MODE_RULES_SIZE 1
+
+ const SPH_TweakRule COMPATIBILITY_MODE_Rules
+ [COMPATIBILITY_MODE_RULES_SIZE] =
+ {
+ { "Verdana Clones", 0, "", 0 },
+ };
+
+
+ /* Don't do subpixel (ignore_x_mode) hinting; do normal hinting. */
+#define PIXEL_HINTING_RULES_SIZE 2
+
+ const SPH_TweakRule PIXEL_HINTING_Rules
+ [PIXEL_HINTING_RULES_SIZE] =
+ {
+ /* these characters are almost always safe */
+ { "Courier New", 12, "Italic", 'z' },
+ { "Courier New", 11, "Italic", 'z' },
+ };
+
+
+ /* Subpixel hinting ignores SHPIX rules on X. Force SHPIX for these. */
+#define DO_SHPIX_RULES_SIZE 1
+
+ const SPH_TweakRule DO_SHPIX_Rules
+ [DO_SHPIX_RULES_SIZE] =
+ {
+ { "-", 0, "", 0 },
+ };
+
+
+ /* Skip Y moves that start with a point that is not on a Y pixel */
+ /* boundary and don't move that point to a Y pixel boundary. */
+#define SKIP_NONPIXEL_Y_MOVES_RULES_SIZE 4
+
+ const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_Rules
+ [SKIP_NONPIXEL_Y_MOVES_RULES_SIZE] =
+ {
+ /* fix vwxyz thinness*/
+ { "Consolas", 0, "", 0 },
+ /* Fix thin middle stems */
+ { "Core MS Legacy Fonts", 0, "Regular", 0 },
+ /* Cyrillic small letter I */
+ { "Legacy Sans Fonts", 0, "", 0 },
+ /* Fix artifacts with some Regular & Bold */
+ { "Verdana Clones", 0, "", 0 },
+ };
+
+
+#define SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
+
+ const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions
+ [SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
+ {
+ /* Fixes < and > */
+ { "Courier New", 0, "Regular", 0 },
+ };
+
+
+ /* Skip Y moves that start with a point that is not on a Y pixel */
+ /* boundary and don't move that point to a Y pixel boundary. */
+#define SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE 2
+
+ const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_DELTAP_Rules
+ [SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE] =
+ {
+ /* Maintain thickness of diagonal in 'N' */
+ { "Times New Roman", 0, "Regular/Bold Class", 'N' },
+ { "Georgia", 0, "Regular/Bold Class", 'N' },
+ };
+
+
+ /* Skip Y moves that move a point off a Y pixel boundary. */
+#define SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE 1
+
+ const SPH_TweakRule SKIP_OFFPIXEL_Y_MOVES_Rules
+ [SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE] =
+ {
+ { "-", 0, "", 0 },
+ };
+
+
+#define SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
+
+ const SPH_TweakRule SKIP_OFFPIXEL_Y_MOVES_Rules_Exceptions
+ [SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
+ {
+ { "-", 0, "", 0 },
+ };
+
+
+ /* Round moves that don't move a point to a Y pixel boundary. */
+#define ROUND_NONPIXEL_Y_MOVES_RULES_SIZE 2
+
+ const SPH_TweakRule ROUND_NONPIXEL_Y_MOVES_Rules
+ [ROUND_NONPIXEL_Y_MOVES_RULES_SIZE] =
+ {
+ /* Droid font instructions don't snap Y to pixels */
+ { "Droid Sans", 0, "Regular/Italic Class", 0 },
+ { "Droid Sans Mono", 0, "", 0 },
+ };
+
+
+#define ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
+
+ const SPH_TweakRule ROUND_NONPIXEL_Y_MOVES_Rules_Exceptions
+ [ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
+ {
+ { "-", 0, "", 0 },
+ };
+
+
+ /* Allow a Direct_Move along X freedom vector if matched. */
+#define ALLOW_X_DMOVE_RULES_SIZE 1
+
+ const SPH_TweakRule ALLOW_X_DMOVE_Rules
+ [ALLOW_X_DMOVE_RULES_SIZE] =
+ {
+ /* Fixes vanishing diagonal in 4 */
+ { "Verdana", 0, "Regular", '4' },
+ };
+
+
+ /* Return MS rasterizer version 35 if matched. */
+#define RASTERIZER_35_RULES_SIZE 8
+
+ const SPH_TweakRule RASTERIZER_35_Rules
+ [RASTERIZER_35_RULES_SIZE] =
+ {
+ /* This seems to be the only way to make these look good */
+ { "Times New Roman", 0, "Regular", 'i' },
+ { "Times New Roman", 0, "Regular", 'j' },
+ { "Times New Roman", 0, "Regular", 'm' },
+ { "Times New Roman", 0, "Regular", 'r' },
+ { "Times New Roman", 0, "Regular", 'a' },
+ { "Times New Roman", 0, "Regular", 'n' },
+ { "Times New Roman", 0, "Regular", 'p' },
+ { "Times", 0, "", 0 },
+ };
+
+
+ /* Don't round to the subpixel grid. Round to pixel grid. */
+#define NORMAL_ROUND_RULES_SIZE 1
+
+ const SPH_TweakRule NORMAL_ROUND_Rules
+ [NORMAL_ROUND_RULES_SIZE] =
+ {
+ /* Fix serif thickness for certain ppems */
+ /* Can probably be generalized somehow */
+ { "Courier New", 0, "", 0 },
+ };
+
+
+ /* Skip IUP instructions if matched. */
+#define SKIP_IUP_RULES_SIZE 1
+
+ const SPH_TweakRule SKIP_IUP_Rules
+ [SKIP_IUP_RULES_SIZE] =
+ {
+ { "Arial", 13, "Regular", 'a' },
+ };
+
+
+ /* Skip MIAP Twilight hack if matched. */
+#define MIAP_HACK_RULES_SIZE 1
+
+ const SPH_TweakRule MIAP_HACK_Rules
+ [MIAP_HACK_RULES_SIZE] =
+ {
+ { "Geneva", 12, "", 0 },
+ };
+
+
+ /* Skip DELTAP instructions if matched. */
+#define ALWAYS_SKIP_DELTAP_RULES_SIZE 23
+
+ const SPH_TweakRule ALWAYS_SKIP_DELTAP_Rules
+ [ALWAYS_SKIP_DELTAP_RULES_SIZE] =
+ {
+ { "Georgia", 0, "Regular", 'k' },
+ /* fix various problems with e in different versions */
+ { "Trebuchet MS", 14, "Regular", 'e' },
+ { "Trebuchet MS", 13, "Regular", 'e' },
+ { "Trebuchet MS", 15, "Regular", 'e' },
+ { "Trebuchet MS", 0, "Italic", 'v' },
+ { "Trebuchet MS", 0, "Italic", 'w' },
+ { "Trebuchet MS", 0, "Regular", 'Y' },
+ { "Arial", 11, "Regular", 's' },
+ /* prevent problems with '3' and others */
+ { "Verdana", 10, "Regular", 0 },
+ { "Verdana", 9, "Regular", 0 },
+ /* Cyrillic small letter short I */
+ { "Legacy Sans Fonts", 0, "", 0x438 },
+ { "Legacy Sans Fonts", 0, "", 0x439 },
+ { "Arial", 10, "Regular", '6' },
+ { "Arial", 0, "Bold/BoldItalic Class", 'a' },
+ /* Make horizontal stems consistent with the rest */
+ { "Arial", 24, "Bold", 'a' },
+ { "Arial", 25, "Bold", 'a' },
+ { "Arial", 24, "Bold", 's' },
+ { "Arial", 25, "Bold", 's' },
+ { "Arial", 34, "Bold", 's' },
+ { "Arial", 35, "Bold", 's' },
+ { "Arial", 36, "Bold", 's' },
+ { "Arial", 25, "Regular", 's' },
+ { "Arial", 26, "Regular", 's' },
+ };
+
+
+ /* Always do DELTAP instructions if matched. */
+#define ALWAYS_DO_DELTAP_RULES_SIZE 1
+
+ const SPH_TweakRule ALWAYS_DO_DELTAP_Rules
+ [ALWAYS_DO_DELTAP_RULES_SIZE] =
+ {
+ { "-", 0, "", 0 },
+ };
+
+
+ /* Don't allow ALIGNRP after IUP. */
+#define NO_ALIGNRP_AFTER_IUP_RULES_SIZE 1
+
+ static const SPH_TweakRule NO_ALIGNRP_AFTER_IUP_Rules
+ [NO_ALIGNRP_AFTER_IUP_RULES_SIZE] =
+ {
+ /* Prevent creation of dents in outline */
+ { "-", 0, "", 0 },
+ };
+
+
+ /* Don't allow DELTAP after IUP. */
+#define NO_DELTAP_AFTER_IUP_RULES_SIZE 1
+
+ static const SPH_TweakRule NO_DELTAP_AFTER_IUP_Rules
+ [NO_DELTAP_AFTER_IUP_RULES_SIZE] =
+ {
+ { "-", 0, "", 0 },
+ };
+
+
+ /* Don't allow CALL after IUP. */
+#define NO_CALL_AFTER_IUP_RULES_SIZE 1
+
+ static const SPH_TweakRule NO_CALL_AFTER_IUP_Rules
+ [NO_CALL_AFTER_IUP_RULES_SIZE] =
+ {
+ /* Prevent creation of dents in outline */
+ { "-", 0, "", 0 },
+ };
+
+
+ /* De-embolden these glyphs slightly. */
+#define DEEMBOLDEN_RULES_SIZE 9
+
+ static const SPH_TweakRule DEEMBOLDEN_Rules
+ [DEEMBOLDEN_RULES_SIZE] =
+ {
+ { "Courier New", 0, "Bold", 'A' },
+ { "Courier New", 0, "Bold", 'W' },
+ { "Courier New", 0, "Bold", 'w' },
+ { "Courier New", 0, "Bold", 'M' },
+ { "Courier New", 0, "Bold", 'X' },
+ { "Courier New", 0, "Bold", 'K' },
+ { "Courier New", 0, "Bold", 'x' },
+ { "Courier New", 0, "Bold", 'z' },
+ { "Courier New", 0, "Bold", 'v' },
+ };
+
+
+ /* Embolden these glyphs slightly. */
+#define EMBOLDEN_RULES_SIZE 2
+
+ static const SPH_TweakRule EMBOLDEN_Rules
+ [EMBOLDEN_RULES_SIZE] =
+ {
+ { "Courier New", 0, "Regular", 0 },
+ { "Courier New", 0, "Italic", 0 },
+ };
+
+
+ /* This is a CVT hack that makes thick horizontal stems on 2, 5, 7 */
+ /* similar to Windows XP. */
+#define TIMES_NEW_ROMAN_HACK_RULES_SIZE 12
+
+ static const SPH_TweakRule TIMES_NEW_ROMAN_HACK_Rules
+ [TIMES_NEW_ROMAN_HACK_RULES_SIZE] =
+ {
+ { "Times New Roman", 16, "Italic", '2' },
+ { "Times New Roman", 16, "Italic", '5' },
+ { "Times New Roman", 16, "Italic", '7' },
+ { "Times New Roman", 16, "Regular", '2' },
+ { "Times New Roman", 16, "Regular", '5' },
+ { "Times New Roman", 16, "Regular", '7' },
+ { "Times New Roman", 17, "Italic", '2' },
+ { "Times New Roman", 17, "Italic", '5' },
+ { "Times New Roman", 17, "Italic", '7' },
+ { "Times New Roman", 17, "Regular", '2' },
+ { "Times New Roman", 17, "Regular", '5' },
+ { "Times New Roman", 17, "Regular", '7' },
+ };
+
+
+ /* This fudges distance on 2 to get rid of the vanishing stem issue. */
+ /* A real solution to this is certainly welcome. */
+#define COURIER_NEW_2_HACK_RULES_SIZE 15
+
+ static const SPH_TweakRule COURIER_NEW_2_HACK_Rules
+ [COURIER_NEW_2_HACK_RULES_SIZE] =
+ {
+ { "Courier New", 10, "Regular", '2' },
+ { "Courier New", 11, "Regular", '2' },
+ { "Courier New", 12, "Regular", '2' },
+ { "Courier New", 13, "Regular", '2' },
+ { "Courier New", 14, "Regular", '2' },
+ { "Courier New", 15, "Regular", '2' },
+ { "Courier New", 16, "Regular", '2' },
+ { "Courier New", 17, "Regular", '2' },
+ { "Courier New", 18, "Regular", '2' },
+ { "Courier New", 19, "Regular", '2' },
+ { "Courier New", 20, "Regular", '2' },
+ { "Courier New", 21, "Regular", '2' },
+ { "Courier New", 22, "Regular", '2' },
+ { "Courier New", 23, "Regular", '2' },
+ { "Courier New", 24, "Regular", '2' },
+ };
+
+
+#ifndef FORCE_NATURAL_WIDTHS
+
+ /* Use compatible widths with these glyphs. Compatible widths is always */
+ /* on when doing B/W TrueType instructing, but is used selectively here, */
+ /* typically on glyphs with 3 or more vertical stems. */
+#define COMPATIBLE_WIDTHS_RULES_SIZE 38
+
+ static const SPH_TweakRule COMPATIBLE_WIDTHS_Rules
+ [COMPATIBLE_WIDTHS_RULES_SIZE] =
+ {
+ { "Arial Unicode MS", 12, "Regular Class", 'm' },
+ { "Arial Unicode MS", 14, "Regular Class", 'm' },
+ /* Cyrillic small letter sha */
+ { "Arial", 10, "Regular Class", 0x448 },
+ { "Arial", 11, "Regular Class", 'm' },
+ { "Arial", 12, "Regular Class", 'm' },
+ /* Cyrillic small letter sha */
+ { "Arial", 12, "Regular Class", 0x448 },
+ { "Arial", 13, "Regular Class", 0x448 },
+ { "Arial", 14, "Regular Class", 'm' },
+ /* Cyrillic small letter sha */
+ { "Arial", 14, "Regular Class", 0x448 },
+ { "Arial", 15, "Regular Class", 0x448 },
+ { "Arial", 17, "Regular Class", 'm' },
+ { "DejaVu Sans", 15, "Regular Class", 0 },
+ { "Microsoft Sans Serif", 11, "Regular Class", 0 },
+ { "Microsoft Sans Serif", 12, "Regular Class", 0 },
+ { "Segoe UI", 11, "Regular Class", 0 },
+ { "Monaco", 0, "Regular Class", 0 },
+ { "Segoe UI", 12, "Regular Class", 'm' },
+ { "Segoe UI", 14, "Regular Class", 'm' },
+ { "Tahoma", 11, "Regular Class", 0 },
+ { "Times New Roman", 16, "Regular Class", 'c' },
+ { "Times New Roman", 16, "Regular Class", 'm' },
+ { "Times New Roman", 16, "Regular Class", 'o' },
+ { "Times New Roman", 16, "Regular Class", 'w' },
+ { "Trebuchet MS", 11, "Regular Class", 0 },
+ { "Trebuchet MS", 12, "Regular Class", 0 },
+ { "Trebuchet MS", 14, "Regular Class", 0 },
+ { "Trebuchet MS", 15, "Regular Class", 0 },
+ { "Ubuntu", 12, "Regular Class", 'm' },
+ /* Cyrillic small letter sha */
+ { "Verdana", 10, "Regular Class", 0x448 },
+ { "Verdana", 11, "Regular Class", 0x448 },
+ { "Verdana and Clones", 12, "Regular Class", 'i' },
+ { "Verdana and Clones", 12, "Regular Class", 'j' },
+ { "Verdana and Clones", 12, "Regular Class", 'l' },
+ { "Verdana and Clones", 12, "Regular Class", 'm' },
+ { "Verdana and Clones", 13, "Regular Class", 'i' },
+ { "Verdana and Clones", 13, "Regular Class", 'j' },
+ { "Verdana and Clones", 13, "Regular Class", 'l' },
+ { "Verdana and Clones", 14, "Regular Class", 'm' },
+ };
+
+
+ /* Scaling slightly in the x-direction prior to hinting results in */
+ /* more visually pleasing glyphs in certain cases. */
+ /* This sometimes needs to be coordinated with compatible width rules. */
+ /* A value of 1000 corresponds to a scaled value of 1.0. */
+
+#define X_SCALING_RULES_SIZE 50
+
+ static const SPH_ScaleRule X_SCALING_Rules[X_SCALING_RULES_SIZE] =
+ {
+ { "DejaVu Sans", 12, "Regular Class", 'm', 950 },
+ { "Verdana and Clones", 12, "Regular Class", 'a', 1100 },
+ { "Verdana and Clones", 13, "Regular Class", 'a', 1050 },
+ { "Arial", 11, "Regular Class", 'm', 975 },
+ { "Arial", 12, "Regular Class", 'm', 1050 },
+ /* Cyrillic small letter el */
+ { "Arial", 13, "Regular Class", 0x43B, 950 },
+ { "Arial", 13, "Regular Class", 'o', 950 },
+ { "Arial", 13, "Regular Class", 'e', 950 },
+ { "Arial", 14, "Regular Class", 'm', 950 },
+ /* Cyrillic small letter el */
+ { "Arial", 15, "Regular Class", 0x43B, 925 },
+ { "Bitstream Vera Sans", 10, "Regular/Italic Class", 0, 1100 },
+ { "Bitstream Vera Sans", 12, "Regular/Italic Class", 0, 1050 },
+ { "Bitstream Vera Sans", 16, "Regular Class", 0, 1050 },
+ { "Bitstream Vera Sans", 9, "Regular/Italic Class", 0, 1050 },
+ { "DejaVu Sans", 12, "Regular Class", 'l', 975 },
+ { "DejaVu Sans", 12, "Regular Class", 'i', 975 },
+ { "DejaVu Sans", 12, "Regular Class", 'j', 975 },
+ { "DejaVu Sans", 13, "Regular Class", 'l', 950 },
+ { "DejaVu Sans", 13, "Regular Class", 'i', 950 },
+ { "DejaVu Sans", 13, "Regular Class", 'j', 950 },
+ { "DejaVu Sans", 10, "Regular/Italic Class", 0, 1100 },
+ { "DejaVu Sans", 12, "Regular/Italic Class", 0, 1050 },
+ { "Georgia", 10, "", 0, 1050 },
+ { "Georgia", 11, "", 0, 1100 },
+ { "Georgia", 12, "", 0, 1025 },
+ { "Georgia", 13, "", 0, 1050 },
+ { "Georgia", 16, "", 0, 1050 },
+ { "Georgia", 17, "", 0, 1030 },
+ { "Liberation Sans", 12, "Regular Class", 'm', 1100 },
+ { "Lucida Grande", 11, "Regular Class", 'm', 1100 },
+ { "Microsoft Sans Serif", 11, "Regular Class", 'm', 950 },
+ { "Microsoft Sans Serif", 12, "Regular Class", 'm', 1050 },
+ { "Segoe UI", 12, "Regular Class", 'H', 1050 },
+ { "Segoe UI", 12, "Regular Class", 'm', 1050 },
+ { "Segoe UI", 14, "Regular Class", 'm', 1050 },
+ { "Tahoma", 11, "Regular Class", 'i', 975 },
+ { "Tahoma", 11, "Regular Class", 'l', 975 },
+ { "Tahoma", 11, "Regular Class", 'j', 900 },
+ { "Tahoma", 11, "Regular Class", 'm', 918 },
+ { "Verdana", 10, "Regular/Italic Class", 0, 1100 },
+ { "Verdana", 12, "Regular Class", 'm', 975 },
+ { "Verdana", 12, "Regular/Italic Class", 0, 1050 },
+ { "Verdana", 13, "Regular/Italic Class", 'i', 950 },
+ { "Verdana", 13, "Regular/Italic Class", 'j', 950 },
+ { "Verdana", 13, "Regular/Italic Class", 'l', 950 },
+ { "Verdana", 16, "Regular Class", 0, 1050 },
+ { "Verdana", 9, "Regular/Italic Class", 0, 1050 },
+ { "Times New Roman", 16, "Regular Class", 'm', 918 },
+ { "Trebuchet MS", 11, "Regular Class", 'm', 800 },
+ { "Trebuchet MS", 12, "Regular Class", 'm', 800 },
+ };
+
+#else
+
+#define COMPATIBLE_WIDTHS_RULES_SIZE 1
+
+ static const SPH_TweakRule COMPATIBLE_WIDTHS_Rules
+ [COMPATIBLE_WIDTHS_RULES_SIZE] =
+ {
+ { "-", 0, "", 0 },
+ };
+
+
+#define X_SCALING_RULES_SIZE 1
+
+ static const SPH_ScaleRule X_SCALING_Rules
+ [X_SCALING_RULES_SIZE] =
+ {
+ { "-", 0, "", 0, 1000 },
+ };
+
+#endif /* FORCE_NATURAL_WIDTHS */
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ is_member_of_family_class( const FT_String* detected_font_name,
+ const FT_String* rule_font_name )
+ {
+ FT_UInt i, j;
+
+
+ /* Does font name match rule family? */
+ if ( strcmp( detected_font_name, rule_font_name ) == 0 )
+ return TRUE;
+
+ /* Is font name a wildcard ""? */
+ if ( 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 )
+ {
+ for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
+ {
+ if ( strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 )
+ continue;
+ if ( strcmp( FAMILY_CLASS_Rules[i].member[j],
+ detected_font_name ) == 0 )
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+ }
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ is_member_of_style_class( const FT_String* detected_font_style,
+ const FT_String* rule_font_style )
+ {
+ FT_UInt i, j;
+
+
+ /* Does font style match rule style? */
+ if ( strcmp( detected_font_style, rule_font_style ) == 0 )
+ return TRUE;
+
+ /* Is font style a wildcard ""? */
+ if ( 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 )
+ {
+ for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
+ {
+ if ( strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 )
+ continue;
+ if ( strcmp( STYLE_CLASS_Rules[i].member[j],
+ detected_font_style ) == 0 )
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+ }
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ sph_test_tweak( TT_Face face,
+ const FT_String* family,
+ FT_UInt ppem,
+ const FT_String* style,
+ FT_UInt glyph_index,
+ const SPH_TweakRule* rule,
+ FT_UInt num_rules )
+ {
+ FT_UInt i;
+
+
+ /* rule checks may be able to be optimized further */
+ for ( i = 0; i < num_rules; i++ )
+ {
+ if ( family &&
+ ( is_member_of_family_class ( family, rule[i].family ) ) )
+ if ( rule[i].ppem == 0 ||
+ rule[i].ppem == ppem )
+ if ( style &&
+ is_member_of_style_class ( style, rule[i].style ) )
+ if ( rule[i].glyph == 0 ||
+ FT_Get_Char_Index( (FT_Face)face,
+ rule[i].glyph ) == glyph_index )
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+ static FT_UInt
+ scale_test_tweak( TT_Face face,
+ const FT_String* family,
+ FT_UInt ppem,
+ const FT_String* style,
+ FT_UInt glyph_index,
+ const SPH_ScaleRule* rule,
+ FT_UInt num_rules )
+ {
+ FT_UInt i;
+
+
+ /* rule checks may be able to be optimized further */
+ for ( i = 0; i < num_rules; i++ )
+ {
+ if ( family &&
+ ( is_member_of_family_class ( family, rule[i].family ) ) )
+ if ( rule[i].ppem == 0 ||
+ rule[i].ppem == ppem )
+ if ( style &&
+ is_member_of_style_class( style, rule[i].style ) )
+ if ( rule[i].glyph == 0 ||
+ FT_Get_Char_Index( (FT_Face)face,
+ rule[i].glyph ) == glyph_index )
+ return rule[i].scale;
+ }
+
+ return 1000;
+ }
+
+
+ FT_LOCAL_DEF( FT_UInt )
+ sph_test_tweak_x_scaling( TT_Face face,
+ const FT_String* family,
+ FT_UInt ppem,
+ const FT_String* style,
+ FT_UInt glyph_index )
+ {
+ return scale_test_tweak( face, family, ppem, style, glyph_index,
+ X_SCALING_Rules, X_SCALING_RULES_SIZE );
+ }
+
+
+#define TWEAK_RULES( x ) \
+ if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
+ x##_Rules, x##_RULES_SIZE ) ) \
+ loader->exec->sph_tweak_flags |= SPH_TWEAK_##x;
+
+#define TWEAK_RULES_EXCEPTIONS( x ) \
+ if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
+ x##_Rules_Exceptions, x##_RULES_EXCEPTIONS_SIZE ) ) \
+ loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x;
+
+
+ FT_LOCAL_DEF( void )
+ sph_set_tweaks( TT_Loader loader,
+ FT_UInt glyph_index )
+ {
+ TT_Face face = (TT_Face)loader->face;
+ FT_String* family = face->root.family_name;
+ int ppem = loader->size->metrics.x_ppem;
+ FT_String* style = face->root.style_name;
+
+
+ /* don't apply rules if style isn't set */
+ if ( !face->root.style_name )
+ return;
+
+#ifdef SPH_DEBUG_MORE_VERBOSE
+ printf( "%s,%d,%s,%c=%d ",
+ family, ppem, style, glyph_index, glyph_index );
+#endif
+
+ TWEAK_RULES( PIXEL_HINTING );
+
+ if ( loader->exec->sph_tweak_flags & SPH_TWEAK_PIXEL_HINTING )
+ {
+ loader->exec->ignore_x_mode = FALSE;
+ return;
+ }
+
+ TWEAK_RULES( ALLOW_X_DMOVE );
+ TWEAK_RULES( ALWAYS_DO_DELTAP );
+ TWEAK_RULES( ALWAYS_SKIP_DELTAP );
+ TWEAK_RULES( DEEMBOLDEN );
+ TWEAK_RULES( DO_SHPIX );
+ TWEAK_RULES( EMBOLDEN );
+ TWEAK_RULES( MIAP_HACK );
+ TWEAK_RULES( NORMAL_ROUND );
+ TWEAK_RULES( NO_ALIGNRP_AFTER_IUP );
+ TWEAK_RULES( NO_CALL_AFTER_IUP );
+ TWEAK_RULES( NO_DELTAP_AFTER_IUP );
+ TWEAK_RULES( RASTERIZER_35 );
+ TWEAK_RULES( SKIP_IUP );
+
+ TWEAK_RULES( SKIP_OFFPIXEL_Y_MOVES );
+ TWEAK_RULES_EXCEPTIONS( SKIP_OFFPIXEL_Y_MOVES );
+
+ TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES_DELTAP );
+
+ TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES );
+ TWEAK_RULES_EXCEPTIONS( SKIP_NONPIXEL_Y_MOVES );
+
+ TWEAK_RULES( ROUND_NONPIXEL_Y_MOVES );
+ TWEAK_RULES_EXCEPTIONS( ROUND_NONPIXEL_Y_MOVES );
+
+ if ( loader->exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
+ {
+ if ( loader->exec->rasterizer_version != TT_INTERPRETER_VERSION_35 )
+ {
+ loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
+ loader->exec->size->cvt_ready = -1;
+
+ tt_size_ready_bytecode(
+ loader->exec->size,
+ FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
+ }
+ else
+ loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
+ }
+ else
+ {
+ if ( loader->exec->rasterizer_version !=
+ SPH_OPTION_SET_RASTERIZER_VERSION )
+ {
+ loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
+ loader->exec->size->cvt_ready = -1;
+
+ tt_size_ready_bytecode(
+ loader->exec->size,
+ FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
+ }
+ else
+ loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
+ }
+
+ if ( IS_HINTED( loader->load_flags ) )
+ {
+ TWEAK_RULES( TIMES_NEW_ROMAN_HACK );
+ TWEAK_RULES( COURIER_NEW_2_HACK );
+ }
+
+ if ( sph_test_tweak( face, family, ppem, style, glyph_index,
+ COMPATIBILITY_MODE_Rules, COMPATIBILITY_MODE_RULES_SIZE ) )
+ loader->exec->face->sph_compatibility_mode = TRUE;
+
+
+ if ( IS_HINTED( loader->load_flags ) )
+ {
+ if ( sph_test_tweak( face, family, ppem, style, glyph_index,
+ COMPATIBLE_WIDTHS_Rules, COMPATIBLE_WIDTHS_RULES_SIZE ) )
+ loader->exec->compatible_widths |= TRUE;
+ }
+ }
+
+#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ /* ANSI C doesn't like empty source files */
+ typedef int _tt_subpix_dummy;
+
+#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.h b/src/3rdparty/freetype/src/truetype/ttsubpix.h
new file mode 100644
index 0000000000..8a54fc7cc7
--- /dev/null
+++ b/src/3rdparty/freetype/src/truetype/ttsubpix.h
@@ -0,0 +1,110 @@
+/***************************************************************************/
+/* */
+/* ttsubpix.h */
+/* */
+/* TrueType Subpixel Hinting. */
+/* */
+/* Copyright 2010-2013 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 __TTSUBPIX_H__
+#define __TTSUBPIX_H__
+
+#include <ft2build.h>
+#include "ttobjs.h"
+#include "ttinterp.h"
+
+
+FT_BEGIN_HEADER
+
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ /*************************************************************************/
+ /* */
+ /* ID flags to identify special functions at FDEF and runtime. */
+ /* */
+ /* */
+#define SPH_FDEF_INLINE_DELTA_1 0x0000001
+#define SPH_FDEF_INLINE_DELTA_2 0x0000002
+#define SPH_FDEF_DIAGONAL_STROKE 0x0000004
+#define SPH_FDEF_VACUFORM_ROUND_1 0x0000008
+#define SPH_FDEF_TTFAUTOHINT_1 0x0000010
+#define SPH_FDEF_SPACING_1 0x0000020
+#define SPH_FDEF_SPACING_2 0x0000040
+#define SPH_FDEF_TYPEMAN_STROKES 0x0000080
+#define SPH_FDEF_TYPEMAN_DIAGENDCTRL 0x0000100
+
+
+ /*************************************************************************/
+ /* */
+ /* Tweak flags that are set for each glyph by the below rules. */
+ /* */
+ /* */
+#define SPH_TWEAK_ALLOW_X_DMOVE 0x0000001
+#define SPH_TWEAK_ALWAYS_DO_DELTAP 0x0000002
+#define SPH_TWEAK_ALWAYS_SKIP_DELTAP 0x0000004
+#define SPH_TWEAK_COURIER_NEW_2_HACK 0x0000008
+#define SPH_TWEAK_DEEMBOLDEN 0x0000010
+#define SPH_TWEAK_DO_SHPIX 0x0000020
+#define SPH_TWEAK_EMBOLDEN 0x0000040
+#define SPH_TWEAK_MIAP_HACK 0x0000080
+#define SPH_TWEAK_NORMAL_ROUND 0x0000100
+#define SPH_TWEAK_NO_ALIGNRP_AFTER_IUP 0x0000200
+#define SPH_TWEAK_NO_CALL_AFTER_IUP 0x0000400
+#define SPH_TWEAK_NO_DELTAP_AFTER_IUP 0x0000800
+#define SPH_TWEAK_PIXEL_HINTING 0x0001000
+#define SPH_TWEAK_RASTERIZER_35 0x0002000
+#define SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES 0x0004000
+#define SPH_TWEAK_SKIP_IUP 0x0008000
+#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES 0x0010000
+#define SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES 0x0020000
+#define SPH_TWEAK_TIMES_NEW_ROMAN_HACK 0x0040000
+#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP 0x0080000
+
+
+ FT_LOCAL( FT_Bool )
+ sph_test_tweak( TT_Face face,
+ const FT_String* family,
+ FT_UInt ppem,
+ const FT_String* style,
+ FT_UInt glyph_index,
+ const SPH_TweakRule* rule,
+ FT_UInt num_rules );
+
+ FT_LOCAL( FT_UInt )
+ sph_test_tweak_x_scaling( TT_Face face,
+ const FT_String* family,
+ FT_UInt ppem,
+ const FT_String* style,
+ FT_UInt glyph_index );
+
+ FT_LOCAL( void )
+ sph_set_tweaks( TT_Loader loader,
+ FT_UInt glyph_index );
+
+
+ /* These macros are defined absent a method for setting them */
+#define SPH_OPTION_BITMAP_WIDTHS FALSE
+#define SPH_OPTION_SET_SUBPIXEL TRUE
+#define SPH_OPTION_SET_GRAYSCALE FALSE
+#define SPH_OPTION_SET_COMPATIBLE_WIDTHS FALSE
+#define SPH_OPTION_SET_RASTERIZER_VERSION 38
+
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+
+FT_END_HEADER
+
+#endif /* __TTSUBPIX_H__ */
+
+/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1afm.c b/src/3rdparty/freetype/src/type1/t1afm.c
index ef343901a4..de9c1997c4 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,9 +18,10 @@
#include <ft2build.h>
#include "t1afm.h"
-#include "t1errors.h"
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include "t1errors.h"
/*************************************************************************/
@@ -107,7 +108,7 @@
FT_Stream stream,
AFM_FontInfo fi )
{
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = stream->memory;
FT_Byte* start;
FT_Byte* limit;
@@ -121,14 +122,13 @@
start = (FT_Byte*)stream->cursor;
limit = (FT_Byte*)stream->limit;
- p = start;
/* Figure out how long the width table is. */
/* This info is a little-endian short at offset 99. */
p = start + 99;
if ( p + 2 > limit )
{
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
width_table_length = FT_PEEK_USHORT_LE( p );
@@ -148,7 +148,7 @@
if ( p + 2 > limit )
{
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -156,7 +156,7 @@
p += 2;
if ( p + 4 * fi->NumKernPair > limit )
{
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -235,10 +235,10 @@
FT_Stream stream )
{
PSAux_Service psaux;
- FT_Memory memory = stream->memory;
+ FT_Memory memory = stream->memory;
AFM_ParserRec parser;
- AFM_FontInfo fi;
- FT_Error error = T1_Err_Unknown_File_Format;
+ AFM_FontInfo fi = NULL;
+ FT_Error error = FT_ERR( Unknown_File_Format );
T1_Font t1_font = &( (T1_Face)t1_face )->type1;
@@ -251,7 +251,7 @@
fi->Descender = t1_font->font_bbox.yMin;
psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
- if ( psaux && psaux->afm_parser_funcs )
+ if ( psaux->afm_parser_funcs )
{
error = psaux->afm_parser_funcs->init( &parser,
stream->memory,
@@ -269,7 +269,7 @@
}
}
- if ( error == T1_Err_Unknown_File_Format )
+ if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
FT_Byte* start = stream->cursor;
@@ -366,7 +366,7 @@
if ( !fi )
- return T1_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
for ( i = 0; i < fi->NumTrackKern; i++ )
{
@@ -389,7 +389,7 @@
}
}
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/type1/t1driver.c b/src/3rdparty/freetype/src/type1/t1driver.c
index 8c398eee22..2602bdb6ff 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-2001, 2002, 2003, 2004, 2006, 2007, 2009 by */
+/* Copyright 1996-2004, 2006, 2007, 2009, 2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
{
FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -69,13 +69,13 @@
t1_get_name_index( T1_Face face,
FT_String* glyph_name )
{
- FT_Int i;
- FT_String* gname;
+ FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
- gname = face->type1.glyph_names[i];
+ FT_String* gname = face->type1.glyph_names[i];
+
if ( !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)i;
@@ -138,7 +138,7 @@
{
*afont_info = ((T1_Face)face)->type1.font_info;
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -148,7 +148,7 @@
{
*afont_extra = ((T1_Face)face)->type1.font_extra;
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -167,7 +167,399 @@
{
*afont_private = ((T1_Face)face)->type1.private_dict;
- return T1_Err_Ok;
+ return FT_Err_Ok;
+ }
+
+
+ static FT_Long
+ t1_ps_get_font_value( FT_Face face,
+ PS_Dict_Keys key,
+ FT_UInt idx,
+ void *value,
+ FT_Long value_len )
+ {
+ FT_Long retval = -1;
+ T1_Face t1face = (T1_Face)face;
+ T1_Font type1 = &t1face->type1;
+
+
+ switch ( key )
+ {
+ case PS_DICT_FONT_TYPE:
+ retval = sizeof ( type1->font_type );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->font_type;
+ break;
+
+ case PS_DICT_FONT_MATRIX:
+ if ( idx < sizeof ( type1->font_matrix ) /
+ sizeof ( type1->font_matrix.xx ) )
+ {
+ FT_Fixed val = 0;
+
+
+ retval = sizeof ( val );
+ if ( value && value_len >= retval )
+ {
+ switch ( idx )
+ {
+ case 0:
+ val = type1->font_matrix.xx;
+ break;
+ case 1:
+ val = type1->font_matrix.xy;
+ break;
+ case 2:
+ val = type1->font_matrix.yx;
+ break;
+ case 3:
+ val = type1->font_matrix.yy;
+ break;
+ }
+ *((FT_Fixed *)value) = val;
+ }
+ }
+ break;
+
+ case PS_DICT_FONT_BBOX:
+ if ( idx < sizeof ( type1->font_bbox ) /
+ sizeof ( type1->font_bbox.xMin ) )
+ {
+ FT_Fixed val = 0;
+
+
+ retval = sizeof ( val );
+ if ( value && value_len >= retval )
+ {
+ switch ( idx )
+ {
+ case 0:
+ val = type1->font_bbox.xMin;
+ break;
+ case 1:
+ val = type1->font_bbox.yMin;
+ break;
+ case 2:
+ val = type1->font_bbox.xMax;
+ break;
+ case 3:
+ val = type1->font_bbox.yMax;
+ break;
+ }
+ *((FT_Fixed *)value) = val;
+ }
+ }
+ break;
+
+ case PS_DICT_PAINT_TYPE:
+ retval = sizeof ( type1->paint_type );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->paint_type;
+ break;
+
+ case PS_DICT_FONT_NAME:
+ retval = (FT_Long)( ft_strlen( type1->font_name ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_name ), retval );
+ break;
+
+ case PS_DICT_UNIQUE_ID:
+ retval = sizeof ( type1->private_dict.unique_id );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.unique_id;
+ break;
+
+ case PS_DICT_NUM_CHAR_STRINGS:
+ retval = sizeof ( type1->num_glyphs );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->num_glyphs;
+ break;
+
+ case PS_DICT_CHAR_STRING_KEY:
+ if ( idx < (FT_UInt)type1->num_glyphs )
+ {
+ retval = (FT_Long)( ft_strlen( type1->glyph_names[idx] ) + 1 );
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
+ }
+ break;
+
+ case PS_DICT_CHAR_STRING:
+ if ( idx < (FT_UInt)type1->num_glyphs )
+ {
+ retval = (FT_Long)( type1->charstrings_len[idx] + 1 );
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->charstrings[idx] ),
+ retval - 1 );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
+ }
+ break;
+
+ case PS_DICT_ENCODING_TYPE:
+ retval = sizeof ( type1->encoding_type );
+ if ( value && value_len >= retval )
+ *((T1_EncodingType *)value) = type1->encoding_type;
+ break;
+
+ case PS_DICT_ENCODING_ENTRY:
+ if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY &&
+ idx < (FT_UInt)type1->encoding.num_chars )
+ {
+ retval = (FT_Long)( ft_strlen( type1->encoding.char_name[idx] ) + 1 );
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ),
+ retval - 1 );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
+ }
+ break;
+
+ case PS_DICT_NUM_SUBRS:
+ retval = sizeof ( type1->num_subrs );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->num_subrs;
+ break;
+
+ case PS_DICT_SUBR:
+ if ( idx < (FT_UInt)type1->num_subrs )
+ {
+ retval = (FT_Long)( 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;
+
+ case PS_DICT_STD_HW:
+ retval = sizeof ( type1->private_dict.standard_width[0] );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->private_dict.standard_width[0];
+ break;
+
+ case PS_DICT_STD_VW:
+ retval = sizeof ( type1->private_dict.standard_height[0] );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->private_dict.standard_height[0];
+ break;
+
+ case PS_DICT_NUM_BLUE_VALUES:
+ retval = sizeof ( type1->private_dict.num_blue_values );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_blue_values;
+ break;
+
+ case PS_DICT_BLUE_VALUE:
+ if ( idx < type1->private_dict.num_blue_values )
+ {
+ retval = sizeof ( type1->private_dict.blue_values[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.blue_values[idx];
+ }
+ break;
+
+ case PS_DICT_BLUE_SCALE:
+ retval = sizeof ( type1->private_dict.blue_scale );
+ if ( value && value_len >= retval )
+ *((FT_Fixed *)value) = type1->private_dict.blue_scale;
+ break;
+
+ case PS_DICT_BLUE_FUZZ:
+ retval = sizeof ( type1->private_dict.blue_fuzz );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.blue_fuzz;
+ break;
+
+ case PS_DICT_BLUE_SHIFT:
+ retval = sizeof ( type1->private_dict.blue_shift );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.blue_shift;
+ break;
+
+ case PS_DICT_NUM_OTHER_BLUES:
+ retval = sizeof ( type1->private_dict.num_other_blues );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_other_blues;
+ break;
+
+ case PS_DICT_OTHER_BLUE:
+ if ( idx < type1->private_dict.num_other_blues )
+ {
+ retval = sizeof ( type1->private_dict.other_blues[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.other_blues[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_FAMILY_BLUES:
+ retval = sizeof ( type1->private_dict.num_family_blues );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_family_blues;
+ break;
+
+ case PS_DICT_FAMILY_BLUE:
+ if ( idx < type1->private_dict.num_family_blues )
+ {
+ retval = sizeof ( type1->private_dict.family_blues[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.family_blues[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_FAMILY_OTHER_BLUES:
+ retval = sizeof ( type1->private_dict.num_family_other_blues );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_family_other_blues;
+ break;
+
+ case PS_DICT_FAMILY_OTHER_BLUE:
+ if ( idx < type1->private_dict.num_family_other_blues )
+ {
+ retval = sizeof ( type1->private_dict.family_other_blues[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.family_other_blues[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_STEM_SNAP_H:
+ retval = sizeof ( type1->private_dict.num_snap_widths );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_snap_widths;
+ break;
+
+ case PS_DICT_STEM_SNAP_H:
+ if ( idx < type1->private_dict.num_snap_widths )
+ {
+ retval = sizeof ( type1->private_dict.snap_widths[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.snap_widths[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_STEM_SNAP_V:
+ retval = sizeof ( type1->private_dict.num_snap_heights );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_snap_heights;
+ break;
+
+ case PS_DICT_STEM_SNAP_V:
+ if ( idx < type1->private_dict.num_snap_heights )
+ {
+ retval = sizeof ( type1->private_dict.snap_heights[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.snap_heights[idx];
+ }
+ break;
+
+ case PS_DICT_RND_STEM_UP:
+ retval = sizeof ( type1->private_dict.round_stem_up );
+ if ( value && value_len >= retval )
+ *((FT_Bool *)value) = type1->private_dict.round_stem_up;
+ break;
+
+ case PS_DICT_FORCE_BOLD:
+ retval = sizeof ( type1->private_dict.force_bold );
+ if ( value && value_len >= retval )
+ *((FT_Bool *)value) = type1->private_dict.force_bold;
+ break;
+
+ case PS_DICT_MIN_FEATURE:
+ if ( idx < sizeof ( type1->private_dict.min_feature ) /
+ sizeof ( type1->private_dict.min_feature[0] ) )
+ {
+ retval = sizeof ( type1->private_dict.min_feature[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.min_feature[idx];
+ }
+ break;
+
+ case PS_DICT_LEN_IV:
+ retval = sizeof ( type1->private_dict.lenIV );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.lenIV;
+ break;
+
+ case PS_DICT_PASSWORD:
+ retval = sizeof ( type1->private_dict.password );
+ if ( value && value_len >= retval )
+ *((FT_Long *)value) = type1->private_dict.password;
+ break;
+
+ case PS_DICT_LANGUAGE_GROUP:
+ retval = sizeof ( type1->private_dict.language_group );
+ if ( value && value_len >= retval )
+ *((FT_Long *)value) = type1->private_dict.language_group;
+ break;
+
+ case PS_DICT_IS_FIXED_PITCH:
+ retval = sizeof ( type1->font_info.is_fixed_pitch );
+ if ( value && value_len >= retval )
+ *((FT_Bool *)value) = type1->font_info.is_fixed_pitch;
+ break;
+
+ case PS_DICT_UNDERLINE_POSITION:
+ retval = sizeof ( type1->font_info.underline_position );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->font_info.underline_position;
+ break;
+
+ case PS_DICT_UNDERLINE_THICKNESS:
+ retval = sizeof ( type1->font_info.underline_thickness );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->font_info.underline_thickness;
+ break;
+
+ case PS_DICT_FS_TYPE:
+ retval = sizeof ( type1->font_extra.fs_type );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->font_extra.fs_type;
+ break;
+
+ case PS_DICT_VERSION:
+ retval = (FT_Long)( ft_strlen( type1->font_info.version ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.version ), retval );
+ break;
+
+ case PS_DICT_NOTICE:
+ retval = (FT_Long)( ft_strlen( type1->font_info.notice ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.notice ), retval );
+ break;
+
+ case PS_DICT_FULL_NAME:
+ retval = (FT_Long)( ft_strlen( type1->font_info.full_name ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.full_name ), retval );
+ break;
+
+ case PS_DICT_FAMILY_NAME:
+ retval = (FT_Long)( ft_strlen( type1->font_info.family_name ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.family_name ), retval );
+ break;
+
+ case PS_DICT_WEIGHT:
+ retval = (FT_Long)( ft_strlen( type1->font_info.weight ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.weight ), retval );
+ break;
+
+ case PS_DICT_ITALIC_ANGLE:
+ retval = sizeof ( type1->font_info.italic_angle );
+ if ( value && value_len >= retval )
+ *((FT_Long *)value) = type1->font_info.italic_angle;
+ break;
+ }
+
+ return retval;
}
@@ -177,6 +569,7 @@
(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,
};
@@ -211,11 +604,11 @@
};
- static FT_Module_Interface
- Get_Interface( FT_Driver driver,
+ FT_CALLBACK_DEF( FT_Module_Interface )
+ Get_Interface( FT_Module module,
const FT_String* t1_interface )
{
- FT_UNUSED( driver );
+ FT_UNUSED( module );
return ft_service_list_lookup( t1_services, t1_interface );
}
@@ -256,11 +649,14 @@
/* They can be implemented by format-specific interfaces. */
/* */
static FT_Error
- Get_Kerning( T1_Face face,
+ Get_Kerning( FT_Face t1face, /* T1_Face */
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
+ T1_Face face = (T1_Face)t1face;
+
+
kerning->x = 0;
kerning->y = 0;
@@ -270,7 +666,7 @@
right_glyph,
kerning );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -285,7 +681,7 @@
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
- sizeof( FT_DriverRec ),
+ sizeof ( FT_DriverRec ),
"type1",
0x10000L,
@@ -293,38 +689,34 @@
0, /* format interface */
- (FT_Module_Constructor)T1_Driver_Init,
- (FT_Module_Destructor) T1_Driver_Done,
- (FT_Module_Requester) Get_Interface,
+ T1_Driver_Init,
+ T1_Driver_Done,
+ Get_Interface,
},
- sizeof( T1_FaceRec ),
- sizeof( T1_SizeRec ),
- sizeof( T1_GlyphSlotRec ),
+ sizeof ( T1_FaceRec ),
+ sizeof ( T1_SizeRec ),
+ sizeof ( T1_GlyphSlotRec ),
- (FT_Face_InitFunc) T1_Face_Init,
- (FT_Face_DoneFunc) T1_Face_Done,
- (FT_Size_InitFunc) T1_Size_Init,
- (FT_Size_DoneFunc) T1_Size_Done,
- (FT_Slot_InitFunc) T1_GlyphSlot_Init,
- (FT_Slot_DoneFunc) T1_GlyphSlot_Done,
+ T1_Face_Init,
+ T1_Face_Done,
+ T1_Size_Init,
+ T1_Size_Done,
+ T1_GlyphSlot_Init,
+ T1_GlyphSlot_Done,
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
- (FT_Slot_LoadFunc) T1_Load_Glyph,
+ T1_Load_Glyph,
#ifdef T1_CONFIG_OPTION_NO_AFM
- (FT_Face_GetKerningFunc) 0,
- (FT_Face_AttachFunc) 0,
+ 0, /* FT_Face_GetKerningFunc */
+ 0, /* FT_Face_AttachFunc */
#else
- (FT_Face_GetKerningFunc) Get_Kerning,
- (FT_Face_AttachFunc) T1_Read_Metrics,
+ Get_Kerning,
+ T1_Read_Metrics,
#endif
- (FT_Face_GetAdvancesFunc) T1_Get_Advances,
- (FT_Size_RequestFunc) T1_Size_Request,
- (FT_Size_SelectFunc) 0
+ T1_Get_Advances,
+ T1_Size_Request,
+ 0 /* FT_Size_SelectFunc */
};
diff --git a/src/3rdparty/freetype/src/type1/t1driver.h b/src/3rdparty/freetype/src/type1/t1driver.h
index 9fecbeb0f8..639cd4a7ad 100644
--- a/src/3rdparty/freetype/src/type1/t1driver.h
+++ b/src/3rdparty/freetype/src/type1/t1driver.h
@@ -28,7 +28,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Driver_ClassRec ) t1_driver_class;
diff --git a/src/3rdparty/freetype/src/type1/t1errors.h b/src/3rdparty/freetype/src/type1/t1errors.h
index 81221c343d..8740530eef 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX T1_Err_
#define FT_ERR_BASE FT_Mod_Err_Type1
diff --git a/src/3rdparty/freetype/src/type1/t1gload.c b/src/3rdparty/freetype/src/type1/t1gload.c
index f3fad4f5df..af102fd85e 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-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by */
+/* Copyright 1996-2006, 2008-2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec *inc =
@@ -194,7 +194,7 @@
for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
{
/* now get load the unscaled outline */
- error = T1_Parse_Glyph( &decoder, glyph_index );
+ (void)T1_Parse_Glyph( &decoder, glyph_index );
if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
*max_advance = decoder.builder.advance.x;
@@ -203,17 +203,18 @@
psaux->t1_decoder_funcs->done( &decoder );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
FT_LOCAL_DEF( FT_Error )
- T1_Get_Advances( T1_Face face,
+ T1_Get_Advances( FT_Face t1face, /* T1_Face */
FT_UInt first,
FT_UInt count,
- FT_ULong load_flags,
+ FT_Int32 load_flags,
FT_Fixed* advances )
{
+ T1_Face face = (T1_Face)t1face;
T1_DecoderRec decoder;
T1_Font type1 = &face->type1;
PSAux_Service psaux = (PSAux_Service)face->psaux;
@@ -226,7 +227,7 @@
for ( nn = 0; nn < count; nn++ )
advances[nn] = 0;
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
error = psaux->t1_decoder_funcs->init( &decoder,
@@ -260,19 +261,20 @@
advances[nn] = 0;
}
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
FT_LOCAL_DEF( FT_Error )
- T1_Load_Glyph( T1_GlyphSlot glyph,
- T1_Size size,
+ T1_Load_Glyph( FT_GlyphSlot t1glyph, /* T1_GlyphSlot */
+ FT_Size t1size, /* T1_Size */
FT_UInt glyph_index,
FT_Int32 load_flags )
{
+ T1_GlyphSlot glyph = (T1_GlyphSlot)t1glyph;
FT_Error error;
T1_DecoderRec decoder;
- T1_Face face = (T1_Face)glyph->root.face;
+ T1_Face face = (T1_Face)t1glyph->face;
FT_Bool hinting;
T1_Font type1 = &face->type1;
PSAux_Service psaux = (PSAux_Service)face->psaux;
@@ -294,19 +296,21 @@
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
- error = T1_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
+ FT_TRACE1(( "T1_Load_Glyph: glyph index %d\n", glyph_index ));
+
FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
- if ( size )
+ if ( t1size )
{
- glyph->x_scale = size->root.metrics.x_scale;
- glyph->y_scale = size->root.metrics.y_scale;
+ glyph->x_scale = t1size->metrics.x_scale;
+ glyph->y_scale = t1size->metrics.y_scale;
}
else
{
@@ -314,18 +318,18 @@
glyph->y_scale = 0x10000L;
}
- glyph->root.outline.n_points = 0;
- glyph->root.outline.n_contours = 0;
+ t1glyph->outline.n_points = 0;
+ t1glyph->outline.n_contours = 0;
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+ t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = decoder_funcs->init( &decoder,
- (FT_Face)face,
- (FT_Size)size,
- (FT_GlyphSlot)glyph,
+ t1glyph->face,
+ t1size,
+ t1glyph,
(FT_Byte**)type1->glyph_names,
face->blend,
FT_BOOL( hinting ),
@@ -368,19 +372,19 @@
/* bearing the yMax */
if ( !error )
{
- glyph->root.outline.flags &= FT_OUTLINE_OWNER;
- glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
+ t1glyph->outline.flags &= FT_OUTLINE_OWNER;
+ t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* for composite glyphs, return only left side bearing and */
/* advance width */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
- FT_Slot_Internal internal = glyph->root.internal;
+ FT_Slot_Internal internal = t1glyph->internal;
- glyph->root.metrics.horiBearingX =
+ t1glyph->metrics.horiBearingX =
FIXED_TO_INT( decoder.builder.left_bearing.x );
- glyph->root.metrics.horiAdvance =
+ t1glyph->metrics.horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
internal->glyph_matrix = font_matrix;
@@ -390,45 +394,45 @@
else
{
FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &glyph->root.metrics;
+ FT_Glyph_Metrics* metrics = &t1glyph->metrics;
FT_Vector advance;
/* copy the _unscaled_ advance width */
metrics->horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
- glyph->root.linearHoriAdvance =
+ t1glyph->linearHoriAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
- glyph->root.internal->glyph_transformed = 0;
+ t1glyph->internal->glyph_transformed = 0;
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
/* make up vertical ones */
metrics->vertAdvance = ( face->type1.font_bbox.yMax -
face->type1.font_bbox.yMin ) >> 16;
- glyph->root.linearVertAdvance = metrics->vertAdvance;
+ t1glyph->linearVertAdvance = metrics->vertAdvance;
}
else
{
metrics->vertAdvance =
FIXED_TO_INT( decoder.builder.advance.y );
- glyph->root.linearVertAdvance =
+ t1glyph->linearVertAdvance =
FIXED_TO_INT( decoder.builder.advance.y );
}
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+ t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
- if ( size && size->root.metrics.y_ppem < 24 )
- glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
+ if ( t1size && t1size->metrics.y_ppem < 24 )
+ t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
#if 1
/* apply the font matrix, if any */
if ( font_matrix.xx != 0x10000L || font_matrix.yy != font_matrix.xx ||
font_matrix.xy != 0 || font_matrix.yx != 0 )
- FT_Outline_Transform( &glyph->root.outline, &font_matrix );
+ FT_Outline_Transform( &t1glyph->outline, &font_matrix );
if ( font_offset.x || font_offset.y )
- FT_Outline_Translate( &glyph->root.outline,
+ FT_Outline_Translate( &t1glyph->outline,
font_offset.x,
font_offset.y );
@@ -466,7 +470,7 @@
}
/* compute the other metrics */
- FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
+ FT_Outline_Get_CBox( &t1glyph->outline, &cbox );
metrics->width = cbox.xMax - cbox.xMin;
metrics->height = cbox.yMax - cbox.yMin;
@@ -474,7 +478,7 @@
metrics->horiBearingX = cbox.xMin;
metrics->horiBearingY = cbox.yMax;
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
/* make up vertical ones */
ft_synthesize_vertical_metrics( metrics,
@@ -484,8 +488,8 @@
/* Set control data to the glyph charstrings. Note that this is */
/* _not_ zero-terminated. */
- glyph->root.control_data = (FT_Byte*)glyph_data.pointer;
- glyph->root.control_len = glyph_data.length;
+ t1glyph->control_data = (FT_Byte*)glyph_data.pointer;
+ t1glyph->control_len = glyph_data.length;
}
@@ -500,8 +504,8 @@
/* Set the control data to null - it is no longer available if */
/* loaded incrementally. */
- glyph->root.control_data = 0;
- glyph->root.control_len = 0;
+ t1glyph->control_data = 0;
+ t1glyph->control_len = 0;
}
#endif
diff --git a/src/3rdparty/freetype/src/type1/t1gload.h b/src/3rdparty/freetype/src/type1/t1gload.h
index 100df06e8e..0bdea3a8d5 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-2001, 2002, 2003, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2008, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -32,15 +32,15 @@ FT_BEGIN_HEADER
FT_Pos* max_advance );
FT_LOCAL( FT_Error )
- T1_Get_Advances( T1_Face face,
+ T1_Get_Advances( FT_Face face,
FT_UInt first,
FT_UInt count,
- FT_ULong load_flags,
+ FT_Int32 load_flags,
FT_Fixed* advances );
FT_LOCAL( FT_Error )
- T1_Load_Glyph( T1_GlyphSlot glyph,
- T1_Size size,
+ T1_Load_Glyph( FT_GlyphSlot glyph,
+ FT_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags );
diff --git a/src/3rdparty/freetype/src/type1/t1load.c b/src/3rdparty/freetype/src/type1/t1load.c
index d867e942c9..22b3f6b31d 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -71,6 +71,13 @@
#include "t1errors.h"
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+#define IS_INCREMENTAL (FT_Bool)( face->root.internal->incremental_interface != 0 )
+#else
+#define IS_INCREMENTAL 0
+#endif
+
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -99,7 +106,7 @@
{
PS_Blend blend;
FT_Memory memory = face->root.memory;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
blend = face->blend;
@@ -123,8 +130,8 @@
/* allocate the blend `private' and `font_info' dictionaries */
if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs ) ||
- FT_NEW_ARRAY( blend->privates[1], num_designs ) ||
- FT_NEW_ARRAY( blend->bboxes[1], num_designs ) ||
+ FT_NEW_ARRAY( blend->privates [1], num_designs ) ||
+ FT_NEW_ARRAY( blend->bboxes [1], num_designs ) ||
FT_NEW_ARRAY( blend->weight_vector, num_designs * 2 ) )
goto Exit;
@@ -136,12 +143,12 @@
for ( nn = 2; nn <= num_designs; nn++ )
{
- blend->privates[nn] = blend->privates [nn - 1] + 1;
blend->font_infos[nn] = blend->font_infos[nn - 1] + 1;
- blend->bboxes[nn] = blend->bboxes [nn - 1] + 1;
+ blend->privates [nn] = blend->privates [nn - 1] + 1;
+ blend->bboxes [nn] = blend->bboxes [nn - 1] + 1;
}
- blend->num_designs = num_designs;
+ blend->num_designs = num_designs;
}
else if ( blend->num_designs != num_designs )
goto Fail;
@@ -175,7 +182,7 @@
return error;
Fail:
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -189,7 +196,7 @@
FT_Error error;
- error = T1_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
if ( blend )
{
@@ -207,7 +214,7 @@
axis->maximum = map->design_points[map->num_points - 1];
}
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
}
return error;
@@ -232,18 +239,11 @@
for ( j = 1; j < axismap->num_points; ++j )
{
if ( ncv <= axismap->blend_points[j] )
- {
- FT_Fixed t = FT_MulDiv( ncv - axismap->blend_points[j - 1],
- 0x10000L,
- axismap->blend_points[j] -
- axismap->blend_points[j - 1] );
-
return INT_TO_FIXED( axismap->design_points[j - 1] ) +
- FT_MulDiv( t,
- axismap->design_points[j] -
- axismap->design_points[j - 1],
- 1L );
- }
+ ( axismap->design_points[j] - axismap->design_points[j - 1] ) *
+ FT_DivFix( ncv - axismap->blend_points[j - 1],
+ axismap->blend_points[j] -
+ axismap->blend_points[j - 1] );
}
return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] );
@@ -302,7 +302,7 @@
FT_MM_Var* *master )
{
FT_Memory memory = face->root.memory;
- FT_MM_Var *mmvar;
+ FT_MM_Var *mmvar = NULL;
FT_Multi_Master mmaster;
FT_Error error;
FT_UInt i;
@@ -320,7 +320,7 @@
mmvar->num_axis = mmaster.num_axis;
mmvar->num_designs = mmaster.num_designs;
- mmvar->num_namedstyles = (FT_UInt)-1; /* Does not apply */
+ mmvar->num_namedstyles = ~0U; /* Does not apply */
mmvar->axis = (FT_Var_Axis*)&mmvar[1];
/* Point to axes after MM_Var struct */
mmvar->namedstyle = NULL;
@@ -333,8 +333,8 @@
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 = (FT_UInt)-1; /* Does not apply */
- mmvar->axis[i].tag = (FT_ULong)-1; /* Does not apply */
+ mmvar->axis[i].strid = ~0U; /* Does not apply */
+ mmvar->axis[i].tag = ~0U; /* Does not apply */
if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' );
@@ -372,13 +372,11 @@
FT_UInt n, m;
- error = T1_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( blend && blend->num_axis == num_coords )
{
/* recompute the weight vector from the blend coordinates */
- error = T1_Err_Ok;
-
for ( n = 0; n < blend->num_designs; n++ )
{
FT_Fixed result = 0x10000L; /* 1.0 fixed */
@@ -391,8 +389,10 @@
/* get current blend axis position */
factor = coords[m];
- if ( factor < 0 ) factor = 0;
- if ( factor > 0x10000L ) factor = 0x10000L;
+ if ( factor < 0 )
+ factor = 0;
+ if ( factor > 0x10000L )
+ factor = 0x10000L;
if ( ( n & ( 1 << m ) ) == 0 )
factor = 0x10000L - factor;
@@ -402,7 +402,7 @@
blend->weight_vector[n] = result;
}
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
}
return error;
@@ -419,7 +419,7 @@
FT_UInt n, p;
- error = T1_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( blend && blend->num_axis == num_coords )
{
/* compute the blend coordinates through the blend design map */
@@ -495,7 +495,7 @@
FT_Error error;
- error = T1_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( num_coords <= 4 && num_coords > 0 )
{
for ( i = 0; i < num_coords; ++i )
@@ -524,7 +524,7 @@
/* release design pos table */
FT_FREE( blend->design_pos[0] );
for ( n = 1; n < num_designs; n++ )
- blend->design_pos[n] = 0;
+ blend->design_pos[n] = NULL;
/* release blend `private' and `font info' dictionaries */
FT_FREE( blend->privates[1] );
@@ -533,14 +533,14 @@
for ( n = 0; n < num_designs; n++ )
{
- blend->privates [n] = 0;
- blend->font_infos[n] = 0;
- blend->bboxes [n] = 0;
+ blend->privates [n] = NULL;
+ blend->font_infos[n] = NULL;
+ blend->bboxes [n] = NULL;
}
/* release weight vectors */
FT_FREE( blend->weight_vector );
- blend->default_weight_vector = 0;
+ blend->default_weight_vector = NULL;
/* release axis names */
for ( n = 0; n < num_axis; n++ )
@@ -567,7 +567,7 @@
{
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
FT_Int n, num_axis;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PS_Blend blend;
FT_Memory memory;
@@ -577,14 +577,14 @@
T1_MAX_MM_AXIS, &num_axis );
if ( num_axis < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_axis_types: incorrect number of axes: %d\n",
num_axis ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -611,16 +611,16 @@
len = token->limit - token->start;
if ( len == 0 )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
- if ( FT_ALLOC( blend->axis_names[n], len + 1 ) )
+ if ( FT_ALLOC( blend->axis_names[n], (FT_Long)( len + 1 ) ) )
goto Exit;
name = (FT_Byte*)blend->axis_names[n];
FT_MEM_COPY( name, token->start, len );
- name[len] = 0;
+ name[len] = '\0';
}
Exit:
@@ -637,7 +637,7 @@
FT_Int num_axis;
T1_Parser parser = &loader->parser;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PS_Blend blend;
@@ -646,7 +646,7 @@
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
@@ -654,7 +654,7 @@
FT_ERROR(( "parse_blend_design_positions:"
" incorrect number of designs: %d\n",
num_designs ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -687,7 +687,7 @@
FT_ERROR(( "parse_blend_design_positions:"
" invalid number of axes: %d\n",
n_axis ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -700,7 +700,7 @@
else if ( n_axis != num_axis )
{
FT_ERROR(( "parse_blend_design_positions: incorrect table\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -729,7 +729,7 @@
parse_blend_design_map( T1_Face face,
T1_Loader loader )
{
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend;
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
@@ -743,14 +743,14 @@
T1_MAX_MM_AXIS, &num_axis );
if ( num_axis < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n",
num_axis ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -781,7 +781,7 @@
if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
{
FT_ERROR(( "parse_blend_design_map: incorrect table\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -821,7 +821,7 @@
{
T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
FT_Int num_designs;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend = face->blend;
T1_Token token;
@@ -834,7 +834,7 @@
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
@@ -842,7 +842,7 @@
FT_ERROR(( "parse_weight_vector:"
" incorrect number of designs: %d\n",
num_designs ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -859,7 +859,7 @@
" /BlendDesignPosition and /WeightVector have\n"
" "
" different number of elements\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -896,7 +896,7 @@
}
-#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */
+#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
@@ -921,6 +921,9 @@
PS_Blend blend = face->blend;
+ if ( blend && blend->num_designs == 0 )
+ blend = NULL;
+
/* if the keyword has a dedicated callback, call it */
if ( field->type == T1_FIELD_TYPE_CALLBACK )
{
@@ -1001,13 +1004,24 @@
max_objects = 0;
}
- if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
- field->type == T1_FIELD_TYPE_FIXED_ARRAY )
- error = T1_Load_Field_Table( &loader->parser, field,
- objects, max_objects, 0 );
+ if ( *objects )
+ {
+ if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
+ field->type == T1_FIELD_TYPE_FIXED_ARRAY )
+ error = T1_Load_Field_Table( &loader->parser, field,
+ objects, max_objects, 0 );
+ else
+ error = T1_Load_Field( &loader->parser, field,
+ objects, max_objects, 0 );
+ }
else
- error = T1_Load_Field( &loader->parser, field,
- objects, max_objects, 0 );
+ {
+ FT_TRACE1(( "t1_load_keyword: ignoring keyword `%s'"
+ " which is not valid at this point\n"
+ " (probably due to missing keywords)\n",
+ field->ident ));
+ error = FT_Err_Ok;
+ }
Exit:
return error;
@@ -1027,7 +1041,8 @@
static int
read_binary_data( T1_Parser parser,
FT_Long* size,
- FT_Byte** base )
+ FT_Byte** base,
+ FT_Bool incremental )
{
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
@@ -1045,7 +1060,8 @@
if ( cur < limit && ft_isdigit( *cur ) )
{
- *size = T1_ToInt( parser );
+ FT_Long s = T1_ToInt( parser );
+
T1_Skip_PS_Token( parser ); /* `RD' or `-|' or something else */
@@ -1053,12 +1069,20 @@
/* `RD' or `-|' token */
*base = parser->root.cursor + 1;
- parser->root.cursor += *size + 1;
- return !parser->root.error;
+ if ( s >= 0 && s < limit - *base )
+ {
+ parser->root.cursor += s + 1;
+ *size = s;
+ return !parser->root.error;
+ }
+ }
+
+ if( !incremental )
+ {
+ FT_ERROR(( "read_binary_data: invalid size field\n" ));
+ parser->root.error = FT_THROW( Invalid_File_Format );
}
- FT_ERROR(( "read_binary_data: invalid size field\n" ));
- parser->root.error = T1_Err_Invalid_File_Format;
return 0;
}
@@ -1067,8 +1091,8 @@
/* and `/CharStrings' dictionaries. */
static void
- parse_font_matrix( T1_Face face,
- T1_Loader loader )
+ t1_parse_font_matrix( T1_Face face,
+ T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Matrix* matrix = &face->type1.font_matrix;
@@ -1081,9 +1105,9 @@
result = T1_ToFixedArray( parser, 6, temp, 3 );
- if ( result < 0 )
+ if ( result < 6 )
{
- parser->root.error = T1_Err_Invalid_File_Format;
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1091,8 +1115,8 @@
if ( temp_scale == 0 )
{
- FT_ERROR(( "parse_font_matrix: invalid font matrix\n" ));
- parser->root.error = T1_Err_Invalid_File_Format;
+ FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1100,8 +1124,7 @@
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
- root->units_per_EM = (FT_UShort)( FT_DivFix( 1000 * 0x10000L,
- temp_scale ) >> 16 );
+ root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp_scale */
if ( temp_scale != 0x10000L )
@@ -1111,7 +1134,7 @@
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = 0x10000L;
+ temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
@@ -1141,7 +1164,7 @@
if ( cur >= limit )
{
FT_ERROR(( "parse_encoding: out of bounds\n" ));
- parser->root.error = T1_Err_Invalid_File_Format;
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1188,7 +1211,7 @@
char* notdef = (char *)".notdef";
- T1_Add_Table( char_table, n, notdef, 8 );
+ (void)T1_Add_Table( char_table, n, notdef, 8 );
}
/* Now we need to read records of the form */
@@ -1249,11 +1272,18 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
- if ( *cur == '/' && cur + 2 < limit && n < count )
+ if ( cur + 2 < limit && *cur == '/' && n < count )
{
FT_PtrDist len;
@@ -1262,6 +1292,8 @@
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.cursor >= limit )
+ return;
if ( parser->root.error )
return;
@@ -1285,7 +1317,7 @@
/* specification (it might be an encoding for a CID type1 */
/* font, however), so we conclude that this font is NOT a */
/* type1 font. */
- parser->root.error = FT_Err_Unknown_File_Format;
+ parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
@@ -1320,7 +1352,7 @@
face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
else
- parser->root.error = T1_Err_Ignore;
+ parser->root.error = FT_ERR( Ignore );
}
}
@@ -1348,7 +1380,7 @@
T1_Skip_Spaces ( parser );
if ( parser->root.cursor >= parser->root.limit ||
*parser->root.cursor != ']' )
- parser->root.error = T1_Err_Invalid_File_Format;
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1379,15 +1411,17 @@
FT_Byte* base;
- /* If the next token isn't `dup' we are done. */
- if ( ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
+ /* If we are out of data, or if the next token isn't `dup', */
+ /* we are done. */
+ if ( parser->root.cursor + 4 >= parser->root.limit ||
+ ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
break;
T1_Skip_PS_Token( parser ); /* `dup' */
idx = T1_ToInt( parser );
- if ( !read_binary_data( parser, &size, &base ) )
+ if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
return;
/* The binary string is followed by one token, e.g. `NP' */
@@ -1399,7 +1433,8 @@
return;
T1_Skip_Spaces ( parser );
- if ( ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
+ if ( parser->root.cursor + 4 < parser->root.limit &&
+ ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
{
T1_Skip_PS_Token( parser ); /* skip `put' */
T1_Skip_Spaces ( parser );
@@ -1424,7 +1459,7 @@
/* least contain a `return'), but we support them anyway */
if ( size < face->type1.private_dict.lenIV )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -1478,6 +1513,12 @@
num_glyphs = (FT_Int)T1_ToInt( parser );
+ if ( num_glyphs < 0 )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
+
/* some fonts like Optima-Oblique not only define the /CharStrings */
/* array but access it also */
if ( num_glyphs == 0 || parser->root.error )
@@ -1555,6 +1596,11 @@
}
T1_Skip_PS_Token( parser );
+ if ( parser->root.cursor >= limit )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
if ( parser->root.error )
return;
@@ -1563,16 +1609,16 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
cur++; /* skip `/' */
len = parser->root.cursor - cur;
- if ( !read_binary_data( parser, &size, &base ) )
+ if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
return;
/* for some non-standard fonts like `Optima' which provides */
@@ -1605,7 +1651,7 @@
if ( size <= face->type1.private_dict.lenIV )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -1764,7 +1810,7 @@
#include "t1tokens.h"
/* now add the special functions... */
- T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix,
+ T1_FIELD_CALLBACK( "FontMatrix", t1_parse_font_matrix,
T1_FIELD_DICT_FONTDICT )
T1_FIELD_CALLBACK( "Encoding", parse_encoding,
T1_FIELD_DICT_FONTDICT )
@@ -1809,7 +1855,7 @@
parser->root.cursor = base;
parser->root.limit = base + size;
- parser->root.error = T1_Err_Ok;
+ parser->root.error = FT_Err_Ok;
limit = parser->root.limit;
@@ -1861,8 +1907,8 @@
parser->root.cursor = start_binary;
- if ( !read_binary_data( parser, &s, &b ) )
- return T1_Err_Invalid_File_Format;
+ if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) )
+ return FT_THROW( Invalid_File_Format );
have_integer = 0;
}
@@ -1874,8 +1920,8 @@
parser->root.cursor = start_binary;
- if ( !read_binary_data( parser, &s, &b ) )
- return T1_Err_Invalid_File_Format;
+ if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) )
+ return FT_THROW( Invalid_File_Format );
have_integer = 0;
}
@@ -1947,8 +1993,8 @@
if ( !( dict & keyword->dict ) )
{
- FT_TRACE1(( "parse_dict: found %s but ignoring it "
- "since it is in the wrong dictionary\n",
+ FT_TRACE1(( "parse_dict: found `%s' but ignoring it"
+ " since it is in the wrong dictionary\n",
keyword->ident ));
break;
}
@@ -1960,10 +2006,10 @@
parser->root.error = t1_load_keyword( face,
loader,
keyword );
- if ( parser->root.error != T1_Err_Ok )
+ if ( parser->root.error != FT_Err_Ok )
{
- if ( FT_ERROR_BASE( parser->root.error ) == FT_Err_Ignore )
- parser->root.error = T1_Err_Ok;
+ if ( FT_ERR_EQ( parser->root.error, Ignore ) )
+ parser->root.error = FT_Err_Ok;
else
return parser->root.error;
}
@@ -2132,8 +2178,10 @@
}
}
}
+ else
+ face->len_buildchar = 0;
-#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */
+#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
/* now, propagate the subrs, charstrings, and glyphnames tables */
/* to the Type1 data */
@@ -2148,13 +2196,11 @@
type1->subrs_len = loader.subrs.lengths;
}
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( !face->root.internal->incremental_interface )
-#endif
+ if ( !IS_INCREMENTAL )
if ( !loader.charstrings.init )
{
FT_ERROR(( "T1_Open_Face: no `/CharStrings' array in face\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
@@ -2173,14 +2219,13 @@
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
- FT_Byte* char_name;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* the index is then stored in type1.encoding.char_index, and */
- /* a the name to type1.encoding.char_name */
+ /* the name to type1.encoding.char_name */
min_char = 0;
max_char = 0;
@@ -2188,6 +2233,9 @@
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
+ FT_Byte* char_name;
+
+
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
diff --git a/src/3rdparty/freetype/src/type1/t1objs.c b/src/3rdparty/freetype/src/type1/t1objs.c
index b1de687196..e11770feef 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-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2009, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -72,8 +72,11 @@
FT_LOCAL_DEF( void )
- T1_Size_Done( T1_Size size )
+ T1_Size_Done( FT_Size t1size ) /* T1_Size */
{
+ T1_Size size = (T1_Size)t1size;
+
+
if ( size->root.internal )
{
PSH_Globals_Funcs funcs;
@@ -89,9 +92,10 @@
FT_LOCAL_DEF( FT_Error )
- T1_Size_Init( T1_Size size )
+ T1_Size_Init( FT_Size t1size ) /* T1_Size */
{
- FT_Error error = T1_Err_Ok;
+ T1_Size size = (T1_Size)t1size;
+ FT_Error error = FT_Err_Ok;
PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
@@ -112,9 +116,10 @@
FT_LOCAL_DEF( FT_Error )
- T1_Size_Request( T1_Size size,
+ T1_Size_Request( FT_Size t1size, /* T1_Size */
FT_Size_Request req )
{
+ T1_Size size = (T1_Size)t1size;
PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
@@ -126,7 +131,7 @@
size->root.metrics.y_scale,
0, 0 );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -137,20 +142,20 @@
/*************************************************************************/
FT_LOCAL_DEF( void )
- T1_GlyphSlot_Done( T1_GlyphSlot slot )
+ T1_GlyphSlot_Done( FT_GlyphSlot slot )
{
- slot->root.internal->glyph_hints = 0;
+ slot->internal->glyph_hints = 0;
}
FT_LOCAL_DEF( FT_Error )
- T1_GlyphSlot_Init( T1_GlyphSlot slot )
+ T1_GlyphSlot_Init( FT_GlyphSlot slot )
{
T1_Face face;
PSHinter_Service pshinter;
- face = (T1_Face)slot->root.face;
+ face = (T1_Face)slot->face;
pshinter = (PSHinter_Service)face->pshinter;
if ( pshinter )
@@ -158,15 +163,18 @@
FT_Module module;
- module = FT_Get_Module( slot->root.face->driver->root.library, "pshinter" );
- if (module)
+ module = FT_Get_Module( slot->face->driver->root.library,
+ "pshinter" );
+ if ( module )
{
T1_Hints_Funcs funcs;
+
funcs = pshinter->get_t1_funcs( module );
- slot->root.internal->glyph_hints = (void*)funcs;
+ slot->internal->glyph_hints = (void*)funcs;
}
}
+
return 0;
}
@@ -190,8 +198,9 @@
/* face :: A typeless pointer to the face object to destroy. */
/* */
FT_LOCAL_DEF( void )
- T1_Face_Done( T1_Face face )
+ T1_Face_Done( FT_Face t1face ) /* T1_Face */
{
+ T1_Face face = (T1_Face)t1face;
FT_Memory memory;
T1_Font type1;
@@ -289,11 +298,12 @@
/* */
FT_LOCAL_DEF( FT_Error )
T1_Face_Init( FT_Stream stream,
- T1_Face face,
+ FT_Face t1face, /* T1_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
+ T1_Face face = (T1_Face)t1face;
FT_Error error;
FT_Service_PsCMaps psnames;
PSAux_Service psaux;
@@ -313,10 +323,18 @@
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
+ if ( !psaux )
+ {
+ FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"pshinter" );
+ FT_TRACE2(( "Type 1 driver\n" ));
+
/* open the tokenizer; this will also check the font format */
error = T1_Open_Face( face );
if ( error )
@@ -330,7 +348,7 @@
if ( face_index > 0 )
{
FT_ERROR(( "T1_Face_Init: invalid face index\n" ));
- error = T1_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -346,10 +364,10 @@
root->num_glyphs = type1->num_glyphs;
root->face_index = 0;
- root->face_flags = FT_FACE_FLAG_SCALABLE |
- FT_FACE_FLAG_HORIZONTAL |
- FT_FACE_FLAG_GLYPH_NAMES |
- FT_FACE_FLAG_HINTER;
+ root->face_flags |= FT_FACE_FLAG_SCALABLE |
+ FT_FACE_FLAG_HORIZONTAL |
+ FT_FACE_FLAG_GLYPH_NAMES |
+ FT_FACE_FLAG_HINTER;
if ( info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
@@ -447,7 +465,7 @@
root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFF ) >> 16;
root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFF ) >> 16;
- /* Set units_per_EM if we didn't set it in parse_font_matrix. */
+ /* Set units_per_EM if we didn't set it in t1_parse_font_matrix. */
if ( !root->units_per_EM )
root->units_per_EM = 1000;
@@ -471,7 +489,7 @@
if ( !error )
root->max_advance_width = (FT_Short)FIXED_TO_INT( max_advance );
else
- error = T1_Err_Ok; /* clear error */
+ error = FT_Err_Ok; /* clear error */
}
root->max_advance_height = root->height;
@@ -484,7 +502,7 @@
FT_Face root = &face->root;
- if ( psnames && psaux )
+ if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
@@ -494,14 +512,18 @@
charmap.face = root;
/* first of all, try to synthesize a Unicode charmap */
- charmap.platform_id = 3;
- charmap.encoding_id = 1;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
- FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
+ error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
+ if ( error &&
+ FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
+ goto Exit;
+ error = FT_Err_Ok;
/* now, generate an Adobe Standard encoding when appropriate */
- charmap.platform_id = 7;
+ charmap.platform_id = TT_PLATFORM_ADOBE;
clazz = NULL;
switch ( type1->encoding_type )
@@ -535,7 +557,7 @@
}
if ( clazz )
- FT_CMap_New( clazz, NULL, &charmap, NULL );
+ error = FT_CMap_New( clazz, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
@@ -565,11 +587,11 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- T1_Driver_Init( T1_Driver driver )
+ T1_Driver_Init( FT_Module driver )
{
FT_UNUSED( driver );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -585,7 +607,7 @@
/* driver :: A handle to the target Type 1 driver. */
/* */
FT_LOCAL_DEF( void )
- T1_Driver_Done( T1_Driver driver )
+ T1_Driver_Done( FT_Module driver )
{
FT_UNUSED( driver );
}
diff --git a/src/3rdparty/freetype/src/type1/t1objs.h b/src/3rdparty/freetype/src/type1/t1objs.h
index e5e90293d7..54ccbb996a 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-2001, 2002, 2006 by */
+/* Copyright 1996-2001, 2002, 2006, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,17 +37,6 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Type> */
- /* T1_Driver */
- /* */
- /* <Description> */
- /* A handle to a Type 1 driver object. */
- /* */
- typedef struct T1_DriverRec_ *T1_Driver;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
/* T1_Size */
/* */
/* <Description> */
@@ -106,14 +95,14 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
- T1_Size_Done( T1_Size size );
+ T1_Size_Done( FT_Size size );
FT_LOCAL( FT_Error )
- T1_Size_Request( T1_Size size,
+ T1_Size_Request( FT_Size size,
FT_Size_Request req );
FT_LOCAL( FT_Error )
- T1_Size_Init( T1_Size size );
+ T1_Size_Init( FT_Size size );
/*************************************************************************/
@@ -142,25 +131,25 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
T1_Face_Init( FT_Stream stream,
- T1_Face face,
+ FT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( void )
- T1_Face_Done( T1_Face face );
+ T1_Face_Done( FT_Face face );
FT_LOCAL( FT_Error )
- T1_GlyphSlot_Init( T1_GlyphSlot slot );
+ T1_GlyphSlot_Init( FT_GlyphSlot slot );
FT_LOCAL( void )
- T1_GlyphSlot_Done( T1_GlyphSlot slot );
+ T1_GlyphSlot_Done( FT_GlyphSlot slot );
FT_LOCAL( FT_Error )
- T1_Driver_Init( T1_Driver driver );
+ T1_Driver_Init( FT_Module driver );
FT_LOCAL( void )
- T1_Driver_Done( T1_Driver driver );
+ T1_Driver_Done( FT_Module driver );
FT_END_HEADER
diff --git a/src/3rdparty/freetype/src/type1/t1parse.c b/src/3rdparty/freetype/src/type1/t1parse.c
index 2a762279fd..ccf9f4cc56 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-2001, 2002, 2003, 2004, 2005, 2008, 2009 by */
+/* Copyright 1996-2005, 2008, 2009, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -119,10 +119,10 @@
if ( !FT_FRAME_ENTER( header_length ) )
{
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
if ( ft_memcmp( stream->cursor, header_string, header_length ) != 0 )
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
FT_FRAME_EXIT();
}
@@ -158,13 +158,13 @@
error = check_type1_format( stream, "%!PS-AdobeFont", 14 );
if ( error )
{
- if ( error != T1_Err_Unknown_File_Format )
+ if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
goto Exit;
error = check_type1_format( stream, "%!FontType", 10 );
if ( error )
{
- FT_TRACE2(( "[not a Type1 font]\n" ));
+ FT_TRACE2(( " not a Type 1 font\n" ));
goto Exit;
}
}
@@ -263,7 +263,7 @@
{
FT_Stream stream = parser->stream;
FT_Memory memory = parser->root.memory;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ULong size;
@@ -299,7 +299,7 @@
{
FT_ERROR(( "T1_Get_Private_Dict:"
" invalid private dictionary section\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -313,7 +313,7 @@
error = read_pfb_tag( stream, &tag, &size );
if ( error || tag != 0x8002U )
{
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
break;
}
@@ -332,9 +332,11 @@
/* dictionary block in the heap. */
/* first of all, look at the `eexec' keyword */
- FT_Byte* cur = parser->base_dict;
- FT_Byte* limit = cur + parser->base_len;
- FT_Byte c;
+ FT_Byte* cur = parser->base_dict;
+ FT_Byte* limit = cur + parser->base_len;
+ FT_Byte c;
+ FT_Pointer pos_lf;
+ FT_Bool test_cr;
Again:
@@ -342,7 +344,7 @@
{
c = cur[0];
if ( c == 'e' && cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */
- /* newline + 4 chars */
+ /* whitespace + 4 chars */
{
if ( cur[1] == 'e' &&
cur[2] == 'x' &&
@@ -355,7 +357,7 @@
{
FT_ERROR(( "T1_Get_Private_Dict:"
" could not find `eexec' keyword\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
}
@@ -364,7 +366,8 @@
/* or string (as e.g. in u003043t.gsf from ghostscript) */
parser->root.cursor = parser->base_dict;
- parser->root.limit = cur + 9;
+ /* set limit to `eexec' + whitespace + 4 characters */
+ parser->root.limit = cur + 10;
cur = parser->root.cursor;
limit = parser->root.limit;
@@ -396,27 +399,37 @@
parser->root.limit = parser->base_dict + parser->base_len;
T1_Skip_PS_Token( parser );
- cur = parser->root.cursor;
+ cur = parser->root.cursor;
+ limit = parser->root.limit;
- /* according to the Type1 spec, the first cipher byte must not be */
+ /* According to the Type 1 spec, the first cipher byte must not be */
/* an ASCII whitespace character code (blank, tab, carriage return */
/* or line feed). We have seen Type 1 fonts with two line feed */
/* characters... So skip now all whitespace character codes. */
- while ( cur < limit &&
- ( *cur == ' ' ||
- *cur == '\t' ||
- *cur == '\r' ||
- *cur == '\n' ) )
+ /* */
+ /* On the other hand, Adobe's Type 1 parser handles fonts just */
+ /* fine that are violating this limitation, so we add a heuristic */
+ /* test to stop at \r only if it is not used for EOL. */
+
+ pos_lf = ft_memchr( cur, '\n', limit - cur );
+ test_cr = FT_BOOL( !pos_lf ||
+ pos_lf > ft_memchr( cur, '\r', limit - cur ) );
+
+ while ( cur < limit &&
+ ( *cur == ' ' ||
+ *cur == '\t' ||
+ (test_cr && *cur == '\r' ) ||
+ *cur == '\n' ) )
++cur;
if ( cur >= limit )
{
FT_ERROR(( "T1_Get_Private_Dict:"
" `eexec' not properly terminated\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
- size = parser->base_len - ( cur - parser->base_dict );
+ size = (FT_ULong)( parser->base_len - ( cur - parser->base_dict ) );
if ( parser->in_memory )
{
@@ -437,11 +450,12 @@
/* now determine whether the private dictionary is encoded in binary */
/* or hexadecimal ASCII format -- decode it accordingly */
- /* we need to access the next 4 bytes (after the final \r following */
- /* the `eexec' keyword); if they all are hexadecimal digits, then */
- /* we have a case of ASCII storage */
+ /* we need to access the next 4 bytes (after the final whitespace */
+ /* following the `eexec' keyword); if they all are hexadecimal */
+ /* digits, then we have a case of ASCII storage */
- if ( ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
+ if ( cur + 3 < limit &&
+ ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
ft_isxdigit( cur[2] ) && ft_isxdigit( cur[3] ) )
{
/* ASCII hexadecimal encoding */
@@ -467,6 +481,14 @@
/* we now decrypt the encoded binary private dictionary */
psaux->t1_decrypt( parser->private_dict, parser->private_len, 55665U );
+ if ( parser->private_len < 4 )
+ {
+ FT_ERROR(( "T1_Get_Private_Dict:"
+ " invalid private dictionary section\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
+
/* replace the four random bytes at the beginning with whitespace */
parser->private_dict[0] = ' ';
parser->private_dict[1] = ' ';
diff --git a/src/3rdparty/freetype/src/type1/t1tokens.h b/src/3rdparty/freetype/src/type1/t1tokens.h
index 2d692f0e61..e37276b908 100644
--- a/src/3rdparty/freetype/src/type1/t1tokens.h
+++ b/src/3rdparty/freetype/src/type1/t1tokens.h
@@ -96,7 +96,7 @@
T1_FIELD_DICT_PRIVATE )
T1_FIELD_BOOL ( "ForceBold", force_bold,
T1_FIELD_DICT_PRIVATE )
-
+
#undef FT_STRUCTURE
#define FT_STRUCTURE T1_FontRec
diff --git a/src/3rdparty/freetype/src/type42/t42drivr.c b/src/3rdparty/freetype/src/type42/t42drivr.c
index 820c679612..3ad1bde79f 100644
--- a/src/3rdparty/freetype/src/type42/t42drivr.c
+++ b/src/3rdparty/freetype/src/type42/t42drivr.c
@@ -4,7 +4,8 @@
/* */
/* High-level Type 42 driver interface (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2006, 2007, 2009 by Roberto Alameda. */
+/* Copyright 2002-2004, 2006, 2007, 2009, 2011, 2013 by */
+/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -63,7 +64,7 @@
{
FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
- return T42_Err_Ok;
+ return FT_Err_Ok;
}
@@ -71,13 +72,13 @@
t42_get_name_index( T42_Face face,
FT_String* glyph_name )
{
- FT_Int i;
- FT_String* gname;
+ FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
- gname = face->type1.glyph_names[i];
+ FT_String* gname = face->type1.glyph_names[i];
+
if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] );
@@ -125,7 +126,7 @@
{
*afont_info = ((T42_Face)face)->type1.font_info;
- return T42_Err_Ok;
+ return FT_Err_Ok;
}
@@ -135,7 +136,7 @@
{
*afont_extra = ((T42_Face)face)->type1.font_extra;
- return T42_Err_Ok;
+ return FT_Err_Ok;
}
@@ -154,16 +155,17 @@
{
*afont_private = ((T42_Face)face)->type1.private_dict;
- return T42_Err_Ok;
+ return FT_Err_Ok;
}
static const FT_Service_PsInfoRec t42_service_ps_info =
{
(PS_GetFontInfoFunc) t42_ps_get_font_info,
- (PS_GetFontExtraFunc) t42_ps_get_font_extra,
+ (PS_GetFontExtraFunc) t42_ps_get_font_extra,
(PS_HasGlyphNamesFunc) t42_ps_has_glyph_names,
- (PS_GetFontPrivateFunc)t42_ps_get_font_private
+ (PS_GetFontPrivateFunc)t42_ps_get_font_private,
+ (PS_GetFontValueFunc) NULL /* not implemented */
};
@@ -183,11 +185,11 @@
};
- static FT_Module_Interface
- T42_Get_Interface( FT_Driver driver,
+ FT_CALLBACK_DEF( FT_Module_Interface )
+ T42_Get_Interface( FT_Module module,
const FT_String* t42_interface )
{
- FT_UNUSED( driver );
+ FT_UNUSED( module );
return ft_service_list_lookup( t42_services, t42_interface );
}
@@ -212,34 +214,30 @@
0, /* format interface */
- (FT_Module_Constructor)T42_Driver_Init,
- (FT_Module_Destructor) T42_Driver_Done,
- (FT_Module_Requester) T42_Get_Interface,
+ T42_Driver_Init,
+ T42_Driver_Done,
+ T42_Get_Interface,
},
sizeof ( T42_FaceRec ),
sizeof ( T42_SizeRec ),
sizeof ( T42_GlyphSlotRec ),
- (FT_Face_InitFunc) T42_Face_Init,
- (FT_Face_DoneFunc) T42_Face_Done,
- (FT_Size_InitFunc) T42_Size_Init,
- (FT_Size_DoneFunc) T42_Size_Done,
- (FT_Slot_InitFunc) T42_GlyphSlot_Init,
- (FT_Slot_DoneFunc) T42_GlyphSlot_Done,
+ T42_Face_Init,
+ T42_Face_Done,
+ T42_Size_Init,
+ T42_Size_Done,
+ T42_GlyphSlot_Init,
+ T42_GlyphSlot_Done,
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
- (FT_Slot_LoadFunc) T42_GlyphSlot_Load,
+ T42_GlyphSlot_Load,
- (FT_Face_GetKerningFunc) 0,
- (FT_Face_AttachFunc) 0,
+ 0, /* FT_Face_GetKerningFunc */
+ 0, /* FT_Face_AttachFunc */
- (FT_Face_GetAdvancesFunc) 0,
- (FT_Size_RequestFunc) T42_Size_Request,
- (FT_Size_SelectFunc) T42_Size_Select
+ 0, /* FT_Face_GetAdvancesFunc */
+ T42_Size_Request,
+ T42_Size_Select
};
diff --git a/src/3rdparty/freetype/src/type42/t42drivr.h b/src/3rdparty/freetype/src/type42/t42drivr.h
index 4717e4613f..9a1e97e30e 100644
--- a/src/3rdparty/freetype/src/type42/t42drivr.h
+++ b/src/3rdparty/freetype/src/type42/t42drivr.h
@@ -27,7 +27,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Driver_ClassRec ) t42_driver_class;
diff --git a/src/3rdparty/freetype/src/type42/t42error.h b/src/3rdparty/freetype/src/type42/t42error.h
index b230910012..217ae8bd52 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, 2003 by */
+/* Copyright 2002, 2003, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX T42_Err_
#define FT_ERR_BASE FT_Mod_Err_Type42
diff --git a/src/3rdparty/freetype/src/type42/t42objs.c b/src/3rdparty/freetype/src/type42/t42objs.c
index 9081ffc6d2..915e81fe74 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
+/* Copyright 2002-2009, 2011, 2013 */
/* by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,7 @@
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#include FT_LIST_H
+#include FT_TRUETYPE_IDS_H
#undef FT_COMPONENT
@@ -46,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
@@ -60,7 +67,9 @@
if ( type1->font_type != 42 )
{
- error = T42_Err_Unknown_File_Format;
+ FT_ERROR(( "T42_Open_Face: cannot handle FontType %d\n",
+ type1->font_type ));
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -71,7 +80,7 @@
if ( !loader.charstrings.init )
{
FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
@@ -90,7 +99,6 @@
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
- FT_Byte* char_name;
FT_Byte* glyph_name;
@@ -106,6 +114,9 @@
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
+ FT_Byte* char_name;
+
+
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
@@ -151,11 +162,12 @@
FT_LOCAL_DEF( FT_Error )
T42_Face_Init( FT_Stream stream,
- T42_Face face,
+ FT_Face t42face, /* T42_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
+ T42_Face face = (T42_Face)t42face;
FT_Error error;
FT_Service_PsCMaps psnames;
PSAux_Service psaux;
@@ -165,7 +177,6 @@
FT_UNUSED( num_params );
FT_UNUSED( params );
- FT_UNUSED( face_index );
FT_UNUSED( stream );
@@ -178,6 +189,14 @@
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
+ if ( !psaux )
+ {
+ FT_ERROR(( "T42_Face_Init: cannot access `psaux' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
+
+ FT_TRACE2(( "Type 42 driver\n" ));
/* open the tokenizer, this will also check the font format */
error = T42_Open_Face( face );
@@ -192,7 +211,7 @@
if ( face_index > 0 )
{
FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
- error = T42_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -205,9 +224,9 @@
root->num_charmaps = 0;
root->face_index = 0;
- root->face_flags = FT_FACE_FLAG_SCALABLE |
- FT_FACE_FLAG_HORIZONTAL |
- FT_FACE_FLAG_GLYPH_NAMES;
+ root->face_flags |= FT_FACE_FLAG_SCALABLE |
+ FT_FACE_FLAG_HORIZONTAL |
+ FT_FACE_FLAG_GLYPH_NAMES;
if ( info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
@@ -273,7 +292,9 @@
FT_Open_Args args;
- args.flags = FT_OPEN_MEMORY;
+ args.flags = FT_OPEN_MEMORY | FT_OPEN_DRIVER;
+ args.driver = FT_Get_Module( FT_FACE_LIBRARY( face ),
+ "truetype" );
args.memory_base = face->ttf_data;
args.memory_size = face->ttf_size;
@@ -320,7 +341,7 @@
root->face_flags |= FT_FACE_FLAG_VERTICAL;
{
- if ( psnames && psaux )
+ if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
@@ -330,39 +351,43 @@
charmap.face = root;
/* first of all, try to synthesize a Unicode charmap */
- charmap.platform_id = 3;
- charmap.encoding_id = 1;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
- FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
+ error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
+ if ( error &&
+ FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
+ goto Exit;
+ error = FT_Err_Ok;
/* now, generate an Adobe Standard encoding when appropriate */
- charmap.platform_id = 7;
+ charmap.platform_id = TT_PLATFORM_ADOBE;
clazz = NULL;
switch ( type1->encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
- charmap.encoding_id = 0;
+ charmap.encoding_id = TT_ADOBE_ID_STANDARD;
clazz = cmap_classes->standard;
break;
case T1_ENCODING_TYPE_EXPERT:
charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
- charmap.encoding_id = 1;
+ charmap.encoding_id = TT_ADOBE_ID_EXPERT;
clazz = cmap_classes->expert;
break;
case T1_ENCODING_TYPE_ARRAY:
charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
- charmap.encoding_id = 2;
+ charmap.encoding_id = TT_ADOBE_ID_CUSTOM;
clazz = cmap_classes->custom;
break;
case T1_ENCODING_TYPE_ISOLATIN1:
charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
- charmap.encoding_id = 3;
+ charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
clazz = cmap_classes->unicode;
break;
@@ -371,7 +396,7 @@
}
if ( clazz )
- FT_CMap_New( clazz, NULL, &charmap, NULL );
+ error = FT_CMap_New( clazz, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
@@ -386,8 +411,9 @@
FT_LOCAL_DEF( void )
- T42_Face_Done( T42_Face face )
+ T42_Face_Done( FT_Face t42face )
{
+ T42_Face face = (T42_Face)t42face;
T1_Font type1;
PS_FontInfo info;
FT_Memory memory;
@@ -455,36 +481,44 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- T42_Driver_Init( T42_Driver driver )
+ T42_Driver_Init( FT_Module module ) /* T42_Driver */
{
- FT_Module ttmodule;
+ T42_Driver driver = (T42_Driver)module;
+ FT_Module ttmodule;
- ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );
+ ttmodule = FT_Get_Module( module->library, "truetype" );
+ if ( !ttmodule )
+ {
+ FT_ERROR(( "T42_Driver_Init: cannot access `truetype' module\n" ));
+ return FT_THROW( Missing_Module );
+ }
+
driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
- return T42_Err_Ok;
+ return FT_Err_Ok;
}
FT_LOCAL_DEF( void )
- T42_Driver_Done( T42_Driver driver )
+ T42_Driver_Done( FT_Module module )
{
- FT_UNUSED( driver );
+ FT_UNUSED( module );
}
FT_LOCAL_DEF( FT_Error )
- T42_Size_Init( T42_Size size )
+ T42_Size_Init( FT_Size size ) /* T42_Size */
{
- FT_Face face = size->root.face;
+ T42_Size t42size = (T42_Size)size;
+ FT_Face face = size->face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
- FT_Error error = T42_Err_Ok;
+ FT_Error error;
error = FT_New_Size( t42face->ttf_face, &ttsize );
- size->ttsize = ttsize;
+ t42size->ttsize = ttsize;
FT_Activate_Size( ttsize );
@@ -493,10 +527,11 @@
FT_LOCAL_DEF( FT_Error )
- T42_Size_Request( T42_Size size,
+ T42_Size_Request( FT_Size t42size, /* T42_Size */
FT_Size_Request req )
{
- T42_Face face = (T42_Face)size->root.face;
+ T42_Size size = (T42_Size)t42size;
+ T42_Face face = (T42_Face)t42size->face;
FT_Error error;
@@ -504,17 +539,18 @@
error = FT_Request_Size( face->ttf_face, req );
if ( !error )
- ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
+ t42size->metrics = face->ttf_face->size->metrics;
return error;
}
FT_LOCAL_DEF( FT_Error )
- T42_Size_Select( T42_Size size,
+ T42_Size_Select( FT_Size t42size, /* T42_Size */
FT_ULong strike_index )
{
- T42_Face face = (T42_Face)size->root.face;
+ T42_Size size = (T42_Size)t42size;
+ T42_Face face = (T42_Face)t42size->face;
FT_Error error;
@@ -522,7 +558,7 @@
error = FT_Select_Size( face->ttf_face, (FT_Int)strike_index );
if ( !error )
- ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
+ t42size->metrics = face->ttf_face->size->metrics;
return error;
@@ -530,9 +566,10 @@
FT_LOCAL_DEF( void )
- T42_Size_Done( T42_Size size )
+ T42_Size_Done( FT_Size t42size ) /* T42_Size */
{
- FT_Face face = size->root.face;
+ T42_Size size = (T42_Size)t42size;
+ FT_Face face = t42size->face;
T42_Face t42face = (T42_Face)face;
FT_ListNode node;
@@ -547,12 +584,13 @@
FT_LOCAL_DEF( FT_Error )
- T42_GlyphSlot_Init( T42_GlyphSlot slot )
+ T42_GlyphSlot_Init( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
- FT_Face face = slot->root.face;
- T42_Face t42face = (T42_Face)face;
- FT_GlyphSlot ttslot;
- FT_Error error = T42_Err_Ok;
+ T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
+ FT_Face face = t42slot->face;
+ T42_Face t42face = (T42_Face)face;
+ FT_GlyphSlot ttslot;
+ FT_Error error = FT_Err_Ok;
if ( face->glyph == NULL )
@@ -571,8 +609,11 @@
FT_LOCAL_DEF( void )
- T42_GlyphSlot_Done( T42_GlyphSlot slot )
+ T42_GlyphSlot_Done( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
+ T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
+
+
FT_Done_GlyphSlot( slot->ttslot );
}
@@ -614,6 +655,8 @@
FT_Driver_Class ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;
+ FT_TRACE1(( "T42_GlyphSlot_Load: glyph index %d\n", glyph_index ));
+
t42_glyphslot_clear( t42slot->ttslot );
error = ttclazz->load_glyph( t42slot->ttslot,
t42size->ttsize,
diff --git a/src/3rdparty/freetype/src/type42/t42objs.h b/src/3rdparty/freetype/src/type42/t42objs.h
index 289dedcc69..02d13259be 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, 2003, 2006, 2007 by Roberto Alameda. */
+/* Copyright 2002, 2003, 2006, 2007, 2011 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -65,36 +65,36 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
T42_Face_Init( FT_Stream stream,
- T42_Face face,
+ FT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( void )
- T42_Face_Done( T42_Face face );
+ T42_Face_Done( FT_Face face );
FT_LOCAL( FT_Error )
- T42_Size_Init( T42_Size size );
+ T42_Size_Init( FT_Size size );
FT_LOCAL( FT_Error )
- T42_Size_Request( T42_Size size,
+ T42_Size_Request( FT_Size size,
FT_Size_Request req );
FT_LOCAL( FT_Error )
- T42_Size_Select( T42_Size size,
+ T42_Size_Select( FT_Size size,
FT_ULong strike_index );
FT_LOCAL( void )
- T42_Size_Done( T42_Size size );
+ T42_Size_Done( FT_Size size );
FT_LOCAL( FT_Error )
- T42_GlyphSlot_Init( T42_GlyphSlot slot );
+ T42_GlyphSlot_Init( FT_GlyphSlot slot );
FT_LOCAL( FT_Error )
@@ -104,14 +104,14 @@ FT_BEGIN_HEADER
FT_Int32 load_flags );
FT_LOCAL( void )
- T42_GlyphSlot_Done( T42_GlyphSlot slot );
+ T42_GlyphSlot_Done( FT_GlyphSlot slot );
FT_LOCAL( FT_Error )
- T42_Driver_Init( T42_Driver driver );
+ T42_Driver_Init( FT_Module module );
FT_LOCAL( void )
- T42_Driver_Done( T42_Driver driver );
+ T42_Driver_Done( FT_Module module );
/* */
diff --git a/src/3rdparty/freetype/src/type42/t42parse.c b/src/3rdparty/freetype/src/type42/t42parse.c
index 13bda64c83..50708537df 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2002-2014 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -52,7 +52,8 @@
/* as Type42 fonts have no Private dict, */
/* we set the last argument of T1_FIELD_XXX to 0 */
static const
- T1_FieldRec t42_keywords[] = {
+ T1_FieldRec t42_keywords[] =
+ {
#undef FT_STRUCTURE
#define FT_STRUCTURE T1_FontInfo
@@ -143,7 +144,7 @@
FT_Memory memory,
PSAux_Service psaux )
{
- FT_Error error = T42_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Long size;
@@ -174,8 +175,8 @@
if ( ft_memcmp( stream->cursor, "%!PS-TrueTypeFont", 17 ) != 0 )
{
- FT_TRACE2(( "not a Type42 font\n" ));
- error = T42_Err_Unknown_File_Format;
+ FT_TRACE2(( " not a Type42 font\n" ));
+ error = FT_THROW( Unknown_File_Format );
}
FT_FRAME_EXIT();
@@ -254,27 +255,41 @@
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
FT_Fixed temp_scale;
+ FT_Int result;
+
+ result = T1_ToFixedArray( parser, 6, temp, 3 );
- (void)T1_ToFixedArray( parser, 6, temp, 3 );
+ if ( result < 6 )
+ {
+ parser->root.error = FT_THROW( Invalid_File_Format );
+ return;
+ }
temp_scale = FT_ABS( temp[3] );
+ if ( temp_scale == 0 )
+ {
+ FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
+ parser->root.error = FT_THROW( Invalid_File_Format );
+ return;
+ }
+
/* Set Units per EM based on FontMatrix values. We set the value to */
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
- root->units_per_EM = (FT_UShort)( FT_DivFix( 1000 * 0x10000L,
- temp_scale ) >> 16 );
+ root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp_scale */
- if ( temp_scale != 0x10000L ) {
+ if ( temp_scale != 0x10000L )
+ {
temp[0] = FT_DivFix( temp[0], temp_scale );
temp[1] = FT_DivFix( temp[1], temp_scale );
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = 0x10000L;
+ temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
@@ -304,7 +319,7 @@
if ( cur >= limit )
{
FT_ERROR(( "t42_parse_encoding: out of bounds\n" ));
- parser->root.error = T42_Err_Invalid_File_Format;
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -313,7 +328,7 @@
if ( ft_isdigit( *cur ) || *cur == '[' )
{
T1_Encoding encode = &face->type1.encoding;
- FT_UInt count, n;
+ FT_Int count, n;
PS_Table char_table = &loader->encoding_table;
FT_Memory memory = parser->root.memory;
FT_Error error;
@@ -328,7 +343,7 @@
parser->root.cursor++;
}
else
- count = (FT_UInt)T1_ToInt( parser );
+ count = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit )
@@ -351,7 +366,7 @@
char* notdef = (char *)".notdef";
- T1_Add_Table( char_table, n, notdef, 8 );
+ (void)T1_Add_Table( char_table, n, notdef, 8 );
}
/* Now we need to read records of the form */
@@ -416,7 +431,7 @@
cur = parser->root.cursor;
- if ( *cur == '/' && cur + 2 < limit && n < count )
+ if ( cur + 2 < limit && *cur == '/' && n < count )
{
FT_PtrDist len;
@@ -425,6 +440,8 @@
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.cursor >= limit )
+ return;
if ( parser->root.error )
return;
@@ -438,6 +455,19 @@
n++;
}
+ else if ( only_immediates )
+ {
+ /* Since the current position is not updated for */
+ /* immediates-only mode we would get an infinite loop if */
+ /* we don't do anything here. */
+ /* */
+ /* This encoding array is not valid according to the type1 */
+ /* specification (it might be an encoding for a CID type1 */
+ /* font, however), so we conclude that this font is NOT a */
+ /* type1 font. */
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
else
{
@@ -449,8 +479,8 @@
T1_Skip_Spaces( parser );
}
- face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
- parser->root.cursor = cur;
+ face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
+ parser->root.cursor = cur;
}
/* Otherwise, we should have either `StandardEncoding', */
@@ -470,10 +500,7 @@
face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
else
- {
- FT_ERROR(( "t42_parse_encoding: invalid token\n" ));
- parser->root.error = T42_Err_Invalid_File_Format;
- }
+ parser->root.error = FT_THROW( Ignore );
}
}
@@ -497,7 +524,7 @@
FT_Byte* limit = parser->root.limit;
FT_Error error;
FT_Int num_tables = 0;
- FT_ULong count, ttf_size = 0;
+ FT_ULong count;
FT_Long n, string_size, old_string_size, real_size;
FT_Byte* string_buf = NULL;
@@ -525,7 +552,7 @@
if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
{
FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -553,6 +580,12 @@
/* don't include delimiters */
string_size = (FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
+ if ( !string_size )
+ {
+ FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
goto Fail;
@@ -570,11 +603,17 @@
{
FT_ERROR(( "t42_parse_sfnts: "
"can't handle mixed binary and hex strings\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
string_size = T1_ToInt( parser );
+ if ( string_size < 0 )
+ {
+ FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
T1_Skip_PS_Token( parser ); /* `RD' */
if ( parser->root.error )
@@ -582,30 +621,32 @@
string_buf = parser->root.cursor + 1; /* one space after `RD' */
- parser->root.cursor += string_size + 1;
- if ( parser->root.cursor >= limit )
+ if ( limit - parser->root.cursor < string_size )
{
- FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
- error = T42_Err_Invalid_File_Format;
+ FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
+ else
+ parser->root.cursor += string_size + 1;
}
if ( !string_buf )
{
FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
- /* A string can have a trailing zero byte for padding. Ignore it. */
- if ( string_buf[string_size - 1] == 0 && ( string_size % 2 == 1 ) )
+ /* A string can have a trailing zero (odd) byte for padding. */
+ /* Ignore it. */
+ if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
string_size--;
if ( !string_size )
{
FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -622,18 +663,25 @@
}
else
{
- num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
- status = BEFORE_TABLE_DIR;
- ttf_size = 12 + 16 * num_tables;
+ num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
+ status = BEFORE_TABLE_DIR;
+ face->ttf_size = 12 + 16 * num_tables;
- if ( FT_REALLOC( face->ttf_data, 12, ttf_size ) )
+ if ( (FT_ULong)( limit - parser->root.cursor ) < face->ttf_size )
+ {
+ FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
+
+ if ( FT_REALLOC( face->ttf_data, 12, face->ttf_size ) )
goto Fail;
}
/* fall through */
case BEFORE_TABLE_DIR:
/* the offset table is read; read the table directory */
- if ( count < ttf_size )
+ if ( count < face->ttf_size )
{
face->ttf_data[count++] = string_buf[n];
continue;
@@ -652,25 +700,24 @@
len = FT_PEEK_ULONG( p );
/* Pad to a 4-byte boundary length */
- ttf_size += ( len + 3 ) & ~3;
+ face->ttf_size += ( len + 3 ) & ~3;
}
- status = OTHER_TABLES;
- face->ttf_size = ttf_size;
+ status = OTHER_TABLES;
/* there are no more than 256 tables, so no size check here */
if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
- ttf_size + 1 ) )
+ face->ttf_size + 1 ) )
goto Fail;
}
/* fall through */
case OTHER_TABLES:
/* all other tables are just copied */
- if ( count >= ttf_size )
+ if ( count >= face->ttf_size )
{
- FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
- error = T42_Err_Invalid_File_Format;
+ FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
face->ttf_data[count++] = string_buf[n];
@@ -681,7 +728,7 @@
}
/* if control reaches this point, the format was not valid */
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
Fail:
parser->root.error = error;
@@ -717,7 +764,7 @@
if ( parser->root.cursor >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -759,14 +806,14 @@
else
{
FT_ERROR(( "t42_parse_charstrings: invalid token\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
if ( parser->root.cursor >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -815,6 +862,12 @@
break;
T1_Skip_PS_Token( parser );
+ if ( parser->root.cursor >= limit )
+ {
+ FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
if ( parser->root.error )
return;
@@ -823,10 +876,10 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -857,7 +910,7 @@
if ( parser->root.cursor >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -880,7 +933,7 @@
if ( !notdef_found )
{
FT_ERROR(( "t42_parse_charstrings: no /.notdef glyph\n" ));
- error = T42_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -1024,7 +1077,7 @@
parser->root.cursor = base;
parser->root.limit = base + size;
- parser->root.error = T42_Err_Ok;
+ parser->root.error = FT_Err_Ok;
limit = parser->root.limit;
diff --git a/src/3rdparty/freetype/src/winfonts/fnterrs.h b/src/3rdparty/freetype/src/winfonts/fnterrs.h
index ea80909715..463ba77ee2 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 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX FNT_Err_
#define FT_ERR_BASE FT_Mod_Err_Winfonts
diff --git a/src/3rdparty/freetype/src/winfonts/winfnt.c b/src/3rdparty/freetype/src/winfonts/winfnt.c
index 6b3a4e17f2..4705c53963 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-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2004, 2006-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* Copyright 2003 Huw D M Davies for Codeweavers */
/* Copyright 2007 Dmitry Timoshkov for Codeweavers */
@@ -23,6 +23,7 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H
+#include FT_TRUETYPE_IDS_H
#include "winfnt.h"
#include "fnterrs.h"
@@ -71,12 +72,12 @@
FT_FRAME_START( 248 ),
FT_FRAME_ULONG_LE ( magic ), /* PE00 */
- FT_FRAME_USHORT_LE ( machine ), /* 0x014c - i386 */
+ FT_FRAME_USHORT_LE ( machine ), /* 0x014C - i386 */
FT_FRAME_USHORT_LE ( number_of_sections ),
FT_FRAME_SKIP_BYTES( 12 ),
FT_FRAME_USHORT_LE ( size_of_optional_header ),
FT_FRAME_SKIP_BYTES( 2 ),
- FT_FRAME_USHORT_LE ( magic32 ), /* 0x10b */
+ FT_FRAME_USHORT_LE ( magic32 ), /* 0x10B */
FT_FRAME_SKIP_BYTES( 110 ),
FT_FRAME_ULONG_LE ( rsrc_virtual_address ),
FT_FRAME_ULONG_LE ( rsrc_size ),
@@ -223,8 +224,8 @@
if ( header->version != 0x200 &&
header->version != 0x300 )
{
- FT_TRACE2(( "[not a valid FNT file]\n" ));
- error = FNT_Err_Unknown_File_Format;
+ FT_TRACE2(( " not a Windows FNT file\n" ));
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -233,8 +234,8 @@
if ( header->file_size < size )
{
- FT_TRACE2(( "[not a valid FNT file]\n" ));
- error = FNT_Err_Unknown_File_Format;
+ FT_TRACE2(( " not a Windows FNT file\n" ));
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -252,7 +253,7 @@
if ( header->file_type & 1 )
{
FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
- error = FNT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -283,7 +284,7 @@
FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
goto Exit;
- error = FNT_Err_Unknown_File_Format;
+ error = FT_ERR( Unknown_File_Format );
if ( mz_header.magic == WINFNT_MZ_MAGIC )
{
/* yes, now look for an NE header in the file */
@@ -296,7 +297,7 @@
FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
goto Exit;
- error = FNT_Err_Unknown_File_Format;
+ error = FT_ERR( Unknown_File_Format );
if ( ne_header.magic == WINFNT_NE_MAGIC )
{
/* good, now look into the resource table for each FNT resource */
@@ -343,7 +344,7 @@
if ( !font_count || !font_offset )
{
FT_TRACE2(( "this file doesn't contain any FNT resources\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -352,7 +353,7 @@
if ( font_count * 118UL > stream->size )
{
FT_TRACE2(( "invalid number of faces\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -360,7 +361,7 @@
if ( face_index >= font_count )
{
- error = FNT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
else if ( face_index < 0 )
@@ -411,12 +412,12 @@
pe32_header.rsrc_size ));
if ( pe32_header.magic != WINFNT_PE_MAGIC /* check full signature */ ||
- pe32_header.machine != 0x014c /* i386 */ ||
- pe32_header.size_of_optional_header != 0xe0 /* FIXME */ ||
- pe32_header.magic32 != 0x10b )
+ pe32_header.machine != 0x014C /* i386 */ ||
+ pe32_header.size_of_optional_header != 0xE0 /* FIXME */ ||
+ pe32_header.magic32 != 0x10B )
{
FT_TRACE2(( "this file has an invalid PE header\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -439,7 +440,7 @@
}
FT_TRACE2(( "this file doesn't contain any resources\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
Found_rsrc_section:
@@ -461,7 +462,7 @@
if ( !(dir_entry1.offset & 0x80000000UL ) /* DataIsDirectory */ )
{
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -485,7 +486,7 @@
if ( !(dir_entry2.offset & 0x80000000UL ) /* DataIsDirectory */ )
{
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -509,7 +510,7 @@
if ( dir_entry2.offset & 0x80000000UL /* DataIsDirectory */ )
{
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -560,13 +561,13 @@
if ( !face->root.num_faces )
{
FT_TRACE2(( "this file doesn't contain any RT_FONT resources\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( face_index >= face->root.num_faces )
{
- error = FNT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
}
@@ -590,11 +591,14 @@
static FT_Error
- fnt_cmap_init( FNT_CMap cmap )
+ fnt_cmap_init( FNT_CMap cmap,
+ FT_Pointer pointer )
{
FNT_Face face = (FNT_Face)FT_CMAP_FACE( cmap );
FNT_Font font = face->font;
+ FT_UNUSED( pointer );
+
cmap->first = (FT_UInt32) font->header.first_char;
cmap->count = (FT_UInt32)( font->header.last_char - cmap->first + 1 );
@@ -664,8 +668,9 @@
static void
- FNT_Face_Done( FNT_Face face )
+ FNT_Face_Done( FT_Face fntface ) /* FNT_Face */
{
+ FNT_Face face = (FNT_Face)fntface;
FT_Memory memory;
@@ -676,18 +681,19 @@
fnt_font_done( face );
- FT_FREE( face->root.available_sizes );
- face->root.num_fixed_sizes = 0;
+ FT_FREE( fntface->available_sizes );
+ fntface->num_fixed_sizes = 0;
}
static FT_Error
FNT_Face_Init( FT_Stream stream,
- FNT_Face face,
+ FT_Face fntface, /* FNT_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
+ FNT_Face face = (FNT_Face)fntface;
FT_Error error;
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -695,12 +701,14 @@
FT_UNUSED( params );
+ FT_TRACE2(( "Windows FNT driver\n" ));
+
/* try to load font from a DLL */
error = fnt_face_get_dll_font( face, face_index );
if ( !error && face_index < 0 )
goto Exit;
- if ( error == FNT_Err_Unknown_File_Format )
+ if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
/* this didn't work; try to load a single FNT font */
FNT_Font font;
@@ -708,7 +716,7 @@
if ( FT_NEW( face->font ) )
goto Exit;
- face->root.num_faces = 1;
+ fntface->num_faces = 1;
font = face->font;
font->offset = 0;
@@ -719,7 +727,7 @@
if ( !error )
{
if ( face_index > 0 )
- error = FNT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
else if ( face_index < 0 )
goto Exit;
}
@@ -738,8 +746,8 @@
root->face_index = face_index;
- root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
- FT_FACE_FLAG_HORIZONTAL;
+ root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
+ FT_FACE_FLAG_HORIZONTAL;
if ( font->header.avg_width == font->header.max_width )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
@@ -802,15 +810,16 @@
charmap.encoding = FT_ENCODING_NONE;
- charmap.platform_id = 0;
- charmap.encoding_id = 0;
+ /* initial platform/encoding should indicate unset status? */
+ charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
+ charmap.encoding_id = TT_APPLE_ID_DEFAULT;
charmap.face = root;
if ( font->header.charset == FT_WinFNT_ID_MAC )
{
charmap.encoding = FT_ENCODING_APPLE_ROMAN;
- charmap.platform_id = 1;
-/* charmap.encoding_id = 0; */
+ charmap.platform_id = TT_PLATFORM_MACINTOSH;
+/* charmap.encoding_id = TT_MAC_ID_ROMAN; */
}
error = FT_CMap_New( fnt_cmap_class,
@@ -825,7 +834,14 @@
root->charmap = root->charmaps[0];
}
- /* setup remaining flags */
+ /* set up remaining flags */
+
+ if ( font->header.last_char < font->header.first_char )
+ {
+ FT_TRACE2(( "invalid number of glyphs\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
/* reserve one slot for the .notdef glyph at index 0 */
root->num_glyphs = font->header.last_char -
@@ -834,7 +850,7 @@
if ( font->header.face_name_offset >= font->header.file_size )
{
FT_TRACE2(( "invalid family name offset\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
family_size = font->header.file_size - font->header.face_name_offset;
@@ -872,7 +888,7 @@
goto Exit;
Fail:
- FNT_Face_Done( face );
+ FNT_Face_Done( fntface );
Exit:
return error;
@@ -880,11 +896,14 @@
static FT_Error
- FNT_Size_Select( FT_Size size )
+ FNT_Size_Select( FT_Size size,
+ FT_ULong strike_index )
{
FNT_Face face = (FNT_Face)size->face;
FT_WinFNT_Header header = &face->font->header;
+ FT_UNUSED( strike_index );
+
FT_Select_Metrics( size->face, 0 );
@@ -893,7 +912,7 @@
header->ascent ) * 64;
size->metrics.max_advance = header->max_width * 64;
- return FNT_Err_Ok;
+ return FT_Err_Ok;
}
@@ -904,7 +923,7 @@
FNT_Face face = (FNT_Face)size->face;
FT_WinFNT_Header header = &face->font->header;
FT_Bitmap_Size* bsize = size->face->available_sizes;
- FT_Error error = FNT_Err_Invalid_Pixel_Size;
+ FT_Error error = FT_ERR( Invalid_Pixel_Size );
FT_Long height;
@@ -915,23 +934,23 @@
{
case FT_SIZE_REQUEST_TYPE_NOMINAL:
if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
- error = FNT_Err_Ok;
+ error = FT_Err_Ok;
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
if ( height == header->pixel_height )
- error = FNT_Err_Ok;
+ error = FT_Err_Ok;
break;
default:
- error = FNT_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
break;
}
if ( error )
return error;
else
- return FNT_Size_Select( size );
+ return FNT_Size_Select( size, 0 );
}
@@ -942,8 +961,8 @@
FT_Int32 load_flags )
{
FNT_Face face = (FNT_Face)FT_SIZE_FACE( size );
- FNT_Font font = face->font;
- FT_Error error = FNT_Err_Ok;
+ FNT_Font font;
+ FT_Error error = FT_Err_Ok;
FT_Byte* p;
FT_Int len;
FT_Bitmap* bitmap = &slot->bitmap;
@@ -953,26 +972,46 @@
FT_UNUSED( load_flags );
- if ( !face || !font ||
+ if ( !face )
+ {
+ error = FT_THROW( Invalid_Face_Handle );
+ goto Exit;
+ }
+
+ font = face->font;
+
+ if ( !font ||
glyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) )
{
- error = FNT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
+ FT_TRACE1(( "FNT_Load_Glyph: glyph index %d\n", glyph_index ));
+
if ( glyph_index > 0 )
glyph_index--; /* revert to real index */
else
- glyph_index = font->header.default_char; /* the .notdef glyph */
+ glyph_index = font->header.default_char; /* the `.notdef' glyph */
new_format = FT_BOOL( font->header.version == 0x300 );
len = new_format ? 6 : 4;
- /* jump to glyph entry */
- p = font->fnt_frame + ( new_format ? 148 : 118 ) + len * glyph_index;
+ /* get glyph width and offset */
+ offset = ( new_format ? 148 : 118 ) + len * glyph_index;
+
+ if ( offset >= font->header.file_size - 2 - ( new_format ? 4 : 2 ) )
+ {
+ FT_TRACE2(( "invalid FNT offset\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ p = font->fnt_frame + offset;
bitmap->width = FT_NEXT_SHORT_LE( p );
+ /* jump to glyph entry */
if ( new_format )
offset = FT_NEXT_ULONG_LE( p );
else
@@ -981,7 +1020,7 @@
if ( offset >= font->header.file_size )
{
FT_TRACE2(( "invalid FNT offset\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1000,10 +1039,10 @@
bitmap->rows = font->header.pixel_height;
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
- if ( offset + pitch * bitmap->rows >= font->header.file_size )
+ if ( offset + pitch * bitmap->rows > font->header.file_size )
{
FT_TRACE2(( "invalid bitmap width\n" ));
- error = FNT_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1076,10 +1115,10 @@
static FT_Module_Interface
- winfnt_get_service( FT_Driver driver,
+ winfnt_get_service( FT_Module module,
const FT_String* service_id )
{
- FT_UNUSED( driver );
+ FT_UNUSED( module );
return ft_service_list_lookup( winfnt_services, service_id );
}
@@ -1101,34 +1140,30 @@
0,
- (FT_Module_Constructor)0,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) winfnt_get_service
+ 0, /* FT_Module_Constructor */
+ 0, /* FT_Module_Destructor */
+ winfnt_get_service
},
- sizeof( FNT_FaceRec ),
- sizeof( FT_SizeRec ),
- sizeof( FT_GlyphSlotRec ),
-
- (FT_Face_InitFunc) FNT_Face_Init,
- (FT_Face_DoneFunc) FNT_Face_Done,
- (FT_Size_InitFunc) 0,
- (FT_Size_DoneFunc) 0,
- (FT_Slot_InitFunc) 0,
- (FT_Slot_DoneFunc) 0,
-
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
- (FT_Slot_LoadFunc) FNT_Load_Glyph,
-
- (FT_Face_GetKerningFunc) 0,
- (FT_Face_AttachFunc) 0,
- (FT_Face_GetAdvancesFunc) 0,
-
- (FT_Size_RequestFunc) FNT_Size_Request,
- (FT_Size_SelectFunc) FNT_Size_Select
+ 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_Load_Glyph,
+
+ 0, /* FT_Face_GetKerningFunc */
+ 0, /* FT_Face_AttachFunc */
+ 0, /* FT_Face_GetAdvancesFunc */
+
+ FNT_Size_Request,
+ FNT_Size_Select
};
diff --git a/src/3rdparty/freetype/src/winfonts/winfnt.h b/src/3rdparty/freetype/src/winfonts/winfnt.h
index 70a90861ab..b7a80736d8 100644
--- a/src/3rdparty/freetype/src/winfonts/winfnt.h
+++ b/src/3rdparty/freetype/src/winfonts/winfnt.h
@@ -30,7 +30,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
typedef struct WinMZ_HeaderRec_
{