summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mfluadir
diff options
context:
space:
mode:
authorDenis Bitouzé <dbitouze@wanadoo.fr>2021-02-25 18:23:07 +0000
committerDenis Bitouzé <dbitouze@wanadoo.fr>2021-02-25 18:23:07 +0000
commitc6101f91d071883b48b1b4b51e5eba0f36d9a78d (patch)
tree1bf7f5a881d7a4f5c5bf59d0b2821943dd822372 /Build/source/texk/web2c/mfluadir
parent07ee7222e389b0777456b427a55c22d0e6ffd267 (diff)
French translation for tlmgr updated
git-svn-id: svn://tug.org/texlive/trunk@57912 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mfluadir')
-rw-r--r--Build/source/texk/web2c/mfluadir/ChangeLog99
-rw-r--r--Build/source/texk/web2c/mfluadir/am/mflua.am138
-rw-r--r--Build/source/texk/web2c/mfluadir/am/mfluaotfcc.am302
-rw-r--r--Build/source/texk/web2c/mfluadir/mf-lua.ch528
-rw-r--r--Build/source/texk/web2c/mfluadir/mflua-m.ch12
-rw-r--r--Build/source/texk/web2c/mfluadir/mflua.defines29
-rw-r--r--Build/source/texk/web2c/mfluadir/mflua_version.h2
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluac.c1600
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluac.h57
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluaextra.c11
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluaextra.h25
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/mflua.lua3790
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/mflua_svg_backend.lua538
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/mflua_ttx_backend.lua1228
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs285
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf38
-rwxr-xr-xBuild/source/texk/web2c/mfluadir/mfluatraptest.test51
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.c439
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.h6
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json-builder.c889
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json.c1039
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sds.c1264
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sdsalloc.h41
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/caryll/buffer.h52
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/caryll/element.h67
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/caryll/ownership.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/caryll/vector.h38
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/dep/json-builder.h139
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/dep/json.h291
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/dep/sds.h259
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/dep/uthash.h1208
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/font.h120
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/glyph-order.h37
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/handle.h40
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/logger.h35
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/options.h41
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/primitives.h47
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt-builder.h30
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt.h34
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/BASE.h30
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CFF.h90
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/COLR.h24
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CPAL.h35
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/GDEF.h31
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/LTSH.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/OS_2.h50
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/SVG.h18
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/TSI5.h10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VDMX.h36
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VORG.h19
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/_TSI.h19
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cmap.h44
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cvt.h12
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fpgm-prep.h14
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fvar.h40
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/gasp.h24
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/glyf.h129
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hdmx.h23
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/head.h29
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hhea.h25
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hmtx.h21
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/maxp.h27
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/meta.h23
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/name.h17
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl.h260
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/classdef.h28
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/coverage.h25
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/post.h22
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/table-common.h18
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vhea.h28
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vmtx.h21
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/axis.h21
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/region.h34
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vf.h14
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vq.h61
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vv.h18
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.c132
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.h55
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.c410
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.h35
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.c532
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.h8
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.c67
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.h7
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.c55
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.h7
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.c24
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.h10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.c54
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.h8
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.c10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.h7
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.c53
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.h8
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.c29
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.h8
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.c64
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.h10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.c57
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.h8
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.c56
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.h8
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.c166
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.h10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-font.c168
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt-builder.c115
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt.c90
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/json-reader/json-reader.c181
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/json-writer/json-writer.c56
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.c126
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.h62
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-codecs.c316
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.c122
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.h32
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.c81
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.h48
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.c146
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.h33
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-opmean.c245
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-parser.c847
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-string.c411
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-util.h123
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.c7
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.h29
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-writer.c60
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.c518
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.h44
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/libcff.h164
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.c635
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.h55
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/logger/logger.c171
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/otf-reader.c91
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.c399
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.h9
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/otf-writer.c106
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.c706
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.h9
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.c592
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.h6
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/aliases.h60
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.c89
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.h10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/bin-io.h171
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/buffer/buffer.c231
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/element-impl.h275
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/glyph-order.c117
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/handle.c63
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-funcs.h203
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.c86
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/options.c38
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/otfcc-alloc.h83
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/primitives.c66
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.c144
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.h35
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/tag.h36
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.c701
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.h38
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c291
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/util.h41
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/support/vector-impl.h190
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.c330
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.c1411
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.c184
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.c280
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.c254
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.c35
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.h9
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.c435
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.c150
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.c39
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/VDMX.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.c46
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.h9
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.c241
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.h18
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/all.h39
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.c801
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.c83
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.c73
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.h12
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.c326
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.h9
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.c109
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf.h61
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/build.c222
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/glyf.c482
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/read.c707
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.c36
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.h8
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.c137
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.c108
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.h12
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.c64
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.h10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.c125
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/build.c21
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/dump.c36
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/parse.c47
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/read.c36
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/type.c27
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.c198
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl.h18
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/build.c320
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/classdef.c237
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/constants.c24
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/coverage.c256
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/dump.c87
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/otl.c104
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/parse.c376
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/private.h24
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/read.c267
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining.h28
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/build.c239
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/classifier.c238
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.c23
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.h33
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/dump.c27
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/parse.c37
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/read.c416
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/common.h15
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.c35
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.c214
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.h43
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.c101
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.c241
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.h14
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.c203
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.h14
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.c406
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.c129
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.c177
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.c91
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.c133
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.c139
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.h13
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.c140
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/funcs.c150
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/type.c28
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.c108
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.h11
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.c64
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.h10
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/vf/axis.c5
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/vf/region.c62
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/lib/vf/vq.c291
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/aliases.h17
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/luafunc.c617
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/otfccbuild.c326
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/otfccdll.c57
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/otfccdump.c311
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/platform.h75
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.c108
-rw-r--r--Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.h28
278 files changed, 0 insertions, 42546 deletions
diff --git a/Build/source/texk/web2c/mfluadir/ChangeLog b/Build/source/texk/web2c/mfluadir/ChangeLog
deleted file mode 100644
index 6f1a9f9e498..00000000000
--- a/Build/source/texk/web2c/mfluadir/ChangeLog
+++ /dev/null
@@ -1,99 +0,0 @@
-2021-02-07 Luigi Scarso <luigi.scarso@gmail.com>
-
- * DEK tuneup2021
-
-
-2021-01-05 Luigi Scarso <luigi.scarso@gmail.com>
-
- * MFLua 1.0.0-alpha: embedding of otfcc (see https://github.com/caryll/otfcc)
-
-
-2020-02-16 Luigi Scarso <luigi.scarso@gmail.com>
-
- Small clean up.
-
-2019-03-06 Luigi Scarso <luigi.scarso@gmail.com>
-
- MFLua 0.9.1. Fixed a bug on strings management.
-
-2018-10-30 Luigi Scarso <luigi.scarso@gmail.com>
-
- * jit default off in mfluajit: in some platforms (e.g NetBSD8)
- executing code from memory is forbidden by default.
- In case, a user can enable jit at runtime.
-
-
-2018-02-08 Luigi Scarso <luigi.scarso@gmail.com>
-
- * MFLua 0.9.
- * Fixed a bug on clean up string in runscript.
- * Added a parser for generic font to mflua.lua
-
-
-2017-04-16 Luigi Scarso <luigi.scarso@gmail.com>
-
- * MFLua 0.8. New primitive runscript, cleanup of the Lua code.
- * new backend ttx .
- * am/mflua.am: deleted useless lua files
-
-2016-04-15 Luigi Scarso <luigi.scarso@gmail.com>
-
- * mfluac.c priv_lua_writemessage: write to stdout
- when a lua file is loaded.
-
-
-2016-04-12 Karl Berry <karl@tug.org>
-
- * mfluac.c (mfluaPREstartofMF): look for start_of_mf.lua
- rather than start_of_MF.lua.
- * mfluatrap/start_of_mf.lua: rename file.
- * install mfluatrap/*.lua in Master/texmf-dist/scripts/mflua.
-
-2016-04-05 Karl Berry <karl@tug.org>
-
- * am/mflua.am: no need for inimflua.
-
-2016-03-22 Luigi Scarso <luigi.scarso@gmail.com>
-
- * mflua.c: return if a lua file is not found.
-
-2015-09-27 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- * am/mflua.am: Fix dependencies.
-
-2015-07-10 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- * mfluatraptest (removed): Renamed ...
- * mfluatraptest.test (new): ... into this.
- * am/mflua.am: Better dependencies for 'make check'.
-
-2015-07-08 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- * am/mflua.am: Fix dependencies.
-
-2015-07-03 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- * am/mflua.am, mfluac.[ch]: Use lkpselib.c.
-
-2015-07-03 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- * am/mflua.am: Always create mflua-nowin, either as extra
- program or as symlink.
-
-2015-07-02 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- * mfluatraptest: Directly use mfluatrap/*.lua files.
-
-2015-07-02 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
-
- * mflua.c: Use kpse_find_file() to locate .lua files.
-
-2015-06-22 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- * am/mflua.am: Use $(tie_c) and $(tie_m).
-
-2015-04-01 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- Imported MFLua into TeX Live, based on the SVN repository
- https://foundry.supelec.fr/projects/mflua
- from Luigi Scarso <luigi.scarso@gmail.com>.
diff --git a/Build/source/texk/web2c/mfluadir/am/mflua.am b/Build/source/texk/web2c/mfluadir/am/mflua.am
deleted file mode 100644
index 5f19d8ceca8..00000000000
--- a/Build/source/texk/web2c/mfluadir/am/mflua.am
+++ /dev/null
@@ -1,138 +0,0 @@
-## texk/web2c/mfluadir/am/mflua.am: Makefile fragment for MFLua.
-##
-## Copyright 2016 Karl Berry <tex-live@tug.org>
-## Copyright 2015 Peter Breitenlohner <tex-live@tug.org>
-## You may freely use, modify and/or distribute this file.
-
-## MFLua
-##
-if MFLUA
-bin_PROGRAMS += mflua
-if MFLUAN
-bin_PROGRAMS += mflua-nowin
-endif MFLUAN
-if WIN32
-noinst_PROGRAMS += call_mflua
-install_exe_links += install-mflua-links
-uninstall_exe_links += uninstall-mflua-links
-else !WIN32
-if !MFLUAN
-bin_links += mflua$(EXEEXT):mflua-nowin
-endif !MFLUAN
-endif !WIN32
-endif MFLUA
-EXTRA_PROGRAMS += mflua mflua-nowin
-DISTCLEANFILES += mfluatrap.diffs
-
-call_mflua_CPPFLAGS = -DEXEPROG=\"mflua.exe\"
-nodist_call_mflua_SOURCES = callexe.c
-call_mflua_LDADD =
-
-.PHONY: install-mflua-links uninstall-mflua-links
-if WIN32
-install-mflua-links: call_mflua$(EXEEXT)
-if !MFLUAN
- $(INSTALL_PROGRAM) call_mflua$(EXEEXT) $(DESTDIR)$(bindir)/mflua-nowin$(EXEEXT)
-endif !MFLUAN
-uninstall-mflua-links:
-if !MFLUAN
- rm -f $(DESTDIR)$(bindir)/mflua-nowin$(EXEEXT)
-endif !MFLUAN
-endif WIN32
-
-dist_mflua_SOURCES = mfluadir/mfluaextra.c mfluadir/mfluaextra.h mfluadir/mflua_version.h
-mflua_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) $(LUA_INCLUDES)
-mflua_LDADD = libmflua.a libmfluaotfcc.a $(LDADD) $(windowlib) $(mf_x_libs) $(LUA_LIBS)
-mflua_LDFLAGS = -export-dynamic
-nodist_mflua_nowin_SOURCES = $(dist_mflua_SOURCES)
-mflua_nowin_CPPFLAGS = $(mflua_CPPFLAGS) -DMFNOWIN $(LUA_INCLUDES)
-mflua_nowin_LDADD = libmflua.a libmfluaotfcc.a $(LDADD) $(windowlib) $(LUA_LIBS)
-mflua_nowin_LDFLAGS = -export-dynamic
-
-# We must create mfluad.h and mfluadir/mflua_version.h before compiling mfluaextra.c.
-$(mflua_OBJECTS) $(mflua_nowin_OBJECTS): mfluad.h mfluadir/mflua_version.h
-
-## mflua and mflua-nowin compile mfluaextra.c with different CPPFLAGS.
-## Automake, however, does not support CPPFLAGS for individual source files.
-## To avoid compiling everything twice, the common objects are in a library.
-EXTRA_LIBRARIES += libmflua.a libmfluaotfcc.a
-
-# MFLua C sources
-mflua_c_h = mfluaini.c mflua0.c mfluacoerce.h mfluad.h
-dist_libmflua_a_SOURCES = luatexdir/lua/lkpselib.c mfluadir/mfluac.c mfluadir/mfluac.h
-nodist_libmflua_a_SOURCES = $(mflua_c_h) mflua-pool.c
-libmflua_a_CPPFLAGS = $(AM_CPPFLAGS) $(LUA_INCLUDES) -DMF_LUA
-
-# We must create mfluad.h before building the libmflua_a_OBJECTS.
-$(libmflua_a_OBJECTS): mfluad.h
-
-$(mflua_c_h): mflua-web2c
- @$(web2c) mflua
-mflua-web2c: mflua.p $(web2c_texmf) web2c/cvtmf1.sed web2c/cvtmf2.sed mfluadir/mflua.defines $(LUA_DEPEND)
- @$(web2c) mflua
-
-mflua-pool.c: mflua.pool mfluad.h $(makecpool_stamp)
- $(makecpool) mflua >$@ || rm -f $@
-
-# Tangling MFLua
-mflua.p mflua.pool: mflua-tangle
- @$(texmf_tangle) mflua mflua
-mflua-tangle: tangle$(EXEEXT) mflua.web mflua.ch tangle-sh
- @$(texmf_tangle) mflua mflua
-
-# Extract mflua version
-$(srcdir)/mfluadir/mflua_version.h: @MAINTAINER_MODE_TRUE@ mfluadir/mf-lua.ch
- $(AM_V_GEN)grep '^@d MFLua_version_string==' $(srcdir)/mfluadir/mf-lua.ch \
- | sed "s/^.*'-/#define MFLUA_VERSION \"/;s/'.*$$/\"/" >$@
-
-# Generate mflua.web
-mflua.web: tie$(EXEEXT) $(mflua_web_srcs)
- $(tie_m) $(mflua_web_srcs)
-mflua_web_srcs = \
- mf.web \
- mfluadir/mf-lua.ch
-
-# Generate mflua.ch
-mflua.ch: tie$(EXEEXT) mflua.web $(mflua_ch_src)
- $(tie_c) mflua.web $(mflua_ch_src)
-mflua_ch_src = \
- mf.ch \
- mfluadir/mflua-m.ch \
- mf-binpool.ch
-##
-EXTRA_DIST += $(mflua_web_srcs) $(mflua_ch_src) mfluadir/mflua.defines
-
-DISTCLEANFILES += $(nodist_libmflua_a_SOURCES) mflua.web mflua.ch mflua-web2c \
- mflua.p mflua.pool mflua-tangle
-
-EXTRA_DIST += \
- mfluadir/ChangeLog
-
-# MFLua tests
-#
-mflua_tests = mfluadir/mfluatraptest.test
-mfluadir/mfluatraptest.log: mflua$(EXEEXT) gftype$(EXEEXT) tftopl$(EXEEXT)
-EXTRA_DIST += $(mflua_tests)
-
-if MFLUA
-TESTS += $(mflua_tests)
-TRIPTRAP += mfluatrap.diffs
-TRIPTRAP_CLEAN += mfluatrap-clean
-endif MFLUA
-DISTCLEANFILES += mfluatrap.diffs
-
-## mfluadir/mfluatraptest
-mfluatrap.diffs: mflua$(EXEEXT) gftype$(EXEEXT) tftopl$(EXEEXT)
- $(triptrap_diffs) $@
-.PHONY: mfluatrap-clean
-mfluatrap-clean:
- rm -rf mfluatrapdir
-
-## Test data
-##
-EXTRA_DIST += \
- mfluadir/mfluatrap/mflua.lua \
- mfluadir/mfluatrap/mflua_svg_backend.lua \
- mfluadir/mfluatrap/mflua_ttx_backend.lua \
- mfluadir/mfluatrap/texmf.cnf \
- mfluadir/mfluatrap/mfluatrap.diffs
diff --git a/Build/source/texk/web2c/mfluadir/am/mfluaotfcc.am b/Build/source/texk/web2c/mfluadir/am/mfluaotfcc.am
deleted file mode 100644
index 04785f1ef74..00000000000
--- a/Build/source/texk/web2c/mfluadir/am/mfluaotfcc.am
+++ /dev/null
@@ -1,302 +0,0 @@
-## texk/web2c/luatexdir/am/mfluaotfcc.am: Makefile fragment for libmfluaotfcc.
-##
-## Copyright (C) 2021 Luigi Scarso <tex-live@tug.org>
-## You may freely use, modify and/or distribute this file.
-
-## mfluaotfcc
-##
-EXTRA_LIBRARIES += libmfluaotfcc.a libmfluajitotfcc.a
-
-#libmfluaotfcc_a_DEPENDENCIES = $(ZLIB_DEPEND)
-#libmfluajitotfcc_a_DEPENDENCIES = $(ZLIB_DEPEND)
-
-$(libmfluaotfcc_a_OBJECTS): $(LUA_DEPEND)
-$(libmfluajitotfcc_a_OBJECTS): $(LUAJIT_DEPEND)
-
-libmfluaotfcc_a_CPPFLAGS = \
- -std=c99 -D_CARYLL_USE_PRE_SERIALIZED -DMAIN_VER=0 -DSECONDARY_VER=10 -DPATCH_VER=4 \
- -I$(top_srcdir)/mfluadir/otfcc/include \
- -I$(top_srcdir)/mfluadir/otfcc/include/dep \
- -I$(top_srcdir)/mfluadir/otfcc/lib \
- $(LUA_INCLUDES)
-
-
-libmfluajitotfcc_a_CPPFLAGS = \
- -std=c99 -D_CARYLL_USE_PRE_SERIALIZED -DMAIN_VER=0 -DSECONDARY_VER=10 -DPATCH_VER=4 \
- -DJIT \
- -I$(top_srcdir)/mfluadir/otfcc/include \
- -I$(top_srcdir)/mfluadir/otfcc/include/dep \
- -I$(top_srcdir)/mfluadir/otfcc/lib \
- $(LUAJIT_INCLUDES)
-
-libmfluaotfcc_a_CFLAGS = # $(WARNING_CFLAGS)
-libmfluajitotfcc_a_CFLAGS = # $(WARNING_CFLAGS)
-
-#nodist_libmfluaotfcc_a_SOURCES = $(libmfluaotfcc_sources)
-#nodist_libmfluajitotfcc_a_SOURCES = $(libmfluaotfcc_sources)
-
-libmfluaotfcc_a_SOURCES = \
- mfluadir/otfcc/dep/extern/sdsalloc.h \
- mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.c \
- mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.h \
- mfluadir/otfcc/dep/extern/json.c \
- mfluadir/otfcc/dep/extern/json-builder.c \
- mfluadir/otfcc/dep/extern/sds.c \
- mfluadir/otfcc/src/aliases.h \
- mfluadir/otfcc/src/luafunc.c \
- mfluadir/otfcc/src/platform.h \
- mfluadir/otfcc/src/otfccdll.c \
- mfluadir/otfcc/include/dep/json.h \
- mfluadir/otfcc/include/dep/json-builder.h \
- mfluadir/otfcc/include/dep/sds.h \
- mfluadir/otfcc/include/dep/uthash.h \
- mfluadir/otfcc/include/otfcc/options.h \
- mfluadir/otfcc/include/otfcc/primitives.h \
- mfluadir/otfcc/include/otfcc/handle.h \
- mfluadir/otfcc/include/otfcc/vf/vf.h \
- mfluadir/otfcc/include/otfcc/vf/vv.h \
- mfluadir/otfcc/include/otfcc/vf/region.h \
- mfluadir/otfcc/include/otfcc/vf/axis.h \
- mfluadir/otfcc/include/otfcc/vf/vq.h \
- mfluadir/otfcc/include/otfcc/sfnt.h \
- mfluadir/otfcc/include/otfcc/glyph-order.h \
- mfluadir/otfcc/include/otfcc/sfnt-builder.h \
- mfluadir/otfcc/include/otfcc/logger.h \
- mfluadir/otfcc/include/otfcc/font.h \
- mfluadir/otfcc/include/otfcc/table/fvar.h \
- mfluadir/otfcc/include/otfcc/table/maxp.h \
- mfluadir/otfcc/include/otfcc/table/BASE.h \
- mfluadir/otfcc/include/otfcc/table/post.h \
- mfluadir/otfcc/include/otfcc/table/vmtx.h \
- mfluadir/otfcc/include/otfcc/table/glyf.h \
- mfluadir/otfcc/include/otfcc/table/fpgm-prep.h \
- mfluadir/otfcc/include/otfcc/table/vhea.h \
- mfluadir/otfcc/include/otfcc/table/gasp.h \
- mfluadir/otfcc/include/otfcc/table/name.h \
- mfluadir/otfcc/include/otfcc/table/hmtx.h \
- mfluadir/otfcc/include/otfcc/table/OS_2.h \
- mfluadir/otfcc/include/otfcc/table/CPAL.h \
- mfluadir/otfcc/include/otfcc/table/GDEF.h \
- mfluadir/otfcc/include/otfcc/table/TSI5.h \
- mfluadir/otfcc/include/otfcc/table/hdmx.h \
- mfluadir/otfcc/include/otfcc/table/table-common.h \
- mfluadir/otfcc/include/otfcc/table/LTSH.h \
- mfluadir/otfcc/include/otfcc/table/VORG.h \
- mfluadir/otfcc/include/otfcc/table/cmap.h \
- mfluadir/otfcc/include/otfcc/table/_TSI.h \
- mfluadir/otfcc/include/otfcc/table/COLR.h \
- mfluadir/otfcc/include/otfcc/table/CFF.h \
- mfluadir/otfcc/include/otfcc/table/otl/coverage.h \
- mfluadir/otfcc/include/otfcc/table/otl/classdef.h \
- mfluadir/otfcc/include/otfcc/table/otl.h \
- mfluadir/otfcc/include/otfcc/table/cvt.h \
- mfluadir/otfcc/include/otfcc/table/meta.h \
- mfluadir/otfcc/include/otfcc/table/SVG.h \
- mfluadir/otfcc/include/otfcc/table/hhea.h \
- mfluadir/otfcc/include/otfcc/table/VDMX.h \
- mfluadir/otfcc/include/otfcc/table/head.h \
- mfluadir/otfcc/include/caryll/ownership.h \
- mfluadir/otfcc/include/caryll/element.h \
- mfluadir/otfcc/include/caryll/buffer.h \
- mfluadir/otfcc/include/caryll/vector.h \
- mfluadir/otfcc/lib/consolidate/consolidate.c \
- mfluadir/otfcc/lib/consolidate/consolidate.h \
- mfluadir/otfcc/lib/consolidate/otl/gpos-single.h \
- mfluadir/otfcc/lib/consolidate/otl/gsub-single.c \
- mfluadir/otfcc/lib/consolidate/otl/gpos-single.c \
- mfluadir/otfcc/lib/consolidate/otl/chaining.c \
- mfluadir/otfcc/lib/consolidate/otl/common.c \
- mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.h \
- mfluadir/otfcc/lib/consolidate/otl/gpos-pair.h \
- mfluadir/otfcc/lib/consolidate/otl/gsub-single.h \
- mfluadir/otfcc/lib/consolidate/otl/chaining.h \
- mfluadir/otfcc/lib/consolidate/otl/GDEF.h \
- mfluadir/otfcc/lib/consolidate/otl/gsub-multi.c \
- mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.c \
- mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.h \
- mfluadir/otfcc/lib/consolidate/otl/mark.h \
- mfluadir/otfcc/lib/consolidate/otl/common.h \
- mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.c \
- mfluadir/otfcc/lib/consolidate/otl/GDEF.c \
- mfluadir/otfcc/lib/consolidate/otl/gpos-pair.c \
- mfluadir/otfcc/lib/consolidate/otl/gsub-multi.h \
- mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.c \
- mfluadir/otfcc/lib/consolidate/otl/mark.c \
- mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.h \
- mfluadir/otfcc/lib/support/options.c \
- mfluadir/otfcc/lib/support/aliases.h \
- mfluadir/otfcc/lib/support/tag.h \
- mfluadir/otfcc/lib/support/bin-io.h \
- mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c \
- mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h \
- mfluadir/otfcc/lib/support/handle.c \
- mfluadir/otfcc/lib/support/otfcc-alloc.h \
- mfluadir/otfcc/lib/support/util.h \
- mfluadir/otfcc/lib/support/element-impl.h \
- mfluadir/otfcc/lib/support/buffer/buffer.c \
- mfluadir/otfcc/lib/support/vector-impl.h \
- mfluadir/otfcc/lib/support/primitives.c \
- mfluadir/otfcc/lib/support/glyph-order.c \
- mfluadir/otfcc/lib/support/sha1/sha1.h \
- mfluadir/otfcc/lib/support/sha1/sha1.c \
- mfluadir/otfcc/lib/support/ttinstr/ttinstr.c \
- mfluadir/otfcc/lib/support/ttinstr/ttinstr.h \
- mfluadir/otfcc/lib/support/base64/base64.h \
- mfluadir/otfcc/lib/support/base64/base64.c \
- mfluadir/otfcc/lib/support/json/json-ident.c \
- mfluadir/otfcc/lib/support/json/json-funcs.h \
- mfluadir/otfcc/lib/support/json/json-ident.h \
- mfluadir/otfcc/lib/support/aglfn/aglfn.c \
- mfluadir/otfcc/lib/support/aglfn/aglfn.h \
- mfluadir/otfcc/lib/otf-writer/stat.h \
- mfluadir/otfcc/lib/otf-writer/stat.c \
- mfluadir/otfcc/lib/otf-writer/otf-writer.c \
- mfluadir/otfcc/lib/otf-reader/otf-reader.c \
- mfluadir/otfcc/lib/otf-reader/unconsolidate.c \
- mfluadir/otfcc/lib/otf-reader/unconsolidate.h \
- mfluadir/otfcc/lib/vf/axis.c \
- mfluadir/otfcc/lib/vf/region.c \
- mfluadir/otfcc/lib/vf/vq.c \
- mfluadir/otfcc/lib/logger/logger.c \
- mfluadir/otfcc/lib/bk/bkblock.h \
- mfluadir/otfcc/lib/bk/bkgraph.h \
- mfluadir/otfcc/lib/bk/bkgraph.c \
- mfluadir/otfcc/lib/bk/bkblock.c \
- mfluadir/otfcc/lib/font/caryll-font.c \
- mfluadir/otfcc/lib/font/caryll-sfnt-builder.c \
- mfluadir/otfcc/lib/font/caryll-sfnt.c \
- mfluadir/otfcc/lib/json-writer/json-writer.c \
- mfluadir/otfcc/lib/json-reader/json-reader.c \
- mfluadir/otfcc/lib/libcff/charstring-il.h \
- mfluadir/otfcc/lib/libcff/cff-index.h \
- mfluadir/otfcc/lib/libcff/cff-dict.h \
- mfluadir/otfcc/lib/libcff/cff-value.h \
- mfluadir/otfcc/lib/libcff/cff-string.c \
- mfluadir/otfcc/lib/libcff/cff-opmean.c \
- mfluadir/otfcc/lib/libcff/libcff.h \
- mfluadir/otfcc/lib/libcff/charstring-il.c \
- mfluadir/otfcc/lib/libcff/cff-fdselect.c \
- mfluadir/otfcc/lib/libcff/cff-parser.c \
- mfluadir/otfcc/lib/libcff/subr.c \
- mfluadir/otfcc/lib/libcff/cff-charset.c \
- mfluadir/otfcc/lib/libcff/cff-index.c \
- mfluadir/otfcc/lib/libcff/cff-codecs.c \
- mfluadir/otfcc/lib/libcff/cff-charset.h \
- mfluadir/otfcc/lib/libcff/cff-util.h \
- mfluadir/otfcc/lib/libcff/cff-writer.c \
- mfluadir/otfcc/lib/libcff/subr.h \
- mfluadir/otfcc/lib/libcff/cff-fdselect.h \
- mfluadir/otfcc/lib/libcff/cff-dict.c \
- mfluadir/otfcc/lib/libcff/cff-value.c \
- mfluadir/otfcc/lib/table/vhea.c \
- mfluadir/otfcc/lib/table/fvar.c \
- mfluadir/otfcc/lib/table/cmap.c \
- mfluadir/otfcc/lib/table/meta/read.c \
- mfluadir/otfcc/lib/table/meta/type.c \
- mfluadir/otfcc/lib/table/meta/build.c \
- mfluadir/otfcc/lib/table/meta/parse.c \
- mfluadir/otfcc/lib/table/meta/dump.c \
- mfluadir/otfcc/lib/table/vdmx/type.c \
- mfluadir/otfcc/lib/table/vdmx/funcs.c \
- mfluadir/otfcc/lib/table/hhea.c \
- mfluadir/otfcc/lib/table/fvar.h \
- mfluadir/otfcc/lib/table/maxp.h \
- mfluadir/otfcc/lib/table/BASE.h \
- mfluadir/otfcc/lib/table/post.h \
- mfluadir/otfcc/lib/table/post.c \
- mfluadir/otfcc/lib/table/cvt.c \
- mfluadir/otfcc/lib/table/CFF.c \
- mfluadir/otfcc/lib/table/vmtx.h \
- mfluadir/otfcc/lib/table/glyf.h \
- mfluadir/otfcc/lib/table/gasp.c \
- mfluadir/otfcc/lib/table/LTSH.c \
- mfluadir/otfcc/lib/table/maxp.c \
- mfluadir/otfcc/lib/table/fpgm-prep.h \
- mfluadir/otfcc/lib/table/all.h \
- mfluadir/otfcc/lib/table/COLR.c \
- mfluadir/otfcc/lib/table/vmtx.c \
- mfluadir/otfcc/lib/table/vhea.h \
- mfluadir/otfcc/lib/table/gasp.h \
- mfluadir/otfcc/lib/table/fpgm-prep.c \
- mfluadir/otfcc/lib/table/name.h \
- mfluadir/otfcc/lib/table/hmtx.h \
- mfluadir/otfcc/lib/table/head.c \
- mfluadir/otfcc/lib/table/OS_2.h \
- mfluadir/otfcc/lib/table/CPAL.c \
- mfluadir/otfcc/lib/table/CPAL.h \
- mfluadir/otfcc/lib/table/GDEF.h \
- mfluadir/otfcc/lib/table/TSI5.h \
- mfluadir/otfcc/lib/table/hdmx.h \
- mfluadir/otfcc/lib/table/_TSI.c \
- mfluadir/otfcc/lib/table/LTSH.h \
- mfluadir/otfcc/lib/table/VORG.h \
- mfluadir/otfcc/lib/table/name.c \
- mfluadir/otfcc/lib/table/cmap.h \
- mfluadir/otfcc/lib/table/OS_2.c \
- mfluadir/otfcc/lib/table/hdmx.c \
- mfluadir/otfcc/lib/table/glyf/read.c \
- mfluadir/otfcc/lib/table/glyf/glyf.c \
- mfluadir/otfcc/lib/table/glyf/build.c \
- mfluadir/otfcc/lib/table/_TSI.h \
- mfluadir/otfcc/lib/table/GDEF.c \
- mfluadir/otfcc/lib/table/COLR.h \
- mfluadir/otfcc/lib/table/VORG.c \
- mfluadir/otfcc/lib/table/CFF.h \
- mfluadir/otfcc/lib/table/otl/coverage.c \
- mfluadir/otfcc/lib/table/otl/read.c \
- mfluadir/otfcc/lib/table/otl/private.h \
- mfluadir/otfcc/lib/table/otl/classdef.c \
- mfluadir/otfcc/lib/table/otl/build.c \
- mfluadir/otfcc/lib/table/otl/parse.c \
- mfluadir/otfcc/lib/table/otl/dump.c \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-single.h \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-single.c \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-common.h \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-single.c \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.h \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.h \
- mfluadir/otfcc/lib/table/otl/subtables/chaining/read.c \
- mfluadir/otfcc/lib/table/otl/subtables/chaining/common.c \
- mfluadir/otfcc/lib/table/otl/subtables/chaining/classifier.c \
- mfluadir/otfcc/lib/table/otl/subtables/chaining/build.c \
- mfluadir/otfcc/lib/table/otl/subtables/chaining/common.h \
- mfluadir/otfcc/lib/table/otl/subtables/chaining/parse.c \
- mfluadir/otfcc/lib/table/otl/subtables/chaining/dump.c \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-single.h \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.c \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.c \
- mfluadir/otfcc/lib/table/otl/subtables/chaining.h \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.c \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.c \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.h \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-common.c \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.h \
- mfluadir/otfcc/lib/table/otl/subtables/common.h \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.c \
- mfluadir/otfcc/lib/table/otl/subtables/extend.c \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.c \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.h \
- mfluadir/otfcc/lib/table/otl/subtables/extend.h \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.h \
- mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.c \
- mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.h \
- mfluadir/otfcc/lib/table/otl/otl.c \
- mfluadir/otfcc/lib/table/otl/constants.c \
- mfluadir/otfcc/lib/table/hmtx.c \
- mfluadir/otfcc/lib/table/otl.h \
- mfluadir/otfcc/lib/table/cvt.h \
- mfluadir/otfcc/lib/table/meta.h \
- mfluadir/otfcc/lib/table/SVG.h \
- mfluadir/otfcc/lib/table/hhea.h \
- mfluadir/otfcc/lib/table/BASE.c \
- mfluadir/otfcc/lib/table/VDMX.h \
- mfluadir/otfcc/lib/table/SVG.c \
- mfluadir/otfcc/lib/table/head.h \
- mfluadir/otfcc/lib/table/TSI5.c
-
-##
-#EXTRA_DIST +=
-
-## Not used
-##
-#EXTRA_DIST +=
diff --git a/Build/source/texk/web2c/mfluadir/mf-lua.ch b/Build/source/texk/web2c/mfluadir/mf-lua.ch
deleted file mode 100644
index 4cb2d72e9ab..00000000000
--- a/Build/source/texk/web2c/mfluadir/mf-lua.ch
+++ /dev/null
@@ -1,528 +0,0 @@
-@x [0] MFLua
-% This program is copyright (C) 1984 by D. E. Knuth; all rights are reserved.
-@y
-% This program is MFLua, strictly based on the METAFONT 2.71828182 source code.
-% What follow are the original comments of METAFONT 2.71828182.
-
-% This program is copyright (C) 1984 by D. E. Knuth; all rights are reserved.
-@z
-
-@x [0] MFLua
-\def\MF{{\tenlogo META}\-{\tenlogo FONT}}
-@y
-%\def\MF{{\tenlogo META}\-{\tenlogo FONT}}
-\def\MF{{\tenlogo MF}{\mc LUA}}
-@z
-
-@x [1.2] MFLua
-@d banner=='This is METAFONT, Version 2.71828182' {printed when \MF\ starts}
-@y
-@d METAFONT_banner=='This is METAFONT, Version 2.71828182' {printed when \MF\ starts}
-@#
-@d MFLua_version_string=='-1.0.0-alpha'
-@#
-@d MFLua_banner=='This is MFLua, Version 2.71828182', MFLua_version_string
- {printed when MFLua starts}
-@#
-@d banner==MFLua_banner
-@z
-
-@x [12.186] MFLua - runscript primitive
-At any rate, here is the list, for future reference.
-
-@d if_test=1 {conditional text (\&{if})}
-@d fi_or_else=2 {delimiters for conditionals (\&{elseif}, \&{else}, \&{fi})}
-@d input=3 {input a source file (\&{input}, \&{endinput})}
-@d iteration=4 {iterate (\&{for}, \&{forsuffixes}, \&{forever}, \&{endfor})}
-@d repeat_loop=5 {special command substituted for \&{endfor}}
-@d exit_test=6 {premature exit from a loop (\&{exitif})}
-@d relax=7 {do nothing (\.{\char`\\})}
-@d scan_tokens=8 {put a string into the input buffer}
-@d expand_after=9 {look ahead one token}
-@d defined_macro=10 {a macro defined by the user}
-@d min_command=defined_macro+1
-@d display_command=11 {online graphic output (\&{display})}
-@d save_command=12 {save a list of tokens (\&{save})}
-@d interim_command=13 {save an internal quantity (\&{interim})}
-@d let_command=14 {redefine a symbolic token (\&{let})}
-@d new_internal=15 {define a new internal quantity (\&{newinternal})}
-@d macro_def=16 {define a macro (\&{def}, \&{vardef}, etc.)}
-@d ship_out_command=17 {output a character (\&{shipout})}
-@d add_to_command=18 {add to edges (\&{addto})}
-@d cull_command=19 {cull and normalize edges (\&{cull})}
-@d tfm_command=20 {command for font metric info (\&{ligtable}, etc.)}
-@d protection_command=21 {set protection flag (\&{outer}, \&{inner})}
-@d show_command=22 {diagnostic output (\&{show}, \&{showvariable}, etc.)}
-@d mode_command=23 {set interaction level (\&{batchmode}, etc.)}
-@d random_seed=24 {initialize random number generator (\&{randomseed})}
-@d message_command=25 {communicate to user (\&{message}, \&{errmessage})}
-@d every_job_command=26 {designate a starting token (\&{everyjob})}
-@d delimiters=27 {define a pair of delimiters (\&{delimiters})}
-@d open_window=28 {define a window on the screen (\&{openwindow})}
-@d special_command=29 {output special info (\&{special}, \&{numspecial})}
-@d type_name=30 {declare a type (\&{numeric}, \&{pair}, etc.)}
-@d max_statement_command=type_name
-@d min_primary_command=type_name
-@d left_delimiter=31 {the left delimiter of a matching pair}
-@d begin_group=32 {beginning of a group (\&{begingroup})}
-@d nullary=33 {an operator without arguments (e.g., \&{normaldeviate})}
-@d unary=34 {an operator with one argument (e.g., \&{sqrt})}
-@d str_op=35 {convert a suffix to a string (\&{str})}
-@d cycle=36 {close a cyclic path (\&{cycle})}
-@d primary_binary=37 {binary operation taking `\&{of}' (e.g., \&{point})}
-@d capsule_token=38 {a value that has been put into a token list}
-@d string_token=39 {a string constant (e.g., |"hello"|)}
-@d internal_quantity=40 {internal numeric parameter (e.g., \&{pausing})}
-@d min_suffix_token=internal_quantity
-@d tag_token=41 {a symbolic token without a primitive meaning}
-@d numeric_token=42 {a numeric constant (e.g., \.{3.14159})}
-@d max_suffix_token=numeric_token
-@d plus_or_minus=43 {either `\.+' or `\.-'}
-@d max_primary_command=plus_or_minus {should also be |numeric_token+1|}
-@d min_tertiary_command=plus_or_minus
-@d tertiary_secondary_macro=44 {a macro defined by \&{secondarydef}}
-@d tertiary_binary=45 {an operator at the tertiary level (e.g., `\.{++}')}
-@d max_tertiary_command=tertiary_binary
-@d left_brace=46 {the operator `\.{\char`\{}'}
-@d min_expression_command=left_brace
-@d path_join=47 {the operator `\.{..}'}
-@d ampersand=48 {the operator `\.\&'}
-@d expression_tertiary_macro=49 {a macro defined by \&{tertiarydef}}
-@d expression_binary=50 {an operator at the expression level (e.g., `\.<')}
-@d equals=51 {the operator `\.='}
-@d max_expression_command=equals
-@d and_command=52 {the operator `\&{and}'}
-@d min_secondary_command=and_command
-@d secondary_primary_macro=53 {a macro defined by \&{primarydef}}
-@d slash=54 {the operator `\./'}
-@d secondary_binary=55 {an operator at the binary level (e.g., \&{shifted})}
-@d max_secondary_command=secondary_binary
-@d param_type=56 {type of parameter (\&{primary}, \&{expr}, \&{suffix}, etc.)}
-@d controls=57 {specify control points explicitly (\&{controls})}
-@d tension=58 {specify tension between knots (\&{tension})}
-@d at_least=59 {bounded tension value (\&{atleast})}
-@d curl_command=60 {specify curl at an end knot (\&{curl})}
-@d macro_special=61 {special macro operators (\&{quote}, \.{\#\AT!}, etc.)}
-@d right_delimiter=62 {the right delimiter of a matching pair}
-@d left_bracket=63 {the operator `\.['}
-@d right_bracket=64 {the operator `\.]'}
-@d right_brace=65 {the operator `\.{\char`\}}'}
-@d with_option=66 {option for filling (\&{withpen}, \&{withweight})}
-@d cull_op=67 {the operator `\&{keeping}' or `\&{dropping}'}
-@d thing_to_add=68
- {variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also})}
-@d of_token=69 {the operator `\&{of}'}
-@d from_token=70 {the operator `\&{from}'}
-@d to_token=71 {the operator `\&{to}'}
-@d at_token=72 {the operator `\&{at}'}
-@d in_window=73 {the operator `\&{inwindow}'}
-@d step_token=74 {the operator `\&{step}'}
-@d until_token=75 {the operator `\&{until}'}
-@d lig_kern_token=76
- {the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc.}
-@d assignment=77 {the operator `\.{:=}'}
-@d skip_to=78 {the operation `\&{skipto}'}
-@d bchar_label=79 {the operator `\.{\char'174\char'174:}'}
-@d double_colon=80 {the operator `\.{::}'}
-@d colon=81 {the operator `\.:'}
-@#
-@d comma=82 {the operator `\.,', must be |colon+1|}
-@d end_of_statement==cur_cmd>comma
-@d semicolon=83 {the operator `\.;', must be |comma+1|}
-@d end_group=84 {end a group (\&{endgroup}), must be |semicolon+1|}
-@d stop=85 {end a job (\&{end}, \&{dump}), must be |end_group+1|}
-@d max_command_code=stop
-@d outer_tag=max_command_code+1 {protection code added to command code}
-@y
-At any rate, here is the list, for future reference.
-
-@d delta_code=1 {n. of new primitives added }
-@d if_test=1 {conditional text (\&{if})}
-@d fi_or_else=2 {delimiters for conditionals (\&{elseif}, \&{else}, \&{fi})}
-@d input=3 {input a source file (\&{input}, \&{endinput})}
-@d iteration=4 {iterate (\&{for}, \&{forsuffixes}, \&{forever}, \&{endfor})}
-@d repeat_loop=5 {special command substituted for \&{endfor}}
-@d exit_test=6 {premature exit from a loop (\&{exitif})}
-@d relax=7 {do nothing (\.{\char`\\})}
-@d scan_tokens=8 {put a string into the input buffer}
-@d run_script=8+delta_code {execute a Lua script}
-@d expand_after=9+delta_code {look ahead one token}
-@d defined_macro=10+delta_code {a macro defined by the user}
-@d min_command=defined_macro+1
-@d display_command=11+delta_code {online graphic output (\&{display})}
-@d save_command=12+delta_code {save a list of tokens (\&{save})}
-@d interim_command=13+delta_code {save an internal quantity (\&{interim})}
-@d let_command=14+delta_code {redefine a symbolic token (\&{let})}
-@d new_internal=15+delta_code {define a new internal quantity (\&{newinternal})}
-@d macro_def=16+delta_code {define a macro (\&{def}, \&{vardef}, etc.)}
-@d ship_out_command=17+delta_code {output a character (\&{shipout})}
-@d add_to_command=18+delta_code {add to edges (\&{addto})}
-@d cull_command=19+delta_code {cull and normalize edges (\&{cull})}
-@d tfm_command=20+delta_code {command for font metric info (\&{ligtable}, etc.)}
-@d protection_command=21+delta_code {set protection flag (\&{outer}, \&{inner})}
-@d show_command=22+delta_code {diagnostic output (\&{show}, \&{showvariable}, etc.)}
-@d mode_command=23+delta_code {set interaction level (\&{batchmode}, etc.)}
-@d random_seed=24+delta_code {initialize random number generator (\&{randomseed})}
-@d message_command=25+delta_code {communicate to user (\&{message}, \&{errmessage})}
-@d every_job_command=26+delta_code {designate a starting token (\&{everyjob})}
-@d delimiters=27+delta_code {define a pair of delimiters (\&{delimiters})}
-@d open_window=28+delta_code {define a window on the screen (\&{openwindow})}
-@d special_command=29+delta_code {output special info (\&{special}, \&{numspecial})}
-@d type_name=30+delta_code {declare a type (\&{numeric}, \&{pair}, etc.)}
-@d max_statement_command=type_name
-@d min_primary_command=type_name
-@d left_delimiter=31+delta_code {the left delimiter of a matching pair}
-@d begin_group=32+delta_code {beginning of a group (\&{begingroup})}
-@d nullary=33+delta_code {an operator without arguments (e.g., \&{normaldeviate})}
-@d unary=34+delta_code {an operator with one argument (e.g., \&{sqrt})}
-@d str_op=35+delta_code {convert a suffix to a string (\&{str})}
-@d cycle=36+delta_code {close a cyclic path (\&{cycle})}
-@d primary_binary=37+delta_code {binary operation taking `\&{of}' (e.g., \&{point})}
-@d capsule_token=38+delta_code {a value that has been put into a token list}
-@d string_token=39+delta_code {a string constant (e.g., |"hello"|)}
-@d internal_quantity=40+delta_code {internal numeric parameter (e.g., \&{pausing})}
-@d min_suffix_token=internal_quantity
-@d tag_token=41+delta_code {a symbolic token without a primitive meaning}
-@d numeric_token=42+delta_code {a numeric constant (e.g., \.{3.14159})}
-@d max_suffix_token=numeric_token
-@d plus_or_minus=43+delta_code {either `\.+' or `\.-'}
-@d max_primary_command=plus_or_minus {should also be |numeric_token+1|}
-@d min_tertiary_command=plus_or_minus
-@d tertiary_secondary_macro=44+delta_code {a macro defined by \&{secondarydef}}
-@d tertiary_binary=45+delta_code {an operator at the tertiary level (e.g., `\.{++}')}
-@d max_tertiary_command=tertiary_binary
-@d left_brace=46+delta_code {the operator `\.{\char`\{}'}
-@d min_expression_command=left_brace
-@d path_join=47+delta_code {the operator `\.{..}'}
-@d ampersand=48+delta_code {the operator `\.\&'}
-@d expression_tertiary_macro=49+delta_code {a macro defined by \&{tertiarydef}}
-@d expression_binary=50+delta_code {an operator at the expression level (e.g., `\.<')}
-@d equals=51+delta_code {the operator `\.='}
-@d max_expression_command=equals
-@d and_command=52+delta_code {the operator `\&{and}'}
-@d min_secondary_command=and_command
-@d secondary_primary_macro=53+delta_code {a macro defined by \&{primarydef}}
-@d slash=54+delta_code {the operator `\./'}
-@d secondary_binary=55+delta_code {an operator at the binary level (e.g., \&{shifted})}
-@d max_secondary_command=secondary_binary
-@d param_type=56+delta_code {type of parameter (\&{primary}, \&{expr}, \&{suffix}, etc.)}
-@d controls=57+delta_code {specify control points explicitly (\&{controls})}
-@d tension=58+delta_code {specify tension between knots (\&{tension})}
-@d at_least=59+delta_code {bounded tension value (\&{atleast})}
-@d curl_command=60+delta_code {specify curl at an end knot (\&{curl})}
-@d macro_special=61+delta_code {special macro operators (\&{quote}, \.{\#\AT!}, etc.)}
-@d right_delimiter=62+delta_code {the right delimiter of a matching pair}
-@d left_bracket=63+delta_code {the operator `\.['}
-@d right_bracket=64+delta_code {the operator `\.]'}
-@d right_brace=65+delta_code {the operator `\.{\char`\}}'}
-@d with_option=66+delta_code {option for filling (\&{withpen}, \&{withweight})}
-@d cull_op=67+delta_code {the operator `\&{keeping}' or `\&{dropping}'}
-@d thing_to_add=68+delta_code
- {variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also})}
-@d of_token=69+delta_code {the operator `\&{of}'}
-@d from_token=70+delta_code {the operator `\&{from}'}
-@d to_token=71+delta_code {the operator `\&{to}'}
-@d at_token=72+delta_code {the operator `\&{at}'}
-@d in_window=73+delta_code {the operator `\&{inwindow}'}
-@d step_token=74+delta_code {the operator `\&{step}'}
-@d until_token=75+delta_code {the operator `\&{until}'}
-@d lig_kern_token=76+delta_code
- {the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc.}
-@d assignment=77+delta_code {the operator `\.{:=}'}
-@d skip_to=78+delta_code {the operation `\&{skipto}'}
-@d bchar_label=79+delta_code {the operator `\.{\char'174\char'174:}'}
-@d double_colon=80+delta_code {the operator `\.{::}'}
-@d colon=81+delta_code {the operator `\.:'}
-@#
-@d comma=82+delta_code {the operator `\.,', must be |colon+1|}
-@d end_of_statement==cur_cmd>comma
-@d semicolon=83+delta_code {the operator `\.;', must be |comma+1|}
-@d end_group=84+delta_code {end a group (\&{endgroup}), must be |semicolon+1|}
-@d stop=85+delta_code {end a job (\&{end}, \&{dump}), must be |end_group+1|}
-@d max_command_code=stop
-@d outer_tag=max_command_code+1 {protection code added to command code}
-@z
-
-@x [13.211] MFLua - runscript primitive
-primitive("randomseed",random_seed,0);@/
-@!@:random_seed_}{\&{randomseed} primitive@>
-@y
-primitive("randomseed",random_seed,0);@/
-@!@:random_seed_}{\&{randomseed} primitive@>
-primitive("runscript",run_script,0);@/
-@!@:run_script_}{\&{runscript} primitive@>
-@z
-
-@x [13.212] MFLua - runscript primitive
-right_bracket:print("]");
-@y
-right_bracket:print("]");
-run_script:print("runscript");
-@z
-
-@x [17.257] MFLua
-begin print_diagnostic("Path",s,nuline); print_ln;
-@y
-begin
-mflua_printpath(h,s,nuline);
-print_diagnostic("Path",s,nuline); print_ln;
-@z
-
-@x [20.332] MFLua
-begin print_diagnostic("Edge structure",s,nuline);
-@y
-begin
-{mflua\_printedges(s,nuline,x\_off,y\_off);}
-print_diagnostic("Edge structure",s,nuline);
-@z
-
-@x [22.465] MFLua
- move_to_edges(m0,n0,m1,n1);
-@y
- mflua_PRE_move_to_edges(p);
- move_to_edges(m0,n0,m1,n1);
- mflua_POST_move_to_edges(p);
-@z
-
-@x [24.491] MFLua
-begin p:=c; n:=info(h); lh:=link(h); {now |lh| points to $w_0$}
-@y
-begin
-{mflua\_offsetprep(c,h);}
-p:=c; n:=info(h); lh:=link(h); {now |lh| points to $w_0$}
-@z
-
-@x [24.506] MFLua
-offset_prep(p,h); {this may clobber node~|q|, if it becomes ``dead''}
-@y
-mfluaPRE_offset_prep(p,h);
-offset_prep(p,h); {this may clobber node~|q|, if it becomes ``dead''}
-mfluaPOST_offset_prep(p,h);
-@z
-
-@x [24.519] MFLua
- unskew(x1,y1,octant);@/
-@y
- unskew(x1,y1,octant);@/
- mflua_print_retrograde_line(x0,y0,cur_x,cur_y);
-@z
-
-@x [24.515] MFLua
-begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
-@y
-begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
-mflua_print_transition_line_from(xx,yy-half_unit);
-@z
-
-@x [24.515] MFLua
-else begin decr(k); w:=knil(w);
- xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
- end;
-@y
-else begin decr(k); w:=knil(w);
- xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
- end;
-mflua_print_transition_line_to(xp,yp-half_unit);
-@z
-
-@x [24.521] MFLua
-@<Insert a line segment dually to approach the correct offset@>=
-begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
-@y
-@<Insert a line segment dually to approach the correct offset@>=
-begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
-mflua_print_transition_line_from(xx,yy-half_unit);
-@z
-
-@x [24.521] MFLua
-else begin incr(k); w:=link(w);
- xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
- end;
-@y
-else begin incr(k); w:=link(w);
- xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
- end;
-mflua_print_transition_line_to(xp,yp-half_unit);
-@z
-
-@x [31.630] MFLua - runscript primitive
-moved into the buffer by \&{scantokens}.
-@y
-moved into the buffer by \&{scantokens} or \&{runscript}.
-@z
-
-@x [31.637] MFLua - runscript primitive
-else if name=2 then print_nl("<scantokens>")
-@y
-else if name=2 then print_nl("<scantokens> or <runscript>")
-@z
-
-@x [33.679] MFLua - runscript primitive
- {text was inserted during error recovery or by \&{scantokens}}
-@y
- {text was inserted during error recovery or by \&{scantokens} or \&{runscript}}
-@z
-
-@x [35.706] MFLua - runscript primitive
-|exit_test|, |relax|, |scan_tokens|, |expand_after|, and |defined_macro|.
-@y
-|exit_test|, |relax|, |scan_tokens|, |run_script|, |expand_after|, and |defined_macro|.
-@z
-
-@x [35.707] MFLua - runscript primitive
-scan_tokens: @<Put a string into the input buffer@>;
-@y
-scan_tokens: @<Put a string into the input buffer@>;
-run_script: @<Pass a string to the Lua interpreter and put the result string into the input buffer@>;
-@z
-
-@x [39.796] MFLua - runscript primitive
-@!cur_exp:integer; {the value of the expression just found}
-@y
-@!cur_exp:integer; {the value of the expression just found}
-@!lua_cur_exp:integer; {the value of the Lua expression returned by runscript}
-@z
-
-@x [41.866] MFLua
-q:=make_ellipse(major_axis,minor_axis,theta);
-if (tx<>0)or(ty<>0) then @<Shift the coordinates of path |q|@>;
-@y
-mfluaPRE_make_ellipse(major_axis,minor_axis,theta,tx,ty,0);
-q:=make_ellipse(major_axis,minor_axis,theta);
-if (tx<>0)or(ty<>0) then @<Shift the coordinates of path |q|@>;
-mfluaPOST_make_ellipse(major_axis,minor_axis,theta,tx,ty,q);
-@z
-
-@x [41.891] MFLua
-make_choices(p);
-@y
-mfluaPRE_make_choices(p);
-make_choices(p);
-mfluaPOST_make_choices(p);
-@z
-
-@x [44.1064] MFLua
- cur_wt:=w; rhs:=make_spec(rhs,max_offset(cur_pen),internal[tracing_specs]);
- @<Check the turning number@>;
- if max_offset(cur_pen)=0 then fill_spec(rhs)
- else fill_envelope(rhs);
- if lhs<>null then
- begin rev_turns:=true;
- lhs:=make_spec(lhs,max_offset(cur_pen),internal[tracing_specs]);
- rev_turns:=false;
- if max_offset(cur_pen)=0 then fill_spec(lhs)
- else fill_envelope(lhs);
-@y
- cur_wt:=w; mfluaPRE_make_spec_rhs(rhs); rhs:=make_spec(rhs,max_offset(cur_pen),internal[tracing_specs]);mfluaPOST_make_spec_rhs(rhs);
- @<Check the turning number@>;
- if max_offset(cur_pen)=0 then begin mfluaPRE_fill_spec_rhs(rhs); fill_spec(rhs); mfluaPOST_fill_spec_rhs(rhs);end
- else begin mfluaPRE_fill_envelope_rhs(rhs); fill_envelope(rhs); mfluaPOST_fill_envelope_rhs(rhs); end ;
- if lhs<>null then
- begin rev_turns:=true;
- mfluaPRE_make_spec_lhs(lhs);
- lhs:=make_spec(lhs,max_offset(cur_pen),internal[tracing_specs]);
- mfluaPOST_make_spec_lhs(lhs);
- rev_turns:=false;
- if max_offset(cur_pen)=0 then begin mfluaPRE_fill_spec_lhs(lhs); fill_spec(lhs); mfluaPOST_fill_spec_lhs(lhs); end
- else begin mfluaPRE_fill_envelope_lhs(lhs); fill_envelope(lhs); mfluaPOST_fill_envelope_lhs(lhs); end;
-@z
-
-@x [47.1165] MFLua
-print_char("]"); update_terminal; {progress report}
-@y
-print_char("]"); update_terminal; {progress report}
-mflua_printedges(" (just shipped out)",true,x_off,y_off);
-@z
-
-@x [49.1204] MFLua
-@p begin @!{|start_here|}
-@y
-@p begin @!{|start_here|}
-mflua_begin_program;
-@z
-
-@x [49.1204] MFLua
-start_of_MF: @<Initialize the output routines@>;
-@<Get the first line of input and prepare to start@>;
-history:=spotless; {ready to go!}
-if start_sym>0 then {insert the `\&{everyjob}' symbol}
- begin cur_sym:=start_sym; back_input;
- end;
-main_control; {come to life}
-final_cleanup; {prepare for death}
-@y
-mfluaPRE_start_of_MF;
-start_of_MF: @<Initialize the output routines@>;
-@<Get the first line of input and prepare to start@>;
-history:=spotless; {ready to go!}
-{This was the first sensor. Original comment: "remember to modify web2c/texmf.defines by adding mfuainitialize and then texmfmp.h and lib/texmfmp.c". Now obsolete}
-mflua_initialize;
-if start_sym>0 then {insert the `\&{everyjob}' symbol}
- begin cur_sym:=start_sym; back_input;
- end;
-mfluaPRE_main_control;
-main_control; {come to life}
-mfluaPOST_main_control;
-final_cleanup; {prepare for death}
-mfluaPOST_final_cleanup;
-@z
-
-@x [49.1205] MFLua
- end;
-end;
-@y
- end;
-mflua_end_program;
-end;
-@z
-
-@x [51.1214] MFLua - additional sections to handle runscript
-@* \[51] System-dependent changes.
-@y
-@ @<Pass a string to the Lua interpreter and put the result string into the input buffer@>=
-begin get_x_next; scan_primary;
-if cur_type<>string_type then
- begin disp_err(null,"Not a string");
-@.Not a string@>
- help2("I'm going to flush this expression, since")@/
- ("runscript should be followed by a known string.");
- put_get_flush_error(0);
- end
-else begin back_input;
- if length(cur_exp)>0 then @<As for scantokens, pretend we're reading a new one-line file@>;
- end;
-end
-
-@ @<As for scantokens, pretend we're reading a new one-line file@>=
-begin {begin\_file\_reading;} name:=2; {should be name:=3 but for the moment we keep 2}
-k:=first+length(cur_exp);
-j:=str_start[cur_exp]; limit:=k;
-mflua_runscript(j,first,limit);
-lua_cur_exp:=make_string;
-if length(lua_cur_exp)> 0 then
-begin
- begin_file_reading;
- add_str_ref(lua_cur_exp);
- j:=str_start[lua_cur_exp]; k:=first+length(lua_cur_exp);limit:=k;
- if k>=max_buf_stack then
- begin if k>=buf_size then
- begin max_buf_stack:=buf_size;
- overflow("buffer size",buf_size);
-@:METAFONT capacity exceeded buffer size}{\quad buffer size@>
- end;
- max_buf_stack:=k+1;
- end;
- while first<limit do
- begin
- {print(" loop");print\_ln;}
- buffer[first]:=so(str_pool[j]); {print(so(str\_pool[j]));} incr(j); incr(first);
- end;
- buffer[limit]:="%"; first:=limit+1; loc:=start;
- delete_str_ref(lua_cur_exp);
-end;
-delete_str_ref(lua_cur_exp);
-{flush_string(lua_cur_exp);}
-flush_cur_exp(0);
-end
-@* \[51] System-dependent changes.
-@z \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mflua-m.ch b/Build/source/texk/web2c/mfluadir/mflua-m.ch
deleted file mode 100644
index 2f532ea09ca..00000000000
--- a/Build/source/texk/web2c/mfluadir/mflua-m.ch
+++ /dev/null
@@ -1,12 +0,0 @@
-@x [1.11]
-@!max_strings=7500; {maximum number of strings; must not exceed |max_halfword|}
-@y
-@!max_strings=1048574; {maximum number of strings; must not exceed |max_halfword|}
-@z
-
-@x [1.11]
-@!pool_size=100000; {maximum number of characters in strings, including all
-@y
-@!pool_size=10000000; {maximum number of characters in strings, including all
-@z
-
diff --git a/Build/source/texk/web2c/mfluadir/mflua.defines b/Build/source/texk/web2c/mfluadir/mflua.defines
deleted file mode 100644
index f142ef4c5b1..00000000000
--- a/Build/source/texk/web2c/mfluadir/mflua.defines
+++ /dev/null
@@ -1,29 +0,0 @@
-{ Additional symbols for MFLua. Public domain.}
-
-@define procedure mfluainitialize;
-@define procedure mfluaprintpath();
-@define procedure mfluaprintedges();
-@define procedure mfluaPREoffsetprep();
-@define procedure mfluaPOSToffsetprep();
-@define procedure mfluaPREfillenveloperhs();
-@define procedure mfluaPOSTfillenveloperhs();
-@define procedure mfluaPREfillenvelopelhs();
-@define procedure mfluaPOSTfillenvelopelhs();
-@define procedure mfluaPREmakespecrhs();
-@define procedure mfluaPOSTmakespecrhs();
-@define procedure mfluaPREmakespeclhs();
-@define procedure mfluaPOSTmakespeclhs();
-@define procedure mfluaPREfillspecrhs();
-@define procedure mfluaPOSTfillspecrhs();
-@define procedure mfluaPREfillspeclhs();
-@define procedure mfluaPOSTfillspeclhs();
-@define procedure mfluaPREmovetoedges();
-@define procedure mfluaPOSTmovetoedges();
-@define procedure mfluaPREmakechoices();
-@define procedure mfluaPOSTmakechoices();
-@define procedure mfluaprintretrogradeline();
-@define procedure mfluaprinttransitionlinefrom();
-@define procedure mfluaprinttransitionlineto();
-@define procedure mfluaPREmakeellipse();
-@define procedure mfluaPOSTmakeellipse();
-@define procedure mfluarunscript();
diff --git a/Build/source/texk/web2c/mfluadir/mflua_version.h b/Build/source/texk/web2c/mfluadir/mflua_version.h
deleted file mode 100644
index 45244c96c3b..00000000000
--- a/Build/source/texk/web2c/mfluadir/mflua_version.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#define MFLUA_VERSION "1.0.0-alpha"
-#define BANNER "This is MFLua, Version 2.71828182-" MFLUA_VERSION
diff --git a/Build/source/texk/web2c/mfluadir/mfluac.c b/Build/source/texk/web2c/mfluadir/mfluac.c
deleted file mode 100644
index 82d8a04927f..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluac.c
+++ /dev/null
@@ -1,1600 +0,0 @@
-#include <string.h>
-
-#define EXTERN extern
-
-
-#if defined(JIT)
-#include "mfluajitd.h"
-#else
-#include "mfluad.h"
-#endif
-
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-#include <kpathsea/kpathsea.h>
-#if defined(JIT)
-#include <luajit.h>
-#endif
-
-
-#if defined(NO_OTFCC)
-/* */
-#else
-extern int otfcc_build(int argc, char *argv[]);
-extern int otfcc_dump(int argc, char *argv[]);
-#endif
-
-/* See shell_cmd_is_allowed below */
-int shellenabledp = 1;
-int restrictedshell = 0;
-
-/**************************************************************/
-/* */
-/* MFbuiltin private functions */
-/* */
-/**************************************************************/
-static lua_State *Luas[1];
-
-/* static */
-/* void stackdump_g(lua_State* L) */
-/* { */
-/* int i; */
-/* int top = lua_gettop(L); */
-
-/* printf("total in stack %d\n",top); */
-
-/* for (i = 1; i <= top; i++) */
-/* { /\* repeat for each level *\/ */
-/* int t = lua_type(L, i); */
-/* printf("[%d][%d] ",i,i-top-1); */
-/* switch (t) { */
-/* case LUA_TSTRING: /\* strings *\/ */
-/* printf("string: '%s'\n", lua_tostring(L, i)); */
-/* break; */
-/* case LUA_TBOOLEAN: /\* booleans *\/ */
-/* printf("boolean %s\n",lua_toboolean(L, i) ? "true" : "false"); */
-/* break; */
-/* case LUA_TNUMBER: /\* numbers *\/ */
-/* printf("number: %g\n", lua_tonumber(L, i)); */
-/* break; */
-/* default: /\* other values *\/ */
-/* printf("%s\n", lua_typename(L, t)); */
-/* break; */
-/* } */
-/* printf(" "); /\* put a separator *\/ */
-/* } */
-/* printf("\n"); /\* end the listing *\/ */
-/* } */
-
-
-static
-void priv_lua_reporterrors(lua_State *L, int status)
-{
- if ( status!=0 ) {
- fprintf(stderr,"\n! %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* remove error message */
- }
-}
-
-
-/* static */
-/* void priv_lua_writemessage(lua_State *L, char *startmsg, char *bodymsg, char *endmsg, int status) */
-/* { */
-/* (void) L; */
-/* if ( status!=0 ) { */
-/* fprintf(stdout,"%s%s%s\n",startmsg,bodymsg,endmsg); */
-/* } */
-/* } */
-
-
-#define link_field(p) mem[p].hhfield.rh /* {the |link| field of a memory word} */
-static int priv_mfweb_link(lua_State *L)
-{
- halfword p,q;
- p = (halfword) lua_tonumber(L,1);
- q = link_field(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-#define info_field(p) mem[p].hhfield.lhfield /* {the |info| field of a memory word} */
-static int priv_mfweb_info(lua_State *L)
-{
- halfword p,q;
- p = (halfword) lua_tonumber(L,1);
- q = info_field(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-
-#define x_coord(p) mem[p+1].cint /* {the |x| coordinate of this knot} */
-static int priv_mfweb_x_coord(lua_State *L)
-{
- halfword p;
- int q;
- p = (halfword) lua_tonumber(L,1);
- q = x_coord(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-#define y_coord(p) mem[p+2].cint /* {the |y| coordinate of this knot} */
-static int priv_mfweb_y_coord(lua_State *L)
-{
- halfword p,q;
- p = (halfword) lua_tonumber(L,1);
- q = y_coord(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-
-#define left_type(p) mem[p].hhfield.b0 /* {characterizes the path entering this knot} */
-static int priv_mfweb_left_type(lua_State *L)
-{
- halfword p,q;
- p = (halfword) lua_tonumber(L,1);
- q = left_type(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-#define right_type(p) mem[p].hhfield.b1 /* {characterizes the path leaving this knot} */
-static int priv_mfweb_right_type(lua_State *L)
-{
- halfword p,q;
- p = (halfword) lua_tonumber(L,1);
- q = right_type(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-
-#define left_x(p) mem[p+3].cint /* {the |x| coordinate of previous control point} */
-static int priv_mfweb_left_x(lua_State *L)
-{
- halfword p;
- integer q ;
- p = (halfword) lua_tonumber(L,1);
- q = left_x(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-
-#define left_y(p) mem[p+4].cint /* {the |y| coordinate of previous control point} */
-static int priv_mfweb_left_y(lua_State *L)
-{
- halfword p;
- integer q ;
- p = (halfword) lua_tonumber(L,1);
- q = left_y(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-
-#define right_x(p) mem[p+5].cint /* {the |x| coordinate of next control point} */
-static int priv_mfweb_right_x(lua_State *L)
-{
- halfword p;
- integer q ;
- p = (halfword) lua_tonumber(L,1);
- q = right_x(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-#define right_y(p) mem[p+6].cint /* {the |y| coordinate of next control point} */
-static int priv_mfweb_right_y(lua_State *L)
-{
- halfword p;
- integer q;
- p = (halfword) lua_tonumber(L,1);
- q = right_y(p);
- lua_pushnumber(L,q);
- return 1;
-}
-
-/* @ Conversely, the |n_sin_cos| routine takes an |angle| and produces the sine */
-/* and cosine of that angle. The results of this routine are */
-/* stored in global integer variables |n_sin| and |n_cos|. */
-
-/* @<Glob...@>= */
-/* @!n_sin,@!n_cos:fraction; {results computed by |n_sin_cos|} */
-
-/* @ Given an integer |z| that is $2^{20}$ times an angle $\theta$ in degrees, */
-/* the purpose of |n_sin_cos(z)| is to set */
-/* |x=@t$r\cos\theta$@>| and |y=@t$r\sin\theta$@>| (approximately), */
-/* for some rather large number~|r|. The maximum of |x| and |y| */
-/* will be between $2^{28}$ and $2^{30}$, so that there will be hardly */
-/* any loss of accuracy. Then |x| and~|y| are divided by~|r|. */
-static int priv_mfweb_n_sin_cos(lua_State *L)
-{
- nsincos(lua_tonumber(L,1));
- return 0;
-}
-
-
-/* @ When a lot of work is being done on a particular edge structure, we plant */
-/* a pointer to its main header in the global variable |cur_edges|. */
-/* This saves us from having to pass this pointer as a parameter over and */
-/* over again between subroutines. */
-
-/* Similarly, |cur_wt| is a global weight that is being used by several */
-/* procedures at once. */
-
-/* @<Glob...@>= */
-/* @!cur_edges:pointer; {the edge structure of current interest} */
-/* @!cur_wt:integer; {the edge weight of current interest} */
-static int priv_mfweb_LUAGLOBALGET_cur_edges(lua_State *L)
-{
- halfword p = curedges;
- lua_pushnumber(L,p);
- return 1;
-}
-
-
-/* @<Glob...@>= */
-/* @!cur_type:small_number; {the type of the expression just found} */
-/* @!cur_exp:integer; {the value of the expression just found} */
-static int priv_mfweb_LUAGLOBALGET_cur_exp(lua_State *L)
-{
- halfword p = curexp;
- lua_pushnumber(L,p);
- return 1;
-}
-
-
-
-
-
-
-/* @d mem_top==30000 {largest index in the |mem| array dumped by \.{INIMF}; */
-/* must be substantially larger than |mem_min| */
-/* and not greater than |mem_max|} */
-static int priv_mfweb_LUAGLOBALGET_mem_top(lua_State *L)
-{
- integer p = memtop;
- lua_pushnumber(L,p);
- return 1;
-}
-
-
-
-/* And there are two global variables that affect the rounding */
-/* decisions, as we'll see later; they are called |cur_pen| and |cur_path_type|. */
-/* The latter will be |double_path_code| if |make_spec| is being */
-/* applied to a double path.*/
-/* @!cur_pen:pointer; {an implicit input of |make_spec|, used in autorounding} */
-static int priv_mfweb_LUAGLOBALGET_cur_pen(lua_State *L)
-{
- halfword p = curpen;
- lua_pushnumber(L,p);
- return 1;
-}
-
-
-/* @ The current octant code appears in a global variable. If, for example, */
-/* we have |octant=third_octant|, it means that a curve traveling in a north to */
-/* north-westerly direction has been rotated for the purposes of internal */
-/* calculations so that the |move| data travels in an east to north-easterly */
-/* direction. We want to unrotate as we update the edge structure. */
-/* */
-/* @<Glob...@>= */
-/* @!octant:first_octant..sixth_octant; {the current octant of interest} */
-static int priv_mfweb_LUAGLOBALGET_octant(lua_State *L)
-{
- char p = octant;
- lua_pushnumber(L,p);
- return 1;
-}
-
-
-/* @ The |make_spec| routine has an interesting side effect, namely to set */
-/* the global variable |turning_number| to the number of times the tangent */
-/* vector of the given cyclic path winds around the origin. */
-/* */
-/* @<Glob...@>= */
-/* @!turning_number:integer; {another output of |make_spec|} */
-static int priv_mfweb_LUAGLOBALGET_turning_number(lua_State *L)
-{
- integer p = turningnumber;
- lua_pushnumber(L,p);
- return 1;
-}
-
-
-
-/* @ \MF\ also has a bunch of internal parameters that a user might want to */
-/* fuss with. Every such parameter has an identifying code number, defined here. */
-/* Warning: these parameters must be the same of the original MF !! */
-#define tracing_titles 1 /*show titles online when they appear} */
-#define tracing_equations 2 /*show each variable when it becomes known} */
-#define tracing_capsules 3 /*show capsules too} */
-#define tracing_choices 4 /*show the control points chosen for paths} */
-#define tracing_specs 5 /*show subdivision of paths into octants before digitizing} */
-#define tracing_pens 6 /*show details of pens that are made} */
-#define tracing_commands 7 /*show commands and operations before they are performed} */
-#define tracing_restores 8 /*show when a variable or internal is restored} */
-#define tracing_macros 9 /*show macros before they are expanded} */
-#define tracing_edges 10 /*show digitized edges as they are computed} */
-#define tracing_output 11 /*show digitized edges as they are output} */
-#define tracing_stats 12 /*show memory usage at end of job} */
-#define tracing_online 13 /*show long diagnostics on terminal and in the log file} */
-#define year 14 /*the current year (e.g., 1984)} */
-#define month 15 /*the current month (e.g., 3 $\equiv$ March)} */
-#define day 16 /*the current day of the month} */
-#define time 17 /*the number of minutes past midnight when this job started} */
-#define char_code 18 /*the number of the next character to be output} */
-#define char_ext 19 /*the extension code of the next character to be output} */
-#define char_wd 20 /*the width of the next character to be output} */
-#define char_ht 21 /*the height of the next character to be output} */
-#define char_dp 22 /*the depth of the next character to be output} */
-#define char_ic 23 /*the italic correction of the next character to be output} */
-#define char_dx 24 /*the device's $x$ movement for the next character, in pixels} */
-#define char_dy 25 /*the device's $y$ movement for the next character, in pixels} */
-#define design_size 26 /*the unit of measure used for |char_wd..char_ic|, in points} */
-#define hppp 27 /*the number of horizontal pixels per point} */
-#define vppp 28 /*the number of vertical pixels per point} */
-#define x_offset 29 /*horizontal displacement of shipped-out characters} */
-#define y_offset 30 /*vertical displacement of shipped-out characters} */
-#define pausing 31 /*positive to display lines on the terminal before they are read} */
-#define showstopping 32 /*positive to stop after each \&{show} command} */
-#define fontmaking 33 /*positive if font metric output is to be produced} */
-#define proofing 34 /*positive for proof mode, negative to suppress output} */
-#define smoothing 35 /*positive if moves are to be ``smoothed''} */
-#define autorounding 36 /*controls path modification to ``good'' points} */
-#define granularity 37 /*autorounding uses this pixel size} */
-#define fillin 38 /*extra darkness of diagonal lines} */
-#define turning_check 39 /*controls reorientation of clockwise paths} */
-#define warning_check 40 /*controls error message when variable value is large} */
-#define boundary_char 41 /*the right boundary character for ligatures} */
-/* @d max_given_internal=41 */
-
-static int priv_mfweb_LUAGLOBALGET_char_code(lua_State *L)
-{
- integer p = roundunscaled ( internal [char_code]) % 256 ;
- lua_pushnumber(L,p);
- return 1;
-}
-static int priv_mfweb_LUAGLOBALGET_char_ext(lua_State *L)
-{
- integer p = roundunscaled ( internal [char_ext]) ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-
-static int priv_mfweb_LUAGLOBALGET_char_wd(lua_State *L)
-{
- integer p = internal [char_wd] ;
- lua_pushnumber(L,p);
- return 1;
-}
-static int priv_mfweb_LUAGLOBALGET_char_ht(lua_State *L)
-{
- integer p = internal [char_ht] ;
- lua_pushnumber(L,p);
- return 1;
-}
-static int priv_mfweb_LUAGLOBALGET_char_dp(lua_State *L)
-{
- integer p = internal [char_dp] ;
- lua_pushnumber(L,p);
- return 1;
-}
-static int priv_mfweb_LUAGLOBALGET_char_ic(lua_State *L)
-{
- integer p = internal [char_ic] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_char_dx(lua_State *L)
-{
- integer p = internal [char_dx] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_char_dy(lua_State *L)
-{
- integer p = internal [char_dy] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_designsize(lua_State *L)
-{
- integer p = internal [design_size] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_hppp(lua_State *L)
-{
- integer p = internal [hppp] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_vppp(lua_State *L)
-{
- integer p = internal [vppp] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_x_offset(lua_State *L)
-{
- integer p = internal [x_offset] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_y_offset(lua_State *L)
-{
- integer p = internal [y_offset] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_granularity(lua_State *L)
-{
- integer p = internal [granularity] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_fillin(lua_State *L)
-{
- integer p = internal [fillin] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_turning_check(lua_State *L)
-{
- integer p = internal [turning_check] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mfweb_LUAGLOBALGET_boundary_char(lua_State *L)
-{
- integer p = internal [boundary_char] ;
- lua_pushnumber(L,p);
- return 1;
-}
-
-static int priv_mflua_version(lua_State *L)
-{
- lua_pushstring(L,MFLUA_VERSION);
- return 1;
-}
-
-static int priv_mflua_banner(lua_State *L)
-{
- lua_pushstring(L,BANNER);
- return 1;
-}
-
-
-/**************************************************************/
-/* */
-/* otfcc private functions */
-/* */
-/**************************************************************/
-
-#ifdef MFLuaJIT
-static void lua_len (lua_State *L, int i) {
- switch (lua_type(L, i)) {
- case LUA_TSTRING:
- lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
- break;
- case LUA_TTABLE:
- if (!luaL_callmeta(L, i, "__len"))
- lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
- break;
- case LUA_TUSERDATA:
- if (luaL_callmeta(L, i, "__len"))
- break;
- /* FALLTHROUGH */
- default:
- luaL_error(L, "attempt to get length of a %s value",
- lua_typename(L, lua_type(L, i)));
- }
-}
-
-static int lua_absindex (lua_State *L, int i) {
- if (i < 0 && i > LUA_REGISTRYINDEX)
- i += lua_gettop(L) + 1;
- return i;
-}
-static int lua_geti (lua_State *L, int index, lua_Integer i) {
- index = lua_absindex(L, index);
- lua_pushinteger(L, i);
- lua_gettable(L, index);
- return lua_type(L, -1);
-}
-#endif
-
-static int priv_mflua_otf_dump(lua_State *L) {
- if (!lua_istable(L, -1)) {
- fprintf(stderr, "! dump: expected a table\n");
- lua_pop(L,1);
- return 0;
- } else {
- /* table is in the stack at index '-1' */
- size_t l=0;
- int j;
- char **av;
-
- lua_len (L, -1);
- l = (size_t)(lua_tonumber(L,-1));
- lua_pop(L,1);
- if (l==0 )
- return 0;
- av = malloc((l+1) * sizeof(char*));
- if (av==NULL) {
- fprintf(stderr, "! dump: unable to allocate av\n");
- return 0;
- }
- av[0] = malloc((strlen("/dump")+1)*sizeof(char));
- if (av[0]==NULL) {
- fprintf(stderr, "! dump: unable to allocate av[0]\n");
- return 0;
- }
- strcpy(av[0], "/dump");
- /* fill the av array */
- for(j=1;j<=l;j++){
- const char *k;
- lua_geti(L,-1,j);
- k = lua_tostring(L, -1);
- av[j] = malloc((strlen(k)+1)*sizeof(char));
- if (av[j]==NULL) {
- fprintf(stderr, "! dump: unable to allocate av[%d]\n",j);
- return 0;
- }
- strcpy(av[j], k);
- lua_pop(L,1);
- }
-#if defined(NO_OTFCC)
-/* */
-#else
- otfcc_dump(l+1,av);
-#endif
- /* release the av */
- free(av[0]);
- for(j=1;j<=l;j++)
- free(av[j]);
- free(av);
- return 0;
- }
-}
-
-
-static int priv_mflua_otf_build(lua_State *L) {
- if (!lua_istable(L, -1)) {
- fprintf(stderr, "! build: expected a table\n");
- lua_pop(L,1);
- return 0;
- } else {
- /* table is in the stack at index '-1' */
- size_t l=0;
- int j;
- char **av;
-
- lua_len (L, -1);
- l = (size_t)(lua_tonumber(L,-1)) ;
- lua_pop(L,1);
- if (l==0 )
- return 0;
- av = malloc((l+1) * sizeof(char*));
- if (av==NULL) {
- fprintf(stderr, "! build: unable to allocate av\n");
- return 0;
- }
- av[0] = malloc((strlen("/build")+1)*sizeof(char));
- if (av[0]==NULL) {
- fprintf(stderr, "! build: unable to allocate av[0]\n");
- return 0;
- }
- strcpy(av[0], "/build");
- /* fill the av array */
- for(j=1;j<=l;j++){
- const char *k;
- lua_geti(L,-1,j);
- k = lua_tostring(L, -1);
- av[j] = malloc((strlen(k)+1)*sizeof(char));
- if (av[j]==NULL) {
- fprintf(stderr, "! build: unable to allocate av[%d]\n",j);
- return 0;
- }
- strcpy(av[j], k);
- lua_pop(L,1);
- }
-#if defined(NO_OTFCC)
-/* */
-#else
- otfcc_build(l+1,av);
-#endif
- /* release the av */
- free(av[0]);
- for(j=1;j<=l;j++)
- free(av[j]);
- free(av);
- return 0;
- }
-}
-
-
-
-/**************************************************************/
-/* */
-/* mflua layer */
-/* */
-/**************************************************************/
-static const struct luaL_Reg MFbuiltin_l[] = {
- {"link", priv_mfweb_link},
- {"info", priv_mfweb_info},
- {"x_coord", priv_mfweb_x_coord},
- {"y_coord", priv_mfweb_y_coord},
- {"left_type", priv_mfweb_left_type},
- {"right_type", priv_mfweb_right_type},
- {"left_x", priv_mfweb_left_x},
- {"left_y", priv_mfweb_left_y},
- {"right_x", priv_mfweb_right_x},
- {"right_y", priv_mfweb_right_y},
- {"n_sin_cos", priv_mfweb_n_sin_cos},
- {"cur_edges", priv_mfweb_LUAGLOBALGET_cur_edges},
- {"cur_exp", priv_mfweb_LUAGLOBALGET_cur_exp},
- {"mem_top", priv_mfweb_LUAGLOBALGET_mem_top},
- {"cur_pen", priv_mfweb_LUAGLOBALGET_cur_pen},
- {"octant", priv_mfweb_LUAGLOBALGET_octant},
- {"char_code", priv_mfweb_LUAGLOBALGET_char_code},
- {"char_ext", priv_mfweb_LUAGLOBALGET_char_ext},
- {"char_wd", priv_mfweb_LUAGLOBALGET_char_wd},
- {"char_ht", priv_mfweb_LUAGLOBALGET_char_ht},
- {"char_dp", priv_mfweb_LUAGLOBALGET_char_dp},
- {"char_ic", priv_mfweb_LUAGLOBALGET_char_ic},
- {"char_dx", priv_mfweb_LUAGLOBALGET_char_dx},
- {"char_dy", priv_mfweb_LUAGLOBALGET_char_dy},
- {"designsize", priv_mfweb_LUAGLOBALGET_designsize},
- {"hppp", priv_mfweb_LUAGLOBALGET_hppp},
- {"vppp", priv_mfweb_LUAGLOBALGET_vppp},
- {"x_offset", priv_mfweb_LUAGLOBALGET_x_offset},
- {"y_offset", priv_mfweb_LUAGLOBALGET_y_offset},
- {"granularity", priv_mfweb_LUAGLOBALGET_granularity},
- {"fillin", priv_mfweb_LUAGLOBALGET_fillin},
- {"turning_check", priv_mfweb_LUAGLOBALGET_turning_check},
- {"boundary_char", priv_mfweb_LUAGLOBALGET_boundary_char},
- {"turning_number", priv_mfweb_LUAGLOBALGET_turning_number},
- {"mflua_version",priv_mflua_version},
- {"mflua_banner",priv_mflua_banner},
- {NULL, NULL} /* sentinel */
-};
-
-static struct luaL_Reg mflua_otfcc[] = {
- { "build", priv_mflua_otf_build },
- { "dump", priv_mflua_otf_dump },
- { NULL, NULL}
-};
-
-
-#define lua_swap(L) lua_insert(L, -2)
-
-#define GETGLOBALTABLEMFLUA(a) lua_getglobal(L, "mflua");\
- if (!lua_istable(L, -1)) { \
- lua_pushstring(L,#a); \
- lua_pushstring(L,":global table mflua not found"); \
- lua_concat (L, 2); \
- priv_lua_reporterrors(L, 1); \
- } \
-
-
-
-int mfluabeginprogram(void)
-{
- lua_State *L ;
- char* luafile ;
- int res ;
-
- L = luaL_newstate();
- luaL_openlibs(L);
- Luas[0] = L;
- /* register lua functions */
- luaopen_kpse(L);
- /* to be sure of having a clear stack */
- lua_settop(L,0);
-
-
- lua_getglobal(L, "mflua");
- if (!lua_istable(L, -1)) {
- lua_pop(L,1);
- lua_newtable(L);
- lua_setglobal(L,"mflua");
- /* check it */
- lua_getglobal(L,"mflua");
- if (!lua_istable(L, -1)) {
- printf("mflua table NOT registered!\n");
- } else {
- lua_pushstring(L,"MFbuiltin");
-#ifdef MFLuaJIT
- /* 5.1 */
- luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE|LUAJIT_MODE_OFF);
- lua_newtable(L);
- luaL_register (L,NULL,MFbuiltin_l);
-#else
- luaL_newlib(L,MFbuiltin_l);
-#endif
- lua_settable(L, -3);
- /* set the otfcc table */
- lua_pushstring(L,"otf");
-#ifdef MFLuaJIT
- /* 5.1 */
- lua_newtable(L);
- luaL_register (L,NULL,mflua_otfcc);
-#else
- luaL_newlib(L,mflua_otfcc);
-#endif
- lua_settable(L, -3);
-
- }
- lua_pop(L,1);
- }
-
-
- luafile = kpse_find_file("mflua.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"mflua.lua not found.");
- priv_lua_reporterrors(L, res);
- goto EXIT;
- }
- res = luaL_loadfile(L, luafile);
- free(luafile);
- if ( res==LUA_OK ) {
- if((res=lua_pcall(L,0,0,0))){
- priv_lua_reporterrors(L, res);
- goto EXIT;
- }
- } else {
- priv_lua_reporterrors(L, res);
- goto EXIT;
- }
- /* Still a chance that mflua is around */
- GETGLOBALTABLEMFLUA(mfluabeginprogram);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"begin_program");
- if((res=lua_pcall(L,0,0,0)))
- priv_lua_reporterrors(L, res);
- }
- EXIT:
- lua_settop(L,0);
- return 0;
-}
-
-/* /\* TODO*\/ */
-/* int mfluaendprogram(void) */
-/* { */
-/* lua_State *L; */
-/* char* luafile; */
-/* int res; */
-
-/* L = Luas[0]; */
-/* GETGLOBALTABLEMFLUA(mfluaendprogram); */
-/* luafile = kpse_find_file("end_program.lua", kpse_lua_format, 0); */
-/* if (luafile==NULL) { */
-/* res = 1; */
-/* lua_pushstring(L,"end_program.lua not found"); */
-/* priv_lua_reporterrors(L, res); */
-/* lua_settop(L,0); */
-/* return 0; */
-/* } */
-/* priv_lua_writemessage(L,"(",luafile,")",1); */
-/* res = luaL_loadfile(L, luafile); */
-/* free(luafile); */
-/* if ( res==0 ) { */
-/* res = lua_pcall(L, 0, 0, 0); */
-/* } */
-/* /\* stackdump_g(L); *\/ */
-/* priv_lua_reporterrors(L, res); */
-/* lua_settop(L,0); */
-/* return 0; */
-/* } */
-
-int mfluaendprogram(void)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaendprogram);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"end_program");
- /* do the call (0 arguments, 0 result) */
- if((res=lua_pcall(L, 0, 0, 0))){
- lua_pushstring(L,"error in end_program:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPREstartofMF(void)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREstartofMF);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"PRE_start_of_MF");
- /* do the call (0 arguments, 0 result) */
- if((res=lua_pcall(L, 0, 0, 0))){
- lua_pushstring(L,"error in PRE_start_of_MF:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPREmaincontrol(void)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREmaincontrol);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_main_control");
- /* do the call (0 arguments, 0 result) */
- if((res=lua_pcall(L, 0, 0, 0))){
- lua_pushstring(L,"error in PRE_main_control:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-int mfluaPOSTmaincontrol(void)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTmaincontrol);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_main_control");
- /* do the call (0 arguments, 0 result) */
- if((res=lua_pcall(L, 0, 0, 0))){
- lua_pushstring(L,"error in POST_main_control:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-
-}
-
-
-int mfluainitialize(void)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluainitialize);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "mflua_initialize");
- /* do the call (0 arguments, 0 result) */
- if((res=lua_pcall(L, 0, 0, 0))){
- lua_pushstring(L,"error in mflua_initialize:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPOSTfinalcleanup(void)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTfinalcleanup);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_final_cleanup");
- /* do the call (0 arguments, 0 result) */
- if((res=lua_pcall(L, 0, 0, 0))){
- lua_pushstring(L,"error in POST_final_cleanup:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-/* Not a good way: */
-/* 1) these definitions are taken from mfcoerc.h which is generated at run-time */
-/* 2) too much coupling with webc2c translation of mf.web*/
-/* */
-/* #define printdiagnostic(s, t, nuline) zprintdiagnostic((strnumber) (s), (strnumber) (t), (boolean) (nuline)) */
-/* #define print(s) zprint((integer) (s)) */
-/* #define printarg(q, n, b) zprintarg((halfword) (q), (integer) (n), (halfword) (b) */
-/* int mfluaprintpath P3C(halfword, h , strnumber, s , boolean, nuline) */
-/* { */
-/* fprintf(stderr,"\n! %d \n",s); */
-/* printdiagnostic ( 517 , s , nuline ) ; */
-/* println () ; */
-/* print ( 518 ) ; */
-/* println () ; */
-/* fprintf(stderr,"\n! %s\n","*end***************"); */
-
-/* lua_State *L = Luas[0]; */
-/* char* file = kpse_find_file("print_path.lua", kpse_lua_format, 0); */
-/* int res = luaL_loadfile(L, file); */
-/* if (file) free (file); */
-/* if ( res==0 ) { */
-/* res = lua_pcall(L, 0, 0, 0); */
-/* } */
-/* // */
-/* //stackdump_g(L); */
-
-/* // */
-/* priv_lua_reporterrors(L, res); */
-/* return 0; */
-
-/* } */
-
-int mfluaprintpath(halfword h, strnumber s, boolean nuline)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaprintpath);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "printpath");
- lua_pushnumber(L, h); /* push 1st argument */
- lua_pushnumber(L, s); /* push 2nd argument */
- lua_pushnumber(L, nuline); /* push 3nd argument */
- /* do the call (3 arguments, 0 result) */
- if((res=lua_pcall(L, 3, 0, 0))){
- lua_pushstring(L,"error in printpath:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaprintedges(strnumber s, boolean nuline, integer xoff, integer yoff)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaprintedges);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "printedges");
- lua_pushnumber(L, s); /* push 1st argument */
- lua_pushnumber(L, nuline); /* push 2nd argument */
- lua_pushnumber(L, xoff); /* push 3nd argument */
- lua_pushnumber(L, yoff); /* push 4nd argument */
- /* do the call (4 arguments, 0 result) */
- if((res=lua_pcall(L, 4, 0, 0))){
- lua_pushstring(L,"error in printedges:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-/* */
-/* Sensor before and after offset_prep */
-/* */
-int mfluaPREoffsetprep(halfword c, halfword h)
-{
-
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREoffsetprep);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_offset_prep");
- lua_pushnumber(L, c); /* push 1st argument */
- lua_pushnumber(L, h); /* push 2nd argument */
- /* do the call (2 arguments, 0 result) */
- if((res=lua_pcall(L, 2, 0, 0))){
- lua_pushstring(L,"error in PRE_offset_prep:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPOSToffsetprep(halfword c, halfword h)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSToffsetprep);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_offset_prep");
- lua_pushnumber(L, c); /* push 1st argument */
- lua_pushnumber(L, h); /* push 2nd argument */
- /* do the call (2 arguments, 0 result) */
- if((res=lua_pcall(L, 2, 0, 0))){
- lua_pushstring(L,"error in POST_offset_prep:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPREmakespecrhs(halfword rhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREmakespecrhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_make_spec_rhs");
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 0result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_make_spec_rhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPOSTmakespecrhs(halfword rhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTmakespecrhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_make_spec_rhs");
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 0result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_make_spec_rhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPREmakespeclhs(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREmakespeclhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_make_spec_lhs");
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_make_spec_lhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-int mfluaPOSTmakespeclhs(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTmakespeclhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_make_spec_lhs");
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_make_spec_lhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPREfillenveloperhs(halfword rhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREfillenveloperhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_fill_envelope_rhs");
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_fill_envelope_rhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPOSTfillenveloperhs(halfword rhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTfillenveloperhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_fill_envelope_rhs");
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_fill_envelope_rhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPREfillenvelopelhs(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREfillenvelopelhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_fill_envelope_lhs");
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_fill_envelope_lhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPOSTfillenvelopelhs(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTfillenvelopelhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_fill_envelope_lhs");
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_fill_envelope_lhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPREfillspecrhs(halfword rhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREfillspecrhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_fill_spec_rhs");
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_fill_spec_rhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-int mfluaPOSTfillspecrhs(halfword rhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTfillspecrhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_fill_spec_rhs");
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_fill_spec_rhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-int mfluaPREfillspeclhs(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREfillspeclhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_fill_spec_lhs");
- L = Luas[0];
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_fill_spec_lhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPOSTfillspeclhs(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTfillspeclhs);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_fill_spec_lhs");
- L = Luas[0];
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_fill_spec_lhs:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPREmovetoedges(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREmovetoedges);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "PRE_move_to_edges");
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_move_to_edges:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPOSTmovetoedges(halfword lhs)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTmovetoedges);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1, "POST_move_to_edges");
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_move_to_edges:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPREmakechoices(halfword p)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREmakechoices);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"PRE_make_choices"); /* function to be called */
- lua_pushnumber(L, p); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in PRE_make_choices:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPOSTmakechoices(halfword p)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTmakechoices);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"POST_make_choices"); /* function to be called */
- lua_pushnumber(L, p); /* push 1st argument */
- /* do the call (1 arguments, 0 result) */
- if((res=lua_pcall(L, 1, 0, 0))){
- lua_pushstring(L,"error in POST_make_choices:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaprintretrogradeline(integer x0, integer y0, integer cur_x, integer cur_y)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaprintretrogradeline);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"print_retrograde_line");
- lua_pushnumber(L, x0); /* push 1st argument */
- lua_pushnumber(L, y0); /* push 2nd argument */
- lua_pushnumber(L, cur_x); /* push 3th argument */
- lua_pushnumber(L, cur_y); /* push 4th argument */
- /* do the call (4 arguments, 0 result) */
- if((res=lua_pcall(L, 4, 0, 0))){
- lua_pushstring(L,"error in print_retrograde_line:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaPREmakeellipse(integer major_axis, integer minor_axis, integer theta_angle , integer tx_val, integer ty_val,integer q)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPREmakeellipse);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"PRE_make_ellipse");
- lua_pushnumber(L, major_axis); /* push 1st argument */
- lua_pushnumber(L, minor_axis); /* push 2nd argument */
- lua_pushnumber(L, theta_angle); /* push 3th argument */
- lua_pushnumber(L, tx_val); /* push 4th argument */
- lua_pushnumber(L, ty_val); /* push 5th argument */
- lua_pushnumber(L, q); /* push 6th argument */
- /* do the call (6 arguments, 0 result) */
- if((res=lua_pcall(L, 6, 1, 0))){
- lua_pushstring(L,"error in PRE_make_ellipse:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-int mfluaPOSTmakeellipse(integer major_axis, integer minor_axis, integer mfl_theta , integer mfl_tx, integer mfl_ty,integer q)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaPOSTmakeellipse);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"POST_make_ellipse");
- lua_pushnumber(L, major_axis); /* push 1st argument */
- lua_pushnumber(L, minor_axis); /* push 2nd argument */
- lua_pushnumber(L, mfl_theta); /* push 3th argument */
- lua_pushnumber(L, mfl_tx); /* push 4th argument */
- lua_pushnumber(L, mfl_ty); /* push 5th argument */
- lua_pushnumber(L, q); /* push 6th argument */
- /* do the call (6 arguments, 0 result) */
- if((res=lua_pcall(L, 6, 1, 0))){
- lua_pushstring(L,"error in POST_make_ellipse:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaprinttransitionlinefrom(integer x, integer y)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaprinttransitionlinefrom);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"print_transition_line_from");
- lua_pushnumber(L, x); /* push 1st argument */
- lua_pushnumber(L, y); /* push 2nd argument */
- /* do the call (2 arguments, 0 result) */
- if((res=lua_pcall(L, 2, 0, 0))){
- lua_pushstring(L,"error in print_transition_line_from:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-int mfluaprinttransitionlineto(integer x, integer y)
-{
- lua_State *L;
- int res;
-
- L = Luas[0];
- GETGLOBALTABLEMFLUA(mfluaprinttransitionlineto);
- if (lua_istable(L, -1)) {
- lua_getfield(L,-1,"print_transition_line_to");
- lua_pushnumber(L, x); /* push 1st argument */
- lua_pushnumber(L, y); /* push 2nd argument */
- /* do the call (2 arguments, 0 result) */
- if((res=lua_pcall(L, 2, 0, 0))){
- lua_pushstring(L,"error in print_transition_line_to:");
- lua_swap(L);lua_concat (L, 2);
- priv_lua_reporterrors(L, res);
- }
- }
- lua_settop(L,0);
- return 0;
-}
-
-
-
-#define priv_append_char(c) do { \
- strpool[poolptr]=c; \
- poolptr++; \
-} while(0)
-
-#define priv_str_room(l) do { \
- if ((poolptr + l) > maxpoolptr) { \
- if ((poolptr + l) > poolsize) { \
- fprintf(stderr,"\n! (Lua) MFLua capacity exceeded, sorry [pool size=%ld]\nIf you really absolutely need more capacity,\nyou can ask a wizard to enlarge me.\n",poolsize-initpoolptr); \
- exit(1); \
- } \
- maxpoolptr = poolptr + l; \
- } \
-} while (0)
-
-int mfluarunscript(halfword j, halfword first_val, halfword limit)
-{
- int i ;
- lua_State *L ;
- unsigned char last_char;
- int error;
- const char *str;
- size_t len;
- L = Luas[0];
- last_char = strpool[j+limit-first_val] ;
- /* end of a C string */
- strpool[j+limit-first_val] = '\0';
- str = (const char *)(strpool+j) ;
- /* do the call (0 arguments, 1 result) */
- error = (luaL_loadstring(L, str) || lua_pcall(L, 0, 1, 0)) ;
- strpool[j+limit-first_val] = last_char;
- if(error) {
- priv_lua_reporterrors(L,error);
- } else {
- /* retrieve result */
- str = lua_tolstring(L, -1,&len);
- priv_str_room(len);
- for(i=0;i<len;i++){
- priv_append_char( (unsigned char)(*(str+i))) ;
- }
- lua_pop(L, 1); /* pop returned value */
- }
- return 0;
-}
-
-/* TODO: check if shell_cmd_is_allowed makes sense */
-int shell_cmd_is_allowed(const char *cmd, char **safecmd, char **cmdname){return 1;}
diff --git a/Build/source/texk/web2c/mfluadir/mfluac.h b/Build/source/texk/web2c/mfluadir/mfluac.h
deleted file mode 100644
index ed793cfc5c0..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluac.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef MFLUAC_H
-#define MFLUAC_H
-
-#include <mfluadir/mflua_version.h>
-extern int mfluabeginprogram(void);
-extern int mfluaPREstartofMF(void);
-extern int mfluaPREmaincontrol(void);
-extern int mfluaPOSTmaincontrol(void);
-extern int mfluainitialize(void);
-extern int mfluaPOSTfinalcleanup(void);
-extern int mfluaendprogram(void);
-
-extern int mfluaprintpath(halfword, strnumber, boolean);
-extern int mfluarunscript(halfword, halfword, halfword);
-extern int mfluaprintedges(strnumber, boolean, integer, integer);
-
-extern int mfluaPREoffsetprep(halfword, halfword);
-extern int mfluaPOSToffsetprep(halfword, halfword);
-
-extern int mfluaPREfillenveloperhs(halfword);
-extern int mfluaPOSTfillenveloperhs(halfword);
-extern int mfluaPREfillenvelopelhs(halfword);
-extern int mfluaPOSTfillenvelopelhs(halfword);
-
-extern int mfluaPREmakespecrhs(halfword);
-extern int mfluaPOSTmakespecrhs(halfword);
-extern int mfluaPREmakespeclhs(halfword);
-extern int mfluaPOSTmakespeclhs(halfword);
-
-extern int mfluaPREfillspecrhs(halfword);
-extern int mfluaPOSTfillspecrhs(halfword);
-extern int mfluaPREfillspeclhs(halfword);
-extern int mfluaPOSTfillspeclhs(halfword);
-
-extern int mfluaPREmakechoices(halfword);
-extern int mfluaPOSTmakechoices(halfword);
-
-extern int mfluaPREmovetoedges(halfword);
-extern int mfluaPOSTmovetoedges(halfword);
-
-extern int mfluaprintretrogradeline(integer, integer, integer, integer);
-
-extern int mfluaprinttransitionlinefrom(integer, integer);
-extern int mfluaprinttransitionlineto(integer, integer);
-
-extern int mfluaPREmakeellipse(integer, integer, integer, integer, integer, integer);
-extern int mfluaPOSTmakeellipse(integer, integer, integer, integer, integer, integer);
-
-/* TODO: check if shell_cmd_is_allowed makes sense */
-extern int shellenabledp;
-extern int restrictedshell;
-extern int shell_cmd_is_allowed(const char *, char **, char **);
-
-#include <lauxlib.h>
-extern int luaopen_kpse(lua_State * L);
-
-#endif /* MFLUAC_H */
diff --git a/Build/source/texk/web2c/mfluadir/mfluaextra.c b/Build/source/texk/web2c/mfluadir/mfluaextra.c
deleted file mode 100644
index 3ec9db1060a..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluaextra.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/* mfluaextra.c: Hand-coded routines for MFLua.
-
- This file is public domain. */
-
-#define EXTERN /* Instantiate data from mfluad.h here. */
-
-/* This file defines MFLua. */
-#include <mfluad.h>
-
-/* Hand-coded routines for TeX or Metafont in C. */
-#include <lib/texmfmp.c>
diff --git a/Build/source/texk/web2c/mfluadir/mfluaextra.h b/Build/source/texk/web2c/mfluadir/mfluaextra.h
deleted file mode 100644
index 636c01d5d2f..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluaextra.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* mfluaextra.h: banner etc. for MFLua.
-
- This is included by MFLua, from mfluaextra.c
-*/
-
-#include <mfluadir/mflua_version.h> /* for MFLUA_VERSION and BANNER */
-
-/*#define BANNER "This is MFLua, Version 2.71828182-" MFLUA_VERSION*/
-#define COPYRIGHT_HOLDER "L. Scarso"
-#define AUTHOR NULL
-#define PROGRAM_HELP MFLUAHELP
-#define BUG_ADDRESS "luigi.scarso@gmail.com"
-#define DUMP_VAR MFbasedefault
-#define DUMP_LENGTH_VAR basedefaultlength
-#define DUMP_OPTION "base"
-#ifdef DOS
-#define DUMP_EXT ".bas"
-#else
-#define DUMP_EXT ".base"
-#endif
-#define INPUT_FORMAT kpse_mf_format
-#define INI_PROGRAM "inimflua"
-#define VIR_PROGRAM "virmflua"
-#define MFLua
-
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/mflua.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/mflua.lua
deleted file mode 100644
index ec9864a18bd..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluatrap/mflua.lua
+++ /dev/null
@@ -1,3790 +0,0 @@
-print("MFLua version: " .. mflua.MFbuiltin.mflua_version())
-print("MFLua banner: ".. mflua.MFbuiltin.mflua_banner())
-
-local function PRINTDBG(s) print(tostring(s)) end
-local function PRINTDBG(s) end
-local function chMF(t,k) if t[k] then print(k.." already inserted") os.exit(1) end end
-
-PRINTDBG("mflua.lua")
-
---------------------------------------------------------------------------------
---
--- kpse
---
---------------------------------------------------------------------------------
--- "new"
--- "set_program_name"
--- "init_prog"
--- "readable_file"
--- "find_file"
--- "expand_path"
--- "expand_var"
--- "expand_braces"
--- "var_value"
--- "show_path"
--- "lookup"
--- "version"
--- "default_texmfcnf"
-
-
---------------------------------------------------------------------------------
---
--- These are hardcoded into mflua.MFbuiltin table:
---
---------------------------------------------------------------------------------
-MFbuiltin = mflua.MFbuiltin or {}
--- function: link
--- function: info
--- function: x_coord
--- function: y_coord
--- function: left_type
--- function: right_type
--- function: left_x
--- function: left_y
--- function: right_x
--- function: right_y
--- function: n_sin_cos
---
--- function: LUAGLOBALGET_boundary_char
--- function: LUAGLOBALGET_char_code
--- function: LUAGLOBALGET_char_dp
--- function: LUAGLOBALGET_char_dx
--- function: LUAGLOBALGET_char_dy
--- function: LUAGLOBALGET_char_ext
--- function: LUAGLOBALGET_char_ht
--- function: LUAGLOBALGET_char_ic
--- function: LUAGLOBALGET_char_wd
--- function: LUAGLOBALGET_cur_edges
--- function: LUAGLOBALGET_cur_exp
--- function: LUAGLOBALGET_cur_pen
--- function: LUAGLOBALGET_designsize
--- function: LUAGLOBALGET_fillin
--- function: LUAGLOBALGET_granularity
--- function: LUAGLOBALGET_hppp
--- function: LUAGLOBALGET_mem_top
--- function: LUAGLOBALGET_octant
--- function: LUAGLOBALGET_turning_check
--- function: LUAGLOBALGET_vppp
--- function: LUAGLOBALGET_x_offset
--- function: LUAGLOBALGET_y_offset
-
---
--- It's handy to have them as local
---
-
-local link = MFbuiltin.link
-local info = MFbuiltin.info
-local x_coord = MFbuiltin.x_coord
-local y_coord = MFbuiltin.y_coord
-local left_type = MFbuiltin.left_type
-local right_type = MFbuiltin.right_type
-local left_x = MFbuiltin.left_x
-local left_y = MFbuiltin.left_y
-local right_x = MFbuiltin.right_x
-local right_y = MFbuiltin.right_y
-local n_sin_cos = MFbuiltin.n_sin_cos
-
-
-
---------------------------------------------------------------------------------
--- Global table mflua.
--- Important subtable:
--- * mflua.MFbuiltin that stores the hardwired functions;
--- * mflua.MF that stores some constants from MetaFont, as also some functions
--- from PascalWEB rewritten in Lua (almost 1:1 translation).
--- Use them with care !
---------------------------------------------------------------------------------
-
-mflua = mflua or {}
-mflua.MF = mflua.MF or {}
-
-
---------------------------------------------------------------------------------
---
--- As in MetaFont:
---
---------------------------------------------------------------------------------
-
-local min_quarterword = 0 --{smallest allowable value in a |quarterword|}
-local max_quarterword = 255 --{largest allowable value in a |quarterword|}
-local min_halfword = 0 --{smallest allowable value in a |halfword|}
-local max_halfword = 65535 --{largest allowable value in a |halfword|}
-
-local mem_min = 0 -- {smallest index in the |mem| array, must not be less than |min_halfword|}
-
-local quarter_unit = 2^14 -- {$2^{14}$, represents 0.250000}
-local half_unit = 2^15 -- {$2^{15}$, represents 0.50000}
-local three_quarter_unit = 3*(2^14) -- {$3\cdot2^{14}$, represents 0.75000}
-local unity = 2^16 -- {$2^{16}$, represents 1.00000}
-local two = 2^17 -- {$2^{17}$, represents 2.00000}
-local three = 2^16+2^16 -- {$2^{17}+2^{16}$, represents 3.00000}
-
-
-chMF(mflua.MF,min_quarterword);mflua.MF.min_quarterword = min_quarterword
-chMF(mflua.MF,max_quarterword);mflua.MF.max_quarterword = max_quarterword
-chMF(mflua.MF,min_halfword);mflua.MF.min_halfword = min_halfword
-chMF(mflua.MF,max_halfword);mflua.MF.max_halfword = max_halfword
-chMF(mflua.MF,mem_min);mflua.MF.mem_min = mem_min
-chMF(mflua.MF,quarter_unit);mflua.MF.quarter_unit = quarter_unit
-chMF(mflua.MF,half_unit);mflua.MF.half_unit = half_unit
-chMF(mflua.MF,three_quarter_unit);mflua.MF.three_quarter_unit = three_quarter_unit
-chMF(mflua.MF,unity);mflua.MF.unity = unity
-chMF(mflua.MF,two);mflua.MF.two = two
-chMF(mflua.MF,three);mflua.MF.three = three
-
-
-
--- @ Given integers |x| and |y|, not both zero, the |n_arg| function
--- returns the |angle| whose tangent points in the direction $(x,y)$.
--- This subroutine first determines the correct octant, then solves the
--- problem for |0<=y<=x|, then converts the result appropriately to
--- return an answer in the range |-one_eighty_deg<=@t$\theta$@><=one_eighty_deg|.
--- (The answer is |+one_eighty_deg| if |y=0| and |x<0|, but an answer of
--- |-one_eighty_deg| is possible if, for example, |y=-1| and $x=-2^{30}$.)
-
--- The octants are represented in a ``Gray code,'' since that turns out
--- to be computationally simplest.
-
-negate_x=1
-negate_y=2
-switch_x_and_y=4
-first_octant=1
-second_octant=first_octant+switch_x_and_y
-third_octant=first_octant+switch_x_and_y+negate_x
-fourth_octant=first_octant+negate_x
-fifth_octant=first_octant+negate_x+negate_y
-sixth_octant=first_octant+switch_x_and_y+negate_x+negate_y
-seventh_octant=first_octant+switch_x_and_y+negate_y
-eighth_octant=first_octant+negate_y
-
-
-local negate_x=1
-local negate_y=2
-local switch_x_and_y=4
-local first_octant=1
-local second_octant=first_octant+switch_x_and_y
-local third_octant=first_octant+switch_x_and_y+negate_x
-local fourth_octant=first_octant+negate_x
-local fifth_octant=first_octant+negate_x+negate_y
-local sixth_octant=first_octant+switch_x_and_y+negate_x+negate_y
-local seventh_octant=first_octant+switch_x_and_y+negate_y
-local eighth_octant=first_octant+negate_y
-
-chMF(mflua.MF,negate_x);mflua.MF.negate_x = negate_x
-chMF(mflua.MF,negate_y);mflua.MF.negate_y = negate_y
-chMF(mflua.MF,switch_x_and_y);mflua.MF.switch_x_and_y = switch_x_and_y
-chMF(mflua.MF,first_octant);mflua.MF.first_octant = first_octant
-chMF(mflua.MF,second_octant);mflua.MF.second_octant = second_octant
-chMF(mflua.MF,third_octant);mflua.MF.third_octant = third_octant
-chMF(mflua.MF,fourth_octant);mflua.MF.fourth_octant = fourth_octant
-chMF(mflua.MF,fifth_octant);mflua.MF.fifth_octant = fifth_octant
-chMF(mflua.MF,sixth_octant);mflua.MF.sixth_octant = sixth_octant
-chMF(mflua.MF,seventh_octant);mflua.MF.seventh_octant = seventh_octant
-chMF(mflua.MF,eighth_octant);mflua.MF.eighth_octant = eighth_octant
-
-
-local octant_dir = {}
-octant_dir[first_octant]="ENE-1"
-octant_dir[second_octant]="NNE-2"
-octant_dir[third_octant]="NNW-3"
-octant_dir[fourth_octant]="WNW-4"
-octant_dir[fifth_octant]="WSW-5"
-octant_dir[sixth_octant]="SSW-6"
-octant_dir[seventh_octant]="SSE-7"
-octant_dir[eighth_octant]="ESE-8"
-
-chMF(mflua.MF,octant_dir);mflua.MF.octant_dir = octant_dir
-
--- @ Finally we come to the last steps of |make_spec|, when boundary nodes
--- are inserted between cubics that move in different octants. The main
--- complication remaining arises from consecutive cubics whose octants
--- are not adjacent; we should insert more than one octant boundary
--- at such sharp turns, so that the envelope-forming routine will work.
--- For this purpose, conversion tables between numeric and Gray codes for
--- octants are desirable.
--- @<Glob...@>=
--- @!octant_number:array[first_octant..sixth_octant] of 1..8;
--- @!octant_code:array[1..8] of first_octant..sixth_octant;
-
-local octant_code = {}
-octant_code[1]=first_octant;
-octant_code[2]=second_octant;
-octant_code[3]=third_octant;
-octant_code[4]=fourth_octant;
-octant_code[5]=fifth_octant;
-octant_code[6]=sixth_octant;
-octant_code[7]=seventh_octant;
-octant_code[8]=eighth_octant;
-chMF(mflua.MF,octant_code);mflua.MF.octant_code = octant_code
-
-
-local octant_number = {}
-for k=1, 8 do octant_number[octant_code[k]]=k; end
-chMF(mflua.MF,octant_number);mflua.MF.octant_number = octant_number
-
-
--- It is convenient to define a \.{WEB} macro |t_of_the_way| such that
--- |t_of_the_way(a)(b)| expands to |a-(a-b)*t|, i.e., to |t[a,b]|.
--- @d t_of_the_way_end(#)==#,t@=)@>
--- @d t_of_the_way(#)==#-take_fraction@=(@>#-t_of_the_way_end
---
--- TO implement !!
--- function t_of_the_way(a,b,t)
--- return take_fraction(a-b,t)
--- end
-
-local endpoint = 0 -- {|left_type| at path beginning and |right_type| at path end}
-local knot_node_size = 7 -- {number of words in a knot node} */
-
-local left_curl=left_x -- {curl information when entering this knot}
-local left_given=left_x -- {given direction when entering this knot}
-local left_tension=left_y -- {tension information when entering this knot}
-local right_curl=right_x -- {curl information when leaving this knot}
-local right_given=right_x -- {given direction when leaving this knot}
-local right_tension=right_y -- {tension information when leaving this knot}
-local explicit =1 -- {|left_type| or |right_type| when control points are known}
-local given = 2 -- {|left_type| or |right_type| when a direction is given}
-local curl = 3 -- {|left_type| or |right_type| when a curl is desired}
-local open = 4 -- {|left_type| or |right_type| when \MF\ should choose the direction}
-
-local right_octant=right_x -- {the octant code before a transition}
-local left_octant=left_x -- {the octant after a transition}
-local right_transition=right_y -- {the type of transition}
-local left_transition=left_y -- {ditto, either |axis| or |diagonal|}
-local axis=0 -- {a transition across the $x'$- or $y'$-axis}
-local diagonal=1 -- {a transition where $y'=\pm x'$}
-
-local mem_top = MFbuiltin.mem_top()
-local sentinel= mem_top --{end of sorted lists}
-local null = mem_min -- {the null pointer}
-local knil=info -- {inverse of the |link| field, in a doubly linked list}
-local zero_w=4
-local void=null+1
-
-local zero_field=4096 -- {amount added to coordinates to make them positive}
-
-
-chMF(mflua.MF,endpoint);mflua.MF.endpoint = endpoint
-chMF(mflua.MF,knot_node_size);mflua.MF.knot_node_size = knot_node_size
-
-chMF(mflua.MF,left_curl);mflua.MF.left_curl = left_curl
-chMF(mflua.MF,left_given);mflua.MF.left_given = left_given
-chMF(mflua.MF,left_tension);mflua.MF.left_tension = left_tension
-chMF(mflua.MF,right_curl);mflua.MF.right_curl = right_curl
-chMF(mflua.MF,right_given);mflua.MF.right_given = right_given
-chMF(mflua.MF,right_tension);mflua.MF.right_tension = right_tension
-chMF(mflua.MF,explicit);mflua.MF.explicit = explicit
-chMF(mflua.MF,given);mflua.MF.given = given
-chMF(mflua.MF,curl);mflua.MF.curl = curl
-chMF(mflua.MF,open);mflua.MF.open = open
-
-chMF(mflua.MF,right_octant);mflua.MF.right_octant = right_octant
-chMF(mflua.MF,left_octant);mflua.MF.left_octant = left_octant
-chMF(mflua.MF,right_transition);mflua.MF.right_transition = right_transition
-chMF(mflua.MF,left_transition);mflua.MF.left_transition = left_transition
-chMF(mflua.MF,axis);mflua.MF.axis = axis
-chMF(mflua.MF,diagonal);mflua.MF.diagonal = diagonal
-
-chMF(mflua.MF,mem_top);mflua.MF.mem_top = mem_top
-chMF(mflua.MF,sentinel);mflua.MF.sentinel = sentinel
-chMF(mflua.MF,null);mflua.MF.null = null
-chMF(mflua.MF,knil);mflua.MF.knil = knil
-chMF(mflua.MF,zero_w);mflua.MF.zero_w = zero_w
-chMF(mflua.MF,void);mflua.MF.void = void
-
-chMF(mflua.MF,zero_field);mflua.MF.zero_field = zero_field
-
-
--- @d incr(#) == #:=#+1 {increase a variable by unity}
-local function incr(p)
- return p+1
-end
-chMF(mflua.MF,incr);mflua.MF.incr = incr
-
--- decr(#) == #:=#-1 {decrease a variable by unity}
-local function decr(p)
- return p-1
-end
-chMF(mflua.MF,decr);mflua.MF.decr = decr
-
--- double(#) == #:=#+# {multiply a variable by two}
-local function double(p)
- return 2*p
-end
-chMF(mflua.MF,double);mflua.MF.double = double
-
-
-
--- @ An array of digits in the range |0..9| is printed by |print_the_digs|.
--- @<Basic print...@>=
--- procedure print_the_digs(@!k:eight_bits);
--- {prints |dig[k-1]|$\,\ldots\,$|dig[0]|}
--- begin while k>0 do
--- begin decr(k); print_char("0"+dig[k]);
--- end;
--- end;
-local function print_the_digs(k,dig)
- local res = ''
- while k > 0 do
- k=k-1
- res= res .. dig[k+1]
- end
- return res
-end
-chMF(mflua.MF,print_the_digs);mflua.MF.print_the_digs = print_the_digs
-
-
--- @<Basic print...@>=
--- procedure print_int(@!n:integer); {prints an integer in decimal form}
--- var k:0..23; {index to current digit; we assume that $|n|<10^{23}$}
--- @!m:integer; {used to negate |n| in possibly dangerous cases}
--- begin k:=0;
--- if n<0 then
--- begin print_char("-");
--- if n>-100000000 then negate(n)
--- else begin m:=-1-n; n:=m div 10; m:=(m mod 10)+1; k:=1;
--- if m<10 then dig[0]:=m
--- else begin dig[0]:=0; incr(n);
--- end;
--- end;
--- end;
--- repeat dig[k]:=n mod 10; n:=n div 10; incr(k);
--- until n=0;
--- print_the_digs(k);
--- end;
-local function print_int(n) -- {prints an integer in decimal form}
- local k -- 0..23; {index to current digit; we assume that $|n|<10^{23}$}
- local m -- {used to negate |n| in possibly dangerous cases}
- local dig = {}
- local done
- local res
- local sign=''
- k=0
- if n<0 then
- --begin print_char("-");
- sign='-'
- if n>-100000000
- then
- n=-n
- else
- m=-1-n; n=math.floor(m/10) ; m=math.fmod(m,10)+1; k=1;
- if m<10
- then
- dig[1]=m
- else
- dig[1]=0; n=n+1
- end
- end
- end
- done=false
- while not done do
- dig[k+1]=math.fmod(n,10); n=math.floor(n/10); k=k+1;
- if n==0 then done=true end
- end
- res = print_the_digs(k,dig)
- return sign .. res
-end
-chMF(mflua.MF,print_int);mflua.MF.print_int = print_int
-
-
-
--- @<Basic printing...@>=
--- procedure print_scaled(@!s:scaled); {prints scaled real, rounded to five
--- digits}
--- var @!delta:scaled; {amount of allowable inaccuracy}
--- begin if s<0 then
--- begin print_char("-"); negate(s); {print the sign, if negative}
--- end;
--- print_int(s div unity); {print the integer part}
--- s:=10*(s mod unity)+5;
--- if s<>5 then
--- begin delta:=10; print_char(".");
--- repeat if delta>unity then
--- s:=s+@'100000-(delta div 2); {round the final digit '}
--- print_char("0"+(s div unity)); s:=10*(s mod unity); delta:=delta*10;
--- until s<=delta;
--- end;
--- end;
-local function print_scaled(s)
- local delta
- local res = ''
- local done
- if s== nil then print("\nWarning: print_scale called with nil argument."); return res end
- if s<0 then
- res = '-'
- s=-s
- end
- res = res .. print_int(math.floor(s/unity)) -- {print the integer part}
- s=10*(math.fmod(s,unity))+5
- if s ~= 5 then
- delta=10; res = res .. '.'
- done = false
- while not done do
- if delta>unity then
- s=s+half_unit-(math.floor(delta/2)) -- {round the final digit}
- end
- res = res .. math.floor(s/unity); s=10*math.fmod(s,unity); delta=delta*10;
- if s<=delta then done = true end
- end;
- end
- return res
-end
-chMF(mflua.MF,print_scaled);mflua.MF.print_scaled = print_scaled
-
-
-
--- @<Basic printing...@>=
--- procedure print_two(@!x,@!y:scaled); {prints `|(x,y)|''}
--- begin print_char("("); print_scaled(x); print_char(","); print_scaled(y);
--- print_char(")");
--- end;
-local function print_two(x,y) -- {prints `|(x,y)|'}
- local res
- -- debug
- res = '(' .. print_scaled(x) .. ',' .. print_scaled(y) .. ')'
- return res
-end
-chMF(mflua.MF,print_two);mflua.MF.print_two = print_two
-
--- procedure unskew(@!x,@!y:scaled;@!octant:small_number);
--- begin case octant of
--- first_octant: set_two(x+y)(y);
--- second_octant: set_two(y)(x+y);
--- third_octant: set_two(-y)(x+y);
--- fourth_octant: set_two(-x-y)(y);
--- fifth_octant: set_two(-x-y)(-y);
--- sixth_octant: set_two(-y)(-x-y);
--- seventh_octant: set_two(y)(-x-y);
--- eighth_octant: set_two(x+y)(-y);
--- end; {there are no other cases}
--- end;
-local function unskew ( x , y , octant )
- local curx,cury
- if octant == 1 then
- curx = x + y ;
- cury = y ;
- elseif octant == 5 then
- curx = y ;
- cury = x + y ;
- elseif octant == 6 then
- curx = -y ;
- cury = x + y ;
- elseif octant == 2 then
- curx = -x - y ;
- cury = y ;
- elseif octant == 4 then
- curx = -x - y ;
- cury = -y ;
- elseif octant == 8 then
- curx = -y ;
- cury = -x - y ;
- elseif octant == 7 then
- curx = y ;
- cury = -x - y ;
- elseif octant == 3 then
- curx = x + y ;
- cury = -y ;
- end
- return curx,cury
-end
-chMF(mflua.MF,unskew);mflua.MF.unskew = unskew
-
--- print_two_true(#)==unskew(#,octant); print_two(cur_x,cur_y)
-local function print_two_true(x,y,octant)
- local cur_x,cur_y ,res
- cur_x,cur_y = unskew ( x , y , octant )
- res = print_two(cur_x,cur_y)
- return res
-end
-chMF(mflua.MF,print_two_true);mflua.MF.print_two_true = print_two_true
---
--- Debug only
---
--- function mflua_print_path(h)
--- print("mflua_print_path")
--- local p,q
--- local res
--- local done
--- local done1
--- local f
--- done = false
--- done1 = false
--- p = h
--- res = ''
--- while not done do
--- q = link(p)
--- if (p==0) or (q==0) then
--- res = "???"
--- -- do something with res --
--- return 0
--- end
--- res = res .. print_two(x_coord(p),y_coord(p)); -- print("res=",res)
--- if right_type(p) == endpoint then
--- if left_type(p)== open then print("{open?}") end -- {can't happen}
--- if (left_type(q) ~= endpoint) or (q ~= h) then q=null end -- {force an error}
--- done1 = true -- goto done1;
--- elseif right_type(p) == explicit then
--- -- begin "@<Print control points between |p| and |q|, then |goto done1|@>"
--- res = res .. "..controls " .. print_two(right_x(p),right_y(p)) .. " and ";
--- if left_type(q) ~= explicit then print("??") -- {can't happen}
--- else res = res .. print_two(left_x(q),left_y(q));
--- done1 = true -- goto done1;
--- end
--- -- end "@<Print control points between |p| and |q|, then |goto done1|@>"
--- elseif right_type(p) == open then
--- -- begin "@<Print information for a curve that begins |open|@>"
--- if (left_type(p) ~= explicit) and (left_type(p)~=open) then
--- res = res .. "{open?}" -- {can't happen}
--- end
--- -- end "@<Print information for a curve that begins |open|@>"
--- elseif (right_type(p) == curl) or (right_type(p) == given) then
--- -- @ A curl of 1 is shown explicitly, so that the user sees clearly that
--- -- \MF's default curl is present.
--- -- begin @<Print information for a curve that begins |curl|...@>=
--- if left_type(p)==open then res = res .. "??" end -- {can't happen}
--- if right_type(p)==curl then
--- res = res .. "{curl ".. print_scaled(right_curl(p))
--- else n_sin_cos(right_given(p)); res = res .."{"
--- res = res .. print_scaled(n_cos) .. "," .. print_scaled(n_sin)
--- end
--- res = res .."}"
--- -- end @<Print information for a curve that begins |curl|...@>=
--- else res = res .. "???" -- {can't happen}
--- end
--- if not done1 then -- mimic label done 1
--- if left_type(q)~=explicit then res = res .. "..control?" -- {can't happen}
--- else if (right_tension(p) ~= unity) or (left_tension(q) ~= unity) then
--- -- begin "@<Print tension between |p| and |q|@>;"
--- res = res .. "..tension "
--- if right_tension(p)<0 then res = res .. "atleast" end
--- res = res .. print_scaled(math.abs(right_tension(p)))
--- if right_tension(p) ~= left_tension(q) then
--- res = res .. " and "
--- if left_tension(q)<0 then res = res .. "atleast" end
--- res = res .. print_scaled(math.abs(left_tension(q)))
--- end
--- end -- "@<Print tension between |p| and |q|@>;"
--- end
--- end --- LABEL: done1
--- -- begin @<Print two dots...@>=
--- p = q
--- res = res .. " .."
--- if left_type(p)==given then
--- n_sin_cos(left_given(p)); res = res .. "{"
--- res = res .. print_scaled(n_cos); res = res .. ",";
--- res = res .. print_scaled(n_sin); res = res .. "}";
--- else if left_type(p)==curl then
--- res = res .. "{curl "; res = res .. print_scaled(left_curl(p)) .. "}";
--- end;
--- end
--- -- end @<Print two dots...@>=
--- -- end "@<Print information for adjacent knots |p| and |q|@>"
--- if p == h then done =true end
--- end
--- if left_type(h) ~= endpoint then
--- res = res .. "cycle"
--- else
--- res = res
--- end
--- -- do something with res --
--- return res
--- end
-
-
-
--- n_max(#)==link(#+1) {maximum row number present, plus |zero_field|}
-local function n_max(p)
- return link(p+1)
-end
-chMF(mflua.MF,n_max);mflua.MF.n_max = n_max
-
-
--- sorted_loc(#)==#+1 {where the |sorted| link field resides}
-local function sorted_loc(p)
- return p+1
-end
-chMF(mflua.MF,sorted_loc);mflua.MF.sorted_loc = sorted_loc
-
-
--- @d sorted(#)==link(sorted_loc(#)) {beginning of the list of sorted edge weights}
-local function sorted(p)
- return link(sorted_loc(p))
-end
-chMF(mflua.MF,sorted);mflua.MF.sorted = sorted
-
-
--- @d unsorted(#)==info(#+1) {beginning of the list of unsorted edge weights}
-local function unsorted(p)
- return info(p+1)
-end
-chMF(mflua.MF,unsorted);mflua.MF.unsorted = unsorted
-
--- @d ho(#)==#-min_halfword
--- {to take a sixteen-bit item from a halfword}
--- See mf.ch
--- ho(#) == #
-local function ho(p)
- return p
-end
-chMF(mflua.MF,ho);mflua.MF.ho = ho
---
--- @d m_offset(#)==info(#+3) {translation of $m$ data in edge-weight nodes}
---
-function m_offset(p)
- return info(p+3)
-end
-
-
-
--- @ @<Declare the procedure called |print_weight|@>=
--- procedure print_weight(@!q:pointer;@!x_off:integer);
--- var @!w,@!m:integer; {unpacked weight and coordinate}
--- @!d:integer; {temporary data register}
--- begin d:=ho(info(q)); w:=d mod 8; m:=(d div 8)-m_offset(cur_edges);
--- if file_offset>max_print_line-9 then print_nl(" ")
--- else print_char(" ");
--- print_int(m+x_off);
--- while w>zero_w do
--- begin print_char("+"); decr(w);
--- end;
--- while w<zero_w do
--- begin print_char("-"); incr(w);
--- end;
--- end;
-local function print_weight(q,x_off)
- local w,m -- {unpacked weight and coordinate}
- local d --{temporary data register}
- local cur_edges = MFbuiltin.cur_edges()
- local res = ''
- local temp
- d=ho(info(q)); w=math.fmod(d,8); m=math.floor(d/8)-m_offset(cur_edges);
- res = tostring(print_int(m+x_off))
- while w>zero_w do
- --print(tostring(print_int(m+x_off)) .. " w=" .. w.. " " .. zero_w .. " " .. (w-zero_w))
- res = res .. "+" ; w=decr(w);
- end
- while w<zero_w do
- --print(tostring(print_int(m+x_off)) .. " w=" .. w.. " " .. zero_w .. " " .. (w-zero_w))
- res = res .. "-" ; w=incr(w)
- end
- --print("res=" .. res .. "w=" .. math.fmod(d,8)-zero_w)
- return res, math.fmod(d,8)-zero_w,tostring(print_int(m+x_off))
-end
-chMF(mflua.MF,print_weight);mflua.MF.print_weight = print_weight
-
--- Others utilities functions
-local function odd(n)
- return math.fmod(n,2) == 1
-end
-chMF(mflua.MF,odd);mflua.MF.odd = odd
-
---------------------------------------------------------------------------------
---
--- Read-only callbacs aka Sensors
---
---------------------------------------------------------------------------------
-
-local function begin_program()
- PRINTDBG("begin_program")
-end
-
-local function PRE_start_of_MF()
- PRINTDBG("PRE_start_of_MF")
-end
-
-local function PRE_main_control()
- PRINTDBG("PRE_main_control")
-end
-
-local function POST_main_control()
- PRINTDBG("POST_main_control")
-end
-
-local function mflua_initialize()
- PRINTDBG("mflua_initialize")
-end
-
-local function POST_final_cleanup()
- PRINTDBG("POST_final_cleanup")
-end
-
-local function printpath(h,s,nuline)
- PRINTDBG("printpath")
- local p,q
- local res
- local done
- local done1
- local f
- done = false
- done1 = false
- p = h
- res = ''
- while not done do
- q = link(p)
- if (p==0) or (q==0) then
- res = "???"
- -- do something with res --
- return 0
- end
- -- We can choose to follow the pascal-web way
- -- or to follow the C-web2c way
- -- begin "@<Print information for adjacent knots |p| and |q|@>"
- res = res .. print_two(x_coord(p),y_coord(p)); -- print("res=",res)
- if right_type(p) == endpoint then
- if left_type(p)== open then print("{open?}") end -- {can't happen}
- if (left_type(q) ~= endpoint) or (q ~= h) then q=null end -- {force an error}
- done1 = true -- goto done1;
- elseif right_type(p) == explicit then
- -- begin "@<Print control points between |p| and |q|, then |goto done1|@>"
- res = res .. "..controls " .. print_two(right_x(p),right_y(p)) .. " and ";
- if left_type(q) ~= explicit then print("??") -- {can't happen}
- else res = res .. print_two(left_x(q),left_y(q));
- done1 = true -- goto done1;
- end
- -- end "@<Print control points between |p| and |q|, then |goto done1|@>"
- elseif right_type(p) == open then
- -- begin "@<Print information for a curve that begins |open|@>"
- if (left_type(p) ~= explicit) and (left_type(p)~=open) then
- res = res .. "{open?}" -- {can't happen}
- end
- -- end "@<Print information for a curve that begins |open|@>"
- elseif (right_type(p) == curl) or (right_type(p) == given) then
- -- @ A curl of 1 is shown explicitly, so that the user sees clearly that
- -- \MF's default curl is present.
- -- begin @<Print information for a curve that begins |curl|...@>=
- if left_type(p)==open then res = res .. "??" end -- {can't happen}
- if right_type(p)==curl then
- res = res .. "{curl ".. print_scaled(right_curl(p))
- else n_sin_cos(right_given(p)); res = res .."{"
- res = res .. print_scaled(n_cos) .. "," .. print_scaled(n_sin)
- end
- res = res .."}"
- -- end @<Print information for a curve that begins |curl|...@>=
- else res = res .. "???" -- {can't happen}
- end
- if not done1 then -- mimic label done 1
- if left_type(q)~=explicit then res = res .. "..control?" -- {can't happen}
- else if (right_tension(p) ~= unity) or (left_tension(q) ~= unity) then
- -- begin "@<Print tension between |p| and |q|@>;"
- res = res .. "..tension "
- if right_tension(p)<0 then res = res .. "atleast" end
- res = res .. print_scaled(math.abs(right_tension(p)))
- if right_tension(p) ~= left_tension(q) then
- res = res .. " and "
- if left_tension(q)<0 then res = res .. "atleast" end
- res = res .. print_scaled(math.abs(left_tension(q)))
- end
- end -- "@<Print tension between |p| and |q|@>;"
- end
- end --- LABEL: done1
- -- begin @<Print two dots...@>=
- p = q
- res = res .. " .."
- if left_type(p)==given then
- n_sin_cos(left_given(p)); res = res .. "{"
- res = res .. print_scaled(n_cos); res = res .. ",";
- res = res .. print_scaled(n_sin); res = res .. "}";
- else if left_type(p)==curl then
- res = res .. "{curl "; res = res .. print_scaled(left_curl(p)) .. "}";
- end;
- end
- -- end @<Print two dots...@>=
- -- end "@<Print information for adjacent knots |p| and |q|@>"
- if p == h then done =true end
- end
- if left_type(h) ~= endpoint then res = res .. "cycle" end
- -- do something with res --
- res = "%%Print path\n" .. "drawoptions(withcolor black withpen pencircle scaled 1pt);\n" .. "draw " .. res .. " ;\n"
- --print(res)
- -- local index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- -- local char = mflua.chartable[index] or {}
- -- char['char_wd'] = print_scaled(MFbuiltin.char_wd())
- -- char['char_ht'] = print_scaled(MFbuiltin.char_ht())
- -- char['char_dp'] = print_scaled(MFbuiltin.char_dp())
- -- char['char_ic'] = print_scaled(MFbuiltin.char_ic())
- -- char['res'] = char['res'] or ""
- -- char['res'] = char['res'] .. res
- -- mflua.chartable[index] = char
-end
-
-
--- @ The |print_edges| subroutine gives a symbolic rendition of an edge
--- structure, for use in `\&{show}\' commands. A rather terse output
--- format has been chosen since edge structures can grow quite large.
-
--- @<Declare subroutines for printing expressions@>=
--- @t\4@>@<Declare the procedure called |print_weight|@>@;@/
--- procedure print_edges(@!s:str_number;@!nuline:boolean;@!x_off,@!y_off:integer);
--- var @!p,@!q,@!r:pointer; {for list traversal}
--- @!n:integer; {row number}
--- begin
--- mflua_printedges(s,nuline,x_off,y_off);
--- print_diagnostic("Edge structure",s,nuline);
--- p:=knil(cur_edges); n:=n_max(cur_edges)-zero_field;
--- while p<>cur_edges do
--- begin q:=unsorted(p); r:=sorted(p);
--- if(q>void)or(r<>sentinel) then
--- begin print_nl("row "); print_int(n+y_off); print_char(":");
--- while q>void do
--- begin print_weight(q,x_off); q:=link(q);
--- end;
--- print(" |");
--- while r<>sentinel do
--- begin print_weight(r,x_off); r:=link(r);
--- end;
--- end;
--- p:=knil(p); decr(n);
--- end;
--- end_diagnostic(true);
--- end;
-local function printedges(s,nuline,x_off,y_off)
- PRINTDBG("printedges")
- local p,q,r -- for list traversal
- local n=0 -- row number
- local cur_edges = MFbuiltin.cur_edges()
- local res =''
- local y = {}
- local xr = {}
- local xq = {}
- local f, start_row, end_row ,start_row_1, end_row_1
- local edge
- local w,w_integer,row_weight,xoff
- local chartable = mflua.chartable
- local index
- local char
- p = knil(cur_edges)
- n = n_max(cur_edges)-zero_field
- while p ~= cur_edges do
- xq = {}; xr = {}
- q=unsorted(p); r=sorted(p)
- if(q>void)or(r~=sentinel) then
- res = "mflua row " .. print_int(n+y_off) ..":"
- while (q>void) do
- w, w_integer,xoff = print_weight(q,x_off)
- xq[#xq+1] = {xoff,w_integer}
- res = res .. w; q=link(q);
- end
- res = res .. " |"
- while r~=sentinel do
- w,w_integer,xoff = print_weight(r,x_off)
- xr[#xr+1]= {xoff,w_integer}
- res = res .. w .. ' '; r=link(r)
- end
- y[#y+1] = {print_int(n+y_off),xq,xr}
- end
- -- print(res)
- p=knil(p);n=decr(n);
- end
- --
- -- local management of y, xq, xr
- --
- index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- char = chartable[index] or {}
- --print("#xq=".. #xq)
- for i,v in ipairs(y) do
- xq,xr = v[2],v[3]
- -- for j=1, #xq, 2 do end ??
- row_weight=0
- for j=1, #xr, 1 do
- local xb = xr[j][1]
- local xwb = xr[j][2]
- row_weight=row_weight+xwb
- xr[j][3]=row_weight
- --print(v[1],xr[j][1],xr[j][2],xr[j][3])
- end
- end
- char['edges'] = char['edges'] or {}
- char['edges'][#char['edges']+1] = {y,x_off,y_off}
-
- char['pre_res'] = char['pre_res'] or ""
- for i,v in ipairs(y) do
- xq,xr = v[2],v[3]
- -- for j=1, #xq, 2 do end ??
- row_weight=0
- char['pre_res'] = char['pre_res'] .. "%% print edges " .. v[1] .. "\n"
- for j=1, #xr-1, 1 do
- local xb,xe = xr[j][1],xr[j+1][1]
- local xsb,xse = xr[j][3],xr[j+1][3]
- res = ""
- if xsb>0 then
- local color = {'0.7white','0.5white','0.4white'}
- local col = color[xsb] or 'black'
- res = res .. "drawoptions(withcolor " .. col .. " withpen pencircle scaled 0.1pt);\n"
- edge = string.format("fill (%s,%s) -- (%s,%s) -- (%s,%s+1) -- (%s,%s+1) -- cycle shifted (-(%s),-(%s));\n",
- xb,v[1],xe,v[1],xe,v[1],xb,v[1],x_off,y_off)
- res = res .. edge
- --
- res = res .. "drawoptions(withcolor black withpen pencircle scaled 0.1pt);\n"
- edge = string.format("draw (%s,%s) -- (%s,%s) -- (%s,%s+1) -- (%s,%s+1) -- cycle shifted (-(%s),-(%s));\n",
- xb,v[1],xe,v[1],xe,v[1],xb,v[1],x_off,y_off)
- res = res .. edge
- end
- -- print(v[1],xr[j][1],xr[j][2],xr[j][3])
- char['pre_res'] = char['pre_res'] .. res
- end
- end
-end
-mflua.MF.printedges = printedges
-
-
-
-
--- @ The |print_pen| subroutine illustrates these conventions by
--- reconstructing the vertices of a polygon from \MF\'s complicated
--- internal offset representation.
--- @<Declare subroutines for printing expressions@>=
-
-local function print_pen(p,s,nuline)
- local nothing_printed -- {:boolean has there been any action yet?}
- local k --1..8; {octant number}
- local h -- pointer; {offset list head}
- local m,n -- integer; {offset indices}
- local w,ww -- :pointer; {pointers that traverse the offset list}
- local res = ''
- -- begin print_diagnostic("Pen polygon",s,nuline);
- nothing_printed=true; -- print()
- for k=1,8 do
- local octant=octant_code[k]; h=p+octant; n=info(h); w=link(h);
- -- print("%% octant",octant_dir[octant],n,w)
- if not(odd(k)==true) then w=knil(w) end -- {in even octants, start at $w_{n+1}$}
- for m=1, n+1 do
- if odd(k)==true then ww=link(w) else ww=knil(w) end
- -- print("%% ".. m .. "/" .. n+1 .. " w=" .. print_two_true(x_coord(w),y_coord(w),octant) .. " ww=" .. print_two_true(x_coord(ww),y_coord(ww),octant))
- if (x_coord(ww)~=x_coord(w)) or (y_coord(ww)~=y_coord(w)) then
- ---@<Print the unskewed and unrotated coordinates of node |ww|@>;
- if nothing_printed then nothing_printed=false else -- print(" .. ")
- end
- -- print(print_two_true(x_coord(ww),y_coord(ww),octant))
- res = res .. print_two_true(x_coord(ww),y_coord(ww),octant)
- end
- w=ww;
- end -- for m=1, n+1 do
- end -- for k=1,8 do
- if nothing_printed==true then
- w=link(p+first_octant); print(print_two(x_coord(w)+y_coord(w),y_coord(w)));
- res = res .. print_two(x_coord(w)+y_coord(w),y_coord(w))
- end;
- res = res .. " .. cycle"; --end_diagnostic(true);
- return res
-end -- function
-mflua.MF.print_pen = print_pen
-
-mflua.offset_prep = mflua.offset_prep or {}
-
-local function _get_pen(p)
- local nothing_printed -- {:boolean has there been any action yet?}
- local k --1..8; {octant number}
- local h -- pointer; {offset list head}
- local m,n -- integer; {offset indices}
- local w,ww -- :pointer; {pointers that traverse the offset list}
- local res = {}
- nothing_printed=true;
- for k=1,8 do
- local octant=octant_code[k]; h=p+octant; n=info(h); w=link(h);
- if not(odd(k)==true) then w=knil(w) end -- {in even octants, start at $w_{n+1}$}
- for m=1, n+1 do
- if odd(k)==true then ww=link(w) else ww=knil(w) end
- if (x_coord(ww)~=x_coord(w)) or (y_coord(ww)~=y_coord(w)) then
- ---@<Print the unskewed and unrotated coordinates of node |ww|@>;
- if nothing_printed then nothing_printed=false else -- print(" .. ")
- end
- -- print(print_two_true(x_coord(ww),y_coord(ww),octant))
- res[#res+1] = print_two_true(x_coord(ww),y_coord(ww),octant)
- end
- w=ww;
- end -- for m=1, n+1 do
- end -- for k=1,8 do
- if nothing_printed==true then
- w=link(p+first_octant);
- res[#res+1] = print_two(x_coord(w)+y_coord(w),y_coord(w))
- end;
- -- print(" .. cycle"); --end_diagnostic(true);
- return res
-end
-mflua.offset_prep._get_pen = _get_pen
-
-local function _get_offset_coords(p,octant)
- local nothing_printed -- {:boolean has there been any action yet?}
- local k --1..8; {octant number}
- local h -- pointer; {offset list head}
- local m,n -- integer; {offset indices}
- local w,ww -- :pointer; {pointers that traverse the offset list}
- local res ={}
- nothing_printed=true; --print()
- k=octant_number[octant];
- h=p+octant; n=info(h); w=link(h);
- if not(odd(k)==true) then w=knil(w) end -- {in even octants, start at $w_{n+1}$}
- for m=1, n+1 do
- if odd(k)==true then ww=link(w) else ww=knil(w) end
- res[m] = print_two_true(x_coord(w),y_coord(w),octant)
- w=ww;
- end -- for m=1, n+1 do
- return res
-end -- function
-mflua.offset_prep._get_offset_coords = _get_offset_coords
-
-
--- @ Given a pointer |c| to a nonempty list of cubics,
--- and a pointer~|h| to the header information of a pen polygon segment,
--- the |offset_prep| routine changes the list into cubics that are
--- associated with particular pen offsets. Namely, the cubic between |p|
--- and~|q| should be associated with the |k|th offset when |right_type(p)=k|.
-
--- List |c| is actually part of a cycle spec, so it terminates at the
--- first node whose |right_type| is |endpoint|. The cubics all have
--- monotone-nondecreasing $x(t)$ and $y(t)$.
-
-mflua.do_add_to = mflua.do_add_to or {}
-mflua.do_add_to.bezier_octant = {}
-mflua.do_add_to.bezier_octant_envelope = {}
-mflua.do_add_to.bezier_octant_I = {}
-mflua.do_add_to.bezier_octant_contour = {}
-
-
-local function print_specification(c,h)
- local p,q,n,nh
- local octant
- local cur_spec
- local res,res1 = "",""
- local offsets = {}
- local cubic,cubics ={},{}
- local f
- local first_point, first_point_offset
-
- local bezier,beziers ={},{}
- local offset_list = {}
- local path_list ={}
- local bezier_octant
- local pen_key = ''
- local temp1 = mflua.print_specification.temp1
-
- cur_spec=c
- p=cur_spec
- --n=info(h)
- --lh=link(h) --{now |lh| points to $w_0$}
- octant = left_octant(p)
- offsets = mflua.offset_prep._get_offset_coords(MFbuiltin.cur_pen(),octant)
-
- -- for l=1,#offsets do print("SPEC " .. offsets[l] )end
-
- cubics['offsets'] = offsets
- cubics['octant_number'] = octant_number[octant]
-
- beziers['offsets'] = offsets
- beziers['octant_number'] = octant_number[octant]
- beziers['pen'] = mflua.offset_prep._get_pen(MFbuiltin.cur_pen())
-
- for i,v in ipairs(beziers['pen']) do
- --print( "BEZ pen=",i,v)
- pen_key = pen_key..v
- end
- --if not(mflua.pen[pen_key] == nil) then
- --table.foreach(mflua.pen[pen_key],print)
- --end
- --
- --res = res .. "%% cur_pen " .. tostring(MFbuiltin.cur_pen()) .."\n"
- --res = res .. string.format("%%%% current octant %s, octant number %s, offset %s\n",octant_dir[MFbuiltin.octant()],octant_number[octant],print_int(n))
- --res = res .. "pair offset[];\n"
- --for i,v in ipairs(offsets) do
- -- res = res .. string.format("offset%s:=%s;\n",i-1,v)
- --end
- --res = res .. "pair OffSet; OffSet:=offset"..print_int(n) ..";\n"
- --res = res .. "path p; p:= " .. print_two_true(x_coord(p),y_coord(p),octant) .. "\n"
- --cubic['p'] = print_two_true(x_coord(p),y_coord(p),octant)
- first_point = print_two_true(x_coord(p),y_coord(p),octant)
- first_point_offset = print_int(right_type(p))
- --
- --print(res);
- local end_loop_1 = false
- while end_loop_1 == false do
- local end_loop_2 = false
- while end_loop_2 == false do
- q=link(p);
- if right_type(p)==endpoint then
- end_loop_2=true
- else
- cubic['p'] = print_two_true(x_coord(p),y_coord(p),octant);
- cubic['control1'] = print_two_true(right_x(p),right_y(p),octant)
- cubic['control2'] = print_two_true(left_x(q),left_y(q),octant)
- cubic['q'] = print_two_true(x_coord(q),y_coord(q),octant)
- cubic['offset'] = print_int(right_type(p))
- cubic['segment'] = print_int(left_type(q)-1)
- cubics[#cubics+1] = cubic
- cubic = {}
- bezier['p'] = print_two_true(x_coord(p),y_coord(p),octant);
- bezier['control1'] = print_two_true(right_x(p),right_y(p),octant)
- bezier['control2'] = print_two_true(left_x(q),left_y(q),octant)
- bezier['q'] = print_two_true(x_coord(q),y_coord(q),octant)
- bezier['offset'] = print_int(right_type(p))
- bezier['segment'] = print_int(left_type(q)-1)
- beziers[#beziers+1] = bezier
- bezier = {}
- p=q
- end
- end
- -- not_found label
- if q==cur_spec then
- end_loop_1=true
- else
- p=q; octant=left_octant(p); -- print("% entering octant `");
- end
- -- We don't want all the octans of the cubic
- -- only the pieces of the current octant
- end_loop_1 = not(MFbuiltin.octant() == octant)
- end
- if #cubics == 0 then
- cubics['single_point'] = first_point
- cubics['single_point_offset'] = first_point_offset
- end
- -- done label:
- -- We can now use the results
- --
- -- No curves stored
- if #beziers == 0 then
- beziers['single_point'] = first_point
- beziers['single_point_offset'] = first_point_offset
- end
- if #beziers['offsets'] == 1 then
- offset_list[#offset_list+1] = {0,beziers['offsets'][1]}
- offset_list[#offset_list+1] = {1,beziers['offsets'][1]}
- else
- for i,v in ipairs(beziers['offsets']) do
- if odd(beziers['octant_number']) == true then
- offset_list[#offset_list+1] = {(i-1),v}
- else
- offset_list[#offset_list+1] = {#beziers['offsets']-i+1,v}
- end
- end
- end
- beziers['offset_list']=offset_list
- beziers['path_list'] = {}
- if #beziers == 0 then
- path_list['p'] = beziers['single_point']
- if odd(beziers['octant_number']) == true then
- path_list['offset'] = beziers['single_point_offset']
- else
- path_list['offset'] = #beziers['offsets']-beziers['single_point_offset']
- end
- beziers['path_list'][#beziers['path_list']+1] = path_list
- path_list={}
- else
- for i,v in ipairs(beziers) do
- bezier = v
- path_list['p'] = bezier['p']
- path_list['control1'] = bezier['control1']
- path_list['control2'] = bezier['control2']
- path_list['q'] = bezier['q']
- path_list['offset'] = bezier['offset']
- beziers['path_list'][#beziers['path_list']+1] = path_list
- path_list={}
- end
- end
- bezier_octant =mflua.do_add_to.bezier_octant
- bezier_octant[#bezier_octant+1] = beziers
- res = ""
- res = res .. "%% cur_pen " .. tostring(MFbuiltin.cur_pen()) .."\n"
- --res = res .. string.format("%%%% current octant %s, offset %s\n",octant_dir[MFbuiltin.octant()],print_int(n))
- res = res .. string.format("%%%% current octant %s\n",octant_dir[MFbuiltin.octant()])
- res = res .. "pair offset[];\n"
- if #cubics['offsets'] == 1 then
- res = res .."%% Only one offset\n"
- res = res ..string.format("offset%s:=%s;\n",0,cubics['offsets'][1])
- res = res ..string.format("offset%s:=%s;\n",1,cubics['offsets'][1])
- else
- for i,v in ipairs(cubics['offsets']) do
- if odd(cubics['octant_number']) == true then
- res = res .. string.format("offset%s:=%s;\n",(i-1),v)
- else
- res = res .. string.format("offset%s:=%s;\n",#cubics['offsets']-i+1,v)
- end
- end
- end
- res = res .. "%% cubics['octant_number'])=" .. cubics['octant_number'] .. "\n"
- res = res .. "%% #cubics=" .. #cubics .. "\n"
- if #cubics == 0 then
- res = res .. "path p; p:=" .. cubics['single_point'] .. ";\n"
- res = res .. "drawoptions(withcolor red withpen pencircle scaled 0.1pt);\n"
- temp1 = temp1 +1
- if odd(cubics['octant_number']) == true then
- res = res .. "draw p shifted offset" .. cubics['single_point_offset'] .. ";\n"
- res = res .. string.format("pickup pencircle scaled 0.2pt;drawdot(%s) shifted offset%s withcolor 0.75white;label(\"%s\",%s+(-0.5,-0.5)) shifted offset%s;\n",
- cubics['single_point'],cubics['single_point_offset'],temp1,cubics['single_point'],cubics['single_point_offset'])
- else
- res = res .. "draw p shifted offset" .. #cubics['offsets']-cubics['single_point_offset'] .. ";\n"
- res = res .. string.format("pickup pencircle scaled 0.2pt;drawdot(%s) shifted offset%s withcolor 0.75white;label(\"%s\",%s+(-0.5,-0.5)) shifted offset%s;\n",
- cubics['single_point'],#cubics['offsets']-cubics['single_point_offset'],temp1,cubics['single_point'],#cubics['offsets']-cubics['single_point_offset'])
- end
- end
- -- if #cubics == 0 then this for loop is never executed
- for i,v in ipairs(cubics) do
- cubic = v
- res = res .. "path p; p:= " .. cubic['p'] .."\n"
- res = res .. " .. controls " .. cubic['control1'] .." and " .. cubic['control2']
- res = res .. " .. " .. cubic['q'] .."\n ;\n"
- res = res .. 'label("'.. octant_dir[MFbuiltin.octant()] ..'"' .. ",0.5[" .. cubic['p'] .. "," .. cubic['q'] .."]) shifted offset" .. cubic['offset'] .. ";\n"
- res = res .. "drawoptions(withcolor black withpen pencircle scaled 0.2pt);\n"
- res = res .. "draw p shifted offset" .. cubic['offset'] .. ";\n"
- temp1 = temp1 +1
- res = res .. string.format("pickup pencircle scaled 0.2pt;drawdot(%s) shifted offset%s withcolor 0.75white;label(\"%s\",%s+(-0.5,-0.5)) shifted offset%s;\n",
- cubic['p'],cubic['offset'],temp1,cubic['p'],cubic['offset'])
- temp1 = temp1 +1
- res = res .. string.format("pickup pencircle scaled 0.2pt;drawdot(%s) shifted offset%s withcolor 0.75white;label(\"%s\",%s+(0.5,0.5)) shifted offset%s;\n",
- cubic['q'],cubic['offset'],temp1,cubic['q'],cubic['offset'])
-
- end
- mflua.print_specification.temp1 = temp1
- res = res .. string.format("%%%%mflua.print_specification.temp1 = %s\n" ,mflua.print_specification.temp1)
- --print("\n%%POST START\n".. res .. "%%POST END\n")
- -- f = io.open("envelope.tex",'a')
- -- f = mflua.print_specification.outfile1
- -- f:write("\n%%POST START\n".. res .. "\n%%POST END\n")
- --f:close()
- return res
-end
-mflua.MF.print_specification = print_specification
-
-
-
-local function PRE_offset_prep(c,h)
- PRINTDBG("PRE_offset_prep")
- -- local p = c
- -- print("\nBEZ TEST".. print_int(right_type(p)))
- -- print ("BEZ TEST".. print_two(x_coord(p),y_coord(p)))
- -- print ("BEZ TEST".. print_two(right_x(p),right_y(p)))
- -- p = link(p)
- -- print ("BEZ TEST".. print_two(left_x(p),left_y(p)))
-end
-
-local function POST_offset_prep(c,h)
- PRINTDBG("POST_offset_prep")
- -- print("\nPOST print pen"); mflua.MF.print_pen(MFbuiltin.cur_pen(),"" , "")
- -- print("\nPOST print specification")
- --res = print_pen(MFbuiltin.cur_pen(),"" , "")
- --print(" PRINT PEN " .. res )
- mflua.MF.print_specification(c,h)
-end
-
-
-mflua.do_add_to = mflua.do_add_to or {}
-
-local function _get_cycle(h)
- local p,q
- local res = ''
- local done
- local done1
- local f
- local cycle = {}
- done = false
- done1 = false
- p = h
- while not done do
- q = link(p)
- if (p==0) or (q==0) then
- return '???'
- end
- cycle[#cycle+1] = {tonumber(print_scaled(x_coord(p))), tonumber(print_scaled(y_coord(p)))} -- p
- --res = res .. print_two(x_coord(p),y_coord(p)); -- print("res=",res)
- if right_type(p) == endpoint then
- if left_type(p)== open then return "{open?}" end -- {can't happen}
- if (left_type(q) ~= endpoint) or (q ~= h) then q=null end -- {force an error}
- done1 = true -- goto done1;
- elseif right_type(p) == explicit then
- -- begin "@<Print control points between |p| and |q|, then |goto done1|@>"
- --res = res .. "..controls " .. print_two(right_x(p),right_y(p)) .. " and ";
- cycle[#cycle+1] = {tonumber(print_scaled(right_x(p))), tonumber(print_scaled(right_y(p)))} -- c1
- if left_type(q) ~= explicit then return "??" -- {can't happen}
- else
- --res = res .. print_two(left_x(q),left_y(q));
- cycle[#cycle+1] = {tonumber(print_scaled(left_x(q))), tonumber(print_scaled(left_y(q)))} -- c2
- done1 = true -- goto done1;
- end
- -- end "@<Print control points between |p| and |q|, then |goto done1|@>"
- elseif right_type(p) == open then
- -- begin "@<Print information for a curve that begins |open|@>"
- if (left_type(p) ~= explicit) and (left_type(p)~=open) then
- return "{open?}" -- {can't happen}
- end
- -- end "@<Print information for a curve that begins |open|@>"
- elseif (right_type(p) == curl) or (right_type(p) == given) then
- -- @ A curl of 1 is shown explicitly, so that the user sees clearly that
- -- \MF's default curl is present.
- -- begin @<Print information for a curve that begins |curl|...@>=
- if left_type(p)==open then res = res .. "??" end -- {can't happen}
- if right_type(p)==curl then
- res = res .. "{curl ".. print_scaled(right_curl(p))
- else n_sin_cos(right_given(p)); res = res .."{"
- res = res .. print_scaled(n_cos) .. "," .. print_scaled(n_sin)
- end
- res = res .."}"
- -- end @<Print information for a curve that begins |curl|...@>=
- else return "???" -- {can't happen}
- end
- if not done1 then -- mimic label done 1
- if left_type(q)~=explicit then return "..control?" -- {can't happen}
- else if (right_tension(p) ~= unity) or (left_tension(q) ~= unity) then
- -- begin "@<Print tension between |p| and |q|@>;"
- res = res .. "..tension "
- if right_tension(p)<0 then res = res .. "atleast" end
- res = res .. print_scaled(math.abs(right_tension(p)))
- if right_tension(p) ~= left_tension(q) then
- res = res .. " and "
- if left_tension(q)<0 then res = res .. "atleast" end
- res = res .. print_scaled(math.abs(left_tension(q)))
- end
- end -- "@<Print tension between |p| and |q|@>;"
- end
- end --- LABEL: done1
- -- begin @<Print two dots...@>=
- p = q
- --res = res .. " .."
- if left_type(p)==given then
- n_sin_cos(left_given(p)); res = res .. "{"
- res = res .. print_scaled(n_cos); res = res .. ",";
- res = res .. print_scaled(n_sin); res = res .. "}";
- else if left_type(p)==curl then
- res = res .. "{curl "; res = res .. print_scaled(left_curl(p)) .. "}";
- end;
- end
- -- end @<Print two dots...@>=
- -- end "@<Print information for adjacent knots |p| and |q|@>"
- if p == h then done =true end
- end
- if left_type(h) ~= endpoint then
- res = res .. "cycle"
- end
- -- do something with res --
- return res ,cycle
-end
-mflua.do_add_to._get_cycle = _get_cycle
-
-
--- @p procedure print_spec(@!s:str_number);
--- label not_found,done;
--- var @!p,@!q:pointer; {for list traversal}
--- @!octant:small_number; {the current octant code}
--- begin print_diagnostic("Cycle spec",s,true);
--- @.Cycle spec at line...@>
--- p:=cur_spec; octant:=left_octant(p); print_ln;
--- print_two_true(x_coord(cur_spec),y_coord(cur_spec));
--- print(" % beginning in octant `");
--- loop@+ begin print(octant_dir[octant]); print_char("'");
--- loop@+ begin q:=link(p);
--- if right_type(p)=endpoint then goto not_found;
--- @<Print the cubic between |p| and |q|@>;
--- p:=q;
--- end;
--- not_found: if q=cur_spec then goto done;
--- p:=q; octant:=left_octant(p); print_nl("% entering octant `");
--- end;
--- @.entering the nth octant@>
--- done: print_nl(" & cycle"); end_diagnostic(true);
--- end;
-local function _print_spec(cur_spec)
- --print("\n.....Hello world from _print_spec!.....")
- local p,q
- local octant
- --local res = ''
- local knot = {}
- local knots = {}
- -- local res = {}
- local endloop1 = false
- local endloop2 = false
-
- p=cur_spec; octant=left_octant(p); --print()
- -- res = res .. print_two_true(x_coord(cur_spec),y_coord(cur_spec),octant)
- knot[#knot+1] = print_two_true(x_coord(cur_spec),y_coord(cur_spec),octant)
- while (endloop1 == false) do
- -- print('%%' .. octant_dir[octant])
- endloop2 = false
- while (endloop2 == false) do
- q = link(p)
- if right_type(p)==endpoint then
- endloop2 = true -- goto not_found;
- else
- -- print(' @<Print the cubic between |p| and |q|@>;')
- -- c1
- knot[#knot+1] = print_two_true(right_x(p),right_y(p),octant)
- -- c2
- knot[#knot+1] = print_two_true(left_x(q),left_y(q),octant)
- -- q
- knot[#knot+1] = print_two_true(x_coord(q),y_coord(q),octant)
- -- segment
- knot[#knot+1] = print_int(left_type(q)-1)
- knots[#knots+1] = knot
- knot = {}
- -- res = res .." ..controls "
- -- res = res .. print_two_true(right_x(p),right_y(p),octant)
- -- res = res .." and "
- -- res = res ..print_two_true(left_x(q),left_y(q),octant)
- -- res = res .. "\n .."
- -- res = res .. print_two_true(x_coord(q),y_coord(q),octant)
- -- res = res .." % segment " ..print_int(left_type(q)-1) .. "\n";
- p=q;
- knot[#knot+1] = print_two_true(x_coord(p),y_coord(p),octant)
- end
- end -- endloop2
- -- not_found
- if q == cur_spec then
- endloop1 = true
- else
- p=q; octant=left_octant(p) -- print("% entering octant `");
- end
- end -- endloop1
- --done:
- -- print(" & cycle") ; end_diagnostic(true);
- -- print("%BEZ TEST\ndraw "..res .. ";\n")
- -- table.foreach(knots,function (k) table.foreach(knots[k],print) end)
- return knots
-end
-mflua.do_add_to._print_spec = _print_spec
-
-
-local function _store_current_envelope()
- local bezier_octant_envelope = mflua.do_add_to.bezier_octant_envelope
- local bezier_octant = mflua.do_add_to.bezier_octant
- if (#bezier_octant_envelope == 0) then
- local _t = {}
- for i,v in ipairs(bezier_octant) do _t[i] = v end
- bezier_octant_envelope[1] = _t
- else
- local _cnt=0
- for i,v in ipairs(bezier_octant_envelope) do _cnt=_cnt+#v end
- local _t = {}
- for i,v in ipairs(bezier_octant) do if i>_cnt then _t[#_t+1] = v end end
- bezier_octant_envelope[#bezier_octant_envelope+1] = _t
- end
- mflua.do_add_to.bezier_octant_envelope = bezier_octant_envelope
- return 0
-end
-mflua.do_add_to._store_current_envelope = _store_current_envelope
-
-
-local function _postprocessing()
- local bezier_octant
- local beziers,offsets
-
- local path_list
- local prev_point
- local path_cnt
- local res = "%% postprocessing envelope\n"
- local f
- local chartable = mflua.chartable
- local index
- local char
-
- index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- --print("CHAR " .. index)
- --print("%% postprocessing envelope "..index.. ' ' .. #chartable)
-
- res = res .. "path p[];\n"
-
- -- The last part of envelope added
- bezier_octant = mflua.do_add_to.bezier_octant_envelope[#mflua.do_add_to.bezier_octant_envelope]
-
- path_cnt = 1
- for i,v in ipairs(bezier_octant) do
- beziers = v
- offsets = beziers['offsets']
- path_list = beziers['path_list']
- local offset_list = beziers['offset_list']
- for i,path in ipairs(path_list) do
- local shifted
- local p,c1,c2,q,offset =
- path['p'],path['control1'],path['control2'],path['q'],path['offset']
- for i,v in ipairs(offset_list) do
- if v[1] == (0+offset) then
- shifted = v[2]
- break
- end
- end
- if (q == nil) then
- res = res .. string.format("p%d:=(%s) shifted %s;%% shifted 1\n",
- path_cnt,p,shifted)
- else
- res = res .. string.format("p%d:=(%s .. controls %s and %s .. %s) shifted %s;%% shifted 2\n",
- path_cnt,p,c1,c2,q,shifted)
- end
- path_cnt = path_cnt +1
- end
- end
- res = res .. "%% path_cnt=" .. path_cnt .. " char_code=" .. print_int(MFbuiltin.char_code()) .. " char_ext=" .. print_int(MFbuiltin.char_ext())
- res = res .. " char_wd=" .. print_scaled(MFbuiltin.char_wd())
- res = res .. " char_ht=" .. print_scaled(MFbuiltin.char_ht())
- res = res .. " char_dp=" .. print_scaled(MFbuiltin.char_dp())
- res = res .. " char_ic=" .. print_scaled(MFbuiltin.char_ic())
- res = res .. " \n"
-
- res = res .. "drawoptions(withcolor (" .. math.random().."," .. math.random()..",".. math.random().. ") withpen pencircle scaled 0.4pt);\n"
- res = res .. "draw p1"
- for i=2,path_cnt-1 do
- res = res .. string.format(" -- p%d",i)
- end
- res = res .. " --cycle;\n"
-
- index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- char = chartable[index] or {}
- char['char_wd'] = print_scaled(MFbuiltin.char_wd())
- char['char_ht'] = print_scaled(MFbuiltin.char_ht())
- char['char_dp'] = print_scaled(MFbuiltin.char_dp())
- char['char_ic'] = print_scaled(MFbuiltin.char_ic())
- char['envelope'] = char['envelope'] or {}
- char['envelope'][#char['envelope']+1] = bezier_octant
- char['res'] = char['res'] or ""
- char['res'] = char['res'] .. res
- char['index'] = index
- chartable[index] = char
-end
-mflua.do_add_to._postprocessing = _postprocessing
-
-
-local function _store_current_contour()
- local bezier_octant_contour = mflua.do_add_to.bezier_octant_contour
- local bezier_octant_I = mflua.do_add_to.bezier_octant_I
- if (#bezier_octant_contour == 0) then
- local _t = {}
- for i,v in ipairs(bezier_octant_I) do _t[i] = v end
- bezier_octant_contour[1] = _t;
- else
- local _cnt=0
- for i,v in ipairs(bezier_octant_contour) do _cnt=_cnt+#v end
- local _t = {}
- for i,v in ipairs(bezier_octant_I) do if i>_cnt then _t[#_t+1] = v; end end
- bezier_octant_contour[#bezier_octant_contour+1] = _t
- end
- mflua.do_add_to.bezier_octant_contour = bezier_octant_contour
- return 0
-end
-mflua.do_add_to._store_current_contour = _store_current_contour
-
-
-local function _postprocessing_contour()
- local bezier_octant_contour,contour,path_list
- local chartable = mflua.chartable
- local index
- local char
- local res = ""
- index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- res = res .. "%% postprocessing contour for " .. index ..";\n"
- res = res .. "path p[];\n"
- --print("\n_postprocessing_contour CHAR " .. index)
- bezier_octant_contour = mflua.do_add_to.bezier_octant_contour[#mflua.do_add_to.bezier_octant_contour]
-
- path_cnt = 1
- for i,v in ipairs(bezier_octant_contour) do
- contour = v
- path_list = contour['path_list']
- for i,path in ipairs(path_list) do
- local p,c1,c2,q = path['p'],path['control1'],path['control2'],path['q']
- if (q == nil) then
- res = res .. string.format("p%d:=(%s);\n", path_cnt,p)
- else
- res = res .. string.format("p%d:=(%s .. controls %s and %s .. %s);\n",path_cnt,p,c1,c2,q)
- end
- path_cnt = path_cnt +1
- end
- end
- if path_cnt > 1 then
- res = res .. "drawoptions(withcolor black withpen pencircle scaled 0.3pt);\n"
- res = res .. "draw p1"
- for i=2,path_cnt-1 do
- res = res .. string.format(" -- p%d",i)
- end
- res = res .. " --cycle ;\n"
- end
-
-
- index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- --print("BEZ index="..index)
- char = chartable[index] or {}
- char['char_wd'] = print_scaled(MFbuiltin.char_wd())
- char['char_ht'] = print_scaled(MFbuiltin.char_ht())
- char['char_dp'] = print_scaled(MFbuiltin.char_dp())
- char['char_ic'] = print_scaled(MFbuiltin.char_ic())
- char['contour'] = char['contour'] or {}
- char['contour'][#char['contour']+1] = bezier_octant_contour
- char['res'] = char['res'] or ""
- char['res'] = char['res'] .. res ;
- char['index'] = index
- chartable[index] = char
- return 0
-end
-mflua.do_add_to._postprocessing_contour = _postprocessing_contour
-
--- local function _circular_list_geti(l,i)
--- local size = #l
--- if size==0 then
--- return nil
--- end
--- return l[1+(i-1)%size]
--- end
-
-
-local function _store_current_cycle(hs)
- local res, current_cycle
- res, current_cycle = mflua.do_add_to._get_cycle(hs)
- if res=='cycle' then
- local index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- local char = mflua.chartable[index] or {}
- char['cycle'] = char['cycle'] or {}
- char['cycle'][#char['cycle']+1] = current_cycle
-
- mflua.chartable[index] = char
- else
- print("Error:"..res)
- end
-end
-mflua.do_add_to._store_current_cycle = _store_current_cycle
-
-
-local function PRE_make_spec_rhs(rhs)
- PRINTDBG("PRE_make_spec_rhs")
- mflua.do_add_to._store_current_cycle(rhs)
-end
-
-local function POST_make_spec_rhs(rhs)
- PRINTDBG("POST_make_spec_rhs")
- --mflua.do_add_to._store_current_cycle(rhs)
- --print("post rhs MFbuiltin.turning_number=",MFbuiltin.turning_number() ) ;
-end
-
-
-local function PRE_make_spec_lhs(lhs)
- PRINTDBG("PRE_make_spec_lhs")
- mflua.do_add_to._store_current_cycle(lhs)
-end
-
-local function POST_make_spec_lhs(lhs)
- PRINTDBG("PRE_make_spec_lhs")
- --mflua.do_add_to._store_current_cycle(lhs)
- --print("post lhs MFbuiltin.turning_number=",MFbuiltin.turning_number() ) ;
-end
-
-local function PRE_fill_envelope_rhs(rhs)
- PRINTDBG("PRE_fill_envelope_rhs")
- local knots ,knots_list
- local index,char
- local chartable = mflua.chartable
- knots = mflua.do_add_to._print_spec(rhs)
- index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- char = chartable[index] or {}
- knots_list = char['knots'] or {}
- knots_list[#knots_list+1] = knots
- char['knots'] = knots_list
- chartable[index] = char
-end
-
-local function POST_fill_envelope_rhs(rhs)
- PRINTDBG("POST_fill_envelope_rhs")
- mflua.do_add_to._store_current_envelope()
- mflua.do_add_to._postprocessing()
-end
-
-local function PRE_fill_envelope_lhs(lhs)
- PRINTDBG("PRE_fill_envelope_lhs")
-end
-
-local function POST_fill_envelope_lhs(lhs)
- PRINTDBG("POST_fill_envelope_lhs")
- mflua.do_add_to._store_current_envelope()
- mflua.do_add_to._postprocessing()
-end
-
-local function PRE_fill_spec_rhs(rhs)
- PRINTDBG("PRE_fill_spec_rhs")
- --print_specification_contour(rhs)
-end
-
-local function POST_fill_spec_rhs(rhs)
- PRINTDBG("POST_fill_spec_rhs")
- mflua.do_add_to._store_current_contour()
- mflua.do_add_to._postprocessing_contour()
-end
-
-local function PRE_fill_spec_lhs(lhs)
- PRINTDBG("PRE_fill_spec_lhs")
- --print_specification_contour(lhs)
-end
-
-local function POST_fill_spec_lhs(lhs)
- PRINTDBG("POST_fill_spec_lhs")
- mflua.do_add_to._store_current_contour()
- mflua.do_add_to._postprocessing_contour()
-end
-
-
---------------------------------------------------------------------------------
---
--- fill_spec
---
---------------------------------------------------------------------------------
-
-mflua.fill_spec = mflua.fill_spec or {}
-
--- @ Here's a routine that prints a cycle spec in symbolic form, so that it
--- is possible to see what subdivision has been made. The point coordinates
--- are converted back from \MF's internal ``rotated'' form to the external
--- ``true'' form. The global variable~|cur_spec| should point to a knot just
--- after the beginning of an octant boundary, i.e., such that
--- |left_type(cur_spec)=endpoint|.
-local function print_specification_contour(h)
- local p,q,n,nh
- local octant
- local cur_spec
- local res = ""
- local f
- local first_point, first_point_offset
- local path_cnt
- local bezier_contour,beziers_contour ={},{}
- local offset_list = {}
- local path_list ={}
- local bezier_octant_I
- cur_spec=h
- p=cur_spec
- octant = left_octant(p)
- beziers_contour['octant_number'] = octant_number[octant]
- first_point = print_two_true(x_coord(p),y_coord(p),octant)
- first_point_offset = print_int(right_type(p))
- local end_loop_1 = false
- while end_loop_1 == false do
- local end_loop_2 = false
- while end_loop_2 == false do
- q=link(p);
- if right_type(p)==endpoint then
- end_loop_2=true
- else
- bezier_contour['p'] = print_two_true(x_coord(p),y_coord(p),octant);
- bezier_contour['control1'] = print_two_true(right_x(p),right_y(p),octant)
- bezier_contour['control2'] = print_two_true(left_x(q),left_y(q),octant)
- bezier_contour['q'] = print_two_true(x_coord(q),y_coord(q),octant)
- beziers_contour[#beziers_contour+1] = bezier_contour
- bezier_contour = {}
- p=q
- end
- end
- -- not_found label
- if q==cur_spec then
- end_loop_1=true
- else
- p=q; octant=left_octant(p); -- print("% entering octant `");
- end
- -- We don't want all the octans of the cycle
- -- only the pieces of the current octant
- end_loop_1 = not(MFbuiltin.octant() == octant)
- end
- -- done label:
- -- We can now use the results
- -- No curves stored
- if #beziers_contour == 0 then
- beziers_contour['single_point'] = first_point
- end
- beziers_contour['path_list'] = {}
- if #beziers_contour == 0 then
- path_list['p'] = beziers_contour['single_point']
- beziers_contour['path_list'][#beziers_contour['path_list']+1] = path_list
- path_list={}
- else
- for i,v in ipairs(beziers_contour) do
- bezier_contour = v
- path_list['p'] = bezier_contour['p']
- path_list['control1'] = bezier_contour['control1']
- path_list['control2'] = bezier_contour['control2']
- path_list['q'] = bezier_contour['q']
- beziers_contour['path_list'][#beziers_contour['path_list']+1] = path_list
- path_list={}
- end
- end
- bezier_octant_I =mflua.do_add_to.bezier_octant_I
- bezier_octant_I[#bezier_octant_I+1] = beziers_contour
- return 0
-end
-mflua.MF.print_specification_contour = print_specification_contour
-
-
-local function PRE_move_to_edges(p)
- PRINTDBG("PRE_move_to_edges")
- mflua.MF.print_specification_contour(p)
-end
-
-
-local function POST_move_to_edges(p)
- PRINTDBG("POST_move_to_edges")
-end
-
-
---
--- scan_direction
---
-
-mflua.scan_direction = mflua.scan_direction or {}
-
-local function _print_path(h,s,nuline)
- local p,q
- local res
- local done
- local done1
- local f
- done = false
- done1 = false
- p = h
- res = ''
- while not done do
- q = link(p)
- if (p==0) or (q==0) then
- res = "???"
- -- do something with res --
- return 0
- end
- res = res .. print_two(x_coord(p),y_coord(p)); -- print("res=",res)
- if right_type(p) == endpoint then
- if left_type(p)== open then print("{open?}") end -- {can't happen}
- if (left_type(q) ~= endpoint) or (q ~= h) then q=null end -- {force an error}
- done1 = true -- goto done1;
- elseif right_type(p) == explicit then
- -- begin "@<Print control points between |p| and |q|, then |goto done1|@>"
- res = res .. "..controls " .. print_two(right_x(p),right_y(p)) .. " and ";
- if left_type(q) ~= explicit then print("??") -- {can't happen}
- else res = res .. print_two(left_x(q),left_y(q));
- done1 = true -- goto done1;
- end
- -- end "@<Print control points between |p| and |q|, then |goto done1|@>"
- elseif right_type(p) == open then
- -- begin "@<Print information for a curve that begins |open|@>"
- if (left_type(p) ~= explicit) and (left_type(p)~=open) then
- res = res .. "{open?}" -- {can't happen}
- end
- -- end "@<Print information for a curve that begins |open|@>"
- elseif (right_type(p) == curl) or (right_type(p) == given) then
- -- @ A curl of 1 is shown explicitly, so that the user sees clearly that
- -- \MF's default curl is present.
- -- begin @<Print information for a curve that begins |curl|...@>=
- if left_type(p)==open then res = res .. "??" end -- {can't happen}
- if right_type(p)==curl then
- res = res .. "{curl ".. print_scaled(right_curl(p))
- else n_sin_cos(right_given(p)); res = res .."{"
- res = res .. print_scaled(n_cos) .. "," .. print_scaled(n_sin)
- end
- res = res .."}"
- -- end @<Print information for a curve that begins |curl|...@>=
- else res = res .. "???" -- {can't happen}
- end
- if not done1 then -- mimic label done 1
- if left_type(q)~=explicit then res = res .. "..control?" -- {can't happen}
- else if (right_tension(p) ~= unity) or (left_tension(q) ~= unity) then
- -- begin "@<Print tension between |p| and |q|@>;"
- res = res .. "..tension "
- if right_tension(p)<0 then res = res .. "atleast" end
- res = res .. print_scaled(math.abs(right_tension(p)))
- if right_tension(p) ~= left_tension(q) then
- res = res .. " and "
- if left_tension(q)<0 then res = res .. "atleast" end
- res = res .. print_scaled(math.abs(left_tension(q)))
- end
- end -- "@<Print tension between |p| and |q|@>;"
- end
- end --- LABEL: done1
- -- begin @<Print two dots...@>=
- p = q
- res = res .. " .."
- if left_type(p)==given then
- n_sin_cos(left_given(p)); res = res .. "{"
- res = res .. print_scaled(n_cos); res = res .. ",";
- res = res .. print_scaled(n_sin); res = res .. "}";
- else if left_type(p)==curl then
- res = res .. "{curl "; res = res .. print_scaled(left_curl(p)) .. "}";
- end;
- end
- -- end @<Print two dots...@>=
- -- end "@<Print information for adjacent knots |p| and |q|@>"
- if p == h then done =true end
- end
- if left_type(h) ~= endpoint then
- res = res .. "cycle"
- else
- res = res
- end
- -- do something with res --
- return res
- --res = "drawoptions(withcolor black withpen pencircle scaled 1pt);\n" .. "draw " .. res .. " ;\n"
- --print(res)
- -- local index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- -- local char = mflua.chartable[index] or {}
- -- char['char_wd'] = print_scaled(MFbuiltin.char_wd())
- -- char['char_ht'] = print_scaled(MFbuiltin.char_ht())
- -- char['char_dp'] = print_scaled(MFbuiltin.char_dp())
- -- char['char_ic'] = print_scaled(MFbuiltin.char_ic())
- -- char['res'] = char['res'] or ""
- -- char['res'] = char['res'] .. res
- -- mflua.chartable[index] = char
- -- return 0
-end
-mflua.scan_direction.print_path = _print_path
-
-local function PRE_make_choices(p)
- PRINTDBG("PRE_make_choices")
- -- _print_path(p,"PRE make choice",false)
-end
-
-local function POST_make_choices(p)
- PRINTDBG("POST_make_choices")
- --local res = ''
- --res = _print_path(p,"POST make choice",false)
- --print(res)
-end
-
-local function print_retrograde_line(x0,y0,cur_x,cur_y)
- PRINTDBG("print_retrograde_line")
- local chartable = mflua.chartable
- local index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- local char = chartable[index] or {}
- local tab = char['retrograde_line'] or {}
- tab[#tab+1] = {print_two(x0,y0),print_two(cur_x,cur_y)}
- char['retrograde_line'] = tab
- --print("%%Retrograde line")
- --print("drawoptions(withcolor (0,0.6,0) withpen pencircle scaled 0.09pt);")
- --print("draw ".. print_two(x0,y0) .. " -- " .. print_two(cur_x,cur_y) ..";")
-end
-
-
-local function PRE_make_ellipse(major_axis,minor_axis,theta,tx,ty,q)
- PRINTDBG("PRE_make_ellipse")
- --print("major_axis,minor_axis,theta,tx,ty,q=",major_axis,minor_axis,theta,tx,ty,q)
-end
-
-local function POST_make_ellipse(major_axis,minor_axis,theta,tx,ty,q)
- PRINTDBG("POST_make_ellipse")
- --print("major_axis,minor_axis,theta,tx,ty,q=",print_two(major_axis,minor_axis),theta*(2^-20),print_two(tx,ty),print_two(x_coord(q),y_coord(q)))
- local flag=true
- local p=q
- local res = ''
- local xy
- local i = 0
- while flag do
- i=i+1
- res = res ..print_two(x_coord(p),y_coord(p))
- p=link(p)
- if p==q then flag=false end
- end
- mflua.pen[res] = {print_two(major_axis,minor_axis),
- theta*(2^-20),print_two(tx,ty)}
-
-end
-
-
-
-local function print_transition_line_from(x,y)
- PRINTDBG("print_transition_line_from")
- local octant = MFbuiltin.octant()
- --local res = ""
- local index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- local chartable = mflua.chartable
- local char = chartable[index] or {}
- local p = print_two_true(x,y,octant)
- local c1 = p
- char['transition_lines'] = char['transition_lines'] or {}
- char['transition_lines'][#char['transition_lines']+1]={p,p}
- return 0
-end
-
-
-local function print_transition_line_to(x,y)
- PRINTDBG("print_transition_line_to")
- local octant = MFbuiltin.octant()
- local index = (0+print_int(MFbuiltin.char_code())) + (0+print_int(MFbuiltin.char_ext()))*256
- local chartable = mflua.chartable
- local char = chartable[index] or {}
- local q = print_two_true(x,y,octant)
- local c2 = q
- char['transition_lines_set'] = char['transition_lines_set'] or {}
- char['transition_lines'] = char['transition_lines'] or {}
- local _t = char['transition_lines'][#char['transition_lines']]
- local p = _t[1]
- --
- -- avoid multiple lines
- --
- --print("BEZ char['transition_lines_set'][p..q]=",char['transition_lines_set'][p..q])
- if char['transition_lines_set'][p..q]==true or char['transition_lines_set'][q..p]==true then
- char['transition_lines'][#char['transition_lines']]=nil
- return 0
- end
- char['transition_lines_set'][p..q]=true
- char['transition_lines_set'][q..p]=true
- --
- -- remove curves that degenerate into points
- --
- if p~=q then
- _t[#_t+1] = c2
- _t[#_t+1] = q
- _t[#_t+1] = '(0,0)'
- _t[#_t+1] = 'transition_line'
- else
- char['transition_lines'][#char['transition_lines']]=nil
- end
- return 0
-end
-
-
-local function end_program()
- PRINTDBG("end_program")
- local f = kpse.find_file('end_program.lua','lua')
- if f==nil then
- print("Warning: end_program.lua not found")
- return
- end
- local func,errmsg = loadfile(f)
- if not(func) then
- print(errmsg)
- os.exit(1)
- end
- status, msg = pcall(func)
- if not(status) then
- print(msg)
- os.exit(status)
- end
-end
-
-
---
--- Add local function to mflua
---
-
-mflua.begin_program = begin_program
-mflua.PRE_start_of_MF = PRE_start_of_MF
-mflua.PRE_main_control = PRE_main_control
-mflua.POST_main_control = POST_main_control
-mflua.mflua_initialize = mflua_initialize
-mflua.POST_final_cleanup = POST_final_cleanup
-mflua.printpath = printpath
-mflua.printedges = printedges
-mflua.PRE_offset_prep = PRE_offset_prep
-mflua.POST_offset_prep = POST_offset_prep
-
-mflua.PRE_make_spec_rhs = PRE_make_spec_rhs
-mflua.POST_make_spec_rhs = POST_make_spec_rhs
-mflua.PRE_make_spec_lhs = PRE_make_spec_lhs
-mflua.POST_make_spec_lhs = POST_make_spec_lhs
-mflua.PRE_fill_envelope_rhs = PRE_fill_envelope_rhs
-mflua.POST_fill_envelope_rhs = POST_fill_envelope_rhs
-mflua.PRE_fill_envelope_lhs = PRE_fill_envelope_lhs
-mflua.POST_fill_envelope_lhs = POST_fill_envelope_lhs
-mflua.PRE_fill_spec_rhs = PRE_fill_spec_rhs
-mflua.POST_fill_spec_rhs = POST_fill_spec_rhs
-mflua.PRE_fill_spec_lhs = PRE_fill_spec_lhs
-mflua.POST_fill_spec_lhs = POST_fill_spec_lhs
-
-mflua.PRE_move_to_edges = PRE_move_to_edges
-mflua.POST_move_to_edges = POST_move_to_edges
-
-mflua.PRE_make_choices = PRE_make_choices
-mflua.POST_make_choices = POST_make_choices
-
-mflua.print_retrograde_line = print_retrograde_line
-
-mflua.PRE_make_ellipse = PRE_make_ellipse
-mflua.POST_make_ellipse = POST_make_ellipse
-
-mflua.print_transition_line_from = print_transition_line_from
-mflua.print_transition_line_to = print_transition_line_to
-
-mflua.end_program = end_program
-
-
---------------------------------------------------------------------------------
---
--- Other setups, mostly depend on old routines
---
---------------------------------------------------------------------------------
-
-mflua.max_recursion_level = 32
-
-
-mflua.bit = 7 -- should be 4
-
-mflua.pi = 2*math.atan2(1,0)
-mflua.print_specification = mflua.print_specification or {}
-mflua.print_specification.temp1 = 0
-mflua.print_specification.p = ""
-mflua.print_specification.q = ""
-mflua.threshold_path_removed = 4 -- how many path we can safely remove
-mflua.threshold_extra_step = 2 -- add values/mflua.threshold_extra_step time values
-mflua.threshold_small_path_check_point = 3 -- check 3 pixels for horiz/vert. paths
-mflua.threshold_small_pen_path = 0.001 -- _fix_wrong_pending_path
-mflua.threshold_fix = 1 -- _fix_wrong_pending_path
-mflua.threshold = 1 -- _remove_small_path
-mflua.threshold_degree = 2 -- _remove_small_path
-mflua.threshold_degree_1 = 90 -- _remove_small_path
-mflua.threshold_degree_2 = 270 -- _remove_small_path
-mflua.threshold_small_curve = 2 -- _remove_reduntant_curves
-mflua.threshold_normal_curve = 4 -- _remove_reduntant_curves
-mflua.threshold_min_dist = 0.5 -- _remove_reduntant_curves
-mflua.threshold_pending_path = 0.002 -- _remove_reduntant_curves
-mflua.threshold_pen = 5 -- _remove_redundant_segments
-mflua.threshold_bug = 4 -- _fix_intersection_bug
-mflua.threshold_min_bug = 0.03 -- _fix_intersection_bug
-mflua.threshold_equal_path=0.03 -- _remove_duplicate_pen_path
-mflua.threshold_straight_line = 0.125 -- _is_a_straight_line
-mflua.threshold_fix_knots = 0.125 -- _fix_knots
-mflua.threshold_fix_knots_1 = 0.0005 -- _fix_knots
-mflua.threshold_fix_knots_2 = 0.4 -- _fix_knots
-mflua.threshold_remove_redundant_pen = 0.02 -- remove_redundant_pen
-mflua.threshold_remove_redundant_curves = 3 -- _remove_redundant_curves
-mflua.threshold_merge_segments = 5e-5 -- _merge_segments
-mflua.threshold_join_curves = 0.049 -- _build_cycles try and error
-mflua.set_poly_done={}
-mflua.mflua_exe = 'mflua'
-mflua.turningnumber_file='mflua_tn'
-mflua.fill_envelope = {}
-mflua.fill_envelope.temp_transition = ""
-mflua.pen = {} -- collect bezier curves of the pens
-
---
-
-mflua.chartable ={}
-mflua.max_curves =1e4
-
-
-function mflua.lock(params)
- if params ==nil then
- return io.open('LOCK1','w')
- else
- return io.open(tostring(params),'w')
- end
-end
-
-function mflua.unlock(params)
- if params == nil then
- return os.remove('LOCK1')
- else
- return os.remove(tostring(params))
- end
-end
-
-function mflua.checklock(params)
- if params == nil then
- if io.open("LOCK1") ~= nil then return true else return false end
- else
- if io.open(tostring(params)) ~= nil then return true else return false end
- end
-end
-
-
-function mflua.dot(P1,P2)
- return P1[1]*P2[1]+P1[2]*P2[2]
-end
-
-function mflua.angle(p,q)
- local dot = mflua.dot
- if math.abs(1 - dot(p,q)/(math.sqrt(dot(p,p))*math.sqrt(dot(q,q)))) <0.0001 then
- return 0
- else
- return math.acos(dot(p,q)/(math.sqrt(dot(p,p))*math.sqrt(dot(q,q))))
- end
-end
-
--- function mflua.vec(a,w,b1) if b1 == nil then b=w else b = b1 end ; return {b[1]-a[1],b[2]-a[2]} end
--- mflua.vec(a,b) == mflua.vec(a,'->',b)
-function mflua.round(p)
- local w=string.gmatch(p,"[-0-9.]+");
- local p p={w(),w()};
- return string.format("(%6.5f,%6.5f)",tostring(p[1]),tostring(p[2]) )
-end
-
-function mflua.round5(p)
- local w=string.gmatch(p,"[-0-9.]+");
- local p; p={w(),w()};
- return string.format("(%6.5f,%6.5f)",tostring(p[1]),tostring(p[2]) )
-end
-
-function mflua.round2(p)
- local w=string.gmatch(p,"[-0-9.]+");
- local p; p={w(),w()};
- return string.format("(%6.2f,%6.2f)",tostring(p[1]),tostring(p[2]) )
-end
-
-function mflua.round1(p)
- local w=string.gmatch(p,"[-0-9.]+");
- local p; p={w(),w()};
- return string.format("(%6.1f,%6.1f)",tostring(p[1]),tostring(p[2]) )
-end
-
-function mflua.round0(p)
- local w=string.gmatch(p,"[-0-9.]+");
- local p; p={w(),w()};
- return string.format("(%6.0f,%6.0f)",tostring(p[1]),tostring(p[2]) )
-end
-
-function mflua.floor(p)
- local w=string.gmatch(p,"[-0-9.]+");
- local p; p={w(),w()};
- return string.format("(%d,%d)",math.floor(p[1]),math.floor(p[2]) )
-end
-
-function mflua.round5_table(p)
- return {tonumber(string.format("%6.5f",tostring(p[1]))),tonumber(string.format("%6.5f",tostring(p[2])))}
-end
-
-function mflua.number_to_string_round5(p)
- return string.format("(%6.5f,%6.5f)",p[1],p[2])
-end
-
-
-function mflua.vec(a,b)
- return {b[1]-a[1],b[2]-a[2]}
-end
-
-function mflua.modul_vec(a,b)
- local dot = mflua.dot
- local P ={b[1]-a[1],b[2]-a[2]}
- return math.sqrt(dot(P,P))
-end
-
-function mflua.approx_curve_lenght(p,c1,c2,q)
- return mflua.modul_vec(p,c1) + mflua.modul_vec(c1,c2) + mflua.modul_vec(c2,q) + mflua.modul_vec(p,q)
-end
-
-
--- for multiple instances of mflua one can define a LOCK like this
--- if io.open('LOCK1')==nil and io.open('LOCK_ELLIPSE')==nil then
--- mflua.print_specification.filename = "envelope.tex"
--- mflua.print_specification.outfile1 = io.open(mflua.print_specification.filename,'w')
--- end
-
-
-
---------------------------------------------------------------------------------
---
--- tfm module
---
---------------------------------------------------------------------------------
-local tfm = {}
-tfm.bits =
- function(a,l)
- local bita = {}
- local a = a
- for k=1,l do
- local r=math.fmod(a,2)
- a=math.floor(a/2)
- bita[k]=r
- end
- return bita
- end
-tfm.bitand =
- function(a,b,l)
- local bita,bitb,bitc = tfm.bits(a,l), tfm.bits(b,l),{}
- local c= 0
- for k=1,l do
- bit1,bit2 = bita[k],bitb[k]
- if (bit1==1) and (bit2==1) then
- bitc[k]=1
- else
- bitc[k]=0
- end
- c = c+2^(k-1)*bitc[k]
- end
- return c,bitc
- end
-tfm.bitor =
- function(a,b,l)
- local bita,bitb,bitc = tfm.bits(a,l), tfm.bits(b,l),{}
- local c= 0
- for k=1,l do
- bit1,bit2 = bita[k],bitb[k]
- if (bit1==1) or (bit2==1) then
- bitc[k]=1
- else
- bitc[k]=0
- end
- c = c+ 2^(k-1)*bitc[k]
- end
- return c,bitc
- end
-tfm.bitnot =
- function(a,l)
- local bita,bitb = tfm.bits(a,l),{}
- local b= 0
- for k=1,l do
- bit1 = bita[k]
- if (bit1==1) then
- bitb[k]=0
- else
- bitb[k]=1
- end
- b = b+ 2^(k-1)*bitb[k]
- end
- return b,bitb
- end
-tfm.printbits=
- function(t,l)
- local r = ''
- local l = l or #t
- if l==0 then return '' end
- for k=l,1,-1 do
- local v = t[k] or '0'
- r=r..v
- end
- return r
- end
-
-tfm.stop_flag = 128
-tfm.kern_flag = 128
-
-tfm.parameters = {}
-tfm.parameters.init =
- function()
- -- 8. The first 24 bytes (6 words) of a TFM file contain twelve 16-bit integers that give the lengths of the
- -- various subsequent portions of the file. These twelve integers are, in order:
- -- lf = length of the entire file, in words;
- -- lh = length of the header data, in words;
- -- bc = smallest character code in the font;
- -- ec = largest character code in the font;
- -- nw = number of words in the width table;
- -- nh = number of words in the height table;
- -- nd = number of words in the depth table;
- -- ni = number of words in the italic correction table;
- -- nl = number of words in the lig/kern table;
- -- nk = number of words in the kern table;
- -- ne = number of words in the extensible character table;
- -- np = number of font parameter words.
- -- They are all nonnegative and less than 2^15 . We must have bc - 1<= ec <= 255, ne<= 256, and
- -- lf = 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np .
- -- When two or more 8-bit bytes are combined to form an integer of 16 or more bits, the most
- -- significant bytes appear first in the file. This is called BigEndian order.
-
- if tfm.content ==nil or type(tfm.content)~= 'string' then
- return false, 'Error on file content'
- end
- tfm.parameters.w = string.gmatch(tfm.content,"[%z%Z]")
- local w = tfm.parameters.w
- local W1,W2
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (lf)' end
- tfm.parameters.lf = 256*string.byte(W1)+string.byte(W2) -- length of the entire file, in words;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (lh)' end
- tfm.parameters.lh = 256*string.byte(W1)+string.byte(W2) -- length of the header data, in words;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (bc)' end
- tfm.parameters.bc = 256*string.byte(W1)+string.byte(W2) -- smallest character code in the font;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (ec)' end
- tfm.parameters.ec = 256*string.byte(W1)+string.byte(W2) -- largest character code in the font;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (nw)' end
- tfm.parameters.nw = 256*string.byte(W1)+string.byte(W2) -- number of words in the width table;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (nh)' end
- tfm.parameters.nh = 256*string.byte(W1)+string.byte(W2) -- number of words in the height table;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (nd)' end
- tfm.parameters.nd = 256*string.byte(W1)+string.byte(W2) -- number of words in the depth table;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (ni)' end
- tfm.parameters.ni = 256*string.byte(W1)+string.byte(W2) -- number of words in the italic correction table;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (nl)' end
- tfm.parameters.nl = 256*string.byte(W1)+string.byte(W2) -- number of words in the lig/kern table;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (nk)' end
- tfm.parameters.nk = 256*string.byte(W1)+string.byte(W2) -- number of words in the kern table;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (ne)' end
- tfm.parameters.ne = 256*string.byte(W1)+string.byte(W2) -- number of words in the extensible character table;
-
- W1,W2=w(),w();if W1==nil or W2==nil then return false, 'Error on parsing content (np)' end
- tfm.parameters.np = 256*string.byte(W1)+string.byte(W2) -- number of font parameter words.
- return
- end
-
-tfm.parameters.check =
- function()
- local w = tfm.parameters.w
- local lf = tfm.parameters.lf
- local lh = tfm.parameters.lh
- local bc = tfm.parameters.bc
- local ec = tfm.parameters.ec
- local nw = tfm.parameters.nw
- local nh = tfm.parameters.nh
- local nd = tfm.parameters.nd
- local ni = tfm.parameters.ni
- local nl = tfm.parameters.nl
- local nk = tfm.parameters.nk
- local ne = tfm.parameters.ne
- local np = tfm.parameters.np
- local status = true
- local status_cnt = 0
- local status_msg = 'OK'
- local function _assert(cond,msg)
- if cond==false then
- --print(msg)
- status_msg = msg
- status_cnt = status_cnt +1
- end
- end
- if status_cnt == 0 then _assert(lf == 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np ,"Error on lf") end
- if status_cnt == 0 then _assert(0<=lf and lf <2^15,"lf out of range") end
- if status_cnt == 0 then _assert(0<=lh and lh <2^15,"lh out of range") end
- if status_cnt == 0 then _assert(0<=bc and bc <2^15,"bc out of range") end
- if status_cnt == 0 then _assert(0<=ec and ec <2^15,"ec out of range") end
- if status_cnt == 0 then _assert(0<=nw and nw <2^15,"nw out of range") end
- if status_cnt == 0 then _assert(0<=nh and nh <2^15,"nh out of range") end
- if status_cnt == 0 then _assert(0<=nd and nd <2^15,"nd out of range") end
- if status_cnt == 0 then _assert(0<=ni and ni <2^15,"ni out of range") end
- if status_cnt == 0 then _assert(0<=nl and nl <2^15,"nl out of range") end
- if status_cnt == 0 then _assert(0<=nk and nk <2^15,"nk out of range") end
- if status_cnt == 0 then _assert(0<=ne and ne <2^15,"ne out of range") end
- if status_cnt == 0 then _assert(0<=np and np <2^15,"np out of range") end
- if status_cnt == 0 then _assert( (bc-1)<=ec and ec<= 255, "Error on bc and ec") end
- if status_cnt == 0 then _assert(ne<= 256, "ne >256") end
- if status_cnt > 0 then status=false end
- return status,status_msg
- end
-
-
-tfm.int_to_frac =
- function(d)
- if not (0<=d and d<2^32) then
- return nil, string.format("Error: %s out of range (-%s,%s-2^-20)",d,2^31,2^31)
- else
- if d<=2147483647 then
- return d/2^20,'ok'
- else
- return (d-2^32)/2^20,'ok'
- end
- end
-
- end
-tfm.tag_meaning =
- function(d)
- local t = {'vanilla character','character has a ligature/kerning program',
- 'character has a successor in a charlist','character is extensible'}
- local d = tonumber(d) or -1
- if d<0 or d>3 then return '' end
- return t[tonumber(d+1)]
- end
-
-tfm.getface =
- function(d)
- --If the value is less than 18, it has the following
- --interpretation as a "weight, slope, and expansion": Add 0 or 2 or 4 (for medium or bold or light) to
- --0 or 1 (for roman or italic) to 0 or 6 or 12 (for regular or condensed or extended). For example, 13 is
- --0+1+12, so it represents medium italic extended. A three-letter code (e.g., MIE) can be used for such
- --face data.
- -- d = 3⋅rce_bit⋅2^{2,1} + ri_bit + mbl_bit⋅2^{2,1} , rce_bit,ri_bit,mbl_bit ∈ {0,1}
- -- d%2 = ri_bit := ri
- -- d%3 - d%2 = mbl⋅2^{2,1} := mbl
- -- d - d%3 = 3⋅rce⋅2^{2,1} := rce
- if d>17 then return '' end
- local mbl,ri, rce = '*','*','*'
- local _ri = d % 2
- if _ri==0 then ri ='R' else ri ='I' end
- local _mbl = (d%3) -(d%2)
- if _mbl == 0 then mbl='M' end
- if _mbl == 2 then mbl='B' end
- if _mbl == 4 then mbl='E' end
- local _rce = d - (d%3)
- if _rce == 0 then rce = 'M' end
- if _rce == 1 then rce = 'I' end
- if _rce == 12 then rce = 'E' end
- return mbl..ri..rce, {_mbl,_ri,_rce}
- end
-
-tfm.printfloat =
- function(d,p)
- if d then
- local d,p = d, tonumber(p) or 6
- local f = string.format("%%.%df",p)
- return string.format(f,d)
- else
- return tostring(d)
- end
- end
-
-tfm.array = {}
-tfm.array.check =
- function()
- local width = tfm.array.width
- local height = tfm.array.height
- local depth = tfm.array.depth
- local italic = tfm.array.italic
- local status = true
- local status_cnt = 0
- local status_msg = 'OK'
- local function _assert(cond,msg)
- if cond==false then
- --print(msg)
- status_msg = msg
- status_cnt = status_cnt +1
- end
- end
- _assert(width[0]==0,'Error in width[0]')
- _assert(height[0]==0,'Error in height[0]')
- _assert(depth[0]==0,'Error in depth[0]')
- _assert(italic[0]==0,'Error in italic[0]')
- if status_cnt > 0 then status=false end
- return status,status_msg
-
- end
-
-tfm.dump={}
-tfm.dump.kernprogram =
- function(d,c)
- local char_info = tfm.array.char_info
- local lig_kern = tfm.array.lig_kern
- local kern = tfm.array.kern
- local current_step = d
- local current_char = c
- local skip_byte=lig_kern[current_step][1]
- local next_char=lig_kern[current_step][2]
- local op_byte=lig_kern[current_step][3]
- local remainder=lig_kern[current_step][4]
- local _print = tfm.printdebug()
- _print("-------")
- _print("skip_byte=",skip_byte)
- _print("next_char=",next_char,'C '..string.char(next_char),'O '..string.format("%o",next_char))
- _print("op_byte=",op_byte)
- _print("remainder=",remainder,string.format("O %o",remainder))
- if op_byte <tfm.kern_flag then -- a ligature step
- -- op_byte= 4a+2b+c where 0<=a<=b+c and 0<=b,c<=1.
- local a,b,c
- c= op_byte%2
- b = ((op_byte-c)%4)/2
- a = (op_byte-2*b-c)/4
- _print("ligature step: a,b,c=",a,b,c)
- if b==0 then
- _print("current char: deleted")
- else
- _print("current char: not deleted" )
- end
- if c==0 then
- _print("next char: deleted")
- else
- _print("next char: not deleted ")
- end
- if a==0 then
- _print("no next char")
- else
- -- we must pass over the next a characters
- -- local _,_remainder,_,_,_tag,_ = char_info[current_char+a]
- -- if _tag==1 then
- -- local kern_program = tfm.dump.kernprogram(_remainder,current_char+a)
- -- end
- end
- tfm.chars[current_char] = tfm.chars[current_char] or {}
- tfm.chars[current_char].ligature = tfm.chars[current_char].ligature or {}
- tfm.chars[current_char].ligature[#tfm.chars[current_char].ligature+1]=
- {['next_char']=next_char,['a']=a,['b']=b,['c']=c}
-
- else -- a kern step
- local additional_space = kern[256*(op_byte-128)+remainder]
- _print("kern step:additional_space=",tfm.printfloat(additional_space))
- tfm.chars[current_char] = tfm.chars[current_char] or {}
- tfm.chars[current_char].kern = tfm.chars[current_char].kern or {}
- tfm.chars[current_char].kern[#tfm.chars[current_char].kern+1] =
- {['next_char']=next_char,['additional_space']=additional_space}
- end
-
- if skip_byte>=tfm.stop_flag then
- -- end
- return
- else
- -- take next instruction
- tfm.dump.kernprogram(current_step+1+skip_byte,current_char)
- end
- end
-
-
-tfm.build = {}
-tfm.build.header =
- function(i,j,w)
- local _i,_j,_a = i,j,{}
- for i=_i,_j do
- if i<=1 or i>17 then
- _a[i] =2^24*string.byte(w())+2^16*string.byte(w())+2^8*string.byte(w())+string.byte(w())
- elseif 2<=i and i<=16 then
- _a[i] =w()..w()..w()..w()
- elseif i==17 then
- _a[i] ={string.byte(w()),string.byte(w()),string.byte(w()),string.byte(w())}
- end
- end
- return _a
- end
-
-tfm.build._bytearray =
- function(i,j,w)
- local _i,_j,_a = i,j,{}
- for i=_i,_j do
- _a[i] ={string.byte(w()),string.byte(w()),string.byte(w()),string.byte(w())}
- end
- return _a
- end
-tfm.build.char_info = tfm.build._bytearray
-tfm.build.lig_kern = tfm.build._bytearray
-tfm.build.exten = tfm.build._bytearray
-
-tfm.build._dimension =
- function(i,j,w)
- local _i,_j,_a = i,j,{}
- for i=_i,_j do
- _a[i] = tfm.int_to_frac(2^24*string.byte(w())+2^16*string.byte(w())+2^8*string.byte(w())+string.byte(w()))
- end
- return _a
- end
-tfm.build.width = tfm.build._dimension
-tfm.build.height = tfm.build._dimension
-tfm.build.depth = tfm.build._dimension
-tfm.build.italic = tfm.build._dimension
-tfm.build.kern = tfm.build._dimension
-tfm.build.param = tfm.build._dimension
-
-tfm.build.all =
- function()
- local w = tfm.parameters.w
- local lf = tfm.parameters.lf
- local lh = tfm.parameters.lh
- local bc = tfm.parameters.bc
- local ec = tfm.parameters.ec
- local nw = tfm.parameters.nw
- local nh = tfm.parameters.nh
- local nd = tfm.parameters.nd
- local ni = tfm.parameters.ni
- local nl = tfm.parameters.nl
- local nk = tfm.parameters.nk
- local ne = tfm.parameters.ne
- local np = tfm.parameters.np
- tfm.array.header = tfm.build.header(0,lh-1,w)
- tfm.array.char_info = tfm.build.char_info(bc,ec,w)
- tfm.array.width = tfm.build.width( 0,nw-1,w)
- tfm.array.height = tfm.build.height(0,nh-1,w)
- tfm.array.depth = tfm.build.depth( 0,nd-1,w)
- tfm.array.italic = tfm.build.italic(0,ni-1,w)
- tfm.array.lig_kern = tfm.build.lig_kern(0,nl-1,w)
- tfm.array.kern = tfm.build.kern(0,nk-1,w)
- tfm.array.exten = tfm.build.exten(0,ne-1,w)
- tfm.array.param = tfm.build.param(1,np,w)
- end
-
-tfm.debug = 0
-tfm.printdebug =
- function()
- if tfm.debug==1 then
- return print
- else
- return function(...) end
- end
- end
-
-tfm.getdata={}
-tfm.getdata.char_info =
- function(i)
- local char_info = tfm.array.char_info
- local width_index = char_info[i][1]
- local height_index_plus_depth_index = char_info[i][2]
- local italic_index_plus_tag = char_info[i][3]
- local remainder = char_info[i][4]
- local depth_index = height_index_plus_depth_index % 16
- local height_index= (height_index_plus_depth_index -depth_index)/16
- local tag = italic_index_plus_tag % 4
- local italic_index = (italic_index_plus_tag -tag)/4
- return width_index,remainder,depth_index,height_index,tag,italic_index
- end
-tfm.chars = {}
-tfm.font = {}
-
-tfm.run=
- function(name)
- local name = name
- local _print = tfm.printdebug()
- local header ={}
- local char_info ={}
- local width ={}
- local height ={}
- local depth ={}
- local italic ={}
- local lig_kern ={}
- local kern ={}
- local exten ={}
- local param ={}
- local w
- local lf
- local lh
- local bc
- local ec
- local nw
- local nh
- local nd
- local ni
- local nl
- local nk
- local ne
- local np
-
- if kpse.find_file(name)==nil then
- name = name .. ".tfm"
- end
- if kpse.find_file(name)==nil then
- return false, "Error: file "..tostring(name).." not found"
- end
- tfm.name = name
- tfm.file = io.open(tfm.name,'rb')
- if tfm.file == nil then
- return false, "Error on opening file "..tostring(tfm.name)
- end
- tfm.content = tfm.file:read("*a")
- status,status_msg = tfm.parameters.init()
- if status== false then
- _print("ERROR="..tostring(status_msg))
- return false, tostring(status_msg)
- end
-
- status,status_msg = tfm.parameters.check()
- if status == false then
- _print("ERROR="..tostring(status_msg))
- return false, tostring(status_msg)
- end
- -- Build all arrays
- tfm.build.all()
- header = tfm.array.header
- char_info = tfm.array.char_info
- width = tfm.array.width
- height = tfm.array.height
- depth = tfm.array.depth
- italic = tfm.array.italic
- lig_kern = tfm.array.lig_kern
- kern = tfm.array.kern
- exten = tfm.array.exten
- param = tfm.array.param
-
- w = tfm.parameters.w
- lf = tfm.parameters.lf
- lh = tfm.parameters.lh
- bc = tfm.parameters.bc
- ec = tfm.parameters.ec
- nw = tfm.parameters.nw
- nh = tfm.parameters.nh
- nd = tfm.parameters.nd
- ni = tfm.parameters.ni
- nl = tfm.parameters.nl
- nk = tfm.parameters.nk
- ne = tfm.parameters.ne
- np = tfm.parameters.np
-
- status,status_msg = tfm.array.check()
- if status == false then
- _print("ERROR="..tostring(status_msg))
- return false, tostring(status_msg)
- end
- tfm.font.checksum =header[0]
- tfm.font.designsize = tfm.int_to_frac(header[1])
- local coding_scheme
- if header[2]~= nil then
- coding_scheme = ''
- for j=2,11 do coding_scheme=coding_scheme..tostring(header[j]) end
- tfm.font.coding_scheme=coding_scheme
- _print(string.format("CODING SCHEME:%s",tfm.font.coding_scheme))
- end
- local font_identifier
- if header[12]~= nil then
- font_identifier = ''
- for j=12,16 do font_identifier=font_identifier..tostring(header[j]) end
- tfm.font.font_identifier=font_identifier
- _print(string.format("FONT IDENTIFIER:%s",tfm.font.font_identifier))
- end
- local seven_bit_safe_flag ,face
- if header[17]~= nil then
- seven_bit_safe_flag ,face = header[17][1],header[17][4]
- tfm.font.seven_bit_safe_flag = seven_bit_safe_flag
- tfm.font.face = face
- _print(string.format("SEVEN_BIT_SAFE_FLAG=%x",seven_bit_safe_flag))
- local f,t = tfm.getface(face)
- face = f
- _print(string.format("FACE=%s (mbl=%d,ri=%d,rce=%d)",face,t[1],t[2],t[3]))
- end
- local _pf = tfm.printfloat
- for current_char=bc,ec do
- --for current_char=102,102 do
- local width_index,remainder,depth_index,height_index,tag,italic_index = tfm.getdata.char_info(current_char)
- tfm.chars[current_char] = tfm.chars[current_char] or {}
- tfm.chars[current_char].width = width[width_index]
- tfm.chars[current_char].height = height[height_index]
- tfm.chars[current_char].depth = depth[depth_index]
- tfm.chars[current_char].italic = italic[italic_index]
- tfm.chars[current_char].tag = tag
- _print(string.format("O %o",current_char),string.char(current_char),
- 'WIDTH='.._pf(width[width_index]),
- 'HEIGHT='.._pf(height[height_index]),
- 'DEPTH='.._pf(depth[depth_index]),
- 'ITALIC='.._pf(italic[italic_index]),
- 'TAG='..tfm.tag_meaning(tag)
- )
- if tag==1 then -- character has a ligature/kerning program
- local kern_program = tfm.dump.kernprogram(remainder,current_char)
- end
- end
-
- tfm.font.slant = param[1]
- _print("SLANT=".._pf(tfm.font.slant))
-
- tfm.font.space = param[2]
- _print("SPACE=".._pf(tfm.font.space))
-
- tfm.font.space_stretch = param[3]
- _print("SPACE_STRETCH=".._pf(tfm.font.space_stretch))
-
- tfm.font.space_shrink = param[4]
- _print("SPACE_SHRINK=".._pf(tfm.font.space_shrink))
-
- tfm.font.x_height = param[5]
- _print("X_HEIGHT=".._pf(tfm.font.x_height))
-
- tfm.font.quad = param[6]
- _print("QUAD=".._pf(tfm.font.quad))
-
- tfm.font.extra_space = param[7]
- _print("EXTRA_SPACE=".._pf(tfm.font.extra_space))
-
- return true,'ok'
-
- end
---------------------------------------------------------------------------------
-
--- Add tfm to the mflua table
-mflua.tfm = tfm
-
-
-
---------------------------------------------------------------------------------
---
--- gf module
---
---------------------------------------------------------------------------------
---
--- In-memory parser, i.e. reads all the gf into memory
--- and then parses the byte stream
---
-
-local GF = {}
-do
-
- local sub = string.sub
- local len = string.len
- local byte = string.byte
- local format = string.format
- local rep = string.rep
-
- local gfdata=''
- local gfdata_index
- local gfdata_len
-
- local chars={}
- local current_char
- local current_row -- aka n
- local current_col -- aka m
- local white=0
- local black=white+1
- local paint_switch
- chars.xxx1 = {}
- chars.xxx2 = {}
- chars.xxx3 = {}
- chars.xxx4 = {}
- chars.yyy = {}
- chars.nop = {}
- chars.all_nop = {} -- collect a xxx1 or xxx2 or xxx3 or xxx4 or yyy or nop
- chars.locators = {}
-
-
-
-
- local defDEBUG = false
- local function DEBUG(k,s)
- print("DEBUG:"..tostring(k).."="..tostring(s))
- end
-
-
- local function error_msg(msg)
- io.write(format("! mflua GF: char %s: %s",current_char, msg))
- io.write(format(" position=%s ",gfdata_index))
- print()
- end
- GF.error = error_msg
-
- local function warning_msg(msg)
- print(format("\n! mflua GF: char %s: %s.",current_char, msg))
- end
- GF.warning = warning_msg
-
-
-
- --
- -- read n bytes starting from from gfdata_index included
- -- and move gfdata_index
- --
- local function readbytes(n)
- if (gfdata_index+n-1)<1 then
- GF.warning("attempt to read before the beginning of the file")
- return nil
- end
- if (gfdata_index+n-1)>gfdata_len then
- GF.warning("attempt to read beyond the end of the file")
- return nil
- end
- local s
- if (n<0) then
- s = sub(gfdata,gfdata_index+n+1,gfdata_index)
- elseif n>0 then
- s = sub(gfdata,gfdata_index,gfdata_index+n-1)
- else
- s =''
- end
- gfdata_index = gfdata_index+n
- return s
- end
-
-
- local function read4bytes()
- local b0 = byte(readbytes(1))
- local b1 = byte(readbytes(1))
- local b2 = byte(readbytes(1))
- local b3 = byte(readbytes(1))
- local v = (b3+b2*256+b1*65536+b0*16777216)
- if v >2147483647 then
- v = v -4294967296
- end
- return v
- end
-
-
- local function readrev4bytes()
- local b3 = byte(readbytes(-1))
- local b2 = byte(readbytes(-1))
- local b1 = byte(readbytes(-1))
- local b0 = byte(readbytes(-1))
- local v = (b3+b2*256+b1*65536+b0*16777216)
- if v >2147483647 then
- v = v -4294967296
- end
- return v
- end
-
-
- local function readuntileof()
- if gfdata_index>gfdata_len then
- GF.warning("wrong index: gfdata_index="..tostring(gfdata_index).."> gfdata_len="..tostring(gfdata_len) )
- return nil
- end
- local s = sub(gfdata,gfdata_index,gfdata_len)
- gfdata_index = gfdata_len +1
- return s
- end
-
-
- local function datanotfinished()
- return (gfdata_index <= gfdata_len)
- end
-
-
- local function moveindex_after(p)
- gfdata_index = p+1
- end
-
-
-
- error = {}
- error.ok = 0
- error.base = error.ok
- error.pre = error.base +1
- error.parse = error.base +2
- error.post = error.base +3
- error.boc = error.base +4
- error.load = error.base +127
- error.parse = error.base +128
- error.parsechar = error.base +129
- error.paint = {}
- for j=0,63 do
- error.paint[j] = error.base +130+j
- end
- error.paint_switch=error.base +130+64
- error.paint1 = error.base +130+64+1
- error.paint2 = error.base +130+64+2
- error.paint3 = error.base +130+64+3
- error.eoc = error.base +130+64+6
- error.skip0 = error.base +130+64+7
- error.skip1 = error.base +130+64+8
- error.skip2 = error.base +130+64+9
- error.skip3 = error.base +130+64+10
- error.new_row = {}
- for j=0,164 do
- error.new_row[j]= error.base +130+64+10+1+j
- end
-
- error.post_post=error.base +130+64+10+1+165
-
- error.skip223=error.base +130+64+10+1+166
-
-
- error_name_t = {}
- for k,v in pairs(error) do
- error_name_t[v] = k
- end
- local function error_name(res)
- if res==nil then
- return "unknown error code"
- elseif error_name_t[res] == nil then
- return "unknown error code"
- else
- return error_name_t[res]
- end
- end
-
- local opcodes = {}
-
- -- {beginning of the \\{paint} commands}
- for j=0,63 do
- local s = format("paint_%d",j)
- opcodes[s] = j
- end
- opcodes.paint1=64 -- {move right a given number of columns, then black${}\swap{}$white}
- opcodes.paint2=65
- opcodes.paint3=66
- opcodes.boc=67 -- {beginning of a character}
- opcodes.boc1=68 -- {short form of |boc|}
- opcodes.eoc=69 -- {end of a character}
- opcodes.skip0=70 -- {skip no blank rows}
- opcodes.skip1=71 -- {skip over blank rows}
- opcodes.skip2=72
- opcodes.skip3=73
- --opcodes.new_row_0=74 -- {move down one row and then right}
- --:
- --opcodes.new_row_164=238
- for j=0,164 do
- local s = format("new_row_%d",j)
- opcodes[s] = j+74
- end
-
- --opcodes.max_new_row=164 -- {the largest \\{new\_row} command is |new_row_164|}
- opcodes.xxx1=239 -- {for \&{special} strings}
- opcodes.xxx2=240
- opcodes.xxx3=241 -- {for long \&{special} strings}
- opcodes.xxx4=242
- opcodes.yyy=243 -- {for \&{numspecial} numbers}
- opcodes.nop=244 -- no operation
- opcodes.char_loc=245 -- {character locators in the postamble}
- opcodes.char_loc0=246
- opcodes.pre=247 -- {preamble}
- opcodes.post=248 -- {postamble beginning}
- opcodes.post_post=249 -- {postamble ending}
-
- opcodes.undefined_1=250
- opcodes.undefined_2=251
- opcodes.undefined_3=252
- opcodes.undefined_4=253
- opcodes.undefined_5=254
- opcodes.undefined_6=255
-
- local revopcode = {}
- for k,v in pairs(opcodes) do revopcode[v] = k end
-
-
-
- complement_paint_switch = function()
- local res = error.ok
- if( paint_switch==black or paint_switch==white) then
- paint_switch=(paint_switch+1)%2
- else
- GF.error("wrong value for paint_switch")
- res = error.paint_switch
- end
- return res
- end
-
- local paint = function(n)
- local res = error.ok
- local c = chars[current_char]
- local row = c[current_row]
- if row==nil then
- GF.error("error in paint_"..tostring(n)..", row is nil")
- end
- if paint_switch==black then
- for i=current_col,current_col+n-1 do
- row[i]=true
- end
- end
- res = complement_paint_switch()
- current_col = current_col + n
- if res~=error.ok then
- if n<64 then
- GF.error("error in paint_"..tostring(n))
- res = error.paint[n]
- elseif (64<=n and n<256) then
- GF.error("error in paint1")
- res = error.paint1
- elseif (256<=n and n<65536) then
- GF.error("error in paint2")
- res = error.paint2
- elseif (65536<=n and n<16777216) then
- GF.error("error in paint3")
- res = error.paint3
- end
- end
- return res
- end
-
-
- opcodes.func = {}
-
-
- opcodes.func[opcodes.paint_0]= function()
- local res = error.ok
- res = complement_paint_switch()
- if res~=error.ok then
- GF.error("error in paint_0")
- res = error.paint[0]
- end
- return res
- end
-
- --opcodes.func[opcodes.paint_1]= function() return paint(1) end
- --:
- --opcodes.func[opcodes.paint_63]= function() return paint(63) end
- for i=1, 63 do
- local key = format("paint_%d",i)
- local index = opcodes[key]
- opcodes.func[index] = function() return paint(i) end
- end
-
- opcodes.func[opcodes.paint1]= function()
- local res = error.ok
- local b = byte(readbytes(1))
- if (64<=b and b<256) then
- paint(b)
- else
- GF.error("wrong value " ..tostring(b) .. " in paint1")
- res = error.paint1
- end
- return res
- end
-
-
- opcodes.func[opcodes.paint2]= function()
- local res = error.ok
- local b1 = byte(readbytes(1))
- local b2 = byte(readbytes(1))
- local b = b2+b1*256
- if (256<=b and b<65536) then
- paint(b)
- else
- GF.error("wrong value " ..tostring(b) .. " in paint2")
- res = error.paint2
- end
- return res
- end
-
-
-
- opcodes.func[opcodes.paint3]= function()
- local res = error.ok
- local b1 = byte(readbytes(1))
- local b2 = byte(readbytes(1))
- local b3 = byte(readbytes(1))
- local b = b3+b2*256+ (b1*65536)
- if (65536<=b and b<16777216) then
- paint(b)
- else
- GF.error("wrong value " ..tostring(b) .. " in paint3")
- res = error.paint3
- end
- return res
- end
-
-
- opcodes.func[opcodes.boc]= function()
- local pos = gfdata_index
- local c = read4bytes()
- local p = read4bytes()
- local min_m = read4bytes()
- local max_m = read4bytes()
- local min_n = read4bytes()
- local max_n = read4bytes()
- current_char = c
- chars[current_char] = chars[current_char] or {}
- chars[current_char]['p'] = p
- chars[current_char]['max_m'] = max_m
- chars[current_char]['min_m'] = min_m
- chars[current_char]['max_n'] = max_n
- chars[current_char]['min_n'] = min_n
- chars[current_char]['opened'] = true
- chars[current_char]['stream_pos'] = gfdata_index
- chars[current_char]['max_col'] = max_m
- chars[current_char]['min_col'] = min_m
- chars[current_char]['max_row'] = max_n
- chars[current_char]['min_row'] = min_n
- current_col = min_m
- current_row = max_n
- chars[current_char][current_row]={}
- paint_switch = white
- return error.ok
- end
-
-
- opcodes.func[opcodes.boc1]= function()
- local pos = gfdata_index
- local c = byte(readbytes(1))
- local del_m = byte(readbytes(1))
- local max_m = byte(readbytes(1))
- local del_n = byte(readbytes(1))
- local max_n = byte(readbytes(1))
- local p = -1
- local min_m = max_m - del_m
- local min_n = max_n - del_n
- current_char = c
- chars[current_char] = chars[current_char] or {}
- chars[current_char]['p'] = p
- chars[current_char]['max_m'] = max_m
- chars[current_char]['min_m'] = min_m
- chars[current_char]['max_n'] = max_n
- chars[current_char]['min_n'] = min_n
- chars[current_char]['opened'] = true
- chars[current_char]['stream_pos'] = gfdata_index
- chars[current_char]['max_col'] = max_m
- chars[current_char]['min_col'] = min_m
- chars[current_char]['max_row'] = max_n
- chars[current_char]['min_row'] = min_n
- current_col = min_m
- current_row = max_n
- chars[current_char][current_row]={}
- paint_switch = white
- return error.ok
- end
-
-
- opcodes.func[opcodes.eoc]= function()
- local res = error.ok
- if chars[current_char].opened == true then
- chars[current_char].opened = false
- res = error.ok
- else
- GF.error("error closing char")
- res = error.eoc
- end
- --
- -- use them as stack to tie the nop
- -- opcodes to current_char
- table.insert(chars.xxx1,{current_char,-1})
- table.insert(chars.xxx2,{current_char,-1})
- table.insert(chars.xxx3,{current_char,-1})
- table.insert(chars.xxx4,{current_char,-1})
- table.insert(chars.yyy,{current_char,-1})
- table.insert(chars.nop,{current_char,-1})
- table.insert(chars.all_nop,{'eoc',current_char,-1})
- return res
- end
-
-
- opcodes.func[opcodes.skip0]= function()
- if chars[current_char]==nil or chars[current_char].min_m==nil then
- GF.error("error in skip0")
- return error.skip0
- end
- current_row = current_row -1
- current_col = chars[current_char].min_m
- paint_switch = white
- chars[current_char][current_row]={}
- return error.ok
- end
-
-
- opcodes.func[opcodes.skip1]= function()
- if chars[current_char]==nil or chars[current_char].min_m==nil then
- GF.error("error in skip1")
- return error.skip1
- end
- local b = byte(readbytes(1))
- current_row = current_row -(b+1)
- current_col = chars[current_char].min_m
- paint_switch = white
- chars[current_char][current_row]={}
- return error.ok
- end
-
-
- opcodes.func[opcodes.skip2]= function()
- if chars[current_char]==nil or chars[current_char].min_m==nil then
- GF.error("error in skip2")
- return error.skip2
- end
- local b0 = byte(readbytes(1))
- local b1 = byte(readbytes(1))
- local b = b1+256*b0
- current_row = current_row - (b+1)
- current_col = chars[current_char].min_m
- paint_switch = white
- chars[current_char][current_row]={}
- return error.ok
- end
-
-
- opcodes.func[opcodes.skip3]= function()
- if chars[current_char]==nil or chars[current_char].min_m==nil then
- GF.error("error in skip3 ")
- return error.skip3
- end
- local b0 = byte(readbytes(1))
- local b1 = byte(readbytes(1))
- local b2 = byte(readbytes(1))
- local b = b2+b1*256+b3*65536
- current_row = current_row - (b+1)
- current_col = chars[current_char].min_m
- paint_switch = white
- chars[current_char][current_row]={}
- return error.ok
- end
-
-
- local function new_row(n)
- if chars[current_char]==nil or chars[current_char].min_m==nil then
- GF.error("error in new_row_"..n)
- return error.new_row[n]
- end
- current_row = current_row - 1
- current_col = chars[current_char].min_m+n
- paint_switch = black
- chars[current_char][current_row]={}
- return error.ok
-
- end
-
- opcodes.func[opcodes.new_row_0]= function()
- if chars[current_char]==nil or chars[current_char].min_m==nil then
- GF.error("error in new_row_0")
- return error.new_row[0]
- end
- current_row = current_row - 1
- current_col = chars[current_char].min_m
- paint_switch = black
- chars[current_char][current_row]={}
- return error.ok
- end
-
- --opcodes.func[opcodes.new_row_1]= function() new_row(1) end
- --:
- --opcodes.func[opcodes.new_row_164]= function() new_row(i)end
- for i=1, 164 do
- local key = format("new_row_%d",i)
- local index = opcodes[key]
- opcodes.func[index] = function() return new_row(i) end
- end
-
- --opcodes.func[opcodes.max_new_row]= function()
- -- return new_row(opcodes.max_new_row)
- --end
-
- opcodes.func[opcodes.xxx1]= function()
- local stream_pos = gfdata_index
- local b = byte(readbytes(1))
- local k = readbytes(b)
- table.insert(chars.xxx1,{k,stream_pos})
- table.insert(chars.all_nop,{'xxx1',k,stream_pos})
- return error.ok
- end
-
- opcodes.func[opcodes.xxx2]= function()
- local stream_pos = gfdata_index
- local b0 = byte(readbytes(1))
- local b1 = byte(readbytes(1))
- local k = readbytes(b1+ b0*256)
- table.insert(chars.xxx2,{k,stream_pos})
- table.insert(chars.all_nop,{'xxx2',k,stream_pos})
- return error.ok
- end
-
-
- opcodes.func[opcodes.xxx3]= function()
- local stream_pos = gfdata_index
- local b0 = byte(readbytes(1))
- local b1 = byte(readbytes(1))
- local b2 = byte(readbytes(1))
- local k = readbytes(b2+ b1*256+b0*65536)
- table.insert(chars.xxx3,{k,stream_pos})
- table.insert(chars.all_nop,{'xxx3', k,stream_pos})
- return error.ok
- end
-
- opcodes.func[opcodes.xxx4]= function()
- local stream_pos = gfdata_index
- local k = readbytes(read4bytes())
- -- k must be positive
- if k<=0 then
- k = k +4294967296
- end
- table.insert(chars.xxx4,{k,stream_pos})
- table.insert(chars.all_nop,{'xxx4',k,stream_pos})
- return error.ok
- end
-
- opcodes.func[opcodes.yyy]= function()
- local stream_pos = gfdata_index
- local v = read4bytes()
- table.insert(chars.yyy,{v,stream_pos})
- table.insert(chars.all_nop,{'yyy',v,stream_pos})
- return error.ok
- end
-
- opcodes.func[opcodes.nop]= function()
- table.insert(chars.nop,gfdata_index)
- table.insert(chars.all_nop,{'nop','',gfdata_index})
- return error.ok
- end
-
- opcodes.func[opcodes.char_loc]= function()
- local c = byte(readbytes(1))
- local dx = read4bytes()
- local dy = read4bytes()
- local w = read4bytes()
- local p = read4bytes()
- local char_locator = {}
- char_locator['c'] = c
- char_locator['dx'] = dx
- char_locator['dy'] = dy
- char_locator['w'] = w
- char_locator['p'] = p
- table.insert(chars.locators,char_locator)
- return error.ok
- end
-
-
- opcodes.func[opcodes.char_loc0]= function()
- local c = byte(readbytes(1))
- local dm = byte(readbytes(1))
- local w = read4bytes()
- local p = read4bytes()
- local dy = 0
- local dx = 65536*dm
- local char_locator = {}
- char_locator['c'] = c
- char_locator['dx'] = dx
- char_locator['dy'] = dy
- char_locator['w'] = w
- char_locator['p'] = p
- table.insert(chars.locators,char_locator)
- return error.ok
- end
-
-
- opcodes.func[opcodes.pre]= function()
- local i = byte(readbytes(1))
- local k = byte(readbytes(1))
- local x = readbytes(k)
- chars.GF_format = i
- chars.GF_comment = x
- return error.ok
- end
-
- opcodes.func[opcodes.post]= function()
- local p = read4bytes()
- local ds = read4bytes()
- local cs = read4bytes()
- local hppp = read4bytes()
- local vppp = read4bytes()
- local min_m = read4bytes()
- local max_m = read4bytes()
- local min_n = read4bytes()
- local max_n = read4bytes()
- chars['ds'] = ds
- chars['cs'] = cs
- chars['hppp'] = hppp
- chars['vppp'] = vppp
- chars['min_m'] = min_m
- chars['max_m'] = max_m
- chars['min_n'] = min_n
- chars['max_n'] = max_n
- return error.ok
- end
-
- opcodes.func[opcodes.post_post]= function()
- local q = read4bytes()
- local i = byte(readbytes(1))
- local pad223 = readbytes(4)
- if ( pad223~='\223\223\223\223' ) then
- GF.error("error post_post_1 "..pad223)
- return error.post_post
- end
- if gfdata_index <=gfdata_len then
- local s = readuntileof()
- local ctr223 = rep('\223',len(s))
- if ctr223 ~= s then
- GF.error("error post_post_2 "..pad223)
- return error.post_post
- end
- end
- chars.GF_format_post = i
- return error.ok
- end
-
- opcodes.func[opcodes.undefined_1]= function()
- GF.warning("undefined command 1")
- return error.ok
- end
- opcodes.func[opcodes.undefined_2]= function()
- GF.warning("undefined command 2")
- return error.ok
- end
- opcodes.func[opcodes.undefined_3]= function()
- GF.warning("undefined command 3")
- return error.ok
- end
- opcodes.func[opcodes.undefined_4]= function()
- GF.warning("undefined command 4")
- return error.ok
- end
- opcodes.func[opcodes.undefined_5]= function()
- GF.warning("undefined command 5")
- return error.ok
- end
- opcodes.func[opcodes.undefined_6]= function()
- GF.warning("undefined command 6")
- return error.ok
- end
-
-
-
- --------------------------------------------------------------------------------
- --
- --------------------------------------------------------------------------------
-
- local function load(gffile)
- gfdata = ''
- local f,res = io.open(gffile,'rb')
- if f==nil then
- GF.error(res)
- gfdata_index=0
- return error.load
- else
- gfdata = f:read("*a")
- gfdata_len = len(gfdata)
- gfdata_index =1
- end
- f:close()
- return error.ok
- end
-
-
- local function parse_pre()
- gfdata_index=1
- local res = error.ok
- local b = byte(readbytes(1))
- if b==opcodes.pre then
- local i=byte(readbytes(1))
- local k=byte(readbytes(1))
- local x=readbytes(k)
- chars.GF_format=i
- chars.comments=x
- else
- GF.error("error parsing pre")
- res = error.pre
- end
- return res
- end
-
-
- local function parse_rest()
- local b = byte(readbytes(1))
- local func = opcodes.func
- local res = error.ok
- local cond = true
- while (cond) do
- if func[b] then
- res = (func[b])()
- if res~=error.ok then
- cond = false
- elseif datanotfinished() then
- b = byte(readbytes(1))
- else
- res = error.ok
- cond = false
- end
- else
- cond = false
- GF.error("wrong opcode while parsing char")
- res = error.parsechar
- end
- end
- return res
- end
-
-
- local function parse()
- if gfdata_len == 0 then
- GF.error("no data")
- return error.parse
- end
- local res
- res = parse_pre()
- if res~=error.ok then
- GF.error("wrong preamble")
- return res
- end
- res = parse_rest()
- if not(res==error.ok) then
- GF.error("error while reading characters")
- return res
- end
- return res
- end
-
-
- ----------------------------------------------------------------------------------
- -- Parse from the end
- ----------------------------------------------------------------------------------
-
- local function skip223()
- local i = gfdata_len
- local cond = true
- while cond do
- local c = byte(sub(gfdata,i,i))
- if c==223 then
- i=i-1
- else
- cond=false
- end
- end
- if i<3 then
- GF.error("error skip suffix ")
- res = error.skip223
- else
- res = error.ok
- gfdata_index = i
- end
- return res
- end
-
-
- local function parse_char_fromlocator()
- local cond = true
- local func = opcodes.func
- local b,res
- while cond do
- b = byte(readbytes(1))
- if func[b] then
- res = (func[b])()
- if res ~= error.ok then
- cond = false
- return res
- elseif b==opcodes.eoc then
- cond = false
- else
- cond = true
- end
- else
- GF.error("wrong char from locator")
- cond = false
- return error.parse
- end
- end
- if chars[current_char] and chars[current_char].p == -1 then
- return error.ok
- end
- moveindex_after(chars[current_char].p)
- return parse_char_fromlocator()
-
- end
-
- local function parse_from_end()
- if gfdata_len == 0 then
- GF.error("no data")
- return error.parse
- end
- local res = error.ok
- gfdata_index = gfdata_len
- res = skip223()
- if res ~= error.ok then
- return res
- end
- --
- -- read identification byte
- --
- chars.GF_format_post = byte(readbytes(-1))
- --
- -- read post_post
- --
- local q = readrev4bytes()
- if q<=0 then
- q = q +4294967296
- end
- if q<1 or q>gfdata_len then
- GF.error("wrong pointer to post")
- return error.parse
- end
- --
- -- reading post
- --
- moveindex_after(q)
- q = byte(readbytes(1))
- if q~=opcodes.post then
- GF.error("expected post opcode")
- return error.parse
- end
- --
- res = opcodes.func[opcodes.post]()
- if res~=error.ok then
- GF.error("reading postamble")
- return error.parse
- end
- --
- -- read char locators
- --
- local cond = true
- local char_loc = opcodes.char_loc
- local char_loc0 = opcodes.char_loc0
- local post_post = opcodes.post_post
- local f = opcodes.func
- while cond do
- q = byte(readbytes(1))
- if q==char_loc or q==char_loc0 then
- f[q]()
- elseif q==post_post then
- cond = false
- res = error.ok
- else
- GF.error("reading char locators")
- cond = false
- return error.parse
- end
- end
- --
- -- read chars
- --
- if #chars.locators == 0 then
- GF.error("no char locators")
- return error.parse
- end
- for i,v in ipairs(chars.locators) do
- local p = v.p
- if p>-1 then
- moveindex_after(p)
- res = parse_char_fromlocator()
- if res ~= error.ok then
- break;
- end
- end
- end
- return res
- end
-
-
- --------------------------------------------------------------------------------
-
- -- Already assigned before:
- -- GF.warning = warning_msg
- -- GF.error = error_msg
- GF.load = load
- GF.parse = parse
- GF.chars = chars
- GF.errorcode = error
- GF.error_name = error_name
- GF.parse_from_end = parse_from_end
- --
- -- TODO: parsing by reading a file
- --
-
-
-end
--- Add GF to the mflua table
-mflua.GF = GF
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/mflua_svg_backend.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/mflua_svg_backend.lua
deleted file mode 100644
index 67bdeb97058..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluatrap/mflua_svg_backend.lua
+++ /dev/null
@@ -1,538 +0,0 @@
---
---
--- Experimental svg back end
---
---
-
---print ("mflua_svg_backend")
-local MFbuiltin = mflua.MFbuiltin
-local MF = mflua.MF
-print_scaled = mflua.MF.print_scaled
-
-local svg = svg or {}
-svg = {
- ['enabled']=true,
- ['enabled_raw']=false,
- ['output_dir']='svg',
- ['svg_preamble'] = [=[<?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
- "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg width="15cm" height="15cm" viewBox="%s %s %s %s"
- xmlns="http://www.w3.org/2000/svg" version="1.1">
- <title>cubic Bézier commands in path data</title>
- <desc>B char</desc>
- <style type="text/css"><![CDATA[
- .Border { fill:none; stroke:blue; stroke-width:1 }
- .Connect { fill:none; stroke:#888888; stroke-width:2 }
- .SamplePath { fill:none; stroke:black; stroke-width:1 }
- .EndPoint { fill:none; stroke:#888888; stroke-width:2 }
- .CtlPoint { fill:#888888; stroke:none }
- .AutoCtlPoint { fill:none; stroke:blue; stroke-width:4 }
- .Label { font-size:22; font-family:Verdana }
- ]]></style>
- <g transform="matrix(1 0 0 -1 0 0)">
- <g transform="translate(0 %s)">
- %s
- </g>
- </g>
- </svg>]=],
- ['emsize']= 1000,
- ['filename']= 'SourceCode',
- ['font'] = [=[
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
-<svg>
-<metadata>
-Created by FontForge 20110222 at Sun Sep 18 10:37:34 2011
- By root
-Copyleft 2002, 2003, 2005 Free Software Foundation.
- </metadata>
-<defs>
-<font id="SourceCode" >
- <font-face
- font-size='%s'
- units-per-em="%s"
- ascent='800' descent='200'
- x-height='%s'
- font-family="SourceCode"
- font-weight="400"
- font-stretch="normal"
- panose-1="2 2 6 3 5 4 5 2 3 4"
- alphabetic='0'
- />
- <missing-glyph horiz-adv-x="280" />
-
- %s
- </font>
-</defs></svg>
-]=],
-['glyph'] =
- [==[<glyph glyph-name="%s" unicode="%s" orientation="h"
- horiz-adv-x="%s" vert-adv-y="%s"
- d="%s" >%s
- </glyph>
-]==],
-['hkern'] = [==[<hkern g1="%s" u1="%s" g2="%s" u2="%s" k="%s" />]==],
-['vkern'] = [==[<vkern g1="%s" u1="%s" g2="%s" u2="%s" k="%s" />]==],
-['hkerns']='',
-['vkerns']='',
-['char']={
- ['0']={glyph_name='uni0393',unicode='&#x0393;'}, -- U+0393 GREEK CAPITAL LETTER GAMMA
- ['1']={glyph_name='uni0394',unicode='&#x0394;'}, --U+0394 GREEK CAPITAL LETTER DELTA
- ['2']={glyph_name='uni0398',unicode='&#x0398;'}, -- U+0398 GREEK CAPITAL LETTER THETA
- ['3']={glyph_name='uni039b',unicode='&#x039b;'}, -- U+039B GREEK CAPITAL LETTER LAMBDA
- ['4']={glyph_name='uni039e',unicode='&#x039e;'}, --U+039E GREEK CAPITAL LETTER XI
- ['5']={glyph_name='uni03a0',unicode='&#x03a0;'}, --U+03A0 GREEK CAPITAL LETTER PI
- ['6']={glyph_name='uni03a3',unicode='&#x03a3;'}, -- U+03A3 GREEK CAPITAL LETTER SIGMA
- ['7']={glyph_name='uni03a5',unicode='&#x03a5;'}, --U+03A5 GREEK CAPITAL LETTER UPSILON
- ['8']={glyph_name='uni03a6',unicode='&#x03a6;'}, -- U+03A6 GREEK CAPITAL LETTER PHI
- ['9']={glyph_name='uni03a8',unicode='&#x03a8;'}, -- U+03A8 GREEK CAPITAL LETTER PSI
- ['10']={glyph_name='uni03a9',unicode='&#x03a9;'}, -- U+03A9 GREEK CAPITAL LETTER OMEGA
- ['11']={glyph_name='unifb00',unicode='ff'}, -- U+FB00 LATIN SMALL LIGATURE FF
- ['12']={glyph_name='unifb01',unicode='fi'}, --U+FB01 LATIN SMALL LIGATURE FI
- ['13']={glyph_name='unifb02',unicode='fl'}, -- U+FB02 LATIN SMALL LIGATURE FL
- ['14']={glyph_name='unifb03',unicode='ffi'}, --U+FB03 LATIN SMALL LIGATURE FFI
- ['15']={glyph_name='unifb04',unicode='ffl'}, -- U+FB04 LATIN SMALL LIGATURE FFL
- ['16']={glyph_name='uni0131',unicode='&#x0131;'}, -- U+0131 LATIN SMALL LETTER DOTLESS I
- ['17']={glyph_name='uni0237',unicode='&#x0237;'}, -- U+0237 LATIN SMALL LETTER DOTLESS J
- ['18']={glyph_name='uni0060',unicode='&#x0060;'}, -- U+0060 GRAVE ACCENT
- ['19']={glyph_name='uni00b4',unicode='&#x00b4;'}, -- U+00B4 ACUTE ACCENT
- ['20']={glyph_name='uni02c7',unicode='&#x02c7;'}, -- U+02C7 CARON
- ['21']={glyph_name='uni02d8',unicode='&#x02d8;'}, -- U+02D8 BREVE
- ['22']={glyph_name='uni00af',unicode='&#x00af;'}, -- U+00AF MACRON
- ['23']={glyph_name='uni02da',unicode='&#x02da;'}, -- U+02DA RING ABOVE
- ['24']={glyph_name='uni00b8',unicode='&#x00b8;'}, -- U+00B8 CEDILLA
- ['25']={glyph_name='uni00df',unicode='&#x00df;'}, -- U+00DF LATIN SMALL LETTER SHARP S
- ['26']={glyph_name='uni00e6',unicode='&#x00e6;'}, -- U+00E6 LATIN SMALL LETTER AE
- ['27']={glyph_name='uni0153',unicode='&#x0153;'}, -- U+0153 LATIN SMALL LIGATURE OE
- ['28']={glyph_name='uni00f8',unicode='&#x00f8;'}, -- U+00F8 LATIN SMALL LETTER O WITH STROKE
- ['29']={glyph_name='uni00c6',unicode='&#x00c6;'}, --U+00C6 LATIN CAPITAL LETTER AE
- ['30']={glyph_name='uni0152',unicode='&#x0152;'}, --U+0152 LATIN CAPITAL LIGATURE OE
- ['31']={glyph_name='uni00D8',unicode='&#x00D8;'}, --U+00D8 LATIN CAPITAL LETTER O WITH STROKE
- ['32']={glyph_name='uni0337',unicode='&#x0337;'}, --U+0337 COMBINING SHORT SOLIDUS OVERLAY
- ['33']={glyph_name='uni0021',unicode='&#x0021;'},
- ['34']={glyph_name='uni201d',unicode='&#x201d;'}, -- U+201D RIGHT DOUBLE QUOTATION MARK
- ['35']={glyph_name='uni0023',unicode='&#x0023;'},
- ['36']={glyph_name='uni0024',unicode='&#x0024;'},
- ['37']={glyph_name='uni0025',unicode='&#x0025;'},
- ['38']={glyph_name='uni0026',unicode='&#x0026;'},
- ['39']={glyph_name='uni0027',unicode='&#x0027;'},
- ['40']={glyph_name='uni0028',unicode='&#x0028;'},
- ['41']={glyph_name='uni0029',unicode='&#x0029;'},
- ['42']={glyph_name='uni002a',unicode='&#x002a;'},
- ['43']={glyph_name='uni002b',unicode='&#x002b;'},
- ['44']={glyph_name='uni002c',unicode='&#x002c;'},
- ['45']={glyph_name='uni002d',unicode='&#x002d;'}, -- U+002D HYPHEN-MINUS
- ['46']={glyph_name='uni002e',unicode='&#x002e;'},
- ['47']={glyph_name='uni002f',unicode='&#x002f;'},
- ['48']={glyph_name='uni0030',unicode='&#x0030;'},
- ['49']={glyph_name='uni0031',unicode='&#x0031;'},
- ['50']={glyph_name='uni0032',unicode='&#x0032;'},
- ['51']={glyph_name='uni0033',unicode='&#x0033;'},
- ['52']={glyph_name='uni0034',unicode='&#x0034;'},
- ['53']={glyph_name='uni0035',unicode='&#x0035;'},
- ['54']={glyph_name='uni0036',unicode='&#x0036;'},
- ['55']={glyph_name='uni0037',unicode='&#x0037;'},
- ['56']={glyph_name='uni0038',unicode='&#x0038;'},
- ['57']={glyph_name='uni0039',unicode='&#x0039;'},
- ['58']={glyph_name='uni003a',unicode='&#x003a;'},
- ['59']={glyph_name='uni003b',unicode='&#x003b;'},
- ['60']={glyph_name='uni00a1',unicode='&#x00a1;'}, -- U+00A1 INVERTED EXCLAMATION MARK, but only if ligs>1
- ['61']={glyph_name='uni003d',unicode='&#x003d;'},
- ['62']={glyph_name='uni00bf',unicode='&#x00bf;'}, --U+00BF INVERTED QUESTION MARK
- ['63']={glyph_name='uni003f',unicode='&#x003f;'},
- ['64']={glyph_name='uni0040',unicode='&#x0040;'},
- ['65']={glyph_name='uni0041',unicode='&#x0041;'},
- ['66']={glyph_name='uni0042',unicode='&#x0042;'},
- ['67']={glyph_name='uni0043',unicode='&#x0043;'},
- ['68']={glyph_name='uni0044',unicode='&#x0044;'},
- ['69']={glyph_name='uni0045',unicode='&#x0045;'},
- ['70']={glyph_name='uni0046',unicode='&#x0046;'},
- ['71']={glyph_name='uni0047',unicode='&#x0047;'},
- ['72']={glyph_name='uni0048',unicode='&#x0048;'},
- ['73']={glyph_name='uni0049',unicode='&#x0049;'},
- ['74']={glyph_name='uni004a',unicode='&#x004a;'},
- ['75']={glyph_name='uni004b',unicode='&#x004b;'},
- ['76']={glyph_name='uni004c',unicode='&#x004c;'},
- ['77']={glyph_name='uni004d',unicode='&#x004d;'},
- ['78']={glyph_name='uni004e',unicode='&#x004e;'},
- ['79']={glyph_name='uni004f',unicode='&#x004f;'},
- ['80']={glyph_name='uni0050',unicode='&#x0050;'},
- ['81']={glyph_name='uni0051',unicode='&#x0051;'},
- ['82']={glyph_name='uni0052',unicode='&#x0052;'},
- ['83']={glyph_name='uni0053',unicode='&#x0053;'},
- ['84']={glyph_name='uni0054',unicode='&#x0054;'},
- ['85']={glyph_name='uni0055',unicode='&#x0055;'},
- ['86']={glyph_name='uni0056',unicode='&#x0056;'},
- ['87']={glyph_name='uni0057',unicode='&#x0057;'},
- ['88']={glyph_name='uni0058',unicode='&#x0058;'},
- ['89']={glyph_name='uni0059',unicode='&#x0059;'},
- ['90']={glyph_name='uni005a',unicode='&#x005a;'},
- ['91']={glyph_name='uni005b',unicode='&#x005b;'},
- ['92']={glyph_name='uni201c',unicode='&#x201c;'}, -- U+201C LEFT DOUBLE QUOTATION MARK
- ['93']={glyph_name='uni005d',unicode='&#x005d;'},
- ['94']={glyph_name='uni0302',unicode='&#x0302;'}, --U+0302 COMBINING CIRCUMFLEX ACCENT
- ['95']={glyph_name='uni0307',unicode='&#x0307;'}, --U+0307 COMBINING DOT ABOVE
- ['96']={glyph_name='uni2018',unicode='&#x2018;'}, --U+2018 LEFT SINGLE QUOTATION MARK
- ['97']={glyph_name='uni0061',unicode='&#x0061;'},
- ['98']={glyph_name='uni0062',unicode='&#x0062;'},
- ['99']={glyph_name='uni0063',unicode='&#x0063;'},
- ['100']={glyph_name='uni0064',unicode='&#x0064;'},
- ['101']={glyph_name='uni0065',unicode='&#x0065;'},
- ['102']={glyph_name='uni0066',unicode='&#x0066;'},
- ['103']={glyph_name='uni0067',unicode='&#x0067;'},
- ['104']={glyph_name='uni0068',unicode='&#x0068;'},
- ['105']={glyph_name='uni0069',unicode='&#x0069;'},
- ['106']={glyph_name='uni006a',unicode='&#x006a;'},
- ['107']={glyph_name='uni006b',unicode='&#x006b;'},
- ['108']={glyph_name='uni006c',unicode='&#x006c;'},
- ['109']={glyph_name='uni006d',unicode='&#x006d;'},
- ['110']={glyph_name='uni006e',unicode='&#x006e;'},
- ['111']={glyph_name='uni006f',unicode='&#x006f;'},
- ['112']={glyph_name='uni0070',unicode='&#x0070;'},
- ['113']={glyph_name='uni0071',unicode='&#x0071;'},
- ['114']={glyph_name='uni0072',unicode='&#x0072;'},
- ['115']={glyph_name='uni0073',unicode='&#x0073;'},
- ['116']={glyph_name='uni0074',unicode='&#x0074;'},
- ['117']={glyph_name='uni0075',unicode='&#x0075;'},
- ['118']={glyph_name='uni0076',unicode='&#x0076;'},
- ['119']={glyph_name='uni0077',unicode='&#x0077;'},
- ['120']={glyph_name='uni0078',unicode='&#x0078;'},
- ['121']={glyph_name='uni0079',unicode='&#x0079;'},
- ['122']={glyph_name='uni007a',unicode='&#x007a;'},
- ['123']={glyph_name='uni2013',unicode='&#x2013;'}, -- U+2013 EN DASH
- ['124']={glyph_name='uni2014',unicode='&#x2014;'}, -- U+2014 EM DASH
- ['125']={glyph_name='uni030b',unicode='&#x030b;'}, --U+030B COMBINING DOUBLE ACUTE ACCENT
- ['126']={glyph_name='uni0303',unicode='&#x0303;'}, --U+0303 COMBINING TILDE
- ['127']={glyph_name='uni0308',unicode='&#x0308;'}, --U+0308 COMBINING DIAERESIS
- ['128']={glyph_name='uni0080',unicode='&#x0080;'},
- ['129']={glyph_name='uni0081',unicode='&#x0081;'},
- ['130']={glyph_name='uni0082',unicode='&#x0082;'},
- ['131']={glyph_name='uni0083',unicode='&#x0083;'},
- ['132']={glyph_name='uni0084',unicode='&#x0084;'},
- ['133']={glyph_name='uni0085',unicode='&#x0085;'},
- ['134']={glyph_name='uni0086',unicode='&#x0086;'},
- ['135']={glyph_name='uni0087',unicode='&#x0087;'},
- ['136']={glyph_name='uni0088',unicode='&#x0088;'},
- ['137']={glyph_name='uni0089',unicode='&#x0089;'},
- ['138']={glyph_name='uni008a',unicode='&#x008a;'},
- ['139']={glyph_name='uni008b',unicode='&#x008b;'},
- ['140']={glyph_name='uni008c',unicode='&#x008c;'},
- ['141']={glyph_name='uni008d',unicode='&#x008d;'},
- ['142']={glyph_name='uni008e',unicode='&#x008e;'},
- ['143']={glyph_name='uni008f',unicode='&#x008f;'},
- ['144']={glyph_name='uni0090',unicode='&#x0090;'},
- ['145']={glyph_name='uni0091',unicode='&#x0091;'},
- ['146']={glyph_name='uni0092',unicode='&#x0092;'},
- ['147']={glyph_name='uni0093',unicode='&#x0093;'},
- ['148']={glyph_name='uni0094',unicode='&#x0094;'},
- ['149']={glyph_name='uni0095',unicode='&#x0095;'},
- ['150']={glyph_name='uni0096',unicode='&#x0096;'},
- ['151']={glyph_name='uni0097',unicode='&#x0097;'},
- ['152']={glyph_name='uni0098',unicode='&#x0098;'},
- ['153']={glyph_name='uni0099',unicode='&#x0099;'},
- ['154']={glyph_name='uni009a',unicode='&#x009a;'},
- ['155']={glyph_name='uni009b',unicode='&#x009b;'},
- ['156']={glyph_name='uni009c',unicode='&#x009c;'},
- ['157']={glyph_name='uni009d',unicode='&#x009d;'},
- ['158']={glyph_name='uni009e',unicode='&#x009e;'},
- ['159']={glyph_name='uni009f',unicode='&#x009f;'},
- ['160']={glyph_name='uni00a0',unicode='&#x00a0;'},
- ['161']={glyph_name='uni00a1',unicode='&#x00a1;'},
- ['162']={glyph_name='uni00a2',unicode='&#x00a2;'},
- ['163']={glyph_name='uni00a3',unicode='&#x00a3;'},
- ['164']={glyph_name='uni00a4',unicode='&#x00a4;'},
- ['165']={glyph_name='uni00a5',unicode='&#x00a5;'},
- ['166']={glyph_name='uni00a6',unicode='&#x00a6;'},
- ['167']={glyph_name='uni00a7',unicode='&#x00a7;'},
- ['168']={glyph_name='uni00a8',unicode='&#x00a8;'},
- ['169']={glyph_name='uni00a9',unicode='&#x00a9;'},
- ['170']={glyph_name='uni00aa',unicode='&#x00aa;'},
- ['171']={glyph_name='uni00ab',unicode='&#x00ab;'},
- ['172']={glyph_name='uni00ac',unicode='&#x00ac;'},
- ['173']={glyph_name='uni00ad',unicode='&#x00ad;'},
- ['174']={glyph_name='uni00ae',unicode='&#x00ae;'},
- ['175']={glyph_name='uni00af',unicode='&#x00af;'},
- ['176']={glyph_name='uni00b0',unicode='&#x00b0;'},
- ['177']={glyph_name='uni00b1',unicode='&#x00b1;'},
- ['178']={glyph_name='uni00b2',unicode='&#x00b2;'},
- ['179']={glyph_name='uni00b3',unicode='&#x00b3;'},
- ['180']={glyph_name='uni00b4',unicode='&#x00b4;'},
- ['181']={glyph_name='uni00b5',unicode='&#x00b5;'},
- ['182']={glyph_name='uni00b6',unicode='&#x00b6;'},
- ['183']={glyph_name='uni00b7',unicode='&#x00b7;'},
- ['184']={glyph_name='uni00b8',unicode='&#x00b8;'},
- ['185']={glyph_name='uni00b9',unicode='&#x00b9;'},
- ['186']={glyph_name='uni00ba',unicode='&#x00ba;'},
- ['187']={glyph_name='uni00bb',unicode='&#x00bb;'},
- ['188']={glyph_name='uni00bc',unicode='&#x00bc;'},
- ['189']={glyph_name='uni00bd',unicode='&#x00bd;'},
- ['190']={glyph_name='uni00be',unicode='&#x00be;'},
- ['191']={glyph_name='uni00bf',unicode='&#x00bf;'},
- ['192']={glyph_name='uni00c0',unicode='&#x00c0;'},
--- ['193']={glyph_name='uni00c1',unicode='&#x00c1;'},
- ['193']={glyph_name='uni0060',unicode='&#x0060;'},
--- ['194']={glyph_name='uni00c2',unicode='&#x00c2;'},
- ['194']={glyph_name='uni00b4',unicode='&#x00b4;'},
--- ['195']={glyph_name='uni00c3',unicode='&#x00c3;'},
- ['195']={glyph_name='uni005e',unicode='&#x005e;'},
- ['196']={glyph_name='uni00c4',unicode='&#x00c4;'},
- ['197']={glyph_name='uni00c5',unicode='&#x00c5;'},
- ['198']={glyph_name='uni00c6',unicode='&#x00c6;'},
- ['199']={glyph_name='uni00c7',unicode='&#x00c7;'},
- ['200']={glyph_name='uni00c8',unicode='&#x00c8;'},
- ['201']={glyph_name='uni00c9',unicode='&#x00c9;'},
- ['202']={glyph_name='uni00ca',unicode='&#x00ca;'},
- ['203']={glyph_name='uni00cb',unicode='&#x00cb;'},
- ['204']={glyph_name='uni00cc',unicode='&#x00cc;'},
- ['205']={glyph_name='uni00cd',unicode='&#x00cd;'},
- ['206']={glyph_name='uni00ce',unicode='&#x00ce;'},
- ['207']={glyph_name='uni00cf',unicode='&#x00cf;'},
- ['208']={glyph_name='uni00d0',unicode='&#x00d0;'},
- ['209']={glyph_name='uni00d1',unicode='&#x00d1;'},
- ['210']={glyph_name='uni00d2',unicode='&#x00d2;'},
- ['211']={glyph_name='uni00d3',unicode='&#x00d3;'},
- ['212']={glyph_name='uni00d4',unicode='&#x00d4;'},
- ['213']={glyph_name='uni00d5',unicode='&#x00d5;'},
- ['214']={glyph_name='uni00d6',unicode='&#x00d6;'},
- ['215']={glyph_name='uni00d7',unicode='&#x00d7;'},
- ['216']={glyph_name='uni00d8',unicode='&#x00d8;'},
- ['217']={glyph_name='uni00d9',unicode='&#x00d9;'},
- ['218']={glyph_name='uni00da',unicode='&#x00da;'},
- ['219']={glyph_name='uni00db',unicode='&#x00db;'},
- ['220']={glyph_name='uni00dc',unicode='&#x00dc;'},
- ['221']={glyph_name='uni00dd',unicode='&#x00dd;'},
- ['222']={glyph_name='uni00de',unicode='&#x00de;'},
- ['223']={glyph_name='uni00df',unicode='&#x00df;'},
- ['224']={glyph_name='uni00e0',unicode='&#x00e0;'},
- ['225']={glyph_name='uni00e1',unicode='&#x00e1;'},
- ['226']={glyph_name='uni00e2',unicode='&#x00e2;'},
- ['227']={glyph_name='uni00e3',unicode='&#x00e3;'},
- ['228']={glyph_name='uni00e4',unicode='&#x00e4;'},
- ['229']={glyph_name='uni00e5',unicode='&#x00e5;'},
- ['230']={glyph_name='uni00e6',unicode='&#x00e6;'},
- ['231']={glyph_name='uni00e7',unicode='&#x00e7;'},
- ['232']={glyph_name='uni00e8',unicode='&#x00e8;'},
- ['233']={glyph_name='uni00e9',unicode='&#x00e9;'},
- ['234']={glyph_name='uni00ea',unicode='&#x00ea;'},
- ['235']={glyph_name='uni00eb',unicode='&#x00eb;'},
- ['236']={glyph_name='uni00ec',unicode='&#x00ec;'},
- ['237']={glyph_name='uni00ed',unicode='&#x00ed;'},
- ['238']={glyph_name='uni00ee',unicode='&#x00ee;'},
- ['239']={glyph_name='uni00ef',unicode='&#x00ef;'},
- ['240']={glyph_name='uni00f0',unicode='&#x00f0;'},
- ['241']={glyph_name='uni00f1',unicode='&#x00f1;'},
- ['242']={glyph_name='uni00f2',unicode='&#x00f2;'},
- ['243']={glyph_name='uni00f3',unicode='&#x00f3;'},
- ['244']={glyph_name='uni00f4',unicode='&#x00f4;'},
- ['245']={glyph_name='uni00f5',unicode='&#x00f5;'},
- ['246']={glyph_name='uni00f6',unicode='&#x00f6;'},
- ['247']={glyph_name='uni00f7',unicode='&#x00f7;'},
- ['248']={glyph_name='uni00f8',unicode='&#x00f8;'},
- ['249']={glyph_name='uni00f9',unicode='&#x00f9;'},
- ['250']={glyph_name='uni00fa',unicode='&#x00fa;'},
- ['251']={glyph_name='uni00fb',unicode='&#x00fb;'},
- ['252']={glyph_name='uni00fc',unicode='&#x00fc;'},
- ['253']={glyph_name='uni00fd',unicode='&#x00fd;'},
- ['254']={glyph_name='uni00fe',unicode='&#x00fe;'},
- ['255']={glyph_name='uni00ff',unicode='&#x00ff;'},
- ['256']={glyph_name='uni0100',unicode='&#x0100;'},
- },
-
-}
-
-local function _eval_tonumber(q,offset)
- local qx,qy,xo,yo
- local w
- local _offset = offset
- if _offset == nil then _offset = '(0,0)' end
- w=string.gmatch(q,"[-0-9.]+"); qx,qy=w(),w()
- w=string.gmatch(_offset,"[-0-9.]+"); xo,yo=w(),w()
- return {tonumber(qx+xo),tonumber(qy+yo)}
-end
-
-
-local function get_svg_glyph(valid_curves,char,cycles,tfm)
- -- Write the svg
- --
- -- print('BEZ MFbuiltin.hppp='..print_scaled(MFbuiltin.hppp()))
- -- print('BEZ MFbuiltin.vppp='..print_scaled(MFbuiltin.vppp()))
- -- print('BEZ MFbuiltin.designsize='..print_scaled(MFbuiltin.designsize()))
- local tfm = tfm
- local index = tostring( char['index'] ) -- better a string or a number
- local design_size=tonumber ( print_scaled(MFbuiltin.designsize()) ) --pt
- local char_wd=tonumber( char['char_wd'] ) -- pt
- local char_ht=tonumber( char['char_ht'] ) -- pt
- local char_dp=tonumber( char['char_dp'] ) -- pt
-
- --local xheight = 0.458333 * design_size -- must be read from tfm !!
-
- local x_resolution = math.floor(0.5+tonumber( print_scaled(MFbuiltin.hppp()) )* 72.27)
- local y_resolution = math.floor(0.5+tonumber( print_scaled(MFbuiltin.vppp()) )* 72.27)
- assert(x_resolution==y_resolution, string.format('Error on _get_svg_glyph x_res=%d and y_res=%d differ',x_resolution,y_resolution))
-
- local resolution = x_resolution
- local emsize = mflua.svg.emsize -- 1000, type 1, also known as em_unit: 1000 emsize = 1em
- local em_unit = emsize
-
- local em_unit_for_pixel = (72.27/design_size) * (emsize / resolution)
- local bp_for_pt = 72/72.27
- local char_wd_emunit = (char_wd/design_size) *em_unit
- local char_ht_emunit = (char_ht/design_size) *em_unit
- local char_dp_emunit = (char_dp/design_size) *em_unit
-
- local outdir = mflua.svg.output_dir or '.'
- local fname = tostring(char['charname'])
- if fname and fname ~= '' then
- mflua.svg.char[index] ={glyph_name='', unicode = ''};
- mflua.svg.char[index].glyph_name = fname
- local w = string.gmatch(fname,'uni(.+)')
- local unicode_hex = w()
- mflua.svg.char[index].unicode = [[&#x]] .. unicode_hex ..';'
- end
-
- fname = mflua.svg.char[index].glyph_name
- assert(fname~=nil, string.format("Error on svg file name for char index %s: it's nil",index))
- --local f = io.open(outdir..'/'.. fname..'.svg','w')
- local w = string.gmatch(fname,'uni(.+)')
- local unicode_hex = w()
- local unicode = mflua.svg.char[index].unicode
- local unicode_range = 'U+'..unicode_hex
- local glyph_name = fname
- local bezier = ''
- local maxx,maxy=-1e9,-1e9
- local minx,miny=1e9,1e9
- for i,cycle in pairs(cycles) do
- local path=''
- local _i=1
- for _,j in ipairs(cycle) do
- --local curve = valid_curves[j]
- local curve = j
- local p,c1,c2,q,offset=curve[1],curve[2],curve[3],curve[4],curve[5]
- p=_eval_tonumber(p,offset)
- c1=_eval_tonumber(c1,offset)
- c2=_eval_tonumber(c2,offset)
- q=_eval_tonumber(q,offset)
- -- em_unit_for_pixel
- p[1],p[2] = p[1]*em_unit_for_pixel,p[2]*em_unit_for_pixel
- q[1],q[2] = q[1]*em_unit_for_pixel,q[2]*em_unit_for_pixel
- c1[1],c1[2] = c1[1]*em_unit_for_pixel,c1[2]*em_unit_for_pixel
- c2[1],c2[2] = c2[1]*em_unit_for_pixel,c2[2]*em_unit_for_pixel
- if _i==1 then bezier = bezier..string.format("M%s %s ",p[1],p[2]) end
- _i=_i+1
- bezier = bezier .. string.format("C%s %s %s %s %s %s\n",c1[1],c1[2],c2[1],c2[2],q[1],q[2])
- --print("BEZ bez="..bezier)
- if p[1]>maxx then maxx=p[1] end
- if c1[1]>maxx then maxx=c1[1] end
- if c2[1]>maxx then maxx=c2[1] end
- if q[1]>maxx then maxx=q[1] end
- if p[2]>maxy then maxy=p[2] end
- if c1[2]>maxy then maxy=c1[2] end
- if c2[2]>maxy then maxy=c2[2] end
- if q[2]>maxy then maxy=q[2] end
- --
- if p[1]<minx then minx=p[1] end
- if c1[1]<minx then minx=c1[1] end
- if c2[1]<minx then minx=c2[1] end
- if q[1]<minx then minx=q[1] end
- if p[2]<miny then miny=p[2] end
- if c1[2]<miny then miny=c1[2] end
- if c2[2]<miny then miny=c2[2] end
- if q[2]<miny then miny=q[2] end
- end
- bezier = bezier .. 'Z\n'
- end
- --print('BEZ (x,y) (X,Y)=',minx,miny,maxx,maxy)
- --print('BEZ', svg_glyph,glyph_name,unicode,char_wd_emunit,char_ht_emunit,bezier)
- local trunk = ''
- local svg_glyph = mflua.svg.glyph
- local svg_font = mflua.svg.font
- trunk = string.format(svg_glyph,
- glyph_name,unicode,
- char_wd_emunit,
- char_ht_emunit,
- bezier,'')
- local svg_preamble = mflua.svg.svg_preamble
- local paths = string.format('<path style="fill:#000000;stroke=none;fill-rule:nonzero" d="%s" />', bezier)
- local raw=string.format(svg_preamble,minx,miny,maxx,maxy,-maxy,paths)
- return trunk,raw
-end -- _get_svg_glyph
-
-
-local function svg_kern_and_lig(chartable,t,tfm)
- --
- -- Store kerns and ligs
- --
- local current_chars={}
- local index
- local kern, next_char,additional_space
- local bp_for_pt = 72/72.27
- local x_resolution = math.floor(0.5+tonumber( print_scaled(MFbuiltin.hppp()) )* bp_for_pt)
- local y_resolution = math.floor(0.5+tonumber( print_scaled(MFbuiltin.vppp()) )* bp_for_pt)
- local design_size=tfm.font.designsize -- pt
- assert(x_resolution==y_resolution, string.format('Error on _get_svg_glyph x_res=%d and y_res=%d differ',x_resolution,y_resolution))
- local resolution = x_resolution
- local emsize = mflua.svg.emsize -- 1000, type 1, also known as em_unit: 1000 emsize = 1em
- local em_unit = emsize
- local em_unit_for_pixel = (bp_for_pt/design_size) * (emsize / resolution)
-
- local hkern,vkern = '' ,''
- for i,_ in ipairs(t) do
- index = t[i]
- current_chars[index]=true
- end
- for i,_ in ipairs(t) do
- index = t[i]
- if tfm.chars[index] and tfm.chars[index].kern then
- kerntable = tfm.chars[index].kern
- for _,k in ipairs(kerntable) do
- next_char,additional_space = tostring(k.next_char),tonumber(k.additional_space)
- --
- if additional_space~=0 then
- local a_name,a_unicode = mflua.svg.char[tostring(index)].glyph_name,mflua.svg.char[tostring(index)].unicode
- local b_name,b_unicode = mflua.svg.char[next_char].glyph_name,mflua.svg.char[next_char].unicode
- hkern = hkern .. "\n".. string.format(mflua.svg.hkern,
- a_name,a_unicode,
- b_name,b_unicode,
- additional_space*design_size*em_unit_for_pixel)
- end
- end
- end
- end
- return hkern,vkern
-end
-
-local function store_svg_font(tfm)
- -- local outdir = mflua.svg.output_dir or '.'
- -- local fname = mflua.svg.filename
- -- assert(fname~=nil, string.format("Error on svg file name for %s: it's nil",fname))
- -- local f = io.open(outdir..'/'.. fname..'.svg','w')
- local svg_font = mflua.svg.font
- local design_size=tonumber ( print_scaled(MFbuiltin.designsize()) ) --pt
- local emsize = mflua.svg.emsize -- 1000, type 1, also known as em_unit: 1000 emsize = 1em
- local bp_for_pt = 72/72.27
- local xheight = tfm.font.x_height * design_size --0.458333 * design_size -- must be read from tfm !!
- local trunk =''
- local char = mflua.svg.char
- for index=0,2^16-1 do
- if not(char[tostring(index)]==nil) then
- --print("BEZ char[tostring(index)].data=",index,char[tostring(index)].data)
- trunk= trunk.. (char[tostring(index)].data or '')
- end
- end
- trunk = trunk.."\n"..mflua.svg.hkerns.."\n"..mflua.svg.vkerns
- trunk = string.format(svg_font,
- string.format("%2.2f",design_size*bp_for_pt),
- emsize,
- string.format("%2.2f",xheight*bp_for_pt),
- trunk)
- return trunk
-
-
-end
-
-svg.get_svg_glyph = get_svg_glyph
-svg.svg_kern_and_lig = svg_kern_and_lig
-svg.store_svg_font = store_svg_font
-
-return svg
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/mflua_ttx_backend.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/mflua_ttx_backend.lua
deleted file mode 100644
index 2f3f36fa095..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluatrap/mflua_ttx_backend.lua
+++ /dev/null
@@ -1,1228 +0,0 @@
-local format = string.format
-local table_insert = table.insert
-local table_remove = table.remove
-local table_concat = table.concat
-local table_sort = table.sort
-local print_int = mflua.MF.print_int
-local abs = math.abs
-local math_floor = math.floor
-local math_tointeger = math.tointeger or math.floor
-
-local print_scaled = mflua.MF.print_scaled
-local unity = mflua.MF.unity
-
-local GF = mflua.GF
-local GF_chars = GF.chars
-
-local ttx = {}
-local xmlstream = {}
-local scrt = {} -- general table for local use
-
-
-
-
-local function DUMP(t)
- if type(t) == 'table' then
- print("table",#table)
- for k,v in pairs(t) do print(k,v) end
- end
-end
-
-local function print_err(msg)
- print(format("! ttx backend: %s",tostring(msg)))
-end
-
-local function tointeger(n)
- return math_tointeger(n)
-end
-
-local function _normalize(w,n)
- n = tonumber(n) or 5
- n = math_floor(abs(n))
- n = (n<25 and n) or 24
- local fmt = format("%%0.%sf", n)
- local W = tonumber(format(fmt,w))
- nx = tointeger(W)
- if nx==W then
- return nx
- else
- return w
- end
-end
-
-local function normalize(w,n)
- return print_scaled(w)
-end
-
-local function _normalize_and_simplify(w,n)
- n = tonumber(n) or 2
- n = math_floor(abs(n))
- n = (n<25 and n) or 24
- local fmt = format("%%0.%sf", n)
- local W = tonumber(format(fmt,w))
- nx = tointeger(W)
- if nx==W then
- return nx
- else
- return W
- end
-end
-
-local function normalize_and_simplify(w,n)
- return print_scaled(w)
-end
-
-
-local function toscaled(n)
- return tonumber(format("%0.0f",n*unity))
-end
-
-local function table_sorted(t)
- if type(t)=='table' then
- table_sort(t)
- return t
- else
- return {t}
- end
-end
-
-
-local xml_comment = 'c'
-local xml_processing_instruction = 'p'
-local xml_element = 'e'
-local xml_header = 'h'
-
-
---------------------------------------------------------------------------------
---
--- Errors and warning
---------------------------------------------------------------------------------
-local function warning(t,msg)
- print("Warning:"..msg..".")
- print("Element:")
- if type(t)=='table' then
- for k,v in pairs(t) do print(k,v) end
- print(#t.." values")
- else
- print(tostring(s))
- end
-end
-
-
---------------------------------------------------------------------------------
---
--- Element management
---------------------------------------------------------------------------------
-
-
--- Todo: valid XML totext & toattr & tocomment
-local function totext(s)
- if not(type(s)=='string') then
- warning(s,"text:the data in not a string")
- end
- return tostring(s)
-end
-
-local function toattr(s)
- if not(type(s)=='string') then
- warning(s,"attr.:the data in not a string")
- end
- return tostring(s)
-end
-
-local function tocomment(s)
- if not(type(s)=='string') then
- warning(s,"comment:the data in not a string")
- end
- return tostring(s)
-end
-
-local function new_comment(text)
- local t ={}
- t[0]=xml_comment
- t[1]=false
- t[2]=tocomment(text)
- return t
-end
-
-local function new_element(name,attr)
- local t ={}
- t[0]=xml_element
- t[1]=tostring(name)
- if attr and type(attr)=='table' then
- for k,v in pairs(attr) do
- if type(k)~='number' then
- t[k]=v
- end
- end
- end
- return t
-end
-
-local function get_elementname(t)
- if t and type(t)=='table' then
- return t[1]
- else
- return nil
- end
-end
-
-local function insert_child(f,c)
- table_insert(f,c)
-end
-
-local function insert_child_at_beginning(f,c)
- -- f[1] is always the name
- table_insert(f,2,c)
-end
-
-local function insert_children(f,cc)
- for j=1,#cc do
- table_insert(f,cc[j])
- end
-end
-
-
---
--- get all the children (not descendants!)
--- of source that match target name and attr.
--- The existence of an attribute can be checked
--- with @attrname=true (not @attrname="true") in
--- target
-local function get_children(source,target)
- local res={}
- local t_attr={}
- -- only key/val from target
- for k,v in pairs(target) do
- if type(k)=='number' then
- t_attr[k]=v
- end
- end
- for i=2,#source do
- local e = source[i]
- if e[1]==target[1] then
- local found=true
- for k,v in pairs(t_attr) do
- if not(e[k] and ((e[k]==v) or (v==true))) then
- found=false
- break
- end
- end
- if found then
- res[#res+1]=e
- end
- end
- end
- return res
-end
-
---
--- remove the first xml_element inserted
--- with name. Return the element removed
--- false otherwise
-local function remove_child(t,name)
- for i=1,#t do
- if t[i][0]==xml_element and t[i][1]==tostring(name) then
- return table.remove(t,i)
- end
- end
- return false
-end
-
---
--- call remove_child on all elements of
--- names
-
-local function remove_children(t,names)
- local res = {}
- local name, r
- for _,v in pairs(names) do
- name = tostring(v)
- r = remove_child(t,name)
- if r then
- table_insert(res,r)
- end
- end
- return res
-end
-
-
-
---------------------------------------------------------------------------------
---
--- Serialization
----------------------------------------------------------------------------------
-
-local function serialize_comment(t)
- if not(t[0]== xml_comment) then
- warning(t,'the node to serialize is not a comment')
- return
- end
- local name=t[1] -- false, discarded
- local elem={}
- elem[#elem+1]='<--'
- elem[#elem+1]=tocomment(t2)
- elem[#elem+1]='-->'
- elem[#elem+1]='\n'
- xmlstream[#xmlstream+1] = table_concat(elem)
-end
-
-
-local function serialize_processing_instruction(t)
- if not(t[0]== xml_processing_instruction) then
- warning(t,'the node to serialize is not a processing_instruction')
- return
- end
- local name=t[1]
- local elem={}
- elem[#elem+1]='<?'
- elem[#elem+1]=name
- local _t={}
- for k,v in pairs(t) do
- if not(type(k)=='number') then
- _t[#_t+1]=k
- end
- end
- for j=1,#_t do
- elem[#elem+1]=format([[ %s="%s"]],_t[j],toattr(t[_t[j]]))
- end
- elem[#elem+1]='?>'
- elem[#elem+1]="\n"
- xmlstream[#xmlstream+1] = table_concat(elem)
-end
-
-local function serialize_xml_header(t)
- local _t={}
- local elem={}
- elem[#elem+1]='<?'
- elem[#elem+1]='xml '
- elem[#elem+1]=t
- elem[#elem+1]='?>'
- elem[#elem+1]='\n'
- xmlstream[#xmlstream+1] = table_concat(elem)
-end
-
-local function serialize_empty_elem(t)
- local name=t[1]
- local elem={}
- elem[#elem+1]='<'
- elem[#elem+1]=name
- local _t={}
- for k,v in pairs(t) do
- if not(type(k)=='number') then
- _t[#_t+1]=k
- end
- end
- table.sort(_t)
- for j=1,#_t do
- elem[#elem+1]=format([[ %s="%s"]],_t[j],toattr(t[_t[j]]))
- end
- elem[#elem+1]='/>'
- elem[#elem+1]="\n"
- xmlstream[#xmlstream+1] = table_concat(elem)
-end
-
-local function serialize_elem(t)
- if #t==1 then
- serialize_empty_elem(t)
- else
- local name=t[1]
- local elem={}
- elem[#elem+1]='<'
- elem[#elem+1]=name
- -- attributes
- local _t={}
- for k,v in pairs(t) do
- if not(type(k)=='number') then
- _t[#_t+1]=k
- end
- end
- table.sort(_t)
- for j=1,#_t do
- elem[#elem+1]=format([[ %s="%s"]],_t[j],toattr(t[_t[j]])) --
- end
- elem[#elem+1]='>'
- if type(t[2])~= 'string' then
- elem[#elem+1]="\n"
- end
- xmlstream[#xmlstream+1] = table_concat(elem)
- elem = {}
- for j=2,#t do
- if type(t[j])=='table' then
- serialize_elem(t[j])
- elseif type(t[j])=='string' then
- xmlstream[#xmlstream+1] = totext(t[j])
- end
- end
- elem[#elem+1]='</'
- elem[#elem+1]=name
- elem[#elem+1]='>'
- elem[#elem+1]="\n"
- xmlstream[#xmlstream+1] = table_concat(elem)
- end
-end
-
-
---------------------------------------------------------------------------------
---
--- First children of XML ttx, plus utilities
---------------------------------------------------------------------------------
-
-local ttFont
-local GlyphOrder
-local GlyphID
-local head
-local hhea
-local maxp
-local OS_2,panose -- handy to have
-local name
-local cmap
-local post
-local CFF, CFFFont, Private -- only a single CFFFont, for the moment
-local FFTM
-local GDEF
-local hmtx
-
--- For variable fonts
-local extranames -- handy to have
-local CFF2
-local HVAR,VarStore,VarRegionList,Regions,VarRegionAxis,VarData,AdvWidthMap
-local fvar
-
-
--- Important, child of CFFFont
-local CharStrings
-
-local function get_GlyphID(id,name)
- return new_element('GlyphID',{['id']=tostring(id),['name']=tostring(name)})
-end
-
-local function put_head(name,value)
- table_insert(head, new_element(name, {['value']=tostring(value)}))
-end
-
-local function put_hhea(name,value)
- table_insert(hhea, new_element(name, {['value']=tostring(value)}))
-end
-
-local function put_maxp(name,value)
- table_insert(maxp,new_element(name, {['value']=tostring(value)}))
-end
-
-local function put_OS_2(name,value)
- table_insert(OS_2,new_element(name, {['value']=tostring(value)}))
-end
--- handy
-local function put_panose(name,value)
- table_insert(panose,new_element(name, {['value']=tostring(value)}))
-end
-
-local function get_map(code,name)
- return new_element('map', {['code']=tostring(code),['name']=tostring(name)})
-end
-
-local function put_post(name,value)
- table_insert(post,new_element(name, {['value']=tostring(value)}))
-end
-
-local function put_CFF(name,value)
- table_insert(CFF,new_element(name, {['value']=tostring(value)}))
-end
-
-local function put_CFF2(name,value)
- table_insert(CFF2,new_element(name, {['value']=tostring(value)}))
-end
-
-
-local function put_CFFFont(name,value)
- table_insert(CFFFont,new_element(name, {['value']=tostring(value)}))
-end
-
-local function put_Private(name,value)
- table_insert(Private,new_element(name, {['value']=tostring(value)}))
-end
-
-local function put_FFTM(name,value)
- table_insert(FFTM,new_element(name, {['value']=tostring(value)}))
-end
-
-local function get_ClassDef(glyph,class)
- return new_element('ClassDef', {['glyph']=tostring(glyph),['class']=tostring(class)})
-end
-
-local function get_mtx(name,width,lsb)
- return new_element('mtx', {['name']=tostring(name),['width']=tostring(width),['lsb']=tostring(lsb)})
-end
-
---
--- convenient method for a cmap0
---
--- local function get_cmap0_maps(maps)
--- local t = {}
--- if not(#maps==256) then
--- warning(maps,"maps has not 256 values")
--- end
--- local s=(#maps>=256 and 256) or #maps
--- for j=1,s do
--- t[#t+1]=get_map(format("0x%x",j-1),maps[j])
--- end
--- return t
--- end
-
-local function get_raw_cmap0()
- local t = {}
- for j=0,255 do
- t[format("0x%02x",j)] = ".notdef"
- end
- return t
-end
-
-
-
-
---------------------------------------------------------------------------------
---
--- Create & save xml font
---------------------------------------------------------------------------------
-
-local function checkall(tfm)
- -- several checks & fixes here
- local gf_chars = {}
- if GF then
- for k,_ in pairs(GF.chars) do
- if type(k)=='number' then
- table_insert(gf_chars,k)
- end
- end
- table_sort(gf_chars)
- end
- --
- -- fix head
- if ttx.userdata.update_head and
- type(ttx.userdata.update_head)=='function' then
- ttx.userdata.update_head(tfm)
- elseif GF then
- remove_children(head,{'xMin', 'xMax','yMin','yMax','modified'})
- put_head('xMin',GF_chars.min_m);
- put_head('yMin',GF_chars.min_n);
- put_head('xMax',GF_chars.max_m-GF_chars.min_m+1);
- put_head('yMax',GF_chars.max_n-GF_chars.min_n+1);
- -- Date is UTC
- put_head('modified',os.date("!%c"));
- end
- --
- -- fix CFFFont, only one for the moment
- if ttx.userdata.update_CFFFont and
- type(ttx.userdata.update_CFFFont)=='function' then
- ttx.userdata.update_CFFFont(CFFont)
- elseif GF then
- remove_child(CFFFont,'FontBBox')
- put_CFFFont('FontBBox',
- format("%s %s %s %s",GF_chars.min_m,GF_chars.min_n,
- GF_chars.max_m-GF_chars.min_m+1,
- GF_chars.max_n-GF_chars.min_n+1))
- end
- --
- -- fix OS_2
- if ttx.userdata.update_OS_2 and
- type(ttx.userdata.update_OS_2)=='function' then
- ttx.userdata.update_CFFFont(OS_2)
- elseif mflua.chartable then
- local design_size=tonumber ( print_scaled(MFbuiltin.designsize()) ) --pt
- local emsize = ttx.emsize or 1000
- local avgx = 0
- local avgx_cnt=0
- for k,v in pairs(mflua.chartable) do
- if tonumber(v.char_wd) > 0 then
- avgx = tonumber(v.char_wd)*emsize/design_size+avgx
- avgx_cnt=avgx_cnt+1
- end
- end
- avgx = math_floor(avgx/avgx_cnt+0.5)
- remove_child(OS_2,'xAvgCharWidth')
- put_OS_2('xAvgCharWidth',avgx)
- end
- -- fix cmap0
- -- local t = {}
- -- for k,_ in pairs(scrt.cmap.rawcmap0) do t[#t+1]=k end
- -- table.sort(t)
- -- for k=1,256 do
- -- insert_child(scrt.cmap.cmap0, get_map(t[k],scrt.cmap.rawcmap0[t[k]]))
- -- end
-
-end
-
-local function savettxfont(t)
- serialize_xml_header([[version="1.0" encoding="UTF-8"]])
- serialize_elem(t)
- return table_concat(xmlstream)
-
-end
-
-local function makefont(tfm)
- --
- checkall(tfm)
- serialize_xml_header([[version="1.0" encoding="UTF-8"]])
- serialize_elem(ttFont)
- return table_concat(xmlstream)
-end
-
-
-
-
---------------------------------------------------------------------------------
---
--- mflua layer
---------------------------------------------------------------------------------
-
-local function _eval_tonumber(q,offset)
- local qx,qy,xo,yo
- local w
- local _offset = offset
- if _offset == nil then _offset = '(0,0)' end
- w=string.gmatch(q,"[-0-9.]+"); qx,qy=w(),w()
- w=string.gmatch(_offset,"[-0-9.]+"); xo,yo=w(),w()
- return {tonumber(qx+xo),tonumber(qy+yo)}
-end
-
-local function setup(tfm,index,chartable)
- -- Default emsize is 1000 for CFF and CFF2
- ttx.emsize = ttx.emsize or 1000
-
- scrt.font_space = tfm.printfloat(ttx.emsize*(tfm.font.space),3)
-
- ttFont = new_element('ttFont', {['sfntVersion']="OTTO", ['ttLibVersion']="3.1"})
- GlyphOrder = new_element('GlyphOrder')
- GlyphID = new_element('GlyphID', {['id']="0", ['name']=".notdef"})
- head = new_element('head')
- hhea = new_element('hhea')
- maxp = new_element('maxp')
- OS_2 = new_element('OS_2')
- name = new_element('name')
- cmap = new_element('cmap')
- post = new_element('post')
- if ttx.cffver==1 then
- CFF = new_element('CFF')
- CFF2 = nil
- elseif ttx.cffver==2 then
- CFF2 = new_element('CFF2')
- CFF = nil
- end
- -- FFTM = new_element('FFTM') --FontForge TimeStamp table
- GDEF = new_element('GDEF')
- if ttx.cffver==2 then
- HVAR = new_element('HVAR')
- end
- hmtx = new_element('hmtx')
-
- -- handy
- panose = new_element('panose')
- if ttx.cffver==1 then
- CFFFont = new_element('CFFFont',{['name']= (ttx.userdata.CFFFont['FullName'] or "mfluatestfont"..tostring(math.random(0,1000000)))})
- elseif ttx.cffver==2 then
- CFFFont = new_element('CFFFont',{['name']="CFF2Font"})
- end
- Private = new_element('Private')
-
- CharStrings= new_element('CharStrings')
-
- table_insert(ttFont,GlyphOrder)
- table_insert(ttFont,head)
- table_insert(ttFont,hhea)
- table_insert(ttFont,maxp)
- table_insert(ttFont,OS_2)
- table_insert(ttFont,name)
- table_insert(ttFont,cmap)
- table_insert(ttFont,post)
- if ttx.cffver==1 then
- table_insert(ttFont,CFF)
- elseif ttx.cffver==2 then
- table_insert(ttFont,CFF2)
- end
- -- table_insert(ttFont,FFTM)
- table_insert(ttFont,GDEF)
-
- if ttx.cffver==2 then
- table_insert(ttFont,HVAR)
- insert_child(HVAR,{'Version', ['value']="0x00010000"})
- VarStore = new_element('VarStore',{['Format']="1"})
- insert_child(VarStore,{'Format',['value']="1"})
- VarRegionList = new_element('VarRegionList')
- -- For the moment, 1 axis and 1 region
- Regions = {new_element('Region',{['index']="0"})}
- VarRegionAxis = new_element('VarRegionAxis',{['index']="0"})
- insert_child(VarRegionAxis,new_element('StartCoord',{['value']="-1.0"}))
- insert_child(VarRegionAxis,new_element('PeakCoord',{['value']="-1.0"}))
- insert_child(VarRegionAxis,new_element('EndCoord',{['value']="0.0"}))
- -- insert_child(VarRegionAxis,new_element('StartCoord',{['value']="0.0"}))
- -- insert_child(VarRegionAxis,new_element('PeakCoord',{['value']="1.0"}))
- -- insert_child(VarRegionAxis,new_element('EndCoord',{['value']="1.0"}))
- insert_child(Regions[1],VarRegionAxis)
- insert_children(VarRegionList,Regions)
- insert_child(VarStore,VarRegionList)
- VarData = new_element('VarData',{['index']="0"})
- insert_child(VarData,new_element('NumShorts',{['value']="1"}))
- insert_child(VarData,new_element('VarRegionIndex',{['value']="0"}))
- insert_child(VarData,new_element('Item',{['index']="0", ['value']="[-125]"}))
- insert_child(VarStore,VarData)
- AdvWidthMap = new_element('AdvWidthMap')
- insert_child(AdvWidthMap,new_element('Map', {['index']="0", ['outer']="0", ['inner']="0"}))
- insert_child(HVAR,VarStore)
- --insert_child(HVAR,AdvWidthMap)
- end
-
- table_insert(ttFont,hmtx)
-
- table_insert(GlyphOrder,GlyphID)
-
- if ttx.userdata.head then
- for k,v in pairs(ttx.userdata.head) do
- put_head(k,v)
- end
- end
-
- if ttx.userdata.hhea then
- for k,v in pairs(ttx.userdata.hhea) do
- put_hhea(k,v)
- end
- end
-
- if ttx.userdata.maxp then
- for k,v in pairs(ttx.userdata.maxp) do
- put_maxp(k,v)
- end
- end
-
- if ttx.userdata.OS_2 then
- for k,v in pairs(ttx.userdata.OS_2) do
- put_OS_2(k,v)
- end
- end
-
- if ttx.userdata.panose then
- for k,v in pairs(ttx.userdata.panose) do
- put_panose(k,v)
- end
- end
- insert_child(OS_2,panose)
-
- if ttx.userdata.namerecord then
- local _e
- local t
- for i=1,#ttx.userdata.namerecord do
- t = ttx.userdata.namerecord[i]
- _e = new_element('namerecord',{['nameID']=t.nameID,['platformID']=t.platformID,
- ['platEncID']=t.platEncID, ['langID']=t.langID, ['unicode']=t.unicode})
- insert_child(_e,t.value); insert_child(name,_e)
- end
- end
-
-
- local cmap0,cmap4_0,cmap4_3
- cmap4_0 = new_element('cmap_format_4', {['platformID']="0",['platEncID']="3",['language']="0",})
- --cmap0 = new_element('cmap_format_0', {['platformID']="1",['platEncID']="0",['language']="0",})
- cmap4_3 = new_element('cmap_format_4', {['platformID']="3",['platEncID']="1",['language']="0",})
-
-
- insert_child(cmap4_0,get_map("0x0",".notdef"))
- insert_child(cmap4_3,get_map("0x0",".notdef"))
-
- scrt.cmap = scrt.cmap or {}
- scrt.cmap.cmap4_0 = cmap4_0
- scrt.cmap.cmap4_3 = cmap4_3
- --scrt.cmap.cmap0 = cmap0
- --scrt.cmap.rawcmap0 = get_raw_cmap0()
-
-
- insert_child(cmap,{'tableVersion', ['version']="0"})
- insert_child(cmap,cmap4_0)
- --insert_child(cmap,cmap0)
- insert_child(cmap,cmap4_3)
-
-
- if ttx.userdata.post then
- for k,v in pairs(ttx.userdata.post) do
- put_post(k,v)
- end
- end
- if ttx.cffver==2 then
- insert_child(post,{'psNames'})
- extranames = new_element('extraNames')
- insert_child(post,extranames)
- end
-
- if ttx.cffver==1 then
- put_CFF('major',"1")
- put_CFF('minor',"0")
- insert_child(CFF,CFFFont)
- elseif ttx.cffver==2 then
- put_CFF2('major',"2")
- put_CFF2('minor',"0")
- insert_child(CFF2,CFFFont)
- end
-
- if ttx.cffver==1 then
- if ttx.userdata.CFFFont then
- for k,v in pairs(mflua.ttx.userdata.CFFFont) do
- put_CFFFont(k,v)
- end
- end
-
- insert_child(CFFFont,{'Encoding', ['name']=mflua.ttx.userdata.CFFFont.Encoding})
-
- insert_child(CFFFont,Private)
- if ttx.userdata.CFFFont.Private then
- for k,v in pairs(ttx.userdata.CFFFont.Private) do
- put_Private(k,v)
- end
- end
-
- local subrs = new_element('Subrs')
- scrt.subrs = subrs
- if ttx.userdata.CFFFont.Private.Subrs then
- for k,v in pairs(ttx.userdata.CFFFont.Private.Subrs) do
- insert_child(subrs,{'CharString', ['index']=k, v})
- end
- end
- insert_child(Private,subrs)
-
- elseif ttx.cffver==2 then
- insert_child(CFFFont,{'FontMatrix', ['value']=mflua.ttx.userdata.CFF2Font['FontMatrix']})
- local FDArray = new_element('FDArray')
- local FontDict = new_element('FontDict', {['index']="0"})
- insert_child(FontDict,{'FontMatrix', ['value']=mflua.ttx.userdata.CFF2Font['FontMatrix']})
- insert_child(FontDict,{'Private'})
- insert_child(FDArray,FontDict)
- insert_child(CFFFont,FDArray)
- end
-
- -- .notdef char
- local notdef = new_element('CharString', {['name']=".notdef"})
- if ttx.cffver == 1 then
- insert_child(notdef,"endchar\n")
- elseif ttx.cffver == 2 then
- insert_child(notdef,"0 0 0 0 0 0 rrcurveto \n")
- end
-
- insert_child_at_beginning(CharStrings, notdef)
-
- insert_child(CFFFont,CharStrings)
-
- if CFF2 and mflua.ttx.userdata.varstore then
- insert_child(CFFFont,mflua.ttx.userdata.varstore)
- end
-
-
- --
- -- TODO: check GlobalSubrs!!
- --
- local globsubrs = new_element('GlobalSubrs')
- if ttx.cffver==1 then
- insert_child(CFF,globsubrs)
- elseif ttx.cffver==2 then
- insert_child(CFF2,globsubrs)
- end
- if ttx.userdata.CFF.GlobalSubrs then
- for k,v in pairs(ttx.userdata.CFF.GlobalSubrs) do
- insert_child(globsubrs,{'CharString', ['index']=k, v})
- end
- end
-
- local glyphclassdef = new_element('GlyphClassDef',{['Format']="2"})
- insert_child(GDEF,{'Version',['value']="0x00010000"})
- insert_child(GDEF,glyphclassdef)
- scrt.gdef = scrt.gdef or {}
- scrt.gdef.glyphclassdef = glyphclassdef
-
- local LigCaretList = new_element('LigCaretList')
- insert_child(LigCaretList,new_element('Coverage',{['Format']="2"}))
- insert_child(GDEF,LigCaretList)
-
-
- insert_child(hmtx, get_mtx('.notdef',
- ttx.userdata.char_notdef['width'],
- ttx.userdata.char_notdef['lsb']))
-
- if CFF2 and ttx.userdata.fvar then
- local fvar = new_element('fvar')
- local v, axis, _e
- for i=1,#ttx.userdata.fvar.Axis do
- v = ttx.userdata.fvar.Axis[i]
- axis = new_element('Axis')
- _e = new_element('AxisTag'); _e[2] = v['AxisTag']; insert_child(axis,_e)
- _e = new_element('MinValue'); _e[2] = v['MinValue']; insert_child(axis,_e)
- _e = new_element('DefaultValue'); _e[2] = v['DefaultValue']; insert_child(axis,_e)
- _e = new_element('MaxValue'); _e[2] = v['MaxValue']; insert_child(axis,_e)
- _e = new_element('AxisNameID'); _e[2] = v['AxisNameID']; insert_child(axis,_e)
- end
- insert_child(fvar,axis)
- insert_child(ttFont,fvar)
- end
-
-end
-
-
-local function reverse(cycle)
- local t={}
- local curve
- local p,c1,c2,q
- for i=#cycle,1,-1 do
- curve=cycle[i]
- p,c1,c2,q=curve[1],curve[2],curve[3],curve[4]
- curve[1],curve[2],curve[3],curve[4]=q,c2,c1,p
- t[#t+1]=curve
- end
- return t
-end
-
-
-local function sort(cycle)
- local t={}
- local curve
- local p,q, index
- local xmin,ymin = 4096,4096
- index = 1
- for i=1,#cycle do
- curve=cycle[i]
- p=curve[1];
- t = _eval_tonumber(p)
- -- Align to leftmost x and y
- --if t[1]<=xmin and t[2]<=ymin then index = i;xmin,ymin=t[1],t[2] end
- -- Align to the leftmost x
- if t[1]<=xmin then index = i;xmin,ymin=t[1],t[2] end
- end
- t={}
- for i=index,#cycle do t[#t+1]=cycle[i] end
- for i=1,index-1 do t[#t+1]=cycle[i] end
- for i=1,#t do
- curve=t[i]
- p,c1,c2,q=curve[1],curve[2],curve[3],curve[4]
- end
- return t
-end
-
-
-local function _reverse(cycle)
- local cv1, cv2
- local p,c1,c2,q
- local l=#cycle
- for i=1,l/2 do
- cv1=cycle[i]
- cv2=cycle[l+1-i]
- p,c1,c2,q = cv1[1],cv1[2],cv1[3],cv1[4]
- cv1[1],cv1[2],cv1[3],cv1[4] = q,c2,c1,p
- p,c1,c2,q = cv2[1],cv2[2],cv2[3],cv2[4]
- cv2[1],cv2[2],cv2[3],cv2[4] = q,c2,c1,p
- cycle[l+1-i]=cv1
- cycle[i]=cv2
- end
-end
-
-
--- local function updateminmax(p,c1,c2,q)
--- ttx = ttx or {}
--- ttx.userdata = ttx.userdata or {}
--- ttx.userdata.head = ttx.userdata.head or {}
--- local t;
--- -- hm not ok, too raw
--- -- we need at least 3 bisections
--- t = {p[1],c1[1],c2[1],q[1]}
--- table_sort(t)
--- ttx.userdata.head['xMin']= math_floor(t[1])
--- ttx.userdata.head['xMax']= math_floor(t[4])
--- t = {p[2],c1[2],c2[2],q[2]}
--- table_sort(t)
--- ttx.userdata.head['yMin']= math_floor(t[1])
--- ttx.userdata.head['yMax']= math_floor(t[4])
--- end
-
-
-local function update_char_lsb(glyph_name,char_wd_emunit,index)
- local err = true
- if ttx.userdata.update_char_lsb and
- type(ttx.userdata.update_char_lsb)=='function' then
- ttx.userdata.update_char_lsb(glyph_name,char_wd_emunit,index)
- return
- end
- if GF_chars[index] then
- insert_child(hmtx, get_mtx(glyph_name,
- char_wd_emunit,GF_chars[index].min_m))
- return
- end
- if err then print_err("update_char_lsb failed") end
-end
-
-
-
-
-
-local function isvhline(py,c1y,c2y,qy)
- if (py==c1y) and (c1y==c2y) and (c2y==qy) then
- return true
- end
- --local abs = math.abs
- local eps = ttx.eps or 0.01
- local d1,d2,d3,d4 = abs(py-c1y), abs(c1y-c2y), abs(c2y-qy),abs(py-qy)
- if d1<eps and d2<eps and d3<eps and d4<eps then
- return true
- end
- return false
-end
-
-
-local function isline(px,py,c1x,c1y,c2x,c2y,qx,qy)
- local px,py,c1x,c1y,c2x,c2y,qx,qy = 0,0,c1x-px,c1y-py,c2x-px,c2y-py,qx-px,qy-py
- local eps = ttx.deps or 0.01
- local atan2,abs = math.atan2, math.abs
- a = atan2(qy,qx)
- a1 = atan2(c1y,c1x)
- a2 = atan2(c2y,c2x)
- if abs(a-a1)<eps and abs(a-a2)<eps and abs(a1-a2)<eps then
- return true
- end
- return false
-end
-
-
-local function insert_stem(index,stem_type)
- if mflua and mflua.userdata and mflua.userdata.char and mflua.userdata.char[index] and mflua.userdata.char[index][stem_type] then
- -- stem[i]={base, delta}
- local stem = mflua.userdata.char[index][stem_type]
- local content = {}
- for i=1,#stem do
- --table_insert(content, format("%s %s", normalize(stem[i][1]),normalize(stem[i][2])))
- table_insert(content, format("%s %s",stem[i][1],stem[i][2]))
- end
- table_insert(content,stem_type)
- return table_concat(content, " ")
- end
- return nil
-end
-
-
-
-local function make_glyph(valid_curves,char,cycles,tfm)
- -- Write the ttx
-
- if #cycles == 0 and #valid_curves==0 then
- print("no outlines ")
- --return
- end
- local tfm = tfm
- local mflua_index = tointeger( char['index'] ) -- better a string or a number
- local index = mflua_index
- if mflua.ttx.userdata.charindex and mflua.ttx.userdata.charindex[index] then
- index = mflua.ttx.userdata.charindex[index]
- end
- local design_size=tonumber ( print_scaled(MFbuiltin.designsize()) ) --pt
- local char_wd=tonumber( char['char_wd'] ) -- pt
- local char_ht=tonumber( char['char_ht'] ) -- pt
- local char_dp=tonumber( char['char_dp'] ) -- pt
-
- local cmap4_0 = scrt.cmap.cmap4_0
- local cmap4_3 = scrt.cmap.cmap4_3
- --local rawcmap0 = scrt.cmap.rawcmap0
-
- local glyphclassdef = scrt.gdef.glyphclassdef
-
-
- local x_resolution = math_floor(0.5+tonumber( print_scaled(MFbuiltin.hppp()) )* 72.27)
- local y_resolution = math_floor(0.5+tonumber( print_scaled(MFbuiltin.vppp()) )* 72.27)
- assert(x_resolution==y_resolution, format('Error on _make_glyph x_res=%d and y_res=%d differ',x_resolution,y_resolution))
-
- local resolution = x_resolution
- local emsize = ttx.emsize -- 1000, type 1, also known as em_unit: 1000 emsize = 1em
- local em_unit = emsize
- local em_unit_for_pixel = (72.27/design_size) * (emsize / resolution)
- local bp_for_pt = 72/72.27
- local char_wd_emunit = tonumber(format("%0.0f", (char_wd/design_size) *em_unit))
- local char_ht_emunit = tonumber(format("%0.0f", (char_ht/design_size) *em_unit))
- local char_dp_emunit = tonumber(format("%0.0f", (char_dp/design_size) *em_unit))
- local glyph_name = tostring(char['charname'])
-
- if glyph_name and glyph_name ~= '' and not(index==0) then
- table_insert(GlyphOrder,get_GlyphID(index,glyph_name))
- end
-
- local content = {}
- table_insert(content," ")
- if CFF2 and (abs(char_wd_emunit-scrt.font_space)>1e-4) then
- table_insert(content,format("%0.3f w",char_wd_emunit-scrt.font_space))
- end
-
-
- table_insert(content,insert_stem(mflua_index,"hstem"))
- table_insert(content,insert_stem(mflua_index,"vstem"))
- --table_insert(content,"mask ?") -- TODO
-
- local origin = {0,0}
- for i,_cycle in pairs(cycles) do
- local cycle
- local p,c1,c2,q,offset
- --cycle = reverse(_cycle)
- cycle = _cycle
- -- do we need a sort ?
- --cycle = sort(cycle)
- for i1,curve in ipairs(cycle) do
- p,c1,c2,q,offset=curve[1],curve[2],curve[3],curve[4],curve[5]
- p =_eval_tonumber(p ,offset)
- c1=_eval_tonumber(c1,offset)
- c2=_eval_tonumber(c2,offset)
- q =_eval_tonumber(q ,offset)
- -- em_unit_for_pixel
- p[1],p[2] = p[1] *em_unit_for_pixel, p[2]*em_unit_for_pixel
- q[1],q[2] = q[1] *em_unit_for_pixel, q[2]*em_unit_for_pixel
- c1[1],c1[2] = c1[1]*em_unit_for_pixel, c1[2]*em_unit_for_pixel
- c2[1],c2[2] = c2[1]*em_unit_for_pixel, c2[2]*em_unit_for_pixel
-
-
- p[1],p[2] = toscaled(p[1]), toscaled(p[2])
- q[1],q[2] = toscaled(q[1]), toscaled(q[2])
- c1[1],c1[2] = toscaled(c1[1]), toscaled(c1[2])
- c2[1],c2[2] = toscaled(c2[1]), toscaled(c2[2])
-
-
- if CFF then
- -- print(format("p1 %s path=(%0.14f,%0.14f) (%0.14f,%0.14f) (%0.14f,%0.14f) (%0.14f,%0.14f)", index,
- -- p[1], p[2],
- -- c1[1], c1[2],
- -- c2[1], c2[2],
- -- q[1],q[2]))
- -- print(format("p2 %s path=(%0.4f,%0.4f) (%0.4f,%0.4f) (%0.4f,%0.4f) (%0.4f,%0.4f)", index,
- -- p[1], p[2],
- -- c1[1], c1[2],
- -- c2[1], c2[2],
- -- q[1],q[2]))
- -- print(format("p3 %s path=(%s,%s) (%s,%s) (%s,%s) (%s,%s)", index,
- -- normalize(p[1]), normalize(p[2]),
- -- normalize(c1[1]), normalize(c1[2]),
- -- normalize(c2[1]), normalize(c2[2]),
- -- normalize(q[1]), normalize(q[2])))
-
- if i1==1 then
- --print(format("m %s %s %s rmoveto",index, normalize(p[1]-origin[1]),normalize(p[2]-origin[2])))
- table_insert(content,format("%s %s rmoveto",normalize(p[1]-origin[1]),normalize(p[2]-origin[2])))
- origin = {p[1],p[2]}
- end
- if isvhline(p[2],c1[2],c2[2], q[2]) then -- check horizontal line
- --print(format("h %s %s hlineto", index, normalize(q[1]-p[1])))
- table_insert(content,format("%s hlineto", normalize(q[1]-p[1])))
- elseif isvhline(p[1],c1[1],c2[1], q[1]) then -- check vertical line
- --print(format("v %s %s vlineto", index,normalize(q[2]-p[2])))
- table_insert(content,format("%s vlineto", normalize(q[2]-p[2])))
- elseif isline(p[1],p[2],c1[1],c1[2],c2[1],c2[2],q[1],q[2]) then -- check a line
- --print(format("r %s %s %s rlineto", index, normalize(q[1]-p[1]), normalize(q[2]-p[2])))
- table_insert(content,format("%s %s rlineto", normalize(q[1]-p[1]), normalize(q[2]-p[2])))
- else
- local prec = 3;
- -- p[1] = normalize_and_simplify(p[1],prec);p[2] = normalize_and_simplify(p[2],prec);
- -- c1[1] = normalize_and_simplify(c1[1],prec);c1[2] = normalize_and_simplify(c1[2],prec);
- -- c2[1] = normalize_and_simplify(c2[1],prec);c2[2] = normalize_and_simplify(c2[2],prec);
- -- q[1] = normalize_and_simplify(q[1],prec);q[2] = normalize_and_simplify(q[2],prec);
-
-
- table_insert(content,(format("%s %s %s %s %s %s rrcurveto",
- normalize_and_simplify(c1[1] -p[1],prec), normalize_and_simplify(c1[2]-p[2],prec),
- normalize_and_simplify(c2[1]-c1[1],prec), normalize_and_simplify(c2[2]-c1[2],prec),
- normalize_and_simplify(q[1] -c2[1],prec), normalize_and_simplify(q[2]-c2[2],prec))))
-
- end
-
- elseif CFF2 then --
- -- reverse the key, because we reverse the cycle
- local kp = table.concat({curve[4],curve[3],curve[2],curve[1]})
- local deltas_width = {{0,0},{0,0}, {0,0},{0,0}, {0,0},{0,0}, {0,0},{0,0}}
- local origin_deltas_width = {0,0}
- local a, b, c, d, da, Da, db, Db, dc, Dc, dd, Dd
- if mflua.userdata.deltas_width[glyph_name] then
- deltas_width = mflua.userdata.deltas_width[glyph_name][kp]
- -- Original from MF, we have to reverse it; d..c..b..a is the key,
- -- da and Da are the delta min and delta max,
- -- where delta is (variated_instance - reference_instance)
- -- delta are not affected by offset, but scaling are cannot be discarded
- a, b, c, d, da, Da, db, Db, dc, Dc, dd, Dd = table.unpack(deltas_width)
- deltas_width = {dd, Dd,dc, Dc,db, Db,da, Da}
- for _,v in ipairs(deltas_width) do
- v[1],v[2]=v[1]*em_unit_for_pixel, v[2]*em_unit_for_pixel
- end
- end
- da, Da, db, Db, dc, Dc, dd, Dd = table.unpack(deltas_width)
- -- One axis only, width
- -- Condensed Regular (still not Extended)
- local blend
- if i1==1 then
- blend = format("%0.2f %0.2f 2 blend",da[1]-origin_deltas_width[1],da[2]-origin_deltas_width[2]) ;
- table_insert(content,format("%0.0f %0.0f %s rmoveto",p[1]-origin[1],p[2]-origin[2],blend))
- origin = {p[1],p[2]}
- origin_deltas_width ={da[1],da[2]}
- end
- blend = format("%0.2f %0.2f %0.2f %0.2f %0.2f %0.2f 6 blend",
- db[1]-da[1],db[2]-da[2],
- dc[1]-db[1],dc[2]-db[2],
- dd[1]-dc[1],dd[2]-dc[2])
-
- table_insert(content,format("%0.0f %0.0f %0.0f %0.0f %0.0f %0.0f %s rrcurveto",
- c1[1] -p[1], c1[2]-p[2],
- c2[1]-c1[1], c2[2]-c1[2],
- q[1] -c2[1], q[2]-c2[2],blend))
-
-
-
- -- if i1==1 then
- -- blend = '0 0 2 blend' ;
- -- table_insert(content,format("%0.0f %0.0f %s rmoveto",p[1]-origin[1],p[2]-origin[2],blend))
- -- origin = {p[1],p[2]}
- -- end
- -- --table_insert(content,format("%0.2f %0.2f %0.2f %0.2f %0.2f %0.2f rrcurveto",
- -- if i1==1 then blend = '0 0 0 0 0 0 6 blend' ; else blend = '0 0 0 0 -10 0 6 blend' end
- -- table_insert(content,format("%0.0f %0.0f %0.0f %0.0f %0.0f %0.0f %s rrcurveto",
- -- c1[1] -p[1], c1[2]-p[2],
- -- c2[1]-c1[1], c2[2]-c1[2],
- -- q[1] -c2[1], q[2]-c2[2],blend))
- end
- end
- end
- if ttx.cffver == 1 then
- table_insert(content,"endchar\n")
- elseif ttx.cffver == 2 then
- table_insert(content,"")
- end
- local CharString = new_element('CharString', {['name']=glyph_name})
- insert_child(CharString,table_concat(content,"\n"))
-
- insert_child(CharStrings,CharString)
- insert_child(cmap4_0,get_map(format("0x%x",index),glyph_name))
- --rawcmap0[format("0x%x",1+index%256)] = glyph_name
- insert_child(cmap4_3,get_map(format("0x%x",index),glyph_name))
-
- insert_child(glyphclassdef, get_ClassDef(glyph_name,"1"))
- update_char_lsb(glyph_name,char_wd_emunit,mflua_index)
-
-
- if ttx.cffver==2 then
- local psName = new_element('psName', {['name']=glyph_name})
- local Item = new_element('Item', {['index']=format("%d",index), ['value']="[-125]"})
- local Map = new_element('Map', {['index']=format("%d",index), ['outer']="0", ['inner']="0"})
- local VarStore = get_children(HVAR,{'VarStore'})
- local VarData = get_children(VarStore[1],{'VarData'})
- --local AdvWidthMap = get_children(HVAR,{'AdvWidthMap'})
- insert_child(VarData[1],Item)
- --insert_child(AdvWidthMap[1],Map)
- insert_child(extranames,psName)
-
- end
-
-end -- make_glyph
-
-
-
-
-
-ttx.make_glyph = make_glyph
-ttx.makefont = makefont
-ttx.setup = setup
-ttx.userdata = {}
-ttx.cffver = 1
-ttx.eps = 0.01
-ttx.deps = 0.01
-return ttx
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs b/Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs
deleted file mode 100644
index 6dcf5fcb85a..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs
+++ /dev/null
@@ -1,285 +0,0 @@
-#! /bin/sh -vx
-# Copyright 2017 Karl Berry <tex-live@tug.org>
-# Copyright 2015 Peter Breitenlohner <tex-live@tug.org>
-# You may freely use, modify and/or distribute this file.
-
-testdir=$abs_srcdir/triptrap
-+ testdir=SRCDIR/triptrap
-ltestdir=$abs_srcdir/mfluadir/mfluatrap
-+ ltestdir=SRCDIR/mfluadir/mfluatrap
-
-TEXMFCNF=$ltestdir
-+ TEXMFCNF=SRCDIR/mfluadir/mfluatrap
-LUAINPUTS=$ltestdir
-+ LUAINPUTS=SRCDIR/mfluadir/mfluatrap
-export TEXMFCNF LUAINPUTS
-+ export TEXMFCNF LUAINPUTS
-
-rm -rf mfluatrapdir
-+ rm -rf mfluatrapdir
-mkdir mfluatrapdir
-+ mkdir mfluatrapdir
-cd mfluatrapdir
-+ cd mfluatrapdir
-
-echo ">>> Running TRAP test for MFLua." >&2
-+ echo '>>> Running TRAP test for MFLua.'
->>> Running TRAP test for MFLua.
-echo ">>> See $ltestdir/mfluatrap.diffs for example of acceptable diffs." >&2
-+ echo '>>> See SRCDIR/mfluadir/mfluatrap/mfluatrap.diffs for example of acceptable diffs.'
->>> See SRCDIR/mfluadir/mfluatrap/mfluatrap.diffs for example of acceptable diffs.
-
-is_OK=:
-+ is_OK=:
-
-set -x
-+ set -x
-
-# get same filename in log
-$LN_S $testdir/trap.mf .
-+ ln -s SRCDIR/triptrap/trap.mf .
-
-./mflua --progname=inimflua <$testdir/mftrap1.in >mftrapin.fot
-+ ./mflua --progname=inimflua
-if test ! -s trap.base; then
- echo "*** trap.base not created by mftrap1.in, investigate!" >&2
- exit 1
-fi
-+ test '!' -s trap.base
-mv trap.log mftrapin.log || exit 1
-+ mv trap.log mftrapin.log
-diff $testdir/mftrapin.log mftrapin.log
-+ diff SRCDIR/triptrap/mftrapin.log mftrapin.log
-1c1
-< This is METAFONT, Version 2.71828182 (INIMF) 4 JUL 1776 12:00
----
-> This is MFLua, Version 2.71828182-1.0.0-alpha (INIMF) 27 JAN 2021 18:03
-150c150
-< String usage 26&83 (892&11481 still untouched)
----
-> String usage 30&98 (1047458&9979376 still untouched)
-176,177c176,177
-< (preloaded base=trap 1776.7.4)
-< 1116 strings of total length 20570
----
-> (preloaded base=trap 2021.1.27)
-> 1125 strings of total length 20685
-179c179
-< 265 symbolic tokens
----
-> 266 symbolic tokens
-
-./mflua --progname=inimflua <$testdir/mftrap2.in >mftrap.fot
-+ ./mflua --progname=inimflua
-mv trap.log mftrap.log || exit 1
-+ mv trap.log mftrap.log
-mv trap.tfm mftrap.tfm || exit 1
-+ mv trap.tfm mftrap.tfm
-diff $testdir/mftrap.fot mftrap.fot
-+ diff SRCDIR/triptrap/mftrap.fot mftrap.fot
-1,3c1,4
-< This is METAFONT, Version 2.71828182 (INIMF)
-< ** &trap trap
-< (trap.mf
----
-> MFLua version: 1.0.0-alpha
-> MFLua banner: This is MFLua, Version 2.71828182-1.0.0-alpha
-> This is MFLua, Version 2.71828182-1.0.0-alpha (TeX Live 2021/dev) (INIMF)
-> **(trap.mf
-22a24,99
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
-27a105,136
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-> Warning: print_scale called with nil argument.
->
-39c148
-< String usage 41&161 (816&7678 still untouched)
----
-> String usage 50&202 (1047372&9975522 still untouched)
-59a169
-> Warning: end_program.lua not found
-diff $testdir/mftrap.log mftrap.log
-+ diff SRCDIR/triptrap/mftrap.log mftrap.log
-1c1
-< This is METAFONT, Version 2.71828182 (preloaded base=trap 1776.7.4) 4 JUL 1776 12:00
----
-> This is MFLua, Version 2.71828182-1.0.0-alpha (preloaded base=trap 2021.1.27) 27 JAN 2021 18:03
-133,134c133,134
-< <scantokens> pair
-< p[],';^^ff
----
-> <scantokens> or <runscript> pair
-> p[],';^^ff
-145,146c145,146
-< <scantokens> pair
-< p[],';^^ff
----
-> <scantokens> or <runscript> pair
-> p[],';^^ff
-158,159c158,159
-< <scantokens> pair
-< p[],';^^ff
----
-> <scantokens> or <runscript> pair
-> p[],';^^ff
-169,170c169,170
-< <scantokens> pair p[],';^^ff
-<
----
-> <scantokens> or <runscript> ...f
->
-1825c1825
-< String usage 24&92 (859&11353 still untouched)
----
-> String usage 30&119 (1047418&9979190 still untouched)
-4235c4235
-< String usage 41&161 (816&7678 still untouched)
----
-> String usage 50&202 (1047372&9975522 still untouched)
-4251,4252c4251,4252
-< 68 strings out of 884
-< 3752 string characters out of 11430
----
-> 77 strings out of 1047449
-> 3793 string characters out of 9979315
-4254,4255c4254,4255
-< 289 symbolic tokens out of 2100
-< 8i,43n,14r,8p,167b stack positions out of 30i,100n,300r,150p,500b
----
-> 290 symbolic tokens out of 9500
-> 8i,43n,14r,8p,167b stack positions out of 300i,300n,1000r,150p,3000b
-4263c4263
-< out of 256w,16h,16d,64i,5000l,500k,256e,50p)
----
-> out of 256w,16h,16d,64i,15000l,2500k,256e,60p)
-
-./tftopl ./mftrap.tfm mftrap.pl || exit 1
-+ ./tftopl ./mftrap.tfm mftrap.pl
-diff $testdir/mftrap.pl mftrap.pl || is_OK=false
-+ diff SRCDIR/triptrap/mftrap.pl mftrap.pl
-
-./gftype -m -i ./trap.72270gf >trap.typ || exit 1
-+ ./gftype -m -i ./trap.72270gf
-diff $testdir/trap.typ trap.typ
-+ diff SRCDIR/triptrap/trap.typ trap.typ
-1c1
-< This is GFtype, Version 3.1
----
-> This is GFtype, Version 3.1 (TeX Live 2021/dev)
-3c3
-< ' METAFONT output 2014.01.07:1811'
----
-> ' METAFONT output 2021.01.27:1803'
-
-$is_OK || {
- echo ">>> There were some errors." >&2
- exit 1
-}
-+ :
-
-PASS mfluadir/mfluatraptest.test (exit status: 0)
-PASS: mfluadir/mfluatraptest.test
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf b/Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf
deleted file mode 100644
index 04165594719..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf
+++ /dev/null
@@ -1,38 +0,0 @@
-% mfluadir/mfluatrap/texmf.cnf -- configuration for the MFLua and MFLuaJIT trap tests.
-
-% These values apply to all the programs, and they are necessary for any
-% kind of reasonable diff.
-error_line = 64
-half_error_line = 32
-max_print_line = 72
-
-% Metafont
-main_memory = 3001
-
-% Actually, Metafont currently ignores the settings for max_strings,
-% string_vacancies and pool_size specified here, but it doesn't hurt
-% to supply the correct values, just in case this changes one day.
-
-max_strings = 2000
-string_vacancies = 8000
-pool_size = 40000
-
-gf_buf_size = 8 % trapman.tex says to use this.
-MFTERM = trap % get the right screen output
-screen_width = 100
-screen_depth = 200
-
-% Search paths.
-% trap.mf:
-MFINPUTS = .
-% trip.tfm, trap.tfm, trapf.tfm:
-TFMFONTS = .
-% trap.base:
-MFBASES = .
-% mf.pool:
-MFPOOL = .
-
-% GFtype only.
-line_length.gftype = 79
-max_rows.gftype = 79
-max_cols.gftype = 79
diff --git a/Build/source/texk/web2c/mfluadir/mfluatraptest.test b/Build/source/texk/web2c/mfluadir/mfluatraptest.test
deleted file mode 100755
index c1c6ca3259a..00000000000
--- a/Build/source/texk/web2c/mfluadir/mfluatraptest.test
+++ /dev/null
@@ -1,51 +0,0 @@
-#! /bin/sh -vx
-# Copyright 2017 Karl Berry <tex-live@tug.org>
-# Copyright 2015 Peter Breitenlohner <tex-live@tug.org>
-# You may freely use, modify and/or distribute this file.
-
-testdir=$abs_srcdir/triptrap
-ltestdir=$abs_srcdir/mfluadir/mfluatrap
-
-TEXMFCNF=$ltestdir
-LUAINPUTS=$ltestdir
-export TEXMFCNF LUAINPUTS
-
-rm -rf mfluatrapdir
-mkdir mfluatrapdir
-cd mfluatrapdir
-
-echo ">>> Running TRAP test for MFLua." >&2
-echo ">>> See $ltestdir/mfluatrap.diffs for example of acceptable diffs." >&2
-
-is_OK=:
-
-set -x
-
-# get same filename in log
-$LN_S $testdir/trap.mf .
-
-../mflua --progname=inimflua <$testdir/mftrap1.in >mftrapin.fot
-if test ! -s trap.base; then
- echo "*** trap.base not created by mftrap1.in, investigate!" >&2
- exit 1
-fi
-mv trap.log mftrapin.log || exit 1
-diff $testdir/mftrapin.log mftrapin.log
-
-../mflua --progname=inimflua <$testdir/mftrap2.in >mftrap.fot
-mv trap.log mftrap.log || exit 1
-mv trap.tfm mftrap.tfm || exit 1
-diff $testdir/mftrap.fot mftrap.fot
-diff $testdir/mftrap.log mftrap.log
-
-../tftopl ./mftrap.tfm mftrap.pl || exit 1
-diff $testdir/mftrap.pl mftrap.pl || is_OK=false
-
-../gftype -m -i ./trap.72270gf >trap.typ || exit 1
-diff $testdir/trap.typ trap.typ
-
-$is_OK || {
- echo ">>> There were some errors." >&2
- exit 1
-}
-
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.c b/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.c
deleted file mode 100644
index 8bf700daaf8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/* emyg_dtoa.c
-** Copyright (C) 2015 Doug Currie
-** based on dtoa_milo.h
-** Copyright (C) 2014 Milo Yip
-**
-** Permission is hereby granted, free of charge, to any person obtaining a copy
-** of this software and associated documentation files (the "Software"), to deal
-** in the Software without restriction, including without limitation the rights
-** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-** copies of the Software, and to permit persons to whom the Software is
-** furnished to do so, subject to the following conditions:
-**
-** The above copyright notice and this permission notice shall be included in
-** all copies or substantial portions of the Software.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-** THE SOFTWARE.
-*/
-
-/* This code is a mostly mechanical translation of Milo Yip's C++ version of
-** Grisu2 to C. For algorithm information, see Loitsch, Florian. "Printing
-** floating-point numbers quickly and accurately with integers." ACM Sigplan
-** Notices 45.6 (2010): 233-243.
-*/
-
-#include <assert.h>
-#include <math.h>
-
-#if defined(_MSC_VER)
-#include <intrin.h>
-#endif
-
-#include <stdint.h>
-
-#include <string.h>
-
-#include "emyg-dtoa.h"
-
-#define UINT64_C2(h, l) (((uint64_t)(h) << 32) | (uint64_t)(l))
-
-typedef struct DiyFp_s {
- uint64_t f;
- int e;
-} DiyFp;
-
-static const int kDiySignificandSize = 64;
-static const int kDpSignificandSize = 52;
-static const int kDpExponentBias = 0x3FF + 52;
-static const int kDpMinExponent = -0x3FF - 52;
-static const uint64_t kDpExponentMask = UINT64_C2(0x7FF00000, 0x00000000);
-static const uint64_t kDpSignificandMask = UINT64_C2(0x000FFFFF, 0xFFFFFFFF);
-static const uint64_t kDpHiddenBit = UINT64_C2(0x00100000, 0x00000000);
-
-static inline DiyFp DiyFp_from_parts(uint64_t f, int e) {
- DiyFp fp;
- fp.f = f;
- fp.e = e;
- return fp;
-}
-
-static inline DiyFp DiyFp_from_double(double d) {
- union {
- double d;
- uint64_t u64;
- } u = {d};
- DiyFp res;
-
- int biased_e = (int)((u.u64 & kDpExponentMask) >> kDpSignificandSize);
- uint64_t significand = (u.u64 & kDpSignificandMask);
- if (biased_e != 0) {
- res.f = significand + kDpHiddenBit;
- res.e = biased_e - kDpExponentBias;
- } else {
- res.f = significand;
- res.e = kDpMinExponent + 1;
- }
- return res;
-}
-
-static inline DiyFp DiyFp_subtract(const DiyFp lhs, const DiyFp rhs) {
- assert(lhs.e == rhs.e);
- assert(lhs.f >= rhs.f);
- return DiyFp_from_parts(lhs.f - rhs.f, lhs.e);
-}
-
-static inline DiyFp DiyFp_multiply(const DiyFp lhs, const DiyFp rhs) {
-#if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__clang__)
- uint64_t h;
- uint64_t l = _umul128(lhs.f, rhs.f, &h);
- if (l & ((uint64_t)(1) << 63)) { // rounding
- h++;
- }
- return DiyFp_from_parts(h, lhs.e + rhs.e + 64);
-#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__) && !defined(_MSC_VER)
- __extension__ typedef unsigned __int128 uint128_t;
- //unsigned int128 p = (unsigned int128)(lhs.f) * (unsigned int128)(rhs.f);
- uint128_t p = (uint128_t)(lhs.f) * (uint128_t)(rhs.f);
- uint64_t h = p >> 64;
- uint64_t l = (uint64_t)(p);
- if (l & ((uint64_t)(1) << 63)) // rounding
- h++;
- return DiyFp_from_parts(h, lhs.e + rhs.e + 64);
-#else
- const uint64_t M32 = 0xFFFFFFFF;
- const uint64_t a = lhs.f >> 32;
- const uint64_t b = lhs.f & M32;
- const uint64_t c = rhs.f >> 32;
- const uint64_t d = rhs.f & M32;
- const uint64_t ac = a * c;
- const uint64_t bc = b * c;
- const uint64_t ad = a * d;
- const uint64_t bd = b * d;
- uint64_t tmp = (bd >> 32) + (ad & M32) + (bc & M32);
- tmp += 1U << 31; /// mult_round
- return DiyFp_from_parts(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32), lhs.e + rhs.e + 64);
-#endif
-}
-
-static inline DiyFp Normalize(const DiyFp lhs) {
-#if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__clang__)
- unsigned long index;
- _BitScanReverse64(&index, lhs.f);
- return DiyFp_from_parts(lhs.f << (63 - index), lhs.e - (63 - index));
-#elif defined(__GNUC__) && !defined(_MSC_VER)
- int s = __builtin_clzll(lhs.f);
- return DiyFp_from_parts(lhs.f << s, lhs.e - s);
-#else
- DiyFp res = lhs;
- while (!(res.f & kDpHiddenBit)) {
- res.f <<= 1;
- res.e--;
- }
- res.f <<= (kDiySignificandSize - kDpSignificandSize - 1);
- res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 1);
- return res;
-#endif
-}
-
-static inline DiyFp NormalizeBoundary(const DiyFp lhs) {
-#if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__clang__)
- unsigned long index;
- _BitScanReverse64(&index, lhs.f);
- return DiyFp_from_parts(lhs.f << (63 - index), lhs.e - (63 - index));
-#else
- DiyFp res = lhs;
- while (!(res.f & (kDpHiddenBit << 1))) {
- res.f <<= 1;
- res.e--;
- }
- res.f <<= (kDiySignificandSize - kDpSignificandSize - 2);
- res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 2);
- return res;
-#endif
-}
-
-static inline void NormalizedBoundaries(DiyFp lhs, DiyFp *minus, DiyFp *plus) {
- DiyFp pl = NormalizeBoundary(DiyFp_from_parts((lhs.f << 1) + 1, lhs.e - 1));
- DiyFp mi = (lhs.f == kDpHiddenBit) ? DiyFp_from_parts((lhs.f << 2) - 1, lhs.e - 2)
- : DiyFp_from_parts((lhs.f << 1) - 1, lhs.e - 1);
- mi.f <<= mi.e - pl.e;
- mi.e = pl.e;
- *plus = pl;
- *minus = mi;
-}
-
-static inline DiyFp GetCachedPower(int e, int *K) {
- // 10^-348, 10^-340, ..., 10^340
- static const uint64_t kCachedPowers_F[] = {
- UINT64_C2(0xfa8fd5a0, 0x081c0288), UINT64_C2(0xbaaee17f, 0xa23ebf76), UINT64_C2(0x8b16fb20, 0x3055ac76),
- UINT64_C2(0xcf42894a, 0x5dce35ea), UINT64_C2(0x9a6bb0aa, 0x55653b2d), UINT64_C2(0xe61acf03, 0x3d1a45df),
- UINT64_C2(0xab70fe17, 0xc79ac6ca), UINT64_C2(0xff77b1fc, 0xbebcdc4f), UINT64_C2(0xbe5691ef, 0x416bd60c),
- UINT64_C2(0x8dd01fad, 0x907ffc3c), UINT64_C2(0xd3515c28, 0x31559a83), UINT64_C2(0x9d71ac8f, 0xada6c9b5),
- UINT64_C2(0xea9c2277, 0x23ee8bcb), UINT64_C2(0xaecc4991, 0x4078536d), UINT64_C2(0x823c1279, 0x5db6ce57),
- UINT64_C2(0xc2109436, 0x4dfb5637), UINT64_C2(0x9096ea6f, 0x3848984f), UINT64_C2(0xd77485cb, 0x25823ac7),
- UINT64_C2(0xa086cfcd, 0x97bf97f4), UINT64_C2(0xef340a98, 0x172aace5), UINT64_C2(0xb23867fb, 0x2a35b28e),
- UINT64_C2(0x84c8d4df, 0xd2c63f3b), UINT64_C2(0xc5dd4427, 0x1ad3cdba), UINT64_C2(0x936b9fce, 0xbb25c996),
- UINT64_C2(0xdbac6c24, 0x7d62a584), UINT64_C2(0xa3ab6658, 0x0d5fdaf6), UINT64_C2(0xf3e2f893, 0xdec3f126),
- UINT64_C2(0xb5b5ada8, 0xaaff80b8), UINT64_C2(0x87625f05, 0x6c7c4a8b), UINT64_C2(0xc9bcff60, 0x34c13053),
- UINT64_C2(0x964e858c, 0x91ba2655), UINT64_C2(0xdff97724, 0x70297ebd), UINT64_C2(0xa6dfbd9f, 0xb8e5b88f),
- UINT64_C2(0xf8a95fcf, 0x88747d94), UINT64_C2(0xb9447093, 0x8fa89bcf), UINT64_C2(0x8a08f0f8, 0xbf0f156b),
- UINT64_C2(0xcdb02555, 0x653131b6), UINT64_C2(0x993fe2c6, 0xd07b7fac), UINT64_C2(0xe45c10c4, 0x2a2b3b06),
- UINT64_C2(0xaa242499, 0x697392d3), UINT64_C2(0xfd87b5f2, 0x8300ca0e), UINT64_C2(0xbce50864, 0x92111aeb),
- UINT64_C2(0x8cbccc09, 0x6f5088cc), UINT64_C2(0xd1b71758, 0xe219652c), UINT64_C2(0x9c400000, 0x00000000),
- UINT64_C2(0xe8d4a510, 0x00000000), UINT64_C2(0xad78ebc5, 0xac620000), UINT64_C2(0x813f3978, 0xf8940984),
- UINT64_C2(0xc097ce7b, 0xc90715b3), UINT64_C2(0x8f7e32ce, 0x7bea5c70), UINT64_C2(0xd5d238a4, 0xabe98068),
- UINT64_C2(0x9f4f2726, 0x179a2245), UINT64_C2(0xed63a231, 0xd4c4fb27), UINT64_C2(0xb0de6538, 0x8cc8ada8),
- UINT64_C2(0x83c7088e, 0x1aab65db), UINT64_C2(0xc45d1df9, 0x42711d9a), UINT64_C2(0x924d692c, 0xa61be758),
- UINT64_C2(0xda01ee64, 0x1a708dea), UINT64_C2(0xa26da399, 0x9aef774a), UINT64_C2(0xf209787b, 0xb47d6b85),
- UINT64_C2(0xb454e4a1, 0x79dd1877), UINT64_C2(0x865b8692, 0x5b9bc5c2), UINT64_C2(0xc83553c5, 0xc8965d3d),
- UINT64_C2(0x952ab45c, 0xfa97a0b3), UINT64_C2(0xde469fbd, 0x99a05fe3), UINT64_C2(0xa59bc234, 0xdb398c25),
- UINT64_C2(0xf6c69a72, 0xa3989f5c), UINT64_C2(0xb7dcbf53, 0x54e9bece), UINT64_C2(0x88fcf317, 0xf22241e2),
- UINT64_C2(0xcc20ce9b, 0xd35c78a5), UINT64_C2(0x98165af3, 0x7b2153df), UINT64_C2(0xe2a0b5dc, 0x971f303a),
- UINT64_C2(0xa8d9d153, 0x5ce3b396), UINT64_C2(0xfb9b7cd9, 0xa4a7443c), UINT64_C2(0xbb764c4c, 0xa7a44410),
- UINT64_C2(0x8bab8eef, 0xb6409c1a), UINT64_C2(0xd01fef10, 0xa657842c), UINT64_C2(0x9b10a4e5, 0xe9913129),
- UINT64_C2(0xe7109bfb, 0xa19c0c9d), UINT64_C2(0xac2820d9, 0x623bf429), UINT64_C2(0x80444b5e, 0x7aa7cf85),
- UINT64_C2(0xbf21e440, 0x03acdd2d), UINT64_C2(0x8e679c2f, 0x5e44ff8f), UINT64_C2(0xd433179d, 0x9c8cb841),
- UINT64_C2(0x9e19db92, 0xb4e31ba9), UINT64_C2(0xeb96bf6e, 0xbadf77d9), UINT64_C2(0xaf87023b, 0x9bf0ee6b)};
- static const int16_t kCachedPowers_E[] = {
- -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, -954, -927, -901, -874, -847,
- -821, -794, -768, -741, -715, -688, -661, -635, -608, -582, -555, -529, -502, -475, -449,
- -422, -396, -369, -343, -316, -289, -263, -236, -210, -183, -157, -130, -103, -77, -50,
- -24, 3, 30, 56, 83, 109, 136, 162, 189, 216, 242, 269, 295, 322, 348,
- 375, 402, 428, 455, 481, 508, 534, 561, 588, 614, 641, 667, 694, 720, 747,
- 774, 800, 827, 853, 880, 907, 933, 960, 986, 1013, 1039, 1066};
-
- // int k = (int )(ceil((-61 - e) * 0.30102999566398114)) + 374;
- double dk = (-61 - e) * 0.30102999566398114 + 347; // dk must be positive, so can do ceiling in positive
- int k = (int)(dk);
- if (k != dk) k++;
-
- unsigned index = (unsigned)((k >> 3) + 1);
- *K = -(-348 + (int)(index << 3)); // decimal exponent no need lookup table
-
- assert(index < sizeof(kCachedPowers_F) / sizeof(kCachedPowers_F[0]));
- return DiyFp_from_parts(kCachedPowers_F[index], kCachedPowers_E[index]);
-}
-
-static inline void GrisuRound(char *buffer, int len, uint64_t delta, uint64_t rest, uint64_t ten_kappa, uint64_t wp_w) {
- while (rest < wp_w && delta - rest >= ten_kappa && (rest + ten_kappa < wp_w || /// closer
- wp_w - rest > rest + ten_kappa - wp_w)) {
- buffer[len - 1]--;
- rest += ten_kappa;
- }
-}
-
-static inline unsigned CountDecimalDigit32(uint32_t n) {
- // Simple pure C++ implementation was faster than __builtin_clz version in this situation.
- if (n < 10) return 1;
- if (n < 100) return 2;
- if (n < 1000) return 3;
- if (n < 10000) return 4;
- if (n < 100000) return 5;
- if (n < 1000000) return 6;
- if (n < 10000000) return 7;
- if (n < 100000000) return 8;
- if (n < 1000000000) return 9;
- return 10;
-}
-
-static inline void DigitGen(const DiyFp W, const DiyFp Mp, uint64_t delta, char *buffer, int *len, int *K) {
- static const uint32_t kPow10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
- const DiyFp one = DiyFp_from_parts((uint64_t)(1) << -Mp.e, Mp.e);
- const DiyFp wp_w = DiyFp_subtract(Mp, W);
- uint32_t p1 = (uint32_t)(Mp.f >> -one.e);
- uint64_t p2 = Mp.f & (one.f - 1);
- int kappa = (int)(CountDecimalDigit32(p1));
- *len = 0;
-
- while (kappa > 0) {
- uint32_t d = 0;
- switch (kappa) {
- case 10:
- d = p1 / 1000000000;
- p1 %= 1000000000;
- break;
- case 9:
- d = p1 / 100000000;
- p1 %= 100000000;
- break;
- case 8:
- d = p1 / 10000000;
- p1 %= 10000000;
- break;
- case 7:
- d = p1 / 1000000;
- p1 %= 1000000;
- break;
- case 6:
- d = p1 / 100000;
- p1 %= 100000;
- break;
- case 5:
- d = p1 / 10000;
- p1 %= 10000;
- break;
- case 4:
- d = p1 / 1000;
- p1 %= 1000;
- break;
- case 3:
- d = p1 / 100;
- p1 %= 100;
- break;
- case 2:
- d = p1 / 10;
- p1 %= 10;
- break;
- case 1:
- d = p1;
- p1 = 0;
- break;
- default:
-#if defined(_MSC_VER)
- __assume(0);
-#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
- __builtin_unreachable();
-#else
- d = 0;
-#endif
- }
- if (d || *len) buffer[(*len)++] = '0' + (char)(d);
- kappa--;
- uint64_t tmp = ((uint64_t)(p1) << -one.e) + p2;
- if (tmp <= delta) {
- *K += kappa;
- GrisuRound(buffer, *len, delta, tmp, (uint64_t)(kPow10[kappa]) << -one.e, wp_w.f);
- return;
- }
- }
-
- // kappa = 0
- for (;;) {
- p2 *= 10;
- delta *= 10;
- char d = (char)(p2 >> -one.e);
- if (d || *len) buffer[(*len)++] = '0' + d;
- p2 &= one.f - 1;
- kappa--;
- if (p2 < delta) {
- *K += kappa;
- GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * kPow10[-kappa]);
- return;
- }
- }
-}
-
-static inline void Grisu2(double value, char *buffer, int *length, int *K) {
- const DiyFp v = DiyFp_from_double(value);
- DiyFp w_m, w_p;
- NormalizedBoundaries(v, &w_m, &w_p);
-
- const DiyFp c_mk = GetCachedPower(w_p.e, K);
- const DiyFp W = DiyFp_multiply(Normalize(v), c_mk);
- DiyFp Wp = DiyFp_multiply(w_p, c_mk);
- DiyFp Wm = DiyFp_multiply(w_m, c_mk);
- Wm.f++;
- Wp.f--;
- DigitGen(W, Wp, Wp.f - Wm.f, buffer, length, K);
-}
-
-static inline const char *GetDigitsLut() {
- static const char cDigitsLut[200] = {
- '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
- '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
- '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
- '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
- '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
- '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
- '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
- '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
- '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
- '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'};
- return cDigitsLut;
-}
-
-static inline void WriteExponent(int K, char *buffer) {
- if (K < 0) {
- *buffer++ = '-';
- K = -K;
- }
-
- if (K >= 100) {
- *buffer++ = '0' + (char)(K / 100);
- K %= 100;
- const char *d = GetDigitsLut() + K * 2;
- *buffer++ = d[0];
- *buffer++ = d[1];
- } else if (K >= 10) {
- const char *d = GetDigitsLut() + K * 2;
- *buffer++ = d[0];
- *buffer++ = d[1];
- } else
- *buffer++ = '0' + (char)(K);
-
- *buffer = '\0';
-}
-
-static inline void Prettify(char *buffer, int length, int k) {
- const int kk = length + k; // 10^(kk-1) <= v < 10^kk
-
- if (length <= kk && kk <= 21) {
- // 1234e7 -> 12340000000
- for (int i = length; i < kk; i++)
- buffer[i] = '0';
- buffer[kk] = '.';
- buffer[kk + 1] = '0';
- buffer[kk + 2] = '\0';
- } else if (0 < kk && kk <= 21) {
- // 1234e-2 -> 12.34
- memmove(&buffer[kk + 1], &buffer[kk], length - kk);
- buffer[kk] = '.';
- buffer[length + 1] = '\0';
- } else if (-6 < kk && kk <= 0) {
- // 1234e-6 -> 0.001234
- const int offset = 2 - kk;
- memmove(&buffer[offset], &buffer[0], length);
- buffer[0] = '0';
- buffer[1] = '.';
- for (int i = 2; i < offset; i++)
- buffer[i] = '0';
- buffer[length + offset] = '\0';
- } else if (length == 1) {
- // 1e30
- buffer[1] = 'e';
- WriteExponent(kk - 1, &buffer[2]);
- } else {
- // 1234e30 -> 1.234e33
- memmove(&buffer[2], &buffer[1], length - 1);
- buffer[1] = '.';
- buffer[length + 1] = 'e';
- WriteExponent(kk - 1, &buffer[0 + length + 2]);
- }
-}
-
-void emyg_dtoa(double value, char *buffer) {
- // Not handling NaN and inf
- assert(!isnan(value));
- assert(!isinf(value));
-
- if (value == 0) {
- buffer[0] = '0';
- buffer[1] = '.';
- buffer[2] = '0';
- buffer[3] = '\0';
- } else {
- if (value < 0) {
- *buffer++ = '-';
- value = -value;
- }
- int length, K;
- Grisu2(value, buffer, &length, &K);
- Prettify(buffer, length, K);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.h b/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.h
deleted file mode 100644
index f9ff35bede8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/emyg-dtoa/emyg-dtoa.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CARYLL_DEP_EMYG_DTOA_H
-#define CARYLL_DEP_EMYG_DTOA_H
-
-void emyg_dtoa(double value, char *buffer);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json-builder.c b/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json-builder.c
deleted file mode 100644
index 9e36667bafd..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json-builder.c
+++ /dev/null
@@ -1,889 +0,0 @@
-
-/* vim: set et ts=3 sw=3 sts=3 ft=c:
- *
- * Copyright (C) 2014 James McLaughlin. All rights reserved.
- * https://github.com/udp/json-builder
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "json-builder.h"
-#include "emyg-dtoa/emyg-dtoa.h"
-
-#include <string.h>
-#include <assert.h>
-#include <stdio.h>
-#include <math.h>
-
-#ifdef _MSC_VER
-#define snprintf _snprintf
-#endif
-
-const static json_serialize_opts default_opts = {
- json_serialize_mode_single_line, 0, 3 /* indent_size */
-};
-
-typedef struct json_builder_value {
- json_value value;
-
- int is_builder_value;
-
- size_t additional_length_allocated;
- size_t length_iterated;
-
-} json_builder_value;
-
-static int builderize(json_value *value) {
- if (((json_builder_value *)value)->is_builder_value) return 1;
-
- if (value->type == json_object) {
- unsigned int i;
-
- /* Values straight out of the parser have the names of object entries
- * allocated in the same allocation as the values array itself. This is
- * not desirable when manipulating values because the names would be easy
- * to clobber.
- */
- for (i = 0; i < value->u.object.length; ++i) {
- json_char *name_copy;
- json_object_entry *entry = &value->u.object.values[i];
-
- if (!(name_copy = (json_char *)malloc((entry->name_length + 1) * sizeof(json_char)))) return 0;
-
- memcpy(name_copy, entry->name, entry->name_length + 1);
- entry->name = name_copy;
- }
- }
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- return 1;
-}
-
-const size_t json_builder_extra = sizeof(json_builder_value) - sizeof(json_value);
-
-/* These flags are set up from the opts before serializing to make the
- * serializer conditions simpler.
- */
-const int f_spaces_around_brackets = (1 << 0);
-const int f_spaces_after_commas = (1 << 1);
-const int f_spaces_after_colons = (1 << 2);
-const int f_tabs = (1 << 3);
-
-static int get_serialize_flags(json_serialize_opts opts) {
- int flags = 0;
-
- if (opts.mode == json_serialize_mode_packed) return 0;
-
- if (opts.mode == json_serialize_mode_multiline) {
- if (opts.opts & json_serialize_opt_use_tabs) flags |= f_tabs;
- } else {
- if (!(opts.opts & json_serialize_opt_pack_brackets)) flags |= f_spaces_around_brackets;
-
- if (!(opts.opts & json_serialize_opt_no_space_after_comma)) flags |= f_spaces_after_commas;
- }
-
- if (!(opts.opts & json_serialize_opt_no_space_after_colon)) flags |= f_spaces_after_colons;
-
- return flags;
-}
-
-json_value *json_array_new(size_t length) {
- json_value *value = (json_value *)calloc(1, sizeof(json_builder_value));
-
- if (!value) return NULL;
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- value->type = json_array;
-
- if (!(value->u.array.values = (json_value **)malloc(length * sizeof(json_value *)))) {
- free(value);
- return NULL;
- }
-
- ((json_builder_value *)value)->additional_length_allocated = length;
-
- return value;
-}
-
-json_value *json_array_push(json_value *array, json_value *value) {
- assert(array->type == json_array);
-
- if (!builderize(array) || !builderize(value)) return NULL;
-
- if (((json_builder_value *)array)->additional_length_allocated > 0) {
- --((json_builder_value *)array)->additional_length_allocated;
- } else {
- json_value **values_new =
- (json_value **)realloc(array->u.array.values, sizeof(json_value *) * (array->u.array.length + 1));
-
- if (!values_new) return NULL;
-
- array->u.array.values = values_new;
- }
-
- array->u.array.values[array->u.array.length] = value;
- ++array->u.array.length;
-
- value->parent = array;
-
- return value;
-}
-
-json_value *json_object_new(size_t length) {
- json_value *value = (json_value *)calloc(1, sizeof(json_builder_value));
-
- if (!value) return NULL;
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- value->type = json_object;
-
- if (!(value->u.object.values = (json_object_entry *)calloc(length, sizeof(*value->u.object.values)))) {
- free(value);
- return NULL;
- }
-
- ((json_builder_value *)value)->additional_length_allocated = length;
-
- return value;
-}
-
-json_value *json_object_push(json_value *object, const json_char *name, json_value *value) {
- return json_object_push_length(object, strlen(name), name, value);
-}
-
-json_value *json_object_push_length(json_value *object, unsigned int name_length, const json_char *name,
- json_value *value) {
- json_char *name_copy;
-
- assert(object->type == json_object);
-
- if (!(name_copy = (json_char *)malloc((name_length + 1) * sizeof(json_char)))) return NULL;
-
- memcpy(name_copy, name, name_length * sizeof(json_char));
- name_copy[name_length] = 0;
-
- if (!json_object_push_nocopy(object, name_length, name_copy, value)) {
- free(name_copy);
- return NULL;
- }
-
- return value;
-}
-
-json_value *json_object_push_nocopy(json_value *object, unsigned int name_length, json_char *name, json_value *value) {
- json_object_entry *entry;
-
- assert(object->type == json_object);
-
- if (!builderize(object) || !builderize(value)) return NULL;
-
- if (((json_builder_value *)object)->additional_length_allocated > 0) {
- --((json_builder_value *)object)->additional_length_allocated;
- } else {
- json_object_entry *values_new = (json_object_entry *)realloc(
- object->u.object.values, sizeof(*object->u.object.values) * (object->u.object.length + 1));
-
- if (!values_new) return NULL;
-
- object->u.object.values = values_new;
- }
-
- entry = object->u.object.values + object->u.object.length;
-
- entry->name_length = name_length;
- entry->name = name;
- entry->value = value;
-
- ++object->u.object.length;
-
- value->parent = object;
-
- return value;
-}
-
-json_value *json_string_new(const json_char *buf) {
- return json_string_new_length(strlen(buf), buf);
-}
-
-json_value *json_string_new_length(unsigned int length, const json_char *buf) {
- json_value *value;
- json_char *copy = (json_char *)malloc((length + 1) * sizeof(json_char));
-
- if (!copy) return NULL;
-
- memcpy(copy, buf, length * sizeof(json_char));
- copy[length] = 0;
-
- if (!(value = json_string_new_nocopy(length, copy))) {
- free(copy);
- return NULL;
- }
-
- return value;
-}
-
-json_value *json_string_new_nocopy(unsigned int length, json_char *buf) {
- json_value *value = (json_value *)calloc(1, sizeof(json_builder_value));
-
- if (!value) return NULL;
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- value->type = json_string;
- value->u.string.length = length;
- value->u.string.ptr = buf;
-
- return value;
-}
-
-json_value *json_integer_new(json_int_t integer) {
- json_value *value = (json_value *)calloc(1, sizeof(json_builder_value));
-
- if (!value) return NULL;
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- value->type = json_integer;
- value->u.integer = integer;
-
- return value;
-}
-
-json_value *json_double_new(double dbl) {
- json_value *value = (json_value *)calloc(1, sizeof(json_builder_value));
-
- if (!value) return NULL;
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- value->type = json_double;
- value->u.dbl = dbl;
-
- return value;
-}
-
-json_value *json_boolean_new(int b) {
- json_value *value = (json_value *)calloc(1, sizeof(json_builder_value));
-
- if (!value) return NULL;
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- value->type = json_boolean;
- value->u.boolean = b;
-
- return value;
-}
-
-json_value *json_null_new(void) {
- json_value *value = (json_value *)calloc(1, sizeof(json_builder_value));
-
- if (!value) return NULL;
-
- ((json_builder_value *)value)->is_builder_value = 1;
-
- value->type = json_null;
-
- return value;
-}
-
-void json_object_sort(json_value *object, json_value *proto) {
- unsigned int i, out_index = 0;
-
- if (!builderize(object)) return; /* TODO error */
-
- assert(object->type == json_object);
- assert(proto->type == json_object);
-
- for (i = 0; i < proto->u.object.length; ++i) {
- unsigned int j;
- json_object_entry proto_entry = proto->u.object.values[i];
-
- for (j = 0; j < object->u.object.length; ++j) {
- json_object_entry entry = object->u.object.values[j];
-
- if (entry.name_length != proto_entry.name_length) continue;
-
- if (memcmp(entry.name, proto_entry.name, entry.name_length) != 0) continue;
-
- object->u.object.values[j] = object->u.object.values[out_index];
- object->u.object.values[out_index] = entry;
-
- ++out_index;
- }
- }
-}
-
-json_value *json_object_merge(json_value *objectA, json_value *objectB) {
- unsigned int i;
-
- assert(objectA->type == json_object);
- assert(objectB->type == json_object);
- assert(objectA != objectB);
-
- if (!builderize(objectA) || !builderize(objectB)) return NULL;
-
- if (objectB->u.object.length <= ((json_builder_value *)objectA)->additional_length_allocated) {
- ((json_builder_value *)objectA)->additional_length_allocated -= objectB->u.object.length;
- } else {
- json_object_entry *values_new;
-
- unsigned int alloc = objectA->u.object.length + ((json_builder_value *)objectA)->additional_length_allocated +
- objectB->u.object.length;
-
- if (!(values_new = (json_object_entry *)realloc(objectA->u.object.values, sizeof(json_object_entry) * alloc))) {
- return NULL;
- }
-
- objectA->u.object.values = values_new;
- }
-
- for (i = 0; i < objectB->u.object.length; ++i) {
- json_object_entry *entry = &objectA->u.object.values[objectA->u.object.length + i];
-
- *entry = objectB->u.object.values[i];
- entry->value->parent = objectA;
- }
-
- objectA->u.object.length += objectB->u.object.length;
-
- free(objectB->u.object.values);
- free(objectB);
-
- return objectA;
-}
-
-static size_t measure_string(unsigned int length, const json_char *str) {
- unsigned int i;
- size_t measured_length = 0;
-
- for (i = 0; i < length; ++i) {
- json_char c = str[i];
-
- switch (c) {
- case 0:
- case 0xb:
- measured_length += 6;
- break;
- case '"':
- case '\\':
- case '\b':
- case '\f':
- case '\n':
- case '\r':
- case '\t':
-
- measured_length += 2;
- break;
-
- default:
-
- ++measured_length;
- break;
- };
- };
-
- return measured_length;
-}
-
-#define PRINT_ESCAPED(c) \
- do { \
- *buf++ = '\\'; \
- *buf++ = (c); \
- } while (0);
-
-static size_t serialize_string(json_char *buf, unsigned int length, const json_char *str) {
- json_char *orig_buf = buf;
- unsigned int i;
-
- for (i = 0; i < length; ++i) {
- json_char c = str[i];
-
- switch (c) {
- case 0:
- *buf++ = '\\';
- *buf++ = 'u';
- *buf++ = '0';
- *buf++ = '0';
- *buf++ = '0';
- *buf++ = '0';
- continue;
- case '"':
- PRINT_ESCAPED('\"');
- continue;
- case '\\':
- PRINT_ESCAPED('\\');
- continue;
- case '\b':
- PRINT_ESCAPED('b');
- continue;
- case '\f':
- PRINT_ESCAPED('f');
- continue;
- case '\n':
- PRINT_ESCAPED('n');
- continue;
- case '\r':
- PRINT_ESCAPED('r');
- continue;
- case '\t':
- PRINT_ESCAPED('t');
- continue;
- case 0xb:
- *buf++ = '\\';
- *buf++ = 'u';
- *buf++ = '0';
- *buf++ = '0';
- *buf++ = '0';
- *buf++ = 'b';
- continue;
-
- default:
-
- *buf++ = c;
- break;
- };
- };
-
- return buf - orig_buf;
-}
-
-size_t json_measure(json_value *value) {
- return json_measure_ex(value, default_opts);
-}
-
-#define MEASURE_NEWLINE() \
- do { \
- ++newlines; \
- indents += depth; \
- } while (0);
-
-size_t json_measure_ex(json_value *value, json_serialize_opts opts) {
- size_t total = 1; /* null terminator */
- size_t newlines = 0;
- size_t depth = 0;
- size_t indents = 0;
- int flags;
- int bracket_size, comma_size, colon_size;
-
- flags = get_serialize_flags(opts);
-
- /* to reduce branching
- */
- bracket_size = flags & f_spaces_around_brackets ? 2 : 1;
- comma_size = flags & f_spaces_after_commas ? 2 : 1;
- colon_size = flags & f_spaces_after_colons ? 2 : 1;
-
- while (value) {
- json_int_t integer;
- json_object_entry *entry;
-
- switch (value->type) {
- case json_array:
-
- if (((json_builder_value *)value)->length_iterated == 0) {
- if (value->u.array.length == 0) {
- total += 2; /* `[]` */
- break;
- }
-
- total += bracket_size; /* `[` */
-
- ++depth;
- MEASURE_NEWLINE(); /* \n after [ */
- }
-
- if (((json_builder_value *)value)->length_iterated == value->u.array.length) {
- --depth;
- MEASURE_NEWLINE();
- total += bracket_size; /* `]` */
-
- ((json_builder_value *)value)->length_iterated = 0;
- break;
- }
-
- if (((json_builder_value *)value)->length_iterated > 0) {
- total += comma_size; /* `, ` */
-
- MEASURE_NEWLINE();
- }
-
- ((json_builder_value *)value)->length_iterated++;
- value = value->u.array.values[((json_builder_value *)value)->length_iterated - 1];
- continue;
-
- case json_object:
-
- if (((json_builder_value *)value)->length_iterated == 0) {
- if (value->u.object.length == 0) {
- total += 2; /* `{}` */
- break;
- }
-
- total += bracket_size; /* `{` */
-
- ++depth;
- MEASURE_NEWLINE(); /* \n after { */
- }
-
- if (((json_builder_value *)value)->length_iterated == value->u.object.length) {
- --depth;
- MEASURE_NEWLINE();
- total += bracket_size; /* `}` */
-
- ((json_builder_value *)value)->length_iterated = 0;
- break;
- }
-
- if (((json_builder_value *)value)->length_iterated > 0) {
- total += comma_size; /* `, ` */
- MEASURE_NEWLINE();
- }
-
- entry = value->u.object.values + (((json_builder_value *)value)->length_iterated++);
-
- total += 2 + colon_size; /* `"": ` */
- total += measure_string(entry->name_length, entry->name);
-
- value = entry->value;
- continue;
-#ifdef CARYLL_USE_PRE_SERIALIZED
- case json_pre_serialized:
-
- total += value->u.string.length;
- break;
-#endif
- case json_string:
- total += 2; /* `""` */
- total += measure_string(value->u.string.length, value->u.string.ptr);
- break;
-
- case json_integer:
-
- integer = value->u.integer;
-
- if (integer < 0) {
- total += 1; /* `-` */
- integer = -integer;
- }
-
- ++total; /* first digit */
-
- while (integer >= 10) {
- ++total; /* another digit */
- integer /= 10;
- }
-
- break;
-
- case json_double: {
- char buffer[256];
- emyg_dtoa(value->u.dbl, buffer);
- total += strlen(buffer);
- break;
- }
-
- case json_boolean:
-
- total += value->u.boolean ? 4 : /* `true` */
- 5; /* `false` */
-
- break;
-
- case json_null:
-
- total += 4; /* `null` */
- break;
-
- default:
- break;
- };
-
- value = value->parent;
- }
-
- if (opts.mode == json_serialize_mode_multiline) {
- total += newlines * (((opts.opts & json_serialize_opt_CRLF) ? 2 : 1) + opts.indent_size);
- total += indents * opts.indent_size;
- }
-
- return total;
-}
-
-void json_serialize(json_char *buf, json_value *value) {
- json_serialize_ex(buf, value, default_opts);
-}
-
-#define PRINT_NEWLINE() \
- do { \
- if (opts.mode == json_serialize_mode_multiline) { \
- if (opts.opts & json_serialize_opt_CRLF) *buf++ = '\r'; \
- *buf++ = '\n'; \
- for (i = 0; i < indent; ++i) \
- *buf++ = indent_char; \
- } \
- } while (0);
-
-#define PRINT_OPENING_BRACKET(c) \
- do { \
- *buf++ = (c); \
- if (flags & f_spaces_around_brackets) *buf++ = ' '; \
- } while (0);
-
-#define PRINT_CLOSING_BRACKET(c) \
- do { \
- if (flags & f_spaces_around_brackets) *buf++ = ' '; \
- *buf++ = (c); \
- } while (0);
-
-void json_serialize_ex(json_char *buf, json_value *value, json_serialize_opts opts) {
- json_int_t integer, orig_integer;
- json_object_entry *entry;
- json_char *ptr;
- int indent = 0;
- char indent_char;
- int i;
- int flags;
-
- flags = get_serialize_flags(opts);
-
- indent_char = flags & f_tabs ? '\t' : ' ';
-
- while (value) {
- switch (value->type) {
- case json_array:
-
- if (((json_builder_value *)value)->length_iterated == 0) {
- if (value->u.array.length == 0) {
- *buf++ = '[';
- *buf++ = ']';
-
- break;
- }
-
- PRINT_OPENING_BRACKET('[');
-
- indent += opts.indent_size;
- PRINT_NEWLINE();
- }
-
- if (((json_builder_value *)value)->length_iterated == value->u.array.length) {
- indent -= opts.indent_size;
- PRINT_NEWLINE();
- PRINT_CLOSING_BRACKET(']');
-
- ((json_builder_value *)value)->length_iterated = 0;
- break;
- }
-
- if (((json_builder_value *)value)->length_iterated > 0) {
- *buf++ = ',';
-
- if (flags & f_spaces_after_commas) *buf++ = ' ';
-
- PRINT_NEWLINE();
- }
-
- ((json_builder_value *)value)->length_iterated++;
- value = value->u.array.values[((json_builder_value *)value)->length_iterated - 1];
- continue;
-
- case json_object:
-
- if (((json_builder_value *)value)->length_iterated == 0) {
- if (value->u.object.length == 0) {
- *buf++ = '{';
- *buf++ = '}';
-
- break;
- }
-
- PRINT_OPENING_BRACKET('{');
-
- indent += opts.indent_size;
- PRINT_NEWLINE();
- }
-
- if (((json_builder_value *)value)->length_iterated == value->u.object.length) {
- indent -= opts.indent_size;
- PRINT_NEWLINE();
- PRINT_CLOSING_BRACKET('}');
-
- ((json_builder_value *)value)->length_iterated = 0;
- break;
- }
-
- if (((json_builder_value *)value)->length_iterated > 0) {
- *buf++ = ',';
-
- if (flags & f_spaces_after_commas) *buf++ = ' ';
-
- PRINT_NEWLINE();
- }
-
- entry = value->u.object.values + (((json_builder_value *)value)->length_iterated++);
-
- *buf++ = '\"';
- buf += serialize_string(buf, entry->name_length, entry->name);
- *buf++ = '\"';
- *buf++ = ':';
-
- if (flags & f_spaces_after_colons) *buf++ = ' ';
-
- value = entry->value;
- continue;
-#ifdef CARYLL_USE_PRE_SERIALIZED
- case json_pre_serialized:
- memcpy(buf, value->u.string.ptr, value->u.string.length);
- buf += value->u.string.length;
- break;
-#endif
- case json_string:
-
- *buf++ = '\"';
- buf += serialize_string(buf, value->u.string.length, value->u.string.ptr);
- *buf++ = '\"';
- break;
-
- case json_integer:
-
- integer = value->u.integer;
-
- if (integer < 0) {
- *buf++ = '-';
- integer = -integer;
- }
-
- orig_integer = integer;
-
- ++buf;
-
- while (integer >= 10) {
- ++buf;
- integer /= 10;
- }
-
- integer = orig_integer;
- ptr = buf;
-
- do {
- *--ptr = "0123456789"[integer % 10];
- } while ((integer /= 10) > 0);
-
- break;
-
- case json_double: {
- char tmp[256];
- emyg_dtoa(value->u.dbl, tmp);
- memcpy(buf, tmp, strlen(tmp));
- buf += strlen(tmp);
- break;
- }
-
- case json_boolean:
-
- if (value->u.boolean) {
- memcpy(buf, "true", 4);
- buf += 4;
- } else {
- memcpy(buf, "false", 5);
- buf += 5;
- }
-
- break;
-
- case json_null:
-
- memcpy(buf, "null", 4);
- buf += 4;
- break;
-
- default:
- break;
- };
-
- value = value->parent;
- }
-
- *buf = 0;
-}
-
-void json_builder_free(json_value *value) {
- json_value *cur_value;
-
- if (!value) return;
-
- value->parent = 0;
-
- while (value) {
- switch (value->type) {
- case json_array:
-
- if (!value->u.array.length) {
- free(value->u.array.values);
- break;
- }
-
- value = value->u.array.values[--value->u.array.length];
- continue;
-
- case json_object:
-
- if (!value->u.object.length) {
- free(value->u.object.values);
- break;
- }
-
- --value->u.object.length;
-
- if (((json_builder_value *)value)->is_builder_value) {
- /* Names are allocated separately for builder values. In parser
- * values, they are part of the same allocation as the values array
- * itself.
- */
- free(value->u.object.values[value->u.object.length].name);
- }
-
- value = value->u.object.values[value->u.object.length].value;
- continue;
-
- case json_string:
-#ifdef CARYLL_USE_PRE_SERIALIZED
- case json_pre_serialized:
-#endif
- free(value->u.string.ptr);
- break;
-
- default:
- break;
- };
-
- cur_value = value;
- value = value->parent;
- free(cur_value);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json.c b/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json.c
deleted file mode 100644
index 4f6bcfe8d50..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/json.c
+++ /dev/null
@@ -1,1039 +0,0 @@
-/* vim: set et ts=3 sw=3 sts=3 ft=c:
- *
- * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved.
- * https://github.com/udp/json-parser
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "json.h"
-
-#ifdef _MSC_VER
- #ifndef _CRT_SECURE_NO_WARNINGS
- #define _CRT_SECURE_NO_WARNINGS
- #endif
-#endif
-
-const struct _json_value json_value_none;
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <math.h>
-
-typedef unsigned int json_uchar;
-
-static unsigned char hex_value (json_char c)
-{
- if (isdigit(c))
- return c - '0';
-
- switch (c) {
- case 'a': case 'A': return 0x0A;
- case 'b': case 'B': return 0x0B;
- case 'c': case 'C': return 0x0C;
- case 'd': case 'D': return 0x0D;
- case 'e': case 'E': return 0x0E;
- case 'f': case 'F': return 0x0F;
- default: return 0xFF;
- }
-}
-
-typedef struct
-{
- unsigned long used_memory;
-
- unsigned int uint_max;
- unsigned long ulong_max;
-
- json_settings settings;
- int first_pass;
-
- const json_char * ptr;
- unsigned int cur_line, cur_col;
-
-} json_state;
-
-static void * default_alloc (size_t size, int zero, void * user_data)
-{
- return zero ? calloc (1, size) : malloc (size);
-}
-
-static void default_free (void * ptr, void * user_data)
-{
- free (ptr);
-}
-
-static void * json_alloc (json_state * state, unsigned long size, int zero)
-{
- if ((state->ulong_max - state->used_memory) < size)
- return 0;
-
- if (state->settings.max_memory
- && (state->used_memory += size) > state->settings.max_memory)
- {
- return 0;
- }
-
- return state->settings.mem_alloc (size, zero, state->settings.user_data);
-}
-
-static int new_value (json_state * state,
- json_value ** top, json_value ** root, json_value ** alloc,
- json_type type)
-{
- json_value * value;
- int values_size;
-
- if (!state->first_pass)
- {
- value = *top = *alloc;
- *alloc = (*alloc)->_reserved.next_alloc;
-
- if (!*root)
- *root = value;
-
- switch (value->type)
- {
- case json_array:
-
- if (value->u.array.length == 0)
- break;
-
- if (! (value->u.array.values = (json_value **) json_alloc
- (state, value->u.array.length * sizeof (json_value *), 0)) )
- {
- return 0;
- }
-
- value->u.array.length = 0;
- break;
-
- case json_object:
-
- if (value->u.object.length == 0)
- break;
-
- values_size = sizeof (*value->u.object.values) * value->u.object.length;
-
- if (! (value->u.object.values = (json_object_entry *) json_alloc
- (state, values_size + ((uintptr_t) value->u.object.values), 0)) )
- {
- return 0;
- }
-
- value->_reserved.object_mem = (*(char **) &value->u.object.values) + values_size;
-
- value->u.object.length = 0;
- break;
-
- case json_string:
-
- if (! (value->u.string.ptr = (json_char *) json_alloc
- (state, (value->u.string.length + 1) * sizeof (json_char), 0)) )
- {
- return 0;
- }
-
- value->u.string.length = 0;
- break;
-
- default:
- break;
- };
-
- return 1;
- }
-
- if (! (value = (json_value *) json_alloc
- (state, sizeof (json_value) + state->settings.value_extra, 1)))
- {
- return 0;
- }
-
- if (!*root)
- *root = value;
-
- value->type = type;
- value->parent = *top;
-
- #ifdef JSON_TRACK_SOURCE
- value->line = state->cur_line;
- value->col = state->cur_col;
- #endif
-
- if (*alloc)
- (*alloc)->_reserved.next_alloc = value;
-
- *alloc = *top = value;
-
- return 1;
-}
-
-#define whitespace \
- case '\n': ++ state.cur_line; state.cur_col = 0; \
- case ' ': case '\t': case '\r'
-
-#define string_add(b) \
- do { if (!state.first_pass) string [string_length] = b; ++ string_length; } while (0);
-
-#define line_and_col \
- state.cur_line, state.cur_col
-
-static const long
- flag_next = 1 << 0,
- flag_reproc = 1 << 1,
- flag_need_comma = 1 << 2,
- flag_seek_value = 1 << 3,
- flag_escaped = 1 << 4,
- flag_string = 1 << 5,
- flag_need_colon = 1 << 6,
- flag_done = 1 << 7,
- flag_num_negative = 1 << 8,
- flag_num_zero = 1 << 9,
- flag_num_e = 1 << 10,
- flag_num_e_got_sign = 1 << 11,
- flag_num_e_negative = 1 << 12,
- flag_line_comment = 1 << 13,
- flag_block_comment = 1 << 14;
-
-json_value * json_parse_ex (json_settings * settings,
- const json_char * json,
- size_t length,
- char * error_buf)
-{
- json_char error [json_error_max];
- const json_char * end;
- json_value * top, * root, * alloc = 0;
- json_state state;
- state.used_memory = 0;
- state.uint_max = 0;
- state.ulong_max = 0;
- state.settings.max_memory = 0;
- state.settings.mem_alloc = NULL;
- state.settings.mem_free = NULL;
- state.settings.settings = 0;
- state.settings.user_data = NULL;
- state.settings.value_extra = 0;
- state.first_pass = 0;
- state.ptr = NULL;
- state.cur_col = 0;
- state.cur_line = 0;
-
- long flags;
- long num_digits = 0, num_e = 0;
- json_int_t num_fraction = 0;
-
- /* Skip UTF-8 BOM
- */
- if (length >= 3 && ((unsigned char) json [0]) == 0xEF
- && ((unsigned char) json [1]) == 0xBB
- && ((unsigned char) json [2]) == 0xBF)
- {
- json += 3;
- length -= 3;
- }
-
- error[0] = '\0';
- end = (json + length);
-
- memcpy (&state.settings, settings, sizeof (json_settings));
-
- if (!state.settings.mem_alloc)
- state.settings.mem_alloc = default_alloc;
-
- if (!state.settings.mem_free)
- state.settings.mem_free = default_free;
-
- memset (&state.uint_max, 0xFF, sizeof (state.uint_max));
- memset (&state.ulong_max, 0xFF, sizeof (state.ulong_max));
-
- state.uint_max -= 8; /* limit of how much can be added before next check */
- state.ulong_max -= 8;
-
- for (state.first_pass = 1; state.first_pass >= 0; -- state.first_pass)
- {
- json_uchar uchar;
- unsigned char uc_b1, uc_b2, uc_b3, uc_b4;
- json_char * string = 0;
- unsigned int string_length = 0;
-
- top = root = 0;
- flags = flag_seek_value;
-
- state.cur_line = 1;
-
- for (state.ptr = json ;; ++ state.ptr)
- {
- json_char b = (state.ptr == end ? 0 : *state.ptr);
-
- if (flags & flag_string)
- {
- if (!b)
- { sprintf (error, "Unexpected EOF in string (at %d:%d)", line_and_col);
- goto e_failed;
- }
-
- if (string_length > state.uint_max)
- goto e_overflow;
-
- if (flags & flag_escaped)
- {
- flags &= ~ flag_escaped;
-
- switch (b)
- {
- case 'b': string_add ('\b'); break;
- case 'f': string_add ('\f'); break;
- case 'n': string_add ('\n'); break;
- case 'r': string_add ('\r'); break;
- case 't': string_add ('\t'); break;
- case 'u':
-
- if (end - state.ptr < 4 ||
- (uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
- (uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
- (uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
- (uc_b4 = hex_value (*++ state.ptr)) == 0xFF)
- {
- sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col);
- goto e_failed;
- }
-
- uc_b1 = (uc_b1 << 4) | uc_b2;
- uc_b2 = (uc_b3 << 4) | uc_b4;
- uchar = (uc_b1 << 8) | uc_b2;
-
- if ((uchar & 0xF800) == 0xD800) {
- json_uchar uchar2;
-
- if (end - state.ptr < 6 || (*++ state.ptr) != '\\' || (*++ state.ptr) != 'u' ||
- (uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
- (uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
- (uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
- (uc_b4 = hex_value (*++ state.ptr)) == 0xFF)
- {
- sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col);
- goto e_failed;
- }
-
- uc_b1 = (uc_b1 << 4) | uc_b2;
- uc_b2 = (uc_b3 << 4) | uc_b4;
- uchar2 = (uc_b1 << 8) | uc_b2;
-
- uchar = 0x010000 + ((uchar & 0x3FF) << 10) | (uchar2 & 0x3FF);
- }
-
- if (sizeof (json_char) >= sizeof (json_uchar) || (uchar <= 0x7F))
- {
- string_add ((json_char) uchar);
- break;
- }
-
- if (uchar <= 0x7FF)
- {
- if (state.first_pass)
- string_length += 2;
- else
- { string [string_length ++] = 0xC0 | (uchar >> 6);
- string [string_length ++] = 0x80 | (uchar & 0x3F);
- }
-
- break;
- }
-
- if (uchar <= 0xFFFF) {
- if (state.first_pass)
- string_length += 3;
- else
- { string [string_length ++] = 0xE0 | (uchar >> 12);
- string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F);
- string [string_length ++] = 0x80 | (uchar & 0x3F);
- }
-
- break;
- }
-
- if (state.first_pass)
- string_length += 4;
- else
- { string [string_length ++] = 0xF0 | (uchar >> 18);
- string [string_length ++] = 0x80 | ((uchar >> 12) & 0x3F);
- string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F);
- string [string_length ++] = 0x80 | (uchar & 0x3F);
- }
-
- break;
-
- default:
- string_add (b);
- };
-
- continue;
- }
-
- if (b == '\\')
- {
- flags |= flag_escaped;
- continue;
- }
-
- if (b == '"')
- {
- if (!state.first_pass)
- string [string_length] = 0;
-
- flags &= ~ flag_string;
- string = 0;
-
- switch (top->type)
- {
- case json_string:
-
- top->u.string.length = string_length;
- flags |= flag_next;
-
- break;
-
- case json_object:
-
- if (state.first_pass)
- (*(json_char **) &top->u.object.values) += string_length + 1;
- else
- {
- top->u.object.values [top->u.object.length].name
- = (json_char *) top->_reserved.object_mem;
-
- top->u.object.values [top->u.object.length].name_length
- = string_length;
-
- (*(json_char **) &top->_reserved.object_mem) += string_length + 1;
- }
-
- flags |= flag_seek_value | flag_need_colon;
- continue;
-
- default:
- break;
- };
- }
- else
- {
- string_add (b);
- continue;
- }
- }
-
- if (state.settings.settings & json_enable_comments)
- {
- if (flags & (flag_line_comment | flag_block_comment))
- {
- if (flags & flag_line_comment)
- {
- if (b == '\r' || b == '\n' || !b)
- {
- flags &= ~ flag_line_comment;
- -- state.ptr; /* so null can be reproc'd */
- }
-
- continue;
- }
-
- if (flags & flag_block_comment)
- {
- if (!b)
- { sprintf (error, "%d:%d: Unexpected EOF in block comment", line_and_col);
- goto e_failed;
- }
-
- if (b == '*' && state.ptr < (end - 1) && state.ptr [1] == '/')
- {
- flags &= ~ flag_block_comment;
- ++ state.ptr; /* skip closing sequence */
- }
-
- continue;
- }
- }
- else if (b == '/')
- {
- if (! (flags & (flag_seek_value | flag_done)) && top->type != json_object)
- { sprintf (error, "%d:%d: Comment not allowed here", line_and_col);
- goto e_failed;
- }
-
- if (++ state.ptr == end)
- { sprintf (error, "%d:%d: EOF unexpected", line_and_col);
- goto e_failed;
- }
-
- switch (b = *state.ptr)
- {
- case '/':
- flags |= flag_line_comment;
- continue;
-
- case '*':
- flags |= flag_block_comment;
- continue;
-
- default:
- sprintf (error, "%d:%d: Unexpected `%c` in comment opening sequence", line_and_col, b);
- goto e_failed;
- };
- }
- }
-
- if (flags & flag_done)
- {
- if (!b)
- break;
-
- switch (b)
- {
- whitespace:
- continue;
-
- default:
-
- sprintf (error, "%d:%d: Trailing garbage: `%c`",
- state.cur_line, state.cur_col, b);
-
- goto e_failed;
- };
- }
-
- if (flags & flag_seek_value)
- {
- switch (b)
- {
- whitespace:
- continue;
-
- case ']':
-
- if (top && top->type == json_array)
- flags = (flags & ~ (flag_need_comma | flag_seek_value)) | flag_next;
- else
- { sprintf (error, "%d:%d: Unexpected ]", line_and_col);
- goto e_failed;
- }
-
- break;
-
- default:
-
- if (flags & flag_need_comma)
- {
- if (b == ',')
- { flags &= ~ flag_need_comma;
- continue;
- }
- else
- {
- sprintf (error, "%d:%d: Expected , before %c",
- state.cur_line, state.cur_col, b);
-
- goto e_failed;
- }
- }
-
- if (flags & flag_need_colon)
- {
- if (b == ':')
- { flags &= ~ flag_need_colon;
- continue;
- }
- else
- {
- sprintf (error, "%d:%d: Expected : before %c",
- state.cur_line, state.cur_col, b);
-
- goto e_failed;
- }
- }
-
- flags &= ~ flag_seek_value;
-
- switch (b)
- {
- case '{':
-
- if (!new_value (&state, &top, &root, &alloc, json_object))
- goto e_alloc_failure;
-
- continue;
-
- case '[':
-
- if (!new_value (&state, &top, &root, &alloc, json_array))
- goto e_alloc_failure;
-
- flags |= flag_seek_value;
- continue;
-
- case '"':
-
- if (!new_value (&state, &top, &root, &alloc, json_string))
- goto e_alloc_failure;
-
- flags |= flag_string;
-
- string = top->u.string.ptr;
- string_length = 0;
-
- continue;
-
- case 't':
-
- if ((end - state.ptr) < 3 || *(++ state.ptr) != 'r' ||
- *(++ state.ptr) != 'u' || *(++ state.ptr) != 'e')
- {
- goto e_unknown_value;
- }
-
- if (!new_value (&state, &top, &root, &alloc, json_boolean))
- goto e_alloc_failure;
-
- top->u.boolean = 1;
-
- flags |= flag_next;
- break;
-
- case 'f':
-
- if ((end - state.ptr) < 4 || *(++ state.ptr) != 'a' ||
- *(++ state.ptr) != 'l' || *(++ state.ptr) != 's' ||
- *(++ state.ptr) != 'e')
- {
- goto e_unknown_value;
- }
-
- if (!new_value (&state, &top, &root, &alloc, json_boolean))
- goto e_alloc_failure;
-
- flags |= flag_next;
- break;
-
- case 'n':
-
- if ((end - state.ptr) < 3 || *(++ state.ptr) != 'u' ||
- *(++ state.ptr) != 'l' || *(++ state.ptr) != 'l')
- {
- goto e_unknown_value;
- }
-
- if (!new_value (&state, &top, &root, &alloc, json_null))
- goto e_alloc_failure;
-
- flags |= flag_next;
- break;
-
- default:
-
- if (isdigit (b) || b == '-')
- {
- if (!new_value (&state, &top, &root, &alloc, json_integer))
- goto e_alloc_failure;
-
- if (!state.first_pass)
- {
- while (isdigit (b) || b == '+' || b == '-'
- || b == 'e' || b == 'E' || b == '.')
- {
- if ( (++ state.ptr) == end)
- {
- b = 0;
- break;
- }
-
- b = *state.ptr;
- }
-
- flags |= flag_next | flag_reproc;
- break;
- }
-
- flags &= ~ (flag_num_negative | flag_num_e |
- flag_num_e_got_sign | flag_num_e_negative |
- flag_num_zero);
-
- num_digits = 0;
- num_fraction = 0;
- num_e = 0;
-
- if (b != '-')
- {
- flags |= flag_reproc;
- break;
- }
-
- flags |= flag_num_negative;
- continue;
- }
- else
- { sprintf (error, "%d:%d: Unexpected %c when seeking value", line_and_col, b);
- goto e_failed;
- }
- };
- };
- }
- else
- {
- switch (top->type)
- {
- case json_object:
-
- switch (b)
- {
- whitespace:
- continue;
-
- case '"':
-
- if (flags & flag_need_comma)
- { sprintf (error, "%d:%d: Expected , before \"", line_and_col);
- goto e_failed;
- }
-
- flags |= flag_string;
-
- string = (json_char *) top->_reserved.object_mem;
- string_length = 0;
-
- break;
-
- case '}':
-
- flags = (flags & ~ flag_need_comma) | flag_next;
- break;
-
- case ',':
-
- if (flags & flag_need_comma)
- {
- flags &= ~ flag_need_comma;
- break;
- }
-
- default:
- sprintf (error, "%d:%d: Unexpected `%c` in object", line_and_col, b);
- goto e_failed;
- };
-
- break;
-
- case json_integer:
- case json_double:
-
- if (isdigit (b))
- {
- ++ num_digits;
-
- if (top->type == json_integer || flags & flag_num_e)
- {
- if (! (flags & flag_num_e))
- {
- if (flags & flag_num_zero)
- { sprintf (error, "%d:%d: Unexpected `0` before `%c`", line_and_col, b);
- goto e_failed;
- }
-
- if (num_digits == 1 && b == '0')
- flags |= flag_num_zero;
- }
- else
- {
- flags |= flag_num_e_got_sign;
- num_e = (num_e * 10) + (b - '0');
- continue;
- }
-
- top->u.integer = (top->u.integer * 10) + (b - '0');
- continue;
- }
-
- num_fraction = (num_fraction * 10) + (b - '0');
- continue;
- }
-
- if (b == '+' || b == '-')
- {
- if ( (flags & flag_num_e) && !(flags & flag_num_e_got_sign))
- {
- flags |= flag_num_e_got_sign;
-
- if (b == '-')
- flags |= flag_num_e_negative;
-
- continue;
- }
- }
- else if (b == '.' && top->type == json_integer)
- {
- if (!num_digits)
- { sprintf (error, "%d:%d: Expected digit before `.`", line_and_col);
- goto e_failed;
- }
-
- top->type = json_double;
- top->u.dbl = (double) top->u.integer;
-
- num_digits = 0;
- continue;
- }
-
- if (! (flags & flag_num_e))
- {
- if (top->type == json_double)
- {
- if (!num_digits)
- { sprintf (error, "%d:%d: Expected digit after `.`", line_and_col);
- goto e_failed;
- }
-
- top->u.dbl += ((double) num_fraction) / (pow (10.0, (double) num_digits));
- }
-
- if (b == 'e' || b == 'E')
- {
- flags |= flag_num_e;
-
- if (top->type == json_integer)
- {
- top->type = json_double;
- top->u.dbl = (double) top->u.integer;
- }
-
- num_digits = 0;
- flags &= ~ flag_num_zero;
-
- continue;
- }
- }
- else
- {
- if (!num_digits)
- { sprintf (error, "%d:%d: Expected digit after `e`", line_and_col);
- goto e_failed;
- }
-
- top->u.dbl *= pow (10.0, (double)
- (flags & flag_num_e_negative ? - num_e : num_e));
- }
-
- if (flags & flag_num_negative)
- {
- if (top->type == json_integer)
- top->u.integer = - top->u.integer;
- else
- top->u.dbl = - top->u.dbl;
- }
-
- flags |= flag_next | flag_reproc;
- break;
-
- default:
- break;
- };
- }
-
- if (flags & flag_reproc)
- {
- flags &= ~ flag_reproc;
- -- state.ptr;
- }
-
- if (flags & flag_next)
- {
- flags = (flags & ~ flag_next) | flag_need_comma;
-
- if (!top->parent)
- {
- /* root value done */
-
- flags |= flag_done;
- continue;
- }
-
- if (top->parent->type == json_array)
- flags |= flag_seek_value;
-
- if (!state.first_pass)
- {
- json_value * parent = top->parent;
-
- switch (parent->type)
- {
- case json_object:
-
- parent->u.object.values
- [parent->u.object.length].value = top;
-
- break;
-
- case json_array:
-
- parent->u.array.values
- [parent->u.array.length] = top;
-
- break;
-
- default:
- break;
- };
- }
-
- if ( (++ top->parent->u.array.length) > state.uint_max)
- goto e_overflow;
-
- top = top->parent;
-
- continue;
- }
- }
-
- alloc = root;
- }
-
- return root;
-
-e_unknown_value:
-
- sprintf (error, "%d:%d: Unknown value", line_and_col);
- goto e_failed;
-
-e_alloc_failure:
-
- strcpy (error, "Memory allocation failure");
- goto e_failed;
-
-e_overflow:
-
- sprintf (error, "%d:%d: Too long (caught overflow)", line_and_col);
- goto e_failed;
-
-e_failed:
-
- if (error_buf)
- {
- if (*error)
- strcpy (error_buf, error);
- else
- strcpy (error_buf, "Unknown error");
- }
-
- if (state.first_pass)
- alloc = root;
-
- while (alloc)
- {
- top = alloc->_reserved.next_alloc;
- state.settings.mem_free (alloc, state.settings.user_data);
- alloc = top;
- }
-
- if (!state.first_pass)
- json_value_free_ex (&state.settings, root);
-
- return 0;
-}
-
-json_value * json_parse (const json_char * json, size_t length)
-{
- json_settings settings;
- settings.max_memory = 0;
- settings.settings = 0;
- settings.mem_alloc = NULL;
- settings.mem_free = NULL;
- settings.user_data = NULL;
- settings.value_extra = 0;
- return json_parse_ex (&settings, json, length, 0);
-}
-
-void json_value_free_ex (json_settings * settings, json_value * value)
-{
- json_value * cur_value;
-
- if (!value)
- return;
-
- value->parent = 0;
-
- while (value)
- {
- switch (value->type)
- {
- case json_array:
-
- if (!value->u.array.length)
- {
- settings->mem_free (value->u.array.values, settings->user_data);
- break;
- }
-
- value = value->u.array.values [-- value->u.array.length];
- continue;
-
- case json_object:
-
- if (!value->u.object.length)
- {
- settings->mem_free (value->u.object.values, settings->user_data);
- break;
- }
-
- value = value->u.object.values [-- value->u.object.length].value;
- continue;
-
- case json_string:
-#ifdef CARYLL_USE_PRE_SERIALIZED
- case json_pre_serialized:
-#endif
- settings->mem_free (value->u.string.ptr, settings->user_data);
- break;
-
- default:
- break;
- };
-
- cur_value = value;
- value = value->parent;
- settings->mem_free (cur_value, settings->user_data);
- }
-}
-
-void json_value_free (json_value * value)
-{
- json_settings settings;
- settings.max_memory = 0;
- settings.settings = 0;
- settings.mem_alloc = NULL;
- settings.mem_free = NULL;
- settings.user_data = NULL;
- settings.value_extra = 0;
- settings.mem_free = default_free;
- json_value_free_ex (&settings, value);
-}
-
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sds.c b/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sds.c
deleted file mode 100644
index fbb90ebbf1d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sds.c
+++ /dev/null
@@ -1,1264 +0,0 @@
-/* SDSLib 2.0 -- A C dynamic strings library
- *
- * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com>
- * Copyright (c) 2015, Redis Labs, Inc
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Redis nor the names of its contributors may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-#include "sds.h"
-#include "sdsalloc.h"
-
-static inline int sdsHdrSize(char type) {
- switch(type&SDS_TYPE_MASK) {
- case SDS_TYPE_5:
- return sizeof(struct sdshdr5);
- case SDS_TYPE_8:
- return sizeof(struct sdshdr8);
- case SDS_TYPE_16:
- return sizeof(struct sdshdr16);
- case SDS_TYPE_32:
- return sizeof(struct sdshdr32);
- case SDS_TYPE_64:
- return sizeof(struct sdshdr64);
- }
- return 0;
-}
-
-static inline char sdsReqType(size_t string_size) {
- if (string_size < 32)
- return SDS_TYPE_5;
- if (string_size < 0xff)
- return SDS_TYPE_8;
- if (string_size < 0xffff)
- return SDS_TYPE_16;
- if (string_size < 0xffffffff)
- return SDS_TYPE_32;
- return SDS_TYPE_64;
-}
-
-/* Create a new sds string with the content specified by the 'init' pointer
- * and 'initlen'.
- * If NULL is used for 'init' the string is initialized with zero bytes.
- *
- * The string is always null-termined (all the sds strings are, always) so
- * even if you create an sds string with:
- *
- * mystring = sdsnewlen("abc",3);
- *
- * You can print the string with printf() as there is an implicit \0 at the
- * end of the string. However the string is binary safe and can contain
- * \0 characters in the middle, as the length is stored in the sds header. */
-sds sdsnewlen(const void *init, size_t initlen) {
- void *sh;
- sds s;
- char type = sdsReqType(initlen);
- /* Empty strings are usually created in order to append. Use type 8
- * since type 5 is not good at this. */
- if (type == SDS_TYPE_5 && initlen == 0) type = SDS_TYPE_8;
- int hdrlen = sdsHdrSize(type);
- unsigned char *fp; /* flags pointer. */
-
- sh = s_malloc(hdrlen+initlen+1);
- if (!init)
- memset(sh, 0, hdrlen+initlen+1);
- if (sh == NULL) return NULL;
- s = (char*)sh+hdrlen;
- fp = ((unsigned char*)s)-1;
- switch(type) {
- case SDS_TYPE_5: {
- *fp = type | (initlen << SDS_TYPE_BITS);
- break;
- }
- case SDS_TYPE_8: {
- SDS_HDR_VAR(8,s);
- sh->len = initlen;
- sh->alloc = initlen;
- *fp = type;
- break;
- }
- case SDS_TYPE_16: {
- SDS_HDR_VAR(16,s);
- sh->len = initlen;
- sh->alloc = initlen;
- *fp = type;
- break;
- }
- case SDS_TYPE_32: {
- SDS_HDR_VAR(32,s);
- sh->len = initlen;
- sh->alloc = initlen;
- *fp = type;
- break;
- }
- case SDS_TYPE_64: {
- SDS_HDR_VAR(64,s);
- sh->len = initlen;
- sh->alloc = initlen;
- *fp = type;
- break;
- }
- }
- if (initlen && init)
- memcpy(s, init, initlen);
- s[initlen] = '\0';
- return s;
-}
-
-/* Create an empty (zero length) sds string. Even in this case the string
- * always has an implicit null term. */
-sds sdsempty(void) {
- return sdsnewlen("",0);
-}
-
-/* Create a new sds string starting from a null terminated C string. */
-sds sdsnew(const char *init) {
- size_t initlen = (init == NULL) ? 0 : strlen(init);
- return sdsnewlen(init, initlen);
-}
-
-/* Duplicate an sds string. */
-sds sdsdup(const sds s) {
- return sdsnewlen(s, sdslen(s));
-}
-
-/* Free an sds string. No operation is performed if 's' is NULL. */
-void sdsfree(sds s) {
- if (s == NULL) return;
- s_free((char*)s-sdsHdrSize(s[-1]));
-}
-
-/* Set the sds string length to the length as obtained with strlen(), so
- * considering as content only up to the first null term character.
- *
- * This function is useful when the sds string is hacked manually in some
- * way, like in the following example:
- *
- * s = sdsnew("foobar");
- * s[2] = '\0';
- * sdsupdatelen(s);
- * printf("%d\n", sdslen(s));
- *
- * The output will be "2", but if we comment out the call to sdsupdatelen()
- * the output will be "6" as the string was modified but the logical length
- * remains 6 bytes. */
-void sdsupdatelen(sds s) {
- int reallen = strlen(s);
- sdssetlen(s, reallen);
-}
-
-/* Modify an sds string in-place to make it empty (zero length).
- * However all the existing buffer is not discarded but set as free space
- * so that next append operations will not require allocations up to the
- * number of bytes previously available. */
-void sdsclear(sds s) {
- sdssetlen(s, 0);
- s[0] = '\0';
-}
-
-/* Enlarge the free space at the end of the sds string so that the caller
- * is sure that after calling this function can overwrite up to addlen
- * bytes after the end of the string, plus one more byte for nul term.
- *
- * Note: this does not change the *length* of the sds string as returned
- * by sdslen(), but only the free buffer space we have. */
-sds sdsMakeRoomFor(sds s, size_t addlen) {
- void *sh, *newsh;
- size_t avail = sdsavail(s);
- size_t len, newlen;
- char type, oldtype = s[-1] & SDS_TYPE_MASK;
- int hdrlen;
-
- /* Return ASAP if there is enough space left. */
- if (avail >= addlen) return s;
-
- len = sdslen(s);
- sh = (char*)s-sdsHdrSize(oldtype);
- newlen = (len+addlen);
- if (newlen < SDS_MAX_PREALLOC)
- newlen *= 2;
- else
- newlen += SDS_MAX_PREALLOC;
-
- type = sdsReqType(newlen);
-
- /* Don't use type 5: the user is appending to the string and type 5 is
- * not able to remember empty space, so sdsMakeRoomFor() must be called
- * at every appending operation. */
- if (type == SDS_TYPE_5) type = SDS_TYPE_8;
-
- hdrlen = sdsHdrSize(type);
- if (oldtype==type) {
- newsh = s_realloc(sh, hdrlen+newlen+1);
- if (newsh == NULL) return NULL;
- s = (char*)newsh+hdrlen;
- } else {
- /* Since the header size changes, need to move the string forward,
- * and can't use realloc */
- newsh = s_malloc(hdrlen+newlen+1);
- if (newsh == NULL) return NULL;
- memcpy((char*)newsh+hdrlen, s, len+1);
- s_free(sh);
- s = (char*)newsh+hdrlen;
- s[-1] = type;
- sdssetlen(s, len);
- }
- sdssetalloc(s, newlen);
- return s;
-}
-
-/* Reallocate the sds string so that it has no free space at the end. The
- * contained string remains not altered, but next concatenation operations
- * will require a reallocation.
- *
- * After the call, the passed sds string is no longer valid and all the
- * references must be substituted with the new pointer returned by the call. */
-sds sdsRemoveFreeSpace(sds s) {
- void *sh, *newsh;
- char type, oldtype = s[-1] & SDS_TYPE_MASK;
- int hdrlen;
- size_t len = sdslen(s);
- sh = (char*)s-sdsHdrSize(oldtype);
-
- type = sdsReqType(len);
- hdrlen = sdsHdrSize(type);
- if (oldtype==type) {
- newsh = s_realloc(sh, hdrlen+len+1);
- if (newsh == NULL) return NULL;
- s = (char*)newsh+hdrlen;
- } else {
- newsh = s_malloc(hdrlen+len+1);
- if (newsh == NULL) return NULL;
- memcpy((char*)newsh+hdrlen, s, len+1);
- s_free(sh);
- s = (char*)newsh+hdrlen;
- s[-1] = type;
- sdssetlen(s, len);
- }
- sdssetalloc(s, len);
- return s;
-}
-
-/* Return the total size of the allocation of the specifed sds string,
- * including:
- * 1) The sds header before the pointer.
- * 2) The string.
- * 3) The free buffer at the end if any.
- * 4) The implicit null term.
- */
-size_t sdsAllocSize(sds s) {
- size_t alloc = sdsalloc(s);
- return sdsHdrSize(s[-1])+alloc+1;
-}
-
-/* Return the pointer of the actual SDS allocation (normally SDS strings
- * are referenced by the start of the string buffer). */
-void *sdsAllocPtr(sds s) {
- return (void*) (s-sdsHdrSize(s[-1]));
-}
-
-/* Increment the sds length and decrements the left free space at the
- * end of the string according to 'incr'. Also set the null term
- * in the new end of the string.
- *
- * This function is used in order to fix the string length after the
- * user calls sdsMakeRoomFor(), writes something after the end of
- * the current string, and finally needs to set the new length.
- *
- * Note: it is possible to use a negative increment in order to
- * right-trim the string.
- *
- * Usage example:
- *
- * Using sdsIncrLen() and sdsMakeRoomFor() it is possible to mount the
- * following schema, to cat bytes coming from the kernel to the end of an
- * sds string without copying into an intermediate buffer:
- *
- * oldlen = sdslen(s);
- * s = sdsMakeRoomFor(s, BUFFER_SIZE);
- * nread = read(fd, s+oldlen, BUFFER_SIZE);
- * ... check for nread <= 0 and handle it ...
- * sdsIncrLen(s, nread);
- */
-void sdsIncrLen(sds s, int incr) {
- unsigned char flags = s[-1];
- size_t len;
- switch(flags&SDS_TYPE_MASK) {
- case SDS_TYPE_5: {
- unsigned char *fp = ((unsigned char*)s)-1;
- unsigned char oldlen = SDS_TYPE_5_LEN(flags);
- assert((incr > 0 && oldlen+incr < 32) || (incr < 0 && oldlen >= (unsigned int)(-incr)));
- *fp = SDS_TYPE_5 | ((oldlen+incr) << SDS_TYPE_BITS);
- len = oldlen+incr;
- break;
- }
- case SDS_TYPE_8: {
- SDS_HDR_VAR(8,s);
- assert((incr >= 0 && sh->alloc-sh->len >= incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
- len = (sh->len += incr);
- break;
- }
- case SDS_TYPE_16: {
- SDS_HDR_VAR(16,s);
- assert((incr >= 0 && sh->alloc-sh->len >= incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
- len = (sh->len += incr);
- break;
- }
- case SDS_TYPE_32: {
- SDS_HDR_VAR(32,s);
- assert((incr >= 0 && sh->alloc-sh->len >= (unsigned int)incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
- len = (sh->len += incr);
- break;
- }
- case SDS_TYPE_64: {
- SDS_HDR_VAR(64,s);
- assert((incr >= 0 && sh->alloc-sh->len >= (uint64_t)incr) || (incr < 0 && sh->len >= (uint64_t)(-incr)));
- len = (sh->len += incr);
- break;
- }
- default: len = 0; /* Just to avoid compilation warnings. */
- }
- s[len] = '\0';
-}
-
-/* Grow the sds to have the specified length. Bytes that were not part of
- * the original length of the sds will be set to zero.
- *
- * if the specified length is smaller than the current length, no operation
- * is performed. */
-sds sdsgrowzero(sds s, size_t len) {
- size_t curlen = sdslen(s);
-
- if (len <= curlen) return s;
- s = sdsMakeRoomFor(s,len-curlen);
- if (s == NULL) return NULL;
-
- /* Make sure added region doesn't contain garbage */
- memset(s+curlen,0,(len-curlen+1)); /* also set trailing \0 byte */
- sdssetlen(s, len);
- return s;
-}
-
-/* Append the specified binary-safe string pointed by 't' of 'len' bytes to the
- * end of the specified sds string 's'.
- *
- * After the call, the passed sds string is no longer valid and all the
- * references must be substituted with the new pointer returned by the call. */
-sds sdscatlen(sds s, const void *t, size_t len) {
- size_t curlen = sdslen(s);
-
- s = sdsMakeRoomFor(s,len);
- if (s == NULL) return NULL;
- memcpy(s+curlen, t, len);
- sdssetlen(s, curlen+len);
- s[curlen+len] = '\0';
- return s;
-}
-
-/* Append the specified null termianted C string to the sds string 's'.
- *
- * After the call, the passed sds string is no longer valid and all the
- * references must be substituted with the new pointer returned by the call. */
-sds sdscat(sds s, const char *t) {
- return sdscatlen(s, t, strlen(t));
-}
-
-/* Append the specified sds 't' to the existing sds 's'.
- *
- * After the call, the modified sds string is no longer valid and all the
- * references must be substituted with the new pointer returned by the call. */
-sds sdscatsds(sds s, const sds t) {
- return sdscatlen(s, t, sdslen(t));
-}
-
-/* Destructively modify the sds string 's' to hold the specified binary
- * safe string pointed by 't' of length 'len' bytes. */
-sds sdscpylen(sds s, const char *t, size_t len) {
- if (sdsalloc(s) < len) {
- s = sdsMakeRoomFor(s,len-sdslen(s));
- if (s == NULL) return NULL;
- }
- memcpy(s, t, len);
- s[len] = '\0';
- sdssetlen(s, len);
- return s;
-}
-
-/* Like sdscpylen() but 't' must be a null-termined string so that the length
- * of the string is obtained with strlen(). */
-sds sdscpy(sds s, const char *t) {
- return sdscpylen(s, t, strlen(t));
-}
-
-/* Helper for sdscatlonglong() doing the actual number -> string
- * conversion. 's' must point to a string with room for at least
- * SDS_LLSTR_SIZE bytes.
- *
- * The function returns the length of the null-terminated string
- * representation stored at 's'. */
-#define SDS_LLSTR_SIZE 21
-static int sdsll2str(char *s, long long value) {
- char *p, aux;
- unsigned long long v;
- size_t l;
-
- /* Generate the string representation, this method produces
- * an reversed string. */
- v = (value < 0) ? -value : value;
- p = s;
- do {
- *p++ = '0'+(v%10);
- v /= 10;
- } while(v);
- if (value < 0) *p++ = '-';
-
- /* Compute length and add null term. */
- l = p-s;
- *p = '\0';
-
- /* Reverse the string. */
- p--;
- while(s < p) {
- aux = *s;
- *s = *p;
- *p = aux;
- s++;
- p--;
- }
- return l;
-}
-
-/* Identical sdsll2str(), but for unsigned long long type. */
-static int sdsull2str(char *s, unsigned long long v) {
- char *p, aux;
- size_t l;
-
- /* Generate the string representation, this method produces
- * an reversed string. */
- p = s;
- do {
- *p++ = '0'+(v%10);
- v /= 10;
- } while(v);
-
- /* Compute length and add null term. */
- l = p-s;
- *p = '\0';
-
- /* Reverse the string. */
- p--;
- while(s < p) {
- aux = *s;
- *s = *p;
- *p = aux;
- s++;
- p--;
- }
- return l;
-}
-
-/* Create an sds string from a long long value. It is much faster than:
- *
- * sdscatprintf(sdsempty(),"%lld\n", value);
- */
-sds sdsfromlonglong(long long value) {
- char buf[SDS_LLSTR_SIZE];
- int len = sdsll2str(buf,value);
-
- return sdsnewlen(buf,len);
-}
-
-/* Like sdscatprintf() but gets va_list instead of being variadic. */
-sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
- va_list cpy;
- char staticbuf[1024], *buf = staticbuf, *t;
- size_t buflen = strlen(fmt)*2;
-
- /* We try to start using a static buffer for speed.
- * If not possible we revert to heap allocation. */
- if (buflen > sizeof(staticbuf)) {
- buf = s_malloc(buflen);
- if (buf == NULL) return NULL;
- } else {
- buflen = sizeof(staticbuf);
- }
-
- /* Try with buffers two times bigger every time we fail to
- * fit the string in the current buffer size. */
- while(1) {
- buf[buflen-2] = '\0';
- va_copy(cpy,ap);
- vsnprintf(buf, buflen, fmt, cpy);
- va_end(cpy);
- if (buf[buflen-2] != '\0') {
- if (buf != staticbuf) s_free(buf);
- buflen *= 2;
- buf = s_malloc(buflen);
- if (buf == NULL) return NULL;
- continue;
- }
- break;
- }
-
- /* Finally concat the obtained string to the SDS string and return it. */
- t = sdscat(s, buf);
- if (buf != staticbuf) s_free(buf);
- return t;
-}
-
-/* Append to the sds string 's' a string obtained using printf-alike format
- * specifier.
- *
- * After the call, the modified sds string is no longer valid and all the
- * references must be substituted with the new pointer returned by the call.
- *
- * Example:
- *
- * s = sdsnew("Sum is: ");
- * s = sdscatprintf(s,"%d+%d = %d",a,b,a+b).
- *
- * Often you need to create a string from scratch with the printf-alike
- * format. When this is the need, just use sdsempty() as the target string:
- *
- * s = sdscatprintf(sdsempty(), "... your format ...", args);
- */
-sds sdscatprintf(sds s, const char *fmt, ...) {
- va_list ap;
- char *t;
- va_start(ap, fmt);
- t = sdscatvprintf(s,fmt,ap);
- va_end(ap);
- return t;
-}
-
-/* This function is similar to sdscatprintf, but much faster as it does
- * not rely on sprintf() family functions implemented by the libc that
- * are often very slow. Moreover directly handling the sds string as
- * new data is concatenated provides a performance improvement.
- *
- * However this function only handles an incompatible subset of printf-alike
- * format specifiers:
- *
- * %s - C String
- * %S - SDS string
- * %i - signed int
- * %I - 64 bit signed integer (long long, int64_t)
- * %u - unsigned int
- * %U - 64 bit unsigned integer (unsigned long long, uint64_t)
- * %% - Verbatim "%" character.
- */
-sds sdscatfmt(sds s, char const *fmt, ...) {
- size_t initlen = sdslen(s);
- const char *f = fmt;
- int i;
- va_list ap;
-
- va_start(ap,fmt);
- f = fmt; /* Next format specifier byte to process. */
- i = initlen; /* Position of the next byte to write to dest str. */
- while(*f) {
- char next, *str;
- size_t l;
- long long num;
- unsigned long long unum;
-
- /* Make sure there is always space for at least 1 char. */
- if (sdsavail(s)==0) {
- s = sdsMakeRoomFor(s,1);
- }
-
- switch(*f) {
- case '%':
- next = *(f+1);
- f++;
- switch(next) {
- case 's':
- case 'S':
- str = va_arg(ap,char*);
- l = (next == 's') ? strlen(str) : sdslen(str);
- if (sdsavail(s) < l) {
- s = sdsMakeRoomFor(s,l);
- }
- memcpy(s+i,str,l);
- sdsinclen(s,l);
- i += l;
- break;
- case 'i':
- case 'I':
- if (next == 'i')
- num = va_arg(ap,int);
- else
- num = va_arg(ap,long long);
- {
- char buf[SDS_LLSTR_SIZE];
- l = sdsll2str(buf,num);
- if (sdsavail(s) < l) {
- s = sdsMakeRoomFor(s,l);
- }
- memcpy(s+i,buf,l);
- sdsinclen(s,l);
- i += l;
- }
- break;
- case 'u':
- case 'U':
- if (next == 'u')
- unum = va_arg(ap,unsigned int);
- else
- unum = va_arg(ap,unsigned long long);
- {
- char buf[SDS_LLSTR_SIZE];
- l = sdsull2str(buf,unum);
- if (sdsavail(s) < l) {
- s = sdsMakeRoomFor(s,l);
- }
- memcpy(s+i,buf,l);
- sdsinclen(s,l);
- i += l;
- }
- break;
- default: /* Handle %% and generally %<unknown>. */
- s[i++] = next;
- sdsinclen(s,1);
- break;
- }
- break;
- default:
- s[i++] = *f;
- sdsinclen(s,1);
- break;
- }
- f++;
- }
- va_end(ap);
-
- /* Add null-term */
- s[i] = '\0';
- return s;
-}
-
-/* Remove the part of the string from left and from right composed just of
- * contiguous characters found in 'cset', that is a null terminted C string.
- *
- * After the call, the modified sds string is no longer valid and all the
- * references must be substituted with the new pointer returned by the call.
- *
- * Example:
- *
- * s = sdsnew("AA...AA.a.aa.aHelloWorld :::");
- * s = sdstrim(s,"Aa. :");
- * printf("%s\n", s);
- *
- * Output will be just "Hello World".
- */
-sds sdstrim(sds s, const char *cset) {
- char *start, *end, *sp, *ep;
- size_t len;
-
- sp = start = s;
- ep = end = s+sdslen(s)-1;
- while(sp <= end && strchr(cset, *sp)) sp++;
- while(ep > sp && strchr(cset, *ep)) ep--;
- len = (sp > ep) ? 0 : ((ep-sp)+1);
- if (s != sp) memmove(s, sp, len);
- s[len] = '\0';
- sdssetlen(s,len);
- return s;
-}
-
-/* Turn the string into a smaller (or equal) string containing only the
- * substring specified by the 'start' and 'end' indexes.
- *
- * start and end can be negative, where -1 means the last character of the
- * string, -2 the penultimate character, and so forth.
- *
- * The interval is inclusive, so the start and end characters will be part
- * of the resulting string.
- *
- * The string is modified in-place.
- *
- * Example:
- *
- * s = sdsnew("Hello World");
- * sdsrange(s,1,-1); => "ello World"
- */
-void sdsrange(sds s, int start, int end) {
- size_t newlen, len = sdslen(s);
-
- if (len == 0) return;
- if (start < 0) {
- start = len+start;
- if (start < 0) start = 0;
- }
- if (end < 0) {
- end = len+end;
- if (end < 0) end = 0;
- }
- newlen = (start > end) ? 0 : (end-start)+1;
- if (newlen != 0) {
- if (start >= (signed)len) {
- newlen = 0;
- } else if (end >= (signed)len) {
- end = len-1;
- newlen = (start > end) ? 0 : (end-start)+1;
- }
- } else {
- start = 0;
- }
- if (start && newlen) memmove(s, s+start, newlen);
- s[newlen] = 0;
- sdssetlen(s,newlen);
-}
-
-/* Apply tolower() to every character of the sds string 's'. */
-void sdstolower(sds s) {
- int len = sdslen(s), j;
-
- for (j = 0; j < len; j++) s[j] = tolower(s[j]);
-}
-
-/* Apply toupper() to every character of the sds string 's'. */
-void sdstoupper(sds s) {
- int len = sdslen(s), j;
-
- for (j = 0; j < len; j++) s[j] = toupper(s[j]);
-}
-
-/* Compare two sds strings s1 and s2 with memcmp().
- *
- * Return value:
- *
- * positive if s1 > s2.
- * negative if s1 < s2.
- * 0 if s1 and s2 are exactly the same binary string.
- *
- * If two strings share exactly the same prefix, but one of the two has
- * additional characters, the longer string is considered to be greater than
- * the smaller one. */
-int sdscmp(const sds s1, const sds s2) {
- size_t l1, l2, minlen;
- int cmp;
-
- l1 = sdslen(s1);
- l2 = sdslen(s2);
- minlen = (l1 < l2) ? l1 : l2;
- cmp = memcmp(s1,s2,minlen);
- if (cmp == 0) return l1-l2;
- return cmp;
-}
-
-/* Split 's' with separator in 'sep'. An array
- * of sds strings is returned. *count will be set
- * by reference to the number of tokens returned.
- *
- * On out of memory, zero length string, zero length
- * separator, NULL is returned.
- *
- * Note that 'sep' is able to split a string using
- * a multi-character separator. For example
- * sdssplit("foo_-_bar","_-_"); will return two
- * elements "foo" and "bar".
- *
- * This version of the function is binary-safe but
- * requires length arguments. sdssplit() is just the
- * same function but for zero-terminated strings.
- */
-sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count) {
- int elements = 0, slots = 5, start = 0, j;
- sds *tokens;
-
- if (seplen < 1 || len < 0) return NULL;
-
- tokens = s_malloc(sizeof(sds)*slots);
- if (tokens == NULL) return NULL;
-
- if (len == 0) {
- *count = 0;
- return tokens;
- }
- for (j = 0; j < (len-(seplen-1)); j++) {
- /* make sure there is room for the next element and the final one */
- if (slots < elements+2) {
- sds *newtokens;
-
- slots *= 2;
- newtokens = s_realloc(tokens,sizeof(sds)*slots);
- if (newtokens == NULL) goto cleanup;
- tokens = newtokens;
- }
- /* search the separator */
- if ((seplen == 1 && *(s+j) == sep[0]) || (memcmp(s+j,sep,seplen) == 0)) {
- tokens[elements] = sdsnewlen(s+start,j-start);
- if (tokens[elements] == NULL) goto cleanup;
- elements++;
- start = j+seplen;
- j = j+seplen-1; /* skip the separator */
- }
- }
- /* Add the final element. We are sure there is room in the tokens array. */
- tokens[elements] = sdsnewlen(s+start,len-start);
- if (tokens[elements] == NULL) goto cleanup;
- elements++;
- *count = elements;
- return tokens;
-
-cleanup:
- {
- int i;
- for (i = 0; i < elements; i++) sdsfree(tokens[i]);
- s_free(tokens);
- *count = 0;
- return NULL;
- }
-}
-
-/* Free the result returned by sdssplitlen(), or do nothing if 'tokens' is NULL. */
-void sdsfreesplitres(sds *tokens, int count) {
- if (!tokens) return;
- while(count--)
- sdsfree(tokens[count]);
- s_free(tokens);
-}
-
-/* Append to the sds string "s" an escaped string representation where
- * all the non-printable characters (tested with isprint()) are turned into
- * escapes in the form "\n\r\a...." or "\x<hex-number>".
- *
- * After the call, the modified sds string is no longer valid and all the
- * references must be substituted with the new pointer returned by the call. */
-sds sdscatrepr(sds s, const char *p, size_t len) {
- s = sdscatlen(s,"\"",1);
- while(len--) {
- switch(*p) {
- case '\\':
- case '"':
- s = sdscatprintf(s,"\\%c",*p);
- break;
- case '\n': s = sdscatlen(s,"\\n",2); break;
- case '\r': s = sdscatlen(s,"\\r",2); break;
- case '\t': s = sdscatlen(s,"\\t",2); break;
- case '\a': s = sdscatlen(s,"\\a",2); break;
- case '\b': s = sdscatlen(s,"\\b",2); break;
- default:
- if (isprint(*p))
- s = sdscatprintf(s,"%c",*p);
- else
- s = sdscatprintf(s,"\\x%02x",(unsigned char)*p);
- break;
- }
- p++;
- }
- return sdscatlen(s,"\"",1);
-}
-
-/* Helper function for sdssplitargs() that returns non zero if 'c'
- * is a valid hex digit. */
-static int is_hex_digit(char c) {
- return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
- (c >= 'A' && c <= 'F');
-}
-
-/* Helper function for sdssplitargs() that converts a hex digit into an
- * integer from 0 to 15 */
-static int hex_digit_to_int(char c) {
- switch(c) {
- case '0': return 0;
- case '1': return 1;
- case '2': return 2;
- case '3': return 3;
- case '4': return 4;
- case '5': return 5;
- case '6': return 6;
- case '7': return 7;
- case '8': return 8;
- case '9': return 9;
- case 'a': case 'A': return 10;
- case 'b': case 'B': return 11;
- case 'c': case 'C': return 12;
- case 'd': case 'D': return 13;
- case 'e': case 'E': return 14;
- case 'f': case 'F': return 15;
- default: return 0;
- }
-}
-
-/* Split a line into arguments, where every argument can be in the
- * following programming-language REPL-alike form:
- *
- * foo bar "newline are supported\n" and "\xff\x00otherstuff"
- *
- * The number of arguments is stored into *argc, and an array
- * of sds is returned.
- *
- * The caller should free the resulting array of sds strings with
- * sdsfreesplitres().
- *
- * Note that sdscatrepr() is able to convert back a string into
- * a quoted string in the same format sdssplitargs() is able to parse.
- *
- * The function returns the allocated tokens on success, even when the
- * input string is empty, or NULL if the input contains unbalanced
- * quotes or closed quotes followed by non space characters
- * as in: "foo"bar or "foo'
- */
-sds *sdssplitargs(const char *line, int *argc) {
- const char *p = line;
- char *current = NULL;
- char **vector = NULL;
-
- *argc = 0;
- while(1) {
- /* skip blanks */
- while(*p && isspace(*p)) p++;
- if (*p) {
- /* get a token */
- int inq=0; /* set to 1 if we are in "quotes" */
- int insq=0; /* set to 1 if we are in 'single quotes' */
- int done=0;
-
- if (current == NULL) current = sdsempty();
- while(!done) {
- if (inq) {
- if (*p == '\\' && *(p+1) == 'x' &&
- is_hex_digit(*(p+2)) &&
- is_hex_digit(*(p+3)))
- {
- unsigned char byte;
-
- byte = (hex_digit_to_int(*(p+2))*16)+
- hex_digit_to_int(*(p+3));
- current = sdscatlen(current,(char*)&byte,1);
- p += 3;
- } else if (*p == '\\' && *(p+1)) {
- char c;
-
- p++;
- switch(*p) {
- case 'n': c = '\n'; break;
- case 'r': c = '\r'; break;
- case 't': c = '\t'; break;
- case 'b': c = '\b'; break;
- case 'a': c = '\a'; break;
- default: c = *p; break;
- }
- current = sdscatlen(current,&c,1);
- } else if (*p == '"') {
- /* closing quote must be followed by a space or
- * nothing at all. */
- if (*(p+1) && !isspace(*(p+1))) goto err;
- done=1;
- } else if (!*p) {
- /* unterminated quotes */
- goto err;
- } else {
- current = sdscatlen(current,p,1);
- }
- } else if (insq) {
- if (*p == '\\' && *(p+1) == '\'') {
- p++;
- current = sdscatlen(current,"'",1);
- } else if (*p == '\'') {
- /* closing quote must be followed by a space or
- * nothing at all. */
- if (*(p+1) && !isspace(*(p+1))) goto err;
- done=1;
- } else if (!*p) {
- /* unterminated quotes */
- goto err;
- } else {
- current = sdscatlen(current,p,1);
- }
- } else {
- switch(*p) {
- case ' ':
- case '\n':
- case '\r':
- case '\t':
- case '\0':
- done=1;
- break;
- case '"':
- inq=1;
- break;
- case '\'':
- insq=1;
- break;
- default:
- current = sdscatlen(current,p,1);
- break;
- }
- }
- if (*p) p++;
- }
- /* add the token to the vector */
- vector = s_realloc(vector,((*argc)+1)*sizeof(char*));
- vector[*argc] = current;
- (*argc)++;
- current = NULL;
- } else {
- /* Even on empty input string return something not NULL. */
- if (vector == NULL) vector = s_malloc(sizeof(void*));
- return vector;
- }
- }
-
-err:
- while((*argc)--)
- sdsfree(vector[*argc]);
- s_free(vector);
- if (current) sdsfree(current);
- *argc = 0;
- return NULL;
-}
-
-/* Modify the string substituting all the occurrences of the set of
- * characters specified in the 'from' string to the corresponding character
- * in the 'to' array.
- *
- * For instance: sdsmapchars(mystring, "ho", "01", 2)
- * will have the effect of turning the string "hello" into "0ell1".
- *
- * The function returns the sds string pointer, that is always the same
- * as the input pointer since no resize is needed. */
-sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen) {
- size_t j, i, l = sdslen(s);
-
- for (j = 0; j < l; j++) {
- for (i = 0; i < setlen; i++) {
- if (s[j] == from[i]) {
- s[j] = to[i];
- break;
- }
- }
- }
- return s;
-}
-
-/* Join an array of C strings using the specified separator (also a C string).
- * Returns the result as an sds string. */
-sds sdsjoin(char **argv, int argc, char *sep) {
- sds join = sdsempty();
- int j;
-
- for (j = 0; j < argc; j++) {
- join = sdscat(join, argv[j]);
- if (j != argc-1) join = sdscat(join,sep);
- }
- return join;
-}
-
-/* Like sdsjoin, but joins an array of SDS strings. */
-sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
- sds join = sdsempty();
- int j;
-
- for (j = 0; j < argc; j++) {
- join = sdscatsds(join, argv[j]);
- if (j != argc-1) join = sdscatlen(join,sep,seplen);
- }
- return join;
-}
-
-#if defined(SDS_TEST_MAIN)
-#include <stdio.h>
-#include "testhelp.h"
-#include "limits.h"
-
-#define UNUSED(x) (void)(x)
-int sdsTest(void) {
- {
- sds x = sdsnew("foo"), y;
-
- test_cond("Create a string and obtain the length",
- sdslen(x) == 3 && memcmp(x,"foo\0",4) == 0)
-
- sdsfree(x);
- x = sdsnewlen("foo",2);
- test_cond("Create a string with specified length",
- sdslen(x) == 2 && memcmp(x,"fo\0",3) == 0)
-
- x = sdscat(x,"bar");
- test_cond("Strings concatenation",
- sdslen(x) == 5 && memcmp(x,"fobar\0",6) == 0);
-
- x = sdscpy(x,"a");
- test_cond("sdscpy() against an originally longer string",
- sdslen(x) == 1 && memcmp(x,"a\0",2) == 0)
-
- x = sdscpy(x,"xyzxxxxxxxxxxyyyyyyyyyykkkkkkkkkk");
- test_cond("sdscpy() against an originally shorter string",
- sdslen(x) == 33 &&
- memcmp(x,"xyzxxxxxxxxxxyyyyyyyyyykkkkkkkkkk\0",33) == 0)
-
- sdsfree(x);
- x = sdscatprintf(sdsempty(),"%d",123);
- test_cond("sdscatprintf() seems working in the base case",
- sdslen(x) == 3 && memcmp(x,"123\0",4) == 0)
-
- sdsfree(x);
- x = sdsnew("--");
- x = sdscatfmt(x, "Hello %s World %I,%I--", "Hi!", LLONG_MIN,LLONG_MAX);
- test_cond("sdscatfmt() seems working in the base case",
- sdslen(x) == 60 &&
- memcmp(x,"--Hello Hi! World -9223372036854775808,"
- "9223372036854775807--",60) == 0)
- printf("[%s]\n",x);
-
- sdsfree(x);
- x = sdsnew("--");
- x = sdscatfmt(x, "%u,%U--", UINT_MAX, ULLONG_MAX);
- test_cond("sdscatfmt() seems working with unsigned numbers",
- sdslen(x) == 35 &&
- memcmp(x,"--4294967295,18446744073709551615--",35) == 0)
-
- sdsfree(x);
- x = sdsnew(" x ");
- sdstrim(x," x");
- test_cond("sdstrim() works when all chars match",
- sdslen(x) == 0)
-
- sdsfree(x);
- x = sdsnew(" x ");
- sdstrim(x," ");
- test_cond("sdstrim() works when a single char remains",
- sdslen(x) == 1 && x[0] == 'x')
-
- sdsfree(x);
- x = sdsnew("xxciaoyyy");
- sdstrim(x,"xy");
- test_cond("sdstrim() correctly trims characters",
- sdslen(x) == 4 && memcmp(x,"ciao\0",5) == 0)
-
- y = sdsdup(x);
- sdsrange(y,1,1);
- test_cond("sdsrange(...,1,1)",
- sdslen(y) == 1 && memcmp(y,"i\0",2) == 0)
-
- sdsfree(y);
- y = sdsdup(x);
- sdsrange(y,1,-1);
- test_cond("sdsrange(...,1,-1)",
- sdslen(y) == 3 && memcmp(y,"iao\0",4) == 0)
-
- sdsfree(y);
- y = sdsdup(x);
- sdsrange(y,-2,-1);
- test_cond("sdsrange(...,-2,-1)",
- sdslen(y) == 2 && memcmp(y,"ao\0",3) == 0)
-
- sdsfree(y);
- y = sdsdup(x);
- sdsrange(y,2,1);
- test_cond("sdsrange(...,2,1)",
- sdslen(y) == 0 && memcmp(y,"\0",1) == 0)
-
- sdsfree(y);
- y = sdsdup(x);
- sdsrange(y,1,100);
- test_cond("sdsrange(...,1,100)",
- sdslen(y) == 3 && memcmp(y,"iao\0",4) == 0)
-
- sdsfree(y);
- y = sdsdup(x);
- sdsrange(y,100,100);
- test_cond("sdsrange(...,100,100)",
- sdslen(y) == 0 && memcmp(y,"\0",1) == 0)
-
- sdsfree(y);
- sdsfree(x);
- x = sdsnew("foo");
- y = sdsnew("foa");
- test_cond("sdscmp(foo,foa)", sdscmp(x,y) > 0)
-
- sdsfree(y);
- sdsfree(x);
- x = sdsnew("bar");
- y = sdsnew("bar");
- test_cond("sdscmp(bar,bar)", sdscmp(x,y) == 0)
-
- sdsfree(y);
- sdsfree(x);
- x = sdsnew("aar");
- y = sdsnew("bar");
- test_cond("sdscmp(bar,bar)", sdscmp(x,y) < 0)
-
- sdsfree(y);
- sdsfree(x);
- x = sdsnewlen("\a\n\0foo\r",7);
- y = sdscatrepr(sdsempty(),x,sdslen(x));
- test_cond("sdscatrepr(...data...)",
- memcmp(y,"\"\\a\\n\\x00foo\\r\"",15) == 0)
-
- {
- unsigned int oldfree;
- char *p;
- int step = 10, j, i;
-
- sdsfree(x);
- sdsfree(y);
- x = sdsnew("0");
- test_cond("sdsnew() free/len buffers", sdslen(x) == 1 && sdsavail(x) == 0);
-
- /* Run the test a few times in order to hit the first two
- * SDS header types. */
- for (i = 0; i < 10; i++) {
- int oldlen = sdslen(x);
- x = sdsMakeRoomFor(x,step);
- int type = x[-1]&SDS_TYPE_MASK;
-
- test_cond("sdsMakeRoomFor() len", sdslen(x) == oldlen);
- if (type != SDS_TYPE_5) {
- test_cond("sdsMakeRoomFor() free", sdsavail(x) >= step);
- oldfree = sdsavail(x);
- }
- p = x+oldlen;
- for (j = 0; j < step; j++) {
- p[j] = 'A'+j;
- }
- sdsIncrLen(x,step);
- }
- test_cond("sdsMakeRoomFor() content",
- memcmp("0ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ",x,101) == 0);
- test_cond("sdsMakeRoomFor() final length",sdslen(x)==101);
-
- sdsfree(x);
- }
- }
- test_report()
- return 0;
-}
-#endif
-
-#ifdef SDS_TEST_MAIN
-int main(void) {
- return sdsTest();
-}
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sdsalloc.h b/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sdsalloc.h
deleted file mode 100644
index 152976c808b..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/dep/extern/sdsalloc.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* SDSLib 2.0 -- A C dynamic strings library
- *
- * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com>
- * Copyright (c) 2015, Redis Labs, Inc
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Redis nor the names of its contributors may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* SDS allocator selection.
- *
- * This file is used in order to change the SDS allocator at compile time.
- * Just define the following defines to what you want to use. Also add
- * the include of your alternate allocator if needed (not needed in order
- * to use the default libc allocator). */
-
-#define s_malloc malloc
-#define s_realloc realloc
-#define s_free free
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/buffer.h b/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/buffer.h
deleted file mode 100644
index 9b4186b5eb8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/buffer.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef CARYLL_INCLUDE_BUFFER_H
-#define CARYLL_INCLUDE_BUFFER_H
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdarg.h>
-#include "dep/sds.h"
-
-typedef struct caryll_Buffer {
- size_t cursor;
- size_t size;
- size_t free;
- uint8_t *data;
-} caryll_Buffer;
-
-caryll_Buffer *bufnew(void);
-caryll_Buffer *bufninit(uint32_t n, ...);
-void buffree(caryll_Buffer *buf);
-size_t buflen(caryll_Buffer *buf);
-size_t bufpos(caryll_Buffer *buf);
-void bufseek(caryll_Buffer *buf, size_t pos);
-void bufclear(caryll_Buffer *buf);
-
-void bufwrite8(caryll_Buffer *buf, uint8_t byte);
-void bufwrite16l(caryll_Buffer *buf, uint16_t x);
-void bufwrite16b(caryll_Buffer *buf, uint16_t x);
-void bufwrite24l(caryll_Buffer *buf, uint32_t x);
-void bufwrite24b(caryll_Buffer *buf, uint32_t x);
-void bufwrite32l(caryll_Buffer *buf, uint32_t x);
-void bufwrite32b(caryll_Buffer *buf, uint32_t x);
-void bufwrite64l(caryll_Buffer *buf, uint64_t x);
-void bufwrite64b(caryll_Buffer *buf, uint64_t x);
-
-void bufnwrite8(caryll_Buffer *buf, uint32_t n, ...);
-
-void bufwrite_sds(caryll_Buffer *buf, sds str);
-void bufwrite_str(caryll_Buffer *buf, const char *str);
-void bufwrite_bytes(caryll_Buffer *buf, size_t size, const uint8_t *str);
-void bufwrite_buf(caryll_Buffer *buf, caryll_Buffer *that);
-void bufwrite_bufdel(caryll_Buffer *buf, caryll_Buffer *that);
-
-void bufping16b(caryll_Buffer *buf, size_t *offset, size_t *cp);
-void bufping16bd(caryll_Buffer *buf, size_t *offset, size_t *shift, size_t *cp);
-void bufpingpong16b(caryll_Buffer *buf, caryll_Buffer *that, size_t *offset, size_t *cp);
-void bufpong(caryll_Buffer *buf, size_t *offset, size_t *cp);
-
-void bufprint(caryll_Buffer *buf);
-
-void buflongalign(caryll_Buffer *buf);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/element.h b/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/element.h
deleted file mode 100644
index 82bfc73cfb6..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/element.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef CARYLL_INCLUDE_ELEMENT_H
-#define CARYLL_INCLUDE_ELEMENT_H
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "ownership.h"
-
-// We assume all T have trivial move constructors.
-#define caryll_T(T) \
- void (*init)(MODIFY T *); \
- void (*copy)(MODIFY T *, const T *); \
- void (*move)(MODIFY T *, T *); \
- void (*dispose)(MOVE T *); \
- void (*replace)(MODIFY T *, MOVE const T); \
- void (*copyReplace)(MODIFY T *, const T);
-
-#define caryll_VT(T) \
- caryll_T(T); \
- T (*empty)(); \
- T (*dup)(const T);
-#define caryll_RT(T) \
- caryll_T(T); \
- T *(*create)(); \
- void (*free)(MOVE T *);
-
-#define caryll_ElementInterfaceOf(T) const struct __caryll_elementinterface_##T
-#define caryll_ElementInterface(T) \
- caryll_ElementInterfaceOf(T) { \
- caryll_T(T); \
- }
-#define caryll_RefElementInterface(T) \
- caryll_ElementInterfaceOf(T) { \
- caryll_RT(T); \
- }
-#define caryll_ValElementInterface(T) \
- caryll_ElementInterfaceOf(T) { \
- caryll_VT(T); \
- }
-
-/// Individual traits
-
-#define caryll_Show(T) void (*show)(const T);
-#define caryll_Eq(T) bool (*equal)(const T, const T);
-#define caryll_Ord(T) \
- caryll_Eq(T); \
- int (*compare)(const T a, const T b); \
- int (*compareRef)(const T *a, const T *b);
-#define caryll_Monoid(T) \
- T (*neutral)(); \
- T (*plus)(const T a, const T b); \
- void (*inplacePlus)(MODIFY T * a, const T b);
-#define caryll_Group(T) \
- caryll_Monoid(T); \
- void (*inplaceNegate)(MODIFY T * a); \
- T (*negate)(const T); \
- void (*inplaceMinus)(MODIFY T *, const T); \
- T (*minus)(const T, const T);
-#define caryll_Module(T, TScale) \
- caryll_Group(T); \
- void (*inplaceScale)(MODIFY T * a, TScale b); \
- void (*inplacePlusScale)(MODIFY T * a, TScale b, const T c); \
- T (*scale)(const T a, TScale b);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/ownership.h b/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/ownership.h
deleted file mode 100644
index 694927f7bc2..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/ownership.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_INCLUDE_OWNERSHIP_H
-#define CARYLL_INCLUDE_OWNERSHIP_H
-
-#define OWNING /*owning*/
-#define MOVE /*move*/
-#define OBSERVE /*shared*/ const
-#define MODIFY /*modify*/
-#define COPY /*shared*/
-#define OUT /*shared*/
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/vector.h b/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/vector.h
deleted file mode 100644
index 4f1aece956c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/caryll/vector.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef CARYLL_INCLUDE_VECTOR_H
-#define CARYLL_INCLUDE_VECTOR_H
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "element.h"
-
-// We assume all T have trivial move constructors.
-#define caryll_Vector(T) \
- struct { \
- size_t length; \
- size_t capacity; \
- T *items; \
- }
-#define caryll_VectorInterfaceTypeName(__TV) const struct __caryll_vectorinterface_##__TV
-#define caryll_VectorInterfaceTrait(__TV, __T) \
- caryll_RT(__TV); \
- void (*initN)(MODIFY __TV * arr, size_t n); \
- void (*initCapN)(MODIFY __TV * arr, size_t n); \
- __TV *(*createN)(size_t n); \
- void (*fill)(MODIFY __TV * arr, size_t n); \
- void (*clear)(MODIFY __TV * arr); \
- void (*push)(MODIFY __TV * arr, MOVE __T obj); \
- void (*shrinkToFit)(MODIFY __TV * arr); \
- __T (*pop)(MODIFY __TV * arr); \
- void (*disposeItem)(MODIFY __TV * arr, size_t n); \
- void (*filterEnv)(MODIFY __TV * arr, bool (*fn)(const __T *x, void *env), void *env); \
- void (*sort)(MODIFY __TV * arr, int (*fn)(const __T *a, const __T *b));
-
-#define caryll_VectorInterface(__TV, __T) \
- caryll_VectorInterfaceTypeName(__TV) { \
- caryll_VectorInterfaceTrait(__TV, __T); \
- }
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/json-builder.h b/Build/source/texk/web2c/mfluadir/otfcc/include/dep/json-builder.h
deleted file mode 100644
index e0e1b68b501..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/json-builder.h
+++ /dev/null
@@ -1,139 +0,0 @@
-
-/* vim: set et ts=3 sw=3 sts=3 ft=c:
- *
- * Copyright (C) 2014 James McLaughlin. All rights reserved.
- * https://github.com/udp/json-builder
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _JSON_BUILDER_H
-#define _JSON_BUILDER_H
-
-/* Requires json.h from json-parser
- * https://github.com/udp/json-parser
- */
-#include "json.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* IMPORTANT NOTE: If you want to use json-builder functions with values
- * allocated by json-parser as part of the parsing process, you must pass
- * json_builder_extra as the value_extra setting in json_settings when
- * parsing. Otherwise there will not be room for the extra state and
- * json-builder WILL invoke undefined behaviour.
- *
- * Also note that unlike json-parser, json-builder does not currently support
- * custom allocators (for no particular reason other than that it doesn't have
- * any settings or global state.)
- */
-extern const size_t json_builder_extra;
-
-/*** Arrays
- ***
- * Note that all of these length arguments are just a hint to allow for
- * pre-allocation - passing 0 is fine.
- */
-json_value *json_array_new(size_t length);
-json_value *json_array_push(json_value *array, json_value *);
-
-/*** Objects
- ***/
-json_value *json_object_new(size_t length);
-
-json_value *json_object_push(json_value *object, const json_char *name, json_value *);
-
-/* Same as json_object_push, but doesn't call strlen() for you.
- */
-json_value *json_object_push_length(json_value *object, unsigned int name_length, const json_char *name, json_value *);
-
-/* Same as json_object_push_length, but doesn't copy the name buffer before
- * storing it in the value. Use this micro-optimisation at your own risk.
- */
-json_value *json_object_push_nocopy(json_value *object, unsigned int name_length, json_char *name, json_value *);
-
-/* Merges all entries from objectB into objectA and frees objectB.
- */
-json_value *json_object_merge(json_value *objectA, json_value *objectB);
-
-/* Sort the entries of an object based on the order in a prototype object.
- * Helpful when reading JSON and writing it again to preserve user order.
- */
-void json_object_sort(json_value *object, json_value *proto);
-
-/*** Strings
- ***/
-json_value *json_string_new(const json_char *);
-json_value *json_string_new_length(unsigned int length, const json_char *);
-json_value *json_string_new_nocopy(unsigned int length, json_char *);
-
-/*** Everything else
- ***/
-json_value *json_integer_new(json_int_t);
-json_value *json_double_new(double);
-json_value *json_boolean_new(int);
-json_value *json_null_new(void);
-
-/*** Serializing
- ***/
-#define json_serialize_mode_multiline 0
-#define json_serialize_mode_single_line 1
-#define json_serialize_mode_packed 2
-
-#define json_serialize_opt_CRLF (1 << 1)
-#define json_serialize_opt_pack_brackets (1 << 2)
-#define json_serialize_opt_no_space_after_comma (1 << 3)
-#define json_serialize_opt_no_space_after_colon (1 << 4)
-#define json_serialize_opt_use_tabs (1 << 5)
-
-typedef struct json_serialize_opts {
- int mode;
- int opts;
- int indent_size;
-
-} json_serialize_opts;
-
-/* Returns a length in characters that is at least large enough to hold the
- * value in its serialized form, including a null terminator.
- */
-size_t json_measure(json_value *);
-size_t json_measure_ex(json_value *, json_serialize_opts);
-
-/* Serializes a JSON value into the buffer given (which must already be
- * allocated with a length of at least json_measure(value, opts))
- */
-void json_serialize(json_char *buf, json_value *);
-void json_serialize_ex(json_char *buf, json_value *, json_serialize_opts);
-
-/*** Cleaning up
- ***/
-void json_builder_free(json_value *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/json.h b/Build/source/texk/web2c/mfluadir/otfcc/include/dep/json.h
deleted file mode 100644
index c893d8917f2..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/json.h
+++ /dev/null
@@ -1,291 +0,0 @@
-
-/* vim: set et ts=3 sw=3 sts=3 ft=c:
- *
- * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved.
- * https://github.com/udp/json-parser
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _JSON_H
-#define _JSON_H
-
-#ifndef json_char
- #define json_char char
-#endif
-
-#ifdef _CARYLL_USE_PRE_SERIALIZED
- #define CARYLL_USE_PRE_SERIALIZED
-#endif
-
-#ifndef json_int_t
- #include <stdint.h>
- #ifndef _MSC_VER
- #include <inttypes.h>
- #define json_int_t int64_t
- #else
- #define json_int_t __int64
- #endif
-#endif
-
-#include <stdlib.h>
-
-#ifdef __cplusplus
-
- #include <string.h>
-
- extern "C"
- {
-
-#endif
-
-typedef struct
-{
- unsigned long max_memory;
- int settings;
-
- /* Custom allocator support (leave null to use malloc/free)
- */
-
- void * (* mem_alloc) (size_t, int zero, void * user_data);
- void (* mem_free) (void *, void * user_data);
-
- void * user_data; /* will be passed to mem_alloc and mem_free */
-
- size_t value_extra; /* how much extra space to allocate for values? */
-
-} json_settings;
-
-#define json_enable_comments 0x01
-
-typedef enum
-{
- json_none,
- json_object,
- json_array,
- json_integer,
- json_double,
- json_string,
- json_boolean,
- json_null
-#ifdef CARYLL_USE_PRE_SERIALIZED
-,
- json_pre_serialized
-#endif
-} json_type;
-
-extern const struct _json_value json_value_none;
-
-typedef struct _json_object_entry
-{
- json_char * name;
- unsigned int name_length;
-
- struct _json_value * value;
-
-} json_object_entry;
-
-typedef struct _json_value
-{
- struct _json_value * parent;
-
- json_type type;
-
- union
- {
- int boolean;
- json_int_t integer;
- double dbl;
-
- struct
- {
- unsigned int length;
- json_char * ptr; /* null terminated */
-
- } string;
-
- struct
- {
- unsigned int length;
-
- json_object_entry * values;
-
- #if defined(__cplusplus) && __cplusplus >= 201103L
- decltype(values) begin () const
- { return values;
- }
- decltype(values) end () const
- { return values + length;
- }
- #endif
-
- } object;
-
- struct
- {
- unsigned int length;
- struct _json_value ** values;
-
- #if defined(__cplusplus) && __cplusplus >= 201103L
- decltype(values) begin () const
- { return values;
- }
- decltype(values) end () const
- { return values + length;
- }
- #endif
-
- } array;
-
- } u;
-
- union
- {
- struct _json_value * next_alloc;
- void * object_mem;
-
- } _reserved;
-
- #ifdef JSON_TRACK_SOURCE
-
- /* Location of the value in the source JSON
- */
- unsigned int line, col;
-
- #endif
-
-
- /* Some C++ operator sugar */
-
- #ifdef __cplusplus
-
- public:
-
- inline _json_value ()
- { memset (this, 0, sizeof (_json_value));
- }
-
- inline const struct _json_value &operator [] (int index) const
- {
- if (type != json_array || index < 0
- || ((unsigned int) index) >= u.array.length)
- {
- return json_value_none;
- }
-
- return *u.array.values [index];
- }
-
- inline const struct _json_value &operator [] (const char * index) const
- {
- if (type != json_object)
- return json_value_none;
-
- for (unsigned int i = 0; i < u.object.length; ++ i)
- if (!strcmp (u.object.values [i].name, index))
- return *u.object.values [i].value;
-
- return json_value_none;
- }
-
- inline operator const char * () const
- {
- switch (type)
- {
- case json_string:
- return u.string.ptr;
-
- default:
- return "";
- };
- }
-
- inline operator json_int_t () const
- {
- switch (type)
- {
- case json_integer:
- return u.integer;
-
- case json_double:
- return (json_int_t) u.dbl;
-
- default:
- return 0;
- };
- }
-
- inline operator bool () const
- {
- if (type != json_boolean)
- return false;
-
- return u.boolean != 0;
- }
-
- inline operator double () const
- {
- switch (type)
- {
- case json_integer:
- return (double) u.integer;
-
- case json_double:
- return u.dbl;
-
- default:
- return 0;
- };
- }
-
- #endif
-
-} json_value;
-
-json_value * json_parse (const json_char * json,
- size_t length);
-
-#define json_error_max 128
-json_value * json_parse_ex (json_settings * settings,
- const json_char * json,
- size_t length,
- char * error);
-
-void json_value_free (json_value *);
-
-
-/* Not usually necessary, unless you used a custom mem_alloc and now want to
- * use a custom mem_free.
- */
-void json_value_free_ex (json_settings * settings,
- json_value *);
-
-
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
-
-#endif
-
-
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/sds.h b/Build/source/texk/web2c/mfluadir/otfcc/include/dep/sds.h
deleted file mode 100644
index 3cdc7e98548..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/sds.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/* SDSLib 2.0 -- A C dynamic strings library
- *
- * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com>
- * Copyright (c) 2015, Redis Labs, Inc
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Redis nor the names of its contributors may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __SDS_H
-#define __SDS_H
-
-#define SDS_MAX_PREALLOC (1024 * 1024)
-
-#include <sys/types.h>
-#include <stdarg.h>
-#include <stdint.h>
-
-typedef char *sds;
-
-/* Note: sdshdr5 is never used, we just access the flags byte directly.
- * However is here to document the layout of type 5 SDS strings. */
-struct __attribute__((__packed__)) sdshdr5 {
- unsigned char flags; /* 3 lsb of type, and 5 msb of string length */
- char buf[];
-};
-struct __attribute__((__packed__)) sdshdr8 {
- uint8_t len; /* used */
- uint8_t alloc; /* excluding the header and null terminator */
- unsigned char flags; /* 3 lsb of type, 5 unused bits */
- char buf[];
-};
-struct __attribute__((__packed__)) sdshdr16 {
- uint16_t len; /* used */
- uint16_t alloc; /* excluding the header and null terminator */
- unsigned char flags; /* 3 lsb of type, 5 unused bits */
- char buf[];
-};
-struct __attribute__((__packed__)) sdshdr32 {
- uint32_t len; /* used */
- uint32_t alloc; /* excluding the header and null terminator */
- unsigned char flags; /* 3 lsb of type, 5 unused bits */
- char buf[];
-};
-struct __attribute__((__packed__)) sdshdr64 {
- uint64_t len; /* used */
- uint64_t alloc; /* excluding the header and null terminator */
- unsigned char flags; /* 3 lsb of type, 5 unused bits */
- char buf[];
-};
-
-#define SDS_TYPE_5 0
-#define SDS_TYPE_8 1
-#define SDS_TYPE_16 2
-#define SDS_TYPE_32 3
-#define SDS_TYPE_64 4
-#define SDS_TYPE_MASK 7
-#define SDS_TYPE_BITS 3
-#define SDS_HDR_VAR(T, s) struct sdshdr##T *sh = (void *)((s) - (sizeof(struct sdshdr##T)));
-#define SDS_HDR(T, s) ((struct sdshdr##T *)((s) - (sizeof(struct sdshdr##T))))
-#define SDS_TYPE_5_LEN(f) ((f) >> SDS_TYPE_BITS)
-
-static inline size_t sdslen(const sds s) {
- unsigned char flags = s[-1];
- switch (flags & SDS_TYPE_MASK) {
- case SDS_TYPE_5:
- return SDS_TYPE_5_LEN(flags);
- case SDS_TYPE_8:
- return SDS_HDR(8, s)->len;
- case SDS_TYPE_16:
- return SDS_HDR(16, s)->len;
- case SDS_TYPE_32:
- return SDS_HDR(32, s)->len;
- case SDS_TYPE_64:
- return SDS_HDR(64, s)->len;
- }
- return 0;
-}
-
-static inline size_t sdsavail(const sds s) {
- unsigned char flags = s[-1];
- switch (flags & SDS_TYPE_MASK) {
- case SDS_TYPE_5: {
- return 0;
- }
- case SDS_TYPE_8: {
- SDS_HDR_VAR(8, s);
- return sh->alloc - sh->len;
- }
- case SDS_TYPE_16: {
- SDS_HDR_VAR(16, s);
- return sh->alloc - sh->len;
- }
- case SDS_TYPE_32: {
- SDS_HDR_VAR(32, s);
- return sh->alloc - sh->len;
- }
- case SDS_TYPE_64: {
- SDS_HDR_VAR(64, s);
- return sh->alloc - sh->len;
- }
- }
- return 0;
-}
-
-static inline void sdssetlen(sds s, size_t newlen) {
- unsigned char flags = s[-1];
- switch (flags & SDS_TYPE_MASK) {
- case SDS_TYPE_5: {
- unsigned char *fp = ((unsigned char *)s) - 1;
- *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
- } break;
- case SDS_TYPE_8:
- SDS_HDR(8, s)->len = (uint8_t)newlen;
- break;
- case SDS_TYPE_16:
- SDS_HDR(16, s)->len = (uint16_t)newlen;
- break;
- case SDS_TYPE_32:
- SDS_HDR(32, s)->len = (uint32_t)newlen;
- break;
- case SDS_TYPE_64:
- SDS_HDR(64, s)->len = newlen;
- break;
- }
-}
-
-static inline void sdsinclen(sds s, size_t inc) {
- unsigned char flags = s[-1];
- switch (flags & SDS_TYPE_MASK) {
- case SDS_TYPE_5: {
- unsigned char *fp = ((unsigned char *)s) - 1;
- unsigned char newlen = SDS_TYPE_5_LEN(flags) + inc;
- *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
- } break;
- case SDS_TYPE_8:
- SDS_HDR(8, s)->len += (uint8_t)inc;
- break;
- case SDS_TYPE_16:
- SDS_HDR(16, s)->len += (uint16_t)inc;
- break;
- case SDS_TYPE_32:
- SDS_HDR(32, s)->len += (uint32_t)inc;
- break;
- case SDS_TYPE_64:
- SDS_HDR(64, s)->len += inc;
- break;
- }
-}
-
-/* sdsalloc() = sdsavail() + sdslen() */
-static inline size_t sdsalloc(const sds s) {
- unsigned char flags = s[-1];
- switch (flags & SDS_TYPE_MASK) {
- case SDS_TYPE_5:
- return SDS_TYPE_5_LEN(flags);
- case SDS_TYPE_8:
- return SDS_HDR(8, s)->alloc;
- case SDS_TYPE_16:
- return SDS_HDR(16, s)->alloc;
- case SDS_TYPE_32:
- return SDS_HDR(32, s)->alloc;
- case SDS_TYPE_64:
- return SDS_HDR(64, s)->alloc;
- }
- return 0;
-}
-
-static inline void sdssetalloc(sds s, size_t newlen) {
- unsigned char flags = s[-1];
- switch (flags & SDS_TYPE_MASK) {
- case SDS_TYPE_5:
- /* Nothing to do, this type has no total allocation info. */
- break;
- case SDS_TYPE_8:
- SDS_HDR(8, s)->alloc = (uint8_t)newlen;
- break;
- case SDS_TYPE_16:
- SDS_HDR(16, s)->alloc = (uint16_t)newlen;
- break;
- case SDS_TYPE_32:
- SDS_HDR(32, s)->alloc = (uint32_t)newlen;
- break;
- case SDS_TYPE_64:
- SDS_HDR(64, s)->alloc = newlen;
- break;
- }
-}
-
-sds sdsnewlen(const void *init, size_t initlen);
-sds sdsnew(const char *init);
-sds sdsempty(void);
-sds sdsdup(const sds s);
-void sdsfree(sds s);
-sds sdsgrowzero(sds s, size_t len);
-sds sdscatlen(sds s, const void *t, size_t len);
-sds sdscat(sds s, const char *t);
-sds sdscatsds(sds s, const sds t);
-sds sdscpylen(sds s, const char *t, size_t len);
-sds sdscpy(sds s, const char *t);
-
-sds sdscatvprintf(sds s, const char *fmt, va_list ap);
-#ifdef __GNUC__
-sds sdscatprintf(sds s, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-#else
-sds sdscatprintf(sds s, const char *fmt, ...);
-#endif
-
-sds sdscatfmt(sds s, char const *fmt, ...);
-sds sdstrim(sds s, const char *cset);
-void sdsrange(sds s, int start, int end);
-void sdsupdatelen(sds s);
-void sdsclear(sds s);
-int sdscmp(const sds s1, const sds s2);
-sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count);
-void sdsfreesplitres(sds *tokens, int count);
-void sdstolower(sds s);
-void sdstoupper(sds s);
-sds sdsfromlonglong(long long value);
-sds sdscatrepr(sds s, const char *p, size_t len);
-sds *sdssplitargs(const char *line, int *argc);
-sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
-sds sdsjoin(char **argv, int argc, char *sep);
-sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen);
-
-/* Low level functions exposed to the user API */
-sds sdsMakeRoomFor(sds s, size_t addlen);
-void sdsIncrLen(sds s, int incr);
-sds sdsRemoveFreeSpace(sds s);
-size_t sdsAllocSize(sds s);
-void *sdsAllocPtr(sds s);
-
-#ifdef REDIS_TEST
-int sdsTest(int argc, char *argv[]);
-#endif
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/uthash.h b/Build/source/texk/web2c/mfluadir/otfcc/include/dep/uthash.h
deleted file mode 100644
index 6bf5688c081..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/dep/uthash.h
+++ /dev/null
@@ -1,1208 +0,0 @@
-/*
-Copyright (c) 2003-2017, Troy D. Hanson http://troydhanson.github.com/uthash/
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef UTHASH_H
-#define UTHASH_H
-
-#define UTHASH_VERSION 2.0.2
-
-#include <string.h> /* memcmp, memset, strlen */
-#include <stddef.h> /* ptrdiff_t */
-#include <stdlib.h> /* exit */
-
-/* These macros use decltype or the earlier __typeof GNU extension.
- As decltype is only available in newer compilers (VS2010 or gcc 4.3+
- when compiling c++ source) this code uses whatever method is needed
- or, for VS2008 where neither is available, uses casting workarounds. */
-#if !defined(DECLTYPE) && !defined(NO_DECLTYPE)
-#if defined(_MSC_VER) /* MS compiler */
-#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */
-#define DECLTYPE(x) (decltype(x))
-#else /* VS2008 or older (or VS2010 in C mode) */
-#define NO_DECLTYPE
-#endif
-#elif defined(__BORLANDC__) || defined(__ICCARM__) || defined(__LCC__) || defined(__WATCOMC__)
-#define NO_DECLTYPE
-#else /* GNU, Sun and other compilers */
-#define DECLTYPE(x) (__typeof(x))
-#endif
-#endif
-
-#ifdef NO_DECLTYPE
-#define DECLTYPE(x)
-#define DECLTYPE_ASSIGN(dst,src) \
-do { \
- char **_da_dst = (char**)(&(dst)); \
- *_da_dst = (char*)(src); \
-} while (0)
-#else
-#define DECLTYPE_ASSIGN(dst,src) \
-do { \
- (dst) = DECLTYPE(dst)(src); \
-} while (0)
-#endif
-
-/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */
-#if defined(_WIN32)
-#if defined(_MSC_VER) && _MSC_VER >= 1600
-#include <stdint.h>
-#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__)
-#include <stdint.h>
-#else
-typedef unsigned int uint32_t;
-typedef unsigned char uint8_t;
-#endif
-#elif defined(__GNUC__) && !defined(__VXWORKS__)
-#include <stdint.h>
-#else
-typedef unsigned int uint32_t;
-typedef unsigned char uint8_t;
-#endif
-
-#ifndef uthash_malloc
-#define uthash_malloc(sz) malloc(sz) /* malloc fcn */
-#endif
-#ifndef uthash_free
-#define uthash_free(ptr,sz) free(ptr) /* free fcn */
-#endif
-#ifndef uthash_bzero
-#define uthash_bzero(a,n) memset(a,'\0',n)
-#endif
-#ifndef uthash_memcmp
-#define uthash_memcmp(a,b,n) memcmp(a,b,n)
-#endif
-#ifndef uthash_strlen
-#define uthash_strlen(s) strlen(s)
-#endif
-
-#ifndef uthash_noexpand_fyi
-#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */
-#endif
-#ifndef uthash_expand_fyi
-#define uthash_expand_fyi(tbl) /* can be defined to log expands */
-#endif
-
-#ifndef HASH_NONFATAL_OOM
-#define HASH_NONFATAL_OOM 0
-#endif
-
-#if HASH_NONFATAL_OOM
-/* malloc failures can be recovered from */
-
-#ifndef uthash_nonfatal_oom
-#define uthash_nonfatal_oom(obj) do {} while (0) /* non-fatal OOM error */
-#endif
-
-#define HASH_RECORD_OOM(oomed) do { (oomed) = 1; } while (0)
-#define IF_HASH_NONFATAL_OOM(x) x
-
-#else
-/* malloc failures result in lost memory, hash tables are unusable */
-
-#ifndef uthash_fatal
-#define uthash_fatal(msg) exit(-1) /* fatal OOM error */
-#endif
-
-#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
-#define IF_HASH_NONFATAL_OOM(x)
-
-#endif
-
-/* initial number of buckets */
-#define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */
-#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
-#define HASH_BKT_CAPACITY_THRESH 10U /* expand when bucket count reaches */
-
-/* calculate the element whose hash handle address is hhp */
-#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
-/* calculate the hash handle from element address elp */
-#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho)))
-
-#define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \
-do { \
- struct UT_hash_handle *_hd_hh_item = (itemptrhh); \
- unsigned _hd_bkt; \
- HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
- (head)->hh.tbl->buckets[_hd_bkt].count++; \
- _hd_hh_item->hh_next = NULL; \
- _hd_hh_item->hh_prev = NULL; \
-} while (0)
-
-#define HASH_VALUE(keyptr,keylen,hashv) \
-do { \
- HASH_FCN(keyptr, keylen, hashv); \
-} while (0)
-
-#define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \
-do { \
- (out) = NULL; \
- if (head) { \
- unsigned _hf_bkt; \
- HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt); \
- if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) { \
- HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], keyptr, keylen, hashval, out); \
- } \
- } \
-} while (0)
-
-#define HASH_FIND(hh,head,keyptr,keylen,out) \
-do { \
- unsigned _hf_hashv; \
- HASH_VALUE(keyptr, keylen, _hf_hashv); \
- HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \
-} while (0)
-
-#ifdef HASH_BLOOM
-#define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM)
-#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8UL) + (((HASH_BLOOM_BITLEN%8UL)!=0UL) ? 1UL : 0UL)
-#define HASH_BLOOM_MAKE(tbl,oomed) \
-do { \
- (tbl)->bloom_nbits = HASH_BLOOM; \
- (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \
- if (!(tbl)->bloom_bv) { \
- HASH_RECORD_OOM(oomed); \
- } else { \
- uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \
- (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \
- } \
-} while (0)
-
-#define HASH_BLOOM_FREE(tbl) \
-do { \
- uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \
-} while (0)
-
-#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8U] |= (1U << ((idx)%8U)))
-#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8U] & (1U << ((idx)%8U)))
-
-#define HASH_BLOOM_ADD(tbl,hashv) \
- HASH_BLOOM_BITSET((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U)))
-
-#define HASH_BLOOM_TEST(tbl,hashv) \
- HASH_BLOOM_BITTEST((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U)))
-
-#else
-#define HASH_BLOOM_MAKE(tbl,oomed)
-#define HASH_BLOOM_FREE(tbl)
-#define HASH_BLOOM_ADD(tbl,hashv)
-#define HASH_BLOOM_TEST(tbl,hashv) (1)
-#define HASH_BLOOM_BYTELEN 0U
-#endif
-
-#define HASH_MAKE_TABLE(hh,head,oomed) \
-do { \
- (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table)); \
- if (!(head)->hh.tbl) { \
- HASH_RECORD_OOM(oomed); \
- } else { \
- uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \
- (head)->hh.tbl->tail = &((head)->hh); \
- (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
- (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
- (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
- (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
- HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
- (head)->hh.tbl->signature = HASH_SIGNATURE; \
- if (!(head)->hh.tbl->buckets) { \
- HASH_RECORD_OOM(oomed); \
- uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
- } else { \
- uthash_bzero((head)->hh.tbl->buckets, \
- HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
- HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \
- IF_HASH_NONFATAL_OOM( \
- if (oomed) { \
- uthash_free((head)->hh.tbl->buckets, \
- HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
- uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
- } \
- ) \
- } \
- } \
-} while (0)
-
-#define HASH_REPLACE_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,replaced,cmpfcn) \
-do { \
- (replaced) = NULL; \
- HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \
- if (replaced) { \
- HASH_DELETE(hh, head, replaced); \
- } \
- HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn); \
-} while (0)
-
-#define HASH_REPLACE_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add,replaced) \
-do { \
- (replaced) = NULL; \
- HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \
- if (replaced) { \
- HASH_DELETE(hh, head, replaced); \
- } \
- HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add); \
-} while (0)
-
-#define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \
-do { \
- unsigned _hr_hashv; \
- HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \
- HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced); \
-} while (0)
-
-#define HASH_REPLACE_INORDER(hh,head,fieldname,keylen_in,add,replaced,cmpfcn) \
-do { \
- unsigned _hr_hashv; \
- HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \
- HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced, cmpfcn); \
-} while (0)
-
-#define HASH_APPEND_LIST(hh, head, add) \
-do { \
- (add)->hh.next = NULL; \
- (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
- (head)->hh.tbl->tail->next = (add); \
- (head)->hh.tbl->tail = &((add)->hh); \
-} while (0)
-
-#define HASH_AKBI_INNER_LOOP(hh,head,add,cmpfcn) \
-do { \
- do { \
- if (cmpfcn(DECLTYPE(head)(_hs_iter), add) > 0) { \
- break; \
- } \
- } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \
-} while (0)
-
-#ifdef NO_DECLTYPE
-#undef HASH_AKBI_INNER_LOOP
-#define HASH_AKBI_INNER_LOOP(hh,head,add,cmpfcn) \
-do { \
- char *_hs_saved_head = (char*)(head); \
- do { \
- DECLTYPE_ASSIGN(head, _hs_iter); \
- if (cmpfcn(head, add) > 0) { \
- DECLTYPE_ASSIGN(head, _hs_saved_head); \
- break; \
- } \
- DECLTYPE_ASSIGN(head, _hs_saved_head); \
- } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \
-} while (0)
-#endif
-
-#if HASH_NONFATAL_OOM
-
-#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \
-do { \
- if (!(oomed)) { \
- unsigned _ha_bkt; \
- (head)->hh.tbl->num_items++; \
- HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \
- HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \
- if (oomed) { \
- HASH_ROLLBACK_BKT(hh, head, &(add)->hh); \
- HASH_DELETE_HH(hh, head, &(add)->hh); \
- (add)->hh.tbl = NULL; \
- uthash_nonfatal_oom(add); \
- } else { \
- HASH_BLOOM_ADD((head)->hh.tbl, hashval); \
- HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \
- } \
- } else { \
- (add)->hh.tbl = NULL; \
- uthash_nonfatal_oom(add); \
- } \
-} while (0)
-
-#else
-
-#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \
-do { \
- unsigned _ha_bkt; \
- (head)->hh.tbl->num_items++; \
- HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \
- HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \
- HASH_BLOOM_ADD((head)->hh.tbl, hashval); \
- HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \
-} while (0)
-
-#endif
-
-
-#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \
-do { \
- IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \
- (add)->hh.hashv = (hashval); \
- (add)->hh.key = (char*) (keyptr); \
- (add)->hh.keylen = (unsigned) (keylen_in); \
- if (!(head)) { \
- (add)->hh.next = NULL; \
- (add)->hh.prev = NULL; \
- HASH_MAKE_TABLE(hh, add, _ha_oomed); \
- IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \
- (head) = (add); \
- IF_HASH_NONFATAL_OOM( } ) \
- } else { \
- void *_hs_iter = (head); \
- (add)->hh.tbl = (head)->hh.tbl; \
- HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn); \
- if (_hs_iter) { \
- (add)->hh.next = _hs_iter; \
- if (((add)->hh.prev = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev)) { \
- HH_FROM_ELMT((head)->hh.tbl, (add)->hh.prev)->next = (add); \
- } else { \
- (head) = (add); \
- } \
- HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev = (add); \
- } else { \
- HASH_APPEND_LIST(hh, head, add); \
- } \
- } \
- HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \
- HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE_INORDER"); \
-} while (0)
-
-#define HASH_ADD_KEYPTR_INORDER(hh,head,keyptr,keylen_in,add,cmpfcn) \
-do { \
- unsigned _hs_hashv; \
- HASH_VALUE(keyptr, keylen_in, _hs_hashv); \
- HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, _hs_hashv, add, cmpfcn); \
-} while (0)
-
-#define HASH_ADD_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,cmpfcn) \
- HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn)
-
-#define HASH_ADD_INORDER(hh,head,fieldname,keylen_in,add,cmpfcn) \
- HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn)
-
-#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add) \
-do { \
- IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \
- (add)->hh.hashv = (hashval); \
- (add)->hh.key = (char*) (keyptr); \
- (add)->hh.keylen = (unsigned) (keylen_in); \
- if (!(head)) { \
- (add)->hh.next = NULL; \
- (add)->hh.prev = NULL; \
- HASH_MAKE_TABLE(hh, add, _ha_oomed); \
- IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \
- (head) = (add); \
- IF_HASH_NONFATAL_OOM( } ) \
- } else { \
- (add)->hh.tbl = (head)->hh.tbl; \
- HASH_APPEND_LIST(hh, head, add); \
- } \
- HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \
- HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \
-} while (0)
-
-#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \
-do { \
- unsigned _ha_hashv; \
- HASH_VALUE(keyptr, keylen_in, _ha_hashv); \
- HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add); \
-} while (0)
-
-#define HASH_ADD_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add) \
- HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add)
-
-#define HASH_ADD(hh,head,fieldname,keylen_in,add) \
- HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
-
-#define HASH_TO_BKT(hashv,num_bkts,bkt) \
-do { \
- bkt = ((hashv) & ((num_bkts) - 1U)); \
-} while (0)
-
-/* delete "delptr" from the hash table.
- * "the usual" patch-up process for the app-order doubly-linked-list.
- * The use of _hd_hh_del below deserves special explanation.
- * These used to be expressed using (delptr) but that led to a bug
- * if someone used the same symbol for the head and deletee, like
- * HASH_DELETE(hh,users,users);
- * We want that to work, but by changing the head (users) below
- * we were forfeiting our ability to further refer to the deletee (users)
- * in the patch-up process. Solution: use scratch space to
- * copy the deletee pointer, then the latter references are via that
- * scratch pointer rather than through the repointed (users) symbol.
- */
-#define HASH_DELETE(hh,head,delptr) \
- HASH_DELETE_HH(hh, head, &(delptr)->hh)
-
-#define HASH_DELETE_HH(hh,head,delptrhh) \
-do { \
- struct UT_hash_handle *_hd_hh_del = (delptrhh); \
- if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \
- HASH_BLOOM_FREE((head)->hh.tbl); \
- uthash_free((head)->hh.tbl->buckets, \
- (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
- uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
- (head) = NULL; \
- } else { \
- unsigned _hd_bkt; \
- if (_hd_hh_del == (head)->hh.tbl->tail) { \
- (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev); \
- } \
- if (_hd_hh_del->prev != NULL) { \
- HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next; \
- } else { \
- DECLTYPE_ASSIGN(head, _hd_hh_del->next); \
- } \
- if (_hd_hh_del->next != NULL) { \
- HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev; \
- } \
- HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
- HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
- (head)->hh.tbl->num_items--; \
- } \
- HASH_FSCK(hh, head, "HASH_DELETE_HH"); \
-} while (0)
-
-/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */
-#define HASH_FIND_STR(head,findstr,out) \
- HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out)
-#define HASH_ADD_STR(head,strfield,add) \
- HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add)
-#define HASH_REPLACE_STR(head,strfield,add,replaced) \
- HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced)
-#define HASH_FIND_INT(head,findint,out) \
- HASH_FIND(hh,head,findint,sizeof(int),out)
-#define HASH_ADD_INT(head,intfield,add) \
- HASH_ADD(hh,head,intfield,sizeof(int),add)
-#define HASH_REPLACE_INT(head,intfield,add,replaced) \
- HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced)
-#define HASH_FIND_PTR(head,findptr,out) \
- HASH_FIND(hh,head,findptr,sizeof(void *),out)
-#define HASH_ADD_PTR(head,ptrfield,add) \
- HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
-#define HASH_REPLACE_PTR(head,ptrfield,add,replaced) \
- HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced)
-#define HASH_DEL(head,delptr) \
- HASH_DELETE(hh,head,delptr)
-
-/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined.
- * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined.
- */
-#ifdef HASH_DEBUG
-#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0)
-#define HASH_FSCK(hh,head,where) \
-do { \
- struct UT_hash_handle *_thh; \
- if (head) { \
- unsigned _bkt_i; \
- unsigned _count = 0; \
- char *_prev; \
- for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \
- unsigned _bkt_count = 0; \
- _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
- _prev = NULL; \
- while (_thh) { \
- if (_prev != (char*)(_thh->hh_prev)) { \
- HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \
- (where), (void*)_thh->hh_prev, (void*)_prev); \
- } \
- _bkt_count++; \
- _prev = (char*)(_thh); \
- _thh = _thh->hh_next; \
- } \
- _count += _bkt_count; \
- if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
- HASH_OOPS("%s: invalid bucket count %u, actual %u\n", \
- (where), (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
- } \
- } \
- if (_count != (head)->hh.tbl->num_items) { \
- HASH_OOPS("%s: invalid hh item count %u, actual %u\n", \
- (where), (head)->hh.tbl->num_items, _count); \
- } \
- _count = 0; \
- _prev = NULL; \
- _thh = &(head)->hh; \
- while (_thh) { \
- _count++; \
- if (_prev != (char*)_thh->prev) { \
- HASH_OOPS("%s: invalid prev %p, actual %p\n", \
- (where), (void*)_thh->prev, (void*)_prev); \
- } \
- _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
- _thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \
- } \
- if (_count != (head)->hh.tbl->num_items) { \
- HASH_OOPS("%s: invalid app item count %u, actual %u\n", \
- (where), (head)->hh.tbl->num_items, _count); \
- } \
- } \
-} while (0)
-#else
-#define HASH_FSCK(hh,head,where)
-#endif
-
-/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to
- * the descriptor to which this macro is defined for tuning the hash function.
- * The app can #include <unistd.h> to get the prototype for write(2). */
-#ifdef HASH_EMIT_KEYS
-#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \
-do { \
- unsigned _klen = fieldlen; \
- write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \
- write(HASH_EMIT_KEYS, keyptr, (unsigned long)fieldlen); \
-} while (0)
-#else
-#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)
-#endif
-
-/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */
-#ifdef HASH_FUNCTION
-#define HASH_FCN HASH_FUNCTION
-#else
-#define HASH_FCN HASH_JEN
-#endif
-
-/* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */
-#define HASH_BER(key,keylen,hashv) \
-do { \
- unsigned _hb_keylen = (unsigned)keylen; \
- const unsigned char *_hb_key = (const unsigned char*)(key); \
- (hashv) = 0; \
- while (_hb_keylen-- != 0U) { \
- (hashv) = (((hashv) << 5) + (hashv)) + *_hb_key++; \
- } \
-} while (0)
-
-
-/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at
- * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */
-#define HASH_SAX(key,keylen,hashv) \
-do { \
- unsigned _sx_i; \
- const unsigned char *_hs_key = (const unsigned char*)(key); \
- hashv = 0; \
- for (_sx_i=0; _sx_i < keylen; _sx_i++) { \
- hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \
- } \
-} while (0)
-/* FNV-1a variation */
-#define HASH_FNV(key,keylen,hashv) \
-do { \
- unsigned _fn_i; \
- const unsigned char *_hf_key = (const unsigned char*)(key); \
- (hashv) = 2166136261U; \
- for (_fn_i=0; _fn_i < keylen; _fn_i++) { \
- hashv = hashv ^ _hf_key[_fn_i]; \
- hashv = hashv * 16777619U; \
- } \
-} while (0)
-
-#define HASH_OAT(key,keylen,hashv) \
-do { \
- unsigned _ho_i; \
- const unsigned char *_ho_key=(const unsigned char*)(key); \
- hashv = 0; \
- for(_ho_i=0; _ho_i < keylen; _ho_i++) { \
- hashv += _ho_key[_ho_i]; \
- hashv += (hashv << 10); \
- hashv ^= (hashv >> 6); \
- } \
- hashv += (hashv << 3); \
- hashv ^= (hashv >> 11); \
- hashv += (hashv << 15); \
-} while (0)
-
-#define HASH_JEN_MIX(a,b,c) \
-do { \
- a -= b; a -= c; a ^= ( c >> 13 ); \
- b -= c; b -= a; b ^= ( a << 8 ); \
- c -= a; c -= b; c ^= ( b >> 13 ); \
- a -= b; a -= c; a ^= ( c >> 12 ); \
- b -= c; b -= a; b ^= ( a << 16 ); \
- c -= a; c -= b; c ^= ( b >> 5 ); \
- a -= b; a -= c; a ^= ( c >> 3 ); \
- b -= c; b -= a; b ^= ( a << 10 ); \
- c -= a; c -= b; c ^= ( b >> 15 ); \
-} while (0)
-
-#define HASH_JEN(key,keylen,hashv) \
-do { \
- unsigned _hj_i,_hj_j,_hj_k; \
- unsigned const char *_hj_key=(unsigned const char*)(key); \
- hashv = 0xfeedbeefu; \
- _hj_i = _hj_j = 0x9e3779b9u; \
- _hj_k = (unsigned)(keylen); \
- while (_hj_k >= 12U) { \
- _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \
- + ( (unsigned)_hj_key[2] << 16 ) \
- + ( (unsigned)_hj_key[3] << 24 ) ); \
- _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \
- + ( (unsigned)_hj_key[6] << 16 ) \
- + ( (unsigned)_hj_key[7] << 24 ) ); \
- hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \
- + ( (unsigned)_hj_key[10] << 16 ) \
- + ( (unsigned)_hj_key[11] << 24 ) ); \
- \
- HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
- \
- _hj_key += 12; \
- _hj_k -= 12U; \
- } \
- hashv += (unsigned)(keylen); \
- switch ( _hj_k ) { \
- case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
- case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); /* FALLTHROUGH */ \
- case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); /* FALLTHROUGH */ \
- case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); /* FALLTHROUGH */ \
- case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); /* FALLTHROUGH */ \
- case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); /* FALLTHROUGH */ \
- case 5: _hj_j += _hj_key[4]; /* FALLTHROUGH */ \
- case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \
- case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \
- case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \
- case 1: _hj_i += _hj_key[0]; \
- } \
- HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
-} while (0)
-
-/* The Paul Hsieh hash function */
-#undef get16bits
-#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
- || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
-#define get16bits(d) (*((const uint16_t *) (d)))
-#endif
-
-#if !defined (get16bits)
-#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
- +(uint32_t)(((const uint8_t *)(d))[0]) )
-#endif
-#define HASH_SFH(key,keylen,hashv) \
-do { \
- unsigned const char *_sfh_key=(unsigned const char*)(key); \
- uint32_t _sfh_tmp, _sfh_len = (uint32_t)keylen; \
- \
- unsigned _sfh_rem = _sfh_len & 3U; \
- _sfh_len >>= 2; \
- hashv = 0xcafebabeu; \
- \
- /* Main loop */ \
- for (;_sfh_len > 0U; _sfh_len--) { \
- hashv += get16bits (_sfh_key); \
- _sfh_tmp = ((uint32_t)(get16bits (_sfh_key+2)) << 11) ^ hashv; \
- hashv = (hashv << 16) ^ _sfh_tmp; \
- _sfh_key += 2U*sizeof (uint16_t); \
- hashv += hashv >> 11; \
- } \
- \
- /* Handle end cases */ \
- switch (_sfh_rem) { \
- case 3: hashv += get16bits (_sfh_key); \
- hashv ^= hashv << 16; \
- hashv ^= (uint32_t)(_sfh_key[sizeof (uint16_t)]) << 18; \
- hashv += hashv >> 11; \
- break; \
- case 2: hashv += get16bits (_sfh_key); \
- hashv ^= hashv << 11; \
- hashv += hashv >> 17; \
- break; \
- case 1: hashv += *_sfh_key; \
- hashv ^= hashv << 10; \
- hashv += hashv >> 1; \
- } \
- \
- /* Force "avalanching" of final 127 bits */ \
- hashv ^= hashv << 3; \
- hashv += hashv >> 5; \
- hashv ^= hashv << 4; \
- hashv += hashv >> 17; \
- hashv ^= hashv << 25; \
- hashv += hashv >> 6; \
-} while (0)
-
-#ifdef HASH_USING_NO_STRICT_ALIASING
-/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads.
- * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error.
- * MurmurHash uses the faster approach only on CPU's where we know it's safe.
- *
- * Note the preprocessor built-in defines can be emitted using:
- *
- * gcc -m64 -dM -E - < /dev/null (on gcc)
- * cc -## a.c (where a.c is a simple test file) (Sun Studio)
- */
-#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86))
-#define MUR_GETBLOCK(p,i) p[i]
-#else /* non intel */
-#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL)
-#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL)
-#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL)
-#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL)
-#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL))
-#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__))
-#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24))
-#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16))
-#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8))
-#else /* assume little endian non-intel */
-#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24))
-#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16))
-#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8))
-#endif
-#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \
- (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \
- (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \
- MUR_ONE_THREE(p))))
-#endif
-#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r))))
-#define MUR_FMIX(_h) \
-do { \
- _h ^= _h >> 16; \
- _h *= 0x85ebca6bu; \
- _h ^= _h >> 13; \
- _h *= 0xc2b2ae35u; \
- _h ^= _h >> 16; \
-} while (0)
-
-#define HASH_MUR(key,keylen,hashv) \
-do { \
- const uint8_t *_mur_data = (const uint8_t*)(key); \
- const int _mur_nblocks = (int)(keylen) / 4; \
- uint32_t _mur_h1 = 0xf88D5353u; \
- uint32_t _mur_c1 = 0xcc9e2d51u; \
- uint32_t _mur_c2 = 0x1b873593u; \
- uint32_t _mur_k1 = 0; \
- const uint8_t *_mur_tail; \
- const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+(_mur_nblocks*4)); \
- int _mur_i; \
- for (_mur_i = -_mur_nblocks; _mur_i != 0; _mur_i++) { \
- _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \
- _mur_k1 *= _mur_c1; \
- _mur_k1 = MUR_ROTL32(_mur_k1,15); \
- _mur_k1 *= _mur_c2; \
- \
- _mur_h1 ^= _mur_k1; \
- _mur_h1 = MUR_ROTL32(_mur_h1,13); \
- _mur_h1 = (_mur_h1*5U) + 0xe6546b64u; \
- } \
- _mur_tail = (const uint8_t*)(_mur_data + (_mur_nblocks*4)); \
- _mur_k1=0; \
- switch ((keylen) & 3U) { \
- case 0: break; \
- case 3: _mur_k1 ^= (uint32_t)_mur_tail[2] << 16; /* FALLTHROUGH */ \
- case 2: _mur_k1 ^= (uint32_t)_mur_tail[1] << 8; /* FALLTHROUGH */ \
- case 1: _mur_k1 ^= (uint32_t)_mur_tail[0]; \
- _mur_k1 *= _mur_c1; \
- _mur_k1 = MUR_ROTL32(_mur_k1,15); \
- _mur_k1 *= _mur_c2; \
- _mur_h1 ^= _mur_k1; \
- } \
- _mur_h1 ^= (uint32_t)(keylen); \
- MUR_FMIX(_mur_h1); \
- hashv = _mur_h1; \
-} while (0)
-#endif /* HASH_USING_NO_STRICT_ALIASING */
-
-/* iterate over items in a known bucket to find desired item */
-#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out) \
-do { \
- if ((head).hh_head != NULL) { \
- DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head)); \
- } else { \
- (out) = NULL; \
- } \
- while ((out) != NULL) { \
- if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \
- if (uthash_memcmp((out)->hh.key, keyptr, keylen_in) == 0) { \
- break; \
- } \
- } \
- if ((out)->hh.hh_next != NULL) { \
- DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (out)->hh.hh_next)); \
- } else { \
- (out) = NULL; \
- } \
- } \
-} while (0)
-
-/* add an item to a bucket */
-#define HASH_ADD_TO_BKT(head,hh,addhh,oomed) \
-do { \
- UT_hash_bucket *_ha_head = &(head); \
- _ha_head->count++; \
- (addhh)->hh_next = _ha_head->hh_head; \
- (addhh)->hh_prev = NULL; \
- if (_ha_head->hh_head != NULL) { \
- _ha_head->hh_head->hh_prev = (addhh); \
- } \
- _ha_head->hh_head = (addhh); \
- if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
- && !(addhh)->tbl->noexpand) { \
- HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed); \
- IF_HASH_NONFATAL_OOM( \
- if (oomed) { \
- HASH_DEL_IN_BKT(head,addhh); \
- } \
- ) \
- } \
-} while (0)
-
-/* remove an item from a given bucket */
-#define HASH_DEL_IN_BKT(head,delhh) \
-do { \
- UT_hash_bucket *_hd_head = &(head); \
- _hd_head->count--; \
- if (_hd_head->hh_head == (delhh)) { \
- _hd_head->hh_head = (delhh)->hh_next; \
- } \
- if ((delhh)->hh_prev) { \
- (delhh)->hh_prev->hh_next = (delhh)->hh_next; \
- } \
- if ((delhh)->hh_next) { \
- (delhh)->hh_next->hh_prev = (delhh)->hh_prev; \
- } \
-} while (0)
-
-/* Bucket expansion has the effect of doubling the number of buckets
- * and redistributing the items into the new buckets. Ideally the
- * items will distribute more or less evenly into the new buckets
- * (the extent to which this is true is a measure of the quality of
- * the hash function as it applies to the key domain).
- *
- * With the items distributed into more buckets, the chain length
- * (item count) in each bucket is reduced. Thus by expanding buckets
- * the hash keeps a bound on the chain length. This bounded chain
- * length is the essence of how a hash provides constant time lookup.
- *
- * The calculation of tbl->ideal_chain_maxlen below deserves some
- * explanation. First, keep in mind that we're calculating the ideal
- * maximum chain length based on the *new* (doubled) bucket count.
- * In fractions this is just n/b (n=number of items,b=new num buckets).
- * Since the ideal chain length is an integer, we want to calculate
- * ceil(n/b). We don't depend on floating point arithmetic in this
- * hash, so to calculate ceil(n/b) with integers we could write
- *
- * ceil(n/b) = (n/b) + ((n%b)?1:0)
- *
- * and in fact a previous version of this hash did just that.
- * But now we have improved things a bit by recognizing that b is
- * always a power of two. We keep its base 2 log handy (call it lb),
- * so now we can write this with a bit shift and logical AND:
- *
- * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
- *
- */
-#define HASH_EXPAND_BUCKETS(hh,tbl,oomed) \
-do { \
- unsigned _he_bkt; \
- unsigned _he_bkt_i; \
- struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
- UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
- _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \
- 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
- if (!_he_new_buckets) { \
- HASH_RECORD_OOM(oomed); \
- } else { \
- uthash_bzero(_he_new_buckets, \
- 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
- (tbl)->ideal_chain_maxlen = \
- ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \
- ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \
- (tbl)->nonideal_items = 0; \
- for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \
- _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \
- while (_he_thh != NULL) { \
- _he_hh_nxt = _he_thh->hh_next; \
- HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \
- _he_newbkt = &(_he_new_buckets[_he_bkt]); \
- if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \
- (tbl)->nonideal_items++; \
- _he_newbkt->expand_mult = _he_newbkt->count / (tbl)->ideal_chain_maxlen; \
- } \
- _he_thh->hh_prev = NULL; \
- _he_thh->hh_next = _he_newbkt->hh_head; \
- if (_he_newbkt->hh_head != NULL) { \
- _he_newbkt->hh_head->hh_prev = _he_thh; \
- } \
- _he_newbkt->hh_head = _he_thh; \
- _he_thh = _he_hh_nxt; \
- } \
- } \
- uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
- (tbl)->num_buckets *= 2U; \
- (tbl)->log2_num_buckets++; \
- (tbl)->buckets = _he_new_buckets; \
- (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \
- ((tbl)->ineff_expands+1U) : 0U; \
- if ((tbl)->ineff_expands > 1U) { \
- (tbl)->noexpand = 1; \
- uthash_noexpand_fyi(tbl); \
- } \
- uthash_expand_fyi(tbl); \
- } \
-} while (0)
-
-
-/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */
-/* Note that HASH_SORT assumes the hash handle name to be hh.
- * HASH_SRT was added to allow the hash handle name to be passed in. */
-#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn)
-#define HASH_SRT(hh,head,cmpfcn) \
-do { \
- unsigned _hs_i; \
- unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \
- struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \
- if (head != NULL) { \
- _hs_insize = 1; \
- _hs_looping = 1; \
- _hs_list = &((head)->hh); \
- while (_hs_looping != 0U) { \
- _hs_p = _hs_list; \
- _hs_list = NULL; \
- _hs_tail = NULL; \
- _hs_nmerges = 0; \
- while (_hs_p != NULL) { \
- _hs_nmerges++; \
- _hs_q = _hs_p; \
- _hs_psize = 0; \
- for (_hs_i = 0; _hs_i < _hs_insize; ++_hs_i) { \
- _hs_psize++; \
- _hs_q = ((_hs_q->next != NULL) ? \
- HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \
- if (_hs_q == NULL) { \
- break; \
- } \
- } \
- _hs_qsize = _hs_insize; \
- while ((_hs_psize != 0U) || ((_hs_qsize != 0U) && (_hs_q != NULL))) { \
- if (_hs_psize == 0U) { \
- _hs_e = _hs_q; \
- _hs_q = ((_hs_q->next != NULL) ? \
- HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \
- _hs_qsize--; \
- } else if ((_hs_qsize == 0U) || (_hs_q == NULL)) { \
- _hs_e = _hs_p; \
- if (_hs_p != NULL) { \
- _hs_p = ((_hs_p->next != NULL) ? \
- HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : NULL); \
- } \
- _hs_psize--; \
- } else if ((cmpfcn( \
- DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \
- DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)) \
- )) <= 0) { \
- _hs_e = _hs_p; \
- if (_hs_p != NULL) { \
- _hs_p = ((_hs_p->next != NULL) ? \
- HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : NULL); \
- } \
- _hs_psize--; \
- } else { \
- _hs_e = _hs_q; \
- _hs_q = ((_hs_q->next != NULL) ? \
- HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \
- _hs_qsize--; \
- } \
- if ( _hs_tail != NULL ) { \
- _hs_tail->next = ((_hs_e != NULL) ? \
- ELMT_FROM_HH((head)->hh.tbl, _hs_e) : NULL); \
- } else { \
- _hs_list = _hs_e; \
- } \
- if (_hs_e != NULL) { \
- _hs_e->prev = ((_hs_tail != NULL) ? \
- ELMT_FROM_HH((head)->hh.tbl, _hs_tail) : NULL); \
- } \
- _hs_tail = _hs_e; \
- } \
- _hs_p = _hs_q; \
- } \
- if (_hs_tail != NULL) { \
- _hs_tail->next = NULL; \
- } \
- if (_hs_nmerges <= 1U) { \
- _hs_looping = 0; \
- (head)->hh.tbl->tail = _hs_tail; \
- DECLTYPE_ASSIGN(head, ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
- } \
- _hs_insize *= 2U; \
- } \
- HASH_FSCK(hh, head, "HASH_SRT"); \
- } \
-} while (0)
-
-/* This function selects items from one hash into another hash.
- * The end result is that the selected items have dual presence
- * in both hashes. There is no copy of the items made; rather
- * they are added into the new hash through a secondary hash
- * hash handle that must be present in the structure. */
-#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \
-do { \
- unsigned _src_bkt, _dst_bkt; \
- void *_last_elt = NULL, *_elt; \
- UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \
- ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \
- if ((src) != NULL) { \
- for (_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \
- for (_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \
- _src_hh != NULL; \
- _src_hh = _src_hh->hh_next) { \
- _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
- if (cond(_elt)) { \
- IF_HASH_NONFATAL_OOM( int _hs_oomed = 0; ) \
- _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \
- _dst_hh->key = _src_hh->key; \
- _dst_hh->keylen = _src_hh->keylen; \
- _dst_hh->hashv = _src_hh->hashv; \
- _dst_hh->prev = _last_elt; \
- _dst_hh->next = NULL; \
- if (_last_elt_hh != NULL) { \
- _last_elt_hh->next = _elt; \
- } \
- if ((dst) == NULL) { \
- DECLTYPE_ASSIGN(dst, _elt); \
- HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \
- IF_HASH_NONFATAL_OOM( \
- if (_hs_oomed) { \
- uthash_nonfatal_oom(_elt); \
- (dst) = NULL; \
- continue; \
- } \
- ) \
- } else { \
- _dst_hh->tbl = (dst)->hh_dst.tbl; \
- } \
- HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \
- HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \
- (dst)->hh_dst.tbl->num_items++; \
- IF_HASH_NONFATAL_OOM( \
- if (_hs_oomed) { \
- HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \
- HASH_DELETE_HH(hh_dst, dst, _dst_hh); \
- _dst_hh->tbl = NULL; \
- uthash_nonfatal_oom(_elt); \
- continue; \
- } \
- ) \
- HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \
- _last_elt = _elt; \
- _last_elt_hh = _dst_hh; \
- } \
- } \
- } \
- } \
- HASH_FSCK(hh_dst, dst, "HASH_SELECT"); \
-} while (0)
-
-#define HASH_CLEAR(hh,head) \
-do { \
- if ((head) != NULL) { \
- HASH_BLOOM_FREE((head)->hh.tbl); \
- uthash_free((head)->hh.tbl->buckets, \
- (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
- uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
- (head) = NULL; \
- } \
-} while (0)
-
-#define HASH_OVERHEAD(hh,head) \
- (((head) != NULL) ? ( \
- (size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
- ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
- sizeof(UT_hash_table) + \
- (HASH_BLOOM_BYTELEN))) : 0U)
-
-#ifdef NO_DECLTYPE
-#define HASH_ITER(hh,head,el,tmp) \
-for(((el)=(head)), ((*(char**)(&(tmp)))=(char*)((head!=NULL)?(head)->hh.next:NULL)); \
- (el) != NULL; ((el)=(tmp)), ((*(char**)(&(tmp)))=(char*)((tmp!=NULL)?(tmp)->hh.next:NULL)))
-#else
-#define HASH_ITER(hh,head,el,tmp) \
-for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL)); \
- (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL)))
-#endif
-
-/* obtain a count of items in the hash */
-#define HASH_COUNT(head) HASH_CNT(hh,head)
-#define HASH_CNT(hh,head) ((head != NULL)?((head)->hh.tbl->num_items):0U)
-
-typedef struct UT_hash_bucket {
- struct UT_hash_handle *hh_head;
- unsigned count;
-
- /* expand_mult is normally set to 0. In this situation, the max chain length
- * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If
- * the bucket's chain exceeds this length, bucket expansion is triggered).
- * However, setting expand_mult to a non-zero value delays bucket expansion
- * (that would be triggered by additions to this particular bucket)
- * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH.
- * (The multiplier is simply expand_mult+1). The whole idea of this
- * multiplier is to reduce bucket expansions, since they are expensive, in
- * situations where we know that a particular bucket tends to be overused.
- * It is better to let its chain length grow to a longer yet-still-bounded
- * value, than to do an O(n) bucket expansion too often.
- */
- unsigned expand_mult;
-
-} UT_hash_bucket;
-
-/* random signature used only to find hash tables in external analysis */
-#define HASH_SIGNATURE 0xa0111fe1u
-#define HASH_BLOOM_SIGNATURE 0xb12220f2u
-
-typedef struct UT_hash_table {
- UT_hash_bucket *buckets;
- unsigned num_buckets, log2_num_buckets;
- unsigned num_items;
- struct UT_hash_handle *tail; /* tail hh in app order, for fast append */
- ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */
-
- /* in an ideal situation (all buckets used equally), no bucket would have
- * more than ceil(#items/#buckets) items. that's the ideal chain length. */
- unsigned ideal_chain_maxlen;
-
- /* nonideal_items is the number of items in the hash whose chain position
- * exceeds the ideal chain maxlen. these items pay the penalty for an uneven
- * hash distribution; reaching them in a chain traversal takes >ideal steps */
- unsigned nonideal_items;
-
- /* ineffective expands occur when a bucket doubling was performed, but
- * afterward, more than half the items in the hash had nonideal chain
- * positions. If this happens on two consecutive expansions we inhibit any
- * further expansion, as it's not helping; this happens when the hash
- * function isn't a good fit for the key domain. When expansion is inhibited
- * the hash will still work, albeit no longer in constant time. */
- unsigned ineff_expands, noexpand;
-
- uint32_t signature; /* used only to find hash tables in external analysis */
-#ifdef HASH_BLOOM
- uint32_t bloom_sig; /* used only to test bloom exists in external analysis */
- uint8_t *bloom_bv;
- uint8_t bloom_nbits;
-#endif
-
-} UT_hash_table;
-
-typedef struct UT_hash_handle {
- struct UT_hash_table *tbl;
- void *prev; /* prev element in app order */
- void *next; /* next element in app order */
- struct UT_hash_handle *hh_prev; /* previous hh in bucket order */
- struct UT_hash_handle *hh_next; /* next hh in bucket order */
- void *key; /* ptr to enclosing struct's key */
- unsigned keylen; /* enclosing struct's key len */
- unsigned hashv; /* result of hash-fcn(key) */
-} UT_hash_handle;
-
-#endif /* UTHASH_H */ \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/font.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/font.h
deleted file mode 100644
index 1159c9c80d3..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/font.h
+++ /dev/null
@@ -1,120 +0,0 @@
-#ifndef CARYLL_FONT_H
-#define CARYLL_FONT_H
-
-#include "sfnt.h"
-
-struct _caryll_font;
-typedef struct _caryll_font otfcc_Font;
-
-#include "otfcc/glyph-order.h"
-
-#include "otfcc/table/fvar.h"
-
-#include "otfcc/table/head.h"
-#include "otfcc/table/glyf.h"
-#include "otfcc/table/CFF.h"
-#include "otfcc/table/maxp.h"
-#include "otfcc/table/hhea.h"
-#include "otfcc/table/hmtx.h"
-#include "otfcc/table/hdmx.h"
-#include "otfcc/table/vhea.h"
-#include "otfcc/table/vmtx.h"
-#include "otfcc/table/OS_2.h"
-#include "otfcc/table/post.h"
-#include "otfcc/table/name.h"
-#include "otfcc/table/meta.h"
-
-#include "otfcc/table/cmap.h"
-#include "otfcc/table/cvt.h"
-#include "otfcc/table/fpgm-prep.h"
-#include "otfcc/table/gasp.h"
-#include "otfcc/table/VDMX.h"
-
-#include "otfcc/table/LTSH.h"
-#include "otfcc/table/VORG.h"
-
-#include "otfcc/table/GDEF.h"
-#include "otfcc/table/BASE.h"
-#include "otfcc/table/otl.h"
-
-#include "otfcc/table/CPAL.h"
-#include "otfcc/table/COLR.h"
-#include "otfcc/table/SVG.h"
-
-#include "otfcc/table/_TSI.h"
-#include "otfcc/table/TSI5.h"
-
-typedef enum { FONTTYPE_TTF, FONTTYPE_CFF } otfcc_font_subtype;
-
-struct _caryll_font {
- otfcc_font_subtype subtype;
-
- table_fvar *fvar;
-
- table_head *head;
- table_hhea *hhea;
- table_maxp *maxp;
- table_OS_2 *OS_2;
- table_hmtx *hmtx;
- table_post *post;
- table_hdmx *hdmx;
-
- table_vhea *vhea;
- table_vmtx *vmtx;
- table_VORG *VORG;
-
- table_CFF *CFF_;
- table_glyf *glyf;
- table_cmap *cmap;
- table_name *name;
- table_meta *meta;
-
- table_fpgm_prep *fpgm;
- table_fpgm_prep *prep;
- table_cvt *cvt_;
- table_gasp *gasp;
- table_VDMX *VDMX;
-
- table_LTSH *LTSH;
-
- table_OTL *GSUB;
- table_OTL *GPOS;
- table_GDEF *GDEF;
- table_BASE *BASE;
-
- table_CPAL *CPAL;
- table_COLR *COLR;
- table_SVG *SVG_;
-
- table_TSI *TSI_01;
- table_TSI *TSI_23;
- table_TSI5 *TSI5;
-
- otfcc_GlyphOrder *glyph_order;
-};
-
-extern caryll_ElementInterfaceOf(otfcc_Font) {
- caryll_RT(otfcc_Font);
- void (*consolidate)(otfcc_Font * font, const otfcc_Options *options);
- void *(*createTable)(otfcc_Font * font, const uint32_t tag);
- void (*deleteTable)(otfcc_Font * font, const uint32_t tag);
-}
-otfcc_iFont;
-
-// Font builder interfaces
-typedef struct otfcc_IFontBuilder {
- otfcc_Font *(*read)(void *source, uint32_t index, const otfcc_Options *options);
- void (*free)(struct otfcc_IFontBuilder *self);
-} otfcc_IFontBuilder;
-otfcc_IFontBuilder *otfcc_newOTFReader(void);
-otfcc_IFontBuilder *otfcc_newJsonReader(void);
-
-// Font serializer interface
-typedef struct otfcc_IFontSerializer {
- void *(*serialize)(otfcc_Font *font, const otfcc_Options *options);
- void (*free)(struct otfcc_IFontSerializer *self);
-} otfcc_IFontSerializer;
-otfcc_IFontSerializer *otfcc_newJsonWriter(void);
-otfcc_IFontSerializer *otfcc_newOTFWriter(void);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/glyph-order.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/glyph-order.h
deleted file mode 100644
index 68ff92d9ec7..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/glyph-order.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef CARYLL_INCLUDE_GLYPH_ORDER_H
-#define CARYLL_INCLUDE_GLYPH_ORDER_H
-
-#include "dep/sds.h"
-#include "dep/json.h"
-#include "dep/uthash.h"
-#include "caryll/ownership.h"
-#include "otfcc/primitives.h"
-#include "otfcc/handle.h"
-#include "otfcc/options.h"
-
-typedef struct {
- glyphid_t gid;
- sds name;
- uint8_t orderType;
- uint32_t orderEntry;
- UT_hash_handle hhID;
- UT_hash_handle hhName;
-} otfcc_GlyphOrderEntry;
-
-typedef struct {
- otfcc_GlyphOrderEntry *byGID;
- otfcc_GlyphOrderEntry *byName;
-} otfcc_GlyphOrder;
-
-struct otfcc_GlyphOrderPackage {
- caryll_RT(otfcc_GlyphOrder);
- sds (*setByGID)(otfcc_GlyphOrder *go, glyphid_t gid, sds name);
- bool (*setByName)(otfcc_GlyphOrder *go, sds name, glyphid_t gid);
- bool (*nameAField_Shared)(otfcc_GlyphOrder *go, glyphid_t gid, sds *field); // return a shared name pointer
- bool (*consolidateHandle)(otfcc_GlyphOrder *go, otfcc_GlyphHandle *h);
- bool (*lookupName)(otfcc_GlyphOrder *go, sds name);
-};
-
-extern const struct otfcc_GlyphOrderPackage otfcc_pkgGlyphOrder;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/handle.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/handle.h
deleted file mode 100644
index 364d136307b..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/handle.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef CARYLL_INCLUDE_OTFCC_HANDLE_H
-#define CARYLL_INCLUDE_OTFCC_HANDLE_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include "dep/sds.h"
-#include "caryll/ownership.h"
-#include "caryll/element.h"
-#include "primitives.h"
-
-typedef enum {
- HANDLE_STATE_EMPTY = 0,
- HANDLE_STATE_INDEX = 1,
- HANDLE_STATE_NAME = 2,
- HANDLE_STATE_CONSOLIDATED = 3
-} handle_state;
-struct otfcc_Handle {
- handle_state state;
- glyphid_t index;
- OWNING sds name;
-};
-
-typedef struct otfcc_Handle otfcc_Handle;
-typedef struct otfcc_Handle otfcc_GlyphHandle;
-typedef struct otfcc_Handle otfcc_FDHandle;
-typedef struct otfcc_Handle otfcc_LookupHandle;
-typedef struct otfcc_Handle otfcc_AxisHandle;
-
-struct otfcc_HandlePackage {
- caryll_VT(otfcc_Handle);
- struct otfcc_Handle (*fromIndex)(glyphid_t id);
- struct otfcc_Handle (*fromName)(MOVE sds s);
- struct otfcc_Handle (*fromConsolidated)(glyphid_t id, COPY sds s);
- void (*consolidateTo)(struct otfcc_Handle *h, glyphid_t id, sds name);
-};
-
-extern const struct otfcc_HandlePackage otfcc_iHandle;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/logger.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/logger.h
deleted file mode 100644
index 83a4bea6e6a..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/logger.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef CARYLL_INCLUDE_LOGGER_H
-#define CARYLL_INCLUDE_LOGGER_H
-
-#include "dep/sds.h"
-#include "caryll/ownership.h"
-#include "primitives.h"
-
-typedef struct otfcc_ILoggerTarget {
- void (*dispose)(struct otfcc_ILoggerTarget *self); // destructor
- void (*push)(struct otfcc_ILoggerTarget *self, MOVE sds data); // push data
-} otfcc_ILoggerTarget;
-
-typedef enum { log_type_error = 0, log_type_warning = 1, log_type_info = 2, log_type_progress = 3 } otfcc_LoggerType;
-enum { log_vl_critical = 0, log_vl_important = 1, log_vl_notice = 2, log_vl_info = 5, log_vl_progress = 10 };
-
-typedef struct otfcc_ILogger {
- void (*dispose)(struct otfcc_ILogger *self); // destructor
- void (*indent)(struct otfcc_ILogger *self, const char *segment); // add a level
- void (*indentSDS)(struct otfcc_ILogger *self, MOVE sds segment); // add a level, using SDS
- void (*start)(struct otfcc_ILogger *self, const char *segment); // add a level, output a progress
- void (*startSDS)(struct otfcc_ILogger *self, MOVE sds segment); // add a level, output a progress
- void (*log)(struct otfcc_ILogger *self, uint8_t verbosity, otfcc_LoggerType type, const char *data); // log a data
- void (*logSDS)(struct otfcc_ILogger *self, uint8_t verbosity, otfcc_LoggerType type, MOVE sds data); // log a data
- void (*dedent)(struct otfcc_ILogger *self); // remove a level
- void (*finish)(struct otfcc_ILogger *self); // remove a level, finishing a ask
- void (*end)(struct otfcc_ILogger *self); // remove a level
- void (*setVerbosity)(struct otfcc_ILogger *self, uint8_t verbosity); // remove a level
- otfcc_ILoggerTarget *(*getTarget)(struct otfcc_ILogger *self); // query target
-} otfcc_ILogger;
-
-otfcc_ILogger *otfcc_newLogger(otfcc_ILoggerTarget *target);
-otfcc_ILoggerTarget *otfcc_newStdErrTarget(void);
-otfcc_ILoggerTarget *otfcc_newEmptyTarget(void);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/options.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/options.h
deleted file mode 100644
index 10e95d399de..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/options.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef CARYLL_INCLUDE_OPTIONS_H
-#define CARYLL_INCLUDE_OPTIONS_H
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include "logger.h"
-
-typedef struct {
- bool debug_wait_on_start;
- bool ignore_glyph_order;
- bool ignore_hints;
- bool has_vertical_metrics;
- bool export_fdselect;
- bool keep_average_char_width;
- bool keep_unicode_ranges;
- bool short_post;
- bool dummy_DSIG;
- bool keep_modified_time;
- bool instr_as_bytes;
- bool verbose;
- bool quiet;
- bool cff_short_vmtx;
- bool merge_lookups;
- bool merge_features;
- bool force_cid;
- bool cff_rollCharString;
- bool cff_doSubroutinize;
- bool stub_cmap4;
- bool decimal_cmap;
- bool name_glyphs_by_hash;
- bool name_glyphs_by_gid;
- char *glyph_name_prefix;
- otfcc_ILogger *logger;
-} otfcc_Options;
-
-otfcc_Options *otfcc_newOptions(void);
-void otfcc_deleteOptions(otfcc_Options *options);
-void otfcc_Options_optimizeTo(otfcc_Options *options, uint8_t level);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/primitives.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/primitives.h
deleted file mode 100644
index 69ae393be3a..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/primitives.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef CARYLL_INCLUDE_OTFCC_PRIMITIVES_H
-#define CARYLL_INCLUDE_OTFCC_PRIMITIVES_H
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <float.h>
-
-typedef int16_t f2dot14; // 2.14 Fixed number, representing a value between [-1, 1].
-typedef int32_t f16dot16; // 16.16 Fixed number, usually used by intermediate coordiantes of a font.
- // To deal with implicit deltas in GVAR we must be very careful about it.
- // Arithmetic operators saturate towards positive or negative infinity.
- // Infinity values short circuit expressions.
-
-typedef uint16_t glyphid_t; // Glyph index
-typedef uint16_t glyphclass_t; // Glyph class
-typedef uint16_t glyphsize_t; // GASP glyph size
-typedef uint16_t tableid_t; // Table/Font structure index
-typedef uint16_t colorid_t; // Color index
-typedef uint16_t shapeid_t; // Shape index
-typedef uint16_t cffsid_t; // CFF/CFF2 String index
-typedef uint32_t arity_t; // CFF Arity/Stack depth
-typedef uint32_t unicode_t; // Unicode
-
-typedef double pos_t; // Position
-typedef double scale_t; // transform scaling
-#define POS_MAX FLT_MAX
-#define POS_MIN FLT_MIN
-
-typedef double length_t; // Length
-
-double otfcc_from_f2dot14(const f2dot14 x);
-int16_t otfcc_to_f2dot14(const double x);
-double otfcc_from_fixed(const f16dot16 x);
-f16dot16 otfcc_to_fixed(const double x);
-
-#define f16dot16_precision 16
-#define f16dot16_k (1 << (f16dot16_precision - 1))
-#define f16dot16_infinity ((f16dot16)0x7fffffff)
-#define f16dot16_negativeIntinity ((f16dot16)0x80000000)
-
-f16dot16 otfcc_f1616_add(f16dot16 a, f16dot16 b);
-f16dot16 otfcc_f1616_minus(f16dot16 a, f16dot16 b);
-f16dot16 otfcc_f1616_multiply(f16dot16 a, f16dot16 b);
-f16dot16 otfcc_f1616_divide(f16dot16 a, f16dot16 b);
-f16dot16 otfcc_f1616_muldiv(f16dot16 a, f16dot16 b, f16dot16 c);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt-builder.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt-builder.h
deleted file mode 100644
index 313003a0eb5..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt-builder.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef CARYLL_SFNT_BUILDER_H
-#define CARYLL_SFNT_BUILDER_H
-
-#include "primitives.h"
-#include "caryll/buffer.h"
-#include "otfcc/options.h"
-#include "dep/uthash.h"
-
-typedef struct {
- int tag;
- uint32_t length;
- uint32_t checksum;
- caryll_Buffer *buffer;
- UT_hash_handle hh;
-} otfcc_SFNTTableEntry;
-
-typedef struct {
- uint32_t count;
- uint32_t header;
- otfcc_SFNTTableEntry *tables;
- const otfcc_Options *options;
-} otfcc_SFNTBuilder;
-
-otfcc_SFNTBuilder *otfcc_newSFNTBuilder(uint32_t header, const otfcc_Options *options);
-void otfcc_SFNTBuilder_pushTable(otfcc_SFNTBuilder *builder, uint32_t tag, caryll_Buffer *buffer);
-void otfcc_deleteSFNTBuilder(otfcc_SFNTBuilder *builder);
-
-caryll_Buffer *otfcc_SFNTBuilder_serialize(otfcc_SFNTBuilder *builder);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt.h
deleted file mode 100644
index 15e7975109d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/sfnt.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef CARYLL_INCLUDE_OTFCC_SFNT_H
-#define CARYLL_INCLUDE_OTFCC_SFNT_H
-
-#include <stdint.h>
-#include <stdio.h>
-
-typedef struct {
- uint32_t tag;
- uint32_t checkSum;
- uint32_t offset;
- uint32_t length;
- uint8_t *data;
-} otfcc_PacketPiece;
-
-typedef struct {
- uint32_t sfnt_version;
- uint16_t numTables;
- uint16_t searchRange;
- uint16_t entrySelector;
- uint16_t rangeShift;
- otfcc_PacketPiece *pieces;
-} otfcc_Packet;
-
-typedef struct {
- uint32_t type;
- uint32_t count;
- uint32_t *offsets;
- otfcc_Packet *packets;
-} otfcc_SplineFontContainer;
-
-otfcc_SplineFontContainer *otfcc_readSFNT(FILE *file);
-void otfcc_deleteSFNT(otfcc_SplineFontContainer *font);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/BASE.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/BASE.h
deleted file mode 100644
index 7d780f951ee..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/BASE.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_BASE_H
-#define CARYLL_INCLUDE_TABLE_BASE_H
-
-#include "otl.h"
-
-typedef struct {
- uint32_t tag;
- pos_t coordinate;
-} otl_BaseValue;
-
-typedef struct {
- uint32_t tag;
- uint32_t defaultBaselineTag;
- tableid_t baseValuesCount;
- OWNING otl_BaseValue *baseValues;
-} otl_BaseScriptEntry;
-
-typedef struct {
- tableid_t scriptCount;
- otl_BaseScriptEntry *entries;
-} otl_BaseAxis;
-
-typedef struct {
- otl_BaseAxis *horizontal;
- otl_BaseAxis *vertical;
-} table_BASE;
-
-extern caryll_RefElementInterface(table_BASE) table_iBASE;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CFF.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CFF.h
deleted file mode 100644
index 26ccc26a437..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CFF.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_CFF_H
-#define CARYLL_INCLUDE_TABLE_CFF_H
-
-#include "table-common.h"
-#include "head.h"
-#include "glyf.h"
-
-typedef struct {
- scale_t a;
- scale_t b;
- scale_t c;
- scale_t d;
- VQ x;
- VQ y;
-} cff_FontMatrix;
-
-typedef struct {
- arity_t blueValuesCount;
- OWNING double *blueValues;
- arity_t otherBluesCount;
- OWNING double *otherBlues;
- arity_t familyBluesCount;
- OWNING double *familyBlues;
- arity_t familyOtherBluesCount;
- OWNING double *familyOtherBlues;
- double blueScale;
- double blueShift;
- double blueFuzz;
- double stdHW;
- double stdVW;
- arity_t stemSnapHCount;
- OWNING double *stemSnapH;
- arity_t stemSnapVCount;
- OWNING double *stemSnapV;
- bool forceBold;
- uint32_t languageGroup;
- double expansionFactor;
- double initialRandomSeed;
- double defaultWidthX;
- double nominalWidthX;
-} cff_PrivateDict;
-
-typedef struct _table_CFF table_CFF;
-
-struct _table_CFF {
- // Name
- sds fontName;
-
- // General properties
- bool isCID;
- sds version;
- sds notice;
- sds copyright;
- sds fullName;
- sds familyName;
- sds weight;
- bool isFixedPitch;
- double italicAngle;
- double underlinePosition;
- double underlineThickness;
- double fontBBoxTop;
- double fontBBoxBottom;
- double fontBBoxLeft;
- double fontBBoxRight;
- double strokeWidth;
- OWNING cff_PrivateDict *privateDict;
- OWNING cff_FontMatrix *fontMatrix;
-
- // CID-only operators
- sds cidRegistry;
- sds cidOrdering;
- uint32_t cidSupplement;
- double cidFontVersion;
- double cidFontRevision;
- uint32_t cidCount;
- uint32_t UIDBase;
- // CID FDArray
- tableid_t fdArrayCount;
- OWNING table_CFF **fdArray;
-};
-
-extern caryll_RefElementInterface(table_CFF) table_iCFF;
-
-// CFF and glyf
-typedef struct {
- OWNING table_CFF *meta;
- OWNING table_glyf *glyphs;
-} table_CFFAndGlyf;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/COLR.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/COLR.h
deleted file mode 100644
index a89e9691ae1..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/COLR.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_COLR_H
-#define CARYLL_INCLUDE_TABLE_COLR_H
-
-#include "table-common.h"
-
-// Layer and layer vector
-typedef struct {
- otfcc_GlyphHandle glyph;
- colorid_t paletteIndex;
-} colr_Layer;
-extern caryll_ElementInterface(colr_Layer) colr_iLayer;
-typedef caryll_Vector(colr_Layer) colr_LayerList;
-extern caryll_VectorInterface(colr_LayerList, colr_Layer) colr_iLayerList;
-
-// glyph-to-layers mapping and COLR table
-typedef struct {
- otfcc_GlyphHandle glyph;
- colr_LayerList layers;
-} colr_Mapping;
-extern caryll_ElementInterface(colr_Mapping) colr_iMapping;
-typedef caryll_Vector(colr_Mapping) table_COLR;
-extern caryll_VectorInterface(table_COLR, colr_Mapping) table_iCOLR;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CPAL.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CPAL.h
deleted file mode 100644
index cd45e1e0b4e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/CPAL.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_CPAL_H
-#define CARYLL_INCLUDE_TABLE_CPAL_H
-
-#include "table-common.h"
-
-// Color and Color list
-typedef struct {
- uint8_t red;
- uint8_t green;
- uint8_t blue;
- uint8_t alpha;
- uint16_t label;
-} cpal_Color;
-extern caryll_ElementInterface(cpal_Color) cpal_iColor;
-typedef caryll_Vector(cpal_Color) cpal_ColorSet;
-extern caryll_VectorInterface(cpal_ColorSet, cpal_Color) cpal_iColorSet;
-
-// Palette and Palette list
-typedef struct {
- cpal_ColorSet colorset;
- uint32_t type;
- uint32_t label;
-} cpal_Palette;
-extern caryll_ElementInterface(cpal_Palette) cpal_iPalette;
-typedef caryll_Vector(cpal_Palette) cpal_PaletteSet;
-extern caryll_VectorInterface(cpal_PaletteSet, cpal_Palette) cpal_iPaletteSet;
-
-// CPAL table
-typedef struct {
- uint16_t version;
- cpal_PaletteSet palettes;
-} table_CPAL;
-extern caryll_RefElementInterface(table_CPAL) table_iCPAL;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/GDEF.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/GDEF.h
deleted file mode 100644
index aba93c7eeb6..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/GDEF.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_GEDF_H
-#define CARYLL_INCLUDE_TABLE_GEDF_H
-
-#include "otl.h"
-
-typedef struct {
- int8_t format;
- pos_t coordiante;
- int16_t pointIndex;
-} otl_CaretValue;
-extern caryll_ElementInterface(otl_CaretValue) otl_iCaretValue;
-typedef caryll_Vector(otl_CaretValue) otl_CaretValueList;
-extern caryll_VectorInterface(otl_CaretValueList, otl_CaretValue) otl_iCaretValueList;
-
-typedef struct {
- otfcc_GlyphHandle glyph;
- OWNING otl_CaretValueList carets;
-} otl_CaretValueRecord;
-extern caryll_ElementInterface(otl_CaretValueRecord) otl_iCaretValueRecord;
-typedef caryll_Vector(otl_CaretValueRecord) otl_LigCaretTable;
-extern caryll_VectorInterface(otl_LigCaretTable, otl_CaretValueRecord) otl_iLigCaretTable;
-
-typedef struct {
- OWNING otl_ClassDef *glyphClassDef;
- OWNING otl_ClassDef *markAttachClassDef;
- OWNING otl_LigCaretTable ligCarets;
-} table_GDEF;
-
-extern caryll_RefElementInterface(table_GDEF) table_iGDEF;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/LTSH.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/LTSH.h
deleted file mode 100644
index a59cc8add22..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/LTSH.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_LTSH_H
-#define CARYLL_INCLUDE_TABLE_LTSH_H
-
-#include "table-common.h"
-
-typedef struct {
- uint16_t version;
- glyphid_t numGlyphs;
- OWNING uint8_t *yPels;
-} table_LTSH;
-extern caryll_RefElementInterface(table_LTSH) table_iLTSH;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/OS_2.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/OS_2.h
deleted file mode 100644
index e604edd3ea8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/OS_2.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_OS_2_H
-#define CARYLL_INCLUDE_TABLE_OS_2_H
-
-#include "table-common.h"
-
-typedef struct {
- // OS/2 and Windows specific metrics
- uint16_t version;
- int16_t xAvgCharWidth;
- uint16_t usWeightClass;
- uint16_t usWidthClass;
- uint16_t fsType;
- int16_t ySubscriptXSize;
- int16_t ySubscriptYSize;
- int16_t ySubscriptXOffset;
- int16_t ySubscriptYOffset;
- int16_t ySupscriptXSize;
- int16_t ySupscriptYSize;
- int16_t ySupscriptXOffset;
- int16_t ySupscriptYOffset;
- int16_t yStrikeoutSize;
- int16_t yStrikeoutPosition;
- int16_t sFamilyClass;
- uint8_t panose[10];
- uint32_t ulUnicodeRange1;
- uint32_t ulUnicodeRange2;
- uint32_t ulUnicodeRange3;
- uint32_t ulUnicodeRange4;
- uint8_t achVendID[4];
- uint16_t fsSelection;
- uint16_t usFirstCharIndex;
- uint16_t usLastCharIndex;
- int16_t sTypoAscender;
- int16_t sTypoDescender;
- int16_t sTypoLineGap;
- uint16_t usWinAscent;
- uint16_t usWinDescent;
- uint32_t ulCodePageRange1;
- uint32_t ulCodePageRange2;
- int16_t sxHeight;
- int16_t sCapHeight;
- uint16_t usDefaultChar;
- uint16_t usBreakChar;
- uint16_t usMaxContext;
- uint16_t usLowerOpticalPointSize;
- uint16_t usUpperOpticalPointSize;
-} table_OS_2;
-extern caryll_RefElementInterface(table_OS_2) table_iOS_2;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/SVG.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/SVG.h
deleted file mode 100644
index 3105b88814e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/SVG.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_SVG_H
-#define CARYLL_INCLUDE_TABLE_SVG_H
-
-#include "table-common.h"
-
-// SVG assignment
-typedef struct {
- // Due to the outward references from SVG document to GID.
- // We have to use GID here. Sorry.
- glyphid_t start;
- glyphid_t end;
- caryll_Buffer *document;
-} svg_Assignment;
-extern caryll_ValElementInterface(svg_Assignment) svg_iAssignment;
-typedef caryll_Vector(svg_Assignment) table_SVG;
-extern caryll_VectorInterface(table_SVG, svg_Assignment) table_iSVG;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/TSI5.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/TSI5.h
deleted file mode 100644
index 57a95ae7583..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/TSI5.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_TSI5_H
-#define CARYLL_INCLUDE_TABLE_TSI5_H
-
-#include "table-common.h"
-#include "otl/classdef.h"
-
-// A TSI5 table is simply an OTL Class definition.
-typedef otl_ClassDef table_TSI5;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VDMX.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VDMX.h
deleted file mode 100644
index 0cd1f242b94..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VDMX.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_VDMX_H
-#define CARYLL_INCLUDE_TABLE_VDMX_H
-
-#include "table-common.h"
-
-typedef struct {
- uint16_t yPelHeight;
- int16_t yMax;
- int16_t yMin;
-} vdmx_Record;
-
-extern caryll_ValElementInterface(vdmx_Record) vdmx_iRecord;
-typedef caryll_Vector(vdmx_Record) vdmx_Group;
-extern caryll_VectorInterface(vdmx_Group, vdmx_Record) vdmx_iGroup;
-
-typedef struct {
- uint8_t bCharset;
- uint8_t xRatio;
- uint8_t yStartRatio;
- uint8_t yEndRatio;
-
- vdmx_Group records;
-} vdmx_RatioRange;
-
-extern caryll_ElementInterface(vdmx_RatioRange) vdmx_iRatioRange;
-typedef caryll_Vector(vdmx_RatioRange) vdmx_RatioRagneList;
-extern caryll_VectorInterface(vdmx_RatioRagneList, vdmx_RatioRange) vdmx_iRatioRangeList;
-
-typedef struct {
- uint16_t version;
- vdmx_RatioRagneList ratios;
-} table_VDMX;
-
-extern caryll_RefElementInterface(table_VDMX) table_iVDMX;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VORG.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VORG.h
deleted file mode 100644
index 065ee3da5dc..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/VORG.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_VORG_H
-#define CARYLL_INCLUDE_TABLE_VORG_H
-
-#include "table-common.h"
-
-typedef struct {
- glyphid_t gid;
- int16_t verticalOrigin;
-} VORG_entry;
-
-typedef struct {
- glyphid_t numVertOriginYMetrics;
- pos_t defaultVerticalOrigin;
- OWNING VORG_entry *entries;
-} table_VORG;
-
-extern caryll_RefElementInterface(table_VORG) table_iVORG;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/_TSI.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/_TSI.h
deleted file mode 100644
index dbafbb2ace6..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/_TSI.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_TSI_H
-#define CARYLL_INCLUDE_TABLE_TSI_H
-
-#include "table-common.h"
-
-// TSI entries
-typedef enum { TSI_GLYPH, TSI_FPGM, TSI_PREP, TSI_CVT, TSI_RESERVED_FFFC } tsi_EntryType;
-
-typedef struct {
- tsi_EntryType type;
- otfcc_GlyphHandle glyph;
- sds content;
-} tsi_Entry;
-
-extern caryll_ElementInterface(tsi_Entry) tsi_iEntry;
-typedef caryll_Vector(tsi_Entry) table_TSI;
-extern caryll_VectorInterface(table_TSI, tsi_Entry) table_iTSI;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cmap.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cmap.h
deleted file mode 100644
index 5cd2ad0cb72..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cmap.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_CMAP_H
-#define CARYLL_INCLUDE_TABLE_CMAP_H
-
-#include "table-common.h"
-
-// We will support format 0, 4, 12 and 14 of CMAP only
-typedef struct {
- UT_hash_handle hh;
- int unicode;
- otfcc_GlyphHandle glyph;
-} cmap_Entry;
-
-typedef struct {
- uint32_t unicode;
- uint32_t selector;
-} cmap_UVS_key;
-
-typedef struct {
- UT_hash_handle hh;
- cmap_UVS_key key;
- otfcc_GlyphHandle glyph;
-} cmap_UVS_Entry;
-
-typedef struct {
- OWNING cmap_Entry *unicodes;
- OWNING cmap_UVS_Entry *uvs;
-} table_cmap;
-
-extern caryll_ElementInterfaceOf(table_cmap) {
- caryll_RT(table_cmap);
- // unicode
- bool (*encodeByIndex)(table_cmap * cmap, int c, uint16_t gid);
- bool (*encodeByName)(table_cmap * cmap, int c, MOVE sds name);
- bool (*unmap)(table_cmap * cmap, int c);
- otfcc_GlyphHandle *(*lookup)(const table_cmap *cmap, int c);
- // uvs
- bool (*encodeUVSByIndex)(table_cmap * cmap, cmap_UVS_key c, uint16_t gid);
- bool (*encodeUVSByName)(table_cmap * cmap, cmap_UVS_key c, MOVE sds name);
- bool (*unmapUVS)(table_cmap * cmap, cmap_UVS_key c);
- otfcc_GlyphHandle *(*lookupUVS)(const table_cmap *cmap, cmap_UVS_key c);
-}
-table_iCmap;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cvt.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cvt.h
deleted file mode 100644
index 978ad1f648f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/cvt.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_CVT_H
-#define CARYLL_INCLUDE_TABLE_CVT_H
-
-#include "table-common.h"
-
-typedef struct {
- uint32_t length;
- OWNING uint16_t *words;
-} table_cvt;
-extern caryll_RefElementInterface(table_cvt) table_iCvt;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fpgm-prep.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fpgm-prep.h
deleted file mode 100644
index 850204b6d48..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fpgm-prep.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_FPGM_PREP_H
-#define CARYLL_INCLUDE_TABLE_FPGM_PREP_H
-
-#include "table-common.h"
-
-typedef struct {
- sds tag;
- uint32_t length;
- OWNING uint8_t *bytes;
-} table_fpgm_prep;
-
-extern caryll_RefElementInterface(table_fpgm_prep) table_iFpgm_prep;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fvar.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fvar.h
deleted file mode 100644
index 767496dfc3e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/fvar.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_FVAR_H
-#define CARYLL_INCLUDE_TABLE_FVAR_H
-
-#include "table-common.h"
-#include "otfcc/vf/vf.h"
-
-// vf_Axis and vf_Axes are defined in vf/vf.h
-// fvar_Instance is defined below
-typedef struct {
- uint16_t subfamilyNameID;
- uint16_t flags;
- VV coordinates;
- uint16_t postScriptNameID;
-} fvar_Instance;
-extern caryll_ElementInterface(fvar_Instance) fvar_iInstance;
-typedef caryll_Vector(fvar_Instance) fvar_InstanceList;
-extern caryll_VectorInterface(fvar_InstanceList, fvar_Instance) fvar_iInstanceList;
-
-typedef struct {
- sds name;
- vq_Region *region;
- UT_hash_handle hh;
-} fvar_Master;
-
-typedef struct {
- uint16_t majorVersion;
- uint16_t minorVersion;
- vf_Axes axes;
- fvar_InstanceList instances;
- fvar_Master *masters;
-} table_fvar;
-
-extern caryll_ElementInterfaceOf(table_fvar) {
- caryll_RT(table_fvar);
- const vq_Region *(*registerRegion)(table_fvar * fvar, MOVE vq_Region * region);
- const fvar_Master *(*findMasterByRegion)(const table_fvar *fvar, const vq_Region *region);
-}
-table_iFvar;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/gasp.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/gasp.h
deleted file mode 100644
index b8a995fa988..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/gasp.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_GASP_H
-#define CARYLL_INCLUDE_TABLE_GASP_H
-
-#include "table-common.h"
-
-typedef struct {
- glyphsize_t rangeMaxPPEM;
- bool dogray;
- bool gridfit;
- bool symmetric_smoothing;
- bool symmetric_gridfit;
-} gasp_Record;
-extern caryll_ElementInterface(gasp_Record) gasp_iRecord;
-typedef caryll_Vector(gasp_Record) gasp_RecordList;
-extern caryll_VectorInterface(gasp_RecordList, gasp_Record) gasp_iRecordList;
-
-typedef struct {
- uint16_t version;
- OWNING gasp_RecordList records;
-} table_gasp;
-
-extern caryll_RefElementInterface(table_gasp) table_iGasp;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/glyf.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/glyf.h
deleted file mode 100644
index 740492cbb96..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/glyf.h
+++ /dev/null
@@ -1,129 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_GLYF_H
-#define CARYLL_INCLUDE_TABLE_GLYF_H
-
-#include "table-common.h"
-#include "head.h"
-#include "maxp.h"
-#include "fvar.h"
-
-enum GlyphType { SIMPLE, COMPOSITE };
-
-typedef struct {
- VQ x;
- VQ y;
- int8_t onCurve; // a mask indicates whether a point is on-curve or off-curve
- // bit 0 : 1 for on-curve, 0 for off-curve. JSON field: "on"
- // bit 1 - 7 : unused, set to 0
- // in JSON, they are separated into several boolean fields.
-} glyf_Point;
-extern caryll_ValElementInterface(glyf_Point) glyf_iPoint;
-typedef caryll_Vector(glyf_Point) glyf_Contour;
-extern caryll_VectorInterface(glyf_Contour, glyf_Point) glyf_iContour;
-
-typedef caryll_Vector(glyf_Contour) glyf_ContourList;
-extern caryll_VectorInterface(glyf_ContourList, glyf_Contour) glyf_iContourList;
-
-// CFF stems and hint masks
-typedef struct {
- pos_t position;
- pos_t width;
- uint16_t map;
-} glyf_PostscriptStemDef;
-extern caryll_ElementInterface(glyf_PostscriptStemDef) glyf_iPostscriptStemDef;
-typedef caryll_Vector(glyf_PostscriptStemDef) glyf_StemDefList;
-extern caryll_VectorInterface(glyf_StemDefList, glyf_PostscriptStemDef) glyf_iStemDefList;
-
-typedef struct {
- uint16_t pointsBefore;
- uint16_t contoursBefore;
- bool maskH[0x100];
- bool maskV[0x100];
-} glyf_PostscriptHintMask;
-extern caryll_ElementInterface(glyf_PostscriptHintMask) glyf_iPostscriptHintMask;
-typedef caryll_Vector(glyf_PostscriptHintMask) glyf_MaskList;
-extern caryll_VectorInterface(glyf_MaskList, glyf_PostscriptHintMask) glyf_iMaskList;
-
-typedef enum {
- REF_XY = 0,
- REF_ANCHOR_ANCHOR = 1,
- REF_ANCHOR_XY = 2,
- REF_ANCHOR_CONSOLIDATED = 3,
- REF_ANCHOR_CONSOLIDATING_ANCHOR = 4,
- REF_ANCHOR_CONSOLIDATING_XY = 5,
-} RefAnchorStatus;
-
-typedef struct {
- //// NOTE: this part and below looks like a glyf_Point
- VQ x;
- VQ y;
- // flags
- bool roundToGrid;
- bool useMyMetrics;
- // the glyph being referenced
- otfcc_GlyphHandle glyph;
- // transformation term
- scale_t a;
- scale_t b;
- scale_t c;
- scale_t d;
- // Anchorness term
- RefAnchorStatus isAnchored;
- shapeid_t inner;
- shapeid_t outer;
-} glyf_ComponentReference;
-extern caryll_ValElementInterface(glyf_ComponentReference) glyf_iComponentReference;
-typedef caryll_Vector(glyf_ComponentReference) glyf_ReferenceList;
-extern caryll_VectorInterface(glyf_ReferenceList, glyf_ComponentReference) glyf_iReferenceList;
-
-typedef struct {
- pos_t xMin;
- pos_t xMax;
- pos_t yMin;
- pos_t yMax;
- uint16_t nestDepth;
- uint16_t nPoints;
- uint16_t nContours;
- uint16_t nCompositePoints;
- uint16_t nCompositeContours;
-} glyf_GlyphStat;
-
-typedef struct {
- sds name;
-
- // Metrics
- VQ horizontalOrigin;
- VQ advanceWidth;
- VQ verticalOrigin;
- VQ advanceHeight;
-
- // Outline
- // NOTE: SFNT does not support mixed glyphs, but we do.
- OWNING glyf_ContourList contours;
- OWNING glyf_ReferenceList references;
-
- // Postscript hints
- OWNING glyf_StemDefList stemH;
- OWNING glyf_StemDefList stemV;
- OWNING glyf_MaskList hintMasks;
- OWNING glyf_MaskList contourMasks;
-
- // TTF instructions
- uint16_t instructionsLength;
- uint8_t *instructions;
- // TTF Screen specific
- uint8_t yPel;
-
- // CID FDSelect
- otfcc_FDHandle fdSelect;
- glyphid_t cid; // Subset CID fonts may need this to represent the original CID entry
-
- // Stats
- glyf_GlyphStat stat;
-} glyf_Glyph;
-
-typedef glyf_Glyph *glyf_GlyphPtr;
-extern caryll_ElementInterface(glyf_GlyphPtr) glyf_iGlyphPtr;
-typedef caryll_Vector(glyf_GlyphPtr) table_glyf;
-extern caryll_VectorInterface(table_glyf, glyf_GlyphPtr) table_iGlyf;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hdmx.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hdmx.h
deleted file mode 100644
index 4349b6e8d6a..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hdmx.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_HDMX_H
-#define CARYLL_INCLUDE_TABLE_HDMX_H
-
-#include "table-common.h"
-#include "maxp.h"
-
-typedef struct {
- uint8_t pixelSize;
- uint8_t maxWidth;
- uint8_t *widths;
-} device_record;
-
-typedef struct {
- // Horizontal device metrics
- uint16_t version;
- uint16_t numRecords;
- uint32_t sizeDeviceRecord;
- OWNING device_record *records;
-} table_hdmx;
-
-extern caryll_RefElementInterface(table_hdmx) table_iHdmx;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/head.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/head.h
deleted file mode 100644
index 04faac3003d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/head.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_HEAD_H
-#define CARYLL_INCLUDE_TABLE_HEAD_H
-
-#include "table-common.h"
-
-typedef struct {
- // Font header
- f16dot16 version;
- uint32_t fontRevision;
- uint32_t checkSumAdjustment;
- uint32_t magicNumber;
- uint16_t flags;
- uint16_t unitsPerEm;
- int64_t created;
- int64_t modified;
- int16_t xMin;
- int16_t yMin;
- int16_t xMax;
- int16_t yMax;
- uint16_t macStyle;
- uint16_t lowestRecPPEM;
- int16_t fontDirectoryHint;
- int16_t indexToLocFormat;
- int16_t glyphDataFormat;
-} table_head;
-
-extern caryll_RefElementInterface(table_head) table_iHead;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hhea.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hhea.h
deleted file mode 100644
index d9d94b86867..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hhea.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_HHEA_H
-#define CARYLL_INCLUDE_TABLE_HHEA_H
-
-#include "table-common.h"
-
-typedef struct {
- // Horizontal header
- f16dot16 version;
- int16_t ascender;
- int16_t descender;
- int16_t lineGap;
- uint16_t advanceWidthMax;
- int16_t minLeftSideBearing;
- int16_t minRightSideBearing;
- int16_t xMaxExtent;
- int16_t caretSlopeRise;
- int16_t caretSlopeRun;
- int16_t caretOffset;
- int16_t reserved[4];
- int16_t metricDataFormat;
- uint16_t numberOfMetrics;
-} table_hhea;
-extern caryll_RefElementInterface(table_hhea) table_iHhea;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hmtx.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hmtx.h
deleted file mode 100644
index c9f3cc45a67..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/hmtx.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_HMTX_H
-#define CARYLL_INCLUDE_TABLE_HMTX_H
-
-#include "table-common.h"
-
-#include "hhea.h"
-#include "maxp.h"
-
-typedef struct {
- length_t advanceWidth;
- pos_t lsb;
-} horizontal_metric;
-
-typedef struct {
- // Horizontal metrics
- OWNING horizontal_metric *metrics;
- OWNING pos_t *leftSideBearing;
-} table_hmtx;
-extern caryll_RefElementInterface(table_hmtx) table_iHmtx;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/maxp.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/maxp.h
deleted file mode 100644
index 11bceb586ae..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/maxp.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_MAXP_H
-#define CARYLL_INCLUDE_TABLE_MAXP_H
-
-#include "table-common.h"
-
-typedef struct {
- // Maximum profile
- f16dot16 version;
- uint16_t numGlyphs;
- uint16_t maxPoints;
- uint16_t maxContours;
- uint16_t maxCompositePoints;
- uint16_t maxCompositeContours;
- uint16_t maxZones;
- uint16_t maxTwilightPoints;
- uint16_t maxStorage;
- uint16_t maxFunctionDefs;
- uint16_t maxInstructionDefs;
- uint16_t maxStackElements;
- uint16_t maxSizeOfInstructions;
- uint16_t maxComponentElements;
- uint16_t maxComponentDepth;
-} table_maxp;
-
-extern caryll_RefElementInterface(table_maxp) table_iMaxp;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/meta.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/meta.h
deleted file mode 100644
index a4464d11c43..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/meta.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_META_H
-#define CARYLL_INCLUDE_TABLE_META_H
-
-#include "table-common.h"
-
-// Layer and layer vector
-typedef struct {
- uint32_t tag;
- sds data;
-} meta_Entry;
-extern caryll_ElementInterface(meta_Entry) meta_iEntry;
-typedef caryll_Vector(meta_Entry) meta_Entries;
-extern caryll_VectorInterface(meta_Entries, meta_Entry) meta_iEntries;
-
-// glyph-to-layers mapping and COLR table
-typedef struct {
- uint32_t version;
- uint32_t flags;
- meta_Entries entries;
-} table_meta;
-extern caryll_RefElementInterface(table_meta) table_iMeta;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/name.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/name.h
deleted file mode 100644
index 8721a1d1245..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/name.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_NAME_H
-#define CARYLL_INCLUDE_TABLE_NAME_H
-
-#include "table-common.h"
-
-typedef struct {
- uint16_t platformID;
- uint16_t encodingID;
- uint16_t languageID;
- uint16_t nameID;
- sds nameString;
-} otfcc_NameRecord;
-extern caryll_ElementInterface(otfcc_NameRecord) otfcc_iNameRecord;
-typedef caryll_Vector(otfcc_NameRecord) table_name;
-extern caryll_VectorInterface(table_name, otfcc_NameRecord) table_iName;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl.h
deleted file mode 100644
index 4cbca062d64..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl.h
+++ /dev/null
@@ -1,260 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_OTL_H
-#define CARYLL_INCLUDE_TABLE_OTL_H
-
-#include "caryll/vector.h"
-#include "table-common.h"
-#include "otl/coverage.h"
-#include "otl/classdef.h"
-
-typedef enum {
- otl_type_unknown = 0,
-
- otl_type_gsub_unknown = 0x10,
- otl_type_gsub_single = 0x11,
- otl_type_gsub_multiple = 0x12,
- otl_type_gsub_alternate = 0x13,
- otl_type_gsub_ligature = 0x14,
- otl_type_gsub_context = 0x15,
- otl_type_gsub_chaining = 0x16,
- otl_type_gsub_extend = 0x17,
- otl_type_gsub_reverse = 0x18,
-
- otl_type_gpos_unknown = 0x20,
- otl_type_gpos_single = 0x21,
- otl_type_gpos_pair = 0x22,
- otl_type_gpos_cursive = 0x23,
- otl_type_gpos_markToBase = 0x24,
- otl_type_gpos_markToLigature = 0x25,
- otl_type_gpos_markToMark = 0x26,
- otl_type_gpos_context = 0x27,
- otl_type_gpos_chaining = 0x28,
- otl_type_gpos_extend = 0x29
-} otl_LookupType;
-
-
-/*typedef union _otl_subtable otl_Subtable;*/
-typedef struct _otl_lookup otl_Lookup;
-
-
-typedef struct {
- pos_t dx;
- pos_t dy;
- pos_t dWidth;
- pos_t dHeight;
-} otl_PositionValue;
-
-// GSUB subtable formats
-typedef struct {
- OWNING otfcc_GlyphHandle from;
- OWNING otfcc_GlyphHandle to;
-} otl_GsubSingleEntry;
-typedef caryll_Vector(otl_GsubSingleEntry) subtable_gsub_single;
-extern caryll_VectorInterface(subtable_gsub_single, otl_GsubSingleEntry) iSubtable_gsub_single;
-
-typedef struct {
- OWNING otfcc_GlyphHandle from;
- OWNING otl_Coverage *to;
-} otl_GsubMultiEntry;
-typedef caryll_Vector(otl_GsubMultiEntry) subtable_gsub_multi;
-extern caryll_VectorInterface(subtable_gsub_multi, otl_GsubMultiEntry) iSubtable_gsub_multi;
-
-typedef struct {
- OWNING otl_Coverage *from;
- OWNING otfcc_GlyphHandle to;
-} otl_GsubLigatureEntry;
-typedef caryll_Vector(otl_GsubLigatureEntry) subtable_gsub_ligature;
-extern caryll_VectorInterface(subtable_gsub_ligature,
- otl_GsubLigatureEntry) iSubtable_gsub_ligature;
-
-typedef enum {
- otl_chaining_canonical =
- 0, // The canonical form of chaining contextual substitution, one rule per subtable.
- otl_chaining_poly = 1, // The multi-rule form, right after reading OTF. N rule per subtable.
- otl_chaining_classified =
- 2 // The classified intermediate form, for building TTF with compression.
- // N rules, has classdefs, and coverage GID interpreted as class number.
-} otl_chaining_type;
-
-typedef struct {
- tableid_t index;
- otfcc_LookupHandle lookup;
-} otl_ChainLookupApplication;
-typedef struct {
- tableid_t matchCount;
- tableid_t inputBegins;
- tableid_t inputEnds;
- OWNING otl_Coverage **match;
- tableid_t applyCount;
- OWNING otl_ChainLookupApplication *apply;
-} otl_ChainingRule;
-typedef struct {
- otl_chaining_type type;
- union {
- otl_ChainingRule rule; // for type = otl_chaining_canonical
- struct { // for type = otl_chaining_poly or otl_chaining_classified
- tableid_t rulesCount;
- OWNING otl_ChainingRule **rules;
- OWNING otl_ClassDef *bc;
- OWNING otl_ClassDef *ic;
- OWNING otl_ClassDef *fc;
- };
- };
-} subtable_chaining;
-extern caryll_RefElementInterface(subtable_chaining) iSubtable_chaining;
-
-typedef struct {
- tableid_t matchCount;
- tableid_t inputIndex;
- OWNING otl_Coverage **match;
- OWNING otl_Coverage *to;
-} subtable_gsub_reverse;
-extern caryll_RefElementInterface(subtable_gsub_reverse) iSubtable_gsub_reverse;
-
-// GPOS subtable formats
-typedef struct {
- OWNING otfcc_GlyphHandle target;
- OWNING otl_PositionValue value;
-} otl_GposSingleEntry;
-typedef caryll_Vector(otl_GposSingleEntry) subtable_gpos_single;
-extern caryll_VectorInterface(subtable_gpos_single, otl_GposSingleEntry) iSubtable_gpos_single;
-
-typedef struct {
- bool present;
- pos_t x;
- pos_t y;
-} otl_Anchor;
-
-typedef struct {
- OWNING otl_ClassDef *first;
- OWNING otl_ClassDef *second;
- OWNING otl_PositionValue **firstValues;
- OWNING otl_PositionValue **secondValues;
-} subtable_gpos_pair;
-extern caryll_RefElementInterface(subtable_gpos_pair) iSubtable_gpos_pair;
-
-typedef struct {
- OWNING otfcc_GlyphHandle target;
- OWNING otl_Anchor enter;
- OWNING otl_Anchor exit;
-} otl_GposCursiveEntry;
-typedef caryll_Vector(otl_GposCursiveEntry) subtable_gpos_cursive;
-extern caryll_VectorInterface(subtable_gpos_cursive, otl_GposCursiveEntry) iSubtable_gpos_cursive;
-
-typedef struct {
- OWNING otfcc_GlyphHandle glyph;
- glyphclass_t markClass;
- otl_Anchor anchor;
-} otl_MarkRecord;
-typedef caryll_Vector(otl_MarkRecord) otl_MarkArray;
-extern caryll_VectorInterface(otl_MarkArray, otl_MarkRecord) otl_iMarkArray;
-
-typedef struct {
- OWNING otfcc_GlyphHandle glyph;
- OWNING otl_Anchor *anchors;
-} otl_BaseRecord;
-typedef caryll_Vector(otl_BaseRecord) otl_BaseArray;
-extern caryll_VectorInterface(otl_BaseArray, otl_BaseRecord) otl_iBaseArray;
-
-typedef struct {
- glyphclass_t classCount;
- OWNING otl_MarkArray markArray;
- otl_BaseArray baseArray;
-} subtable_gpos_markToSingle;
-extern caryll_RefElementInterface(subtable_gpos_markToSingle) iSubtable_gpos_markToSingle;
-
-typedef struct {
- OWNING otfcc_GlyphHandle glyph;
- glyphid_t componentCount;
- OWNING otl_Anchor **anchors;
-} otl_LigatureBaseRecord;
-typedef caryll_Vector(otl_LigatureBaseRecord) otl_LigatureArray;
-extern caryll_VectorInterface(otl_LigatureArray, otl_LigatureBaseRecord) otl_iLigatureArray;
-
-typedef struct {
- glyphclass_t classCount;
- OWNING otl_MarkArray markArray;
- otl_LigatureArray ligArray;
-} subtable_gpos_markToLigature;
-extern caryll_RefElementInterface(subtable_gpos_markToLigature) iSubtable_gpos_markToLigature;
-
-typedef struct {
- otl_LookupType type;
- /*otl_Subtable *subtable;*/
- union _otl_subtable *subtable;
-} subtable_extend;
-
-typedef union _otl_subtable {
- subtable_gsub_single gsub_single;
- subtable_gsub_multi gsub_multi;
- subtable_gsub_ligature gsub_ligature;
- subtable_chaining chaining;
- subtable_gsub_reverse gsub_reverse;
- subtable_gpos_single gpos_single;
- subtable_gpos_pair gpos_pair;
- subtable_gpos_cursive gpos_cursive;
- subtable_gpos_markToSingle gpos_markToSingle;
- subtable_gpos_markToLigature gpos_markToLigature;
- subtable_extend extend;
-} otl_Subtable;
-
-typedef otl_Subtable *otl_SubtablePtr;
-typedef caryll_Vector(otl_SubtablePtr) otl_SubtableList;
-extern caryll_VectorInterfaceTypeName(otl_SubtableList) {
- caryll_VectorInterfaceTrait(otl_SubtableList, otl_SubtablePtr);
- void (*disposeDependent)(MODIFY otl_SubtableList *, const otl_Lookup *);
-}
-otl_iSubtableList;
-
-struct _otl_lookup {
- sds name;
- otl_LookupType type;
- uint32_t _offset;
- uint16_t flags;
- OWNING otl_SubtableList subtables;
-};
-
-// owning lookup list
-typedef OWNING otl_Lookup *otl_LookupPtr;
-extern caryll_ElementInterface(otl_LookupPtr) otl_iLookupPtr;
-typedef caryll_Vector(otl_LookupPtr) otl_LookupList;
-extern caryll_VectorInterface(otl_LookupList, otl_LookupPtr) otl_iLookupList;
-
-// observe lookup list
-typedef OBSERVE otl_Lookup *otl_LookupRef;
-extern caryll_ElementInterface(otl_LookupRef) otl_iLookupRef;
-typedef caryll_Vector(otl_LookupRef) otl_LookupRefList;
-extern caryll_VectorInterface(otl_LookupRefList, otl_LookupRef) otl_iLookupRefList;
-
-typedef struct {
- sds name;
- OWNING otl_LookupRefList lookups;
-} otl_Feature;
-// owning feature list
-typedef OWNING otl_Feature *otl_FeaturePtr;
-extern caryll_ElementInterface(otl_FeaturePtr) otl_iFeaturePtr;
-typedef caryll_Vector(otl_FeaturePtr) otl_FeatureList;
-extern caryll_VectorInterface(otl_FeatureList, otl_FeaturePtr) otl_iFeatureList;
-// observe feature list
-typedef OBSERVE otl_Feature *otl_FeatureRef;
-extern caryll_ElementInterface(otl_FeatureRef) otl_iFeatureRef;
-typedef caryll_Vector(otl_FeatureRef) otl_FeatureRefList;
-extern caryll_VectorInterface(otl_FeatureRefList, otl_FeatureRef) otl_iFeatureRefList;
-
-typedef struct {
- sds name;
- OWNING otl_FeatureRef requiredFeature;
- OWNING otl_FeatureRefList features;
-} otl_LanguageSystem;
-typedef otl_LanguageSystem *otl_LanguageSystemPtr;
-extern caryll_ElementInterface(otl_LanguageSystemPtr) otl_iLanguageSystem;
-typedef caryll_Vector(otl_LanguageSystemPtr) otl_LangSystemList;
-extern caryll_VectorInterface(otl_LangSystemList, otl_LanguageSystemPtr) otl_iLangSystemList;
-
-typedef struct {
- otl_LookupList lookups;
- otl_FeatureList features;
- otl_LangSystemList languages;
-} table_OTL;
-extern caryll_RefElementInterface(table_OTL) table_iOTL;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/classdef.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/classdef.h
deleted file mode 100644
index 0bc380e6417..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/classdef.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_OTL_CLASSDEF_H
-#define CARYLL_INCLUDE_TABLE_OTL_CLASSDEF_H
-#include "../table-common.h"
-#include "coverage.h"
-
-typedef struct {
- glyphid_t numGlyphs;
- uint32_t capacity;
- glyphclass_t maxclass;
- otfcc_GlyphHandle *glyphs;
- glyphclass_t *classes;
-} otl_ClassDef;
-
-struct __otfcc_IClassDef {
- caryll_RT(otl_ClassDef);
- void (*push)(otl_ClassDef *cd, MOVE otfcc_GlyphHandle h, glyphclass_t cls);
-
- otl_ClassDef *(*read)(const uint8_t *data, uint32_t tableLength, uint32_t offset);
- otl_ClassDef *(*expand)(otl_Coverage *cov, otl_ClassDef *ocd);
- json_value *(*dump)(const otl_ClassDef *cd);
- otl_ClassDef *(*parse)(const json_value *_cd);
- caryll_Buffer *(*build)(const otl_ClassDef *cd);
- void (*shrink)(otl_ClassDef *cd);
-};
-
-extern const struct __otfcc_IClassDef otl_iClassDef;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/coverage.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/coverage.h
deleted file mode 100644
index d3e9656431a..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/otl/coverage.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_OTL_COVERAGE_H
-#define CARYLL_INCLUDE_TABLE_OTL_COVERAGE_H
-#include "../table-common.h"
-
-typedef struct {
- glyphid_t numGlyphs;
- uint32_t capacity;
- otfcc_GlyphHandle *glyphs;
-} otl_Coverage;
-
-struct __otfcc_ICoverage {
- caryll_RT(otl_Coverage);
- void (*clear)(otl_Coverage *coverage, uint32_t n);
- otl_Coverage *(*read)(const uint8_t *data, uint32_t tableLength, uint32_t offset);
- json_value *(*dump)(const otl_Coverage *coverage);
- otl_Coverage *(*parse)(const json_value *cov);
- caryll_Buffer *(*build)(const otl_Coverage *coverage);
- caryll_Buffer *(*buildFormat)(const otl_Coverage *coverage, uint16_t format);
- void (*shrink)(otl_Coverage *coverage, bool dosort);
- void (*push)(otl_Coverage *coverage, MOVE otfcc_GlyphHandle h);
-};
-
-extern const struct __otfcc_ICoverage otl_iCoverage;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/post.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/post.h
deleted file mode 100644
index da94d59bcd3..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/post.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_POST_H
-#define CARYLL_INCLUDE_TABLE_POST_H
-
-#include "table-common.h"
-
-typedef struct {
- // PostScript information
- f16dot16 version;
- f16dot16 italicAngle;
- int16_t underlinePosition;
- int16_t underlineThickness;
- uint32_t isFixedPitch;
- uint32_t minMemType42;
- uint32_t maxMemType42;
- uint32_t minMemType1;
- uint32_t maxMemType1;
- OWNING otfcc_GlyphOrder *post_name_map;
-} table_post;
-
-extern caryll_RefElementInterface(table_post) iTable_post;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/table-common.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/table-common.h
deleted file mode 100644
index 60bd8133a9f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/table-common.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_COMMON_H
-#define CARYLL_INCLUDE_TABLE_COMMON_H
-
-#include "dep/json.h"
-
-#include "caryll/buffer.h"
-#include "caryll/ownership.h"
-#include "caryll/vector.h"
-
-#include "otfcc/handle.h"
-#include "otfcc/glyph-order.h"
-#include "otfcc/primitives.h"
-#include "otfcc/sfnt.h"
-#include "otfcc/options.h"
-
-#include "otfcc/vf/vq.h"
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vhea.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vhea.h
deleted file mode 100644
index 0de8e25f988..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vhea.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_VHEA_H
-#define CARYLL_INCLUDE_TABLE_VHEA_H
-
-#include "table-common.h"
-
-typedef struct {
- f16dot16 version;
- int16_t ascent;
- int16_t descent;
- int16_t lineGap;
- int16_t advanceHeightMax;
- int16_t minTop;
- int16_t minBottom;
- int16_t yMaxExtent;
- int16_t caretSlopeRise;
- int16_t caretSlopeRun;
- int16_t caretOffset;
- int16_t dummy0;
- int16_t dummy1;
- int16_t dummy2;
- int16_t dummy3;
- int16_t metricDataFormat;
- uint16_t numOfLongVerMetrics;
-} table_vhea;
-
-extern caryll_RefElementInterface(table_vhea) table_iVhea;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vmtx.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vmtx.h
deleted file mode 100644
index 9818798dd1f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/vmtx.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CARYLL_INCLUDE_TABLE_VMTX_H
-#define CARYLL_INCLUDE_TABLE_VMTX_H
-
-#include "table-common.h"
-
-#include "vhea.h"
-#include "maxp.h"
-
-typedef struct {
- length_t advanceHeight;
- pos_t tsb;
-} vertical_metric;
-
-typedef struct {
- OWNING vertical_metric *metrics;
- pos_t *topSideBearing;
-} table_vmtx;
-
-extern caryll_RefElementInterface(table_vmtx) table_iVmtx;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/axis.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/axis.h
deleted file mode 100644
index 54d0d7cd3bd..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/axis.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CARYLL_VF_AXIS_H
-#define CARYLL_VF_AXIS_H
-
-#include "caryll/element.h"
-#include "caryll/vector.h"
-#include "otfcc/primitives.h"
-
-typedef struct {
- uint32_t tag;
- pos_t minValue;
- pos_t defaultValue;
- pos_t maxValue;
- uint16_t flags;
- uint16_t axisNameID;
-} vf_Axis;
-
-extern caryll_ValElementInterface(vf_Axis) vf_iAxis;
-typedef caryll_Vector(vf_Axis) vf_Axes;
-extern caryll_VectorInterface(vf_Axes, vf_Axis) vf_iAxes;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/region.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/region.h
deleted file mode 100644
index b6dbd344b89..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/region.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef CARYLL_VF_REGION_H
-#define CARYLL_VF_REGION_H
-
-#include "caryll/element.h"
-#include "caryll/vector.h"
-#include "otfcc/primitives.h"
-
-#include "vv.h"
-
-typedef struct {
- pos_t start;
- pos_t peak;
- pos_t end;
-} vq_AxisSpan;
-
-bool vq_AxisSpanIsOne(const vq_AxisSpan *a);
-
-typedef struct {
- shapeid_t dimensions;
- vq_AxisSpan spans[];
-} vq_Region;
-
-vq_Region *vq_createRegion(shapeid_t dimensions);
-void vq_deleteRegion(MOVE vq_Region *region);
-vq_Region *vq_copyRegion(const vq_Region *region);
-
-int vq_compareRegion(const vq_Region *a, const vq_Region *b);
-pos_t vq_regionGetWeight(const vq_Region *r, const VV *v);
-void vq_showRegion(const vq_Region *r);
-
-// function macros
-#define VQ_REGION_SIZE(n) (sizeof(vq_Region) + sizeof(vq_AxisSpan) * (n))
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vf.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vf.h
deleted file mode 100644
index c30928abf2c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vf.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef CARYLL_VF_VF_H
-#define CARYLL_VF_VF_H
-
-// According to OT 1.8 specification, computing a final coordinate from a variable is a inner
-// product:
-// <x, delta | VS_AVAR | style >
-// We will treat the data representing a point coordinate or a metric as a Functional, while the
-// VS-AVAR
-// part as a Ket.
-
-#include "otfcc/vf/vq.h"
-#include "otfcc/vf/axis.h"
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vq.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vq.h
deleted file mode 100644
index a0e0185b8c6..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vq.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef CARYLL_VF_FUNCTIONAL_H
-#define CARYLL_VF_FUNCTIONAL_H
-
-#include "caryll/ownership.h"
-#include "caryll/element.h"
-#include "caryll/vector.h"
-#include "otfcc/primitives.h"
-#include "otfcc/handle.h"
-
-#include "region.h"
-
-typedef enum { VQ_STILL = 0, VQ_DELTA = 1 } VQSegType;
-typedef struct {
- VQSegType type;
- union {
- pos_t still;
- struct {
- pos_t quantity;
- bool touched;
- const vq_Region *region; // non-owning : they are in FVAR
- } delta;
- } val;
-} vq_Segment;
-
-extern caryll_ElementInterfaceOf(vq_Segment) {
- caryll_VT(vq_Segment);
- caryll_Show(vq_Segment);
- caryll_Ord(vq_Segment);
- vq_Segment (*createStill)(pos_t x);
- vq_Segment (*createDelta)(pos_t delta, vq_Region * region);
-}
-vq_iSegment;
-typedef caryll_Vector(vq_Segment) vq_SegList;
-extern caryll_VectorInterface(vq_SegList, vq_Segment) vq_iSegList;
-
-// VQ
-typedef struct {
- pos_t kernel;
- vq_SegList shift;
-} VQ;
-extern caryll_VectorInterfaceTypeName(VQ) {
- caryll_VT(VQ);
- caryll_Module(VQ, scale_t); // VQ forms a module (vector space)
- caryll_Ord(VQ); // VQs are comparable
- caryll_Show(VQ);
- // Getting still
- pos_t (*getStill)(const VQ v);
- // Creating still
- VQ (*createStill)(pos_t x);
- // Being still
- bool (*isStill)(const VQ v);
- // Being zero
- bool (*isZero)(const VQ v, const pos_t err);
- // util functions
- // point linear transform
- VQ (*pointLinearTfm)(const VQ ax, pos_t a, const VQ x, pos_t b, const VQ y);
- void (*addDelta)(MODIFY VQ * v, const bool touched, const vq_Region *const r,
- const pos_t quantity);
-}
-iVQ;
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vv.h b/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vv.h
deleted file mode 100644
index 68bfc27f111..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/vf/vv.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef CARYLL_VF_VV_H
-#define CARYLL_VF_VV_H
-
-#include "caryll/element.h"
-#include "caryll/vector.h"
-#include "otfcc/primitives.h"
-
-extern caryll_ValElementInterface(pos_t) vq_iPosT;
-typedef caryll_Vector(pos_t) VV;
-extern caryll_VectorInterfaceTypeName(VV) {
- caryll_VectorInterfaceTrait(VV, pos_t);
- // Monoid instances
- VV (*neutral)(tableid_t dimensions);
-}
-iVV;
-// extern caryll_VectorInterface(VV, pos_t) iVV;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.c
deleted file mode 100644
index 577048a4293..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.c
+++ /dev/null
@@ -1,132 +0,0 @@
-#include "bkblock.h"
-
-static void bkblock_acells(bk_Block *b, uint32_t len) {
- if (len <= b->length + b->free) {
- // We have enough space
- b->free -= len - b->length;
- b->length = len;
- } else {
- // allocate space
- b->length = len;
- b->free = (len >> 1) & 0xFFFFFF;
- RESIZE(b->cells, b->length + b->free);
- }
-}
-bool bk_cellIsPointer(bk_Cell *cell) {
- return cell->t >= p16;
-}
-
-static bk_Cell *bkblock_grow(bk_Block *b, uint32_t len) {
- uint32_t olen = b->length;
- bkblock_acells(b, olen + len);
- return &(b->cells[olen]);
-}
-
-bk_Block *_bkblock_init() {
- bk_Block *b;
- NEW(b);
- bkblock_acells(b, 0);
- return b;
-}
-
-static void bkblock_pushint(bk_Block *b, bk_CellType type, uint32_t x) {
- bk_Cell *cell = bkblock_grow(b, 1);
- cell->t = type;
- cell->z = x;
-}
-static void bkblock_pushptr(bk_Block *b, bk_CellType type, bk_Block *p) {
- bk_Cell *cell = bkblock_grow(b, 1);
- cell->t = type;
- cell->p = p;
-}
-
-static void vbkpushitems(bk_Block *b, bk_CellType type0, va_list ap) {
- bk_CellType curtype = type0;
- while (curtype) {
- if (curtype == bkcopy || curtype == bkembed) {
- bk_Block *par = va_arg(ap, bk_Block *);
- if (par && par->cells) {
- for (uint32_t j = 0; j < par->length; j++) {
- if (bk_cellIsPointer(par->cells + j)) {
- bkblock_pushptr(b, par->cells[j].t, par->cells[j].p);
- } else {
- bkblock_pushint(b, par->cells[j].t, par->cells[j].z);
- }
- }
- }
- if (curtype == bkembed && par) {
- FREE(par->cells);
- FREE(par);
- }
- } else if (curtype < p16) {
- uint32_t par = va_arg(ap, int);
- bkblock_pushint(b, curtype, par);
- } else {
- bk_Block *par = va_arg(ap, bk_Block *);
- bkblock_pushptr(b, curtype, par);
- }
- curtype = va_arg(ap, int);
- }
-}
-
-bk_Block *bk_new_Block(int type0, ...) {
- va_list ap;
- va_start(ap, type0);
- bk_Block *b = _bkblock_init();
- vbkpushitems(b, type0, ap);
- va_end(ap);
- return b;
-}
-
-bk_Block *bk_push(bk_Block *b, int type0, ...) {
- va_list ap;
- va_start(ap, type0);
- vbkpushitems(b, type0, ap);
- va_end(ap);
- return b;
-}
-
-bk_Block *bk_newBlockFromStringLen(size_t len, const char *str) {
- if (!str) return NULL;
- bk_Block *b = bk_new_Block(bkover);
- for (size_t j = 0; j < len; j++) {
- bkblock_pushint(b, b8, str[j]);
- }
- return b;
-}
-
-bk_Block *bk_newBlockFromBuffer(MOVE caryll_Buffer *buf) {
- if (!buf) return NULL;
- bk_Block *b = bk_new_Block(bkover);
- for (size_t j = 0; j < buf->size; j++) {
- bkblock_pushint(b, b8, buf->data[j]);
- }
- buffree(buf);
- return b;
-}
-bk_Block *bk_newBlockFromBufferCopy(OBSERVE caryll_Buffer *buf) {
- if (!buf) return NULL;
- bk_Block *b = bk_new_Block(bkover);
- for (size_t j = 0; j < buf->size; j++) {
- bkblock_pushint(b, b8, buf->data[j]);
- }
- return b;
-}
-
-void bk_printBlock(bk_Block *b) {
- fprintf(stderr, "Block size %08x\n", (uint32_t)b->length);
- fprintf(stderr, "------------------\n");
- for (uint32_t j = 0; j < b->length; j++) {
- if (bk_cellIsPointer(b->cells + j)) {
- if (b->cells[j].p) {
- fprintf(stderr, " %3d %p[%d]\n", b->cells[j].t, b->cells[j].p,
- b->cells[j].p->_index);
- } else {
- fprintf(stderr, " %3d [NULL]\n", b->cells[j].t);
- }
- } else {
- fprintf(stderr, " %3d %d\n", b->cells[j].t, b->cells[j].z);
- }
- }
- fprintf(stderr, "------------------\n");
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.h
deleted file mode 100644
index fafa78a1644..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef CARYLL_BK_BLOCK_H
-#define CARYLL_BK_BLOCK_H
-
-#include <stdint.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <limits.h>
-#include "caryll/ownership.h"
-#include "support/otfcc-alloc.h"
-#include "caryll/buffer.h"
-
-struct __caryll_bkblock;
-typedef enum {
- bkover = 0, // nothing
- b8 = 1, // byte
- b16 = 2, // short
- b32 = 3, // long
- p16 = 0x10, // 16-bit offset, p = pointer to block
- p32 = 0x11, // 32-bit offset, p = pointer to block
- sp16 = 0x80, // 16-bit offset, p = pointer to block, marked as compact
- sp32 = 0x81, // 32-bit offset, p = pointer to block, marked as compact
- bkcopy = 0xFE, // Embed another block
- bkembed = 0xFF // Embed another block
-} bk_CellType;
-typedef enum { VISIT_WHITE, VISIT_GRAY, VISIT_BLACK } bk_cell_visit_state;
-
-typedef struct {
- bk_CellType t;
- union {
- uint32_t z;
- struct __caryll_bkblock *p;
- };
-} bk_Cell;
-
-typedef struct __caryll_bkblock {
- bk_cell_visit_state _visitstate;
- uint32_t _index;
- uint32_t _height;
- uint32_t _depth;
- uint32_t length;
- uint32_t free;
- bk_Cell *cells;
-} bk_Block;
-
-bk_Block *_bkblock_init(void);
-bk_Block *bk_new_Block(int type0, ...);
-bk_Block *bk_push(bk_Block *b, int type0, ...);
-bk_Block *bk_newBlockFromStringLen(size_t len, const char *str);
-bk_Block *bk_newBlockFromBuffer(MOVE caryll_Buffer *buf);
-bk_Block *bk_newBlockFromBufferCopy(OBSERVE caryll_Buffer *buf);
-bool bk_cellIsPointer(bk_Cell *cell);
-void bk_printBlock(bk_Block *b);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.c
deleted file mode 100644
index 2c4b1415a95..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.c
+++ /dev/null
@@ -1,410 +0,0 @@
-#include "bkgraph.h"
-
-static bk_GraphNode *_bkgraph_grow(bk_Graph *f) {
- if (f->free) {
- f->length++;
- f->free--;
- } else {
- f->length = f->length + 1;
- f->free = (f->length >> 1) & 0xFFFFFF;
- RESIZE(f->entries, f->length + f->free);
- }
- return &(f->entries[f->length - 1]);
-}
-
-static uint32_t dfs_insert_cells(bk_Block *b, bk_Graph *f, uint32_t *order) {
- if (!b || b->_visitstate == VISIT_GRAY) return 0;
- if (b->_visitstate == VISIT_BLACK) return b->_height;
- b->_visitstate = VISIT_GRAY;
- uint32_t height = 0;
- for (uint32_t j = 0; j < b->length; j++) {
- bk_Cell *cell = &(b->cells[j]);
- if (bk_cellIsPointer(cell) && cell->p) {
- uint32_t thatHeight = dfs_insert_cells(cell->p, f, order);
- if (thatHeight + 1 > height) height = thatHeight + 1;
- }
- }
- bk_GraphNode *e = _bkgraph_grow(f);
- e->alias = 0;
- e->block = b;
- *order += 1;
- e->order = *order;
- e->height = b->_height = height;
- b->_visitstate = VISIT_BLACK;
- return height;
-}
-
-static int _by_height(const void *_a, const void *_b) {
- const bk_GraphNode *a = _a;
- const bk_GraphNode *b = _b;
- return a->height == b->height ? a->order - b->order : b->height - a->height;
-}
-
-static int _by_order(const void *_a, const void *_b) {
- const bk_GraphNode *a = _a;
- const bk_GraphNode *b = _b;
- return a->block && b->block && a->block->_visitstate != b->block->_visitstate // Visited first
- ? b->block->_visitstate - a->block->_visitstate
- : a->block && b->block && a->block->_depth != b->block->_depth // By depth
- ? a->block->_depth - b->block->_depth
- : b->order - a->order; // By order
-}
-
-bk_Graph *bk_newGraphFromRootBlock(bk_Block *b) {
- bk_Graph *forest;
- NEW(forest);
- uint32_t tsOrder = 0;
- dfs_insert_cells(b, forest, &tsOrder);
- qsort(forest->entries, forest->length, sizeof(bk_GraphNode), _by_height);
- for (uint32_t j = 0; j < forest->length; j++) {
- forest->entries[j].block->_index = j;
- forest->entries[j].alias = j;
- }
- return forest;
-}
-
-void bk_delete_Graph(bk_Graph *f) {
- if (!f || !f->entries) return;
- for (uint32_t j = 0; j < f->length; j++) {
- bk_Block *b = f->entries[j].block;
- if (b && b->cells) FREE(b->cells);
- FREE(b);
- }
- FREE(f->entries);
- FREE(f);
-}
-
-static uint32_t gethash(bk_Block *b) {
- uint32_t h = 5381;
- for (uint32_t j = 0; j < b->length; j++) {
- h = ((h << 5) + h) + b->cells[j].t;
- h = ((h << 5) + h);
- switch (b->cells[j].t) {
- case b8:
- case b16:
- case b32:
- h += b->cells[j].z;
- break;
- case p16:
- case p32:
- case sp16:
- case sp32:
- if (b->cells[j].p) { h += b->cells[j].p->_index; }
- break;
- default:
- break;
- }
- }
- return h;
-}
-
-static bool compareblock(bk_Block *a, bk_Block *b) {
- if (!a && !b) return true;
- if (!a || !b) return false;
- if (a->length != b->length) return false;
- for (uint32_t j = 0; j < a->length; j++) {
- if (a->cells[j].t != b->cells[j].t) return false;
- switch (a->cells[j].t) {
- case b8:
- case b16:
- case b32:
- if (a->cells[j].z != b->cells[j].z) return false;
- break;
- case p16:
- case p32:
- case sp16:
- case sp32:
- if (a->cells[j].p != b->cells[j].p) return false;
- break;
- default:
- break;
- }
- }
- return true;
-}
-static bool compareEntry(bk_GraphNode *a, bk_GraphNode *b) {
- if (a->hash != b->hash) return false;
- return compareblock(a->block, b->block);
-}
-
-static void replaceptr(bk_Graph *f, bk_Block *b) {
- for (uint32_t j = 0; j < b->length; j++) {
- switch (b->cells[j].t) {
- case p16:
- case p32:
- case sp16:
- case sp32:
- if (b->cells[j].p) {
- uint32_t index = b->cells[j].p->_index;
- while (f->entries[index].alias != index) {
- index = f->entries[index].alias;
- }
- b->cells[j].p = f->entries[index].block;
- }
- break;
- default:
- break;
- }
- }
-}
-
-void bk_minimizeGraph(bk_Graph *f) {
- uint32_t rear = (uint32_t)(f->length - 1);
- while (rear > 0) {
- uint32_t front = rear;
- while (f->entries[front].height == f->entries[rear].height && front > 0) {
- front--;
- }
- front++;
- for (uint32_t j = front; j <= rear; j++) {
- f->entries[j].hash = gethash(f->entries[j].block);
- }
- for (uint32_t j = front; j <= rear; j++) {
- bk_GraphNode *a = &(f->entries[j]);
- if (a->alias == j) {
- for (uint32_t k = j + 1; k <= rear; k++) {
- bk_GraphNode *b = &(f->entries[k]);
- if (b->alias == k && compareEntry(a, b)) { b->alias = j; }
- }
- }
- }
- // replace pointers with aliased
- for (uint32_t j = 0; j < front; j++) {
- replaceptr(f, f->entries[j].block);
- }
- rear = front - 1;
- }
-}
-
-static size_t otfcc_bkblock_size(bk_Block *b) {
- size_t size = 0;
- for (uint32_t j = 0; j < b->length; j++)
- switch (b->cells[j].t) {
- case b8:
- size += 1;
- break;
- case b16:
- case p16:
- case sp16:
- size += 2;
- break;
- case b32:
- case p32:
- case sp32:
- size += 4;
- break;
- default:
- break;
- }
- return size;
-}
-
-static uint32_t getoffset(size_t *offsets, bk_Block *ref, bk_Block *target, uint8_t bits) {
- size_t offref = offsets[ref->_index];
- size_t offtgt = offsets[target->_index];
- /*
- if (offtgt < offref || (offtgt - offref) >> bits) {
- fprintf(stderr, "[otfcc-fea] Warning : Unable to fit offset %d into %d bits.\n",
- (int32_t)(offtgt - offref), bits);
- }
- */
- return (uint32_t)(offtgt - offref);
-}
-static int64_t getoffset_untangle(size_t *offsets, bk_Block *ref, bk_Block *target) {
- size_t offref = offsets[ref->_index];
- size_t offtgt = offsets[target->_index];
- return (int64_t)(offtgt - offref);
-}
-static void escalate_sppointers(bk_Block *b, bk_Graph *f, uint32_t *order, uint32_t depth) {
- if (!b) return;
- for (uint32_t j = 0; j < b->length; j++) {
- bk_Cell *cell = &(b->cells[j]);
- if (bk_cellIsPointer(cell) && cell->p && cell->t >= sp16) {
- escalate_sppointers(cell->p, f, order, depth);
- }
- }
- b->_depth = depth;
- *order += 1;
- f->entries[b->_index].order = *order;
-}
-static void dfs_attract_cells(bk_Block *b, bk_Graph *f, uint32_t *order, uint32_t depth) {
- if (!b) return;
- if (b->_visitstate != VISIT_WHITE) {
- if (b->_depth < depth) { b->_depth = depth; }
- return;
- }
- b->_visitstate = VISIT_GRAY;
- for (uint32_t j = b->length; j-- > 0;) {
- bk_Cell *cell = &(b->cells[j]);
- if (bk_cellIsPointer(cell) && cell->p) { dfs_attract_cells(cell->p, f, order, depth + 1); }
- }
- *order += 1;
- f->entries[b->_index].order = *order;
- escalate_sppointers(b, f, order, depth);
- b->_visitstate = VISIT_BLACK;
-}
-
-static void attract_bkgraph(bk_Graph *f) {
- // Clear the visit state of all blocks
- for (uint32_t j = 0; j < f->length; j++) {
- f->entries[j].block->_visitstate = VISIT_WHITE;
- f->entries[j].order = 0;
- f->entries[j].block->_index = j;
- f->entries[j].block->_depth = 0;
- }
- uint32_t order = 0;
- dfs_attract_cells(f->entries[0].block, f, &order, 0);
- qsort(f->entries, f->length, sizeof(bk_GraphNode), _by_order);
- for (uint32_t j = 0; j < f->length; j++) {
- f->entries[j].block->_index = j;
- }
-}
-
-static bool try_untabgle_block(bk_Graph *f, bk_Block *b, size_t *offsets, uint16_t passes) {
- bool didCopy = false;
- for (uint32_t j = 0; j < b->length; j++) {
- switch (b->cells[j].t) {
- case p16:
- case sp16:
- if (b->cells[j].p) {
- int64_t offset = getoffset_untangle(offsets, b, b->cells[j].p);
- if (offset < 0 || offset > 0xFFFF) {
- bk_GraphNode *e = _bkgraph_grow(f);
- e->order = 0;
- e->alias = 0;
- e->block = bk_new_Block(bkcopy, b->cells[j].p, bkover);
- b->cells[j].t = sp16;
- b->cells[j].p = e->block;
- didCopy = true;
- }
- }
- break;
- default:
- break;
- }
- }
- return didCopy;
-}
-
-static bool try_untangle(bk_Graph *f, uint16_t passes) {
- size_t *offsets;
- NEW(offsets, f->length + 1);
- offsets[0] = 0;
- for (uint32_t j = 0; j < f->length; j++) {
- if (f->entries[j].block->_visitstate == VISIT_BLACK) {
- offsets[j + 1] = offsets[j] + otfcc_bkblock_size(f->entries[j].block);
- } else {
- offsets[j + 1] = offsets[j];
- }
- }
- uint32_t totalBlocks = f->length;
- bool didUntangle = false;
- for (uint32_t j = 0; j < totalBlocks; j++) {
- if (f->entries[j].block->_visitstate == VISIT_BLACK) {
- bool didCopy = try_untabgle_block(f, f->entries[j].block, offsets, passes);
- didUntangle = didUntangle || didCopy;
- }
- }
- FREE(offsets);
- return didUntangle;
-}
-
-static void otfcc_build_bkblock(caryll_Buffer *buf, bk_Block *b, size_t *offsets) {
- for (uint32_t j = 0; j < b->length; j++) {
- switch (b->cells[j].t) {
- case b8:
- bufwrite8(buf, b->cells[j].z);
- break;
- case b16:
- bufwrite16b(buf, b->cells[j].z);
- break;
- case b32:
- bufwrite32b(buf, b->cells[j].z);
- break;
- case p16:
- case sp16:
- if (b->cells[j].p) {
- bufwrite16b(buf, getoffset(offsets, b, b->cells[j].p, 16));
- } else {
- bufwrite16b(buf, 0);
- }
- break;
- case p32:
- case sp32:
- if (b->cells[j].p) {
- bufwrite32b(buf, getoffset(offsets, b, b->cells[j].p, 32));
- } else {
- bufwrite32b(buf, 0);
- }
- break;
- default:
- break;
- }
- }
-}
-
-caryll_Buffer *bk_build_Graph(bk_Graph *f) {
- caryll_Buffer *buf = bufnew();
- size_t *offsets;
- NEW(offsets, f->length + 1);
-
- offsets[0] = 0;
- for (uint32_t j = 0; j < f->length; j++) {
- if (f->entries[j].block->_visitstate == VISIT_BLACK) {
- offsets[j + 1] = offsets[j] + otfcc_bkblock_size(f->entries[j].block);
- } else {
- offsets[j + 1] = offsets[j];
- }
- }
- for (uint32_t j = 0; j < f->length; j++) {
- if (f->entries[j].block->_visitstate == VISIT_BLACK) {
- otfcc_build_bkblock(buf, f->entries[j].block, offsets);
- }
- }
- FREE(offsets);
- return buf;
-}
-
-size_t bk_estimateSizeOfGraph(bk_Graph *f) {
- size_t *offsets;
- NEW(offsets, f->length + 1);
-
- offsets[0] = 0;
- for (uint32_t j = 0; j < f->length; j++) {
- if (f->entries[j].block->_visitstate == VISIT_BLACK) {
- offsets[j + 1] = offsets[j] + otfcc_bkblock_size(f->entries[j].block);
- } else {
- offsets[j + 1] = offsets[j];
- }
- }
- size_t estimatedSize = offsets[f->length];
- FREE(offsets);
- return estimatedSize;
-}
-
-void bk_untangleGraph(/*BORROW*/ bk_Graph *f) {
- uint16_t passes = 0;
- bool tangled = false;
- attract_bkgraph(f);
- do {
- tangled = try_untangle(f, passes);
- if (tangled) { attract_bkgraph(f); }
- passes++;
- } while (tangled && passes < 16);
-}
-
-caryll_Buffer *bk_build_Block(/*MOVE*/ bk_Block *root) {
- bk_Graph *f = bk_newGraphFromRootBlock(root);
- bk_minimizeGraph(f);
- bk_untangleGraph(f);
- caryll_Buffer *buf = bk_build_Graph(f);
- bk_delete_Graph(f);
- return buf;
-}
-caryll_Buffer *bk_build_Block_noMinimize(/*MOVE*/ bk_Block *root) {
- bk_Graph *f = bk_newGraphFromRootBlock(root);
- bk_untangleGraph(f);
- caryll_Buffer *buf = bk_build_Graph(f);
- bk_delete_Graph(f);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.h
deleted file mode 100644
index 6d48054b355..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkgraph.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef CARYLL_BK_BKGRAPH_H
-#define CARYLL_BK_BKGRAPH_H
-
-#include <stdint.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include "caryll/buffer.h"
-
-#include "bkblock.h"
-
-typedef struct {
- uint32_t alias;
- uint32_t order;
- uint32_t height;
- uint32_t hash;
- bk_Block *block;
-} bk_GraphNode;
-
-typedef struct {
- uint32_t length;
- uint32_t free;
- bk_GraphNode *entries;
-} bk_Graph;
-
-bk_Graph *bk_newGraphFromRootBlock(bk_Block *b);
-void bk_delete_Graph(/*MOVE*/ bk_Graph *f);
-void bk_minimizeGraph(/*BORROW*/ bk_Graph *f);
-void bk_untangleGraph(/*BORROW*/ bk_Graph *f);
-caryll_Buffer *bk_build_Graph(/*BORROW*/ bk_Graph *f);
-caryll_Buffer *bk_build_Block(/*MOVE*/ bk_Block *root);
-caryll_Buffer *bk_build_Block_noMinimize(/*MOVE*/ bk_Block *root);
-size_t bk_estimateSizeOfGraph(bk_Graph *f);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.c
deleted file mode 100644
index 82c22a53302..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.c
+++ /dev/null
@@ -1,532 +0,0 @@
-#include "consolidate.h"
-
-#include "support/util.h"
-#include "table/all.h"
-
-#include "otl/gsub-single.h"
-#include "otl/gsub-multi.h"
-#include "otl/gsub-ligature.h"
-#include "otl/gsub-reverse.h"
-#include "otl/gpos-single.h"
-#include "otl/gpos-pair.h"
-#include "otl/gpos-cursive.h"
-#include "otl/chaining.h"
-#include "otl/mark.h"
-#include "otl/GDEF.h"
-
-// Consolidation
-// Replace name entries in json to ids and do some check
-static int by_stem_pos(const glyf_PostscriptStemDef *a, const glyf_PostscriptStemDef *b) {
- if (a->position == b->position) {
- return (int)a->map - (int)b->map;
- } else if (a->position > b->position) {
- return 1;
- } else {
- return -1;
- }
-}
-static int by_mask_pointindex(const glyf_PostscriptHintMask *a, const glyf_PostscriptHintMask *b) {
- return a->contoursBefore == b->contoursBefore ? a->pointsBefore - b->pointsBefore
- : a->contoursBefore - b->contoursBefore;
-}
-
-static void consolidateGlyphContours(glyf_Glyph *g, const otfcc_Options *options) {
- shapeid_t nContoursConsolidated = 0;
- shapeid_t skip = 0;
- for (shapeid_t j = 0; j < g->contours.length; j++) {
- if (g->contours.items[j].length) {
- g->contours.items[j - skip] = g->contours.items[j];
- nContoursConsolidated += 1;
- } else {
- glyf_iContourList.disposeItem(&g->contours, j);
- logWarning("[Consolidate] Removed empty contour #%d in glyph %s.\n", j, g->name);
- skip += 1;
- }
- }
- g->contours.length = nContoursConsolidated;
-}
-static void consolidateGlyphReferences(glyf_Glyph *g, otfcc_Font *font,
- const otfcc_Options *options) {
- shapeid_t nReferencesConsolidated = 0;
- shapeid_t skip = 0;
- for (shapeid_t j = 0; j < g->references.length; j++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &g->references.items[j].glyph)) {
- logWarning("[Consolidate] Ignored absent glyph component reference /%s within /%s.\n",
- g->references.items[j].glyph.name, g->name);
- glyf_iReferenceList.disposeItem(&(g->references), j);
- skip += 1;
- } else {
- g->references.items[j - skip] = g->references.items[j];
- nReferencesConsolidated += 1;
- }
- }
- g->references.length = nReferencesConsolidated;
-}
-static void consolidateGlyphHints(glyf_Glyph *g, const otfcc_Options *options) {
- // sort stems
- if (g->stemH.length) {
- for (shapeid_t j = 0; j < g->stemH.length; j++) {
- g->stemH.items[j].map = j;
- }
- glyf_iStemDefList.sort(&g->stemH, by_stem_pos);
- }
- if (g->stemV.length) {
- for (shapeid_t j = 0; j < g->stemV.length; j++) {
- g->stemV.items[j].map = j;
- }
- glyf_iStemDefList.sort(&g->stemV, by_stem_pos);
- }
- shapeid_t *hmap;
- NEW(hmap, g->stemH.length);
- shapeid_t *vmap;
- NEW(vmap, g->stemV.length);
- for (shapeid_t j = 0; j < g->stemH.length; j++) {
- hmap[g->stemH.items[j].map] = j;
- }
- for (shapeid_t j = 0; j < g->stemV.length; j++) {
- vmap[g->stemV.items[j].map] = j;
- }
- // sort masks
- if (g->hintMasks.length) {
- glyf_iMaskList.sort(&g->hintMasks, by_mask_pointindex);
- for (shapeid_t j = 0; j < g->hintMasks.length; j++) {
- glyf_PostscriptHintMask oldmask = g->hintMasks.items[j]; // copy
- for (shapeid_t k = 0; k < g->stemH.length; k++) {
- g->hintMasks.items[j].maskH[k] = oldmask.maskH[hmap[k]];
- }
- for (shapeid_t k = 0; k < g->stemV.length; k++) {
- g->hintMasks.items[j].maskV[k] = oldmask.maskV[vmap[k]];
- }
- }
- }
- if (g->contourMasks.length) {
- glyf_iMaskList.sort(&g->contourMasks, by_mask_pointindex);
- for (shapeid_t j = 0; j < g->contourMasks.length; j++) {
- glyf_PostscriptHintMask oldmask = g->contourMasks.items[j]; // copy
- for (shapeid_t k = 0; k < g->stemH.length; k++) {
- g->contourMasks.items[j].maskH[k] = oldmask.maskH[hmap[k]];
- }
- for (shapeid_t k = 0; k < g->stemV.length; k++) {
- g->contourMasks.items[j].maskV[k] = oldmask.maskV[vmap[k]];
- }
- }
- }
- FREE(hmap);
- FREE(vmap);
-}
-static void consolidateFDSelect(fd_handle *h, table_CFF *cff, const otfcc_Options *options,
- const sds gname) {
- if (!cff || !cff->fdArray || !cff->fdArrayCount) return;
- // Consolidate fdSelect
- if (h->state == HANDLE_STATE_INDEX) {
- if (h->index >= cff->fdArrayCount) { h->index = 0; }
- Handle.consolidateTo(h, h->index, cff->fdArray[h->index]->fontName);
- } else if (h->name) {
- bool found = false;
- for (tableid_t j = 0; j < cff->fdArrayCount; j++) {
- if (strcmp(h->name, cff->fdArray[j]->fontName) == 0) {
- found = true;
- Handle.consolidateTo(h, j, cff->fdArray[j]->fontName);
- break;
- }
- }
- if (!found) {
- logWarning("[Consolidate] CID Subfont %s is not defined. (in glyph /%s).\n", h->name,
- gname);
- Handle.dispose(h);
- }
- } else if (h->name) {
- Handle.dispose(h);
- }
-}
-static void consolidateGlyph(glyf_Glyph *g, otfcc_Font *font, const otfcc_Options *options) {
- consolidateGlyphContours(g, options);
- consolidateGlyphReferences(g, font, options);
- consolidateGlyphHints(g, options);
- consolidateFDSelect(&g->fdSelect, font->CFF_, options, g->name);
-}
-
-// Anchored reference consolidation
-bool consolidateAnchorRef(table_glyf *table, glyf_ComponentReference *gr,
- glyf_ComponentReference *rr, const otfcc_Options *options);
-static bool getPointCoordinates(table_glyf *table, glyf_ComponentReference *gr, shapeid_t n,
- shapeid_t *stated, VQ *x, VQ *y, const otfcc_Options *options) {
- glyphid_t j = gr->glyph.index;
- glyf_Glyph *g = table->items[j];
- for (shapeid_t c = 0; c < g->contours.length; c++) {
- for (shapeid_t pj = 0; pj < g->contours.items[c].length; pj++) {
- if (*stated == n) {
- glyf_Point *p = &(g->contours.items[c].items[pj]);
- iVQ.replace(x, iVQ.pointLinearTfm(gr->x, gr->a, p->x, gr->b, p->y));
- iVQ.replace(y, iVQ.pointLinearTfm(gr->y, gr->c, p->x, gr->d, p->y));
- return true;
- }
- *stated += 1;
- }
- }
- for (shapeid_t r = 0; r < g->references.length; r++) {
- glyf_ComponentReference *rr = &(g->references.items[r]);
-
- consolidateAnchorRef(table, gr, rr, options);
-
- // composite affine transformations
- glyf_ComponentReference ref = glyf_iComponentReference.empty();
- ref.glyph = Handle.fromIndex(g->references.items[r].glyph.index);
- ref.a = gr->a * rr->a + rr->b * gr->c;
- ref.b = rr->a * gr->b + rr->b * gr->d;
- ref.c = gr->a * rr->c + gr->c * rr->d;
- ref.d = gr->b * rr->c + rr->d * gr->d;
- iVQ.replace(&ref.x, iVQ.pointLinearTfm(rr->x, rr->a, gr->x, rr->b, gr->y));
- iVQ.replace(&ref.y, iVQ.pointLinearTfm(rr->y, rr->c, gr->x, rr->d, gr->y));
-
- bool success = getPointCoordinates(table, &ref, n, stated, x, y, options);
- glyf_iComponentReference.dispose(&ref);
- if (success) return true;
- }
- return false;
-}
-
-bool consolidateAnchorRef(table_glyf *table, glyf_ComponentReference *gr,
- glyf_ComponentReference *rr, const otfcc_Options *options) {
- if (rr->isAnchored == REF_ANCHOR_CONSOLIDATED || rr->isAnchored == REF_XY) return true;
- if (rr->isAnchored == REF_ANCHOR_CONSOLIDATING_ANCHOR ||
- rr->isAnchored == REF_ANCHOR_CONSOLIDATING_XY) {
- logWarning(
- "Found circular reference of out-of-range point reference in anchored reference.");
- rr->isAnchored = REF_XY;
- return false;
- }
- if (rr->isAnchored == REF_ANCHOR_ANCHOR) {
- rr->isAnchored = REF_ANCHOR_CONSOLIDATING_ANCHOR;
- } else {
- rr->isAnchored = REF_ANCHOR_CONSOLIDATING_XY;
- }
- VQ innerX = iVQ.neutral(), outerX = iVQ.neutral();
- VQ innerY = iVQ.neutral(), outerY = iVQ.neutral();
- shapeid_t innerCounter = 0, outerCounter = 0;
-
- glyf_ComponentReference rr1 = glyf_iComponentReference.empty();
- rr1.glyph = Handle.fromIndex(rr->glyph.index);
-
- bool s1 = getPointCoordinates(table, gr, rr->outer, &outerCounter, &outerX, &outerY, options);
- bool s2 = getPointCoordinates(table, &rr1, rr->inner, &innerCounter, &innerX, &innerY, options);
- if (!s1) { logWarning("Failed to access point %d in outer glyph.", rr->outer); }
- if (!s2) {
- logWarning("Failed to access point %d in reference to %s.", rr->outer, rr->glyph.name);
- }
-
- VQ rrx = iVQ.pointLinearTfm(outerX, -rr->a, innerX, -rr->b, innerY);
- VQ rry = iVQ.pointLinearTfm(outerY, -rr->c, innerX, -rr->d, innerY);
-
- if (rr->isAnchored == REF_ANCHOR_CONSOLIDATING_ANCHOR) {
- iVQ.replace(&rr->x, rrx);
- iVQ.replace(&rr->y, rry);
- rr->isAnchored = REF_ANCHOR_CONSOLIDATED;
- } else {
- if (fabs(iVQ.getStill(rr->x) - iVQ.getStill(rrx)) > 0.5 &&
- fabs(iVQ.getStill(rr->y) - iVQ.getStill(rry)) > 0.5) {
- logWarning("Anchored reference to %s does not match its X/Y offset data.",
- rr->glyph.name);
- }
- rr->isAnchored = REF_ANCHOR_CONSOLIDATED;
- iVQ.dispose(&rrx), iVQ.dispose(&rry);
- }
- glyf_iComponentReference.dispose(&rr1);
- iVQ.dispose(&innerX), iVQ.dispose(&innerY);
- iVQ.dispose(&outerX), iVQ.dispose(&outerY);
- return false;
-}
-
-static void consolidateGlyf(otfcc_Font *font, const otfcc_Options *options) {
- if (!font->glyph_order || !font->glyf) return;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- if (font->glyf->items[j]) {
- consolidateGlyph(font->glyf->items[j], font, options);
- } else {
- font->glyf->items[j] = otfcc_newGlyf_glyph();
- }
- }
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- loggedStep("%s", g->name) {
- glyf_ComponentReference gr = glyf_iComponentReference.empty();
- gr.glyph = Handle.fromIndex(j);
-
- for (shapeid_t r = 0; r < g->references.length; r++) {
- glyf_ComponentReference *rr = &(g->references.items[r]);
- consolidateAnchorRef(font->glyf, &gr, rr, options);
- }
- glyf_iComponentReference.dispose(&gr);
- }
- }
-}
-
-static void consolidateCmap(otfcc_Font *font, const otfcc_Options *options) {
- if (font->glyph_order && font->cmap) {
- cmap_Entry *item;
- foreach_hash(item, font->cmap->unicodes) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &item->glyph)) {
- logWarning("[Consolidate] Ignored mapping U+%04X to non-existent glyph /%s.\n",
- item->unicode, item->glyph.name);
- Handle.dispose(&item->glyph);
- }
- }
- }
- if (font->glyph_order && font->cmap) {
- cmap_UVS_Entry *item;
- foreach_hash(item, font->cmap->uvs) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &item->glyph)) {
- logWarning("[Consolidate] Ignored UVS mapping [U+%04X U+%04X] to non-existent "
- "glyph /%s.\n",
- item->key.unicode, item->key.selector, item->glyph.name);
- Handle.dispose(&item->glyph);
- }
- }
- }
-}
-
-typedef bool (*otl_consolidation_function)(otfcc_Font *, table_OTL *, otl_Subtable *,
- const otfcc_Options *);
-typedef void (*subtable_remover)(otl_Subtable *);
-#define LOOKUP_CONSOLIDATOR(llt, fn, fndel) \
- __declare_otl_consolidation(llt, fn, (subtable_remover)fndel, font, table, lookup, options);
-
-static void __declare_otl_consolidation(otl_LookupType type, otl_consolidation_function fn,
- subtable_remover fndel, otfcc_Font *font, table_OTL *table,
- otl_Lookup *lookup, const otfcc_Options *options) {
- if (!lookup || !lookup->subtables.length || lookup->type != type) return;
- loggedStep("%s", lookup->name) {
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- if (!lookup->subtables.items[j]) {
- logWarning("[Consolidate] Ignored empty subtable %d of lookup %s.\n", j,
- lookup->name);
- continue;
- }
- bool subtableRemoved;
- // loggedStep("Subtable %d", j) {
- subtableRemoved = fn(font, table, lookup->subtables.items[j], options);
- //}
- if (subtableRemoved) {
- fndel(lookup->subtables.items[j]);
- lookup->subtables.items[j] = NULL;
- logWarning("[Consolidate] Ignored empty subtable %d of lookup %s.\n", j,
- lookup->name);
- }
- }
- tableid_t k = 0;
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- if (lookup->subtables.items[j]) {
- lookup->subtables.items[k++] = lookup->subtables.items[j];
- }
- }
- lookup->subtables.length = k;
- if (!k) {
- logWarning("[Consolidate] Lookup %s is empty and will be removed.\n", lookup->name);
- }
- }
-}
-
-static void otfcc_consolidate_lookup(otfcc_Font *font, table_OTL *table, otl_Lookup *lookup,
- const otfcc_Options *options) {
- LOOKUP_CONSOLIDATOR(otl_type_gsub_single, consolidate_gsub_single, iSubtable_gsub_single.free);
- LOOKUP_CONSOLIDATOR(otl_type_gsub_multiple, consolidate_gsub_multi, iSubtable_gsub_multi.free);
- LOOKUP_CONSOLIDATOR(otl_type_gsub_alternate, consolidate_gsub_alternative,
- iSubtable_gsub_multi.free);
- LOOKUP_CONSOLIDATOR(otl_type_gsub_ligature, consolidate_gsub_ligature,
- iSubtable_gsub_ligature.free);
- LOOKUP_CONSOLIDATOR(otl_type_gsub_chaining, consolidate_chaining, iSubtable_chaining.free);
- LOOKUP_CONSOLIDATOR(otl_type_gsub_reverse, consolidate_gsub_reverse,
- iSubtable_gsub_reverse.free);
- LOOKUP_CONSOLIDATOR(otl_type_gpos_single, consolidate_gpos_single, iSubtable_gpos_single.free);
- LOOKUP_CONSOLIDATOR(otl_type_gpos_pair, consolidate_gpos_pair, iSubtable_gpos_pair.free);
- LOOKUP_CONSOLIDATOR(otl_type_gpos_cursive, consolidate_gpos_cursive,
- iSubtable_gpos_cursive.free);
- LOOKUP_CONSOLIDATOR(otl_type_gpos_chaining, consolidate_chaining, iSubtable_chaining.free);
- LOOKUP_CONSOLIDATOR(otl_type_gpos_markToBase, consolidate_mark_to_single,
- iSubtable_gpos_markToSingle.free);
- LOOKUP_CONSOLIDATOR(otl_type_gpos_markToMark, consolidate_mark_to_single,
- iSubtable_gpos_markToSingle.free);
- LOOKUP_CONSOLIDATOR(otl_type_gpos_markToLigature, consolidate_mark_to_ligature,
- iSubtable_gpos_markToLigature.free);
-}
-
-static bool lookupRefIsNotEmpty(const otl_LookupRef *rLut, void *env) {
- return rLut && *rLut && (*rLut)->subtables.length > 0;
-}
-static bool featureRefIsNotEmpty(const otl_FeatureRef *rFeat, void *env) {
- return rFeat && *rFeat && (*rFeat)->lookups.length > 0;
-}
-static bool lookupIsNotEmpty(const otl_LookupPtr *rLut, void *env) {
- return rLut && *rLut && (*rLut)->subtables.length > 0;
-}
-static bool featureIsNotEmpty(const otl_FeaturePtr *rFeat, void *env) {
- return rFeat && *rFeat && (*rFeat)->lookups.length > 0;
-}
-
-static void consolidateOTLTable(otfcc_Font *font, table_OTL *table, const otfcc_Options *options) {
- if (!font->glyph_order || !table) return;
- do {
- tableid_t featN = table->features.length;
- tableid_t lutN = table->lookups.length;
-
- // Perform consolidation
- for (tableid_t j = 0; j < table->lookups.length; j++) {
- otfcc_consolidate_lookup(font, table, table->lookups.items[j], options);
- }
- // remove empty features
- for (tableid_t j = 0; j < table->features.length; j++) {
- otl_Feature *feature = table->features.items[j];
- otl_iLookupRefList.filterEnv(&feature->lookups, lookupRefIsNotEmpty, NULL);
- }
- // remove empty lookups
- for (tableid_t j = 0; j < table->languages.length; j++) {
- otl_LanguageSystem *lang = table->languages.items[j];
- otl_iFeatureRefList.filterEnv(&lang->features, featureRefIsNotEmpty, NULL);
- }
- otl_iLookupList.filterEnv(&table->lookups, lookupIsNotEmpty, NULL);
- otl_iFeatureList.filterEnv(&table->features, featureIsNotEmpty, NULL);
-
- tableid_t featN1 = table->features.length;
- tableid_t lutN1 = table->lookups.length;
- if (featN1 >= featN && lutN1 >= lutN) break;
- } while (true);
-}
-
-static void consolidateOTL(otfcc_Font *font, const otfcc_Options *options) {
- loggedStep("GSUB") {
- consolidateOTLTable(font, font->GSUB, options);
- }
- loggedStep("GPOS") {
- consolidateOTLTable(font, font->GPOS, options);
- }
- loggedStep("GDEF") {
- consolidate_GDEF(font, font->GDEF, options);
- }
-}
-
-static void consolidateCOLR(otfcc_Font *font, const otfcc_Options *options) {
- if (!font || !font->COLR || !font->glyph_order) return;
- table_COLR *consolidated = table_iCOLR.create();
- foreach (colr_Mapping *mapping, *(font->COLR)) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &mapping->glyph)) {
- logWarning("[Consolidate] Ignored missing glyph of /%s", mapping->glyph.name);
- continue;
- }
- colr_Mapping m;
- Handle.copy(&m.glyph, &mapping->glyph);
- colr_iLayerList.init(&m.layers);
- foreach (colr_Layer *layer, mapping->layers) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &layer->glyph)) {
- logWarning("[Consolidate] Ignored missing glyph of /%s", layer->glyph.name);
- continue;
- }
- colr_Layer layer1;
- colr_iLayer.copy(&layer1, layer);
- colr_iLayerList.push(&m.layers, layer1);
- }
- if (mapping->layers.length) {
- table_iCOLR.push(consolidated, m);
- } else {
- logWarning("[Consolidate] COLR decomposition for /%s is empth", mapping->glyph.name);
- colr_iMapping.dispose(&m);
- }
- }
- table_iCOLR.free(font->COLR);
- font->COLR = consolidated;
-}
-
-static int compareTSIEntry(const tsi_Entry *a, const tsi_Entry *b) {
- if (a->type != b->type) return a->type - b->type;
- return a->glyph.index - b->glyph.index;
-}
-
-static void consolidateTSI(otfcc_Font *font, table_TSI **_tsi, const otfcc_Options *options) {
- table_TSI *tsi = *_tsi;
- if (!font || !font->glyf || !tsi || !font->glyph_order) return;
- table_TSI *consolidated = table_iTSI.create();
- sds *gidEntries;
- NEW_CLEAN_N(gidEntries, font->glyf->length);
-
- foreach (tsi_Entry *entry, *tsi) {
- if (entry->type == TSI_GLYPH) {
- if (GlyphOrder.consolidateHandle(font->glyph_order, &entry->glyph)) {
- if (gidEntries[entry->glyph.index]) sdsfree(gidEntries[entry->glyph.index]);
- gidEntries[entry->glyph.index] = entry->content;
- entry->content = NULL;
- } else {
- logWarning("[Consolidate] Ignored missing glyph of /%s", entry->glyph.name);
- }
- } else {
- tsi_Entry e;
- tsi_iEntry.copy(&e, entry);
- table_iTSI.push(consolidated, e);
- }
- }
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- tsi_Entry e;
- e.type = TSI_GLYPH;
- e.glyph = Handle.fromIndex(j);
- GlyphOrder.consolidateHandle(font->glyph_order, &e.glyph);
- e.content = gidEntries[j] ? gidEntries[j] : sdsempty();
- table_iTSI.push(consolidated, e);
- }
- table_iTSI.free(tsi);
- FREE(gidEntries);
- table_iTSI.sort(consolidated, compareTSIEntry);
- *_tsi = consolidated;
-}
-
-void otfcc_consolidateFont(otfcc_Font *font, const otfcc_Options *options) {
- // In case we don’t have a glyph order, make one.
- if (font->glyf && !font->glyph_order) {
- otfcc_GlyphOrder *go = GlyphOrder.create();
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- sds name;
- sds glyfName = font->glyf->items[j]->name;
- if (glyfName) {
- name = sdsdup(glyfName);
- } else {
- name = sdscatprintf(sdsempty(), "$$gid%d", j);
- font->glyf->items[j]->name = sdsdup(name);
- }
- if (!GlyphOrder.setByName(go, name, j)) {
- logWarning("[Consolidate] Glyph name %s is already in use.", name);
- uint32_t suffix = 2;
- bool success = false;
- do {
- sds newname = sdscatfmt(sdsempty(), "%s_%u", name, suffix);
- success = GlyphOrder.setByName(go, newname, j);
- if (!success) {
- sdsfree(newname);
- suffix += 1;
- } else {
- logWarning("[Consolidate] Glyph %s is renamed into %s.", name, newname);
- sdsfree(font->glyf->items[j]->name);
- font->glyf->items[j]->name = sdsdup(newname);
- }
- } while (!success);
- sdsfree(name);
- }
- }
- font->glyph_order = go;
- }
- loggedStep("glyf") {
- consolidateGlyf(font, options);
- }
- loggedStep("cmap") {
- consolidateCmap(font, options);
- }
- if (font->glyf) consolidateOTL(font, options);
- loggedStep("COLR") {
- consolidateCOLR(font, options);
- }
- loggedStep("TSI_01") {
- consolidateTSI(font, &font->TSI_01, options);
- }
- loggedStep("TSI_23") {
- consolidateTSI(font, &font->TSI_23, options);
- }
- loggedStep("TSI5") {
- fontop_consolidateClassDef(font, font->TSI5, options);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.h
deleted file mode 100644
index 9675ddc8ac8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/consolidate.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CARYLL_CONSOLIDATE_H
-#define CARYLL_CONSOLIDATE_H
-
-#include "otfcc/font.h"
-
-extern void otfcc_consolidateFont(otfcc_Font *font, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.c
deleted file mode 100644
index 56debfdb2f5..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "GDEF.h"
-
-typedef struct {
- int gid;
- sds name;
- otl_CaretValueList carets;
- UT_hash_handle hh;
-} GDEF_ligcaret_hash;
-static int by_gid(GDEF_ligcaret_hash *a, GDEF_ligcaret_hash *b) {
- return a->gid - b->gid;
-}
-void consolidate_GDEF(otfcc_Font *font, table_GDEF *gdef, const otfcc_Options *options) {
- if (!font || !font->glyph_order || !gdef) return;
- if (gdef->glyphClassDef) {
- fontop_consolidateClassDef(font, gdef->glyphClassDef, options);
- otl_iClassDef.shrink(gdef->glyphClassDef);
- if (!gdef->glyphClassDef->numGlyphs) {
- otl_iClassDef.free(gdef->glyphClassDef);
- gdef->glyphClassDef = NULL;
- }
- }
- if (gdef->markAttachClassDef) {
- fontop_consolidateClassDef(font, gdef->markAttachClassDef, options);
- otl_iClassDef.shrink(gdef->markAttachClassDef);
- if (!gdef->markAttachClassDef->numGlyphs) {
- otl_iClassDef.free(gdef->markAttachClassDef);
- gdef->markAttachClassDef = NULL;
- }
- }
- if (gdef->ligCarets.length) {
- GDEF_ligcaret_hash *h = NULL;
- for (glyphid_t j = 0; j < gdef->ligCarets.length; j++) {
- GDEF_ligcaret_hash *s;
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &gdef->ligCarets.items[j].glyph)) {
- continue;
- }
- int gid = gdef->ligCarets.items[j].glyph.index;
- sds gname = sdsdup(gdef->ligCarets.items[j].glyph.name);
- if (gname) {
- HASH_FIND_INT(h, &gid, s);
- if (!s) {
- NEW(s);
- s->gid = gid;
- s->name = gname;
- otl_iCaretValueList.move(&s->carets, &gdef->ligCarets.items[j].carets);
- HASH_ADD_INT(h, gid, s);
- } else {
- logWarning("[Consolidate] Detected caret value double-mapping about glyph %s",
- gname);
- }
- }
- }
- HASH_SORT(h, by_gid);
- otl_iLigCaretTable.clear(&gdef->ligCarets);
- GDEF_ligcaret_hash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- otl_CaretValueRecord v = {
- .glyph = Handle.fromConsolidated(s->gid, s->name),
- };
- otl_iCaretValueList.move(&v.carets, &s->carets);
- otl_iLigCaretTable.push(&gdef->ligCarets, v);
- sdsfree(s->name);
- HASH_DEL(h, s);
- FREE(s);
- }
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.h
deleted file mode 100644
index b3548c687eb..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/GDEF.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GDEF_H
-#define CARYLL_FONTOPS_OTL_GDEF_H
-#include "common.h"
-
-void consolidate_GDEF(otfcc_Font *font, table_GDEF *gdef, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.c
deleted file mode 100644
index 4d883ab87a1..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "chaining.h"
-
-bool consolidate_chaining(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_chaining *subtable = &(_subtable->chaining);
- if (subtable->type) {
- logWarning("[Consolidate] Ignoring non-canonical chaining subtable.");
- return false;
- }
- otl_ChainingRule *rule = &(subtable->rule);
- bool possible = true;
- for (tableid_t j = 0; j < rule->matchCount; j++) {
- fontop_consolidateCoverage(font, rule->match[j], options);
- Coverage.shrink(rule->match[j], true);
- possible = possible && (rule->match[j]->numGlyphs > 0);
- }
- if (rule->inputBegins > rule->matchCount) rule->inputBegins = rule->matchCount;
- if (rule->inputEnds > rule->matchCount) rule->inputEnds = rule->matchCount;
- for (tableid_t j = 0; j < rule->applyCount; j++) {
- bool foundLookup = false;
- lookup_handle *h = &(rule->apply[j].lookup);
- if (h->name) {
- for (tableid_t k = 0; k < table->lookups.length; k++) {
- if (!table->lookups.items[k]) continue;
- if (!table->lookups.items[k]->subtables.length) continue;
- if (strcmp(table->lookups.items[k]->name, h->name) != 0) continue;
- foundLookup = true;
- Handle.consolidateTo(h, k, table->lookups.items[k]->name);
- }
- if (!foundLookup && rule->apply[j].lookup.name) {
- logWarning("[Consolidate] Quoting an invalid lookup %s. This lookup application is "
- "ignored.",
- rule->apply[j].lookup.name);
- Handle.dispose(&rule->apply[j].lookup);
- }
- } else if (h->state == HANDLE_STATE_INDEX) {
- if (h->index >= table->lookups.length) {
- logWarning("[Consolidate] Quoting an invalid lookup #%d.", h->index);
- h->index = 0;
- }
- Handle.consolidateTo(h, h->index, table->lookups.items[h->index]->name);
- }
- }
- // If a rule is designed to have no lookup application, it may be a ignoration
- // otfcc will keep them.
- if (rule->applyCount) {
- tableid_t k = 0;
- for (tableid_t j = 0; j < rule->applyCount; j++) {
- if (rule->apply[j].lookup.name) { rule->apply[k++] = rule->apply[j]; }
- }
- rule->applyCount = k;
- if (!rule->applyCount) { return true; }
- }
- return !possible;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.h
deleted file mode 100644
index a104dd66e6d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/chaining.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_CHAINING_H
-#define CARYLL_FONTOPS_OTL_CHAINING_H
-#include "common.h"
-
-bool consolidate_chaining(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.c
deleted file mode 100644
index 9877ceb35e9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "common.h"
-
-void fontop_consolidateCoverage(otfcc_Font *font, otl_Coverage *coverage, const otfcc_Options *options) {
- if (!coverage) return;
- for (glyphid_t j = 0; j < coverage->numGlyphs; j++) {
- glyph_handle *h = &(coverage->glyphs[j]);
- if (!GlyphOrder.consolidateHandle(font->glyph_order, h)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n", h->name);
- Handle.dispose(h);
- }
- }
-}
-
-void fontop_consolidateClassDef(otfcc_Font *font, otl_ClassDef *cd, const otfcc_Options *options) {
- if (!cd) return;
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- glyph_handle *h = &(cd->glyphs[j]);
- if (!GlyphOrder.consolidateHandle(font->glyph_order, h)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n", h->name);
- Handle.dispose(h);
- cd->classes[j] = 0;
- }
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.h
deleted file mode 100644
index e1106373a95..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/common.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_COMMON_H
-#define CARYLL_FONTOPS_OTL_COMMON_H
-
-#include "otfcc/font.h"
-#include "table/otl/private.h"
-
-void fontop_consolidateCoverage(otfcc_Font *font, otl_Coverage *coverage, const otfcc_Options *options);
-void fontop_consolidateClassDef(otfcc_Font *font, otl_ClassDef *cd, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.c
deleted file mode 100644
index 7ebbf9c48b8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.c
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "gpos-cursive.h"
-
-typedef struct {
- int fromid;
- sds fromname;
- otl_Anchor enter;
- otl_Anchor exit;
- UT_hash_handle hh;
-} gpos_cursive_hash;
-static int gpos_cursive_by_from_id(gpos_cursive_hash *a, gpos_cursive_hash *b) {
- return a->fromid - b->fromid;
-}
-bool consolidate_gpos_cursive(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gpos_cursive *subtable = &(_subtable->gpos_cursive);
- gpos_cursive_hash *h = NULL;
- for (glyphid_t k = 0; k < subtable->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].target)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].target.name);
- continue;
- }
-
- gpos_cursive_hash *s;
- int fromid = subtable->items[k].target.index;
- HASH_FIND_INT(h, &fromid, s);
- if (s) {
- logWarning("[Consolidate] Double-mapping a glyph in a cursive positioning /%s.\n",
- subtable->items[k].target.name);
- } else {
- NEW(s);
- s->fromid = subtable->items[k].target.index;
- s->fromname = sdsdup(subtable->items[k].target.name);
- s->enter = subtable->items[k].enter;
- s->exit = subtable->items[k].exit;
- HASH_ADD_INT(h, fromid, s);
- }
- }
-
- HASH_SORT(h, gpos_cursive_by_from_id);
- iSubtable_gpos_cursive.clear(subtable);
-
- gpos_cursive_hash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- iSubtable_gpos_cursive.push(
- subtable, ((otl_GposCursiveEntry){
- .target = Handle.fromConsolidated(s->fromid, s->fromname), .enter = s->enter, .exit = s->exit,
- }));
- sdsfree(s->fromname);
- HASH_DEL(h, s);
- FREE(s);
- }
-
- return (subtable->length == 0);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.h
deleted file mode 100644
index bc8cc1804b0..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-cursive.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GPOS_CURSIVE_H
-#define CARYLL_FONTOPS_OTL_GPOS_CURSIVE_H
-#include "common.h"
-
-bool consolidate_gpos_cursive(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.c
deleted file mode 100644
index 226f1c2481e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "gpos-pair.h"
-
-bool consolidate_gpos_pair(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable, const otfcc_Options *options) {
- subtable_gpos_pair *subtable = &(_subtable->gpos_pair);
- fontop_consolidateClassDef(font, subtable->first, options);
- fontop_consolidateClassDef(font, subtable->second, options);
- ClassDef.shrink(subtable->first);
- ClassDef.shrink(subtable->second);
- return (subtable->first->numGlyphs == 0);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.h
deleted file mode 100644
index 788b27d7dba..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-pair.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GPOS_PAIR_H
-#define CARYLL_FONTOPS_OTL_GPOS_PAIR_H
-#include "common.h"
-
-bool consolidate_gpos_pair(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.c
deleted file mode 100644
index ddcc9ee3b6d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "gpos-single.h"
-
-typedef struct {
- int fromid;
- sds fromname;
- otl_PositionValue v;
- UT_hash_handle hh;
-} gpos_single_hash;
-static int gpos_by_from_id(gpos_single_hash *a, gpos_single_hash *b) {
- return a->fromid - b->fromid;
-}
-
-bool consolidate_gpos_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gpos_single *subtable = &(_subtable->gpos_single);
- gpos_single_hash *h = NULL;
- for (glyphid_t k = 0; k < subtable->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].target)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n",
- subtable->items[k].target.name);
- continue;
- }
- gpos_single_hash *s;
- int fromid = subtable->items[k].target.index;
- HASH_FIND_INT(h, &fromid, s);
- if (s) {
- logWarning("[Consolidate] Detected glyph double-mapping about /%s.\n",
- subtable->items[k].target.name);
- } else {
- NEW(s);
- s->fromid = subtable->items[k].target.index;
- s->fromname = sdsdup(subtable->items[k].target.name);
- s->v = subtable->items[k].value;
- HASH_ADD_INT(h, fromid, s);
- }
- }
-
- HASH_SORT(h, gpos_by_from_id);
- iSubtable_gpos_single.clear(subtable);
-
- gpos_single_hash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- iSubtable_gpos_single.push(
- subtable, ((otl_GposSingleEntry){
- .target = Handle.fromConsolidated(s->fromid, s->fromname), .value = s->v,
- }));
- sdsfree(s->fromname);
- HASH_DEL(h, s);
- FREE(s);
- }
-
- return (subtable->length == 0);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.h
deleted file mode 100644
index e60718317be..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gpos-single.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GPOS_SINGLE_H
-#define CARYLL_FONTOPS_OTL_GPOS_SINGLE_H
-#include "common.h"
-
-bool consolidate_gpos_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.c
deleted file mode 100644
index c284feb6bf9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "gsub-ligature.h"
-
-bool consolidate_gsub_ligature(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gsub_ligature *subtable = &(_subtable->gsub_ligature);
- subtable_gsub_ligature nt;
- iSubtable_gsub_ligature.init(&nt);
- for (glyphid_t k = 0; k < subtable->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].to)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].to.name);
- continue;
- }
- fontop_consolidateCoverage(font, subtable->items[k].from, options);
- Coverage.shrink(subtable->items[k].from, false);
- if (!subtable->items[k].from->numGlyphs) {
- logWarning("[Consolidate] Ignoring empty ligature substitution to "
- "glyph /%s.\n",
- subtable->items[k].to.name);
- continue;
- }
- iSubtable_gsub_ligature.push(
- &nt, ((otl_GsubLigatureEntry){
- .from = subtable->items[k].from, .to = Handle.dup(subtable->items[k].to),
- }));
- subtable->items[k].from = NULL;
- }
- iSubtable_gsub_ligature.replace(subtable, nt);
- return (subtable->length == 0);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.h
deleted file mode 100644
index d698dce355c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-ligature.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GSUB_LIGATURE_H
-#define CARYLL_FONTOPS_OTL_GSUB_LIGATURE_H
-#include "common.h"
-
-bool consolidate_gsub_ligature(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.c
deleted file mode 100644
index 21c9ce8b0d5..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "gsub-multi.h"
-
-typedef struct {
- int fromid;
- sds fromname;
- otl_Coverage *to;
- UT_hash_handle hh;
-} gsub_multi_hash;
-static int by_from_id_multi(gsub_multi_hash *a, gsub_multi_hash *b) {
- return a->fromid - b->fromid;
-}
-
-bool consolidate_gsub_multi(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gsub_multi *subtable = &(_subtable->gsub_multi);
- gsub_multi_hash *h = NULL;
-
- for (glyphid_t k = 0; k < subtable->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].from)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].from.name);
- continue;
- }
- fontop_consolidateCoverage(font, subtable->items[k].to, options);
- Coverage.shrink(subtable->items[k].to, false);
- if (!subtable->items[k].to->numGlyphs) {
- logWarning("[Consolidate] Ignoring empty one-to-many / alternative substitution for "
- "glyph /%s.\n",
- subtable->items[k].from.name);
- continue;
- }
-
- gsub_multi_hash *s;
- int fromid = subtable->items[k].from.index;
- HASH_FIND_INT(h, &fromid, s);
- if (!s) {
- NEW(s);
- s->fromid = subtable->items[k].from.index;
- s->fromname = sdsdup(subtable->items[k].from.name);
- s->to = subtable->items[k].to;
- subtable->items[k].to = NULL; // Transfer ownership
- HASH_ADD_INT(h, fromid, s);
- }
- }
- HASH_SORT(h, by_from_id_multi);
- iSubtable_gsub_multi.clear(subtable);
- {
- gsub_multi_hash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- iSubtable_gsub_multi.push(
- subtable, ((otl_GsubMultiEntry){
- .from = Handle.fromConsolidated(s->fromid, s->fromname), .to = s->to,
- }));
- sdsfree(s->fromname);
- HASH_DEL(h, s);
- FREE(s);
- }
- }
- return (subtable->length == 0);
-}
-
-bool consolidate_gsub_alternative(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- return consolidate_gsub_multi(font, table, _subtable, options);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.h
deleted file mode 100644
index ff2a2be7368..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-multi.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GSUB_MULTI_H
-#define CARYLL_FONTOPS_OTL_GSUB_MULTI_H
-#include "common.h"
-
-bool consolidate_gsub_multi(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-bool consolidate_gsub_alternative(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.c
deleted file mode 100644
index 7157dfc6966..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "gsub-reverse.h"
-
-typedef struct {
- int fromid;
- sds fromname;
- int toid;
- sds toname;
- UT_hash_handle hh;
-} gsub_single_map_hash;
-static int by_from_id(gsub_single_map_hash *a, gsub_single_map_hash *b) {
- return a->fromid - b->fromid;
-}
-
-bool consolidate_gsub_reverse(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gsub_reverse *subtable = &(_subtable->gsub_reverse);
- for (tableid_t j = 0; j < subtable->matchCount; j++) {
- fontop_consolidateCoverage(font, subtable->match[j], options);
- }
- fontop_consolidateCoverage(font, subtable->to, options);
- if (subtable->inputIndex >= subtable->matchCount) { subtable->inputIndex = subtable->matchCount - 1; }
- gsub_single_map_hash *h = NULL;
- otl_Coverage *from = subtable->match[subtable->inputIndex];
- for (glyphid_t k = 0; k < from->numGlyphs && k < subtable->to->numGlyphs; k++) {
- gsub_single_map_hash *s;
- int fromid = from->glyphs[k].index;
- HASH_FIND_INT(h, &fromid, s);
- if (s) {
- logWarning("[Consolidate] Double-mapping a glyph in a reverse substitution /%s.\n", from->glyphs[k].name);
- } else {
- NEW(s);
- s->fromid = from->glyphs[k].index;
- s->toid = subtable->to->glyphs[k].index;
- s->fromname = from->glyphs[k].name;
- s->toname = subtable->to->glyphs[k].name;
- HASH_ADD_INT(h, fromid, s);
- }
- }
- HASH_SORT(h, by_from_id);
- if (HASH_COUNT(h) != from->numGlyphs || HASH_COUNT(h) != subtable->to->numGlyphs) {
- logWarning("[Consolidate] In this reverse subsitution lookup, some mappings are ignored.\n");
- }
- from->numGlyphs = HASH_COUNT(h);
- subtable->to->numGlyphs = HASH_COUNT(h);
- {
- gsub_single_map_hash *s, *tmp;
- glyphid_t j = 0;
- HASH_ITER(hh, h, s, tmp) {
- from->glyphs[j] = Handle.fromConsolidated(s->fromid, s->fromname);
- subtable->to->glyphs[j] = Handle.fromConsolidated(s->toid, s->toname);
- j++;
- HASH_DEL(h, s);
- FREE(s);
- }
- }
- return false;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.h
deleted file mode 100644
index 53b9b5a16fc..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-reverse.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GSUB_REVERSE_H
-#define CARYLL_FONTOPS_OTL_GSUB_REVERSE_H
-#include "common.h"
-
-bool consolidate_gsub_reverse(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.c
deleted file mode 100644
index f1d25258a9d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "gsub-single.h"
-
-typedef struct {
- int fromid;
- sds fromname;
- int toid;
- sds toname;
- UT_hash_handle hh;
-} gsub_single_map_hash;
-static int by_from_id(gsub_single_map_hash *a, gsub_single_map_hash *b) {
- return a->fromid - b->fromid;
-}
-bool consolidate_gsub_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gsub_single *subtable = &(_subtable->gsub_single);
- gsub_single_map_hash *h = NULL;
- for (size_t k = 0; k < subtable->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].from)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].from.name);
- continue;
- }
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].to)) {
- logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].to.name);
- continue;
- }
- gsub_single_map_hash *s;
- int fromid = subtable->items[k].from.index;
- HASH_FIND_INT(h, &fromid, s);
- if (s) {
- logWarning("[Consolidate] Double-mapping a glyph in a single substitution /%s.\n",
- subtable->items[k].from.name);
- } else {
- NEW(s);
- s->fromid = subtable->items[k].from.index;
- s->toid = subtable->items[k].to.index;
- s->fromname = sdsdup(subtable->items[k].from.name);
- s->toname = sdsdup(subtable->items[k].to.name);
- HASH_ADD_INT(h, fromid, s);
- }
- }
- HASH_SORT(h, by_from_id);
- if (HASH_COUNT(h) != subtable->length) { logWarning("[Consolidate] In this lookup, some mappings are ignored.\n"); }
-
- iSubtable_gsub_single.clear(subtable);
- gsub_single_map_hash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- iSubtable_gsub_single.push(subtable,
- ((otl_GsubSingleEntry){.from = Handle.fromConsolidated(s->fromid, s->fromname),
- .to = Handle.fromConsolidated(s->toid, s->toname)}));
- sdsfree(s->fromname);
- sdsfree(s->toname);
- HASH_DEL(h, s);
- FREE(s);
- }
- return (subtable->length == 0);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.h
deleted file mode 100644
index 5678548dea9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/gsub-single.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_GSUB_SINGLE_H
-#define CARYLL_FONTOPS_OTL_GSUB_SINGLE_H
-#include "common.h"
-
-bool consolidate_gsub_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.c
deleted file mode 100644
index c5e3e420677..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.c
+++ /dev/null
@@ -1,166 +0,0 @@
-#include "mark.h"
-
-typedef struct {
- int gid;
- sds name;
- glyphclass_t markClass;
- otl_Anchor anchor;
- UT_hash_handle hh;
-} mark_hash;
-static int mark_by_gid(mark_hash *a, mark_hash *b) {
- return a->gid - b->gid;
-}
-typedef struct {
- int gid;
- sds name;
- otl_Anchor *anchors;
- UT_hash_handle hh;
-} base_hash;
-static int base_by_gid(base_hash *a, base_hash *b) {
- return a->gid - b->gid;
-}
-typedef struct {
- int gid;
- sds name;
- glyphid_t componentCount;
- otl_Anchor **anchors;
- UT_hash_handle hh;
-} lig_hash;
-static int lig_by_gid(lig_hash *a, lig_hash *b) {
- return a->gid - b->gid;
-}
-
-static void consolidateMarkArray(otfcc_Font *font, table_OTL *table, const otfcc_Options *options,
- otl_MarkArray *markArray, glyphclass_t classCount) {
- mark_hash *hm = NULL;
- for (glyphid_t k = 0; k < markArray->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &markArray->items[k].glyph)) {
- logWarning("[Consolidate] Ignored unknown glyph name %s.",
- markArray->items[k].glyph.name);
- continue;
- }
- mark_hash *s = NULL;
- int gid = markArray->items[k].glyph.index;
- HASH_FIND_INT(hm, &gid, s);
- if (!s && markArray->items[k].anchor.present &&
- markArray->items[k].markClass < classCount) {
- NEW(s);
- s->gid = markArray->items[k].glyph.index;
- s->name = sdsdup(markArray->items[k].glyph.name);
- s->markClass = markArray->items[k].markClass;
- s->anchor = markArray->items[k].anchor;
- HASH_ADD_INT(hm, gid, s);
- } else {
- logWarning("[Consolidate] Ignored invalid or double-mapping mark definition for /%s.",
- markArray->items[k].glyph.name);
- }
- }
- HASH_SORT(hm, mark_by_gid);
- otl_iMarkArray.clear(markArray);
- mark_hash *s, *tmp;
- HASH_ITER(hh, hm, s, tmp) {
- otl_iMarkArray.push(markArray, ((otl_MarkRecord){
- .glyph = Handle.fromConsolidated(s->gid, s->name),
- .markClass = s->markClass,
- .anchor = s->anchor,
- }));
- sdsfree(s->name);
- HASH_DEL(hm, s);
- FREE(s);
- }
-}
-
-static void consolidateBaseArray(otfcc_Font *font, table_OTL *table, const otfcc_Options *options,
- otl_BaseArray *baseArray) {
- // consolidate bases
- base_hash *hm = NULL;
- for (glyphid_t k = 0; k < baseArray->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &baseArray->items[k].glyph)) {
- logWarning("[Consolidate] Ignored unknown glyph name %s.",
- baseArray->items[k].glyph.name);
- continue;
- }
- base_hash *s = NULL;
- int gid = baseArray->items[k].glyph.index;
- HASH_FIND_INT(hm, &gid, s);
- if (!s) {
- NEW(s);
- s->gid = baseArray->items[k].glyph.index;
- s->name = sdsdup(baseArray->items[k].glyph.name);
- s->anchors = baseArray->items[k].anchors;
- baseArray->items[k].anchors = NULL; // Transfer ownership
- HASH_ADD_INT(hm, gid, s);
- } else {
- logWarning("[Consolidate] Ignored anchor double-definition for /%s.",
- baseArray->items[k].glyph.name);
- }
- }
- HASH_SORT(hm, base_by_gid);
- otl_iBaseArray.clear(baseArray);
- base_hash *s, *tmp;
- HASH_ITER(hh, hm, s, tmp) {
- otl_iBaseArray.push(
- baseArray, ((otl_BaseRecord){
- .glyph = Handle.fromConsolidated(s->gid, s->name), .anchors = s->anchors,
- }));
- sdsfree(s->name);
- HASH_DEL(hm, s);
- FREE(s);
- }
-}
-
-static void consolidateLigArray(otfcc_Font *font, table_OTL *table, const otfcc_Options *options,
- otl_LigatureArray *ligArray) {
- lig_hash *hm = NULL;
- for (glyphid_t k = 0; k < ligArray->length; k++) {
- if (!GlyphOrder.consolidateHandle(font->glyph_order, &ligArray->items[k].glyph)) {
- logWarning("[Consolidate] Ignored unknown glyph name %s.",
- ligArray->items[k].glyph.name);
- continue;
- }
- lig_hash *s = NULL;
- int gid = ligArray->items[k].glyph.index;
- HASH_FIND_INT(hm, &gid, s);
- if (!s) {
- NEW(s);
- s->gid = ligArray->items[k].glyph.index;
- s->name = sdsdup(ligArray->items[k].glyph.name);
- s->componentCount = ligArray->items[k].componentCount;
- s->anchors = ligArray->items[k].anchors;
- ligArray->items[k].anchors = NULL;
- HASH_ADD_INT(hm, gid, s);
- } else {
- logWarning("[Consolidate] Ignored anchor double-definition for /%s.",
- ligArray->items[k].glyph.name);
- }
- }
- HASH_SORT(hm, lig_by_gid);
- otl_iLigatureArray.clear(ligArray);
- lig_hash *s, *tmp;
- HASH_ITER(hh, hm, s, tmp) {
- otl_iLigatureArray.push(ligArray, ((otl_LigatureBaseRecord){
- .glyph = Handle.fromConsolidated(s->gid, s->name),
- .componentCount = s->componentCount,
- .anchors = s->anchors,
- }));
- sdsfree(s->name);
- HASH_DEL(hm, s);
- FREE(s);
- }
-}
-
-bool consolidate_mark_to_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gpos_markToSingle *subtable = &(_subtable->gpos_markToSingle);
- consolidateMarkArray(font, table, options, &subtable->markArray, subtable->classCount);
- consolidateBaseArray(font, table, options, &subtable->baseArray);
- return (subtable->markArray.length == 0) || (subtable->baseArray.length == 0);
-}
-
-bool consolidate_mark_to_ligature(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options) {
- subtable_gpos_markToLigature *subtable = &(_subtable->gpos_markToLigature);
- consolidateMarkArray(font, table, options, &subtable->markArray, subtable->classCount);
- consolidateLigArray(font, table, options, &subtable->ligArray);
- return (subtable->markArray.length == 0) || (subtable->ligArray.length == 0);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.h
deleted file mode 100644
index 7aaa23a93eb..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/consolidate/otl/mark.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef CARYLL_FONTOPS_OTL_MARK_H
-#define CARYLL_FONTOPS_OTL_MARK_H
-#include "common.h"
-
-bool consolidate_mark_to_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-bool consolidate_mark_to_ligature(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-font.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-font.c
deleted file mode 100644
index 1e32f867cf4..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-font.c
+++ /dev/null
@@ -1,168 +0,0 @@
-#include "support/util.h"
-#include "otfcc/font.h"
-#include "table/all.h"
-#include "otfcc/sfnt-builder.h"
-#include "consolidate/consolidate.h"
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-static void *createFontTable(otfcc_Font *font, const uint32_t tag) {
- switch (tag) {
- case OTFCC_CHR('n','a','m','e'):
- return table_iName.create();
- case OTFCC_CHR('G','S','U','B'):
- case OTFCC_CHR('G','P','O','S'):
- return table_iOTL.create();
- default:
- return NULL;
- }
-}
-
-static void deleteFontTable(otfcc_Font *font, const uint32_t tag) {
- switch (tag) {
- case OTFCC_CHR('h','e','a','d'):
- if (font->head) DELETE(table_iHead.free, font->head);
- return;
- case OTFCC_CHR('h','h','e','a'):
- if (font->hhea) DELETE(table_iHhea.free, font->hhea);
- return;
- case OTFCC_CHR('m','a','x','p'):
- if (font->maxp) DELETE(table_iMaxp.free, font->maxp);
- return;
- case OTFCC_CHR('O','S','_','2'):
- case OTFCC_CHR('O','S','/','2'):
- if (font->OS_2) DELETE(table_iOS_2.free, font->OS_2);
- return;
- case OTFCC_CHR('n','a','m','e'):
- if (font->name) DELETE(table_iName.free, font->name);
- return;
- case OTFCC_CHR('m','e','t','a'):
- if (font->meta) DELETE(table_iMeta.free, font->meta);
- return;
- case OTFCC_CHR('h','m','t','x'):
- if (font->hmtx) DELETE(table_iHmtx.free, font->hmtx);
- return;
- case OTFCC_CHR('v','m','t','x'):
- if (font->vmtx) DELETE(table_iVmtx.free, font->vmtx);
- return;
- case OTFCC_CHR('p','o','s','t'):
- if (font->post) DELETE(iTable_post.free, font->post);
- return;
-#if 0
- case OTFCC_CHR('h','d','m','x'):
- if (font->hdmx) DELETE(otfcc_deleteHdmx, font->hdmx);
- return;
-#endif
- case OTFCC_CHR('v','h','e','a'):
- if (font->vhea) DELETE(table_iVhea.free, font->vhea);
- return;
- case OTFCC_CHR('f','p','g','m'):
- if (font->fpgm) DELETE(table_iFpgm_prep.free, font->fpgm);
- return;
- case OTFCC_CHR('p','r','e','p'):
- if (font->prep) DELETE(table_iFpgm_prep.free, font->prep);
- return;
- case OTFCC_CHR('c','v','t','_'):
- case OTFCC_CHR('c','v','t',' '):
- if (font->cvt_) DELETE(table_iCvt.free, font->cvt_);
- return;
- case OTFCC_CHR('g','a','s','p'):
- if (font->gasp) DELETE(table_iGasp.free, font->gasp);
- return;
- case OTFCC_CHR('C','F','F','_'):
- case OTFCC_CHR('C','F','F',' '):
- if (font->CFF_) DELETE(table_iCFF.free, font->CFF_);
- return;
- case OTFCC_CHR('g','l','y','f'):
- if (font->glyf) DELETE(table_iGlyf.free, font->glyf);
- return;
- case OTFCC_CHR('c','m','a','p'):
- if (font->cmap) DELETE(table_iCmap.free, font->cmap);
- return;
- case OTFCC_CHR('L','T','S','H'):
- if (font->LTSH) DELETE(table_iLTSH.free, font->LTSH);
- return;
- case OTFCC_CHR('G','S','U','B'):
- if (font->GSUB) DELETE(table_iOTL.free, font->GSUB);
- return;
- case OTFCC_CHR('G','P','O','S'):
- if (font->GPOS) DELETE(table_iOTL.free, font->GPOS);
- return;
- case OTFCC_CHR('G','D','E','F'):
- if (font->GDEF) DELETE(table_iGDEF.free, font->GDEF);
- return;
- case OTFCC_CHR('B','A','S','E'):
- if (font->BASE) DELETE(table_iBASE.free, font->BASE);
- return;
- case OTFCC_CHR('V','O','R','G'):
- if (font->VORG) DELETE(table_iVORG.free, font->VORG);
- return;
- case OTFCC_CHR('C','P','A','L'):
- if (font->CPAL) DELETE(table_iCPAL.free, font->CPAL);
- return;
- case OTFCC_CHR('C','O','L','R'):
- if (font->COLR) DELETE(table_iCOLR.free, font->COLR);
- return;
- case OTFCC_CHR('S','V','G',' '):
- case OTFCC_CHR('S','V','G','_'):
- if (font->SVG_) DELETE(table_iSVG.free, font->SVG_);
- return;
- case OTFCC_CHR('T','S','I','0'):
- case OTFCC_CHR('T','S','I','1'):
- if (font->TSI_01) DELETE(table_iTSI.free, font->TSI_01);
- return;
- case OTFCC_CHR('T','S','I','2'):
- case OTFCC_CHR('T','S','I','3'):
- if (font->TSI_23) DELETE(table_iTSI.free, font->TSI_23);
- return;
- case OTFCC_CHR('T','S','I','5'):
- if (font->TSI5) DELETE(otl_iClassDef.free, font->TSI5);
- return;
- }
-}
-
-static INLINE void initFont(otfcc_Font *font) {
- memset(font, 0, sizeof(*font));
-}
-static INLINE void disposeFont(otfcc_Font *font) {
- deleteFontTable(font, OTFCC_CHR('h','e','a','d'));
- deleteFontTable(font, OTFCC_CHR('h','h','e','a'));
- deleteFontTable(font, OTFCC_CHR('m','a','x','p'));
- deleteFontTable(font, OTFCC_CHR('O','S','_','2'));
- deleteFontTable(font, OTFCC_CHR('n','a','m','e'));
- deleteFontTable(font, OTFCC_CHR('m','e','t','a'));
- deleteFontTable(font, OTFCC_CHR('h','m','t','x'));
- deleteFontTable(font, OTFCC_CHR('v','m','t','x'));
- deleteFontTable(font, OTFCC_CHR('p','o','s','t'));
- deleteFontTable(font, OTFCC_CHR('h','d','m','x'));
- deleteFontTable(font, OTFCC_CHR('v','h','e','a'));
- deleteFontTable(font, OTFCC_CHR('f','p','g','m'));
- deleteFontTable(font, OTFCC_CHR('p','r','e','p'));
- deleteFontTable(font, OTFCC_CHR('c','v','t','_'));
- deleteFontTable(font, OTFCC_CHR('g','a','s','p'));
- deleteFontTable(font, OTFCC_CHR('C','F','F','_'));
- deleteFontTable(font, OTFCC_CHR('g','l','y','f'));
- deleteFontTable(font, OTFCC_CHR('c','m','a','p'));
- deleteFontTable(font, OTFCC_CHR('L','T','S','H'));
- deleteFontTable(font, OTFCC_CHR('G','S','U','B'));
- deleteFontTable(font, OTFCC_CHR('G','P','O','S'));
- deleteFontTable(font, OTFCC_CHR('G','D','E','F'));
- deleteFontTable(font, OTFCC_CHR('B','A','S','E'));
- deleteFontTable(font, OTFCC_CHR('V','O','R','G'));
- deleteFontTable(font, OTFCC_CHR('C','P','A','L'));
- deleteFontTable(font, OTFCC_CHR('C','O','L','R'));
- deleteFontTable(font, OTFCC_CHR('S','V','G','_'));
- deleteFontTable(font, OTFCC_CHR('T','S','I','0'));
- deleteFontTable(font, OTFCC_CHR('T','S','I','2'));
- deleteFontTable(font, OTFCC_CHR('T','S','I','5'));
-
- GlyphOrder.free(font->glyph_order);
-}
-caryll_standardRefTypeFn(otfcc_Font, initFont, disposeFont);
-
-caryll_ElementInterfaceOf(otfcc_Font) otfcc_iFont = {
- caryll_standardRefTypeMethods(otfcc_Font),
- .createTable = createFontTable,
- .deleteTable = deleteFontTable,
- .consolidate = otfcc_consolidateFont,
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt-builder.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt-builder.c
deleted file mode 100644
index 8e6ff87030f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt-builder.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include "support/util.h"
-#include "otfcc/sfnt-builder.h"
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-static uint32_t buf_checksum(caryll_Buffer *buffer) {
- uint32_t actualLength = (uint32_t)buflen(buffer);
- buflongalign(buffer);
- uint32_t sum = 0;
- {
- uint32_t *start = (uint32_t *)buffer->data;
- uint32_t *end = start + ((actualLength + 3) & ~3) / sizeof(uint32_t);
- while (start < end) {
- sum += otfcc_endian_convert32(*start++);
- }
- }
- return sum;
-}
-
-static otfcc_SFNTTableEntry *createSegment(uint32_t tag, caryll_Buffer *buffer) {
- otfcc_SFNTTableEntry *table;
- NEW(table);
- table->tag = tag;
- table->length = (uint32_t)buflen(buffer);
- buflongalign(buffer);
- table->buffer = buffer;
-
- uint32_t sum = 0;
- {
- uint32_t *start = (uint32_t *)buffer->data;
- uint32_t *end = start + ((table->length + 3) & ~3) / sizeof(uint32_t);
- while (start < end) {
- sum += otfcc_endian_convert32(*start++);
- }
- }
- table->checksum = sum;
- return table;
-}
-
-otfcc_SFNTBuilder *otfcc_newSFNTBuilder(uint32_t header, const otfcc_Options *options) {
- otfcc_SFNTBuilder *builder;
- NEW(builder);
- builder->count = 0;
- builder->header = header;
- builder->tables = NULL;
- builder->options = options;
- return builder;
-}
-
-void otfcc_deleteSFNTBuilder(otfcc_SFNTBuilder *builder) {
- if (!builder) return;
- otfcc_SFNTTableEntry *item, *tmp;
- HASH_ITER(hh, builder->tables, item, tmp) {
- HASH_DEL(builder->tables, item);
- buffree(item->buffer);
- FREE(item);
- }
- FREE(builder);
-}
-
-void otfcc_SFNTBuilder_pushTable(otfcc_SFNTBuilder *builder, uint32_t tag, caryll_Buffer *buffer) {
- if (!builder || !buffer) return;
- otfcc_SFNTTableEntry *item;
- const otfcc_Options *options = builder->options;
- HASH_FIND_INT(builder->tables, &tag, item);
- if (!item) {
- item = createSegment(tag, buffer);
- HASH_ADD_INT(builder->tables, tag, item);
- logProgress("OpenType table %c%c%c%c successfully built.\n", (tag >> 24) & 0xff,
- (tag >> 16) & 0xff, (tag >> 8) & 0xff, tag & 0xff);
- } else {
- buffree(buffer);
- }
-}
-
-static int byTag(otfcc_SFNTTableEntry *a, otfcc_SFNTTableEntry *b) {
- return (a->tag - b->tag);
-}
-
-caryll_Buffer *otfcc_SFNTBuilder_serialize(otfcc_SFNTBuilder *builder) {
- caryll_Buffer *buffer = bufnew();
- if (!builder) return buffer;
- uint16_t nTables = HASH_COUNT(builder->tables);
- uint16_t searchRange = (nTables < 16 ? 8 : nTables < 32 ? 16 : nTables < 64 ? 32 : 64) * 16;
- bufwrite32b(buffer, builder->header);
- bufwrite16b(buffer, nTables);
- bufwrite16b(buffer, searchRange);
- bufwrite16b(buffer, (nTables < 16 ? 3 : nTables < 32 ? 4 : nTables < 64 ? 5 : 6));
- bufwrite16b(buffer, nTables * 16 - searchRange);
-
- otfcc_SFNTTableEntry *table;
- size_t offset = 12 + nTables * 16;
- size_t headOffset = offset;
- HASH_SORT(builder->tables, byTag);
- foreach_hash(table, builder->tables) {
- // write table directory
- bufwrite32b(buffer, table->tag);
- bufwrite32b(buffer, table->checksum);
- bufwrite32b(buffer, (uint32_t)offset);
- bufwrite32b(buffer, table->length);
- size_t cp = buffer->cursor;
- bufseek(buffer, offset);
- bufwrite_buf(buffer, table->buffer);
- bufseek(buffer, cp);
- // record where the [head] is
- if (table->tag == OTFCC_CHR('h','e','a','d')) { headOffset = offset; }
- offset += buflen(table->buffer);
- }
-
- // write head.checksumAdjust
- uint32_t wholeChecksum = buf_checksum(buffer);
- bufseek(buffer, headOffset + 8);
- bufwrite32b(buffer, 0xB1B0AFBA - wholeChecksum);
- return buffer;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt.c
deleted file mode 100644
index c336b118fdf..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/font/caryll-sfnt.c
+++ /dev/null
@@ -1,90 +0,0 @@
-#include "support/util.h"
-#include "otfcc/sfnt.h"
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-static void otfcc_read_packets(otfcc_SplineFontContainer *font, FILE *file) {
- for (uint32_t count = 0; count < font->count; count++) {
- (void)fseek(file, font->offsets[count], SEEK_SET);
-
- font->packets[count].sfnt_version = otfcc_get32u(file);
- font->packets[count].numTables = otfcc_get16u(file);
- font->packets[count].searchRange = otfcc_get16u(file);
- font->packets[count].entrySelector = otfcc_get16u(file);
- font->packets[count].rangeShift = otfcc_get16u(file);
- NEW(font->packets[count].pieces, font->packets[count].numTables);
-
- for (uint32_t i = 0; i < font->packets[count].numTables; i++) {
- font->packets[count].pieces[i].tag = otfcc_get32u(file);
- font->packets[count].pieces[i].checkSum = otfcc_get32u(file);
- font->packets[count].pieces[i].offset = otfcc_get32u(file);
- font->packets[count].pieces[i].length = otfcc_get32u(file);
- NEW(font->packets[count].pieces[i].data, font->packets[count].pieces[i].length);
- }
-
- for (uint32_t i = 0; i < font->packets[0].numTables; i++) {
- (void)fseek(file, font->packets[count].pieces[i].offset, SEEK_SET);
- (void)fread(font->packets[count].pieces[i].data, font->packets[count].pieces[i].length,
- 1, file);
- }
- }
-}
-
-otfcc_SplineFontContainer *otfcc_readSFNT(FILE *file) {
- if (!file) return NULL;
- otfcc_SplineFontContainer *font;
- NEW(font);
-
- font->type = otfcc_get32u(file);
-
- switch (font->type) {
- case OTFCC_CHR('O','T','T','O'):
- case 0x00010000:
- case OTFCC_CHR('t','r','u','e'):
- case OTFCC_CHR('t','y','p','1'):
- font->count = 1;
- NEW(font->offsets, font->count);
- NEW(font->packets, font->count);
- font->offsets[0] = 0;
- otfcc_read_packets(font, file);
- break;
-
- case OTFCC_CHR('t','t','c','f'):
- (void)otfcc_get32u(file);
- font->count = otfcc_get32u(file);
- NEW(font->offsets, font->count);
- NEW(font->packets, font->count);
-
- for (uint32_t i = 0; i < font->count; i++) {
- font->offsets[i] = otfcc_get32u(file);
- }
-
- otfcc_read_packets(font, file);
- break;
-
- default:
- font->count = 0;
- font->offsets = NULL;
- font->packets = NULL;
- break;
- }
-
- fclose(file);
-
- return font;
-}
-
-void otfcc_deleteSFNT(otfcc_SplineFontContainer *font) {
- if (!font) return;
- if (font->count > 0) {
- for (uint32_t count = 0; count < font->count; count++) {
- for (int i = 0; i < font->packets[count].numTables; i++) {
- FREE(font->packets[count].pieces[i].data);
- }
- FREE(font->packets[count].pieces);
- }
- FREE(font->packets);
- }
- FREE(font->offsets);
- FREE(font);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/json-reader/json-reader.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/json-reader/json-reader.c
deleted file mode 100644
index 6561cf0d7bb..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/json-reader/json-reader.c
+++ /dev/null
@@ -1,181 +0,0 @@
-#include "support/util.h"
-#include "otfcc/font.h"
-#include "table/all.h"
-
-static otfcc_font_subtype otfcc_decideFontSubtypeFromJson(const json_value *root) {
- if (json_obj_get_type(root, "CFF_", json_object) != NULL) {
- return FONTTYPE_CFF;
- } else {
- return FONTTYPE_TTF;
- }
-}
-
-// The default glyph_order object is completed using a two-step construction
-enum { ORD_GLYPHORDER = 1, ORD_NOTDEF = 2, ORD_CMAP = 3, ORD_GLYF = 4 };
-
-// Register a name->(orderType, orderEntry) map.
-static void setOrderByName(otfcc_GlyphOrder *go, sds name, uint8_t orderType, uint32_t orderEntry) {
- otfcc_GlyphOrderEntry *s = NULL;
- HASH_FIND(hhName, go->byName, name, sdslen(name), s);
- if (!s) {
- NEW(s);
- s->gid = -1;
- s->name = name;
- s->orderType = orderType;
- s->orderEntry = orderEntry;
- HASH_ADD(hhName, go->byName, name[0], sdslen(s->name), s);
- } else if (s->orderType > orderType) {
- s->orderType = orderType;
- s->orderEntry = orderEntry;
- }
-}
-
-static int _byOrder(otfcc_GlyphOrderEntry *a, otfcc_GlyphOrderEntry *b) {
- if (a->orderType < b->orderType) return (-1);
- if (a->orderType > b->orderType) return (1);
- if (a->orderEntry < b->orderEntry) return (-1);
- if (a->orderEntry > b->orderEntry) return (1);
- return 0;
-}
-
-// Complete ClyphOrder
-static void orderGlyphs(otfcc_GlyphOrder *go) {
- HASH_SRT(hhName, go->byName, _byOrder);
- otfcc_GlyphOrderEntry *current, *temp;
- glyphid_t gid = 0;
- HASH_ITER(hhName, go->byName, current, temp) {
- current->gid = gid;
- HASH_ADD(hhID, go->byGID, gid, sizeof(glyphid_t), current);
- gid += 1;
- }
-}
-
-static void escalateGlyphOrderByName(otfcc_GlyphOrder *go, sds name, uint8_t orderType,
- uint32_t orderEntry) {
- otfcc_GlyphOrderEntry *s = NULL;
- HASH_FIND(hhName, go->byName, name, sdslen(name), s);
- if (s && s->orderType > orderType) {
- s->orderType = orderType;
- s->orderEntry = orderEntry;
- }
-}
-
-static void placeOrderEntriesFromGlyf(json_value *table, otfcc_GlyphOrder *go) {
- for (uint32_t j = 0; j < table->u.object.length; j++) {
- sds gname =
- sdsnewlen(table->u.object.values[j].name, table->u.object.values[j].name_length);
- if (strcmp(gname, ".notdef") == 0) {
- setOrderByName(go, gname, ORD_NOTDEF, 0);
- } else if (strcmp(gname, ".null") == 0) {
- setOrderByName(go, gname, ORD_NOTDEF, 1);
- } else {
- setOrderByName(go, gname, ORD_GLYF, j);
- }
- }
-}
-static void placeOrderEntriesFromCmap(json_value *table, otfcc_GlyphOrder *go) {
- for (uint32_t j = 0; j < table->u.object.length; j++) {
- sds unicodeStr =
- sdsnewlen(table->u.object.values[j].name, table->u.object.values[j].name_length);
- json_value *item = table->u.object.values[j].value;
- int32_t unicode;
- if (sdslen(unicodeStr) > 2 && unicodeStr[0] == 'U' && unicodeStr[1] == '+') {
- unicode = strtol(unicodeStr + 2, NULL, 16);
- } else {
- unicode = atoi(unicodeStr);
- }
- sdsfree(unicodeStr);
- if (item->type == json_string && unicode > 0 &&
- unicode <= 0x10FFFF) { // a valid unicode codepoint
- sds gname = sdsnewlen(item->u.string.ptr, item->u.string.length);
- escalateGlyphOrderByName(go, gname, ORD_CMAP, unicode);
- sdsfree(gname);
- }
- }
-}
-static void placeOrderEntriesFromSubtable(json_value *table, otfcc_GlyphOrder *go, bool zeroOnly) {
- uint32_t uplimit = table->u.array.length;
- if (uplimit >= 1 && zeroOnly) { uplimit = 1; }
- for (uint32_t j = 0; j < uplimit; j++) {
- json_value *item = table->u.array.values[j];
- if (item->type == json_string) {
- sds gname = sdsnewlen(item->u.string.ptr, item->u.string.length);
- escalateGlyphOrderByName(go, gname, ORD_GLYPHORDER, j);
- sdsfree(gname);
- }
- }
-}
-
-static otfcc_GlyphOrder *parseGlyphOrder(const json_value *root, const otfcc_Options *options) {
- otfcc_GlyphOrder *go = GlyphOrder.create();
- if (root->type != json_object) return go;
- json_value *table;
-
- if ((table = json_obj_get_type(root, "glyf", json_object))) {
- placeOrderEntriesFromGlyf(table, go);
- if ((table = json_obj_get_type(root, "cmap", json_object))) {
- placeOrderEntriesFromCmap(table, go);
- }
- if ((table = json_obj_get_type(root, "glyph_order", json_array))) {
- bool ignoreGlyphOrder = options->ignore_glyph_order;
- if (ignoreGlyphOrder && !!json_obj_get_type(root, "SVG_", json_array)) {
- logNotice("OpenType SVG table detected. Glyph order is preserved.");
- ignoreGlyphOrder = false;
- }
- placeOrderEntriesFromSubtable(table, go, ignoreGlyphOrder);
- }
- }
- orderGlyphs(go);
- return go;
-}
-
-static otfcc_Font *readJson(void *_root, uint32_t index, const otfcc_Options *options) {
- const json_value *root = (json_value *)_root;
- otfcc_Font *font = otfcc_iFont.create();
- if (!font) return NULL;
- font->subtype = otfcc_decideFontSubtypeFromJson(root);
- font->glyph_order = parseGlyphOrder(root, options);
- font->glyf = otfcc_parseGlyf(root, font->glyph_order, options);
- font->CFF_ = otfcc_parseCFF(root, options);
- font->head = otfcc_parseHead(root, options);
- font->hhea = otfcc_parseHhea(root, options);
- font->OS_2 = otfcc_parseOS_2(root, options);
- font->maxp = otfcc_parseMaxp(root, options);
- font->post = otfcc_parsePost(root, options);
- font->name = otfcc_parseName(root, options);
- font->meta = otfcc_parseMeta(root, options);
- font->cmap = otfcc_parseCmap(root, options);
- if (!options->ignore_hints) {
- font->fpgm = otfcc_parseFpgmPrep(root, options, "fpgm");
- font->prep = otfcc_parseFpgmPrep(root, options, "prep");
- font->cvt_ = otfcc_parseCvt(root, options, "cvt_");
- font->gasp = otfcc_parseGasp(root, options);
- }
- font->VDMX = otfcc_parseVDMX(root, options);
- font->vhea = otfcc_parseVhea(root, options);
- if (font->glyf) {
- font->GSUB = otfcc_parseOtl(root, options, "GSUB");
- font->GPOS = otfcc_parseOtl(root, options, "GPOS");
- font->GDEF = otfcc_parseGDEF(root, options);
- }
- font->BASE = otfcc_parseBASE(root, options);
- font->CPAL = otfcc_parseCPAL(root, options);
- font->COLR = otfcc_parseCOLR(root, options);
- font->SVG_ = otfcc_parseSVG(root, options);
-
- font->TSI_01 = otfcc_parseTSI(root, options, "TSI_01");
- font->TSI_23 = otfcc_parseTSI(root, options, "TSI_23");
- font->TSI5 = otfcc_parseTSI5(root, options);
-
- return font;
-}
-static INLINE void freeReader(otfcc_IFontBuilder *self) {
- free(self);
-}
-otfcc_IFontBuilder *otfcc_newJsonReader() {
- otfcc_IFontBuilder *reader;
- NEW(reader);
- reader->read = readJson;
- reader->free = freeReader;
- return reader;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/json-writer/json-writer.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/json-writer/json-writer.c
deleted file mode 100644
index cec3af660b5..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/json-writer/json-writer.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "support/util.h"
-#include "otfcc/font.h"
-#include "table/all.h"
-
-static void *serializeToJson(otfcc_Font *font, const otfcc_Options *options) {
- json_value *root = json_object_new(48);
- if (!root) return NULL;
- otfcc_dumpFvar(font->fvar, root, options);
- otfcc_dumpHead(font->head, root, options);
- otfcc_dumpHhea(font->hhea, root, options);
- otfcc_dumpMaxp(font->maxp, root, options);
- otfcc_dumpVhea(font->vhea, root, options);
- otfcc_dumpPost(font->post, root, options);
- otfcc_dumpOS_2(font->OS_2, root, options);
- otfcc_dumpName(font->name, root, options);
- otfcc_dumpMeta(font->meta, root, options);
- otfcc_dumpCmap(font->cmap, root, options);
- otfcc_dumpCFF(font->CFF_, root, options);
-
- GlyfIOContext ctx = {.locaIsLong = font->head->indexToLocFormat,
- .numGlyphs = font->maxp->numGlyphs,
- .nPhantomPoints = 4,
- .hasVerticalMetrics = !!(font->vhea),
- .exportFDSelect = font->CFF_ && font->CFF_->isCID,
- .fvar = font->fvar};
- otfcc_dumpGlyf(font->glyf, root, options, &ctx);
- if (!options->ignore_hints) {
- table_dumpTableFpgmPrep(font->fpgm, root, options, "fpgm");
- table_dumpTableFpgmPrep(font->prep, root, options, "prep");
- otfcc_dumpCvt(font->cvt_, root, options, "cvt_");
- otfcc_dumpGasp(font->gasp, root, options);
- }
- otfcc_dumpVDMX(font->VDMX, root, options);
- otfcc_dumpOtl(font->GSUB, root, options, "GSUB");
- otfcc_dumpOtl(font->GPOS, root, options, "GPOS");
- otfcc_dumpGDEF(font->GDEF, root, options);
- otfcc_dumpBASE(font->BASE, root, options);
-
- otfcc_dumpCPAL(font->CPAL, root, options);
- otfcc_dumpCOLR(font->COLR, root, options);
- otfcc_dumpSVG(font->SVG_, root, options);
- otfcc_dumpTSI(font->TSI_01, root, options, "TSI_01");
- otfcc_dumpTSI(font->TSI_23, root, options, "TSI_23");
- otfcc_dumpTSI5(font->TSI5, root, options);
- return root;
-}
-static void freeJsonWriter(otfcc_IFontSerializer *self) {
- free(self);
-}
-otfcc_IFontSerializer *otfcc_newJsonWriter() {
- otfcc_IFontSerializer *writer;
- NEW(writer);
- writer->serialize = serializeToJson;
- writer->free = freeJsonWriter;
- return writer;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.c
deleted file mode 100644
index 027a25e5ac2..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#include "cff-charset.h"
-
-void cff_extract_Charset(uint8_t *data, int32_t offset, uint16_t nchars, cff_Charset *charsets) {
- uint32_t i;
- if (offset == cff_CHARSET_ISOADOBE)
- charsets->t = cff_CHARSET_ISOADOBE;
- else if (offset == cff_CHARSET_EXPERT)
- charsets->t = cff_CHARSET_EXPERT;
- else if (offset == cff_CHARSET_EXPERTSUBSET)
- charsets->t = cff_CHARSET_EXPERTSUBSET;
- else {
- // NOTE: gid 1 will always be named as .notdef
- switch (data[offset]) {
- case 0:
- charsets->t = cff_CHARSET_FORMAT0;
- {
- charsets->s = nchars - 1;
- NEW(charsets->f0.glyph, nchars - 1);
-
- for (i = 0; i < charsets->s; i++)
- charsets->f0.glyph[i] = gu2(data, offset + 1 + i * 2);
- }
- break;
- case 1:
- charsets->t = cff_CHARSET_FORMAT1;
- {
- uint32_t size;
- uint32_t glyphsEncodedSofar = 1;
- for (i = 0; glyphsEncodedSofar < nchars; i++) {
- glyphsEncodedSofar += 1 + gu1(data, offset + 3 + i * 3);
- }
-
- size = i;
- charsets->s = size;
- NEW(charsets->f1.range1, i + 1);
- for (i = 0; i < size; i++) {
- charsets->f1.range1[i].first = gu2(data, offset + 1 + i * 3);
- charsets->f1.range1[i].nleft = gu1(data, offset + 3 + i * 3);
- }
- }
- break;
- case 2:
- charsets->t = cff_CHARSET_FORMAT2;
- {
- uint32_t size;
- uint32_t glyphsEncodedSofar = 1;
- for (i = 0; glyphsEncodedSofar < nchars; i++) {
- glyphsEncodedSofar += 1 + gu2(data, offset + 3 + i * 4);
- }
-
- size = i;
- charsets->s = size;
- NEW(charsets->f2.range2, i + 1);
-
- for (i = 0; i < size; i++) {
- charsets->f2.range2[i].first = gu2(data, offset + 1 + i * 4);
- charsets->f2.range2[i].nleft = gu2(data, offset + 3 + i * 4);
- }
- }
- break;
- }
- }
-}
-
-caryll_Buffer *cff_build_Charset(cff_Charset cset) {
- switch (cset.t) {
- case cff_CHARSET_ISOADOBE:
- case cff_CHARSET_EXPERT:
- case cff_CHARSET_EXPERTSUBSET: {
- return bufnew();
- }
- case cff_CHARSET_FORMAT0: {
- caryll_Buffer *blob = bufnew();
- blob->size = 1 + cset.s * 2;
- NEW(blob->data, blob->size);
- blob->data[0] = 0;
- for (uint32_t i = 0; i < cset.s; i++)
- blob->data[1 + 2 * i] = cset.f0.glyph[i] / 256, blob->data[2 + 2 * i] = cset.f0.glyph[i] % 256;
- blob->cursor = blob->size;
- return blob;
- }
- case cff_CHARSET_FORMAT1: {
- caryll_Buffer *blob = bufnew();
- blob->size = 1 + cset.s * 3;
- NEW(blob->data, blob->size);
- blob->data[0] = 1;
- for (uint32_t i = 0; i < cset.s; i++)
- blob->data[1 + 3 * i] = cset.f1.range1[i].first / 256,
- blob->data[2 + 3 * i] = cset.f1.range1[i].first % 256,
- blob->data[3 + 3 * i] = cset.f1.range1[i].nleft;
- return blob;
- }
- case cff_CHARSET_FORMAT2: {
- caryll_Buffer *blob = bufnew();
- blob->size = 1 + cset.s * 4;
- NEW(blob->data, blob->size);
- blob->data[0] = 2;
- for (uint32_t i = 0; i < cset.s; i++)
- blob->data[1 + 4 * i] = cset.f2.range2[i].first / 256,
- blob->data[2 + 4 * i] = cset.f2.range2[i].first % 256,
- blob->data[3 + 4 * i] = cset.f2.range2[i].nleft / 256,
- blob->data[4 + 4 * i] = cset.f2.range2[i].nleft % 256;
- blob->cursor = blob->size;
- return blob;
- }
- }
- return NULL;
-}
-
-void cff_close_Charset(cff_Charset cset) {
- switch (cset.t) {
- case cff_CHARSET_EXPERT:
- case cff_CHARSET_EXPERTSUBSET:
- case cff_CHARSET_ISOADOBE:
- break;
- case cff_CHARSET_FORMAT0:
- if (cset.f0.glyph != NULL) FREE(cset.f0.glyph);
- break;
- case cff_CHARSET_FORMAT1:
- if (cset.f1.range1 != NULL) FREE(cset.f1.range1);
- break;
- case cff_CHARSET_FORMAT2:
- if (cset.f2.range2 != NULL) FREE(cset.f2.range2);
- break;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.h
deleted file mode 100644
index b0a422251c7..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-charset.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef CARYLL_cff_CHARSET_H
-#define CARYLL_cff_CHARSET_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "support/util.h"
-#include "cff-util.h"
-#include "cff-value.h"
-
-enum {
- cff_CHARSET_ISOADOBE = 0,
- cff_CHARSET_UNSPECED = 0,
- cff_CHARSET_EXPERT = 1,
- cff_CHARSET_EXPERTSUBSET = 2,
- cff_CHARSET_FORMAT0 = 3,
- cff_CHARSET_FORMAT1 = 4,
- cff_CHARSET_FORMAT2 = 5,
-};
-
-// CFF Charset Structures
-typedef struct {
- uint8_t format;
- uint16_t *glyph;
-} cff_CharsetFormat0;
-
-typedef struct {
- uint16_t first;
- uint8_t nleft;
-} cff_CharsetRangeFormat1;
-
-typedef struct {
- uint8_t format;
- cff_CharsetRangeFormat1 *range1;
-} cff_CharsetFormat1;
-
-typedef struct {
- uint16_t first;
- uint16_t nleft;
-} cff_CharsetRangeFormat2;
-
-typedef struct {
- uint8_t format;
- cff_CharsetRangeFormat2 *range2;
-} cff_CharsetFormat2;
-
-typedef struct {
- uint32_t t;
- uint32_t s; // size
- union {
- cff_CharsetFormat0 f0;
- cff_CharsetFormat1 f1;
- cff_CharsetFormat2 f2;
- };
-} cff_Charset;
-
-void cff_close_Charset(cff_Charset cset);
-void cff_extract_Charset(uint8_t *data, int32_t offset, uint16_t nchars, cff_Charset *charsets);
-caryll_Buffer *cff_build_Charset(cff_Charset cset);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-codecs.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-codecs.c
deleted file mode 100644
index 361f8497f34..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-codecs.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- Codec of CFF file format and Type2 CharString.
-*/
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libcff.h"
-
-/*
- Number in Type2
- 1 32 -246 [-107, 107] b0 - 139
- 2 247-250 [108, 1131] (b0 - 247) * 256 + b1 + 108
- 2 251-254 [-1132, -108] -(b0 - 251) * 256 - b1 - 108
- 3 28 (int16_t) [-32768, 32767] b1 << 8 | b2
- 5 29 (int32_t) [-(2^31), (2^32 - 1)] b1 << 24 | b2 << 16 | b3 << 8 | b4
- * 30 (double)
-*/
-
-caryll_Buffer *cff_encodeCffOperator(int32_t val) {
- if (val > 256) {
- return bufninit(2, val / 256, val % 256);
- } else {
- return bufninit(1, val);
- }
-}
-
-caryll_Buffer *cff_encodeCffInteger(int32_t val) {
- if (val >= -107 && val <= 107) {
- return bufninit(1, val + 139);
- } else if (val >= 108 && val <= 1131) {
- val -= 108;
- return bufninit(2, (val >> 8) + 247, val & 0xff);
- } else if (val >= -1131 && val <= -108) {
- val = -108 - val;
- return bufninit(2, (val >> 8) + 251, val & 0xff);
- } else if (val >= -32768 && val < 32768) {
- return bufninit(3, 28, val >> 8, val & 0xff);
- } else {
- /* In dict data we have 4 byte ints, in type2 strings we don't */
- return bufninit(5, 29, (val >> 24) & 0xff, (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff);
- }
-}
-
-// -2.25 -> 1e e2 a2 5f
-// 0.140541E-3 -> 1e 0a 14 05 41 c3 ff
-caryll_Buffer *cff_encodeCffFloat(double val) {
- caryll_Buffer *blob = bufnew();
- uint32_t i, j = 0;
- uint8_t temp[32] = {0};
-
- if (val == 0.0) {
- blob->size = 2;
- NEW(blob->data, blob->size);
- blob->data[0] = 30;
- blob->data[1] = 0x0f;
- } else {
- uint32_t niblen = 0;
- uint8_t *array;
- sprintf((char *)temp, "%.13g", val);
-
- for (i = 0; i < strlen((char *)temp);) {
- if (temp[i] == '.')
- niblen++, i++;
- else if (temp[i] >= '0' && temp[i] <= '9')
- niblen++, i++;
- else if (temp[i] == 'e' && temp[i + 1] == '-')
- niblen++, i += 2;
- else if (temp[i] == 'e' && temp[i + 1] == '+')
- niblen++, i += 2;
- else if (temp[i] == '-')
- niblen++, i++;
- }
-
- blob->size = 2 + niblen / 2;
- NEW(blob->data, blob->size);
- blob->data[0] = 30;
-
- if (niblen % 2 != 0) {
- NEW(array, (niblen + 1));
- array[niblen] = 0x0f;
- } else {
- NEW(array, (niblen + 2));
- array[niblen + 1] = 0x0f;
- array[niblen] = 0x0f;
- }
-
- for (i = 0; i < strlen((char *)temp);) {
- if (temp[i] == '.')
- array[j++] = 0x0a, i++;
- else if (temp[i] >= '0' && temp[i] <= '9')
- array[j++] = temp[i] - '0', i++;
- else if (temp[i] == 'e' && temp[i + 1] == '-')
- array[j++] = 0x0c, i += 2;
- else if (temp[i] == 'e' && temp[i + 1] == '+')
- array[j++] = 0x0b, i += 2;
- else if (temp[i] == '-')
- array[j++] = 0x0e, i++;
- }
-
- for (i = 1; i < blob->size; i++) {
- blob->data[i] = array[(i - 1) * 2] * 16 + array[(i - 1) * 2 + 1];
- }
-
- FREE(array);
- }
-
- return blob;
-}
-
-uint32_t cff_decodeCS2Token(const uint8_t *start, cff_Value *val) {
- uint32_t advance = 0;
-
- if (*start <= 27) {
- val->t = CS2_OPERATOR;
-
- if (*start <= 11) {
- val->i = *start;
- advance = 1;
- } else if (*start == 12) {
- val->i = *start << 8 | *(start + 1);
- advance = 2;
- } else if (*start >= 13 && *start <= 18) {
- val->i = *start;
- advance = 1;
- } else if (*start >= 19 && *start <= 20) {
- val->i = *start;
- advance = 1;
- } else if (*start >= 21 && *start <= 27) {
- val->i = *start;
- advance = 1;
- }
- } else if (*start == 28) {
- val->t = CS2_OPERAND;
- val->i = (int16_t)(*(start + 1) << 8 | *(start + 2));
- advance = 3;
- } else if (*start >= 29 && *start <= 31) {
- val->t = CS2_OPERATOR;
- val->i = *start;
- advance = 1;
- } else if (*start >= 32 && *start <= 254) {
- val->t = CS2_OPERAND;
- if (*start >= 32 && *start <= 246) {
- val->i = (int32_t)(*start - 139);
- advance = 1;
- } else if (*start >= 247 && *start <= 250) {
- val->i = (int32_t)((*start - 247) * 256 + *(start + 1) + 108);
- advance = 2;
- } else if (*start >= 251 && *start <= 254) {
- val->i = (int32_t)(-((*start - 251) * 256) - *(start + 1) - 108);
- advance = 2;
- }
- } else if (*start == 255) {
- val->t = CS2_FRACTION;
- int16_t integerPart = start[1] << 8 | start[2];
- uint16_t fractionPart = start[3] << 8 | start[4];
- val->d = (double)(integerPart + fractionPart / 65536.0);
- advance = 5;
- }
-
- if (val->t == CS2_OPERAND) val->d = (double)val->i, val->t = CS2_FRACTION;
-
- return advance;
-}
-
-// decode integer
-static uint32_t cff_dec_i(const uint8_t *start, cff_Value *val) {
- uint8_t b0 = *start, b1, b2, b3, b4;
- uint32_t len = 0;
-
- if (b0 >= 32 && b0 <= 246) {
- val->i = b0 - 139;
- len = 1;
- } else if (b0 >= 247 && b0 <= 250) {
- b1 = *(start + 1);
- val->i = (b0 - 247) * 256 + b1 + 108;
- len = 2;
- } else if (b0 >= 251 && b0 <= 254) {
- b1 = *(start + 1);
- val->i = -(b0 - 251) * 256 - b1 - 108;
- len = 2;
- } else if (b0 == 28) {
- b1 = *(start + 1);
- b2 = *(start + 2);
- val->i = (b1 << 8) | b2;
- len = 3;
- } else if (b0 == 29) {
- b1 = *(start + 1);
- b2 = *(start + 2);
- b3 = *(start + 3);
- b4 = *(start + 4);
- val->i = b1 << 24 | b2 << 16 | b3 << 8 | b4;
- len = 5;
- }
-
- val->t = cff_INTEGER;
- return len;
-}
-
-static const int nibble_attr[15] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1};
-static const char *nibble_symb[15] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", "", "-"};
-
-// decode double
-static uint32_t cff_dec_r(const uint8_t *start, cff_Value *val) {
- uint8_t restr[72] = {0};
- size_t str_len = 0;
- uint32_t len;
- uint8_t a, b;
-
- const uint8_t *nibst = start + 1;
-
- while (1) {
- a = *nibst / 16;
- b = *nibst % 16;
-
- if (a != 15)
- str_len += nibble_attr[a];
- else
- break;
-
- if (b != 15)
- str_len += nibble_attr[b];
- else
- break;
-
- nibst++;
- }
-
- len = (uint32_t)(nibst - start + 1);
- nibst = start + 1;
-
- while (1) {
- a = *nibst / 16;
- b = *nibst % 16;
-
- if (a != 0x0f)
- strcat((char *)restr, nibble_symb[a]);
- else
- break;
-
- if (b != 0x0f)
- strcat((char *)restr, nibble_symb[b]);
- else
- break;
-
- nibst++;
- }
-
- val->d = atof((char *)restr);
- val->t = cff_DOUBLE;
-
- return len;
-}
-
-// decode operator
-static uint32_t cff_dec_o(const uint8_t *start, cff_Value *val) {
- uint8_t b0 = *start, b1;
- uint32_t len = 0;
-
- if (b0 <= 21) {
- if (b0 != 12) {
- val->i = b0;
- len = 1;
- } else {
- b1 = *(start + 1);
- val->i = b0 * 256 + b1;
- len = 2;
- }
- }
-
- val->t = cff_OPERATOR;
-
- return len;
-}
-
-// error in parsing, return a integer
-static uint32_t cff_dec_e(const uint8_t *start, cff_Value *val) {
- printf("Undefined Byte in CFF: %d.\n", *start);
- val->i = *start;
- val->t = cff_INTEGER;
- return 1;
-}
-
-static uint32_t (*_de_t2[256])(const uint8_t *, cff_Value *) = {
- cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o,
- cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o, cff_dec_o,
- cff_dec_o, cff_dec_o, cff_dec_e, cff_dec_e, cff_dec_e, cff_dec_e, cff_dec_e, cff_dec_e, cff_dec_i, cff_dec_i,
- cff_dec_r, cff_dec_e, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i,
- cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_i, cff_dec_e};
-
-uint32_t cff_decodeCffToken(const uint8_t *start, cff_Value *val) {
- return _de_t2[*start](start, val);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.c
deleted file mode 100644
index 151d5d4e14d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.c
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "libcff.h"
-
-static INLINE void disposeDict(cff_Dict *dict) {
- for (uint32_t j = 0; j < dict->count; j++) {
- FREE(dict->ents[j].vals);
- }
- FREE(dict->ents);
-}
-
-caryll_standardRefTypeFn(cff_Dict, disposeDict);
-
-static cff_Dict *parseDict(const uint8_t *data, const uint32_t len) {
- cff_Dict *dict;
- NEW(dict);
- uint32_t index = 0, advance;
- cff_Value val, stack[48];
- const uint8_t *temp = data;
-
- while (temp < data + len) {
- advance = cff_decodeCffToken(temp, &val);
-
- switch (val.t) {
- case cff_OPERATOR:
- RESIZE(dict->ents, dict->count + 1);
- dict->ents[dict->count].op = val.i;
- dict->ents[dict->count].cnt = index;
- NEW(dict->ents[dict->count].vals, index);
- memcpy(dict->ents[dict->count].vals, stack, sizeof(cff_Value) * index);
- dict->count++;
- index = 0;
- break;
- case cff_INTEGER:
- case cff_DOUBLE:
- stack[index++] = val;
- break;
- }
-
- temp += advance;
- }
-
- return dict;
-}
-
-static void parseToCallback(const uint8_t *data, const uint32_t len, void *context,
- void (*callback)(uint32_t op, uint8_t top, cff_Value *stack, void *context)) {
- uint8_t index = 0;
- uint32_t advance;
- cff_Value val, stack[256];
- const uint8_t *temp = data;
-
- while (temp < data + len) {
- advance = cff_decodeCffToken(temp, &val);
-
- switch (val.t) {
- case cff_OPERATOR:
- callback(val.i, index, stack, context);
- index = 0;
- break;
-
- case cff_INTEGER:
- case cff_DOUBLE:
- stack[index++] = val;
- break;
- }
-
- temp += advance;
- }
-}
-
-typedef struct {
- bool found;
- cff_Value res;
- uint32_t op;
- uint32_t idx;
-} cff_get_key_context;
-
-static void callback_get_key(uint32_t op, uint8_t top, cff_Value *stack, void *_context) {
- cff_get_key_context *context = (cff_get_key_context *)_context;
- if (op == context->op && context->idx <= top) {
- context->found = true;
- context->res = stack[context->idx];
- }
-}
-
-static cff_Value parseDictKey(const uint8_t *data, const uint32_t len, const uint32_t op, const uint32_t idx) {
- cff_get_key_context context;
- context.found = false;
- context.idx = idx;
- context.op = op;
- context.res.t = 0;
- context.res.i = -1;
-
- parseToCallback(data, len, &context, callback_get_key);
- return context.res;
-}
-
-static caryll_Buffer *buildDict(const cff_Dict *dict) {
- caryll_Buffer *blob = bufnew();
- for (uint32_t i = 0; i < dict->count; i++) {
- for (uint32_t j = 0; j < dict->ents[i].cnt; j++) {
- caryll_Buffer *blob_val;
- if (dict->ents[i].vals[j].t == cff_INTEGER) {
- blob_val = cff_encodeCffInteger(dict->ents[i].vals[j].i);
- } else if (dict->ents[i].vals[j].t == cff_DOUBLE) {
- blob_val = cff_encodeCffFloat(dict->ents[i].vals[j].d);
- } else {
- blob_val = cff_encodeCffInteger(0);
- }
- bufwrite_bufdel(blob, blob_val);
- }
- bufwrite_bufdel(blob, cff_encodeCffOperator(dict->ents[i].op));
- }
- return blob;
-}
-
-caryll_ElementInterfaceOf(cff_Dict) cff_iDict = {
- caryll_standardRefTypeMethods(cff_Dict),
- .parse = parseDict,
- .parseToCallback = parseToCallback,
- .parseDictKey = parseDictKey,
- .build = buildDict,
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.h
deleted file mode 100644
index c49ff8e0a32..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-dict.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef CARYLL_cff_DICT_H
-#define CARYLL_cff_DICT_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "support/util.h"
-#include "cff-value.h"
-
-typedef struct {
- uint32_t op;
- uint32_t cnt;
- cff_Value *vals;
-} cff_DictEntry;
-
-typedef struct {
- uint32_t count;
- cff_DictEntry *ents;
-} cff_Dict;
-
-extern caryll_ElementInterfaceOf(cff_Dict) {
- caryll_RT(cff_Dict);
- cff_Dict *(*parse)(const uint8_t *data, const uint32_t len);
- void (*parseToCallback)(const uint8_t *data, const uint32_t len, void *context,
- void (*callback)(uint32_t op, uint8_t top, cff_Value * stack, void *context));
- cff_Value (*parseDictKey)(const uint8_t *data, const uint32_t len, const uint32_t op, const uint32_t idx);
- caryll_Buffer *(*build)(const cff_Dict *dict);
-}
-cff_iDict;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.c
deleted file mode 100644
index ea1546d38ff..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "cff-fdselect.h"
-
-void cff_close_FDSelect(cff_FDSelect fds) {
- switch (fds.t) {
- case cff_FDSELECT_FORMAT0:
- if (fds.f0.fds != NULL) FREE(fds.f0.fds);
- break;
- case cff_FDSELECT_FORMAT3:
- if (fds.f3.range3 != NULL) FREE(fds.f3.range3);
- break;
- case cff_FDSELECT_UNSPECED:
- break;
- }
-}
-
-caryll_Buffer *cff_build_FDSelect(cff_FDSelect fd) {
- switch (fd.t) {
- case cff_FDSELECT_UNSPECED: {
- return bufnew();
- }
- case cff_FDSELECT_FORMAT0: {
- caryll_Buffer *blob = bufnew();
- blob->size = 1 + fd.s;
- NEW(blob->data, blob->size);
- for (uint16_t j = 0; j < fd.s; j++) {
- blob->data[j] = fd.f0.fds[j];
- }
- return blob;
- }
- case cff_FDSELECT_FORMAT3: {
- caryll_Buffer *blob = bufnew();
- blob->size = 5 + fd.f3.nranges * 3;
- NEW(blob->data, blob->size);
- blob->data[0] = 3;
- blob->data[1] = fd.f3.nranges / 256;
- blob->data[2] = fd.f3.nranges % 256;
- for (int i = 0; i < fd.f3.nranges; i++)
- blob->data[3 + 3 * i] = fd.f3.range3[i].first / 256,
- blob->data[4 + 3 * i] = fd.f3.range3[i].first % 256,
- blob->data[5 + 3 * i] = fd.f3.range3[i].fd;
- blob->data[blob->size - 2] = fd.f3.sentinel / 256;
- blob->data[blob->size - 1] = fd.f3.sentinel % 256;
- return blob;
- }
- default: { return NULL; }
- }
-}
-
-void cff_extract_FDSelect(uint8_t *data, int32_t offset, uint16_t nchars, cff_FDSelect *fdselect) {
- switch (data[offset]) {
- case 0: {
- fdselect->t = cff_FDSELECT_FORMAT0;
- fdselect->f0.format = 0;
- fdselect->s = nchars;
- NEW(fdselect->f0.fds, nchars);
-
- for (uint32_t i = 0; i < nchars; i++) {
- fdselect->f0.fds[i] = gu1(data, offset + 1 + i);
- }
- break;
- }
- case 3: {
- fdselect->t = cff_FDSELECT_FORMAT3;
- fdselect->f3.format = 3;
- fdselect->f3.nranges = gu2(data, offset + 1);
- NEW(fdselect->f3.range3, fdselect->f3.nranges);
-
- for (uint32_t i = 0; i < fdselect->f3.nranges; i++) {
- fdselect->f3.range3[i].first = gu2(data, offset + 3 + i * 3);
- fdselect->f3.range3[i].fd = gu1(data, offset + 5 + i * 3);
- }
-
- fdselect->f3.sentinel = gu2(data, offset + (fdselect->f3.nranges + 1) * 3);
- break;
- }
- default: {
- fdselect->t = cff_FDSELECT_UNSPECED;
- break;
- }
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.h
deleted file mode 100644
index f67cbd46e47..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-fdselect.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef CARYLL_cff_FDSELECT_H
-#define CARYLL_cff_FDSELECT_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "support/util.h"
-#include "cff-util.h"
-#include "cff-value.h"
-
-enum {
- cff_FDSELECT_FORMAT0,
- cff_FDSELECT_FORMAT3,
- cff_FDSELECT_UNSPECED,
-};
-
-typedef struct {
- uint8_t format;
- uint8_t *fds;
-} cff_FDSelectFormat0;
-
-typedef struct {
- uint16_t first;
- uint8_t fd;
-} cff_FDSelectRangeFormat3;
-
-typedef struct {
- uint8_t format;
- uint16_t nranges;
- cff_FDSelectRangeFormat3 *range3;
- uint16_t sentinel;
-} cff_FDSelectFormat3;
-
-typedef struct {
- uint32_t t;
- uint32_t s;
- union {
- cff_FDSelectFormat0 f0;
- cff_FDSelectFormat3 f3;
- };
-} cff_FDSelect;
-
-void cff_close_FDSelect(cff_FDSelect fds);
-void cff_extract_FDSelect(uint8_t *data, int32_t offset, uint16_t nchars, cff_FDSelect *fdselect);
-caryll_Buffer *cff_build_FDSelect(cff_FDSelect fd);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.c
deleted file mode 100644
index 7a42b16ad94..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "cff-index.h"
-// INDEX util functions
-
-static INLINE void disposeCffIndex(cff_Index *in) {
- if (in->offset) FREE(in->offset);
- if (in->data) FREE(in->data);
-}
-
-caryll_standardRefTypeFn(cff_Index, disposeCffIndex);
-
-static uint32_t getIndexLength(const cff_Index *i) {
- if (i->count != 0)
- return 3 + (i->offset[i->count] - 1) + ((i->count + 1) * i->offSize);
- else
- return 3;
-}
-static void emptyIndex(cff_Index *i) {
- cff_iIndex.dispose(i);
- memset(i, 0, sizeof(*i));
-}
-
-static void extractIndex(uint8_t *data, uint32_t pos, cff_Index *in) {
- in->count = gu2(data, pos);
- in->offSize = gu1(data, pos + 2);
-
- if (in->count > 0) {
- NEW(in->offset, in->count + 1);
-
- for (arity_t i = 0; i <= in->count; i++) {
- switch (in->offSize) {
- case 1:
- in->offset[i] = gu1(data, pos + 3 + (i * in->offSize));
- break;
- case 2:
- in->offset[i] = gu2(data, pos + 3 + (i * in->offSize));
- break;
- case 3:
- in->offset[i] = gu3(data, pos + 3 + (i * in->offSize));
- break;
- case 4:
- in->offset[i] = gu4(data, pos + 3 + (i * in->offSize));
- break;
- }
- }
-
- NEW(in->data, in->offset[in->count] - 1);
- memcpy(in->data, data + pos + 3 + (in->count + 1) * in->offSize, in->offset[in->count] - 1);
- } else {
- in->offset = NULL;
- in->data = NULL;
- }
-}
-
-static cff_Index *newIndexByCallback(void *context, uint32_t length, caryll_Buffer *(*fn)(void *, uint32_t)) {
- cff_Index *idx = cff_iIndex.create();
- idx->count = length;
- NEW(idx->offset, idx->count + 1);
- idx->offset[0] = 1;
- idx->data = NULL;
-
- size_t used = 0;
- size_t blank = 0;
- for (arity_t i = 0; i < length; i++) {
- caryll_Buffer *blob = fn(context, i);
- if (blank < blob->size) {
- used += blob->size;
- blank = (used >> 1) & 0xFFFFFF;
- RESIZE(idx->data, used + blank);
- } else {
- used += blob->size;
- blank -= blob->size;
- }
- idx->offset[i + 1] = (uint32_t)(blob->size + idx->offset[i]);
- memcpy(idx->data + idx->offset[i] - 1, blob->data, blob->size);
- buffree(blob);
- }
- idx->offSize = 4;
- return idx;
-}
-
-static caryll_Buffer *buildIndex(const cff_Index *index) {
- caryll_Buffer *blob = bufnew();
- if (!index->count) {
- bufwrite8(blob, 0);
- bufwrite8(blob, 0);
- bufwrite8(blob, 0);
- return blob;
- }
-
- uint32_t lastOffset = index->offset[index->count];
- uint8_t offSize = 4;
- if (lastOffset < 0x100) {
- offSize = 1;
- } else if (lastOffset < 0x10000) {
- offSize = 2;
- } else if (lastOffset < 0x1000000) {
- offSize = 3;
- } else {
- offSize = 4;
- }
-
- if (index->count != 0)
- blob->size = 3 + (index->offset[index->count] - 1) + ((index->count + 1) * offSize);
- else
- blob->size = 3;
-
- NEW(blob->data, blob->size);
- blob->data[0] = index->count / 256;
- blob->data[1] = index->count % 256;
- blob->data[2] = offSize;
-
- if (index->count > 0) {
- for (arity_t i = 0; i <= index->count; i++) {
- switch (offSize) {
- case 1:
- blob->data[3 + i] = index->offset[i];
- break;
- case 2:
- blob->data[3 + i * 2] = index->offset[i] / 256;
- blob->data[4 + i * 2] = index->offset[i] % 256;
- break;
- case 3:
- blob->data[3 + i * 3] = index->offset[i] / 65536;
- blob->data[4 + i * 3] = (index->offset[i] % 65536) / 256;
- blob->data[5 + i * 3] = (index->offset[i] % 65536) % 256;
- break;
- case 4:
- blob->data[3 + i * 4] = (index->offset[i] / 65536) / 256;
- blob->data[4 + i * 4] = (index->offset[i] / 65536) % 256;
- blob->data[5 + i * 4] = (index->offset[i] % 65536) / 256;
- blob->data[6 + i * 4] = (index->offset[i] % 65536) % 256;
- break;
- }
- }
-
- if (index->data != NULL)
- memcpy(blob->data + 3 + ((index->count + 1) * offSize), index->data, index->offset[index->count] - 1);
- }
- blob->cursor = blob->size;
- return blob;
-}
-
-caryll_ElementInterfaceOf(cff_Index) cff_iIndex = {
- caryll_standardRefTypeMethods(cff_Index), .getLength = getIndexLength, .empty = emptyIndex, .parse = extractIndex,
- .fromCallback = newIndexByCallback, .build = buildIndex,
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.h
deleted file mode 100644
index be2614158f4..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-index.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef CARYLL_cff_INDEX_H
-#define CARYLL_cff_INDEX_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "support/util.h"
-
-#include "cff-util.h"
-#include "cff-value.h"
-
-typedef enum { CFF_INDEX_16, CFF_INDEX_32 } cff_IndexCountType;
-
-typedef struct {
- cff_IndexCountType countType;
- arity_t count;
- uint8_t offSize;
- uint32_t *offset;
- uint8_t *data;
-} cff_Index;
-
-extern caryll_ElementInterfaceOf(cff_Index) {
- caryll_RT(cff_Index);
- void (*empty)(cff_Index * i);
- uint32_t (*getLength)(const cff_Index *i);
- void (*parse)(uint8_t * data, uint32_t pos, cff_Index * in);
- cff_Index *(*fromCallback)(void *context, uint32_t length, caryll_Buffer *(*fn)(void *, uint32_t));
- caryll_Buffer *(*build)(const cff_Index *index);
-}
-cff_iIndex;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-opmean.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-opmean.c
deleted file mode 100644
index 57d689a44e9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-opmean.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- operator to string.
-*/
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libcff.h"
-
-const char *op_cff_name(uint32_t op) {
- switch (op) {
- case op_version:
- return "Version";
- case op_Notice:
- return "Notice";
- case op_FullName:
- return "FullName";
- case op_FamilyName:
- return "FamilyName";
- case op_Weight:
- return "Weight";
- case op_FontBBox:
- return "FontBBox";
- case op_BlueValues:
- return "BlueValues";
- case op_OtherBlues:
- return "OtherBlues";
- case op_FamilyBlues:
- return "FamilyBlues";
- case op_FamilyOtherBlues:
- return "FamilyOtherBlues";
- case op_StdHW:
- return "StdHW";
- case op_StdVW:
- return "StdVW";
- case op_UniqueID:
- return "UniqueID";
- case op_XUID:
- return "XUID";
- case op_charset:
- return "charset";
- case op_Encoding:
- return "Encoding";
- case op_CharStrings:
- return "CharStrings";
- case op_Private:
- return "Private";
- case op_Subrs:
- return "Subrs";
- case op_defaultWidthX:
- return "defaultWidthX";
- case op_nominalWidthX:
- return "nominalWidthX";
- case op_Copyright:
- return "Copyright";
- case op_isFixedPitch:
- return "isFixedPitch";
- case op_ItalicAngle:
- return "ItalicAngle";
- case op_UnderlinePosition:
- return "UnderlinePosition";
- case op_UnderlineThickness:
- return "UnderlineThickness";
- case op_PaintType:
- return "PaintType";
- case op_CharstringType:
- return "CharstringType";
- case op_FontMatrix:
- return "FontMatrix";
- case op_StrokeWidth:
- return "StrokeWidth";
- case op_BlueScale:
- return "BlueScale";
- case op_BlueShift:
- return "BlueShift";
- case op_BlueFuzz:
- return "BlueFuzz";
- case op_StemSnapH:
- return "StemSnapH";
- case op_StemSnapV:
- return "StemSnapV";
- case op_ForceBold:
- return "ForceBold";
- case op_LanguageGroup:
- return "LanguageGroup";
- case op_ExpansionFactor:
- return "ExpansionFactor";
- case op_initialRandomSeed:
- return "initialRandomSeed";
- case op_SyntheicBase:
- return "SyntheicBase";
- case op_PostScript:
- return "PostScript";
- case op_BaseFontName:
- return "BaseFontName";
- case op_BaseFontBlend:
- return "BaseFontBlend";
- case op_ROS:
- return "ROS";
- case op_CIDFontVersion:
- return "CIDFontVersion";
- case op_CIDFontRevision:
- return "CIDFontReversion";
- case op_CIDFontType:
- return "CIDFontType";
- case op_CIDCount:
- return "CIDCount";
- case op_UIDBase:
- return "UIDBase";
- case op_FDArray:
- return "FDArray";
- case op_FDSelect:
- return "FDSelect";
- case op_FontName:
- return "FontName";
- default:
- return "Unkown";
- }
-}
-
-const char *op_cs2_name(uint32_t op) {
- switch (op) {
- case op_hstem:
- return "hstem";
- case op_vstem:
- return "vstem";
- case op_vmoveto:
- return "vmoveto";
- case op_rlineto:
- return "rlineto";
- case op_hlineto:
- return "hlineto";
- case op_vlineto:
- return "vlineto";
- case op_rrcurveto:
- return "rrcurveto";
- case op_callsubr:
- return "callsubr";
- case op_return:
- return "return";
- case op_endchar:
- return "endchar";
- case op_hstemhm:
- return "hstemhm";
- case op_hintmask:
- return "hintmask";
- case op_cntrmask:
- return "cntrmask";
- case op_rmoveto:
- return "rmoveto";
- case op_hmoveto:
- return "hmoveto";
- case op_vstemhm:
- return "vstemhm";
- case op_rcurveline:
- return "rcurveline";
- case op_rlinecurve:
- return "rlinecurve";
- case op_vvcurveto:
- return "vvcurveto";
- case op_hhcurveto:
- return "hhcurveto";
- case op_callgsubr:
- return "callgsubr";
- case op_vhcurveto:
- return "vhcurveto";
- case op_hvcurveto:
- return "hvcurveto";
- case op_and:
- return "and";
- case op_or:
- return "or";
- case op_not:
- return "not";
- case op_abs:
- return "abs";
- case op_add:
- return "add";
- case op_sub:
- return "sub";
- case op_div:
- return "div";
- case op_neg:
- return "neg";
- case op_eq:
- return "eq";
- case op_drop:
- return "drop";
- case op_put:
- return "put";
- case op_get:
- return "get";
- case op_ifelse:
- return "ifelse";
- case op_random:
- return "random";
- case op_mul:
- return "mul";
- case op_sqrt:
- return "sqrt";
- case op_dup:
- return "dup";
- case op_exch:
- return "exch";
- case op_index:
- return "index";
- case op_roll:
- return "roll";
- case op_hflex:
- return "hflex";
- case op_flex:
- return "fles";
- case op_hflex1:
- return "hflex1";
- case op_flex1:
- return "flex1";
- default:
- return "Unknown";
- }
-}
-
-uint8_t cff_getStandardArity(uint32_t op) {
- switch (op) {
- case op_rlineto:
- case op_rmoveto:
- return 2;
- case op_hlineto:
- case op_vlineto:
- return 1;
- case op_hhcurveto:
- case op_vvcurveto:
- case op_hvcurveto:
- case op_vhcurveto:
- return 4;
- case op_rrcurveto:
- return 6;
- case op_hintmask:
- case op_cntrmask:
- return 0;
- default:
- return 2;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-parser.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-parser.c
deleted file mode 100644
index 14ad9f2cecc..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-parser.c
+++ /dev/null
@@ -1,847 +0,0 @@
-/*
- Parser/Linter of CFF font, notable references:
- * Technical Note #5176: The Compact Font Format Specification
- * Technical Note #5177: The Type 2 Charstring Format
- * Adobe TinTin
-*/
-
-#include <math.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libcff.h"
-
-static void parse_encoding(cff_File *cff, int32_t offset, cff_Encoding *enc) {
- uint8_t *data = cff->raw_data;
-
- if (offset == cff_ENC_STANDARD)
- enc->t = cff_ENC_STANDARD;
- else if (offset == cff_ENC_EXPERT)
- enc->t = cff_ENC_EXPERT;
- else {
- switch (data[offset]) {
- case 0:
- enc->t = cff_ENC_FORMAT0;
- {
- enc->f0.format = 0;
- enc->f0.ncodes = data[offset + 1];
- NEW(enc->f0.code, enc->f0.ncodes);
-
- for (uint32_t i = 0; i < enc->f0.ncodes; i++)
- enc->f0.code[i] = data[offset + 2 + i];
- }
- break;
- case 1:
- enc->t = cff_ENC_FORMAT1;
- {
- enc->f1.format = 1;
- enc->f1.nranges = data[offset + 1];
- NEW(enc->f1.range1, enc->f1.nranges);
-
- for (uint32_t i = 0; i < enc->f1.nranges; i++)
- enc->f1.range1[i].first = data[offset + 2 + i * 2],
- enc->f1.range1[i].nleft = data[offset + 3 + i * 2];
- }
- break;
- default:
- enc->t = cff_ENC_FORMAT_SUPPLEMENT;
- {
- enc->ns.nsup = data[offset];
- NEW(enc->ns.supplement, enc->ns.nsup);
-
- for (uint32_t i = 0; i < enc->ns.nsup; i++)
- enc->ns.supplement[i].code = data[offset + 1 + i * 3],
- enc->ns.supplement[i].glyph = gu2(data, offset + 2 + i * 3);
- }
- break;
- }
- }
-}
-
-static void parse_cff_bytecode(cff_File *cff, const otfcc_Options *options) {
- uint32_t pos;
- int32_t offset;
-
- /* Header */
- cff->head.major = gu1(cff->raw_data, 0);
- cff->head.minor = gu1(cff->raw_data, 1);
- cff->head.hdrSize = gu1(cff->raw_data, 2);
- cff->head.offSize = gu1(cff->raw_data, 3);
-
- /* Name INDEX */
- pos = cff->head.hdrSize;
- cff_iIndex.parse(cff->raw_data, pos, &cff->name);
-
- /* Top Dict INDEX */
- pos = 4 + cff_iIndex.getLength(&cff->name);
- cff_iIndex.parse(cff->raw_data, pos, &cff->top_dict);
-
- /** LINT CFF FONTSET **/
-
- if (cff->name.count != cff->top_dict.count)
- logWarning("[libcff] Bad CFF font: (%d, name), (%d, top_dict).\n", cff->name.count,
- cff->top_dict.count);
-
- /* String INDEX */
- pos = 4 + cff_iIndex.getLength(&cff->name) + cff_iIndex.getLength(&cff->top_dict);
- cff_iIndex.parse(cff->raw_data, pos, &cff->string);
-
- /* Global Subr INDEX */
- pos = 4 + cff_iIndex.getLength(&cff->name) + cff_iIndex.getLength(&cff->top_dict) +
- cff_iIndex.getLength(&cff->string);
- cff_iIndex.parse(cff->raw_data, pos, &cff->global_subr);
-
- if (cff->top_dict.data != NULL) {
- int32_t offset;
-
- // cff->topdict.dict = calloc(1, sizeof(cff_Dict));
- // cff->topdict.dict = cff_extract_Dict(cff->top_dict.data, cff->top_dict.offset[1] -
- // cff->top_dict.offset[0]);
-
- /* CharStrings INDEX */
- offset =
- cff_iDict
- .parseDictKey(cff->top_dict.data, cff->top_dict.offset[1] - cff->top_dict.offset[0],
- op_CharStrings, 0)
- .i;
-
- if (offset != -1) {
- cff_iIndex.parse(cff->raw_data, offset, &cff->char_strings);
- cff->cnt_glyph = cff->char_strings.count;
- } else {
- cff_iIndex.empty(&cff->char_strings);
- logWarning("[libcff] Bad CFF font: no any glyph data.\n");
- }
-
- /* Encodings */
- offset =
- cff_iDict
- .parseDictKey(cff->top_dict.data, cff->top_dict.offset[1] - cff->top_dict.offset[0],
- op_Encoding, 0)
- .i;
-
- if (offset != -1) {
- parse_encoding(cff, offset, &cff->encodings);
- } else {
- cff->encodings.t = cff_ENC_UNSPECED;
- }
-
- /* Charsets */
- offset = cff_iDict
- .parseDictKey(cff->top_dict.data,
- cff->top_dict.offset[1] - cff->top_dict.offset[0], op_charset, 0)
- .i;
-
- if (offset != -1) {
- cff_extract_Charset(cff->raw_data, offset, cff->char_strings.count, &cff->charsets);
- } else {
- cff->charsets.t = cff_CHARSET_UNSPECED;
- }
-
- /* FDSelect */
- offset =
- cff_iDict
- .parseDictKey(cff->top_dict.data, cff->top_dict.offset[1] - cff->top_dict.offset[0],
- op_FDSelect, 0)
- .i;
-
- if (cff->char_strings.count && offset != -1) {
- cff_extract_FDSelect(cff->raw_data, offset, cff->char_strings.count, &cff->fdselect);
- } else {
- cff->fdselect.t = cff_FDSELECT_UNSPECED;
- }
-
- /* Font Dict INDEX */
- offset = cff_iDict
- .parseDictKey(cff->top_dict.data,
- cff->top_dict.offset[1] - cff->top_dict.offset[0], op_FDArray, 0)
- .i;
-
- if (offset != -1) {
- cff_iIndex.parse(cff->raw_data, offset, &cff->font_dict);
- } else {
- cff_iIndex.empty(&cff->font_dict);
- }
- }
-
- /* Private and Local Subr */
- {
- int32_t private_len = -1;
- int32_t private_off = -1;
-
- if (cff->top_dict.data != NULL) {
- private_len =
- cff_iDict
- .parseDictKey(cff->top_dict.data,
- cff->top_dict.offset[1] - cff->top_dict.offset[0], op_Private, 0)
- .i;
- private_off =
- cff_iDict
- .parseDictKey(cff->top_dict.data,
- cff->top_dict.offset[1] - cff->top_dict.offset[0], op_Private, 1)
- .i;
- }
-
- if (private_off != -1 && private_len != -1) {
- offset =
- cff_iDict.parseDictKey(cff->raw_data + private_off, private_len, op_Subrs, 0).i;
-
- if (offset != -1)
- cff_iIndex.parse(cff->raw_data, private_off + offset, &cff->local_subr);
- else
- cff_iIndex.empty(&cff->local_subr);
- } else {
- cff_iIndex.empty(&cff->local_subr);
- }
- }
-}
-
-cff_File *cff_openStream(uint8_t *data, uint32_t len, const otfcc_Options *options) {
- cff_File *file;
- NEW(file);
-
- NEW(file->raw_data, len);
- memcpy(file->raw_data, data, len);
- file->raw_length = len;
- file->cnt_glyph = 0;
- parse_cff_bytecode(file, options);
-
- return file;
-}
-
-void cff_close(cff_File *file) {
- if (file != NULL) {
- if (file->raw_data != NULL) FREE(file->raw_data);
-
- cff_iIndex.dispose(&file->name);
- cff_iIndex.dispose(&file->top_dict);
- cff_iIndex.dispose(&file->string);
- cff_iIndex.dispose(&file->global_subr);
- cff_iIndex.dispose(&file->char_strings);
- cff_iIndex.dispose(&file->font_dict);
- cff_iIndex.dispose(&file->local_subr);
-
- switch (file->encodings.t) {
- case cff_ENC_STANDARD:
- case cff_ENC_EXPERT:
- case cff_ENC_UNSPECED:
- break;
- case cff_ENC_FORMAT0:
- if (file->encodings.f0.code != NULL) FREE(file->encodings.f0.code);
- break;
- case cff_ENC_FORMAT1:
- if (file->encodings.f1.range1 != NULL) FREE(file->encodings.f1.range1);
- break;
- case cff_ENC_FORMAT_SUPPLEMENT:
- if (file->encodings.ns.supplement != NULL) FREE(file->encodings.ns.supplement);
- break;
- }
-
- cff_close_Charset(file->charsets);
- cff_close_FDSelect(file->fdselect);
-
- FREE(file);
- }
-}
-
-uint8_t cff_parseSubr(uint16_t idx, uint8_t *raw, cff_Index fdarray, cff_FDSelect select,
- cff_Index *subr) {
- uint8_t fd = 0;
- int32_t off_private, len_private;
- int32_t off_subr;
-
- switch (select.t) {
- case cff_FDSELECT_FORMAT0:
- fd = select.f0.fds[idx];
- break;
- case cff_FDSELECT_FORMAT3:
- for (int i = 0; i < select.f3.nranges - 1; i++)
- if (idx >= select.f3.range3[i].first && idx < select.f3.range3[i + 1].first)
- fd = select.f3.range3[i].fd;
- if (idx >= select.f3.range3[select.f3.nranges - 1].first && idx < select.f3.sentinel)
- fd = select.f3.range3[select.f3.nranges - 1].fd;
- break;
- case cff_FDSELECT_UNSPECED:
- fd = 0;
- break;
- }
-
- off_private = cff_iDict
- .parseDictKey(fdarray.data + fdarray.offset[fd] - 1,
- fdarray.offset[fd + 1] - fdarray.offset[fd], op_Private, 1)
- .i;
- len_private = cff_iDict
- .parseDictKey(fdarray.data + fdarray.offset[fd] - 1,
- fdarray.offset[fd + 1] - fdarray.offset[fd], op_Private, 0)
- .i;
-
- if (off_private != -1 && len_private != -1) {
- off_subr = cff_iDict.parseDictKey(raw + off_private, len_private, op_Subrs, 0).i;
-
- if (off_subr != -1) {
- cff_iIndex.parse(raw, off_private + off_subr, subr);
- } else {
- cff_iIndex.empty(subr);
- }
- } else {
- cff_iIndex.empty(subr);
- }
-
- return fd;
-}
-
-static inline uint16_t compute_subr_bias(uint16_t cnt) {
- if (cnt < 1240)
- return 107;
- else if (cnt < 33900)
- return 1131;
- else
- return 32768;
-}
-
-/*
- CharString program:
- w? {hs* vs* cm* hm* mt subpath}? {mt subpath}* endchar
-*/
-static void reverseStack(cff_Stack *stack, uint8_t left, uint8_t right) {
- cff_Value *p1 = stack->stack + left;
- cff_Value *p2 = stack->stack + right;
- while (p1 < p2) {
- cff_Value temp = *p1;
- *p1 = *p2;
- *p2 = temp;
- p1++;
- p2--;
- }
-}
-static void callback_nopSetWidth(void *context, double width) {}
-static void callback_nopNewContour(void *context) {}
-static void callback_nopLineTo(void *context, double x1, double y1) {}
-static void callback_nopCurveTo(void *context, double x1, double y1, double x2, double y2,
- double x3, double y3) {}
-static void callback_nopsetHint(void *context, bool isVertical, double position, double width) {}
-static void callback_nopsetMask(void *context, bool isContourMask, bool *mask) {
- FREE(mask);
-}
-static double callback_nopgetrand(void *context) {
- return 0;
-}
-#define CHECK_STACK_TOP(op, n) \
- { \
- if (stack->index < n) { \
- logWarning("[libcff] Stack cannot provide enough parameters for %s (%04x). This " \
- "operation is ignored.\n", \
- #op, op); \
- break; \
- } \
- }
-
-// CFF charastring parser
-void cff_parseOutline(uint8_t *data, uint32_t len, cff_Index gsubr, cff_Index lsubr,
- cff_Stack *stack, void *outline, cff_IOutlineBuilder methods,
- const otfcc_Options *options) {
- uint16_t gsubr_bias = compute_subr_bias(gsubr.count);
- uint16_t lsubr_bias = compute_subr_bias(lsubr.count);
- uint8_t *start = data;
- uint32_t advance, i, cnt_bezier;
- cff_Value val;
-
- void (*setWidth)(void *context, double width) = methods.setWidth;
- void (*newContour)(void *context) = methods.newContour;
- void (*lineTo)(void *context, double x1, double y1) = methods.lineTo;
- void (*curveTo)(void *context, double x1, double y1, double x2, double y2, double x3,
- double y3) = methods.curveTo;
- void (*setHint)(void *context, bool isVertical, double position, double width) =
- methods.setHint;
- void (*setMask)(void *context, bool isContourMask, bool *mask) = methods.setMask;
- double (*getrand)(void *context) = methods.getrand;
-
- if (!setWidth) setWidth = callback_nopSetWidth;
- if (!newContour) newContour = callback_nopNewContour;
- if (!lineTo) lineTo = callback_nopLineTo;
- if (!curveTo) curveTo = callback_nopCurveTo;
- if (!setHint) setHint = callback_nopsetHint;
- if (!setMask) setMask = callback_nopsetMask;
- if (!getrand) getrand = callback_nopgetrand;
-
- while (start < data + len) {
- advance = cff_decodeCS2Token(start, &val);
-
- switch (val.t) {
- case CS2_OPERATOR:
- switch (val.i) {
- case op_hstem:
- case op_vstem:
- case op_hstemhm:
- case op_vstemhm:
- if (stack->index % 2) setWidth(outline, stack->stack[0].d);
- stack->stem += stack->index >> 1;
- double hintBase = 0;
- for (uint16_t j = stack->index % 2; j < stack->index; j += 2) {
- double pos = stack->stack[j].d;
- double width = stack->stack[j + 1].d;
- setHint(outline, (val.i == op_vstem || val.i == op_vstemhm),
- pos + hintBase, width);
- hintBase += pos + width;
- }
- stack->index = 0;
- break;
- case op_hintmask:
- case op_cntrmask: {
- if (stack->index % 2) setWidth(outline, stack->stack[0].d);
- bool isVertical = stack->stem > 0;
- stack->stem += stack->index >> 1;
- double hintBase = 0;
- for (uint16_t j = stack->index % 2; j < stack->index; j += 2) {
- double pos = stack->stack[j].d;
- double width = stack->stack[j + 1].d;
- setHint(outline, isVertical, pos + hintBase, width);
- hintBase += pos + width;
- }
- uint32_t maskLength = (stack->stem + 7) >> 3;
- bool *mask;
- NEW(mask, stack->stem + 7);
- for (uint32_t byte = 0; byte < maskLength; byte++) {
- uint8_t maskByte = start[advance + byte];
- mask[(byte << 3) + 0] = maskByte >> 7 & 1;
- mask[(byte << 3) + 1] = maskByte >> 6 & 1;
- mask[(byte << 3) + 2] = maskByte >> 5 & 1;
- mask[(byte << 3) + 3] = maskByte >> 4 & 1;
- mask[(byte << 3) + 4] = maskByte >> 3 & 1;
- mask[(byte << 3) + 5] = maskByte >> 2 & 1;
- mask[(byte << 3) + 6] = maskByte >> 1 & 1;
- mask[(byte << 3) + 7] = maskByte >> 0 & 1;
- }
- setMask(outline, (val.i == op_cntrmask), mask);
- advance += maskLength;
- stack->index = 0;
- break;
- }
-
- case op_vmoveto: {
- CHECK_STACK_TOP(op_vmoveto, 1);
- if (stack->index > 1) setWidth(outline, stack->stack[stack->index - 2].d);
- newContour(outline);
- lineTo(outline, 0.0, stack->stack[stack->index - 1].d);
- stack->index = 0;
- break;
- }
- case op_rmoveto: {
- CHECK_STACK_TOP(op_rmoveto, 2);
- if (stack->index > 2) setWidth(outline, stack->stack[stack->index - 3].d);
- newContour(outline);
- lineTo(outline, stack->stack[stack->index - 2].d,
- stack->stack[stack->index - 1].d);
- stack->index = 0;
- break;
- }
- case op_hmoveto: {
- CHECK_STACK_TOP(op_hmoveto, 1);
- if (stack->index > 1) setWidth(outline, stack->stack[stack->index - 2].d);
- newContour(outline);
- lineTo(outline, stack->stack[stack->index - 1].d, 0.0);
- stack->index = 0;
- break;
- }
- case op_endchar: {
- if (stack->index > 0) setWidth(outline, stack->stack[stack->index - 1].d);
- break;
- }
- case op_rlineto: {
- for (i = 0; i < stack->index; i += 2)
- lineTo(outline, stack->stack[i].d, stack->stack[i + 1].d);
- stack->index = 0;
- break;
- }
- case op_vlineto: {
- if (stack->index % 2 == 1) {
- lineTo(outline, 0.0, stack->stack[0].d);
- for (i = 1; i < stack->index; i += 2) {
- lineTo(outline, stack->stack[i].d, 0.0);
- lineTo(outline, 0.0, stack->stack[i + 1].d);
- }
- } else {
- for (i = 0; i < stack->index; i += 2) {
- lineTo(outline, 0.0, stack->stack[i].d);
- lineTo(outline, stack->stack[i + 1].d, 0.0);
- }
- }
- stack->index = 0;
- break;
- }
- case op_hlineto: {
- if (stack->index % 2 == 1) {
- lineTo(outline, stack->stack[0].d, 0.0);
- for (i = 1; i < stack->index; i += 2) {
- lineTo(outline, 0.0, stack->stack[i].d);
- lineTo(outline, stack->stack[i + 1].d, 0.0);
- }
- } else {
- for (i = 0; i < stack->index; i += 2) {
- lineTo(outline, stack->stack[i].d, 0.0);
- lineTo(outline, 0.0, stack->stack[i + 1].d);
- }
- }
- stack->index = 0;
- break;
- }
- case op_rrcurveto: {
- for (i = 0; i < stack->index; i += 6)
- curveTo(outline, stack->stack[i].d, stack->stack[i + 1].d,
- stack->stack[i + 2].d, stack->stack[i + 3].d,
- stack->stack[i + 4].d, stack->stack[i + 5].d);
- stack->index = 0;
- break;
- }
- case op_rcurveline: {
- for (i = 0; i < stack->index - 2; i += 6)
- curveTo(outline, stack->stack[i].d, stack->stack[i + 1].d,
- stack->stack[i + 2].d, stack->stack[i + 3].d,
- stack->stack[i + 4].d, stack->stack[i + 5].d);
- lineTo(outline, stack->stack[stack->index - 2].d,
- stack->stack[stack->index - 1].d);
- stack->index = 0;
- break;
- }
- case op_rlinecurve: {
- for (i = 0; i < stack->index - 6; i += 2)
- lineTo(outline, stack->stack[i].d, stack->stack[i + 1].d);
- curveTo(outline, stack->stack[stack->index - 6].d,
- stack->stack[stack->index - 5].d, stack->stack[stack->index - 4].d,
- stack->stack[stack->index - 3].d, stack->stack[stack->index - 2].d,
- stack->stack[stack->index - 1].d);
- stack->index = 0;
- break;
- }
- case op_vvcurveto: {
- if (stack->index % 4 == 1) {
- curveTo(outline, stack->stack[0].d, stack->stack[1].d,
- stack->stack[2].d, stack->stack[3].d, 0.0, stack->stack[4].d);
- for (i = 5; i < stack->index; i += 4)
- curveTo(outline, 0.0, stack->stack[i].d, stack->stack[i + 1].d,
- stack->stack[i + 2].d, 0.0, stack->stack[i + 3].d);
- } else {
- for (i = 0; i < stack->index; i += 4)
- curveTo(outline, 0.0, stack->stack[i].d, stack->stack[i + 1].d,
- stack->stack[i + 2].d, 0.0, stack->stack[i + 3].d);
- }
- stack->index = 0;
- break;
- }
- case op_hhcurveto: {
- if (stack->index % 4 == 1) {
- curveTo(outline, stack->stack[1].d, stack->stack[0].d,
- stack->stack[2].d, stack->stack[3].d, stack->stack[4].d, 0.0);
- for (i = 5; i < stack->index; i += 4)
- curveTo(outline, stack->stack[i].d, 0.0, stack->stack[i + 1].d,
- stack->stack[i + 2].d, stack->stack[i + 3].d, 0.0);
- } else {
- for (i = 0; i < stack->index; i += 4)
- curveTo(outline, stack->stack[i].d, 0.0, stack->stack[i + 1].d,
- stack->stack[i + 2].d, stack->stack[i + 3].d, 0.0);
- }
- stack->index = 0;
- break;
- }
- case op_vhcurveto: {
- if (stack->index % 4 == 1)
- cnt_bezier = (stack->index - 5) / 4;
- else
- cnt_bezier = (stack->index / 4);
-
- for (i = 0; i < 4 * cnt_bezier; i += 4) {
- if ((i / 4) % 2 == 0)
- curveTo(outline, 0.0, stack->stack[i].d, stack->stack[i + 1].d,
- stack->stack[i + 2].d, stack->stack[i + 3].d, 0.0);
- else
- curveTo(outline, stack->stack[i].d, 0.0, stack->stack[i + 1].d,
- stack->stack[i + 2].d, 0.0, stack->stack[i + 3].d);
- }
- if (stack->index % 8 == 5) {
- curveTo(
- outline, 0.0, stack->stack[stack->index - 5].d,
- stack->stack[stack->index - 4].d, stack->stack[stack->index - 3].d,
- stack->stack[stack->index - 2].d, stack->stack[stack->index - 1].d);
- }
- if (stack->index % 8 == 1) {
- curveTo(
- outline, stack->stack[stack->index - 5].d, 0.0,
- stack->stack[stack->index - 4].d, stack->stack[stack->index - 3].d,
- stack->stack[stack->index - 1].d, stack->stack[stack->index - 2].d);
- }
- stack->index = 0;
- break;
- }
- case op_hvcurveto: {
- if (stack->index % 4 == 1)
- cnt_bezier = (stack->index - 5) / 4;
- else
- cnt_bezier = (stack->index / 4);
-
- for (i = 0; i < 4 * cnt_bezier; i += 4) {
- if ((i / 4) % 2 == 0)
- curveTo(outline, stack->stack[i].d, 0.0, stack->stack[i + 1].d,
- stack->stack[i + 2].d, 0.0, stack->stack[i + 3].d);
- else
- curveTo(outline, 0.0, stack->stack[i].d, stack->stack[i + 1].d,
- stack->stack[i + 2].d, stack->stack[i + 3].d, 0.0);
- }
-
- if (stack->index % 8 == 5) {
- curveTo(
- outline, stack->stack[stack->index - 5].d, 0.0,
- stack->stack[stack->index - 4].d, stack->stack[stack->index - 3].d,
- stack->stack[stack->index - 1].d, stack->stack[stack->index - 2].d);
- }
- if (stack->index % 8 == 1) {
- curveTo(
- outline, 0.0, stack->stack[stack->index - 5].d,
- stack->stack[stack->index - 4].d, stack->stack[stack->index - 3].d,
- stack->stack[stack->index - 2].d, stack->stack[stack->index - 1].d);
- }
- stack->index = 0;
- break;
- }
- case op_hflex: {
- CHECK_STACK_TOP(op_hflex, 7);
- curveTo(outline, stack->stack[0].d, 0.0, stack->stack[1].d,
- stack->stack[2].d, stack->stack[3].d, 0.0);
- curveTo(outline, stack->stack[4].d, 0.0, stack->stack[5].d,
- -stack->stack[2].d, stack->stack[6].d, 0.0);
- stack->index = 0;
- break;
- }
- case op_flex: {
- CHECK_STACK_TOP(op_flex, 12);
- curveTo(outline, stack->stack[0].d, stack->stack[1].d, stack->stack[2].d,
- stack->stack[3].d, stack->stack[4].d, stack->stack[5].d);
- curveTo(outline, stack->stack[6].d, stack->stack[7].d, stack->stack[8].d,
- stack->stack[9].d, stack->stack[10].d, stack->stack[11].d);
- stack->index = 0;
- break;
- }
- case op_hflex1: {
- CHECK_STACK_TOP(op_hflex1, 9);
- curveTo(outline, stack->stack[0].d, stack->stack[1].d, stack->stack[2].d,
- stack->stack[3].d, stack->stack[4].d, 0.0);
- curveTo(outline, stack->stack[5].d, 0.0, stack->stack[6].d,
- stack->stack[7].d, stack->stack[8].d,
- -(stack->stack[1].d + stack->stack[3].d + stack->stack[7].d));
- stack->index = 0;
- break;
- }
- case op_flex1: {
- CHECK_STACK_TOP(op_flex1, 11);
- double dx = stack->stack[0].d + stack->stack[2].d + stack->stack[4].d +
- stack->stack[6].d + stack->stack[8].d;
- double dy = stack->stack[1].d + stack->stack[3].d + stack->stack[5].d +
- stack->stack[7].d + stack->stack[9].d;
- if (fabs(dx) > fabs(dy)) {
- dx = stack->stack[10].d;
- dy = -dy;
- } else {
- dx = -dx;
- dy = stack->stack[10].d;
- }
- curveTo(outline, stack->stack[0].d, stack->stack[1].d, stack->stack[2].d,
- stack->stack[3].d, stack->stack[4].d, stack->stack[5].d);
- curveTo(outline, stack->stack[6].d, stack->stack[7].d, stack->stack[8].d,
- stack->stack[9].d, dx, dy);
- stack->index = 0;
- break;
- }
- case op_and: {
- CHECK_STACK_TOP(op_and, 2);
- double num1 = stack->stack[stack->index - 1].d;
- double num2 = stack->stack[stack->index - 2].d;
- stack->stack[stack->index - 2].d = (num1 && num2) ? 1.0 : 0.0;
- stack->index -= 1;
- break;
- }
- case op_or: {
- CHECK_STACK_TOP(op_or, 2);
- double num1 = stack->stack[stack->index - 1].d;
- double num2 = stack->stack[stack->index - 2].d;
- stack->stack[stack->index - 2].d = (num1 || num2) ? 1.0 : 0.0;
- stack->index -= 1;
- break;
- }
- case op_not: {
- CHECK_STACK_TOP(op_not, 1);
- double num = stack->stack[stack->index - 1].d;
- stack->stack[stack->index - 1].d = num ? 0.0 : 1.0;
- break;
- }
- case op_abs: {
- CHECK_STACK_TOP(op_abs, 1);
- double num = stack->stack[stack->index - 1].d;
- stack->stack[stack->index - 1].d = (num < 0.0) ? -num : num;
- break;
- }
- case op_add: {
- CHECK_STACK_TOP(op_add, 2);
- double num1 = stack->stack[stack->index - 1].d;
- double num2 = stack->stack[stack->index - 2].d;
- stack->stack[stack->index - 2].d = num1 + num2;
- stack->index -= 1;
- break;
- }
- case op_sub: {
- CHECK_STACK_TOP(op_sub, 2);
- double num1 = stack->stack[stack->index - 2].d;
- double num2 = stack->stack[stack->index - 1].d;
- stack->stack[stack->index - 2].d = num1 - num2;
- stack->index -= 1;
- break;
- }
- case op_div: {
- CHECK_STACK_TOP(op_div, 2);
- double num1 = stack->stack[stack->index - 2].d;
- double num2 = stack->stack[stack->index - 1].d;
- stack->stack[stack->index - 2].d = num1 / num2;
- stack->index -= 1;
- break;
- }
- case op_neg: {
- CHECK_STACK_TOP(op_neg, 1);
- double num = stack->stack[stack->index - 1].d;
- stack->stack[stack->index - 1].d = -num;
- break;
- }
- case op_eq: {
- CHECK_STACK_TOP(op_eq, 2);
- double num1 = stack->stack[stack->index - 1].d;
- double num2 = stack->stack[stack->index - 2].d;
- stack->stack[stack->index - 2].d = (num1 == num2) ? 1.0 : 0.0;
- stack->index -= 1;
- break;
- }
- case op_drop: {
- CHECK_STACK_TOP(op_drop, 1);
- stack->index -= 1;
- break;
- }
- case op_put: {
- CHECK_STACK_TOP(op_put, 2);
- double val = stack->stack[stack->index - 2].d;
- int32_t i = (int32_t)stack->stack[stack->index - 1].d;
- stack->transient[i % type2_transient_array].d = val;
- stack->index -= 2;
- break;
- }
- case op_get: {
- CHECK_STACK_TOP(op_get, 1);
- int32_t i = (int32_t)stack->stack[stack->index - 1].d;
- stack->stack[stack->index - 1].d =
- stack->transient[i % type2_transient_array].d;
- break;
- }
- case op_ifelse: {
- CHECK_STACK_TOP(op_ifelse, 4);
- double v2 = stack->stack[stack->index - 1].d;
- double v1 = stack->stack[stack->index - 2].d;
- double s2 = stack->stack[stack->index - 3].d;
- double s1 = stack->stack[stack->index - 4].d;
- stack->stack[stack->index - 4].d = (v1 <= v2) ? s1 : s2;
- stack->index -= 3;
- break;
- }
- case op_random: {
- // Chosen from a fair dice
- // TODO: use a real randomizer
- stack->stack[stack->index].t = cff_DOUBLE;
- stack->stack[stack->index].d = getrand(outline);
- stack->index += 1;
- break;
- }
- case op_mul: {
- CHECK_STACK_TOP(op_mul, 2);
- double num1 = stack->stack[stack->index - 1].d;
- double num2 = stack->stack[stack->index - 2].d;
- stack->stack[stack->index - 2].d = num1 * num2;
- stack->index -= 1;
- break;
- }
- case op_sqrt: {
- CHECK_STACK_TOP(op_sqrt, 1);
- double num = stack->stack[stack->index - 1].d;
- stack->stack[stack->index - 1].d = sqrt(num);
- break;
- }
- case op_dup: {
- CHECK_STACK_TOP(op_dup, 1);
- stack->stack[stack->index] = stack->stack[stack->index - 1];
- stack->index += 1;
- break;
- }
- case op_exch: {
- CHECK_STACK_TOP(op_exch, 2);
- double num1 = stack->stack[stack->index - 1].d;
- double num2 = stack->stack[stack->index - 2].d;
- stack->stack[stack->index - 1].d = num2;
- stack->stack[stack->index - 2].d = num1;
- break;
- }
- case op_index: {
- CHECK_STACK_TOP(op_index, 2);
- uint8_t n = stack->index - 1;
- uint8_t j = n - 1 - (uint8_t)(stack->stack[n].d) % n;
- stack->stack[n] = stack->stack[j];
- break;
- }
- case op_roll: {
- CHECK_STACK_TOP(op_roll, 2);
- int32_t j = stack->stack[stack->index - 1].d;
- uint32_t n = stack->stack[stack->index - 2].d;
- CHECK_STACK_TOP(op_roll, 2 + n);
- j = -j % n;
- if (j < 0) j += n;
- if (!j) break;
- uint8_t last = stack->index - 3;
- uint8_t first = stack->index - 2 - n;
-
- reverseStack(stack, first, last);
- reverseStack(stack, last - j + 1, last);
- reverseStack(stack, first, last - j);
- stack->index -= 2;
- break;
- }
- case op_return:
- return;
- case op_callsubr: {
- CHECK_STACK_TOP(op_callsubr, 1);
- uint32_t subr = (uint32_t)stack->stack[--(stack->index)].d;
- cff_parseOutline(lsubr.data + lsubr.offset[lsubr_bias + subr] - 1,
- lsubr.offset[lsubr_bias + subr + 1] -
- lsubr.offset[lsubr_bias + subr],
- gsubr, lsubr, stack, outline, methods, options);
- break;
- }
- case op_callgsubr: {
- CHECK_STACK_TOP(op_callgsubr, 1);
- uint32_t subr = (uint32_t)stack->stack[--(stack->index)].d;
- cff_parseOutline(gsubr.data + gsubr.offset[gsubr_bias + subr] - 1,
- gsubr.offset[gsubr_bias + subr + 1] -
- gsubr.offset[gsubr_bias + subr],
- gsubr, lsubr, stack, outline, methods, options);
- break;
- }
- default: {
- logWarning("Warning: unknown operator %d occurs in Type 2 CharString. It "
- "may caused by file corruption.",
- val.i);
- return;
- }
- }
- break;
- case CS2_OPERAND:
- case CS2_FRACTION:
- stack->stack[(stack->index)++] = val;
- break;
- }
-
- start += advance;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-string.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-string.c
deleted file mode 100644
index 92db60b6879..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-string.c
+++ /dev/null
@@ -1,411 +0,0 @@
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libcff.h"
-
-static const char *const string_standard[391] = {
- ".notdef",
- "space",
- "exclam",
- "quotedbl",
- "numbersign",
- "dollar",
- "percent",
- "ampersand",
- "quoteright",
- "parenleft",
- "parenright",
- "asterisk",
- "plus",
- "comma",
- "hyphen",
- "period",
- "slash",
- "zero",
- "one",
- "two",
- "three",
- "four",
- "five",
- "six",
- "seven",
- "eight",
- "nine",
- "colon",
- "semicolon",
- "less",
- "equal",
- "greater",
- "question",
- "at",
- "A",
- "B",
- "C",
- "D",
- "E",
- "F",
- "G",
- "H",
- "I",
- "J",
- "K",
- "L",
- "M",
- "N",
- "O",
- "P",
- "Q",
- "R",
- "S",
- "T",
- "U",
- "V",
- "W",
- "X",
- "Y",
- "Z",
- "bracketleft",
- "backslash",
- "bracketright",
- "asciicircum",
- "underscore",
- "quoteleft",
- "a",
- "b",
- "c",
- "d",
- "e",
- "f",
- "g",
- "h",
- "i",
- "j",
- "k",
- "l",
- "m",
- "n",
- "o",
- "p",
- "q",
- "r",
- "s",
- "t",
- "u",
- "v",
- "w",
- "x",
- "y",
- "z",
- "braceleft",
- "bar",
- "braceright",
- "asciitilde",
- "exclamdown",
- "cent",
- "sterling",
- "fraction",
- "yen",
- "florin",
- "section",
- "currency",
- "quotesingle",
- "quotedblleft",
- "guillemotleft",
- "guilsinglleft",
- "guilsinglright",
- "fi",
- "fl",
- "endash",
- "dagger",
- "daggerdbl",
- "periodcentered",
- "paragraph",
- "bullet",
- "quotesinglbase",
- "quotedblbase",
- "quotedblright",
- "guillemotright",
- "ellipsis",
- "perthousand",
- "questiondown",
- "grave",
- "acute",
- "circumflex",
- "tilde",
- "macron",
- "breve",
- "dotaccent",
- "dieresis",
- "ring",
- "cedilla",
- "hungarumlaut",
- "ogonek",
- "caron",
- "emdash",
- "AE",
- "ordfeminine",
- "Lslash",
- "Oslash",
- "OE",
- "ordmasculine",
- "ae",
- "dotlessi",
- "lslash",
- "oslash",
- "oe",
- "germandbls",
- "onesuperior",
- "logicalnot",
- "mu",
- "trademark",
- "Eth",
- "onehalf",
- "plusminus",
- "Thorn",
- "onequarter",
- "divide",
- "brokenbar",
- "degree",
- "thorn",
- "threequarters",
- "twosuperior",
- "registered",
- "minus",
- "eth",
- "multiply",
- "threesuperior",
- "copyright",
- "Aacute",
- "Acircumflex",
- "Adieresis",
- "Agrave",
- "Aring",
- "Atilde",
- "Ccedilla",
- "Eacute",
- "Ecircumflex",
- "Edieresis",
- "Egrave",
- "Iacute",
- "Icircumflex",
- "Idieresis",
- "Igrave",
- "Ntilde",
- "Oacute",
- "Ocircumflex",
- "Odieresis",
- "Ograve",
- "Otilde",
- "Scaron",
- "Uacute",
- "Ucircumflex",
- "Udieresis",
- "Ugrave",
- "Yacute",
- "Ydieresis",
- "Zcaron",
- "aacute",
- "acircumflex",
- "adieresis",
- "agrave",
- "aring",
- "atilde",
- "ccedilla",
- "eacute",
- "ecircumflex",
- "edieresis",
- "egrave",
- "iacute",
- "icircumflex",
- "idieresis",
- "igrave",
- "ntilde",
- "oacute",
- "ocircumflex",
- "odieresis",
- "ograve",
- "otilde",
- "scaron",
- "uacute",
- "ucircumflex",
- "udieresis",
- "ugrave",
- "yacute",
- "ydieresis",
- "zcaron",
- "exclamsmall",
- "Hungarumlautsmall",
- "dollaroldstyle",
- "dollarsuperior",
- "ampersandsmall",
- "Acutesmall",
- "parenleftsuperior",
- "parenrightsuperior",
- "twodotenleader",
- "onedotenleader",
- "zerooldstyle",
- "oneoldstyle",
- "twooldstyle",
- "threeoldstyle",
- "fouroldstyle",
- "fiveoldstyle",
- "sixoldstyle",
- "sevenoldstyle",
- "eightoldstyle",
- "nineoldstyle",
- "commasuperior",
- "threequartersemdash",
- "periodsuperior",
- "questionsmall",
- "asuperior",
- "bsuperior",
- "centsuperior",
- "dsuperior",
- "esuperior",
- "isuperior",
- "lsuperior",
- "msuperior",
- "nsuperior",
- "osuperior",
- "rsuperior",
- "ssuperior",
- "tsuperior",
- "ff",
- "ffi",
- "ffl",
- "parenleftinferior",
- "parenrightinferior",
- "Circumflexsmall",
- "hyphensuperior",
- "Gravesmall",
- "Asmall",
- "Bsmall",
- "Csmall",
- "Dsmall",
- "Esmall",
- "Fsmall",
- "Gsmall",
- "Hsmall",
- "Ismall",
- "Jsmall",
- "Ksmall",
- "Lsmall",
- "Msmall",
- "Nsmall",
- "Osmall",
- "Psmall",
- "Qsmall",
- "Rsmall",
- "Ssmall",
- "Tsmall",
- "Usmall",
- "Vsmall",
- "Wsmall",
- "Xsmall",
- "Ysmall",
- "Zsmall",
- "colonmonetary",
- "onefitted",
- "rupiah",
- "Tildesmall",
- "exclamdownsmall",
- "centoldstyle",
- "Lslashsmall",
- "Scaronsmall",
- "Zcaronsmall",
- "Dieresissmall",
- "Brevesmall",
- "Caronsmall",
- "Dotaccentsmall",
- "Macronsmall",
- "figuredash",
- "hypheninferior",
- "Ogoneksmall",
- "Ringsmall",
- "Cedillasmall",
- "questiondownsmall",
- "oneeighth",
- "threeeighths",
- "fiveeighths",
- "seveneighths",
- "onethird",
- "twothirds",
- "zerosuperior",
- "foursuperior",
- "fivesuperior",
- "sixsuperior",
- "sevensuperior",
- "eightsuperior",
- "ninesuperior",
- "zeroinferior",
- "oneinferior",
- "twoinferior",
- "threeinferior",
- "fourinferior",
- "fiveinferior",
- "sixinferior",
- "seveninferior",
- "eightinferior",
- "nineinferior",
- "centinferior",
- "dollarinferior",
- "periodinferior",
- "commainferior",
- "Agravesmall",
- "Aacutesmall",
- "Acircumflexsmall",
- "Atildesmall",
- "Adieresissmall",
- "Aringsmall",
- "AEsmall",
- "Ccedillasmall",
- "Egravesmall",
- "Eacutesmall",
- "Ecircumflexsmall",
- "Edieresissmall",
- "Igravesmall",
- "Iacutesmall",
- "Icircumflexsmall",
- "Idieresissmall",
- "Ethsmall",
- "Ntildesmall",
- "Ogravesmall",
- "Oacutesmall",
- "Ocircumflexsmall",
- "Otildesmall",
- "Odieresissmall",
- "OEsmall",
- "Oslashsmall",
- "Ugravesmall",
- "Uacutesmall",
- "Ucircumflexsmall",
- "Udieresissmall",
- "Yacutesmall",
- "Thornsmall",
- "Ydieresissmall",
- "001.000",
- "001.001",
- "001.002",
- "001.003",
- "Black",
- "Bold",
- "Book",
- "Light",
- "Medium",
- "Regular",
- "Roman",
- "Semibold",
-};
-
-sds sdsget_cff_sid(uint16_t idx, cff_Index str) {
- if (idx <= 390) {
- return sdsnew(string_standard[idx]);
- } else if (str.count > 0 && idx - 391 < str.count) {
- return sdsnewlen(str.data + str.offset[idx - 391] - 1,
- str.offset[idx - 390] - str.offset[idx - 391]);
- } else {
- return NULL;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-util.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-util.h
deleted file mode 100644
index 4535062721e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-util.h
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef CARYLL_cff_UTIL_H
-#define CARYLL_cff_UTIL_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "support/util.h"
-
-// clang-format off
-// CFF DICT Operators
-enum {
- op_version = 0x00, op_Copyright = 0x0c00,
- op_Notice = 0x01, op_isFixedPitch = 0x0c01,
- op_FullName = 0x02, op_ItalicAngle = 0x0c02,
- op_FamilyName = 0x03, op_UnderlinePosition = 0x0c03,
- op_Weight = 0x04, op_UnderlineThickness = 0x0c04,
- op_FontBBox = 0x05, op_PaintType = 0x0c05,
- op_BlueValues = 0x06, op_CharstringType = 0x0c06,
- op_OtherBlues = 0x07, op_FontMatrix = 0x0c07,
- op_FamilyBlues = 0x08, op_StrokeWidth = 0x0c08,
- op_FamilyOtherBlues = 0x09, op_BlueScale = 0x0c09,
- op_StdHW = 0x0a, op_BlueShift = 0x0c0a,
- op_StdVW = 0x0b, op_BlueFuzz = 0x0c0b,
- /* 0x0c escape */ op_StemSnapH = 0x0c0c,
- op_UniqueID = 0x0d, op_StemSnapV = 0x0c0d,
- op_XUID = 0x0e, op_ForceBold = 0x0c0e,
- op_charset = 0x0f, /* 0x0c0f Reserved */
- op_Encoding = 0x10, /* 0x0c10 Reserved */
- op_CharStrings = 0x11, op_LanguageGroup = 0x0c11,
- op_Private = 0x12, op_ExpansionFactor = 0x0c12,
- op_Subrs = 0x13, op_initialRandomSeed = 0x0c13,
- op_defaultWidthX = 0x14, op_SyntheicBase = 0x0c14,
- op_nominalWidthX = 0x15, op_PostScript = 0x0c15,
- op_vsindex = 0x16, op_BaseFontName = 0x0c16,
- op_blend = 0x17, op_BaseFontBlend = 0x0c17,
- op_vstore = 0x18, /* 0x0c18 Reserved */
- op_maxstack = 0x19, /* 0x0c19 Reserved */
- /* 0x0c1a Reserved */
- /* 0x0c1b Reserved */
- /* 0x0c1c Reserved */
- /* 0x0c1d Reserved */
- op_ROS = 0x0c1e,
- op_CIDFontVersion = 0x0c1f,
- op_CIDFontRevision = 0x0c20,
- op_CIDFontType = 0x0c21,
- op_CIDCount = 0x0c22,
- op_UIDBase = 0x0c23,
- op_FDArray = 0x0c24,
- op_FDSelect = 0x0c25,
- op_FontName = 0x0c26,
-};
-
-// Type2 CharString Operators
-enum {
- /* 0x00 Reserved */ /* 0x0c00 Reserved */
- op_hstem = 0x01, /* 0x0c01 Reserved */
- /* 0x02 Reserved */ /* 0x0c02 Reserved */
- op_vstem = 0x03, op_and = 0x0c03,
- op_vmoveto = 0x04, op_or = 0x0c04,
- op_rlineto = 0x05, op_not = 0x0c05,
- op_hlineto = 0x06, /* 0x0c06 Reserved */
- op_vlineto = 0x07, /* 0x0c07 Reserved */
- op_rrcurveto = 0x08, /* 0x0c08 Reserved */
- /* 0x09 Reserved */ op_abs = 0x0c09,
- op_callsubr = 0x0a, op_add = 0x0c0a,
- op_return = 0x0b, op_sub = 0x0c0b,
- /* 0x0c escape */ op_div = 0x0c0c,
- /* 0x0d Reserved */ /* 0x0c0d Reserved */
- op_endchar = 0x0e, op_neg = 0x0c0e,
- op_cff2vsidx = 0x0f, op_eq = 0x0c0f,
- op_cff2blend = 0x10, /* 0x0c10 Reserved */
- /* 0x11 Reserved */ /* 0x0c11 Reserved */
- op_hstemhm = 0x12, op_drop = 0x0c12,
- op_hintmask = 0x13, /* 0x0c13 Reserved */
- op_cntrmask = 0x14, op_put = 0x0c14,
- op_rmoveto = 0x15, op_get = 0x0c15,
- op_hmoveto = 0x16, op_ifelse = 0x0c16,
- op_vstemhm = 0x17, op_random = 0x0c17,
- op_rcurveline = 0x18, op_mul = 0x0c18,
- op_rlinecurve = 0x19, /* 0x0c19 Reserved */
- op_vvcurveto = 0x1a, op_sqrt = 0x0c1a,
- op_hhcurveto = 0x1b, op_dup = 0x0c1b,
- /* 0x1c short int */ op_exch = 0x0c1c,
- op_callgsubr = 0x1d, op_index = 0x0c1d,
- op_vhcurveto = 0x1e, op_roll = 0x0c1e,
- op_hvcurveto = 0x1f, /* 0x0c1f Reserved */
- /* 0x0c20 Reserved */
- /* 0x0c21 Reserved */
- op_hflex = 0x0c22,
- op_flex = 0x0c23,
- op_hflex1 = 0x0c24,
- op_flex1 = 0x0c25,
-};
-// clang-format on
-
-// parser util functions
-static INLINE uint32_t gu1(uint8_t *s, uint32_t p) {
- uint32_t b0 = *(s + p);
- return b0;
-}
-
-static INLINE uint32_t gu2(uint8_t *s, uint32_t p) {
- uint32_t b0 = *(s + p) << 8;
- uint32_t b1 = *(s + p + 1);
- return b0 | b1;
-}
-
-static INLINE uint32_t gu3(uint8_t *s, uint32_t p) {
- uint32_t b0 = *(s + p) << 16;
- uint32_t b1 = *(s + p + 1) << 8;
- uint32_t b2 = *(s + p + 2);
- return b0 | b1 | b2;
-}
-static INLINE uint32_t gu4(uint8_t *s, uint32_t p) {
- uint32_t b0 = *(s + p) << 24;
- uint32_t b1 = *(s + p + 1) << 16;
- uint32_t b2 = *(s + p + 2) << 8;
- uint32_t b3 = *(s + p + 3);
- return b0 | b1 | b2 | b3;
-}
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.c
deleted file mode 100644
index 6637a209520..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "cff-value.h"
-
-double cffnum(cff_Value val) {
- if (val.t == cff_INTEGER) return val.i;
- if (val.t == cff_DOUBLE) return val.d;
- return 0;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.h
deleted file mode 100644
index 8e7b45d1fc2..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-value.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef CARYLL_cff_VALUE_H
-#define CARYLL_cff_VALUE_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "support/util.h"
-
-typedef enum {
- cff_OPERATOR = 1,
- CS2_OPERATOR = 1,
- cff_INTEGER = 2,
- CS2_OPERAND = 2,
- cff_DOUBLE = 3,
- CS2_FRACTION = 3
-} cff_Value_Type;
-
-typedef struct {
- cff_Value_Type t;
- union {
- int32_t i;
- double d;
- };
-} cff_Value;
-
-double cffnum(cff_Value v);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-writer.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-writer.c
deleted file mode 100644
index 759fb0c75f8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/cff-writer.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- Compiler of CFF, subset and full conversion
- * note that there is no optimization in current implement
-*/
-
-#include <math.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libcff.h"
-
-caryll_Buffer *cff_buildHeader(void) {
- return bufninit(4, 1, 0, 4, 4);
-}
-
-void cff_mergeCS2Operator(caryll_Buffer *blob, int32_t val) {
- if (val >= 0x100) {
- bufnwrite8(blob, 2, val >> 8, val & 0xff);
- } else {
- bufnwrite8(blob, 1, val & 0xff);
- }
-}
-void cff_mergeCS2Int(caryll_Buffer *blob, int32_t val) {
- if (val >= -1131 && val <= -108) {
- bufnwrite8(blob, 2, (uint8_t)((-108 - val) / 256 + 251), (uint8_t)((-108 - val) % 256));
- } else if (val >= -107 && val <= 107) {
- bufnwrite8(blob, 1, (uint8_t)(val + 139));
- } else if (val >= 108 && val <= 1131) {
- bufnwrite8(blob, 2, (uint8_t)((val - 108) / 256 + 247), (uint8_t)((val - 108) % 256));
- } else {
- if (val >= -32768 && val <= 32767) {
- bufnwrite8(blob, 3, 28, (uint8_t)(val >> 8), (uint8_t)((val << 8) >> 8));
- } else {
- cff_mergeCS2Int(blob, 0);
- }
- }
-}
-static void mergeCS2Real(caryll_Buffer *blob, double val) {
- int16_t integerPart = floor(val);
- uint16_t fractionPart = (val - integerPart) * 65536.0;
- bufnwrite8(blob, 5, 0xFF, integerPart >> 8, integerPart & 0xFF, fractionPart >> 8, fractionPart & 0xFF);
-}
-void cff_mergeCS2Operand(caryll_Buffer *blob, double val) {
- double intpart;
- if (modf(val, &intpart) == 0.0) {
- cff_mergeCS2Int(blob, (int32_t)intpart);
- } else {
- mergeCS2Real(blob, val);
- }
-}
-void cff_mergeCS2Special(caryll_Buffer *blob, uint8_t val) {
- bufwrite8(blob, val);
-}
-
-caryll_Buffer *cff_buildOffset(int32_t val) {
- return bufninit(5, 29, (val >> 24) & 0xff, (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.c
deleted file mode 100644
index d73f4dd57b5..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.c
+++ /dev/null
@@ -1,518 +0,0 @@
-#include "charstring-il.h"
-#include "table/glyf.h"
-
-// Glyph building
-static void ensureThereIsSpace(cff_CharstringIL *il) {
- if (il->free) return;
- il->free = 0x100;
- RESIZE(il->instr, il->length + il->free);
-}
-
-void il_push_operand(cff_CharstringIL *il, double x) {
- ensureThereIsSpace(il);
- il->instr[il->length].type = IL_ITEM_OPERAND;
- il->instr[il->length].d = x;
- il->instr[il->length].arity = 0;
- il->length++;
- il->free--;
-}
-static void il_push_VQ(cff_CharstringIL *il, VQ x) {
- il_push_operand(il, iVQ.getStill(x));
-}
-void il_push_special(cff_CharstringIL *il, int32_t s) {
- ensureThereIsSpace(il);
- il->instr[il->length].type = IL_ITEM_SPECIAL;
- il->instr[il->length].i = s;
- il->instr[il->length].arity = 0;
- il->length++;
- il->free--;
-}
-void il_push_op(cff_CharstringIL *il, int32_t op) {
- ensureThereIsSpace(il);
- il->instr[il->length].type = IL_ITEM_OPERATOR;
- il->instr[il->length].i = op;
- il->instr[il->length].arity = cff_getStandardArity(op);
- il->length++;
- il->free--;
-}
-static void il_moveto(cff_CharstringIL *il, VQ dx, VQ dy) {
- il_push_VQ(il, dx);
- il_push_VQ(il, dy);
- il_push_op(il, op_rmoveto);
-}
-static void il_lineto(cff_CharstringIL *il, VQ dx, VQ dy) {
- il_push_VQ(il, dx);
- il_push_VQ(il, dy);
- il_push_op(il, op_rlineto);
-}
-static void il_curveto(cff_CharstringIL *il, VQ dx1, VQ dy1, VQ dx2, VQ dy2, VQ dx3, VQ dy3) {
- il_push_VQ(il, dx1);
- il_push_VQ(il, dy1);
- il_push_VQ(il, dx2);
- il_push_VQ(il, dy2);
- il_push_VQ(il, dx3);
- il_push_VQ(il, dy3);
- il_push_op(il, op_rrcurveto);
-}
-
-static void _il_push_maskgroup(cff_CharstringIL *il, // il seq
- glyf_MaskList *masks, // masks array
- uint16_t contours, // contous drawn
- uint16_t points, // points drawn
- uint16_t nh, uint16_t nv, // quantity of stems
- uint16_t *jm, // index of cur mask
- int32_t op) { // mask operator
- shapeid_t n = masks->length;
- while (*jm < n && (masks->items[*jm].contoursBefore < contours ||
- (masks->items[*jm].contoursBefore == contours &&
- masks->items[*jm].pointsBefore <= points))) {
- il_push_op(il, op);
- uint8_t maskByte = 0;
- uint8_t bits = 0;
- for (uint16_t j = 0; j < nh; j++) {
- maskByte = maskByte << 1 | (masks->items[*jm].maskH[j] & 1);
- bits += 1;
- if (bits == 8) {
- il_push_special(il, maskByte);
- bits = 0;
- }
- }
- for (uint16_t j = 0; j < nv; j++) {
- maskByte = maskByte << 1 | (masks->items[*jm].maskV[j] & 1);
- bits += 1;
- if (bits == 8) {
- il_push_special(il, maskByte);
- bits = 0;
- }
- }
- if (bits) {
- maskByte = maskByte << (8 - bits);
- il_push_special(il, maskByte);
- }
- *jm += 1;
- }
-}
-static void il_push_masks(cff_CharstringIL *il, glyf_Glyph *g, // meta
- uint16_t contours, // contours sofar
- uint16_t points, // points sofar
- uint16_t *jh, // index of pushed cmasks
- uint16_t *jm // index of pushed hmasks
-) {
- if (!g->stemH.length && !g->stemV.length) return;
- _il_push_maskgroup(il, &g->contourMasks, contours, points, //
- g->stemH.length, g->stemV.length, jh, op_cntrmask);
- _il_push_maskgroup(il, &g->hintMasks, contours, points, //
- g->stemH.length, g->stemV.length, jm, op_hintmask);
-}
-
-static void _il_push_stemgroup(cff_CharstringIL *il, // il seq
- glyf_StemDefList *stems, // stem array
- bool hasmask, bool haswidth, int32_t ophm, int32_t oph) {
- if (!stems || !stems->length) return;
- pos_t ref = 0;
- uint16_t nn = haswidth ? 1 : 0;
- for (uint16_t j = 0; j < stems->length; j++) {
- il_push_operand(il, stems->items[j].position - ref);
- il_push_operand(il, stems->items[j].width);
- ref = stems->items[j].position + stems->items[j].width;
- nn++;
- if (nn >= type2_argument_stack) {
- if (hasmask) {
- il_push_op(il, op_hstemhm);
- } else {
- il_push_op(il, op_hstem);
- }
- il->instr[il->length - 1].arity = nn;
- nn = 0;
- }
- }
- if (hasmask) {
- il_push_op(il, ophm);
- } else {
- il_push_op(il, oph);
- }
- il->instr[il->length - 1].arity = nn;
-}
-static void il_push_stems(cff_CharstringIL *il, glyf_Glyph *g, bool hasmask, bool haswidth) {
- _il_push_stemgroup(il, &g->stemH, hasmask, haswidth, op_hstemhm, op_hstem);
- _il_push_stemgroup(il, &g->stemV, hasmask, haswidth, op_vstemhm, op_vstem);
-}
-cff_CharstringIL *cff_compileGlyphToIL(glyf_Glyph *g, uint16_t defaultWidth,
- uint16_t nominalWidth) {
- cff_CharstringIL *il;
- NEW(il);
- // Convert absolute positions to deltas
- glyf_Contour *tempContours = NULL;
- {
- VQ x = iVQ.neutral();
- VQ y = iVQ.neutral();
- NEW(tempContours, g->contours.length);
- for (uint16_t c = 0; c < g->contours.length; c++) {
- glyf_Contour *contour = &(g->contours.items[c]);
- glyf_Contour *newcontour = &(tempContours[c]);
- glyf_iContour.init(newcontour);
- for (shapeid_t j = 0; j < contour->length; j++) {
- glyf_iContour.push(newcontour, glyf_iPoint.dup(contour->items[j]));
- }
-
- if (newcontour->length > 2 && !newcontour->items[newcontour->length - 1].onCurve) {
- // Duplicate first point for proper CurveTo generation
- glyf_iContour.push(newcontour, glyf_iPoint.dup(newcontour->items[0]));
- }
-
- for (shapeid_t j = 0; j < newcontour->length; j++) {
- VQ dx = iVQ.minus(newcontour->items[j].x, x);
- VQ dy = iVQ.minus(newcontour->items[j].y, y);
- iVQ.copyReplace(&x, newcontour->items[j].x);
- iVQ.copyReplace(&y, newcontour->items[j].y);
- iVQ.replace(&newcontour->items[j].x, dx);
- iVQ.replace(&newcontour->items[j].y, dy);
- }
- }
- iVQ.dispose(&x);
- iVQ.dispose(&y);
- }
-
- bool hasmask =
- g->hintMasks.length || g->contourMasks.length; // we have hint masks or contour masks
- const pos_t glyphADWConst = iVQ.getStill(g->advanceWidth);
- bool haswidth = glyphADWConst != defaultWidth; // we have width operand here
- // Write IL
- if (haswidth) { il_push_operand(il, (int)(glyphADWConst) - (int)(nominalWidth)); }
- il_push_stems(il, g, hasmask, haswidth);
- // Write contour
- shapeid_t contoursSofar = 0;
- shapeid_t pointsSofar = 0;
- shapeid_t jh = 0;
- shapeid_t jm = 0;
- if (hasmask) il_push_masks(il, g, contoursSofar, pointsSofar, &jh, &jm);
- for (shapeid_t c = 0; c < g->contours.length; c++) {
- glyf_Contour *contour = &(tempContours[c]);
- shapeid_t n = contour->length;
- if (n == 0) continue;
- il_moveto(il, contour->items[0].x, contour->items[0].y);
- pointsSofar++;
- if (hasmask) il_push_masks(il, g, contoursSofar, pointsSofar, &jh, &jm);
- // TODO: Generate BLENDs
- for (shapeid_t j = 1; j < n; j++) {
- if (contour->items[j].onCurve) { // A line-to
- il_lineto(il, contour->items[j].x, contour->items[j].y);
- pointsSofar += 1;
- } else if (j < n - 2 // have enough points
- && !contour->items[j + 1].onCurve // next is offcurve
- && contour->items[j + 2].onCurve // and next is oncurve
- ) { // means this is an bezier curve strand
- il_curveto(il, contour->items[j].x,
- contour->items[j].y, // dz1
- contour->items[j + 1].x,
- contour->items[j + 1].y, // dz2
- contour->items[j + 2].x,
- contour->items[j + 2].y); // dz3
- pointsSofar += 3;
- j += 2;
- } else { // invalid offcurve, treat as oncurve
- il_lineto(il, contour->items[j].x, contour->items[j].y);
- pointsSofar++;
- }
- if (hasmask) il_push_masks(il, g, contoursSofar, pointsSofar, &jh, &jm);
- }
- contoursSofar += 1;
- pointsSofar = 0;
- }
- il_push_op(il, op_endchar);
- // delete temp contour array
- for (shapeid_t c = 0; c < g->contours.length; c++) {
- glyf_iContour.dispose(&tempContours[c]);
- }
- FREE(tempContours);
- return il;
-}
-
-// Pattern-based peephole optimization
-static bool il_matchtype(cff_CharstringIL *il, uint32_t j, uint32_t k, cff_InstructionType t) {
- if (k >= il->length) return false;
- for (uint32_t m = j; m < k; m++) {
- if (il->instr[m].type != t) return false;
- }
- return true;
-}
-static bool il_matchop(cff_CharstringIL *il, uint32_t j, int32_t op) {
- if (il->instr[j].type != IL_ITEM_OPERATOR) return false;
- if (il->instr[j].i != op) return false;
- return true;
-}
-static uint8_t zroll(cff_CharstringIL *il, uint32_t j, int32_t op, int32_t op2, ...) {
- uint8_t arity = cff_getStandardArity(op);
- if (arity > 16 || j + arity >= il->length) return 0;
- if ((j == 0 || // We are at the beginning of charstring
- !il_matchtype(il, j - 1, j,
- IL_ITEM_PHANTOM_OPERATOR)) // .. or we are right after a solid operator
- && il_matchop(il, j + arity, op) // The next operator is <op>
- && il_matchtype(il, j, j + arity, IL_ITEM_OPERAND) // And we have correct number of operands
- ) {
- va_list ap;
- uint8_t check = true;
- uint8_t resultArity = arity;
- bool mask[16];
- va_start(ap, op2);
- for (uint32_t m = 0; m < arity; m++) {
- int checkzero = va_arg(ap, int);
- mask[m] = checkzero;
- if (checkzero) {
- resultArity -= 1;
- check = check && il->instr[j + m].d == 0;
- }
- }
- va_end(ap);
- if (check) {
- for (uint32_t m = 0; m < arity; m++) {
- if (mask[m]) { il->instr[j + m].type = IL_ITEM_PHANTOM_OPERAND; }
- }
- il->instr[j + arity].i = op2;
- il->instr[j + arity].arity = resultArity;
- return arity;
- } else {
- return 0;
- }
- } else {
- return 0;
- }
-}
-static uint8_t opop_roll(cff_CharstringIL *il, uint32_t j, int32_t op1, int32_t arity, int32_t op2,
- int32_t resultop) {
- if (j + 1 + arity >= il->length) return 0;
- cff_CharstringInstruction *current = &(il->instr[j]);
- cff_CharstringInstruction *nextop = &(il->instr[j + 1 + arity]);
- if (il_matchop(il, j, op1) // match this operator
- && il_matchtype(il, j + 1, j + 1 + arity, IL_ITEM_OPERAND) // match operands
- && il_matchop(il, j + 1 + arity, op2) // match next operator
- && current->arity + nextop->arity <= type2_argument_stack // stack is not full
- ) {
- current->type = IL_ITEM_PHANTOM_OPERATOR;
- nextop->i = resultop;
- nextop->arity += current->arity;
- return arity + 1;
- } else {
- return 0;
- }
-}
-static uint8_t hvlineto_roll(cff_CharstringIL *il, uint32_t j) {
- if (j + 3 >= il->length) return 0;
- cff_CharstringInstruction *current = &(il->instr[j]);
- // We will check whether operand <checkdelta> is zero
- // ODD EVEN -- current arity
- // hlineto X Y
- // vlineto Y X
- uint32_t checkdelta = ((bool)(current->arity & 1) ^ (bool)(current->i == op_vlineto) ? 1 : 2);
- if ((il_matchop(il, j, op_hlineto) || il_matchop(il, j, op_vlineto)) // a hlineto/vlineto
- && il_matchop(il, j + 3, op_rlineto) // followed by a lineto
- && il_matchtype(il, j + 1, j + 3, IL_ITEM_OPERAND) // have enough operands
- && il->instr[j + checkdelta].d == 0 // and it is a h/v
- && current->arity + 1 <= type2_argument_stack // we have enough stack space
- ) {
- il->instr[j + checkdelta].type = IL_ITEM_PHANTOM_OPERAND;
- il->instr[j].type = IL_ITEM_PHANTOM_OPERATOR;
- il->instr[j + 3].i = current->i;
- il->instr[j + 3].arity = current->arity + 1;
- return 3;
- } else {
- return 0;
- }
-}
-static uint8_t hvvhcurve_roll(cff_CharstringIL *il, uint32_t j) {
- if (!il_matchop(il, j, op_hvcurveto) && !il_matchop(il, j, op_vhcurveto)) return 0;
- cff_CharstringInstruction *current = &(il->instr[j]);
- // Exit in case of array not long enough or we have already ended
- if (j + 7 >= il->length || current->arity & 1) return 0;
- bool hvcase = (bool)((current->arity >> 2) & 1) ^ (bool)(current->i == op_hvcurveto);
- // We will check whether operand <checkdelta> is zero
- // ODD EVEN -- current arity divided by 4
- // hvcurveto X Y
- // vhcurveto Y X
- uint32_t checkdelta1 = hvcase ? 2 : 1;
- uint32_t checkdelta2 = hvcase ? 5 : 6;
- if (il_matchop(il, j + 7, op_rrcurveto) // followed by a curveto
- && il_matchtype(il, j + 1, j + 7, IL_ITEM_OPERAND) // have enough operands
- && il->instr[j + checkdelta1].d == 0 // and it is a h/v
- ) {
- if (il->instr[j + checkdelta2].d == 0 && current->arity + 4 <= type2_argument_stack) {
- // The Standard case
- il->instr[j + checkdelta1].type = IL_ITEM_PHANTOM_OPERAND;
- il->instr[j + checkdelta2].type = IL_ITEM_PHANTOM_OPERAND;
- il->instr[j].type = IL_ITEM_PHANTOM_OPERATOR;
- il->instr[j + 7].i = current->i;
- il->instr[j + 7].arity = current->arity + 4;
- return 7;
- } else if (current->arity + 5 <= type2_argument_stack) {
- // The trailing case
- il->instr[j + checkdelta1].type = IL_ITEM_PHANTOM_OPERAND;
- il->instr[j].type = IL_ITEM_PHANTOM_OPERATOR;
- il->instr[j + 7].i = current->i;
- il->instr[j + 7].arity = current->arity + 5;
- if (hvcase) {
- // Swap the last two operands because hvcurveto's trailing operand is in y-x order
- double t = il->instr[j + 5].d;
- il->instr[j + 5].d = il->instr[j + 6].d;
- il->instr[j + 6].d = t;
- }
- return 7;
- } else {
- return 0;
- }
- } else {
- return 0;
- }
-}
-static uint8_t hhvvcurve_roll(cff_CharstringIL *il, uint32_t j) {
- if (!il_matchop(il, j, op_hhcurveto) && !il_matchop(il, j, op_vvcurveto)) return 0;
- cff_CharstringInstruction *current = &(il->instr[j]);
- // Exit in case of array not long enough or we have already ended
- if (j + 7 >= il->length) return 0;
- bool hh = current->i == op_hhcurveto;
- uint32_t checkdelta1 = hh ? 2 : 1;
- uint32_t checkdelta2 = hh ? 6 : 5;
- if (il_matchop(il, j + 7, op_rrcurveto) // followed by a curveto
- && il_matchtype(il, j + 1, j + 7, IL_ITEM_OPERAND) // have enough operands
- && il->instr[j + checkdelta1].d == 0 // and it is a h/v
- && il->instr[j + checkdelta2].d == 0 // and it is a h/v
- && current->arity + 4 <= type2_argument_stack) {
- il->instr[j + checkdelta1].type = IL_ITEM_PHANTOM_OPERAND;
- il->instr[j + checkdelta2].type = IL_ITEM_PHANTOM_OPERAND;
- il->instr[j].type = IL_ITEM_PHANTOM_OPERATOR;
- il->instr[j + 7].i = current->i;
- il->instr[j + 7].arity = current->arity + 4;
- return 7;
- } else {
- return 0;
- }
-}
-static uint32_t nextstop(cff_CharstringIL *il, uint32_t j) {
- uint32_t delta = 0;
- for (; j + delta < il->length && il->instr[j + delta].type == IL_ITEM_OPERAND; delta++)
- ;
- return delta;
-}
-#define ROLL_FALL(x) \
- if ((r = (x))) return r;
-static uint8_t decideAdvance(cff_CharstringIL *il, uint32_t j, uint8_t optimizeLevel) {
- uint8_t r = 0;
- ROLL_FALL(zroll(il, j, op_rlineto, op_hlineto, 0, 1)); // rlineto -> hlineto
- ROLL_FALL(zroll(il, j, op_rlineto, op_vlineto, 1, 0)); // rlineto -> vlineto
- ROLL_FALL(zroll(il, j, op_rmoveto, op_hmoveto, 0, 1)); // rmoveto -> hmoveto
- ROLL_FALL(zroll(il, j, op_rmoveto, op_vmoveto, 1, 0)); // rmoveto -> vmoveto
- ROLL_FALL(zroll(il, j, op_rrcurveto, op_hvcurveto, 0, 1, 0, 0, 1, 0)); // rrcurveto->hvcurveto
- ROLL_FALL(zroll(il, j, op_rrcurveto, op_vhcurveto, 1, 0, 0, 0, 0, 1)); // rrcurveto->vhcurveto
- ROLL_FALL(zroll(il, j, op_rrcurveto, op_hhcurveto, 0, 1, 0, 0, 0, 1)); // rrcurveto->hhcurveto
- ROLL_FALL(zroll(il, j, op_rrcurveto, op_vvcurveto, 1, 0, 0, 0, 1, 0)); // rrcurveto->vvcurveto
- ROLL_FALL(opop_roll(il, j, op_rrcurveto, 6, op_rrcurveto, op_rrcurveto)); // rrcurveto roll
- ROLL_FALL(opop_roll(il, j, op_rrcurveto, 2, op_rlineto, op_rcurveline)); // rcurveline roll
- ROLL_FALL(opop_roll(il, j, op_rlineto, 6, op_rrcurveto, op_rlinecurve)); // rlinecurve roll
- ROLL_FALL(opop_roll(il, j, op_rlineto, 2, op_rlineto, op_rlineto)); // rlineto roll
- ROLL_FALL(opop_roll(il, j, op_hstemhm, 0, op_hintmask, op_hintmask)); // hintmask roll
- ROLL_FALL(opop_roll(il, j, op_vstemhm, 0, op_hintmask, op_hintmask)); // hintmask roll
- ROLL_FALL(opop_roll(il, j, op_hstemhm, 0, op_cntrmask, op_cntrmask)); // cntrmask roll
- ROLL_FALL(opop_roll(il, j, op_vstemhm, 0, op_cntrmask, op_cntrmask)); // cntrmask roll
- ROLL_FALL(hvlineto_roll(il, j)); // hlineto-vlineto roll
- ROLL_FALL(hhvvcurve_roll(il, j)); // hhcurveto-vvcurveto roll
- ROLL_FALL(hvvhcurve_roll(il, j)); // hvcurveto-vhcurveto roll
- ROLL_FALL(nextstop(il, j)); // move to next stop for operand match
- return 1; // nothing match
-}
-
-void cff_optimizeIL(cff_CharstringIL *il, const otfcc_Options *options) {
- if (!options->cff_rollCharString) return;
- uint32_t j = 0;
- while (j < il->length) {
- j += decideAdvance(il, j, options->cff_rollCharString);
- }
-}
-
-// IL to buffer conversion
-caryll_Buffer *cff_build_IL(cff_CharstringIL *il) {
- caryll_Buffer *blob = bufnew();
-
- for (uint16_t j = 0; j < il->length; j++) {
- switch (il->instr[j].type) {
- case IL_ITEM_OPERAND: {
- cff_mergeCS2Operand(blob, il->instr[j].d);
- break;
- }
- case IL_ITEM_OPERATOR: {
- cff_mergeCS2Operator(blob, il->instr[j].i);
- break;
- }
- case IL_ITEM_SPECIAL: {
- cff_mergeCS2Special(blob, il->instr[j].i);
- break;
- }
- default:
- break;
- }
- }
- return blob;
-}
-
-cff_CharstringIL *cff_shrinkIL(cff_CharstringIL *il) {
- cff_CharstringIL *out;
- NEW(out);
- for (uint16_t j = 0; j < il->length; j++) {
- switch (il->instr[j].type) {
- case IL_ITEM_OPERAND: {
- il_push_operand(out, il->instr[j].d);
- break;
- }
- case IL_ITEM_OPERATOR: {
- il_push_op(out, il->instr[j].i);
- break;
- }
- case IL_ITEM_SPECIAL: {
- il_push_special(out, il->instr[j].i);
- break;
- }
- default:
- break;
- }
- }
- return out;
-}
-
-void cff_ILmergeIL(cff_CharstringIL *self, cff_CharstringIL *il) {
- for (uint16_t j = 0; j < il->length; j++) {
- switch (il->instr[j].type) {
- case IL_ITEM_OPERAND: {
- il_push_operand(self, il->instr[j].d);
- break;
- }
- case IL_ITEM_OPERATOR: {
- il_push_op(self, il->instr[j].i);
- break;
- }
- case IL_ITEM_SPECIAL: {
- il_push_special(self, il->instr[j].i);
- break;
- }
- default:
- break;
- }
- }
-}
-
-bool instruction_eq(cff_CharstringInstruction *z1, cff_CharstringInstruction *z2) {
- if (z1->type == z2->type) {
- if (z1->type == IL_ITEM_OPERAND || z1->type == IL_ITEM_PHANTOM_OPERAND) {
- return z1->d == z2->d;
- } else {
- return z1->i == z2->i;
- }
- } else {
- return false;
- }
-}
-
-bool cff_ilEqual(cff_CharstringIL *a, cff_CharstringIL *b) {
- if (!a || !b) return false;
- if (a->length != b->length) return false;
- for (uint32_t j = 0; j < a->length; j++)
- if (!instruction_eq(a->instr + j, b->instr + j)) { return false; }
- return true;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.h
deleted file mode 100644
index 2c0f15f1661..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/charstring-il.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef CARYLL_cff_CHARSTRING_IL
-#define CARYLL_cff_CHARSTRING_IL
-
-#include "libcff.h"
-#include "otfcc/table/glyf.h"
-
-typedef enum {
- IL_ITEM_OPERAND,
- IL_ITEM_OPERATOR,
- IL_ITEM_SPECIAL,
- IL_ITEM_PHANTOM_OPERATOR,
- IL_ITEM_PHANTOM_OPERAND
-} cff_InstructionType;
-
-typedef struct {
- cff_InstructionType type;
- arity_t arity;
- union {
- double d; // for type == IL_ITEM_OPERAND, IL_ITEM_PHANTOM_OPERAND
- int32_t i; // otherwise
- };
-} cff_CharstringInstruction;
-
-typedef struct {
- uint32_t length;
- uint32_t free;
- cff_CharstringInstruction *instr;
-} cff_CharstringIL;
-
-bool instruction_eq(cff_CharstringInstruction *z1, cff_CharstringInstruction *z2);
-
-// basic ops
-cff_CharstringIL *cff_compileGlyphToIL(glyf_Glyph *g, uint16_t defaultWidth, uint16_t nominalWidth);
-void cff_optimizeIL(cff_CharstringIL *il, const otfcc_Options *options);
-cff_CharstringIL *cff_shrinkIL(cff_CharstringIL *il);
-void cff_ILmergeIL(cff_CharstringIL *self, cff_CharstringIL *il);
-caryll_Buffer *cff_build_IL(cff_CharstringIL *il);
-bool cff_ilEqual(cff_CharstringIL *a, cff_CharstringIL *b);
-
-void il_push_operand(cff_CharstringIL *il, double x);
-void il_push_op(cff_CharstringIL *il, int32_t op);
-void il_push_special(cff_CharstringIL *il, int32_t s);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/libcff.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/libcff.h
deleted file mode 100644
index a57c9eadc7a..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/libcff.h
+++ /dev/null
@@ -1,164 +0,0 @@
-#ifndef cff_DATA_TYPES
-#define cff_DATA_TYPES
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "support/util.h"
-
-#include "cff-util.h"
-#include "cff-value.h"
-#include "cff-index.h"
-#include "cff-dict.h"
-#include "cff-charset.h"
-#include "cff-fdselect.h"
-
-// Limits of Type2 CharSrting
-enum {
- type2_argument_stack = 48,
- type2_stem_hints = 96,
- type2_subr_nesting = 10,
- type2_charstring_len = 65535,
- type2_max_subrs = 65300,
- type2_transient_array = 32,
-};
-
-typedef struct {
- uint8_t major;
- uint8_t minor;
- uint8_t hdrSize;
- uint8_t offSize;
-} cff_Header;
-
-// CFF Encoding Structures
-typedef struct {
- uint8_t format;
- uint8_t ncodes;
- uint8_t *code;
-} cff_EncodingFormat0;
-
-typedef struct {
- uint8_t first;
- uint8_t nleft;
-} cff_EncodingRangeFormat1;
-
-typedef struct {
- uint8_t format;
- uint8_t nranges;
- cff_EncodingRangeFormat1 *range1;
-} cff_EncodingFormat1;
-
-typedef struct {
- uint8_t code;
- uint16_t glyph;
-} cff_EncodingSupplement;
-
-typedef struct {
- uint8_t nsup;
- cff_EncodingSupplement *supplement;
-} cff_EncodingNS;
-
-typedef struct {
- uint32_t t;
- union {
- cff_EncodingFormat0 f0;
- cff_EncodingFormat1 f1;
- cff_EncodingNS ns;
- };
-} cff_Encoding;
-
-// Predefined Encoding Types
-enum {
- cff_FONT_COMMON,
- cff_FONT_CID,
- cff_FONT_MM,
-};
-
-enum {
- cff_ENC_STANDARD,
- cff_ENC_EXPERT,
- cff_ENC_FORMAT0,
- cff_ENC_FORMAT1,
- cff_ENC_FORMAT_SUPPLEMENT,
- cff_ENC_UNSPECED,
-};
-
-typedef struct {
- cff_Value *stack;
- cff_Value transient[32];
- arity_t index;
- arity_t max;
- uint8_t stem;
-} cff_Stack;
-
-typedef struct {
- uint8_t *raw_data;
- uint32_t raw_length;
- uint16_t cnt_glyph;
-
- cff_Header head;
- cff_Index name;
- cff_Index top_dict;
- cff_Index string;
- cff_Index global_subr;
-
- cff_Encoding encodings; // offset
- cff_Charset charsets; // offset
- cff_FDSelect fdselect; // offset
- cff_Index char_strings; // offset
- cff_Index font_dict; // offset
- cff_Index local_subr; // offset
-} cff_File;
-
-// Outline builder method table
-typedef struct {
- void (*setWidth)(void *context, double width);
- void (*newContour)(void *context);
- void (*lineTo)(void *context, double x1, double y1);
- void (*curveTo)(void *context, double x1, double y1, double x2, double y2, double x3, double y3);
- void (*setHint)(void *context, bool isVertical, double position, double width);
- void (*setMask)(void *context, bool isContourMask, bool *mask);
- double (*getrand)(void *context);
-} cff_IOutlineBuilder;
-
-/*
- CFF -> Compact Font Format
- CS2 -> Type2 CharString
-*/
-
-extern const char *op_cff_name(uint32_t op);
-extern const char *op_cs2_name(uint32_t op);
-uint8_t cff_getStandardArity(uint32_t op);
-
-sds sdsget_cff_sid(uint16_t idx, cff_Index str);
-
-extern uint32_t cff_decodeCffToken(const uint8_t *start, cff_Value *val);
-extern uint32_t cff_decodeCS2Token(const uint8_t *start, cff_Value *val);
-
-// number, number, float
-extern caryll_Buffer *cff_encodeCffOperator(int32_t val);
-extern caryll_Buffer *cff_encodeCffInteger(int32_t val);
-extern caryll_Buffer *cff_encodeCffFloat(double val);
-
-/*
- Writer
-*/
-
-extern caryll_Buffer *cff_buildOffset(int32_t val);
-extern caryll_Buffer *cff_buildHeader(void);
-
-void cff_mergeCS2Int(caryll_Buffer *blob, int32_t val);
-void cff_mergeCS2Operator(caryll_Buffer *blob, int32_t val);
-void cff_mergeCS2Operand(caryll_Buffer *blob, double val);
-void cff_mergeCS2Special(caryll_Buffer *blob, uint8_t val);
-
-extern uint8_t cff_parseSubr(uint16_t idx, uint8_t *raw, cff_Index fdarray, cff_FDSelect select, cff_Index *subr);
-void cff_parseOutline(uint8_t *data, uint32_t len, cff_Index gsubr, cff_Index lsubr, cff_Stack *stack, void *outline,
- cff_IOutlineBuilder methods, const otfcc_Options *options);
-
-// File
-extern cff_File *cff_openStream(uint8_t *data, uint32_t len, const otfcc_Options *options);
-extern void cff_close(cff_File *file);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.c
deleted file mode 100644
index 5886d1bc5d6..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.c
+++ /dev/null
@@ -1,635 +0,0 @@
-#include "subr.h"
-/**
-Type 2 CharString subroutinizer.
-This program uses SEQUITUR (Nevill-Manning algorithm) to construct a CFG from the input sequence of
-opcodes (in the minimum unit of a operator call. That is, operand* operator special*.)
-Kieffer-Yang optimization is unnecessary, given that in almost all payloads, there are no repeating
-subroutines.
-*/
-
-#ifdef DEBUG
-static int nodesCreated = 0;
-static int nodesRemoved = 0;
-static int rulesCreated = 0;
-static int rulesRemoved = 0;
-#endif
-
-static cff_SubrNode *cff_new_Node() {
- cff_SubrNode *n;
- NEW(n);
- n->rule = NULL;
- n->terminal = NULL;
- n->guard = false;
- n->hard = false;
- n->prev = NULL;
- n->next = NULL;
-#ifdef DEBUG
- nodesCreated += 1;
-#endif
- return n;
-}
-
-static cff_SubrRule *cff_new_Rule() {
- cff_SubrRule *r;
- NEW(r);
- r->refcount = 0;
- r->guard = cff_new_Node();
- r->guard->prev = r->guard;
- r->guard->next = r->guard;
- r->guard->terminal = 0;
- r->guard->guard = true;
- r->guard->rule = r;
- r->next = NULL;
-#ifdef DEBUG
- rulesCreated += 1;
-#endif
- return r;
-}
-
-static void initSubrGraph(cff_SubrGraph *g) {
- g->root = cff_new_Rule();
- g->last = g->root;
- g->diagramIndex = NULL;
- g->totalRules = 0;
- g->totalCharStrings = 0;
- g->doSubroutinize = false;
-}
-
-static void clean_Node(cff_SubrNode *x) {
- if (x->rule) { x->rule->refcount -= 1; }
- x->rule = NULL;
- buffree(x->terminal);
- x->terminal = NULL;
-}
-static void delete_Node(cff_SubrNode *x) {
- if (!x) return;
- clean_Node(x);
-#ifdef DEBUG
- nodesRemoved += 1;
-#endif
- FREE(x);
-}
-
-static void deleteFullRule(cff_SubrRule *r) {
- if (r->guard) {
- for (cff_SubrNode *e = r->guard->next; e != r->guard;) {
- cff_SubrNode *next = e->next;
- if (e->terminal) buffree(e->terminal);
- FREE(e);
-#ifdef DEBUG
- nodesRemoved += 1;
-#endif
- e = next;
- }
- {
- FREE(r->guard);
-#ifdef DEBUG
- nodesRemoved += 1;
-#endif
- }
- }
-
- FREE(r);
-#ifdef DEBUG
- rulesRemoved += 1;
-#endif
-}
-
-static void disposeSubrGraph(cff_SubrGraph *g) {
- {
- cff_SubrRule *r = g->root;
- while (r) {
- cff_SubrRule *next = r->next;
- deleteFullRule(r);
- r = next;
- }
- }
- cff_SubrDiagramIndex *s, *tmp;
- HASH_ITER(hh, g->diagramIndex, s, tmp) {
- HASH_DEL(g->diagramIndex, s);
- FREE(s->key);
- FREE(s);
- }
-#ifdef DEBUG
- fprintf(stderr, "ALLOC: %d >< %d nodes\n", nodesCreated, nodesRemoved);
- fprintf(stderr, "ALLOC: %d >< %d rules\n", rulesCreated, rulesRemoved);
-#endif
-}
-
-caryll_standardRefType(cff_SubrGraph, cff_iSubrGraph, initSubrGraph, disposeSubrGraph);
-
-// Subroutinizer
-
-static void joinNodes(cff_SubrGraph *g, cff_SubrNode *m, cff_SubrNode *n);
-
-static uint8_t *getSingletHashKey(cff_SubrNode *n, size_t *len) {
- size_t l1;
- if (n->rule) {
- l1 = sizeof(n->rule->uniqueIndex);
- } else {
- l1 = buflen(n->terminal) * sizeof(uint8_t);
- }
-
- *len = 3 + l1 + 1;
- uint8_t *key;
- NEW(key, *len);
- key[0] = '1';
- key[1] = (n->rule ? '1' : '0');
- key[2] = '0';
- key[*len - 1] = 0;
-
- if (n->rule) {
- memcpy(key + 3, &(n->rule->uniqueIndex), l1);
- } else {
- memcpy(key + 3, n->terminal->data, l1);
- }
- return key;
-}
-
-static uint8_t *getDoubletHashKey(cff_SubrNode *n, size_t *len) {
- size_t l1, l2;
- if (n->rule) {
- l1 = sizeof(n->rule->uniqueIndex);
- } else {
- l1 = buflen(n->terminal) * sizeof(uint8_t);
- }
- if (n->next->rule) {
- l2 = sizeof(n->next->rule->uniqueIndex);
- } else {
- l2 = buflen(n->next->terminal) * sizeof(uint8_t);
- }
- *len = 3 + l1 + l2 + 1;
- uint8_t *key;
- NEW(key, *len);
- key[0] = '2';
- key[1] = (n->rule ? '1' : '0');
- key[2] = (n->next->rule ? '1' : '0');
- key[*len - 1] = 0;
- if (n->rule) {
- memcpy(key + 3, &(n->rule->uniqueIndex), l1);
- } else {
- memcpy(key + 3, n->terminal->data, l1);
- }
- if (n->next->rule) {
- memcpy(key + 3 + l1, &(n->next->rule->uniqueIndex), l2);
- } else {
- memcpy(key + 3 + l1, n->next->terminal->data, l2);
- }
- return key;
-}
-
-static cff_SubrNode *lastNodeOf(cff_SubrRule *r) {
- return r->guard->prev;
-}
-
-static cff_SubrNode *copyNode(cff_SubrNode *n) {
- cff_SubrNode *m = cff_new_Node();
- if (n->rule) {
- m->rule = n->rule;
- m->rule->refcount += 1;
- } else {
- m->terminal = bufnew();
- bufwrite_buf(m->terminal, n->terminal);
- }
- m->last = n->last;
- return m;
-}
-
-// checkNode: check whether node N is shrinkable
-static bool checkDoubletMatch(cff_SubrGraph *g, cff_SubrNode *n);
-
-static void unlinkNode(cff_SubrGraph *g, cff_SubrNode *a) {
- if (a->hard || a->guard) return;
- size_t len;
- uint8_t *key = getDoubletHashKey(a, &len);
- cff_SubrDiagramIndex *di = NULL;
- HASH_FIND(hh, g->diagramIndex, key, len, di);
- if (di && di->start == a) {
- HASH_DEL(g->diagramIndex, di);
- FREE(di->key);
- FREE(di);
- }
- FREE(key);
- key = getSingletHashKey(a, &len);
- di = NULL;
- HASH_FIND(hh, g->diagramIndex, key, len, di);
- if (di && di->start == a) {
- HASH_DEL(g->diagramIndex, di);
- FREE(di->key);
- FREE(di);
- }
- FREE(key);
- return;
-}
-
-static void addDoublet(cff_SubrGraph *g, cff_SubrNode *n) {
- if (!n || !n->next || n->guard || n->hard || n->next->hard || n->next->guard) return;
- size_t len;
- uint8_t *key = getDoubletHashKey(n, &len);
- cff_SubrDiagramIndex *di = NULL;
- HASH_FIND(hh, g->diagramIndex, key, len, di);
- if (!di) {
- NEW(di);
- di->arity = 2;
- di->key = key;
- di->start = n;
- HASH_ADD_KEYPTR(hh, g->diagramIndex, key, len, di);
- } else {
- di->start = n;
- FREE(key);
- }
-}
-static void addSinglet(cff_SubrGraph *g, cff_SubrNode *n) {
- if (!n || n->guard || n->hard) return;
- size_t len;
- uint8_t *key = getSingletHashKey(n, &len);
- cff_SubrDiagramIndex *di = NULL;
- HASH_FIND(hh, g->diagramIndex, key, len, di);
- if (!di) {
- NEW(di);
- di->arity = 1;
- di->key = key;
- di->start = n;
- HASH_ADD_KEYPTR(hh, g->diagramIndex, key, len, di);
- } else {
- di->start = n;
- FREE(key);
- }
-}
-
-static bool identNode(cff_SubrNode *m, cff_SubrNode *n) {
- if (m->rule)
- return (m->rule == n->rule);
- else if (n->rule)
- return false;
- else
- return (m->terminal->size == n->terminal->size &&
- strncmp((char *)m->terminal->data, (char *)n->terminal->data, m->terminal->size) == 0);
-}
-static void joinNodes(cff_SubrGraph *g, cff_SubrNode *m, cff_SubrNode *n) {
- if (m->next) {
- unlinkNode(g, m);
- if (n->prev && n->next && identNode(n->prev, n) && identNode(n, n->next)) { addDoublet(g, n); }
- if (m->prev && m->next && identNode(m->prev, m) && identNode(m, m->next)) { addDoublet(g, m->prev); }
- }
- m->next = n;
- n->prev = m;
-}
-static void xInsertNodeAfter(cff_SubrGraph *g, cff_SubrNode *m, cff_SubrNode *n) {
- joinNodes(g, n, m->next);
- joinNodes(g, m, n);
-}
-static void removeNodeFromGraph(cff_SubrGraph *g, cff_SubrNode *a) {
- joinNodes(g, a->prev, a->next);
- if (!a->guard) {
- unlinkNode(g, a);
- delete_Node(a);
- }
-}
-
-static void expandCall(cff_SubrGraph *g, cff_SubrNode *a) {
- cff_SubrNode *aprev = a->prev;
- cff_SubrNode *anext = a->next;
- cff_SubrRule *r = a->rule;
- cff_SubrNode *r1 = r->guard->next;
- cff_SubrNode *r2 = r->guard->prev;
-
- // We should move out [a, a'] from g's diagramIndex
- unlinkNode(g, a);
-
- joinNodes(g, aprev, r1);
- joinNodes(g, r2, anext);
- addDoublet(g, r2);
- // make this rule a stub.
- r->guard->prev = r->guard->next = r->guard;
- r->refcount -= 1;
- // remove call node
- delete_Node(a);
-}
-
-static void substituteDoubletWithRule(cff_SubrGraph *g, cff_SubrNode *m, cff_SubrRule *r) {
- cff_SubrNode *prev = m->prev;
- removeNodeFromGraph(g, prev->next);
- removeNodeFromGraph(g, prev->next);
- cff_SubrNode *invoke = cff_new_Node();
- invoke->rule = r;
- invoke->rule->refcount += 1;
- xInsertNodeAfter(g, prev, invoke);
- addDoublet(g, prev);
- addDoublet(g, invoke);
- addSinglet(g, invoke);
-
- if (!checkDoubletMatch(g, prev)) { checkDoubletMatch(g, prev->next); }
-}
-static void substituteSingletWithRule(cff_SubrGraph *g, cff_SubrNode *m, cff_SubrRule *r) {
- cff_SubrNode *prev = m->prev;
- removeNodeFromGraph(g, prev->next);
- cff_SubrNode *invoke = cff_new_Node();
- invoke->rule = r;
- invoke->rule->refcount += 1;
- xInsertNodeAfter(g, prev, invoke);
- addDoublet(g, prev);
- addDoublet(g, invoke);
- addSinglet(g, invoke);
-}
-
-static void processMatchDoublet(cff_SubrGraph *g, cff_SubrNode *m, cff_SubrNode *n) {
- cff_SubrRule *rule = NULL;
- if (m->prev->guard && m->next->next->guard) {
- // The match [m, m'] is a rule's full content
- rule = m->prev->rule;
- substituteDoubletWithRule(g, n, rule);
- } else {
- rule = cff_new_Rule();
- rule->uniqueIndex = g->totalRules;
- g->totalRules += 1;
- g->last->next = rule;
- g->last = rule;
- xInsertNodeAfter(g, lastNodeOf(rule), copyNode(m));
- xInsertNodeAfter(g, lastNodeOf(rule), copyNode(m->next));
- substituteDoubletWithRule(g, m, rule);
- substituteDoubletWithRule(g, n, rule);
- addDoublet(g, rule->guard->next);
- addSinglet(g, rule->guard->next);
- addSinglet(g, rule->guard->next->next);
- }
-
- if (rule->guard->next->rule && rule->guard->next->rule->refcount == 1) {
- // The rule is shrinkable.
- expandCall(g, rule->guard->next);
- }
-}
-static void processMatchSinglet(cff_SubrGraph *g, cff_SubrNode *m, cff_SubrNode *n) {
- cff_SubrRule *rule = NULL;
- if (m->prev->guard && m->next->guard) {
- // The match [m] is a rule's full content
- rule = m->prev->rule;
- substituteSingletWithRule(g, n, rule);
- } else {
- // Create a new rule
- rule = cff_new_Rule();
- rule->uniqueIndex = g->totalRules;
- g->totalRules += 1;
- g->last->next = rule;
- g->last = rule;
- xInsertNodeAfter(g, lastNodeOf(rule), copyNode(m));
- substituteSingletWithRule(g, m, rule);
- substituteSingletWithRule(g, n, rule);
- addSinglet(g, rule->guard->next);
- }
-}
-
-static bool checkDoubletMatch(cff_SubrGraph *g, cff_SubrNode *n) {
- if (n->guard || n->next->guard || n->hard || n->next->hard) return false;
- // printf("test "), printNode(n, false), printNode(n->next, true);
- size_t len;
- uint8_t *key = getDoubletHashKey(n, &len);
- cff_SubrDiagramIndex *di = NULL;
- HASH_FIND(hh, g->diagramIndex, key, len, di);
- if (!di) {
- NEW(di);
- di->arity = 2;
- di->key = key;
- di->start = n;
- HASH_ADD_KEYPTR(hh, g->diagramIndex, key, len, di);
- return false;
- } else if (di->arity == 2 && di->start != n && !di->start->guard && !di->start->next->guard) {
- FREE(key);
- processMatchDoublet(g, di->start, n);
- return true;
- } else {
- FREE(key);
- return true;
- }
-}
-
-static bool checkSingletMatch(cff_SubrGraph *g, cff_SubrNode *n) {
- if (n->guard || n->hard) return false;
- size_t len;
- uint8_t *key = getSingletHashKey(n, &len);
- cff_SubrDiagramIndex *di = NULL;
- HASH_FIND(hh, g->diagramIndex, key, len, di);
- if (!di) {
- NEW(di);
- di->arity = 1;
- di->key = key;
- di->start = n;
- HASH_ADD_KEYPTR(hh, g->diagramIndex, key, len, di);
- return false;
- } else if (di->arity == 1 && di->start != n && !di->start->guard) {
- FREE(key);
- processMatchSinglet(g, di->start, n);
- return true;
- } else {
- FREE(key);
- return false;
- }
-}
-
-static void appendNodeToGraph(cff_SubrGraph *g, cff_SubrNode *n) {
- cff_SubrNode *last = lastNodeOf(g->root);
- xInsertNodeAfter(g, last, n);
- if (g->doSubroutinize) {
- if (!checkDoubletMatch(g, last)) {
- if (buflen(n->terminal) > 15) checkSingletMatch(g, n);
- }
- }
-}
-
-void cff_insertILToGraph(cff_SubrGraph *g, cff_CharstringIL *il) {
- caryll_Buffer *blob = bufnew();
- bool flush = false;
- bool last = false;
- for (uint32_t j = 0; j < il->length; j++) {
- switch (il->instr[j].type) {
- case IL_ITEM_OPERAND: {
- if (flush) {
- cff_SubrNode *n = cff_new_Node();
- n->rule = NULL;
- n->terminal = blob;
- n->last = last;
- appendNodeToGraph(g, n);
- blob = bufnew();
- flush = false;
- }
- cff_mergeCS2Operand(blob, il->instr[j].d);
- break;
- }
-
- case IL_ITEM_OPERATOR: {
- cff_mergeCS2Operator(blob, il->instr[j].i);
- if (il->instr[j].i == op_endchar) { last = true; }
- flush = true;
- break;
- }
- case IL_ITEM_SPECIAL: {
- cff_mergeCS2Special(blob, il->instr[j].i);
- flush = true;
- break;
- }
- default:
- break;
- }
- }
- if (blob->size) {
- cff_SubrNode *n = cff_new_Node();
- n->rule = NULL;
- n->last = last;
- n->terminal = blob;
- appendNodeToGraph(g, n);
- }
- {
- blob = bufnew();
- cff_SubrNode *n = cff_new_Node();
- n->rule = NULL;
- n->terminal = blob;
- n->hard = true;
- appendNodeToGraph(g, n);
- g->totalCharStrings += 1;
- }
-}
-
-static void cff_statHeight(cff_SubrRule *r, uint32_t height) {
- if (height > r->height) r->height = height;
- // Stat the heights bottom-up.
- uint32_t effectiveLength = 0;
- for (cff_SubrNode *e = r->guard->next; e != r->guard; e = e->next) {
- if (e->rule) {
- cff_statHeight(e->rule, height + 1);
- effectiveLength += 4;
- } else {
- effectiveLength += e->terminal->size;
- }
- }
- r->effectiveLength = effectiveLength;
-}
-
-static void numberASubroutine(cff_SubrRule *r, uint32_t *current) {
- if (r->numbered) return;
- if (r->height >= type2_subr_nesting) return;
- if ((r->effectiveLength - 4) * (r->refcount - 1) - 4 <= 0) return;
- r->number = *current;
- (*current)++;
- r->numbered = true;
- for (cff_SubrNode *e = r->guard->next; e != r->guard; e = e->next) {
- if (e->rule) { numberASubroutine(e->rule, current); }
- }
-}
-static uint32_t cff_numberSubroutines(cff_SubrGraph *g) {
- uint32_t current = 0;
- for (cff_SubrNode *e = g->root->guard->next; e != g->root->guard; e = e->next) {
- if (e->rule) numberASubroutine(e->rule, &current);
- }
- return current;
-}
-
-static inline int32_t subroutineBias(int32_t cnt) {
- if (cnt < 1240)
- return 107;
- else if (cnt < 33900)
- return 1131;
- else
- return 32768;
-}
-
-static bool endsWithEndChar(cff_SubrRule *rule) {
- cff_SubrNode *node = lastNodeOf(rule);
- if (node->terminal) {
- return node->last;
- } else {
- return endsWithEndChar(node->rule);
- }
-}
-
-static void serializeNodeToBuffer(cff_SubrNode *node, caryll_Buffer *buf, caryll_Buffer *gsubrs, uint32_t maxGSubrs,
- caryll_Buffer *lsubrs, uint32_t maxLSubrs) {
- if (node->rule) {
- if (node->rule->numbered && node->rule->number < maxLSubrs + maxGSubrs &&
- node->rule->height < type2_subr_nesting) {
- // A call.
- caryll_Buffer *target;
- if (node->rule->number < maxLSubrs) {
- int32_t stacknum = node->rule->number - subroutineBias(maxLSubrs);
- target = lsubrs + node->rule->number;
- cff_mergeCS2Int(buf, stacknum);
- cff_mergeCS2Operator(buf, op_callsubr);
- } else {
- int32_t stacknum = node->rule->number - maxLSubrs - subroutineBias(maxGSubrs);
- target = gsubrs + (node->rule->number - maxLSubrs);
- cff_mergeCS2Int(buf, stacknum);
- cff_mergeCS2Operator(buf, op_callgsubr);
- }
- cff_SubrRule *r = node->rule;
- if (!r->printed) {
- r->printed = true;
- for (cff_SubrNode *e = r->guard->next; e != r->guard; e = e->next) {
- serializeNodeToBuffer(e, target, gsubrs, maxGSubrs, lsubrs, maxLSubrs);
- }
- if (!endsWithEndChar(r)) { cff_mergeCS2Operator(target, op_return); }
- }
- } else {
- // A call, but invalid
- // Inline its code.
- cff_SubrRule *r = node->rule;
- for (cff_SubrNode *e = r->guard->next; e != r->guard; e = e->next) {
- serializeNodeToBuffer(e, buf, gsubrs, maxGSubrs, lsubrs, maxLSubrs);
- }
- }
- } else {
- bufwrite_buf(buf, node->terminal);
- }
-}
-
-static caryll_Buffer *from_array(void *_context, uint32_t j) {
- caryll_Buffer *context = (caryll_Buffer *)_context;
- caryll_Buffer *blob = bufnew();
- bufwrite_buf(blob, context + j);
- return blob;
-}
-void cff_ilGraphToBuffers(cff_SubrGraph *g, caryll_Buffer **s, caryll_Buffer **gs, caryll_Buffer **ls,
- const otfcc_Options *options) {
- cff_statHeight(g->root, 0);
- uint32_t maxSubroutines = cff_numberSubroutines(g);
- logProgress("[libcff] Total %d subroutines extracted.", maxSubroutines);
- uint32_t maxLSubrs = maxSubroutines;
- uint32_t maxGSubrs = 0;
- {
- // balance
- if (maxLSubrs > type2_max_subrs) {
- maxLSubrs = type2_max_subrs;
- maxGSubrs = maxSubroutines - maxLSubrs;
- }
- if (maxGSubrs > type2_max_subrs) { maxGSubrs = type2_max_subrs; }
- uint32_t total = maxLSubrs + maxGSubrs;
- maxLSubrs = total / 2;
- maxGSubrs = total - maxLSubrs;
- }
- caryll_Buffer *charStrings, *gsubrs, *lsubrs;
- NEW(charStrings, g->totalCharStrings + 1);
- NEW(lsubrs, maxLSubrs + 1);
- NEW(gsubrs, maxGSubrs + 1);
- uint32_t j = 0;
- cff_SubrRule *r = g->root;
- for (cff_SubrNode *e = r->guard->next; e != r->guard; e = e->next) {
- serializeNodeToBuffer(e, charStrings + j, gsubrs, maxGSubrs, lsubrs, maxLSubrs);
- if (!e->rule && e->terminal && e->hard) { j++; }
- }
-
- cff_Index *is = cff_iIndex.fromCallback(charStrings, g->totalCharStrings, from_array);
- cff_Index *igs = cff_iIndex.fromCallback(gsubrs, maxGSubrs, from_array);
- cff_Index *ils = cff_iIndex.fromCallback(lsubrs, maxLSubrs, from_array);
-
- for (uint32_t j = 0; j < g->totalCharStrings; j++) {
- FREE((charStrings + j)->data);
- }
- for (uint32_t j = 0; j < maxGSubrs; j++) {
- FREE((gsubrs + j)->data);
- }
- for (uint32_t j = 0; j < maxLSubrs; j++) {
- FREE((lsubrs + j)->data);
- }
- FREE(charStrings), FREE(gsubrs), FREE(lsubrs);
-
- *s = cff_iIndex.build(is), *gs = cff_iIndex.build(igs), *ls = cff_iIndex.build(ils);
- cff_iIndex.free(is), cff_iIndex.free(igs), cff_iIndex.free(ils);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.h
deleted file mode 100644
index c5588d3305c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/libcff/subr.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef CARYLL_cff_SUBR_H
-#define CARYLL_cff_SUBR_H
-
-#include "libcff.h"
-#include "charstring-il.h"
-
-typedef struct __cff_SubrRule cff_SubrRule;
-typedef struct __cff_SubrNode cff_SubrNode;
-
-struct __cff_SubrNode {
- cff_SubrNode *prev;
- cff_SubrRule *rule;
- OWNING cff_SubrNode *next;
- OWNING caryll_Buffer *terminal;
- bool hard;
- bool guard;
- bool last;
-};
-
-struct __cff_SubrRule {
- bool printed;
- bool numbered;
- uint32_t number;
- uint32_t height;
- uint32_t uniqueIndex;
- uint16_t cffIndex;
- uint32_t refcount;
- uint32_t effectiveLength;
- OWNING cff_SubrNode *guard;
- OWNING cff_SubrRule *next;
-};
-
-typedef struct {
- uint8_t arity;
- uint8_t *key;
- cff_SubrNode *start;
- UT_hash_handle hh;
-} cff_SubrDiagramIndex;
-
-typedef struct {
- OWNING cff_SubrRule *root;
- cff_SubrRule *last;
- cff_SubrDiagramIndex *diagramIndex;
- uint32_t totalRules;
- uint32_t totalCharStrings;
- bool doSubroutinize;
-} cff_SubrGraph;
-
-extern caryll_RefElementInterface(cff_SubrGraph) cff_iSubrGraph;
-
-void cff_insertILToGraph(cff_SubrGraph *g, cff_CharstringIL *il);
-void cff_ilGraphToBuffers(cff_SubrGraph *g, caryll_Buffer **s, caryll_Buffer **gs, caryll_Buffer **ls,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/logger/logger.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/logger/logger.c
deleted file mode 100644
index 22091055f26..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/logger/logger.c
+++ /dev/null
@@ -1,171 +0,0 @@
-#include "support/util.h"
-#include "otfcc/logger.h"
-
-typedef struct Logger {
- otfcc_ILogger vtable;
- void *target;
- uint16_t level;
- uint16_t lastLoggedLevel;
- uint16_t levelCap;
- sds *indents;
- uint8_t verbosityLimit;
-} Logger;
-
-const char *otfcc_LoggerTypeNames[3] = {"[ERROR]", "[WARNING]", "[NOTE]"};
-
-static void loggerIndent(otfcc_ILogger *_self, const char *segment) {
- ((otfcc_ILogger *)_self)->indentSDS(_self, sdsnew(segment));
-}
-static void loggerIndentSDS(otfcc_ILogger *_self, MOVE sds segment) {
- Logger *self = (Logger *)_self;
- uint8_t newLevel = self->level + 1;
- if (newLevel > self->levelCap) {
- self->levelCap += self->levelCap / 2 + 1;
- RESIZE(self->indents, self->levelCap);
- }
- self->level++;
- self->indents[self->level - 1] = segment;
-}
-
-static void loggerDedent(otfcc_ILogger *_self) {
- Logger *self = (Logger *)_self;
- if (!self->level) return;
- sdsfree(self->indents[self->level - 1]);
- self->level -= 1;
- if (self->level < self->lastLoggedLevel) { self->lastLoggedLevel = self->level; }
-}
-static void loggerFinish(otfcc_ILogger *self) {
- self->logSDS(self, log_vl_progress + ((Logger *)self)->level, log_type_progress, sdsnew("Finish"));
- self->dedent(self);
-}
-static void loggerStart(otfcc_ILogger *self, const char *segment) {
- self->indentSDS(self, sdsnew(segment));
- self->logSDS(self, log_vl_progress + ((Logger *)self)->level, log_type_progress, sdsnew("Begin"));
-}
-static void loggerStartSDS(otfcc_ILogger *self, MOVE sds segment) {
- self->indentSDS(self, segment);
- self->logSDS(self, log_vl_progress + ((Logger *)self)->level, log_type_progress, sdsnew("Begin"));
-}
-static void loggerLog(otfcc_ILogger *self, uint8_t verbosity, otfcc_LoggerType type, const char *data) {
- self->logSDS(self, verbosity, type, sdsnew(data));
-}
-
-static void loggerLogSDS(otfcc_ILogger *_self, uint8_t verbosity, otfcc_LoggerType type, MOVE sds data) {
- Logger *self = (Logger *)_self;
- sds demand = sdsempty();
- for (uint16_t level = 0; level < self->level; level++) {
- if (level < self->lastLoggedLevel - 1) {
- for (size_t j = 0; j < sdslen(self->indents[level]); j++) {
- demand = sdscat(demand, " ");
- }
- if (level < self->lastLoggedLevel - 2) {
- demand = sdscat(demand, " | ");
- } else {
- demand = sdscat(demand, " |-");
- }
- } else {
- demand = sdscatfmt(demand, "%S : ", self->indents[level]);
- }
- }
- if (type < 3) {
- demand = sdscatfmt(demand, "%s %S", otfcc_LoggerTypeNames[type], data);
- } else {
- demand = sdscatfmt(demand, "%S", data);
- }
- sdsfree(data);
- if (verbosity <= self->verbosityLimit) {
- _self->getTarget(_self)->push(self->target, demand);
- self->lastLoggedLevel = self->level;
- } else {
- sdsfree(demand);
- }
-}
-
-static otfcc_ILoggerTarget *loggerGetTarget(otfcc_ILogger *_self) {
- Logger *self = (Logger *)_self;
- return (otfcc_ILoggerTarget *)self->target;
-}
-
-static void loggerSetVerbosity(otfcc_ILogger *_self, uint8_t verbosity) {
- Logger *self = (Logger *)_self;
- self->verbosityLimit = verbosity;
-}
-
-static INLINE void loggerDispose(otfcc_ILogger *_self) {
- Logger *self = (Logger *)_self;
- if (!self) return;
- otfcc_ILoggerTarget *target = _self->getTarget(_self);
- target->dispose(target);
- for (uint16_t level = 0; level < self->level; level++) {
- sdsfree(self->indents[level]);
- }
- FREE(self->indents);
- FREE(self);
-}
-
-const otfcc_ILogger VTABLE_LOGGER = {.dispose = loggerDispose,
- .indent = loggerIndent,
- .indentSDS = loggerIndentSDS,
- .start = loggerStart,
- .startSDS = loggerStartSDS,
- .log = loggerLog,
- .logSDS = loggerLogSDS,
- .dedent = loggerDedent,
- .finish = loggerFinish,
- .getTarget = loggerGetTarget,
- .setVerbosity = loggerSetVerbosity};
-
-otfcc_ILogger *otfcc_newLogger(otfcc_ILoggerTarget *target) {
- Logger *logger;
- NEW(logger);
- logger->target = target;
- logger->vtable = VTABLE_LOGGER;
- return (otfcc_ILogger *)logger;
-}
-
-// STDERR logger target
-
-typedef struct StderrTarget { otfcc_ILoggerTarget vtable; } StderrTarget;
-
-static void stderrTargetDispose(otfcc_ILoggerTarget *_self) {
- StderrTarget *self = (StderrTarget *)_self;
- if (!self) return;
- FREE(self);
-}
-
-static void stderrTargetPush(otfcc_ILoggerTarget *_self, MOVE sds data) {
- fprintf(stderr, "%s", data);
- if (data[sdslen(data) - 1] != '\n') fprintf(stderr, "\n");
- sdsfree(data);
-}
-
-const otfcc_ILoggerTarget VTABLE_STDERR_TARGET = {.dispose = stderrTargetDispose, .push = stderrTargetPush};
-
-otfcc_ILoggerTarget *otfcc_newStdErrTarget() {
- StderrTarget *target;
- NEW(target);
- target->vtable = VTABLE_STDERR_TARGET;
- return (otfcc_ILoggerTarget *)target;
-}
-
-// Empty logger target
-
-typedef struct EmptyTarget { otfcc_ILoggerTarget vtable; } EmptyTarget;
-static void emptyTargetDispose(otfcc_ILoggerTarget *_self) {
- StderrTarget *self = (StderrTarget *)_self;
- if (!self) return;
- FREE(self);
-}
-
-static void emptyTargetPush(otfcc_ILoggerTarget *_self, MOVE sds data) {
- sdsfree(data);
-}
-
-const otfcc_ILoggerTarget VTABLE_EMPTY_TARGET = {.dispose = emptyTargetDispose, .push = emptyTargetPush};
-
-otfcc_ILoggerTarget *otfcc_newEmptyTarget() {
- StderrTarget *target;
- NEW(target);
- target->vtable = VTABLE_EMPTY_TARGET;
- return (otfcc_ILoggerTarget *)target;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/otf-reader.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/otf-reader.c
deleted file mode 100644
index 58405749172..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/otf-reader.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "support/util.h"
-#include "otfcc/font.h"
-#include "table/all.h"
-
-#include "unconsolidate.h"
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-static otfcc_font_subtype decideFontSubtypeOTF(otfcc_SplineFontContainer *sfnt, uint32_t index) {
- otfcc_Packet packet = sfnt->packets[index];
- FOR_TABLE_SILENT(OTFCC_CHR('C','F','F',' '), table) {
- return FONTTYPE_CFF;
- }
- return FONTTYPE_TTF;
-}
-
-static otfcc_Font *readOtf(void *_sfnt, uint32_t index, const otfcc_Options *options) {
- otfcc_SplineFontContainer *sfnt = (otfcc_SplineFontContainer *)_sfnt;
- if (sfnt->count - 1 < index) {
- return NULL;
- } else {
- otfcc_Font *font = otfcc_iFont.create();
- otfcc_Packet packet = sfnt->packets[index];
- font->subtype = decideFontSubtypeOTF(sfnt, index);
- font->fvar = otfcc_readFvar(packet, options);
- font->head = otfcc_readHead(packet, options);
- font->maxp = otfcc_readMaxp(packet, options);
- font->name = otfcc_readName(packet, options);
- font->meta = otfcc_readMeta(packet, options);
- font->OS_2 = otfcc_readOS_2(packet, options);
- font->post = otfcc_readPost(packet, options);
- font->hhea = otfcc_readHhea(packet, options);
- font->cmap = otfcc_readCmap(packet, options);
- if (font->subtype == FONTTYPE_TTF) {
- font->hmtx = otfcc_readHmtx(packet, options, font->hhea, font->maxp);
- font->vhea = otfcc_readVhea(packet, options);
- if (font->vhea) font->vmtx = otfcc_readVmtx(packet, options, font->vhea, font->maxp);
- font->fpgm = otfcc_readFpgmPrep(packet, options, OTFCC_CHR('f','p','g','m'));
- font->prep = otfcc_readFpgmPrep(packet, options, OTFCC_CHR('p','r','e','p'));
- font->cvt_ = otfcc_readCvt(packet, options, OTFCC_CHR('c','v','t',' '));
- font->gasp = otfcc_readGasp(packet, options);
- font->VDMX = otfcc_readVDMX(packet, options);
- font->LTSH = otfcc_readLTSH(packet, options);
-
- GlyfIOContext ctx = {.locaIsLong = font->head->indexToLocFormat,
- .numGlyphs = font->maxp->numGlyphs,
- .nPhantomPoints = 4, // Since MS rasterizer v1.7,
- // it would always add 4 phantom points
- .fvar = font->fvar};
- font->glyf = otfcc_readGlyf(packet, options, &ctx);
- } else {
- table_CFFAndGlyf cffpr = otfcc_readCFFAndGlyfTables(packet, options, font->head);
- font->CFF_ = cffpr.meta;
- font->glyf = cffpr.glyphs;
- font->vhea = otfcc_readVhea(packet, options);
- if (font->vhea) {
- font->vmtx = otfcc_readVmtx(packet, options, font->vhea, font->maxp);
- font->VORG = otfcc_readVORG(packet, options);
- }
- }
- if (font->glyf) {
- font->GSUB = otfcc_readOtl(packet, options, OTFCC_CHR('G','S','U','B'), font->glyf->length);
- font->GPOS = otfcc_readOtl(packet, options, OTFCC_CHR('G','P','O','S'), font->glyf->length);
- font->GDEF = otfcc_readGDEF(packet, options);
- }
- font->BASE = otfcc_readBASE(packet, options);
-
- // Color font
- font->CPAL = otfcc_readCPAL(packet, options);
- font->COLR = otfcc_readCOLR(packet, options);
- font->SVG_ = otfcc_readSVG(packet, options);
-
- // VTT TSI entries
- font->TSI_01 = otfcc_readTSI(packet, options, OTFCC_CHR('T','S','I','0'), OTFCC_CHR('T','S','I','1'));
- font->TSI_23 = otfcc_readTSI(packet, options, OTFCC_CHR('T','S','I','2'), OTFCC_CHR('T','S','I','3'));
- font->TSI5 = otfcc_readTSI5(packet, options);
-
- otfcc_unconsolidateFont(font, options);
- return font;
- }
-}
-static INLINE void freeReader(otfcc_IFontBuilder *self) {
- free(self);
-}
-otfcc_IFontBuilder *otfcc_newOTFReader() {
- otfcc_IFontBuilder *reader;
- NEW(reader);
- reader->read = readOtf;
- reader->free = freeReader;
- return reader;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.c
deleted file mode 100644
index f267d730bad..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.c
+++ /dev/null
@@ -1,399 +0,0 @@
-#include "unconsolidate.h"
-#include "support/util.h"
-#include "support/aglfn/aglfn.h"
-#include "support/sha1/sha1.h"
-
-typedef struct {
- uint8_t hash[SHA1_BLOCK_SIZE];
-} GlyphHash;
-static void hashVQS(caryll_Buffer *buf, vq_Segment s) {
- bufwrite8(buf, s.type);
- switch (s.type) {
- case VQ_STILL:
- bufwrite32b(buf, otfcc_to_fixed(s.val.still));
- break;
- case VQ_DELTA:
- bufwrite32b(buf, otfcc_to_fixed(s.val.delta.quantity));
- bufwrite32b(buf, (uint32_t)s.val.delta.region->dimensions);
- for (size_t j = 0; j < s.val.delta.region->dimensions; j++) {
- const vq_AxisSpan *span = &s.val.delta.region->spans[j];
- bufwrite32b(buf, otfcc_to_f2dot14(span->start));
- bufwrite32b(buf, otfcc_to_f2dot14(span->peak));
- bufwrite32b(buf, otfcc_to_f2dot14(span->end));
- }
- }
-}
-
-static void hashVQ(caryll_Buffer *buf, VQ x) {
- bufwrite32b(buf, otfcc_to_fixed(x.kernel));
- bufwrite32b(buf, (uint32_t)x.shift.length);
- for (size_t j = 0; j < x.shift.length; j++) {
- hashVQS(buf, x.shift.items[j]);
- }
-}
-
-static GlyphHash nameGlyphByHash(glyf_Glyph *g, table_glyf *glyf) {
- caryll_Buffer *buf = bufnew();
- bufwrite8(buf, 'H');
- hashVQ(buf, g->advanceWidth);
- bufwrite8(buf, 'h');
- hashVQ(buf, g->horizontalOrigin);
- bufwrite8(buf, 'V');
- hashVQ(buf, g->advanceHeight);
- bufwrite8(buf, 'v');
- hashVQ(buf, g->verticalOrigin);
- // contours
- bufwrite8(buf, 'C');
- bufwrite8(buf, '(');
- for (shapeid_t j = 0; j < g->contours.length; j++) {
- bufwrite8(buf, '(');
- glyf_Contour *c = &g->contours.items[j];
- for (shapeid_t k = 0; k < c->length; k++) {
- hashVQ(buf, c->items[k].x);
- hashVQ(buf, c->items[k].y);
- bufwrite8(buf, c->items[k].onCurve ? 1 : 0);
- }
- bufwrite8(buf, ')');
- }
- bufwrite8(buf, ')');
- // references
- bufwrite8(buf, 'R');
- bufwrite8(buf, '(');
- for (shapeid_t j = 0; j < g->references.length; j++) {
- glyf_ComponentReference *r = &g->references.items[j];
- GlyphHash h = nameGlyphByHash(glyf->items[r->glyph.index], glyf);
- bufwrite_bytes(buf, SHA1_BLOCK_SIZE, h.hash);
- hashVQ(buf, r->x);
- hashVQ(buf, r->y);
- bufwrite32b(buf, otfcc_to_f2dot14(r->a));
- bufwrite32b(buf, otfcc_to_f2dot14(r->b));
- bufwrite32b(buf, otfcc_to_f2dot14(r->c));
- bufwrite32b(buf, otfcc_to_f2dot14(r->d));
- }
- bufwrite8(buf, ')');
- // stemH, stemV
- bufwrite8(buf, 's'), bufwrite8(buf, 'H');
- bufwrite8(buf, '(');
- for (shapeid_t j = 0; j < g->stemH.length; j++) {
- bufwrite32b(buf, otfcc_to_fixed(g->stemH.items[j].position));
- bufwrite32b(buf, otfcc_to_fixed(g->stemH.items[j].width));
- }
- bufwrite8(buf, ')');
- bufwrite8(buf, 's'), bufwrite8(buf, 'V');
- bufwrite8(buf, '(');
- for (shapeid_t j = 0; j < g->stemV.length; j++) {
- bufwrite32b(buf, otfcc_to_fixed(g->stemV.items[j].position));
- bufwrite32b(buf, otfcc_to_fixed(g->stemV.items[j].width));
- }
- bufwrite8(buf, ')');
- // hintmask, contourmask
- bufwrite8(buf, 'm'), bufwrite8(buf, 'H');
- bufwrite8(buf, '(');
- for (shapeid_t j = 0; j < g->hintMasks.length; j++) {
- bufwrite16b(buf, g->hintMasks.items[j].contoursBefore);
- bufwrite16b(buf, g->hintMasks.items[j].pointsBefore);
- for (shapeid_t k = 0; k < g->stemH.length; k++) {
- bufwrite8(buf, g->hintMasks.items[j].maskH[k]);
- }
- for (shapeid_t k = 0; k < g->stemV.length; k++) {
- bufwrite8(buf, g->hintMasks.items[j].maskV[k]);
- }
- }
- bufwrite8(buf, ')');
- bufwrite8(buf, 'm'), bufwrite8(buf, 'C');
- bufwrite8(buf, '(');
- for (shapeid_t j = 0; j < g->contourMasks.length; j++) {
- bufwrite16b(buf, g->contourMasks.items[j].contoursBefore);
- bufwrite16b(buf, g->contourMasks.items[j].pointsBefore);
- for (shapeid_t k = 0; k < g->stemH.length; k++) {
- bufwrite8(buf, g->contourMasks.items[j].maskH[k]);
- }
- for (shapeid_t k = 0; k < g->stemV.length; k++) {
- bufwrite8(buf, g->contourMasks.items[j].maskV[k]);
- }
- }
- bufwrite8(buf, ')');
- // instructions
- bufwrite8(buf, 'I');
- bufwrite32b(buf, g->instructionsLength);
- bufwrite_bytes(buf, g->instructionsLength, g->instructions);
- // Generate SHA1
- SHA1_CTX ctx;
- uint8_t hash[SHA1_BLOCK_SIZE];
- sha1_init(&ctx);
- sha1_update(&ctx, buf->data, buflen(buf));
- sha1_final(&ctx, hash);
- GlyphHash h;
- for (uint16_t j = 0; j < SHA1_BLOCK_SIZE; j++) {
- h.hash[j] = hash[j];
- }
- buffree(buf);
- return h;
-}
-
-// Unconsolidation: Remove redundent data and de-couple internal data
-// It does these things:
-// 1. Merge hmtx data into glyf
-// 2. Replace all glyph IDs into glyph names. Note all glyph references with
-// same name whare one unique string entity stored in font->glyph_order.
-// (Separate?)
-static otfcc_GlyphOrder *createGlyphOrder(otfcc_Font *font, const otfcc_Options *options) {
- otfcc_GlyphOrder *glyph_order = GlyphOrder.create();
-
- glyphid_t numGlyphs = font->glyf->length;
- sds prefix;
- if (options->glyph_name_prefix) {
- prefix = sdsnew(options->glyph_name_prefix);
- } else {
- prefix = sdsempty();
- }
-
- // pass 1: Map to existing glyph names
- for (glyphid_t j = 0; j < numGlyphs; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- if (options->name_glyphs_by_hash) { // name by hash
- GlyphHash h = nameGlyphByHash(g, font->glyf);
- sds gname = sdsempty();
- for (uint16_t j = 0; j < SHA1_BLOCK_SIZE; j++) {
- if (!(j % 4) && (j / 4)) {
- gname = sdscatprintf(gname, "-%02X", h.hash[j]);
- } else {
- gname = sdscatprintf(gname, "%02X", h.hash[j]);
- }
- }
- if (GlyphOrder.lookupName(glyph_order, gname)) {
- // found duplicate glyph
- glyphid_t n = 2;
- bool stillIn = false;
- do {
- if (stillIn) n += 1;
- sds newname = sdscatprintf(sdsempty(), "%s-%s%d", gname, prefix, n);
- stillIn = GlyphOrder.lookupName(glyph_order, newname);
- sdsfree(newname);
- } while (stillIn);
- sds newname = sdscatprintf(sdsempty(), "%s-%s%d", gname, prefix, n);
- sds sharedName = GlyphOrder.setByGID(glyph_order, j, newname);
- if (g->name) sdsfree(g->name);
- g->name = sdsdup(sharedName);
- sdsfree(gname);
- } else {
- sds sharedName = GlyphOrder.setByGID(glyph_order, j, gname);
- if (g->name) sdsfree(g->name);
- g->name = sdsdup(sharedName);
- }
- } else if (options->ignore_glyph_order || options->name_glyphs_by_gid) {
- // ignore built-in names
- // pass
- } else if (g->name) {
- sds gname = sdscatprintf(sdsempty(), "%s%s", prefix, g->name);
- sds sharedName = GlyphOrder.setByGID(glyph_order, j, gname);
- if (g->name) sdsfree(g->name);
- g->name = sdsdup(sharedName);
- }
- }
-
- // pass 2: Map to `post` names
- if (font->post != NULL && font->post->post_name_map != NULL && !options->ignore_glyph_order &&
- !options->name_glyphs_by_gid) {
- otfcc_GlyphOrderEntry *s, *tmp;
- HASH_ITER(hhID, font->post->post_name_map->byGID, s, tmp) {
- sds gname = sdscatprintf(sdsempty(), "%s%s", prefix, s->name);
- GlyphOrder.setByGID(glyph_order, s->gid, gname);
- }
- }
-
- // pass 3: Map to AGLFN & Unicode
- if (font->cmap && !options->name_glyphs_by_gid) {
- otfcc_GlyphOrder *aglfn = GlyphOrder.create();
- aglfn_setupNames(aglfn);
-
- cmap_Entry *s;
- foreach_hash(s, font->cmap->unicodes) if (s->glyph.index > 0) {
- sds name = NULL;
- if (s->unicode > 0 && s->unicode < 0xFFFF) {
- GlyphOrder.nameAField_Shared(aglfn, s->unicode, &name);
- }
- if (name == NULL) {
- name = sdscatprintf(sdsempty(), "%suni%04X", prefix, s->unicode);
- } else {
- name = sdscatprintf(sdsempty(), "%s%s", prefix, name);
- }
- GlyphOrder.setByGID(glyph_order, s->glyph.index, name);
- }
-
- GlyphOrder.free(aglfn);
- }
-
- // pass 4 : Map to GID
- for (glyphid_t j = 0; j < numGlyphs; j++) {
- sds name;
- if (j > 1) {
- name = sdscatfmt(sdsempty(), "%sglyph%u", prefix, j);
- } else if (j == 1) {
- // GID 1 may often be ".null"
- if (font->glyf->items[1] && !font->glyf->items[1]->contours.length &&
- !font->glyf->items[1]->references.length) {
- name = sdscatfmt(sdsempty(), "%s.null", prefix);
- } else {
- name = sdscatfmt(sdsempty(), "%sglyph%u", prefix, j);
- }
- } else {
- name = sdscatfmt(sdsempty(), "%s.notdef", prefix);
- }
- GlyphOrder.setByGID(glyph_order, j, name);
- }
-
- sdsfree(prefix);
- return glyph_order;
-}
-
-static void nameGlyphs(otfcc_Font *font, otfcc_GlyphOrder *gord) {
- if (!gord) return;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- sds glyphName = NULL;
- GlyphOrder.nameAField_Shared(gord, j, &glyphName);
- if (g->name) sdsfree(g->name);
- g->name = sdsdup(glyphName);
- }
-}
-
-static void unconsolidate_chaining(otfcc_Font *font, otl_Lookup *lookup, table_OTL *table) {
- tableid_t totalRules = 0;
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- if (!lookup->subtables.items[j]) continue;
- if (lookup->subtables.items[j]->chaining.type == otl_chaining_poly) {
- totalRules += lookup->subtables.items[j]->chaining.rulesCount;
- } else if (lookup->subtables.items[j]->chaining.type == otl_chaining_canonical) {
- totalRules += 1;
- }
- }
- otl_SubtableList newsts;
- otl_iSubtableList.init(&newsts);
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- if (!lookup->subtables.items[j]) continue;
- if (lookup->subtables.items[j]->chaining.type == otl_chaining_poly) {
- for (tableid_t k = 0; k < lookup->subtables.items[j]->chaining.rulesCount; k++) {
- otl_Subtable *st;
- NEW(st);
- st->chaining.type = otl_chaining_canonical;
- // transfer ownership of rule
- st->chaining.rule = *(lookup->subtables.items[j]->chaining.rules[k]);
- FREE(lookup->subtables.items[j]->chaining.rules[k]);
- otl_iSubtableList.push(&newsts, st);
- }
- FREE(lookup->subtables.items[j]->chaining.rules);
- FREE(lookup->subtables.items[j]);
- } else if (lookup->subtables.items[j]->chaining.type == otl_chaining_canonical) {
- otl_Subtable *st;
- NEW(st);
- st->chaining.type = otl_chaining_canonical;
- st->chaining.rule = lookup->subtables.items[j]->chaining.rule;
- otl_iSubtableList.push(&newsts, st);
- lookup->subtables.items[j] = NULL;
- }
- }
- otl_iSubtableList.disposeDependent(&lookup->subtables, lookup);
- lookup->subtables = newsts;
-}
-
-static void expandChain(otfcc_Font *font, otl_Lookup *lookup, table_OTL *table) {
- switch (lookup->type) {
- case otl_type_gsub_chaining:
- case otl_type_gpos_chaining:
- unconsolidate_chaining(font, lookup, table);
- break;
- default:
- break;
- }
-}
-
-static void expandChainingLookups(otfcc_Font *font) {
- if (font->GSUB) {
- for (uint32_t j = 0; j < font->GSUB->lookups.length; j++) {
- otl_Lookup *lookup = font->GSUB->lookups.items[j];
- expandChain(font, lookup, font->GSUB);
- }
- }
- if (font->GPOS) {
- for (uint32_t j = 0; j < font->GPOS->lookups.length; j++) {
- otl_Lookup *lookup = font->GPOS->lookups.items[j];
- expandChain(font, lookup, font->GPOS);
- }
- }
-}
-
-static void mergeHmtx(otfcc_Font *font) {
- // Merge hmtx table into glyf.
- if (!(font->hhea && font->hmtx && font->glyf)) return;
- uint32_t count_a = font->hhea->numberOfMetrics;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- const pos_t adw = font->hmtx->metrics[(j < count_a ? j : count_a - 1)].advanceWidth;
- const pos_t lsb =
- j < count_a ? font->hmtx->metrics[j].lsb : font->hmtx->leftSideBearing[j - count_a];
-
- iVQ.inplacePlus(&g->advanceWidth, iVQ.createStill(adw));
- iVQ.inplacePlus(&g->horizontalOrigin, iVQ.createStill(-lsb + g->stat.xMin));
- }
- table_iHmtx.free(font->hmtx);
- font->hmtx = NULL;
-}
-
-static void mergeVmtx(otfcc_Font *font) {
- // Merge vmtx table into glyf.
- if (!(font->vhea && font->vmtx && font->glyf)) return;
- uint32_t count_a = font->vhea->numOfLongVerMetrics;
-
- pos_t *vorgs = NULL;
-
- if (font->VORG) {
- NEW_CLEAN_N(vorgs, font->glyf->length);
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- vorgs[j] = font->VORG->defaultVerticalOrigin;
- }
- for (glyphid_t j = 0; j < font->VORG->numVertOriginYMetrics; j++) {
- if (!(font->VORG->entries[j].gid < font->glyf->length)) continue;
- vorgs[font->VORG->entries[j].gid] = font->VORG->entries[j].verticalOrigin;
- }
- table_iVORG.free(font->VORG);
- font->VORG = NULL;
- }
-
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- const pos_t adh = font->vmtx->metrics[(j < count_a ? j : count_a - 1)].advanceHeight;
- const pos_t tsb =
- j < count_a ? font->vmtx->metrics[j].tsb : font->vmtx->topSideBearing[j - count_a];
-
- iVQ.inplacePlus(&g->advanceHeight, iVQ.createStill(adh));
- iVQ.inplacePlus(&g->verticalOrigin, iVQ.createStill(vorgs ? vorgs[j] : tsb + g->stat.yMax));
- }
-
- if (vorgs) FREE(vorgs);
- table_iVmtx.free(font->vmtx);
- font->vmtx = NULL;
-}
-
-static void mergeLTSH(otfcc_Font *font) {
- if (font->glyf && font->LTSH) {
- for (glyphid_t j = 0; j < font->glyf->length && j < font->LTSH->numGlyphs; j++) {
- font->glyf->items[j]->yPel = font->LTSH->yPels[j];
- }
- }
-}
-
-void otfcc_unconsolidateFont(otfcc_Font *font, const otfcc_Options *options) {
- // Merge metrics
- mergeHmtx(font);
- mergeVmtx(font);
- mergeLTSH(font);
- // expand chaining lookups
- expandChainingLookups(font);
- // Name glyphs
- if (font->glyf) {
- otfcc_GlyphOrder *gord = createGlyphOrder(font, options);
- nameGlyphs(font, gord);
- GlyphOrder.free(gord);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.h
deleted file mode 100644
index fa0d1172fb9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-reader/unconsolidate.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef CARYLL_OTF_READER_UNCONSOLIDATE_H
-#define CARYLL_OTF_READER_UNCONSOLIDATE_H
-
-#include "otfcc/font.h"
-#include "table/all.h"
-
-void otfcc_unconsolidateFont(otfcc_Font *font, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/otf-writer.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/otf-writer.c
deleted file mode 100644
index 4da56e0ed91..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/otf-writer.c
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "support/util.h"
-#include "otfcc/font.h"
-#include "table/all.h"
-#include "otfcc/sfnt-builder.h"
-#include "stat.h"
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-static void *serializeToOTF(otfcc_Font *font, const otfcc_Options *options) {
- // do stat before serialize
- otfcc_statFont(font, options);
-
- otfcc_SFNTBuilder *builder =
- otfcc_newSFNTBuilder(font->subtype == FONTTYPE_CFF ? OTFCC_CHR('O','T','T','O') : 0x00010000, options);
- // Outline data
- if (font->subtype == FONTTYPE_TTF) {
- table_GlyfAndLocaBuffers pair = otfcc_buildGlyf(font->glyf, font->head, options);
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('g','l','y','f'), pair.glyf);
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('l','o','c','a'), pair.loca);
- } else {
- table_CFFAndGlyf r = {font->CFF_, font->glyf};
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('C','F','F',' '), otfcc_buildCFF(r, options));
- }
-
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('h','e','a','d'), otfcc_buildHead(font->head, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('h','h','e','a'), otfcc_buildHhea(font->hhea, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('O','S','/','2'), otfcc_buildOS_2(font->OS_2, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('m','a','x','p'), otfcc_buildMaxp(font->maxp, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('n','a','m','e'), otfcc_buildName(font->name, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('m','e','t','a'), otfcc_buildMeta(font->meta, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('p','o','s','t'),
- otfcc_buildPost(font->post, font->glyph_order, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('c','m','a','p'), otfcc_buildCmap(font->cmap, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('g','a','s','p'), otfcc_buildGasp(font->gasp, options));
-
- if (font->subtype == FONTTYPE_TTF) {
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('f','p','g','m'), otfcc_buildFpgmPrep(font->fpgm, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('p','r','e','p'), otfcc_buildFpgmPrep(font->prep, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('c','v','t',' '), otfcc_buildCvt(font->cvt_, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('L','T','S','H'), otfcc_buildLTSH(font->LTSH, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('V','D','M','X'), otfcc_buildVDMX(font->VDMX, options));
- }
-
- if (font->hhea && font->maxp && font->hmtx) {
- uint16_t hmtx_counta = font->hhea->numberOfMetrics;
- uint16_t hmtx_countk = font->maxp->numGlyphs - font->hhea->numberOfMetrics;
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('h','m','t','x'),
- otfcc_buildHmtx(font->hmtx, hmtx_counta, hmtx_countk, options));
- }
-
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('v','h','e','a'), otfcc_buildVhea(font->vhea, options));
- if (font->vhea && font->maxp && font->vmtx) {
- uint16_t vmtx_counta = font->vhea->numOfLongVerMetrics;
- uint16_t vmtx_countk = font->maxp->numGlyphs - font->vhea->numOfLongVerMetrics;
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('v','m','t','x'),
- otfcc_buildVmtx(font->vmtx, vmtx_counta, vmtx_countk, options));
- }
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('V','O','R','G'), otfcc_buildVORG(font->VORG, options));
-
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('G','S','U','B'), otfcc_buildOtl(font->GSUB, options, "GSUB"));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('G','P','O','S'), otfcc_buildOtl(font->GPOS, options, "GPOS"));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('G','D','E','F'), otfcc_buildGDEF(font->GDEF, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('B','A','S','E'), otfcc_buildBASE(font->BASE, options));
-
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('C','P','A','L'), otfcc_buildCPAL(font->CPAL, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('C','O','L','R'), otfcc_buildCOLR(font->COLR, options));
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('S','V','G',' '), otfcc_buildSVG(font->SVG_, options));
-
- {
- tsi_BuildTarget target = otfcc_buildTSI(font->TSI_01, options);
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('T','S','I','0'), target.indexPart);
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('T','S','I','1'), target.textPart);
- }
- {
- tsi_BuildTarget target = otfcc_buildTSI(font->TSI_23, options);
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('T','S','I','2'), target.indexPart);
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('T','S','I','3'), target.textPart);
- }
- if (font->glyf) {
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('T','S','I','5'),
- otfcc_buildTSI5(font->TSI5, options, font->glyf->length));
- }
-
- if (options->dummy_DSIG) {
- caryll_Buffer *dsig = bufnew();
- bufwrite32b(dsig, 0x00000001);
- bufwrite16b(dsig, 0);
- bufwrite16b(dsig, 0);
- otfcc_SFNTBuilder_pushTable(builder, OTFCC_CHR('D','S','I','G'), dsig);
- }
-
- caryll_Buffer *otf = otfcc_SFNTBuilder_serialize(builder);
- otfcc_deleteSFNTBuilder(builder);
- otfcc_unstatFont(font, options);
- return otf;
-}
-static void freeFontWriter(otfcc_IFontSerializer *self) {
- free(self);
-}
-otfcc_IFontSerializer *otfcc_newOTFWriter() {
- otfcc_IFontSerializer *writer;
- NEW(writer);
- writer->serialize = serializeToOTF;
- writer->free = freeFontWriter;
- return writer;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.c
deleted file mode 100644
index e94b2a2f551..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.c
+++ /dev/null
@@ -1,706 +0,0 @@
-#include "stat.h"
-
-#include <time.h>
-#include <float.h>
-#include "support/util.h"
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-// Stating
-// Calculate necessary values for SFNT
-
-typedef enum { stat_not_started = 0, stat_doing = 1, stat_completed = 2 } stat_status;
-
-static glyf_GlyphStat stat_single_glyph(table_glyf *table, glyf_ComponentReference *gr,
- stat_status *stated, uint8_t depth, glyphid_t topj,
- const otfcc_Options *options) {
- glyf_GlyphStat stat = {0, 0, 0, 0, 0, 0, 0, 0, 0};
- glyphid_t j = gr->glyph.index;
- if (depth >= 0xFF) return stat;
- if (stated[j] == stat_doing) {
- // We have a circular reference
- logWarning("[Stat] Circular glyph reference found in gid %d to gid %d. The reference will "
- "be dropped.\n",
- topj, j);
- stated[j] = stat_completed;
- return stat;
- }
-
- glyf_Glyph *g = table->items[j];
- stated[j] = stat_doing;
- pos_t xmin = POS_MAX;
- pos_t xmax = -POS_MAX;
- pos_t ymin = POS_MAX;
- pos_t ymax = -POS_MAX;
- uint16_t nestDepth = 0;
- uint16_t nPoints = 0;
- uint16_t nCompositePoints = 0;
- uint16_t nCompositeContours = 0;
- // Stat xmin, xmax, ymin, ymax
- for (shapeid_t c = 0; c < g->contours.length; c++) {
- for (shapeid_t pj = 0; pj < g->contours.items[c].length; pj++) {
- // Stat point coordinates USING the matrix transformation
- glyf_Point *p = &(g->contours.items[c].items[pj]);
- pos_t x = round(iVQ.getStill(gr->x) + gr->a * iVQ.getStill(p->x) +
- gr->b * iVQ.getStill(p->y));
- pos_t y = round(iVQ.getStill(gr->y) + gr->c * iVQ.getStill(p->x) +
- gr->d * iVQ.getStill(p->y));
- if (x < xmin) xmin = x;
- if (x > xmax) xmax = x;
- if (y < ymin) ymin = y;
- if (y > ymax) ymax = y;
- nPoints += 1;
- }
- }
- nCompositePoints = nPoints;
- nCompositeContours = g->contours.length;
- for (shapeid_t r = 0; r < g->references.length; r++) {
- glyf_ComponentReference ref;
- glyf_iComponentReference.init(&ref);
- glyf_ComponentReference *rr = &(g->references.items[r]);
- // composite affine transformations
- Handle.replace(&ref.glyph, Handle.fromIndex(g->references.items[r].glyph.index));
- ref.a = gr->a * rr->a + rr->b * gr->c;
- ref.b = rr->a * gr->b + rr->b * gr->d;
- ref.c = gr->a * rr->c + gr->c * rr->d;
- ref.d = gr->b * rr->c + rr->d * gr->d;
- iVQ.replace(&ref.x, iVQ.createStill(iVQ.getStill(rr->x) + rr->a * iVQ.getStill(gr->x) +
- rr->b * iVQ.getStill(gr->y)));
- iVQ.replace(&ref.y, iVQ.createStill(iVQ.getStill(rr->y) + rr->c * iVQ.getStill(gr->x) +
- rr->d * iVQ.getStill(gr->y)));
-
- glyf_GlyphStat thatstat = stat_single_glyph(table, &ref, stated, depth + 1, topj, options);
- if (thatstat.xMin < xmin) xmin = thatstat.xMin;
- if (thatstat.xMax > xmax) xmax = thatstat.xMax;
- if (thatstat.yMin < ymin) ymin = thatstat.yMin;
- if (thatstat.yMax > ymax) ymax = thatstat.yMax;
- if (thatstat.nestDepth + 1 > nestDepth) nestDepth = thatstat.nestDepth + 1;
- nCompositePoints += thatstat.nCompositePoints;
- nCompositeContours += thatstat.nCompositeContours;
- }
- // deal with space glyphs
- if (xmin > xmax) xmin = xmax = 0;
- if (ymin > ymax) ymin = ymax = 0;
-
- // write back
- stat.xMin = xmin;
- stat.xMax = xmax;
- stat.yMin = ymin;
- stat.yMax = ymax;
- stat.nestDepth = nestDepth;
- stat.nPoints = nPoints;
- stat.nContours = g->contours.length;
- stat.nCompositePoints = nCompositePoints;
- stat.nCompositeContours = nCompositeContours;
- stated[j] = stat_completed;
- return stat;
-}
-
-static void statGlyf(otfcc_Font *font, const otfcc_Options *options) {
- stat_status *stated;
- NEW(stated, font->glyf->length);
- pos_t xmin = 0xFFFFFFFF;
- pos_t xmax = -0xFFFFFFFF;
- pos_t ymin = 0xFFFFFFFF;
- pos_t ymax = -0xFFFFFFFF;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_ComponentReference gr;
- gr.glyph = Handle.fromIndex(j);
- gr.x = iVQ.createStill(0);
- gr.y = iVQ.createStill(0);
- gr.a = 1;
- gr.b = 0;
- gr.c = 0;
- gr.d = 1;
- glyf_GlyphStat thatstat = font->glyf->items[j]->stat =
- stat_single_glyph(font->glyf, &gr, stated, 0, j, options);
- if (thatstat.xMin < xmin) xmin = thatstat.xMin;
- if (thatstat.xMax > xmax) xmax = thatstat.xMax;
- if (thatstat.yMin < ymin) ymin = thatstat.yMin;
- if (thatstat.yMax > ymax) ymax = thatstat.yMax;
- }
- font->head->xMin = xmin;
- font->head->xMax = xmax;
- font->head->yMin = ymin;
- font->head->yMax = ymax;
- FREE(stated);
-}
-
-static void statMaxp(otfcc_Font *font) {
- uint16_t nestDepth = 0;
- uint16_t nPoints = 0;
- uint16_t nContours = 0;
- uint16_t nComponents = 0;
- uint16_t nCompositePoints = 0;
- uint16_t nCompositeContours = 0;
- uint16_t instSize = 0;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- if (g->contours.length > 0) {
- if (g->stat.nPoints > nPoints) nPoints = g->stat.nPoints;
- if (g->stat.nContours > nContours) nContours = g->stat.nContours;
- } else if (g->references.length > 0) {
- if (g->stat.nCompositePoints > nCompositePoints)
- nCompositePoints = g->stat.nCompositePoints;
- if (g->stat.nCompositeContours > nCompositeContours)
- nCompositeContours = g->stat.nCompositeContours;
- if (g->stat.nestDepth > nestDepth) nestDepth = g->stat.nestDepth;
- if (g->references.length > nComponents) nComponents = g->references.length;
- }
- if (g->instructionsLength > instSize) instSize = g->instructionsLength;
- }
- font->maxp->maxPoints = nPoints;
- font->maxp->maxContours = nContours;
- font->maxp->maxCompositePoints = nCompositePoints;
- font->maxp->maxCompositeContours = nCompositeContours;
- font->maxp->maxComponentDepth = nestDepth;
- font->maxp->maxComponentElements = nComponents;
- font->maxp->maxSizeOfInstructions = instSize;
-}
-
-static void statHmtx(otfcc_Font *font, const otfcc_Options *options) {
- if (!font->glyf) return;
- table_hmtx *hmtx;
- NEW(hmtx);
- glyphid_t count_a = font->glyf->length;
- glyphid_t count_k = 0;
- bool lsbAtX_0 = true;
- if (font->subtype == FONTTYPE_CFF) {
- // pass
- } else {
- while (count_a > 2 && iVQ.getStill(font->glyf->items[count_a - 1]->advanceWidth) ==
- iVQ.getStill(font->glyf->items[count_a - 2]->advanceWidth)) {
- count_a--;
- }
- count_k = font->glyf->length - count_a;
- }
- NEW(hmtx->metrics, count_a);
- NEW(hmtx->leftSideBearing, count_k);
-
- pos_t minLSB = 0x7FFF;
- pos_t minRSB = 0x7FFF;
- pos_t maxExtent = -0x8000;
- length_t maxWidth = 0;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- if (iVQ.isZero(g->horizontalOrigin, 1.0 / 1000.0)) {
- iVQ.replace(&g->horizontalOrigin, iVQ.neutral());
- } else {
- lsbAtX_0 = false;
- }
- const pos_t hori = iVQ.getStill(g->horizontalOrigin);
- const pos_t advw = iVQ.getStill(g->advanceWidth);
- const pos_t lsb = (g->stat.xMin) - hori;
- const pos_t rsb = advw + hori - (g->stat.xMax);
-
- if (j < count_a) {
- hmtx->metrics[j].advanceWidth = advw;
- hmtx->metrics[j].lsb = lsb;
- } else {
- hmtx->leftSideBearing[j - count_a] = lsb;
- }
-
- if (advw > maxWidth) maxWidth = advw;
- if (lsb < minLSB) minLSB = lsb;
- if (rsb < minRSB) minRSB = rsb;
- if (g->stat.xMax - hori > maxExtent) { maxExtent = g->stat.xMax - hori; }
- }
- font->hhea->numberOfMetrics = count_a;
- font->hhea->minLeftSideBearing = minLSB;
- font->hhea->minRightSideBearing = minRSB;
- font->hhea->xMaxExtent = maxExtent;
- font->hhea->advanceWidthMax = maxWidth;
- font->hmtx = hmtx;
- // set bit 1 in head.flags
- font->head->flags = (font->head->flags & (~0x2)) | (lsbAtX_0 ? 0x2 : 0);
-}
-static void statVmtx(otfcc_Font *font, const otfcc_Options *options) {
- if (!font->glyf) return;
- table_vmtx *vmtx;
- NEW(vmtx);
- glyphid_t count_a = font->glyf->length;
- glyphid_t count_k = 0;
- if (font->subtype == FONTTYPE_CFF && !options->cff_short_vmtx) {
- // pass
- } else {
- while (count_a > 2 && iVQ.getStill(font->glyf->items[count_a - 1]->advanceHeight) ==
- iVQ.getStill(font->glyf->items[count_a - 2]->advanceHeight)) {
- count_a--;
- }
- count_k = font->glyf->length - count_a;
- }
- NEW(vmtx->metrics, count_a);
- NEW(vmtx->topSideBearing, count_k);
-
- pos_t minTSB = 0x7FFF;
- pos_t minBSB = 0x7FFF;
- pos_t maxExtent = -0x8000;
- length_t maxHeight = 0;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- glyf_Glyph *g = font->glyf->items[j];
- const pos_t vori = iVQ.getStill(g->verticalOrigin);
- const pos_t advh = iVQ.getStill(g->advanceHeight);
- const pos_t tsb = (vori) - (g->stat.yMax);
- const pos_t bsb = (g->stat.yMin) - (vori) + (advh);
- if (j < count_a) {
- vmtx->metrics[j].advanceHeight = advh;
- vmtx->metrics[j].tsb = tsb;
- } else {
- vmtx->topSideBearing[j - count_a] = tsb;
- }
- if (advh > maxHeight) maxHeight = advh;
- if (tsb < minTSB) minTSB = tsb;
- if (bsb < minBSB) minBSB = bsb;
- if (vori - g->stat.yMin > maxExtent) { maxExtent = vori - g->stat.yMin; }
- }
- font->vhea->numOfLongVerMetrics = count_a;
- font->vhea->minTop = minTSB;
- font->vhea->minBottom = minBSB;
- font->vhea->yMaxExtent = maxExtent;
- font->vhea->advanceHeightMax = maxHeight;
- font->vmtx = vmtx;
-}
-static void statOS_2UnicodeRanges(otfcc_Font *font, const otfcc_Options *options) {
- cmap_Entry *item;
- // Stat for OS/2.ulUnicodeRange.
- uint32_t u1 = 0;
- uint32_t u2 = 0;
- uint32_t u3 = 0;
- uint32_t u4 = 0;
- int32_t minUnicode = 0xFFFF;
- int32_t maxUnicode = 0;
- foreach_hash(item, font->cmap->unicodes) {
- int u = item->unicode;
- // Stat for minimium and maximium unicode
- if (u < minUnicode) minUnicode = u;
- if (u > maxUnicode) maxUnicode = u;
- // Reference: https://www.microsoft.com/typography/otspec/os2.htm#ur
- if ((u >= 0x0000 && u <= 0x007F)) { u1 |= (1 << 0); }
- if ((u >= 0x0080 && u <= 0x00FF)) { u1 |= (1 << 1); }
- if ((u >= 0x0100 && u <= 0x017F)) { u1 |= (1 << 2); }
- if ((u >= 0x0180 && u <= 0x024F)) { u1 |= (1 << 3); }
- if ((u >= 0x0250 && u <= 0x02AF) || (u >= 0x1D00 && u <= 0x1D7F) ||
- (u >= 0x1D80 && u <= 0x1DBF)) {
- u1 |= (1 << 4);
- }
- if ((u >= 0x02B0 && u <= 0x02FF) || (u >= 0xA700 && u <= 0xA71F)) { u1 |= (1 << 5); }
- if ((u >= 0x0300 && u <= 0x036F) || (u >= 0x1DC0 && u <= 0x1DFF)) { u1 |= (1 << 6); }
- if ((u >= 0x0370 && u <= 0x03FF)) { u1 |= (1 << 7); }
- if ((u >= 0x2C80 && u <= 0x2CFF)) { u1 |= (1 << 8); }
- if ((u >= 0x0400 && u <= 0x04FF) || (u >= 0x0500 && u <= 0x052F) ||
- (u >= 0x2DE0 && u <= 0x2DFF) || (u >= 0xA640 && u <= 0xA69F)) {
- u1 |= (1 << 9);
- }
- if ((u >= 0x0530 && u <= 0x058F)) { u1 |= (1 << 10); }
- if ((u >= 0x0590 && u <= 0x05FF)) { u1 |= (1 << 11); }
- if ((u >= 0xA500 && u <= 0xA63F)) { u1 |= (1 << 12); }
- if ((u >= 0x0600 && u <= 0x06FF) || (u >= 0x0750 && u <= 0x077F)) { u1 |= (1 << 13); }
- if ((u >= 0x07C0 && u <= 0x07FF)) { u1 |= (1 << 14); }
- if ((u >= 0x0900 && u <= 0x097F)) { u1 |= (1 << 15); }
- if ((u >= 0x0980 && u <= 0x09FF)) { u1 |= (1 << 16); }
- if ((u >= 0x0A00 && u <= 0x0A7F)) { u1 |= (1 << 17); }
- if ((u >= 0x0A80 && u <= 0x0AFF)) { u1 |= (1 << 18); }
- if ((u >= 0x0B00 && u <= 0x0B7F)) { u1 |= (1 << 19); }
- if ((u >= 0x0B80 && u <= 0x0BFF)) { u1 |= (1 << 20); }
- if ((u >= 0x0C00 && u <= 0x0C7F)) { u1 |= (1 << 21); }
- if ((u >= 0x0C80 && u <= 0x0CFF)) { u1 |= (1 << 22); }
- if ((u >= 0x0D00 && u <= 0x0D7F)) { u1 |= (1 << 23); }
- if ((u >= 0x0E00 && u <= 0x0E7F)) { u1 |= (1 << 24); }
- if ((u >= 0x0E80 && u <= 0x0EFF)) { u1 |= (1 << 25); }
- if ((u >= 0x10A0 && u <= 0x10FF) || (u >= 0x2D00 && u <= 0x2D2F)) { u1 |= (1 << 26); }
- if ((u >= 0x1B00 && u <= 0x1B7F)) { u1 |= (1 << 27); }
- if ((u >= 0x1100 && u <= 0x11FF)) { u1 |= (1 << 28); }
- if ((u >= 0x1E00 && u <= 0x1EFF) || (u >= 0x2C60 && u <= 0x2C7F) ||
- (u >= 0xA720 && u <= 0xA7FF)) {
- u1 |= (1 << 29);
- }
- if ((u >= 0x1F00 && u <= 0x1FFF)) { u1 |= (1 << 30); }
- if ((u >= 0x2000 && u <= 0x206F) || (u >= 0x2E00 && u <= 0x2E7F)) { u1 |= (1 << 31); }
- if ((u >= 0x2070 && u <= 0x209F)) { u2 |= (1 << 0); }
- if ((u >= 0x20A0 && u <= 0x20CF)) { u2 |= (1 << 1); }
- if ((u >= 0x20D0 && u <= 0x20FF)) { u2 |= (1 << 2); }
- if ((u >= 0x2100 && u <= 0x214F)) { u2 |= (1 << 3); }
- if ((u >= 0x2150 && u <= 0x218F)) { u2 |= (1 << 4); }
- if ((u >= 0x2190 && u <= 0x21FF) || (u >= 0x27F0 && u <= 0x27FF) ||
- (u >= 0x2900 && u <= 0x297F) || (u >= 0x2B00 && u <= 0x2BFF)) {
- u2 |= (1 << 5);
- }
- if ((u >= 0x2200 && u <= 0x22FF) || (u >= 0x2A00 && u <= 0x2AFF) ||
- (u >= 0x27C0 && u <= 0x27EF) || (u >= 0x2980 && u <= 0x29FF)) {
- u2 |= (1 << 6);
- }
- if ((u >= 0x2300 && u <= 0x23FF)) { u2 |= (1 << 7); }
- if ((u >= 0x2400 && u <= 0x243F)) { u2 |= (1 << 8); }
- if ((u >= 0x2440 && u <= 0x245F)) { u2 |= (1 << 9); }
- if ((u >= 0x2460 && u <= 0x24FF)) { u2 |= (1 << 10); }
- if ((u >= 0x2500 && u <= 0x257F)) { u2 |= (1 << 11); }
- if ((u >= 0x2580 && u <= 0x259F)) { u2 |= (1 << 12); }
- if ((u >= 0x25A0 && u <= 0x25FF)) { u2 |= (1 << 13); }
- if ((u >= 0x2600 && u <= 0x26FF)) { u2 |= (1 << 14); }
- if ((u >= 0x2700 && u <= 0x27BF)) { u2 |= (1 << 15); }
- if ((u >= 0x3000 && u <= 0x303F)) { u2 |= (1 << 16); }
- if ((u >= 0x3040 && u <= 0x309F)) { u2 |= (1 << 17); }
- if ((u >= 0x30A0 && u <= 0x30FF) || (u >= 0x31F0 && u <= 0x31FF)) { u2 |= (1 << 18); }
- if ((u >= 0x3100 && u <= 0x312F) || (u >= 0x31A0 && u <= 0x31BF)) { u2 |= (1 << 19); }
- if ((u >= 0x3130 && u <= 0x318F)) { u2 |= (1 << 20); }
- if ((u >= 0xA840 && u <= 0xA87F)) { u2 |= (1 << 21); }
- if ((u >= 0x3200 && u <= 0x32FF)) { u2 |= (1 << 22); }
- if ((u >= 0x3300 && u <= 0x33FF)) { u2 |= (1 << 23); }
- if ((u >= 0xAC00 && u <= 0xD7AF)) { u2 |= (1 << 24); }
- if ((u >= 0xD800 && u <= 0xDFFF) || u > 0xFFFF) { u2 |= (1 << 25); }
- if ((u >= 0x10900 && u <= 0x1091F)) { u2 |= (1 << 26); }
- if ((u >= 0x4E00 && u <= 0x9FFF) || (u >= 0x2E80 && u <= 0x2EFF) ||
- (u >= 0x2F00 && u <= 0x2FDF) || (u >= 0x2FF0 && u <= 0x2FFF) ||
- (u >= 0x3400 && u <= 0x4DBF) || (u >= 0x20000 && u <= 0x2F7FF) ||
- (u >= 0x3190 && u <= 0x319F)) {
- u2 |= (1 << 27);
- }
- if ((u >= 0xE000 && u <= 0xF8FF)) { u2 |= (1 << 28); }
- if ((u >= 0x31C0 && u <= 0x31EF) || (u >= 0xF900 && u <= 0xFAFF) ||
- (u >= 0x2F800 && u <= 0x2FA1F)) {
- u2 |= (1 << 29);
- }
- if ((u >= 0xFB00 && u <= 0xFB4F)) { u2 |= (1 << 30); }
- if ((u >= 0xFB50 && u <= 0xFDFF)) { u2 |= (1 << 31); }
- if ((u >= 0xFE20 && u <= 0xFE2F)) { u3 |= (1 << 0); }
- if ((u >= 0xFE10 && u <= 0xFE1F) || (u >= 0xFE30 && u <= 0xFE4F)) { u3 |= (1 << 1); }
- if ((u >= 0xFE50 && u <= 0xFE6F)) { u3 |= (1 << 2); }
- if ((u >= 0xFE70 && u <= 0xFEFF)) { u3 |= (1 << 3); }
- if ((u >= 0xFF00 && u <= 0xFFEF)) { u3 |= (1 << 4); }
- if ((u >= 0xFFF0 && u <= 0xFFFF)) { u3 |= (1 << 5); }
- if ((u >= 0x0F00 && u <= 0x0FFF)) { u3 |= (1 << 6); }
- if ((u >= 0x0700 && u <= 0x074F)) { u3 |= (1 << 7); }
- if ((u >= 0x0780 && u <= 0x07BF)) { u3 |= (1 << 8); }
- if ((u >= 0x0D80 && u <= 0x0DFF)) { u3 |= (1 << 9); }
- if ((u >= 0x1000 && u <= 0x109F)) { u3 |= (1 << 10); }
- if ((u >= 0x1200 && u <= 0x137F) || (u >= 0x1380 && u <= 0x139F) ||
- (u >= 0x2D80 && u <= 0x2DDF)) {
- u3 |= (1 << 11);
- }
- if ((u >= 0x13A0 && u <= 0x13FF)) { u3 |= (1 << 12); }
- if ((u >= 0x1400 && u <= 0x167F)) { u3 |= (1 << 13); }
- if ((u >= 0x1680 && u <= 0x169F)) { u3 |= (1 << 14); }
- if ((u >= 0x16A0 && u <= 0x16FF)) { u3 |= (1 << 15); }
- if ((u >= 0x1780 && u <= 0x17FF) || (u >= 0x19E0 && u <= 0x19FF)) { u3 |= (1 << 16); }
- if ((u >= 0x1800 && u <= 0x18AF)) { u3 |= (1 << 17); }
- if ((u >= 0x2800 && u <= 0x28FF)) { u3 |= (1 << 18); }
- if ((u >= 0xA000 && u <= 0xA48F) || (u >= 0xA490 && u <= 0xA4CF)) { u3 |= (1 << 19); }
- if ((u >= 0x1700 && u <= 0x171F) || (u >= 0x1720 && u <= 0x173F) ||
- (u >= 0x1740 && u <= 0x175F) || (u >= 0x1760 && u <= 0x177F)) {
- u3 |= (1 << 20);
- }
- if ((u >= 0x10300 && u <= 0x1032F)) { u3 |= (1 << 21); }
- if ((u >= 0x10330 && u <= 0x1034F)) { u3 |= (1 << 22); }
- if ((u >= 0x10400 && u <= 0x1044F)) { u3 |= (1 << 23); }
- if ((u >= 0x1D000 && u <= 0x1D0FF) || (u >= 0x1D100 && u <= 0x1D1FF) ||
- (u >= 0x1D200 && u <= 0x1D24F)) {
- u3 |= (1 << 24);
- }
- if ((u >= 0x1D400 && u <= 0x1D7FF)) { u3 |= (1 << 25); }
- if ((u >= 0xFF000 && u <= 0xFFFFD) || (u >= 0x100000 && u <= 0x10FFFD)) { u3 |= (1 << 26); }
- if ((u >= 0xFE00 && u <= 0xFE0F) || (u >= 0xE0100 && u <= 0xE01EF)) { u3 |= (1 << 27); }
- if ((u >= 0xE0000 && u <= 0xE007F)) { u3 |= (1 << 28); }
- if ((u >= 0x1900 && u <= 0x194F)) { u3 |= (1 << 29); }
- if ((u >= 0x1950 && u <= 0x197F)) { u3 |= (1 << 30); }
- if ((u >= 0x1980 && u <= 0x19DF)) { u3 |= (1 << 31); }
- if ((u >= 0x1A00 && u <= 0x1A1F)) { u4 |= (1 << 0); }
- if ((u >= 0x2C00 && u <= 0x2C5F)) { u4 |= (1 << 1); }
- if ((u >= 0x2D30 && u <= 0x2D7F)) { u4 |= (1 << 2); }
- if ((u >= 0x4DC0 && u <= 0x4DFF)) { u4 |= (1 << 3); }
- if ((u >= 0xA800 && u <= 0xA82F)) { u4 |= (1 << 4); }
- if ((u >= 0x10000 && u <= 0x1007F) || (u >= 0x10080 && u <= 0x100FF) ||
- (u >= 0x10100 && u <= 0x1013F)) {
- u4 |= (1 << 5);
- }
- if ((u >= 0x10140 && u <= 0x1018F)) { u4 |= (1 << 6); }
- if ((u >= 0x10380 && u <= 0x1039F)) { u4 |= (1 << 7); }
- if ((u >= 0x103A0 && u <= 0x103DF)) { u4 |= (1 << 8); }
- if ((u >= 0x10450 && u <= 0x1047F)) { u4 |= (1 << 9); }
- if ((u >= 0x10480 && u <= 0x104AF)) { u4 |= (1 << 10); }
- if ((u >= 0x10800 && u <= 0x1083F)) { u4 |= (1 << 11); }
- if ((u >= 0x10A00 && u <= 0x10A5F)) { u4 |= (1 << 12); }
- if ((u >= 0x1D300 && u <= 0x1D35F)) { u4 |= (1 << 13); }
- if ((u >= 0x12000 && u <= 0x123FF) || (u >= 0x12400 && u <= 0x1247F)) { u4 |= (1 << 14); }
- if ((u >= 0x1D360 && u <= 0x1D37F)) { u4 |= (1 << 15); }
- if ((u >= 0x1B80 && u <= 0x1BBF)) { u4 |= (1 << 16); }
- if ((u >= 0x1C00 && u <= 0x1C4F)) { u4 |= (1 << 17); }
- if ((u >= 0x1C50 && u <= 0x1C7F)) { u4 |= (1 << 18); }
- if ((u >= 0xA880 && u <= 0xA8DF)) { u4 |= (1 << 19); }
- if ((u >= 0xA900 && u <= 0xA92F)) { u4 |= (1 << 20); }
- if ((u >= 0xA930 && u <= 0xA95F)) { u4 |= (1 << 21); }
- if ((u >= 0xAA00 && u <= 0xAA5F)) { u4 |= (1 << 22); }
- if ((u >= 0x10190 && u <= 0x101CF)) { u4 |= (1 << 23); }
- if ((u >= 0x101D0 && u <= 0x101FF)) { u4 |= (1 << 24); }
- if ((u >= 0x102A0 && u <= 0x102DF) || (u >= 0x10280 && u <= 0x1029F) ||
- (u >= 0x10920 && u <= 0x1093F)) {
- u4 |= (1 << 25);
- }
- if ((u >= 0x1F030 && u <= 0x1F09F) || (u >= 0x1F000 && u <= 0x1F02F)) { u4 |= (1 << 26); }
- }
- if (!options->keep_unicode_ranges) {
- font->OS_2->ulUnicodeRange1 = u1;
- font->OS_2->ulUnicodeRange2 = u2;
- font->OS_2->ulUnicodeRange3 = u3;
- font->OS_2->ulUnicodeRange4 = u4;
- }
- if (minUnicode < 0x10000) {
- font->OS_2->usFirstCharIndex = minUnicode;
- } else {
- font->OS_2->usFirstCharIndex = 0xFFFF;
- }
- if (maxUnicode < 0x10000) {
- font->OS_2->usLastCharIndex = maxUnicode;
- } else {
- font->OS_2->usLastCharIndex = 0xFFFF;
- }
-}
-static void statOS_2AverageWidth(otfcc_Font *font, const otfcc_Options *options) {
- if (options->keep_average_char_width) return;
- uint32_t totalWidth = 0;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- const pos_t adw = iVQ.getStill(font->glyf->items[j]->advanceWidth);
- if (adw > 0) { totalWidth += adw; }
- }
- font->OS_2->xAvgCharWidth = totalWidth / font->glyf->length;
-}
-static uint16_t statMaxContextOTL(const table_OTL *table) {
- uint16_t maxc = 1;
- foreach (otl_Lookup **lookup_, table->lookups) {
- otl_Lookup *lookup = *lookup_;
- switch (lookup->type) {
- case otl_type_gpos_pair:
- case otl_type_gpos_markToBase:
- case otl_type_gpos_markToLigature:
- case otl_type_gpos_markToMark:
- if (maxc < 2) maxc = 2;
- break;
- case otl_type_gsub_ligature:
- foreach (otl_Subtable **subtable_, lookup->subtables) {
- subtable_gsub_ligature *subtable = (subtable_gsub_ligature *)*subtable_;
- foreach (otl_GsubLigatureEntry *entry, *subtable) {
- if (maxc < entry->from->numGlyphs) { maxc = entry->from->numGlyphs; }
- };
- }
- break;
- case otl_type_gsub_chaining:
- case otl_type_gpos_chaining:
- foreach (otl_Subtable **subtable_, lookup->subtables) {
- subtable_chaining *subtable = (subtable_chaining *)*subtable_;
- if (maxc < subtable->rule.matchCount) maxc = subtable->rule.matchCount;
- }
- break;
- case otl_type_gsub_reverse:
- foreach (otl_Subtable **subtable_, lookup->subtables) {
- subtable_gsub_reverse *subtable = (subtable_gsub_reverse *)*subtable_;
- if (maxc < subtable->matchCount) maxc = subtable->matchCount;
- }
- break;
- default:;
- }
- }
- return maxc;
-}
-static void statMaxContext(otfcc_Font *font, const otfcc_Options *options) {
- uint16_t maxc = 1;
- if (font->GSUB) {
- uint16_t maxc_gsub = statMaxContextOTL(font->GSUB);
- if (maxc_gsub > maxc) maxc = maxc_gsub;
- }
- if (font->GPOS) {
- uint16_t maxc_gpos = statMaxContextOTL(font->GPOS);
- if (maxc_gpos > maxc) maxc = maxc_gpos;
- }
- font->OS_2->usMaxContext = maxc;
-}
-static void statOS_2(otfcc_Font *font, const otfcc_Options *options) {
- statOS_2UnicodeRanges(font, options);
- statOS_2AverageWidth(font, options);
- statMaxContext(font, options);
-}
-
-#define MAX_STAT_METRIC 4096
-static void statCFFWidths(otfcc_Font *font) {
- if (!font->glyf || !font->CFF_) return;
- // Stat the most frequent character width
- uint32_t *frequency;
- NEW(frequency, MAX_STAT_METRIC);
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- uint16_t intWidth = (uint16_t)iVQ.getStill(font->glyf->items[j]->advanceWidth);
- if (intWidth < MAX_STAT_METRIC) { frequency[intWidth] += 1; }
- }
- uint16_t maxfreq = 0;
- uint16_t maxj = 0;
- for (uint16_t j = 0; j < MAX_STAT_METRIC; j++) {
- if (frequency[j] > maxfreq) {
- maxfreq = frequency[j];
- maxj = j;
- }
- }
- // stat nominalWidthX
- uint16_t nn = 0;
- uint32_t nnsum = 0;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- const pos_t adw = iVQ.getStill(font->glyf->items[j]->advanceWidth);
- if (adw != maxj) { nn += 1, nnsum += adw; }
- }
- int16_t nominalWidthX = 0;
- if (nn > 0) nominalWidthX = nnsum / nn;
- if (font->CFF_->privateDict) {
- font->CFF_->privateDict->defaultWidthX = maxj;
- if (nn != 0) { font->CFF_->privateDict->nominalWidthX = nominalWidthX; }
- }
- if (font->CFF_->fdArray) {
- for (tableid_t j = 0; j < font->CFF_->fdArrayCount; j++) {
- font->CFF_->fdArray[j]->privateDict->defaultWidthX = maxj;
- font->CFF_->fdArray[j]->privateDict->nominalWidthX = nominalWidthX;
- }
- }
- FREE(frequency);
-}
-
-static void statVORG(otfcc_Font *font) {
- if (!font->glyf || !font->CFF_ || !font->vhea || !font->vmtx) return;
- uint32_t *frequency;
- NEW(frequency, MAX_STAT_METRIC);
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- const pos_t vori = iVQ.getStill(font->glyf->items[j]->verticalOrigin);
- if (vori >= 0 && vori < MAX_STAT_METRIC) { frequency[(uint16_t)(vori)] += 1; }
- }
- // stat VORG.defaultVerticalOrigin
- uint32_t maxfreq = 0;
- glyphid_t maxj = 0;
- for (glyphid_t j = 0; j < MAX_STAT_METRIC; j++) {
- if (frequency[j] > maxfreq) {
- maxfreq = frequency[j];
- maxj = j;
- }
- }
-
- table_VORG *vorg;
- NEW(vorg);
- vorg->defaultVerticalOrigin = maxj;
-
- glyphid_t nVertOrigs = 0;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- const pos_t vori = iVQ.getStill(font->glyf->items[j]->verticalOrigin);
- if (vori != maxj) { nVertOrigs += 1; }
- }
- vorg->numVertOriginYMetrics = nVertOrigs;
- NEW(vorg->entries, nVertOrigs);
-
- glyphid_t jj = 0;
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- const pos_t vori = iVQ.getStill(font->glyf->items[j]->verticalOrigin);
- if (vori != maxj) {
- vorg->entries[jj].gid = j;
- vorg->entries[jj].verticalOrigin = vori;
- jj += 1;
- }
- }
- FREE(frequency);
- font->VORG = vorg;
-}
-
-static void statLTSH(otfcc_Font *font) {
- if (!font->glyf) return;
- bool needLTSH = false;
- for (glyphid_t j = 0; j < font->glyf->length; j++)
- if (font->glyf->items[j]->yPel > 1) { needLTSH = true; }
- if (!needLTSH) return;
-
- table_LTSH *ltsh;
- NEW(ltsh);
- ltsh->numGlyphs = font->glyf->length;
- NEW(ltsh->yPels, ltsh->numGlyphs);
- for (glyphid_t j = 0; j < font->glyf->length; j++) {
- ltsh->yPels[j] = font->glyf->items[j]->yPel;
- }
- font->LTSH = ltsh;
-}
-
-void otfcc_statFont(otfcc_Font *font, const otfcc_Options *options) {
- if (font->glyf && font->head) {
- statGlyf(font, options);
- if (!options->keep_modified_time) {
- font->head->modified = 2082844800 + (int64_t)time(NULL);
- }
- }
- if (font->head && font->CFF_) {
- table_CFF *cff = font->CFF_;
- if (cff->fontBBoxBottom > font->head->yMin) cff->fontBBoxBottom = font->head->yMin;
- if (cff->fontBBoxTop < font->head->yMax) cff->fontBBoxTop = font->head->yMax;
- if (cff->fontBBoxLeft < font->head->xMin) cff->fontBBoxLeft = font->head->xMin;
- if (cff->fontBBoxRight < font->head->xMax) cff->fontBBoxRight = font->head->xMax;
- if (font->glyf && cff->isCID) { cff->cidCount = (uint32_t)font->glyf->length; }
- if (cff->isCID) {
- if (cff->fontMatrix) {
- iVQ.dispose(&cff->fontMatrix->x);
- iVQ.dispose(&cff->fontMatrix->y);
- FREE(cff->fontMatrix);
- cff->fontMatrix = NULL;
- }
- for (tableid_t j = 0; j < cff->fdArrayCount; j++) {
- table_CFF *fd = cff->fdArray[j];
- if (fd->fontMatrix) {
- iVQ.dispose(&fd->fontMatrix->x);
- iVQ.dispose(&fd->fontMatrix->y);
- FREE(fd->fontMatrix);
- fd->fontMatrix = NULL;
- }
- if (font->head->unitsPerEm == 1000) {
- fd->fontMatrix = NULL;
- } else {
- NEW(fd->fontMatrix);
- fd->fontMatrix->a = 1.0 / font->head->unitsPerEm;
- fd->fontMatrix->b = 0.0;
- fd->fontMatrix->c = 0.0;
- fd->fontMatrix->d = 1.0 / font->head->unitsPerEm;
- fd->fontMatrix->x = iVQ.neutral();
- fd->fontMatrix->y = iVQ.neutral();
- }
- }
- } else {
- if (font->head->unitsPerEm == 1000) {
- cff->fontMatrix = NULL;
- } else {
- NEW(cff->fontMatrix);
- cff->fontMatrix->a = 1.0 / font->head->unitsPerEm;
- cff->fontMatrix->b = 0.0;
- cff->fontMatrix->c = 0.0;
- cff->fontMatrix->d = 1.0 / font->head->unitsPerEm;
- cff->fontMatrix->x = iVQ.neutral();
- cff->fontMatrix->y = iVQ.neutral();
- }
- }
-
- statCFFWidths(font);
- }
- if (font->glyf && font->maxp) { font->maxp->numGlyphs = (uint16_t)font->glyf->length; }
- if (font->glyf && font->post) { font->post->maxMemType42 = (uint32_t)font->glyf->length; }
- if (font->glyf && font->maxp && font->maxp->version == 0x10000) {
- statMaxp(font);
- if (font->fpgm && font->fpgm->length > font->maxp->maxSizeOfInstructions) {
- font->maxp->maxSizeOfInstructions = font->fpgm->length;
- }
- if (font->prep && font->prep->length > font->maxp->maxSizeOfInstructions) {
- font->maxp->maxSizeOfInstructions = font->prep->length;
- }
- }
- if (font->OS_2 && font->cmap && font->glyf) statOS_2(font, options);
- if (font->subtype == FONTTYPE_TTF) {
- if (font->maxp) font->maxp->version = 0x00010000;
- } else {
- if (font->maxp) font->maxp->version = 0x00005000;
- }
- if (font->glyf && font->hhea) { statHmtx(font, options); }
- if (font->glyf && font->vhea) { statVmtx(font, options), statVORG(font); }
- statLTSH(font);
-}
-
-void otfcc_unstatFont(otfcc_Font *font, const otfcc_Options *options) {
- otfcc_iFont.deleteTable(font, OTFCC_CHR('h','d','m','x'));
- otfcc_iFont.deleteTable(font, OTFCC_CHR('h','m','t','x'));
- otfcc_iFont.deleteTable(font, OTFCC_CHR('V','O','R','G'));
- otfcc_iFont.deleteTable(font, OTFCC_CHR('v','m','t','x'));
- otfcc_iFont.deleteTable(font, OTFCC_CHR('L','T','S','H'));
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.h
deleted file mode 100644
index fe08b57ba65..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/otf-writer/stat.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef CARYLL_OTF_WRITER_STAT_H
-#define CARYLL_OTF_WRITER_STAT_H
-
-#include "otfcc/font.h"
-#include "table/all.h"
-
-void otfcc_statFont(otfcc_Font *font, const otfcc_Options *options);
-void otfcc_unstatFont(otfcc_Font *font, const otfcc_Options *options);
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.c
deleted file mode 100644
index 1b770527de0..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.c
+++ /dev/null
@@ -1,592 +0,0 @@
-#include "aglfn.h"
-#define GlyphOrder otfcc_pkgGlyphOrder
-
-// This table contains standard AGLFN 1.7 glyph names, mapped to Unicode.
-void aglfn_setupNames(otfcc_GlyphOrder *map) {
- GlyphOrder.setByGID(map, 0x0041, sdsnew("A"));
- GlyphOrder.setByGID(map, 0x00C6, sdsnew("AE"));
- GlyphOrder.setByGID(map, 0x01FC, sdsnew("AEacute"));
- GlyphOrder.setByGID(map, 0x00C1, sdsnew("Aacute"));
- GlyphOrder.setByGID(map, 0x0102, sdsnew("Abreve"));
- GlyphOrder.setByGID(map, 0x00C2, sdsnew("Acircumflex"));
- GlyphOrder.setByGID(map, 0x00C4, sdsnew("Adieresis"));
- GlyphOrder.setByGID(map, 0x00C0, sdsnew("Agrave"));
- GlyphOrder.setByGID(map, 0x0391, sdsnew("Alpha"));
- GlyphOrder.setByGID(map, 0x0386, sdsnew("Alphatonos"));
- GlyphOrder.setByGID(map, 0x0100, sdsnew("Amacron"));
- GlyphOrder.setByGID(map, 0x0104, sdsnew("Aogonek"));
- GlyphOrder.setByGID(map, 0x00C5, sdsnew("Aring"));
- GlyphOrder.setByGID(map, 0x01FA, sdsnew("Aringacute"));
- GlyphOrder.setByGID(map, 0x00C3, sdsnew("Atilde"));
- GlyphOrder.setByGID(map, 0x0042, sdsnew("B"));
- GlyphOrder.setByGID(map, 0x0392, sdsnew("Beta"));
- GlyphOrder.setByGID(map, 0x0043, sdsnew("C"));
- GlyphOrder.setByGID(map, 0x0106, sdsnew("Cacute"));
- GlyphOrder.setByGID(map, 0x010C, sdsnew("Ccaron"));
- GlyphOrder.setByGID(map, 0x00C7, sdsnew("Ccedilla"));
- GlyphOrder.setByGID(map, 0x0108, sdsnew("Ccircumflex"));
- GlyphOrder.setByGID(map, 0x010A, sdsnew("Cdotaccent"));
- GlyphOrder.setByGID(map, 0x03A7, sdsnew("Chi"));
- GlyphOrder.setByGID(map, 0x0044, sdsnew("D"));
- GlyphOrder.setByGID(map, 0x010E, sdsnew("Dcaron"));
- GlyphOrder.setByGID(map, 0x0110, sdsnew("Dcroat"));
- GlyphOrder.setByGID(map, 0x2206, sdsnew("Delta"));
- GlyphOrder.setByGID(map, 0x0045, sdsnew("E"));
- GlyphOrder.setByGID(map, 0x00C9, sdsnew("Eacute"));
- GlyphOrder.setByGID(map, 0x0114, sdsnew("Ebreve"));
- GlyphOrder.setByGID(map, 0x011A, sdsnew("Ecaron"));
- GlyphOrder.setByGID(map, 0x00CA, sdsnew("Ecircumflex"));
- GlyphOrder.setByGID(map, 0x00CB, sdsnew("Edieresis"));
- GlyphOrder.setByGID(map, 0x0116, sdsnew("Edotaccent"));
- GlyphOrder.setByGID(map, 0x00C8, sdsnew("Egrave"));
- GlyphOrder.setByGID(map, 0x0112, sdsnew("Emacron"));
- GlyphOrder.setByGID(map, 0x014A, sdsnew("Eng"));
- GlyphOrder.setByGID(map, 0x0118, sdsnew("Eogonek"));
- GlyphOrder.setByGID(map, 0x0395, sdsnew("Epsilon"));
- GlyphOrder.setByGID(map, 0x0388, sdsnew("Epsilontonos"));
- GlyphOrder.setByGID(map, 0x0397, sdsnew("Eta"));
- GlyphOrder.setByGID(map, 0x0389, sdsnew("Etatonos"));
- GlyphOrder.setByGID(map, 0x00D0, sdsnew("Eth"));
- GlyphOrder.setByGID(map, 0x20AC, sdsnew("Euro"));
- GlyphOrder.setByGID(map, 0x0046, sdsnew("F"));
- GlyphOrder.setByGID(map, 0x0047, sdsnew("G"));
- GlyphOrder.setByGID(map, 0x0393, sdsnew("Gamma"));
- GlyphOrder.setByGID(map, 0x011E, sdsnew("Gbreve"));
- GlyphOrder.setByGID(map, 0x01E6, sdsnew("Gcaron"));
- GlyphOrder.setByGID(map, 0x011C, sdsnew("Gcircumflex"));
- GlyphOrder.setByGID(map, 0x0120, sdsnew("Gdotaccent"));
- GlyphOrder.setByGID(map, 0x0048, sdsnew("H"));
- GlyphOrder.setByGID(map, 0x25CF, sdsnew("H18533"));
- GlyphOrder.setByGID(map, 0x25AA, sdsnew("H18543"));
- GlyphOrder.setByGID(map, 0x25AB, sdsnew("H18551"));
- GlyphOrder.setByGID(map, 0x25A1, sdsnew("H22073"));
- GlyphOrder.setByGID(map, 0x0126, sdsnew("Hbar"));
- GlyphOrder.setByGID(map, 0x0124, sdsnew("Hcircumflex"));
- GlyphOrder.setByGID(map, 0x0049, sdsnew("I"));
- GlyphOrder.setByGID(map, 0x0132, sdsnew("IJ"));
- GlyphOrder.setByGID(map, 0x00CD, sdsnew("Iacute"));
- GlyphOrder.setByGID(map, 0x012C, sdsnew("Ibreve"));
- GlyphOrder.setByGID(map, 0x00CE, sdsnew("Icircumflex"));
- GlyphOrder.setByGID(map, 0x00CF, sdsnew("Idieresis"));
- GlyphOrder.setByGID(map, 0x0130, sdsnew("Idotaccent"));
- GlyphOrder.setByGID(map, 0x2111, sdsnew("Ifraktur"));
- GlyphOrder.setByGID(map, 0x00CC, sdsnew("Igrave"));
- GlyphOrder.setByGID(map, 0x012A, sdsnew("Imacron"));
- GlyphOrder.setByGID(map, 0x012E, sdsnew("Iogonek"));
- GlyphOrder.setByGID(map, 0x0399, sdsnew("Iota"));
- GlyphOrder.setByGID(map, 0x03AA, sdsnew("Iotadieresis"));
- GlyphOrder.setByGID(map, 0x038A, sdsnew("Iotatonos"));
- GlyphOrder.setByGID(map, 0x0128, sdsnew("Itilde"));
- GlyphOrder.setByGID(map, 0x004A, sdsnew("J"));
- GlyphOrder.setByGID(map, 0x0134, sdsnew("Jcircumflex"));
- GlyphOrder.setByGID(map, 0x004B, sdsnew("K"));
- GlyphOrder.setByGID(map, 0x039A, sdsnew("Kappa"));
- GlyphOrder.setByGID(map, 0x004C, sdsnew("L"));
- GlyphOrder.setByGID(map, 0x0139, sdsnew("Lacute"));
- GlyphOrder.setByGID(map, 0x039B, sdsnew("Lambda"));
- GlyphOrder.setByGID(map, 0x013D, sdsnew("Lcaron"));
- GlyphOrder.setByGID(map, 0x013F, sdsnew("Ldot"));
- GlyphOrder.setByGID(map, 0x0141, sdsnew("Lslash"));
- GlyphOrder.setByGID(map, 0x004D, sdsnew("M"));
- GlyphOrder.setByGID(map, 0x039C, sdsnew("Mu"));
- GlyphOrder.setByGID(map, 0x004E, sdsnew("N"));
- GlyphOrder.setByGID(map, 0x0143, sdsnew("Nacute"));
- GlyphOrder.setByGID(map, 0x0147, sdsnew("Ncaron"));
- GlyphOrder.setByGID(map, 0x00D1, sdsnew("Ntilde"));
- GlyphOrder.setByGID(map, 0x039D, sdsnew("Nu"));
- GlyphOrder.setByGID(map, 0x004F, sdsnew("O"));
- GlyphOrder.setByGID(map, 0x0152, sdsnew("OE"));
- GlyphOrder.setByGID(map, 0x00D3, sdsnew("Oacute"));
- GlyphOrder.setByGID(map, 0x014E, sdsnew("Obreve"));
- GlyphOrder.setByGID(map, 0x00D4, sdsnew("Ocircumflex"));
- GlyphOrder.setByGID(map, 0x00D6, sdsnew("Odieresis"));
- GlyphOrder.setByGID(map, 0x00D2, sdsnew("Ograve"));
- GlyphOrder.setByGID(map, 0x01A0, sdsnew("Ohorn"));
- GlyphOrder.setByGID(map, 0x0150, sdsnew("Ohungarumlaut"));
- GlyphOrder.setByGID(map, 0x014C, sdsnew("Omacron"));
- GlyphOrder.setByGID(map, 0x2126, sdsnew("Omega"));
- GlyphOrder.setByGID(map, 0x038F, sdsnew("Omegatonos"));
- GlyphOrder.setByGID(map, 0x039F, sdsnew("Omicron"));
- GlyphOrder.setByGID(map, 0x038C, sdsnew("Omicrontonos"));
- GlyphOrder.setByGID(map, 0x00D8, sdsnew("Oslash"));
- GlyphOrder.setByGID(map, 0x01FE, sdsnew("Oslashacute"));
- GlyphOrder.setByGID(map, 0x00D5, sdsnew("Otilde"));
- GlyphOrder.setByGID(map, 0x0050, sdsnew("P"));
- GlyphOrder.setByGID(map, 0x03A6, sdsnew("Phi"));
- GlyphOrder.setByGID(map, 0x03A0, sdsnew("Pi"));
- GlyphOrder.setByGID(map, 0x03A8, sdsnew("Psi"));
- GlyphOrder.setByGID(map, 0x0051, sdsnew("Q"));
- GlyphOrder.setByGID(map, 0x0052, sdsnew("R"));
- GlyphOrder.setByGID(map, 0x0154, sdsnew("Racute"));
- GlyphOrder.setByGID(map, 0x0158, sdsnew("Rcaron"));
- GlyphOrder.setByGID(map, 0x211C, sdsnew("Rfraktur"));
- GlyphOrder.setByGID(map, 0x03A1, sdsnew("Rho"));
- GlyphOrder.setByGID(map, 0x0053, sdsnew("S"));
- GlyphOrder.setByGID(map, 0x250C, sdsnew("SF010000"));
- GlyphOrder.setByGID(map, 0x2514, sdsnew("SF020000"));
- GlyphOrder.setByGID(map, 0x2510, sdsnew("SF030000"));
- GlyphOrder.setByGID(map, 0x2518, sdsnew("SF040000"));
- GlyphOrder.setByGID(map, 0x253C, sdsnew("SF050000"));
- GlyphOrder.setByGID(map, 0x252C, sdsnew("SF060000"));
- GlyphOrder.setByGID(map, 0x2534, sdsnew("SF070000"));
- GlyphOrder.setByGID(map, 0x251C, sdsnew("SF080000"));
- GlyphOrder.setByGID(map, 0x2524, sdsnew("SF090000"));
- GlyphOrder.setByGID(map, 0x2500, sdsnew("SF100000"));
- GlyphOrder.setByGID(map, 0x2502, sdsnew("SF110000"));
- GlyphOrder.setByGID(map, 0x2561, sdsnew("SF190000"));
- GlyphOrder.setByGID(map, 0x2562, sdsnew("SF200000"));
- GlyphOrder.setByGID(map, 0x2556, sdsnew("SF210000"));
- GlyphOrder.setByGID(map, 0x2555, sdsnew("SF220000"));
- GlyphOrder.setByGID(map, 0x2563, sdsnew("SF230000"));
- GlyphOrder.setByGID(map, 0x2551, sdsnew("SF240000"));
- GlyphOrder.setByGID(map, 0x2557, sdsnew("SF250000"));
- GlyphOrder.setByGID(map, 0x255D, sdsnew("SF260000"));
- GlyphOrder.setByGID(map, 0x255C, sdsnew("SF270000"));
- GlyphOrder.setByGID(map, 0x255B, sdsnew("SF280000"));
- GlyphOrder.setByGID(map, 0x255E, sdsnew("SF360000"));
- GlyphOrder.setByGID(map, 0x255F, sdsnew("SF370000"));
- GlyphOrder.setByGID(map, 0x255A, sdsnew("SF380000"));
- GlyphOrder.setByGID(map, 0x2554, sdsnew("SF390000"));
- GlyphOrder.setByGID(map, 0x2569, sdsnew("SF400000"));
- GlyphOrder.setByGID(map, 0x2566, sdsnew("SF410000"));
- GlyphOrder.setByGID(map, 0x2560, sdsnew("SF420000"));
- GlyphOrder.setByGID(map, 0x2550, sdsnew("SF430000"));
- GlyphOrder.setByGID(map, 0x256C, sdsnew("SF440000"));
- GlyphOrder.setByGID(map, 0x2567, sdsnew("SF450000"));
- GlyphOrder.setByGID(map, 0x2568, sdsnew("SF460000"));
- GlyphOrder.setByGID(map, 0x2564, sdsnew("SF470000"));
- GlyphOrder.setByGID(map, 0x2565, sdsnew("SF480000"));
- GlyphOrder.setByGID(map, 0x2559, sdsnew("SF490000"));
- GlyphOrder.setByGID(map, 0x2558, sdsnew("SF500000"));
- GlyphOrder.setByGID(map, 0x2552, sdsnew("SF510000"));
- GlyphOrder.setByGID(map, 0x2553, sdsnew("SF520000"));
- GlyphOrder.setByGID(map, 0x256B, sdsnew("SF530000"));
- GlyphOrder.setByGID(map, 0x256A, sdsnew("SF540000"));
- GlyphOrder.setByGID(map, 0x015A, sdsnew("Sacute"));
- GlyphOrder.setByGID(map, 0x0160, sdsnew("Scaron"));
- GlyphOrder.setByGID(map, 0x015E, sdsnew("Scedilla"));
- GlyphOrder.setByGID(map, 0x015C, sdsnew("Scircumflex"));
- GlyphOrder.setByGID(map, 0x03A3, sdsnew("Sigma"));
- GlyphOrder.setByGID(map, 0x0054, sdsnew("T"));
- GlyphOrder.setByGID(map, 0x03A4, sdsnew("Tau"));
- GlyphOrder.setByGID(map, 0x0166, sdsnew("Tbar"));
- GlyphOrder.setByGID(map, 0x0164, sdsnew("Tcaron"));
- GlyphOrder.setByGID(map, 0x0398, sdsnew("Theta"));
- GlyphOrder.setByGID(map, 0x00DE, sdsnew("Thorn"));
- GlyphOrder.setByGID(map, 0x0055, sdsnew("U"));
- GlyphOrder.setByGID(map, 0x00DA, sdsnew("Uacute"));
- GlyphOrder.setByGID(map, 0x016C, sdsnew("Ubreve"));
- GlyphOrder.setByGID(map, 0x00DB, sdsnew("Ucircumflex"));
- GlyphOrder.setByGID(map, 0x00DC, sdsnew("Udieresis"));
- GlyphOrder.setByGID(map, 0x00D9, sdsnew("Ugrave"));
- GlyphOrder.setByGID(map, 0x01AF, sdsnew("Uhorn"));
- GlyphOrder.setByGID(map, 0x0170, sdsnew("Uhungarumlaut"));
- GlyphOrder.setByGID(map, 0x016A, sdsnew("Umacron"));
- GlyphOrder.setByGID(map, 0x0172, sdsnew("Uogonek"));
- GlyphOrder.setByGID(map, 0x03A5, sdsnew("Upsilon"));
- GlyphOrder.setByGID(map, 0x03D2, sdsnew("Upsilon1"));
- GlyphOrder.setByGID(map, 0x03AB, sdsnew("Upsilondieresis"));
- GlyphOrder.setByGID(map, 0x038E, sdsnew("Upsilontonos"));
- GlyphOrder.setByGID(map, 0x016E, sdsnew("Uring"));
- GlyphOrder.setByGID(map, 0x0168, sdsnew("Utilde"));
- GlyphOrder.setByGID(map, 0x0056, sdsnew("V"));
- GlyphOrder.setByGID(map, 0x0057, sdsnew("W"));
- GlyphOrder.setByGID(map, 0x1E82, sdsnew("Wacute"));
- GlyphOrder.setByGID(map, 0x0174, sdsnew("Wcircumflex"));
- GlyphOrder.setByGID(map, 0x1E84, sdsnew("Wdieresis"));
- GlyphOrder.setByGID(map, 0x1E80, sdsnew("Wgrave"));
- GlyphOrder.setByGID(map, 0x0058, sdsnew("X"));
- GlyphOrder.setByGID(map, 0x039E, sdsnew("Xi"));
- GlyphOrder.setByGID(map, 0x0059, sdsnew("Y"));
- GlyphOrder.setByGID(map, 0x00DD, sdsnew("Yacute"));
- GlyphOrder.setByGID(map, 0x0176, sdsnew("Ycircumflex"));
- GlyphOrder.setByGID(map, 0x0178, sdsnew("Ydieresis"));
- GlyphOrder.setByGID(map, 0x1EF2, sdsnew("Ygrave"));
- GlyphOrder.setByGID(map, 0x005A, sdsnew("Z"));
- GlyphOrder.setByGID(map, 0x0179, sdsnew("Zacute"));
- GlyphOrder.setByGID(map, 0x017D, sdsnew("Zcaron"));
- GlyphOrder.setByGID(map, 0x017B, sdsnew("Zdotaccent"));
- GlyphOrder.setByGID(map, 0x0396, sdsnew("Zeta"));
- GlyphOrder.setByGID(map, 0x0061, sdsnew("a"));
- GlyphOrder.setByGID(map, 0x00E1, sdsnew("aacute"));
- GlyphOrder.setByGID(map, 0x0103, sdsnew("abreve"));
- GlyphOrder.setByGID(map, 0x00E2, sdsnew("acircumflex"));
- GlyphOrder.setByGID(map, 0x00B4, sdsnew("acute"));
- GlyphOrder.setByGID(map, 0x0301, sdsnew("acutecomb"));
- GlyphOrder.setByGID(map, 0x00E4, sdsnew("adieresis"));
- GlyphOrder.setByGID(map, 0x00E6, sdsnew("ae"));
- GlyphOrder.setByGID(map, 0x01FD, sdsnew("aeacute"));
- GlyphOrder.setByGID(map, 0x00E0, sdsnew("agrave"));
- GlyphOrder.setByGID(map, 0x2135, sdsnew("aleph"));
- GlyphOrder.setByGID(map, 0x03B1, sdsnew("alpha"));
- GlyphOrder.setByGID(map, 0x03AC, sdsnew("alphatonos"));
- GlyphOrder.setByGID(map, 0x0101, sdsnew("amacron"));
- GlyphOrder.setByGID(map, 0x0026, sdsnew("ampersand"));
- GlyphOrder.setByGID(map, 0x2220, sdsnew("angle"));
- GlyphOrder.setByGID(map, 0x2329, sdsnew("angleleft"));
- GlyphOrder.setByGID(map, 0x232A, sdsnew("angleright"));
- GlyphOrder.setByGID(map, 0x0387, sdsnew("anoteleia"));
- GlyphOrder.setByGID(map, 0x0105, sdsnew("aogonek"));
- GlyphOrder.setByGID(map, 0x2248, sdsnew("approxequal"));
- GlyphOrder.setByGID(map, 0x00E5, sdsnew("aring"));
- GlyphOrder.setByGID(map, 0x01FB, sdsnew("aringacute"));
- GlyphOrder.setByGID(map, 0x2194, sdsnew("arrowboth"));
- GlyphOrder.setByGID(map, 0x21D4, sdsnew("arrowdblboth"));
- GlyphOrder.setByGID(map, 0x21D3, sdsnew("arrowdbldown"));
- GlyphOrder.setByGID(map, 0x21D0, sdsnew("arrowdblleft"));
- GlyphOrder.setByGID(map, 0x21D2, sdsnew("arrowdblright"));
- GlyphOrder.setByGID(map, 0x21D1, sdsnew("arrowdblup"));
- GlyphOrder.setByGID(map, 0x2193, sdsnew("arrowdown"));
- GlyphOrder.setByGID(map, 0x2190, sdsnew("arrowleft"));
- GlyphOrder.setByGID(map, 0x2192, sdsnew("arrowright"));
- GlyphOrder.setByGID(map, 0x2191, sdsnew("arrowup"));
- GlyphOrder.setByGID(map, 0x2195, sdsnew("arrowupdn"));
- GlyphOrder.setByGID(map, 0x21A8, sdsnew("arrowupdnbse"));
- GlyphOrder.setByGID(map, 0x005E, sdsnew("asciicircum"));
- GlyphOrder.setByGID(map, 0x007E, sdsnew("asciitilde"));
- GlyphOrder.setByGID(map, 0x002A, sdsnew("asterisk"));
- GlyphOrder.setByGID(map, 0x2217, sdsnew("asteriskmath"));
- GlyphOrder.setByGID(map, 0x0040, sdsnew("at"));
- GlyphOrder.setByGID(map, 0x00E3, sdsnew("atilde"));
- GlyphOrder.setByGID(map, 0x0062, sdsnew("b"));
- GlyphOrder.setByGID(map, 0x005C, sdsnew("backslash"));
- GlyphOrder.setByGID(map, 0x007C, sdsnew("bar"));
- GlyphOrder.setByGID(map, 0x03B2, sdsnew("beta"));
- GlyphOrder.setByGID(map, 0x2588, sdsnew("block"));
- GlyphOrder.setByGID(map, 0x007B, sdsnew("braceleft"));
- GlyphOrder.setByGID(map, 0x007D, sdsnew("braceright"));
- GlyphOrder.setByGID(map, 0x005B, sdsnew("bracketleft"));
- GlyphOrder.setByGID(map, 0x005D, sdsnew("bracketright"));
- GlyphOrder.setByGID(map, 0x02D8, sdsnew("breve"));
- GlyphOrder.setByGID(map, 0x00A6, sdsnew("brokenbar"));
- GlyphOrder.setByGID(map, 0x2022, sdsnew("bullet"));
- GlyphOrder.setByGID(map, 0x0063, sdsnew("c"));
- GlyphOrder.setByGID(map, 0x0107, sdsnew("cacute"));
- GlyphOrder.setByGID(map, 0x02C7, sdsnew("caron"));
- GlyphOrder.setByGID(map, 0x21B5, sdsnew("carriagereturn"));
- GlyphOrder.setByGID(map, 0x010D, sdsnew("ccaron"));
- GlyphOrder.setByGID(map, 0x00E7, sdsnew("ccedilla"));
- GlyphOrder.setByGID(map, 0x0109, sdsnew("ccircumflex"));
- GlyphOrder.setByGID(map, 0x010B, sdsnew("cdotaccent"));
- GlyphOrder.setByGID(map, 0x00B8, sdsnew("cedilla"));
- GlyphOrder.setByGID(map, 0x00A2, sdsnew("cent"));
- GlyphOrder.setByGID(map, 0x03C7, sdsnew("chi"));
- GlyphOrder.setByGID(map, 0x25CB, sdsnew("circle"));
- GlyphOrder.setByGID(map, 0x2297, sdsnew("circlemultiply"));
- GlyphOrder.setByGID(map, 0x2295, sdsnew("circleplus"));
- GlyphOrder.setByGID(map, 0x02C6, sdsnew("circumflex"));
- GlyphOrder.setByGID(map, 0x2663, sdsnew("club"));
- GlyphOrder.setByGID(map, 0x003A, sdsnew("colon"));
- GlyphOrder.setByGID(map, 0x20A1, sdsnew("colonmonetary"));
- GlyphOrder.setByGID(map, 0x002C, sdsnew("comma"));
- GlyphOrder.setByGID(map, 0x2245, sdsnew("congruent"));
- GlyphOrder.setByGID(map, 0x00A9, sdsnew("copyright"));
- GlyphOrder.setByGID(map, 0x00A4, sdsnew("currency"));
- GlyphOrder.setByGID(map, 0x0064, sdsnew("d"));
- GlyphOrder.setByGID(map, 0x2020, sdsnew("dagger"));
- GlyphOrder.setByGID(map, 0x2021, sdsnew("daggerdbl"));
- GlyphOrder.setByGID(map, 0x010F, sdsnew("dcaron"));
- GlyphOrder.setByGID(map, 0x0111, sdsnew("dcroat"));
- GlyphOrder.setByGID(map, 0x00B0, sdsnew("degree"));
- GlyphOrder.setByGID(map, 0x03B4, sdsnew("delta"));
- GlyphOrder.setByGID(map, 0x2666, sdsnew("diamond"));
- GlyphOrder.setByGID(map, 0x00A8, sdsnew("dieresis"));
- GlyphOrder.setByGID(map, 0x0385, sdsnew("dieresistonos"));
- GlyphOrder.setByGID(map, 0x00F7, sdsnew("divide"));
- GlyphOrder.setByGID(map, 0x2593, sdsnew("dkshade"));
- GlyphOrder.setByGID(map, 0x2584, sdsnew("dnblock"));
- GlyphOrder.setByGID(map, 0x0024, sdsnew("dollar"));
- GlyphOrder.setByGID(map, 0x20AB, sdsnew("dong"));
- GlyphOrder.setByGID(map, 0x02D9, sdsnew("dotaccent"));
- GlyphOrder.setByGID(map, 0x0323, sdsnew("dotbelowcomb"));
- GlyphOrder.setByGID(map, 0x0131, sdsnew("dotlessi"));
- GlyphOrder.setByGID(map, 0x22C5, sdsnew("dotmath"));
- GlyphOrder.setByGID(map, 0x0065, sdsnew("e"));
- GlyphOrder.setByGID(map, 0x00E9, sdsnew("eacute"));
- GlyphOrder.setByGID(map, 0x0115, sdsnew("ebreve"));
- GlyphOrder.setByGID(map, 0x011B, sdsnew("ecaron"));
- GlyphOrder.setByGID(map, 0x00EA, sdsnew("ecircumflex"));
- GlyphOrder.setByGID(map, 0x00EB, sdsnew("edieresis"));
- GlyphOrder.setByGID(map, 0x0117, sdsnew("edotaccent"));
- GlyphOrder.setByGID(map, 0x00E8, sdsnew("egrave"));
- GlyphOrder.setByGID(map, 0x0038, sdsnew("eight"));
- GlyphOrder.setByGID(map, 0x2208, sdsnew("element"));
- GlyphOrder.setByGID(map, 0x2026, sdsnew("ellipsis"));
- GlyphOrder.setByGID(map, 0x0113, sdsnew("emacron"));
- GlyphOrder.setByGID(map, 0x2014, sdsnew("emdash"));
- GlyphOrder.setByGID(map, 0x2205, sdsnew("emptyset"));
- GlyphOrder.setByGID(map, 0x2013, sdsnew("endash"));
- GlyphOrder.setByGID(map, 0x014B, sdsnew("eng"));
- GlyphOrder.setByGID(map, 0x0119, sdsnew("eogonek"));
- GlyphOrder.setByGID(map, 0x03B5, sdsnew("epsilon"));
- GlyphOrder.setByGID(map, 0x03AD, sdsnew("epsilontonos"));
- GlyphOrder.setByGID(map, 0x003D, sdsnew("equal"));
- GlyphOrder.setByGID(map, 0x2261, sdsnew("equivalence"));
- GlyphOrder.setByGID(map, 0x212E, sdsnew("estimated"));
- GlyphOrder.setByGID(map, 0x03B7, sdsnew("eta"));
- GlyphOrder.setByGID(map, 0x03AE, sdsnew("etatonos"));
- GlyphOrder.setByGID(map, 0x00F0, sdsnew("eth"));
- GlyphOrder.setByGID(map, 0x0021, sdsnew("exclam"));
- GlyphOrder.setByGID(map, 0x203C, sdsnew("exclamdbl"));
- GlyphOrder.setByGID(map, 0x00A1, sdsnew("exclamdown"));
- GlyphOrder.setByGID(map, 0x2203, sdsnew("existential"));
- GlyphOrder.setByGID(map, 0x0066, sdsnew("f"));
- GlyphOrder.setByGID(map, 0x2640, sdsnew("female"));
- GlyphOrder.setByGID(map, 0x2012, sdsnew("figuredash"));
- GlyphOrder.setByGID(map, 0x25A0, sdsnew("filledbox"));
- GlyphOrder.setByGID(map, 0x25AC, sdsnew("filledrect"));
- GlyphOrder.setByGID(map, 0x0035, sdsnew("five"));
- GlyphOrder.setByGID(map, 0x215D, sdsnew("fiveeighths"));
- GlyphOrder.setByGID(map, 0x0192, sdsnew("florin"));
- GlyphOrder.setByGID(map, 0x0034, sdsnew("four"));
- GlyphOrder.setByGID(map, 0x2044, sdsnew("fraction"));
- GlyphOrder.setByGID(map, 0x20A3, sdsnew("franc"));
- GlyphOrder.setByGID(map, 0x0067, sdsnew("g"));
- GlyphOrder.setByGID(map, 0x03B3, sdsnew("gamma"));
- GlyphOrder.setByGID(map, 0x011F, sdsnew("gbreve"));
- GlyphOrder.setByGID(map, 0x01E7, sdsnew("gcaron"));
- GlyphOrder.setByGID(map, 0x011D, sdsnew("gcircumflex"));
- GlyphOrder.setByGID(map, 0x0121, sdsnew("gdotaccent"));
- GlyphOrder.setByGID(map, 0x00DF, sdsnew("germandbls"));
- GlyphOrder.setByGID(map, 0x2207, sdsnew("gradient"));
- GlyphOrder.setByGID(map, 0x0060, sdsnew("grave"));
- GlyphOrder.setByGID(map, 0x0300, sdsnew("gravecomb"));
- GlyphOrder.setByGID(map, 0x003E, sdsnew("greater"));
- GlyphOrder.setByGID(map, 0x2265, sdsnew("greaterequal"));
- GlyphOrder.setByGID(map, 0x00AB, sdsnew("guillemotleft"));
- GlyphOrder.setByGID(map, 0x00BB, sdsnew("guillemotright"));
- GlyphOrder.setByGID(map, 0x2039, sdsnew("guilsinglleft"));
- GlyphOrder.setByGID(map, 0x203A, sdsnew("guilsinglright"));
- GlyphOrder.setByGID(map, 0x0068, sdsnew("h"));
- GlyphOrder.setByGID(map, 0x0127, sdsnew("hbar"));
- GlyphOrder.setByGID(map, 0x0125, sdsnew("hcircumflex"));
- GlyphOrder.setByGID(map, 0x2665, sdsnew("heart"));
- GlyphOrder.setByGID(map, 0x0309, sdsnew("hookabovecomb"));
- GlyphOrder.setByGID(map, 0x2302, sdsnew("house"));
- GlyphOrder.setByGID(map, 0x02DD, sdsnew("hungarumlaut"));
- GlyphOrder.setByGID(map, 0x002D, sdsnew("hyphen"));
- GlyphOrder.setByGID(map, 0x0069, sdsnew("i"));
- GlyphOrder.setByGID(map, 0x00ED, sdsnew("iacute"));
- GlyphOrder.setByGID(map, 0x012D, sdsnew("ibreve"));
- GlyphOrder.setByGID(map, 0x00EE, sdsnew("icircumflex"));
- GlyphOrder.setByGID(map, 0x00EF, sdsnew("idieresis"));
- GlyphOrder.setByGID(map, 0x00EC, sdsnew("igrave"));
- GlyphOrder.setByGID(map, 0x0133, sdsnew("ij"));
- GlyphOrder.setByGID(map, 0x012B, sdsnew("imacron"));
- GlyphOrder.setByGID(map, 0x221E, sdsnew("infinity"));
- GlyphOrder.setByGID(map, 0x222B, sdsnew("integral"));
- GlyphOrder.setByGID(map, 0x2321, sdsnew("integralbt"));
- GlyphOrder.setByGID(map, 0x2320, sdsnew("integraltp"));
- GlyphOrder.setByGID(map, 0x2229, sdsnew("intersection"));
- GlyphOrder.setByGID(map, 0x25D8, sdsnew("invbullet"));
- GlyphOrder.setByGID(map, 0x25D9, sdsnew("invcircle"));
- GlyphOrder.setByGID(map, 0x263B, sdsnew("invsmileface"));
- GlyphOrder.setByGID(map, 0x012F, sdsnew("iogonek"));
- GlyphOrder.setByGID(map, 0x03B9, sdsnew("iota"));
- GlyphOrder.setByGID(map, 0x03CA, sdsnew("iotadieresis"));
- GlyphOrder.setByGID(map, 0x0390, sdsnew("iotadieresistonos"));
- GlyphOrder.setByGID(map, 0x03AF, sdsnew("iotatonos"));
- GlyphOrder.setByGID(map, 0x0129, sdsnew("itilde"));
- GlyphOrder.setByGID(map, 0x006A, sdsnew("j"));
- GlyphOrder.setByGID(map, 0x0135, sdsnew("jcircumflex"));
- GlyphOrder.setByGID(map, 0x006B, sdsnew("k"));
- GlyphOrder.setByGID(map, 0x03BA, sdsnew("kappa"));
- GlyphOrder.setByGID(map, 0x0138, sdsnew("kgreenlandic"));
- GlyphOrder.setByGID(map, 0x006C, sdsnew("l"));
- GlyphOrder.setByGID(map, 0x013A, sdsnew("lacute"));
- GlyphOrder.setByGID(map, 0x03BB, sdsnew("lambda"));
- GlyphOrder.setByGID(map, 0x013E, sdsnew("lcaron"));
- GlyphOrder.setByGID(map, 0x0140, sdsnew("ldot"));
- GlyphOrder.setByGID(map, 0x003C, sdsnew("less"));
- GlyphOrder.setByGID(map, 0x2264, sdsnew("lessequal"));
- GlyphOrder.setByGID(map, 0x258C, sdsnew("lfblock"));
- GlyphOrder.setByGID(map, 0x20A4, sdsnew("lira"));
- GlyphOrder.setByGID(map, 0x2227, sdsnew("logicaland"));
- GlyphOrder.setByGID(map, 0x00AC, sdsnew("logicalnot"));
- GlyphOrder.setByGID(map, 0x2228, sdsnew("logicalor"));
- GlyphOrder.setByGID(map, 0x017F, sdsnew("longs"));
- GlyphOrder.setByGID(map, 0x25CA, sdsnew("lozenge"));
- GlyphOrder.setByGID(map, 0x0142, sdsnew("lslash"));
- GlyphOrder.setByGID(map, 0x2591, sdsnew("ltshade"));
- GlyphOrder.setByGID(map, 0x006D, sdsnew("m"));
- GlyphOrder.setByGID(map, 0x00AF, sdsnew("macron"));
- GlyphOrder.setByGID(map, 0x2642, sdsnew("male"));
- GlyphOrder.setByGID(map, 0x2212, sdsnew("minus"));
- GlyphOrder.setByGID(map, 0x2032, sdsnew("minute"));
- GlyphOrder.setByGID(map, 0x00B5, sdsnew("mu"));
- GlyphOrder.setByGID(map, 0x00D7, sdsnew("multiply"));
- GlyphOrder.setByGID(map, 0x266A, sdsnew("musicalnote"));
- GlyphOrder.setByGID(map, 0x266B, sdsnew("musicalnotedbl"));
- GlyphOrder.setByGID(map, 0x006E, sdsnew("n"));
- GlyphOrder.setByGID(map, 0x0144, sdsnew("nacute"));
- GlyphOrder.setByGID(map, 0x0149, sdsnew("napostrophe"));
- GlyphOrder.setByGID(map, 0x0148, sdsnew("ncaron"));
- GlyphOrder.setByGID(map, 0x0039, sdsnew("nine"));
- GlyphOrder.setByGID(map, 0x2209, sdsnew("notelement"));
- GlyphOrder.setByGID(map, 0x2260, sdsnew("notequal"));
- GlyphOrder.setByGID(map, 0x2284, sdsnew("notsubset"));
- GlyphOrder.setByGID(map, 0x00F1, sdsnew("ntilde"));
- GlyphOrder.setByGID(map, 0x03BD, sdsnew("nu"));
- GlyphOrder.setByGID(map, 0x0023, sdsnew("numbersign"));
- GlyphOrder.setByGID(map, 0x006F, sdsnew("o"));
- GlyphOrder.setByGID(map, 0x00F3, sdsnew("oacute"));
- GlyphOrder.setByGID(map, 0x014F, sdsnew("obreve"));
- GlyphOrder.setByGID(map, 0x00F4, sdsnew("ocircumflex"));
- GlyphOrder.setByGID(map, 0x00F6, sdsnew("odieresis"));
- GlyphOrder.setByGID(map, 0x0153, sdsnew("oe"));
- GlyphOrder.setByGID(map, 0x02DB, sdsnew("ogonek"));
- GlyphOrder.setByGID(map, 0x00F2, sdsnew("ograve"));
- GlyphOrder.setByGID(map, 0x01A1, sdsnew("ohorn"));
- GlyphOrder.setByGID(map, 0x0151, sdsnew("ohungarumlaut"));
- GlyphOrder.setByGID(map, 0x014D, sdsnew("omacron"));
- GlyphOrder.setByGID(map, 0x03C9, sdsnew("omega"));
- GlyphOrder.setByGID(map, 0x03D6, sdsnew("omega1"));
- GlyphOrder.setByGID(map, 0x03CE, sdsnew("omegatonos"));
- GlyphOrder.setByGID(map, 0x03BF, sdsnew("omicron"));
- GlyphOrder.setByGID(map, 0x03CC, sdsnew("omicrontonos"));
- GlyphOrder.setByGID(map, 0x0031, sdsnew("one"));
- GlyphOrder.setByGID(map, 0x2024, sdsnew("onedotenleader"));
- GlyphOrder.setByGID(map, 0x215B, sdsnew("oneeighth"));
- GlyphOrder.setByGID(map, 0x00BD, sdsnew("onehalf"));
- GlyphOrder.setByGID(map, 0x00BC, sdsnew("onequarter"));
- GlyphOrder.setByGID(map, 0x2153, sdsnew("onethird"));
- GlyphOrder.setByGID(map, 0x25E6, sdsnew("openbullet"));
- GlyphOrder.setByGID(map, 0x00AA, sdsnew("ordfeminine"));
- GlyphOrder.setByGID(map, 0x00BA, sdsnew("ordmasculine"));
- GlyphOrder.setByGID(map, 0x221F, sdsnew("orthogonal"));
- GlyphOrder.setByGID(map, 0x00F8, sdsnew("oslash"));
- GlyphOrder.setByGID(map, 0x01FF, sdsnew("oslashacute"));
- GlyphOrder.setByGID(map, 0x00F5, sdsnew("otilde"));
- GlyphOrder.setByGID(map, 0x0070, sdsnew("p"));
- GlyphOrder.setByGID(map, 0x00B6, sdsnew("paragraph"));
- GlyphOrder.setByGID(map, 0x0028, sdsnew("parenleft"));
- GlyphOrder.setByGID(map, 0x0029, sdsnew("parenright"));
- GlyphOrder.setByGID(map, 0x2202, sdsnew("partialdiff"));
- GlyphOrder.setByGID(map, 0x0025, sdsnew("percent"));
- GlyphOrder.setByGID(map, 0x002E, sdsnew("period"));
- GlyphOrder.setByGID(map, 0x00B7, sdsnew("periodcentered"));
- GlyphOrder.setByGID(map, 0x22A5, sdsnew("perpendicular"));
- GlyphOrder.setByGID(map, 0x2030, sdsnew("perthousand"));
- GlyphOrder.setByGID(map, 0x20A7, sdsnew("peseta"));
- GlyphOrder.setByGID(map, 0x03C6, sdsnew("phi"));
- GlyphOrder.setByGID(map, 0x03D5, sdsnew("phi1"));
- GlyphOrder.setByGID(map, 0x03C0, sdsnew("pi"));
- GlyphOrder.setByGID(map, 0x002B, sdsnew("plus"));
- GlyphOrder.setByGID(map, 0x00B1, sdsnew("plusminus"));
- GlyphOrder.setByGID(map, 0x211E, sdsnew("prescription"));
- GlyphOrder.setByGID(map, 0x220F, sdsnew("product"));
- GlyphOrder.setByGID(map, 0x2282, sdsnew("propersubset"));
- GlyphOrder.setByGID(map, 0x2283, sdsnew("propersuperset"));
- GlyphOrder.setByGID(map, 0x221D, sdsnew("proportional"));
- GlyphOrder.setByGID(map, 0x03C8, sdsnew("psi"));
- GlyphOrder.setByGID(map, 0x0071, sdsnew("q"));
- GlyphOrder.setByGID(map, 0x003F, sdsnew("question"));
- GlyphOrder.setByGID(map, 0x00BF, sdsnew("questiondown"));
- GlyphOrder.setByGID(map, 0x0022, sdsnew("quotedbl"));
- GlyphOrder.setByGID(map, 0x201E, sdsnew("quotedblbase"));
- GlyphOrder.setByGID(map, 0x201C, sdsnew("quotedblleft"));
- GlyphOrder.setByGID(map, 0x201D, sdsnew("quotedblright"));
- GlyphOrder.setByGID(map, 0x2018, sdsnew("quoteleft"));
- GlyphOrder.setByGID(map, 0x201B, sdsnew("quotereversed"));
- GlyphOrder.setByGID(map, 0x2019, sdsnew("quoteright"));
- GlyphOrder.setByGID(map, 0x201A, sdsnew("quotesinglbase"));
- GlyphOrder.setByGID(map, 0x0027, sdsnew("quotesingle"));
- GlyphOrder.setByGID(map, 0x0072, sdsnew("r"));
- GlyphOrder.setByGID(map, 0x0155, sdsnew("racute"));
- GlyphOrder.setByGID(map, 0x221A, sdsnew("radical"));
- GlyphOrder.setByGID(map, 0x0159, sdsnew("rcaron"));
- GlyphOrder.setByGID(map, 0x2286, sdsnew("reflexsubset"));
- GlyphOrder.setByGID(map, 0x2287, sdsnew("reflexsuperset"));
- GlyphOrder.setByGID(map, 0x00AE, sdsnew("registered"));
- GlyphOrder.setByGID(map, 0x2310, sdsnew("revlogicalnot"));
- GlyphOrder.setByGID(map, 0x03C1, sdsnew("rho"));
- GlyphOrder.setByGID(map, 0x02DA, sdsnew("ring"));
- GlyphOrder.setByGID(map, 0x2590, sdsnew("rtblock"));
- GlyphOrder.setByGID(map, 0x0073, sdsnew("s"));
- GlyphOrder.setByGID(map, 0x015B, sdsnew("sacute"));
- GlyphOrder.setByGID(map, 0x0161, sdsnew("scaron"));
- GlyphOrder.setByGID(map, 0x015F, sdsnew("scedilla"));
- GlyphOrder.setByGID(map, 0x015D, sdsnew("scircumflex"));
- GlyphOrder.setByGID(map, 0x2033, sdsnew("second"));
- GlyphOrder.setByGID(map, 0x00A7, sdsnew("section"));
- GlyphOrder.setByGID(map, 0x003B, sdsnew("semicolon"));
- GlyphOrder.setByGID(map, 0x0037, sdsnew("seven"));
- GlyphOrder.setByGID(map, 0x215E, sdsnew("seveneighths"));
- GlyphOrder.setByGID(map, 0x2592, sdsnew("shade"));
- GlyphOrder.setByGID(map, 0x03C3, sdsnew("sigma"));
- GlyphOrder.setByGID(map, 0x03C2, sdsnew("sigma1"));
- GlyphOrder.setByGID(map, 0x223C, sdsnew("similar"));
- GlyphOrder.setByGID(map, 0x0036, sdsnew("six"));
- GlyphOrder.setByGID(map, 0x002F, sdsnew("slash"));
- GlyphOrder.setByGID(map, 0x263A, sdsnew("smileface"));
- GlyphOrder.setByGID(map, 0x0020, sdsnew("space"));
- GlyphOrder.setByGID(map, 0x2660, sdsnew("spade"));
- GlyphOrder.setByGID(map, 0x00A3, sdsnew("sterling"));
- GlyphOrder.setByGID(map, 0x220B, sdsnew("suchthat"));
- GlyphOrder.setByGID(map, 0x2211, sdsnew("summation"));
- GlyphOrder.setByGID(map, 0x263C, sdsnew("sun"));
- GlyphOrder.setByGID(map, 0x0074, sdsnew("t"));
- GlyphOrder.setByGID(map, 0x03C4, sdsnew("tau"));
- GlyphOrder.setByGID(map, 0x0167, sdsnew("tbar"));
- GlyphOrder.setByGID(map, 0x0165, sdsnew("tcaron"));
- GlyphOrder.setByGID(map, 0x2234, sdsnew("therefore"));
- GlyphOrder.setByGID(map, 0x03B8, sdsnew("theta"));
- GlyphOrder.setByGID(map, 0x03D1, sdsnew("theta1"));
- GlyphOrder.setByGID(map, 0x00FE, sdsnew("thorn"));
- GlyphOrder.setByGID(map, 0x0033, sdsnew("three"));
- GlyphOrder.setByGID(map, 0x215C, sdsnew("threeeighths"));
- GlyphOrder.setByGID(map, 0x00BE, sdsnew("threequarters"));
- GlyphOrder.setByGID(map, 0x02DC, sdsnew("tilde"));
- GlyphOrder.setByGID(map, 0x0303, sdsnew("tildecomb"));
- GlyphOrder.setByGID(map, 0x0384, sdsnew("tonos"));
- GlyphOrder.setByGID(map, 0x2122, sdsnew("trademark"));
- GlyphOrder.setByGID(map, 0x25BC, sdsnew("triagdn"));
- GlyphOrder.setByGID(map, 0x25C4, sdsnew("triaglf"));
- GlyphOrder.setByGID(map, 0x25BA, sdsnew("triagrt"));
- GlyphOrder.setByGID(map, 0x25B2, sdsnew("triagup"));
- GlyphOrder.setByGID(map, 0x0032, sdsnew("two"));
- GlyphOrder.setByGID(map, 0x2025, sdsnew("twodotenleader"));
- GlyphOrder.setByGID(map, 0x2154, sdsnew("twothirds"));
- GlyphOrder.setByGID(map, 0x0075, sdsnew("u"));
- GlyphOrder.setByGID(map, 0x00FA, sdsnew("uacute"));
- GlyphOrder.setByGID(map, 0x016D, sdsnew("ubreve"));
- GlyphOrder.setByGID(map, 0x00FB, sdsnew("ucircumflex"));
- GlyphOrder.setByGID(map, 0x00FC, sdsnew("udieresis"));
- GlyphOrder.setByGID(map, 0x00F9, sdsnew("ugrave"));
- GlyphOrder.setByGID(map, 0x01B0, sdsnew("uhorn"));
- GlyphOrder.setByGID(map, 0x0171, sdsnew("uhungarumlaut"));
- GlyphOrder.setByGID(map, 0x016B, sdsnew("umacron"));
- GlyphOrder.setByGID(map, 0x005F, sdsnew("underscore"));
- GlyphOrder.setByGID(map, 0x2017, sdsnew("underscoredbl"));
- GlyphOrder.setByGID(map, 0x222A, sdsnew("union"));
- GlyphOrder.setByGID(map, 0x2200, sdsnew("universal"));
- GlyphOrder.setByGID(map, 0x0173, sdsnew("uogonek"));
- GlyphOrder.setByGID(map, 0x2580, sdsnew("upblock"));
- GlyphOrder.setByGID(map, 0x03C5, sdsnew("upsilon"));
- GlyphOrder.setByGID(map, 0x03CB, sdsnew("upsilondieresis"));
- GlyphOrder.setByGID(map, 0x03B0, sdsnew("upsilondieresistonos"));
- GlyphOrder.setByGID(map, 0x03CD, sdsnew("upsilontonos"));
- GlyphOrder.setByGID(map, 0x016F, sdsnew("uring"));
- GlyphOrder.setByGID(map, 0x0169, sdsnew("utilde"));
- GlyphOrder.setByGID(map, 0x0076, sdsnew("v"));
- GlyphOrder.setByGID(map, 0x0077, sdsnew("w"));
- GlyphOrder.setByGID(map, 0x1E83, sdsnew("wacute"));
- GlyphOrder.setByGID(map, 0x0175, sdsnew("wcircumflex"));
- GlyphOrder.setByGID(map, 0x1E85, sdsnew("wdieresis"));
- GlyphOrder.setByGID(map, 0x2118, sdsnew("weierstrass"));
- GlyphOrder.setByGID(map, 0x1E81, sdsnew("wgrave"));
- GlyphOrder.setByGID(map, 0x0078, sdsnew("x"));
- GlyphOrder.setByGID(map, 0x03BE, sdsnew("xi"));
- GlyphOrder.setByGID(map, 0x0079, sdsnew("y"));
- GlyphOrder.setByGID(map, 0x00FD, sdsnew("yacute"));
- GlyphOrder.setByGID(map, 0x0177, sdsnew("ycircumflex"));
- GlyphOrder.setByGID(map, 0x00FF, sdsnew("ydieresis"));
- GlyphOrder.setByGID(map, 0x00A5, sdsnew("yen"));
- GlyphOrder.setByGID(map, 0x1EF3, sdsnew("ygrave"));
- GlyphOrder.setByGID(map, 0x007A, sdsnew("z"));
- GlyphOrder.setByGID(map, 0x017A, sdsnew("zacute"));
- GlyphOrder.setByGID(map, 0x017E, sdsnew("zcaron"));
- GlyphOrder.setByGID(map, 0x017C, sdsnew("zdotaccent"));
- GlyphOrder.setByGID(map, 0x0030, sdsnew("zero"));
- GlyphOrder.setByGID(map, 0x03B6, sdsnew("zeta"));
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.h
deleted file mode 100644
index 98f854b6f49..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CARYLL_SUPPORT_AGLFN_H
-#define CARYLL_SUPPORT_AGLFN_H
-#include "otfcc/glyph-order.h"
-
-void aglfn_setupNames(otfcc_GlyphOrder *map);
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aliases.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aliases.h
deleted file mode 100644
index 25cd8e5e672..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aliases.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef CARYLL_SUPPORT_ALIASES_H
-#define CARYLL_SUPPORT_ALIASES_H
-
-#include <stdint.h>
-
-#define loggedStep(...) \
- for (bool ___loggedstep_v = (options->logger->startSDS(options->logger, \
- sdscatprintf(sdsempty(), __VA_ARGS__)), \
- true); \
- ___loggedstep_v; ___loggedstep_v = false, options->logger->finish(options->logger))
-#define logError(...) \
- options->logger->logSDS(options->logger, log_vl_critical, log_type_error, \
- sdscatprintf(sdsempty(), __VA_ARGS__));
-#define logWarning(...) \
- options->logger->logSDS(options->logger, log_vl_important, log_type_warning, \
- sdscatprintf(sdsempty(), __VA_ARGS__));
-#define logNotice(...) \
- options->logger->logSDS(options->logger, log_vl_notice, log_type_info, \
- sdscatprintf(sdsempty(), __VA_ARGS__));
-#define logProgress(...) \
- options->logger->logSDS(options->logger, log_vl_progress, log_type_progress, \
- sdscatprintf(sdsempty(), __VA_ARGS__));
-
-#define FOR_TABLE_SILENT(name, table) \
- for (int __fortable_keep = 1, __fortable_count = 0, __notfound = 1; \
- __notfound && __fortable_keep && __fortable_count < packet.numTables; \
- __fortable_keep = !__fortable_keep, __fortable_count++) \
- for (otfcc_PacketPiece table = (packet.pieces)[__fortable_count]; __fortable_keep; \
- __fortable_keep = !__fortable_keep) \
- if (table.tag == (name)) \
- for (int __fortable_k2 = 1; __fortable_k2; __fortable_k2 = 0, __notfound = 0)
-
-#define FOR_TABLE(name, table) FOR_TABLE_SILENT(name, table)
-
-#define foreach_index(item, index, vector) \
- for (size_t index = 0, keep = 1; keep && index < (vector).length; keep = !keep, index++) \
- for (item = (vector).items + index; keep; keep = !keep)
-#define foreach(item, vector) foreach_index(item, __caryll_index, vector)
-#define foreach_hash(id, range) for (id = (range); id != NULL; id = id->hh.next)
-
-typedef uint8_t *font_file_pointer;
-
-// alias "package" otfcc_pHandle to Handle
-#include "otfcc/handle.h"
-#define Handle otfcc_iHandle
-typedef otfcc_GlyphHandle glyph_handle;
-typedef otfcc_FDHandle fd_handle;
-typedef otfcc_LookupHandle lookup_handle;
-
-// alias "package" otfcc_pkgGlyphOrder to GlyphOrder
-#include "otfcc/glyph-order.h"
-#define GlyphOrder otfcc_pkgGlyphOrder
-
-#include "otfcc/table/otl/classdef.h"
-#define ClassDef otl_iClassDef
-
-#include "otfcc/table/otl/coverage.h"
-#define Coverage otl_iCoverage
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.c
deleted file mode 100644
index b57a0e156cf..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "base64.h"
-#include "../otfcc-alloc.h"
-
-static const uint8_t base64_table[64] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-uint8_t *base64_encode(const uint8_t *src, size_t len, size_t *out_len) {
- uint8_t *out, *pos;
- const uint8_t *end, *in;
- size_t olen;
-
- olen = (len + 3 - 1) / 3 * 4; /* 3-byte blocks to 4-byte */
- olen++; /* nul termination */
- out = __caryll_malloc(sizeof(uint8_t) * olen);
- if (out == NULL) return NULL;
-
- end = src + len;
- in = src;
- pos = out;
- while (end - in >= 3) {
- *pos++ = base64_table[in[0] >> 2];
- *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
- *pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
- *pos++ = base64_table[in[2] & 0x3f];
- in += 3;
- }
-
- if (end - in) {
- *pos++ = base64_table[in[0] >> 2];
- if (end - in == 1) {
- *pos++ = base64_table[(in[0] & 0x03) << 4];
- *pos++ = '=';
- } else {
- *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
- *pos++ = base64_table[(in[1] & 0x0f) << 2];
- }
- *pos++ = '=';
- }
-
- *pos = '\0';
- if (out_len) *out_len = pos - out;
- return out;
-}
-
-uint8_t *base64_decode(const uint8_t *src, size_t len, size_t *out_len) {
- uint8_t dtable[256], *out, *pos, in[4], block[4], tmp;
- size_t i, count;
-
- memset(dtable, 0x80, 256);
- for (i = 0; i < sizeof(base64_table); i++)
- dtable[base64_table[i]] = i;
- dtable['='] = 0;
-
- count = 0;
- for (i = 0; i < len; i++) {
- if (dtable[src[i]] != 0x80) count++;
- }
-
- if (count % 4) return NULL;
-
- pos = out = __caryll_malloc(sizeof(uint8_t) * count);
- if (out == NULL) return NULL;
-
- count = 0;
- for (i = 0; i < len; i++) {
- tmp = dtable[src[i]];
- if (tmp == 0x80) continue;
-
- in[count] = src[i];
- block[count] = tmp;
- count++;
- if (count == 4) {
- *pos++ = (block[0] << 2) | (block[1] >> 4);
- *pos++ = (block[1] << 4) | (block[2] >> 2);
- *pos++ = (block[2] << 6) | block[3];
- count = 0;
- }
- }
-
- if (pos > out) {
- if (in[2] == '=')
- pos -= 2;
- else if (in[3] == '=')
- pos--;
- }
-
- *out_len = pos - out;
- return out;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.h
deleted file mode 100644
index 36d4702dd90..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef CARYLL_SUPPORT_BASE64_H
-#define CARYLL_SUPPORT_BASE64_H
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-uint8_t *base64_encode(const uint8_t *src, size_t len, size_t *out_len);
-uint8_t *base64_decode(const uint8_t *src, size_t len, size_t *out_len);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/bin-io.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/bin-io.h
deleted file mode 100644
index 2df14b4506b..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/bin-io.h
+++ /dev/null
@@ -1,171 +0,0 @@
-#ifndef CARYLL_SUPPORT_BIN_IO_H
-#define CARYLL_SUPPORT_BIN_IO_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef INLINE
-#ifdef _MSC_VER
-#define INLINE __forceinline /* use __forceinline (VC++ specific) */
-#else
-#define INLINE inline /* use standard inline */
-#endif
-#endif
-
-static INLINE bool otfcc_check_endian(void) {
- union {
- uint8_t i1[2];
- uint16_t i2;
- } check_union = {.i2 = 1}; // if you don't have a new VC, upgrade it
-
- return (check_union.i1[0] == 1);
-}
-
-static INLINE uint16_t otfcc_endian_convert16(uint16_t i) {
- if (otfcc_check_endian()) {
- union {
- uint8_t i1[2];
- uint16_t i2;
- } src, des;
-
- src.i2 = i;
-
- des.i1[0] = src.i1[1];
- des.i1[1] = src.i1[0];
-
- return des.i2;
- } else {
- return i;
- }
-}
-
-static INLINE uint32_t otfcc_endian_convert32(uint32_t i) {
- if (otfcc_check_endian()) {
- union {
- uint8_t i1[4];
- uint32_t i4;
- } src, des;
-
- src.i4 = i;
-
- des.i1[0] = src.i1[3];
- des.i1[1] = src.i1[2];
- des.i1[2] = src.i1[1];
- des.i1[3] = src.i1[0];
-
- return des.i4;
- } else {
- return i;
- }
-}
-
-static INLINE uint64_t otfcc_endian_convert64(uint64_t i) {
- if (otfcc_check_endian()) {
- union {
- uint8_t i1[8];
- uint64_t i8;
- } src, des;
-
- src.i8 = i;
-
- des.i1[0] = src.i1[7];
- des.i1[1] = src.i1[6];
- des.i1[2] = src.i1[5];
- des.i1[3] = src.i1[4];
- des.i1[4] = src.i1[3];
- des.i1[5] = src.i1[2];
- des.i1[6] = src.i1[1];
- des.i1[7] = src.i1[0];
-
- return des.i8;
- } else {
- return i;
- }
-}
-
-static INLINE uint16_t otfcc_get16u(FILE *file) {
- uint16_t tmp;
- size_t sizeRead = fread(&tmp, 2, 1, file);
- if (!sizeRead) {
- fprintf(stderr, "File corruption of terminated unexpectedly.\n");
- exit(EXIT_FAILURE);
- }
- return otfcc_endian_convert16(tmp);
-}
-
-static INLINE uint32_t otfcc_get32u(FILE *file) {
- uint32_t tmp;
- size_t sizeRead = fread(&tmp, 4, 1, file);
- if (!sizeRead) {
- fprintf(stderr, "File corruption of terminated unexpectedly.\n");
- exit(EXIT_FAILURE);
- }
- return otfcc_endian_convert32(tmp);
-}
-
-static INLINE uint64_t otfcc_get64u(FILE *file) {
- uint64_t tmp;
- size_t sizeRead = fread(&tmp, 8, 1, file);
- if (!sizeRead) {
- fprintf(stderr, "File corruption of terminated unexpectedly.\n");
- exit(EXIT_FAILURE);
- }
- return otfcc_endian_convert64(tmp);
-}
-
-// data reader
-static INLINE uint8_t read_8u(const uint8_t *src) {
- return src[0];
-}
-static INLINE uint16_t read_16u(const uint8_t *src) {
- uint16_t b0 = ((uint16_t)src[0]) << 8;
- uint16_t b1 = ((uint16_t)src[1]);
- return (b0 | b1);
-}
-static INLINE uint32_t read_24u(const uint8_t *src) {
- uint32_t b0 = ((uint32_t)src[0]) << 16;
- uint32_t b1 = ((uint32_t)src[1]) << 8;
- uint32_t b2 = ((uint32_t)src[2]);
- return (b0 | b1 | b2);
-}
-static INLINE uint32_t read_32u(const uint8_t *src) {
- uint32_t b0 = ((uint32_t)src[0]) << 24;
- uint32_t b1 = ((uint32_t)src[1]) << 16;
- uint32_t b2 = ((uint32_t)src[2]) << 8;
- uint32_t b3 = ((uint32_t)src[3]);
- return (b0 | b1 | b2 | b3);
-}
-static INLINE uint64_t read_64u(const uint8_t *src) {
- uint64_t b0 = ((uint64_t)src[0]) << 56;
- uint64_t b1 = ((uint64_t)src[1]) << 48;
- uint64_t b2 = ((uint64_t)src[2]) << 40;
- uint64_t b3 = ((uint64_t)src[3]) << 32;
- uint64_t b4 = ((uint64_t)src[4]) << 24;
- uint64_t b5 = ((uint64_t)src[5]) << 16;
- uint64_t b6 = ((uint64_t)src[6]) << 8;
- uint64_t b7 = ((uint64_t)src[7]);
- return (b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7);
-}
-static INLINE int8_t read_8s(const uint8_t *src) {
- return (int8_t)read_8u(src);
-}
-static INLINE int16_t read_16s(const uint8_t *src) {
- return (int16_t)read_16u(src);
-}
-static INLINE int32_t read_32s(const uint8_t *src) {
- return (int32_t)read_32u(src);
-}
-static INLINE int64_t read_64s(const uint8_t *src) {
- return (int64_t)read_64u(src);
-}
-
-static INLINE uint16_t be16(uint16_t x) {
- return ((x & 0xff) << 8) | ((x & 0xFF00) >> 8);
-}
-static INLINE uint32_t be32(uint32_t x) {
- return ((x & 0x000000ff) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) |
- ((x & 0xFF000000) >> 24);
-}
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/buffer/buffer.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/buffer/buffer.c
deleted file mode 100644
index 0fd855b1706..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/buffer/buffer.c
+++ /dev/null
@@ -1,231 +0,0 @@
-#include "caryll/buffer.h"
-#include "support/otfcc-alloc.h"
-
-caryll_Buffer *bufnew() {
- caryll_Buffer *buf;
- NEW(buf);
- buf->size = buf->free = 0;
- return buf;
-}
-void buffree(caryll_Buffer *buf) {
- if (!buf) return;
- if (buf->data) FREE(buf->data);
- FREE(buf);
-}
-size_t buflen(caryll_Buffer *buf) {
- return buf->size;
-}
-size_t bufpos(caryll_Buffer *buf) {
- return buf->cursor;
-}
-void bufseek(caryll_Buffer *buf, size_t pos) {
- buf->cursor = pos;
-}
-void bufclear(caryll_Buffer *buf) {
- buf->cursor = 0;
- buf->free = buf->size + buf->free;
- buf->size = 0;
-}
-
-static void bufbeforewrite(caryll_Buffer *buf, size_t towrite) {
- size_t currentSize = buf->size;
- size_t allocated = buf->size + buf->free;
- size_t required = buf->cursor + towrite;
- if (required < currentSize) {
- // Completely overlap.
- return;
- } else if (required <= allocated) {
- // Within range without reallocation
- buf->size = required;
- buf->free = allocated - buf->size;
- } else {
- // Needs realloc
- buf->size = required;
- buf->free = required; // Double growth
- if (buf->free > 0x1000000) { buf->free = 0x1000000; }
- RESIZE(buf->data, buf->size + buf->free);
- }
-}
-void bufwrite8(caryll_Buffer *buf, uint8_t byte) {
- bufbeforewrite(buf, 1);
- buf->data[buf->cursor++] = byte;
-}
-void bufwrite16l(caryll_Buffer *buf, uint16_t x) {
- bufbeforewrite(buf, 2);
- buf->data[buf->cursor++] = x & 0xFF;
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
-}
-void bufwrite16b(caryll_Buffer *buf, uint16_t x) {
- bufbeforewrite(buf, 2);
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
- buf->data[buf->cursor++] = x & 0xFF;
-}
-void bufwrite24l(caryll_Buffer *buf, uint32_t x) {
- bufbeforewrite(buf, 3);
- buf->data[buf->cursor++] = x & 0xFF;
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
- buf->data[buf->cursor++] = (x >> 16) & 0xFF;
-}
-void bufwrite24b(caryll_Buffer *buf, uint32_t x) {
- bufbeforewrite(buf, 3);
- buf->data[buf->cursor++] = (x >> 16) & 0xFF;
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
- buf->data[buf->cursor++] = x & 0xFF;
-}
-void bufwrite32l(caryll_Buffer *buf, uint32_t x) {
- bufbeforewrite(buf, 4);
- buf->data[buf->cursor++] = x & 0xFF;
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
- buf->data[buf->cursor++] = (x >> 16) & 0xFF;
- buf->data[buf->cursor++] = (x >> 24) & 0xFF;
-}
-void bufwrite32b(caryll_Buffer *buf, uint32_t x) {
- bufbeforewrite(buf, 4);
- buf->data[buf->cursor++] = (x >> 24) & 0xFF;
- buf->data[buf->cursor++] = (x >> 16) & 0xFF;
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
- buf->data[buf->cursor++] = x & 0xFF;
-}
-void bufwrite64l(caryll_Buffer *buf, uint64_t x) {
- bufbeforewrite(buf, 8);
- buf->data[buf->cursor++] = x & 0xFF;
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
- buf->data[buf->cursor++] = (x >> 16) & 0xFF;
- buf->data[buf->cursor++] = (x >> 24) & 0xFF;
- buf->data[buf->cursor++] = (x >> 32) & 0xFF;
- buf->data[buf->cursor++] = (x >> 40) & 0xFF;
- buf->data[buf->cursor++] = (x >> 48) & 0xFF;
- buf->data[buf->cursor++] = (x >> 56) & 0xFF;
-}
-void bufwrite64b(caryll_Buffer *buf, uint64_t x) {
- bufbeforewrite(buf, 8);
- buf->data[buf->cursor++] = (x >> 56) & 0xFF;
- buf->data[buf->cursor++] = (x >> 48) & 0xFF;
- buf->data[buf->cursor++] = (x >> 40) & 0xFF;
- buf->data[buf->cursor++] = (x >> 32) & 0xFF;
- buf->data[buf->cursor++] = (x >> 24) & 0xFF;
- buf->data[buf->cursor++] = (x >> 16) & 0xFF;
- buf->data[buf->cursor++] = (x >> 8) & 0xFF;
- buf->data[buf->cursor++] = x & 0xFF;
-}
-
-caryll_Buffer *bufninit(uint32_t n, ...) {
- caryll_Buffer *buf = bufnew();
- bufbeforewrite(buf, n);
- va_list ap;
- va_start(ap, n);
- for (uint16_t j = 0; j < n; j++) {
- bufwrite8(buf, (uint8_t)va_arg(ap, int));
- }
- va_end(ap);
- return buf;
-}
-void bufnwrite8(caryll_Buffer *buf, uint32_t n, ...) {
- bufbeforewrite(buf, n);
- va_list ap;
- va_start(ap, n);
- for (uint16_t j = 0; j < n; j++) {
- bufwrite8(buf, (uint8_t)va_arg(ap, int));
- }
- va_end(ap);
-}
-
-void bufwrite_sds(caryll_Buffer *buf, sds str) {
- if (!str) return;
- size_t len = sdslen(str);
- if (!len) return;
- bufbeforewrite(buf, len);
- memcpy(buf->data + buf->cursor, str, len);
- buf->cursor += len;
-}
-void bufwrite_str(caryll_Buffer *buf, const char *str) {
- if (!str) return;
- size_t len = strlen(str);
- if (!len) return;
- bufbeforewrite(buf, len);
- memcpy(buf->data + buf->cursor, str, len);
- buf->cursor += len;
-}
-void bufwrite_bytes(caryll_Buffer *buf, size_t len, const uint8_t *str) {
- if (!str) return;
- if (!len) return;
- bufbeforewrite(buf, len);
- memcpy(buf->data + buf->cursor, str, len);
- buf->cursor += len;
-}
-void bufwrite_buf(caryll_Buffer *buf, caryll_Buffer *that) {
- if (!that || !that->data) return;
- size_t len = buflen(that);
- bufbeforewrite(buf, len);
- memcpy(buf->data + buf->cursor, that->data, len);
- buf->cursor += len;
-}
-void bufwrite_bufdel(caryll_Buffer *buf, caryll_Buffer *that) {
- if (!that) return;
- if (!that->data) {
- buffree(that);
- return;
- }
- size_t len = buflen(that);
- bufbeforewrite(buf, len);
- memcpy(buf->data + buf->cursor, that->data, len);
- buffree(that);
- buf->cursor += len;
-}
-
-void buflongalign(caryll_Buffer *buf) {
- size_t cp = buf->cursor;
- bufseek(buf, buflen(buf));
- if (buflen(buf) % 4 == 1) {
- bufwrite8(buf, 0);
- bufwrite8(buf, 0);
- bufwrite8(buf, 0);
- } else if (buflen(buf) % 4 == 2) {
- bufwrite8(buf, 0);
- bufwrite8(buf, 0);
- } else if (buflen(buf) % 4 == 3) {
- bufwrite8(buf, 0);
- }
- bufseek(buf, cp);
-}
-
-// bufpingpong16b writes a buffer and an offset towards it.
-// [ ^ ] + ###### that
-// ^cp ^offset
-// |
-// V
-// [ @^ ###### ] , and the value of [@] equals to the former
-// offset.
-// ^cp ^offset
-// Common in writing OpenType features.
-void bufping16b(caryll_Buffer *buf, size_t *offset, size_t *cp) {
- bufwrite16b(buf, *offset);
- *cp = buf->cursor;
- bufseek(buf, *offset);
-}
-void bufping16bd(caryll_Buffer *buf, size_t *offset, size_t *shift, size_t *cp) {
- bufwrite16b(buf, *offset - *shift);
- *cp = buf->cursor;
- bufseek(buf, *offset);
-}
-void bufpong(caryll_Buffer *buf, size_t *offset, size_t *cp) {
- *offset = buf->cursor;
- bufseek(buf, *cp);
-}
-void bufpingpong16b(caryll_Buffer *buf, caryll_Buffer *that, size_t *offset, size_t *cp) {
- bufwrite16b(buf, *offset);
- *cp = buf->cursor;
- bufseek(buf, *offset);
- bufwrite_bufdel(buf, that);
- *offset = buf->cursor;
- bufseek(buf, *cp);
-}
-
-void bufprint(caryll_Buffer *buf) {
- for (size_t j = 0; j < buf->size; j++) {
- if (j % 16) fprintf(stderr, " ");
- fprintf(stderr, "%02X", buf->data[j]);
- if (j % 16 == 15) fprintf(stderr, "\n");
- }
- fprintf(stderr, "\n");
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/element-impl.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/element-impl.h
deleted file mode 100644
index b65a403fe5d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/element-impl.h
+++ /dev/null
@@ -1,275 +0,0 @@
-#ifndef CARYLL_SUPPORT_ELEMENT_IMPL_H
-#define CARYLL_SUPPORT_ELEMENT_IMPL_H
-
-#include "caryll/element.h"
-#include "otfcc-alloc.h"
-
-#ifndef __CARYLL_INLINE__
-#ifdef _MSC_VER
-#define __CARYLL_INLINE__ __forceinline /* use __forceinline (VC++ specific) */
-#else
-#define __CARYLL_INLINE__ inline /* use standard inline */
-#endif
-#endif
-
-#define __NARG__(...) __NARG_I_(__VA_ARGS__, __RSEQ_N())
-#define __NARG_I_(...) __ARG_N(__VA_ARGS__)
-#define __ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
- _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, \
- _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
- _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, N, ...) \
- N
-#define __RSEQ_N() \
- 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \
- 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \
- 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
-
-// general definition for any function name
-#define __CARYLL_VFUNC__2(name, n) name##n
-#define __CARYLL_VFUNC__1(name, n) __CARYLL_VFUNC__2(name, n)
-#define __CARYLLVFUNC(func, ...) __CARYLL_VFUNC__1(func, __NARG__(__VA_ARGS__))(__VA_ARGS__)
-
-#define caryll_trivialInit(T) \
- static __CARYLL_INLINE__ void T##_init(MODIFY T *x) { \
- memset(x, 0, sizeof(T)); \
- }
-#define caryll_nonTrivialInit(T, __fn_init) \
- static __CARYLL_INLINE__ void T##_init(MODIFY T *x) { \
- (__fn_init)(x); \
- }
-#define caryll_trivialEmpty(T) \
- static __CARYLL_INLINE__ T T##_empty() { \
- T x; \
- T##_init(&x); \
- return x; \
- }
-#define caryll_trivialCreate(T) \
- static __CARYLL_INLINE__ T *T##_create() { \
- T *x = (T *)malloc(sizeof(T)); \
- T##_init(x); \
- return x; \
- }
-#define caryll_trivialCopy(T) \
- static __CARYLL_INLINE__ void T##_copy(MODIFY T *dst, const T *src) { \
- memcpy(dst, src, sizeof(T)); \
- }
-#define caryll_nonTrivialCopy(T, __fn_copy) \
- static __CARYLL_INLINE__ void T##_copy(MODIFY T *dst, const T *src) { \
- (__fn_copy)(dst, src); \
- }
-#define caryll_trivialMove(T) \
- static __CARYLL_INLINE__ void T##_move(MODIFY T *dst, T *src) { \
- memcpy(dst, src, sizeof(T)); \
- T##_init(src); \
- }
-#define caryll_nonTrivialMove(T, __fn_move) \
- static __CARYLL_INLINE__ void T##_move(MODIFY T *dst, T *src) { \
- (__fn_move)(dst, src); \
- T##_init(src); \
- }
-#define caryll_trivialDispose(T) \
- static __CARYLL_INLINE__ void T##_dispose(MODIFY T *x) { \
- /* trivial */ \
- }
-#define caryll_nonTrivialDispose(T, __fn_dispose) \
- static __CARYLL_INLINE__ void T##_dispose(MODIFY T *x) { \
- (__fn_dispose)(x); \
- }
-#define caryll_trivialFree(T) \
- static __CARYLL_INLINE__ void T##_free(MOVE T *x) { \
- if (!x) return; \
- T##_dispose(x); \
- __caryll_free(x); \
- }
-#define caryll_trivialDup(T) \
- static __CARYLL_INLINE__ T T##_dup(const T src) { \
- T dst; \
- T##_copy(&dst, &src); \
- return dst; \
- }
-#define caryll_trivialReplace(T) \
- static __CARYLL_INLINE__ void T##_replace(MODIFY T *dst, MOVE const T src) { \
- T##_dispose(dst); \
- memcpy(dst, &src, sizeof(T)); \
- } \
- static __CARYLL_INLINE__ void T##_copyReplace(MODIFY T *dst, const T src) { \
- T##_dispose(dst); \
- T##_copy(dst, &src); \
- }
-
-#define caryll_standardTypeFn1(T) \
- caryll_trivialInit(T); \
- caryll_trivialCopy(T); \
- caryll_trivialDispose(T); \
- caryll_trivialMove(T); \
- caryll_trivialReplace(T);
-#define caryll_standardTypeFn2(T, __fn_dispose) \
- caryll_trivialInit(T); \
- caryll_trivialCopy(T); \
- caryll_nonTrivialDispose(T, __fn_dispose); \
- caryll_trivialMove(T); \
- caryll_trivialReplace(T);
-#define caryll_standardTypeFn3(T, __fn_init, __fn_dispose) \
- caryll_nonTrivialInit(T, __fn_init); \
- caryll_trivialCopy(T); \
- caryll_nonTrivialDispose(T, __fn_dispose); \
- caryll_trivialMove(T); \
- caryll_trivialReplace(T);
-#define caryll_standardTypeFn4(T, __fn_init, __fn_copy, __fn_dispose) \
- caryll_nonTrivialInit(T, __fn_init); \
- caryll_nonTrivialCopy(T, __fn_copy); \
- caryll_nonTrivialDispose(T, __fn_dispose); \
- caryll_trivialMove(T); \
- caryll_trivialReplace(T);
-#define caryll_standardTypeFn5(T, __fn_init, __fn_copy, __fn_dispose, __fn_move) \
- caryll_nonTrivialInit(T, __fn_init); \
- caryll_nonTrivialCopy(T, __fn_copy); \
- caryll_nonTrivialDispose(T, __fn_dispose); \
- caryll_nonTrivialMove(T, __fn_move); \
- caryll_trivialReplace(T);
-
-#define caryll_standardTypeMethods(T) \
- .init = T##_init, .copy = T##_copy, .dispose = T##_dispose, .move = T##_move, \
- .replace = T##_replace, .copyReplace = T##_copyReplace
-#define caryll_standardRefTypeMethods(T) \
- caryll_standardTypeMethods(T), .create = T##_create, .free = T##_free
-#define caryll_standardValTypeMethods(T) \
- caryll_standardTypeMethods(T), .empty = T##_empty, .dup = T##_dup
-
-#define caryll_standardTypeFn(...) __CARYLLVFUNC(caryll_standardTypeFn, __VA_ARGS__)
-
-#ifdef __GNUC__
-
-// GCC requires adding ## before __VA_ARGS__.
-// Make it happy.
-
-#define caryll_standardRefTypeFn(T, ...) \
- caryll_standardTypeFn(T, ##__VA_ARGS__); \
- caryll_trivialCreate(T); \
- caryll_trivialFree(T);
-#define caryll_standardValTypeFn(T, ...) \
- caryll_standardTypeFn(T, ##__VA_ARGS__); \
- caryll_trivialEmpty(T); \
- caryll_trivialDup(T);
-
-#define caryll_standardType(T, __name, ...) \
- caryll_standardTypeFn(T, ##__VA_ARGS__); \
- caryll_ElementInterfaceOf(T) __name = {caryll_standardTypeMethods(T)};
-#define caryll_standardRefType(T, __name, ...) \
- caryll_standardRefTypeFn(T, ##__VA_ARGS__); \
- caryll_ElementInterfaceOf(T) __name = {caryll_standardRefTypeMethods(T)};
-#define caryll_standardValType(T, __name, ...) \
- caryll_standardValTypeFn(T, ##__VA_ARGS__); \
- caryll_ElementInterfaceOf(T) __name = {caryll_standardValTypeMethods(T)};
-
-#else
-
-#define caryll_standardRefTypeFn(T, ...) \
- caryll_standardTypeFn(T, __VA_ARGS__); \
- caryll_trivialCreate(T); \
- caryll_trivialFree(T);
-#define caryll_standardValTypeFn(T, ...) \
- caryll_standardTypeFn(T, __VA_ARGS__); \
- caryll_trivialEmpty(T); \
- caryll_trivialDup(T);
-
-#define caryll_standardType(T, __name, ...) \
- caryll_standardTypeFn(T, __VA_ARGS__); \
- caryll_ElementInterfaceOf(T) __name = {caryll_standardTypeMethods(T)};
-#define caryll_standardRefType(T, __name, ...) \
- caryll_standardRefTypeFn(T, __VA_ARGS__); \
- caryll_ElementInterfaceOf(T) __name = {caryll_standardRefTypeMethods(T)};
-#define caryll_standardValType(T, __name, ...) \
- caryll_standardValTypeFn(T, __VA_ARGS__); \
- caryll_ElementInterfaceOf(T) __name = {caryll_standardValTypeMethods(T)};
-
-#endif
-
-//// Traits
-
-// Show
-#define caryll_ShowFns(T, _fn_Show) \
- static __CARYLL_INLINE__ void T##_show(const T a) { \
- return (_fn_Show)(a); \
- }
-#define caryll_ShowAssigns(T) .show = T##_show
-
-// Ord
-#define caryll_OrdFns(T, _fnCompare) \
- static __CARYLL_INLINE__ int T##_compare(const T a, const T b) { \
- return (_fnCompare)(a, b); \
- } \
- static __CARYLL_INLINE__ int T##_compareRef(const T *a, const T *b) { \
- return (_fnCompare)(*a, *b); \
- }
-#define caryll_OrdEqFns(T, _fnCompare) \
- caryll_OrdFns(T, _fnCompare); \
- static __CARYLL_INLINE__ bool T##_equal(const T a, const T b) { \
- return !(_fnCompare)(a, b); \
- }
-#define caryll_OrdEqAssigns(T) \
- .compare = T##_compare, .compareRef = T##_compareRef, .equal = T##_equal
-
-// Monoid
-#define caryll_MonoidFns(T, _fn_neutral, _fn_inplacePlus) \
- static __CARYLL_INLINE__ T T##_neutral() { \
- return (_fn_neutral)(); \
- } \
- static __CARYLL_INLINE__ void T##_inplacePlus(MODIFY T *a, const T b) { \
- (_fn_inplacePlus)(a, b); \
- } \
- static __CARYLL_INLINE__ T T##_plus(const T a, const T b) { \
- T result = (_fn_neutral)(); \
- (_fn_inplacePlus)(&result, a); \
- (_fn_inplacePlus)(&result, b); \
- return result; \
- }
-#define caryll_MonoidAssigns(T) \
- .neutral = T##_neutral, .inplacePlus = T##_inplacePlus, .plus = T##_plus
-
-// Group
-#define caryll_GroupFns(T, _fn_inplaceNegate) \
- static __CARYLL_INLINE__ void T##_inplaceNegate(MODIFY T *a) { \
- (_fn_inplaceNegate)(a); \
- } \
- static __CARYLL_INLINE__ T T##_negate(const T a) { \
- T result; \
- T##_copy(&result, &a); \
- T##_inplaceNegate(&result); \
- return result; \
- } \
- static __CARYLL_INLINE__ void T##_inplaceMinus(MODIFY T *a, const T b) { \
- T tb = T##_negate(b); \
- (T##_inplacePlus)(a, tb); \
- T##_dispose(&tb); \
- } \
- static __CARYLL_INLINE__ T T##_minus(const T a, const T b) { \
- T result = (T##_neutral)(); \
- (T##_inplacePlus)(&result, a); \
- (T##_inplaceMinus)(&result, b); \
- return result; \
- }
-#define caryll_GroupAssigns(T) \
- .inplaceNegate = T##_inplaceNegate, .negate = T##_negate, .inplaceMinus = T##_inplaceMinus, \
- .minus = T##_minus
-
-// Module
-#define caryll_ModuleFns(T, TS, _fn_inplaceScale) \
- static __CARYLL_INLINE__ void T##_inplaceScale(MODIFY T *a, TS b) { \
- (_fn_inplaceScale)(a, b); \
- } \
- static __CARYLL_INLINE__ T T##_scale(const T a, TS b) { \
- T result; \
- T##_copy(&result, &a); \
- T##_inplaceScale(&result, b); \
- return result; \
- } \
- static __CARYLL_INLINE__ void T##_inplacePlusScale(MODIFY T *a, TS b, const T c) { \
- T x = T##_scale(c, b); \
- T##_inplacePlus(a, x); \
- T##_dispose(&x); \
- }
-#define caryll_ModuleAssigns(T) \
- .inplaceScale = T##_inplaceScale, .scale = T##_scale, .inplacePlusScale = T##_inplacePlusScale
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/glyph-order.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/glyph-order.c
deleted file mode 100644
index 3a30c702806..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/glyph-order.c
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "util.h"
-#include "otfcc/glyph-order.h"
-
-static INLINE void initGlyphOrder(otfcc_GlyphOrder *go) {
- go->byGID = NULL;
- go->byName = NULL;
-}
-static INLINE void disposeGlyphOrder(otfcc_GlyphOrder *go) {
- otfcc_GlyphOrderEntry *current, *temp;
- HASH_ITER(hhID, go->byGID, current, temp) {
- if (current->name) sdsfree(current->name);
- HASH_DELETE(hhID, go->byGID, current);
- HASH_DELETE(hhName, go->byName, current);
- FREE(current);
- }
-}
-caryll_standardRefTypeFn(otfcc_GlyphOrder, initGlyphOrder, disposeGlyphOrder);
-
-// Register a gid->name map
-static sds otfcc_setGlyphOrderByGID(otfcc_GlyphOrder *go, glyphid_t gid, sds name) {
- otfcc_GlyphOrderEntry *s = NULL;
- HASH_FIND(hhID, go->byGID, &gid, sizeof(glyphid_t), s);
- if (s) {
- // gid is already in the order table.
- // reject this naming suggestion.
- sdsfree(name);
- return s->name;
- } else {
- otfcc_GlyphOrderEntry *t = NULL;
- HASH_FIND(hhName, go->byName, name, sdslen(name), t);
- if (t) {
- // The name is already in-use.
- sdsfree(name);
- name = sdscatprintf(sdsempty(), "$$gid%d", gid);
- }
- NEW(s);
- s->gid = gid;
- s->name = name;
- HASH_ADD(hhID, go->byGID, gid, sizeof(glyphid_t), s);
- HASH_ADD(hhName, go->byName, name[0], sdslen(s->name), s);
- }
- return name;
-}
-
-// Register a name->gid map
-static bool otfcc_setGlyphOrderByName(otfcc_GlyphOrder *go, sds name, glyphid_t gid) {
- otfcc_GlyphOrderEntry *s = NULL;
- HASH_FIND(hhName, go->byName, name, sdslen(name), s);
- if (s) {
- // name is already mapped to a glyph
- // reject this naming suggestion
- return false;
- } else {
- NEW(s);
- s->gid = gid;
- s->name = name;
- HASH_ADD(hhID, go->byGID, gid, sizeof(glyphid_t), s);
- HASH_ADD(hhName, go->byName, name[0], sdslen(s->name), s);
- return true;
- }
-}
-
-static bool otfcc_gordNameAFieldShared(otfcc_GlyphOrder *go, glyphid_t gid, sds *field) {
- otfcc_GlyphOrderEntry *t;
- HASH_FIND(hhID, go->byGID, &gid, sizeof(glyphid_t), t);
- if (t != NULL) {
- *field = t->name;
- return true;
- } else {
- *field = NULL;
- return false;
- }
-}
-
-static bool otfcc_gordConsolidateHandle(otfcc_GlyphOrder *go, glyph_handle *h) {
- if (h->state == HANDLE_STATE_CONSOLIDATED) {
- otfcc_GlyphOrderEntry *t;
- HASH_FIND(hhName, go->byName, h->name, sdslen(h->name), t);
- if (t) {
- Handle.consolidateTo(h, t->gid, t->name);
- return true;
- }
- HASH_FIND(hhName, go->byGID, &(h->index), sizeof(glyphid_t), t);
- if (t) {
- Handle.consolidateTo(h, t->gid, t->name);
- return true;
- }
- } else if (h->state == HANDLE_STATE_NAME) {
- otfcc_GlyphOrderEntry *t;
- HASH_FIND(hhName, go->byName, h->name, sdslen(h->name), t);
- if (t) {
- Handle.consolidateTo(h, t->gid, t->name);
- return true;
- }
- } else if (h->state == HANDLE_STATE_INDEX) {
- sds name = NULL;
- otfcc_gordNameAFieldShared(go, h->index, &name);
- if (name) {
- Handle.consolidateTo(h, h->index, name);
- return true;
- }
- }
- return false;
-}
-
-static bool gordLookupName(otfcc_GlyphOrder *go, sds name) {
- otfcc_GlyphOrderEntry *t;
- HASH_FIND(hhName, go->byName, name, sdslen(name), t);
- if (t) return true;
- return false;
-}
-
-const struct otfcc_GlyphOrderPackage otfcc_pkgGlyphOrder = {
- caryll_standardRefTypeMethods(otfcc_GlyphOrder), .setByGID = otfcc_setGlyphOrderByGID,
- .setByName = otfcc_setGlyphOrderByName, .nameAField_Shared = otfcc_gordNameAFieldShared,
- .consolidateHandle = otfcc_gordConsolidateHandle, .lookupName = gordLookupName,
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/handle.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/handle.c
deleted file mode 100644
index a6657ee4371..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/handle.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "otfcc/handle.h"
-#include "element-impl.h"
-#include "support/otfcc-alloc.h"
-
-// default constructors
-static INLINE void initHandle(otfcc_Handle *h) {
- h->state = HANDLE_STATE_EMPTY;
- h->index = 0;
- h->name = NULL;
-}
-static INLINE void disposeHandle(struct otfcc_Handle *h) {
- if (h->name) {
- sdsfree(h->name);
- h->name = NULL;
- }
- h->index = 0;
- h->state = HANDLE_STATE_EMPTY;
-}
-static void copyHandle(otfcc_Handle *dst, const otfcc_Handle *src) {
- dst->state = src->state;
- dst->index = src->index;
- if (src->name) {
- dst->name = sdsdup(src->name);
- } else {
- dst->name = NULL;
- }
-}
-
-caryll_standardValTypeFn(otfcc_Handle, initHandle, copyHandle, disposeHandle);
-
-// custom constructors
-static struct otfcc_Handle handle_fromIndex(glyphid_t id) {
- struct otfcc_Handle h = {HANDLE_STATE_INDEX, id, NULL};
- return h;
-}
-static struct otfcc_Handle handle_fromName(MOVE sds s) {
- struct otfcc_Handle h = {HANDLE_STATE_EMPTY, 0, NULL};
- if (s) {
- h.state = HANDLE_STATE_NAME;
- h.name = s;
- }
- return h;
-}
-static struct otfcc_Handle handle_fromConsolidated(glyphid_t id, sds s) {
- struct otfcc_Handle h = {HANDLE_STATE_CONSOLIDATED, id, sdsdup(s)};
- return h;
-}
-
-// consolidation
-static void handle_consolidateTo(struct otfcc_Handle *h, glyphid_t id, sds name) {
- otfcc_iHandle.dispose(h);
- h->state = HANDLE_STATE_CONSOLIDATED;
- h->index = id;
- h->name = sdsdup(name);
-}
-
-const struct otfcc_HandlePackage otfcc_iHandle = {
- caryll_standardValTypeMethods(otfcc_Handle), // VT
- .fromIndex = handle_fromIndex, // custom constructor, from index
- .fromName = handle_fromName, // custom constructor, from name
- .fromConsolidated = handle_fromConsolidated, // custom constructor, from consolidated
- .consolidateTo = handle_consolidateTo,
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-funcs.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-funcs.h
deleted file mode 100644
index 55e2d98ecd1..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-funcs.h
+++ /dev/null
@@ -1,203 +0,0 @@
-#ifndef CARYLL_SUPPORT_JSON_FUNCS_H
-#define CARYLL_SUPPORT_JSON_FUNCS_H
-
-#include <stdint.h>
-#include <math.h>
-
-#include "dep/json-builder.h"
-#include "dep/json.h"
-#include "dep/sds.h"
-
-#include "caryll/ownership.h"
-#include "otfcc/primitives.h"
-#include "otfcc/vf/vq.h"
-#include "otfcc/table/fvar.h"
-
-#ifndef INLINE
-#ifdef _MSC_VER
-#define INLINE __forceinline /* use __forceinline (VC++ specific) */
-#else
-#define INLINE inline /* use standard inline */
-#endif
-#endif
-
-static INLINE json_value *preserialize(MOVE json_value *x);
-
-static INLINE json_value *json_obj_get(const json_value *obj, const char *key) {
- if (!obj || obj->type != json_object) return NULL;
- for (uint32_t _k = 0; _k < obj->u.object.length; _k++) {
- char *ck = obj->u.object.values[_k].name;
- if (strcmp(ck, key) == 0) return obj->u.object.values[_k].value;
- }
- return NULL;
-}
-static INLINE json_value *json_obj_get_type(const json_value *obj, const char *key,
- const json_type type) {
- json_value *v = json_obj_get(obj, key);
- if (v && v->type == type) return v;
- return NULL;
-}
-static INLINE sds json_obj_getsds(const json_value *obj, const char *key) {
- json_value *v = json_obj_get_type(obj, key, json_string);
- if (!v)
- return NULL;
- else
- return sdsnewlen(v->u.string.ptr, v->u.string.length);
-}
-static INLINE char *json_obj_getstr_share(const json_value *obj, const char *key) {
- json_value *v = json_obj_get_type(obj, key, json_string);
- if (!v)
- return NULL;
- else
- return v->u.string.ptr;
-}
-
-static INLINE json_value *json_object_push_tag(json_value *a, uint32_t tag, json_value *b) {
- char tags[4] = {(tag & 0xff000000) >> 24, (tag & 0xff0000) >> 16, (tag & 0xff00) >> 8,
- (tag & 0xff)};
- return json_object_push_length(a, 4, tags, b);
-}
-
-// Coordinates, VV and VQ
-static INLINE double json_numof(const json_value *cv) {
- if (cv && cv->type == json_integer) return cv->u.integer;
- if (cv && cv->type == json_double) return cv->u.dbl;
- return 0;
-}
-static INLINE json_value *json_new_position(pos_t z) {
- if (round(z) == z) {
- return json_integer_new(z);
- } else {
- return json_double_new(z);
- }
-}
-json_value *json_new_VQRegion_Explicit(const vq_Region *rs, const table_fvar *fvar);
-json_value *json_new_VQRegion(const vq_Region *rs, const table_fvar *fvar);
-json_value *json_new_VQ(const VQ z, const table_fvar *fvar);
-json_value *json_new_VV(const VV x, const table_fvar *fvar);
-json_value *json_new_VVp(const VV *x, const table_fvar *fvar);
-VQ json_vqOf(const json_value *cv, const table_fvar *fvar);
-
-static INLINE double json_obj_getnum(const json_value *obj, const char *key) {
- if (!obj || obj->type != json_object) return 0.0;
- for (uint32_t _k = 0; _k < obj->u.object.length; _k++) {
- char *ck = obj->u.object.values[_k].name;
- json_value *cv = obj->u.object.values[_k].value;
- if (strcmp(ck, key) == 0) {
- if (cv && cv->type == json_integer) return cv->u.integer;
- if (cv && cv->type == json_double) return cv->u.dbl;
- }
- }
- return 0.0;
-}
-static INLINE int32_t json_obj_getint(const json_value *obj, const char *key) {
- if (!obj || obj->type != json_object) return 0;
- for (uint32_t _k = 0; _k < obj->u.object.length; _k++) {
- char *ck = obj->u.object.values[_k].name;
- json_value *cv = obj->u.object.values[_k].value;
- if (strcmp(ck, key) == 0) {
- if (cv && cv->type == json_integer) return (int32_t)cv->u.integer;
- if (cv && cv->type == json_double) return cv->u.dbl;
- }
- }
- return 0;
-}
-static INLINE double json_obj_getnum_fallback(const json_value *obj, const char *key,
- double fallback) {
- if (!obj || obj->type != json_object) return fallback;
- for (uint32_t _k = 0; _k < obj->u.object.length; _k++) {
- char *ck = obj->u.object.values[_k].name;
- json_value *cv = obj->u.object.values[_k].value;
- if (strcmp(ck, key) == 0) {
- if (cv && cv->type == json_integer) return cv->u.integer;
- if (cv && cv->type == json_double) return cv->u.dbl;
- }
- }
- return fallback;
-}
-static INLINE int32_t json_obj_getint_fallback(const json_value *obj, const char *key,
- int32_t fallback) {
- if (!obj || obj->type != json_object) return fallback;
- for (uint32_t _k = 0; _k < obj->u.object.length; _k++) {
- char *ck = obj->u.object.values[_k].name;
- json_value *cv = obj->u.object.values[_k].value;
- if (strcmp(ck, key) == 0) {
- if (cv && cv->type == json_integer) return (int32_t)cv->u.integer;
- if (cv && cv->type == json_double) return cv->u.dbl;
- }
- }
- return fallback;
-}
-static INLINE bool json_boolof(const json_value *cv) {
- if (cv && cv->type == json_boolean) return cv->u.boolean;
- return false;
-}
-static INLINE bool json_obj_getbool(const json_value *obj, const char *key) {
- if (!obj || obj->type != json_object) return false;
- for (uint32_t _k = 0; _k < obj->u.object.length; _k++) {
- char *ck = obj->u.object.values[_k].name;
- json_value *cv = obj->u.object.values[_k].value;
- if (strcmp(ck, key) == 0) {
- if (cv && cv->type == json_boolean) return cv->u.boolean;
- }
- }
- return false;
-}
-static INLINE bool json_obj_getbool_fallback(const json_value *obj, const char *key,
- bool fallback) {
- if (!obj || obj->type != json_object) return fallback;
- for (uint32_t _k = 0; _k < obj->u.object.length; _k++) {
- char *ck = obj->u.object.values[_k].name;
- json_value *cv = obj->u.object.values[_k].value;
- if (strcmp(ck, key) == 0) {
- if (cv && cv->type == json_boolean) return cv->u.boolean;
- }
- }
- return fallback;
-}
-
-static INLINE json_value *json_from_sds(const sds str) {
- return json_string_new_length((uint32_t)sdslen(str), str);
-}
-
-// flags reader and writer
-static INLINE json_value *otfcc_dump_flags(int flags, const char *labels[]) {
- json_value *v = json_object_new(0);
- for (uint16_t j = 0; labels[j]; j++)
- if (flags & (1 << j)) { json_object_push(v, labels[j], json_boolean_new(true)); }
- return v;
-}
-static INLINE uint32_t otfcc_parse_flags(const json_value *v, const char *labels[]) {
- if (!v) return 0;
- if (v->type == json_integer) {
- return (uint32_t)v->u.integer;
- } else if (v->type == json_double) {
- return (uint32_t)v->u.dbl;
- } else if (v->type == json_object) {
- uint32_t flags = 0;
- for (uint16_t j = 0; labels[j]; j++) {
- if (json_obj_getbool(v, labels[j])) { flags |= (1 << j); }
- }
- return flags;
- } else {
- return 0;
- }
-}
-
-static INLINE json_value *preserialize(MOVE json_value *x) {
-#ifdef CARYLL_USE_PRE_SERIALIZED
- json_serialize_opts opts = {.mode = json_serialize_mode_packed};
- size_t preserialize_len = json_measure_ex(x, opts);
- char *buf = (char *)malloc(preserialize_len);
- json_serialize_ex(buf, x, opts);
- json_builder_free(x);
-
- json_value *xx = json_string_new_nocopy((uint32_t)(preserialize_len - 1), buf);
- xx->type = json_pre_serialized;
- return xx;
-#else
- return x;
-#endif
-}
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.c
deleted file mode 100644
index 442bd7eeb6c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "json-ident.h"
-#include "support/otfcc-alloc.h"
-
-#ifdef _MSC_VER
-#include "winfns.h"
-#endif
-
-static bool compare_json_arrays(const json_value *a, const json_value *b) {
- for (uint16_t j = 0; j < a->u.array.length; j++) {
- if (!json_ident(a->u.array.values[j], b->u.array.values[j])) { return false; }
- }
- return true;
-}
-
-typedef struct {
- char *key;
- json_value *val;
- bool check;
- UT_hash_handle hh;
-} json_obj_entry;
-static bool compare_json_objects(const json_value *a, const json_value *b) {
- json_obj_entry *h = NULL;
- for (uint32_t j = 0; j < a->u.object.length; j++) {
- char *k = a->u.object.values[j].name;
- json_obj_entry *e = NULL;
- HASH_FIND_STR(h, k, e);
- if (!e) {
- NEW(e);
- e->key = xstrdup(k);
- e->val = a->u.object.values[j].value;
- e->check = false;
- HASH_ADD_STR(h, key, e);
- }
- }
- bool allcheck = true;
- for (uint32_t j = 0; j < b->u.object.length; j++) {
- char *k = b->u.object.values[j].name;
- json_obj_entry *e = NULL;
- HASH_FIND_STR(h, k, e);
- if (!e) {
- allcheck = false;
- break;
- } else {
- bool check = json_ident(e->val, b->u.object.values[j].value);
- if (!check) {
- allcheck = false;
- break;
- } else {
- e->check = true;
- }
- }
- }
- json_obj_entry *e, *tmp;
- HASH_ITER(hh, h, e, tmp) {
- allcheck = allcheck && e->check;
- HASH_DEL(h, e);
- FREE(e->key);
- FREE(e);
- }
- return allcheck;
-}
-
-bool json_ident(const json_value *a, const json_value *b) {
- if (!a && !b) return true;
- if (!a || !b) return false;
- if (a->type != b->type) return false;
- switch (a->type) {
- case json_none:
- case json_null:
- return true;
- case json_integer:
- return a->u.integer == b->u.integer;
- case json_double:
- return a->u.dbl == b->u.dbl;
- case json_boolean:
- return a->u.boolean == b->u.boolean;
- case json_string:
- return a->u.string.length == b->u.string.length && strcmp(a->u.string.ptr, b->u.string.ptr) == 0;
- case json_array:
- return a->u.array.length == b->u.array.length && compare_json_arrays(a, b);
- case json_object:
- return a->u.object.length == b->u.object.length && compare_json_objects(a, b);
- default:
- return false;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.h
deleted file mode 100644
index ec778d1f48f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_SUPPORT_JSON_IDENT_H
-#define CARYLL_SUPPORT_JSON_IDENT_H
-
-#include "dep/json.h"
-#include "dep/uthash.h"
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-bool json_ident(const json_value *a, const json_value *b);
-
-extern char *xstrdup(const char *);
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/options.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/options.c
deleted file mode 100644
index d32e7c082b3..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/options.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "otfcc/options.h"
-#include "support/otfcc-alloc.h"
-
-otfcc_Options *otfcc_newOptions() {
- otfcc_Options *options;
- NEW(options);
- return options;
-}
-void otfcc_deleteOptions(otfcc_Options *options) {
- if (options) {
- FREE(options->glyph_name_prefix);
- if (options->logger) options->logger->dispose(options->logger);
- }
- FREE(options);
-}
-void otfcc_Options_optimizeTo(otfcc_Options *options, uint8_t level) {
- options->cff_rollCharString = false;
- options->short_post = false;
- options->ignore_glyph_order = false;
- options->cff_short_vmtx = false;
- options->merge_features = false;
- options->force_cid = false;
- options->cff_doSubroutinize = false;
-
- if (level >= 1) {
- options->cff_rollCharString = true;
- options->cff_short_vmtx = true;
- }
- if (level >= 2) {
- options->short_post = true;
- options->cff_doSubroutinize = true;
- options->merge_features = true;
- }
- if (level >= 3) {
- options->ignore_glyph_order = true;
- options->force_cid = true;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/otfcc-alloc.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/otfcc-alloc.h
deleted file mode 100644
index 51b57442f5f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/otfcc-alloc.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef CARYLL_SUPPORT_OTFCC_ALLOC_H
-#define CARYLL_SUPPORT_OTFCC_ALLOC_H
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef INLINE
-#ifdef _MSC_VER
-#define INLINE __forceinline /* use __forceinline (VC++ specific) */
-#else
-#define INLINE inline /* use standard inline */
-#endif
-#endif
-
-// Allocators
-// Change this if you prefer other allocators
-#define __caryll_malloc malloc
-#define __caryll_calloc calloc
-#define __caryll_realloc realloc
-#define __caryll_free free
-
-static INLINE void *__caryll_allocate_dirty(size_t n, unsigned long line) {
- if (!n) return NULL;
- void *p = __caryll_malloc(n);
- if (!p) {
- fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
- exit(EXIT_FAILURE);
- }
- return p;
-}
-static INLINE void *__caryll_allocate_clean(size_t n, unsigned long line) {
- if (!n) return NULL;
- void *p = __caryll_calloc(n, 1);
- if (!p) {
- fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
- exit(EXIT_FAILURE);
- }
- return p;
-}
-static INLINE void *__caryll_reallocate(void *ptr, size_t n, unsigned long line) {
- if (!n) {
- __caryll_free(ptr);
- return NULL;
- }
- if (!ptr) {
- return __caryll_allocate_clean(n, line);
- } else {
- void *p = __caryll_realloc(ptr, n);
- if (!p) {
- fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
- exit(EXIT_FAILURE);
- }
- return p;
- }
-}
-#ifdef __cplusplus
-#define NEW_CLEAN_S(ptr, size) ptr = __caryll_allocate_clean((size), __LINE__)
-#define NEW_CLEAN_1(ptr) \
- ptr = (decltype(ptr))__caryll_allocate_clean(sizeof(decltype(*ptr)), __LINE__)
-#define NEW_CLEAN_N(ptr, n) \
- ptr = (decltype(ptr))__caryll_allocate_clean(sizeof(decltype(*ptr)) * (n), __LINE__)
-#define NEW_DIRTY(ptr) \
- ptr = (decltype(ptr))__caryll_allocate_dirty(sizeof(decltype(*ptr)), __LINE__)
-#define NEW_DIRTY_N(ptr, n) \
- ptr = (decltype(ptr))__caryll_allocate_dirty(sizeof(decltype(*ptr)) * (n), __LINE__)
-#define FREE(ptr) (__caryll_free(ptr), ptr = nullptr)
-#define DELETE(fn, ptr) (fn(ptr), ptr = nullptr)
-#define RESIZE(ptr, n) ptr = (decltype(ptr))__caryll_reallocate(ptr, sizeof(*ptr) * (n), __LINE__)
-#else
-#define NEW_CLEAN_S(ptr, size) ptr = __caryll_allocate_clean((size), __LINE__)
-#define NEW_CLEAN_1(ptr) ptr = __caryll_allocate_clean(sizeof(*ptr), __LINE__)
-#define NEW_CLEAN_N(ptr, n) ptr = __caryll_allocate_clean(sizeof(*ptr) * (n), __LINE__)
-#define NEW_DIRTY(ptr) ptr = __caryll_allocate_dirty(sizeof(*ptr), __LINE__)
-#define NEW_DIRTY_N(ptr, n) ptr = __caryll_allocate_dirty(sizeof(*ptr) * (n), __LINE__)
-#define FREE(ptr) (__caryll_free(ptr), ptr = NULL)
-#define DELETE(fn, ptr) (fn(ptr), ptr = NULL)
-#define RESIZE(ptr, n) ptr = __caryll_reallocate(ptr, sizeof(*ptr) * (n), __LINE__)
-#endif
-
-#define __GET_MACRO_OTFCC_ALLOC_2(_1, _2, NAME, ...) NAME
-#define NEW(...) __GET_MACRO_OTFCC_ALLOC_2(__VA_ARGS__, NEW_CLEAN_N, NEW_CLEAN_1)(__VA_ARGS__)
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/primitives.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/primitives.c
deleted file mode 100644
index 2f2ad360979..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/primitives.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "otfcc/primitives.h"
-#include "bin-io.h"
-#include <math.h>
-
-// f2dot14 type
-double otfcc_from_f2dot14(const f2dot14 x) {
- return x / 16384.0;
-}
-int16_t otfcc_to_f2dot14(const double x) {
- return round(x * 16384.0);
-}
-
-// F16.16 (fixed) type
-double otfcc_from_fixed(const f16dot16 x) {
- return x / 65536.0;
-}
-f16dot16 otfcc_to_fixed(const double x) {
- return round(x * 65536.0);
-}
-
-// F16.16 arith
-// Clamp: remove too-large values
-static INLINE f16dot16 clamp(int64_t value) {
- int64_t tmp = value;
- if (tmp < (int64_t)f16dot16_negativeIntinity) tmp = (int64_t)f16dot16_negativeIntinity;
- if (tmp > (int64_t)f16dot16_infinity) tmp = (int64_t)f16dot16_infinity;
- return (f16dot16)tmp;
-}
-
-f16dot16 otfcc_f1616_add(f16dot16 a, f16dot16 b) {
- return a + b;
-}
-f16dot16 otfcc_f1616_minus(f16dot16 a, f16dot16 b) {
- return a - b;
-}
-
-f16dot16 otfcc_f1616_multiply(f16dot16 a, f16dot16 b) {
- int64_t tmp = (int64_t)a * (int64_t)b + f16dot16_k;
- f16dot16 product = clamp(tmp >> f16dot16_precision);
- return product;
-}
-
-static INLINE f16dot16 divide(int64_t a, int32_t b) {
- if (b == 0) {
- if (a < 0)
- return f16dot16_negativeIntinity;
- else
- return f16dot16_infinity;
- }
-
- if ((a < 0 != b < 0)) {
- a -= b / 2;
- } else {
- a += b / 2;
- }
-
- return (f16dot16)(clamp(a / b));
-}
-
-f16dot16 otfcc_f1616_muldiv(f16dot16 a, f16dot16 b, f16dot16 c) {
- int64_t tmp = (int64_t)a * (int64_t)b + f16dot16_k;
- return divide(tmp, c);
-}
-f16dot16 otfcc_f1616_divide(f16dot16 a, f16dot16 b) {
- return divide((int64_t)a << f16dot16_precision, b);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.c
deleted file mode 100644
index 9efa794e73a..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*********************************************************************
-* Filename: sha1.c
-* Author: Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details: Implementation of the SHA1 hashing algorithm.
- Algorithm specification can be found here:
- * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
- This implementation uses little endian byte order.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <memory.h>
-#include "sha1.h"
-
-/****************************** MACROS ******************************/
-#define ROTLEFT(a, b) ((a << b) | (a >> (32 - b)))
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-static void sha1_transform(SHA1_CTX *ctx, const BYTE data[]) {
- WORD a, b, c, d, e, i, j, t, m[80];
-
- for (i = 0, j = 0; i < 16; ++i, j += 4)
- m[i] = (data[j] << 24) + (data[j + 1] << 16) + (data[j + 2] << 8) + (data[j + 3]);
- for (; i < 80; ++i) {
- m[i] = (m[i - 3] ^ m[i - 8] ^ m[i - 14] ^ m[i - 16]);
- m[i] = (m[i] << 1) | (m[i] >> 31);
- }
-
- a = ctx->state[0];
- b = ctx->state[1];
- c = ctx->state[2];
- d = ctx->state[3];
- e = ctx->state[4];
-
- for (i = 0; i < 20; ++i) {
- t = ROTLEFT(a, 5) + ((b & c) ^ (~b & d)) + e + ctx->k[0] + m[i];
- e = d;
- d = c;
- c = ROTLEFT(b, 30);
- b = a;
- a = t;
- }
- for (; i < 40; ++i) {
- t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[1] + m[i];
- e = d;
- d = c;
- c = ROTLEFT(b, 30);
- b = a;
- a = t;
- }
- for (; i < 60; ++i) {
- t = ROTLEFT(a, 5) + ((b & c) ^ (b & d) ^ (c & d)) + e + ctx->k[2] + m[i];
- e = d;
- d = c;
- c = ROTLEFT(b, 30);
- b = a;
- a = t;
- }
- for (; i < 80; ++i) {
- t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[3] + m[i];
- e = d;
- d = c;
- c = ROTLEFT(b, 30);
- b = a;
- a = t;
- }
-
- ctx->state[0] += a;
- ctx->state[1] += b;
- ctx->state[2] += c;
- ctx->state[3] += d;
- ctx->state[4] += e;
-}
-
-void sha1_init(SHA1_CTX *ctx) {
- ctx->datalen = 0;
- ctx->bitlen = 0;
- ctx->state[0] = 0x67452301;
- ctx->state[1] = 0xEFCDAB89;
- ctx->state[2] = 0x98BADCFE;
- ctx->state[3] = 0x10325476;
- ctx->state[4] = 0xc3d2e1f0;
- ctx->k[0] = 0x5a827999;
- ctx->k[1] = 0x6ed9eba1;
- ctx->k[2] = 0x8f1bbcdc;
- ctx->k[3] = 0xca62c1d6;
-}
-
-void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len) {
- size_t i;
-
- for (i = 0; i < len; ++i) {
- ctx->data[ctx->datalen] = data[i];
- ctx->datalen++;
- if (ctx->datalen == 64) {
- sha1_transform(ctx, ctx->data);
- ctx->bitlen += 512;
- ctx->datalen = 0;
- }
- }
-}
-
-void sha1_final(SHA1_CTX *ctx, BYTE hash[]) {
- WORD i;
-
- i = ctx->datalen;
-
- // Pad whatever data is left in the buffer.
- if (ctx->datalen < 56) {
- ctx->data[i++] = 0x80;
- while (i < 56)
- ctx->data[i++] = 0x00;
- } else {
- ctx->data[i++] = 0x80;
- while (i < 64)
- ctx->data[i++] = 0x00;
- sha1_transform(ctx, ctx->data);
- memset(ctx->data, 0, 56);
- }
-
- // Append to the padding the total message's length in bits and transform.
- ctx->bitlen += ctx->datalen * 8;
- ctx->data[63] = ctx->bitlen;
- ctx->data[62] = ctx->bitlen >> 8;
- ctx->data[61] = ctx->bitlen >> 16;
- ctx->data[60] = ctx->bitlen >> 24;
- ctx->data[59] = ctx->bitlen >> 32;
- ctx->data[58] = ctx->bitlen >> 40;
- ctx->data[57] = ctx->bitlen >> 48;
- ctx->data[56] = ctx->bitlen >> 56;
- sha1_transform(ctx, ctx->data);
-
- // Since this implementation uses little endian byte ordering and MD uses big endian,
- // reverse all the bytes when copying the final state to the output hash.
- for (i = 0; i < 4; ++i) {
- hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
- hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
- hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
- hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
- hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.h
deleted file mode 100644
index 47db579d6d2..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*********************************************************************
-* Filename: sha1.h
-* Author: Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details: Defines the API for the corresponding SHA1 implementation.
-*********************************************************************/
-
-#ifndef SHA1_H
-#define SHA1_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/****************************** MACROS ******************************/
-#define SHA1_BLOCK_SIZE 20 // SHA1 outputs a 20 byte digest
-
-/**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE; // 8-bit byte
-typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
-
-typedef struct {
- BYTE data[64];
- WORD datalen;
- unsigned long long bitlen;
- WORD state[5];
- WORD k[4];
-} SHA1_CTX;
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void sha1_init(SHA1_CTX *ctx);
-void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len);
-void sha1_final(SHA1_CTX *ctx, BYTE hash[]);
-
-#endif // SHA1_H
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/tag.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/tag.h
deleted file mode 100644
index e2a339d3b61..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/tag.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef CARYLL_SUPPORT_TAG_H
-#define CARYLL_SUPPORT_TAG_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#ifndef INLINE
-#ifdef _MSC_VER
-#define INLINE __forceinline /* use __forceinline (VC++ specific) */
-#else
-#define INLINE inline /* use standard inline */
-#endif
-#endif
-
-// Tag handler
-static INLINE void tag2str(uint32_t tag, char tags[4]) {
- tags[0] = (tag >> 24) & 0xFF;
- tags[1] = (tag >> 16) & 0xFF;
- tags[2] = (tag >> 8) & 0xFF;
- tags[3] = tag & 0xFF;
-}
-
-static INLINE uint32_t str2tag(const char *tags) {
- if (!tags) return 0;
- uint32_t tag = 0;
- uint8_t len = 0;
- while (*tags && len < 4) {
- tag = (tag << 8) | (*tags), tags++, len++;
- }
- while (len < 4) {
- tag = (tag << 8) | ' ', len++;
- }
- return tag;
-}
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.c
deleted file mode 100644
index 3fc3e043b56..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.c
+++ /dev/null
@@ -1,701 +0,0 @@
-/* Copyright (C) 2001-2012 by George Williams */
-/* Copyright (C) 2016 by Belleve Invis */
-
-/*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ttinstr.h"
-#include <ctype.h>
-
-enum ttf_instructions {
- ttf_npushb = 0x40,
- ttf_npushw = 0x41,
- ttf_pushb = 0xb0,
- ttf_pushw = 0xb8,
- ttf_aa = 0x7f,
- ttf_abs = 0x64,
- ttf_add = 0x60,
- ttf_alignpts = 0x27,
- ttf_alignrp = 0x3c,
- ttf_and = 0x5a,
- ttf_call = 0x2b,
- ttf_ceiling = 0x67,
- ttf_cindex = 0x25,
- ttf_clear = 0x22,
- ttf_debug = 0x4f,
- ttf_deltac1 = 0x73,
- ttf_deltac2 = 0x74,
- ttf_deltac3 = 0x75,
- ttf_deltap1 = 0x5d,
- ttf_deltap2 = 0x71,
- ttf_deltap3 = 0x72,
- ttf_depth = 0x24,
- ttf_div = 0x62,
- ttf_dup = 0x20,
- ttf_eif = 0x59,
- ttf_else = 0x1b,
- ttf_endf = 0x2d,
- ttf_eq = 0x54,
- ttf_even = 0x57,
- ttf_fdef = 0x2c,
- ttf_flipoff = 0x4e,
- ttf_flipon = 0x4d,
- ttf_flippt = 0x80,
- ttf_fliprgoff = 0x82,
- ttf_fliprgon = 0x81,
- ttf_floor = 0x66,
- ttf_gc = 0x46,
- ttf_getinfo = 0x88,
- ttf_gfv = 0x0d,
- ttf_gpv = 0x0c,
- ttf_gt = 0x52,
- ttf_gteq = 0x53,
- ttf_idef = 0x89,
- ttf_if = 0x58,
- ttf_instctrl = 0x8e,
- ttf_ip = 0x39,
- ttf_isect = 0x0f,
- ttf_iup = 0x30,
- ttf_jmpr = 0x1c,
- ttf_jrof = 0x79,
- ttf_jrot = 0x78,
- ttf_loopcall = 0x2a,
- ttf_lt = 0x50,
- ttf_lteq = 0x51,
- ttf_max = 0x8b,
- ttf_md = 0x49,
- ttf_mdap = 0x2e,
- ttf_mdrp = 0xc0,
- ttf_miap = 0x3e,
- ttf_min = 0x8c,
- ttf_mindex = 0x26,
- ttf_mirp = 0xe0,
- ttf_mppem = 0x4b,
- ttf_mps = 0x4c,
- ttf_msirp = 0x3a,
- ttf_mul = 0x63,
- ttf_neg = 0x65,
- ttf_neq = 0x55,
- ttf_not = 0x5c,
- ttf_nround = 0x6c,
- ttf_odd = 0x56,
- ttf_or = 0x5b,
- ttf_pop = 0x21,
- ttf_rcvt = 0x45,
- ttf_rdtg = 0x7d,
- ttf_roff = 0x7a,
- ttf_roll = 0x8a,
- ttf_round = 0x68,
- ttf_rs = 0x43,
- ttf_rtdg = 0x3d,
- ttf_rtg = 0x18,
- ttf_rthg = 0x19,
- ttf_rutg = 0x7c,
- ttf_s45round = 0x77,
- ttf_sangw = 0x7e,
- ttf_scanctrl = 0x85,
- ttf_scantype = 0x8d,
- ttf_scfs = 0x48,
- ttf_scvtci = 0x1d,
- ttf_sdb = 0x5e,
- ttf_sdpvtl = 0x86,
- ttf_sds = 0x5f,
- ttf_sfvfs = 0x0b,
- ttf_sfvtca = 0x04,
- ttf_sfvtl = 0x08,
- ttf_sfvtpv = 0x0e,
- ttf_shc = 0x34,
- ttf_shp = 0x32,
- ttf_shpix = 0x38,
- ttf_shz = 0x36,
- ttf_sloop = 0x17,
- ttf_smd = 0x1a,
- ttf_spvfs = 0x0a,
- ttf_spvtca = 0x02,
- ttf_spvtl = 0x06,
- ttf_sround = 0x76,
- ttf_srp0 = 0x10,
- ttf_srp1 = 0x11,
- ttf_srp2 = 0x12,
- ttf_ssw = 0x1f,
- ttf_sswci = 0x1e,
- ttf_sub = 0x61,
- ttf_svtca = 0x00,
- ttf_swap = 0x23,
- ttf_szp0 = 0x13,
- ttf_szp1 = 0x14,
- ttf_szp2 = 0x15,
- ttf_szps = 0x16,
- ttf_utp = 0x29,
- ttf_wcvtf = 0x70,
- ttf_wcvtp = 0x44,
- ttf_ws = 0x42,
- ttf_getvariation = 0x91
-};
-enum byte_types { bt_instr, bt_cnt, bt_byte, bt_wordhi, bt_wordlo, bt_impliedreturn };
-
-struct instrdata {
- uint8_t *instrs;
- uint32_t instr_cnt;
- uint8_t *bts;
-};
-
-const char *ff_ttf_instrnames[] = {"SVTCA[y-axis]",
- "SVTCA[x-axis]",
- "SPVTCA[y-axis]",
- "SPVTCA[x-axis]",
- "SFVTCA[y-axis]",
- "SFVTCA[x-axis]",
- "SPVTL[parallel]",
- "SPVTL[orthog]",
- "SFVTL[parallel]",
- "SFVTL[orthog]",
- "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",
- "Unknown28",
- "UTP",
- "LOOPCALL",
- "CALL",
- "FDEF",
- "ENDF",
- "MDAP[no-rnd]",
- "MDAP[rnd]",
- "IUP[y]",
- "IUP[x]",
- "SHP[rp2]",
- "SHP[rp1]",
- "SHC[rp2]",
- "SHC[rp1]",
- "SHZ[rp2]",
- "SHZ[rp1]",
- "SHPIX",
- "IP",
- "MSIRP[no-rp0]",
- "MSIRP[rp0]",
- "ALIGNRP",
- "RTDG",
- "MIAP[no-rnd]",
- "MIAP[rnd]",
- "NPUSHB",
- "NPUSHW",
- "WS",
- "RS",
- "WCVTP",
- "RCVT",
- "GC[cur]",
- "GC[orig]",
- "SCFS",
- "MD[grid]",
- "MD[orig]",
- "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[Grey]",
- "ROUND[Black]",
- "ROUND[White]",
- "ROUND[Undef4]",
- "NROUND[Grey]",
- "NROUND[Black]",
- "NROUND[White]",
- "NROUND[Undef4]",
- "WCVTF",
- "DELTAP2",
- "DELTAP3",
- "DELTAC1",
- "DELTAC2",
- "DELTAC3",
- "SROUND",
- "S45ROUND",
- "JROT",
- "JROF",
- "ROFF",
- "Unknown7B",
- "RUTG",
- "RDTG",
- "SANGW",
- "AA",
- "FLIPPT",
- "FLIPRGON",
- "FLIPRGOFF",
- "Unknown83",
- "Unknown84",
- "SCANCTRL",
- "SDPVTL[parallel]",
- "SDPVTL[orthog]",
- "GETINFO",
- "IDEF",
- "ROLL",
- "MAX",
- "MIN",
- "SCANTYPE",
- "INSTCTRL",
- "Unknown8F",
- "Unknown90",
- "GETVARIATION",
- "Unknown92",
- "Unknown93",
- "Unknown94",
- "Unknown95",
- "Unknown96",
- "Unknown97",
- "Unknown98",
- "Unknown99",
- "Unknown9A",
- "Unknown9B",
- "Unknown9C",
- "Unknown9D",
- "Unknown9E",
- "Unknown9F",
- "UnknownA0",
- "UnknownA1",
- "UnknownA2",
- "UnknownA3",
- "UnknownA4",
- "UnknownA5",
- "UnknownA6",
- "UnknownA7",
- "UnknownA8",
- "UnknownA9",
- "UnknownAA",
- "UnknownAB",
- "UnknownAC",
- "UnknownAD",
- "UnknownAE",
- "UnknownAF",
- "PUSHB_1",
- "PUSHB_2",
- "PUSHB_3",
- "PUSHB_4",
- "PUSHB_5",
- "PUSHB_6",
- "PUSHB_7",
- "PUSHB_8",
- "PUSHW_1",
- "PUSHW_2",
- "PUSHW_3",
- "PUSHW_4",
- "PUSHW_5",
- "PUSHW_6",
- "PUSHW_7",
- "PUSHW_8",
- "MDRP[grey]",
- "MDRP[black]",
- "MDRP[white]",
- "MDRP03",
- "MDRP[rnd,grey]",
- "MDRP[rnd,black]",
- "MDRP[rnd,white]",
- "MDRP07",
- "MDRP[min,grey]",
- "MDRP[min,black]",
- "MDRP[min,white]",
- "MDRP0b",
- "MDRP[min,rnd,grey]",
- "MDRP[min,rnd,black]",
- "MDRP[min,rnd,white]",
- "MDRP0f",
- "MDRP[rp0,grey]",
- "MDRP[rp0,black]",
- "MDRP[rp0,white]",
- "MDRP13",
- "MDRP[rp0,rnd,grey]",
- "MDRP[rp0,rnd,black]",
- "MDRP[rp0,rnd,white]",
- "MDRP17",
- "MDRP[rp0,min,grey]",
- "MDRP[rp0,min,black]",
- "MDRP[rp0,min,white]",
- "MDRP1b",
- "MDRP[rp0,min,rnd,grey]",
- "MDRP[rp0,min,rnd,black]",
- "MDRP[rp0,min,rnd,white]",
- "MDRP1f",
- "MIRP[grey]",
- "MIRP[black]",
- "MIRP[white]",
- "MIRP03",
- "MIRP[rnd,grey]",
- "MIRP[rnd,black]",
- "MIRP[rnd,white]",
- "MIRP07",
- "MIRP[min,grey]",
- "MIRP[min,black]",
- "MIRP[min,white]",
- "MIRP0b",
- "MIRP[min,rnd,grey]",
- "MIRP[min,rnd,black]",
- "MIRP[min,rnd,white]",
- "MIRP0f",
- "MIRP[rp0,grey]",
- "MIRP[rp0,black]",
- "MIRP[rp0,white]",
- "MIRP13",
- "MIRP[rp0,rnd,grey]",
- "MIRP[rp0,rnd,black]",
- "MIRP[rp0,rnd,white]",
- "MIRP17",
- "MIRP[rp0,min,grey]",
- "MIRP[rp0,min,black]",
- "MIRP[rp0,min,white]",
- "MIRP1b",
- "MIRP[rp0,min,rnd,grey]",
- "MIRP[rp0,min,rnd,black]",
- "MIRP[rp0,min,rnd,white]",
- "MIRP1f"};
-
-static int strnmatch(const char *str1, const char *str2, int n) {
- int ch1, ch2;
- for (; n-- > 0;) {
- ch1 = *str1++;
- ch2 = *str2++;
- ch1 = tolower(ch1);
- ch2 = tolower(ch2);
- if (ch1 != ch2 || ch1 == '\0') return (ch1 - ch2);
- }
- return (0);
-}
-
-static uint8_t *parse_instrs(char *text, int *len, void *context,
- void (*IVError)(void *context, const char *, int)) {
- short numberstack[256];
- int npos = 0, nread, i;
- int push_left = 0, push_size = 0;
- char *pt;
- char *end, *bend, *brack;
- int icnt = 0, imax = (int)(strlen(text)), val;
- uint8_t *instrs;
- NEW(instrs, imax);
-
- for (pt = text; *pt; ++pt) {
- npos = 0;
- while (npos < 256) {
- while (*pt == ' ' || *pt == '\t')
- ++pt;
- if (isdigit(*pt) || *pt == '-') {
- val = strtol(pt, &end, 0);
- if (val > 32767 || val < -32768) {
- IVError(context, "A value must be between [-32768,32767]", (int)(pt - text));
- return (NULL);
- }
- pt = end;
- numberstack[npos++] = val;
- } else
- break;
- }
- while (*pt == ' ' || *pt == '\t')
- ++pt;
- if (npos == 0 && (*pt == '\r' || *pt == '\n' || *pt == '\0')) continue;
- nread = 0;
- if (push_left == -1) {
- /* we need a push count */
- if (npos == 0)
- IVError(context, "Expected a number for a push count", (int)(pt - text));
- else if (numberstack[0] > 255 || numberstack[0] <= 0) {
- IVError(context, "The push count must be a number between 0 and 255",
- (int)(pt - text));
- return (NULL);
- } else {
- nread = 1;
- instrs[icnt++] = numberstack[0];
- push_left = numberstack[0];
- }
- }
- if (push_left != 0 && push_left < npos - nread &&
- (*pt == '\r' || *pt == '\n' || *pt == '\0')) {
- IVError(context, "More pushes specified than needed", (int)(pt - text));
- return (NULL);
- }
- while (push_left > 0 && nread < npos) {
- if (push_size == 2) {
- instrs[icnt++] = numberstack[nread] >> 8;
- instrs[icnt++] = numberstack[nread++] & 0xff;
- } else if (numberstack[0] > 255 || numberstack[0] < 0) {
- IVError(context, "A value to be pushed by a byte push must be between 0 and 255",
- (int)(pt - text));
- return (NULL);
- } else
- instrs[icnt++] = numberstack[nread++];
- --push_left;
- }
- if (nread < npos && push_left == 0 && (*pt == '\r' || *pt == '\n' || *pt == '\0')) {
- IVError(context, "Unexpected number", (int)(pt - text));
- return (NULL);
- }
- if (*pt == '\r' || *pt == '\n' || *pt == '\0') continue;
- if (push_left > 0) {
- IVError(context, "Missing pushes", (int)(pt - text));
- return (NULL);
- }
- while (nread < npos) {
- i = nread;
- if (numberstack[nread] >= 0 && numberstack[nread] <= 255) {
- while (i < npos && numberstack[i] >= 0 && numberstack[i] <= 255)
- ++i;
- if (i - nread <= 8)
- instrs[icnt++] = ttf_pushb + (i - nread) - 1;
- else {
- instrs[icnt++] = ttf_npushb;
- instrs[icnt++] = i - nread;
- }
- while (nread < i)
- instrs[icnt++] = numberstack[nread++];
- } else {
- while (i < npos && (numberstack[i] < 0 || numberstack[i] > 255))
- ++i;
- if (i - nread <= 8)
- instrs[icnt++] = ttf_pushw + (i - nread) - 1;
- else {
- instrs[icnt++] = ttf_npushw;
- instrs[icnt++] = i - nread;
- }
- while (nread < i) {
- instrs[icnt++] = numberstack[nread] >> 8;
- instrs[icnt++] = numberstack[nread++] & 0xff;
- }
- }
- }
- brack = NULL;
- for (end = pt; *end != '\r' && *end != '\n' && *end != ' ' && *end != '\0'; ++end)
- if (*end == '[' || *end == '_') brack = end;
- for (i = 0; i < 256; ++i)
- if (strnmatch(pt, ff_ttf_instrnames[i], (int)(end - pt)) == 0 &&
- sizeof(char) * (end - pt) == strlen(ff_ttf_instrnames[i]))
- break;
- if (i == 256 && brack != NULL) {
- for (i = 0; i < 256; ++i)
- if (strnmatch(pt, ff_ttf_instrnames[i], (int)(brack - pt + 1)) == 0) break;
- val = strtol(brack + 1, &bend, 2); /* Stuff in brackets should be in binary */
- while (*bend == ' ' || *bend == '\t')
- ++bend;
- if (*bend != ']') {
- IVError(context,
- "Missing right bracket in command (or bad binary value in bracket)",
- (int)(pt - text));
- return (NULL);
- }
- if (val >= 32) {
- IVError(context, "Bracketted value is too large", (int)(pt - text));
- return (NULL);
- }
- i += val;
- }
- pt = end;
- instrs[icnt++] = i;
- if (i == ttf_npushb || i == ttf_npushw || (i >= ttf_pushb && i <= ttf_pushw + 7)) {
- push_size = (i == ttf_npushb || (i >= ttf_pushb && i <= ttf_pushb + 7)) ? 1 : 2;
- if (i == ttf_npushb || i == ttf_npushw)
- push_left = -1;
- else if (i >= ttf_pushb && i <= ttf_pushb + 7)
- push_left = i - ttf_pushb + 1;
- else
- push_left = i - ttf_pushw + 1;
- }
- if (*pt == '\0') break;
- }
- *len = icnt;
- RESIZE(instrs, icnt == 0 ? 1 : icnt);
- return instrs; /* some versions of realloc abort on 0 */
-}
-
-static int instr_typify(struct instrdata *id) {
- int i, len = id->instr_cnt, cnt, j, lh;
- uint8_t *instrs = id->instrs;
- uint8_t *bts;
-
- if (id->bts == NULL) NEW(id->bts, len + 1);
- bts = id->bts;
- for (i = lh = 0; i < len; ++i) {
- bts[i] = bt_instr;
- ++lh;
- if (instrs[i] == ttf_npushb) {
- /* NPUSHB */
- bts[++i] = bt_cnt;
- cnt = instrs[i];
- for (j = 0; j < cnt; ++j)
- bts[++i] = bt_byte;
- lh += 1 + cnt;
- } else if (instrs[i] == ttf_npushw) {
- /* NPUSHW */
- bts[++i] = bt_cnt;
- ++lh;
- cnt = instrs[i];
- for (j = 0; j < cnt; ++j) {
- bts[++i] = bt_wordhi;
- bts[++i] = bt_wordlo;
- }
- lh += 1 + cnt;
- } else if ((instrs[i] & 0xf8) == 0xb0) {
- /* PUSHB[n] */
- cnt = (instrs[i] & 7) + 1;
- for (j = 0; j < cnt; ++j)
- bts[++i] = bt_byte;
- lh += cnt;
- } else if ((instrs[i] & 0xf8) == 0xb8) {
- /* PUSHW[n] */
- cnt = (instrs[i] & 7) + 1;
- for (j = 0; j < cnt; ++j) {
- bts[++i] = bt_wordhi;
- bts[++i] = bt_wordlo;
- }
- lh += cnt;
- }
- }
- bts[i] = bt_impliedreturn;
- return (lh);
-}
-
-json_value *dump_ttinstr(uint8_t *instructions, uint32_t length, const otfcc_Options *options) {
- if (options->instr_as_bytes) {
- size_t len = 0;
- uint8_t *buf = base64_encode(instructions, length, &len);
- return json_string_new_length((uint32_t)len, (char *)buf);
- FREE(buf);
- } else {
- struct instrdata id;
-
- memset(&id, 0, sizeof(id));
- id.instr_cnt = length;
- id.instrs = instructions;
- instr_typify(&id);
- json_value *ret = json_array_new(id.instr_cnt);
- for (uint32_t i = 0; i < id.instr_cnt; ++i) {
- if (id.bts[i] == bt_wordhi) {
- json_array_push(
- ret, json_integer_new((int16_t)((id.instrs[i] << 8) | id.instrs[i + 1])));
- ++i;
- } else if (id.bts[i] == bt_cnt || id.bts[i] == bt_byte) {
- json_array_push(ret, json_integer_new(id.instrs[i]));
- } else {
- json_array_push(ret, json_string_new(ff_ttf_instrnames[id.instrs[i]]));
- }
- }
- FREE(id.bts);
- return preserialize(ret);
- }
-}
-
-void parse_ttinstr(json_value *col, void *context, void (*Make)(void *, uint8_t *, uint32_t),
- void (*Wrong)(void *, const char *, int)) {
- if (!col) {
- Make(context, NULL, 0);
- } else if (col->type == json_string) {
- size_t instrlen;
- uint8_t *instructions =
- base64_decode((uint8_t *)col->u.string.ptr, col->u.string.length, &instrlen);
- Make(context, instructions, (uint32_t)instrlen);
- } else if (col->type == json_array) {
- size_t istrlen = 0;
- for (uint32_t j = 0; j < col->u.array.length; j++) {
- json_value *record = col->u.array.values[j];
- if (record->type == json_string) {
- istrlen += record->u.string.length + 1;
- } else if (record->type == json_integer) {
- istrlen += 1 + 20;
- } else {
- Make(context, NULL, 0);
- return;
- }
- }
- sds instrString = sdsnewlen(NULL, istrlen + 1);
- char *head = instrString;
- for (uint32_t j = 0; j < col->u.array.length; j++) {
- json_value *record = col->u.array.values[j];
- if (record->type == json_string) {
- memcpy(head, record->u.string.ptr, sizeof(char) * record->u.string.length);
- head += record->u.string.length;
- } else if (record->type == json_integer) {
- int n = snprintf(head, 20, "%d", (int)record->u.integer);
- head += n;
- }
- *head = '\n';
- head++;
- }
- int instrLength = 0;
- uint8_t *instructions = parse_instrs(instrString, &instrLength, context, Wrong);
- sdsfree(instrString);
- if (instructions && instrLength) {
- Make(context, instructions, instrLength);
- } else {
- Make(context, NULL, 0);
- }
- } else {
- Make(context, NULL, 0);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.h
deleted file mode 100644
index 3bf56832f3b..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2001-2012 by George Williams */
-/* Copyright (C) 2016 by Belleve Invis */
-
-/*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CARYLL_SUPPORT_TTINSTR_H
-#define CARYLL_SUPPORT_TTINSTR_H
-#include "../util.h"
-
-void parse_ttinstr(json_value *col, void *context, void (*Make)(void *, uint8_t *, uint32_t),
- void (*Wrong)(void *, const char *, int));
-json_value *dump_ttinstr(uint8_t *instructions, uint32_t length, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c
deleted file mode 100644
index a2c2e1ec85e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c
+++ /dev/null
@@ -1,291 +0,0 @@
-#include "unicodeconv.h"
-
-// Brought from libXML2.
-sds utf16le_to_utf8(const uint8_t *inbyte, int inlenb) {
- uint8_t *inb;
- uint16_t *in ;
- uint16_t *inend;
- uint32_t c, d, inlen;
- int bits;
-
- if(inlenb<0) {
- fprintf(stderr,"! error utf16le_to_utf8: inlenb negative.\n");
- return NULL;
- }
- inb = malloc(inlenb);
- if(inb==NULL && inlenb>0){
- fprintf(stderr,"! error utf16le_to_utf8: allocating inb failed.\n");
- exit(1);
- }
- memcpy(inb, inbyte, (size_t)(inlenb));
-
- in = (uint16_t *)inb;
-
- if ((inlenb % 2) == 1) (inlenb)--;
- inlen = inlenb / 2;
- inend = in + inlen;
- // pass 1: calculate bytes used for output
- uint32_t bytesNeeded = 0;
- while (in < inend) {
- c = *in++;
- if ((c & 0xFC00) == 0xD800) { // surrogates
- if (in >= inend) { // (in > inend) shouldn't happens
- break;
- }
- d = *in++;
- if ((d & 0xFC00) == 0xDC00) {
- c &= 0x03FF;
- c <<= 10;
- c |= d & 0x03FF;
- c += 0x10000;
- }
- }
- if (c < 0x80) {
- bytesNeeded += 1;
- } else if (c < 0x800) {
- bytesNeeded += 2;
- } else if (c < 0x10000) {
- bytesNeeded += 3;
- } else {
- bytesNeeded += 4;
- }
- }
- in = (uint16_t *)inb;
- sds out = sdsnewlen(NULL, bytesNeeded);
- sds out0 = out;
-
- while (in < inend) {
- c = *in++;
- if ((c & 0xFC00) == 0xD800) {
- if (in >= inend) { break; }
- d = *in++;
- if ((d & 0xFC00) == 0xDC00) {
- c &= 0x03FF;
- c <<= 10;
- c |= d & 0x03FF;
- c += 0x10000;
- }
- }
-
- if (c < 0x80) {
- *out++ = c;
- bits = -6;
- } else if (c < 0x800) {
- *out++ = ((c >> 6) & 0x1F) | 0xC0;
- bits = 0;
- } else if (c < 0x10000) {
- *out++ = ((c >> 12) & 0x0F) | 0xE0;
- bits = 6;
- } else {
- *out++ = ((c >> 18) & 0x07) | 0xF0;
- bits = 12;
- }
-
- for (; bits >= 0; bits -= 6) {
- *out++ = ((c >> bits) & 0x3F) | 0x80;
- }
- }
- if (inb) {
- free(inb);
- }
- return out0;
-}
-
-sds utf16be_to_utf8(const uint8_t *inbyte, int inlenb) {
- uint8_t *inb;
- uint16_t *in ; //= (uint16_t *)inb;
- uint16_t *inend;
- uint32_t c, d, inlen;
- uint8_t *tmp;
- int bits;
-
- if(inlenb<0) {
- fprintf(stderr,"! error utf16be_to_utf8: inlenb negative.\n");
- return NULL;
- }
- inb = malloc(inlenb);
- if(inb==NULL && inlenb>0){
- fprintf(stderr,"! error utf16be_to_utf8: allocating inb failed.\n");
- exit(1);
- }
- memcpy(inb, inbyte, (size_t)(inlenb));
-
- in = (uint16_t *)inb;
-
- if ((inlenb % 2) == 1) (inlenb)--;
- inlen = inlenb / 2;
- inend = in + inlen;
- uint32_t bytesNeeded = 0;
- while (in < inend) {
- {
- tmp = (uint8_t *)in;
- c = *tmp++;
- c = c << 8;
- c = c | (uint32_t)*tmp;
- in++;
- }
- if ((c & 0xFC00) == 0xD800) {
- if (in >= inend) { break; }
- {
- tmp = (uint8_t *)in;
- d = *tmp++;
- d = d << 8;
- d = d | (uint32_t)*tmp;
- in++;
- }
- if ((d & 0xFC00) == 0xDC00) {
- c &= 0x03FF;
- c <<= 10;
- c |= d & 0x03FF;
- c += 0x10000;
- }
- }
- if (c < 0x80) {
- bytesNeeded += 1;
- } else if (c < 0x800) {
- bytesNeeded += 2;
- } else if (c < 0x10000) {
- bytesNeeded += 3;
- } else {
- bytesNeeded += 4;
- }
- }
- in = (uint16_t *)inb;
- sds out = sdsnewlen(NULL, bytesNeeded);
- sds out0 = out;
-
- while (in < inend) {
- {
- tmp = (uint8_t *)in;
- c = *tmp++;
- c = c << 8;
- c = c | (uint32_t)*tmp;
- in++;
- }
- if ((c & 0xFC00) == 0xD800) {
- if (in >= inend) { break; }
- {
- tmp = (uint8_t *)in;
- d = *tmp++;
- d = d << 8;
- d = d | (uint32_t)*tmp;
- in++;
- }
- if ((d & 0xFC00) == 0xDC00) {
- c &= 0x03FF;
- c <<= 10;
- c |= d & 0x03FF;
- c += 0x10000;
- }
- }
-
- if (c < 0x80) {
- *out++ = c;
- bits = -6;
- } else if (c < 0x800) {
- *out++ = ((c >> 6) & 0x1F) | 0xC0;
- bits = 0;
- } else if (c < 0x10000) {
- *out++ = ((c >> 12) & 0x0F) | 0xE0;
- bits = 6;
- } else {
- *out++ = ((c >> 18) & 0x07) | 0xF0;
- bits = 12;
- }
-
- for (; bits >= 0; bits -= 6) {
- *out++ = ((c >> bits) & 0x3F) | 0x80;
- }
- }
- if (inb) {
- free(inb);
- }
- return out0;
-}
-
-uint8_t *utf8toutf16be(sds _in, size_t *out_bytes) {
- if (!_in) {
- *out_bytes = 0;
- return NULL;
- }
- sds in = _in;
- size_t inlen = sdslen(in);
- char *inend = in + inlen;
-
- uint32_t wordsNeeded = 0;
- uint8_t trailing = 0;
- uint32_t c = 0;
- while (in < inend) {
- uint8_t d = *in++;
- if (d < 0x80) {
- c = d;
- trailing = 0;
- } else if (d < 0xC0) {
- break; // trailing byte in leading position
- } else if (d < 0xE0) {
- c = d & 0x1F;
- trailing = 1;
- } else if (d < 0xF0) {
- c = d & 0x0F;
- trailing = 2;
- } else if (d < 0xF8) {
- c = d & 0x07;
- trailing = 3;
- } else {
- break;
- }
- if (inend - in < trailing) { break; }
- for (; trailing; trailing--) {
- if ((in >= inend) || (((d = *in++) & 0xC0) != 0x80)) break;
- c <<= 6;
- c |= d & 0x3F;
- }
- if (c < 0x10000) {
- wordsNeeded += 1;
- } else if (c < 0x110000) {
- wordsNeeded += 2;
- }
- }
- uint8_t *_out = malloc(2 * wordsNeeded * sizeof(uint8_t));
- uint8_t *out = _out;
- in = _in;
- while (in < inend) {
- uint8_t d = *in++;
- if (d < 0x80) {
- c = d;
- trailing = 0;
- } else if (d < 0xC0) {
- break; // trailing byte in leading position
- } else if (d < 0xE0) {
- c = d & 0x1F;
- trailing = 1;
- } else if (d < 0xF0) {
- c = d & 0x0F;
- trailing = 2;
- } else if (d < 0xF8) {
- c = d & 0x07;
- trailing = 3;
- } else {
- break;
- }
- if (inend - in < trailing) { break; }
- for (; trailing; trailing--) {
- if ((in >= inend) || (((d = *in++) & 0xC0) != 0x80)) break;
- c <<= 6;
- c |= d & 0x3F;
- }
- if (c < 0x10000) {
- *(out++) = (c >> 8) & 0xFF;
- *(out++) = c & 0xFF;
- } else if (c < 0x110000) {
- uint16_t tmp1 = 0xD800 | (c >> 10);
- *(out++) = (tmp1 >> 8) & 0xFF;
- *(out++) = tmp1 & 0xFF;
- uint16_t tmp2 = 0xDC00 | (c & 0x03FF);
- *(out++) = (tmp2 >> 8) & 0xFF;
- *(out++) = tmp2 & 0xFF;
- }
- }
- *out_bytes = wordsNeeded * 2;
- return _out;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h
deleted file mode 100644
index 2d22e4ac466..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_SUPPORT_UNICODECONV_H
-#define CARYLL_SUPPORT_UNICODECONV_H
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include "dep/sds.h"
-sds utf16le_to_utf8(const uint8_t *inb, int inlenb);
-sds utf16be_to_utf8(const uint8_t *inb, int inlenb);
-uint8_t *utf8toutf16be(sds _in, size_t *out_bytes);
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/util.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/util.h
deleted file mode 100644
index a68b3e0ab74..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/util.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef CARYLL_SUPPORT_UTIL_H
-#define CARYLL_SUPPORT_UTIL_H
-
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS
-#endif
-
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "dep/json-builder.h"
-#include "dep/json.h"
-#include "dep/sds.h"
-#include "dep/uthash.h"
-
-#include "caryll/ownership.h"
-#include "caryll/buffer.h"
-
-#include "otfcc/handle.h"
-#include "otfcc/primitives.h"
-#include "otfcc/options.h"
-
-#include "aliases.h"
-#include "otfcc-alloc.h"
-#include "element-impl.h"
-#include "vector-impl.h"
-
-#include "base64/base64.h"
-#include "json/json-ident.h"
-#include "json/json-funcs.h"
-#include "bin-io.h"
-#include "tag.h"
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/vector-impl.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/vector-impl.h
deleted file mode 100644
index f38153d68ec..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/vector-impl.h
+++ /dev/null
@@ -1,190 +0,0 @@
-#ifndef CARYLL_SUPPORT_VECTOR_IMPL_H
-#define CARYLL_SUPPORT_VECTOR_IMPL_H
-
-#include "caryll/vector.h"
-#include "element-impl.h"
-
-#ifndef __CARYLL_INLINE__
-#ifdef _MSC_VER
-#define __CARYLL_INLINE__ __forceinline /* use __forceinline (VC++ specific) */
-#else
-#define __CARYLL_INLINE__ inline /* use standard inline */
-#endif
-#endif
-
-#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define __CARYLL_MAY_UNUSED__ __attribute__((__unused__))
-#elif (__clang_major__ > 2)
-#define __CARYLL_MAY_UNUSED__ __attribute__((__unused__))
-#else
-#define __CARYLL_MAY_UNUSED__
-#endif
-
-#define __CARYLL_VECTOR_INITIAL_SIZE 2
-
-#define caryll_VectorImplFreeIndependent(__TV, __T, __ti) \
- static __CARYLL_INLINE__ void __TV##_dispose(__TV *arr) { \
- if (!arr) return; \
- if ((__ti).dispose) { \
- for (size_t j = arr->length; j--;) { \
- (__ti).dispose(&arr->items[j]); \
- } \
- } \
- __caryll_free(arr->items); \
- arr->items = NULL; \
- arr->length = 0; \
- arr->capacity = 0; \
- }
-
-#define caryll_VectorImplFreeDependent(__TV, __T, __TX, fn) \
- static __CARYLL_INLINE__ void __TV##_disposeDependent(__TV *arr, const __TX *enclosure) { \
- if (!arr) return; \
- for (size_t j = arr->length; j--;) { \
- fn(&arr->items[j], enclosure); \
- } \
- __caryll_free(arr->items); \
- arr->items = NULL; \
- arr->length = 0; \
- arr->capacity = 0; \
- }
-
-#define caryll_VectorImplFunctionsCommon(__TV, __T, __ti) \
- static __CARYLL_INLINE__ void __TV##_init(MODIFY __TV *arr) { \
- arr->length = 0; \
- arr->capacity = 0; \
- arr->items = NULL; \
- } \
- caryll_trivialCreate(__TV); \
- caryll_trivialFree(__TV); \
- static __CARYLL_INLINE__ void __TV##_growTo(MODIFY __TV *arr, size_t target) { \
- if (target <= arr->capacity) return; \
- if (arr->capacity < __CARYLL_VECTOR_INITIAL_SIZE) \
- arr->capacity = __CARYLL_VECTOR_INITIAL_SIZE; \
- while (arr->capacity < target) { \
- arr->capacity += arr->capacity / 2; \
- } \
- if (arr->items) { \
- arr->items = __caryll_realloc(arr->items, arr->capacity * sizeof(__T)); \
- } else { \
- arr->items = __caryll_calloc(arr->capacity, sizeof(__T)); \
- } \
- } \
- static __CARYLL_INLINE__ void __TV##_growToN(MODIFY __TV *arr, size_t target) { \
- if (target <= arr->capacity) return; \
- if (arr->capacity < __CARYLL_VECTOR_INITIAL_SIZE) \
- arr->capacity = __CARYLL_VECTOR_INITIAL_SIZE; \
- if (arr->capacity < target) { arr->capacity = target + 1; } \
- if (arr->items) { \
- arr->items = __caryll_realloc(arr->items, arr->capacity * sizeof(__T)); \
- } else { \
- arr->items = __caryll_calloc(arr->capacity, sizeof(__T)); \
- } \
- } \
- static __CARYLL_INLINE__ void __TV##_resizeTo(MODIFY __TV *arr, size_t target) { \
- arr->capacity = target; \
- if (arr->items) { \
- arr->items = __caryll_realloc(arr->items, arr->capacity * sizeof(__T)); \
- } else { \
- arr->items = __caryll_calloc(arr->capacity, sizeof(__T)); \
- } \
- } \
- static __CARYLL_INLINE__ void __TV##_shrinkToFit(MODIFY __TV *arr) { \
- __TV##_resizeTo(arr, arr->length); \
- } \
- static __CARYLL_INLINE__ void __TV##_grow(MODIFY __TV *arr) { \
- __TV##_growTo(arr, arr->length + 1); \
- } \
- static __CARYLL_INLINE__ void __TV##_push(MODIFY __TV *arr, MOVE __T elem) { \
- __TV##_grow(arr); \
- (arr)->items[(arr)->length++] = (elem); \
- } \
- static __CARYLL_INLINE__ __T __TV##_pop(MODIFY __TV *arr) { \
- __T t = arr->items[arr->length - 1]; \
- arr->length -= 1; \
- return t; \
- } \
- static __CARYLL_INLINE__ void __TV##_fill(MODIFY __TV *arr, size_t n) { \
- while (arr->length < n) { \
- __T x; \
- if ((__ti).init) { \
- (__ti).init(&x); \
- } else { \
- memset(&x, 0, sizeof(x)); \
- } \
- __TV##_push(arr, x); \
- } \
- } \
- static __CARYLL_INLINE__ void __TV##_initN(MODIFY __TV *arr, size_t n) { \
- __TV##_init(arr); \
- __TV##_growToN(arr, n); \
- __TV##_fill(arr, n); \
- } \
- static __CARYLL_INLINE__ void __TV##_initCapN(MODIFY __TV *arr, size_t n) { \
- __TV##_init(arr); \
- __TV##_growToN(arr, n); \
- } \
- static __CARYLL_INLINE__ __TV *__TV##_createN(size_t n) { \
- __TV *t = __caryll_malloc(sizeof(__TV)); \
- __TV##_initN(t, n); \
- return t; \
- } \
- static __CARYLL_INLINE__ void __TV##_move(MODIFY __TV *dst, MOVE __TV *src) { \
- *dst = *src; \
- __TV##_init(src); \
- } \
- static __CARYLL_INLINE__ void __TV##_copy(MODIFY __TV *dst, const __TV *src) { \
- __TV##_init(dst); \
- __TV##_growTo(dst, src->length); \
- dst->length = src->length; \
- if ((__ti).copy) { \
- for (size_t j = 0; j < src->length; j++) { \
- (__ti).copy(&dst->items[j], (const __T *)&src->items[j]); \
- } \
- } else { \
- for (size_t j = 0; j < src->length; j++) { \
- dst->items[j] = src->items[j]; \
- } \
- } \
- } \
- static __CARYLL_INLINE__ void __TV##_sort(MODIFY __TV *arr, \
- int (*fn)(const __T *a, const __T *b)) { \
- qsort(arr->items, arr->length, sizeof(arr->items[0]), \
- (int (*)(const void *, const void *))fn); \
- } \
- static __CARYLL_INLINE__ void __TV##_filterEnv( \
- MODIFY __TV *arr, bool (*fn)(const __T *a, void *env), void *env) { \
- size_t j = 0; \
- for (size_t k = 0; k < arr->length; k++) { \
- if (fn(&arr->items[k], env)) { \
- if (j != k) arr->items[j] = arr->items[k]; \
- j++; \
- } else { \
- (__ti).dispose ? (__ti).dispose(&((arr)->items[k])) : (void)0; \
- } \
- }; \
- arr->length = j; \
- } \
- static __CARYLL_INLINE__ void __TV##_disposeItem(MODIFY __TV *arr, size_t n) { \
- (__ti).dispose ? (__ti).dispose(&((arr)->items[n])) : (void)0; \
- } \
- caryll_trivialReplace(__TV);
-
-#define caryll_VectorImplFunctions(__TV, __T, __ti) \
- caryll_VectorImplFreeIndependent(__TV, __T, __ti); \
- caryll_VectorImplFunctionsCommon(__TV, __T, __ti);
-
-#define caryll_VectorImplAssignments(__TV, __T, __ti) \
- .init = __TV##_init, .copy = __TV##_copy, .dispose = __TV##_dispose, .create = __TV##_create, \
- .createN = __TV##_createN, .free = __TV##_free, .initN = __TV##_initN, \
- .initCapN = __TV##_initCapN, .clear = __TV##_dispose, .replace = __TV##_replace, \
- .copyReplace = __TV##_copyReplace, .push = __TV##_push, .pop = __TV##_pop, \
- .fill = __TV##_fill, .sort = __TV##_sort, .disposeItem = __TV##_disposeItem, \
- .filterEnv = __TV##_filterEnv, .move = __TV##_move, .shrinkToFit = __TV##_shrinkToFit
-
-#define caryll_standardVectorImpl(__TV, __T, __ti, __name) \
- caryll_VectorImplFunctions(__TV, __T, __ti); \
- caryll_VectorInterfaceTypeName(__TV) __name = { \
- caryll_VectorImplAssignments(__TV, __T, __ti), \
- };
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.c
deleted file mode 100644
index bc42832cf65..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.c
+++ /dev/null
@@ -1,330 +0,0 @@
-#include "BASE.h"
-
-#include "otl/private.h"
-
-
-static void deleteBaseAxis(MOVE otl_BaseAxis *axis) {
- if (!axis) return;
- if (axis->entries) {
- for (tableid_t j = 0; j < axis->scriptCount; j++) {
- if (axis->entries[j].baseValues) FREE(axis->entries[j].baseValues);
- }
- FREE(axis->entries);
- }
-}
-
-static INLINE void disposeBASE(MOVE table_BASE *base) {
- deleteBaseAxis(base->horizontal);
- deleteBaseAxis(base->vertical);
-}
-
-caryll_standardRefType(table_BASE, table_iBASE, disposeBASE);
-
-static int16_t readBaseValue(font_file_pointer data, uint32_t tableLength, uint16_t offset) {
- checkLength(offset + 4);
- return read_16s(data + offset + 2);
-FAIL:
- return 0;
-}
-
-static void readBaseScript(const font_file_pointer data, uint32_t tableLength, uint16_t offset,
- otl_BaseScriptEntry *entry, uint32_t *baseTagList, uint16_t nBaseTags) {
- entry->baseValuesCount = 0;
- entry->baseValues = NULL;
- entry->defaultBaselineTag = 0;
- checkLength(offset + 2); // care about base values only now
- uint16_t baseValuesOffset = read_16u(data + offset);
- if (baseValuesOffset) {
- baseValuesOffset += offset;
- checkLength(baseValuesOffset + 4);
- uint16_t defaultIndex = read_16u(data + baseValuesOffset) % nBaseTags;
- entry->defaultBaselineTag = baseTagList[defaultIndex];
- entry->baseValuesCount = read_16u(data + baseValuesOffset + 2);
- if (entry->baseValuesCount != nBaseTags) goto FAIL;
- checkLength(baseValuesOffset + 4 + 2 * entry->baseValuesCount);
- NEW(entry->baseValues, entry->baseValuesCount);
- for (tableid_t j = 0; j < entry->baseValuesCount; j++) {
- entry->baseValues[j].tag = baseTagList[j];
- uint16_t _valOffset = read_16u(data + baseValuesOffset + 4 + 2 * j);
- if (_valOffset) {
- entry->baseValues[j].coordinate =
- readBaseValue(data, tableLength, baseValuesOffset + _valOffset);
- } else {
- entry->baseValues[j].coordinate = 0;
- }
- }
- return;
- }
-FAIL:
- entry->baseValuesCount = 0;
- if (entry->baseValues) FREE(entry->baseValues);
- entry->baseValues = NULL;
- entry->defaultBaselineTag = 0;
- return;
-}
-
-static otl_BaseAxis *readAxis(font_file_pointer data, uint32_t tableLength, uint16_t offset) {
- otl_BaseAxis *axis = NULL;
- uint32_t *baseTagList = NULL;
- checkLength(offset + 4);
-
- // Read BaseTagList
- uint16_t baseTagListOffset = offset + read_16u(data + offset);
- if (baseTagListOffset <= offset) goto FAIL;
- checkLength(baseTagListOffset + 2);
- uint16_t nBaseTags = read_16u(data + baseTagListOffset);
- if (!nBaseTags) goto FAIL;
- checkLength(baseTagListOffset + 2 + 4 * nBaseTags);
- NEW(baseTagList, nBaseTags);
- for (uint16_t j = 0; j < nBaseTags; j++) {
- baseTagList[j] = read_32u(data + baseTagListOffset + 2 + j * 4);
- }
-
- uint16_t baseScriptListOffset = offset + read_16u(data + offset + 2);
- if (baseScriptListOffset <= offset) goto FAIL;
- checkLength(baseScriptListOffset + 2);
- tableid_t nBaseScripts = read_16u(data + baseScriptListOffset);
- checkLength(baseScriptListOffset + 2 + 6 * nBaseScripts);
- NEW(axis);
- axis->scriptCount = nBaseScripts;
- NEW(axis->entries, nBaseScripts);
- for (tableid_t j = 0; j < nBaseScripts; j++) {
- axis->entries[j].tag = read_32u(data + baseScriptListOffset + 2 + 6 * j);
- uint16_t baseScriptOffset = read_16u(data + baseScriptListOffset + 2 + 6 * j + 4);
- if (baseScriptOffset) {
- readBaseScript(data, tableLength, baseScriptListOffset + baseScriptOffset,
- &(axis->entries[j]), baseTagList, nBaseTags);
- } else {
- axis->entries[j].baseValuesCount = 0;
- axis->entries[j].baseValues = NULL;
- axis->entries[j].defaultBaselineTag = 0;
- }
- }
- return axis;
-
-FAIL:
- if (baseTagList) FREE(baseTagList);
- DELETE(deleteBaseAxis, axis);
- return axis;
-}
-
-table_BASE *otfcc_readBASE(const otfcc_Packet packet, const otfcc_Options *options) {
- table_BASE *base = NULL;
- FOR_TABLE(OTFCC_CHR('B','A','S','E'), table) {
- font_file_pointer data = table.data;
- uint32_t tableLength = table.length;
- checkLength(8);
- NEW(base);
- uint16_t offsetH = read_16u(data + 4);
- if (offsetH) base->horizontal = readAxis(data, tableLength, offsetH);
- uint16_t offsetV = read_16u(data + 6);
- if (offsetV) base->vertical = readAxis(data, tableLength, offsetV);
- return base;
- FAIL:
- logWarning("Table 'BASE' Corrupted");
- DELETE(table_iBASE.free, base);
- }
- return base;
-}
-
-static json_value *axisToJson(const otl_BaseAxis *axis) {
- json_value *_axis = json_object_new(axis->scriptCount);
- for (tableid_t j = 0; j < axis->scriptCount; j++) {
- if (!axis->entries[j].tag) continue;
- json_value *_entry = json_object_new(3);
- if (axis->entries[j].defaultBaselineTag) {
- char tag[4];
- tag2str(axis->entries[j].defaultBaselineTag, tag);
- json_object_push(_entry, "defaultBaseline", json_string_new_length(4, tag));
- }
- json_value *_values = json_object_new(axis->entries[j].baseValuesCount);
- for (tableid_t k = 0; k < axis->entries[j].baseValuesCount; k++) {
- if (axis->entries[j].baseValues[k].tag) {
-
- json_object_push_tag(_values, axis->entries[j].baseValues[k].tag,
- json_new_position(axis->entries[j].baseValues[k].coordinate));
- }
- }
- json_object_push(_entry, "baselines", _values);
- json_object_push_tag(_axis, axis->entries[j].tag, _entry);
- }
- return _axis;
-}
-
-void otfcc_dumpBASE(const table_BASE *base, json_value *root, const otfcc_Options *options) {
- if (!base) return;
- loggedStep("BASE") {
- json_value *_base = json_object_new(2);
- if (base->horizontal) json_object_push(_base, "horizontal", axisToJson(base->horizontal));
- if (base->vertical) json_object_push(_base, "vertical", axisToJson(base->vertical));
- json_object_push(root, "BASE", _base);
- }
-}
-
-static void baseScriptFromJson(const json_value *_sr, otl_BaseScriptEntry *entry) {
- entry->defaultBaselineTag = str2tag(json_obj_getstr_share(_sr, "defaultBaseline"));
- json_value *_basevalues = json_obj_get_type(_sr, "baselines", json_object);
- if (!_basevalues) {
- entry->baseValuesCount = 0;
- entry->baseValues = NULL;
- } else {
- entry->baseValuesCount = _basevalues->u.object.length;
- NEW(entry->baseValues, entry->baseValuesCount);
- for (tableid_t j = 0; j < entry->baseValuesCount; j++) {
- entry->baseValues[j].tag = str2tag(_basevalues->u.object.values[j].name);
- entry->baseValues[j].coordinate = json_numof(_basevalues->u.object.values[j].value);
- }
- }
-}
-
-static int by_script_tag(const void *a, const void *b) {
- return ((const otl_BaseScriptEntry *)a)->tag - ((const otl_BaseScriptEntry *)b)->tag;
-}
-
-static otl_BaseAxis *axisFromJson(const json_value *_axis) {
- if (!_axis) return NULL;
- otl_BaseAxis *axis;
- NEW(axis);
- axis->scriptCount = _axis->u.object.length;
- NEW(axis->entries, axis->scriptCount);
- tableid_t jj = 0;
- for (tableid_t j = 0; j < axis->scriptCount; j++) {
- if (_axis->u.object.values[j].value &&
- _axis->u.object.values[j].value->type == json_object) {
- axis->entries[jj].tag = str2tag(_axis->u.object.values[j].name);
- baseScriptFromJson(_axis->u.object.values[j].value, &(axis->entries[jj]));
- jj++;
- }
- }
- axis->scriptCount = jj;
- qsort(axis->entries, axis->scriptCount, sizeof(otl_BaseScriptEntry), by_script_tag);
- return axis;
-}
-
-table_BASE *otfcc_parseBASE(const json_value *root, const otfcc_Options *options) {
- table_BASE *base = NULL;
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "BASE", json_object))) {
- loggedStep("BASE") {
- NEW(base);
- base->horizontal = axisFromJson(json_obj_get_type(table, "horizontal", json_object));
- base->vertical = axisFromJson(json_obj_get_type(table, "vertical", json_object));
- }
- }
- return base;
-}
-
-static int by_tag(const void *a, const void *b) {
- return *((const uint32_t *)a) - *((const uint32_t *)b);
-}
-
-static bk_Block *axisToBk(const otl_BaseAxis *axis) {
- if (!axis) return NULL;
- struct {
- tableid_t size;
- uint32_t *items;
- } taglist;
- taglist.size = 0;
- taglist.items = NULL;
-
- for (tableid_t j = 0; j < axis->scriptCount; j++) {
- otl_BaseScriptEntry *entry = &(axis->entries[j]);
- if (entry->defaultBaselineTag) {
- bool found = false;
- for (tableid_t jk = 0; jk < taglist.size; jk++) {
- if (taglist.items[jk] == entry->defaultBaselineTag) {
- found = true;
- break;
- }
- }
- if (!found) {
- taglist.size += 1;
- RESIZE(taglist.items, taglist.size);
- taglist.items[taglist.size - 1] = entry->defaultBaselineTag;
- }
- }
- for (tableid_t k = 0; k < entry->baseValuesCount; k++) {
- uint32_t tag = entry->baseValues[k].tag;
- bool found = false;
- for (tableid_t jk = 0; jk < taglist.size; jk++) {
- if (taglist.items[jk] == tag) {
- found = true;
- break;
- }
- }
- if (!found) {
- taglist.size += 1;
- RESIZE(taglist.items, taglist.size);
- taglist.items[taglist.size - 1] = tag;
- }
- }
- }
- qsort(taglist.items, taglist.size, sizeof(uint32_t), by_tag);
- bk_Block *baseTagList = bk_new_Block(b16, taglist.size, bkover);
- for (tableid_t j = 0; j < taglist.size; j++) {
- bk_push(baseTagList, b32, taglist.items[j], bkover);
- }
-
- bk_Block *baseScriptList = bk_new_Block(b16, axis->scriptCount, bkover);
- for (tableid_t j = 0; j < axis->scriptCount; j++) {
- otl_BaseScriptEntry *entry = &(axis->entries[j]);
- bk_Block *baseValues = bk_new_Block(bkover);
- {
- tableid_t defaultIndex = 0;
- for (tableid_t m = 0; m < taglist.size; m++) {
- if (taglist.items[m] == entry->defaultBaselineTag) {
- defaultIndex = m;
- break;
- }
- }
- bk_push(baseValues, b16, defaultIndex, bkover);
- }
- bk_push(baseValues, b16, taglist.size, bkover);
- for (size_t m = 0; m < taglist.size; m++) {
- bool found = false;
- tableid_t foundIndex = 0;
- for (tableid_t k = 0; k < entry->baseValuesCount; k++) {
- if (entry->baseValues[k].tag == taglist.items[m]) {
- found = true, foundIndex = k;
- break;
- }
- }
- if (found) {
- bk_push(baseValues, // base value
- p16,
- bk_new_Block(
- b16, 1, // format
- b16, (int16_t)entry->baseValues[foundIndex].coordinate, // coordinate
- bkover),
- bkover);
- } else {
- bk_push(baseValues, // assign a zero value
- p16,
- bk_new_Block(b16, 1, // format
- b16, 0, // coordinate
- bkover),
- bkover);
- }
- }
- bk_Block *scriptRecord = bk_new_Block(p16, baseValues, // BaseValues
- p16, NULL, // DefaultMinMax
- b16, 0, // BaseLangSysCount
- bkover);
- bk_push(baseScriptList, b32, entry->tag, // BaseScriptTag
- p16, scriptRecord, // BaseScript
- bkover);
- }
- FREE(taglist.items);
- return bk_new_Block(p16, baseTagList, // BaseTagList
- p16, baseScriptList, // BaseScriptList
- bkover);
-}
-
-caryll_Buffer *otfcc_buildBASE(const table_BASE *base, const otfcc_Options *options) {
- if (!base) return NULL;
- bk_Block *root = bk_new_Block(b32, 0x10000, // Version
- p16, axisToBk(base->horizontal), // HorizAxis
- p16, axisToBk(base->vertical), // VertAxis
- bkover);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.h
deleted file mode 100644
index 3d279e5c4b9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/BASE.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_BASE_H
-#define CARYLL_TABLE_BASE_H
-
-#include "otfcc/table/BASE.h"
-
-table_BASE *otfcc_readBASE(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpBASE(const table_BASE *base, json_value *root, const otfcc_Options *options);
-table_BASE *otfcc_parseBASE(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildBASE(const table_BASE *base, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.c
deleted file mode 100644
index 8ec40f150fe..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.c
+++ /dev/null
@@ -1,1411 +0,0 @@
-#include "CFF.h"
-
-#include "support/util.h"
-#include "libcff/libcff.h"
-#include "libcff/charstring-il.h"
-#include "libcff/subr.h"
-
-
-const double DEFAULT_BLUE_SCALE = 0.039625;
-const double DEFAULT_BLUE_SHIFT = 7;
-const double DEFAULT_BLUE_FUZZ = 1;
-const double DEFAULT_EXPANSION_FACTOR = 0.06;
-
-static cff_PrivateDict *otfcc_newCff_private() {
- cff_PrivateDict *pd = NULL;
- NEW(pd);
- pd->blueFuzz = DEFAULT_BLUE_FUZZ;
- pd->blueScale = DEFAULT_BLUE_SCALE;
- pd->blueShift = DEFAULT_BLUE_SHIFT;
- pd->expansionFactor = DEFAULT_EXPANSION_FACTOR;
- return pd;
-}
-
-static INLINE void initFD(table_CFF *fd) {
- memset(fd, 0, sizeof(*fd));
- fd->underlinePosition = -100;
- fd->underlineThickness = 50;
-}
-static void otfcc_delete_privatedict(cff_PrivateDict *priv) {
- if (!priv) return;
- FREE(priv->blueValues);
- FREE(priv->otherBlues);
- FREE(priv->familyBlues);
-
- FREE(priv->familyOtherBlues);
- FREE(priv->stemSnapH);
- FREE(priv->stemSnapV);
- FREE(priv);
-}
-static INLINE void disposeFontMatrix(cff_FontMatrix *fm) {
- if (!fm) return;
- iVQ.dispose(&fm->x);
- iVQ.dispose(&fm->y);
-}
-static INLINE void disposeFD(table_CFF *fd) {
- sdsfree(fd->version);
- sdsfree(fd->notice);
- sdsfree(fd->copyright);
- sdsfree(fd->fullName);
- sdsfree(fd->familyName);
- sdsfree(fd->weight);
-
- sdsfree(fd->fontName);
- sdsfree(fd->cidRegistry);
- sdsfree(fd->cidOrdering);
- disposeFontMatrix(fd->fontMatrix);
- FREE(fd->fontMatrix);
- otfcc_delete_privatedict(fd->privateDict);
- if (fd->fdArray) {
- for (tableid_t j = 0; j < fd->fdArrayCount; j++) {
- table_iCFF.free(fd->fdArray[j]);
- }
- FREE(fd->fdArray);
- }
-}
-
-caryll_standardRefType(table_CFF, table_iCFF, initFD, disposeFD);
-
-typedef struct {
- int32_t fdArrayIndex;
- table_CFF *meta;
- table_glyf *glyphs;
- cff_File *cffFile;
- uint64_t seed;
-} cff_extract_context;
-static void callback_extract_private(uint32_t op, uint8_t top, cff_Value *stack, void *_context) {
- cff_extract_context *context = (cff_extract_context *)_context;
- table_CFF *meta = context->meta;
- if (context->fdArrayIndex >= 0 && context->fdArrayIndex < meta->fdArrayCount) {
- meta = meta->fdArray[context->fdArrayIndex];
- }
- cff_PrivateDict *pd = meta->privateDict;
- switch (op) {
- // DELTAs
- case op_BlueValues: {
- pd->blueValuesCount = top;
- NEW(pd->blueValues, pd->blueValuesCount);
- for (arity_t j = 0; j < pd->blueValuesCount; j++) {
- pd->blueValues[j] = cffnum(stack[j]);
- }
- break;
- }
- case op_OtherBlues: {
- pd->otherBluesCount = top;
- NEW(pd->otherBlues, pd->otherBluesCount);
- for (arity_t j = 0; j < pd->otherBluesCount; j++) {
- pd->otherBlues[j] = cffnum(stack[j]);
- }
- break;
- }
- case op_FamilyBlues: {
- pd->familyBluesCount = top;
- NEW(pd->familyBlues, pd->familyBluesCount);
- for (arity_t j = 0; j < pd->familyBluesCount; j++) {
- pd->familyBlues[j] = cffnum(stack[j]);
- }
- break;
- }
- case op_FamilyOtherBlues: {
- pd->familyOtherBluesCount = top;
- NEW(pd->familyOtherBlues, pd->familyOtherBluesCount);
- for (arity_t j = 0; j < pd->familyOtherBluesCount; j++) {
- pd->familyOtherBlues[j] = cffnum(stack[j]);
- }
- break;
- }
- case op_StemSnapH: {
- pd->stemSnapHCount = top;
- NEW(pd->stemSnapH, pd->stemSnapHCount);
- for (arity_t j = 0; j < pd->stemSnapHCount; j++) {
- pd->stemSnapH[j] = cffnum(stack[j]);
- }
- break;
- }
- case op_StemSnapV: {
- pd->stemSnapVCount = top;
- NEW(pd->stemSnapV, pd->stemSnapVCount);
- for (arity_t j = 0; j < pd->stemSnapVCount; j++) {
- pd->stemSnapV[j] = cffnum(stack[j]);
- }
- break;
- }
- // Numbers
- case op_BlueScale:
- if (top) { pd->blueScale = cffnum(stack[top - 1]); }
- break;
- case op_BlueShift:
- if (top) { pd->blueShift = cffnum(stack[top - 1]); }
- break;
- case op_BlueFuzz:
- if (top) { pd->blueFuzz = cffnum(stack[top - 1]); }
- break;
- case op_StdHW:
- if (top) { pd->stdHW = cffnum(stack[top - 1]); }
- break;
- case op_StdVW:
- if (top) { pd->stdVW = cffnum(stack[top - 1]); }
- break;
- case op_ForceBold:
- if (top) { pd->forceBold = cffnum(stack[top - 1]); }
- break;
- case op_LanguageGroup:
- if (top) { pd->languageGroup = cffnum(stack[top - 1]); }
- break;
- case op_ExpansionFactor:
- if (top) { pd->expansionFactor = cffnum(stack[top - 1]); }
- break;
- case op_initialRandomSeed:
- if (top) { pd->initialRandomSeed = cffnum(stack[top - 1]); }
- break;
- case op_defaultWidthX:
- if (top) { pd->defaultWidthX = cffnum(stack[top - 1]); }
- break;
- case op_nominalWidthX:
- if (top) { pd->nominalWidthX = cffnum(stack[top - 1]); }
- break;
- }
-}
-
-static void callback_extract_fd(uint32_t op, uint8_t top, cff_Value *stack, void *_context) {
- cff_extract_context *context = (cff_extract_context *)_context;
- cff_File *file = context->cffFile;
- table_CFF *meta = context->meta;
- if (context->fdArrayIndex >= 0 && context->fdArrayIndex < meta->fdArrayCount) {
- meta = meta->fdArray[context->fdArrayIndex];
- }
- switch (op) {
- case op_version:
- if (top) { meta->version = sdsget_cff_sid(stack[top - 1].i, file->string); }
- break;
- case op_Notice:
- if (top) { meta->notice = sdsget_cff_sid(stack[top - 1].i, file->string); }
- break;
- case op_Copyright:
- if (top) { meta->copyright = sdsget_cff_sid(stack[top - 1].i, file->string); }
- break;
- case op_FontName:
- if (top) { meta->fontName = sdsget_cff_sid(stack[top - 1].i, file->string); }
- break;
- case op_FullName:
- if (top) { meta->fullName = sdsget_cff_sid(stack[top - 1].i, file->string); }
- break;
- case op_FamilyName:
- if (top) { meta->familyName = sdsget_cff_sid(stack[top - 1].i, file->string); }
- break;
- case op_Weight:
- if (top) { meta->weight = sdsget_cff_sid(stack[top - 1].i, file->string); }
- break;
- case op_FontBBox:
- if (top >= 4) {
- meta->fontBBoxLeft = cffnum(stack[top - 4]);
- meta->fontBBoxBottom = cffnum(stack[top - 3]);
- meta->fontBBoxRight = cffnum(stack[top - 2]);
- meta->fontBBoxTop = cffnum(stack[top - 1]);
- }
- break;
- case op_FontMatrix:
- if (top >= 6) {
- NEW(meta->fontMatrix);
- meta->fontMatrix->a = cffnum(stack[top - 6]);
- meta->fontMatrix->b = cffnum(stack[top - 5]);
- meta->fontMatrix->c = cffnum(stack[top - 4]);
- meta->fontMatrix->d = cffnum(stack[top - 3]);
- meta->fontMatrix->x = iVQ.createStill(cffnum(stack[top - 2]));
- meta->fontMatrix->y = iVQ.createStill(cffnum(stack[top - 1]));
- }
- break;
- case op_isFixedPitch:
- if (top) { meta->isFixedPitch = (bool)cffnum(stack[top - 1]); }
- break;
- case op_ItalicAngle:
- if (top) { meta->italicAngle = cffnum(stack[top - 1]); }
- break;
- case op_UnderlinePosition:
- if (top) { meta->underlinePosition = cffnum(stack[top - 1]); }
- break;
- case op_UnderlineThickness:
- if (top) { meta->underlineThickness = cffnum(stack[top - 1]); }
- break;
- case op_StrokeWidth:
- if (top) { meta->strokeWidth = cffnum(stack[top - 1]); }
- break;
-
- // Private
- case op_Private:
- if (top >= 2) {
- uint32_t privateLength = cffnum(stack[top - 2]);
- uint32_t privateOffset = cffnum(stack[top - 1]);
- meta->privateDict = otfcc_newCff_private();
- cff_iDict.parseToCallback(file->raw_data + privateOffset, privateLength, context,
- callback_extract_private);
- }
- break;
- // CID
- case op_ROS:
- if (top >= 3) {
- meta->isCID = true;
- meta->cidRegistry = sdsget_cff_sid(stack[top - 3].i, file->string);
- meta->cidOrdering = sdsget_cff_sid(stack[top - 2].i, file->string);
- meta->cidSupplement = cffnum(stack[top - 1]);
- }
- break;
- }
-}
-
-typedef struct {
- glyf_Glyph *g;
- shapeid_t jContour;
- shapeid_t jPoint;
- double defaultWidthX;
- double nominalWidthX;
- uint8_t definedHStems;
- uint8_t definedVStems;
- uint8_t definedHintMasks;
- uint8_t definedContourMasks;
- uint64_t randx;
-} outline_builder_context;
-
-static void callback_draw_setwidth(void *_context, double width) {
- outline_builder_context *context = (outline_builder_context *)_context;
- iVQ.replace(&context->g->advanceWidth, iVQ.createStill(width + context->nominalWidthX));
-}
-static void callback_draw_next_contour(void *_context) {
- outline_builder_context *context = (outline_builder_context *)_context;
- glyf_Contour c;
- glyf_iContour.init(&c);
- glyf_iContourList.push(&context->g->contours, c);
- context->jContour = context->g->contours.length;
- context->jPoint = 0;
-}
-static void callback_draw_lineto(void *_context, double x1, double y1) {
- outline_builder_context *context = (outline_builder_context *)_context;
- if (context->jContour) {
- glyf_Contour *contour = &context->g->contours.items[context->jContour - 1];
- glyf_Point z;
- glyf_iPoint.init(&z);
- z.onCurve = true;
- iVQ.copyReplace(&z.x, iVQ.createStill(x1));
- iVQ.copyReplace(&z.y, iVQ.createStill(y1));
- glyf_iContour.push(contour, z);
- context->jPoint += 1;
- }
-}
-static void callback_draw_curveto(void *_context, double x1, double y1, double x2, double y2,
- double x3, double y3) {
- outline_builder_context *context = (outline_builder_context *)_context;
- if (context->jContour) {
- glyf_Contour *contour = &context->g->contours.items[context->jContour - 1];
- {
- glyf_Point z;
- glyf_iPoint.init(&z);
- z.onCurve = false;
- iVQ.copyReplace(&z.x, iVQ.createStill(x1));
- iVQ.copyReplace(&z.y, iVQ.createStill(y1));
- glyf_iContour.push(contour, z);
- }
- {
- glyf_Point z;
- glyf_iPoint.init(&z);
- z.onCurve = false;
- iVQ.copyReplace(&z.x, iVQ.createStill(x2));
- iVQ.copyReplace(&z.y, iVQ.createStill(y2));
- glyf_iContour.push(contour, z);
- }
- {
- glyf_Point z;
- glyf_iPoint.init(&z);
- z.onCurve = true;
- iVQ.copyReplace(&z.x, iVQ.createStill(x3));
- iVQ.copyReplace(&z.y, iVQ.createStill(y3));
- glyf_iContour.push(contour, z);
- }
- context->jPoint += 3;
- }
-}
-static void callback_draw_sethint(void *_context, bool isVertical, double position, double width) {
- outline_builder_context *context = (outline_builder_context *)_context;
- glyf_iStemDefList.push((isVertical ? &context->g->stemV : &context->g->stemH), //
- ((glyf_PostscriptStemDef){
- .position = position,
- .width = width,
- }));
-}
-static void callback_draw_setmask(void *_context, bool isContourMask, bool *maskArray) {
- outline_builder_context *context = (outline_builder_context *)_context;
- glyf_MaskList *maskList = isContourMask ? &context->g->contourMasks : &context->g->hintMasks;
- glyf_PostscriptHintMask mask;
-
- if (context->jContour) {
- mask.contoursBefore = context->jContour - 1;
- } else {
- mask.contoursBefore = 0;
- }
- mask.pointsBefore = context->jPoint;
-
- for (shapeid_t j = 0; j < 0x100; j++) {
- mask.maskH[j] = j < context->g->stemH.length ? maskArray[j] : 0;
- mask.maskV[j] = j < context->g->stemV.length ? maskArray[j + context->g->stemH.length] : 0;
- }
-
- FREE(maskArray);
- if (maskList->length > 0 &&
- maskList->items[maskList->length - 1].contoursBefore == mask.contoursBefore &&
- maskList->items[maskList->length - 1].pointsBefore == mask.pointsBefore) {
- // two masks are stacking together
- // simply replace maskH and maskV
- for (shapeid_t j = 0; j < 0x100; j++) {
- maskList->items[maskList->length - 1].maskH[j] = mask.maskH[j];
- maskList->items[maskList->length - 1].maskV[j] = mask.maskV[j];
- }
- } else {
- glyf_iMaskList.push(maskList, mask);
- if (isContourMask) {
- context->definedContourMasks += 1;
- } else {
- context->definedHintMasks += 1;
- }
- }
-}
-
-static double callback_draw_getrand(void *_context) {
- // xorshift64* PRNG to double53
- outline_builder_context *context = (outline_builder_context *)_context;
- uint64_t x = context->randx;
- x ^= x >> 12;
- x ^= x << 25;
- x ^= x >> 27;
- context->randx = x;
- union {
- uint64_t u;
- double d;
- } a;
- a.u = x * UINT64_C(2685821657736338717);
- a.u = (a.u >> 12) | UINT64_C(0x3FF0000000000000);
- double q = (a.u & 2048) ? (1.0 - (2.2204460492503131E-16 / 2.0)) : 1.0;
- return a.d - q;
-}
-
-static cff_IOutlineBuilder drawPass = {.setWidth = callback_draw_setwidth,
- .newContour = callback_draw_next_contour,
- .lineTo = callback_draw_lineto,
- .curveTo = callback_draw_curveto,
- .setHint = callback_draw_sethint,
- .setMask = callback_draw_setmask,
- .getrand = callback_draw_getrand};
-
-static void buildOutline(glyphid_t i, cff_extract_context *context, const otfcc_Options *options) {
- cff_File *f = context->cffFile;
- glyf_Glyph *g = otfcc_newGlyf_glyph();
- context->glyphs->items[i] = g;
- uint64_t seed = context->seed;
-
- cff_Index localSubrs;
- cff_iIndex.init(&localSubrs);
-
- cff_Stack stack;
- stack.max = 0x10000;
- NEW(stack.stack, stack.max);
- stack.index = 0;
- stack.stem = 0;
-
- outline_builder_context bc = {g, 0, 0, 0.0, 0.0, 0, 0, 0, 0, 0};
-
- // Determine used FD index and subroutine list
- uint8_t fd = 0;
- if (f->fdselect.t != cff_FDSELECT_UNSPECED)
- fd = cff_parseSubr(i, f->raw_data, f->font_dict, f->fdselect, &localSubrs);
- else
- fd = cff_parseSubr(i, f->raw_data, f->top_dict, f->fdselect, &localSubrs);
-
- g->fdSelect = Handle.fromIndex(fd);
-
- // Decide default and nominal width
- if (context->meta->fdArray && fd < context->meta->fdArrayCount &&
- context->meta->fdArray[fd]->privateDict) {
- bc.defaultWidthX = context->meta->fdArray[fd]->privateDict->defaultWidthX;
- bc.nominalWidthX = context->meta->fdArray[fd]->privateDict->nominalWidthX;
- } else if (context->meta->privateDict) {
- bc.defaultWidthX = context->meta->privateDict->defaultWidthX;
- bc.nominalWidthX = context->meta->privateDict->nominalWidthX;
- }
- iVQ.replace(&g->advanceWidth, iVQ.createStill(bc.defaultWidthX));
-
- // Get charstring
- uint8_t *charStringPtr = f->char_strings.data + f->char_strings.offset[i] - 1;
- uint32_t charStringLength = f->char_strings.offset[i + 1] - f->char_strings.offset[i];
-
- // Draw points
- stack.index = 0;
- stack.stem = 0;
- bc.jContour = 0;
- bc.jPoint = 0;
- bc.randx = seed;
-
- cff_parseOutline(charStringPtr, charStringLength, f->global_subr, localSubrs, &stack, &bc,
- drawPass, options);
-
- // Turn deltas into absolute coordinates
- VQ cx = iVQ.neutral(), cy = iVQ.neutral();
- for (shapeid_t j = 0; j < g->contours.length; j++) {
- glyf_Contour *contour = &g->contours.items[j];
- for (shapeid_t k = 0; k < contour->length; k++) {
- glyf_Point *z = &contour->items[k];
- iVQ.inplacePlus(&cx, z->x);
- iVQ.inplacePlus(&cy, z->y);
- iVQ.copyReplace(&z->x, cx);
- iVQ.copyReplace(&z->y, cy);
- }
- if (!iVQ.compare(contour->items[0].x, contour->items[contour->length - 1].x) &&
- !iVQ.compare(contour->items[0].y, contour->items[contour->length - 1].y) &&
- (contour->items[0].onCurve && contour->items[contour->length - 1].onCurve)) {
- // We found a duplicate knot at the beginning and end of a curve
- // mainly due to curveto. We can remove that. This is unnecessary.
- glyf_iContour.pop(contour);
- }
- glyf_iContour.shrinkToFit(contour);
- }
- glyf_iContourList.shrinkToFit(&g->contours);
- iVQ.dispose(&cx), iVQ.dispose(&cy);
-
- cff_iIndex.dispose(&localSubrs);
- FREE(stack.stack);
- context->seed = bc.randx;
-}
-
-static sds formCIDString(cffsid_t cid) {
- return sdscatprintf(sdsnew("CID"), "%d", cid);
-}
-
-static void nameGlyphsAccordingToCFF(cff_extract_context *context) {
- cff_File *cffFile = context->cffFile;
- table_glyf *glyphs = context->glyphs;
- cff_Charset *charset = &cffFile->charsets;
- if (context->meta->isCID) {
- switch (charset->t) {
- case cff_CHARSET_FORMAT0: {
- for (glyphid_t j = 0; j < charset->s; j++) {
- cffsid_t sid = charset->f0.glyph[j];
- sds glyphname = sdsget_cff_sid(sid, cffFile->string);
- if (glyphname) {
- glyphs->items[j + 1]->name = glyphname;
- glyphs->items[j + 1]->cid = sid;
- }
- }
- break;
- }
- case cff_CHARSET_FORMAT1: {
- uint32_t glyphsNamedSofar = 1;
- for (glyphid_t j = 0; j < charset->s; j++) {
- cffsid_t first = charset->f1.range1[j].first;
- for (glyphid_t k = 0; k <= charset->f1.range1[j].nleft; k++) {
- cffsid_t sid = first + k;
- sds glyphname = formCIDString(sid);
- if (glyphsNamedSofar < glyphs->length && glyphname) {
- glyphs->items[glyphsNamedSofar]->name = glyphname;
- glyphs->items[glyphsNamedSofar]->cid = sid;
- }
- glyphsNamedSofar++;
- }
- }
- break;
- }
- case cff_CHARSET_FORMAT2: {
- uint32_t glyphsNamedSofar = 1;
- for (glyphid_t j = 0; j < charset->s; j++) {
- cffsid_t first = charset->f2.range2[j].first;
- for (glyphid_t k = 0; k <= charset->f2.range2[j].nleft; k++) {
- cffsid_t sid = first + k;
- sds glyphname = formCIDString(sid);
- if (glyphsNamedSofar < glyphs->length && glyphname) {
- glyphs->items[glyphsNamedSofar]->name = glyphname;
- glyphs->items[glyphsNamedSofar]->cid = sid;
- }
- glyphsNamedSofar++;
- }
- }
- break;
- }
- }
- } else {
- switch (charset->t) {
- case cff_CHARSET_FORMAT0: {
- for (glyphid_t j = 0; j < charset->s; j++) {
- cffsid_t sid = charset->f0.glyph[j];
- sds glyphname = sdsget_cff_sid(sid, cffFile->string);
- if (glyphname) { glyphs->items[j + 1]->name = glyphname; }
- }
- break;
- }
- case cff_CHARSET_FORMAT1: {
- uint32_t glyphsNamedSofar = 1;
- for (glyphid_t j = 0; j < charset->s; j++) {
- glyphid_t first = charset->f1.range1[j].first;
- for (glyphid_t k = 0; k <= charset->f1.range1[j].nleft; k++) {
- cffsid_t sid = first + k;
- sds glyphname = sdsget_cff_sid(sid, cffFile->string);
- if (glyphsNamedSofar < glyphs->length && glyphname) {
- glyphs->items[glyphsNamedSofar]->name = glyphname;
- }
- glyphsNamedSofar++;
- }
- }
- break;
- }
- case cff_CHARSET_FORMAT2: {
- uint32_t glyphsNamedSofar = 1;
- for (glyphid_t j = 0; j < charset->s; j++) {
- glyphid_t first = charset->f2.range2[j].first;
- for (glyphid_t k = 0; k <= charset->f2.range2[j].nleft; k++) {
- cffsid_t sid = first + k;
- sds glyphname = sdsget_cff_sid(sid, cffFile->string);
- if (glyphsNamedSofar < glyphs->length && glyphname) {
- glyphs->items[glyphsNamedSofar]->name = glyphname;
- }
- glyphsNamedSofar++;
- }
- }
- break;
- }
- }
- }
-}
-
-static double qround(const double x) {
- return otfcc_from_fixed(otfcc_to_fixed(x));
-}
-static void applyCffMatrix(table_CFF *CFF_, table_glyf *glyf, const table_head *head) {
- for (glyphid_t jj = 0; jj < glyf->length; jj++) {
- glyf_Glyph *g = glyf->items[jj];
- table_CFF *fd = CFF_;
- if (fd->fdArray && g->fdSelect.index < fd->fdArrayCount) {
- fd = fd->fdArray[g->fdSelect.index];
- }
- if (fd->fontMatrix) {
- scale_t a = qround(head->unitsPerEm * fd->fontMatrix->a);
- scale_t b = qround(head->unitsPerEm * fd->fontMatrix->b);
- scale_t c = qround(head->unitsPerEm * fd->fontMatrix->c);
- scale_t d = qround(head->unitsPerEm * fd->fontMatrix->d);
- VQ x = iVQ.scale(fd->fontMatrix->x, head->unitsPerEm);
- x.kernel = qround(x.kernel);
- VQ y = iVQ.scale(fd->fontMatrix->y, head->unitsPerEm);
- y.kernel = qround(y.kernel);
- for (shapeid_t j = 0; j < g->contours.length; j++) {
- glyf_Contour *contour = &g->contours.items[j];
- for (shapeid_t k = 0; k < contour->length; k++) {
- VQ zx = iVQ.dup(contour->items[k].x);
- VQ zy = iVQ.dup(contour->items[k].y);
- iVQ.replace(&contour->items[k].x, iVQ.pointLinearTfm(x, a, zx, b, zy));
- iVQ.replace(&contour->items[k].y, iVQ.pointLinearTfm(y, c, zx, d, zy));
- iVQ.dispose(&zx), iVQ.dispose(&zy);
- }
- }
- iVQ.dispose(&x), iVQ.dispose(&y);
- }
- }
-}
-
-table_CFFAndGlyf otfcc_readCFFAndGlyfTables(const otfcc_Packet packet, const otfcc_Options *options,
- const table_head *head) {
- table_CFFAndGlyf ret;
- ret.meta = NULL;
- ret.glyphs = NULL;
-
- cff_extract_context context;
- context.fdArrayIndex = -1;
- context.meta = NULL;
- context.glyphs = NULL;
- context.cffFile = NULL;
- FOR_TABLE(OTFCC_CHR('C','F','F',' '), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- cff_File *cffFile = cff_openStream(data, length, options);
- context.cffFile = cffFile;
- context.meta = table_iCFF.create();
-
- // Extract data in TOP DICT
- cff_iDict.parseToCallback(cffFile->top_dict.data,
- cffFile->top_dict.offset[1] - cffFile->top_dict.offset[0],
- &context, callback_extract_fd);
-
- if (!context.meta->fontName) {
- context.meta->fontName = sdsget_cff_sid(391, cffFile->name);
- }
-
- // We have FDArray
- if (cffFile->font_dict.count) {
- context.meta->fdArrayCount = cffFile->font_dict.count;
- NEW(context.meta->fdArray, context.meta->fdArrayCount);
- for (tableid_t j = 0; j < context.meta->fdArrayCount; j++) {
- context.meta->fdArray[j] = table_iCFF.create();
- context.fdArrayIndex = j;
- cff_iDict.parseToCallback(
- cffFile->font_dict.data + cffFile->font_dict.offset[j] - 1,
- cffFile->font_dict.offset[j + 1] - cffFile->font_dict.offset[j], &context,
- callback_extract_fd);
- if (!context.meta->fdArray[j]->fontName) {
- context.meta->fdArray[j]->fontName = sdscatprintf(sdsempty(), "_Subfont%d", j);
- }
- }
- }
- ret.meta = context.meta;
-
- // Extract data of outlines
- context.seed = 0x1234567887654321;
- if (context.meta->privateDict) {
- context.seed =
- (uint64_t)context.meta->privateDict->initialRandomSeed ^ 0x1234567887654321;
- }
- table_glyf *glyphs = table_iGlyf.createN(cffFile->char_strings.count);
- context.glyphs = glyphs;
- for (glyphid_t j = 0; j < glyphs->length; j++) {
- buildOutline(j, &context, options);
- }
-
- applyCffMatrix(context.meta, context.glyphs, head);
-
- // Name glyphs according charset
- nameGlyphsAccordingToCFF(&context);
-
- ret.glyphs = context.glyphs;
- cff_close(cffFile);
- }
- return ret;
-}
-
-static void pdDeltaToJson(json_value *target, const char *field, arity_t count, double *values) {
- if (!count || !values) return;
- json_value *a = json_array_new(count);
- for (arity_t j = 0; j < count; j++) {
- json_array_push(a, json_double_new(values[j]));
- }
- json_object_push(target, field, a);
-}
-
-static json_value *pdToJson(const cff_PrivateDict *pd) {
- json_value *_pd = json_object_new(24);
- pdDeltaToJson(_pd, "blueValues", pd->blueValuesCount, pd->blueValues);
- pdDeltaToJson(_pd, "otherBlues", pd->otherBluesCount, pd->otherBlues);
- pdDeltaToJson(_pd, "familyBlues", pd->familyBluesCount, pd->familyBlues);
- pdDeltaToJson(_pd, "familyOtherBlues", pd->familyOtherBluesCount, pd->familyOtherBlues);
- pdDeltaToJson(_pd, "stemSnapH", pd->stemSnapHCount, pd->stemSnapH);
- pdDeltaToJson(_pd, "stemSnapV", pd->stemSnapVCount, pd->stemSnapV);
- if (pd->blueScale != DEFAULT_BLUE_SCALE)
- json_object_push(_pd, "blueScale", json_double_new(pd->blueScale));
- if (pd->blueShift != DEFAULT_BLUE_SHIFT)
- json_object_push(_pd, "blueShift", json_double_new(pd->blueShift));
- if (pd->blueFuzz != DEFAULT_BLUE_FUZZ)
- json_object_push(_pd, "blueFuzz", json_double_new(pd->blueFuzz));
- if (pd->stdHW) json_object_push(_pd, "stdHW", json_double_new(pd->stdHW));
- if (pd->stdVW) json_object_push(_pd, "stdVW", json_double_new(pd->stdVW));
- if (pd->forceBold) json_object_push(_pd, "forceBold", json_boolean_new(pd->forceBold));
- if (pd->languageGroup)
- json_object_push(_pd, "languageGroup", json_double_new(pd->languageGroup));
- if (pd->expansionFactor != DEFAULT_EXPANSION_FACTOR)
- json_object_push(_pd, "expansionFactor", json_double_new(pd->expansionFactor));
- if (pd->initialRandomSeed)
- json_object_push(_pd, "initialRandomSeed", json_double_new(pd->initialRandomSeed));
- if (pd->defaultWidthX)
- json_object_push(_pd, "defaultWidthX", json_double_new(pd->defaultWidthX));
- if (pd->nominalWidthX)
- json_object_push(_pd, "nominalWidthX", json_double_new(pd->nominalWidthX));
- return _pd;
-}
-static json_value *fdToJson(const table_CFF *table) {
- json_value *_CFF_ = json_object_new(24);
-
- if (table->isCID) json_object_push(_CFF_, "isCID", json_boolean_new(table->isCID));
-
- if (table->version) json_object_push(_CFF_, "version", json_from_sds(table->version));
- if (table->notice) json_object_push(_CFF_, "notice", json_from_sds(table->notice));
- if (table->copyright) json_object_push(_CFF_, "copyright", json_from_sds(table->copyright));
- if (table->fontName) json_object_push(_CFF_, "fontName", json_from_sds(table->fontName));
- if (table->fullName) json_object_push(_CFF_, "fullName", json_from_sds(table->fullName));
- if (table->familyName) json_object_push(_CFF_, "familyName", json_from_sds(table->familyName));
- if (table->weight) json_object_push(_CFF_, "weight", json_from_sds(table->weight));
-
- if (table->isFixedPitch)
- json_object_push(_CFF_, "isFixedPitch", json_boolean_new(table->isFixedPitch));
- if (table->italicAngle)
- json_object_push(_CFF_, "italicAngle", json_double_new(table->italicAngle));
- if (table->underlinePosition != -100)
- json_object_push(_CFF_, "underlinePosition", json_double_new(table->underlinePosition));
- if (table->underlineThickness != 50)
- json_object_push(_CFF_, "underlineThickness", json_double_new(table->underlineThickness));
- if (table->strokeWidth)
- json_object_push(_CFF_, "strokeWidth", json_double_new(table->strokeWidth));
- if (table->fontBBoxLeft)
- json_object_push(_CFF_, "fontBBoxLeft", json_double_new(table->fontBBoxLeft));
- if (table->fontBBoxBottom)
- json_object_push(_CFF_, "fontBBoxBottom", json_double_new(table->fontBBoxBottom));
- if (table->fontBBoxRight)
- json_object_push(_CFF_, "fontBBoxRight", json_double_new(table->fontBBoxRight));
- if (table->fontBBoxTop)
- json_object_push(_CFF_, "fontBBoxTop", json_double_new(table->fontBBoxTop));
-
- if (table->fontMatrix) {
- json_value *_fontMatrix = json_object_new(6);
- json_object_push(_fontMatrix, "a", json_double_new(table->fontMatrix->a));
- json_object_push(_fontMatrix, "b", json_double_new(table->fontMatrix->b));
- json_object_push(_fontMatrix, "c", json_double_new(table->fontMatrix->c));
- json_object_push(_fontMatrix, "d", json_double_new(table->fontMatrix->d));
- json_object_push(_fontMatrix, "x", json_new_VQ(table->fontMatrix->x, NULL));
- json_object_push(_fontMatrix, "y", json_new_VQ(table->fontMatrix->y, NULL));
- json_object_push(_CFF_, "fontMatrix", _fontMatrix);
- }
- if (table->privateDict) { json_object_push(_CFF_, "privates", pdToJson(table->privateDict)); }
-
- if (table->cidRegistry && table->cidOrdering) {
- json_object_push(_CFF_, "cidRegistry", json_from_sds(table->cidRegistry));
- json_object_push(_CFF_, "cidOrdering", json_from_sds(table->cidOrdering));
- json_object_push(_CFF_, "cidSupplement", json_integer_new(table->cidSupplement));
- }
- if (table->fdArray) {
- json_value *_fdArray = json_object_new(table->fdArrayCount);
- for (tableid_t j = 0; j < table->fdArrayCount; j++) {
- sds name = table->fdArray[j]->fontName;
- table->fdArray[j]->fontName = NULL;
- json_object_push(_fdArray, name, fdToJson(table->fdArray[j]));
- table->fdArray[j]->fontName = name;
- }
- json_object_push(_CFF_, "fdArray", _fdArray);
- }
- return _CFF_;
-}
-
-void otfcc_dumpCFF(const table_CFF *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("CFF") {
- json_object_push(root, "CFF_", fdToJson(table));
- }
-}
-
-static void pdDeltaFromJson(json_value *dump, arity_t *count, double **array) {
- if (!dump || dump->type != json_array) return;
- *count = dump->u.array.length;
- NEW(*array, *count);
- for (arity_t j = 0; j < *count; j++) {
- (*array)[j] = json_numof(dump->u.array.values[j]);
- }
-}
-static cff_PrivateDict *pdFromJson(json_value *dump) {
- if (!dump || dump->type != json_object) return NULL;
- cff_PrivateDict *pd = otfcc_newCff_private();
- pdDeltaFromJson(json_obj_get(dump, "blueValues"), &(pd->blueValuesCount), &(pd->blueValues));
- pdDeltaFromJson(json_obj_get(dump, "otherBlues"), &(pd->otherBluesCount), &(pd->otherBlues));
- pdDeltaFromJson(json_obj_get(dump, "familyBlues"), &(pd->familyBluesCount), &(pd->familyBlues));
- pdDeltaFromJson(json_obj_get(dump, "familyOtherBlues"), &(pd->familyOtherBluesCount),
- &(pd->familyOtherBlues));
- pdDeltaFromJson(json_obj_get(dump, "stemSnapH"), &(pd->stemSnapHCount), &(pd->stemSnapH));
- pdDeltaFromJson(json_obj_get(dump, "stemSnapV"), &(pd->stemSnapVCount), &(pd->stemSnapV));
-
- pd->blueScale = json_obj_getnum_fallback(dump, "blueScale", DEFAULT_BLUE_SCALE);
- pd->blueShift = json_obj_getnum_fallback(dump, "blueShift", DEFAULT_BLUE_SHIFT);
- pd->blueFuzz = json_obj_getnum_fallback(dump, "blueFuzz", DEFAULT_BLUE_FUZZ);
- pd->stdHW = json_obj_getnum(dump, "stdHW");
- pd->stdVW = json_obj_getnum(dump, "stdVW");
- pd->forceBold = json_obj_getbool(dump, "forceBold");
- pd->languageGroup = json_obj_getnum(dump, "languageGroup");
- pd->expansionFactor =
- json_obj_getnum_fallback(dump, "expansionFactor", DEFAULT_EXPANSION_FACTOR);
- pd->initialRandomSeed = json_obj_getnum(dump, "initialRandomSeed");
- // Not used -- they will be automatically calculated
- // pd->defaultWidthX = json_obj_getnum(dump, "defaultWidthX");
- // pd->nominalWidthX = json_obj_getnum(dump, "nominalWidthX");
-
- return pd;
-}
-static table_CFF *fdFromJson(const json_value *dump, const otfcc_Options *options, bool topLevel) {
- table_CFF *table = table_iCFF.create();
- if (!dump || dump->type != json_object) return table;
- // Names
- table->version = json_obj_getsds(dump, "version");
- table->notice = json_obj_getsds(dump, "notice");
- table->copyright = json_obj_getsds(dump, "copyright");
- table->fontName = json_obj_getsds(dump, "fontName");
- table->fullName = json_obj_getsds(dump, "fullName");
- table->familyName = json_obj_getsds(dump, "familyName");
- table->weight = json_obj_getsds(dump, "weight");
-
- // Metrics
- table->isFixedPitch = json_obj_getbool(dump, "isFixedPitch");
- table->italicAngle = json_obj_getnum(dump, "italicAngle");
- table->underlinePosition = json_obj_getnum_fallback(dump, "underlinePosition", -100.0);
- table->underlineThickness = json_obj_getnum_fallback(dump, "underlineThickness", 50.0);
- table->strokeWidth = json_obj_getnum(dump, "strokeWidth");
- table->fontBBoxLeft = json_obj_getnum(dump, "fontBBoxLeft");
- table->fontBBoxBottom = json_obj_getnum(dump, "fontBBoxBottom");
- table->fontBBoxRight = json_obj_getnum(dump, "fontBBoxRight");
- table->fontBBoxTop = json_obj_getnum(dump, "fontBBoxTop");
-
- // fontMatrix
- // Need?
- /*
- json_value *fmatdump = json_obj_get_type(dump, "fontMatrix", json_object);
- if (fmatdump) {
- NEW(table->fontMatrix);
- table->fontMatrix->a = json_obj_getnum(fmatdump, "a");
- table->fontMatrix->b = json_obj_getnum(fmatdump, "b");
- table->fontMatrix->c = json_obj_getnum(fmatdump, "c");
- table->fontMatrix->d = json_obj_getnum(fmatdump, "d");
- table->fontMatrix->x = json_obj_getnum(fmatdump, "x");
- table->fontMatrix->y = json_obj_getnum(fmatdump, "y");
- }
- */
-
- // privates
- table->privateDict = pdFromJson(json_obj_get_type(dump, "privates", json_object));
-
- // CID
- table->cidRegistry = json_obj_getsds(dump, "cidRegistry");
- table->cidOrdering = json_obj_getsds(dump, "cidOrdering");
- table->cidSupplement = json_obj_getint(dump, "cidSupplement");
- table->UIDBase = json_obj_getint(dump, "UIDBase");
- table->cidCount = json_obj_getint(dump, "cidCount");
- table->cidFontVersion = json_obj_getnum(dump, "cidFontVersion");
- table->cidFontRevision = json_obj_getnum(dump, "cidFontRevision");
-
- // fdArray
- json_value *fdarraydump = json_obj_get_type(dump, "fdArray", json_object);
- if (fdarraydump) {
- table->isCID = true;
- table->fdArrayCount = fdarraydump->u.object.length;
- NEW(table->fdArray, table->fdArrayCount);
- for (tableid_t j = 0; j < table->fdArrayCount; j++) {
- table->fdArray[j] = fdFromJson(fdarraydump->u.object.values[j].value, options, false);
- if (table->fdArray[j]->fontName) { sdsfree(table->fdArray[j]->fontName); }
- table->fdArray[j]->fontName = sdsnewlen(fdarraydump->u.object.values[j].name,
- fdarraydump->u.object.values[j].name_length);
- }
- }
- if (!table->fontName) table->fontName = sdsnew("CARYLL_CFFFONT");
- if (!table->privateDict) table->privateDict = otfcc_newCff_private();
- // Deal with force-cid
- if (topLevel && options->force_cid && !table->fdArray) {
- table->fdArrayCount = 1;
- NEW(table->fdArray, table->fdArrayCount);
- table->fdArray[0] = table_iCFF.create();
- table_CFF *fd0 = table->fdArray[0];
- fd0->privateDict = table->privateDict;
- table->privateDict = otfcc_newCff_private();
- fd0->fontName = sdscat(sdsdup(table->fontName), "-subfont0");
- table->isCID = true;
- }
- if (table->isCID && !table->cidRegistry) { table->cidRegistry = sdsnew("CARYLL"); }
- if (table->isCID && !table->cidOrdering) { table->cidOrdering = sdsnew("OTFCCAUTOCID"); }
- return table;
-}
-table_CFF *otfcc_parseCFF(const json_value *root, const otfcc_Options *options) {
- json_value *dump = json_obj_get_type(root, "CFF_", json_object);
- if (!dump) {
- return NULL;
- } else {
- table_CFF *cff = NULL;
- loggedStep("CFF") {
- cff = fdFromJson(dump, options, true);
- }
- return cff;
- }
-}
-
-typedef struct {
- table_glyf *glyf;
- uint16_t defaultWidth;
- uint16_t nominalWidthX;
- const otfcc_Options *options;
- cff_SubrGraph graph;
-} cff_charstring_builder_context;
-typedef struct {
- caryll_Buffer *charStrings;
- caryll_Buffer *subroutines;
-} cff_charStringAndSubrs;
-
-static void cff_make_charstrings(cff_charstring_builder_context *context, caryll_Buffer **s,
- caryll_Buffer **gs, caryll_Buffer **ls) {
- if (context->glyf->length == 0) { return; }
- for (glyphid_t j = 0; j < context->glyf->length; j++) {
- cff_CharstringIL *il = cff_compileGlyphToIL(context->glyf->items[j], context->defaultWidth,
- context->nominalWidthX);
- cff_optimizeIL(il, context->options);
- cff_insertILToGraph(&context->graph, il);
- FREE(il->instr);
- FREE(il);
- }
- cff_ilGraphToBuffers(&context->graph, s, gs, ls, context->options);
-}
-
-// String table management
-typedef struct {
- int sid;
- char *str;
- UT_hash_handle hh;
-} cff_sid_entry;
-
-static int sidof(cff_sid_entry **h, sds s) {
- cff_sid_entry *item = NULL;
- HASH_FIND_STR(*h, s, item);
- if (item) {
- return 391 + item->sid;
- } else {
- NEW(item);
- item->sid = HASH_COUNT(*h);
- item->str = sdsdup(s);
- HASH_ADD_STR(*h, str, item);
- return 391 + item->sid;
- }
-}
-
-static cff_DictEntry *cffdict_givemeablank(cff_Dict *dict) {
- dict->count++;
- RESIZE(dict->ents, dict->count);
- return &(dict->ents[dict->count - 1]);
-}
-static void cffdict_input(cff_Dict *dict, uint32_t op, cff_Value_Type t, arity_t arity, ...) {
- cff_DictEntry *last = cffdict_givemeablank(dict);
- last->op = op;
- last->cnt = arity;
- NEW(last->vals, arity);
-
- va_list ap;
- va_start(ap, arity);
- for (arity_t j = 0; j < arity; j++) {
- if (t == cff_DOUBLE) {
- double x = va_arg(ap, double);
- if (x == round(x)) {
- last->vals[j].t = cff_INTEGER;
- last->vals[j].i = round(x);
- } else {
- last->vals[j].t = cff_DOUBLE;
- last->vals[j].d = x;
- }
- } else {
- int x = va_arg(ap, int);
- last->vals[j].t = t;
- last->vals[j].i = x;
- }
- }
- va_end(ap);
-}
-static void cffdict_input_array(cff_Dict *dict, uint32_t op, cff_Value_Type t, arity_t arity,
- double *arr) {
- if (!arity || !arr) return;
- cff_DictEntry *last = cffdict_givemeablank(dict);
- last->op = op;
- last->cnt = arity;
- NEW(last->vals, arity);
- for (arity_t j = 0; j < arity; j++) {
- double x = arr[j];
- if (t == cff_DOUBLE) {
- if (x == round(x)) {
- last->vals[j].t = cff_INTEGER;
- last->vals[j].i = round(x);
- } else {
- last->vals[j].t = cff_DOUBLE;
- last->vals[j].d = x;
- }
- } else {
- last->vals[j].t = t;
- last->vals[j].i = round(x);
- }
- }
-}
-
-static cff_Dict *cff_make_fd_dict(table_CFF *fd, cff_sid_entry **h) {
- cff_Dict *dict = cff_iDict.create();
- // ROS
- if (fd->cidRegistry && fd->cidOrdering) {
- cffdict_input(dict, op_ROS, cff_INTEGER, 3, sidof(h, fd->cidRegistry),
- sidof(h, fd->cidOrdering), fd->cidSupplement);
- }
-
- // CFF Names
- if (fd->version) cffdict_input(dict, op_version, cff_INTEGER, 1, sidof(h, fd->version));
- if (fd->notice) cffdict_input(dict, op_Notice, cff_INTEGER, 1, sidof(h, fd->notice));
- if (fd->copyright) cffdict_input(dict, op_Copyright, cff_INTEGER, 1, sidof(h, fd->copyright));
- if (fd->fullName) cffdict_input(dict, op_FullName, cff_INTEGER, 1, sidof(h, fd->fullName));
- if (fd->familyName)
- cffdict_input(dict, op_FamilyName, cff_INTEGER, 1, sidof(h, fd->familyName));
- if (fd->weight) cffdict_input(dict, op_Weight, cff_INTEGER, 1, sidof(h, fd->weight));
-
- // CFF Metrics
- cffdict_input(dict, op_FontBBox, cff_DOUBLE, 4, fd->fontBBoxLeft, fd->fontBBoxBottom,
- fd->fontBBoxRight, fd->fontBBoxTop);
- cffdict_input(dict, op_isFixedPitch, cff_INTEGER, 1, (int)fd->isFixedPitch);
- cffdict_input(dict, op_ItalicAngle, cff_DOUBLE, 1, fd->italicAngle);
- cffdict_input(dict, op_UnderlinePosition, cff_DOUBLE, 1, fd->underlinePosition);
- cffdict_input(dict, op_UnderlineThickness, cff_DOUBLE, 1, fd->underlineThickness);
- cffdict_input(dict, op_StrokeWidth, cff_DOUBLE, 1, fd->strokeWidth);
- if (fd->fontMatrix) {
- cffdict_input(dict, op_FontMatrix, cff_DOUBLE, 6,
- fd->fontMatrix->a, fd->fontMatrix->b,
- fd->fontMatrix->c, fd->fontMatrix->d,
- iVQ.getStill(fd->fontMatrix->x), iVQ.getStill(fd->fontMatrix->y));
- }
-
- // CID specific
- if (fd->fontName) cffdict_input(dict, op_FontName, cff_INTEGER, 1, sidof(h, fd->fontName));
- if (fd->cidFontVersion)
- cffdict_input(dict, op_CIDFontVersion, cff_DOUBLE, 1, fd->cidFontVersion);
- if (fd->cidFontRevision)
- cffdict_input(dict, op_CIDFontRevision, cff_DOUBLE, 1, fd->cidFontRevision);
- if (fd->cidCount) cffdict_input(dict, op_CIDCount, cff_INTEGER, 1, fd->cidCount);
- if (fd->UIDBase) cffdict_input(dict, op_UIDBase, cff_INTEGER, 1, fd->UIDBase);
- return dict;
-}
-
-static cff_Dict *cff_make_private_dict(cff_PrivateDict *pd) {
- cff_Dict *dict;
- NEW(dict);
- if (!pd) return dict;
- // DELTA arrays
- cffdict_input_array(dict, op_BlueValues, cff_DOUBLE, pd->blueValuesCount, pd->blueValues);
- cffdict_input_array(dict, op_OtherBlues, cff_DOUBLE, pd->otherBluesCount, pd->otherBlues);
- cffdict_input_array(dict, op_FamilyBlues, cff_DOUBLE, pd->familyBluesCount, pd->familyBlues);
- cffdict_input_array(dict, op_FamilyOtherBlues, cff_DOUBLE, pd->familyOtherBluesCount,
- pd->familyOtherBlues);
- cffdict_input_array(dict, op_StemSnapH, cff_DOUBLE, pd->stemSnapHCount, pd->stemSnapH);
- cffdict_input_array(dict, op_StemSnapV, cff_DOUBLE, pd->stemSnapVCount, pd->stemSnapV);
-
- // Private scalars
- cffdict_input(dict, op_BlueScale, cff_DOUBLE, 1, pd->blueScale);
- cffdict_input(dict, op_BlueShift, cff_DOUBLE, 1, pd->blueShift);
- cffdict_input(dict, op_BlueFuzz, cff_DOUBLE, 1, pd->blueFuzz);
- cffdict_input(dict, op_StdHW, cff_DOUBLE, 1, pd->stdHW);
- cffdict_input(dict, op_StdVW, cff_DOUBLE, 1, pd->stdVW);
- cffdict_input(dict, op_ForceBold, cff_INTEGER, 1, (int)pd->forceBold);
- cffdict_input(dict, op_LanguageGroup, cff_INTEGER, 1, pd->languageGroup);
- cffdict_input(dict, op_ExpansionFactor, cff_DOUBLE, 1, pd->expansionFactor);
- cffdict_input(dict, op_initialRandomSeed, cff_DOUBLE, 1, pd->initialRandomSeed);
-
- // op_nominalWidthX are currently not used
- cffdict_input(dict, op_defaultWidthX, cff_DOUBLE, 1, pd->defaultWidthX);
- cffdict_input(dict, op_nominalWidthX, cff_DOUBLE, 1, pd->nominalWidthX);
-
- return dict;
-}
-
-static int by_sid(cff_sid_entry *a, cff_sid_entry *b) {
- return a->sid - b->sid;
-}
-static caryll_Buffer *callback_makestringindex(void *context, uint32_t i) {
- caryll_Buffer **blobs = context;
- return blobs[i];
-}
-static caryll_Buffer *cffstrings_to_indexblob(cff_sid_entry **h) {
- HASH_SORT(*h, by_sid);
- caryll_Buffer **blobs;
- uint32_t n = HASH_COUNT(*h);
- NEW(blobs, n);
- uint32_t j = 0;
- cff_sid_entry *item, *tmp;
- HASH_ITER(hh, *h, item, tmp) {
- blobs[j] = bufnew();
- bufwrite_sds(blobs[j], item->str);
- HASH_DEL(*h, item);
- sdsfree(item->str);
- FREE(item);
- j++;
- }
-
- cff_Index *strings = cff_iIndex.fromCallback(blobs, n, callback_makestringindex);
- FREE(blobs);
- caryll_Buffer *final_blob = cff_iIndex.build(strings);
- cff_iIndex.free(strings);
- final_blob->cursor = final_blob->size;
- return final_blob;
-}
-
-static caryll_Buffer *cff_compile_nameindex(table_CFF *cff) {
- cff_Index *nameIndex = cff_iIndex.create();
- nameIndex->count = 1;
- nameIndex->offSize = 4;
- NEW(nameIndex->offset, 2);
- if (!cff->fontName) { cff->fontName = sdsnew("Caryll-CFF-FONT"); }
- nameIndex->offset[0] = 1;
- nameIndex->offset[1] = (uint32_t)(sdslen(cff->fontName) + 1);
- NEW(nameIndex->data, 1 + sdslen(cff->fontName));
- memcpy(nameIndex->data, cff->fontName, sdslen(cff->fontName));
- // CFF Name INDEX
- caryll_Buffer *buf = cff_iIndex.build(nameIndex);
- cff_iIndex.free(nameIndex);
- if (cff->fontName) {
- sdsfree(cff->fontName);
- cff->fontName = NULL;
- }
- return buf;
-}
-
-static caryll_Buffer *cff_make_charset(table_CFF *cff, table_glyf *glyf,
- cff_sid_entry **stringHash) {
- cff_Charset *charset;
- NEW(charset);
- if (glyf->length > 1) { // At least two glyphs
- charset->t = cff_CHARSET_FORMAT2;
- charset->s = 1; // One segment only
- charset->f2.format = 2;
- NEW(charset->f2.range2);
- if (cff->isCID) {
- charset->f2.range2[0].first = 1;
- charset->f2.range2[0].nleft = glyf->length - 2;
- } else {
- for (glyphid_t j = 1; j < glyf->length; j++) {
- sidof(stringHash, glyf->items[j]->name);
- }
- charset->f2.range2[0].first = sidof(stringHash, glyf->items[1]->name);
- charset->f2.range2[0].nleft = glyf->length - 2;
- }
- } else {
- charset->t = cff_CHARSET_ISOADOBE;
- }
- caryll_Buffer *c = cff_build_Charset(*charset);
- if (charset->t == cff_CHARSET_FORMAT2) { FREE(charset->f2.range2); }
- FREE(charset);
- return c;
-}
-
-static caryll_Buffer *cff_make_fdselect(table_CFF *cff, table_glyf *glyf) {
- if (!cff->isCID) return bufnew();
- // We choose format 3 here
- uint32_t ranges = 1;
- uint8_t current = 0;
- cff_FDSelect *fds;
- NEW(fds);
- fds->t = cff_FDSELECT_UNSPECED;
- if (!glyf->length) goto done;
- uint8_t fdi0 = glyf->items[0]->fdSelect.index;
- if (fdi0 > cff->fdArrayCount) fdi0 = 0;
- current = fdi0;
- for (glyphid_t j = 1; j < glyf->length; j++) {
- uint8_t fdi = glyf->items[j]->fdSelect.index;
- if (fdi > cff->fdArrayCount) fdi = 0;
- if (fdi != current) {
- current = fdi;
- ranges++;
- }
- }
- NEW(fds->f3.range3, ranges);
- fds->f3.range3[0].first = 0;
- fds->f3.range3[0].fd = current = fdi0;
- for (glyphid_t j = 1; j < glyf->length; j++) {
- uint8_t fdi = glyf->items[j]->fdSelect.index;
- if (fdi > cff->fdArrayCount) fdi = 0;
- if (glyf->items[j]->fdSelect.index != current) {
- current = fdi;
- fds->s++;
- fds->f3.range3[fds->s].first = j;
- fds->f3.range3[fds->s].fd = current;
- }
- }
- fds->t = cff_FDSELECT_FORMAT3;
- fds->s = ranges;
- fds->f3.format = 3;
- fds->f3.nranges = ranges;
- fds->f3.sentinel = glyf->length;
-done:;
- caryll_Buffer *e = cff_build_FDSelect(*fds);
- cff_close_FDSelect(*fds);
- FREE(fds);
- return e;
-}
-
-typedef struct {
- table_CFF **fdArray;
- cff_sid_entry **stringHash;
-} fdarray_compile_context;
-static caryll_Buffer *callback_makefd(void *_context, uint32_t i) {
- fdarray_compile_context *context = (fdarray_compile_context *)_context;
- cff_Dict *fd = cff_make_fd_dict(context->fdArray[i], context->stringHash);
- caryll_Buffer *blob = cff_iDict.build(fd);
- bufwrite_bufdel(blob, cff_buildOffset(0xEEEEEEEE));
- bufwrite_bufdel(blob, cff_buildOffset(0xFFFFFFFF));
- bufwrite_bufdel(blob, cff_encodeCffOperator(op_Private));
- cff_iDict.build(fd);
- return blob;
-}
-static cff_Index *cff_make_fdarray(tableid_t fdArrayCount, table_CFF **fdArray,
- cff_sid_entry **stringHash) {
- fdarray_compile_context context;
- context.fdArray = fdArray;
- context.stringHash = stringHash;
-
- return cff_iIndex.fromCallback(&context, fdArrayCount, callback_makefd);
-}
-
-static caryll_Buffer *writecff_CIDKeyed(table_CFF *cff, table_glyf *glyf,
- const otfcc_Options *options) {
- caryll_Buffer *blob = bufnew();
- // The Strings hashtable
- cff_sid_entry *stringHash = NULL;
-
- // CFF Header
- caryll_Buffer *h = cff_buildHeader();
- caryll_Buffer *n = cff_compile_nameindex(cff);
-
- // cff top DICT
- cff_Dict *top = cff_make_fd_dict(cff, &stringHash);
- caryll_Buffer *t = cff_iDict.build(top);
- cff_iDict.free(top);
-
- // cff top PRIVATE
- cff_Dict *top_pd = cff_make_private_dict(cff->privateDict);
- caryll_Buffer *p = cff_iDict.build(top_pd);
- bufwrite_bufdel(p, cff_buildOffset(0xFFFFFFFF));
- bufwrite_bufdel(p, cff_encodeCffOperator(op_Subrs));
- cff_iDict.free(top_pd);
-
- // FDSelect
- caryll_Buffer *e = cff_make_fdselect(cff, glyf);
-
- // FDArray
- cff_Index *fdArrayIndex = NULL;
- caryll_Buffer *r;
- if (cff->isCID) {
- fdArrayIndex = cff_make_fdarray(cff->fdArrayCount, cff->fdArray, &stringHash);
- r = cff_iIndex.build(fdArrayIndex);
- } else {
- NEW(r);
- }
-
- // cff charset : Allocate string index terms for glyph names
- caryll_Buffer *c = cff_make_charset(cff, glyf, &stringHash);
-
- // CFF String Index
- caryll_Buffer *i = cffstrings_to_indexblob(&stringHash);
-
- // CFF Charstrings
- caryll_Buffer *s;
- caryll_Buffer *gs;
- caryll_Buffer *ls;
- {
- cff_charstring_builder_context g2cContext;
- g2cContext.glyf = glyf;
- g2cContext.defaultWidth = cff->privateDict->defaultWidthX;
- g2cContext.nominalWidthX = cff->privateDict->nominalWidthX;
- g2cContext.options = options;
- cff_iSubrGraph.init(&g2cContext.graph);
- g2cContext.graph.doSubroutinize = options->cff_doSubroutinize;
-
- cff_make_charstrings(&g2cContext, &s, &gs, &ls);
-
- cff_iSubrGraph.dispose(&g2cContext.graph);
- }
-
- // Merge these data
- uint32_t additionalTopDictOpsSize = 0;
- uint32_t off = (uint32_t)(h->size + n->size + 11 + t->size);
- if (c->size != 0) additionalTopDictOpsSize += 6; // op_charset
- if (e->size != 0) additionalTopDictOpsSize += 7; // op_FDSelect
- if (s->size != 0) additionalTopDictOpsSize += 6; // op_CharStrings
- if (p->size != 0) additionalTopDictOpsSize += 11; // op_Private
- if (r->size != 0) additionalTopDictOpsSize += 7; // op_FDArray
-
- // Start building CFF table
- bufwrite_bufdel(blob, h); // header
- bufwrite_bufdel(blob, n); // name index
- int32_t delta_size = (uint32_t)(t->size + additionalTopDictOpsSize + 1);
- bufwrite_bufdel(blob, bufninit(11, 0, 1, // top dict index headerone item
- 4, // four bytes per offset
- 0, 0, 0, 1, // offset 1
- (delta_size >> 24) & 0xff, (delta_size >> 16) & 0xff,
- (delta_size >> 8) & 0xff,
- delta_size & 0xff) // offset 2
- );
-
- bufwrite_bufdel(blob, t); // top dict body
-
- // top dict offsets
- off += additionalTopDictOpsSize + i->size + gs->size;
- if (c->size != 0) {
- bufwrite_bufdel(blob, cff_buildOffset(off));
- bufwrite_bufdel(blob, cff_encodeCffOperator(op_charset));
- off += c->size;
- }
- if (e->size != 0) {
- bufwrite_bufdel(blob, cff_buildOffset(off));
- bufwrite_bufdel(blob, cff_encodeCffOperator(op_FDSelect));
- off += e->size;
- }
- if (s->size != 0) {
- bufwrite_bufdel(blob, cff_buildOffset(off));
- bufwrite_bufdel(blob, cff_encodeCffOperator(op_CharStrings));
- off += s->size;
- }
- if (p->size != 0) {
- bufwrite_bufdel(blob, cff_buildOffset((uint32_t)(p->size)));
- bufwrite_bufdel(blob, cff_buildOffset(off));
- bufwrite_bufdel(blob, cff_encodeCffOperator(op_Private));
- off += p->size;
- }
- if (r->size != 0) {
- bufwrite_bufdel(blob, cff_buildOffset(off));
- bufwrite_bufdel(blob, cff_encodeCffOperator(op_FDArray));
- off += r->size;
- }
-
- bufwrite_bufdel(blob, i); // string index
- bufwrite_bufdel(blob, gs); // gsubr
- bufwrite_bufdel(blob, c); // charset
- bufwrite_bufdel(blob, e); // fdselect
- bufwrite_bufdel(blob, s); // charstring
- size_t *startingPositionOfPrivates;
- NEW(startingPositionOfPrivates, 1 + cff->fdArrayCount);
- startingPositionOfPrivates[0] = blob->cursor;
- bufwrite_bufdel(blob, p); // top private
- size_t *endingPositionOfPrivates;
- NEW(endingPositionOfPrivates, 1 + cff->fdArrayCount);
- endingPositionOfPrivates[0] = blob->cursor;
- if (cff->isCID) { // fdarray and fdarray privates
- uint32_t fdArrayPrivatesStartOffset = off;
- caryll_Buffer **fdArrayPrivates;
- NEW(fdArrayPrivates, cff->fdArrayCount);
- for (tableid_t j = 0; j < cff->fdArrayCount; j++) {
- cff_Dict *pd = cff_make_private_dict(cff->fdArray[j]->privateDict);
- caryll_Buffer *p = cff_iDict.build(pd);
- bufwrite_bufdel(p, cff_buildOffset(0xFFFFFFFF));
- bufwrite_bufdel(p, cff_encodeCffOperator(op_Subrs));
- cff_iDict.free(pd);
- fdArrayPrivates[j] = p;
- uint8_t *privateLengthPtr = &(fdArrayIndex->data[fdArrayIndex->offset[j + 1] - 11]);
- privateLengthPtr[0] = (p->size >> 24) & 0xFF;
- privateLengthPtr[1] = (p->size >> 16) & 0xFF;
- privateLengthPtr[2] = (p->size >> 8) & 0xFF;
- privateLengthPtr[3] = (p->size >> 0) & 0xFF;
- uint8_t *privateOffsetPtr = &(fdArrayIndex->data[fdArrayIndex->offset[j + 1] - 6]);
- privateOffsetPtr[0] = (fdArrayPrivatesStartOffset >> 24) & 0xFF;
- privateOffsetPtr[1] = (fdArrayPrivatesStartOffset >> 16) & 0xFF;
- privateOffsetPtr[2] = (fdArrayPrivatesStartOffset >> 8) & 0xFF;
- privateOffsetPtr[3] = (fdArrayPrivatesStartOffset >> 0) & 0xFF;
- fdArrayPrivatesStartOffset += p->size;
- }
- buffree(r); // fdarray
- r = cff_iIndex.build(fdArrayIndex);
- cff_iIndex.free(fdArrayIndex);
- bufwrite_bufdel(blob, r);
- for (tableid_t j = 0; j < cff->fdArrayCount; j++) {
- startingPositionOfPrivates[j + 1] = blob->cursor;
- bufwrite_bufdel(blob, fdArrayPrivates[j]);
- endingPositionOfPrivates[j + 1] = blob->cursor;
- }
- FREE(fdArrayPrivates);
- } else {
- bufwrite_bufdel(blob, r);
- }
- size_t positionOfLocalSubroutines = blob->cursor;
- bufwrite_bufdel(blob, ls);
- for (tableid_t j = 0; j < cff->fdArrayCount + 1; j++) {
- size_t lsOffset = positionOfLocalSubroutines - startingPositionOfPrivates[j];
- uint8_t *ptr = &(blob->data[endingPositionOfPrivates[j] - 5]);
- ptr[0] = (lsOffset >> 24) & 0xFF;
- ptr[1] = (lsOffset >> 16) & 0xFF;
- ptr[2] = (lsOffset >> 8) & 0xFF;
- ptr[3] = (lsOffset >> 0) & 0xFF;
- }
- FREE(startingPositionOfPrivates);
- FREE(endingPositionOfPrivates);
- // finish
- return blob;
-}
-
-caryll_Buffer *otfcc_buildCFF(const table_CFFAndGlyf cffAndGlyf, const otfcc_Options *options) {
- return writecff_CIDKeyed(cffAndGlyf.meta, cffAndGlyf.glyphs, options);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.h
deleted file mode 100644
index bfcb92bb6d5..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CFF.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_CFF_H
-#define CARYLL_TABLE_CFF_H
-
-#include "otfcc/table/CFF.h"
-#include "glyf.h"
-
-table_CFFAndGlyf otfcc_readCFFAndGlyfTables(const otfcc_Packet packet, const otfcc_Options *options,
- const table_head *head);
-void otfcc_dumpCFF(const table_CFF *table, MODIFY json_value *root, const otfcc_Options *options);
-table_CFF *otfcc_parseCFF(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildCFF(const table_CFFAndGlyf cffAndGlyf, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.c
deleted file mode 100644
index 6f82b5296b3..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.c
+++ /dev/null
@@ -1,184 +0,0 @@
-#include "COLR.h"
-
-#include "support/util.h"
-#include "bk/bkgraph.h"
-
-
-static INLINE void initLayer(colr_Layer *layer) {
- Handle.init(&layer->glyph);
-}
-static INLINE void copyLayer(colr_Layer *dst, const colr_Layer *src) {
- Handle.copy(&dst->glyph, &src->glyph);
- dst->paletteIndex = src->paletteIndex;
-}
-static INLINE void disposeLayer(colr_Layer *layer) {
- Handle.dispose(&layer->glyph);
-}
-caryll_standardType(colr_Layer, colr_iLayer, initLayer, copyLayer, disposeLayer);
-caryll_standardVectorImpl(colr_LayerList, colr_Layer, colr_iLayer, colr_iLayerList);
-
-static INLINE void initMapping(colr_Mapping *mapping) {
- Handle.init(&mapping->glyph);
- colr_iLayerList.init(&mapping->layers);
-}
-static INLINE void copyMapping(colr_Mapping *dst, const colr_Mapping *src) {
- Handle.copy(&dst->glyph, &src->glyph);
- colr_iLayerList.copy(&dst->layers, &src->layers);
-}
-static INLINE void disposeMapping(colr_Mapping *mapping) {
- Handle.dispose(&mapping->glyph);
- colr_iLayerList.dispose(&mapping->layers);
-}
-caryll_standardType(colr_Mapping, colr_iMapping, initMapping, copyMapping, disposeMapping);
-caryll_standardVectorImpl(table_COLR, colr_Mapping, colr_iMapping, table_iCOLR);
-
-static const size_t baseGlyphRecLength = 6;
-static const size_t layerRecLength = 4;
-
-table_COLR *otfcc_readCOLR(const otfcc_Packet packet, const otfcc_Options *options) {
- table_COLR *colr = NULL;
- FOR_TABLE(OTFCC_CHR('C','O','L','R'), table) {
- if (table.length < 14) goto FAIL;
- uint16_t numBaseGlyphRecords = read_16u(table.data + 2);
- uint16_t numLayerRecords = read_16u(table.data + 12);
- uint32_t offsetBaseGlyphRecord = read_32u(table.data + 4);
- uint32_t offsetLayerRecord = read_32u(table.data + 8);
- if (table.length < offsetBaseGlyphRecord + baseGlyphRecLength * numBaseGlyphRecords)
- goto FAIL;
- if (table.length < offsetLayerRecord + layerRecLength * numLayerRecords) goto FAIL;
-
- // parse layer data
- glyphid_t *gids;
- colorid_t *colors;
- NEW(gids, numLayerRecords);
- NEW(colors, numLayerRecords);
- for (glyphid_t j = 0; j < numLayerRecords; j++) {
- gids[j] = read_16u(table.data + offsetLayerRecord + layerRecLength * j);
- colors[j] = read_16u(table.data + offsetLayerRecord + layerRecLength * j + 2);
- }
- // parse decomposition data
- colr = table_iCOLR.create();
- for (glyphid_t j = 0; j < numBaseGlyphRecords; j++) {
- colr_Mapping mapping;
- colr_iMapping.init(&mapping);
- uint16_t gid = read_16u(table.data + offsetBaseGlyphRecord + baseGlyphRecLength * j);
- uint16_t firstLayerIndex =
- read_16u(table.data + offsetBaseGlyphRecord + baseGlyphRecLength * j + 2);
- uint16_t numLayers =
- read_16u(table.data + offsetBaseGlyphRecord + baseGlyphRecLength * j + 4);
-
- glyph_handle baseGlyph = Handle.fromIndex(gid);
- Handle.move(&mapping.glyph, &baseGlyph);
- for (glyphid_t k = 0; k < numLayers; k++) {
- if (k + firstLayerIndex < numLayerRecords) {
- colr_iLayerList.push(&mapping.layers,
- (colr_Layer){
- .glyph = Handle.fromIndex(gids[k + firstLayerIndex]),
- .paletteIndex = colors[k + firstLayerIndex],
- });
- }
- }
- table_iCOLR.push(colr, mapping);
- }
- return colr;
- FAIL:
- logWarning("Table 'COLR' corrupted.\n");
- table_iCOLR.free(colr);
- colr = NULL;
- }
- return colr;
-}
-
-void otfcc_dumpCOLR(const table_COLR *colr, json_value *root, const otfcc_Options *options) {
- if (!colr) return;
- loggedStep("COLR") {
- json_value *_colr = json_array_new(colr->length);
- foreach (colr_Mapping *mapping, *colr) {
- json_value *_map = json_object_new(2);
- json_object_push(_map, "from", json_string_new(mapping->glyph.name));
- json_value *_layers = json_array_new(mapping->layers.length);
- foreach (colr_Layer *layer, mapping->layers) {
- json_value *_layer = json_object_new(2);
- json_object_push(_layer, "layer", json_string_new(layer->glyph.name));
- json_object_push(_layer, "paletteIndex", json_integer_new(layer->paletteIndex));
- json_array_push(_layers, _layer);
- }
- json_object_push(_map, "to", preserialize(_layers));
- json_array_push(_colr, _map);
- }
- json_object_push(root, "COLR", _colr);
- }
-}
-
-table_COLR *otfcc_parseCOLR(const json_value *root, const otfcc_Options *options) {
- json_value *_colr = NULL;
- if (!(_colr = json_obj_get_type(root, "COLR", json_array))) return NULL;
- table_COLR *colr = table_iCOLR.create();
- loggedStep("COLR") {
- for (glyphid_t j = 0; j < _colr->u.array.length; j++) {
- json_value *_mapping = _colr->u.array.values[j];
- if (!_mapping || _mapping->type != json_object) continue;
- json_value *_baseglyph = json_obj_get_type(_mapping, "from", json_string);
- json_value *_layers = json_obj_get_type(_mapping, "to", json_array);
- if (!_baseglyph || !_layers) continue;
-
- colr_Mapping m;
- colr_iMapping.init(&m);
- m.glyph =
- Handle.fromName(sdsnewlen(_baseglyph->u.string.ptr, _baseglyph->u.string.length));
- for (glyphid_t k = 0; k < _layers->u.array.length; k++) {
- json_value *_layer = _layers->u.array.values[k];
- if (!_layer || _layer->type != json_object) continue;
- json_value *_layerglyph = json_obj_get_type(_layer, "layer", json_string);
- if (!_layerglyph) continue;
- colr_iLayerList.push(
- &m.layers,
- (colr_Layer){
- .glyph = Handle.fromName(
- sdsnewlen(_layerglyph->u.string.ptr, _layerglyph->u.string.length)),
- .paletteIndex = json_obj_getint_fallback(_layer, "paletteIndex", 0xFFFF),
- });
- }
- table_iCOLR.push(colr, m);
- }
- }
- return colr;
-}
-
-static int byGID(const colr_Mapping *a, const colr_Mapping *b) {
- return a->glyph.index - b->glyph.index;
-}
-
-caryll_Buffer *otfcc_buildCOLR(const table_COLR *_colr, const otfcc_Options *options) {
- if (!_colr || !_colr->length) return NULL;
-
- // sort base defs
- table_COLR colr;
- table_iCOLR.copy(&colr, _colr);
- table_iCOLR.sort(&colr, byGID);
-
- glyphid_t currentLayerIndex = 0;
- bk_Block *layerRecords = bk_new_Block(bkover);
- bk_Block *baseRecords = bk_new_Block(bkover);
- foreach (colr_Mapping *mapping, colr) {
- bk_push(baseRecords, b16, mapping->glyph.index, // GID
- b16, currentLayerIndex, // firstLayerIndex
- b16, mapping->layers.length, // numLayers
- bkover);
- foreach (colr_Layer *layer, mapping->layers) {
- bk_push(layerRecords, b16, layer->glyph.index, // GID
- b16, layer->paletteIndex, // paletteIndex
- bkover);
- currentLayerIndex += 1;
- }
- }
-
- bk_Block *root = bk_new_Block(b16, 0, // Version
- b16, colr.length, // numBaseGlyphRecords
- p32, baseRecords, // offsetBaseGlyphRecord
- p32, layerRecords, // offsetLayerRecord
- b16, currentLayerIndex, // numLayerRecords
- bkover);
- table_iCOLR.dispose(&colr);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.h
deleted file mode 100644
index 6d7f3ba0cbf..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/COLR.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_COLR_H
-#define CARYLL_TABLE_COLR_H
-
-#include "otfcc/table/COLR.h"
-
-table_COLR *otfcc_readCOLR(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpCOLR(const table_COLR *table, json_value *root, const otfcc_Options *options);
-table_COLR *otfcc_parseCOLR(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildCOLR(const table_COLR *colr, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.c
deleted file mode 100644
index 50131df6377..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.c
+++ /dev/null
@@ -1,280 +0,0 @@
-#include "CPAL.h"
-
-#include "support/util.h"
-#include "bk/bkgraph.h"
-
-
-// Colors are trivial.
-caryll_standardType(cpal_Color, cpal_iColor);
-caryll_standardVectorImpl(cpal_ColorSet, cpal_Color, cpal_iColor, cpal_iColorSet);
-
-// Palettes are non-trivial.
-static INLINE void initPalette(cpal_Palette *p) {
- cpal_iColorSet.init(&p->colorset);
- p->type = 0;
- p->label = 0xFFFF;
-}
-static INLINE void disposePalette(cpal_Palette *p) {
- cpal_iColorSet.dispose(&p->colorset);
-}
-caryll_standardType(cpal_Palette, cpal_iPalette, initPalette, disposePalette);
-caryll_standardVectorImpl(cpal_PaletteSet, cpal_Palette, cpal_iPalette, cpal_iPaletteSet);
-
-// CPAL table
-static INLINE void initCPAL(table_CPAL *cpal) {
- cpal->version = 1;
- cpal_iPaletteSet.init(&cpal->palettes);
-}
-static INLINE void disposeCPAL(table_CPAL *cpal) {
- cpal_iPaletteSet.dispose(&cpal->palettes);
-}
-caryll_standardRefType(table_CPAL, table_iCPAL, initCPAL, disposeCPAL);
-
-const cpal_Color white = {.red = 0xFF, .green = 0xFF, .blue = 0xFF, .alpha = 0xFF, .label = 0xFFFF};
-
-table_CPAL *otfcc_readCPAL(const otfcc_Packet packet, const otfcc_Options *options) {
- table_CPAL *t = NULL;
- FOR_TABLE(OTFCC_CHR('C','P','A','L'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- if (length < 2) goto FAIL;
- t = table_iCPAL.create();
- uint16_t version = read_16u(data);
- uint32_t tableHeaderLength = (version == 0 ? 14 : 26);
- if (length < tableHeaderLength) goto FAIL;
-
- t->version = version;
- uint16_t numPalettesEntries = read_16u(data + 2);
- uint16_t numPalettes = read_16u(data + 4);
- uint16_t numColorRecords = read_16u(data + 6);
- uint32_t offsetFirstColorRecord = read_32u(data + 8);
- if (length < offsetFirstColorRecord + numColorRecords * 4) goto FAIL;
- if (length < tableHeaderLength + 2 * numPalettes) goto FAIL;
-
- // read color list
- cpal_Color *colorList;
- NEW(colorList, numColorRecords);
- for (uint16_t j = 0; j < numColorRecords; j++) {
- colorList[j] = (cpal_Color){.blue = read_8u(data + offsetFirstColorRecord + j * 4),
- .green = read_8u(data + offsetFirstColorRecord + j * 4 + 1),
- .red = read_8u(data + offsetFirstColorRecord + j * 4 + 2),
- .alpha = read_8u(data + offsetFirstColorRecord + j * 4 + 3),
- .label = 0xFFFF};
- }
-
- // read palettes
- for (tableid_t j = 0; j < numPalettes; j++) {
- cpal_Palette palette;
- cpal_iPalette.init(&palette);
- tableid_t paletteStartIndex = read_16u(data + 12 + j * 2);
- for (colorid_t j = 0; j < numPalettesEntries; j++) {
- if (paletteStartIndex + j < numColorRecords) {
- cpal_iColorSet.push(&palette.colorset, colorList[j + paletteStartIndex]);
- } else {
- cpal_iColorSet.push(&palette.colorset, white);
- }
- }
- cpal_iPaletteSet.push(&t->palettes, palette);
- }
-
- if (version > 0) {
- uint32_t offsetPaletteTypeArray = read_32u(data + 16 + 2 * numPalettes);
- if (offsetPaletteTypeArray && length >= offsetPaletteTypeArray + 4 * numPalettes) {
- for (tableid_t j = 0; j < numPalettes; j++) {
- uint32_t type = read_32u(data + j * 4 + offsetPaletteTypeArray);
- t->palettes.items[j].type = type;
- }
- }
- uint32_t offsetPaletteLabelArray = read_32u(data + 20 + 2 * numPalettes);
- if (offsetPaletteLabelArray && length >= offsetPaletteLabelArray + 2 * numPalettes) {
- for (tableid_t j = 0; j < numPalettes; j++) {
- uint16_t label = read_16u(data + j * 2 + offsetPaletteLabelArray);
- t->palettes.items[j].label = label;
- }
- }
-
- if (version > 0) {
- uint32_t offsetPaletteEntryLabelArray = read_32u(data + 24 + 2 * numPalettes);
- if (offsetPaletteEntryLabelArray &&
- length >= offsetPaletteEntryLabelArray + 4 * numPalettesEntries) {
- for (colorid_t j = 0; j < numPalettesEntries; j++) {
- uint16_t label = read_16u(data + j * 2 + offsetPaletteEntryLabelArray);
- for (tableid_t k = 0; k < numPalettes; k++) {
- t->palettes.items[k].colorset.items[j].label = label;
- }
- }
- }
- }
- }
-
- FREE(colorList);
- return t;
-
- FAIL:
- table_iCPAL.free(t);
- t = NULL;
- }
- return NULL;
-}
-
-static INLINE json_value *dumpColor(cpal_Color *color) {
- json_value *_color = json_object_new(5);
- json_object_push(_color, "red", json_integer_new(color->red));
- json_object_push(_color, "green", json_integer_new(color->green));
- json_object_push(_color, "blue", json_integer_new(color->blue));
- if (color->alpha != 0xFF) json_object_push(_color, "alpha", json_integer_new(color->alpha));
- if (color->label != 0xFFFF) json_object_push(_color, "label", json_integer_new(color->label));
- return preserialize(_color);
-}
-
-static INLINE json_value *dumpPalette(cpal_Palette *palette) {
- json_value *_palette = json_object_new(3);
- if (palette->type) { json_object_push(_palette, "type", json_integer_new(palette->type)); }
- if (palette->label != 0xFFFF) {
- json_object_push(_palette, "label", json_integer_new(palette->label));
- }
- json_value *a = json_array_new(palette->colorset.length);
- for (colorid_t j = 0; j < palette->colorset.length; j++) {
- json_array_push(a, dumpColor(&palette->colorset.items[j]));
- }
- json_object_push(_palette, "colors", a);
- return _palette;
-}
-
-void otfcc_dumpCPAL(const table_CPAL *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("CPAL") {
- json_value *_t = json_object_new(2);
- json_object_push(_t, "version", json_integer_new(table->version));
- json_value *_a = json_array_new(table->palettes.length);
- for (tableid_t j = 0; j < table->palettes.length; j++) {
- json_array_push(_a, dumpPalette(&table->palettes.items[j]));
- }
- json_object_push(_t, "palettes", _a);
- json_object_push(root, "CPAL", _t);
- }
-}
-
-static INLINE cpal_Color parseColor(const json_value *_color) {
- cpal_Color color = white;
- if (!_color || _color->type != json_object) return color;
- color.red = json_obj_getint_fallback(_color, "red", 0);
- color.green = json_obj_getint_fallback(_color, "green", 0);
- color.blue = json_obj_getint_fallback(_color, "blue", 0);
- color.alpha = json_obj_getint_fallback(_color, "alpha", 0xFF);
- color.label = json_obj_getint_fallback(_color, "label", 0xFFFF);
- return color;
-}
-
-table_CPAL *otfcc_parseCPAL(const json_value *root, const otfcc_Options *options) {
- json_value *table = NULL;
- if (!(table = json_obj_get_type(root, "CPAL", json_object))) return NULL;
- table_CPAL *cpal = NULL;
- loggedStep("CPAL") {
- json_value *_palettes = json_obj_get_type(table, "palettes", json_array);
- if (!_palettes || !_palettes->u.array.length) return NULL;
- cpal = table_iCPAL.create();
- cpal->version = json_obj_getint(table, "version");
- for (tableid_t j = 0; j < _palettes->u.array.length; j++) {
- json_value *_palette = _palettes->u.array.values[j];
- if (!_palette || _palette->type != json_object) continue;
- json_value *_colors = json_obj_get_type(_palette, "colors", json_array);
- if (!_colors) continue;
-
- // palette parser
- cpal_Palette palette;
- cpal_iPalette.init(&palette);
- palette.type = json_obj_getint(_palette, "type");
- palette.label = json_obj_getint_fallback(_palette, "type", 0xFFFF);
-
- // color list parser
- for (colorid_t k = 0; k < _colors->u.array.length; k++) {
- cpal_iColorSet.push(&palette.colorset, parseColor(_colors->u.array.values[k]));
- }
-
- // push into cpal
- cpal_iPaletteSet.push(&cpal->palettes, palette);
- }
- }
- return cpal;
-}
-
-static INLINE bk_Block *buildPaletteType(const table_CPAL *cpal) {
- bool needsPaletteType = false;
- for (tableid_t j = 0; j < cpal->palettes.length; j++) {
- if (cpal->palettes.items[j].type) needsPaletteType = true;
- }
- if (!needsPaletteType) return NULL;
- bk_Block *block = bk_new_Block(bkover);
- for (tableid_t j = 0; j < cpal->palettes.length; j++) {
- bk_push(block, b32, cpal->palettes.items[j].type, bkover);
- }
- return block;
-}
-static INLINE bk_Block *buildPaletteLabel(const table_CPAL *cpal) {
- bool needsPaletteLabel = false;
- for (tableid_t j = 0; j < cpal->palettes.length; j++) {
- if (cpal->palettes.items[j].label != 0xFFFF) needsPaletteLabel = true;
- }
- if (!needsPaletteLabel) return NULL;
- bk_Block *block = bk_new_Block(bkover);
- for (tableid_t j = 0; j < cpal->palettes.length; j++) {
- bk_push(block, b16, cpal->palettes.items[j].label, bkover);
- }
- return block;
-}
-static INLINE bk_Block *buildPaletteEntryLabel(const table_CPAL *cpal) {
- bool needsPaletteEntryLabel = false;
- cpal_Palette *palette = &cpal->palettes.items[0];
- for (colorid_t j = 0; j < palette->colorset.length; j++) {
- if (palette->colorset.items[j].label != 0xFFFF) needsPaletteEntryLabel = true;
- }
- if (!needsPaletteEntryLabel) return NULL;
- bk_Block *block = bk_new_Block(bkover);
- for (colorid_t j = 0; j < palette->colorset.length; j++) {
- bk_push(block, b16, palette->colorset.items[j].label, bkover);
- }
- return block;
-}
-caryll_Buffer *otfcc_buildCPAL(const table_CPAL *cpal, const otfcc_Options *options) {
- if (!cpal || !cpal->palettes.length) return NULL;
- uint16_t numPalettes = cpal->palettes.length;
- uint16_t numPalettesEntries = cpal->palettes.items[0].colorset.length;
- uint16_t numColorRecords = numPalettes * numPalettesEntries;
-
- bk_Block *colorRecords = bk_new_Block(bkover);
- for (tableid_t j = 0; j < numPalettes; j++) {
- cpal_Palette *palette = &cpal->palettes.items[j];
- colorid_t totalColors = palette->colorset.length;
- for (colorid_t k = 0; k < numPalettesEntries; k++) {
- const cpal_Color *color = NULL;
- if (k < totalColors) {
- color = &palette->colorset.items[k];
- } else {
- color = &white;
- }
- bk_push(colorRecords, b8, color->blue, // blue
- b8, color->green, // green
- b8, color->red, // red
- b8, color->alpha, // alpha
- bkover);
- }
- }
-
- bk_Block *root = bk_new_Block(b16, cpal->version, // Version
- b16, numPalettesEntries, // numPalettesEntries
- b16, numPalettes, // numPalettes
- b16, numColorRecords, // numColorRecords
- p32, colorRecords, // offsetFirstColorRecord
- bkover);
- for (tableid_t j = 0; j < numPalettes; j++) {
- bk_push(root, b16, numPalettesEntries * j, bkover); // colorRecordIndices
- }
- if (cpal->version > 0) {
- bk_push(root, p32, buildPaletteType(cpal), // offsetPaletteTypeArray
- p32, buildPaletteLabel(cpal), // offsetPaletteLabelArray
- p32, buildPaletteEntryLabel(cpal), // offsetPaletteEntryLabelArray
- bkover);
- }
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.h
deleted file mode 100644
index 3d96bdde895..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/CPAL.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_CPAL_H
-#define CARYLL_TABLE_CPAL_H
-
-#include "otfcc/table/CPAL.h"
-
-table_CPAL *otfcc_readCPAL(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpCPAL(const table_CPAL *table, json_value *root, const otfcc_Options *options);
-table_CPAL *otfcc_parseCPAL(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildCPAL(const table_CPAL *cpal, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.c
deleted file mode 100644
index 6566b2f9060..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.c
+++ /dev/null
@@ -1,254 +0,0 @@
-#include "GDEF.h"
-
-#include "otl/private.h"
-
-
-caryll_ElementInterfaceOf(otl_CaretValue) otl_iCaretValue = {
- .init = NULL,
- .copy = NULL,
- .dispose = NULL,
-};
-caryll_standardVectorImpl(otl_CaretValueList, otl_CaretValue, otl_iCaretValue, otl_iCaretValueList);
-
-static INLINE void initGdefLigCaretRec(otl_CaretValueRecord *v) {
- v->glyph = Handle.empty();
- otl_iCaretValueList.init(&v->carets);
-}
-static void deleteGdefLigCaretRec(otl_CaretValueRecord *v) {
- Handle.dispose(&v->glyph);
- otl_iCaretValueList.dispose(&v->carets);
-}
-caryll_ElementInterfaceOf(otl_CaretValueRecord) otl_iCaretValueRecord = {
- .init = initGdefLigCaretRec,
- .copy = NULL,
- .dispose = deleteGdefLigCaretRec,
-};
-caryll_standardVectorImpl(otl_LigCaretTable, otl_CaretValueRecord, otl_iCaretValueRecord,
- otl_iLigCaretTable);
-
-static INLINE void initGDEF(table_GDEF *gdef) {
- gdef->glyphClassDef = NULL;
- gdef->markAttachClassDef = NULL;
- otl_iLigCaretTable.init(&gdef->ligCarets);
-}
-static INLINE void disposeGDEF(table_GDEF *gdef) {
- if (!gdef) return;
- if (gdef->glyphClassDef) ClassDef.free(gdef->glyphClassDef);
- if (gdef->markAttachClassDef) ClassDef.free(gdef->markAttachClassDef);
- otl_iLigCaretTable.dispose(&gdef->ligCarets);
-}
-
-caryll_standardRefType(table_GDEF, table_iGDEF, initGDEF, disposeGDEF);
-
-static otl_CaretValue readCaretValue(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset) {
- otl_CaretValue v;
- v.format = 0;
- v.coordiante = 0;
- v.pointIndex = 0xFFFF;
- checkLength(offset + 4);
-
- v.format = read_16u(data + offset);
- if (v.format == 2) { // attach to glyph point
- v.pointIndex = read_16u(data + offset + 2);
- } else {
- v.coordiante = (pos_t)read_16u(data + offset + 2);
- }
-FAIL:
- return v;
-}
-static otl_CaretValueRecord readLigCaretRecord(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset) {
- otl_CaretValueRecord g;
- otl_iCaretValueRecord.init(&g);
- checkLength(offset + 2);
- shapeid_t caretCount = read_16u(data + offset);
- checkLength(offset + 2 + caretCount * 2);
-
- for (glyphid_t j = 0; j < caretCount; j++) {
- otl_iCaretValueList.push(
- &g.carets,
- readCaretValue(data, tableLength, offset + read_16u(data + offset + 2 + j * 2)));
- }
-FAIL:;
- return g;
-}
-
-table_GDEF *otfcc_readGDEF(const otfcc_Packet packet, const otfcc_Options *options) {
- table_GDEF *gdef = NULL;
- FOR_TABLE(OTFCC_CHR('G','D','E','F'), table) {
- font_file_pointer data = table.data;
- uint32_t tableLength = table.length;
- checkLength(12);
- gdef = table_iGDEF.create();
- uint16_t classdefOffset = read_16u(data + 4);
- if (classdefOffset) {
- gdef->glyphClassDef = ClassDef.read(data, tableLength, classdefOffset);
- }
- uint16_t ligCaretOffset = read_16u(data + 8);
- if (ligCaretOffset) {
- checkLength(ligCaretOffset + 4);
- otl_Coverage *cov =
- Coverage.read(data, tableLength, ligCaretOffset + read_16u(data + ligCaretOffset));
- if (!cov || cov->numGlyphs != read_16u(data + ligCaretOffset + 2)) goto FAIL;
- checkLength(ligCaretOffset + 4 + cov->numGlyphs * 2);
- for (glyphid_t j = 0; j < cov->numGlyphs; j++) {
- otl_CaretValueRecord v = readLigCaretRecord(
- data, tableLength,
- ligCaretOffset + read_16u(data + ligCaretOffset + 4 + j * 2));
- v.glyph = Handle.dup(cov->glyphs[j]);
- otl_iLigCaretTable.push(&gdef->ligCarets, v);
- }
- Coverage.free(cov);
- }
- uint16_t markAttachDefOffset = read_16u(data + 10);
- if (markAttachDefOffset) {
- gdef->markAttachClassDef = ClassDef.read(data, tableLength, markAttachDefOffset);
- }
- return gdef;
-
- FAIL:
- DELETE(table_iGDEF.free, gdef);
- }
- return gdef;
-}
-
-static json_value *dumpGDEFLigCarets(const table_GDEF *gdef) {
- json_value *_carets = json_object_new(gdef->ligCarets.length);
- for (glyphid_t j = 0; j < gdef->ligCarets.length; j++) {
- sds name = gdef->ligCarets.items[j].glyph.name;
- json_value *_record = json_array_new(gdef->ligCarets.items[j].carets.length);
-
- for (glyphid_t k = 0; k < gdef->ligCarets.items[j].carets.length; k++) {
- json_value *_cv = json_object_new(1);
- if (gdef->ligCarets.items[j].carets.items[k].format == 2) {
- json_object_push(
- _cv, "atPoint",
- json_integer_new(gdef->ligCarets.items[j].carets.items[k].pointIndex));
- } else {
- json_object_push(
- _cv, "at",
- json_integer_new(gdef->ligCarets.items[j].carets.items[k].coordiante));
- }
- json_array_push(_record, _cv);
- }
- json_object_push(_carets, name, preserialize(_record));
- }
- return _carets;
-}
-
-void otfcc_dumpGDEF(const table_GDEF *gdef, json_value *root, const otfcc_Options *options) {
- if (!gdef) return;
- loggedStep("GDEF") {
- json_value *_gdef = json_object_new(4);
- if (gdef->glyphClassDef) {
- json_object_push(_gdef, "glyphClassDef", ClassDef.dump(gdef->glyphClassDef));
- }
- if (gdef->markAttachClassDef) {
- json_object_push(_gdef, "markAttachClassDef", ClassDef.dump(gdef->markAttachClassDef));
- }
- if (gdef->ligCarets.length) {
- json_object_push(_gdef, "ligCarets", dumpGDEFLigCarets(gdef));
- }
- json_object_push(root, "GDEF", _gdef);
- }
-}
-
-static void ligCaretFromJson(const json_value *_carets, otl_LigCaretTable *lc) {
- if (!_carets || _carets->type != json_object) return;
-
- for (glyphid_t j = 0; j < _carets->u.object.length; j++) {
- json_value *a = _carets->u.object.values[j].value;
- if (!a || a->type != json_array) continue;
- otl_CaretValueRecord v;
- otl_iCaretValueRecord.init(&v);
- v.glyph = Handle.fromName(
- sdsnewlen(_carets->u.object.values[j].name, _carets->u.object.values[j].name_length));
- shapeid_t caretCount = a->u.array.length;
- for (glyphid_t k = 0; k < caretCount; k++) {
- otl_CaretValue caret;
- caret.format = 1;
- caret.coordiante = 0;
- caret.pointIndex = 0xFFFF;
- json_value *_caret = a->u.array.values[k];
- if (_caret && _caret->type == json_object) {
- if (json_obj_get_type(_caret, "atPoint", json_integer)) {
- caret.format = 2;
- caret.pointIndex = json_obj_getint(_caret, "atPoint");
- } else {
- caret.coordiante = json_obj_getnum(_caret, "at");
- }
- }
- otl_iCaretValueList.push(&v.carets, caret);
- }
- otl_iLigCaretTable.push(lc, v);
- }
-}
-
-table_GDEF *otfcc_parseGDEF(const json_value *root, const otfcc_Options *options) {
- table_GDEF *gdef = NULL;
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "GDEF", json_object))) {
- loggedStep("GDEF") {
- gdef = table_iGDEF.create();
- gdef->glyphClassDef = ClassDef.parse(json_obj_get(table, "glyphClassDef"));
- gdef->markAttachClassDef = ClassDef.parse(json_obj_get(table, "markAttachClassDef"));
- ligCaretFromJson(json_obj_get(table, "ligCarets"), &gdef->ligCarets);
- }
- }
- return gdef;
-}
-
-static bk_Block *writeLigCaretRec(otl_CaretValueRecord *cr) {
- bk_Block *bcr = bk_new_Block(b16, cr->carets.length, // CaretCount
- bkover);
- for (glyphid_t j = 0; j < cr->carets.length; j++) {
- bk_push(bcr, p16,
- bk_new_Block(b16, cr->carets.items[j].format, // format
- b16,
- cr->carets.items[j].format == 2
- ? cr->carets.items[j].pointIndex // Point index
- : (int16_t)cr->carets.items[j].coordiante, // X coordinate
- bkover), // CaretValue
- bkover);
- }
- return bcr;
-}
-
-static bk_Block *writeLigCarets(const otl_LigCaretTable *lc) {
- otl_Coverage *cov = Coverage.create();
- for (glyphid_t j = 0; j < lc->length; j++) {
- Coverage.push(cov, Handle.dup(lc->items[j].glyph));
- }
- bk_Block *lct = bk_new_Block(p16, bk_newBlockFromBuffer(Coverage.build(cov)), // Coverage
- b16, lc->length, // LigGlyphCount
- bkover);
- for (glyphid_t j = 0; j < lc->length; j++) {
- bk_push(lct, p16, writeLigCaretRec(&(lc->items[j])), bkover);
- }
- Coverage.free(cov);
- return lct;
-}
-
-caryll_Buffer *otfcc_buildGDEF(const table_GDEF *gdef, const otfcc_Options *options) {
- if (!gdef) return NULL;
- bk_Block *bGlyphClassDef = NULL;
- bk_Block *bAttachList = NULL;
- bk_Block *bLigCaretList = NULL;
- bk_Block *bMarkAttachClassDef = NULL;
-
- if (gdef->glyphClassDef) {
- bGlyphClassDef = bk_newBlockFromBuffer(ClassDef.build(gdef->glyphClassDef));
- }
- if (gdef->ligCarets.length) { bLigCaretList = writeLigCarets(&gdef->ligCarets); }
- if (gdef->markAttachClassDef) {
- bMarkAttachClassDef = bk_newBlockFromBuffer(ClassDef.build(gdef->markAttachClassDef));
- }
- bk_Block *root = bk_new_Block(b32, 0x10000, // Version
- p16, bGlyphClassDef, // GlyphClassDef
- p16, bAttachList, // AttachList
- p16, bLigCaretList, // LigCaretList
- p16, bMarkAttachClassDef, // MarkAttachClassDef
- bkover);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.h
deleted file mode 100644
index e718f998f40..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/GDEF.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_GDEF_H
-#define CARYLL_TABLE_GDEF_H
-
-#include "otfcc/table/GDEF.h"
-
-table_GDEF *otfcc_readGDEF(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpGDEF(const table_GDEF *gdef, json_value *root, const otfcc_Options *options);
-table_GDEF *otfcc_parseGDEF(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildGDEF(const table_GDEF *gdef, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.c
deleted file mode 100644
index 2938c450c2c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "LTSH.h"
-
-#include "support/util.h"
-
-
-static INLINE void disposeLTSH(MOVE table_LTSH *ltsh) {
- if (ltsh) { FREE(ltsh->yPels); }
-}
-caryll_standardRefType(table_LTSH, table_iLTSH, disposeLTSH);
-
-table_LTSH *otfcc_readLTSH(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('L','T','S','H'), table) {
- font_file_pointer data = table.data;
-
- table_LTSH *LTSH;
- NEW(LTSH);
- LTSH->version = read_16u(data);
- LTSH->numGlyphs = read_16u(data + 2);
- NEW(LTSH->yPels, LTSH->numGlyphs);
- memcpy(LTSH->yPels, data + 4, LTSH->numGlyphs);
-
- return LTSH;
- }
- return NULL;
-}
-caryll_Buffer *otfcc_buildLTSH(const table_LTSH *ltsh, const otfcc_Options *options) {
- if (!ltsh) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, 0);
- bufwrite16b(buf, ltsh->numGlyphs);
- for (uint16_t j = 0; j < ltsh->numGlyphs; j++) {
- bufwrite8(buf, ltsh->yPels[j]);
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.h
deleted file mode 100644
index ffca1e2067c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/LTSH.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef CARYLL_TABLE_LTSH_H
-#define CARYLL_TABLE_LTSH_H
-
-#include "otfcc/table/LTSH.h"
-
-table_LTSH *otfcc_readLTSH(const otfcc_Packet packet, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildLTSH(const table_LTSH *ltsh, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.c
deleted file mode 100644
index 5c4ad385c46..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.c
+++ /dev/null
@@ -1,435 +0,0 @@
-#include "OS_2.h"
-#include "support/util.h"
-
-
-static INLINE void initOS2(table_OS_2 *table) {
- memset(table, 0, sizeof(*table));
- table->version = 4;
-}
-static INLINE void disposeOS2(MOVE table_OS_2 *table) {
- // trivial
-}
-caryll_standardRefType(table_OS_2, table_iOS_2, initOS2, disposeOS2);
-
-table_OS_2 *otfcc_readOS_2(const otfcc_Packet packet, const otfcc_Options *options) {
- table_OS_2 *os_2 = NULL;
- FOR_TABLE(OTFCC_CHR('O','S','/','2'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- if (length < 2) goto OS_2_CORRUPTED;
- os_2 = table_iOS_2.create();
- os_2->version = read_16u(data);
- // version 0 (Apple's TrueType)
- if (length < 68) goto OS_2_CORRUPTED;
- {
- os_2->xAvgCharWidth = read_16u(data + 2);
- os_2->usWeightClass = read_16u(data + 4);
- os_2->usWidthClass = read_16u(data + 6);
- os_2->fsType = read_16u(data + 8);
- os_2->ySubscriptXSize = read_16u(data + 10);
- os_2->ySubscriptYSize = read_16u(data + 12);
- os_2->ySubscriptXOffset = read_16u(data + 14);
- os_2->ySubscriptYOffset = read_16u(data + 16);
- os_2->ySupscriptXSize = read_16u(data + 18);
- os_2->ySupscriptYSize = read_16u(data + 20);
- os_2->ySupscriptXOffset = read_16u(data + 22);
- os_2->ySupscriptYOffset = read_16u(data + 24);
- os_2->yStrikeoutSize = read_16u(data + 26);
- os_2->yStrikeoutPosition = read_16u(data + 28);
- os_2->sFamilyClass = read_16u(data + 30);
- memcpy(os_2->panose, data + 32, 10);
- os_2->ulUnicodeRange1 = read_32u(data + 42);
- os_2->ulUnicodeRange2 = read_32u(data + 46);
- os_2->ulUnicodeRange3 = read_32u(data + 50);
- os_2->ulUnicodeRange4 = read_32u(data + 54);
- memcpy(os_2->achVendID, data + 58, 4);
- os_2->fsSelection = read_16u(data + 62);
- os_2->usFirstCharIndex = read_16u(data + 64);
- os_2->usLastCharIndex = read_16u(data + 66);
- }
- // version 0 (OpenType)
- if (length >= 78) {
- os_2->sTypoAscender = read_16s(data + 68);
- os_2->sTypoDescender = read_16s(data + 70);
- os_2->sTypoLineGap = read_16s(data + 72);
- os_2->usWinAscent = read_16u(data + 74);
- os_2->usWinDescent = read_16u(data + 76);
- }
- // version 1
- if (os_2->version >= 1 && length < 86) goto OS_2_CORRUPTED;
- if (os_2->version >= 1) {
- os_2->ulCodePageRange1 = read_32u(data + 78);
- os_2->ulCodePageRange2 = read_32u(data + 82);
- }
- // version 2, 3, 4
- if (os_2->version >= 2 && length < 96) goto OS_2_CORRUPTED;
- if (os_2->version >= 2) {
- os_2->sxHeight = read_16s(data + 86);
- os_2->sCapHeight = read_16s(data + 88);
- os_2->usDefaultChar = read_16u(data + 90);
- os_2->usBreakChar = read_16u(data + 92);
- os_2->usMaxContext = read_16u(data + 94);
- }
- // version 5
- if (os_2->version >= 5 && length < 100) goto OS_2_CORRUPTED;
- if (os_2->version >= 5) {
- os_2->usLowerOpticalPointSize = read_16u(data + 96);
- os_2->usLowerOpticalPointSize = read_16u(data + 98);
- }
- return os_2;
-
- OS_2_CORRUPTED:
- logWarning("table 'OS/2' corrupted.\n");
- if (os_2 != NULL) FREE(os_2);
- }
- return NULL;
-}
-
-const char *fsTypeLabels[] = {"_reserved1",
- "restrictedLicense",
- "previewPrintLicense",
- "editableEmbedding",
- "_reserved2",
- "_reserved3",
- "_reserved4",
- "_reserved5",
- "noSubsetting",
- "bitmapEmbeddingOnly",
- NULL};
-const char *fsSelectionLabels[] = {"italic", "underscore", "negative", "outlined",
- "strikeout", "bold", "regular", "useTypoMetrics",
- "wws", "oblique", NULL};
-const char *codePageLabels1[] = {
- "latin1", "latin2", "cyrillic", "greek", "turkish", "hebrew", "arabic",
- "windowsBaltic", "vietnamese", "ansi1", "ansi2", "ansi3", "ansi4", "ansi5",
- "ansi6", "ansi7", "thai", "jis", "gbk", "korean", "big5",
- "koreanJohab", "oem1", "oem2", "oem3", "oem4", "oem5", "oem6",
- "oem7", "macRoman", "oem", "symbol", NULL};
-const char *codePageLabels2[] = {"oem8", "oem9", "oem10", "oem11", "oem12", "oem13", "oem14",
- "oem15", "oem16", "oem17", "oem18", "oem19", "oem20", "oem21",
- "oem22", "oem23", "cp869", "cp866", "cp865", "cp864", "cp863",
- "cp862", "cp861", "cp860", "cp857", "cp855", "cp852", "cp775",
- "cp737", "cp708", "cp850", "ascii", NULL};
-const char *unicodeRangeLabels1[] = {"Basic_Latin",
- "Latin_1_Supplement",
- "Latin_Extended_A",
- "Latin_Extended_B",
- "Phonetics",
- "Spacing_Modifiers",
- "Combining_Diacritical_Marks",
- "Greek_and_Coptic",
- "Coptic",
- "Cyrillic",
- "Armenian",
- "Hebrew",
- "Vai",
- "Arabic",
- "NKo",
- "Devanagari",
- "Bengali",
- "Gurmukhi",
- "Gujarati",
- "Oriya",
- "Tamil",
- "Telugu",
- "Kannada",
- "Malayalam",
- "Thai",
- "Lao",
- "Georgian",
- "Balinese",
- "Hangul_Jamo",
- "Latin_Extended_Additional",
- "Greek_Extended",
- "Punctuations",
- NULL};
-const char *unicodeRangeLabels2[] = {"Superscripts_And_Subscripts",
- "Currency_Symbols",
- "Combining_Diacritical_Marks_For_Symbols",
- "Letterlike_Symbols",
- "Number_Forms",
- "Arrows",
- "Mathematical_Operators",
- "Miscellaneous_Technical",
- "Control_Pictures",
- "Optical_Character_Recognition",
- "Enclosed_Alphanumerics",
- "Box_Drawing",
- "Block_Elements",
- "Geometric_Shapes",
- "Miscellaneous_Symbols",
- "Dingbats",
- "CJK_Symbols_And_Punctuation",
- "Hiragana",
- "Katakana",
- "Bopomofo",
- "Hangul_Compatibility_Jamo",
- "Phags_pa",
- "Enclosed_CJK_Letters_And_Months",
- "CJK_Compatibility",
- "Hangul_Syllables",
- "Non_Plane_0",
- "Phoenician",
- "CJK_Unified_Ideographs",
- "Private_Use_Area_p0",
- "CJK_Strokes",
- "Alphabetic_Presentation_Forms",
- "Arabic_Presentation_Forms_A",
- NULL};
-const char *unicodeRangeLabels3[] = {"Combining_Half_Marks",
- "Vertical_Forms_and_CJK_Compatibility_Forms",
- "Small_Form_Variants",
- "Arabic_Presentation_Forms_B",
- "Halfwidth_And_Fullwidth_Forms",
- "Specials",
- "Tibetan",
- "Syriac",
- "Thaana",
- "Sinhala",
- "Myanmar",
- "Ethiopic",
- "Cherokee",
- "Unified_Canadian_Aboriginal_Syllabics",
- "Ogham",
- "Runic",
- "Khmer",
- "Mongolian",
- "Braille_Patterns",
- "Yi_Syllables",
- "Tagalog",
- "Old_Italic",
- "Gothic",
- "Deseret",
- "Musical_Symbols",
- "Mathematical_Alphanumeric_Symbols",
- "Private_Use_p15_and_p16",
- "Variation_Selectors",
- "Tags",
- "Limbu",
- "Tai_Le",
- "New_Tai_Lue",
- NULL};
-const char *unicodeRangeLabels4[] = {"Buginese",
- "Glagolitic",
- "Tifinagh",
- "Yijing_Hexagram_Symbols",
- "Syloti_Nagri",
- "Linear_B_Syllabary_Ideograms_and_Aegean_Numbers",
- "Ancient_Greek_Numbers",
- "Ugaritic",
- "Old_Persian",
- "Shavian",
- "Osmanya",
- "Cypriot_Syllabary",
- "Kharoshthi",
- "Tai_Xuan_Jing_Symbols",
- "Cuneiform",
- "Counting_Rod_Numerals",
- "Sundanese",
- "Lepcha",
- "Ol_Chiki",
- "Saurashtra",
- "Kayah_Li",
- "Rejang",
- "Cham",
- "Ancient_Symbols",
- "Phaistos_Disc",
- "Carian_and_Lycian",
- "Domino_and_Mahjong_Tiles",
- NULL};
-
-void otfcc_dumpOS_2(const table_OS_2 *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("OS/2") {
- json_value *os_2 = json_object_new(30);
- json_object_push(os_2, "version", json_integer_new(table->version));
- json_object_push(os_2, "xAvgCharWidth", json_integer_new(table->xAvgCharWidth));
- json_object_push(os_2, "usWeightClass", json_integer_new(table->usWeightClass));
- json_object_push(os_2, "usWidthClass", json_integer_new(table->usWidthClass));
- json_object_push(os_2, "fsType", otfcc_dump_flags(table->fsType, fsTypeLabels));
- json_object_push(os_2, "ySubscriptXSize", json_integer_new(table->ySubscriptXSize));
- json_object_push(os_2, "ySubscriptYSize", json_integer_new(table->ySubscriptYSize));
- json_object_push(os_2, "ySubscriptXOffset", json_integer_new(table->ySubscriptXOffset));
- json_object_push(os_2, "ySubscriptYOffset", json_integer_new(table->ySubscriptYOffset));
- json_object_push(os_2, "ySupscriptXSize", json_integer_new(table->ySupscriptXSize));
- json_object_push(os_2, "ySupscriptYSize", json_integer_new(table->ySupscriptYSize));
- json_object_push(os_2, "ySupscriptXOffset", json_integer_new(table->ySupscriptXOffset));
- json_object_push(os_2, "ySupscriptYOffset", json_integer_new(table->ySupscriptYOffset));
- json_object_push(os_2, "yStrikeoutSize", json_integer_new(table->yStrikeoutSize));
- json_object_push(os_2, "yStrikeoutPosition", json_integer_new(table->yStrikeoutPosition));
- json_object_push(os_2, "sFamilyClass", json_integer_new(table->sFamilyClass));
-
- json_value *panose = json_array_new(10);
- for (uint8_t j = 0; j < 10; j++) {
- json_array_push(panose, json_integer_new(table->panose[j]));
- }
- json_object_push(os_2, "panose", panose);
-
- json_object_push(os_2, "ulUnicodeRange1",
- otfcc_dump_flags(table->ulUnicodeRange1, unicodeRangeLabels1));
- json_object_push(os_2, "ulUnicodeRange2",
- otfcc_dump_flags(table->ulUnicodeRange2, unicodeRangeLabels2));
- json_object_push(os_2, "ulUnicodeRange3",
- otfcc_dump_flags(table->ulUnicodeRange3, unicodeRangeLabels3));
- json_object_push(os_2, "ulUnicodeRange4",
- otfcc_dump_flags(table->ulUnicodeRange4, unicodeRangeLabels4));
-
- sds vendorid = sdsnewlen(table->achVendID, 4);
- json_object_push(os_2, "achVendID", json_string_new(vendorid));
- sdsfree(vendorid);
-
- json_object_push(os_2, "fsSelection",
- otfcc_dump_flags(table->fsSelection, fsSelectionLabels));
- json_object_push(os_2, "usFirstCharIndex", json_integer_new(table->usFirstCharIndex));
- json_object_push(os_2, "usLastCharIndex", json_integer_new(table->usLastCharIndex));
- json_object_push(os_2, "sTypoAscender", json_integer_new(table->sTypoAscender));
- json_object_push(os_2, "sTypoDescender", json_integer_new(table->sTypoDescender));
- json_object_push(os_2, "sTypoLineGap", json_integer_new(table->sTypoLineGap));
- json_object_push(os_2, "usWinAscent", json_integer_new(table->usWinAscent));
- json_object_push(os_2, "usWinDescent", json_integer_new(table->usWinDescent));
- json_object_push(os_2, "ulCodePageRange1",
- otfcc_dump_flags(table->ulCodePageRange1, codePageLabels1));
- json_object_push(os_2, "ulCodePageRange2",
- otfcc_dump_flags(table->ulCodePageRange2, codePageLabels2));
- json_object_push(os_2, "sxHeight", json_integer_new(table->sxHeight));
- json_object_push(os_2, "sCapHeight", json_integer_new(table->sCapHeight));
- json_object_push(os_2, "usDefaultChar", json_integer_new(table->usDefaultChar));
- json_object_push(os_2, "usBreakChar", json_integer_new(table->usBreakChar));
- json_object_push(os_2, "usMaxContext", json_integer_new(table->usMaxContext));
- json_object_push(os_2, "usLowerOpticalPointSize",
- json_integer_new(table->usLowerOpticalPointSize));
- json_object_push(os_2, "usUpperOpticalPointSize",
- json_integer_new(table->usUpperOpticalPointSize));
- json_object_push(root, "OS_2", os_2);
- }
-}
-
-table_OS_2 *otfcc_parseOS_2(const json_value *root, const otfcc_Options *options) {
- table_OS_2 *os_2 = table_iOS_2.create();
- if (!os_2) return NULL;
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "OS_2", json_object))) {
- loggedStep("OS/2") {
- os_2->version = json_obj_getnum_fallback(table, "version", 0);
- os_2->xAvgCharWidth = json_obj_getnum_fallback(table, "xAvgCharWidth", 0);
- os_2->usWeightClass = json_obj_getnum_fallback(table, "usWeightClass", 0);
- os_2->usWidthClass = json_obj_getnum_fallback(table, "usWidthClass", 0);
- os_2->fsType = otfcc_parse_flags(json_obj_get(table, "fsType"), fsTypeLabels);
- os_2->ySubscriptXSize = json_obj_getnum_fallback(table, "ySubscriptXSize", 0);
- os_2->ySubscriptYSize = json_obj_getnum_fallback(table, "ySubscriptYSize", 0);
- os_2->ySubscriptXOffset = json_obj_getnum_fallback(table, "ySubscriptXOffset", 0);
- os_2->ySubscriptYOffset = json_obj_getnum_fallback(table, "ySubscriptYOffset", 0);
- os_2->ySupscriptXSize = json_obj_getnum_fallback(table, "ySupscriptXSize", 0);
- os_2->ySupscriptYSize = json_obj_getnum_fallback(table, "ySupscriptYSize", 0);
- os_2->ySupscriptXOffset = json_obj_getnum_fallback(table, "ySupscriptXOffset", 0);
- os_2->ySupscriptYOffset = json_obj_getnum_fallback(table, "ySupscriptYOffset", 0);
- os_2->yStrikeoutSize = json_obj_getnum_fallback(table, "yStrikeoutSize", 0);
- os_2->yStrikeoutPosition = json_obj_getnum_fallback(table, "yStrikeoutPosition", 0);
- os_2->sFamilyClass = json_obj_getnum_fallback(table, "sFamilyClass", 0);
- os_2->fsSelection =
- otfcc_parse_flags(json_obj_get(table, "fsSelection"), fsSelectionLabels);
- os_2->usFirstCharIndex = json_obj_getnum_fallback(table, "usFirstCharIndex", 0);
- os_2->usLastCharIndex = json_obj_getnum_fallback(table, "usLastCharIndex", 0);
- os_2->sTypoAscender = json_obj_getnum_fallback(table, "sTypoAscender", 0);
- os_2->sTypoDescender = json_obj_getnum_fallback(table, "sTypoDescender", 0);
- os_2->sTypoLineGap = json_obj_getnum_fallback(table, "sTypoLineGap", 0);
- os_2->usWinAscent = json_obj_getnum_fallback(table, "usWinAscent", 0);
- os_2->usWinDescent = json_obj_getnum_fallback(table, "usWinDescent", 0);
- os_2->ulCodePageRange1 =
- otfcc_parse_flags(json_obj_get(table, "ulCodePageRange1"), codePageLabels1);
- os_2->ulCodePageRange2 =
- otfcc_parse_flags(json_obj_get(table, "ulCodePageRange2"), codePageLabels2);
- os_2->ulUnicodeRange1 =
- otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange1"), unicodeRangeLabels1);
- os_2->ulUnicodeRange2 =
- otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange2"), unicodeRangeLabels2);
- os_2->ulUnicodeRange3 =
- otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange3"), unicodeRangeLabels3);
- os_2->ulUnicodeRange4 =
- otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange4"), unicodeRangeLabels4);
- os_2->sxHeight = json_obj_getnum_fallback(table, "sxHeight", 0);
- os_2->sCapHeight = json_obj_getnum_fallback(table, "sCapHeight", 0);
- os_2->usDefaultChar = json_obj_getnum_fallback(table, "usDefaultChar", 0);
- os_2->usBreakChar = json_obj_getnum_fallback(table, "usBreakChar", 0);
- os_2->usMaxContext = json_obj_getnum_fallback(table, "usMaxContext", 0);
- os_2->usLowerOpticalPointSize =
- json_obj_getnum_fallback(table, "usLowerOpticalPointSize", 0);
- os_2->usUpperOpticalPointSize =
- json_obj_getnum_fallback(table, "usUpperOpticalPointSize", 0);
- // panose
- json_value *panose = NULL;
- if ((panose = json_obj_get_type(table, "panose", json_array))) {
- for (uint32_t j = 0; j < panose->u.array.length && j < 10; j++) {
- json_value *term = panose->u.array.values[j];
- if (term->type == json_integer) {
- os_2->panose[j] = term->u.integer;
- } else if (term->type == json_double) {
- os_2->panose[j] = term->u.dbl;
- }
- }
- }
- // achVendID
- json_value *vendorid = NULL;
- if ((vendorid = json_obj_get_type(table, "achVendID", json_string))) {
- os_2->achVendID[0] = ' ';
- os_2->achVendID[1] = ' ';
- os_2->achVendID[2] = ' ';
- os_2->achVendID[3] = ' ';
- if (vendorid->u.string.length >= 4) {
- memcpy(os_2->achVendID, vendorid->u.string.ptr, 4);
- } else {
- memcpy(os_2->achVendID, vendorid->u.string.ptr, vendorid->u.string.length);
- }
- }
- }
- }
- if (os_2->version < 1) os_2->version = 1;
- return os_2;
-}
-
-caryll_Buffer *otfcc_buildOS_2(const table_OS_2 *os_2, const otfcc_Options *options) {
- if (!os_2) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, os_2->version);
- bufwrite16b(buf, os_2->xAvgCharWidth);
- bufwrite16b(buf, os_2->usWeightClass);
- bufwrite16b(buf, os_2->usWidthClass);
- bufwrite16b(buf, os_2->fsType);
- bufwrite16b(buf, os_2->ySubscriptXSize);
- bufwrite16b(buf, os_2->ySubscriptYSize);
- bufwrite16b(buf, os_2->ySubscriptXOffset);
- bufwrite16b(buf, os_2->ySubscriptYOffset);
- bufwrite16b(buf, os_2->ySupscriptXSize);
- bufwrite16b(buf, os_2->ySupscriptYSize);
- bufwrite16b(buf, os_2->ySupscriptXOffset);
- bufwrite16b(buf, os_2->ySupscriptYOffset);
- bufwrite16b(buf, os_2->yStrikeoutSize);
- bufwrite16b(buf, os_2->yStrikeoutPosition);
- bufwrite16b(buf, os_2->sFamilyClass);
- bufwrite_bytes(buf, 10, os_2->panose);
- bufwrite32b(buf, os_2->ulUnicodeRange1);
- bufwrite32b(buf, os_2->ulUnicodeRange2);
- bufwrite32b(buf, os_2->ulUnicodeRange3);
- bufwrite32b(buf, os_2->ulUnicodeRange4);
- bufwrite_bytes(buf, 4, os_2->achVendID);
- bufwrite16b(buf, os_2->fsSelection);
- bufwrite16b(buf, os_2->usFirstCharIndex);
- bufwrite16b(buf, os_2->usLastCharIndex);
- bufwrite16b(buf, os_2->sTypoAscender);
- bufwrite16b(buf, os_2->sTypoDescender);
- bufwrite16b(buf, os_2->sTypoLineGap);
- bufwrite16b(buf, os_2->usWinAscent);
- bufwrite16b(buf, os_2->usWinDescent);
- bufwrite32b(buf, os_2->ulCodePageRange1);
- bufwrite32b(buf, os_2->ulCodePageRange2);
- if (os_2->version < 2) return buf;
- bufwrite16b(buf, os_2->sxHeight);
- bufwrite16b(buf, os_2->sCapHeight);
- bufwrite16b(buf, os_2->usDefaultChar);
- bufwrite16b(buf, os_2->usBreakChar);
- bufwrite16b(buf, os_2->usMaxContext);
- if (os_2->version < 5) return buf;
- bufwrite16b(buf, os_2->usLowerOpticalPointSize);
- bufwrite16b(buf, os_2->usUpperOpticalPointSize);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.h
deleted file mode 100644
index 3bfdbdf63bd..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/OS_2.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_OS_2_H
-#define CARYLL_TABLE_OS_2_H
-
-#include "otfcc/table/OS_2.h"
-
-table_OS_2 *otfcc_readOS_2(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpOS_2(const table_OS_2 *table, json_value *root, const otfcc_Options *options);
-table_OS_2 *otfcc_parseOS_2(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildOS_2(const table_OS_2 *os_2, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.c
deleted file mode 100644
index 9862a0722ed..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.c
+++ /dev/null
@@ -1,150 +0,0 @@
-#include "SVG.h"
-
-#include "support/util.h"
-#include "bk/bkgraph.h"
-
-
-static INLINE void initSVGAssigment(svg_Assignment *a) {
- memset(a, 0, sizeof(*a));
-}
-static INLINE void copySVGAssigment(svg_Assignment *dst, const svg_Assignment *src) {
- dst->start = src->start;
- dst->end = src->end;
- dst->document = bufnew();
- bufwrite_buf(dst->document, src->document);
-}
-static INLINE void disposeSVGAssignment(svg_Assignment *a) {
- buffree(a->document);
-}
-caryll_standardValType(svg_Assignment, svg_iAssignment, initSVGAssigment, copySVGAssigment,
- disposeSVGAssignment);
-caryll_standardVectorImpl(table_SVG, svg_Assignment, svg_iAssignment, table_iSVG);
-
-table_SVG *otfcc_readSVG(const otfcc_Packet packet, const otfcc_Options *options) {
- table_SVG *svg = NULL;
- FOR_TABLE(OTFCC_CHR('S','V','G',' '), table) {
- if (table.length < 10) goto FAIL;
- uint32_t offsetToSVGDocIndex = read_32u(table.data + 2);
- if (table.length < offsetToSVGDocIndex + 2) goto FAIL;
- uint16_t numEntries = read_16u(table.data + offsetToSVGDocIndex);
- if (table.length < offsetToSVGDocIndex + 2 + 12 * numEntries) goto FAIL;
-
- svg = table_iSVG.create();
- for (glyphid_t j = 0; j < numEntries; j++) {
- font_file_pointer record = table.data + offsetToSVGDocIndex + 2 + 12 * j;
- svg_Assignment asg = svg_iAssignment.empty();
- asg.start = read_16u(record);
- asg.end = read_16u(record + 2);
- uint32_t docstart = read_32u(record + 4);
- uint32_t doclen = read_32u(record + 8);
- if (offsetToSVGDocIndex + docstart + doclen <= table.length) {
- asg.document = bufnew();
- bufwrite_bytes(asg.document, doclen, table.data + offsetToSVGDocIndex + docstart);
- } else {
- asg.document = bufnew();
- }
- table_iSVG.push(svg, asg);
- }
- return svg;
- FAIL:
- table_iSVG.dispose(svg);
- svg = NULL;
- }
- return svg;
-}
-
-static bool canUsePlainFormat(const caryll_Buffer *buf) {
- return (buf->size > 4 && buf->data[0] == '<' && buf->data[1] == 's' && buf->data[2] == 'v' &&
- buf->data[3] == 'g') // <svg
- || (buf->size > 5 && buf->data[0] == '<' && buf->data[1] == '?' && buf->data[2] == 'x' &&
- buf->data[3] == 'm' && buf->data[4] == 'l');
-}
-void otfcc_dumpSVG(const table_SVG *svg, json_value *root, const otfcc_Options *options) {
- if (!svg) return;
- loggedStep("SVG ") {
- json_value *_svg = json_array_new(svg->length);
- foreach (svg_Assignment *a, *svg) {
- json_value *_a = json_object_new(4);
- json_object_push(_a, "start", json_integer_new(a->start));
- json_object_push(_a, "end", json_integer_new(a->end));
- if (canUsePlainFormat(a->document)) {
- json_object_push(_a, "format", json_string_new("plain"));
- json_object_push(
- _a, "document",
- json_string_new_length((uint32_t)a->document->size, (char *)a->document->data));
- } else {
- size_t len = 0;
- uint8_t *buf = base64_encode(a->document->data, a->document->size, &len);
- json_object_push(_a, "format", json_string_new("base64"));
- json_object_push(_a, "document",
- json_string_new_length((uint32_t)len, (char *)buf));
- FREE(buf);
- }
- json_array_push(_svg, _a);
- }
- json_object_push(root, "SVG_", _svg);
- }
-}
-
-table_SVG *otfcc_parseSVG(const json_value *root, const otfcc_Options *options) {
- json_value *_svg = NULL;
- if (!(_svg = json_obj_get_type(root, "SVG_", json_array))) return NULL;
- table_SVG *svg = table_iSVG.create();
- loggedStep("SVG ") {
- for (glyphid_t j = 0; j < _svg->u.array.length; j++) {
- json_value *_a = _svg->u.array.values[j];
- if (!_a || _a->type != json_object) continue;
- const char *format = json_obj_getstr_share(_a, "format");
- sds doc = json_obj_getsds(_a, "document");
- if (!format || !doc) continue;
- svg_Assignment asg = svg_iAssignment.empty();
- asg.start = json_obj_getint(_a, "start");
- asg.end = json_obj_getint(_a, "end");
-
- if (strcmp(format, "plain") == 0) {
- asg.document = bufnew();
- bufwrite_bytes(asg.document, sdslen(doc), (uint8_t *)doc);
- sdsfree(doc);
- } else {
- asg.document = bufnew();
- size_t len = 0;
- uint8_t *buf = base64_encode((uint8_t *)doc, sdslen(doc), &len);
- bufwrite_bytes(asg.document, len, buf);
- FREE(buf);
- sdsfree(doc);
- }
- table_iSVG.push(svg, asg);
- }
- }
- return svg;
-}
-
-static int byStartGID(const svg_Assignment *a, const svg_Assignment *b) {
- return a->start - b->start;
-}
-
-caryll_Buffer *otfcc_buildSVG(const table_SVG *_svg, const otfcc_Options *options) {
- if (!_svg || !_svg->length) return NULL;
-
- // sort assignments
- table_SVG svg;
- table_iSVG.copy(&svg, _svg);
- table_iSVG.sort(&svg, byStartGID);
-
- bk_Block *major = bk_new_Block(b16, svg.length, // numEntries
- bkover);
- foreach (svg_Assignment *a, svg) {
- bk_push(major, // SVG Document Index Entry
- b16, a->start, // startGlyphID
- b16, a->end, // endGlyphID
- p32, bk_newBlockFromBufferCopy(a->document), // svgDocOffset
- b32, a->document->size, // svgDocLength
- bkover);
- }
- bk_Block *root = bk_new_Block(b16, 0, // Version
- p32, major, // offsetToSVGDocIndex
- b32, 0, // Reserved
- bkover);
- table_iSVG.dispose(&svg);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.h
deleted file mode 100644
index e5ee39bcca0..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/SVG.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_SVG_H
-#define CARYLL_TABLE_SVG_H
-
-#include "otfcc/table/SVG.h"
-
-table_SVG *otfcc_readSVG(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpSVG(const table_SVG *svg, json_value *root, const otfcc_Options *options);
-table_SVG *otfcc_parseSVG(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildSVG(const table_SVG *svg, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.c
deleted file mode 100644
index 727640e960f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "TSI5.h"
-#include "support/util.h"
-
-table_TSI5 *otfcc_readTSI5(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('T','S','I','5'), table) {
- table_TSI5 *tsi5 = otl_iClassDef.create();
- for (glyphid_t j = 0; j * 2 < table.length; j++) {
- otl_iClassDef.push(tsi5, Handle.fromIndex(j), read_16u(table.data + j * 2));
- }
- return tsi5;
- }
- return NULL;
-}
-void otfcc_dumpTSI5(const table_TSI5 *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- json_object_push(root, "TSI5", otl_iClassDef.dump(table));
-}
-table_TSI5 *otfcc_parseTSI5(const json_value *root, const otfcc_Options *options) {
- json_value *_tsi = NULL;
- if (!(_tsi = json_obj_get_type(root, "TSI5", json_object))) return NULL;
- return otl_iClassDef.parse(_tsi);
-}
-caryll_Buffer *otfcc_buildTSI5(const table_TSI5 *tsi5, const otfcc_Options *options,
- glyphid_t numGlyphs) {
- if (!tsi5) return NULL;
- uint16_t *tsi5cls;
- NEW_CLEAN_N(tsi5cls, numGlyphs);
- for (glyphid_t j = 0; j < tsi5->numGlyphs; j++) {
- if (tsi5->glyphs[j].index < numGlyphs) {
- tsi5cls[tsi5->glyphs[j].index] = tsi5->classes[j];
- }
- }
- caryll_Buffer *buf = bufnew();
- for (glyphid_t j = 0; j < numGlyphs; j++) {
- bufwrite16b(buf, tsi5cls[j]);
- }
- FREE(tsi5cls);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.h
deleted file mode 100644
index e0ff992cc41..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/TSI5.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_TSI5_H
-#define CARYLL_TABLE_TSI5_H
-
-#include "otfcc/table/TSI5.h"
-
-table_TSI5 *otfcc_readTSI5(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpTSI5(const table_TSI5 *table, json_value *root, const otfcc_Options *options);
-table_TSI5 *otfcc_parseTSI5(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildTSI5(const table_TSI5 *TSI, const otfcc_Options *options, glyphid_t numGlyphs);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VDMX.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VDMX.h
deleted file mode 100644
index e74d39d3e35..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VDMX.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_VDMX_H
-#define CARYLL_TABLE_VDMX_H
-
-#include "otfcc/table/VDMX.h"
-
-table_VDMX *otfcc_readVDMX(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpVDMX(const table_VDMX *table, json_value *root, const otfcc_Options *options);
-table_VDMX *otfcc_parseVDMX(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildVDMX(const table_VDMX *vdmx, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.c
deleted file mode 100644
index 9a669251478..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "VORG.h"
-
-#include "support/util.h"
-
-static INLINE void disposeVORG(table_VORG *vorg) {
- FREE(vorg->entries);
-}
-
-caryll_standardRefType(table_VORG, table_iVORG, disposeVORG);
-
-table_VORG *otfcc_readVORG(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('V','O','R','G'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- if (length < 8) goto VORG_CORRUPTED;
- uint16_t numVertOriginYMetrics = read_16u(data + 6);
- if (length < 8 + 4 * numVertOriginYMetrics) goto VORG_CORRUPTED;
-
- table_VORG *vorg = table_iVORG.create();
- vorg->defaultVerticalOrigin = read_16s(data + 4);
- vorg->numVertOriginYMetrics = numVertOriginYMetrics;
- NEW(vorg->entries, numVertOriginYMetrics);
- for (uint16_t j = 0; j < numVertOriginYMetrics; j++) {
- vorg->entries[j].gid = read_16u(data + 8 + 4 * j);
- vorg->entries[j].verticalOrigin = read_16s(data + 8 + 4 * j + 2);
- }
- return vorg;
- VORG_CORRUPTED:
- logWarning("Table 'VORG' corrupted.");
- }
- return NULL;
-}
-
-caryll_Buffer *otfcc_buildVORG(const table_VORG *table, const otfcc_Options *options) {
- if (!table) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, 1);
- bufwrite16b(buf, 0);
- bufwrite16b(buf, table->defaultVerticalOrigin);
- bufwrite16b(buf, table->numVertOriginYMetrics);
- for (uint16_t j = 0; j < table->numVertOriginYMetrics; j++) {
- bufwrite16b(buf, table->entries[j].gid);
- bufwrite16b(buf, table->entries[j].verticalOrigin);
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.h
deleted file mode 100644
index e9028df960d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/VORG.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef CARYLL_TABLE_VORG_H
-#define CARYLL_TABLE_VORG_H
-
-#include "otfcc/table/VORG.h"
-
-table_VORG *otfcc_readVORG(const otfcc_Packet packet, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildVORG(const table_VORG *table, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.c
deleted file mode 100644
index 24279cf03e7..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.c
+++ /dev/null
@@ -1,241 +0,0 @@
-#include "_TSI.h"
-#include "support/util.h"
-
-static INLINE void initTSIEntry(tsi_Entry *entry) {
- Handle.init(&entry->glyph);
- entry->type = TSI_GLYPH;
- entry->content = NULL;
-}
-static INLINE void copyTSIEntry(tsi_Entry *dst, const tsi_Entry *src) {
- Handle.copy(&dst->glyph, &src->glyph);
- dst->type = src->type;
- dst->content = sdsdup(src->content);
-}
-static INLINE void disposeTSIEntry(tsi_Entry *entry) {
- Handle.dispose(&entry->glyph);
- sdsfree(entry->content);
-}
-caryll_standardType(tsi_Entry, tsi_iEntry, initTSIEntry, copyTSIEntry, disposeTSIEntry);
-caryll_standardVectorImpl(table_TSI, tsi_Entry, tsi_iEntry, table_iTSI);
-
-static INLINE bool isValidGID(uint16_t gid, uint32_t tagIndex) {
- if (tagIndex == OTFCC_CHR('T','S','I','0')) {
- return gid != 0xFFFE && gid != 0xFFFC;
- } else {
- return gid < 0xFFFA;
- }
-}
-
-table_TSI *otfcc_readTSI(const otfcc_Packet packet, const otfcc_Options *options, uint32_t tagIndex,
- uint32_t tagText) {
- otfcc_PacketPiece textPart;
- textPart.tag = 0;
- otfcc_PacketPiece indexPart;
- indexPart.tag = 0;
- FOR_TABLE(tagIndex, tableIx) {
- indexPart = tableIx;
- }
- FOR_TABLE(tagText, tableTx) {
- textPart = tableTx;
- }
- if (!textPart.tag || !indexPart.tag) return NULL;
-
- table_TSI *tsi = table_iTSI.create();
- for (uint32_t j = 0; j * 8 < indexPart.length; j++) {
- uint16_t gid = read_16u(indexPart.data + j * 8);
- uint32_t textLength = read_16u(indexPart.data + j * 8 + 2);
- uint32_t textOffset = read_32u(indexPart.data + j * 8 + 4);
- if (!isValidGID(gid, tagIndex) || textOffset >= textPart.length || !textLength) continue;
- // acquire next valid entry to retreve length of text of this entry
- uint32_t predictedTextLength = textPart.length - textOffset;
- for (glyphid_t k = j + 1; k * 8 < indexPart.length; k++) {
- uint16_t gidK = read_16u(indexPart.data + k * 8);
- uint32_t textOffsetK = read_32u(indexPart.data + k * 8 + 4);
- if (gidK != 0xFFFE && textOffsetK < textPart.length && textOffsetK > textOffset) {
- predictedTextLength = textOffsetK - textOffset;
- break;
- }
- }
- if (textLength >= 0x8000) { textLength = predictedTextLength; }
- // push entry
- tsi_Entry entry;
- switch (gid) {
- case 0xFFFA:
- entry.type = TSI_PREP;
- Handle.init(&entry.glyph);
- break;
- case 0xFFFB:
- entry.type = TSI_CVT;
- Handle.init(&entry.glyph);
- break;
- case 0xFFFD:
- entry.type = TSI_FPGM;
- Handle.init(&entry.glyph);
- break;
- default:
- entry.type = TSI_GLYPH;
- entry.glyph = Handle.fromIndex(gid);
- break;
- }
- entry.content = sdsnewlen(textPart.data + textOffset, textLength);
- table_iTSI.push(tsi, entry);
- }
- return tsi;
-}
-
-void otfcc_dumpTSI(const table_TSI *tsi, json_value *root, const otfcc_Options *options,
- const char *tag) {
- if (!tsi) return;
- loggedStep("%s", tag) {
- json_value *_tsi = json_object_new(2);
- json_value *_glyphs = json_object_new(tsi->length);
- foreach (tsi_Entry *entry, *tsi) {
- if (entry->type != TSI_GLYPH) continue;
- json_object_push(
- _glyphs, entry->glyph.name,
- json_string_new_length((uint32_t)sdslen(entry->content), entry->content));
- }
-
- json_value *_extra = json_object_new(tsi->length);
- foreach (tsi_Entry *entry, *tsi) {
- if (entry->type == TSI_GLYPH) continue;
- const char *extraKey;
- switch (entry->type) {
- case TSI_CVT:
- extraKey = "cvt";
- break;
- case TSI_FPGM:
- extraKey = "fpgm";
- break;
- break;
- case TSI_PREP:
- extraKey = "prep";
- break;
- default:
- extraKey = "reserved";
- break;
- }
- json_object_push(
- _extra, extraKey,
- json_string_new_length((uint32_t)sdslen(entry->content), entry->content));
- }
- json_object_push(_tsi, "glyphs", _glyphs);
- json_object_push(_tsi, "extra", _extra);
- json_object_push(root, tag, _tsi);
- }
-}
-
-table_TSI *otfcc_parseTSI(const json_value *root, const otfcc_Options *options, const char *tag) {
- json_value *_tsi = NULL;
- if (!(_tsi = json_obj_get_type(root, tag, json_object))) return NULL;
- table_TSI *tsi = table_iTSI.create();
- loggedStep("%s", tag) {
- json_value *_glyphs = json_obj_get_type(_tsi, "glyphs", json_object);
- if (_glyphs) {
- for (uint32_t j = 0; j < _glyphs->u.object.length; j++) {
- char *_gid = _glyphs->u.object.values[j].name;
- size_t _gidlen = _glyphs->u.object.values[j].name_length;
- json_value *_content = _glyphs->u.object.values[j].value;
- if (!_content || _content->type != json_string) continue;
- table_iTSI.push(tsi, (tsi_Entry){.type = TSI_GLYPH,
- .glyph = Handle.fromName(sdsnewlen(_gid, _gidlen)),
- .content = sdsnewlen(_content->u.string.ptr,
- _content->u.string.length)});
- }
- }
- json_value *_extra = json_obj_get_type(_tsi, "extra", json_object);
- if (_extra) {
- for (uint32_t j = 0; j < _extra->u.object.length; j++) {
- char *_key = _extra->u.object.values[j].name;
- json_value *_content = _extra->u.object.values[j].value;
- if (!_content || _content->type != json_string) continue;
- if (strcmp(_key, "cvt") == 0) {
- table_iTSI.push(tsi,
- (tsi_Entry){.type = TSI_CVT,
- .glyph = Handle.empty(),
- .content = sdsnewlen(_content->u.string.ptr,
- _content->u.string.length)});
- } else if (strcmp(_key, "fpgm") == 0) {
- table_iTSI.push(tsi,
- (tsi_Entry){.type = TSI_FPGM,
- .glyph = Handle.empty(),
- .content = sdsnewlen(_content->u.string.ptr,
- _content->u.string.length)});
- } else if (strcmp(_key, "prep") == 0) {
- table_iTSI.push(tsi,
- (tsi_Entry){.type = TSI_PREP,
- .glyph = Handle.empty(),
- .content = sdsnewlen(_content->u.string.ptr,
- _content->u.string.length)});
- }
- }
- }
- }
- return tsi;
-}
-
-static glyphid_t propergid(tsi_Entry *entry, const tsi_EntryType type) {
- switch (type) {
- case TSI_CVT:
- return 0xFFFB;
- case TSI_FPGM:
- return 0xFFFD;
- case TSI_PREP:
- return 0xFFFA;
- case TSI_RESERVED_FFFC:
- return 0xFFFC;
- case TSI_GLYPH:
- return entry->glyph.index;
- default:
- fprintf(stderr,"! warning: propergid: unknown EntryType %u. Return 0x0.\n",type);
- return 0x0;
- }
-}
-
-static void pushTSIEntries(tsi_BuildTarget *target, const table_TSI *tsi, const tsi_EntryType type,
- const glyphid_t minN) {
- glyphid_t itemsPushed = 0;
- foreach (tsi_Entry *entry, *tsi) {
- if (entry->type != type) continue;
- size_t lengthSofar = target->textPart->cursor;
- bufwrite_sds(target->textPart, entry->content);
- size_t lengthAfter = target->textPart->cursor;
- bufwrite16b(target->indexPart, propergid(entry, type));
- if (lengthAfter - lengthSofar < 0x8000) {
- bufwrite16b(target->indexPart, lengthAfter - lengthSofar);
- } else {
- bufwrite16b(target->indexPart, 0x8000);
- }
- bufwrite32b(target->indexPart, (uint32_t)lengthSofar);
- itemsPushed += 1;
- }
- while (itemsPushed < minN) {
- bufwrite16b(target->indexPart, propergid(NULL, type));
- bufwrite16b(target->indexPart, 0x0000);
- bufwrite32b(target->indexPart, (uint32_t)target->textPart->cursor);
- itemsPushed += 1;
- }
-}
-
-tsi_BuildTarget otfcc_buildTSI(const table_TSI *tsi, const otfcc_Options *options) {
-
- tsi_BuildTarget target;
- if (!tsi) {
- target.textPart = NULL;
- target.indexPart = NULL;
- } else {
- target.textPart = bufnew();
- target.indexPart = bufnew();
-
- pushTSIEntries(&target, tsi, TSI_GLYPH, 0);
- // magic
- bufwrite16b(target.indexPart, 0xFFFE);
- bufwrite16b(target.indexPart, 0x0000);
- bufwrite32b(target.indexPart, 0xABFC1F34);
- pushTSIEntries(&target, tsi, TSI_PREP, 1);
- pushTSIEntries(&target, tsi, TSI_CVT, 1);
- pushTSIEntries(&target, tsi, TSI_RESERVED_FFFC, 1);
- pushTSIEntries(&target, tsi, TSI_FPGM, 1);
- }
- return target;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.h
deleted file mode 100644
index 3da7b6fdfa8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/_TSI.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef CARYLL_TABLE_TSI_H
-#define CARYLL_TABLE_TSI_H
-
-#include "otfcc/table/_TSI.h"
-
-table_TSI *otfcc_readTSI(const otfcc_Packet packet, const otfcc_Options *options, uint32_t tagIndex, uint32_t tagText);
-void otfcc_dumpTSI(const table_TSI *table, json_value *root, const otfcc_Options *options, const char *tag);
-table_TSI *otfcc_parseTSI(const json_value *root, const otfcc_Options *options, const char *tag);
-
-// TSI tables has two parts: an Index part and a Text part, so we need a struct.
-typedef struct {
- caryll_Buffer *indexPart;
- caryll_Buffer *textPart;
-} tsi_BuildTarget;
-
-tsi_BuildTarget otfcc_buildTSI(const table_TSI *TSI, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/all.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/all.h
deleted file mode 100644
index 2ac9d07f88f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/all.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef CARYLL_TABLES_ALL_H
-#define CARYLL_TABLES_ALL_H
-
-#include "table/fvar.h"
-
-#include "table/head.h"
-#include "table/glyf.h"
-#include "table/CFF.h"
-#include "table/maxp.h"
-#include "table/hhea.h"
-#include "table/hmtx.h"
-#include "table/hdmx.h"
-#include "table/vhea.h"
-#include "table/vmtx.h"
-#include "table/OS_2.h"
-#include "table/post.h"
-#include "table/name.h"
-#include "table/meta.h"
-
-#include "table/cmap.h"
-#include "table/cvt.h"
-#include "table/fpgm-prep.h"
-#include "table/gasp.h"
-#include "table/VDMX.h"
-
-#include "table/LTSH.h"
-#include "table/VORG.h"
-
-#include "table/GDEF.h"
-#include "table/BASE.h"
-#include "table/otl.h"
-
-#include "table/CPAL.h"
-#include "table/COLR.h"
-#include "table/SVG.h"
-#include "table/_TSI.h"
-#include "table/TSI5.h"
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.c
deleted file mode 100644
index 71518d36db2..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.c
+++ /dev/null
@@ -1,801 +0,0 @@
-#include "cmap.h"
-
-#include "support/util.h"
-#include "bk/bkgraph.h"
-
-// PART I, type definition
-
-static INLINE void initCmap(table_cmap *cmap) {
- cmap->unicodes = NULL;
- cmap->uvs = NULL;
-}
-static INLINE void disposeCmap(table_cmap *cmap) {
- { // Unicode
- cmap_Entry *s, *tmp;
- HASH_ITER(hh, cmap->unicodes, s, tmp) {
- // delete and free all cmap entries
- Handle.dispose(&s->glyph);
- HASH_DEL(cmap->unicodes, s);
- FREE(s);
- }
- }
- { // UVS
- cmap_UVS_Entry *s, *tmp;
- HASH_ITER(hh, cmap->uvs, s, tmp) {
- // delete and free all cmap entries
- Handle.dispose(&s->glyph);
- HASH_DEL(cmap->uvs, s);
- FREE(s);
- }
- }
-}
-caryll_standardRefTypeFn(table_cmap, initCmap, disposeCmap);
-
-static bool otfcc_encodeCmapByIndex(table_cmap *cmap, int c, uint16_t gid) {
- cmap_Entry *s;
- HASH_FIND_INT(cmap->unicodes, &c, s);
- if (s == NULL) {
- NEW(s);
- s->glyph = Handle.fromIndex(gid);
- s->unicode = c;
- HASH_ADD_INT(cmap->unicodes, unicode, s);
- return true;
- } else {
- return false;
- }
-}
-static bool otfcc_encodeCmapByName(table_cmap *cmap, int c, sds name) {
- cmap_Entry *s;
- HASH_FIND_INT(cmap->unicodes, &c, s);
- if (s == NULL) {
- NEW(s);
- s->glyph = Handle.fromName(name);
- s->unicode = c;
- HASH_ADD_INT(cmap->unicodes, unicode, s);
- return true;
- } else {
- return false;
- }
-}
-static bool otfcc_unmapCmap(table_cmap *cmap, int c) {
- cmap_Entry *s;
- HASH_FIND_INT(cmap->unicodes, &c, s);
- if (s) {
- Handle.dispose(&s->glyph);
- HASH_DEL(cmap->unicodes, s);
- FREE(s);
- return true;
- } else {
- return false;
- }
-}
-
-static otfcc_GlyphHandle *otfcc_cmapLookup(const table_cmap *cmap, int c) {
- cmap_Entry *s;
- HASH_FIND_INT(cmap->unicodes, &c, s);
- if (s) {
- return &(s->glyph);
- } else {
- return NULL;
- }
-}
-
-static bool otfcc_encodeCmapUVSByIndex(table_cmap *cmap, cmap_UVS_key c, uint16_t gid) {
- cmap_UVS_Entry *s;
- HASH_FIND(hh, cmap->uvs, &c, sizeof(cmap_UVS_key), s);
- if (s == NULL) {
- NEW(s);
- s->glyph = Handle.fromIndex(gid);
- s->key = c;
- HASH_ADD(hh, cmap->uvs, key, sizeof(cmap_UVS_key), s);
- return true;
- } else {
- return false;
- }
-}
-static bool otfcc_encodeCmapUVSByName(table_cmap *cmap, cmap_UVS_key c, sds name) {
- cmap_UVS_Entry *s;
- HASH_FIND(hh, cmap->uvs, &c, sizeof(cmap_UVS_key), s);
- if (s == NULL) {
- NEW(s);
- s->glyph = Handle.fromName(name);
- s->key = c;
- HASH_ADD(hh, cmap->uvs, key, sizeof(cmap_UVS_key), s);
- return true;
- } else {
- return false;
- }
-}
-static bool otfcc_unmapCmapUVS(table_cmap *cmap, cmap_UVS_key c) {
- cmap_Entry *s;
- HASH_FIND(hh, cmap->uvs, &c, sizeof(cmap_UVS_key), s);
- if (s) {
- Handle.dispose(&s->glyph);
- HASH_DEL(cmap->uvs, s);
- FREE(s);
- return true;
- } else {
- return false;
- }
-}
-
-static otfcc_GlyphHandle *otfcc_cmapLookupUVS(const table_cmap *cmap, cmap_UVS_key c) {
- cmap_Entry *s;
- HASH_FIND(hh, cmap->uvs, &c, sizeof(cmap_UVS_key), s);
- if (s) {
- return &(s->glyph);
- } else {
- return NULL;
- }
-}
-
-caryll_ElementInterfaceOf(table_cmap) table_iCmap = {caryll_standardRefTypeMethods(table_cmap),
- .encodeByIndex = otfcc_encodeCmapByIndex,
- .encodeByName = otfcc_encodeCmapByName,
- .unmap = otfcc_unmapCmap,
- .lookup = otfcc_cmapLookup,
- .encodeUVSByIndex = otfcc_encodeCmapUVSByIndex,
- .encodeUVSByName = otfcc_encodeCmapUVSByName,
- .unmapUVS = otfcc_unmapCmapUVS,
- .lookupUVS = otfcc_cmapLookupUVS};
-
-// PART II, reading and writing
-
-static void readFormat12(font_file_pointer start, uint32_t lengthLimit, table_cmap *cmap) {
- if (lengthLimit < 16) return;
- uint32_t nGroups = read_32u(start + 12);
- if (lengthLimit < 16 + 12 * nGroups) return;
- for (uint32_t j = 0; j < nGroups; j++) {
- uint32_t startCode = read_32u(start + 16 + 12 * j);
- uint32_t endCode = read_32u(start + 16 + 12 * j + 4);
- uint32_t startGID = read_32u(start + 16 + 12 * j + 8);
- for (uint32_t c = startCode; c <= endCode; c++) {
- otfcc_encodeCmapByIndex(cmap, c, (c - startCode) + startGID);
- }
- }
-}
-
-static void readFormat4(font_file_pointer start, uint32_t lengthLimit, table_cmap *cmap) {
- if (lengthLimit < 14) return;
- uint16_t segmentsCount = read_16u(start + 6) / 2;
- if (lengthLimit < 16 + segmentsCount * 8) return;
- for (uint16_t j = 0; j < segmentsCount; j++) {
- uint16_t endCode = read_16u(start + 14 + j * 2);
- uint16_t startCode = read_16u(start + 14 + segmentsCount * 2 + 2 + j * 2);
- int16_t idDelta = read_16u(start + 14 + segmentsCount * 4 + 2 + j * 2);
- uint32_t idRangeOffsetOffset = 14 + segmentsCount * 6 + 2 + j * 2;
- uint16_t idRangeOffset = read_16u(start + idRangeOffsetOffset);
- if (idRangeOffset == 0) {
- for (uint32_t c = startCode; c < 0xFFFF && c <= endCode; c++) {
- uint16_t gid = (c + idDelta) & 0xFFFF;
- otfcc_encodeCmapByIndex(cmap, c, gid);
- }
- } else {
- for (uint32_t c = startCode; c < 0xFFFF && c <= endCode; c++) {
- uint32_t glyphOffset = idRangeOffset + (c - startCode) * 2 + idRangeOffsetOffset;
- if (glyphOffset + 2 > lengthLimit) continue; // ignore this encoding slot when o-o-r
- uint16_t gid = (read_16u(start + glyphOffset) + idDelta) & 0xFFFF;
- otfcc_encodeCmapByIndex(cmap, c, gid);
- }
- }
- }
-}
-static void readUVSDefault(font_file_pointer start, uint32_t lengthLimit, unicode_t selector,
- table_cmap *cmap) {
- if (lengthLimit < 4) return;
- uint32_t numUnicodeValueRanges = read_32u(start);
- if (lengthLimit < 4 + 4 * numUnicodeValueRanges) return;
- for (uint32_t j = 0; j < numUnicodeValueRanges; j++) {
- font_file_pointer vsr = start + 4 + 4 * j;
- unicode_t startUnicodeValue = read_24u(vsr);
- uint8_t additionalCount = read_8u(vsr + 3);
- for (unicode_t u = startUnicodeValue; u <= startUnicodeValue + additionalCount; u++) {
- otfcc_GlyphHandle *g = table_iCmap.lookup(cmap, (int)u);
- if (!g) continue;
- table_iCmap.encodeUVSByIndex(cmap, (cmap_UVS_key){.unicode = u, .selector = selector},
- g->index);
- }
- }
-}
-static void readUVSNonDefault(font_file_pointer start, uint32_t lengthLimit, unicode_t selector,
- table_cmap *cmap) {
- if (lengthLimit < 4) return;
- uint32_t numUVSMappings = read_32u(start);
- if (lengthLimit < 4 + 5 * numUVSMappings) return;
- for (uint32_t j = 0; j < numUVSMappings; j++) {
- font_file_pointer vsr = start + 4 + 5 * j;
- unicode_t unicodeValue = read_24u(vsr);
- glyphid_t glyphID = read_16u(vsr + 3);
- table_iCmap.encodeUVSByIndex(
- cmap, (cmap_UVS_key){.unicode = unicodeValue, .selector = selector}, glyphID);
- }
-}
-static void readFormat14(font_file_pointer start, uint32_t lengthLimit, table_cmap *cmap) {
- if (lengthLimit < 10) return;
- uint32_t nGroups = read_32u(start + 6);
- if (lengthLimit < 11 + 11 * nGroups) return;
- for (uint32_t j = 0; j < nGroups; j++) {
- font_file_pointer vsr = start + 10 + 11 * j;
- unicode_t selector = read_24u(vsr);
- uint32_t defaultUVSOffset = read_32u(vsr + 3);
- uint32_t nonDefaultUVSOffset = read_32u(vsr + 7);
-
- if (defaultUVSOffset) {
- readUVSDefault(start + defaultUVSOffset, lengthLimit - defaultUVSOffset, selector,
- cmap);
- }
- if (nonDefaultUVSOffset) {
- readUVSNonDefault(start + nonDefaultUVSOffset, lengthLimit - nonDefaultUVSOffset,
- selector, cmap);
- }
- }
-}
-
-static void readCmapMappingTable(font_file_pointer start, uint32_t lengthLimit, table_cmap *cmap,
- tableid_t requiredFormat) {
- uint16_t format = read_16u(start);
- if (format == requiredFormat) {
- if (format == 4) {
- readFormat4(start, lengthLimit, cmap);
- } else if (format == 12) {
- readFormat12(start, lengthLimit, cmap);
- }
- }
-}
-
-static void readCmapMappingTableUVS(font_file_pointer start, uint32_t lengthLimit,
- table_cmap *cmap) {
- uint16_t format = read_16u(start);
- if (format == 14) { readFormat14(start, lengthLimit, cmap); }
-}
-
-static int by_unicode(cmap_Entry *a, cmap_Entry *b) {
- return (a->unicode - b->unicode);
-}
-
-static int by_uvs_key(cmap_UVS_Entry *a, cmap_UVS_Entry *b) {
- if (a->key.unicode == b->key.unicode) {
- return a->key.selector - b->key.selector;
- } else {
- return a->key.unicode - b->key.unicode;
- }
-}
-
-static INLINE bool isValidCmapEncoding(uint16_t platform, uint16_t encoding) {
- return (platform == 0 && encoding == 3) || (platform == 0 && encoding == 4) ||
- (platform == 0 && encoding == 5) || (platform == 3 && encoding == 1) ||
- (platform == 3 && encoding == 10);
-}
-
-// Note: we do not support Apple's format 0 subtable
-// since we not never support legacy fonts.
-const tableid_t formatPriorities[] = {12, 4, 0};
-
-// OTFCC will not support all `cmap` mappings.
-table_cmap *otfcc_readCmap(const otfcc_Packet packet, const otfcc_Options *options) {
- // the map is a reference to a hash table
- table_cmap *cmap = NULL;
- FOR_TABLE(OTFCC_CHR('c','m','a','p'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- if (length < 4) goto CMAP_CORRUPTED;
-
- cmap = table_iCmap.create(); // intialize to empty hashtable
- uint16_t numTables = read_16u(data + 2);
- if (length < 4 + 8 * numTables) goto CMAP_CORRUPTED;
-
- // step 1 : read format 12. The results are prioritized
- for (size_t kSubtableType = 0; formatPriorities[kSubtableType]; kSubtableType++) {
- for (uint16_t j = 0; j < numTables; j++) {
- uint16_t platform = read_16u(data + 4 + 8 * j);
- uint16_t encoding = read_16u(data + 4 + 8 * j + 2);
- if (!isValidCmapEncoding(platform, encoding)) continue;
-
- uint32_t tableOffset = read_32u(data + 4 + 8 * j + 4);
- readCmapMappingTable(data + tableOffset, length - tableOffset, cmap,
- formatPriorities[kSubtableType]);
- };
- }
- HASH_SORT(cmap->unicodes, by_unicode);
-
- // step 3 : read format 14
- for (uint16_t j = 0; j < numTables; j++) {
- uint16_t platform = read_16u(data + 4 + 8 * j);
- uint16_t encoding = read_16u(data + 4 + 8 * j + 2);
- if (!isValidCmapEncoding(platform, encoding)) continue;
-
- uint32_t tableOffset = read_32u(data + 4 + 8 * j + 4);
- readCmapMappingTableUVS(data + tableOffset, length - tableOffset, cmap);
- };
- HASH_SORT(cmap->uvs, by_uvs_key);
- return cmap;
-
- CMAP_CORRUPTED:
- logWarning("table 'cmap' corrupted.\n");
- if (cmap != NULL) { FREE(cmap), cmap = NULL; }
- }
- return NULL;
-}
-
-void otfcc_dumpCmap(const table_cmap *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("cmap") {
- if (table->unicodes) {
- json_value *cmap = json_object_new(HASH_COUNT(table->unicodes));
- cmap_Entry *item;
- foreach_hash(item, table->unicodes) if (item->glyph.name) {
- sds key;
- if (options->decimal_cmap) {
- key = sdsfromlonglong(item->unicode);
- } else {
- key = sdscatprintf(sdsempty(), "U+%04X", item->unicode);
- }
- json_object_push(
- cmap, key,
- json_string_new_length((uint32_t)sdslen(item->glyph.name), item->glyph.name));
- sdsfree(key);
- }
- json_object_push(root, "cmap", cmap);
- }
- if (table->uvs) {
- json_value *uvs = json_object_new(HASH_COUNT(table->uvs));
- cmap_UVS_Entry *item;
- foreach_hash(item, table->uvs) if (item->glyph.name) {
- sds key;
- if (options->decimal_cmap) {
- key = sdscatprintf(sdsempty(), "%d %d", item->key.unicode, item->key.selector);
- } else {
- key = sdscatprintf(sdsempty(), "U+%04X U+%04X", item->key.unicode,
- item->key.selector);
- }
- json_object_push(
- uvs, key,
- json_string_new_length((uint32_t)sdslen(item->glyph.name), item->glyph.name));
- sdsfree(key);
- }
- json_object_push(root, "cmap_uvs", uvs);
- }
- }
-}
-
-static INLINE unicode_t parseUnicode(const sds unicodeStr) {
- if (sdslen(unicodeStr) > 2 && unicodeStr[0] == 'U' && unicodeStr[1] == '+') {
- return strtol(unicodeStr + 2, NULL, 16);
- } else {
- return atoi(unicodeStr);
- }
-}
-
-static void parseCmapUnicodes(table_cmap *cmap, const json_value *table,
- const otfcc_Options *options) {
- if (!table || table->type != json_object) return;
- for (uint32_t j = 0; j < table->u.object.length; j++) {
- sds unicodeStr =
- sdsnewlen(table->u.object.values[j].name, table->u.object.values[j].name_length);
- json_value *item = table->u.object.values[j].value;
- unicode_t unicode = parseUnicode(unicodeStr);
- sdsfree(unicodeStr);
- if (item->type == json_string && unicode > 0 && unicode <= 0x10FFFF) {
- sds gname = sdsnewlen(item->u.string.ptr, item->u.string.length);
- if (!otfcc_encodeCmapByName(cmap, unicode, gname)) {
- glyph_handle *currentMap = otfcc_cmapLookup(cmap, unicode);
- logWarning("U+%04X is already mapped to %s. Assignment to %s is ignored.", unicode,
- currentMap->name, gname);
- }
- }
- }
-}
-
-static INLINE cmap_UVS_key parseUVSKey(const sds uvsStr) {
- size_t len = sdslen(uvsStr);
- cmap_UVS_key k = {.unicode = 0, .selector = 0};
- for (sds scan = uvsStr; scan < uvsStr + len; scan++) {
- if (*scan == ' ') {
- k.unicode = parseUnicode(uvsStr);
- k.selector = parseUnicode(scan + 1);
- return k;
- }
- }
- return k;
-}
-
-static void parseCmapUVS(table_cmap *cmap, const json_value *table, const otfcc_Options *options) {
- if (!table || table->type != json_object) return;
- for (uint32_t j = 0; j < table->u.object.length; j++) {
- sds uvsStr =
- sdsnewlen(table->u.object.values[j].name, table->u.object.values[j].name_length);
- cmap_UVS_key k = parseUVSKey(uvsStr);
- json_value *item = table->u.object.values[j].value;
- if (item->type == json_string && k.unicode > 0 && k.unicode <= 0x10FFFF && k.selector > 0 &&
- k.selector <= 0x10FFFF) {
- sds gname = sdsnewlen(item->u.string.ptr, item->u.string.length);
- if (!otfcc_encodeCmapUVSByName(cmap, k, gname)) {
- glyph_handle *currentMap = otfcc_cmapLookupUVS(cmap, k);
- logWarning(
- "UVS U+%04X U+%04X is already mapped to %s. Assignment to %s is ignored.",
- k.unicode, k.selector, currentMap->name, gname);
- }
- }
- }
-}
-
-table_cmap *otfcc_parseCmap(const json_value *root, const otfcc_Options *options) {
- if (root->type != json_object) return NULL;
- table_cmap *cmap = table_iCmap.create();
- loggedStep("cmap") {
- parseCmapUnicodes(cmap, json_obj_get_type(root, "cmap", json_object), options);
- }
- loggedStep("cmap_uvs") {
- parseCmapUVS(cmap, json_obj_get_type(root, "cmap_uvs", json_object), options);
- }
-
- HASH_SORT(cmap->unicodes, by_unicode);
- HASH_SORT(cmap->uvs, by_uvs_key);
-
- return cmap;
-}
-// writing tables
-#define FLUSH_SEQUENCE_FORMAT_4 \
- bufwrite16b(endCount, lastUnicodeEnd); \
- bufwrite16b(startCount, lastUnicodeStart); \
- if (isSequencial) { \
- bufwrite16b(idDelta, lastGIDStart - lastUnicodeStart); \
- bufwrite16b(idRangeOffset, 0); \
- } else { \
- bufwrite16b(idDelta, 0); \
- bufwrite16b(idRangeOffset, lastGlyphIdArrayOffset + 1); \
- } \
- segmentsCount += 1;
-
-static caryll_Buffer *otfcc_buildCmap_format4(const table_cmap *cmap) {
- caryll_Buffer *buf = bufnew();
- caryll_Buffer *endCount = bufnew();
- caryll_Buffer *startCount = bufnew();
- caryll_Buffer *idDelta = bufnew();
- caryll_Buffer *idRangeOffset = bufnew();
- caryll_Buffer *glyphIdArray = bufnew();
-
- bool started = false;
- int lastUnicodeStart = 0xFFFFFF;
- int lastUnicodeEnd = 0xFFFFFF;
- int lastGIDStart = 0xFFFFFF;
- int lastGIDEnd = 0xFFFFFF;
- size_t lastGlyphIdArrayOffset = 0;
- bool isSequencial = true;
- uint16_t segmentsCount = 0;
-
- cmap_Entry *item;
- foreach_hash(item, cmap->unicodes) if (item->unicode <= 0xFFFF) {
- if (!started) {
- started = true;
- lastUnicodeStart = lastUnicodeEnd = item->unicode;
- lastGIDStart = lastGIDEnd = item->glyph.index;
- isSequencial = true;
- } else {
- if (item->unicode == lastUnicodeEnd + 1 &&
- !(item->glyph.index != lastGIDEnd + 1 && isSequencial &&
- lastGIDEnd - lastGIDStart >= 4)) {
- if (isSequencial && !(item->glyph.index == lastGIDEnd + 1)) {
- lastGlyphIdArrayOffset = glyphIdArray->cursor;
- // oops, sequencial glyphid broken
- for (int j = lastGIDStart; j <= lastGIDEnd; j++) {
- bufwrite16b(glyphIdArray, j);
- }
- }
- lastUnicodeEnd = item->unicode;
- isSequencial = isSequencial && (item->glyph.index == lastGIDEnd + 1);
- lastGIDEnd = item->glyph.index;
- if (!isSequencial) { bufwrite16b(glyphIdArray, lastGIDEnd); }
- } else {
- // we have a segment
- FLUSH_SEQUENCE_FORMAT_4;
-
- lastUnicodeStart = lastUnicodeEnd = item->unicode;
- lastGIDStart = lastGIDEnd = item->glyph.index;
- isSequencial = true;
- }
- }
- }
-
- FLUSH_SEQUENCE_FORMAT_4;
- if (lastGIDEnd < 0xFFFF) {
- // Add a padding segment to end this subtable
- bufwrite16b(endCount, 0xFFFF);
- bufwrite16b(startCount, 0xFFFF);
- bufwrite16b(idDelta, 1);
- bufwrite16b(idRangeOffset, 0);
- segmentsCount += 1;
- }
-
- for (int j = 0; j < segmentsCount; j++) {
- // rewrite idRangeOffset
- uint16_t ro = read_16u((uint8_t *)idRangeOffset->data + j * 2);
- if (ro) {
- ro -= 1;
- ro += 2 * (segmentsCount - j);
- bufseek(idRangeOffset, 2 * j);
- bufwrite16b(idRangeOffset, ro);
- }
- }
-
- bufwrite16b(buf, 4);
- bufwrite16b(buf, 0); // fill later
- bufwrite16b(buf, 0);
- bufwrite16b(buf, segmentsCount << 1);
- uint32_t i;
- uint32_t j;
- for (j = 0, i = 1; i <= segmentsCount; ++j) {
- i <<= 1;
- }
- bufwrite16b(buf, i);
- bufwrite16b(buf, j - 1);
- bufwrite16b(buf, 2 * segmentsCount - i);
- bufwrite_buf(buf, endCount);
- bufwrite16b(buf, 0);
- bufwrite_buf(buf, startCount);
- bufwrite_buf(buf, idDelta);
- bufwrite_buf(buf, idRangeOffset);
- bufwrite_buf(buf, glyphIdArray);
-
- bufseek(buf, 2);
- bufwrite16b(buf, buflen(buf));
-
- buffree(endCount);
- buffree(startCount);
- buffree(idDelta);
- buffree(idRangeOffset);
- buffree(glyphIdArray);
- return buf;
-}
-
-static caryll_Buffer *otfcc_tryBuildCmap_format4(const table_cmap *cmap) {
- caryll_Buffer *buf = otfcc_buildCmap_format4(cmap);
- if (buflen(buf) > UINT16_MAX) {
- // this cmap subtable is broken
- buffree(buf);
- return NULL;
- } else
- return buf;
-}
-
-static caryll_Buffer *otfcc_buildCmap_format12(const table_cmap *cmap) {
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, 12);
- bufwrite16b(buf, 0);
- bufwrite32b(buf, 0); // fill later
- bufwrite32b(buf, 0);
- bufwrite32b(buf, 0); // fill later
-
- uint32_t nGroups = 0;
- bool started = false;
- int lastUnicodeStart = 0xFFFFFF;
- int lastUnicodeEnd = 0xFFFFFF;
- int lastGIDStart = 0xFFFFFF;
- int lastGIDEnd = 0xFFFFFF;
- cmap_Entry *item;
- foreach_hash(item, cmap->unicodes) {
- if (!started) {
- started = true;
- lastUnicodeStart = lastUnicodeEnd = item->unicode;
- lastGIDStart = lastGIDEnd = item->glyph.index;
- } else if (item->unicode == lastUnicodeEnd + 1 && item->glyph.index == lastGIDEnd + 1) {
- lastUnicodeEnd = item->unicode;
- lastGIDEnd = item->glyph.index;
- } else {
- bufwrite32b(buf, lastUnicodeStart);
- bufwrite32b(buf, lastUnicodeEnd);
- bufwrite32b(buf, lastGIDStart);
- nGroups += 1;
- lastUnicodeStart = lastUnicodeEnd = item->unicode;
- lastGIDStart = lastGIDEnd = item->glyph.index;
- }
- }
- bufwrite32b(buf, lastUnicodeStart);
- bufwrite32b(buf, lastUnicodeEnd);
- bufwrite32b(buf, lastGIDStart);
- nGroups += 1;
-
- bufseek(buf, 4);
- bufwrite32b(buf, (uint32_t)buflen(buf));
- bufseek(buf, 12);
- bufwrite32b(buf, nGroups);
- return buf;
-}
-
-#define MAX_UNICODE 0x110001
-#define HAS_DEFAULT 1
-#define HAS_NON_DEFAULT 2
-
-static INLINE void writeDefaultRange(caryll_Buffer *dflt, uint32_t *nRanges, unicode_t start,
- unicode_t end) {
- // start and end are inclusive
- while (end - start > 0xFF) {
- bufwrite24b(dflt, start);
- bufwrite8(dflt, 0xFF);
- start += 0x100;
- *nRanges += 1;
- }
- bufwrite24b(dflt, start);
- bufwrite8(dflt, end - start);
- *nRanges += 1;
-}
-
-static uint8_t buildFormat14ForSelector(const table_cmap *cmap, unicode_t selector,
- caryll_Buffer *dflt, caryll_Buffer *nondflt) {
- glyphid_t *defaults, *nonDefaults;
- NEW_CLEAN_N(defaults, MAX_UNICODE);
- NEW_CLEAN_N(nonDefaults, MAX_UNICODE);
- for (unicode_t s = 0; s < MAX_UNICODE; s++) {
- defaults[s] = 0xFFFF;
- nonDefaults[s] = 0xFFFF;
- }
- cmap_UVS_Entry *item;
- foreach_hash(item, cmap->uvs) {
- unicode_t u = item->key.unicode;
- if (item->key.selector != selector || u >= MAX_UNICODE) continue;
- if (!item->glyph.name) continue;
- glyphid_t uvsGID = item->glyph.index;
- otfcc_GlyphHandle *g = table_iCmap.lookup(cmap, (int)u);
- if (!g) {
- nonDefaults[u] = uvsGID;
- } else if (uvsGID == g->index) {
- defaults[u] = uvsGID;
- } else {
- nonDefaults[u] = uvsGID;
- }
- }
-
- defaults[0] = nonDefaults[0] = 0xFFFF; // clear U+0000
- defaults[MAX_UNICODE - 1] = nonDefaults[MAX_UNICODE - 1] = 0xFFFF; // clear U+110000 *
-
- uint32_t numUnicodeValueRanges = 0;
- unicode_t startUnicodeValue = 0;
- uint32_t numUVSMappings = 0;
- bufwrite32b(dflt, 0);
- bufwrite32b(nondflt, 0);
- for (unicode_t u = 1; u < MAX_UNICODE; u++) {
- if (defaults[u] != 0xFFFF && defaults[u - 1] == 0xFFFF) { startUnicodeValue = u; }
- if (defaults[u] == 0xFFFF && defaults[u - 1] != 0xFFFF) {
- writeDefaultRange(dflt, &numUnicodeValueRanges, startUnicodeValue, u - 1);
- }
- // non-defaults
- if (nonDefaults[u] != 0xFFFF) {
- bufwrite24b(nondflt, u);
- bufwrite16b(nondflt, nonDefaults[u]);
- numUVSMappings++;
- }
- }
- bufseek(dflt, 0);
- bufwrite32b(dflt, numUnicodeValueRanges);
- bufseek(nondflt, 0);
- bufwrite32b(nondflt, numUVSMappings);
-
- FREE(defaults);
- FREE(nonDefaults);
-
- return (numUnicodeValueRanges ? HAS_DEFAULT : 0) | (numUVSMappings ? HAS_NON_DEFAULT : 0);
-}
-
-static caryll_Buffer *otfcc_buildCmap_format14(const table_cmap *cmap) {
- bool *validSelectors;
- NEW_CLEAN_N(validSelectors, MAX_UNICODE);
- cmap_UVS_Entry *item;
- foreach_hash(item, cmap->uvs) {
- if (item->key.selector < MAX_UNICODE) { validSelectors[item->key.selector] = true; }
- }
- uint32_t nSelectors = 0;
- for (unicode_t selector = 0; selector < MAX_UNICODE; selector++) {
- if (!validSelectors[selector]) continue;
- nSelectors++;
- }
-
- bk_Block *st = bk_new_Block(b16, 14, // format
- b32, 0, // length -- fill later
- b32, nSelectors, // selector quantity
- bkover);
-
- for (unicode_t selector = 0; selector < MAX_UNICODE; selector++) {
- if (!validSelectors[selector]) continue;
- caryll_Buffer *dflt = bufnew();
- caryll_Buffer *nondflt = bufnew();
- uint8_t results = buildFormat14ForSelector(cmap, selector, dflt, nondflt);
- if (!(results & HAS_DEFAULT)) {
- buffree(dflt);
- dflt = NULL;
- }
- if (!(results & HAS_NON_DEFAULT)) {
- buffree(nondflt);
- nondflt = NULL;
- }
- bk_push(st, b8, (selector >> 16) & 0xFF, // selector, first byte
- b8, (selector >> 8) & 0xFF, // selector, first byte
- b8, (selector >> 0) & 0xFF, // selector, first byte
- p32, bk_newBlockFromBuffer(dflt), // default offset
- p32, bk_newBlockFromBuffer(nondflt), // non-default offset
- bkover);
- }
-
- caryll_Buffer *buf = bk_build_Block(st);
- bufseek(buf, 2);
- bufwrite32b(buf, (uint32_t)buflen(buf));
- return buf;
-}
-
-caryll_Buffer *otfcc_buildCmap(const table_cmap *cmap, const otfcc_Options *options) {
- if (!cmap || !cmap->unicodes) return NULL;
-
- cmap_Entry *entry;
- bool requiresFormat12 = false;
- bool hasUVS = cmap->uvs && (HASH_COUNT(cmap->uvs) > 0);
- foreach_hash(entry, cmap->unicodes) {
- if (entry->unicode > 0xFFFF) { requiresFormat12 = true; }
- }
-
- caryll_Buffer *format4 = NULL;
- if (!requiresFormat12 || !options->stub_cmap4) {
- format4 = otfcc_tryBuildCmap_format4(cmap);
- if (!format4)
- requiresFormat12 = true;
- }
-
- uint8_t nTables = requiresFormat12 ? 4 : 2;
- if (hasUVS) nTables += 1;
-
- if (!format4) {
- // Write a dummy
- format4 = bufnew();
- bufwrite16b(format4, 4); // format
- bufwrite16b(format4, 32); // length
- bufwrite16b(format4, 0); // language
- bufwrite16b(format4, 4); // segCountX2
- bufwrite16b(format4, 4); // searchRange
- bufwrite16b(format4, 1); // entrySelector
- bufwrite16b(format4, 0); // rangeShift
- bufwrite16b(format4, 0); // endCount
- bufwrite16b(format4, 0xFFFF); // endCount
- bufwrite16b(format4, 0); // endCount
- bufwrite16b(format4, 0); // startCount
- bufwrite16b(format4, 0xFFFF); // startCount
- bufwrite16b(format4, 0); // idDelta
- bufwrite16b(format4, 1); // idDelta
- bufwrite16b(format4, 0); // idRangeOffset
- bufwrite16b(format4, 0); // idRangeOffset
- }
-
- caryll_Buffer *format12 = otfcc_buildCmap_format12(cmap);
-
- bk_Block *root = bk_new_Block(b16, 0, // version
- b16, nTables, // nTables
- bkover);
- bk_push(root, b16, 0, // unicode
- b16, 3, // BMP
- p32, bk_newBlockFromBufferCopy(format4), // table
- bkover);
- if (requiresFormat12) {
- bk_push(root, b16, 0, // unicode
- b16, 4, // full
- p32, bk_newBlockFromBufferCopy(format12), // table
- bkover);
- }
- if (hasUVS) {
- caryll_Buffer *format14 = otfcc_buildCmap_format14(cmap);
- bk_push(root, b16, 0, // Unicode
- b16, 5, // Variation
- p32, bk_newBlockFromBuffer(format14), // table
- bkover);
- }
- bk_push(root, b16, 3, // Windows
- b16, 1, // Unicode BMP
- p32, bk_newBlockFromBufferCopy(format4), // table
- bkover);
- if (requiresFormat12) {
- bk_push(root, b16, 3, // Windows
- b16, 10, // Unicode Full
- p32, bk_newBlockFromBufferCopy(format12), // table
- bkover);
- }
-
- buffree(format4);
- buffree(format12);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.h
deleted file mode 100644
index e358527ff18..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cmap.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_CMAP_H
-#define CARYLL_TABLE_CMAP_H
-
-#include "otfcc/table/cmap.h"
-
-table_cmap *otfcc_readCmap(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpCmap(const table_cmap *cmap, json_value *root, const otfcc_Options *options);
-table_cmap *otfcc_parseCmap(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildCmap(const table_cmap *cmap, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.c
deleted file mode 100644
index 7370886d183..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "cvt.h"
-
-#include "support/util.h"
-
-static INLINE void disposeCvt(MOVE table_cvt *table) {
- if (table->words) FREE(table->words);
-}
-
-caryll_standardRefType(table_cvt, table_iCvt, disposeCvt);
-
-table_cvt *otfcc_readCvt(const otfcc_Packet packet, const otfcc_Options *options, uint32_t tag) {
- table_cvt *t = NULL;
- FOR_TABLE(tag, table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- NEW(t);
- t->length = length >> 1;
- NEW(t->words, (t->length + 1));
- for (uint16_t j = 0; j < t->length; j++) {
- t->words[j] = read_16u(data + 2 * j);
- }
- return t;
- }
- return NULL;
-}
-
-void otfcc_dumpCvt(const table_cvt *table, json_value *root, const otfcc_Options *options,
- const char *tag) {
- if (!table) return;
- loggedStep("cvt") {
- json_value *arr = json_array_new(table->length);
- for (uint16_t j = 0; j < table->length; j++) {
- json_array_push(arr, json_integer_new(table->words[j]));
- }
- json_object_push(root, tag, arr);
- }
-}
-table_cvt *otfcc_parseCvt(const json_value *root, const otfcc_Options *options, const char *tag) {
- table_cvt *t = NULL;
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, tag, json_array))) {
- loggedStep("cvt") {
- // Meaningful CVT dump
- NEW(t);
- t->length = table->u.array.length;
- NEW(t->words, (t->length + 1));
- for (uint16_t j = 0; j < t->length; j++) {
- json_value *record = table->u.array.values[j];
- if (record->type == json_integer) {
- t->words[j] = record->u.integer;
- } else if (record->type == json_double) {
- t->words[j] = (uint16_t)record->u.dbl;
- } else {
- t->words[j] = 0;
- }
- }
- }
- } else if ((table = json_obj_get_type(root, tag, json_string))) {
- loggedStep("cvt") {
- // Bytes CVT dump
- NEW(t);
- size_t len;
- uint8_t *raw =
- base64_decode((uint8_t *)table->u.string.ptr, table->u.string.length, &len);
- t->length = (uint32_t)(len >> 1);
- NEW(t->words, (t->length + 1));
- for (uint16_t j = 0; j < t->length; j++) {
- t->words[j] = read_16u(raw + 2 * j);
- }
- FREE(raw);
- }
- }
- return t;
-}
-
-caryll_Buffer *otfcc_buildCvt(const table_cvt *table, const otfcc_Options *options) {
- if (!table) return NULL;
- caryll_Buffer *buf = bufnew();
- for (uint16_t j = 0; j < table->length; j++) {
- bufwrite16b(buf, table->words[j]);
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.h
deleted file mode 100644
index 3309c1ca332..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/cvt.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_CVT_H
-#define CARYLL_TABLE_CVT_H
-
-#include "otfcc/table/cvt.h"
-
-table_cvt *otfcc_readCvt(const otfcc_Packet packet, const otfcc_Options *options, uint32_t tag);
-void otfcc_dumpCvt(const table_cvt *table, json_value *root, const otfcc_Options *options, const char *tag);
-table_cvt *otfcc_parseCvt(const json_value *root, const otfcc_Options *options, const char *tag);
-caryll_Buffer *otfcc_buildCvt(const table_cvt *table, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.c
deleted file mode 100644
index 8a70f5ece71..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "fpgm-prep.h"
-
-#include "support/util.h"
-#include "support/ttinstr/ttinstr.h"
-
-static INLINE void disposeFpgmPrep(MOVE table_fpgm_prep *table) {
- if (table->tag) sdsfree(table->tag);
- if (table->bytes) FREE(table->bytes);
-}
-
-caryll_standardRefType(table_fpgm_prep, table_iFpgm_prep, disposeFpgmPrep);
-
-table_fpgm_prep *otfcc_readFpgmPrep(const otfcc_Packet packet, const otfcc_Options *options,
- uint32_t tag) {
- table_fpgm_prep *t = NULL;
- FOR_TABLE(tag, table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- t = table_iFpgm_prep.create();
- t->tag = NULL;
- t->length = length;
- NEW(t->bytes, length);
- if (!t->bytes) goto FAIL;
- memcpy(t->bytes, data, length);
- return t;
- FAIL:
- table_iFpgm_prep.free(t);
- t = NULL;
- }
- return NULL;
-}
-
-void table_dumpTableFpgmPrep(const table_fpgm_prep *table, json_value *root,
- const otfcc_Options *options, const char *tag) {
- if (!table) return;
- loggedStep("%s", tag) {
- json_object_push(root, tag, dump_ttinstr(table->bytes, table->length, options));
- }
-}
-
-static void makeFpgmPrepInstr(void *_t, uint8_t *instrs, uint32_t length) {
- table_fpgm_prep *t = (table_fpgm_prep *)_t;
- t->length = length;
- t->bytes = instrs;
-}
-static void wrongFpgmPrepInstr(void *_t, const char *reason, int pos) {
- /*
- table_fpgm_prep *t = (table_fpgm_prep *)_t;
- fprintf(stderr, "[OTFCC] TrueType instructions parse error : %s, at %d in /%s\n", reason, pos,
- t->tag);
- */
-}
-
-table_fpgm_prep *otfcc_parseFpgmPrep(const json_value *root, const otfcc_Options *options,
- const char *tag) {
- table_fpgm_prep *t = NULL;
- json_value *table = NULL;
- if ((table = json_obj_get(root, tag))) {
- loggedStep("%s", tag) {
- t = table_iFpgm_prep.create();
- t->tag = sdsnew(tag);
- parse_ttinstr(table, t, makeFpgmPrepInstr, wrongFpgmPrepInstr);
- }
- }
- return t;
-}
-
-caryll_Buffer *otfcc_buildFpgmPrep(const table_fpgm_prep *table, const otfcc_Options *options) {
- if (!table) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite_bytes(buf, table->length, table->bytes);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.h
deleted file mode 100644
index 2b178b68cc9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fpgm-prep.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef CARYLL_TABLE_FPGM_PREP_H
-#define CARYLL_TABLE_FPGM_PREP_H
-
-#include "otfcc/table/fpgm-prep.h"
-
-table_fpgm_prep *otfcc_readFpgmPrep(const otfcc_Packet packet, const otfcc_Options *options, uint32_t tag);
-void table_dumpTableFpgmPrep(const table_fpgm_prep *table, json_value *root, const otfcc_Options *options,
- const char *tag);
-table_fpgm_prep *otfcc_parseFpgmPrep(const json_value *root, const otfcc_Options *options, const char *tag);
-caryll_Buffer *otfcc_buildFpgmPrep(const table_fpgm_prep *table, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.c
deleted file mode 100644
index 111420b3113..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.c
+++ /dev/null
@@ -1,326 +0,0 @@
-#include "fvar.h"
-
-#include "support/util.h"
-
-
-// fvar instance tuple
-// fvar instance
-static INLINE void initFvarInstance(fvar_Instance *inst) {
- memset(inst, 0, sizeof(*inst));
- iVV.init(&inst->coordinates);
-}
-static INLINE void disposeFvarInstance(fvar_Instance *inst) {
- iVV.dispose(&inst->coordinates);
-}
-caryll_standardType(fvar_Instance, fvar_iInstance, initFvarInstance, disposeFvarInstance);
-caryll_standardVectorImpl(fvar_InstanceList, fvar_Instance, fvar_iInstance, fvar_iInstanceList);
-// table fvar
-
-static INLINE void disposeFvarMaster(fvar_Master *m) {
- sdsfree(m->name);
- vq_deleteRegion(m->region);
-}
-
-static INLINE void initFvar(table_fvar *fvar) {
- memset(fvar, 0, sizeof(*fvar));
- vf_iAxes.init(&fvar->axes);
- fvar_iInstanceList.init(&fvar->instances);
-}
-static INLINE void disposeFvar(table_fvar *fvar) {
- vf_iAxes.dispose(&fvar->axes);
- fvar_iInstanceList.dispose(&fvar->instances);
-
- fvar_Master *current, *tmp;
- HASH_ITER(hh, fvar->masters, current, tmp) {
- HASH_DEL(fvar->masters, current);
- disposeFvarMaster(current);
- FREE(current);
- }
-}
-
-static const vq_Region *fvar_registerRegion(table_fvar *fvar, MOVE vq_Region *region) {
- fvar_Master *m = NULL;
- HASH_FIND(hh, fvar->masters, region, VQ_REGION_SIZE(region->dimensions), m);
- if (m) {
- vq_deleteRegion(region);
- return m->region;
- } else {
- NEW_CLEAN_1(m);
- sds sMasterID = sdsfromlonglong(1 + HASH_CNT(hh, fvar->masters));
- m->name = sdscatsds(sdsnew("m"), sMasterID);
- sdsfree(sMasterID);
- m->region = region;
- HASH_ADD_KEYPTR(hh, fvar->masters, m->region, VQ_REGION_SIZE(region->dimensions), m);
- return m->region;
- }
-}
-
-static const fvar_Master *fvar_findMasterByRegion(const table_fvar *fvar, const vq_Region *region) {
- fvar_Master *m = NULL;
- HASH_FIND(hh, fvar->masters, region, VQ_REGION_SIZE(region->dimensions), m);
- return m;
-}
-
-caryll_standardRefTypeFn(table_fvar, initFvar, disposeFvar);
-caryll_ElementInterfaceOf(table_fvar) table_iFvar = {caryll_standardRefTypeMethods(table_fvar),
- .registerRegion = fvar_registerRegion,
- .findMasterByRegion = fvar_findMasterByRegion};
-
-// Local typedefs for parsing axis record
-#pragma pack(1)
-struct FVARHeader {
- uint16_t majorVersion;
- uint16_t minorVersion;
- uint16_t axesArrayOffset;
- uint16_t reserved1;
- uint16_t axisCount;
- uint16_t axisSize;
- uint16_t instanceCount;
- uint16_t instanceSize;
-};
-
-struct VariationAxisRecord {
- uint32_t axisTag;
- f16dot16 minValue;
- f16dot16 defaultValue;
- f16dot16 maxValue;
- uint16_t flags;
- uint16_t axisNameID;
-};
-
-struct InstanceRecord {
- uint16_t subfamilyNameID;
- uint16_t flags;
- f16dot16 coordinates[];
-};
-#pragma pack()
-
-table_fvar *otfcc_readFvar(const otfcc_Packet packet, const otfcc_Options *options) {
- table_fvar *fvar = NULL;
- FOR_TABLE(OTFCC_CHR('f','v','a','r'), table) {
- font_file_pointer data = table.data;
- if (table.length < sizeof(struct FVARHeader)) goto FAIL;
-
- struct FVARHeader *header = (struct FVARHeader *)data;
- if (be16(header->majorVersion) != 1) goto FAIL;
- if (be16(header->minorVersion) != 0) goto FAIL;
- if (be16(header->axesArrayOffset) == 0) goto FAIL;
- if (be16(header->axisCount) == 0) goto FAIL;
- if (be16(header->axisSize) != sizeof(struct VariationAxisRecord)) goto FAIL;
- uint16_t nAxes = be16(header->axisCount);
- uint16_t instanceSizeWithoutPSNID = 4 + nAxes * sizeof(f16dot16);
- uint16_t instanceSizeWithPSNID = 2 + instanceSizeWithoutPSNID;
- if (be16(header->instanceSize) != instanceSizeWithoutPSNID &&
- be16(header->instanceSize) != instanceSizeWithPSNID)
- goto FAIL;
- if (table.length < be16(header->axesArrayOffset) +
- sizeof(struct VariationAxisRecord) * nAxes +
- be16(header->instanceSize) * be16(header->instanceCount))
- goto FAIL;
-
- fvar = table_iFvar.create();
-
- // parse axes
- struct VariationAxisRecord *axisRecord =
- (struct VariationAxisRecord *)(data + be16(header->axesArrayOffset));
- for (uint16_t j = 0; j < nAxes; j++) {
- vf_Axis axis = {.tag = be32(axisRecord->axisTag),
- .minValue = otfcc_from_fixed(be32(axisRecord->minValue)),
- .defaultValue = otfcc_from_fixed(be32(axisRecord->defaultValue)),
- .maxValue = otfcc_from_fixed(be32(axisRecord->maxValue)),
- .flags = be16(axisRecord->flags),
- .axisNameID = be16(axisRecord->axisNameID)};
- vf_iAxes.push(&fvar->axes, axis);
- axisRecord++;
- }
-
- // parse instances
- uint16_t nInstances = be16(header->instanceCount);
- bool hasPostscriptNameID = be16(header->instanceSize) == instanceSizeWithPSNID;
- struct InstanceRecord *instance = (struct InstanceRecord *)axisRecord;
- for (uint16_t j = 0; j < nInstances; j++) {
- fvar_Instance inst;
- fvar_iInstance.init(&inst);
- inst.subfamilyNameID = be16(instance->subfamilyNameID);
- inst.flags = be16(instance->flags);
- for (uint16_t k = 0; k < nAxes; k++) {
- iVV.push(&inst.coordinates, otfcc_from_fixed(be32(instance->coordinates[k])));
- }
- iVV.shrinkToFit(&inst.coordinates);
- if (hasPostscriptNameID) {
- inst.postScriptNameID =
- be16(*(uint16_t *)(((font_file_pointer)instance) + instanceSizeWithoutPSNID));
- }
- fvar_iInstanceList.push(&fvar->instances, inst);
- instance = (struct InstanceRecord *)(((font_file_pointer)instance) +
- be16(header->instanceSize));
- }
- vf_iAxes.shrinkToFit(&fvar->axes);
- fvar_iInstanceList.shrinkToFit(&fvar->instances);
-
- return fvar;
-
- FAIL:
- logWarning("table 'fvar' corrupted.\n");
- table_iFvar.free(fvar);
- fvar = NULL;
- }
- return NULL;
-}
-
-void otfcc_dumpFvar(const table_fvar *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("fvar") {
- json_value *t = json_object_new(2);
- // dump axes
- json_value *_axes = json_object_new(table->axes.length);
- foreach (vf_Axis *axis, table->axes) {
- json_value *_axis = json_object_new(5);
- json_object_push(_axis, "minValue", json_double_new(axis->minValue));
- json_object_push(_axis, "defaultValue", json_double_new(axis->defaultValue));
- json_object_push(_axis, "maxValue", json_double_new(axis->maxValue));
- json_object_push(_axis, "flags", json_integer_new(axis->flags));
- json_object_push(_axis, "axisNameID", json_integer_new(axis->axisNameID));
- json_object_push_tag(_axes, axis->tag, _axis);
- }
- json_object_push(t, "axes", _axes);
- // dump instances
- json_value *_instances = json_array_new(table->instances.length);
- foreach (fvar_Instance *instance, table->instances) {
- json_value *_instance = json_object_new(4);
- json_object_push(_instance, "subfamilyNameID",
- json_integer_new(instance->subfamilyNameID));
- if (instance->postScriptNameID) {
- json_object_push(_instance, "postScriptNameID",
- json_integer_new(instance->postScriptNameID));
- }
- json_object_push(_instance, "flags", json_integer_new(instance->flags));
- json_object_push(_instance, "coordinates", json_new_VVp(&instance->coordinates, table));
- json_array_push(_instances, _instance);
- }
- json_object_push(t, "instances", _instances);
- // dump masters
- json_value *_masters = json_object_new(HASH_COUNT(table->masters));
- fvar_Master *current, *tmp;
- HASH_ITER(hh, table->masters, current, tmp) {
- json_object_push(_masters, current->name,
- preserialize(json_new_VQRegion_Explicit(current->region, table)));
- }
- json_object_push(t, "masters", _masters);
- json_object_push(root, "fvar", t);
- }
-}
-
-// JSON conversion functions
-// dump
-
-static json_value *json_new_VQSegment(const vq_Segment *s, const table_fvar *fvar) {
- switch (s->type) {
- case VQ_STILL:;
- return json_new_position(s->val.still);
- case VQ_DELTA:;
- json_value *d = json_object_new(3);
- json_object_push(d, "delta", json_new_position(s->val.delta.quantity));
- if (!s->val.delta.touched) {
- json_object_push(d, "implicit", json_boolean_new(!s->val.delta.touched));
- }
- json_object_push(d, "on", json_new_VQRegion(s->val.delta.region, fvar));
- return d;
- default:;
- return json_integer_new(0);
- }
-}
-json_value *json_new_VQ(const VQ z, const table_fvar *fvar) {
-
- if (!z.shift.length) {
- return preserialize(json_new_position(iVQ.getStill(z)));
- } else {
- json_value *a = json_array_new(z.shift.length + 1);
- json_array_push(a, json_new_position(z.kernel));
- for (size_t j = 0; j < z.shift.length; j++) {
- json_array_push(a, json_new_VQSegment(&z.shift.items[j], fvar));
- }
- return preserialize(a);
- }
-}
-
-json_value *json_new_VV(const VV x, const table_fvar *fvar) {
- const vf_Axes *axes = &fvar->axes;
- if (axes && axes->length == x.length) {
- json_value *_coord = json_object_new(axes->length);
- for (size_t m = 0; m < x.length; m++) {
- vf_Axis *axis = &axes->items[m];
- char tag[4] = {(axis->tag & 0xff000000) >> 24, (axis->tag & 0xff0000) >> 16,
- (axis->tag & 0xff00) >> 8, (axis->tag & 0xff)};
- json_object_push_length(_coord, 4, tag, json_new_position(x.items[m]));
- }
- return preserialize(_coord);
- } else {
- json_value *_coord = json_array_new(x.length);
- for (size_t m = 0; m < x.length; m++) {
- json_array_push(_coord, json_new_position(x.items[m]));
- }
- return preserialize(_coord);
- }
-}
-json_value *json_new_VVp(const VV *x, const table_fvar *fvar) {
- const vf_Axes *axes = &fvar->axes;
-
- if (axes && axes->length == x->length) {
- json_value *_coord = json_object_new(axes->length);
- for (size_t m = 0; m < x->length; m++) {
- vf_Axis *axis = &axes->items[m];
- char tag[4] = {(axis->tag & 0xff000000) >> 24, (axis->tag & 0xff0000) >> 16,
- (axis->tag & 0xff00) >> 8, (axis->tag & 0xff)};
- json_object_push_length(_coord, 4, tag, json_new_position(x->items[m]));
- }
- return preserialize(_coord);
-
- } else {
- json_value *_coord = json_array_new(x->length);
- for (size_t m = 0; m < x->length; m++) {
- json_array_push(_coord, json_new_position(x->items[m]));
- }
- return preserialize(_coord);
- }
-}
-// parse
-VQ json_vqOf(const json_value *cv, const table_fvar *fvar) {
- return iVQ.createStill(json_numof(cv));
-}
-
-static json_value *json_new_VQAxisSpan(const vq_AxisSpan *s) {
- if (vq_AxisSpanIsOne(s)) {
- return json_string_new("*");
- } else {
- json_value *a = json_object_new(3);
- json_object_push(a, "start", json_new_position(s->start));
- json_object_push(a, "peak", json_new_position(s->peak));
- json_object_push(a, "end", json_new_position(s->end));
- return a;
- }
-}
-json_value *json_new_VQRegion_Explicit(const vq_Region *rs, const table_fvar *fvar) {
- const vf_Axes *axes = &fvar->axes;
- if (axes && axes->length == rs->dimensions) {
- json_value *r = json_object_new(rs->dimensions);
- for (size_t j = 0; j < rs->dimensions; j++) {
- json_object_push_tag(r, axes->items[j].tag, json_new_VQAxisSpan(&rs->spans[j]));
- }
- return r;
- } else {
- json_value *r = json_array_new(rs->dimensions);
- for (size_t j = 0; j < rs->dimensions; j++) {
- json_array_push(r, json_new_VQAxisSpan(&rs->spans[j]));
- }
- return r;
- }
-}
-json_value *json_new_VQRegion(const vq_Region *rs, const table_fvar *fvar) {
- const fvar_Master *m = table_iFvar.findMasterByRegion(fvar, rs);
- if (m && m->name) {
- return json_string_new_length((unsigned int)sdslen(m->name), m->name);
- } else {
- return json_new_VQRegion_Explicit(rs, fvar);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.h
deleted file mode 100644
index 33f29e96b32..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/fvar.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef CARYLL_TABLE_FVAR_H
-#define CARYLL_TABLE_FVAR_H
-
-#include "otfcc/table/fvar.h"
-
-table_fvar *otfcc_readFvar(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpFvar(const table_fvar *table, json_value *root, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.c
deleted file mode 100644
index c8ccdbdd716..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#include "gasp.h"
-
-#include "support/util.h"
-
-
-#define GASP_DOGRAY 0x0002
-#define GASP_GRIDFIT 0x0001
-#define GASP_SYMMETRIC_GRIDFIT 0x0004
-#define GASP_SYMMETRIC_SMOOTHING 0x0008
-
-caryll_standardType(gasp_Record, gasp_iRecord);
-caryll_standardVectorImpl(gasp_RecordList, gasp_Record, gasp_iRecord, gasp_iRecordList);
-
-static INLINE void initGasp(table_gasp *gasp) {
- gasp->version = 1;
- gasp_iRecordList.init(&gasp->records);
-}
-static INLINE void disposeGasp(MOVE table_gasp *gasp) {
- gasp_iRecordList.dispose(&gasp->records);
-}
-
-caryll_standardRefType(table_gasp, table_iGasp, initGasp, disposeGasp);
-
-table_gasp *otfcc_readGasp(const otfcc_Packet packet, const otfcc_Options *options) {
- table_gasp *gasp = NULL;
- FOR_TABLE(OTFCC_CHR('g','a','s','p'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- if (length < 4) { goto FAIL; }
- gasp = table_iGasp.create();
- gasp->version = read_16u(data);
- tableid_t numRanges = read_16u(data + 2);
- if (length < 4 + numRanges * 4) { goto FAIL; }
-
- for (uint32_t j = 0; j < numRanges; j++) {
- gasp_Record record;
- record.rangeMaxPPEM = read_16u(data + 4 + j * 4);
- uint16_t rangeGaspBehavior = read_16u(data + 4 + j * 4 + 2);
- record.dogray = !!(rangeGaspBehavior & GASP_DOGRAY);
- record.gridfit = !!(rangeGaspBehavior & GASP_GRIDFIT);
- record.symmetric_smoothing = !!(rangeGaspBehavior & GASP_SYMMETRIC_SMOOTHING);
- record.symmetric_gridfit = !!(rangeGaspBehavior & GASP_SYMMETRIC_GRIDFIT);
- gasp_iRecordList.push(&gasp->records, record);
- }
- return gasp;
-
- FAIL:
- logWarning("table 'gasp' corrupted.\n");
- table_iGasp.free(gasp);
- gasp = NULL;
- }
- return NULL;
-}
-void otfcc_dumpGasp(const table_gasp *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("gasp") {
- json_value *t = json_array_new(table->records.length);
- for (uint16_t j = 0; j < table->records.length; j++) {
- json_value *rec = json_object_new(5);
- json_object_push(rec, "rangeMaxPPEM",
- json_integer_new(table->records.items[j].rangeMaxPPEM));
- json_object_push(rec, "dogray", json_boolean_new(table->records.items[j].dogray));
- json_object_push(rec, "gridfit", json_boolean_new(table->records.items[j].gridfit));
- json_object_push(rec, "symmetric_smoothing",
- json_boolean_new(table->records.items[j].symmetric_smoothing));
- json_object_push(rec, "symmetric_gridfit",
- json_boolean_new(table->records.items[j].symmetric_gridfit));
- json_array_push(t, rec);
- }
- json_object_push(root, "gasp", t);
- }
-}
-
-table_gasp *otfcc_parseGasp(const json_value *root, const otfcc_Options *options) {
- table_gasp *gasp = NULL;
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "gasp", json_array))) {
- loggedStep("gasp") {
- gasp = table_iGasp.create();
- for (uint16_t j = 0; j < table->u.array.length; j++) {
- json_value *r = table->u.array.values[j];
- if (!r || r->type != json_object) continue;
- gasp_Record record;
- record.rangeMaxPPEM = json_obj_getint_fallback(r, "rangeMaxPPEM", 0xFFFF);
- record.dogray = json_obj_getbool(r, "dogray");
- record.gridfit = json_obj_getbool(r, "gridfit");
- record.symmetric_smoothing = json_obj_getbool(r, "symmetric_smoothing");
- record.symmetric_gridfit = json_obj_getbool(r, "symmetric_gridfit");
- gasp_iRecordList.push(&gasp->records, record);
- }
- }
- }
- return gasp;
-}
-
-caryll_Buffer *otfcc_buildGasp(const table_gasp *gasp, const otfcc_Options *options) {
- if (!gasp) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, 1);
- bufwrite16b(buf, gasp->records.length);
- for (uint16_t j = 0; j < gasp->records.length; j++) {
- gasp_Record *r = &(gasp->records.items[j]);
- bufwrite16b(buf, r->rangeMaxPPEM);
- bufwrite16b(buf, (r->dogray ? GASP_DOGRAY : 0) | (r->gridfit ? GASP_GRIDFIT : 0) |
- (r->symmetric_gridfit ? GASP_SYMMETRIC_GRIDFIT : 0) |
- (r->symmetric_smoothing ? GASP_SYMMETRIC_SMOOTHING : 0));
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.h
deleted file mode 100644
index cfa96bc59bb..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/gasp.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_GASP_H
-#define CARYLL_TABLE_GASP_H
-
-#include "otfcc/table/gasp.h"
-
-table_gasp *otfcc_readGasp(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpGasp(const table_gasp *table, json_value *root, const otfcc_Options *options);
-table_gasp *otfcc_parseGasp(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildGasp(const table_gasp *table, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf.h
deleted file mode 100644
index ff61af08dfe..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef CARYLL_TABLE_GLYF_H
-#define CARYLL_TABLE_GLYF_H
-
-#include "otfcc/table/glyf.h"
-
-glyf_Glyph *otfcc_newGlyf_glyph(void);
-void otfcc_initGlyfContour(glyf_Contour *contour);
-
-typedef struct {
- bool locaIsLong;
- glyphid_t numGlyphs;
- shapeid_t nPhantomPoints;
- table_fvar *fvar;
- bool hasVerticalMetrics;
- bool exportFDSelect;
-} GlyfIOContext;
-
-table_glyf *otfcc_readGlyf(const otfcc_Packet packet, const otfcc_Options *options,
- const GlyfIOContext *ctx);
-void otfcc_dumpGlyf(const table_glyf *table, json_value *root, const otfcc_Options *options,
- const GlyfIOContext *ctx);
-table_glyf *otfcc_parseGlyf(const json_value *root, otfcc_GlyphOrder *glyph_order,
- const otfcc_Options *options);
-
-typedef struct {
- caryll_Buffer *glyf;
- caryll_Buffer *loca;
-} table_GlyfAndLocaBuffers;
-
-table_GlyfAndLocaBuffers otfcc_buildGlyf(const table_glyf *table, table_head *head,
- const otfcc_Options *options);
-
-typedef enum {
- GLYF_FLAG_ON_CURVE = 1,
- GLYF_FLAG_X_SHORT = (1 << 1),
- GLYF_FLAG_Y_SHORT = (1 << 2),
- GLYF_FLAG_REPEAT = (1 << 3),
- GLYF_FLAG_SAME_X = (1 << 4),
- GLYF_FLAG_SAME_Y = (1 << 5),
- GLYF_FLAG_POSITIVE_X = (1 << 4),
- GLYF_FLAG_POSITIVE_Y = (1 << 5)
-} glyf_point_flag;
-
-typedef enum {
- ARG_1_AND_2_ARE_WORDS = (1 << 0),
- ARGS_ARE_XY_VALUES = (1 << 1),
- ROUND_XY_TO_GRID = (1 << 2),
- WE_HAVE_A_SCALE = (1 << 3),
- MORE_COMPONENTS = (1 << 5),
- WE_HAVE_AN_X_AND_Y_SCALE = (1 << 6),
- WE_HAVE_A_TWO_BY_TWO = (1 << 7),
- WE_HAVE_INSTRUCTIONS = (1 << 8),
- USE_MY_METRICS = (1 << 9),
- OVERLAP_COMPOUND = (1 << 10),
- SCALED_COMPONENT_OFFSET = (1 << 11),
- UNSCALED_COMPONENT_OFFSET = (1 << 12)
-} glyf_reference_flag;
-
-typedef enum { MASK_ON_CURVE = 1 } glyf_oncurve_mask;
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/build.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/build.c
deleted file mode 100644
index 63153e8df03..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/build.c
+++ /dev/null
@@ -1,222 +0,0 @@
-#include "../glyf.h"
-
-#include "support/util.h"
-#include "support/ttinstr/ttinstr.h"
-
-static caryll_Buffer *shrinkFlags(caryll_Buffer *flags) {
- if (!buflen(flags)) return (flags);
- caryll_Buffer *shrunk = bufnew();
- bufwrite8(shrunk, flags->data[0]);
- int repeating = 0;
- for (size_t j = 1; j < buflen(flags); j++) {
- if (flags->data[j] == flags->data[j - 1]) {
- if (repeating && repeating < 0xFE) {
- shrunk->data[shrunk->cursor - 1] += 1;
- repeating += 1;
- } else if (repeating == 0) {
- shrunk->data[shrunk->cursor - 1] |= GLYF_FLAG_REPEAT;
- bufwrite8(shrunk, 1);
- repeating += 1;
- } else {
- repeating = 0;
- bufwrite8(shrunk, flags->data[j]);
- }
- } else {
- repeating = 0;
- bufwrite8(shrunk, flags->data[j]);
- }
- }
- buffree(flags);
- return shrunk;
-}
-
-// serialize
-#define EPSILON (1e-5)
-static void glyf_build_simple(const glyf_Glyph *g, caryll_Buffer *gbuf) {
- caryll_Buffer *flags = bufnew();
- caryll_Buffer *xs = bufnew();
- caryll_Buffer *ys = bufnew();
-
- bufwrite16b(gbuf, g->contours.length);
- bufwrite16b(gbuf, (int16_t)g->stat.xMin);
- bufwrite16b(gbuf, (int16_t)g->stat.yMin);
- bufwrite16b(gbuf, (int16_t)g->stat.xMax);
- bufwrite16b(gbuf, (int16_t)g->stat.yMax);
-
- // endPtsOfContours[n]
- shapeid_t ptid = 0;
- for (shapeid_t j = 0; j < g->contours.length; j++) {
- ptid += g->contours.items[j].length;
- bufwrite16b(gbuf, ptid - 1);
- }
-
- // instructions
- bufwrite16b(gbuf, g->instructionsLength);
- if (g->instructions) bufwrite_bytes(gbuf, g->instructionsLength, g->instructions);
-
- // flags and points
- bufclear(flags);
- bufclear(xs);
- bufclear(ys);
- int32_t cx = 0;
- int32_t cy = 0;
- for (shapeid_t cj = 0; cj < g->contours.length; cj++) {
- for (shapeid_t k = 0; k < g->contours.items[cj].length; k++) {
- glyf_Point *p = &(g->contours.items[cj].items[k]);
- uint8_t flag = (p->onCurve & MASK_ON_CURVE) ? GLYF_FLAG_ON_CURVE : 0;
- int32_t px = round(iVQ.getStill(p->x));
- int32_t py = round(iVQ.getStill(p->y));
- int16_t dx = (int16_t)(px - cx);
- int16_t dy = (int16_t)(py - cy);
- if (dx == 0) {
- flag |= GLYF_FLAG_SAME_X;
- } else if (dx >= -0xFF && dx <= 0xFF) {
- flag |= GLYF_FLAG_X_SHORT;
- if (dx > 0) {
- flag |= GLYF_FLAG_POSITIVE_X;
- bufwrite8(xs, dx);
- } else {
- bufwrite8(xs, -dx);
- }
- } else {
- bufwrite16b(xs, dx);
- }
-
- if (dy == 0) {
- flag |= GLYF_FLAG_SAME_Y;
- } else if (dy >= -0xFF && dy <= 0xFF) {
- flag |= GLYF_FLAG_Y_SHORT;
- if (dy > 0) {
- flag |= GLYF_FLAG_POSITIVE_Y;
- bufwrite8(ys, dy);
- } else {
- bufwrite8(ys, -dy);
- }
- } else {
- bufwrite16b(ys, dy);
- }
- bufwrite8(flags, flag);
- cx = px;
- cy = py;
- }
- }
- flags = shrinkFlags(flags);
- bufwrite_buf(gbuf, flags);
- bufwrite_buf(gbuf, xs);
- bufwrite_buf(gbuf, ys);
-
- buffree(flags);
- buffree(xs);
- buffree(ys);
-}
-static void glyf_build_composite(const glyf_Glyph *g, caryll_Buffer *gbuf) {
- bufwrite16b(gbuf, (-1));
- bufwrite16b(gbuf, (int16_t)g->stat.xMin);
- bufwrite16b(gbuf, (int16_t)g->stat.yMin);
- bufwrite16b(gbuf, (int16_t)g->stat.xMax);
- bufwrite16b(gbuf, (int16_t)g->stat.yMax);
- for (shapeid_t rj = 0; rj < g->references.length; rj++) {
- glyf_ComponentReference *r = &(g->references.items[rj]);
- uint16_t flags =
- (rj < g->references.length - 1 ? MORE_COMPONENTS
- : g->instructionsLength > 0 ? WE_HAVE_INSTRUCTIONS : 0);
- bool outputAnchor = r->isAnchored == REF_ANCHOR_CONSOLIDATED;
-
- union {
- uint16_t pointid;
- int16_t coord;
- } arg1, arg2;
-
- // flags
- if (outputAnchor) {
- arg1.pointid = r->outer;
- arg2.pointid = r->inner;
- if (!(arg1.pointid < 0x100 && arg2.pointid < 0x100)) { flags |= ARG_1_AND_2_ARE_WORDS; }
- } else {
- flags |= ARGS_ARE_XY_VALUES;
- arg1.coord = iVQ.getStill(r->x);
- arg2.coord = iVQ.getStill(r->y);
- if (!(arg1.coord < 128 && arg1.coord >= -128 && arg2.coord < 128 &&
- arg2.coord >= -128)) {
- flags |= ARG_1_AND_2_ARE_WORDS;
- }
- }
- if (fabs(r->b) > EPSILON || fabs(r->c) > EPSILON) {
- flags |= WE_HAVE_A_TWO_BY_TWO;
- } else if (fabs(r->a - 1) > EPSILON || fabs(r->d - 1) > EPSILON) {
- if (fabs(r->a - r->d) > EPSILON) {
- flags |= WE_HAVE_AN_X_AND_Y_SCALE;
- } else {
- flags |= WE_HAVE_A_SCALE;
- }
- }
- if (r->roundToGrid) flags |= ROUND_XY_TO_GRID;
- if (r->useMyMetrics) flags |= USE_MY_METRICS;
- flags |= UNSCALED_COMPONENT_OFFSET;
- bufwrite16b(gbuf, flags);
- bufwrite16b(gbuf, r->glyph.index);
- if (flags & ARG_1_AND_2_ARE_WORDS) {
- bufwrite16b(gbuf, arg1.pointid);
- bufwrite16b(gbuf, arg2.pointid);
- } else {
- bufwrite8(gbuf, arg1.pointid);
- bufwrite8(gbuf, arg2.pointid);
- }
- if (flags & WE_HAVE_A_SCALE) {
- bufwrite16b(gbuf, otfcc_to_f2dot14(r->a));
- } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
- bufwrite16b(gbuf, otfcc_to_f2dot14(r->a));
- bufwrite16b(gbuf, otfcc_to_f2dot14(r->d));
- } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
- bufwrite16b(gbuf, otfcc_to_f2dot14(r->a));
- bufwrite16b(gbuf, otfcc_to_f2dot14(r->b));
- bufwrite16b(gbuf, otfcc_to_f2dot14(r->c));
- bufwrite16b(gbuf, otfcc_to_f2dot14(r->d));
- }
- }
- if (g->instructionsLength) {
- bufwrite16b(gbuf, g->instructionsLength);
- if (g->instructions) bufwrite_bytes(gbuf, g->instructionsLength, g->instructions);
- }
-}
-table_GlyfAndLocaBuffers otfcc_buildGlyf(const table_glyf *table, table_head *head,
- const otfcc_Options *options) {
- caryll_Buffer *bufglyf = bufnew();
- caryll_Buffer *bufloca = bufnew();
- if (table && head) {
- caryll_Buffer *gbuf = bufnew();
- uint32_t *loca;
- NEW(loca, table->length + 1);
- for (glyphid_t j = 0; j < table->length; j++) {
- loca[j] = (uint32_t)bufglyf->cursor;
- glyf_Glyph *g = table->items[j];
- bufclear(gbuf);
- if (g->contours.length > 0) {
- glyf_build_simple(g, gbuf);
- } else if (g->references.length > 0) {
- glyf_build_composite(g, gbuf);
- }
- // pad extra zeroes
- buflongalign(gbuf);
- bufwrite_buf(bufglyf, gbuf);
- }
- loca[table->length] = (uint32_t)bufglyf->cursor;
- if (bufglyf->cursor >= 0x20000) {
- head->indexToLocFormat = 1;
- } else {
- head->indexToLocFormat = 0;
- }
- // write loca table
- for (uint32_t j = 0; j <= table->length; j++) {
- if (head->indexToLocFormat) {
- bufwrite32b(bufloca, loca[j]);
- } else {
- bufwrite16b(bufloca, loca[j] >> 1);
- }
- }
- buffree(gbuf);
- FREE(loca);
- }
- table_GlyfAndLocaBuffers pair = {bufglyf, bufloca};
- return pair;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/glyf.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/glyf.c
deleted file mode 100644
index 4a44334ecfa..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/glyf.c
+++ /dev/null
@@ -1,482 +0,0 @@
-#include "../glyf.h"
-
-#include "support/util.h"
-#include "support/ttinstr/ttinstr.h"
-
-
-// point
-static void createPoint(glyf_Point *p) {
- p->x = iVQ.createStill(0);
- p->y = iVQ.createStill(0);
- p->onCurve = true;
-}
-static void copyPoint(glyf_Point *dst, const glyf_Point *src) {
- iVQ.copy(&dst->x, &src->x);
- iVQ.copy(&dst->y, &src->y);
- dst->onCurve = src->onCurve;
-}
-static void disposePoint(glyf_Point *p) {
- iVQ.dispose(&p->x);
- iVQ.dispose(&p->y);
-}
-
-caryll_standardValType(glyf_Point, glyf_iPoint, createPoint, copyPoint, disposePoint);
-
-// contour
-caryll_standardVectorImpl(glyf_Contour, glyf_Point, glyf_iPoint, glyf_iContour);
-caryll_standardVectorImpl(glyf_ContourList, glyf_Contour, glyf_iContour, glyf_iContourList);
-
-// ref
-static INLINE void initGlyfReference(glyf_ComponentReference *ref) {
- ref->glyph = Handle.empty();
- ref->x = iVQ.createStill(0);
- ref->y = iVQ.createStill(0);
- ref->a = 1;
- ref->b = 0;
- ref->c = 0;
- ref->d = 1;
- ref->isAnchored = REF_XY;
- ref->inner = ref->outer = 0;
- ref->roundToGrid = false;
- ref->useMyMetrics = false;
-}
-static void copyGlyfReference(glyf_ComponentReference *dst, const glyf_ComponentReference *src) {
- iVQ.copy(&dst->x, &src->x);
- iVQ.copy(&dst->y, &src->y);
- Handle.copy(&dst->glyph, &src->glyph);
- dst->a = src->a;
- dst->b = src->b;
- dst->c = src->c;
- dst->d = src->d;
- dst->isAnchored = src->isAnchored;
- dst->inner = src->inner;
- dst->outer = src->outer;
- dst->roundToGrid = src->roundToGrid;
- dst->useMyMetrics = src->useMyMetrics;
-}
-static INLINE void disposeGlyfReference(glyf_ComponentReference *ref) {
- iVQ.dispose(&ref->x);
- iVQ.dispose(&ref->y);
- Handle.dispose(&ref->glyph);
-}
-caryll_standardValType(glyf_ComponentReference, glyf_iComponentReference, initGlyfReference,
- copyGlyfReference, disposeGlyfReference);
-caryll_standardVectorImpl(glyf_ReferenceList, glyf_ComponentReference, glyf_iComponentReference,
- glyf_iReferenceList);
-
-// stem
-caryll_standardType(glyf_PostscriptStemDef, glyf_iPostscriptStemDef);
-caryll_standardVectorImpl(glyf_StemDefList, glyf_PostscriptStemDef, glyf_iPostscriptStemDef,
- glyf_iStemDefList);
-
-// mask
-caryll_standardType(glyf_PostscriptHintMask, glyf_iPostscriptHintMask);
-caryll_standardVectorImpl(glyf_MaskList, glyf_PostscriptHintMask, glyf_iPostscriptHintMask,
- glyf_iMaskList);
-
-glyf_Glyph *otfcc_newGlyf_glyph() {
- glyf_Glyph *g;
- NEW(g);
- g->name = NULL;
- iVQ.init(&g->horizontalOrigin);
- iVQ.init(&g->advanceWidth);
- iVQ.init(&g->verticalOrigin);
- iVQ.init(&g->advanceHeight);
-
- glyf_iContourList.init(&g->contours);
- glyf_iReferenceList.init(&g->references);
- glyf_iStemDefList.init(&g->stemH);
- glyf_iStemDefList.init(&g->stemV);
- glyf_iMaskList.init(&g->hintMasks);
- glyf_iMaskList.init(&g->contourMasks);
-
- g->instructionsLength = 0;
- g->instructions = NULL;
- g->fdSelect = Handle.empty();
- g->yPel = 0;
-
- g->stat.xMin = 0;
- g->stat.xMax = 0;
- g->stat.yMin = 0;
- g->stat.yMax = 0;
- g->stat.nestDepth = 0;
- g->stat.nPoints = 0;
- g->stat.nContours = 0;
- g->stat.nCompositePoints = 0;
- g->stat.nCompositeContours = 0;
- return g;
-}
-static void otfcc_deleteGlyf_glyph(glyf_Glyph *g) {
- if (!g) return;
- iVQ.dispose(&g->horizontalOrigin);
- iVQ.dispose(&g->advanceWidth);
- iVQ.dispose(&g->verticalOrigin);
- iVQ.dispose(&g->advanceHeight);
- sdsfree(g->name);
- glyf_iContourList.dispose(&g->contours);
- glyf_iReferenceList.dispose(&g->references);
- glyf_iStemDefList.dispose(&g->stemH);
- glyf_iStemDefList.dispose(&g->stemV);
- glyf_iMaskList.dispose(&g->hintMasks);
- glyf_iMaskList.dispose(&g->contourMasks);
- if (g->instructions) { FREE(g->instructions); }
- Handle.dispose(&g->fdSelect);
- g->name = NULL;
- FREE(g);
-}
-
-static INLINE void initGlyfPtr(glyf_GlyphPtr *g) {
- *g = NULL;
-}
-static void copyGlyfPtr(glyf_GlyphPtr *dst, const glyf_GlyphPtr *src) {
- *dst = *src;
-}
-static INLINE void disposeGlyfPtr(glyf_GlyphPtr *g) {
- otfcc_deleteGlyf_glyph(*g);
-}
-caryll_ElementInterfaceOf(glyf_GlyphPtr) glyf_iGlyphPtr = {
- .init = initGlyfPtr,
- .copy = copyGlyfPtr,
- .dispose = disposeGlyfPtr,
-};
-caryll_standardVectorImpl(table_glyf, glyf_GlyphPtr, glyf_iGlyphPtr, table_iGlyf);
-
-// to json
-static void glyf_glyph_dump_contours(glyf_Glyph *g, json_value *target, const GlyfIOContext *ctx) {
- if (!g->contours.length) return;
- json_value *contours = json_array_new(g->contours.length);
- for (shapeid_t k = 0; k < g->contours.length; k++) {
- glyf_Contour *c = &(g->contours.items[k]);
- json_value *contour = json_array_new(c->length);
- for (shapeid_t m = 0; m < c->length; m++) {
- json_value *point = json_object_new(4);
- json_object_push(point, "x", json_new_VQ(c->items[m].x, ctx->fvar));
- json_object_push(point, "y", json_new_VQ(c->items[m].y, ctx->fvar));
- json_object_push(point, "on", json_boolean_new(c->items[m].onCurve & MASK_ON_CURVE));
- json_array_push(contour, point);
- }
- json_array_push(contours, preserialize(contour));
- }
- json_object_push(target, "contours", contours);
-}
-
-static void glyf_glyph_dump_references(glyf_Glyph *g, json_value *target,
- const GlyfIOContext *ctx) {
- if (!g->references.length) return;
- json_value *references = json_array_new(g->references.length);
- for (shapeid_t k = 0; k < g->references.length; k++) {
- glyf_ComponentReference *r = &(g->references.items[k]);
- json_value *ref = json_object_new(9);
- json_object_push(ref, "glyph",
- json_string_new_length((uint32_t)sdslen(r->glyph.name), r->glyph.name));
- json_object_push(ref, "x", json_new_VQ(r->x, ctx->fvar));
- json_object_push(ref, "y", json_new_VQ(r->y, ctx->fvar));
- json_object_push(ref, "a", json_new_position(r->a));
- json_object_push(ref, "b", json_new_position(r->b));
- json_object_push(ref, "c", json_new_position(r->c));
- json_object_push(ref, "d", json_new_position(r->d));
- if (r->isAnchored != REF_XY) {
- json_object_push(ref, "isAnchored", json_boolean_new(true));
- json_object_push(ref, "inner", json_integer_new(r->inner));
- json_object_push(ref, "outer", json_integer_new(r->outer));
- }
- if (r->roundToGrid) { json_object_push(ref, "roundToGrid", json_boolean_new(true)); }
- if (r->useMyMetrics) { json_object_push(ref, "useMyMetrics", json_boolean_new(true)); }
- json_array_push(references, preserialize(ref));
- }
- json_object_push(target, "references", references);
-}
-static json_value *glyf_glyph_dump_stemdefs(glyf_StemDefList *stems) {
- json_value *a = json_array_new(stems->length);
- for (shapeid_t j = 0; j < stems->length; j++) {
- json_value *stem = json_object_new(3);
- json_object_push(stem, "position", json_new_position(stems->items[j].position));
- json_object_push(stem, "width", json_new_position(stems->items[j].width));
- json_array_push(a, stem);
- }
- return a;
-}
-static json_value *glyf_glyph_dump_maskdefs(glyf_MaskList *masks, glyf_StemDefList *hh,
- glyf_StemDefList *vv) {
- json_value *a = json_array_new(masks->length);
- for (shapeid_t j = 0; j < masks->length; j++) {
- json_value *mask = json_object_new(3);
- json_object_push(mask, "contoursBefore", json_integer_new(masks->items[j].contoursBefore));
- json_object_push(mask, "pointsBefore", json_integer_new(masks->items[j].pointsBefore));
- json_value *h = json_array_new(hh->length);
- for (shapeid_t k = 0; k < hh->length; k++) {
- json_array_push(h, json_boolean_new(masks->items[j].maskH[k]));
- }
- json_object_push(mask, "maskH", h);
- json_value *v = json_array_new(vv->length);
- for (shapeid_t k = 0; k < vv->length; k++) {
- json_array_push(v, json_boolean_new(masks->items[j].maskV[k]));
- }
- json_object_push(mask, "maskV", v);
- json_array_push(a, mask);
- }
- return a;
-}
-
-static json_value *glyf_dump_glyph(glyf_Glyph *g, const otfcc_Options *options,
- const GlyfIOContext *ctx) {
- json_value *glyph = json_object_new(12);
- json_object_push(glyph, "advanceWidth", json_new_VQ(g->advanceWidth, ctx->fvar));
- if (iVQ.isStill(g->horizontalOrigin) &&
- fabs(iVQ.getStill(g->horizontalOrigin)) > 1.0 / 1000.0) {
- json_object_push(glyph, "horizontalOrigin", json_new_VQ(g->horizontalOrigin, ctx->fvar));
- }
- if (ctx->hasVerticalMetrics) {
- json_object_push(glyph, "advanceHeight", json_new_VQ(g->advanceHeight, ctx->fvar));
- json_object_push(glyph, "verticalOrigin", json_new_VQ(g->verticalOrigin, ctx->fvar));
- }
- glyf_glyph_dump_contours(g, glyph, ctx);
- glyf_glyph_dump_references(g, glyph, ctx);
- if (ctx->exportFDSelect) {
- json_object_push(glyph, "CFF_fdSelect", json_string_new(g->fdSelect.name));
- json_object_push(glyph, "CFF_CID", json_integer_new(g->cid));
- }
-
- // hinting data
- if (!options->ignore_hints) {
- if (g->instructions && g->instructionsLength) {
- json_object_push(glyph, "instructions",
- dump_ttinstr(g->instructions, g->instructionsLength, options));
- }
- if (g->stemH.length) {
- json_object_push(glyph, "stemH", preserialize(glyf_glyph_dump_stemdefs(&g->stemH)));
- }
- if (g->stemV.length) {
- json_object_push(glyph, "stemV", preserialize(glyf_glyph_dump_stemdefs(&g->stemV)));
- }
- if (g->hintMasks.length) {
- json_object_push(
- glyph, "hintMasks",
- preserialize(glyf_glyph_dump_maskdefs(&g->hintMasks, &g->stemH, &g->stemV)));
- }
- if (g->contourMasks.length) {
- json_object_push(
- glyph, "contourMasks",
- preserialize(glyf_glyph_dump_maskdefs(&g->contourMasks, &g->stemH, &g->stemV)));
- }
- if (g->yPel) { json_object_push(glyph, "LTSH_yPel", json_integer_new(g->yPel)); }
- }
- return glyph;
-}
-static void otfcc_dump_glyphorder(const table_glyf *table, json_value *root) {
- if (!table) return;
- json_value *order = json_array_new(table->length);
- for (glyphid_t j = 0; j < table->length; j++) {
- json_array_push(order, json_string_new_length((uint32_t)sdslen(table->items[j]->name),
- table->items[j]->name));
- }
- json_object_push(root, "glyph_order", preserialize(order));
-}
-void otfcc_dumpGlyf(const table_glyf *table, json_value *root, const otfcc_Options *options,
- const GlyfIOContext *ctx) {
- if (!table) return;
- loggedStep("glyf") {
- json_value *glyf = json_object_new(table->length);
- for (glyphid_t j = 0; j < table->length; j++) {
- glyf_Glyph *g = table->items[j];
- json_object_push(glyf, g->name, glyf_dump_glyph(g, options, ctx));
- }
- json_object_push(root, "glyf", glyf);
- if (!options->ignore_glyph_order) otfcc_dump_glyphorder(table, root);
- }
-}
-
-// from json
-static glyf_Point glyf_parse_point(json_value *pointdump) {
- glyf_Point point;
- glyf_iPoint.init(&point);
- if (!pointdump || pointdump->type != json_object) return point;
- for (uint32_t _k = 0; _k < pointdump->u.object.length; _k++) {
- char *ck = pointdump->u.object.values[_k].name;
- json_value *cv = pointdump->u.object.values[_k].value;
- if (strcmp(ck, "x") == 0) {
- iVQ.replace(&point.x, json_vqOf(cv, NULL));
- } else if (strcmp(ck, "y") == 0) {
- iVQ.replace(&point.y, json_vqOf(cv, NULL));
- } else if (strcmp(ck, "on") == 0) {
- point.onCurve = json_boolof(cv);
- }
- }
- return point;
-}
-
-static void glyf_parse_contours(json_value *col, glyf_Glyph *g) {
- if (!col) { return; }
- shapeid_t nContours = col->u.array.length;
- for (shapeid_t j = 0; j < nContours; j++) {
- json_value *contourdump = col->u.array.values[j];
- glyf_Contour contour;
- glyf_iContour.initCapN(&contour, contourdump && contourdump->type == json_array
- ? contourdump->u.array.length
- : 1);
- if (contourdump && contourdump->type == json_array) {
- for (shapeid_t k = 0; k < contourdump->u.array.length; k++) {
- glyf_iContour.push(&contour, glyf_parse_point(contourdump->u.array.values[k]));
- }
- }
- glyf_iContourList.push(&g->contours, contour);
- }
-}
-
-static glyf_ComponentReference glyf_parse_reference(json_value *refdump) {
- json_value *_gname = json_obj_get_type(refdump, "glyph", json_string);
- glyf_ComponentReference ref = glyf_iComponentReference.empty();
- if (_gname) {
- ref.glyph = Handle.fromName(sdsnewlen(_gname->u.string.ptr, _gname->u.string.length));
- iVQ.replace(&ref.x, json_vqOf(json_obj_get(refdump, "x"), NULL));
- iVQ.replace(&ref.y, json_vqOf(json_obj_get(refdump, "y"), NULL));
- ref.a = json_obj_getnum_fallback(refdump, "a", 1.0);
- ref.b = json_obj_getnum_fallback(refdump, "b", 0.0);
- ref.c = json_obj_getnum_fallback(refdump, "c", 0.0);
- ref.d = json_obj_getnum_fallback(refdump, "d", 1.0);
- ref.roundToGrid = json_obj_getbool(refdump, "roundToGrid");
- ref.useMyMetrics = json_obj_getbool(refdump, "useMyMetrics");
- if (json_obj_getbool(refdump, "isAnchored")) {
- ref.isAnchored = REF_ANCHOR_XY;
- ref.inner = json_obj_getint(refdump, "inner");
- ref.outer = json_obj_getint(refdump, "outer");
- }
- } else {
- // Invalid glyph references
- ref.glyph.name = NULL;
- iVQ.replace(&ref.x, iVQ.createStill(0));
- iVQ.replace(&ref.y, iVQ.createStill(0));
- ref.a = 1.0;
- ref.b = 0.0;
- ref.c = 0.0;
- ref.d = 1.0;
- ref.roundToGrid = false;
- ref.useMyMetrics = false;
- }
- return ref;
-}
-static void glyf_parse_references(json_value *col, glyf_Glyph *g) {
- if (!col) { return; }
- for (shapeid_t j = 0; j < col->u.array.length; j++) {
- glyf_iReferenceList.push(&g->references, glyf_parse_reference(col->u.array.values[j]));
- }
-}
-
-static void makeInstrsForGlyph(void *_g, uint8_t *instrs, uint32_t len) {
- glyf_Glyph *g = (glyf_Glyph *)_g;
- g->instructionsLength = len;
- g->instructions = instrs;
-}
-static void wrongInstrsForGlyph(void *_g, const char *reason, int pos) {
- glyf_Glyph *g = (glyf_Glyph *)_g;
- fprintf(stderr, "[OTFCC] TrueType instructions parse error : %s, at %d in /%s\n", reason, pos,
- g->name);
-}
-
-static void parse_stems(json_value *sd, glyf_StemDefList *stems) {
- if (!sd) return;
- for (shapeid_t j = 0; j < sd->u.array.length; j++) {
- json_value *s = sd->u.array.values[j];
- if (s->type != json_object) continue;
- glyf_PostscriptStemDef sdef;
- sdef.map = 0;
- sdef.position = json_obj_getnum(s, "position");
- sdef.width = json_obj_getnum(s, "width");
- glyf_iStemDefList.push(stems, sdef);
- }
-}
-static void parse_maskbits(bool *arr, json_value *bits) {
- if (!bits) {
- for (shapeid_t j = 0; j < 0x100; j++) {
- arr[j] = false;
- }
- } else {
- for (shapeid_t j = 0; j < 0x100 && j < bits->u.array.length; j++) {
- json_value *b = bits->u.array.values[j];
- switch (b->type) {
- case json_boolean:
- arr[j] = b->u.boolean;
- break;
- case json_integer:
- arr[j] = b->u.integer;
- break;
- case json_double:
- arr[j] = b->u.dbl;
- break;
- default:
- arr[j] = false;
- }
- }
- }
-}
-static void parse_masks(json_value *md, glyf_MaskList *masks) {
- if (!md) return;
- for (shapeid_t j = 0; j < md->u.array.length; j++) {
- json_value *m = md->u.array.values[j];
- if (m->type != json_object) continue;
-
- glyf_PostscriptHintMask mask;
- mask.pointsBefore = json_obj_getint(m, "pointsBefore");
- mask.contoursBefore = json_obj_getint(m, "contoursBefore");
- parse_maskbits(&(mask.maskH[0]), json_obj_get_type(m, "maskH", json_array));
- parse_maskbits(&(mask.maskV[0]), json_obj_get_type(m, "maskV", json_array));
- glyf_iMaskList.push(masks, mask);
- }
-}
-
-static glyf_Glyph *otfcc_glyf_parse_glyph(json_value *glyphdump, otfcc_GlyphOrderEntry *order_entry,
- const otfcc_Options *options) {
- glyf_Glyph *g = otfcc_newGlyf_glyph();
- g->name = sdsdup(order_entry->name);
- iVQ.replace(&g->advanceWidth, json_vqOf(json_obj_get(glyphdump, "advanceWidth"), NULL));
- iVQ.replace(&g->horizontalOrigin, json_vqOf(json_obj_get(glyphdump, "horizontalOrigin"), NULL));
- iVQ.replace(&g->advanceHeight, json_vqOf(json_obj_get(glyphdump, "advanceHeight"), NULL));
- iVQ.replace(&g->verticalOrigin, json_vqOf(json_obj_get(glyphdump, "verticalOrigin"), NULL));
- glyf_parse_contours(json_obj_get_type(glyphdump, "contours", json_array), g);
- glyf_parse_references(json_obj_get_type(glyphdump, "references", json_array), g);
- if (!options->ignore_hints) {
- parse_ttinstr(json_obj_get(glyphdump, "instructions"), g, makeInstrsForGlyph,
- wrongInstrsForGlyph);
- parse_stems(json_obj_get_type(glyphdump, "stemH", json_array), &g->stemH);
- parse_stems(json_obj_get_type(glyphdump, "stemV", json_array), &g->stemV);
- parse_masks(json_obj_get_type(glyphdump, "hintMasks", json_array), &g->hintMasks);
- parse_masks(json_obj_get_type(glyphdump, "contourMasks", json_array), &g->contourMasks);
- g->yPel = json_obj_getint(glyphdump, "LTSH_yPel");
- }
- // Glyph data of other tables
- g->fdSelect = Handle.fromName(json_obj_getsds(glyphdump, "CFF_fdSelect"));
- if (!g->yPel) { g->yPel = json_obj_getint(glyphdump, "yPel"); }
- return g;
-}
-
-table_glyf *otfcc_parseGlyf(const json_value *root, otfcc_GlyphOrder *glyph_order,
- const otfcc_Options *options) {
- if (root->type != json_object || !glyph_order) return NULL;
- table_glyf *glyf = NULL;
- json_value *table;
- if ((table = json_obj_get_type(root, "glyf", json_object))) {
- loggedStep("glyf") {
- glyphid_t numGlyphs = table->u.object.length;
- glyf = table_iGlyf.createN(numGlyphs);
- for (glyphid_t j = 0; j < numGlyphs; j++) {
- sds gname = sdsnewlen(table->u.object.values[j].name,
- table->u.object.values[j].name_length);
- json_value *glyphdump = table->u.object.values[j].value;
- otfcc_GlyphOrderEntry *order_entry = NULL;
- HASH_FIND(hhName, glyph_order->byName, gname, sdslen(gname), order_entry);
- if (glyphdump->type == json_object && order_entry &&
- !glyf->items[order_entry->gid]) {
- glyf->items[order_entry->gid] =
- otfcc_glyf_parse_glyph(glyphdump, order_entry, options);
- }
- json_value_free(glyphdump);
- json_value *v = json_null_new();
- v->parent = table;
- table->u.object.values[j].value = v;
- sdsfree(gname);
- }
- }
- return glyf;
- }
- return NULL;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/read.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/read.c
deleted file mode 100644
index 4a88d7becc3..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/glyf/read.c
+++ /dev/null
@@ -1,707 +0,0 @@
-#include "../glyf.h"
-
-#include "support/util.h"
-#include "support/ttinstr/ttinstr.h"
-
-static glyf_Point *next_point(glyf_ContourList *contours, shapeid_t *cc, shapeid_t *cp) {
- if (*cp >= contours->items[*cc].length) {
- *cp = 0;
- *cc += 1;
- }
- return &contours->items[*cc].items[(*cp)++];
-}
-
-static glyf_Glyph *otfcc_read_simple_glyph(font_file_pointer start, shapeid_t numberOfContours,
- const otfcc_Options *options) {
- glyf_Glyph *g = otfcc_newGlyf_glyph();
- glyf_ContourList *contours = &g->contours;
-
- shapeid_t pointsInGlyph = 0;
- for (shapeid_t j = 0; j < numberOfContours; j++) {
- shapeid_t lastPointInCurrentContour = read_16u(start + 2 * j);
- glyf_Contour contour;
- glyf_iContour.init(&contour);
- glyf_iContour.fill(&contour, lastPointInCurrentContour - pointsInGlyph + 1);
- glyf_iContourList.push(contours, contour);
- pointsInGlyph = lastPointInCurrentContour + 1;
- }
- uint16_t instructionLength = read_16u(start + 2 * numberOfContours);
- uint8_t *instructions = NULL;
- if (instructionLength > 0) {
- NEW(instructions, instructionLength);
- memcpy(instructions, start + 2 * numberOfContours + 2, sizeof(uint8_t) * instructionLength);
- }
- g->instructionsLength = instructionLength;
- g->instructions = instructions;
-
- // read flags
- // There are repeating entries in the flags list, we will fill out the
- // result
- font_file_pointer flags;
- NEW(flags, pointsInGlyph);
- font_file_pointer flagStart = start + 2 * numberOfContours + 2 + instructionLength;
- shapeid_t flagsReadSofar = 0;
- shapeid_t flagBytesReadSofar = 0;
-
- shapeid_t currentContour = 0;
- shapeid_t currentContourPointIndex = 0;
- while (flagsReadSofar < pointsInGlyph) {
- uint8_t flag = flagStart[flagBytesReadSofar];
- flags[flagsReadSofar] = flag;
- flagBytesReadSofar += 1;
- flagsReadSofar += 1;
- next_point(contours, &currentContour, &currentContourPointIndex)->onCurve =
- (flag & GLYF_FLAG_ON_CURVE);
- if (flag & GLYF_FLAG_REPEAT) { // repeating flag
- uint8_t repeat = flagStart[flagBytesReadSofar];
- flagBytesReadSofar += 1;
- for (uint8_t j = 0; j < repeat; j++) {
- flags[flagsReadSofar + j] = flag;
- next_point(contours, &currentContour, &currentContourPointIndex)->onCurve =
- (flag & GLYF_FLAG_ON_CURVE);
- }
- flagsReadSofar += repeat;
- }
- }
-
- // read X coordinates
- font_file_pointer coordinatesStart = flagStart + flagBytesReadSofar;
- uint32_t coordinatesOffset = 0;
- shapeid_t coordinatesRead = 0;
- currentContour = 0;
- currentContourPointIndex = 0;
- while (coordinatesRead < pointsInGlyph) {
- uint8_t flag = flags[coordinatesRead];
- int16_t x;
- if (flag & GLYF_FLAG_X_SHORT) {
- x = (flag & GLYF_FLAG_POSITIVE_X ? 1 : -1) *
- read_8u(coordinatesStart + coordinatesOffset);
- coordinatesOffset += 1;
- } else {
- if (flag & GLYF_FLAG_SAME_X) {
- x = 0;
- } else {
- x = read_16s(coordinatesStart + coordinatesOffset);
- coordinatesOffset += 2;
- }
- }
- iVQ.replace(&(next_point(contours, &currentContour, &currentContourPointIndex)->x),
- iVQ.createStill(x));
- coordinatesRead += 1;
- }
- // read Y, identical to X
- coordinatesRead = 0;
- currentContour = 0;
- currentContourPointIndex = 0;
- while (coordinatesRead < pointsInGlyph) {
- uint8_t flag = flags[coordinatesRead];
- int16_t y;
- if (flag & GLYF_FLAG_Y_SHORT) {
- y = (flag & GLYF_FLAG_POSITIVE_Y ? 1 : -1) *
- read_8u(coordinatesStart + coordinatesOffset);
- coordinatesOffset += 1;
- } else {
- if (flag & GLYF_FLAG_SAME_Y) {
- y = 0;
- } else {
- y = read_16s(coordinatesStart + coordinatesOffset);
- coordinatesOffset += 2;
- }
- }
- iVQ.replace(&(next_point(contours, &currentContour, &currentContourPointIndex)->y),
- iVQ.createStill(y));
- coordinatesRead += 1;
- }
- FREE(flags);
-
- // turn deltas to absolute coordiantes
- VQ cx = iVQ.neutral(), cy = iVQ.neutral();
- for (shapeid_t j = 0; j < numberOfContours; j++) {
- for (shapeid_t k = 0; k < contours->items[j].length; k++) {
- glyf_Point *z = &contours->items[j].items[k];
- iVQ.inplacePlus(&cx, z->x);
- iVQ.inplacePlus(&cy, z->y);
- iVQ.copyReplace(&z->x, cx);
- iVQ.copyReplace(&z->y, cy);
- }
- glyf_iContour.shrinkToFit(&contours->items[j]);
- }
- glyf_iContourList.shrinkToFit(contours);
- iVQ.dispose(&cx), iVQ.dispose(&cy);
- return g;
-}
-
-static glyf_Glyph *otfcc_read_composite_glyph(font_file_pointer start,
- const otfcc_Options *options) {
- glyf_Glyph *g = otfcc_newGlyf_glyph();
-
- // pass 1, read references quantity
- uint16_t flags = 0;
- uint32_t offset = 0;
- bool glyphHasInstruction = false;
- do {
- flags = read_16u(start + offset);
- glyphid_t index = read_16u(start + offset + 2);
-
- glyf_ComponentReference ref = glyf_iComponentReference.empty();
- ref.glyph = Handle.fromIndex(index);
-
- offset += 4; // flags & index
- if (flags & ARGS_ARE_XY_VALUES) {
- ref.isAnchored = REF_XY;
- if (flags & ARG_1_AND_2_ARE_WORDS) {
- ref.x = iVQ.createStill(read_16s(start + offset));
- ref.y = iVQ.createStill(read_16s(start + offset + 2));
- offset += 4;
- } else {
- ref.x = iVQ.createStill(read_8s(start + offset));
- ref.y = iVQ.createStill(read_8s(start + offset + 1));
- offset += 2;
- }
- } else {
- ref.isAnchored = REF_ANCHOR_ANCHOR;
- if (flags & ARG_1_AND_2_ARE_WORDS) {
- ref.outer = read_16u(start + offset);
- ref.inner = read_16u(start + offset + 2);
- offset += 4;
- } else {
- ref.outer = read_8u(start + offset);
- ref.inner = read_8u(start + offset + 1);
- offset += 2;
- }
- }
- if (flags & WE_HAVE_A_SCALE) {
- ref.a = ref.d = otfcc_from_f2dot14(read_16s(start + offset));
- offset += 2;
- } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
- ref.a = otfcc_from_f2dot14(read_16s(start + offset));
- ref.d = otfcc_from_f2dot14(read_16s(start + offset + 2));
- offset += 4;
- } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
- ref.a = otfcc_from_f2dot14(read_16s(start + offset));
- ref.b = otfcc_from_f2dot14(read_16s(start + offset + 2));
- ref.c = otfcc_from_f2dot14(read_16s(start + offset + 4));
- ref.d = otfcc_from_f2dot14(read_16s(start + offset + 6));
- offset += 8;
- }
- ref.roundToGrid = flags & ROUND_XY_TO_GRID;
- ref.useMyMetrics = flags & USE_MY_METRICS;
- if (flags & SCALED_COMPONENT_OFFSET &&
- (flags & WE_HAVE_AN_X_AND_Y_SCALE || flags & WE_HAVE_A_TWO_BY_TWO)) {
- logWarning("glyf: SCALED_COMPONENT_OFFSET is not supported.")
- }
- if (flags & WE_HAVE_INSTRUCTIONS) { glyphHasInstruction = true; }
- glyf_iReferenceList.push(&g->references, ref);
- } while (flags & MORE_COMPONENTS);
-
- if (glyphHasInstruction) {
- uint16_t instructionLength = read_16u(start + offset);
- font_file_pointer instructions = NULL;
- if (instructionLength > 0) {
- NEW(instructions, instructionLength);
- memcpy(instructions, start + offset + 2, sizeof(uint8_t) * instructionLength);
- }
- g->instructionsLength = instructionLength;
- g->instructions = instructions;
- } else {
- g->instructionsLength = 0;
- g->instructions = NULL;
- }
-
- return g;
-}
-
-static glyf_Glyph *otfcc_read_glyph(font_file_pointer data, uint32_t offset,
- const otfcc_Options *options) {
- font_file_pointer start = data + offset;
- int16_t numberOfContours = read_16u(start);
- glyf_Glyph *g;
- if (numberOfContours > 0) {
- g = otfcc_read_simple_glyph(start + 10, numberOfContours, options);
- } else {
- g = otfcc_read_composite_glyph(start + 10, options);
- }
- g->stat.xMin = read_16s(start + 2);
- g->stat.yMin = read_16s(start + 4);
- g->stat.xMax = read_16s(start + 6);
- g->stat.yMax = read_16s(start + 8);
- return g;
-}
-
-// common states of tuple polymorphizer
-
-typedef struct {
- table_fvar *fvar;
- uint16_t dimensions;
- uint16_t sharedTupleCount;
- f2dot14 *sharedTuples;
- uint8_t coordDimensions;
- bool allowIUP;
- shapeid_t nPhantomPoints;
-} TuplePolymorphizerCtx;
-
-// GVAR header
-#pragma pack(1)
-struct GVARHeader {
- uint16_t majorVersion;
- uint16_t minorVersion;
- uint16_t axisCount;
- uint16_t sharedTupleCount;
- uint32_t sharedTuplesOffset;
- uint16_t glyphCount;
- uint16_t flags;
- uint32_t glyphVariationDataArrayOffset;
-};
-
-struct TupleVariationHeader {
- uint16_t variationDataSize;
- uint16_t tupleIndex;
-};
-struct GlyphVariationData {
- uint16_t tupleVariationCount;
- uint16_t dataOffset;
- struct TupleVariationHeader tvhs[];
-};
-#pragma pack()
-
-#define GVAR_OFFSETS_ARE_LONG 1
-#define EMBEDDED_PEAK_TUPLE 0x8000
-#define INTERMEDIATE_REGION 0x4000
-#define PRIVATE_POINT_NUMBERS 0x2000
-#define TUPLE_INDEX_MASK 0xFFF
-
-static INLINE struct TupleVariationHeader *nextTVH(struct TupleVariationHeader *currentHeader,
- const TuplePolymorphizerCtx *ctx) {
- uint32_t bump = 2 * sizeof(uint16_t);
- uint16_t tupleIndex = be16(currentHeader->tupleIndex);
- if (tupleIndex & EMBEDDED_PEAK_TUPLE) bump += ctx->dimensions * sizeof(f2dot14);
- if (tupleIndex & INTERMEDIATE_REGION) bump += 2 * ctx->dimensions * sizeof(f2dot14);
- return (struct TupleVariationHeader *)((font_file_pointer)currentHeader + bump);
-}
-
-#define POINT_COUNT_IS_WORD 0x80
-#define POINT_COUNT_LONG_MASK 0x7FFF
-#define POINT_RUN_COUNT_MASK 0x7F
-#define POINTS_ARE_WORDS 0x80
-
-static INLINE font_file_pointer parsePointNumbers(font_file_pointer data, shapeid_t **pointIndeces,
- shapeid_t *pc, shapeid_t totalPoints) {
- uint16_t nPoints = 0;
- uint8_t firstByte = *data;
- if (firstByte & POINT_COUNT_IS_WORD) {
- nPoints = (data[0] << 8 | data[1]) & POINT_COUNT_LONG_MASK;
- data += 2;
- } else {
- nPoints = firstByte;
- data++;
- }
- if (nPoints > 0) {
- struct {
- shapeid_t length;
- bool wide;
- } run = {0, false};
- shapeid_t filled = 0;
- shapeid_t jPoint = 0;
- NEW_CLEAN_N(*pointIndeces, nPoints);
- while (filled < nPoints) {
- if (run.length == 0) {
- uint8_t runHeader = *data++;
- run.wide = !!(runHeader & POINTS_ARE_WORDS);
- run.length = (runHeader & POINT_RUN_COUNT_MASK) + 1;
- }
- int16_t pointNumber = jPoint;
- if (run.wide) {
- pointNumber += *((uint16_t *)data);
- data += 2;
- } else {
- pointNumber += *data++;
- }
- (*pointIndeces)[filled] = pointNumber;
- filled++;
- jPoint = pointNumber;
- --run.length;
- }
- *pc = nPoints;
- } else {
- NEW_CLEAN_N(*pointIndeces, totalPoints);
- for (shapeid_t j = 0; j < totalPoints; j++) {
- (*pointIndeces)[j] = j;
- }
- *pc = totalPoints;
- }
-
- return data;
-}
-
-#define DELTAS_ARE_ZERO 0x80
-#define DELTAS_ARE_WORDS 0x40
-#define DELTA_RUN_COUNT_MASK 0x3F
-
-static INLINE font_file_pointer readPackedDelta(font_file_pointer data, shapeid_t nPoints,
- pos_t *deltas) {
- struct {
- shapeid_t length;
- bool wide;
- bool zero;
- } run = {0, false, false};
- shapeid_t filled = 0;
- while (filled < nPoints) {
- int16_t delta = 0;
- if (run.length == 0) {
- uint8_t runHeader = *data++;
- run.zero = runHeader & DELTAS_ARE_ZERO;
- run.wide = runHeader & DELTAS_ARE_WORDS;
- run.length = (runHeader & DELTA_RUN_COUNT_MASK) + 1;
- }
- if (!run.zero) {
- if (run.wide) {
- delta = (int16_t)be16(*(uint16_t *)data);
- data += 2;
- } else {
- delta = (int8_t)*data;
- data++;
- }
- }
- deltas[filled] = (pos_t)delta;
- filled++;
- --run.length;
- }
- return data;
-}
-
-typedef VQ *(*CoordPartGetter)(glyf_Point *z);
-
-static VQ *getX(glyf_Point *z) {
- return &z->x;
-}
-static VQ *getY(glyf_Point *z) {
- return &z->y;
-}
-
-static INLINE void fillTheGaps(shapeid_t jMin, shapeid_t jMax, vq_Segment *nudges,
- glyf_Point **glyphRefs, CoordPartGetter getter) {
- for (shapeid_t j = jMin; j < jMax; j++) {
- if (nudges[j].val.delta.touched) continue;
- // get next knot
- shapeid_t jNext = j;
- while (!nudges[jNext].val.delta.touched) {
- if (jNext == jMax - 1) {
- jNext = jMin;
- } else {
- jNext += 1;
- }
- if (jNext == j) break;
- }
- // get pre knot
- shapeid_t jPrev = j;
- while (!nudges[jPrev].val.delta.touched) {
- if (jPrev == jMin) {
- jPrev = jMax - 1;
- } else {
- jPrev -= 1;
- }
- if (jPrev == j) break;
- }
- if (nudges[jNext].val.delta.touched && nudges[jPrev].val.delta.touched) {
- f16dot16 untouchJ = otfcc_to_fixed(getter(glyphRefs[j])->kernel);
- f16dot16 untouchPrev = otfcc_to_fixed(getter(glyphRefs[jPrev])->kernel);
- f16dot16 untouchNext = otfcc_to_fixed(getter(glyphRefs[jNext])->kernel);
- f16dot16 deltaPrev = otfcc_to_fixed(nudges[jPrev].val.delta.quantity);
- f16dot16 deltaNext = otfcc_to_fixed(nudges[jNext].val.delta.quantity);
-
- f16dot16 uMin = untouchPrev;
- f16dot16 uMax = untouchNext;
- f16dot16 dMin = deltaPrev;
- f16dot16 dMax = deltaNext;
- if (untouchPrev > untouchNext) {
- uMin = untouchNext;
- uMax = untouchPrev;
- dMin = deltaNext;
- dMax = deltaPrev;
- }
- if (untouchJ <= uMin) {
- nudges[j].val.delta.quantity = otfcc_from_fixed(dMin);
- } else if (untouchJ >= uMax) {
- nudges[j].val.delta.quantity = otfcc_from_fixed(dMax);
- } else {
- nudges[j].val.delta.quantity =
- otfcc_from_fixed(otfcc_f1616_muldiv(dMax - dMin, untouchJ - uMin, uMax - uMin));
- }
- }
- }
-}
-
-static void applyCoords(const shapeid_t totalPoints, glyf_Glyph *glyph,
- glyf_Point **glyphRefs, // target
- const shapeid_t nTouchedPoints, const pos_t *tupleDelta,
- const shapeid_t *points,
- const vq_Region *r, // data
- CoordPartGetter getter) {
- vq_Segment *nudges;
- NEW_CLEAN_N(nudges, totalPoints);
- for (shapeid_t j = 0; j < totalPoints; j++) {
- nudges[j].type = VQ_DELTA;
- nudges[j].val.delta.touched = false;
- nudges[j].val.delta.quantity = 0;
- nudges[j].val.delta.region = r;
- }
- for (shapeid_t j = 0; j < nTouchedPoints; j++) {
- if (points[j] >= totalPoints) continue;
- nudges[points[j]].val.delta.touched = true;
- nudges[points[j]].val.delta.quantity += tupleDelta[j];
- }
- // fill the gaps
- shapeid_t jFirst = 0;
- foreach (glyf_Contour *c, glyph->contours) {
- fillTheGaps(jFirst, jFirst + c->length, nudges, glyphRefs, getX);
- jFirst += c->length;
- }
- for (shapeid_t j = 0; j < totalPoints; j++) {
- if (!nudges[j].val.delta.quantity && nudges[j].val.delta.touched) continue;
- VQ *coordinatePart = getter(glyphRefs[j]);
- vq_iSegList.push(&(coordinatePart->shift), nudges[j]);
- }
- FREE(nudges);
-}
-
-static INLINE void applyPolymorphism(const shapeid_t totalPoints, glyf_GlyphPtr glyph, // target
- const shapeid_t nTouchedPoints, const shapeid_t *points,
- const pos_t *deltaX, const pos_t *deltaY,
- const vq_Region *r // delta data
-) {
- glyf_Point **glyphRefs;
- NEW_CLEAN_N(glyphRefs, totalPoints);
- {
- shapeid_t j = 0;
- foreach (glyf_Contour *c, glyph->contours) {
- foreach (glyf_Point *g, *c) { glyphRefs[j++] = g; }
- }
- foreach (glyf_ComponentReference *r, glyph->references) {
- // in glyf_ComponentReference, we also have a X and a Y entry
- // so a trick of conversion
- glyphRefs[j++] = (glyf_Point *)&(r->x);
- }
- }
- applyCoords(totalPoints, glyph, glyphRefs, nTouchedPoints, deltaX, points, r, getX);
- applyCoords(totalPoints, glyph, glyphRefs, nTouchedPoints, deltaY, points, r, getY);
- // Horizontal phantom point
- if (totalPoints + 1 < nTouchedPoints) {
- iVQ.addDelta(&(glyph->horizontalOrigin), true, r, deltaX[totalPoints]);
- iVQ.addDelta(&(glyph->advanceWidth), true, r,
- deltaX[totalPoints + 1] - deltaX[totalPoints]);
- }
- // Vertical phantom point
- if (totalPoints + 3 < nTouchedPoints) {
- iVQ.addDelta(&(glyph->verticalOrigin), true, r, deltaY[totalPoints + 2]);
- iVQ.addDelta(&(glyph->advanceHeight), true, r,
- deltaY[totalPoints + 2] - deltaY[totalPoints + 3]);
- }
-
- FREE(glyphRefs);
-}
-
-static vq_Region *createRegionFromTuples(uint16_t dimensions, f2dot14 *peak, f2dot14 *start,
- f2dot14 *end) {
- vq_Region *r = vq_createRegion(dimensions);
- for (uint16_t d = 0; d < dimensions; d++) {
- pos_t peakVal = otfcc_from_f2dot14(be16(peak[d]));
- vq_AxisSpan span = {peakVal <= 0 ? -1 : 0, peakVal, peakVal >= 0 ? 1 : 0};
- if (start && end) {
- span.start = otfcc_from_f2dot14(be16(start[d]));
- span.end = otfcc_from_f2dot14(be16(end[d]));
- }
- r->spans[d] = span;
- }
- return r;
-}
-
-static INLINE void polymorphizeGlyph(glyphid_t gid, glyf_GlyphPtr glyph,
- const TuplePolymorphizerCtx *ctx,
- struct GlyphVariationData *gvd, const otfcc_Options *options) {
-
- shapeid_t totalPoints = 0;
- foreach (glyf_Contour *c, glyph->contours) { totalPoints += c->length; }
- totalPoints += glyph->references.length;
- shapeid_t totalDeltaEntries = totalPoints + ctx->nPhantomPoints;
-
- uint16_t nTuples = be16(gvd->tupleVariationCount) & 0xFFF;
- struct TupleVariationHeader *tvh = gvd->tvhs;
-
- bool hasSharedPointNumbers = be16(gvd->tupleVariationCount) & 0x8000;
- shapeid_t sharedPointCount = 0;
- shapeid_t *sharedPointIndeces = NULL;
- font_file_pointer data = (font_file_pointer)gvd + be16(gvd->dataOffset);
- if (hasSharedPointNumbers) {
- data = parsePointNumbers(data, &sharedPointIndeces, &sharedPointCount, totalDeltaEntries);
- }
-
- size_t tsdStart = 0;
-
- for (uint16_t j = 0; j < nTuples; j++) {
-
- // Tuple options
- shapeid_t tupleIndex = be16(tvh->tupleIndex) & TUPLE_INDEX_MASK;
- bool hasEmbeddedPeak = be16(tvh->tupleIndex) & EMBEDDED_PEAK_TUPLE;
- bool hasIntermediate = be16(tvh->tupleIndex) & INTERMEDIATE_REGION;
-
- // Peak tuple
- f2dot14 *peak = NULL;
- if (hasEmbeddedPeak) {
- peak = (f2dot14 *)(((font_file_pointer)tvh) + 4);
- } else {
- peak = ctx->sharedTuples + ctx->dimensions * tupleIndex;
- }
-
- // Intermediate tuple -- if present
- f2dot14 *start = NULL;
- f2dot14 *end = NULL;
- if (hasIntermediate) {
- start = (f2dot14 *)(((font_file_pointer)tvh) + 4 +
- 2 * (hasEmbeddedPeak ? 1 : 0) * ctx->dimensions);
- end = (f2dot14 *)(((font_file_pointer)tvh) + 4 +
- 2 * (hasEmbeddedPeak ? 2 : 1) * ctx->dimensions);
- }
-
- const vq_Region *r = table_iFvar.registerRegion(
- ctx->fvar, createRegionFromTuples(ctx->dimensions, peak, start, end));
-
- // Pointer of tuple serialized data
- font_file_pointer tsd = data + tsdStart;
- // Point number term
- shapeid_t nPoints = sharedPointCount;
- shapeid_t *pointIndeces = sharedPointIndeces;
-
- if (be16(tvh->tupleIndex) & PRIVATE_POINT_NUMBERS) {
- shapeid_t privatePointCount = 0;
- shapeid_t *privatePointNumbers = NULL;
- tsd =
- parsePointNumbers(tsd, &privatePointNumbers, &privatePointCount, totalDeltaEntries);
- nPoints = privatePointCount;
- pointIndeces = privatePointNumbers;
- }
- if (pointIndeces) {
- // Delta term
- pos_t *deltaX = 0;
- pos_t *deltaY = 0;
- NEW_CLEAN_N(deltaX, nPoints);
- NEW_CLEAN_N(deltaY, nPoints);
-
- tsd = readPackedDelta(tsd, nPoints, deltaX);
- tsd = readPackedDelta(tsd, nPoints, deltaY);
-
- // Do polymorphize
- applyPolymorphism(totalPoints, glyph, nPoints, pointIndeces, deltaX, deltaY, r);
- FREE(deltaX);
- FREE(deltaY);
- }
- // Cleanup
- if (be16(tvh->tupleIndex) & PRIVATE_POINT_NUMBERS) { FREE(pointIndeces); }
- tsdStart += be16(tvh->variationDataSize);
-
- tvh = nextTVH(tvh, ctx);
- }
- FREE(sharedPointIndeces);
-}
-
-// NOTE: for polymorphize, we would
-// TODO: polymorphize advanceWidth, verticalOrigin and advanceHeight
-static INLINE void polymorphize(const otfcc_Packet packet, const otfcc_Options *options,
- table_glyf *glyf, const GlyfIOContext *ctx) {
- if (!ctx->fvar || !ctx->fvar->axes.length) return;
- FOR_TABLE(OTFCC_CHR('g','v','a','r'), table) {
- font_file_pointer data = table.data;
- if (table.length < sizeof(struct GVARHeader)) return;
- struct GVARHeader *header = (struct GVARHeader *)data;
- if (be16(header->axisCount) != ctx->fvar->axes.length) {
- logWarning("Axes number in GVAR and FVAR are inequal");
- return;
- };
- for (glyphid_t j = 0; j < glyf->length; j++) {
- TuplePolymorphizerCtx tpctx = {.fvar = ctx->fvar,
- .dimensions = ctx->fvar->axes.length,
- .nPhantomPoints = ctx->nPhantomPoints,
- .sharedTupleCount = be16(header->sharedTupleCount),
- .sharedTuples =
- (f2dot14 *)(data + be32(header->sharedTuplesOffset)),
- .coordDimensions = 2,
- .allowIUP = glyf->items[j]->contours.length > 0};
- uint32_t glyphVariationDataOffset = 0;
- if (be16(header->flags) & GVAR_OFFSETS_ARE_LONG) {
- glyphVariationDataOffset =
- be32(((uint32_t *)(data + sizeof(struct GVARHeader)))[j]);
- } else {
- glyphVariationDataOffset =
- 2 * be16(((uint16_t *)(data + sizeof(struct GVARHeader)))[j]);
- }
- struct GlyphVariationData *gvd =
- (struct GlyphVariationData *)(data + be32(header->glyphVariationDataArrayOffset) +
- glyphVariationDataOffset);
- polymorphizeGlyph(j, glyf->items[j], &tpctx, gvd, options);
- }
- }
-}
-
-table_glyf *otfcc_readGlyf(const otfcc_Packet packet, const otfcc_Options *options,
- const GlyfIOContext *ctx) {
- uint32_t *offsets = NULL;
- table_glyf *glyf = NULL;
-
- NEW_CLEAN_N(offsets, (ctx->numGlyphs + 1));
- if (!offsets) goto ABSENT;
- bool foundLoca = false;
-
- // read loca
- FOR_TABLE(OTFCC_CHR('l','o','c','a'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- if (length < 2 * ctx->numGlyphs + 2) goto LOCA_CORRUPTED;
- for (uint32_t j = 0; j < ctx->numGlyphs + 1; j++) {
- if (ctx->locaIsLong) {
- offsets[j] = read_32u(data + j * 4);
- } else {
- offsets[j] = read_16u(data + j * 2) * 2;
- }
- if (j > 0 && offsets[j] < offsets[j - 1]) goto LOCA_CORRUPTED;
- }
- foundLoca = true;
- break;
- LOCA_CORRUPTED:
- logWarning("table 'loca' corrupted.\n");
- if (offsets) { FREE(offsets), offsets = NULL; }
- continue;
- }
- if (!foundLoca) goto ABSENT;
-
- // read glyf
- FOR_TABLE(OTFCC_CHR('g','l','y','f'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- if (length < offsets[ctx->numGlyphs]) goto GLYF_CORRUPTED;
-
- glyf = table_iGlyf.create();
-
- for (glyphid_t j = 0; j < ctx->numGlyphs; j++) {
- if (offsets[j] < offsets[j + 1]) { // non-space glyph
- table_iGlyf.push(glyf, otfcc_read_glyph(data, offsets[j], options));
- } else { // space glyph
- table_iGlyf.push(glyf, otfcc_newGlyf_glyph());
- }
- }
- goto PRESENT;
- GLYF_CORRUPTED:
- logWarning("table 'glyf' corrupted.\n");
- if (glyf) { DELETE(table_iGlyf.free, glyf), glyf = NULL; }
- }
- goto ABSENT;
-
-PRESENT:
- if (offsets) { FREE(offsets), offsets = NULL; }
- // We have glyf table read. Do polymorphize
- polymorphize(packet, options, glyf, ctx);
- return glyf;
-
-ABSENT:
- if (offsets) { FREE(offsets), offsets = NULL; }
- if (glyf) { FREE(glyf), glyf = NULL; }
- return NULL;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.c
deleted file mode 100644
index d20011ed046..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "hdmx.h"
-
-#include "support/util.h"
-
-static INLINE void disposeHdmx(MOVE table_hdmx *table) {
- if (!table->records) return;
- for (uint32_t i = 0; i < table->numRecords; i++) {
- if (table->records[i].widths != NULL) FREE(table->records[i].widths);
- }
- FREE(table->records);
-}
-
-caryll_standardRefType(table_hdmx, table_iHdmx, disposeHdmx);
-
-table_hdmx *otfcc_readHdmx(otfcc_Packet packet, const otfcc_Options *options, table_maxp *maxp) {
- FOR_TABLE(OTFCC_CHR('h','d','m','x'), table) {
- font_file_pointer data = table.data;
-
- table_hdmx *hdmx;
- NEW(hdmx);
- hdmx->version = read_16u(data);
- hdmx->numRecords = read_16u(data + 2);
- hdmx->sizeDeviceRecord = read_32u(data + 4);
- NEW(hdmx->records, hdmx->numRecords);
-
- for (uint32_t i = 0; i < hdmx->numRecords; i++) {
- hdmx->records[i].pixelSize = *(data + 8 + i * (2 + maxp->numGlyphs));
- hdmx->records[i].maxWidth = *(data + 8 + i * (2 + maxp->numGlyphs) + 1);
- NEW(hdmx->records[i].widths, maxp->numGlyphs);
- memcpy(hdmx->records[i].widths, data + 8 + i * (2 + maxp->numGlyphs) + 2, maxp->numGlyphs);
- }
-
- return hdmx;
- }
- return NULL;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.h
deleted file mode 100644
index 77fb3804ca1..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hdmx.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CARYLL_TABLE_HDMX_H
-#define CARYLL_TABLE_HDMX_H
-
-#include "otfcc/table/hdmx.h"
-
-table_hdmx *otfcc_readHdmx(otfcc_Packet packet, const otfcc_Options *options, table_maxp *maxp);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.c
deleted file mode 100644
index e5478aab4ec..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.c
+++ /dev/null
@@ -1,137 +0,0 @@
-#include "head.h"
-
-#include "support/util.h"
-
-static INLINE void initHead(table_head *head) {
- memset(head, 0, sizeof(*head));
- head->magicNumber = 0x5f0f3cf5;
- head->unitsPerEm = 1000;
-}
-static INLINE void disposeHead(table_head *head) {
- // trivial
-}
-caryll_standardRefType(table_head, table_iHead, initHead, disposeHead);
-
-table_head *otfcc_readHead(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('h','e','a','d'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
-
- if (length < 54) {
- logWarning("table 'head' corrupted.\n");
- } else {
- table_head *head;
- NEW(head);
- head->version = read_32s(data);
- head->fontRevision = read_32u(data + 4);
- head->checkSumAdjustment = read_32u(data + 8);
- head->magicNumber = read_32u(data + 12);
- head->flags = read_16u(data + 16);
- head->unitsPerEm = read_16u(data + 18);
- head->created = read_64u(data + 20);
- head->modified = read_64u(data + 28);
- head->xMin = read_16u(data + 36);
- head->yMin = read_16u(data + 38);
- head->xMax = read_16u(data + 40);
- head->yMax = read_16u(data + 42);
- head->macStyle = read_16u(data + 44);
- head->lowestRecPPEM = read_16u(data + 46);
- head->fontDirectoryHint = read_16u(data + 48);
- head->indexToLocFormat = read_16u(data + 50);
- head->glyphDataFormat = read_16u(data + 52);
- return head;
- }
- }
- return NULL;
-}
-
-static const char *headFlagsLabels[] = {"baselineAtY_0",
- "lsbAtX_0",
- "instrMayDependOnPointSize",
- "alwaysUseIntegerSize",
- "instrMayAlterAdvanceWidth",
- "designedForVertical",
- "_reserved1",
- "designedForComplexScript",
- "hasMetamorphosisEffects",
- "containsStrongRTL",
- "containsIndicRearrangement",
- "fontIsLossless",
- "fontIsConverted",
- "optimizedForCleartype",
- "lastResortFont",
- NULL};
-static const char *macStyleLabels[] = {"bold", "italic", "underline", "outline",
- "shadow", "condensed", "extended", NULL};
-
-void otfcc_dumpHead(const table_head *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("head") {
- json_value *head = json_object_new(15);
- json_object_push(head, "version", json_double_new(otfcc_from_fixed(table->version)));
- json_object_push(head, "fontRevision",
- json_double_new(otfcc_from_fixed(table->fontRevision)));
- json_object_push(head, "flags", otfcc_dump_flags(table->flags, headFlagsLabels));
- json_object_push(head, "unitsPerEm", json_integer_new(table->unitsPerEm));
- json_object_push(head, "created", json_integer_new(table->created));
- json_object_push(head, "modified", json_integer_new(table->modified));
- json_object_push(head, "xMin", json_integer_new(table->xMin));
- json_object_push(head, "xMax", json_integer_new(table->xMax));
- json_object_push(head, "yMin", json_integer_new(table->yMin));
- json_object_push(head, "yMax", json_integer_new(table->yMax));
- json_object_push(head, "macStyle", otfcc_dump_flags(table->macStyle, macStyleLabels));
- json_object_push(head, "lowestRecPPEM", json_integer_new(table->lowestRecPPEM));
- json_object_push(head, "fontDirectoryHint", json_integer_new(table->fontDirectoryHint));
- json_object_push(head, "indexToLocFormat", json_integer_new(table->indexToLocFormat));
- json_object_push(head, "glyphDataFormat", json_integer_new(table->glyphDataFormat));
- json_object_push(root, "head", head);
- }
-}
-
-table_head *otfcc_parseHead(const json_value *root, const otfcc_Options *options) {
- table_head *head = table_iHead.create();
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "head", json_object))) {
- loggedStep("head") {
- head->version = otfcc_to_fixed(json_obj_getnum_fallback(table, "version", 0));
- head->fontRevision = otfcc_to_fixed(json_obj_getnum_fallback(table, "fontRevision", 0));
- head->flags = otfcc_parse_flags(json_obj_get(table, "flags"), headFlagsLabels);
- head->unitsPerEm = json_obj_getnum_fallback(table, "unitsPerEm", 0);
- head->created = json_obj_getnum_fallback(table, "created", 0);
- head->modified = json_obj_getnum_fallback(table, "modified", 0);
- head->xMin = json_obj_getnum_fallback(table, "xMin", 0);
- head->xMax = json_obj_getnum_fallback(table, "xMax", 0);
- head->yMin = json_obj_getnum_fallback(table, "yMin", 0);
- head->yMax = json_obj_getnum_fallback(table, "yMax", 0);
- head->macStyle = otfcc_parse_flags(json_obj_get(table, "macStyle"), macStyleLabels);
- head->lowestRecPPEM = json_obj_getnum_fallback(table, "lowestRecPPEM", 0);
- head->fontDirectoryHint = json_obj_getnum_fallback(table, "fontDirectoryHint", 0);
- head->indexToLocFormat = json_obj_getnum_fallback(table, "indexToLocFormat", 0);
- head->glyphDataFormat = json_obj_getnum_fallback(table, "glyphDataFormat", 0);
- }
- }
- return head;
-}
-
-caryll_Buffer *otfcc_buildHead(const table_head *head, const otfcc_Options *options) {
- if (!head) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite32b(buf, head->version);
- bufwrite32b(buf, head->fontRevision);
- bufwrite32b(buf, head->checkSumAdjustment);
- bufwrite32b(buf, head->magicNumber);
- bufwrite16b(buf, head->flags);
- bufwrite16b(buf, head->unitsPerEm);
- bufwrite64b(buf, head->created);
- bufwrite64b(buf, head->modified);
- bufwrite16b(buf, head->xMin);
- bufwrite16b(buf, head->yMin);
- bufwrite16b(buf, head->xMax);
- bufwrite16b(buf, head->yMax);
- bufwrite16b(buf, head->macStyle);
- bufwrite16b(buf, head->lowestRecPPEM);
- bufwrite16b(buf, head->fontDirectoryHint);
- bufwrite16b(buf, head->indexToLocFormat);
- bufwrite16b(buf, head->glyphDataFormat);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.h
deleted file mode 100644
index 75a2baff918..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/head.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_HEAD_H
-#define CARYLL_TABLE_HEAD_H
-
-#include "otfcc/table/head.h"
-
-table_head *otfcc_readHead(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpHead(const table_head *table, json_value *root, const otfcc_Options *options);
-table_head *otfcc_parseHead(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildHead(const table_head *head, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.c
deleted file mode 100644
index 87806448de0..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "hhea.h"
-
-#include "support/util.h"
-
-static INLINE void initHhea(table_hhea *hhea) {
- memset(hhea, 0, sizeof(*hhea));
- hhea->version = 0x10000;
-}
-static INLINE void disposeHhea(MOVE table_hhea *hhea) {
- // trivial
-}
-caryll_standardRefType(table_hhea, table_iHhea, initHhea, disposeHhea);
-
-table_hhea *otfcc_readHhea(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('h','h','e','a'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
-
- if (length < 36) {
- logWarning("table 'hhea' corrupted.\n");
- } else {
- table_hhea *hhea;
- NEW(hhea);
- hhea->version = read_32s(data);
- hhea->ascender = read_16u(data + 4);
- hhea->descender = read_16u(data + 6);
- hhea->lineGap = read_16u(data + 8);
- hhea->advanceWidthMax = read_16u(data + 10);
- hhea->minLeftSideBearing = read_16u(data + 12);
- hhea->minRightSideBearing = read_16u(data + 14);
- hhea->xMaxExtent = read_16u(data + 16);
- hhea->caretSlopeRise = read_16u(data + 18);
- hhea->caretSlopeRun = read_16u(data + 20);
- hhea->caretOffset = read_16u(data + 22);
- hhea->reserved[0] = read_16u(data + 24);
- hhea->reserved[1] = read_16u(data + 26);
- hhea->reserved[2] = read_16u(data + 28);
- hhea->reserved[3] = read_16u(data + 30);
- hhea->metricDataFormat = read_16u(data + 32);
- hhea->numberOfMetrics = read_16u(data + 34);
- return hhea;
- }
- }
- return NULL;
-}
-
-void otfcc_dumpHhea(const table_hhea *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("hhea") {
- json_value *hhea = json_object_new(13);
- json_object_push(hhea, "version", json_double_new(otfcc_from_fixed(table->version)));
- json_object_push(hhea, "ascender", json_integer_new(table->ascender));
- json_object_push(hhea, "descender", json_integer_new(table->descender));
- json_object_push(hhea, "lineGap", json_integer_new(table->lineGap));
- json_object_push(hhea, "advanceWidthMax", json_integer_new(table->advanceWidthMax));
- json_object_push(hhea, "minLeftSideBearing", json_integer_new(table->minLeftSideBearing));
- json_object_push(hhea, "minRightSideBearing", json_integer_new(table->minRightSideBearing));
- json_object_push(hhea, "xMaxExtent", json_integer_new(table->xMaxExtent));
- json_object_push(hhea, "caretSlopeRise", json_integer_new(table->caretSlopeRise));
- json_object_push(hhea, "caretSlopeRun", json_integer_new(table->caretSlopeRun));
- json_object_push(hhea, "caretOffset", json_integer_new(table->caretOffset));
- json_object_push(root, "hhea", hhea);
- }
-}
-
-table_hhea *otfcc_parseHhea(const json_value *root, const otfcc_Options *options) {
- table_hhea *hhea = table_iHhea.create();
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "hhea", json_object))) {
- loggedStep("hhea") {
- hhea->version = otfcc_to_fixed(json_obj_getnum_fallback(table, "version", 0));
- hhea->ascender = json_obj_getnum_fallback(table, "ascender", 0);
- hhea->descender = json_obj_getnum_fallback(table, "descender", 0);
- hhea->lineGap = json_obj_getnum_fallback(table, "lineGap", 0);
- hhea->advanceWidthMax = json_obj_getnum_fallback(table, "advanceWidthMax", 0);
- hhea->minLeftSideBearing = json_obj_getnum_fallback(table, "minLeftSideBearing", 0);
- hhea->minRightSideBearing = json_obj_getnum_fallback(table, "minRightSideBearing", 0);
- hhea->xMaxExtent = json_obj_getnum_fallback(table, "xMaxExtent", 0);
- hhea->caretSlopeRise = json_obj_getnum_fallback(table, "caretSlopeRise", 0);
- hhea->caretSlopeRun = json_obj_getnum_fallback(table, "caretSlopeRun", 0);
- hhea->caretOffset = json_obj_getnum_fallback(table, "caretOffset", 0);
- }
- }
- return hhea;
-}
-
-caryll_Buffer *otfcc_buildHhea(const table_hhea *hhea, const otfcc_Options *options) {
- if (!hhea) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite32b(buf, hhea->version);
- bufwrite16b(buf, hhea->ascender);
- bufwrite16b(buf, hhea->descender);
- bufwrite16b(buf, hhea->lineGap);
- bufwrite16b(buf, hhea->advanceWidthMax);
- bufwrite16b(buf, hhea->minLeftSideBearing);
- bufwrite16b(buf, hhea->minRightSideBearing);
- bufwrite16b(buf, hhea->xMaxExtent);
- bufwrite16b(buf, hhea->caretSlopeRise);
- bufwrite16b(buf, hhea->caretSlopeRun);
- bufwrite16b(buf, hhea->caretOffset);
- bufwrite16b(buf, hhea->reserved[0]);
- bufwrite16b(buf, hhea->reserved[1]);
- bufwrite16b(buf, hhea->reserved[2]);
- bufwrite16b(buf, hhea->reserved[3]);
- bufwrite16b(buf, 0);
- bufwrite16b(buf, hhea->numberOfMetrics);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.h
deleted file mode 100644
index 93ce8631326..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hhea.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef CARYLL_TABLE_HHEA_H
-#define CARYLL_TABLE_HHEA_H
-
-#include "otfcc/table/hhea.h"
-
-table_hhea *otfcc_newHhea();
-table_hhea *otfcc_readHhea(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpHhea(const table_hhea *table, json_value *root, const otfcc_Options *options);
-table_hhea *otfcc_parseHhea(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildHhea(const table_hhea *hhea, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.c
deleted file mode 100644
index 50a5c671fd5..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "hmtx.h"
-
-#include "support/util.h"
-
-static INLINE void disposeHmtx(MOVE table_hmtx *table) {
- if (table->metrics != NULL) FREE(table->metrics);
- if (table->leftSideBearing != NULL) FREE(table->leftSideBearing);
-}
-
-caryll_standardRefType(table_hmtx, table_iHmtx, disposeHmtx);
-
-table_hmtx *otfcc_readHmtx(const otfcc_Packet packet, const otfcc_Options *options,
- table_hhea *hhea, table_maxp *maxp) {
- if (!hhea || !maxp || !hhea->numberOfMetrics || maxp->numGlyphs < hhea->numberOfMetrics) {
- return NULL;
- }
- FOR_TABLE(OTFCC_CHR('h','m','t','x'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
-
- table_hmtx *hmtx = NULL;
-
- glyphid_t count_a = hhea->numberOfMetrics;
- glyphid_t count_k = maxp->numGlyphs - hhea->numberOfMetrics;
- if (length < count_a * 4 + count_k * 2) goto HMTX_CORRUPTED;
-
- NEW(hmtx);
- NEW(hmtx->metrics, count_a);
- NEW(hmtx->leftSideBearing, count_k);
-
- for (glyphid_t ia = 0; ia < count_a; ia++) {
- hmtx->metrics[ia].advanceWidth = read_16u(data + ia * 4);
- hmtx->metrics[ia].lsb = read_16s(data + ia * 4 + 2);
- }
-
- for (glyphid_t ik = 0; ik < count_k; ik++) {
- hmtx->leftSideBearing[ik] = read_16s(data + count_a * 4 + ik * 2);
- }
-
- return hmtx;
- HMTX_CORRUPTED:
- logWarning("Table 'hmtx' corrupted.\n");
- if (hmtx) { table_iHmtx.free(hmtx), hmtx = NULL; }
- }
- return NULL;
-}
-
-caryll_Buffer *otfcc_buildHmtx(const table_hmtx *hmtx, glyphid_t count_a, glyphid_t count_k,
- const otfcc_Options *options) {
- caryll_Buffer *buf = bufnew();
- if (!hmtx) return buf;
- if (hmtx->metrics) {
- for (glyphid_t j = 0; j < count_a; j++) {
- bufwrite16b(buf, hmtx->metrics[j].advanceWidth);
- bufwrite16b(buf, hmtx->metrics[j].lsb);
- }
- }
- if (hmtx->leftSideBearing) {
- for (glyphid_t j = 0; j < count_k; j++) {
- bufwrite16b(buf, hmtx->leftSideBearing[j]);
- }
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.h
deleted file mode 100644
index a6a3a55fb85..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/hmtx.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef CARYLL_TABLE_HMTX_H
-#define CARYLL_TABLE_HMTX_H
-
-#include "otfcc/table/hmtx.h"
-
-table_hmtx *otfcc_readHmtx(const otfcc_Packet packet, const otfcc_Options *options, table_hhea *hhea, table_maxp *maxp);
-caryll_Buffer *otfcc_buildHmtx(const table_hmtx *table, glyphid_t count_a, glyphid_t count_k,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.c
deleted file mode 100644
index 126f7536ab4..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.c
+++ /dev/null
@@ -1,125 +0,0 @@
-#include "maxp.h"
-
-#include "support/util.h"
-
-static INLINE void initMaxp(table_maxp *maxp) {
- memset(maxp, 0, sizeof(*maxp));
- maxp->version = 0x10000;
-}
-static INLINE void disposeMaxp(MOVE table_maxp *maxp) {
- // trivial
-}
-caryll_standardRefType(table_maxp, table_iMaxp, initMaxp, disposeMaxp);
-
-table_maxp *otfcc_readMaxp(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('m','a','x','p'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
-
- if (length != 32 && length != 6) {
- logWarning("table 'maxp' corrupted.\n");
- } else {
- table_maxp *maxp = table_iMaxp.create();
- maxp->version = read_32s(data);
- maxp->numGlyphs = read_16u(data + 4);
- if (maxp->version == 0x00010000) { // TrueType Format 1
- maxp->maxPoints = read_16u(data + 6);
- maxp->maxContours = read_16u(data + 8);
- maxp->maxCompositePoints = read_16u(data + 10);
- maxp->maxCompositeContours = read_16u(data + 12);
- maxp->maxZones = read_16u(data + 14);
- maxp->maxTwilightPoints = read_16u(data + 16);
- maxp->maxStorage = read_16u(data + 18);
- maxp->maxFunctionDefs = read_16u(data + 20);
- maxp->maxInstructionDefs = read_16u(data + 22);
- maxp->maxStackElements = read_16u(data + 24);
- maxp->maxSizeOfInstructions = read_16u(data + 26);
- maxp->maxComponentElements = read_16u(data + 28);
- maxp->maxComponentDepth = read_16u(data + 30);
- } else { // CFF OTF Format 0.5
- maxp->maxPoints = 0;
- maxp->maxContours = 0;
- maxp->maxCompositePoints = 0;
- maxp->maxCompositeContours = 0;
- maxp->maxZones = 0;
- maxp->maxTwilightPoints = 0;
- maxp->maxStorage = 0;
- maxp->maxFunctionDefs = 0;
- maxp->maxInstructionDefs = 0;
- maxp->maxStackElements = 0;
- maxp->maxSizeOfInstructions = 0;
- maxp->maxComponentElements = 0;
- maxp->maxComponentDepth = 0;
- }
- return maxp;
- }
- }
- return NULL;
-}
-
-void otfcc_dumpMaxp(const table_maxp *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("maxp") {
- json_value *maxp = json_object_new(15);
- json_object_push(maxp, "version", json_double_new(otfcc_from_fixed(table->version)));
- json_object_push(maxp, "numGlyphs", json_integer_new(table->numGlyphs));
- json_object_push(maxp, "maxPoints", json_integer_new(table->maxPoints));
- json_object_push(maxp, "maxContours", json_integer_new(table->maxContours));
- json_object_push(maxp, "maxCompositePoints", json_integer_new(table->maxCompositePoints));
- json_object_push(maxp, "maxCompositeContours",
- json_integer_new(table->maxCompositeContours));
- json_object_push(maxp, "maxZones", json_integer_new(table->maxZones));
- json_object_push(maxp, "maxTwilightPoints", json_integer_new(table->maxTwilightPoints));
- json_object_push(maxp, "maxStorage", json_integer_new(table->maxStorage));
- json_object_push(maxp, "maxFunctionDefs", json_integer_new(table->maxFunctionDefs));
- json_object_push(maxp, "maxInstructionDefs", json_integer_new(table->maxInstructionDefs));
- json_object_push(maxp, "maxStackElements", json_integer_new(table->maxStackElements));
- json_object_push(maxp, "maxSizeOfInstructions",
- json_integer_new(table->maxSizeOfInstructions));
- json_object_push(maxp, "maxComponentElements",
- json_integer_new(table->maxComponentElements));
- json_object_push(maxp, "maxComponentDepth", json_integer_new(table->maxComponentDepth));
- json_object_push(root, "maxp", maxp);
- }
-}
-
-table_maxp *otfcc_parseMaxp(const json_value *root, const otfcc_Options *options) {
- table_maxp *maxp = table_iMaxp.create();
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "maxp", json_object))) {
- loggedStep("maxp") {
- maxp->version = otfcc_to_fixed(json_obj_getnum(table, "version"));
- maxp->numGlyphs = json_obj_getnum(table, "numGlyphs");
- maxp->maxZones = json_obj_getnum(table, "maxZones");
- maxp->maxTwilightPoints = json_obj_getnum(table, "maxTwilightPoints");
- maxp->maxStorage = json_obj_getnum(table, "maxStorage");
- maxp->maxFunctionDefs = json_obj_getnum(table, "maxFunctionDefs");
- maxp->maxInstructionDefs = json_obj_getnum(table, "maxInstructionDefs");
- maxp->maxStackElements = json_obj_getnum(table, "maxStackElements");
- }
- }
- return maxp;
-}
-
-caryll_Buffer *otfcc_buildMaxp(const table_maxp *maxp, const otfcc_Options *options) {
- if (!maxp) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite32b(buf, maxp->version);
- bufwrite16b(buf, maxp->numGlyphs);
- if (maxp->version > 0x00005000) {
- bufwrite16b(buf, maxp->maxPoints);
- bufwrite16b(buf, maxp->maxContours);
- bufwrite16b(buf, maxp->maxCompositePoints);
- bufwrite16b(buf, maxp->maxCompositeContours);
- bufwrite16b(buf, maxp->maxZones);
- bufwrite16b(buf, maxp->maxTwilightPoints);
- bufwrite16b(buf, maxp->maxStorage);
- bufwrite16b(buf, maxp->maxFunctionDefs);
- bufwrite16b(buf, maxp->maxInstructionDefs);
- bufwrite16b(buf, maxp->maxStackElements);
- bufwrite16b(buf, maxp->maxSizeOfInstructions);
- bufwrite16b(buf, maxp->maxComponentElements);
- bufwrite16b(buf, maxp->maxComponentDepth);
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.h
deleted file mode 100644
index bd9ec134c4d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/maxp.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_MAXP_H
-#define CARYLL_TABLE_MAXP_H
-
-#include "otfcc/table/maxp.h"
-
-table_maxp *otfcc_readMaxp(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpMaxp(const table_maxp *table, json_value *root, const otfcc_Options *options);
-table_maxp *otfcc_parseMaxp(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildMaxp(const table_maxp *maxp, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta.h
deleted file mode 100644
index f0cb1216560..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_META_H
-#define CARYLL_TABLE_META_H
-
-#include "otfcc/table/meta.h"
-
-table_meta *otfcc_readMeta(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpMeta(const table_meta *table, json_value *root, const otfcc_Options *options);
-table_meta *otfcc_parseMeta(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildMeta(const table_meta *meta, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/build.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/build.c
deleted file mode 100644
index 2d9c327118b..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/build.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "../meta.h"
-
-#include "support/util.h"
-#include "bk/bkgraph.h"
-
-caryll_Buffer *otfcc_buildMeta(const table_meta *meta, const otfcc_Options *options) {
- if (!meta || !meta->entries.length) return NULL;
- bk_Block *root = bk_new_Block(b32, meta->version, // Version
- b32, meta->flags, // Flags
- b32, 0, // RESERVED
- b32, (uint32_t)meta->entries.length, // dataMapsCount
- bkover);
- foreach (meta_Entry *e, meta->entries) {
- bk_push(root, /// begin
- b32, e->tag, // tag
- p32, bk_newBlockFromStringLen(sdslen(e->data), e->data), // dataOffset
- b32, sdslen(e->data), // dataLength
- bkover);
- }
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/dump.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/dump.c
deleted file mode 100644
index 3f0dd3d2b78..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/dump.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "../meta.h"
-
-#include "support/util.h"
-
-static INLINE bool isStringTag(uint32_t tag) {
- return tag == OTFCC_CHR('d','l','n','g') || tag == OTFCC_CHR('s','l','n','g');
-}
-
-void otfcc_dumpMeta(const table_meta *meta, json_value *root, const otfcc_Options *options) {
- if (!meta) return;
- loggedStep("meta") {
- json_value *_meta = json_object_new(3);
- json_object_push(_meta, "version", json_integer_new(meta->version));
- json_object_push(_meta, "flags", json_integer_new(meta->flags));
- json_value *_entries = json_array_new(meta->entries.length);
- json_object_push(_meta, "entries", _entries);
- foreach (meta_Entry *e, meta->entries) {
- json_value *_e = json_object_new(2);
- char _tag[4];
- tag2str(e->tag, _tag);
- json_object_push(_e, "tag", json_string_new_length(4, _tag));
- if (isStringTag(e->tag)) {
- json_object_push(_e, "string",
- json_string_new_length((uint32_t)sdslen(e->data), e->data));
- } else {
- size_t outLen = 0;
- uint8_t *out = base64_encode((uint8_t *)e->data, sdslen(e->data), &outLen);
- json_object_push(_e, "base64",
- json_string_new_length((uint32_t)outLen, (char *)out));
- FREE(out);
- }
- json_array_push(_entries, _e);
- }
- json_object_push(root, "meta", _meta);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/parse.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/parse.c
deleted file mode 100644
index 6cc206eefb9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/parse.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "../meta.h"
-
-#include "support/util.h"
-
-static sds parseMetaData(const json_value *v) {
- if (v->type == json_string) {
- return sdsnewlen(v->u.string.ptr, v->u.string.length);
- } else if (v->type == json_object) {
- // string entry
- json_value *_string = json_obj_get_type(v, "string", json_string);
- if (_string) { return sdsnewlen(_string->u.string.ptr, _string->u.string.length); }
-
- // base64 entry
- json_value *_base64 = json_obj_get_type(v, "base64", json_string);
- if (_base64) {
- size_t strLen = 0;
- char *str = (char *)base64_decode((uint8_t *)_base64->u.string.ptr,
- _base64->u.string.length, &strLen);
- sds s = sdsnewlen(str, strLen);
- FREE(str);
- return s;
- }
- }
- return NULL;
-}
-
-table_meta *otfcc_parseMeta(const json_value *root, const otfcc_Options *options) {
- json_value *_meta = NULL;
- if (!(_meta = json_obj_get_type(root, "meta", json_object))) return NULL;
- json_value *_meta_entries = NULL;
- if (!(_meta_entries = json_obj_get_type(_meta, "entries", json_array))) return NULL;
- table_meta *meta = table_iMeta.create();
- loggedStep("meta") {
- for (size_t j = 0; j < _meta_entries->u.array.length; j++) {
-
- json_value *_e = _meta_entries->u.array.values[j];
- json_value *_tag = json_obj_get_type(_e, "tag", json_string);
- if (!_tag || _tag->u.string.length != 4) continue;
-
- uint32_t tag = str2tag(_tag->u.string.ptr);
- sds str = parseMetaData(_e);
- if (!str) continue;
- meta_iEntries.push(&meta->entries, (meta_Entry){.tag = tag, .data = str});
- }
- }
- return meta;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/read.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/read.c
deleted file mode 100644
index 837ac0bf725..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/read.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "../meta.h"
-
-#include "support/util.h"
-
-table_meta *otfcc_readMeta(const otfcc_Packet packet, const otfcc_Options *options) {
- table_meta *meta = NULL;
- FOR_TABLE(OTFCC_CHR('m','e','t','a'), table) {
- if (table.length < 16) goto FAIL;
- uint32_t version = read_32u(table.data + 0);
- uint32_t flags = read_32u(table.data + 4);
- uint32_t dataMapsCount = read_32u(table.data + 12);
- if (table.length < 16 + 12 * dataMapsCount) goto FAIL;
-
- meta = table_iMeta.create();
- meta->version = version;
- meta->flags = flags;
-
- for (uint32_t j = 0; j < dataMapsCount; j++) {
- uint32_t tag = read_32u(table.data + 16 + 12 * j + 0);
- uint32_t offset = read_32u(table.data + 16 + 12 * j + 4);
- uint32_t length = read_32u(table.data + 16 + 12 * j + 8);
- if (table.length < offset + length) continue;
-
- meta_iEntries.push(
- &meta->entries,
- (meta_Entry){.tag = tag, .data = sdsnewlen((char *)(table.data + offset), length)});
- }
- return meta;
-
- FAIL:
- logWarning("Table 'meta' corrupted.\n");
- table_iMeta.free(meta);
- meta = NULL;
- }
- return meta;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/type.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/type.c
deleted file mode 100644
index c528cf91d05..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/meta/type.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "../meta.h"
-
-#include "support/util.h"
-
-static void initMetaEntry(meta_Entry *e) {
- e->tag = 1;
- e->data = NULL;
-}
-
-static void disposeMetaEntry(meta_Entry *e) {
- sdsfree(e->data);
-}
-
-caryll_standardType(meta_Entry, meta_iEntry, initMetaEntry, disposeMetaEntry);
-caryll_standardVectorImpl(meta_Entries, meta_Entry, meta_iEntry, meta_iEntries);
-
-static void initMetaTable(table_meta *t) {
- t->version = 1;
- t->flags = 0;
- meta_iEntries.init(&t->entries);
-}
-
-static void disposeMetaTable(table_meta *t) {
- meta_iEntries.dispose(&t->entries);
-}
-
-caryll_standardRefType(table_meta, table_iMeta, initMetaTable, disposeMetaTable);
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.c
deleted file mode 100644
index 9f579932564..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.c
+++ /dev/null
@@ -1,198 +0,0 @@
-#include "name.h"
-
-#include "support/util.h"
-#include "support/unicodeconv/unicodeconv.h"
-
-#ifndef MAIN_VER
-#define MAIN_VER 0
-#endif
-#ifndef SECONDARY_VER
-#define SECONDARY_VER 0
-#endif
-#ifndef PATCH_VER
-#define PATCH_VER 0
-#endif
-
-#define COPYRIGHT_LEN 32
-
-static void nameRecordDtor(otfcc_NameRecord *entry) {
- DELETE(sdsfree, entry->nameString);
-}
-caryll_standardType(otfcc_NameRecord, otfcc_iNameRecord, nameRecordDtor);
-caryll_standardVectorImpl(table_name, otfcc_NameRecord, otfcc_iNameRecord, table_iName);
-
-static bool shouldDecodeAsUTF16(const otfcc_NameRecord *record) {
- return (record->platformID == 0) // Unicode, all
- || (record->platformID == 2 && record->encodingID == 1) // ISO, 1
- || (record->platformID == 3 && // Microsoft, 0, 1, 10
- (record->encodingID == 0 || record->encodingID == 1 || record->encodingID == 10));
-}
-static bool shouldDecodeAsBytes(const otfcc_NameRecord *record) {
- return record->platformID == 1 && record->encodingID == 0 &&
- record->languageID == 0; // Mac Roman English - I hope
-}
-
-table_name *otfcc_readName(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('n','a','m','e'), table) {
- table_name *name = NULL;
- font_file_pointer data = table.data;
-
- uint32_t length = table.length;
- if (length < 6) goto TABLE_NAME_CORRUPTED;
- uint32_t count = read_16u(data + 2);
- uint32_t stringOffset = read_16u(data + 4);
- if (length < 6 + 12 * count) goto TABLE_NAME_CORRUPTED;
-
- name = table_iName.create();
-
- for (uint16_t j = 0; j < count; j++) {
- otfcc_NameRecord record;
- record.platformID = read_16u(data + 6 + j * 12);
- record.encodingID = read_16u(data + 6 + j * 12 + 2);
- record.languageID = read_16u(data + 6 + j * 12 + 4);
- record.nameID = read_16u(data + 6 + j * 12 + 6);
- record.nameString = NULL;
- uint16_t length = read_16u(data + 6 + j * 12 + 8);
- uint16_t offset = read_16u(data + 6 + j * 12 + 10);
-
- if (shouldDecodeAsBytes(&record)) {
- // Mac Roman. Note that this is not very correct, but works for most fonts
- sds nameString = sdsnewlen(data + stringOffset + offset, length);
- record.nameString = nameString;
- } else if (shouldDecodeAsUTF16(&record)) {
- sds nameString = utf16be_to_utf8(data + stringOffset + offset, length);
- record.nameString = nameString;
- } else {
- size_t len = 0;
- uint8_t *buf = base64_encode(data + stringOffset + offset, length, &len);
- record.nameString = sdsnewlen(buf, len);
- FREE(buf);
- }
- table_iName.push(name, record);
- }
- return name;
- TABLE_NAME_CORRUPTED:
- logWarning("table 'name' corrupted.\n");
- if (name) { DELETE(table_iName.free, name); }
- }
- return NULL;
-}
-
-void otfcc_dumpName(const table_name *name, json_value *root, const otfcc_Options *options) {
- if (!name) return;
- loggedStep("name") {
- json_value *_name = json_array_new(name->length);
- for (uint16_t j = 0; j < name->length; j++) {
- otfcc_NameRecord *r = &(name->items[j]);
- json_value *record = json_object_new(5);
- json_object_push(record, "platformID", json_integer_new(r->platformID));
- json_object_push(record, "encodingID", json_integer_new(r->encodingID));
- json_object_push(record, "languageID", json_integer_new(r->languageID));
- json_object_push(record, "nameID", json_integer_new(r->nameID));
- json_object_push(
- record, "nameString",
- json_string_new_length((uint32_t)sdslen(r->nameString), r->nameString));
- json_array_push(_name, record);
- }
- json_object_push(root, "name", _name);
- }
-}
-static int name_record_sort(const otfcc_NameRecord *a, const otfcc_NameRecord *b) {
- if (a->platformID != b->platformID) return a->platformID - b->platformID;
- if (a->encodingID != b->encodingID) return a->encodingID - b->encodingID;
- if (a->languageID != b->languageID) return a->languageID - b->languageID;
- return a->nameID - b->nameID;
-}
-table_name *otfcc_parseName(const json_value *root, const otfcc_Options *options) {
- table_name *name = table_iName.create();
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "name", json_array))) {
- loggedStep("name") {
-
- for (uint32_t j = 0; j < table->u.array.length; j++) {
- if (!(table->u.array.values[j] && table->u.array.values[j]->type == json_object))
- continue;
- json_value *_record = table->u.array.values[j];
- if (!json_obj_get_type(_record, "platformID", json_integer)) {
- logWarning("Missing or invalid platformID for name entry %d\n", j);
- continue;
- }
- if (!json_obj_get_type(_record, "encodingID", json_integer)) {
- logWarning("Missing or invalid encodingID for name entry %d\n", j);
- continue;
- }
- if (!json_obj_get_type(_record, "languageID", json_integer)) {
- logWarning("Missing or invalid languageID for name entry %d\n", j);
- continue;
- }
- if (!json_obj_get_type(_record, "nameID", json_integer)) {
- logWarning("Missing or invalid nameID for name entry %d\n", j);
- continue;
- }
- if (!json_obj_get_type(_record, "nameString", json_string)) {
- logWarning("Missing or invalid name string for name entry %d\n", j);
- continue;
- }
- otfcc_NameRecord record;
- record.platformID = json_obj_getint(_record, "platformID");
- record.encodingID = json_obj_getint(_record, "encodingID");
- record.languageID = json_obj_getint(_record, "languageID");
- record.nameID = json_obj_getint(_record, "nameID");
-
- json_value *str = json_obj_get_type(_record, "nameString", json_string);
- record.nameString = sdsnewlen(str->u.string.ptr, str->u.string.length);
- table_iName.push(name, record);
- }
-
- table_iName.sort(name, name_record_sort);
- }
- }
- return name;
-}
-caryll_Buffer *otfcc_buildName(const table_name *name, const otfcc_Options *options) {
- if (!name) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, 0);
- bufwrite16b(buf, name->length);
- bufwrite16b(buf, 0); // fill later
- caryll_Buffer *strings = bufnew();
- for (uint16_t j = 0; j < name->length; j++) {
- otfcc_NameRecord *record = &(name->items[j]);
- bufwrite16b(buf, record->platformID);
- bufwrite16b(buf, record->encodingID);
- bufwrite16b(buf, record->languageID);
- bufwrite16b(buf, record->nameID);
- size_t cbefore = strings->cursor;
- if (shouldDecodeAsUTF16(record)) {
- size_t words;
- uint8_t *u16 = utf8toutf16be(record->nameString, &words);
- bufwrite_bytes(strings, words, u16);
- FREE(u16);
- } else if (shouldDecodeAsBytes(record)) {
- bufwrite_bytes(strings, sdslen(record->nameString), (uint8_t *)record->nameString);
- } else {
- size_t length;
- uint8_t *decoded =
- base64_decode((uint8_t *)record->nameString, sdslen(record->nameString), &length);
- bufwrite_bytes(strings, length, decoded);
- FREE(decoded);
- }
- size_t cafter = strings->cursor;
- bufwrite16b(buf, cafter - cbefore);
- bufwrite16b(buf, cbefore);
- }
-
- // write copyright info
- sds copyright =
- sdscatprintf(sdsempty(), "-- By OTFCC %d.%d.%d --", MAIN_VER, SECONDARY_VER, PATCH_VER);
- sdsgrowzero(copyright, COPYRIGHT_LEN);
- bufwrite_bytes(strings, COPYRIGHT_LEN, (uint8_t *)copyright);
- sdsfree(copyright);
-
- size_t stringsOffset = buf->cursor;
- bufwrite_buf(buf, strings);
- bufseek(buf, 4);
- bufwrite16b(buf, stringsOffset);
- buffree(strings);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.h
deleted file mode 100644
index 7877787b5b8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/name.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_NAME_H
-#define CARYLL_TABLE_NAME_H
-
-#include "otfcc/table/name.h"
-
-table_name *otfcc_readName(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpName(const table_name *table, json_value *root, const otfcc_Options *options);
-table_name *otfcc_parseName(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildName(const table_name *name, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl.h
deleted file mode 100644
index 4ef56672b3d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_H
-#define CARYLL_TABLE_OTL_H
-
-#include "otfcc/table/otl.h"
-
-otl_Subtable *otfcc_readOtl_subtable(uint8_t *data, uint32_t tableLength, uint32_t subtableOffset,
- otl_LookupType lookupType, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-
-table_OTL *otfcc_readOtl(const otfcc_Packet packet, const otfcc_Options *options,
- const uint32_t tag, const glyphid_t maxGlyphs);
-void otfcc_dumpOtl(const table_OTL *table, json_value *root, const otfcc_Options *options,
- const char *tag);
-table_OTL *otfcc_parseOtl(const json_value *root, const otfcc_Options *options, const char *tag);
-caryll_Buffer *otfcc_buildOtl(const table_OTL *table, const otfcc_Options *options,
- const char *tag);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/build.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/build.c
deleted file mode 100644
index 91739f11589..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/build.c
+++ /dev/null
@@ -1,320 +0,0 @@
-#include "private.h"
-
-#define LARGE_SUBTABLE_LIMIT 4096
-
-static uint32_t featureNameToTag(const sds name) {
- uint32_t tag = 0;
- if (sdslen(name) > 0) {
- tag |= ((uint8_t)name[0]) << 24;
- } else {
- tag |= ((uint8_t)' ') << 24;
- }
- if (sdslen(name) > 1) {
- tag |= ((uint8_t)name[1]) << 16;
- } else {
- tag |= ((uint8_t)' ') << 16;
- }
- if (sdslen(name) > 2) {
- tag |= ((uint8_t)name[2]) << 8;
- } else {
- tag |= ((uint8_t)' ') << 8;
- }
- if (sdslen(name) > 3) {
- tag |= ((uint8_t)name[3]) << 0;
- } else {
- tag |= ((uint8_t)' ') << 0;
- }
- return tag;
-}
-
-typedef caryll_Buffer *(*_otl_Builder)(const otl_Subtable *_subtable,
- otl_BuildHeuristics heuristics);
-
-static tableid_t _declare_lookup_writer(otl_LookupType type, _otl_Builder fn,
- const otl_Lookup *lookup, caryll_Buffer ***subtables,
- size_t *lastOffset, bool *preferExtensionForThisLUT,
- otl_BuildHeuristics heuristics) {
- if (lookup->type == type) {
- NEW(*subtables, lookup->subtables.length);
- size_t totalBufSizeShort = 0;
- size_t totalBufSizeExt = 0;
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- caryll_Buffer *buf = fn(lookup->subtables.items[j], heuristics);
- (*subtables)[j] = buf;
- totalBufSizeShort += buf->size;
- totalBufSizeExt += 8;
- }
- if (totalBufSizeShort > LARGE_SUBTABLE_LIMIT) {
- *lastOffset += totalBufSizeExt;
- *preferExtensionForThisLUT = true;
- } else {
- *lastOffset += totalBufSizeShort;
- *preferExtensionForThisLUT = false;
- }
- return lookup->subtables.length;
- }
- return 0;
-}
-
-#define LOOKUP_WRITER(type, fn) \
- if (!written) \
- written = _declare_lookup_writer(type, fn, lookup, subtables, lastOffset, \
- preferExtensionForThisLUT, heuristics);
-
-static tableid_t _build_lookup(const otl_Lookup *lookup, caryll_Buffer ***subtables,
- size_t *lastOffset, bool *preferExtensionForThisLUT,
- otl_BuildHeuristics heuristics) {
- if (lookup->type == otl_type_gpos_chaining || lookup->type == otl_type_gsub_chaining) {
- return otfcc_classifiedBuildChaining(lookup, subtables, lastOffset);
- }
-
- tableid_t written = 0;
- LOOKUP_WRITER(otl_type_gsub_single, otfcc_build_gsub_single_subtable);
- LOOKUP_WRITER(otl_type_gsub_multiple, otfcc_build_gsub_multi_subtable);
- LOOKUP_WRITER(otl_type_gsub_alternate, otfcc_build_gsub_multi_subtable);
- LOOKUP_WRITER(otl_type_gsub_ligature, otfcc_build_gsub_ligature_subtable);
- LOOKUP_WRITER(otl_type_gsub_reverse, otfcc_build_gsub_reverse);
- LOOKUP_WRITER(otl_type_gpos_single, otfcc_build_gpos_single);
- LOOKUP_WRITER(otl_type_gpos_pair, otfcc_build_gpos_pair);
- LOOKUP_WRITER(otl_type_gpos_cursive, otfcc_build_gpos_cursive);
- LOOKUP_WRITER(otl_type_gpos_markToBase, otfcc_build_gpos_markToSingle);
- LOOKUP_WRITER(otl_type_gpos_markToMark, otfcc_build_gpos_markToSingle);
- LOOKUP_WRITER(otl_type_gpos_markToLigature, otfcc_build_gpos_markToLigature);
- return written;
-}
-
-static otl_BuildHeuristics getLookupHeuristics(const table_OTL *table, const otl_Lookup *lut) {
- otl_BuildHeuristics heu = OTL_BH_NORMAL;
- // GSUB VERT heuristics
- // GDI have some restrictions on the internal format of the lookup inisde a VERT feature
- if (lut->type == otl_type_gsub_single) {
- for (tableid_t j = 0; j < table->features.length; j++) {
- const otl_Feature *fea = table->features.items[j];
- if (featureNameToTag(fea->name) != OTFCC_CHR('v','e','r','t')) continue;
- for (tableid_t k = 0; k < fea->lookups.length; k++) {
- if (fea->lookups.items[k] == lut) heu |= OTL_BH_GSUB_VERT;
- }
- }
- }
- return heu;
-}
-
-// When writing lookups, otfcc will try to maintain everything correctly.
-// That is, we will use extended layout lookups automatically when the
-// offsets are too large.
-static bk_Block *writeOTLLookups(const table_OTL *table, const otfcc_Options *options,
- const char *tag) {
- caryll_Buffer ***subtables;
- NEW(subtables, table->lookups.length);
- bool *preferExtForThisLut;
- tableid_t *subtableQuantity;
- NEW(subtableQuantity, table->lookups.length);
- NEW(preferExtForThisLut, table->lookups.length);
-
- size_t lastOffset = 0;
- for (tableid_t j = 0; j < table->lookups.length; j++) {
- otl_Lookup *lookup = table->lookups.items[j];
- otl_BuildHeuristics heu = getLookupHeuristics(table, lookup);
- logProgress("Building lookup %s (%u/%u)\n", lookup->name, j,
- (uint32_t)table->lookups.length);
- subtableQuantity[j] =
- _build_lookup(lookup, &(subtables[j]), &lastOffset, &(preferExtForThisLut[j]), heu);
- }
-
- size_t headerSize = 2 + 2 * table->lookups.length;
- for (tableid_t j = 0; j < table->lookups.length; j++) {
- if (subtableQuantity[j]) { headerSize += 6 + 2 * subtableQuantity[j]; }
- }
- bool useExtended = lastOffset >= 0xFF00 - headerSize;
-
- bk_Block *root = bk_new_Block(b16, table->lookups.length, // LookupCount
- bkover);
- for (tableid_t j = 0; j < table->lookups.length; j++) {
- if (!subtableQuantity[j]) {
- logNotice("Lookup %s is empty.\n", table->lookups.items[j]->name);
- }
- otl_Lookup *lookup = table->lookups.items[j];
- const bool canBeContextual = otfcc_chainingLookupIsContextualLookup(lookup);
- const bool useExtendedForIt = useExtended || preferExtForThisLut[j];
- if (useExtendedForIt) {
- logNotice("[OTFCC-fea] Using extended OpenType table layout for %s/%s.\n", tag,
- lookup->name);
- }
- uint16_t lookupType =
- useExtendedForIt
- ? (lookup->type > otl_type_gpos_unknown
- ? otl_type_gpos_extend - otl_type_gpos_unknown
- : lookup->type > otl_type_gsub_unknown
- ? otl_type_gsub_extend - otl_type_gsub_unknown
- : 0)
- : (lookup->type > otl_type_gpos_unknown
- ? lookup->type - otl_type_gpos_unknown
- : lookup->type > otl_type_gsub_unknown ? lookup->type - otl_type_gsub_unknown
- : 0) -
- (canBeContextual ? 1 : 0);
-
- bk_Block *blk = bk_new_Block(b16, lookupType, // LookupType
- b16, lookup->flags, // LookupFlag
- b16, subtableQuantity[j], // SubTableCount
- bkover);
-
- for (tableid_t k = 0; k < subtableQuantity[j]; k++) {
- if (useExtendedForIt) {
- uint16_t extensionLookupType = (lookup->type > otl_type_gpos_unknown
- ? lookup->type - otl_type_gpos_unknown
- : lookup->type > otl_type_gsub_unknown
- ? lookup->type - otl_type_gsub_unknown
- : 0) -
- (canBeContextual ? 1 : 0);
-
- bk_Block *stub =
- bk_new_Block(b16, 1, // format
- b16, extensionLookupType, // ExtensionLookupType
- p32, bk_newBlockFromBuffer(subtables[j][k]), // ExtensionOffset
- bkover);
- bk_push(blk, p16, stub, bkover);
- } else {
- bk_push(blk, p16, bk_newBlockFromBuffer(subtables[j][k]), bkover);
- }
- }
- bk_push(blk, b16, 0, // MarkFilteringSet
- bkover);
- bk_push(root, p16, blk, bkover);
- FREE(subtables[j]);
- }
- FREE(subtables);
- FREE(subtableQuantity);
- FREE(preferExtForThisLut);
- return root;
-}
-
-static bk_Block *writeOTLFeatures(const table_OTL *table, const otfcc_Options *options) {
- bk_Block *root = bk_new_Block(b16, table->features.length, bkover);
- for (tableid_t j = 0; j < table->features.length; j++) {
- bk_Block *fea = bk_new_Block(p16, NULL, // FeatureParams
- b16, table->features.items[j]->lookups.length, // LookupCount
- bkover);
- for (tableid_t k = 0; k < table->features.items[j]->lookups.length; k++) {
- // reverse lookup
- for (tableid_t l = 0; l < table->lookups.length; l++) {
- if (table->features.items[j]->lookups.items[k] == table->lookups.items[l]) {
- bk_push(fea, b16, l, bkover);
- break;
- }
- }
- }
- bk_push(root, b32, featureNameToTag(table->features.items[j]->name), // FeatureTag
- p16, fea, // Feature
- bkover);
- }
- return root;
-}
-
-// script hash
-typedef struct {
- sds tag;
- uint16_t lc;
- otl_LanguageSystem *dl;
- otl_LanguageSystem **ll;
- UT_hash_handle hh;
-} script_stat_hash;
-
-static tableid_t featureIndex(const otl_Feature *feature, const table_OTL *table) {
- for (tableid_t j = 0; j < table->features.length; j++)
- if (table->features.items[j] == feature) { return j; }
- return 0xFFFF;
-}
-static bk_Block *writeLanguage(otl_LanguageSystem *lang, const table_OTL *table) {
- if (!lang) return NULL;
- bk_Block *root =
- bk_new_Block(p16, NULL, // LookupOrder
- b16, featureIndex(lang->requiredFeature, table), // ReqFeatureIndex
- b16, lang->features.length, // FeatureCount
- bkover);
- for (tableid_t k = 0; k < lang->features.length; k++) {
- bk_push(root, b16, featureIndex(lang->features.items[k], table), bkover);
- }
- return root;
-}
-
-static bk_Block *writeScript(script_stat_hash *script, const table_OTL *table) {
- bk_Block *root = bk_new_Block(p16, writeLanguage(script->dl, table), // DefaultLangSys
- b16, script->lc, // LangSysCount
- bkover);
-
- for (tableid_t j = 0; j < script->lc; j++) {
- sds tag = sdsnewlen(script->ll[j]->name + 5, 4);
-
- bk_push(root, b32, featureNameToTag(tag), // LangSysTag
- p16, writeLanguage(script->ll[j], table), // LangSys
- bkover);
- sdsfree(tag);
- }
- return root;
-}
-static bk_Block *writeOTLScriptAndLanguages(const table_OTL *table, const otfcc_Options *options) {
- script_stat_hash *h = NULL;
- for (tableid_t j = 0; j < table->languages.length; j++) {
- otl_LanguageSystem *language = table->languages.items[j];
- sds scriptTag = sdsnewlen(language->name, 4);
- bool isDefault = strncmp(language->name + 5, "DFLT", 4) == 0 ||
- strncmp(language->name + 5, "dflt", 4) == 0;
-
- script_stat_hash *s = NULL;
- HASH_FIND_STR(h, scriptTag, s);
- if (s) {
- if (isDefault) {
- s->dl = language;
- } else {
- s->lc += 1;
- s->ll[s->lc - 1] = language;
- }
- sdsfree(scriptTag);
- } else {
- NEW(s);
- s->tag = scriptTag;
- s->dl = NULL;
- NEW(s->ll, table->languages.length);
- if (isDefault) {
- s->dl = language;
- s->lc = 0;
- } else {
- s->lc = 1;
- s->ll[s->lc - 1] = language;
- }
- HASH_ADD_STR(h, tag, s);
- }
- }
-
- bk_Block *root = bk_new_Block(b16, HASH_COUNT(h), bkover);
-
- script_stat_hash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- bk_push(root, b32, featureNameToTag(s->tag), // ScriptTag
- p16, writeScript(s, table), // Script
- bkover);
- HASH_DEL(h, s);
- sdsfree(s->tag);
- FREE(s->ll);
- FREE(s);
- }
- return root;
-}
-
-caryll_Buffer *otfcc_buildOtl(const table_OTL *table, const otfcc_Options *options,
- const char *tag) {
- if (!table) return NULL;
- caryll_Buffer *buf;
- loggedStep("%s", tag) {
- bk_Block *lookups = writeOTLLookups(table, options, tag);
- bk_Block *features = writeOTLFeatures(table, options);
- bk_Block *languages = writeOTLScriptAndLanguages(table, options);
- bk_Block *root = bk_new_Block(b32, 0x10000, // Version
- p16, languages, // ScriptList
- p16, features, // FeatureList
- p16, lookups, // LookupList
- bkover);
- buf = bk_build_Block(root);
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/classdef.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/classdef.c
deleted file mode 100644
index da09b2b3bee..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/classdef.c
+++ /dev/null
@@ -1,237 +0,0 @@
-#include "support/util.h"
-#include "otfcc/table/otl/classdef.h"
-
-static INLINE void disposeClassDef(otl_ClassDef *cd) {
- if (cd->glyphs) {
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- Handle.dispose(&cd->glyphs[j]);
- }
- FREE(cd->glyphs);
- }
- FREE(cd->classes);
-}
-caryll_standardRefTypeFn(otl_ClassDef, disposeClassDef);
-
-static void growClassdef(otl_ClassDef *cd, uint32_t n) {
- if (!n) return;
- if (n > cd->capacity) {
- if (!cd->capacity) cd->capacity = 0x10;
- while (n > cd->capacity)
- cd->capacity += (cd->capacity >> 1) & 0xFFFFFF;
- RESIZE(cd->glyphs, cd->capacity);
- RESIZE(cd->classes, cd->capacity);
- }
-}
-static void pushClassDef(otl_ClassDef *cd, MOVE otfcc_GlyphHandle h, glyphclass_t cls) {
- cd->numGlyphs += 1;
- growClassdef(cd, cd->numGlyphs);
- cd->glyphs[cd->numGlyphs - 1] = h;
- cd->classes[cd->numGlyphs - 1] = cls;
- if (cls > cd->maxclass) cd->maxclass = cls;
-}
-
-typedef struct {
- int gid;
- int covIndex;
- UT_hash_handle hh;
-} coverage_entry;
-
-static int by_covIndex(coverage_entry *a, coverage_entry *b) {
- return a->covIndex - b->covIndex;
-}
-
-static otl_ClassDef *readClassDef(const uint8_t *data, uint32_t tableLength, uint32_t offset) {
- otl_ClassDef *cd = otl_iClassDef.create();
- if (tableLength < offset + 4) return cd;
- uint16_t format = read_16u(data + offset);
- if (format == 1 && tableLength >= offset + 6) {
- glyphid_t startGID = read_16u(data + offset + 2);
- glyphid_t count = read_16u(data + offset + 4);
- if (count && tableLength >= offset + 6 + count * 2) {
- for (glyphid_t j = 0; j < count; j++) {
- pushClassDef(cd, Handle.fromIndex(startGID + j), read_16u(data + offset + 6 + j * 2));
- }
- return cd;
- }
- } else if (format == 2) {
- // The ranges may overlap.
- // Use hashtable.
- uint16_t rangeCount = read_16u(data + offset + 2);
- if (tableLength < offset + 4 + rangeCount * 6) return cd;
- coverage_entry *hash = NULL;
- for (uint16_t j = 0; j < rangeCount; j++) {
- uint16_t start = read_16u(data + offset + 4 + 6 * j);
- uint16_t end = read_16u(data + offset + 4 + 6 * j + 2);
- uint16_t cls = read_16u(data + offset + 4 + 6 * j + 4);
- for (int k = start; k <= end; k++) {
- coverage_entry *item = NULL;
- HASH_FIND_INT(hash, &k, item);
- if (!item) {
- NEW(item);
- item->gid = k;
- item->covIndex = cls;
- HASH_ADD_INT(hash, gid, item);
- }
- }
- }
- HASH_SORT(hash, by_covIndex);
- coverage_entry *e, *tmp;
- HASH_ITER(hh, hash, e, tmp) {
- pushClassDef(cd, Handle.fromIndex(e->gid), e->covIndex);
- HASH_DEL(hash, e);
- FREE(e);
- }
- return cd;
- }
- return cd;
-}
-
-static otl_ClassDef *expandClassDef(otl_Coverage *cov, otl_ClassDef *ocd) {
- otl_ClassDef *cd = otl_iClassDef.create();
- coverage_entry *hash = NULL;
- for (glyphid_t j = 0; j < ocd->numGlyphs; j++) {
- int gid = ocd->glyphs[j].index;
- int cid = ocd->classes[j];
- coverage_entry *item = NULL;
- HASH_FIND_INT(hash, &gid, item);
- if (!item) {
- NEW(item);
- item->gid = gid;
- item->covIndex = cid;
- HASH_ADD_INT(hash, gid, item);
- }
- }
- for (glyphid_t j = 0; j < cov->numGlyphs; j++) {
- int gid = cov->glyphs[j].index;
- coverage_entry *item = NULL;
- HASH_FIND_INT(hash, &gid, item);
- if (!item) {
- NEW(item);
- item->gid = gid;
- item->covIndex = 0;
- HASH_ADD_INT(hash, gid, item);
- }
- }
- coverage_entry *e, *tmp;
- HASH_ITER(hh, hash, e, tmp) {
- pushClassDef(cd, Handle.fromIndex(e->gid), e->covIndex);
- HASH_DEL(hash, e);
- FREE(e);
- }
- otl_iClassDef.free(ocd);
- return cd;
-}
-
-static json_value *dumpClassDef(const otl_ClassDef *cd) {
- json_value *a = json_object_new(cd->numGlyphs);
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- json_object_push(a, cd->glyphs[j].name, json_integer_new(cd->classes[j]));
- }
- return preserialize(a);
-}
-
-static otl_ClassDef *parseClassDef(const json_value *_cd) {
- if (!_cd || _cd->type != json_object) return NULL;
- otl_ClassDef *cd = otl_iClassDef.create();
- for (glyphid_t j = 0; j < _cd->u.object.length; j++) {
- glyph_handle h = Handle.fromName(sdsnewlen(_cd->u.object.values[j].name, _cd->u.object.values[j].name_length));
- json_value *_cid = _cd->u.object.values[j].value;
- glyphclass_t cls = 0;
- if (_cid->type == json_integer) {
- cls = _cid->u.integer;
- } else if (_cid->type == json_double) {
- cls = _cid->u.dbl;
- }
- pushClassDef(cd, h, cls);
- }
- return cd;
-}
-
-typedef struct {
- glyphid_t gid;
- glyphclass_t cid;
-} classdef_sortrecord;
-
-static int by_gid(const void *a, const void *b) {
- return ((const classdef_sortrecord *)a)->gid - ((const classdef_sortrecord *)b)->gid;
-}
-static caryll_Buffer *buildClassDef(const otl_ClassDef *cd) {
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, 2);
- if (!cd->numGlyphs) { // no glyphs, return a blank classdef
- bufwrite16b(buf, 0);
- return buf;
- }
-
- classdef_sortrecord *r;
- NEW(r, cd->numGlyphs);
- glyphid_t jj = 0;
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- if (cd->classes[j]) {
- r[jj].gid = cd->glyphs[j].index;
- r[jj].cid = cd->classes[j];
- jj++;
- }
- }
- if (!jj) { // The classdef has only class 0
- FREE(r);
- bufwrite16b(buf, 0);
- return buf;
- }
- qsort(r, jj, sizeof(classdef_sortrecord), by_gid);
-
- glyphid_t startGID = r[0].gid;
- glyphid_t endGID = startGID;
- glyphclass_t lastClass = r[0].cid;
- glyphid_t nRanges = 0;
- glyphid_t lastGID = startGID;
- caryll_Buffer *ranges = bufnew();
- for (glyphid_t j = 1; j < jj; j++) {
- glyphid_t current = r[j].gid;
- if (current <= lastGID) continue;
- if (current == endGID + 1 && r[j].cid == lastClass) {
- endGID = current;
- } else {
- bufwrite16b(ranges, startGID);
- bufwrite16b(ranges, endGID);
- bufwrite16b(ranges, lastClass);
- nRanges += 1;
- startGID = endGID = current;
- lastClass = r[j].cid;
- }
- lastGID = current;
- }
- bufwrite16b(ranges, startGID);
- bufwrite16b(ranges, endGID);
- bufwrite16b(ranges, lastClass);
- nRanges += 1;
- bufwrite16b(buf, nRanges);
- bufwrite_bufdel(buf, ranges);
- FREE(r);
- return buf;
-}
-
-static void shrinkClassDef(otl_ClassDef *cd) {
- glyphid_t k = 0;
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- if (cd->glyphs[j].name) {
- cd->glyphs[k] = cd->glyphs[j];
- cd->classes[k] = cd->classes[j];
- k++;
- } else {
- Handle.dispose(&cd->glyphs[j]);
- }
- }
- cd->numGlyphs = k;
-}
-
-const struct __otfcc_IClassDef otl_iClassDef = {
- caryll_standardRefTypeMethods(otl_ClassDef),
- .read = readClassDef,
- .expand = expandClassDef,
- .dump = dumpClassDef,
- .parse = parseClassDef,
- .build = buildClassDef,
- .shrink = shrinkClassDef,
- .push = pushClassDef,
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/constants.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/constants.c
deleted file mode 100644
index b9ea407ad06..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/constants.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "private.h"
-
-const char SCRIPT_LANGUAGE_SEPARATOR = '_';
-const char *lookupFlagsLabels[] = {"rightToLeft", "ignoreBases", "ignoreLigatures", "ignoreMarks", NULL};
-const char *tableNames[] = {[otl_type_unknown] = "unknown",
- [otl_type_gsub_unknown] = "gsub_unknown",
- [otl_type_gsub_single] = "gsub_single",
- [otl_type_gsub_multiple] = "gsub_multiple",
- [otl_type_gsub_alternate] = "gsub_alternate",
- [otl_type_gsub_ligature] = "gsub_ligature",
- [otl_type_gsub_context] = "gsub_context",
- [otl_type_gsub_chaining] = "gsub_chaining",
- [otl_type_gsub_extend] = "gsub_extend",
- [otl_type_gsub_reverse] = "gsub_reverse",
- [otl_type_gpos_unknown] = "gpos_unknown",
- [otl_type_gpos_single] = "gpos_single",
- [otl_type_gpos_pair] = "gpos_pair",
- [otl_type_gpos_cursive] = "gpos_cursive",
- [otl_type_gpos_markToBase] = "gpos_mark_to_base",
- [otl_type_gpos_markToLigature] = "gpos_mark_to_ligature",
- [otl_type_gpos_markToMark] = "gpos_mark_to_mark",
- [otl_type_gpos_context] = "gpos_context",
- [otl_type_gpos_chaining] = "gpos_chaining",
- [otl_type_gpos_extend] = "gpos_extend"};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/coverage.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/coverage.c
deleted file mode 100644
index f592d48d101..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/coverage.c
+++ /dev/null
@@ -1,256 +0,0 @@
-#include "support/util.h"
-#include "otfcc/table/otl/coverage.h"
-
-static INLINE void disposeCoverage(MOVE otl_Coverage *coverage) {
- for (glyphid_t j = 0; j < coverage->numGlyphs; j++) {
- Handle.dispose(&coverage->glyphs[j]);
- }
- FREE(coverage->glyphs);
-}
-caryll_standardRefTypeFn(otl_Coverage, disposeCoverage);
-
-static void growCoverage(otl_Coverage *coverage, uint32_t n) {
- if (!n) return;
- if (n > coverage->capacity) {
- if (!coverage->capacity) coverage->capacity = 0x10;
- while (n > coverage->capacity)
- coverage->capacity += (coverage->capacity >> 1) & 0xFFFFFF;
- RESIZE(coverage->glyphs, coverage->capacity);
- }
-}
-static void clearCoverage(otl_Coverage *coverage, uint32_t n) {
- if (!coverage || !coverage->glyphs) return;
- for (glyphid_t j = 0; j < coverage->numGlyphs; j++) {
- Handle.dispose(&coverage->glyphs[j]);
- }
- growCoverage(coverage, n);
- coverage->numGlyphs = n;
-}
-
-typedef struct {
- int gid;
- int covIndex;
- UT_hash_handle hh;
-} coverage_entry;
-
-static int by_covIndex(coverage_entry *a, coverage_entry *b) {
- return a->covIndex - b->covIndex;
-}
-
-static void pushToCoverage(otl_Coverage *coverage, MOVE otfcc_GlyphHandle h) {
- coverage->numGlyphs += 1;
- growCoverage(coverage, coverage->numGlyphs);
- coverage->glyphs[coverage->numGlyphs - 1] = h;
-}
-
-static otl_Coverage *readCoverage(const uint8_t *data, uint32_t tableLength, uint32_t offset) {
- otl_Coverage *coverage = otl_iCoverage.create();
- if (tableLength < offset + 4) return coverage;
- uint16_t format = read_16u(data + offset);
- switch (format) {
- case 1: {
- uint16_t glyphCount = read_16u(data + offset + 2);
- if (tableLength < offset + 4 + glyphCount * 2) return coverage;
- coverage_entry *hash = NULL;
- for (uint16_t j = 0; j < glyphCount; j++) {
- coverage_entry *item = NULL;
- int gid = read_16u(data + offset + 4 + j * 2);
- HASH_FIND_INT(hash, &gid, item);
- if (!item) {
- NEW(item);
- item->gid = gid;
- item->covIndex = j;
- HASH_ADD_INT(hash, gid, item);
- }
- }
- HASH_SORT(hash, by_covIndex);
- coverage_entry *e, *tmp;
- HASH_ITER(hh, hash, e, tmp) {
- pushToCoverage(coverage, Handle.fromIndex(e->gid));
- HASH_DEL(hash, e);
- FREE(e);
- }
- break;
- }
- case 2: {
- uint16_t rangeCount = read_16u(data + offset + 2);
- if (tableLength < offset + 4 + rangeCount * 6) return coverage;
- coverage_entry *hash = NULL;
- for (uint16_t j = 0; j < rangeCount; j++) {
- uint16_t start = read_16u(data + offset + 4 + 6 * j);
- uint16_t end = read_16u(data + offset + 4 + 6 * j + 2);
- uint16_t startCoverageIndex = read_16u(data + offset + 4 + 6 * j + 4);
- for (int k = start; k <= end; k++) {
- coverage_entry *item = NULL;
- HASH_FIND_INT(hash, &k, item);
- if (!item) {
- NEW(item);
- item->gid = k;
- item->covIndex = startCoverageIndex + k;
- HASH_ADD_INT(hash, gid, item);
- }
- }
- }
- HASH_SORT(hash, by_covIndex);
- coverage_entry *e, *tmp;
- HASH_ITER(hh, hash, e, tmp) {
- pushToCoverage(coverage, Handle.fromIndex(e->gid));
- HASH_DEL(hash, e);
- FREE(e);
- }
- break;
- }
- default:
- break;
- }
- return coverage;
-}
-
-static json_value *dumpCoverage(const otl_Coverage *coverage) {
- json_value *a = json_array_new(coverage->numGlyphs);
- for (glyphid_t j = 0; j < coverage->numGlyphs; j++) {
- json_array_push(a, json_string_new(coverage->glyphs[j].name));
- }
- return preserialize(a);
-}
-
-static otl_Coverage *parseCoverage(const json_value *cov) {
- otl_Coverage *c = otl_iCoverage.create();
- if (!cov || cov->type != json_array) return c;
-
- for (glyphid_t j = 0; j < cov->u.array.length; j++) {
- if (cov->u.array.values[j]->type == json_string) {
- pushToCoverage(c,
- Handle.fromName(sdsnewlen(cov->u.array.values[j]->u.string.ptr,
- cov->u.array.values[j]->u.string.length)));
- }
- }
- return c;
-}
-
-static int by_gid(const void *a, const void *b) {
- return *((const glyphid_t *)a) - *((const glyphid_t *)b);
-}
-
-static caryll_Buffer *buildCoverageFormat(const otl_Coverage *coverage, uint16_t format) {
- // sort the gids in coverage
- if (!coverage->numGlyphs) {
- caryll_Buffer *buf = bufnew();
- bufwrite16b(buf, 2);
- bufwrite16b(buf, 0);
- return buf;
- }
- glyphid_t *r;
- NEW(r, coverage->numGlyphs);
- glyphid_t jj = 0;
- for (glyphid_t j = 0; j < coverage->numGlyphs; j++) {
- r[jj] = coverage->glyphs[j].index;
- jj++;
- }
- qsort(r, jj, sizeof(glyphid_t), by_gid);
-
- caryll_Buffer *format1 = bufnew();
- bufwrite16b(format1, 1);
- bufwrite16b(format1, jj);
- for (glyphid_t j = 0; j < jj; j++) {
- bufwrite16b(format1, r[j]);
- }
- if (jj < 2) {
- FREE(r);
- return format1;
- }
-
- caryll_Buffer *format2 = bufnew();
- bufwrite16b(format2, 2);
- caryll_Buffer *ranges = bufnew();
- glyphid_t startGID = r[0];
- glyphid_t endGID = startGID;
- glyphid_t lastGID = startGID;
- glyphid_t nRanges = 0;
- for (glyphid_t j = 1; j < jj; j++) {
- glyphid_t current = r[j];
- if (current <= lastGID) continue;
- if (current == endGID + 1) {
- endGID = current;
- } else {
- bufwrite16b(ranges, startGID);
- bufwrite16b(ranges, endGID);
- bufwrite16b(ranges, j + startGID - endGID - 1);
- nRanges += 1;
- startGID = endGID = current;
- }
- lastGID = current;
- }
- bufwrite16b(ranges, startGID);
- bufwrite16b(ranges, endGID);
- bufwrite16b(ranges, jj + startGID - endGID - 1);
- nRanges += 1;
- bufwrite16b(format2, nRanges);
- bufwrite_bufdel(format2, ranges);
-
- if (format == 1) {
- buffree(format2);
- FREE(r);
- return format1;
- } else if (format == 2) {
- buffree(format1);
- FREE(r);
- return format2;
- } else {
- if (buflen(format1) < buflen(format2)) {
- buffree(format2);
- FREE(r);
- return format1;
- } else {
- buffree(format1);
- FREE(r);
- return format2;
- }
- }
-}
-
-static caryll_Buffer *buildCoverage(const otl_Coverage *coverage) {
- return buildCoverageFormat(coverage, 0);
-}
-
-static int byHandleGID(const void *a, const void *b) {
- return ((const glyph_handle *)a)->index - ((const glyph_handle *)b)->index;
-}
-
-static void shrinkCoverage(otl_Coverage *coverage, bool dosort) {
- if (!coverage) return;
- glyphid_t k = 0;
- for (glyphid_t j = 0; j < coverage->numGlyphs; j++) {
- if (coverage->glyphs[j].name) {
- coverage->glyphs[k++] = coverage->glyphs[j];
- } else {
- Handle.dispose(&coverage->glyphs[j]);
- }
- }
- if (dosort) {
- qsort(coverage->glyphs, k, sizeof(glyph_handle), byHandleGID);
- glyphid_t skip = 0;
- for (glyphid_t rear = 1; rear < k; rear++) {
- if (coverage->glyphs[rear].index == coverage->glyphs[rear - skip - 1].index) {
- Handle.dispose(&coverage->glyphs[rear]);
- skip += 1;
- } else {
- coverage->glyphs[rear - skip] = coverage->glyphs[rear];
- }
- }
- k -= skip;
- }
- coverage->numGlyphs = k;
-}
-
-const struct __otfcc_ICoverage otl_iCoverage = {
- caryll_standardRefTypeMethods(otl_Coverage),
- .clear = clearCoverage,
- .read = readCoverage,
- .dump = dumpCoverage,
- .parse = parseCoverage,
- .build = buildCoverage,
- .buildFormat = buildCoverageFormat,
- .shrink = shrinkCoverage,
- .push = pushToCoverage,
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/dump.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/dump.c
deleted file mode 100644
index 60d5f99b282..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/dump.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "private.h"
-
-static void _declare_lookup_dumper(otl_LookupType llt, const char *lt, json_value *(*dumper)(const otl_Subtable *st),
- otl_Lookup *lookup, json_value *dump) {
- if (lookup->type == llt) {
- json_object_push(dump, "type", json_string_new(lt));
- json_object_push(dump, "flags", otfcc_dump_flags(lookup->flags, lookupFlagsLabels));
- if (lookup->flags >> 8) { json_object_push(dump, "markAttachmentType", json_integer_new(lookup->flags >> 8)); }
- json_value *subtables = json_array_new(lookup->subtables.length);
- for (tableid_t j = 0; j < lookup->subtables.length; j++)
- if (lookup->subtables.items[j]) { json_array_push(subtables, dumper(lookup->subtables.items[j])); }
- json_object_push(dump, "subtables", subtables);
- }
-}
-
-#define LOOKUP_DUMPER(llt, fn) _declare_lookup_dumper(llt, tableNames[llt], fn, lookup, dump);
-
-static void _dump_lookup(otl_Lookup *lookup, json_value *dump) {
- LOOKUP_DUMPER(otl_type_gsub_single, otl_gsub_dump_single);
- LOOKUP_DUMPER(otl_type_gsub_multiple, otl_gsub_dump_multi);
- LOOKUP_DUMPER(otl_type_gsub_alternate, otl_gsub_dump_multi);
- LOOKUP_DUMPER(otl_type_gsub_ligature, otl_gsub_dump_ligature);
- LOOKUP_DUMPER(otl_type_gsub_chaining, otl_dump_chaining);
- LOOKUP_DUMPER(otl_type_gsub_reverse, otl_gsub_dump_reverse);
- LOOKUP_DUMPER(otl_type_gpos_chaining, otl_dump_chaining);
- LOOKUP_DUMPER(otl_type_gpos_single, otl_gpos_dump_single);
- LOOKUP_DUMPER(otl_type_gpos_pair, otl_gpos_dump_pair);
- LOOKUP_DUMPER(otl_type_gpos_cursive, otl_gpos_dump_cursive);
- LOOKUP_DUMPER(otl_type_gpos_markToBase, otl_gpos_dump_markToSingle);
- LOOKUP_DUMPER(otl_type_gpos_markToMark, otl_gpos_dump_markToSingle);
- LOOKUP_DUMPER(otl_type_gpos_markToLigature, otl_gpos_dump_markToLigature);
-}
-
-void otfcc_dumpOtl(const table_OTL *table, json_value *root, const otfcc_Options *options, const char *tag) {
- if (!table || !table->languages.length || !table->lookups.length || !table->features.length) return;
- loggedStep("%s", tag) {
- json_value *otl = json_object_new(3);
- loggedStep("Languages") {
- // dump script list
- json_value *languages = json_object_new(table->languages.length);
- for (tableid_t j = 0; j < table->languages.length; j++) {
- json_value *_lang = json_object_new(5);
- otl_LanguageSystem *lang = table->languages.items[j];
- if (lang->requiredFeature) {
- json_object_push(_lang, "requiredFeature", json_string_new(lang->requiredFeature->name));
- }
- json_value *features = json_array_new(lang->features.length);
- for (tableid_t k = 0; k < lang->features.length; k++)
- if (lang->features.items[k]) {
- json_array_push(features, json_string_new(lang->features.items[k]->name));
- }
- json_object_push(_lang, "features", preserialize(features));
- json_object_push(languages, lang->name, _lang);
- }
- json_object_push(otl, "languages", languages);
- }
- loggedStep("Features") {
- // dump feature list
- json_value *features = json_object_new(table->features.length);
- for (tableid_t j = 0; j < table->features.length; j++) {
- otl_Feature *feature = table->features.items[j];
- json_value *_feature = json_array_new(feature->lookups.length);
- for (tableid_t k = 0; k < feature->lookups.length; k++)
- if (feature->lookups.items[k]) {
- json_array_push(_feature, json_string_new(feature->lookups.items[k]->name));
- }
- json_object_push(features, feature->name, preserialize(_feature));
- }
- json_object_push(otl, "features", features);
- }
- loggedStep("Lookups") {
- // dump lookups
- json_value *lookups = json_object_new(table->lookups.length);
- json_value *lookupOrder = json_array_new(table->lookups.length);
- for (tableid_t j = 0; j < table->lookups.length; j++) {
- json_value *_lookup = json_object_new(5);
- otl_Lookup *lookup = table->lookups.items[j];
- _dump_lookup(lookup, _lookup);
- json_object_push(lookups, lookup->name, _lookup);
- json_array_push(lookupOrder, json_string_new(lookup->name));
- }
- json_object_push(otl, "lookups", lookups);
- json_object_push(otl, "lookupOrder", lookupOrder);
- }
- json_object_push(root, tag, otl);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/otl.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/otl.c
deleted file mode 100644
index eba22583124..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/otl.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "private.h"
-
-#define DELETE_TYPE(type, fn) \
- case type: \
- ((void (*)(otl_Subtable *))fn)(*subtableRef); \
- break;
-
-static INLINE void disposeSubtableDependent(MODIFY otl_SubtablePtr *subtableRef,
- const otl_Lookup *lookup) {
- switch (lookup->type) {
- DELETE_TYPE(otl_type_gsub_single, iSubtable_gsub_single.free);
- DELETE_TYPE(otl_type_gsub_multiple, iSubtable_gsub_multi.free);
- DELETE_TYPE(otl_type_gsub_alternate, iSubtable_gsub_multi.free);
- DELETE_TYPE(otl_type_gsub_ligature, iSubtable_gsub_ligature.free);
- DELETE_TYPE(otl_type_gsub_chaining, iSubtable_chaining.free);
- DELETE_TYPE(otl_type_gsub_reverse, iSubtable_gsub_reverse.free);
- DELETE_TYPE(otl_type_gpos_single, iSubtable_gpos_single.free);
- DELETE_TYPE(otl_type_gpos_pair, iSubtable_gpos_pair.free);
- DELETE_TYPE(otl_type_gpos_cursive, iSubtable_gpos_cursive.free);
- DELETE_TYPE(otl_type_gpos_chaining, iSubtable_chaining.free);
- DELETE_TYPE(otl_type_gpos_markToBase, iSubtable_gpos_markToSingle.free);
- DELETE_TYPE(otl_type_gpos_markToMark, iSubtable_gpos_markToSingle.free);
- DELETE_TYPE(otl_type_gpos_markToLigature, iSubtable_gpos_markToLigature.free);
- default:;
- }
-}
-static caryll_ElementInterface(otl_SubtablePtr) otl_iSubtablePtr = {
- .init = NULL, .copy = NULL, .dispose = NULL,
-};
-caryll_VectorImplFreeDependent(otl_SubtableList, otl_SubtablePtr, otl_Lookup,
- disposeSubtableDependent);
-caryll_VectorImplFunctions(otl_SubtableList, otl_SubtablePtr, otl_iSubtablePtr);
-caryll_VectorInterfaceTypeName(otl_SubtableList) otl_iSubtableList = {
- caryll_VectorImplAssignments(otl_SubtableList, otl_SubtablePtr, otl_iSubtablePtr),
- .disposeDependent = otl_SubtableList_disposeDependent,
-};
-
-void otfcc_delete_lookup(otl_Lookup *lookup) {
- if (!lookup) return;
- otl_iSubtableList.disposeDependent(&lookup->subtables, lookup);
- sdsfree(lookup->name);
- FREE(lookup);
-}
-
-// LOOKUP
-static INLINE void initLookupPtr(otl_LookupPtr *entry) {
- NEW(*entry);
- (*entry)->name = NULL;
- otl_iSubtableList.init(&(*entry)->subtables);
-}
-static INLINE void disposeLookupPtr(otl_LookupPtr *entry) {
- otfcc_delete_lookup(*entry);
-}
-caryll_standardType(otl_LookupPtr, otl_iLookupPtr, initLookupPtr, disposeLookupPtr);
-caryll_standardVectorImpl(otl_LookupList, otl_LookupPtr, otl_iLookupPtr, otl_iLookupList);
-caryll_standardType(otl_LookupRef, otl_iLookupRef);
-caryll_standardVectorImpl(otl_LookupRefList, otl_LookupRef, otl_iLookupRef, otl_iLookupRefList);
-
-// FEATURE
-static INLINE void initFeaturePtr(otl_FeaturePtr *feature) {
- NEW(*feature);
- otl_iLookupRefList.init(&(*feature)->lookups);
-}
-static INLINE void disposeFeaturePtr(otl_FeaturePtr *feature) {
- if (!*feature) return;
- if ((*feature)->name) sdsfree((*feature)->name);
- otl_iLookupRefList.dispose(&(*feature)->lookups);
- FREE(*feature);
-}
-caryll_standardType(otl_FeaturePtr, otl_iFeaturePtr, initFeaturePtr, disposeFeaturePtr);
-caryll_standardVectorImpl(otl_FeatureList, otl_FeaturePtr, otl_iFeaturePtr, otl_iFeatureList);
-caryll_standardType(otl_FeatureRef, otl_iFeatureRef);
-caryll_standardVectorImpl(otl_FeatureRefList, otl_FeatureRef, otl_iFeatureRef, otl_iFeatureRefList);
-
-// LANGUAGE
-static INLINE void initLanguagePtr(otl_LanguageSystemPtr *language) {
- NEW(*language);
- otl_iFeatureRefList.init(&(*language)->features);
-}
-static INLINE void disposeLanguagePtr(otl_LanguageSystemPtr *language) {
- if (!*language) return;
- if ((*language)->name) sdsfree((*language)->name);
- otl_iFeatureRefList.dispose(&(*language)->features);
- FREE(*language);
-}
-caryll_ElementInterfaceOf(otl_LanguageSystemPtr) otl_iLanguageSystem = {
- .init = initLanguagePtr, .dispose = disposeLanguagePtr,
-};
-caryll_standardVectorImpl(otl_LangSystemList, otl_LanguageSystemPtr, otl_iLanguageSystem,
- otl_iLangSystemList);
-
-// COMMON PART
-static INLINE void initOTL(table_OTL *table) {
- otl_iLookupList.init(&table->lookups);
- otl_iFeatureList.init(&table->features);
- otl_iLangSystemList.init(&table->languages);
-}
-static INLINE void disposeOTL(table_OTL *table) {
- otl_iLookupList.dispose(&table->lookups);
- otl_iFeatureList.dispose(&table->features);
- otl_iLangSystemList.dispose(&table->languages);
-}
-
-caryll_standardRefType(table_OTL, table_iOTL, initOTL, disposeOTL);
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/parse.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/parse.c
deleted file mode 100644
index f02b3746d21..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/parse.c
+++ /dev/null
@@ -1,376 +0,0 @@
-#include "private.h"
-
-typedef enum { LOOKUP_ORDER_FORCE, LOOKUP_ORDER_FILE } lookup_order_type;
-
-typedef struct {
- char *name;
- otl_Lookup *lookup;
- UT_hash_handle hh;
- lookup_order_type orderType;
- uint16_t orderVal;
-} lookup_hash;
-
-typedef struct {
- char *name;
- bool alias;
- otl_Feature *feature;
- UT_hash_handle hh;
-} feature_hash;
-
-typedef struct {
- char *name;
- otl_LanguageSystem *language;
- UT_hash_handle hh;
-} language_hash;
-static bool _declareLookupParser(const char *lt, otl_LookupType llt,
- otl_Subtable *(*parser)(const json_value *,
- const otfcc_Options *options),
- json_value *_lookup, char *lookupName,
- const otfcc_Options *options, lookup_hash **lh);
-
-#define LOOKUP_PARSER(llt, parser) \
- if (!parsed) { \
- parsed = \
- _declareLookupParser(tableNames[llt], llt, parser, lookup, lookupName, options, lh); \
- }
-
-static bool _parse_lookup(json_value *lookup, char *lookupName, const otfcc_Options *options,
- lookup_hash **lh) {
- bool parsed = false;
- LOOKUP_PARSER(otl_type_gsub_single, otl_gsub_parse_single);
- LOOKUP_PARSER(otl_type_gsub_multiple, otl_gsub_parse_multi);
- LOOKUP_PARSER(otl_type_gsub_alternate, otl_gsub_parse_multi);
- LOOKUP_PARSER(otl_type_gsub_ligature, otl_gsub_parse_ligature);
- LOOKUP_PARSER(otl_type_gsub_chaining, otl_parse_chaining);
- LOOKUP_PARSER(otl_type_gsub_reverse, otl_gsub_parse_reverse);
- LOOKUP_PARSER(otl_type_gpos_single, otl_gpos_parse_single);
- LOOKUP_PARSER(otl_type_gpos_pair, otl_gpos_parse_pair);
- LOOKUP_PARSER(otl_type_gpos_cursive, otl_gpos_parse_cursive);
- LOOKUP_PARSER(otl_type_gpos_chaining, otl_parse_chaining);
- LOOKUP_PARSER(otl_type_gpos_markToBase, otl_gpos_parse_markToSingle);
- LOOKUP_PARSER(otl_type_gpos_markToMark, otl_gpos_parse_markToSingle);
- LOOKUP_PARSER(otl_type_gpos_markToLigature, otl_gpos_parse_markToLigature);
- return parsed;
-}
-
-static bool _declareLookupParser(const char *lt, otl_LookupType llt,
- otl_Subtable *(*parser)(const json_value *,
- const otfcc_Options *options),
- json_value *_lookup, char *lookupName,
- const otfcc_Options *options, lookup_hash **lh) {
-
- // detect a valid type field exists
- json_value *type = json_obj_get_type(_lookup, "type", json_string);
- if (!type || strcmp(type->u.string.ptr, lt)) {
- if (!type) logWarning("Lookup %s does not have a valid 'type' field.", lookupName);
- return false;
- }
- // no duplicate lookup has been parsed
- lookup_hash *item = NULL;
- HASH_FIND_STR(*lh, lookupName, item);
- if (item) {
- logWarning("Lookup %s already exists.", lookupName);
- return false;
- }
- // detect valid subtables array
- json_value *_subtables = json_obj_get_type(_lookup, "subtables", json_array);
- if (!_subtables) {
- logWarning("Lookup %s does not have a valid subtable list.", lookupName);
- return false;
- }
- // init this lookup
- otl_Lookup *lookup;
- otl_iLookupPtr.init(&lookup);
- lookup->type = llt;
- lookup->flags = otfcc_parse_flags(json_obj_get(_lookup, "flags"), lookupFlagsLabels);
- uint16_t markAttachmentType = json_obj_getint(_lookup, "markAttachmentType");
- if (markAttachmentType) { lookup->flags |= markAttachmentType << 8; }
- // start parse subtables
- tableid_t subtableCount = _subtables->u.array.length;
- loggedStep("%s", lookupName) {
- for (tableid_t j = 0; j < subtableCount; j++) {
- json_value *_subtable = _subtables->u.array.values[j];
- if (_subtable && _subtable->type == json_object) {
- otl_Subtable *_st = parser(_subtable, options);
- otl_iSubtableList.push(&lookup->subtables, _st);
- }
- }
- }
- if (!lookup->subtables.length) {
- logWarning("Lookup %s does not have any subtables.", lookupName);
- otfcc_delete_lookup(lookup);
- return false;
- }
- // we've found a valid lookup, put it into the hash.
- NEW(item);
- item->name = sdsnew(lookupName);
- lookup->name = sdsdup(item->name);
- item->lookup = lookup;
- item->orderType = LOOKUP_ORDER_FILE;
- item->orderVal = HASH_COUNT(*lh);
- HASH_ADD_STR(*lh, name, item);
- return true;
-}
-
-static lookup_hash *figureOutLookupsFromJSON(json_value *lookups, const otfcc_Options *options) {
- lookup_hash *lh = NULL;
-
- for (uint32_t j = 0; j < lookups->u.object.length; j++) {
- char *lookupName = lookups->u.object.values[j].name;
- if (lookups->u.object.values[j].value->type == json_object) {
- bool parsed =
- _parse_lookup(lookups->u.object.values[j].value, lookupName, options, &lh);
- if (!parsed) {
- logWarning("[OTFCC-fea] Ignoring invalid or unsupported lookup %s.\n", lookupName);
- }
- } else if (lookups->u.object.values[j].value->type == json_string) {
- char *thatname = lookups->u.object.values[j].value->u.string.ptr;
- lookup_hash *s = NULL;
- HASH_FIND_STR(lh, thatname, s);
- if (s) {
- lookup_hash *dup;
- NEW(dup);
- dup->name = sdsnew(lookupName);
- dup->lookup = s->lookup;
- dup->orderType = LOOKUP_ORDER_FILE;
- dup->orderVal = HASH_COUNT(lh);
- HASH_ADD_STR(lh, name, dup);
- }
- }
- }
- return lh;
-}
-
-static void feature_merger_activate(json_value *d, const bool sametag, const char *objtype,
- const otfcc_Options *options) {
- for (uint32_t j = 0; j < d->u.object.length; j++) {
- json_value *jthis = d->u.object.values[j].value;
- char *kthis = d->u.object.values[j].name;
- uint32_t nkthis = d->u.object.values[j].name_length;
- if (jthis->type != json_array && jthis->type != json_object) continue;
- for (uint32_t k = j + 1; k < d->u.object.length; k++) {
- json_value *jthat = d->u.object.values[k].value;
- char *kthat = d->u.object.values[k].name;
- if (json_ident(jthis, jthat) && (sametag ? strncmp(kthis, kthat, 4) == 0 : true)) {
- json_value_free(jthat);
- json_value *v = json_string_new_length(nkthis, kthis);
- v->parent = d;
- d->u.object.values[k].value = v;
- logNotice("[OTFCC-fea] Merged duplicate %s '%s' into '%s'.\n", objtype, kthat,
- kthis);
- }
- }
- }
-}
-
-static feature_hash *figureOutFeaturesFromJSON(json_value *features, lookup_hash *lh,
- const char *tag, const otfcc_Options *options) {
- feature_hash *fh = NULL;
- // Remove duplicates
- if (options->merge_features) { feature_merger_activate(features, true, "feature", options); }
- // Resolve features
- for (uint32_t j = 0; j < features->u.object.length; j++) {
- char *featureName = features->u.object.values[j].name;
- json_value *_feature = features->u.object.values[j].value;
- if (_feature->type == json_array) {
- otl_LookupRefList al;
- otl_iLookupRefList.init(&al);
- for (tableid_t k = 0; k < _feature->u.array.length; k++) {
- json_value *term = _feature->u.array.values[k];
- if (term->type != json_string) continue;
- lookup_hash *item = NULL;
- HASH_FIND_STR(lh, term->u.string.ptr, item);
- if (item) {
- otl_iLookupRefList.push(&al, item->lookup);
- } else {
- logWarning("Lookup assignment %s for feature [%s/%s] is missing or invalid.",
- term->u.string.ptr, tag, featureName)
- }
- }
- if (al.length > 0) {
- feature_hash *s = NULL;
- HASH_FIND_STR(fh, featureName, s);
- if (!s) {
- NEW(s);
- s->name = sdsnew(featureName);
- s->alias = false;
- otl_iFeaturePtr.init(&s->feature);
- s->feature->name = sdsdup(s->name);
- otl_iLookupRefList.replace(&s->feature->lookups, al);
- HASH_ADD_STR(fh, name, s);
- } else {
- logWarning("[OTFCC-fea] Duplicate feature for [%s/%s]. This feature will "
- "be ignored.\n",
- tag, featureName);
- otl_iLookupRefList.dispose(&al);
- }
- } else {
- logWarning("[OTFCC-fea] There is no valid lookup "
- "assignments for [%s/%s]. This feature will be "
- "ignored.\n",
- tag, featureName);
- otl_iLookupRefList.dispose(&al);
- }
- } else if (_feature->type == json_string) {
- feature_hash *s = NULL;
- char *target = _feature->u.string.ptr;
- HASH_FIND_STR(fh, target, s);
- if (s) {
- feature_hash *dup;
- NEW(dup);
- dup->alias = true;
- dup->name = sdsnew(featureName);
- dup->feature = s->feature;
- HASH_ADD_STR(fh, name, dup);
- }
- }
- }
- return fh;
-}
-static bool isValidLanguageName(const char *name, const size_t length) {
- return length == 9 && name[4] == SCRIPT_LANGUAGE_SEPARATOR;
-}
-static language_hash *figureOutLanguagesFromJson(json_value *languages, feature_hash *fh,
- const char *tag, const otfcc_Options *options) {
- language_hash *sh = NULL;
- // languages
- for (uint32_t j = 0; j < languages->u.object.length; j++) {
- char *languageName = languages->u.object.values[j].name;
- size_t languageNameLen = languages->u.object.values[j].name_length;
- json_value *_language = languages->u.object.values[j].value;
- if (isValidLanguageName(languageName, languageNameLen) && _language->type == json_object) {
- otl_Feature *requiredFeature = NULL;
- json_value *_rf = json_obj_get_type(_language, "requiredFeature", json_string);
- if (_rf) {
- // required feature term
- feature_hash *rf = NULL;
- HASH_FIND_STR(fh, _rf->u.string.ptr, rf);
- if (rf) { requiredFeature = rf->feature; }
- }
- otl_FeatureRefList af;
- otl_iFeatureRefList.init(&af);
- json_value *_features = json_obj_get_type(_language, "features", json_array);
- if (_features) {
- for (tableid_t k = 0; k < _features->u.array.length; k++) {
- json_value *term = _features->u.array.values[k];
- if (term->type == json_string) {
- feature_hash *item = NULL;
- HASH_FIND_STR(fh, term->u.string.ptr, item);
- if (item) { otl_iFeatureRefList.push(&af, item->feature); }
- }
- }
- }
- if (requiredFeature || (af.length > 0)) {
- language_hash *s = NULL;
- HASH_FIND_STR(sh, languageName, s);
- if (!s) {
- NEW(s);
- s->name = sdsnew(languageName);
- otl_iLanguageSystem.init(&s->language);
- s->language->name = sdsdup(s->name);
- s->language->requiredFeature = requiredFeature;
- otl_iFeatureRefList.replace(&s->language->features, af);
- HASH_ADD_STR(sh, name, s);
- } else {
- logWarning("[OTFCC-fea] Duplicate language item [%s/%s]. This language "
- "term will be ignored.\n",
- tag, languageName);
- otl_iFeatureRefList.dispose(&af);
- }
- } else {
- logWarning("[OTFCC-fea] There is no valid feature "
- "assignments for [%s/%s]. This language term "
- "will be ignored.\n",
- tag, languageName);
- otl_iFeatureRefList.dispose(&af);
- }
- }
- }
- return sh;
-}
-
-static int by_lookup_order(lookup_hash *a, lookup_hash *b) {
- if (a->orderType == b->orderType) {
- return a->orderVal - b->orderVal;
- } else {
- return a->orderType - b->orderType;
- }
-}
-static int by_feature_name(feature_hash *a, feature_hash *b) {
- return strcmp(a->name, b->name);
-}
-static int by_language_name(language_hash *a, language_hash *b) {
- return strcmp(a->name, b->name);
-}
-table_OTL *otfcc_parseOtl(const json_value *root, const otfcc_Options *options, const char *tag) {
- table_OTL *otl = NULL;
- json_value *table = json_obj_get_type(root, tag, json_object);
- if (!table) goto FAIL;
- otl = table_iOTL.create();
- json_value *languages = json_obj_get_type(table, "languages", json_object);
- json_value *features = json_obj_get_type(table, "features", json_object);
- json_value *lookups = json_obj_get_type(table, "lookups", json_object);
- if (!languages || !features || !lookups) goto FAIL;
-
- loggedStep("%s", tag) {
- lookup_hash *lh = figureOutLookupsFromJSON(lookups, options);
- json_value *lookupOrder = json_obj_get_type(table, "lookupOrder", json_array);
- if (lookupOrder) {
- for (tableid_t j = 0; j < lookupOrder->u.array.length; j++) {
- json_value *_ln = lookupOrder->u.array.values[j];
- if (_ln && _ln->type == json_string) {
- lookup_hash *item = NULL;
- HASH_FIND_STR(lh, _ln->u.string.ptr, item);
- if (item) {
- item->orderType = LOOKUP_ORDER_FORCE;
- item->orderVal = j;
- }
- }
- }
- }
- HASH_SORT(lh, by_lookup_order);
- feature_hash *fh = figureOutFeaturesFromJSON(features, lh, tag, options);
- HASH_SORT(fh, by_feature_name);
- language_hash *sh = figureOutLanguagesFromJson(languages, fh, tag, options);
- HASH_SORT(sh, by_language_name);
- if (!HASH_COUNT(lh) || !HASH_COUNT(fh) || !HASH_COUNT(sh)) {
- options->logger->dedent(options->logger);
- goto FAIL;
- }
-
- {
- lookup_hash *s, *tmp;
- HASH_ITER(hh, lh, s, tmp) {
- otl_iLookupList.push(&otl->lookups, s->lookup);
- HASH_DEL(lh, s);
- sdsfree(s->name);
- FREE(s);
- }
- }
- {
- feature_hash *s, *tmp;
- HASH_ITER(hh, fh, s, tmp) {
- if (!s->alias) { otl_iFeatureList.push(&otl->features, s->feature); }
- HASH_DEL(fh, s);
- sdsfree(s->name);
- FREE(s);
- }
- }
- {
- language_hash *s, *tmp;
- HASH_ITER(hh, sh, s, tmp) {
- otl_iLangSystemList.push(&otl->languages, s->language);
- HASH_DEL(sh, s);
- sdsfree(s->name);
- FREE(s);
- }
- }
- }
- return otl;
-FAIL:
- if (otl) {
- logWarning("[OTFCC-fea] Ignoring invalid or incomplete OTL table %s.\n", tag);
- table_iOTL.free(otl);
- }
- return NULL;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/private.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/private.h
deleted file mode 100644
index 3e72b77face..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/private.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_PRIVATE_H
-#define CARYLL_TABLE_OTL_PRIVATE_H
-
-#include "subtables/gsub-single.h"
-#include "subtables/gsub-multi.h"
-#include "subtables/gsub-ligature.h"
-#include "subtables/gsub-reverse.h"
-#include "subtables/gpos-single.h"
-#include "subtables/gpos-pair.h"
-#include "subtables/gpos-cursive.h"
-#include "subtables/gpos-mark-to-single.h"
-#include "subtables/gpos-mark-to-ligature.h"
-#include "subtables/chaining.h"
-#include "subtables/extend.h"
-
-extern const char SCRIPT_LANGUAGE_SEPARATOR;
-extern const char *lookupFlagsLabels[];
-extern const char *tableNames[];
-
-void otfcc_delete_lookup(otl_Lookup *lookup);
-
-#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/read.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/read.c
deleted file mode 100644
index f1fd1f9230b..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/read.c
+++ /dev/null
@@ -1,267 +0,0 @@
-#include "private.h"
-
-#define LOOKUP_READER(llt, fn) \
- case llt: \
- return fn(data, tableLength, subtableOffset, maxGlyphs, options);
-
-otl_Subtable *otfcc_readOtl_subtable(font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, otl_LookupType lookupType,
- const glyphid_t maxGlyphs, const otfcc_Options *options) {
- switch (lookupType) {
- LOOKUP_READER(otl_type_gsub_single, otl_read_gsub_single);
- LOOKUP_READER(otl_type_gsub_multiple, otl_read_gsub_multi);
- LOOKUP_READER(otl_type_gsub_alternate, otl_read_gsub_multi);
- LOOKUP_READER(otl_type_gsub_ligature, otl_read_gsub_ligature);
- LOOKUP_READER(otl_type_gsub_chaining, otl_read_chaining);
- LOOKUP_READER(otl_type_gsub_reverse, otl_read_gsub_reverse);
- LOOKUP_READER(otl_type_gpos_chaining, otl_read_chaining);
- LOOKUP_READER(otl_type_gsub_context, otl_read_contextual);
- LOOKUP_READER(otl_type_gpos_context, otl_read_contextual);
- LOOKUP_READER(otl_type_gpos_single, otl_read_gpos_single);
- LOOKUP_READER(otl_type_gpos_pair, otl_read_gpos_pair);
- LOOKUP_READER(otl_type_gpos_cursive, otl_read_gpos_cursive);
- LOOKUP_READER(otl_type_gpos_markToBase, otl_read_gpos_markToSingle);
- LOOKUP_READER(otl_type_gpos_markToMark, otl_read_gpos_markToSingle);
- LOOKUP_READER(otl_type_gpos_markToLigature, otl_read_gpos_markToLigature);
- LOOKUP_READER(otl_type_gsub_extend, otfcc_readOtl_gsub_extend);
- LOOKUP_READER(otl_type_gpos_extend, otfcc_readOtl_gpos_extend);
- default:
- return NULL;
- }
-}
-
-static void parseLanguage(font_file_pointer data, uint32_t tableLength, uint32_t base,
- otl_LanguageSystem *lang, otl_FeatureList *features) {
- checkLength(base + 6);
- tableid_t rid = read_16u(data + base + 2);
- if (rid < features->length) {
- lang->requiredFeature = features->items[rid];
- } else {
- lang->requiredFeature = NULL;
- }
- tableid_t featureCount = read_16u(data + base + 4);
- for (tableid_t j = 0; j < featureCount; j++) {
- tableid_t featureIndex = read_16u(data + base + 6 + 2 * j);
- if (featureIndex < features->length) {
- otl_iFeatureRefList.push(&lang->features, features->items[featureIndex]);
- }
- }
- return;
-FAIL:
- otl_iFeatureRefList.dispose(&lang->features);
- lang->requiredFeature = NULL;
- return;
-}
-
-static table_OTL *otfcc_readOtl_common(font_file_pointer data, uint32_t tableLength,
- otl_LookupType lookup_type_base,
- const otfcc_Options *options) {
- table_OTL *table = table_iOTL.create();
- if (!table) goto FAIL;
- checkLength(10);
- uint32_t scriptListOffset = read_16u(data + 4);
- checkLength(scriptListOffset + 2);
- uint32_t featureListOffset = read_16u(data + 6);
- checkLength(featureListOffset + 2);
- uint32_t lookupListOffset = read_16u(data + 8);
- checkLength(lookupListOffset + 2);
-
- // parse lookup list
- {
- tableid_t lookupCount = read_16u(data + lookupListOffset);
- checkLength(lookupListOffset + 2 + lookupCount * 2);
- for (tableid_t j = 0; j < lookupCount; j++) {
- otl_Lookup *lookup;
- otl_iLookupPtr.init(&lookup);
- lookup->_offset = lookupListOffset + read_16u(data + lookupListOffset + 2 + 2 * j);
- checkLength(lookup->_offset + 6);
- lookup->type = read_16u(data + lookup->_offset) + lookup_type_base;
- otl_iLookupList.push(&table->lookups, lookup);
- }
- }
-
- // parse feature list
- {
- tableid_t featureCount = read_16u(data + featureListOffset);
- checkLength(featureListOffset + 2 + featureCount * 6);
- tableid_t lnk = 0;
- for (tableid_t j = 0; j < featureCount; j++) {
- otl_Feature *feature;
- otl_iFeaturePtr.init(&feature);
- uint32_t tag = read_32u(data + featureListOffset + 2 + j * 6);
- if (options->glyph_name_prefix) {
- feature->name = sdscatprintf(sdsempty(), "%c%c%c%c_%s_%05d", (tag >> 24) & 0xFF,
- (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff,
- options->glyph_name_prefix, j);
- } else {
- feature->name = sdscatprintf(sdsempty(), "%c%c%c%c_%05d", (tag >> 24) & 0xFF,
- (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff, j);
- }
- uint32_t featureOffset =
- featureListOffset + read_16u(data + featureListOffset + 2 + j * 6 + 4);
-
- checkLength(featureOffset + 4);
- tableid_t lookupCount = read_16u(data + featureOffset + 2);
- checkLength(featureOffset + 4 + lookupCount * 2);
- for (tableid_t k = 0; k < lookupCount; k++) {
- tableid_t lookupid = read_16u(data + featureOffset + 4 + k * 2);
- if (lookupid < table->lookups.length) {
- otl_Lookup *lookup = table->lookups.items[lookupid];
- if (!lookup->name) {
- if (options->glyph_name_prefix) {
- lookup->name = sdscatprintf(sdsempty(), "lookup_%s_%c%c%c%c_%d",
- options->glyph_name_prefix,
- (tag >> 24) & 0xFF, (tag >> 16) & 0xFF,
- (tag >> 8) & 0xff, tag & 0xff, lnk++);
- } else {
- lookup->name = sdscatprintf(sdsempty(), "lookup_%c%c%c%c_%d",
- (tag >> 24) & 0xFF, (tag >> 16) & 0xFF,
- (tag >> 8) & 0xff, tag & 0xff, lnk++);
- }
- }
- otl_iLookupRefList.push(&feature->lookups, lookup);
- }
- }
- otl_iFeatureList.push(&table->features, feature);
- }
- }
-
- // parse script list
- {
- tableid_t scriptCount = read_16u(data + scriptListOffset);
- checkLength(scriptListOffset + 2 + 6 * scriptCount);
-
- uint32_t nLanguageCombinations = 0;
- for (tableid_t j = 0; j < scriptCount; j++) {
- uint32_t scriptOffset =
- scriptListOffset + read_16u(data + scriptListOffset + 2 + 6 * j + 4);
- checkLength(scriptOffset + 4);
-
- tableid_t defaultLangSystem = read_16u(data + scriptOffset);
- nLanguageCombinations +=
- (defaultLangSystem ? 1 : 0) + read_16u(data + scriptOffset + 2);
- }
-
- for (tableid_t j = 0; j < scriptCount; j++) {
- uint32_t tag = read_32u(data + scriptListOffset + 2 + 6 * j);
- uint32_t scriptOffset =
- scriptListOffset + read_16u(data + scriptListOffset + 2 + 6 * j + 4);
- tableid_t defaultLangSystem = read_16u(data + scriptOffset);
- if (defaultLangSystem) {
- otl_LanguageSystem *lang;
- otl_iLanguageSystem.init(&lang);
- lang->name = sdscatprintf(sdsempty(), "%c%c%c%c%cDFLT", (tag >> 24) & 0xFF,
- (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff,
- SCRIPT_LANGUAGE_SEPARATOR);
- parseLanguage(data, tableLength, scriptOffset + defaultLangSystem, lang,
- &table->features);
- otl_iLangSystemList.push(&table->languages, lang);
- }
- tableid_t langSysCount = read_16u(data + scriptOffset + 2);
- for (tableid_t k = 0; k < langSysCount; k++) {
- uint32_t langTag = read_32u(data + scriptOffset + 4 + 6 * k);
- tableid_t langSys = read_16u(data + scriptOffset + 4 + 6 * k + 4);
- otl_LanguageSystem *lang;
- otl_iLanguageSystem.init(&lang);
- lang->name =
- sdscatprintf(sdsempty(), "%c%c%c%c%c%c%c%c%c", (tag >> 24) & 0xFF,
- (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff,
- SCRIPT_LANGUAGE_SEPARATOR, (langTag >> 24) & 0xFF,
- (langTag >> 16) & 0xFF, (langTag >> 8) & 0xff, langTag & 0xff);
- parseLanguage(data, tableLength, scriptOffset + langSys, lang, &table->features);
- otl_iLangSystemList.push(&table->languages, lang);
- }
- }
- }
-
- // name all lookups
- for (tableid_t j = 0; j < table->lookups.length; j++) {
- if (!table->lookups.items[j]->name) {
- if (options->glyph_name_prefix) {
- table->lookups.items[j]->name =
- sdscatprintf(sdsempty(), "lookup_%s_%02x_%d", options->glyph_name_prefix,
- table->lookups.items[j]->type, j);
- } else {
- table->lookups.items[j]->name =
- sdscatprintf(sdsempty(), "lookup_%02x_%d", table->lookups.items[j]->type, j);
- }
- }
- }
- return table;
-FAIL:
- if (table) table_iOTL.free(table);
- return NULL;
-}
-
-static void otfcc_readOtl_lookup(font_file_pointer data, uint32_t tableLength, otl_Lookup *lookup,
- glyphid_t maxGlyphs, const otfcc_Options *options) {
- lookup->flags = read_16u(data + lookup->_offset + 2);
- tableid_t subtableCount = read_16u(data + lookup->_offset + 4);
- if (!subtableCount || tableLength < lookup->_offset + 6 + 2 * subtableCount) {
- lookup->type = otl_type_unknown;
- return;
- }
- for (tableid_t j = 0; j < subtableCount; j++) {
- uint32_t subtableOffset = lookup->_offset + read_16u(data + lookup->_offset + 6 + j * 2);
- otl_Subtable *subtable = otfcc_readOtl_subtable(data, tableLength, subtableOffset,
- lookup->type, maxGlyphs, options);
- otl_iSubtableList.push(&lookup->subtables, subtable);
- }
- if (lookup->type == otl_type_gsub_extend || lookup->type == otl_type_gpos_extend) {
- lookup->type = 0;
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- if (lookup->subtables.items[j]) {
- lookup->type = lookup->subtables.items[j]->extend.type;
- break;
- }
- }
- if (lookup->type) {
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- if (lookup->subtables.items[j] &&
- lookup->subtables.items[j]->extend.type == lookup->type) {
- // this subtable is valid
- otl_Subtable *st = lookup->subtables.items[j]->extend.subtable;
- FREE(lookup->subtables.items[j]);
- lookup->subtables.items[j] = st;
- } else if (lookup->subtables.items[j]) {
- // type mismatch, delete this subtable
- otl_Lookup *temp;
- otl_iLookupPtr.init(&temp);
- temp->type = lookup->subtables.items[j]->extend.type;
- otl_iSubtableList.push(&temp->subtables,
- lookup->subtables.items[j]->extend.subtable);
- DELETE(otfcc_delete_lookup, temp);
- FREE(lookup->subtables.items[j]);
- }
- }
- } else {
- otl_iSubtableList.disposeDependent(&lookup->subtables, lookup);
- return;
- }
- }
- if (lookup->type == otl_type_gsub_context) lookup->type = otl_type_gsub_chaining;
- if (lookup->type == otl_type_gpos_context) lookup->type = otl_type_gpos_chaining;
-}
-
-table_OTL *otfcc_readOtl(otfcc_Packet packet, const otfcc_Options *options, uint32_t tag,
- glyphid_t maxGlyphs) {
- table_OTL *otl = NULL;
- FOR_TABLE(tag, table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
- otl = otfcc_readOtl_common(data, length,
- (tag == OTFCC_CHR('G','S','U','B')
- ? otl_type_gsub_unknown
- : tag == OTFCC_CHR('G','P','O','S') ? otl_type_gpos_unknown : otl_type_unknown),
- options);
- if (!otl) goto FAIL;
- for (tableid_t j = 0; j < otl->lookups.length; j++) {
- otfcc_readOtl_lookup(data, length, otl->lookups.items[j], maxGlyphs, options);
- }
- return otl;
- FAIL:
- if (otl) table_iOTL.free(otl);
- otl = NULL;
- }
- return NULL;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining.h
deleted file mode 100644
index a7b14ac8b06..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_CHAINING_H
-#define CARYLL_TABLE_OTL_CHAINING_H
-
-#include "common.h"
-
-// This file supports four formats
-// GSUB contextual
-// GSUB chaining
-// GPOS contextual
-// GPOS chaining
-
-otl_Subtable *otl_read_chaining(const font_file_pointer data, uint32_t tableLength, uint32_t offset,
- const glyphid_t maxGlyphs, const otfcc_Options *options);
-otl_Subtable *otl_read_contextual(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_dump_chaining(const otl_Subtable *_subtable);
-otl_Subtable *otl_parse_chaining(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_chaining(const otl_Subtable *_subtable);
-caryll_Buffer *otfcc_build_contextual(const otl_Subtable *_subtable);
-
-tableid_t otfcc_classifiedBuildChaining(const otl_Lookup *lookup,
- OUT caryll_Buffer ***subtableBuffers,
- MODIFY size_t *lastOffset);
-
-bool otfcc_chainingLookupIsContextualLookup(const otl_Lookup *lookup);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/build.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/build.c
deleted file mode 100644
index 6ec7958addb..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/build.c
+++ /dev/null
@@ -1,239 +0,0 @@
-#include "../chaining.h"
-#include "common.h"
-
-bool otfcc_chainingLookupIsContextualLookup(const otl_Lookup *lookup) {
- if (!(lookup->type == otl_type_gpos_chaining || lookup->type == otl_type_gsub_chaining))
- return false;
- bool isContextual = true;
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- const subtable_chaining *subtable = &(lookup->subtables.items[j]->chaining);
- if (subtable->type == otl_chaining_classified) {
- for (tableid_t k = 0; k < subtable->rulesCount; k++) {
- otl_ChainingRule *rule = subtable->rules[k];
- tableid_t nBacktrack = rule->inputBegins;
- tableid_t nLookahead = rule->matchCount - rule->inputEnds;
- isContextual = isContextual && !nBacktrack && !nLookahead;
- }
- } else {
- const otl_ChainingRule *rule = (const otl_ChainingRule *)&(subtable->rule);
- tableid_t nBacktrack = rule->inputBegins;
- tableid_t nLookahead = rule->matchCount - rule->inputEnds;
- isContextual = isContextual && !nBacktrack && !nLookahead;
- }
- }
- return isContextual;
-}
-
-////// CHAINING
-
-static caryll_Buffer *otfcc_build_chaining_coverage(const otl_Subtable *_subtable) {
- const subtable_chaining *subtable = &(_subtable->chaining);
- const otl_ChainingRule *rule = (const otl_ChainingRule *)&(subtable->rule);
- tableid_t nBacktrack = rule->inputBegins;
- tableid_t nInput = rule->inputEnds - rule->inputBegins;
- tableid_t nLookahead = rule->matchCount - rule->inputEnds;
- tableid_t nSubst = rule->applyCount;
- reverseBacktracks(rule);
-
- bk_Block *root = bk_new_Block(b16, 3, // format
- bkover);
-
- bk_push(root, b16, nBacktrack, bkover);
- for (tableid_t j = 0; j < rule->inputBegins; j++) {
- bk_push(root, p16, bk_newBlockFromBuffer(Coverage.build(rule->match[j])), bkover);
- }
- bk_push(root, b16, nInput, bkover);
- for (tableid_t j = rule->inputBegins; j < rule->inputEnds; j++) {
- bk_push(root, p16, bk_newBlockFromBuffer(Coverage.build(rule->match[j])), bkover);
- }
- bk_push(root, b16, nLookahead, bkover);
- for (tableid_t j = rule->inputEnds; j < rule->matchCount; j++) {
- bk_push(root, p16, bk_newBlockFromBuffer(Coverage.build(rule->match[j])), bkover);
- }
- bk_push(root, b16, rule->applyCount, bkover);
- for (tableid_t j = 0; j < nSubst; j++) {
- bk_push(root, b16, rule->apply[j].index - nBacktrack, // position
- b16, rule->apply[j].lookup.index, // lookup
- bkover);
- }
-
- return bk_build_Block(root);
-}
-
-static caryll_Buffer *otfcc_build_chaining_classes(const otl_Subtable *_subtable) {
- const subtable_chaining *subtable = &(_subtable->chaining);
-
- otl_Coverage *coverage;
- NEW(coverage);
- coverage->numGlyphs = subtable->ic->numGlyphs;
- coverage->glyphs = subtable->ic->glyphs;
-
- bk_Block *root =
- bk_new_Block(b16, 2, // format
- p16, bk_newBlockFromBuffer(Coverage.build(coverage)), // coverage
- p16, bk_newBlockFromBuffer(ClassDef.build(subtable->bc)), // BacktrackClassDef
- p16, bk_newBlockFromBuffer(ClassDef.build(subtable->ic)), // InputClassDef
- p16, bk_newBlockFromBuffer(ClassDef.build(subtable->fc)), // LookaheadClassDef
- b16, subtable->ic->maxclass + 1, // ChainSubClassSetCnt
- bkover);
-
- glyphclass_t *rcpg;
- NEW(rcpg, subtable->ic->maxclass + 1);
- for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
- rcpg[j] = 0;
- }
- for (tableid_t j = 0; j < subtable->rulesCount; j++) {
- tableid_t ib = subtable->rules[j]->inputBegins;
- tableid_t startClass = subtable->rules[j]->match[ib]->glyphs[0].index;
- if (startClass <= subtable->ic->maxclass) rcpg[startClass] += 1;
- }
-
- for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
- if (rcpg[j]) {
- bk_Block *cset = bk_new_Block(b16, rcpg[j], // ChainSubClassRuleCnt
- bkover);
- for (tableid_t k = 0; k < subtable->rulesCount; k++) {
- otl_ChainingRule *rule = subtable->rules[k];
- glyphclass_t startClass = rule->match[rule->inputBegins]->glyphs[0].index;
- if (startClass != j) { continue; }
- reverseBacktracks(rule);
- tableid_t nBacktrack = rule->inputBegins;
- tableid_t nInput = rule->inputEnds - rule->inputBegins;
- tableid_t nLookahead = rule->matchCount - rule->inputEnds;
- tableid_t nSubst = rule->applyCount;
- bk_Block *r = bk_new_Block(bkover);
- bk_push(r, b16, nBacktrack, bkover);
- for (tableid_t m = 0; m < rule->inputBegins; m++) {
- bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
- }
- bk_push(r, b16, nInput, bkover);
- for (tableid_t m = rule->inputBegins + 1; m < rule->inputEnds; m++) {
- bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
- }
- bk_push(r, b16, nLookahead, bkover);
- for (tableid_t m = rule->inputEnds; m < rule->matchCount; m++) {
- bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
- }
- bk_push(r, b16, nSubst, bkover);
- for (tableid_t m = 0; m < nSubst; m++) {
- bk_push(r, b16, rule->apply[m].index - nBacktrack, // position
- b16, rule->apply[m].lookup.index, // lookup index
- bkover);
- }
- bk_push(cset, p16, r, bkover);
- }
- bk_push(root, p16, cset, bkover);
- } else {
- bk_push(root, p16, NULL, bkover);
- }
- }
-
- FREE(coverage);
- FREE(rcpg);
- return bk_build_Block(root);
-}
-
-caryll_Buffer *otfcc_build_chaining(const otl_Subtable *_subtable) {
- if (_subtable->chaining.type == otl_chaining_classified) {
- return otfcc_build_chaining_classes(_subtable);
- } else {
- return otfcc_build_chaining_coverage(_subtable);
- }
-}
-
-////// CONTEXTUAL
-
-static caryll_Buffer *otfcc_build_contextual_coverage(const otl_Subtable *_subtable) {
- const subtable_chaining *subtable = &(_subtable->chaining);
- const otl_ChainingRule *rule = (const otl_ChainingRule *)&(subtable->rule);
- tableid_t nInput = rule->inputEnds - rule->inputBegins;
- tableid_t nSubst = rule->applyCount;
- reverseBacktracks(rule);
-
- bk_Block *root = bk_new_Block(b16, 3, // format
- bkover);
-
- bk_push(root, b16, nInput, bkover);
- bk_push(root, b16, nSubst, bkover);
- for (tableid_t j = rule->inputBegins; j < rule->inputEnds; j++) {
- bk_push(root, p16, bk_newBlockFromBuffer(Coverage.build(rule->match[j])), bkover);
- }
- for (tableid_t j = 0; j < nSubst; j++) {
- bk_push(root, b16, rule->apply[j].index, // position
- b16, rule->apply[j].lookup.index, // lookup
- bkover);
- }
-
- return bk_build_Block(root);
-}
-
-static caryll_Buffer *otfcc_build_contextual_classes(const otl_Subtable *_subtable) {
- const subtable_chaining *subtable = &(_subtable->chaining);
-
- otl_Coverage *coverage;
- NEW(coverage);
- coverage->numGlyphs = subtable->ic->numGlyphs;
- coverage->glyphs = subtable->ic->glyphs;
-
- bk_Block *root =
- bk_new_Block(b16, 2, // format
- p16, bk_newBlockFromBuffer(Coverage.build(coverage)), // coverage
- p16, bk_newBlockFromBuffer(ClassDef.build(subtable->ic)), // InputClassDef
- b16, subtable->ic->maxclass + 1, // ChainSubClassSetCnt
- bkover);
-
- glyphclass_t *rcpg;
- NEW(rcpg, subtable->ic->maxclass + 1);
- for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
- rcpg[j] = 0;
- }
- for (tableid_t j = 0; j < subtable->rulesCount; j++) {
- tableid_t ib = subtable->rules[j]->inputBegins;
- tableid_t startClass = subtable->rules[j]->match[ib]->glyphs[0].index;
- if (startClass <= subtable->ic->maxclass) rcpg[startClass] += 1;
- }
-
- for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
- if (rcpg[j]) {
- bk_Block *cset = bk_new_Block(b16, rcpg[j], // ChainSubClassRuleCnt
- bkover);
- for (tableid_t k = 0; k < subtable->rulesCount; k++) {
- otl_ChainingRule *rule = subtable->rules[k];
- glyphclass_t startClass = rule->match[rule->inputBegins]->glyphs[0].index;
- if (startClass != j) { continue; }
- reverseBacktracks(rule);
- tableid_t nInput = rule->inputEnds - rule->inputBegins;
- tableid_t nSubst = rule->applyCount;
- bk_Block *r = bk_new_Block(bkover);
-
- bk_push(r, b16, nInput, bkover);
- bk_push(r, b16, nSubst, bkover);
- for (tableid_t m = rule->inputBegins + 1; m < rule->inputEnds; m++) {
- bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
- }
-
- for (tableid_t m = 0; m < nSubst; m++) {
- bk_push(r, b16, rule->apply[m].index, // position
- b16, rule->apply[m].lookup.index, // lookup index
- bkover);
- }
- bk_push(cset, p16, r, bkover);
- }
- bk_push(root, p16, cset, bkover);
- } else {
- bk_push(root, p16, NULL, bkover);
- }
- }
-
- FREE(coverage);
- FREE(rcpg);
- return bk_build_Block(root);
-}
-
-caryll_Buffer *otfcc_build_contextual(const otl_Subtable *_subtable) {
- if (_subtable->chaining.type == otl_chaining_classified) {
- return otfcc_build_contextual_classes(_subtable);
- } else {
- return otfcc_build_contextual_coverage(_subtable);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/classifier.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/classifier.c
deleted file mode 100644
index a5c904b693e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/classifier.c
+++ /dev/null
@@ -1,238 +0,0 @@
-#include "../chaining.h"
-
-// Chaining substitution classifier
-// We will merge similar subtables.
-
-typedef struct {
- int gid;
- sds gname;
- int cls;
- UT_hash_handle hh;
-} classifier_hash;
-static int by_gid_clsh(classifier_hash *a, classifier_hash *b) {
- return a->gid - b->gid;
-}
-
-static int classCompatible(classifier_hash **h, otl_Coverage *cov, int *past) {
- // checks whether a coverage is compatible to a class hash.
- classifier_hash *s = NULL;
- if (cov->numGlyphs == 0) return 1;
- int gid = cov->glyphs[0].index;
- // check pass
- HASH_FIND_INT(*h, &gid, s);
- if (s) {
- // the coverage has been defined into a class
- classifier_hash *ss, *tmp;
- for (glyphid_t j = 1; j < cov->numGlyphs; j++) {
- int gid = cov->glyphs[j].index;
- HASH_FIND_INT(*h, &gid, ss);
- if (!ss || ss->cls != s->cls) return 0;
- }
- // reverse check: all glyphs classified are there in the coverage
- classifier_hash *revh = NULL;
- for (glyphid_t j = 0; j < cov->numGlyphs; j++) {
- int gid = cov->glyphs[j].index;
- classifier_hash *rss = NULL;
- HASH_FIND_INT(revh, &gid, rss);
- if (!rss) {
- NEW(rss);
- rss->gid = gid;
- rss->gname = cov->glyphs[j].name;
- rss->cls = s->cls;
- HASH_ADD_INT(revh, gid, rss);
- }
- }
-
- bool allcheck = true;
- foreach_hash(ss, *h) if (ss->cls == s->cls) {
- int gid = ss->gid;
- classifier_hash *rss;
- HASH_FIND_INT(revh, &gid, rss);
- if (!rss) {
- allcheck = false;
- break;
- }
- }
- HASH_ITER(hh, revh, ss, tmp) {
- HASH_DEL(revh, ss);
- FREE(ss);
- }
- return allcheck ? s->cls : 0;
- } else {
- // the coverage is not defined into a class.
- classifier_hash *ss;
- for (glyphid_t j = 1; j < cov->numGlyphs; j++) {
- int gid = cov->glyphs[j].index;
- HASH_FIND_INT(*h, &gid, ss);
- if (ss) return 0;
- }
- for (glyphid_t j = 0; j < cov->numGlyphs; j++) {
- int gid = cov->glyphs[j].index;
- classifier_hash *s = NULL;
- HASH_FIND_INT(*h, &gid, s);
- if (!s) {
- NEW(s);
- s->gid = cov->glyphs[j].index;
- s->gname = cov->glyphs[j].name;
- s->cls = *past + 1;
- HASH_ADD_INT(*h, gid, s);
- }
- }
- *past += 1;
- return 1;
- }
-}
-static otl_ChainingRule *buildRule(otl_ChainingRule *rule, classifier_hash *hb, classifier_hash *hi,
- classifier_hash *hf) {
- otl_ChainingRule *newRule;
- NEW(newRule);
- newRule->matchCount = rule->matchCount;
- newRule->inputBegins = rule->inputBegins;
- newRule->inputEnds = rule->inputEnds;
- NEW(newRule->match, newRule->matchCount);
- for (tableid_t m = 0; m < rule->matchCount; m++) {
- NEW(newRule->match[m]);
- newRule->match[m]->numGlyphs = 1;
- NEW(newRule->match[m]->glyphs);
- if (rule->match[m]->numGlyphs > 0) {
- classifier_hash *h = (m < rule->inputBegins ? hb : m < rule->inputEnds ? hi : hf);
- classifier_hash *s;
- int gid = rule->match[m]->glyphs[0].index;
- HASH_FIND_INT(h, &gid, s);
- newRule->match[m]->glyphs[0] = Handle.fromIndex(s->cls);
- } else {
- newRule->match[m]->glyphs[0] = Handle.fromIndex(0);
- }
- }
- newRule->applyCount = rule->applyCount;
- NEW(newRule->apply, newRule->applyCount);
- for (tableid_t j = 0; j < rule->applyCount; j++) {
- newRule->apply[j].index = rule->apply[j].index;
- newRule->apply[j].lookup = Handle.dup(rule->apply[j].lookup);
- }
- return newRule;
-}
-static otl_ClassDef *toClass(classifier_hash **h) {
- otl_ClassDef *cd = ClassDef.create();
- classifier_hash *item;
- HASH_SORT(*h, by_gid_clsh);
- foreach_hash(item, *h) {
- ClassDef.push(cd, Handle.fromConsolidated(item->gid, item->gname), item->cls);
- }
- return cd;
-}
-static tableid_t tryClassifyAround(const otl_Lookup *lookup, tableid_t j,
- OUT subtable_chaining **classifiedST) {
- tableid_t compatibleCount = 0;
- classifier_hash *hb = NULL;
- classifier_hash *hi = NULL;
- classifier_hash *hf = NULL;
- // initialize the class hash
- subtable_chaining *subtable0 = &(lookup->subtables.items[j]->chaining);
- int classno_b = 0;
- int classno_i = 0;
- int classno_f = 0;
-
- otl_ChainingRule *rule0 = &subtable0->rule;
- for (tableid_t m = 0; m < rule0->matchCount; m++) {
- int check = 0;
- if (m < rule0->inputBegins) {
- check = classCompatible(&hb, rule0->match[m], &classno_b);
- } else if (m < rule0->inputEnds) {
- check = classCompatible(&hi, rule0->match[m], &classno_i);
- } else {
- check = classCompatible(&hf, rule0->match[m], &classno_f);
- }
- if (!check) { goto FAIL; }
- }
- for (tableid_t k = j + 1; k < lookup->subtables.length; k++) {
- otl_ChainingRule *rule = &lookup->subtables.items[k]->chaining.rule;
- bool allcheck = true;
- for (tableid_t m = 0; m < rule->matchCount; m++) {
- int check = 0;
- if (m < rule->inputBegins) {
- check = classCompatible(&hb, rule->match[m], &classno_b);
- } else if (m < rule->inputEnds) {
- check = classCompatible(&hi, rule->match[m], &classno_i);
- } else {
- check = classCompatible(&hf, rule->match[m], &classno_f);
- }
- if (!check) {
- allcheck = false;
- goto endcheck;
- }
- }
- if (allcheck) { compatibleCount += 1; }
- }
-endcheck:
- if (compatibleCount > 1) {
- // We've found multiple compatible subtables;
- NEW(subtable0);
- subtable0->rulesCount = compatibleCount + 1;
- NEW(subtable0->rules, compatibleCount + 1);
-
- subtable0->rules[0] = buildRule(rule0, hb, hi, hf);
- // write other rules
- tableid_t kk = 1;
- for (tableid_t k = j + 1; k < lookup->subtables.length && kk < compatibleCount + 1; k++) {
- otl_ChainingRule *rule = &lookup->subtables.items[k]->chaining.rule;
- subtable0->rules[kk] = buildRule(rule, hb, hi, hf);
- kk++;
- }
-
- subtable0->type = otl_chaining_classified;
- subtable0->bc = toClass(&hb);
- subtable0->ic = toClass(&hi);
- subtable0->fc = toClass(&hf);
- *classifiedST = subtable0;
- }
-FAIL:;
- if (hb) {
- classifier_hash *s, *tmp;
- HASH_ITER(hh, hb, s, tmp) {
- HASH_DEL(hb, s);
- FREE(s);
- }
- }
- if (hi) {
- classifier_hash *s, *tmp;
- HASH_ITER(hh, hi, s, tmp) {
- HASH_DEL(hi, s);
- FREE(s);
- }
- }
- if (hf) {
- classifier_hash *s, *tmp;
- HASH_ITER(hh, hf, s, tmp) {
- HASH_DEL(hf, s);
- FREE(s);
- }
- }
-
- if (compatibleCount > 1) {
- return compatibleCount;
- } else {
- return 0;
- }
-}
-tableid_t otfcc_classifiedBuildChaining(const otl_Lookup *lookup,
- OUT caryll_Buffer ***subtableBuffers,
- MODIFY size_t *lastOffset) {
- bool isContextual = otfcc_chainingLookupIsContextualLookup(lookup);
- tableid_t subtablesWritten = 0;
- NEW(*subtableBuffers, lookup->subtables.length);
- for (tableid_t j = 0; j < lookup->subtables.length; j++) {
- subtable_chaining *st0 = &(lookup->subtables.items[j]->chaining);
- if (st0->type) continue;
- subtable_chaining *st = st0;
- // Try to classify subtables after j into j
- j += tryClassifyAround(lookup, j, &st);
- caryll_Buffer *buf = isContextual ? otfcc_build_contextual((otl_Subtable *)st)
- : otfcc_build_chaining((otl_Subtable *)st);
- if (st != st0) { iSubtable_chaining.free(st); }
- (*subtableBuffers)[subtablesWritten] = buf;
- *lastOffset += buf->size;
- subtablesWritten += 1;
- }
- return subtablesWritten;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.c
deleted file mode 100644
index c670a1dcbca..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "../chaining.h"
-#include "common.h"
-static void otl_init_chaining(subtable_chaining *subtable) {
- memset(subtable, 0, sizeof(*subtable));
-}
-static void otl_dispose_chaining(subtable_chaining *subtable) {
- if (subtable->type) {
- if (subtable->rules) {
- for (tableid_t j = 0; j < subtable->rulesCount; j++) {
- deleteRule(subtable->rules[j]);
- }
- FREE(subtable->rules);
- }
- if (subtable->bc) { ClassDef.free(subtable->bc); }
- if (subtable->ic) { ClassDef.free(subtable->ic); }
- if (subtable->fc) { ClassDef.free(subtable->fc); }
- } else {
- closeRule(&subtable->rule);
- }
-}
-
-caryll_standardRefType(subtable_chaining, iSubtable_chaining, otl_init_chaining,
- otl_dispose_chaining);
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.h
deleted file mode 100644
index db8cf92898e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/common.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "../chaining.h"
-
-static INLINE void closeRule(otl_ChainingRule *rule) {
- if (rule && rule->match && rule->matchCount) {
- for (tableid_t k = 0; k < rule->matchCount; k++) {
- Coverage.free(rule->match[k]);
- }
- FREE(rule->match);
- }
- if (rule && rule->apply) {
- for (tableid_t j = 0; j < rule->applyCount; j++) {
- Handle.dispose(&rule->apply[j].lookup);
- }
- FREE(rule->apply);
- }
-}
-static INLINE void deleteRule(otl_ChainingRule *rule) {
- if (!rule) return;
- closeRule(rule);
- FREE(rule);
-}
-static INLINE void reverseBacktracks(otl_ChainingRule *rule) {
- if (rule->inputBegins > 0) {
- tableid_t start = 0;
- tableid_t end = rule->inputBegins - 1;
- while (end > start) {
- otl_Coverage *tmp = rule->match[start];
- rule->match[start] = rule->match[end];
- rule->match[end] = tmp;
- end--, start++;
- }
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/dump.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/dump.c
deleted file mode 100644
index 31332ca8a5e..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/dump.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "../chaining.h"
-
-json_value *otl_dump_chaining(const otl_Subtable *_subtable) {
- const subtable_chaining *subtable = &(_subtable->chaining);
- if (subtable->type) return json_null_new();
- const otl_ChainingRule *rule = &(subtable->rule);
- json_value *_st = json_object_new(4);
-
- json_value *_match = json_array_new(rule->matchCount);
- for (tableid_t j = 0; j < rule->matchCount; j++) {
- json_array_push(_match, Coverage.dump(rule->match[j]));
- }
- json_object_push(_st, "match", _match);
-
- json_value *_apply = json_array_new(rule->applyCount);
- for (tableid_t j = 0; j < rule->applyCount; j++) {
- json_value *_application = json_object_new(2);
- json_object_push(_application, "at", json_integer_new(rule->apply[j].index));
- json_object_push(_application, "lookup", json_string_new(rule->apply[j].lookup.name));
- json_array_push(_apply, _application);
- }
- json_object_push(_st, "apply", preserialize(_apply));
-
- json_object_push(_st, "inputBegins", json_integer_new(rule->inputBegins));
- json_object_push(_st, "inputEnds", json_integer_new(rule->inputEnds));
- return _st;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/parse.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/parse.c
deleted file mode 100644
index 7a2c1e2d24b..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/parse.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "../chaining.h"
-
-otl_Subtable *otl_parse_chaining(const json_value *_subtable, const otfcc_Options *options) {
- json_value *_match = json_obj_get_type(_subtable, "match", json_array);
- json_value *_apply = json_obj_get_type(_subtable, "apply", json_array);
- if (!_match || !_apply) return NULL;
-
- subtable_chaining *subtable = iSubtable_chaining.create();
- subtable->type = otl_chaining_canonical;
-
- otl_ChainingRule *rule = &subtable->rule;
-
- rule->matchCount = _match->u.array.length;
- NEW(rule->match, rule->matchCount);
- rule->applyCount = _apply->u.array.length;
- NEW(rule->apply, rule->applyCount);
-
- rule->inputBegins = json_obj_getnum_fallback(_subtable, "inputBegins", 0);
- rule->inputEnds = json_obj_getnum_fallback(_subtable, "inputEnds", rule->matchCount);
-
- for (tableid_t j = 0; j < rule->matchCount; j++) {
- rule->match[j] = Coverage.parse(_match->u.array.values[j]);
- }
- for (tableid_t j = 0; j < rule->applyCount; j++) {
- rule->apply[j].index = 0;
- rule->apply[j].lookup = Handle.empty();
- json_value *_application = _apply->u.array.values[j];
- if (_application->type == json_object) {
- json_value *_ln = json_obj_get_type(_application, "lookup", json_string);
- if (_ln) {
- rule->apply[j].lookup = Handle.fromName(sdsnewlen(_ln->u.string.ptr, _ln->u.string.length));
- rule->apply[j].index = json_obj_getnum(_application, "at");
- }
- }
- }
- return (otl_Subtable *)subtable;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/read.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/read.c
deleted file mode 100644
index 0059efeaec9..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/read.c
+++ /dev/null
@@ -1,416 +0,0 @@
-#include "../chaining.h"
-#include "common.h"
-
-typedef struct {
- otl_ClassDef *bc;
- otl_ClassDef *ic;
- otl_ClassDef *fc;
-} classdefs;
-
-static otl_Coverage *singleCoverage(font_file_pointer data, uint32_t tableLength, uint16_t gid,
- uint32_t _offset, uint16_t kind, const glyphid_t maxGlyphs,
- void *userdata) {
- otl_Coverage *cov;
- NEW(cov);
- cov->numGlyphs = 1;
- NEW(cov->glyphs);
- cov->glyphs[0] = Handle.fromIndex((glyphid_t)gid);
- return cov;
-}
-static otl_Coverage *classCoverage(font_file_pointer data, uint32_t tableLength, uint16_t cls,
- uint32_t _offset, uint16_t kind, const glyphid_t maxGlyphs,
- void *_classdefs) {
- classdefs *defs = (classdefs *)_classdefs;
- otl_ClassDef *cd = (kind == 1 ? defs->bc : kind == 2 ? defs->ic : defs->fc);
- otl_Coverage *cov;
- NEW(cov);
- cov->numGlyphs = 0;
- cov->glyphs = NULL;
- glyphid_t count = 0;
- if (cls == 0) {
- for (glyphid_t k = 0; k < maxGlyphs; k++) {
- bool found = false;
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- if (cd->classes[j] > 0 && cd->glyphs[j].index == k) {
- found = true;
- break;
- }
- }
- if (!found) count += 1;
- }
- } else {
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- if (cd->classes[j] == cls) count++;
- }
- }
- if (!count) return cov;
-
- cov->numGlyphs = count;
- NEW(cov->glyphs, count);
- glyphid_t jj = 0;
- if (cls == 0) {
- for (glyphid_t k = 0; k < maxGlyphs; k++) {
- bool found = false;
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- if (cd->classes[j] > 0 && cd->glyphs[j].index == k) {
- found = true;
- break;
- }
- }
- if (!found) cov->glyphs[jj++] = Handle.fromIndex(k);
- }
- } else {
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- if (cd->classes[j] == cls) { cov->glyphs[jj++] = Handle.dup(cd->glyphs[j]); }
- }
- }
- return cov;
-}
-static otl_Coverage *format3Coverage(font_file_pointer data, uint32_t tableLength, uint16_t shift,
- uint32_t _offset, uint16_t kind, const glyphid_t maxGlyphs,
- void *userdata) {
- return Coverage.read(data, tableLength, _offset + shift - 2);
-}
-
-typedef otl_Coverage *(*CoverageReaderHandler)(font_file_pointer, uint32_t, uint16_t, uint32_t,
- uint16_t, glyphid_t, void *);
-
-static otl_ChainingRule *GeneralReadContextualRule(font_file_pointer data, uint32_t tableLength,
- uint32_t offset, uint16_t startGID, bool minusOne,
- CoverageReaderHandler fn, const glyphid_t maxGlyphs,
- void *userdata) {
- otl_ChainingRule *rule;
- NEW(rule);
- rule->match = NULL;
- rule->apply = NULL;
-
- uint16_t minusOneQ = (minusOne ? 1 : 0);
-
- checkLength(offset + 4);
- uint16_t nInput = read_16u(data + offset);
- uint16_t nApply = read_16u(data + offset + 2);
- checkLength(offset + 4 + 2 * nInput + 4 * nApply);
-
- rule->matchCount = nInput;
- rule->inputBegins = 0;
- rule->inputEnds = nInput;
-
- NEW(rule->match, rule->matchCount);
- uint16_t jj = 0;
- if (minusOne) {
- rule->match[jj++] = fn(data, tableLength, startGID, offset, 2, maxGlyphs, userdata);
- }
- for (uint16_t j = 0; j < nInput - minusOneQ; j++) {
- uint32_t gid = read_16u(data + offset + 4 + j * 2);
- rule->match[jj++] = fn(data, tableLength, gid, offset, 2, maxGlyphs, userdata);
- }
- rule->applyCount = nApply;
- NEW(rule->apply, rule->applyCount);
- for (tableid_t j = 0; j < nApply; j++) {
- rule->apply[j].index =
- rule->inputBegins +
- read_16u(data + offset + 4 + 2 * (rule->matchCount - minusOneQ) + j * 4);
- rule->apply[j].lookup = Handle.fromIndex(
- read_16u(data + offset + 4 + 2 * (rule->matchCount - minusOneQ) + j * 4 + 2));
- }
- reverseBacktracks(rule);
- return rule;
-
-FAIL:
- DELETE(deleteRule, rule);
- return NULL;
-}
-static subtable_chaining *readContextualFormat1(subtable_chaining *subtable,
- const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs) {
- // Contextual Substitution Subtable, Simple.
- checkLength(offset + 6);
-
- uint16_t covOffset = offset + read_16u(data + offset + 2);
- otl_Coverage *firstCoverage = Coverage.read(data, tableLength, covOffset);
-
- tableid_t chainSubRuleSetCount = read_16u(data + offset + 4);
- if (chainSubRuleSetCount != firstCoverage->numGlyphs) goto FAIL;
- checkLength(offset + 6 + 2 * chainSubRuleSetCount);
-
- tableid_t totalRules = 0;
- for (tableid_t j = 0; j < chainSubRuleSetCount; j++) {
- uint32_t srsOffset = offset + read_16u(data + offset + 6 + j * 2);
- checkLength(srsOffset + 2);
- totalRules += read_16u(data + srsOffset);
- checkLength(srsOffset + 2 + 2 * read_16u(data + srsOffset));
- }
- subtable->rulesCount = totalRules;
- NEW(subtable->rules, totalRules);
-
- tableid_t jj = 0;
- for (tableid_t j = 0; j < chainSubRuleSetCount; j++) {
- uint32_t srsOffset = offset + read_16u(data + offset + 6 + j * 2);
- tableid_t srsCount = read_16u(data + srsOffset);
- for (tableid_t k = 0; k < srsCount; k++) {
- uint32_t srOffset = srsOffset + read_16u(data + srsOffset + 2 + k * 2);
- subtable->rules[jj] = GeneralReadContextualRule(data, tableLength, srOffset,
- firstCoverage->glyphs[j].index, true,
- singleCoverage, maxGlyphs, NULL);
- jj += 1;
- }
- }
-
- Coverage.free(firstCoverage);
- return subtable;
-FAIL:
- iSubtable_chaining.free(subtable);
- return NULL;
-}
-static subtable_chaining *readContextualFormat2(subtable_chaining *subtable,
- const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs) {
- // Contextual Substitution Subtable, Class based.
- checkLength(offset + 8);
-
- classdefs *cds;
- NEW(cds);
- cds->bc = NULL;
- cds->ic = ClassDef.read(data, tableLength, offset + read_16u(data + offset + 4));
- cds->fc = NULL;
-
- tableid_t chainSubClassSetCnt = read_16u(data + offset + 6);
- checkLength(offset + 12 + 2 * chainSubClassSetCnt);
-
- tableid_t totalRules = 0;
- for (tableid_t j = 0; j < chainSubClassSetCnt; j++) {
- uint32_t srcOffset = read_16u(data + offset + 8 + j * 2);
- if (srcOffset) { totalRules += read_16u(data + offset + srcOffset); }
- }
- subtable->rulesCount = totalRules;
- NEW(subtable->rules, totalRules);
-
- tableid_t jj = 0;
- for (tableid_t j = 0; j < chainSubClassSetCnt; j++) {
- uint32_t srcOffset = read_16u(data + offset + 8 + j * 2);
- if (srcOffset) {
- tableid_t srsCount = read_16u(data + offset + srcOffset);
- for (tableid_t k = 0; k < srsCount; k++) {
- uint32_t srOffset =
- offset + srcOffset + read_16u(data + offset + srcOffset + 2 + k * 2);
- subtable->rules[jj] = GeneralReadContextualRule(
- data, tableLength, srOffset, j, true, classCoverage, maxGlyphs, cds);
- jj += 1;
- }
- }
- }
- if (cds) {
- if (cds->bc) ClassDef.free(cds->bc);
- if (cds->ic) ClassDef.free(cds->ic);
- if (cds->fc) ClassDef.free(cds->fc);
- FREE(cds);
- }
- return subtable;
-FAIL:
- iSubtable_chaining.free(subtable);
- return NULL;
-}
-otl_Subtable *otl_read_contextual(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- uint16_t format = 0;
- subtable_chaining *subtable = iSubtable_chaining.create();
- subtable->type = otl_chaining_poly;
-
- checkLength(offset + 2);
- format = read_16u(data + offset);
- if (format == 1) {
- return (otl_Subtable *)readContextualFormat1(subtable, data, tableLength, offset,
- maxGlyphs);
- } else if (format == 2) {
- return (otl_Subtable *)readContextualFormat2(subtable, data, tableLength, offset,
- maxGlyphs);
- } else if (format == 3) {
- // Contextual Substitution Subtable, Coverage based.
- subtable->rulesCount = 1;
- NEW(subtable->rules, 1);
- subtable->rules[0] = GeneralReadContextualRule(data, tableLength, offset + 2, 0, false,
- format3Coverage, maxGlyphs, NULL);
- return (otl_Subtable *)subtable;
- }
-FAIL:
- logWarning("Unsupported format %d.\n", format);
- iSubtable_chaining.free(subtable);
- return NULL;
-}
-
-static otl_ChainingRule *GeneralReadChainingRule(font_file_pointer data, uint32_t tableLength,
- uint32_t offset, uint16_t startGID, bool minusOne,
- CoverageReaderHandler fn, const glyphid_t maxGlyphs,
- void *userdata) {
- otl_ChainingRule *rule;
- NEW(rule);
- rule->match = NULL;
- rule->apply = NULL;
-
- uint16_t minusOneQ = (minusOne ? 1 : 0);
-
- checkLength(offset + 8);
- tableid_t nBack = read_16u(data + offset);
- checkLength(offset + 2 + 2 * nBack + 2);
- tableid_t nInput = read_16u(data + offset + 2 + 2 * nBack);
- checkLength(offset + 4 + 2 * (nBack + nInput - minusOneQ) + 2);
- tableid_t nLookaround = read_16u(data + offset + 4 + 2 * (nBack + nInput - minusOneQ));
- checkLength(offset + 6 + 2 * (nBack + nInput - minusOneQ + nLookaround) + 2);
- tableid_t nApply = read_16u(data + offset + 6 + 2 * (nBack + nInput - minusOneQ + nLookaround));
- checkLength(offset + 8 + 2 * (nBack + nInput - minusOneQ + nLookaround) + nApply * 4);
-
- rule->matchCount = nBack + nInput + nLookaround;
- rule->inputBegins = nBack;
- rule->inputEnds = nBack + nInput;
-
- NEW(rule->match, rule->matchCount);
- tableid_t jj = 0;
- for (tableid_t j = 0; j < nBack; j++) {
- uint32_t gid = read_16u(data + offset + 2 + j * 2);
- rule->match[jj++] = fn(data, tableLength, gid, offset, 1, maxGlyphs, userdata);
- }
- if (minusOne) {
- rule->match[jj++] = fn(data, tableLength, startGID, offset, 2, maxGlyphs, userdata);
- }
- for (tableid_t j = 0; j < nInput - minusOneQ; j++) {
- uint32_t gid = read_16u(data + offset + 4 + 2 * rule->inputBegins + j * 2);
- rule->match[jj++] = fn(data, tableLength, gid, offset, 2, maxGlyphs, userdata);
- }
- for (tableid_t j = 0; j < nLookaround; j++) {
- uint32_t gid = read_16u(data + offset + 6 + 2 * (rule->inputEnds - minusOneQ) + j * 2);
- rule->match[jj++] = fn(data, tableLength, gid, offset, 3, maxGlyphs, userdata);
- }
- rule->applyCount = nApply;
- NEW(rule->apply, rule->applyCount);
- for (tableid_t j = 0; j < nApply; j++) {
- rule->apply[j].index =
- rule->inputBegins +
- read_16u(data + offset + 8 + 2 * (rule->matchCount - minusOneQ) + j * 4);
- rule->apply[j].lookup = Handle.fromIndex(
- read_16u(data + offset + 8 + 2 * (rule->matchCount - minusOneQ) + j * 4 + 2));
- }
- reverseBacktracks(rule);
- return rule;
-
-FAIL:
- DELETE(deleteRule, rule);
- return NULL;
-}
-static subtable_chaining *readChainingFormat1(subtable_chaining *subtable,
- const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs) {
- // Contextual Substitution Subtable, Simple.
- checkLength(offset + 6);
-
- uint16_t covOffset = offset + read_16u(data + offset + 2);
- otl_Coverage *firstCoverage = Coverage.read(data, tableLength, covOffset);
-
- tableid_t chainSubRuleSetCount = read_16u(data + offset + 4);
- if (chainSubRuleSetCount != firstCoverage->numGlyphs) goto FAIL;
- checkLength(offset + 6 + 2 * chainSubRuleSetCount);
-
- tableid_t totalRules = 0;
- for (tableid_t j = 0; j < chainSubRuleSetCount; j++) {
- uint32_t srsOffset = offset + read_16u(data + offset + 6 + j * 2);
- checkLength(srsOffset + 2);
- totalRules += read_16u(data + srsOffset);
- checkLength(srsOffset + 2 + 2 * read_16u(data + srsOffset));
- }
- subtable->rulesCount = totalRules;
- NEW(subtable->rules, totalRules);
-
- tableid_t jj = 0;
- for (tableid_t j = 0; j < chainSubRuleSetCount; j++) {
- uint32_t srsOffset = offset + read_16u(data + offset + 6 + j * 2);
- tableid_t srsCount = read_16u(data + srsOffset);
- for (tableid_t k = 0; k < srsCount; k++) {
- uint32_t srOffset = srsOffset + read_16u(data + srsOffset + 2 + k * 2);
- subtable->rules[jj] =
- GeneralReadChainingRule(data, tableLength, srOffset, firstCoverage->glyphs[j].index,
- true, singleCoverage, maxGlyphs, NULL);
- jj += 1;
- }
- }
-
- Coverage.free(firstCoverage);
- return subtable;
-FAIL:
- iSubtable_chaining.free(subtable);
- return NULL;
-}
-static subtable_chaining *readChainingFormat2(subtable_chaining *subtable,
- const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs) {
- // Chaining Contextual Substitution Subtable, Class based.
- checkLength(offset + 12);
-
- classdefs *cds;
- NEW(cds);
- cds->bc = ClassDef.read(data, tableLength, offset + read_16u(data + offset + 4));
- cds->ic = ClassDef.read(data, tableLength, offset + read_16u(data + offset + 6));
- cds->fc = ClassDef.read(data, tableLength, offset + read_16u(data + offset + 8));
-
- tableid_t chainSubClassSetCnt = read_16u(data + offset + 10);
- checkLength(offset + 12 + 2 * chainSubClassSetCnt);
-
- tableid_t totalRules = 0;
- for (tableid_t j = 0; j < chainSubClassSetCnt; j++) {
- uint32_t srcOffset = read_16u(data + offset + 12 + j * 2);
- if (srcOffset) { totalRules += read_16u(data + offset + srcOffset); }
- }
- subtable->rulesCount = totalRules;
- NEW(subtable->rules, totalRules);
-
- tableid_t jj = 0;
- for (tableid_t j = 0; j < chainSubClassSetCnt; j++) {
- uint32_t srcOffset = read_16u(data + offset + 12 + j * 2);
- if (srcOffset) {
- tableid_t srsCount = read_16u(data + offset + srcOffset);
- for (tableid_t k = 0; k < srsCount; k++) {
- uint32_t dsrOffset = read_16u(data + offset + srcOffset + 2 + k * 2);
- uint32_t srOffset = offset + srcOffset + dsrOffset;
- subtable->rules[jj] = GeneralReadChainingRule(data, tableLength, srOffset, j, true,
- classCoverage, maxGlyphs, cds);
- jj += 1;
- }
- }
- }
-
- if (cds) {
- if (cds->bc) ClassDef.free(cds->bc);
- if (cds->ic) ClassDef.free(cds->ic);
- if (cds->fc) ClassDef.free(cds->fc);
- FREE(cds);
- }
- return subtable;
-FAIL:
- iSubtable_chaining.free(subtable);
- return NULL;
-}
-otl_Subtable *otl_read_chaining(const font_file_pointer data, uint32_t tableLength, uint32_t offset,
- const glyphid_t maxGlyphs, const otfcc_Options *options) {
- uint16_t format = 0;
- subtable_chaining *subtable = iSubtable_chaining.create();
- subtable->type = otl_chaining_poly;
-
- checkLength(offset + 2);
- format = read_16u(data + offset);
- if (format == 1) {
- return (otl_Subtable *)readChainingFormat1(subtable, data, tableLength, offset, maxGlyphs);
- } else if (format == 2) {
- return (otl_Subtable *)readChainingFormat2(subtable, data, tableLength, offset, maxGlyphs);
- } else if (format == 3) {
- // Chaining Contextual Substitution Subtable, Coverage based.
- // This table has exactly one rule within it, and i love it.
- subtable->rulesCount = 1;
- NEW(subtable->rules, 1);
- subtable->rules[0] = GeneralReadChainingRule(data, tableLength, offset + 2, 0, false,
- format3Coverage, maxGlyphs, NULL);
- return (otl_Subtable *)subtable;
- }
-FAIL:
- logWarning("Unsupported format %d.\n", format);
- iSubtable_chaining.free(subtable);
- return NULL;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/common.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/common.h
deleted file mode 100644
index 3fa1736e759..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/common.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_SUBTABLES_COMMON_H
-#define CARYLL_TABLE_OTL_SUBTABLES_COMMON_H
-
-#include "support/util.h"
-#include "bk/bkgraph.h"
-#include "../../otl.h"
-
-typedef enum {
- OTL_BH_NORMAL = 0,
- OTL_BH_GSUB_VERT = 1
-} otl_BuildHeuristics;
-
-#define checkLength(offset) if (tableLength < offset) { goto FAIL; }
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.c
deleted file mode 100644
index 4b64449d0b4..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "extend.h"
-
-// Extended tables are special
-// We will only deal with reading, and they will be flatten.
-static otl_Subtable *_caryll_read_otl_extend(font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, otl_LookupType BASIS,
- const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- otl_Subtable *_subtable;
- NEW(_subtable);
- checkLength(subtableOffset + 8);
- subtable_extend *subtable = &(_subtable->extend);
- subtable->type = read_16u(data + subtableOffset + 2) + BASIS;
- subtable->subtable = otfcc_readOtl_subtable(
- data, tableLength, subtableOffset + read_32u(data + subtableOffset + 4), subtable->type,
- maxGlyphs, options);
- goto OK;
-FAIL:
- FREE(_subtable);
-OK:
- return _subtable;
-}
-
-otl_Subtable *otfcc_readOtl_gsub_extend(font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- return _caryll_read_otl_extend(data, tableLength, subtableOffset, otl_type_gsub_unknown,
- maxGlyphs, options);
-}
-otl_Subtable *otfcc_readOtl_gpos_extend(font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- return _caryll_read_otl_extend(data, tableLength, subtableOffset, otl_type_gpos_unknown,
- maxGlyphs, options);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.h
deleted file mode 100644
index 8ac3719a60c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/extend.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_EXTEND_H
-#define CARYLL_TABLE_OTL_EXTEND_H
-
-#include "common.h"
-
-otl_Subtable *otfcc_readOtl_gsub_extend(font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-otl_Subtable *otfcc_readOtl_gpos_extend(font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.c
deleted file mode 100644
index 3c99772ee32..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.c
+++ /dev/null
@@ -1,214 +0,0 @@
-#include "gpos-common.h"
-
-static void deleteMarkArrayItem(otl_MarkRecord *entry) {
- Handle.dispose(&entry->glyph);
-}
-static caryll_ElementInterface(otl_MarkRecord) gss_typeinfo = {
- .init = NULL, .copy = NULL, .dispose = deleteMarkArrayItem};
-
-caryll_standardVectorImpl(otl_MarkArray, otl_MarkRecord, gss_typeinfo, otl_iMarkArray);
-
-void otl_readMarkArray(otl_MarkArray *array, otl_Coverage *cov, font_file_pointer data,
- uint32_t tableLength, uint32_t offset) {
- checkLength(offset + 2);
- glyphid_t markCount = read_16u(data + offset);
- for (glyphid_t j = 0; j < markCount; j++) {
- glyphclass_t markClass = read_16u(data + offset + 2 + j * 4);
- uint16_t delta = read_16u(data + offset + 2 + j * 4 + 2);
- if (delta) {
- otl_iMarkArray.push(
- array,
- ((otl_MarkRecord){.glyph = Handle.dup(cov->glyphs[j]),
- .markClass = markClass,
- .anchor = otl_read_anchor(data, tableLength, offset + delta)}));
- } else {
- otl_iMarkArray.push(array, ((otl_MarkRecord){.glyph = Handle.dup(cov->glyphs[j]),
- .markClass = markClass,
- .anchor = otl_anchor_absent()}));
- }
- }
-FAIL:
- return;
-}
-
-static int compare_classHash(otl_ClassnameHash *a, otl_ClassnameHash *b) {
- return strcmp(a->className, b->className);
-}
-void otl_parseMarkArray(json_value *_marks, otl_MarkArray *array, otl_ClassnameHash **h,
- const otfcc_Options *options) {
- for (glyphid_t j = 0; j < _marks->u.object.length; j++) {
- otl_MarkRecord mark;
- char *gname = _marks->u.object.values[j].name;
- json_value *anchorRecord = _marks->u.object.values[j].value;
- mark.glyph = Handle.fromName(sdsnewlen(gname, _marks->u.object.values[j].name_length));
- mark.markClass = 0;
- mark.anchor = otl_anchor_absent();
-
- if (!anchorRecord || anchorRecord->type != json_object) {
- otl_iMarkArray.push(array, mark);
- continue;
- }
- json_value *_className = json_obj_get_type(anchorRecord, "class", json_string);
- if (!_className) {
- otl_iMarkArray.push(array, mark);
- continue;
- }
-
- sds className = sdsnewlen(_className->u.string.ptr, _className->u.string.length);
- otl_ClassnameHash *s;
- HASH_FIND_STR(*h, className, s);
- if (!s) {
- NEW(s);
- s->className = className;
- s->classID = HASH_COUNT(*h);
- HASH_ADD_STR(*h, className, s);
- } else {
- sdsfree(className);
- }
- mark.markClass = s->classID;
- mark.anchor.present = true;
- mark.anchor.x = json_obj_getnum(anchorRecord, "x");
- mark.anchor.y = json_obj_getnum(anchorRecord, "y");
- otl_iMarkArray.push(array, mark);
- }
-
- HASH_SORT(*h, compare_classHash);
- glyphid_t jAnchorIndex = 0;
- otl_ClassnameHash *s;
- foreach_hash(s, *h) {
- s->classID = jAnchorIndex;
- jAnchorIndex++;
- }
- for (glyphid_t j = 0; j < array->length; j++) {
- if (!array->items[j].anchor.present) continue;
- json_value *anchorRecord = _marks->u.object.values[j].value;
- json_value *_className = json_obj_get_type(anchorRecord, "class", json_string);
- sds className = sdsnewlen(_className->u.string.ptr, _className->u.string.length);
- otl_ClassnameHash *s;
- HASH_FIND_STR(*h, className, s);
- if (s) {
- array->items[j].markClass = s->classID;
- } else {
- array->items[j].markClass = 0;
- }
- sdsfree(className);
- }
-}
-
-otl_Anchor otl_anchor_absent() {
- otl_Anchor anchor = {.present = false, .x = 0, .y = 0};
- return anchor;
-}
-otl_Anchor otl_read_anchor(font_file_pointer data, uint32_t tableLength, uint32_t offset) {
- otl_Anchor anchor = {.present = false, .x = 0, .y = 0};
- checkLength(offset + 6);
- anchor.present = true;
- anchor.x = read_16s(data + offset + 2);
- anchor.y = read_16s(data + offset + 4);
- return anchor;
-FAIL:
- anchor.present = false;
- anchor.x = 0;
- anchor.y = 0;
- return anchor;
-}
-json_value *otl_dump_anchor(otl_Anchor a) {
- if (a.present) {
- json_value *v = json_object_new(2);
- json_object_push(v, "x", json_new_position(a.x));
- json_object_push(v, "y", json_new_position(a.y));
- return v;
- } else {
- return json_null_new();
- }
-}
-otl_Anchor otl_parse_anchor(json_value *v) {
- otl_Anchor anchor = {.present = false, .x = 0, .y = 0};
- if (!v || v->type != json_object) return anchor;
- anchor.present = true;
- anchor.x = json_obj_getnum_fallback(v, "x", 0);
- anchor.y = json_obj_getnum_fallback(v, "y", 0);
- return anchor;
-}
-
-bk_Block *bkFromAnchor(otl_Anchor a) {
- if (!a.present) return NULL;
- return bk_new_Block(b16, 1, // format
- b16, (int16_t)a.x, // x
- b16, (int16_t)a.y, // y
- bkover);
-}
-
-// GPOS position value constants
-const uint8_t FORMAT_DX = 1;
-const uint8_t FORMAT_DY = 2;
-const uint8_t FORMAT_DWIDTH = 4;
-const uint8_t FORMAT_DHEIGHT = 8;
-
-#define a(n) n + 0, n + 1, n + 1, n + 2 // 2 bits
-#define b(n) a(n + 0), a(n + 1), a(n + 1), a(n + 2) // 4 bits
-#define c(n) b(n + 0), b(n + 1), b(n + 1), b(n + 2) // 6 bits
-#define d(n) c(n + 0), c(n + 1), c(n + 1), c(n + 2) // 8 bits
-const uint8_t bits_in[0x100] = {d(0)};
-#undef d
-#undef c
-#undef b
-#undef a
-
-// Length of a position value in bytes
-uint8_t position_format_length(uint16_t format) {
- return bits_in[format & 0xFF] << 1;
-}
-otl_PositionValue position_zero() {
- otl_PositionValue v = {0.0, 0.0, 0.0, 0.0};
- return v;
-}
-// Read a position value from SFNT
-otl_PositionValue read_gpos_value(font_file_pointer data, uint32_t tableLength, uint32_t offset,
- uint16_t format) {
- otl_PositionValue v = {0.0, 0.0, 0.0, 0.0};
- if (tableLength < offset + position_format_length(format)) return v;
- if (format & FORMAT_DX) { v.dx = read_16s(data + offset), offset += 2; };
- if (format & FORMAT_DY) { v.dy = read_16s(data + offset), offset += 2; };
- if (format & FORMAT_DWIDTH) { v.dWidth = read_16s(data + offset), offset += 2; };
- if (format & FORMAT_DHEIGHT) { v.dHeight = read_16s(data + offset), offset += 2; };
- return v;
-}
-json_value *gpos_dump_value(otl_PositionValue value) {
- json_value *v = json_object_new(4);
- if (value.dx) json_object_push(v, "dx", json_new_position(value.dx));
- if (value.dy) json_object_push(v, "dy", json_new_position(value.dy));
- if (value.dWidth) json_object_push(v, "dWidth", json_new_position(value.dWidth));
- if (value.dHeight) json_object_push(v, "dHeight", json_new_position(value.dHeight));
- return preserialize(v);
-}
-otl_PositionValue gpos_parse_value(json_value *pos) {
- otl_PositionValue v = {0.0, 0.0, 0.0, 0.0};
- if (!pos || pos->type != json_object) return v;
- v.dx = json_obj_getnum(pos, "dx");
- v.dy = json_obj_getnum(pos, "dy");
- v.dWidth = json_obj_getnum(pos, "dWidth");
- v.dHeight = json_obj_getnum(pos, "dHeight");
- return v;
-}
-// The required format of a position value
-uint8_t required_position_format(otl_PositionValue v) {
- return (v.dx ? FORMAT_DX : 0) | (v.dy ? FORMAT_DY : 0) | (v.dWidth ? FORMAT_DWIDTH : 0) |
- (v.dHeight ? FORMAT_DHEIGHT : 0);
-}
-// Write gpos position value
-void write_gpos_value(caryll_Buffer *buf, otl_PositionValue v, uint16_t format) {
- if (format & FORMAT_DX) bufwrite16b(buf, (int16_t)v.dx);
- if (format & FORMAT_DY) bufwrite16b(buf, (int16_t)v.dy);
- if (format & FORMAT_DWIDTH) bufwrite16b(buf, (int16_t)v.dWidth);
- if (format & FORMAT_DHEIGHT) bufwrite16b(buf, (int16_t)v.dHeight);
-}
-
-bk_Block *bk_gpos_value(otl_PositionValue v, uint16_t format) {
- bk_Block *b = bk_new_Block(bkover);
- if (format & FORMAT_DX) bk_push(b, b16, (int16_t)v.dx, bkover);
- if (format & FORMAT_DY) bk_push(b, b16, (int16_t)v.dy, bkover);
- if (format & FORMAT_DWIDTH) bk_push(b, b16, (int16_t)v.dWidth, bkover);
- if (format & FORMAT_DHEIGHT) bk_push(b, b16, (int16_t)v.dHeight, bkover);
- return b;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.h
deleted file mode 100644
index e232bbb6ecd..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-common.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GPOS_COMMON_H
-#define CARYLL_TABLE_OTL_GPOS_COMMON_H
-
-#include "common.h"
-
-// anchors
-otl_Anchor otl_anchor_absent(void);
-otl_Anchor otl_read_anchor(font_file_pointer data, uint32_t tableLength, uint32_t offset);
-json_value *otl_dump_anchor(otl_Anchor a);
-otl_Anchor otl_parse_anchor(json_value *v);
-bk_Block *bkFromAnchor(otl_Anchor a);
-
-// mark arrays
-typedef struct {
- sds className;
- glyphclass_t classID;
- UT_hash_handle hh;
-} otl_ClassnameHash;
-
-void otl_readMarkArray(otl_MarkArray *array, otl_Coverage *cov, font_file_pointer data,
- uint32_t tableLength, uint32_t offset);
-void otl_parseMarkArray(json_value *_marks, otl_MarkArray *array, otl_ClassnameHash **h,
- const otfcc_Options *options);
-
-// position values
-extern const uint8_t FORMAT_DX;
-extern const uint8_t FORMAT_DY;
-extern const uint8_t FORMAT_DWIDTH;
-extern const uint8_t FORMAT_DHEIGHT;
-extern const uint8_t bits_in[0x100];
-
-uint8_t position_format_length(uint16_t format);
-otl_PositionValue position_zero(void);
-otl_PositionValue read_gpos_value(font_file_pointer data, uint32_t tableLength, uint32_t offset,
- uint16_t format);
-uint8_t required_position_format(otl_PositionValue v);
-void write_gpos_value(caryll_Buffer *buf, otl_PositionValue v, uint16_t format);
-bk_Block *bk_gpos_value(otl_PositionValue v, uint16_t format);
-
-json_value *gpos_dump_value(otl_PositionValue value);
-otl_PositionValue gpos_parse_value(json_value *pos);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.c
deleted file mode 100644
index f75fc487a20..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "gpos-cursive.h"
-#include "gpos-common.h"
-
-static void deleteGposCursiveEntry(otl_GposCursiveEntry *entry) {
- Handle.dispose(&entry->target);
-}
-
-static caryll_ElementInterface(otl_GposCursiveEntry) gss_typeinfo = {
- .init = NULL, .copy = NULL, .dispose = deleteGposCursiveEntry};
-
-caryll_standardVectorImpl(subtable_gpos_cursive, otl_GposCursiveEntry, gss_typeinfo,
- iSubtable_gpos_cursive);
-
-otl_Subtable *otl_read_gpos_cursive(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- subtable_gpos_cursive *subtable = iSubtable_gpos_cursive.create();
- otl_Coverage *targets = NULL;
-
- checkLength(offset + 6);
-
- targets = Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
- if (!targets || targets->numGlyphs == 0) goto FAIL;
-
- glyphid_t valueCount = read_16u(data + offset + 4);
- checkLength(offset + 6 + 4 * valueCount);
- if (valueCount != targets->numGlyphs) goto FAIL;
-
- for (glyphid_t j = 0; j < valueCount; j++) {
- uint16_t enterOffset = read_16u(data + offset + 6 + 4 * j);
- uint16_t exitOffset = read_16u(data + offset + 6 + 4 * j + 2);
- otl_Anchor enter = otl_anchor_absent();
- otl_Anchor exit = otl_anchor_absent();
- if (enterOffset) { enter = otl_read_anchor(data, tableLength, offset + enterOffset); }
- if (exitOffset) { exit = otl_read_anchor(data, tableLength, offset + exitOffset); }
- iSubtable_gpos_cursive.push(
- subtable, ((otl_GposCursiveEntry){
- .target = Handle.dup(targets->glyphs[j]), .enter = enter, .exit = exit}));
- }
- if (targets) Coverage.free(targets);
- return (otl_Subtable *)subtable;
-FAIL:
- if (targets) Coverage.free(targets);
- iSubtable_gpos_cursive.free(subtable);
- return NULL;
-}
-
-json_value *otl_gpos_dump_cursive(const otl_Subtable *_subtable) {
- const subtable_gpos_cursive *subtable = &(_subtable->gpos_cursive);
- json_value *st = json_object_new(subtable->length);
- for (glyphid_t j = 0; j < subtable->length; j++) {
- json_value *rec = json_object_new(2);
- json_object_push(rec, "enter", otl_dump_anchor(subtable->items[j].enter));
- json_object_push(rec, "exit", otl_dump_anchor(subtable->items[j].exit));
- json_object_push(st, subtable->items[j].target.name, preserialize(rec));
- }
- return st;
-}
-
-otl_Subtable *otl_gpos_parse_cursive(const json_value *_subtable, const otfcc_Options *options) {
- subtable_gpos_cursive *subtable = iSubtable_gpos_cursive.create();
- for (glyphid_t j = 0; j < _subtable->u.object.length; j++) {
- if (_subtable->u.object.values[j].value &&
- _subtable->u.object.values[j].value->type == json_object) {
- sds gname = sdsnewlen(_subtable->u.object.values[j].name,
- _subtable->u.object.values[j].name_length);
- iSubtable_gpos_cursive.push(
- subtable, ((otl_GposCursiveEntry){
- .target = Handle.fromName(gname),
- .enter = otl_parse_anchor(
- json_obj_get(_subtable->u.object.values[j].value, "enter")),
- .exit = otl_parse_anchor(
- json_obj_get(_subtable->u.object.values[j].value, "exit")),
- }));
- }
- }
- return (otl_Subtable *)subtable;
-}
-
-caryll_Buffer *otfcc_build_gpos_cursive(const otl_Subtable *_subtable,
- otl_BuildHeuristics heuristics) {
- const subtable_gpos_cursive *subtable = &(_subtable->gpos_cursive);
- otl_Coverage *cov = Coverage.create();
- for (glyphid_t j = 0; j < subtable->length; j++) {
- Coverage.push(cov, Handle.dup(subtable->items[j].target));
- }
-
- bk_Block *root = bk_new_Block(b16, 1, // format
- p16, bk_newBlockFromBuffer(Coverage.build(cov)), // Coverage
- b16, subtable->length, // EntryExitCount
- bkover);
- for (glyphid_t j = 0; j < subtable->length; j++) {
- bk_push(root, // EntryExitRecord[.]
- p16, bkFromAnchor(subtable->items[j].enter), // enter
- p16, bkFromAnchor(subtable->items[j].exit), // exit
- bkover);
- }
- Coverage.free(cov);
-
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.h
deleted file mode 100644
index e0736de4c46..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-cursive.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GPOS_CURSIVE_H
-#define CARYLL_TABLE_OTL_GPOS_CURSIVE_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gpos_cursive(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gpos_dump_cursive(const otl_Subtable *_subtable);
-otl_Subtable *otl_gpos_parse_cursive(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gpos_cursive(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.c
deleted file mode 100644
index 45bf16b80fa..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.c
+++ /dev/null
@@ -1,241 +0,0 @@
-#include "gpos-mark-to-ligature.h"
-#include "gpos-common.h"
-
-static void deleteLigArrayItem(otl_LigatureBaseRecord *entry) {
- Handle.dispose(&entry->glyph);
- if (entry->anchors) {
- for (glyphid_t k = 0; k < entry->componentCount; k++)
- FREE(entry->anchors[k]);
- FREE(entry->anchors);
- }
-}
-static caryll_ElementInterface(otl_LigatureBaseRecord) la_typeinfo = {
- .init = NULL, .copy = NULL, .dispose = deleteLigArrayItem};
-
-caryll_standardVectorImpl(otl_LigatureArray, otl_LigatureBaseRecord, la_typeinfo,
- otl_iLigatureArray);
-
-static INLINE void initMarkToLigature(subtable_gpos_markToLigature *subtable) {
- otl_iMarkArray.init(&subtable->markArray);
- otl_iLigatureArray.init(&subtable->ligArray);
-}
-static INLINE void disposeMarkToLigature(subtable_gpos_markToLigature *subtable) {
- otl_iMarkArray.dispose(&subtable->markArray);
- otl_iLigatureArray.dispose(&subtable->ligArray);
-}
-
-caryll_standardRefType(subtable_gpos_markToLigature, iSubtable_gpos_markToLigature,
- initMarkToLigature, disposeMarkToLigature);
-
-otl_Subtable *otl_read_gpos_markToLigature(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- subtable_gpos_markToLigature *subtable = iSubtable_gpos_markToLigature.create();
- otl_Coverage *marks = NULL;
- otl_Coverage *bases = NULL;
- if (tableLength < offset + 12) goto FAIL;
-
- marks = Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
- bases = Coverage.read(data, tableLength, offset + read_16u(data + offset + 4));
- if (!marks || marks->numGlyphs == 0 || !bases || bases->numGlyphs == 0) goto FAIL;
- subtable->classCount = read_16u(data + offset + 6);
-
- uint32_t markArrayOffset = offset + read_16u(data + offset + 8);
- otl_readMarkArray(&subtable->markArray, marks, data, tableLength, markArrayOffset);
-
- uint32_t ligArrayOffset = offset + read_16u(data + offset + 10);
- checkLength(ligArrayOffset + 2 + 2 * bases->numGlyphs);
- if (read_16u(data + ligArrayOffset) != bases->numGlyphs) goto FAIL;
-
- for (glyphid_t j = 0; j < bases->numGlyphs; j++) {
- otl_LigatureBaseRecord lig;
- lig.glyph = Handle.dup(bases->glyphs[j]);
- uint32_t ligAttachOffset = ligArrayOffset + read_16u(data + ligArrayOffset + 2 + j * 2);
- checkLength(ligAttachOffset + 2);
- lig.componentCount = read_16u(data + ligAttachOffset);
-
- checkLength(ligAttachOffset + 2 + 2 * lig.componentCount * subtable->classCount);
- NEW(lig.anchors, lig.componentCount);
-
- uint32_t _offset = ligAttachOffset + 2;
- for (glyphid_t k = 0; k < lig.componentCount; k++) {
- NEW(lig.anchors[k], subtable->classCount);
- for (glyphclass_t m = 0; m < subtable->classCount; m++) {
- uint32_t anchorOffset = read_16u(data + _offset);
- if (anchorOffset) {
- lig.anchors[k][m] =
- otl_read_anchor(data, tableLength, ligAttachOffset + anchorOffset);
- } else {
- lig.anchors[k][m] = otl_anchor_absent();
- }
- _offset += 2;
- }
- }
- otl_iLigatureArray.push(&subtable->ligArray, lig);
- }
- if (marks) Coverage.free(marks);
- if (bases) Coverage.free(bases);
- return (otl_Subtable *)subtable;
-FAIL:
- if (marks) Coverage.free(marks);
- if (bases) Coverage.free(bases);
- iSubtable_gpos_markToLigature.free(subtable);
- return NULL;
-}
-
-json_value *otl_gpos_dump_markToLigature(const otl_Subtable *st) {
- const subtable_gpos_markToLigature *subtable = &(st->gpos_markToLigature);
- json_value *_subtable = json_object_new(3);
- json_value *_marks = json_object_new(subtable->markArray.length);
- json_value *_bases = json_object_new(subtable->ligArray.length);
- for (glyphid_t j = 0; j < subtable->markArray.length; j++) {
- json_value *_mark = json_object_new(3);
- sds markClassName = sdscatfmt(sdsempty(), "ac_%i", subtable->markArray.items[j].markClass);
- json_object_push(_mark, "class",
- json_string_new_length((uint32_t)sdslen(markClassName), markClassName));
- sdsfree(markClassName);
- json_object_push(_mark, "x", json_integer_new(subtable->markArray.items[j].anchor.x));
- json_object_push(_mark, "y", json_integer_new(subtable->markArray.items[j].anchor.y));
- json_object_push(_marks, subtable->markArray.items[j].glyph.name, preserialize(_mark));
- }
- for (glyphid_t j = 0; j < subtable->ligArray.length; j++) {
- otl_LigatureBaseRecord *base = &subtable->ligArray.items[j];
- json_value *_base = json_array_new(base->componentCount);
- for (glyphid_t k = 0; k < base->componentCount; k++) {
- json_value *_bk = json_object_new(subtable->classCount);
- for (glyphclass_t m = 0; m < subtable->classCount; m++) {
- if (base->anchors[k][m].present) {
- json_value *_anchor = json_object_new(2);
- json_object_push(_anchor, "x", json_integer_new(base->anchors[k][m].x));
- json_object_push(_anchor, "y", json_integer_new(base->anchors[k][m].y));
- sds markClassName = sdscatfmt(sdsempty(), "ac_%i", m);
- json_object_push_length(_bk, (uint32_t)sdslen(markClassName), markClassName,
- _anchor);
- sdsfree(markClassName);
- }
- }
- json_array_push(_base, _bk);
- }
- json_object_push(_bases, base->glyph.name, preserialize(_base));
- }
- json_object_push(_subtable, "classCount", json_integer_new(subtable->classCount));
- json_object_push(_subtable, "marks", _marks);
- json_object_push(_subtable, "bases", _bases);
- return _subtable;
-}
-
-static void parseBases(json_value *_bases, subtable_gpos_markToLigature *subtable,
- otl_ClassnameHash **h, const otfcc_Options *options) {
- glyphclass_t classCount = HASH_COUNT(*h);
-
- for (glyphid_t j = 0; j < _bases->u.object.length; j++) {
- char *gname = _bases->u.object.values[j].name;
- otl_LigatureBaseRecord lig;
- lig.componentCount = 0;
- lig.anchors = NULL;
- lig.glyph = Handle.fromName(
- sdsnewlen(_bases->u.object.values[j].name, _bases->u.object.values[j].name_length));
-
- json_value *baseRecord = _bases->u.object.values[j].value;
- if (!baseRecord || baseRecord->type != json_array) {
- otl_iLigatureArray.push(&subtable->ligArray, lig);
- continue;
- }
- lig.componentCount = baseRecord->u.array.length;
-
- NEW(lig.anchors, lig.componentCount);
-
- for (glyphid_t k = 0; k < lig.componentCount; k++) {
- json_value *_componentRecord = baseRecord->u.array.values[k];
- NEW(lig.anchors[k], classCount);
- for (glyphclass_t m = 0; m < classCount; m++) {
- lig.anchors[k][m] = otl_anchor_absent();
- }
- if (!_componentRecord || _componentRecord->type != json_object) { continue; }
- for (glyphclass_t m = 0; m < _componentRecord->u.object.length; m++) {
- sds className = sdsnewlen(_componentRecord->u.object.values[m].name,
- _componentRecord->u.object.values[m].name_length);
- otl_ClassnameHash *s;
- HASH_FIND_STR(*h, className, s);
- if (!s) {
- logWarning("[OTFCC-fea] Invalid anchor class name <%s> for /%s. This base "
- "anchor is ignored.\n",
- className, gname);
- goto NEXT;
- }
- lig.anchors[k][s->classID] =
- otl_parse_anchor(_componentRecord->u.object.values[m].value);
-
- NEXT:
- sdsfree(className);
- }
- }
- otl_iLigatureArray.push(&subtable->ligArray, lig);
- }
-}
-otl_Subtable *otl_gpos_parse_markToLigature(const json_value *_subtable,
- const otfcc_Options *options) {
- json_value *_marks = json_obj_get_type(_subtable, "marks", json_object);
- json_value *_bases = json_obj_get_type(_subtable, "bases", json_object);
- if (!_marks || !_bases) return NULL;
- subtable_gpos_markToLigature *st = iSubtable_gpos_markToLigature.create();
- otl_ClassnameHash *h = NULL;
- otl_parseMarkArray(_marks, &st->markArray, &h, options);
- st->classCount = HASH_COUNT(h);
- parseBases(_bases, st, &h, options);
-
- otl_ClassnameHash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- HASH_DEL(h, s);
- sdsfree(s->className);
- FREE(s);
- }
-
- return (otl_Subtable *)st;
-}
-
-caryll_Buffer *otfcc_build_gpos_markToLigature(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- const subtable_gpos_markToLigature *subtable = &(_subtable->gpos_markToLigature);
- otl_Coverage *marks = Coverage.create();
- for (glyphid_t j = 0; j < subtable->markArray.length; j++) {
- Coverage.push(marks, Handle.dup(subtable->markArray.items[j].glyph));
- }
- otl_Coverage *bases = Coverage.create();
- for (glyphid_t j = 0; j < subtable->ligArray.length; j++) {
- Coverage.push(bases, Handle.dup(subtable->ligArray.items[j].glyph));
- }
-
- bk_Block *root = bk_new_Block(b16, 1, // format
- p16, bk_newBlockFromBuffer(Coverage.build(marks)), // markCoverage
- p16, bk_newBlockFromBuffer(Coverage.build(bases)), // baseCoverage
- b16, subtable->classCount, // classCont
- bkover);
-
- bk_Block *markArray = bk_new_Block(b16, subtable->markArray.length, // markCount
- bkover);
- for (glyphid_t j = 0; j < subtable->markArray.length; j++) {
- bk_push(markArray, // markArray item
- b16, subtable->markArray.items[j].markClass, // markClass
- p16, bkFromAnchor(subtable->markArray.items[j].anchor), // Anchor
- bkover);
- }
-
- bk_Block *ligatureArray = bk_new_Block(b16, subtable->ligArray.length, bkover);
- for (glyphid_t j = 0; j < subtable->ligArray.length; j++) {
- bk_Block *attach =
- bk_new_Block(b16, subtable->ligArray.items[j].componentCount, // componentCount
- bkover);
- for (glyphid_t k = 0; k < subtable->ligArray.items[j].componentCount; k++) {
- for (glyphclass_t m = 0; m < subtable->classCount; m++) {
- bk_push(attach, p16, bkFromAnchor(subtable->ligArray.items[j].anchors[k][m]),
- bkover);
- }
- }
- bk_push(ligatureArray, p16, attach, bkover);
- }
-
- bk_push(root, p16, markArray, p16, ligatureArray, bkover);
- Coverage.free(marks);
- Coverage.free(bases);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.h
deleted file mode 100644
index 53de1acbd19..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-ligature.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GPOS_MARK_TO_LIGATURE_H
-#define CARYLL_TABLE_OTL_GPOS_MARK_TO_LIGATURE_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gpos_markToLigature(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gpos_dump_markToLigature(const otl_Subtable *st);
-otl_Subtable *otl_gpos_parse_markToLigature(const json_value *_subtable,
- const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gpos_markToLigature(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.c
deleted file mode 100644
index cf55cde82dc..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.c
+++ /dev/null
@@ -1,203 +0,0 @@
-#include "gpos-mark-to-single.h"
-#include "gpos-common.h"
-
-static void deleteBaseArrayItem(otl_BaseRecord *entry) {
- Handle.dispose(&entry->glyph);
- FREE(entry->anchors);
-}
-static caryll_ElementInterface(otl_BaseRecord) ba_typeinfo = {
- .init = NULL, .copy = NULL, .dispose = deleteBaseArrayItem};
-
-caryll_standardVectorImpl(otl_BaseArray, otl_BaseRecord, ba_typeinfo, otl_iBaseArray);
-
-static INLINE void initMarkToSingle(subtable_gpos_markToSingle *subtable) {
- otl_iMarkArray.init(&subtable->markArray);
- otl_iBaseArray.init(&subtable->baseArray);
-}
-static INLINE void disposeMarkToSingle(subtable_gpos_markToSingle *subtable) {
- otl_iMarkArray.dispose(&subtable->markArray);
- otl_iBaseArray.dispose(&subtable->baseArray);
-}
-
-caryll_standardRefType(subtable_gpos_markToSingle, iSubtable_gpos_markToSingle, initMarkToSingle,
- disposeMarkToSingle);
-
-otl_Subtable *otl_read_gpos_markToSingle(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
-
- subtable_gpos_markToSingle *subtable = iSubtable_gpos_markToSingle.create();
- otl_Coverage *marks = NULL;
- otl_Coverage *bases = NULL;
-
- if (tableLength < subtableOffset + 12) goto FAIL;
- marks = Coverage.read(data, tableLength, subtableOffset + read_16u(data + subtableOffset + 2));
- bases = Coverage.read(data, tableLength, subtableOffset + read_16u(data + subtableOffset + 4));
- if (!marks || marks->numGlyphs == 0 || !bases || bases->numGlyphs == 0) goto FAIL;
-
- subtable->classCount = read_16u(data + subtableOffset + 6);
- uint32_t markArrayOffset = subtableOffset + read_16u(data + subtableOffset + 8);
- otl_readMarkArray(&subtable->markArray, marks, data, tableLength, markArrayOffset);
-
- uint32_t baseArrayOffset = subtableOffset + read_16u(data + subtableOffset + 10);
- checkLength(baseArrayOffset + 2 + 2 * bases->numGlyphs * subtable->classCount);
- if (read_16u(data + baseArrayOffset) != bases->numGlyphs) goto FAIL;
-
- uint32_t _offset = baseArrayOffset + 2;
- for (glyphid_t j = 0; j < bases->numGlyphs; j++) {
- otl_Anchor *baseAnchors;
- NEW(baseAnchors, subtable->classCount);
- for (glyphclass_t k = 0; k < subtable->classCount; k++) {
- if (read_16u(data + _offset)) {
- baseAnchors[k] =
- otl_read_anchor(data, tableLength, baseArrayOffset + read_16u(data + _offset));
- } else {
- baseAnchors[k] = otl_anchor_absent();
- }
- _offset += 2;
- }
- otl_iBaseArray.push(
- &subtable->baseArray,
- ((otl_BaseRecord){.glyph = Handle.dup(bases->glyphs[j]), .anchors = baseAnchors}));
- }
- if (marks) Coverage.free(marks);
- if (bases) Coverage.free(bases);
- return (otl_Subtable *)subtable;
-FAIL:
- iSubtable_gpos_markToSingle.free(subtable);
- return NULL;
-}
-
-json_value *otl_gpos_dump_markToSingle(const otl_Subtable *st) {
- const subtable_gpos_markToSingle *subtable = &(st->gpos_markToSingle);
- json_value *_subtable = json_object_new(3);
- json_value *_marks = json_object_new(subtable->markArray.length);
- json_value *_bases = json_object_new(subtable->baseArray.length);
- for (glyphid_t j = 0; j < subtable->markArray.length; j++) {
- json_value *_mark = json_object_new(3);
- sds markClassName =
- sdscatfmt(sdsempty(), "anchor%i", subtable->markArray.items[j].markClass);
- json_object_push(_mark, "class",
- json_string_new_length((uint32_t)sdslen(markClassName), markClassName));
- sdsfree(markClassName);
- json_object_push(_mark, "x", json_integer_new(subtable->markArray.items[j].anchor.x));
- json_object_push(_mark, "y", json_integer_new(subtable->markArray.items[j].anchor.y));
- json_object_push(_marks, subtable->markArray.items[j].glyph.name, preserialize(_mark));
- }
- for (glyphid_t j = 0; j < subtable->baseArray.length; j++) {
- json_value *_base = json_object_new(subtable->classCount);
- for (glyphclass_t k = 0; k < subtable->classCount; k++) {
- if (subtable->baseArray.items[j].anchors[k].present) {
- json_value *_anchor = json_object_new(2);
- json_object_push(_anchor, "x",
- json_integer_new(subtable->baseArray.items[j].anchors[k].x));
- json_object_push(_anchor, "y",
- json_integer_new(subtable->baseArray.items[j].anchors[k].y));
- sds markClassName = sdscatfmt(sdsempty(), "anchor%i", k);
- json_object_push_length(_base, (uint32_t)sdslen(markClassName), markClassName,
- _anchor);
- sdsfree(markClassName);
- }
- }
- json_object_push(_bases, subtable->baseArray.items[j].glyph.name, preserialize(_base));
- }
- json_object_push(_subtable, "marks", _marks);
- json_object_push(_subtable, "bases", _bases);
- return _subtable;
-}
-
-static void parseBases(json_value *_bases, subtable_gpos_markToSingle *subtable,
- otl_ClassnameHash **h, const otfcc_Options *options) {
- glyphclass_t classCount = HASH_COUNT(*h);
- for (glyphid_t j = 0; j < _bases->u.object.length; j++) {
- char *gname = _bases->u.object.values[j].name;
- otl_BaseRecord base;
- base.glyph = Handle.fromName(sdsnewlen(gname, _bases->u.object.values[j].name_length));
- NEW(base.anchors, classCount);
- for (glyphclass_t k = 0; k < classCount; k++) {
- base.anchors[k] = otl_anchor_absent();
- }
- json_value *baseRecord = _bases->u.object.values[j].value;
- if (!baseRecord || baseRecord->type != json_object) {
- otl_iBaseArray.push(&subtable->baseArray, base);
- continue;
- }
-
- for (glyphclass_t k = 0; k < baseRecord->u.object.length; k++) {
- sds className = sdsnewlen(baseRecord->u.object.values[k].name,
- baseRecord->u.object.values[k].name_length);
- otl_ClassnameHash *s;
- HASH_FIND_STR(*h, className, s);
- if (!s) {
- logWarning("[OTFCC-fea] Invalid anchor class name <%s> for /%s. This base anchor "
- "is ignored.\n",
- className, gname);
- goto NEXT;
- }
- base.anchors[s->classID] = otl_parse_anchor(baseRecord->u.object.values[k].value);
- NEXT:
- sdsfree(className);
- }
- otl_iBaseArray.push(&subtable->baseArray, base);
- }
-}
-otl_Subtable *otl_gpos_parse_markToSingle(const json_value *_subtable,
- const otfcc_Options *options) {
- json_value *_marks = json_obj_get_type(_subtable, "marks", json_object);
- json_value *_bases = json_obj_get_type(_subtable, "bases", json_object);
- if (!_marks || !_bases) return NULL;
- subtable_gpos_markToSingle *st = iSubtable_gpos_markToSingle.create();
- otl_ClassnameHash *h = NULL;
- otl_parseMarkArray(_marks, &st->markArray, &h, options);
- st->classCount = HASH_COUNT(h);
- parseBases(_bases, st, &h, options);
-
- otl_ClassnameHash *s, *tmp;
- HASH_ITER(hh, h, s, tmp) {
- HASH_DEL(h, s);
- sdsfree(s->className);
- FREE(s);
- }
-
- return (otl_Subtable *)st;
-}
-
-caryll_Buffer *otfcc_build_gpos_markToSingle(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- const subtable_gpos_markToSingle *subtable = &(_subtable->gpos_markToSingle);
- otl_Coverage *marks = Coverage.create();
- for (glyphid_t j = 0; j < subtable->markArray.length; j++) {
- Coverage.push(marks, Handle.dup(subtable->markArray.items[j].glyph));
- }
- otl_Coverage *bases = Coverage.create();
- for (glyphid_t j = 0; j < subtable->baseArray.length; j++) {
- Coverage.push(bases, Handle.dup(subtable->baseArray.items[j].glyph));
- }
-
- bk_Block *root = bk_new_Block(b16, 1, // format
- p16, bk_newBlockFromBuffer(Coverage.build(marks)), // markCoverage
- p16, bk_newBlockFromBuffer(Coverage.build(bases)), // baseCoverage
- b16, subtable->classCount, // classCont
- bkover);
-
- bk_Block *markArray = bk_new_Block(b16, subtable->markArray.length, // markCount
- bkover);
- for (glyphid_t j = 0; j < subtable->markArray.length; j++) {
- bk_push(markArray, // markArray item
- b16, subtable->markArray.items[j].markClass, // markClass
- p16, bkFromAnchor(subtable->markArray.items[j].anchor), // Anchor
- bkover);
- }
-
- bk_Block *baseArray = bk_new_Block(b16, subtable->baseArray.length, // baseCount
- bkover);
- for (glyphid_t j = 0; j < subtable->baseArray.length; j++) {
- for (glyphclass_t k = 0; k < subtable->classCount; k++) {
- bk_push(baseArray, p16, bkFromAnchor(subtable->baseArray.items[j].anchors[k]), bkover);
- }
- }
-
- bk_push(root, p16, markArray, p16, baseArray, bkover);
- Coverage.free(marks);
- Coverage.free(bases);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.h
deleted file mode 100644
index e5e7a8792ea..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-mark-to-single.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GPOS_MARK_TO_SINGLE_H
-#define CARYLL_TABLE_OTL_GPOS_MARK_TO_SINGLE_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gpos_markToSingle(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gpos_dump_markToSingle(const otl_Subtable *st);
-otl_Subtable *otl_gpos_parse_markToSingle(const json_value *_subtable,
- const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gpos_markToSingle(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.c
deleted file mode 100644
index 87a113096d2..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.c
+++ /dev/null
@@ -1,406 +0,0 @@
-#include "gpos-pair.h"
-#include "gpos-common.h"
-
-static INLINE void initGposPair(subtable_gpos_pair *subtable) {
- subtable->first = NULL;
- subtable->second = NULL;
- subtable->firstValues = NULL;
- subtable->secondValues = NULL;
-}
-static INLINE void disposeGposPair(subtable_gpos_pair *subtable) {
- if (subtable->firstValues) {
- for (glyphclass_t j = 0; j <= subtable->first->maxclass; j++) {
- FREE(subtable->firstValues[j]);
- }
- FREE(subtable->firstValues);
- }
- if (subtable->secondValues) {
- for (glyphclass_t j = 0; j <= subtable->first->maxclass; j++) {
- FREE(subtable->secondValues[j]);
- }
- FREE(subtable->secondValues);
- }
- DELETE(ClassDef.free, subtable->first);
- DELETE(ClassDef.free, subtable->second);
-}
-
-caryll_standardRefType(subtable_gpos_pair, iSubtable_gpos_pair, initGposPair, disposeGposPair);
-
-typedef struct {
- int gid;
- int cid;
- UT_hash_handle hh;
-} pair_classifier_hash;
-
-otl_Subtable *otl_read_gpos_pair(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- subtable_gpos_pair *subtable = iSubtable_gpos_pair.create();
-
- checkLength(offset + 2);
- uint16_t subtableFormat = read_16u(data + offset);
- if (subtableFormat == 1) {
- // pair adjustment by individuals
- otl_Coverage *cov = Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
- NEW(subtable->first);
- subtable->first->numGlyphs = cov->numGlyphs;
- subtable->first->maxclass = cov->numGlyphs - 1;
- subtable->first->glyphs = cov->glyphs;
- NEW(subtable->first->classes, cov->numGlyphs);
- for (glyphid_t j = 0; j < cov->numGlyphs; j++) {
- subtable->first->classes[j] = j;
- }
- FREE(cov);
-
- uint16_t format1 = read_16u(data + offset + 4);
- uint16_t format2 = read_16u(data + offset + 6);
- uint8_t len1 = position_format_length(format1);
- uint8_t len2 = position_format_length(format2);
-
- glyphid_t pairSetCount = read_16u(data + offset + 8);
- if (pairSetCount != subtable->first->numGlyphs) goto FAIL;
- checkLength(offset + 10 + 2 * pairSetCount);
-
- // pass 1: check length
- for (glyphid_t j = 0; j < pairSetCount; j++) {
- uint32_t pairSetOffset = offset + read_16u(data + offset + 10 + 2 * j);
- checkLength(pairSetOffset + 2);
- glyphid_t pairCount = read_16u(data + pairSetOffset);
- checkLength(pairSetOffset + 2 + (2 + len1 + len2) * pairCount);
- }
- // pass 2: make hashtable about second glyphs to construct a classdec
- pair_classifier_hash *h = NULL;
- for (glyphid_t j = 0; j < pairSetCount; j++) {
- uint32_t pairSetOffset = offset + read_16u(data + offset + 10 + 2 * j);
- glyphid_t pairCount = read_16u(data + pairSetOffset);
- for (glyphid_t k = 0; k < pairCount; k++) {
- int second = read_16u(data + pairSetOffset + 2 + (2 + len1 + len2) * k);
- pair_classifier_hash *s;
- HASH_FIND_INT(h, &second, s);
- if (!s) {
- NEW(s);
- s->gid = second;
- s->cid = HASH_COUNT(h) + 1;
- HASH_ADD_INT(h, gid, s);
- }
- }
- }
- // pass 3: make the matrix
- NEW(subtable->second);
- subtable->second->numGlyphs = HASH_COUNT(h);
- subtable->second->maxclass = HASH_COUNT(h);
- NEW(subtable->second->classes, subtable->second->numGlyphs);
- NEW(subtable->second->glyphs, subtable->second->numGlyphs);
- glyphclass_t class2Count = subtable->second->maxclass + 1;
-
- NEW(subtable->firstValues, subtable->first->maxclass + 1);
- NEW(subtable->secondValues, subtable->first->maxclass + 1);
- for (glyphclass_t j = 0; j <= subtable->first->maxclass; j++) {
- NEW(subtable->firstValues[j], class2Count);
- NEW(subtable->secondValues[j], class2Count);
- for (glyphclass_t k = 0; k < class2Count; k++) {
- subtable->firstValues[j][k] = position_zero();
- subtable->secondValues[j][k] = position_zero();
- }
- };
- for (glyphclass_t j = 0; j <= subtable->first->maxclass; j++) {
- uint32_t pairSetOffset = offset + read_16u(data + offset + 10 + 2 * j);
- glyphid_t pairCount = read_16u(data + pairSetOffset);
- for (glyphid_t k = 0; k < pairCount; k++) {
- int second = read_16u(data + pairSetOffset + 2 + (2 + len1 + len2) * k);
- pair_classifier_hash *s;
- HASH_FIND_INT(h, &second, s);
- if (s) {
- subtable->firstValues[j][s->cid] = read_gpos_value(
- data, tableLength, pairSetOffset + 2 + (2 + len1 + len2) * k + 2, format1);
- subtable->secondValues[j][s->cid] = read_gpos_value(
- data, tableLength, pairSetOffset + 2 + (2 + len1 + len2) * k + 2 + len1,
- format2);
- }
- }
- }
- // pass 4: return
- pair_classifier_hash *s, *tmp;
- glyphid_t jj = 0;
- HASH_ITER(hh, h, s, tmp) {
- subtable->second->glyphs[jj] = Handle.fromIndex(s->gid);
- subtable->second->classes[jj] = s->cid;
- jj++;
- HASH_DEL(h, s);
- FREE(s);
- }
- return (otl_Subtable *)subtable;
- } else if (subtableFormat == 2) {
- // pair adjustment by classes
- checkLength(offset + 16);
- uint16_t format1 = read_16u(data + offset + 4);
- uint16_t format2 = read_16u(data + offset + 6);
- uint8_t len1 = position_format_length(format1);
- uint8_t len2 = position_format_length(format2);
- otl_Coverage *cov = Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
- subtable->first = ClassDef.read(data, tableLength, offset + read_16u(data + offset + 8));
- subtable->first = ClassDef.expand(cov, subtable->first);
- DELETE(Coverage.free, cov);
- subtable->second = ClassDef.read(data, tableLength, offset + read_16u(data + offset + 10));
- if (!subtable->first || !subtable->second) goto FAIL;
- glyphclass_t class1Count = read_16u(data + offset + 12);
- glyphclass_t class2Count = read_16u(data + offset + 14);
- if (subtable->first->maxclass + 1 != class1Count) goto FAIL;
- if (subtable->second->maxclass + 1 != class2Count) goto FAIL;
-
- checkLength(offset + 16 + class1Count * class2Count * (len1 + len2));
- // read the matrix
- NEW(subtable->firstValues, class1Count);
- NEW(subtable->secondValues, class1Count);
-
- for (glyphclass_t j = 0; j < class1Count; j++) {
- NEW(subtable->firstValues[j], class2Count);
- NEW(subtable->secondValues[j], class2Count);
- for (glyphclass_t k = 0; k < class2Count; k++) {
- subtable->firstValues[j][k] =
- read_gpos_value(data, tableLength,
- offset + 16 + (j * class2Count + k) * (len1 + len2), format1);
- subtable->secondValues[j][k] = read_gpos_value(
- data, tableLength, offset + 16 + (j * class2Count + k) * (len1 + len2) + len1,
- format2);
- }
- }
-
- return (otl_Subtable *)subtable;
- }
-FAIL:
- iSubtable_gpos_pair.free(subtable);
- return NULL;
-}
-
-json_value *otl_gpos_dump_pair(const otl_Subtable *_subtable) {
- const subtable_gpos_pair *subtable = &(_subtable->gpos_pair);
- json_value *st = json_object_new(3);
- json_object_push(st, "first", ClassDef.dump(subtable->first));
- json_object_push(st, "second", ClassDef.dump(subtable->second));
-
- json_value *mat = json_array_new(subtable->first->maxclass + 1);
- for (glyphclass_t j = 0; j <= subtable->first->maxclass; j++) {
- json_value *row = json_array_new(subtable->second->maxclass + 1);
- for (glyphclass_t k = 0; k <= subtable->second->maxclass; k++) {
- uint8_t f1 = required_position_format(subtable->firstValues[j][k]);
- uint8_t f2 = required_position_format(subtable->secondValues[j][k]);
- if (f1 | f2) {
- if (f1 == FORMAT_DWIDTH && f2 == 0) {
- // simple kerning
- json_array_push(row, json_new_position(subtable->firstValues[j][k].dWidth));
- } else {
- json_value *pair = json_object_new(2);
- if (f1) {
- json_object_push(pair, "first",
- gpos_dump_value(subtable->firstValues[j][k]));
- }
- if (f2) {
- json_object_push(pair, "second",
- gpos_dump_value(subtable->secondValues[j][k]));
- }
- json_array_push(row, pair);
- }
- } else {
- json_array_push(row, json_new_position(0));
- }
- }
- json_array_push(mat, preserialize(row));
- }
- json_object_push(st, "matrix", mat);
- return st;
-}
-otl_Subtable *otl_gpos_parse_pair(const json_value *_subtable, const otfcc_Options *options) {
- subtable_gpos_pair *subtable = iSubtable_gpos_pair.create();
-
- json_value *_mat = json_obj_get_type(_subtable, "matrix", json_array);
- subtable->first = ClassDef.parse(json_obj_get_type(_subtable, "first", json_object));
- subtable->second = ClassDef.parse(json_obj_get_type(_subtable, "second", json_object));
- if (!_mat || !subtable->first || !subtable->second) goto FAIL;
-
- glyphclass_t class1Count = subtable->first->maxclass + 1;
- glyphclass_t class2Count = subtable->second->maxclass + 1;
-
- NEW(subtable->firstValues, class1Count);
- NEW(subtable->secondValues, class1Count);
-
- for (glyphclass_t j = 0; j < class1Count; j++) {
- NEW(subtable->firstValues[j], class2Count);
- NEW(subtable->secondValues[j], class2Count);
- for (glyphclass_t k = 0; k < class2Count; k++) {
- subtable->firstValues[j][k] = position_zero();
- subtable->secondValues[j][k] = position_zero();
- }
- }
- for (glyphclass_t j = 0; j < class1Count && j < _mat->u.array.length; j++) {
- json_value *_row = _mat->u.array.values[j];
- if (!_row || _row->type != json_array) continue;
- for (glyphclass_t k = 0; k < class2Count && k < _row->u.array.length; k++) {
- json_value *_item = _row->u.array.values[k];
- if (_item->type == json_integer) {
- subtable->firstValues[j][k].dWidth = _item->u.integer;
- } else if (_item->type == json_double) {
- subtable->firstValues[j][k].dWidth = _item->u.dbl;
- } else if (_item->type == json_object) {
- subtable->firstValues[j][k] = gpos_parse_value(json_obj_get(_item, "first"));
- subtable->secondValues[j][k] = gpos_parse_value(json_obj_get(_item, "second"));
- }
- }
- }
- return (otl_Subtable *)subtable;
-FAIL:
- iSubtable_gpos_pair.free(subtable);
- return NULL;
-}
-static otl_Coverage *covFromCD(otl_ClassDef *cd) {
- otl_Coverage *cov;
- NEW(cov);
- cov->numGlyphs = cd->numGlyphs;
- NEW(cov->glyphs, cd->numGlyphs);
- for (glyphid_t j = 0; j < cd->numGlyphs; j++) {
- cov->glyphs[j] = Handle.dup(cd->glyphs[j]);
- }
- return cov;
-}
-
-typedef struct {
- glyphid_t gid;
- otl_PositionValue *fv;
- otl_PositionValue *sv;
-} IndividualGposPair;
-
-static int by_pairSecondGlyph(const void *a, const void *b) {
- return ((const IndividualGposPair *)a)->gid - ((const IndividualGposPair *)b)->gid;
-}
-
-static bk_Block *otfcc_build_gpos_pair_individual(const otl_Subtable *_subtable) {
- const subtable_gpos_pair *subtable = &(_subtable->gpos_pair);
- uint16_t format1 = 0;
- uint16_t format2 = 0;
- glyphclass_t class1Count = subtable->first->maxclass + 1;
- glyphclass_t class2Count = subtable->second->maxclass + 1;
-
- for (glyphclass_t j = 0; j < class1Count; j++) {
- for (glyphclass_t k = 0; k < class2Count; k++) {
- format1 |= required_position_format(subtable->firstValues[j][k]);
- format2 |= required_position_format(subtable->secondValues[j][k]);
- }
- }
- glyphid_t *pairCounts;
- NEW(pairCounts, subtable->first->numGlyphs);
- for (glyphid_t j = 0; j < subtable->first->numGlyphs; j++) {
- pairCounts[j] = 0;
- for (glyphid_t k = 0; k < subtable->second->numGlyphs; k++) {
- glyphclass_t c1 = subtable->first->classes[j];
- glyphclass_t c2 = subtable->second->classes[k];
- if (required_position_format(subtable->firstValues[c1][c2]) |
- required_position_format(subtable->secondValues[c1][c2])) {
- pairCounts[j] += 1;
- }
- }
- }
- otl_Coverage *cov = covFromCD(subtable->first);
- Coverage.shrink(cov, true);
- bk_Block *root = bk_new_Block(b16, 1, // PosFormat
- p16, bk_newBlockFromBuffer(Coverage.build(cov)), // Coverage
- b16, format1, // ValueFormat1
- b16, format2, // ValueFormat2
- b16, subtable->first->numGlyphs, // PairSetCount
- bkover);
-
- for (glyphid_t j = 0; j < cov->numGlyphs; j++) {
- tableid_t currentPairCount = 0;
- glyphclass_t c1 = 0;
- for (glyphid_t k = 0; k < subtable->first->numGlyphs; k++) {
- if (subtable->first->glyphs[k].index == cov->glyphs[j].index) {
- // The coverage is sorted, not direct correspondence with subtable->first.
- c1 = subtable->first->classes[k];
- currentPairCount = pairCounts[k];
- }
- }
- bk_Block *pairSet = bk_new_Block(b16, currentPairCount, // PairValueCount
- bkover);
- IndividualGposPair *pairs;
- NEW_CLEAN_N(pairs, currentPairCount);
- size_t n = 0;
- for (glyphid_t k = 0; k < subtable->second->numGlyphs; k++) {
- glyphclass_t c2 = subtable->second->classes[k];
- if (required_position_format(subtable->firstValues[c1][c2]) |
- required_position_format(subtable->secondValues[c1][c2])) {
- pairs[n].gid = subtable->second->glyphs[k].index;
- pairs[n].fv = &subtable->firstValues[c1][c2];
- pairs[n].sv = &subtable->secondValues[c1][c2];
- n++;
- }
- }
- qsort(pairs, currentPairCount, sizeof(IndividualGposPair), by_pairSecondGlyph);
- for (size_t n = 0; n < currentPairCount; n++) {
- bk_push(pairSet, b16, pairs[n].gid, // SecondGlyph
- bkembed, bk_gpos_value(*(pairs[n].fv), format1), // Value1
- bkembed, bk_gpos_value(*(pairs[n].sv), format2), // Value2
- bkover);
- }
- FREE(pairs);
- bk_push(root, p16, pairSet, bkover);
- }
- DELETE(Coverage.free, cov);
- FREE(pairCounts);
- return root;
-}
-static bk_Block *otfcc_build_gpos_pair_classes(const otl_Subtable *_subtable) {
- const subtable_gpos_pair *subtable = &(_subtable->gpos_pair);
- uint16_t format1 = 0;
- uint16_t format2 = 0;
- glyphclass_t class1Count = subtable->first->maxclass + 1;
- glyphclass_t class2Count = subtable->second->maxclass + 1;
-
- for (glyphclass_t j = 0; j < class1Count; j++) {
- for (glyphclass_t k = 0; k < class2Count; k++) {
- format1 |= required_position_format(subtable->firstValues[j][k]);
- format2 |= required_position_format(subtable->secondValues[j][k]);
- }
- }
- otl_Coverage *cov = covFromCD(subtable->first);
- bk_Block *root =
- bk_new_Block(b16, 2, // PosFormat
- p16, bk_newBlockFromBuffer(Coverage.build(cov)), // Coverage
- b16, format1, // ValueFormat1
- b16, format2, // ValueFormat2
- p16, bk_newBlockFromBuffer(ClassDef.build(subtable->first)), // ClassDef1
- p16, bk_newBlockFromBuffer(ClassDef.build(subtable->second)), // ClassDef2
- b16, class1Count, // Class1Count
- b16, class2Count, // Class2Count
- bkover);
- for (glyphclass_t j = 0; j < class1Count; j++) {
- for (glyphclass_t k = 0; k < class2Count; k++) {
- bk_push(root, bkembed, bk_gpos_value(subtable->firstValues[j][k], format1), // Value1
- bkembed, bk_gpos_value(subtable->secondValues[j][k], format2), // Value2
- bkover);
- }
- }
- DELETE(Coverage.free, cov);
- return root;
-}
-caryll_Buffer *otfcc_build_gpos_pair(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- bk_Block *format1 = otfcc_build_gpos_pair_individual(_subtable);
- bk_Block *format2 = otfcc_build_gpos_pair_classes(_subtable);
- bk_Graph *g1 = bk_newGraphFromRootBlock(format1);
- bk_Graph *g2 = bk_newGraphFromRootBlock(format2);
- bk_minimizeGraph(g1);
- bk_minimizeGraph(g2);
- if (bk_estimateSizeOfGraph(g1) > bk_estimateSizeOfGraph(g2)) {
- // Choose pair adjustment by classes
- bk_delete_Graph(g1);
- bk_untangleGraph(g2);
- caryll_Buffer *buf = bk_build_Graph(g2);
- bk_delete_Graph(g2);
- return buf;
- } else {
- // Choose pair adjustment by individuals
- bk_delete_Graph(g2);
- bk_untangleGraph(g1);
- caryll_Buffer *buf = bk_build_Graph(g1);
- bk_delete_Graph(g1);
- return buf;
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.h
deleted file mode 100644
index ce09c209b81..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-pair.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GPOS_PAIR_H
-#define CARYLL_TABLE_OTL_GPOS_PAIR_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gpos_pair(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gpos_dump_pair(const otl_Subtable *_subtable);
-otl_Subtable *otl_gpos_parse_pair(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gpos_pair(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.c
deleted file mode 100644
index d1f42faa94c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.c
+++ /dev/null
@@ -1,129 +0,0 @@
-#include "gpos-single.h"
-#include "gpos-common.h"
-
-static void deleteGposSingleEntry(otl_GposSingleEntry *entry) {
- Handle.dispose(&entry->target);
-}
-
-static caryll_ElementInterface(otl_GposSingleEntry) gss_typeinfo = {
- .init = NULL, .copy = NULL, .dispose = deleteGposSingleEntry};
-
-caryll_standardVectorImpl(subtable_gpos_single, otl_GposSingleEntry, gss_typeinfo,
- iSubtable_gpos_single);
-
-otl_Subtable *otl_read_gpos_single(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- subtable_gpos_single *subtable = iSubtable_gpos_single.create();
- otl_Coverage *targets = NULL;
-
- checkLength(offset + 6);
-
- uint16_t subtableFormat = read_16u(data + offset);
- targets = Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
- if (!targets || targets->numGlyphs == 0) goto FAIL;
-
- if (subtableFormat == 1) {
- otl_PositionValue v =
- read_gpos_value(data, tableLength, offset + 6, read_16u(data + offset + 4));
- for (glyphid_t j = 0; j < targets->numGlyphs; j++) {
- iSubtable_gpos_single.push(subtable,
- ((otl_GposSingleEntry){
- .target = Handle.dup(targets->glyphs[j]), .value = v,
- }));
- }
- } else {
- uint16_t valueFormat = read_16u(data + offset + 4);
- uint16_t valueCount = read_16u(data + offset + 6);
- checkLength(offset + 8 + position_format_length(valueFormat) * valueCount);
- if (valueCount != targets->numGlyphs) goto FAIL;
-
- for (glyphid_t j = 0; j < targets->numGlyphs; j++) {
- iSubtable_gpos_single.push(
- subtable,
- ((otl_GposSingleEntry){
- .target = Handle.dup(targets->glyphs[j]),
- .value = read_gpos_value(data, tableLength,
- offset + 8 + j * position_format_length(valueFormat),
- valueFormat),
- }));
- }
- }
- if (targets) Coverage.free(targets);
- return (otl_Subtable *)subtable;
-
-FAIL:
- if (targets) Coverage.free(targets);
- iSubtable_gpos_single.free(subtable);
- return NULL;
-}
-
-json_value *otl_gpos_dump_single(const otl_Subtable *_subtable) {
- const subtable_gpos_single *subtable = &(_subtable->gpos_single);
- json_value *st = json_object_new(subtable->length);
- for (glyphid_t j = 0; j < subtable->length; j++) {
- json_object_push(st, subtable->items[j].target.name,
- gpos_dump_value(subtable->items[j].value));
- }
- return st;
-}
-otl_Subtable *otl_gpos_parse_single(const json_value *_subtable, const otfcc_Options *options) {
- subtable_gpos_single *subtable = iSubtable_gpos_single.create();
- for (glyphid_t j = 0; j < _subtable->u.object.length; j++) {
- if (_subtable->u.object.values[j].value &&
- _subtable->u.object.values[j].value->type == json_object) {
- sds gname = sdsnewlen(_subtable->u.object.values[j].name,
- _subtable->u.object.values[j].name_length);
- iSubtable_gpos_single.push(
- subtable, ((otl_GposSingleEntry){
- .target = Handle.fromName(gname),
- .value = gpos_parse_value(_subtable->u.object.values[j].value),
- }));
- }
- }
- return (otl_Subtable *)subtable;
-}
-
-caryll_Buffer *otfcc_build_gpos_single(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- const subtable_gpos_single *subtable = &(_subtable->gpos_single);
- bool isConst = subtable->length > 0;
- uint16_t format = 0;
- if (subtable->length > 0) {
- for (glyphid_t j = 0; j < subtable->length; j++) {
- isConst = isConst && (subtable->items[j].value.dx == subtable->items[0].value.dx) &&
- (subtable->items[j].value.dy == subtable->items[0].value.dy) &&
- (subtable->items[j].value.dWidth == subtable->items[0].value.dWidth) &&
- (subtable->items[j].value.dHeight == subtable->items[0].value.dHeight);
- format |= required_position_format(subtable->items[j].value);
- }
- }
- otl_Coverage *cov = Coverage.create();
- for (glyphid_t j = 0; j < subtable->length; j++) {
- Coverage.push(cov, Handle.dup(subtable->items[j].target));
- }
-
- caryll_Buffer *coverageBuf = Coverage.build(cov);
-
- if (isConst) {
- bk_Block *b =
- (bk_new_Block(b16, 1, // Format
- p16, bk_newBlockFromBuffer(coverageBuf), // coverage
- b16, format, // format
- bkembed, bk_gpos_value(subtable->items[0].value, format), // value
- bkover));
- Coverage.free(cov);
- return bk_build_Block(b);
- } else {
- bk_Block *b = bk_new_Block(b16, 2, // Format
- p16, bk_newBlockFromBuffer(coverageBuf), // coverage
- b16, format, // format
- b16, subtable->length, // quantity
- bkover);
- for (glyphid_t k = 0; k < subtable->length; k++) {
- bk_push(b, bkembed, bk_gpos_value(subtable->items[k].value, format), // value
- bkover);
- }
- Coverage.free(cov);
- return bk_build_Block(b);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.h
deleted file mode 100644
index 20774d72ac0..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gpos-single.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GPOS_SINGLE_H
-#define CARYLL_TABLE_OTL_GPOS_SINGLE_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gpos_single(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gpos_dump_single(const otl_Subtable *_subtable);
-otl_Subtable *otl_gpos_parse_single(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gpos_single(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.c
deleted file mode 100644
index 49f126fd47f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.c
+++ /dev/null
@@ -1,177 +0,0 @@
-#include "gsub-ligature.h"
-
-static void deleteGsubLigatureEntry(otl_GsubLigatureEntry *entry) {
- Handle.dispose(&entry->to);
- DELETE(Coverage.free, entry->from);
-}
-static caryll_ElementInterface(otl_GsubLigatureEntry) gss_typeinfo = {
- .init = NULL, .copy = NULL, .dispose = deleteGsubLigatureEntry};
-
-caryll_standardVectorImpl(subtable_gsub_ligature, otl_GsubLigatureEntry, gss_typeinfo,
- iSubtable_gsub_ligature);
-
-otl_Subtable *otl_read_gsub_ligature(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- subtable_gsub_ligature *subtable = iSubtable_gsub_ligature.create();
- checkLength(offset + 6);
-
- otl_Coverage *startCoverage =
- Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
- if (!startCoverage) goto FAIL;
- glyphid_t setCount = read_16u(data + offset + 4);
- if (setCount != startCoverage->numGlyphs) goto FAIL;
- checkLength(offset + 6 + setCount * 2);
-
- uint32_t ligatureCount = 0;
- for (glyphid_t j = 0; j < setCount; j++) {
- uint32_t setOffset = offset + read_16u(data + offset + 6 + j * 2);
- checkLength(setOffset + 2);
- ligatureCount += read_16u(data + setOffset);
- checkLength(setOffset + 2 + read_16u(data + setOffset) * 2);
- }
-
- for (glyphid_t j = 0; j < setCount; j++) {
- uint32_t setOffset = offset + read_16u(data + offset + 6 + j * 2);
- glyphid_t lc = read_16u(data + setOffset);
- for (glyphid_t k = 0; k < lc; k++) {
- uint32_t ligOffset = setOffset + read_16u(data + setOffset + 2 + k * 2);
- checkLength(ligOffset + 4);
- glyphid_t ligComponents = read_16u(data + ligOffset + 2);
- checkLength(ligOffset + 2 + ligComponents * 2);
-
- otl_Coverage *cov = Coverage.create();
- Coverage.push(cov, Handle.fromIndex(startCoverage->glyphs[j].index));
- for (glyphid_t m = 1; m < ligComponents; m++) {
- Coverage.push(cov, Handle.fromIndex(read_16u(data + ligOffset + 2 + m * 2)));
- }
- iSubtable_gsub_ligature.push(
- subtable, ((otl_GsubLigatureEntry){
- .from = cov, .to = Handle.fromIndex(read_16u(data + ligOffset)),
- }));
- }
- }
- Coverage.free(startCoverage);
- return (otl_Subtable *)subtable;
-FAIL:
- iSubtable_gsub_ligature.free(subtable);
- return NULL;
-}
-
-json_value *otl_gsub_dump_ligature(const otl_Subtable *_subtable) {
- const subtable_gsub_ligature *subtable = &(_subtable->gsub_ligature);
- json_value *st = json_array_new(subtable->length);
- for (glyphid_t j = 0; j < subtable->length; j++) {
- json_value *entry = json_object_new(2);
- json_object_push(entry, "from", Coverage.dump(subtable->items[j].from));
- json_object_push(entry, "to",
- json_string_new_length((uint32_t)sdslen(subtable->items[j].to.name),
- subtable->items[j].to.name));
- json_array_push(st, preserialize(entry));
- }
- json_value *ret = json_object_new(1);
- json_object_push(ret, "substitutions", st);
- return ret;
-}
-
-otl_Subtable *otl_gsub_parse_ligature(const json_value *_subtable, const otfcc_Options *options) {
- if (json_obj_get_type(_subtable, "substitutions", json_array)) {
- _subtable = json_obj_get_type(_subtable, "substitutions", json_array);
-
- subtable_gsub_ligature *st = iSubtable_gsub_ligature.create();
- glyphid_t n = _subtable->u.array.length;
-
- for (glyphid_t k = 0; k < n; k++) {
- json_value *entry = _subtable->u.array.values[k];
- json_value *_from = json_obj_get_type(entry, "from", json_array);
- json_value *_to = json_obj_get_type(entry, "to", json_string);
- if (!_from || !_to) continue;
- iSubtable_gsub_ligature.push(
- st, ((otl_GsubLigatureEntry){
- .to = Handle.fromName(sdsnewlen(_to->u.string.ptr, _to->u.string.length)),
- .from = Coverage.parse(_from),
- }));
- }
- return (otl_Subtable *)st;
- } else {
- subtable_gsub_ligature *st = iSubtable_gsub_ligature.create();
- glyphid_t n = _subtable->u.array.length;
-
- for (glyphid_t k = 0; k < n; k++) {
- json_value *_from = _subtable->u.object.values[k].value;
- if (!_from || _from->type != json_array) continue;
- iSubtable_gsub_ligature.push(
- st, ((otl_GsubLigatureEntry){
- .to = Handle.fromName(sdsnewlen(_subtable->u.object.values[k].name,
- _subtable->u.object.values[k].name_length)),
- .from = Coverage.parse(_from),
- }));
- }
- return (otl_Subtable *)st;
- }
- return NULL;
-}
-
-typedef struct {
- int gid;
- UT_hash_handle hh;
-} ligature_aggerator;
-static int by_gid(ligature_aggerator *a, ligature_aggerator *b) {
- return a->gid - b->gid;
-}
-
-caryll_Buffer *otfcc_build_gsub_ligature_subtable(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- const subtable_gsub_ligature *subtable = &(_subtable->gsub_ligature);
-
- ligature_aggerator *h = NULL, *s, *tmp;
- glyphid_t nLigatures = subtable->length;
- for (glyphid_t j = 0; j < nLigatures; j++) {
- int sgid = subtable->items[j].from->glyphs[0].index;
- HASH_FIND_INT(h, &sgid, s);
- if (!s) {
- NEW(s);
- s->gid = sgid;
- HASH_ADD_INT(h, gid, s);
- }
- }
- HASH_SORT(h, by_gid);
-
- otl_Coverage *startcov = Coverage.create();
-
- foreach_hash(s, h) {
- Coverage.push(startcov, Handle.fromIndex(s->gid));
- }
-
- bk_Block *root = bk_new_Block(b16, 1, // format
- p16, bk_newBlockFromBuffer(Coverage.build(startcov)), // coverage
- b16, startcov->numGlyphs, // LigSetCount
- bkover);
-
- foreach_hash(s, h) {
- glyphid_t nLigsHere = 0;
- for (glyphid_t j = 0; j < nLigatures; j++)
- if (subtable->items[j].from->glyphs[0].index == s->gid) nLigsHere++;
- bk_Block *ligset = bk_new_Block(b16, nLigsHere, bkover);
-
- for (glyphid_t j = 0; j < nLigatures; j++) {
- if (subtable->items[j].from->glyphs[0].index == s->gid) {
- bk_Block *ligdef =
- bk_new_Block(b16, subtable->items[j].to.index, // ligGlyph
- b16, subtable->items[j].from->numGlyphs, // compCount
- bkover);
- for (glyphid_t m = 1; m < subtable->items[j].from->numGlyphs; m++) {
- bk_push(ligdef, b16, subtable->items[j].from->glyphs[m].index, bkover);
- }
- bk_push(ligset, p16, ligdef, bkover);
- }
- }
- bk_push(root, p16, ligset, bkover);
- }
-
- Coverage.free(startcov);
- HASH_ITER(hh, h, s, tmp) {
- HASH_DEL(h, s);
- FREE(s);
- }
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.h
deleted file mode 100644
index f76244c5495..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-ligature.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GSUB_LIGATURE_H
-#define CARYLL_TABLE_OTL_GSUB_LIGATURE_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gsub_ligature(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gsub_dump_ligature(const otl_Subtable *_subtable);
-otl_Subtable *otl_gsub_parse_ligature(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gsub_ligature_subtable(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.c
deleted file mode 100644
index 938218b3c4c..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "gsub-multi.h"
-
-static void deleteGsubMultiEntry(otl_GsubMultiEntry *entry) {
- Handle.dispose(&entry->from);
- DELETE(Coverage.free, entry->to);
-}
-
-static caryll_ElementInterface(otl_GsubMultiEntry) gsm_typeinfo = {
- .init = NULL, .copy = NULL, .dispose = deleteGsubMultiEntry};
-
-caryll_standardVectorImpl(subtable_gsub_multi, otl_GsubMultiEntry, gsm_typeinfo,
- iSubtable_gsub_multi);
-
-otl_Subtable *otl_read_gsub_multi(font_file_pointer data, uint32_t tableLength, uint32_t offset,
- const glyphid_t maxGlyphs, const otfcc_Options *options) {
- subtable_gsub_multi *subtable = iSubtable_gsub_multi.create();
- otl_Coverage *from = NULL;
- checkLength(offset + 6);
-
- from = Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
- glyphid_t seqCount = read_16u(data + offset + 4);
- if (seqCount != from->numGlyphs) goto FAIL;
- checkLength(offset + 6 + seqCount * 2);
-
- for (glyphid_t j = 0; j < seqCount; j++) {
- uint32_t seqOffset = offset + read_16u(data + offset + 6 + j * 2);
- otl_Coverage *cov = Coverage.create();
- glyphid_t n = read_16u(data + seqOffset);
- for (glyphid_t k = 0; k < n; k++) {
- Coverage.push(cov, Handle.fromIndex(read_16u(data + seqOffset + 2 + k * 2)));
- }
- iSubtable_gsub_multi.push(subtable, ((otl_GsubMultiEntry){
- .from = Handle.dup(from->glyphs[j]), .to = cov,
- }));
- }
- Coverage.free(from);
- return (otl_Subtable *)subtable;
-
-FAIL:
- if (from) Coverage.free(from);
- iSubtable_gsub_multi.free(subtable);
- return NULL;
-}
-
-json_value *otl_gsub_dump_multi(const otl_Subtable *_subtable) {
- const subtable_gsub_multi *subtable = &(_subtable->gsub_multi);
- json_value *st = json_object_new(subtable->length);
- for (glyphid_t j = 0; j < subtable->length; j++) {
- json_object_push(st, subtable->items[j].from.name, Coverage.dump(subtable->items[j].to));
- }
- return st;
-}
-
-otl_Subtable *otl_gsub_parse_multi(const json_value *_subtable, const otfcc_Options *options) {
- subtable_gsub_multi *st = iSubtable_gsub_multi.create();
-
- for (glyphid_t k = 0; k < _subtable->u.object.length; k++) {
- json_value *_to = _subtable->u.object.values[k].value;
- if (!_to || _to->type != json_array) continue;
- iSubtable_gsub_multi.push(
- st, ((otl_GsubMultiEntry){
- .from = Handle.fromName(sdsnewlen(_subtable->u.object.values[k].name,
- _subtable->u.object.values[k].name_length)),
- .to = Coverage.parse(_to),
- }));
- }
-
- return (otl_Subtable *)st;
-}
-
-caryll_Buffer *otfcc_build_gsub_multi_subtable(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- const subtable_gsub_multi *subtable = &(_subtable->gsub_multi);
- otl_Coverage *cov = Coverage.create();
- for (glyphid_t j = 0; j < subtable->length; j++) {
- Coverage.push(cov, Handle.dup(subtable->items[j].from));
- }
-
- bk_Block *root = bk_new_Block(b16, 1, // format
- p16, bk_newBlockFromBuffer(Coverage.build(cov)), // coverage
- b16, subtable->length, // quantity
- bkover);
- for (glyphid_t j = 0; j < subtable->length; j++) {
- bk_Block *b = bk_new_Block(b16, subtable->items[j].to->numGlyphs, bkover);
- for (glyphid_t k = 0; k < subtable->items[j].to->numGlyphs; k++) {
- bk_push(b, b16, subtable->items[j].to->glyphs[k].index, bkover);
- }
- bk_push(root, p16, b, bkover);
- }
- Coverage.free(cov);
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.h
deleted file mode 100644
index bfd4eb7dc5d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-multi.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GSUB_MULTI_H
-#define CARYLL_TABLE_OTL_GSUB_MULTI_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gsub_multi(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gsub_dump_multi(const otl_Subtable *_subtable);
-otl_Subtable *otl_gsub_parse_multi(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gsub_multi_subtable(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.c
deleted file mode 100644
index 023e3d3d6b3..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.c
+++ /dev/null
@@ -1,133 +0,0 @@
-#include "gsub-reverse.h"
-
-static INLINE void initGsubReverse(subtable_gsub_reverse *subtable) {
- subtable->match = NULL;
- subtable->to = NULL;
-}
-static INLINE void disposeGsubReverse(subtable_gsub_reverse *subtable) {
- if (subtable->match)
- for (tableid_t j = 0; j < subtable->matchCount; j++) {
- Coverage.free(subtable->match[j]);
- }
- if (subtable->to) Coverage.free(subtable->to);
-}
-
-caryll_standardRefType(subtable_gsub_reverse, iSubtable_gsub_reverse, initGsubReverse,
- disposeGsubReverse);
-
-static void reverseBacktracks(otl_Coverage **match, tableid_t inputIndex) {
- if (inputIndex > 0) {
- tableid_t start = 0;
- tableid_t end = inputIndex - 1;
- while (end > start) {
- otl_Coverage *tmp = match[start];
- match[start] = match[end];
- match[end] = tmp;
- end--, start++;
- }
- }
-}
-
-otl_Subtable *otl_read_gsub_reverse(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- subtable_gsub_reverse *subtable = iSubtable_gsub_reverse.create();
- checkLength(offset + 6);
-
- tableid_t nBacktrack = read_16u(data + offset + 4);
- checkLength(offset + 6 + nBacktrack * 2);
-
- tableid_t nForward = read_16u(data + offset + 6 + nBacktrack * 2);
- checkLength(offset + 8 + (nBacktrack + nForward) * 2);
-
- tableid_t nReplacement = read_16u(data + offset + 8 + (nBacktrack + nForward) * 2);
- checkLength(offset + 10 + (nBacktrack + nForward + nReplacement) * 2);
-
- subtable->matchCount = nBacktrack + nForward + 1;
- NEW(subtable->match, subtable->matchCount);
- subtable->inputIndex = nBacktrack;
-
- for (tableid_t j = 0; j < nBacktrack; j++) {
- uint32_t covOffset = offset + read_16u(data + offset + 6 + j * 2);
- subtable->match[j] = Coverage.read(data, tableLength, covOffset);
- }
- {
- uint32_t covOffset = offset + read_16u(data + offset + 2);
- subtable->match[subtable->inputIndex] = Coverage.read(data, tableLength, covOffset);
- if (nReplacement != subtable->match[subtable->inputIndex]->numGlyphs) goto FAIL;
- }
- for (tableid_t j = 0; j < nForward; j++) {
- uint32_t covOffset = offset + read_16u(data + offset + 8 + nBacktrack * 2 + j * 2);
- subtable->match[nBacktrack + 1 + j] = Coverage.read(data, tableLength, covOffset);
- }
-
- NEW(subtable->to);
- subtable->to->numGlyphs = nReplacement;
- NEW(subtable->to->glyphs, nReplacement);
- for (tableid_t j = 0; j < nReplacement; j++) {
- subtable->to->glyphs[j] =
- Handle.fromIndex(read_16u(data + offset + 10 + (nBacktrack + nForward + j) * 2));
- }
- reverseBacktracks(subtable->match, subtable->inputIndex);
- return (otl_Subtable *)subtable;
-
-FAIL:
- iSubtable_gsub_reverse.free(subtable);
- return NULL;
-}
-
-json_value *otl_gsub_dump_reverse(const otl_Subtable *_subtable) {
- const subtable_gsub_reverse *subtable = &(_subtable->gsub_reverse);
- json_value *_st = json_object_new(3);
- json_value *_match = json_array_new(subtable->matchCount);
- for (tableid_t j = 0; j < subtable->matchCount; j++) {
- json_array_push(_match, Coverage.dump(subtable->match[j]));
- }
- json_object_push(_st, "match", _match);
- json_object_push(_st, "to", Coverage.dump(subtable->to));
- json_object_push(_st, "inputIndex", json_integer_new(subtable->inputIndex));
- return _st;
-}
-
-otl_Subtable *otl_gsub_parse_reverse(const json_value *_subtable, const otfcc_Options *options) {
- json_value *_match = json_obj_get_type(_subtable, "match", json_array);
- json_value *_to = json_obj_get_type(_subtable, "to", json_array);
- if (!_match || !_to) return NULL;
-
- subtable_gsub_reverse *subtable = iSubtable_gsub_reverse.create();
-
- subtable->matchCount = _match->u.array.length;
- NEW(subtable->match, subtable->matchCount);
-
- subtable->inputIndex = json_obj_getnum_fallback(_subtable, "inputIndex", 0);
-
- for (tableid_t j = 0; j < subtable->matchCount; j++) {
- subtable->match[j] = Coverage.parse(_match->u.array.values[j]);
- }
- subtable->to = Coverage.parse(_to);
- return (otl_Subtable *)subtable;
-}
-
-caryll_Buffer *otfcc_build_gsub_reverse(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- const subtable_gsub_reverse *subtable = &(_subtable->gsub_reverse);
- reverseBacktracks(subtable->match, subtable->inputIndex);
-
- bk_Block *root = bk_new_Block(b16, 1, // format
- p16, bk_newBlockFromBuffer(Coverage.build(
- subtable->match[subtable->inputIndex])), // coverage
- bkover);
- bk_push(root, b16, subtable->inputIndex, bkover);
- for (tableid_t j = 0; j < subtable->inputIndex; j++) {
- bk_push(root, p16, bk_newBlockFromBuffer(Coverage.build(subtable->match[j])), bkover);
- }
- bk_push(root, b16, subtable->matchCount - subtable->inputIndex - 1, bkover);
- for (tableid_t j = subtable->inputIndex + 1; j < subtable->matchCount; j++) {
- bk_push(root, p16, bk_newBlockFromBuffer(Coverage.build(subtable->match[j])), bkover);
- }
- bk_push(root, b16, subtable->to->numGlyphs, bkover);
- for (tableid_t j = 0; j < subtable->to->numGlyphs; j++) {
- bk_push(root, b16, subtable->to->glyphs[j].index, bkover);
- }
-
- return bk_build_Block(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.h
deleted file mode 100644
index 001b2a0cabc..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-reverse.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GSUB_REVERSE_H
-#define CARYLL_TABLE_OTL_GSUB_REVERSE_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gsub_reverse(const font_file_pointer data, uint32_t tableLength,
- uint32_t offset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gsub_dump_reverse(const otl_Subtable *_subtable);
-otl_Subtable *otl_gsub_parse_reverse(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gsub_reverse(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.c
deleted file mode 100644
index fa1ac665ade..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.c
+++ /dev/null
@@ -1,139 +0,0 @@
-#include "gsub-single.h"
-
-static void gss_entry_ctor(MODIFY otl_GsubSingleEntry *entry) {
- entry->from = Handle.empty();
- entry->to = Handle.empty();
-}
-static void gss_entry_copyctor(MODIFY otl_GsubSingleEntry *dst,
- COPY const otl_GsubSingleEntry *src) {
- dst->from = Handle.dup(src->from);
- dst->to = Handle.dup(src->to);
-}
-static void gss_entry_dtor(MODIFY otl_GsubSingleEntry *entry) {
- Handle.dispose(&entry->from);
- Handle.dispose(&entry->to);
-}
-
-static caryll_ElementInterface(otl_GsubSingleEntry) gss_typeinfo = {
- .init = gss_entry_ctor, .copy = gss_entry_copyctor, .dispose = gss_entry_dtor};
-
-caryll_standardVectorImpl(subtable_gsub_single, otl_GsubSingleEntry, gss_typeinfo,
- iSubtable_gsub_single);
-
-otl_Subtable *otl_read_gsub_single(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options) {
- subtable_gsub_single *subtable = iSubtable_gsub_single.create();
- otl_Coverage *from = NULL;
- otl_Coverage *to = NULL;
- if (tableLength < subtableOffset + 6) goto FAIL;
-
- uint16_t subtableFormat = read_16u(data + subtableOffset);
- from = Coverage.read(data, tableLength, subtableOffset + read_16u(data + subtableOffset + 2));
- if (!from || from->numGlyphs == 0) goto FAIL;
-
- if (subtableFormat == 1) {
- NEW(to);
- to->numGlyphs = from->numGlyphs;
- NEW(to->glyphs, to->numGlyphs);
-
- uint16_t delta = read_16u(data + subtableOffset + 4);
- for (glyphid_t j = 0; j < from->numGlyphs; j++) {
- to->glyphs[j] = Handle.fromIndex(from->glyphs[j].index + delta);
- }
- } else {
- glyphid_t toglyphs = read_16u(data + subtableOffset + 4);
- if (tableLength < subtableOffset + 6 + toglyphs * 2 || toglyphs != from->numGlyphs)
- goto FAIL;
- NEW(to);
- to->numGlyphs = toglyphs;
- NEW(to->glyphs, to->numGlyphs);
-
- for (glyphid_t j = 0; j < to->numGlyphs; j++) {
- to->glyphs[j] = Handle.fromIndex(read_16u(data + subtableOffset + 6 + j * 2));
- }
- }
- goto OK;
-FAIL:
- iSubtable_gsub_single.free(subtable);
- if (from) Coverage.free(from);
- if (to) Coverage.free(to);
- return NULL;
-OK:
- for (glyphid_t j = 0; j < from->numGlyphs; j++) {
- iSubtable_gsub_single.push(subtable, ((otl_GsubSingleEntry){
- .from = Handle.dup(from->glyphs[j]), // from
- .to = Handle.dup(to->glyphs[j]), // to
- }));
- }
- if (from) Coverage.free(from);
- if (to) Coverage.free(to);
- return (otl_Subtable *)subtable;
-}
-
-json_value *otl_gsub_dump_single(const otl_Subtable *_subtable) {
- const subtable_gsub_single *subtable = &(_subtable->gsub_single);
- json_value *st = json_object_new(subtable->length);
- for (size_t j = 0; j < subtable->length; j++) {
- json_object_push(st, subtable->items[j].from.name,
- json_string_new(subtable->items[j].to.name));
- }
- return st;
-}
-
-otl_Subtable *otl_gsub_parse_single(const json_value *_subtable, const otfcc_Options *options) {
- subtable_gsub_single *subtable = iSubtable_gsub_single.create();
- for (glyphid_t j = 0; j < _subtable->u.object.length; j++) {
- if (_subtable->u.object.values[j].value &&
- _subtable->u.object.values[j].value->type == json_string) {
- glyph_handle from = Handle.fromName(sdsnewlen(
- _subtable->u.object.values[j].name, _subtable->u.object.values[j].name_length));
- glyph_handle to =
- Handle.fromName(sdsnewlen(_subtable->u.object.values[j].value->u.string.ptr,
- _subtable->u.object.values[j].value->u.string.length));
- iSubtable_gsub_single.push(subtable, ((otl_GsubSingleEntry){.from = from, .to = to}));
- }
- }
- return (otl_Subtable *)subtable;
-};
-
-caryll_Buffer *otfcc_build_gsub_single_subtable(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics) {
- const subtable_gsub_single *subtable = &(_subtable->gsub_single);
- bool isConstantDifference = subtable->length > 0;
- if (isConstantDifference) {
- int32_t difference = subtable->items[0].to.index - subtable->items[0].from.index;
- isConstantDifference = isConstantDifference && difference < 0x8000 && difference > -0x8000;
- for (glyphid_t j = 1; j < subtable->length; j++) {
- int32_t diffJ = subtable->items[j].to.index - subtable->items[j].from.index;
- isConstantDifference = isConstantDifference && diffJ == difference
- && diffJ < 0x8000 && diffJ > -0x8000;
- }
- }
- otl_Coverage *cov = Coverage.create();
- for (glyphid_t j = 0; j < subtable->length; j++) {
- Coverage.push(cov, Handle.dup(subtable->items[j].from));
- }
-
- caryll_Buffer *coverageBuf = Coverage.buildFormat(cov, heuristics & OTL_BH_GSUB_VERT ? 1 : 0);
-
- if (isConstantDifference && !(heuristics & OTL_BH_GSUB_VERT)) {
- bk_Block *b =
- bk_new_Block(b16, 1, // Format
- p16, bk_newBlockFromBuffer(coverageBuf), // coverage
- b16,
- subtable->items[0].to.index - subtable->items[0].from.index, // delta
- bkover);
- Coverage.free(cov);
- return bk_build_Block(b);
- } else {
- bk_Block *b = bk_new_Block(b16, 2, // Format
- p16, bk_newBlockFromBuffer(coverageBuf), // coverage
- b16, subtable->length, // quantity
- bkover);
- for (glyphid_t k = 0; k < subtable->length; k++) {
- bk_push(b, b16, subtable->items[k].to.index, bkover);
- }
- Coverage.free(cov);
- return bk_build_Block(b);
- }
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.h
deleted file mode 100644
index 0991639b993..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/gsub-single.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CARYLL_TABLE_OTL_GSUB_SINGLE_H
-#define CARYLL_TABLE_OTL_GSUB_SINGLE_H
-
-#include "common.h"
-
-otl_Subtable *otl_read_gsub_single(const font_file_pointer data, uint32_t tableLength,
- uint32_t subtableOffset, const glyphid_t maxGlyphs,
- const otfcc_Options *options);
-json_value *otl_gsub_dump_single(const otl_Subtable *_subtable);
-otl_Subtable *otl_gsub_parse_single(const json_value *_subtable, const otfcc_Options *options);
-caryll_Buffer *otfcc_build_gsub_single_subtable(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.c
deleted file mode 100644
index 99a7f60442d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.c
+++ /dev/null
@@ -1,140 +0,0 @@
-#include "post.h"
-
-#include "support/util.h"
-
-// clang-format off
-static const char *standardMacNames[258] = {".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dcroat"};
-
-// clang-format on
-
-static INLINE void initPost(table_post *post) {
- memset(post, 0, sizeof(*post));
- post->version = 0x30000;
-}
-static INLINE void disposePost(MOVE table_post *post) {
- if (post->post_name_map != NULL) { GlyphOrder.free(post->post_name_map); }
-}
-
-caryll_standardRefType(table_post, iTable_post, initPost, disposePost);
-
-table_post *otfcc_readPost(const otfcc_Packet packet, const otfcc_Options *options) {
- FOR_TABLE(OTFCC_CHR('p','o','s','t'), table) {
- font_file_pointer data = table.data;
-
- table_post *post = iTable_post.create();
- post->version = read_32s(data);
- post->italicAngle = read_32u(data + 4);
- post->underlinePosition = read_16u(data + 8);
- post->underlineThickness = read_16u(data + 10);
- post->isFixedPitch = read_32u(data + 12);
- post->minMemType42 = read_32u(data + 16);
- post->maxMemType42 = read_32u(data + 20);
- post->minMemType1 = read_32u(data + 24);
- post->maxMemType1 = read_32u(data + 28);
- post->post_name_map = NULL;
- // Foamt 2 additional glyph names
- if (post->version == 0x20000) {
- otfcc_GlyphOrder *map = GlyphOrder.create();
-
- sds pendingNames[0x10000];
- memset(pendingNames, 0, sizeof(pendingNames));
- uint16_t numberGlyphs = read_16u(data + 32);
- uint32_t offset = 34 + 2 * numberGlyphs;
- uint16_t pendingNameIndex = 0;
- while (pendingNameIndex <= 0xFFFF && offset < table.length) {
- uint8_t len = data[offset];
- sds s;
- if (len > 0) {
- s = sdsnewlen(data + offset + 1, len);
- } else {
- s = sdsempty();
- }
- offset += len + 1;
- pendingNames[pendingNameIndex] = s;
- pendingNameIndex += 1;
- }
- for (uint16_t j = 0; j < numberGlyphs; j++) {
- uint16_t nameMap = read_16u(data + 34 + 2 * j);
- if (nameMap >= 258) { // Custom glyph name
- GlyphOrder.setByGID(map, j, sdsdup(pendingNames[nameMap - 258]));
- } else { // Standard Macintosh glyph name
- GlyphOrder.setByGID(map, j, sdsnew(standardMacNames[nameMap]));
- }
- }
- for (uint32_t j = 0; j < pendingNameIndex; j++) {
- sdsfree(pendingNames[j]);
- }
- post->post_name_map = map;
- }
- return post;
- }
- return NULL;
-}
-
-void otfcc_dumpPost(const table_post *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- loggedStep("post") {
- json_value *post = json_object_new(10);
- json_object_push(post, "version", json_double_new(otfcc_from_fixed(table->version)));
- json_object_push(post, "italicAngle",
- json_integer_new(otfcc_from_fixed(table->italicAngle)));
- json_object_push(post, "underlinePosition", json_integer_new(table->underlinePosition));
- json_object_push(post, "underlineThickness", json_integer_new(table->underlineThickness));
- json_object_push(post, "isFixedPitch", json_boolean_new(table->isFixedPitch));
- json_object_push(post, "minMemType42", json_integer_new(table->minMemType42));
- json_object_push(post, "maxMemType42", json_integer_new(table->maxMemType42));
- json_object_push(post, "minMemType1", json_integer_new(table->minMemType1));
- json_object_push(post, "maxMemType1", json_integer_new(table->maxMemType1));
- json_object_push(root, "post", post);
- }
-}
-table_post *otfcc_parsePost(const json_value *root, const otfcc_Options *options) {
- table_post *post = iTable_post.create();
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "post", json_object))) {
- loggedStep("post") {
- if (options->short_post) {
- post->version = 0x30000;
- } else {
- post->version = otfcc_to_fixed(json_obj_getnum(table, "version"));
- }
- post->italicAngle = otfcc_to_fixed(json_obj_getnum(table, "italicAngle"));
- post->underlinePosition = json_obj_getnum(table, "underlinePosition");
- post->underlineThickness = json_obj_getnum(table, "underlineThickness");
- post->isFixedPitch = json_obj_getbool(table, "isFixedPitch");
- post->minMemType42 = json_obj_getnum(table, "minMemType42");
- post->maxMemType42 = json_obj_getnum(table, "maxMemType42");
- post->minMemType1 = json_obj_getnum(table, "minMemType1");
- post->maxMemType1 = json_obj_getnum(table, "maxMemType1");
- }
- }
- return post;
-}
-caryll_Buffer *otfcc_buildPost(const table_post *post, otfcc_GlyphOrder *glyphorder,
- const otfcc_Options *options) {
- if (!post) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite32b(buf, post->version);
- bufwrite32b(buf, post->italicAngle);
- bufwrite16b(buf, post->underlinePosition);
- bufwrite16b(buf, post->underlineThickness);
- bufwrite32b(buf, post->isFixedPitch);
- bufwrite32b(buf, post->minMemType42);
- bufwrite32b(buf, post->maxMemType42);
- bufwrite32b(buf, post->minMemType1);
- bufwrite32b(buf, post->maxMemType1);
- if (post->version == 0x20000) {
- bufwrite16b(buf, HASH_CNT(hhName, glyphorder->byName));
- // Since the glyphorder is already sorted using the "real" glyph order
- // we can simply write down the glyph names.
- otfcc_GlyphOrderEntry *s, *tmp;
- HASH_ITER(hhName, glyphorder->byName, s, tmp) {
- bufwrite16b(buf, 258 + s->gid);
- }
- HASH_ITER(hhName, glyphorder->byName, s, tmp) {
- bufwrite8(buf, sdslen(s->name));
- bufwrite_sds(buf, s->name);
- }
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.h
deleted file mode 100644
index 8b244446400..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/post.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_POST_H
-#define CARYLL_TABLE_POST_H
-
-#include "otfcc/table/post.h"
-
-table_post *otfcc_readPost(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpPost(const table_post *table, json_value *root, const otfcc_Options *options);
-table_post *otfcc_parsePost(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildPost(const table_post *post, otfcc_GlyphOrder *glyphorder, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/funcs.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/funcs.c
deleted file mode 100644
index ec6d0691b43..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/funcs.c
+++ /dev/null
@@ -1,150 +0,0 @@
-#include "../VDMX.h"
-
-#include "support/util.h"
-#include "bk/bkgraph.h"
-
-table_VDMX *otfcc_readVDMX(const otfcc_Packet packet, const otfcc_Options *options) {
- table_VDMX *vdmx = NULL;
- FOR_TABLE(OTFCC_CHR('V','D','M','X'), table) {
- if (table.length < 6) goto FAIL;
- uint16_t version = read_16u(table.data + 0);
- uint16_t numRatios = read_16u(table.data + 4);
- if (table.length < 6 + 6 * numRatios) goto FAIL;
-
- vdmx = table_iVDMX.create();
- vdmx->version = version;
- for (shapeid_t g = 0; g < numRatios; g++) {
- const size_t ratioRangeOffset = 6 + 4 * g;
- const size_t offsetOffset = 6 + 4 * numRatios + 2 * g;
- vdmx_RatioRange r;
- vdmx_iRatioRange.init(&r);
- r.bCharset = read_8u(table.data + ratioRangeOffset + 0);
- r.xRatio = read_8u(table.data + ratioRangeOffset + 1);
- r.yStartRatio = read_8u(table.data + ratioRangeOffset + 2);
- r.yEndRatio = read_8u(table.data + ratioRangeOffset + 3);
-
- uint16_t groupOffset = read_16u(table.data + offsetOffset);
- uint16_t recs = read_16u(table.data + groupOffset + 0);
- for (uint16_t j = 0; j < recs; j++) {
- uint16_t yPelHeight = read_16u(table.data + groupOffset + 4 + j * 6 + 0);
- int16_t yMax = read_16s(table.data + groupOffset + 4 + j * 6 + 2);
- int16_t yMin = read_16s(table.data + groupOffset + 4 + j * 6 + 4);
- vdmx_iGroup.push(&r.records, (vdmx_Record){
- .yPelHeight = yPelHeight,
- .yMax = yMax,
- .yMin = yMin,
- });
- }
- vdmx_iRatioRangeList.push(&vdmx->ratios, r);
- }
- return vdmx;
- FAIL:
- logWarning("Table 'VDMX' corrupted.\n");
- table_iVDMX.free(vdmx);
- vdmx = NULL;
- }
- return vdmx;
-}
-
-void otfcc_dumpVDMX(const table_VDMX *vdmx, json_value *root, const otfcc_Options *options) {
- if (!vdmx) return;
- loggedStep("VDMX") {
- json_value *_vdmx = json_object_new(2);
- json_object_push(_vdmx, "version", json_integer_new(vdmx->version));
-
- json_value *_ratios = json_array_new(vdmx->ratios.length);
- json_object_push(_vdmx, "ratios", _ratios);
- foreach (vdmx_RatioRange *rr, vdmx->ratios) {
- json_value *_rr = json_object_new(5);
- json_array_push(_ratios, _rr);
- json_object_push(_rr, "bCharset", json_integer_new(rr->bCharset));
- json_object_push(_rr, "xRatio", json_integer_new(rr->xRatio));
- json_object_push(_rr, "yStartRatio", json_integer_new(rr->yStartRatio));
- json_object_push(_rr, "yEndRatio", json_integer_new(rr->yEndRatio));
-
- json_value *_records = json_array_new(rr->records.length);
- json_object_push(_rr, "records", _records);
- foreach (vdmx_Record *r, rr->records) {
- json_value *_r = json_object_new(3);
- json_array_push(_records, _r);
- json_object_push(_r, "yPelHeight", json_integer_new(r->yPelHeight));
- json_object_push(_r, "yMax", json_integer_new(r->yMax));
- json_object_push(_r, "yMin", json_integer_new(r->yMin));
- }
- }
- json_object_push(root, "VDMX", _vdmx);
- }
-}
-
-table_VDMX *otfcc_parseVDMX(const json_value *root, const otfcc_Options *options) {
- json_value *_vdmx = NULL;
- if (!(_vdmx = json_obj_get_type(root, "VDMX", json_object))) return NULL;
- table_VDMX *vdmx = table_iVDMX.create();
- loggedStep("VDMX") {
- vdmx->version = json_obj_getnum(_vdmx, "version");
- json_value *_ratios = json_obj_get_type(_vdmx, "ratios", json_array);
- for (size_t j = 0; j < _ratios->u.array.length; j++) {
- json_value *_rr = _ratios->u.array.values[j];
- if (!_rr || _rr->type != json_object) continue;
- vdmx_RatioRange r;
- vdmx_iRatioRange.init(&r);
- r.bCharset = json_obj_getnum(_rr, "bCharset");
- r.xRatio = json_obj_getnum(_rr, "xRatio");
- r.yStartRatio = json_obj_getnum(_rr, "yStartRatio");
- r.yEndRatio = json_obj_getnum(_rr, "yEndRatio");
- json_value *_records = json_obj_get_type(_rr, "records", json_array);
- if (!_records) {
- vdmx_iRatioRange.dispose(&r);
- continue;
- }
- for (size_t j = 0; j < _records->u.array.length; j++) {
- json_value *_r = _records->u.array.values[j];
- if (!_r || _r->type != json_object) continue;
- vdmx_iGroup.push(&r.records, (vdmx_Record){
- .yPelHeight = json_obj_getnum(_r, "yPelHeight"),
- .yMax = json_obj_getnum(_r, "yMax"),
- .yMin = json_obj_getnum(_r, "yMin"),
- });
- }
- vdmx_iRatioRangeList.push(&vdmx->ratios, r);
- }
- }
- return vdmx;
-}
-
-caryll_Buffer *otfcc_buildVDMX(const table_VDMX *vdmx, const otfcc_Options *options) {
- if (!vdmx || !vdmx->ratios.length) return NULL;
- bk_Block *root = bk_new_Block(b16, vdmx->version, // Version
- b16, vdmx->ratios.length, // numRecs
- b16, vdmx->ratios.length, // numRatios
- bkover);
- foreach (vdmx_RatioRange *rr, vdmx->ratios) {
- bk_push(root, // RatioRange
- b8, rr->bCharset, // bCharset
- b8, rr->xRatio, // bCharset
- b8, rr->yStartRatio, // bCharset
- b8, rr->yEndRatio, // bCharset
- bkover);
- }
- foreach (vdmx_RatioRange *rr, vdmx->ratios) {
- uint16_t startsz = 0xFFFF;
- uint16_t endsz = 0;
- foreach (vdmx_Record *r, rr->records) {
- if (startsz > r->yPelHeight) startsz = r->yPelHeight;
- if (endsz < r->yPelHeight) endsz = r->yPelHeight;
- }
- bk_Block *group = bk_new_Block(b16, rr->records.length, // recs
- b8, startsz, //
- b8, endsz, //
- bkover);
- foreach (vdmx_Record *r, rr->records) {
- bk_push(group, //
- b16, r->yPelHeight, //
- b16, r->yMax, //
- b16, r->yMin, //
- bkover);
- }
- bk_push(root, p16, group, bkover);
- }
- return bk_build_Block_noMinimize(root);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/type.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/type.c
deleted file mode 100644
index 3607de42000..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vdmx/type.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "../VDMX.h"
-
-#include "support/util.h"
-
-caryll_standardValType(vdmx_Record, vdmx_iRecord);
-
-caryll_standardVectorImpl(vdmx_Group, vdmx_Record, vdmx_iRecord, vdmx_iGroup);
-
-static void initRR(vdmx_RatioRange *rr) {
- memset(rr, 0, sizeof(*rr));
- vdmx_iGroup.init(&rr->records);
-}
-
-static void disposeRR(vdmx_RatioRange *rr) {
- vdmx_iGroup.dispose(&rr->records);
-}
-
-caryll_standardType(vdmx_RatioRange, vdmx_iRatioRange, initRR, disposeRR);
-caryll_standardVectorImpl(vdmx_RatioRagneList, vdmx_RatioRange, vdmx_iRatioRange,
- vdmx_iRatioRangeList);
-
-static void initVDMX(table_VDMX *t) {
- vdmx_iRatioRangeList.init(&t->ratios);
-}
-static void disposeVDMX(table_VDMX *t) {
- vdmx_iRatioRangeList.dispose(&t->ratios);
-}
-caryll_standardRefType(table_VDMX, table_iVDMX, initVDMX, disposeVDMX);
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.c
deleted file mode 100644
index e7bf8796da6..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "vhea.h"
-
-#include "support/util.h"
-
-static INLINE void initVhea(table_vhea *vhea) {
- memset(vhea, 0, sizeof(*vhea));
- vhea->version = 0x10000;
-}
-static INLINE void disposeVhea(MOVE table_vhea *vhea) {
- // trivial
-}
-caryll_standardRefType(table_vhea, table_iVhea, initVhea, disposeVhea);
-
-table_vhea *otfcc_readVhea(const otfcc_Packet packet, const otfcc_Options *options) {
- table_vhea *vhea = NULL;
- FOR_TABLE(OTFCC_CHR('v','h','e','a'), table) {
- font_file_pointer data = table.data;
- size_t length = table.length;
- if (length >= 36) {
- NEW(vhea);
- vhea->version = read_32s(data);
- vhea->ascent = read_16s(data + 4);
- vhea->descent = read_16s(data + 6);
- vhea->lineGap = read_16s(data + 8);
- vhea->advanceHeightMax = read_16s(data + 10);
- vhea->minTop = read_16s(data + 12);
- vhea->minBottom = read_16s(data + 14);
- vhea->yMaxExtent = read_16s(data + 16);
- vhea->caretSlopeRise = read_16s(data + 18);
- vhea->caretSlopeRun = read_16s(data + 20);
- vhea->caretOffset = read_16s(data + 22);
- vhea->dummy0 = 0;
- vhea->dummy1 = 0;
- vhea->dummy2 = 0;
- vhea->dummy3 = 0;
- vhea->metricDataFormat = 0;
- vhea->numOfLongVerMetrics = read_16u(data + 34);
- return vhea;
- } else {
- logWarning("Table 'vhea' corrupted.")
- }
- }
- return NULL;
-}
-void otfcc_dumpVhea(const table_vhea *table, json_value *root, const otfcc_Options *options) {
- if (!table) return;
- json_value *vhea = json_object_new(11);
- loggedStep("vhea") {
- json_object_push(vhea, "version", json_double_new(otfcc_from_fixed(table->version)));
- json_object_push(vhea, "ascent", json_integer_new(table->ascent));
- json_object_push(vhea, "descent", json_integer_new(table->descent));
- json_object_push(vhea, "lineGap", json_integer_new(table->lineGap));
- json_object_push(vhea, "advanceHeightMax", json_integer_new(table->advanceHeightMax));
- json_object_push(vhea, "minTop", json_integer_new(table->minTop));
- json_object_push(vhea, "minBottom", json_integer_new(table->minBottom));
- json_object_push(vhea, "yMaxExtent", json_integer_new(table->yMaxExtent));
- json_object_push(vhea, "caretSlopeRise", json_integer_new(table->caretSlopeRise));
- json_object_push(vhea, "caretSlopeRun", json_integer_new(table->caretSlopeRun));
- json_object_push(vhea, "caretOffset", json_integer_new(table->caretOffset));
- json_object_push(root, "vhea", vhea);
- }
-}
-
-table_vhea *otfcc_parseVhea(const json_value *root, const otfcc_Options *options) {
- table_vhea *vhea = NULL;
- json_value *table = NULL;
- if ((table = json_obj_get_type(root, "vhea", json_object))) {
- vhea = table_iVhea.create();
- if (!vhea) return NULL;
- loggedStep("vhea") {
- vhea->version = otfcc_to_fixed(json_obj_getnum(table, "version"));
- vhea->ascent = json_obj_getnum_fallback(table, "ascent", 0);
- vhea->descent = json_obj_getnum_fallback(table, "descent", 0);
- vhea->lineGap = json_obj_getnum_fallback(table, "lineGap", 0);
- vhea->advanceHeightMax = json_obj_getnum_fallback(table, "advanceHeightMax", 0);
- vhea->minTop = json_obj_getnum_fallback(table, "minTop", 0);
- vhea->minBottom = json_obj_getnum_fallback(table, "minBottom", 0);
- vhea->yMaxExtent = json_obj_getnum_fallback(table, "yMaxExtent", 0);
- vhea->caretSlopeRise = json_obj_getnum_fallback(table, "caretSlopeRise", 0);
- vhea->caretSlopeRun = json_obj_getnum_fallback(table, "caretSlopeRun", 0);
- vhea->caretOffset = json_obj_getnum_fallback(table, "caretOffset", 0);
- }
- }
- return vhea;
-}
-
-caryll_Buffer *otfcc_buildVhea(const table_vhea *vhea, const otfcc_Options *options) {
- if (!vhea) return NULL;
- caryll_Buffer *buf = bufnew();
- bufwrite32b(buf, vhea->version);
- bufwrite16b(buf, vhea->ascent);
- bufwrite16b(buf, vhea->descent);
- bufwrite16b(buf, vhea->lineGap);
- bufwrite16b(buf, vhea->advanceHeightMax);
- bufwrite16b(buf, vhea->minTop);
- bufwrite16b(buf, vhea->minBottom);
- bufwrite16b(buf, vhea->yMaxExtent);
- bufwrite16b(buf, vhea->caretSlopeRise);
- bufwrite16b(buf, vhea->caretSlopeRun);
- bufwrite16b(buf, vhea->caretOffset);
- bufwrite16b(buf, 0);
- bufwrite16b(buf, 0);
- bufwrite16b(buf, 0);
- bufwrite16b(buf, 0);
- bufwrite16b(buf, 0);
- bufwrite16b(buf, vhea->numOfLongVerMetrics);
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.h
deleted file mode 100644
index 3e692a5a455..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vhea.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef CARYLL_TABLE_VHEA_H
-#define CARYLL_TABLE_VHEA_H
-
-#include "otfcc/table/vhea.h"
-
-table_vhea *otfcc_readVhea(const otfcc_Packet packet, const otfcc_Options *options);
-void otfcc_dumpVhea(const table_vhea *table, json_value *root, const otfcc_Options *options);
-table_vhea *otfcc_parseVhea(const json_value *root, const otfcc_Options *options);
-caryll_Buffer *otfcc_buildVhea(const table_vhea *vhea, const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.c
deleted file mode 100644
index 471ca273f65..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "vmtx.h"
-
-#include "support/util.h"
-
-static INLINE void disposeVmtx(MOVE table_vmtx *table) {
- if (table->metrics != NULL) FREE(table->metrics);
- if (table->topSideBearing != NULL) FREE(table->topSideBearing);
-}
-
-caryll_standardRefType(table_vmtx, table_iVmtx, disposeVmtx);
-
-table_vmtx *otfcc_readVmtx(const otfcc_Packet packet, const otfcc_Options *options,
- table_vhea *vhea, table_maxp *maxp) {
- if (!vhea || !maxp || vhea->numOfLongVerMetrics == 0 ||
- maxp->numGlyphs < vhea->numOfLongVerMetrics)
- return NULL;
- FOR_TABLE(OTFCC_CHR('v','m','t','x'), table) {
- font_file_pointer data = table.data;
- uint32_t length = table.length;
-
- table_vmtx *vmtx = NULL;
-
- glyphid_t count_a = vhea->numOfLongVerMetrics;
- glyphid_t count_k = maxp->numGlyphs - vhea->numOfLongVerMetrics;
- if (length < count_a * 4 + count_k * 2) goto vmtx_CORRUPTED;
-
- NEW(vmtx);
- NEW(vmtx->metrics, count_a);
- NEW(vmtx->topSideBearing, count_k);
-
- for (glyphid_t ia = 0; ia < count_a; ia++) {
- vmtx->metrics[ia].advanceHeight = read_16u(data + ia * 4);
- vmtx->metrics[ia].tsb = read_16s(data + ia * 4 + 2);
- }
-
- for (glyphid_t ik = 0; ik < count_k; ik++) {
- vmtx->topSideBearing[ik] = read_16s(data + count_a * 4 + ik * 2);
- }
-
- return vmtx;
- vmtx_CORRUPTED:
- logWarning("Table 'vmtx' corrupted.\n");
- if (vmtx) { table_iVmtx.free(vmtx), vmtx = NULL; }
- }
- return NULL;
-}
-
-caryll_Buffer *otfcc_buildVmtx(const table_vmtx *vmtx, glyphid_t count_a, glyphid_t count_k,
- const otfcc_Options *options) {
- if (!vmtx) return NULL;
- caryll_Buffer *buf = bufnew();
- if (vmtx->metrics) {
- for (glyphid_t j = 0; j < count_a; j++) {
- bufwrite16b(buf, vmtx->metrics[j].advanceHeight);
- bufwrite16b(buf, vmtx->metrics[j].tsb);
- }
- }
- if (vmtx->topSideBearing) {
- for (glyphid_t j = 0; j < count_k; j++) {
- bufwrite16b(buf, vmtx->topSideBearing[j]);
- }
- }
- return buf;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.h
deleted file mode 100644
index 10c8b50e306..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/table/vmtx.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef CARYLL_TABLE_VMTX_H
-#define CARYLL_TABLE_VMTX_H
-
-#include "otfcc/table/vmtx.h"
-
-table_vmtx *otfcc_readVmtx(const otfcc_Packet packet, const otfcc_Options *options, table_vhea *vhea, table_maxp *maxp);
-caryll_Buffer *otfcc_buildVmtx(const table_vmtx *table, glyphid_t count_a, glyphid_t count_k,
- const otfcc_Options *options);
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/axis.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/axis.c
deleted file mode 100644
index 60d76e215d8..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/axis.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "otfcc/vf/axis.h"
-#include "support/util.h"
-
-caryll_standardValType(vf_Axis, vf_iAxis);
-caryll_standardVectorImpl(vf_Axes, vf_Axis, vf_iAxis, vf_iAxes);
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/region.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/region.c
deleted file mode 100644
index 61301273ad0..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/region.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "otfcc/vf/axis.h"
-#include "support/util.h"
-
-vq_Region *vq_createRegion(shapeid_t dimensions) {
- vq_Region *r;
- NEW_CLEAN_S(r, (VQ_REGION_SIZE(dimensions)));
- r->dimensions = dimensions;
- return r;
-}
-
-void vq_deleteRegion(MOVE vq_Region *region) {
- FREE(region);
-}
-
-vq_Region *vq_copyRegion(const vq_Region *region) {
- vq_Region *dst = vq_createRegion(region->dimensions);
- memcpy(dst, region, VQ_REGION_SIZE(region->dimensions));
- return dst;
-}
-
-int vq_compareRegion(const vq_Region *a, const vq_Region *b) {
- if (a->dimensions < b->dimensions) return -1;
- if (a->dimensions > b->dimensions) return 1;
- return strncmp((const char *)a, (const char *)b, VQ_REGION_SIZE(a->dimensions));
-}
-
-bool vq_AxisSpanIsOne(const vq_AxisSpan *s) {
- const pos_t a = s->start;
- const pos_t p = s->peak;
- const pos_t z = s->end;
- return a > p || p > z || (a < 0 && z > 0 && p != 0) || (p == 0);
-}
-
-static pos_t INLINE weightAxisRegion(const vq_AxisSpan *as, const pos_t x) {
- const pos_t a = as->start;
- const pos_t p = as->peak;
- const pos_t z = as->end;
- if (a > p || p > z) {
- return 1;
- } else if (a < 0 && z > 0 && p != 0) {
- return 1;
- } else if (p == 0) {
- return 1;
- } else if (x < a || x > z) {
- return 0;
- } else if (x == p) {
- return 1;
- } else if (x < p) {
- return (x - a) / (p - a);
- } else {
- return (z - x) / (z - p);
- }
-}
-//static pos_t vqRegionGetWeight(const vq_Region *r, const VV *v) {
-// pos_t w = 1;
-// for (size_t j = 0; j < r->dimensions && v->length; j++) {
-// w *= weightAxisRegion(&r->spans[j], v->items[j]);
-// }
-// return w;
-//}
-
-void vq_showRegion(const vq_Region *r) {}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/vq.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/vq.c
deleted file mode 100644
index e23d8e2823f..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/lib/vf/vq.c
+++ /dev/null
@@ -1,291 +0,0 @@
-#include "otfcc/vf/vq.h"
-#include "support/util.h"
-
-// Variation vector
-caryll_standardValType(pos_t, vq_iPosT);
-caryll_VectorImplFunctions(VV, pos_t, vq_iPosT);
-
-static VV createNeutralVV(tableid_t dimensions) {
- VV vv;
- iVV.initN(&vv, dimensions);
- for (tableid_t j = 0; j < dimensions; j++) {
- vv.items[j] = 0;
- }
- return vv;
-};
-caryll_VectorInterfaceTypeName(VV) iVV = {
- caryll_VectorImplAssignments(VV, pos_t, vq_iPosT),
- .neutral = createNeutralVV,
-};
-
-// VQS
-static INLINE void initVQSegment(vq_Segment *vqs) {
- vqs->type = VQ_STILL;
- vqs->val.still = 0;
-}
-static INLINE void copyVQSegment(vq_Segment *dst, const vq_Segment *src) {
- dst->type = src->type;
- switch (dst->type) {
- case VQ_STILL:
- dst->val.still = src->val.still;
- break;
- case VQ_DELTA:
- dst->val.delta.quantity = src->val.delta.quantity;
- dst->val.delta.region = src->val.delta.region;
- }
-}
-static INLINE void disposeVQSegment(vq_Segment *vqs) {
- switch (vqs->type) {
- case VQ_DELTA:
- break;
- default:;
- }
- initVQSegment(vqs);
-}
-
-caryll_standardValTypeFn(vq_Segment, initVQSegment, copyVQSegment, disposeVQSegment);
-static vq_Segment vqsCreateStill(pos_t x) {
- vq_Segment vqs;
- vq_iSegment.init(&vqs);
- vqs.val.still = x;
- return vqs;
-}
-static vq_Segment vqsCreateDelta(pos_t delta, vq_Region *region) {
- vq_Segment vqs;
- vq_iSegment.init(&vqs);
- vqs.type = VQ_DELTA;
- vqs.val.delta.quantity = delta;
- vqs.val.delta.region = region;
- return vqs;
-}
-
-static int vqsCompare(const vq_Segment a, const vq_Segment b) {
- if (a.type < b.type) return -1;
- if (a.type > b.type) return 1;
- switch (a.type) {
- case VQ_STILL: {
- if (a.val.still < b.val.still) return -1;
- if (a.val.still > b.val.still) return 1;
- return 0;
- }
- case VQ_DELTA: {
- int vqrc = vq_compareRegion(a.val.delta.region, b.val.delta.region);
- if (vqrc) return vqrc;
- if (a.val.delta.quantity < b.val.delta.quantity) return -1;
- if (a.val.delta.quantity > b.val.delta.quantity) return 1;
- return 0;
- }
- default:
- fprintf(stderr,"! warning: vqsCompare unknown a.type %u. Return -1.\n",a.type);
- return -1;
- }
-}
-caryll_OrdEqFns(vq_Segment, vqsCompare);
-static void showVQS(const vq_Segment x) {
- switch (x.type) {
- case VQ_STILL:
- fprintf(stderr, "%g", x.val.still);
- return;
- case VQ_DELTA:
- fprintf(stderr, "{%g%s", x.val.delta.quantity, x.val.delta.touched ? " " : "* ");
- vq_showRegion(x.val.delta.region);
- fprintf(stderr, "}\n");
- return;
-
- default:;
- }
-}
-caryll_ShowFns(vq_Segment, showVQS);
-caryll_ElementInterfaceOf(vq_Segment) vq_iSegment = {
- caryll_standardValTypeMethods(vq_Segment),
- caryll_OrdEqAssigns(vq_Segment), // Ord and Eq
- caryll_ShowAssigns(vq_Segment), // Show
- // creating instances
- .createStill = vqsCreateStill,
- .createDelta = vqsCreateDelta,
-};
-
-caryll_standardVectorImpl(vq_SegList, vq_Segment, vq_iSegment, vq_iSegList);
-
-// Monoid
-
-static INLINE void vqInit(VQ *a) {
- a->kernel = 0;
- vq_iSegList.init(&a->shift);
-}
-static INLINE void vqCopy(VQ *a, const VQ *b) {
- a->kernel = b->kernel;
- vq_iSegList.copy(&a->shift, &b->shift);
-}
-static INLINE void vqDispose(VQ *a) {
- a->kernel = 0;
- vq_iSegList.dispose(&a->shift);
-}
-
-caryll_standardValTypeFn(VQ, vqInit, vqCopy, vqDispose);
-static VQ vqNeutral() {
- return iVQ.createStill(0);
-}
-static bool vqsCompatible(const vq_Segment a, const vq_Segment b) {
- if (a.type != b.type) return false;
- switch (a.type) {
- case VQ_STILL:
- return true;
- case VQ_DELTA:
- return 0 == vq_compareRegion(a.val.delta.region, b.val.delta.region);
- default:
- fprintf(stderr,"! warning: vqsCompatible unknown a.type %u. Return false.\n",a.type);
- return false;
- }
-}
-static void simplifyVq(MODIFY VQ *x) {
- if (!x->shift.length) return;
- vq_iSegList.sort(&x->shift, vq_iSegment.compareRef);
- size_t k = 0;
- for (size_t j = 1; j < x->shift.length; j++) {
- if (vqsCompatible(x->shift.items[k], x->shift.items[j])) {
- switch (x->shift.items[k].type) {
- case VQ_STILL:
- x->shift.items[k].val.still += x->shift.items[j].val.still;
- break;
- case VQ_DELTA:
- x->shift.items[k].val.delta.quantity += x->shift.items[j].val.delta.quantity;
- break;
- }
- vq_iSegment.dispose(&x->shift.items[j]);
- } else {
- x->shift.items[k] = x->shift.items[j];
- k++;
- }
- }
- x->shift.length = k + 1;
-}
-static void vqInplacePlus(MODIFY VQ *a, const VQ b) {
- a->kernel += b.kernel;
- for (size_t p = 0; p < b.shift.length; p++) {
- vq_Segment *k = &b.shift.items[p];
- if (k->type == VQ_STILL) {
- a->kernel += k->val.still;
- } else {
- vq_Segment s;
- vq_iSegment.copy(&s, k);
- vq_iSegList.push(&a->shift, s);
- }
- }
- simplifyVq(a);
-}
-
-caryll_MonoidFns(VQ, vqNeutral, vqInplacePlus);
-
-// Module
-static void vqInplaceScale(MODIFY VQ *a, pos_t b) {
- a->kernel *= b;
- for (size_t j = 0; j < a->shift.length; j++) {
- vq_Segment *s = &a->shift.items[j];
- switch (s->type) {
- case VQ_STILL:
- s->val.still *= b;
- break;
- case VQ_DELTA:
- s->val.delta.quantity *= b;
- break;
- }
- }
-}
-
-// Group
-static void vqInplaceNegate(MODIFY VQ *a) {
- vqInplaceScale(a, -1);
-}
-
-caryll_GroupFns(VQ, vqInplaceNegate);
-caryll_ModuleFns(VQ, pos_t, vqInplaceScale);
-
-// Ord
-static int vqCompare(const VQ a, const VQ b) {
- if (a.shift.length < b.shift.length) return -1;
- if (a.shift.length > b.shift.length) return 1;
- for (size_t j = 0; j < a.shift.length; j++) {
- int cr = vqsCompare(a.shift.items[j], b.shift.items[j]);
- if (cr) return cr;
- }
- return a.kernel - b.kernel;
-}
-caryll_OrdEqFns(VQ, vqCompare);
-
-// Show
-static void showVQ(const VQ x) {
- fprintf(stderr, "%g + {", x.kernel);
- for (size_t j = 0; j < x.shift.length; j++) {
- if (j) fprintf(stderr, " ");
- vq_iSegment.show(x.shift.items[j]);
- }
- fprintf(stderr, "}\n");
-}
-caryll_ShowFns(VQ, showVQ);
-
-// Still instances
-static pos_t vqGetStill(const VQ v) {
- pos_t result = v.kernel;
- for (size_t j = 0; j < v.shift.length; j++) {
- switch (v.shift.items[j].type) {
- case VQ_STILL:
- result += v.shift.items[j].val.still;
- default:;
- }
- }
- return result;
-}
-static VQ vqCreateStill(pos_t x) {
- VQ vq;
- iVQ.init(&vq);
- vq.kernel = x;
- return vq;
-}
-static bool vqIsStill(const VQ v) {
- for (size_t j = 0; j < v.shift.length; j++) {
- switch (v.shift.items[j].type) {
- case VQ_STILL:
- break;
- default:
- return false;
- }
- }
- return true;
-}
-static bool vqIsZero(const VQ v, const pos_t err) {
- return vqIsStill(v) && fabs(vqGetStill(v)) < err;
-}
-static void vqAddDelta(MODIFY VQ *v, const bool touched, const vq_Region *const r,
- const pos_t quantity) {
- if (!quantity) return;
- vq_Segment nudge;
- nudge.type = VQ_DELTA;
- nudge.val.delta.region = r;
- nudge.val.delta.touched = touched;
- nudge.val.delta.quantity = quantity;
- vq_iSegList.push(&v->shift, nudge);
-}
-
-// pointLinearTfm
-static VQ vqPointLinearTfm(const VQ ax, pos_t a, const VQ x, pos_t b, const VQ y) {
- VQ targetX = iVQ.dup(ax);
- iVQ.inplacePlusScale(&targetX, a, x);
- iVQ.inplacePlusScale(&targetX, b, y);
- return targetX;
-}
-
-caryll_VectorInterfaceTypeName(VQ) iVQ = {
- caryll_standardValTypeMethods(VQ),
- .getStill = vqGetStill,
- .createStill = vqCreateStill,
- .isStill = vqIsStill,
- .isZero = vqIsZero,
- caryll_MonoidAssigns(VQ), // Monoid
- caryll_GroupAssigns(VQ), // Group
- caryll_ModuleAssigns(VQ), // Module
- caryll_OrdEqAssigns(VQ), // Eq-Ord
- caryll_ShowAssigns(VQ), // Show
- .pointLinearTfm = vqPointLinearTfm, // pointLinearTfm
- .addDelta = vqAddDelta // addDelta
-};
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/aliases.h b/Build/source/texk/web2c/mfluadir/otfcc/src/aliases.h
deleted file mode 100644
index 4b132845654..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/aliases.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef CARYLL_SRC_ALIASES_H
-#define CARYLL_SRC_ALIASES_H
-
-#define loggedStep(...) \
- for (bool ___loggedstep_v = \
- (options->logger->startSDS(options->logger, sdscatprintf(sdsempty(), __VA_ARGS__)), true); \
- ___loggedstep_v; ___loggedstep_v = false, options->logger->finish(options->logger))
-#define logError(...) \
- options->logger->logSDS(options->logger, log_vl_critical, log_type_error, sdscatprintf(sdsempty(), __VA_ARGS__));
-#define logWarning(...) \
- options->logger->logSDS(options->logger, log_vl_important, log_type_warning, sdscatprintf(sdsempty(), __VA_ARGS__));
-#define logNotice(...) \
- options->logger->logSDS(options->logger, log_vl_notice, log_type_info, sdscatprintf(sdsempty(), __VA_ARGS__));
-#define logProgress(...) \
- options->logger->logSDS(options->logger, log_vl_progress, log_type_progress, sdscatprintf(sdsempty(), __VA_ARGS__));
-
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/luafunc.c b/Build/source/texk/web2c/mfluadir/otfcc/src/luafunc.c
deleted file mode 100644
index bbf8e1b1b09..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/luafunc.c
+++ /dev/null
@@ -1,617 +0,0 @@
-#include "dep/json-builder.h"
-#include "otfcc/sfnt.h"
-#include "otfcc/font.h"
-#include "otfcc/sfnt-builder.h"
-#include "aliases.h"
-#include "platform.h"
-//#include "stopwatch.h"
-
-#include <unistd.h>
-
-/* to reset the getopt_long */
-extern int optind;
-
-int otfcc_build(int b_argc, char *b_argv[]);
-int otfcc_dump(int b_argc, char *b_argv[]);
-
-extern char *xstrdup(const char *);
-
-
-#ifndef MAIN_VER
-#define MAIN_VER 0
-#endif
-#ifndef SECONDARY_VER
-#define SECONDARY_VER 0
-#endif
-#ifndef PATCH_VER
-#define PATCH_VER 0
-#endif
-
-static void dump_printInfo() {
- fprintf(stdout, "This is dump, version %d.%d.%d.\n", MAIN_VER, SECONDARY_VER,
- PATCH_VER);
-}
-
-static void build_printInfo() {
- fprintf(stdout, "This is build, version %d.%d.%d.\n", MAIN_VER, SECONDARY_VER,
- PATCH_VER);
-}
-
-static void dump_printHelp() {
- fprintf(stdout,
- "\n"
- "Usage : dump [OPTIONS] input.[otf|ttf|ttc]\n\n"
- " -h, --help : Display this help message and exit.\n"
- " -v, --version : Display version information and exit.\n"
- " -o <file> : Set output file path to <file>. When absent the dump\n"
- " will be written to STDOUT.\n"
- " -n <n>, --ttc-index <n> : Use the <n>th subfont within the input font.\n"
- " --pretty : Prettify the output JSON.\n"
- " --ugly : Force uglify the output JSON.\n"
- " --verbose : Show more information when building.\n"
- " -q, --quiet : Be silent when building.\n\n"
- " --ignore-glyph-order : Do not export glyph order information.\n"
- " --glyph-name-prefix pfx : Add a prefix to the glyph names.\n"
- " --ignore-hints : Do not export hinting information.\n"
- " --decimal-cmap : Export 'cmap' keys as decimal number.\n"
- " --hex-cmap : Export 'cmap' keys as hex number (U+FFFF).\n"
- " --name-by-hash : Name glyphs using its hash value.\n"
- " --name-by-gid : Name glyphs using its glyph id.\n"
- " --add-bom : Add BOM mark in the output. (It is default on Windows\n"
- " when redirecting to another program. Use --no-bom to\n"
- " turn it off.)\n"
- "\n");
-}
-
-
-static void build_printHelp() {
- fprintf(stdout,
- "\n"
- "Usage : build [OPTIONS] [input.json] -o output.[ttf|otf]\n\n"
- " input.json : Path to input file. When absent the input will be\n"
- " read from the STDIN.\n\n"
- " -h, --help : Display this help message and exit.\n"
- " -v, --version : Display version information and exit.\n"
- " -o <file> : Set output file path to <file>.\n"
- " -s, --dummy-dsig : Include an empty DSIG table in the font. For some\n"
- " Microsoft applications, DSIG is required to enable\n"
- " OpenType features.\n"
- " -O<n> : Specify the level for optimization.\n"
- " -O0 Turn off any optimization.\n"
- " -O1 Default optimization.\n"
- " -O2 More aggressive optimizations for web font. In this\n"
- " level, the following options will be set:\n"
- " --merge-features\n"
- " --short-post\n"
- " --subroutinize\n"
- " -O3 Most aggressive opptimization strategy will be\n"
- " used. In this level, these options will be set:\n"
- " --force-cid\n"
- " --ignore-glyph-order\n"
- " --verbose : Show more information when building.\n"
- " -q, --quiet : Be silent when building.\n\n"
- " --ignore-hints : Ignore the hinting information in the input.\n"
- " --keep-average-char-width : Keep the OS/2.xAvgCharWidth value from the input\n"
- " instead of stating the average width of glyphs.\n"
- " Useful when creating a monospaced font.\n"
- " --keep-unicode-ranges : Keep the OS/2.ulUnicodeRange[1-4] as-is.\n"
- " --keep-modified-time : Keep the head.modified time in the json, instead of\n"
- " using current time.\n\n"
- " --short-post : Don't export glyph names in the result font.\n"
- " --ignore-glyph-order, -i : Ignore the glyph order information in the input.\n"
- " --keep-glyph-order, -k : Keep the glyph order information in the input.\n"
- " Use to preserve glyph order under -O2 and -O3.\n"
- " --dont-ignore-glyph-order : Same as --keep-glyph-order.\n"
- " --merge-features : Merge duplicate OpenType feature definitions.\n"
- " --dont-merge-features : Keep duplicate OpenType feature definitions.\n"
- " --merge-lookups : Merge duplicate OpenType lookups.\n"
- " --dont-merge-lookups : Keep duplicate OpenType lookups.\n"
- " --force-cid : Convert name-keyed CFF OTF into CID-keyed.\n"
- " --subroutinize : Subroutinize CFF table.\n"
- " --stub-cmap4 : Create a stub `cmap` format 4 subtable if format\n"
- " 12 subtable is present.\n"
- "\n");
-}
-
-
-static void build_readEntireFile(char *inPath, char **_buffer, long *_length) {
- char *buffer = NULL;
- long length = 0;
- FILE *f = u8fopen(inPath, "rb");
- if (!f) {
- fprintf(stderr, "Cannot read JSON file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- fseek(f, 0, SEEK_END);
- length = ftell(f);
- fseek(f, 0, SEEK_SET);
- buffer = malloc(length);
- if (buffer) { fread(buffer, 1, length, f); }
- fclose(f);
-
- if (!buffer) {
- fprintf(stderr, "Cannot read JSON file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- *_buffer = buffer;
- *_length = length;
-}
-
-
-int otfcc_build(int b_argc, char *b_argv[]) {
-// struct timespec begin;
-// time_now(&begin);
-
- bool show_help = false;
- bool show_version = false;
- sds outputPath = NULL;
- sds inPath = NULL;
- int option_index = 0;
- int c;
-
- optind=0;
- if ((b_argc==0)||(b_argv==NULL))
- return 0;
-
- otfcc_Options *options = otfcc_newOptions();
- options->logger = otfcc_newLogger(otfcc_newStdErrTarget());
- options->logger->indent(options->logger, "build");
- otfcc_Options_optimizeTo(options, 1);
-
- struct option longopts[] = {{"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {"time", no_argument, NULL, 0},
- {"ignore-glyph-order", no_argument, NULL, 0},
- {"keep-glyph-order", no_argument, NULL, 0},
- {"dont-ignore-glyph-order", no_argument, NULL, 0},
- {"ignore-hints", no_argument, NULL, 0},
- {"keep-average-char-width", no_argument, NULL, 0},
- {"keep-unicode-ranges", no_argument, NULL, 0},
- {"keep-modified-time", no_argument, NULL, 0},
- {"merge-lookups", no_argument, NULL, 0},
- {"merge-features", no_argument, NULL, 0},
- {"dont-merge-lookups", no_argument, NULL, 0},
- {"dont-merge-features", no_argument, NULL, 0},
- {"short-post", no_argument, NULL, 0},
- {"force-cid", no_argument, NULL, 0},
- {"subroutinize", no_argument, NULL, 0},
- {"stub-cmap4", no_argument, NULL, 0},
- {"dummy-dsig", no_argument, NULL, 's'},
- {"ship", no_argument, NULL, 0},
- {"verbose", no_argument, NULL, 0},
- {"quiet", no_argument, NULL, 0},
- {"optimize", required_argument, NULL, 'O'},
- {"output", required_argument, NULL, 'o'},
- {0, 0, 0, 0}};
-
- while ((c = getopt_long(b_argc, b_argv, "vhqskiO:o:", longopts, &option_index)) != (-1)) {
- switch (c) {
- case 0:
- /* If this option set a flag, do nothing else now. */
- if (longopts[option_index].flag != 0) {
- break;
- } else if (strcmp(longopts[option_index].name, "time") == 0) {
- } else if (strcmp(longopts[option_index].name, "ignore-hints") == 0) {
- options->ignore_hints = true;
- } else if (strcmp(longopts[option_index].name, "keep-average-char-width") == 0) {
- options->keep_average_char_width = true;
- } else if (strcmp(longopts[option_index].name, "keep-unicode-ranges") == 0) {
- options->keep_unicode_ranges = true;
- } else if (strcmp(longopts[option_index].name, "keep-modified-time") == 0) {
- options->keep_modified_time = true;
- } else if (strcmp(longopts[option_index].name, "merge-features") == 0) {
- options->merge_features = true;
- } else if (strcmp(longopts[option_index].name, "merge-lookups") == 0) {
- options->merge_lookups = true;
- } else if (strcmp(longopts[option_index].name, "dont-merge-features") == 0) {
- options->merge_features = false;
- } else if (strcmp(longopts[option_index].name, "dont-merge-lookups") == 0) {
- options->merge_lookups = false;
- } else if (strcmp(longopts[option_index].name, "ignore-glyph-order") == 0) {
- options->ignore_glyph_order = true;
- } else if (strcmp(longopts[option_index].name, "keep-glyph-order") == 0) {
- options->ignore_glyph_order = false;
- } else if (strcmp(longopts[option_index].name, "dont-keep-glyph-order") == 0) {
- options->ignore_glyph_order = false;
- } else if (strcmp(longopts[option_index].name, "short-post") == 0) {
- options->short_post = true;
- } else if (strcmp(longopts[option_index].name, "force-cid") == 0) {
- options->force_cid = true;
- } else if (strcmp(longopts[option_index].name, "subroutinize") == 0) {
- options->cff_doSubroutinize = true;
- } else if (strcmp(longopts[option_index].name, "stub-cmap4") == 0) {
- options->stub_cmap4 = true;
- } else if (strcmp(longopts[option_index].name, "ship") == 0) {
- options->ignore_glyph_order = true;
- options->short_post = true;
- options->dummy_DSIG = true;
- } else if (strcmp(longopts[option_index].name, "verbose") == 0) {
- options->verbose = true;
- } else if (strcmp(longopts[option_index].name, "quiet") == 0) {
- options->quiet = true;
- }
- break;
- case 'v':
- show_version = true;
- break;
- case 'h':
- show_help = true;
- break;
- case 'k':
- options->ignore_glyph_order = false;
- break;
- case 'i':
- options->ignore_glyph_order = true;
- break;
- case 'o':
- outputPath = sdsnew(optarg);
- break;
- case 's':
- options->dummy_DSIG = true;
- break;
- case 'q':
- options->quiet = true;
- break;
- case 'O':
- otfcc_Options_optimizeTo(options, atoi(optarg));
- break;
- }
- }
- options->logger->setVerbosity(options->logger,
- options->quiet ? 0 : options->verbose ? 0xFF : 1);
- if (show_help) {
- build_printInfo();
- build_printHelp();
- return 0;
- }
- if (show_version) {
- build_printInfo();
- return 0;
- }
-
- if (optind >= b_argc) {
- inPath = NULL; // read from STDIN
- } else {
- inPath = sdsnew(b_argv[optind]); // read from file
- }
- if (!outputPath) {
- logError("Unable to build OpenType font tile : output path not "
- "specified. Exit.\n");
- build_printHelp();
- exit(EXIT_FAILURE);
- }
-
- char *buffer;
- long length;
- loggedStep("Load file") {
- if (inPath) {
- loggedStep("Load from file %s", inPath) {
- build_readEntireFile(inPath, &buffer, &length);
- sdsfree(inPath);
- }
- } else {
- /*loggedStep("Load from stdin") {
- build_readEntireStdin(&buffer, &length);
- }*/
- }
- //logStepTime;
- }
-
- json_value *jsonRoot = NULL;
- loggedStep("Parse into JSON") {
- jsonRoot = json_parse(buffer, length);
- free(buffer);
- //logStepTime;
- if (!jsonRoot) {
- logError("Cannot parse JSON file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- }
-
- otfcc_Font *font;
- loggedStep("Parse") {
- otfcc_IFontBuilder *parser = otfcc_newJsonReader();
- font = parser->read(jsonRoot, 0, options);
- if (!font) {
- logError("Cannot parse JSON file \"%s\" as a font. Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- parser->free(parser);
- json_value_free(jsonRoot);
- //logStepTime;
- }
- loggedStep("Consolidate") {
- otfcc_iFont.consolidate(font, options);
- //logStepTime;
- }
- loggedStep("Build") {
- otfcc_IFontSerializer *writer = otfcc_newOTFWriter();
- caryll_Buffer *otf = (caryll_Buffer *)writer->serialize(font, options);
- loggedStep("Write to file") {
- FILE *outfile = u8fopen(outputPath, "wb");
- if (!outfile) {
- logError("Cannot write to file \"%s\". Exit.\n", outputPath);
- exit(EXIT_FAILURE);
- }
- fwrite(otf->data, sizeof(uint8_t), buflen(otf), outfile);
- fclose(outfile);
- }
- //logStepTime;
- buffree(otf), writer->free(writer), otfcc_iFont.free(font), sdsfree(outputPath);
- }
- otfcc_deleteOptions(options);
-
- return 0;
-}
-
-
-
-int otfcc_dump(int b_argc, char *b_argv[]) {
- bool show_help = false;
- bool show_version = false;
- bool show_pretty = false;
- bool show_ugly = false;
- bool add_bom = false;
- bool no_bom = false;
- uint32_t ttcindex = 0;
- struct option longopts[] = {{"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {"pretty", no_argument, NULL, 'p'},
- {"ugly", no_argument, NULL, 0},
- {"time", no_argument, NULL, 0},
- {"ignore-glyph-order", no_argument, NULL, 0},
- {"ignore-hints", no_argument, NULL, 0},
- {"hex-cmap", no_argument, NULL, 0},
- {"decimal-cmap", no_argument, NULL, 0},
- {"instr-as-bytes", no_argument, NULL, 0},
- {"name-by-hash", no_argument, NULL, 0},
- {"name-by-gid", no_argument, NULL, 0},
- {"glyph-name-prefix", required_argument, NULL, 0},
- {"verbose", no_argument, NULL, 0},
- {"quiet", no_argument, NULL, 0},
- {"add-bom", no_argument, NULL, 0},
- {"no-bom", no_argument, NULL, 0},
- {"output", required_argument, NULL, 'o'},
- {"ttc-index", required_argument, NULL, 'n'},
- {"debug-wait-on-start", no_argument, NULL, 0},
- {0, 0, 0, 0}};
-
- optind=0;
- if ((b_argc==0)||(b_argv==NULL))
- return 0;
- otfcc_Options *options = otfcc_newOptions();
- options->logger = otfcc_newLogger(otfcc_newStdErrTarget());
- options->logger->indent(options->logger, "dump");
- options->decimal_cmap = true;
-
- int option_index = 0;
- int c;
-
- sds outputPath = NULL;
- sds inPath = NULL;
-
- while ((c = getopt_long(b_argc, b_argv, "vhqpio:n:", longopts, &option_index)) != (-1)) {
- switch (c) {
- case 0:
- /* If this option set a flag, do nothing else now. */
- if (longopts[option_index].flag != 0) {
- break;
- } else if (strcmp(longopts[option_index].name, "ugly") == 0) {
- show_ugly = true;
- } else if (strcmp(longopts[option_index].name, "time") == 0) {
- } else if (strcmp(longopts[option_index].name, "add-bom") == 0) {
- add_bom = true;
- } else if (strcmp(longopts[option_index].name, "no-bom") == 0) {
- no_bom = true;
- } else if (strcmp(longopts[option_index].name, "ignore-glyph-order") == 0) {
- options->ignore_glyph_order = true;
- } else if (strcmp(longopts[option_index].name, "verbose") == 0) {
- options->verbose = true;
- } else if (strcmp(longopts[option_index].name, "quiet") == 0) {
- options->quiet = true;
- } else if (strcmp(longopts[option_index].name, "ignore-hints") == 0) {
- options->ignore_hints = true;
- } else if (strcmp(longopts[option_index].name, "decimal-cmap") == 0) {
- options->decimal_cmap = true;
- } else if (strcmp(longopts[option_index].name, "hex-cmap") == 0) {
- options->decimal_cmap = false;
- } else if (strcmp(longopts[option_index].name, "name-by-hash") == 0) {
- options->name_glyphs_by_hash = true;
- } else if (strcmp(longopts[option_index].name, "name-by-gid") == 0) {
- options->name_glyphs_by_gid = true;
- } else if (strcmp(longopts[option_index].name, "instr-as-bytes") == 0) {
- options->instr_as_bytes = true;
- } else if (strcmp(longopts[option_index].name, "glyph-name-prefix") == 0) {
- options->glyph_name_prefix = xstrdup(optarg);
- } else if (strcmp(longopts[option_index].name, "debug-wait-on-start") == 0) {
- options->debug_wait_on_start = true;
- }
- break;
- case 'v':
- show_version = true;
- break;
- case 'i':
- options->ignore_glyph_order = true;
- break;
- case 'h':
- show_help = true;
- break;
- case 'p':
- show_pretty = true;
- break;
- case 'o':
- outputPath = sdsnew(optarg);
- break;
- case 'q':
- options->quiet = true;
- break;
- case 'n':
- ttcindex = atoi(optarg);
- break;
- }
- }
-
- if (options->debug_wait_on_start) { getchar(); }
-
- options->logger->setVerbosity(options->logger,
- options->quiet ? 0 : options->verbose ? 0xFF : 1);
-
- if (show_help) {
- dump_printInfo();
- dump_printHelp();
- return 0;
- }
- if (show_version) {
- dump_printInfo();
- return 0;
- }
-
- if (optind >= b_argc) {
- logError("Expected argument for input file name.\n");
- dump_printHelp();
- exit(EXIT_FAILURE);
- } else {
- inPath = sdsnew(b_argv[optind]);
- }
-
-// struct timespec begin;
-
-// time_now(&begin);
-
- otfcc_SplineFontContainer *sfnt;
- loggedStep("Read SFNT") {
- logProgress("From file %s", inPath);
- FILE *file = u8fopen(inPath, "rb");
- sfnt = otfcc_readSFNT(file);
- if (!sfnt || sfnt->count == 0) {
- logError("Cannot read SFNT file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- if (ttcindex >= sfnt->count) {
- logError("Subfont index %d out of range for \"%s\" (0 -- %d). Exit.\n", ttcindex,
- inPath, (sfnt->count - 1));
- exit(EXIT_FAILURE);
- }
- //logStepTime;
- }
-
- otfcc_Font *font;
- loggedStep("Read Font") {
- otfcc_IFontBuilder *reader = otfcc_newOTFReader();
- font = reader->read(sfnt, ttcindex, options);
- if (!font) {
- logError("Font structure broken or corrupted \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- reader->free(reader);
- if (sfnt) otfcc_deleteSFNT(sfnt);
- //logStepTime;
- }
- loggedStep("Consolidate") {
- otfcc_iFont.consolidate(font, options);
- //logStepTime;
- }
- json_value *root;
- loggedStep("Dump") {
- otfcc_IFontSerializer *dumper = otfcc_newJsonWriter();
- root = (json_value *)dumper->serialize(font, options);
- if (!root) {
- logError("Font structure broken or corrupted \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- //logStepTime;
- dumper->free(dumper);
- }
-
- char *buf;
- size_t buflen;
- loggedStep("Serialize to JSON") {
- json_serialize_opts jsonOptions;
- jsonOptions.mode = json_serialize_mode_packed;
- jsonOptions.opts = 0;
- jsonOptions.indent_size = 4;
-#ifdef WIN32
- if (show_pretty || (!outputPath && isatty(fileno(stdout)))) {
- jsonOptions.mode = json_serialize_mode_multiline;
- }
-#else
- if (show_pretty || (!outputPath && isatty(STDOUT_FILENO))) {
- jsonOptions.mode = json_serialize_mode_multiline;
- }
-#endif
- if (show_ugly) jsonOptions.mode = json_serialize_mode_packed;
- buflen = json_measure_ex(root, jsonOptions);
- buf = calloc(1, buflen);
- json_serialize_ex(buf, root, jsonOptions);
- //logStepTime;
- }
-
- loggedStep("Output") {
- if (outputPath) {
- FILE *outputFile = u8fopen(outputPath, "wb");
- if (!outputFile) {
- logError("Cannot write to file \"%s\". Exit.", outputPath);
- exit(EXIT_FAILURE);
- }
- if (add_bom) {
- fputc(0xEF, outputFile);
- fputc(0xBB, outputFile);
- fputc(0xBF, outputFile);
- }
- size_t actualLen = buflen - 1;
- while (!buf[actualLen])
- actualLen -= 1;
- fwrite(buf, sizeof(char), actualLen + 1, outputFile);
- fclose(outputFile);
- } else {
-#ifdef WIN32
- if (isatty(fileno(stdout))) {
- LPWSTR pwStr;
- DWORD dwNum = widen_utf8(buf, &pwStr);
- DWORD actual = 0;
- DWORD written = 0;
- const DWORD chunk = 0x10000;
- while (written < dwNum) {
- DWORD len = dwNum - written;
- if (len > chunk) len = chunk;
- WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), pwStr + written, len, &actual,
- NULL);
- written += len;
- }
- free(pwStr);
- } else {
- if (!no_bom) {
- fputc(0xEF, stdout);
- fputc(0xBB, stdout);
- fputc(0xBF, stdout);
- }
- fputs(buf, stdout);
- }
-#else
- (void)(no_bom);
- if (add_bom) {
- fputc(0xEF, stdout);
- fputc(0xBB, stdout);
- fputc(0xBF, stdout);
- }
- fputs(buf, stdout);
-#endif
- }
- //logStepTime;
- }
-
- loggedStep("Finalize") {
- free(buf);
- if (font) otfcc_iFont.free(font);
- if (root) json_builder_free(root);
- if (inPath) sdsfree(inPath);
- if (outputPath) sdsfree(outputPath);
- //logStepTime;
- }
- otfcc_deleteOptions(options);
-
- return 0;
-}
-
-
-
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/otfccbuild.c b/Build/source/texk/web2c/mfluadir/otfcc/src/otfccbuild.c
deleted file mode 100644
index 30c401a73a4..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/otfccbuild.c
+++ /dev/null
@@ -1,326 +0,0 @@
-#include "otfcc/sfnt.h"
-#include "otfcc/font.h"
-#include "otfcc/sfnt-builder.h"
-
-#include "aliases.h"
-#include "platform.h"
-#include "stopwatch.h"
-
-#ifndef MAIN_VER
-#define MAIN_VER 0
-#endif
-#ifndef SECONDARY_VER
-#define SECONDARY_VER 0
-#endif
-#ifndef PATCH_VER
-#define PATCH_VER 0
-#endif
-
-static void printInfo() {
- fprintf(stdout, "This is Polymorphic otfccbuild, version %d.%d.%d.\n", MAIN_VER, SECONDARY_VER,
- PATCH_VER);
-}
-static void printHelp() {
- fprintf(stdout,
- "\n"
- "Usage : otfccbuild [OPTIONS] [input.json] -o output.[ttf|otf]\n\n"
- " input.json : Path to input file. When absent the input will be\n"
- " read from the STDIN.\n\n"
- " -h, --help : Display this help message and exit.\n"
- " -v, --version : Display version information and exit.\n"
- " -o <file> : Set output file path to <file>.\n"
- " -s, --dummy-dsig : Include an empty DSIG table in the font. For some\n"
- " Microsoft applications, DSIG is required to enable\n"
- " OpenType features.\n"
- " -O<n> : Specify the level for optimization.\n"
- " -O0 Turn off any optimization.\n"
- " -O1 Default optimization.\n"
- " -O2 More aggressive optimizations for web font. In this\n"
- " level, the following options will be set:\n"
- " --merge-features\n"
- " --short-post\n"
- " --subroutinize\n"
- " -O3 Most aggressive opptimization strategy will be\n"
- " used. In this level, these options will be set:\n"
- " --force-cid\n"
- " --ignore-glyph-order\n"
- " --verbose : Show more information when building.\n"
- " -q, --quiet : Be silent when building.\n\n"
- " --ignore-hints : Ignore the hinting information in the input.\n"
- " --keep-average-char-width : Keep the OS/2.xAvgCharWidth value from the input\n"
- " instead of stating the average width of glyphs.\n"
- " Useful when creating a monospaced font.\n"
- " --keep-unicode-ranges : Keep the OS/2.ulUnicodeRange[1-4] as-is.\n"
- " --keep-modified-time : Keep the head.modified time in the json, instead of\n"
- " using current time.\n\n"
- " --short-post : Don't export glyph names in the result font.\n"
- " --ignore-glyph-order, -i : Ignore the glyph order information in the input.\n"
- " --keep-glyph-order, -k : Keep the glyph order information in the input.\n"
- " Use to preserve glyph order under -O2 and -O3.\n"
- " --dont-ignore-glyph-order : Same as --keep-glyph-order.\n"
- " --merge-features : Merge duplicate OpenType feature definitions.\n"
- " --dont-merge-features : Keep duplicate OpenType feature definitions.\n"
- " --merge-lookups : Merge duplicate OpenType lookups.\n"
- " --dont-merge-lookups : Keep duplicate OpenType lookups.\n"
- " --force-cid : Convert name-keyed CFF OTF into CID-keyed.\n"
- " --subroutinize : Subroutinize CFF table.\n"
- " --stub-cmap4 : Create a stub `cmap` format 4 subtable if format\n"
- " 12 subtable is present.\n"
- "\n");
-}
-static void readEntireFile(char *inPath, char **_buffer, long *_length) {
- char *buffer = NULL;
- long length = 0;
- FILE *f = u8fopen(inPath, "rb");
- if (!f) {
- fprintf(stderr, "Cannot read JSON file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- fseek(f, 0, SEEK_END);
- length = ftell(f);
- fseek(f, 0, SEEK_SET);
- buffer = malloc(length);
- if (buffer) { fread(buffer, 1, length, f); }
- fclose(f);
-
- if (!buffer) {
- fprintf(stderr, "Cannot read JSON file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- *_buffer = buffer;
- *_length = length;
-}
-
-static void readEntireStdin(char **_buffer, long *_length) {
-#ifdef _WIN32
- freopen(NULL, "rb", stdin);
-#endif
- static const long BUF_SIZE = 0x400000;
- static const long BUF_MIN = 0x1000;
- char *buffer = malloc(BUF_SIZE);
- long length = 0;
- long remain = BUF_SIZE;
- while (!feof(stdin)) {
- if (remain <= BUF_MIN) {
- remain += (length >> 1) & 0xFFFFFF;
- buffer = realloc(buffer, length + remain);
- }
-
- fgets(buffer + length, remain, stdin);
- long n = (long)strlen(buffer + length);
- length += n;
- remain -= n;
- }
- *_buffer = buffer;
- *_length = length;
-}
-
-#ifdef _WIN32
-int main() {
- int argc;
- char **argv;
- get_argv_utf8(&argc, &argv);
-#else
-int main(int argc, char *argv[]) {
-#endif
-
- struct timespec begin;
- time_now(&begin);
-
- bool show_help = false;
- bool show_version = false;
- sds outputPath = NULL;
- sds inPath = NULL;
- int option_index = 0;
- int c;
-
- otfcc_Options *options = otfcc_newOptions();
- options->logger = otfcc_newLogger(otfcc_newStdErrTarget());
- options->logger->indent(options->logger, "otfccbuild");
- otfcc_Options_optimizeTo(options, 1);
-
- struct option longopts[] = {{"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {"time", no_argument, NULL, 0},
- {"ignore-glyph-order", no_argument, NULL, 0},
- {"keep-glyph-order", no_argument, NULL, 0},
- {"dont-ignore-glyph-order", no_argument, NULL, 0},
- {"ignore-hints", no_argument, NULL, 0},
- {"keep-average-char-width", no_argument, NULL, 0},
- {"keep-unicode-ranges", no_argument, NULL, 0},
- {"keep-modified-time", no_argument, NULL, 0},
- {"merge-lookups", no_argument, NULL, 0},
- {"merge-features", no_argument, NULL, 0},
- {"dont-merge-lookups", no_argument, NULL, 0},
- {"dont-merge-features", no_argument, NULL, 0},
- {"short-post", no_argument, NULL, 0},
- {"force-cid", no_argument, NULL, 0},
- {"subroutinize", no_argument, NULL, 0},
- {"stub-cmap4", no_argument, NULL, 0},
- {"dummy-dsig", no_argument, NULL, 's'},
- {"ship", no_argument, NULL, 0},
- {"verbose", no_argument, NULL, 0},
- {"quiet", no_argument, NULL, 0},
- {"optimize", required_argument, NULL, 'O'},
- {"output", required_argument, NULL, 'o'},
- {0, 0, 0, 0}};
-
- while ((c = getopt_long(argc, argv, "vhqskiO:o:", longopts, &option_index)) != (-1)) {
- switch (c) {
- case 0:
- /* If this option set a flag, do nothing else now. */
- if (longopts[option_index].flag != 0) {
- break;
- } else if (strcmp(longopts[option_index].name, "time") == 0) {
- } else if (strcmp(longopts[option_index].name, "ignore-hints") == 0) {
- options->ignore_hints = true;
- } else if (strcmp(longopts[option_index].name, "keep-average-char-width") == 0) {
- options->keep_average_char_width = true;
- } else if (strcmp(longopts[option_index].name, "keep-unicode-ranges") == 0) {
- options->keep_unicode_ranges = true;
- } else if (strcmp(longopts[option_index].name, "keep-modified-time") == 0) {
- options->keep_modified_time = true;
- } else if (strcmp(longopts[option_index].name, "merge-features") == 0) {
- options->merge_features = true;
- } else if (strcmp(longopts[option_index].name, "merge-lookups") == 0) {
- options->merge_lookups = true;
- } else if (strcmp(longopts[option_index].name, "dont-merge-features") == 0) {
- options->merge_features = false;
- } else if (strcmp(longopts[option_index].name, "dont-merge-lookups") == 0) {
- options->merge_lookups = false;
- } else if (strcmp(longopts[option_index].name, "ignore-glyph-order") == 0) {
- options->ignore_glyph_order = true;
- } else if (strcmp(longopts[option_index].name, "keep-glyph-order") == 0) {
- options->ignore_glyph_order = false;
- } else if (strcmp(longopts[option_index].name, "dont-keep-glyph-order") == 0) {
- options->ignore_glyph_order = false;
- } else if (strcmp(longopts[option_index].name, "short-post") == 0) {
- options->short_post = true;
- } else if (strcmp(longopts[option_index].name, "force-cid") == 0) {
- options->force_cid = true;
- } else if (strcmp(longopts[option_index].name, "subroutinize") == 0) {
- options->cff_doSubroutinize = true;
- } else if (strcmp(longopts[option_index].name, "stub-cmap4") == 0) {
- options->stub_cmap4 = true;
- } else if (strcmp(longopts[option_index].name, "ship") == 0) {
- options->ignore_glyph_order = true;
- options->short_post = true;
- options->dummy_DSIG = true;
- } else if (strcmp(longopts[option_index].name, "verbose") == 0) {
- options->verbose = true;
- } else if (strcmp(longopts[option_index].name, "quiet") == 0) {
- options->quiet = true;
- }
- break;
- case 'v':
- show_version = true;
- break;
- case 'h':
- show_help = true;
- break;
- case 'k':
- options->ignore_glyph_order = false;
- break;
- case 'i':
- options->ignore_glyph_order = true;
- break;
- case 'o':
- outputPath = sdsnew(optarg);
- break;
- case 's':
- options->dummy_DSIG = true;
- break;
- case 'q':
- options->quiet = true;
- break;
- case 'O':
- otfcc_Options_optimizeTo(options, atoi(optarg));
- break;
- }
- }
- options->logger->setVerbosity(options->logger,
- options->quiet ? 0 : options->verbose ? 0xFF : 1);
- if (show_help) {
- printInfo();
- printHelp();
- return 0;
- }
- if (show_version) {
- printInfo();
- return 0;
- }
-
- if (optind >= argc) {
- inPath = NULL; // read from STDIN
- } else {
- inPath = sdsnew(argv[optind]); // read from file
- }
- if (!outputPath) {
- logError("Unable to build OpenType font tile : output path not "
- "specified. Exit.\n");
- printHelp();
- exit(EXIT_FAILURE);
- }
-
- char *buffer;
- long length;
- loggedStep("Load file") {
- if (inPath) {
- loggedStep("Load from file %s", inPath) {
- readEntireFile(inPath, &buffer, &length);
- sdsfree(inPath);
- }
- } else {
- loggedStep("Load from stdin") {
- readEntireStdin(&buffer, &length);
- }
- }
- logStepTime;
- }
-
- json_value *jsonRoot = NULL;
- loggedStep("Parse into JSON") {
- jsonRoot = json_parse(buffer, length);
- free(buffer);
- logStepTime;
- if (!jsonRoot) {
- logError("Cannot parse JSON file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- }
-
- otfcc_Font *font;
- loggedStep("Parse") {
- otfcc_IFontBuilder *parser = otfcc_newJsonReader();
- font = parser->read(jsonRoot, 0, options);
- if (!font) {
- logError("Cannot parse JSON file \"%s\" as a font. Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- parser->free(parser);
- json_value_free(jsonRoot);
- logStepTime;
- }
- loggedStep("Consolidate") {
- otfcc_iFont.consolidate(font, options);
- logStepTime;
- }
- loggedStep("Build") {
- otfcc_IFontSerializer *writer = otfcc_newOTFWriter();
- caryll_Buffer *otf = (caryll_Buffer *)writer->serialize(font, options);
- loggedStep("Write to file") {
- FILE *outfile = u8fopen(outputPath, "wb");
- if (!outfile) {
- logError("Cannot write to file \"%s\". Exit.\n", outputPath);
- exit(EXIT_FAILURE);
- }
- fwrite(otf->data, sizeof(uint8_t), buflen(otf), outfile);
- fclose(outfile);
- }
- logStepTime;
- buffree(otf), writer->free(writer), otfcc_iFont.free(font), sdsfree(outputPath);
- }
- otfcc_deleteOptions(options);
-
- return 0;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/otfccdll.c b/Build/source/texk/web2c/mfluadir/otfcc/src/otfccdll.c
deleted file mode 100644
index 98bb85f05bc..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/otfccdll.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "otfcc/sfnt.h"
-#include "otfcc/font.h"
-#include "otfcc/sfnt-builder.h"
-
-#ifdef _WIN32
-#define OTFCC_DLL_EXPORT __declspec(dllexport)
-#else
-#define OTFCC_DLL_EXPORT
-#endif
-
-caryll_Buffer *otfccbuild_json_otf(uint32_t inlen, const char *injson, uint8_t olevel,bool for_webfont);
-size_t otfcc_get_buf_len(caryll_Buffer *buf);
-uint8_t *otfcc_get_buf_data(caryll_Buffer *buf);
-void otfccbuild_free_otfbuf(caryll_Buffer *buf);
-
-OTFCC_DLL_EXPORT caryll_Buffer *otfccbuild_json_otf(uint32_t inlen, const char *injson, uint8_t olevel,
- bool for_webfont) {
- otfcc_Options *options = otfcc_newOptions();
- options->logger = otfcc_newLogger(otfcc_newEmptyTarget());
- options->logger->indent(options->logger, "otfccbuild");
-
- // optimization levels
- otfcc_Options_optimizeTo(options, olevel);
- if (for_webfont) {
- options->ignore_glyph_order = true;
- options->force_cid = true;
- }
-
- // json parsing
- json_value *jsonRoot = json_parse(injson, inlen);
- if (!jsonRoot) { return NULL; }
- // font parsing
- otfcc_IFontBuilder *parser = otfcc_newJsonReader();
- otfcc_Font *font = parser->read(jsonRoot, 0, options);
- parser->free(parser);
- json_value_free(jsonRoot);
- if (!font) { return NULL; }
-
- // consolidation and build
- otfcc_iFont.consolidate(font, options);
- otfcc_IFontSerializer *writer = otfcc_newOTFWriter();
- caryll_Buffer *otf = (caryll_Buffer *)writer->serialize(font, options);
-
- writer->free(writer);
- otfcc_iFont.free(font);
- return otf;
-}
-
-OTFCC_DLL_EXPORT size_t otfcc_get_buf_len(caryll_Buffer *buf) {
- return buf->size;
-}
-OTFCC_DLL_EXPORT uint8_t *otfcc_get_buf_data(caryll_Buffer *buf) {
- return buf->data;
-}
-OTFCC_DLL_EXPORT void otfccbuild_free_otfbuf(caryll_Buffer *buf) {
- buffree(buf);
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/otfccdump.c b/Build/source/texk/web2c/mfluadir/otfcc/src/otfccdump.c
deleted file mode 100644
index 2630bd49d4d..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/otfccdump.c
+++ /dev/null
@@ -1,311 +0,0 @@
-#include "dep/json-builder.h"
-#include "otfcc/sfnt.h"
-#include "otfcc/font.h"
-
-#include "aliases.h"
-#include "platform.h"
-#include "stopwatch.h"
-
-#ifndef MAIN_VER
-#define MAIN_VER 0
-#endif
-#ifndef SECONDARY_VER
-#define SECONDARY_VER 0
-#endif
-#ifndef PATCH_VER
-#define PATCH_VER 0
-#endif
-
-static void printInfo() {
- fprintf(stdout, "This is Polymorphic otfccdump, version %d.%d.%d.\n", MAIN_VER, SECONDARY_VER,
- PATCH_VER);
-}
-static void printHelp() {
- fprintf(stdout,
- "\n"
- "Usage : otfccdump [OPTIONS] input.[otf|ttf|ttc]\n\n"
- " -h, --help : Display this help message and exit.\n"
- " -v, --version : Display version information and exit.\n"
- " -o <file> : Set output file path to <file>. When absent the dump\n"
- " will be written to STDOUT.\n"
- " -n <n>, --ttc-index <n> : Use the <n>th subfont within the input font.\n"
- " --pretty : Prettify the output JSON.\n"
- " --ugly : Force uglify the output JSON.\n"
- " --verbose : Show more information when building.\n"
- " -q, --quiet : Be silent when building.\n\n"
- " --ignore-glyph-order : Do not export glyph order information.\n"
- " --glyph-name-prefix pfx : Add a prefix to the glyph names.\n"
- " --ignore-hints : Do not export hinting information.\n"
- " --decimal-cmap : Export 'cmap' keys as decimal number.\n"
- " --hex-cmap : Export 'cmap' keys as hex number (U+FFFF).\n"
- " --name-by-hash : Name glyphs using its hash value.\n"
- " --name-by-gid : Name glyphs using its glyph id.\n"
- " --add-bom : Add BOM mark in the output. (It is default on Windows\n"
- " when redirecting to another program. Use --no-bom to\n"
- " turn it off.)\n"
- "\n");
-}
-#ifdef _WIN32
-int main() {
- int argc;
- char **argv;
- get_argv_utf8(&argc, &argv);
-#else
-int main(int argc, char *argv[]) {
-#endif
-
- bool show_help = false;
- bool show_version = false;
- bool show_pretty = false;
- bool show_ugly = false;
- bool add_bom = false;
- bool no_bom = false;
- uint32_t ttcindex = 0;
- struct option longopts[] = {{"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {"pretty", no_argument, NULL, 'p'},
- {"ugly", no_argument, NULL, 0},
- {"time", no_argument, NULL, 0},
- {"ignore-glyph-order", no_argument, NULL, 0},
- {"ignore-hints", no_argument, NULL, 0},
- {"hex-cmap", no_argument, NULL, 0},
- {"decimal-cmap", no_argument, NULL, 0},
- {"instr-as-bytes", no_argument, NULL, 0},
- {"name-by-hash", no_argument, NULL, 0},
- {"name-by-gid", no_argument, NULL, 0},
- {"glyph-name-prefix", required_argument, NULL, 0},
- {"verbose", no_argument, NULL, 0},
- {"quiet", no_argument, NULL, 0},
- {"add-bom", no_argument, NULL, 0},
- {"no-bom", no_argument, NULL, 0},
- {"output", required_argument, NULL, 'o'},
- {"ttc-index", required_argument, NULL, 'n'},
- {"debug-wait-on-start", no_argument, NULL, 0},
- {0, 0, 0, 0}};
-
- otfcc_Options *options = otfcc_newOptions();
- options->logger = otfcc_newLogger(otfcc_newStdErrTarget());
- options->logger->indent(options->logger, "otfccdump");
- options->decimal_cmap = true;
-
- int option_index = 0;
- int c;
-
- sds outputPath = NULL;
- sds inPath = NULL;
-
- while ((c = getopt_long(argc, argv, "vhqpio:n:", longopts, &option_index)) != (-1)) {
- switch (c) {
- case 0:
- /* If this option set a flag, do nothing else now. */
- if (longopts[option_index].flag != 0) {
- break;
- } else if (strcmp(longopts[option_index].name, "ugly") == 0) {
- show_ugly = true;
- } else if (strcmp(longopts[option_index].name, "time") == 0) {
- } else if (strcmp(longopts[option_index].name, "add-bom") == 0) {
- add_bom = true;
- } else if (strcmp(longopts[option_index].name, "no-bom") == 0) {
- no_bom = true;
- } else if (strcmp(longopts[option_index].name, "ignore-glyph-order") == 0) {
- options->ignore_glyph_order = true;
- } else if (strcmp(longopts[option_index].name, "verbose") == 0) {
- options->verbose = true;
- } else if (strcmp(longopts[option_index].name, "quiet") == 0) {
- options->quiet = true;
- } else if (strcmp(longopts[option_index].name, "ignore-hints") == 0) {
- options->ignore_hints = true;
- } else if (strcmp(longopts[option_index].name, "decimal-cmap") == 0) {
- options->decimal_cmap = true;
- } else if (strcmp(longopts[option_index].name, "hex-cmap") == 0) {
- options->decimal_cmap = false;
- } else if (strcmp(longopts[option_index].name, "name-by-hash") == 0) {
- options->name_glyphs_by_hash = true;
- } else if (strcmp(longopts[option_index].name, "name-by-gid") == 0) {
- options->name_glyphs_by_gid = true;
- } else if (strcmp(longopts[option_index].name, "instr-as-bytes") == 0) {
- options->instr_as_bytes = true;
- } else if (strcmp(longopts[option_index].name, "glyph-name-prefix") == 0) {
- options->glyph_name_prefix = strdup(optarg);
- } else if (strcmp(longopts[option_index].name, "debug-wait-on-start") == 0) {
- options->debug_wait_on_start = true;
- }
- break;
- case 'v':
- show_version = true;
- break;
- case 'i':
- options->ignore_glyph_order = true;
- break;
- case 'h':
- show_help = true;
- break;
- case 'p':
- show_pretty = true;
- break;
- case 'o':
- outputPath = sdsnew(optarg);
- break;
- case 'q':
- options->quiet = true;
- break;
- case 'n':
- ttcindex = atoi(optarg);
- break;
- }
- }
-
- if (options->debug_wait_on_start) { getchar(); }
-
- options->logger->setVerbosity(options->logger,
- options->quiet ? 0 : options->verbose ? 0xFF : 1);
-
- if (show_help) {
- printInfo();
- printHelp();
- return 0;
- }
- if (show_version) {
- printInfo();
- return 0;
- }
-
- if (optind >= argc) {
- logError("Expected argument for input file name.\n");
- printHelp();
- exit(EXIT_FAILURE);
- } else {
- inPath = sdsnew(argv[optind]);
- }
-
- struct timespec begin;
-
- time_now(&begin);
-
- otfcc_SplineFontContainer *sfnt;
- loggedStep("Read SFNT") {
- logProgress("From file %s", inPath);
- FILE *file = u8fopen(inPath, "rb");
- sfnt = otfcc_readSFNT(file);
- if (!sfnt || sfnt->count == 0) {
- logError("Cannot read SFNT file \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- if (ttcindex >= sfnt->count) {
- logError("Subfont index %d out of range for \"%s\" (0 -- %d). Exit.\n", ttcindex,
- inPath, (sfnt->count - 1));
- exit(EXIT_FAILURE);
- }
- logStepTime;
- }
-
- otfcc_Font *font;
- loggedStep("Read Font") {
- otfcc_IFontBuilder *reader = otfcc_newOTFReader();
- font = reader->read(sfnt, ttcindex, options);
- if (!font) {
- logError("Font structure broken or corrupted \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- reader->free(reader);
- if (sfnt) otfcc_deleteSFNT(sfnt);
- logStepTime;
- }
- loggedStep("Consolidate") {
- otfcc_iFont.consolidate(font, options);
- logStepTime;
- }
- json_value *root;
- loggedStep("Dump") {
- otfcc_IFontSerializer *dumper = otfcc_newJsonWriter();
- root = (json_value *)dumper->serialize(font, options);
- if (!root) {
- logError("Font structure broken or corrupted \"%s\". Exit.\n", inPath);
- exit(EXIT_FAILURE);
- }
- logStepTime;
- dumper->free(dumper);
- }
-
- char *buf;
- size_t buflen;
- loggedStep("Serialize to JSON") {
- json_serialize_opts jsonOptions;
- jsonOptions.mode = json_serialize_mode_packed;
- jsonOptions.opts = 0;
- jsonOptions.indent_size = 4;
- if (show_pretty || (!outputPath && isatty(fileno(stdout)))) {
- jsonOptions.mode = json_serialize_mode_multiline;
- }
- if (show_ugly) jsonOptions.mode = json_serialize_mode_packed;
- buflen = json_measure_ex(root, jsonOptions);
- buf = calloc(1, buflen);
- json_serialize_ex(buf, root, jsonOptions);
- logStepTime;
- }
-
- loggedStep("Output") {
- if (outputPath) {
- FILE *outputFile = u8fopen(outputPath, "wb");
- if (!outputFile) {
- logError("Cannot write to file \"%s\". Exit.", outputPath);
- exit(EXIT_FAILURE);
- }
- if (add_bom) {
- fputc(0xEF, outputFile);
- fputc(0xBB, outputFile);
- fputc(0xBF, outputFile);
- }
- size_t actualLen = buflen - 1;
- while (!buf[actualLen])
- actualLen -= 1;
- fwrite(buf, sizeof(char), actualLen + 1, outputFile);
- fclose(outputFile);
- } else {
-#ifdef WIN32
- if (isatty(fileno(stdout))) {
- LPWSTR pwStr;
- DWORD dwNum = widen_utf8(buf, &pwStr);
- DWORD actual = 0;
- DWORD written = 0;
- const DWORD chunk = 0x10000;
- while (written < dwNum) {
- DWORD len = dwNum - written;
- if (len > chunk) len = chunk;
- WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), pwStr + written, len, &actual,
- NULL);
- written += len;
- }
- free(pwStr);
- } else {
- if (!no_bom) {
- fputc(0xEF, stdout);
- fputc(0xBB, stdout);
- fputc(0xBF, stdout);
- }
- fputs(buf, stdout);
- }
-#else
- if (add_bom) {
- fputc(0xEF, stdout);
- fputc(0xBB, stdout);
- fputc(0xBF, stdout);
- }
- fputs(buf, stdout);
-#endif
- }
- logStepTime;
- }
-
- loggedStep("Finalize") {
- free(buf);
- if (font) otfcc_iFont.free(font);
- if (root) json_builder_free(root);
- if (inPath) sdsfree(inPath);
- if (outputPath) sdsfree(outputPath);
- logStepTime;
- }
- otfcc_deleteOptions(options);
-
- return 0;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/platform.h b/Build/source/texk/web2c/mfluadir/otfcc/src/platform.h
deleted file mode 100644
index cb1ac79eb44..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/platform.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef CARYLL_CLI_PLATFORM_H
-#define CARYLL_CLI_PLATFORM_H
-
-#ifdef _WIN32
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef __MINGW32__
-#include <windows.h>
-#else
-#include <Windows.h>
-#endif
-#include "getopt.h"
-
-#ifdef _MSC_VER
-#include "winfns.h"
-#endif
-
-int get_argv_utf8(int *argc_ptr, char ***argv_ptr);
-int widen_utf8(const char *filename_utf8, LPWSTR *filename_w);
-FILE *__u8fopen(char *path, const char *mode);
-
-int get_argv_utf8(int *argc_ptr, char ***argv_ptr) {
- int argc;
- char **argv;
- wchar_t **argv_utf16 = CommandLineToArgvW(GetCommandLineW(), &argc);
- int i;
- int offset = (argc + 1) * sizeof(char *);
- int size = offset;
- for (i = 0; i < argc; i++) {
- size += WideCharToMultiByte(CP_UTF8, 0, argv_utf16[i], -1, 0, 0, 0, 0);
- }
- argv = (char **)malloc(size);
- for (i = 0; i < argc; i++) {
- argv[i] = (char *)argv + offset;
- offset += WideCharToMultiByte(CP_UTF8, 0, argv_utf16[i], -1, argv[i], size - offset, 0, 0);
- }
- *argc_ptr = argc;
- *argv_ptr = argv;
- return 0;
-}
-int widen_utf8(const char *filename_utf8, LPWSTR *filename_w) {
- int num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, 0, 0);
- int size = sizeof(WCHAR);
- *filename_w = (LPWSTR)malloc(size * num_chars);
- MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
- return num_chars;
-}
-FILE *__u8fopen(char *path, const char *mode) {
- LPWSTR wpath, wmode;
- widen_utf8(path, &wpath);
- widen_utf8(mode, &wmode);
- FILE *f = _wfopen(wpath, wmode);
- free(wpath);
- free(wmode);
- return f;
-}
-#define u8fopen __u8fopen
-
-#ifdef _MSC_VER
-#include <io.h>
-#define isatty _isatty
-#define fileno _fileno
-#elif __MINGW32__
-#include <unistd.h>
-#endif
-
-#else
-
-#include <getopt.h>
-#define u8fopen fopen
-
-#endif
-#endif
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.c b/Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.c
deleted file mode 100644
index bbb775ee482..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "stopwatch.h"
-#ifdef _WIN32
-LARGE_INTEGER getFILETIMEoffset(void);
-
-LARGE_INTEGER getFILETIMEoffset() {
- SYSTEMTIME s;
- FILETIME f;
- LARGE_INTEGER t;
-
- s.wYear = 1970;
- s.wMonth = 1;
- s.wDay = 1;
- s.wHour = 0;
- s.wMinute = 0;
- s.wSecond = 0;
- s.wMilliseconds = 0;
- SystemTimeToFileTime(&s, &f);
- t.QuadPart = f.dwHighDateTime;
- t.QuadPart <<= 32;
- t.QuadPart |= f.dwLowDateTime;
- return (t);
-}
-
-void time_now(struct timespec *tv) {
- LARGE_INTEGER t;
- FILETIME f;
- double microseconds;
- static LARGE_INTEGER offset;
- static double frequencyToMicroseconds;
- static int initialized = 0;
- static BOOL usePerformanceCounter = 0;
-
- if (!initialized) {
- LARGE_INTEGER performanceFrequency;
- initialized = 1;
- usePerformanceCounter = QueryPerformanceFrequency(&performanceFrequency);
- if (usePerformanceCounter) {
- QueryPerformanceCounter(&offset);
- frequencyToMicroseconds = (double)performanceFrequency.QuadPart / 1000000.0;
- } else {
- offset = getFILETIMEoffset();
- frequencyToMicroseconds = 10.0;
- }
- }
- if (usePerformanceCounter)
- QueryPerformanceCounter(&t);
- else {
- GetSystemTimeAsFileTime(&f);
- t.QuadPart = f.dwHighDateTime;
- t.QuadPart <<= 32;
- t.QuadPart |= f.dwLowDateTime;
- }
-
- t.QuadPart -= offset.QuadPart;
- microseconds = (double)t.QuadPart / frequencyToMicroseconds;
- t.QuadPart = microseconds;
- tv->tv_sec = t.QuadPart / 1000000;
- tv->tv_nsec = t.QuadPart % 1000000 * 1000;
-}
-#elif __MACH__
-#define ORWL_NANO (+1.0E-9)
-#define ORWL_GIGA UINT64_C(1000000000)
-
-static double orwl_timebase = 0.0;
-static uint64_t orwl_timestart = 0;
-
-void time_now(struct timespec *tv) {
- // be more careful in a multithreaded environement
- if (!orwl_timestart) {
- mach_timebase_info_data_t tb = {0};
- mach_timebase_info(&tb);
- orwl_timebase = tb.numer;
- orwl_timebase /= tb.denom;
- orwl_timestart = mach_absolute_time();
- }
- double diff = (mach_absolute_time() - orwl_timestart) * orwl_timebase;
- tv->tv_sec = diff * ORWL_NANO;
- tv->tv_nsec = diff - (tv->tv_sec * ORWL_GIGA);
-}
-#else
-void time_now(struct timespec *tv) {
- clock_gettime(CLOCK_REALTIME, tv);
-}
-#endif
-
-#define BILLION 1000000000
-
-static void timespec_diff(struct timespec *start, struct timespec *stop, struct timespec *result) {
- if ((stop->tv_nsec - start->tv_nsec) < 0) {
- result->tv_sec = stop->tv_sec - start->tv_sec - 1;
- result->tv_nsec = stop->tv_nsec - start->tv_nsec + BILLION;
- } else {
- result->tv_sec = stop->tv_sec - start->tv_sec;
- result->tv_nsec = stop->tv_nsec - start->tv_nsec;
- }
-
- return;
-}
-
-sds push_stopwatch(struct timespec *sofar) {
- struct timespec ends;
- time_now(&ends);
- struct timespec diff;
- timespec_diff(sofar, &ends, &diff);
- *sofar = ends;
- sds log = sdscatprintf(sdsempty(), "Step time = %gs.\n", diff.tv_sec + diff.tv_nsec / (double)BILLION);
- return log;
-}
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.h b/Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.h
deleted file mode 100644
index 2bdce33b422..00000000000
--- a/Build/source/texk/web2c/mfluadir/otfcc/src/stopwatch.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef CARYLL_SUPPORT_STOPWATCH_H
-#define CARYLL_SUPPORT_STOPWATCH_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include "dep/sds.h"
-
-#ifdef _WIN32
-// Windows
-#ifdef __MINGW32__
-#include <windows.h>
-#else
-#include <Windows.h>
-#endif
-#elif __MACH__
-// OSX
-#include <unistd.h>
-#include <mach/mach_time.h>
-#else
-#include <unistd.h>
-#endif
-void time_now(struct timespec *tv);
-sds push_stopwatch(struct timespec *sofar);
-#define logStepTime \
- options->logger->logSDS(options->logger, log_vl_progress, log_type_progress, push_stopwatch(&begin));
-
-#endif