From f372862c42d234710b6057449b46818e63181c90 Mon Sep 17 00:00:00 2001 From: Taco Hoekwater Date: Sun, 4 Apr 2010 13:55:46 +0000 Subject: import luatex 0.60.0 (with small local changes, see luatexdir/ChangeLog) and do an autoreconf git-svn-id: svn://tug.org/texlive/trunk@17680 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/ChangeLog | 7 + Build/source/texk/web2c/Makefile.am | 2 +- Build/source/texk/web2c/Makefile.in | 3183 +- Build/source/texk/web2c/aclocal.m4 | 889 +- Build/source/texk/web2c/c-auto.in | 22 + Build/source/texk/web2c/configure | 425 +- Build/source/texk/web2c/configure.ac | 4 + Build/source/texk/web2c/doc/Makefile.in | 8 +- Build/source/texk/web2c/lib/Makefile.in | 8 +- Build/source/texk/web2c/luatexdir/NEWS | 638 +- Build/source/texk/web2c/luatexdir/README | 87 - Build/source/texk/web2c/luatexdir/am/libluatex.am | 639 +- .../source/texk/web2c/luatexdir/am/luafontforge.am | 6 +- Build/source/texk/web2c/luatexdir/am/luamisc.am | 3 +- Build/source/texk/web2c/luatexdir/am/luatangle.am | 30 - Build/source/texk/web2c/luatexdir/am/luatex.am | 45 +- Build/source/texk/web2c/luatexdir/change-files.txt | 35 - Build/source/texk/web2c/luatexdir/commands.h | 554 - Build/source/texk/web2c/luatexdir/dvi/dvigen.h | 193 + Build/source/texk/web2c/luatexdir/dvi/dvigen.w | 1420 + Build/source/texk/web2c/luatexdir/font/dofont.c | 179 - Build/source/texk/web2c/luatexdir/font/dofont.w | 147 + Build/source/texk/web2c/luatexdir/font/luafont.c | 2322 -- Build/source/texk/web2c/luatexdir/font/luafont.w | 2400 ++ .../source/texk/web2c/luatexdir/font/luatexfont.h | 80 +- Build/source/texk/web2c/luatexdir/font/macnames.c | 313 - Build/source/texk/web2c/luatexdir/font/mapfile.c | 1003 - Build/source/texk/web2c/luatexdir/font/mapfile.h | 106 +- Build/source/texk/web2c/luatexdir/font/mapfile.w | 752 + Build/source/texk/web2c/luatexdir/font/pkin.c | 433 - Build/source/texk/web2c/luatexdir/font/pkin.w | 434 + Build/source/texk/web2c/luatexdir/font/sfnt.c | 621 - Build/source/texk/web2c/luatexdir/font/sfnt.h | 8 +- Build/source/texk/web2c/luatexdir/font/sfnt.w | 466 + Build/source/texk/web2c/luatexdir/font/subfont.c | 276 - Build/source/texk/web2c/luatexdir/font/subfont.txt | 103 +- Build/source/texk/web2c/luatexdir/font/subfont.w | 266 + Build/source/texk/web2c/luatexdir/font/texfont.c | 1752 - Build/source/texk/web2c/luatexdir/font/texfont.h | 283 +- Build/source/texk/web2c/luatexdir/font/texfont.w | 1774 + Build/source/texk/web2c/luatexdir/font/tfmofm.c | 1116 - Build/source/texk/web2c/luatexdir/font/tfmofm.w | 1117 + Build/source/texk/web2c/luatexdir/font/tounicode.c | 610 - Build/source/texk/web2c/luatexdir/font/tounicode.w | 626 + Build/source/texk/web2c/luatexdir/font/tt_glyf.c | 651 - Build/source/texk/web2c/luatexdir/font/tt_glyf.w | 669 + Build/source/texk/web2c/luatexdir/font/tt_table.c | 476 - Build/source/texk/web2c/luatexdir/font/tt_table.w | 463 + Build/source/texk/web2c/luatexdir/font/vfovf.c | 1636 - Build/source/texk/web2c/luatexdir/font/vfovf.w | 1624 + Build/source/texk/web2c/luatexdir/font/vfpacket.c | 375 - Build/source/texk/web2c/luatexdir/font/vfpacket.w | 375 + Build/source/texk/web2c/luatexdir/font/writecff.c | 3444 -- Build/source/texk/web2c/luatexdir/font/writecff.h | 6 +- Build/source/texk/web2c/luatexdir/font/writecff.w | 3526 ++ Build/source/texk/web2c/luatexdir/font/writeenc.c | 187 - Build/source/texk/web2c/luatexdir/font/writeenc.w | 161 + Build/source/texk/web2c/luatexdir/font/writefont.c | 1025 - Build/source/texk/web2c/luatexdir/font/writefont.w | 1010 + Build/source/texk/web2c/luatexdir/font/writet1.c | 1814 -- Build/source/texk/web2c/luatexdir/font/writet1.w | 1726 + Build/source/texk/web2c/luatexdir/font/writet3.c | 338 - Build/source/texk/web2c/luatexdir/font/writet3.w | 331 + Build/source/texk/web2c/luatexdir/font/writettf.c | 1518 - Build/source/texk/web2c/luatexdir/font/writettf.h | 18 +- Build/source/texk/web2c/luatexdir/font/writettf.w | 1834 ++ .../source/texk/web2c/luatexdir/font/writetype0.c | 125 - .../source/texk/web2c/luatexdir/font/writetype0.w | 123 + .../source/texk/web2c/luatexdir/font/writetype2.c | 442 - .../source/texk/web2c/luatexdir/font/writetype2.w | 427 + .../source/texk/web2c/luatexdir/get_svnversion.sh | 13 - .../texk/web2c/luatexdir/getluatexsvnversion.sh | 25 + Build/source/texk/web2c/luatexdir/hyphen.h | 61 - Build/source/texk/web2c/luatexdir/image/epdf.c | 81 - Build/source/texk/web2c/luatexdir/image/epdf.h | 211 +- Build/source/texk/web2c/luatexdir/image/epdf.w | 34 + Build/source/texk/web2c/luatexdir/image/image.h | 94 +- .../source/texk/web2c/luatexdir/image/pdftoepdf.cc | 1103 +- .../source/texk/web2c/luatexdir/image/pdftoepdf.h | 10 +- Build/source/texk/web2c/luatexdir/image/writeimg.c | 959 - Build/source/texk/web2c/luatexdir/image/writeimg.h | 57 +- Build/source/texk/web2c/luatexdir/image/writeimg.w | 823 + .../source/texk/web2c/luatexdir/image/writejbig2.c | 852 - .../source/texk/web2c/luatexdir/image/writejbig2.h | 6 +- .../source/texk/web2c/luatexdir/image/writejbig2.w | 841 + Build/source/texk/web2c/luatexdir/image/writejpg.c | 281 - Build/source/texk/web2c/luatexdir/image/writejpg.h | 6 +- Build/source/texk/web2c/luatexdir/image/writejpg.w | 294 + Build/source/texk/web2c/luatexdir/image/writepng.c | 673 - Build/source/texk/web2c/luatexdir/image/writepng.h | 8 +- Build/source/texk/web2c/luatexdir/image/writepng.w | 689 + Build/source/texk/web2c/luatexdir/inc-epdf.h | 8 - Build/source/texk/web2c/luatexdir/inc-extra.h | 4 - Build/source/texk/web2c/luatexdir/inc-vfovf.h | 2 - Build/source/texk/web2c/luatexdir/lang/hnjalloc.c | 74 - Build/source/texk/web2c/luatexdir/lang/hnjalloc.h | 10 +- Build/source/texk/web2c/luatexdir/lang/hnjalloc.w | 66 + Build/source/texk/web2c/luatexdir/lang/hyphen.c | 850 - Build/source/texk/web2c/luatexdir/lang/hyphen.h | 60 + Build/source/texk/web2c/luatexdir/lang/hyphen.w | 857 + Build/source/texk/web2c/luatexdir/lang/texlang.c | 1025 - Build/source/texk/web2c/luatexdir/lang/texlang.h | 82 + Build/source/texk/web2c/luatexdir/lang/texlang.w | 1111 + .../source/texk/web2c/luatexdir/lua/lcallbacklib.c | 49 +- Build/source/texk/web2c/luatexdir/lua/lepdflib.cc | 58 + Build/source/texk/web2c/luatexdir/lua/lfontlib.c | 86 +- Build/source/texk/web2c/luatexdir/lua/limglib.c | 195 +- Build/source/texk/web2c/luatexdir/lua/liolib.c | 21 +- Build/source/texk/web2c/luatexdir/lua/lkpselib.c | 427 +- Build/source/texk/web2c/luatexdir/lua/llanglib.c | 60 +- Build/source/texk/web2c/luatexdir/lua/llualib.c | 92 +- Build/source/texk/web2c/luatexdir/lua/lnodelib.c | 701 +- Build/source/texk/web2c/luatexdir/lua/loslibext.c | 147 +- Build/source/texk/web2c/luatexdir/lua/lpdflib.c | 754 +- Build/source/texk/web2c/luatexdir/lua/lstatslib.c | 194 +- Build/source/texk/web2c/luatexdir/lua/ltexiolib.c | 47 +- Build/source/texk/web2c/luatexdir/lua/ltexlib.c | 1434 +- Build/source/texk/web2c/luatexdir/lua/ltokenlib.c | 81 +- Build/source/texk/web2c/luatexdir/lua/luagen.h | 27 + Build/source/texk/web2c/luatexdir/lua/luagen.w | 55 + Build/source/texk/web2c/luatexdir/lua/luainit.c | 655 - Build/source/texk/web2c/luatexdir/lua/luainit.w | 930 + Build/source/texk/web2c/luatexdir/lua/luanode.c | 330 - Build/source/texk/web2c/luatexdir/lua/luanode.w | 360 + Build/source/texk/web2c/luatexdir/lua/luastuff.c | 406 - Build/source/texk/web2c/luatexdir/lua/luastuff.w | 493 + Build/source/texk/web2c/luatexdir/lua/luatex-api.h | 202 + Build/source/texk/web2c/luatexdir/lua/luatex.c | 364 - Build/source/texk/web2c/luatexdir/lua/luatoken.c | 602 - Build/source/texk/web2c/luatexdir/lua/luatoken.w | 423 + Build/source/texk/web2c/luatexdir/lua/texluac.c | 231 - Build/source/texk/web2c/luatexdir/lua/texluac.w | 243 + Build/source/texk/web2c/luatexdir/lua51/lcoco.c | 2 +- Build/source/texk/web2c/luatexdir/lua51/loadlib.c | 23 + Build/source/texk/web2c/luatexdir/lua51/luaconf.h | 35 +- .../texk/web2c/luatexdir/luafilesystem/src/lfs.c | 60 +- .../luafontloader/fontforge/Unicode/Makefile.in | 2 +- .../luafontloader/fontforge/Unicode/cjk.c | 30 + .../luafontloader/fontforge/Unicode/gwwiconv.c | 175 +- .../luafontloader/fontforge/Unicode/ucharmap.c | 276 +- .../luafontloader/fontforge/fontforge/autohint.c | 8 + .../luafontloader/fontforge/fontforge/encoding.c | 13 +- .../luafontloader/fontforge/fontforge/macbinary.c | 1946 +- .../luafontloader/fontforge/fontforge/nouiutil.c | 2 +- .../luafontloader/fontforge/fontforge/parsettf.c | 166 +- .../fontforge/fontforge/parsettfatt.c | 5 +- .../luafontloader/fontforge/fontforge/psread.c | 701 +- .../luafontloader/fontforge/fontforge/splinefont.c | 13 +- .../luafontloader/fontforge/fontforge/splinefont.h | 11 +- .../fontforge/fontforge/splineutil2.c | 2 +- .../luafontloader/fontforge/fontforge/tottfaat.c | 2 + .../luafontloader/fontforge/inc/chardata.h | 4 - .../luafontloader/fontforge/inc/ustring.h | 4 - .../web2c/luatexdir/luafontloader/src/ffdummies.c | 324 +- .../web2c/luatexdir/luafontloader/src/luafflib.c | 4196 +-- Build/source/texk/web2c/luatexdir/luamd5/luamd5.h | 20 + Build/source/texk/web2c/luatexdir/luamd5/md5.c | 5 +- Build/source/texk/web2c/luatexdir/luamd5/md5.h | 20 - Build/source/texk/web2c/luatexdir/luamd5/md5_lua.c | 38 + Build/source/texk/web2c/luatexdir/luamd5/md5lib.c | 2 +- Build/source/texk/web2c/luatexdir/luatangle.ch | 508 - Build/source/texk/web2c/luatexdir/luatangle.test | 10 - Build/source/texk/web2c/luatexdir/luatangle.web | 3329 -- Build/source/texk/web2c/luatexdir/luatex-api.h | 143 - Build/source/texk/web2c/luatexdir/luatex.c | 1063 + Build/source/texk/web2c/luatexdir/luatex.ch | 2176 -- Build/source/texk/web2c/luatexdir/luatex.defines | 900 - Build/source/texk/web2c/luatexdir/luatex.h | 161 +- Build/source/texk/web2c/luatexdir/luatex.mk | 158 - Build/source/texk/web2c/luatexdir/luatex.web | 31941 ------------------- .../texk/web2c/luatexdir/luatex_svnversion.h | 1 + Build/source/texk/web2c/luatexdir/luatexextra.in | 40 - Build/source/texk/web2c/luatexdir/makecpool.c | 93 - Build/source/texk/web2c/luatexdir/managed-sa.c | 287 - Build/source/texk/web2c/luatexdir/managed-sa.h | 76 - Build/source/texk/web2c/luatexdir/mathcodes.c | 473 - Build/source/texk/web2c/luatexdir/nodes.h | 778 - Build/source/texk/web2c/luatexdir/ocp/ocp.h | 52 + Build/source/texk/web2c/luatexdir/ocp/ocp.w | 201 + Build/source/texk/web2c/luatexdir/ocp/ocplist.h | 91 + Build/source/texk/web2c/luatexdir/ocp/ocplist.w | 357 + Build/source/texk/web2c/luatexdir/ocp/readocp.h | 61 + Build/source/texk/web2c/luatexdir/ocp/readocp.w | 273 + Build/source/texk/web2c/luatexdir/ocp/runocp.h | 60 + Build/source/texk/web2c/luatexdir/ocp/runocp.w | 1069 + Build/source/texk/web2c/luatexdir/pdf/pagetree.c | 266 - Build/source/texk/web2c/luatexdir/pdf/pagetree.h | 8 +- Build/source/texk/web2c/luatexdir/pdf/pagetree.w | 269 + Build/source/texk/web2c/luatexdir/pdf/pdfaction.h | 78 + Build/source/texk/web2c/luatexdir/pdf/pdfaction.w | 207 + Build/source/texk/web2c/luatexdir/pdf/pdfannot.h | 37 + Build/source/texk/web2c/luatexdir/pdf/pdfannot.w | 99 + .../texk/web2c/luatexdir/pdf/pdfcolorstack.h | 44 + .../texk/web2c/luatexdir/pdf/pdfcolorstack.w | 386 + Build/source/texk/web2c/luatexdir/pdf/pdfdest.h | 66 + Build/source/texk/web2c/luatexdir/pdf/pdfdest.w | 417 + Build/source/texk/web2c/luatexdir/pdf/pdffont.h | 48 + Build/source/texk/web2c/luatexdir/pdf/pdffont.w | 495 + Build/source/texk/web2c/luatexdir/pdf/pdfgen.h | 239 + Build/source/texk/web2c/luatexdir/pdf/pdfgen.w | 2479 ++ Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h | 30 + Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w | 222 + Build/source/texk/web2c/luatexdir/pdf/pdfimage.h | 28 + Build/source/texk/web2c/luatexdir/pdf/pdfimage.w | 156 + Build/source/texk/web2c/luatexdir/pdf/pdflink.h | 39 + Build/source/texk/web2c/luatexdir/pdf/pdflink.w | 166 + Build/source/texk/web2c/luatexdir/pdf/pdflistout.h | 50 + Build/source/texk/web2c/luatexdir/pdf/pdflistout.w | 1139 + Build/source/texk/web2c/luatexdir/pdf/pdfliteral.h | 34 + Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w | 154 + Build/source/texk/web2c/luatexdir/pdf/pdfobj.h | 66 + Build/source/texk/web2c/luatexdir/pdf/pdfobj.w | 214 + Build/source/texk/web2c/luatexdir/pdf/pdfoutline.h | 28 + Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w | 240 + Build/source/texk/web2c/luatexdir/pdf/pdfpage.c | 561 - Build/source/texk/web2c/luatexdir/pdf/pdfpage.h | 67 +- Build/source/texk/web2c/luatexdir/pdf/pdfpage.w | 292 + Build/source/texk/web2c/luatexdir/pdf/pdfrule.h | 27 + Build/source/texk/web2c/luatexdir/pdf/pdfrule.w | 70 + .../texk/web2c/luatexdir/pdf/pdfsaverestore.h | 37 + .../texk/web2c/luatexdir/pdf/pdfsaverestore.w | 88 + .../source/texk/web2c/luatexdir/pdf/pdfsetmatrix.h | 52 + .../source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w | 238 + Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h | 30 + Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w | 332 + Build/source/texk/web2c/luatexdir/pdf/pdftables.h | 136 + Build/source/texk/web2c/luatexdir/pdf/pdftables.w | 456 + Build/source/texk/web2c/luatexdir/pdf/pdfthread.h | 71 + Build/source/texk/web2c/luatexdir/pdf/pdfthread.w | 290 + Build/source/texk/web2c/luatexdir/pdf/pdftypes.h | 291 + Build/source/texk/web2c/luatexdir/pdf/pdfxform.h | 56 + Build/source/texk/web2c/luatexdir/pdf/pdfxform.w | 128 + Build/source/texk/web2c/luatexdir/primitive.h | 82 - Build/source/texk/web2c/luatexdir/ptexlib.h | 590 +- Build/source/texk/web2c/luatexdir/ptexmac.h | 172 - Build/source/texk/web2c/luatexdir/tex/align.h | 55 + Build/source/texk/web2c/luatexdir/tex/align.w | 1153 + Build/source/texk/web2c/luatexdir/tex/arithmetic.h | 81 + Build/source/texk/web2c/luatexdir/tex/arithmetic.w | 734 + Build/source/texk/web2c/luatexdir/tex/buildpage.h | 75 + Build/source/texk/web2c/luatexdir/tex/buildpage.w | 1057 + Build/source/texk/web2c/luatexdir/tex/commands.h | 355 + Build/source/texk/web2c/luatexdir/tex/commands.w | 1223 + .../source/texk/web2c/luatexdir/tex/conditional.h | 82 + .../source/texk/web2c/luatexdir/tex/conditional.w | 539 + Build/source/texk/web2c/luatexdir/tex/directions.h | 347 + Build/source/texk/web2c/luatexdir/tex/directions.w | 202 + Build/source/texk/web2c/luatexdir/tex/dumpdata.h | 115 + Build/source/texk/web2c/luatexdir/tex/dumpdata.w | 527 + .../source/texk/web2c/luatexdir/tex/equivalents.h | 560 + .../source/texk/web2c/luatexdir/tex/equivalents.w | 1171 + Build/source/texk/web2c/luatexdir/tex/errors.h | 102 + Build/source/texk/web2c/luatexdir/tex/errors.w | 625 + Build/source/texk/web2c/luatexdir/tex/expand.h | 102 + Build/source/texk/web2c/luatexdir/tex/expand.w | 789 + Build/source/texk/web2c/luatexdir/tex/extensions.h | 118 + Build/source/texk/web2c/luatexdir/tex/extensions.w | 1217 + Build/source/texk/web2c/luatexdir/tex/filename.c | 353 - Build/source/texk/web2c/luatexdir/tex/filename.h | 34 + Build/source/texk/web2c/luatexdir/tex/filename.w | 349 + Build/source/texk/web2c/luatexdir/tex/inputstack.h | 353 + Build/source/texk/web2c/luatexdir/tex/inputstack.w | 800 + Build/source/texk/web2c/luatexdir/tex/linebreak.c | 2053 -- Build/source/texk/web2c/luatexdir/tex/linebreak.h | 106 + Build/source/texk/web2c/luatexdir/tex/linebreak.w | 2184 ++ Build/source/texk/web2c/luatexdir/tex/mainbody.h | 252 + Build/source/texk/web2c/luatexdir/tex/mainbody.w | 745 + .../source/texk/web2c/luatexdir/tex/maincontrol.h | 196 + .../source/texk/web2c/luatexdir/tex/maincontrol.w | 3610 +++ Build/source/texk/web2c/luatexdir/tex/math.c | 2203 -- Build/source/texk/web2c/luatexdir/tex/mathcodes.h | 76 + Build/source/texk/web2c/luatexdir/tex/mathcodes.w | 508 + Build/source/texk/web2c/luatexdir/tex/memoryword.h | 129 + Build/source/texk/web2c/luatexdir/tex/memoryword.w | 58 + Build/source/texk/web2c/luatexdir/tex/mlist.c | 4028 --- Build/source/texk/web2c/luatexdir/tex/mlist.h | 35 + Build/source/texk/web2c/luatexdir/tex/mlist.w | 3679 +++ Build/source/texk/web2c/luatexdir/tex/nesting.h | 71 + Build/source/texk/web2c/luatexdir/tex/nesting.w | 447 + Build/source/texk/web2c/luatexdir/tex/packaging.h | 150 + Build/source/texk/web2c/luatexdir/tex/packaging.w | 1789 ++ .../texk/web2c/luatexdir/tex/postlinebreak.c | 553 - .../texk/web2c/luatexdir/tex/postlinebreak.h | 59 + .../texk/web2c/luatexdir/tex/postlinebreak.w | 557 + Build/source/texk/web2c/luatexdir/tex/primitive.c | 654 - Build/source/texk/web2c/luatexdir/tex/primitive.h | 92 + Build/source/texk/web2c/luatexdir/tex/primitive.w | 664 + Build/source/texk/web2c/luatexdir/tex/printing.h | 124 + Build/source/texk/web2c/luatexdir/tex/printing.w | 984 + Build/source/texk/web2c/luatexdir/tex/scanning.h | 111 + Build/source/texk/web2c/luatexdir/tex/scanning.w | 2641 ++ Build/source/texk/web2c/luatexdir/tex/stringpool.h | 146 + Build/source/texk/web2c/luatexdir/tex/stringpool.w | 492 + Build/source/texk/web2c/luatexdir/tex/texdeffont.c | 190 - Build/source/texk/web2c/luatexdir/tex/texdeffont.h | 31 + Build/source/texk/web2c/luatexdir/tex/texdeffont.w | 204 + Build/source/texk/web2c/luatexdir/tex/texfileio.h | 144 + Build/source/texk/web2c/luatexdir/tex/texfileio.w | 1368 + Build/source/texk/web2c/luatexdir/tex/texmath.h | 329 + Build/source/texk/web2c/luatexdir/tex/texmath.w | 2260 ++ Build/source/texk/web2c/luatexdir/tex/texnodes.c | 2892 -- Build/source/texk/web2c/luatexdir/tex/texnodes.h | 780 + Build/source/texk/web2c/luatexdir/tex/texnodes.w | 3391 ++ Build/source/texk/web2c/luatexdir/tex/texpdf.c | 186 - Build/source/texk/web2c/luatexdir/tex/textcodes.h | 46 + Build/source/texk/web2c/luatexdir/tex/textcodes.w | 319 + Build/source/texk/web2c/luatexdir/tex/textoken.c | 1173 - Build/source/texk/web2c/luatexdir/tex/textoken.h | 179 + Build/source/texk/web2c/luatexdir/tex/textoken.w | 2410 ++ Build/source/texk/web2c/luatexdir/texmath.h | 338 - Build/source/texk/web2c/luatexdir/textcodes.c | 321 - Build/source/texk/web2c/luatexdir/tokens.h | 86 - Build/source/texk/web2c/luatexdir/utils/avl.c | 7 +- Build/source/texk/web2c/luatexdir/utils/avl.h | 2 + Build/source/texk/web2c/luatexdir/utils/avlstuff.c | 181 - Build/source/texk/web2c/luatexdir/utils/avlstuff.h | 5 +- Build/source/texk/web2c/luatexdir/utils/avlstuff.w | 63 + .../source/texk/web2c/luatexdir/utils/managed-sa.h | 75 + .../source/texk/web2c/luatexdir/utils/managed-sa.w | 284 + .../texk/web2c/luatexdir/utils/synctex-common.h | 51 + .../texk/web2c/luatexdir/utils/synctex-luatex.h | 99 + Build/source/texk/web2c/luatexdir/utils/synctex.c | 1661 +- Build/source/texk/web2c/luatexdir/utils/synctex.h | 48 +- Build/source/texk/web2c/luatexdir/utils/utils.c | 1809 -- Build/source/texk/web2c/luatexdir/utils/utils.h | 69 +- Build/source/texk/web2c/luatexdir/utils/utils.w | 465 + Build/source/texk/web2c/luatexdir/utils/writezip.c | 99 - Build/source/texk/web2c/man/Makefile.in | 8 +- Build/source/texk/web2c/omegafonts/Makefile.in | 8 +- Build/source/texk/web2c/otps/Makefile.in | 8 +- Build/source/texk/web2c/web2c/Makefile.in | 13 +- Build/source/texk/web2c/web2c/aclocal.m4 | 6 +- Build/source/texk/web2c/web2c/configure | 6 +- Build/source/texk/web2c/window/Makefile.in | 8 +- 334 files changed, 102497 insertions(+), 96441 deletions(-) delete mode 100644 Build/source/texk/web2c/luatexdir/README delete mode 100644 Build/source/texk/web2c/luatexdir/change-files.txt delete mode 100644 Build/source/texk/web2c/luatexdir/commands.h create mode 100644 Build/source/texk/web2c/luatexdir/dvi/dvigen.h create mode 100644 Build/source/texk/web2c/luatexdir/dvi/dvigen.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/dofont.c create mode 100644 Build/source/texk/web2c/luatexdir/font/dofont.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/luafont.c create mode 100644 Build/source/texk/web2c/luatexdir/font/luafont.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/macnames.c delete mode 100644 Build/source/texk/web2c/luatexdir/font/mapfile.c create mode 100644 Build/source/texk/web2c/luatexdir/font/mapfile.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/pkin.c create mode 100644 Build/source/texk/web2c/luatexdir/font/pkin.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/sfnt.c create mode 100644 Build/source/texk/web2c/luatexdir/font/sfnt.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/subfont.c create mode 100644 Build/source/texk/web2c/luatexdir/font/subfont.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/texfont.c create mode 100644 Build/source/texk/web2c/luatexdir/font/texfont.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/tfmofm.c create mode 100644 Build/source/texk/web2c/luatexdir/font/tfmofm.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/tounicode.c create mode 100644 Build/source/texk/web2c/luatexdir/font/tounicode.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/tt_glyf.c create mode 100644 Build/source/texk/web2c/luatexdir/font/tt_glyf.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/tt_table.c create mode 100644 Build/source/texk/web2c/luatexdir/font/tt_table.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/vfovf.c create mode 100644 Build/source/texk/web2c/luatexdir/font/vfovf.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/vfpacket.c create mode 100644 Build/source/texk/web2c/luatexdir/font/vfpacket.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writecff.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writecff.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writeenc.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writeenc.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writefont.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writefont.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writet1.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writet1.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writet3.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writet3.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writettf.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writettf.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writetype0.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writetype0.w delete mode 100644 Build/source/texk/web2c/luatexdir/font/writetype2.c create mode 100644 Build/source/texk/web2c/luatexdir/font/writetype2.w delete mode 100755 Build/source/texk/web2c/luatexdir/get_svnversion.sh create mode 100755 Build/source/texk/web2c/luatexdir/getluatexsvnversion.sh delete mode 100644 Build/source/texk/web2c/luatexdir/hyphen.h delete mode 100644 Build/source/texk/web2c/luatexdir/image/epdf.c create mode 100644 Build/source/texk/web2c/luatexdir/image/epdf.w delete mode 100644 Build/source/texk/web2c/luatexdir/image/writeimg.c create mode 100644 Build/source/texk/web2c/luatexdir/image/writeimg.w delete mode 100644 Build/source/texk/web2c/luatexdir/image/writejbig2.c create mode 100644 Build/source/texk/web2c/luatexdir/image/writejbig2.w delete mode 100644 Build/source/texk/web2c/luatexdir/image/writejpg.c create mode 100644 Build/source/texk/web2c/luatexdir/image/writejpg.w delete mode 100644 Build/source/texk/web2c/luatexdir/image/writepng.c create mode 100644 Build/source/texk/web2c/luatexdir/image/writepng.w delete mode 100644 Build/source/texk/web2c/luatexdir/inc-epdf.h delete mode 100644 Build/source/texk/web2c/luatexdir/inc-extra.h delete mode 100644 Build/source/texk/web2c/luatexdir/inc-vfovf.h delete mode 100644 Build/source/texk/web2c/luatexdir/lang/hnjalloc.c create mode 100644 Build/source/texk/web2c/luatexdir/lang/hnjalloc.w delete mode 100644 Build/source/texk/web2c/luatexdir/lang/hyphen.c create mode 100644 Build/source/texk/web2c/luatexdir/lang/hyphen.h create mode 100644 Build/source/texk/web2c/luatexdir/lang/hyphen.w delete mode 100644 Build/source/texk/web2c/luatexdir/lang/texlang.c create mode 100644 Build/source/texk/web2c/luatexdir/lang/texlang.h create mode 100644 Build/source/texk/web2c/luatexdir/lang/texlang.w create mode 100644 Build/source/texk/web2c/luatexdir/lua/lepdflib.cc create mode 100644 Build/source/texk/web2c/luatexdir/lua/luagen.h create mode 100644 Build/source/texk/web2c/luatexdir/lua/luagen.w delete mode 100644 Build/source/texk/web2c/luatexdir/lua/luainit.c create mode 100644 Build/source/texk/web2c/luatexdir/lua/luainit.w delete mode 100644 Build/source/texk/web2c/luatexdir/lua/luanode.c create mode 100644 Build/source/texk/web2c/luatexdir/lua/luanode.w delete mode 100644 Build/source/texk/web2c/luatexdir/lua/luastuff.c create mode 100644 Build/source/texk/web2c/luatexdir/lua/luastuff.w create mode 100644 Build/source/texk/web2c/luatexdir/lua/luatex-api.h delete mode 100644 Build/source/texk/web2c/luatexdir/lua/luatex.c delete mode 100644 Build/source/texk/web2c/luatexdir/lua/luatoken.c create mode 100644 Build/source/texk/web2c/luatexdir/lua/luatoken.w delete mode 100644 Build/source/texk/web2c/luatexdir/lua/texluac.c create mode 100644 Build/source/texk/web2c/luatexdir/lua/texluac.w create mode 100644 Build/source/texk/web2c/luatexdir/luamd5/luamd5.h delete mode 100644 Build/source/texk/web2c/luatexdir/luamd5/md5.h create mode 100644 Build/source/texk/web2c/luatexdir/luamd5/md5_lua.c delete mode 100644 Build/source/texk/web2c/luatexdir/luatangle.ch delete mode 100755 Build/source/texk/web2c/luatexdir/luatangle.test delete mode 100644 Build/source/texk/web2c/luatexdir/luatangle.web delete mode 100644 Build/source/texk/web2c/luatexdir/luatex-api.h create mode 100644 Build/source/texk/web2c/luatexdir/luatex.c delete mode 100644 Build/source/texk/web2c/luatexdir/luatex.ch delete mode 100644 Build/source/texk/web2c/luatexdir/luatex.defines delete mode 100644 Build/source/texk/web2c/luatexdir/luatex.mk delete mode 100644 Build/source/texk/web2c/luatexdir/luatex.web create mode 100644 Build/source/texk/web2c/luatexdir/luatex_svnversion.h delete mode 100644 Build/source/texk/web2c/luatexdir/luatexextra.in delete mode 100644 Build/source/texk/web2c/luatexdir/makecpool.c delete mode 100644 Build/source/texk/web2c/luatexdir/managed-sa.c delete mode 100644 Build/source/texk/web2c/luatexdir/managed-sa.h delete mode 100644 Build/source/texk/web2c/luatexdir/mathcodes.c delete mode 100644 Build/source/texk/web2c/luatexdir/nodes.h create mode 100644 Build/source/texk/web2c/luatexdir/ocp/ocp.h create mode 100644 Build/source/texk/web2c/luatexdir/ocp/ocp.w create mode 100644 Build/source/texk/web2c/luatexdir/ocp/ocplist.h create mode 100644 Build/source/texk/web2c/luatexdir/ocp/ocplist.w create mode 100644 Build/source/texk/web2c/luatexdir/ocp/readocp.h create mode 100644 Build/source/texk/web2c/luatexdir/ocp/readocp.w create mode 100644 Build/source/texk/web2c/luatexdir/ocp/runocp.h create mode 100644 Build/source/texk/web2c/luatexdir/ocp/runocp.w delete mode 100644 Build/source/texk/web2c/luatexdir/pdf/pagetree.c create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pagetree.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfaction.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfaction.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfannot.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfannot.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfdest.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfdest.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdffont.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdffont.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfgen.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfgen.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfglyph.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfimage.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfimage.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdflink.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdflink.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdflistout.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdflistout.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfliteral.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfobj.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfobj.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfoutline.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w delete mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfpage.c create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfpage.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfrule.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfrule.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfshipout.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdftables.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdftables.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfthread.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfthread.w create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdftypes.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfxform.h create mode 100644 Build/source/texk/web2c/luatexdir/pdf/pdfxform.w delete mode 100644 Build/source/texk/web2c/luatexdir/primitive.h delete mode 100644 Build/source/texk/web2c/luatexdir/ptexmac.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/align.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/align.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/arithmetic.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/arithmetic.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/buildpage.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/buildpage.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/commands.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/commands.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/conditional.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/conditional.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/directions.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/directions.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/dumpdata.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/dumpdata.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/equivalents.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/equivalents.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/errors.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/errors.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/expand.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/expand.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/extensions.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/extensions.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/filename.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/filename.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/filename.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/inputstack.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/inputstack.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/linebreak.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/linebreak.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/linebreak.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/mainbody.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/mainbody.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/maincontrol.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/maincontrol.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/math.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/mathcodes.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/mathcodes.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/memoryword.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/memoryword.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/mlist.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/mlist.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/mlist.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/nesting.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/nesting.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/packaging.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/packaging.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/postlinebreak.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/postlinebreak.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/postlinebreak.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/primitive.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/primitive.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/primitive.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/printing.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/printing.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/scanning.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/scanning.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/stringpool.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/stringpool.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/texdeffont.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/texdeffont.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/texdeffont.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/texfileio.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/texfileio.w create mode 100644 Build/source/texk/web2c/luatexdir/tex/texmath.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/texmath.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/texnodes.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/texnodes.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/texnodes.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/texpdf.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/textcodes.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/textcodes.w delete mode 100644 Build/source/texk/web2c/luatexdir/tex/textoken.c create mode 100644 Build/source/texk/web2c/luatexdir/tex/textoken.h create mode 100644 Build/source/texk/web2c/luatexdir/tex/textoken.w delete mode 100644 Build/source/texk/web2c/luatexdir/texmath.h delete mode 100644 Build/source/texk/web2c/luatexdir/textcodes.c delete mode 100644 Build/source/texk/web2c/luatexdir/tokens.h delete mode 100644 Build/source/texk/web2c/luatexdir/utils/avlstuff.c create mode 100644 Build/source/texk/web2c/luatexdir/utils/avlstuff.w create mode 100644 Build/source/texk/web2c/luatexdir/utils/managed-sa.h create mode 100644 Build/source/texk/web2c/luatexdir/utils/managed-sa.w create mode 100644 Build/source/texk/web2c/luatexdir/utils/synctex-common.h create mode 100644 Build/source/texk/web2c/luatexdir/utils/synctex-luatex.h delete mode 100644 Build/source/texk/web2c/luatexdir/utils/utils.c create mode 100644 Build/source/texk/web2c/luatexdir/utils/utils.w delete mode 100644 Build/source/texk/web2c/luatexdir/utils/writezip.c diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index 73fe188aa29..bd758d091be 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -1,3 +1,10 @@ +2010-04-04 Taco Hoekwater + + * configure.ac: Append LT_LIB_DLLOAD to the end, + needed for the current 0.60.0 luatex build system. + * Makefile.am: Comment out the luatexdir/am/luatangle.am line + * autoreconf + 2010-03-24 Peter Breitenlohner * configure.ac: Check if dlopen() requires `-ldl'. diff --git a/Build/source/texk/web2c/Makefile.am b/Build/source/texk/web2c/Makefile.am index e6de8dbd64b..e6abcf2fdbd 100644 --- a/Build/source/texk/web2c/Makefile.am +++ b/Build/source/texk/web2c/Makefile.am @@ -167,7 +167,7 @@ include $(srcdir)/pdftexdir/am/pdftosrc.am ## luaTeX include $(srcdir)/luatexdir/am/luatex.am -include $(srcdir)/luatexdir/am/luatangle.am +## include $(srcdir)/luatexdir/am/luatangle.am include $(srcdir)/luatexdir/am/liblua51.am include $(srcdir)/luatexdir/am/luasocket.am include $(srcdir)/luatexdir/am/luamisc.am diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index 4088baafdc8..19e5377943f 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -37,8 +37,7 @@ host_triplet = @host@ EXTRA_PROGRAMS = $(am__EXEEXT_1) tex$(EXEEXT) mf$(EXEEXT) \ mf-nowin$(EXEEXT) mpost$(EXEEXT) etex$(EXEEXT) pdftex$(EXEEXT) \ ttf2afm$(EXEEXT) pdftosrc$(EXEEXT) luatex$(EXEEXT) \ - luatangle$(EXEEXT) xetex$(EXEEXT) $(am__EXEEXT_4) \ - aleph$(EXEEXT) + xetex$(EXEEXT) $(am__EXEEXT_4) aleph$(EXEEXT) bin_PROGRAMS = tangle$(EXEEXT) ctangle$(EXEEXT) $(am__EXEEXT_5) \ ctie$(EXEEXT) cweave$(EXEEXT) tie$(EXEEXT) $(am__EXEEXT_6) \ $(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \ @@ -51,8 +50,7 @@ check_PROGRAMS = $(am__EXEEXT_17) $(am__EXEEXT_18) $(am__EXEEXT_19) \ TESTS = tangle.test $(am__EXEEXT_24) ctiedir/ctie.test \ cwebdir/cweave.test tiedir/tie.test $(am__append_4) \ $(am__append_10) $(am__append_13) $(am__append_17) \ - $(am__append_23) $(am__append_39) $(am__append_40) \ - libmd5/md5.test + $(am__append_38) $(am__append_39) libmd5/md5.test DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \ $(srcdir)/../../build-aux/config.guess \ $(srcdir)/../../build-aux/config.sub \ @@ -69,7 +67,6 @@ DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \ $(srcdir)/luatexdir/am/luafontforge.am \ $(srcdir)/luatexdir/am/luamisc.am \ $(srcdir)/luatexdir/am/luasocket.am \ - $(srcdir)/luatexdir/am/luatangle.am \ $(srcdir)/luatexdir/am/luatex.am \ $(srcdir)/mplibdir/am/libmplib.am \ $(srcdir)/mplibdir/am/mplib.am \ @@ -111,25 +108,24 @@ DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \ @MINGW32_TRUE@ pdftexdir/regex/regex.c \ @MINGW32_TRUE@ pdftexdir/regex/regex.h -@LUATEX_TRUE@am__append_22 = luatex luatangle -@LUATEX_TRUE@am__append_23 = luatexdir/luatangle.test -@MINGW32_FALSE@am__append_24 = -DLUA_USE_POSIX -@XETEX_TRUE@am__append_25 = xetex -@XETEX_MACOSX_TRUE@am__append_26 = -DXETEX_MAC -@XETEX_MACOSX_TRUE@am__append_27 = libxetexmm.a -@XETEX_MACOSX_FALSE@am__append_28 = -DXETEX_OTHER $(XPDF_INCLUDES) \ +@LUATEX_TRUE@am__append_22 = luatex +@MINGW32_FALSE@am__append_23 = -DLUA_USE_POSIX +@XETEX_TRUE@am__append_24 = xetex +@XETEX_MACOSX_TRUE@am__append_25 = -DXETEX_MAC +@XETEX_MACOSX_TRUE@am__append_26 = libxetexmm.a +@XETEX_MACOSX_FALSE@am__append_27 = -DXETEX_OTHER $(XPDF_INCLUDES) \ @XETEX_MACOSX_FALSE@ $(LIBPNG_INCLUDES) $(FONTCONFIG_INCLUDES) -@XETEX_MACOSX_FALSE@am__append_29 = $(XPDF_LIBS) $(LIBPNG_LIBS) $(FONTCONFIG_LIBS) -@XETEX_MACOSX_FALSE@am__append_30 = $(XPDF_DEPEND) $(LIBPNG_DEPEND) -@XETEX_GRAPHITE_TRUE@am__append_31 = -DXETEX_GRAPHITE $(GRAPHITE_INCLUDES) -@XETEX_GRAPHITE_TRUE@am__append_32 = $(GRAPHITE_LIBS) -@XETEX_GRAPHITE_TRUE@am__append_33 = $(GRAPHITE_DEPEND) -@XETEX_MACOSX_TRUE@am__append_34 = \ +@XETEX_MACOSX_FALSE@am__append_28 = $(XPDF_LIBS) $(LIBPNG_LIBS) $(FONTCONFIG_LIBS) +@XETEX_MACOSX_FALSE@am__append_29 = $(XPDF_DEPEND) $(LIBPNG_DEPEND) +@XETEX_GRAPHITE_TRUE@am__append_30 = -DXETEX_GRAPHITE $(GRAPHITE_INCLUDES) +@XETEX_GRAPHITE_TRUE@am__append_31 = $(GRAPHITE_LIBS) +@XETEX_GRAPHITE_TRUE@am__append_32 = $(GRAPHITE_DEPEND) +@XETEX_MACOSX_TRUE@am__append_33 = \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeXFontInst_Mac.cpp \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeXFontInst_Mac.h \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeX_mac.c -@XETEX_MACOSX_FALSE@am__append_35 = \ +@XETEX_MACOSX_FALSE@am__append_34 = \ @XETEX_MACOSX_FALSE@ xetexdir/XeTeXFontMgr_FC.cpp \ @XETEX_MACOSX_FALSE@ xetexdir/XeTeXFontMgr_FC.h \ @XETEX_MACOSX_FALSE@ xetexdir/XeTeX_pic.c \ @@ -146,38 +142,38 @@ DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \ @XETEX_MACOSX_FALSE@ xetexdir/pngimage.c \ @XETEX_MACOSX_FALSE@ xetexdir/pngimage.h -@XETEX_GRAPHITE_TRUE@am__append_36 = \ +@XETEX_GRAPHITE_TRUE@am__append_35 = \ @XETEX_GRAPHITE_TRUE@ xetexdir/XeTeXGrLayout.cpp \ @XETEX_GRAPHITE_TRUE@ xetexdir/XeTeXGrLayout.h -@OTANGLE_TRUE@am__append_37 = $(omegaware_tools) -@OMFONTS_FALSE@@OTANGLE_TRUE@am__append_38 = $(omegaware_font_tools) -@OTANGLE_TRUE@am__append_39 = $(OTANGLE_tests) -@OMFONTS_FALSE@@OTANGLE_TRUE@am__append_40 = $(OMFONTS_tests) -@OTANGLE_TRUE@am__append_41 = pltotf tftopl -@ALEPH_TRUE@am__append_42 = aleph -@TEX_SYNCTEX_TRUE@am__append_43 = -I$(srcdir)/synctexdir \ +@OTANGLE_TRUE@am__append_36 = $(omegaware_tools) +@OMFONTS_FALSE@@OTANGLE_TRUE@am__append_37 = $(omegaware_font_tools) +@OTANGLE_TRUE@am__append_38 = $(OTANGLE_tests) +@OMFONTS_FALSE@@OTANGLE_TRUE@am__append_39 = $(OMFONTS_tests) +@OTANGLE_TRUE@am__append_40 = pltotf tftopl +@ALEPH_TRUE@am__append_41 = aleph +@TEX_SYNCTEX_TRUE@am__append_42 = -I$(srcdir)/synctexdir \ @TEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ -@TEX_SYNCTEX_TRUE@am__append_44 = $(ZLIB_LIBS) -@TEX_SYNCTEX_TRUE@am__append_45 = $(ZLIB_DEPEND) -@TEX_SYNCTEX_TRUE@am__append_46 = \ +@TEX_SYNCTEX_TRUE@am__append_43 = $(ZLIB_LIBS) +@TEX_SYNCTEX_TRUE@am__append_44 = $(ZLIB_DEPEND) +@TEX_SYNCTEX_TRUE@am__append_45 = \ @TEX_SYNCTEX_TRUE@ synctex.c -@ETEX_SYNCTEX_TRUE@am__append_47 = -I$(srcdir)/synctexdir \ +@ETEX_SYNCTEX_TRUE@am__append_46 = -I$(srcdir)/synctexdir \ @ETEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ -@ETEX_SYNCTEX_TRUE@am__append_48 = $(ZLIB_LIBS) -@ETEX_SYNCTEX_TRUE@am__append_49 = $(ZLIB_DEPEND) -@ETEX_SYNCTEX_TRUE@am__append_50 = \ +@ETEX_SYNCTEX_TRUE@am__append_47 = $(ZLIB_LIBS) +@ETEX_SYNCTEX_TRUE@am__append_48 = $(ZLIB_DEPEND) +@ETEX_SYNCTEX_TRUE@am__append_49 = \ @ETEX_SYNCTEX_TRUE@ synctex-e.c -@PDFTEX_SYNCTEX_TRUE@am__append_51 = -I$(srcdir)/synctexdir \ +@PDFTEX_SYNCTEX_TRUE@am__append_50 = -I$(srcdir)/synctexdir \ @PDFTEX_SYNCTEX_TRUE@ -D__SyncTeX__ -@PDFTEX_SYNCTEX_TRUE@am__append_52 = \ +@PDFTEX_SYNCTEX_TRUE@am__append_51 = \ @PDFTEX_SYNCTEX_TRUE@ synctex-pdf.c -@XETEX_SYNCTEX_TRUE@am__append_53 = -I$(srcdir)/synctexdir \ +@XETEX_SYNCTEX_TRUE@am__append_52 = -I$(srcdir)/synctexdir \ @XETEX_SYNCTEX_TRUE@ -D__SyncTeX__ -@XETEX_SYNCTEX_TRUE@am__append_54 = \ +@XETEX_SYNCTEX_TRUE@am__append_53 = \ @XETEX_SYNCTEX_TRUE@ synctex-xe.c subdir = . @@ -223,27 +219,25 @@ ARFLAGS = cru libff_a_AR = $(AR) $(ARFLAGS) libff_a_LIBADD = am_libff_a_OBJECTS = libff_a-ArabicForms.$(OBJEXT) \ - libff_a-alphabet.$(OBJEXT) libff_a-backtrns.$(OBJEXT) \ - libff_a-char.$(OBJEXT) libff_a-cjk.$(OBJEXT) \ - libff_a-dump.$(OBJEXT) libff_a-gwwiconv.$(OBJEXT) \ + libff_a-alphabet.$(OBJEXT) libff_a-char.$(OBJEXT) \ + libff_a-cjk.$(OBJEXT) libff_a-gwwiconv.$(OBJEXT) \ libff_a-memory.$(OBJEXT) libff_a-ucharmap.$(OBJEXT) \ - libff_a-unialt.$(OBJEXT) libff_a-ustring.$(OBJEXT) \ - libff_a-utype.$(OBJEXT) libff_a-autohint.$(OBJEXT) \ - libff_a-clipnoui.$(OBJEXT) libff_a-cvundoes.$(OBJEXT) \ - libff_a-dumppfa.$(OBJEXT) libff_a-encoding.$(OBJEXT) \ - libff_a-featurefile.$(OBJEXT) libff_a-fontviewbase.$(OBJEXT) \ - libff_a-fvcomposit.$(OBJEXT) libff_a-fvfonts.$(OBJEXT) \ - libff_a-lookups.$(OBJEXT) libff_a-macbinary.$(OBJEXT) \ - libff_a-macenc.$(OBJEXT) libff_a-mathconstants.$(OBJEXT) \ - libff_a-mm.$(OBJEXT) libff_a-namelist.$(OBJEXT) \ - libff_a-noprefs.$(OBJEXT) libff_a-nouiutil.$(OBJEXT) \ - libff_a-parsepfa.$(OBJEXT) libff_a-parsettf.$(OBJEXT) \ - libff_a-parsettfatt.$(OBJEXT) libff_a-parsettfvar.$(OBJEXT) \ - libff_a-psread.$(OBJEXT) libff_a-pua.$(OBJEXT) \ - libff_a-python.$(OBJEXT) libff_a-sfd1.$(OBJEXT) \ - libff_a-splinechar.$(OBJEXT) libff_a-splinefill.$(OBJEXT) \ - libff_a-splinefont.$(OBJEXT) libff_a-splineorder2.$(OBJEXT) \ - libff_a-splineoverlap.$(OBJEXT) \ + libff_a-ustring.$(OBJEXT) libff_a-utype.$(OBJEXT) \ + libff_a-autohint.$(OBJEXT) libff_a-clipnoui.$(OBJEXT) \ + libff_a-cvundoes.$(OBJEXT) libff_a-dumppfa.$(OBJEXT) \ + libff_a-encoding.$(OBJEXT) libff_a-featurefile.$(OBJEXT) \ + libff_a-fontviewbase.$(OBJEXT) libff_a-fvcomposit.$(OBJEXT) \ + libff_a-fvfonts.$(OBJEXT) libff_a-lookups.$(OBJEXT) \ + libff_a-macbinary.$(OBJEXT) libff_a-macenc.$(OBJEXT) \ + libff_a-mathconstants.$(OBJEXT) libff_a-mm.$(OBJEXT) \ + libff_a-namelist.$(OBJEXT) libff_a-noprefs.$(OBJEXT) \ + libff_a-nouiutil.$(OBJEXT) libff_a-parsepfa.$(OBJEXT) \ + libff_a-parsettf.$(OBJEXT) libff_a-parsettfatt.$(OBJEXT) \ + libff_a-parsettfvar.$(OBJEXT) libff_a-psread.$(OBJEXT) \ + libff_a-pua.$(OBJEXT) libff_a-python.$(OBJEXT) \ + libff_a-sfd1.$(OBJEXT) libff_a-splinechar.$(OBJEXT) \ + libff_a-splinefill.$(OBJEXT) libff_a-splinefont.$(OBJEXT) \ + libff_a-splineorder2.$(OBJEXT) libff_a-splineoverlap.$(OBJEXT) \ libff_a-splinerefigure.$(OBJEXT) libff_a-splinesave.$(OBJEXT) \ libff_a-splinesaveafm.$(OBJEXT) libff_a-splinestroke.$(OBJEXT) \ libff_a-splineutil.$(OBJEXT) libff_a-splineutil2.$(OBJEXT) \ @@ -275,7 +269,8 @@ libluamisc_a_AR = $(AR) $(ARFLAGS) libluamisc_a_LIBADD = am_libluamisc_a_OBJECTS = libluamisc_a-lfs.$(OBJEXT) \ libluamisc_a-md5.$(OBJEXT) libluamisc_a-md5lib.$(OBJEXT) \ - libluamisc_a-lpeg.$(OBJEXT) libluamisc_a-clocks.$(OBJEXT) \ + libluamisc_a-md5_lua.$(OBJEXT) libluamisc_a-lpeg.$(OBJEXT) \ + libluamisc_a-clocks.$(OBJEXT) \ libluamisc_a-core_profiler.$(OBJEXT) \ libluamisc_a-function_meter.$(OBJEXT) \ libluamisc_a-stack.$(OBJEXT) \ @@ -298,67 +293,163 @@ am_libluasocket_a_OBJECTS = libluasocket_a-auxiliar.$(OBJEXT) \ libluasocket_a_OBJECTS = $(am_libluasocket_a_OBJECTS) libluatex_a_AR = $(AR) $(ARFLAGS) libluatex_a_LIBADD = -am_libluatex_a_OBJECTS = libluatex_a-dofont.$(OBJEXT) \ - libluatex_a-luafont.$(OBJEXT) libluatex_a-mapfile.$(OBJEXT) \ - libluatex_a-pkin.$(OBJEXT) libluatex_a-sfnt.$(OBJEXT) \ - libluatex_a-subfont.$(OBJEXT) libluatex_a-texfont.$(OBJEXT) \ - libluatex_a-tfmofm.$(OBJEXT) libluatex_a-tounicode.$(OBJEXT) \ - libluatex_a-tt_glyf.$(OBJEXT) libluatex_a-tt_table.$(OBJEXT) \ - libluatex_a-vfovf.$(OBJEXT) libluatex_a-vfpacket.$(OBJEXT) \ - libluatex_a-writecff.$(OBJEXT) libluatex_a-writeenc.$(OBJEXT) \ - libluatex_a-writefont.$(OBJEXT) libluatex_a-writet1.$(OBJEXT) \ - libluatex_a-writet3.$(OBJEXT) libluatex_a-writettf.$(OBJEXT) \ +am__objects_1 = libluatex_a-dvigen.$(OBJEXT) \ + libluatex_a-dofont.$(OBJEXT) libluatex_a-luafont.$(OBJEXT) \ + libluatex_a-mapfile.$(OBJEXT) libluatex_a-pkin.$(OBJEXT) \ + libluatex_a-sfnt.$(OBJEXT) libluatex_a-subfont.$(OBJEXT) \ + libluatex_a-texfont.$(OBJEXT) libluatex_a-tfmofm.$(OBJEXT) \ + libluatex_a-tounicode.$(OBJEXT) libluatex_a-tt_glyf.$(OBJEXT) \ + libluatex_a-tt_table.$(OBJEXT) libluatex_a-vfovf.$(OBJEXT) \ + libluatex_a-vfpacket.$(OBJEXT) libluatex_a-writecff.$(OBJEXT) \ + libluatex_a-writeenc.$(OBJEXT) libluatex_a-writefont.$(OBJEXT) \ + libluatex_a-writet1.$(OBJEXT) libluatex_a-writet3.$(OBJEXT) \ + libluatex_a-writettf.$(OBJEXT) \ libluatex_a-writetype0.$(OBJEXT) \ libluatex_a-writetype2.$(OBJEXT) libluatex_a-epdf.$(OBJEXT) \ - libluatex_a-pdftoepdf.$(OBJEXT) libluatex_a-writeimg.$(OBJEXT) \ + libluatex_a-writeimg.$(OBJEXT) \ libluatex_a-writejbig2.$(OBJEXT) \ libluatex_a-writejpg.$(OBJEXT) libluatex_a-writepng.$(OBJEXT) \ - libluatex_a-hnjalloc.$(OBJEXT) libluatex_a-hyphen.$(OBJEXT) \ - libluatex_a-texlang.$(OBJEXT) \ + libluatex_a-luagen.$(OBJEXT) libluatex_a-luainit.$(OBJEXT) \ + libluatex_a-luanode.$(OBJEXT) libluatex_a-luastuff.$(OBJEXT) \ + libluatex_a-luatoken.$(OBJEXT) libluatex_a-texluac.$(OBJEXT) \ + libluatex_a-ocp.$(OBJEXT) libluatex_a-ocplist.$(OBJEXT) \ + libluatex_a-readocp.$(OBJEXT) libluatex_a-runocp.$(OBJEXT) \ + libluatex_a-texlang.$(OBJEXT) libluatex_a-hyphen.$(OBJEXT) \ + libluatex_a-hnjalloc.$(OBJEXT) libluatex_a-pagetree.$(OBJEXT) \ + libluatex_a-pdfaction.$(OBJEXT) libluatex_a-pdfannot.$(OBJEXT) \ + libluatex_a-pdfcolorstack.$(OBJEXT) \ + libluatex_a-pdfdest.$(OBJEXT) libluatex_a-pdffont.$(OBJEXT) \ + libluatex_a-pdfgen.$(OBJEXT) libluatex_a-pdfglyph.$(OBJEXT) \ + libluatex_a-pdfimage.$(OBJEXT) libluatex_a-pdflink.$(OBJEXT) \ + libluatex_a-pdflistout.$(OBJEXT) \ + libluatex_a-pdfliteral.$(OBJEXT) libluatex_a-pdfobj.$(OBJEXT) \ + libluatex_a-pdfoutline.$(OBJEXT) libluatex_a-pdfpage.$(OBJEXT) \ + libluatex_a-pdfrule.$(OBJEXT) \ + libluatex_a-pdfsaverestore.$(OBJEXT) \ + libluatex_a-pdfsetmatrix.$(OBJEXT) \ + libluatex_a-pdfshipout.$(OBJEXT) \ + libluatex_a-pdftables.$(OBJEXT) \ + libluatex_a-pdfthread.$(OBJEXT) libluatex_a-pdfxform.$(OBJEXT) \ + libluatex_a-align.$(OBJEXT) libluatex_a-dumpdata.$(OBJEXT) \ + libluatex_a-expand.$(OBJEXT) libluatex_a-inputstack.$(OBJEXT) \ + libluatex_a-maincontrol.$(OBJEXT) libluatex_a-mlist.$(OBJEXT) \ + libluatex_a-postlinebreak.$(OBJEXT) \ + libluatex_a-scanning.$(OBJEXT) \ + libluatex_a-texdeffont.$(OBJEXT) \ + libluatex_a-texnodes.$(OBJEXT) \ + libluatex_a-arithmetic.$(OBJEXT) \ + libluatex_a-conditional.$(OBJEXT) \ + libluatex_a-equivalents.$(OBJEXT) \ + libluatex_a-extensions.$(OBJEXT) \ + libluatex_a-commands.$(OBJEXT) libluatex_a-linebreak.$(OBJEXT) \ + libluatex_a-mathcodes.$(OBJEXT) libluatex_a-nesting.$(OBJEXT) \ + libluatex_a-primitive.$(OBJEXT) \ + libluatex_a-texfileio.$(OBJEXT) \ + libluatex_a-textcodes.$(OBJEXT) \ + libluatex_a-buildpage.$(OBJEXT) \ + libluatex_a-directions.$(OBJEXT) libluatex_a-errors.$(OBJEXT) \ + libluatex_a-filename.$(OBJEXT) libluatex_a-mainbody.$(OBJEXT) \ + libluatex_a-memoryword.$(OBJEXT) \ + libluatex_a-packaging.$(OBJEXT) libluatex_a-printing.$(OBJEXT) \ + libluatex_a-stringpool.$(OBJEXT) libluatex_a-texmath.$(OBJEXT) \ + libluatex_a-textoken.$(OBJEXT) libluatex_a-utils.$(OBJEXT) \ + libluatex_a-avlstuff.$(OBJEXT) \ + libluatex_a-managed-sa.$(OBJEXT) +am_libluatex_a_OBJECTS = libluatex_a-pdftoepdf.$(OBJEXT) \ libluatex_a-lcallbacklib.$(OBJEXT) \ libluatex_a-lfontlib.$(OBJEXT) libluatex_a-limglib.$(OBJEXT) \ - libluatex_a-lkpselib.$(OBJEXT) libluatex_a-llanglib.$(OBJEXT) \ - libluatex_a-llualib.$(OBJEXT) libluatex_a-lnodelib.$(OBJEXT) \ - libluatex_a-loslibext.$(OBJEXT) libluatex_a-liolib.$(OBJEXT) \ - libluatex_a-lpdflib.$(OBJEXT) libluatex_a-lstatslib.$(OBJEXT) \ + libluatex_a-lepdflib.$(OBJEXT) libluatex_a-lkpselib.$(OBJEXT) \ + libluatex_a-llanglib.$(OBJEXT) libluatex_a-llualib.$(OBJEXT) \ + libluatex_a-lnodelib.$(OBJEXT) libluatex_a-loslibext.$(OBJEXT) \ + libluatex_a-liolib.$(OBJEXT) libluatex_a-lpdflib.$(OBJEXT) \ + libluatex_a-lstatslib.$(OBJEXT) \ libluatex_a-ltexiolib.$(OBJEXT) libluatex_a-ltexlib.$(OBJEXT) \ - libluatex_a-ltokenlib.$(OBJEXT) libluatex_a-luainit.$(OBJEXT) \ + libluatex_a-ltokenlib.$(OBJEXT) libluatex_a-avl.$(OBJEXT) \ + libluatex_a-synctex.$(OBJEXT) $(am__objects_1) \ + libluatex_a-lmplib.$(OBJEXT) +nodist_libluatex_a_OBJECTS = libluatex_a-dvigen.$(OBJEXT) \ + libluatex_a-dofont.$(OBJEXT) libluatex_a-luafont.$(OBJEXT) \ + libluatex_a-mapfile.$(OBJEXT) libluatex_a-pkin.$(OBJEXT) \ + libluatex_a-sfnt.$(OBJEXT) libluatex_a-subfont.$(OBJEXT) \ + libluatex_a-texfont.$(OBJEXT) libluatex_a-tfmofm.$(OBJEXT) \ + libluatex_a-tounicode.$(OBJEXT) libluatex_a-tt_glyf.$(OBJEXT) \ + libluatex_a-tt_table.$(OBJEXT) libluatex_a-vfovf.$(OBJEXT) \ + libluatex_a-vfpacket.$(OBJEXT) libluatex_a-writecff.$(OBJEXT) \ + libluatex_a-writeenc.$(OBJEXT) libluatex_a-writefont.$(OBJEXT) \ + libluatex_a-writet1.$(OBJEXT) libluatex_a-writet3.$(OBJEXT) \ + libluatex_a-writettf.$(OBJEXT) \ + libluatex_a-writetype0.$(OBJEXT) \ + libluatex_a-writetype2.$(OBJEXT) libluatex_a-epdf.$(OBJEXT) \ + libluatex_a-writeimg.$(OBJEXT) \ + libluatex_a-writejbig2.$(OBJEXT) \ + libluatex_a-writejpg.$(OBJEXT) libluatex_a-writepng.$(OBJEXT) \ + libluatex_a-luagen.$(OBJEXT) libluatex_a-luainit.$(OBJEXT) \ libluatex_a-luanode.$(OBJEXT) libluatex_a-luastuff.$(OBJEXT) \ - libluatex_a-luatex.$(OBJEXT) libluatex_a-luatoken.$(OBJEXT) \ - libluatex_a-texluac.$(OBJEXT) libluatex_a-makecpool.$(OBJEXT) \ - libluatex_a-managed-sa.$(OBJEXT) \ - libluatex_a-mathcodes.$(OBJEXT) libluatex_a-pagetree.$(OBJEXT) \ - libluatex_a-pdfpage.$(OBJEXT) libluatex_a-filename.$(OBJEXT) \ - libluatex_a-linebreak.$(OBJEXT) libluatex_a-math.$(OBJEXT) \ - libluatex_a-mlist.$(OBJEXT) \ + libluatex_a-luatoken.$(OBJEXT) libluatex_a-texluac.$(OBJEXT) \ + libluatex_a-ocp.$(OBJEXT) libluatex_a-ocplist.$(OBJEXT) \ + libluatex_a-readocp.$(OBJEXT) libluatex_a-runocp.$(OBJEXT) \ + libluatex_a-texlang.$(OBJEXT) libluatex_a-hyphen.$(OBJEXT) \ + libluatex_a-hnjalloc.$(OBJEXT) libluatex_a-pagetree.$(OBJEXT) \ + libluatex_a-pdfaction.$(OBJEXT) libluatex_a-pdfannot.$(OBJEXT) \ + libluatex_a-pdfcolorstack.$(OBJEXT) \ + libluatex_a-pdfdest.$(OBJEXT) libluatex_a-pdffont.$(OBJEXT) \ + libluatex_a-pdfgen.$(OBJEXT) libluatex_a-pdfglyph.$(OBJEXT) \ + libluatex_a-pdfimage.$(OBJEXT) libluatex_a-pdflink.$(OBJEXT) \ + libluatex_a-pdflistout.$(OBJEXT) \ + libluatex_a-pdfliteral.$(OBJEXT) libluatex_a-pdfobj.$(OBJEXT) \ + libluatex_a-pdfoutline.$(OBJEXT) libluatex_a-pdfpage.$(OBJEXT) \ + libluatex_a-pdfrule.$(OBJEXT) \ + libluatex_a-pdfsaverestore.$(OBJEXT) \ + libluatex_a-pdfsetmatrix.$(OBJEXT) \ + libluatex_a-pdfshipout.$(OBJEXT) \ + libluatex_a-pdftables.$(OBJEXT) \ + libluatex_a-pdfthread.$(OBJEXT) libluatex_a-pdfxform.$(OBJEXT) \ + libluatex_a-align.$(OBJEXT) libluatex_a-dumpdata.$(OBJEXT) \ + libluatex_a-expand.$(OBJEXT) libluatex_a-inputstack.$(OBJEXT) \ + libluatex_a-maincontrol.$(OBJEXT) libluatex_a-mlist.$(OBJEXT) \ libluatex_a-postlinebreak.$(OBJEXT) \ - libluatex_a-primitive.$(OBJEXT) \ + libluatex_a-scanning.$(OBJEXT) \ libluatex_a-texdeffont.$(OBJEXT) \ - libluatex_a-texnodes.$(OBJEXT) libluatex_a-texpdf.$(OBJEXT) \ - libluatex_a-textoken.$(OBJEXT) libluatex_a-textcodes.$(OBJEXT) \ - libluatex_a-avl.$(OBJEXT) libluatex_a-avlstuff.$(OBJEXT) \ - libluatex_a-synctex.$(OBJEXT) libluatex_a-utils.$(OBJEXT) \ - libluatex_a-writezip.$(OBJEXT) libluatex_a-lmplib.$(OBJEXT) -libluatex_a_OBJECTS = $(am_libluatex_a_OBJECTS) + libluatex_a-texnodes.$(OBJEXT) \ + libluatex_a-arithmetic.$(OBJEXT) \ + libluatex_a-conditional.$(OBJEXT) \ + libluatex_a-equivalents.$(OBJEXT) \ + libluatex_a-extensions.$(OBJEXT) \ + libluatex_a-commands.$(OBJEXT) libluatex_a-linebreak.$(OBJEXT) \ + libluatex_a-mathcodes.$(OBJEXT) libluatex_a-nesting.$(OBJEXT) \ + libluatex_a-primitive.$(OBJEXT) \ + libluatex_a-texfileio.$(OBJEXT) \ + libluatex_a-textcodes.$(OBJEXT) \ + libluatex_a-buildpage.$(OBJEXT) \ + libluatex_a-directions.$(OBJEXT) libluatex_a-errors.$(OBJEXT) \ + libluatex_a-filename.$(OBJEXT) libluatex_a-mainbody.$(OBJEXT) \ + libluatex_a-memoryword.$(OBJEXT) \ + libluatex_a-packaging.$(OBJEXT) libluatex_a-printing.$(OBJEXT) \ + libluatex_a-stringpool.$(OBJEXT) libluatex_a-texmath.$(OBJEXT) \ + libluatex_a-textoken.$(OBJEXT) libluatex_a-utils.$(OBJEXT) \ + libluatex_a-avlstuff.$(OBJEXT) \ + libluatex_a-managed-sa.$(OBJEXT) +libluatex_a_OBJECTS = $(am_libluatex_a_OBJECTS) \ + $(nodist_libluatex_a_OBJECTS) libmd5_a_AR = $(AR) $(ARFLAGS) libmd5_a_LIBADD = am_libmd5_a_OBJECTS = libmd5_a-md5.$(OBJEXT) libmd5_a_OBJECTS = $(am_libmd5_a_OBJECTS) libmf_a_AR = $(AR) $(ARFLAGS) libmf_a_LIBADD = -am__objects_1 = libmf_a-mfini.$(OBJEXT) libmf_a-mf0.$(OBJEXT) -nodist_libmf_a_OBJECTS = $(am__objects_1) libmf_a-mf-pool.$(OBJEXT) +am__objects_2 = libmf_a-mfini.$(OBJEXT) libmf_a-mf0.$(OBJEXT) +nodist_libmf_a_OBJECTS = $(am__objects_2) libmf_a-mf-pool.$(OBJEXT) libmf_a_OBJECTS = $(nodist_libmf_a_OBJECTS) libmplib_a_AR = $(AR) $(ARFLAGS) libmplib_a_LIBADD = am_libmplib_a_OBJECTS = libmplib_a-avl.$(OBJEXT) -am__objects_2 = libmplib_a-memio.$(OBJEXT) -am__objects_3 = libmplib_a-mp.$(OBJEXT) -am__objects_4 = libmplib_a-psout.$(OBJEXT) -am__objects_5 = libmplib_a-svgout.$(OBJEXT) -am__objects_6 = libmplib_a-tfmin.$(OBJEXT) -nodist_libmplib_a_OBJECTS = $(am__objects_2) $(am__objects_3) \ - $(am__objects_4) $(am__objects_5) $(am__objects_6) +am__objects_3 = libmplib_a-memio.$(OBJEXT) +am__objects_4 = libmplib_a-mp.$(OBJEXT) +am__objects_5 = libmplib_a-psout.$(OBJEXT) +am__objects_6 = libmplib_a-svgout.$(OBJEXT) +am__objects_7 = libmplib_a-tfmin.$(OBJEXT) +nodist_libmplib_a_OBJECTS = $(am__objects_3) $(am__objects_4) \ + $(am__objects_5) $(am__objects_6) $(am__objects_7) libmplib_a_OBJECTS = $(am_libmplib_a_OBJECTS) \ $(nodist_libmplib_a_OBJECTS) libpdftex_a_AR = $(AR) $(ARFLAGS) @@ -376,7 +467,7 @@ am__libpdftex_a_SOURCES_DIST = pdftexdir/avl.c pdftexdir/avl.h \ pdftexdir/writettf.c pdftexdir/writettf.h pdftexdir/writezip.c \ pdftexdir/regex/regex.c pdftexdir/regex/regex.h \ pdftexdir/inc-epdf.h pdftexdir/inc-extra.h -@MINGW32_TRUE@am__objects_7 = libpdftex_a-regex.$(OBJEXT) +@MINGW32_TRUE@am__objects_8 = libpdftex_a-regex.$(OBJEXT) am_libpdftex_a_OBJECTS = libpdftex_a-avl.$(OBJEXT) \ libpdftex_a-avlstuff.$(OBJEXT) libpdftex_a-epdf.$(OBJEXT) \ libpdftex_a-mapfile.$(OBJEXT) libpdftex_a-pdftoepdf.$(OBJEXT) \ @@ -388,7 +479,7 @@ am_libpdftex_a_OBJECTS = libpdftex_a-avl.$(OBJEXT) \ libpdftex_a-writejpg.$(OBJEXT) libpdftex_a-writepng.$(OBJEXT) \ libpdftex_a-writet1.$(OBJEXT) libpdftex_a-writet3.$(OBJEXT) \ libpdftex_a-writettf.$(OBJEXT) libpdftex_a-writezip.$(OBJEXT) \ - $(am__objects_7) + $(am__objects_8) libpdftex_a_OBJECTS = $(am_libpdftex_a_OBJECTS) libxetex_a_AR = $(AR) $(ARFLAGS) libxetex_a_LIBADD = @@ -413,10 +504,10 @@ am__libxetex_a_SOURCES_DIST = xetexdir/MathTable.h \ xetexdir/numbers.c xetexdir/numbers.h xetexdir/pdfimage.cpp \ xetexdir/pdfimage.h xetexdir/pngimage.c xetexdir/pngimage.h \ xetexdir/XeTeXGrLayout.cpp xetexdir/XeTeXGrLayout.h -@XETEX_MACOSX_TRUE@am__objects_8 = \ +@XETEX_MACOSX_TRUE@am__objects_9 = \ @XETEX_MACOSX_TRUE@ libxetex_a-XeTeXFontInst_Mac.$(OBJEXT) \ @XETEX_MACOSX_TRUE@ libxetex_a-XeTeX_mac.$(OBJEXT) -@XETEX_MACOSX_FALSE@am__objects_9 = \ +@XETEX_MACOSX_FALSE@am__objects_10 = \ @XETEX_MACOSX_FALSE@ libxetex_a-XeTeXFontMgr_FC.$(OBJEXT) \ @XETEX_MACOSX_FALSE@ libxetex_a-XeTeX_pic.$(OBJEXT) \ @XETEX_MACOSX_FALSE@ libxetex_a-bmpimage.$(OBJEXT) \ @@ -425,7 +516,7 @@ am__libxetex_a_SOURCES_DIST = xetexdir/MathTable.h \ @XETEX_MACOSX_FALSE@ libxetex_a-numbers.$(OBJEXT) \ @XETEX_MACOSX_FALSE@ libxetex_a-pdfimage.$(OBJEXT) \ @XETEX_MACOSX_FALSE@ libxetex_a-pngimage.$(OBJEXT) -@XETEX_GRAPHITE_TRUE@am__objects_10 = \ +@XETEX_GRAPHITE_TRUE@am__objects_11 = \ @XETEX_GRAPHITE_TRUE@ libxetex_a-XeTeXGrLayout.$(OBJEXT) am_libxetex_a_OBJECTS = libxetex_a-FontTableCache.$(OBJEXT) \ libxetex_a-XeTeXFontInst.$(OBJEXT) \ @@ -435,8 +526,8 @@ am_libxetex_a_OBJECTS = libxetex_a-FontTableCache.$(OBJEXT) \ libxetex_a-XeTeXOTLayoutEngine.$(OBJEXT) \ libxetex_a-XeTeXOTMath.$(OBJEXT) \ libxetex_a-XeTeX_ext.$(OBJEXT) libxetex_a-cmaps.$(OBJEXT) \ - libxetex_a-trans.$(OBJEXT) $(am__objects_8) $(am__objects_9) \ - $(am__objects_10) + libxetex_a-trans.$(OBJEXT) $(am__objects_9) $(am__objects_10) \ + $(am__objects_11) libxetex_a_OBJECTS = $(am_libxetex_a_OBJECTS) libxetexmm_a_AR = $(AR) $(ARFLAGS) libxetexmm_a_LIBADD = @@ -459,7 +550,7 @@ am__EXEEXT_4 = $(am__EXEEXT_2) $(am__EXEEXT_3) @ETEX_TRUE@am__EXEEXT_10 = etex$(EXEEXT) @PDFTEX_TRUE@am__EXEEXT_11 = pdftex$(EXEEXT) ttf2afm$(EXEEXT) \ @PDFTEX_TRUE@ pdftosrc$(EXEEXT) -@LUATEX_TRUE@am__EXEEXT_12 = luatex$(EXEEXT) luatangle$(EXEEXT) +@LUATEX_TRUE@am__EXEEXT_12 = luatex$(EXEEXT) @XETEX_TRUE@am__EXEEXT_13 = xetex$(EXEEXT) @OTANGLE_TRUE@am__EXEEXT_14 = $(am__EXEEXT_2) @OMFONTS_FALSE@@OTANGLE_TRUE@am__EXEEXT_15 = $(am__EXEEXT_3) @@ -475,8 +566,8 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \ @OTANGLE_TRUE@am__EXEEXT_21 = pltotf$(EXEEXT) tftopl$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am_aleph_OBJECTS = aleph-aleph.$(OBJEXT) aleph-alephbis.$(OBJEXT) -am__objects_11 = aleph-alephini.$(OBJEXT) aleph-aleph0.$(OBJEXT) -nodist_aleph_OBJECTS = $(am__objects_11) aleph-aleph-pool.$(OBJEXT) \ +am__objects_12 = aleph-alephini.$(OBJEXT) aleph-aleph0.$(OBJEXT) +nodist_aleph_OBJECTS = $(am__objects_12) aleph-aleph-pool.$(OBJEXT) \ aleph-alephextra.$(OBJEXT) aleph_OBJECTS = $(am_aleph_OBJECTS) $(nodist_aleph_OBJECTS) am__DEPENDENCIES_1 = @@ -525,10 +616,10 @@ dvitype_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) am__dist_etex_SOURCES_DIST = synctexdir/synctex.h \ synctexdir/synctex-common.h synctexdir/synctex-etex.h dist_etex_OBJECTS = -am__objects_12 = etex-etexini.$(OBJEXT) etex-etex0.$(OBJEXT) -@ETEX_SYNCTEX_TRUE@am__objects_13 = etex-synctex-e.$(OBJEXT) -nodist_etex_OBJECTS = $(am__objects_12) etex-etex-pool.$(OBJEXT) \ - etex-etexextra.$(OBJEXT) $(am__objects_13) +am__objects_13 = etex-etexini.$(OBJEXT) etex-etex0.$(OBJEXT) +@ETEX_SYNCTEX_TRUE@am__objects_14 = etex-synctex-e.$(OBJEXT) +nodist_etex_OBJECTS = $(am__objects_13) etex-etex-pool.$(OBJEXT) \ + etex-etexextra.$(OBJEXT) $(am__objects_14) etex_OBJECTS = $(dist_etex_OBJECTS) $(nodist_etex_OBJECTS) @ETEX_SYNCTEX_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) etex_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ @@ -549,21 +640,15 @@ nodist_gftype_OBJECTS = gftype.$(OBJEXT) gftype_OBJECTS = $(nodist_gftype_OBJECTS) gftype_LDADD = $(LDADD) gftype_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -nodist_luatangle_OBJECTS = luatangle.$(OBJEXT) -luatangle_OBJECTS = $(nodist_luatangle_OBJECTS) -luatangle_LDADD = $(LDADD) -luatangle_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -am__objects_14 = luatex-luatexini.$(OBJEXT) luatex-luatex0.$(OBJEXT) -nodist_luatex_OBJECTS = $(am__objects_14) luatex-luatex-pool.$(OBJEXT) \ - luatex-luatexextra.$(OBJEXT) -luatex_OBJECTS = $(nodist_luatex_OBJECTS) +am_luatex_OBJECTS = luatex-luatex.$(OBJEXT) +luatex_OBJECTS = $(am_luatex_OBJECTS) am__DEPENDENCIES_4 = libluatex.a libff.a libluamisc.a libluasocket.a \ liblua51.a $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) libmd5.a libmplib.a luatex_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(luatex_CXXFLAGS) $(CXXFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ + $(luatex_LDFLAGS) $(LDFLAGS) -o $@ am_md5main_OBJECTS = md5main-md5main.$(OBJEXT) md5main_OBJECTS = $(am_md5main_OBJECTS) md5main_DEPENDENCIES = libmd5.a @@ -766,7 +851,7 @@ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ SOURCES = $(libff_a_SOURCES) $(liblua51_a_SOURCES) \ $(libluamisc_a_SOURCES) $(EXTRA_libluamisc_a_SOURCES) \ $(libluasocket_a_SOURCES) $(libluatex_a_SOURCES) \ - $(EXTRA_libluatex_a_SOURCES) $(libmd5_a_SOURCES) \ + $(nodist_libluatex_a_SOURCES) $(libmd5_a_SOURCES) \ $(nodist_libmf_a_SOURCES) $(libmplib_a_SOURCES) \ $(nodist_libmplib_a_SOURCES) $(libpdftex_a_SOURCES) \ $(EXTRA_libpdftex_a_SOURCES) $(libxetex_a_SOURCES) \ @@ -777,39 +862,38 @@ SOURCES = $(libff_a_SOURCES) $(liblua51_a_SOURCES) \ $(nodist_dvicopy_SOURCES) $(nodist_dvitype_SOURCES) \ $(dist_etex_SOURCES) $(nodist_etex_SOURCES) $(gftodvi_SOURCES) \ $(nodist_gftodvi_SOURCES) $(nodist_gftopk_SOURCES) \ - $(nodist_gftype_SOURCES) $(nodist_luatangle_SOURCES) \ - $(nodist_luatex_SOURCES) $(nodist_EXTRA_luatex_SOURCES) \ - $(md5main_SOURCES) $(nodist_mf_SOURCES) \ - $(nodist_mf_nowin_SOURCES) $(nodist_mft_SOURCES) \ - $(nodist_mpost_SOURCES) $(nodist_odvicopy_SOURCES) \ - $(nodist_odvitype_SOURCES) $(nodist_ofm2opl_SOURCES) \ - $(nodist_opl2ofm_SOURCES) $(nodist_otangle_SOURCES) \ - $(nodist_ovf2ovp_SOURCES) $(nodist_ovp2ovf_SOURCES) \ - $(nodist_patgen_SOURCES) $(dist_pdftex_SOURCES) \ - $(nodist_pdftex_SOURCES) $(nodist_EXTRA_pdftex_SOURCES) \ - $(pdftosrc_SOURCES) $(nodist_EXTRA_pdftosrc_SOURCES) \ - $(nodist_pktogf_SOURCES) $(nodist_pktype_SOURCES) \ - $(nodist_pltotf_SOURCES) $(nodist_pooltype_SOURCES) \ - $(synctex_SOURCES) $(nodist_tangle_SOURCES) \ - $(nodist_tangleboot_SOURCES) $(dist_tex_SOURCES) \ - $(nodist_tex_SOURCES) $(nodist_tftopl_SOURCES) \ - $(nodist_tie_SOURCES) $(ttf2afm_SOURCES) \ - $(EXTRA_ttf2afm_SOURCES) $(nodist_vftovp_SOURCES) \ - $(nodist_vptovf_SOURCES) $(nodist_weave_SOURCES) \ - $(dist_xetex_SOURCES) $(nodist_xetex_SOURCES) \ - $(nodist_EXTRA_xetex_SOURCES) + $(nodist_gftype_SOURCES) $(luatex_SOURCES) \ + $(nodist_EXTRA_luatex_SOURCES) $(md5main_SOURCES) \ + $(nodist_mf_SOURCES) $(nodist_mf_nowin_SOURCES) \ + $(nodist_mft_SOURCES) $(nodist_mpost_SOURCES) \ + $(nodist_odvicopy_SOURCES) $(nodist_odvitype_SOURCES) \ + $(nodist_ofm2opl_SOURCES) $(nodist_opl2ofm_SOURCES) \ + $(nodist_otangle_SOURCES) $(nodist_ovf2ovp_SOURCES) \ + $(nodist_ovp2ovf_SOURCES) $(nodist_patgen_SOURCES) \ + $(dist_pdftex_SOURCES) $(nodist_pdftex_SOURCES) \ + $(nodist_EXTRA_pdftex_SOURCES) $(pdftosrc_SOURCES) \ + $(nodist_EXTRA_pdftosrc_SOURCES) $(nodist_pktogf_SOURCES) \ + $(nodist_pktype_SOURCES) $(nodist_pltotf_SOURCES) \ + $(nodist_pooltype_SOURCES) $(synctex_SOURCES) \ + $(nodist_tangle_SOURCES) $(nodist_tangleboot_SOURCES) \ + $(dist_tex_SOURCES) $(nodist_tex_SOURCES) \ + $(nodist_tftopl_SOURCES) $(nodist_tie_SOURCES) \ + $(ttf2afm_SOURCES) $(EXTRA_ttf2afm_SOURCES) \ + $(nodist_vftovp_SOURCES) $(nodist_vptovf_SOURCES) \ + $(nodist_weave_SOURCES) $(dist_xetex_SOURCES) \ + $(nodist_xetex_SOURCES) $(nodist_EXTRA_xetex_SOURCES) DIST_SOURCES = $(libff_a_SOURCES) $(liblua51_a_SOURCES) \ $(libluamisc_a_SOURCES) $(EXTRA_libluamisc_a_SOURCES) \ $(libluasocket_a_SOURCES) $(libluatex_a_SOURCES) \ - $(EXTRA_libluatex_a_SOURCES) $(libmd5_a_SOURCES) \ - $(libmplib_a_SOURCES) $(am__libpdftex_a_SOURCES_DIST) \ - $(EXTRA_libpdftex_a_SOURCES) $(am__libxetex_a_SOURCES_DIST) \ - $(libxetexmm_a_SOURCES) $(aleph_SOURCES) \ - $(am__dist_etex_SOURCES_DIST) $(gftodvi_SOURCES) \ - $(md5main_SOURCES) $(am__dist_pdftex_SOURCES_DIST) \ - $(pdftosrc_SOURCES) $(synctex_SOURCES) \ - $(am__dist_tex_SOURCES_DIST) $(ttf2afm_SOURCES) \ - $(EXTRA_ttf2afm_SOURCES) $(am__dist_xetex_SOURCES_DIST) + $(libmd5_a_SOURCES) $(libmplib_a_SOURCES) \ + $(am__libpdftex_a_SOURCES_DIST) $(EXTRA_libpdftex_a_SOURCES) \ + $(am__libxetex_a_SOURCES_DIST) $(libxetexmm_a_SOURCES) \ + $(aleph_SOURCES) $(am__dist_etex_SOURCES_DIST) \ + $(gftodvi_SOURCES) $(luatex_SOURCES) $(md5main_SOURCES) \ + $(am__dist_pdftex_SOURCES_DIST) $(pdftosrc_SOURCES) \ + $(synctex_SOURCES) $(am__dist_tex_SOURCES_DIST) \ + $(ttf2afm_SOURCES) $(EXTRA_ttf2afm_SOURCES) \ + $(am__dist_xetex_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ @@ -955,6 +1039,10 @@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBADD_DL = @LIBADD_DL@ +LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ +LIBADD_DLOPEN = @LIBADD_DLOPEN@ +LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBOBJS = @LIBOBJS@ LIBPNG_DEPEND = @LIBPNG_DEPEND@ LIBPNG_INCLUDES = @LIBPNG_INCLUDES@ @@ -964,6 +1052,8 @@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +LT_DLLOADERS = @LT_DLLOADERS@ +LT_DLPREOPEN = @LT_DLPREOPEN@ LUATANGLE = @LUATANGLE@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ @@ -1158,10 +1248,7 @@ EXTRA_DIST = PROJECTS cftests config.h cpascal.h help.h triptrap-sh \ pdftexdir/README pdftexdir/change-files.txt \ pdftexdir/pdftex.mak pdftexdir/pdftex.mk \ pdftexdir/regex/COPYING.LIB pdftexdir/regex/README \ - $(luatex_sources) luatexdir/luatex.defines \ - luatexdir/luatexextra.in luatexdir/ptexlib.h \ - luatexdir/luatex.mk $(luatangle_sources) \ - luatexdir/luatangle.test luatexdir/lua51/Makefile \ + luatexdir/ptexlib.h luatexdir/lua51/Makefile \ luatexdir/lua51/liolib.c luatexdir/lua51/lua.c \ luatexdir/lua51/luac.c luatexdir/lua51/print.c \ luatexdir/luasocket/src/socket_lua.c \ @@ -1256,17 +1343,16 @@ EXTRA_DIST = PROJECTS cftests config.h cpascal.h help.h triptrap-sh \ luatexdir/luafontloader/fontforge/gutils/Makefile.in \ luatexdir/luafontloader/fontforge/inc/config.h.in \ luatexdir/luafontloader/fontforge/plugins/Makefile.in \ - luatexdir/ChangeLog luatexdir/NEWS luatexdir/README \ - luatexdir/change-files.txt luatexdir/font/subfont.txt \ - $(xetex_web_srcs) xetexdir/xetex.defines \ - xetexdir/xetexextra.in xetexdir/pool2c.pl \ - xetexdir/unicode-char-prep.pl xetexdir/appleGlyphNames.c \ - xetexdir/XeTeXFontMgr_Mac.mm xetexdir/ChangeLog \ - xetexdir/LICENSE.txt xetexdir/xetex.mk omegaware/README \ - omegaware/ChangeLog $(odvicopy_sources) $(odvitype_sources) \ - $(ofm2opl_sources) $(opl2ofm_sources) $(otangle_sources) \ - $(ovf2ovp_sources) $(ovp2ovf_sources) $(OTANGLE_tests) \ - $(OMFONTS_tests) omegaware/tests/level1.opl \ + $(libluatex_web) luatexdir/ChangeLog luatexdir/NEWS \ + luatexdir/README luatexdir/font/subfont.txt $(xetex_web_srcs) \ + xetexdir/xetex.defines xetexdir/xetexextra.in \ + xetexdir/pool2c.pl xetexdir/unicode-char-prep.pl \ + xetexdir/appleGlyphNames.c xetexdir/XeTeXFontMgr_Mac.mm \ + xetexdir/ChangeLog xetexdir/LICENSE.txt xetexdir/xetex.mk \ + omegaware/README omegaware/ChangeLog $(odvicopy_sources) \ + $(odvitype_sources) $(ofm2opl_sources) $(opl2ofm_sources) \ + $(otangle_sources) $(ovf2ovp_sources) $(ovp2ovf_sources) \ + $(OTANGLE_tests) $(OMFONTS_tests) omegaware/tests/level1.opl \ omegaware/tests/ofontd1.dvi omegaware/tests/ofontd1.typ \ omegaware/tests/ofontd2.dvi omegaware/tests/ofontd2.typ \ omegaware/tests/ofontd3.dvi omegaware/tests/ofontd3.typ \ @@ -1330,9 +1416,7 @@ DISTCLEANFILES = $(EXTRA_LIBRARIES) tangle.c tangle.h tangle.p \ etex.pool etex-tangle etexdir/etex.version etrip.diffs \ $(nodist_pdftex_SOURCES) pdftex.ch pdftex-web2c pdftex.p \ pdftex.pool pdftex-tangle pdftexdir/pdftex.version \ - $(nodist_luatex_SOURCES) luatex-web2c luatex.p luatex.pool \ - luatex-tangle luatexdir/luatex.version luatangle.c luatangle.h \ - luatangle-web2c luatangle.p cftest.p $(nodist_xetex_SOURCES) \ + $(nodist_libluatex_a_SOURCES) $(nodist_xetex_SOURCES) \ xetex.web xetex-web2c xetex.p xetex.pool xetex-tangle \ xetexdir/etex.version xetexdir/xetex.version \ $(omegaware_programs:=.c) $(omegaware_programs:=.h) \ @@ -1432,18 +1516,18 @@ cweave_CFLAGS = $(WARNING_CFLAGS) nodist_tie_SOURCES = tie.c tie_CPPFLAGS = -DNOT_WEB2C tie_CFLAGS = $(WARNING_CFLAGS) -tex_CPPFLAGS = $(am__append_43) +tex_CPPFLAGS = $(am__append_42) tex_CFLAGS = $(WARNING_CFLAGS) # With --enable-ipc, TeX may need to link with -lsocket. -tex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_44) +tex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_43) # TeX C sources tex_c_h = texini.c tex0.c texcoerce.h texd.h -nodist_tex_SOURCES = $(tex_c_h) tex-pool.c texextra.c $(am__append_46) +nodist_tex_SOURCES = $(tex_c_h) tex-pool.c texextra.c $(am__append_45) # We must create texd.h before building the tex_OBJECTS. -tex_prereq = texd.h $(am__append_45) +tex_prereq = texd.h $(am__append_44) tex_ch_srcs = \ tex.web \ tex.ch \ @@ -1506,19 +1590,19 @@ svgout_c_h = mplibsvg.h mpsvgout.h svgout.c tfmin_c_h = mptfmin.h tfmin.c libmplib_web = mplibdir/mp.w mplibdir/psout.w mplibdir/svgout.w \ mplibdir/memio.w mplibdir/tfmin.w -etex_CPPFLAGS = $(am__append_47) +etex_CPPFLAGS = $(am__append_46) etex_CFLAGS = $(WARNING_CFLAGS) # With --enable-ipc, e-TeX may need to link with -lsocket. -etex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_48) +etex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_47) # e-TeX C sources etex_c_h = etexini.c etex0.c etexcoerce.h etexd.h nodist_etex_SOURCES = $(etex_c_h) etex-pool.c etexextra.c \ - etexdir/etexextra.h $(am__append_50) + etexdir/etexextra.h $(am__append_49) # We must create etexd.h before building the etex_OBJECTS. -etex_prereq = etexd.h $(am__append_49) +etex_prereq = etexd.h $(am__append_48) etex_web_srcs = \ tex.web \ etexdir/etex.ch \ @@ -1549,7 +1633,7 @@ pdftex_dependencies = $(proglib) $(KPATHSEA_DEPEND) $(LIBPNG_DEPEND) \ # Force Automake to use CXXLD for linking nodist_EXTRA_pdftex_SOURCES = dummy.cxx pdf_tangle = WEBINPUTS=.:$(srcdir)/pdftexdir $(SHELL) ./tangle-sh $@ $(TANGLE) -pdftex_CPPFLAGS = $(pdftex_cppflags) $(am__append_51) +pdftex_CPPFLAGS = $(pdftex_cppflags) $(am__append_50) pdftex_CFLAGS = $(WARNING_CFLAGS) pdftex_CXXFLAGS = $(WARNING_CXXFLAGS) @@ -1558,7 +1642,7 @@ pdftex_LDADD = libpdftex.a $(pdftex_ldadd) $(LDADD) $(ipc_socketlibs) pdftex_DEPENDENCIES = $(pdftex_dependencies) libpdftex.a pdftex_c_h = pdftexini.c pdftex0.c pdftexcoerce.h pdftexd.h nodist_pdftex_SOURCES = $(pdftex_c_h) pdftex-pool.c pdftexextra.c \ - pdftexdir/pdftexextra.h $(am__append_52) + pdftexdir/pdftexextra.h $(am__append_51) pdftex_ch_srcs = \ pdftexdir/pdftex.web \ pdftexdir/tex.ch0 \ @@ -1600,7 +1684,6 @@ pdftosrc_DEPENDENCIES = $(pdftex_dependencies) # Force Automake to use CXXLD for linking nodist_EXTRA_luatex_SOURCES = dummy.cxx -luatex_tangle = WEBINPUTS=$(srcdir)/luatexdir $(SHELL) ./tangle-sh $@ '$(LUATANGLE) --underlines' luatex_CPPFLAGS = $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) $(XPDF_INCLUDES) \ $(OBSDCOMPAT_INCLUDES) -I$(srcdir)/libmd5 -Iluatexdir \ -I$(srcdir)/luatexdir -I$(srcdir)/luatexdir/lua51 \ @@ -1610,16 +1693,13 @@ luatex_CXXFLAGS = $(WARNING_CXXFLAGS) luatex_ldadd = libluatex.a libff.a libluamisc.a libluasocket.a \ liblua51.a $(ZZIPLIB_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) \ $(XPDF_LIBS) $(OBSDCOMPAT_LIBS) libmd5.a libmplib.a -luatex_LDADD = $(luatex_ldadd) $(LDADD) $(lua_socketlibs) +luatex_LDFLAGS = -export-dynamic +luatex_LDADD = $(luatex_ldadd) $(LDADD) $(LIBADD_DLOPEN) $(lua_socketlibs) luatex_DEPENDENCIES = $(proglib) $(KPATHSEA_DEPEND) libluatex.a \ $(LIBPNG_DEPEND) $(ZLIB_DEPEND) $(XPDF_DEPEND) \ $(OBSDCOMPAT_DEPEND) libmd5.a libmplib.a -luatex_c_h = luatexini.c luatex0.c luatexcoerce.h luatexd.h -nodist_luatex_SOURCES = $(luatex_c_h) luatex-pool.c luatexextra.c luatexdir/luatexextra.h -luatex_sources = luatexdir/luatex.web luatexdir/luatex.ch -nodist_luatangle_SOURCES = luatangle.c luatangle.h -luatangle_sources = luatexdir/luatangle.web luatexdir/luatangle.ch -liblua51_a_CPPFLAGS = -I$(top_srcdir)/luatexdir/lua51 $(am__append_24) +luatex_SOURCES = luatexdir/luatex_svnversion.h luatexdir/luatex.c luatexdir/luatex.h +liblua51_a_CPPFLAGS = -I$(top_srcdir)/luatexdir/lua51 $(am__append_23) liblua51_a_CFLAGS = # $(WARNING_CFLAGS) liblua51_a_SOURCES = \ luatexdir/lua51/lapi.c \ @@ -1722,8 +1802,9 @@ libluamisc_a_SOURCES = \ luatexdir/luafilesystem/src/lfs.c \ luatexdir/luafilesystem/src/lfs.h \ luatexdir/luamd5/md5.c \ - luatexdir/luamd5/md5.h \ + luatexdir/luamd5/luamd5.h \ luatexdir/luamd5/md5lib.c \ + luatexdir/luamd5/md5_lua.c \ luatexdir/luapeg/lpeg.c \ luatexdir/luaprofiler/clocks.c \ luatexdir/luaprofiler/clocks.h \ @@ -1755,15 +1836,12 @@ libff_a_CFLAGS = # $(WARNING_CFLAGS) libff_a_SOURCES = \ luatexdir/luafontloader/fontforge/Unicode/ArabicForms.c \ luatexdir/luafontloader/fontforge/Unicode/alphabet.c \ - luatexdir/luafontloader/fontforge/Unicode/backtrns.c \ luatexdir/luafontloader/fontforge/Unicode/char.c \ luatexdir/luafontloader/fontforge/Unicode/cjk.c \ luatexdir/luafontloader/fontforge/Unicode/combiners.h \ - luatexdir/luafontloader/fontforge/Unicode/dump.c \ luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c \ luatexdir/luafontloader/fontforge/Unicode/memory.c \ luatexdir/luafontloader/fontforge/Unicode/ucharmap.c \ - luatexdir/luafontloader/fontforge/Unicode/unialt.c \ luatexdir/luafontloader/fontforge/Unicode/ustring.c \ luatexdir/luafontloader/fontforge/Unicode/utype.c \ luatexdir/luafontloader/fontforge/fontforge/PfEd.h \ @@ -1853,8 +1931,7 @@ libff_a_SOURCES = \ luatexdir/luafontloader/fontforge/inc/ustring.h \ luatexdir/luafontloader/fontforge/inc/utype.h \ luatexdir/luafontloader/src/ffdummies.c \ - luatexdir/luafontloader/src/luafflib.c \ - luatexdir/luafontloader/src/luafflib.h + luatexdir/luafontloader/src/luafflib.c libluatex_a_DEPENDENCIES = libff.a libluatex_a_CPPFLAGS = $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) \ @@ -1863,82 +1940,213 @@ libluatex_a_CPPFLAGS = $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) \ -DpdfTeX libluatex_a_CFLAGS = $(WARNING_CFLAGS) libluatex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) -libluatex_a_SOURCES = luatexdir/commands.h luatexdir/font/dofont.c \ - luatexdir/font/luatexfont.h luatexdir/font/luafont.c \ - luatexdir/font/mapfile.c luatexdir/font/mapfile.h \ - luatexdir/font/pkin.c luatexdir/font/sfnt.c \ - luatexdir/font/sfnt.h luatexdir/font/subfont.c \ - luatexdir/font/texfont.c luatexdir/font/texfont.h \ - luatexdir/font/tfmofm.c luatexdir/font/tounicode.c \ - luatexdir/font/tt_glyf.c luatexdir/font/tt_glyf.h \ - luatexdir/font/tt_table.c luatexdir/font/tt_table.h \ - luatexdir/font/vfovf.c luatexdir/font/vfpacket.c \ - luatexdir/font/writecff.c luatexdir/font/writecff.h \ - luatexdir/font/writeenc.c luatexdir/font/writefont.c \ - luatexdir/font/writet1.c luatexdir/font/writet3.c \ - luatexdir/font/writettf.c luatexdir/font/writettf.h \ - luatexdir/font/writetype0.c luatexdir/font/writetype2.c \ - luatexdir/get_svnversion.sh luatexdir/hyphen.h \ - luatexdir/image/epdf.c luatexdir/image/epdf.h \ - luatexdir/image/image.h luatexdir/image/pdftoepdf.cc \ - luatexdir/image/pdftoepdf.h luatexdir/image/writeimg.c \ - luatexdir/image/writeimg.h luatexdir/image/writejbig2.c \ - luatexdir/image/writejbig2.h luatexdir/image/writejpg.c \ - luatexdir/image/writejpg.h luatexdir/image/writepng.c \ - luatexdir/image/writepng.h luatexdir/lang/hnjalloc.c \ - luatexdir/lang/hnjalloc.h luatexdir/lang/hyphen.c \ - luatexdir/lang/texlang.c luatexdir/lua/lcallbacklib.c \ - luatexdir/lua/lfontlib.c luatexdir/lua/limglib.c \ - luatexdir/lua/lkpselib.c luatexdir/lua/llanglib.c \ - luatexdir/lua/llualib.c luatexdir/lua/lnodelib.c \ - luatexdir/lua/loslibext.c luatexdir/lua/liolib.c \ - luatexdir/lua/lpdflib.c luatexdir/lua/lstatslib.c \ - luatexdir/lua/ltexiolib.c luatexdir/lua/ltexlib.c \ - luatexdir/lua/ltokenlib.c luatexdir/lua/luainit.c \ - luatexdir/lua/luanode.c luatexdir/lua/luastuff.c \ - luatexdir/lua/luatex.c luatexdir/lua/luatoken.c \ - luatexdir/lua/texluac.c luatexdir/luatex-api.h \ - luatexdir/luatex.h luatexdir/makecpool.c \ - luatexdir/managed-sa.c luatexdir/managed-sa.h \ - luatexdir/mathcodes.c luatexdir/nodes.h \ - luatexdir/pdf/pagetree.c luatexdir/pdf/pagetree.h \ - luatexdir/pdf/pdfpage.c luatexdir/pdf/pdfpage.h \ - luatexdir/primitive.h luatexdir/ptexmac.h \ - luatexdir/tex/filename.c luatexdir/tex/linebreak.c \ - luatexdir/tex/math.c luatexdir/tex/mlist.c \ - luatexdir/tex/postlinebreak.c luatexdir/tex/primitive.c \ - luatexdir/tex/texdeffont.c luatexdir/tex/texnodes.c \ - luatexdir/tex/texpdf.c luatexdir/tex/textoken.c \ - luatexdir/texmath.h luatexdir/textcodes.c luatexdir/tokens.h \ - luatexdir/utils/avl.c luatexdir/utils/avl.h \ - luatexdir/utils/avlstuff.c luatexdir/utils/avlstuff.h \ - luatexdir/utils/synctex.h luatexdir/utils/synctex.c \ - luatexdir/utils/utils.c luatexdir/utils/utils.h \ - luatexdir/utils/writezip.c mplibdir/lmplib.c \ - luatexdir/inc-epdf.h luatexdir/inc-extra.h \ - luatexdir/inc-vfovf.h -EXTRA_libluatex_a_SOURCES = luatexdir/font/macnames.c +luatex_dvi_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/dvi $(ctangle) +libluatex_web = luatexdir/dvi/dvigen.w luatexdir/font/dofont.w \ + luatexdir/font/luafont.w luatexdir/font/mapfile.w \ + luatexdir/font/pkin.w luatexdir/font/sfnt.w \ + luatexdir/font/subfont.w luatexdir/font/texfont.w \ + luatexdir/font/tfmofm.w luatexdir/font/tounicode.w \ + luatexdir/font/tt_glyf.w luatexdir/font/tt_table.w \ + luatexdir/font/vfovf.w luatexdir/font/vfpacket.w \ + luatexdir/font/writecff.w luatexdir/font/writeenc.w \ + luatexdir/font/writefont.w luatexdir/font/writet1.w \ + luatexdir/font/writet3.w luatexdir/font/writettf.w \ + luatexdir/font/writetype0.w luatexdir/font/writetype2.w \ + luatexdir/image/epdf.w luatexdir/image/writeimg.w \ + luatexdir/image/writejbig2.w luatexdir/image/writejpg.w \ + luatexdir/image/writepng.w luatexdir/lua/luagen.w \ + luatexdir/lua/luainit.w luatexdir/lua/luanode.w \ + luatexdir/lua/luastuff.w luatexdir/lua/luatoken.w \ + luatexdir/lua/texluac.w luatexdir/ocp/ocp.w \ + luatexdir/ocp/ocplist.w luatexdir/ocp/readocp.w \ + luatexdir/ocp/runocp.w luatexdir/lang/texlang.w \ + luatexdir/lang/hyphen.w luatexdir/lang/hnjalloc.w \ + luatexdir/pdf/pagetree.w luatexdir/pdf/pdfaction.w \ + luatexdir/pdf/pdfannot.w luatexdir/pdf/pdfcolorstack.w \ + luatexdir/pdf/pdfdest.w luatexdir/pdf/pdffont.w \ + luatexdir/pdf/pdfgen.w luatexdir/pdf/pdfglyph.w \ + luatexdir/pdf/pdfimage.w luatexdir/pdf/pdflink.w \ + luatexdir/pdf/pdflistout.w luatexdir/pdf/pdfliteral.w \ + luatexdir/pdf/pdfobj.w luatexdir/pdf/pdfoutline.w \ + luatexdir/pdf/pdfpage.w luatexdir/pdf/pdfrule.w \ + luatexdir/pdf/pdfsaverestore.w luatexdir/pdf/pdfsetmatrix.w \ + luatexdir/pdf/pdfshipout.w luatexdir/pdf/pdftables.w \ + luatexdir/pdf/pdfthread.w luatexdir/pdf/pdfxform.w \ + luatexdir/tex/align.w luatexdir/tex/dumpdata.w \ + luatexdir/tex/expand.w luatexdir/tex/inputstack.w \ + luatexdir/tex/maincontrol.w luatexdir/tex/mlist.w \ + luatexdir/tex/postlinebreak.w luatexdir/tex/scanning.w \ + luatexdir/tex/texdeffont.w luatexdir/tex/texnodes.w \ + luatexdir/tex/arithmetic.w luatexdir/tex/conditional.w \ + luatexdir/tex/equivalents.w luatexdir/tex/extensions.w \ + luatexdir/tex/commands.w luatexdir/tex/linebreak.w \ + luatexdir/tex/mathcodes.w luatexdir/tex/nesting.w \ + luatexdir/tex/primitive.w luatexdir/tex/texfileio.w \ + luatexdir/tex/textcodes.w luatexdir/tex/buildpage.w \ + luatexdir/tex/directions.w luatexdir/tex/errors.w \ + luatexdir/tex/filename.w luatexdir/tex/mainbody.w \ + luatexdir/tex/memoryword.w luatexdir/tex/packaging.w \ + luatexdir/tex/printing.w luatexdir/tex/stringpool.w \ + luatexdir/tex/texmath.w luatexdir/tex/textoken.w \ + luatexdir/utils/utils.w luatexdir/utils/avlstuff.w \ + luatexdir/utils/managed-sa.w +nodist_libluatex_a_SOURCES = dvigen.c dofont.c luafont.c mapfile.c \ + pkin.c sfnt.c subfont.c texfont.c tfmofm.c tounicode.c \ + tt_glyf.c tt_table.c vfovf.c vfpacket.c writecff.c writeenc.c \ + writefont.c writet1.c writet3.c writettf.c writetype0.c \ + writetype2.c epdf.c writeimg.c writejbig2.c writejpg.c \ + writepng.c luagen.c luainit.c luanode.c luastuff.c luatoken.c \ + texluac.c ocp.c ocplist.c readocp.c runocp.c texlang.c \ + hyphen.c hnjalloc.c pagetree.c pdfaction.c pdfannot.c \ + pdfcolorstack.c pdfdest.c pdffont.c pdfgen.c pdfglyph.c \ + pdfimage.c pdflink.c pdflistout.c pdfliteral.c pdfobj.c \ + pdfoutline.c pdfpage.c pdfrule.c pdfsaverestore.c \ + pdfsetmatrix.c pdfshipout.c pdftables.c pdfthread.c pdfxform.c \ + align.c dumpdata.c expand.c inputstack.c maincontrol.c mlist.c \ + postlinebreak.c scanning.c texdeffont.c texnodes.c \ + arithmetic.c conditional.c equivalents.c extensions.c \ + commands.c linebreak.c mathcodes.c nesting.c primitive.c \ + texfileio.c textcodes.c buildpage.c directions.c errors.c \ + filename.c mainbody.c memoryword.c packaging.c printing.c \ + stringpool.c texmath.c textoken.c utils.c avlstuff.c \ + managed-sa.c +luatex_font_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/font $(ctangle) +luatex_image_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/image $(ctangle) +luatex_lua_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/lua $(ctangle) +luatex_ocp_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/ocp $(ctangle) +luatex_lang_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/lang $(ctangle) +luatex_pdf_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/pdf $(ctangle) +luatex_tex_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/tex $(ctangle) +luatex_utils_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/utils $(ctangle) +libluatex_a_SOURCES = \ + luatexdir/dvi/dvigen.h \ + luatexdir/font/luatexfont.h \ + luatexdir/font/mapfile.h \ + luatexdir/font/sfnt.h \ + luatexdir/font/texfont.h \ + luatexdir/font/tt_glyf.h \ + luatexdir/font/tt_table.h \ + luatexdir/font/writecff.h \ + luatexdir/font/writettf.h \ + luatexdir/image/epdf.h \ + luatexdir/image/image.h \ + luatexdir/image/pdftoepdf.cc \ + luatexdir/image/pdftoepdf.h \ + luatexdir/image/writeimg.h \ + luatexdir/image/writejbig2.h \ + luatexdir/image/writejpg.h \ + luatexdir/image/writepng.h \ + luatexdir/lang/hnjalloc.h \ + luatexdir/lang/hyphen.h \ + luatexdir/lang/texlang.h \ + luatexdir/lua/lcallbacklib.c \ + luatexdir/lua/lfontlib.c \ + luatexdir/lua/limglib.c \ + luatexdir/lua/lepdflib.cc \ + luatexdir/lua/lkpselib.c \ + luatexdir/lua/llanglib.c \ + luatexdir/lua/llualib.c \ + luatexdir/lua/lnodelib.c \ + luatexdir/lua/loslibext.c \ + luatexdir/lua/liolib.c \ + luatexdir/lua/lpdflib.c \ + luatexdir/lua/lstatslib.c \ + luatexdir/lua/ltexiolib.c \ + luatexdir/lua/ltexlib.c \ + luatexdir/lua/ltokenlib.c \ + luatexdir/lua/luagen.h \ + luatexdir/lua/luatex-api.h \ + luatexdir/luatex.h \ + luatexdir/ocp/ocp.h \ + luatexdir/ocp/ocplist.h \ + luatexdir/ocp/readocp.h \ + luatexdir/ocp/runocp.h \ + luatexdir/pdf/pagetree.h \ + luatexdir/pdf/pdfaction.h \ + luatexdir/pdf/pdfannot.h \ + luatexdir/pdf/pdfcolorstack.h \ + luatexdir/pdf/pdfdest.h \ + luatexdir/pdf/pdffont.h \ + luatexdir/pdf/pdfgen.h \ + luatexdir/pdf/pdfglyph.h \ + luatexdir/pdf/pdfimage.h \ + luatexdir/pdf/pdflink.h \ + luatexdir/pdf/pdflistout.h \ + luatexdir/pdf/pdfliteral.h \ + luatexdir/pdf/pdfobj.h \ + luatexdir/pdf/pdfoutline.h \ + luatexdir/pdf/pdfpage.h \ + luatexdir/pdf/pdfrule.h \ + luatexdir/pdf/pdfsaverestore.h \ + luatexdir/pdf/pdfsetmatrix.h \ + luatexdir/pdf/pdfshipout.h \ + luatexdir/pdf/pdftables.h \ + luatexdir/pdf/pdfthread.h \ + luatexdir/pdf/pdftypes.h \ + luatexdir/pdf/pdfxform.h \ + luatexdir/tex/align.h \ + luatexdir/tex/arithmetic.h \ + luatexdir/tex/buildpage.h \ + luatexdir/tex/commands.h \ + luatexdir/tex/conditional.h \ + luatexdir/tex/directions.h \ + luatexdir/tex/dumpdata.h \ + luatexdir/tex/equivalents.h \ + luatexdir/tex/errors.h \ + luatexdir/tex/expand.h \ + luatexdir/tex/extensions.h \ + luatexdir/tex/filename.h \ + luatexdir/tex/inputstack.h \ + luatexdir/tex/linebreak.h \ + luatexdir/tex/mainbody.h \ + luatexdir/tex/maincontrol.h \ + luatexdir/tex/mathcodes.h \ + luatexdir/tex/memoryword.h \ + luatexdir/tex/mlist.h \ + luatexdir/tex/nesting.h \ + luatexdir/tex/packaging.h \ + luatexdir/tex/postlinebreak.h \ + luatexdir/tex/primitive.h \ + luatexdir/tex/printing.h \ + luatexdir/tex/scanning.h \ + luatexdir/tex/stringpool.h \ + luatexdir/tex/texdeffont.h \ + luatexdir/tex/texfileio.h \ + luatexdir/tex/texmath.h \ + luatexdir/tex/texnodes.h \ + luatexdir/tex/textoken.h \ + luatexdir/tex/textcodes.h \ + luatexdir/utils/avl.c \ + luatexdir/utils/avl.h \ + luatexdir/utils/avlstuff.h \ + luatexdir/utils/managed-sa.h \ + luatexdir/utils/synctex.h \ + luatexdir/utils/synctex.c \ + luatexdir/utils/utils.h \ + $(nodist_libluatex_a_SOURCES) \ + mplibdir/lmplib.c + # Force Automake to use CXXLD for linking nodist_EXTRA_xetex_SOURCES = dummy.cxx -libxetex = libxetex.a $(am__append_27) +libxetex = libxetex.a $(am__append_26) xetex_cppflags = -I$(srcdir)/xetexdir $(ICU_INCLUDES) \ - $(FREETYPE2_INCLUDES) $(TECKIT_INCLUDES) $(am__append_26) \ - $(am__append_28) $(am__append_31) $(ZLIB_INCLUDES) -xetex_ldadd = $(libxetex) $(ICU_LIBS) $(TECKIT_LIBS) $(am__append_29) \ - $(am__append_32) $(FREETYPE2_LIBS) $(ZLIB_LIBS) + $(FREETYPE2_INCLUDES) $(TECKIT_INCLUDES) $(am__append_25) \ + $(am__append_27) $(am__append_30) $(ZLIB_INCLUDES) +xetex_ldadd = $(libxetex) $(ICU_LIBS) $(TECKIT_LIBS) $(am__append_28) \ + $(am__append_31) $(FREETYPE2_LIBS) $(ZLIB_LIBS) xetex_dependencies = $(proglib) $(KPATHSEA_DEPEND) $(ICU_DEPEND) \ - $(TECKIT_DEPEND) $(am__append_30) $(am__append_33) \ + $(TECKIT_DEPEND) $(am__append_29) $(am__append_32) \ $(FREETYPE2_DEPEND) $(ZLIB_DEPEND) @XETEX_MACOSX_TRUE@xetex_LDFLAGS = -framework Carbon -framework Cocoa -framework QuickTime -xetex_CPPFLAGS = $(xetex_cppflags) $(am__append_53) +xetex_CPPFLAGS = $(xetex_cppflags) $(am__append_52) xetex_CFLAGS = # $(WARNING_CFLAGS) xetex_CXXFLAGS = # $(WARNING_CXXFLAGS) xetex_LDADD = $(xetex_ldadd) $(LDADD) $(ipc_socketlibs) xetex_prereq = $(libxetex) xetex_c_h = xetexini.c xetex0.c xetexcoerce.h xetexd.h nodist_xetex_SOURCES = $(xetex_c_h) xetex_pool.c xetexextra.c \ - xetexdir/xetexextra.h $(am__append_54) + xetexdir/xetexextra.h $(am__append_53) xetex_web_srcs = \ tex.web \ etexdir/etex.ch \ @@ -1966,8 +2174,8 @@ libxetex_a_SOURCES = xetexdir/MathTable.h xetexdir/FontTableCache.cpp \ xetexdir/XeTeXOTMath.h xetexdir/XeTeX_ext.c \ xetexdir/XeTeX_ext.h xetexdir/XeTeXswap.h xetexdir/cmaps.cpp \ xetexdir/cmaps.h xetexdir/sfnt.h xetexdir/trans.c \ - xetexdir/trans.h xetexdir/xetex.h $(am__append_34) \ - $(am__append_35) $(am__append_36) + xetexdir/trans.h xetexdir/xetex.h $(am__append_33) \ + $(am__append_34) $(am__append_35) # We must create xetexd.h etc. before building the libxetex_a_OBJECTS. libxetex_prereq = xetexd.h $(xetex_dependencies) @@ -2146,7 +2354,7 @@ all: c-auto.h ff-config.h .SUFFIXES: .c .cc .cin .cpp .cxx .h .hin .lo .o .obj .p .pin am--refresh: @: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/am/bootstrap.am $(srcdir)/am/web.am $(srcdir)/am/cweb.am $(srcdir)/am/texmf.am $(srcdir)/mplibdir/am/mplib.am $(srcdir)/mplibdir/am/libmplib.am $(srcdir)/etexdir/am/etex.am $(srcdir)/pdftexdir/am/pdftex.am $(srcdir)/pdftexdir/am/libpdftex.am $(srcdir)/pdftexdir/am/ttf2afm.am $(srcdir)/pdftexdir/am/pdftosrc.am $(srcdir)/luatexdir/am/luatex.am $(srcdir)/luatexdir/am/luatangle.am $(srcdir)/luatexdir/am/liblua51.am $(srcdir)/luatexdir/am/luasocket.am $(srcdir)/luatexdir/am/luamisc.am $(srcdir)/luatexdir/am/luafontforge.am $(srcdir)/luatexdir/am/libluatex.am $(srcdir)/xetexdir/am/xetex.am $(srcdir)/omegaware/am/omegaware.am $(srcdir)/alephdir/am/aleph.am $(srcdir)/synctexdir/am/synctex.am $(srcdir)/libmd5/am/md5.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/am/bootstrap.am $(srcdir)/am/web.am $(srcdir)/am/cweb.am $(srcdir)/am/texmf.am $(srcdir)/mplibdir/am/mplib.am $(srcdir)/mplibdir/am/libmplib.am $(srcdir)/etexdir/am/etex.am $(srcdir)/pdftexdir/am/pdftex.am $(srcdir)/pdftexdir/am/libpdftex.am $(srcdir)/pdftexdir/am/ttf2afm.am $(srcdir)/pdftexdir/am/pdftosrc.am $(srcdir)/luatexdir/am/luatex.am $(srcdir)/luatexdir/am/liblua51.am $(srcdir)/luatexdir/am/luasocket.am $(srcdir)/luatexdir/am/luamisc.am $(srcdir)/luatexdir/am/luafontforge.am $(srcdir)/luatexdir/am/libluatex.am $(srcdir)/xetexdir/am/xetex.am $(srcdir)/omegaware/am/omegaware.am $(srcdir)/alephdir/am/aleph.am $(srcdir)/synctexdir/am/synctex.am $(srcdir)/libmd5/am/md5.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -2351,9 +2559,6 @@ gftopk$(EXEEXT): $(gftopk_OBJECTS) $(gftopk_DEPENDENCIES) gftype$(EXEEXT): $(gftype_OBJECTS) $(gftype_DEPENDENCIES) @rm -f gftype$(EXEEXT) $(LINK) $(gftype_OBJECTS) $(gftype_LDADD) $(LIBS) -luatangle$(EXEEXT): $(luatangle_OBJECTS) $(luatangle_DEPENDENCIES) - @rm -f luatangle$(EXEEXT) - $(LINK) $(luatangle_OBJECTS) $(luatangle_LDADD) $(LIBS) luatex$(EXEEXT): $(luatex_OBJECTS) $(luatex_DEPENDENCIES) @rm -f luatex$(EXEEXT) $(luatex_LINK) $(luatex_OBJECTS) $(luatex_LDADD) $(LIBS) @@ -2481,12 +2686,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-ArabicForms.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-alphabet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-autohint.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-backtrns.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-char.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-cjk.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-clipnoui.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-cvundoes.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-dump.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-dumppfa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-encoding.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-featurefile.Po@am__quote@ @@ -2533,7 +2736,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-tottfgpos.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-ttfspecial.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-ucharmap.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-unialt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-ustring.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libff_a-utype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblua51_a-lapi.Po@am__quote@ @@ -2575,6 +2777,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluamisc_a-luazip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluamisc_a-lzlib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluamisc_a-md5.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluamisc_a-md5_lua.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluamisc_a-md5lib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluamisc_a-slnudata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluamisc_a-slnunico.Po@am__quote@ @@ -2593,14 +2796,28 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluasocket_a-tcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluasocket_a-timeout.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluasocket_a-udp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-align.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-arithmetic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-avl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-avlstuff.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-buildpage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-commands.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-conditional.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-directions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-dofont.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-dumpdata.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-dvigen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-epdf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-equivalents.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-errors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-expand.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-extensions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-filename.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-hnjalloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-hyphen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-inputstack.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-lcallbacklib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-lepdflib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-lfontlib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-limglib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-linebreak.Po@am__quote@ @@ -2617,33 +2834,63 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-ltexlib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-ltokenlib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-luafont.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-luagen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-luainit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-luanode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-luastuff.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-luatex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-luatoken.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-macnames.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-makecpool.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-mainbody.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-maincontrol.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-managed-sa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-mapfile.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-math.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-mathcodes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-memoryword.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-mlist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-nesting.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-ocp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-ocplist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-packaging.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pagetree.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfaction.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfannot.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfcolorstack.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfdest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdffont.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfgen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfglyph.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfimage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdflink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdflistout.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfliteral.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfobj.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfoutline.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfpage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfrule.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfsaverestore.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfsetmatrix.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfshipout.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdftables.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfthread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdftoepdf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pdfxform.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-pkin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-postlinebreak.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-primitive.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-printing.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-readocp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-runocp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-scanning.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-sfnt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-stringpool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-subfont.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-synctex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texdeffont.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texfileio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texfont.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texlang.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texluac.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texmath.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texnodes.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-texpdf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-textcodes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-textoken.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-tfmofm.Po@am__quote@ @@ -2665,7 +2912,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-writettf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-writetype0.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-writetype2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-writezip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmd5_a-md5.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmf_a-mf-pool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmf_a-mf0.Po@am__quote@ @@ -2723,12 +2969,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxetex_a-pngimage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxetex_a-trans.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxetexmm_a-XeTeXFontMgr_Mac.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luatangle.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luatex-dummy.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luatex-luatex-pool.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luatex-luatex0.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luatex-luatexextra.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luatex-luatexini.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luatex-luatex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5main-md5main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf-mfextra.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf_nowin-mfextra.Po@am__quote@ @@ -2828,20 +3070,6 @@ libff_a-alphabet.obj: luatexdir/luafontloader/fontforge/Unicode/alphabet.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-alphabet.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/alphabet.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/alphabet.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/alphabet.c'; fi` -libff_a-backtrns.o: luatexdir/luafontloader/fontforge/Unicode/backtrns.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-backtrns.o -MD -MP -MF $(DEPDIR)/libff_a-backtrns.Tpo -c -o libff_a-backtrns.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/backtrns.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/backtrns.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-backtrns.Tpo $(DEPDIR)/libff_a-backtrns.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luafontloader/fontforge/Unicode/backtrns.c' object='libff_a-backtrns.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-backtrns.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/backtrns.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/backtrns.c - -libff_a-backtrns.obj: luatexdir/luafontloader/fontforge/Unicode/backtrns.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-backtrns.obj -MD -MP -MF $(DEPDIR)/libff_a-backtrns.Tpo -c -o libff_a-backtrns.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/backtrns.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/backtrns.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/backtrns.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-backtrns.Tpo $(DEPDIR)/libff_a-backtrns.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luafontloader/fontforge/Unicode/backtrns.c' object='libff_a-backtrns.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-backtrns.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/backtrns.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/backtrns.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/backtrns.c'; fi` - libff_a-char.o: luatexdir/luafontloader/fontforge/Unicode/char.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-char.o -MD -MP -MF $(DEPDIR)/libff_a-char.Tpo -c -o libff_a-char.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/char.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/char.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-char.Tpo $(DEPDIR)/libff_a-char.Po @@ -2870,20 +3098,6 @@ libff_a-cjk.obj: luatexdir/luafontloader/fontforge/Unicode/cjk.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-cjk.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/cjk.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/cjk.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/cjk.c'; fi` -libff_a-dump.o: luatexdir/luafontloader/fontforge/Unicode/dump.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-dump.o -MD -MP -MF $(DEPDIR)/libff_a-dump.Tpo -c -o libff_a-dump.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/dump.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/dump.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-dump.Tpo $(DEPDIR)/libff_a-dump.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luafontloader/fontforge/Unicode/dump.c' object='libff_a-dump.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-dump.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/dump.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/dump.c - -libff_a-dump.obj: luatexdir/luafontloader/fontforge/Unicode/dump.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-dump.obj -MD -MP -MF $(DEPDIR)/libff_a-dump.Tpo -c -o libff_a-dump.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/dump.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/dump.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/dump.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-dump.Tpo $(DEPDIR)/libff_a-dump.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luafontloader/fontforge/Unicode/dump.c' object='libff_a-dump.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-dump.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/dump.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/dump.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/dump.c'; fi` - libff_a-gwwiconv.o: luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-gwwiconv.o -MD -MP -MF $(DEPDIR)/libff_a-gwwiconv.Tpo -c -o libff_a-gwwiconv.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-gwwiconv.Tpo $(DEPDIR)/libff_a-gwwiconv.Po @@ -2926,20 +3140,6 @@ libff_a-ucharmap.obj: luatexdir/luafontloader/fontforge/Unicode/ucharmap.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-ucharmap.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/ucharmap.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/ucharmap.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c'; fi` -libff_a-unialt.o: luatexdir/luafontloader/fontforge/Unicode/unialt.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-unialt.o -MD -MP -MF $(DEPDIR)/libff_a-unialt.Tpo -c -o libff_a-unialt.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/unialt.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/unialt.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-unialt.Tpo $(DEPDIR)/libff_a-unialt.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luafontloader/fontforge/Unicode/unialt.c' object='libff_a-unialt.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-unialt.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/unialt.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/unialt.c - -libff_a-unialt.obj: luatexdir/luafontloader/fontforge/Unicode/unialt.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-unialt.obj -MD -MP -MF $(DEPDIR)/libff_a-unialt.Tpo -c -o libff_a-unialt.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/unialt.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/unialt.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/unialt.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-unialt.Tpo $(DEPDIR)/libff_a-unialt.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luafontloader/fontforge/Unicode/unialt.c' object='libff_a-unialt.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -c -o libff_a-unialt.obj `if test -f 'luatexdir/luafontloader/fontforge/Unicode/unialt.c'; then $(CYGPATH_W) 'luatexdir/luafontloader/fontforge/Unicode/unialt.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luafontloader/fontforge/Unicode/unialt.c'; fi` - libff_a-ustring.o: luatexdir/luafontloader/fontforge/Unicode/ustring.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libff_a_CPPFLAGS) $(CPPFLAGS) $(libff_a_CFLAGS) $(CFLAGS) -MT libff_a-ustring.o -MD -MP -MF $(DEPDIR)/libff_a-ustring.Tpo -c -o libff_a-ustring.o `test -f 'luatexdir/luafontloader/fontforge/Unicode/ustring.c' || echo '$(srcdir)/'`luatexdir/luafontloader/fontforge/Unicode/ustring.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libff_a-ustring.Tpo $(DEPDIR)/libff_a-ustring.Po @@ -4060,6 +4260,20 @@ libluamisc_a-md5lib.obj: luatexdir/luamd5/md5lib.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluamisc_a_CPPFLAGS) $(CPPFLAGS) $(libluamisc_a_CFLAGS) $(CFLAGS) -c -o libluamisc_a-md5lib.obj `if test -f 'luatexdir/luamd5/md5lib.c'; then $(CYGPATH_W) 'luatexdir/luamd5/md5lib.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luamd5/md5lib.c'; fi` +libluamisc_a-md5_lua.o: luatexdir/luamd5/md5_lua.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluamisc_a_CPPFLAGS) $(CPPFLAGS) $(libluamisc_a_CFLAGS) $(CFLAGS) -MT libluamisc_a-md5_lua.o -MD -MP -MF $(DEPDIR)/libluamisc_a-md5_lua.Tpo -c -o libluamisc_a-md5_lua.o `test -f 'luatexdir/luamd5/md5_lua.c' || echo '$(srcdir)/'`luatexdir/luamd5/md5_lua.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluamisc_a-md5_lua.Tpo $(DEPDIR)/libluamisc_a-md5_lua.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luamd5/md5_lua.c' object='libluamisc_a-md5_lua.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluamisc_a_CPPFLAGS) $(CPPFLAGS) $(libluamisc_a_CFLAGS) $(CFLAGS) -c -o libluamisc_a-md5_lua.o `test -f 'luatexdir/luamd5/md5_lua.c' || echo '$(srcdir)/'`luatexdir/luamd5/md5_lua.c + +libluamisc_a-md5_lua.obj: luatexdir/luamd5/md5_lua.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluamisc_a_CPPFLAGS) $(CPPFLAGS) $(libluamisc_a_CFLAGS) $(CFLAGS) -MT libluamisc_a-md5_lua.obj -MD -MP -MF $(DEPDIR)/libluamisc_a-md5_lua.Tpo -c -o libluamisc_a-md5_lua.obj `if test -f 'luatexdir/luamd5/md5_lua.c'; then $(CYGPATH_W) 'luatexdir/luamd5/md5_lua.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luamd5/md5_lua.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluamisc_a-md5_lua.Tpo $(DEPDIR)/libluamisc_a-md5_lua.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luamd5/md5_lua.c' object='libluamisc_a-md5_lua.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluamisc_a_CPPFLAGS) $(CPPFLAGS) $(libluamisc_a_CFLAGS) $(CFLAGS) -c -o libluamisc_a-md5_lua.obj `if test -f 'luatexdir/luamd5/md5_lua.c'; then $(CYGPATH_W) 'luatexdir/luamd5/md5_lua.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luamd5/md5_lua.c'; fi` + libluamisc_a-lpeg.o: luatexdir/luapeg/lpeg.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluamisc_a_CPPFLAGS) $(CPPFLAGS) $(libluamisc_a_CFLAGS) $(CFLAGS) -MT libluamisc_a-lpeg.o -MD -MP -MF $(DEPDIR)/libluamisc_a-lpeg.Tpo -c -o libluamisc_a-lpeg.o `test -f 'luatexdir/luapeg/lpeg.c' || echo '$(srcdir)/'`luatexdir/luapeg/lpeg.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluamisc_a-lpeg.Tpo $(DEPDIR)/libluamisc_a-lpeg.Po @@ -4410,412 +4624,6 @@ libluasocket_a-udp.obj: luatexdir/luasocket/src/udp.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluasocket_a_CPPFLAGS) $(CPPFLAGS) $(libluasocket_a_CFLAGS) $(CFLAGS) -c -o libluasocket_a-udp.obj `if test -f 'luatexdir/luasocket/src/udp.c'; then $(CYGPATH_W) 'luatexdir/luasocket/src/udp.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luasocket/src/udp.c'; fi` -libluatex_a-dofont.o: luatexdir/font/dofont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dofont.o -MD -MP -MF $(DEPDIR)/libluatex_a-dofont.Tpo -c -o libluatex_a-dofont.o `test -f 'luatexdir/font/dofont.c' || echo '$(srcdir)/'`luatexdir/font/dofont.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dofont.Tpo $(DEPDIR)/libluatex_a-dofont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/dofont.c' object='libluatex_a-dofont.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dofont.o `test -f 'luatexdir/font/dofont.c' || echo '$(srcdir)/'`luatexdir/font/dofont.c - -libluatex_a-dofont.obj: luatexdir/font/dofont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dofont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-dofont.Tpo -c -o libluatex_a-dofont.obj `if test -f 'luatexdir/font/dofont.c'; then $(CYGPATH_W) 'luatexdir/font/dofont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/dofont.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dofont.Tpo $(DEPDIR)/libluatex_a-dofont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/dofont.c' object='libluatex_a-dofont.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dofont.obj `if test -f 'luatexdir/font/dofont.c'; then $(CYGPATH_W) 'luatexdir/font/dofont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/dofont.c'; fi` - -libluatex_a-luafont.o: luatexdir/font/luafont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luafont.o -MD -MP -MF $(DEPDIR)/libluatex_a-luafont.Tpo -c -o libluatex_a-luafont.o `test -f 'luatexdir/font/luafont.c' || echo '$(srcdir)/'`luatexdir/font/luafont.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luafont.Tpo $(DEPDIR)/libluatex_a-luafont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/luafont.c' object='libluatex_a-luafont.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luafont.o `test -f 'luatexdir/font/luafont.c' || echo '$(srcdir)/'`luatexdir/font/luafont.c - -libluatex_a-luafont.obj: luatexdir/font/luafont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luafont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luafont.Tpo -c -o libluatex_a-luafont.obj `if test -f 'luatexdir/font/luafont.c'; then $(CYGPATH_W) 'luatexdir/font/luafont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/luafont.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luafont.Tpo $(DEPDIR)/libluatex_a-luafont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/luafont.c' object='libluatex_a-luafont.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luafont.obj `if test -f 'luatexdir/font/luafont.c'; then $(CYGPATH_W) 'luatexdir/font/luafont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/luafont.c'; fi` - -libluatex_a-mapfile.o: luatexdir/font/mapfile.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mapfile.o -MD -MP -MF $(DEPDIR)/libluatex_a-mapfile.Tpo -c -o libluatex_a-mapfile.o `test -f 'luatexdir/font/mapfile.c' || echo '$(srcdir)/'`luatexdir/font/mapfile.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mapfile.Tpo $(DEPDIR)/libluatex_a-mapfile.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/mapfile.c' object='libluatex_a-mapfile.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mapfile.o `test -f 'luatexdir/font/mapfile.c' || echo '$(srcdir)/'`luatexdir/font/mapfile.c - -libluatex_a-mapfile.obj: luatexdir/font/mapfile.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mapfile.obj -MD -MP -MF $(DEPDIR)/libluatex_a-mapfile.Tpo -c -o libluatex_a-mapfile.obj `if test -f 'luatexdir/font/mapfile.c'; then $(CYGPATH_W) 'luatexdir/font/mapfile.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/mapfile.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mapfile.Tpo $(DEPDIR)/libluatex_a-mapfile.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/mapfile.c' object='libluatex_a-mapfile.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mapfile.obj `if test -f 'luatexdir/font/mapfile.c'; then $(CYGPATH_W) 'luatexdir/font/mapfile.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/mapfile.c'; fi` - -libluatex_a-pkin.o: luatexdir/font/pkin.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pkin.o -MD -MP -MF $(DEPDIR)/libluatex_a-pkin.Tpo -c -o libluatex_a-pkin.o `test -f 'luatexdir/font/pkin.c' || echo '$(srcdir)/'`luatexdir/font/pkin.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pkin.Tpo $(DEPDIR)/libluatex_a-pkin.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/pkin.c' object='libluatex_a-pkin.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pkin.o `test -f 'luatexdir/font/pkin.c' || echo '$(srcdir)/'`luatexdir/font/pkin.c - -libluatex_a-pkin.obj: luatexdir/font/pkin.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pkin.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pkin.Tpo -c -o libluatex_a-pkin.obj `if test -f 'luatexdir/font/pkin.c'; then $(CYGPATH_W) 'luatexdir/font/pkin.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/pkin.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pkin.Tpo $(DEPDIR)/libluatex_a-pkin.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/pkin.c' object='libluatex_a-pkin.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pkin.obj `if test -f 'luatexdir/font/pkin.c'; then $(CYGPATH_W) 'luatexdir/font/pkin.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/pkin.c'; fi` - -libluatex_a-sfnt.o: luatexdir/font/sfnt.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-sfnt.o -MD -MP -MF $(DEPDIR)/libluatex_a-sfnt.Tpo -c -o libluatex_a-sfnt.o `test -f 'luatexdir/font/sfnt.c' || echo '$(srcdir)/'`luatexdir/font/sfnt.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-sfnt.Tpo $(DEPDIR)/libluatex_a-sfnt.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/sfnt.c' object='libluatex_a-sfnt.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-sfnt.o `test -f 'luatexdir/font/sfnt.c' || echo '$(srcdir)/'`luatexdir/font/sfnt.c - -libluatex_a-sfnt.obj: luatexdir/font/sfnt.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-sfnt.obj -MD -MP -MF $(DEPDIR)/libluatex_a-sfnt.Tpo -c -o libluatex_a-sfnt.obj `if test -f 'luatexdir/font/sfnt.c'; then $(CYGPATH_W) 'luatexdir/font/sfnt.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/sfnt.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-sfnt.Tpo $(DEPDIR)/libluatex_a-sfnt.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/sfnt.c' object='libluatex_a-sfnt.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-sfnt.obj `if test -f 'luatexdir/font/sfnt.c'; then $(CYGPATH_W) 'luatexdir/font/sfnt.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/sfnt.c'; fi` - -libluatex_a-subfont.o: luatexdir/font/subfont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-subfont.o -MD -MP -MF $(DEPDIR)/libluatex_a-subfont.Tpo -c -o libluatex_a-subfont.o `test -f 'luatexdir/font/subfont.c' || echo '$(srcdir)/'`luatexdir/font/subfont.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-subfont.Tpo $(DEPDIR)/libluatex_a-subfont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/subfont.c' object='libluatex_a-subfont.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-subfont.o `test -f 'luatexdir/font/subfont.c' || echo '$(srcdir)/'`luatexdir/font/subfont.c - -libluatex_a-subfont.obj: luatexdir/font/subfont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-subfont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-subfont.Tpo -c -o libluatex_a-subfont.obj `if test -f 'luatexdir/font/subfont.c'; then $(CYGPATH_W) 'luatexdir/font/subfont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/subfont.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-subfont.Tpo $(DEPDIR)/libluatex_a-subfont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/subfont.c' object='libluatex_a-subfont.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-subfont.obj `if test -f 'luatexdir/font/subfont.c'; then $(CYGPATH_W) 'luatexdir/font/subfont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/subfont.c'; fi` - -libluatex_a-texfont.o: luatexdir/font/texfont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texfont.o -MD -MP -MF $(DEPDIR)/libluatex_a-texfont.Tpo -c -o libluatex_a-texfont.o `test -f 'luatexdir/font/texfont.c' || echo '$(srcdir)/'`luatexdir/font/texfont.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texfont.Tpo $(DEPDIR)/libluatex_a-texfont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/texfont.c' object='libluatex_a-texfont.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texfont.o `test -f 'luatexdir/font/texfont.c' || echo '$(srcdir)/'`luatexdir/font/texfont.c - -libluatex_a-texfont.obj: luatexdir/font/texfont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texfont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texfont.Tpo -c -o libluatex_a-texfont.obj `if test -f 'luatexdir/font/texfont.c'; then $(CYGPATH_W) 'luatexdir/font/texfont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/texfont.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texfont.Tpo $(DEPDIR)/libluatex_a-texfont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/texfont.c' object='libluatex_a-texfont.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texfont.obj `if test -f 'luatexdir/font/texfont.c'; then $(CYGPATH_W) 'luatexdir/font/texfont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/texfont.c'; fi` - -libluatex_a-tfmofm.o: luatexdir/font/tfmofm.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tfmofm.o -MD -MP -MF $(DEPDIR)/libluatex_a-tfmofm.Tpo -c -o libluatex_a-tfmofm.o `test -f 'luatexdir/font/tfmofm.c' || echo '$(srcdir)/'`luatexdir/font/tfmofm.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tfmofm.Tpo $(DEPDIR)/libluatex_a-tfmofm.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tfmofm.c' object='libluatex_a-tfmofm.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tfmofm.o `test -f 'luatexdir/font/tfmofm.c' || echo '$(srcdir)/'`luatexdir/font/tfmofm.c - -libluatex_a-tfmofm.obj: luatexdir/font/tfmofm.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tfmofm.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tfmofm.Tpo -c -o libluatex_a-tfmofm.obj `if test -f 'luatexdir/font/tfmofm.c'; then $(CYGPATH_W) 'luatexdir/font/tfmofm.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tfmofm.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tfmofm.Tpo $(DEPDIR)/libluatex_a-tfmofm.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tfmofm.c' object='libluatex_a-tfmofm.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tfmofm.obj `if test -f 'luatexdir/font/tfmofm.c'; then $(CYGPATH_W) 'luatexdir/font/tfmofm.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tfmofm.c'; fi` - -libluatex_a-tounicode.o: luatexdir/font/tounicode.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tounicode.o -MD -MP -MF $(DEPDIR)/libluatex_a-tounicode.Tpo -c -o libluatex_a-tounicode.o `test -f 'luatexdir/font/tounicode.c' || echo '$(srcdir)/'`luatexdir/font/tounicode.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tounicode.Tpo $(DEPDIR)/libluatex_a-tounicode.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tounicode.c' object='libluatex_a-tounicode.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tounicode.o `test -f 'luatexdir/font/tounicode.c' || echo '$(srcdir)/'`luatexdir/font/tounicode.c - -libluatex_a-tounicode.obj: luatexdir/font/tounicode.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tounicode.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tounicode.Tpo -c -o libluatex_a-tounicode.obj `if test -f 'luatexdir/font/tounicode.c'; then $(CYGPATH_W) 'luatexdir/font/tounicode.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tounicode.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tounicode.Tpo $(DEPDIR)/libluatex_a-tounicode.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tounicode.c' object='libluatex_a-tounicode.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tounicode.obj `if test -f 'luatexdir/font/tounicode.c'; then $(CYGPATH_W) 'luatexdir/font/tounicode.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tounicode.c'; fi` - -libluatex_a-tt_glyf.o: luatexdir/font/tt_glyf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_glyf.o -MD -MP -MF $(DEPDIR)/libluatex_a-tt_glyf.Tpo -c -o libluatex_a-tt_glyf.o `test -f 'luatexdir/font/tt_glyf.c' || echo '$(srcdir)/'`luatexdir/font/tt_glyf.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_glyf.Tpo $(DEPDIR)/libluatex_a-tt_glyf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tt_glyf.c' object='libluatex_a-tt_glyf.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_glyf.o `test -f 'luatexdir/font/tt_glyf.c' || echo '$(srcdir)/'`luatexdir/font/tt_glyf.c - -libluatex_a-tt_glyf.obj: luatexdir/font/tt_glyf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_glyf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tt_glyf.Tpo -c -o libluatex_a-tt_glyf.obj `if test -f 'luatexdir/font/tt_glyf.c'; then $(CYGPATH_W) 'luatexdir/font/tt_glyf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tt_glyf.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_glyf.Tpo $(DEPDIR)/libluatex_a-tt_glyf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tt_glyf.c' object='libluatex_a-tt_glyf.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_glyf.obj `if test -f 'luatexdir/font/tt_glyf.c'; then $(CYGPATH_W) 'luatexdir/font/tt_glyf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tt_glyf.c'; fi` - -libluatex_a-tt_table.o: luatexdir/font/tt_table.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_table.o -MD -MP -MF $(DEPDIR)/libluatex_a-tt_table.Tpo -c -o libluatex_a-tt_table.o `test -f 'luatexdir/font/tt_table.c' || echo '$(srcdir)/'`luatexdir/font/tt_table.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_table.Tpo $(DEPDIR)/libluatex_a-tt_table.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tt_table.c' object='libluatex_a-tt_table.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_table.o `test -f 'luatexdir/font/tt_table.c' || echo '$(srcdir)/'`luatexdir/font/tt_table.c - -libluatex_a-tt_table.obj: luatexdir/font/tt_table.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_table.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tt_table.Tpo -c -o libluatex_a-tt_table.obj `if test -f 'luatexdir/font/tt_table.c'; then $(CYGPATH_W) 'luatexdir/font/tt_table.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tt_table.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_table.Tpo $(DEPDIR)/libluatex_a-tt_table.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/tt_table.c' object='libluatex_a-tt_table.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_table.obj `if test -f 'luatexdir/font/tt_table.c'; then $(CYGPATH_W) 'luatexdir/font/tt_table.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/tt_table.c'; fi` - -libluatex_a-vfovf.o: luatexdir/font/vfovf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfovf.o -MD -MP -MF $(DEPDIR)/libluatex_a-vfovf.Tpo -c -o libluatex_a-vfovf.o `test -f 'luatexdir/font/vfovf.c' || echo '$(srcdir)/'`luatexdir/font/vfovf.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfovf.Tpo $(DEPDIR)/libluatex_a-vfovf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/vfovf.c' object='libluatex_a-vfovf.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfovf.o `test -f 'luatexdir/font/vfovf.c' || echo '$(srcdir)/'`luatexdir/font/vfovf.c - -libluatex_a-vfovf.obj: luatexdir/font/vfovf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfovf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-vfovf.Tpo -c -o libluatex_a-vfovf.obj `if test -f 'luatexdir/font/vfovf.c'; then $(CYGPATH_W) 'luatexdir/font/vfovf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/vfovf.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfovf.Tpo $(DEPDIR)/libluatex_a-vfovf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/vfovf.c' object='libluatex_a-vfovf.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfovf.obj `if test -f 'luatexdir/font/vfovf.c'; then $(CYGPATH_W) 'luatexdir/font/vfovf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/vfovf.c'; fi` - -libluatex_a-vfpacket.o: luatexdir/font/vfpacket.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfpacket.o -MD -MP -MF $(DEPDIR)/libluatex_a-vfpacket.Tpo -c -o libluatex_a-vfpacket.o `test -f 'luatexdir/font/vfpacket.c' || echo '$(srcdir)/'`luatexdir/font/vfpacket.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfpacket.Tpo $(DEPDIR)/libluatex_a-vfpacket.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/vfpacket.c' object='libluatex_a-vfpacket.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfpacket.o `test -f 'luatexdir/font/vfpacket.c' || echo '$(srcdir)/'`luatexdir/font/vfpacket.c - -libluatex_a-vfpacket.obj: luatexdir/font/vfpacket.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfpacket.obj -MD -MP -MF $(DEPDIR)/libluatex_a-vfpacket.Tpo -c -o libluatex_a-vfpacket.obj `if test -f 'luatexdir/font/vfpacket.c'; then $(CYGPATH_W) 'luatexdir/font/vfpacket.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/vfpacket.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfpacket.Tpo $(DEPDIR)/libluatex_a-vfpacket.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/vfpacket.c' object='libluatex_a-vfpacket.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfpacket.obj `if test -f 'luatexdir/font/vfpacket.c'; then $(CYGPATH_W) 'luatexdir/font/vfpacket.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/vfpacket.c'; fi` - -libluatex_a-writecff.o: luatexdir/font/writecff.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writecff.o -MD -MP -MF $(DEPDIR)/libluatex_a-writecff.Tpo -c -o libluatex_a-writecff.o `test -f 'luatexdir/font/writecff.c' || echo '$(srcdir)/'`luatexdir/font/writecff.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writecff.Tpo $(DEPDIR)/libluatex_a-writecff.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writecff.c' object='libluatex_a-writecff.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writecff.o `test -f 'luatexdir/font/writecff.c' || echo '$(srcdir)/'`luatexdir/font/writecff.c - -libluatex_a-writecff.obj: luatexdir/font/writecff.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writecff.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writecff.Tpo -c -o libluatex_a-writecff.obj `if test -f 'luatexdir/font/writecff.c'; then $(CYGPATH_W) 'luatexdir/font/writecff.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writecff.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writecff.Tpo $(DEPDIR)/libluatex_a-writecff.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writecff.c' object='libluatex_a-writecff.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writecff.obj `if test -f 'luatexdir/font/writecff.c'; then $(CYGPATH_W) 'luatexdir/font/writecff.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writecff.c'; fi` - -libluatex_a-writeenc.o: luatexdir/font/writeenc.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeenc.o -MD -MP -MF $(DEPDIR)/libluatex_a-writeenc.Tpo -c -o libluatex_a-writeenc.o `test -f 'luatexdir/font/writeenc.c' || echo '$(srcdir)/'`luatexdir/font/writeenc.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeenc.Tpo $(DEPDIR)/libluatex_a-writeenc.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writeenc.c' object='libluatex_a-writeenc.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeenc.o `test -f 'luatexdir/font/writeenc.c' || echo '$(srcdir)/'`luatexdir/font/writeenc.c - -libluatex_a-writeenc.obj: luatexdir/font/writeenc.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeenc.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writeenc.Tpo -c -o libluatex_a-writeenc.obj `if test -f 'luatexdir/font/writeenc.c'; then $(CYGPATH_W) 'luatexdir/font/writeenc.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writeenc.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeenc.Tpo $(DEPDIR)/libluatex_a-writeenc.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writeenc.c' object='libluatex_a-writeenc.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeenc.obj `if test -f 'luatexdir/font/writeenc.c'; then $(CYGPATH_W) 'luatexdir/font/writeenc.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writeenc.c'; fi` - -libluatex_a-writefont.o: luatexdir/font/writefont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writefont.o -MD -MP -MF $(DEPDIR)/libluatex_a-writefont.Tpo -c -o libluatex_a-writefont.o `test -f 'luatexdir/font/writefont.c' || echo '$(srcdir)/'`luatexdir/font/writefont.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writefont.Tpo $(DEPDIR)/libluatex_a-writefont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writefont.c' object='libluatex_a-writefont.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writefont.o `test -f 'luatexdir/font/writefont.c' || echo '$(srcdir)/'`luatexdir/font/writefont.c - -libluatex_a-writefont.obj: luatexdir/font/writefont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writefont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writefont.Tpo -c -o libluatex_a-writefont.obj `if test -f 'luatexdir/font/writefont.c'; then $(CYGPATH_W) 'luatexdir/font/writefont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writefont.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writefont.Tpo $(DEPDIR)/libluatex_a-writefont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writefont.c' object='libluatex_a-writefont.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writefont.obj `if test -f 'luatexdir/font/writefont.c'; then $(CYGPATH_W) 'luatexdir/font/writefont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writefont.c'; fi` - -libluatex_a-writet1.o: luatexdir/font/writet1.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet1.o -MD -MP -MF $(DEPDIR)/libluatex_a-writet1.Tpo -c -o libluatex_a-writet1.o `test -f 'luatexdir/font/writet1.c' || echo '$(srcdir)/'`luatexdir/font/writet1.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet1.Tpo $(DEPDIR)/libluatex_a-writet1.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writet1.c' object='libluatex_a-writet1.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet1.o `test -f 'luatexdir/font/writet1.c' || echo '$(srcdir)/'`luatexdir/font/writet1.c - -libluatex_a-writet1.obj: luatexdir/font/writet1.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet1.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writet1.Tpo -c -o libluatex_a-writet1.obj `if test -f 'luatexdir/font/writet1.c'; then $(CYGPATH_W) 'luatexdir/font/writet1.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writet1.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet1.Tpo $(DEPDIR)/libluatex_a-writet1.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writet1.c' object='libluatex_a-writet1.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet1.obj `if test -f 'luatexdir/font/writet1.c'; then $(CYGPATH_W) 'luatexdir/font/writet1.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writet1.c'; fi` - -libluatex_a-writet3.o: luatexdir/font/writet3.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet3.o -MD -MP -MF $(DEPDIR)/libluatex_a-writet3.Tpo -c -o libluatex_a-writet3.o `test -f 'luatexdir/font/writet3.c' || echo '$(srcdir)/'`luatexdir/font/writet3.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet3.Tpo $(DEPDIR)/libluatex_a-writet3.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writet3.c' object='libluatex_a-writet3.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet3.o `test -f 'luatexdir/font/writet3.c' || echo '$(srcdir)/'`luatexdir/font/writet3.c - -libluatex_a-writet3.obj: luatexdir/font/writet3.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet3.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writet3.Tpo -c -o libluatex_a-writet3.obj `if test -f 'luatexdir/font/writet3.c'; then $(CYGPATH_W) 'luatexdir/font/writet3.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writet3.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet3.Tpo $(DEPDIR)/libluatex_a-writet3.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writet3.c' object='libluatex_a-writet3.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet3.obj `if test -f 'luatexdir/font/writet3.c'; then $(CYGPATH_W) 'luatexdir/font/writet3.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writet3.c'; fi` - -libluatex_a-writettf.o: luatexdir/font/writettf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writettf.o -MD -MP -MF $(DEPDIR)/libluatex_a-writettf.Tpo -c -o libluatex_a-writettf.o `test -f 'luatexdir/font/writettf.c' || echo '$(srcdir)/'`luatexdir/font/writettf.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writettf.Tpo $(DEPDIR)/libluatex_a-writettf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writettf.c' object='libluatex_a-writettf.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writettf.o `test -f 'luatexdir/font/writettf.c' || echo '$(srcdir)/'`luatexdir/font/writettf.c - -libluatex_a-writettf.obj: luatexdir/font/writettf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writettf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writettf.Tpo -c -o libluatex_a-writettf.obj `if test -f 'luatexdir/font/writettf.c'; then $(CYGPATH_W) 'luatexdir/font/writettf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writettf.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writettf.Tpo $(DEPDIR)/libluatex_a-writettf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writettf.c' object='libluatex_a-writettf.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writettf.obj `if test -f 'luatexdir/font/writettf.c'; then $(CYGPATH_W) 'luatexdir/font/writettf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writettf.c'; fi` - -libluatex_a-writetype0.o: luatexdir/font/writetype0.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype0.o -MD -MP -MF $(DEPDIR)/libluatex_a-writetype0.Tpo -c -o libluatex_a-writetype0.o `test -f 'luatexdir/font/writetype0.c' || echo '$(srcdir)/'`luatexdir/font/writetype0.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype0.Tpo $(DEPDIR)/libluatex_a-writetype0.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writetype0.c' object='libluatex_a-writetype0.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype0.o `test -f 'luatexdir/font/writetype0.c' || echo '$(srcdir)/'`luatexdir/font/writetype0.c - -libluatex_a-writetype0.obj: luatexdir/font/writetype0.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype0.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writetype0.Tpo -c -o libluatex_a-writetype0.obj `if test -f 'luatexdir/font/writetype0.c'; then $(CYGPATH_W) 'luatexdir/font/writetype0.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writetype0.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype0.Tpo $(DEPDIR)/libluatex_a-writetype0.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writetype0.c' object='libluatex_a-writetype0.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype0.obj `if test -f 'luatexdir/font/writetype0.c'; then $(CYGPATH_W) 'luatexdir/font/writetype0.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writetype0.c'; fi` - -libluatex_a-writetype2.o: luatexdir/font/writetype2.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype2.o -MD -MP -MF $(DEPDIR)/libluatex_a-writetype2.Tpo -c -o libluatex_a-writetype2.o `test -f 'luatexdir/font/writetype2.c' || echo '$(srcdir)/'`luatexdir/font/writetype2.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype2.Tpo $(DEPDIR)/libluatex_a-writetype2.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writetype2.c' object='libluatex_a-writetype2.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype2.o `test -f 'luatexdir/font/writetype2.c' || echo '$(srcdir)/'`luatexdir/font/writetype2.c - -libluatex_a-writetype2.obj: luatexdir/font/writetype2.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype2.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writetype2.Tpo -c -o libluatex_a-writetype2.obj `if test -f 'luatexdir/font/writetype2.c'; then $(CYGPATH_W) 'luatexdir/font/writetype2.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writetype2.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype2.Tpo $(DEPDIR)/libluatex_a-writetype2.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/writetype2.c' object='libluatex_a-writetype2.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype2.obj `if test -f 'luatexdir/font/writetype2.c'; then $(CYGPATH_W) 'luatexdir/font/writetype2.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/writetype2.c'; fi` - -libluatex_a-epdf.o: luatexdir/image/epdf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-epdf.o -MD -MP -MF $(DEPDIR)/libluatex_a-epdf.Tpo -c -o libluatex_a-epdf.o `test -f 'luatexdir/image/epdf.c' || echo '$(srcdir)/'`luatexdir/image/epdf.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-epdf.Tpo $(DEPDIR)/libluatex_a-epdf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/epdf.c' object='libluatex_a-epdf.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-epdf.o `test -f 'luatexdir/image/epdf.c' || echo '$(srcdir)/'`luatexdir/image/epdf.c - -libluatex_a-epdf.obj: luatexdir/image/epdf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-epdf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-epdf.Tpo -c -o libluatex_a-epdf.obj `if test -f 'luatexdir/image/epdf.c'; then $(CYGPATH_W) 'luatexdir/image/epdf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/epdf.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-epdf.Tpo $(DEPDIR)/libluatex_a-epdf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/epdf.c' object='libluatex_a-epdf.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-epdf.obj `if test -f 'luatexdir/image/epdf.c'; then $(CYGPATH_W) 'luatexdir/image/epdf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/epdf.c'; fi` - -libluatex_a-writeimg.o: luatexdir/image/writeimg.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeimg.o -MD -MP -MF $(DEPDIR)/libluatex_a-writeimg.Tpo -c -o libluatex_a-writeimg.o `test -f 'luatexdir/image/writeimg.c' || echo '$(srcdir)/'`luatexdir/image/writeimg.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeimg.Tpo $(DEPDIR)/libluatex_a-writeimg.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writeimg.c' object='libluatex_a-writeimg.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeimg.o `test -f 'luatexdir/image/writeimg.c' || echo '$(srcdir)/'`luatexdir/image/writeimg.c - -libluatex_a-writeimg.obj: luatexdir/image/writeimg.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeimg.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writeimg.Tpo -c -o libluatex_a-writeimg.obj `if test -f 'luatexdir/image/writeimg.c'; then $(CYGPATH_W) 'luatexdir/image/writeimg.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writeimg.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeimg.Tpo $(DEPDIR)/libluatex_a-writeimg.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writeimg.c' object='libluatex_a-writeimg.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeimg.obj `if test -f 'luatexdir/image/writeimg.c'; then $(CYGPATH_W) 'luatexdir/image/writeimg.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writeimg.c'; fi` - -libluatex_a-writejbig2.o: luatexdir/image/writejbig2.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejbig2.o -MD -MP -MF $(DEPDIR)/libluatex_a-writejbig2.Tpo -c -o libluatex_a-writejbig2.o `test -f 'luatexdir/image/writejbig2.c' || echo '$(srcdir)/'`luatexdir/image/writejbig2.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejbig2.Tpo $(DEPDIR)/libluatex_a-writejbig2.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writejbig2.c' object='libluatex_a-writejbig2.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejbig2.o `test -f 'luatexdir/image/writejbig2.c' || echo '$(srcdir)/'`luatexdir/image/writejbig2.c - -libluatex_a-writejbig2.obj: luatexdir/image/writejbig2.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejbig2.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writejbig2.Tpo -c -o libluatex_a-writejbig2.obj `if test -f 'luatexdir/image/writejbig2.c'; then $(CYGPATH_W) 'luatexdir/image/writejbig2.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writejbig2.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejbig2.Tpo $(DEPDIR)/libluatex_a-writejbig2.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writejbig2.c' object='libluatex_a-writejbig2.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejbig2.obj `if test -f 'luatexdir/image/writejbig2.c'; then $(CYGPATH_W) 'luatexdir/image/writejbig2.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writejbig2.c'; fi` - -libluatex_a-writejpg.o: luatexdir/image/writejpg.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejpg.o -MD -MP -MF $(DEPDIR)/libluatex_a-writejpg.Tpo -c -o libluatex_a-writejpg.o `test -f 'luatexdir/image/writejpg.c' || echo '$(srcdir)/'`luatexdir/image/writejpg.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejpg.Tpo $(DEPDIR)/libluatex_a-writejpg.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writejpg.c' object='libluatex_a-writejpg.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejpg.o `test -f 'luatexdir/image/writejpg.c' || echo '$(srcdir)/'`luatexdir/image/writejpg.c - -libluatex_a-writejpg.obj: luatexdir/image/writejpg.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejpg.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writejpg.Tpo -c -o libluatex_a-writejpg.obj `if test -f 'luatexdir/image/writejpg.c'; then $(CYGPATH_W) 'luatexdir/image/writejpg.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writejpg.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejpg.Tpo $(DEPDIR)/libluatex_a-writejpg.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writejpg.c' object='libluatex_a-writejpg.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejpg.obj `if test -f 'luatexdir/image/writejpg.c'; then $(CYGPATH_W) 'luatexdir/image/writejpg.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writejpg.c'; fi` - -libluatex_a-writepng.o: luatexdir/image/writepng.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writepng.o -MD -MP -MF $(DEPDIR)/libluatex_a-writepng.Tpo -c -o libluatex_a-writepng.o `test -f 'luatexdir/image/writepng.c' || echo '$(srcdir)/'`luatexdir/image/writepng.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writepng.Tpo $(DEPDIR)/libluatex_a-writepng.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writepng.c' object='libluatex_a-writepng.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writepng.o `test -f 'luatexdir/image/writepng.c' || echo '$(srcdir)/'`luatexdir/image/writepng.c - -libluatex_a-writepng.obj: luatexdir/image/writepng.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writepng.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writepng.Tpo -c -o libluatex_a-writepng.obj `if test -f 'luatexdir/image/writepng.c'; then $(CYGPATH_W) 'luatexdir/image/writepng.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writepng.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writepng.Tpo $(DEPDIR)/libluatex_a-writepng.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/image/writepng.c' object='libluatex_a-writepng.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writepng.obj `if test -f 'luatexdir/image/writepng.c'; then $(CYGPATH_W) 'luatexdir/image/writepng.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/writepng.c'; fi` - -libluatex_a-hnjalloc.o: luatexdir/lang/hnjalloc.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hnjalloc.o -MD -MP -MF $(DEPDIR)/libluatex_a-hnjalloc.Tpo -c -o libluatex_a-hnjalloc.o `test -f 'luatexdir/lang/hnjalloc.c' || echo '$(srcdir)/'`luatexdir/lang/hnjalloc.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hnjalloc.Tpo $(DEPDIR)/libluatex_a-hnjalloc.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lang/hnjalloc.c' object='libluatex_a-hnjalloc.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hnjalloc.o `test -f 'luatexdir/lang/hnjalloc.c' || echo '$(srcdir)/'`luatexdir/lang/hnjalloc.c - -libluatex_a-hnjalloc.obj: luatexdir/lang/hnjalloc.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hnjalloc.obj -MD -MP -MF $(DEPDIR)/libluatex_a-hnjalloc.Tpo -c -o libluatex_a-hnjalloc.obj `if test -f 'luatexdir/lang/hnjalloc.c'; then $(CYGPATH_W) 'luatexdir/lang/hnjalloc.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lang/hnjalloc.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hnjalloc.Tpo $(DEPDIR)/libluatex_a-hnjalloc.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lang/hnjalloc.c' object='libluatex_a-hnjalloc.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hnjalloc.obj `if test -f 'luatexdir/lang/hnjalloc.c'; then $(CYGPATH_W) 'luatexdir/lang/hnjalloc.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lang/hnjalloc.c'; fi` - -libluatex_a-hyphen.o: luatexdir/lang/hyphen.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hyphen.o -MD -MP -MF $(DEPDIR)/libluatex_a-hyphen.Tpo -c -o libluatex_a-hyphen.o `test -f 'luatexdir/lang/hyphen.c' || echo '$(srcdir)/'`luatexdir/lang/hyphen.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hyphen.Tpo $(DEPDIR)/libluatex_a-hyphen.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lang/hyphen.c' object='libluatex_a-hyphen.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hyphen.o `test -f 'luatexdir/lang/hyphen.c' || echo '$(srcdir)/'`luatexdir/lang/hyphen.c - -libluatex_a-hyphen.obj: luatexdir/lang/hyphen.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hyphen.obj -MD -MP -MF $(DEPDIR)/libluatex_a-hyphen.Tpo -c -o libluatex_a-hyphen.obj `if test -f 'luatexdir/lang/hyphen.c'; then $(CYGPATH_W) 'luatexdir/lang/hyphen.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lang/hyphen.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hyphen.Tpo $(DEPDIR)/libluatex_a-hyphen.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lang/hyphen.c' object='libluatex_a-hyphen.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hyphen.obj `if test -f 'luatexdir/lang/hyphen.c'; then $(CYGPATH_W) 'luatexdir/lang/hyphen.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lang/hyphen.c'; fi` - -libluatex_a-texlang.o: luatexdir/lang/texlang.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texlang.o -MD -MP -MF $(DEPDIR)/libluatex_a-texlang.Tpo -c -o libluatex_a-texlang.o `test -f 'luatexdir/lang/texlang.c' || echo '$(srcdir)/'`luatexdir/lang/texlang.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texlang.Tpo $(DEPDIR)/libluatex_a-texlang.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lang/texlang.c' object='libluatex_a-texlang.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texlang.o `test -f 'luatexdir/lang/texlang.c' || echo '$(srcdir)/'`luatexdir/lang/texlang.c - -libluatex_a-texlang.obj: luatexdir/lang/texlang.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texlang.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texlang.Tpo -c -o libluatex_a-texlang.obj `if test -f 'luatexdir/lang/texlang.c'; then $(CYGPATH_W) 'luatexdir/lang/texlang.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lang/texlang.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texlang.Tpo $(DEPDIR)/libluatex_a-texlang.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lang/texlang.c' object='libluatex_a-texlang.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texlang.obj `if test -f 'luatexdir/lang/texlang.c'; then $(CYGPATH_W) 'luatexdir/lang/texlang.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lang/texlang.c'; fi` - libluatex_a-lcallbacklib.o: luatexdir/lua/lcallbacklib.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-lcallbacklib.o -MD -MP -MF $(DEPDIR)/libluatex_a-lcallbacklib.Tpo -c -o libluatex_a-lcallbacklib.o `test -f 'luatexdir/lua/lcallbacklib.c' || echo '$(srcdir)/'`luatexdir/lua/lcallbacklib.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-lcallbacklib.Tpo $(DEPDIR)/libluatex_a-lcallbacklib.Po @@ -5012,383 +4820,1391 @@ libluatex_a-ltokenlib.obj: luatexdir/lua/ltokenlib.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-ltokenlib.obj `if test -f 'luatexdir/lua/ltokenlib.c'; then $(CYGPATH_W) 'luatexdir/lua/ltokenlib.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/ltokenlib.c'; fi` -libluatex_a-luainit.o: luatexdir/lua/luainit.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luainit.o -MD -MP -MF $(DEPDIR)/libluatex_a-luainit.Tpo -c -o libluatex_a-luainit.o `test -f 'luatexdir/lua/luainit.c' || echo '$(srcdir)/'`luatexdir/lua/luainit.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luainit.Tpo $(DEPDIR)/libluatex_a-luainit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luainit.c' object='libluatex_a-luainit.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-avl.o: luatexdir/utils/avl.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avl.o -MD -MP -MF $(DEPDIR)/libluatex_a-avl.Tpo -c -o libluatex_a-avl.o `test -f 'luatexdir/utils/avl.c' || echo '$(srcdir)/'`luatexdir/utils/avl.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avl.Tpo $(DEPDIR)/libluatex_a-avl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/avl.c' object='libluatex_a-avl.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luainit.o `test -f 'luatexdir/lua/luainit.c' || echo '$(srcdir)/'`luatexdir/lua/luainit.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avl.o `test -f 'luatexdir/utils/avl.c' || echo '$(srcdir)/'`luatexdir/utils/avl.c -libluatex_a-luainit.obj: luatexdir/lua/luainit.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luainit.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luainit.Tpo -c -o libluatex_a-luainit.obj `if test -f 'luatexdir/lua/luainit.c'; then $(CYGPATH_W) 'luatexdir/lua/luainit.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luainit.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luainit.Tpo $(DEPDIR)/libluatex_a-luainit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luainit.c' object='libluatex_a-luainit.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-avl.obj: luatexdir/utils/avl.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avl.obj -MD -MP -MF $(DEPDIR)/libluatex_a-avl.Tpo -c -o libluatex_a-avl.obj `if test -f 'luatexdir/utils/avl.c'; then $(CYGPATH_W) 'luatexdir/utils/avl.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/avl.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avl.Tpo $(DEPDIR)/libluatex_a-avl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/avl.c' object='libluatex_a-avl.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luainit.obj `if test -f 'luatexdir/lua/luainit.c'; then $(CYGPATH_W) 'luatexdir/lua/luainit.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luainit.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avl.obj `if test -f 'luatexdir/utils/avl.c'; then $(CYGPATH_W) 'luatexdir/utils/avl.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/avl.c'; fi` -libluatex_a-luanode.o: luatexdir/lua/luanode.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luanode.o -MD -MP -MF $(DEPDIR)/libluatex_a-luanode.Tpo -c -o libluatex_a-luanode.o `test -f 'luatexdir/lua/luanode.c' || echo '$(srcdir)/'`luatexdir/lua/luanode.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luanode.Tpo $(DEPDIR)/libluatex_a-luanode.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luanode.c' object='libluatex_a-luanode.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-synctex.o: luatexdir/utils/synctex.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-synctex.o -MD -MP -MF $(DEPDIR)/libluatex_a-synctex.Tpo -c -o libluatex_a-synctex.o `test -f 'luatexdir/utils/synctex.c' || echo '$(srcdir)/'`luatexdir/utils/synctex.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-synctex.Tpo $(DEPDIR)/libluatex_a-synctex.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/synctex.c' object='libluatex_a-synctex.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luanode.o `test -f 'luatexdir/lua/luanode.c' || echo '$(srcdir)/'`luatexdir/lua/luanode.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-synctex.o `test -f 'luatexdir/utils/synctex.c' || echo '$(srcdir)/'`luatexdir/utils/synctex.c -libluatex_a-luanode.obj: luatexdir/lua/luanode.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luanode.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luanode.Tpo -c -o libluatex_a-luanode.obj `if test -f 'luatexdir/lua/luanode.c'; then $(CYGPATH_W) 'luatexdir/lua/luanode.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luanode.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luanode.Tpo $(DEPDIR)/libluatex_a-luanode.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luanode.c' object='libluatex_a-luanode.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-synctex.obj: luatexdir/utils/synctex.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-synctex.obj -MD -MP -MF $(DEPDIR)/libluatex_a-synctex.Tpo -c -o libluatex_a-synctex.obj `if test -f 'luatexdir/utils/synctex.c'; then $(CYGPATH_W) 'luatexdir/utils/synctex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/synctex.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-synctex.Tpo $(DEPDIR)/libluatex_a-synctex.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/synctex.c' object='libluatex_a-synctex.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luanode.obj `if test -f 'luatexdir/lua/luanode.c'; then $(CYGPATH_W) 'luatexdir/lua/luanode.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luanode.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-synctex.obj `if test -f 'luatexdir/utils/synctex.c'; then $(CYGPATH_W) 'luatexdir/utils/synctex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/synctex.c'; fi` -libluatex_a-luastuff.o: luatexdir/lua/luastuff.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luastuff.o -MD -MP -MF $(DEPDIR)/libluatex_a-luastuff.Tpo -c -o libluatex_a-luastuff.o `test -f 'luatexdir/lua/luastuff.c' || echo '$(srcdir)/'`luatexdir/lua/luastuff.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luastuff.Tpo $(DEPDIR)/libluatex_a-luastuff.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luastuff.c' object='libluatex_a-luastuff.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-dvigen.o: dvigen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dvigen.o -MD -MP -MF $(DEPDIR)/libluatex_a-dvigen.Tpo -c -o libluatex_a-dvigen.o `test -f 'dvigen.c' || echo '$(srcdir)/'`dvigen.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dvigen.Tpo $(DEPDIR)/libluatex_a-dvigen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dvigen.c' object='libluatex_a-dvigen.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luastuff.o `test -f 'luatexdir/lua/luastuff.c' || echo '$(srcdir)/'`luatexdir/lua/luastuff.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dvigen.o `test -f 'dvigen.c' || echo '$(srcdir)/'`dvigen.c -libluatex_a-luastuff.obj: luatexdir/lua/luastuff.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luastuff.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luastuff.Tpo -c -o libluatex_a-luastuff.obj `if test -f 'luatexdir/lua/luastuff.c'; then $(CYGPATH_W) 'luatexdir/lua/luastuff.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luastuff.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luastuff.Tpo $(DEPDIR)/libluatex_a-luastuff.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luastuff.c' object='libluatex_a-luastuff.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-dvigen.obj: dvigen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dvigen.obj -MD -MP -MF $(DEPDIR)/libluatex_a-dvigen.Tpo -c -o libluatex_a-dvigen.obj `if test -f 'dvigen.c'; then $(CYGPATH_W) 'dvigen.c'; else $(CYGPATH_W) '$(srcdir)/dvigen.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dvigen.Tpo $(DEPDIR)/libluatex_a-dvigen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dvigen.c' object='libluatex_a-dvigen.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luastuff.obj `if test -f 'luatexdir/lua/luastuff.c'; then $(CYGPATH_W) 'luatexdir/lua/luastuff.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luastuff.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dvigen.obj `if test -f 'dvigen.c'; then $(CYGPATH_W) 'dvigen.c'; else $(CYGPATH_W) '$(srcdir)/dvigen.c'; fi` -libluatex_a-luatex.o: luatexdir/lua/luatex.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luatex.o -MD -MP -MF $(DEPDIR)/libluatex_a-luatex.Tpo -c -o libluatex_a-luatex.o `test -f 'luatexdir/lua/luatex.c' || echo '$(srcdir)/'`luatexdir/lua/luatex.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luatex.Tpo $(DEPDIR)/libluatex_a-luatex.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luatex.c' object='libluatex_a-luatex.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-dofont.o: dofont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dofont.o -MD -MP -MF $(DEPDIR)/libluatex_a-dofont.Tpo -c -o libluatex_a-dofont.o `test -f 'dofont.c' || echo '$(srcdir)/'`dofont.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dofont.Tpo $(DEPDIR)/libluatex_a-dofont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dofont.c' object='libluatex_a-dofont.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luatex.o `test -f 'luatexdir/lua/luatex.c' || echo '$(srcdir)/'`luatexdir/lua/luatex.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dofont.o `test -f 'dofont.c' || echo '$(srcdir)/'`dofont.c -libluatex_a-luatex.obj: luatexdir/lua/luatex.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luatex.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luatex.Tpo -c -o libluatex_a-luatex.obj `if test -f 'luatexdir/lua/luatex.c'; then $(CYGPATH_W) 'luatexdir/lua/luatex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luatex.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luatex.Tpo $(DEPDIR)/libluatex_a-luatex.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luatex.c' object='libluatex_a-luatex.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-dofont.obj: dofont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dofont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-dofont.Tpo -c -o libluatex_a-dofont.obj `if test -f 'dofont.c'; then $(CYGPATH_W) 'dofont.c'; else $(CYGPATH_W) '$(srcdir)/dofont.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dofont.Tpo $(DEPDIR)/libluatex_a-dofont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dofont.c' object='libluatex_a-dofont.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luatex.obj `if test -f 'luatexdir/lua/luatex.c'; then $(CYGPATH_W) 'luatexdir/lua/luatex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luatex.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dofont.obj `if test -f 'dofont.c'; then $(CYGPATH_W) 'dofont.c'; else $(CYGPATH_W) '$(srcdir)/dofont.c'; fi` -libluatex_a-luatoken.o: luatexdir/lua/luatoken.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luatoken.o -MD -MP -MF $(DEPDIR)/libluatex_a-luatoken.Tpo -c -o libluatex_a-luatoken.o `test -f 'luatexdir/lua/luatoken.c' || echo '$(srcdir)/'`luatexdir/lua/luatoken.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luatoken.Tpo $(DEPDIR)/libluatex_a-luatoken.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luatoken.c' object='libluatex_a-luatoken.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-luafont.o: luafont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luafont.o -MD -MP -MF $(DEPDIR)/libluatex_a-luafont.Tpo -c -o libluatex_a-luafont.o `test -f 'luafont.c' || echo '$(srcdir)/'`luafont.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luafont.Tpo $(DEPDIR)/libluatex_a-luafont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luafont.c' object='libluatex_a-luafont.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luatoken.o `test -f 'luatexdir/lua/luatoken.c' || echo '$(srcdir)/'`luatexdir/lua/luatoken.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luafont.o `test -f 'luafont.c' || echo '$(srcdir)/'`luafont.c -libluatex_a-luatoken.obj: luatexdir/lua/luatoken.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luatoken.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luatoken.Tpo -c -o libluatex_a-luatoken.obj `if test -f 'luatexdir/lua/luatoken.c'; then $(CYGPATH_W) 'luatexdir/lua/luatoken.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luatoken.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luatoken.Tpo $(DEPDIR)/libluatex_a-luatoken.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/luatoken.c' object='libluatex_a-luatoken.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-luafont.obj: luafont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luafont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luafont.Tpo -c -o libluatex_a-luafont.obj `if test -f 'luafont.c'; then $(CYGPATH_W) 'luafont.c'; else $(CYGPATH_W) '$(srcdir)/luafont.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luafont.Tpo $(DEPDIR)/libluatex_a-luafont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luafont.c' object='libluatex_a-luafont.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luatoken.obj `if test -f 'luatexdir/lua/luatoken.c'; then $(CYGPATH_W) 'luatexdir/lua/luatoken.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/luatoken.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luafont.obj `if test -f 'luafont.c'; then $(CYGPATH_W) 'luafont.c'; else $(CYGPATH_W) '$(srcdir)/luafont.c'; fi` -libluatex_a-texluac.o: luatexdir/lua/texluac.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texluac.o -MD -MP -MF $(DEPDIR)/libluatex_a-texluac.Tpo -c -o libluatex_a-texluac.o `test -f 'luatexdir/lua/texluac.c' || echo '$(srcdir)/'`luatexdir/lua/texluac.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texluac.Tpo $(DEPDIR)/libluatex_a-texluac.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/texluac.c' object='libluatex_a-texluac.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-mapfile.o: mapfile.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mapfile.o -MD -MP -MF $(DEPDIR)/libluatex_a-mapfile.Tpo -c -o libluatex_a-mapfile.o `test -f 'mapfile.c' || echo '$(srcdir)/'`mapfile.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mapfile.Tpo $(DEPDIR)/libluatex_a-mapfile.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mapfile.c' object='libluatex_a-mapfile.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texluac.o `test -f 'luatexdir/lua/texluac.c' || echo '$(srcdir)/'`luatexdir/lua/texluac.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mapfile.o `test -f 'mapfile.c' || echo '$(srcdir)/'`mapfile.c -libluatex_a-texluac.obj: luatexdir/lua/texluac.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texluac.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texluac.Tpo -c -o libluatex_a-texluac.obj `if test -f 'luatexdir/lua/texluac.c'; then $(CYGPATH_W) 'luatexdir/lua/texluac.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/texluac.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texluac.Tpo $(DEPDIR)/libluatex_a-texluac.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/lua/texluac.c' object='libluatex_a-texluac.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-mapfile.obj: mapfile.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mapfile.obj -MD -MP -MF $(DEPDIR)/libluatex_a-mapfile.Tpo -c -o libluatex_a-mapfile.obj `if test -f 'mapfile.c'; then $(CYGPATH_W) 'mapfile.c'; else $(CYGPATH_W) '$(srcdir)/mapfile.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mapfile.Tpo $(DEPDIR)/libluatex_a-mapfile.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mapfile.c' object='libluatex_a-mapfile.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texluac.obj `if test -f 'luatexdir/lua/texluac.c'; then $(CYGPATH_W) 'luatexdir/lua/texluac.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/texluac.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mapfile.obj `if test -f 'mapfile.c'; then $(CYGPATH_W) 'mapfile.c'; else $(CYGPATH_W) '$(srcdir)/mapfile.c'; fi` -libluatex_a-makecpool.o: luatexdir/makecpool.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-makecpool.o -MD -MP -MF $(DEPDIR)/libluatex_a-makecpool.Tpo -c -o libluatex_a-makecpool.o `test -f 'luatexdir/makecpool.c' || echo '$(srcdir)/'`luatexdir/makecpool.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-makecpool.Tpo $(DEPDIR)/libluatex_a-makecpool.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/makecpool.c' object='libluatex_a-makecpool.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-pkin.o: pkin.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pkin.o -MD -MP -MF $(DEPDIR)/libluatex_a-pkin.Tpo -c -o libluatex_a-pkin.o `test -f 'pkin.c' || echo '$(srcdir)/'`pkin.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pkin.Tpo $(DEPDIR)/libluatex_a-pkin.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pkin.c' object='libluatex_a-pkin.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-makecpool.o `test -f 'luatexdir/makecpool.c' || echo '$(srcdir)/'`luatexdir/makecpool.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pkin.o `test -f 'pkin.c' || echo '$(srcdir)/'`pkin.c -libluatex_a-makecpool.obj: luatexdir/makecpool.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-makecpool.obj -MD -MP -MF $(DEPDIR)/libluatex_a-makecpool.Tpo -c -o libluatex_a-makecpool.obj `if test -f 'luatexdir/makecpool.c'; then $(CYGPATH_W) 'luatexdir/makecpool.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/makecpool.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-makecpool.Tpo $(DEPDIR)/libluatex_a-makecpool.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/makecpool.c' object='libluatex_a-makecpool.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-pkin.obj: pkin.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pkin.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pkin.Tpo -c -o libluatex_a-pkin.obj `if test -f 'pkin.c'; then $(CYGPATH_W) 'pkin.c'; else $(CYGPATH_W) '$(srcdir)/pkin.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pkin.Tpo $(DEPDIR)/libluatex_a-pkin.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pkin.c' object='libluatex_a-pkin.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-makecpool.obj `if test -f 'luatexdir/makecpool.c'; then $(CYGPATH_W) 'luatexdir/makecpool.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/makecpool.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pkin.obj `if test -f 'pkin.c'; then $(CYGPATH_W) 'pkin.c'; else $(CYGPATH_W) '$(srcdir)/pkin.c'; fi` -libluatex_a-managed-sa.o: luatexdir/managed-sa.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-managed-sa.o -MD -MP -MF $(DEPDIR)/libluatex_a-managed-sa.Tpo -c -o libluatex_a-managed-sa.o `test -f 'luatexdir/managed-sa.c' || echo '$(srcdir)/'`luatexdir/managed-sa.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-managed-sa.Tpo $(DEPDIR)/libluatex_a-managed-sa.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/managed-sa.c' object='libluatex_a-managed-sa.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-sfnt.o: sfnt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-sfnt.o -MD -MP -MF $(DEPDIR)/libluatex_a-sfnt.Tpo -c -o libluatex_a-sfnt.o `test -f 'sfnt.c' || echo '$(srcdir)/'`sfnt.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-sfnt.Tpo $(DEPDIR)/libluatex_a-sfnt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sfnt.c' object='libluatex_a-sfnt.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-managed-sa.o `test -f 'luatexdir/managed-sa.c' || echo '$(srcdir)/'`luatexdir/managed-sa.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-sfnt.o `test -f 'sfnt.c' || echo '$(srcdir)/'`sfnt.c -libluatex_a-managed-sa.obj: luatexdir/managed-sa.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-managed-sa.obj -MD -MP -MF $(DEPDIR)/libluatex_a-managed-sa.Tpo -c -o libluatex_a-managed-sa.obj `if test -f 'luatexdir/managed-sa.c'; then $(CYGPATH_W) 'luatexdir/managed-sa.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/managed-sa.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-managed-sa.Tpo $(DEPDIR)/libluatex_a-managed-sa.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/managed-sa.c' object='libluatex_a-managed-sa.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-sfnt.obj: sfnt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-sfnt.obj -MD -MP -MF $(DEPDIR)/libluatex_a-sfnt.Tpo -c -o libluatex_a-sfnt.obj `if test -f 'sfnt.c'; then $(CYGPATH_W) 'sfnt.c'; else $(CYGPATH_W) '$(srcdir)/sfnt.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-sfnt.Tpo $(DEPDIR)/libluatex_a-sfnt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sfnt.c' object='libluatex_a-sfnt.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-managed-sa.obj `if test -f 'luatexdir/managed-sa.c'; then $(CYGPATH_W) 'luatexdir/managed-sa.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/managed-sa.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-sfnt.obj `if test -f 'sfnt.c'; then $(CYGPATH_W) 'sfnt.c'; else $(CYGPATH_W) '$(srcdir)/sfnt.c'; fi` -libluatex_a-mathcodes.o: luatexdir/mathcodes.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mathcodes.o -MD -MP -MF $(DEPDIR)/libluatex_a-mathcodes.Tpo -c -o libluatex_a-mathcodes.o `test -f 'luatexdir/mathcodes.c' || echo '$(srcdir)/'`luatexdir/mathcodes.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mathcodes.Tpo $(DEPDIR)/libluatex_a-mathcodes.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/mathcodes.c' object='libluatex_a-mathcodes.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-subfont.o: subfont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-subfont.o -MD -MP -MF $(DEPDIR)/libluatex_a-subfont.Tpo -c -o libluatex_a-subfont.o `test -f 'subfont.c' || echo '$(srcdir)/'`subfont.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-subfont.Tpo $(DEPDIR)/libluatex_a-subfont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='subfont.c' object='libluatex_a-subfont.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mathcodes.o `test -f 'luatexdir/mathcodes.c' || echo '$(srcdir)/'`luatexdir/mathcodes.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-subfont.o `test -f 'subfont.c' || echo '$(srcdir)/'`subfont.c -libluatex_a-mathcodes.obj: luatexdir/mathcodes.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mathcodes.obj -MD -MP -MF $(DEPDIR)/libluatex_a-mathcodes.Tpo -c -o libluatex_a-mathcodes.obj `if test -f 'luatexdir/mathcodes.c'; then $(CYGPATH_W) 'luatexdir/mathcodes.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/mathcodes.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mathcodes.Tpo $(DEPDIR)/libluatex_a-mathcodes.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/mathcodes.c' object='libluatex_a-mathcodes.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-subfont.obj: subfont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-subfont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-subfont.Tpo -c -o libluatex_a-subfont.obj `if test -f 'subfont.c'; then $(CYGPATH_W) 'subfont.c'; else $(CYGPATH_W) '$(srcdir)/subfont.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-subfont.Tpo $(DEPDIR)/libluatex_a-subfont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='subfont.c' object='libluatex_a-subfont.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mathcodes.obj `if test -f 'luatexdir/mathcodes.c'; then $(CYGPATH_W) 'luatexdir/mathcodes.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/mathcodes.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-subfont.obj `if test -f 'subfont.c'; then $(CYGPATH_W) 'subfont.c'; else $(CYGPATH_W) '$(srcdir)/subfont.c'; fi` -libluatex_a-pagetree.o: luatexdir/pdf/pagetree.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pagetree.o -MD -MP -MF $(DEPDIR)/libluatex_a-pagetree.Tpo -c -o libluatex_a-pagetree.o `test -f 'luatexdir/pdf/pagetree.c' || echo '$(srcdir)/'`luatexdir/pdf/pagetree.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pagetree.Tpo $(DEPDIR)/libluatex_a-pagetree.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/pdf/pagetree.c' object='libluatex_a-pagetree.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-texfont.o: texfont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texfont.o -MD -MP -MF $(DEPDIR)/libluatex_a-texfont.Tpo -c -o libluatex_a-texfont.o `test -f 'texfont.c' || echo '$(srcdir)/'`texfont.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texfont.Tpo $(DEPDIR)/libluatex_a-texfont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texfont.c' object='libluatex_a-texfont.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pagetree.o `test -f 'luatexdir/pdf/pagetree.c' || echo '$(srcdir)/'`luatexdir/pdf/pagetree.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texfont.o `test -f 'texfont.c' || echo '$(srcdir)/'`texfont.c -libluatex_a-pagetree.obj: luatexdir/pdf/pagetree.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pagetree.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pagetree.Tpo -c -o libluatex_a-pagetree.obj `if test -f 'luatexdir/pdf/pagetree.c'; then $(CYGPATH_W) 'luatexdir/pdf/pagetree.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/pdf/pagetree.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pagetree.Tpo $(DEPDIR)/libluatex_a-pagetree.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/pdf/pagetree.c' object='libluatex_a-pagetree.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-texfont.obj: texfont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texfont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texfont.Tpo -c -o libluatex_a-texfont.obj `if test -f 'texfont.c'; then $(CYGPATH_W) 'texfont.c'; else $(CYGPATH_W) '$(srcdir)/texfont.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texfont.Tpo $(DEPDIR)/libluatex_a-texfont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texfont.c' object='libluatex_a-texfont.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pagetree.obj `if test -f 'luatexdir/pdf/pagetree.c'; then $(CYGPATH_W) 'luatexdir/pdf/pagetree.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/pdf/pagetree.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texfont.obj `if test -f 'texfont.c'; then $(CYGPATH_W) 'texfont.c'; else $(CYGPATH_W) '$(srcdir)/texfont.c'; fi` -libluatex_a-pdfpage.o: luatexdir/pdf/pdfpage.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfpage.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfpage.Tpo -c -o libluatex_a-pdfpage.o `test -f 'luatexdir/pdf/pdfpage.c' || echo '$(srcdir)/'`luatexdir/pdf/pdfpage.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfpage.Tpo $(DEPDIR)/libluatex_a-pdfpage.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/pdf/pdfpage.c' object='libluatex_a-pdfpage.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-tfmofm.o: tfmofm.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tfmofm.o -MD -MP -MF $(DEPDIR)/libluatex_a-tfmofm.Tpo -c -o libluatex_a-tfmofm.o `test -f 'tfmofm.c' || echo '$(srcdir)/'`tfmofm.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tfmofm.Tpo $(DEPDIR)/libluatex_a-tfmofm.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tfmofm.c' object='libluatex_a-tfmofm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfpage.o `test -f 'luatexdir/pdf/pdfpage.c' || echo '$(srcdir)/'`luatexdir/pdf/pdfpage.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tfmofm.o `test -f 'tfmofm.c' || echo '$(srcdir)/'`tfmofm.c -libluatex_a-pdfpage.obj: luatexdir/pdf/pdfpage.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfpage.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfpage.Tpo -c -o libluatex_a-pdfpage.obj `if test -f 'luatexdir/pdf/pdfpage.c'; then $(CYGPATH_W) 'luatexdir/pdf/pdfpage.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/pdf/pdfpage.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfpage.Tpo $(DEPDIR)/libluatex_a-pdfpage.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/pdf/pdfpage.c' object='libluatex_a-pdfpage.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-tfmofm.obj: tfmofm.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tfmofm.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tfmofm.Tpo -c -o libluatex_a-tfmofm.obj `if test -f 'tfmofm.c'; then $(CYGPATH_W) 'tfmofm.c'; else $(CYGPATH_W) '$(srcdir)/tfmofm.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tfmofm.Tpo $(DEPDIR)/libluatex_a-tfmofm.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tfmofm.c' object='libluatex_a-tfmofm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfpage.obj `if test -f 'luatexdir/pdf/pdfpage.c'; then $(CYGPATH_W) 'luatexdir/pdf/pdfpage.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/pdf/pdfpage.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tfmofm.obj `if test -f 'tfmofm.c'; then $(CYGPATH_W) 'tfmofm.c'; else $(CYGPATH_W) '$(srcdir)/tfmofm.c'; fi` -libluatex_a-filename.o: luatexdir/tex/filename.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-filename.o -MD -MP -MF $(DEPDIR)/libluatex_a-filename.Tpo -c -o libluatex_a-filename.o `test -f 'luatexdir/tex/filename.c' || echo '$(srcdir)/'`luatexdir/tex/filename.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-filename.Tpo $(DEPDIR)/libluatex_a-filename.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/filename.c' object='libluatex_a-filename.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-tounicode.o: tounicode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tounicode.o -MD -MP -MF $(DEPDIR)/libluatex_a-tounicode.Tpo -c -o libluatex_a-tounicode.o `test -f 'tounicode.c' || echo '$(srcdir)/'`tounicode.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tounicode.Tpo $(DEPDIR)/libluatex_a-tounicode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tounicode.c' object='libluatex_a-tounicode.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-filename.o `test -f 'luatexdir/tex/filename.c' || echo '$(srcdir)/'`luatexdir/tex/filename.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tounicode.o `test -f 'tounicode.c' || echo '$(srcdir)/'`tounicode.c -libluatex_a-filename.obj: luatexdir/tex/filename.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-filename.obj -MD -MP -MF $(DEPDIR)/libluatex_a-filename.Tpo -c -o libluatex_a-filename.obj `if test -f 'luatexdir/tex/filename.c'; then $(CYGPATH_W) 'luatexdir/tex/filename.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/filename.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-filename.Tpo $(DEPDIR)/libluatex_a-filename.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/filename.c' object='libluatex_a-filename.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-tounicode.obj: tounicode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tounicode.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tounicode.Tpo -c -o libluatex_a-tounicode.obj `if test -f 'tounicode.c'; then $(CYGPATH_W) 'tounicode.c'; else $(CYGPATH_W) '$(srcdir)/tounicode.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tounicode.Tpo $(DEPDIR)/libluatex_a-tounicode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tounicode.c' object='libluatex_a-tounicode.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-filename.obj `if test -f 'luatexdir/tex/filename.c'; then $(CYGPATH_W) 'luatexdir/tex/filename.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/filename.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tounicode.obj `if test -f 'tounicode.c'; then $(CYGPATH_W) 'tounicode.c'; else $(CYGPATH_W) '$(srcdir)/tounicode.c'; fi` -libluatex_a-linebreak.o: luatexdir/tex/linebreak.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-linebreak.o -MD -MP -MF $(DEPDIR)/libluatex_a-linebreak.Tpo -c -o libluatex_a-linebreak.o `test -f 'luatexdir/tex/linebreak.c' || echo '$(srcdir)/'`luatexdir/tex/linebreak.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-linebreak.Tpo $(DEPDIR)/libluatex_a-linebreak.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/linebreak.c' object='libluatex_a-linebreak.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-tt_glyf.o: tt_glyf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_glyf.o -MD -MP -MF $(DEPDIR)/libluatex_a-tt_glyf.Tpo -c -o libluatex_a-tt_glyf.o `test -f 'tt_glyf.c' || echo '$(srcdir)/'`tt_glyf.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_glyf.Tpo $(DEPDIR)/libluatex_a-tt_glyf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tt_glyf.c' object='libluatex_a-tt_glyf.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-linebreak.o `test -f 'luatexdir/tex/linebreak.c' || echo '$(srcdir)/'`luatexdir/tex/linebreak.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_glyf.o `test -f 'tt_glyf.c' || echo '$(srcdir)/'`tt_glyf.c -libluatex_a-linebreak.obj: luatexdir/tex/linebreak.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-linebreak.obj -MD -MP -MF $(DEPDIR)/libluatex_a-linebreak.Tpo -c -o libluatex_a-linebreak.obj `if test -f 'luatexdir/tex/linebreak.c'; then $(CYGPATH_W) 'luatexdir/tex/linebreak.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/linebreak.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-linebreak.Tpo $(DEPDIR)/libluatex_a-linebreak.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/linebreak.c' object='libluatex_a-linebreak.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-tt_glyf.obj: tt_glyf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_glyf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tt_glyf.Tpo -c -o libluatex_a-tt_glyf.obj `if test -f 'tt_glyf.c'; then $(CYGPATH_W) 'tt_glyf.c'; else $(CYGPATH_W) '$(srcdir)/tt_glyf.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_glyf.Tpo $(DEPDIR)/libluatex_a-tt_glyf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tt_glyf.c' object='libluatex_a-tt_glyf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_glyf.obj `if test -f 'tt_glyf.c'; then $(CYGPATH_W) 'tt_glyf.c'; else $(CYGPATH_W) '$(srcdir)/tt_glyf.c'; fi` + +libluatex_a-tt_table.o: tt_table.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_table.o -MD -MP -MF $(DEPDIR)/libluatex_a-tt_table.Tpo -c -o libluatex_a-tt_table.o `test -f 'tt_table.c' || echo '$(srcdir)/'`tt_table.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_table.Tpo $(DEPDIR)/libluatex_a-tt_table.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tt_table.c' object='libluatex_a-tt_table.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_table.o `test -f 'tt_table.c' || echo '$(srcdir)/'`tt_table.c + +libluatex_a-tt_table.obj: tt_table.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-tt_table.obj -MD -MP -MF $(DEPDIR)/libluatex_a-tt_table.Tpo -c -o libluatex_a-tt_table.obj `if test -f 'tt_table.c'; then $(CYGPATH_W) 'tt_table.c'; else $(CYGPATH_W) '$(srcdir)/tt_table.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-tt_table.Tpo $(DEPDIR)/libluatex_a-tt_table.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tt_table.c' object='libluatex_a-tt_table.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-tt_table.obj `if test -f 'tt_table.c'; then $(CYGPATH_W) 'tt_table.c'; else $(CYGPATH_W) '$(srcdir)/tt_table.c'; fi` + +libluatex_a-vfovf.o: vfovf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfovf.o -MD -MP -MF $(DEPDIR)/libluatex_a-vfovf.Tpo -c -o libluatex_a-vfovf.o `test -f 'vfovf.c' || echo '$(srcdir)/'`vfovf.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfovf.Tpo $(DEPDIR)/libluatex_a-vfovf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='vfovf.c' object='libluatex_a-vfovf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfovf.o `test -f 'vfovf.c' || echo '$(srcdir)/'`vfovf.c + +libluatex_a-vfovf.obj: vfovf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfovf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-vfovf.Tpo -c -o libluatex_a-vfovf.obj `if test -f 'vfovf.c'; then $(CYGPATH_W) 'vfovf.c'; else $(CYGPATH_W) '$(srcdir)/vfovf.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfovf.Tpo $(DEPDIR)/libluatex_a-vfovf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='vfovf.c' object='libluatex_a-vfovf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfovf.obj `if test -f 'vfovf.c'; then $(CYGPATH_W) 'vfovf.c'; else $(CYGPATH_W) '$(srcdir)/vfovf.c'; fi` + +libluatex_a-vfpacket.o: vfpacket.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfpacket.o -MD -MP -MF $(DEPDIR)/libluatex_a-vfpacket.Tpo -c -o libluatex_a-vfpacket.o `test -f 'vfpacket.c' || echo '$(srcdir)/'`vfpacket.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfpacket.Tpo $(DEPDIR)/libluatex_a-vfpacket.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='vfpacket.c' object='libluatex_a-vfpacket.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfpacket.o `test -f 'vfpacket.c' || echo '$(srcdir)/'`vfpacket.c + +libluatex_a-vfpacket.obj: vfpacket.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-vfpacket.obj -MD -MP -MF $(DEPDIR)/libluatex_a-vfpacket.Tpo -c -o libluatex_a-vfpacket.obj `if test -f 'vfpacket.c'; then $(CYGPATH_W) 'vfpacket.c'; else $(CYGPATH_W) '$(srcdir)/vfpacket.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-vfpacket.Tpo $(DEPDIR)/libluatex_a-vfpacket.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='vfpacket.c' object='libluatex_a-vfpacket.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-vfpacket.obj `if test -f 'vfpacket.c'; then $(CYGPATH_W) 'vfpacket.c'; else $(CYGPATH_W) '$(srcdir)/vfpacket.c'; fi` + +libluatex_a-writecff.o: writecff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writecff.o -MD -MP -MF $(DEPDIR)/libluatex_a-writecff.Tpo -c -o libluatex_a-writecff.o `test -f 'writecff.c' || echo '$(srcdir)/'`writecff.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writecff.Tpo $(DEPDIR)/libluatex_a-writecff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writecff.c' object='libluatex_a-writecff.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writecff.o `test -f 'writecff.c' || echo '$(srcdir)/'`writecff.c + +libluatex_a-writecff.obj: writecff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writecff.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writecff.Tpo -c -o libluatex_a-writecff.obj `if test -f 'writecff.c'; then $(CYGPATH_W) 'writecff.c'; else $(CYGPATH_W) '$(srcdir)/writecff.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writecff.Tpo $(DEPDIR)/libluatex_a-writecff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writecff.c' object='libluatex_a-writecff.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writecff.obj `if test -f 'writecff.c'; then $(CYGPATH_W) 'writecff.c'; else $(CYGPATH_W) '$(srcdir)/writecff.c'; fi` + +libluatex_a-writeenc.o: writeenc.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeenc.o -MD -MP -MF $(DEPDIR)/libluatex_a-writeenc.Tpo -c -o libluatex_a-writeenc.o `test -f 'writeenc.c' || echo '$(srcdir)/'`writeenc.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeenc.Tpo $(DEPDIR)/libluatex_a-writeenc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writeenc.c' object='libluatex_a-writeenc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeenc.o `test -f 'writeenc.c' || echo '$(srcdir)/'`writeenc.c + +libluatex_a-writeenc.obj: writeenc.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeenc.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writeenc.Tpo -c -o libluatex_a-writeenc.obj `if test -f 'writeenc.c'; then $(CYGPATH_W) 'writeenc.c'; else $(CYGPATH_W) '$(srcdir)/writeenc.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeenc.Tpo $(DEPDIR)/libluatex_a-writeenc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writeenc.c' object='libluatex_a-writeenc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeenc.obj `if test -f 'writeenc.c'; then $(CYGPATH_W) 'writeenc.c'; else $(CYGPATH_W) '$(srcdir)/writeenc.c'; fi` + +libluatex_a-writefont.o: writefont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writefont.o -MD -MP -MF $(DEPDIR)/libluatex_a-writefont.Tpo -c -o libluatex_a-writefont.o `test -f 'writefont.c' || echo '$(srcdir)/'`writefont.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writefont.Tpo $(DEPDIR)/libluatex_a-writefont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writefont.c' object='libluatex_a-writefont.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writefont.o `test -f 'writefont.c' || echo '$(srcdir)/'`writefont.c + +libluatex_a-writefont.obj: writefont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writefont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writefont.Tpo -c -o libluatex_a-writefont.obj `if test -f 'writefont.c'; then $(CYGPATH_W) 'writefont.c'; else $(CYGPATH_W) '$(srcdir)/writefont.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writefont.Tpo $(DEPDIR)/libluatex_a-writefont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writefont.c' object='libluatex_a-writefont.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writefont.obj `if test -f 'writefont.c'; then $(CYGPATH_W) 'writefont.c'; else $(CYGPATH_W) '$(srcdir)/writefont.c'; fi` + +libluatex_a-writet1.o: writet1.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet1.o -MD -MP -MF $(DEPDIR)/libluatex_a-writet1.Tpo -c -o libluatex_a-writet1.o `test -f 'writet1.c' || echo '$(srcdir)/'`writet1.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet1.Tpo $(DEPDIR)/libluatex_a-writet1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writet1.c' object='libluatex_a-writet1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet1.o `test -f 'writet1.c' || echo '$(srcdir)/'`writet1.c + +libluatex_a-writet1.obj: writet1.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet1.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writet1.Tpo -c -o libluatex_a-writet1.obj `if test -f 'writet1.c'; then $(CYGPATH_W) 'writet1.c'; else $(CYGPATH_W) '$(srcdir)/writet1.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet1.Tpo $(DEPDIR)/libluatex_a-writet1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writet1.c' object='libluatex_a-writet1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet1.obj `if test -f 'writet1.c'; then $(CYGPATH_W) 'writet1.c'; else $(CYGPATH_W) '$(srcdir)/writet1.c'; fi` + +libluatex_a-writet3.o: writet3.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet3.o -MD -MP -MF $(DEPDIR)/libluatex_a-writet3.Tpo -c -o libluatex_a-writet3.o `test -f 'writet3.c' || echo '$(srcdir)/'`writet3.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet3.Tpo $(DEPDIR)/libluatex_a-writet3.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writet3.c' object='libluatex_a-writet3.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet3.o `test -f 'writet3.c' || echo '$(srcdir)/'`writet3.c + +libluatex_a-writet3.obj: writet3.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writet3.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writet3.Tpo -c -o libluatex_a-writet3.obj `if test -f 'writet3.c'; then $(CYGPATH_W) 'writet3.c'; else $(CYGPATH_W) '$(srcdir)/writet3.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writet3.Tpo $(DEPDIR)/libluatex_a-writet3.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writet3.c' object='libluatex_a-writet3.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writet3.obj `if test -f 'writet3.c'; then $(CYGPATH_W) 'writet3.c'; else $(CYGPATH_W) '$(srcdir)/writet3.c'; fi` + +libluatex_a-writettf.o: writettf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writettf.o -MD -MP -MF $(DEPDIR)/libluatex_a-writettf.Tpo -c -o libluatex_a-writettf.o `test -f 'writettf.c' || echo '$(srcdir)/'`writettf.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writettf.Tpo $(DEPDIR)/libluatex_a-writettf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writettf.c' object='libluatex_a-writettf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writettf.o `test -f 'writettf.c' || echo '$(srcdir)/'`writettf.c + +libluatex_a-writettf.obj: writettf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writettf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writettf.Tpo -c -o libluatex_a-writettf.obj `if test -f 'writettf.c'; then $(CYGPATH_W) 'writettf.c'; else $(CYGPATH_W) '$(srcdir)/writettf.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writettf.Tpo $(DEPDIR)/libluatex_a-writettf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writettf.c' object='libluatex_a-writettf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writettf.obj `if test -f 'writettf.c'; then $(CYGPATH_W) 'writettf.c'; else $(CYGPATH_W) '$(srcdir)/writettf.c'; fi` + +libluatex_a-writetype0.o: writetype0.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype0.o -MD -MP -MF $(DEPDIR)/libluatex_a-writetype0.Tpo -c -o libluatex_a-writetype0.o `test -f 'writetype0.c' || echo '$(srcdir)/'`writetype0.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype0.Tpo $(DEPDIR)/libluatex_a-writetype0.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writetype0.c' object='libluatex_a-writetype0.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype0.o `test -f 'writetype0.c' || echo '$(srcdir)/'`writetype0.c + +libluatex_a-writetype0.obj: writetype0.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype0.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writetype0.Tpo -c -o libluatex_a-writetype0.obj `if test -f 'writetype0.c'; then $(CYGPATH_W) 'writetype0.c'; else $(CYGPATH_W) '$(srcdir)/writetype0.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype0.Tpo $(DEPDIR)/libluatex_a-writetype0.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writetype0.c' object='libluatex_a-writetype0.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype0.obj `if test -f 'writetype0.c'; then $(CYGPATH_W) 'writetype0.c'; else $(CYGPATH_W) '$(srcdir)/writetype0.c'; fi` + +libluatex_a-writetype2.o: writetype2.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype2.o -MD -MP -MF $(DEPDIR)/libluatex_a-writetype2.Tpo -c -o libluatex_a-writetype2.o `test -f 'writetype2.c' || echo '$(srcdir)/'`writetype2.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype2.Tpo $(DEPDIR)/libluatex_a-writetype2.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writetype2.c' object='libluatex_a-writetype2.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype2.o `test -f 'writetype2.c' || echo '$(srcdir)/'`writetype2.c + +libluatex_a-writetype2.obj: writetype2.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writetype2.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writetype2.Tpo -c -o libluatex_a-writetype2.obj `if test -f 'writetype2.c'; then $(CYGPATH_W) 'writetype2.c'; else $(CYGPATH_W) '$(srcdir)/writetype2.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writetype2.Tpo $(DEPDIR)/libluatex_a-writetype2.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writetype2.c' object='libluatex_a-writetype2.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writetype2.obj `if test -f 'writetype2.c'; then $(CYGPATH_W) 'writetype2.c'; else $(CYGPATH_W) '$(srcdir)/writetype2.c'; fi` + +libluatex_a-epdf.o: epdf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-epdf.o -MD -MP -MF $(DEPDIR)/libluatex_a-epdf.Tpo -c -o libluatex_a-epdf.o `test -f 'epdf.c' || echo '$(srcdir)/'`epdf.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-epdf.Tpo $(DEPDIR)/libluatex_a-epdf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='epdf.c' object='libluatex_a-epdf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-epdf.o `test -f 'epdf.c' || echo '$(srcdir)/'`epdf.c + +libluatex_a-epdf.obj: epdf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-epdf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-epdf.Tpo -c -o libluatex_a-epdf.obj `if test -f 'epdf.c'; then $(CYGPATH_W) 'epdf.c'; else $(CYGPATH_W) '$(srcdir)/epdf.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-epdf.Tpo $(DEPDIR)/libluatex_a-epdf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='epdf.c' object='libluatex_a-epdf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-epdf.obj `if test -f 'epdf.c'; then $(CYGPATH_W) 'epdf.c'; else $(CYGPATH_W) '$(srcdir)/epdf.c'; fi` + +libluatex_a-writeimg.o: writeimg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeimg.o -MD -MP -MF $(DEPDIR)/libluatex_a-writeimg.Tpo -c -o libluatex_a-writeimg.o `test -f 'writeimg.c' || echo '$(srcdir)/'`writeimg.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeimg.Tpo $(DEPDIR)/libluatex_a-writeimg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writeimg.c' object='libluatex_a-writeimg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeimg.o `test -f 'writeimg.c' || echo '$(srcdir)/'`writeimg.c + +libluatex_a-writeimg.obj: writeimg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writeimg.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writeimg.Tpo -c -o libluatex_a-writeimg.obj `if test -f 'writeimg.c'; then $(CYGPATH_W) 'writeimg.c'; else $(CYGPATH_W) '$(srcdir)/writeimg.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writeimg.Tpo $(DEPDIR)/libluatex_a-writeimg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writeimg.c' object='libluatex_a-writeimg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writeimg.obj `if test -f 'writeimg.c'; then $(CYGPATH_W) 'writeimg.c'; else $(CYGPATH_W) '$(srcdir)/writeimg.c'; fi` + +libluatex_a-writejbig2.o: writejbig2.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejbig2.o -MD -MP -MF $(DEPDIR)/libluatex_a-writejbig2.Tpo -c -o libluatex_a-writejbig2.o `test -f 'writejbig2.c' || echo '$(srcdir)/'`writejbig2.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejbig2.Tpo $(DEPDIR)/libluatex_a-writejbig2.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writejbig2.c' object='libluatex_a-writejbig2.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejbig2.o `test -f 'writejbig2.c' || echo '$(srcdir)/'`writejbig2.c + +libluatex_a-writejbig2.obj: writejbig2.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejbig2.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writejbig2.Tpo -c -o libluatex_a-writejbig2.obj `if test -f 'writejbig2.c'; then $(CYGPATH_W) 'writejbig2.c'; else $(CYGPATH_W) '$(srcdir)/writejbig2.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejbig2.Tpo $(DEPDIR)/libluatex_a-writejbig2.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writejbig2.c' object='libluatex_a-writejbig2.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejbig2.obj `if test -f 'writejbig2.c'; then $(CYGPATH_W) 'writejbig2.c'; else $(CYGPATH_W) '$(srcdir)/writejbig2.c'; fi` + +libluatex_a-writejpg.o: writejpg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejpg.o -MD -MP -MF $(DEPDIR)/libluatex_a-writejpg.Tpo -c -o libluatex_a-writejpg.o `test -f 'writejpg.c' || echo '$(srcdir)/'`writejpg.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejpg.Tpo $(DEPDIR)/libluatex_a-writejpg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writejpg.c' object='libluatex_a-writejpg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejpg.o `test -f 'writejpg.c' || echo '$(srcdir)/'`writejpg.c + +libluatex_a-writejpg.obj: writejpg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writejpg.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writejpg.Tpo -c -o libluatex_a-writejpg.obj `if test -f 'writejpg.c'; then $(CYGPATH_W) 'writejpg.c'; else $(CYGPATH_W) '$(srcdir)/writejpg.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writejpg.Tpo $(DEPDIR)/libluatex_a-writejpg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writejpg.c' object='libluatex_a-writejpg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writejpg.obj `if test -f 'writejpg.c'; then $(CYGPATH_W) 'writejpg.c'; else $(CYGPATH_W) '$(srcdir)/writejpg.c'; fi` + +libluatex_a-writepng.o: writepng.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writepng.o -MD -MP -MF $(DEPDIR)/libluatex_a-writepng.Tpo -c -o libluatex_a-writepng.o `test -f 'writepng.c' || echo '$(srcdir)/'`writepng.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writepng.Tpo $(DEPDIR)/libluatex_a-writepng.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writepng.c' object='libluatex_a-writepng.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writepng.o `test -f 'writepng.c' || echo '$(srcdir)/'`writepng.c + +libluatex_a-writepng.obj: writepng.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writepng.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writepng.Tpo -c -o libluatex_a-writepng.obj `if test -f 'writepng.c'; then $(CYGPATH_W) 'writepng.c'; else $(CYGPATH_W) '$(srcdir)/writepng.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writepng.Tpo $(DEPDIR)/libluatex_a-writepng.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='writepng.c' object='libluatex_a-writepng.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writepng.obj `if test -f 'writepng.c'; then $(CYGPATH_W) 'writepng.c'; else $(CYGPATH_W) '$(srcdir)/writepng.c'; fi` + +libluatex_a-luagen.o: luagen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luagen.o -MD -MP -MF $(DEPDIR)/libluatex_a-luagen.Tpo -c -o libluatex_a-luagen.o `test -f 'luagen.c' || echo '$(srcdir)/'`luagen.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luagen.Tpo $(DEPDIR)/libluatex_a-luagen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luagen.c' object='libluatex_a-luagen.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luagen.o `test -f 'luagen.c' || echo '$(srcdir)/'`luagen.c + +libluatex_a-luagen.obj: luagen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luagen.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luagen.Tpo -c -o libluatex_a-luagen.obj `if test -f 'luagen.c'; then $(CYGPATH_W) 'luagen.c'; else $(CYGPATH_W) '$(srcdir)/luagen.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luagen.Tpo $(DEPDIR)/libluatex_a-luagen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luagen.c' object='libluatex_a-luagen.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luagen.obj `if test -f 'luagen.c'; then $(CYGPATH_W) 'luagen.c'; else $(CYGPATH_W) '$(srcdir)/luagen.c'; fi` + +libluatex_a-luainit.o: luainit.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luainit.o -MD -MP -MF $(DEPDIR)/libluatex_a-luainit.Tpo -c -o libluatex_a-luainit.o `test -f 'luainit.c' || echo '$(srcdir)/'`luainit.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luainit.Tpo $(DEPDIR)/libluatex_a-luainit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luainit.c' object='libluatex_a-luainit.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luainit.o `test -f 'luainit.c' || echo '$(srcdir)/'`luainit.c + +libluatex_a-luainit.obj: luainit.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luainit.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luainit.Tpo -c -o libluatex_a-luainit.obj `if test -f 'luainit.c'; then $(CYGPATH_W) 'luainit.c'; else $(CYGPATH_W) '$(srcdir)/luainit.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luainit.Tpo $(DEPDIR)/libluatex_a-luainit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luainit.c' object='libluatex_a-luainit.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luainit.obj `if test -f 'luainit.c'; then $(CYGPATH_W) 'luainit.c'; else $(CYGPATH_W) '$(srcdir)/luainit.c'; fi` + +libluatex_a-luanode.o: luanode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luanode.o -MD -MP -MF $(DEPDIR)/libluatex_a-luanode.Tpo -c -o libluatex_a-luanode.o `test -f 'luanode.c' || echo '$(srcdir)/'`luanode.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luanode.Tpo $(DEPDIR)/libluatex_a-luanode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luanode.c' object='libluatex_a-luanode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luanode.o `test -f 'luanode.c' || echo '$(srcdir)/'`luanode.c + +libluatex_a-luanode.obj: luanode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luanode.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luanode.Tpo -c -o libluatex_a-luanode.obj `if test -f 'luanode.c'; then $(CYGPATH_W) 'luanode.c'; else $(CYGPATH_W) '$(srcdir)/luanode.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luanode.Tpo $(DEPDIR)/libluatex_a-luanode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luanode.c' object='libluatex_a-luanode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luanode.obj `if test -f 'luanode.c'; then $(CYGPATH_W) 'luanode.c'; else $(CYGPATH_W) '$(srcdir)/luanode.c'; fi` + +libluatex_a-luastuff.o: luastuff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luastuff.o -MD -MP -MF $(DEPDIR)/libluatex_a-luastuff.Tpo -c -o libluatex_a-luastuff.o `test -f 'luastuff.c' || echo '$(srcdir)/'`luastuff.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luastuff.Tpo $(DEPDIR)/libluatex_a-luastuff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luastuff.c' object='libluatex_a-luastuff.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luastuff.o `test -f 'luastuff.c' || echo '$(srcdir)/'`luastuff.c + +libluatex_a-luastuff.obj: luastuff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luastuff.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luastuff.Tpo -c -o libluatex_a-luastuff.obj `if test -f 'luastuff.c'; then $(CYGPATH_W) 'luastuff.c'; else $(CYGPATH_W) '$(srcdir)/luastuff.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luastuff.Tpo $(DEPDIR)/libluatex_a-luastuff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luastuff.c' object='libluatex_a-luastuff.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luastuff.obj `if test -f 'luastuff.c'; then $(CYGPATH_W) 'luastuff.c'; else $(CYGPATH_W) '$(srcdir)/luastuff.c'; fi` + +libluatex_a-luatoken.o: luatoken.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luatoken.o -MD -MP -MF $(DEPDIR)/libluatex_a-luatoken.Tpo -c -o libluatex_a-luatoken.o `test -f 'luatoken.c' || echo '$(srcdir)/'`luatoken.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luatoken.Tpo $(DEPDIR)/libluatex_a-luatoken.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatoken.c' object='libluatex_a-luatoken.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luatoken.o `test -f 'luatoken.c' || echo '$(srcdir)/'`luatoken.c + +libluatex_a-luatoken.obj: luatoken.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-luatoken.obj -MD -MP -MF $(DEPDIR)/libluatex_a-luatoken.Tpo -c -o libluatex_a-luatoken.obj `if test -f 'luatoken.c'; then $(CYGPATH_W) 'luatoken.c'; else $(CYGPATH_W) '$(srcdir)/luatoken.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-luatoken.Tpo $(DEPDIR)/libluatex_a-luatoken.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatoken.c' object='libluatex_a-luatoken.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-luatoken.obj `if test -f 'luatoken.c'; then $(CYGPATH_W) 'luatoken.c'; else $(CYGPATH_W) '$(srcdir)/luatoken.c'; fi` + +libluatex_a-texluac.o: texluac.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texluac.o -MD -MP -MF $(DEPDIR)/libluatex_a-texluac.Tpo -c -o libluatex_a-texluac.o `test -f 'texluac.c' || echo '$(srcdir)/'`texluac.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texluac.Tpo $(DEPDIR)/libluatex_a-texluac.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texluac.c' object='libluatex_a-texluac.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texluac.o `test -f 'texluac.c' || echo '$(srcdir)/'`texluac.c + +libluatex_a-texluac.obj: texluac.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texluac.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texluac.Tpo -c -o libluatex_a-texluac.obj `if test -f 'texluac.c'; then $(CYGPATH_W) 'texluac.c'; else $(CYGPATH_W) '$(srcdir)/texluac.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texluac.Tpo $(DEPDIR)/libluatex_a-texluac.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texluac.c' object='libluatex_a-texluac.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texluac.obj `if test -f 'texluac.c'; then $(CYGPATH_W) 'texluac.c'; else $(CYGPATH_W) '$(srcdir)/texluac.c'; fi` + +libluatex_a-ocp.o: ocp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-ocp.o -MD -MP -MF $(DEPDIR)/libluatex_a-ocp.Tpo -c -o libluatex_a-ocp.o `test -f 'ocp.c' || echo '$(srcdir)/'`ocp.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-ocp.Tpo $(DEPDIR)/libluatex_a-ocp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ocp.c' object='libluatex_a-ocp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-ocp.o `test -f 'ocp.c' || echo '$(srcdir)/'`ocp.c + +libluatex_a-ocp.obj: ocp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-ocp.obj -MD -MP -MF $(DEPDIR)/libluatex_a-ocp.Tpo -c -o libluatex_a-ocp.obj `if test -f 'ocp.c'; then $(CYGPATH_W) 'ocp.c'; else $(CYGPATH_W) '$(srcdir)/ocp.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-ocp.Tpo $(DEPDIR)/libluatex_a-ocp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ocp.c' object='libluatex_a-ocp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-ocp.obj `if test -f 'ocp.c'; then $(CYGPATH_W) 'ocp.c'; else $(CYGPATH_W) '$(srcdir)/ocp.c'; fi` + +libluatex_a-ocplist.o: ocplist.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-ocplist.o -MD -MP -MF $(DEPDIR)/libluatex_a-ocplist.Tpo -c -o libluatex_a-ocplist.o `test -f 'ocplist.c' || echo '$(srcdir)/'`ocplist.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-ocplist.Tpo $(DEPDIR)/libluatex_a-ocplist.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ocplist.c' object='libluatex_a-ocplist.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-ocplist.o `test -f 'ocplist.c' || echo '$(srcdir)/'`ocplist.c + +libluatex_a-ocplist.obj: ocplist.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-ocplist.obj -MD -MP -MF $(DEPDIR)/libluatex_a-ocplist.Tpo -c -o libluatex_a-ocplist.obj `if test -f 'ocplist.c'; then $(CYGPATH_W) 'ocplist.c'; else $(CYGPATH_W) '$(srcdir)/ocplist.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-ocplist.Tpo $(DEPDIR)/libluatex_a-ocplist.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ocplist.c' object='libluatex_a-ocplist.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-ocplist.obj `if test -f 'ocplist.c'; then $(CYGPATH_W) 'ocplist.c'; else $(CYGPATH_W) '$(srcdir)/ocplist.c'; fi` + +libluatex_a-readocp.o: readocp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-readocp.o -MD -MP -MF $(DEPDIR)/libluatex_a-readocp.Tpo -c -o libluatex_a-readocp.o `test -f 'readocp.c' || echo '$(srcdir)/'`readocp.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-readocp.Tpo $(DEPDIR)/libluatex_a-readocp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='readocp.c' object='libluatex_a-readocp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-readocp.o `test -f 'readocp.c' || echo '$(srcdir)/'`readocp.c + +libluatex_a-readocp.obj: readocp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-readocp.obj -MD -MP -MF $(DEPDIR)/libluatex_a-readocp.Tpo -c -o libluatex_a-readocp.obj `if test -f 'readocp.c'; then $(CYGPATH_W) 'readocp.c'; else $(CYGPATH_W) '$(srcdir)/readocp.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-readocp.Tpo $(DEPDIR)/libluatex_a-readocp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='readocp.c' object='libluatex_a-readocp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-readocp.obj `if test -f 'readocp.c'; then $(CYGPATH_W) 'readocp.c'; else $(CYGPATH_W) '$(srcdir)/readocp.c'; fi` + +libluatex_a-runocp.o: runocp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-runocp.o -MD -MP -MF $(DEPDIR)/libluatex_a-runocp.Tpo -c -o libluatex_a-runocp.o `test -f 'runocp.c' || echo '$(srcdir)/'`runocp.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-runocp.Tpo $(DEPDIR)/libluatex_a-runocp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runocp.c' object='libluatex_a-runocp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-runocp.o `test -f 'runocp.c' || echo '$(srcdir)/'`runocp.c + +libluatex_a-runocp.obj: runocp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-runocp.obj -MD -MP -MF $(DEPDIR)/libluatex_a-runocp.Tpo -c -o libluatex_a-runocp.obj `if test -f 'runocp.c'; then $(CYGPATH_W) 'runocp.c'; else $(CYGPATH_W) '$(srcdir)/runocp.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-runocp.Tpo $(DEPDIR)/libluatex_a-runocp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runocp.c' object='libluatex_a-runocp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-runocp.obj `if test -f 'runocp.c'; then $(CYGPATH_W) 'runocp.c'; else $(CYGPATH_W) '$(srcdir)/runocp.c'; fi` + +libluatex_a-texlang.o: texlang.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texlang.o -MD -MP -MF $(DEPDIR)/libluatex_a-texlang.Tpo -c -o libluatex_a-texlang.o `test -f 'texlang.c' || echo '$(srcdir)/'`texlang.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texlang.Tpo $(DEPDIR)/libluatex_a-texlang.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texlang.c' object='libluatex_a-texlang.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texlang.o `test -f 'texlang.c' || echo '$(srcdir)/'`texlang.c + +libluatex_a-texlang.obj: texlang.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texlang.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texlang.Tpo -c -o libluatex_a-texlang.obj `if test -f 'texlang.c'; then $(CYGPATH_W) 'texlang.c'; else $(CYGPATH_W) '$(srcdir)/texlang.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texlang.Tpo $(DEPDIR)/libluatex_a-texlang.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texlang.c' object='libluatex_a-texlang.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texlang.obj `if test -f 'texlang.c'; then $(CYGPATH_W) 'texlang.c'; else $(CYGPATH_W) '$(srcdir)/texlang.c'; fi` + +libluatex_a-hyphen.o: hyphen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hyphen.o -MD -MP -MF $(DEPDIR)/libluatex_a-hyphen.Tpo -c -o libluatex_a-hyphen.o `test -f 'hyphen.c' || echo '$(srcdir)/'`hyphen.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hyphen.Tpo $(DEPDIR)/libluatex_a-hyphen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='hyphen.c' object='libluatex_a-hyphen.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hyphen.o `test -f 'hyphen.c' || echo '$(srcdir)/'`hyphen.c + +libluatex_a-hyphen.obj: hyphen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hyphen.obj -MD -MP -MF $(DEPDIR)/libluatex_a-hyphen.Tpo -c -o libluatex_a-hyphen.obj `if test -f 'hyphen.c'; then $(CYGPATH_W) 'hyphen.c'; else $(CYGPATH_W) '$(srcdir)/hyphen.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hyphen.Tpo $(DEPDIR)/libluatex_a-hyphen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='hyphen.c' object='libluatex_a-hyphen.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hyphen.obj `if test -f 'hyphen.c'; then $(CYGPATH_W) 'hyphen.c'; else $(CYGPATH_W) '$(srcdir)/hyphen.c'; fi` + +libluatex_a-hnjalloc.o: hnjalloc.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hnjalloc.o -MD -MP -MF $(DEPDIR)/libluatex_a-hnjalloc.Tpo -c -o libluatex_a-hnjalloc.o `test -f 'hnjalloc.c' || echo '$(srcdir)/'`hnjalloc.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hnjalloc.Tpo $(DEPDIR)/libluatex_a-hnjalloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='hnjalloc.c' object='libluatex_a-hnjalloc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hnjalloc.o `test -f 'hnjalloc.c' || echo '$(srcdir)/'`hnjalloc.c + +libluatex_a-hnjalloc.obj: hnjalloc.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-hnjalloc.obj -MD -MP -MF $(DEPDIR)/libluatex_a-hnjalloc.Tpo -c -o libluatex_a-hnjalloc.obj `if test -f 'hnjalloc.c'; then $(CYGPATH_W) 'hnjalloc.c'; else $(CYGPATH_W) '$(srcdir)/hnjalloc.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-hnjalloc.Tpo $(DEPDIR)/libluatex_a-hnjalloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='hnjalloc.c' object='libluatex_a-hnjalloc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-hnjalloc.obj `if test -f 'hnjalloc.c'; then $(CYGPATH_W) 'hnjalloc.c'; else $(CYGPATH_W) '$(srcdir)/hnjalloc.c'; fi` + +libluatex_a-pagetree.o: pagetree.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pagetree.o -MD -MP -MF $(DEPDIR)/libluatex_a-pagetree.Tpo -c -o libluatex_a-pagetree.o `test -f 'pagetree.c' || echo '$(srcdir)/'`pagetree.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pagetree.Tpo $(DEPDIR)/libluatex_a-pagetree.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pagetree.c' object='libluatex_a-pagetree.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pagetree.o `test -f 'pagetree.c' || echo '$(srcdir)/'`pagetree.c + +libluatex_a-pagetree.obj: pagetree.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pagetree.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pagetree.Tpo -c -o libluatex_a-pagetree.obj `if test -f 'pagetree.c'; then $(CYGPATH_W) 'pagetree.c'; else $(CYGPATH_W) '$(srcdir)/pagetree.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pagetree.Tpo $(DEPDIR)/libluatex_a-pagetree.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pagetree.c' object='libluatex_a-pagetree.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pagetree.obj `if test -f 'pagetree.c'; then $(CYGPATH_W) 'pagetree.c'; else $(CYGPATH_W) '$(srcdir)/pagetree.c'; fi` + +libluatex_a-pdfaction.o: pdfaction.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfaction.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfaction.Tpo -c -o libluatex_a-pdfaction.o `test -f 'pdfaction.c' || echo '$(srcdir)/'`pdfaction.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfaction.Tpo $(DEPDIR)/libluatex_a-pdfaction.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfaction.c' object='libluatex_a-pdfaction.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfaction.o `test -f 'pdfaction.c' || echo '$(srcdir)/'`pdfaction.c + +libluatex_a-pdfaction.obj: pdfaction.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfaction.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfaction.Tpo -c -o libluatex_a-pdfaction.obj `if test -f 'pdfaction.c'; then $(CYGPATH_W) 'pdfaction.c'; else $(CYGPATH_W) '$(srcdir)/pdfaction.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfaction.Tpo $(DEPDIR)/libluatex_a-pdfaction.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfaction.c' object='libluatex_a-pdfaction.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfaction.obj `if test -f 'pdfaction.c'; then $(CYGPATH_W) 'pdfaction.c'; else $(CYGPATH_W) '$(srcdir)/pdfaction.c'; fi` + +libluatex_a-pdfannot.o: pdfannot.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfannot.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfannot.Tpo -c -o libluatex_a-pdfannot.o `test -f 'pdfannot.c' || echo '$(srcdir)/'`pdfannot.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfannot.Tpo $(DEPDIR)/libluatex_a-pdfannot.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfannot.c' object='libluatex_a-pdfannot.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfannot.o `test -f 'pdfannot.c' || echo '$(srcdir)/'`pdfannot.c + +libluatex_a-pdfannot.obj: pdfannot.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfannot.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfannot.Tpo -c -o libluatex_a-pdfannot.obj `if test -f 'pdfannot.c'; then $(CYGPATH_W) 'pdfannot.c'; else $(CYGPATH_W) '$(srcdir)/pdfannot.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfannot.Tpo $(DEPDIR)/libluatex_a-pdfannot.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfannot.c' object='libluatex_a-pdfannot.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfannot.obj `if test -f 'pdfannot.c'; then $(CYGPATH_W) 'pdfannot.c'; else $(CYGPATH_W) '$(srcdir)/pdfannot.c'; fi` + +libluatex_a-pdfcolorstack.o: pdfcolorstack.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfcolorstack.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfcolorstack.Tpo -c -o libluatex_a-pdfcolorstack.o `test -f 'pdfcolorstack.c' || echo '$(srcdir)/'`pdfcolorstack.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfcolorstack.Tpo $(DEPDIR)/libluatex_a-pdfcolorstack.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfcolorstack.c' object='libluatex_a-pdfcolorstack.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfcolorstack.o `test -f 'pdfcolorstack.c' || echo '$(srcdir)/'`pdfcolorstack.c + +libluatex_a-pdfcolorstack.obj: pdfcolorstack.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfcolorstack.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfcolorstack.Tpo -c -o libluatex_a-pdfcolorstack.obj `if test -f 'pdfcolorstack.c'; then $(CYGPATH_W) 'pdfcolorstack.c'; else $(CYGPATH_W) '$(srcdir)/pdfcolorstack.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfcolorstack.Tpo $(DEPDIR)/libluatex_a-pdfcolorstack.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfcolorstack.c' object='libluatex_a-pdfcolorstack.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfcolorstack.obj `if test -f 'pdfcolorstack.c'; then $(CYGPATH_W) 'pdfcolorstack.c'; else $(CYGPATH_W) '$(srcdir)/pdfcolorstack.c'; fi` + +libluatex_a-pdfdest.o: pdfdest.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfdest.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfdest.Tpo -c -o libluatex_a-pdfdest.o `test -f 'pdfdest.c' || echo '$(srcdir)/'`pdfdest.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfdest.Tpo $(DEPDIR)/libluatex_a-pdfdest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfdest.c' object='libluatex_a-pdfdest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfdest.o `test -f 'pdfdest.c' || echo '$(srcdir)/'`pdfdest.c + +libluatex_a-pdfdest.obj: pdfdest.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfdest.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfdest.Tpo -c -o libluatex_a-pdfdest.obj `if test -f 'pdfdest.c'; then $(CYGPATH_W) 'pdfdest.c'; else $(CYGPATH_W) '$(srcdir)/pdfdest.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfdest.Tpo $(DEPDIR)/libluatex_a-pdfdest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfdest.c' object='libluatex_a-pdfdest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfdest.obj `if test -f 'pdfdest.c'; then $(CYGPATH_W) 'pdfdest.c'; else $(CYGPATH_W) '$(srcdir)/pdfdest.c'; fi` + +libluatex_a-pdffont.o: pdffont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdffont.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdffont.Tpo -c -o libluatex_a-pdffont.o `test -f 'pdffont.c' || echo '$(srcdir)/'`pdffont.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdffont.Tpo $(DEPDIR)/libluatex_a-pdffont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdffont.c' object='libluatex_a-pdffont.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdffont.o `test -f 'pdffont.c' || echo '$(srcdir)/'`pdffont.c + +libluatex_a-pdffont.obj: pdffont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdffont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdffont.Tpo -c -o libluatex_a-pdffont.obj `if test -f 'pdffont.c'; then $(CYGPATH_W) 'pdffont.c'; else $(CYGPATH_W) '$(srcdir)/pdffont.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdffont.Tpo $(DEPDIR)/libluatex_a-pdffont.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdffont.c' object='libluatex_a-pdffont.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdffont.obj `if test -f 'pdffont.c'; then $(CYGPATH_W) 'pdffont.c'; else $(CYGPATH_W) '$(srcdir)/pdffont.c'; fi` + +libluatex_a-pdfgen.o: pdfgen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfgen.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfgen.Tpo -c -o libluatex_a-pdfgen.o `test -f 'pdfgen.c' || echo '$(srcdir)/'`pdfgen.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfgen.Tpo $(DEPDIR)/libluatex_a-pdfgen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfgen.c' object='libluatex_a-pdfgen.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfgen.o `test -f 'pdfgen.c' || echo '$(srcdir)/'`pdfgen.c + +libluatex_a-pdfgen.obj: pdfgen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfgen.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfgen.Tpo -c -o libluatex_a-pdfgen.obj `if test -f 'pdfgen.c'; then $(CYGPATH_W) 'pdfgen.c'; else $(CYGPATH_W) '$(srcdir)/pdfgen.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfgen.Tpo $(DEPDIR)/libluatex_a-pdfgen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfgen.c' object='libluatex_a-pdfgen.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfgen.obj `if test -f 'pdfgen.c'; then $(CYGPATH_W) 'pdfgen.c'; else $(CYGPATH_W) '$(srcdir)/pdfgen.c'; fi` + +libluatex_a-pdfglyph.o: pdfglyph.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfglyph.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfglyph.Tpo -c -o libluatex_a-pdfglyph.o `test -f 'pdfglyph.c' || echo '$(srcdir)/'`pdfglyph.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfglyph.Tpo $(DEPDIR)/libluatex_a-pdfglyph.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfglyph.c' object='libluatex_a-pdfglyph.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfglyph.o `test -f 'pdfglyph.c' || echo '$(srcdir)/'`pdfglyph.c + +libluatex_a-pdfglyph.obj: pdfglyph.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfglyph.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfglyph.Tpo -c -o libluatex_a-pdfglyph.obj `if test -f 'pdfglyph.c'; then $(CYGPATH_W) 'pdfglyph.c'; else $(CYGPATH_W) '$(srcdir)/pdfglyph.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfglyph.Tpo $(DEPDIR)/libluatex_a-pdfglyph.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfglyph.c' object='libluatex_a-pdfglyph.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfglyph.obj `if test -f 'pdfglyph.c'; then $(CYGPATH_W) 'pdfglyph.c'; else $(CYGPATH_W) '$(srcdir)/pdfglyph.c'; fi` + +libluatex_a-pdfimage.o: pdfimage.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfimage.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfimage.Tpo -c -o libluatex_a-pdfimage.o `test -f 'pdfimage.c' || echo '$(srcdir)/'`pdfimage.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfimage.Tpo $(DEPDIR)/libluatex_a-pdfimage.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfimage.c' object='libluatex_a-pdfimage.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfimage.o `test -f 'pdfimage.c' || echo '$(srcdir)/'`pdfimage.c + +libluatex_a-pdfimage.obj: pdfimage.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfimage.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfimage.Tpo -c -o libluatex_a-pdfimage.obj `if test -f 'pdfimage.c'; then $(CYGPATH_W) 'pdfimage.c'; else $(CYGPATH_W) '$(srcdir)/pdfimage.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfimage.Tpo $(DEPDIR)/libluatex_a-pdfimage.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfimage.c' object='libluatex_a-pdfimage.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfimage.obj `if test -f 'pdfimage.c'; then $(CYGPATH_W) 'pdfimage.c'; else $(CYGPATH_W) '$(srcdir)/pdfimage.c'; fi` + +libluatex_a-pdflink.o: pdflink.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdflink.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdflink.Tpo -c -o libluatex_a-pdflink.o `test -f 'pdflink.c' || echo '$(srcdir)/'`pdflink.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdflink.Tpo $(DEPDIR)/libluatex_a-pdflink.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdflink.c' object='libluatex_a-pdflink.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdflink.o `test -f 'pdflink.c' || echo '$(srcdir)/'`pdflink.c + +libluatex_a-pdflink.obj: pdflink.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdflink.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdflink.Tpo -c -o libluatex_a-pdflink.obj `if test -f 'pdflink.c'; then $(CYGPATH_W) 'pdflink.c'; else $(CYGPATH_W) '$(srcdir)/pdflink.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdflink.Tpo $(DEPDIR)/libluatex_a-pdflink.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdflink.c' object='libluatex_a-pdflink.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdflink.obj `if test -f 'pdflink.c'; then $(CYGPATH_W) 'pdflink.c'; else $(CYGPATH_W) '$(srcdir)/pdflink.c'; fi` + +libluatex_a-pdflistout.o: pdflistout.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdflistout.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdflistout.Tpo -c -o libluatex_a-pdflistout.o `test -f 'pdflistout.c' || echo '$(srcdir)/'`pdflistout.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdflistout.Tpo $(DEPDIR)/libluatex_a-pdflistout.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdflistout.c' object='libluatex_a-pdflistout.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdflistout.o `test -f 'pdflistout.c' || echo '$(srcdir)/'`pdflistout.c + +libluatex_a-pdflistout.obj: pdflistout.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdflistout.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdflistout.Tpo -c -o libluatex_a-pdflistout.obj `if test -f 'pdflistout.c'; then $(CYGPATH_W) 'pdflistout.c'; else $(CYGPATH_W) '$(srcdir)/pdflistout.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdflistout.Tpo $(DEPDIR)/libluatex_a-pdflistout.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdflistout.c' object='libluatex_a-pdflistout.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdflistout.obj `if test -f 'pdflistout.c'; then $(CYGPATH_W) 'pdflistout.c'; else $(CYGPATH_W) '$(srcdir)/pdflistout.c'; fi` + +libluatex_a-pdfliteral.o: pdfliteral.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfliteral.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfliteral.Tpo -c -o libluatex_a-pdfliteral.o `test -f 'pdfliteral.c' || echo '$(srcdir)/'`pdfliteral.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfliteral.Tpo $(DEPDIR)/libluatex_a-pdfliteral.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfliteral.c' object='libluatex_a-pdfliteral.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfliteral.o `test -f 'pdfliteral.c' || echo '$(srcdir)/'`pdfliteral.c + +libluatex_a-pdfliteral.obj: pdfliteral.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfliteral.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfliteral.Tpo -c -o libluatex_a-pdfliteral.obj `if test -f 'pdfliteral.c'; then $(CYGPATH_W) 'pdfliteral.c'; else $(CYGPATH_W) '$(srcdir)/pdfliteral.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfliteral.Tpo $(DEPDIR)/libluatex_a-pdfliteral.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfliteral.c' object='libluatex_a-pdfliteral.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfliteral.obj `if test -f 'pdfliteral.c'; then $(CYGPATH_W) 'pdfliteral.c'; else $(CYGPATH_W) '$(srcdir)/pdfliteral.c'; fi` + +libluatex_a-pdfobj.o: pdfobj.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfobj.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfobj.Tpo -c -o libluatex_a-pdfobj.o `test -f 'pdfobj.c' || echo '$(srcdir)/'`pdfobj.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfobj.Tpo $(DEPDIR)/libluatex_a-pdfobj.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfobj.c' object='libluatex_a-pdfobj.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfobj.o `test -f 'pdfobj.c' || echo '$(srcdir)/'`pdfobj.c + +libluatex_a-pdfobj.obj: pdfobj.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfobj.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfobj.Tpo -c -o libluatex_a-pdfobj.obj `if test -f 'pdfobj.c'; then $(CYGPATH_W) 'pdfobj.c'; else $(CYGPATH_W) '$(srcdir)/pdfobj.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfobj.Tpo $(DEPDIR)/libluatex_a-pdfobj.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfobj.c' object='libluatex_a-pdfobj.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfobj.obj `if test -f 'pdfobj.c'; then $(CYGPATH_W) 'pdfobj.c'; else $(CYGPATH_W) '$(srcdir)/pdfobj.c'; fi` + +libluatex_a-pdfoutline.o: pdfoutline.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfoutline.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfoutline.Tpo -c -o libluatex_a-pdfoutline.o `test -f 'pdfoutline.c' || echo '$(srcdir)/'`pdfoutline.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfoutline.Tpo $(DEPDIR)/libluatex_a-pdfoutline.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfoutline.c' object='libluatex_a-pdfoutline.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-linebreak.obj `if test -f 'luatexdir/tex/linebreak.c'; then $(CYGPATH_W) 'luatexdir/tex/linebreak.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/linebreak.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfoutline.o `test -f 'pdfoutline.c' || echo '$(srcdir)/'`pdfoutline.c -libluatex_a-math.o: luatexdir/tex/math.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-math.o -MD -MP -MF $(DEPDIR)/libluatex_a-math.Tpo -c -o libluatex_a-math.o `test -f 'luatexdir/tex/math.c' || echo '$(srcdir)/'`luatexdir/tex/math.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-math.Tpo $(DEPDIR)/libluatex_a-math.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/math.c' object='libluatex_a-math.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-pdfoutline.obj: pdfoutline.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfoutline.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfoutline.Tpo -c -o libluatex_a-pdfoutline.obj `if test -f 'pdfoutline.c'; then $(CYGPATH_W) 'pdfoutline.c'; else $(CYGPATH_W) '$(srcdir)/pdfoutline.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfoutline.Tpo $(DEPDIR)/libluatex_a-pdfoutline.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfoutline.c' object='libluatex_a-pdfoutline.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-math.o `test -f 'luatexdir/tex/math.c' || echo '$(srcdir)/'`luatexdir/tex/math.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfoutline.obj `if test -f 'pdfoutline.c'; then $(CYGPATH_W) 'pdfoutline.c'; else $(CYGPATH_W) '$(srcdir)/pdfoutline.c'; fi` -libluatex_a-math.obj: luatexdir/tex/math.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-math.obj -MD -MP -MF $(DEPDIR)/libluatex_a-math.Tpo -c -o libluatex_a-math.obj `if test -f 'luatexdir/tex/math.c'; then $(CYGPATH_W) 'luatexdir/tex/math.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/math.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-math.Tpo $(DEPDIR)/libluatex_a-math.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/math.c' object='libluatex_a-math.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-pdfpage.o: pdfpage.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfpage.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfpage.Tpo -c -o libluatex_a-pdfpage.o `test -f 'pdfpage.c' || echo '$(srcdir)/'`pdfpage.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfpage.Tpo $(DEPDIR)/libluatex_a-pdfpage.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfpage.c' object='libluatex_a-pdfpage.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfpage.o `test -f 'pdfpage.c' || echo '$(srcdir)/'`pdfpage.c + +libluatex_a-pdfpage.obj: pdfpage.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfpage.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfpage.Tpo -c -o libluatex_a-pdfpage.obj `if test -f 'pdfpage.c'; then $(CYGPATH_W) 'pdfpage.c'; else $(CYGPATH_W) '$(srcdir)/pdfpage.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfpage.Tpo $(DEPDIR)/libluatex_a-pdfpage.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfpage.c' object='libluatex_a-pdfpage.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfpage.obj `if test -f 'pdfpage.c'; then $(CYGPATH_W) 'pdfpage.c'; else $(CYGPATH_W) '$(srcdir)/pdfpage.c'; fi` + +libluatex_a-pdfrule.o: pdfrule.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfrule.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfrule.Tpo -c -o libluatex_a-pdfrule.o `test -f 'pdfrule.c' || echo '$(srcdir)/'`pdfrule.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfrule.Tpo $(DEPDIR)/libluatex_a-pdfrule.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfrule.c' object='libluatex_a-pdfrule.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfrule.o `test -f 'pdfrule.c' || echo '$(srcdir)/'`pdfrule.c + +libluatex_a-pdfrule.obj: pdfrule.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfrule.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfrule.Tpo -c -o libluatex_a-pdfrule.obj `if test -f 'pdfrule.c'; then $(CYGPATH_W) 'pdfrule.c'; else $(CYGPATH_W) '$(srcdir)/pdfrule.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfrule.Tpo $(DEPDIR)/libluatex_a-pdfrule.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfrule.c' object='libluatex_a-pdfrule.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfrule.obj `if test -f 'pdfrule.c'; then $(CYGPATH_W) 'pdfrule.c'; else $(CYGPATH_W) '$(srcdir)/pdfrule.c'; fi` + +libluatex_a-pdfsaverestore.o: pdfsaverestore.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfsaverestore.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfsaverestore.Tpo -c -o libluatex_a-pdfsaverestore.o `test -f 'pdfsaverestore.c' || echo '$(srcdir)/'`pdfsaverestore.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfsaverestore.Tpo $(DEPDIR)/libluatex_a-pdfsaverestore.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfsaverestore.c' object='libluatex_a-pdfsaverestore.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfsaverestore.o `test -f 'pdfsaverestore.c' || echo '$(srcdir)/'`pdfsaverestore.c + +libluatex_a-pdfsaverestore.obj: pdfsaverestore.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfsaverestore.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfsaverestore.Tpo -c -o libluatex_a-pdfsaverestore.obj `if test -f 'pdfsaverestore.c'; then $(CYGPATH_W) 'pdfsaverestore.c'; else $(CYGPATH_W) '$(srcdir)/pdfsaverestore.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfsaverestore.Tpo $(DEPDIR)/libluatex_a-pdfsaverestore.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfsaverestore.c' object='libluatex_a-pdfsaverestore.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfsaverestore.obj `if test -f 'pdfsaverestore.c'; then $(CYGPATH_W) 'pdfsaverestore.c'; else $(CYGPATH_W) '$(srcdir)/pdfsaverestore.c'; fi` + +libluatex_a-pdfsetmatrix.o: pdfsetmatrix.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfsetmatrix.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfsetmatrix.Tpo -c -o libluatex_a-pdfsetmatrix.o `test -f 'pdfsetmatrix.c' || echo '$(srcdir)/'`pdfsetmatrix.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfsetmatrix.Tpo $(DEPDIR)/libluatex_a-pdfsetmatrix.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfsetmatrix.c' object='libluatex_a-pdfsetmatrix.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfsetmatrix.o `test -f 'pdfsetmatrix.c' || echo '$(srcdir)/'`pdfsetmatrix.c + +libluatex_a-pdfsetmatrix.obj: pdfsetmatrix.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfsetmatrix.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfsetmatrix.Tpo -c -o libluatex_a-pdfsetmatrix.obj `if test -f 'pdfsetmatrix.c'; then $(CYGPATH_W) 'pdfsetmatrix.c'; else $(CYGPATH_W) '$(srcdir)/pdfsetmatrix.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfsetmatrix.Tpo $(DEPDIR)/libluatex_a-pdfsetmatrix.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfsetmatrix.c' object='libluatex_a-pdfsetmatrix.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfsetmatrix.obj `if test -f 'pdfsetmatrix.c'; then $(CYGPATH_W) 'pdfsetmatrix.c'; else $(CYGPATH_W) '$(srcdir)/pdfsetmatrix.c'; fi` + +libluatex_a-pdfshipout.o: pdfshipout.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfshipout.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfshipout.Tpo -c -o libluatex_a-pdfshipout.o `test -f 'pdfshipout.c' || echo '$(srcdir)/'`pdfshipout.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfshipout.Tpo $(DEPDIR)/libluatex_a-pdfshipout.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfshipout.c' object='libluatex_a-pdfshipout.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfshipout.o `test -f 'pdfshipout.c' || echo '$(srcdir)/'`pdfshipout.c + +libluatex_a-pdfshipout.obj: pdfshipout.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfshipout.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfshipout.Tpo -c -o libluatex_a-pdfshipout.obj `if test -f 'pdfshipout.c'; then $(CYGPATH_W) 'pdfshipout.c'; else $(CYGPATH_W) '$(srcdir)/pdfshipout.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfshipout.Tpo $(DEPDIR)/libluatex_a-pdfshipout.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfshipout.c' object='libluatex_a-pdfshipout.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfshipout.obj `if test -f 'pdfshipout.c'; then $(CYGPATH_W) 'pdfshipout.c'; else $(CYGPATH_W) '$(srcdir)/pdfshipout.c'; fi` + +libluatex_a-pdftables.o: pdftables.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdftables.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdftables.Tpo -c -o libluatex_a-pdftables.o `test -f 'pdftables.c' || echo '$(srcdir)/'`pdftables.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdftables.Tpo $(DEPDIR)/libluatex_a-pdftables.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdftables.c' object='libluatex_a-pdftables.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdftables.o `test -f 'pdftables.c' || echo '$(srcdir)/'`pdftables.c + +libluatex_a-pdftables.obj: pdftables.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdftables.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdftables.Tpo -c -o libluatex_a-pdftables.obj `if test -f 'pdftables.c'; then $(CYGPATH_W) 'pdftables.c'; else $(CYGPATH_W) '$(srcdir)/pdftables.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdftables.Tpo $(DEPDIR)/libluatex_a-pdftables.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdftables.c' object='libluatex_a-pdftables.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdftables.obj `if test -f 'pdftables.c'; then $(CYGPATH_W) 'pdftables.c'; else $(CYGPATH_W) '$(srcdir)/pdftables.c'; fi` + +libluatex_a-pdfthread.o: pdfthread.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfthread.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfthread.Tpo -c -o libluatex_a-pdfthread.o `test -f 'pdfthread.c' || echo '$(srcdir)/'`pdfthread.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfthread.Tpo $(DEPDIR)/libluatex_a-pdfthread.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfthread.c' object='libluatex_a-pdfthread.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfthread.o `test -f 'pdfthread.c' || echo '$(srcdir)/'`pdfthread.c + +libluatex_a-pdfthread.obj: pdfthread.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfthread.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfthread.Tpo -c -o libluatex_a-pdfthread.obj `if test -f 'pdfthread.c'; then $(CYGPATH_W) 'pdfthread.c'; else $(CYGPATH_W) '$(srcdir)/pdfthread.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfthread.Tpo $(DEPDIR)/libluatex_a-pdfthread.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfthread.c' object='libluatex_a-pdfthread.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfthread.obj `if test -f 'pdfthread.c'; then $(CYGPATH_W) 'pdfthread.c'; else $(CYGPATH_W) '$(srcdir)/pdfthread.c'; fi` + +libluatex_a-pdfxform.o: pdfxform.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfxform.o -MD -MP -MF $(DEPDIR)/libluatex_a-pdfxform.Tpo -c -o libluatex_a-pdfxform.o `test -f 'pdfxform.c' || echo '$(srcdir)/'`pdfxform.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfxform.Tpo $(DEPDIR)/libluatex_a-pdfxform.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfxform.c' object='libluatex_a-pdfxform.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfxform.o `test -f 'pdfxform.c' || echo '$(srcdir)/'`pdfxform.c + +libluatex_a-pdfxform.obj: pdfxform.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-pdfxform.obj -MD -MP -MF $(DEPDIR)/libluatex_a-pdfxform.Tpo -c -o libluatex_a-pdfxform.obj `if test -f 'pdfxform.c'; then $(CYGPATH_W) 'pdfxform.c'; else $(CYGPATH_W) '$(srcdir)/pdfxform.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-pdfxform.Tpo $(DEPDIR)/libluatex_a-pdfxform.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfxform.c' object='libluatex_a-pdfxform.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-pdfxform.obj `if test -f 'pdfxform.c'; then $(CYGPATH_W) 'pdfxform.c'; else $(CYGPATH_W) '$(srcdir)/pdfxform.c'; fi` + +libluatex_a-align.o: align.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-align.o -MD -MP -MF $(DEPDIR)/libluatex_a-align.Tpo -c -o libluatex_a-align.o `test -f 'align.c' || echo '$(srcdir)/'`align.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-align.Tpo $(DEPDIR)/libluatex_a-align.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='align.c' object='libluatex_a-align.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-align.o `test -f 'align.c' || echo '$(srcdir)/'`align.c + +libluatex_a-align.obj: align.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-align.obj -MD -MP -MF $(DEPDIR)/libluatex_a-align.Tpo -c -o libluatex_a-align.obj `if test -f 'align.c'; then $(CYGPATH_W) 'align.c'; else $(CYGPATH_W) '$(srcdir)/align.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-align.Tpo $(DEPDIR)/libluatex_a-align.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='align.c' object='libluatex_a-align.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-align.obj `if test -f 'align.c'; then $(CYGPATH_W) 'align.c'; else $(CYGPATH_W) '$(srcdir)/align.c'; fi` + +libluatex_a-dumpdata.o: dumpdata.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dumpdata.o -MD -MP -MF $(DEPDIR)/libluatex_a-dumpdata.Tpo -c -o libluatex_a-dumpdata.o `test -f 'dumpdata.c' || echo '$(srcdir)/'`dumpdata.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dumpdata.Tpo $(DEPDIR)/libluatex_a-dumpdata.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dumpdata.c' object='libluatex_a-dumpdata.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dumpdata.o `test -f 'dumpdata.c' || echo '$(srcdir)/'`dumpdata.c + +libluatex_a-dumpdata.obj: dumpdata.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-dumpdata.obj -MD -MP -MF $(DEPDIR)/libluatex_a-dumpdata.Tpo -c -o libluatex_a-dumpdata.obj `if test -f 'dumpdata.c'; then $(CYGPATH_W) 'dumpdata.c'; else $(CYGPATH_W) '$(srcdir)/dumpdata.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-dumpdata.Tpo $(DEPDIR)/libluatex_a-dumpdata.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dumpdata.c' object='libluatex_a-dumpdata.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-dumpdata.obj `if test -f 'dumpdata.c'; then $(CYGPATH_W) 'dumpdata.c'; else $(CYGPATH_W) '$(srcdir)/dumpdata.c'; fi` + +libluatex_a-expand.o: expand.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-expand.o -MD -MP -MF $(DEPDIR)/libluatex_a-expand.Tpo -c -o libluatex_a-expand.o `test -f 'expand.c' || echo '$(srcdir)/'`expand.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-expand.Tpo $(DEPDIR)/libluatex_a-expand.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='expand.c' object='libluatex_a-expand.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-expand.o `test -f 'expand.c' || echo '$(srcdir)/'`expand.c + +libluatex_a-expand.obj: expand.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-expand.obj -MD -MP -MF $(DEPDIR)/libluatex_a-expand.Tpo -c -o libluatex_a-expand.obj `if test -f 'expand.c'; then $(CYGPATH_W) 'expand.c'; else $(CYGPATH_W) '$(srcdir)/expand.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-expand.Tpo $(DEPDIR)/libluatex_a-expand.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='expand.c' object='libluatex_a-expand.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-math.obj `if test -f 'luatexdir/tex/math.c'; then $(CYGPATH_W) 'luatexdir/tex/math.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/math.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-expand.obj `if test -f 'expand.c'; then $(CYGPATH_W) 'expand.c'; else $(CYGPATH_W) '$(srcdir)/expand.c'; fi` -libluatex_a-mlist.o: luatexdir/tex/mlist.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mlist.o -MD -MP -MF $(DEPDIR)/libluatex_a-mlist.Tpo -c -o libluatex_a-mlist.o `test -f 'luatexdir/tex/mlist.c' || echo '$(srcdir)/'`luatexdir/tex/mlist.c +libluatex_a-inputstack.o: inputstack.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-inputstack.o -MD -MP -MF $(DEPDIR)/libluatex_a-inputstack.Tpo -c -o libluatex_a-inputstack.o `test -f 'inputstack.c' || echo '$(srcdir)/'`inputstack.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-inputstack.Tpo $(DEPDIR)/libluatex_a-inputstack.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inputstack.c' object='libluatex_a-inputstack.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-inputstack.o `test -f 'inputstack.c' || echo '$(srcdir)/'`inputstack.c + +libluatex_a-inputstack.obj: inputstack.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-inputstack.obj -MD -MP -MF $(DEPDIR)/libluatex_a-inputstack.Tpo -c -o libluatex_a-inputstack.obj `if test -f 'inputstack.c'; then $(CYGPATH_W) 'inputstack.c'; else $(CYGPATH_W) '$(srcdir)/inputstack.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-inputstack.Tpo $(DEPDIR)/libluatex_a-inputstack.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inputstack.c' object='libluatex_a-inputstack.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-inputstack.obj `if test -f 'inputstack.c'; then $(CYGPATH_W) 'inputstack.c'; else $(CYGPATH_W) '$(srcdir)/inputstack.c'; fi` + +libluatex_a-maincontrol.o: maincontrol.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-maincontrol.o -MD -MP -MF $(DEPDIR)/libluatex_a-maincontrol.Tpo -c -o libluatex_a-maincontrol.o `test -f 'maincontrol.c' || echo '$(srcdir)/'`maincontrol.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-maincontrol.Tpo $(DEPDIR)/libluatex_a-maincontrol.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='maincontrol.c' object='libluatex_a-maincontrol.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-maincontrol.o `test -f 'maincontrol.c' || echo '$(srcdir)/'`maincontrol.c + +libluatex_a-maincontrol.obj: maincontrol.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-maincontrol.obj -MD -MP -MF $(DEPDIR)/libluatex_a-maincontrol.Tpo -c -o libluatex_a-maincontrol.obj `if test -f 'maincontrol.c'; then $(CYGPATH_W) 'maincontrol.c'; else $(CYGPATH_W) '$(srcdir)/maincontrol.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-maincontrol.Tpo $(DEPDIR)/libluatex_a-maincontrol.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='maincontrol.c' object='libluatex_a-maincontrol.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-maincontrol.obj `if test -f 'maincontrol.c'; then $(CYGPATH_W) 'maincontrol.c'; else $(CYGPATH_W) '$(srcdir)/maincontrol.c'; fi` + +libluatex_a-mlist.o: mlist.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mlist.o -MD -MP -MF $(DEPDIR)/libluatex_a-mlist.Tpo -c -o libluatex_a-mlist.o `test -f 'mlist.c' || echo '$(srcdir)/'`mlist.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mlist.Tpo $(DEPDIR)/libluatex_a-mlist.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/mlist.c' object='libluatex_a-mlist.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mlist.c' object='libluatex_a-mlist.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mlist.o `test -f 'luatexdir/tex/mlist.c' || echo '$(srcdir)/'`luatexdir/tex/mlist.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mlist.o `test -f 'mlist.c' || echo '$(srcdir)/'`mlist.c -libluatex_a-mlist.obj: luatexdir/tex/mlist.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mlist.obj -MD -MP -MF $(DEPDIR)/libluatex_a-mlist.Tpo -c -o libluatex_a-mlist.obj `if test -f 'luatexdir/tex/mlist.c'; then $(CYGPATH_W) 'luatexdir/tex/mlist.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/mlist.c'; fi` +libluatex_a-mlist.obj: mlist.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mlist.obj -MD -MP -MF $(DEPDIR)/libluatex_a-mlist.Tpo -c -o libluatex_a-mlist.obj `if test -f 'mlist.c'; then $(CYGPATH_W) 'mlist.c'; else $(CYGPATH_W) '$(srcdir)/mlist.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mlist.Tpo $(DEPDIR)/libluatex_a-mlist.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/mlist.c' object='libluatex_a-mlist.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mlist.c' object='libluatex_a-mlist.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mlist.obj `if test -f 'luatexdir/tex/mlist.c'; then $(CYGPATH_W) 'luatexdir/tex/mlist.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/mlist.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mlist.obj `if test -f 'mlist.c'; then $(CYGPATH_W) 'mlist.c'; else $(CYGPATH_W) '$(srcdir)/mlist.c'; fi` -libluatex_a-postlinebreak.o: luatexdir/tex/postlinebreak.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-postlinebreak.o -MD -MP -MF $(DEPDIR)/libluatex_a-postlinebreak.Tpo -c -o libluatex_a-postlinebreak.o `test -f 'luatexdir/tex/postlinebreak.c' || echo '$(srcdir)/'`luatexdir/tex/postlinebreak.c +libluatex_a-postlinebreak.o: postlinebreak.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-postlinebreak.o -MD -MP -MF $(DEPDIR)/libluatex_a-postlinebreak.Tpo -c -o libluatex_a-postlinebreak.o `test -f 'postlinebreak.c' || echo '$(srcdir)/'`postlinebreak.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-postlinebreak.Tpo $(DEPDIR)/libluatex_a-postlinebreak.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/postlinebreak.c' object='libluatex_a-postlinebreak.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='postlinebreak.c' object='libluatex_a-postlinebreak.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-postlinebreak.o `test -f 'luatexdir/tex/postlinebreak.c' || echo '$(srcdir)/'`luatexdir/tex/postlinebreak.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-postlinebreak.o `test -f 'postlinebreak.c' || echo '$(srcdir)/'`postlinebreak.c -libluatex_a-postlinebreak.obj: luatexdir/tex/postlinebreak.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-postlinebreak.obj -MD -MP -MF $(DEPDIR)/libluatex_a-postlinebreak.Tpo -c -o libluatex_a-postlinebreak.obj `if test -f 'luatexdir/tex/postlinebreak.c'; then $(CYGPATH_W) 'luatexdir/tex/postlinebreak.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/postlinebreak.c'; fi` +libluatex_a-postlinebreak.obj: postlinebreak.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-postlinebreak.obj -MD -MP -MF $(DEPDIR)/libluatex_a-postlinebreak.Tpo -c -o libluatex_a-postlinebreak.obj `if test -f 'postlinebreak.c'; then $(CYGPATH_W) 'postlinebreak.c'; else $(CYGPATH_W) '$(srcdir)/postlinebreak.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-postlinebreak.Tpo $(DEPDIR)/libluatex_a-postlinebreak.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/postlinebreak.c' object='libluatex_a-postlinebreak.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='postlinebreak.c' object='libluatex_a-postlinebreak.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-postlinebreak.obj `if test -f 'luatexdir/tex/postlinebreak.c'; then $(CYGPATH_W) 'luatexdir/tex/postlinebreak.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/postlinebreak.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-postlinebreak.obj `if test -f 'postlinebreak.c'; then $(CYGPATH_W) 'postlinebreak.c'; else $(CYGPATH_W) '$(srcdir)/postlinebreak.c'; fi` -libluatex_a-primitive.o: luatexdir/tex/primitive.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-primitive.o -MD -MP -MF $(DEPDIR)/libluatex_a-primitive.Tpo -c -o libluatex_a-primitive.o `test -f 'luatexdir/tex/primitive.c' || echo '$(srcdir)/'`luatexdir/tex/primitive.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-primitive.Tpo $(DEPDIR)/libluatex_a-primitive.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/primitive.c' object='libluatex_a-primitive.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-scanning.o: scanning.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-scanning.o -MD -MP -MF $(DEPDIR)/libluatex_a-scanning.Tpo -c -o libluatex_a-scanning.o `test -f 'scanning.c' || echo '$(srcdir)/'`scanning.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-scanning.Tpo $(DEPDIR)/libluatex_a-scanning.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanning.c' object='libluatex_a-scanning.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-primitive.o `test -f 'luatexdir/tex/primitive.c' || echo '$(srcdir)/'`luatexdir/tex/primitive.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-scanning.o `test -f 'scanning.c' || echo '$(srcdir)/'`scanning.c -libluatex_a-primitive.obj: luatexdir/tex/primitive.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-primitive.obj -MD -MP -MF $(DEPDIR)/libluatex_a-primitive.Tpo -c -o libluatex_a-primitive.obj `if test -f 'luatexdir/tex/primitive.c'; then $(CYGPATH_W) 'luatexdir/tex/primitive.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/primitive.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-primitive.Tpo $(DEPDIR)/libluatex_a-primitive.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/primitive.c' object='libluatex_a-primitive.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-scanning.obj: scanning.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-scanning.obj -MD -MP -MF $(DEPDIR)/libluatex_a-scanning.Tpo -c -o libluatex_a-scanning.obj `if test -f 'scanning.c'; then $(CYGPATH_W) 'scanning.c'; else $(CYGPATH_W) '$(srcdir)/scanning.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-scanning.Tpo $(DEPDIR)/libluatex_a-scanning.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanning.c' object='libluatex_a-scanning.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-primitive.obj `if test -f 'luatexdir/tex/primitive.c'; then $(CYGPATH_W) 'luatexdir/tex/primitive.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/primitive.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-scanning.obj `if test -f 'scanning.c'; then $(CYGPATH_W) 'scanning.c'; else $(CYGPATH_W) '$(srcdir)/scanning.c'; fi` -libluatex_a-texdeffont.o: luatexdir/tex/texdeffont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texdeffont.o -MD -MP -MF $(DEPDIR)/libluatex_a-texdeffont.Tpo -c -o libluatex_a-texdeffont.o `test -f 'luatexdir/tex/texdeffont.c' || echo '$(srcdir)/'`luatexdir/tex/texdeffont.c +libluatex_a-texdeffont.o: texdeffont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texdeffont.o -MD -MP -MF $(DEPDIR)/libluatex_a-texdeffont.Tpo -c -o libluatex_a-texdeffont.o `test -f 'texdeffont.c' || echo '$(srcdir)/'`texdeffont.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texdeffont.Tpo $(DEPDIR)/libluatex_a-texdeffont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/texdeffont.c' object='libluatex_a-texdeffont.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texdeffont.c' object='libluatex_a-texdeffont.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texdeffont.o `test -f 'luatexdir/tex/texdeffont.c' || echo '$(srcdir)/'`luatexdir/tex/texdeffont.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texdeffont.o `test -f 'texdeffont.c' || echo '$(srcdir)/'`texdeffont.c -libluatex_a-texdeffont.obj: luatexdir/tex/texdeffont.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texdeffont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texdeffont.Tpo -c -o libluatex_a-texdeffont.obj `if test -f 'luatexdir/tex/texdeffont.c'; then $(CYGPATH_W) 'luatexdir/tex/texdeffont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/texdeffont.c'; fi` +libluatex_a-texdeffont.obj: texdeffont.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texdeffont.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texdeffont.Tpo -c -o libluatex_a-texdeffont.obj `if test -f 'texdeffont.c'; then $(CYGPATH_W) 'texdeffont.c'; else $(CYGPATH_W) '$(srcdir)/texdeffont.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texdeffont.Tpo $(DEPDIR)/libluatex_a-texdeffont.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/texdeffont.c' object='libluatex_a-texdeffont.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texdeffont.c' object='libluatex_a-texdeffont.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texdeffont.obj `if test -f 'luatexdir/tex/texdeffont.c'; then $(CYGPATH_W) 'luatexdir/tex/texdeffont.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/texdeffont.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texdeffont.obj `if test -f 'texdeffont.c'; then $(CYGPATH_W) 'texdeffont.c'; else $(CYGPATH_W) '$(srcdir)/texdeffont.c'; fi` -libluatex_a-texnodes.o: luatexdir/tex/texnodes.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texnodes.o -MD -MP -MF $(DEPDIR)/libluatex_a-texnodes.Tpo -c -o libluatex_a-texnodes.o `test -f 'luatexdir/tex/texnodes.c' || echo '$(srcdir)/'`luatexdir/tex/texnodes.c +libluatex_a-texnodes.o: texnodes.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texnodes.o -MD -MP -MF $(DEPDIR)/libluatex_a-texnodes.Tpo -c -o libluatex_a-texnodes.o `test -f 'texnodes.c' || echo '$(srcdir)/'`texnodes.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texnodes.Tpo $(DEPDIR)/libluatex_a-texnodes.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/texnodes.c' object='libluatex_a-texnodes.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texnodes.c' object='libluatex_a-texnodes.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texnodes.o `test -f 'luatexdir/tex/texnodes.c' || echo '$(srcdir)/'`luatexdir/tex/texnodes.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texnodes.o `test -f 'texnodes.c' || echo '$(srcdir)/'`texnodes.c -libluatex_a-texnodes.obj: luatexdir/tex/texnodes.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texnodes.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texnodes.Tpo -c -o libluatex_a-texnodes.obj `if test -f 'luatexdir/tex/texnodes.c'; then $(CYGPATH_W) 'luatexdir/tex/texnodes.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/texnodes.c'; fi` +libluatex_a-texnodes.obj: texnodes.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texnodes.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texnodes.Tpo -c -o libluatex_a-texnodes.obj `if test -f 'texnodes.c'; then $(CYGPATH_W) 'texnodes.c'; else $(CYGPATH_W) '$(srcdir)/texnodes.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texnodes.Tpo $(DEPDIR)/libluatex_a-texnodes.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/texnodes.c' object='libluatex_a-texnodes.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texnodes.c' object='libluatex_a-texnodes.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texnodes.obj `if test -f 'luatexdir/tex/texnodes.c'; then $(CYGPATH_W) 'luatexdir/tex/texnodes.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/texnodes.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texnodes.obj `if test -f 'texnodes.c'; then $(CYGPATH_W) 'texnodes.c'; else $(CYGPATH_W) '$(srcdir)/texnodes.c'; fi` -libluatex_a-texpdf.o: luatexdir/tex/texpdf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texpdf.o -MD -MP -MF $(DEPDIR)/libluatex_a-texpdf.Tpo -c -o libluatex_a-texpdf.o `test -f 'luatexdir/tex/texpdf.c' || echo '$(srcdir)/'`luatexdir/tex/texpdf.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texpdf.Tpo $(DEPDIR)/libluatex_a-texpdf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/texpdf.c' object='libluatex_a-texpdf.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-arithmetic.o: arithmetic.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-arithmetic.o -MD -MP -MF $(DEPDIR)/libluatex_a-arithmetic.Tpo -c -o libluatex_a-arithmetic.o `test -f 'arithmetic.c' || echo '$(srcdir)/'`arithmetic.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-arithmetic.Tpo $(DEPDIR)/libluatex_a-arithmetic.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='arithmetic.c' object='libluatex_a-arithmetic.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texpdf.o `test -f 'luatexdir/tex/texpdf.c' || echo '$(srcdir)/'`luatexdir/tex/texpdf.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-arithmetic.o `test -f 'arithmetic.c' || echo '$(srcdir)/'`arithmetic.c -libluatex_a-texpdf.obj: luatexdir/tex/texpdf.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texpdf.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texpdf.Tpo -c -o libluatex_a-texpdf.obj `if test -f 'luatexdir/tex/texpdf.c'; then $(CYGPATH_W) 'luatexdir/tex/texpdf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/texpdf.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texpdf.Tpo $(DEPDIR)/libluatex_a-texpdf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/texpdf.c' object='libluatex_a-texpdf.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-arithmetic.obj: arithmetic.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-arithmetic.obj -MD -MP -MF $(DEPDIR)/libluatex_a-arithmetic.Tpo -c -o libluatex_a-arithmetic.obj `if test -f 'arithmetic.c'; then $(CYGPATH_W) 'arithmetic.c'; else $(CYGPATH_W) '$(srcdir)/arithmetic.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-arithmetic.Tpo $(DEPDIR)/libluatex_a-arithmetic.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='arithmetic.c' object='libluatex_a-arithmetic.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texpdf.obj `if test -f 'luatexdir/tex/texpdf.c'; then $(CYGPATH_W) 'luatexdir/tex/texpdf.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/texpdf.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-arithmetic.obj `if test -f 'arithmetic.c'; then $(CYGPATH_W) 'arithmetic.c'; else $(CYGPATH_W) '$(srcdir)/arithmetic.c'; fi` -libluatex_a-textoken.o: luatexdir/tex/textoken.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textoken.o -MD -MP -MF $(DEPDIR)/libluatex_a-textoken.Tpo -c -o libluatex_a-textoken.o `test -f 'luatexdir/tex/textoken.c' || echo '$(srcdir)/'`luatexdir/tex/textoken.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-textoken.Tpo $(DEPDIR)/libluatex_a-textoken.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/textoken.c' object='libluatex_a-textoken.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-conditional.o: conditional.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-conditional.o -MD -MP -MF $(DEPDIR)/libluatex_a-conditional.Tpo -c -o libluatex_a-conditional.o `test -f 'conditional.c' || echo '$(srcdir)/'`conditional.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-conditional.Tpo $(DEPDIR)/libluatex_a-conditional.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='conditional.c' object='libluatex_a-conditional.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textoken.o `test -f 'luatexdir/tex/textoken.c' || echo '$(srcdir)/'`luatexdir/tex/textoken.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-conditional.o `test -f 'conditional.c' || echo '$(srcdir)/'`conditional.c -libluatex_a-textoken.obj: luatexdir/tex/textoken.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textoken.obj -MD -MP -MF $(DEPDIR)/libluatex_a-textoken.Tpo -c -o libluatex_a-textoken.obj `if test -f 'luatexdir/tex/textoken.c'; then $(CYGPATH_W) 'luatexdir/tex/textoken.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/textoken.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-textoken.Tpo $(DEPDIR)/libluatex_a-textoken.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/tex/textoken.c' object='libluatex_a-textoken.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-conditional.obj: conditional.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-conditional.obj -MD -MP -MF $(DEPDIR)/libluatex_a-conditional.Tpo -c -o libluatex_a-conditional.obj `if test -f 'conditional.c'; then $(CYGPATH_W) 'conditional.c'; else $(CYGPATH_W) '$(srcdir)/conditional.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-conditional.Tpo $(DEPDIR)/libluatex_a-conditional.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='conditional.c' object='libluatex_a-conditional.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-conditional.obj `if test -f 'conditional.c'; then $(CYGPATH_W) 'conditional.c'; else $(CYGPATH_W) '$(srcdir)/conditional.c'; fi` + +libluatex_a-equivalents.o: equivalents.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-equivalents.o -MD -MP -MF $(DEPDIR)/libluatex_a-equivalents.Tpo -c -o libluatex_a-equivalents.o `test -f 'equivalents.c' || echo '$(srcdir)/'`equivalents.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-equivalents.Tpo $(DEPDIR)/libluatex_a-equivalents.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='equivalents.c' object='libluatex_a-equivalents.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textoken.obj `if test -f 'luatexdir/tex/textoken.c'; then $(CYGPATH_W) 'luatexdir/tex/textoken.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/tex/textoken.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-equivalents.o `test -f 'equivalents.c' || echo '$(srcdir)/'`equivalents.c -libluatex_a-textcodes.o: luatexdir/textcodes.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textcodes.o -MD -MP -MF $(DEPDIR)/libluatex_a-textcodes.Tpo -c -o libluatex_a-textcodes.o `test -f 'luatexdir/textcodes.c' || echo '$(srcdir)/'`luatexdir/textcodes.c +libluatex_a-equivalents.obj: equivalents.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-equivalents.obj -MD -MP -MF $(DEPDIR)/libluatex_a-equivalents.Tpo -c -o libluatex_a-equivalents.obj `if test -f 'equivalents.c'; then $(CYGPATH_W) 'equivalents.c'; else $(CYGPATH_W) '$(srcdir)/equivalents.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-equivalents.Tpo $(DEPDIR)/libluatex_a-equivalents.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='equivalents.c' object='libluatex_a-equivalents.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-equivalents.obj `if test -f 'equivalents.c'; then $(CYGPATH_W) 'equivalents.c'; else $(CYGPATH_W) '$(srcdir)/equivalents.c'; fi` + +libluatex_a-extensions.o: extensions.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-extensions.o -MD -MP -MF $(DEPDIR)/libluatex_a-extensions.Tpo -c -o libluatex_a-extensions.o `test -f 'extensions.c' || echo '$(srcdir)/'`extensions.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-extensions.Tpo $(DEPDIR)/libluatex_a-extensions.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='extensions.c' object='libluatex_a-extensions.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-extensions.o `test -f 'extensions.c' || echo '$(srcdir)/'`extensions.c + +libluatex_a-extensions.obj: extensions.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-extensions.obj -MD -MP -MF $(DEPDIR)/libluatex_a-extensions.Tpo -c -o libluatex_a-extensions.obj `if test -f 'extensions.c'; then $(CYGPATH_W) 'extensions.c'; else $(CYGPATH_W) '$(srcdir)/extensions.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-extensions.Tpo $(DEPDIR)/libluatex_a-extensions.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='extensions.c' object='libluatex_a-extensions.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-extensions.obj `if test -f 'extensions.c'; then $(CYGPATH_W) 'extensions.c'; else $(CYGPATH_W) '$(srcdir)/extensions.c'; fi` + +libluatex_a-commands.o: commands.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-commands.o -MD -MP -MF $(DEPDIR)/libluatex_a-commands.Tpo -c -o libluatex_a-commands.o `test -f 'commands.c' || echo '$(srcdir)/'`commands.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-commands.Tpo $(DEPDIR)/libluatex_a-commands.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='commands.c' object='libluatex_a-commands.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-commands.o `test -f 'commands.c' || echo '$(srcdir)/'`commands.c + +libluatex_a-commands.obj: commands.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-commands.obj -MD -MP -MF $(DEPDIR)/libluatex_a-commands.Tpo -c -o libluatex_a-commands.obj `if test -f 'commands.c'; then $(CYGPATH_W) 'commands.c'; else $(CYGPATH_W) '$(srcdir)/commands.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-commands.Tpo $(DEPDIR)/libluatex_a-commands.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='commands.c' object='libluatex_a-commands.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-commands.obj `if test -f 'commands.c'; then $(CYGPATH_W) 'commands.c'; else $(CYGPATH_W) '$(srcdir)/commands.c'; fi` + +libluatex_a-linebreak.o: linebreak.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-linebreak.o -MD -MP -MF $(DEPDIR)/libluatex_a-linebreak.Tpo -c -o libluatex_a-linebreak.o `test -f 'linebreak.c' || echo '$(srcdir)/'`linebreak.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-linebreak.Tpo $(DEPDIR)/libluatex_a-linebreak.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='linebreak.c' object='libluatex_a-linebreak.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-linebreak.o `test -f 'linebreak.c' || echo '$(srcdir)/'`linebreak.c + +libluatex_a-linebreak.obj: linebreak.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-linebreak.obj -MD -MP -MF $(DEPDIR)/libluatex_a-linebreak.Tpo -c -o libluatex_a-linebreak.obj `if test -f 'linebreak.c'; then $(CYGPATH_W) 'linebreak.c'; else $(CYGPATH_W) '$(srcdir)/linebreak.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-linebreak.Tpo $(DEPDIR)/libluatex_a-linebreak.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='linebreak.c' object='libluatex_a-linebreak.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-linebreak.obj `if test -f 'linebreak.c'; then $(CYGPATH_W) 'linebreak.c'; else $(CYGPATH_W) '$(srcdir)/linebreak.c'; fi` + +libluatex_a-mathcodes.o: mathcodes.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mathcodes.o -MD -MP -MF $(DEPDIR)/libluatex_a-mathcodes.Tpo -c -o libluatex_a-mathcodes.o `test -f 'mathcodes.c' || echo '$(srcdir)/'`mathcodes.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mathcodes.Tpo $(DEPDIR)/libluatex_a-mathcodes.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mathcodes.c' object='libluatex_a-mathcodes.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mathcodes.o `test -f 'mathcodes.c' || echo '$(srcdir)/'`mathcodes.c + +libluatex_a-mathcodes.obj: mathcodes.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mathcodes.obj -MD -MP -MF $(DEPDIR)/libluatex_a-mathcodes.Tpo -c -o libluatex_a-mathcodes.obj `if test -f 'mathcodes.c'; then $(CYGPATH_W) 'mathcodes.c'; else $(CYGPATH_W) '$(srcdir)/mathcodes.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mathcodes.Tpo $(DEPDIR)/libluatex_a-mathcodes.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mathcodes.c' object='libluatex_a-mathcodes.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mathcodes.obj `if test -f 'mathcodes.c'; then $(CYGPATH_W) 'mathcodes.c'; else $(CYGPATH_W) '$(srcdir)/mathcodes.c'; fi` + +libluatex_a-nesting.o: nesting.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-nesting.o -MD -MP -MF $(DEPDIR)/libluatex_a-nesting.Tpo -c -o libluatex_a-nesting.o `test -f 'nesting.c' || echo '$(srcdir)/'`nesting.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-nesting.Tpo $(DEPDIR)/libluatex_a-nesting.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nesting.c' object='libluatex_a-nesting.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-nesting.o `test -f 'nesting.c' || echo '$(srcdir)/'`nesting.c + +libluatex_a-nesting.obj: nesting.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-nesting.obj -MD -MP -MF $(DEPDIR)/libluatex_a-nesting.Tpo -c -o libluatex_a-nesting.obj `if test -f 'nesting.c'; then $(CYGPATH_W) 'nesting.c'; else $(CYGPATH_W) '$(srcdir)/nesting.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-nesting.Tpo $(DEPDIR)/libluatex_a-nesting.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nesting.c' object='libluatex_a-nesting.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-nesting.obj `if test -f 'nesting.c'; then $(CYGPATH_W) 'nesting.c'; else $(CYGPATH_W) '$(srcdir)/nesting.c'; fi` + +libluatex_a-primitive.o: primitive.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-primitive.o -MD -MP -MF $(DEPDIR)/libluatex_a-primitive.Tpo -c -o libluatex_a-primitive.o `test -f 'primitive.c' || echo '$(srcdir)/'`primitive.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-primitive.Tpo $(DEPDIR)/libluatex_a-primitive.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='primitive.c' object='libluatex_a-primitive.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-primitive.o `test -f 'primitive.c' || echo '$(srcdir)/'`primitive.c + +libluatex_a-primitive.obj: primitive.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-primitive.obj -MD -MP -MF $(DEPDIR)/libluatex_a-primitive.Tpo -c -o libluatex_a-primitive.obj `if test -f 'primitive.c'; then $(CYGPATH_W) 'primitive.c'; else $(CYGPATH_W) '$(srcdir)/primitive.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-primitive.Tpo $(DEPDIR)/libluatex_a-primitive.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='primitive.c' object='libluatex_a-primitive.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-primitive.obj `if test -f 'primitive.c'; then $(CYGPATH_W) 'primitive.c'; else $(CYGPATH_W) '$(srcdir)/primitive.c'; fi` + +libluatex_a-texfileio.o: texfileio.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texfileio.o -MD -MP -MF $(DEPDIR)/libluatex_a-texfileio.Tpo -c -o libluatex_a-texfileio.o `test -f 'texfileio.c' || echo '$(srcdir)/'`texfileio.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texfileio.Tpo $(DEPDIR)/libluatex_a-texfileio.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texfileio.c' object='libluatex_a-texfileio.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texfileio.o `test -f 'texfileio.c' || echo '$(srcdir)/'`texfileio.c + +libluatex_a-texfileio.obj: texfileio.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texfileio.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texfileio.Tpo -c -o libluatex_a-texfileio.obj `if test -f 'texfileio.c'; then $(CYGPATH_W) 'texfileio.c'; else $(CYGPATH_W) '$(srcdir)/texfileio.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texfileio.Tpo $(DEPDIR)/libluatex_a-texfileio.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texfileio.c' object='libluatex_a-texfileio.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texfileio.obj `if test -f 'texfileio.c'; then $(CYGPATH_W) 'texfileio.c'; else $(CYGPATH_W) '$(srcdir)/texfileio.c'; fi` + +libluatex_a-textcodes.o: textcodes.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textcodes.o -MD -MP -MF $(DEPDIR)/libluatex_a-textcodes.Tpo -c -o libluatex_a-textcodes.o `test -f 'textcodes.c' || echo '$(srcdir)/'`textcodes.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-textcodes.Tpo $(DEPDIR)/libluatex_a-textcodes.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/textcodes.c' object='libluatex_a-textcodes.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='textcodes.c' object='libluatex_a-textcodes.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textcodes.o `test -f 'luatexdir/textcodes.c' || echo '$(srcdir)/'`luatexdir/textcodes.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textcodes.o `test -f 'textcodes.c' || echo '$(srcdir)/'`textcodes.c -libluatex_a-textcodes.obj: luatexdir/textcodes.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textcodes.obj -MD -MP -MF $(DEPDIR)/libluatex_a-textcodes.Tpo -c -o libluatex_a-textcodes.obj `if test -f 'luatexdir/textcodes.c'; then $(CYGPATH_W) 'luatexdir/textcodes.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/textcodes.c'; fi` +libluatex_a-textcodes.obj: textcodes.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textcodes.obj -MD -MP -MF $(DEPDIR)/libluatex_a-textcodes.Tpo -c -o libluatex_a-textcodes.obj `if test -f 'textcodes.c'; then $(CYGPATH_W) 'textcodes.c'; else $(CYGPATH_W) '$(srcdir)/textcodes.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-textcodes.Tpo $(DEPDIR)/libluatex_a-textcodes.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/textcodes.c' object='libluatex_a-textcodes.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='textcodes.c' object='libluatex_a-textcodes.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textcodes.obj `if test -f 'luatexdir/textcodes.c'; then $(CYGPATH_W) 'luatexdir/textcodes.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/textcodes.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textcodes.obj `if test -f 'textcodes.c'; then $(CYGPATH_W) 'textcodes.c'; else $(CYGPATH_W) '$(srcdir)/textcodes.c'; fi` -libluatex_a-avl.o: luatexdir/utils/avl.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avl.o -MD -MP -MF $(DEPDIR)/libluatex_a-avl.Tpo -c -o libluatex_a-avl.o `test -f 'luatexdir/utils/avl.c' || echo '$(srcdir)/'`luatexdir/utils/avl.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avl.Tpo $(DEPDIR)/libluatex_a-avl.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/avl.c' object='libluatex_a-avl.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-buildpage.o: buildpage.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-buildpage.o -MD -MP -MF $(DEPDIR)/libluatex_a-buildpage.Tpo -c -o libluatex_a-buildpage.o `test -f 'buildpage.c' || echo '$(srcdir)/'`buildpage.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-buildpage.Tpo $(DEPDIR)/libluatex_a-buildpage.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='buildpage.c' object='libluatex_a-buildpage.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avl.o `test -f 'luatexdir/utils/avl.c' || echo '$(srcdir)/'`luatexdir/utils/avl.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-buildpage.o `test -f 'buildpage.c' || echo '$(srcdir)/'`buildpage.c -libluatex_a-avl.obj: luatexdir/utils/avl.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avl.obj -MD -MP -MF $(DEPDIR)/libluatex_a-avl.Tpo -c -o libluatex_a-avl.obj `if test -f 'luatexdir/utils/avl.c'; then $(CYGPATH_W) 'luatexdir/utils/avl.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/avl.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avl.Tpo $(DEPDIR)/libluatex_a-avl.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/avl.c' object='libluatex_a-avl.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-buildpage.obj: buildpage.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-buildpage.obj -MD -MP -MF $(DEPDIR)/libluatex_a-buildpage.Tpo -c -o libluatex_a-buildpage.obj `if test -f 'buildpage.c'; then $(CYGPATH_W) 'buildpage.c'; else $(CYGPATH_W) '$(srcdir)/buildpage.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-buildpage.Tpo $(DEPDIR)/libluatex_a-buildpage.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='buildpage.c' object='libluatex_a-buildpage.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avl.obj `if test -f 'luatexdir/utils/avl.c'; then $(CYGPATH_W) 'luatexdir/utils/avl.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/avl.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-buildpage.obj `if test -f 'buildpage.c'; then $(CYGPATH_W) 'buildpage.c'; else $(CYGPATH_W) '$(srcdir)/buildpage.c'; fi` -libluatex_a-avlstuff.o: luatexdir/utils/avlstuff.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avlstuff.o -MD -MP -MF $(DEPDIR)/libluatex_a-avlstuff.Tpo -c -o libluatex_a-avlstuff.o `test -f 'luatexdir/utils/avlstuff.c' || echo '$(srcdir)/'`luatexdir/utils/avlstuff.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avlstuff.Tpo $(DEPDIR)/libluatex_a-avlstuff.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/avlstuff.c' object='libluatex_a-avlstuff.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-directions.o: directions.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-directions.o -MD -MP -MF $(DEPDIR)/libluatex_a-directions.Tpo -c -o libluatex_a-directions.o `test -f 'directions.c' || echo '$(srcdir)/'`directions.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-directions.Tpo $(DEPDIR)/libluatex_a-directions.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='directions.c' object='libluatex_a-directions.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avlstuff.o `test -f 'luatexdir/utils/avlstuff.c' || echo '$(srcdir)/'`luatexdir/utils/avlstuff.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-directions.o `test -f 'directions.c' || echo '$(srcdir)/'`directions.c -libluatex_a-avlstuff.obj: luatexdir/utils/avlstuff.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avlstuff.obj -MD -MP -MF $(DEPDIR)/libluatex_a-avlstuff.Tpo -c -o libluatex_a-avlstuff.obj `if test -f 'luatexdir/utils/avlstuff.c'; then $(CYGPATH_W) 'luatexdir/utils/avlstuff.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/avlstuff.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avlstuff.Tpo $(DEPDIR)/libluatex_a-avlstuff.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/avlstuff.c' object='libluatex_a-avlstuff.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-directions.obj: directions.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-directions.obj -MD -MP -MF $(DEPDIR)/libluatex_a-directions.Tpo -c -o libluatex_a-directions.obj `if test -f 'directions.c'; then $(CYGPATH_W) 'directions.c'; else $(CYGPATH_W) '$(srcdir)/directions.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-directions.Tpo $(DEPDIR)/libluatex_a-directions.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='directions.c' object='libluatex_a-directions.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avlstuff.obj `if test -f 'luatexdir/utils/avlstuff.c'; then $(CYGPATH_W) 'luatexdir/utils/avlstuff.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/avlstuff.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-directions.obj `if test -f 'directions.c'; then $(CYGPATH_W) 'directions.c'; else $(CYGPATH_W) '$(srcdir)/directions.c'; fi` -libluatex_a-synctex.o: luatexdir/utils/synctex.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-synctex.o -MD -MP -MF $(DEPDIR)/libluatex_a-synctex.Tpo -c -o libluatex_a-synctex.o `test -f 'luatexdir/utils/synctex.c' || echo '$(srcdir)/'`luatexdir/utils/synctex.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-synctex.Tpo $(DEPDIR)/libluatex_a-synctex.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/synctex.c' object='libluatex_a-synctex.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-errors.o: errors.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-errors.o -MD -MP -MF $(DEPDIR)/libluatex_a-errors.Tpo -c -o libluatex_a-errors.o `test -f 'errors.c' || echo '$(srcdir)/'`errors.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-errors.Tpo $(DEPDIR)/libluatex_a-errors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='errors.c' object='libluatex_a-errors.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-synctex.o `test -f 'luatexdir/utils/synctex.c' || echo '$(srcdir)/'`luatexdir/utils/synctex.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-errors.o `test -f 'errors.c' || echo '$(srcdir)/'`errors.c -libluatex_a-synctex.obj: luatexdir/utils/synctex.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-synctex.obj -MD -MP -MF $(DEPDIR)/libluatex_a-synctex.Tpo -c -o libluatex_a-synctex.obj `if test -f 'luatexdir/utils/synctex.c'; then $(CYGPATH_W) 'luatexdir/utils/synctex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/synctex.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-synctex.Tpo $(DEPDIR)/libluatex_a-synctex.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/synctex.c' object='libluatex_a-synctex.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-errors.obj: errors.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-errors.obj -MD -MP -MF $(DEPDIR)/libluatex_a-errors.Tpo -c -o libluatex_a-errors.obj `if test -f 'errors.c'; then $(CYGPATH_W) 'errors.c'; else $(CYGPATH_W) '$(srcdir)/errors.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-errors.Tpo $(DEPDIR)/libluatex_a-errors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='errors.c' object='libluatex_a-errors.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-synctex.obj `if test -f 'luatexdir/utils/synctex.c'; then $(CYGPATH_W) 'luatexdir/utils/synctex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/synctex.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-errors.obj `if test -f 'errors.c'; then $(CYGPATH_W) 'errors.c'; else $(CYGPATH_W) '$(srcdir)/errors.c'; fi` + +libluatex_a-filename.o: filename.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-filename.o -MD -MP -MF $(DEPDIR)/libluatex_a-filename.Tpo -c -o libluatex_a-filename.o `test -f 'filename.c' || echo '$(srcdir)/'`filename.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-filename.Tpo $(DEPDIR)/libluatex_a-filename.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filename.c' object='libluatex_a-filename.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-filename.o `test -f 'filename.c' || echo '$(srcdir)/'`filename.c + +libluatex_a-filename.obj: filename.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-filename.obj -MD -MP -MF $(DEPDIR)/libluatex_a-filename.Tpo -c -o libluatex_a-filename.obj `if test -f 'filename.c'; then $(CYGPATH_W) 'filename.c'; else $(CYGPATH_W) '$(srcdir)/filename.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-filename.Tpo $(DEPDIR)/libluatex_a-filename.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filename.c' object='libluatex_a-filename.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-filename.obj `if test -f 'filename.c'; then $(CYGPATH_W) 'filename.c'; else $(CYGPATH_W) '$(srcdir)/filename.c'; fi` + +libluatex_a-mainbody.o: mainbody.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mainbody.o -MD -MP -MF $(DEPDIR)/libluatex_a-mainbody.Tpo -c -o libluatex_a-mainbody.o `test -f 'mainbody.c' || echo '$(srcdir)/'`mainbody.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mainbody.Tpo $(DEPDIR)/libluatex_a-mainbody.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mainbody.c' object='libluatex_a-mainbody.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mainbody.o `test -f 'mainbody.c' || echo '$(srcdir)/'`mainbody.c + +libluatex_a-mainbody.obj: mainbody.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-mainbody.obj -MD -MP -MF $(DEPDIR)/libluatex_a-mainbody.Tpo -c -o libluatex_a-mainbody.obj `if test -f 'mainbody.c'; then $(CYGPATH_W) 'mainbody.c'; else $(CYGPATH_W) '$(srcdir)/mainbody.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-mainbody.Tpo $(DEPDIR)/libluatex_a-mainbody.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mainbody.c' object='libluatex_a-mainbody.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-mainbody.obj `if test -f 'mainbody.c'; then $(CYGPATH_W) 'mainbody.c'; else $(CYGPATH_W) '$(srcdir)/mainbody.c'; fi` + +libluatex_a-memoryword.o: memoryword.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-memoryword.o -MD -MP -MF $(DEPDIR)/libluatex_a-memoryword.Tpo -c -o libluatex_a-memoryword.o `test -f 'memoryword.c' || echo '$(srcdir)/'`memoryword.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-memoryword.Tpo $(DEPDIR)/libluatex_a-memoryword.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='memoryword.c' object='libluatex_a-memoryword.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-memoryword.o `test -f 'memoryword.c' || echo '$(srcdir)/'`memoryword.c + +libluatex_a-memoryword.obj: memoryword.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-memoryword.obj -MD -MP -MF $(DEPDIR)/libluatex_a-memoryword.Tpo -c -o libluatex_a-memoryword.obj `if test -f 'memoryword.c'; then $(CYGPATH_W) 'memoryword.c'; else $(CYGPATH_W) '$(srcdir)/memoryword.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-memoryword.Tpo $(DEPDIR)/libluatex_a-memoryword.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='memoryword.c' object='libluatex_a-memoryword.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-memoryword.obj `if test -f 'memoryword.c'; then $(CYGPATH_W) 'memoryword.c'; else $(CYGPATH_W) '$(srcdir)/memoryword.c'; fi` + +libluatex_a-packaging.o: packaging.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-packaging.o -MD -MP -MF $(DEPDIR)/libluatex_a-packaging.Tpo -c -o libluatex_a-packaging.o `test -f 'packaging.c' || echo '$(srcdir)/'`packaging.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-packaging.Tpo $(DEPDIR)/libluatex_a-packaging.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='packaging.c' object='libluatex_a-packaging.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-packaging.o `test -f 'packaging.c' || echo '$(srcdir)/'`packaging.c + +libluatex_a-packaging.obj: packaging.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-packaging.obj -MD -MP -MF $(DEPDIR)/libluatex_a-packaging.Tpo -c -o libluatex_a-packaging.obj `if test -f 'packaging.c'; then $(CYGPATH_W) 'packaging.c'; else $(CYGPATH_W) '$(srcdir)/packaging.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-packaging.Tpo $(DEPDIR)/libluatex_a-packaging.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='packaging.c' object='libluatex_a-packaging.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-packaging.obj `if test -f 'packaging.c'; then $(CYGPATH_W) 'packaging.c'; else $(CYGPATH_W) '$(srcdir)/packaging.c'; fi` + +libluatex_a-printing.o: printing.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-printing.o -MD -MP -MF $(DEPDIR)/libluatex_a-printing.Tpo -c -o libluatex_a-printing.o `test -f 'printing.c' || echo '$(srcdir)/'`printing.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-printing.Tpo $(DEPDIR)/libluatex_a-printing.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='printing.c' object='libluatex_a-printing.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-printing.o `test -f 'printing.c' || echo '$(srcdir)/'`printing.c + +libluatex_a-printing.obj: printing.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-printing.obj -MD -MP -MF $(DEPDIR)/libluatex_a-printing.Tpo -c -o libluatex_a-printing.obj `if test -f 'printing.c'; then $(CYGPATH_W) 'printing.c'; else $(CYGPATH_W) '$(srcdir)/printing.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-printing.Tpo $(DEPDIR)/libluatex_a-printing.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='printing.c' object='libluatex_a-printing.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-printing.obj `if test -f 'printing.c'; then $(CYGPATH_W) 'printing.c'; else $(CYGPATH_W) '$(srcdir)/printing.c'; fi` + +libluatex_a-stringpool.o: stringpool.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-stringpool.o -MD -MP -MF $(DEPDIR)/libluatex_a-stringpool.Tpo -c -o libluatex_a-stringpool.o `test -f 'stringpool.c' || echo '$(srcdir)/'`stringpool.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-stringpool.Tpo $(DEPDIR)/libluatex_a-stringpool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='stringpool.c' object='libluatex_a-stringpool.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-stringpool.o `test -f 'stringpool.c' || echo '$(srcdir)/'`stringpool.c + +libluatex_a-stringpool.obj: stringpool.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-stringpool.obj -MD -MP -MF $(DEPDIR)/libluatex_a-stringpool.Tpo -c -o libluatex_a-stringpool.obj `if test -f 'stringpool.c'; then $(CYGPATH_W) 'stringpool.c'; else $(CYGPATH_W) '$(srcdir)/stringpool.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-stringpool.Tpo $(DEPDIR)/libluatex_a-stringpool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='stringpool.c' object='libluatex_a-stringpool.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-stringpool.obj `if test -f 'stringpool.c'; then $(CYGPATH_W) 'stringpool.c'; else $(CYGPATH_W) '$(srcdir)/stringpool.c'; fi` + +libluatex_a-texmath.o: texmath.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texmath.o -MD -MP -MF $(DEPDIR)/libluatex_a-texmath.Tpo -c -o libluatex_a-texmath.o `test -f 'texmath.c' || echo '$(srcdir)/'`texmath.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texmath.Tpo $(DEPDIR)/libluatex_a-texmath.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texmath.c' object='libluatex_a-texmath.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texmath.o `test -f 'texmath.c' || echo '$(srcdir)/'`texmath.c -libluatex_a-utils.o: luatexdir/utils/utils.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-utils.o -MD -MP -MF $(DEPDIR)/libluatex_a-utils.Tpo -c -o libluatex_a-utils.o `test -f 'luatexdir/utils/utils.c' || echo '$(srcdir)/'`luatexdir/utils/utils.c +libluatex_a-texmath.obj: texmath.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-texmath.obj -MD -MP -MF $(DEPDIR)/libluatex_a-texmath.Tpo -c -o libluatex_a-texmath.obj `if test -f 'texmath.c'; then $(CYGPATH_W) 'texmath.c'; else $(CYGPATH_W) '$(srcdir)/texmath.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-texmath.Tpo $(DEPDIR)/libluatex_a-texmath.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='texmath.c' object='libluatex_a-texmath.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-texmath.obj `if test -f 'texmath.c'; then $(CYGPATH_W) 'texmath.c'; else $(CYGPATH_W) '$(srcdir)/texmath.c'; fi` + +libluatex_a-textoken.o: textoken.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textoken.o -MD -MP -MF $(DEPDIR)/libluatex_a-textoken.Tpo -c -o libluatex_a-textoken.o `test -f 'textoken.c' || echo '$(srcdir)/'`textoken.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-textoken.Tpo $(DEPDIR)/libluatex_a-textoken.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='textoken.c' object='libluatex_a-textoken.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textoken.o `test -f 'textoken.c' || echo '$(srcdir)/'`textoken.c + +libluatex_a-textoken.obj: textoken.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-textoken.obj -MD -MP -MF $(DEPDIR)/libluatex_a-textoken.Tpo -c -o libluatex_a-textoken.obj `if test -f 'textoken.c'; then $(CYGPATH_W) 'textoken.c'; else $(CYGPATH_W) '$(srcdir)/textoken.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-textoken.Tpo $(DEPDIR)/libluatex_a-textoken.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='textoken.c' object='libluatex_a-textoken.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-textoken.obj `if test -f 'textoken.c'; then $(CYGPATH_W) 'textoken.c'; else $(CYGPATH_W) '$(srcdir)/textoken.c'; fi` + +libluatex_a-utils.o: utils.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-utils.o -MD -MP -MF $(DEPDIR)/libluatex_a-utils.Tpo -c -o libluatex_a-utils.o `test -f 'utils.c' || echo '$(srcdir)/'`utils.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-utils.Tpo $(DEPDIR)/libluatex_a-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/utils.c' object='libluatex_a-utils.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='utils.c' object='libluatex_a-utils.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-utils.o `test -f 'luatexdir/utils/utils.c' || echo '$(srcdir)/'`luatexdir/utils/utils.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-utils.o `test -f 'utils.c' || echo '$(srcdir)/'`utils.c -libluatex_a-utils.obj: luatexdir/utils/utils.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-utils.obj -MD -MP -MF $(DEPDIR)/libluatex_a-utils.Tpo -c -o libluatex_a-utils.obj `if test -f 'luatexdir/utils/utils.c'; then $(CYGPATH_W) 'luatexdir/utils/utils.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/utils.c'; fi` +libluatex_a-utils.obj: utils.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-utils.obj -MD -MP -MF $(DEPDIR)/libluatex_a-utils.Tpo -c -o libluatex_a-utils.obj `if test -f 'utils.c'; then $(CYGPATH_W) 'utils.c'; else $(CYGPATH_W) '$(srcdir)/utils.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-utils.Tpo $(DEPDIR)/libluatex_a-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/utils.c' object='libluatex_a-utils.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='utils.c' object='libluatex_a-utils.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-utils.obj `if test -f 'utils.c'; then $(CYGPATH_W) 'utils.c'; else $(CYGPATH_W) '$(srcdir)/utils.c'; fi` + +libluatex_a-avlstuff.o: avlstuff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avlstuff.o -MD -MP -MF $(DEPDIR)/libluatex_a-avlstuff.Tpo -c -o libluatex_a-avlstuff.o `test -f 'avlstuff.c' || echo '$(srcdir)/'`avlstuff.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avlstuff.Tpo $(DEPDIR)/libluatex_a-avlstuff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='avlstuff.c' object='libluatex_a-avlstuff.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avlstuff.o `test -f 'avlstuff.c' || echo '$(srcdir)/'`avlstuff.c + +libluatex_a-avlstuff.obj: avlstuff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-avlstuff.obj -MD -MP -MF $(DEPDIR)/libluatex_a-avlstuff.Tpo -c -o libluatex_a-avlstuff.obj `if test -f 'avlstuff.c'; then $(CYGPATH_W) 'avlstuff.c'; else $(CYGPATH_W) '$(srcdir)/avlstuff.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-avlstuff.Tpo $(DEPDIR)/libluatex_a-avlstuff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='avlstuff.c' object='libluatex_a-avlstuff.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-utils.obj `if test -f 'luatexdir/utils/utils.c'; then $(CYGPATH_W) 'luatexdir/utils/utils.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/utils.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-avlstuff.obj `if test -f 'avlstuff.c'; then $(CYGPATH_W) 'avlstuff.c'; else $(CYGPATH_W) '$(srcdir)/avlstuff.c'; fi` -libluatex_a-writezip.o: luatexdir/utils/writezip.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writezip.o -MD -MP -MF $(DEPDIR)/libluatex_a-writezip.Tpo -c -o libluatex_a-writezip.o `test -f 'luatexdir/utils/writezip.c' || echo '$(srcdir)/'`luatexdir/utils/writezip.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writezip.Tpo $(DEPDIR)/libluatex_a-writezip.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/writezip.c' object='libluatex_a-writezip.o' libtool=no @AMDEPBACKSLASH@ +libluatex_a-managed-sa.o: managed-sa.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-managed-sa.o -MD -MP -MF $(DEPDIR)/libluatex_a-managed-sa.Tpo -c -o libluatex_a-managed-sa.o `test -f 'managed-sa.c' || echo '$(srcdir)/'`managed-sa.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-managed-sa.Tpo $(DEPDIR)/libluatex_a-managed-sa.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='managed-sa.c' object='libluatex_a-managed-sa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writezip.o `test -f 'luatexdir/utils/writezip.c' || echo '$(srcdir)/'`luatexdir/utils/writezip.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-managed-sa.o `test -f 'managed-sa.c' || echo '$(srcdir)/'`managed-sa.c -libluatex_a-writezip.obj: luatexdir/utils/writezip.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-writezip.obj -MD -MP -MF $(DEPDIR)/libluatex_a-writezip.Tpo -c -o libluatex_a-writezip.obj `if test -f 'luatexdir/utils/writezip.c'; then $(CYGPATH_W) 'luatexdir/utils/writezip.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/writezip.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-writezip.Tpo $(DEPDIR)/libluatex_a-writezip.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/utils/writezip.c' object='libluatex_a-writezip.obj' libtool=no @AMDEPBACKSLASH@ +libluatex_a-managed-sa.obj: managed-sa.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-managed-sa.obj -MD -MP -MF $(DEPDIR)/libluatex_a-managed-sa.Tpo -c -o libluatex_a-managed-sa.obj `if test -f 'managed-sa.c'; then $(CYGPATH_W) 'managed-sa.c'; else $(CYGPATH_W) '$(srcdir)/managed-sa.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-managed-sa.Tpo $(DEPDIR)/libluatex_a-managed-sa.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='managed-sa.c' object='libluatex_a-managed-sa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-writezip.obj `if test -f 'luatexdir/utils/writezip.c'; then $(CYGPATH_W) 'luatexdir/utils/writezip.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/utils/writezip.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-managed-sa.obj `if test -f 'managed-sa.c'; then $(CYGPATH_W) 'managed-sa.c'; else $(CYGPATH_W) '$(srcdir)/managed-sa.c'; fi` libluatex_a-lmplib.o: mplibdir/lmplib.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-lmplib.o -MD -MP -MF $(DEPDIR)/libluatex_a-lmplib.Tpo -c -o libluatex_a-lmplib.o `test -f 'mplibdir/lmplib.c' || echo '$(srcdir)/'`mplibdir/lmplib.c @@ -5404,20 +6220,6 @@ libluatex_a-lmplib.obj: mplibdir/lmplib.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-lmplib.obj `if test -f 'mplibdir/lmplib.c'; then $(CYGPATH_W) 'mplibdir/lmplib.c'; else $(CYGPATH_W) '$(srcdir)/mplibdir/lmplib.c'; fi` -libluatex_a-macnames.o: luatexdir/font/macnames.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-macnames.o -MD -MP -MF $(DEPDIR)/libluatex_a-macnames.Tpo -c -o libluatex_a-macnames.o `test -f 'luatexdir/font/macnames.c' || echo '$(srcdir)/'`luatexdir/font/macnames.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-macnames.Tpo $(DEPDIR)/libluatex_a-macnames.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/macnames.c' object='libluatex_a-macnames.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-macnames.o `test -f 'luatexdir/font/macnames.c' || echo '$(srcdir)/'`luatexdir/font/macnames.c - -libluatex_a-macnames.obj: luatexdir/font/macnames.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -MT libluatex_a-macnames.obj -MD -MP -MF $(DEPDIR)/libluatex_a-macnames.Tpo -c -o libluatex_a-macnames.obj `if test -f 'luatexdir/font/macnames.c'; then $(CYGPATH_W) 'luatexdir/font/macnames.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/macnames.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-macnames.Tpo $(DEPDIR)/libluatex_a-macnames.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/font/macnames.c' object='libluatex_a-macnames.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CFLAGS) $(CFLAGS) -c -o libluatex_a-macnames.obj `if test -f 'luatexdir/font/macnames.c'; then $(CYGPATH_W) 'luatexdir/font/macnames.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/font/macnames.c'; fi` - libmd5_a-md5.o: libmd5/md5.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmd5_a_CPPFLAGS) $(CPPFLAGS) $(libmd5_a_CFLAGS) $(CFLAGS) -MT libmd5_a-md5.o -MD -MP -MF $(DEPDIR)/libmd5_a-md5.Tpo -c -o libmd5_a-md5.o `test -f 'libmd5/md5.c' || echo '$(srcdir)/'`libmd5/md5.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libmd5_a-md5.Tpo $(DEPDIR)/libmd5_a-md5.Po @@ -6244,61 +7046,19 @@ etex-synctex-e.obj: synctex-e.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(etex_CPPFLAGS) $(CPPFLAGS) $(etex_CFLAGS) $(CFLAGS) -c -o etex-synctex-e.obj `if test -f 'synctex-e.c'; then $(CYGPATH_W) 'synctex-e.c'; else $(CYGPATH_W) '$(srcdir)/synctex-e.c'; fi` -luatex-luatexini.o: luatexini.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatexini.o -MD -MP -MF $(DEPDIR)/luatex-luatexini.Tpo -c -o luatex-luatexini.o `test -f 'luatexini.c' || echo '$(srcdir)/'`luatexini.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatexini.Tpo $(DEPDIR)/luatex-luatexini.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexini.c' object='luatex-luatexini.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatexini.o `test -f 'luatexini.c' || echo '$(srcdir)/'`luatexini.c - -luatex-luatexini.obj: luatexini.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatexini.obj -MD -MP -MF $(DEPDIR)/luatex-luatexini.Tpo -c -o luatex-luatexini.obj `if test -f 'luatexini.c'; then $(CYGPATH_W) 'luatexini.c'; else $(CYGPATH_W) '$(srcdir)/luatexini.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatexini.Tpo $(DEPDIR)/luatex-luatexini.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexini.c' object='luatex-luatexini.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatexini.obj `if test -f 'luatexini.c'; then $(CYGPATH_W) 'luatexini.c'; else $(CYGPATH_W) '$(srcdir)/luatexini.c'; fi` - -luatex-luatex0.o: luatex0.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatex0.o -MD -MP -MF $(DEPDIR)/luatex-luatex0.Tpo -c -o luatex-luatex0.o `test -f 'luatex0.c' || echo '$(srcdir)/'`luatex0.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatex0.Tpo $(DEPDIR)/luatex-luatex0.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatex0.c' object='luatex-luatex0.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatex0.o `test -f 'luatex0.c' || echo '$(srcdir)/'`luatex0.c - -luatex-luatex0.obj: luatex0.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatex0.obj -MD -MP -MF $(DEPDIR)/luatex-luatex0.Tpo -c -o luatex-luatex0.obj `if test -f 'luatex0.c'; then $(CYGPATH_W) 'luatex0.c'; else $(CYGPATH_W) '$(srcdir)/luatex0.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatex0.Tpo $(DEPDIR)/luatex-luatex0.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatex0.c' object='luatex-luatex0.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatex0.obj `if test -f 'luatex0.c'; then $(CYGPATH_W) 'luatex0.c'; else $(CYGPATH_W) '$(srcdir)/luatex0.c'; fi` - -luatex-luatex-pool.o: luatex-pool.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatex-pool.o -MD -MP -MF $(DEPDIR)/luatex-luatex-pool.Tpo -c -o luatex-luatex-pool.o `test -f 'luatex-pool.c' || echo '$(srcdir)/'`luatex-pool.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatex-pool.Tpo $(DEPDIR)/luatex-luatex-pool.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatex-pool.c' object='luatex-luatex-pool.o' libtool=no @AMDEPBACKSLASH@ +luatex-luatex.o: luatexdir/luatex.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatex.o -MD -MP -MF $(DEPDIR)/luatex-luatex.Tpo -c -o luatex-luatex.o `test -f 'luatexdir/luatex.c' || echo '$(srcdir)/'`luatexdir/luatex.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatex.Tpo $(DEPDIR)/luatex-luatex.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luatex.c' object='luatex-luatex.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatex-pool.o `test -f 'luatex-pool.c' || echo '$(srcdir)/'`luatex-pool.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatex.o `test -f 'luatexdir/luatex.c' || echo '$(srcdir)/'`luatexdir/luatex.c -luatex-luatex-pool.obj: luatex-pool.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatex-pool.obj -MD -MP -MF $(DEPDIR)/luatex-luatex-pool.Tpo -c -o luatex-luatex-pool.obj `if test -f 'luatex-pool.c'; then $(CYGPATH_W) 'luatex-pool.c'; else $(CYGPATH_W) '$(srcdir)/luatex-pool.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatex-pool.Tpo $(DEPDIR)/luatex-luatex-pool.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatex-pool.c' object='luatex-luatex-pool.obj' libtool=no @AMDEPBACKSLASH@ +luatex-luatex.obj: luatexdir/luatex.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatex.obj -MD -MP -MF $(DEPDIR)/luatex-luatex.Tpo -c -o luatex-luatex.obj `if test -f 'luatexdir/luatex.c'; then $(CYGPATH_W) 'luatexdir/luatex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luatex.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatex.Tpo $(DEPDIR)/luatex-luatex.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexdir/luatex.c' object='luatex-luatex.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatex-pool.obj `if test -f 'luatex-pool.c'; then $(CYGPATH_W) 'luatex-pool.c'; else $(CYGPATH_W) '$(srcdir)/luatex-pool.c'; fi` - -luatex-luatexextra.o: luatexextra.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatexextra.o -MD -MP -MF $(DEPDIR)/luatex-luatexextra.Tpo -c -o luatex-luatexextra.o `test -f 'luatexextra.c' || echo '$(srcdir)/'`luatexextra.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatexextra.Tpo $(DEPDIR)/luatex-luatexextra.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexextra.c' object='luatex-luatexextra.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatexextra.o `test -f 'luatexextra.c' || echo '$(srcdir)/'`luatexextra.c - -luatex-luatexextra.obj: luatexextra.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -MT luatex-luatexextra.obj -MD -MP -MF $(DEPDIR)/luatex-luatexextra.Tpo -c -o luatex-luatexextra.obj `if test -f 'luatexextra.c'; then $(CYGPATH_W) 'luatexextra.c'; else $(CYGPATH_W) '$(srcdir)/luatexextra.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/luatex-luatexextra.Tpo $(DEPDIR)/luatex-luatexextra.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='luatexextra.c' object='luatex-luatexextra.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatexextra.obj `if test -f 'luatexextra.c'; then $(CYGPATH_W) 'luatexextra.c'; else $(CYGPATH_W) '$(srcdir)/luatexextra.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luatex_CPPFLAGS) $(CPPFLAGS) $(luatex_CFLAGS) $(CFLAGS) -c -o luatex-luatex.obj `if test -f 'luatexdir/luatex.c'; then $(CYGPATH_W) 'luatexdir/luatex.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/luatex.c'; fi` md5main-md5main.o: libmd5/md5main.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(md5main_CPPFLAGS) $(CPPFLAGS) $(md5main_CFLAGS) $(CFLAGS) -MT md5main-md5main.o -MD -MP -MF $(DEPDIR)/md5main-md5main.Tpo -c -o md5main-md5main.o `test -f 'libmd5/md5main.c' || echo '$(srcdir)/'`libmd5/md5main.c @@ -6699,6 +7459,20 @@ libluatex_a-pdftoepdf.obj: luatexdir/image/pdftoepdf.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CXXFLAGS) $(CXXFLAGS) -c -o libluatex_a-pdftoepdf.obj `if test -f 'luatexdir/image/pdftoepdf.cc'; then $(CYGPATH_W) 'luatexdir/image/pdftoepdf.cc'; else $(CYGPATH_W) '$(srcdir)/luatexdir/image/pdftoepdf.cc'; fi` +libluatex_a-lepdflib.o: luatexdir/lua/lepdflib.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CXXFLAGS) $(CXXFLAGS) -MT libluatex_a-lepdflib.o -MD -MP -MF $(DEPDIR)/libluatex_a-lepdflib.Tpo -c -o libluatex_a-lepdflib.o `test -f 'luatexdir/lua/lepdflib.cc' || echo '$(srcdir)/'`luatexdir/lua/lepdflib.cc +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-lepdflib.Tpo $(DEPDIR)/libluatex_a-lepdflib.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='luatexdir/lua/lepdflib.cc' object='libluatex_a-lepdflib.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CXXFLAGS) $(CXXFLAGS) -c -o libluatex_a-lepdflib.o `test -f 'luatexdir/lua/lepdflib.cc' || echo '$(srcdir)/'`luatexdir/lua/lepdflib.cc + +libluatex_a-lepdflib.obj: luatexdir/lua/lepdflib.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CXXFLAGS) $(CXXFLAGS) -MT libluatex_a-lepdflib.obj -MD -MP -MF $(DEPDIR)/libluatex_a-lepdflib.Tpo -c -o libluatex_a-lepdflib.obj `if test -f 'luatexdir/lua/lepdflib.cc'; then $(CYGPATH_W) 'luatexdir/lua/lepdflib.cc'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/lepdflib.cc'; fi` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libluatex_a-lepdflib.Tpo $(DEPDIR)/libluatex_a-lepdflib.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='luatexdir/lua/lepdflib.cc' object='libluatex_a-lepdflib.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluatex_a_CPPFLAGS) $(CPPFLAGS) $(libluatex_a_CXXFLAGS) $(CXXFLAGS) -c -o libluatex_a-lepdflib.obj `if test -f 'luatexdir/lua/lepdflib.cc'; then $(CYGPATH_W) 'luatexdir/lua/lepdflib.cc'; else $(CYGPATH_W) '$(srcdir)/luatexdir/lua/lepdflib.cc'; fi` + libpdftex_a-pdftoepdf.o: pdftexdir/pdftoepdf.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpdftex_a_CPPFLAGS) $(CPPFLAGS) $(libpdftex_a_CXXFLAGS) $(CXXFLAGS) -MT libpdftex_a-pdftoepdf.o -MD -MP -MF $(DEPDIR)/libpdftex_a-pdftoepdf.Tpo -c -o libpdftex_a-pdftoepdf.o `test -f 'pdftexdir/pdftoepdf.cc' || echo '$(srcdir)/'`pdftexdir/pdftoepdf.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libpdftex_a-pdftoepdf.Tpo $(DEPDIR)/libpdftex_a-pdftoepdf.Po @@ -7099,7 +7873,7 @@ uninstall-man5: # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ + @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -7124,7 +7898,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ + @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -7396,8 +8170,7 @@ distdir: $(DISTFILES) top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ + || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ @@ -7441,17 +8214,17 @@ dist dist-all: distdir distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ - lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ + unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac @@ -8041,28 +8814,7 @@ $(libpdftex_a_OBJECTS): pdftexd.h $(XPDF_DEPEND) $(ZLIB_DEPEND) $(LIBPNG_DEPEND) $(pdftosrc_OBJECTS): $(ZLIB_DEPEND) $(LIBPNG_DEPEND) $(XPDF_DEPEND) $(OBSDCOMPAT_DEPEND) -# We must create libluatex.a and libmplib.a before building the luatex_OBJECTS. $(luatex_OBJECTS): libluatex.a libmplib.a -$(luatex_c_h): luatex-web2c - @$(web2c) luatex -luatex-web2c: luatex.p $(web2c_texmf) luatexdir/luatex.defines - @$(web2c) luatex -luatexextra.c: luatexd.h luatexdir/luatexextra.h lib/texmfmp.c - sed s/TEX-OR-MF-OR-MP/luatex/ $(srcdir)/lib/texmfmp.c >$@ -luatex.p luatex.pool: luatex-tangle - @$(luatex_tangle) luatex luatex -luatex-tangle: luatangle$(EXEEXT) $(luatex_sources) tangle-sh - @$(luatex_tangle) luatex luatex -luatex-pool.c: luatex.pool luatexd.h $(makecpool_stamp) - $(makecpool) luatex >$@ || rm -f $@ -# Extract luatex version -luatexdir/luatex.version: luatexdir/luatex.web - $(MKDIR_P) luatexdir - grep '^@d luatex_version_string==' $(srcdir)/luatexdir/luatex.web \ - | sed "s/^.*=='//;s/'.*$$//" >luatexdir/luatex.version -luatexdir/luatexextra.h: luatexdir/luatexextra.in luatexdir/luatex.version - sed -e s/LUATEX-VERSION/`cat luatexdir/luatex.version`/ \ - $(srcdir)/luatexdir/luatexextra.in >$@ # Double-colon rules since we do something similar in mplibdir (maybe others). @LUATEX_TRUE@install-exec-hook:: @@ -8073,12 +8825,6 @@ luatexdir/luatexextra.h: luatexdir/luatexextra.in luatexdir/luatex.version @LUATEX_TRUE@uninstall-hook:: @LUATEX_TRUE@ rm -f $(DESTDIR)$(bindir)/texlua$(EXEEXT) @LUATEX_TRUE@ rm -f $(DESTDIR)$(bindir)/texluac$(EXEEXT) -luatangle.c luatangle.h: luatangle-web2c - @$(web2c) luatangle -luatangle-web2c: luatangle.p $(web2c_depend) - @$(web2c) luatangle -luatangle.p: tangle$(EXEEXT) $(luatangle_sources) - WEBINPUTS=$(srcdir)/luatexdir $(buildenv) $(TANGLE) luatangle luatangle $(libluasocket_a_OBJECTS): liblua51.a @@ -8086,8 +8832,267 @@ $(libluamisc_a_OBJECTS): $(libluamisc_a_DEPENDENCIES) $(libff_a_OBJECTS): $(libff_a_DEPENDENCIES) -# We must create libff.a and luatexd.h before building the libluatex_a_OBJECTS -$(libluatex_a_OBJECTS): libff.a luatexd.h luatexdir/luatexextra.h +dvigen.c: ctangle$(EXEEXT) luatexdir/dvi/dvigen.w + $(luatex_dvi_ctangle) dvigen.w + +dofont.c: ctangle$(EXEEXT) luatexdir/font/dofont.w + $(luatex_font_ctangle) dofont.w +luafont.c: ctangle$(EXEEXT) luatexdir/font/luafont.w + $(luatex_font_ctangle) luafont.w +mapfile.c: ctangle$(EXEEXT) luatexdir/font/mapfile.w + $(luatex_font_ctangle) mapfile.w +pkin.c: ctangle$(EXEEXT) luatexdir/font/pkin.w + $(luatex_font_ctangle) pkin.w +sfnt.c: ctangle$(EXEEXT) luatexdir/font/sfnt.w + $(luatex_font_ctangle) sfnt.w +subfont.c: ctangle$(EXEEXT) luatexdir/font/subfont.w + $(luatex_font_ctangle) subfont.w +texfont.c: ctangle$(EXEEXT) luatexdir/font/texfont.w + $(luatex_font_ctangle) texfont.w +tfmofm.c: ctangle$(EXEEXT) luatexdir/font/tfmofm.w + $(luatex_font_ctangle) tfmofm.w +tounicode.c: ctangle$(EXEEXT) luatexdir/font/tounicode.w + $(luatex_font_ctangle) tounicode.w +tt_glyf.c: ctangle$(EXEEXT) luatexdir/font/tt_glyf.w + $(luatex_font_ctangle) tt_glyf.w +tt_table.c: ctangle$(EXEEXT) luatexdir/font/tt_table.w + $(luatex_font_ctangle) tt_table.w +vfovf.c: ctangle$(EXEEXT) luatexdir/font/vfovf.w + $(luatex_font_ctangle) vfovf.w +vfpacket.c: ctangle$(EXEEXT) luatexdir/font/vfpacket.w + $(luatex_font_ctangle) vfpacket.w +writecff.c: ctangle$(EXEEXT) luatexdir/font/writecff.w + $(luatex_font_ctangle) writecff.w +writeenc.c: ctangle$(EXEEXT) luatexdir/font/writeenc.w + $(luatex_font_ctangle) writeenc.w +writefont.c: ctangle$(EXEEXT) luatexdir/font/writefont.w + $(luatex_font_ctangle) writefont.w +writet1.c: ctangle$(EXEEXT) luatexdir/font/writet1.w + $(luatex_font_ctangle) writet1.w +writet3.c: ctangle$(EXEEXT) luatexdir/font/writet3.w + $(luatex_font_ctangle) writet3.w +writettf.c: ctangle$(EXEEXT) luatexdir/font/writettf.w + $(luatex_font_ctangle) writettf.w +writetype0.c: ctangle$(EXEEXT) luatexdir/font/writetype0.w + $(luatex_font_ctangle) writetype0.w +writetype2.c: ctangle$(EXEEXT) luatexdir/font/writetype2.w + $(luatex_font_ctangle) writetype2.w + +epdf.c: ctangle$(EXEEXT) luatexdir/image/epdf.w + $(luatex_image_ctangle) epdf.w +writeimg.c: ctangle$(EXEEXT) luatexdir/image/writeimg.w + $(luatex_image_ctangle) writeimg.w +writejbig2.c: ctangle$(EXEEXT) luatexdir/image/writejbig2.w + $(luatex_image_ctangle) writejbig2.w +writejpg.c: ctangle$(EXEEXT) luatexdir/image/writejpg.w + $(luatex_image_ctangle) writejpg.w +writepng.c: ctangle$(EXEEXT) luatexdir/image/writepng.w + $(luatex_image_ctangle) writepng.w + +luagen.c: ctangle$(EXEEXT) luatexdir/lua/luagen.w + $(luatex_lua_ctangle) luagen.w +luainit.c: ctangle$(EXEEXT) luatexdir/lua/luainit.w + $(luatex_lua_ctangle) luainit.w +luanode.c: ctangle$(EXEEXT) luatexdir/lua/luanode.w + $(luatex_lua_ctangle) luanode.w +luastuff.c: ctangle$(EXEEXT) luatexdir/lua/luastuff.w + $(luatex_lua_ctangle) luastuff.w +luatoken.c: ctangle$(EXEEXT) luatexdir/lua/luatoken.w + $(luatex_lua_ctangle) luatoken.w +texluac.c: ctangle$(EXEEXT) luatexdir/lua/texluac.w + $(luatex_lua_ctangle) texluac.w + +ocp.c: ctangle$(EXEEXT) luatexdir/ocp/ocp.w + $(luatex_ocp_ctangle) ocp.w + +runocp.c: ctangle$(EXEEXT) luatexdir/ocp/runocp.w + $(luatex_ocp_ctangle) runocp.w + +readocp.c: ctangle$(EXEEXT) luatexdir/ocp/readocp.w + $(luatex_ocp_ctangle) readocp.w + +ocplist.c: ctangle$(EXEEXT) luatexdir/ocp/ocplist.w + $(luatex_ocp_ctangle) ocplist.w + +hnjalloc.c: ctangle$(EXEEXT) luatexdir/lang/hnjalloc.w + $(luatex_lang_ctangle) hnjalloc.w + +hyphen.c: ctangle$(EXEEXT) luatexdir/lang/hyphen.w + $(luatex_lang_ctangle) hyphen.w + +texlang.c: ctangle$(EXEEXT) luatexdir/lang/texlang.w + $(luatex_lang_ctangle) texlang.w + +pagetree.c: ctangle$(EXEEXT) luatexdir/pdf/pagetree.w + $(luatex_pdf_ctangle) pagetree.w + +pdfaction.c: ctangle$(EXEEXT) luatexdir/pdf/pdfaction.w + $(luatex_pdf_ctangle) pdfaction.w + +pdfannot.c: ctangle$(EXEEXT) luatexdir/pdf/pdfannot.w + $(luatex_pdf_ctangle) pdfannot.w + +pdfcolorstack.c: ctangle$(EXEEXT) luatexdir/pdf/pdfcolorstack.w + $(luatex_pdf_ctangle) pdfcolorstack.w + +pdfdest.c: ctangle$(EXEEXT) luatexdir/pdf/pdfdest.w + $(luatex_pdf_ctangle) pdfdest.w + +pdffont.c: ctangle$(EXEEXT) luatexdir/pdf/pdffont.w + $(luatex_pdf_ctangle) pdffont.w + +pdfgen.c: ctangle$(EXEEXT) luatexdir/pdf/pdfgen.w + $(luatex_pdf_ctangle) pdfgen.w + +pdfglyph.c: ctangle$(EXEEXT) luatexdir/pdf/pdfglyph.w + $(luatex_pdf_ctangle) pdfglyph.w + +pdfimage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfimage.w + $(luatex_pdf_ctangle) pdfimage.w + +pdflink.c: ctangle$(EXEEXT) luatexdir/pdf/pdflink.w + $(luatex_pdf_ctangle) pdflink.w + +pdflistout.c: ctangle$(EXEEXT) luatexdir/pdf/pdflistout.w + $(luatex_pdf_ctangle) pdflistout.w + +pdfliteral.c: ctangle$(EXEEXT) luatexdir/pdf/pdfliteral.w + $(luatex_pdf_ctangle) pdfliteral.w + +pdfobj.c: ctangle$(EXEEXT) luatexdir/pdf/pdfobj.w + $(luatex_pdf_ctangle) pdfobj.w + +pdfoutline.c: ctangle$(EXEEXT) luatexdir/pdf/pdfoutline.w + $(luatex_pdf_ctangle) pdfoutline.w + +pdfpage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfpage.w + $(luatex_pdf_ctangle) pdfpage.w + +pdfrule.c: ctangle$(EXEEXT) luatexdir/pdf/pdfrule.w + $(luatex_pdf_ctangle) pdfrule.w + +pdfsaverestore.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsaverestore.w + $(luatex_pdf_ctangle) pdfsaverestore.w + +pdfsetmatrix.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsetmatrix.w + $(luatex_pdf_ctangle) pdfsetmatrix.w + +pdfshipout.c: ctangle$(EXEEXT) luatexdir/pdf/pdfshipout.w + $(luatex_pdf_ctangle) pdfshipout.w + +pdftables.c: ctangle$(EXEEXT) luatexdir/pdf/pdftables.w + $(luatex_pdf_ctangle) pdftables.w + +pdfthread.c: ctangle$(EXEEXT) luatexdir/pdf/pdfthread.w + $(luatex_pdf_ctangle) pdfthread.w + +pdfxform.c: ctangle$(EXEEXT) luatexdir/pdf/pdfxform.w + $(luatex_pdf_ctangle) pdfxform.w + +align.c: ctangle$(EXEEXT) luatexdir/tex/align.w + $(luatex_tex_ctangle) align.w + +dumpdata.c: ctangle$(EXEEXT) luatexdir/tex/dumpdata.w + $(luatex_tex_ctangle) dumpdata.w + +expand.c: ctangle$(EXEEXT) luatexdir/tex/expand.w + $(luatex_tex_ctangle) expand.w + +inputstack.c: ctangle$(EXEEXT) luatexdir/tex/inputstack.w + $(luatex_tex_ctangle) inputstack.w + +maincontrol.c: ctangle$(EXEEXT) luatexdir/tex/maincontrol.w + $(luatex_tex_ctangle) maincontrol.w + +mlist.c: ctangle$(EXEEXT) luatexdir/tex/mlist.w + $(luatex_tex_ctangle) mlist.w + +postlinebreak.c: ctangle$(EXEEXT) luatexdir/tex/postlinebreak.w + $(luatex_tex_ctangle) postlinebreak.w + +scanning.c: ctangle$(EXEEXT) luatexdir/tex/scanning.w + $(luatex_tex_ctangle) scanning.w + +texdeffont.c: ctangle$(EXEEXT) luatexdir/tex/texdeffont.w + $(luatex_tex_ctangle) texdeffont.w + +texnodes.c: ctangle$(EXEEXT) luatexdir/tex/texnodes.w + $(luatex_tex_ctangle) texnodes.w + +arithmetic.c: ctangle$(EXEEXT) luatexdir/tex/arithmetic.w + $(luatex_tex_ctangle) arithmetic.w + +conditional.c: ctangle$(EXEEXT) luatexdir/tex/conditional.w + $(luatex_tex_ctangle) conditional.w + +equivalents.c: ctangle$(EXEEXT) luatexdir/tex/equivalents.w + $(luatex_tex_ctangle) equivalents.w + +extensions.c: ctangle$(EXEEXT) luatexdir/tex/extensions.w + $(luatex_tex_ctangle) extensions.w + +commands.c: ctangle$(EXEEXT) luatexdir/tex/commands.w + $(luatex_tex_ctangle) commands.w + +linebreak.c: ctangle$(EXEEXT) luatexdir/tex/linebreak.w + $(luatex_tex_ctangle) linebreak.w + +mathcodes.c: ctangle$(EXEEXT) luatexdir/tex/mathcodes.w + $(luatex_tex_ctangle) mathcodes.w + +nesting.c: ctangle$(EXEEXT) luatexdir/tex/nesting.w + $(luatex_tex_ctangle) nesting.w + +primitive.c: ctangle$(EXEEXT) luatexdir/tex/primitive.w + $(luatex_tex_ctangle) primitive.w + +texfileio.c: ctangle$(EXEEXT) luatexdir/tex/texfileio.w + $(luatex_tex_ctangle) texfileio.w + +textcodes.c: ctangle$(EXEEXT) luatexdir/tex/textcodes.w + $(luatex_tex_ctangle) textcodes.w + +buildpage.c: ctangle$(EXEEXT) luatexdir/tex/buildpage.w + $(luatex_tex_ctangle) buildpage.w + +directions.c: ctangle$(EXEEXT) luatexdir/tex/directions.w + $(luatex_tex_ctangle) directions.w + +errors.c: ctangle$(EXEEXT) luatexdir/tex/errors.w + $(luatex_tex_ctangle) errors.w + +filename.c: ctangle$(EXEEXT) luatexdir/tex/filename.w + $(luatex_tex_ctangle) filename.w + +mainbody.c: ctangle$(EXEEXT) luatexdir/tex/mainbody.w + $(luatex_tex_ctangle) mainbody.w + +memoryword.c: ctangle$(EXEEXT) luatexdir/tex/memoryword.w + $(luatex_tex_ctangle) memoryword.w + +packaging.c: ctangle$(EXEEXT) luatexdir/tex/packaging.w + $(luatex_tex_ctangle) packaging.w + +printing.c: ctangle$(EXEEXT) luatexdir/tex/printing.w + $(luatex_tex_ctangle) printing.w + +stringpool.c: ctangle$(EXEEXT) luatexdir/tex/stringpool.w + $(luatex_tex_ctangle) stringpool.w + +texmath.c: ctangle$(EXEEXT) luatexdir/tex/texmath.w + $(luatex_tex_ctangle) texmath.w + +textoken.c: ctangle$(EXEEXT) luatexdir/tex/textoken.w + $(luatex_tex_ctangle) textoken.w + +utils.c: ctangle$(EXEEXT) luatexdir/utils/utils.w + $(luatex_utils_ctangle) utils.w +managed-sa.c: ctangle$(EXEEXT) luatexdir/utils/managed-sa.w + $(luatex_utils_ctangle) managed-sa.w +avlstuff.c: ctangle$(EXEEXT) luatexdir/utils/avlstuff.w + $(luatex_utils_ctangle) avlstuff.w + +$(libluatex_a_OBJECTS): libff.a $(xetex_OBJECTS): $(xetex_prereq) $(xetex_c_h): xetex-web2c diff --git a/Build/source/texk/web2c/aclocal.m4 b/Build/source/texk/web2c/aclocal.m4 index 7fe1e663592..ed964362b42 100644 --- a/Build/source/texk/web2c/aclocal.m4 +++ b/Build/source/texk/web2c/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# generated automatically by aclocal 1.11 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. @@ -19,115 +19,804 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# longlong.m4 serial 13 -dnl Copyright (C) 1999-2007 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. +# ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*- +# +# Copyright (C) 1999-2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Thomas Tanner, 1999 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 17 LTDL_INIT + +# LT_CONFIG_LTDL_DIR(DIRECTORY, [LTDL-MODE]) +# ------------------------------------------ +# DIRECTORY contains the libltdl sources. It is okay to call this +# function multiple times, as long as the same DIRECTORY is always given. +AC_DEFUN([LT_CONFIG_LTDL_DIR], +[AC_BEFORE([$0], [LTDL_INIT]) +_$0($*) +])# LT_CONFIG_LTDL_DIR + +# We break this out into a separate macro, so that we can call it safely +# internally without being caught accidentally by the sed scan in libtoolize. +m4_defun([_LT_CONFIG_LTDL_DIR], +[dnl remove trailing slashes +m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$])) +m4_case(_LTDL_DIR, + [], [dnl only set lt_ltdl_dir if _ARG_DIR is not simply `.' + m4_if(_ARG_DIR, [.], + [], + [m4_define([_LTDL_DIR], _ARG_DIR) + _LT_SHELL_INIT([lt_ltdl_dir=']_ARG_DIR['])])], + [m4_if(_ARG_DIR, _LTDL_DIR, + [], + [m4_fatal([multiple libltdl directories: `]_LTDL_DIR[', `]_ARG_DIR['])])]) +m4_popdef([_ARG_DIR]) +])# _LT_CONFIG_LTDL_DIR + +# Initialise: +m4_define([_LTDL_DIR], []) + + +# _LT_BUILD_PREFIX +# ---------------- +# If Autoconf is new enough, expand to `${top_build_prefix}', otherwise +# to `${top_builddir}/'. +m4_define([_LT_BUILD_PREFIX], +[m4_ifdef([AC_AUTOCONF_VERSION], + [m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.62]), + [-1], [m4_ifdef([_AC_HAVE_TOP_BUILD_PREFIX], + [${top_build_prefix}], + [${top_builddir}/])], + [${top_build_prefix}])], + [${top_builddir}/])[]dnl +]) -dnl From Paul Eggert. -# Define HAVE_LONG_LONG_INT if 'long long int' works. -# This fixes a bug in Autoconf 2.61, but can be removed once we -# assume 2.62 everywhere. +# LTDL_CONVENIENCE +# ---------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. LIBLTDL will be prefixed with +# '${top_build_prefix}' if available, otherwise with '${top_builddir}/', +# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single +# quotes!). If your package is not flat and you're not using automake, +# define top_build_prefix, top_builddir, and top_srcdir appropriately +# in your Makefiles. +AC_DEFUN([LTDL_CONVENIENCE], +[AC_BEFORE([$0], [LTDL_INIT])dnl +dnl Although the argument is deprecated and no longer documented, +dnl LTDL_CONVENIENCE used to take a DIRECTORY orgument, if we have one +dnl here make sure it is the same as any other declaration of libltdl's +dnl location! This also ensures lt_ltdl_dir is set when configure.ac is +dnl not yet using an explicit LT_CONFIG_LTDL_DIR. +m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl +_$0() +])# LTDL_CONVENIENCE + +# AC_LIBLTDL_CONVENIENCE accepted a directory argument in older libtools, +# now we have LT_CONFIG_LTDL_DIR: +AU_DEFUN([AC_LIBLTDL_CONVENIENCE], +[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) +_LTDL_CONVENIENCE]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBLTDL_CONVENIENCE], []) + + +# _LTDL_CONVENIENCE +# ----------------- +# Code shared by LTDL_CONVENIENCE and LTDL_INIT([convenience]). +m4_defun([_LTDL_CONVENIENCE], +[case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; +esac +LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdlc.la" +LTDLDEPS=$LIBLTDL +LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}" + +AC_SUBST([LIBLTDL]) +AC_SUBST([LTDLDEPS]) +AC_SUBST([LTDLINCL]) + +# For backwards non-gettext consistent compatibility... +INCLTDL="$LTDLINCL" +AC_SUBST([INCLTDL]) +])# _LTDL_CONVENIENCE + + +# LTDL_INSTALLABLE +# ---------------- +# sets LIBLTDL to the link flags for the libltdl installable library +# and LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called from here. If an installed libltdl +# is not found, LIBLTDL will be prefixed with '${top_build_prefix}' if +# available, otherwise with '${top_builddir}/', and LTDLINCL will be +# prefixed with '${top_srcdir}/' (note the single quotes!). If your +# package is not flat and you're not using automake, define top_build_prefix, +# top_builddir, and top_srcdir appropriately in your Makefiles. +# In the future, this macro may have to be called after LT_INIT. +AC_DEFUN([LTDL_INSTALLABLE], +[AC_BEFORE([$0], [LTDL_INIT])dnl +dnl Although the argument is deprecated and no longer documented, +dnl LTDL_INSTALLABLE used to take a DIRECTORY orgument, if we have one +dnl here make sure it is the same as any other declaration of libltdl's +dnl location! This also ensures lt_ltdl_dir is set when configure.ac is +dnl not yet using an explicit LT_CONFIG_LTDL_DIR. +m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl +_$0() +])# LTDL_INSTALLABLE + +# AC_LIBLTDL_INSTALLABLE accepted a directory argument in older libtools, +# now we have LT_CONFIG_LTDL_DIR: +AU_DEFUN([AC_LIBLTDL_INSTALLABLE], +[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) +_LTDL_INSTALLABLE]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBLTDL_INSTALLABLE], []) + + +# _LTDL_INSTALLABLE +# ----------------- +# Code shared by LTDL_INSTALLABLE and LTDL_INIT([installable]). +m4_defun([_LTDL_INSTALLABLE], +[AC_CHECK_LIB([ltdl], [lt_dlinit], [lt_lib_ltdl=yes]) + if test x"${lt_lib_ltdl-no}" = xyes; then + if test x"$enable_ltdl_install" != xyes; then + AC_MSG_WARN([not overwriting installed libltdl, force with `--enable-ltdl-install']) + enable_ltdl_install=no + fi + elif test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + fi -# Note: If the type 'long long int' exists but is only 32 bits large -# (as on some very old compilers), HAVE_LONG_LONG_INT will not be -# defined. In this case you can treat 'long long int' like 'long int'. +# If configure.ac declared an installable ltdl, and the user didn't override +# with --disable-ltdl-install, we will install the shipped libltdl. +case $enable_ltdl_install in + no) ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLDEPS= + LTDLINCL= + ;; + *) enable_ltdl_install=yes + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdl.la" + LTDLDEPS=$LIBLTDL + LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}" + ;; +esac -AC_DEFUN([AC_TYPE_LONG_LONG_INT], -[ - AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], - [AC_LINK_IFELSE( - [_AC_TYPE_LONG_LONG_SNIPPET], - [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. - dnl If cross compiling, assume the bug isn't important, since - dnl nobody cross compiles for this platform as far as we know. - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[@%:@include - @%:@ifndef LLONG_MAX - @%:@ define HALF \ - (1LL << (sizeof (long long int) * CHAR_BIT - 2)) - @%:@ define LLONG_MAX (HALF - 1 + HALF) - @%:@endif]], - [[long long int n = 1; - int i; - for (i = 0; ; i++) - { - long long int m = n << i; - if (m >> i != n) - return 1; - if (LLONG_MAX / 2 < m) - break; - } - return 0;]])], - [ac_cv_type_long_long_int=yes], - [ac_cv_type_long_long_int=no], - [ac_cv_type_long_long_int=yes])], - [ac_cv_type_long_long_int=no])]) - if test $ac_cv_type_long_long_int = yes; then - AC_DEFINE([HAVE_LONG_LONG_INT], 1, - [Define to 1 if the system has the type `long long int'.]) +AC_SUBST([LIBLTDL]) +AC_SUBST([LTDLDEPS]) +AC_SUBST([LTDLINCL]) + +# For backwards non-gettext consistent compatibility... +INCLTDL="$LTDLINCL" +AC_SUBST([INCLTDL]) +])# LTDL_INSTALLABLE + + +# _LTDL_MODE_DISPATCH +# ------------------- +m4_define([_LTDL_MODE_DISPATCH], +[dnl If _LTDL_DIR is `.', then we are configuring libltdl itself: +m4_if(_LTDL_DIR, [], + [], + dnl if _LTDL_MODE was not set already, the default value is `subproject': + [m4_case(m4_default(_LTDL_MODE, [subproject]), + [subproject], [AC_CONFIG_SUBDIRS(_LTDL_DIR) + _LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"])], + [nonrecursive], [_LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"; lt_libobj_prefix="$lt_ltdl_dir/"])], + [recursive], [], + [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])])dnl +dnl Be careful not to expand twice: +m4_define([$0], []) +])# _LTDL_MODE_DISPATCH + + +# _LT_LIBOBJ(MODULE_NAME) +# ----------------------- +# Like AC_LIBOBJ, except that MODULE_NAME goes into _LT_LIBOBJS instead +# of into LIBOBJS. +AC_DEFUN([_LT_LIBOBJ], [ + m4_pattern_allow([^_LT_LIBOBJS$]) + _LT_LIBOBJS="$_LT_LIBOBJS $1.$ac_objext" +])# _LT_LIBOBJS + + +# LTDL_INIT([OPTIONS]) +# -------------------- +# Clients of libltdl can use this macro to allow the installer to +# choose between a shipped copy of the ltdl sources or a preinstalled +# version of the library. If the shipped ltdl sources are not in a +# subdirectory named libltdl, the directory name must be given by +# LT_CONFIG_LTDL_DIR. +AC_DEFUN([LTDL_INIT], +[dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +dnl We need to keep our own list of libobjs separate from our parent project, +dnl and the easiest way to do that is redefine the AC_LIBOBJs macro while +dnl we look for our own LIBOBJs. +m4_pushdef([AC_LIBOBJ], m4_defn([_LT_LIBOBJ])) +m4_pushdef([AC_LIBSOURCES]) + +dnl If not otherwise defined, default to the 1.5.x compatible subproject mode: +m4_if(_LTDL_MODE, [], + [m4_define([_LTDL_MODE], m4_default([$2], [subproject])) + m4_if([-1], [m4_bregexp(_LTDL_MODE, [\(subproject\|\(non\)?recursive\)])], + [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])]) + +AC_ARG_WITH([included_ltdl], + [AS_HELP_STRING([--with-included-ltdl], + [use the GNU ltdl sources included here])]) + +if test "x$with_included_ltdl" != xyes; then + # We are not being forced to use the included libltdl sources, so + # decide whether there is a useful installed version we can use. + AC_CHECK_HEADER([ltdl.h], + [AC_CHECK_DECL([lt_dlinterface_register], + [AC_CHECK_LIB([ltdl], [lt_dladvise_preload], + [with_included_ltdl=no], + [with_included_ltdl=yes])], + [with_included_ltdl=yes], + [AC_INCLUDES_DEFAULT + #include ])], + [with_included_ltdl=yes], + [AC_INCLUDES_DEFAULT] + ) +fi + +dnl If neither LT_CONFIG_LTDL_DIR, LTDL_CONVENIENCE nor LTDL_INSTALLABLE +dnl was called yet, then for old times' sake, we assume libltdl is in an +dnl eponymous directory: +AC_PROVIDE_IFELSE([LT_CONFIG_LTDL_DIR], [], [_LT_CONFIG_LTDL_DIR([libltdl])]) + +AC_ARG_WITH([ltdl_include], + [AS_HELP_STRING([--with-ltdl-include=DIR], + [use the ltdl headers installed in DIR])]) + +if test -n "$with_ltdl_include"; then + if test -f "$with_ltdl_include/ltdl.h"; then : + else + AC_MSG_ERROR([invalid ltdl include directory: `$with_ltdl_include']) + fi +else + with_ltdl_include=no +fi + +AC_ARG_WITH([ltdl_lib], + [AS_HELP_STRING([--with-ltdl-lib=DIR], + [use the libltdl.la installed in DIR])]) + +if test -n "$with_ltdl_lib"; then + if test -f "$with_ltdl_lib/libltdl.la"; then : + else + AC_MSG_ERROR([invalid ltdl library directory: `$with_ltdl_lib']) fi +else + with_ltdl_lib=no +fi + +case ,$with_included_ltdl,$with_ltdl_include,$with_ltdl_lib, in + ,yes,no,no,) + m4_case(m4_default(_LTDL_TYPE, [convenience]), + [convenience], [_LTDL_CONVENIENCE], + [installable], [_LTDL_INSTALLABLE], + [m4_fatal([unknown libltdl build type: ]_LTDL_TYPE)]) + ;; + ,no,no,no,) + # If the included ltdl is not to be used, then use the + # preinstalled libltdl we found. + AC_DEFINE([HAVE_LTDL], [1], + [Define this if a modern libltdl is already installed]) + LIBLTDL=-lltdl + LTDLDEPS= + LTDLINCL= + ;; + ,no*,no,*) + AC_MSG_ERROR([`--with-ltdl-include' and `--with-ltdl-lib' options must be used together]) + ;; + *) with_included_ltdl=no + LIBLTDL="-L$with_ltdl_lib -lltdl" + LTDLDEPS= + LTDLINCL="-I$with_ltdl_include" + ;; +esac +INCLTDL="$LTDLINCL" + +# Report our decision... +AC_MSG_CHECKING([where to find libltdl headers]) +AC_MSG_RESULT([$LTDLINCL]) +AC_MSG_CHECKING([where to find libltdl library]) +AC_MSG_RESULT([$LIBLTDL]) + +_LTDL_SETUP + +dnl restore autoconf definition. +m4_popdef([AC_LIBOBJ]) +m4_popdef([AC_LIBSOURCES]) + +AC_CONFIG_COMMANDS_PRE([ + _ltdl_libobjs= + _ltdl_ltlibobjs= + if test -n "$_LT_LIBOBJS"; then + # Remove the extension. + _lt_sed_drop_objext='s/\.o$//;s/\.obj$//' + for i in `for i in $_LT_LIBOBJS; do echo "$i"; done | sed "$_lt_sed_drop_objext" | sort -u`; do + _ltdl_libobjs="$_ltdl_libobjs $lt_libobj_prefix$i.$ac_objext" + _ltdl_ltlibobjs="$_ltdl_ltlibobjs $lt_libobj_prefix$i.lo" + done + fi + AC_SUBST([ltdl_LIBOBJS], [$_ltdl_libobjs]) + AC_SUBST([ltdl_LTLIBOBJS], [$_ltdl_ltlibobjs]) ]) -# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. -# This fixes a bug in Autoconf 2.61, but can be removed once we -# assume 2.62 everywhere. +# Only expand once: +m4_define([LTDL_INIT]) +])# LTDL_INIT + +# Old names: +AU_DEFUN([AC_LIB_LTDL], [LTDL_INIT($@)]) +AU_DEFUN([AC_WITH_LTDL], [LTDL_INIT($@)]) +AU_DEFUN([LT_WITH_LTDL], [LTDL_INIT($@)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIB_LTDL], []) +dnl AC_DEFUN([AC_WITH_LTDL], []) +dnl AC_DEFUN([LT_WITH_LTDL], []) + + +# _LTDL_SETUP +# ----------- +# Perform all the checks necessary for compilation of the ltdl objects +# -- including compiler checks and header checks. This is a public +# interface mainly for the benefit of libltdl's own configure.ac, most +# other users should call LTDL_INIT instead. +AC_DEFUN([_LTDL_SETUP], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_SYS_MODULE_EXT])dnl +AC_REQUIRE([LT_SYS_MODULE_PATH])dnl +AC_REQUIRE([LT_SYS_DLSEARCH_PATH])dnl +AC_REQUIRE([LT_LIB_DLLOAD])dnl +AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl +AC_REQUIRE([LT_FUNC_DLSYM_USCORE])dnl +AC_REQUIRE([LT_SYS_DLOPEN_DEPLIBS])dnl +AC_REQUIRE([gl_FUNC_ARGZ])dnl + +m4_require([_LT_CHECK_OBJDIR])dnl +m4_require([_LT_HEADER_DLFCN])dnl +m4_require([_LT_CHECK_DLPREOPEN])dnl +m4_require([_LT_DECL_SED])dnl + +dnl Don't require this, or it will be expanded earlier than the code +dnl that sets the variables it relies on: +_LT_ENABLE_INSTALL + +dnl _LTDL_MODE specific code must be called at least once: +_LTDL_MODE_DISPATCH + +# In order that ltdl.c can compile, find out the first AC_CONFIG_HEADERS +# the user used. This is so that ltdl.h can pick up the parent projects +# config.h file, The first file in AC_CONFIG_HEADERS must contain the +# definitions required by ltdl.c. +# FIXME: Remove use of undocumented AC_LIST_HEADERS (2.59 compatibility). +AC_CONFIG_COMMANDS_PRE([dnl +m4_pattern_allow([^LT_CONFIG_H$])dnl +m4_ifset([AH_HEADER], + [LT_CONFIG_H=AH_HEADER], + [m4_ifset([AC_LIST_HEADERS], + [LT_CONFIG_H=`echo "AC_LIST_HEADERS" | $SED 's,^[[ ]]*,,;s,[[ :]].*$,,'`], + [])])]) +AC_SUBST([LT_CONFIG_H]) + +AC_CHECK_HEADERS([unistd.h dl.h sys/dl.h dld.h mach-o/dyld.h dirent.h], + [], [], [AC_INCLUDES_DEFAULT]) + +AC_CHECK_FUNCS([closedir opendir readdir], [], [AC_LIBOBJ([lt__dirent])]) +AC_CHECK_FUNCS([strlcat strlcpy], [], [AC_LIBOBJ([lt__strl])]) + +AC_DEFINE_UNQUOTED([LT_LIBEXT],["$libext"],[The archive extension]) + +name=ltdl +LTDLOPEN=`eval "\\$ECHO \"$libname_spec\""` +AC_SUBST([LTDLOPEN]) +])# _LTDL_SETUP + + +# _LT_ENABLE_INSTALL +# ------------------ +m4_define([_LT_ENABLE_INSTALL], +[AC_ARG_ENABLE([ltdl-install], + [AS_HELP_STRING([--enable-ltdl-install], [install libltdl])]) + +case ,${enable_ltdl_install},${enable_ltdl_convenience} in + *yes*) ;; + *) enable_ltdl_convenience=yes ;; +esac + +m4_ifdef([AM_CONDITIONAL], +[AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno) + AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)]) +])# _LT_ENABLE_INSTALL + + +# LT_SYS_DLOPEN_DEPLIBS +# --------------------- +AC_DEFUN([LT_SYS_DLOPEN_DEPLIBS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_CACHE_CHECK([whether deplibs are loaded by dlopen], + [lt_cv_sys_dlopen_deplibs], + [# PORTME does your system automatically load deplibs for dlopen? + # or its logical equivalent (e.g. shl_load for HP-UX < 11) + # For now, we just catch OSes we know something about -- in the + # future, we'll try test this programmatically. + lt_cv_sys_dlopen_deplibs=unknown + case $host_os in + aix3*|aix4.1.*|aix4.2.*) + # Unknown whether this is true for these versions of AIX, but + # we want this `case' here to explicitly catch those versions. + lt_cv_sys_dlopen_deplibs=unknown + ;; + aix[[4-9]]*) + lt_cv_sys_dlopen_deplibs=yes + ;; + amigaos*) + case $host_cpu in + powerpc) + lt_cv_sys_dlopen_deplibs=no + ;; + esac + ;; + darwin*) + # Assuming the user has installed a libdl from somewhere, this is true + # If you are looking for one http://www.opendarwin.org/projects/dlcompat + lt_cv_sys_dlopen_deplibs=yes + ;; + freebsd* | dragonfly*) + lt_cv_sys_dlopen_deplibs=yes + ;; + gnu* | linux* | k*bsd*-gnu) + # GNU and its variants, using gnu ld.so (Glibc) + lt_cv_sys_dlopen_deplibs=yes + ;; + hpux10*|hpux11*) + lt_cv_sys_dlopen_deplibs=yes + ;; + interix*) + lt_cv_sys_dlopen_deplibs=yes + ;; + irix[[12345]]*|irix6.[[01]]*) + # Catch all versions of IRIX before 6.2, and indicate that we don't + # know how it worked for any of those versions. + lt_cv_sys_dlopen_deplibs=unknown + ;; + irix*) + # The case above catches anything before 6.2, and it's known that + # at 6.2 and later dlopen does load deplibs. + lt_cv_sys_dlopen_deplibs=yes + ;; + netbsd*) + lt_cv_sys_dlopen_deplibs=yes + ;; + openbsd*) + lt_cv_sys_dlopen_deplibs=yes + ;; + osf[[1234]]*) + # dlopen did load deplibs (at least at 4.x), but until the 5.x series, + # it did *not* use an RPATH in a shared library to find objects the + # library depends on, so we explicitly say `no'. + lt_cv_sys_dlopen_deplibs=no + ;; + osf5.0|osf5.0a|osf5.1) + # dlopen *does* load deplibs and with the right loader patch applied + # it even uses RPATH in a shared library to search for shared objects + # that the library depends on, but there's no easy way to know if that + # patch is installed. Since this is the case, all we can really + # say is unknown -- it depends on the patch being installed. If + # it is, this changes to `yes'. Without it, it would be `no'. + lt_cv_sys_dlopen_deplibs=unknown + ;; + osf*) + # the two cases above should catch all versions of osf <= 5.1. Read + # the comments above for what we know about them. + # At > 5.1, deplibs are loaded *and* any RPATH in a shared library + # is used to find them so we can finally say `yes'. + lt_cv_sys_dlopen_deplibs=yes + ;; + qnx*) + lt_cv_sys_dlopen_deplibs=yes + ;; + solaris*) + lt_cv_sys_dlopen_deplibs=yes + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + libltdl_cv_sys_dlopen_deplibs=yes + ;; + esac + ]) +if test "$lt_cv_sys_dlopen_deplibs" != yes; then + AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1], + [Define if the OS needs help to load dependent libraries for dlopen().]) +fi +])# LT_SYS_DLOPEN_DEPLIBS + +# Old name: +AU_ALIAS([AC_LTDL_SYS_DLOPEN_DEPLIBS], [LT_SYS_DLOPEN_DEPLIBS]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS], []) -# Note: If the type 'unsigned long long int' exists but is only 32 bits -# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT -# will not be defined. In this case you can treat 'unsigned long long int' -# like 'unsigned long int'. -AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], +# LT_SYS_MODULE_EXT +# ----------------- +AC_DEFUN([LT_SYS_MODULE_EXT], +[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl +AC_CACHE_CHECK([which extension is used for runtime loadable modules], + [libltdl_cv_shlibext], [ - AC_CACHE_CHECK([for unsigned long long int], - [ac_cv_type_unsigned_long_long_int], - [AC_LINK_IFELSE( - [_AC_TYPE_LONG_LONG_SNIPPET], - [ac_cv_type_unsigned_long_long_int=yes], - [ac_cv_type_unsigned_long_long_int=no])]) - if test $ac_cv_type_unsigned_long_long_int = yes; then - AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1, - [Define to 1 if the system has the type `unsigned long long int'.]) +module=yes +eval libltdl_cv_shlibext=$shrext_cmds + ]) +if test -n "$libltdl_cv_shlibext"; then + m4_pattern_allow([LT_MODULE_EXT])dnl + AC_DEFINE_UNQUOTED([LT_MODULE_EXT], ["$libltdl_cv_shlibext"], + [Define to the extension used for runtime loadable modules, say, ".so".]) +fi +])# LT_SYS_MODULE_EXT + +# Old name: +AU_ALIAS([AC_LTDL_SHLIBEXT], [LT_SYS_MODULE_EXT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SHLIBEXT], []) + + +# LT_SYS_MODULE_PATH +# ------------------ +AC_DEFUN([LT_SYS_MODULE_PATH], +[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl +AC_CACHE_CHECK([which variable specifies run-time module search path], + [lt_cv_module_path_var], [lt_cv_module_path_var="$shlibpath_var"]) +if test -n "$lt_cv_module_path_var"; then + m4_pattern_allow([LT_MODULE_PATH_VAR])dnl + AC_DEFINE_UNQUOTED([LT_MODULE_PATH_VAR], ["$lt_cv_module_path_var"], + [Define to the name of the environment variable that determines the run-time module search path.]) +fi +])# LT_SYS_MODULE_PATH + +# Old name: +AU_ALIAS([AC_LTDL_SHLIBPATH], [LT_SYS_MODULE_PATH]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SHLIBPATH], []) + + +# LT_SYS_DLSEARCH_PATH +# -------------------- +AC_DEFUN([LT_SYS_DLSEARCH_PATH], +[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl +AC_CACHE_CHECK([for the default library search path], + [lt_cv_sys_dlsearch_path], + [lt_cv_sys_dlsearch_path="$sys_lib_dlsearch_path_spec"]) +if test -n "$lt_cv_sys_dlsearch_path"; then + sys_dlsearch_path= + for dir in $lt_cv_sys_dlsearch_path; do + if test -z "$sys_dlsearch_path"; then + sys_dlsearch_path="$dir" + else + sys_dlsearch_path="$sys_dlsearch_path$PATH_SEPARATOR$dir" + fi + done + m4_pattern_allow([LT_DLSEARCH_PATH])dnl + AC_DEFINE_UNQUOTED([LT_DLSEARCH_PATH], ["$sys_dlsearch_path"], + [Define to the system default library search path.]) +fi +])# LT_SYS_DLSEARCH_PATH + +# Old name: +AU_ALIAS([AC_LTDL_SYSSEARCHPATH], [LT_SYS_DLSEARCH_PATH]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SYSSEARCHPATH], []) + + +# _LT_CHECK_DLPREOPEN +# ------------------- +m4_defun([_LT_CHECK_DLPREOPEN], +[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen], + [libltdl_cv_preloaded_symbols], + [if test -n "$lt_cv_sys_global_symbol_pipe"; then + libltdl_cv_preloaded_symbols=yes + else + libltdl_cv_preloaded_symbols=no fi -]) + ]) +if test x"$libltdl_cv_preloaded_symbols" = xyes; then + AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1], + [Define if libtool can extract symbol lists from object files.]) +fi +])# _LT_CHECK_DLPREOPEN -# Expands to a C program that can be used to test for simultaneous support -# of 'long long' and 'unsigned long long'. We don't want to say that -# 'long long' is available if 'unsigned long long' is not, or vice versa, -# because too many programs rely on the symmetry between signed and unsigned -# integer types (excluding 'bool'). -AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], -[ - AC_LANG_PROGRAM( - [[/* Test preprocessor. */ - #if ! (-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - error in preprocessor; - #endif - #if ! (18446744073709551615ULL <= -1ull) - error in preprocessor; - #endif - /* Test literals. */ - long long int ll = 9223372036854775807ll; - long long int nll = -9223372036854775807LL; - unsigned long long int ull = 18446744073709551615ULL; - /* Test constant expressions. */ - typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - ? 1 : -1)]; - typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; - int i = 63;]], - [[/* Test availability of runtime routines for shift and division. */ - long long int llmax = 9223372036854775807ll; - unsigned long long int ullmax = 18446744073709551615ull; - return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll) - | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) - | (ullmax / ull) | (ullmax % ull));]]) -]) + +# LT_LIB_DLLOAD +# ------------- +AC_DEFUN([LT_LIB_DLLOAD], +[m4_pattern_allow([^LT_DLLOADERS$]) +LT_DLLOADERS= +AC_SUBST([LT_DLLOADERS]) + +AC_LANG_PUSH([C]) + +LIBADD_DLOPEN= +AC_SEARCH_LIBS([dlopen], [dl], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + if test "$ac_cv_search_dlopen" != "none required" ; then + LIBADD_DLOPEN="-ldl" + fi + libltdl_cv_lib_dl_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H +# include +#endif + ]], [[dlopen(0, 0);]])], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + libltdl_cv_func_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], + [AC_CHECK_LIB([svld], [dlopen], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + LIBADD_DLOPEN="-lsvld" libltdl_cv_func_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"])])]) +if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes +then + lt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBADD_DLOPEN" + AC_CHECK_FUNCS([dlerror]) + LIBS="$lt_save_LIBS" +fi +AC_SUBST([LIBADD_DLOPEN]) + +LIBADD_SHL_LOAD= +AC_CHECK_FUNC([shl_load], + [AC_DEFINE([HAVE_SHL_LOAD], [1], + [Define if you have the shl_load function.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la"], + [AC_CHECK_LIB([dld], [shl_load], + [AC_DEFINE([HAVE_SHL_LOAD], [1], + [Define if you have the shl_load function.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" + LIBADD_SHL_LOAD="-ldld"])]) +AC_SUBST([LIBADD_SHL_LOAD]) + +case $host_os in +darwin[[1567]].*) +# We only want this for pre-Mac OS X 10.4. + AC_CHECK_FUNC([_dyld_func_lookup], + [AC_DEFINE([HAVE_DYLD], [1], + [Define if you have the _dyld_func_lookup function.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dyld.la"]) + ;; +beos*) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la" + ;; +cygwin* | mingw* | os2* | pw32*) + AC_CHECK_DECLS([cygwin_conv_path], [], [], [[#include ]]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la" + ;; +esac + +AC_CHECK_LIB([dld], [dld_link], + [AC_DEFINE([HAVE_DLD], [1], + [Define if you have the GNU dld library.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dld_link.la"]) +AC_SUBST([LIBADD_DLD_LINK]) + +m4_pattern_allow([^LT_DLPREOPEN$]) +LT_DLPREOPEN= +if test -n "$LT_DLLOADERS" +then + for lt_loader in $LT_DLLOADERS; do + LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen $lt_loader " + done + AC_DEFINE([HAVE_LIBDLLOADER], [1], + [Define if libdlloader will be built on this platform]) +fi +AC_SUBST([LT_DLPREOPEN]) + +dnl This isn't used anymore, but set it for backwards compatibility +LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD" +AC_SUBST([LIBADD_DL]) + +AC_LANG_POP +])# LT_LIB_DLLOAD + +# Old name: +AU_ALIAS([AC_LTDL_DLLIB], [LT_LIB_DLLOAD]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_DLLIB], []) + + +# LT_SYS_SYMBOL_USCORE +# -------------------- +# does the compiler prefix global symbols with an underscore? +AC_DEFUN([LT_SYS_SYMBOL_USCORE], +[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +AC_CACHE_CHECK([for _ prefix in compiled symbols], + [lt_cv_sys_symbol_underscore], + [lt_cv_sys_symbol_underscore=no + cat > conftest.$ac_ext <<_LT_EOF +void nm_test_func(){} +int main(){nm_test_func;return 0;} +_LT_EOF + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + ac_nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then + # See whether the symbols have a leading underscore. + if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then + lt_cv_sys_symbol_underscore=yes + else + if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then + : + else + echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD + fi + fi + else + echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.c >&AS_MESSAGE_LOG_FD + fi + rm -rf conftest* + ]) + sys_symbol_underscore=$lt_cv_sys_symbol_underscore + AC_SUBST([sys_symbol_underscore]) +])# LT_SYS_SYMBOL_USCORE + +# Old name: +AU_ALIAS([AC_LTDL_SYMBOL_USCORE], [LT_SYS_SYMBOL_USCORE]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SYMBOL_USCORE], []) + + +# LT_FUNC_DLSYM_USCORE +# -------------------- +AC_DEFUN([LT_FUNC_DLSYM_USCORE], +[AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl +if test x"$lt_cv_sys_symbol_underscore" = xyes; then + if test x"$libltdl_cv_func_dlopen" = xyes || + test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then + AC_CACHE_CHECK([whether we have to add an underscore for dlsym], + [libltdl_cv_need_uscore], + [libltdl_cv_need_uscore=unknown + save_LIBS="$LIBS" + LIBS="$LIBS $LIBADD_DLOPEN" + _LT_TRY_DLOPEN_SELF( + [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes], + [], [libltdl_cv_need_uscore=cross]) + LIBS="$save_LIBS" + ]) + fi +fi + +if test x"$libltdl_cv_need_uscore" = xyes; then + AC_DEFINE([NEED_USCORE], [1], + [Define if dlsym() requires a leading underscore in symbol names.]) +fi +])# LT_FUNC_DLSYM_USCORE + +# Old name: +AU_ALIAS([AC_LTDL_DLSYM_USCORE], [LT_FUNC_DLSYM_USCORE]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_DLSYM_USCORE], []) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # @@ -144,7 +833,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.1], [], +m4_if([$1], [1.11], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -160,7 +849,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.1])dnl +[AM_AUTOMAKE_VERSION([1.11])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) diff --git a/Build/source/texk/web2c/c-auto.in b/Build/source/texk/web2c/c-auto.in index 18418d6c175..ec96c318b77 100644 --- a/Build/source/texk/web2c/c-auto.in +++ b/Build/source/texk/web2c/c-auto.in @@ -64,13 +64,26 @@ /* Define to 1 if you have the Mac OS X Carbon framework. */ #undef HAVE_CARBON +/* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if + you don't. */ +#undef HAVE_DECL_CYGWIN_CONV_PATH + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H +/* Define if you have the GNU dld library. */ +#undef HAVE_DLD + +/* Define to 1 if you have the `dlerror' function. */ +#undef HAVE_DLERROR + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H +/* Define if you have the _dyld_func_lookup function. */ +#undef HAVE_DYLD + /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H @@ -110,6 +123,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LANGINFO_H +/* Define if you have the libdl library or equivalent. */ +#undef HAVE_LIBDL + +/* Define if libdlloader will be built on this platform */ +#undef HAVE_LIBDLLOADER + /* Define if you have libfontconfig. */ #undef HAVE_LIBFONTCONFIG @@ -165,6 +184,9 @@ /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE +/* Define if you have the shl_load function. */ +#undef HAVE_SHL_LOAD + /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF diff --git a/Build/source/texk/web2c/configure b/Build/source/texk/web2c/configure index cdeb5ec7be3..810b17bfa4a 100755 --- a/Build/source/texk/web2c/configure +++ b/Build/source/texk/web2c/configure @@ -748,6 +748,12 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +LIBADD_DL +LT_DLPREOPEN +LIBADD_DLD_LINK +LIBADD_SHL_LOAD +LIBADD_DLOPEN +LT_DLLOADERS subdirs LUATANGLE OTANGLE @@ -2769,6 +2775,45 @@ rm -f conftest.val as_fn_set_status $ac_retval } # ac_fn_c_compute_int + +# ac_fn_c_check_decl LINENO SYMBOL VAR +# ------------------------------------ +# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 +$as_echo_n "checking whether $2 is declared... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $2 + (void) $2; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -5226,13 +5271,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:5229: $ac_compile\"" >&5) + (eval echo "\"\$as_me:5274: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:5232: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:5277: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:5235: output\"" >&5) + (eval echo "\"\$as_me:5280: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -6435,7 +6480,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6438 "configure"' > conftest.$ac_ext + echo '#line 6483 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8365,11 +8410,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8368: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8413: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8372: \$? = $ac_status" >&5 + echo "$as_me:8417: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8704,11 +8749,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8707: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8752: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8711: \$? = $ac_status" >&5 + echo "$as_me:8756: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8809,11 +8854,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8812: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8857: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8816: \$? = $ac_status" >&5 + echo "$as_me:8861: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8864,11 +8909,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8867: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8912: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8871: \$? = $ac_status" >&5 + echo "$as_me:8916: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11231,7 +11276,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11234 "configure" +#line 11279 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11327,7 +11372,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11330 "configure" +#line 11375 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15128,11 +15173,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15131: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15176: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15135: \$? = $ac_status" >&5 + echo "$as_me:15180: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15227,11 +15272,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15230: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15275: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15234: \$? = $ac_status" >&5 + echo "$as_me:15279: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15279,11 +15324,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15282: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15327: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15286: \$? = $ac_status" >&5 + echo "$as_me:15331: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -19064,13 +19109,10 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - /* Test preprocessor. */ - #if ! (-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - error in preprocessor; - #endif - #if ! (18446744073709551615ULL <= -1ull) - error in preprocessor; - #endif + /* For now, do not test the preprocessor; as of 2007 there are too many + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ /* Test literals. */ long long int ll = 9223372036854775807ll; long long int nll = -9223372036854775807LL; @@ -21981,6 +22023,329 @@ ac_config_files="$ac_config_files ctangleboot-sh" + + +LT_DLLOADERS= + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_link="./libtool --mode=link --tag=CC $ac_link" + + +LIBADD_DLOPEN= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 +$as_echo_n "checking for library containing dlopen... " >&6; } +if test "${ac_cv_search_dlopen+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_dlopen=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_dlopen+set}" = set; then : + break +fi +done +if test "${ac_cv_search_dlopen+set}" = set; then : + +else + ac_cv_search_dlopen=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 +$as_echo "$ac_cv_search_dlopen" >&6; } +ac_res=$ac_cv_search_dlopen +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +$as_echo "#define HAVE_LIBDL 1" >>confdefs.h + + if test "$ac_cv_search_dlopen" != "none required" ; then + LIBADD_DLOPEN="-ldl" + fi + libltdl_cv_lib_dl_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if HAVE_DLFCN_H +# include +#endif + +int +main () +{ +dlopen(0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +$as_echo "#define HAVE_LIBDL 1" >>confdefs.h + + libltdl_cv_func_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if test "${ac_cv_lib_svld_dlopen+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_svld_dlopen=yes +else + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : + +$as_echo "#define HAVE_LIBDL 1" >>confdefs.h + + LIBADD_DLOPEN="-lsvld" libltdl_cv_func_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la" +fi + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + +if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes +then + lt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBADD_DLOPEN" + for ac_func in dlerror +do : + ac_fn_c_check_func "$LINENO" "dlerror" "ac_cv_func_dlerror" +if test "x$ac_cv_func_dlerror" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLERROR 1 +_ACEOF + +fi +done + + LIBS="$lt_save_LIBS" +fi + + +LIBADD_SHL_LOAD= +ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = x""yes; then : + +$as_echo "#define HAVE_SHL_LOAD 1" >>confdefs.h + + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if test "${ac_cv_lib_dld_shl_load+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_shl_load=yes +else + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : + +$as_echo "#define HAVE_SHL_LOAD 1" >>confdefs.h + + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" + LIBADD_SHL_LOAD="-ldld" +fi + +fi + + + +case $host_os in +darwin[1567].*) +# We only want this for pre-Mac OS X 10.4. + ac_fn_c_check_func "$LINENO" "_dyld_func_lookup" "ac_cv_func__dyld_func_lookup" +if test "x$ac_cv_func__dyld_func_lookup" = x""yes; then : + +$as_echo "#define HAVE_DYLD 1" >>confdefs.h + + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dyld.la" +fi + + ;; +beos*) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la" + ;; +cygwin* | mingw* | os2* | pw32*) + ac_fn_c_check_decl "$LINENO" "cygwin_conv_path" "ac_cv_have_decl_cygwin_conv_path" "#include +" +if test "x$ac_cv_have_decl_cygwin_conv_path" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_CYGWIN_CONV_PATH $ac_have_decl +_ACEOF + + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la" + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if test "${ac_cv_lib_dld_dld_link+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_dld_link=yes +else + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : + +$as_echo "#define HAVE_DLD 1" >>confdefs.h + + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dld_link.la" +fi + + + + +LT_DLPREOPEN= +if test -n "$LT_DLLOADERS" +then + for lt_loader in $LT_DLLOADERS; do + LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen $lt_loader " + done + +$as_echo "#define HAVE_LIBDLLOADER 1" >>confdefs.h + +fi + + +LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD" + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_link="./libtool --mode=link --tag=CC $ac_link" + + + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -22632,9 +22997,9 @@ esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" -config_commands="$ac_config_commands" +config_files="`echo $ac_config_files`" +config_headers="`echo $ac_config_headers`" +config_commands="`echo $ac_config_commands`" _ACEOF diff --git a/Build/source/texk/web2c/configure.ac b/Build/source/texk/web2c/configure.ac index e1ea7cca29d..a0e9eb96c04 100644 --- a/Build/source/texk/web2c/configure.ac +++ b/Build/source/texk/web2c/configure.ac @@ -375,4 +375,8 @@ AC_CONFIG_COMMANDS_POST([AS_IF([test "x$cross_compiling" = xyes], CC='$BUILDCC' CPPFLAGS='$BUILDCPPFLAGS'\ CFLAGS='$BUILDCFLAGS' LDFLAGS='$BUILDLDFLAGS'"])]) +dnl for luatex dynamic loading + +LT_LIB_DLLOAD + AC_OUTPUT diff --git a/Build/source/texk/web2c/doc/Makefile.in b/Build/source/texk/web2c/doc/Makefile.in index 24e22f59310..20df3d41c47 100644 --- a/Build/source/texk/web2c/doc/Makefile.in +++ b/Build/source/texk/web2c/doc/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -170,6 +170,10 @@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBADD_DL = @LIBADD_DL@ +LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ +LIBADD_DLOPEN = @LIBADD_DLOPEN@ +LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBOBJS = @LIBOBJS@ LIBPNG_DEPEND = @LIBPNG_DEPEND@ LIBPNG_INCLUDES = @LIBPNG_INCLUDES@ @@ -179,6 +183,8 @@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +LT_DLLOADERS = @LT_DLLOADERS@ +LT_DLPREOPEN = @LT_DLPREOPEN@ LUATANGLE = @LUATANGLE@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/Build/source/texk/web2c/lib/Makefile.in b/Build/source/texk/web2c/lib/Makefile.in index 4d9d1d52781..130deaaa1ca 100644 --- a/Build/source/texk/web2c/lib/Makefile.in +++ b/Build/source/texk/web2c/lib/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -162,6 +162,10 @@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBADD_DL = @LIBADD_DL@ +LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ +LIBADD_DLOPEN = @LIBADD_DLOPEN@ +LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBOBJS = @LIBOBJS@ LIBPNG_DEPEND = @LIBPNG_DEPEND@ LIBPNG_INCLUDES = @LIBPNG_INCLUDES@ @@ -171,6 +175,8 @@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +LT_DLLOADERS = @LT_DLLOADERS@ +LT_DLPREOPEN = @LT_DLPREOPEN@ LUATANGLE = @LUATANGLE@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/Build/source/texk/web2c/luatexdir/NEWS b/Build/source/texk/web2c/luatexdir/NEWS index e8225664548..d4031c5adc4 100644 --- a/Build/source/texk/web2c/luatexdir/NEWS +++ b/Build/source/texk/web2c/luatexdir/NEWS @@ -1,3 +1,638 @@ + +This file is in the public domain. + +============================================================== +Luatex beta-0.60.0 was released 20100404 +============================================================== + +New features: + +* os.name now knows about CYGWIN (from Elie Roux) + +* Internal handling of direction specifiers is faster now. + +* Each glyph node now has three new virtual read-only fields: + width, height, and depth (values in scaled points, of course) + +* There are new functions node.protrusion_skipable() and + tex.badness() (useful for paragraph breaking in lua) + +* Also new: tex.linebreak(). See the manual for details. + +* All lua errors now report file and line numbers to aid in + debugging. + +* Import of metapost 1.211. + +* pdf.pdfcatalog will be replaced soon by the new pdf.catalog + pdf.pdfinfo will be replaced soon by the new pdf.info + pdf.pdfnames will be replaced soon by the new pdf.names + pdf.pdftrailer will be replaced soon by the new pdf.trailer + +* pdf.pdfmapfile and pdf.pdfmapline are replaced by the new + pdf.mapfile() and pdf.mapline() functions. (a function interface + fits these parameters better because they never return anything). + +* New read-write lua variables: pdf.pageattributes, pdf.pageresources, + pdf.pagesresources + +* getluatexsvnversion.sh now correctly detects git-svn and still + manages to find a valid SVN revision number (from Patrick Gundlach) + +* Many of the source files have been converted to CWEB. + +Bug fixes: + +* GNU libtool is now used to solve the various technical issues with + dynamic loading of lua modules. + +* Error detection in scan_integer_part was wrong due to missing + initialization of OK_so_far (spotted by Javier Mugica) + +* Synctex was broken in 0.51-0.52. + +* \lastlinefit was broken since ... well, nearly forever. + +* Reading of binary files with length zero was broken. + +* Trapping of unitialized rules (this was for sloppily created + rule nodes from lua) + +* pdf.immediateobj('streamfile') was broken on 64-bit platforms. + +* tex.linebreak did not take the given left and right skip, but + instead used the current TeX-side values (bug #356). + +* the found 'MAKE' command in build.sh is now fed into configure to fix + problems with that not finding GNU make even when it is actually + installed. + +* dofile() and loadfile() in batch mode now give an + error and continue instead of pointlessly waiting for user input. + +* Reverted commit #3417 (the buildpage experiment) as it causes bad + things to happen when items are waiting during page breaks. + +* Overrule loaders[4] in --safer mode, make require() behave + closer to normal lua 5.1, and add some nicer error messages + (based on an email and patches from Manuel Pegourie-Gonnard) + +* Added an extra sanity check for GDEF loading in luafontloader, + based on a crash caused by Linux' AkaashNormal.ttf. + + +============================================================== +Luatex beta-0.52.0 was released 20100316 +============================================================== + +New features: + +* Various small manual improvements. + +* A better version of getluatexsvnversion.sh, from Tomek. + +* node.copy_list() now allows the second (optional) argument to + be nil. + +* An import of the current state of the texlive repository + (kpathsea and build system). + +Bug fixes: + +* An attempt fix for bug #345 (math kerning is not perfect): when the + current math font is a new math font, check against \catcode + == 11 to suppress the italic correction, instead of looking at + the value of space(). + +* There is a new key: 'units_per_em' (defaults to 0). + This is part of a fix for bug #200 (Problem with CFF fonts having + em-size other than 1000): there is a special correction to the + embedded cff font itself and the font scale if the font to be output + is opentype or type1 in unicode encoding and the 'units_per_em + differs' from zero. + .units_per_em has to be passed back to luatex from + the lua font loading code for this to work. + +* A fix for bug #314 (problem with pk file). + +* lua code can no longer change the internal preallocated glue_spec + nodes (as that resulted in weird spacing bugs). For this, glue_specs + now have a new field: 'writable'. If that field is false, a copy + has to be made of the glue_spec instead of doing an assignment + to it. + +* Setting of \textdir inside the output routine could trash output + on following pages due to a lingering internal variable. + +* \pdfthread crashed because the arguments were handled in reverse + order. + +============================================================== +Luatex beta-0.51.0 was released 20100312 +============================================================== + +New features: + +* Various small manual improvements. +* The backend message "cannot open Type 1 font file for reading" + now reports which Type1 font it was looking for. +* Fontforge clears some font names at loading time that will be + refilled in at font generation time, but the fontloader should not + do that. Patch from Khaled Hosny. +* New synctex code imported from TeXLive. +* luamd5/md5.h is renamed to luamd5/luamd5.h to avoid confusion. +* Embedded mplib is now 1.209. +* Some experimental tweaking of buildpage_filter, see the manual + for details. +* Luatex now detects kfreebsd (from Alan Braslau) +* The new lua function tex.sp() converts a string to a number + representing scaled points. +* There is now support for revision numbers in the banner and stats + library again. +* The command line help and manual documentation page is extended. +* node.hpack() now also accepts "cal_expand_ratio" and "subst_ex_font" + modifiers. +* node.hpack() and node.vpack() now give back the badness of the box + as second return value. +* node.copy_list() now allows a second (stop) argument, this stopper + is not copied. +* new lua functions in lfs: lfs.readlink() and lfs.shortname(). +* new lua function tex.tprint() that can combine multiple catcode + regime prints in one function call. +* new lua sub-table: tex.nest[] (read/write access to the semantic + nest state). +* New lua functions in kpse: kpse.lookup() and kpse.version(). See + the manual for more details. +* New lua function tex.shipout(). + +Bug fixes: + +* There problems in the pdf output for Type3 (pk) fonts. +* Fix a bug that allowed bad commandline quoting. +* Fix a bug that sometimes caused crashes when \pdfprotrudechars. +* The build script now exports CONFIG_SHELL to avoid problems with + /bin/dash. +* The was a bug in the generated /Image /ProcSet. +* status.font_bytes reported the wrong value. +* Lots of compiler warnings are removed (thanks Javier Mugica). +* Patch to fontloader.info() to accept filenames with embedded + parentheses. +* Fix a \write error with docstrip package. +* Fixed a crash on AdobeMyungjoStd-Medium.otf. +* Fix coco stack overflows, needed for lpeg. +* \pdfcompresslevel wasn't initialized for early immediate objects. +* Fix for slanted fonts when HZ was on (slant angle was multiplied). +* When concatenating content streams, put a space between them. +* Allow pfb lines to end with \r as well as \n (for msam10.pfb). +* Fix the internal string->scaled point conversion in the lua + interface. +* Memory leaks in the fontloader removed, thanks to patches from + Elie Roux. +* Fix a crash caused by the combination of coroutines and font.each(). + +Removed features: + +* Support for Type3 .pgc files (nobody used them). + +============================================================== +Luatex beta-0.50.0 was released 20091224 +============================================================== + +New features: + +* Fonts now listen also to the 'extend' key in the lua font + metrics table, and the processing for this is done via de + pdf text matrix instead of via the font matrix, which means + it now works for all font types. + +* The embedded Metapost library is now at version 1.209. + +Dropped features: + +* It is no longer possible for fonts from embedded pdf files + to be replaced by / merged with the document fonts of the + enveloping pdf. This regression may be temporary, depending + on how the rewritten font backend will look after beta 0.60. + +Bug fixes: + +* Use of \middle confused the \mathstyle operation. + +* \pdfcolorstack handling was broken. + +* node.unset_attribute() had a bug whereby it inverted the + requested result in some cases (the node on which the unset + was called was sometimes the only node at the current level + that *kept* the attribute). + +* During font expansion, the internal font copy had one character + information object less than the original, resulting in the + disappearance of a glyph in some fonts when font expansion + was active. + +* Placement of operator scripts of OT MATH fonts is adjusted + to be conformant with Word's logic where the italic correction + is only used to tuck in the subscript and for nothing else. + +* luafontloader.open() no longer writes directly to stderr in + case of internal font errors. + +* Any .objnum could not be assigned to. + +* The lua 'pdf' table could not be assigned to. + +* The lua 'md5' library was returning incorrect results on + 64-bit architectures. + +* Luatex now compiles on GNU Hurd systems. + +* Fix segfault when embedding stream file object (these + backend segfaults were a side-effect of the string pool + patches). + +============================================================== +Luatex beta-0.47.0 was released 20091218 +============================================================== + +New features: + +* New read-write lua variables pdf.pdfcatalog, pdf.pdfnames, + pdf.pdfinfo, pdf.pdftrailer + +* The horizontal mode nodes that are added to lines during line + breaking now inherit the attributes from the first and last node + inside the created line. + +* The new function pdf.registerannot() registers an + annotation object number to be included in the current + page's /Annots list. + +* The variables .Mathconstants.FractionDelimiterSize + and .Mathconstants.FractionDelimiterDisplayStyleSize + are added to the font table. This allows proper setting of the + size parameters for TeX's ...withdelims math primitives. + +* The internal representation of the string pool is reorganized + (the pool of string characters is now allocated dynamically), + and as a side-effect the lua variable status.init_pool_ptr + is deprecated and will be removed in a later version. Also, + status.pool_ptr now simply returns the current number of bytes + in use for string characters. + +* There are new lua variables pdf.pdfmapline and pdf.pdfmapfile + (write-only strings that mimic \pdfmapline and \pdfmapfile). + +* \pdfobj data and attribute are now stored as C strings instead + of as token lists (this should speed up cases with a lot of data). + +* Artificially slanted fonts now work via the pdf text matrix + (instead of adjusting the actual font) so that it now also + works for non-Type1 fonts. The lua .slant font key is + now obeyed in all cases. + +* The lua function font.id() returns the internal font id + number belonging to a control sequence name. + +* Pdf image inclusion is optimized such that objects from an + external pdf will now be included only once even if they are + referenced from multiple inclusions. + +Bug fixes: + +* Protrusion for non-TLT documents did not work properly for + the hyphenation character. + +* \lastbox could not remove the paragraph indent box for non-TLT + documents. + +* Pdf images (\pdfximage) are no longer kept open during the + whole run, but closed and reopened. An error is raised if + the file has changed between \pdfximage and \pdfrefximage. + This prevents the 'too many open files' error when lots of + images are included. + +* On Win32 Pdf image files are locked during the time that it is + open, to prevent unnoticed file changes by external sources. + +* Compilation now again works on FreeBSD. + +* Format sharing between 32-bit and 64-bit architectures was + broken. + +* Unsetting attributes from lua could sometimes result in + the unset state persisting beyond the current group level. + +* If something went wrong in the scanning of pdf action items, + the error message reported the current primitive name + incorrectly. + +* Luatex would crash on non-existant pdfs that were referenced + from map file entries. + +============================================================== +Luatex beta-0.46.0 was released 20091126 +============================================================== + +New features: + +* The build.sh script now has better support for new MacOSX-es + (patch from Mojca). + +* Luatex now has experimental support for dynamic loading of + external compiled lua libraries. Building luatex and loading + external .so/.dll files is reported to work on Windows, + linux and osx, other platforms are still unknown. + +* pdf.obj{type="stream"} no longer converts its argument to and + from a tokenlist. This allows the use of binary data in the + "string" argument. Such data does still have to hidden from + the normal file parser by putting the code in a dofile() + or by using string.char(), though. + +Bug fixes: + +* Luatex 0.45.0 was not able to find truetype nor opentype fonts + if there were no callbacks defined (patch from Pawel). + +* 0.45.0 printed the user input instead of the full pathname + for \input-ed tex files. + +* The TFM reader now rejects fonts with tfm names that are + longer than 255 characters because such font names cannot + be stored in a DVI file. + +* The combination of \immediate\pdfxform followed by a later + \pdfrefxform could cause broken pdf output files because + the box used for the form could have been freed and even + reused already at that moment in time, sometimes resulting + in an invalid transformation matrix. + +* The placement of super- and subscripts for displaystyle + \int's in CambriaMath is now better than before. It still + needs a tweak to the metrics though: in the current version, + the italic correction has to be substracted from the width + of the integral sign to get correct placement (context mkiv + does this). to be continued ... + +============================================================== +Luatex beta-0.45.0 was released 20091118 +============================================================== + +New features: + +* Loading big OTF fonts via lua is now much faster than before, + at the expense of a bit of precision loss in the calculated + bounding boxes. + +* Two new token lists are provided: \pdfxformresources and + \pdfxformattr, as an alternative to \pdfxform keywords. + +* \input and \openin now accept braced filenames. + +* The \endlinechar can now be set to any value between 0 and 127. + +* Luatex can now optionally use kpathsea to find lua require() + files. + +* The new primitives \aligntab and \alignmark are aliases for + the use of & and # in alignments. + +* \pdfrefximage [width ] [height ] [depth ] + overrules settings from \pdfximage for this \pdfrefximage call only + +* The print precision for small numbers in lua code (tostring) + has been improved. + +* Akira Kakuto suppled a patch that restricts writing to files + with names such as latex.bat etc. (on windows only) + +* (un-feature): from now on luatex now only handles 4 direction + specifiers: TLT (latin), TRT (arabic), RTT (cjk), and LTL + (mongolian). The other directions now generate an error. + +* (un-feature): xpdf's automatic lower- and uppercasing retry attempts + for nonfound image pdf files has been removed. + +* The callbacks hpack_filter, vpack_filter and pre_output_filter + pass on an extra string argument for the direction, when known + (nil == use default). + +* The lua functions node.hpack(), node.vpack() and node.dimensions() + now accept an optional direction argument (not given == use default). + +* \pdfrefxform [width ] [height ] [depth ] + scales a form object; similar principle as with \pdfximage: depth alone + doesn't scale, it shifts vertically. + +* A change to the relative ordering inside font name discovery for use + by the backend: now it tries .psname first, as that is much less + likely to contain spaces. + +* For ttc fonts, now the used subfont name and its index id are printed + to the terminal, and if the backend cannot find a ttc subfont, the + run is aborted. + +Bug fixes: + +* Prevent crashes for lua-loaded fonts without a (tfm) name. + +* Remove spurious newlines in the output pdf that could be the + result of using \pdfximage for an included pdf figure too early. + +* Full font embedding for wide otf and ttf fonts now really + works (older versions only pretended that it did work). + +* node.dimensions() sometimes continued past the 'stop' node. + +* Images inside virtual fonts were broken. + +* The processing of \language=-1 was wrong, resulting in + hyphenation attempts even though there was no proper language + set up. + +* Fix for finding files in --output-directory. + +* Fix for handling of --file-line-error. + +* tex.box[] assingments are now checked to make sure the assigned + node has the right id (hlist or vlist). + +* show_node_list (as in \showbox) produced spurious local_par + whatsit prints in the output after direction nodes. + +* The handling of pdf literals has been sped up. + +============================================================== +Luatex beta-0.44.0 was released 20091027 +============================================================== + +New features: + +* libpng is now 1.2.40. + +* hlist nodes now have a subtype to distinguish hlists generated + by the paragraph breaking, explicit \hbox commands, and other + (as-yet-undefined) sources. + +* \pdfobj now has an extra optional keyword: 'uncompressed', + which forces the object to be written to the PDF in plain + text (see the manual for the exact details). + +* The lua file from the luamd5 library (which provides the + md5.hexsuma() function) is now embedded in the executable. + +Bug fixes: + +* \latelua now works in DVI mode again. + +* status.output_file_name could crash when used too soon. + +* In 0.43, rules were not output at all in DVI mode. + +* \leavevmode\penalty-10000\penalty-10000 crashed luatex. + +* the API of margin kern nodes to lua was using the wrong + fields in the nodes. + +* A few fixes to the manual. + +* PDF Xref stream dicts were slightly non-conformant. + +* There was too much space between two consecutive math displays + (this bug was inherited from Aleph) + +* Synctex was broken (thanks, Akira) + +* Font mark classes were handled incorrectly by the fontloader + code. + +* There was a crash possible with certain types of named PDF + destinations. + +* Math delimiters and large operators in new MATH fonts no + longer apply the italic correction (this fixes placements + of super- and subscripts on such items for those fonts). + +* The converter from lua strings to token lists (for the node + interface) sometimes generated invalid tokens. + +* CFF (OpenType) fonts now listen to 'embedding="full"'. TTF + is still todo. + +* Font tables with 'embedding="no"' would cause luatex to crash. + +* \pdfobj file {} failed to find the file if there was no lua + callback in place. + +* An optimization in MS Mincho caused luatex to crash. + +============================================================== +Luatex beta-0.43.0 was released 20090819 +============================================================== + +New features: + +* There is a new allowed key in the table trhat is returned + by lua-loaded fonts: .psname. This value should be set + to the original PostScript font name of the font. Fonts inside + dfont and ttc collections are fetched using this field + (if it is missing, .fullname will be used instead). + +* It is now possible to use Apple dfont font files + (those that contain at least one outline font). + +* \latelua is now allowed inside leaders. + +* There is a new callback: process_output_buffer, from Manuel + Pégourié-Gonnard. This callback is called just before + \write acts, so it can be used to alter the file encoding + of text output files. + +* There is a new node.dimensions() function, which calculates + the natural size of (part of) a list of nodes. + +* The new primitive \gleaders provides 'globally aligned' + leaders. + +* The DVI and PDF backends now share much code internally. + +* The embedded MPlib is now 1.207. + +* libpng is now 1.2.39. + +Bugfixes: + +* We fixed lots of anonymous bugs introduced in 0.42.0 (as expected) + +* fontloader.info() errors are no longer fatal, the function now + just returns a nil,"error string" pair. + +* Automatically inserted kerns for \accents are now once again + valid word ends, as in \TEX. + +* Fixed the placement of math displays in mixed direction + settings. + +* The \pdfcompresslevel is now dynamic again. + +============================================================== +Luatex beta-0.42.0 was released 20090717 +============================================================== + +* There is a new node.tail() function + +* lua-loaded fonts now support a 'nomath' key to speed up + loading the lua table. + +* A bugfix in the ttf reader for the inclusion backend, and + (also in the backend) support for treating ttc files by + pretending they are single ttf fonts (both patches from pdftex) + +* Add Khaled Hosny's man page to the repository + +* The \pdfcompresslevel is now effectively fixed as soon as + output to the pdf file has occurred. + +* Patched status.filename so that it (nearly) always returns a + file name. + +* fix '\the\delcode' and disable '\the\odelcode', '\the\Udelcode', + and '\the\Udelcodenum' + +* Handle jfifs where either xres or yres is 0 and the other + res is != 0 (from pdftex) + +* The single-argument version of lang.hyphenate() was broken. + +* Get rid of the \directlua/\latelua number warning. + +* The Lua coroutine patch (coco) is now disabled on linux + powerpc architectures (because it caused crashes) + +* Removed obsolete pdftex primitives: + \pdfoptionalwaysusepdfpagebox + \pdfoptionpdfinclusionerrorlevel + \pdfforcepagebox + \pdfmovechars + +* The loading speed of large fonts (especially ttf) via the + fontloader library, and the inclusion speed for subsetting + in the backend have both been improved. + +* The 'pdf' lua library has been enhanced with various new + functions, see the manual for details. + +* BLT and BRT glyph position fixed. + +* Various fixes for synctex offsets. + +* Support for exotic font string encodings has been removed + from the fontloader library. + +* The embedded MPlib is now 1.205. + +* libpng is now 1.2.38. + ============================================================== Luatex beta-0.40.6 was released 20090625 ============================================================== @@ -8,7 +643,6 @@ Luatex beta-0.40.6 was released 20090625 * Sometimes pdf.print() could be used before the proper structures were initialized. - * There was a bug in the type codes for the lua package filter callback: wrong extra info was passed to lua for the alignment @@ -849,7 +1483,7 @@ Other news: we probably introduced new problems as well). * Most (all?) files now have a corrected Copyright header, - and link in $Id$ and $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/NEWS $ into the object file. + and link in $Id$ and $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/NEWS $ into the object file. * Some unnecessary files were removed from the distribution. diff --git a/Build/source/texk/web2c/luatexdir/README b/Build/source/texk/web2c/luatexdir/README deleted file mode 100644 index f1e142f1b25..00000000000 --- a/Build/source/texk/web2c/luatexdir/README +++ /dev/null @@ -1,87 +0,0 @@ -pdfTeX -====== - -README for version 3.14159-1.40.0-beta-20060811 -=============================================== - -This directory contains the version 1.40.0-alpha-20060811 of pdfTeX, an -extended version of eTeX that can create PDF directly from TeX source files -and enhance the result of TeX typesetting with the help of PDF. When PDF -output is not selected, pdfTeX produces normal DVI output, otherwise it -produces PDF output that looks identical to the DVI output. An important -aspect of this project is to investigate alternative justification -algorithms, optionally making use of multiple master fonts. - -pdfTeX is based on the original eTeX sources and Web2c, and has been -successfully compiled on Unix, Win32 and DOS systems. It is still under -development and features may change; it produces reasonable PDF code. - -See the file NEWS for changes to the program. - -Documentation about pdfTeX can be found at http://www.pdftex.org - -There is also a mailing list on pdfTeX; go to -http://tug.org/mailman/listinfo/pdftex for more information about it. Its -searchable archive can be found at http://tug.org/pipermail/pdftex/ -Please read http://www.catb.org/~esr/faqs/smart-questions.html before -asking any questions on the pdfTeX mailing list. - -A mailing list for the developement of pdfTeX can be found at -http://www.ntg.nl/mailman/listinfo/ntg-pdftex - - -LEGAL ISSUES -============ - -pdfTeX is copyright (c) 1996-2006 Han The Thanh, - -pdfTeX is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -pdfTeX is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along -with pdfTeX; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -pdfTeX uses code from TeX; for these parts the original copyright by Don -Knuth applies. See the source files for details. - -pdfeTeX uses code from eTeX; for these parts the original copyright by -Peter Breitenlohner applies. See the source files for details. - - -WHAT TO DO IF YOU BELIEVE YOU HAVE FOUND A BUG IN pdfTeX -======================================================== - -Please read http://www.chiark.greenend.org.uk/~sgtatham/bugs.html and -follow the guidelines there. Then go to the sarovar site of pdfTeX -(http://sarovar.org/projects/pdftex/) and submit your bug report there. -Here you can also report feature requests or patches. - - -CONTRIBUTORS -============ - -Peter Breitenlohner, Ricardo Sanchez Carmenes, Otfried Cheong, Thomas -Esser, Hans Hagen, Hartmut Henkel, Taco Hoekwater, Pawel Jackowski, Tom -Kacvinsky, Akira Kakuto, Reinhard Kotucha, Derek B. Noonburg, Heiko -Oberdiek, Jiri Osoba, Fabrice Popineau, Sebastian Rahtz, Tomas Rokicki, -Martin Schröder, Petr Sojka, Ralf Utermann, Olaf Weber, Jiri Zlatuska. - -pdfTeX is built on top of TeX, written by Donald Knuth cum suis (Liang and -so), and eTeX, written by Peter Breitenlohner cum suis; part of the -paragraph optimization is inspired by the work of Hermann Zapf. - - ------------------------------------------------------------------------------- - -Please send bug reports, offers of help, etc. to martin@pdftex.org - -$Id$ -// vim: tw=75 diff --git a/Build/source/texk/web2c/luatexdir/am/libluatex.am b/Build/source/texk/web2c/luatexdir/am/libluatex.am index 626cdc4ab64..9a0397ddd3f 100644 --- a/Build/source/texk/web2c/luatexdir/am/libluatex.am +++ b/Build/source/texk/web2c/luatexdir/am/libluatex.am @@ -16,59 +16,528 @@ libluatex_a_CPPFLAGS += -DpdfTeX libluatex_a_CFLAGS = $(WARNING_CFLAGS) libluatex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) +luatex_dvi_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/dvi $(ctangle) + +dvigen.c: ctangle$(EXEEXT) luatexdir/dvi/dvigen.w + $(luatex_dvi_ctangle) dvigen.w + +libluatex_web = luatexdir/dvi/dvigen.w + +nodist_libluatex_a_SOURCES = dvigen.c + +luatex_font_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/font $(ctangle) + +dofont.c: ctangle$(EXEEXT) luatexdir/font/dofont.w + $(luatex_font_ctangle) dofont.w +luafont.c: ctangle$(EXEEXT) luatexdir/font/luafont.w + $(luatex_font_ctangle) luafont.w +mapfile.c: ctangle$(EXEEXT) luatexdir/font/mapfile.w + $(luatex_font_ctangle) mapfile.w +pkin.c: ctangle$(EXEEXT) luatexdir/font/pkin.w + $(luatex_font_ctangle) pkin.w +sfnt.c: ctangle$(EXEEXT) luatexdir/font/sfnt.w + $(luatex_font_ctangle) sfnt.w +subfont.c: ctangle$(EXEEXT) luatexdir/font/subfont.w + $(luatex_font_ctangle) subfont.w +texfont.c: ctangle$(EXEEXT) luatexdir/font/texfont.w + $(luatex_font_ctangle) texfont.w +tfmofm.c: ctangle$(EXEEXT) luatexdir/font/tfmofm.w + $(luatex_font_ctangle) tfmofm.w +tounicode.c: ctangle$(EXEEXT) luatexdir/font/tounicode.w + $(luatex_font_ctangle) tounicode.w +tt_glyf.c: ctangle$(EXEEXT) luatexdir/font/tt_glyf.w + $(luatex_font_ctangle) tt_glyf.w +tt_table.c: ctangle$(EXEEXT) luatexdir/font/tt_table.w + $(luatex_font_ctangle) tt_table.w +vfovf.c: ctangle$(EXEEXT) luatexdir/font/vfovf.w + $(luatex_font_ctangle) vfovf.w +vfpacket.c: ctangle$(EXEEXT) luatexdir/font/vfpacket.w + $(luatex_font_ctangle) vfpacket.w +writecff.c: ctangle$(EXEEXT) luatexdir/font/writecff.w + $(luatex_font_ctangle) writecff.w +writeenc.c: ctangle$(EXEEXT) luatexdir/font/writeenc.w + $(luatex_font_ctangle) writeenc.w +writefont.c: ctangle$(EXEEXT) luatexdir/font/writefont.w + $(luatex_font_ctangle) writefont.w +writet1.c: ctangle$(EXEEXT) luatexdir/font/writet1.w + $(luatex_font_ctangle) writet1.w +writet3.c: ctangle$(EXEEXT) luatexdir/font/writet3.w + $(luatex_font_ctangle) writet3.w +writettf.c: ctangle$(EXEEXT) luatexdir/font/writettf.w + $(luatex_font_ctangle) writettf.w +writetype0.c: ctangle$(EXEEXT) luatexdir/font/writetype0.w + $(luatex_font_ctangle) writetype0.w +writetype2.c: ctangle$(EXEEXT) luatexdir/font/writetype2.w + $(luatex_font_ctangle) writetype2.w + + +libluatex_web += luatexdir/font/dofont.w luatexdir/font/luafont.w luatexdir/font/mapfile.w +libluatex_web += luatexdir/font/pkin.w luatexdir/font/sfnt.w luatexdir/font/subfont.w +libluatex_web += luatexdir/font/texfont.w luatexdir/font/tfmofm.w +libluatex_web += luatexdir/font/tounicode.w luatexdir/font/tt_glyf.w +libluatex_web += luatexdir/font/tt_table.w luatexdir/font/vfovf.w +libluatex_web += luatexdir/font/vfpacket.w luatexdir/font/writecff.w +libluatex_web += luatexdir/font/writeenc.w luatexdir/font/writefont.w +libluatex_web += luatexdir/font/writet1.w luatexdir/font/writet3.w +libluatex_web += luatexdir/font/writettf.w luatexdir/font/writetype0.w +libluatex_web += luatexdir/font/writetype2.w + +nodist_libluatex_a_SOURCES += dofont.c luafont.c mapfile.c pkin.c sfnt.c subfont.c +nodist_libluatex_a_SOURCES += texfont.c tfmofm.c tounicode.c tt_glyf.c tt_table.c vfovf.c vfpacket.c +nodist_libluatex_a_SOURCES += writecff.c writeenc.c writefont.c writet1.c writet3.c writettf.c +nodist_libluatex_a_SOURCES += writetype0.c writetype2.c + +luatex_image_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/image $(ctangle) + +epdf.c: ctangle$(EXEEXT) luatexdir/image/epdf.w + $(luatex_image_ctangle) epdf.w +writeimg.c: ctangle$(EXEEXT) luatexdir/image/writeimg.w + $(luatex_image_ctangle) writeimg.w +writejbig2.c: ctangle$(EXEEXT) luatexdir/image/writejbig2.w + $(luatex_image_ctangle) writejbig2.w +writejpg.c: ctangle$(EXEEXT) luatexdir/image/writejpg.w + $(luatex_image_ctangle) writejpg.w +writepng.c: ctangle$(EXEEXT) luatexdir/image/writepng.w + $(luatex_image_ctangle) writepng.w + +libluatex_web += luatexdir/image/epdf.w luatexdir/image/writeimg.w +libluatex_web += luatexdir/image/writejbig2.w luatexdir/image/writejpg.w luatexdir/image/writepng.w + +nodist_libluatex_a_SOURCES += epdf.c writeimg.c writejbig2.c writejpg.c writepng.c + + +luatex_lua_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/lua $(ctangle) + +luagen.c: ctangle$(EXEEXT) luatexdir/lua/luagen.w + $(luatex_lua_ctangle) luagen.w +luainit.c: ctangle$(EXEEXT) luatexdir/lua/luainit.w + $(luatex_lua_ctangle) luainit.w +luanode.c: ctangle$(EXEEXT) luatexdir/lua/luanode.w + $(luatex_lua_ctangle) luanode.w +luastuff.c: ctangle$(EXEEXT) luatexdir/lua/luastuff.w + $(luatex_lua_ctangle) luastuff.w +luatoken.c: ctangle$(EXEEXT) luatexdir/lua/luatoken.w + $(luatex_lua_ctangle) luatoken.w +texluac.c: ctangle$(EXEEXT) luatexdir/lua/texluac.w + $(luatex_lua_ctangle) texluac.w + +libluatex_web += luatexdir/lua/luagen.w luatexdir/lua/luainit.w luatexdir/lua/luanode.w +libluatex_web += luatexdir/lua/luastuff.w luatexdir/lua/luatoken.w luatexdir/lua/texluac.w + +nodist_libluatex_a_SOURCES += luagen.c luainit.c luanode.c luastuff.c luatoken.c texluac.c + + +luatex_ocp_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/ocp $(ctangle) + +ocp.c: ctangle$(EXEEXT) luatexdir/ocp/ocp.w + $(luatex_ocp_ctangle) ocp.w + +runocp.c: ctangle$(EXEEXT) luatexdir/ocp/runocp.w + $(luatex_ocp_ctangle) runocp.w + +readocp.c: ctangle$(EXEEXT) luatexdir/ocp/readocp.w + $(luatex_ocp_ctangle) readocp.w + +ocplist.c: ctangle$(EXEEXT) luatexdir/ocp/ocplist.w + $(luatex_ocp_ctangle) ocplist.w + +libluatex_web += luatexdir/ocp/ocp.w luatexdir/ocp/ocplist.w luatexdir/ocp/readocp.w luatexdir/ocp/runocp.w + +nodist_libluatex_a_SOURCES += ocp.c ocplist.c readocp.c runocp.c + +luatex_lang_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/lang $(ctangle) + +hnjalloc.c: ctangle$(EXEEXT) luatexdir/lang/hnjalloc.w + $(luatex_lang_ctangle) hnjalloc.w + +hyphen.c: ctangle$(EXEEXT) luatexdir/lang/hyphen.w + $(luatex_lang_ctangle) hyphen.w + +texlang.c: ctangle$(EXEEXT) luatexdir/lang/texlang.w + $(luatex_lang_ctangle) texlang.w + +libluatex_web += luatexdir/lang/texlang.w luatexdir/lang/hyphen.w luatexdir/lang/hnjalloc.w + +nodist_libluatex_a_SOURCES += texlang.c hyphen.c hnjalloc.c + +luatex_pdf_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/pdf $(ctangle) + +pagetree.c: ctangle$(EXEEXT) luatexdir/pdf/pagetree.w + $(luatex_pdf_ctangle) pagetree.w + +pdfaction.c: ctangle$(EXEEXT) luatexdir/pdf/pdfaction.w + $(luatex_pdf_ctangle) pdfaction.w + +pdfannot.c: ctangle$(EXEEXT) luatexdir/pdf/pdfannot.w + $(luatex_pdf_ctangle) pdfannot.w + +pdfcolorstack.c: ctangle$(EXEEXT) luatexdir/pdf/pdfcolorstack.w + $(luatex_pdf_ctangle) pdfcolorstack.w + +pdfdest.c: ctangle$(EXEEXT) luatexdir/pdf/pdfdest.w + $(luatex_pdf_ctangle) pdfdest.w + +pdffont.c: ctangle$(EXEEXT) luatexdir/pdf/pdffont.w + $(luatex_pdf_ctangle) pdffont.w + +pdfgen.c: ctangle$(EXEEXT) luatexdir/pdf/pdfgen.w + $(luatex_pdf_ctangle) pdfgen.w + +pdfglyph.c: ctangle$(EXEEXT) luatexdir/pdf/pdfglyph.w + $(luatex_pdf_ctangle) pdfglyph.w + +pdfimage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfimage.w + $(luatex_pdf_ctangle) pdfimage.w + +pdflink.c: ctangle$(EXEEXT) luatexdir/pdf/pdflink.w + $(luatex_pdf_ctangle) pdflink.w + +pdflistout.c: ctangle$(EXEEXT) luatexdir/pdf/pdflistout.w + $(luatex_pdf_ctangle) pdflistout.w + +pdfliteral.c: ctangle$(EXEEXT) luatexdir/pdf/pdfliteral.w + $(luatex_pdf_ctangle) pdfliteral.w + +pdfobj.c: ctangle$(EXEEXT) luatexdir/pdf/pdfobj.w + $(luatex_pdf_ctangle) pdfobj.w + +pdfoutline.c: ctangle$(EXEEXT) luatexdir/pdf/pdfoutline.w + $(luatex_pdf_ctangle) pdfoutline.w + +pdfpage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfpage.w + $(luatex_pdf_ctangle) pdfpage.w + +pdfrule.c: ctangle$(EXEEXT) luatexdir/pdf/pdfrule.w + $(luatex_pdf_ctangle) pdfrule.w + +pdfsaverestore.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsaverestore.w + $(luatex_pdf_ctangle) pdfsaverestore.w + +pdfsetmatrix.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsetmatrix.w + $(luatex_pdf_ctangle) pdfsetmatrix.w + +pdfshipout.c: ctangle$(EXEEXT) luatexdir/pdf/pdfshipout.w + $(luatex_pdf_ctangle) pdfshipout.w + +pdftables.c: ctangle$(EXEEXT) luatexdir/pdf/pdftables.w + $(luatex_pdf_ctangle) pdftables.w + +pdfthread.c: ctangle$(EXEEXT) luatexdir/pdf/pdfthread.w + $(luatex_pdf_ctangle) pdfthread.w + +pdfxform.c: ctangle$(EXEEXT) luatexdir/pdf/pdfxform.w + $(luatex_pdf_ctangle) pdfxform.w + +libluatex_web += luatexdir/pdf/pagetree.w luatexdir/pdf/pdfaction.w luatexdir/pdf/pdfannot.w +libluatex_web += luatexdir/pdf/pdfcolorstack.w luatexdir/pdf/pdfdest.w +libluatex_web += luatexdir/pdf/pdffont.w luatexdir/pdf/pdfgen.w luatexdir/pdf/pdfglyph.w +libluatex_web += luatexdir/pdf/pdfimage.w luatexdir/pdf/pdflink.w luatexdir/pdf/pdflistout.w +libluatex_web += luatexdir/pdf/pdfliteral.w luatexdir/pdf/pdfobj.w luatexdir/pdf/pdfoutline.w +libluatex_web += luatexdir/pdf/pdfpage.w luatexdir/pdf/pdfrule.w +libluatex_web += luatexdir/pdf/pdfsaverestore.w luatexdir/pdf/pdfsetmatrix.w +libluatex_web += luatexdir/pdf/pdfshipout.w luatexdir/pdf/pdftables.w +libluatex_web += luatexdir/pdf/pdfthread.w luatexdir/pdf/pdfxform.w + +nodist_libluatex_a_SOURCES += pagetree.c pdfaction.c pdfannot.c pdfcolorstack.c pdfdest.c pdffont.c +nodist_libluatex_a_SOURCES += pdfgen.c pdfglyph.c pdfimage.c pdflink.c pdflistout.c pdfliteral.c +nodist_libluatex_a_SOURCES += pdfobj.c pdfoutline.c pdfpage.c pdfrule.c pdfsaverestore.c +nodist_libluatex_a_SOURCES += pdfsetmatrix.c pdfshipout.c pdftables.c pdfthread.c pdfxform.c + +luatex_tex_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/tex $(ctangle) + +align.c: ctangle$(EXEEXT) luatexdir/tex/align.w + $(luatex_tex_ctangle) align.w + +libluatex_web += luatexdir/tex/align.w + +nodist_libluatex_a_SOURCES += align.c + +dumpdata.c: ctangle$(EXEEXT) luatexdir/tex/dumpdata.w + $(luatex_tex_ctangle) dumpdata.w + +nodist_libluatex_a_SOURCES += dumpdata.c + +libluatex_web += luatexdir/tex/dumpdata.w + + +expand.c: ctangle$(EXEEXT) luatexdir/tex/expand.w + $(luatex_tex_ctangle) expand.w + +nodist_libluatex_a_SOURCES += expand.c + +libluatex_web += luatexdir/tex/expand.w + + +inputstack.c: ctangle$(EXEEXT) luatexdir/tex/inputstack.w + $(luatex_tex_ctangle) inputstack.w + +nodist_libluatex_a_SOURCES += inputstack.c + +libluatex_web += luatexdir/tex/inputstack.w + + +maincontrol.c: ctangle$(EXEEXT) luatexdir/tex/maincontrol.w + $(luatex_tex_ctangle) maincontrol.w + +nodist_libluatex_a_SOURCES += maincontrol.c + +libluatex_web += luatexdir/tex/maincontrol.w + + +mlist.c: ctangle$(EXEEXT) luatexdir/tex/mlist.w + $(luatex_tex_ctangle) mlist.w + +nodist_libluatex_a_SOURCES += mlist.c + +libluatex_web += luatexdir/tex/mlist.w + + +postlinebreak.c: ctangle$(EXEEXT) luatexdir/tex/postlinebreak.w + $(luatex_tex_ctangle) postlinebreak.w + +nodist_libluatex_a_SOURCES += postlinebreak.c + +libluatex_web += luatexdir/tex/postlinebreak.w + + +scanning.c: ctangle$(EXEEXT) luatexdir/tex/scanning.w + $(luatex_tex_ctangle) scanning.w + +nodist_libluatex_a_SOURCES += scanning.c + +libluatex_web += luatexdir/tex/scanning.w + + +texdeffont.c: ctangle$(EXEEXT) luatexdir/tex/texdeffont.w + $(luatex_tex_ctangle) texdeffont.w + +nodist_libluatex_a_SOURCES += texdeffont.c + +libluatex_web += luatexdir/tex/texdeffont.w + + +texnodes.c: ctangle$(EXEEXT) luatexdir/tex/texnodes.w + $(luatex_tex_ctangle) texnodes.w + +nodist_libluatex_a_SOURCES += texnodes.c + +libluatex_web += luatexdir/tex/texnodes.w + + +arithmetic.c: ctangle$(EXEEXT) luatexdir/tex/arithmetic.w + $(luatex_tex_ctangle) arithmetic.w + +nodist_libluatex_a_SOURCES += arithmetic.c + +libluatex_web += luatexdir/tex/arithmetic.w + + +conditional.c: ctangle$(EXEEXT) luatexdir/tex/conditional.w + $(luatex_tex_ctangle) conditional.w + +nodist_libluatex_a_SOURCES += conditional.c + +libluatex_web += luatexdir/tex/conditional.w + + +equivalents.c: ctangle$(EXEEXT) luatexdir/tex/equivalents.w + $(luatex_tex_ctangle) equivalents.w + +nodist_libluatex_a_SOURCES += equivalents.c + +libluatex_web += luatexdir/tex/equivalents.w + + +extensions.c: ctangle$(EXEEXT) luatexdir/tex/extensions.w + $(luatex_tex_ctangle) extensions.w + +nodist_libluatex_a_SOURCES += extensions.c + +libluatex_web += luatexdir/tex/extensions.w + +commands.c: ctangle$(EXEEXT) luatexdir/tex/commands.w + $(luatex_tex_ctangle) commands.w + +nodist_libluatex_a_SOURCES += commands.c + +libluatex_web += luatexdir/tex/commands.w + + +linebreak.c: ctangle$(EXEEXT) luatexdir/tex/linebreak.w + $(luatex_tex_ctangle) linebreak.w + +nodist_libluatex_a_SOURCES += linebreak.c + +libluatex_web += luatexdir/tex/linebreak.w + + +mathcodes.c: ctangle$(EXEEXT) luatexdir/tex/mathcodes.w + $(luatex_tex_ctangle) mathcodes.w + +nodist_libluatex_a_SOURCES += mathcodes.c + +libluatex_web += luatexdir/tex/mathcodes.w + + +nesting.c: ctangle$(EXEEXT) luatexdir/tex/nesting.w + $(luatex_tex_ctangle) nesting.w + +nodist_libluatex_a_SOURCES += nesting.c + +libluatex_web += luatexdir/tex/nesting.w + + +primitive.c: ctangle$(EXEEXT) luatexdir/tex/primitive.w + $(luatex_tex_ctangle) primitive.w + +nodist_libluatex_a_SOURCES += primitive.c + +libluatex_web += luatexdir/tex/primitive.w + + +texfileio.c: ctangle$(EXEEXT) luatexdir/tex/texfileio.w + $(luatex_tex_ctangle) texfileio.w + +nodist_libluatex_a_SOURCES += texfileio.c + +libluatex_web += luatexdir/tex/texfileio.w + + +textcodes.c: ctangle$(EXEEXT) luatexdir/tex/textcodes.w + $(luatex_tex_ctangle) textcodes.w + +nodist_libluatex_a_SOURCES += textcodes.c + +libluatex_web += luatexdir/tex/textcodes.w + + +buildpage.c: ctangle$(EXEEXT) luatexdir/tex/buildpage.w + $(luatex_tex_ctangle) buildpage.w + +nodist_libluatex_a_SOURCES += buildpage.c + +libluatex_web += luatexdir/tex/buildpage.w + + +directions.c: ctangle$(EXEEXT) luatexdir/tex/directions.w + $(luatex_tex_ctangle) directions.w + +nodist_libluatex_a_SOURCES += directions.c + +libluatex_web += luatexdir/tex/directions.w + + +errors.c: ctangle$(EXEEXT) luatexdir/tex/errors.w + $(luatex_tex_ctangle) errors.w + +nodist_libluatex_a_SOURCES += errors.c + +libluatex_web += luatexdir/tex/errors.w + + +filename.c: ctangle$(EXEEXT) luatexdir/tex/filename.w + $(luatex_tex_ctangle) filename.w + +nodist_libluatex_a_SOURCES += filename.c + +libluatex_web += luatexdir/tex/filename.w + + +mainbody.c: ctangle$(EXEEXT) luatexdir/tex/mainbody.w + $(luatex_tex_ctangle) mainbody.w + +nodist_libluatex_a_SOURCES += mainbody.c + +libluatex_web += luatexdir/tex/mainbody.w + + +memoryword.c: ctangle$(EXEEXT) luatexdir/tex/memoryword.w + $(luatex_tex_ctangle) memoryword.w + +nodist_libluatex_a_SOURCES += memoryword.c + +libluatex_web += luatexdir/tex/memoryword.w + + +packaging.c: ctangle$(EXEEXT) luatexdir/tex/packaging.w + $(luatex_tex_ctangle) packaging.w + +nodist_libluatex_a_SOURCES += packaging.c + +libluatex_web += luatexdir/tex/packaging.w + + +printing.c: ctangle$(EXEEXT) luatexdir/tex/printing.w + $(luatex_tex_ctangle) printing.w + +nodist_libluatex_a_SOURCES += printing.c + +libluatex_web += luatexdir/tex/printing.w + + +stringpool.c: ctangle$(EXEEXT) luatexdir/tex/stringpool.w + $(luatex_tex_ctangle) stringpool.w + +nodist_libluatex_a_SOURCES += stringpool.c + +libluatex_web += luatexdir/tex/stringpool.w + + +texmath.c: ctangle$(EXEEXT) luatexdir/tex/texmath.w + $(luatex_tex_ctangle) texmath.w + +nodist_libluatex_a_SOURCES += texmath.c + +libluatex_web += luatexdir/tex/texmath.w + + +textoken.c: ctangle$(EXEEXT) luatexdir/tex/textoken.w + $(luatex_tex_ctangle) textoken.w + +nodist_libluatex_a_SOURCES += textoken.c + +libluatex_web += luatexdir/tex/textoken.w + + +luatex_utils_ctangle = CWEBINPUTS=$(srcdir)/luatexdir/utils $(ctangle) + +utils.c: ctangle$(EXEEXT) luatexdir/utils/utils.w + $(luatex_utils_ctangle) utils.w +managed-sa.c: ctangle$(EXEEXT) luatexdir/utils/managed-sa.w + $(luatex_utils_ctangle) managed-sa.w +avlstuff.c: ctangle$(EXEEXT) luatexdir/utils/avlstuff.w + $(luatex_utils_ctangle) avlstuff.w + +libluatex_web += luatexdir/utils/utils.w luatexdir/utils/avlstuff.w luatexdir/utils/managed-sa.w + +nodist_libluatex_a_SOURCES += utils.c avlstuff.c managed-sa.c + + libluatex_a_SOURCES = \ - luatexdir/commands.h \ - luatexdir/font/dofont.c \ + luatexdir/dvi/dvigen.h \ luatexdir/font/luatexfont.h \ - luatexdir/font/luafont.c \ - luatexdir/font/mapfile.c \ luatexdir/font/mapfile.h \ - luatexdir/font/pkin.c \ - luatexdir/font/sfnt.c \ luatexdir/font/sfnt.h \ - luatexdir/font/subfont.c \ - luatexdir/font/texfont.c \ luatexdir/font/texfont.h \ - luatexdir/font/tfmofm.c \ - luatexdir/font/tounicode.c \ - luatexdir/font/tt_glyf.c \ luatexdir/font/tt_glyf.h \ - luatexdir/font/tt_table.c \ luatexdir/font/tt_table.h \ - luatexdir/font/vfovf.c \ - luatexdir/font/vfpacket.c \ - luatexdir/font/writecff.c \ luatexdir/font/writecff.h \ - luatexdir/font/writeenc.c \ - luatexdir/font/writefont.c \ - luatexdir/font/writet1.c \ - luatexdir/font/writet3.c \ - luatexdir/font/writettf.c \ luatexdir/font/writettf.h \ - luatexdir/font/writetype0.c \ - luatexdir/font/writetype2.c \ - luatexdir/get_svnversion.sh \ - luatexdir/hyphen.h \ - luatexdir/image/epdf.c \ luatexdir/image/epdf.h \ luatexdir/image/image.h \ luatexdir/image/pdftoepdf.cc \ luatexdir/image/pdftoepdf.h \ - luatexdir/image/writeimg.c \ luatexdir/image/writeimg.h \ - luatexdir/image/writejbig2.c \ luatexdir/image/writejbig2.h \ - luatexdir/image/writejpg.c \ luatexdir/image/writejpg.h \ - luatexdir/image/writepng.c \ luatexdir/image/writepng.h \ - luatexdir/lang/hnjalloc.c \ luatexdir/lang/hnjalloc.h \ - luatexdir/lang/hyphen.c \ - luatexdir/lang/texlang.c \ + luatexdir/lang/hyphen.h \ + luatexdir/lang/texlang.h \ luatexdir/lua/lcallbacklib.c \ luatexdir/lua/lfontlib.c \ luatexdir/lua/limglib.c \ + luatexdir/lua/lepdflib.cc \ luatexdir/lua/lkpselib.c \ luatexdir/lua/llanglib.c \ luatexdir/lua/llualib.c \ @@ -80,65 +549,87 @@ libluatex_a_SOURCES = \ luatexdir/lua/ltexiolib.c \ luatexdir/lua/ltexlib.c \ luatexdir/lua/ltokenlib.c \ - luatexdir/lua/luainit.c \ - luatexdir/lua/luanode.c \ - luatexdir/lua/luastuff.c \ - luatexdir/lua/luatex.c \ - luatexdir/lua/luatoken.c \ - luatexdir/lua/texluac.c \ - luatexdir/luatex-api.h \ + luatexdir/lua/luagen.h \ + luatexdir/lua/luatex-api.h \ luatexdir/luatex.h \ - luatexdir/makecpool.c \ - luatexdir/managed-sa.c \ - luatexdir/managed-sa.h \ - luatexdir/mathcodes.c \ - luatexdir/nodes.h \ - luatexdir/pdf/pagetree.c \ + luatexdir/ocp/ocp.h \ + luatexdir/ocp/ocplist.h \ + luatexdir/ocp/readocp.h \ + luatexdir/ocp/runocp.h \ luatexdir/pdf/pagetree.h \ - luatexdir/pdf/pdfpage.c \ + luatexdir/pdf/pdfaction.h \ + luatexdir/pdf/pdfannot.h \ + luatexdir/pdf/pdfcolorstack.h \ + luatexdir/pdf/pdfdest.h \ + luatexdir/pdf/pdffont.h \ + luatexdir/pdf/pdfgen.h \ + luatexdir/pdf/pdfglyph.h \ + luatexdir/pdf/pdfimage.h \ + luatexdir/pdf/pdflink.h \ + luatexdir/pdf/pdflistout.h \ + luatexdir/pdf/pdfliteral.h \ + luatexdir/pdf/pdfobj.h \ + luatexdir/pdf/pdfoutline.h \ luatexdir/pdf/pdfpage.h \ - luatexdir/primitive.h \ - luatexdir/ptexmac.h \ - luatexdir/tex/filename.c \ - luatexdir/tex/linebreak.c \ - luatexdir/tex/math.c \ - luatexdir/tex/mlist.c \ - luatexdir/tex/postlinebreak.c \ - luatexdir/tex/primitive.c \ - luatexdir/tex/texdeffont.c \ - luatexdir/tex/texnodes.c \ - luatexdir/tex/texpdf.c \ - luatexdir/tex/textoken.c \ - luatexdir/texmath.h \ - luatexdir/textcodes.c \ - luatexdir/tokens.h \ + luatexdir/pdf/pdfrule.h \ + luatexdir/pdf/pdfsaverestore.h \ + luatexdir/pdf/pdfsetmatrix.h \ + luatexdir/pdf/pdfshipout.h \ + luatexdir/pdf/pdftables.h \ + luatexdir/pdf/pdfthread.h \ + luatexdir/pdf/pdftypes.h \ + luatexdir/pdf/pdfxform.h \ + luatexdir/tex/align.h \ + luatexdir/tex/arithmetic.h \ + luatexdir/tex/buildpage.h \ + luatexdir/tex/commands.h \ + luatexdir/tex/conditional.h \ + luatexdir/tex/directions.h \ + luatexdir/tex/dumpdata.h \ + luatexdir/tex/equivalents.h \ + luatexdir/tex/errors.h \ + luatexdir/tex/expand.h \ + luatexdir/tex/extensions.h \ + luatexdir/tex/filename.h \ + luatexdir/tex/inputstack.h \ + luatexdir/tex/linebreak.h \ + luatexdir/tex/mainbody.h \ + luatexdir/tex/maincontrol.h \ + luatexdir/tex/mathcodes.h \ + luatexdir/tex/memoryword.h \ + luatexdir/tex/mlist.h \ + luatexdir/tex/nesting.h \ + luatexdir/tex/packaging.h \ + luatexdir/tex/postlinebreak.h \ + luatexdir/tex/primitive.h \ + luatexdir/tex/printing.h \ + luatexdir/tex/scanning.h \ + luatexdir/tex/stringpool.h \ + luatexdir/tex/texdeffont.h \ + luatexdir/tex/texfileio.h \ + luatexdir/tex/texmath.h \ + luatexdir/tex/texnodes.h \ + luatexdir/tex/textoken.h \ + luatexdir/tex/textcodes.h \ luatexdir/utils/avl.c \ luatexdir/utils/avl.h \ - luatexdir/utils/avlstuff.c \ luatexdir/utils/avlstuff.h \ + luatexdir/utils/managed-sa.h \ luatexdir/utils/synctex.h \ luatexdir/utils/synctex.c \ - luatexdir/utils/utils.c \ luatexdir/utils/utils.h \ - luatexdir/utils/writezip.c \ + $(nodist_libluatex_a_SOURCES) \ mplibdir/lmplib.c -## FIXME: temporary additional headers: -libluatex_a_SOURCES += \ - luatexdir/inc-epdf.h \ - luatexdir/inc-extra.h \ - luatexdir/inc-vfovf.h +$(libluatex_a_OBJECTS): libff.a -## included by luatexdir/font/writettf.c -EXTRA_libluatex_a_SOURCES = luatexdir/font/macnames.c +EXTRA_DIST += $(libluatex_web) -# We must create libff.a and luatexd.h before building the libluatex_a_OBJECTS -$(libluatex_a_OBJECTS): libff.a luatexd.h luatexdir/luatexextra.h +DISTCLEANFILES += $(nodist_libluatex_a_SOURCES) EXTRA_DIST += \ luatexdir/ChangeLog \ luatexdir/NEWS \ luatexdir/README \ - luatexdir/change-files.txt \ luatexdir/font/subfont.txt diff --git a/Build/source/texk/web2c/luatexdir/am/luafontforge.am b/Build/source/texk/web2c/luatexdir/am/luafontforge.am index f137f43fe7f..8f1770d07d6 100644 --- a/Build/source/texk/web2c/luatexdir/am/luafontforge.am +++ b/Build/source/texk/web2c/luatexdir/am/luafontforge.am @@ -23,15 +23,12 @@ libff_a_CFLAGS = # $(WARNING_CFLAGS) libff_a_SOURCES = \ luatexdir/luafontloader/fontforge/Unicode/ArabicForms.c \ luatexdir/luafontloader/fontforge/Unicode/alphabet.c \ - luatexdir/luafontloader/fontforge/Unicode/backtrns.c \ luatexdir/luafontloader/fontforge/Unicode/char.c \ luatexdir/luafontloader/fontforge/Unicode/cjk.c \ luatexdir/luafontloader/fontforge/Unicode/combiners.h \ - luatexdir/luafontloader/fontforge/Unicode/dump.c \ luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c \ luatexdir/luafontloader/fontforge/Unicode/memory.c \ luatexdir/luafontloader/fontforge/Unicode/ucharmap.c \ - luatexdir/luafontloader/fontforge/Unicode/unialt.c \ luatexdir/luafontloader/fontforge/Unicode/ustring.c \ luatexdir/luafontloader/fontforge/Unicode/utype.c \ luatexdir/luafontloader/fontforge/fontforge/PfEd.h \ @@ -121,8 +118,7 @@ libff_a_SOURCES = \ luatexdir/luafontloader/fontforge/inc/ustring.h \ luatexdir/luafontloader/fontforge/inc/utype.h \ luatexdir/luafontloader/src/ffdummies.c \ - luatexdir/luafontloader/src/luafflib.c \ - luatexdir/luafontloader/src/luafflib.h + luatexdir/luafontloader/src/luafflib.c EXTRA_DIST += \ luatexdir/luafontloader/ChangeLog \ diff --git a/Build/source/texk/web2c/luatexdir/am/luamisc.am b/Build/source/texk/web2c/luatexdir/am/luamisc.am index 07a80dab334..5f43cf2b64a 100644 --- a/Build/source/texk/web2c/luatexdir/am/luamisc.am +++ b/Build/source/texk/web2c/luatexdir/am/luamisc.am @@ -22,8 +22,9 @@ libluamisc_a_SOURCES = \ luatexdir/luafilesystem/src/lfs.c \ luatexdir/luafilesystem/src/lfs.h \ luatexdir/luamd5/md5.c \ - luatexdir/luamd5/md5.h \ + luatexdir/luamd5/luamd5.h \ luatexdir/luamd5/md5lib.c \ + luatexdir/luamd5/md5_lua.c \ luatexdir/luapeg/lpeg.c \ luatexdir/luaprofiler/clocks.c \ luatexdir/luaprofiler/clocks.h \ diff --git a/Build/source/texk/web2c/luatexdir/am/luatangle.am b/Build/source/texk/web2c/luatexdir/am/luatangle.am index 75fa50ca29d..39218db3d56 100644 --- a/Build/source/texk/web2c/luatexdir/am/luatangle.am +++ b/Build/source/texk/web2c/luatexdir/am/luatangle.am @@ -3,33 +3,3 @@ ## Copyright (C) 2009 Peter Breitenlohner ## You may freely use, modify and/or distribute this file. -## luatangle -## -if LUATEX -bin_PROGRAMS += luatangle -endif LUATEX -EXTRA_PROGRAMS += luatangle - -nodist_luatangle_SOURCES = luatangle.c luatangle.h -luatangle.c luatangle.h: luatangle-web2c - @$(web2c) luatangle -luatangle-web2c: luatangle.p $(web2c_depend) - @$(web2c) luatangle - -EXTRA_DIST += $(luatangle_sources) - -luatangle_sources = luatexdir/luatangle.web luatexdir/luatangle.ch -luatangle.p: tangle$(EXEEXT) $(luatangle_sources) - WEBINPUTS=$(srcdir)/luatexdir $(buildenv) $(TANGLE) luatangle luatangle - -DISTCLEANFILES += luatangle.c luatangle.h luatangle-web2c luatangle.p - -## Tests -## -EXTRA_DIST += luatexdir/luatangle.test - -if LUATEX -TESTS += luatexdir/luatangle.test -endif LUATEX - -DISTCLEANFILES += cftest.p diff --git a/Build/source/texk/web2c/luatexdir/am/luatex.am b/Build/source/texk/web2c/luatexdir/am/luatex.am index 19f891fc7a6..e979f60865a 100644 --- a/Build/source/texk/web2c/luatexdir/am/luatex.am +++ b/Build/source/texk/web2c/luatexdir/am/luatex.am @@ -13,8 +13,6 @@ EXTRA_PROGRAMS += luatex # Force Automake to use CXXLD for linking nodist_EXTRA_luatex_SOURCES = dummy.cxx -luatex_tangle = WEBINPUTS=$(srcdir)/luatexdir $(SHELL) ./tangle-sh $@ '$(LUATANGLE) --underlines' - luatex_CPPFLAGS = $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) $(XPDF_INCLUDES) luatex_CPPFLAGS += $(OBSDCOMPAT_INCLUDES) -I$(srcdir)/libmd5 luatex_CPPFLAGS += -Iluatexdir -I$(srcdir)/luatexdir -I$(srcdir)/luatexdir/lua51 -I$(srcdir)/mplibdir @@ -24,40 +22,19 @@ luatex_CXXFLAGS = $(WARNING_CXXFLAGS) luatex_ldadd = libluatex.a libff.a libluamisc.a libluasocket.a liblua51.a luatex_ldadd += $(ZZIPLIB_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) $(XPDF_LIBS) -luatex_ldadd += $(OBSDCOMPAT_LIBS) libmd5.a libmplib.a +luatex_ldadd += $(OBSDCOMPAT_LIBS) libmd5.a libmplib.a + +luatex_LDFLAGS = -export-dynamic -luatex_LDADD = $(luatex_ldadd) $(LDADD) $(lua_socketlibs) +luatex_LDADD = $(luatex_ldadd) $(LDADD) $(LIBADD_DLOPEN) $(lua_socketlibs) luatex_DEPENDENCIES = $(proglib) $(KPATHSEA_DEPEND) libluatex.a luatex_DEPENDENCIES += $(LIBPNG_DEPEND) $(ZLIB_DEPEND) $(XPDF_DEPEND) luatex_DEPENDENCIES += $(OBSDCOMPAT_DEPEND) libmd5.a libmplib.a -# We must create libluatex.a and libmplib.a before building the luatex_OBJECTS. $(luatex_OBJECTS): libluatex.a libmplib.a -luatex_c_h = luatexini.c luatex0.c luatexcoerce.h luatexd.h -nodist_luatex_SOURCES = $(luatex_c_h) luatex-pool.c luatexextra.c luatexdir/luatexextra.h -$(luatex_c_h): luatex-web2c - @$(web2c) luatex -luatex-web2c: luatex.p $(web2c_texmf) luatexdir/luatex.defines - @$(web2c) luatex -luatexextra.c: luatexd.h luatexdir/luatexextra.h lib/texmfmp.c - sed s/TEX-OR-MF-OR-MP/luatex/ $(srcdir)/lib/texmfmp.c >$@ -luatex_sources = luatexdir/luatex.web luatexdir/luatex.ch -luatex.p luatex.pool: luatex-tangle - @$(luatex_tangle) luatex luatex -luatex-tangle: luatangle$(EXEEXT) $(luatex_sources) tangle-sh - @$(luatex_tangle) luatex luatex -luatex-pool.c: luatex.pool luatexd.h $(makecpool_stamp) - $(makecpool) luatex >$@ || rm -f $@ -# Extract luatex version -luatexdir/luatex.version: luatexdir/luatex.web - $(MKDIR_P) luatexdir - grep '^@d luatex_version_string==' $(srcdir)/luatexdir/luatex.web \ - | sed "s/^.*=='//;s/'.*$$//" >luatexdir/luatex.version -luatexdir/luatexextra.h: luatexdir/luatexextra.in luatexdir/luatex.version - sed -e s/LUATEX-VERSION/`cat luatexdir/luatex.version`/ \ - $(srcdir)/luatexdir/luatexextra.in >$@ +luatex_SOURCES = luatexdir/luatex_svnversion.h luatexdir/luatex.c luatexdir/luatex.h # Double-colon rules since we do something similar in mplibdir (maybe others). if LUATEX @@ -71,15 +48,5 @@ uninstall-hook:: rm -f $(DESTDIR)$(bindir)/texluac$(EXEEXT) endif LUATEX -EXTRA_DIST += $(luatex_sources) \ - luatexdir/luatex.defines \ - luatexdir/luatexextra.in \ - luatexdir/ptexlib.h - -DISTCLEANFILES += $(nodist_luatex_SOURCES) luatex-web2c \ - luatex.p luatex.pool luatex-tangle luatexdir/luatex.version - -## Eventually delete these files -## -EXTRA_DIST += luatexdir/luatex.mk +EXTRA_DIST += luatexdir/ptexlib.h diff --git a/Build/source/texk/web2c/luatexdir/change-files.txt b/Build/source/texk/web2c/luatexdir/change-files.txt deleted file mode 100644 index c6a3387f41d..00000000000 --- a/Build/source/texk/web2c/luatexdir/change-files.txt +++ /dev/null @@ -1,35 +0,0 @@ -How change files are applied for pdftex/pdfetex? - -============================= pdftex ============================= - -2) pdftex.ch is generated from - ./tie -c pdftex.ch pdftex.web \ - $(srcdir)/pdftexdir/tex.ch0 \ - $(srcdir)/tex.ch \ - $(srcdir)/pdftexdir/tex.ch1 \ - $(srcdir)/pdftexdir/tex.pch - -Input: - pdftex.web: - pdftex without system-dependent changes - - pdftexdir/tex.ch0: - % Change file to assist in creating the web2c-specific change file. - % This one comes first, resolves inconsistencies between the - % generated pdftex.web and tex.ch - - change the pdftex banner to tex banner, so tex.ch can be applied - - tex.ch: - the main web2c-specific (or other system-dependent) change file - - pdftexdir/pdftex.ch: - - % Change file to assist in creating the web2c-specific change file. - % This one resolves inconsistencies between tex.ch and tex.pch. - - change the tex banner to pdftex banner (reverse tex.ch0) - -Output: - pdftex.ch (not pdftexdir/pdftex.ch): - additional & system-dependent changes diff --git a/Build/source/texk/web2c/luatexdir/commands.h b/Build/source/texk/web2c/luatexdir/commands.h deleted file mode 100644 index b9a50adca8e..00000000000 --- a/Build/source/texk/web2c/luatexdir/commands.h +++ /dev/null @@ -1,554 +0,0 @@ -/* commands.h - - Copyright 2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -/* $Id: commands.h 2554 2009-06-21 07:58:02Z taco $ */ - - -typedef enum { - relax_cmd = 0, /* do nothing ( \.{\\relax} ) */ -#define escape_cmd relax_cmd /* escape delimiter (called \.\\ in {\sl The \TeX book\/}) */ - left_brace_cmd, /* beginning of a group ( \.\{ ) */ - right_brace_cmd, /* ending of a group ( \.\} ) */ - math_shift_cmd, /* mathematics shift character ( \.\$ ) */ - tab_mark_cmd, /* alignment delimiter ( \.\&, \.{\\span} ) */ - car_ret_cmd, /* end of line ( |carriage_return|, \.{\\cr}, \.{\\crcr} ) */ -#define out_param_cmd car_ret_cmd /* output a macro parameter */ - mac_param_cmd, /* macro parameter symbol ( \.\# ) */ - sup_mark_cmd, /* superscript ( \.{\char'136} ) */ - sub_mark_cmd, /* subscript ( \.{\char'137} ) */ - endv_cmd, /* end of \ list in alignment template */ -#define ignore_cmd endv_cmd /* characters to ignore ( \.{\^\^@@} ) */ - spacer_cmd, /* characters equivalent to blank space ( \.{\ } ) */ - letter_cmd, /* characters regarded as letters ( \.{A..Z}, \.{a..z} ) */ - other_char_cmd, /* none of the special character types */ - par_end_cmd, /* end of paragraph ( \.{\\par} ) */ -#define active_char_cmd par_end_cmd /* characters that invoke macros ( \.{\char`\~} ) */ -#define match_cmd par_end_cmd /* match a macro parameter */ - stop_cmd, /* end of job ( \.{\\end}, \.{\\dump} ) */ -#define comment_cmd stop_cmd /* characters that introduce comments ( \.\% ) */ -#define end_match_cmd stop_cmd /* end of parameters to macro */ - delim_num_cmd, /* specify delimiter numerically ( \.{\\delimiter} ) */ -#define invalid_char_cmd delim_num_cmd /* characters that shouldn't appear ( \.{\^\^?} ) */ -#define max_char_code_cmd delim_num_cmd /* largest catcode for individual characters */ - char_num_cmd, /* character specified numerically ( \.{\\char} ) */ - math_char_num_cmd, /* explicit math code ( \.{\\mathchar} ) */ - mark_cmd, /* mark definition ( \.{\\mark} ) */ - xray_cmd, /* peek inside of \TeX\ ( \.{\\show}, \.{\\showbox}, etc.~) */ - make_box_cmd, /* make a box ( \.{\\box}, \.{\\copy}, \.{\\hbox}, etc.~) */ - hmove_cmd, /* horizontal motion ( \.{\\moveleft}, \.{\\moveright} ) */ - vmove_cmd, /* vertical motion ( \.{\\raise}, \.{\\lower} ) */ - un_hbox_cmd, /* unglue a box ( \.{\\unhbox}, \.{\\unhcopy} ) */ - un_vbox_cmd, /* unglue a box ( \.{\\unvbox}, \.{\\unvcopy} or - \.{\\pagediscards}, \.{\\splitdiscards} ) */ - remove_item_cmd, /* nullify last item ( \.{\\unpenalty}, \.{\\unkern}, \.{\\unskip} ) */ - hskip_cmd, /* horizontal glue ( \.{\\hskip}, \.{\\hfil}, etc.~) */ - vskip_cmd, /* vertical glue ( \.{\\vskip}, \.{\\vfil}, etc.~) */ - mskip_cmd, /* math glue ( \.{\\mskip} ) */ - kern_cmd, /* fixed space ( \.{\\kern}) */ - mkern_cmd, /* math kern ( \.{\\mkern} ) */ - leader_ship_cmd, /* use a box ( \.{\\shipout}, \.{\\leaders}, etc.~) */ - halign_cmd, /* horizontal table alignment ( \.{\\halign} ) */ - valign_cmd, /* vertical table alignment ( \.{\\valign} ) */ - no_align_cmd, /* temporary escape from alignment ( \.{\\noalign} ) */ - vrule_cmd, /* vertical rule ( \.{\\vrule} ) */ - hrule_cmd, /* horizontal rule ( \.{\\hrule} ) */ - insert_cmd, /* vlist inserted in box ( \.{\\insert} ) */ - vadjust_cmd, /* vlist inserted in enclosing paragraph ( \.{\\vadjust} ) */ - ignore_spaces_cmd, /* gobble |spacer| tokens ( \.{\\ignorespaces} ) */ - after_assignment_cmd, /* save till assignment is done ( \.{\\afterassignment} ) */ - after_group_cmd, /* save till group is done ( \.{\\aftergroup} ) */ - break_penalty_cmd, /* additional badness ( \.{\\penalty} ) */ - start_par_cmd, /* begin paragraph ( \.{\\indent}, \.{\\noindent} ) */ - ital_corr_cmd, /* italic correction ( \.{\\/} ) */ - accent_cmd, /* attach accent in text ( \.{\\accent} ) */ - math_accent_cmd, /* attach accent in math ( \.{\\mathaccent} ) */ - discretionary_cmd, /* discretionary texts ( \.{\\-}, \.{\\discretionary} ) */ - eq_no_cmd, /* equation number ( \.{\\eqno}, \.{\\leqno} ) */ - left_right_cmd, /* variable delimiter ( \.{\\left}, \.{\\right} or \.{\\middle} ) */ - math_comp_cmd, /* component of formula ( \.{\\mathbin}, etc.~) */ - limit_switch_cmd, /* diddle limit conventions ( \.{\\displaylimits}, etc.~) */ - above_cmd, /* generalized fraction ( \.{\\above}, \.{\\atop}, etc.~) */ - math_style_cmd, /* style specification ( \.{\\displaystyle}, etc.~) */ - math_choice_cmd, /* choice specification ( \.{\\mathchoice} ) */ - non_script_cmd, /* conditional math glue ( \.{\\nonscript} ) */ - vcenter_cmd, /* vertically center a vbox ( \.{\\vcenter} ) */ - case_shift_cmd, /* force specific case ( \.{\\lowercase}, \.{\\uppercase}~) */ - message_cmd, /* send to user ( \.{\\message}, \.{\\errmessage} ) */ - extension_cmd, /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */ - in_stream_cmd, /* files for reading ( \.{\\openin}, \.{\\closein} ) */ - begin_group_cmd, /* begin local grouping ( \.{\\begingroup} ) */ - end_group_cmd, /* end local grouping ( \.{\\endgroup} ) */ - omit_cmd, /* omit alignment template ( \.{\\omit} ) */ - ex_space_cmd, /* explicit space ( \.{\\\ } ) */ - no_boundary_cmd, /* suppress boundary ligatures ( \.{\\noboundary} ) */ - radical_cmd, /* square root and similar signs ( \.{\\radical} ) */ - super_sub_script_cmd, /* explicit super- or subscript */ - math_shift_cs_cmd, /* start- and endmath */ - end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */ - char_ghost_cmd, /* \.{\\ghostleft}, \.{\\ghostright} character for kerning */ - assign_local_box_cmd, /* box for guillemets \.{\\localleftbox} or \.{\\localrightbox} */ - char_given_cmd, /* character code defined by \.{\\chardef} */ -#define min_internal_cmd char_given_cmd /* the smallest code that can follow \.{\\the} */ - math_given_cmd, /* math code defined by \.{\\mathchardef} */ - omath_given_cmd, /* math code defined by \.{\\omathchardef} */ - xmath_given_cmd, /* math code defined by \.{\\LuaTeXmathchardef} */ - last_item_cmd, /* most recent item ( \.{\\lastpenalty}, \.{\\lastkern}, \.{\\lastskip} ) */ -#define max_non_prefixed_command_cmd last_item_cmd /* largest command code that can't be \.{\\global} */ - toks_register_cmd, /* token list register ( \.{\\toks} ) */ - assign_toks_cmd, /* special token list ( \.{\\output}, \.{\\everypar}, etc.~) */ - assign_int_cmd, /* user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~) */ - assign_attr_cmd, /* user-defined attributes */ - assign_dimen_cmd, /* user-defined length ( \.{\\hsize}, etc.~) */ - assign_glue_cmd, /* user-defined glue ( \.{\\baselineskip}, etc.~) */ - assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */ - assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */ - assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */ - set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */ - set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */ - set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */ - set_page_int_cmd, /* specify state info ( \.{\\deadcycles}, \.{\\insertpenalties} ) */ - set_box_dimen_cmd, /* change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} ) */ - set_tex_shape_cmd, /* specify fancy paragraph shape ( \.{\\parshape} ) */ - set_etex_shape_cmd, /* specify etex extended list ( \.{\\interlinepenalties}, etc.~) */ - def_char_code_cmd, /* define a character code ( \.{\\catcode}, etc.~) */ - def_del_code_cmd, /* define a delimiter code ( \.{\\delcode}) */ - extdef_math_code_cmd, /* define an extended character code ( \.{\\omathcode}, etc.~) */ - extdef_del_code_cmd, /* define an extended delimiter code ( \.{\\odelcode}, etc.~) */ - def_family_cmd, /* declare math fonts ( \.{\\textfont}, etc.~) */ - set_math_param_cmd, /* set math parameters ( \.{\\mathquad}, etc.~) */ - set_font_cmd, /* set current font ( font identifiers ) */ - def_font_cmd, /* define a font file ( \.{\\font} ) */ - register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */ - assign_box_dir_cmd, /* (\.{\\boxdir}) */ - assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */ -#define max_internal_cmd assign_dir_cmd /* the largest code that can follow \.{\\the} */ - advance_cmd, /* advance a register or parameter ( \.{\\advance} ) */ - multiply_cmd, /* multiply a register or parameter ( \.{\\multiply} ) */ - divide_cmd, /* divide a register or parameter ( \.{\\divide} ) */ - prefix_cmd, /* qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} ) */ - let_cmd, /* assign a command code ( \.{\\let}, \.{\\futurelet} ) */ - shorthand_def_cmd, /* code definition ( \.{\\chardef}, \.{\\countdef}, etc.~) */ - read_to_cs_cmd, /* read into a control sequence ( \.{\\read} ) */ - def_cmd, /* macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} ) */ - set_box_cmd, /* set a box ( \.{\\setbox} ) */ - hyph_data_cmd, /* hyphenation data ( \.{\\hyphenation}, \.{\\patterns} ) */ - set_interaction_cmd, /* define level of interaction ( \.{\\batchmode}, etc.~) */ - letterspace_font_cmd, /* letterspace a font ( \.{\\letterspacefont} ) */ - pdf_copy_font_cmd, /* create a new font instance ( \.{\\pdfcopyfont} ) */ - set_ocp_cmd, /* Place a translation process in the stream */ - def_ocp_cmd, /* Define and load a translation process */ - set_ocp_list_cmd, /* Place a list of OCPs in the stream */ - def_ocp_list_cmd, /* Define a list of OCPs */ - clear_ocp_lists_cmd, /* Remove all active OCP lists */ - push_ocp_list_cmd, /* Add to the sequence of active OCP lists */ - pop_ocp_list_cmd, /* Remove from the sequence of active OCP lists */ - ocp_list_op_cmd, /* Operations for building a list of OCPs */ - ocp_trace_level_cmd, /* Tracing of active OCPs, either 0 or 1 */ -#define max_command_cmd ocp_trace_level_cmd /* the largest command code seen at |big_switch| */ - undefined_cs_cmd, /* initial state of most |eq_type| fields */ - expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */ - no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */ - input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or - \.{\\scantokens} or \.{\\scantextokens} ) */ - if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */ - fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */ - cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */ - convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */ - the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */ - top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */ - call_cmd, /* non-long, non-outer control sequence */ - long_call_cmd, /* long, non-outer control sequence */ - outer_call_cmd, /* non-long, outer control sequence */ - long_outer_call_cmd, /* long, outer control sequence */ - end_template_cmd, /* end of an alignment template */ - dont_expand_cmd, /* the following token was marked by \.{\\noexpand} */ - glue_ref_cmd, /* the equivalent points to a glue specification */ - shape_ref_cmd, /* the equivalent points to a parshape specification */ - box_ref_cmd, /* the equivalent points to a box node, or is |null| */ - data_cmd, /* the equivalent is simply a halfword number */ -#define last_cmd data_cmd -} tex_command_code; - - -typedef enum { - int_val_level = 0, /* integer values */ - attr_val_level, /* integer values */ - dimen_val_level, /* dimension values */ - glue_val_level, /* glue specifications */ - mu_val_level, /* math glue specifications */ - dir_val_level, /* directions */ - ident_val_level, /* font identifier */ - tok_val_level, /* token lists */ -} value_level_code; - -typedef enum { - above_code = 0, - over_code = 1, - atop_code = 2, - delimited_code = 3 -} fraction_codes; - - -typedef enum { - convert_number_code = 0, /* command code for \.{\\number} */ - convert_roman_numeral_code, /* command code for \.{\\romannumeral} */ - convert_string_code, /* command code for \.{\\string} */ - convert_meaning_code, /* command code for \.{\\meaning} */ - convert_font_name_code, /* command code for \.{\\fontname} */ - convert_etex_code, /* command code for \.{\\eTeXVersion} */ - convert_omega_code, /* command code for \.{\\OmegaVersion} */ - convert_aleph_code, /* command code for \.{\\AlephVersion} */ - convert_format_name_code, /* command code for \.{\\AlephVersion} */ - convert_pdftex_revision_code, /* command code for \.{\\pdftexrevision} */ -#define convert_pdftex_first_expand_code convert_pdftex_revision_code /* base for \pdfTeX's command codes */ - convert_pdftex_banner_code, /* command code for \.{\\pdftexbanner} */ - convert_pdf_font_name_code, /* command code for \.{\\pdffontname} */ - convert_pdf_font_objnum_code, /* command code for \.{\\pdffontobjnum} */ - convert_pdf_font_size_code, /* command code for \.{\\pdffontsize} */ - convert_pdf_page_ref_code, /* command code for \.{\\pdfpageref} */ - convert_pdf_xform_name_code, /* command code for \.{\\pdfxformname} */ - convert_left_margin_kern_code, /* command code for \.{\\leftmarginkern} */ - convert_right_margin_kern_code, /* command code for \.{\\rightmarginkern} */ - convert_pdf_creation_date_code, /* command code for \.{\\pdfcreationdate} */ - convert_uniform_deviate_code, /* command code for \.{\\uniformdeviate} */ - convert_normal_deviate_code, /* command code for \.{\\normaldeviate} */ - convert_pdf_insert_ht_code, /* command code for \.{\\pdfinsertht} */ - convert_pdf_ximage_bbox_code, /* command code for \.{\\pdfximagebbox} */ - convert_lua_code, /* command code for \.{\\directlua} */ - convert_lua_escape_string_code, /* command code for \.{\\luaescapestring} */ - convert_pdf_colorstack_init_code, /* command code for \.{\\pdfcolorstackinit} */ - convert_luatex_revision_code, /* command code for \.{\\luatexrevision} */ - convert_luatex_date_code, /* command code for \.{\\luatexdate} */ - convert_math_style_code, /* command code for \.{\\mathstyle} */ - convert_expanded_code, /* command code for \.{\\expanded} */ - convert_job_name_code, /* command code for \.{\\jobname} */ -#define convert_pdftex_convert_codes convert_job_name_code /* end of \pdfTeX's command codes */ - convert_Aleph_revision_code, /* command code for \.{\\Alephrevision} */ - convert_Omega_revision_code, /* command code for \.{\\Omegarevision} */ - convert_eTeX_revision_code, /* command code for \.{\\eTeXrevision} */ - convert_font_identifier_code, /* command code for \.{tex.fontidentifier} (virtual) */ -} convert_codes; - -typedef enum { - last_item_lastpenalty_code = 0, /* code for \.{\\lastpenalty} */ - last_item_lastattr_code, /* not used */ - last_item_lastkern_code, /* code for \.{\\lastkern} */ - last_item_lastskip_code, /* code for \.{\\lastskip} */ - last_item_last_node_type_code, /* code for \.{\\lastnodetype} */ - last_item_input_line_no_code, /* code for \.{\\inputlineno} */ - last_item_badness_code, /* code for \.{\\badness} */ - last_item_pdftex_version_code, /* code for \.{\\pdftexversion} */ -#define last_item_pdftex_first_rint_code last_item_pdftex_version_code /* base for \pdfTeX's command codes */ - last_item_pdf_last_obj_code, /* code for \.{\\pdflastobj} */ - last_item_pdf_last_xform_code, /* code for \.{\\pdflastxform} */ - last_item_pdf_last_ximage_code, /* code for \.{\\pdflastximage} */ - last_item_pdf_last_ximage_pages_code, /* code for \.{\\pdflastximagepages} */ - last_item_pdf_last_annot_code, /* code for \.{\\pdflastannot} */ - last_item_pdf_last_x_pos_code, /* code for \.{\\pdflastxpos} */ - last_item_pdf_last_y_pos_code, /* code for \.{\\pdflastypos} */ - last_item_pdf_retval_code, /* global multi-purpose return value */ - last_item_pdf_last_ximage_colordepth_code, /* code for \.{\\pdflastximagecolordepth} */ - last_item_random_seed_code, /* code for \.{\\pdfrandomseed} */ - last_item_pdf_last_link_code, /* code for \.{\\pdflastlink} */ - last_item_luatex_version_code, /* code for \.{\\luatexversion} */ -#define last_item_pdftex_last_item_codes last_item_luatex_version_code /* end of \pdfTeX's command codes */ - last_item_Aleph_version_code, /* code for \.{\\Alephversion} */ -#define last_item_Aleph_int last_item_Aleph_version_code - last_item_Omega_version_code, /* code for \.{\\Omegaversion} */ - last_item_Aleph_minor_version_code, /* code for \.{\\Alephminorversion} */ - last_item_Omega_minor_version_code, /* code for \.{\\Omegaminorversion} */ - last_item_eTeX_minor_version_code, /* code for \.{\\eTeXminorversion} */ - last_item_eTeX_version_code, /* code for \.{\\eTeXversion} */ -#define last_item_eTeX_int last_item_eTeX_version_code /* first of \eTeX\ codes for integers */ - last_item_current_group_level_code, /* code for \.{\\currentgrouplevel} */ - last_item_current_group_type_code, /* code for \.{\\currentgrouptype} */ - last_item_current_if_level_code, /* code for \.{\\currentiflevel} */ - last_item_current_if_type_code, /* code for \.{\\currentiftype} */ - last_item_current_if_branch_code, /* code for \.{\\currentifbranch} */ - last_item_glue_stretch_order_code, /* code for \.{\\gluestretchorder} */ - last_item_glue_shrink_order_code, /* code for \.{\\glueshrinkorder} */ - last_item_font_char_wd_code, /* code for \.{\\fontcharwd} */ -#define last_item_eTeX_dim last_item_font_char_wd_code /* first of \eTeX\ codes for dimensions */ - last_item_font_char_ht_code, /* code for \.{\\fontcharht} */ - last_item_font_char_dp_code, /* code for \.{\\fontchardp} */ - last_item_font_char_ic_code, /* code for \.{\\fontcharic} */ - last_item_par_shape_length_code, /* code for \.{\\parshapelength} */ - last_item_par_shape_indent_code, /* code for \.{\\parshapeindent} */ - last_item_par_shape_dimen_code, /* code for \.{\\parshapedimen} */ - last_item_glue_stretch_code, /* code for \.{\\gluestretch} */ - last_item_glue_shrink_code, /* code for \.{\\glueshrink} */ - last_item_mu_to_glue_code, /* code for \.{\\mutoglue} */ -#define last_item_eTeX_glue last_item_mu_to_glue_code /* first of \eTeX\ codes for glue */ - last_item_glue_to_mu_code, /* code for \.{\\gluetomu} */ -#define last_item_eTeX_mu last_item_glue_to_mu_code /* first of \eTeX\ codes for muglue */ - last_item_numexpr_code, /* code for \.{\\numexpr} */ -#define last_item_eTeX_expr last_item_numexpr_code /* first of \eTeX\ codes for expressions */ - last_item_attrexpr_code, /* not used */ - last_item_dimexpr_code, /* code for \.{\\dimexpr} */ - last_item_glueexpr_code, /* code for \.{\\glueexpr} */ - last_item_muexpr_code, /* code for \.{\\muexpr} */ -} last_item_codes; - -typedef enum { - param_par_shape_code = 0, /* specifies paragraph shape */ - param_output_routine_code, /* points to token list for \.{\\output} */ - param_every_par_code, /* points to token list for \.{\\everypar} */ - param_every_math_code, /* points to token list for \.{\\everymath} */ - param_every_display_code, /* points to token list for \.{\\everydisplay} */ - param_every_hbox_code, /* points to token list for \.{\\everyhbox} */ - param_every_vbox_code, /* points to token list for \.{\\everyvbox} */ - param_every_job_code, /* points to token list for \.{\\everyjob} */ - param_every_cr_code, /* points to token list for \.{\\everycr} */ - param_err_help_code, /* points to token list for \.{\\errhelp} */ - param_pdf_pages_attr_code, /* points to token list for \.{\\pdfpagesattr} */ - param_pdf_page_attr_code, /* points to token list for \.{\\pdfpageattr} */ - param_pdf_page_resources_code, /* points to token list for \.{\\pdfpageresources} */ - param_pdf_pk_mode_code, /* points to token list for \.{\\pdfpkmode} */ - param_every_eof_code, /* points to token list for \.{\\everyeof} */ - param_ocp_trace_level_code, - param_ocp_active_number_code, - param_ocp_active_min_ptr_code, - param_ocp_active_max_ptr_code, - param_ocp_active_code -} param_local_pars; - - -typedef enum { - param_pretolerance_code = 0, /* badness tolerance before hyphenation */ - param_tolerance_code, /* badness tolerance after hyphenation */ - param_line_penalty_code, /* added to the badness of every line */ - param_hyphen_penalty_code, /* penalty for break after discretionary hyphen */ - param_ex_hyphen_penalty_code, /* penalty for break after explicit hyphen */ - param_club_penalty_code, /* penalty for creating a club line */ - param_widow_penalty_code, /* penalty for creating a widow line */ - param_display_widow_penalty_code, /* ditto, just before a display */ - param_broken_penalty_code, /* penalty for breaking a page at a broken line */ - param_bin_op_penalty_code, /* penalty for breaking after a binary operation */ - param_rel_penalty_code, /* penalty for breaking after a relation */ - param_pre_display_penalty_code, /* penalty for breaking just before a displayed formula */ - param_post_display_penalty_code, /* penalty for breaking just after a displayed formula */ - param_inter_line_penalty_code, /* additional penalty between lines */ - param_double_hyphen_demerits_code, /* demerits for double hyphen break */ - param_final_hyphen_demerits_code, /* demerits for final hyphen break */ - param_adj_demerits_code, /* demerits for adjacent incompatible lines */ - param_mag_code, /* magnification ratio */ - param_delimiter_factor_code, /* ratio for variable-size delimiters */ - param_looseness_code, /* change in number of lines for a paragraph */ - param_time_code, /* current time of day */ - param_day_code, /* current day of the month */ - param_month_code, /* current month of the year */ - param_year_code, /* current year of our Lord */ - param_show_box_breadth_code, /* nodes per level in |show_box| */ - param_show_box_depth_code, /* maximum level in |show_box| */ - param_hbadness_code, /* hboxes exceeding this badness will be shown by |hpack| */ - param_vbadness_code, /* vboxes exceeding this badness will be shown by |vpack| */ - param_pausing_code, /* pause after each line is read from a file */ - param_tracing_online_code, /* show diagnostic output on terminal */ - param_tracing_macros_code, /* show macros as they are being expanded */ - param_tracing_stats_code, /* show memory usage if \TeX\ knows it */ - param_tracing_paragraphs_code, /* show line-break calculations */ - param_tracing_pages_code, /* show page-break calculations */ - param_tracing_output_code, /* show boxes when they are shipped out */ - param_tracing_lost_chars_code, /* show characters that aren't in the font */ - param_tracing_commands_code, /* show command codes at |big_switch| */ - param_tracing_restores_code, /* show equivalents when they are restored */ - param_uc_hyph_code, /* hyphenate words beginning with a capital letter */ - param_output_penalty_code, /* penalty found at current page break */ - param_max_dead_cycles_code, /* bound on consecutive dead cycles of output */ - param_hang_after_code, /* hanging indentation changes after this many lines */ - param_floating_penalty_code, /* penalty for insertions heldover after a split */ - param_global_defs_code, /* override \.{\\global} specifications */ - param_cur_fam_code, /* current family */ - param_escape_char_code, /* escape character for token output */ - param_default_hyphen_char_code, /* value of \.{\\hyphenchar} when a font is loaded */ - param_default_skew_char_code, /* value of \.{\\skewchar} when a font is loaded */ - param_end_line_char_code, /* character placed at the right end of the buffer */ - param_new_line_char_code, /* character that prints as |print_ln| */ - param_language_code, /* current hyphenation table */ - param_left_hyphen_min_code, /* minimum left hyphenation fragment size */ - param_right_hyphen_min_code, /* minimum right hyphenation fragment size */ - param_holding_inserts_code, /* do not remove insertion nodes from \.{\\box255} */ - param_error_context_lines_code, /* maximum intermediate line pairs shown */ - param_local_inter_line_penalty_code, /* local \.{\\interlinepenalty} */ - param_local_broken_penalty_code, /* local \.{\\brokenpenalty} */ - param_no_local_whatsits_code, /* counts local whatsits */ - param_no_local_dirs_code, - param_level_local_dir_code, - param_luastartup_id_code, - param_disable_lig_code, - param_disable_kern_code, - param_cat_code_table_code, - param_output_box_code, - param_cur_lang_code, /* current language id */ - param_ex_hyphen_char_code, - param_page_direction_code, /* the five direction params do not exist in web */ - param_body_direction_code, - param_par_direction_code, - param_text_direction_code, - param_math_direction_code, - param_pdf_output_code, /* switch on PDF output if positive */ - param_pdf_compress_level_code, /* compress level of streams */ - param_pdf_decimal_digits_code, /* digits after the decimal point of numbers */ - param_pdf_move_chars_code, /* move chars 0..31 to higher area if possible */ - param_pdf_image_resolution_code, /* default image resolution */ - param_pdf_pk_resolution_code, /* default resolution of PK font */ - param_pdf_unique_resname_code, /* generate unique names for resouces */ - param_pdf_option_always_use_pdfpagebox_code, /* if the PDF inclusion should always use a specific PDF page box */ - param_pdf_option_pdf_inclusion_errorlevel_code, /* if the PDF inclusion should treat pdfs newer than |pdf_minor_version| as an error */ - param_pdf_minor_version_code, /* fractional part of the PDF version produced */ - param_pdf_force_pagebox_code, /* if the PDF inclusion should always use a specific PDF page box */ - param_pdf_pagebox_code, /* default pagebox to use for PDF inclusion */ - param_pdf_inclusion_errorlevel_code, /* if the PDF inclusion should treat pdfs newer than |pdf_minor_version| as an error */ - param_pdf_gamma_code, - param_pdf_image_gamma_code, - param_pdf_image_hicolor_code, - param_pdf_image_apply_gamma_code, - param_pdf_adjust_spacing_code, /* level of spacing adjusting */ - param_pdf_protrude_chars_code, /* protrude chars at left/right edge of paragraphs */ - param_pdf_tracing_fonts_code, /* level of font detail in log */ - param_pdf_objcompresslevel_code, /* activate object streams */ - param_unused_one_code, /* deleted param (pdftex integer 21) */ - param_unused_two_code, /* deleted param (pdftex integer 22) */ - param_unused_three_code, /* deleted param (pdftex integer 23) */ - param_pdf_gen_tounicode_code, /* generate ToUnicode for fonts? */ - param_pdf_draftmode_code, /* switch on draftmode if positive */ - param_pdf_replace_font_code, /* generate ToUnicode for fonts? */ - param_pdf_inclusion_copy_font_code, /* generate ToUnicode for fonts? */ - param_tracing_assigns_code, /* show assignments */ - param_tracing_groups_code, /* show save/restore groups */ - param_tracing_ifs_code, /* show conditionals */ - param_tracing_scan_tokens_code, /* show pseudo file open and close */ - param_tracing_nesting_code, /* show incomplete groups and ifs within files */ - param_pre_display_direction_code, /* text direction preceding a display */ - param_last_line_fit_code, /* adjustment for last line of paragraph */ - param_saving_vdiscards_code, /* save items discarded from vlists */ - param_saving_hyph_codes_code, /* save hyphenation codes for languages */ - param_suppress_fontnotfound_error_code, /* suppress errors for missing fonts */ - param_suppress_long_error_code, /* suppress errors for \\par in non-long contexts */ - param_suppress_ifcsname_error_code, /* suppress errors for \\ifcsname junk contexts */ - param_suppress_outer_error_code, /* suppress errors for \\outer contexts */ - param_synctex_code, /* is synctex file generation enabled ? */ -} int_param_codes; - -#define param_int_pars param_synctex_code+1 /* total number of integer parameters */ - -typedef enum { - param_par_indent_code = 0, /* indentation of paragraphs */ - param_math_surround_code, /* space around math in text */ - param_line_skip_limit_code, /* threshold for |line_skip| instead of |baseline_skip| */ - param_hsize_code, /* line width in horizontal mode */ - param_vsize_code, /* page height in vertical mode */ - param_max_depth_code, /* maximum depth of boxes on main pages */ - param_split_max_depth_code, /* maximum depth of boxes on split pages */ - param_box_max_depth_code, /* maximum depth of explicit vboxes */ - param_hfuzz_code, /* tolerance for overfull hbox messages */ - param_vfuzz_code, /* tolerance for overfull vbox messages */ - param_delimiter_shortfall_code, /* maximum amount uncovered by variable delimiters */ - param_null_delimiter_space_code, /* blank space in null delimiters */ - param_script_space_code, /* extra space after subscript or superscript */ - param_pre_display_size_code, /* length of text preceding a display */ - param_display_width_code, /* length of line for displayed equation */ - param_display_indent_code, /* indentation of line for displayed equation */ - param_overfull_rule_code, /* width of rule that identifies overfull hboxes */ - param_hang_indent_code, /* amount of hanging indentation */ - param_h_offset_code, /* amount of horizontal offset when shipping pages out */ - param_v_offset_code, /* amount of vertical offset when shipping pages out */ - param_emergency_stretch_code, /* reduces badnesses on final pass of line-breaking */ - param_page_left_offset_code, - param_page_top_offset_code, - param_page_right_offset_code, - param_page_bottom_offset_code, - param_pdf_h_origin_code, /* horigin of the PDF output */ -#define param_pdftex_first_dimen_code param_pdf_horigin_code /* first number defined in this section */ - param_pdf_v_origin_code, /* vorigin of the PDF output */ - param_page_width_code, /* page width of the PDF output */ - param_page_height_code, /* page height of the PDF output */ - param_pdf_link_margin_code, /* link margin in the PDF output */ - param_pdf_dest_margin_code, /* dest margin in the PDF output */ - param_pdf_thread_margin_code, /* thread margin in the PDF output */ - param_pdf_first_line_height_code, - param_pdf_last_line_depth_code, - param_pdf_each_line_height_code, - param_pdf_each_line_depth_code, - param_pdf_ignored_dimen_code, - param_pdf_px_dimen_code -} dimen_param_codes; - -#define param_pdftex_last_dimen_code param_pdftex_px_dimen_code /* last number defined in this section */ -#define param_dimen_pars param_pdftex_last_dimen_code+1 /* total number of dimension parameters */ - -typedef enum { - param_line_skip_code = 0, /* interline glue if |baseline_skip| is infeasible */ - param_baseline_skip_code, /* desired glue between baselines */ - param_par_skip_code, /* extra glue just above a paragraph */ - param_above_display_skip_code, /* extra glue just above displayed math */ - param_below_display_skip_code, /* extra glue just below displayed math */ - param_above_display_short_skip_code, /* glue above displayed math following short lines */ - param_below_display_short_skip_code, /* glue below displayed math following short lines */ - param_left_skip_code, /* glue at left of justified lines */ - param_right_skip_code, /* glue at right of justified lines */ - param_top_skip_code, /* glue at top of main pages */ - param_split_top_skip_code, /* glue at top of split pages */ - param_tab_skip_code, /* glue between aligned entries */ - param_space_skip_code, /* glue between words (if not |zero_glue|) */ - param_xspace_skip_code, /* glue after sentences (if not |zero_glue|) */ - param_par_fill_skip_code, /* glue on last line of paragraph */ - param_thin_mu_skip_code, /* thin space in math formula */ - param_med_mu_skip_code, /* medium space in math formula */ - param_thick_mu_skip_code, /* thick space in math formula */ -} param_skip_codes; - -#define glue_pars thick_mu_skip_code+1 /* total number of glue parameters */ - -#define eq_type(a) zeqtb[a].hh.u.B0 -#define equiv(a) zeqtb[a].hh.v.RH - -#define int_par(A) zeqtb[static_int_base+(A)].cint -#define dimen_par(A) zeqtb[static_dimen_base+(A)].cint -#define loc_par(A) equiv(static_local_base+(A)) -#define glue_par(A) equiv(static_glue_base+(A)) - - -typedef enum { - bottom_level = 0, /* group code for the outside world */ - simple_group, /* group code for local structure only */ - hbox_group, /* code for `\.{\\hbox}\grp' */ - adjusted_hbox_group, /* code for `\.{\\hbox}\grp' in vertical mode */ - vbox_group, /* code for `\.{\\vbox}\grp' */ - vtop_group, /* code for `\.{\\vtop}\grp' */ - align_group, /* code for `\.{\\halign}\grp', `\.{\\valign}\grp' */ - no_align_group, /* code for `\.{\\noalign}\grp' */ - output_group, /* code for output routine */ - math_group, /* code for, e.g., `\.{\char'136}\grp' */ - disc_group, /* code for `\.{\\discretionary}\grp\grp\grp' */ - insert_group, /* code for `\.{\\insert}\grp', `\.{\\vadjust}\grp' */ - vcenter_group, /* code for `\.{\\vcenter}\grp' */ - math_choice_group, /* code for `\.{\\mathchoice}\grp\grp\grp\grp' */ - semi_simple_group, /* code for `\.{\\begingroup...\\endgroup}' */ - math_shift_group, /* code for `\.{\$...\$}' */ - math_left_group, /* code for `\.{\\left...\\right}' */ - local_box_group, /* code for `\.{\\localleftbox...\\localrightbox}' */ - split_off_group, /* box code for the top part of a \.{\\vsplit} */ - split_keep_group, /* box code for the bottom part of a \.{\\vsplit} */ - preamble_group, /* box code for the preamble processing in an alignment */ - align_set_group, /* box code for the final item pass in an alignment */ - fin_row_group /* box code for a provisory line in an alignment */ -} tex_group_codes; - -#define max_group_code local_box_group diff --git a/Build/source/texk/web2c/luatexdir/dvi/dvigen.h b/Build/source/texk/web2c/luatexdir/dvi/dvigen.h new file mode 100644 index 00000000000..29989a3e10c --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/dvi/dvigen.h @@ -0,0 +1,193 @@ +/* dvigen.h + + Copyright 2009 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ + +/* $Id: dvigen.h 3404 2010-01-28 11:17:10Z taco $ */ + +#ifndef DVIGEN_H +# define DVIGEN_H + +extern int total_pages; +extern scaled max_v; +extern scaled max_h; +extern int max_push; +extern int last_bop; +extern int dead_cycles; +extern boolean doing_leaders; +extern int c, f; +extern int oval, ocmd; +extern halfword g; +extern int lq, lr; +extern int cur_s; + +typedef int dvi_index; /* an index into the output buffer */ + +extern int dvi_buf_size; +extern eight_bits *dvi_buf; /* 0 is unused */ +extern dvi_index half_buf; +extern dvi_index dvi_limit; +extern dvi_index dvi_ptr; +extern int dvi_offset; +extern int dvi_gone; + +/* +To put a byte in the buffer without paying the cost of invoking a procedure +each time, we use the macro |dvi_out|. +*/ + +# define dvi_out(A) do { \ + dvi_buf[dvi_ptr++]=(eight_bits)(A); \ + if (dvi_ptr==dvi_limit) dvi_swap(); \ + } while (0) + +extern void dvi_swap(void); +extern void dvi_four(int x); +extern void dvi_push(void); +extern void dvi_pop(int l); +extern void out_cmd(void); +extern void dvi_font_def(internal_font_number f); + +# define dvi_set(A,B) do { \ + oval=A; ocmd=set1; out_cmd(); dvi.h += (B); \ + } while (0) + +# define dvi_put(A) do { \ + oval=A; ocmd=put1; out_cmd(); \ + } while (0) + +# define location(A) varmem[(A)+1].cint + +extern halfword down_ptr, right_ptr; /* heads of the down and right stacks */ + +/* +The |vinfo| fields in the entries of the down stack or the right stack +have six possible settings: |y_here| or |z_here| mean that the \.{DVI} +command refers to |y| or |z|, respectively (or to |w| or |x|, in the +case of horizontal motion); |yz_OK| means that the \.{DVI} command is +\\{down} (or \\{right}) but can be changed to either |y| or |z| (or +to either |w| or |x|); |y_OK| means that it is \\{down} and can be changed +to |y| but not |z|; |z_OK| is similar; and |d_fixed| means it must stay +\\{down}. + +The four settings |yz_OK|, |y_OK|, |z_OK|, |d_fixed| would not need to +be distinguished from each other if we were simply solving the +digit-subscripting problem mentioned above. But in \TeX's case there is +a complication because of the nested structure of |push| and |pop| +commands. Suppose we add parentheses to the digit-subscripting problem, +redefining hits so that $\delta_y\ldots \delta_y$ is a hit if all $y$'s between +the $\delta$'s are enclosed in properly nested parentheses, and if the +parenthesis level of the right-hand $\delta_y$ is deeper than or equal to +that of the left-hand one. Thus, `(' and `)' correspond to `|push|' +and `|pop|'. Now if we want to assign a subscript to the final 1 in the +sequence +$$2_y\,7_d\,1_d\,(\,8_z\,2_y\,8_z\,)\,1$$ +we cannot change the previous $1_d$ to $1_y$, since that would invalidate +the $2_y\ldots2_y$ hit. But we can change it to $1_z$, scoring a hit +since the intervening $8_z$'s are enclosed in parentheses. +*/ + +typedef enum { + y_here = 1, /* |vinfo| when the movement entry points to a |y| command */ + z_here = 2, /* |vinfo| when the movement entry points to a |z| command */ + yz_OK = 3, /* |vinfo| corresponding to an unconstrained \\{down} command */ + y_OK = 4, /* |vinfo| corresponding to a \\{down} that can't become a |z| */ + z_OK = 5, /* |vinfo| corresponding to a \\{down} that can't become a |y| */ + d_fixed = 6, /* |vinfo| corresponding to a \\{down} that can't change */ +} movement_codes; + +/* As we search through the stack, we are in one of three states, + |y_seen|, |z_seen|, or |none_seen|, depending on whether we have + encountered |y_here| or |z_here| nodes. These states are encoded as + multiples of 6, so that they can be added to the |info| fields for quick + decision-making. */ + +# define none_seen 0 /* no |y_here| or |z_here| nodes have been encountered yet */ +# define y_seen 6 /* we have seen |y_here| but not |z_here| */ +# define z_seen 12 /* we have seen |z_here| but not |y_here| */ + +extern void movement(scaled w, eight_bits o); +extern void prune_movements(int l); + +/* +The actual distances by which we want to move might be computed as the +sum of several separate movements. For example, there might be several +glue nodes in succession, or we might want to move right by the width of +some box plus some amount of glue. More importantly, the baselineskip +distances are computed in terms of glue together with the depth and +height of adjacent boxes, and we want the \.{DVI} file to lump these +three quantities together into a single motion. + +Therefore, \TeX\ maintains two pairs of global variables: |dvi.h| and |dvi.v| +are the |h| and |v| coordinates corresponding to the commands actually +output to the \.{DVI} file, while |cur.h| and |cur.v| are the coordinates +corresponding to the current state of the output routines. Coordinate +changes will accumulate in |cur.h| and |cur.v| without being reflected +in the output, until such a change becomes necessary or desirable; we +can call the |movement| procedure whenever we want to make |dvi.h=pos.h| +or |dvi.v=pos.v|. + +The current font reflected in the \.{DVI} output is called |dvi_f|; +there is no need for a `\\{cur\_f}' variable. + +The depth of nesting of |hlist_out| and |vlist_out| is called |cur_s|; +this is essentially the depth of |push| commands in the \.{DVI} output. +*/ + +# define synch_h(p) do { \ + if (p.h != dvi.h) { \ + movement(p.h - dvi.h, right1); \ + dvi.h = p.h; \ + } \ + } while (0) + +# define synch_v(p) do { \ + if (p.v != dvi.v) { \ + movement(dvi.v - p.v, down1); \ + dvi.v = p.v; \ + } \ + } while (0) + +# define synch_dvi_with_pos(p) do {synch_h(p); synch_v(p); } while (0) + +# define billion 1000000000.0 + +# define vet_glue(A) do { glue_temp=A; \ + if (glue_temp>billion) \ + glue_temp=billion; \ + else if (glue_temp<-billion) \ + glue_temp=-billion; \ + } while (0) + +extern scaled_whd rule; +extern scaledpos dvi; +extern scaledpos cur_page_size; /* width and height of page being shipped */ + +extern void expand_macros_in_tokenlist(halfword p); +extern void write_out(halfword p); +extern void dvi_special(PDF pdf, halfword p); + +extern void ensure_dvi_header_written(PDF pdf); +extern void finish_dvi_file(PDF pdf, int version, int revision); + +extern void dvi_place_glyph(PDF pdf, internal_font_number f, int c); +extern void dvi_place_rule(PDF pdf, halfword q, scaledpos size); + +extern void dvi_begin_page(PDF pdf); +extern void dvi_end_page(PDF pdf); + +#endif diff --git a/Build/source/texk/web2c/luatexdir/dvi/dvigen.w b/Build/source/texk/web2c/luatexdir/dvi/dvigen.w new file mode 100644 index 00000000000..240d589fee1 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/dvi/dvigen.w @@ -0,0 +1,1420 @@ +%dvigen.w + +%Copyright 2009-2010 Taco Hoekwater + +%This file is part of LuaTeX. + +%LuaTeX is free software; you can redistribute it and/or modify it under +%the terms of the GNU General Public License as published by the Free +%Software Foundation; either version 2 of the License, or (at your +%option) any later version. + +%LuaTeX is distributed in the hope that it will be useful, but WITHOUT +%ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +%FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +%License for more details. + +%You should have received a copy of the GNU General Public License along +%with LuaTeX; if not, see . + +\def\MF{MetaFont} +\def\MP{MetaPost} +\def\PASCAL{Pascal} +\def\[#1]{#1} +\pdfoutput=1 +\pdfmapline{cmtex10 < cmtex10.pfb} +\pdfmapfile{pdftex.map} + +\title{: generation of DVI output} + +@ Initial identification of this file, and the needed headers. +@c +static const char _svn_version[] = + "$Id: dvigen.w 3535 2010-03-21 17:02:05Z oneiros $" + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/dvi/dvigen.w $"; + +#include "ptexlib.h" + +@ Here is the start of the actual C file. +@c +#undef write_dvi + +#define mode cur_list.mode_field /* current mode */ + +#define pdf_output int_par(pdf_output_code) +#define mag int_par(mag_code) +#define tracing_output int_par(tracing_output_code) +#define tracing_stats int_par(tracing_stats_code) +#define tracing_online int_par(tracing_online_code) +#define page_direction int_par(page_direction_code) +#define page_width dimen_par(page_width_code) +#define page_height dimen_par(page_height_code) +#define page_left_offset dimen_par(page_left_offset_code) +#define page_right_offset dimen_par(page_right_offset_code) +#define page_top_offset dimen_par(page_top_offset_code) +#define page_bottom_offset dimen_par(page_bottom_offset_code) +#define h_offset dimen_par(h_offset_code) +#define v_offset dimen_par(v_offset_code) + +#define count(A) eqtb[count_base+(A)].cint + +@ The most important output produced by a run of \TeX\ is the ``device +independent'' (\.{DVI}) file that specifies where characters and rules +are to appear on printed pages. The form of these files was designed by +David R. Fuchs in 1979. Almost any reasonable typesetting device can be +@^Fuchs, David Raymond@> +@:DVI_files}{\.{DVI} files@> +driven by a program that takes \.{DVI} files as input, and dozens of such +\.{DVI}-to-whatever programs have been written. Thus, it is possible to +print the output of \TeX\ on many different kinds of equipment, using \TeX\ +as a device-independent ``front end.'' + +A \.{DVI} file is a stream of 8-bit bytes, which may be regarded as a +series of commands in a machine-like language. The first byte of each command +is the operation code, and this code is followed by zero or more bytes +that provide parameters to the command. The parameters themselves may consist +of several consecutive bytes; for example, the `|set_rule|' command has two +parameters, each of which is four bytes long. Parameters are usually +regarded as nonnegative integers; but four-byte-long parameters, +and shorter parameters that denote distances, can be +either positive or negative. Such parameters are given in two's complement +notation. For example, a two-byte-long distance parameter has a value between +$-2^{15}$ and $2^{15}-1$. As in \.{TFM} files, numbers that occupy +more than one byte position appear in BigEndian order. + +A \.{DVI} file consists of a ``preamble,'' followed by a sequence of one +or more ``pages,'' followed by a ``postamble.'' The preamble is simply a +|pre| command, with its parameters that define the dimensions used in the +file; this must come first. Each ``page'' consists of a |bop| command, +followed by any number of other commands that tell where characters are to +be placed on a physical page, followed by an |eop| command. The pages +appear in the order that \TeX\ generated them. If we ignore |nop| commands +and \\{fnt\_def} commands (which are allowed between any two commands in +the file), each |eop| command is immediately followed by a |bop| command, +or by a |post| command; in the latter case, there are no more pages in the +file, and the remaining bytes form the postamble. Further details about +the postamble will be explained later. + +Some parameters in \.{DVI} commands are ``pointers.'' These are four-byte +quantities that give the location number of some other byte in the file; +the first byte is number~0, then comes number~1, and so on. For example, +one of the parameters of a |bop| command points to the previous |bop|; +this makes it feasible to read the pages in backwards order, in case the +results are being directed to a device that stacks its output face up. +Suppose the preamble of a \.{DVI} file occupies bytes 0 to 99. Now if the +first page occupies bytes 100 to 999, say, and if the second +page occupies bytes 1000 to 1999, then the |bop| that starts in byte 1000 +points to 100 and the |bop| that starts in byte 2000 points to 1000. (The +very first |bop|, i.e., the one starting in byte 100, has a pointer of~$-1$.) + +@ The \.{DVI} format is intended to be both compact and easily interpreted +by a machine. Compactness is achieved by making most of the information +implicit instead of explicit. When a \.{DVI}-reading program reads the +commands for a page, it keeps track of several quantities: (a)~The current +font |f| is an integer; this value is changed only +by \\{fnt} and \\{fnt\_num} commands. (b)~The current position on the page +is given by two numbers called the horizontal and vertical coordinates, +|h| and |v|. Both coordinates are zero at the upper left corner of the page; +moving to the right corresponds to increasing the horizontal coordinate, and +moving down corresponds to increasing the vertical coordinate. Thus, the +coordinates are essentially Cartesian, except that vertical directions are +flipped; the Cartesian version of |(h,v)| would be |(h,-v)|. (c)~The +current spacing amounts are given by four numbers |w|, |x|, |y|, and |z|, +where |w| and~|x| are used for horizontal spacing and where |y| and~|z| +are used for vertical spacing. (d)~There is a stack containing +|(h,v,w,x,y,z)| values; the \.{DVI} commands |push| and |pop| are used to +change the current level of operation. Note that the current font~|f| is +not pushed and popped; the stack contains only information about +positioning. + +The values of |h|, |v|, |w|, |x|, |y|, and |z| are signed integers having up +to 32 bits, including the sign. Since they represent physical distances, +there is a small unit of measurement such that increasing |h| by~1 means +moving a certain tiny distance to the right. The actual unit of +measurement is variable, as explained below; \TeX\ sets things up so that +its \.{DVI} output is in sp units, i.e., scaled points, in agreement with +all the |scaled| dimensions in \TeX's data structures. + +@ Here is a list of all the commands that may appear in a \.{DVI} file. Each +command is specified by its symbolic name (e.g., |bop|), its opcode byte +(e.g., 139), and its parameters (if any). The parameters are followed +by a bracketed number telling how many bytes they occupy; for example, +`|p[4]|' means that parameter |p| is four bytes long. + +\yskip\hang|set_char_0| 0. Typeset character number~0 from font~|f| +such that the reference point of the character is at |(h,v)|. Then +increase |h| by the width of that character. Note that a character may +have zero or negative width, so one cannot be sure that |h| will advance +after this command; but |h| usually does increase. + +\yskip\hang\\{set\_char\_1} through \\{set\_char\_127} (opcodes 1 to 127). +Do the operations of |set_char_0|; but use the character whose number +matches the opcode, instead of character~0. + +\yskip\hang|set1| 128 |c[1]|. Same as |set_char_0|, except that character +number~|c| is typeset. \TeX82 uses this command for characters in the +range |128<=c<256|. + +\yskip\hang|@!set2| 129 |c[2]|. Same as |set1|, except that |c|~is two +bytes long, so it is in the range |0<=c<65536|. \TeX82 never uses this +command, but it should come in handy for extensions of \TeX\ that deal +with oriental languages. +@^oriental characters@>@^Chinese characters@>@^Japanese characters@> + +\yskip\hang|@!set3| 130 |c[3]|. Same as |set1|, except that |c|~is three +bytes long, so it can be as large as $2^{24}-1$. Not even the Chinese +language has this many characters, but this command might prove useful +in some yet unforeseen extension. + +\yskip\hang|@!set4| 131 |c[4]|. Same as |set1|, except that |c|~is four +bytes long. Imagine that. + +\yskip\hang|set_rule| 132 |a[4]| |b[4]|. Typeset a solid black rectangle +of height~|a| and width~|b|, with its bottom left corner at |(h,v)|. Then +set |h:=h+b|. If either |a<=0| or |b<=0|, nothing should be typeset. Note +that if |b<0|, the value of |h| will decrease even though nothing else happens. +See below for details about how to typeset rules so that consistency with +\MF\ is guaranteed. + +\yskip\hang|@!put1| 133 |c[1]|. Typeset character number~|c| from font~|f| +such that the reference point of the character is at |(h,v)|. (The `put' +commands are exactly like the `set' commands, except that they simply put out a +character or a rule without moving the reference point afterwards.) + +\yskip\hang|@!put2| 134 |c[2]|. Same as |set2|, except that |h| is not changed. + +\yskip\hang|@!put3| 135 |c[3]|. Same as |set3|, except that |h| is not changed. + +\yskip\hang|@!put4| 136 |c[4]|. Same as |set4|, except that |h| is not changed. + +\yskip\hang|put_rule| 137 |a[4]| |b[4]|. Same as |set_rule|, except that +|h| is not changed. + +\yskip\hang|nop| 138. No operation, do nothing. Any number of |nop|'s +may occur between \.{DVI} commands, but a |nop| cannot be inserted between +a command and its parameters or between two parameters. + +\yskip\hang|bop| 139 $c_0[4]$ $c_1[4]$ $\ldots$ $c_9[4]$ $p[4]$. Beginning +of a page: Set |(h,v,w,x,y,z):=(0,0,0,0,0,0)| and set the stack empty. Set +the current font |f| to an undefined value. The ten $c_i$ parameters hold +the values of \.{\\count0} $\ldots$ \.{\\count9} in \TeX\ at the time +\.{\\shipout} was invoked for this page; they can be used to identify +pages, if a user wants to print only part of a \.{DVI} file. The parameter +|p| points to the previous |bop| in the file; the first +|bop| has $p=-1$. + +\yskip\hang|eop| 140. End of page: Print what you have read since the +previous |bop|. At this point the stack should be empty. (The \.{DVI}-reading +programs that drive most output devices will have kept a buffer of the +material that appears on the page that has just ended. This material is +largely, but not entirely, in order by |v| coordinate and (for fixed |v|) by +|h|~coordinate; so it usually needs to be sorted into some order that is +appropriate for the device in question.) + +\yskip\hang|push| 141. Push the current values of |(h,v,w,x,y,z)| onto the +top of the stack; do not change any of these values. Note that |f| is +not pushed. + +\yskip\hang|pop| 142. Pop the top six values off of the stack and assign +them respectively to |(h,v,w,x,y,z)|. The number of pops should never +exceed the number of pushes, since it would be highly embarrassing if the +stack were empty at the time of a |pop| command. + +\yskip\hang|right1| 143 |b[1]|. Set |h:=h+b|, i.e., move right |b| units. +The parameter is a signed number in two's complement notation, |-128<=b<128|; +if |b<0|, the reference point moves left. + +\yskip\hang|right2| 144 |b[2]|. Same as |right1|, except that |b| is a +two-byte quantity in the range |-32768<=b<32768|. + +\yskip\hang|right3| 145 |b[3]|. Same as |right1|, except that |b| is a +three-byte quantity in the range |@t$-2^{23}$@><=b<@t$2^{23}$@>|. + +\yskip\hang|right4| 146 |b[4]|. Same as |right1|, except that |b| is a +four-byte quantity in the range |@t$-2^{31}$@><=b<@t$2^{31}$@>|. + +\yskip\hang|w0| 147. Set |h:=h+w|; i.e., move right |w| units. With luck, +this parameterless command will usually suffice, because the same kind of motion +will occur several times in succession; the following commands explain how +|w| gets particular values. + +\yskip\hang|w1| 148 |b[1]|. Set |w:=b| and |h:=h+b|. The value of |b| is a +signed quantity in two's complement notation, |-128<=b<128|. This command +changes the current |w|~spacing and moves right by |b|. + +\yskip\hang|@!w2| 149 |b[2]|. Same as |w1|, but |b| is two bytes long, +|-32768<=b<32768|. + +\yskip\hang|@!w3| 150 |b[3]|. Same as |w1|, but |b| is three bytes long, +|@t$-2^{23}$@><=b<@t$2^{23}$@>|. + +\yskip\hang|@!w4| 151 |b[4]|. Same as |w1|, but |b| is four bytes long, +|@t$-2^{31}$@><=b<@t$2^{31}$@>|. + +\yskip\hang|x0| 152. Set |h:=h+x|; i.e., move right |x| units. The `|x|' +commands are like the `|w|' commands except that they involve |x| instead +of |w|. + +\yskip\hang|x1| 153 |b[1]|. Set |x:=b| and |h:=h+b|. The value of |b| is a +signed quantity in two's complement notation, |-128<=b<128|. This command +changes the current |x|~spacing and moves right by |b|. + +\yskip\hang|@!x2| 154 |b[2]|. Same as |x1|, but |b| is two bytes long, +|-32768<=b<32768|. + +\yskip\hang|@!x3| 155 |b[3]|. Same as |x1|, but |b| is three bytes long, +|@t$-2^{23}$@><=b<@t$2^{23}$@>|. + +\yskip\hang|@!x4| 156 |b[4]|. Same as |x1|, but |b| is four bytes long, +|@t$-2^{31}$@><=b<@t$2^{31}$@>|. + +\yskip\hang|down1| 157 |a[1]|. Set |v:=v+a|, i.e., move down |a| units. +The parameter is a signed number in two's complement notation, |-128<=a<128|; +if |a<0|, the reference point moves up. + +\yskip\hang|@!down2| 158 |a[2]|. Same as |down1|, except that |a| is a +two-byte quantity in the range |-32768<=a<32768|. + +\yskip\hang|@!down3| 159 |a[3]|. Same as |down1|, except that |a| is a +three-byte quantity in the range |@t$-2^{23}$@><=a<@t$2^{23}$@>|. + +\yskip\hang|@!down4| 160 |a[4]|. Same as |down1|, except that |a| is a +four-byte quantity in the range |@t$-2^{31}$@><=a<@t$2^{31}$@>|. + +\yskip\hang|y0| 161. Set |v:=v+y|; i.e., move down |y| units. With luck, +this parameterless command will usually suffice, because the same kind of motion +will occur several times in succession; the following commands explain how +|y| gets particular values. + +\yskip\hang|y1| 162 |a[1]|. Set |y:=a| and |v:=v+a|. The value of |a| is a +signed quantity in two's complement notation, |-128<=a<128|. This command +changes the current |y|~spacing and moves down by |a|. + +\yskip\hang|@!y2| 163 |a[2]|. Same as |y1|, but |a| is two bytes long, +|-32768<=a<32768|. + +\yskip\hang|@!y3| 164 |a[3]|. Same as |y1|, but |a| is three bytes long, +|@t$-2^{23}$@><=a<@t$2^{23}$@>|. + +\yskip\hang|@!y4| 165 |a[4]|. Same as |y1|, but |a| is four bytes long, +|@t$-2^{31}$@><=a<@t$2^{31}$@>|. + +\yskip\hang|z0| 166. Set |v:=v+z|; i.e., move down |z| units. The `|z|' commands +are like the `|y|' commands except that they involve |z| instead of |y|. + +\yskip\hang|z1| 167 |a[1]|. Set |z:=a| and |v:=v+a|. The value of |a| is a +signed quantity in two's complement notation, |-128<=a<128|. This command +changes the current |z|~spacing and moves down by |a|. + +\yskip\hang|@!z2| 168 |a[2]|. Same as |z1|, but |a| is two bytes long, +|-32768<=a<32768|. + +\yskip\hang|@!z3| 169 |a[3]|. Same as |z1|, but |a| is three bytes long, +|@t$-2^{23}$@><=a<@t$2^{23}$@>|. + +\yskip\hang|@!z4| 170 |a[4]|. Same as |z1|, but |a| is four bytes long, +|@t$-2^{31}$@><=a<@t$2^{31}$@>|. + +\yskip\hang|fnt_num_0| 171. Set |f:=0|. Font 0 must previously have been +defined by a \\{fnt\_def} instruction, as explained below. + +\yskip\hang\\{fnt\_num\_1} through \\{fnt\_num\_63} (opcodes 172 to 234). Set +|f:=1|, \dots, \hbox{|f:=63|}, respectively. + +\yskip\hang|fnt1| 235 |k[1]|. Set |f:=k|. \TeX82 uses this command for font +numbers in the range |64<=k<256|. + +\yskip\hang|@!fnt2| 236 |k[2]|. Same as |fnt1|, except that |k|~is two +bytes long, so it is in the range |0<=k<65536|. \TeX82 never generates this +command, but large font numbers may prove useful for specifications of +color or texture, or they may be used for special fonts that have fixed +numbers in some external coding scheme. + +\yskip\hang|@!fnt3| 237 |k[3]|. Same as |fnt1|, except that |k|~is three +bytes long, so it can be as large as $2^{24}-1$. + +\yskip\hang|@!fnt4| 238 |k[4]|. Same as |fnt1|, except that |k|~is four +bytes long; this is for the really big font numbers (and for the negative ones). + +\yskip\hang|xxx1| 239 |k[1]| |x[k]|. This command is undefined in +general; it functions as a $(k+2)$-byte |nop| unless special \.{DVI}-reading +programs are being used. \TeX82 generates |xxx1| when a short enough +\.{\\special} appears, setting |k| to the number of bytes being sent. It +is recommended that |x| be a string having the form of a keyword followed +by possible parameters relevant to that keyword. + +\yskip\hang|@!xxx2| 240 |k[2]| |x[k]|. Like |xxx1|, but |0<=k<65536|. + +\yskip\hang|@!xxx3| 241 |k[3]| |x[k]|. Like |xxx1|, but |0<=k<@t$2^{24}$@>|. + +\yskip\hang|xxx4| 242 |k[4]| |x[k]|. Like |xxx1|, but |k| can be ridiculously +large. \TeX82 uses |xxx4| when sending a string of length 256 or more. + +\yskip\hang|fnt_def1| 243 |k[1]| |c[4]| |s[4]| |d[4]| |a[1]| |l[1]| |n[a+l]|. +Define font |k|, where |0<=k<256|; font definitions will be explained shortly. + +\yskip\hang|@!fnt_def2| 244 |k[2]| |c[4]| |s[4]| |d[4]| |a[1]| |l[1]| |n[a+l]|. +Define font |k|, where |0<=k<65536|. + +\yskip\hang|@!fnt_def3| 245 |k[3]| |c[4]| |s[4]| |d[4]| |a[1]| |l[1]| |n[a+l]|. +Define font |k|, where |0<=k<@t$2^{24}$@>|. + +\yskip\hang|@!fnt_def4| 246 |k[4]| |c[4]| |s[4]| |d[4]| |a[1]| |l[1]| |n[a+l]|. +Define font |k|, where |@t$-2^{31}$@><=k<@t$2^{31}$@>|. + +\yskip\hang|pre| 247 |i[1]| |num[4]| |den[4]| |mag[4]| |k[1]| |x[k]|. +Beginning of the preamble; this must come at the very beginning of the +file. Parameters |i|, |num|, |den|, |mag|, |k|, and |x| are explained below. + +\yskip\hang|post| 248. Beginning of the postamble, see below. + +\yskip\hang|post_post| 249. Ending of the postamble, see below. + +\yskip\noindent Commands 250--255 are undefined at the present time. + +@c +#define set_char_0 0 /* typeset character 0 and move right */ +#define set1 128 /* typeset a character and move right */ +#define set_rule 132 /* typeset a rule and move right */ +#define put1 133 /* typeset a character without moving */ +#define put_rule 137 /* typeset a rule */ +#define nop 138 /* no operation */ +#define bop 139 /* beginning of page */ +#define eop 140 /* ending of page */ +#define push 141 /* save the current positions */ +#define pop 142 /* restore previous positions */ +#define right1 143 /* move right */ +#define right4 146 /* move right, 4 bytes */ +#define w0 147 /* move right by |w| */ +#define w1 148 /* move right and set |w| */ +#define x0 152 /* move right by |x| */ +#define x1 153 /* move right and set |x| */ +#define down1 157 /* move down */ +#define down4 160 /* move down, 4 bytes */ +#define y0 161 /* move down by |y| */ +#define y1 162 /* move down and set |y| */ +#define z0 166 /* move down by |z| */ +#define z1 167 /* move down and set |z| */ +#define fnt_num_0 171 /* set current font to 0 */ +#define fnt1 235 /* set current font */ +#define xxx1 239 /* extension to \.{DVI} primitives */ +#define xxx4 242 /* potentially long extension to \.{DVI} primitives */ +#define fnt_def1 243 /* define the meaning of a font number */ +#define pre 247 /* preamble */ +#define post 248 /* postamble beginning */ +#define post_post 249 /* postamble ending */ + +@ The preamble contains basic information about the file as a whole. As +stated above, there are six parameters: +$$\hbox{|@!i[1]| |@!num[4]| |@!den[4]| |@!mag[4]| |@!k[1]| |@!x[k]|.}$$ +The |i| byte identifies \.{DVI} format; currently this byte is always set +to~2. (The value |i=3| is currently used for an extended format that +allows a mixture of right-to-left and left-to-right typesetting. +Some day we will set |i=4|, when \.{DVI} format makes another +incompatible change---perhaps in the year 2048.) + +The next two parameters, |num| and |den|, are positive integers that define +the units of measurement; they are the numerator and denominator of a +fraction by which all dimensions in the \.{DVI} file could be multiplied +in order to get lengths in units of $10^{-7}$ meters. Since $\rm 7227{pt} = +254{cm}$, and since \TeX\ works with scaled points where there are $2^{16}$ +sp in a point, \TeX\ sets +$|num|/|den|=(254\cdot10^5)/(7227\cdot2^{16})=25400000/473628672$. +@^sp@> + +The |mag| parameter is what \TeX\ calls \.{\\mag}, i.e., 1000 times the +desired magnification. The actual fraction by which dimensions are +multiplied is therefore $|mag|\cdot|num|/1000|den|$. Note that if a \TeX\ +source document does not call for any `\.{true}' dimensions, and if you +change it only by specifying a different \.{\\mag} setting, the \.{DVI} +file that \TeX\ creates will be completely unchanged except for the value +of |mag| in the preamble and postamble. (Fancy \.{DVI}-reading programs allow +users to override the |mag|~setting when a \.{DVI} file is being printed.) + +Finally, |k| and |x| allow the \.{DVI} writer to include a comment, which is not +interpreted further. The length of comment |x| is |k|, where |0<=k<256|. + + +@c +#define id_byte 2 /* identifies the kind of \.{DVI} files described here */ + +@ Font definitions for a given font number |k| contain further parameters +$$\hbox{|c[4]| |s[4]| |d[4]| |a[1]| |l[1]| |n[a+l]|.}$$ +The four-byte value |c| is the check sum that \TeX\ found in the \.{TFM} +file for this font; |c| should match the check sum of the font found by +programs that read this \.{DVI} file. +@^check sum@> + +Parameter |s| contains a fixed-point scale factor that is applied to +the character widths in font |k|; font dimensions in \.{TFM} files and +other font files are relative to this quantity, which is called the +``at size'' elsewhere in this documentation. The value of |s| is +always positive and less than $2^{27}$. It is given in the same units +as the other \.{DVI} dimensions, i.e., in sp when \TeX82 has made the +file. Parameter |d| is similar to |s|; it is the ``design size,'' and +(like~|s|) it is given in \.{DVI} units. Thus, font |k| is to be used +at $|mag|\cdot s/1000d$ times its normal size. + +The remaining part of a font definition gives the external name of the font, +which is an ASCII string of length |a+l|. The number |a| is the length +of the ``area'' or directory, and |l| is the length of the font name itself; +the standard local system font area is supposed to be used when |a=0|. +The |n| field contains the area in its first |a| bytes. + +Font definitions must appear before the first use of a particular font number. +Once font |k| is defined, it must not be defined again; however, we +shall see below that font definitions appear in the postamble as well as +in the pages, so in this sense each font number is defined exactly twice, +if at all. Like |nop| commands, font definitions can +appear before the first |bop|, or between an |eop| and a |bop|. + +@ Sometimes it is desirable to make horizontal or vertical rules line up +precisely with certain features in characters of a font. It is possible to +guarantee the correct matching between \.{DVI} output and the characters +generated by \MF\ by adhering to the following principles: (1)~The \MF\ +characters should be positioned so that a bottom edge or left edge that is +supposed to line up with the bottom or left edge of a rule appears at the +reference point, i.e., in row~0 and column~0 of the \MF\ raster. This +ensures that the position of the rule will not be rounded differently when +the pixel size is not a perfect multiple of the units of measurement in +the \.{DVI} file. (2)~A typeset rule of height $a>0$ and width $b>0$ +should be equivalent to a \MF-generated character having black pixels in +precisely those raster positions whose \MF\ coordinates satisfy +|0<=x<@t$\alpha$@>b| and |0<=y<@t$\alpha$@>a|, where $\alpha$ is the number +of pixels per \.{DVI} unit. +@:METAFONT}{\MF@> +@^alignment of rules with characters@> +@^rules aligning with characters@> + +@ The last page in a \.{DVI} file is followed by `|post|'; this command +introduces the postamble, which summarizes important facts that \TeX\ has +accumulated about the file, making it possible to print subsets of the data +with reasonable efficiency. The postamble has the form +$$\vbox{\halign{\hbox{#\hfil}\cr + |post| |p[4]| |num[4]| |den[4]| |mag[4]| |l[4]| |u[4]| |s[2]| |t[2]|\cr + $\langle\,$font definitions$\,\rangle$\cr + |post_post| |q[4]| |i[1]| 223's$[{\G}4]$\cr}}$$ +Here |p| is a pointer to the final |bop| in the file. The next three +parameters, |num|, |den|, and |mag|, are duplicates of the quantities that +appeared in the preamble. + +Parameters |l| and |u| give respectively the height-plus-depth of the tallest +page and the width of the widest page, in the same units as other dimensions +of the file. These numbers might be used by a \.{DVI}-reading program to +position individual ``pages'' on large sheets of film or paper; however, +the standard convention for output on normal size paper is to position each +page so that the upper left-hand corner is exactly one inch from the left +and the top. Experience has shown that it is unwise to design \.{DVI}-to-printer +software that attempts cleverly to center the output; a fixed position of +the upper left corner is easiest for users to understand and to work with. +Therefore |l| and~|u| are often ignored. + +Parameter |s| is the maximum stack depth (i.e., the largest excess of +|push| commands over |pop| commands) needed to process this file. Then +comes |t|, the total number of pages (|bop| commands) present. + +The postamble continues with font definitions, which are any number of +\\{fnt\_def} commands as described above, possibly interspersed with |nop| +commands. Each font number that is used in the \.{DVI} file must be defined +exactly twice: Once before it is first selected by a \\{fnt} command, and once +in the postamble. + +@ The last part of the postamble, following the |post_post| byte that +signifies the end of the font definitions, contains |q|, a pointer to the +|post| command that started the postamble. An identification byte, |i|, +comes next; this currently equals~2, as in the preamble. + +The |i| byte is followed by four or more bytes that are all equal to +the decimal number 223 (i.e., '337 in octal). \TeX\ puts out four to seven of +these trailing bytes, until the total length of the file is a multiple of +four bytes, since this works out best on machines that pack four bytes per +word; but any number of 223's is allowed, as long as there are at least four +of them. In effect, 223 is a sort of signature that is added at the very end. +@^Fuchs, David Raymond@> + +This curious way to finish off a \.{DVI} file makes it feasible for +\.{DVI}-reading programs to find the postamble first, on most computers, +even though \TeX\ wants to write the postamble last. Most operating +systems permit random access to individual words or bytes of a file, so +the \.{DVI} reader can start at the end and skip backwards over the 223's +until finding the identification byte. Then it can back up four bytes, read +|q|, and move to byte |q| of the file. This byte should, of course, +contain the value 248 (|post|); now the postamble can be read, so the +\.{DVI} reader can discover all the information needed for typesetting the +pages. Note that it is also possible to skip through the \.{DVI} file at +reasonably high speed to locate a particular page, if that proves +desirable. This saves a lot of time, since \.{DVI} files used in production +jobs tend to be large. + +Unfortunately, however, standard \PASCAL\ does not include the ability to +@^system dependencies@> +access a random position in a file, or even to determine the length of a file. +Almost all systems nowadays provide the necessary capabilities, so \.{DVI} +format has been designed to work most efficiently with modern operating systems. +But if \.{DVI} files have to be processed under the restrictions of standard +\PASCAL, one can simply read them from front to back, since the necessary +header information is present in the preamble and in the font definitions. +(The |l| and |u| and |s| and |t| parameters, which appear only in the +postamble, are ``frills'' that are handy but not absolutely necessary.) + + +@* \[32] Shipping pages out. +After considering \TeX's eyes and stomach, we come now to the bowels. +@^bowels@> + +The |ship_out| procedure is given a pointer to a box; its mission is +to describe that box in \.{DVI} form, outputting a ``page'' to |dvi_file|. +The \.{DVI} coordinates $(h,v)=(0,0)$ should correspond to the upper left +corner of the box being shipped. + +Since boxes can be inside of boxes inside of boxes, the main work of +|ship_out| is done by two mutually recursive routines, |hlist_out| +and |vlist_out|, which traverse the hlists and vlists inside of horizontal +and vertical boxes. + +As individual pages are being processed, we need to accumulate +information about the entire set of pages, since such statistics must be +reported in the postamble. The global variables |total_pages|, |max_v|, +|max_h|, |max_push|, and |last_bop| are used to record this information. + +The variable |doing_leaders| is |true| while leaders are being output. +The variable |dead_cycles| contains the number of times an output routine +has been initiated since the last |ship_out|. + +A few additional global variables are also defined here for use in +|vlist_out| and |hlist_out|. They could have been local variables, but +that would waste stack space when boxes are deeply nested, since the +values of these variables are not needed during recursive calls. +@^recursion@> + +@c +int total_pages = 0; /* the number of pages that have been shipped out */ +scaled max_v = 0; /* maximum height-plus-depth of pages shipped so far */ +scaled max_h = 0; /* maximum width of pages shipped so far */ +int max_push = 0; /* deepest nesting of |push| commands encountered so far */ +int last_bop = -1; /* location of previous |bop| in the \.{DVI} output */ +int dead_cycles = 0; /* recent outputs that didn't ship anything out */ +boolean doing_leaders = false; /* are we inside a leader box? */ +int c, f; /* character and font in current |char_node| */ +int oval, ocmd; /* used by |out_cmd| for generating |set|, |fnt| and |fnt_def| commands */ +pointer g; /* current glue specification */ +int lq, lr; /* quantities used in calculations for leaders */ +int cur_s = -1; /* current depth of output box nesting, initially $-1$ */ + +@ The \.{DVI} bytes are output to a buffer instead of being written directly +to the output file. This makes it possible to reduce the overhead of +subroutine calls, thereby measurably speeding up the computation, since +output of \.{DVI} bytes is part of \TeX's inner loop. And it has another +advantage as well, since we can change instructions in the buffer in order to +make the output more compact. For example, a `|down2|' command can be +changed to a `|y2|', thereby making a subsequent `|y0|' command possible, +saving two bytes. + +The output buffer is divided into two parts of equal size; the bytes found +in |dvi_buf[0..half_buf-1]| constitute the first half, and those in +|dvi_buf[half_buf..dvi_buf_size-1]| constitute the second. The global +variable |dvi_ptr| points to the position that will receive the next +output byte. When |dvi_ptr| reaches |dvi_limit|, which is always equal +to one of the two values |half_buf| or |dvi_buf_size|, the half buffer that +is about to be invaded next is sent to the output and |dvi_limit| is +changed to its other value. Thus, there is always at least a half buffer's +worth of information present, except at the very beginning of the job. + +Bytes of the \.{DVI} file are numbered sequentially starting with 0; +the next byte to be generated will be number |dvi_offset+dvi_ptr|. +A byte is present in the buffer only if its number is |>=dvi_gone|. + +Some systems may find it more efficient to make |dvi_buf| a |packed| +array, since output of four bytes at once may be facilitated. +@^system dependencies@> + + +@ Initially the buffer is all in one piece; we will output half of it only +after it first fills up. + +@c +int dvi_buf_size = 800; /* size of the output buffer; must be a multiple of 8 */ +eight_bits *dvi_buf; /* buffer for \.{DVI} output */ +dvi_index half_buf = 0; /* half of |dvi_buf_size| */ +dvi_index dvi_limit = 0; /* end of the current half buffer */ +dvi_index dvi_ptr = 0; /* the next available buffer address */ +int dvi_offset = 0; /* |dvi_buf_size| times the number of times the output buffer has been fully emptied */ +int dvi_gone = 0; /* the number of bytes already output to |dvi_file| */ + +@ The actual output of |dvi_buf[a..b]| to |dvi_file| is performed by calling +|write_dvi(a,b)|. For best results, this procedure should be optimized to +run as fast as possible on each particular system, since it is part of +\TeX's inner loop. It is safe to assume that |a| and |b+1| will both be +multiples of 4 when |write_dvi(a,b)| is called; therefore it is possible on +many machines to use efficient methods to pack four bytes per word and to +output an array of words with one system call. +@^system dependencies@> +@^inner loop@> +@^defecation@> + +@c +void write_dvi(dvi_index a, dvi_index b) +{ + dvi_index k; + for (k = a; k <= b; k++) + fputc(dvi_buf[k], static_pdf->file); +} + +/* outputs half of the buffer */ +void dvi_swap(void) +{ + if (dvi_limit == dvi_buf_size) { + write_dvi(0, half_buf - 1); + dvi_limit = half_buf; + dvi_offset = dvi_offset + dvi_buf_size; + dvi_ptr = 0; + } else { + write_dvi(half_buf, dvi_buf_size - 1); + dvi_limit = dvi_buf_size; + } + dvi_gone = dvi_gone + half_buf; +} + +@ The |dvi_four| procedure outputs four bytes in two's complement notation, +without risking arithmetic overflow. + +@c +void dvi_four(int x) +{ + if (x >= 0) { + dvi_out(x / 0100000000); + } else { + x = x + 010000000000; + x = x + 010000000000; + dvi_out((x / 0100000000) + 128); + } + x = x % 0100000000; + dvi_out(x / 0200000); + x = x % 0200000; + dvi_out(x / 0400); + dvi_out(x % 0400); +} + +@ +A mild optimization of the output is performed by the |dvi_pop| +routine, which issues a |pop| unless it is possible to cancel a +`|push| |pop|' pair. The parameter to |dvi_pop| is the byte address +following the old |push| that matches the new |pop|. + + +@c +void dvi_push(void) +{ + dvi_out(push); +} + +void dvi_pop(int l) +{ + if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0)) + decr(dvi_ptr); + else + dvi_out(pop); +} + +@ Here's a procedure that outputs a font definition. $\Omega$ allows +more than 256 different fonts per job, so the right font definition +command must be selected. + +@c +void out_cmd(void) +{ + if ((oval < 0x100) && (oval >= 0)) { + if ((ocmd != set1) || (oval > 127)) { + if ((ocmd == fnt1) && (oval < 64)) + oval += fnt_num_0; + else + dvi_out(ocmd); + } + } else { + if ((oval < 0x10000) && (oval >= 0)) { + dvi_out(ocmd + 1); + } else { + if ((oval < 0x1000000) && (oval >= 0)) { + dvi_out(ocmd + 2); + } else { + dvi_out(ocmd + 3); + if (oval >= 0) { + dvi_out(oval / 0x1000000); + } else { + oval += 0x40000000; + oval += 0x40000000; + dvi_out((oval / 0x1000000) + 128); + oval = oval % 0x1000000; + } + dvi_out(oval / 0x10000); + oval = oval % 0x10000; + } + dvi_out(oval / 0x10000); + oval = oval % 0x10000; + } + dvi_out(oval / 0x100); + oval = oval % 0x100; + } + dvi_out(oval); +} + +void dvi_font_def(internal_font_number f) +{ + char *fa; + oval = f - 1; + ocmd = fnt_def1; + out_cmd(); + dvi_out(font_check_0(f)); + dvi_out(font_check_1(f)); + dvi_out(font_check_2(f)); + dvi_out(font_check_3(f)); + dvi_four(font_size(f)); + dvi_four(font_dsize(f)); + dvi_out(0); /* |font_area(f)| is unused */ + dvi_out(strlen(font_name(f))); + /* Output the font name whose internal number is |f| */ + fa = font_name(f); + while (*fa != '\0') { + dvi_out(*fa++); + } +} + +@ Versions of \TeX\ intended for small computers might well choose to omit +the ideas in the next few parts of this program, since it is not really +necessary to optimize the \.{DVI} code by making use of the |w0|, |x0|, +|y0|, and |z0| commands. Furthermore, the algorithm that we are about to +describe does not pretend to give an optimum reduction in the length +of the \.{DVI} code; after all, speed is more important than compactness. +But the method is surprisingly effective, and it takes comparatively little +time. + +We can best understand the basic idea by first considering a simpler problem +that has the same essential characteristics. Given a sequence of digits, +say $3\,1\,4\,1\,5\,9\,2\,6\,5\,3\,5\,8\,9$, we want to assign subscripts +$d$, $y$, or $z$ to each digit so as to maximize the number of ``$y$-hits'' +and ``$z$-hits''; a $y$-hit is an instance of two appearances of the same +digit with the subscript $y$, where no $y$'s intervene between the two +appearances, and a $z$-hit is defined similarly. For example, the sequence +above could be decorated with subscripts as follows: +$$3_z\,1_y\,4_d\,1_y\,5_y\,9_d\,2_d\,6_d\,5_y\,3_z\,5_y\,8_d\,9_d.$$ +There are three $y$-hits ($1_y\ldots1_y$ and $5_y\ldots5_y\ldots5_y$) and +one $z$-hit ($3_z\ldots3_z$); there are no $d$-hits, since the two appearances +of $9_d$ have $d$'s between them, but we don't count $d$-hits so it doesn't +matter how many there are. These subscripts are analogous to the \.{DVI} +commands called \\{down}, $y$, and $z$, and the digits are analogous to +different amounts of vertical motion; a $y$-hit or $z$-hit corresponds to +the opportunity to use the one-byte commands |y0| or |z0| in a \.{DVI} file. + +\TeX's method of assigning subscripts works like this: Append a new digit, +say $\delta$, to the right of the sequence. Now look back through the +sequence until one of the following things happens: (a)~You see +$\delta_y$ or $\delta_z$, and this was the first time you encountered a +$y$ or $z$ subscript, respectively. Then assign $y$ or $z$ to the new +$\delta$; you have scored a hit. (b)~You see $\delta_d$, and no $y$ +subscripts have been encountered so far during this search. Then change +the previous $\delta_d$ to $\delta_y$ (this corresponds to changing a +command in the output buffer), and assign $y$ to the new $\delta$; it's +another hit. (c)~You see $\delta_d$, and a $y$ subscript has been seen +but not a $z$. Change the previous $\delta_d$ to $\delta_z$ and assign +$z$ to the new $\delta$. (d)~You encounter both $y$ and $z$ subscripts +before encountering a suitable $\delta$, or you scan all the way to the +front of the sequence. Assign $d$ to the new $\delta$; this assignment may +be changed later. + +The subscripts $3_z\,1_y\,4_d\ldots\,$ in the example above were, in fact, +produced by this procedure, as the reader can verify. (Go ahead and try it.) + +@ In order to implement such an idea, \TeX\ maintains a stack of pointers +to the \\{down}, $y$, and $z$ commands that have been generated for the +current page. And there is a similar stack for \\{right}, |w|, and |x| +commands. These stacks are called the down stack and right stack, and their +top elements are maintained in the variables |down_ptr| and |right_ptr|. + +Each entry in these stacks contains four fields: The |width| field is +the amount of motion down or to the right; the |location| field is the +byte number of the \.{DVI} command in question (including the appropriate +|dvi_offset|); the |vlink| field points to the next item below this one +on the stack; and the |vinfo| field encodes the options for possible change +in the \.{DVI} command. + +@c +#define location(A) varmem[(A)+1].cint /* \.{DVI} byte number for a movement command */ + +halfword down_ptr = null, right_ptr = null; /* heads of the down and right stacks */ + +@ Here is a subroutine that produces a \.{DVI} command for some specified +downward or rightward motion. It has two parameters: |w| is the amount +of motion, and |o| is either |down1| or |right1|. We use the fact that +the command codes have convenient arithmetic properties: |y1-down1=w1-right1| +and |z1-down1=x1-right1|. + +@c +void movement(scaled w, eight_bits o) +{ + small_number mstate; /* have we seen a |y| or |z|? */ + halfword p, q; /* current and top nodes on the stack */ + int k; /* index into |dvi_buf|, modulo |dvi_buf_size| */ + if (false) { /* TODO: HUH? */ + q = new_node(movement_node, 0); /* new node for the top of the stack */ + width(q) = w; + location(q) = dvi_offset + dvi_ptr; + if (o == down1) { + vlink(q) = down_ptr; + down_ptr = q; + } else { + vlink(q) = right_ptr; + right_ptr = q; + } + /* Look at the other stack entries until deciding what sort of \.{DVI} command + to generate; |goto found| if node |p| is a ``hit'' */ + p = vlink(q); + mstate = none_seen; + while (p != null) { + if (width(p) == w) { + /* Consider a node with matching width;|goto found| if it's a hit */ + /* We might find a valid hit in a |y| or |z| byte that is already gone + from the buffer. But we can't change bytes that are gone forever; ``the + moving finger writes, $\ldots\,\,$.'' */ + + switch (mstate + vinfo(p)) { + case none_seen + yz_OK: + case none_seen + y_OK: + case z_seen + yz_OK: + case z_seen + y_OK: + if (location(p) < dvi_gone) { + goto NOT_FOUND; + } else { + /* Change buffered instruction to |y| or |w| and |goto found| */ + k = location(p) - dvi_offset; + if (k < 0) + k = k + dvi_buf_size; + dvi_buf[k] = (eight_bits) (dvi_buf[k] + y1 - down1); + vinfo(p) = y_here; + goto FOUND; + } + break; + case none_seen + z_OK: + case y_seen + yz_OK: + case y_seen + z_OK: + if (location(p) < dvi_gone) { + goto NOT_FOUND; + } else { + /* Change buffered instruction to |z| or |x| and |goto found| */ + k = location(p) - dvi_offset; + if (k < 0) + k = k + dvi_buf_size; + dvi_buf[k] = (eight_bits) (dvi_buf[k] + z1 - down1); + vinfo(p) = z_here; + goto FOUND; + } + break; + case none_seen + y_here: + case none_seen + z_here: + case y_seen + z_here: + case z_seen + y_here: + goto FOUND; + break; + default: + break; + } + } else { + switch (mstate + vinfo(p)) { + case none_seen + y_here: + mstate = y_seen; + break; + case none_seen + z_here: + mstate = z_seen; + break; + case y_seen + z_here: + case z_seen + y_here: + goto NOT_FOUND; + break; + default: + break; + } + } + p = vlink(p); + } + } + NOT_FOUND: + /* Generate a |down| or |right| command for |w| and |return| */ + if (abs(w) >= 040000000) { + dvi_out(o + 3); /* |down4| or |right4| */ + dvi_four(w); + return; + } + if (abs(w) >= 0100000) { + dvi_out(o + 2); /* |down3| or |right3| */ + if (w < 0) + w = w + 0100000000; + dvi_out(w / 0200000); + w = w % 0200000; + goto TWO; + } + if (abs(w) >= 0200) { + dvi_out(o + 1); /* |down2| or |right2| */ + if (w < 0) + w = w + 0200000; + goto TWO; + } + dvi_out(o); /* |down1| or |right1| */ + if (w < 0) + w = w + 0400; + goto ONE; + TWO: + dvi_out(w / 0400); + ONE: + dvi_out(w % 0400); + return; + FOUND: + /* Generate a |y0| or |z0| command in order to reuse a previous appearance of~|w| */ + /* The program below removes movement nodes that are introduced after a |push|, + before it outputs the corresponding |pop|. */ + /* + When the |movement| procedure gets to the label |found|, the value of + |vinfo(p)| will be either |y_here| or |z_here|. If it is, say, |y_here|, + the procedure generates a |y0| command (or a |w0| command), and marks + all |vinfo| fields between |q| and |p| so that |y| is not OK in that range. + */ + vinfo(q) = vinfo(p); + if (vinfo(q) == y_here) { + dvi_out(o + y0 - down1); /* |y0| or |w0| */ + while (vlink(q) != p) { + q = vlink(q); + switch (vinfo(q)) { + case yz_OK: + vinfo(q) = z_OK; + break; + case y_OK: + vinfo(q) = d_fixed; + break; + default: + break; + } + } + } else { + dvi_out(o + z0 - down1); /* |z0| or |x0| */ + while (vlink(q) != p) { + q = vlink(q); + switch (vinfo(q)) { + case yz_OK: + vinfo(q) = y_OK; + break; + case z_OK: + vinfo(q) = d_fixed; + break; + default: + break; + } + } + } +} + +@ In case you are wondering when all the movement nodes are removed from +\TeX's memory, the answer is that they are recycled just before +|hlist_out| and |vlist_out| finish outputting a box. This restores the +down and right stacks to the state they were in before the box was output, +except that some |vinfo|'s may have become more restrictive. + + +@c +/* delete movement nodes with |location>=l| */ +void prune_movements(int l) +{ + pointer p; /* node being deleted */ + while (down_ptr != null) { + if (location(down_ptr) < l) + break; + p = down_ptr; + down_ptr = vlink(p); + flush_node(p); + } + while (right_ptr != null) { + if (location(right_ptr) < l) + return; + p = right_ptr; + right_ptr = vlink(p); + flush_node(p); + } +} + +scaledpos dvi; /* a \.{DVI} position in page coordinates, in sync with DVI file */ + +scaledpos cur_page_size; + +@ When |hlist_out| is called, its duty is to output the box represented +by the |hlist_node| pointed to by |temp_ptr|. The reference point of that +box has coordinates |(cur.h,cur.v)|. + +Similarly, when |vlist_out| is called, its duty is to output the box represented +by the |vlist_node| pointed to by |temp_ptr|. The reference point of that +box has coordinates |(cur.h,cur.v)|. +@^recursion@> + +@ The recursive procedures |hlist_out| and |vlist_out| each have a local variable +|save_dvi| to hold the value of |dvi| just before +entering a new level of recursion. In effect, the value of |save_dvi| +on \TeX's run-time stack corresponds to the values of |h| and |v| +that a \.{DVI}-reading program will push onto its coordinate stack. + +@c +void dvi_place_rule(PDF pdf, halfword q, scaledpos size) +{ + (void) q; + synch_dvi_with_pos(pdf->posstruct->pos); + if (textdir_is_L(pdf->posstruct->dir)) { + dvi_out(set_rule); /* movement optimization for |dir_*L*| */ + dvi.h += size.h; + } else + dvi_out(put_rule); + dvi_four(size.v); + dvi_four(size.h); +} + +void dvi_place_glyph(PDF pdf, internal_font_number f, int c) +{ + scaled_whd ci; + synch_dvi_with_pos(pdf->posstruct->pos); + if (f != pdf->f_cur) { + /* Change font |f_cur| to |f| */ + if (!font_used(f)) { + dvi_font_def(f); + set_font_used(f, true); + } + oval = f - 1; + ocmd = fnt1; + out_cmd(); + pdf->f_cur = f; + } + if (textdir_is_L(pdf->posstruct->dir)) { + ci = get_charinfo_whd(f, c); + dvi_set(c, ci.wd); /* movement optimization for |dir_*L*| */ + } else + dvi_put(c); +} + +void dvi_special(PDF pdf, halfword p) +{ + int old_setting; /* holds print |selector| */ + unsigned k; /* index into |cur_string| */ + synch_dvi_with_pos(pdf->posstruct->pos); + old_setting = selector; + selector = new_string; + show_token_list(token_link(write_tokens(p)), null, -1); + selector = old_setting; + if (cur_length < 256) { + dvi_out(xxx1); + dvi_out(cur_length); + } else { + dvi_out(xxx4); + dvi_four((int) cur_length); + } + for (k = 0; k < cur_length; k++) + dvi_out(cur_string[k]); + cur_length = 0; /* erase the string */ +} + +@ The final line of this routine is slightly subtle; at least, the author +didn't think about it until getting burnt! There is a used-up token list +@^Knuth, Donald Ervin@> +on the stack, namely the one that contained |end_write_token|. (We +insert this artificial `\.{\\endwrite}' to prevent runaways, as explained +above.) If it were not removed, and if there were numerous writes on a +single page, the stack would overflow. + +@c +/* TODO: keep track of this value */ +#define end_write_token cs_token_flag+end_write + +void expand_macros_in_tokenlist(halfword p) +{ + int old_mode; /* saved |mode| */ + pointer q, r; /* temporary variables for list manipulation */ + q = get_avail(); + token_info(q) = right_brace_token + '}'; + r = get_avail(); + token_link(q) = r; + token_info(r) = end_write_token; + begin_token_list(q, inserted); + begin_token_list(write_tokens(p), write_text); + q = get_avail(); + token_info(q) = left_brace_token + '{'; + begin_token_list(q, inserted); + /* now we're ready to scan + `\.\{$\langle\,$token list$\,\rangle$\.{\} \\endwrite}' */ + old_mode = mode; + mode = 0; + /* disable \.{\\prevdepth}, \.{\\spacefactor}, \.{\\lastskip}, \.{\\prevgraf} */ + cur_cs = write_loc; + q = scan_toks(false, true); /* expand macros, etc. */ + get_token(); + if (cur_tok != end_write_token) { + /* Recover from an unbalanced write command */ + const char *hlp[] = { + "On this page there's a \\write with fewer real {'s than }'s.", + "I can't handle that very well; good luck.", NULL + }; + tex_error("Unbalanced write command", hlp); + do { + get_token(); + } while (cur_tok != end_write_token); + } + mode = old_mode; + end_token_list(); /* conserve stack space */ +} + +void write_out(halfword p) +{ + int old_setting; /* holds print |selector| */ + int j; /* write stream number */ + boolean clobbered; /* system string is ok? */ + int ret; /* return value from |runsystem| */ + char *s, *ss; /* line to be written, as a C string */ + int callback_id; + int lua_retval; + expand_macros_in_tokenlist(p); + old_setting = selector; + j = write_stream(p); + if (j == 18) { + selector = new_string; + } else if (write_open[j]) { + selector = j; + } else { /* write to the terminal if file isn't open */ + if ((j == 17) && (selector == term_and_log)) + selector = log_only; + tprint_nl(""); + } + s = tokenlist_to_cstring(def_ref, false, NULL); + if (selector < no_print) { /* selector is a file */ + /* fix up the output buffer using callbacks */ + callback_id = callback_defined(process_output_buffer_callback); + if (callback_id > 0) { + lua_retval = run_callback(callback_id, "S->S", s, &ss); + if ((lua_retval == true) && (ss != NULL)) + s = ss; + } + } + tprint(s); + print_ln(); + flush_list(def_ref); + if (j == 18) { + cur_string[cur_length] = '\0'; /* Convert newline to null. */ + if (tracing_online <= 0) + selector = log_only; /* Show what we're doing in the log file. */ + else + selector = term_and_log; /* Show what we're doing. */ + /* If the log file isn't open yet, we can only send output to the terminal. + Calling |open_log_file| from here seems to result in bad data in the log. + */ + if (!log_opened) + selector = term_only; + tprint_nl("runsystem("); + tprint((char *) cur_string); + tprint(")..."); + if (shellenabledp) { + clobbered = false; + if (strlen((char *) cur_string) != cur_length) + clobbered = true; + /* minimal checking: NUL not allowed in argument string of |system|() */ + if (clobbered) { + tprint("clobbered"); + } else { + /* We have the command. See if we're allowed to execute it, + and report in the log. We don't check the actual exit status of + the command, or do anything with the output. */ + ret = runsystem((char *) cur_string); + if (ret == -1) + tprint("quotation error in system command"); + else if (ret == 0) + tprint("disabled (restricted)"); + else if (ret == 1) + tprint("executed"); + else if (ret == 2) + tprint("executed safely (allowed)"); + } + } else { + tprint("disabled"); /* |shellenabledp| false */ + } + print_char('.'); + tprint_nl(""); + print_ln(); + cur_length = 0; /* erase the string */ + } + selector = old_setting; +} + +@ Here's an example of how these conventions are used. Whenever it is time to +ship out a box of stuff, we shall use the macro |ensure_dvi_open|. + +@c +void ensure_dvi_header_written(PDF pdf) +{ + unsigned l; + unsigned s; /* index into |str_pool| */ + int old_setting; /* saved |selector| setting */ + assert(pdf->o_mode == OMODE_DVI); + assert(pdf->o_state == ST_FILE_OPEN); + + if (half_buf == 0) { + half_buf = dvi_buf_size / 2; + dvi_limit = dvi_buf_size; + } + + dvi_out(pre); + dvi_out(id_byte); /* output the preamble */ + dvi_four(25400000); + dvi_four(473628672); /* conversion ratio for sp */ + prepare_mag(); + dvi_four(mag); /* magnification factor is frozen */ + if (output_comment) { + l = (unsigned) strlen(output_comment); + dvi_out(l); + for (s = 0; s <= l - 1; s++) + dvi_out(output_comment[s]); + } else { /* the default code is unchanged */ + old_setting = selector; + selector = new_string; + tprint(" LuaTeX output "); + print_int(int_par(year_code)); + print_char('.'); + print_two(int_par(month_code)); + print_char('.'); + print_two(int_par(day_code)); + print_char(':'); + print_two(int_par(time_code) / 60); + print_two(int_par(time_code) % 60); + selector = old_setting; + dvi_out(cur_length); + for (s = 0; s < cur_length; s++) + dvi_out(cur_string[s]); + cur_length = 0; + } +} + +void dvi_begin_page(PDF pdf) +{ + int k; + int page_loc; /* location of the current |bop| */ + ensure_output_state(pdf, ST_HEADER_WRITTEN); + /* Initialize variables as |ship_out| begins */ + page_loc = dvi_offset + dvi_ptr; + dvi_out(bop); + for (k = 0; k <= 9; k++) + dvi_four(count(k)); + dvi_four(last_bop); + last_bop = page_loc; +} + +void dvi_end_page(PDF pdf) +{ + (void) pdf; + dvi_out(eop); + +#ifdef IPC + if (ipcon > 0) { + if (dvi_limit == half_buf) { + write_dvi(half_buf, dvi_buf_size - 1); + fflush(static_pdf->file); + dvi_gone = dvi_gone + half_buf; + } + if (dvi_ptr > 0) { + write_dvi(0, dvi_ptr - 1); + fflush(static_pdf->file); + dvi_offset = dvi_offset + dvi_ptr; + dvi_gone = dvi_gone + dvi_ptr; + } + dvi_ptr = 0; + dvi_limit = dvi_buf_size; + ipcpage(dvi_gone); + } +#endif /* IPC */ +} + +@ At the end of the program, we must finish things off by writing the +post\-amble. If |total_pages=0|, the \.{DVI} file was never opened. +If |total_pages>=65536|, the \.{DVI} file will lie. And if +|max_push>=65536|, the user deserves whatever chaos might ensue. + +@c +void finish_dvi_file(PDF pdf, int version, int revision) +{ + int k; + boolean res; + int callback_id = callback_defined(stop_run_callback); + (void) version; + (void) revision; + while (cur_s > -1) { + if (cur_s > 0) { + dvi_out(pop); + } else { + dvi_out(eop); + incr(total_pages); + } + decr(cur_s); + } + if (total_pages == 0) { + if (callback_id == 0) + tprint_nl("No pages of output."); + else if (callback_id > 0) + res = run_callback(callback_id, "->"); + } else { + dvi_out(post); /* beginning of the postamble */ + dvi_four(last_bop); + last_bop = dvi_offset + dvi_ptr - 5; /* |post| location */ + dvi_four(25400000); + dvi_four(473628672); /* conversion ratio for sp */ + prepare_mag(); + dvi_four(mag); /* magnification factor */ + dvi_four(max_v); + dvi_four(max_h); + dvi_out(max_push / 256); + dvi_out(max_push % 256); + dvi_out((total_pages / 256) % 256); + dvi_out(total_pages % 256); + /* Output the font definitions for all fonts that were used */ + k = max_font_id(); + while (k > 0) { + if (font_used(k)) { + dvi_font_def(k); + } + decr(k); + } + + dvi_out(post_post); + dvi_four(last_bop); + dvi_out(id_byte); +#ifndef IPC + k = 4 + ((dvi_buf_size - dvi_ptr) % 4); /* the number of 223's */ +#else + k = 7 - ((3 + dvi_offset + dvi_ptr) % 4); /* the number of 223's */ +#endif + + while (k > 0) { + dvi_out(223); + decr(k); + } + /* Empty the last bytes out of |dvi_buf| */ + /* Here is how we clean out the buffer when \TeX\ is all through; |dvi_ptr| + will be a multiple of~4. */ + if (dvi_limit == half_buf) + write_dvi(half_buf, dvi_buf_size - 1); + if (dvi_ptr > 0) + write_dvi(0, dvi_ptr - 1); + + if (callback_id == 0) { + tprint_nl("Output written on "); + tprint(pdf->file_name); + tprint(" ("); + print_int(total_pages); + tprint(" page"); + if (total_pages != 1) + print_char('s'); + tprint(", "); + print_int(dvi_offset + dvi_ptr); + tprint(" bytes)."); + } else if (callback_id > 0) { + res = run_callback(callback_id, "->"); + } + close_file(pdf->file); + } +} diff --git a/Build/source/texk/web2c/luatexdir/font/dofont.c b/Build/source/texk/web2c/luatexdir/font/dofont.c deleted file mode 100644 index 4e026f339a3..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/dofont.c +++ /dev/null @@ -1,179 +0,0 @@ -/* dofont.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" - -#include "luatex-api.h" - -static const char _svn_version[] = - "$Id: dofont.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/dofont.c $"; - -#define TIMERS 0 - -#if TIMERS -# include -#endif - - -/* a bit more interfacing is needed for proper error reporting */ - -static char *font_error_message(pointer u, char *nom, scaled s) -{ - char *str = xmalloc(256); - char *c = makecstring(zget_cs_text(u)); - const char *extra = "metric data not found or bad"; - if (s >= 0) { - snprintf(str, 255, "Font \\%s=%s at %gpt not loadable: %s", c, nom, - (double) s / 65536, extra); - } else if (s != -1000) { - snprintf(str, 255, "Font \\%s=%s scaled %d not loadable: %s", c, nom, - (int) (-s), extra); - } else { - snprintf(str, 255, "Font \\%s=%s not loadable: %s", c, nom, extra); - } - return str; -} - -static int do_define_font(integer f, const char *cnom, scaled s, integer natural_dir) -{ - - boolean res; /* was the callback successful? */ - integer callback_id; - char *cnam; -#if TIMERS - struct timeval tva; - struct timeval tvb; - double tvdiff; -#endif - int r; - res = 0; - - callback_id = callback_defined(define_font_callback); - if (callback_id > 0) { - cnam = xstrdup(cnom); -#if TIMERS - gettimeofday(&tva, NULL); -#endif - callback_id = run_and_save_callback(callback_id, "Sdd->", cnam, s, f); -#if TIMERS - gettimeofday(&tvb, NULL); - tvdiff = tvb.tv_sec * 1000000.0; - tvdiff += (double) tvb.tv_usec; - tvdiff -= (tva.tv_sec * 1000000.0); - tvdiff -= (double) tva.tv_usec; - tvdiff /= 1000000; - fprintf(stdout, "\ncallback('define_font',%s,%i): %f seconds\n", cnam, - f, tvdiff); -#endif - free(cnam); - if (callback_id > 0) { /* success */ - luaL_checkstack(Luas, 1, "out of stack space"); - lua_rawgeti(Luas, LUA_REGISTRYINDEX, callback_id); - if (lua_istable(Luas, -1)) { -#if TIMERS - gettimeofday(&tva, NULL); -#endif - res = font_from_lua(Luas, f); - destroy_saved_callback(callback_id); -#if TIMERS - gettimeofday(&tvb, NULL); - tvdiff = tvb.tv_sec * 1000000.0; - tvdiff += (double) tvb.tv_usec; - tvdiff -= (tva.tv_sec * 1000000.0); - tvdiff -= (double) tva.tv_usec; - tvdiff /= 1000000; - fprintf(stdout, "font_from_lua(%s,%i): %f seconds\n", - font_name(f), f, tvdiff); -#endif - /* lua_pop(Luas, 1); *//* done by font_from_lua */ - } else if (lua_isnumber(Luas, -1)) { - r = lua_tonumber(Luas, -1); - destroy_saved_callback(callback_id); - delete_font(f); - lua_pop(Luas, 1); - return r; - } else { - lua_pop(Luas, 1); - delete_font(f); - return 0; - } - } - } else if (callback_id == 0) { - res = read_tfm_info(f, cnom, s); - if (res) { - set_hyphen_char(f, get_default_hyphen_char()); - set_skew_char(f, get_default_skew_char()); - } - } - if (res) { - if (font_type(f) != virtual_font_type) { /* implies lua */ - do_vf(f); - set_font_natural_dir(f, natural_dir); - } - return f; - } else { - delete_font(f); - return 0; - } - -} - -int read_font_info(pointer u, str_number nom, scaled s, integer natural_dir) -{ - integer f; - char *cnom; - char *msg; - cnom = xstrdup(makecstring(nom)); - - f = new_font(); - if ((f = do_define_font(f, cnom, s, natural_dir))) { - free(cnom); - return f; - } else { - const char *help[] = { "I wasn't able to read the size data for this font,", - "so I will ignore the font specification.", - "[Wizards can fix TFM files using TFtoPL/PLtoTF.]", - "You might try inserting a different font spec;", - "e.g., type `I\font='.", - NULL - }; - if (!get_suppress_fontnotfound_error()) { - msg = font_error_message(u, cnom, s); - tex_error(msg, help); - free(msg); - } - free(cnom); - return 0; - } -} - -/* TODO This function is a placeholder. There can easily appears holes in - the |font_tables| array, and we could attempt to reuse those -*/ - -int find_font_id(const char *nom, scaled s) -{ - integer f; - f = new_font(); - if ((f = do_define_font(f, nom, s, -1))) { - return f; - } else { - return 0; - } -} diff --git a/Build/source/texk/web2c/luatexdir/font/dofont.w b/Build/source/texk/web2c/luatexdir/font/dofont.w new file mode 100644 index 00000000000..38278e8d1cb --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/dofont.w @@ -0,0 +1,147 @@ +% dofont.w +% +% Copyright 2006-2010 Taco Hoekwater +% +% This file is part of LuaTeX. +% +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. +% +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. +% +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" + +#include "lua/luatex-api.h" + +static const char _svn_version[] = + "$Id: dofont.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/dofont.w $"; + +@ a bit more interfacing is needed for proper error reporting + +@c +static char *font_error_message(pointer u, char *nom, scaled s) +{ + char *str = xmalloc(256); + char *c = makecstring(cs_text(u)); + const char *extra = "metric data not found or bad"; + if (s >= 0) { + snprintf(str, 255, "Font \\%s=%s at %gpt not loadable: %s", c, nom, + (double) s / 65536, extra); + } else if (s != -1000) { + snprintf(str, 255, "Font \\%s=%s scaled %d not loadable: %s", c, nom, + (int) (-s), extra); + } else { + snprintf(str, 255, "Font \\%s=%s not loadable: %s", c, nom, extra); + } + free(c); + return str; +} + +static int do_define_font(int f, const char *cnom, scaled s, int natural_dir) +{ + + boolean res; /* was the callback successful? */ + int callback_id; + char *cnam; + int r; + res = 0; + + callback_id = callback_defined(define_font_callback); + if (callback_id > 0) { + cnam = xstrdup(cnom); + callback_id = run_and_save_callback(callback_id, "Sdd->", cnam, s, f); + free(cnam); + if (callback_id > 0) { /* success */ + luaL_checkstack(Luas, 1, "out of stack space"); + lua_rawgeti(Luas, LUA_REGISTRYINDEX, callback_id); + if (lua_istable(Luas, -1)) { + res = font_from_lua(Luas, f); + destroy_saved_callback(callback_id); + /* |lua_pop(Luas, 1);| *//* done by |font_from_lua| */ + } else if (lua_isnumber(Luas, -1)) { + lua_number2int(r, lua_tonumber(Luas, -1)); + destroy_saved_callback(callback_id); + delete_font(f); + lua_pop(Luas, 1); + return r; + } else { + lua_pop(Luas, 1); + delete_font(f); + return 0; + } + } + } else if (callback_id == 0) { + res = read_tfm_info(f, cnom, s); + if (res) { + set_hyphen_char(f, int_par(default_hyphen_char_code)); + set_skew_char(f, int_par(default_skew_char_code)); + } + } + if (font_name(f) && strlen(font_name(f)) > 255) { + /* the font name has to fit in the dvi file's single byte storage */ + /* no need to test area, as we are never using it */ + res = 0; + } + if (res) { + if (font_type(f) != virtual_font_type) { /* implies lua */ + do_vf(f); + set_font_natural_dir(f, natural_dir); + } + return f; + } else { + delete_font(f); + return 0; + } + +} + +int read_font_info(pointer u, char *cnom, scaled s, int natural_dir) +{ + int f; + char *msg; + + f = new_font(); + if ((f = do_define_font(f, cnom, s, natural_dir))) { + return f; + } else { + const char *help[] = + { "I wasn't able to read the size data for this font,", + "so I will ignore the font specification.", + "[Wizards can fix TFM files using TFtoPL/PLtoTF.]", + "You might try inserting a different font spec;", + "e.g., type `I\\font='.", + NULL + }; + if (int_par(suppress_fontnotfound_error_code) == 0) { + msg = font_error_message(u, cnom, s); + tex_error(msg, help); + free(msg); + } + return 0; + } +} + +@ TODO This function is a placeholder. There can easily appears holes in + the |font_tables| array, and we could attempt to reuse those + +@c +int find_font_id(const char *nom, scaled s) +{ + int f; + f = new_font(); + if ((f = do_define_font(f, nom, s, -1))) { + return f; + } else { + return 0; + } +} diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.c b/Build/source/texk/web2c/luatexdir/font/luafont.c deleted file mode 100644 index 11bafd8b1ec..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/luafont.c +++ /dev/null @@ -1,2322 +0,0 @@ -/* luafont.c - - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "luatex-api.h" -#include - -#include "nodes.h" - -static const char _svn_version[] = - "$Id: luafont.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/luafont.c $"; - -#define noVERBOSE - -const char *font_type_strings[] = { "unknown", "virtual", "real", NULL }; -const char *font_format_strings[] = - { "unknown", "type1", "type3", "truetype", "opentype", NULL }; -const char *font_embedding_strings[] = { "unknown", "no", "subset", "full", NULL }; -const char *ligature_type_strings[] = - { "=:", "=:|", "|=:", "|=:|", "", "=:|>", "|=:>", "|=:|>", "", "", "", - "|=:|>>", NULL -}; - -const char *MATH_param_names[] = { - "nil", - "ScriptPercentScaleDown", - "ScriptScriptPercentScaleDown", - "DelimitedSubFormulaMinHeight", - "DisplayOperatorMinHeight", - "MathLeading", - "AxisHeight", - "AccentBaseHeight", - "FlattenedAccentBaseHeight", - "SubscriptShiftDown", - "SubscriptTopMax", - "SubscriptBaselineDropMin", - "SuperscriptShiftUp", - "SuperscriptShiftUpCramped", - "SuperscriptBottomMin", - "SuperscriptBaselineDropMax", - "SubSuperscriptGapMin", - "SuperscriptBottomMaxWithSubscript", - "SpaceAfterScript", - "UpperLimitGapMin", - "UpperLimitBaselineRiseMin", - "LowerLimitGapMin", - "LowerLimitBaselineDropMin", - "StackTopShiftUp", - "StackTopDisplayStyleShiftUp", - "StackBottomShiftDown", - "StackBottomDisplayStyleShiftDown", - "StackGapMin", - "StackDisplayStyleGapMin", - "StretchStackTopShiftUp", - "StretchStackBottomShiftDown", - "StretchStackGapAboveMin", - "StretchStackGapBelowMin", - "FractionNumeratorShiftUp", - "FractionNumeratorDisplayStyleShiftUp", - "FractionDenominatorShiftDown", - "FractionDenominatorDisplayStyleShiftDown", - "FractionNumeratorGapMin", - "FractionNumeratorDisplayStyleGapMin", - "FractionRuleThickness", - "FractionDenominatorGapMin", - "FractionDenominatorDisplayStyleGapMin", - "SkewedFractionHorizontalGap", - "SkewedFractionVerticalGap", - "OverbarVerticalGap", - "OverbarRuleThickness", - "OverbarExtraAscender", - "UnderbarVerticalGap", - "UnderbarRuleThickness", - "UnderbarExtraDescender", - "RadicalVerticalGap", - "RadicalDisplayStyleVerticalGap", - "RadicalRuleThickness", - "RadicalExtraAscender", - "RadicalKernBeforeDegree", - "RadicalKernAfterDegree", - "RadicalDegreeBottomRaisePercent", - "MinConnectorOverlap", - "SubscriptShiftDownWithSuperscript", - NULL, -}; - -static void dump_intfield(lua_State * L, const char *n, int c) -{ - lua_pushstring(L, n); - lua_pushnumber(L, c); - lua_rawset(L, -3); -} - - -static void dump_math_kerns(lua_State * L, charinfo * co, int l, int id) -{ - int i; - for (i = 0; i < l; i++) { - lua_newtable(L); - /* *INDENT-OFF* */ - if (id==top_left_kern) { - dump_intfield(L, "height", co->top_left_math_kern_array[(2*i)]); - dump_intfield(L, "kern", co->top_left_math_kern_array[(2*i)+1]); - } else if (id==top_right_kern) { - dump_intfield(L, "height", co->top_right_math_kern_array[(2*i)]); - dump_intfield(L, "kern", co->top_right_math_kern_array[(2*i)+1]); - } else if (id==bottom_right_kern) { - dump_intfield(L, "height", co->bottom_right_math_kern_array[(2*i)]); - dump_intfield(L, "kern", co->bottom_right_math_kern_array[(2*i)+1]); - } else if (id==bottom_left_kern) { - dump_intfield(L, "height", co->bottom_left_math_kern_array[(2*i)]); - dump_intfield(L, "kern", co->bottom_left_math_kern_array[(2*i)+1]); - } - /* *INDENT-ON* */ - lua_rawseti(L, -2, (i + 1)); - } -} - - -static void font_char_to_lua(lua_State * L, internalfontnumber f, charinfo * co) -{ - int i, j; - liginfo *l; - kerninfo *ki; - - lua_createtable(L, 0, 10); - - lua_pushstring(L, "width"); - lua_pushnumber(L, get_charinfo_width(co)); - lua_rawset(L, -3); - - lua_pushstring(L, "height"); - lua_pushnumber(L, get_charinfo_height(co)); - lua_rawset(L, -3); - - lua_pushstring(L, "depth"); - lua_pushnumber(L, get_charinfo_depth(co)); - lua_rawset(L, -3); - - lua_pushstring(L, "italic"); - lua_pushnumber(L, get_charinfo_italic(co)); - lua_rawset(L, -3); - - lua_pushstring(L, "top_accent"); - lua_pushnumber(L, get_charinfo_top_accent(co)); - lua_rawset(L, -3); - - lua_pushstring(L, "bot_accent"); - lua_pushnumber(L, get_charinfo_bot_accent(co)); - lua_rawset(L, -3); - - - if (get_charinfo_ef(co) != 0) { - lua_pushstring(L, "expansion_factor"); - lua_pushnumber(L, get_charinfo_ef(co)); - lua_rawset(L, -3); - } - - if (get_charinfo_lp(co) != 0) { - lua_pushstring(L, "left_protruding"); - lua_pushnumber(L, get_charinfo_lp(co)); - lua_rawset(L, -3); - } - - if (get_charinfo_lp(co) != 0) { - lua_pushstring(L, "right_protruding"); - lua_pushnumber(L, get_charinfo_rp(co)); - lua_rawset(L, -3); - } - - - if (font_encodingbytes(f) == 2) { - lua_pushstring(L, "index"); - lua_pushnumber(L, get_charinfo_index(co)); - lua_rawset(L, -3); - } - - if (get_charinfo_name(co) != NULL) { - lua_pushstring(L, "name"); - lua_pushstring(L, get_charinfo_name(co)); - lua_rawset(L, -3); - } - - if (get_charinfo_tounicode(co) != NULL) { - lua_pushstring(L, "tounicode"); - lua_pushstring(L, get_charinfo_tounicode(co)); - lua_rawset(L, -3); - } - - if (get_charinfo_tag(co) == list_tag) { - lua_pushstring(L, "next"); - lua_pushnumber(L, get_charinfo_remainder(co)); - lua_rawset(L, -3); - } - - lua_pushstring(L, "used"); - lua_pushboolean(L, (get_charinfo_used(co) ? true : false)); - lua_rawset(L, -3); - - if (get_charinfo_tag(co) == ext_tag) { - extinfo *h; - h = get_charinfo_hor_variants(co); - if (h != NULL) { - int i = 1; - lua_newtable(L); - while (h != NULL) { - lua_createtable(L, 0, 5); - dump_intfield(L, "glyph", h->glyph); - dump_intfield(L, "extender", h->extender); - dump_intfield(L, "start", h->start_overlap); - dump_intfield(L, "end", h->end_overlap); - dump_intfield(L, "advance", h->advance); - lua_rawseti(L, -2, i); - i++; - h = h->next; - } - lua_setfield(L, -2, "horiz_variants"); - } - h = get_charinfo_vert_variants(co); - if (h != NULL) { - int i = 1; - lua_newtable(L); - while (h != NULL) { - lua_createtable(L, 0, 5); - dump_intfield(L, "glyph", h->glyph); - dump_intfield(L, "extender", h->extender); - dump_intfield(L, "start", h->start_overlap); - dump_intfield(L, "end", h->end_overlap); - dump_intfield(L, "advance", h->advance); - lua_rawseti(L, -2, i); - i++; - h = h->next; - } - lua_setfield(L, -2, "vert_variants"); - } - } - ki = get_charinfo_kerns(co); - if (ki != NULL) { - lua_pushstring(L, "kerns"); - lua_createtable(L, 10, 1); - for (i = 0; !kern_end(ki[i]); i++) { - if (kern_char(ki[i]) == right_boundarychar) { - lua_pushstring(L, "right_boundary"); - } else { - lua_pushnumber(L, kern_char(ki[i])); - } - lua_pushnumber(L, kern_kern(ki[i])); - lua_rawset(L, -3); - } - lua_rawset(L, -3); - } - l = get_charinfo_ligatures(co); - if (l != NULL) { - lua_pushstring(L, "ligatures"); - lua_createtable(L, 10, 1); - for (i = 0; !lig_end(l[i]); i++) { - if (lig_char(l[i]) == right_boundarychar) { - lua_pushstring(L, "right_boundary"); - } else { - lua_pushnumber(L, lig_char(l[i])); - } - lua_createtable(L, 0, 2); - lua_pushstring(L, "type"); - lua_pushnumber(L, lig_type(l[i])); - lua_rawset(L, -3); - lua_pushstring(L, "char"); - lua_pushnumber(L, lig_replacement(l[i])); - lua_rawset(L, -3); - lua_rawset(L, -3); - } - lua_rawset(L, -3); - } - - lua_newtable(L); - - i = get_charinfo_math_kerns(co, top_right_kern); - j = 0; - if (i > 0) { - j++; - lua_newtable(L); - dump_math_kerns(L, co, i, top_right_kern); - lua_setfield(L, -2, "top_right"); - } - i = get_charinfo_math_kerns(co, top_left_kern); - if (i > 0) { - j++; - lua_newtable(L); - dump_math_kerns(L, co, i, top_left_kern); - lua_setfield(L, -2, "top_left"); - } - i = get_charinfo_math_kerns(co, bottom_right_kern); - if (i > 0) { - j++; - lua_newtable(L); - dump_math_kerns(L, co, i, bottom_right_kern); - lua_setfield(L, -2, "bottom_right"); - } - i = get_charinfo_math_kerns(co, bottom_left_kern); - if (i > 0) { - j++; - lua_newtable(L); - dump_math_kerns(L, co, i, bottom_left_kern); - lua_setfield(L, -2, "bottom_left"); - } - if (j > 0) - lua_setfield(L, -2, "mathkern"); - else - lua_pop(L, 1); - -} - -static void write_lua_parameters(lua_State * L, int f) -{ - int k; - lua_newtable(L); - for (k = 1; k <= font_params(f); k++) { - lua_pushnumber(L, font_param(f, k)); - switch (k) { - case slant_code: - lua_setfield(L, -2, "slant"); - break; - case space_code: - lua_setfield(L, -2, "space"); - break; - case space_stretch_code: - lua_setfield(L, -2, "space_stretch"); - break; - case space_shrink_code: - lua_setfield(L, -2, "space_shrink"); - break; - case x_height_code: - lua_setfield(L, -2, "x_height"); - break; - case quad_code: - lua_setfield(L, -2, "quad"); - break; - case extra_space_code: - lua_setfield(L, -2, "extra_space"); - break; - default: - lua_rawseti(L, -2, k); - } - } - lua_setfield(L, -2, "parameters"); -} - - -static void write_lua_math_parameters(lua_State * L, int f) -{ - int k; - lua_newtable(L); - for (k = 1; k < font_math_params(f); k++) { - lua_pushnumber(L, font_math_param(f, k)); - if (k <= MATH_param_max) { - lua_setfield(L, -2, MATH_param_names[k]); - } else { - lua_rawseti(L, -2, k); - } - } - lua_setfield(L, -2, "MathConstants"); -} - - - -int font_to_lua(lua_State * L, int f) -{ - int k; - charinfo *co; - if (font_cache_id(f) > 0) { - /* fetch the table from the registry if it was - saved there by font_from_lua() */ - lua_rawgeti(L, LUA_REGISTRYINDEX, font_cache_id(f)); - /* fontdimens can be changed from tex code */ - write_lua_parameters(L, f); - return 1; - } - - lua_newtable(L); - lua_pushstring(L, font_name(f)); - lua_setfield(L, -2, "name"); - if (font_area(f) != NULL) { - lua_pushstring(L, font_area(f)); - lua_setfield(L, -2, "area"); - } - if (font_filename(f) != NULL) { - lua_pushstring(L, font_filename(f)); - lua_setfield(L, -2, "filename"); - } - if (font_fullname(f) != NULL) { - lua_pushstring(L, font_fullname(f)); - lua_setfield(L, -2, "fullname"); - } - if (font_encodingname(f) != NULL) { - lua_pushstring(L, font_encodingname(f)); - lua_setfield(L, -2, "encodingname"); - } - - lua_pushboolean(L, (font_used(f) ? true : false)); - lua_setfield(L, -2, "used"); - - - lua_pushstring(L, font_type_strings[font_type(f)]); - lua_setfield(L, -2, "type"); - lua_pushstring(L, font_format_strings[font_format(f)]); - lua_setfield(L, -2, "format"); - lua_pushstring(L, font_embedding_strings[font_embedding(f)]); - lua_setfield(L, -2, "embedding"); - - lua_pushnumber(L, font_size(f)); - lua_setfield(L, -2, "size"); - lua_pushnumber(L, font_dsize(f)); - lua_setfield(L, -2, "designsize"); - lua_pushnumber(L, font_checksum(f)); - lua_setfield(L, -2, "checksum"); - lua_pushnumber(L, font_slant(f)); - lua_setfield(L, -2, "slant"); - lua_pushnumber(L, font_extend(f)); - lua_setfield(L, -2, "extend"); - lua_pushnumber(L, font_natural_dir(f)); - lua_setfield(L, -2, "direction"); - lua_pushnumber(L, font_encodingbytes(f)); - lua_setfield(L, -2, "encodingbytes"); - lua_pushnumber(L, font_tounicode(f)); - lua_setfield(L, -2, "tounicode"); - - /* pdf parameters */ - /* skip the first four for now, that are very much interal */ - /* - if (pdf_font_size(f) != 0) { - lua_pushnumber(L,pdf_font_size(f)); - lua_setfield(L,-2,"pdf_size"); - } - if (pdf_font_num(f) != 0) { - lua_pushnumber(L,pdf_font_num(f)); - lua_setfield(L,-2,"pdf_num"); - } - if (pdf_font_blink(f) != 0) { - lua_pushnumber(L,pdf_font_blink(f)); - lua_setfield(L,-2,"pdf_blink"); - } - if (pdf_font_elink(f) != 0) { - lua_pushnumber(L,pdf_font_elink(f)); - lua_setfield(L,-2,"pdf_elink"); - } - */ - /* the next one is read only */ - if (pdf_font_expand_ratio(f) != 0) { - lua_pushnumber(L, pdf_font_expand_ratio(f)); - lua_setfield(L, -2, "expand_ratio"); - } - if (pdf_font_shrink(f) != 0) { - lua_pushnumber(L, pdf_font_shrink(f)); - lua_setfield(L, -2, "shrink"); - } - if (pdf_font_stretch(f) != 0) { - lua_pushnumber(L, pdf_font_stretch(f)); - lua_setfield(L, -2, "stretch"); - } - if (pdf_font_step(f) != 0) { - lua_pushnumber(L, pdf_font_step(f)); - lua_setfield(L, -2, "step"); - } - if (pdf_font_auto_expand(f) != 0) { - lua_pushboolean(L, pdf_font_auto_expand(f)); - lua_setfield(L, -2, "auto_expand"); - } - if (pdf_font_attr(f) != 0) { - lua_pushstring(L, makecstring(pdf_font_attr(f))); - lua_setfield(L, -2, "attributes"); - } - - /* params */ - write_lua_parameters(L, f); - write_lua_math_parameters(L, f); - - /* chars */ - lua_createtable(L, font_tables[f]->charinfo_size, 0); /* all characters */ - - if (has_left_boundary(f)) { - co = get_charinfo(f, left_boundarychar); - font_char_to_lua(L, f, co); - lua_setfield(L, -2, "left_boundary"); - } - if (has_right_boundary(f)) { - co = get_charinfo(f, right_boundarychar); - font_char_to_lua(L, f, co); - lua_setfield(L, -2, "right_boundary"); - } - - for (k = font_bc(f); k <= font_ec(f); k++) { - if (char_exists(f, k)) { - lua_pushnumber(L, k); - co = get_charinfo(f, k); - font_char_to_lua(L, f, co); - lua_rawset(L, -3); - } - } - lua_setfield(L, -2, "characters"); - - if (font_cache_id(f) == 0) { /* renew */ - integer r; - lua_pushvalue(L, -1); - r = luaL_ref(Luas, LUA_REGISTRYINDEX); /* pops the table */ - set_font_cache_id(f, r); - } - return 1; -} - -static int count_hash_items(lua_State * L, int name_index) -{ - int n = -1; - lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); - lua_rawget(L, -2); - if (!lua_isnil(L, -1)) { - if (lua_istable(L, -1)) { - n = 0; - /* now find the number */ - lua_pushnil(L); /* first key */ - while (lua_next(L, -2) != 0) { - n++; - lua_pop(L, 1); - } - } - } - lua_pop(L, 1); - return n; -} - -#define streq(a,b) (strcmp(a,b)==0) - -#define append_packet(k) { cpackets[np++] = k; } - -#define do_store_four(l) { \ - append_packet((l&0xFF000000)>>24); \ - append_packet((l&0x00FF0000)>>16); \ - append_packet((l&0x0000FF00)>>8); \ - append_packet((l&0x000000FF)); } - -/* -*/ - -#define lua_roundnumber(a,b) (int)floor((double)lua_tonumber(L,-1)+0.5) - -static int numeric_field(lua_State * L, const char *name, int dflt) -{ - int i = dflt; - lua_pushstring(L, name); - lua_rawget(L, -2); - if (lua_isnumber(L, -1)) { - i = lua_roundnumber(L, -1); - } - lua_pop(L, 1); - return i; -} - -static int n_numeric_field(lua_State * L, int name_index, int dflt) -{ - register int i = dflt; - lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */ - lua_rawget(L, -2); - if (lua_type(L, -1) == LUA_TNUMBER) { - i = lua_roundnumber(L, -1); - } - lua_pop(L, 1); - return i; -} - - -static int enum_field(lua_State * L, const char *name, int dflt, const char **values) -{ - int k; - const char *s; - int i = dflt; - lua_pushstring(L, name); - lua_rawget(L, -2); - if (lua_isnumber(L, -1)) { - i = lua_tonumber(L, -1); - } else if (lua_isstring(L, -1)) { - s = lua_tostring(L, -1); - k = 0; - while (values[k] != NULL) { - if (strcmp(values[k], s) == 0) { - i = k; - break; - } - k++; - } - } - lua_pop(L, 1); - return i; -} - -static int boolean_field(lua_State * L, const char *name, int dflt) -{ - int i = dflt; - lua_pushstring(L, name); - lua_rawget(L, -2); - if (lua_isboolean(L, -1)) { - i = lua_toboolean(L, -1); - } - lua_pop(L, 1); - return i; -} - -static int n_boolean_field(lua_State * L, int name_index, int dflt) -{ - int i = dflt; - lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */ - lua_rawget(L, -2); - if (lua_isboolean(L, -1)) { - i = lua_toboolean(L, -1); - } - lua_pop(L, 1); - return i; -} - - -static char *string_field(lua_State * L, const char *name, const char *dflt) -{ - char *i; - lua_pushstring(L, name); - lua_rawget(L, -2); - if (lua_isstring(L, -1)) { - i = xstrdup(lua_tostring(L, -1)); - } else if (dflt == NULL) { - i = NULL; - } else { - i = xstrdup(dflt); - } - lua_pop(L, 1); - return i; -} - -static char *n_string_field(lua_State * L, int name_index, const char *dflt) -{ - char *i; - lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */ - lua_rawget(L, -2); - if (lua_isstring(L, -1)) { - i = xstrdup(lua_tostring(L, -1)); - } else if (dflt == NULL) { - i = NULL; - } else { - i = xstrdup(dflt); - } - lua_pop(L, 1); - return i; -} - -#define init_luaS_index(a) do { \ - lua_pushliteral(L,#a); \ - luaS_##a##_ptr = lua_tostring(L,-1); \ - luaS_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \ - } while (0) - -#define make_luaS_index(a) \ - static int luaS_##a##_index = 0; \ - static const char * luaS_##a##_ptr = NULL - -#define luaS_index(a) luaS_##a##_index - -#define luaS_ptr_eq(a,b) (a==luaS_##b##_ptr) - -make_luaS_index(width); -make_luaS_index(height); -make_luaS_index(depth); -make_luaS_index(italic); -make_luaS_index(top_accent); -make_luaS_index(bot_accent); -make_luaS_index(index); -make_luaS_index(left_protruding); -make_luaS_index(right_protruding); -make_luaS_index(expansion_factor); -make_luaS_index(top); -make_luaS_index(bot); -make_luaS_index(rep); -make_luaS_index(mid); -make_luaS_index(next); -make_luaS_index(used); -make_luaS_index(name); -make_luaS_index(tounicode); -make_luaS_index(font); -make_luaS_index(char); -make_luaS_index(slot); -make_luaS_index(comment); -make_luaS_index(push); -make_luaS_index(pop); -make_luaS_index(rule); -make_luaS_index(right); -make_luaS_index(node); -make_luaS_index(down); -make_luaS_index(special); -make_luaS_index(image); -make_luaS_index(slant); -make_luaS_index(space); -make_luaS_index(space_stretch); -make_luaS_index(space_shrink); -make_luaS_index(x_height); -make_luaS_index(quad); -make_luaS_index(extra_space); -make_luaS_index(left_boundary); -make_luaS_index(right_boundary); -make_luaS_index(kerns); -make_luaS_index(ligatures); -make_luaS_index(fonts); -make_luaS_index(extender); -make_luaS_index(start); -make_luaS_index(end); -make_luaS_index(advance); -make_luaS_index(glyph); -make_luaS_index(extensible); -make_luaS_index(horiz_variants); -make_luaS_index(vert_variants); -make_luaS_index(mathkern); -make_luaS_index(commands); - -static void init_font_string_pointers(lua_State * L) -{ - init_luaS_index(width); - init_luaS_index(height); - init_luaS_index(depth); - init_luaS_index(italic); - init_luaS_index(top_accent); - init_luaS_index(bot_accent); - init_luaS_index(index); - init_luaS_index(left_protruding); - init_luaS_index(right_protruding); - init_luaS_index(expansion_factor); - init_luaS_index(top); - init_luaS_index(bot); - init_luaS_index(rep); - init_luaS_index(mid); - init_luaS_index(next); - init_luaS_index(used); - init_luaS_index(name); - init_luaS_index(tounicode); - init_luaS_index(font); - init_luaS_index(char); - init_luaS_index(slot); - init_luaS_index(comment); - init_luaS_index(push); - init_luaS_index(pop); - init_luaS_index(rule); - init_luaS_index(right); - init_luaS_index(node); - init_luaS_index(down); - init_luaS_index(special); - init_luaS_index(image); - - init_luaS_index(slant); - init_luaS_index(space); - init_luaS_index(space_stretch); - init_luaS_index(space_shrink); - init_luaS_index(x_height); - init_luaS_index(quad); - init_luaS_index(extra_space); - - init_luaS_index(left_boundary); - init_luaS_index(right_boundary); - init_luaS_index(kerns); - init_luaS_index(ligatures); - init_luaS_index(fonts); - - init_luaS_index(extender); - init_luaS_index(start); - init_luaS_index(end); - init_luaS_index(advance); - init_luaS_index(glyph); - - init_luaS_index(extensible); - init_luaS_index(horiz_variants); - init_luaS_index(vert_variants); - init_luaS_index(mathkern); - init_luaS_index(commands); - -} - -static int count_char_packet_bytes(lua_State * L) -{ - register int i; - register int l = 0; - int ff = 0; - for (i = 1; i <= (int) lua_objlen(L, -1); i++) { - lua_rawgeti(L, -1, i); - if (lua_istable(L, -1)) { - lua_rawgeti(L, -1, 1); - if (lua_isstring(L, -1)) { - const char *s = lua_tostring(L, -1); - if (luaS_ptr_eq(s, font)) { - l += 5; - ff = 1; - } else if (luaS_ptr_eq(s, char)) { - if (ff == 0) { - l += 5; - } - l += 5; - ff = 1; - } else if (luaS_ptr_eq(s, slot)) { - l += 10; - ff = 1; - } else if (luaS_ptr_eq(s, comment)) {; - } else if (luaS_ptr_eq(s, push) || luaS_ptr_eq(s, pop)) { - l++; - } else if (luaS_ptr_eq(s, rule)) { - l += 9; - } else if (luaS_ptr_eq(s, right) || - luaS_ptr_eq(s, node) || luaS_ptr_eq(s, down)) { - l += 5; - } else if (luaS_ptr_eq(s, special)) { - size_t len; - lua_rawgeti(L, -2, 2); - (void) lua_tolstring(L, -1, &len); - lua_pop(L, 1); - if (len > 0) { - l = l + 5 + len; - } - } else if (luaS_ptr_eq(s, image)) { - l += 5; - } else { - fprintf(stdout, "unknown packet command %s!\n", s); - } - } else { - fprintf(stdout, "no packet command!\n"); - } - lua_pop(L, 1); /* command name */ - } - lua_pop(L, 1); /* item */ - } - return l; -} - - - -static scaled sp_to_dvi(halfword sp, halfword atsize) -{ - double result, mult; - mult = (double) (atsize / 65536.0); - result = (double) (sp * 16.0); - return floor(result / mult); -} - - -static void -read_char_packets(lua_State * L, integer * l_fonts, charinfo * co, int atsize) -{ - int i, n, m; - size_t l; - int cmd; - const char *s; - real_eight_bits *cpackets; - int ff = 0; - int np = 0; - int max_f = 0; - int pc = count_char_packet_bytes(L); - if (pc <= 0) - return; - assert(l_fonts != NULL); - assert(l_fonts[1] != 0); - while (l_fonts[(max_f + 1)] != 0) - max_f++; - - cpackets = xmalloc(pc + 1); - for (i = 1; i <= (int) lua_objlen(L, -1); i++) { - lua_rawgeti(L, -1, i); - if (lua_istable(L, -1)) { - /* fetch the command code */ - lua_rawgeti(L, -1, 1); - if (lua_isstring(L, -1)) { - s = lua_tostring(L, -1); - cmd = 0; - if (luaS_ptr_eq(s, font)) { - cmd = packet_font_code; - } else if (luaS_ptr_eq(s, char)) { - cmd = packet_char_code; - if (ff == 0) { - append_packet(packet_font_code); - ff = l_fonts[1]; - do_store_four(ff); - } - } else if (luaS_ptr_eq(s, slot)) { - cmd = packet_nop_code; - lua_rawgeti(L, -2, 2); - n = lua_tointeger(L, -1); - ff = (n > max_f ? l_fonts[1] : l_fonts[n]); - lua_rawgeti(L, -3, 3); - n = lua_tointeger(L, -1); - lua_pop(L, 2); - append_packet(packet_font_code); - do_store_four(ff); - append_packet(packet_char_code); - do_store_four(n); - } else if (luaS_ptr_eq(s, comment)) { - cmd = packet_nop_code; - } else if (luaS_ptr_eq(s, node)) { - cmd = packet_node_code; - } else if (luaS_ptr_eq(s, push)) { - cmd = packet_push_code; - } else if (luaS_ptr_eq(s, pop)) { - cmd = packet_pop_code; - } else if (luaS_ptr_eq(s, rule)) { - cmd = packet_rule_code; - } else if (luaS_ptr_eq(s, right)) { - cmd = packet_right_code; - } else if (luaS_ptr_eq(s, down)) { - cmd = packet_down_code; - } else if (luaS_ptr_eq(s, special)) { - cmd = packet_special_code; - } else if (luaS_ptr_eq(s, image)) { - cmd = packet_image_code; - } - - switch (cmd) { - case packet_push_code: - case packet_pop_code: - append_packet(cmd); - break; - case packet_font_code: - append_packet(cmd); - lua_rawgeti(L, -2, 2); - n = lua_tointeger(L, -1); - ff = (n > max_f ? l_fonts[1] : l_fonts[n]); - do_store_four(ff); - lua_pop(L, 1); - break; - case packet_node_code: - append_packet(cmd); - lua_rawgeti(L, -2, 2); - n = copy_node_list(nodelist_from_lua(L)); - do_store_four(n); - lua_pop(L, 1); - break; - case packet_char_code: - append_packet(cmd); - lua_rawgeti(L, -2, 2); - n = lua_tointeger(L, -1); - do_store_four(n); - lua_pop(L, 1); - break; - case packet_right_code: - case packet_down_code: - append_packet(cmd); - lua_rawgeti(L, -2, 2); - n = lua_tointeger(L, -1); - do_store_four(sp_to_dvi(n, atsize)); - lua_pop(L, 1); - break; - case packet_rule_code: - append_packet(cmd); - lua_rawgeti(L, -2, 2); - n = lua_tointeger(L, -1); - do_store_four(sp_to_dvi(n, atsize)); - lua_rawgeti(L, -3, 3); - n = lua_tointeger(L, -1); - do_store_four(sp_to_dvi(n, atsize)); - lua_pop(L, 2); - break; - case packet_special_code: - append_packet(cmd); - lua_rawgeti(L, -2, 2); - s = lua_tolstring(L, -1, &l); - if (l > 0) { - do_store_four(l); - m = (int) l; - while (m > 0) { - n = *s++; - m--; - append_packet(n); - } - } - lua_pop(L, 1); - break; - case packet_image_code: - append_packet(cmd); - lua_rawgeti(L, -2, 2); /* img/imgtable? ... */ - if (lua_istable(L, -1)) { /* imgtable ... */ - lua_getglobal(L, "img"); /* imglib imgtable ... */ - lua_pushstring(L, "new"); /* `new' imglib imgtable ... */ - lua_gettable(L, -2); /* f imglib imgtable ... */ - lua_insert(L, -3); /* imglib imgtable f ... */ - lua_pop(L, 1); /* imgtable f ... */ - lua_call(L, 1, 1); - } /* img ... */ - luaL_checkudata(L, -1, TYPE_IMG); /* img ... --- just typecheck */ - n = luaL_ref(L, LUA_GLOBALSINDEX); /* ... */ - do_store_four(n); - break; - case packet_nop_code: - break; - default: - fprintf(stdout, - "Unknown char packet code %s (char %d in font %s)\n", - s, (int) c, font_name(f)); - } - } - lua_pop(L, 1); /* command code */ - } else { - fprintf(stdout, - "Found a `commands' item that is not a table (char %d in font %s)\n", - (int) c, font_name(f)); - } - lua_pop(L, 1); /* command table */ - } - append_packet(packet_end_code); - set_charinfo_packets(co, cpackets); - return; -} - - -static void read_lua_cidinfo(lua_State * L, int f) -{ - int i; - char *s; - lua_getfield(L, -1, "cidinfo"); - if (lua_istable(L, -1)) { - i = numeric_field(L, "version", 0); - set_font_cidversion(f, i); - i = numeric_field(L, "supplement", 0); - set_font_cidsupplement(f, i); - s = string_field(L, "registry", "Adobe"); /* Adobe-Identity-0 */ - set_font_cidregistry(f, s); - s = string_field(L, "ordering", "Identity"); - set_font_cidordering(f, s); - } - lua_pop(L, 1); -} - - -static void read_lua_parameters(lua_State * L, int f) -{ - int i, n; - const char *s; - lua_getfield(L, -1, "parameters"); - if (lua_istable(L, -1)) { - /* the number of parameters is the max(IntegerKeys(L)),7) */ - n = 7; - lua_pushnil(L); /* first key */ - while (lua_next(L, -2) != 0) { - if (lua_isnumber(L, -2)) { - i = lua_tonumber(L, -2); - if (i > n) - n = i; - } - lua_pop(L, 1); /* pop value */ - } - if (n > 7) - set_font_params(f, n); - /* sometimes it is handy to have all integer keys */ - for (i = 1; i <= 7; i++) { - lua_rawgeti(L, -1, i); - if (lua_isnumber(L, -1)) { - n = lua_roundnumber(L, -1); - set_font_param(f, i, n); - } - lua_pop(L, 1); - } - lua_pushnil(L); /* first key */ - while (lua_next(L, -2) != 0) { - if (lua_isnumber(L, -2)) { - i = lua_tointeger(L, -2); - if (i >= 8) { - n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0); - set_font_param(f, i, n); - } - } else if (lua_isstring(L, -2)) { - s = lua_tostring(L, -2); - n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0); - if (luaS_ptr_eq(s, slant)) { - set_font_param(f, slant_code, n); - } else if (luaS_ptr_eq(s, space)) { - set_font_param(f, space_code, n); - } else if (luaS_ptr_eq(s, space_stretch)) { - set_font_param(f, space_stretch_code, n); - } else if (luaS_ptr_eq(s, space_shrink)) { - set_font_param(f, space_shrink_code, n); - } else if (luaS_ptr_eq(s, x_height)) { - set_font_param(f, x_height_code, n); - } else if (luaS_ptr_eq(s, quad)) { - set_font_param(f, quad_code, n); - } else if (luaS_ptr_eq(s, extra_space)) { - set_font_param(f, extra_space_code, n); - } - } - lua_pop(L, 1); - } - } - lua_pop(L, 1); - -} - -static void read_lua_math_parameters(lua_State * L, int f) -{ - int i = 0, n = 0; - lua_getfield(L, -1, "MathConstants"); - if (lua_istable(L, -1)) { - lua_pushnil(L); - while (lua_next(L, -2) != 0) { - if (lua_isnumber(L, -2)) { - i = lua_tonumber(L, -2); - } else if (lua_isstring(L, -2)) { - i = luaL_checkoption(L, -2, NULL, MATH_param_names); - } - n = lua_tonumber(L, -1); - if (i != 0) { - set_font_math_param(f, i, n); - } - lua_pop(L, 1); /* pop value */ - } - } - lua_pop(L, 1); -} - -#define MIN_INF -0x7FFFFFFF - - -static void store_math_kerns(lua_State * L, charinfo * co, int id) -{ - int l, k; - scaled ht, krn; - if (lua_istable(L, -1) && ((k = lua_objlen(L, -1)) > 0)) { - for (l = 0; l < k; l++) { - lua_rawgeti(L, -1, (l + 1)); - if (lua_istable(L, -1)) { - lua_getfield(L, -1, "height"); - if (lua_isnumber(L, -1)) { - ht = (scaled) lua_tonumber(L, -1); - } else { - ht = MIN_INF; - } - lua_pop(L, 1); - lua_getfield(L, -1, "kern"); - if (lua_isnumber(L, -1)) { - krn = (scaled) lua_tonumber(L, -1); - } else { - krn = MIN_INF; - } - lua_pop(L, 1); - if (krn > MIN_INF && ht > MIN_INF) - add_charinfo_math_kern(co, id, ht, krn); - } - lua_pop(L, 1); - } - } -} - -static void -font_char_from_lua(lua_State * L, internal_font_number f, integer i, - integer * l_fonts) -{ - int k, r, t; - charinfo *co; - kerninfo *ckerns; - liginfo *cligs; - scaled j; - char *s; - int nl = 0; /* number of ligature table items */ - int nk = 0; /* number of kern table items */ - int ctr = 0; - int atsize = font_size(f); - if (lua_istable(L, -1)) { - co = get_charinfo(f, i); - set_charinfo_tag(co, 0); - j = n_numeric_field(L, luaS_width_index, 0); - set_charinfo_width(co, j); - j = n_numeric_field(L, luaS_height_index, 0); - set_charinfo_height(co, j); - j = n_numeric_field(L, luaS_depth_index, 0); - set_charinfo_depth(co, j); - j = n_numeric_field(L, luaS_italic_index, 0); - set_charinfo_italic(co, j); - j = n_numeric_field(L, luaS_top_accent_index, 0); - set_charinfo_top_accent(co, j); - j = n_numeric_field(L, luaS_bot_accent_index, 0); - set_charinfo_bot_accent(co, j); - j = n_numeric_field(L, luaS_index_index, 0); - set_charinfo_index(co, j); - j = n_numeric_field(L, luaS_expansion_factor_index, 0); - set_charinfo_ef(co, j); - j = n_numeric_field(L, luaS_left_protruding_index, 0); - set_charinfo_lp(co, j); - j = n_numeric_field(L, luaS_right_protruding_index, 0); - set_charinfo_rp(co, j); - k = n_boolean_field(L, luaS_used_index, 0); - set_charinfo_used(co, k); - s = n_string_field(L, luaS_name_index, NULL); - set_charinfo_name(co, s); - s = n_string_field(L, luaS_tounicode_index, NULL); - set_charinfo_tounicode(co, s); - k = n_numeric_field(L, luaS_next_index, -1); - if (k >= 0) { - set_charinfo_tag(co, list_tag); - set_charinfo_remainder(co, k); - } - - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_extensible_index); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { - int top, bot, mid, rep; - top = n_numeric_field(L, luaS_top_index, 0); - bot = n_numeric_field(L, luaS_bot_index, 0); - mid = n_numeric_field(L, luaS_mid_index, 0); - rep = n_numeric_field(L, luaS_rep_index, 0); - if (top != 0 || bot != 0 || mid != 0 || rep != 0) { - set_charinfo_tag(co, ext_tag); - set_charinfo_extensible(co, top, bot, mid, rep); - } else { - pdftex_warn - ("lua-loaded font %s char [U+%X] has an invalid extensible field!", - font_name(f), (int) i); - } - } - lua_pop(L, 1); - - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_horiz_variants_index); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { - int glyph, startconnect, endconnect, advance, extender; - extinfo *h; - set_charinfo_tag(co, ext_tag); - set_charinfo_hor_variants(co, NULL); - for (k = 1;; k++) { - lua_rawgeti(L, -1, k); - if (lua_istable(L, -1)) { - glyph = n_numeric_field(L, luaS_glyph_index, 0); - extender = n_numeric_field(L, luaS_extender_index, 0); - startconnect = n_numeric_field(L, luaS_start_index, 0); - endconnect = n_numeric_field(L, luaS_end_index, 0); - advance = n_numeric_field(L, luaS_advance_index, 0); - h = new_variant(glyph, startconnect, endconnect, advance, - extender); - add_charinfo_hor_variant(co, h); - lua_pop(L, 1); - } else { - lua_pop(L, 1); - break; - } - } - } - lua_pop(L, 1); - - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_vert_variants_index); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { - int glyph, startconnect, endconnect, advance, extender; - extinfo *h; - set_charinfo_tag(co, ext_tag); - set_charinfo_vert_variants(co, NULL); - for (k = 1;; k++) { - lua_rawgeti(L, -1, k); - if (lua_istable(L, -1)) { - glyph = n_numeric_field(L, luaS_glyph_index, 0); - extender = n_numeric_field(L, luaS_extender_index, 0); - startconnect = n_numeric_field(L, luaS_start_index, 0); - endconnect = n_numeric_field(L, luaS_end_index, 0); - advance = n_numeric_field(L, luaS_advance_index, 0); - h = new_variant(glyph, startconnect, endconnect, advance, - extender); - add_charinfo_vert_variant(co, h); - lua_pop(L, 1); - } else { - lua_pop(L, 1); - break; - } - } - } - lua_pop(L, 1); - - /* Here is a complete example: - ["mathkern"]={ - ["bottom_left"] ={ { ["height"]=420, ["kern"]=80 }, { ["height"]=520, ["kern"]=4 } }, - ["bottom_right"]={ { ["height"]=0, ["kern"]=48 } }, - ["top_left"] ={ { ["height"]=620, ["kern"]=0 }, { ["height"]=720, ["kern"]=-80 } }, - ["top_right"] ={ { ["height"]=676, ["kern"]=115 }, { ["height"]=776, ["kern"]=45 } }, - } - */ - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_mathkern_index); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { - lua_getfield(L, -1, "top_left"); - store_math_kerns(L, co, top_left_kern); - lua_pop(L, 1); - lua_getfield(L, -1, "top_right"); - store_math_kerns(L, co, top_right_kern); - lua_pop(L, 1); - lua_getfield(L, -1, "bottom_right"); - store_math_kerns(L, co, bottom_right_kern); - lua_pop(L, 1); - lua_getfield(L, -1, "bottom_left"); - store_math_kerns(L, co, bottom_left_kern); - lua_pop(L, 1); - } - lua_pop(L, 1); - - nk = count_hash_items(L, luaS_index(kerns)); - if (nk > 0) { - ckerns = xcalloc((nk + 1), sizeof(kerninfo)); - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(kerns)); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { /* there are kerns */ - ctr = 0; - lua_pushnil(L); - while (lua_next(L, -2) != 0) { - k = non_boundarychar; - if (lua_isnumber(L, -2)) { - k = lua_tonumber(L, -2); /* adjacent char */ - if (k < 0) - k = non_boundarychar; - } else if (lua_isstring(L, -2)) { - if (luaS_ptr_eq(lua_tostring(L, -2), right_boundary)) { - k = right_boundarychar; - if (!has_right_boundary(f)) - set_right_boundary(f, - get_charinfo(f, - right_boundarychar)); - } - } - j = lua_roundnumber(L, -1); /* movement */ - if (k != non_boundarychar) { - set_kern_item(ckerns[ctr], k, j); - ctr++; - } else { - pdftex_warn - ("lua-loaded font %s char [U+%X] has an invalid kern field!", - font_name(f), (int) i); - } - lua_pop(L, 1); - } - /* guard against empty tables */ - if (ctr > 0) { - set_kern_item(ckerns[ctr], end_kern, 0); - set_charinfo_kerns(co, ckerns); - } else { - pdftex_warn - ("lua-loaded font %s char [U+%X] has an invalid kerns field!", - font_name(f), (int) i); - } - } - lua_pop(L, 1); - } - - /* packet commands */ - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_commands_index); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { - lua_pushnil(L); /* first key */ - if (lua_next(L, -2) != 0) { - lua_pop(L, 2); - read_char_packets(L, (integer *) l_fonts, co, atsize); - } - } - lua_pop(L, 1); - - /* ligatures */ - nl = count_hash_items(L, luaS_index(ligatures)); - - if (nl > 0) { - cligs = xcalloc((nl + 1), sizeof(liginfo)); - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(ligatures)); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { /* do ligs */ - ctr = 0; - lua_pushnil(L); - while (lua_next(L, -2) != 0) { - k = non_boundarychar; - if (lua_isnumber(L, -2)) { - k = lua_tonumber(L, -2); /* adjacent char */ - if (k < 0) { - k = non_boundarychar; - } - } else if (lua_isstring(L, -2)) { - if (luaS_ptr_eq(lua_tostring(L, -2), right_boundary)) { - k = right_boundarychar; - if (!has_right_boundary(f)) - set_right_boundary(f, - get_charinfo(f, - right_boundarychar)); - } - } - r = -1; - if (lua_istable(L, -1)) { - r = n_numeric_field(L, luaS_char_index, -1); /* ligature */ - } - if (r != -1 && k != non_boundarychar) { - t = enum_field(L, "type", 0, ligature_type_strings); - set_ligature_item(cligs[ctr], (t * 2) + 1, k, r); - ctr++; - } else { - pdftex_warn - ("lua-loaded font %s char [U+%X] has an invalid ligature field!", - font_name(f), (int) i); - } - lua_pop(L, 1); /* iterator value */ - } - /* guard against empty tables */ - if (ctr > 0) { - set_ligature_item(cligs[ctr], 0, end_ligature, 0); - set_charinfo_ligatures(co, cligs); - } else { - pdftex_warn - ("lua-loaded font %s char [U+%X] has an invalid ligatures field!", - font_name(f), (int) i); - } - } - lua_pop(L, 1); /* ligatures table */ - } - } -} - - - -/* The caller has to fix the state of the lua stack when there is an error! */ - - -int font_from_lua(lua_State * L, int f) -{ - int i, n, r, t; - int s_top; /* lua stack top */ - int bc; /* first char index */ - int ec; /* last char index */ - char *s; - integer *l_fonts = NULL; - integer save_ref = 1; /* unneeded, really */ - - /* will we save a cache of the luat table? */ - s = string_field(L, "cache", "yes"); - if (strcmp(s, "yes") == 0) - save_ref = 1; - else if (strcmp(s, "no") == 0) - save_ref = -1; - else if (strcmp(s, "renew") == 0) - save_ref = 0; - free(s); - - /* the table is at stack index -1 */ - - if (luaS_width_index == 0) - init_font_string_pointers(L); - - s = string_field(L, "area", ""); - set_font_area(f, s); - s = string_field(L, "filename", NULL); - set_font_filename(f, s); - s = string_field(L, "encodingname", NULL); - set_font_encodingname(f, s); - - s = string_field(L, "name", NULL); - set_font_name(f, s); - s = string_field(L, "fullname", font_name(f)); - set_font_fullname(f, s); - - if (s == NULL) { - pdftex_fail("lua-loaded font [%d] has no name!", f); - return false; - } - - i = numeric_field(L, "designsize", 655360); - set_font_dsize(f, i); - i = numeric_field(L, "size", font_dsize(f)); - set_font_size(f, i); - i = numeric_field(L, "checksum", 0); - set_font_checksum(f, i); - i = numeric_field(L, "direction", 0); - set_font_natural_dir(f, i); - i = numeric_field(L, "encodingbytes", 0); - set_font_encodingbytes(f, i); - i = numeric_field(L, "tounicode", 0); - set_font_tounicode(f, i); - - i = numeric_field(L, "extend", 0); - if (i < -2000) - i = -2000; - if (i > 2000) - i = 2000; - if (i == 1000) - i = 0; - set_font_extend(f, i); - i = numeric_field(L, "slant", 0); - if (i < -1000) - i = -1000; - if (i > 1000) - i = 1000; - set_font_slant(f, i); - - i = numeric_field(L, "hyphenchar", get_default_hyphen_char()); - set_hyphen_char(f, i); - i = numeric_field(L, "skewchar", get_default_skew_char()); - set_skew_char(f, i); - i = boolean_field(L, "used", 0); - set_font_used(f, i); - - s = string_field(L, "attributes", NULL); - if (s != NULL && strlen(s) > 0) { - i = maketexstring(s); - set_pdf_font_attr(f, i); - } - - i = enum_field(L, "type", unknown_font_type, font_type_strings); - set_font_type(f, i); - i = enum_field(L, "format", unknown_format, font_format_strings); - set_font_format(f, i); - i = enum_field(L, "embedding", unknown_embedding, font_embedding_strings); - set_font_embedding(f, i); - if (font_encodingbytes(f) == 0 && - (font_format(f) == opentype_format - || font_format(f) == truetype_format)) { - set_font_encodingbytes(f, 2); - } - - /* now fetch the base fonts, if needed */ - n = count_hash_items(L, luaS_index(fonts)); - if (n > 0) { - const char *cs; - l_fonts = xmalloc((n + 2) * sizeof(integer)); - memset(l_fonts, 0, (n + 2) * sizeof(integer)); - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(fonts)); - lua_rawget(L, -2); - for (i = 1; i <= n; i++) { - lua_rawgeti(L, -1, i); - if (lua_istable(L, -1)) { - lua_getfield(L, -1, "id"); - if (lua_isnumber(L, -1)) { - l_fonts[i] = lua_tonumber(L, -1); - lua_pop(L, 2); /* pop id and entry */ - continue; - } - lua_pop(L, 1); /* pop id */ - }; - cs = NULL; - if (lua_istable(L, -1)) { - lua_getfield(L, -1, "name"); - if (lua_isstring(L, -1)) { - cs = lua_tostring(L, -1); - } - lua_pop(L, 1); /* pop name */ - } - if (cs != NULL) { - lua_getfield(L, -1, "size"); - t = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : -1000); - lua_pop(L, 1); - - /* TODO: the stack is messed up, otherwise this - * explicit resizing would not be needed - */ - s_top = lua_gettop(L); - if (strcmp(font_name(f), s) == 0) - l_fonts[i] = f; - else - l_fonts[i] = find_font_id(s, t); - lua_settop(L, s_top); - } else { - pdftex_fail("Invalid local font in font %s!\n", font_name(f)); - } - lua_pop(L, 1); /* pop list entry */ - } - lua_pop(L, 1); /* pop list entry */ - } else { - if (font_type(f) == virtual_font_type) { - pdftex_fail("Invalid local fonts in font %s!\n", font_name(f)); - } else { - l_fonts = xmalloc(3 * sizeof(integer)); - l_fonts[0] = 0; - l_fonts[1] = f; - l_fonts[2] = 0; - } - } - - /* parameters */ - read_lua_parameters(L, f); - read_lua_math_parameters(L, f); - read_lua_cidinfo(L, f); - - /* characters */ - lua_getfield(L, -1, "characters"); - if (lua_istable(L, -1)) { - /* find the array size values */ - ec = 0; - bc = -1; - lua_pushnil(L); /* first key */ - while (lua_next(L, -2) != 0) { - if (lua_isnumber(L, -2)) { - i = lua_tointeger(L, -2); - if (i >= 0) { - if (lua_istable(L, -1)) { - if (i > ec) - ec = i; - if (bc < 0) - bc = i; - if (bc >= 0 && i < bc) - bc = i; - } - } - } - lua_pop(L, 1); - } - - if (bc != -1) { - /* fprintf(stdout,"defined a font at %d with %d-%d\n",f,bc,ec); */ - set_font_bc(f, bc); - set_font_ec(f, ec); - lua_pushnil(L); /* first key */ - while (lua_next(L, -2) != 0) { - if (lua_isnumber(L, -2)) { - i = lua_tonumber(L, -2); - if (i >= 0) { - font_char_from_lua(L, f, i, l_fonts); - } - } else if (lua_isstring(L, -2)) { - const char *cs = lua_tostring(L, -2); - if (luaS_ptr_eq(cs, left_boundary)) { - font_char_from_lua(L, f, left_boundarychar, l_fonts); - } else if (luaS_ptr_eq(cs, right_boundary)) { - font_char_from_lua(L, f, right_boundarychar, l_fonts); - } - } - lua_pop(L, 1); - } - lua_pop(L, 1); - - /* handle font expansion last: the |copy_font| routine is called eventually, - and that needs to know |bc| and |ec|. */ - if (font_type(f) != virtual_font_type) { - int fstep = numeric_field(L, "step", 0); - if (fstep < 0) - fstep = 0; - if (fstep > 100) - fstep = 100; - if (fstep != 0) { - int fshrink = numeric_field(L, "shrink", 0); - int fstretch = numeric_field(L, "stretch", 0); - int fexpand = boolean_field(L, "auto_expand", 0); - if (fshrink < 0) - fshrink = 0; - if (fshrink > 500) - fshrink = 500; - fshrink -= (fshrink % fstep); - if (fshrink < 0) - fshrink = 0; - if (fstretch < 0) - fstretch = 0; - if (fstretch > 1000) - fstretch = 1000; - fstretch -= (fstretch % fstep); - if (fstretch < 0) - fstretch = 0; - set_expand_params(f, fexpand, fstretch, fshrink, fstep, 0); - } - } - - } else { /* jikes, no characters */ - pdftex_warn("lua-loaded font [%d] (%s) has no characters!", f, - font_name(f)); - } - - if (save_ref > 0) { - r = luaL_ref(Luas, LUA_REGISTRYINDEX); /* pops the table */ - set_font_cache_id(f, r); - } else { - lua_pop(Luas, 1); - set_font_cache_id(f, save_ref); - } - } else { /* jikes, no characters */ - pdftex_warn("lua-loaded font [%d] (%s) has no character table!", f, - font_name(f)); - } - - if (l_fonts != NULL) - free(l_fonts); - return true; -} - -/* ==================================================================== - * - * L I G A T U R I N G - * - * ==================================================================== */ - - -#define assert_disc(a) \ - assert(pre_break(a)!=null); /* expect head_node */ \ - assert(type(pre_break(a))==nesting_node); \ - assert((vlink_pre_break(a)==null && tlink_pre_break(a)==null) || tail_of_list(vlink_pre_break(a))==tlink_pre_break(a)); \ - assert(post_break(a)!=null); /* expect head_node */ \ - assert(type(post_break(a))==nesting_node); \ - assert((vlink_post_break(a)==null && tlink_post_break(a)==null) || tail_of_list(vlink_post_break(a))==tlink_post_break(a)); \ - assert(no_break(a)!=null); /* expect head_node */ \ - assert(type(no_break(a))==nesting_node); \ - assert((vlink_no_break(a)==null && tlink_no_break(a)==null) || tail_of_list(vlink_no_break(a))==tlink_no_break(a)); - -static void nesting_append(halfword nest, halfword newn) -{ - halfword tail = tlink(nest); - assert(alink(nest) == null); - assert(vlink(newn) == null); - assert(alink(newn) == null); - if (tail == null) { - assert(vlink(nest) == null); - couple_nodes(nest, newn); - } else { - assert(vlink(tail) == null); - assert(tail_of_list(vlink(nest)) == tail); - couple_nodes(tail, newn); - } - tlink(nest) = newn; -} - - -static void nesting_prepend(halfword nest, halfword newn) -{ - halfword head = vlink(nest); - assert(alink(nest) == null); - assert(vlink(newn) == null); - assert(alink(newn) == null); - couple_nodes(nest, newn); - if (head == null) { - assert(tlink(nest) == null); - tlink(nest) = newn; - } else { - assert(alink(head) == nest); - assert(tail_of_list(head) == tlink(nest)); - couple_nodes(newn, head); - } -} - - -static void nesting_prepend_list(halfword nest, halfword newn) -{ - halfword head = vlink(nest); - assert(alink(nest) == null); - assert(alink(newn) == null); - couple_nodes(nest, newn); - if (head == null) { - assert(tlink(nest) == null); - tlink(nest) = tail_of_list(newn); - } else { - halfword tail = tail_of_list(newn); - assert(alink(head) == nest); - assert(tail_of_list(head) == tlink(nest)); - couple_nodes(tail, head); - } -} - - -static int test_ligature(liginfo * lig, halfword left, halfword right) -{ - if (type(left) != glyph_node) - return 0; - assert(type(right) == glyph_node); - if (font(left) != font(right)) - return 0; - if (is_ghost(left) || is_ghost(right)) - return 0; - *lig = get_ligature(font(left), character(left), character(right)); - if (is_valid_ligature(*lig)) { - return 1; - } - return 0; -} - - -static int try_ligature(halfword * frst, halfword fwd) -{ - halfword cur = *frst; - liginfo lig; - if (test_ligature(&lig, cur, fwd)) { - int move_after = (lig_type(lig) & 0x0C) >> 2; - int keep_right = ((lig_type(lig) & 0x01) != 0); - int keep_left = ((lig_type(lig) & 0x02) != 0); - halfword newgl = raw_glyph_node(); - font(newgl) = font(cur); - character(newgl) = lig_replacement(lig); - set_is_ligature(newgl); - - /* below might not be correct in contrived border case. - * but we use it only for debugging, so ... */ - if (character(cur) < 0) { - set_is_leftboundary(newgl); - } - if (character(fwd) < 0) { - set_is_rightboundary(newgl); - } - if (character(cur) < 0) { - if (character(fwd) < 0) { - build_attribute_list(newgl); - } else { - add_node_attr_ref(node_attr(fwd)); - node_attr(newgl) = node_attr(fwd); - } - } else { - add_node_attr_ref(node_attr(cur)); - node_attr(newgl) = node_attr(cur); - } - - /* TODO/FIXME if this ligature is consists of another ligature - * we should add it's lig_ptr to the new glyphs lig_ptr (and - * cleanup the no longer needed node) LOW PRIORITY */ - /* left side */ - if (keep_left) { - halfword new_first = copy_node(cur); - lig_ptr(newgl) = new_first; - couple_nodes(cur, newgl); - if (move_after) { - move_after--; - cur = newgl; - } - } else { - halfword prev = alink(cur); - uncouple_node(cur); - lig_ptr(newgl) = cur; - assert(prev != null); - couple_nodes(prev, newgl); - cur = newgl; /* as cur has disappeared */ - } - /* right side */ - if (keep_right) { - halfword new_second = copy_node(fwd); - /* correct, because we _know_ lig_ptr points to _one_ node */ - couple_nodes(lig_ptr(newgl), new_second); - couple_nodes(newgl, fwd); - if (move_after) { - move_after--; - cur = fwd; - } - } else { - halfword next = vlink(fwd); - uncouple_node(fwd); - /* correct, because we _know_ lig_ptr points to _one_ node */ - couple_nodes(lig_ptr(newgl), fwd); - if (next != null) { - couple_nodes(newgl, next); - } - } - - /* check and return */ - /* assert(move_after==0); */ - *frst = cur; - return 1; - } - return 0; -} - - -/* there shouldn't be any ligatures here - we only add them at the end of - * xxx_break in a DISC-1 - DISC-2 situation and we stop processing DISC-1 - * (we continue with DISC-1's post_ and no_break */ -static halfword handle_lig_nest(halfword root, halfword cur) -{ - if (cur == null) - return root; - while (vlink(cur) != null) { - halfword fwd = vlink(cur); - if (type(cur) == glyph_node && type(fwd) == glyph_node && - font(cur) == font(fwd) && try_ligature(&cur, fwd)) - continue; - cur = vlink(cur); - assert(vlink(alink(cur)) == cur); - } - tlink(root) = cur; - return root; -} - - -static halfword handle_lig_word(halfword cur) -{ - halfword right = null; - - if (type(cur) == whatsit_node && subtype(cur) == cancel_boundary_node) { - halfword prev = alink(cur); - halfword fwd = vlink(cur); - /* uncouple_node(cur); *//* not needed, it is freed */ - flush_node(cur); - if (fwd == null) { - vlink(prev) = fwd; - return prev; - } - couple_nodes(prev, fwd); - if (type(fwd) != glyph_node) - return prev; - cur = fwd; - } else if (has_left_boundary(font(cur))) { - halfword prev = alink(cur); - halfword p = new_glyph(font(cur), left_boundarychar); - couple_nodes(prev, p); - couple_nodes(p, cur); - cur = p; - } - if (has_right_boundary(font(cur))) { - right = new_glyph(font(cur), right_boundarychar); - } - - while (1) { - /* A glyph followed by ... */ - if (type(cur) == glyph_node) { - halfword fwd = vlink(cur); - if (fwd == null) { /* last character of paragraph */ - if (right == null) - break; - /* --\par prohibits use of couple_nodes here */ - try_couple_nodes(cur, right); - right = null; - continue; - } - assert(alink(fwd) == cur); - if (type(fwd) == glyph_node) { /* GLYPH - GLYPH */ - if (font(cur) != font(fwd)) - break; - if (try_ligature(&cur, fwd)) - continue; - } else if (type(fwd) == disc_node) { /* GLYPH - DISC */ - - /* if a{bx}{}{y} and a+b=>B convert to {Bx}{}{ay} */ - halfword pre = vlink_pre_break(fwd); - halfword nob = vlink_no_break(fwd); - halfword next, tail; - liginfo lig; - assert_disc(fwd); - /* Check on: a{b?}{?}{?} and a+b=>B : {B?}{?}{a?} */ - /* Check on: a{?}{?}{b?} and a+b=>B : {a?}{?}{B?} */ - if ((pre != null && type(pre) == glyph_node - && test_ligature(&lig, cur, pre)) - || (nob != null && type(nob) == glyph_node - && test_ligature(&lig, cur, nob))) { - /* move cur from before disc, to skipped part */ - halfword prev = alink(cur); - assert(vlink(prev) == cur); - uncouple_node(cur); - couple_nodes(prev, fwd); - nesting_prepend(no_break(fwd), cur); - /* now ligature the pre_break */ - nesting_prepend(pre_break(fwd), copy_node(cur)); - /* As we have removed cur, we need to start again ... */ - cur = prev; - } - /* Check on: a{?}{?}{}b and a+b=>B : {a?}{?b}{B} */ - next = vlink(fwd); - if (nob == null && next != null && type(next) == glyph_node - && test_ligature(&lig, cur, next)) { - /* move cur from before disc to no_break part */ - halfword prev = alink(cur); - assert(alink(next) == fwd); - assert(vlink(prev) == cur); - uncouple_node(cur); - couple_nodes(prev, fwd); - couple_nodes(no_break(fwd), cur); /* we _know_ it's empty */ - /* now copy cur the pre_break */ - nesting_prepend(pre_break(fwd), copy_node(cur)); - /* move next from after disc to no_break part */ - tail = vlink(next); - uncouple_node(next); - try_couple_nodes(fwd, tail); - couple_nodes(cur, next); /* we _know_ this works */ - tlink(no_break(fwd)) = next; /* and make sure the list is correct */ - /* now copy next to the post_break */ - nesting_append(post_break(fwd), copy_node(next)); - /* As we have removed cur, we need to start again ... */ - cur = prev; - } - /* we are finished with the pre_break */ - handle_lig_nest(pre_break(fwd), vlink_pre_break(fwd)); - } else if (type(fwd) == whatsit_node - && subtype(fwd) == cancel_boundary_node) { - halfword next = vlink(fwd); - try_couple_nodes(cur, next); - flush_node(fwd); - if (right != null) { - flush_node(right); /* Shame, didn't need it */ - /* right = null; *//* no need, we're going to leave the loop anyway */ - } - break; - } else { /* fwd is something unknown */ - if (right == null) - break; - couple_nodes(cur, right); - couple_nodes(right, fwd); - right = null; - continue; - } - /* A discretionary followed by ... */ - } else if (type(cur) == disc_node) { - - assert_disc(cur); - /* If {?}{x}{?} or {?}{?}{y} then ... */ - if (vlink_no_break(cur) != null || vlink_post_break(cur) != null) { - halfword fwd; - liginfo lig; - if (vlink_post_break(cur) != null) - handle_lig_nest(post_break(cur), vlink_post_break(cur)); - if (vlink_no_break(cur) != null) - handle_lig_nest(no_break(cur), vlink_no_break(cur)); - while ((fwd = vlink(cur)) != null) { - halfword nob, pst, next; - if (type(fwd) != glyph_node) - break; - nob = tlink_no_break(cur); - pst = tlink_post_break(cur); - if ((nob == null || !test_ligature(&lig, nob, fwd)) && - (pst == null || !test_ligature(&lig, pst, fwd))) - break; - nesting_append(no_break(cur), copy_node(fwd)); - handle_lig_nest(no_break(cur), nob); - next = vlink(fwd); - uncouple_node(fwd); - try_couple_nodes(cur, next); - nesting_append(post_break(cur), fwd); - handle_lig_nest(post_break(cur), pst); - } - if (fwd != null && type(fwd) == disc_node) { - halfword next = vlink(fwd); - if (vlink_no_break(fwd) == null && - vlink_post_break(fwd) == null && - next != null && - type(next) == glyph_node && - ((tlink_post_break(cur) != null && - test_ligature(&lig, tlink_post_break(cur), next)) || - (tlink_no_break(cur) != null && - test_ligature(&lig, tlink_no_break(cur), next)))) { - /* Building an init_disc followed by a select_disc - * {a-}{b}{AB} {-}{}{} 'c' - */ - halfword last = vlink(next), tail; - uncouple_node(next); - try_couple_nodes(fwd, last); - /* {a-}{b}{AB} {-}{c}{} */ - nesting_append(post_break(fwd), copy_node(next)); - /* {a-}{b}{AB} {-}{c}{-} */ - if (vlink_no_break(cur) != null) { - nesting_prepend(no_break(fwd), - copy_node(vlink_pre_break(fwd))); - } - /* {a-}{b}{AB} {b-}{c}{-} */ - if (vlink_post_break(cur) != null) - nesting_prepend_list(pre_break(fwd), - copy_node_list(vlink_post_break - (cur))); - /* {a-}{b}{AB} {b-}{c}{AB-} */ - if (vlink_no_break(cur) != null) { - nesting_prepend_list(no_break(fwd), - copy_node_list(vlink_no_break - (cur))); - } - /* {a-}{b}{ABC} {b-}{c}{AB-} */ - tail = tlink_no_break(cur); - nesting_append(no_break(cur), copy_node(next)); - handle_lig_nest(no_break(cur), tail); - /* {a-}{BC}{ABC} {b-}{c}{AB-} */ - tail = tlink_post_break(cur); - nesting_append(post_break(cur), next); - handle_lig_nest(post_break(cur), tail); - /* and set the subtypes */ - subtype(cur) = init_disc; - subtype(fwd) = select_disc; - } - } - } - - } else { /* NO GLYPH NOR DISC */ - /* fprintf(stdout,"This is a %d node\n",type(cur)); */ - /* assert(0); *//* TODO howcome there can be a glue here? */ - return cur; - } - /* step-to-next-node */ - { - halfword prev = cur; - /* --\par allows vlink(cur) to be null */ - cur = vlink(cur); - if (cur != null) { - assert(alink(cur) == prev); - } - } - } - - return cur; -} - -/* return = new tail, head should be a dummy */ - -halfword handle_ligaturing(halfword head, halfword tail) -{ - halfword save_tail; /* trick to allow explicit node==null tests */ - halfword cur, prev; - - if (vlink(head) == null) - return tail; - save_tail = vlink(tail); - vlink(tail) = null; - - /* if (fix_node_lists) */ - fix_node_list(head); - - prev = head; - cur = vlink(prev); - - while (cur != null) { - if (type(cur) == glyph_node || - (type(cur) == whatsit_node - && subtype(cur) == cancel_boundary_node)) { - cur = handle_lig_word(cur); - } - prev = cur; - cur = vlink(cur); - assert(cur == null || alink(cur) == prev); - } - if (prev == null) - prev = tail; - - if (valid_node(save_tail)) { - try_couple_nodes(prev, save_tail); - } - return prev; -} - - -/* ==================================================================== - * - * K E R N I N G - * - * ==================================================================== */ - -static void add_kern_before(halfword left, halfword right) -{ - if ((!is_rightghost(right)) && - font(left) == font(right) && has_kern(font(left), character(left))) { - int k = raw_get_kern(font(left), character(left), character(right)); - if (k != 0) { - halfword kern = new_kern(k); - halfword prev = alink(right); - assert(vlink(prev) == right); - couple_nodes(prev, kern); - couple_nodes(kern, right); - } - } -} - - -static void add_kern_after(halfword left, halfword right, halfword aft) -{ - if ((!is_rightghost(right)) && - font(left) == font(right) && has_kern(font(left), character(left))) { - int k = raw_get_kern(font(left), character(left), character(right)); - if (k != 0) { - halfword kern = new_kern(k); - halfword next = vlink(aft); - assert(next == null || alink(next) == aft); - couple_nodes(aft, kern); - try_couple_nodes(kern, next); - } - } -} - - -static void -do_handle_kerning(halfword root, halfword init_left, halfword init_right) -{ - halfword cur = vlink(root); - halfword left = null; - assert(init_left == null || type(init_left) == glyph_node); - assert(init_right == null || type(init_right) == glyph_node); - if (cur == null) { - if (init_left != null && init_right != null) { - add_kern_after(init_left, init_right, root); - tlink(root) = vlink(root); - } - return; - } - if (type(cur) == glyph_node) { - set_is_glyph(cur); - if (init_left != null) - add_kern_before(init_left, cur); - left = cur; - } - while ((cur = vlink(cur)) != null) { - if (type(cur) == glyph_node) { - set_is_glyph(cur); - if (left != null) { - add_kern_before(left, cur); - if (character(left) < 0 || is_ghost(left)) { - halfword prev = alink(left); - couple_nodes(prev, cur); - flush_node(left); - } - } - left = cur; - } else { - if (type(cur) == disc_node) { - halfword right = - type(vlink(cur)) == glyph_node ? vlink(cur) : null; - do_handle_kerning(pre_break(cur), left, null); - do_handle_kerning(post_break(cur), null, right); - if (vlink_post_break(cur) != null) - tlink_post_break(cur) = tail_of_list(vlink_post_break(cur)); - do_handle_kerning(no_break(cur), left, right); - if (vlink_no_break(cur) != null) - tlink_no_break(cur) = tail_of_list(vlink_no_break(cur)); /* needed? */ - } - if (left != null) { - if (character(left) < 0 || is_ghost(left)) { - halfword prev = alink(left); - couple_nodes(prev, cur); - flush_node(left); - } - left = null; - } - } - } - if (left != null) { - if (init_right != null) - add_kern_after(left, init_right, left); - if (character(left) < 0 || is_ghost(left)) { - halfword prev = alink(left); - halfword next = vlink(left); - if (next != null) { - couple_nodes(prev, next); - tlink(root) = next; - assert(vlink(next) == null); - assert(type(next) == kern_node); - } else if (prev != root) { - vlink(prev) = null; - tlink(root) = prev; - } else { - vlink(root) = null; - tlink(root) = null; - } - flush_node(left); - } - } -} - - -halfword handle_kerning(halfword head, halfword tail) -{ - halfword save_link; - save_link = vlink(tail); - vlink(tail) = null; - tlink(head) = tail; - do_handle_kerning(head, null, null); - tail = tlink(head); - if (valid_node(save_link)) { - try_couple_nodes(tail, save_link); - } - return tail; -} - -/* ==================================================================== - * - * L I G A T U R I N G and K E R N I N G : L U A - I N T E R F A C E - * - * ==================================================================== */ - -static halfword -run_lua_ligkern_callback(halfword head, halfword tail, int callback_id) -{ - lua_State *L = Luas; - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); - return tail; - } - nodelist_to_lua(L, head); - nodelist_to_lua(L, tail); - if (lua_pcall(L, 2, 1, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); - lua_error(L); - return tail; - } - tail = nodelist_from_lua(L); - if (fix_node_lists) - fix_node_list(head); - lua_pop(L, 2); - return tail; -} - - -halfword new_ligkern(halfword head, halfword tail) -{ - int callback_id = 0; - - assert(head != null); - if (vlink(head) == null) - return tail; - - callback_id = callback_defined(ligaturing_callback); - if (callback_id > 0) { - tail = run_lua_ligkern_callback(head, tail, callback_id); - if (tail == null) - tail = tail_of_list(head); - } else if (callback_id == 0) { - tail = handle_ligaturing(head, tail); - } - - callback_id = callback_defined(kerning_callback); - if (callback_id > 0) { - tail = run_lua_ligkern_callback(head, tail, callback_id); - if (tail == null) - tail = tail_of_list(head); - } else if (callback_id == 0) { - halfword nest = new_node(nesting_node, 1); - halfword cur = vlink(head); - halfword aft = vlink(tail); - couple_nodes(nest, cur); - tlink(nest) = tail; - vlink(tail) = null; - do_handle_kerning(nest, null, null); - couple_nodes(head, vlink(nest)); - tail = tlink(nest); - try_couple_nodes(tail, aft); - flush_node(nest); - } - return tail; -} diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.w b/Build/source/texk/web2c/luatexdir/font/luafont.w new file mode 100644 index 00000000000..bde66530fb4 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/luafont.w @@ -0,0 +1,2400 @@ +% luafont.w +% +% Copyright 2006-2010 Taco Hoekwater +% +% This file is part of LuaTeX. +% +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. +% +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. +% +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: luafont.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/luafont.w $"; + +#include "ptexlib.h" +#include "lua/luatex-api.h" + +#define noVERBOSE + +const char *font_type_strings[] = { "unknown", "virtual", "real", NULL }; +const char *font_format_strings[] = + { "unknown", "type1", "type3", "truetype", "opentype", NULL }; +const char *font_embedding_strings[] = + { "unknown", "no", "subset", "full", NULL }; + +const char *ligature_type_strings[] = + { "=:", "=:|", "|=:", "|=:|", "", "=:|>", "|=:>", "|=:|>", "", "", "", + "|=:|>>", NULL +}; + +const char *MATH_param_names[] = { + "nil", + "ScriptPercentScaleDown", + "ScriptScriptPercentScaleDown", + "DelimitedSubFormulaMinHeight", + "DisplayOperatorMinHeight", + "MathLeading", + "AxisHeight", + "AccentBaseHeight", + "FlattenedAccentBaseHeight", + "SubscriptShiftDown", + "SubscriptTopMax", + "SubscriptBaselineDropMin", + "SuperscriptShiftUp", + "SuperscriptShiftUpCramped", + "SuperscriptBottomMin", + "SuperscriptBaselineDropMax", + "SubSuperscriptGapMin", + "SuperscriptBottomMaxWithSubscript", + "SpaceAfterScript", + "UpperLimitGapMin", + "UpperLimitBaselineRiseMin", + "LowerLimitGapMin", + "LowerLimitBaselineDropMin", + "StackTopShiftUp", + "StackTopDisplayStyleShiftUp", + "StackBottomShiftDown", + "StackBottomDisplayStyleShiftDown", + "StackGapMin", + "StackDisplayStyleGapMin", + "StretchStackTopShiftUp", + "StretchStackBottomShiftDown", + "StretchStackGapAboveMin", + "StretchStackGapBelowMin", + "FractionNumeratorShiftUp", + "FractionNumeratorDisplayStyleShiftUp", + "FractionDenominatorShiftDown", + "FractionDenominatorDisplayStyleShiftDown", + "FractionNumeratorGapMin", + "FractionNumeratorDisplayStyleGapMin", + "FractionRuleThickness", + "FractionDenominatorGapMin", + "FractionDenominatorDisplayStyleGapMin", + "SkewedFractionHorizontalGap", + "SkewedFractionVerticalGap", + "OverbarVerticalGap", + "OverbarRuleThickness", + "OverbarExtraAscender", + "UnderbarVerticalGap", + "UnderbarRuleThickness", + "UnderbarExtraDescender", + "RadicalVerticalGap", + "RadicalDisplayStyleVerticalGap", + "RadicalRuleThickness", + "RadicalExtraAscender", + "RadicalKernBeforeDegree", + "RadicalKernAfterDegree", + "RadicalDegreeBottomRaisePercent", + "MinConnectorOverlap", + "SubscriptShiftDownWithSuperscript", + "FractionDelimiterSize", + "FractionDelimiterDisplayStyleSize", + NULL, +}; + +static void dump_intfield(lua_State * L, const char *n, int c) +{ + lua_pushstring(L, n); + lua_pushnumber(L, c); + lua_rawset(L, -3); +} + + +void dump_math_kerns(lua_State * L, charinfo * co, int l, int id) +{ + int i; + for (i = 0; i < l; i++) { + lua_newtable(L); + /* *INDENT-OFF* */ + if (id==top_left_kern) { + dump_intfield(L, "height", co->top_left_math_kern_array[(2*i)]); + dump_intfield(L, "kern", co->top_left_math_kern_array[(2*i)+1]); + } else if (id==top_right_kern) { + dump_intfield(L, "height", co->top_right_math_kern_array[(2*i)]); + dump_intfield(L, "kern", co->top_right_math_kern_array[(2*i)+1]); + } else if (id==bottom_right_kern) { + dump_intfield(L, "height", co->bottom_right_math_kern_array[(2*i)]); + dump_intfield(L, "kern", co->bottom_right_math_kern_array[(2*i)+1]); + } else if (id==bottom_left_kern) { + dump_intfield(L, "height", co->bottom_left_math_kern_array[(2*i)]); + dump_intfield(L, "kern", co->bottom_left_math_kern_array[(2*i)+1]); + } + /* *INDENT-ON* */ + lua_rawseti(L, -2, (i + 1)); + } +} + + +void font_char_to_lua(lua_State * L, internal_font_number f, charinfo * co) +{ + int i, j; + liginfo *l; + kerninfo *ki; + + lua_createtable(L, 0, 10); + + lua_pushstring(L, "width"); + lua_pushnumber(L, get_charinfo_width(co)); + lua_rawset(L, -3); + + lua_pushstring(L, "height"); + lua_pushnumber(L, get_charinfo_height(co)); + lua_rawset(L, -3); + + lua_pushstring(L, "depth"); + lua_pushnumber(L, get_charinfo_depth(co)); + lua_rawset(L, -3); + + lua_pushstring(L, "italic"); + lua_pushnumber(L, get_charinfo_italic(co)); + lua_rawset(L, -3); + + lua_pushstring(L, "top_accent"); + lua_pushnumber(L, get_charinfo_top_accent(co)); + lua_rawset(L, -3); + + lua_pushstring(L, "bot_accent"); + lua_pushnumber(L, get_charinfo_bot_accent(co)); + lua_rawset(L, -3); + + + if (get_charinfo_ef(co) != 0) { + lua_pushstring(L, "expansion_factor"); + lua_pushnumber(L, get_charinfo_ef(co)); + lua_rawset(L, -3); + } + + if (get_charinfo_lp(co) != 0) { + lua_pushstring(L, "left_protruding"); + lua_pushnumber(L, get_charinfo_lp(co)); + lua_rawset(L, -3); + } + + if (get_charinfo_lp(co) != 0) { + lua_pushstring(L, "right_protruding"); + lua_pushnumber(L, get_charinfo_rp(co)); + lua_rawset(L, -3); + } + + + if (font_encodingbytes(f) == 2) { + lua_pushstring(L, "index"); + lua_pushnumber(L, get_charinfo_index(co)); + lua_rawset(L, -3); + } + + if (get_charinfo_name(co) != NULL) { + lua_pushstring(L, "name"); + lua_pushstring(L, get_charinfo_name(co)); + lua_rawset(L, -3); + } + + if (get_charinfo_tounicode(co) != NULL) { + lua_pushstring(L, "tounicode"); + lua_pushstring(L, get_charinfo_tounicode(co)); + lua_rawset(L, -3); + } + + if (get_charinfo_tag(co) == list_tag) { + lua_pushstring(L, "next"); + lua_pushnumber(L, get_charinfo_remainder(co)); + lua_rawset(L, -3); + } + + lua_pushstring(L, "used"); + lua_pushboolean(L, (get_charinfo_used(co) ? true : false)); + lua_rawset(L, -3); + + if (get_charinfo_tag(co) == ext_tag) { + extinfo *h; + h = get_charinfo_hor_variants(co); + if (h != NULL) { + int i = 1; + lua_newtable(L); + while (h != NULL) { + lua_createtable(L, 0, 5); + dump_intfield(L, "glyph", h->glyph); + dump_intfield(L, "extender", h->extender); + dump_intfield(L, "start", h->start_overlap); + dump_intfield(L, "end", h->end_overlap); + dump_intfield(L, "advance", h->advance); + lua_rawseti(L, -2, i); + i++; + h = h->next; + } + lua_setfield(L, -2, "horiz_variants"); + } + h = get_charinfo_vert_variants(co); + if (h != NULL) { + int i = 1; + lua_newtable(L); + while (h != NULL) { + lua_createtable(L, 0, 5); + dump_intfield(L, "glyph", h->glyph); + dump_intfield(L, "extender", h->extender); + dump_intfield(L, "start", h->start_overlap); + dump_intfield(L, "end", h->end_overlap); + dump_intfield(L, "advance", h->advance); + lua_rawseti(L, -2, i); + i++; + h = h->next; + } + lua_setfield(L, -2, "vert_variants"); + } + } + ki = get_charinfo_kerns(co); + if (ki != NULL) { + lua_pushstring(L, "kerns"); + lua_createtable(L, 10, 1); + for (i = 0; !kern_end(ki[i]); i++) { + if (kern_char(ki[i]) == right_boundarychar) { + lua_pushstring(L, "right_boundary"); + } else { + lua_pushnumber(L, kern_char(ki[i])); + } + lua_pushnumber(L, kern_kern(ki[i])); + lua_rawset(L, -3); + } + lua_rawset(L, -3); + } + l = get_charinfo_ligatures(co); + if (l != NULL) { + lua_pushstring(L, "ligatures"); + lua_createtable(L, 10, 1); + for (i = 0; !lig_end(l[i]); i++) { + if (lig_char(l[i]) == right_boundarychar) { + lua_pushstring(L, "right_boundary"); + } else { + lua_pushnumber(L, lig_char(l[i])); + } + lua_createtable(L, 0, 2); + lua_pushstring(L, "type"); + lua_pushnumber(L, lig_type(l[i])); + lua_rawset(L, -3); + lua_pushstring(L, "char"); + lua_pushnumber(L, lig_replacement(l[i])); + lua_rawset(L, -3); + lua_rawset(L, -3); + } + lua_rawset(L, -3); + } + + lua_newtable(L); + + i = get_charinfo_math_kerns(co, top_right_kern); + j = 0; + if (i > 0) { + j++; + lua_newtable(L); + dump_math_kerns(L, co, i, top_right_kern); + lua_setfield(L, -2, "top_right"); + } + i = get_charinfo_math_kerns(co, top_left_kern); + if (i > 0) { + j++; + lua_newtable(L); + dump_math_kerns(L, co, i, top_left_kern); + lua_setfield(L, -2, "top_left"); + } + i = get_charinfo_math_kerns(co, bottom_right_kern); + if (i > 0) { + j++; + lua_newtable(L); + dump_math_kerns(L, co, i, bottom_right_kern); + lua_setfield(L, -2, "bottom_right"); + } + i = get_charinfo_math_kerns(co, bottom_left_kern); + if (i > 0) { + j++; + lua_newtable(L); + dump_math_kerns(L, co, i, bottom_left_kern); + lua_setfield(L, -2, "bottom_left"); + } + if (j > 0) + lua_setfield(L, -2, "mathkern"); + else + lua_pop(L, 1); + +} + +static void write_lua_parameters(lua_State * L, int f) +{ + int k; + lua_newtable(L); + for (k = 1; k <= font_params(f); k++) { + lua_pushnumber(L, font_param(f, k)); + switch (k) { + case slant_code: + lua_setfield(L, -2, "slant"); + break; + case space_code: + lua_setfield(L, -2, "space"); + break; + case space_stretch_code: + lua_setfield(L, -2, "space_stretch"); + break; + case space_shrink_code: + lua_setfield(L, -2, "space_shrink"); + break; + case x_height_code: + lua_setfield(L, -2, "x_height"); + break; + case quad_code: + lua_setfield(L, -2, "quad"); + break; + case extra_space_code: + lua_setfield(L, -2, "extra_space"); + break; + default: + lua_rawseti(L, -2, k); + } + } + lua_setfield(L, -2, "parameters"); +} + +@ @c +static void write_lua_math_parameters(lua_State * L, int f) +{ + int k; + lua_newtable(L); + for (k = 1; k < font_math_params(f); k++) { + lua_pushnumber(L, font_math_param(f, k)); + if (k <= MATH_param_max) { + lua_setfield(L, -2, MATH_param_names[k]); + } else { + lua_rawseti(L, -2, k); + } + } + lua_setfield(L, -2, "MathConstants"); +} + + + +int font_to_lua(lua_State * L, int f) +{ + int k; + charinfo *co; + if (font_cache_id(f) > 0) { + /* fetch the table from the registry if it was + saved there by |font_from_lua()| */ + lua_rawgeti(L, LUA_REGISTRYINDEX, font_cache_id(f)); + /* fontdimens can be changed from tex code */ + write_lua_parameters(L, f); + return 1; + } + + lua_newtable(L); + lua_pushstring(L, font_name(f)); + lua_setfield(L, -2, "name"); + if (font_area(f) != NULL) { + lua_pushstring(L, font_area(f)); + lua_setfield(L, -2, "area"); + } + if (font_filename(f) != NULL) { + lua_pushstring(L, font_filename(f)); + lua_setfield(L, -2, "filename"); + } + if (font_fullname(f) != NULL) { + lua_pushstring(L, font_fullname(f)); + lua_setfield(L, -2, "fullname"); + } + if (font_psname(f) != NULL) { + lua_pushstring(L, font_psname(f)); + lua_setfield(L, -2, "psname"); + } + if (font_encodingname(f) != NULL) { + lua_pushstring(L, font_encodingname(f)); + lua_setfield(L, -2, "encodingname"); + } + + lua_pushboolean(L, (font_used(f) ? true : false)); + lua_setfield(L, -2, "used"); + + + lua_pushstring(L, font_type_strings[font_type(f)]); + lua_setfield(L, -2, "type"); + lua_pushstring(L, font_format_strings[font_format(f)]); + lua_setfield(L, -2, "format"); + lua_pushstring(L, font_embedding_strings[font_embedding(f)]); + lua_setfield(L, -2, "embedding"); + + lua_pushnumber(L, font_units_per_em(f)); + lua_setfield(L, -2, "units_per_em"); + lua_pushnumber(L, font_size(f)); + lua_setfield(L, -2, "size"); + lua_pushnumber(L, font_dsize(f)); + lua_setfield(L, -2, "designsize"); + lua_pushnumber(L, font_checksum(f)); + lua_setfield(L, -2, "checksum"); + lua_pushnumber(L, font_slant(f)); + lua_setfield(L, -2, "slant"); + lua_pushnumber(L, font_extend(f)); + lua_setfield(L, -2, "extend"); + lua_pushnumber(L, font_natural_dir(f)); + lua_setfield(L, -2, "direction"); + lua_pushnumber(L, font_encodingbytes(f)); + lua_setfield(L, -2, "encodingbytes"); + lua_pushnumber(L, font_tounicode(f)); + lua_setfield(L, -2, "tounicode"); + + /* pdf parameters */ + /* skip the first four for now, that are very much interal */ +#if 0 + if (pdf_font_num(f) != 0) { + lua_pushnumber(L,pdf_font_num(f)); + lua_setfield(L,-2,"pdf_num"); + } + if (pdf_font_blink(f) != 0) { + lua_pushnumber(L,pdf_font_blink(f)); + lua_setfield(L,-2,"pdf_blink"); + } + if (pdf_font_elink(f) != 0) { + lua_pushnumber(L,pdf_font_elink(f)); + lua_setfield(L,-2,"pdf_elink"); + } +#endif + /* the next one is read only */ + if (font_expand_ratio(f) != 0) { + lua_pushnumber(L, font_expand_ratio(f)); + lua_setfield(L, -2, "expand_ratio"); + } + if (font_shrink(f) != 0) { + lua_pushnumber(L, font_shrink(f)); + lua_setfield(L, -2, "shrink"); + } + if (font_stretch(f) != 0) { + lua_pushnumber(L, font_stretch(f)); + lua_setfield(L, -2, "stretch"); + } + if (font_step(f) != 0) { + lua_pushnumber(L, font_step(f)); + lua_setfield(L, -2, "step"); + } + if (font_auto_expand(f) != 0) { + lua_pushboolean(L, font_auto_expand(f)); + lua_setfield(L, -2, "auto_expand"); + } + if (pdf_font_attr(f) != 0) { + char *s = makecstring(pdf_font_attr(f)); + lua_pushstring(L, s); + free(s); + lua_setfield(L, -2, "attributes"); + } + + /* params */ + write_lua_parameters(L, f); + write_lua_math_parameters(L, f); + + /* chars */ + lua_createtable(L, font_tables[f]->charinfo_size, 0); /* all characters */ + + if (has_left_boundary(f)) { + co = get_charinfo(f, left_boundarychar); + font_char_to_lua(L, f, co); + lua_setfield(L, -2, "left_boundary"); + } + if (has_right_boundary(f)) { + co = get_charinfo(f, right_boundarychar); + font_char_to_lua(L, f, co); + lua_setfield(L, -2, "right_boundary"); + } + + for (k = font_bc(f); k <= font_ec(f); k++) { + if (quick_char_exists(f, k)) { + lua_pushnumber(L, k); + co = get_charinfo(f, k); + font_char_to_lua(L, f, co); + lua_rawset(L, -3); + } + } + lua_setfield(L, -2, "characters"); + + if (font_cache_id(f) == 0) { /* renew */ + int r; + lua_pushvalue(L, -1); + r = luaL_ref(L, LUA_REGISTRYINDEX); /* pops the table */ + set_font_cache_id(f, r); + } + return 1; +} + +static int count_hash_items(lua_State * L, int name_index) +{ + int n = -1; + lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); + lua_rawget(L, -2); + if (!lua_isnil(L, -1)) { + if (lua_istable(L, -1)) { + n = 0; + /* now find the number */ + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + n++; + lua_pop(L, 1); + } + } + } + lua_pop(L, 1); + return n; +} + +@ @c +#define streq(a,b) (strcmp(a,b)==0) + +#define append_packet(k) { cpackets[np++] = (eight_bits)(k); } + +#define do_store_four(l) { \ + append_packet((l&0xFF000000)>>24); \ + append_packet((l&0x00FF0000)>>16); \ + append_packet((l&0x0000FF00)>>8); \ + append_packet((l&0x000000FF)); } + +/* +*/ + +#define lua_roundnumber(a,b) (int)floor((double)lua_tonumber(L,-1)+0.5) + +static int numeric_field(lua_State * L, const char *name, int dflt) +{ + int i = dflt; + lua_pushstring(L, name); + lua_rawget(L, -2); + if (lua_isnumber(L, -1)) { + i = lua_roundnumber(L, -1); + } + lua_pop(L, 1); + return i; +} + +static int n_numeric_field(lua_State * L, int name_index, int dflt) +{ + register int i = dflt; + lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */ + lua_rawget(L, -2); + if (lua_type(L, -1) == LUA_TNUMBER) { + i = lua_roundnumber(L, -1); + } + lua_pop(L, 1); + return i; +} + + +static int enum_field(lua_State * L, const char *name, int dflt, + const char **values) +{ + int k; + const char *s; + int i = dflt; + lua_pushstring(L, name); + lua_rawget(L, -2); + if (lua_isnumber(L, -1)) { + lua_number2int(i, lua_tonumber(L, -1)); + } else if (lua_isstring(L, -1)) { + s = lua_tostring(L, -1); + k = 0; + while (values[k] != NULL) { + if (strcmp(values[k], s) == 0) { + i = k; + break; + } + k++; + } + } + lua_pop(L, 1); + return i; +} + +static int boolean_field(lua_State * L, const char *name, int dflt) +{ + int i = dflt; + lua_pushstring(L, name); + lua_rawget(L, -2); + if (lua_isboolean(L, -1)) { + i = lua_toboolean(L, -1); + } + lua_pop(L, 1); + return i; +} + +static int n_boolean_field(lua_State * L, int name_index, int dflt) +{ + int i = dflt; + lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */ + lua_rawget(L, -2); + if (lua_isboolean(L, -1)) { + i = lua_toboolean(L, -1); + } + lua_pop(L, 1); + return i; +} + + +static char *string_field(lua_State * L, const char *name, const char *dflt) +{ + char *i; + lua_pushstring(L, name); + lua_rawget(L, -2); + if (lua_isstring(L, -1)) { + i = xstrdup(lua_tostring(L, -1)); + } else if (dflt == NULL) { + i = NULL; + } else { + i = xstrdup(dflt); + } + lua_pop(L, 1); + return i; +} + +static char *n_string_field(lua_State * L, int name_index, char *dflt) +{ + char *i; + lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */ + lua_rawget(L, -2); + if (lua_isstring(L, -1)) { + i = xstrdup(lua_tostring(L, -1)); + } else if (dflt == NULL) { + i = NULL; + } else { + i = xstrdup(dflt); + } + lua_pop(L, 1); + return i; +} + +#define init_luaS_index(a) do { \ + lua_pushliteral(L,#a); \ + luaS_##a##_ptr = lua_tostring(L,-1); \ + luaS_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \ + } while (0) + +#define make_luaS_index(a) \ + static int luaS_##a##_index = 0; \ + static const char * luaS_##a##_ptr = NULL + +#define luaS_index(a) luaS_##a##_index + +#define luaS_ptr_eq(a,b) (a==luaS_##b##_ptr) + +make_luaS_index(width); +make_luaS_index(height); +make_luaS_index(depth); +make_luaS_index(italic); +make_luaS_index(top_accent); +make_luaS_index(bot_accent); +make_luaS_index(index); +make_luaS_index(left_protruding); +make_luaS_index(right_protruding); +make_luaS_index(expansion_factor); +make_luaS_index(top); +make_luaS_index(bot); +make_luaS_index(rep); +make_luaS_index(mid); +make_luaS_index(next); +make_luaS_index(used); +make_luaS_index(name); +make_luaS_index(tounicode); +make_luaS_index(font); +make_luaS_index(char); +make_luaS_index(slot); +make_luaS_index(comment); +make_luaS_index(push); +make_luaS_index(pop); +make_luaS_index(rule); +make_luaS_index(right); +make_luaS_index(node); +make_luaS_index(down); +make_luaS_index(special); +make_luaS_index(image); +make_luaS_index(slant); +make_luaS_index(space); +make_luaS_index(space_stretch); +make_luaS_index(space_shrink); +make_luaS_index(x_height); +make_luaS_index(quad); +make_luaS_index(extra_space); +make_luaS_index(left_boundary); +make_luaS_index(right_boundary); +make_luaS_index(kerns); +make_luaS_index(ligatures); +make_luaS_index(fonts); +make_luaS_index(extender); +make_luaS_index(start); +make_luaS_index(end); +make_luaS_index(advance); +make_luaS_index(glyph); +make_luaS_index(extensible); +make_luaS_index(horiz_variants); +make_luaS_index(vert_variants); +make_luaS_index(mathkern); +make_luaS_index(commands); + +void init_font_string_pointers(lua_State * L) +{ + init_luaS_index(width); + init_luaS_index(height); + init_luaS_index(depth); + init_luaS_index(italic); + init_luaS_index(top_accent); + init_luaS_index(bot_accent); + init_luaS_index(index); + init_luaS_index(left_protruding); + init_luaS_index(right_protruding); + init_luaS_index(expansion_factor); + init_luaS_index(top); + init_luaS_index(bot); + init_luaS_index(rep); + init_luaS_index(mid); + init_luaS_index(next); + init_luaS_index(used); + init_luaS_index(name); + init_luaS_index(tounicode); + init_luaS_index(font); + init_luaS_index(char); + init_luaS_index(slot); + init_luaS_index(comment); + init_luaS_index(push); + init_luaS_index(pop); + init_luaS_index(rule); + init_luaS_index(right); + init_luaS_index(node); + init_luaS_index(down); + init_luaS_index(special); + init_luaS_index(image); + + init_luaS_index(slant); + init_luaS_index(space); + init_luaS_index(space_stretch); + init_luaS_index(space_shrink); + init_luaS_index(x_height); + init_luaS_index(quad); + init_luaS_index(extra_space); + + init_luaS_index(left_boundary); + init_luaS_index(right_boundary); + init_luaS_index(kerns); + init_luaS_index(ligatures); + init_luaS_index(fonts); + + init_luaS_index(extender); + init_luaS_index(start); + init_luaS_index(end); + init_luaS_index(advance); + init_luaS_index(glyph); + + init_luaS_index(extensible); + init_luaS_index(horiz_variants); + init_luaS_index(vert_variants); + init_luaS_index(mathkern); + init_luaS_index(commands); + +} + +static int count_char_packet_bytes(lua_State * L) +{ + register int i; + register int l = 0; + int ff = 0; + for (i = 1; i <= (int) lua_objlen(L, -1); i++) { + lua_rawgeti(L, -1, i); + if (lua_istable(L, -1)) { + lua_rawgeti(L, -1, 1); + if (lua_isstring(L, -1)) { + const char *s = lua_tostring(L, -1); + if (luaS_ptr_eq(s, font)) { + l += 5; + ff = 1; + } else if (luaS_ptr_eq(s, char)) { + if (ff == 0) { + l += 5; + } + l += 5; + ff = 1; + } else if (luaS_ptr_eq(s, slot)) { + l += 10; + ff = 1; + } else if (luaS_ptr_eq(s, comment)) {; + } else if (luaS_ptr_eq(s, push) || luaS_ptr_eq(s, pop)) { + l++; + } else if (luaS_ptr_eq(s, rule)) { + l += 9; + } else if (luaS_ptr_eq(s, right) || + luaS_ptr_eq(s, node) || luaS_ptr_eq(s, down)) { + l += 5; + } else if (luaS_ptr_eq(s, special)) { + size_t len; + lua_rawgeti(L, -2, 2); + (void) lua_tolstring(L, -1, &len); + lua_pop(L, 1); + if (len > 0) { + l = (int) (l + 5 + (int) len); + } + } else if (luaS_ptr_eq(s, image)) { + l += 5; + } else { + fprintf(stdout, "unknown packet command %s!\n", s); + } + } else { + fprintf(stdout, "no packet command!\n"); + } + lua_pop(L, 1); /* command name */ + } + lua_pop(L, 1); /* item */ + } + return l; +} + + + +scaled sp_to_dvi(halfword sp, halfword atsize) +{ + double result, mult; + mult = (double) (atsize / 65536.0); + result = (double) (sp * 16.0); + return floor(result / mult); +} + +@ @c +static void +read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize) +{ + int i, n, m; + size_t l; + int cmd; + const char *s; + eight_bits *cpackets; + int ff = 0; + int np = 0; + int max_f = 0; + int pc = count_char_packet_bytes(L); + if (pc <= 0) + return; + assert(l_fonts != NULL); + assert(l_fonts[1] != 0); + while (l_fonts[(max_f + 1)] != 0) + max_f++; + + cpackets = xmalloc((unsigned) (pc + 1)); + for (i = 1; i <= (int) lua_objlen(L, -1); i++) { + lua_rawgeti(L, -1, i); + if (lua_istable(L, -1)) { + /* fetch the command code */ + lua_rawgeti(L, -1, 1); + if (lua_isstring(L, -1)) { + s = lua_tostring(L, -1); + cmd = 0; + if (luaS_ptr_eq(s, font)) { + cmd = packet_font_code; + } else if (luaS_ptr_eq(s, char)) { + cmd = packet_char_code; + if (ff == 0) { + append_packet(packet_font_code); + ff = l_fonts[1]; + do_store_four(ff); + } + } else if (luaS_ptr_eq(s, slot)) { + cmd = packet_nop_code; + lua_rawgeti(L, -2, 2); + n = (int) lua_tointeger(L, -1); + ff = (n > max_f ? l_fonts[1] : l_fonts[n]); + lua_rawgeti(L, -3, 3); + n = (int) lua_tointeger(L, -1); + lua_pop(L, 2); + append_packet(packet_font_code); + do_store_four(ff); + append_packet(packet_char_code); + do_store_four(n); + } else if (luaS_ptr_eq(s, comment)) { + cmd = packet_nop_code; + } else if (luaS_ptr_eq(s, node)) { + cmd = packet_node_code; + } else if (luaS_ptr_eq(s, push)) { + cmd = packet_push_code; + } else if (luaS_ptr_eq(s, pop)) { + cmd = packet_pop_code; + } else if (luaS_ptr_eq(s, rule)) { + cmd = packet_rule_code; + } else if (luaS_ptr_eq(s, right)) { + cmd = packet_right_code; + } else if (luaS_ptr_eq(s, down)) { + cmd = packet_down_code; + } else if (luaS_ptr_eq(s, special)) { + cmd = packet_special_code; + } else if (luaS_ptr_eq(s, image)) { + cmd = packet_image_code; + } + + switch (cmd) { + case packet_push_code: + case packet_pop_code: + append_packet(cmd); + break; + case packet_font_code: + append_packet(cmd); + lua_rawgeti(L, -2, 2); + n = (int) lua_tointeger(L, -1); + ff = (n > max_f ? l_fonts[1] : l_fonts[n]); + do_store_four(ff); + lua_pop(L, 1); + break; + case packet_node_code: + append_packet(cmd); + lua_rawgeti(L, -2, 2); + n = copy_node_list(nodelist_from_lua(L)); + do_store_four(n); + lua_pop(L, 1); + break; + case packet_char_code: + append_packet(cmd); + lua_rawgeti(L, -2, 2); + n = (int) lua_tointeger(L, -1); + do_store_four(n); + lua_pop(L, 1); + break; + case packet_right_code: + case packet_down_code: + append_packet(cmd); + lua_rawgeti(L, -2, 2); + n = (int) lua_tointeger(L, -1); + do_store_four(sp_to_dvi(n, atsize)); + lua_pop(L, 1); + break; + case packet_rule_code: + append_packet(cmd); + lua_rawgeti(L, -2, 2); + n = (int) lua_tointeger(L, -1); + do_store_four(sp_to_dvi(n, atsize)); + lua_rawgeti(L, -3, 3); + n = (int) lua_tointeger(L, -1); + do_store_four(sp_to_dvi(n, atsize)); + lua_pop(L, 2); + break; + case packet_special_code: + append_packet(cmd); + lua_rawgeti(L, -2, 2); + s = lua_tolstring(L, -1, &l); + if (l > 0) { + do_store_four(l); + m = (int) l; + while (m > 0) { + n = *s++; + m--; + append_packet(n); + } + } + lua_pop(L, 1); + break; + case packet_image_code: + append_packet(cmd); + lua_rawgeti(L, -2, 2); /* img/imgtable? ... */ + if (lua_istable(L, -1)) { /* imgtable ... */ + lua_getglobal(L, "img"); /* imglib imgtable ... */ + lua_pushstring(L, "new"); /* `new' imglib imgtable ... */ + lua_gettable(L, -2); /* f imglib imgtable ... */ + lua_insert(L, -3); /* imglib imgtable f ... */ + lua_pop(L, 1); /* imgtable f ... */ + lua_call(L, 1, 1); + } /* img ... */ + luaL_checkudata(L, -1, TYPE_IMG); /* img ... --- just typecheck */ + n = luaL_ref(L, LUA_GLOBALSINDEX); /* ... */ + do_store_four(n); + break; + case packet_nop_code: + break; + default: + fprintf(stdout, + "Unknown char packet code %s (char %d in font %s)\n", + s, (int) c, font_name(f)); + } + } + lua_pop(L, 1); /* command code */ + } else { + fprintf(stdout, + "Found a `commands' item that is not a table (char %d in font %s)\n", + (int) c, font_name(f)); + } + lua_pop(L, 1); /* command table */ + } + append_packet(packet_end_code); + set_charinfo_packets(co, cpackets); + return; +} + + +@ @c +static void read_lua_cidinfo(lua_State * L, int f) +{ + int i; + char *s; + lua_getfield(L, -1, "cidinfo"); + if (lua_istable(L, -1)) { + i = numeric_field(L, "version", 0); + set_font_cidversion(f, i); + i = numeric_field(L, "supplement", 0); + set_font_cidsupplement(f, i); + s = string_field(L, "registry", "Adobe"); /* Adobe-Identity-0 */ + set_font_cidregistry(f, s); + s = string_field(L, "ordering", "Identity"); + set_font_cidordering(f, s); + } + lua_pop(L, 1); +} + + +@ @c +static void read_lua_parameters(lua_State * L, int f) +{ + int i, n; + const char *s; + lua_getfield(L, -1, "parameters"); + if (lua_istable(L, -1)) { + /* the number of parameters is the max(IntegerKeys(L)),7) */ + n = 7; + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + if (lua_isnumber(L, -2)) { + lua_number2int(i, lua_tonumber(L, -2)); + if (i > n) + n = i; + } + lua_pop(L, 1); /* pop value */ + } + if (n > 7) + set_font_params(f, n); + /* sometimes it is handy to have all integer keys */ + for (i = 1; i <= 7; i++) { + lua_rawgeti(L, -1, i); + if (lua_isnumber(L, -1)) { + n = lua_roundnumber(L, -1); + set_font_param(f, i, n); + } + lua_pop(L, 1); + } + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + if (lua_isnumber(L, -2)) { + i = (int) lua_tointeger(L, -2); + if (i >= 8) { + n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0); + set_font_param(f, i, n); + } + } else if (lua_isstring(L, -2)) { + s = lua_tostring(L, -2); + n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0); + if (luaS_ptr_eq(s, slant)) { + set_font_param(f, slant_code, n); + } else if (luaS_ptr_eq(s, space)) { + set_font_param(f, space_code, n); + } else if (luaS_ptr_eq(s, space_stretch)) { + set_font_param(f, space_stretch_code, n); + } else if (luaS_ptr_eq(s, space_shrink)) { + set_font_param(f, space_shrink_code, n); + } else if (luaS_ptr_eq(s, x_height)) { + set_font_param(f, x_height_code, n); + } else if (luaS_ptr_eq(s, quad)) { + set_font_param(f, quad_code, n); + } else if (luaS_ptr_eq(s, extra_space)) { + set_font_param(f, extra_space_code, n); + } + } + lua_pop(L, 1); + } + } + lua_pop(L, 1); + +} + +@ @c +static void read_lua_math_parameters(lua_State * L, int f) +{ + int i = 0, n = 0; + lua_getfield(L, -1, "MathConstants"); + if (lua_istable(L, -1)) { + lua_pushnil(L); + while (lua_next(L, -2) != 0) { + if (lua_isnumber(L, -2)) { + lua_number2int(i, lua_tonumber(L, -2)); + } else if (lua_isstring(L, -2)) { + i = luaL_checkoption(L, -2, NULL, MATH_param_names); + } + lua_number2int(n, lua_tonumber(L, -1)); + if (i != 0) { + set_font_math_param(f, i, n); + } + lua_pop(L, 1); /* pop value */ + } + } + lua_pop(L, 1); +} + +@ @c +#define MIN_INF -0x7FFFFFFF + + +static void store_math_kerns(lua_State * L, charinfo * co, int id) +{ + int l, k, i; + scaled ht, krn; + if (lua_istable(L, -1) && ((k = (int) lua_objlen(L, -1)) > 0)) { + for (l = 0; l < k; l++) { + lua_rawgeti(L, -1, (l + 1)); + if (lua_istable(L, -1)) { + lua_getfield(L, -1, "height"); + if (lua_isnumber(L, -1)) { + lua_number2int(i, lua_tonumber(L, -1)); + ht = (scaled) i; + } else { + ht = MIN_INF; + } + lua_pop(L, 1); + lua_getfield(L, -1, "kern"); + if (lua_isnumber(L, -1)) { + lua_number2int(i, lua_tonumber(L, -1)); + krn = (scaled) i; + } else { + krn = MIN_INF; + } + lua_pop(L, 1); + if (krn > MIN_INF && ht > MIN_INF) + add_charinfo_math_kern(co, id, ht, krn); + } + lua_pop(L, 1); + } + } +} + +@ @c +void +font_char_from_lua(lua_State * L, internal_font_number f, int i, + int *l_fonts, boolean has_math) +{ + int k, r, t; + charinfo *co; + kerninfo *ckerns; + liginfo *cligs; + scaled j; + const char *s; + int nl = 0; /* number of ligature table items */ + int nk = 0; /* number of kern table items */ + int ctr = 0; + int atsize = font_size(f); + if (lua_istable(L, -1)) { + co = get_charinfo(f, i); + set_charinfo_tag(co, 0); + j = n_numeric_field(L, luaS_width_index, 0); + set_charinfo_width(co, j); + j = n_numeric_field(L, luaS_height_index, 0); + set_charinfo_height(co, j); + j = n_numeric_field(L, luaS_depth_index, 0); + set_charinfo_depth(co, j); + j = n_numeric_field(L, luaS_italic_index, 0); + set_charinfo_italic(co, j); + j = n_numeric_field(L, luaS_index_index, 0); + set_charinfo_index(co, j); + j = n_numeric_field(L, luaS_expansion_factor_index, 0); + set_charinfo_ef(co, j); + j = n_numeric_field(L, luaS_left_protruding_index, 0); + set_charinfo_lp(co, j); + j = n_numeric_field(L, luaS_right_protruding_index, 0); + set_charinfo_rp(co, j); + k = n_boolean_field(L, luaS_used_index, 0); + set_charinfo_used(co, k); + s = n_string_field(L, luaS_name_index, NULL); + if (s != NULL) + set_charinfo_name(co, xstrdup(s)); + else + set_charinfo_name(co, NULL); + s = n_string_field(L, luaS_tounicode_index, NULL); + if (s != NULL) + set_charinfo_tounicode(co, xstrdup(s)); + else + set_charinfo_tounicode(co, NULL); + + if (has_math) { + j = n_numeric_field(L, luaS_top_accent_index, 0); + set_charinfo_top_accent(co, j); + j = n_numeric_field(L, luaS_bot_accent_index, 0); + set_charinfo_bot_accent(co, j); + k = n_numeric_field(L, luaS_next_index, -1); + if (k >= 0) { + set_charinfo_tag(co, list_tag); + set_charinfo_remainder(co, k); + } + + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_extensible_index); + lua_rawget(L, -2); + if (lua_istable(L, -1)) { + int top, bot, mid, rep; + top = n_numeric_field(L, luaS_top_index, 0); + bot = n_numeric_field(L, luaS_bot_index, 0); + mid = n_numeric_field(L, luaS_mid_index, 0); + rep = n_numeric_field(L, luaS_rep_index, 0); + if (top != 0 || bot != 0 || mid != 0 || rep != 0) { + set_charinfo_tag(co, ext_tag); + set_charinfo_extensible(co, top, bot, mid, rep); + } else { + pdftex_warn + ("lua-loaded font %s char [U+%X] has an invalid extensible field!", + font_name(f), (int) i); + } + } + lua_pop(L, 1); + + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_horiz_variants_index); + lua_rawget(L, -2); + if (lua_istable(L, -1)) { + int glyph, startconnect, endconnect, advance, extender; + extinfo *h; + set_charinfo_tag(co, ext_tag); + set_charinfo_hor_variants(co, NULL); + for (k = 1;; k++) { + lua_rawgeti(L, -1, k); + if (lua_istable(L, -1)) { + glyph = n_numeric_field(L, luaS_glyph_index, 0); + extender = n_numeric_field(L, luaS_extender_index, 0); + startconnect = n_numeric_field(L, luaS_start_index, 0); + endconnect = n_numeric_field(L, luaS_end_index, 0); + advance = n_numeric_field(L, luaS_advance_index, 0); + h = new_variant(glyph, startconnect, endconnect, + advance, extender); + add_charinfo_hor_variant(co, h); + lua_pop(L, 1); + } else { + lua_pop(L, 1); + break; + } + } + } + lua_pop(L, 1); + + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_vert_variants_index); + lua_rawget(L, -2); + if (lua_istable(L, -1)) { + int glyph, startconnect, endconnect, advance, extender; + extinfo *h; + set_charinfo_tag(co, ext_tag); + set_charinfo_vert_variants(co, NULL); + for (k = 1;; k++) { + lua_rawgeti(L, -1, k); + if (lua_istable(L, -1)) { + glyph = n_numeric_field(L, luaS_glyph_index, 0); + extender = n_numeric_field(L, luaS_extender_index, 0); + startconnect = n_numeric_field(L, luaS_start_index, 0); + endconnect = n_numeric_field(L, luaS_end_index, 0); + advance = n_numeric_field(L, luaS_advance_index, 0); + h = new_variant(glyph, startconnect, endconnect, + advance, extender); + add_charinfo_vert_variant(co, h); + lua_pop(L, 1); + } else { + lua_pop(L, 1); + break; + } + } + } + lua_pop(L, 1); + +/* Here is a complete example: + + |["mathkern"]={| + |["bottom_left"] ={ { ["height"]=420, ["kern"]=80 }, { ["height"]=520, ["kern"]=4 } },| + |["bottom_right"]={ { ["height"]=0, ["kern"]=48 } },| + |["top_left"] ={ { ["height"]=620, ["kern"]=0 }, { ["height"]=720, ["kern"]=-80 } },| + |["top_right"] ={ { ["height"]=676, ["kern"]=115 }, { ["height"]=776, ["kern"]=45 } },| + |}| + */ + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_mathkern_index); + lua_rawget(L, -2); + if (lua_istable(L, -1)) { + lua_getfield(L, -1, "top_left"); + store_math_kerns(L, co, top_left_kern); + lua_pop(L, 1); + lua_getfield(L, -1, "top_right"); + store_math_kerns(L, co, top_right_kern); + lua_pop(L, 1); + lua_getfield(L, -1, "bottom_right"); + store_math_kerns(L, co, bottom_right_kern); + lua_pop(L, 1); + lua_getfield(L, -1, "bottom_left"); + store_math_kerns(L, co, bottom_left_kern); + lua_pop(L, 1); + } + lua_pop(L, 1); + } + /* end of |has_math| */ + nk = count_hash_items(L, luaS_index(kerns)); + if (nk > 0) { + ckerns = xcalloc((unsigned) (nk + 1), sizeof(kerninfo)); + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(kerns)); + lua_rawget(L, -2); + if (lua_istable(L, -1)) { /* there are kerns */ + ctr = 0; + lua_pushnil(L); + while (lua_next(L, -2) != 0) { + k = non_boundarychar; + if (lua_isnumber(L, -2)) { + lua_number2int(k, lua_tonumber(L, -2)); /* adjacent char */ + if (k < 0) + k = non_boundarychar; + } else if (lua_isstring(L, -2)) { + s = lua_tostring(L, -2); + if (luaS_ptr_eq(s, right_boundary)) { + k = right_boundarychar; + if (!has_right_boundary(f)) + set_right_boundary(f, + get_charinfo(f, + right_boundarychar)); + } + } + j = lua_roundnumber(L, -1); /* movement */ + if (k != non_boundarychar) { + set_kern_item(ckerns[ctr], k, j); + ctr++; + } else { + pdftex_warn + ("lua-loaded font %s char [U+%X] has an invalid kern field!", + font_name(f), (int) i); + } + lua_pop(L, 1); + } + /* guard against empty tables */ + if (ctr > 0) { + set_kern_item(ckerns[ctr], end_kern, 0); + set_charinfo_kerns(co, ckerns); + } else { + pdftex_warn + ("lua-loaded font %s char [U+%X] has an invalid kerns field!", + font_name(f), (int) i); + } + } + lua_pop(L, 1); + } + + /* packet commands */ + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_commands_index); + lua_rawget(L, -2); + if (lua_istable(L, -1)) { + lua_pushnil(L); /* first key */ + if (lua_next(L, -2) != 0) { + lua_pop(L, 2); + read_char_packets(L, (int *) l_fonts, co, atsize); + } + } + lua_pop(L, 1); + + /* ligatures */ + nl = count_hash_items(L, luaS_index(ligatures)); + + if (nl > 0) { + cligs = xcalloc((unsigned) (nl + 1), sizeof(liginfo)); + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(ligatures)); + lua_rawget(L, -2); + if (lua_istable(L, -1)) { /* do ligs */ + ctr = 0; + lua_pushnil(L); + while (lua_next(L, -2) != 0) { + k = non_boundarychar; + if (lua_isnumber(L, -2)) { + lua_number2int(k, lua_tonumber(L, -2)); /* adjacent char */ + if (k < 0) { + k = non_boundarychar; + } + } else if (lua_isstring(L, -2)) { + s = lua_tostring(L, -2); + if (luaS_ptr_eq(s, right_boundary)) { + k = right_boundarychar; + if (!has_right_boundary(f)) + set_right_boundary(f, + get_charinfo(f, + right_boundarychar)); + } + } + r = -1; + if (lua_istable(L, -1)) { + r = n_numeric_field(L, luaS_char_index, -1); /* ligature */ + } + if (r != -1 && k != non_boundarychar) { + t = enum_field(L, "type", 0, ligature_type_strings); + set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k, + r); + ctr++; + } else { + pdftex_warn + ("lua-loaded font %s char [U+%X] has an invalid ligature field!", + font_name(f), (int) i); + } + lua_pop(L, 1); /* iterator value */ + } + /* guard against empty tables */ + if (ctr > 0) { + set_ligature_item(cligs[ctr], 0, end_ligature, 0); + set_charinfo_ligatures(co, cligs); + } else { + pdftex_warn + ("lua-loaded font %s char [U+%X] has an invalid ligatures field!", + font_name(f), (int) i); + } + } + lua_pop(L, 1); /* ligatures table */ + } + } +} + + + +@ The caller has to fix the state of the lua stack when there is an error! + +@c +int font_from_lua(lua_State * L, int f) +{ + int i, n, r, t; + int s_top; /* lua stack top */ + int bc; /* first char index */ + int ec; /* last char index */ + char *s; + const char *ss; + int *l_fonts = NULL; + int save_ref = 1; /* unneeded, really */ + boolean no_math = false; + + /* will we save a cache of the luat table? */ + s = string_field(L, "cache", "yes"); + if (strcmp(s, "yes") == 0) + save_ref = 1; + else if (strcmp(s, "no") == 0) + save_ref = -1; + else if (strcmp(s, "renew") == 0) + save_ref = 0; + free(s); + + /* the table is at stack index -1 */ + + if (luaS_width_index == 0) + init_font_string_pointers(L); + + s = string_field(L, "area", ""); + set_font_area(f, s); + s = string_field(L, "filename", NULL); + set_font_filename(f, s); + s = string_field(L, "encodingname", NULL); + set_font_encodingname(f, s); + + s = string_field(L, "name", NULL); + set_font_name(f, s); + s = string_field(L, "fullname", font_name(f)); + set_font_fullname(f, s); + + if (s == NULL) { + pdftex_fail("lua-loaded font [%d] has no name!", f); + return false; + } + s = string_field(L, "psname", NULL); + set_font_psname(f, s); + + i = numeric_field(L, "units_per_em", 0); + set_font_units_per_em(f, i); + i = numeric_field(L, "designsize", 655360); + set_font_dsize(f, i); + i = numeric_field(L, "size", font_dsize(f)); + set_font_size(f, i); + i = numeric_field(L, "checksum", 0); + set_font_checksum(f, (unsigned) i); + i = numeric_field(L, "direction", 0); + set_font_natural_dir(f, i); + i = numeric_field(L, "encodingbytes", 0); + set_font_encodingbytes(f, (char) i); + i = numeric_field(L, "tounicode", 0); + set_font_tounicode(f, (char) i); + + i = numeric_field(L, "extend", 1000); + if (i < FONT_EXTEND_MIN) + i = FONT_EXTEND_MIN; + if (i > FONT_EXTEND_MAX) + i = FONT_EXTEND_MAX; + set_font_extend(f, i); + i = numeric_field(L, "slant", 0); + if (i < FONT_SLANT_MIN) + i = FONT_SLANT_MIN; + if (i > FONT_SLANT_MAX) + i = FONT_SLANT_MAX; + set_font_slant(f, i); + + i = numeric_field(L, "hyphenchar", int_par(default_hyphen_char_code)); + set_hyphen_char(f, i); + i = numeric_field(L, "skewchar", int_par(default_skew_char_code)); + set_skew_char(f, i); + i = boolean_field(L, "used", 0); + set_font_used(f, (char) i); + + s = string_field(L, "attributes", NULL); + if (s != NULL && strlen(s) > 0) { + i = maketexstring(s); + set_pdf_font_attr(f, i); + } + + i = enum_field(L, "type", unknown_font_type, font_type_strings); + set_font_type(f, i); + i = enum_field(L, "format", unknown_format, font_format_strings); + set_font_format(f, i); + i = enum_field(L, "embedding", unknown_embedding, font_embedding_strings); + set_font_embedding(f, i); + if (font_encodingbytes(f) == 0 && + (font_format(f) == opentype_format + || font_format(f) == truetype_format)) { + set_font_encodingbytes(f, 2); + } + + /* now fetch the base fonts, if needed */ + n = count_hash_items(L, luaS_index(fonts)); + if (n > 0) { + l_fonts = xmalloc((unsigned) ((unsigned) (n + 2) * sizeof(int))); + memset(l_fonts, 0, (size_t) ((unsigned) (n + 2) * sizeof(int))); + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(fonts)); + lua_rawget(L, -2); + for (i = 1; i <= n; i++) { + lua_rawgeti(L, -1, i); + if (lua_istable(L, -1)) { + lua_getfield(L, -1, "id"); + if (lua_isnumber(L, -1)) { + lua_number2int(l_fonts[i], lua_tonumber(L, -1)); + lua_pop(L, 2); /* pop id and entry */ + continue; + } + lua_pop(L, 1); /* pop id */ + }; + ss = NULL; + if (lua_istable(L, -1)) { + lua_getfield(L, -1, "name"); + if (lua_isstring(L, -1)) { + ss = lua_tostring(L, -1); + } + lua_pop(L, 1); /* pop name */ + } + if (ss != NULL) { + lua_getfield(L, -1, "size"); + t = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : -1000); + lua_pop(L, 1); + + /* TODO: the stack is messed up, otherwise this + * explicit resizing would not be needed + */ + s_top = lua_gettop(L); + if (strcmp(font_name(f), ss) == 0) + l_fonts[i] = f; + else + l_fonts[i] = find_font_id(ss, t); + lua_settop(L, s_top); + } else { + pdftex_fail("Invalid local font in font %s!\n", font_name(f)); + } + lua_pop(L, 1); /* pop list entry */ + } + lua_pop(L, 1); /* pop list entry */ + } else { + if (font_type(f) == virtual_font_type) { + pdftex_fail("Invalid local fonts in font %s!\n", font_name(f)); + } else { + l_fonts = xmalloc(3 * sizeof(int)); + l_fonts[0] = 0; + l_fonts[1] = f; + l_fonts[2] = 0; + } + } + + /* parameters */ + no_math = boolean_field(L, "nomath", 0); + read_lua_parameters(L, f); + if (!no_math) { + read_lua_math_parameters(L, f); + } + read_lua_cidinfo(L, f); + + /* characters */ + + lua_getfield(L, -1, "characters"); + if (lua_istable(L, -1)) { + /* find the array size values */ + int num = 0; /* number of charinfo's to add */ + ec = 0; + bc = -1; + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + if (lua_isnumber(L, -2)) { + i = (int) lua_tointeger(L, -2); + if (i >= 0) { + if (lua_istable(L, -1)) { + num++; + if (i > ec) + ec = i; + if (bc < 0) + bc = i; + if (bc >= 0 && i < bc) + bc = i; + } + } + } + lua_pop(L, 1); + } + if (bc != -1) { +#if 0 + fprintf(stdout,"defined a font at %d with %d-%d\n",f,bc,ec); +#endif + font_malloc_charinfo(f, num); + set_font_bc(f, bc); + set_font_ec(f, ec); + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + if (lua_isnumber(L, -2)) { + lua_number2int(i, lua_tonumber(L, -2)); + if (i >= 0) { + font_char_from_lua(L, f, i, l_fonts, !no_math); + } + } else if (lua_isstring(L, -2)) { + const char *ss = lua_tostring(L, -2); + if (luaS_ptr_eq(ss, left_boundary)) { + font_char_from_lua(L, f, left_boundarychar, l_fonts, + !no_math); + } else if (luaS_ptr_eq(ss, right_boundary)) { + font_char_from_lua(L, f, right_boundarychar, l_fonts, + !no_math); + } + } + lua_pop(L, 1); + } + lua_pop(L, 1); + + /* handle font expansion last: the |copy_font| routine is called eventually, + and that needs to know |bc| and |ec|. */ + if (font_type(f) != virtual_font_type) { + int fstep = numeric_field(L, "step", 0); + if (fstep < 0) + fstep = 0; + if (fstep > 100) + fstep = 100; + if (fstep != 0) { + int fshrink = numeric_field(L, "shrink", 0); + int fstretch = numeric_field(L, "stretch", 0); + int fexpand = boolean_field(L, "auto_expand", 0); + if (fshrink < 0) + fshrink = 0; + if (fshrink > 500) + fshrink = 500; + fshrink -= (fshrink % fstep); + if (fshrink < 0) + fshrink = 0; + if (fstretch < 0) + fstretch = 0; + if (fstretch > 1000) + fstretch = 1000; + fstretch -= (fstretch % fstep); + if (fstretch < 0) + fstretch = 0; + set_expand_params(f, fexpand, fstretch, fshrink, fstep, 0); + } + } + + } else { /* jikes, no characters */ + pdftex_warn("lua-loaded font [%d] (%s) has no characters!", f, + font_name(f)); + } + + if (save_ref > 0) { + r = luaL_ref(L, LUA_REGISTRYINDEX); /* pops the table */ + set_font_cache_id(f, r); + } else { + lua_pop(L, 1); + set_font_cache_id(f, save_ref); + } + } else { /* jikes, no characters */ + pdftex_warn("lua-loaded font [%d] (%s) has no character table!", f, + font_name(f)); + } + + if (l_fonts != NULL) + free(l_fonts); + return true; +} + + + +@* Ligaturing. + +@c +#define assert_disc(a) \ + assert(pre_break(a)!=null); /* expect |head_node| */ \ + assert(type(pre_break(a))==nesting_node); \ + assert((vlink_pre_break(a)==null && tlink_pre_break(a)==null) || \ + tail_of_list(vlink_pre_break(a))==tlink_pre_break(a)); \ + assert(post_break(a)!=null); /* expect |head_node| */ \ + assert(type(post_break(a))==nesting_node); \ + assert((vlink_post_break(a)==null && tlink_post_break(a)==null) || \ + tail_of_list(vlink_post_break(a))==tlink_post_break(a)); \ + assert(no_break(a)!=null); /* expect |head_node| */ \ + assert(type(no_break(a))==nesting_node); \ + assert((vlink_no_break(a)==null && tlink_no_break(a)==null) || \ + tail_of_list(vlink_no_break(a))==tlink_no_break(a)); + +static void nesting_append(halfword nest, halfword newn) +{ + halfword tail = tlink(nest); + assert(alink(nest) == null); + assert(vlink(newn) == null); + assert(alink(newn) == null); + if (tail == null) { + assert(vlink(nest) == null); + couple_nodes(nest, newn); + } else { + assert(vlink(tail) == null); + assert(tail_of_list(vlink(nest)) == tail); + couple_nodes(tail, newn); + } + tlink(nest) = newn; +} + + +static void nesting_prepend(halfword nest, halfword newn) +{ + halfword head = vlink(nest); + assert(alink(nest) == null); + assert(vlink(newn) == null); + assert(alink(newn) == null); + couple_nodes(nest, newn); + if (head == null) { + assert(tlink(nest) == null); + tlink(nest) = newn; + } else { + assert(alink(head) == nest); + assert(tail_of_list(head) == tlink(nest)); + couple_nodes(newn, head); + } +} + + +static void nesting_prepend_list(halfword nest, halfword newn) +{ + halfword head = vlink(nest); + assert(alink(nest) == null); + assert(alink(newn) == null); + couple_nodes(nest, newn); + if (head == null) { + assert(tlink(nest) == null); + tlink(nest) = tail_of_list(newn); + } else { + halfword tail = tail_of_list(newn); + assert(alink(head) == nest); + assert(tail_of_list(head) == tlink(nest)); + couple_nodes(tail, head); + } +} + + +static int test_ligature(liginfo * lig, halfword left, halfword right) +{ + if (type(left) != glyph_node) + return 0; + assert(type(right) == glyph_node); + if (font(left) != font(right)) + return 0; + if (is_ghost(left) || is_ghost(right)) + return 0; + *lig = get_ligature(font(left), character(left), character(right)); + if (is_valid_ligature(*lig)) { + return 1; + } + return 0; +} + + +static int try_ligature(halfword * frst, halfword fwd) +{ + halfword cur = *frst; + liginfo lig; + if (test_ligature(&lig, cur, fwd)) { + int move_after = (lig_type(lig) & 0x0C) >> 2; + int keep_right = ((lig_type(lig) & 0x01) != 0); + int keep_left = ((lig_type(lig) & 0x02) != 0); + halfword newgl = raw_glyph_node(); + font(newgl) = font(cur); + character(newgl) = lig_replacement(lig); + set_is_ligature(newgl); + + /* below might not be correct in contrived border case. + but we use it only for debugging, so ... */ + if (character(cur) < 0) { + set_is_leftboundary(newgl); + } + if (character(fwd) < 0) { + set_is_rightboundary(newgl); + } + if (character(cur) < 0) { + if (character(fwd) < 0) { + build_attribute_list(newgl); + } else { + add_node_attr_ref(node_attr(fwd)); + node_attr(newgl) = node_attr(fwd); + } + } else { + add_node_attr_ref(node_attr(cur)); + node_attr(newgl) = node_attr(cur); + } + + /* TODO/FIXME if this ligature is consists of another ligature + we should add it's |lig_ptr| to the new glyphs |lig_ptr| (and + cleanup the no longer needed node) LOW PRIORITY */ + /* left side */ + if (keep_left) { + halfword new_first = copy_node(cur); + lig_ptr(newgl) = new_first; + couple_nodes(cur, newgl); + if (move_after) { + move_after--; + cur = newgl; + } + } else { + halfword prev = alink(cur); + uncouple_node(cur); + lig_ptr(newgl) = cur; + assert(prev != null); + couple_nodes(prev, newgl); + cur = newgl; /* as cur has disappeared */ + } + /* right side */ + if (keep_right) { + halfword new_second = copy_node(fwd); + /* correct, because we {\it know\/} |lig_ptr| points to {\it one\/} node */ + couple_nodes(lig_ptr(newgl), new_second); + couple_nodes(newgl, fwd); + if (move_after) { + move_after--; + cur = fwd; + } + } else { + halfword next = vlink(fwd); + uncouple_node(fwd); + /* correct, because we {\it know\/} |lig_ptr| points to {\it one\/} node */ + couple_nodes(lig_ptr(newgl), fwd); + if (next != null) { + couple_nodes(newgl, next); + } + } + + /* check and return */ + *frst = cur; + return 1; + } + return 0; +} + + +@ there shouldn't be any ligatures here - we only add them at the end of + |xxx_break| in a \.{DISC-1 - DISC-2} situation and we stop processing \.{DISC-1} + (we continue with \.{DISC-1}'s |post_| and |no_break|. + +@c +static halfword handle_lig_nest(halfword root, halfword cur) +{ + if (cur == null) + return root; + while (vlink(cur) != null) { + halfword fwd = vlink(cur); + if (type(cur) == glyph_node && type(fwd) == glyph_node && + font(cur) == font(fwd) && try_ligature(&cur, fwd)) + continue; + cur = vlink(cur); + assert(vlink(alink(cur)) == cur); + } + tlink(root) = cur; + return root; +} + + +static halfword handle_lig_word(halfword cur) +{ + halfword right = null; + if (type(cur) == whatsit_node && subtype(cur) == cancel_boundary_node) { + halfword prev = alink(cur); + halfword fwd = vlink(cur); + /* no need to uncouple |cur|, it is freed */ + flush_node(cur); + if (fwd == null) { + vlink(prev) = fwd; + return prev; + } + couple_nodes(prev, fwd); + if (type(fwd) != glyph_node) + return prev; + cur = fwd; + } else if (has_left_boundary(font(cur))) { + halfword prev = alink(cur); + halfword p = new_glyph(font(cur), left_boundarychar); + couple_nodes(prev, p); + couple_nodes(p, cur); + cur = p; + } + if (has_right_boundary(font(cur))) { + right = new_glyph(font(cur), right_boundarychar); + } + while (1) { + /* A glyph followed by ... */ + if (type(cur) == glyph_node) { + halfword fwd = vlink(cur); + if (fwd == null) { /* last character of paragraph */ + if (right == null) + break; + /* \.{--\\par} prohibits use of |couple_nodes| here */ + try_couple_nodes(cur, right); + right = null; + continue; + } + assert(alink(fwd) == cur); + if (type(fwd) == glyph_node) { /* |GLYPH - GLYPH| */ + if (font(cur) != font(fwd)) + break; + if (try_ligature(&cur, fwd)) + continue; + } else if (type(fwd) == disc_node) { /* |GLYPH - DISC| */ + + /* if \.{a{bx}{}{y}} and \.{a+b=>B} convert to \.{{Bx}{}{ay}} */ + halfword pre = vlink_pre_break(fwd); + halfword nob = vlink_no_break(fwd); + halfword next, tail; + liginfo lig; + assert_disc(fwd); + /* Check on: a{b?}{?}{?} and a+b=>B : {B?}{?}{a?} */ + /* Check on: a{?}{?}{b?} and a+b=>B : {a?}{?}{B?} */ + if ((pre != null && type(pre) == glyph_node + && test_ligature(&lig, cur, pre)) + || (nob != null && type(nob) == glyph_node + && test_ligature(&lig, cur, nob))) { + /* move cur from before disc, to skipped part */ + halfword prev = alink(cur); + assert(vlink(prev) == cur); + uncouple_node(cur); + couple_nodes(prev, fwd); + nesting_prepend(no_break(fwd), cur); + /* now ligature the |pre_break| */ + nesting_prepend(pre_break(fwd), copy_node(cur)); + /* As we have removed cur, we need to start again ... */ + cur = prev; + } + /* Check on: a{?}{?}{}b and a+b=>B : {a?}{?b}{B} */ + next = vlink(fwd); + if (nob == null && next != null && type(next) == glyph_node + && test_ligature(&lig, cur, next)) { + /* move |cur| from before |disc| to |no_break| part */ + halfword prev = alink(cur); + assert(alink(next) == fwd); + assert(vlink(prev) == cur); + uncouple_node(cur); + couple_nodes(prev, fwd); + couple_nodes(no_break(fwd), cur); /* we {\it know\/} it's empty */ + /* now copy cur the |pre_break| */ + nesting_prepend(pre_break(fwd), copy_node(cur)); + /* move next from after disc to |no_break| part */ + tail = vlink(next); + uncouple_node(next); + try_couple_nodes(fwd, tail); + couple_nodes(cur, next); /* we {\it know\/} this works */ + tlink(no_break(fwd)) = next; /* and make sure the list is correct */ + /* now copy next to the |post_break| */ + nesting_append(post_break(fwd), copy_node(next)); + /* As we have removed cur, we need to start again ... */ + cur = prev; + } + /* we are finished with the |pre_break| */ + handle_lig_nest(pre_break(fwd), vlink_pre_break(fwd)); + } else if (type(fwd) == whatsit_node + && subtype(fwd) == cancel_boundary_node) { + halfword next = vlink(fwd); + try_couple_nodes(cur, next); + flush_node(fwd); + if (right != null) { + flush_node(right); /* Shame, didn't need it */ + /* no need to reset |right|, we're going to leave the loop anyway */ + } + break; + } else { /* fwd is something unknown */ + if (right == null) + break; + couple_nodes(cur, right); + couple_nodes(right, fwd); + right = null; + continue; + } + /* A discretionary followed by ... */ + } else if (type(cur) == disc_node) { + + assert_disc(cur); + /* If \.{{?}{x}{?}} or \.{{?}{?}{y}} then ... */ + if (vlink_no_break(cur) != null || vlink_post_break(cur) != null) { + halfword prev = 0; + halfword fwd; + liginfo lig; + if (subtype(cur) == select_disc) { + prev = alink(cur); + assert(type(prev) == disc_node + && subtype(prev) == init_disc); + if (vlink_post_break(cur) != null) + handle_lig_nest(post_break(prev), + vlink_post_break(prev)); + if (vlink_no_break(cur) != null) + handle_lig_nest(no_break(prev), vlink_no_break(prev)); + } + if (vlink_post_break(cur) != null) + handle_lig_nest(post_break(cur), vlink_post_break(cur)); + if (vlink_no_break(cur) != null) + handle_lig_nest(no_break(cur), vlink_no_break(cur)); + while ((fwd = vlink(cur)) != null) { + halfword nob, pst, next; + if (type(fwd) != glyph_node) + break; + if (subtype(cur) != select_disc) { + nob = tlink_no_break(cur); + pst = tlink_post_break(cur); + if ((nob == null || !test_ligature(&lig, nob, fwd)) && + (pst == null || !test_ligature(&lig, pst, fwd))) + break; + nesting_append(no_break(cur), copy_node(fwd)); + handle_lig_nest(no_break(cur), nob); + } else { + int dobreak = 0; + nob = tlink_no_break(prev); + pst = tlink_post_break(prev); + if ((nob == null || !test_ligature(&lig, nob, fwd)) && + (pst == null || !test_ligature(&lig, pst, fwd))) + dobreak = 1; + if (!dobreak) { + nesting_append(no_break(prev), copy_node(fwd)); + handle_lig_nest(no_break(prev), nob); + nesting_append(post_break(prev), copy_node(fwd)); + handle_lig_nest(post_break(prev), pst); + } + dobreak = 0; + nob = tlink_no_break(cur); + pst = tlink_post_break(cur); + if ((nob == null || !test_ligature(&lig, nob, fwd)) && + (pst == null || !test_ligature(&lig, pst, fwd))) + dobreak = 1; + if (!dobreak) { + nesting_append(no_break(cur), copy_node(fwd)); + handle_lig_nest(no_break(cur), nob); + } + if (dobreak) + break; + } + next = vlink(fwd); + uncouple_node(fwd); + try_couple_nodes(cur, next); + nesting_append(post_break(cur), fwd); + handle_lig_nest(post_break(cur), pst); + } + if (fwd != null && type(fwd) == disc_node) { + halfword next = vlink(fwd); + if (vlink_no_break(fwd) == null && + vlink_post_break(fwd) == null && + next != null && + type(next) == glyph_node && + ((tlink_post_break(cur) != null && + test_ligature(&lig, tlink_post_break(cur), next)) || + (tlink_no_break(cur) != null && + test_ligature(&lig, tlink_no_break(cur), next)))) { + /* Building an |init_disc| followed by a |select_disc| + \.{{a-}{b}{AB} {-}{}{}} 'c' + */ + halfword last = vlink(next), tail; + uncouple_node(next); + try_couple_nodes(fwd, last); + /* \.{{a-}{b}{AB} {-}{c}{}} */ + nesting_append(post_break(fwd), copy_node(next)); + /* \.{{a-}{b}{AB} {-}{c}{-}} */ + if (vlink_no_break(cur) != null) { + nesting_prepend(no_break(fwd), + copy_node(vlink_pre_break(fwd))); + } + /* \.{{a-}{b}{AB} {b-}{c}{-}} */ + if (vlink_post_break(cur) != null) + nesting_prepend_list(pre_break(fwd), + copy_node_list(vlink_post_break + (cur))); + /* \.{{a-}{b}{AB} {b-}{c}{AB-}} */ + if (vlink_no_break(cur) != null) { + nesting_prepend_list(no_break(fwd), + copy_node_list(vlink_no_break + (cur))); + } + /* \.{{a-}{b}{ABC} {b-}{c}{AB-}} */ + tail = tlink_no_break(cur); + nesting_append(no_break(cur), copy_node(next)); + handle_lig_nest(no_break(cur), tail); + /* \.{{a-}{BC}{ABC} {b-}{c}{AB-}} */ + tail = tlink_post_break(cur); + nesting_append(post_break(cur), next); + handle_lig_nest(post_break(cur), tail); + /* and set the subtypes */ + subtype(cur) = init_disc; + subtype(fwd) = select_disc; + } + } + } + + } else { /* NO GLYPH NOR DISC */ +#if 0 + fprintf(stdout,"This is a %d node\n",type(cur)); + assert(0); /* TODO howcome there can be a glue here? */ +#endif + return cur; + } + /* step-to-next-node */ + { + halfword prev = cur; + /* \.{--\\par} allows |vlink(cur)| to be null */ + cur = vlink(cur); + if (cur != null) { + assert(alink(cur) == prev); + } + } + } + + return cur; +} + +@ Return value is the new tail, head should be a dummy + +@c +halfword handle_ligaturing(halfword head, halfword tail) +{ + halfword save_tail; /* trick to allow explicit |node==null| tests */ + halfword cur, prev; + + if (vlink(head) == null) + return tail; + save_tail = vlink(tail); + vlink(tail) = null; + + /* |if (fix_node_lists)| */ + fix_node_list(head); + + prev = head; + cur = vlink(prev); + + while (cur != null) { + if (type(cur) == glyph_node || + (type(cur) == whatsit_node + && subtype(cur) == cancel_boundary_node)) { + cur = handle_lig_word(cur); + } + prev = cur; + cur = vlink(cur); + assert(cur == null || alink(cur) == prev); + } + if (prev == null) + prev = tail; + + if (valid_node(save_tail)) { + try_couple_nodes(prev, save_tail); + } + return prev; +} + + +@* Kerning. + +@c +static void add_kern_before(halfword left, halfword right) +{ + if ((!is_rightghost(right)) && + font(left) == font(right) && has_kern(font(left), character(left))) { + int k = raw_get_kern(font(left), character(left), character(right)); + if (k != 0) { + halfword kern = new_kern(k); + halfword prev = alink(right); + assert(vlink(prev) == right); + couple_nodes(prev, kern); + couple_nodes(kern, right); + } + } +} + + +static void add_kern_after(halfword left, halfword right, halfword aft) +{ + if ((!is_rightghost(right)) && + font(left) == font(right) && has_kern(font(left), character(left))) { + int k = raw_get_kern(font(left), character(left), character(right)); + if (k != 0) { + halfword kern = new_kern(k); + halfword next = vlink(aft); + assert(next == null || alink(next) == aft); + couple_nodes(aft, kern); + try_couple_nodes(kern, next); + } + } +} + + +static void +do_handle_kerning(halfword root, halfword init_left, halfword init_right) +{ + halfword cur = vlink(root); + halfword left = null; + assert(init_left == null || type(init_left) == glyph_node); + assert(init_right == null || type(init_right) == glyph_node); + if (cur == null) { + if (init_left != null && init_right != null) { + add_kern_after(init_left, init_right, root); + tlink(root) = vlink(root); + } + return; + } + if (type(cur) == glyph_node) { + set_is_glyph(cur); + if (init_left != null) + add_kern_before(init_left, cur); + left = cur; + } + while ((cur = vlink(cur)) != null) { + if (type(cur) == glyph_node) { + set_is_glyph(cur); + if (left != null) { + add_kern_before(left, cur); + if (character(left) < 0 || is_ghost(left)) { + halfword prev = alink(left); + couple_nodes(prev, cur); + flush_node(left); + } + } + left = cur; + } else { + if (type(cur) == disc_node) { + halfword right = + type(vlink(cur)) == glyph_node ? vlink(cur) : null; + do_handle_kerning(pre_break(cur), left, null); + do_handle_kerning(post_break(cur), null, right); + if (vlink_post_break(cur) != null) + tlink_post_break(cur) = tail_of_list(vlink_post_break(cur)); + do_handle_kerning(no_break(cur), left, right); + if (vlink_no_break(cur) != null) + tlink_no_break(cur) = tail_of_list(vlink_no_break(cur)); /* needed? */ + } + if (left != null) { + if (character(left) < 0 || is_ghost(left)) { + halfword prev = alink(left); + couple_nodes(prev, cur); + flush_node(left); + } + left = null; + } + } + } + if (left != null) { + if (init_right != null) + add_kern_after(left, init_right, left); + if (character(left) < 0 || is_ghost(left)) { + halfword prev = alink(left); + halfword next = vlink(left); + if (next != null) { + couple_nodes(prev, next); + tlink(root) = next; + assert(vlink(next) == null); + assert(type(next) == kern_node); + } else if (prev != root) { + vlink(prev) = null; + tlink(root) = prev; + } else { + vlink(root) = null; + tlink(root) = null; + } + flush_node(left); + } + } +} + + +halfword handle_kerning(halfword head, halfword tail) +{ + halfword save_link; + save_link = vlink(tail); + vlink(tail) = null; + tlink(head) = tail; + do_handle_kerning(head, null, null); + tail = tlink(head); + if (valid_node(save_link)) { + try_couple_nodes(tail, save_link); + } + return tail; +} + +@* ligaturing and kerning : lua-interface. + +@c +static halfword +run_lua_ligkern_callback(halfword head, halfword tail, int callback_id) +{ + lua_State *L = Luas; + if (!get_callback(L, callback_id)) { + lua_pop(L, 2); + return tail; + } + nodelist_to_lua(L, head); + nodelist_to_lua(L, tail); + if (lua_pcall(L, 2, 1, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 2); + lua_error(L); + return tail; + } + tail = nodelist_from_lua(L); + if (fix_node_lists) + fix_node_list(head); + lua_pop(L, 2); + return tail; +} + + +halfword new_ligkern(halfword head, halfword tail) +{ + int callback_id = 0; + + assert(head != null); + if (vlink(head) == null) + return tail; + + callback_id = callback_defined(ligaturing_callback); + if (callback_id > 0) { + tail = run_lua_ligkern_callback(head, tail, callback_id); + if (tail == null) + tail = tail_of_list(head); + } else if (callback_id == 0) { + tail = handle_ligaturing(head, tail); + } + + callback_id = callback_defined(kerning_callback); + if (callback_id > 0) { + tail = run_lua_ligkern_callback(head, tail, callback_id); + if (tail == null) + tail = tail_of_list(head); + } else if (callback_id == 0) { + halfword nest = new_node(nesting_node, 1); + halfword cur = vlink(head); + halfword aft = vlink(tail); + couple_nodes(nest, cur); + tlink(nest) = tail; + vlink(tail) = null; + do_handle_kerning(nest, null, null); + couple_nodes(head, vlink(nest)); + tail = tlink(nest); + try_couple_nodes(tail, aft); + flush_node(nest); + } + return tail; +} diff --git a/Build/source/texk/web2c/luatexdir/font/luatexfont.h b/Build/source/texk/web2c/luatexdir/font/luatexfont.h index 987517266ed..fa2d2ac6c6d 100644 --- a/Build/source/texk/web2c/luatexdir/font/luatexfont.h +++ b/Build/source/texk/web2c/luatexdir/font/luatexfont.h @@ -1,6 +1,6 @@ /* luatexfont.h --- General font definitions - Copyright 2008 Taco Hoekwater + Copyright 2008-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: luatexfont.h 2332 2009-04-18 17:17:56Z hhenkel $ */ +/* $Id: luatexfont.h 3433 2010-02-20 10:03:04Z hhenkel $ */ #ifndef LUATEXFONT_H # define LUATEXFONT_H @@ -83,19 +83,18 @@ typedef struct { } intparm; typedef struct { - integer fe_objnum; /* object number */ + int fe_objnum; /* object number */ char *name; /* encoding file name */ char **glyph_names; /* array of glyph names */ struct avl_table *tx_tree; /* tree of encoding positions marked as used by TeX */ } fe_entry; typedef struct fd_entry_ { - integer fd_objnum; /* object number of the font descriptor object */ + int fd_objnum; /* object number of the font descriptor object */ char *fontname; /* /FontName (without subset tag) */ char *subset_tag; /* 6-character subset tag */ boolean ff_found; - integer ff_objnum; /* object number of the font program stream */ - integer fn_objnum; /* font name object number (embedded PDF) */ + int ff_objnum; /* object number of the font program stream */ boolean all_glyphs; /* embed all glyphs? */ boolean write_ttf_glyph_names; intparm font_dim[FONT_KEYS_NUM]; @@ -107,16 +106,16 @@ typedef struct fd_entry_ { } fd_entry; typedef struct fo_entry_ { - integer fo_objnum; /* object number of the font dictionary */ - internalfontnumber tex_font; /* needed only for \pdffontattr{} */ + int fo_objnum; /* object number of the font dictionary */ + internal_font_number tex_font; /* needed only for \pdffontattr{} */ fm_entry *fm; /* pointer to font map structure for this font dictionary */ fd_entry *fd; /* pointer to /FontDescriptor object structure */ fe_entry *fe; /* pointer to encoding structure */ - integer cw_objnum; /* object number of the font program object */ - integer first_char; /* first character used in this font */ - integer last_char; /* last character used in this font */ + int cw_objnum; /* object number of the font program object */ + int first_char; /* first character used in this font */ + int last_char; /* last character used in this font */ struct avl_table *tx_tree; /* tree of non-reencoded TeX characters marked as used */ - integer tounicode_objnum; /* object number of ToUnicode */ + int tounicode_objnum; /* object number of ToUnicode */ } fo_entry; typedef struct { @@ -132,7 +131,7 @@ typedef struct glw_entry_ { /* subset glyphs for inclusion in CID-based font } glw_entry; typedef struct { - integer charcode, cwidth, cheight, xoff, yoff, xescape, rastersize; + int charcode, cwidth, cheight, xoff, yoff, xescape, rastersize; halfword *raster; } chardesc; @@ -141,41 +140,38 @@ typedef struct { # include "texfont.h" /* tounicode.c */ -integer write_cid_tounicode(fo_entry * fo, internalfontnumber f); +int write_cid_tounicode(PDF, fo_entry *, internal_font_number); void glyph_unicode_free(void); void def_tounicode(str_number, str_number); -integer write_tounicode(char **, char *); +int write_tounicode(PDF, char **, char *); /* vfpacket.c */ -void replace_packet_fonts(internal_font_number f, integer * old_fontid, - integer * new_fontid, int count); -integer *packet_local_fonts(internal_font_number f, integer * num); +void replace_packet_fonts(internal_font_number f, int *old_fontid, + int *new_fontid, int count); +int *packet_local_fonts(internal_font_number f, int *num); -/* writeccf.c */ -void writetype1w(fd_entry * fd); +/* writecff.c */ +void writetype1w(PDF pdf, fd_entry * fd); /* writetype0.c */ -void writetype0(fd_entry * fd); +void writetype0(PDF pdf, fd_entry * fd); /* writefont.c */ -void do_pdf_font(integer, internalfontnumber); -fd_entry *lookup_fd_entry(char *, integer, integer); +void do_pdf_font(PDF, internal_font_number); +fd_entry *lookup_fd_entry(char *); fd_entry *new_fd_entry(void); -void write_fontstuff(void); -integer get_fd_objnum(fd_entry * fd); -integer get_fn_objnum(fd_entry * fd); -void embed_whole_font(fd_entry * fd); +void write_fontstuff(PDF); void register_fd_entry(fd_entry * fd); /* writet1.c */ boolean t1_subset(char *, char *, unsigned char *); char **load_enc_file(char *); -void writet1(fd_entry *); +void writet1(PDF, fd_entry *); void t1_free(void); -extern integer t1_length1, t1_length2, t1_length3; +extern int t1_length1, t1_length2, t1_length3; /* writetype2.c */ -void writetype2(fd_entry * fd); +void writetype2(PDF, fd_entry *); extern unsigned long cidtogid_obj; pdf_obj *pdf_new_stream(void); void pdf_add_stream(pdf_obj * stream, unsigned char *buf, long len); @@ -188,37 +184,35 @@ boolean handle_subfont_fm(fm_entry *, int); /* writeenc.c */ fe_entry *get_fe_entry(char *); void enc_free(void); -void write_fontencodings(void); +void write_fontencodings(PDF pdf); /* writettf.c */ -void writettf(fd_entry *); -void writeotf(fd_entry *); +void writettf(PDF, fd_entry *); +void writeotf(PDF, fd_entry *); void ttf_free(void); -extern integer ttf_length; +extern int ttf_length; /* pkin.c */ int readchar(boolean, chardesc *); /* macnames.c */ -extern const char notdef[]; +extern char notdef[]; /* vfovf.c */ void vf_expand_local_fonts(internal_font_number f); internal_font_number letter_space_font(halfword u, internal_font_number f, - integer e); -internal_font_number auto_expand_font(internal_font_number f, integer e); -str_number expand_font_name(internal_font_number f, integer e); -void pdf_check_vf_cur_val(void); + int e); +internal_font_number auto_expand_font(internal_font_number f, int e); +void pdf_check_vf(internal_font_number f); internal_font_number copy_font_info(internal_font_number f); /* writet3.c */ extern FILE *t3_file; -void writet3(int, internalfontnumber); -scaled get_pk_char_width(internalfontnumber, scaled); +void writet3(PDF, internal_font_number); extern unsigned char *t3_buffer; -extern integer t3_size; -extern integer t3_curbyte; +extern int t3_size; +extern int t3_curbyte; # define t3_read_file() readbinfile(t3_file, &t3_buffer, &t3_size) # define t3_close() xfclose(t3_file, cur_file_name) diff --git a/Build/source/texk/web2c/luatexdir/font/macnames.c b/Build/source/texk/web2c/luatexdir/font/macnames.c deleted file mode 100644 index a62de50edcb..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/macnames.c +++ /dev/null @@ -1,313 +0,0 @@ -/* macnames.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -static const char __svn_version[] = - "$Id: macnames.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/macnames.c $"; - -const char notdef[] = ".notdef"; - -const char *mac_glyph_names[] = { -/* 0x00 */ - notdef, - ".null", - "CR", - "space", - "exclam", - "quotedbl", - "numbersign", - "dollar", - "percent", - "ampersand", - "quotesingle", - "parenleft", - "parenright", - "asterisk", - "plus", - "comma", -/* 0x10 */ - "hyphen", - "period", - "slash", - "zero", - "one", - "two", - "three", - "four", - "five", - "six", - "seven", - "eight", - "nine", - "colon", - "semicolon", - "less", -/* 0x20 */ - "equal", - "greater", - "question", - "at", - "A", - "B", - "C", - "D", - "E", - "F", - "G", - "H", - "I", - "J", - "K", - "L", -/* 0x30 */ - "M", - "N", - "O", - "P", - "Q", - "R", - "S", - "T", - "U", - "V", - "W", - "X", - "Y", - "Z", - "bracketleft", - "backslash", -/* 0x40 */ - "bracketright", - "asciicircum", - "underscore", - "grave", - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - "i", - "j", - "k", - "l", -/* 0x50 */ - "m", - "n", - "o", - "p", - "q", - "r", - "s", - "t", - "u", - "v", - "w", - "x", - "y", - "z", - "braceleft", - "bar", -/* 0x60 */ - "braceright", - "asciitilde", - "Adieresis", - "Aring", - "Ccedilla", - "Eacute", - "Ntilde", - "Odieresis", - "Udieresis", - "aacute", - "agrave", - "acircumflex", - "adieresis", - "atilde", - "aring", - "ccedilla", -/* 0x70 */ - "eacute", - "egrave", - "ecircumflex", - "edieresis", - "iacute", - "igrave", - "icircumflex", - "idieresis", - "ntilde", - "oacute", - "ograve", - "ocircumflex", - "odieresis", - "otilde", - "uacute", - "ugrave", -/* 0x80 */ - "ucircumflex", - "udieresis", - "dagger", - "degree", - "cent", - "sterling", - "section", - "bullet", - "paragraph", - "germandbls", - "registered", - "copyright", - "trademark", - "acute", - "dieresis", - "notequal", -/* 0x90 */ - "AE", - "Oslash", - "infinity", - "plusminus", - "lessequal", - "greaterequal", - "yen", - "mu", - "partialdiff", - "Sigma", - "Pi", - "pi", - "integral", - "ordfeminine", - "ordmasculine", - "Omega", -/* 0xa0 */ - "ae", - "oslash", - "questiondown", - "exclamdown", - "logicalnot", - "radical", - "florin", - "approxequal", - "Delta", - "guillemotleft", - "guillemotright", - "ellipsis", - "nbspace", - "Agrave", - "Atilde", - "Otilde", -/* 0xb0 */ - "OE", - "oe", - "endash", - "emdash", - "quotedblleft", - "quotedblright", - "quoteleft", - "quoteright", - "divide", - "lozenge", - "ydieresis", - "Ydieresis", - "fraction", - "currency", - "guilsinglleft", - "guilsinglright", -/* 0xc0 */ - "fi", - "fl", - "daggerdbl", - "periodcentered", - "quotesinglbase", - "quotedblbase", - "perthousand", - "Acircumflex", - "Ecircumflex", - "Aacute", - "Edieresis", - "Egrave", - "Iacute", - "Icircumflex", - "Idieresis", - "Igrave", -/* 0xd0 */ - "Oacute", - "Ocircumflex", - "applelogo", - "Ograve", - "Uacute", - "Ucircumflex", - "Ugrave", - "dotlessi", - "circumflex", - "tilde", - "macron", - "breve", - "dotaccent", - "ring", - "cedilla", - "hungarumlaut", -/* 0xe0 */ - "ogonek", - "caron", - "Lslash", - "lslash", - "Scaron", - "scaron", - "Zcaron", - "zcaron", - "brokenbar", - "Eth", - "eth", - "Yacute", - "yacute", - "Thorn", - "thorn", - "minus", -/* 0xf0 */ - "multiply", - "onesuperior", - "twosuperior", - "threesuperior", - "onehalf", - "onequarter", - "threequarters", - "franc", - "Gbreve", - "gbreve", - "Idot", - "Scedilla", - "scedilla", - "Cacute", - "cacute", - "Ccaron", -/* 0x100 */ - "ccaron", - "dmacron" -}; - -const char *ambiguous_names[] = { - "Delta", /* increment */ - "Omega", /* Ohm */ - "Pi", /* product */ - "Sigma", /* summation */ - "dmacron", /* dslash */ - "macron", /* overscore */ - "periodcentered", /* middot */ - NULL -}; diff --git a/Build/source/texk/web2c/luatexdir/font/mapfile.c b/Build/source/texk/web2c/luatexdir/font/mapfile.c deleted file mode 100644 index fe5155da23e..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/mapfile.c +++ /dev/null @@ -1,1003 +0,0 @@ -/* mapfile.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include -#include "ptexlib.h" -#include -#include -#include -#include "luatex-api.h" - -static const char _svn_version[] = - "$Id: mapfile.c 2331 2009-04-18 16:39:50Z hhenkel $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/mapfile.c $"; - -#define FM_BUF_SIZE 1024 - -static FILE *fm_file; - -static unsigned char *fm_buffer = NULL; -static integer fm_size = 0; -static integer fm_curbyte = 0; - -#define fm_open() \ - (fm_file = fopen((char *) nameoffile + 1, FOPEN_RBIN_MODE)) -#define fm_read_file() \ - readbinfile(fm_file,&fm_buffer,&fm_size) -#define fm_close() xfclose(fm_file, cur_file_name) -#define fm_getchar() fm_buffer[fm_curbyte++] -#define fm_eof() (fm_curbyte>fm_size) -#define is_cfg_comment(c) \ - (c == 10 || c == '*' || c == '#' || c == ';' || c == '%') - -typedef enum { FM_DUPIGNORE, FM_REPLACE, FM_DELETE } updatemode; -typedef enum { MAPFILE, MAPLINE } maptype; - -typedef struct mitem { - updatemode mode; /* FM_DUPIGNORE or FM_REPLACE or FM_DELETE */ - maptype type; /* map file or map line */ - char *line; /* pointer to map file name or map line */ - int lineno; /* line number in map file */ -} mapitem; -mapitem *mitem = NULL; - -static const char nontfm[] = ""; - -#define read_field(r, q, buf) do { \ - q = buf; \ - while (*r != ' ' && *r != '<' && *r != '"' && *r != '\0') \ - *q++ = *r++; \ - *q = '\0'; \ - skip (r, ' '); \ -} while (0) - -#define set_field(F) do { \ - if (q > buf) \ - fm->F = xstrdup(buf); \ - if (*r == '\0') \ - goto done; \ -} while (0) - -fm_entry *new_fm_entry(void) -{ - fm_entry *fm; - fm = xtalloc(1, fm_entry); - fm->tfm_name = NULL; - fm->sfd_name = NULL; - fm->ps_name = NULL; - fm->fd_flags = FD_FLAGS_NOT_SET_IN_MAPLINE; - fm->ff_name = NULL; - fm->encname = NULL; - fm->type = 0; - fm->slant = 0; - fm->extend = 0; - fm->links = 0; - fm->pid = -1; - fm->eid = -1; - fm->subfont = NULL; - fm->in_use = false; - return fm; -} - -void delete_fm_entry(fm_entry * fm) -{ - xfree(fm->tfm_name); - xfree(fm->sfd_name); - xfree(fm->ps_name); - xfree(fm->ff_name); - xfree(fm); -} - -static ff_entry *new_ff_entry(void) -{ - ff_entry *ff; - ff = xtalloc(1, ff_entry); - ff->ff_name = NULL; - ff->ff_path = NULL; - return ff; -} - -static void delete_ff_entry(ff_entry * ff) -{ - xfree(ff->ff_name); - xfree(ff->ff_path); - xfree(ff); -} - -static fm_entry *dummy_fm_entry(void) -{ - static const fm_entry const_fm_entry; - return (fm_entry *) & const_fm_entry; -} - -/**********************************************************************/ - -struct avl_table *tfm_tree = NULL; -struct avl_table *ps_tree = NULL; -struct avl_table *ff_tree = NULL; -struct avl_table *encname_tree = NULL; - -/* AVL sort fm_entry into tfm_tree by tfm_name */ - -static int comp_fm_entry_tfm(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(((const fm_entry *) pa)->tfm_name, - ((const fm_entry *) pb)->tfm_name); -} - -/* AVL sort fm_entry into ps_tree by ps_name, slant, and extend */ - -static int comp_fm_entry_ps(const void *pa, const void *pb, void *p) -{ - int i; - const fm_entry *p1 = (const fm_entry *) pa, *p2 = (const fm_entry *) pb; - (void) p; - assert(p1->ps_name != NULL && p2->ps_name != NULL); - if ((i = strcmp(p1->ps_name, p2->ps_name))) - return i; - cmp_return(p1->slant, p2->slant); - cmp_return(p1->extend, p2->extend); - return 0; -} - -/* AVL sort ff_entry into ff_tree by ff_name */ - -static int comp_ff_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(((const ff_entry *) pa)->ff_name, - ((const ff_entry *) pb)->ff_name); -} - -static void create_avl_trees(void) -{ - assert(tfm_tree == NULL); - tfm_tree = avl_create(comp_fm_entry_tfm, NULL, &avl_xallocator); - assert(tfm_tree != NULL); - assert(ps_tree == NULL); - ps_tree = avl_create(comp_fm_entry_ps, NULL, &avl_xallocator); - assert(ps_tree != NULL); - assert(ff_tree == NULL); - ff_tree = avl_create(comp_ff_entry, NULL, &avl_xallocator); - assert(ff_tree != NULL); - assert(encname_tree == NULL); - encname_tree = avl_create(comp_string_entry, NULL, &avl_xallocator); - assert(encname_tree != NULL); -} - -/* -The function avl_do_entry() is not completely symmetrical with regards -to tfm_name and ps_name handling, e. g. a duplicate tfm_name gives a -"goto exit", and no ps_name link is tried. This is to keep it compatible -with the original version. -*/ - -int avl_do_entry(fm_entry * fm, int mode) -{ - fm_entry *p; - void *a; - void **aa; - - /* handle tfm_name link */ - - if (strcmp(fm->tfm_name, nontfm)) { - p = (fm_entry *) avl_find(tfm_tree, fm); - if (p != NULL) { - switch (mode) { - case FM_DUPIGNORE: - pdftex_warn - ("fontmap entry for `%s' already exists, duplicates ignored", - fm->tfm_name); - goto exit; - break; - case FM_REPLACE: - case FM_DELETE: - if (p->in_use) { - pdftex_warn - ("fontmap entry for `%s' has been used, replace/delete not allowed", - fm->tfm_name); - goto exit; - } - a = avl_delete(tfm_tree, p); - assert(a != NULL); - unset_tfmlink(p); - if (!has_pslink(p)) - delete_fm_entry(p); - break; - default: - assert(0); - } - } - if (mode != FM_DELETE) { - aa = avl_probe(tfm_tree, fm); - assert(aa != NULL); - set_tfmlink(fm); - } - } - - /* handle ps_name link */ - - if (fm->ps_name != NULL) { - p = (fm_entry *) avl_find(ps_tree, fm); - if (p != NULL) { - switch (mode) { - case FM_DUPIGNORE: - goto exit; - break; - case FM_REPLACE: - case FM_DELETE: - if (p->in_use) - goto exit; - a = avl_delete(ps_tree, p); - assert(a != NULL); - unset_pslink(p); - if (!has_tfmlink(p)) - delete_fm_entry(p); - break; - default: - assert(0); - } - } - if (mode != FM_DELETE && is_t1fontfile(fm) && is_included(fm)) { - aa = avl_probe(ps_tree, fm); - assert(aa != NULL); - set_pslink(fm); - } - } - exit: - if (!has_tfmlink(fm) && !has_pslink(fm)) /* e. g. after FM_DELETE */ - return 1; /* deallocation of fm_entry structure required */ - else - return 0; -} - -/* add the encoding name to an AVL tree. this has nothing to do with writeenc.c */ - -static char *add_encname(char *s) -{ - char *p; - void **aa; - assert(s != NULL); - assert(encname_tree != NULL); - if ((p = (char *) avl_find(encname_tree, s)) == NULL) { /* encoding name not yet registered */ - p = xstrdup(s); - aa = avl_probe(encname_tree, p); - assert(aa != NULL); - } - return p; -} - -/**********************************************************************/ -/* consistency check for map entry, with warn flag */ - -static int check_fm_entry(fm_entry * fm, boolean warn) -{ - int a = 0; - assert(fm != NULL); - - if (is_fontfile(fm) && !is_included(fm)) { - if (warn) - pdftex_warn - ("ambiguous entry for `%s': font file present but not included, " - "will be treated as font file not present", fm->tfm_name); - xfree(fm->ff_name); - /* do not set variable |a| as this entry will be still accepted */ - } - - /* if both ps_name and font file are missing, drop this entry */ - if (fm->ps_name == NULL && !is_fontfile(fm)) { - if (warn) - pdftex_warn - ("invalid entry for `%s': both ps_name and font file missing", - fm->tfm_name); - a += 1; - } - - /* TrueType fonts cannot be reencoded without subsetting */ - if (is_truetype(fm) && is_reencoded(fm) && !is_subsetted(fm)) { - if (warn) - pdftex_warn - ("invalid entry for `%s': only subsetted TrueType font can be reencoded", - fm->tfm_name); - a += 2; - } - - /* SlantFont and ExtendFont can be used only with Type1 fonts */ - if ((fm->slant != 0 || fm->extend != 0) - && !(is_t1fontfile(fm) && is_included(fm))) { - if (warn) - pdftex_warn - ("invalid entry for `%s': SlantFont/ExtendFont can be used only with embedded Type1 fonts", - fm->tfm_name); - a += 4; - } - - /* the value of SlantFont and ExtendFont must be reasonable */ - if (abs(fm->slant) > 1000) { - if (warn) - pdftex_warn - ("invalid entry for `%s': too big value of SlantFont (%g)", - fm->tfm_name, fm->slant / 1000.0); - a += 8; - } - if (abs(fm->extend) > 2000) { - if (warn) - pdftex_warn - ("invalid entry for `%s': too big value of ExtendFont (%g)", - fm->tfm_name, fm->extend / 1000.0); - a += 16; - } - - /* subfonts must be used with subsetted non-reencoded TrueType fonts */ - if (fm->pid != -1 && - !(is_truetype(fm) && is_subsetted(fm) && !is_reencoded(fm))) { - if (warn) - pdftex_warn - ("invalid entry for `%s': PidEid can be used only with subsetted non-reencoded TrueType fonts", - fm->tfm_name); - a += 32; - } - - return a; -} - -/**********************************************************************/ -/* returns the font number if s is one of the 14 std. font names, -1 otherwise; speed-trimmed. */ - -int check_std_t1font(char *s) -{ - static const char *std_t1font_names[] = { - "Courier", /* 0:7 */ - "Courier-Bold", /* 1:12 */ - "Courier-Oblique", /* 2:15 */ - "Courier-BoldOblique", /* 3:19 */ - "Helvetica", /* 4:9 */ - "Helvetica-Bold", /* 5:14 */ - "Helvetica-Oblique", /* 6:17 */ - "Helvetica-BoldOblique", /* 7:21 */ - "Symbol", /* 8:6 */ - "Times-Roman", /* 9:11 */ - "Times-Bold", /* 10:10 */ - "Times-Italic", /* 11:12 */ - "Times-BoldItalic", /* 12:16 */ - "ZapfDingbats" /* 13:12 */ - }; - static const int index[] = - { -1, -1, -1, -1, -1, -1, 8, 0, -1, 4, 10, 9, -1, -1, 5, 2, 12, 6, -1, - 3, -1, 7 - }; - size_t n; - int k = -1; - assert(s != NULL); - n = strlen(s); - if (n > 21) - return -1; - if (n == 12) { /* three names have length 12 */ - switch (*s) { - case 'C': - k = 1; /* Courier-Bold */ - break; - case 'T': - k = 11; /* Times-Italic */ - break; - case 'Z': - k = 13; /* ZapfDingbats */ - break; - default: - return -1; - } - } else - k = index[n]; - if (k > -1 && !strcmp(std_t1font_names[k], s)) - return k; - return -1; -}; - - -/**********************************************************************/ - -static void fm_scan_line(void) -{ - int a, b, c, j, u = 0, v = 0; - float d; - fm_entry *fm; - char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE]; - char *p, *q, *r, *s; - switch (mitem->type) { - case MAPFILE: - p = fm_line; - while (!fm_eof()) { - if (fm_curbyte == fm_size) { - fm_curbyte++; - c = 10; - } else { - c = fm_getchar(); - } - append_char_to_buf(c, p, fm_line, FM_BUF_SIZE); - if (c == 10) - break; - } - *(--p) = '\0'; - r = fm_line; - break; - case MAPLINE: - r = mitem->line; /* work on string from makecstring() */ - break; - default: - assert(0); - } - if (*r == '\0' || is_cfg_comment(*r)) - return; - fm = new_fm_entry(); - read_field(r, q, buf); - set_field(tfm_name); - if (!isdigit(*r)) { /* 2nd field ps_name may not start with a digit */ - read_field(r, q, buf); - set_field(ps_name); - } - if (isdigit(*r)) { /* font descriptor /Flags given? */ - for (s = r; isdigit(*s); s++); - if (*s == ' ' || *s == '"' || *s == '<' || *s == '\0') { /* not e. g. 8r.enc */ - fm->fd_flags = atoi(r); - while (isdigit(*r)) - r++; - } - } - while (1) { /* loop through "specials", encoding, font file */ - skip(r, ' '); - switch (*r) { - case '\0': - goto done; - case '"': /* opening quote */ - r++; - u = v = 0; - do { - skip(r, ' '); - if (sscanf(r, "%f %n", &d, &j) > 0) { - s = r + j; /* jump behind number, eat also blanks, if any */ - if (*(s - 1) == 'E' || *(s - 1) == 'e') - s--; /* e. g. 0.5ExtendFont: %f = 0.5E */ - if (str_prefix(s, "SlantFont")) { - d *= 1000.0; /* correct rounding also for neg. numbers */ - fm->slant = (integer) (d > 0 ? d + 0.5 : d - 0.5); - r = s + strlen("SlantFont"); - } else if (str_prefix(s, "ExtendFont")) { - d *= 1000.0; - fm->extend = (integer) (d > 0 ? d + 0.5 : d - 0.5); - if (fm->extend == 1000) - fm->extend = 0; - r = s + strlen("ExtendFont"); - } else { /* unknown name */ - for (r = s; *r != ' ' && *r != '"' && *r != '\0'; r++); /* jump over name */ - c = *r; /* remember char for temporary end of string */ - *r = '\0'; - pdftex_warn - ("invalid entry for `%s': unknown name `%s' ignored", - fm->tfm_name, s); - *r = c; - } - } else - for (; *r != ' ' && *r != '"' && *r != '\0'; r++); - } - while (*r == ' '); - if (*r == '"') /* closing quote */ - r++; - else { - pdftex_warn - ("invalid entry for `%s': closing quote missing", - fm->tfm_name); - goto bad_line; - } - break; - case 'P': /* handle cases for subfonts like 'PidEid=3,1' */ - if (sscanf(r, "PidEid=%i, %i %n", &a, &b, &c) >= 2) { - fm->pid = a; - fm->eid = b; - r += c; - break; - } - default: /* encoding or font file specification */ - a = b = 0; - if (*r == '<') { - a = *r++; - if (*r == '<' || *r == '[') - b = *r++; - } - read_field(r, q, buf); - /* encoding, formats: '8r.enc' or '<8r.enc' or '<[8r.enc' */ - if (strlen(buf) > 4 && strcasecmp(strend(buf) - 4, ".enc") == 0) { - fm->encname = add_encname(buf); - u = v = 0; /* u, v used if intervening blank: "<< foo" */ - } else if (strlen(buf) > 0) { /* file name given */ - /* font file, formats: - * subsetting: ' no subsetting */ - } - set_field(ff_name); - u = v = 0; - } else { - u = a; - v = b; - } - } - } - done: - if (fm->ps_name != NULL && (check_std_t1font(fm->ps_name) >= 0)) - set_std_t1font(fm); - if (is_fontfile(fm) && strlen(fm_fontfile(fm)) > 3) { - if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".ttf") == 0) - set_truetype(fm); - else if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".otf") == 0) - set_opentype(fm); - else - set_type1(fm); - } else - set_type1(fm); /* assume a builtin font is Type1 */ - if (check_fm_entry(fm, true) != 0) - goto bad_line; - /* - Until here the map line has been completely scanned without errors; - fm points to a valid, freshly filled-out fm_entry structure. - Now follows the actual work of registering/deleting. - */ - if (handle_subfont_fm(fm, mitem->mode)) /* is this a subfont? */ - return; - if (avl_do_entry(fm, mitem->mode) == 0) /* if success */ - return; - bad_line: - delete_fm_entry(fm); -} - -/**********************************************************************/ - -void fm_read_info(void) -{ - int callback_id; - int file_opened = 0; - char *ftemp = NULL; - if (tfm_tree == NULL) - create_avl_trees(); - if (mitem->line == NULL) /* nothing to do */ - return; - mitem->lineno = 1; - switch (mitem->type) { - case MAPFILE: - set_cur_file_name(mitem->line); - if (fm_buffer != NULL) { - xfree(fm_buffer); - fm_buffer = NULL; - } - fm_curbyte = 0; - fm_size = 0; - callback_id = callback_defined(find_map_file_callback); - if (callback_id > 0) { - if (run_callback - (callback_id, "S->S", (char *) (nameoffile + 1), &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } - } - } else { - ftemp = - kpse_find_file((char *) (nameoffile + 1), kpse_fontmap_format, - 0); - if (ftemp != NULL) { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } - } - callback_id = callback_defined(read_map_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", (char *) (nameoffile + 1), - &file_opened, &fm_buffer, &fm_size)) { - if (file_opened) { - if (fm_size > 0) { - cur_file_name = (char *) nameoffile + 1; - if (tracefilenames) - tex_printf("{%s", cur_file_name); - while (!fm_eof()) { - fm_scan_line(); - mitem->lineno++; - } - if (tracefilenames) - tex_printf("}"); - fm_file = NULL; - } - } else { - pdftex_warn("cannot open font map file"); - } - } else { - pdftex_warn("cannot open font map file"); - } - } else { - if (!fm_open()) { - pdftex_warn("cannot open font map file"); - } else { - fm_read_file(); - cur_file_name = (char *) nameoffile + 1; - tex_printf("{%s", cur_file_name); - while (!fm_eof()) { - fm_scan_line(); - mitem->lineno++; - } - fm_close(); - tex_printf("}"); - fm_file = NULL; - } - } - break; - case MAPLINE: - cur_file_name = NULL; /* makes pdftex_warn() shorter */ - fm_scan_line(); - break; - default: - assert(0); - } - mitem->line = NULL; /* done with this line */ - cur_file_name = NULL; - return; -} - -/**********************************************************************/ - -static fm_entry_ptr fmlookup(internalfontnumber f) -{ - char *tfm; - fm_entry *fm; - fm_entry tmp; - if (tfm_tree == NULL) - fm_read_info(); /* only to read default map file */ - tfm = font_name(f); - assert(strcmp(tfm, nontfm)); - - /* Look up for full [+-] */ - tmp.tfm_name = tfm; - fm = (fm_entry *) avl_find(tfm_tree, &tmp); - if (fm != NULL) { - fm->in_use = true; - return (fm_entry_ptr) fm; - } - return (fm_entry_ptr) dummy_fm_entry(); -} - -boolean hasfmentry(internalfontnumber f) -{ - if (font_map(f) == NULL) - set_font_map(f, (fm_entry_ptr) fmlookup(f)); - assert(font_map(f) != NULL); - return font_map(f) != (fm_entry_ptr) dummy_fm_entry(); -} - -/* check whether a map entry is valid for font replacement */ - -static boolean fm_valid_for_font_replacement(fm_entry * fm) -{ - ff_entry *ff; - - assert(fm != NULL); - assert(is_fontfile(fm)); /* ps_tree should contain only entries with font file */ - assert(is_type1(fm)); /* ps_tree should contain only Type1 entries */ - - ff = check_ff_exist(fm->ff_name, false); - assert(ff != NULL); - if (ff->ff_path == NULL) /* ...there is no font file available */ - return false; - return true; /* all tests passed */ -} - -/**********************************************************************/ -/* - * lookup fontmap by ps_name; - * used for Type1 font replacement when embedding of PDF files - */ - -fm_entry *lookup_fontmap(char *ps_name) -{ - fm_entry *fm, *fm2, tmp; - char *a, *b, *c, *d, *e, *s; - int i, sl, ex; - struct avl_traverser t, t2; - if (tfm_tree == NULL) - fm_read_info(); /* only to read default map file */ - assert(ps_name != NULL); - s = ps_name; - if (strlen(ps_name) > 7) { /* check for subsetted name tag */ - for (i = 0; i < 6; i++, s++) - if (*s < 'A' || *s > 'Z') - break; - if (i == 6 && *s == '+') - s++; /* if name tag found, skip behind it */ - else - s = ps_name; - } - - /* - * Scan -Slant_ and -Extend_ font name extensions; - * three valid formats: - * -Slant_ - * -Slant_-Extend_ - * -Extend_ - * Slant entry must come _before_ Extend entry - */ - - tmp.slant = 0; - tmp.extend = 0; - if ((a = strstr(s, "-Slant_")) != NULL) { - b = a + strlen("-Slant_"); - sl = (int) strtol(b, &e, 10); - if ((e != b) && (e == strend(b))) { - tmp.slant = sl; - *a = '\0'; /* ps_name string ends before "-Slant_" */ - } else { - if (e != b) { /* only if is valid number */ - if ((c = strstr(e, "-Extend_")) != NULL) { - d = c + strlen("-Extend_"); - ex = (int) strtol(d, &e, 10); - if ((e != d) && (e == strend(d))) { - tmp.slant = sl; - tmp.extend = ex; - *a = '\0'; /* ps_name string ends before "-Slant_" */ - } - } - } - } - } else { - if ((a = strstr(s, "-Extend_")) != NULL) { - b = a + strlen("-Extend_"); - ex = (int) strtol(b, &e, 10); - if ((e != b) && (e == strend(b))) { - tmp.extend = ex; - *a = '\0'; /* ps_name string ends before "-Extend_" */ - } - } - } - tmp.ps_name = s; - - fm = (fm_entry *) avl_t_find(&t, ps_tree, &tmp); - if (fm == NULL) - return NULL; /* no entry found */ - - /* at this point we know there is at least one fm_entry with given ps_name; - * we test all such entries and return the first one that is valid for font - * replacement */ - - t2 = t; - fm2 = (fm_entry *) avl_t_prev(&t2); - - /* search forward */ - do { - if (fm_valid_for_font_replacement(fm)) - return fm; - fm = (fm_entry *) avl_t_next(&t); - } while (fm != NULL && comp_fm_entry_ps(fm, &tmp, NULL) == 0); - - /* search backward */ - while (fm2 != NULL && comp_fm_entry_ps(fm2, &tmp, NULL) == 0) { - if (fm_valid_for_font_replacement(fm2)) - return fm2; - fm2 = (fm_entry *) avl_t_prev(&t2); - } - - return NULL; -} - -/**********************************************************************/ -/* - * Process map file given by its name or map line contents. Items not - * beginning with [+-=] flush default map file, if it has not yet been - * read. Leading blanks and blanks immediately following [+-=] are - * ignored. - */ - -static void process_map_item(char *s, int type) -{ - char *p; - int mode; - if (*s == ' ') - s++; /* ignore leading blank */ - switch (*s) { - case '+': /* +mapfile.map, +mapline */ - mode = FM_DUPIGNORE; /* insert entry, if it is not duplicate */ - s++; - break; - case '=': /* =mapfile.map, =mapline */ - mode = FM_REPLACE; /* try to replace earlier entry */ - s++; - break; - case '-': /* -mapfile.map, -mapline */ - mode = FM_DELETE; /* try to delete entry */ - s++; - break; - default: - mode = FM_DUPIGNORE; /* like +, but also: */ - mitem->line = NULL; /* flush default map file name */ - } - if (*s == ' ') - s++; /* ignore blank after [+-=] */ - p = s; /* map item starts here */ - switch (type) { - case MAPFILE: /* remove blank at end */ - while (*p != '\0' && *p != ' ') - p++; - *p = '\0'; - break; - case MAPLINE: /* blank at end allowed */ - break; - default: - assert(0); - } - if (mitem->line != NULL) /* read default map file first */ - fm_read_info(); - if (*s != '\0') { /* only if real item to process */ - mitem->mode = mode; - mitem->type = type; - mitem->line = s; - fm_read_info(); - } -} - -void pdfmapfile(integer t) -{ - process_map_item(makecstring(tokens_to_string(t)), MAPFILE); - flush_str(last_tokens_string); -} - -void pdfmapline(integer t) -{ - process_map_item(makecstring(tokens_to_string(t)), MAPLINE); - flush_str(last_tokens_string); -} - -void pdf_init_map_file(string map_name) -{ - assert(mitem == NULL); - mitem = xtalloc(1, mapitem); - mitem->mode = FM_DUPIGNORE; - mitem->type = MAPFILE; - mitem->line = map_name; -} - -/**********************************************************************/ -/* - * Early check whether a font file exists. Search tree ff_tree is used - * in 1st instance, as it may be faster than the kpse_find_file(), and - * kpse_find_file() is called only once per font file name + expansion - * parameter. This might help keeping speed, if many PDF pages with - * same fonts are to be embedded. - * - * The ff_tree contains only font files, which are actually needed, - * so this tree typically is much smaller than the tfm_tree or ps_tree. - */ - -ff_entry *check_ff_exist(char *ff_name, boolean is_tt) -{ - ff_entry *ff; - ff_entry tmp; - void **aa; - int callback_id; - char *filepath = NULL; - - assert(ff_name != NULL); - tmp.ff_name = ff_name; - ff = (ff_entry *) avl_find(ff_tree, &tmp); - if (ff == NULL) { /* not yet in database */ - ff = new_ff_entry(); - ff->ff_name = xstrdup(ff_name); - if (is_tt) { - callback_id = callback_defined(find_truetype_file_callback); - if (callback_id > 0) { - run_callback(callback_id, "S->S", ff_name, &filepath); - if (filepath && strlen(filepath) == 0) - filepath = NULL; - ff->ff_path = filepath; - } else { - ff->ff_path = kpse_find_file(ff_name, kpse_truetype_format, 0); - } - } else { - callback_id = callback_defined(find_type1_file_callback); - if (callback_id > 0) { - run_callback(callback_id, "S->S", ff_name, &filepath); - if (filepath && strlen(filepath) == 0) - filepath = NULL; - ff->ff_path = filepath; - } else { - ff->ff_path = kpse_find_file(ff_name, kpse_type1_format, 0); - } - } - aa = avl_probe(ff_tree, ff); - assert(aa != NULL); - } - return ff; -} - -/**********************************************************************/ - -int is_subsetable(fm_entry * fm) -{ - assert(is_included(fm)); - return is_subsetted(fm); -} - -/**********************************************************************/ -/* cleaning up... */ - -static void destroy_fm_entry_tfm(void *pa, void *pb) -{ - fm_entry *fm; - (void) pb; - fm = (fm_entry *) pa; - if (!has_pslink(fm)) - delete_fm_entry(fm); - else - unset_tfmlink(fm); -} - -static void destroy_fm_entry_ps(void *pa, void *pb) -{ - fm_entry *fm; - (void) pb; - fm = (fm_entry *) pa; - if (!has_tfmlink(fm)) - delete_fm_entry(fm); - else - unset_pslink(fm); -} - -static void destroy_ff_entry(void *pa, void *pb) -{ - ff_entry *ff; - (void) pb; - ff = (ff_entry *) pa; - delete_ff_entry(ff); -} - -void fm_free(void) -{ - if (tfm_tree != NULL) { - avl_destroy(tfm_tree, destroy_fm_entry_tfm); - tfm_tree = NULL; - } - if (ps_tree != NULL) { - avl_destroy(ps_tree, destroy_fm_entry_ps); - ps_tree = NULL; - } - if (ff_tree != NULL) { - avl_destroy(ff_tree, destroy_ff_entry); - ff_tree = NULL; - } -} - -/**********************************************************************/ -/* end of mapfile.c */ diff --git a/Build/source/texk/web2c/luatexdir/font/mapfile.h b/Build/source/texk/web2c/luatexdir/font/mapfile.h index e4242a21255..544ebd9c9c3 100644 --- a/Build/source/texk/web2c/luatexdir/font/mapfile.h +++ b/Build/source/texk/web2c/luatexdir/font/mapfile.h @@ -17,39 +17,48 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: mapfile.h 2331 2009-04-18 16:39:50Z hhenkel $ */ +/* $Id: mapfile.h 3404 2010-01-28 11:17:10Z taco $ */ #ifndef MAPFILE_H # define MAPFILE_H -# define F_INCLUDED 0x01 -# define F_SUBSETTED 0x02 -# define F_STDT1FONT 0x04 -# define F_SUBFONT 0x08 -# define F_TYPE1 0x10 -# define F_TRUETYPE 0x20 -# define F_OTF 0x40 -# define F_CIDKEYED 0x80 - -# define set_included(fm) ((fm)->type |= F_INCLUDED) -# define set_subsetted(fm) ((fm)->type |= F_SUBSETTED) -# define set_std_t1font(fm) ((fm)->type |= F_STDT1FONT) -# define set_subfont(fm) ((fm)->type |= F_SUBFONT) -# define set_type1(fm) ((fm)->type |= F_TYPE1) -# define set_truetype(fm) ((fm)->type |= F_TRUETYPE) -# define set_opentype(fm) ((fm)->type |= F_OTF) -# define set_subfont(fm) ((fm)->type |= F_SUBFONT) -# define set_cidkeyed(fm) ((fm)->type |= F_CIDKEYED) - -# define unset_included(fm) ((fm)->type &= ~F_INCLUDED) -# define unset_subsetted(fm) ((fm)->type &= ~F_SUBSETTED) -# define unset_std_t1font(fm)((fm)->type &= ~F_STDT1FONT) -# define unset_subfont(fm) ((fm)->type &= ~F_SUBFONT) -# define unset_type1(fm) ((fm)->type &= ~F_TYPE1) -# define unset_truetype(fm) ((fm)->type &= ~F_TRUETYPE) -# define unset_opentype(fm) ((fm)->type &= ~F_OTF) -# define unset_subfont(fm) ((fm)->type &= ~F_SUBFONT) -# define unset_cidkeyed(fm) ((fm)->type &= ~F_CIDKEYED) +# define F_INCLUDED (1 << 0) +# define F_SUBSETTED (1 << 1) +# define F_STDT1FONT (1 << 2) +# define F_SUBFONT (1 << 3) +# define F_TYPE1 (1 << 4) +# define F_TRUETYPE (1 << 5) +# define F_OTF (1 << 6) +# define F_CIDKEYED (1 << 7) +# define F_SLANTSET (1 << 8) +# define F_EXTENDSET (1 << 9) +# define F_INUSE (1 << 10) + +typedef enum { MAPFILE, MAPLINE } maptype; + +# define set_included(fm) ((fm)->type = (unsigned short)((fm)->type | F_INCLUDED)) +# define set_subsetted(fm) ((fm)->type = (unsigned short)((fm)->type | F_SUBSETTED)) +# define set_std_t1font(fm) ((fm)->type = (unsigned short)((fm)->type | F_STDT1FONT)) +# define set_subfont(fm) ((fm)->type = (unsigned short)((fm)->type | F_SUBFONT)) +# define set_type1(fm) ((fm)->type = (unsigned short)((fm)->type | F_TYPE1)) +# define set_truetype(fm) ((fm)->type = (unsigned short)((fm)->type | F_TRUETYPE)) +# define set_opentype(fm) ((fm)->type = (unsigned short)((fm)->type | F_OTF)) +# define set_cidkeyed(fm) ((fm)->type = (unsigned short)((fm)->type | F_CIDKEYED)) +# define set_slantset(fm) ((fm)->type = (unsigned short)((fm)->type | F_SLANTSET)) +# define set_extendset(fm) ((fm)->type = (unsigned short)((fm)->type | F_EXTENDSET)) +# define set_inuse(fm) ((fm)->type = (unsigned short)((fm)->type | F_INUSE)) + +# define unset_included(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_INCLUDED)) +# define unset_subsetted(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SUBSETTED)) +# define unset_std_t1font(fm)((fm)->type = (unsigned short)((fm)->type & ~F_STDT1FONT)) +# define unset_subfont(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SUBFONT)) +# define unset_type1(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_TYPE1)) +# define unset_truetype(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_TRUETYPE)) +# define unset_opentype(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_OTF)) +# define unset_cidkeyed(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_CIDKEYED)) +# define unset_slantset(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SLANTSET)) +# define unset_extendset(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_EXTENDSET)) +# define unset_inuse(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_INUSE)) # define is_included(fm) (((fm)->type & F_INCLUDED) != 0) # define is_subsetted(fm) (((fm)->type & F_SUBSETTED) != 0) @@ -58,8 +67,10 @@ # define is_type1(fm) (((fm)->type & F_TYPE1) != 0) # define is_truetype(fm) (((fm)->type & F_TRUETYPE) != 0) # define is_opentype(fm) (((fm)->type & F_OTF) != 0) -# define is_subfont(fm) (((fm)->type & F_SUBFONT) != 0) # define is_cidkeyed(fm) (((fm)->type & F_CIDKEYED) != 0) +# define is_slantset(fm) (((fm)->type & F_SLANTSET) != 0) +# define is_extendset(fm) (((fm)->type & F_EXTENDSET) != 0) +# define is_inuse(fm) (((fm)->type & F_INUSE) != 0) # define fm_slant(fm) (fm)->slant # define fm_extend(fm) (fm)->extend @@ -70,15 +81,6 @@ # define is_t1fontfile(fm) (is_fontfile(fm) && is_type1(fm)) # define is_builtin(fm) (!is_fontfile(fm)) -# define LINK_TFM 0x01 -# define LINK_PS 0x02 -# define set_tfmlink(fm) ((fm)->links |= LINK_TFM) -# define set_pslink(fm) ((fm)->links |= LINK_PS) -# define unset_tfmlink(fm) ((fm)->links &= ~LINK_TFM) -# define unset_pslink(fm) ((fm)->links &= ~LINK_PS) -# define has_tfmlink(fm) ((fm)->links & LINK_TFM) -# define has_pslink(fm) ((fm)->links & LINK_PS) - /**********************************************************************/ typedef struct { @@ -86,9 +88,9 @@ typedef struct { char *tfm_name; /* TFM file name (1st field in map line) */ char *sfd_name; /* subfont directory name, like @sfd_name@ */ char *ps_name; /* PostScript name (optional 2nd field in map line) */ - integer fd_flags; /* font descriptor /Flags (PDF Ref. section 5.7.1) */ - integer slant; /* SlantFont */ - integer extend; /* ExtendFont */ + int fd_flags; /* font descriptor /Flags (PDF Ref. section 5.7.1) */ + int slant; /* SlantFont */ + int extend; /* ExtendFont */ char *encname; /* encoding file name */ char *ff_name; /* font file name */ unsigned short type; /* various flags */ @@ -96,8 +98,6 @@ typedef struct { short eid; /* Eid for truetype fonts */ /* parameters NOT scanned from the map file: */ subfont_entry *subfont; /* subfont mapping */ - unsigned short links; /* link flags from tfm_tree and ps_tree */ - boolean in_use; /* true if this structure has been referenced already */ } fm_entry; typedef struct { @@ -107,18 +107,24 @@ typedef struct { /**********************************************************************/ -fm_entry *lookup_fontmap(char *); -boolean hasfmentry(internalfontnumber); +# define FONT_SLANT_MIN -2000 +# define FONT_SLANT_MAX 2000 +# define FONT_EXTEND_MIN -5000 +# define FONT_EXTEND_MAX 5000 + +/**********************************************************************/ + +fm_entry *getfontmap(char *tfm_name); void fm_free(void); -void fm_read_info(void); ff_entry *check_ff_exist(char *, boolean); -void pdfmapfile(integer); -void pdfmapline(integer); -void pdf_init_map_file(string map_name); +void pdfmapfile(int); +void pdfmapline(int); +void pdf_init_map_file(char *map_name); fm_entry *new_fm_entry(void); void delete_fm_entry(fm_entry *); int avl_do_entry(fm_entry *, int); int check_std_t1font(char *s); int is_subsetable(fm_entry * fm); +void process_map_item(char *s, int type); #endif /* MAPFILE_H */ diff --git a/Build/source/texk/web2c/luatexdir/font/mapfile.w b/Build/source/texk/web2c/luatexdir/font/mapfile.w new file mode 100644 index 00000000000..3d129183d6f --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/mapfile.w @@ -0,0 +1,752 @@ +@ @c +/* mapfile.c + + Copyright 1996-2006 Han The Thanh + Copyright 2006-2010 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ + +static const char _svn_version[] = + "$Id: mapfile.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/mapfile.w $"; + +#include +#include "ptexlib.h" +#include +#include +#include + +#define FM_BUF_SIZE 1024 + +static FILE *fm_file; + +static unsigned char *fm_buffer = NULL; +static int fm_size = 0; +static int fm_curbyte = 0; + +#define fm_open(a) (fm_file = fopen((char *)(a), FOPEN_RBIN_MODE)) +#define fm_read_file() readbinfile(fm_file,&fm_buffer,&fm_size) +#define fm_close() xfclose(fm_file, cur_file_name) +#define fm_getchar() fm_buffer[fm_curbyte++] +#define fm_eof() (fm_curbyte>fm_size) +#define is_cfg_comment(c) \ + (c == 10 || c == '*' || c == '#' || c == ';' || c == '%') + +typedef enum { FM_DUPIGNORE, FM_REPLACE, FM_DELETE } updatemode; + +typedef struct mitem { + updatemode mode; /* FM_DUPIGNORE or FM_REPLACE or FM_DELETE */ + maptype type; /* map file or map line */ + char *line; /* pointer to map file name or map line */ + int lineno; /* line number in map file */ +} mapitem; +mapitem *mitem = NULL; + +#define read_field(r, q, buf) do { \ + q = buf; \ + while (*r != ' ' && *r != '<' && *r != '"' && *r != '\0') \ + *q++ = *r++; \ + *q = '\0'; \ + skip (r, ' '); \ +} while (0) + +#define set_field(F) do { \ + if (q > buf) \ + fm->F = xstrdup(buf); \ + if (*r == '\0') \ + goto done; \ +} while (0) + +fm_entry *new_fm_entry(void) +{ + fm_entry *fm; + fm = xtalloc(1, fm_entry); + fm->tfm_name = NULL; + fm->sfd_name = NULL; + fm->ps_name = NULL; + fm->fd_flags = FD_FLAGS_NOT_SET_IN_MAPLINE; + fm->ff_name = NULL; + fm->encname = NULL; + fm->type = 0; + fm->slant = 0; + fm->extend = 1000; + fm->pid = -1; + fm->eid = -1; + fm->subfont = NULL; + unset_slantset(fm); + unset_extendset(fm); + unset_inuse(fm); + return fm; +} + +void delete_fm_entry(fm_entry * fm) +{ + xfree(fm->tfm_name); + xfree(fm->sfd_name); + xfree(fm->ps_name); + xfree(fm->ff_name); + xfree(fm); +} + +static ff_entry *new_ff_entry(void) +{ + ff_entry *ff; + ff = xtalloc(1, ff_entry); + ff->ff_name = NULL; + ff->ff_path = NULL; + return ff; +} + +static void delete_ff_entry(ff_entry * ff) +{ + xfree(ff->ff_name); + xfree(ff->ff_path); + xfree(ff); +} + +/**********************************************************************/ + +static struct avl_table *tfm_tree = NULL; +static struct avl_table *ff_tree = NULL; +static struct avl_table *encname_tree = NULL; + +/* AVL sort fm_entry into tfm_tree by tfm_name */ + +static int comp_fm_entry_tfm(const void *pa, const void *pb, void *p) +{ + (void) p; + return strcmp(((const fm_entry *) pa)->tfm_name, + ((const fm_entry *) pb)->tfm_name); +} + +/* AVL sort ff_entry into ff_tree by ff_name */ + +static int comp_ff_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return strcmp(((const ff_entry *) pa)->ff_name, + ((const ff_entry *) pb)->ff_name); +} + +static void create_avl_trees(void) +{ + assert(tfm_tree == NULL); + tfm_tree = avl_create(comp_fm_entry_tfm, NULL, &avl_xallocator); + assert(tfm_tree != NULL); + assert(ff_tree == NULL); + ff_tree = avl_create(comp_ff_entry, NULL, &avl_xallocator); + assert(ff_tree != NULL); + assert(encname_tree == NULL); + encname_tree = avl_create(comp_string_entry, NULL, &avl_xallocator); + assert(encname_tree != NULL); +} + +int avl_do_entry(fm_entry * fm, int mode) +{ + fm_entry *p; + void *a; + void **aa; + int delete_new = 0; + if (tfm_tree == NULL) + create_avl_trees(); + p = (fm_entry *) avl_find(tfm_tree, fm); + if (p != NULL) { + switch (mode) { + case FM_DUPIGNORE: + pdftex_warn + ("fontmap entry for `%s' already exists, duplicates ignored", + fm->tfm_name); + delete_new = 1; + break; + case FM_REPLACE: + case FM_DELETE: + if (is_inuse(p)) { + pdftex_warn + ("fontmap entry for `%s' has been used, replace/delete not allowed", + fm->tfm_name); + delete_new = 1; + } else { + a = avl_delete(tfm_tree, p); + assert(a != NULL); + delete_fm_entry(p); + } + break; + default: + assert(0); + } + } + if ((mode == FM_DUPIGNORE || mode == FM_REPLACE) && delete_new == 0) { + aa = avl_probe(tfm_tree, fm); + assert(aa != NULL); + } else + delete_new = 1; + return delete_new; +} + +/* add the encoding name to an AVL tree. this has nothing to do with writeenc.c */ + +static char *add_encname(char *s) +{ + char *p; + void **aa; + assert(s != NULL); + assert(encname_tree != NULL); + if ((p = (char *) avl_find(encname_tree, s)) == NULL) { /* encoding name not yet registered */ + p = xstrdup(s); + aa = avl_probe(encname_tree, p); + assert(aa != NULL); + } + return p; +} + +/**********************************************************************/ +/* consistency check for map entry, with warn flag */ + +static int check_fm_entry(fm_entry * fm, boolean warn) +{ + int a = 0; + assert(fm != NULL); + + if (is_fontfile(fm) && !is_included(fm)) { + if (warn) + pdftex_warn + ("ambiguous entry for `%s': font file present but not included, " + "will be treated as font file not present", fm->tfm_name); + xfree(fm->ff_name); + /* do not set variable |a| as this entry will be still accepted */ + } + + /* if both ps_name and font file are missing, drop this entry */ + if (fm->ps_name == NULL && !is_fontfile(fm)) { + if (warn) + pdftex_warn + ("invalid entry for `%s': both ps_name and font file missing", + fm->tfm_name); + a += 1; + } + + /* TrueType fonts cannot be reencoded without subsetting */ + if (is_truetype(fm) && is_reencoded(fm) && !is_subsetted(fm)) { + if (warn) + pdftex_warn + ("invalid entry for `%s': only subsetted TrueType font can be reencoded", + fm->tfm_name); + a += 2; + } + + /* the value of SlantFont and ExtendFont must be reasonable */ + if (fm->slant < FONT_SLANT_MIN || fm->slant > FONT_SLANT_MAX) { + if (warn) + pdftex_warn + ("invalid entry for `%s': too big value of SlantFont (%g)", + fm->tfm_name, fm->slant / 1000.0); + a += 8; + } + if (fm->extend < FONT_EXTEND_MIN || fm->extend > FONT_EXTEND_MAX) { + if (warn) + pdftex_warn + ("invalid entry for `%s': too big value of ExtendFont (%g)", + fm->tfm_name, fm->extend / 1000.0); + a += 16; + } + + /* subfonts must be used with subsetted non-reencoded TrueType fonts */ + if (fm->pid != -1 && + !(is_truetype(fm) && is_subsetted(fm) && !is_reencoded(fm))) { + if (warn) + pdftex_warn + ("invalid entry for `%s': PidEid can be used only with subsetted non-reencoded TrueType fonts", + fm->tfm_name); + a += 32; + } + + return a; +} + +/**********************************************************************/ +/* returns the font number if s is one of the 14 std. font names, -1 otherwise; speed-trimmed. */ + +int check_std_t1font(char *s) +{ + static const char *std_t1font_names[] = { + "Courier", /* 0:7 */ + "Courier-Bold", /* 1:12 */ + "Courier-Oblique", /* 2:15 */ + "Courier-BoldOblique", /* 3:19 */ + "Helvetica", /* 4:9 */ + "Helvetica-Bold", /* 5:14 */ + "Helvetica-Oblique", /* 6:17 */ + "Helvetica-BoldOblique", /* 7:21 */ + "Symbol", /* 8:6 */ + "Times-Roman", /* 9:11 */ + "Times-Bold", /* 10:10 */ + "Times-Italic", /* 11:12 */ + "Times-BoldItalic", /* 12:16 */ + "ZapfDingbats" /* 13:12 */ + }; + static const int index[] = + { -1, -1, -1, -1, -1, -1, 8, 0, -1, 4, 10, 9, -1, -1, 5, 2, 12, 6, -1, + 3, -1, 7 + }; + size_t n; + int k = -1; + assert(s != NULL); + n = strlen(s); + if (n > 21) + return -1; + if (n == 12) { /* three names have length 12 */ + switch (*s) { + case 'C': + k = 1; /* Courier-Bold */ + break; + case 'T': + k = 11; /* Times-Italic */ + break; + case 'Z': + k = 13; /* ZapfDingbats */ + break; + default: + return -1; + } + } else + k = index[n]; + if (k > -1 && !strcmp(std_t1font_names[k], s)) + return k; + return -1; +} + +/**********************************************************************/ + +static void fm_scan_line(void) +{ + int a, b, c, j, u = 0, v = 0; + char cc; + float d; + fm_entry *fm; + char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE]; + char *p, *q, *r, *s; + switch (mitem->type) { + case MAPFILE: + p = fm_line; + while (!fm_eof()) { + if (fm_curbyte == fm_size) { + fm_curbyte++; + cc = 10; + } else { + cc = (char) fm_getchar(); + } + append_char_to_buf(cc, p, fm_line, FM_BUF_SIZE); + if (cc == 10) + break; + } + *(--p) = '\0'; + r = fm_line; + break; + case MAPLINE: + r = mitem->line; /* work on string from makecstring() */ + break; + default: + assert(0); + } + if (*r == '\0' || is_cfg_comment(*r)) + return; + fm = new_fm_entry(); + read_field(r, q, buf); + set_field(tfm_name); + if (!isdigit(*r)) { /* 2nd field ps_name may not start with a digit */ + read_field(r, q, buf); + set_field(ps_name); + } + if (isdigit(*r)) { /* font descriptor /Flags given? */ + for (s = r; isdigit(*s); s++); + if (*s == ' ' || *s == '"' || *s == '<' || *s == '\0') { /* not e. g. 8r.enc */ + fm->fd_flags = atoi(r); + while (isdigit(*r)) + r++; + } + } + while (1) { /* loop through "specials", encoding, font file */ + skip(r, ' '); + switch (*r) { + case '\0': + goto done; + case '"': /* opening quote */ + r++; + u = v = 0; + do { + skip(r, ' '); + if (sscanf(r, "%f %n", &d, &j) > 0) { + s = r + j; /* jump behind number, eat also blanks, if any */ + if (*(s - 1) == 'E' || *(s - 1) == 'e') + s--; /* e. g. 0.5ExtendFont: %f = 0.5E */ + if (str_prefix(s, "SlantFont")) { + d *= (float) 1000.0; /* correct rounding also for neg. numbers */ + fm->slant = (int) (d > 0 ? d + 0.5 : d - 0.5); + set_slantset(fm); + r = s + strlen("SlantFont"); + } else if (str_prefix(s, "ExtendFont")) { + d *= (float) 1000.0; + fm->extend = (int) (d > 0 ? d + 0.5 : d - 0.5); + set_extendset(fm); + r = s + strlen("ExtendFont"); + } else { /* unknown name */ + for (r = s; *r != ' ' && *r != '"' && *r != '\0'; r++); /* jump over name */ + c = *r; /* remember char for temporary end of string */ + *r = '\0'; + pdftex_warn + ("invalid entry for `%s': unknown name `%s' ignored", + fm->tfm_name, s); + *r = (char) c; + } + } else + for (; *r != ' ' && *r != '"' && *r != '\0'; r++); + } + while (*r == ' '); + if (*r == '"') /* closing quote */ + r++; + else { + pdftex_warn + ("invalid entry for `%s': closing quote missing", + fm->tfm_name); + goto bad_line; + } + break; + case 'P': /* handle cases for subfonts like 'PidEid=3,1' */ + if (sscanf(r, "PidEid=%i, %i %n", &a, &b, &c) >= 2) { + fm->pid = (short) a; + fm->eid = (short) b; + r += c; + break; + } + default: /* encoding or font file specification */ + a = b = 0; + if (*r == '<') { + a = *r++; + if (*r == '<' || *r == '[') + b = *r++; + } + read_field(r, q, buf); + /* encoding, formats: '8r.enc' or '<8r.enc' or '<[8r.enc' */ + if (strlen(buf) > 4 && strcasecmp(strend(buf) - 4, ".enc") == 0) { + fm->encname = add_encname(buf); + u = v = 0; /* u, v used if intervening blank: "<< foo" */ + } else if (strlen(buf) > 0) { /* file name given */ + /* font file, formats: + * subsetting: ' no subsetting */ + } + set_field(ff_name); + u = v = 0; + } else { + u = a; + v = b; + } + } + } + done: + if (fm->ps_name != NULL && (check_std_t1font(fm->ps_name) >= 0)) + set_std_t1font(fm); + if (is_fontfile(fm) && strlen(fm_fontfile(fm)) > 3) { + if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".ttf") == 0) + set_truetype(fm); + else if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".ttc") == 0) + set_truetype(fm); + else if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".otf") == 0) + set_opentype(fm); + else + set_type1(fm); + } else + set_type1(fm); /* assume a builtin font is Type1 */ + if (check_fm_entry(fm, true) != 0) + goto bad_line; + /* + Until here the map line has been completely scanned without errors; + fm points to a valid, freshly filled-out fm_entry structure. + Now follows the actual work of registering/deleting. + */ + if (handle_subfont_fm(fm, mitem->mode)) /* is this a subfont? */ + return; + if (avl_do_entry(fm, mitem->mode) == 0) + return; + bad_line: + delete_fm_entry(fm); +} + +/**********************************************************************/ + +static void fm_read_info(void) +{ + int callback_id; + int file_opened = 0; + + if (tfm_tree == NULL) + create_avl_trees(); + if (mitem->line == NULL) /* nothing to do */ + return; + mitem->lineno = 1; + switch (mitem->type) { + case MAPFILE: + xfree(fm_buffer); + fm_curbyte = 0; + fm_size = 0; + cur_file_name = luatex_find_file(mitem->line, find_map_file_callback); + if (cur_file_name) { + callback_id = callback_defined(read_map_file_callback); + if (callback_id > 0) { + if (run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &fm_buffer, &fm_size)) { + if (file_opened) { + if (fm_size > 0) { + if (tracefilenames) + tex_printf("{%s", cur_file_name); + while (!fm_eof()) { + fm_scan_line(); + mitem->lineno++; + } + if (tracefilenames) + tex_printf("}"); + fm_file = NULL; + } + } else { + pdftex_warn("cannot open font map file"); + } + } else { + pdftex_warn("cannot open font map file"); + } + } else { + if (!fm_open(cur_file_name)) { + pdftex_warn("cannot open font map file"); + } else { + fm_read_file(); + tex_printf("{%s", cur_file_name); + while (!fm_eof()) { + fm_scan_line(); + mitem->lineno++; + } + fm_close(); + tex_printf("}"); + fm_file = NULL; + } + } + cur_file_name = NULL; + } + break; + case MAPLINE: + cur_file_name = NULL; /* makes pdftex_warn() shorter */ + fm_scan_line(); + break; + default: + assert(0); + } + mitem->line = NULL; /* done with this line */ + cur_file_name = NULL; + return; +} + +/**********************************************************************/ + +fm_entry *getfontmap(char *tfm_name) +{ + fm_entry *fm; + fm_entry tmp; + if (tfm_name == NULL) /* wide, lua loaded fonts may not have a name */ + return NULL; + if (tfm_tree == NULL) + fm_read_info(); /* only to read default map file */ + tmp.tfm_name = tfm_name; /* Look up for tfmname */ + fm = (fm_entry *) avl_find(tfm_tree, &tmp); + if (fm == NULL) + return NULL; + set_inuse(fm); + return fm; +} + +/**********************************************************************/ +/* + * Process map file given by its name or map line contents. Items not + * beginning with [+-=] flush default map file, if it has not yet been + * read. Leading blanks and blanks immediately following [+-=] are + * ignored. + */ + +void process_map_item(char *s, int type) +{ + char *p; + int mode; + if (*s == ' ') + s++; /* ignore leading blank */ + switch (*s) { + case '+': /* +mapfile.map, +mapline */ + mode = FM_DUPIGNORE; /* insert entry, if it is not duplicate */ + s++; + break; + case '=': /* =mapfile.map, =mapline */ + mode = FM_REPLACE; /* try to replace earlier entry */ + s++; + break; + case '-': /* -mapfile.map, -mapline */ + mode = FM_DELETE; /* try to delete entry */ + s++; + break; + default: + mode = FM_DUPIGNORE; /* like +, but also: */ + mitem->line = NULL; /* flush default map file name */ + } + if (*s == ' ') + s++; /* ignore blank after [+-=] */ + p = s; /* map item starts here */ + switch (type) { + case MAPFILE: /* remove blank at end */ + while (*p != '\0' && *p != ' ') + p++; + *p = '\0'; + break; + case MAPLINE: /* blank at end allowed */ + break; + default: + assert(0); + } + if (mitem->line != NULL) /* read default map file first */ + fm_read_info(); + if (*s != '\0') { /* only if real item to process */ + mitem->mode = mode; + mitem->type = type; + mitem->line = s; + fm_read_info(); + } +} + +void pdfmapfile(int t) +{ + char *s = tokenlist_to_cstring(t, true, NULL); + process_map_item(s, MAPFILE); + free(s); +} + +void pdfmapline(int t) +{ + char *s = tokenlist_to_cstring(t, true, NULL); + process_map_item(s, MAPLINE); + free(s); +} + +void pdf_init_map_file(char *map_name) +{ + assert(mitem == NULL); + mitem = xtalloc(1, mapitem); + mitem->mode = FM_DUPIGNORE; + mitem->type = MAPFILE; + mitem->line = map_name; +} + +/**********************************************************************/ +/* + * Early check whether a font file exists. Search tree ff_tree is used + * in 1st instance, as it may be faster than the kpse_find_file(), and + * kpse_find_file() is called only once per font file name + expansion + * parameter. This might help keeping speed, if many PDF pages with + * same fonts are to be embedded. + * + * The ff_tree contains only font files, which are actually needed, + * so this tree typically is much smaller than the tfm_tree. + */ + +ff_entry *check_ff_exist(char *ff_name, boolean is_tt) +{ + ff_entry *ff; + ff_entry tmp; + void **aa; + int callback_id; + char *filepath = NULL; + + assert(ff_name != NULL); + tmp.ff_name = ff_name; + ff = (ff_entry *) avl_find(ff_tree, &tmp); + if (ff == NULL) { /* not yet in database */ + ff = new_ff_entry(); + ff->ff_name = xstrdup(ff_name); + if (is_tt) { + callback_id = callback_defined(find_truetype_file_callback); + if (callback_id > 0) { + run_callback(callback_id, "S->S", ff_name, &filepath); + if (filepath && strlen(filepath) == 0) + filepath = NULL; + ff->ff_path = filepath; + } else { + ff->ff_path = kpse_find_file(ff_name, kpse_truetype_format, 0); + } + } else { + callback_id = callback_defined(find_type1_file_callback); + if (callback_id > 0) { + run_callback(callback_id, "S->S", ff_name, &filepath); + if (filepath && strlen(filepath) == 0) + filepath = NULL; + ff->ff_path = filepath; + } else { + ff->ff_path = kpse_find_file(ff_name, kpse_type1_format, 0); + } + } + aa = avl_probe(ff_tree, ff); + assert(aa != NULL); + } + return ff; +} + +/**********************************************************************/ + +int is_subsetable(fm_entry * fm) +{ + assert(is_included(fm)); + return is_subsetted(fm); +} + +/**********************************************************************/ +/* cleaning up... */ + +static void destroy_fm_entry_tfm(void *pa, void *pb) +{ + fm_entry *fm; + (void) pb; + fm = (fm_entry *) pa; + delete_fm_entry(fm); +} + +static void destroy_ff_entry(void *pa, void *pb) +{ + ff_entry *ff; + (void) pb; + ff = (ff_entry *) pa; + delete_ff_entry(ff); +} + +void fm_free(void) +{ + if (tfm_tree != NULL) { + avl_destroy(tfm_tree, destroy_fm_entry_tfm); + tfm_tree = NULL; + } + if (ff_tree != NULL) { + avl_destroy(ff_tree, destroy_ff_entry); + ff_tree = NULL; + } +} diff --git a/Build/source/texk/web2c/luatexdir/font/pkin.c b/Build/source/texk/web2c/luatexdir/font/pkin.c deleted file mode 100644 index 0576901ba65..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/pkin.c +++ /dev/null @@ -1,433 +0,0 @@ -/* pkin.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -/* - * NAME - * pkin.c - implementation of readchar() - * DESCRIPTION - * This implementation of readchar() uses parts of the program dvips - * written by Tomas Rokicki--the inventor of the pkformat--(loadfont.c, - * download.c and unpack.c). Dvips in turn is derived from pktype. - * Pktype(TeX) is described in debt in ``The PKtype processor'', - * which is available as pktype.weave as part of the METAFONTware. - * What was needed to implement readchar() is rearranged in pkfile.c to - * get more modularity in the style of MODULA2. - * BUGFIXES - * May 1997: Eric Delaunay reports a - * problem with huge fonts (greater than 1008 DPI). The code for - * handling PK characters in `extended format' was wrongly derived - * from dvips. Made some minor improvements regarding error handling. - * REDESIGN - * Piet Tutelaers - * rcpt@urc.tue.nl - * - * Modified for use with pdftex by Han The Thanh . - */ - -#include "ptexlib.h" -#include "luatexfont.h" - -static const char _svn_version[] = - "$Id: pkin.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/pkin.c $"; - -/* - * Now we have some routines to get stuff from the pk file. pkbyte returns - * the next byte from the pk file. - */ - -static shalfword pkbyte(void) -{ - register shalfword i; - i = t3_getchar(); - if (t3_eof()) - pdftex_fail("unexpected eof in pk file"); - return (i); -} - -static integer pkduo(void) -{ - register integer i; - - i = pkbyte(); - if (i > 127) - i -= 256; - i = i * 256 + pkbyte(); - return (i); -} - -static integer pktrio(void) -{ - register integer i; - - i = pkbyte(); - if (i > 127) - i -= 256; - i = i * 256 + pkbyte(); - i = i * 256 + pkbyte(); - return (i); -} - -static integer pkquad(void) -{ - register integer i; - - i = pkbyte(); - if (i > 127) - i -= 256; - i = i * 256 + pkbyte(); - i = i * 256 + pkbyte(); - i = i * 256 + pkbyte(); - return (i); -} - -/* - * The next part is devoted to unpacking the character data. - */ - -/* - * We need procedures to get a nybble, bit, and packed word from the - * packed data structure. - */ - -static halfword inputbyte, flagbyte; -static halfword bitweight; -static halfword dynf; -static halfword repeatcount; - -static shalfword getnyb(void) -{ - halfword temp; - if (bitweight == 0) { - bitweight = 16; - inputbyte = pkbyte(); - temp = inputbyte >> 4; - } else { - bitweight = 0; - temp = inputbyte & 15; - } - return (temp); -} - -static boolean getbit(void) -{ - bitweight >>= 1; - if (bitweight == 0) { - inputbyte = pkbyte(); - bitweight = 128; - } - return (inputbyte & bitweight); -} - -static halfword(*realfunc) (void); -long pk_remainder; -static halfword handlehuge(halfword i, halfword k); - -static halfword pkpackednum(void) -{ - register halfword i, j; - i = getnyb(); - if (i == 0) { - do { - j = getnyb(); - i++; - } while (!(j != 0)); - if (i > 3) { -/* - * Damn, we got a huge count! We *fake* it by giving an artificially - * large repeat count. - */ - return (handlehuge(i, j)); - } else { - while (i > 0) { - j = j * 16 + getnyb(); - i--; - } - return (j - 15 + (13 - dynf) * 16 + dynf); - } - } else if (i <= dynf) - return (i); - else if (i < 14) - return ((i - dynf - 1) * 16 + getnyb() + dynf + 1); - else { - if (i == 14) - repeatcount = pkpackednum(); - else - repeatcount = 1; -#ifdef DEBUG - printf("[%d]", (int) repeatcount); -#endif - return ((*realfunc) ()); - } -} - -static halfword rest(void) -{ - halfword i; - - if (pk_remainder < 0) { - pk_remainder = -pk_remainder; - return (0); - } else if (pk_remainder > 0) { - if (pk_remainder > 4000) { - pk_remainder = 4000 - pk_remainder; - return (4000); - } else { - i = pk_remainder; - pk_remainder = 0; - realfunc = pkpackednum; - return (i); - } - } else { - pdftex_fail("shouldn't happen"); - return 0; - /*NOTREACHED*/} -} - -static halfword handlehuge(halfword i, halfword k) -{ - register long j = k; - - while (i) { - j = (j << 4L) + getnyb(); - i--; - } - pk_remainder = j - 15 + (13 - dynf) * 16 + dynf; - realfunc = rest; - return (rest()); -} - -/* - * And now we have our unpacking routine. - */ - -static halfword gpower[17] = { 0, 1, 3, 7, 15, 31, 63, 127, - 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535 -}; - -static void unpack(chardesc * cd) -{ - register integer i, j; - register halfword word, wordweight; - halfword *raster; - shalfword rowsleft; - boolean turnon; - shalfword hbit; - halfword count; - shalfword wordwidth; - - wordwidth = (cd->cwidth + 15) / 16; - i = 2 * cd->cheight * (long) wordwidth; - if (i <= 0) - i = 2; - if (i > cd->rastersize) { - xfree(cd->raster); - cd->rastersize = i; - cd->raster = xtalloc(cd->rastersize, halfword); - } - raster = cd->raster; - realfunc = pkpackednum; - dynf = flagbyte / 16; - turnon = flagbyte & 8; - if (dynf == 14) { - bitweight = 0; - for (i = 1; i <= cd->cheight; i++) { - word = 0; - wordweight = 32768; - for (j = 1; j <= cd->cwidth; j++) { - if (getbit()) - word += wordweight; - wordweight >>= 1; - if (wordweight == 0) { - *raster++ = word; - word = 0; - wordweight = 32768; - } - } - if (wordweight != 32768) - *raster++ = word; - } - } else { - rowsleft = cd->cheight; - hbit = cd->cwidth; - repeatcount = 0; - wordweight = 16; - word = 0; - bitweight = 0; - while (rowsleft > 0) { - count = (*realfunc) (); -#ifdef DEBUG - if (turnon) - printf("(%d) ", (int) count); - else - printf("%d ", (int) count); -#endif - while (count != 0) { - if ((count < wordweight) && (count < hbit)) { - if (turnon) - word += gpower[wordweight] - gpower[wordweight - count]; - hbit -= count; - wordweight -= count; - count = 0; - } else if ((count >= hbit) && (hbit <= wordweight)) { - if (turnon) - word += gpower[wordweight] - gpower[wordweight - hbit]; - *raster++ = word; - for (i = 1; i <= repeatcount; i++) { - for (j = 1; j <= wordwidth; j++) { - *raster = *(raster - wordwidth); - raster++; - } - } - rowsleft -= repeatcount + 1; - repeatcount = 0; - word = 0; - wordweight = 16; - count -= hbit; - hbit = cd->cwidth; - } else { - if (turnon) - word += gpower[wordweight]; - *raster++ = word; - word = 0; - count -= wordweight; - hbit -= wordweight; - wordweight = 16; - } - } - turnon = !turnon; - } - if ((rowsleft != 0) || ((integer) hbit != cd->cwidth)) - pdftex_fail("error while unpacking; more bits than required"); - } -} - -/* - * readchar(): the main routine - * Reads the character definition of character `c' into `cd' if available, - * return FALSE (0) otherwise. - */ - -/* - * readchar(): the main routine - * check pk preamble if necessary, - * read the next character definition into `cd', - * return EOF if no character definition is available - */ - -int readchar(boolean check_preamble, chardesc * cd) -{ - register shalfword i; - register integer k; - register integer length = 0; - -/* - * Check the preamble of the pkfile - */ - if (check_preamble) { - if (pkbyte() != 247) - pdftex_fail("bad pk file, expected pre"); - if (pkbyte() != 89) - pdftex_fail("bad version of pk file"); - for (i = pkbyte(); i > 0; i--) /* creator of pkfile */ - (void) pkbyte(); - (void) pkquad(); /* design size */ - k = pkquad(); /* checksum */ - k = pkquad(); /* hppp */ - k = pkquad(); /* vppp */ - } -/* - * Now we skip to the desired character definition - */ - while ((flagbyte = pkbyte()) != 245) { - if (flagbyte < 240) { - switch (flagbyte & 7) { - case 0: - case 1: - case 2: - case 3: - length = (flagbyte & 7) * 256 + pkbyte() - 3; - cd->charcode = pkbyte(); - (void) pktrio(); /* TFMwidth */ - cd->xescape = pkbyte(); /* pixel width */ - cd->cwidth = pkbyte(); - cd->cheight = pkbyte(); - cd->xoff = pkbyte(); - cd->yoff = pkbyte(); - if (cd->xoff > 127) - cd->xoff -= 256; - if (cd->yoff > 127) - cd->yoff -= 256; - break; - case 4: - case 5: - case 6: - length = (flagbyte & 3) * 65536L + pkbyte() * 256L; - length = length + pkbyte() - 4L; - cd->charcode = pkbyte(); - (void) pktrio(); /* TFMwidth */ - cd->xescape = pkduo(); /* pixelwidth */ - cd->cwidth = pkduo(); - cd->cheight = pkduo(); - cd->xoff = pkduo(); - cd->yoff = pkduo(); - break; - case 7: - length = pkquad() - 9L; - cd->charcode = pkquad(); - (void) pkquad(); /* TFMwidth */ - cd->xescape = pkquad(); /* pixelwidth */ - k = pkquad(); - cd->cwidth = pkquad(); - cd->cheight = pkquad(); - cd->xoff = pkquad(); - cd->yoff = pkquad(); - } - if (length <= 0) - pdftex_fail("packet length (%i) too small", (int) length); - unpack(cd); - return 1; - } else { - k = 0; - switch (flagbyte) { - case 243: - k = pkbyte(); - if (k > 127) - k -= 256; - case 242: - k = k * 256 + pkbyte(); - case 241: - k = k * 256 + pkbyte(); - case 240: - k = k * 256 + pkbyte(); - while (k-- > 0) - i = pkbyte(); - break; - case 244: - k = pkquad(); - break; - case 246: - break; - default: - pdftex_fail("unexpected command (%i)", (int) flagbyte); - } - } - } - return 0; /* character not found */ -} diff --git a/Build/source/texk/web2c/luatexdir/font/pkin.w b/Build/source/texk/web2c/luatexdir/font/pkin.w new file mode 100644 index 00000000000..077680eb596 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/pkin.w @@ -0,0 +1,434 @@ +% pkin.w +% +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2008 Taco Hoekwater +% +% This file is part of LuaTeX. +% +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. +% +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. +% +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ +NAME + +pkin.c - implementation of readchar() + +DESCRIPTION + +This implementation of readchar() uses parts of the program dvips +written by Tomas Rokicki--the inventor of the pkformat--(loadfont.c, +download.c and unpack.c). Dvips in turn is derived from pktype. +Pktype(TeX) is described in debt in ``The PKtype processor'', +which is available as pktype.weave as part of the METAFONTware. +What was needed to implement readchar() is rearranged in pkfile.c to +get more modularity in the style of MODULA2. + +BUGFIXES + +May 1997: Eric Delaunay reports a +problem with huge fonts (greater than 1008 DPI). The code for +handling PK characters in `extended format' was wrongly derived +from dvips. Made some minor improvements regarding error handling. + +REDESIGN + +Piet Tutelaers + +Modified for use with pdftex by Han The Thanh . + +@c +#include "ptexlib.h" + +typedef short shalfword; + +static const char _svn_version[] = + "$Id: pkin.w 3584 2010-04-02 17:45:55Z hhenkel $" + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/pkin.w $"; + +@ +Now we have some routines to get stuff from the pk file. pkbyte returns +the next byte from the pk file. + +@c +static shalfword pkbyte(void) +{ + register shalfword i; + i = t3_getchar(); + if (t3_eof()) + pdftex_fail("unexpected eof in pk file"); + return (i); +} + +static int pkduo(void) +{ + register int i; + + i = pkbyte(); + if (i > 127) + i -= 256; + i = i * 256 + pkbyte(); + return (i); +} + +static int pktrio(void) +{ + register int i; + + i = pkbyte(); + if (i > 127) + i -= 256; + i = i * 256 + pkbyte(); + i = i * 256 + pkbyte(); + return (i); +} + +static int pkquad(void) +{ + register int i; + + i = pkbyte(); + if (i > 127) + i -= 256; + i = i * 256 + pkbyte(); + i = i * 256 + pkbyte(); + i = i * 256 + pkbyte(); + return (i); +} + + + +@ The next part is devoted to unpacking the character data. + +@ We need procedures to get a nybble, bit, and packed word from the +packed data structure. + +@c +static halfword inputbyte, flagbyte; +static halfword bitweight; +static halfword dynf; +static halfword repeatcount; + +static shalfword getnyb(void) +{ + halfword temp; + if (bitweight == 0) { + bitweight = 16; + inputbyte = pkbyte(); + temp = inputbyte >> 4; + } else { + bitweight = 0; + temp = inputbyte & 15; + } + return (shalfword) (temp); +} + +static boolean getbit(void) +{ + bitweight >>= 1; + if (bitweight == 0) { + inputbyte = pkbyte(); + bitweight = 128; + } + return (inputbyte & bitweight); +} + +static halfword(*realfunc) (void); +long pk_remainder; +static halfword handlehuge(halfword i, halfword k); + +static halfword pkpackednum(void) +{ + register halfword i, j; + i = getnyb(); + if (i == 0) { + do { + j = getnyb(); + i++; + } while (!(j != 0)); + if (i > 3) { +/* + Damn, we got a huge count! We {\it fake} it by giving an artificially + large repeat count. + */ + return (handlehuge(i, j)); + } else { + while (i > 0) { + j = j * 16 + getnyb(); + i--; + } + return (j - 15 + (13 - dynf) * 16 + dynf); + } + } else if (i <= dynf) + return (i); + else if (i < 14) + return ((i - dynf - 1) * 16 + getnyb() + dynf + 1); + else { + if (i == 14) + repeatcount = pkpackednum(); + else + repeatcount = 1; +#ifdef DEBUG + printf("[%d]", (int) repeatcount); +#endif + return ((*realfunc) ()); + } +} + +static halfword rest(void) +{ + halfword i; + + if (pk_remainder < 0) { + pk_remainder = -pk_remainder; + return (0); + } else if (pk_remainder > 0) { + if (pk_remainder > 4000) { + pk_remainder = 4000 - pk_remainder; + return (4000); + } else { + i = (halfword) pk_remainder; + pk_remainder = 0; + realfunc = pkpackednum; + return (i); + } + } else { + pdftex_fail("shouldn't happen"); + return 0; + /*NOTREACHED*/} +} + +static halfword handlehuge(halfword i, halfword k) +{ + register long j = k; + + while (i) { + j = (j << 4L) + getnyb(); + i--; + } + pk_remainder = j - 15 + (13 - dynf) * 16 + dynf; + realfunc = rest; + return (rest()); +} + + +@ And now we have our unpacking routine. + +@c +static halfword gpower[17] = { 0, 1, 3, 7, 15, 31, 63, 127, + 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535 +}; + +static void unpack(chardesc * cd) +{ + register int i, j; + register halfword word, wordweight; + halfword *raster; + shalfword rowsleft; + boolean turnon; + shalfword hbit; + halfword count; + shalfword wordwidth; + + wordwidth = (shalfword) ((cd->cwidth + 15) / 16); + i = (int) (2 * cd->cheight * (long) wordwidth); + if (i <= 0) + i = 2; + if (i > cd->rastersize) { + xfree(cd->raster); + cd->rastersize = i; + cd->raster = xtalloc((unsigned) cd->rastersize, halfword); + } + raster = cd->raster; + realfunc = pkpackednum; + dynf = flagbyte / 16; + turnon = flagbyte & 8; + if (dynf == 14) { + bitweight = 0; + for (i = 1; i <= cd->cheight; i++) { + word = 0; + wordweight = 32768; + for (j = 1; j <= cd->cwidth; j++) { + if (getbit()) + word += wordweight; + wordweight >>= 1; + if (wordweight == 0) { + *raster++ = word; + word = 0; + wordweight = 32768; + } + } + if (wordweight != 32768) + *raster++ = word; + } + } else { + rowsleft = (shalfword) cd->cheight; + hbit = (shalfword) cd->cwidth; + repeatcount = 0; + wordweight = 16; + word = 0; + bitweight = 0; + while (rowsleft > 0) { + count = (*realfunc) (); +#ifdef DEBUG + if (turnon) + printf("(%d) ", (int) count); + else + printf("%d ", (int) count); +#endif + while (count != 0) { + if ((count < wordweight) && (count < hbit)) { + if (turnon) + word += gpower[wordweight] - gpower[wordweight - count]; + hbit = (shalfword) (hbit - count); + wordweight -= count; + count = 0; + } else if ((count >= hbit) && (hbit <= wordweight)) { + if (turnon) + word += gpower[wordweight] - gpower[wordweight - hbit]; + *raster++ = word; + for (i = 1; i <= repeatcount; i++) { + for (j = 1; j <= wordwidth; j++) { + *raster = *(raster - wordwidth); + raster++; + } + } + rowsleft = (shalfword) (rowsleft - repeatcount - 1); + repeatcount = 0; + word = 0; + wordweight = 16; + count -= hbit; + hbit = (shalfword) cd->cwidth; + } else { + if (turnon) + word += gpower[wordweight]; + *raster++ = word; + word = 0; + count -= wordweight; + hbit = (shalfword) (hbit - wordweight); + wordweight = 16; + } + } + turnon = !turnon; + } + if ((rowsleft != 0) || ((int) hbit != cd->cwidth)) + pdftex_fail("error while unpacking; more bits than required"); + } +} + +@ +|readchar()|: the main routine +check pk preamble if necessary, +Reads the character definition of character `c' into `cd' if available, +return FALSE (0) otherwise. + +@c +int readchar(boolean check_preamble, chardesc * cd) +{ + register shalfword i; + register int k; + register int length = 0; + +/* + Check the preamble of the pkfile + */ + if (check_preamble) { + if (pkbyte() != 247) + pdftex_fail("bad pk file, expected pre"); + if (pkbyte() != 89) + pdftex_fail("bad version of pk file"); + for (i = pkbyte(); i > 0; i--) /* creator of pkfile */ + (void) pkbyte(); + (void) pkquad(); /* design size */ + k = pkquad(); /* checksum */ + k = pkquad(); /* hppp */ + k = pkquad(); /* vppp */ + } +/* + Now we skip to the desired character definition + */ + while ((flagbyte = pkbyte()) != 245) { + if (flagbyte < 240) { + switch (flagbyte & 7) { + case 0: + case 1: + case 2: + case 3: + length = (flagbyte & 7) * 256 + pkbyte() - 3; + cd->charcode = pkbyte(); + (void) pktrio(); /* TFMwidth */ + cd->xescape = pkbyte(); /* pixel width */ + cd->cwidth = pkbyte(); + cd->cheight = pkbyte(); + cd->xoff = pkbyte(); + cd->yoff = pkbyte(); + if (cd->xoff > 127) + cd->xoff -= 256; + if (cd->yoff > 127) + cd->yoff -= 256; + break; + case 4: + case 5: + case 6: + length = (int) ((flagbyte & 3) * 65536L + pkbyte() * 256L); + length = (int) (length + pkbyte() - 4L); + cd->charcode = pkbyte(); + (void) pktrio(); /* TFMwidth */ + cd->xescape = pkduo(); /* pixelwidth */ + cd->cwidth = pkduo(); + cd->cheight = pkduo(); + cd->xoff = pkduo(); + cd->yoff = pkduo(); + break; + case 7: + length = (int) (pkquad() - 9L); + cd->charcode = pkquad(); + (void) pkquad(); /* TFMwidth */ + cd->xescape = pkquad(); /* pixelwidth */ + k = pkquad(); + cd->cwidth = pkquad(); + cd->cheight = pkquad(); + cd->xoff = pkquad(); + cd->yoff = pkquad(); + } + if (length <= 0) + pdftex_fail("packet length (%i) too small", (int) length); + unpack(cd); + return 1; + } else { + k = 0; + switch (flagbyte) { + case 243: + k = pkbyte(); + if (k > 127) + k -= 256; + case 242: + k = k * 256 + pkbyte(); + case 241: + k = k * 256 + pkbyte(); + case 240: + k = k * 256 + pkbyte(); + while (k-- > 0) + i = pkbyte(); + break; + case 244: + k = pkquad(); + break; + case 246: + break; + default: + pdftex_fail("unexpected command (%i)", (int) flagbyte); + } + } + } + return 0; /* character not found */ +} diff --git a/Build/source/texk/web2c/luatexdir/font/sfnt.c b/Build/source/texk/web2c/luatexdir/font/sfnt.c deleted file mode 100644 index 8812cd7fa6c..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/sfnt.c +++ /dev/null @@ -1,621 +0,0 @@ -/* sfnt.c - - Copyright 2002 by Jin-Hwan Cho and Shunsaku Hirata, - the dvipdfmx project team - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -/* Based on dvipdfmx-0.13.2c */ - -#if HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H_ */ - -#include - -#ifndef pdfTeX -# include "system.h" - -# include "error.h" -# include "mem.h" -# include "mfileio.h" -#else -# include "ptexlib.h" -#endif - -#include "sfnt.h" - -static const char _svn_version[] = - "$Id: sfnt.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/sfnt.c $"; - -#ifdef XETEX -UNSIGNED_BYTE ft_unsigned_byte(sfnt * f) -{ - unsigned char byte; - unsigned long length = 1; - - if (FT_Load_Sfnt_Table(f->ft_face, 0, f->loc, &byte, &length) != 0) - TT_ERROR("sfnt: Freetype failure..."); - f->loc += 1; - - return byte; -} - -SIGNED_BYTE ft_signed_byte(sfnt * f) -{ - int b = ft_unsigned_byte(f); - if (b >= 0x80) - b -= 0x100; - return (SIGNED_BYTE) b; -} - -UNSIGNED_PAIR ft_unsigned_pair(sfnt * f) -{ - unsigned char buf[2]; - unsigned long length = 2; - - if (FT_Load_Sfnt_Table(f->ft_face, 0, f->loc, buf, &length) != 0) - TT_ERROR("sfnt: Freetype failure..."); - f->loc += 2; - - return (UNSIGNED_PAIR) ((unsigned) buf[0] << 8) + buf[1]; -} - -SIGNED_PAIR ft_signed_pair(sfnt * f) -{ - int p = ft_unsigned_pair(f); - if (p >= 0x8000U) - p -= 0x10000U; - - return (SIGNED_PAIR) p; -} - -UNSIGNED_QUAD ft_unsigned_quad(sfnt * f) -{ - unsigned char buf[4]; - unsigned long length = 4; - - if (FT_Load_Sfnt_Table(f->ft_face, 0, f->loc, buf, &length) != 0) - TT_ERROR("sfnt: Freetype failure..."); - f->loc += 4; - - return ((unsigned long) buf[0] << 24) + ((unsigned long) buf[1] << 16) - + ((unsigned long) buf[2] << 8) + (unsigned long) buf[3]; -} - -unsigned long ft_read(unsigned char *buf, unsigned long len, sfnt * f) -{ - unsigned long length = len; - if (FT_Load_Sfnt_Table(f->ft_face, 0, f->loc, buf, &length) != 0) - TT_ERROR("sfnt: Freetype failure..."); - f->loc += len; - - return length; -} -#endif - - -/* - * type: - * `true' (0x74727565): TrueType (Mac) - * `typ1' (0x74797031) (Mac): PostScript font housed in a sfnt wrapper - * 0x00010000: TrueType (Win)/OpenType - * `OTTO': PostScript CFF font with OpenType wrapper - * `ttcf': TrueType Collection -*/ -#define SFNT_TRUETYPE 0x00010000UL -#define SFNT_MAC_TRUE 0x74727565UL -#define SFNT_OPENTYPE 0x00010000UL -#define SFNT_POSTSCRIPT 0x4f54544fUL -#define SFNT_TTC 0x74746366UL - -#ifdef XETEX -sfnt *sfnt_open(FT_Face face, int accept_types) -{ - sfnt *sfont; - ULONG type; - - if (!face || !FT_IS_SFNT(face)) - return NULL; - - sfont = NEW(1, sfnt); - sfont->ft_face = face; - sfont->loc = 0; - sfont->type = 0; - - type = sfnt_get_ulong(sfont); - - if (type == SFNT_TRUETYPE || type == SFNT_MAC_TRUE) { - sfont->type = SFNT_TYPE_TRUETYPE; - } else if (type == SFNT_OPENTYPE) { - sfont->type = SFNT_TYPE_OPENTYPE; - } else if (type == SFNT_POSTSCRIPT) { - sfont->type = SFNT_TYPE_POSTSCRIPT; - } else if (type == SFNT_TTC) { - sfont->type = SFNT_TYPE_TTC; - } - - if ((sfont->type & accept_types) == 0) { - RELEASE(sfont); - return NULL; - } - - sfont->loc = 0; - - sfont->directory = NULL; - - return sfont; -} -#else /* not XETEX */ -# ifdef pdfTeX -sfnt *sfnt_open(unsigned char *buffer, integer buflen) -{ - sfnt *sfont; - ULONG type; - - sfont = xmalloc(sizeof(sfnt)); - sfont->loc = 0; - sfont->buffer = buffer; - sfont->buflen = buflen; - - type = sfnt_get_ulong(sfont); - - if (type == SFNT_TRUETYPE || type == SFNT_MAC_TRUE) { - sfont->type = SFNT_TYPE_TRUETYPE; - } else if (type == SFNT_OPENTYPE) { - sfont->type = SFNT_TYPE_OPENTYPE; - } else if (type == SFNT_POSTSCRIPT) { - sfont->type = SFNT_TYPE_POSTSCRIPT; - } else if (type == SFNT_TTC) { - sfont->type = SFNT_TYPE_TTC; - } - - sfont->loc = 0; - sfont->directory = NULL; - return sfont; -} -# else -sfnt *sfnt_open(FILE * fp) -{ - sfnt *sfont; - ULONG type; - - ASSERT(fp); - - rewind(fp); - - sfont = NEW(1, sfnt); - - sfont->stream = fp; - - type = sfnt_get_ulong(sfont); - - if (type == SFNT_TRUETYPE || type == SFNT_MAC_TRUE) { - sfont->type = SFNT_TYPE_TRUETYPE; - } else if (type == SFNT_OPENTYPE) { - sfont->type = SFNT_TYPE_OPENTYPE; - } else if (type == SFNT_POSTSCRIPT) { - sfont->type = SFNT_TYPE_POSTSCRIPT; - } else if (type == SFNT_TTC) { - sfont->type = SFNT_TYPE_TTC; - } - - rewind(sfont->stream); - - sfont->directory = NULL; - - return sfont; -} -# endif -#endif - -static void release_directory(struct sfnt_table_directory *td) -{ - long i; - - if (td) { - if (td->tables) { - for (i = 0; i < td->num_tables; i++) { - if (td->tables[i].data) - RELEASE(td->tables[i].data); - } - RELEASE(td->tables); - } - if (td->flags) - RELEASE(td->flags); - RELEASE(td); - } - - return; -} - -void sfnt_close(sfnt * sfont) -{ - - if (sfont) { - if (sfont->directory) - release_directory(sfont->directory); - RELEASE(sfont); - } - - return; -} - -int put_big_endian(void *s, LONG q, int n) -{ - int i; - char *p; - - p = (char *) s; - for (i = n - 1; i >= 0; i--) { - p[i] = (char) (q & 0xff); - q >>= 8; - } - - return n; -} - -/* Convert four-byte number to big endianess - * in a machine independent way. - */ -static void convert_tag(char *tag, unsigned long u_tag) -{ - int i; - - for (i = 3; i >= 0; i--) { - tag[i] = (char) (u_tag % 256); - u_tag /= 256; - } - - return; -} - -/* - * Computes the max power of 2 <= n - */ -static unsigned max2floor(unsigned n) -{ - int val = 1; - - while (n > 1) { - n /= 2; - val *= 2; - } - - return val; -} - -/* - * Computes the log2 of the max power of 2 <= n - */ -static unsigned log2floor(unsigned n) -{ - unsigned val = 0; - - while (n > 1) { - n /= 2; - val++; - } - - return val; -} - -static ULONG sfnt_calc_checksum(void *data, ULONG length) -{ - ULONG chksum = 0; - BYTE *p, *endptr; - int count = 0; - - p = (BYTE *) data; - endptr = p + length; - while (p < endptr) { - chksum += (p[0] << (8 * (3 - count))); - count = ((count + 1) & 3); - p++; - } - - return chksum; -} - -static int find_table_index(struct sfnt_table_directory *td, const char *tag) -{ - int idx; - - if (!td) - return -1; - - for (idx = 0; idx < td->num_tables; idx++) { - if (!memcmp(td->tables[idx].tag, tag, 4)) - return idx; - } - - return -1; -} - -void sfnt_set_table(sfnt * sfont, const char *tag, void *data, ULONG length) -{ - struct sfnt_table_directory *td; - int idx; - - ASSERT(sfont); - - td = sfont->directory; - idx = find_table_index(td, tag); - - if (idx < 0) { - idx = td->num_tables; - td->num_tables++; - td->tables = RENEW(td->tables, td->num_tables, struct sfnt_table); - memcpy(td->tables[idx].tag, tag, 4); - } - - td->tables[idx].check_sum = sfnt_calc_checksum(data, length); - td->tables[idx].offset = 0L; - td->tables[idx].length = length; - td->tables[idx].data = data; - - return; -} - -ULONG sfnt_find_table_len(sfnt * sfont, const char *tag) -{ - ULONG length; - struct sfnt_table_directory *td; - int idx; - - ASSERT(sfont && tag); - - td = sfont->directory; - idx = find_table_index(td, tag); - if (idx < 0) - length = 0; - else { - length = td->tables[idx].length; - } - - return length; -} - -ULONG sfnt_find_table_pos(sfnt * sfont, const char *tag) -{ - ULONG offset; - struct sfnt_table_directory *td; - int idx; - - ASSERT(sfont && tag); - - td = sfont->directory; - idx = find_table_index(td, tag); - if (idx < 0) - offset = 0; - else { - offset = td->tables[idx].offset; - } - - return offset; -} - -ULONG sfnt_locate_table(sfnt * sfont, const char *tag) -{ - ULONG offset; - - ASSERT(sfont && tag); - - offset = sfnt_find_table_pos(sfont, tag); - if (offset == 0) - TT_ERROR("sfnt: table not found..."); - - sfnt_seek_set(sfont, offset); - - return offset; -} - -int sfnt_read_table_directory(sfnt * sfont, ULONG offset) -{ - struct sfnt_table_directory *td; - unsigned long i, u_tag; - - ASSERT(sfont); - - if (sfont->directory) - release_directory(sfont->directory); - sfont->directory = td = NEW(1, struct sfnt_table_directory); - -#ifdef XETEX - ASSERT(sfont->ft_face); -#elif defined(pdfTeX) - ASSERT(sfont->buffer); -#else - ASSERT(sfont->stream); -#endif - - sfnt_seek_set(sfont, offset); - - td->version = sfnt_get_ulong(sfont); - td->num_tables = sfnt_get_ushort(sfont); - td->search_range = sfnt_get_ushort(sfont); - td->entry_selector = sfnt_get_ushort(sfont); - td->range_shift = sfnt_get_ushort(sfont); - - td->flags = NEW(td->num_tables, char); - td->tables = NEW(td->num_tables, struct sfnt_table); - - for (i = 0; i < td->num_tables; i++) { - u_tag = sfnt_get_ulong(sfont); - - convert_tag(td->tables[i].tag, u_tag); - td->tables[i].check_sum = sfnt_get_ulong(sfont); - td->tables[i].offset = sfnt_get_ulong(sfont); - td->tables[i].length = sfnt_get_ulong(sfont); - td->tables[i].data = NULL; - - td->flags[i] = 0; - } - - td->num_kept_tables = 0; - - return 0; -} - -int sfnt_require_table(sfnt * sfont, const char *tag, int must_exist) -{ - struct sfnt_table_directory *td; - int idx; - - ASSERT(sfont && sfont->directory); - - td = sfont->directory; - idx = find_table_index(td, tag); - if (idx < 0) { - if (must_exist) - return -1; - } else { - td->flags[idx] |= SFNT_TABLE_REQUIRED; - td->num_kept_tables++; - } - - return 0; -} - -#ifndef pdfTeX -# include "pdfobj.h" -#endif - -/* - * o All tables begin on four byte boundries, and pad any remaining space - * between tables with zeros - * - * o Entries in the Table Directory must be sorted in ascending order by tag - * - * o The head table contains checksum of the whole font file. - * To compute: first set it to 0, sum the entire font as ULONG, - * then store 0xB1B0AFBA - sum. - */ - -#ifdef pdfTeX -# include "luatexfont.h" -# undef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -# define STREAM_COMPRESS -#endif - -static unsigned char wbuf[1024], padbytes[4] = { 0, 0, 0, 0 }; - -pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) -{ - pdf_obj *stream; -#ifndef pdfTeX - pdf_obj *stream_dict; -#endif - struct sfnt_table_directory *td; - long offset, nb_read, length; - int i, sr; - char *p; - - ASSERT(sfont && sfont->directory); - - stream = pdf_new_stream(STREAM_COMPRESS); - - td = sfont->directory; - - /* Header */ - p = (char *) wbuf; - p += sfnt_put_ulong(p, td->version); - p += sfnt_put_ushort(p, td->num_kept_tables); - sr = max2floor(td->num_kept_tables) * 16; - p += sfnt_put_ushort(p, sr); - p += sfnt_put_ushort(p, log2floor(td->num_kept_tables)); - p += sfnt_put_ushort(p, td->num_kept_tables * 16 - sr); - - pdf_add_stream(stream, wbuf, 12); - - /* - * Compute start of actual tables (after headers). - */ - offset = 12 + 16 * td->num_kept_tables; - for (i = 0; i < td->num_tables; i++) { - /* This table must exist in FontFile */ - if (td->flags[i] & SFNT_TABLE_REQUIRED) { - if ((offset % 4) != 0) { - offset += 4 - (offset % 4); - } - - p = (char *) wbuf; - memcpy(p, td->tables[i].tag, 4); - p += 4; - p += sfnt_put_ulong(p, td->tables[i].check_sum); - p += sfnt_put_ulong(p, offset); - p += sfnt_put_ulong(p, td->tables[i].length); - pdf_add_stream(stream, wbuf, 16); - - offset += td->tables[i].length; - } - } - - offset = 12 + 16 * td->num_kept_tables; - for (i = 0; i < td->num_tables; i++) { - if (td->flags[i] & SFNT_TABLE_REQUIRED) { - if ((offset % 4) != 0) { - length = 4 - (offset % 4); - pdf_add_stream(stream, padbytes, length); - offset += length; - } - if (!td->tables[i].data) { -#ifdef XETEX - if (!sfont->ft_face) -#elif defined(pdfTeX) - if (!sfont->buffer) -#else - if (!sfont->stream) -#endif - { - pdf_release_obj(stream); - TT_ERROR("Font file not opened or already closed..."); - return NULL; - } - - length = td->tables[i].length; - sfnt_seek_set(sfont, td->tables[i].offset); - while (length > 0) { - nb_read = sfnt_read(wbuf, MIN(length, 1024), sfont); - if (nb_read < 0) { - pdf_release_obj(stream); - TT_ERROR("Reading file failed..."); - return NULL; - } else if (nb_read > 0) { - pdf_add_stream(stream, wbuf, nb_read); - } - length -= nb_read; - } - } else { - pdf_add_stream(stream, - (unsigned char *) td->tables[i].data, - td->tables[i].length); - RELEASE(td->tables[i].data); - td->tables[i].data = NULL; - } - /* Set offset for next table */ - offset += td->tables[i].length; - } - } - -#ifndef pdfTeX - stream_dict = pdf_stream_dict(stream); - pdf_add_dict(stream_dict, pdf_new_name("Length1"), pdf_new_number(offset)); -#endif - return stream; -} diff --git a/Build/source/texk/web2c/luatexdir/font/sfnt.h b/Build/source/texk/web2c/luatexdir/font/sfnt.h index 5d9bd2c973f..d41c019ffcf 100644 --- a/Build/source/texk/web2c/luatexdir/font/sfnt.h +++ b/Build/source/texk/web2c/luatexdir/font/sfnt.h @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: sfnt.h 2271 2009-04-12 23:42:21Z oneiros $ */ +/* $Id: sfnt.h 3404 2010-01-28 11:17:10Z taco $ */ #ifndef _SFNT_H_ # define _SFNT_H_ @@ -157,7 +157,7 @@ extern int put_big_endian(void *s, LONG q, int n); # ifdef XETEX extern sfnt *sfnt_open(FT_Face face, int accept_types); # elif defined(pdfTeX) -extern sfnt *sfnt_open(unsigned char *buffer, integer buflen); +extern sfnt *sfnt_open(unsigned char *buffer, int buflen); # else extern sfnt *sfnt_open(FILE * fp); # endif @@ -181,8 +181,8 @@ typedef struct { # define ASSERT(a) assert(a) # define RELEASE(a) free(a) -# define NEW(a,b) xmalloc((a)*sizeof(b)) -# define RENEW(a,b,c) xrealloc(a, ((b)*sizeof(c))) +# define NEW(a,b) xmalloc((unsigned)((unsigned)(a)*sizeof(b))) +# define RENEW(a,b,c) xrealloc(a, (unsigned)((unsigned)(b)*sizeof(c))) # define TT_ERROR pdftex_fail # define WARN printf diff --git a/Build/source/texk/web2c/luatexdir/font/sfnt.w b/Build/source/texk/web2c/luatexdir/font/sfnt.w new file mode 100644 index 00000000000..25fb3fcd086 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/sfnt.w @@ -0,0 +1,466 @@ +% sfnt.w +% +% Copyright 2002 by Jin-Hwan Cho and Shunsaku Hirata, +% the dvipdfmx project team +% Copyright 2006-2008 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ Based on dvipdfmx-0.13.2c +@c + +#if HAVE_CONFIG_H +# include "config.h" +#endif /* |HAVE_CONFIG_H_| */ + +#include + +# include "ptexlib.h" +#include "font/sfnt.h" + +static const char _svn_version[] = + "$Id: sfnt.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/sfnt.w $"; + + + +@ type: + + `true' (0x74727565): TrueType (Mac) + + `typ1' (0x74797031) (Mac): PostScript font housed in a sfnt wrapper + + 0x00010000: TrueType (Win)/OpenType + + `OTTO': PostScript CFF font with OpenType wrapper + + `ttcf': TrueType Collection + +@c +#define SFNT_TRUETYPE 0x00010000UL +#define SFNT_MAC_TRUE 0x74727565UL +#define SFNT_OPENTYPE 0x00010000UL +#define SFNT_POSTSCRIPT 0x4f54544fUL +#define SFNT_TTC 0x74746366UL + +sfnt *sfnt_open(unsigned char *buffer, int buflen) +{ + sfnt *sfont; + ULONG type; + + sfont = xmalloc(sizeof(sfnt)); + sfont->loc = 0; + sfont->buffer = buffer; + sfont->buflen = buflen; + + type = sfnt_get_ulong(sfont); + + if (type == SFNT_TRUETYPE || type == SFNT_MAC_TRUE) { + sfont->type = SFNT_TYPE_TRUETYPE; + } else if (type == SFNT_OPENTYPE) { + sfont->type = SFNT_TYPE_OPENTYPE; + } else if (type == SFNT_POSTSCRIPT) { + sfont->type = SFNT_TYPE_POSTSCRIPT; + } else if (type == SFNT_TTC) { + sfont->type = SFNT_TYPE_TTC; + } + + sfont->loc = 0; + sfont->directory = NULL; + return sfont; +} + +static void release_directory(struct sfnt_table_directory *td) +{ + long i; + + if (td) { + if (td->tables) { + for (i = 0; i < td->num_tables; i++) { + if (td->tables[i].data) + RELEASE(td->tables[i].data); + } + RELEASE(td->tables); + } + if (td->flags) + RELEASE(td->flags); + RELEASE(td); + } + + return; +} + +void sfnt_close(sfnt * sfont) +{ + + if (sfont) { + if (sfont->directory) + release_directory(sfont->directory); + RELEASE(sfont); + } + + return; +} + +int put_big_endian(void *s, LONG q, int n) +{ + int i; + char *p; + + p = (char *) s; + for (i = n - 1; i >= 0; i--) { + p[i] = (char) (q & 0xff); + q >>= 8; + } + + return n; +} + +@ Convert four-byte number to big endianess in a machine independent way. + +@c +static void convert_tag(char *tag, unsigned long u_tag) +{ + int i; + + for (i = 3; i >= 0; i--) { + tag[i] = (char) (u_tag % 256); + u_tag /= 256; + } + + return; +} + + +@ Computes the max power of 2 <= n + +@c +static unsigned max2floor(unsigned n) +{ + int val = 1; + + while (n > 1) { + n /= 2; + val *= 2; + } + + return (unsigned) val; +} + + +@ Computes the log2 of the max power of 2 <= n + +@c +static unsigned log2floor(unsigned n) +{ + unsigned val = 0; + + while (n > 1) { + n /= 2; + val++; + } + + return val; +} + +@ @c +static ULONG sfnt_calc_checksum(void *data, ULONG length) +{ + ULONG chksum = 0; + BYTE *p, *endptr; + ULONG count = 0; + + p = (BYTE *) data; + endptr = p + length; + while (p < endptr) { + chksum = chksum + (ULONG) (p[0] << (8 * (3 - count))); + count = ((count + 1) & 3); + p++; + } + + return chksum; +} + +@ @c +static int find_table_index(struct sfnt_table_directory *td, const char *tag) +{ + int idx; + + if (!td) + return -1; + + for (idx = 0; idx < td->num_tables; idx++) { + if (!memcmp(td->tables[idx].tag, tag, 4)) + return idx; + } + + return -1; +} + +@ @c +void sfnt_set_table(sfnt * sfont, const char *tag, void *data, ULONG length) +{ + struct sfnt_table_directory *td; + int idx; + + ASSERT(sfont); + + td = sfont->directory; + idx = find_table_index(td, tag); + + if (idx < 0) { + idx = td->num_tables; + td->num_tables++; + td->tables = RENEW(td->tables, td->num_tables, struct sfnt_table); + memcpy(td->tables[idx].tag, tag, 4); + } + + td->tables[idx].check_sum = sfnt_calc_checksum(data, length); + td->tables[idx].offset = 0L; + td->tables[idx].length = length; + td->tables[idx].data = data; + + return; +} + +@ @c +ULONG sfnt_find_table_len(sfnt * sfont, const char *tag) +{ + ULONG length; + struct sfnt_table_directory *td; + int idx; + + ASSERT(sfont && tag); + + td = sfont->directory; + idx = find_table_index(td, tag); + if (idx < 0) + length = 0; + else { + length = td->tables[idx].length; + } + + return length; +} + +@ @c +ULONG sfnt_find_table_pos(sfnt * sfont, const char *tag) +{ + ULONG offset; + struct sfnt_table_directory *td; + int idx; + + ASSERT(sfont && tag); + + td = sfont->directory; + idx = find_table_index(td, tag); + if (idx < 0) + offset = 0; + else { + offset = td->tables[idx].offset; + } + + return offset; +} + +@ @c +ULONG sfnt_locate_table(sfnt * sfont, const char *tag) +{ + ULONG offset; + + ASSERT(sfont && tag); + + offset = sfnt_find_table_pos(sfont, tag); + if (offset == 0) + TT_ERROR("sfnt: table not found..."); + + sfnt_seek_set(sfont, (long) offset); + + return offset; +} + +@ @c +int sfnt_read_table_directory(sfnt * sfont, ULONG offset) +{ + struct sfnt_table_directory *td; + unsigned long i, u_tag; + + ASSERT(sfont); + + if (sfont->directory) + release_directory(sfont->directory); + sfont->directory = td = NEW(1, struct sfnt_table_directory); + + ASSERT(sfont->buffer); + sfnt_seek_set(sfont, (long) offset); + + td->version = sfnt_get_ulong(sfont); + td->num_tables = sfnt_get_ushort(sfont); + td->search_range = sfnt_get_ushort(sfont); + td->entry_selector = sfnt_get_ushort(sfont); + td->range_shift = sfnt_get_ushort(sfont); + + td->flags = NEW(td->num_tables, char); + td->tables = NEW(td->num_tables, struct sfnt_table); + + for (i = 0; i < td->num_tables; i++) { + u_tag = sfnt_get_ulong(sfont); + + convert_tag(td->tables[i].tag, u_tag); + td->tables[i].check_sum = sfnt_get_ulong(sfont); + td->tables[i].offset = sfnt_get_ulong(sfont); + td->tables[i].length = sfnt_get_ulong(sfont); + td->tables[i].data = NULL; + + td->flags[i] = 0; + } + + td->num_kept_tables = 0; + + return 0; +} + +@ @c +int sfnt_require_table(sfnt * sfont, const char *tag, int must_exist) +{ + struct sfnt_table_directory *td; + int idx; + + ASSERT(sfont && sfont->directory); + + td = sfont->directory; + idx = find_table_index(td, tag); + if (idx < 0) { + if (must_exist) + return -1; + } else { + td->flags[idx] |= SFNT_TABLE_REQUIRED; + td->num_kept_tables++; + } + + return 0; +} + + + +@ All tables begin on four byte boundries, and pad any remaining space + between tables with zeros + + Entries in the Table Directory must be sorted in ascending order by tag + + The head table contains checksum of the whole font file. + To compute: first set it to 0, sum the entire font as ULONG, + then store 0xB1B0AFBA - sum. + +@c +# include "font/luatexfont.h" +# undef MIN +# define MIN(a, b) (((a) < (b)) ? (a) : (b)) +# define STREAM_COMPRESS + +static unsigned char wbuf[1024], padbytes[4] = { 0, 0, 0, 0 }; + +pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) +{ + pdf_obj *stream; + struct sfnt_table_directory *td; + long offset, nb_read, length; + int i, sr; + char *p; + + ASSERT(sfont && sfont->directory); + + stream = pdf_new_stream(STREAM_COMPRESS); + + td = sfont->directory; + + /* Header */ + p = (char *) wbuf; + p += sfnt_put_ulong(p, (LONG) td->version); + p += sfnt_put_ushort(p, td->num_kept_tables); + sr = (int) (max2floor(td->num_kept_tables) * 16); + p += sfnt_put_ushort(p, sr); + p += sfnt_put_ushort(p, log2floor(td->num_kept_tables)); + p += sfnt_put_ushort(p, td->num_kept_tables * 16 - sr); + + pdf_add_stream(stream, wbuf, 12); + + /* + Compute start of actual tables (after headers). + */ + offset = 12 + 16 * td->num_kept_tables; + for (i = 0; i < td->num_tables; i++) { + /* This table must exist in FontFile */ + if (td->flags[i] & SFNT_TABLE_REQUIRED) { + if ((offset % 4) != 0) { + offset += 4 - (offset % 4); + } + + p = (char *) wbuf; + memcpy(p, td->tables[i].tag, 4); + p += 4; + p += sfnt_put_ulong(p, (LONG) td->tables[i].check_sum); + p += sfnt_put_ulong(p, offset); + p += sfnt_put_ulong(p, (LONG) td->tables[i].length); + pdf_add_stream(stream, wbuf, 16); + + offset = (long) (offset + (long) td->tables[i].length); + } + } + + offset = 12 + 16 * td->num_kept_tables; + for (i = 0; i < td->num_tables; i++) { + if (td->flags[i] & SFNT_TABLE_REQUIRED) { + if ((offset % 4) != 0) { + length = 4 - (offset % 4); + pdf_add_stream(stream, padbytes, length); + offset += length; + } + if (!td->tables[i].data) { + if (!sfont->buffer) + { + pdf_release_obj(stream); + TT_ERROR("Font file not opened or already closed..."); + return NULL; + } + + length = (long) td->tables[i].length; + sfnt_seek_set(sfont, (long) td->tables[i].offset); + while (length > 0) { + nb_read = sfnt_read(wbuf, (int) MIN(length, 1024), sfont); + if (nb_read < 0) { + pdf_release_obj(stream); + TT_ERROR("Reading file failed..."); + return NULL; + } else if (nb_read > 0) { + pdf_add_stream(stream, wbuf, nb_read); + } + length -= nb_read; + } + } else { + pdf_add_stream(stream, + (unsigned char *) td->tables[i].data, + (long) td->tables[i].length); + RELEASE(td->tables[i].data); + td->tables[i].data = NULL; + } + /* Set offset for next table */ + offset = (long) (offset + (long) td->tables[i].length); + } + } + + return stream; +} diff --git a/Build/source/texk/web2c/luatexdir/font/subfont.c b/Build/source/texk/web2c/luatexdir/font/subfont.c deleted file mode 100644 index 183c78b4f34..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/subfont.c +++ /dev/null @@ -1,276 +0,0 @@ -/* subfont.c - - Copyright 2005-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include - -static const char _svn_version[] = - "$Id: subfont.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/subfont.c $"; - -static struct avl_table *sfd_tree = NULL; - -static unsigned char *sfd_buffer = NULL; -static integer sfd_size = 0; -static integer sfd_curbyte = 0; - -#define SFD_BUF_SIZE SMALL_BUF_SIZE - -#define sfd_close() xfclose(sfd_file, cur_file_name) -#define sfd_open() (sfd_file = fopen((char *) nameoffile + 1, FOPEN_RBIN_MODE)) - -#define sfd_read_file() readbinfile(sfd_file,&sfd_buffer,&sfd_size) -#define sfd_getchar() sfd_buffer[sfd_curbyte++] -#define sfd_eof() (sfd_curbyte>sfd_size) - - -static FILE *sfd_file; -static char sfd_line[SFD_BUF_SIZE]; - -static subfont_entry *new_subfont_entry(void) -{ - int i; - subfont_entry *subfont; - subfont = xtalloc(1, subfont_entry); - subfont->infix = NULL; - for (i = 0; i < 256; ++i) - subfont->charcodes[i] = -1; /* unassigned */ - subfont->next = NULL; - return subfont; -} - -static sfd_entry *new_sfd_entry(void) -{ - sfd_entry *sfd; - sfd = xtalloc(1, sfd_entry); - sfd->name = NULL; - sfd->subfont = NULL; - return sfd; -} - -static void destroy_sfd_entry(void *pa, void *pb) -{ - subfont_entry *p, *q; - sfd_entry *sfd; - sfd = (sfd_entry *) pa; - (void) pb; - p = sfd->subfont; - while (p != NULL) { - q = p->next; - xfree(p->infix); - xfree(p); - p = q; - } - xfree(sfd->name); -} - -static int comp_sfd_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(((const sfd_entry *) pa)->name, - ((const sfd_entry *) pb)->name); -} - -void sfd_free(void) -{ - if (sfd_tree != NULL) - avl_destroy(sfd_tree, destroy_sfd_entry); -} - -static void sfd_getline(boolean expect_eof) -{ - char *p; - int c; - restart: - if (sfd_eof()) { - if (expect_eof) - return; - else - pdftex_fail("unexpected end of file"); - } - p = sfd_line; - do { - c = sfd_getchar(); - append_char_to_buf(c, p, sfd_line, SFD_BUF_SIZE); - } while (c != 10 && !sfd_eof()); - append_eol(p, sfd_line, SFD_BUF_SIZE); - if (p - sfd_line < 2 || *sfd_line == '#') - goto restart; -} - -static sfd_entry *read_sfd(char *sfd_name) -{ - void **aa; - sfd_entry *sfd, tmp_sfd; - subfont_entry *sf; - char *ftemp = NULL; - char buf[SMALL_BUF_SIZE], *p; - long int i, j, k; - int n; - int callback_id = 0; - int file_opened = 0; - /* check whether this sfd has been read */ - tmp_sfd.name = sfd_name; - if (sfd_tree == NULL) { - sfd_tree = avl_create(comp_sfd_entry, NULL, &avl_xallocator); - assert(sfd_tree != NULL); - } - sfd = (sfd_entry *) avl_find(sfd_tree, &tmp_sfd); - if (sfd != NULL) - return sfd; - set_cur_file_name(sfd_name); - if (sfd_buffer != NULL) { - xfree(sfd_buffer); - sfd_buffer = NULL; - } - sfd_curbyte = 0; - sfd_size = 0; - - callback_id = callback_defined(find_sfd_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->S", cur_file_name, &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - if (cur_file_name) - free(cur_file_name); - cur_file_name = xstrdup(ftemp); - free(ftemp); - } - } - } else { - cur_file_name = kpse_find_file(cur_file_name, kpse_sfd_format, 0); - } - callback_id = callback_defined(read_sfd_file_callback); - if (callback_id > 0) { - if (!(run_callback(callback_id, "S->bSd", cur_file_name, - &file_opened, &sfd_buffer, &sfd_size) && - file_opened && sfd_size > 0)) { - pdftex_warn("cannot open SFD file for reading"); - cur_file_name = NULL; - return NULL; - } - } else { - if (!sfd_open()) { - pdftex_warn("cannot open SFD file for reading"); - cur_file_name = NULL; - return NULL; - } - sfd_read_file(); - sfd_close(); - } - tex_printf("{"); - tex_printf("%s", cur_file_name); - sfd = new_sfd_entry(); - sfd->name = xstrdup(sfd_name); - while (!sfd_eof()) { - sfd_getline(true); - if (*sfd_line == 10) /* empty line indicating eof */ - break; - sf = new_subfont_entry(); - sf->next = sfd->subfont; - sfd->subfont = sf; - sscanf(sfd_line, "%s %n", buf, &n); - sf->infix = xstrdup(buf); - p = sfd_line + n; /* skip to the next word */ - k = 0; - read_ranges: - for (;;) { - if (*p == '\\') { /* continue on next line */ - sfd_getline(false); - p = sfd_line; - goto read_ranges; - } else if (*p == 0) /* end of subfont */ - break; - if (sscanf(p, " %li %n", &i, &n) == 0) - pdftex_fail("invalid token:\n%s", p); - p += n; - if (*p == ':') { /* offset */ - k = i; - p++; - } else if (*p == '_') { /* range */ - if (sscanf(p + 1, " %li %n", &j, &n) == 0) - pdftex_fail("invalid token:\n%s", p); - if (i > j || k + (j - i) > 255) - pdftex_fail("invalid range:\n%s", p); - while (i <= j) - sf->charcodes[k++] = i++; - p += n + 1; - } else /* codepoint */ - sf->charcodes[k++] = i; - } - } - tex_printf("}"); - aa = avl_probe(sfd_tree, sfd); - assert(aa != NULL); - return sfd; -} - -boolean handle_subfont_fm(fm_entry * fm, int mode) -{ - size_t l; - char *p, *q, *r; - sfd_entry *sfd; - subfont_entry *sf; - fm_entry *fm2; - char buf[SMALL_BUF_SIZE]; - assert(fm->tfm_name != NULL); - p = fm->tfm_name; - q = strchr(p, '@'); /* search for the first '@' */ - if (q == NULL) - return false; - r = strchr(q + 1, '@'); /* search for the second '@' */ - if (r == NULL) - return false; - if (q <= p || r <= q + 1 /* prefix or sfd name is empty */ - || r - p != (int) strlen(p) - 1) /* or the second '@' is not the last char yet */ - return false; - l = r - (q + 1); /* length of sfd name */ - strncpy(buf, q + 1, l); - buf[l] = 0; - check_buf(strlen(buf) + 4, SMALL_BUF_SIZE); - strcat(buf, ".sfd"); - sfd = read_sfd(buf); - if (sfd == NULL) - return false; - /* at this point we know fm is a subfont */ - set_subfont(fm); - xfree(fm->ps_name); - fm->ps_name = NULL; - /* set default values for PidEid */ - if (fm->pid == -1) { - fm->pid = 3; - fm->eid = 1; - } - l = q - p; /* length of base tfm name (prefix) */ - for (sf = sfd->subfont; sf != NULL; sf = sf->next) { - strncpy(buf, p, l); - buf[l] = 0; - strcat(buf, sf->infix); - fm2 = new_fm_entry(); - fm2->tfm_name = xstrdup(buf); - fm2->ff_name = xstrdup(fm->ff_name); - fm2->type = fm->type; - fm2->pid = fm->pid; - fm2->eid = fm->eid; - fm2->subfont = sf; - if (avl_do_entry(fm2, mode) != 0) /* try to insert the entry */ - delete_fm_entry(fm2); /* delete it if failed */ - } - delete_fm_entry(fm); - return true; -} diff --git a/Build/source/texk/web2c/luatexdir/font/subfont.txt b/Build/source/texk/web2c/luatexdir/font/subfont.txt index 9fe053cbb9c..eaefae02813 100644 --- a/Build/source/texk/web2c/luatexdir/font/subfont.txt +++ b/Build/source/texk/web2c/luatexdir/font/subfont.txt @@ -1,74 +1,43 @@ -map entry: +map entry:cyberb @ Unicode @ = >look at Unicode.sfd = >find the mapping = >charcode = >PidEid = 3, 1 = >glyphs eg cyberb01 = >subfont 01 in Unicode.sfd = >charcodes Infix can be anything, thus the question:given a tfm name, how to find out + whether this is a subfont ? + It is safe to limit the infix to be composed from hexadecimal digits only ? + If so, one possibility is : (1) + while last + -char -of - tfmname is a hexdigit + do + remove the last char from tfmname + do + a lookup for the tfmname + if found an entry with subfont flag then break enddo(2) + Or, when a map entry with subfont flag is scanned, + let pdftex create all the relevant entries. + Which may be a safer and faster solution(but wastes more memory) -cyberb@Unicode@ => look at Unicode.sfd => find the mapping => charcode - => PidEid=3,1 => glyphs - -eg cyberb01 => subfont 01 in Unicode.sfd => charcodes - -Infix can be anything, thus the question: given a tfm name, how to find out -whether this is a subfont? - -It is safe to limit the infix to be composed from hexadecimal digits only? - -If so, one possibility is: - -(1) -while last-char-of-tfmname is a hexdigit do - remove the last char from tfmname - do a lookup for the tfmname - if found an entry with subfont flag then - break -enddo - -(2) -Or, when a map entry with subfont flag is scanned, let pdftex create all -the relevant entries. Which may be a safer and faster solution (but wastes more -memory) - - -Let's do (2), as infix can be any word. + Let 's do (2), as infix can be any word. Implementation: -- let's have a map entry: - -cyberb@Unicode@ long[256] - - added those subfont to an AVL tree - - create map entries for cyberb01--cyberbff, each has a pointer to the - corresponding sfd mapping entry - -- extended attributes for map entry: - - Pid - - Eid - - sfd_map - -- sfd_mapping: - - name: sfd name, eg "Unicode" - - infix, eg "01" - - mapping: long[256] - -- how to find out whether a sfd has been loaded: - - lookup for any entry with the given sfd name - -- functions: - - load_sfd - - lookup_subfont - - extend reading map entries - -- when writting ttf: - - if re-encoded --> process like in case of type1 fonts - - if PidEid is being used: - - read cmap tables: store (ttfname, pid, eid) - - search for used chars - - use sfd to find the charcodes - - look into cmap to +- let' s have a map entry : cyberb @ Unicode @ long[256] + - added those subfont to an AVL tree - + create map entries for cyberb01-- cyberbff, + each has a pointer to the corresponding sfd mapping entry - + extended attributes for map entry:-Pid - Eid - sfd_map - + sfd_mapping:-name:sfd name, eg "Unicode" - infix, + eg "01" - mapping:long[256] + +-how to find out whether a sfd has been loaded: + -lookup for any entry with the given sfd + name - functions:-load_sfd - + lookup_subfont - + extend reading map entries - + when writting ttf:-if re - encoded-- > + process like in case of type1 fonts - + if PidEid is being used:-read cmap + tables:store(ttfname, pid, eid) + -search for used chars - use sfd to find the charcodes - look into cmap to diff --git a/Build/source/texk/web2c/luatexdir/font/subfont.w b/Build/source/texk/web2c/luatexdir/font/subfont.w new file mode 100644 index 00000000000..5ae8639bb41 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/subfont.w @@ -0,0 +1,266 @@ +% subfont.w +% +% Copyright 2005-2006 Han The Thanh +% Copyright 2006-2008 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" +#include + +static const char _svn_version[] = + "$Id: subfont.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/subfont.w $"; + +@ @c +static struct avl_table *sfd_tree = NULL; + +static unsigned char *sfd_buffer = NULL; +static int sfd_size = 0; +static int sfd_curbyte = 0; + +#define SFD_BUF_SIZE SMALL_BUF_SIZE + +#define sfd_close() xfclose(sfd_file, cur_file_name) +#define sfd_open(a) (sfd_file = fopen((char *)(a), FOPEN_RBIN_MODE)) + +#define sfd_read_file() readbinfile(sfd_file,&sfd_buffer,&sfd_size) +#define sfd_getchar() sfd_buffer[sfd_curbyte++] +#define sfd_eof() (sfd_curbyte>sfd_size) + + +static FILE *sfd_file; +static char sfd_line[SFD_BUF_SIZE]; + +static subfont_entry *new_subfont_entry(void) +{ + int i; + subfont_entry *subfont; + subfont = xtalloc(1, subfont_entry); + subfont->infix = NULL; + for (i = 0; i < 256; ++i) + subfont->charcodes[i] = -1; /* unassigned */ + subfont->next = NULL; + return subfont; +} + +static sfd_entry *new_sfd_entry(void) +{ + sfd_entry *sfd; + sfd = xtalloc(1, sfd_entry); + sfd->name = NULL; + sfd->subfont = NULL; + return sfd; +} + +static void destroy_sfd_entry(void *pa, void *pb) +{ + subfont_entry *p, *q; + sfd_entry *sfd; + sfd = (sfd_entry *) pa; + (void) pb; + p = sfd->subfont; + while (p != NULL) { + q = p->next; + xfree(p->infix); + xfree(p); + p = q; + } + xfree(sfd->name); +} + +static int comp_sfd_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return strcmp(((const sfd_entry *) pa)->name, + ((const sfd_entry *) pb)->name); +} + +void sfd_free(void) +{ + if (sfd_tree != NULL) + avl_destroy(sfd_tree, destroy_sfd_entry); +} + +static void sfd_getline(boolean expect_eof) +{ + char *p; + char c; + restart: + if (sfd_eof()) { + if (expect_eof) + return; + else + pdftex_fail("unexpected end of file"); + } + p = sfd_line; + do { + c = (char) sfd_getchar(); + append_char_to_buf(c, p, sfd_line, SFD_BUF_SIZE); + } while (c != 10 && !sfd_eof()); + append_eol(p, sfd_line, SFD_BUF_SIZE); + if (p - sfd_line < 2 || *sfd_line == '#') + goto restart; +} + +@ @c +static sfd_entry *read_sfd(char *sfd_name) +{ + void **aa; + sfd_entry *sfd, tmp_sfd; + subfont_entry *sf; + + char buf[SMALL_BUF_SIZE], *p; + long int i, j, k; + int n; + int callback_id = 0; + int file_opened = 0; + /* check whether this sfd has been read */ + tmp_sfd.name = sfd_name; + if (sfd_tree == NULL) { + sfd_tree = avl_create(comp_sfd_entry, NULL, &avl_xallocator); + assert(sfd_tree != NULL); + } + sfd = (sfd_entry *) avl_find(sfd_tree, &tmp_sfd); + if (sfd != NULL) + return sfd; + xfree(sfd_buffer); + sfd_curbyte = 0; + sfd_size = 0; + + cur_file_name = luatex_find_file(sfd_name, find_sfd_file_callback); + if (cur_file_name) { + callback_id = callback_defined(read_sfd_file_callback); + if (callback_id > 0) { + if (!(run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &sfd_buffer, &sfd_size) && + file_opened && sfd_size > 0)) { + pdftex_warn("cannot open SFD file for reading"); + cur_file_name = NULL; + return NULL; + } + } else { + if (!sfd_open(cur_file_name)) { + pdftex_warn("cannot open SFD file for reading"); + cur_file_name = NULL; + return NULL; + } + sfd_read_file(); + sfd_close(); + } + } + tex_printf("{"); + tex_printf("%s", cur_file_name); + sfd = new_sfd_entry(); + sfd->name = xstrdup(sfd_name); + while (!sfd_eof()) { + sfd_getline(true); + if (*sfd_line == 10) /* empty line indicating eof */ + break; + sf = new_subfont_entry(); + sf->next = sfd->subfont; + sfd->subfont = sf; + sscanf(sfd_line, "%s %n", buf, &n); + sf->infix = xstrdup(buf); + p = sfd_line + n; /* skip to the next word */ + k = 0; + read_ranges: + for (;;) { + if (*p == '\\') { /* continue on next line */ + sfd_getline(false); + p = sfd_line; + goto read_ranges; + } else if (*p == 0) /* end of subfont */ + break; + if (sscanf(p, " %li %n", &i, &n) == 0) + pdftex_fail("invalid token:\n%s", p); + p += n; + if (*p == ':') { /* offset */ + k = i; + p++; + } else if (*p == '_') { /* range */ + if (sscanf(p + 1, " %li %n", &j, &n) == 0) + pdftex_fail("invalid token:\n%s", p); + if (i > j || k + (j - i) > 255) + pdftex_fail("invalid range:\n%s", p); + while (i <= j) + sf->charcodes[k++] = i++; + p += n + 1; + } else /* codepoint */ + sf->charcodes[k++] = i; + } + } + tex_printf("}"); + aa = avl_probe(sfd_tree, sfd); + assert(aa != NULL); + return sfd; +} + +@ @c +boolean handle_subfont_fm(fm_entry * fm, int mode) +{ + size_t l; + char *p, *q, *r; + sfd_entry *sfd; + subfont_entry *sf; + fm_entry *fm2; + char buf[SMALL_BUF_SIZE]; + assert(fm->tfm_name != NULL); + p = fm->tfm_name; + q = strchr(p, '@@'); /* search for the first '@@' */ + if (q == NULL) + return false; + r = strchr(q + 1, '@@'); /* search for the second '@@' */ + if (r == NULL) + return false; + if (q <= p || r <= q + 1 /* prefix or sfd name is empty */ + || r - p != (int) strlen(p) - 1) /* or the second '@@' is not the last char yet */ + return false; + l = (size_t) (r - (q + 1)); /* length of sfd name */ + strncpy(buf, q + 1, l); + buf[l] = 0; + check_buf(strlen(buf) + 4, SMALL_BUF_SIZE); + strcat(buf, ".sfd"); + sfd = read_sfd(buf); + if (sfd == NULL) + return false; + /* at this point we know fm is a subfont */ + set_subfont(fm); + xfree(fm->ps_name); + /* set default values for PidEid */ + if (fm->pid == -1) { + fm->pid = 3; + fm->eid = 1; + } + l = (size_t) (q - p); /* length of base tfm name (prefix) */ + for (sf = sfd->subfont; sf != NULL; sf = sf->next) { + strncpy(buf, p, l); + buf[l] = 0; + strcat(buf, sf->infix); + fm2 = new_fm_entry(); + fm2->tfm_name = xstrdup(buf); + fm2->ff_name = xstrdup(fm->ff_name); + fm2->type = fm->type; + fm2->pid = fm->pid; + fm2->eid = fm->eid; + fm2->subfont = sf; + if (avl_do_entry(fm2, mode) != 0) /* try to insert the entry */ + delete_fm_entry(fm2); /* delete it if failed */ + } + delete_fm_entry(fm); + return true; +} diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.c b/Build/source/texk/web2c/luatexdir/font/texfont.c deleted file mode 100644 index 6e64053aa9a..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/texfont.c +++ /dev/null @@ -1,1752 +0,0 @@ -/* texfont.c Main font API implementation for the pascal parts - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -/* Main font API implementation for the pascal parts */ - -/* stuff to watch out for: - * - * - Knuth had a 'null_character' that was used when a character could - * not be found by the fetch() routine, to signal an error. This has - * been deleted, but it may mean that the output of luatex is - * incompatible with TeX after fetch() has detected an error condition. - * - * - Knuth also had a font_glue() optimization. I've removed that - * because it was a bit of dirty programming and it also was - * problematic if 0 != null. - */ - -#include "ptexlib.h" -#include "luatex-api.h" -#include "luatexfont.h" - -#define noDEBUG - -static const char _svn_version[] = - "$Id: texfont.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/texfont.c $"; - -#define proper_char_index(c) (c<=font_ec(f) && c>=font_bc(f)) -#define dxfree(a,b) { xfree(a); a = b ; } -#define do_realloc(a,b,d) a = xrealloc(a,(b)*sizeof(d)) - -texfont **font_tables = NULL; - -static integer font_arr_max = 0; -static integer font_id_maxval = 0; - -static void grow_font_table(integer id) -{ - int j; - if (id >= font_arr_max) { - font_bytes += (font_arr_max - id + 8) * sizeof(texfont *); - font_tables = xrealloc(font_tables, (id + 8) * sizeof(texfont *)); - j = 8; - while (j--) { - font_tables[id + j] = NULL; - } - font_arr_max = id + 8; - } -} - -integer new_font_id(void) -{ - int i; - for (i = 0; i < font_arr_max; i++) { - if (font_tables[i] == NULL) { - break; - } - } - if (i >= font_arr_max) - grow_font_table(i); - if (i > font_id_maxval) - font_id_maxval = i; - return i; -} - -integer max_font_id(void) -{ - return font_id_maxval; -} - -void set_max_font_id(integer i) -{ - font_id_maxval = i; -} - -integer new_font(void) -{ - int k; - int id; - charinfo *ci; - id = new_font_id(); - font_bytes += sizeof(texfont); - /* most stuff is zero */ - font_tables[id] = xcalloc(1, sizeof(texfont)); - font_tables[id]->_font_name = NULL; - font_tables[id]->_font_area = NULL; - font_tables[id]->_font_filename = NULL; - font_tables[id]->_font_fullname = NULL; - font_tables[id]->_font_encodingname = NULL; - font_tables[id]->_font_cidregistry = NULL; - font_tables[id]->_font_cidordering = NULL; - font_tables[id]->_left_boundary = NULL; - font_tables[id]->_right_boundary = NULL; - font_tables[id]->_param_base = NULL; - font_tables[id]->_math_param_base = NULL; - - set_font_bc(id, 1); /* ec = 0 */ - set_hyphen_char(id, '-'); - set_skew_char(id, -1); - - /* allocate eight values including 0 */ - set_font_params(id, 7); - for (k = 0; k <= 7; k++) { - set_font_param(id, k, 0); - } - /* character info zero is reserved for notdef */ - font_tables[id]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */ - - ci = xcalloc(1, sizeof(charinfo)); - set_charinfo_name(ci, xstrdup(".notdef")); - font_tables[id]->charinfo = ci; - font_tables[id]->charinfo_size = 1; - font_tables[id]->charinfo_cache = NULL; - - return id; -} - -#define find_charinfo_id(f,c) get_sa_item(font_tables[f]->characters,c) - -charinfo *get_charinfo(internal_font_number f, integer c) -{ - sa_tree_item glyph; - charinfo *ci; - if (proper_char_index(c)) { - glyph = get_sa_item(font_tables[f]->characters, c); - if (!glyph) { - - glyph = ++font_tables[f]->charinfo_count; - if (glyph >= (unsigned) font_tables[f]->charinfo_size) { - font_bytes += (16 * sizeof(charinfo)); - do_realloc(font_tables[f]->charinfo, (glyph + 16), charinfo); - memset(&(font_tables[f]->charinfo[glyph]), 0, - (16 * sizeof(charinfo))); - font_tables[f]->charinfo_size += 16; - } - font_tables[f]->charinfo[glyph].ef = 1000; /* init */ - set_sa_item(font_tables[f]->characters, c, glyph, 1); /* 1= global */ - } - return &(font_tables[f]->charinfo[glyph]); - } else if (c == left_boundarychar) { - if (left_boundary(f) == NULL) { - ci = xcalloc(1, sizeof(charinfo)); - font_bytes += sizeof(charinfo); - set_left_boundary(f, ci); - } - return left_boundary(f); - } else if (c == right_boundarychar) { - if (right_boundary(f) == NULL) { - ci = xcalloc(1, sizeof(charinfo)); - font_bytes += sizeof(charinfo); - set_right_boundary(f, ci); - } - return right_boundary(f); - } - return &(font_tables[f]->charinfo[0]); -} - -static void set_charinfo(internal_font_number f, integer c, charinfo * ci) -{ - sa_tree_item glyph; - if (proper_char_index(c)) { - glyph = get_sa_item(font_tables[f]->characters, c); - if (glyph) { - font_tables[f]->charinfo[glyph] = *ci; - } else { - pdftex_fail("font: %s", "character insertion failed"); - } - } else if (c == left_boundarychar) { - set_left_boundary(f, ci); - } else if (c == right_boundarychar) { - set_right_boundary(f, ci); - } -} - - - -charinfo *copy_charinfo(charinfo * ci) -{ - int x; - kerninfo *kern; - liginfo *lig; - real_eight_bits *packet; - charinfo *co = NULL; - if (ci == NULL) - return NULL; - co = xmalloc(sizeof(charinfo)); - memcpy(co, ci, sizeof(charinfo)); - set_charinfo_used(co, false); - co->name = NULL; - co->tounicode = NULL; - co->packets = NULL; - co->ligatures = NULL; - co->kerns = NULL; - co->vert_variants = NULL; - co->hor_variants = NULL; - if (ci->name != NULL) { - co->name = xstrdup(ci->name); - } - if (ci->tounicode != NULL) { - co->tounicode = xstrdup(ci->tounicode); - } - /* kerns */ - if ((kern = get_charinfo_kerns(ci)) != NULL) { - x = 0; - while (!kern_end(kern[x])) { - x++; - } - x++; - co->kerns = xmalloc(x * sizeof(kerninfo)); - memcpy(co->kerns, ci->kerns, (x * sizeof(kerninfo))); - } - /* ligs */ - if ((lig = get_charinfo_ligatures(ci)) != NULL) { - x = 0; - while (!lig_end(lig[x])) { - x++; - } - x++; - co->ligatures = xmalloc(x * sizeof(liginfo)); - memcpy(co->ligatures, ci->ligatures, (x * sizeof(liginfo))); - } - /* packets */ - if ((packet = get_charinfo_packets(ci)) != NULL) { - x = vf_packet_bytes(ci); - co->packets = xmalloc(x); - memcpy(co->packets, ci->packets, x); - } - - /* horizontal and vertical extenders */ - if (get_charinfo_vert_variants(ci) != NULL) { - set_charinfo_vert_variants(co, - copy_variants(get_charinfo_vert_variants - (ci))); - } - if (get_charinfo_hor_variants(ci) != NULL) { - set_charinfo_hor_variants(co, - copy_variants(get_charinfo_hor_variants(ci))); - } - /* TODO: copy mathkerns */ - x = ci->top_left_math_kerns; - co->top_left_math_kerns = x; - if (x > 0) { - co->top_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < co->top_left_math_kerns; k++) { - co->top_left_math_kern_array[(2 * k)] = - ci->top_left_math_kern_array[(2 * k)]; - co->top_left_math_kern_array[(2 * k) + 1] = - ci->top_left_math_kern_array[(2 * k) + 1]; - } - } - x = ci->top_right_math_kerns; - co->top_right_math_kerns = x; - if (x > 0) { - co->top_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < co->top_right_math_kerns; k++) { - co->top_right_math_kern_array[(2 * k)] = - ci->top_right_math_kern_array[(2 * k)]; - co->top_right_math_kern_array[(2 * k) + 1] = - ci->top_right_math_kern_array[(2 * k) + 1]; - } - } - x = ci->bottom_right_math_kerns; - co->bottom_right_math_kerns = x; - if (x > 0) { - co->bottom_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < co->bottom_right_math_kerns; k++) { - co->bottom_right_math_kern_array[(2 * k)] = - ci->bottom_right_math_kern_array[(2 * k)]; - co->bottom_right_math_kern_array[(2 * k) + 1] = - ci->bottom_right_math_kern_array[(2 * k) + 1]; - } - } - x = ci->bottom_left_math_kerns; - co->bottom_left_math_kerns = x; - if (x > 0) { - co->bottom_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < co->bottom_left_math_kerns; k++) { - co->bottom_left_math_kern_array[(2 * k)] = - ci->bottom_left_math_kern_array[(2 * k)]; - co->bottom_left_math_kern_array[(2 * k) + 1] = - ci->bottom_left_math_kern_array[(2 * k) + 1]; - } - } - - - return co; -} - -charinfo *char_info(internal_font_number f, integer c) -{ - if (f > font_id_maxval) - return 0; - if (proper_char_index(c)) { - register int glyph = find_charinfo_id(f, c); - return &(font_tables[f]->charinfo[glyph]); - } else if (c == left_boundarychar && left_boundary(f) != NULL) { - return left_boundary(f); - } else if (c == right_boundarychar && right_boundary(f) != NULL) { - return right_boundary(f); - } - return &(font_tables[f]->charinfo[0]); -} - -charinfo_short char_info_short(internal_font_number f, integer c) -{ - charinfo_short s; - charinfo *i; - i = char_info(f, c); - s.ci_wd = i->width; - s.ci_dp = i->depth; - s.ci_ht = i->height; - return s; -} - -integer char_exists(internal_font_number f, integer c) -{ - if (f > font_id_maxval) - return 0; - if (proper_char_index(c)) { - return find_charinfo_id(f, c); - } else if ((c == left_boundarychar) && has_left_boundary(f)) { - return 1; - } else if ((c == right_boundarychar) && has_right_boundary(f)) { - return 1; - } - return 0; -} - -#if 0 /* unused */ -static int lua_char_exists_callback(internal_font_number f, integer c) -{ - integer callback_id; - lua_State *L = Luas; - int ret = 0; - callback_id = callback_defined(char_exists_callback); - if (callback_id != 0) { - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); - return 0; - } - lua_pushnumber(L, f); - lua_pushnumber(L, c); - if (lua_pcall(L, 2, 1, 0) != 0) { /* two args, 1 result */ - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); - error(); - } else { - ret = lua_toboolean(L, -1); - } - } - return ret; -} -#endif - - -extinfo *new_variant(int glyph, int startconnect, int endconnect, - int advance, int repeater) -{ - extinfo *ext; - ext = xmalloc(sizeof(extinfo)); - ext->next = NULL; - ext->glyph = glyph; - ext->start_overlap = startconnect; - ext->end_overlap = endconnect; - ext->advance = advance; - ext->extender = repeater; - return ext; -} - - -static extinfo *copy_variant(extinfo * old) -{ - extinfo *ext; - ext = xmalloc(sizeof(extinfo)); - ext->next = NULL; - ext->glyph = old->glyph; - ext->start_overlap = old->start_overlap; - ext->end_overlap = old->end_overlap; - ext->advance = old->advance; - ext->extender = old->extender; - return ext; -} - -static void dump_variant(extinfo * ext) -{ - dump_int(ext->glyph); - dump_int(ext->start_overlap); - dump_int(ext->end_overlap); - dump_int(ext->advance); - dump_int(ext->extender); - return; -} - - -static extinfo *undump_variant(void) -{ - integer x; - extinfo *ext; - undump_int(x); - if (x == 0) - return NULL; - ext = xmalloc(sizeof(extinfo)); - ext->next = NULL; - ext->glyph = x; - undump_int(x); - ext->start_overlap = x; - undump_int(x); - ext->end_overlap = x; - undump_int(x); - ext->advance = x; - undump_int(x); - ext->extender = x; - return ext; -} - -void add_charinfo_vert_variant(charinfo * ci, extinfo * ext) -{ - if (ci->vert_variants == NULL) { - ci->vert_variants = ext; - } else { - extinfo *lst = ci->vert_variants; - while (lst->next != NULL) - lst = lst->next; - lst->next = ext; - } - -} - -void add_charinfo_hor_variant(charinfo * ci, extinfo * ext) -{ - if (ci->hor_variants == NULL) { - ci->hor_variants = ext; - } else { - extinfo *lst = ci->hor_variants; - while (lst->next != NULL) - lst = lst->next; - lst->next = ext; - } - -} - -extinfo *copy_variants(extinfo * o) -{ - extinfo *c, *t = NULL, *h = NULL; - while (o != NULL) { - c = copy_variant(o); - if (h == null) - h = c; - else - t->next = c; - t = c; - o = o->next; - } - - return h; -} - - -static void dump_charinfo_variants(extinfo * o) -{ - while (o != NULL) { - dump_variant(o); - o = o->next; - } - dump_int(0); - return; -} - -static extinfo *undump_charinfo_variants(void) -{ - extinfo *c, *t, *h = NULL; - c = undump_variant(); - while (c != NULL) { - if (h == null) - h = c; - else - t->next = c; - t = c; - c = undump_variant(); - } - return h; -} - - -void set_charinfo_width(charinfo * ci, scaled val) -{ - ci->width = val; -} - -void set_charinfo_height(charinfo * ci, scaled val) -{ - ci->height = val; -} - -void set_charinfo_depth(charinfo * ci, scaled val) -{ - ci->depth = val; -} - -void set_charinfo_italic(charinfo * ci, scaled val) -{ - ci->italic = val; -} - -void set_charinfo_top_accent(charinfo * ci, scaled val) -{ - ci->top_accent = val; -} - -void set_charinfo_bot_accent(charinfo * ci, scaled val) -{ - ci->bot_accent = val; -} - -void set_charinfo_tag(charinfo * ci, scaled val) -{ - ci->tag = val; -} - -void set_charinfo_remainder(charinfo * ci, scaled val) -{ - ci->remainder = val; -} - -void set_charinfo_used(charinfo * ci, scaled val) -{ - ci->used = val; -} - -void set_charinfo_index(charinfo * ci, scaled val) -{ - ci->index = val; -} -void set_charinfo_name(charinfo * ci, char *val) -{ - dxfree(ci->name, val); -} -void set_charinfo_tounicode(charinfo * ci, char *val) -{ - dxfree(ci->tounicode, val); -} - -void set_charinfo_ligatures(charinfo * ci, liginfo * val) -{ - dxfree(ci->ligatures, val); -} - -void set_charinfo_kerns(charinfo * ci, kerninfo * val) -{ - dxfree(ci->kerns, val); -} - -void set_charinfo_packets(charinfo * ci, real_eight_bits * val) -{ - dxfree(ci->packets, val); -} - -void set_charinfo_ef(charinfo * ci, scaled val) -{ - ci->ef = val; -} - -void set_charinfo_lp(charinfo * ci, scaled val) -{ - ci->lp = val; -} - -void set_charinfo_rp(charinfo * ci, scaled val) -{ - ci->rp = val; -} - -void set_charinfo_vert_variants(charinfo * ci, extinfo * ext) -{ - extinfo *c, *lst; - if (ci->vert_variants != NULL) { - lst = ci->vert_variants; - while (lst != NULL) { - c = lst->next; - free(lst); - lst = c; - } - } - ci->vert_variants = ext; -} - -void set_charinfo_hor_variants(charinfo * ci, extinfo * ext) -{ - extinfo *c, *lst; - if (ci->hor_variants != NULL) { - lst = ci->hor_variants; - while (lst != NULL) { - c = lst->next; - free(lst); - lst = c; - } - } - ci->hor_variants = ext; - -} - -int get_charinfo_math_kerns(charinfo * ci, int id) -{ - - int k = 0; /* all callers check for result>0 */ - if (id == top_left_kern) { - k = ci->top_left_math_kerns; - } else if (id == bottom_left_kern) { - k = ci->bottom_left_math_kerns; - } else if (id == bottom_right_kern) { - k = ci->bottom_right_math_kerns; - } else if (id == top_right_kern) { - k = ci->top_right_math_kerns; - } else { - tconfusion("get_charinfo_math_kerns"); - } - return k; -} - -void add_charinfo_math_kern(charinfo * ci, int id, scaled ht, scaled krn) -{ - int k; - if (id == top_left_kern) { - k = ci->top_left_math_kerns; - do_realloc(ci->top_left_math_kern_array, ((k + 1) * 2), sizeof(scaled)); - ci->top_left_math_kern_array[(2 * (k))] = ht; - ci->top_left_math_kern_array[((2 * (k)) + 1)] = krn; - ci->top_left_math_kerns++; - } else if (id == bottom_left_kern) { - k = ci->bottom_left_math_kerns; - do_realloc(ci->bottom_left_math_kern_array, ((k + 1) * 2), - sizeof(scaled)); - ci->bottom_left_math_kern_array[(2 * (k))] = ht; - ci->bottom_left_math_kern_array[(2 * (k)) + 1] = krn; - ci->bottom_left_math_kerns++; - } else if (id == bottom_right_kern) { - k = ci->bottom_right_math_kerns; - do_realloc(ci->bottom_right_math_kern_array, ((k + 1) * 2), - sizeof(scaled)); - ci->bottom_right_math_kern_array[(2 * (k))] = ht; - ci->bottom_right_math_kern_array[(2 * (k)) + 1] = krn; - ci->bottom_right_math_kerns++; - } else if (id == top_right_kern) { - k = ci->top_right_math_kerns; - do_realloc(ci->top_right_math_kern_array, ((k + 1) * 2), - sizeof(scaled)); - ci->top_right_math_kern_array[(2 * (k))] = ht; - ci->top_right_math_kern_array[(2 * (k)) + 1] = krn; - ci->top_right_math_kerns++; - } else { - tconfusion("add_charinfo_math_kern"); - } -} - - -static void dump_math_kerns(charinfo * ci) -{ - integer k, l; - l = ci->top_left_math_kerns; - dump_int(l); - for (k = 0; k < l; k++) { - dump_int(ci->top_left_math_kern_array[(2 * k)]); - dump_int(ci->top_left_math_kern_array[(2 * k) + 1]); - } - l = ci->bottom_left_math_kerns; - dump_int(l); - for (k = 0; k < l; k++) { - dump_int(ci->bottom_left_math_kern_array[(2 * k)]); - dump_int(ci->bottom_left_math_kern_array[(2 * k) + 1]); - } - l = ci->bottom_right_math_kerns; - dump_int(l); - for (k = 0; k < l; k++) { - dump_int(ci->bottom_right_math_kern_array[(2 * k)]); - dump_int(ci->bottom_right_math_kern_array[(2 * k) + 1]); - } - l = ci->top_right_math_kerns; - dump_int(l); - for (k = 0; k < l; k++) { - dump_int(ci->bottom_left_math_kern_array[(2 * k)]); - dump_int(ci->bottom_left_math_kern_array[(2 * k) + 1]); - } -} - -static void undump_math_kerns(charinfo * ci) -{ - int k; - integer x; - undump_int(x); - ci->top_left_math_kerns = (int) x; - if (x > 0) - ci->top_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < ci->top_left_math_kerns; k++) { - undump_int(x); - ci->top_left_math_kern_array[(2 * k)] = (scaled) x; - undump_int(x); - ci->top_left_math_kern_array[(2 * k) + 1] = (scaled) x; - } - undump_int(x); - ci->bottom_left_math_kerns = (int) x; - if (x > 0) - ci->bottom_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < ci->bottom_left_math_kerns; k++) { - undump_int(x); - ci->bottom_left_math_kern_array[(2 * k)] = (scaled) x; - undump_int(x); - ci->bottom_left_math_kern_array[(2 * k) + 1] = (scaled) x; - } - undump_int(x); - ci->bottom_right_math_kerns = (int) x; - if (x > 0) - ci->bottom_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < ci->bottom_right_math_kerns; k++) { - undump_int(x); - ci->bottom_right_math_kern_array[(2 * k)] = (scaled) x; - undump_int(x); - ci->bottom_right_math_kern_array[(2 * k) + 1] = (scaled) x; - } - undump_int(x); - ci->top_right_math_kerns = (int) x; - if (x > 0) - ci->top_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); - for (k = 0; k < ci->top_right_math_kerns; k++) { - undump_int(x); - ci->top_right_math_kern_array[(2 * k)] = (scaled) x; - undump_int(x); - ci->top_right_math_kern_array[(2 * k) + 1] = (scaled) x; - } -} - - -/* In TeX, extensibles were fairly simple things. - This function squeezes a TFM extensible into the vertical extender structures. - |advance==0| is a special case for TFM fonts, because finding the proper - advance width during tfm reading can be tricky -*/ - -/* a small complication arises if |rep| is the only non-zero: it needs to be - doubled as a non-repeatable to avoid mayhem */ - -void set_charinfo_extensible(charinfo * ci, int top, int bot, int mid, int rep) -{ - extinfo *ext; - set_charinfo_vert_variants(ci, NULL); /* clear old */ - if (bot == 0 && top == 0 && mid == 0 && rep != 0) { - ext = new_variant(rep, 0, 0, 0, EXT_NORMAL); - add_charinfo_vert_variant(ci, ext); - ext = new_variant(rep, 0, 0, 0, EXT_REPEAT); - add_charinfo_vert_variant(ci, ext); - return; - } - if (bot != 0) { - ext = new_variant(bot, 0, 0, 0, EXT_NORMAL); - add_charinfo_vert_variant(ci, ext); - } - if (rep != 0) { - ext = new_variant(rep, 0, 0, 0, EXT_REPEAT); - add_charinfo_vert_variant(ci, ext); - } - if (mid != 0) { - ext = new_variant(mid, 0, 0, 0, EXT_NORMAL); - add_charinfo_vert_variant(ci, ext); - if (rep != 0) { - ext = new_variant(rep, 0, 0, 0, EXT_REPEAT); - add_charinfo_vert_variant(ci, ext); - } - } - if (top != 0) { - ext = new_variant(top, 0, 0, 0, EXT_NORMAL); - add_charinfo_vert_variant(ci, ext); - } -} - -scaled get_charinfo_width(charinfo * ci) -{ - return ci->width; -} - -scaled get_charinfo_height(charinfo * ci) -{ - return ci->height; -} - -scaled get_charinfo_depth(charinfo * ci) -{ - return ci->depth; -} - -scaled get_charinfo_italic(charinfo * ci) -{ - return ci->italic; -} - -scaled get_charinfo_top_accent(charinfo * ci) -{ - return ci->top_accent; -} - -scaled get_charinfo_bot_accent(charinfo * ci) -{ - return ci->bot_accent; -} - -char get_charinfo_tag(charinfo * ci) -{ - return ci->tag; -} - -integer get_charinfo_remainder(charinfo * ci) -{ - return ci->remainder; -} - -char get_charinfo_used(charinfo * ci) -{ - return ci->used; -} - -integer get_charinfo_index(charinfo * ci) -{ - return ci->index; -} - -char *get_charinfo_name(charinfo * ci) -{ - return ci->name; -} - -char *get_charinfo_tounicode(charinfo * ci) -{ - return ci->tounicode; -} - -liginfo *get_charinfo_ligatures(charinfo * ci) -{ - return ci->ligatures; -} - -kerninfo *get_charinfo_kerns(charinfo * ci) -{ - return ci->kerns; -} - -real_eight_bits *get_charinfo_packets(charinfo * ci) -{ - return ci->packets; -} - -integer get_charinfo_ef(charinfo * ci) -{ - return ci->ef; -} - -integer get_charinfo_rp(charinfo * ci) -{ - return ci->rp; -} - -integer get_charinfo_lp(charinfo * ci) -{ - return ci->lp; -} - -extinfo *get_charinfo_vert_variants(charinfo * ci) -{ - extinfo *w = NULL; - if (ci->vert_variants != NULL) - w = ci->vert_variants; - return w; -} - -extinfo *get_charinfo_hor_variants(charinfo * ci) -{ - extinfo *w = NULL; - if (ci->hor_variants != NULL) - w = ci->hor_variants; - return w; -} - - -scaled char_width(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - scaled w = get_charinfo_width(ci); - /*fprintf(stdout,"width of char 0x%x in font %s: %i\n",c,font_name(f),w); */ - return w; -} - -scaled char_depth(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - scaled w = get_charinfo_depth(ci); - /*fprintf(stdout,"depth of char 0x%x in font %s: %i\n",c,font_name(f),w); */ - return w; -} - -scaled char_height(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - scaled w = get_charinfo_height(ci); - /*fprintf(stdout,"height of char 0x%x in font %s: %i\n",c,font_name(f),w); */ - return w; -} - -scaled char_italic(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_italic(ci); -} - -scaled char_top_accent(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_top_accent(ci); -} - -scaled char_bot_accent(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_bot_accent(ci); -} - - -integer char_remainder(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_remainder(ci); -} - -char char_tag(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_tag(ci); -} - -char char_used(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_used(ci); -} - -char *char_name(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_name(ci); -} - -integer char_index(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_index(ci); -} - -liginfo *char_ligatures(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_ligatures(ci); -} - -kerninfo *char_kerns(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_kerns(ci); -} - -real_eight_bits *char_packets(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_packets(ci); -} - - -void set_font_params(internal_font_number f, int b) -{ - int i; - i = font_params(f); - if (i != b) { - font_bytes += (b - font_params(f) + 1) * sizeof(scaled); - do_realloc(param_base(f), (b + 2), integer); - font_params(f) = b; - if (b > i) { - while (i < b) { - i++; - set_font_param(f, i, 0); - } - } - } -} - -void set_font_math_params(internal_font_number f, int b) -{ - int i; - i = font_math_params(f); - if (i != b) { - font_bytes += (b - font_math_params(f) + 1) * sizeof(scaled); - do_realloc(math_param_base(f), (b + 2), integer); - font_math_params(f) = b; - if (b > i) { - while (i < b) { - i++; - set_font_math_param(f, i, undefined_math_parameter); - } - } - } -} - - - -integer copy_font(integer f) -{ - int i; - charinfo *ci; - integer k = new_font(); - memcpy(font_tables[k], font_tables[f], sizeof(texfont)); - - set_font_cache_id(k, 0); - set_font_used(k, 0); - set_font_touched(k, 0); - - font_tables[k]->_font_name = NULL; - font_tables[k]->_font_filename = NULL; - font_tables[k]->_font_fullname = NULL; - font_tables[k]->_font_encodingname = NULL; - font_tables[k]->_font_area = NULL; - font_tables[k]->_font_cidregistry = NULL; - font_tables[k]->_font_cidordering = NULL; - font_tables[k]->_left_boundary = NULL; - font_tables[k]->_right_boundary = NULL; - - set_font_name(k, xstrdup(font_name(f))); - if (font_filename(f) != NULL) - set_font_filename(k, xstrdup(font_filename(f))); - if (font_fullname(f) != NULL) - set_font_fullname(k, xstrdup(font_fullname(f))); - if (font_encodingname(f) != NULL) - set_font_encodingname(k, xstrdup(font_encodingname(f))); - if (font_area(f) != NULL) - set_font_area(k, xstrdup(font_area(f))); - if (font_cidregistry(f) != NULL) - set_font_cidregistry(k, xstrdup(font_cidregistry(f))); - if (font_cidordering(f) != NULL) - set_font_cidordering(k, xstrdup(font_cidordering(f))); - - i = sizeof(*param_base(f)) * font_params(f); - font_bytes += i; - param_base(k) = xmalloc(i); - memcpy(param_base(k), param_base(f), i); - - if (font_math_params(f) > 0) { - i = sizeof(*math_param_base(f)) * font_math_params(f); - font_bytes += i; - math_param_base(k) = xmalloc(i); - memcpy(math_param_base(k), math_param_base(f), i); - } - - i = sizeof(charinfo) * (font_tables[f]->charinfo_size + 1); - font_bytes += i; - font_tables[k]->charinfo = xmalloc(i); - memset(font_tables[k]->charinfo, 0, i); - for (i = 0; i < font_tables[k]->charinfo_size; i++) { - ci = copy_charinfo(&font_tables[f]->charinfo[i]); - font_tables[k]->charinfo[i] = *ci; - } - - if (left_boundary(f) != NULL) { - ci = copy_charinfo(left_boundary(f)); - set_charinfo(k, left_boundarychar, ci); - } - - if (right_boundary(f) != NULL) { - ci = copy_charinfo(right_boundary(f)); - set_charinfo(k, right_boundarychar, ci); - } - return k; -} - -void delete_font(integer f) -{ - int i; - charinfo *co; - assert(f > 0); - if (font_tables[f] != NULL) { - set_font_name(f, NULL); - set_font_filename(f, NULL); - set_font_fullname(f, NULL); - set_font_encodingname(f, NULL); - set_font_area(f, NULL); - set_font_cidregistry(f, NULL); - set_font_cidordering(f, NULL); - set_left_boundary(f, NULL); - set_right_boundary(f, NULL); - - for (i = font_bc(f); i <= font_ec(f); i++) { - if (char_exists(f, i)) { - co = char_info(f, i); - set_charinfo_name(co, NULL); - set_charinfo_tounicode(co, NULL); - set_charinfo_packets(co, NULL); - set_charinfo_ligatures(co, NULL); - set_charinfo_kerns(co, NULL); - set_charinfo_vert_variants(co, NULL); - set_charinfo_hor_variants(co, NULL); - } - } - /* free .notdef */ - set_charinfo_name(font_tables[f]->charinfo + 0, NULL); - free(font_tables[f]->charinfo); - destroy_sa_tree(font_tables[f]->characters); - - free(param_base(f)); - if (math_param_base(f) != NULL) - free(math_param_base(f)); - free(font_tables[f]); - font_tables[f] = NULL; - - if (font_id_maxval == f) { - font_id_maxval--; - } - } -} - -void create_null_font(void) -{ - int i = new_font(); - assert(i == 0); - set_font_name(i, xstrdup("nullfont")); - set_font_area(i, xstrdup("")); - set_font_touched(i, 1); -} - -boolean is_valid_font(integer id) -{ - int ret = 0; - if (id >= 0 && id <= font_id_maxval && font_tables[id] != NULL) - ret = 1; - return ret; -} - -/* return 1 == identical */ -boolean cmp_font_name(integer id, str_number t) -{ - char *tid, *tt; - if (!is_valid_font(id)) - return 0; - tt = makecstring(t); - tid = font_name(id); - if (tt == NULL && tid == NULL) - return 1; - if (tt == NULL || tid == NULL || strcmp(tid, tt) != 0) - return 0; - return 1; -} - -boolean cmp_font_area(integer id, str_number t) -{ - char *tt = NULL; - char *tid = font_area(id); - if (t == 0) { - if (tid == NULL || strlen(tid) == 0) - return 1; - else - return 0; - } - tt = makecstring(t); - if ((tt == NULL || strlen(tt) == 0) && (tid == NULL || strlen(tid) == 0)) - return 1; - if (tt == NULL || strcmp(tid, tt) != 0) - return 0; - return 1; -} - - -static boolean same_font_name(integer id, integer t) -{ - int ret = 0; - if (font_name(t) == NULL || - font_name(id) == NULL || strcmp(font_name(t), font_name(id)) != 0) { - ; - } else { - ret = 1; - } - return ret; -} - -boolean font_shareable(internal_font_number f, internal_font_number k) -{ - int ret = 0; - /* For some lua-loaded (for instance AFM) fonts, it is normal to have - a zero cidregistry, and such fonts do not have a fontmap entry yet - at this point, so the test shoulh use the other branch */ - if (font_cidregistry(f) == NULL && font_cidregistry(k) == NULL && - font_encodingbytes(f) != 2 && font_encodingbytes(k) != 2) { - if (hasfmentry(k) - && (font_map(k) == font_map(f)) - && (same_font_name(k, f) - || (pdf_font_auto_expand(f) - && (pdf_font_blink(f) != 0) /* 0 = nullfont */ - &&same_font_name(k, pdf_font_blink(f))))) { - ret = 1; - } - } else { - if ((font_filename(k) != NULL && font_filename(f) != NULL && - strcmp(font_filename(k), font_filename(f)) == 0 && - font_fullname(k) != NULL && font_fullname(f) != NULL && - strcmp(font_fullname(k), font_fullname(f)) == 0) - || (pdf_font_auto_expand(f) - && (pdf_font_blink(f) != 0) /* 0 = nullfont */ - &&same_font_name(k, pdf_font_blink(f)))) { - ret = 1; - } -#ifdef DEBUG - printf("font_shareable(%d:%s:%s,%d:%s:%s): => %d\n", - f, font_filename(f), font_fullname(f), - k, font_filename(k), font_fullname(k), ret); -#endif - } - return ret; -} - -integer test_no_ligatures(internal_font_number f) -{ - integer c; - for (c = font_bc(f); c <= font_ec(f); c++) { - if (has_lig(f, c)) /* char_exists(f,c) */ - return 0; - } - return 1; -} - -integer get_tag_code(internal_font_number f, integer c) -{ - small_number i; - if (char_exists(f, c)) { - i = char_tag(f, c); - if (i == lig_tag) - return 1; - else if (i == list_tag) - return 2; - else if (i == ext_tag) - return 4; - else - return 0; - } - return -1; -} - -integer get_lp_code(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_lp(ci); -} - -integer get_rp_code(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_rp(ci); -} - -integer get_ef_code(internal_font_number f, integer c) -{ - charinfo *ci = char_info(f, c); - return get_charinfo_ef(ci); -} - -void set_tag_code(internal_font_number f, integer c, integer i) -{ - integer fixedi; - charinfo *co; - if (char_exists(f, c)) { - /* abs(fix_int(i-7,0)) */ - fixedi = -(i < -7 ? -7 : (i > 0 ? 0 : i)); - co = char_info(f, c); - if (fixedi >= 4) { - if (char_tag(f, c) == ext_tag) - set_charinfo_tag(co, (char_tag(f, c) - ext_tag)); - fixedi = fixedi - 4; - } - if (fixedi >= 2) { - if (char_tag(f, c) == list_tag) - set_charinfo_tag(co, (char_tag(f, c) - list_tag)); - fixedi = fixedi - 2; - }; - if (fixedi >= 1) { - if (has_lig(f, c)) - set_charinfo_ligatures(co, NULL); - if (has_kern(f, c)) - set_charinfo_kerns(co, NULL); - } - } -} - - -void set_lp_code(internal_font_number f, integer c, integer i) -{ - charinfo *co; - if (char_exists(f, c)) { - co = char_info(f, c); - set_charinfo_lp(co, i); - } -} - -void set_rp_code(internal_font_number f, integer c, integer i) -{ - charinfo *co; - if (char_exists(f, c)) { - co = char_info(f, c); - set_charinfo_rp(co, i); - } -} - -void set_ef_code(internal_font_number f, integer c, integer i) -{ - charinfo *co; - if (char_exists(f, c)) { - co = char_info(f, c); - set_charinfo_ef(co, i); - } -} - -void set_no_ligatures(internal_font_number f) -{ - integer c; - charinfo *co; - - if (font_tables[f]->ligatures_disabled) - return; - - co = char_info(f, left_boundarychar); - set_charinfo_ligatures(co, NULL); - co = char_info(f, right_boundarychar); /* this is weird */ - set_charinfo_ligatures(co, NULL); - for (c = 0; c < font_tables[f]->charinfo_count; c++) { - co = font_tables[f]->charinfo + c; - set_charinfo_ligatures(co, NULL); - } - font_tables[f]->ligatures_disabled = 1; -} - -liginfo get_ligature(internal_font_number f, integer lc, integer rc) -{ - liginfo t, u; - charinfo *co; - t.lig = 0; - t.type = 0; - t.adj = 0; - if (lc == non_boundarychar || rc == non_boundarychar || (!has_lig(f, lc))) - return t; - k = 0; - co = char_info(f, lc); - while (1) { - u = charinfo_ligature(co, k); - if (lig_end(u)) - break; - if (lig_char(u) == rc) { - if (lig_disabled(u)) { - return t; - } else { - return u; - } - } - k++; - } - return t; -} - - -scaled raw_get_kern(internal_font_number f, integer lc, integer rc) -{ - integer k; - kerninfo u; - charinfo *co; - if (lc == non_boundarychar || rc == non_boundarychar) - return 0; - k = 0; - co = char_info(f, lc); - while (1) { - u = charinfo_kern(co, k); - if (kern_end(u)) - break; - if (kern_char(u) == rc) { - if (kern_disabled(u)) - return 0; - else - return kern_kern(u); - } - k++; - } - return 0; -} - - -scaled get_kern(internal_font_number f, integer lc, integer rc) -{ - if (lc == non_boundarychar || rc == non_boundarychar || (!has_kern(f, lc))) - return 0; - return raw_get_kern(f, lc, rc); -} - - -/* dumping and undumping fonts */ - -#define dump_string(a) \ - if (a!=NULL) { \ - x = strlen(a)+1; \ - dump_int(x); dump_things(*a, x); \ - } else { \ - x = 0; dump_int(x); \ - } - -static void dump_charinfo(int f, int c) -{ - charinfo *co; - integer x; - liginfo *lig; - kerninfo *kern; - dump_int(c); - co = char_info(f, c); - set_charinfo_used(co, 0); - dump_int(get_charinfo_width(co)); - dump_int(get_charinfo_height(co)); - dump_int(get_charinfo_depth(co)); - dump_int(get_charinfo_italic(co)); - dump_int(get_charinfo_top_accent(co)); - dump_int(get_charinfo_bot_accent(co)); - dump_int(get_charinfo_tag(co)); - dump_int(get_charinfo_ef(co)); - dump_int(get_charinfo_rp(co)); - dump_int(get_charinfo_lp(co)); - dump_int(get_charinfo_remainder(co)); - dump_int(get_charinfo_used(co)); - dump_int(get_charinfo_index(co)); - dump_string(get_charinfo_name(co)); - dump_string(get_charinfo_tounicode(co)); - - /* ligatures */ - x = 0; - if ((lig = get_charinfo_ligatures(co)) != NULL) { - while (!lig_end(lig[x])) { - x++; - } - x++; - dump_int(x); - dump_things(*lig, x); - } else { - dump_int(x); - } - /* kerns */ - x = 0; - if ((kern = get_charinfo_kerns(co)) != NULL) { - while (!kern_end(kern[x])) { - x++; - } - x++; - dump_int(x); - dump_things(*kern, x); - } else { - dump_int(x); - } - /* packets */ - x = vf_packet_bytes(co); - dump_int(x); - if (x > 0) { - dump_things(*get_charinfo_packets(co), x); - } - - if (get_charinfo_tag(co) == ext_tag) { - dump_charinfo_variants(get_charinfo_vert_variants(co)); - dump_charinfo_variants(get_charinfo_hor_variants(co)); - } - dump_math_kerns(co); -} - -static void dump_font_entry(texfont * f) -{ - dump_int(f->_font_size); - dump_int(f->_font_dsize); - dump_int(f->_font_cidversion); - dump_int(f->_font_cidsupplement); - dump_int(f->_font_ec); - dump_int(f->_font_checksum); - dump_int(f->_font_used); - dump_int(f->_font_touched); - dump_int(f->_font_cache_id); - dump_int(f->_font_encodingbytes); - dump_int(f->_font_slant); - dump_int(f->_font_extend); - dump_int(f->_font_tounicode); - dump_int(f->_font_type); - dump_int(f->_font_format); - dump_int(f->_font_embedding); - dump_int(f->_font_bc); - dump_int(f->_hyphen_char); - dump_int(f->_skew_char); - dump_int(f->_font_natural_dir); - dump_int(f->_font_params); - dump_int(f->_font_math_params); - dump_int(f->ligatures_disabled); - dump_int(f->_pdf_font_num); - dump_int(f->_pdf_font_size); - dump_int(f->_pdf_font_blink); - dump_int(f->_pdf_font_elink); - dump_int(f->_pdf_font_expand_ratio); - dump_int(f->_pdf_font_shrink); - dump_int(f->_pdf_font_stretch); - dump_int(f->_pdf_font_step); - dump_int(f->_pdf_font_auto_expand); - dump_int(f->_pdf_font_attr); -} - -void dump_font(int f) -{ - integer i, x; - - set_font_used(f, 0); - font_tables[f]->charinfo_cache = NULL; - dump_font_entry(font_tables[f]); - dump_string(font_name(f)); - dump_string(font_area(f)); - dump_string(font_filename(f)); - dump_string(font_fullname(f)); - dump_string(font_encodingname(f)); - dump_string(font_cidregistry(f)); - dump_string(font_cidordering(f)); - - dump_things(*param_base(f), (font_params(f) + 1)); - - if (font_math_params(f) > 0) { - dump_things(*math_param_base(f), (font_math_params(f))); - } - if (has_left_boundary(f)) { - dump_int(1); - dump_charinfo(f, left_boundarychar); - } else { - dump_int(0); - } - if (has_right_boundary(f)) { - dump_int(1); - dump_charinfo(f, right_boundarychar); - } else { - dump_int(0); - } - - for (i = font_bc(f); i <= font_ec(f); i++) { - if (char_exists(f, i)) { - dump_charinfo(f, i); - } - } -} - -static int undump_charinfo(int f) -{ - charinfo *co; - integer x, i; - char *s = NULL; - liginfo *lig = NULL; - kerninfo *kern = NULL; - real_eight_bits *packet = NULL; - - undump_int(i); - co = get_charinfo(f, i); - undump_int(x); - set_charinfo_width(co, x); - undump_int(x); - set_charinfo_height(co, x); - undump_int(x); - set_charinfo_depth(co, x); - undump_int(x); - set_charinfo_italic(co, x); - undump_int(x); - set_charinfo_top_accent(co, x); - undump_int(x); - set_charinfo_bot_accent(co, x); - undump_int(x); - set_charinfo_tag(co, x); - undump_int(x); - set_charinfo_ef(co, x); - undump_int(x); - set_charinfo_rp(co, x); - undump_int(x); - set_charinfo_lp(co, x); - undump_int(x); - set_charinfo_remainder(co, x); - undump_int(x); - set_charinfo_used(co, x); - undump_int(x); - set_charinfo_index(co, x); - - /* name */ - undump_int(x); - if (x > 0) { - font_bytes += x; - s = xmalloc(x); - undump_things(*s, x); - } - set_charinfo_name(co, s); - /* tounicode */ - undump_int(x); - if (x > 0) { - font_bytes += x; - s = xmalloc(x); - undump_things(*s, x); - } - set_charinfo_tounicode(co, s); - /* ligatures */ - undump_int(x); - if (x > 0) { - font_bytes += x * sizeof(liginfo); - lig = xmalloc(x * sizeof(liginfo)); - undump_things(*lig, x); - } - set_charinfo_ligatures(co, lig); - /* kerns */ - undump_int(x); - if (x > 0) { - font_bytes += x * sizeof(kerninfo); - kern = xmalloc(x * sizeof(kerninfo)); - undump_things(*kern, x); - } - set_charinfo_kerns(co, kern); - - /* packets */ - undump_int(x); - if (x > 0) { - font_bytes += x; - packet = xmalloc(x); - undump_things(*packet, x); - } - set_charinfo_packets(co, packet); - - if (get_charinfo_tag(co) == ext_tag) { - set_charinfo_vert_variants(co, undump_charinfo_variants()); - set_charinfo_hor_variants(co, undump_charinfo_variants()); - } - undump_math_kerns(co); - return i; -} - -#define undump_font_string(a) undump_int (x); \ - if (x>0) { \ - font_bytes += x; \ - s = xmalloc(x); undump_things(*s,x); \ - a(f,s); } - - -static void undump_font_entry(texfont * f) -{ - integer x = 0; - /* *INDENT-OFF* */ - undump_int(x); f->_font_size = x; - undump_int(x); f->_font_dsize = x; - undump_int(x); f->_font_cidversion = x; - undump_int(x); f->_font_cidsupplement = x; - undump_int(x); f->_font_ec = x; - undump_int(x); f->_font_checksum = x; - undump_int(x); f->_font_used = x; - undump_int(x); f->_font_touched = x; - undump_int(x); f->_font_cache_id = x; - undump_int(x); f->_font_encodingbytes = x; - undump_int(x); f->_font_slant = x; - undump_int(x); f->_font_extend = x; - undump_int(x); f->_font_tounicode = x; - undump_int(x); f->_font_type = x; - undump_int(x); f->_font_format = x; - undump_int(x); f->_font_embedding = x; - undump_int(x); f->_font_bc = x; - undump_int(x); f->_hyphen_char = x; - undump_int(x); f->_skew_char = x; - undump_int(x); f->_font_natural_dir = x; - undump_int(x); f->_font_params = x; - undump_int(x); f->_font_math_params = x; - undump_int(x); f->ligatures_disabled = x; - undump_int(x); f->_pdf_font_num = x; - undump_int(x); f->_pdf_font_size = x; - undump_int(x); f->_pdf_font_blink = x; - undump_int(x); f->_pdf_font_elink = x; - undump_int(x); f->_pdf_font_expand_ratio = x; - undump_int(x); f->_pdf_font_shrink = x; - undump_int(x); f->_pdf_font_stretch = x; - undump_int(x); f->_pdf_font_step = x; - undump_int(x); f->_pdf_font_auto_expand = x; - undump_int(x); f->_pdf_font_attr = x; - /* *INDENT-ON* */ -} - - - -void undump_font(int f) -{ - integer x, i; - texfont *tt; - charinfo *ci; - char *s; - grow_font_table(f); - tt = xmalloc(sizeof(texfont)); - memset(tt, 0, sizeof(texfont)); - font_bytes += sizeof(texfont); - undump_font_entry(tt); - font_tables[f] = tt; - - undump_font_string(set_font_name); - undump_font_string(set_font_area); - undump_font_string(set_font_filename); - undump_font_string(set_font_fullname); - undump_font_string(set_font_encodingname); - undump_font_string(set_font_cidregistry); - undump_font_string(set_font_cidordering); - - i = sizeof(*param_base(f)) * (font_params(f) + 1); - font_bytes += i; - param_base(f) = xmalloc(i); - undump_things(*param_base(f), (font_params(f) + 1)); - - if (font_math_params(f) > 0) { - i = sizeof(*math_param_base(f)) * (font_math_params(f) + 1); - font_bytes += i; - math_param_base(f) = xmalloc(i); - undump_things(*math_param_base(f), (font_math_params(f) + 1)); - } - - undump_int(x); - if (x) { - i = undump_charinfo(f); - } /* left boundary */ - undump_int(x); - if (x) { - i = undump_charinfo(f); - } /* right boundary */ - font_tables[f]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */ - ci = xcalloc(1, sizeof(charinfo)); - set_charinfo_name(ci, xstrdup(".notdef")); - font_tables[f]->charinfo = ci; - - i = font_bc(f); - while (i < font_ec(f)) { - i = undump_charinfo(f); - } -} diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.h b/Build/source/texk/web2c/luatexdir/font/texfont.h index 4963f71cad2..6a021726748 100644 --- a/Build/source/texk/web2c/luatexdir/font/texfont.h +++ b/Build/source/texk/web2c/luatexdir/font/texfont.h @@ -1,6 +1,6 @@ /* texfont.h Main font API implementation for the pascal parts - - Copyright 2006-2008 Taco Hoekwater + + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,31 +17,29 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: texfont.h 2448 2009-06-08 07:43:50Z taco $ */ +/* $Id: texfont.h 3482 2010-03-13 11:18:28Z taco $ */ /* Here we have the interface to LuaTeX's font system, as seen from the main pascal program. There is a companion list in luatex.defines to keep web2c happy */ /* this file is read at the end of ptexlib.h, which is called for at - the end of luatexcoerce.h, as well as from the C sources + the end of luatexcoerce.h, as well as from the C sources */ #ifndef TEXFONT_H # define TEXFONT_H -# include "luatexdir/managed-sa.h" - # define pointer halfword typedef struct liginfo { - integer adj; - integer lig; + int adj; + int lig; char type; } liginfo; typedef struct kerninfo { - integer adj; + int adj; scaled sc; } kerninfo; @@ -53,23 +51,23 @@ typedef struct extinfo { int advance; int extender; } extinfo; - +/* todo: maybe create a 'math info structure' */ typedef struct charinfo { char *name; /* postscript character name */ liginfo *ligatures; /* ligature items */ kerninfo *kerns; /* kern items */ - real_eight_bits *packets; /* virtual commands. */ + eight_bits *packets; /* virtual commands. */ unsigned short index; /* CID index */ - integer remainder; /* spare value for odd items, could be union-ed with extensible */ + int remainder; /* spare value for odd items, could be union-ed with extensible */ scaled width; /* width */ scaled height; /* height */ scaled depth; /* depth */ scaled italic; /* italic correction */ scaled top_accent; /* top accent alignment */ scaled bot_accent; /* bot accent alignment */ - integer ef; /* font expansion factor */ - integer lp; /* left protruding factor */ - integer rp; /* right protruding factor */ + int ef; /* font expansion factor */ + int lp; /* left protruding factor */ + int rp; /* right protruding factor */ char tag; /* list / ext taginfo */ char used; /* char is typeset ? */ char *tounicode; /* unicode equivalent */ @@ -85,20 +83,6 @@ typedef struct charinfo { scaled *bottom_left_math_kern_array; } charinfo; - -/* this is for speed reasons, it is called from the web source - when more than two of the traditional four char values are needed - at the same time. the structure |charinfo_short| is defined in - web */ - -# ifndef luaTeX -typedef struct charinfo_short { - scaled ci_wd; /* width */ - scaled ci_ht; /* height */ - scaled ci_dp; /* depth */ -} charinfo_short; -# endif - # define EXT_NORMAL 0 # define EXT_REPEAT 1 @@ -114,66 +98,69 @@ extern extinfo *copy_variants(extinfo * o); extern extinfo *new_variant(int glyph, int startconnect, int endconnect, int advance, int repeater); -extern charinfo_short char_info_short(internal_font_number f, integer c); +extern scaled_whd get_charinfo_whd(internal_font_number f, int c); typedef struct texfont { - integer _font_size; - integer _font_dsize; + int _font_size; + int _font_dsize; + int _font_units_per_em; char *_font_name; char *_font_area; char *_font_filename; char *_font_fullname; + char *_font_psname; char *_font_encodingname; char *_font_cidregistry; char *_font_cidordering; - integer _font_cidversion; - integer _font_cidsupplement; + int _font_cidversion; + int _font_cidsupplement; - integer _font_ec; + int _font_ec; unsigned _font_checksum; /* internal information */ char _font_used; /* internal information */ char _font_touched; /* internal information */ - integer _font_cache_id; /* internal information */ + int _font_cache_id; /* internal information */ char _font_encodingbytes; /* 1 or 2 bytes */ - integer _font_slant; /* a slant in ppt */ - integer _font_extend; /* an extension in ppt, or 0 */ + + int _font_slant; /* a slant in ppt */ + int _font_extend; /* an extension in ppt, or 1000 */ + int _font_expand_ratio; /* expansion ratio of a particular font */ + internal_font_number _font_shrink; /* font at limit of shrinking */ + internal_font_number _font_stretch; /* font at limit of stretching */ + int _font_step; /* amount of one step of expansion */ + boolean _font_auto_expand; /* this font is auto-expanded? */ + char _font_tounicode; /* 1 if info is present */ - fm_entry_ptr _font_map; - integer _font_type; - integer _font_format; - integer _font_embedding; - integer _font_bc; - integer _hyphen_char; - integer _skew_char; - integer _font_natural_dir; + fm_entry *_font_map; + int _font_type; + int _font_format; + int _font_embedding; + int _font_bc; + int _hyphen_char; + int _skew_char; + int _font_natural_dir; charinfo *_left_boundary; charinfo *_right_boundary; - integer _font_params; + int _font_params; scaled *_param_base; - integer _font_math_params; + int _font_math_params; scaled *_math_param_base; sa_tree characters; - integer charinfo_count; - integer charinfo_size; + int charinfo_count; + int charinfo_size; charinfo *charinfo; int *charinfo_cache; - integer ligatures_disabled; + int ligatures_disabled; - integer _pdf_font_num; /* maps to a PDF resource ID */ - scaled _pdf_font_size; /* maps to a PDF font size */ + int _pdf_font_num; /* maps to a PDF resource ID */ internal_font_number _pdf_font_blink; /* link to base font for expanded fonts */ internal_font_number _pdf_font_elink; /* link to expanded fonts for base font */ - integer _pdf_font_expand_ratio; /* expansion ratio of a particular font */ - internal_font_number _pdf_font_shrink; /* font at limit of shrinking */ - internal_font_number _pdf_font_stretch; /* font at limit of stretching */ - integer _pdf_font_step; /* amount of one step of expansion */ - boolean _pdf_font_auto_expand; /* this font is auto-expanded? */ str_number _pdf_font_attr; /* pointer to additional attributes */ } texfont; @@ -216,19 +203,20 @@ extern const char *font_embedding_strings[]; # define font_dsize(a) font_tables[a]->_font_dsize # define set_font_dsize(a,b) font_dsize(a) = b +# define font_units_per_em(a) font_tables[a]->_font_units_per_em +# define set_font_units_per_em(a,b) font_units_per_em(a) = b + # define font_name(a) font_tables[a]->_font_name # define get_font_name(a) (unsigned char *)font_name(a) # define set_font_name(f,b) font_name(f) = b # define tex_font_name(a) maketexstring(font_name(a)) -boolean cmp_font_name(integer, str_number); - # define font_area(a) font_tables[a]->_font_area # define get_font_area(a) (unsigned char *)font_area(a) # define set_font_area(f,b) font_area(f) = b # define tex_font_area(a) maketexstring(font_area(a)) -boolean cmp_font_area(integer, str_number); +boolean cmp_font_area(int, str_number); # define font_reassign(a,b) { if (a!=NULL) free(a); a = b; } @@ -238,11 +226,12 @@ boolean cmp_font_area(integer, str_number); # define font_fullname(a) font_tables[a]->_font_fullname # define set_font_fullname(f,b) font_reassign(font_fullname(f),b) +# define font_psname(a) font_tables[a]->_font_psname +# define set_font_psname(f,b) font_reassign(font_psname(f),b) + # define font_encodingname(a) font_tables[a]->_font_encodingname # define set_font_encodingname(f,b) font_reassign(font_encodingname(f),b) -boolean font_shareable(internal_font_number, internal_font_number); - # define cmp_font_filename(a,b) (!(font_filename(a)!=NULL || font_filename(b)!=NULL || \ strcmp(font_filename(a),font_filename(b)))) # define cmp_font_fullname(a,b) (!(font_fullname(a)!=NULL || font_fullname(b)!=NULL || \ @@ -300,6 +289,21 @@ boolean font_shareable(internal_font_number, internal_font_number); # define font_extend(a) font_tables[a]->_font_extend # define set_font_extend(a,b) font_extend(a) = b +# define font_expand_ratio(a) font_tables[a]->_font_expand_ratio +# define set_font_expand_ratio(a,b) font_expand_ratio(a) = b + +# define font_shrink(a) font_tables[a]->_font_shrink +# define set_font_shrink(a,b) font_shrink(a) = b + +# define font_stretch(a) font_tables[a]->_font_stretch +# define set_font_stretch(a,b) font_stretch(a) = b + +# define font_step(a) font_tables[a]->_font_step +# define set_font_step(a,b) font_step(a) = b + +# define font_auto_expand(a) font_tables[a]->_font_auto_expand +# define set_font_auto_expand(a,b) font_auto_expand(a) = b + # define font_tounicode(a) font_tables[a]->_font_tounicode # define set_font_tounicode(a,b) font_tounicode(a) = b @@ -312,32 +316,14 @@ boolean font_shareable(internal_font_number, internal_font_number); # define font_natural_dir(a) font_tables[a]->_font_natural_dir # define set_font_natural_dir(a,b) font_natural_dir(a) = b -# define pdf_font_size(a) font_tables[a]->_pdf_font_size -# define set_pdf_font_size(a,b) pdf_font_size(a) = b - # define pdf_font_num(a) font_tables[a]->_pdf_font_num # define set_pdf_font_num(a,b) pdf_font_num(a) = b -# define pdf_font_blink(a) font_tables[a]->_pdf_font_blink -# define set_pdf_font_blink(a,b) pdf_font_blink(a) = b - -# define pdf_font_elink(a) font_tables[a]->_pdf_font_elink -# define set_pdf_font_elink(a,b) pdf_font_elink(a) = b - -# define pdf_font_expand_ratio(a) font_tables[a]->_pdf_font_expand_ratio -# define set_pdf_font_expand_ratio(a,b) pdf_font_expand_ratio(a) = b - -# define pdf_font_shrink(a) font_tables[a]->_pdf_font_shrink -# define set_pdf_font_shrink(a,b) pdf_font_shrink(a) = b - -# define pdf_font_stretch(a) font_tables[a]->_pdf_font_stretch -# define set_pdf_font_stretch(a,b) pdf_font_stretch(a) = b +# define pdf_font_blink(a) font_tables[a]->_pdf_font_blink +# define set_pdf_font_blink(a,b) pdf_font_blink(a) = b -# define pdf_font_step(a) font_tables[a]->_pdf_font_step -# define set_pdf_font_step(a,b) pdf_font_step(a) = b - -# define pdf_font_auto_expand(a) font_tables[a]->_pdf_font_auto_expand -# define set_pdf_font_auto_expand(a,b) pdf_font_auto_expand(a) = b +# define pdf_font_elink(a) font_tables[a]->_pdf_font_elink +# define set_pdf_font_elink(a,b) pdf_font_elink(a) = b # define pdf_font_attr(a) font_tables[a]->_pdf_font_attr # define set_pdf_font_attr(a,b) pdf_font_attr(a) = b @@ -412,9 +398,15 @@ typedef enum { top_left_kern = 4 } font_math_kern_codes; -extern charinfo *get_charinfo(internal_font_number f, integer c); -extern integer char_exists(internal_font_number f, integer c); -extern charinfo *char_info(internal_font_number f, integer c); +extern charinfo *get_charinfo(internal_font_number f, int c); +extern int char_exists(internal_font_number f, int c); +extern charinfo *char_info(internal_font_number f, int c); + +/* Here is a quick way to test if a glyph exists, when you are +already certain the font |f| exists, and that the |c| is a regular +glyph id, not one of the two special boundary objects. +*/ +# define quick_char_exists(f,c) get_sa_item(font_tables[f]->characters,c) extern void set_charinfo_width(charinfo * ci, scaled val); extern void set_charinfo_height(charinfo * ci, scaled val); @@ -430,7 +422,7 @@ extern void set_charinfo_name(charinfo * ci, char *val); extern void set_charinfo_tounicode(charinfo * ci, char *val); extern void set_charinfo_ligatures(charinfo * ci, liginfo * val); extern void set_charinfo_kerns(charinfo * ci, kerninfo * val); -extern void set_charinfo_packets(charinfo * ci, real_eight_bits * val); +extern void set_charinfo_packets(charinfo * ci, eight_bits * val); extern void set_charinfo_extensible(charinfo * ci, int a, int b, int c, int d); extern void set_charinfo_ef(charinfo * ci, scaled val); extern void set_charinfo_lp(charinfo * ci, scaled val); @@ -452,23 +444,23 @@ extern scaled get_charinfo_italic(charinfo * ci); extern scaled get_charinfo_top_accent(charinfo * ci); extern scaled get_charinfo_bot_accent(charinfo * ci); extern char get_charinfo_tag(charinfo * ci); -extern integer get_charinfo_remainder(charinfo * ci); +extern int get_charinfo_remainder(charinfo * ci); extern char get_charinfo_used(charinfo * ci); -extern integer get_charinfo_index(charinfo * ci); +extern int get_charinfo_index(charinfo * ci); extern char *get_charinfo_name(charinfo * ci); extern char *get_charinfo_tounicode(charinfo * ci); extern liginfo *get_charinfo_ligatures(charinfo * ci); extern kerninfo *get_charinfo_kerns(charinfo * ci); -extern real_eight_bits *get_charinfo_packets(charinfo * ci); -extern integer get_charinfo_ef(charinfo * ci); -extern integer get_charinfo_rp(charinfo * ci); -extern integer get_charinfo_lp(charinfo * ci); -extern integer get_charinfo_extensible(charinfo * ci, int which); +extern eight_bits *get_charinfo_packets(charinfo * ci); +extern int get_charinfo_ef(charinfo * ci); +extern int get_charinfo_rp(charinfo * ci); +extern int get_charinfo_lp(charinfo * ci); +extern int get_charinfo_extensible(charinfo * ci, int which); -extern integer ext_top(internal_font_number f, integer c); -extern integer ext_bot(internal_font_number f, integer c); -extern integer ext_rep(internal_font_number f, integer c); -extern integer ext_mid(internal_font_number f, integer c); +extern int ext_top(internal_font_number f, int c); +extern int ext_bot(internal_font_number f, int c); +extern int ext_rep(internal_font_number f, int c); +extern int ext_mid(internal_font_number f, int c); # define set_ligature_item(f,b,c,d) { f.type = b; f.adj = c; f.lig = d; } @@ -514,30 +506,30 @@ extern integer ext_mid(internal_font_number f, integer c); # define list_tag 2 /* character has a successor in a charlist */ # define ext_tag 3 /* character is extensible */ -extern scaled char_height(internal_font_number f, integer c); -extern scaled char_width(internal_font_number f, integer c); -extern scaled char_depth(internal_font_number f, integer c); -extern scaled char_italic(internal_font_number f, integer c); -extern scaled char_top_accent(internal_font_number f, integer c); -extern scaled char_bot_accent(internal_font_number f, integer c); +extern scaled char_height(internal_font_number f, int c); +extern scaled char_width(internal_font_number f, int c); +extern scaled char_depth(internal_font_number f, int c); +extern scaled char_italic(internal_font_number f, int c); +extern scaled char_top_accent(internal_font_number f, int c); +extern scaled char_bot_accent(internal_font_number f, int c); -extern liginfo *char_ligatures(internal_font_number f, integer c); -extern kerninfo *char_kerns(internal_font_number f, integer c); -extern real_eight_bits *char_packets(internal_font_number f, integer c); +extern liginfo *char_ligatures(internal_font_number f, int c); +extern kerninfo *char_kerns(internal_font_number f, int c); +extern eight_bits *char_packets(internal_font_number f, int c); # define has_lig(f,b) (char_exists(f,b) &&( char_ligatures(f,b) != NULL)) # define has_kern(f,b) (char_exists(f,b) && (char_kerns(f,b) != NULL)) # define has_packet(f,b) (char_exists(f,b) && (char_packets(f,b) != NULL)) -extern integer char_remainder(internal_font_number f, integer c); -extern char char_tag(internal_font_number f, integer c); -extern char char_used(internal_font_number f, integer c); -extern char *char_name(internal_font_number f, integer c); -extern integer char_index(internal_font_number f, integer c); +extern int char_remainder(internal_font_number f, int c); +extern char char_tag(internal_font_number f, int c); +extern char char_used(internal_font_number f, int c); +extern char *char_name(internal_font_number f, int c); +extern int char_index(internal_font_number f, int c); -scaled raw_get_kern(internalfontnumber f, integer lc, integer rc); -scaled get_kern(internalfontnumber f, integer lc, integer rc); -liginfo get_ligature(internalfontnumber f, integer lc, integer rc); +scaled raw_get_kern(internal_font_number f, int lc, int rc); +scaled get_kern(internal_font_number f, int lc, int rc); +liginfo get_ligature(internal_font_number f, int lc, int rc); # define EXT_TOP 0 # define EXT_BOT 1 @@ -546,44 +538,43 @@ liginfo get_ligature(internalfontnumber f, integer lc, integer rc); extern texfont **font_tables; -integer new_font(void); -integer copy_font(integer id); -integer scale_font(integer id, integer atsize); -integer max_font_id(void); -void set_max_font_id(integer id); -integer new_font_id(void); +int new_font(void); +extern void font_malloc_charinfo(internal_font_number f, int num); +int copy_font(int id); +int scale_font(int id, int atsize); +int max_font_id(void); +void set_max_font_id(int id); +int new_font_id(void); void create_null_font(void); -void delete_font(integer id); -boolean is_valid_font(integer id); +void delete_font(int id); +boolean is_valid_font(int id); void dump_font(int font_number); void undump_font(int font_number); -integer test_no_ligatures(internal_font_number f); +int test_no_ligatures(internal_font_number f); void set_no_ligatures(internal_font_number f); -extern integer get_tag_code(internal_font_number f, integer c); -extern integer get_lp_code(internal_font_number f, integer c); -extern integer get_rp_code(internal_font_number f, integer c); -extern integer get_ef_code(internal_font_number f, integer c); +extern int get_tag_code(internal_font_number f, int c); +extern int get_lp_code(internal_font_number f, int c); +extern int get_rp_code(internal_font_number f, int c); +extern int get_ef_code(internal_font_number f, int c); -extern void set_tag_code(internal_font_number f, integer c, integer i); -extern void set_lp_code(internal_font_number f, integer c, integer i); -extern void set_rp_code(internal_font_number f, integer c, integer i); -extern void set_ef_code(internal_font_number f, integer c, integer i); +extern void set_tag_code(internal_font_number f, int c, int i); +extern void set_lp_code(internal_font_number f, int c, int i); +extern void set_rp_code(internal_font_number f, int c, int i); +extern void set_ef_code(internal_font_number f, int c, int i); int read_tfm_info(internal_font_number f, const char *nom, scaled s); /* from dofont.c */ -extern int read_font_info(pointer u, str_number nom, scaled s, integer ndir); +extern int read_font_info(pointer u, char *cnom, scaled s, int ndir); extern int find_font_id(const char *nom, scaled s); /* for and from vfpacket.c */ -# define scan_special 3 /* look into special text */ /* this is a hack */ - typedef enum { packet_char_code, packet_font_code, packet_pop_code, @@ -598,11 +589,23 @@ typedef enum { packet_char_code, packet_end_code } packet_command_codes; -extern scaled store_scaled_f(scaled sq, integer fw); +extern scaled store_scaled_f(scaled sq, int fw); -extern void do_vf_packet(internal_font_number vf_f, integer c); +extern void do_vf_packet(PDF pdf, internal_font_number vf_f, int c); extern int vf_packet_bytes(charinfo * co); -charinfo *copy_charinfo(charinfo * ci); +extern charinfo *copy_charinfo(charinfo * ci); + +/* this function is in vfovf.c for the moment */ +extern int make_vf_table(lua_State * L, const char *name, scaled s); + +/* some bits of the old interface, used by e.g. writet3.c */ + +# define get_x_height(f) x_height(f) +# define get_quad(f) quad(f) +# define get_slant(f) slant(f) +# define get_charwidth(f,c) (char_exists(f,c) ? char_width(f,c) : 0) +# define get_charheight(f,c) (char_exists(f,c) ? char_height(f,c) : 0) +# define get_chardepth(f,c) (char_exists(f,c) ? char_depth(f,c) : 0) #endif /* TEXFONT_H */ diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.w b/Build/source/texk/web2c/luatexdir/font/texfont.w new file mode 100644 index 00000000000..19dcb0769af --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/texfont.w @@ -0,0 +1,1774 @@ +% texfont.w + +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + + +@* Main font API implementation for the original pascal parts. + +Stuff to watch out for: + +\item{} Knuth had a |'null_character'| that was used when a character could +not be found by the |fetch()| routine, to signal an error. This has +been deleted, but it may mean that the output of luatex is +incompatible with TeX after |fetch()| has detected an error condition. + +\item{} Knuth also had a |font_glue()| optimization. I've removed that +because it was a bit of dirty programming and it also was +problematic |if 0 != null|. + +@c +static const char _svn_version[] = + "$Id: texfont.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/texfont.w $"; + +#include "ptexlib.h" +#include "lua/luatex-api.h" + +@ @c +#define noDEBUG + +#define proper_char_index(c) (c<=font_ec(f) && c>=font_bc(f)) +#define do_realloc(a,b,d) a = xrealloc(a,(unsigned)((unsigned)(b)*sizeof(d))) + +texfont **font_tables = NULL; + +static int font_arr_max = 0; +static int font_id_maxval = 0; + +@ @c +static void grow_font_table(int id) +{ + int j; + if (id >= font_arr_max) { + font_bytes += + (int) (((id + 8 - font_arr_max) * (int) sizeof(texfont *))); + font_tables = + xrealloc(font_tables, + (unsigned) (((unsigned) id + 8) * sizeof(texfont *))); + j = 8; + while (j--) { + font_tables[id + j] = NULL; + } + font_arr_max = id + 8; + } +} + +int new_font_id(void) +{ + int i; + for (i = 0; i < font_arr_max; i++) { + if (font_tables[i] == NULL) { + break; + } + } + if (i >= font_arr_max) + grow_font_table(i); + if (i > font_id_maxval) + font_id_maxval = i; + return i; +} + +int max_font_id(void) +{ + return font_id_maxval; +} + +void set_max_font_id(int i) +{ + font_id_maxval = i; +} + +@ @c +int new_font(void) +{ + int k; + int id; + charinfo *ci; + id = new_font_id(); + font_bytes += (int) sizeof(texfont); + /* most stuff is zero */ + font_tables[id] = xcalloc(1, sizeof(texfont)); + font_tables[id]->_font_name = NULL; + font_tables[id]->_font_area = NULL; + font_tables[id]->_font_filename = NULL; + font_tables[id]->_font_fullname = NULL; + font_tables[id]->_font_psname = NULL; + font_tables[id]->_font_encodingname = NULL; + font_tables[id]->_font_cidregistry = NULL; + font_tables[id]->_font_cidordering = NULL; + font_tables[id]->_left_boundary = NULL; + font_tables[id]->_right_boundary = NULL; + font_tables[id]->_param_base = NULL; + font_tables[id]->_math_param_base = NULL; + + set_font_bc(id, 1); /* ec = 0 */ + set_hyphen_char(id, '-'); + set_skew_char(id, -1); + font_slant(id) = 0; /* vertical */ + font_extend(id) = 1000; /* normal width */ + + /* allocate eight values including 0 */ + set_font_params(id, 7); + for (k = 0; k <= 7; k++) { + set_font_param(id, k, 0); + } + /* character info zero is reserved for notdef */ + font_tables[id]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */ + + ci = xcalloc(1, sizeof(charinfo)); + set_charinfo_name(ci, xstrdup(".notdef")); + font_tables[id]->charinfo = ci; + font_tables[id]->charinfo_size = 1; + font_tables[id]->charinfo_cache = NULL; + + return id; +} + +@ @c +void font_malloc_charinfo(internal_font_number f, int num) +{ + int glyph = font_tables[f]->charinfo_size; + font_bytes += (int) (num * (int) sizeof(charinfo)); + do_realloc(font_tables[f]->charinfo, (unsigned) (glyph + num), charinfo); + memset(&(font_tables[f]->charinfo[glyph]), 0, + (size_t) (num * (int) sizeof(charinfo))); + font_tables[f]->charinfo_size += num; +} + +@ @c +#define find_charinfo_id(f,c) get_sa_item(font_tables[f]->characters,c) + +charinfo *get_charinfo(internal_font_number f, int c) +{ + sa_tree_item glyph; + charinfo *ci; + if (proper_char_index(c)) { + glyph = get_sa_item(font_tables[f]->characters, c); + if (!glyph) { + + int tglyph = ++font_tables[f]->charinfo_count; + if (tglyph >= font_tables[f]->charinfo_size) { + font_malloc_charinfo(f, 256); + } + font_tables[f]->charinfo[tglyph].ef = 1000; /* init */ + set_sa_item(font_tables[f]->characters, c, (sa_tree_item) tglyph, 1); /* 1= global */ + glyph = (sa_tree_item) tglyph; + } + return &(font_tables[f]->charinfo[glyph]); + } else if (c == left_boundarychar) { + if (left_boundary(f) == NULL) { + ci = xcalloc(1, sizeof(charinfo)); + font_bytes += (int) sizeof(charinfo); + set_left_boundary(f, ci); + } + return left_boundary(f); + } else if (c == right_boundarychar) { + if (right_boundary(f) == NULL) { + ci = xcalloc(1, sizeof(charinfo)); + font_bytes += (int) sizeof(charinfo); + set_right_boundary(f, ci); + } + return right_boundary(f); + } + return &(font_tables[f]->charinfo[0]); +} + +@ @c +void set_charinfo(internal_font_number f, int c, charinfo * ci) +{ + sa_tree_item glyph; + if (proper_char_index(c)) { + glyph = get_sa_item(font_tables[f]->characters, c); + if (glyph) { + font_tables[f]->charinfo[glyph] = *ci; + } else { + pdftex_fail("font: %s", "character insertion failed"); + } + } else if (c == left_boundarychar) { + set_left_boundary(f, ci); + } else if (c == right_boundarychar) { + set_right_boundary(f, ci); + } +} + +@ @c +charinfo *copy_charinfo(charinfo * ci) +{ + int x, k; + kerninfo *kern; + liginfo *lig; + eight_bits *packet; + charinfo *co = NULL; + if (ci == NULL) + return NULL; + co = xmalloc(sizeof(charinfo)); + memcpy(co, ci, sizeof(charinfo)); + set_charinfo_used(co, false); + co->name = NULL; + co->tounicode = NULL; + co->packets = NULL; + co->ligatures = NULL; + co->kerns = NULL; + co->vert_variants = NULL; + co->hor_variants = NULL; + if (ci->name != NULL) { + co->name = xstrdup(ci->name); + } + if (ci->tounicode != NULL) { + co->tounicode = xstrdup(ci->tounicode); + } + /* kerns */ + if ((kern = get_charinfo_kerns(ci)) != NULL) { + x = 0; + while (!kern_end(kern[x])) { + x++; + } + x++; + co->kerns = xmalloc((unsigned) (x * (int) sizeof(kerninfo))); + memcpy(co->kerns, ci->kerns, (size_t) (x * (int) sizeof(kerninfo))); + } + /* ligs */ + if ((lig = get_charinfo_ligatures(ci)) != NULL) { + x = 0; + while (!lig_end(lig[x])) { + x++; + } + x++; + co->ligatures = xmalloc((unsigned) (x * (int) sizeof(liginfo))); + memcpy(co->ligatures, ci->ligatures, + (size_t) (x * (int) sizeof(liginfo))); + } + /* packets */ + if ((packet = get_charinfo_packets(ci)) != NULL) { + x = vf_packet_bytes(ci); + co->packets = xmalloc((unsigned) x); + memcpy(co->packets, ci->packets, (size_t) x); + } + + /* horizontal and vertical extenders */ + if (get_charinfo_vert_variants(ci) != NULL) { + set_charinfo_vert_variants(co, + copy_variants(get_charinfo_vert_variants + (ci))); + } + if (get_charinfo_hor_variants(ci) != NULL) { + set_charinfo_hor_variants(co, + copy_variants(get_charinfo_hor_variants(ci))); + } + x = ci->top_left_math_kerns; + co->top_left_math_kerns = x; + if (x > 0) { + co->top_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < co->top_left_math_kerns; k++) { + co->top_left_math_kern_array[(2 * k)] = + ci->top_left_math_kern_array[(2 * k)]; + co->top_left_math_kern_array[(2 * k) + 1] = + ci->top_left_math_kern_array[(2 * k) + 1]; + } + } + x = ci->top_right_math_kerns; + co->top_right_math_kerns = x; + if (x > 0) { + co->top_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < co->top_right_math_kerns; k++) { + co->top_right_math_kern_array[(2 * k)] = + ci->top_right_math_kern_array[(2 * k)]; + co->top_right_math_kern_array[(2 * k) + 1] = + ci->top_right_math_kern_array[(2 * k) + 1]; + } + } + x = ci->bottom_right_math_kerns; + co->bottom_right_math_kerns = x; + if (x > 0) { + co->bottom_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < co->bottom_right_math_kerns; k++) { + co->bottom_right_math_kern_array[(2 * k)] = + ci->bottom_right_math_kern_array[(2 * k)]; + co->bottom_right_math_kern_array[(2 * k) + 1] = + ci->bottom_right_math_kern_array[(2 * k) + 1]; + } + } + x = ci->bottom_left_math_kerns; + co->bottom_left_math_kerns = x; + if (x > 0) { + co->bottom_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < co->bottom_left_math_kerns; k++) { + co->bottom_left_math_kern_array[(2 * k)] = + ci->bottom_left_math_kern_array[(2 * k)]; + co->bottom_left_math_kern_array[(2 * k) + 1] = + ci->bottom_left_math_kern_array[(2 * k) + 1]; + } + } + + + return co; +} + +charinfo *char_info(internal_font_number f, int c) +{ + if (f > font_id_maxval) + return 0; + if (proper_char_index(c)) { + register int glyph = (int) find_charinfo_id(f, c); + return &(font_tables[f]->charinfo[glyph]); + } else if (c == left_boundarychar && left_boundary(f) != NULL) { + return left_boundary(f); + } else if (c == right_boundarychar && right_boundary(f) != NULL) { + return right_boundary(f); + } + return &(font_tables[f]->charinfo[0]); +} + +@ @c +scaled_whd get_charinfo_whd(internal_font_number f, int c) +{ + scaled_whd s; + charinfo *i; + i = char_info(f, c); + s.wd = i->width; + s.dp = i->depth; + s.ht = i->height; + return s; +} + +@ @c +int char_exists(internal_font_number f, int c) +{ + if (f > font_id_maxval) + return 0; + if (proper_char_index(c)) { + return (int) find_charinfo_id(f, c); + } else if ((c == left_boundarychar) && has_left_boundary(f)) { + return 1; + } else if ((c == right_boundarychar) && has_right_boundary(f)) { + return 1; + } + return 0; +} + +@ @c +int lua_char_exists_callback(internal_font_number f, int c) +{ + int callback_id; + lua_State *L = Luas; + int ret = 0; + callback_id = callback_defined(char_exists_callback); + if (callback_id != 0) { + if (!get_callback(L, callback_id)) { + lua_pop(L, 2); + return 0; + } + lua_pushnumber(L, f); + lua_pushnumber(L, c); + if (lua_pcall(L, 2, 1, 0) != 0) { /* two args, 1 result */ + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 2); + error(); + } else { + ret = lua_toboolean(L, -1); + } + } + return ret; +} + + +@ @c +extinfo *new_variant(int glyph, int startconnect, int endconnect, + int advance, int repeater) +{ + extinfo *ext; + ext = xmalloc(sizeof(extinfo)); + ext->next = NULL; + ext->glyph = glyph; + ext->start_overlap = startconnect; + ext->end_overlap = endconnect; + ext->advance = advance; + ext->extender = repeater; + return ext; +} + + +@ @c +extinfo *copy_variant(extinfo * old) +{ + extinfo *ext; + ext = xmalloc(sizeof(extinfo)); + ext->next = NULL; + ext->glyph = old->glyph; + ext->start_overlap = old->start_overlap; + ext->end_overlap = old->end_overlap; + ext->advance = old->advance; + ext->extender = old->extender; + return ext; +} + +@ @c +void dump_variant(extinfo * ext) +{ + dump_int(ext->glyph); + dump_int(ext->start_overlap); + dump_int(ext->end_overlap); + dump_int(ext->advance); + dump_int(ext->extender); + return; +} + + +@ @c +extinfo *undump_variant(void) +{ + int x; + extinfo *ext; + undump_int(x); + if (x == 0) + return NULL; + ext = xmalloc(sizeof(extinfo)); + ext->next = NULL; + ext->glyph = x; + undump_int(x); + ext->start_overlap = x; + undump_int(x); + ext->end_overlap = x; + undump_int(x); + ext->advance = x; + undump_int(x); + ext->extender = x; + return ext; +} + +@ @c +void add_charinfo_vert_variant(charinfo * ci, extinfo * ext) +{ + if (ci->vert_variants == NULL) { + ci->vert_variants = ext; + } else { + extinfo *lst = ci->vert_variants; + while (lst->next != NULL) + lst = lst->next; + lst->next = ext; + } + +} + +@ @c +void add_charinfo_hor_variant(charinfo * ci, extinfo * ext) +{ + if (ci->hor_variants == NULL) { + ci->hor_variants = ext; + } else { + extinfo *lst = ci->hor_variants; + while (lst->next != NULL) + lst = lst->next; + lst->next = ext; + } + +} + +@ @c +extinfo *copy_variants(extinfo * o) +{ + extinfo *c, *t = NULL, *h = NULL; + while (o != NULL) { + c = copy_variant(o); + if (h == null) + h = c; + else + t->next = c; + t = c; + o = o->next; + } + + return h; +} + + +@ @c +void dump_charinfo_variants(extinfo * o) +{ + while (o != NULL) { + dump_variant(o); + o = o->next; + } + dump_int(0); + return; +} + +@ @c +extinfo *undump_charinfo_variants(void) +{ + extinfo *c, *t, *h = NULL; + c = undump_variant(); + while (c != NULL) { + if (h == null) + h = c; + else + t->next = c; + t = c; + c = undump_variant(); + } + return h; +} + + +@ Note that mant more small things like this are implemented +as macros in the header file. +@c +void set_charinfo_width(charinfo * ci, scaled val) +{ + ci->width = val; +} + +void set_charinfo_height(charinfo * ci, scaled val) +{ + ci->height = val; +} + +void set_charinfo_depth(charinfo * ci, scaled val) +{ + ci->depth = val; +} + +void set_charinfo_italic(charinfo * ci, scaled val) +{ + ci->italic = val; +} + +void set_charinfo_top_accent(charinfo * ci, scaled val) +{ + ci->top_accent = val; +} + +void set_charinfo_bot_accent(charinfo * ci, scaled val) +{ + ci->bot_accent = val; +} + +void set_charinfo_tag(charinfo * ci, scaled val) +{ + ci->tag = (char) val; +} + +void set_charinfo_remainder(charinfo * ci, scaled val) +{ + ci->remainder = val; +} + +void set_charinfo_used(charinfo * ci, scaled val) +{ + ci->used = (char) val; +} + +void set_charinfo_index(charinfo * ci, scaled val) +{ + ci->index = (unsigned short) val; +} + +void set_charinfo_name(charinfo * ci, char *val) +{ + xfree(ci->name); + ci->name = val; +} + +void set_charinfo_tounicode(charinfo * ci, char *val) +{ + xfree(ci->tounicode); + ci->tounicode = val; +} + +void set_charinfo_ligatures(charinfo * ci, liginfo * val) +{ + dxfree(ci->ligatures, val); +} + +void set_charinfo_kerns(charinfo * ci, kerninfo * val) +{ + dxfree(ci->kerns, val); +} + +void set_charinfo_packets(charinfo * ci, eight_bits * val) +{ + dxfree(ci->packets, val); +} + +void set_charinfo_ef(charinfo * ci, scaled val) +{ + ci->ef = val; +} + +void set_charinfo_lp(charinfo * ci, scaled val) +{ + ci->lp = val; +} + +void set_charinfo_rp(charinfo * ci, scaled val) +{ + ci->rp = val; +} + +@ @c +void set_charinfo_vert_variants(charinfo * ci, extinfo * ext) +{ + extinfo *c, *lst; + if (ci->vert_variants != NULL) { + lst = ci->vert_variants; + while (lst != NULL) { + c = lst->next; + free(lst); + lst = c; + } + } + ci->vert_variants = ext; +} + +@ @c +void set_charinfo_hor_variants(charinfo * ci, extinfo * ext) +{ + extinfo *c, *lst; + if (ci->hor_variants != NULL) { + lst = ci->hor_variants; + while (lst != NULL) { + c = lst->next; + free(lst); + lst = c; + } + } + ci->hor_variants = ext; + +} + +@ @c +int get_charinfo_math_kerns(charinfo * ci, int id) +{ + + int k = 0; /* all callers check for |result>0| */ + if (id == top_left_kern) { + k = ci->top_left_math_kerns; + } else if (id == bottom_left_kern) { + k = ci->bottom_left_math_kerns; + } else if (id == bottom_right_kern) { + k = ci->bottom_right_math_kerns; + } else if (id == top_right_kern) { + k = ci->top_right_math_kerns; + } else { + confusion("get_charinfo_math_kerns"); + } + return k; +} + +@ @c +void add_charinfo_math_kern(charinfo * ci, int id, scaled ht, scaled krn) +{ + int k; + if (id == top_left_kern) { + k = ci->top_left_math_kerns; + do_realloc(ci->top_left_math_kern_array, ((k + 1) * 2), sizeof(scaled)); + ci->top_left_math_kern_array[(2 * (k))] = ht; + ci->top_left_math_kern_array[((2 * (k)) + 1)] = krn; + ci->top_left_math_kerns++; + } else if (id == bottom_left_kern) { + k = ci->bottom_left_math_kerns; + do_realloc(ci->bottom_left_math_kern_array, ((k + 1) * 2), + sizeof(scaled)); + ci->bottom_left_math_kern_array[(2 * (k))] = ht; + ci->bottom_left_math_kern_array[(2 * (k)) + 1] = krn; + ci->bottom_left_math_kerns++; + } else if (id == bottom_right_kern) { + k = ci->bottom_right_math_kerns; + do_realloc(ci->bottom_right_math_kern_array, ((k + 1) * 2), + sizeof(scaled)); + ci->bottom_right_math_kern_array[(2 * (k))] = ht; + ci->bottom_right_math_kern_array[(2 * (k)) + 1] = krn; + ci->bottom_right_math_kerns++; + } else if (id == top_right_kern) { + k = ci->top_right_math_kerns; + do_realloc(ci->top_right_math_kern_array, ((k + 1) * 2), + sizeof(scaled)); + ci->top_right_math_kern_array[(2 * (k))] = ht; + ci->top_right_math_kern_array[(2 * (k)) + 1] = krn; + ci->top_right_math_kerns++; + } else { + confusion("add_charinfo_math_kern"); + } +} + + +@ @c +static void dump_math_kerns(charinfo * ci) +{ + int k, l; + l = ci->top_left_math_kerns; + dump_int(l); + for (k = 0; k < l; k++) { + dump_int(ci->top_left_math_kern_array[(2 * k)]); + dump_int(ci->top_left_math_kern_array[(2 * k) + 1]); + } + l = ci->bottom_left_math_kerns; + dump_int(l); + for (k = 0; k < l; k++) { + dump_int(ci->bottom_left_math_kern_array[(2 * k)]); + dump_int(ci->bottom_left_math_kern_array[(2 * k) + 1]); + } + l = ci->bottom_right_math_kerns; + dump_int(l); + for (k = 0; k < l; k++) { + dump_int(ci->bottom_right_math_kern_array[(2 * k)]); + dump_int(ci->bottom_right_math_kern_array[(2 * k) + 1]); + } + l = ci->top_right_math_kerns; + dump_int(l); + for (k = 0; k < l; k++) { + dump_int(ci->bottom_left_math_kern_array[(2 * k)]); + dump_int(ci->bottom_left_math_kern_array[(2 * k) + 1]); + } +} + +@ @c +static void undump_math_kerns(charinfo * ci) +{ + int k; + int x; + undump_int(x); + ci->top_left_math_kerns = x; + if (x > 0) + ci->top_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < ci->top_left_math_kerns; k++) { + undump_int(x); + ci->top_left_math_kern_array[(2 * k)] = (scaled) x; + undump_int(x); + ci->top_left_math_kern_array[(2 * k) + 1] = (scaled) x; + } + undump_int(x); + ci->bottom_left_math_kerns = x; + if (x > 0) + ci->bottom_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < ci->bottom_left_math_kerns; k++) { + undump_int(x); + ci->bottom_left_math_kern_array[(2 * k)] = (scaled) x; + undump_int(x); + ci->bottom_left_math_kern_array[(2 * k) + 1] = (scaled) x; + } + undump_int(x); + ci->bottom_right_math_kerns = x; + if (x > 0) + ci->bottom_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < ci->bottom_right_math_kerns; k++) { + undump_int(x); + ci->bottom_right_math_kern_array[(2 * k)] = (scaled) x; + undump_int(x); + ci->bottom_right_math_kern_array[(2 * k) + 1] = (scaled) x; + } + undump_int(x); + ci->top_right_math_kerns = x; + if (x > 0) + ci->top_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); + for (k = 0; k < ci->top_right_math_kerns; k++) { + undump_int(x); + ci->top_right_math_kern_array[(2 * k)] = (scaled) x; + undump_int(x); + ci->top_right_math_kern_array[(2 * k) + 1] = (scaled) x; + } +} + + +@ In TeX, extensibles were fairly simple things. + This function squeezes a TFM extensible into the vertical extender structures. + |advance==0| is a special case for TFM fonts, because finding the proper + advance width during tfm reading can be tricky + + + a small complication arises if |rep| is the only non-zero: it needs to be + doubled as a non-repeatable to avoid mayhem */ + +@c +void set_charinfo_extensible(charinfo * ci, int top, int bot, int mid, int rep) +{ + extinfo *ext; + set_charinfo_vert_variants(ci, NULL); /* clear old */ + if (bot == 0 && top == 0 && mid == 0 && rep != 0) { + ext = new_variant(rep, 0, 0, 0, EXT_NORMAL); + add_charinfo_vert_variant(ci, ext); + ext = new_variant(rep, 0, 0, 0, EXT_REPEAT); + add_charinfo_vert_variant(ci, ext); + return; + } + if (bot != 0) { + ext = new_variant(bot, 0, 0, 0, EXT_NORMAL); + add_charinfo_vert_variant(ci, ext); + } + if (rep != 0) { + ext = new_variant(rep, 0, 0, 0, EXT_REPEAT); + add_charinfo_vert_variant(ci, ext); + } + if (mid != 0) { + ext = new_variant(mid, 0, 0, 0, EXT_NORMAL); + add_charinfo_vert_variant(ci, ext); + if (rep != 0) { + ext = new_variant(rep, 0, 0, 0, EXT_REPEAT); + add_charinfo_vert_variant(ci, ext); + } + } + if (top != 0) { + ext = new_variant(top, 0, 0, 0, EXT_NORMAL); + add_charinfo_vert_variant(ci, ext); + } +} + +@ Note that many more simple things like this are implemented as macros +in the header file. + +@c +scaled get_charinfo_width(charinfo * ci) +{ + return ci->width; +} + +scaled get_charinfo_height(charinfo * ci) +{ + return ci->height; +} + +scaled get_charinfo_depth(charinfo * ci) +{ + return ci->depth; +} + +scaled get_charinfo_italic(charinfo * ci) +{ + return ci->italic; +} + +scaled get_charinfo_top_accent(charinfo * ci) +{ + return ci->top_accent; +} + +scaled get_charinfo_bot_accent(charinfo * ci) +{ + return ci->bot_accent; +} + +char get_charinfo_tag(charinfo * ci) +{ + return ci->tag; +} + +int get_charinfo_remainder(charinfo * ci) +{ + return ci->remainder; +} + +char get_charinfo_used(charinfo * ci) +{ + return ci->used; +} + +int get_charinfo_index(charinfo * ci) +{ + return ci->index; +} + +char *get_charinfo_name(charinfo * ci) +{ + return ci->name; +} + +char *get_charinfo_tounicode(charinfo * ci) +{ + return ci->tounicode; +} + +liginfo *get_charinfo_ligatures(charinfo * ci) +{ + return ci->ligatures; +} + +kerninfo *get_charinfo_kerns(charinfo * ci) +{ + return ci->kerns; +} + +eight_bits *get_charinfo_packets(charinfo * ci) +{ + return ci->packets; +} + +int get_charinfo_ef(charinfo * ci) +{ + return ci->ef; +} + +int get_charinfo_rp(charinfo * ci) +{ + return ci->rp; +} + +int get_charinfo_lp(charinfo * ci) +{ + return ci->lp; +} + +extinfo *get_charinfo_vert_variants(charinfo * ci) +{ + extinfo *w = NULL; + if (ci->vert_variants != NULL) + w = ci->vert_variants; + return w; +} + +extinfo *get_charinfo_hor_variants(charinfo * ci) +{ + extinfo *w = NULL; + if (ci->hor_variants != NULL) + w = ci->hor_variants; + return w; +} + + +scaled char_width(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + scaled w = get_charinfo_width(ci); + return w; +} + +scaled char_depth(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + scaled w = get_charinfo_depth(ci); + return w; +} + +scaled char_height(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + scaled w = get_charinfo_height(ci); + return w; +} + +scaled char_italic(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_italic(ci); +} + +scaled char_top_accent(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_top_accent(ci); +} + +scaled char_bot_accent(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_bot_accent(ci); +} + + +int char_remainder(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_remainder(ci); +} + +char char_tag(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_tag(ci); +} + +char char_used(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_used(ci); +} + +char *char_name(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_name(ci); +} + +int char_index(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_index(ci); +} + +liginfo *char_ligatures(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_ligatures(ci); +} + +kerninfo *char_kerns(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_kerns(ci); +} + +eight_bits *char_packets(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_packets(ci); +} + +@ @c +void set_font_params(internal_font_number f, int b) +{ + int i; + i = font_params(f); + if (i != b) { + font_bytes += + (int) ((b - (int) font_params(f) + 1) * (int) sizeof(scaled)); + do_realloc(param_base(f), (b + 2), int); + font_params(f) = b; + if (b > i) { + while (i < b) { + i++; + set_font_param(f, i, 0); + } + } + } +} + +@ @c +void set_font_math_params(internal_font_number f, int b) +{ + int i; + i = font_math_params(f); + if (i != b) { + font_bytes += + ((b - (int) font_math_params(f) + 1) * (int) sizeof(scaled)); + do_realloc(math_param_base(f), (b + 2), int); + font_math_params(f) = b; + if (b > i) { + while (i < b) { + i++; + set_font_math_param(f, i, undefined_math_parameter); + } + } + } +} + + +@ @c +int copy_font(int f) +{ + int i, ci_cnt, ci_size; + charinfo *ci; + int k = new_font(); + + { + ci = font_tables[k]->charinfo; + ci_cnt = font_tables[k]->charinfo_count; + ci_size = font_tables[k]->charinfo_size; + memcpy(font_tables[k], font_tables[f], sizeof(texfont)); + font_tables[k]->charinfo = ci; + font_tables[k]->charinfo_count = ci_cnt; + font_tables[k]->charinfo_size = ci_size; + } + + font_malloc_charinfo(k, font_tables[f]->charinfo_count); + set_font_cache_id(k, 0); + set_font_used(k, 0); + set_font_touched(k, 0); + + font_tables[k]->_font_name = NULL; + font_tables[k]->_font_filename = NULL; + font_tables[k]->_font_fullname = NULL; + font_tables[k]->_font_psname = NULL; + font_tables[k]->_font_encodingname = NULL; + font_tables[k]->_font_area = NULL; + font_tables[k]->_font_cidregistry = NULL; + font_tables[k]->_font_cidordering = NULL; + font_tables[k]->_left_boundary = NULL; + font_tables[k]->_right_boundary = NULL; + + set_font_name(k, xstrdup(font_name(f))); + if (font_filename(f) != NULL) + set_font_filename(k, xstrdup(font_filename(f))); + if (font_fullname(f) != NULL) + set_font_fullname(k, xstrdup(font_fullname(f))); + if (font_psname(f) != NULL) + set_font_psname(k, xstrdup(font_psname(f))); + if (font_encodingname(f) != NULL) + set_font_encodingname(k, xstrdup(font_encodingname(f))); + if (font_area(f) != NULL) + set_font_area(k, xstrdup(font_area(f))); + if (font_cidregistry(f) != NULL) + set_font_cidregistry(k, xstrdup(font_cidregistry(f))); + if (font_cidordering(f) != NULL) + set_font_cidordering(k, xstrdup(font_cidordering(f))); + + i = (int) (sizeof(*param_base(f)) * (unsigned) font_params(f)); + font_bytes += i; + param_base(k) = xmalloc((unsigned) i); + memcpy(param_base(k), param_base(f), (size_t) i); + + if (font_math_params(f) > 0) { + i = (int) (sizeof(*math_param_base(f)) * + (unsigned) font_math_params(f)); + font_bytes += i; + math_param_base(k) = xmalloc((unsigned) i); + memcpy(math_param_base(k), math_param_base(f), (size_t) i); + } + + for (i = 0; i <= font_tables[f]->charinfo_count; i++) { + ci = copy_charinfo(&font_tables[f]->charinfo[i]); + font_tables[k]->charinfo[i] = *ci; + } + + if (left_boundary(f) != NULL) { + ci = copy_charinfo(left_boundary(f)); + set_charinfo(k, left_boundarychar, ci); + } + + if (right_boundary(f) != NULL) { + ci = copy_charinfo(right_boundary(f)); + set_charinfo(k, right_boundarychar, ci); + } + return k; +} + +@ @c +void delete_font(int f) +{ + int i; + charinfo *co; + assert(f > 0); + if (font_tables[f] != NULL) { + set_font_name(f, NULL); + set_font_filename(f, NULL); + set_font_fullname(f, NULL); + set_font_psname(f, NULL); + set_font_encodingname(f, NULL); + set_font_area(f, NULL); + set_font_cidregistry(f, NULL); + set_font_cidordering(f, NULL); + set_left_boundary(f, NULL); + set_right_boundary(f, NULL); + + for (i = font_bc(f); i <= font_ec(f); i++) { + if (quick_char_exists(f, i)) { + co = char_info(f, i); + set_charinfo_name(co, NULL); + set_charinfo_tounicode(co, NULL); + set_charinfo_packets(co, NULL); + set_charinfo_ligatures(co, NULL); + set_charinfo_kerns(co, NULL); + set_charinfo_vert_variants(co, NULL); + set_charinfo_hor_variants(co, NULL); + } + } + /* free .notdef */ + set_charinfo_name(font_tables[f]->charinfo + 0, NULL); + free(font_tables[f]->charinfo); + destroy_sa_tree(font_tables[f]->characters); + + free(param_base(f)); + if (math_param_base(f) != NULL) + free(math_param_base(f)); + free(font_tables[f]); + font_tables[f] = NULL; + + if (font_id_maxval == f) { + font_id_maxval--; + } + } +} + +@ @c +void create_null_font(void) +{ + int i = new_font(); + assert(i == 0); + set_font_name(i, xstrdup("nullfont")); + set_font_area(i, xstrdup("")); + set_font_touched(i, 1); +} + +@ @c +boolean is_valid_font(int id) +{ + int ret = 0; + if (id >= 0 && id <= font_id_maxval && font_tables[id] != NULL) + ret = 1; + return ret; +} + +@ @c +boolean cmp_font_area(int id, str_number t) +{ + char *tt = NULL; + char *tid = font_area(id); + if (t == 0) { + if (tid == NULL || strlen(tid) == 0) + return 1; + else + return 0; + } + tt = makecstring(t); + if ((tt == NULL || strlen(tt) == 0) && (tid == NULL || strlen(tid) == 0)) + return 1; + if (tt == NULL || strcmp(tid, tt) != 0) + return 0; + free(tt); + return 1; +} + +@ @c +int test_no_ligatures(internal_font_number f) +{ + int c; + for (c = font_bc(f); c <= font_ec(f); c++) { + if (has_lig(f, c)) /* |char_exists(f,c)| */ + return 0; + } + return 1; +} + +@ @c +int get_tag_code(internal_font_number f, int c) +{ + small_number i; + if (char_exists(f, c)) { + i = char_tag(f, c); + if (i == lig_tag) + return 1; + else if (i == list_tag) + return 2; + else if (i == ext_tag) + return 4; + else + return 0; + } + return -1; +} + +@ @c +int get_lp_code(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_lp(ci); +} + +int get_rp_code(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_rp(ci); +} + +int get_ef_code(internal_font_number f, int c) +{ + charinfo *ci = char_info(f, c); + return get_charinfo_ef(ci); +} + +@ @c +void set_tag_code(internal_font_number f, int c, int i) +{ + int fixedi; + charinfo *co; + if (char_exists(f, c)) { + /* |abs(fix_int(i-7,0))| */ + fixedi = -(i < -7 ? -7 : (i > 0 ? 0 : i)); + co = char_info(f, c); + if (fixedi >= 4) { + if (char_tag(f, c) == ext_tag) + set_charinfo_tag(co, (char_tag(f, c) - ext_tag)); + fixedi = fixedi - 4; + } + if (fixedi >= 2) { + if (char_tag(f, c) == list_tag) + set_charinfo_tag(co, (char_tag(f, c) - list_tag)); + fixedi = fixedi - 2; + }; + if (fixedi >= 1) { + if (has_lig(f, c)) + set_charinfo_ligatures(co, NULL); + if (has_kern(f, c)) + set_charinfo_kerns(co, NULL); + } + } +} + + +@ @c +void set_lp_code(internal_font_number f, int c, int i) +{ + charinfo *co; + if (char_exists(f, c)) { + co = char_info(f, c); + set_charinfo_lp(co, i); + } +} + +void set_rp_code(internal_font_number f, int c, int i) +{ + charinfo *co; + if (char_exists(f, c)) { + co = char_info(f, c); + set_charinfo_rp(co, i); + } +} + +void set_ef_code(internal_font_number f, int c, int i) +{ + charinfo *co; + if (char_exists(f, c)) { + co = char_info(f, c); + set_charinfo_ef(co, i); + } +} + +@ @c +void set_no_ligatures(internal_font_number f) +{ + int c; + charinfo *co; + + if (font_tables[f]->ligatures_disabled) + return; + + co = char_info(f, left_boundarychar); + set_charinfo_ligatures(co, NULL); + co = char_info(f, right_boundarychar); /* this is weird */ + set_charinfo_ligatures(co, NULL); + for (c = 0; c < font_tables[f]->charinfo_count; c++) { + co = font_tables[f]->charinfo + c; + set_charinfo_ligatures(co, NULL); + } + font_tables[f]->ligatures_disabled = 1; +} + +@ @c +liginfo get_ligature(internal_font_number f, int lc, int rc) +{ + int k; + liginfo t, u; + charinfo *co; + t.lig = 0; + t.type = 0; + t.adj = 0; + if (lc == non_boundarychar || rc == non_boundarychar || (!has_lig(f, lc))) + return t; + k = 0; + co = char_info(f, lc); + while (1) { + u = charinfo_ligature(co, k); + if (lig_end(u)) + break; + if (lig_char(u) == rc) { + if (lig_disabled(u)) { + return t; + } else { + return u; + } + } + k++; + } + return t; +} + + +@ @c +scaled raw_get_kern(internal_font_number f, int lc, int rc) +{ + int k; + kerninfo u; + charinfo *co; + if (lc == non_boundarychar || rc == non_boundarychar) + return 0; + k = 0; + co = char_info(f, lc); + while (1) { + u = charinfo_kern(co, k); + if (kern_end(u)) + break; + if (kern_char(u) == rc) { + if (kern_disabled(u)) + return 0; + else + return kern_kern(u); + } + k++; + } + return 0; +} + + +@ @c +scaled get_kern(internal_font_number f, int lc, int rc) +{ + if (lc == non_boundarychar || rc == non_boundarychar || (!has_kern(f, lc))) + return 0; + return raw_get_kern(f, lc, rc); +} + + +@ dumping and undumping fonts + +@c +#define dump_string(a) \ + if (a!=NULL) { \ + x = (int)(strlen(a)+1); \ + dump_int(x); dump_things(*a, x); \ + } else { \ + x = 0; dump_int(x); \ + } + +void dump_charinfo(int f, int c) +{ + charinfo *co; + int x; + liginfo *lig; + kerninfo *kern; + dump_int(c); + co = char_info(f, c); + set_charinfo_used(co, 0); + dump_int(get_charinfo_width(co)); + dump_int(get_charinfo_height(co)); + dump_int(get_charinfo_depth(co)); + dump_int(get_charinfo_italic(co)); + dump_int(get_charinfo_top_accent(co)); + dump_int(get_charinfo_bot_accent(co)); + dump_int(get_charinfo_tag(co)); + dump_int(get_charinfo_ef(co)); + dump_int(get_charinfo_rp(co)); + dump_int(get_charinfo_lp(co)); + dump_int(get_charinfo_remainder(co)); + dump_int(get_charinfo_used(co)); + dump_int(get_charinfo_index(co)); + dump_string(get_charinfo_name(co)); + dump_string(get_charinfo_tounicode(co)); + + /* ligatures */ + x = 0; + if ((lig = get_charinfo_ligatures(co)) != NULL) { + while (!lig_end(lig[x])) { + x++; + } + x++; + dump_int(x); + dump_things(*lig, x); + } else { + dump_int(x); + } + /* kerns */ + x = 0; + if ((kern = get_charinfo_kerns(co)) != NULL) { + while (!kern_end(kern[x])) { + x++; + } + x++; + dump_int(x); + dump_things(*kern, x); + } else { + dump_int(x); + } + /* packets */ + x = vf_packet_bytes(co); + dump_int(x); + if (x > 0) { + dump_things(*get_charinfo_packets(co), x); + } + + if (get_charinfo_tag(co) == ext_tag) { + dump_charinfo_variants(get_charinfo_vert_variants(co)); + dump_charinfo_variants(get_charinfo_hor_variants(co)); + } + dump_math_kerns(co); +} + +void dump_font_entry(texfont * f) +{ + int x; + dump_int(f->_font_size); + dump_int(f->_font_dsize); + dump_int(f->_font_cidversion); + dump_int(f->_font_cidsupplement); + dump_int(f->_font_ec); + x = (int) f->_font_checksum; + dump_int(x); + dump_int(f->_font_used); + dump_int(f->_font_touched); + dump_int(f->_font_cache_id); + dump_int(f->_font_encodingbytes); + dump_int(f->_font_slant); + dump_int(f->_font_extend); + dump_int(f->_font_expand_ratio); + dump_int(f->_font_shrink); + dump_int(f->_font_stretch); + dump_int(f->_font_step); + dump_int(f->_font_auto_expand); + dump_int(f->_font_tounicode); + dump_int(f->_font_type); + dump_int(f->_font_format); + dump_int(f->_font_embedding); + dump_int(f->_font_bc); + dump_int(f->_hyphen_char); + dump_int(f->_skew_char); + dump_int(f->_font_natural_dir); + dump_int(f->_font_params); + dump_int(f->_font_math_params); + dump_int(f->ligatures_disabled); + dump_int(f->_pdf_font_num); + dump_int(f->_pdf_font_blink); + dump_int(f->_pdf_font_elink); + dump_int(f->_pdf_font_attr); +} + +void dump_font(int f) +{ + int i, x; + + set_font_used(f, 0); + font_tables[f]->charinfo_cache = NULL; + dump_font_entry(font_tables[f]); + dump_string(font_name(f)); + dump_string(font_area(f)); + dump_string(font_filename(f)); + dump_string(font_fullname(f)); + dump_string(font_psname(f)); + dump_string(font_encodingname(f)); + dump_string(font_cidregistry(f)); + dump_string(font_cidordering(f)); + + dump_things(*param_base(f), (font_params(f) + 1)); + + if (font_math_params(f) > 0) { + dump_things(*math_param_base(f), (font_math_params(f))); + } + if (has_left_boundary(f)) { + dump_int(1); + dump_charinfo(f, left_boundarychar); + } else { + dump_int(0); + } + if (has_right_boundary(f)) { + dump_int(1); + dump_charinfo(f, right_boundarychar); + } else { + dump_int(0); + } + + for (i = font_bc(f); i <= font_ec(f); i++) { + if (quick_char_exists(f, i)) { + dump_charinfo(f, i); + } + } +} + +@ @c +int undump_charinfo(int f) +{ + charinfo *co; + int x, i; + char *s = NULL; + liginfo *lig = NULL; + kerninfo *kern = NULL; + eight_bits *packet = NULL; + + undump_int(i); + co = get_charinfo(f, i); + undump_int(x); + set_charinfo_width(co, x); + undump_int(x); + set_charinfo_height(co, x); + undump_int(x); + set_charinfo_depth(co, x); + undump_int(x); + set_charinfo_italic(co, x); + undump_int(x); + set_charinfo_top_accent(co, x); + undump_int(x); + set_charinfo_bot_accent(co, x); + undump_int(x); + set_charinfo_tag(co, x); + undump_int(x); + set_charinfo_ef(co, x); + undump_int(x); + set_charinfo_rp(co, x); + undump_int(x); + set_charinfo_lp(co, x); + undump_int(x); + set_charinfo_remainder(co, x); + undump_int(x); + set_charinfo_used(co, x); + undump_int(x); + set_charinfo_index(co, x); + + /* name */ + undump_int(x); + if (x > 0) { + font_bytes += x; + s = xmalloc((unsigned) x); + undump_things(*s, x); + } + set_charinfo_name(co, s); + /* tounicode */ + undump_int(x); + if (x > 0) { + font_bytes += x; + s = xmalloc((unsigned) x); + undump_things(*s, x); + } + set_charinfo_tounicode(co, s); + /* ligatures */ + undump_int(x); + if (x > 0) { + font_bytes += (int) ((unsigned) x * sizeof(liginfo)); + lig = xmalloc((unsigned) ((unsigned) x * sizeof(liginfo))); + undump_things(*lig, x); + } + set_charinfo_ligatures(co, lig); + /* kerns */ + undump_int(x); + if (x > 0) { + font_bytes += (int) ((unsigned) x * sizeof(kerninfo)); + kern = xmalloc((unsigned) ((unsigned) x * sizeof(kerninfo))); + undump_things(*kern, x); + } + set_charinfo_kerns(co, kern); + + /* packets */ + undump_int(x); + if (x > 0) { + font_bytes += x; + packet = xmalloc((unsigned) x); + undump_things(*packet, x); + } + set_charinfo_packets(co, packet); + + if (get_charinfo_tag(co) == ext_tag) { + set_charinfo_vert_variants(co, undump_charinfo_variants()); + set_charinfo_hor_variants(co, undump_charinfo_variants()); + } + undump_math_kerns(co); + return i; +} + +#define undump_font_string(a) undump_int (x); \ + if (x>0) { \ + font_bytes += x; \ + s = xmalloc((unsigned)x); undump_things(*s,x); \ + a(f,s); } + + +void undump_font_entry(texfont * f) +{ + int x = 0; + /* *INDENT-OFF* */ + undump_int(x); f->_font_size = x; + undump_int(x); f->_font_dsize = x; + undump_int(x); f->_font_cidversion = x; + undump_int(x); f->_font_cidsupplement = x; + undump_int(x); f->_font_ec = x; + undump_int(x); f->_font_checksum = (unsigned)x; + undump_int(x); f->_font_used = (char)x; + undump_int(x); f->_font_touched = (char)x; + undump_int(x); f->_font_cache_id = x; + undump_int(x); f->_font_encodingbytes = (char)x; + undump_int(x); f->_font_slant = x; + undump_int(x); f->_font_extend = x; + undump_int(x); f->_font_expand_ratio = x; + undump_int(x); f->_font_shrink = x; + undump_int(x); f->_font_stretch = x; + undump_int(x); f->_font_step = x; + undump_int(x); f->_font_auto_expand = x; + undump_int(x); f->_font_tounicode = (char)x; + undump_int(x); f->_font_type = x; + undump_int(x); f->_font_format = x; + undump_int(x); f->_font_embedding = x; + undump_int(x); f->_font_bc = x; + undump_int(x); f->_hyphen_char = x; + undump_int(x); f->_skew_char = x; + undump_int(x); f->_font_natural_dir = x; + undump_int(x); f->_font_params = x; + undump_int(x); f->_font_math_params = x; + undump_int(x); f->ligatures_disabled = x; + undump_int(x); f->_pdf_font_num = x; + undump_int(x); f->_pdf_font_blink = x; + undump_int(x); f->_pdf_font_elink = x; + undump_int(x); f->_pdf_font_attr = x; + /* *INDENT-ON* */ +} + + + +void undump_font(int f) +{ + int x, i; + texfont *tt; + charinfo *ci; + char *s; + grow_font_table(f); + tt = xmalloc(sizeof(texfont)); + memset(tt, 0, sizeof(texfont)); + font_bytes += (int) sizeof(texfont); + undump_font_entry(tt); + font_tables[f] = tt; + + undump_font_string(set_font_name); + undump_font_string(set_font_area); + undump_font_string(set_font_filename); + undump_font_string(set_font_fullname); + undump_font_string(set_font_psname); + undump_font_string(set_font_encodingname); + undump_font_string(set_font_cidregistry); + undump_font_string(set_font_cidordering); + + i = (int) (sizeof(*param_base(f)) * ((unsigned) font_params(f) + 1)); + font_bytes += i; + param_base(f) = xmalloc((unsigned) i); + undump_things(*param_base(f), (font_params(f) + 1)); + + if (font_math_params(f) > 0) { + i = (int) (sizeof(*math_param_base(f)) * + ((unsigned) font_math_params(f) + 1)); + font_bytes += i; + math_param_base(f) = xmalloc((unsigned) i); + undump_things(*math_param_base(f), (font_math_params(f) + 1)); + } + + undump_int(x); + if (x) { + i = undump_charinfo(f); + } /* left boundary */ + undump_int(x); + if (x) { + i = undump_charinfo(f); + } /* right boundary */ + font_tables[f]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */ + ci = xcalloc(1, sizeof(charinfo)); + set_charinfo_name(ci, xstrdup(".notdef")); + font_tables[f]->charinfo = ci; + + i = font_bc(f); + while (i < font_ec(f)) { + i = undump_charinfo(f); + } +} diff --git a/Build/source/texk/web2c/luatexdir/font/tfmofm.c b/Build/source/texk/web2c/luatexdir/font/tfmofm.c deleted file mode 100644 index 6c99a9dd498..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/tfmofm.c +++ /dev/null @@ -1,1116 +0,0 @@ -/* tfmofm.c - - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "luatex-api.h" -#include "luatexfont.h" - -static const char _svn_version[] = - "$Id: tfmofm.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/tfmofm.c $"; - -/* Here are some macros that help process ligatures and kerns */ - -#define lig_kern_start(f,c) char_remainder(f,c) -#define stop_flag 128 /* value indicating `\.{STOP}' in a lig/kern program */ -#define kern_flag 128 /* op code for a kern step */ - -#define skip_byte(z) lig_kerns[z].b0 -#define next_char(z) lig_kerns[z].b1 -#define op_byte(z) lig_kerns[z].b2 -#define rem_byte(z) lig_kerns[z].b3 -#define lig_kern_restart(c) (256*op_byte(c)+rem_byte(c)) - -/* - -The information in a \.{TFM} file appears in a sequence of 8-bit bytes. -Since the number of bytes is always a multiple of 4, we could -also regard the file as a sequence of 32-bit words, but \TeX\ uses the -byte interpretation. The format of \.{TFM} files was designed by -Lyle Ramshaw in 1980. The intent is to convey a lot of different kinds -@^Ramshaw, Lyle Harold@> -of information in a compact but useful form. - -$\Omega$ is capable of reading not only \.{TFM} files, but also -\.{OFM} files, which can describe fonts with up to 65536 characters -and with huge lig/kern tables. These fonts will often be virtual -fonts built up from real fonts with 256 characters, but $\Omega$ -is not aware of this. - -The documentation below describes \.{TFM} files, with slight additions -to show where \.{OFM} files differ. - */ -/* -@ 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: -$$\vbox{\halign{\hfil#&$\null=\null$#\hfil\cr -|lf|&length of the entire file, in words;\cr -|lh|&length of the header data, in words;\cr -|bc|&smallest character code in the font;\cr -|ec|&largest character code in the font;\cr -|nw|&number of words in the width table;\cr -|nh|&number of words in the height table;\cr -|nd|&number of words in the depth table;\cr -|ni|&number of words in the italic correction table;\cr -|nl|&number of words in the lig/kern table;\cr -|nk|&number of words in the kern table;\cr -|ne|&number of words in the extensible character table;\cr -|np|&number of font parameter words.\cr}}$$ -They are all nonnegative and less than $2^{15}$. We must have |bc-1<=ec<=255|, -and -$$\hbox{|lf=6+lh+(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np|.}$$ -Note that a \.{TFM} font may contain as many as 256 characters -(if |bc=0| and |ec=255|), and as few as 0 characters (if |bc=ec+1|). - -Incidentally, 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. -@!@^BigEndian order@> - -The first 52 bytes (13 words) of an \.{OFM} file contains thirteen -32-bit integers that give the lengths of the various subsequent -portions of the file. The first word is 0 (future versions of -\.{OFM} files could have different values; what is important is that -the first two bytes be 0 to differentiate \.{TFM} and \.{OFM} files). -The next twelve integers are as above, all nonegative and less -than~$2^{31}$. We must have |bc-1<=ec<=65535|, and -$$\hbox{|lf=13+lh+2*(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np|.}$$ -Note that an \.{OFM} font may contain as many as 65536 characters -(if |bc=0| and |ec=65535|), and as few as 0 characters (if |bc=ec+1|). - -@ The rest of the \.{TFM} file may be regarded as a sequence of ten data -arrays having the informal specification -$$\def\arr$[#1]#2${\&{array} $[#1]$ \&{of} #2} -\vbox{\halign{\hfil\\{#}&$\,:\,$\arr#\hfil\cr -header&|[0..lh-1]@t\\{stuff}@>|\cr -char\_info&|[bc..ec]char_info_word|\cr -width&|[0..nw-1]fix_word|\cr -height&|[0..nh-1]fix_word|\cr -depth&|[0..nd-1]fix_word|\cr -italic&|[0..ni-1]fix_word|\cr -lig\_kern&|[0..nl-1]lig_kern_command|\cr -kern&|[0..nk-1]fix_word|\cr -exten&|[0..ne-1]extensible_recipe|\cr -param&|[1..np]fix_word|\cr}}$$ -The most important data type used here is a |@!fix_word|, which is -a 32-bit representation of a binary fraction. A |fix_word| is a signed -quantity, with the two's complement of the entire word used to represent -negation. Of the 32 bits in a |fix_word|, exactly 12 are to the left of the -binary point; thus, the largest |fix_word| value is $2048-2^{-20}$, and -the smallest is $-2048$. We will see below, however, that all but two of -the |fix_word| values must lie between $-16$ and $+16$. - -@ The first data array is a block of header information, which contains -general facts about the font. The header must contain at least two words, -|header[0]| and |header[1]|, whose meaning is explained below. -Additional header information of use to other software routines might -also be included, but \TeX82 does not need to know about such details. -For example, 16 more words of header information are in use at the Xerox -Palo Alto Research Center; the first ten specify the character coding -scheme used (e.g., `\.{XEROX text}' or `\.{TeX math symbols}'), the next five -give the font identifier (e.g., `\.{HELVETICA}' or `\.{CMSY}'), and the -last gives the ``face byte.'' The program that converts \.{DVI} files -to Xerox printing format gets this information by looking at the \.{TFM} -file, which it needs to read anyway because of other information that -is not explicitly repeated in \.{DVI}~format. - -\yskip\hang|header[0]| is a 32-bit check sum that \TeX\ will copy into -the \.{DVI} output file. Later on when the \.{DVI} file is printed, -possibly on another computer, the actual font that gets used is supposed -to have a check sum that agrees with the one in the \.{TFM} file used by -\TeX. In this way, users will be warned about potential incompatibilities. -(However, if the check sum is zero in either the font file or the \.{TFM} -file, no check is made.) The actual relation between this check sum and -the rest of the \.{TFM} file is not important; the check sum is simply an -identification number with the property that incompatible fonts almost -always have distinct check sums. -@^check sum@> - -\yskip\hang|header[1]| is a |fix_word| containing the design size of -the font, in units of \TeX\ points. This number must be at least 1.0; it is -fairly arbitrary, but usually the design size is 10.0 for a ``10 point'' -font, i.e., a font that was designed to look best at a 10-point size, -whatever that really means. When a \TeX\ user asks for a font -`\.{at} $\delta$ \.{pt}', the effect is to override the design size -and replace it by $\delta$, and to multiply the $x$ and~$y$ coordinates -of the points in the font image by a factor of $\delta$ divided by the -design size. {\sl All other dimensions in the\/ \.{TFM} file are -|fix_word|\kern-1pt\ numbers in design-size units}, with the exception of -|param[1]| (which denotes the slant ratio). Thus, for example, the value -of |param[6]|, which defines the \.{em} unit, is often the |fix_word| value -$2^{20}=1.0$, since many fonts have a design size equal to one em. -The other dimensions must be less than 16 design-size units in absolute -value; thus, |header[1]| and |param[1]| are the only |fix_word| -entries in the whole \.{TFM} file whose first byte might be something -besides 0 or 255. - -@ Next comes the |char_info| array, which contains one |@!char_info_word| -per character. Each word in this part of a \.{TFM} file contains six fields -packed into four bytes as follows. - -\yskip\hang first byte: |@!width_index| (8 bits)\par -\hang second byte: |@!height_index| (4 bits) times 16, plus |@!depth_index| - (4~bits)\par -\hang third byte: |@!italic_index| (6 bits) times 4, plus |@!tag| - (2~bits)\par -\hang fourth byte: |@!remainder| (8 bits)\par -\yskip\noindent -The actual width of a character is \\{width}|[width_index]|, in design-size -units; this is a device for compressing information, since many characters -have the same width. Since it is quite common for many characters -to have the same height, depth, or italic correction, the \.{TFM} format -imposes a limit of 16 different heights, 16 different depths, and -64 different italic corrections. - -For \.{OFM} files, two words (eight bytes) are used. -The arrangement is as follows. - -\yskip\hang first and second bytes: |@!width_index| (16 bits)\par -\hang third byte: |@!height_index| (8 bits)\par -\hang fourth byte: |@!depth_index| (8~bits)\par -\hang fifth and sixth bytes: -|@!italic_index| (14 bits) times 4, plus |@!tag| (2~bits)\par -\hang seventh and eighth bytes: |@!remainder| (16 bits)\par -\yskip\noindent -Therefore the \.{OFM} format imposes a limit of 256 different heights, -256 different depths, and 16384 different italic corrections. - -@!@^italic correction@> -The italic correction of a character has two different uses. -(a)~In ordinary text, the italic correction is added to the width only if -the \TeX\ user specifies `\.{\\/}' after the character. -(b)~In math formulas, the italic correction is always added to the width, -except with respect to the positioning of subscripts. - -Incidentally, the relation $\\{width}[0]=\\{height}[0]=\\{depth}[0]= -\\{italic}[0]=0$ should always hold, so that an index of zero implies a -value of zero. The |width_index| should never be zero unless the -character does not exist in the font, since a character is valid if and -only if it lies between |bc| and |ec| and has a nonzero |width_index|. -*/ - -/* -@ \TeX\ checks the information of a \.{TFM} file for validity as the -file is being read in, so that no further checks will be needed when -typesetting is going on. The somewhat tedious subroutine that does this -is called |read_font_info|. It has four parameters: the user font -identifier~|u|, the file name and area strings |nom| and |aire|, and the -``at'' size~|s|. If |s|~is negative, it's the negative of a scale factor -to be applied to the design size; |s=-1000| is the normal case. -Otherwise |s| will be substituted for the design size; in this -case, |s| must be positive and less than $2048\rm\,pt$ -(i.e., it must be less than $2^{27}$ when considered as an integer). - -The subroutine opens and closes a global file variable called |tfm_file|. -It returns the value of the internal font number that was just loaded. -If an error is detected, an error message is issued and no font -information is stored; |null_font| is returned in this case. - -@d bad_tfm=11 {label for |read_font_info|} -@d abort==goto bad_tfm {do this when the \.{TFM} data is wrong} - -*/ - -/* -The |tag| field in a |char_info_word| has four values that explain how to -interpret the |remainder| field. - -\yskip\hangg|tag=0| (|no_tag|) means that |remainder| is unused.\par -\hangg|tag=1| (|lig_tag|) means that this character has a ligature/kerning -program starting at position |remainder| in the |lig_kern| array.\par -\hangg|tag=2| (|list_tag|) means that this character is part of a chain of -characters of ascending sizes, and not the largest in the chain. The -|remainder| field gives the character code of the next larger character.\par -\hangg|tag=3| (|ext_tag|) means that this character code represents an -extensible character, i.e., a character that is built up of smaller pieces -so that it can be made arbitrarily large. The pieces are specified in -|@!exten[remainder]|.\par -\yskip\noindent -Characters with |tag=2| and |tag=3| are treated as characters with |tag=0| -unless they are used in special circumstances in math formulas. For example, -the \.{\\sum} operation looks for a |list_tag|, and the \.{\\left} -operation looks for both |list_tag| and |ext_tag|. -*/ - -/* The |lig_kern| array contains instructions in a simple programming language -that explains what to do for special letter pairs. Each word in this array, -in a \.{TFM} file, is a |@!lig_kern_command| of four bytes. - -\yskip\hang first byte: |skip_byte|, indicates that this is the final program - step if the byte is 128 or more, otherwise the next step is obtained by - skipping this number of intervening steps.\par -\hang second byte: |next_char|, ``if |next_char| follows the current character, - then perform the operation and stop, otherwise continue.''\par -\hang third byte: |op_byte|, indicates a ligature step if less than~128, - a kern step otherwise.\par -\hang fourth byte: |remainder|.\par -\yskip\noindent -In an \.{OFM} file, eight bytes are used, two bytes for each field. - -In a kern step, an -additional space equal to |kern[256*(op_byte-128)+remainder]| is inserted -between the current character and |next_char|. This amount is -often negative, so that the characters are brought closer together -by kerning; but it might be positive. - -There are eight kinds of ligature steps, having |op_byte| codes $4a+2b+c$ where -$0\le a\le b+c$ and $0\le b,c\le1$. The character whose code is -|remainder| is inserted between the current character and |next_char|; -then the current character is deleted if $b=0$, and |next_char| is -deleted if $c=0$; then we pass over $a$~characters to reach the next -current character (which may have a ligature/kerning program of its own). - -If the very first instruction of the |lig_kern| array has |skip_byte=255|, -the |next_char| byte is the so-called right boundary character of this font; -the value of |next_char| need not lie between |bc| and~|ec|. -If the very last instruction of the |lig_kern| array has |skip_byte=255|, -there is a special ligature/kerning program for a left boundary character, -beginning at location |256*op_byte+remainder|. -The interpretation is that \TeX\ puts implicit boundary characters -before and after each consecutive string of characters from the same font. -These implicit characters do not appear in the output, but they can affect -ligatures and kerning. - -If the very first instruction of a character's |lig_kern| program has -|skip_byte>128|, the program actually begins in location -|256*op_byte+remainder|. This feature allows access to large |lig_kern| -arrays, because the first instruction must otherwise -appear in a location |<=255| in a \.{TFM} file, |<=65535| in an \.{OFM} file. - -Any instruction with |skip_byte>128| in the |lig_kern| array must satisfy -the condition -$$\hbox{|256*op_byte+remainder=0|, unless $M$ is absent; -in the latter case we can have $TR^kB$ for both even and odd values of~|k|. -The width of the extensible character is the width of $R$; and the -height-plus-depth is the sum of the individual height-plus-depths of the -components used, since the pieces are butted together in a vertical list. -*/ - -/* -The final portion of a \.{TFM} file is the |param| array, which is another -sequence of |fix_word| values. - -\yskip\hang|param[1]=slant| is the amount of italic slant, which is used -to help position accents. For example, |slant=.25| means that when you go -up one unit, you also go .25 units to the right. The |slant| is a pure -number; it's the only |fix_word| other than the design size itself that is -not scaled by the design size. - -\hang|param[2]=space| is the normal spacing between words in text. -Note that character |" "| in the font need not have anything to do with -blank spaces. - -\hang|param[3]=space_stretch| is the amount of glue stretching between words. - -\hang|param[4]=space_shrink| is the amount of glue shrinking between words. - -\hang|param[5]=x_height| is the size of one ex in the font; it is also -the height of letters for which accents don't have to be raised or lowered. - -\hang|param[6]=quad| is the size of one em in the font. - -\hang|param[7]=extra_space| is the amount added to |param[2]| at the -ends of sentences. - -\yskip\noindent -If fewer than seven parameters are present, \TeX\ sets the missing parameters -to zero. Fonts used for math symbols are required to have -additional parameter information, which is explained later. -*/ - -/* - There are programs called \.{TFtoPL} and \.{PLtoTF} that convert - between the \.{TFM} format and a symbolic property-list format - that can be easily edited. These programs contain extensive - diagnostic information, so \TeX\ does not have to bother giving - precise details about why it rejects a particular \.{TFM} file. - -*/ - -#define tfm_abort { font_tables[f]->_font_name = NULL; \ - font_tables[f]->_font_area = NULL; \ - xfree(tfm_buffer); xfree(kerns); \ - xfree(widths); xfree(heights); xfree(depths); \ - xfree(italics); xfree(extens); xfree(lig_kerns); \ - xfree(xligs); xfree(xkerns); \ - return 0; } - -#define tfm_success { xfree(tfm_buffer); xfree(kerns); \ - xfree(widths); xfree(heights); xfree(depths); \ - xfree(italics); xfree(extens); xfree(lig_kerns); \ - xfree(xligs); xfree(xkerns); return 1; } - - -static int open_tfm_file(const char *nom, unsigned char **tfm_buf, integer * tfm_siz) -{ - boolean res; /* was the callback successful? */ - boolean opened; /* was |tfm_file| successfully opened? */ - integer callback_id; - FILE *tfm_file; - /* packfilename(nom,aire,getnullstr()); */ - if (nameoffile != NULL) - xfree(nameoffile); - nameoffile = malloc(strlen(nom) + 2); - strcpy(stringcast(nameoffile + 1), nom); - namelength = strlen(nom); - callback_id = callback_defined(read_font_file_callback); - if (callback_id > 0) { - res = run_callback(callback_id, "S->bSd", stringcast(nameoffile + 1), - &opened, tfm_buf, tfm_siz); - if (res && opened && (*tfm_siz > 0)) { - return 1; - } - if (!opened) - return -1; - } else { - if (ofm_open_in(tfm_file)) { - res = read_tfm_file(tfm_file, tfm_buf, tfm_siz); - b_close(tfm_file); - if (res) { - return 1; - } - } else { - return -1; - } - } - return 0; -} - - -/* - Note: A malformed \.{TFM} file might be shorter than it claims to be; - thus |eof(tfm_file)| might be true when |read_font_info| refers to - |tfm_file^| or when it says |get(tfm_file)|. If such circumstances - cause system error messages, you will have to defeat them somehow, - for example by defining |fget| to be `\ignorespaces|begin get(tfm_file);| - |if eof(tfm_file) then abort; end|\unskip'. - @^system dependencies@> -*/ - -#define fget tfm_byte++ -#define fbyte tfm_buffer[tfm_byte] - -#define read_sixteen(a) \ - { a=tfm_buffer[tfm_byte++]; \ - if (a>127) { tfm_abort; } \ - a=(a*256)+tfm_buffer[tfm_byte]; } - -#define read_sixteen_unsigned(a) \ - { a=tfm_buffer[tfm_byte++]; \ - a=(a*256)+tfm_buffer[tfm_byte]; } - -#define read_thirtytwo(a) \ - { a=tfm_buffer[++tfm_byte]; \ - if (a>127) { tfm_abort; } \ - a=(a*256)+tfm_buffer[++tfm_byte]; \ - a=(a*256)+tfm_buffer[++tfm_byte]; \ - a=(a*256)+tfm_buffer[++tfm_byte]; } - -#define store_four_bytes(z) \ - { a=tfm_buffer[++tfm_byte]; \ - a=(a*256)+tfm_buffer[++tfm_byte]; \ - a=(a*256)+tfm_buffer[++tfm_byte]; \ - a=(a*256)+tfm_buffer[++tfm_byte]; \ - z = a; } - -#define store_char_info(z) \ - { if (font_level!=-1) { \ - fget; read_sixteen_unsigned(a); \ - ci._width_index=a; \ - fget; read_sixteen_unsigned(b); \ - ci._height_index=b>>8; \ - ci._depth_index=b%256; \ - fget; read_sixteen_unsigned(c); \ - ci._italic_index=c>>8; \ - ci._tag=c%4; \ - fget; read_sixteen_unsigned(d); \ - ci._remainder=d; \ - } else { \ - a=tfm_buffer[++tfm_byte]; \ - ci._width_index=a; \ - b=tfm_buffer[++tfm_byte]; \ - ci._height_index=b>>4; \ - ci._depth_index=b%16; \ - c=tfm_buffer[++tfm_byte]; \ - ci._italic_index=c>>2; \ - ci._tag=c%4; \ - d=tfm_buffer[++tfm_byte]; \ - ci._remainder=d; \ - } } - -#define read_four_quarters(q) \ - { if (font_level!=-1) { \ - fget; read_sixteen_unsigned(a); q.b0=a; \ - fget; read_sixteen_unsigned(b); q.b1=b; \ - fget; read_sixteen_unsigned(c); q.b2=c; \ - fget; read_sixteen_unsigned(d); q.b3=d; \ - } else { \ - a=tfm_buffer[++tfm_byte]; q.b0=a; \ - b=tfm_buffer[++tfm_byte]; q.b1=b; \ - c=tfm_buffer[++tfm_byte]; q.b2=c; \ - d=tfm_buffer[++tfm_byte]; q.b3=d; \ - } } - -#define check_byte_range(z) { if ((zec)) tfm_abort ; } - - -/* A |fix_word| whose four bytes are $(a,b,c,d)$ from left to right represents - the number - $$x=\left\{\vcenter{\halign{$#$,\hfil\qquad&if $#$\hfil\cr - b\cdot2^{-4}+c\cdot2^{-12}+d\cdot2^{-20}&a=0;\cr - -16+b\cdot2^{-4}+c\cdot2^{-12}+d\cdot2^{-20}&a=255.\cr}}\right.$$ - (No other choices of |a| are allowed, since the magnitude of a number in - design-size units must be less than 16.) We want to multiply this - quantity by the integer~|z|, which is known to be less than $2^{27}$. - If $|z|<2^{23}$, the individual multiplications $b\cdot z$, - $c\cdot z$, $d\cdot z$ cannot overflow; otherwise we will divide |z| by 2, - 4, 8, or 16, to obtain a multiplier less than $2^{23}$, and we can - compensate for this later. If |z| has thereby been replaced by - $|z|^\prime=|z|/2^e$, let $\beta=2^{4-e}$; we shall compute - $$\lfloor(b+c\cdot2^{-8}+d\cdot2^{-16})\,z^\prime/\beta\rfloor$$ - if $a=0$, or the same quantity minus $\alpha=2^{4+e}z^\prime$ if $a=255$. - This calculation must be done exactly, in order to guarantee portability - of \TeX\ between computers. -*/ - -#define store_scaled(zz) \ - { fget; a=fbyte; fget; b=fbyte; \ - fget; c=fbyte; fget; d=fbyte; \ - sw=(((((d*z)>>8)+(c*z))>>8)+(b*z)) / beta; \ - if (a==0) { zz=sw; } else if (a==255) { zz=sw-alpha; } else tfm_abort; \ - } - -scaled store_scaled_f(scaled sq, scaled z_in) -{ - eight_bits a, b, c, d; - scaled sw; - static integer alpha, beta; /* beta:1..16 */ - static scaled z, z_prev = 0; - /* @; */ - if (z_in != z_prev || z_prev == 0) { - z = z_prev = z_in; - alpha = 16; - while (z >= 0x800000) { - z /= 2; - alpha += alpha; - } - beta = 256 / alpha; - alpha *= z; - }; - if (sq >= 0) { - d = sq % 256; /* any "mod 256" not really needed, would typecast alone be safe? */ - sq = sq / 256; - c = sq % 256; - sq = sq / 256; - b = sq % 256; - sq = sq / 256; - a = sq % 256; - } else { - sq = (sq + 1073741824) + 1073741824; /* braces for optimizing compiler */ - d = sq % 256; - sq = sq / 256; - c = sq % 256; - sq = sq / 256; - b = sq % 256; - sq = sq / 256; - a = (sq + 128) % 256; - } - sw = (((((d * z) >> 8) + (c * z)) >> 8) + (b * z)) / beta; - if (a == 0) - return sw; - else if (a == 255) - return (sw - alpha); - else - pdf_error(maketexstring("vf"), maketexstring("vf scaling")); - return sw; /* not reached, just to make the compiler happy */ -} - -#define check_existence(z) \ - { check_byte_range(z); \ - if (!char_exists(f,z)) tfm_abort; \ - } - -typedef struct tfmcharacterinfo { - integer _kern_index; - integer _lig_index; - integer _width_index; - integer _height_index; - integer _depth_index; - integer _italic_index; - integer _remainder; - unsigned char _tag; -} tfmcharacterinfo; - -int read_tfm_info(internalfontnumber f, const char *cnom, scaled s) -{ - integer k; /* index into |font_info| */ - halfword lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np, slh; /* sizes of subfiles */ - scaled *widths, *heights, *depths, *italics, *kerns; - halfword font_dir; - integer a, b, c, d; /* byte variables */ - integer i; /* counter */ - integer font_level, header_length; - integer nco, ncw, npc, nlw, neew; - tfmcharacterinfo ci; - charinfo *co; - four_quarters qw; - four_quarters *lig_kerns, *extens; - scaled sw; /* accumulators */ - integer bch_label; /* left boundary start location, or infinity */ - int bchar; /* :0..too_big_char; *//* right boundary character, or |too_big_char| */ - integer first_two; - scaled z; /* the design size or the ``at'' size */ - integer alpha; - char beta; /* :1..16 */ - integer *xligs, *xkerns; /* aux. for ligkern processing */ - liginfo *cligs; - kerninfo *ckerns; - int fligs, fkerns; - char *tmpnam; - integer tfm_byte = 0; /* index into |tfm_buffer| */ - integer saved_tfm_byte = 0; /* saved index into |tfm_buffer| */ - unsigned char *tfm_buffer = NULL; /* byte buffer for tfm files */ - integer tfm_size = 0; /* total size of the tfm file */ - - widths = NULL; - heights = NULL; - depths = NULL; - italics = NULL; - kerns = NULL; - lig_kerns = NULL; - extens = NULL; - xkerns = NULL; - ckerns = NULL; - xligs = NULL; - cligs = NULL; - - font_dir = 0; - - memset(&ci, 0, sizeof(tfmcharacterinfo)); - - if (open_tfm_file(cnom, &tfm_buffer, &tfm_size) != 1) - tfm_abort; - - /* cnom can be an absolute filename, xbasename() fixes that. */ - - tmpnam = strdup(xbasename(cnom)); - if (strcmp(tmpnam + strlen(tmpnam) - 4, ".tfm") == 0) { - *(tmpnam + strlen(tmpnam) - 4) = 0; - } - set_font_name(f, tmpnam); - set_font_area(f, NULL); - - /* @; */ - nco = 0; - ncw = 0; - npc = 0; - read_sixteen(first_two); - if (first_two != 0) { - font_level = -1; - lf = first_two; - fget; - read_sixteen(lh); - fget; - read_sixteen(bc); - fget; - read_sixteen(ec); - if ((bc > ec + 1) || (ec > 255)) - tfm_abort; - if (bc > 255) { /* |bc=256| and |ec=255| */ - bc = 1; - ec = 0; - }; - fget; - read_sixteen(nw); - fget; - read_sixteen(nh); - fget; - read_sixteen(nd); - fget; - read_sixteen(ni); - fget; - read_sixteen(nl); - fget; - read_sixteen(nk); - fget; - read_sixteen(ne); - fget; - read_sixteen(np); - header_length = 6; - ncw = (ec - bc + 1); - nlw = nl; - neew = ne; - } else { - fget; - read_sixteen(font_level); - if (font_level != 0) - tfm_abort; - read_thirtytwo(lf); - read_thirtytwo(lh); - read_thirtytwo(bc); - read_thirtytwo(ec); - if ((bc > ec + 1) || (ec > 65535)) - tfm_abort; - if (bc > 65535) { /* |bc=65536| and |ec=65535| */ - bc = 1; - ec = 0; - }; - read_thirtytwo(nw); - read_thirtytwo(nh); - read_thirtytwo(nd); - read_thirtytwo(ni); - read_thirtytwo(nl); - read_thirtytwo(nk); - read_thirtytwo(ne); - read_thirtytwo(np); - read_thirtytwo(font_dir); /* junk */ - nlw = 2 * nl; - neew = 2 * ne; - header_length = 14; - ncw = 2 * (ec - bc + 1); - }; - if (lf != - (header_length + lh + ncw + nw + nh + nd + ni + nlw + nk + neew + np)) - tfm_abort; - if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0)) - tfm_abort; - - /* - We check to see that the \.{TFM} file doesn't end prematurely; but - no error message is given for files having more than |lf| words. - */ - if (lf * 4 > tfm_size) - tfm_abort; - - /* @; */ - - set_font_natural_dir(f, font_dir); - set_font_bc(f, bc); - set_font_ec(f, ec); - - /* read the arrays first */ - widths = xmalloc(nw * sizeof(scaled)); - heights = xmalloc(nh * sizeof(scaled)); - depths = xmalloc(nd * sizeof(scaled)); - italics = xmalloc(ni * sizeof(scaled)); - extens = xmalloc(ne * sizeof(four_quarters)); - lig_kerns = xmalloc(nl * sizeof(four_quarters)); - kerns = xmalloc(nk * sizeof(scaled)); - - /* @; */ - - /* Only the first two words of the header are needed by \TeX82. */ - slh = lh; - if (lh < 2) - tfm_abort; - store_four_bytes(font_checksum(f)); - fget; - read_sixteen(z); /* this rejects a negative design size */ - fget; - z = z * 256 + fbyte; - fget; - z = (z * 16) + (fbyte >> 4); - if (z < unity) - tfm_abort; - while (lh > 2) { - fget; - fget; - fget; - fget; - lh--; /* ignore the rest of the header */ - }; - - /* read the arrays before the character info */ - - set_font_dsize(f, z); - if (s != -1000) { - z = (s >= 0 ? s : xn_over_d(z, -s, 1000)); - } - set_font_size(f, z); - - if (np > 7) - set_font_params(f, np); - - saved_tfm_byte = tfm_byte; - tfm_byte = (header_length + slh + ncw) * 4 - 1; - - /* @; */ - - alpha = 16; - while (z >= 040000000) { - z = z >> 1; - alpha = alpha + alpha; - }; - beta = 256 / alpha; - alpha = alpha * z; - - /* @; */ - - for (k = 0; k < nw; k++) { - store_scaled(sw); - widths[k] = sw; - } - if (widths[0] != 0) /* \\{width}[0] must be zero */ - tfm_abort; - for (k = 0; k < nh; k++) { - store_scaled(sw); - heights[k] = sw; - } - if (heights[0] != 0) - tfm_abort; /* \\{height}[0] must be zero */ - for (k = 0; k < nd; k++) { - store_scaled(sw); - depths[k] = sw; - } - if (depths[0] != 0) - tfm_abort; /* \\{depth}[0] must be zero */ - for (k = 0; k < ni; k++) { - store_scaled(sw); - italics[k] = sw; - } - if (italics[0] != 0) - tfm_abort; /* \\{italic}[0] must be zero */ - - - /* @; */ - - bch_label = nl; /* infinity */ - bchar = 65536; - if (nl > 0) { - for (k = 0; k < nl; k++) { - read_four_quarters(qw); - lig_kerns[k] = qw; - if (a > 128) { - if (256 * c + d >= nl) - tfm_abort; - if (a == 255 && k == 0) - bchar = b; - } else { - /* if (b!=bchar) check_existence(b); */ - if (c < 128) { - /* check_existence(d); *//* check ligature */ - } else if (256 * (c - 128) + d >= nk) { - tfm_abort; /* check kern */ - } - if ((a < 128) && (k - 0 + a + 1 >= nl)) - tfm_abort; - }; - }; - if (a == 255) - bch_label = 256 * c + d; - }; - - /* the actual kerns */ - for (k = 0; k < nk; k++) { - store_scaled(sw); - kerns[k] = sw; - } - - /* @; */ - for (k = 0; k < ne; k++) { - read_four_quarters(qw); - extens[k] = qw; - } - - /* @; */ - - if (np > 7) { - set_font_params(f, np); - } - for (k = 1; k <= np; k++) { - if (k == 1) { /* the |slant| parameter is a pure number */ - fget; - sw = fbyte; - if (sw > 127) - sw = sw - 256; - fget; - sw = sw * 256 + fbyte; - fget; - sw = sw * 256 + fbyte; - fget; - sw = (sw * 16) + (fbyte >> 4); - set_font_param(f, k, sw); - } else { - store_scaled(font_param(f, k)); - } - } - - tfm_byte = saved_tfm_byte; - - /* fix up the left boundary character */ - fligs = 0; - fkerns = 0; - if (bch_label != nl) { - k = bch_label; - /* - if (skip_byte(k) > stop_flag) - k = lig_kern_restart(k); - */ - while (1) { - if (skip_byte(k) <= stop_flag) { - if (op_byte(k) >= kern_flag) { /* kern */ - fkerns++; - } else { /* lig */ - fligs++; - } - } - if (skip_byte(k) == 0) { - k++; - } else { - if (skip_byte(k) >= stop_flag) - break; - k += skip_byte(k) + 1; - } - } - } - if (fkerns > 0 || fligs > 0) { - if (fligs > 0) - cligs = xcalloc((fligs + 1), sizeof(liginfo)); - if (fkerns > 0) - ckerns = xcalloc((fkerns + 1), sizeof(kerninfo)); - fligs = 0; - fkerns = 0; - k = bch_label; - /* - if (skip_byte(k) > stop_flag) - k = lig_kern_restart(k); - */ - while (1) { - if (skip_byte(k) <= stop_flag) { - if (op_byte(k) >= kern_flag) { /* kern */ - set_kern_item(ckerns[fkerns], next_char(k), - kerns[256 * (op_byte(k) - 128) + - rem_byte(k)]); - fkerns++; - } else { /* lig */ - set_ligature_item(cligs[fligs], (op_byte(k) * 2 + 1), - next_char(k), rem_byte(k)); - fligs++; - } - } - if (skip_byte(k) == 0) { - k++; - } else { - if (skip_byte(k) >= stop_flag) - break; - k += skip_byte(k) + 1; - } - } - if (fkerns > 0 || fligs > 0) { - co = get_charinfo(f, left_boundarychar); - if (fkerns > 0) { - set_kern_item(ckerns[fkerns], end_kern, 0); - fkerns++; - set_charinfo_kerns(co, ckerns); - } - if (fligs > 0) { - set_ligature_item(cligs[fligs], 0, end_ligature, 0); - fligs++; - set_charinfo_ligatures(co, cligs); - } - set_charinfo_remainder(co, 0); - } - } - - /* @; */ - for (k = bc; k <= ec; k++) { - store_char_info(k); - if (ci._width_index == 0) - continue; - if (ci._width_index >= nw || ci._height_index >= nh || - ci._depth_index >= nd || ci._italic_index >= ni) - tfm_abort; - d = ci._remainder; - switch (ci._tag) { - case lig_tag: - if (d >= nl) - tfm_abort; - break; - case ext_tag: - if (d >= ne) - tfm_abort; - break; - case list_tag: - /* We want to make sure that there is no cycle of characters linked together - by |list_tag| entries, since such a cycle would get \TeX\ into an endless - loop. If such a cycle exists, the routine here detects it when processing - the largest character code in the cycle. - */ - check_byte_range(d); - while (d < k) { /* current_character == k */ - if (char_tag(f, d) != list_tag) - goto NOT_FOUND; /* not a cycle */ - d = char_remainder(f, d); /* next character on the list */ - }; - if (d == k) - tfm_abort; /* yes, there's a cycle */ - NOT_FOUND: - break; - } - /* put it in the actual font */ - co = get_charinfo(f, k); - set_charinfo_index(co, k); - set_charinfo_tag(co, ci._tag); - if (ci._tag == ext_tag) { - set_charinfo_extensible(co, extens[ci._remainder].b0, /* top */ - extens[ci._remainder].b2, /* bot */ - extens[ci._remainder].b1, /* mid */ - extens[ci._remainder].b3); /* rep */ - set_charinfo_remainder(co, 0); - } else { - set_charinfo_remainder(co, ci._remainder); - } - set_charinfo_width(co, widths[ci._width_index]); - set_charinfo_height(co, heights[ci._height_index]); - set_charinfo_depth(co, depths[ci._depth_index]); - set_charinfo_italic(co, italics[ci._italic_index]); - }; - - /* first pass: count ligs and kerns */ - - xligs = xcalloc((ec + 1), sizeof(integer)); - xkerns = xcalloc((ec + 1), sizeof(integer)); - - for (i = bc; i <= ec; i++) { - if (char_tag(f, i) == lig_tag) { - k = lig_kern_start(f, i); - if (skip_byte(k) > stop_flag) - k = lig_kern_restart(k); - /* now k is the start index */ - while (1) { - if (skip_byte(k) <= stop_flag) { - if (op_byte(k) >= kern_flag) { /* kern */ - xkerns[i]++; - if (next_char(k) == bchar) - xkerns[i]++; - } else { /* lig */ - xligs[i]++; - if (next_char(k) == bchar) - xligs[i]++; - } - } - if (skip_byte(k) == 0) { - k++; - } else { - if (skip_byte(k) >= stop_flag) - break; - k += skip_byte(k) + 1; - } - } - } - } - - cligs = NULL; - ckerns = NULL; - - for (i = bc; i <= ec; i++) { - fligs = 0; - fkerns = 0; - if (char_tag(f, i) == lig_tag) { - k = lig_kern_start(f, i); - if (skip_byte(k) > stop_flag) - k = lig_kern_restart(k); - /* now k is the start index */ - if (xligs[i] > 0) - cligs = xcalloc((xligs[i] + 1), sizeof(liginfo)); - if (xkerns[i] > 0) - ckerns = xcalloc((xkerns[i] + 1), sizeof(kerninfo)); - while (1) { - if (skip_byte(k) <= stop_flag) { - if (op_byte(k) >= kern_flag) { /* kern */ - if (next_char(k) == bchar) { - set_kern_item(ckerns[fkerns], right_boundarychar, - kerns[256 * (op_byte(k) - 128) + - rem_byte(k)]); - fkerns++; - } - set_kern_item(ckerns[fkerns], next_char(k), - kerns[256 * (op_byte(k) - 128) + - rem_byte(k)]); - fkerns++; - } else { /* lig */ - if (next_char(k) == bchar) { - set_ligature_item(cligs[fligs], - (op_byte(k) * 2 + 1), - right_boundarychar, rem_byte(k)); - fligs++; - } - set_ligature_item(cligs[fligs], (op_byte(k) * 2 + 1), - next_char(k), rem_byte(k)); - fligs++; - } - } - if (skip_byte(k) == 0) { - k++; - } else { - if (skip_byte(k) >= stop_flag) - break; - k += skip_byte(k) + 1; - } - } - if (fkerns > 0 || fligs > 0) { - co = get_charinfo(f, i); - if (fkerns > 0) { - set_kern_item(ckerns[fkerns], end_kern, 0); - fkerns++; - set_charinfo_kerns(co, ckerns); - } - if (fligs > 0) { - set_ligature_item(cligs[fligs], 0, end_ligature, 0); - fligs++; - set_charinfo_ligatures(co, cligs); - } - set_charinfo_remainder(co, 0); - } - } - } - - - /* @ */ - - /* Now to wrap it up, we have checked all the necessary things about the \.{TFM} - file, and all we need to do is put the finishing touches on the data for - the new font. - */ - - if (bchar != 65536) { - co = copy_charinfo(char_info(f, bchar)); - set_right_boundary(f, co); - } - - tfm_success; -} diff --git a/Build/source/texk/web2c/luatexdir/font/tfmofm.w b/Build/source/texk/web2c/luatexdir/font/tfmofm.w new file mode 100644 index 00000000000..842af38b405 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/tfmofm.w @@ -0,0 +1,1117 @@ +% tfmofm.w +% +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" + +static const char _svn_version[] = + "$Id: tfmofm.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/tfmofm.w $"; + +@ Here are some macros that help process ligatures and kerns +@c +#define lig_kern_start(f,c) char_remainder(f,c) +#define stop_flag 128 /* value indicating `\.{STOP}' in a lig/kern program */ +#define kern_flag 128 /* op code for a kern step */ + +#define skip_byte(z) lig_kerns[z].b0 +#define next_char(z) lig_kerns[z].b1 +#define op_byte(z) lig_kerns[z].b2 +#define rem_byte(z) lig_kerns[z].b3 +#define lig_kern_restart(c) (256*op_byte(c)+rem_byte(c)) + + +@ +The information in a \.{TFM} file appears in a sequence of 8-bit bytes. +Since the number of bytes is always a multiple of 4, we could +also regard the file as a sequence of 32-bit words, but \TeX\ uses the +byte interpretation. The format of \.{TFM} files was designed by +Lyle Ramshaw in 1980. The intent is to convey a lot of different kinds +@^Ramshaw, Lyle Harold@> +of information in a compact but useful form. + +$\Omega$ is capable of reading not only \.{TFM} files, but also +\.{OFM} files, which can describe fonts with up to 65536 characters +and with huge lig/kern tables. These fonts will often be virtual +fonts built up from real fonts with 256 characters, but $\Omega$ +is not aware of this. + +The documentation below describes \.{TFM} files, with slight additions +to show where \.{OFM} files differ. + +@ +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: +$$\vbox{\halign{\hfil#&$\null=\null$#\hfil\cr +|lf|&length of the entire file, in words;\cr +|lh|&length of the header data, in words;\cr +|bc|&smallest character code in the font;\cr +|ec|&largest character code in the font;\cr +|nw|&number of words in the width table;\cr +|nh|&number of words in the height table;\cr +|nd|&number of words in the depth table;\cr +|ni|&number of words in the italic correction table;\cr +|nl|&number of words in the lig/kern table;\cr +|nk|&number of words in the kern table;\cr +|ne|&number of words in the extensible character table;\cr +|np|&number of font parameter words.\cr}}$$ +They are all nonnegative and less than $2^{15}$. We must have |bc-1<=ec<=255|, +and +$$\hbox{|lf=6+lh+(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np|.}$$ +Note that a \.{TFM} font may contain as many as 256 characters +(if |bc=0| and |ec=255|), and as few as 0 characters (if |bc=ec+1|). + +Incidentally, 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. +@!@^BigEndian order@> + +The first 52 bytes (13 words) of an \.{OFM} file contains thirteen +32-bit integers that give the lengths of the various subsequent +portions of the file. The first word is 0 (future versions of +\.{OFM} files could have different values; what is important is that +the first two bytes be 0 to differentiate \.{TFM} and \.{OFM} files). +The next twelve integers are as above, all nonegative and less +than~$2^{31}$. We must have |bc-1<=ec<=65535|, and +$$\hbox{|lf=13+lh+2*(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np|.}$$ +Note that an \.{OFM} font may contain as many as 65536 characters +(if |bc=0| and |ec=65535|), and as few as 0 characters (if |bc=ec+1|). + +The rest of the \.{TFM} file may be regarded as a sequence of ten data +arrays having the informal specification +$$\def\arr$[#1]#2${\&{array} $[#1]$ \&{of} #2} +\def\doarr\PB#1{\arr#1} +\vbox{\halign{\hfil\\{#}&$\,:\,$\doarr#\hfil\cr +header&|[0..lh-1]stuff|\cr +char\_info&|[bc..ec]char_info_word|\cr +width&|[0..nw-1]fix_word|\cr +height&|[0..nh-1]fix_word|\cr +depth&|[0..nd-1]fix_word|\cr +italic&|[0..ni-1]fix_word|\cr +lig\_kern&|[0..nl-1]lig_kern_command|\cr +kern&|[0..nk-1]fix_word|\cr +exten&|[0..ne-1]extensible_recipe|\cr +param&\omit |[1..np]fix_word|\cr}}$$ +The most important data type used here is a |@!fix_word|, which is +a 32-bit representation of a binary fraction. A |fix_word| is a signed +quantity, with the two's complement of the entire word used to represent +negation. Of the 32 bits in a |fix_word|, exactly 12 are to the left of the +binary point; thus, the largest |fix_word| value is $2048-2^{-20}$, and +the smallest is $-2048$. We will see below, however, that all but two of +the |fix_word| values must lie between $-16$ and $+16$. + +The first data array is a block of header information, which contains +general facts about the font. The header must contain at least two words, +|header[0]| and |header[1]|, whose meaning is explained below. +Additional header information of use to other software routines might +also be included, but \TeX82 does not need to know about such details. +For example, 16 more words of header information are in use at the Xerox +Palo Alto Research Center; the first ten specify the character coding +scheme used (e.g., `\.{XEROX text}' or `\.{TeX math symbols}'), the next five +give the font identifier (e.g., `\.{HELVETICA}' or `\.{CMSY}'), and the +last gives the ``face byte.'' The program that converts \.{DVI} files +to Xerox printing format gets this information by looking at the \.{TFM} +file, which it needs to read anyway because of other information that +is not explicitly repeated in \.{DVI}~format. + +\yskip\hang|header[0]| is a 32-bit check sum that \TeX\ will copy into +the \.{DVI} output file. Later on when the \.{DVI} file is printed, +possibly on another computer, the actual font that gets used is supposed +to have a check sum that agrees with the one in the \.{TFM} file used by +\TeX. In this way, users will be warned about potential incompatibilities. +(However, if the check sum is zero in either the font file or the \.{TFM} +file, no check is made.) The actual relation between this check sum and +the rest of the \.{TFM} file is not important; the check sum is simply an +identification number with the property that incompatible fonts almost +always have distinct check sums. +@^check sum@> + +\yskip\hang|header[1]| is a |fix_word| containing the design size of +the font, in units of \TeX\ points. This number must be at least 1.0; it is +fairly arbitrary, but usually the design size is 10.0 for a ``10 point'' +font, i.e., a font that was designed to look best at a 10-point size, +whatever that really means. When a \TeX\ user asks for a font +`\.{at} $\delta$ \.{pt}', the effect is to override the design size +and replace it by $\delta$, and to multiply the $x$ and~$y$ coordinates +of the points in the font image by a factor of $\delta$ divided by the +design size. {\sl All other dimensions in the\/ \.{TFM} file are +|fix_word|\kern-1pt\ numbers in design-size units}, with the exception of +|param[1]| (which denotes the slant ratio). Thus, for example, the value +of |param[6]|, which defines the \.{em} unit, is often the |fix_word| value +$2^{20}=1.0$, since many fonts have a design size equal to one em. +The other dimensions must be less than 16 design-size units in absolute +value; thus, |header[1]| and |param[1]| are the only |fix_word| +entries in the whole \.{TFM} file whose first byte might be something +besides 0 or 255. + +Next comes the |char_info| array, which contains one |@!char_info_word| +per character. Each word in this part of a \.{TFM} file contains six fields +packed into four bytes as follows. + +\yskip\hang first byte: |@!width_index| (8 bits)\par +\hang second byte: |@!height_index| (4 bits) times 16, plus |@!depth_index| + (4~bits)\par +\hang third byte: |@!italic_index| (6 bits) times 4, plus |@!tag| + (2~bits)\par +\hang fourth byte: |@!remainder| (8 bits)\par +\yskip\noindent +The actual width of a character is \\{width}|[width_index]|, in design-size +units; this is a device for compressing information, since many characters +have the same width. Since it is quite common for many characters +to have the same height, depth, or italic correction, the \.{TFM} format +imposes a limit of 16 different heights, 16 different depths, and +64 different italic corrections. + +For \.{OFM} files, two words (eight bytes) are used. +The arrangement is as follows. + +\yskip\hang first and second bytes: |@!width_index| (16 bits)\par +\hang third byte: |@!height_index| (8 bits)\par +\hang fourth byte: |@!depth_index| (8~bits)\par +\hang fifth and sixth bytes: +|@!italic_index| (14 bits) times 4, plus |@!tag| (2~bits)\par +\hang seventh and eighth bytes: |@!remainder| (16 bits)\par +\yskip\noindent +Therefore the \.{OFM} format imposes a limit of 256 different heights, +256 different depths, and 16384 different italic corrections. + +@!@^italic correction@> +The italic correction of a character has two different uses. +(a)~In ordinary text, the italic correction is added to the width only if +the \TeX\ user specifies `\.{\\/}' after the character. +(b)~In math formulas, the italic correction is always added to the width, +except with respect to the positioning of subscripts. + +Incidentally, the relation $\\{width}[0]=\\{height}[0]=\\{depth}[0]= +\\{italic}[0]=0$ should always hold, so that an index of zero implies a +value of zero. The |width_index| should never be zero unless the +character does not exist in the font, since a character is valid if and +only if it lies between |bc| and |ec| and has a nonzero |width_index|. + + +@ \TeX\ checks the information of a \.{TFM} file for validity as the +file is being read in, so that no further checks will be needed when +typesetting is going on. The somewhat tedious subroutine that does this +is called |read_font_info|. It has four parameters: the user font +identifier~|u|, the file name and area strings |nom| and |aire|, and the +``at'' size~|s|. If |s|~is negative, it's the negative of a scale factor +to be applied to the design size; |s=-1000| is the normal case. +Otherwise |s| will be substituted for the design size; in this +case, |s| must be positive and less than $2048\rm\,pt$ +(i.e., it must be less than $2^{27}$ when considered as an integer). + +The subroutine opens and closes a global file variable called |tfm_file|. +It returns the value of the internal font number that was just loaded. +If an error is detected, an error message is issued and no font +information is stored; |null_font| is returned in this case. + +@ +The |tag| field in a |char_info_word| has four values that explain how to +interpret the |remainder| field. + +\yskip\hang|tag=0| (|no_tag|) means that |remainder| is unused.\par +\hang|tag=1| (|lig_tag|) means that this character has a ligature/kerning +program starting at position |remainder| in the |lig_kern| array.\par +\hang|tag=2| (|list_tag|) means that this character is part of a chain of +characters of ascending sizes, and not the largest in the chain. The +|remainder| field gives the character code of the next larger character.\par +\hang|tag=3| (|ext_tag|) means that this character code represents an +extensible character, i.e., a character that is built up of smaller pieces +so that it can be made arbitrarily large. The pieces are specified in +|@!exten[remainder]|.\par +\yskip\noindent +Characters with |tag=2| and |tag=3| are treated as characters with |tag=0| +unless they are used in special circumstances in math formulas. For example, +the \.{\\sum} operation looks for a |list_tag|, and the \.{\\left} +operation looks for both |list_tag| and |ext_tag|. + + +@ The |lig_kern| array contains instructions in a simple programming language +that explains what to do for special letter pairs. Each word in this array, +in a \.{TFM} file, is a |@!lig_kern_command| of four bytes. + +\yskip\hang first byte: |skip_byte|, indicates that this is the final program + step if the byte is 128 or more, otherwise the next step is obtained by + skipping this number of intervening steps.\par +\hang second byte: |next_char|, ``if |next_char| follows the current character, + then perform the operation and stop, otherwise continue.''\par +\hang third byte: |op_byte|, indicates a ligature step if less than~128, + a kern step otherwise.\par +\hang fourth byte: |remainder|.\par +\yskip\noindent +In an \.{OFM} file, eight bytes are used, two bytes for each field. + +In a kern step, an +additional space equal to |kern[256*(op_byte-128)+remainder]| is inserted +between the current character and |next_char|. This amount is +often negative, so that the characters are brought closer together +by kerning; but it might be positive. + +There are eight kinds of ligature steps, having |op_byte| codes $4a+2b+c$ where +$0\le a\le b+c$ and $0\le b,c\le1$. The character whose code is +|remainder| is inserted between the current character and |next_char|; +then the current character is deleted if $b=0$, and |next_char| is +deleted if $c=0$; then we pass over $a$~characters to reach the next +current character (which may have a ligature/kerning program of its own). + +If the very first instruction of the |lig_kern| array has |skip_byte=255|, +the |next_char| byte is the so-called right boundary character of this font; +the value of |next_char| need not lie between |bc| and~|ec|. +If the very last instruction of the |lig_kern| array has |skip_byte=255|, +there is a special ligature/kerning program for a left boundary character, +beginning at location |256*op_byte+remainder|. +The interpretation is that \TeX\ puts implicit boundary characters +before and after each consecutive string of characters from the same font. +These implicit characters do not appear in the output, but they can affect +ligatures and kerning. + +If the very first instruction of a character's |lig_kern| program has +|skip_byte>128|, the program actually begins in location +|256*op_byte+remainder|. This feature allows access to large |lig_kern| +arrays, because the first instruction must otherwise +appear in a location |<=255| in a \.{TFM} file, |<=65535| in an \.{OFM} file. + +Any instruction with |skip_byte>128| in the |lig_kern| array must satisfy +the condition +$$\hbox{|256*op_byte+remainder=0|, unless $M$ is absent; +in the latter case we can have $TR^kB$ for both even and odd values of~|k|. +The width of the extensible character is the width of $R$; and the +height-plus-depth is the sum of the individual height-plus-depths of the +components used, since the pieces are butted together in a vertical list. + + +@ +The final portion of a \.{TFM} file is the |param| array, which is another +sequence of |fix_word| values. + +\yskip\hang|param[1]=slant| is the amount of italic slant, which is used +to help position accents. For example, |slant=.25| means that when you go +up one unit, you also go .25 units to the right. The |slant| is a pure +number; it's the only |fix_word| other than the design size itself that is +not scaled by the design size. + +\hang|param[2]=space| is the normal spacing between words in text. +Note that character |" "| in the font need not have anything to do with +blank spaces. + +\hang|param[3]=space_stretch| is the amount of glue stretching between words. + +\hang|param[4]=space_shrink| is the amount of glue shrinking between words. + +\hang|param[5]=x_height| is the size of one ex in the font; it is also +the height of letters for which accents don't have to be raised or lowered. + +\hang|param[6]=quad| is the size of one em in the font. + +\hang|param[7]=extra_space| is the amount added to |param[2]| at the +ends of sentences. + +\yskip\noindent +If fewer than seven parameters are present, \TeX\ sets the missing parameters +to zero. Fonts used for math symbols are required to have +additional parameter information, which is explained later. + + +@ + There are programs called \.{TFtoPL} and \.{PLtoTF} that convert + between the \.{TFM} format and a symbolic property-list format + that can be easily edited. These programs contain extensive + diagnostic information, so \TeX\ does not have to bother giving + precise details about why it rejects a particular \.{TFM} file. + +@c +#define tfm_abort { font_tables[f]->_font_name = NULL; \ + font_tables[f]->_font_area = NULL; \ + xfree(tfm_buffer); xfree(kerns); \ + xfree(widths); xfree(heights); xfree(depths); \ + xfree(italics); xfree(extens); xfree(lig_kerns); \ + xfree(xligs); xfree(xkerns); \ + return 0; } + +#define tfm_success { xfree(tfm_buffer); xfree(kerns); \ + xfree(widths); xfree(heights); xfree(depths); \ + xfree(italics); xfree(extens); xfree(lig_kerns); \ + xfree(xligs); xfree(xkerns); return 1; } + +@ @c +static int open_tfm_file(const char *nom, unsigned char **tfm_buf, int *tfm_siz) +{ + boolean res; /* was the callback successful? */ + boolean opened; /* was |tfm_file| successfully opened? */ + int callback_id; + FILE *tfm_file; + char *fname = luatex_find_file(nom, find_font_file_callback); + if (!fname) + return -1; + callback_id = callback_defined(read_font_file_callback); + if (callback_id > 0) { + res = + run_callback(callback_id, "S->bSd", fname, &opened, tfm_buf, + tfm_siz); + if (res && opened && (*tfm_siz > 0)) { + return 1; + } + if (!opened) + return -1; + } else { + if (luatex_open_input + (&(tfm_file), fname, kpse_ofm_format, FOPEN_RBIN_MODE, true)) { + res = read_tfm_file(tfm_file, tfm_buf, tfm_siz); + close_file(tfm_file); + if (res) { + return 1; + } + } else { + return -1; + } + } + return 0; +} + + +@ + Note: A malformed \.{TFM} file might be shorter than it claims to be; + thus |eof(tfm_file)| might be true when |read_font_info| refers to + |tfm_file^| or when it says |get(tfm_file)|. If such circumstances + cause system error messages, you will have to defeat them somehow, + for example by defining |fget| to be `\ignorespaces|begin get(tfm_file);| + |if eof(tfm_file) then abort; end|\unskip'. + @^system dependencies@> +@c + +#define fget tfm_byte++ +#define fbyte tfm_buffer[tfm_byte] + +#define read_sixteen(a) \ + { a=tfm_buffer[tfm_byte++]; \ + if (a>127) { tfm_abort; } \ + a=(a*256)+tfm_buffer[tfm_byte]; } + +#define read_sixteen_unsigned(a) \ + { a=tfm_buffer[tfm_byte++]; \ + a=(a*256)+tfm_buffer[tfm_byte]; } + +#define read_thirtytwo(a) \ + { a=tfm_buffer[++tfm_byte]; \ + if (a>127) { tfm_abort; } \ + a=(a*256)+tfm_buffer[++tfm_byte]; \ + a=(a*256)+tfm_buffer[++tfm_byte]; \ + a=(a*256)+tfm_buffer[++tfm_byte]; } + +#define store_four_bytes(z) \ + { a=tfm_buffer[++tfm_byte]; \ + a=(a*256)+tfm_buffer[++tfm_byte]; \ + a=(a*256)+tfm_buffer[++tfm_byte]; \ + a=(a*256)+tfm_buffer[++tfm_byte]; \ + z = a; } + +#define store_char_info(z) \ + { if (font_level!=-1) { \ + fget; read_sixteen_unsigned(a); \ + ci._width_index=a; \ + fget; read_sixteen_unsigned(b); \ + ci._height_index=b>>8; \ + ci._depth_index=b%256; \ + fget; read_sixteen_unsigned(c); \ + ci._italic_index=c>>8; \ + ci._tag=(unsigned char)(c%4); \ + fget; read_sixteen_unsigned(d); \ + ci._remainder=d; \ + } else { \ + a=tfm_buffer[++tfm_byte]; \ + ci._width_index=a; \ + b=tfm_buffer[++tfm_byte]; \ + ci._height_index=b>>4; \ + ci._depth_index=b%16; \ + c=tfm_buffer[++tfm_byte]; \ + ci._italic_index=c>>2; \ + ci._tag=(unsigned char)(c%4); \ + d=tfm_buffer[++tfm_byte]; \ + ci._remainder=d; \ + } } + +#define read_four_quarters(q) \ + { if (font_level!=-1) { \ + fget; read_sixteen_unsigned(a); q.b0=(quarterword)a; \ + fget; read_sixteen_unsigned(b); q.b1=(quarterword)b; \ + fget; read_sixteen_unsigned(c); q.b2=(quarterword)c; \ + fget; read_sixteen_unsigned(d); q.b3=(quarterword)d; \ + } else { \ + a=tfm_buffer[++tfm_byte]; q.b0=(quarterword)a; \ + b=tfm_buffer[++tfm_byte]; q.b1=(quarterword)b; \ + c=tfm_buffer[++tfm_byte]; q.b2=(quarterword)c; \ + d=tfm_buffer[++tfm_byte]; q.b3=(quarterword)d; \ + } } + +#define check_byte_range(z) { if ((zec)) tfm_abort ; } + + +@ A |fix_word| whose four bytes are $(a,b,c,d)$ from left to right represents + the number + $$x=\left\{\vcenter{\halign{$#$,\hfil\qquad&if $#$\hfil\cr + b\cdot2^{-4}+c\cdot2^{-12}+d\cdot2^{-20}&a=0;\cr + -16+b\cdot2^{-4}+c\cdot2^{-12}+d\cdot2^{-20}&a=255.\cr}}\right.$$ + (No other choices of |a| are allowed, since the magnitude of a number in + design-size units must be less than 16.) We want to multiply this + quantity by the integer~|z|, which is known to be less than $2^{27}$. + If $|z|<2^{23}$, the individual multiplications $b\cdot z$, + $c\cdot z$, $d\cdot z$ cannot overflow; otherwise we will divide |z| by 2, + 4, 8, or 16, to obtain a multiplier less than $2^{23}$, and we can + compensate for this later. If |z| has thereby been replaced by + $|z|^\prime=|z|/2^e$, let $\beta=2^{4-e}$; we shall compute + $$\lfloor(b+c\cdot2^{-8}+d\cdot2^{-16})\,z^\prime/\beta\rfloor$$ + if $a=0$, or the same quantity minus $\alpha=2^{4+e}z^\prime$ if $a=255$. + This calculation must be done exactly, in order to guarantee portability + of \TeX\ between computers. + +@c +#define store_scaled(zz) \ + { fget; a=fbyte; fget; b=fbyte; \ + fget; c=fbyte; fget; d=fbyte; \ + sw=(((((d*z)>>8)+(c*z))>>8)+(b*z)) / beta; \ + if (a==0) { zz=sw; } else if (a==255) { zz=sw-alpha; } else tfm_abort; \ + } + +scaled store_scaled_f(scaled sq, scaled z_in) +{ + eight_bits a, b, c, d; + scaled sw; + static int alpha, beta; /* beta:1..16 */ + static scaled z, z_prev = 0; + /* Replace |z| by $|z|^\prime$ and compute $\alpha,\beta$ */ + if (z_in != z_prev || z_prev == 0) { + z = z_prev = z_in; + alpha = 16; + while (z >= 0x800000) { + z /= 2; + alpha += alpha; + } + beta = 256 / alpha; + alpha *= z; + }; + if (sq >= 0) { + d = (eight_bits) (sq % 256); + sq = sq / 256; + c = (eight_bits) (sq % 256); + sq = sq / 256; + b = (eight_bits) (sq % 256); + sq = sq / 256; + a = (eight_bits) (sq % 256); + } else { + sq = (sq + 1073741824) + 1073741824; /* braces for optimizing compiler */ + d = (eight_bits) (sq % 256); + sq = sq / 256; + c = (eight_bits) (sq % 256); + sq = sq / 256; + b = (eight_bits) (sq % 256); + sq = sq / 256; + a = (eight_bits) ((sq + 128) % 256); + } + sw = (((((d * z) >> 8) + (c * z)) >> 8) + (b * z)) / beta; + if (a == 0) + return sw; + else if (a == 255) + return (sw - alpha); + else + pdf_error("vf", "vf scaling"); + return sw; /* not reached, just to make the compiler happy */ +} + +@ @c +#define check_existence(z) \ + { check_byte_range(z); \ + if (!char_exists(f,z)) tfm_abort; \ + } + +typedef struct tfmcharacterinfo { + int _kern_index; + int _lig_index; + int _width_index; + int _height_index; + int _depth_index; + int _italic_index; + int _remainder; + unsigned char _tag; +} tfmcharacterinfo; + +@ @c +int read_tfm_info(internal_font_number f, const char *cnom, scaled s) +{ + int k; /* index into |font_info| */ + halfword lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np, slh; /* sizes of subfiles */ + scaled *widths, *heights, *depths, *italics, *kerns; + halfword font_dir; + int a, b, c, d; /* byte variables */ + int i; /* counter */ + int font_level, header_length; + int nco, ncw, npc, nlw, neew; + tfmcharacterinfo ci; + charinfo *co; + four_quarters qw; + four_quarters *lig_kerns, *extens; + scaled sw; /* accumulators */ + int bch_label; /* left boundary start location, or infinity */ + int bchar; /* |:0..too_big_char;| *//* right boundary character, or |too_big_char| */ + int first_two; + scaled z; /* the design size or the ``at'' size */ + int alpha; + char beta; /* :1..16 */ + int *xligs, *xkerns; /* aux. for ligkern processing */ + liginfo *cligs; + kerninfo *ckerns; + int fligs, fkerns; + char *tmpnam; + int tfm_byte = 0; /* index into |tfm_buffer| */ + int saved_tfm_byte = 0; /* saved index into |tfm_buffer| */ + unsigned char *tfm_buffer = NULL; /* byte buffer for tfm files */ + int tfm_size = 0; /* total size of the tfm file */ + int tmp; + + widths = NULL; + heights = NULL; + depths = NULL; + italics = NULL; + kerns = NULL; + lig_kerns = NULL; + extens = NULL; + xkerns = NULL; + ckerns = NULL; + xligs = NULL; + cligs = NULL; + + font_dir = 0; + + memset(&ci, 0, sizeof(tfmcharacterinfo)); + + if (open_tfm_file(cnom, &tfm_buffer, &tfm_size) != 1) + tfm_abort; + + /* cnom can be an absolute filename, xbasename() fixes that. */ + + tmpnam = strdup(xbasename(cnom)); + if (strcmp(tmpnam + strlen(tmpnam) - 4, ".tfm") == 0) { + *(tmpnam + strlen(tmpnam) - 4) = 0; + } + set_font_name(f, tmpnam); + set_font_area(f, NULL); + + /* Read the {\.{TFM}} size fields */ + nco = 0; + ncw = 0; + npc = 0; + read_sixteen(first_two); + if (first_two != 0) { + font_level = -1; + lf = first_two; + fget; + read_sixteen(lh); + fget; + read_sixteen(bc); + fget; + read_sixteen(ec); + if ((bc > ec + 1) || (ec > 255)) + tfm_abort; + if (bc > 255) { /* |bc=256| and |ec=255| */ + bc = 1; + ec = 0; + }; + fget; + read_sixteen(nw); + fget; + read_sixteen(nh); + fget; + read_sixteen(nd); + fget; + read_sixteen(ni); + fget; + read_sixteen(nl); + fget; + read_sixteen(nk); + fget; + read_sixteen(ne); + fget; + read_sixteen(np); + header_length = 6; + ncw = (ec - bc + 1); + nlw = nl; + neew = ne; + } else { + fget; + read_sixteen(font_level); + if (font_level != 0) + tfm_abort; + read_thirtytwo(lf); + read_thirtytwo(lh); + read_thirtytwo(bc); + read_thirtytwo(ec); + if ((bc > ec + 1) || (ec > 65535)) + tfm_abort; + if (bc > 65535) { /* |bc=65536| and |ec=65535| */ + bc = 1; + ec = 0; + }; + read_thirtytwo(nw); + read_thirtytwo(nh); + read_thirtytwo(nd); + read_thirtytwo(ni); + read_thirtytwo(nl); + read_thirtytwo(nk); + read_thirtytwo(ne); + read_thirtytwo(np); + read_thirtytwo(font_dir); /* junk */ + nlw = 2 * nl; + neew = 2 * ne; + header_length = 14; + ncw = 2 * (ec - bc + 1); + }; + if (lf != + (header_length + lh + ncw + nw + nh + nd + ni + nlw + nk + neew + np)) + tfm_abort; + if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0)) + tfm_abort; + + /* + We check to see that the \.{TFM} file doesn't end prematurely; but + no error message is given for files having more than |lf| words. + */ + if (lf * 4 > tfm_size) + tfm_abort; + + /* Use size fields to allocate font information */ + + set_font_natural_dir(f, font_dir); + set_font_bc(f, bc); + set_font_ec(f, ec); + + /* read the arrays first */ + widths = xmalloc((unsigned) ((unsigned) nw * sizeof(scaled))); + heights = xmalloc((unsigned) ((unsigned) nh * sizeof(scaled))); + depths = xmalloc((unsigned) ((unsigned) nd * sizeof(scaled))); + italics = xmalloc((unsigned) ((unsigned) ni * sizeof(scaled))); + extens = xmalloc((unsigned) ((unsigned) ne * sizeof(four_quarters))); + lig_kerns = xmalloc((unsigned) ((unsigned) nl * sizeof(four_quarters))); + kerns = xmalloc((unsigned) ((unsigned) nk * sizeof(scaled))); + + /* Read the {\.{TFM}} header */ + + /* Only the first two words of the header are needed by \TeX82. */ + slh = lh; + if (lh < 2) + tfm_abort; + store_four_bytes(tmp); + font_checksum(f) = (unsigned) tmp; + fget; + read_sixteen(z); /* this rejects a negative design size */ + fget; + z = z * 256 + fbyte; + fget; + z = (z * 16) + (fbyte >> 4); + if (z < unity) + tfm_abort; + while (lh > 2) { + fget; + fget; + fget; + fget; + lh--; /* ignore the rest of the header */ + }; + + /* read the arrays before the character info */ + + set_font_dsize(f, z); + if (s != -1000) { + z = (s >= 0 ? s : xn_over_d(z, -s, 1000)); + } + set_font_size(f, z); + + if (np > 7) + set_font_params(f, np); + + saved_tfm_byte = tfm_byte; + tfm_byte = (header_length + slh + ncw) * 4 - 1; + + /* Replace |z| by $|z|^\prime$ and compute $\alpha,\beta$ */ + + alpha = 16; + while (z >= 040000000) { + z = z >> 1; + alpha = alpha + alpha; + }; + beta = (char) (256 / alpha); + alpha = alpha * z; + + /* Read box dimensions */ + + for (k = 0; k < nw; k++) { + store_scaled(sw); + widths[k] = sw; + } + if (widths[0] != 0) /* \\{width}[0] must be zero */ + tfm_abort; + for (k = 0; k < nh; k++) { + store_scaled(sw); + heights[k] = sw; + } + if (heights[0] != 0) + tfm_abort; /* \\{height}[0] must be zero */ + for (k = 0; k < nd; k++) { + store_scaled(sw); + depths[k] = sw; + } + if (depths[0] != 0) + tfm_abort; /* \\{depth}[0] must be zero */ + for (k = 0; k < ni; k++) { + store_scaled(sw); + italics[k] = sw; + } + if (italics[0] != 0) + tfm_abort; /* \\{italic}[0] must be zero */ + + + /* Read ligature/kern program */ + + bch_label = nl; /* infinity */ + bchar = 65536; + if (nl > 0) { + for (k = 0; k < nl; k++) { + read_four_quarters(qw); + lig_kerns[k] = qw; + if (a > 128) { + if (256 * c + d >= nl) + tfm_abort; + if (a == 255 && k == 0) + bchar = b; + } else { +#if 0 + if (b!=bchar) check_existence(b); +#endif + if (c < 128) { +#if 0 + check_existence(d); /* check ligature */ +#endif + } else if (256 * (c - 128) + d >= nk) { + tfm_abort; /* check kern */ + } + if ((a < 128) && (k - 0 + a + 1 >= nl)) + tfm_abort; + }; + }; + if (a == 255) + bch_label = 256 * c + d; + }; + + /* the actual kerns */ + for (k = 0; k < nk; k++) { + store_scaled(sw); + kerns[k] = sw; + } + + /* Read extensible character recipes */ + for (k = 0; k < ne; k++) { + read_four_quarters(qw); + extens[k] = qw; + } + + /* Read font parameters */ + + if (np > 7) { + set_font_params(f, np); + } + for (k = 1; k <= np; k++) { + if (k == 1) { /* the |slant| parameter is a pure number */ + fget; + sw = fbyte; + if (sw > 127) + sw = sw - 256; + fget; + sw = sw * 256 + fbyte; + fget; + sw = sw * 256 + fbyte; + fget; + sw = (sw * 16) + (fbyte >> 4); + set_font_param(f, k, sw); + } else { + store_scaled(font_param(f, k)); + } + } + + tfm_byte = saved_tfm_byte; + + /* fix up the left boundary character */ + fligs = 0; + fkerns = 0; + if (bch_label != nl) { + k = bch_label; +#if 0 + if (skip_byte(k) > stop_flag) + k = lig_kern_restart(k); +#endif + while (1) { + if (skip_byte(k) <= stop_flag) { + if (op_byte(k) >= kern_flag) { /* kern */ + fkerns++; + } else { /* lig */ + fligs++; + } + } + if (skip_byte(k) == 0) { + k++; + } else { + if (skip_byte(k) >= stop_flag) + break; + k += skip_byte(k) + 1; + } + } + } + if (fkerns > 0 || fligs > 0) { + if (fligs > 0) + cligs = xcalloc((unsigned) (fligs + 1), sizeof(liginfo)); + if (fkerns > 0) + ckerns = xcalloc((unsigned) (fkerns + 1), sizeof(kerninfo)); + fligs = 0; + fkerns = 0; + k = bch_label; +#if 0 + if (skip_byte(k) > stop_flag) + k = lig_kern_restart(k); +#endif + while (1) { + if (skip_byte(k) <= stop_flag) { + if (op_byte(k) >= kern_flag) { /* kern */ + set_kern_item(ckerns[fkerns], next_char(k), + kerns[256 * (op_byte(k) - 128) + + rem_byte(k)]); + fkerns++; + } else { /* lig */ + set_ligature_item(cligs[fligs], (char) (op_byte(k) * 2 + 1), + next_char(k), rem_byte(k)); + fligs++; + } + } + if (skip_byte(k) == 0) { + k++; + } else { + if (skip_byte(k) >= stop_flag) + break; + k += skip_byte(k) + 1; + } + } + if (fkerns > 0 || fligs > 0) { + co = get_charinfo(f, left_boundarychar); + if (fkerns > 0) { + set_kern_item(ckerns[fkerns], end_kern, 0); + fkerns++; + set_charinfo_kerns(co, ckerns); + } + if (fligs > 0) { + set_ligature_item(cligs[fligs], 0, end_ligature, 0); + fligs++; + set_charinfo_ligatures(co, cligs); + } + set_charinfo_remainder(co, 0); + } + } + + /* Read character data */ + for (k = bc; k <= ec; k++) { + store_char_info(k); + if (ci._width_index == 0) + continue; + if (ci._width_index >= nw || ci._height_index >= nh || + ci._depth_index >= nd || ci._italic_index >= ni) + tfm_abort; + d = ci._remainder; + switch (ci._tag) { + case lig_tag: + if (d >= nl) + tfm_abort; + break; + case ext_tag: + if (d >= ne) + tfm_abort; + break; + case list_tag: + /* We want to make sure that there is no cycle of characters linked together + by |list_tag| entries, since such a cycle would get \TeX\ into an endless + loop. If such a cycle exists, the routine here detects it when processing + the largest character code in the cycle. + */ + check_byte_range(d); + while (d < k) { /* |current_character == k| */ + if (char_tag(f, d) != list_tag) + goto NOT_FOUND; /* not a cycle */ + d = char_remainder(f, d); /* next character on the list */ + }; + if (d == k) + tfm_abort; /* yes, there's a cycle */ + NOT_FOUND: + break; + } + /* put it in the actual font */ + co = get_charinfo(f, k); + set_charinfo_index(co, k); + set_charinfo_tag(co, ci._tag); + if (ci._tag == ext_tag) { + set_charinfo_extensible(co, extens[ci._remainder].b0, /* top */ + extens[ci._remainder].b2, /* bot */ + extens[ci._remainder].b1, /* mid */ + extens[ci._remainder].b3); /* rep */ + set_charinfo_remainder(co, 0); + } else { + set_charinfo_remainder(co, ci._remainder); + } + set_charinfo_width(co, widths[ci._width_index]); + set_charinfo_height(co, heights[ci._height_index]); + set_charinfo_depth(co, depths[ci._depth_index]); + set_charinfo_italic(co, italics[ci._italic_index]); + }; + + /* first pass: count ligs and kerns */ + + xligs = xcalloc((unsigned) (ec + 1), sizeof(int)); + xkerns = xcalloc((unsigned) (ec + 1), sizeof(int)); + + for (i = bc; i <= ec; i++) { + if (char_tag(f, i) == lig_tag) { + k = lig_kern_start(f, i); + if (skip_byte(k) > stop_flag) + k = lig_kern_restart(k); + /* now k is the start index */ + while (1) { + if (skip_byte(k) <= stop_flag) { + if (op_byte(k) >= kern_flag) { /* kern */ + xkerns[i]++; + if (next_char(k) == bchar) + xkerns[i]++; + } else { /* lig */ + xligs[i]++; + if (next_char(k) == bchar) + xligs[i]++; + } + } + if (skip_byte(k) == 0) { + k++; + } else { + if (skip_byte(k) >= stop_flag) + break; + k += skip_byte(k) + 1; + } + } + } + } + + cligs = NULL; + ckerns = NULL; + + for (i = bc; i <= ec; i++) { + fligs = 0; + fkerns = 0; + if (char_tag(f, i) == lig_tag) { + k = lig_kern_start(f, i); + if (skip_byte(k) > stop_flag) + k = lig_kern_restart(k); + /* now k is the start index */ + if (xligs[i] > 0) + cligs = xcalloc((unsigned) (xligs[i] + 1), sizeof(liginfo)); + if (xkerns[i] > 0) + ckerns = xcalloc((unsigned) (xkerns[i] + 1), sizeof(kerninfo)); + while (1) { + if (skip_byte(k) <= stop_flag) { + if (op_byte(k) >= kern_flag) { /* kern */ + if (next_char(k) == bchar) { + set_kern_item(ckerns[fkerns], right_boundarychar, + kerns[256 * (op_byte(k) - 128) + + rem_byte(k)]); + fkerns++; + } + set_kern_item(ckerns[fkerns], next_char(k), + kerns[256 * (op_byte(k) - 128) + + rem_byte(k)]); + fkerns++; + } else { /* lig */ + if (next_char(k) == bchar) { + set_ligature_item(cligs[fligs], + (char) (op_byte(k) * 2 + 1), + right_boundarychar, rem_byte(k)); + fligs++; + } + set_ligature_item(cligs[fligs], + (char) (op_byte(k) * 2 + 1), + next_char(k), rem_byte(k)); + fligs++; + } + } + if (skip_byte(k) == 0) { + k++; + } else { + if (skip_byte(k) >= stop_flag) + break; + k += skip_byte(k) + 1; + } + } + if (fkerns > 0 || fligs > 0) { + co = get_charinfo(f, i); + if (fkerns > 0) { + set_kern_item(ckerns[fkerns], end_kern, 0); + fkerns++; + set_charinfo_kerns(co, ckerns); + } + if (fligs > 0) { + set_ligature_item(cligs[fligs], 0, end_ligature, 0); + fligs++; + set_charinfo_ligatures(co, cligs); + } + set_charinfo_remainder(co, 0); + } + } + } + + + /* Make final adjustments and |goto done| */ + + /* Now to wrap it up, we have checked all the necessary things about the \.{TFM} + file, and all we need to do is put the finishing touches on the data for + the new font. + */ + + if (bchar != 65536) { + co = copy_charinfo(char_info(f, bchar)); + set_right_boundary(f, co); + } + + tfm_success; +} diff --git a/Build/source/texk/web2c/luatexdir/font/tounicode.c b/Build/source/texk/web2c/luatexdir/font/tounicode.c deleted file mode 100644 index a4029f5220d..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/tounicode.c +++ /dev/null @@ -1,610 +0,0 @@ -/* tounicode.c - Copyright 2006 Han The Thanh, - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" - -static const char _svn_version[] = - "$Id: tounicode.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/tounicode.c $"; - -#define isXdigit(c) (isdigit(c) || ('A' <= (c) && (c) <= 'F')) -#define UNI_UNDEF -1 -#define UNI_STRING -2 /* string allocated by def_tounicode() */ -#define UNI_EXTRA_STRING -3 /* string allocated by set_glyph_unicode() */ - -static struct avl_table *glyph_unicode_tree = NULL; - -static int comp_glyph_unicode_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(((const glyph_unicode_entry *) pa)->name, - ((const glyph_unicode_entry *) pb)->name); -} - -static glyph_unicode_entry *new_glyph_unicode_entry(void) -{ - glyph_unicode_entry *e; - e = xtalloc(1, glyph_unicode_entry); - e->name = NULL; - e->code = UNI_UNDEF; - e->unicode_seq = NULL; - return e; -} - -static void destroy_glyph_unicode_entry(void *pa, void *pb) -{ - glyph_unicode_entry *e = (glyph_unicode_entry *) pa; - (void) pb; - xfree(e->name); - if (e->code == UNI_STRING) { - assert(e->unicode_seq != NULL); - xfree(e->unicode_seq); - } -} - -void glyph_unicode_free(void) -{ - if (glyph_unicode_tree != NULL) - avl_destroy(glyph_unicode_tree, destroy_glyph_unicode_entry); -} - -void def_tounicode(str_number glyph, str_number unistr) -{ - char buf[SMALL_BUF_SIZE], *p; - char buf2[SMALL_BUF_SIZE], *q; - int valid_unistr; /* 0: invalid; 1: unicode value; 2: string */ - int i, l; - glyph_unicode_entry *gu, t; - void **aa; - - p = makecstring(glyph); - assert(strlen(p) < SMALL_BUF_SIZE); - strcpy(buf, p); /* copy the result to buf before next call of makecstring() */ - p = makecstring(unistr); - while (*p == ' ') - p++; /* ignore leading spaces */ - l = strlen(p); - while (l > 0 && p[l - 1] == ' ') - l--; /* ignore traling spaces */ - valid_unistr = 1; /* a unicode value is the most common case */ - for (i = 0; i < l; i++) { - if (p[i] == ' ') - valid_unistr = 2; /* if a space occurs we treat this entry as a string */ - else if (!isXdigit(p[i])) { - valid_unistr = 0; - break; - } - } - if (l == 0 || valid_unistr == 0 || strlen(buf) == 0 - || strcmp(buf, notdef) == 0) { - pdftex_warn("ToUnicode: invalid parameter(s): `%s' => `%s'", buf, p); - return; - } - if (glyph_unicode_tree == NULL) { - glyph_unicode_tree = - avl_create(comp_glyph_unicode_entry, NULL, &avl_xallocator); - assert(glyph_unicode_tree != NULL); - } - t.name = buf; - /* allow overriding existing entries */ - if ((gu = (glyph_unicode_entry *) avl_find(glyph_unicode_tree, &t)) != NULL) { - if (gu->code == UNI_STRING) { - assert(gu->unicode_seq != NULL); - xfree(gu->unicode_seq); - } - } else { /* make new entry */ - gu = new_glyph_unicode_entry(); - gu->name = xstrdup(buf); - } - if (valid_unistr == 2) { /* a string with space(s) */ - /* copy p to buf2, ignoring spaces */ - for (q = buf2; *p != 0; p++) - if (*p != ' ') - *q++ = *p; - *q = 0; - gu->code = UNI_STRING; - gu->unicode_seq = xstrdup(buf2); - } else { - i = sscanf(p, "%lX", &(gu->code)); - assert(i == 1); - } - aa = avl_probe(glyph_unicode_tree, gu); - assert(aa != NULL); -} - - -static long check_unicode_value(char *s, boolean multiple_value) -{ - int l = strlen(s); - int i; - long code; - - if (l == 0) - return UNI_UNDEF; - if (multiple_value && l % 4 != 0) - return UNI_UNDEF; - if (!multiple_value && !(4 <= l && l <= 6)) - return UNI_UNDEF; - - for (i = 0; i < l; i++) { - if (!isXdigit(s[i])) - return UNI_UNDEF; - if (multiple_value) { - if (i % 4 == 3) { - if (sscanf(s + i - 3, "%4lX", &code) != 1) - return UNI_UNDEF; - if (!((0x0000 <= code && code <= 0xD7FF) || - (0xE000 <= code && code <= 0xFFFF))) - return UNI_UNDEF; - } - } else { /* single value */ - if (i == l - 1) { - if (sscanf(s, "%lX", &code) != 1) - return UNI_UNDEF; - if (!((0x0000 <= code && code <= 0xD7FF) || - (0xE000 <= code && code <= 0x10FFFF))) - return UNI_UNDEF; - } - } - } - return code; -} - -static char *utf16be_str(long code) -{ - static char buf[SMALL_BUF_SIZE]; - long v; - unsigned vh, vl; - - assert(code >= 0); - - if (code <= 0xFFFF) - sprintf(buf, "%04lX", code); - else { - v = code - 0x10000; - vh = v / 0x400 + 0xD800; - vl = v % 0x400 + 0xDC00; - sprintf(buf, "%04X%04X", vh, vl); - } - return buf; -} - - -/* this function set proper values to *gp based on s; in case it returns - * gp->code == UNI_EXTRA_STRING then the caller is responsible for freeing - * gp->unicode_seq too */ -static void set_glyph_unicode(char *s, glyph_unicode_entry * gp) -{ - char buf[SMALL_BUF_SIZE], buf2[SMALL_BUF_SIZE], *p; - long code; - boolean last_component; - glyph_unicode_entry tmp, *ptmp; - - /* skip dummy entries */ - if (s == NULL || s == notdef) - return; - - /* strip everything after the first dot */ - p = strchr(s, '.'); - if (p != NULL) { - *buf = 0; - strncat(buf, s, p - s); - s = buf; - } - - if (strlen(s) == 0) - return; - - /* check for case of multiple components separated by '_' */ - p = strchr(s, '_'); - if (p != NULL) { - assert(strlen(s) < sizeof(buf)); - if (s != buf) { - strcpy(buf, s); - p = strchr(buf, '_'); - s = buf; - } - *buf2 = 0; - last_component = false; - for (;;) { - *p = 0; - tmp.code = UNI_UNDEF; - set_glyph_unicode(s, &tmp); - switch (tmp.code) { - case UNI_UNDEF: /* not found, do nothing */ - break; - case UNI_STRING: /* s matched an entry with string value in the database */ - assert(tmp.unicode_seq != NULL); - assert(strlen(buf2) + strlen(tmp.unicode_seq) < sizeof(buf2)); - strcat(buf2, tmp.unicode_seq); - break; - case UNI_EXTRA_STRING: /* s is a multiple value of form "uniXXXX" */ - assert(strlen(buf2) + strlen(tmp.unicode_seq) < sizeof(buf2)); - strcat(buf2, tmp.unicode_seq); - xfree(tmp.unicode_seq); - break; - default: /* s matched an entry with numeric value in the - database, or a value derived from "uXXXX" */ - assert(tmp.code >= 0); - strcat(buf2, utf16be_str(tmp.code)); - } - if (last_component) - break; - s = p + 1; - p = strchr(s, '_'); - if (p == NULL) { - p = strend(s); - last_component = true; - } - } - gp->code = UNI_EXTRA_STRING; - gp->unicode_seq = xstrdup(buf2); - return; - } - - /* lookup for glyph name in the database */ - tmp.name = s; - tmp.code = UNI_UNDEF; - ptmp = (glyph_unicode_entry *) avl_find(glyph_unicode_tree, &tmp); - if (ptmp != NULL) { - gp->code = ptmp->code; - gp->unicode_seq = ptmp->unicode_seq; - return; - } - - /* check for case of "uniXXXX" (multiple 4-hex-digit values allowed) */ - if (str_prefix(s, "uni")) { - p = s + strlen("uni"); - code = check_unicode_value(p, true); - if (code != UNI_UNDEF) { - if (strlen(p) == 4) /* single value */ - gp->code = code; - else { /* multiple value */ - gp->code = UNI_EXTRA_STRING; - gp->unicode_seq = xstrdup(p); - } - } - return; /* since the last case cannot happen */ - } - - /* check for case of "uXXXX" (single value up to 6 hex digits) */ - if (str_prefix(s, "u")) { - p = s + strlen("u"); - code = check_unicode_value(p, false); - if (code != UNI_UNDEF) { - assert(code >= 0); - gp->code = code; - } - } -} - -static void set_cid_glyph_unicode(long index, glyph_unicode_entry * gp, - internal_font_number f) -{ - char *s; - if (font_tounicode(f) && - (s = get_charinfo_tounicode(char_info(f, index))) != NULL) { - gp->code = UNI_EXTRA_STRING; - gp->unicode_seq = xstrdup(s); - } else { - gp->code = index; /* fallback */ - } -} - - -integer write_tounicode(char **glyph_names, char *name) -{ - char buf[SMALL_BUF_SIZE], *p; - static char builtin_suffix[] = "-builtin"; - short range_size[257]; - glyph_unicode_entry gtab[257]; - integer objnum; - int i, j; - int bfchar_count, bfrange_count, subrange_count; - assert(strlen(name) + strlen(builtin_suffix) < SMALL_BUF_SIZE); - if (glyph_unicode_tree == NULL) { - /*pdftex_warn("no GlyphToUnicode entry has been inserted yet!"); */ - fixed_gen_tounicode = 0; - return 0; - } - strcpy(buf, name); - if ((p = strrchr(buf, '.')) != NULL && strcmp(p, ".enc") == 0) - *p = 0; /* strip ".enc" from encoding name */ - else - strcat(buf, builtin_suffix); /* ".enc" not present, this is a builtin - encoding so the name is eg "cmr10-builtin" */ - objnum = pdf_new_objnum(); - pdf_begin_dict(objnum, 0); - pdf_begin_stream(); - pdf_printf("%%!PS-Adobe-3.0 Resource-CMap\n" - "%%%%DocumentNeededResources: ProcSet (CIDInit)\n" - "%%%%IncludeResource: ProcSet (CIDInit)\n" - "%%%%BeginResource: CMap (TeX-%s-0)\n" - "%%%%Title: (TeX-%s-0 TeX %s 0)\n" - "%%%%Version: 1.000\n" - "%%%%EndComments\n" - "/CIDInit /ProcSet findresource begin\n" - "12 dict begin\n" - "begincmap\n" - "/CIDSystemInfo\n" - "<< /Registry (TeX)\n" - "/Ordering (%s)\n" - "/Supplement 0\n" - ">> def\n" - "/CMapName /TeX-%s-0 def\n" - "/CMapType 2 def\n" - "1 begincodespacerange\n" - "<00> \n" "endcodespacerange\n", buf, buf, buf, buf, buf); - - /* set gtab */ - for (i = 0; i < 256; ++i) { - gtab[i].code = UNI_UNDEF; - set_glyph_unicode(glyph_names[i], >ab[i]); - } - gtab[256].code = UNI_UNDEF; - - /* set range_size */ - for (i = 0; i < 256;) { - if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { - range_size[i] = 1; /* single entry */ - i++; - } else if (gtab[i].code == UNI_UNDEF) { - range_size[i] = 0; /* no entry */ - i++; - } else { /* gtab[i].code >= 0 */ - j = i; - while (i < 256 && gtab[i + 1].code >= 0 && - gtab[i].code + 1 == gtab[i + 1].code) - i++; - /* at this point i is the last entry of the subrange */ - i++; /* move i to the next entry */ - range_size[j] = i - j; - } - } - - /* calculate bfrange_count and bfchar_count */ - bfrange_count = 0; - bfchar_count = 0; - for (i = 0; i < 256;) { - if (range_size[i] == 1) { - bfchar_count++; - i++; - } else if (range_size[i] > 1) { - bfrange_count++; - i += range_size[i]; - } else - i++; - } - - /* write out bfrange */ - i = 0; - write_bfrange: - if (bfrange_count > 100) - subrange_count = 100; - else - subrange_count = bfrange_count; - bfrange_count -= subrange_count; - pdf_printf("%i beginbfrange\n", subrange_count); - for (j = 0; j < subrange_count; j++) { - while (range_size[i] <= 1 && i < 256) - i++; - assert(i < 256); - pdf_printf("<%02X> <%02X> <%s>\n", i, i + range_size[i] - 1, - utf16be_str(gtab[i].code)); - i += range_size[i]; - } - pdf_printf("endbfrange\n"); - if (bfrange_count > 0) - goto write_bfrange; - - /* write out bfchar */ - i = 0; - write_bfchar: - if (bfchar_count > 100) - subrange_count = 100; - else - subrange_count = bfchar_count; - bfchar_count -= subrange_count; - pdf_printf("%i beginbfchar\n", subrange_count); - for (j = 0; j < subrange_count; j++) { - while (i < 256) { - if (range_size[i] > 1) - i += range_size[i]; - else if (range_size[i] == 0) - i++; - else /* range_size[i] == 1 */ - break; - } - assert(i < 256 && gtab[i].code != UNI_UNDEF); - if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { - assert(gtab[i].unicode_seq != NULL); - pdf_printf("<%02X> <%s>\n", i, gtab[i].unicode_seq); - } else - pdf_printf("<%02X> <%s>\n", i, utf16be_str(gtab[i].code)); - i++; - } - pdf_printf("endbfchar\n"); - if (bfchar_count > 0) - goto write_bfchar; - - /* free strings allocated by set_glyph_unicode() */ - for (i = 0; i < 256; ++i) { - if (gtab[i].code == UNI_EXTRA_STRING) - xfree(gtab[i].unicode_seq); - } - - pdf_printf("endcmap\n" - "CMapName currentdict /CMap defineresource pop\n" - "end\n" "end\n" "%%%%EndResource\n" "%%%%EOF\n"); - pdf_end_stream(); - return objnum; -} - -integer write_cid_tounicode(fo_entry * fo, internalfontnumber f) -{ - - int range_size[65537]; - glyph_unicode_entry gtab[65537]; - integer objnum; - int i, j, k; - int bfchar_count, bfrange_count, subrange_count; - char *buf; - - assert(fo->fd->fontname); - buf = xmalloc(strlen(fo->fd->fontname) + 8); - sprintf(buf, "%s-%s", - (fo->fd->subset_tag != NULL ? fo->fd->subset_tag : "UCS"), - fo->fd->fontname); - - objnum = pdf_new_objnum(); - pdf_begin_dict(objnum, 0); - pdf_begin_stream(); - pdf_printf("%%!PS-Adobe-3.0 Resource-CMap\n" - "%%%%DocumentNeededResources: ProcSet (CIDInit)\n" - "%%%%IncludeResource: ProcSet (CIDInit)\n" - "%%%%BeginResource: CMap (TeX-%s-0)\n" - "%%%%Title: (TeX-%s-0 TeX %s 0)\n" - "%%%%Version: 1.000\n" - "%%%%EndComments\n" - "/CIDInit /ProcSet findresource begin\n" - "12 dict begin\n" - "begincmap\n" - "/CIDSystemInfo\n" - "<< /Registry (TeX)\n" - "/Ordering (%s)\n" - "/Supplement 0\n" - ">> def\n" - "/CMapName /TeX-Identity-%s def\n" - "/CMapType 2 def\n" - "1 begincodespacerange\n" - "<0000> \n" - "endcodespacerange\n", buf, buf, buf, buf, buf); - xfree(buf); - /* set up gtab */ - for (i = 0; i < 65537; ++i) { - gtab[i].code = UNI_UNDEF; - } - for (k = 1; k <= max_font_id(); k++) { - if (k == f || -f == pdf_font_num(k)) { - for (i = font_bc(k); i <= font_ec(k); i++) { - if (char_exists(k, i) && char_used(k, i)) { - j = char_index(k, i); - if (gtab[j].code == UNI_UNDEF) { - set_cid_glyph_unicode(i, >ab[j], f); - } - } - } - } - } - - /* set range_size */ - for (i = 0; i < 65536;) { - if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { - range_size[i] = 1; /* single entry */ - i++; - } else if (gtab[i].code == UNI_UNDEF) { - range_size[i] = 0; /* no entry */ - i++; - } else { /* gtab[i].code >= 0 */ - j = i; - while (i < 65536 && gtab[i + 1].code >= 0 && - gtab[i].code + 1 == gtab[i + 1].code) - i++; - /* at this point i is the last entry of the subrange */ - i++; /* move i to the next entry */ - range_size[j] = i - j; - } - } - - /* calculate bfrange_count and bfchar_count */ - bfrange_count = 0; - bfchar_count = 0; - for (i = 0; i < 65536;) { - if (range_size[i] == 1) { - bfchar_count++; - i++; - } else if (range_size[i] > 1) { - bfrange_count++; - i += range_size[i]; - } else - i++; - } - - /* write out bfrange */ - i = 0; - write_bfrange: - if (bfrange_count > 100) - subrange_count = 100; - else - subrange_count = bfrange_count; - bfrange_count -= subrange_count; - pdf_printf("%i beginbfrange\n", subrange_count); - for (j = 0; j < subrange_count; j++) { - while (range_size[i] <= 1 && i < 65536) - i++; - assert(i < 65536); - pdf_printf("<%04X> <%04X> <%s>\n", i, i + range_size[i] - 1, - utf16be_str(gtab[i].code)); - i += range_size[i]; - } - pdf_printf("endbfrange\n"); - if (bfrange_count > 0) - goto write_bfrange; - - /* write out bfchar */ - i = 0; - write_bfchar: - if (bfchar_count > 100) - subrange_count = 100; - else - subrange_count = bfchar_count; - bfchar_count -= subrange_count; - pdf_printf("%i beginbfchar\n", subrange_count); - for (j = 0; j < subrange_count; j++) { - while (i < 65536) { - if (range_size[i] > 1) - i += range_size[i]; - else if (range_size[i] == 0) - i++; - else /* range_size[i] == 1 */ - break; - } - assert(i < 65536 && gtab[i].code != UNI_UNDEF); - if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { - assert(gtab[i].unicode_seq != NULL); - pdf_printf("<%04X> <%s>\n", i, gtab[i].unicode_seq); - } else - pdf_printf("<%04X> <%s>\n", i, utf16be_str(gtab[i].code)); - i++; - } - pdf_printf("endbfchar\n"); - if (bfchar_count > 0) - goto write_bfchar; - - /* free strings allocated by set_glyph_unicode() */ - for (i = 0; i < 65536; ++i) { - if (gtab[i].code == UNI_EXTRA_STRING) - xfree(gtab[i].unicode_seq); - } - - pdf_printf("endcmap\n" - "CMapName currentdict /CMap defineresource pop\n" - "end\n" "end\n" "%%%%EndResource\n" "%%%%EOF\n"); - pdf_end_stream(); - return objnum; -} diff --git a/Build/source/texk/web2c/luatexdir/font/tounicode.w b/Build/source/texk/web2c/luatexdir/font/tounicode.w new file mode 100644 index 00000000000..9ca84210606 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/tounicode.w @@ -0,0 +1,626 @@ +% tounicode.w + +% Copyright 2006 Han The Thanh, +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" + +static const char _svn_version[] = + "$Id: tounicode.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/tounicode.w $"; + +@ @c +#define isXdigit(c) (isdigit(c) || ('A' <= (c) && (c) <= 'F')) +#define UNI_UNDEF -1 +#define UNI_STRING -2 /* string allocated by |def_tounicode()| */ +#define UNI_EXTRA_STRING -3 /* string allocated by |set_glyph_unicode()| */ + +static struct avl_table *glyph_unicode_tree = NULL; + +static int comp_glyph_unicode_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return strcmp(((const glyph_unicode_entry *) pa)->name, + ((const glyph_unicode_entry *) pb)->name); +} + +static glyph_unicode_entry *new_glyph_unicode_entry(void) +{ + glyph_unicode_entry *e; + e = xtalloc(1, glyph_unicode_entry); + e->name = NULL; + e->code = UNI_UNDEF; + e->unicode_seq = NULL; + return e; +} + +static void destroy_glyph_unicode_entry(void *pa, void *pb) +{ + glyph_unicode_entry *e = (glyph_unicode_entry *) pa; + (void) pb; + xfree(e->name); + if (e->code == UNI_STRING) { + assert(e->unicode_seq != NULL); + xfree(e->unicode_seq); + } +} + +void glyph_unicode_free(void) +{ + if (glyph_unicode_tree != NULL) + avl_destroy(glyph_unicode_tree, destroy_glyph_unicode_entry); +} + +@ @c +void def_tounicode(str_number glyph, str_number unistr) +{ + char buf[SMALL_BUF_SIZE], *p, *ph; + char buf2[SMALL_BUF_SIZE], *q; + int valid_unistr; /* 0: invalid; 1: unicode value; 2: string */ + int i, l; + glyph_unicode_entry *gu, t; + void **aa; + + p = makecstring(glyph); + assert(strlen(p) < SMALL_BUF_SIZE); + strcpy(buf, p); + free(p); + p = makecstring(unistr); + ph = p; + while (*p == ' ') + p++; /* ignore leading spaces */ + l = (int) strlen(p); + while (l > 0 && p[l - 1] == ' ') + l--; /* ignore traling spaces */ + valid_unistr = 1; /* a unicode value is the most common case */ + for (i = 0; i < l; i++) { + if (p[i] == ' ') + valid_unistr = 2; /* if a space occurs we treat this entry as a string */ + else if (!isXdigit(p[i])) { + valid_unistr = 0; + break; + } + } + if (l == 0 || valid_unistr == 0 || strlen(buf) == 0 + || strcmp(buf, notdef) == 0) { + pdftex_warn("ToUnicode: invalid parameter(s): `%s' => `%s'", buf, p); + return; + } + if (glyph_unicode_tree == NULL) { + glyph_unicode_tree = + avl_create(comp_glyph_unicode_entry, NULL, &avl_xallocator); + assert(glyph_unicode_tree != NULL); + } + t.name = buf; + /* allow overriding existing entries */ + if ((gu = (glyph_unicode_entry *) avl_find(glyph_unicode_tree, &t)) != NULL) { + if (gu->code == UNI_STRING) { + assert(gu->unicode_seq != NULL); + xfree(gu->unicode_seq); + } + } else { /* make new entry */ + gu = new_glyph_unicode_entry(); + gu->name = xstrdup(buf); + } + if (valid_unistr == 2) { /* a string with space(s) */ + /* copy p to buf2, ignoring spaces */ + for (q = buf2; *p != 0; p++) + if (*p != ' ') + *q++ = *p; + *q = 0; + gu->code = UNI_STRING; + gu->unicode_seq = xstrdup(buf2); + } else { + i = sscanf(p, "%lX", &(gu->code)); + assert(i == 1); + } + aa = avl_probe(glyph_unicode_tree, gu); + assert(aa != NULL); + free(ph); +} + + +@ @c +static long check_unicode_value(char *s, boolean multiple_value) +{ + int l = (int) strlen(s); + int i; + long code; + + if (l == 0) + return UNI_UNDEF; + if (multiple_value && l % 4 != 0) + return UNI_UNDEF; + if (!multiple_value && !(4 <= l && l <= 6)) + return UNI_UNDEF; + + for (i = 0; i < l; i++) { + if (!isXdigit(s[i])) + return UNI_UNDEF; + if (multiple_value) { + if (i % 4 == 3) { + if (sscanf(s + i - 3, "%4lX", &code) != 1) + return UNI_UNDEF; + if (!((0x0000 <= code && code <= 0xD7FF) || + (0xE000 <= code && code <= 0xFFFF))) + return UNI_UNDEF; + } + } else { /* single value */ + if (i == l - 1) { + if (sscanf(s, "%lX", &code) != 1) + return UNI_UNDEF; + if (!((0x0000 <= code && code <= 0xD7FF) || + (0xE000 <= code && code <= 0x10FFFF))) + return UNI_UNDEF; + } + } + } + return code; +} + +@ @c +static char *utf16be_str(long code) +{ + static char buf[SMALL_BUF_SIZE]; + long v; + unsigned vh, vl; + + assert(code >= 0); + + if (code <= 0xFFFF) + sprintf(buf, "%04lX", code); + else { + v = code - 0x10000; + vh = (unsigned) (v / 0x400 + 0xD800); + vl = (unsigned) (v % 0x400 + 0xDC00); + sprintf(buf, "%04X%04X", vh, vl); + } + return buf; +} + + +@ This function set proper values to |*gp| based on |s|; in case it returns + |gp->code == UNI_EXTRA_STRING| then the caller is responsible for freeing + |gp->unicode_seq| too. +@c +static void set_glyph_unicode(char *s, glyph_unicode_entry * gp) +{ + char buf[SMALL_BUF_SIZE], buf2[SMALL_BUF_SIZE], *p; + long code; + boolean last_component; + glyph_unicode_entry tmp, *ptmp; + + /* skip dummy entries */ + if (s == NULL || s == notdef) + return; + + /* strip everything after the first dot */ + p = strchr(s, '.'); + if (p != NULL) { + *buf = 0; + strncat(buf, s, (size_t) (p - s)); + s = buf; + } + + if (strlen(s) == 0) + return; + + /* check for case of multiple components separated by |'_'| */ + p = strchr(s, '_'); + if (p != NULL) { + assert(strlen(s) < sizeof(buf)); + if (s != buf) { + strcpy(buf, s); + p = strchr(buf, '_'); + s = buf; + } + *buf2 = 0; + last_component = false; + for (;;) { + *p = 0; + tmp.code = UNI_UNDEF; + set_glyph_unicode(s, &tmp); + switch (tmp.code) { + case UNI_UNDEF: /* not found, do nothing */ + break; + case UNI_STRING: /* s matched an entry with string value in the database */ + assert(tmp.unicode_seq != NULL); + assert(strlen(buf2) + strlen(tmp.unicode_seq) < sizeof(buf2)); + strcat(buf2, tmp.unicode_seq); + break; + case UNI_EXTRA_STRING: /* s is a multiple value of form "uniXXXX" */ + assert(strlen(buf2) + strlen(tmp.unicode_seq) < sizeof(buf2)); + strcat(buf2, tmp.unicode_seq); + xfree(tmp.unicode_seq); + break; + default: /* s matched an entry with numeric value in the + database, or a value derived from "uXXXX" */ + assert(tmp.code >= 0); + strcat(buf2, utf16be_str(tmp.code)); + } + if (last_component) + break; + s = p + 1; + p = strchr(s, '_'); + if (p == NULL) { + p = strend(s); + last_component = true; + } + } + gp->code = UNI_EXTRA_STRING; + gp->unicode_seq = xstrdup(buf2); + return; + } + + /* lookup for glyph name in the database */ + tmp.name = s; + tmp.code = UNI_UNDEF; + ptmp = (glyph_unicode_entry *) avl_find(glyph_unicode_tree, &tmp); + if (ptmp != NULL) { + gp->code = ptmp->code; + gp->unicode_seq = ptmp->unicode_seq; + return; + } + + /* check for case of "uniXXXX" (multiple 4-hex-digit values allowed) */ + if (str_prefix(s, "uni")) { + p = s + strlen("uni"); + code = check_unicode_value(p, true); + if (code != UNI_UNDEF) { + if (strlen(p) == 4) /* single value */ + gp->code = code; + else { /* multiple value */ + gp->code = UNI_EXTRA_STRING; + gp->unicode_seq = xstrdup(p); + } + } + return; /* since the last case cannot happen */ + } + + /* check for case of "uXXXX" (single value up to 6 hex digits) */ + if (str_prefix(s, "u")) { + p = s + strlen("u"); + code = check_unicode_value(p, false); + if (code != UNI_UNDEF) { + assert(code >= 0); + gp->code = code; + } + } +} + +@ @c +static void set_cid_glyph_unicode(long index, glyph_unicode_entry * gp, + internal_font_number f) +{ + char *s; + if (font_tounicode(f) && + (s = get_charinfo_tounicode(char_info(f, (int) index))) != NULL) { + gp->code = UNI_EXTRA_STRING; + gp->unicode_seq = xstrdup(s); + } else { + gp->code = index; /* fallback */ + } +} + + +@ @c +int write_tounicode(PDF pdf, char **glyph_names, char *name) +{ + char buf[SMALL_BUF_SIZE], *p; + static char builtin_suffix[] = "-builtin"; + short range_size[257]; + glyph_unicode_entry gtab[257]; + int objnum; + int i, j; + int bfchar_count, bfrange_count, subrange_count; + assert(strlen(name) + strlen(builtin_suffix) < SMALL_BUF_SIZE); + if (glyph_unicode_tree == NULL) { +#ifdef DEBUG + pdftex_warn("no GlyphToUnicode entry has been inserted yet!"); +#endif + pdf->gen_tounicode = 0; + return 0; + } + strcpy(buf, name); + if ((p = strrchr(buf, '.')) != NULL && strcmp(p, ".enc") == 0) + *p = 0; /* strip ".enc" from encoding name */ + else + strcat(buf, builtin_suffix); /* ".enc" not present, this is a builtin + encoding so the name is eg "cmr10-builtin" */ + objnum = pdf_new_objnum(pdf); + pdf_begin_dict(pdf, objnum, 0); + pdf_begin_stream(pdf); + pdf_printf(pdf, "%%!PS-Adobe-3.0 Resource-CMap\n"@/ + "%%%%DocumentNeededResources: ProcSet (CIDInit)\n"@/ + "%%%%IncludeResource: ProcSet (CIDInit)\n"@/ + "%%%%BeginResource: CMap (TeX-%s-0)\n"@/ + "%%%%Title: (TeX-%s-0 TeX %s 0)\n"@/ + "%%%%Version: 1.000\n"@/ + "%%%%EndComments\n"@/ + "/CIDInit /ProcSet findresource begin\n"@/ + "12 dict begin\n"@/ + "begincmap\n"@/ + "/CIDSystemInfo\n"@/ + "<< /Registry (TeX)\n"@/ + "/Ordering (%s)\n"@/ + "/Supplement 0\n"@/ + ">> def\n"@/ + "/CMapName /TeX-%s-0 def\n"@/ + "/CMapType 2 def\n"@/ + "1 begincodespacerange\n"@/ + "<00> \n" "endcodespacerange\n", buf, buf, buf, buf, buf); + + /* set gtab */ + for (i = 0; i < 256; ++i) { + gtab[i].code = UNI_UNDEF; + set_glyph_unicode(glyph_names[i], >ab[i]); + } + gtab[256].code = UNI_UNDEF; + + /* set |range_size| */ + for (i = 0; i < 256;) { + if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { + range_size[i] = 1; /* single entry */ + i++; + } else if (gtab[i].code == UNI_UNDEF) { + range_size[i] = 0; /* no entry */ + i++; + } else { /* gtab[i].code >= 0 */ + j = i; + while (i < 256 && gtab[i + 1].code >= 0 && + gtab[i].code + 1 == gtab[i + 1].code) + i++; + /* at this point i is the last entry of the subrange */ + i++; /* move i to the next entry */ + range_size[j] = (short) (i - j); + } + } + + /* calculate |bfrange_count| and |bfchar_count| */ + bfrange_count = 0; + bfchar_count = 0; + for (i = 0; i < 256;) { + if (range_size[i] == 1) { + bfchar_count++; + i++; + } else if (range_size[i] > 1) { + bfrange_count++; + i += range_size[i]; + } else + i++; + } + + /* write out bfrange */ + i = 0; + write_bfrange: + if (bfrange_count > 100) + subrange_count = 100; + else + subrange_count = bfrange_count; + bfrange_count -= subrange_count; + pdf_printf(pdf, "%i beginbfrange\n", subrange_count); + for (j = 0; j < subrange_count; j++) { + while (range_size[i] <= 1 && i < 256) + i++; + assert(i < 256); + pdf_printf(pdf, "<%02X> <%02X> <%s>\n", i, i + range_size[i] - 1, + utf16be_str(gtab[i].code)); + i += range_size[i]; + } + pdf_printf(pdf, "endbfrange\n"); + if (bfrange_count > 0) + goto write_bfrange; + + /* write out bfchar */ + i = 0; + write_bfchar: + if (bfchar_count > 100) + subrange_count = 100; + else + subrange_count = bfchar_count; + bfchar_count -= subrange_count; + pdf_printf(pdf, "%i beginbfchar\n", subrange_count); + for (j = 0; j < subrange_count; j++) { + while (i < 256) { + if (range_size[i] > 1) + i += range_size[i]; + else if (range_size[i] == 0) + i++; + else /* |range_size[i] == 1| */ + break; + } + assert(i < 256 && gtab[i].code != UNI_UNDEF); + if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { + assert(gtab[i].unicode_seq != NULL); + pdf_printf(pdf, "<%02X> <%s>\n", i, gtab[i].unicode_seq); + } else + pdf_printf(pdf, "<%02X> <%s>\n", i, utf16be_str(gtab[i].code)); + i++; + } + pdf_printf(pdf, "endbfchar\n"); + if (bfchar_count > 0) + goto write_bfchar; + + /* free strings allocated by |set_glyph_unicode()| */ + for (i = 0; i < 256; ++i) { + if (gtab[i].code == UNI_EXTRA_STRING) + xfree(gtab[i].unicode_seq); + } + + pdf_printf(pdf, "endcmap\n" + "CMapName currentdict /CMap defineresource pop\n" + "end\n" "end\n" "%%%%EndResource\n" "%%%%EOF\n"); + pdf_end_stream(pdf); + return objnum; +} + +@ @c +int write_cid_tounicode(PDF pdf, fo_entry * fo, internal_font_number f) +{ + + int range_size[65537]; + glyph_unicode_entry gtab[65537]; + int objnum; + int i, j, k; + int bfchar_count, bfrange_count, subrange_count; + char *buf; + + assert(fo->fd->fontname); + buf = xmalloc((unsigned) (strlen(fo->fd->fontname) + 8)); + sprintf(buf, "%s-%s", + (fo->fd->subset_tag != NULL ? fo->fd->subset_tag : "UCS"), + fo->fd->fontname); + + objnum = pdf_new_objnum(pdf); + pdf_begin_dict(pdf, objnum, 0); + pdf_begin_stream(pdf); + pdf_printf(pdf, "%%!PS-Adobe-3.0 Resource-CMap\n"@/ + "%%%%DocumentNeededResources: ProcSet (CIDInit)\n"@/ + "%%%%IncludeResource: ProcSet (CIDInit)\n"@/ + "%%%%BeginResource: CMap (TeX-%s-0)\n"@/ + "%%%%Title: (TeX-%s-0 TeX %s 0)\n"@/ + "%%%%Version: 1.000\n"@/ + "%%%%EndComments\n"@/ + "/CIDInit /ProcSet findresource begin\n"@/ + "12 dict begin\n"@/ + "begincmap\n"@/ + "/CIDSystemInfo\n"@/ + "<< /Registry (TeX)\n"@/ + "/Ordering (%s)\n"@/ + "/Supplement 0\n"@/ + ">> def\n"@/ + "/CMapName /TeX-Identity-%s def\n"@/ + "/CMapType 2 def\n"@/ + "1 begincodespacerange\n"@/ + "<0000> \n"@/ + "endcodespacerange\n", buf, buf, buf, buf, buf); + xfree(buf); + /* set up gtab */ + for (i = 0; i < 65537; ++i) { + gtab[i].code = UNI_UNDEF; + } + for (k = 1; k <= max_font_id(); k++) { + if (k == f || -f == pdf_font_num(k)) { + for (i = font_bc(k); i <= font_ec(k); i++) { + if (quick_char_exists(k, i) && char_used(k, i)) { + j = char_index(k, i); + if (gtab[j].code == UNI_UNDEF) { + set_cid_glyph_unicode(i, >ab[j], f); + } + } + } + } + } + + /* set |range_size| */ + for (i = 0; i < 65536;) { + if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { + range_size[i] = 1; /* single entry */ + i++; + } else if (gtab[i].code == UNI_UNDEF) { + range_size[i] = 0; /* no entry */ + i++; + } else { /* |gtab[i].code >= 0| */ + j = i; + while (i < 65536 && gtab[i + 1].code >= 0 && + gtab[i].code + 1 == gtab[i + 1].code) + i++; + /* at this point i is the last entry of the subrange */ + i++; /* move i to the next entry */ + range_size[j] = i - j; + } + } + + /* calculate |bfrange_count| and |bfchar_count| */ + bfrange_count = 0; + bfchar_count = 0; + for (i = 0; i < 65536;) { + if (range_size[i] == 1) { + bfchar_count++; + i++; + } else if (range_size[i] > 1) { + bfrange_count++; + i += range_size[i]; + } else + i++; + } + + /* write out bfrange */ + i = 0; + write_bfrange: + if (bfrange_count > 100) + subrange_count = 100; + else + subrange_count = bfrange_count; + bfrange_count -= subrange_count; + pdf_printf(pdf, "%i beginbfrange\n", subrange_count); + for (j = 0; j < subrange_count; j++) { + while (range_size[i] <= 1 && i < 65536) + i++; + assert(i < 65536); + pdf_printf(pdf, "<%04X> <%04X> <%s>\n", i, i + range_size[i] - 1, + utf16be_str(gtab[i].code)); + i += range_size[i]; + } + pdf_printf(pdf, "endbfrange\n"); + if (bfrange_count > 0) + goto write_bfrange; + + /* write out bfchar */ + i = 0; + write_bfchar: + if (bfchar_count > 100) + subrange_count = 100; + else + subrange_count = bfchar_count; + bfchar_count -= subrange_count; + pdf_printf(pdf, "%i beginbfchar\n", subrange_count); + for (j = 0; j < subrange_count; j++) { + while (i < 65536) { + if (range_size[i] > 1) + i += range_size[i]; + else if (range_size[i] == 0) + i++; + else /* |range_size[i] == 1| */ + break; + } + assert(i < 65536 && gtab[i].code != UNI_UNDEF); + if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) { + assert(gtab[i].unicode_seq != NULL); + pdf_printf(pdf, "<%04X> <%s>\n", i, gtab[i].unicode_seq); + } else + pdf_printf(pdf, "<%04X> <%s>\n", i, utf16be_str(gtab[i].code)); + i++; + } + pdf_printf(pdf, "endbfchar\n"); + if (bfchar_count > 0) + goto write_bfchar; + + /* free strings allocated by |set_glyph_unicode()| */ + for (i = 0; i < 65536; ++i) { + if (gtab[i].code == UNI_EXTRA_STRING) + xfree(gtab[i].unicode_seq); + } + + pdf_printf(pdf, "endcmap\n" + "CMapName currentdict /CMap defineresource pop\n" + "end\n" "end\n" "%%%%EndResource\n" "%%%%EOF\n"); + pdf_end_stream(pdf); + return objnum; +} diff --git a/Build/source/texk/web2c/luatexdir/font/tt_glyf.c b/Build/source/texk/web2c/luatexdir/font/tt_glyf.c deleted file mode 100644 index 1ca35e8800f..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/tt_glyf.c +++ /dev/null @@ -1,651 +0,0 @@ -/* tt_glyf.c - - Copyright 2002 by Jin-Hwan Cho and Shunsaku Hirata, - the dvipdfmx project team - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -/* - * Subsetting glyf, updating loca, hmtx, ... - * - */ - -#include "ptexlib.h" - -#include "sfnt.h" -#include "tt_table.h" -#include "tt_glyf.h" -#include "writettf.h" - -static const char _svn_version[] = - "$Id: tt_glyf.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/tt_glyf.c $"; - -#define NUM_GLYPH_LIMIT 65534 -#define TABLE_DATA_ALLOC_SIZE 40960 -#define GLYPH_ARRAY_ALLOC_SIZE 256 - -static USHORT find_empty_slot(struct tt_glyphs *g) -{ - USHORT gid; - - ASSERT(g); - - for (gid = 0; gid < NUM_GLYPH_LIMIT; gid++) { - if (!(g->used_slot[gid / 8] & (1 << (7 - (gid % 8))))) - break; - } - if (gid == NUM_GLYPH_LIMIT) - TT_ERROR("No empty glyph slot available."); - - return gid; -} - -USHORT tt_find_glyph(struct tt_glyphs * g, USHORT gid) -{ - USHORT idx, new_gid = 0; - - ASSERT(g); - - for (idx = 0; idx < g->num_glyphs; idx++) { - if (gid == g->gd[idx].ogid) { - new_gid = g->gd[idx].gid; - break; - } - } - - return new_gid; -} - -USHORT tt_get_index(struct tt_glyphs * g, USHORT gid) -{ - USHORT idx; - - ASSERT(g); - - for (idx = 0; idx < g->num_glyphs; idx++) { - if (gid == g->gd[idx].gid) - break; - } - if (idx == g->num_glyphs) - idx = 0; - - return idx; -} - -USHORT tt_add_glyph(struct tt_glyphs * g, USHORT gid, USHORT new_gid) -{ - ASSERT(g); - - if (g->used_slot[new_gid / 8] & (1 << (7 - (new_gid % 8)))) { - WARN("Slot %u already used.", new_gid); - } else { - if (g->num_glyphs + 1 >= NUM_GLYPH_LIMIT) - TT_ERROR("Too many glyphs."); - - if (g->num_glyphs >= g->max_glyphs) { - g->max_glyphs += GLYPH_ARRAY_ALLOC_SIZE; - g->gd = RENEW(g->gd, g->max_glyphs, struct tt_glyph_desc); - } - g->gd[g->num_glyphs].gid = new_gid; - g->gd[g->num_glyphs].ogid = gid; - g->gd[g->num_glyphs].length = 0; - g->gd[g->num_glyphs].data = NULL; - g->used_slot[new_gid / 8] |= (1 << (7 - (new_gid % 8))); - g->num_glyphs += 1; - } - - if (new_gid > g->last_gid) { - g->last_gid = new_gid; - } - - return new_gid; -} - -/* - * Initialization - */ -struct tt_glyphs *tt_build_init(void) -{ - struct tt_glyphs *g; - - g = NEW(1, struct tt_glyphs); - - g->num_glyphs = 0; - g->max_glyphs = 0; - g->last_gid = 0; - g->emsize = 1; - g->default_advh = 0; - g->default_tsb = 0; - g->gd = NULL; - g->used_slot = NEW(8192, unsigned char); - memset(g->used_slot, 0, 8192); - tt_add_glyph(g, 0, 0); - - return g; -} - -void tt_build_finish(struct tt_glyphs *g) -{ - if (g) { - if (g->gd) { - USHORT idx; - for (idx = 0; idx < g->num_glyphs; idx++) { - if (g->gd[idx].data) - RELEASE(g->gd[idx].data); - } - RELEASE(g->gd); - } - if (g->used_slot) - RELEASE(g->used_slot); - RELEASE(g); - } -} - -static int glyf_cmp(const void *v1, const void *v2) -{ - int cmp = 0; - const struct tt_glyph_desc *sv1, *sv2; - - sv1 = (const struct tt_glyph_desc *) v1; - sv2 = (const struct tt_glyph_desc *) v2; - - if (sv1->gid == sv2->gid) - cmp = 0; - else if (sv1->gid < sv2->gid) - cmp = -1; - else - cmp = 1; - - return cmp; -} - -int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) -{ - char *hmtx_table_data = NULL, *loca_table_data = NULL; - char *glyf_table_data = NULL; - ULONG hmtx_table_size, loca_table_size, glyf_table_size; - /* some information available from other TrueType table */ - struct tt_head_table *head = NULL; - struct tt_hhea_table *hhea = NULL; - struct tt_maxp_table *maxp = NULL; - struct tt_longMetrics *hmtx, *vmtx = NULL; - struct tt_os2__table *os2; - /* temp */ - ULONG *location, offset; - long i; - USHORT *w_stat; /* Estimate most frequently appeared width */ - - ASSERT(g); - - if (sfont->type != SFNT_TYPE_TRUETYPE && sfont->type != SFNT_TYPE_TTC) - TT_ERROR("Invalid font type"); - - if (g->num_glyphs > NUM_GLYPH_LIMIT) - TT_ERROR("Too many glyphs."); - - /* - * Read head, hhea, maxp, loca: - * - * unitsPerEm --> head - * numHMetrics --> hhea - * indexToLocFormat --> head - * numGlyphs --> maxp - */ - head = tt_read_head_table(sfont); - hhea = tt_read_hhea_table(sfont); - maxp = tt_read_maxp_table(sfont); - - if (hhea->metricDataFormat != 0) - TT_ERROR("Unknown metricDataFormat."); - - g->emsize = head->unitsPerEm; - - sfnt_locate_table(sfont, "hmtx"); - hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); - - os2 = tt_read_os2__table(sfont); - if (os2) { - g->default_advh = os2->sTypoAscender - os2->sTypoDescender; - g->default_tsb = g->default_advh - os2->sTypoAscender; - - /* dvipdfmx does this elsewhere! */ - fd_cur->font_dim[STEMV_CODE].val = - (os2->usWeightClass / 65) * (os2->usWeightClass / 65) + 50; - } - - if (sfnt_find_table_pos(sfont, "vmtx") > 0) { - struct tt_vhea_table *vhea; - vhea = tt_read_vhea_table(sfont); - sfnt_locate_table(sfont, "vmtx"); - vmtx = - tt_read_longMetrics(sfont, maxp->numGlyphs, - vhea->numOfLongVerMetrics); - RELEASE(vhea); - } else { - vmtx = NULL; - } - - sfnt_locate_table(sfont, "loca"); - location = NEW(maxp->numGlyphs + 1, ULONG); - if (head->indexToLocFormat == 0) { - for (i = 0; i <= maxp->numGlyphs; i++) - location[i] = 2 * ((ULONG) sfnt_get_ushort(sfont)); - } else if (head->indexToLocFormat == 1) { - for (i = 0; i <= maxp->numGlyphs; i++) - location[i] = sfnt_get_ulong(sfont); - } else { - TT_ERROR("Unknown IndexToLocFormat."); - } - - w_stat = NEW(g->emsize + 2, USHORT); - memset(w_stat, 0, sizeof(USHORT) * (g->emsize + 2)); - /* - * Read glyf table. - */ - offset = sfnt_locate_table(sfont, "glyf"); - /* - * The num_glyphs may grow when composite glyph is found. - * A component of glyph refered by a composite glyph is appended - * to used_glyphs if it is not already registered in used_glyphs. - * Glyph programs of composite glyphs are modified so that it - * correctly refer to new gid of their components. - */ - for (i = 0; i < NUM_GLYPH_LIMIT; i++) { - USHORT gid; /* old gid */ - ULONG loc, len; - BYTE *p, *endptr; - SHORT number_of_contours; - - if (i >= g->num_glyphs) /* finished */ - break; - - gid = g->gd[i].ogid; - if (gid >= maxp->numGlyphs) - TT_ERROR("Invalid glyph index (gid %u)", gid); - - loc = location[gid]; - len = location[gid + 1] - loc; - g->gd[i].advw = hmtx[gid].advance; - g->gd[i].lsb = hmtx[gid].sideBearing; - if (vmtx) { - g->gd[i].advh = vmtx[gid].advance; - g->gd[i].tsb = vmtx[gid].sideBearing; - } else { - g->gd[i].advh = g->default_advh; - g->gd[i].tsb = g->default_tsb; - } - g->gd[i].length = len; - g->gd[i].data = NULL; - if (g->gd[i].advw <= g->emsize) { - w_stat[g->gd[i].advw] += 1; - } else { - w_stat[g->emsize + 1] += 1; /* larger than em */ - } - - if (len == 0) { /* Does not contains any data. */ - continue; - } else if (len < 10) { - TT_ERROR("Invalid TrueType glyph data (gid %u).", gid); - } - - g->gd[i].data = p = NEW(len, BYTE); - endptr = p + len; - - sfnt_seek_set(sfont, offset + loc); - number_of_contours = sfnt_get_short(sfont); - p += sfnt_put_short(p, number_of_contours); - - /* BoundingBox: FWord x 4 */ - g->gd[i].llx = sfnt_get_short(sfont); - g->gd[i].lly = sfnt_get_short(sfont); - g->gd[i].urx = sfnt_get_short(sfont); - g->gd[i].ury = sfnt_get_short(sfont); - /* _FIXME_ */ -#if 1 - if (!vmtx) /* vertOriginY == sTypeAscender */ - g->gd[i].tsb = g->default_advh - g->default_tsb - g->gd[i].ury; -#endif - p += sfnt_put_short(p, g->gd[i].llx); - p += sfnt_put_short(p, g->gd[i].lly); - p += sfnt_put_short(p, g->gd[i].urx); - p += sfnt_put_short(p, g->gd[i].ury); - - /* Read evrything else. */ - sfnt_read(p, len - 10, sfont); - /* - * Fix GIDs of composite glyphs. - */ - if (number_of_contours < 0) { - USHORT flags, cgid, new_gid; /* flag, gid of a component */ - do { - if (p >= endptr) - TT_ERROR("Invalid TrueType glyph data (gid %u): %u bytes", - gid, (unsigned int) len); - /* - * Flags and gid of component glyph are both USHORT. - */ - flags = ((*p) << 8) | *(p + 1); - p += 2; - cgid = ((*p) << 8) | *(p + 1); - if (cgid >= maxp->numGlyphs) { - TT_ERROR("Invalid gid (%u > %u) in composite glyph %u.", - cgid, maxp->numGlyphs, gid); - } - new_gid = tt_find_glyph(g, cgid); - if (new_gid == 0) { - new_gid = tt_add_glyph(g, cgid, find_empty_slot(g)); - } - p += sfnt_put_ushort(p, new_gid); - /* - * Just skip remaining part. - */ - p += (flags & ARG_1_AND_2_ARE_WORDS) ? 4 : 2; - if (flags & WE_HAVE_A_SCALE) /* F2Dot14 */ - p += 2; - else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) /* F2Dot14 x 2 */ - p += 4; - else if (flags & WE_HAVE_A_TWO_BY_TWO) /* F2Dot14 x 4 */ - p += 8; - } while (flags & MORE_COMPONENTS); - /* - * TrueType instructions comes here: - * length_of_instruction (ushort) - * instruction (byte * length_of_instruction) - */ - } - } - RELEASE(location); - RELEASE(hmtx); - if (vmtx) - RELEASE(vmtx); - - { - int max_count = -1; - - g->dw = g->gd[0].advw; - for (i = 0; i < g->emsize + 1; i++) { - if (w_stat[i] > max_count) { - max_count = w_stat[i]; - g->dw = i; - } - } - } - RELEASE(w_stat); - - qsort(g->gd, g->num_glyphs, sizeof(struct tt_glyph_desc), glyf_cmp); - { - USHORT prev, last_advw; - char *p, *q; - int padlen, num_hm_known; - - glyf_table_size = 0UL; - num_hm_known = 0; - last_advw = g->gd[g->num_glyphs - 1].advw; - for (i = g->num_glyphs - 1; i >= 0; i--) { - padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0; - glyf_table_size += g->gd[i].length + padlen; - if (!num_hm_known && last_advw != g->gd[i].advw) { - hhea->numberOfHMetrics = g->gd[i].gid + 2; - num_hm_known = 1; - } - } - /* All advance widths are same. */ - if (!num_hm_known) { - hhea->numberOfHMetrics = 1; - } - hmtx_table_size = hhea->numberOfHMetrics * 2 + (g->last_gid + 1) * 2; - - /* - * Choosing short format does not always give good result - * when compressed. Sometimes increases size. - */ - if (glyf_table_size < 0x20000UL) { - head->indexToLocFormat = 0; - loca_table_size = (g->last_gid + 2) * 2; - } else { - head->indexToLocFormat = 1; - loca_table_size = (g->last_gid + 2) * 4; - } - - hmtx_table_data = p = NEW(hmtx_table_size, char); - loca_table_data = q = NEW(loca_table_size, char); - glyf_table_data = NEW(glyf_table_size, char); - - offset = 0UL; - prev = 0; - for (i = 0; i < g->num_glyphs; i++) { - long gap, j; - gap = (long) g->gd[i].gid - prev - 1; - for (j = 1; j <= gap; j++) { - if (prev + j == hhea->numberOfHMetrics - 1) { - p += sfnt_put_ushort(p, last_advw); - } else if (prev + j < hhea->numberOfHMetrics) { - p += sfnt_put_ushort(p, 0); - } - p += sfnt_put_short(p, 0); - if (head->indexToLocFormat == 0) { - q += sfnt_put_ushort(q, (USHORT) (offset / 2)); - } else { - q += sfnt_put_ulong(q, offset); - } - } - padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0; - if (g->gd[i].gid < hhea->numberOfHMetrics) { - p += sfnt_put_ushort(p, g->gd[i].advw); - } - p += sfnt_put_short(p, g->gd[i].lsb); - if (head->indexToLocFormat == 0) { - q += sfnt_put_ushort(q, (USHORT) (offset / 2)); - } else { - q += sfnt_put_ulong(q, offset); - } - memset(glyf_table_data + offset, 0, g->gd[i].length + padlen); - memcpy(glyf_table_data + offset, g->gd[i].data, g->gd[i].length); - offset += g->gd[i].length + padlen; - prev = g->gd[i].gid; - /* free data here since it consume much memory */ - RELEASE(g->gd[i].data); - g->gd[i].length = 0; - g->gd[i].data = NULL; - } - if (head->indexToLocFormat == 0) { - q += sfnt_put_ushort(q, (USHORT) (offset / 2)); - } else { - q += sfnt_put_ulong(q, offset); - } - - sfnt_set_table(sfont, "hmtx", (char *) hmtx_table_data, - hmtx_table_size); - sfnt_set_table(sfont, "loca", (char *) loca_table_data, - loca_table_size); - sfnt_set_table(sfont, "glyf", (char *) glyf_table_data, - glyf_table_size); - } - - head->checkSumAdjustment = 0; - maxp->numGlyphs = g->last_gid + 1; - - /* TODO */ - sfnt_set_table(sfont, "maxp", tt_pack_maxp_table(maxp), TT_MAXP_TABLE_SIZE); - sfnt_set_table(sfont, "hhea", tt_pack_hhea_table(hhea), TT_HHEA_TABLE_SIZE); - sfnt_set_table(sfont, "head", tt_pack_head_table(head), TT_HEAD_TABLE_SIZE); - RELEASE(maxp); - RELEASE(hhea); - RELEASE(head); - if (os2) - RELEASE(os2); - - return 0; -} - -int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) -{ - struct tt_head_table *head = NULL; - struct tt_hhea_table *hhea = NULL; - struct tt_maxp_table *maxp = NULL; - struct tt_longMetrics *hmtx, *vmtx = NULL; - struct tt_os2__table *os2; - /* temp */ - ULONG *location, offset; - long i; - USHORT *w_stat; - - ASSERT(g); - - if (sfont == NULL || -#ifdef XETEX - sfont->ft_face == NULL -#elif defined(pdfTeX) - sfont->buffer == NULL -#else - sfont->stream == NULL -#endif - ) - TT_ERROR("File not opened."); - - if (sfont->type != SFNT_TYPE_TRUETYPE && sfont->type != SFNT_TYPE_TTC) - TT_ERROR("Invalid font type"); - - /* - * Read head, hhea, maxp, loca: - * - * unitsPerEm --> head - * numHMetrics --> hhea - * indexToLocFormat --> head - * numGlyphs --> maxp - */ - head = tt_read_head_table(sfont); - hhea = tt_read_hhea_table(sfont); - maxp = tt_read_maxp_table(sfont); - - if (hhea->metricDataFormat != 0) - TT_ERROR("Unknown metricDataFormat."); - - g->emsize = head->unitsPerEm; - - sfnt_locate_table(sfont, "hmtx"); - hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); - - os2 = tt_read_os2__table(sfont); - g->default_advh = os2->sTypoAscender - os2->sTypoDescender; - g->default_tsb = g->default_advh - os2->sTypoAscender; - - if (sfnt_find_table_pos(sfont, "vmtx") > 0) { - struct tt_vhea_table *vhea; - vhea = tt_read_vhea_table(sfont); - sfnt_locate_table(sfont, "vmtx"); - vmtx = - tt_read_longMetrics(sfont, maxp->numGlyphs, - vhea->numOfLongVerMetrics); - RELEASE(vhea); - } else { - vmtx = NULL; - } - - sfnt_locate_table(sfont, "loca"); - location = NEW(maxp->numGlyphs + 1, ULONG); - if (head->indexToLocFormat == 0) { - for (i = 0; i <= maxp->numGlyphs; i++) - location[i] = 2 * ((ULONG) sfnt_get_ushort(sfont)); - } else if (head->indexToLocFormat == 1) { - for (i = 0; i <= maxp->numGlyphs; i++) - location[i] = sfnt_get_ulong(sfont); - } else { - TT_ERROR("Unknown IndexToLocFormat."); - } - - w_stat = NEW(g->emsize + 2, USHORT); - memset(w_stat, 0, sizeof(USHORT) * (g->emsize + 2)); - /* - * Read glyf table. - */ - offset = sfnt_locate_table(sfont, "glyf"); - for (i = 0; i < g->num_glyphs; i++) { - USHORT gid; /* old gid */ - ULONG loc, len; - SHORT number_of_contours; - - gid = g->gd[i].ogid; - if (gid >= maxp->numGlyphs) - TT_ERROR("Invalid glyph index (gid %u)", gid); - - loc = location[gid]; - len = location[gid + 1] - loc; - g->gd[i].advw = hmtx[gid].advance; - g->gd[i].lsb = hmtx[gid].sideBearing; - if (vmtx) { - g->gd[i].advh = vmtx[gid].advance; - g->gd[i].tsb = vmtx[gid].sideBearing; - } else { - g->gd[i].advh = g->default_advh; - g->gd[i].tsb = g->default_tsb; - } - g->gd[i].length = len; - g->gd[i].data = NULL; - - if (g->gd[i].advw <= g->emsize) { - w_stat[g->gd[i].advw] += 1; - } else { - w_stat[g->emsize + 1] += 1; /* larger than em */ - } - - if (len == 0) { /* Does not contains any data. */ - continue; - } else if (len < 10) { - TT_ERROR("Invalid TrueType glyph data (gid %u).", gid); - } - - sfnt_seek_set(sfont, offset + loc); - number_of_contours = sfnt_get_short(sfont); - - /* BoundingBox: FWord x 4 */ - g->gd[i].llx = sfnt_get_short(sfont); - g->gd[i].lly = sfnt_get_short(sfont); - g->gd[i].urx = sfnt_get_short(sfont); - g->gd[i].ury = sfnt_get_short(sfont); - /* _FIXME_ */ -#if 1 - if (!vmtx) /* vertOriginY == sTypeAscender */ - g->gd[i].tsb = g->default_advh - g->default_tsb - g->gd[i].ury; -#endif - } - RELEASE(location); - RELEASE(hmtx); - RELEASE(maxp); - RELEASE(hhea); - RELEASE(head); - RELEASE(os2); - - if (vmtx) - RELEASE(vmtx); - - { - int max_count = -1; - - g->dw = g->gd[0].advw; - for (i = 0; i < g->emsize + 1; i++) { - if (w_stat[i] > max_count) { - max_count = w_stat[i]; - g->dw = i; - } - } - } - RELEASE(w_stat); - - - return 0; -} diff --git a/Build/source/texk/web2c/luatexdir/font/tt_glyf.w b/Build/source/texk/web2c/luatexdir/font/tt_glyf.w new file mode 100644 index 00000000000..b22d5748284 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/tt_glyf.w @@ -0,0 +1,669 @@ +% tt_glyf.w +% +% Copyright 2002 by Jin-Hwan Cho and Shunsaku Hirata, +% the dvipdfmx project team +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@* Subsetting glyf, updating loca, hmtx, etc. + +@ @c +#include "ptexlib.h" + +#include "font/sfnt.h" +#include "font/tt_table.h" +#include "font/tt_glyf.h" +#include "font/writettf.h" + +static const char _svn_version[] = + "$Id: tt_glyf.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/tt_glyf.w $"; + +@ @c +#define NUM_GLYPH_LIMIT 65534 +#define TABLE_DATA_ALLOC_SIZE 40960 +#define GLYPH_ARRAY_ALLOC_SIZE 256 + +static USHORT find_empty_slot(struct tt_glyphs *g) +{ + USHORT gid; + + ASSERT(g); + + for (gid = 0; gid < NUM_GLYPH_LIMIT; gid++) { + if (!(g->used_slot[gid / 8] & (1 << (7 - (gid % 8))))) + break; + } + if (gid == NUM_GLYPH_LIMIT) + TT_ERROR("No empty glyph slot available."); + + return gid; +} + +USHORT tt_find_glyph(struct tt_glyphs * g, USHORT gid) +{ + USHORT idx, new_gid = 0; + + ASSERT(g); + + for (idx = 0; idx < g->num_glyphs; idx++) { + if (gid == g->gd[idx].ogid) { + new_gid = g->gd[idx].gid; + break; + } + } + + return new_gid; +} + +USHORT tt_get_index(struct tt_glyphs * g, USHORT gid) +{ + USHORT idx; + + ASSERT(g); + + for (idx = 0; idx < g->num_glyphs; idx++) { + if (gid == g->gd[idx].gid) + break; + } + if (idx == g->num_glyphs) + idx = 0; + + return idx; +} + +USHORT tt_add_glyph(struct tt_glyphs * g, USHORT gid, USHORT new_gid) +{ + ASSERT(g); + + if (g->used_slot[new_gid / 8] & (1 << (7 - (new_gid % 8)))) { + WARN("Slot %u already used.", new_gid); + } else { + if (g->num_glyphs + 1 >= NUM_GLYPH_LIMIT) + TT_ERROR("Too many glyphs."); + + if (g->num_glyphs >= g->max_glyphs) { + g->max_glyphs = (USHORT) (g->max_glyphs + GLYPH_ARRAY_ALLOC_SIZE); + g->gd = RENEW(g->gd, g->max_glyphs, struct tt_glyph_desc); + } + g->gd[g->num_glyphs].gid = new_gid; + g->gd[g->num_glyphs].ogid = gid; + g->gd[g->num_glyphs].length = 0; + g->gd[g->num_glyphs].data = NULL; + g->used_slot[new_gid / 8] = + (unsigned char) (g->used_slot[new_gid / + 8] | (1 << (7 - (new_gid % 8)))); + g->num_glyphs++; + } + + if (new_gid > g->last_gid) { + g->last_gid = new_gid; + } + + return new_gid; +} + + +@ Initialization +@c +struct tt_glyphs *tt_build_init(void) +{ + struct tt_glyphs *g; + + g = NEW(1, struct tt_glyphs); + + g->num_glyphs = 0; + g->max_glyphs = 0; + g->last_gid = 0; + g->emsize = 1; + g->default_advh = 0; + g->default_tsb = 0; + g->gd = NULL; + g->used_slot = NEW(8192, unsigned char); + memset(g->used_slot, 0, 8192); + tt_add_glyph(g, 0, 0); + + return g; +} + +void tt_build_finish(struct tt_glyphs *g) +{ + if (g) { + if (g->gd) { + USHORT idx; + for (idx = 0; idx < g->num_glyphs; idx++) { + if (g->gd[idx].data) + RELEASE(g->gd[idx].data); + } + RELEASE(g->gd); + } + if (g->used_slot) + RELEASE(g->used_slot); + RELEASE(g); + } +} + +static int glyf_cmp(const void *v1, const void *v2) +{ + int cmp = 0; + const struct tt_glyph_desc *sv1, *sv2; + + sv1 = (const struct tt_glyph_desc *) v1; + sv2 = (const struct tt_glyph_desc *) v2; + + if (sv1->gid == sv2->gid) + cmp = 0; + else if (sv1->gid < sv2->gid) + cmp = -1; + else + cmp = 1; + + return cmp; +} + +@ @c +int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) +{ + char *hmtx_table_data = NULL, *loca_table_data = NULL; + char *glyf_table_data = NULL; + ULONG hmtx_table_size, loca_table_size, glyf_table_size; + /* some information available from other TrueType table */ + struct tt_head_table *head = NULL; + struct tt_hhea_table *hhea = NULL; + struct tt_maxp_table *maxp = NULL; + struct tt_longMetrics *hmtx, *vmtx = NULL; + struct tt_os2__table *os2; + /* temp */ + ULONG *location, offset; + long i; + USHORT *w_stat; /* Estimate most frequently appeared width */ + + ASSERT(g); + + if (sfont->type != SFNT_TYPE_TRUETYPE && sfont->type != SFNT_TYPE_TTC) + TT_ERROR("Invalid font type"); + + if (g->num_glyphs > NUM_GLYPH_LIMIT) + TT_ERROR("Too many glyphs."); + + /* + Read head, hhea, maxp, loca: + + unitsPerEm --> head + + numHMetrics --> hhea + + indexToLocFormat --> head + + numGlyphs --> maxp + */ + head = tt_read_head_table(sfont); + hhea = tt_read_hhea_table(sfont); + maxp = tt_read_maxp_table(sfont); + + if (hhea->metricDataFormat != 0) + TT_ERROR("Unknown metricDataFormat."); + + g->emsize = head->unitsPerEm; + + sfnt_locate_table(sfont, "hmtx"); + hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); + + os2 = tt_read_os2__table(sfont); + if (os2) { + g->default_advh = (USHORT) (os2->sTypoAscender - os2->sTypoDescender); + g->default_tsb = (SHORT) (g->default_advh - os2->sTypoAscender); + + /* dvipdfmx does this elsewhere! */ + fd_cur->font_dim[STEMV_CODE].val = + (os2->usWeightClass / 65) * (os2->usWeightClass / 65) + 50; + } + + if (sfnt_find_table_pos(sfont, "vmtx") > 0) { + struct tt_vhea_table *vhea; + vhea = tt_read_vhea_table(sfont); + sfnt_locate_table(sfont, "vmtx"); + vmtx = + tt_read_longMetrics(sfont, maxp->numGlyphs, + vhea->numOfLongVerMetrics); + RELEASE(vhea); + } else { + vmtx = NULL; + } + + sfnt_locate_table(sfont, "loca"); + location = NEW(maxp->numGlyphs + 1, ULONG); + if (head->indexToLocFormat == 0) { + for (i = 0; i <= maxp->numGlyphs; i++) + location[i] = 2 * ((ULONG) sfnt_get_ushort(sfont)); + } else if (head->indexToLocFormat == 1) { + for (i = 0; i <= maxp->numGlyphs; i++) + location[i] = sfnt_get_ulong(sfont); + } else { + TT_ERROR("Unknown IndexToLocFormat."); + } + + w_stat = NEW(g->emsize + 2, USHORT); + memset(w_stat, 0, + (size_t) (sizeof(USHORT) * ((long unsigned) g->emsize + 2))); + /* + * Read glyf table. + */ + offset = sfnt_locate_table(sfont, "glyf"); + /* + The |num_glyphs| may grow when composite glyph is found. + A component of glyph refered by a composite glyph is appended + to |used_glyphs| if it is not already registered in |used_glyphs|. + Glyph programs of composite glyphs are modified so that it + correctly refer to new gid of their components. + */ + for (i = 0; i < NUM_GLYPH_LIMIT; i++) { + USHORT gid; /* old gid */ + ULONG loc, len; + BYTE *p, *endptr; + SHORT number_of_contours; + + if (i >= g->num_glyphs) /* finished */ + break; + + gid = g->gd[i].ogid; + if (gid >= maxp->numGlyphs) + TT_ERROR("Invalid glyph index (gid %u)", gid); + + loc = location[gid]; + len = location[gid + 1] - loc; + g->gd[i].advw = hmtx[gid].advance; + g->gd[i].lsb = hmtx[gid].sideBearing; + if (vmtx) { + g->gd[i].advh = vmtx[gid].advance; + g->gd[i].tsb = vmtx[gid].sideBearing; + } else { + g->gd[i].advh = g->default_advh; + g->gd[i].tsb = g->default_tsb; + } + g->gd[i].length = len; + g->gd[i].data = NULL; + if (g->gd[i].advw <= g->emsize) { + w_stat[g->gd[i].advw]++; + } else { + w_stat[g->emsize + 1]++; /* larger than em */ + } + + if (len == 0) { /* Does not contains any data. */ + continue; + } else if (len < 10) { + TT_ERROR("Invalid TrueType glyph data (gid %u).", gid); + } + + g->gd[i].data = p = NEW(len, BYTE); + endptr = p + len; + + sfnt_seek_set(sfont, (long) (offset + loc)); + number_of_contours = sfnt_get_short(sfont); + p += sfnt_put_short(p, number_of_contours); + + /* BoundingBox: FWord x 4 */ + g->gd[i].llx = sfnt_get_short(sfont); + g->gd[i].lly = sfnt_get_short(sfont); + g->gd[i].urx = sfnt_get_short(sfont); + g->gd[i].ury = sfnt_get_short(sfont); + /* |_FIXME_| */ +#if 1 + if (!vmtx) /* |vertOriginY == sTypeAscender| */ + g->gd[i].tsb = + (SHORT) (g->default_advh - g->default_tsb - g->gd[i].ury); +#endif + p += sfnt_put_short(p, g->gd[i].llx); + p += sfnt_put_short(p, g->gd[i].lly); + p += sfnt_put_short(p, g->gd[i].urx); + p += sfnt_put_short(p, g->gd[i].ury); + + /* Read evrything else. */ + sfnt_read(p, (int) len - 10, sfont); + /* + Fix GIDs of composite glyphs. + */ + if (number_of_contours < 0) { + USHORT flags, cgid, new_gid; /* flag, gid of a component */ + do { + if (p >= endptr) + TT_ERROR("Invalid TrueType glyph data (gid %u): %u bytes", + gid, (unsigned int) len); + /* + * Flags and gid of component glyph are both USHORT. + */ + flags = (USHORT) (((*p) << 8) | *(p + 1)); + p += 2; + cgid = (USHORT) (((*p) << 8) | *(p + 1)); + if (cgid >= maxp->numGlyphs) { + TT_ERROR("Invalid gid (%u > %u) in composite glyph %u.", + cgid, maxp->numGlyphs, gid); + } + new_gid = tt_find_glyph(g, cgid); + if (new_gid == 0) { + new_gid = tt_add_glyph(g, cgid, find_empty_slot(g)); + } + p += sfnt_put_ushort(p, new_gid); + /* + * Just skip remaining part. + */ + p += (flags & ARG_1_AND_2_ARE_WORDS) ? 4 : 2; + if (flags & WE_HAVE_A_SCALE) /* F2Dot14 */ + p += 2; + else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) /* F2Dot14 x 2 */ + p += 4; + else if (flags & WE_HAVE_A_TWO_BY_TWO) /* F2Dot14 x 4 */ + p += 8; + } while (flags & MORE_COMPONENTS); + /* + TrueType instructions comes here: + + |length_of_instruction| (|ushort|) + + instruction (|byte * length_of_instruction|) + */ + } + } + RELEASE(location); + RELEASE(hmtx); + if (vmtx) + RELEASE(vmtx); + + { + int max_count = -1; + + g->dw = g->gd[0].advw; + for (i = 0; i < g->emsize + 1; i++) { + if (w_stat[i] > max_count) { + max_count = w_stat[i]; + g->dw = (USHORT) i; + } + } + } + RELEASE(w_stat); + + qsort(g->gd, g->num_glyphs, sizeof(struct tt_glyph_desc), glyf_cmp); + { + USHORT prev, last_advw; + char *p, *q; + int padlen, num_hm_known; + + glyf_table_size = 0UL; + num_hm_known = 0; + last_advw = g->gd[g->num_glyphs - 1].advw; + for (i = g->num_glyphs - 1; i >= 0; i--) { + padlen = + (int) ((g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0); + glyf_table_size += (ULONG) (g->gd[i].length + (ULONG) padlen); + if (!num_hm_known && last_advw != g->gd[i].advw) { + hhea->numberOfHMetrics = (USHORT) (g->gd[i].gid + 2); + num_hm_known = 1; + } + } + /* All advance widths are same. */ + if (!num_hm_known) { + hhea->numberOfHMetrics = 1; + } + hmtx_table_size = + (ULONG) (hhea->numberOfHMetrics * 2 + (g->last_gid + 1) * 2); + + /* + Choosing short format does not always give good result + when compressed. Sometimes increases size. + */ + if (glyf_table_size < 0x20000UL) { + head->indexToLocFormat = 0; + loca_table_size = (ULONG) ((g->last_gid + 2) * 2); + } else { + head->indexToLocFormat = 1; + loca_table_size = (ULONG) ((g->last_gid + 2) * 4); + } + + hmtx_table_data = p = NEW(hmtx_table_size, char); + loca_table_data = q = NEW(loca_table_size, char); + glyf_table_data = NEW(glyf_table_size, char); + + offset = 0UL; + prev = 0; + for (i = 0; i < g->num_glyphs; i++) { + long gap, j; + gap = (long) g->gd[i].gid - prev - 1; + for (j = 1; j <= gap; j++) { + if (prev + j == hhea->numberOfHMetrics - 1) { + p += sfnt_put_ushort(p, last_advw); + } else if (prev + j < hhea->numberOfHMetrics) { + p += sfnt_put_ushort(p, 0); + } + p += sfnt_put_short(p, 0); + if (head->indexToLocFormat == 0) { + q += sfnt_put_ushort(q, (USHORT) (offset / 2)); + } else { + q += sfnt_put_ulong(q, (LONG) offset); + } + } + padlen = + (int) ((g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0); + if (g->gd[i].gid < hhea->numberOfHMetrics) { + p += sfnt_put_ushort(p, g->gd[i].advw); + } + p += sfnt_put_short(p, g->gd[i].lsb); + if (head->indexToLocFormat == 0) { + q += sfnt_put_ushort(q, (USHORT) (offset / 2)); + } else { + q += sfnt_put_ulong(q, (LONG) offset); + } + memset(glyf_table_data + offset, 0, + (size_t) (g->gd[i].length + (ULONG) padlen)); + memcpy(glyf_table_data + offset, g->gd[i].data, g->gd[i].length); + offset += (g->gd[i].length + (ULONG) padlen); + prev = g->gd[i].gid; + /* free data here since it consume much memory */ + RELEASE(g->gd[i].data); + g->gd[i].length = 0; + g->gd[i].data = NULL; + } + if (head->indexToLocFormat == 0) { + q += sfnt_put_ushort(q, (USHORT) (offset / 2)); + } else { + q += sfnt_put_ulong(q, (LONG) offset); + } + + sfnt_set_table(sfont, "hmtx", (char *) hmtx_table_data, + hmtx_table_size); + sfnt_set_table(sfont, "loca", (char *) loca_table_data, + loca_table_size); + sfnt_set_table(sfont, "glyf", (char *) glyf_table_data, + glyf_table_size); + } + + head->checkSumAdjustment = 0; + maxp->numGlyphs = (USHORT) (g->last_gid + 1); + + /* TODO */ + sfnt_set_table(sfont, "maxp", tt_pack_maxp_table(maxp), TT_MAXP_TABLE_SIZE); + sfnt_set_table(sfont, "hhea", tt_pack_hhea_table(hhea), TT_HHEA_TABLE_SIZE); + sfnt_set_table(sfont, "head", tt_pack_head_table(head), TT_HEAD_TABLE_SIZE); + RELEASE(maxp); + RELEASE(hhea); + RELEASE(head); + if (os2) + RELEASE(os2); + + return 0; +} + +int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) +{ + struct tt_head_table *head = NULL; + struct tt_hhea_table *hhea = NULL; + struct tt_maxp_table *maxp = NULL; + struct tt_longMetrics *hmtx, *vmtx = NULL; + struct tt_os2__table *os2; + /* temp */ + ULONG *location, offset; + long i; + USHORT *w_stat; + + ASSERT(g); + + if (sfont == NULL || +#ifdef XETEX + sfont->ft_face == NULL +#elif defined(pdfTeX) + sfont->buffer == NULL +#else + sfont->stream == NULL +#endif + ) + TT_ERROR("File not opened."); + + if (sfont->type != SFNT_TYPE_TRUETYPE && sfont->type != SFNT_TYPE_TTC) + TT_ERROR("Invalid font type"); + + /* + Read head, hhea, maxp, loca: + + unitsPerEm --> head + + numHMetrics --> hhea + + indexToLocFormat --> head + + numGlyphs --> maxp + */ + head = tt_read_head_table(sfont); + hhea = tt_read_hhea_table(sfont); + maxp = tt_read_maxp_table(sfont); + + if (hhea->metricDataFormat != 0) + TT_ERROR("Unknown metricDataFormat."); + + g->emsize = head->unitsPerEm; + + sfnt_locate_table(sfont, "hmtx"); + hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); + + os2 = tt_read_os2__table(sfont); + g->default_advh = (USHORT) (os2->sTypoAscender - os2->sTypoDescender); + g->default_tsb = (SHORT) (g->default_advh - os2->sTypoAscender); + + if (sfnt_find_table_pos(sfont, "vmtx") > 0) { + struct tt_vhea_table *vhea; + vhea = tt_read_vhea_table(sfont); + sfnt_locate_table(sfont, "vmtx"); + vmtx = + tt_read_longMetrics(sfont, maxp->numGlyphs, + vhea->numOfLongVerMetrics); + RELEASE(vhea); + } else { + vmtx = NULL; + } + + sfnt_locate_table(sfont, "loca"); + location = NEW(maxp->numGlyphs + 1, ULONG); + if (head->indexToLocFormat == 0) { + for (i = 0; i <= maxp->numGlyphs; i++) + location[i] = 2 * ((ULONG) sfnt_get_ushort(sfont)); + } else if (head->indexToLocFormat == 1) { + for (i = 0; i <= maxp->numGlyphs; i++) + location[i] = sfnt_get_ulong(sfont); + } else { + TT_ERROR("Unknown IndexToLocFormat."); + } + + w_stat = NEW(g->emsize + 2, USHORT); + memset(w_stat, 0, (size_t) ((int) sizeof(USHORT) * (g->emsize + 2))); + /* + Read glyf table. + */ + offset = sfnt_locate_table(sfont, "glyf"); + for (i = 0; i < g->num_glyphs; i++) { + USHORT gid; /* old gid */ + ULONG loc, len; + SHORT number_of_contours; + + gid = g->gd[i].ogid; + if (gid >= maxp->numGlyphs) + TT_ERROR("Invalid glyph index (gid %u)", gid); + + loc = location[gid]; + len = location[gid + 1] - loc; + g->gd[i].advw = hmtx[gid].advance; + g->gd[i].lsb = hmtx[gid].sideBearing; + if (vmtx) { + g->gd[i].advh = vmtx[gid].advance; + g->gd[i].tsb = vmtx[gid].sideBearing; + } else { + g->gd[i].advh = g->default_advh; + g->gd[i].tsb = g->default_tsb; + } + g->gd[i].length = len; + g->gd[i].data = NULL; + + if (g->gd[i].advw <= g->emsize) { + w_stat[g->gd[i].advw]++; + } else { + w_stat[g->emsize + 1]++; /* larger than em */ + } + + if (len == 0) { /* Does not contains any data. */ + continue; + } else if (len < 10) { + TT_ERROR("Invalid TrueType glyph data (gid %u).", gid); + } + + sfnt_seek_set(sfont, (long) (offset + loc)); + number_of_contours = sfnt_get_short(sfont); + + /* BoundingBox: FWord x 4 */ + g->gd[i].llx = sfnt_get_short(sfont); + g->gd[i].lly = sfnt_get_short(sfont); + g->gd[i].urx = sfnt_get_short(sfont); + g->gd[i].ury = sfnt_get_short(sfont); + /* |_FIXME_| */ +#if 1 + if (!vmtx) /* |vertOriginY == sTypeAscender| */ + g->gd[i].tsb = + (SHORT) (g->default_advh - g->default_tsb - g->gd[i].ury); +#endif + } + RELEASE(location); + RELEASE(hmtx); + RELEASE(maxp); + RELEASE(hhea); + RELEASE(head); + RELEASE(os2); + + if (vmtx) + RELEASE(vmtx); + + { + int max_count = -1; + + g->dw = g->gd[0].advw; + for (i = 0; i < g->emsize + 1; i++) { + if (w_stat[i] > max_count) { + max_count = w_stat[i]; + g->dw = (USHORT) i; + } + } + } + RELEASE(w_stat); + + + return 0; +} diff --git a/Build/source/texk/web2c/luatexdir/font/tt_table.c b/Build/source/texk/web2c/luatexdir/font/tt_table.c deleted file mode 100644 index d979542b476..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/tt_table.c +++ /dev/null @@ -1,476 +0,0 @@ -/* tt_table.c - - Copyright 2002 by Jin-Hwan Cho and Shunsaku Hirata, - the dvipdfmx project team - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include - -#ifndef pdfTeX -# include "system.h" -# include "error.h" -# include "mem.h" -# include "mfileio.h" -#else -# include "ptexlib.h" -#endif - -#include "sfnt.h" -#include "tt_table.h" - -static const char _svn_version[] = - "$Id: tt_table.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/tt_table.c $"; - -/* - tables contains information refered by other tables - maxp->numGlyphs, etc --> loca, etc - hhea->numberOfHMetrics --> hmtx - head->indexToLocFormat --> loca - head->glyphDataFormat --> glyf -*/ - -char *tt_pack_head_table(struct tt_head_table *table) -{ - int i; - char *p, *data; - - if (table == NULL) - TT_ERROR("passed NULL pointer\n"); - - p = data = NEW(TT_HEAD_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); - p += sfnt_put_ulong(p, table->fontRevision); - p += sfnt_put_ulong(p, table->checkSumAdjustment); - p += sfnt_put_ulong(p, table->magicNumber); - p += sfnt_put_ushort(p, table->flags); - p += sfnt_put_ushort(p, table->unitsPerEm); - for (i = 0; i < 8; i++) { - *(p++) = (table->created)[i]; - } - for (i = 0; i < 8; i++) { - *(p++) = (table->modified)[i]; - } - p += sfnt_put_short(p, table->xMin); - p += sfnt_put_short(p, table->yMin); - p += sfnt_put_short(p, table->xMax); - p += sfnt_put_short(p, table->yMax); - p += sfnt_put_ushort(p, table->macStyle); - p += sfnt_put_ushort(p, table->lowestRecPPEM); - p += sfnt_put_short(p, table->fontDirectionHint); - p += sfnt_put_short(p, table->indexToLocFormat); - p += sfnt_put_short(p, table->glyphDataFormat); - - return data; -} - -struct tt_head_table *tt_read_head_table(sfnt * sfont) -{ - int i; - struct tt_head_table *table = NULL; - - table = NEW(1, struct tt_head_table); - - sfnt_locate_table(sfont, "head"); - - table->version = sfnt_get_ulong(sfont); - table->fontRevision = sfnt_get_ulong(sfont); - table->checkSumAdjustment = sfnt_get_ulong(sfont); - table->magicNumber = sfnt_get_ulong(sfont); - table->flags = sfnt_get_ushort(sfont); - table->unitsPerEm = sfnt_get_ushort(sfont); - for (i = 0; i < 8; i++) { - (table->created)[i] = sfnt_get_byte(sfont); - } - for (i = 0; i < 8; i++) { - (table->modified)[i] = sfnt_get_byte(sfont); - } - table->xMin = sfnt_get_short(sfont); - table->yMin = sfnt_get_short(sfont); - table->xMax = sfnt_get_short(sfont); - table->yMax = sfnt_get_short(sfont); - table->macStyle = sfnt_get_short(sfont); - table->lowestRecPPEM = sfnt_get_short(sfont); - table->fontDirectionHint = sfnt_get_short(sfont); - table->indexToLocFormat = sfnt_get_short(sfont); - table->glyphDataFormat = sfnt_get_short(sfont); - - return table; -} - -char *tt_pack_maxp_table(struct tt_maxp_table *table) -{ - char *p, *data; - - p = data = NEW(TT_MAXP_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); - p += sfnt_put_ushort(p, table->numGlyphs); - p += sfnt_put_ushort(p, table->maxPoints); - p += sfnt_put_ushort(p, table->maxContours); - p += sfnt_put_ushort(p, table->maxComponentPoints); - p += sfnt_put_ushort(p, table->maxComponentContours); - p += sfnt_put_ushort(p, table->maxZones); - p += sfnt_put_ushort(p, table->maxTwilightPoints); - p += sfnt_put_ushort(p, table->maxStorage); - p += sfnt_put_ushort(p, table->maxFunctionDefs); - p += sfnt_put_ushort(p, table->maxInstructionDefs); - p += sfnt_put_ushort(p, table->maxStackElements); - p += sfnt_put_ushort(p, table->maxSizeOfInstructions); - p += sfnt_put_ushort(p, table->maxComponentElements); - p += sfnt_put_ushort(p, table->maxComponentDepth); - - return data; -} - -struct tt_maxp_table *tt_read_maxp_table(sfnt * sfont) -{ - struct tt_maxp_table *table = NULL; - - table = NEW(1, struct tt_maxp_table); - - sfnt_locate_table(sfont, "maxp"); - table->version = sfnt_get_ulong(sfont); - table->numGlyphs = sfnt_get_ushort(sfont); - table->maxPoints = sfnt_get_ushort(sfont); - table->maxContours = sfnt_get_ushort(sfont); - table->maxComponentPoints = sfnt_get_ushort(sfont); - table->maxComponentContours = sfnt_get_ushort(sfont); - table->maxZones = sfnt_get_ushort(sfont); - table->maxTwilightPoints = sfnt_get_ushort(sfont); - table->maxStorage = sfnt_get_ushort(sfont); - table->maxFunctionDefs = sfnt_get_ushort(sfont); - table->maxInstructionDefs = sfnt_get_ushort(sfont); - table->maxStackElements = sfnt_get_ushort(sfont); - table->maxSizeOfInstructions = sfnt_get_ushort(sfont); - table->maxComponentElements = sfnt_get_ushort(sfont); - table->maxComponentDepth = sfnt_get_ushort(sfont); - - return table; -} - -char *tt_pack_hhea_table(struct tt_hhea_table *table) -{ - int i; - char *p, *data; - - p = data = NEW(TT_HHEA_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); - p += sfnt_put_short(p, table->Ascender); - p += sfnt_put_short(p, table->Descender); - p += sfnt_put_short(p, table->LineGap); - p += sfnt_put_ushort(p, table->advanceWidthMax); - p += sfnt_put_short(p, table->minLeftSideBearing); - p += sfnt_put_short(p, table->minRightSideBearing); - p += sfnt_put_short(p, table->xMaxExtent); - p += sfnt_put_short(p, table->caretSlopeRise); - p += sfnt_put_short(p, table->caretSlopeRun); - for (i = 0; i < 5; i++) { - p += sfnt_put_short(p, table->reserved[i]); - } - p += sfnt_put_short(p, table->metricDataFormat); - p += sfnt_put_ushort(p, table->numberOfHMetrics); - - return data; -} - -struct tt_hhea_table *tt_read_hhea_table(sfnt * sfont) -{ - int i; - struct tt_hhea_table *table = NULL; - - table = NEW(1, struct tt_hhea_table); - - sfnt_locate_table(sfont, "hhea"); - table->version = sfnt_get_ulong(sfont); - table->Ascender = sfnt_get_short(sfont); - table->Descender = sfnt_get_short(sfont); - table->LineGap = sfnt_get_short(sfont); - table->advanceWidthMax = sfnt_get_ushort(sfont); - table->minLeftSideBearing = sfnt_get_short(sfont); - table->minRightSideBearing = sfnt_get_short(sfont); - table->xMaxExtent = sfnt_get_short(sfont); - table->caretSlopeRise = sfnt_get_short(sfont); - table->caretSlopeRun = sfnt_get_short(sfont); - for (i = 0; i < 5; i++) { - table->reserved[i] = sfnt_get_short(sfont); - } - table->metricDataFormat = sfnt_get_short(sfont); - if (table->metricDataFormat != 0) - TT_ERROR("unknown metricDaraFormat"); - table->numberOfHMetrics = sfnt_get_ushort(sfont); - - return table; -} - -/* vhea */ -char *tt_pack_vhea_table(struct tt_vhea_table *table) -{ - int i; - char *p, *data; - - p = data = NEW(TT_VHEA_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); - p += sfnt_put_short(p, table->vertTypoAscender); - p += sfnt_put_short(p, table->vertTypoDescender); - p += sfnt_put_short(p, table->vertTypoLineGap); - p += sfnt_put_short(p, table->advanceHeightMax); /* ushort ? */ - p += sfnt_put_short(p, table->minTopSideBearing); - p += sfnt_put_short(p, table->minBottomSideBearing); - p += sfnt_put_short(p, table->yMaxExtent); - p += sfnt_put_short(p, table->caretSlopeRise); - p += sfnt_put_short(p, table->caretSlopeRun); - p += sfnt_put_short(p, table->caretOffset); - for (i = 0; i < 5; i++) { - p += sfnt_put_short(p, table->reserved[i]); - } - p += sfnt_put_ushort(p, table->numOfLongVerMetrics); - - return data; -} - -struct tt_vhea_table *tt_read_vhea_table(sfnt * sfont) -{ - int i; - struct tt_vhea_table *table = NULL; - - table = NEW(1, struct tt_vhea_table); - - sfnt_locate_table(sfont, "vhea"); - table->version = sfnt_get_ulong(sfont); - table->vertTypoAscender = sfnt_get_short(sfont); - table->vertTypoDescender = sfnt_get_short(sfont); - table->vertTypoLineGap = sfnt_get_short(sfont); - table->advanceHeightMax = sfnt_get_short(sfont); /* ushort ? */ - table->minTopSideBearing = sfnt_get_short(sfont); - table->minBottomSideBearing = sfnt_get_short(sfont); - table->yMaxExtent = sfnt_get_short(sfont); - table->caretSlopeRise = sfnt_get_short(sfont); - table->caretSlopeRun = sfnt_get_short(sfont); - table->caretOffset = sfnt_get_short(sfont); - for (i = 0; i < 5; i++) { - (table->reserved)[i] = sfnt_get_short(sfont); - } - table->numOfLongVerMetrics = sfnt_get_ushort(sfont); - - return table; -} - - -struct tt_VORG_table *tt_read_VORG_table(sfnt * sfont) -{ - struct tt_VORG_table *vorg; - ULONG offset; - USHORT i; - - offset = sfnt_find_table_pos(sfont, "VORG"); - - if (offset > 0) { - vorg = NEW(1, struct tt_VORG_table); - - sfnt_locate_table(sfont, "VORG"); - if (sfnt_get_ushort(sfont) != 1 || sfnt_get_ushort(sfont) != 0) - TT_ERROR("Unsupported VORG version."); - - vorg->defaultVertOriginY = sfnt_get_short(sfont); - vorg->numVertOriginYMetrics = sfnt_get_ushort(sfont); - vorg->vertOriginYMetrics = NEW(vorg->numVertOriginYMetrics, - struct tt_vertOriginYMetrics); - /* - * The vertOriginYMetrics array must be sorted in increasing - * glyphIndex order. - */ - for (i = 0; i < vorg->numVertOriginYMetrics; i++) { - vorg->vertOriginYMetrics[i].glyphIndex = sfnt_get_ushort(sfont); - vorg->vertOriginYMetrics[i].vertOriginY = sfnt_get_short(sfont); - } - } else { - vorg = NULL; - } - - return vorg; -} - -/* - * hmtx and vmtx - * - * Reading/writing hmtx and vmtx depend on other tables, maxp and hhea/vhea. - */ - -struct tt_longMetrics *tt_read_longMetrics(sfnt * sfont, USHORT numGlyphs, - USHORT numLongMetrics) -{ - struct tt_longMetrics *m; - USHORT gid, last_adv = 0; - - m = NEW(numGlyphs, struct tt_longMetrics); - for (gid = 0; gid < numGlyphs; gid++) { - if (gid < numLongMetrics) - last_adv = sfnt_get_ushort(sfont); - m[gid].sideBearing = sfnt_get_short(sfont); - m[gid].advance = last_adv; - } - - return m; -} - -/* OS/2 table */ -/* this table may not exist */ -struct tt_os2__table *tt_read_os2__table(sfnt * sfont) -{ - struct tt_os2__table *table = NULL; - int i; - - if (sfnt_find_table_pos(sfont, "OS/2") == 0) - return NULL; - - sfnt_locate_table(sfont, "OS/2"); - - table = NEW(1, struct tt_os2__table); - - table->version = sfnt_get_ushort(sfont); - table->xAvgCharWidth = sfnt_get_short(sfont); - table->usWeightClass = sfnt_get_ushort(sfont); - table->usWidthClass = sfnt_get_ushort(sfont); - table->fsType = sfnt_get_short(sfont); - table->ySubscriptXSize = sfnt_get_short(sfont); - table->ySubscriptYSize = sfnt_get_short(sfont); - table->ySubscriptXOffset = sfnt_get_short(sfont); - table->ySubscriptYOffset = sfnt_get_short(sfont); - table->ySuperscriptXSize = sfnt_get_short(sfont); - table->ySuperscriptYSize = sfnt_get_short(sfont); - table->ySuperscriptXOffset = sfnt_get_short(sfont); - table->ySuperscriptYOffset = sfnt_get_short(sfont); - table->yStrikeoutSize = sfnt_get_short(sfont); - table->yStrikeoutPosition = sfnt_get_short(sfont); - table->sFamilyClass = sfnt_get_short(sfont); - for (i = 0; i < 10; i++) { - table->panose[i] = sfnt_get_byte(sfont); - } - table->ulUnicodeRange1 = sfnt_get_ulong(sfont); - table->ulUnicodeRange2 = sfnt_get_ulong(sfont); - table->ulUnicodeRange3 = sfnt_get_ulong(sfont); - table->ulUnicodeRange4 = sfnt_get_ulong(sfont); - for (i = 0; i < 4; i++) { - table->achVendID[i] = sfnt_get_char(sfont); - } - table->fsSelection = sfnt_get_ushort(sfont); - table->usFirstCharIndex = sfnt_get_ushort(sfont); - table->usLastCharIndex = sfnt_get_ushort(sfont); - table->sTypoAscender = sfnt_get_short(sfont); - table->sTypoDescender = sfnt_get_short(sfont); - table->sTypoLineGap = sfnt_get_short(sfont); - table->usWinAscent = sfnt_get_ushort(sfont); - table->usWinDescent = sfnt_get_ushort(sfont); - table->ulCodePageRange1 = sfnt_get_ulong(sfont); - table->ulCodePageRange2 = sfnt_get_ulong(sfont); - if (table->version == 0x0002) { - table->sxHeight = sfnt_get_short(sfont); - table->sCapHeight = sfnt_get_short(sfont); - table->usDefaultChar = sfnt_get_ushort(sfont); - table->usBreakChar = sfnt_get_ushort(sfont); - table->usMaxContext = sfnt_get_ushort(sfont); - } - - return table; -} - -USHORT -tt_get_name(sfnt * sfont, char *dest, USHORT destlen, - USHORT plat_id, USHORT enco_id, USHORT lang_id, USHORT name_id) -{ - USHORT length = 0; - USHORT num_names, string_offset; - ULONG name_offset; - int i; - - name_offset = sfnt_locate_table(sfont, "name"); - - if (sfnt_get_ushort(sfont)) - TT_ERROR("Expecting zero"); - - num_names = sfnt_get_ushort(sfont); - string_offset = sfnt_get_ushort(sfont); - for (i = 0; i < num_names; i++) { - USHORT p_id, e_id, n_id, l_id; - USHORT offset; - - p_id = sfnt_get_ushort(sfont); - e_id = sfnt_get_ushort(sfont); - l_id = sfnt_get_ushort(sfont); - n_id = sfnt_get_ushort(sfont); - length = sfnt_get_ushort(sfont); - offset = sfnt_get_ushort(sfont); - /* language ID value 0xffffu for `accept any language ID' */ - if ((p_id == plat_id) && (e_id == enco_id) && - (lang_id == 0xffffu || l_id == lang_id) && (n_id == name_id)) { - if (length > destlen - 1) { - fprintf(stderr, - "\n** Notice: Name string too long. Truncating **\n"); - length = destlen - 1; - } - sfnt_seek_set(sfont, name_offset + string_offset + offset); - sfnt_read((unsigned char *) dest, length, sfont); - dest[length] = '\0'; - break; - } - } - if (i == num_names) { - length = 0; - } - - return length; -} - -USHORT tt_get_ps_fontname(sfnt * sfont, char *dest, USHORT destlen) -{ - USHORT namelen = 0; - -#ifdef XETEX - - const char *name = FT_Get_Postscript_Name(sfont->ft_face); - namelen = strlen(name); - if (namelen > destlen - 1) { - strncpy(dest, name, destlen - 1); - dest[destlen] = 0; - } else - strcpy(dest, name); - -#else - - /* First try Mac-Roman PS name and then Win-Unicode PS name */ - if ((namelen = tt_get_name(sfont, dest, destlen, 1, 0, 0, 6)) != 0 || - (namelen = tt_get_name(sfont, dest, destlen, 3, 1, 0x409u, 6)) != 0 || - (namelen = tt_get_name(sfont, dest, destlen, 3, 5, 0x412u, 6)) != 0) - return namelen; - - fprintf(stderr, "\n** Warning: No valid PostScript name available **\n"); - /* - Wrokaround for some bad TTfonts: - Language ID value 0xffffu for `accept any language ID' - */ - if ((namelen = tt_get_name(sfont, dest, destlen, 1, 0, 0xffffu, 6)) == 0) { - /* - Finally falling back to Mac Roman name field. - Warning: Some bad Japanese TTfonts using SJIS encoded string in the - Mac Roman name field. - */ - namelen = tt_get_name(sfont, dest, destlen, 1, 0, 0, 1); - } -#endif - - return namelen; -} diff --git a/Build/source/texk/web2c/luatexdir/font/tt_table.w b/Build/source/texk/web2c/luatexdir/font/tt_table.w new file mode 100644 index 00000000000..35da4284ee8 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/tt_table.w @@ -0,0 +1,463 @@ +% tt_table.w +% +% Copyright 2002 by Jin-Hwan Cho and Shunsaku Hirata, +% the dvipdfmx project team +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include + +#include "ptexlib.h" +#include "font/sfnt.h" +#include "font/tt_table.h" + +static const char _svn_version[] = + "$Id: tt_table.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/tt_table.w $"; + +@ tables contains information refered by other tables + + |maxp->numGlyphs, etc --> loca, etc| + + |hhea->numberOfHMetrics --> hmtx| + + |head->indexToLocFormat --> loca| + + |head->glyphDataFormat --> glyf| + +@c +char *tt_pack_head_table(struct tt_head_table *table) +{ + int i; + char *p, *data; + + if (table == NULL) + TT_ERROR("passed NULL pointer\n"); + + p = data = NEW(TT_HEAD_TABLE_SIZE, char); + p += sfnt_put_ulong(p, (LONG) table->version); + p += sfnt_put_ulong(p, (LONG) table->fontRevision); + p += sfnt_put_ulong(p, (LONG) table->checkSumAdjustment); + p += sfnt_put_ulong(p, (LONG) table->magicNumber); + p += sfnt_put_ushort(p, table->flags); + p += sfnt_put_ushort(p, table->unitsPerEm); + for (i = 0; i < 8; i++) { + *(p++) = (char) (table->created)[i]; + } + for (i = 0; i < 8; i++) { + *(p++) = (char) (table->modified)[i]; + } + p += sfnt_put_short(p, table->xMin); + p += sfnt_put_short(p, table->yMin); + p += sfnt_put_short(p, table->xMax); + p += sfnt_put_short(p, table->yMax); + p += sfnt_put_ushort(p, table->macStyle); + p += sfnt_put_ushort(p, table->lowestRecPPEM); + p += sfnt_put_short(p, table->fontDirectionHint); + p += sfnt_put_short(p, table->indexToLocFormat); + p += sfnt_put_short(p, table->glyphDataFormat); + + return data; +} + +struct tt_head_table *tt_read_head_table(sfnt * sfont) +{ + int i; + struct tt_head_table *table = NULL; + + table = NEW(1, struct tt_head_table); + + sfnt_locate_table(sfont, "head"); + + table->version = sfnt_get_ulong(sfont); + table->fontRevision = sfnt_get_ulong(sfont); + table->checkSumAdjustment = sfnt_get_ulong(sfont); + table->magicNumber = sfnt_get_ulong(sfont); + table->flags = sfnt_get_ushort(sfont); + table->unitsPerEm = sfnt_get_ushort(sfont); + for (i = 0; i < 8; i++) { + (table->created)[i] = sfnt_get_byte(sfont); + } + for (i = 0; i < 8; i++) { + (table->modified)[i] = sfnt_get_byte(sfont); + } + table->xMin = sfnt_get_short(sfont); + table->yMin = sfnt_get_short(sfont); + table->xMax = sfnt_get_short(sfont); + table->yMax = sfnt_get_short(sfont); + table->macStyle = (USHORT) sfnt_get_short(sfont); + table->lowestRecPPEM = (USHORT) sfnt_get_short(sfont); + table->fontDirectionHint = sfnt_get_short(sfont); + table->indexToLocFormat = sfnt_get_short(sfont); + table->glyphDataFormat = sfnt_get_short(sfont); + + return table; +} + +char *tt_pack_maxp_table(struct tt_maxp_table *table) +{ + char *p, *data; + + p = data = NEW(TT_MAXP_TABLE_SIZE, char); + p += sfnt_put_ulong(p, (LONG) table->version); + p += sfnt_put_ushort(p, table->numGlyphs); + p += sfnt_put_ushort(p, table->maxPoints); + p += sfnt_put_ushort(p, table->maxContours); + p += sfnt_put_ushort(p, table->maxComponentPoints); + p += sfnt_put_ushort(p, table->maxComponentContours); + p += sfnt_put_ushort(p, table->maxZones); + p += sfnt_put_ushort(p, table->maxTwilightPoints); + p += sfnt_put_ushort(p, table->maxStorage); + p += sfnt_put_ushort(p, table->maxFunctionDefs); + p += sfnt_put_ushort(p, table->maxInstructionDefs); + p += sfnt_put_ushort(p, table->maxStackElements); + p += sfnt_put_ushort(p, table->maxSizeOfInstructions); + p += sfnt_put_ushort(p, table->maxComponentElements); + p += sfnt_put_ushort(p, table->maxComponentDepth); + + return data; +} + +struct tt_maxp_table *tt_read_maxp_table(sfnt * sfont) +{ + struct tt_maxp_table *table = NULL; + + table = NEW(1, struct tt_maxp_table); + + sfnt_locate_table(sfont, "maxp"); + table->version = sfnt_get_ulong(sfont); + table->numGlyphs = sfnt_get_ushort(sfont); + table->maxPoints = sfnt_get_ushort(sfont); + table->maxContours = sfnt_get_ushort(sfont); + table->maxComponentPoints = sfnt_get_ushort(sfont); + table->maxComponentContours = sfnt_get_ushort(sfont); + table->maxZones = sfnt_get_ushort(sfont); + table->maxTwilightPoints = sfnt_get_ushort(sfont); + table->maxStorage = sfnt_get_ushort(sfont); + table->maxFunctionDefs = sfnt_get_ushort(sfont); + table->maxInstructionDefs = sfnt_get_ushort(sfont); + table->maxStackElements = sfnt_get_ushort(sfont); + table->maxSizeOfInstructions = sfnt_get_ushort(sfont); + table->maxComponentElements = sfnt_get_ushort(sfont); + table->maxComponentDepth = sfnt_get_ushort(sfont); + + return table; +} + +char *tt_pack_hhea_table(struct tt_hhea_table *table) +{ + int i; + char *p, *data; + + p = data = NEW(TT_HHEA_TABLE_SIZE, char); + p += sfnt_put_ulong(p, (LONG) table->version); + p += sfnt_put_short(p, table->Ascender); + p += sfnt_put_short(p, table->Descender); + p += sfnt_put_short(p, table->LineGap); + p += sfnt_put_ushort(p, table->advanceWidthMax); + p += sfnt_put_short(p, table->minLeftSideBearing); + p += sfnt_put_short(p, table->minRightSideBearing); + p += sfnt_put_short(p, table->xMaxExtent); + p += sfnt_put_short(p, table->caretSlopeRise); + p += sfnt_put_short(p, table->caretSlopeRun); + for (i = 0; i < 5; i++) { + p += sfnt_put_short(p, table->reserved[i]); + } + p += sfnt_put_short(p, table->metricDataFormat); + p += sfnt_put_ushort(p, table->numberOfHMetrics); + + return data; +} + +struct tt_hhea_table *tt_read_hhea_table(sfnt * sfont) +{ + int i; + struct tt_hhea_table *table = NULL; + + table = NEW(1, struct tt_hhea_table); + + sfnt_locate_table(sfont, "hhea"); + table->version = sfnt_get_ulong(sfont); + table->Ascender = sfnt_get_short(sfont); + table->Descender = sfnt_get_short(sfont); + table->LineGap = sfnt_get_short(sfont); + table->advanceWidthMax = sfnt_get_ushort(sfont); + table->minLeftSideBearing = sfnt_get_short(sfont); + table->minRightSideBearing = sfnt_get_short(sfont); + table->xMaxExtent = sfnt_get_short(sfont); + table->caretSlopeRise = sfnt_get_short(sfont); + table->caretSlopeRun = sfnt_get_short(sfont); + for (i = 0; i < 5; i++) { + table->reserved[i] = sfnt_get_short(sfont); + } + table->metricDataFormat = sfnt_get_short(sfont); + if (table->metricDataFormat != 0) + TT_ERROR("unknown metricDaraFormat"); + table->numberOfHMetrics = sfnt_get_ushort(sfont); + + return table; +} + +@ vhea +@c +char *tt_pack_vhea_table(struct tt_vhea_table *table) +{ + int i; + char *p, *data; + + p = data = NEW(TT_VHEA_TABLE_SIZE, char); + p += sfnt_put_ulong(p, (LONG) table->version); + p += sfnt_put_short(p, table->vertTypoAscender); + p += sfnt_put_short(p, table->vertTypoDescender); + p += sfnt_put_short(p, table->vertTypoLineGap); + p += sfnt_put_short(p, table->advanceHeightMax); /* ushort ? */ + p += sfnt_put_short(p, table->minTopSideBearing); + p += sfnt_put_short(p, table->minBottomSideBearing); + p += sfnt_put_short(p, table->yMaxExtent); + p += sfnt_put_short(p, table->caretSlopeRise); + p += sfnt_put_short(p, table->caretSlopeRun); + p += sfnt_put_short(p, table->caretOffset); + for (i = 0; i < 5; i++) { + p += sfnt_put_short(p, table->reserved[i]); + } + p += sfnt_put_ushort(p, table->numOfLongVerMetrics); + + return data; +} + +struct tt_vhea_table *tt_read_vhea_table(sfnt * sfont) +{ + int i; + struct tt_vhea_table *table = NULL; + + table = NEW(1, struct tt_vhea_table); + + sfnt_locate_table(sfont, "vhea"); + table->version = sfnt_get_ulong(sfont); + table->vertTypoAscender = sfnt_get_short(sfont); + table->vertTypoDescender = sfnt_get_short(sfont); + table->vertTypoLineGap = sfnt_get_short(sfont); + table->advanceHeightMax = sfnt_get_short(sfont); /* ushort ? */ + table->minTopSideBearing = sfnt_get_short(sfont); + table->minBottomSideBearing = sfnt_get_short(sfont); + table->yMaxExtent = sfnt_get_short(sfont); + table->caretSlopeRise = sfnt_get_short(sfont); + table->caretSlopeRun = sfnt_get_short(sfont); + table->caretOffset = sfnt_get_short(sfont); + for (i = 0; i < 5; i++) { + (table->reserved)[i] = sfnt_get_short(sfont); + } + table->numOfLongVerMetrics = sfnt_get_ushort(sfont); + + return table; +} + + +struct tt_VORG_table *tt_read_VORG_table(sfnt * sfont) +{ + struct tt_VORG_table *vorg; + ULONG offset; + USHORT i; + + offset = sfnt_find_table_pos(sfont, "VORG"); + + if (offset > 0) { + vorg = NEW(1, struct tt_VORG_table); + + sfnt_locate_table(sfont, "VORG"); + if (sfnt_get_ushort(sfont) != 1 || sfnt_get_ushort(sfont) != 0) + TT_ERROR("Unsupported VORG version."); + + vorg->defaultVertOriginY = sfnt_get_short(sfont); + vorg->numVertOriginYMetrics = sfnt_get_ushort(sfont); + vorg->vertOriginYMetrics = NEW(vorg->numVertOriginYMetrics, + struct tt_vertOriginYMetrics); + /* + * The vertOriginYMetrics array must be sorted in increasing + * glyphIndex order. + */ + for (i = 0; i < vorg->numVertOriginYMetrics; i++) { + vorg->vertOriginYMetrics[i].glyphIndex = sfnt_get_ushort(sfont); + vorg->vertOriginYMetrics[i].vertOriginY = sfnt_get_short(sfont); + } + } else { + vorg = NULL; + } + + return vorg; +} + + +@ hmtx and vmtx + +Reading/writing hmtx and vmtx depend on other tables, maxp and hhea/vhea. + +@c +struct tt_longMetrics *tt_read_longMetrics(sfnt * sfont, USHORT numGlyphs, + USHORT numLongMetrics) +{ + struct tt_longMetrics *m; + USHORT gid, last_adv = 0; + + m = NEW(numGlyphs, struct tt_longMetrics); + for (gid = 0; gid < numGlyphs; gid++) { + if (gid < numLongMetrics) + last_adv = sfnt_get_ushort(sfont); + m[gid].sideBearing = sfnt_get_short(sfont); + m[gid].advance = last_adv; + } + + return m; +} + +@ OS/2 table + +this table may not exist +@c +struct tt_os2__table *tt_read_os2__table(sfnt * sfont) +{ + struct tt_os2__table *table = NULL; + int i; + + if (sfnt_find_table_pos(sfont, "OS/2") == 0) + return NULL; + + sfnt_locate_table(sfont, "OS/2"); + + table = NEW(1, struct tt_os2__table); + + table->version = sfnt_get_ushort(sfont); + table->xAvgCharWidth = sfnt_get_short(sfont); + table->usWeightClass = sfnt_get_ushort(sfont); + table->usWidthClass = sfnt_get_ushort(sfont); + table->fsType = sfnt_get_short(sfont); + table->ySubscriptXSize = sfnt_get_short(sfont); + table->ySubscriptYSize = sfnt_get_short(sfont); + table->ySubscriptXOffset = sfnt_get_short(sfont); + table->ySubscriptYOffset = sfnt_get_short(sfont); + table->ySuperscriptXSize = sfnt_get_short(sfont); + table->ySuperscriptYSize = sfnt_get_short(sfont); + table->ySuperscriptXOffset = sfnt_get_short(sfont); + table->ySuperscriptYOffset = sfnt_get_short(sfont); + table->yStrikeoutSize = sfnt_get_short(sfont); + table->yStrikeoutPosition = sfnt_get_short(sfont); + table->sFamilyClass = sfnt_get_short(sfont); + for (i = 0; i < 10; i++) { + table->panose[i] = sfnt_get_byte(sfont); + } + table->ulUnicodeRange1 = sfnt_get_ulong(sfont); + table->ulUnicodeRange2 = sfnt_get_ulong(sfont); + table->ulUnicodeRange3 = sfnt_get_ulong(sfont); + table->ulUnicodeRange4 = sfnt_get_ulong(sfont); + for (i = 0; i < 4; i++) { + table->achVendID[i] = sfnt_get_char(sfont); + } + table->fsSelection = sfnt_get_ushort(sfont); + table->usFirstCharIndex = sfnt_get_ushort(sfont); + table->usLastCharIndex = sfnt_get_ushort(sfont); + table->sTypoAscender = sfnt_get_short(sfont); + table->sTypoDescender = sfnt_get_short(sfont); + table->sTypoLineGap = sfnt_get_short(sfont); + table->usWinAscent = sfnt_get_ushort(sfont); + table->usWinDescent = sfnt_get_ushort(sfont); + table->ulCodePageRange1 = sfnt_get_ulong(sfont); + table->ulCodePageRange2 = sfnt_get_ulong(sfont); + if (table->version == 0x0002) { + table->sxHeight = sfnt_get_short(sfont); + table->sCapHeight = sfnt_get_short(sfont); + table->usDefaultChar = sfnt_get_ushort(sfont); + table->usBreakChar = sfnt_get_ushort(sfont); + table->usMaxContext = sfnt_get_ushort(sfont); + } + + return table; +} + +USHORT +tt_get_name(sfnt * sfont, char *dest, USHORT destlen, + USHORT plat_id, USHORT enco_id, USHORT lang_id, USHORT name_id) +{ + USHORT length = 0; + USHORT num_names, string_offset; + ULONG name_offset; + int i; + + name_offset = sfnt_locate_table(sfont, "name"); + + if (sfnt_get_ushort(sfont)) + TT_ERROR("Expecting zero"); + + num_names = sfnt_get_ushort(sfont); + string_offset = sfnt_get_ushort(sfont); + for (i = 0; i < num_names; i++) { + USHORT p_id, e_id, n_id, l_id; + USHORT offset; + + p_id = sfnt_get_ushort(sfont); + e_id = sfnt_get_ushort(sfont); + l_id = sfnt_get_ushort(sfont); + n_id = sfnt_get_ushort(sfont); + length = sfnt_get_ushort(sfont); + offset = sfnt_get_ushort(sfont); + /* language ID value 0xffffu for `accept any language ID' */ + if ((p_id == plat_id) && (e_id == enco_id) && + (lang_id == 0xffffu || l_id == lang_id) && (n_id == name_id)) { + if (length > destlen - 1) { + fprintf(stderr, + "\n** Notice: Name string too long. Truncating **\n"); + length = (USHORT) (destlen - 1); + } + sfnt_seek_set(sfont, (long) (name_offset + string_offset + offset)); + sfnt_read((unsigned char *) dest, length, sfont); + dest[length] = '\0'; + break; + } + } + if (i == num_names) { + length = 0; + } + + return length; +} + +USHORT tt_get_ps_fontname(sfnt * sfont, char *dest, USHORT destlen) +{ + USHORT namelen = 0; + + /* First try Mac-Roman PS name and then Win-Unicode PS name */ + if ((namelen = tt_get_name(sfont, dest, destlen, 1, 0, 0, 6)) != 0 || + (namelen = tt_get_name(sfont, dest, destlen, 3, 1, 0x409u, 6)) != 0 || + (namelen = tt_get_name(sfont, dest, destlen, 3, 5, 0x412u, 6)) != 0) + return namelen; + + fprintf(stderr, "\n** Warning: No valid PostScript name available **\n"); + /* + Wrokaround for some bad TTfonts: + Language ID value 0xffffu for `accept any language ID' + */ + if ((namelen = tt_get_name(sfont, dest, destlen, 1, 0, 0xffffu, 6)) == 0) { + /* + Finally falling back to Mac Roman name field. + Warning: Some bad Japanese TTfonts using SJIS encoded string in the + Mac Roman name field. + */ + namelen = tt_get_name(sfont, dest, destlen, 1, 0, 0, 1); + } + + return namelen; +} diff --git a/Build/source/texk/web2c/luatexdir/font/vfovf.c b/Build/source/texk/web2c/luatexdir/font/vfovf.c deleted file mode 100644 index 407076c215e..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/vfovf.c +++ /dev/null @@ -1,1636 +0,0 @@ -/* vfovf.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "luatex-api.h" -#include "luatexfont.h" -#include "inc-vfovf.h" - -static const char _svn_version[] = - "$Id: vfovf.c 2448 2009-06-08 07:43:50Z taco $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/vfovf.c $"; - -/* this is a hack! */ -#define font_max 5000 - -#define set_char_0 0 /* typeset character 0 and move right */ -#define set1 128 /* typeset a character and move right */ -#define set2 129 /* typeset a character and move right */ -#define set3 130 /* typeset a character and move right */ -#define set4 131 /* typeset a character and move right */ -#define set_rule 132 /* typeset a rule and move right */ -#define put1 133 /* typeset a character without moving */ -#define put2 134 /* typeset a character without moving */ -#define put3 135 /* typeset a character without moving */ -#define put4 136 /* typeset a character without moving */ -#define put_rule 137 /* typeset a rule */ -#define nop 138 /* no operation */ -#define bop 139 /* beginning of page */ -#define eop 140 /* ending of page */ -#define push 141 /* save the current positions */ -#define pop 142 /* restore previous positions */ -#define right1 143 /* move right */ -#define right2 144 /* move right */ -#define right3 145 /* move right */ -#define right4 146 /* move right, 4 bytes */ -#define w0 147 /* move right by |w| */ -#define w1 148 /* move right and set |w| */ -#define w2 149 /* move right and set |w| */ -#define w3 150 /* move right and set |w| */ -#define w4 151 /* move right and set |w| */ -#define x0 152 /* move right by |x| */ -#define x1 153 /* move right and set |x| */ -#define x2 154 /* move right and set |x| */ -#define x3 155 /* move right and set |x| */ -#define x4 156 /* move right and set |x| */ -#define down1 157 /* move down */ -#define down2 158 /* move down */ -#define down3 159 /* move down */ -#define down4 160 /* move down, 4 bytes */ -#define y0 161 /* move down by |y| */ -#define y1 162 /* move down and set |y| */ -#define y2 163 /* move down and set |y| */ -#define y3 164 /* move down and set |y| */ -#define y4 165 /* move down and set |y| */ -#define z0 166 /* move down by |z| */ -#define z1 167 /* move down and set |z| */ -#define z2 168 /* move down and set |z| */ -#define z3 169 /* move down and set |z| */ -#define z4 170 /* move down and set |z| */ -#define fnt_num_0 171 /* set current font to 0 */ -#define fnt1 235 /* set current font */ -#define fnt2 236 /* set current font */ -#define fnt3 237 /* set current font */ -#define fnt4 238 /* set current font */ -#define xxx1 239 /* extension to DVI primitives */ -#define xxx2 240 /* extension to DVI primitives */ -#define xxx3 241 /* extension to DVI primitives */ -#define xxx4 242 /* potentially long extension to DVI primitives */ -#define fnt_def1 243 /* define the meaning of a font number */ -#define pre 247 /* preamble */ -#define post 248 /* postamble beginning */ -#define post_post 249 /* postamble ending */ -#define yyy1 250 /* PDF literal text */ -#define yyy2 251 /* PDF literal text */ -#define yyy3 252 /* PDF literal text */ -#define yyy4 253 /* PDF literal text */ - -#define null_font 0 - -#define long_char 242 /* \.{VF} command for general character packet */ -#define vf_id 202 /* identifies \.{VF} files */ - -/* go out \.{VF} processing with an error message */ -#define bad_vf(a) { xfree(vf_buffer); print_nlp(); \ - print_string("Error in processing VF font ("); \ - print_string(font_name(f)); \ - print_string(".vf): "); \ - print_string(a); \ - print_string(", virtual font will be ignored"); \ - print_ln(); return; } - -#define lua_bad_vf(a) { xfree(vf_buffer); \ - lua_settop(L,s_top); \ - lua_pushnil(L); \ - lua_pushstring(L,a); \ - return 2; } - -#define tmp_b0 tmp_w.qqqq.b0 -#define tmp_b1 tmp_w.qqqq.b1 -#define tmp_b2 tmp_w.qqqq.b2 -#define tmp_b3 tmp_w.qqqq.b3 -#define tmp_int tmp_w.cint - -#define vf_stack_size 100 /* \.{DVI} files shouldn't |push| beyond this depth */ - -typedef unsigned char vf_stack_index; /* an index into the stack */ - -typedef struct vf_stack_record { - scaled stack_w, stack_x, stack_y, stack_z; -} vf_stack_record; - -boolean auto_expand_vf(internal_font_number f); /* forward */ - -/* get a byte from\.{VF} file */ - -#define vf_byte(a) \ -{ \ - real_eight_bits vf_tmp_b; \ - if (vf_cur >= vf_size) { \ - pdftex_fail("unexpected eof on virtual font"); \ - } \ - vf_tmp_b = vf_buffer[vf_cur++]; \ - a = vf_tmp_b; \ -} - -#define vf_replace_z() \ -{ \ - vf_alpha = 16; \ - while (vf_z >= 040000000) { \ - vf_z = vf_z / 2; \ - vf_alpha += vf_alpha; \ - } \ - vf_beta = 256 / vf_alpha; \ - vf_alpha = vf_alpha * vf_z; \ -} - -/* read |k| bytes as an integer from \.{VF} file */ -/* beware: the vf_read() macro differs from vf_read() in vftovp.web for 1...3 byte words */ - -#define vf_read(k, l) \ -{ \ - integer itmp = 0, dtmp = k, jtmp = 0; \ - while (dtmp > 0) { \ - vf_byte(jtmp); \ - if ((dtmp == (integer) k) && jtmp > 127) \ - jtmp = jtmp - 256; \ - itmp = itmp * 256 + jtmp; \ - decr(dtmp); \ - } \ - l = itmp; \ -} - -#define vf_read_u(k, l) \ -{ \ - unsigned int dtmp = k, itmp = 0, jtmp = 0; \ - while (dtmp-- > 0) { \ - vf_byte(jtmp); \ - itmp = itmp * 256 + jtmp; \ - } \ - l = itmp; \ -} - -void pdf_check_vf_cur_val(void) -{ - internal_font_number f; - f = cur_val; - if (font_type(f) == virtual_font_type) - pdf_error(maketexstring("font"), - maketexstring("command cannot be used with virtual font")); -} - -static void -vf_local_font_warning(internal_font_number f, internal_font_number k, const char *s, - integer a, integer b) -{ - print_nlp(); - print_string(s); - print_string(" in local font "); - print_string(font_name(k)); - print_string(" ("); - print_int(b); - print_string(" != "); - print_int(a); - print_string(") in virtual font "); - print_string(font_name(f)); - print_string(".vf ignored."); -} - - -/* process a local font in \.{VF} file */ - -static internal_font_number -vf_def_font(internal_font_number f, unsigned char *vf_buffer, integer * vf_cr) -{ - internal_font_number k; - str_number s; - scaled ds, fs; - four_quarters cs; - memory_word tmp_w; /* accumulator */ - integer junk; - unsigned long checksum; - cs.b0 = vf_buffer[(*vf_cr)]; - cs.b1 = vf_buffer[(*vf_cr) + 1]; - cs.b2 = vf_buffer[(*vf_cr) + 2]; - cs.b3 = vf_buffer[(*vf_cr) + 3]; - (*vf_cr) += 4; - checksum = - cs.b0 * 256 * 256 * 256 + cs.b1 * 256 * 256 + cs.b2 * 256 + cs.b3; - k = vf_buffer[(*vf_cr)]; - (*vf_cr)++; - if (k > 127) - k -= 256; - k = k * 256 + vf_buffer[(*vf_cr)]; - (*vf_cr)++; - k = k * 256 + vf_buffer[(*vf_cr)]; - (*vf_cr)++; - k = k * 256 + vf_buffer[(*vf_cr)]; - (*vf_cr)++; - - fs = store_scaled_f(k, font_size(f)); - - k = vf_buffer[(*vf_cr)]; - (*vf_cr)++; - if (k > 127) - k -= 256; - k = k * 256 + vf_buffer[(*vf_cr)]; - (*vf_cr)++; - k = k * 256 + vf_buffer[(*vf_cr)]; - (*vf_cr)++; - k = k * 256 + vf_buffer[(*vf_cr)]; - (*vf_cr)++; - - ds = k / 16; - - - tmp_b0 = vf_buffer[(*vf_cr)]; - (*vf_cr)++; - tmp_b1 = vf_buffer[(*vf_cr)]; - (*vf_cr)++; - while (tmp_b0 > 0) { - tmp_b0--; - (*vf_cr)++; /* skip the font path */ - } - string_room(tmp_b1); - while (tmp_b1 > 0) { - tmp_b1--; - junk = vf_buffer[(*vf_cr)]; - (*vf_cr)++; - append_pool_char(junk); - } - s = make_string(); - k = tfm_lookup(s, fs); - if (k == null_font) - k = read_font_info(get_nullcs(), s, fs, -1); - if (k != null_font) { - if (checksum != 0 && font_checksum(k) != 0 - && checksum != font_checksum(k)) - vf_local_font_warning(f, k, "checksum mismatch", checksum, - font_checksum(k)); - if (ds != font_dsize(k)) - vf_local_font_warning(f, k, "design size mismatch", ds, - font_dsize(k)); - } - if (pdf_font_expand_ratio(f) != 0) - set_expand_params(k, pdf_font_auto_expand(f), - pdf_font_expand_ratio(pdf_font_stretch(f)), - -pdf_font_expand_ratio(pdf_font_shrink(f)), - pdf_font_step(f), pdf_font_expand_ratio(f)); - return k; -} - - -static int open_vf_file(const char *fn, unsigned char **vbuffer, integer * vsize) -{ - boolean res; /* was the callback successful? */ - integer callback_id; - boolean file_read; /* was |vf_file| successfully read? */ - FILE *vf_file; - char *fnam = NULL; - - - - - namelength = strlen(fn); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), fn); - - callback_id = callback_defined(find_vf_file_callback); - if (callback_id > 0) { - res = run_callback(callback_id, "S->S", fn, &fnam); - if (res && (fnam != NULL) && (strlen(fnam) > 0)) { - /* @; */ - free(nameoffile); - namelength = strlen(fnam); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), fnam); - } else { - return 0; - } - } - callback_id = callback_defined(read_vf_file_callback); - if (callback_id > 0) { - file_read = false; - res = run_callback(callback_id, "S->bSd", stringcast(nameoffile + 1), - &file_read, vbuffer, vsize); - if (res && file_read && (*vsize > 0)) { - return 1; - } - if (!file_read) - return 0; /* -1 */ - } else { - if (ovf_b_open_in(vf_file) || vf_b_open_in(vf_file)) { - res = read_vf_file(vf_file, vbuffer, vsize); - b_close(vf_file); - if (res) { - return 1; - } - } else { - return 0; /* -1 */ - } - } - return 0; -} - - -/* - @ The |do_vf| procedure attempts to read the \.{VF} file for a font, and sets - |font_type()| to |real_font_type| if the \.{VF} file could not be found - or loaded, otherwise sets |font_type()| to |virtual_font_type|. At this - time, |tmp_f| is the internal font number of the current \.{TFM} font. To - process font definitions in virtual font we call |vf_def_font|. -*/ - -#define append_packet(k) vpackets[vf_np++] = k - -/* life is easier if all internal font commands are fnt4 and - all character commands are set4 or put4 */ - -#define append_fnt_set(k) \ -{ \ - assert(k > 0); \ - append_packet(packet_font_code); \ - append_four(k); \ -} - -#define append_four(k) \ -{ \ - append_packet((k & 0xFF000000) >> 24); \ - append_packet((k & 0x00FF0000) >> 16); \ - append_packet((k & 0x0000FF00) >> 8); \ - append_packet((k & 0x000000FF)); \ -} - -/* some of these things happen twice, adding a define is simplest */ - -#define test_checksum() { vf_byte(tmp_b0); vf_byte(tmp_b1); \ - vf_byte(tmp_b2); vf_byte(tmp_b3); \ - if (((tmp_b0 != 0) || (tmp_b1 != 0) || (tmp_b2 != 0) || (tmp_b3 != 0)) && \ - ((font_check_0(f) != 0) || (font_check_1(f) != 0) || \ - (font_check_2(f) != 0) || (font_check_3(f) != 0)) && \ - ((tmp_b0 != font_check_0(f)) || (tmp_b1 != font_check_1(f)) || \ - (tmp_b2 != font_check_2(f)) || (tmp_b3 != font_check_3(f)))) { \ - print_nlp(); \ - print_string("checksum mismatch in font "); \ - print_string(font_name(f)); \ - print_string(".vf ignored "); } } - -#define test_dsize() \ -{ \ - int read_tmp; \ - vf_read(4, read_tmp); \ - if ((read_tmp / 16) != font_dsize(f)) { \ - print_nlp(); \ - print_string("design size mismatch in font "); \ - print_string(font_name(f)); \ - print_string(".vf ignored"); \ - } \ -} - -static int count_packet_bytes(real_eight_bits * vf_buf, int cur_bute, int count) -{ - int k = 0; - int ff = 0; - int acc = 0; - unsigned int cmd = 0; - unsigned int d = 0; - while (k < count) { - cmd = vf_buf[cur_bute + k]; - k++; - if (cmd < set1) { - if (ff == 0) { - ff = 1; - acc += 5; - } - acc += 5; - } else if ((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) { - ff = 1; - acc += 5; - } else { - switch (cmd) { - case fnt1: - acc += 5; - k += 1; - ff = 1; - break; - case fnt2: - acc += 5; - k += 2; - ff = 1; - break; - case fnt3: - acc += 5; - k += 3; - ff = 1; - break; - case fnt4: - acc += 5; - k += 4; - ff = 1; - break; - case set_rule: - acc += 9; - k += 8; - break; - case put_rule: - acc += 11; - k += 8; - break; - case set1: - acc += 5; - k += 1; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case set2: - acc += 5; - k += 2; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case set3: - acc += 5; - k += 3; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case set4: - acc += 5; - k += 4; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case put1: - acc += 7; - k += 1; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case put2: - acc += 7; - k += 2; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case put3: - acc += 7; - k += 3; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case put4: - acc += 7; - k += 4; - if (ff == 0) { - ff = 1; - acc += 5; - } - break; - case right1: - acc += 5; - k += 1; - break; - case right2: - acc += 5; - k += 2; - break; - case right3: - acc += 5; - k += 3; - break; - case right4: - acc += 5; - k += 4; - break; - case w1: - acc += 5; - k += 1; - break; - case w2: - acc += 5; - k += 2; - break; - case w3: - acc += 5; - k += 3; - break; - case w4: - acc += 5; - k += 4; - break; - case x1: - acc += 5; - k += 1; - break; - case x2: - acc += 5; - k += 2; - break; - case x3: - acc += 5; - k += 3; - break; - case x4: - acc += 5; - k += 4; - break; - case down1: - acc += 5; - k += 1; - break; - case down2: - acc += 5; - k += 2; - break; - case down3: - acc += 5; - k += 3; - break; - case down4: - acc += 5; - k += 4; - break; - case y1: - acc += 5; - k += 1; - break; - case y2: - acc += 5; - k += 2; - break; - case y3: - acc += 5; - k += 3; - break; - case y4: - acc += 5; - k += 4; - break; - case z1: - acc += 5; - k += 1; - break; - case z2: - acc += 5; - k += 2; - break; - case z3: - acc += 5; - k += 3; - break; - case z4: - acc += 5; - k += 4; - break; - case xxx1: - d = vf_buf[cur_bute + k]; - k++; - k += d; - acc += 5 + d; - break; - case xxx2: - d = vf_buf[cur_bute + k]; - k++; - d = d * 256 + vf_buf[cur_bute + k]; - k++; - k += d; - acc += 5 + d; - break; - case xxx3: - d = vf_buf[cur_bute + k]; - k++; - d = d * 256 + vf_buf[cur_bute + k]; - k++; - d = d * 256 + vf_buf[cur_bute + k]; - k++; - k += d; - acc += 5 + d; - break; - case xxx4: - d = vf_buf[cur_bute + k]; - k++; - d = d * 256 + vf_buf[cur_bute + k]; - k++; - d = d * 256 + vf_buf[cur_bute + k]; - k++; - d = d * 256 + vf_buf[cur_bute + k]; - k++; - k += d; - acc += 5 + d; - break; - case w0: - acc += 5; - break; - case x0: - acc += 5; - break; - case y0: - acc += 5; - break; - case z0: - acc += 5; - break; - case nop: - break; - case push: - acc += 1; - break; - case pop: - acc += 1; - break; - } - } - } - return (acc + 1); -} - -void do_vf(internal_font_number f) -{ - integer k, i; - unsigned cmd, n; - scaled x, y, w, z, h, v; - integer cc, cmd_length, packet_length; - charinfo *co; - scaled tfm_width; - integer save_cur_byte; - vf_stack_index stack_level; - integer vf_z; /* multiplier */ - integer vf_alpha; /* correction for negative values */ - char vf_beta; /* divisor */ - integer vf_np; - real_eight_bits *vpackets; - memory_word tmp_w; /* accumulator */ - vf_stack_record vf_stack[256]; - integer junk; - unsigned char *vf_buffer; - integer vf_size; - integer vf_cur; - integer *vf_local_fnts = NULL; /* external font ids */ - integer *vf_real_fnts = NULL; /* internal font ids */ - unsigned vf_nf = 0; /* local font counter */ - - if (font_type(f) != unknown_font_type) - return; - set_font_type(f, real_font_type); - if (auto_expand_vf(f)) - return; /* auto-expanded virtual font */ - stack_level = 0; - /* @; */ - vf_cur = 0; - vf_buffer = NULL; - vf_size = 0; - if (!open_vf_file(font_name(f), &vf_buffer, &vf_size)) - return; - /* @;@/ */ - set_font_type(f, virtual_font_type); - vf_byte(k); - if (k != pre) - bad_vf("PRE command expected"); - vf_byte(k); - if (k != vf_id) - bad_vf("wrong id byte"); - vf_byte(cmd_length); - for (k = 1; k <= cmd_length; k++) - vf_byte(junk); - test_checksum(); - test_dsize(); - /* update_terminal; */ - vf_z = font_size(f); - vf_replace_z(); - /* @;@/ */ - /* scan forward to find the number of internal fonts */ - vf_nf = 0; - save_cur_byte = vf_cur; - vf_byte(cmd); - while ((cmd >= fnt_def1) && (cmd <= (fnt_def1 + 3))) { - vf_read_u((cmd - fnt_def1 + 1), junk); - vf_read(4, junk); - vf_read(4, junk); - vf_read(4, junk); - vf_byte(k); - vf_byte(junk); - k += junk; - while (k-- > 0) { - vf_byte(junk); - } - incr(vf_nf); - vf_byte(cmd); - } - vf_cur = save_cur_byte; - vf_byte(cmd); - /* malloc and fill the local font arrays */ - if (vf_nf > 0) { - i = vf_nf * sizeof(integer); - vf_local_fnts = xmalloc(i); - memset(vf_local_fnts, 0, i); - vf_real_fnts = xmalloc(i); - memset(vf_real_fnts, 0, i); - vf_nf = 0; - while ((cmd >= fnt_def1) && (cmd <= (fnt_def1 + 3))) { - vf_read_u((cmd - fnt_def1 + 1), vf_local_fnts[vf_nf]); - vf_real_fnts[vf_nf] = vf_def_font(f, vf_buffer, &vf_cur); - incr(vf_nf); - vf_byte(cmd); - } - } - - - while (cmd <= long_char) { - /* @;@/ */ - vf_np = 0; - if (cmd == long_char) { - vf_read_u(4, packet_length); - vf_read_u(4, cc); - if (!char_exists(f, cc)) { - bad_vf("invalid character code"); - } - vf_read(4, k); - tfm_width = store_scaled_f(k, font_size(f)); - } else { - packet_length = cmd; - vf_byte(cc); - if (!char_exists(f, cc)) { - bad_vf("invalid character code"); - } - vf_read_u(3, k); /* cf. vftovp.web, line 1028 */ - tfm_width = store_scaled_f(k, font_size(f)); - } - if (packet_length < 0) - bad_vf("negative packet length"); - if (tfm_width != char_width(f, cc)) { - if (tfm_width != char_width(f, cc)) { - print_nlp(); - print_string("character width mismatch in font "); - print_string(font_name(f)); - print_string(".vf ignored"); - } - } - k = count_packet_bytes(vf_buffer, vf_cur, packet_length); - vpackets = xmalloc(k + 1); /* need one extra extra for packet_end */ - co = get_charinfo(f, cc); - k = 0; - w = 0; - x = 0; - y = 0; - z = 0; - while (packet_length > 0) { - vf_byte(cmd); - decr(packet_length); - - if (cmd < set1) { - if (k == 0) { - k = vf_real_fnts[0]; - append_fnt_set(k); - } - append_packet(packet_char_code); - append_four(cmd); - cmd_length = 0; - cmd = nop; - - } else if (((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) || - ((fnt1 <= cmd) && (cmd <= fnt1 + 3))) { - if (cmd >= fnt1) { - vf_read_u((cmd - fnt1 + 1), k); - packet_length -= (cmd - fnt1 + 1); - } else { - k = cmd - fnt_num_0; - } - - /* change from local to external font id */ - n = 0; - while ((n < vf_nf) && (vf_local_fnts[n] != k)) - n++; - if (n == vf_nf) - bad_vf("undefined local font"); - - k = vf_real_fnts[n]; - append_fnt_set(k); - cmd_length = 0; - cmd = nop; - } else { - switch (cmd) { - case set_rule: - vf_read(4, h); - vf_read(4, v); - append_packet(packet_rule_code); - append_four(h); - append_four(v); - packet_length -= 8; - break; - case put_rule: - vf_read(4, h); - vf_read(4, v); - append_packet(packet_push_code); - append_packet(packet_rule_code); - append_four(h); - append_four(v); - append_packet(packet_pop_code); - packet_length -= 8; - break; - case set1: - case set2: - case set3: - case set4: - if (k == 0) { - k = vf_real_fnts[0]; - append_fnt_set(k); - } - vf_read_u((cmd - set1 + 1), i); - append_packet(packet_char_code); - append_four(i); - packet_length -= (cmd - set1 + 1); - break; - case put1: - case put2: - case put3: - case put4: - if (k == 0) { - k = vf_real_fnts[0]; - append_fnt_set(k); - } - vf_read_u((cmd - put1 + 1), i); - append_packet(packet_push_code); - append_packet(packet_char_code); - append_four(i); - append_packet(packet_pop_code); - packet_length -= (cmd - put1 + 1); - break; - case right1: - case right2: - case right3: - case right4: - vf_read((cmd - right1 + 1), i); - append_packet(packet_right_code); - append_four(i); - packet_length -= (cmd - right1 + 1); - break; - case w1: - case w2: - case w3: - case w4: - vf_read((cmd - w1 + 1), w); - append_packet(packet_right_code); - append_four(w); - packet_length -= (cmd - w1 + 1); - break; - case x1: - case x2: - case x3: - case x4: - vf_read((cmd - x1 + 1), x); - append_packet(packet_right_code); - append_four(x); - packet_length -= (cmd - x1 + 1); - break; - case down1: - case down2: - case down3: - case down4: - vf_read((cmd - down1 + 1), i); - append_packet(packet_down_code); - append_four(i); - packet_length -= (cmd - down1 + 1); - break; - case y1: - case y2: - case y3: - case y4: - vf_read((cmd - y1 + 1), y); - append_packet(packet_down_code); - append_four(y); - packet_length -= (cmd - y1 + 1); - break; - case z1: - case z2: - case z3: - case z4: - vf_read((cmd - z1 + 1), z); - append_packet(packet_down_code); - append_four(z); - packet_length -= (cmd - z1 + 1); - break; - case xxx1: - case xxx2: - case xxx3: - case xxx4: - vf_read_u((cmd - xxx1 + 1), cmd_length); - packet_length -= (cmd - xxx1 + 1); - if (cmd_length <= 0) - bad_vf("special of negative length"); - packet_length -= cmd_length; - - append_packet(packet_special_code); - append_four(cmd_length); - while (cmd_length > 0) { - cmd_length--; - vf_byte(i); - append_packet(i); - } - break; - case w0: - append_packet(packet_right_code); - append_four(w); - break; - case x0: - append_packet(packet_right_code); - append_four(x); - break; - case y0: - append_packet(packet_down_code); - append_four(y); - break; - case z0: - append_packet(packet_down_code); - append_four(z); - break; - case nop: - break; - case push: - if (stack_level == vf_stack_size) { - overflow_string("virtual font stack size", - vf_stack_size); - } else { - vf_stack[stack_level].stack_w = w; - vf_stack[stack_level].stack_x = x; - vf_stack[stack_level].stack_y = y; - vf_stack[stack_level].stack_z = z; - incr(stack_level); - append_packet(packet_push_code); - } - break; - case pop: - if (stack_level == 0) { - bad_vf("more POPs than PUSHs in character"); - } else { - decr(stack_level); - w = vf_stack[stack_level].stack_w; - x = vf_stack[stack_level].stack_x; - y = vf_stack[stack_level].stack_y; - z = vf_stack[stack_level].stack_z; - append_packet(packet_pop_code); - } - break; - default: - bad_vf("improver DVI command"); - } - } - } - /* signal end of packet */ - append_packet(packet_end_code); - - if (stack_level != 0) - bad_vf("more PUSHs than POPs in character packet"); - if (packet_length != 0) - bad_vf("invalid packet length or DVI command in packet"); - /* @; */ - set_charinfo_packets(co, vpackets); - vf_byte(cmd); - } - if (cmd != post) - bad_vf("POST command expected"); - - xfree(vf_buffer); -} - -#define make_command0(N,K) { \ - lua_newtable(L); \ - lua_pushstring(L, N); \ - lua_rawseti(L,-2, 1); \ - lua_rawseti(L,-2, K); \ - K++; } - -#define make_command1(N,V,K) { \ - lua_newtable(L); \ - lua_pushstring(L, N); \ - lua_rawseti(L,-2, 1); \ - lua_pushnumber(L, V); \ - lua_rawseti(L,-2, 2); \ - lua_rawseti(L,-2, K); \ - K++; } - -#define make_command2(N,V,W,K) { \ - lua_newtable(L); \ - lua_pushstring(L, N); \ - lua_rawseti(L,-2, 1); \ - lua_pushnumber(L, V); \ - lua_rawseti(L,-2, 2); \ - lua_pushnumber(L, W); \ - lua_rawseti(L,-2, 3); \ - lua_rawseti(L,-2, K); \ - K++; } - -#define make_commands(N,S,V,K) { \ - lua_newtable(L); \ - lua_pushstring(L, N); \ - lua_rawseti(L,-2, 1); \ - lua_pushlstring(L, S, V); \ - lua_rawseti(L,-2, 2); \ - lua_rawseti(L,-2, K); \ - K++; } - - -int make_vf_table(lua_State * L, const char *cnom, scaled atsize) -{ - integer cmd, k, i; - integer cc, cmd_length, packet_length; - scaled tfm_width; - vf_stack_index stack_level; - integer vf_z; /* multiplier */ - integer vf_alpha; /* correction for negative values */ - char vf_beta; /* divisor */ - char *s; - scaled h, v; - scaled w, x, y, z; - integer s_top; /* lua stack */ - integer vf_nf; /* local font counter */ - scaled ds, fs; - four_quarters cs; - memory_word tmp_w; /* accumulator */ - vf_stack_record vf_stack[256]; - unsigned char *vf_buffer; - integer vf_size; - integer vf_cur; - - - stack_level = 0; - /* @; */ - vf_cur = 0; - vf_buffer = NULL; - vf_size = 0; - if (!open_vf_file(cnom, &vf_buffer, &vf_size)) { - lua_pushnil(L); - return 1; - } - - /* start by creating a table */ - s_top = lua_gettop(L); - lua_newtable(L); - - /* @;@/ */ - vf_byte(k); - if (k != pre) - lua_bad_vf("PRE command expected"); - vf_byte(k); - if (k != vf_id) - lua_bad_vf("wrong id byte"); - vf_byte(cmd_length); - - s = xmalloc(cmd_length); - for (k = 1; k <= cmd_length; k++) - vf_byte(s[(k - 1)]); - - lua_pushlstring(L, s, cmd_length); - free(s); - lua_setfield(L, -2, "header"); - - vf_byte(cs.b0); - vf_byte(cs.b1); - vf_byte(cs.b2); - vf_byte(cs.b3); - lua_pushnumber(L, - (unsigned long) (cs.b0 << 24) + (cs.b1 << 16) + - (cs.b2 << 8) + cs.b3); - lua_setfield(L, -2, "checksum"); - - vf_read(4, k); - ds = k / 16; - lua_pushinteger(L, ds); - lua_setfield(L, -2, "designsize"); - - - lua_pushstring(L, cnom); - lua_setfield(L, -2, "name"); - - lua_pushinteger(L, atsize); - lua_setfield(L, -2, "size"); - - - /* update_terminal; */ - vf_z = atsize; - vf_replace_z(); - /* @;@/ */ - vf_byte(cmd); - lua_newtable(L); - - i = 1; - while ((cmd >= fnt_def1) && (cmd <= fnt_def1 + 3)) { - - lua_newtable(L); - vf_read_u((cmd - fnt_def1 + 1), vf_nf); - vf_nf++; - /* checksum */ - vf_byte(cs.b0); - vf_byte(cs.b1); - vf_byte(cs.b2); - vf_byte(cs.b3); - - vf_read(4, k); - fs = store_scaled_f(k, atsize); - lua_pushstring(L, "size"); - lua_pushnumber(L, fs); - lua_rawset(L, -3); - - vf_read(4, k); - ds = k / 16; /* dsize, not used */ - - vf_byte(tmp_b0); - vf_byte(tmp_b1); - while (tmp_b0 > 0) { - tmp_b0--; - vf_byte(k); - } /* skip the font path */ - - s = xmalloc(tmp_b1 + 1); - k = 0; - while (tmp_b1-- > 0) - vf_byte(s[k++]); - s[k] = 0; - lua_pushstring(L, "name"); - lua_pushstring(L, xstrdup(s)); - free(s); - lua_rawset(L, -3); - - lua_rawseti(L, -2, vf_nf); - i++; - vf_byte(cmd); - } - - if (i > 1) { - lua_setfield(L, -2, "fonts"); - } else { - lua_pop(L, 1); - } - - lua_newtable(L); /* 'characters' */ - while (cmd <= long_char) { - /* @;@/ */ - if (cmd == long_char) { - vf_read_u(4, packet_length); - vf_read_u(4, cc); - vf_read(4, tfm_width); - } else { - packet_length = cmd; - vf_byte(cc); - vf_read_u(3, tfm_width); - } - if (packet_length < 0) - lua_bad_vf("negative packet length"); - - lua_newtable(L); /* for this character */ - - lua_pushnumber(L, tfm_width); - lua_setfield(L, -2, "width"); - - lua_newtable(L); /* for 'commands' */ - - k = 1; - vf_nf = 0; - w = 0; - x = 0; - y = 0; - z = 0; - while (packet_length > 0) { - vf_byte(cmd); - decr(packet_length); - - if ((cmd >= set_char_0) && (cmd < set1)) { - if (vf_nf == 0) { - vf_nf = 1; - make_command1("font", vf_nf, k); - } - make_command1("char", cmd, k); - - } else if (((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) || - ((fnt1 <= cmd) && (cmd <= fnt1 + 3))) { - if (cmd >= fnt1) { - vf_read_u((cmd - fnt1 + 1), vf_nf); - vf_nf++; - packet_length -= (cmd - fnt1 + 1); - } else { - vf_nf = cmd - fnt_num_0 + 1; - } - make_command1("font", vf_nf, k); - } else { - switch (cmd) { - case set_rule: - vf_read(4, h); - vf_read(4, v); - make_command2("rule", store_scaled_f(h, atsize), - store_scaled_f(v, atsize), k); - packet_length -= 8; - break; - case put_rule: - vf_read(4, h); - vf_read(4, v); - make_command0("push", k); - make_command2("rule", store_scaled_f(h, atsize), - store_scaled_f(v, atsize), k); - make_command0("pop", k); - packet_length -= 8; - break; - case set1: - case set2: - case set3: - case set4: - if (vf_nf == 0) { - vf_nf = 1; - make_command1("font", vf_nf, k); - } - vf_read_u((cmd - set1 + 1), i); - make_command1("char", i, k); - packet_length -= (cmd - set1 + 1); - break; - case put1: - case put2: - case put3: - case put4: - if (vf_nf == 0) { - vf_nf = 1; - make_command1("font", vf_nf, k); - } - vf_read_u((cmd - put1 + 1), i); - make_command0("push", k); - make_command1("char", i, k); - make_command0("pop", k); - packet_length -= (cmd - put1 + 1); - break; - case right1: - case right2: - case right3: - case right4: - vf_read((cmd - right1 + 1), i); - make_command1("right", store_scaled_f(i, atsize), k); - packet_length -= (cmd - right1 + 1); - break; - case w1: - case w2: - case w3: - case w4: - vf_read((cmd - w1 + 1), w); - make_command1("right", store_scaled_f(w, atsize), k); - packet_length -= (cmd - w1 + 1); - break; - case x1: - case x2: - case x3: - case x4: - vf_read((cmd - x1 + 1), x); - make_command1("right", store_scaled_f(x, atsize), k); - packet_length -= (cmd - x1 + 1); - break; - case down1: - case down2: - case down3: - case down4: - vf_read((cmd - down1 + 1), i); - make_command1("down", store_scaled_f(i, atsize), k); - packet_length -= (cmd - down1 + 1); - break; - case y1: - case y2: - case y3: - case y4: - vf_read((cmd - y1 + 1), y); - make_command1("down", store_scaled_f(y, atsize), k); - packet_length -= (cmd - y1 + 1); - break; - case z1: - case z2: - case z3: - case z4: - vf_read((cmd - z1 + 1), z); - make_command1("down", store_scaled_f(z, atsize), k); - packet_length -= (cmd - z1 + 1); - break; - case xxx1: - case xxx2: - case xxx3: - case xxx4: - vf_read_u((cmd - xxx1 + 1), cmd_length); - packet_length -= (cmd - xxx1 + 1); - if (cmd_length <= 0) - lua_bad_vf("special of negative length"); - packet_length -= cmd_length; - - s = xmalloc(cmd_length + 1); - i = 0; - while (cmd_length > 0) { - cmd_length--; - vf_byte(s[i]); - i++; - } - s[i] = 0; - make_commands("special", strdup(s), i, k); - free(s); - break; - case w0: - make_command1("right", store_scaled_f(w, atsize), k); - break; - case x0: - make_command1("right", store_scaled_f(x, atsize), k); - break; - case y0: - make_command1("down", store_scaled_f(y, atsize), k); - break; - case z0: - make_command1("down", store_scaled_f(z, atsize), k); - break; - case nop: - break; - case push: - if (stack_level == vf_stack_size) { - overflow_string("virtual font stack size", - vf_stack_size); - } else { - vf_stack[stack_level].stack_w = w; - vf_stack[stack_level].stack_x = x; - vf_stack[stack_level].stack_y = y; - vf_stack[stack_level].stack_z = z; - incr(stack_level); - make_command0("push", k); - } - break; - case pop: - if (stack_level == 0) { - lua_bad_vf("more POPs than PUSHs in character"); - } else { - decr(stack_level); - w = vf_stack[stack_level].stack_w; - x = vf_stack[stack_level].stack_x; - y = vf_stack[stack_level].stack_y; - z = vf_stack[stack_level].stack_z; - make_command0("pop", k); - } - break; - default: - lua_bad_vf("improver DVI command"); - } - } - } - /* signal end of packet */ - lua_setfield(L, -2, "commands"); - - if (stack_level != 0) - lua_bad_vf("more PUSHs than POPs in character packet"); - if (packet_length != 0) - lua_bad_vf("invalid packet length or DVI command in packet"); - - lua_rawseti(L, -2, cc); - - vf_byte(cmd); - } - lua_setfield(L, -2, "characters"); - - if (cmd != post) - lua_bad_vf("POST command expected"); - xfree(vf_buffer); - return 1; -} - - -/* This function is called from |do_vf|, and fixes up the virtual data - inside an auto-expanded virtual font */ - -boolean auto_expand_vf(internal_font_number f) -{ - - internal_font_number bf; - integer e, k; - integer *vf_old_fonts, *vf_new_fonts; - integer num = 0; - - if ((!pdf_font_auto_expand(f)) || (pdf_font_blink(f) == null_font)) - return false; /* not an auto-expanded font */ - bf = pdf_font_blink(f); - - if (font_type(bf) != virtual_font_type) - return false; /* not a virtual font */ - - e = pdf_font_expand_ratio(f); - - vf_old_fonts = packet_local_fonts(bf, &num); - if (num > 0) { - vf_new_fonts = xmalloc(num * sizeof(integer)); - for (k = 0; k < num; k++) { - vf_new_fonts[k] = auto_expand_font(vf_old_fonts[k], e); - copy_expand_params(vf_new_fonts[k], vf_old_fonts[k], e); - } - replace_packet_fonts(f, vf_old_fonts, vf_new_fonts, num); - xfree(vf_new_fonts); - xfree(vf_old_fonts); - } - set_font_type(f, virtual_font_type); - return true; -} - -/* this function is not always safe, because it needs makecstring() */ -str_number expand_font_name(internal_font_number f, integer e) -{ - int old_setting; - old_setting = selector; - selector = new_string; - print_string(font_name(f)); - if (e > 0) { - print_char('+'); - } - print_int(e); - selector = old_setting; - return make_string(); -} - - -internal_font_number auto_expand_font(internal_font_number f, integer e) -{ - internal_font_number k; - kerninfo *krn; - charinfo *co; - char *fn; - integer i; - scaled w; - k = copy_font(f); - i = strlen(font_name(f)) + 12; - fn = xmalloc(i); - snprintf(fn, i, "%s%s%d", font_name(f), (e > 0 ? "+" : ""), (int) e); - set_font_name(k, fn); - for (i = font_bc(k); i <= font_ec(k); i++) { - if (char_exists(k, i)) { - co = get_charinfo(k, i); - w = round_xn_over_d(char_width(f, i), 1000 + e, 1000); - set_charinfo_width(co, w); - w = round_xn_over_d(char_italic(f, i), 1000 + e, 1000); - set_charinfo_italic(co, w); - krn = get_charinfo_kerns(co); - if (krn != NULL) { - while (!kern_end((*krn))) { - kern_kern(*krn) = - round_xn_over_d(kern_kern(*krn), 1000 + e, 1000); - krn++; - } - } - } - } - return k; -} - -void vf_expand_local_fonts(internal_font_number f) -{ - internal_font_number lf; - integer k, num; - integer *vf_old_fonts; - pdfassert(font_type(f) == virtual_font_type); - num = 0; - vf_old_fonts = packet_local_fonts(f, &num); - if (num > 0) { - for (k = 0; k < num; k++) { - lf = vf_old_fonts[k]; - set_expand_params(lf, pdf_font_auto_expand(f), - pdf_font_expand_ratio(pdf_font_stretch(f)), - -pdf_font_expand_ratio(pdf_font_shrink(f)), - pdf_font_step(f), pdf_font_expand_ratio(f)); - if (font_type(lf) == virtual_font_type) - vf_expand_local_fonts(lf); - } - xfree(vf_old_fonts); - } -} - -internal_font_number -letter_space_font(halfword u, internal_font_number f, integer e) -{ - internal_font_number k; - scaled w, r; - - char *new_font_name; - integer vf_z; - integer vf_alpha; - integer vf_beta; - memory_word tmp_w; /* accumulator */ - - - /* read a new font and expand the character widths */ - k = read_font_info(u, tex_font_name(f), font_size(f), font_natural_dir(f)); - set_no_ligatures(k); /* disable ligatures for letter-spaced fonts */ -/* - for (i = 0;i <= font_widths(k);i++) { - set_font_width(k,i,font_width(f,i)+round_xn_over_d(quad(k), e, 1000)); - } -*/ - /* append eg '+100ls' to font name */ - new_font_name = xmalloc(strlen(font_name(k)) + 8); /* |abs(e) <= 1000| */ - if (e > 0) { - sprintf(new_font_name, "%s+%ils", font_name(k), (int) e); - } else { - /* minus from %i */ - sprintf(new_font_name, "%s%ils", font_name(k), (int) e); - } - set_font_name(k, new_font_name); - - /* create the corresponding virtual font */ - set_font_type(k, virtual_font_type); - - vf_z = font_size(f); - vf_replace_z(); - w = round_xn_over_d(quad(f), e, 2000); - if (w > 0) { - tmp_b0 = 0; - } else { - tmp_b0 = 255; - w = vf_alpha + w; - } - r = w * vf_beta; - tmp_b1 = r / vf_z; - r = r % vf_z; - if (r == 0) { - tmp_b2 = 0; - } else { - r = r * 256; - tmp_b2 = r / vf_z; - r = r % vf_z; - } - if (r == 0) { - tmp_b3 = 0; - } else { - r = r * 256; - tmp_b3 = r / vf_z; - } - /* - vf_packet_base[k] = new_vf_packet(k); - - for (c=font_bc(k);c<=font_ec(k);c++) { - string_room(17); - append_fnt_set(f); - append_packet(right1 + 3); - append_packet(tmp_b0); - append_packet(tmp_b1); - append_packet(tmp_b2); - append_packet(tmp_b3); - - append_packet(set1); - append_packet(c); - - append_packet(right1 + 3); - append_packet(tmp_b0); - append_packet(tmp_b1); - append_packet(tmp_b2); - append_packet(tmp_b3); - s = make_string(); - store_packet(k, c, s); - flush_str(s); - } - */ - return k; -} - -/* the fontname has [+-]\d+ls at the end */ - -#if 0 /* unused */ -static boolean is_letterspaced_font(internal_font_number f) -{ - char *i, *j; - if (font_type(f) != virtual_font_type) - return false; - j = font_name(f); - i = j + strlen(j); - if ((*(i - 1) != 'l') || (*i != 's')) - return false; - i = i - 2; - while (i >= j) { - if ((*i < '0') || (*i > '9')) - break; - i--; - } - if (i < j) - return false; - if ((*i != '+') && (*i != '-')) - return false; - return true; -} -#endif - -/* TODO */ - -internal_font_number copy_font_info(internal_font_number f) -{ - return copy_font(f); -} diff --git a/Build/source/texk/web2c/luatexdir/font/vfovf.w b/Build/source/texk/web2c/luatexdir/font/vfovf.w new file mode 100644 index 00000000000..cc3c93ad8b5 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/vfovf.w @@ -0,0 +1,1624 @@ +% vfovf.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2009 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" + +static const char _svn_version[] = + "$Id: vfovf.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/vfovf.w $"; + +@ @c +/* this is a hack! */ +#define font_max 5000 + +#define set_char_0 0 /* typeset character 0 and move right */ +#define set1 128 /* typeset a character and move right */ +#define set2 129 /* typeset a character and move right */ +#define set3 130 /* typeset a character and move right */ +#define set4 131 /* typeset a character and move right */ +#define set_rule 132 /* typeset a rule and move right */ +#define put1 133 /* typeset a character without moving */ +#define put2 134 /* typeset a character without moving */ +#define put3 135 /* typeset a character without moving */ +#define put4 136 /* typeset a character without moving */ +#define put_rule 137 /* typeset a rule */ +#define nop 138 /* no operation */ +#define bop 139 /* beginning of page */ +#define eop 140 /* ending of page */ +#define push 141 /* save the current positions */ +#define pop 142 /* restore previous positions */ +#define right1 143 /* move right */ +#define right2 144 /* move right */ +#define right3 145 /* move right */ +#define right4 146 /* move right, 4 bytes */ +#define w0 147 /* move right by |w| */ +#define w1 148 /* move right and set |w| */ +#define w2 149 /* move right and set |w| */ +#define w3 150 /* move right and set |w| */ +#define w4 151 /* move right and set |w| */ +#define x0 152 /* move right by |x| */ +#define x1 153 /* move right and set |x| */ +#define x2 154 /* move right and set |x| */ +#define x3 155 /* move right and set |x| */ +#define x4 156 /* move right and set |x| */ +#define down1 157 /* move down */ +#define down2 158 /* move down */ +#define down3 159 /* move down */ +#define down4 160 /* move down, 4 bytes */ +#define y0 161 /* move down by |y| */ +#define y1 162 /* move down and set |y| */ +#define y2 163 /* move down and set |y| */ +#define y3 164 /* move down and set |y| */ +#define y4 165 /* move down and set |y| */ +#define z0 166 /* move down by |z| */ +#define z1 167 /* move down and set |z| */ +#define z2 168 /* move down and set |z| */ +#define z3 169 /* move down and set |z| */ +#define z4 170 /* move down and set |z| */ +#define fnt_num_0 171 /* set current font to 0 */ +#define fnt1 235 /* set current font */ +#define fnt2 236 /* set current font */ +#define fnt3 237 /* set current font */ +#define fnt4 238 /* set current font */ +#define xxx1 239 /* extension to DVI primitives */ +#define xxx2 240 /* extension to DVI primitives */ +#define xxx3 241 /* extension to DVI primitives */ +#define xxx4 242 /* potentially long extension to DVI primitives */ +#define fnt_def1 243 /* define the meaning of a font number */ +#define pre 247 /* preamble */ +#define post 248 /* postamble beginning */ +#define post_post 249 /* postamble ending */ +#define yyy1 250 /* PDF literal text */ +#define yyy2 251 /* PDF literal text */ +#define yyy3 252 /* PDF literal text */ +#define yyy4 253 /* PDF literal text */ + +#define null_font 0 + +#define long_char 242 /* \.{VF} command for general character packet */ +#define vf_id 202 /* identifies \.{VF} files */ + +@ go out \.{VF} processing with an error message +@c +#define bad_vf(a) { xfree(vf_buffer); print_nlp(); \ + tprint("Error in processing VF font ("); \ + tprint(font_name(f)); \ + tprint(".vf): "); \ + tprint(a); \ + tprint(", virtual font will be ignored"); \ + print_ln(); return; } + +#define lua_bad_vf(a) { xfree(vf_buffer); \ + lua_settop(L,s_top); \ + lua_pushnil(L); \ + lua_pushstring(L,a); \ + return 2; } + +#define tmp_b0 tmp_w.qqqq.b0 +#define tmp_b1 tmp_w.qqqq.b1 +#define tmp_b2 tmp_w.qqqq.b2 +#define tmp_b3 tmp_w.qqqq.b3 +#define tmp_int tmp_w.cint + +#define vf_stack_size 100 /* \.{DVI} files shouldn't |push| beyond this depth */ + +@ @c +typedef unsigned char vf_stack_index; /* an index into the stack */ + +typedef struct vf_stack_record { + scaled stack_w, stack_x, stack_y, stack_z; +} vf_stack_record; + +boolean auto_expand_vf(internal_font_number f); /* forward */ + +@ get a byte from\.{VF} file +@c +#define vf_byte(a) \ +{ \ + eight_bits vf_tmp_b; \ + if (vf_cur >= vf_size) { \ + pdftex_fail("unexpected eof on virtual font"); \ + } \ + vf_tmp_b = vf_buffer[vf_cur++]; \ + a = vf_tmp_b; \ +} + +@ @c +#define vf_replace_z() \ +{ \ + vf_alpha = 16; \ + while (vf_z >= 040000000) { \ + vf_z = vf_z / 2; \ + vf_alpha += vf_alpha; \ + } \ + vf_beta = (char)(256 / vf_alpha); \ + vf_alpha = (vf_alpha * vf_z); \ +} + + +@ read |k| bytes as an integer from \.{VF} file +beware: the |vf_read()| macro differs from |vf_read()| in vftovp.web for 1...3 byte words. +@c +#define vf_read(k, l) \ +{ \ + int itmp = 0, dtmp = (int)(k), jtmp = 0; \ + while (dtmp > 0) { \ + vf_byte(jtmp); \ + if ((dtmp == (int) k) && jtmp > 127) \ + jtmp = jtmp - 256; \ + itmp = itmp * 256 + jtmp; \ + decr(dtmp); \ + } \ + l = itmp; \ +} + +#define vf_read_u(k, l) \ +{ \ + int dtmp = (int)(k); \ + unsigned int itmp = 0, jtmp = 0; \ + while (dtmp-- > 0) { \ + vf_byte(jtmp); \ + itmp = itmp * 256 + jtmp; \ + } \ + l = itmp; \ +} + +@ @c +void pdf_check_vf(internal_font_number f) +{ + if (font_type(f) == virtual_font_type) + pdf_error("font", "command cannot be used with virtual font"); +} + +static void +vf_local_font_warning(internal_font_number f, internal_font_number k, + const char *s, int a, int b) +{ + print_nlp(); + tprint(s); + tprint(" in local font "); + tprint(font_name(k)); + tprint(" ("); + print_int(b); + tprint(" != "); + print_int(a); + tprint(") in virtual font "); + tprint(font_name(f)); + tprint(".vf ignored."); +} + + +@ process a local font in \.{VF} file +@c +internal_font_number +vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr) +{ + internal_font_number k; + str_number s; + char *st; + scaled ds, fs; + four_quarters cs; + memory_word tmp_w; /* accumulator */ + int junk; + unsigned long checksum; + cs.b0 = vf_buffer[(*vf_cr)]; + cs.b1 = vf_buffer[(*vf_cr) + 1]; + cs.b2 = vf_buffer[(*vf_cr) + 2]; + cs.b3 = vf_buffer[(*vf_cr) + 3]; + (*vf_cr) += 4; + checksum = (unsigned) + (cs.b0 * 256 * 256 * 256 + cs.b1 * 256 * 256 + cs.b2 * 256 + cs.b3); + k = vf_buffer[(*vf_cr)]; + (*vf_cr)++; + if (k > 127) + k -= 256; + k = k * 256 + vf_buffer[(*vf_cr)]; + (*vf_cr)++; + k = k * 256 + vf_buffer[(*vf_cr)]; + (*vf_cr)++; + k = k * 256 + vf_buffer[(*vf_cr)]; + (*vf_cr)++; + + fs = store_scaled_f(k, font_size(f)); + + k = vf_buffer[(*vf_cr)]; + (*vf_cr)++; + if (k > 127) + k -= 256; + k = k * 256 + vf_buffer[(*vf_cr)]; + (*vf_cr)++; + k = k * 256 + vf_buffer[(*vf_cr)]; + (*vf_cr)++; + k = k * 256 + vf_buffer[(*vf_cr)]; + (*vf_cr)++; + + ds = k / 16; + + + tmp_b0 = vf_buffer[(*vf_cr)]; + (*vf_cr)++; + tmp_b1 = vf_buffer[(*vf_cr)]; + (*vf_cr)++; + while (tmp_b0 > 0) { + tmp_b0--; + (*vf_cr)++; /* skip the font path */ + } + str_room((unsigned) tmp_b1); + while (tmp_b1 > 0) { + tmp_b1--; + junk = vf_buffer[(*vf_cr)]; + (*vf_cr)++; + append_char(junk); + } + s = make_string(); + st = makecstring(s); + k = tfm_lookup(st, fs, font_expand_ratio(f)); + if (k == null_font) + k = read_font_info(null_cs, st, fs, -1); + free(st); + if (k != null_font) { + if (checksum != 0 && font_checksum(k) != 0 + && checksum != font_checksum(k)) + vf_local_font_warning(f, k, "checksum mismatch", (int) checksum, + (int) font_checksum(k)); + if (ds != font_dsize(k)) + vf_local_font_warning(f, k, "design size mismatch", ds, + font_dsize(k)); + } + if (font_expand_ratio(f) != 0) + set_expand_params(k, font_auto_expand(f), + font_expand_ratio(font_stretch(f)), + -font_expand_ratio(font_shrink(f)), + font_step(f), font_expand_ratio(f)); + return k; +} + +@ @c +static int open_vf_file(const char *fn, unsigned char **vbuffer, int *vsize) +{ + boolean res; /* was the callback successful? */ + int callback_id; + boolean file_read = false; /* was |vf_file| successfully read? */ + FILE *vf_file; + const char *fname = luatex_find_file(fn, find_vf_file_callback); + if (!fname) + fname = fn; + + callback_id = callback_defined(read_vf_file_callback); + if (callback_id > 0) { + res = run_callback(callback_id, "S->bSd", fname, + &file_read, vbuffer, vsize); + if (res && file_read && (*vsize > 0)) { + return 1; + } + if (!file_read) + return 0; /* -1 */ + } else { + if (luatex_open_input + (&(vf_file), fname, kpse_ovf_format, FOPEN_RBIN_MODE, false) + || luatex_open_input(&(vf_file), fname, kpse_vf_format, + FOPEN_RBIN_MODE, false)) { + res = read_vf_file(vf_file, vbuffer, vsize); + close_file(vf_file); + if (res) { + return 1; + } + } else { + return 0; /* -1 */ + } + } + return 0; +} + + + +@ The |do_vf| procedure attempts to read the \.{VF} file for a font, and sets + |font_type()| to |real_font_type| if the \.{VF} file could not be found + or loaded, otherwise sets |font_type()| to |virtual_font_type|. At this + time, |tmp_f| is the internal font number of the current \.{TFM} font. To + process font definitions in virtual font we call |vf_def_font|. + +@c +#define append_packet(k) vpackets[vf_np++] = (eight_bits)(k) + +@ life is easier if all internal font commands are fnt4 and + all character commands are set4 or put4 + +@c +#define append_fnt_set(k) \ +{ \ + assert(k > 0); \ + append_packet(packet_font_code); \ + append_four(k); \ +} + +#define append_four(k) \ +{ \ + append_packet((k & 0xFF000000) >> 24); \ + append_packet((k & 0x00FF0000) >> 16); \ + append_packet((k & 0x0000FF00) >> 8); \ + append_packet((k & 0x000000FF)); \ +} + +@ some of these things happen twice, adding a define is simplest + +@c +#define test_checksum() { vf_byte(tmp_b0); vf_byte(tmp_b1); \ + vf_byte(tmp_b2); vf_byte(tmp_b3); \ + if (((tmp_b0 != 0) || (tmp_b1 != 0) || (tmp_b2 != 0) || (tmp_b3 != 0)) && \ + ((font_check_0(f) != 0) || (font_check_1(f) != 0) || \ + (font_check_2(f) != 0) || (font_check_3(f) != 0)) && \ + ((tmp_b0 != font_check_0(f)) || (tmp_b1 != font_check_1(f)) || \ + (tmp_b2 != font_check_2(f)) || (tmp_b3 != font_check_3(f)))) { \ + print_nlp(); \ + tprint("checksum mismatch in font "); \ + tprint(font_name(f)); \ + tprint(".vf ignored "); } } + +#define test_dsize() \ +{ \ + int read_tmp; \ + vf_read(4, read_tmp); \ + if ((read_tmp / 16) != font_dsize(f)) { \ + print_nlp(); \ + tprint("design size mismatch in font "); \ + tprint(font_name(f)); \ + tprint(".vf ignored"); \ + } \ +} + +@ @c +int count_packet_bytes(eight_bits * vf_buf, int cur_bute, int count) +{ + unsigned k = 0; + int ff = 0; + int acc = 0; + unsigned int cmd = 0; + unsigned int d = 0; + while (k < (unsigned) count) { + cmd = vf_buf[cur_bute + (int) k]; + k++; + if (cmd < set1) { + if (ff == 0) { + ff = 1; + acc += 5; + } + acc += 5; + } else if ((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) { + ff = 1; + acc += 5; + } else { + switch (cmd) { + case fnt1: + acc += 5; + k += 1; + ff = 1; + break; + case fnt2: + acc += 5; + k += 2; + ff = 1; + break; + case fnt3: + acc += 5; + k += 3; + ff = 1; + break; + case fnt4: + acc += 5; + k += 4; + ff = 1; + break; + case set_rule: + acc += 9; + k += 8; + break; + case put_rule: + acc += 11; + k += 8; + break; + case set1: + acc += 5; + k += 1; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case set2: + acc += 5; + k += 2; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case set3: + acc += 5; + k += 3; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case set4: + acc += 5; + k += 4; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case put1: + acc += 7; + k += 1; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case put2: + acc += 7; + k += 2; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case put3: + acc += 7; + k += 3; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case put4: + acc += 7; + k += 4; + if (ff == 0) { + ff = 1; + acc += 5; + } + break; + case right1: + acc += 5; + k += 1; + break; + case right2: + acc += 5; + k += 2; + break; + case right3: + acc += 5; + k += 3; + break; + case right4: + acc += 5; + k += 4; + break; + case w1: + acc += 5; + k += 1; + break; + case w2: + acc += 5; + k += 2; + break; + case w3: + acc += 5; + k += 3; + break; + case w4: + acc += 5; + k += 4; + break; + case x1: + acc += 5; + k += 1; + break; + case x2: + acc += 5; + k += 2; + break; + case x3: + acc += 5; + k += 3; + break; + case x4: + acc += 5; + k += 4; + break; + case down1: + acc += 5; + k += 1; + break; + case down2: + acc += 5; + k += 2; + break; + case down3: + acc += 5; + k += 3; + break; + case down4: + acc += 5; + k += 4; + break; + case y1: + acc += 5; + k += 1; + break; + case y2: + acc += 5; + k += 2; + break; + case y3: + acc += 5; + k += 3; + break; + case y4: + acc += 5; + k += 4; + break; + case z1: + acc += 5; + k += 1; + break; + case z2: + acc += 5; + k += 2; + break; + case z3: + acc += 5; + k += 3; + break; + case z4: + acc += 5; + k += 4; + break; + case xxx1: + d = vf_buf[cur_bute + (int) k]; + k++; + k += d; + acc += 5 + (int) d; + break; + case xxx2: + d = vf_buf[cur_bute + (int) k]; + k++; + d = d * 256 + vf_buf[cur_bute + (int) k]; + k++; + k += d; + acc += 5 + (int) d; + break; + case xxx3: + d = vf_buf[cur_bute + (int) k]; + k++; + d = d * 256 + vf_buf[cur_bute + (int) k]; + k++; + d = d * 256 + vf_buf[cur_bute + (int) k]; + k++; + k += d; + acc += 5 + (int) d; + break; + case xxx4: + d = vf_buf[cur_bute + (int) k]; + k++; + d = d * 256 + vf_buf[cur_bute + (int) k]; + k++; + d = d * 256 + vf_buf[cur_bute + (int) k]; + k++; + d = d * 256 + vf_buf[cur_bute + (int) k]; + k++; + k += d; + acc += 5 + (int) d; + break; + case w0: + acc += 5; + break; + case x0: + acc += 5; + break; + case y0: + acc += 5; + break; + case z0: + acc += 5; + break; + case nop: + break; + case push: + acc += 1; + break; + case pop: + acc += 1; + break; + } + } + } + return (acc + 1); +} + +@ @c +void do_vf(internal_font_number f) +{ + int k, i; + unsigned cmd, n; + scaled x, y, w, z, h, v; + int cc, cmd_length; + unsigned packet_length; + charinfo *co; + scaled tfm_width; + int save_cur_byte; + vf_stack_index stack_level; + int vf_z; /* multiplier */ + int vf_alpha; /* correction for negative values */ + char vf_beta; /* divisor */ + int vf_np; + eight_bits *vpackets; + memory_word tmp_w; /* accumulator */ + vf_stack_record vf_stack[256]; + int junk; + unsigned utmp; + unsigned char *vf_buffer; + int vf_size; + int vf_cur; + unsigned *vf_local_fnts = NULL; /* external font ids */ + unsigned *vf_real_fnts = NULL; /* internal font ids */ + unsigned vf_nf = 0; /* local font counter */ + + if (font_type(f) != unknown_font_type) + return; + set_font_type(f, real_font_type); + if (auto_expand_vf(f)) + return; /* auto-expanded virtual font */ + stack_level = 0; + /* Open |vf_file|, return if not found */ + vf_cur = 0; + vf_buffer = NULL; + vf_size = 0; + if (!open_vf_file(font_name(f), &vf_buffer, &vf_size)) + return; + /* Process the preamble */ + set_font_type(f, virtual_font_type); + vf_byte(k); + if (k != pre) + bad_vf("PRE command expected"); + vf_byte(k); + if (k != vf_id) + bad_vf("wrong id byte"); + vf_byte(cmd_length); + for (k = 1; k <= cmd_length; k++) + vf_byte(junk); + test_checksum(); + test_dsize(); + vf_z = font_size(f); + vf_replace_z(); + /* Process the font definitions */ + /* scan forward to find the number of internal fonts */ + vf_nf = 0; + save_cur_byte = vf_cur; + vf_byte(cmd); + while ((cmd >= fnt_def1) && (cmd <= (fnt_def1 + 3))) { + vf_read_u((cmd - fnt_def1 + 1), utmp); + vf_read(4, junk); + vf_read(4, junk); + vf_read(4, junk); + vf_byte(k); + vf_byte(junk); + k += junk; + while (k-- > 0) { + vf_byte(junk); + } + incr(vf_nf); + vf_byte(cmd); + } + vf_cur = save_cur_byte; + vf_byte(cmd); + /* malloc and fill the local font arrays */ + if (vf_nf > 0) { + unsigned ii = (unsigned) ((unsigned) vf_nf * sizeof(int)); + vf_local_fnts = xmalloc(ii); + memset(vf_local_fnts, 0, ii); + vf_real_fnts = xmalloc(ii); + memset(vf_real_fnts, 0, ii); + vf_nf = 0; + while ((cmd >= fnt_def1) && (cmd <= (fnt_def1 + 3))) { + vf_read_u((cmd - fnt_def1 + 1), vf_local_fnts[vf_nf]); + vf_real_fnts[vf_nf] = (unsigned) vf_def_font(f, vf_buffer, &vf_cur); + incr(vf_nf); + vf_byte(cmd); + } + } + + + while (cmd <= long_char) { + /* Build a character packet */ + vf_np = 0; + if (cmd == long_char) { + vf_read_u(4, packet_length); + vf_read_u(4, utmp); + cc = (int) utmp; + if (!char_exists(f, cc)) { + bad_vf("invalid character code"); + } + vf_read(4, k); + tfm_width = store_scaled_f(k, font_size(f)); + } else { + packet_length = cmd; + vf_byte(cc); + if (!char_exists(f, cc)) { + bad_vf("invalid character code"); + } + vf_read_u(3, utmp); + k = (int) utmp; /* cf. vftovp.web, line 1028 */ + tfm_width = store_scaled_f(k, font_size(f)); + } + + + if (tfm_width != char_width(f, cc)) { + if (tfm_width != char_width(f, cc)) { + print_nlp(); + tprint("character width mismatch in font "); + tprint(font_name(f)); + tprint(".vf ignored"); + } + } + k = count_packet_bytes(vf_buffer, vf_cur, (int) packet_length); + vpackets = xmalloc((unsigned) (k + 1)); /* need one extra extra for |packet_end| */ + co = get_charinfo(f, cc); + k = 0; + w = 0; + x = 0; + y = 0; + z = 0; + while (packet_length > 0) { + vf_byte(cmd); + decr(packet_length); + + if (cmd < set1) { + if (k == 0) { + k = (int) vf_real_fnts[0]; + append_fnt_set(k); + } + append_packet(packet_char_code); + append_four(cmd); + cmd_length = 0; + cmd = nop; + + } else if (((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) || + ((fnt1 <= cmd) && (cmd <= fnt1 + 3))) { + if (cmd >= fnt1) { + vf_read_u((cmd - fnt1 + 1), utmp); + k = (int) utmp; + packet_length -= (cmd - fnt1 + 1); + } else { + k = (int) cmd - fnt_num_0; + } + + /* change from local to external font id */ + n = 0; + while ((n < vf_nf) && (vf_local_fnts[n] != (unsigned) k)) + n++; + if (n == vf_nf) + bad_vf("undefined local font"); + + k = (int) vf_real_fnts[n]; + append_fnt_set(k); + cmd_length = 0; + cmd = nop; + } else { + switch (cmd) { + case set_rule: + vf_read(4, h); + vf_read(4, v); + append_packet(packet_rule_code); + append_four(h); + append_four(v); + packet_length -= 8; + break; + case put_rule: + vf_read(4, h); + vf_read(4, v); + append_packet(packet_push_code); + append_packet(packet_rule_code); + append_four(h); + append_four(v); + append_packet(packet_pop_code); + packet_length -= 8; + break; + case set1: + case set2: + case set3: + case set4: + if (k == 0) { + k = (int) vf_real_fnts[0]; + append_fnt_set(k); + } + vf_read_u((cmd - set1 + 1), utmp); + i = (int) utmp; + append_packet(packet_char_code); + append_four(i); + packet_length -= (cmd - set1 + 1); + break; + case put1: + case put2: + case put3: + case put4: + if (k == 0) { + k = (int) vf_real_fnts[0]; + append_fnt_set(k); + } + vf_read_u((cmd - put1 + 1), utmp); + i = (int) utmp; + append_packet(packet_push_code); + append_packet(packet_char_code); + append_four(i); + append_packet(packet_pop_code); + packet_length -= (cmd - put1 + 1); + break; + case right1: + case right2: + case right3: + case right4: + vf_read((cmd - right1 + 1), i); + append_packet(packet_right_code); + append_four(i); + packet_length -= (cmd - right1 + 1); + break; + case w1: + case w2: + case w3: + case w4: + vf_read((cmd - w1 + 1), w); + append_packet(packet_right_code); + append_four(w); + packet_length -= (cmd - w1 + 1); + break; + case x1: + case x2: + case x3: + case x4: + vf_read((cmd - x1 + 1), x); + append_packet(packet_right_code); + append_four(x); + packet_length -= (cmd - x1 + 1); + break; + case down1: + case down2: + case down3: + case down4: + vf_read((cmd - down1 + 1), i); + append_packet(packet_down_code); + append_four(i); + packet_length -= (cmd - down1 + 1); + break; + case y1: + case y2: + case y3: + case y4: + vf_read((cmd - y1 + 1), y); + append_packet(packet_down_code); + append_four(y); + packet_length -= (cmd - y1 + 1); + break; + case z1: + case z2: + case z3: + case z4: + vf_read((cmd - z1 + 1), z); + append_packet(packet_down_code); + append_four(z); + packet_length -= (cmd - z1 + 1); + break; + case xxx1: + case xxx2: + case xxx3: + case xxx4: + vf_read_u((cmd - xxx1 + 1), utmp); + cmd_length = (int) utmp; + packet_length -= (cmd - xxx1 + 1); + if (cmd_length <= 0) + bad_vf("special of negative length"); + packet_length -= (unsigned) cmd_length; + + append_packet(packet_special_code); + append_four(cmd_length); + while (cmd_length > 0) { + cmd_length--; + vf_byte(i); + append_packet(i); + } + break; + case w0: + append_packet(packet_right_code); + append_four(w); + break; + case x0: + append_packet(packet_right_code); + append_four(x); + break; + case y0: + append_packet(packet_down_code); + append_four(y); + break; + case z0: + append_packet(packet_down_code); + append_four(z); + break; + case nop: + break; + case push: + if (stack_level == vf_stack_size) { + overflow("virtual font stack size", vf_stack_size); + } else { + vf_stack[stack_level].stack_w = w; + vf_stack[stack_level].stack_x = x; + vf_stack[stack_level].stack_y = y; + vf_stack[stack_level].stack_z = z; + incr(stack_level); + append_packet(packet_push_code); + } + break; + case pop: + if (stack_level == 0) { + bad_vf("more POPs than PUSHs in character"); + } else { + decr(stack_level); + w = vf_stack[stack_level].stack_w; + x = vf_stack[stack_level].stack_x; + y = vf_stack[stack_level].stack_y; + z = vf_stack[stack_level].stack_z; + append_packet(packet_pop_code); + } + break; + default: + bad_vf("improver DVI command"); + } + } + } + /* signal end of packet */ + append_packet(packet_end_code); + + if (stack_level != 0) + bad_vf("more PUSHs than POPs in character packet"); + if (packet_length != 0) + bad_vf("invalid packet length or DVI command in packet"); + /* \.{Store the packet being built} */ + set_charinfo_packets(co, vpackets); + vf_byte(cmd); + } + if (cmd != post) + bad_vf("POST command expected"); + + xfree(vf_buffer); +} + +@ @c +#define make_command0(N,K) { \ + lua_newtable(L); \ + lua_pushstring(L, N); \ + lua_rawseti(L,-2, 1); \ + lua_rawseti(L,-2, K); \ + K++; } + +#define make_command1(N,V,K) { \ + lua_newtable(L); \ + lua_pushstring(L, N); \ + lua_rawseti(L,-2, 1); \ + lua_pushnumber(L, V); \ + lua_rawseti(L,-2, 2); \ + lua_rawseti(L,-2, K); \ + K++; } + +#define make_command2(N,V,W,K) { \ + lua_newtable(L); \ + lua_pushstring(L, N); \ + lua_rawseti(L,-2, 1); \ + lua_pushnumber(L, V); \ + lua_rawseti(L,-2, 2); \ + lua_pushnumber(L, W); \ + lua_rawseti(L,-2, 3); \ + lua_rawseti(L,-2, K); \ + K++; } + +#define make_commands(N,S,V,K) { \ + lua_newtable(L); \ + lua_pushstring(L, N); \ + lua_rawseti(L,-2, 1); \ + lua_pushlstring(L, S, V); \ + lua_rawseti(L,-2, 2); \ + lua_rawseti(L,-2, K); \ + K++; } + + +int make_vf_table(lua_State * L, const char *cnom, scaled atsize) +{ + int cmd, k, i; + int cc; + unsigned cmd_length, packet_length; + scaled tfm_width; + vf_stack_index stack_level; + int vf_z; /* multiplier */ + int vf_alpha; /* correction for negative values */ + char vf_beta; /* divisor */ + eight_bits *s; + scaled h, v; + scaled w, x, y, z; + int s_top; /* lua stack */ + int vf_nf; /* local font counter */ + scaled ds, fs; + four_quarters cs; + memory_word tmp_w; /* accumulator */ + vf_stack_record vf_stack[256]; + unsigned char *vf_buffer; + int vf_size; + int vf_cur; + unsigned utmp; + + + stack_level = 0; + /* Open |vf_file|, return if not found */ + vf_cur = 0; + vf_buffer = NULL; + vf_size = 0; + if (!open_vf_file(cnom, &vf_buffer, &vf_size)) { + lua_pushnil(L); + return 1; + } + + /* start by creating a table */ + s_top = lua_gettop(L); + lua_newtable(L); + + /* Process the preamble */ + vf_byte(k); + if (k != pre) + lua_bad_vf("PRE command expected"); + vf_byte(k); + if (k != vf_id) + lua_bad_vf("wrong id byte"); + vf_byte(cmd_length); + + s = xmalloc(cmd_length); + for (k = 1; k <= (int) cmd_length; k++) + vf_byte(s[(k - 1)]); + + lua_pushlstring(L, (char *) s, (size_t) cmd_length); + free(s); + lua_setfield(L, -2, "header"); + + vf_byte(cs.b0); + vf_byte(cs.b1); + vf_byte(cs.b2); + vf_byte(cs.b3); + lua_pushnumber(L, + (lua_Number) ((cs.b0 << 24) + (cs.b1 << 16) + + (cs.b2 << 8) + cs.b3)); + lua_setfield(L, -2, "checksum"); + + vf_read(4, k); + ds = k / 16; + lua_pushinteger(L, ds); + lua_setfield(L, -2, "designsize"); + + + lua_pushstring(L, cnom); + lua_setfield(L, -2, "name"); + + lua_pushinteger(L, atsize); + lua_setfield(L, -2, "size"); + + vf_z = atsize; + vf_replace_z(); + /* Process the font definitions */ + vf_byte(cmd); + lua_newtable(L); + + i = 1; + while ((cmd >= fnt_def1) && (cmd <= fnt_def1 + 3)) { + + lua_newtable(L); + vf_read_u((cmd - fnt_def1 + 1), utmp); + vf_nf = (int) utmp; + vf_nf++; + /* checksum */ + vf_byte(cs.b0); + vf_byte(cs.b1); + vf_byte(cs.b2); + vf_byte(cs.b3); + + vf_read(4, k); + fs = store_scaled_f(k, atsize); + lua_pushstring(L, "size"); + lua_pushnumber(L, fs); + lua_rawset(L, -3); + + vf_read(4, k); + ds = k / 16; /* dsize, not used */ + + vf_byte(tmp_b0); + vf_byte(tmp_b1); + while (tmp_b0 > 0) { + tmp_b0--; + vf_byte(k); + } /* skip the font path */ + + s = xmalloc((unsigned) (tmp_b1 + 1)); + k = 0; + while (tmp_b1-- > 0) + vf_byte(s[k++]); + s[k] = 0; + lua_pushstring(L, "name"); + lua_pushstring(L, xstrdup((char *) s)); + free(s); + lua_rawset(L, -3); + + lua_rawseti(L, -2, vf_nf); + i++; + vf_byte(cmd); + } + + if (i > 1) { + lua_setfield(L, -2, "fonts"); + } else { + lua_pop(L, 1); + } + + lua_newtable(L); /* 'characters' */ + while (cmd <= long_char) { + /* Build a character packet */ + if (cmd == long_char) { + vf_read_u(4, packet_length); + vf_read_u(4, utmp); + cc = (int) utmp; + vf_read(4, tfm_width); + } else { + packet_length = (unsigned) cmd; + vf_byte(cc); + vf_read_u(3, utmp); + tfm_width = (int) utmp; + } + + + + lua_newtable(L); /* for this character */ + + lua_pushnumber(L, tfm_width); + lua_setfield(L, -2, "width"); + + lua_newtable(L); /* for 'commands' */ + + k = 1; + vf_nf = 0; + w = 0; + x = 0; + y = 0; + z = 0; + while (packet_length > 0) { + vf_byte(cmd); + decr(packet_length); + + if ((cmd >= set_char_0) && (cmd < set1)) { + if (vf_nf == 0) { + vf_nf = 1; + make_command1("font", vf_nf, k); + } + make_command1("char", cmd, k); + + } else if (((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) || + ((fnt1 <= cmd) && (cmd <= fnt1 + 3))) { + if (cmd >= fnt1) { + vf_read_u((cmd - fnt1 + 1), utmp); + vf_nf = (int) utmp; + vf_nf++; + packet_length -= (unsigned) (cmd - fnt1 + 1); + } else { + vf_nf = cmd - fnt_num_0 + 1; + } + make_command1("font", vf_nf, k); + } else { + switch (cmd) { + case set_rule: + vf_read(4, h); + vf_read(4, v); + make_command2("rule", store_scaled_f(h, atsize), + store_scaled_f(v, atsize), k); + packet_length -= 8; + break; + case put_rule: + vf_read(4, h); + vf_read(4, v); + make_command0("push", k); + make_command2("rule", store_scaled_f(h, atsize), + store_scaled_f(v, atsize), k); + make_command0("pop", k); + packet_length -= 8; + break; + case set1: + case set2: + case set3: + case set4: + if (vf_nf == 0) { + vf_nf = 1; + make_command1("font", vf_nf, k); + } + vf_read_u((cmd - set1 + 1), utmp); + i = (int) utmp; + make_command1("char", i, k); + packet_length -= (unsigned) (cmd - set1 + 1); + break; + case put1: + case put2: + case put3: + case put4: + if (vf_nf == 0) { + vf_nf = 1; + make_command1("font", vf_nf, k); + } + vf_read_u((cmd - put1 + 1), utmp); + i = (int) utmp; + make_command0("push", k); + make_command1("char", i, k); + make_command0("pop", k); + packet_length -= (unsigned) (cmd - put1 + 1); + break; + case right1: + case right2: + case right3: + case right4: + vf_read((cmd - right1 + 1), i); + make_command1("right", store_scaled_f(i, atsize), k); + packet_length -= (unsigned) (cmd - right1 + 1); + break; + case w1: + case w2: + case w3: + case w4: + vf_read((cmd - w1 + 1), w); + make_command1("right", store_scaled_f(w, atsize), k); + packet_length -= (unsigned) (cmd - w1 + 1); + break; + case x1: + case x2: + case x3: + case x4: + vf_read((cmd - x1 + 1), x); + make_command1("right", store_scaled_f(x, atsize), k); + packet_length -= (unsigned) (cmd - x1 + 1); + break; + case down1: + case down2: + case down3: + case down4: + vf_read((cmd - down1 + 1), i); + make_command1("down", store_scaled_f(i, atsize), k); + packet_length -= (unsigned) (cmd - down1 + 1); + break; + case y1: + case y2: + case y3: + case y4: + vf_read((cmd - y1 + 1), y); + make_command1("down", store_scaled_f(y, atsize), k); + packet_length -= (unsigned) (cmd - y1 + 1); + break; + case z1: + case z2: + case z3: + case z4: + vf_read((cmd - z1 + 1), z); + make_command1("down", store_scaled_f(z, atsize), k); + packet_length -= (unsigned) (cmd - z1 + 1); + break; + case xxx1: + case xxx2: + case xxx3: + case xxx4: + vf_read_u((cmd - xxx1 + 1), cmd_length); + packet_length -= (unsigned) (cmd - xxx1 + 1); + if (cmd_length <= 0) + lua_bad_vf("special of negative length"); + packet_length -= cmd_length; + + s = xmalloc((cmd_length + 1)); + i = 0; + while (cmd_length > 0) { + cmd_length--; + vf_byte(s[i]); + i++; + } + s[i] = 0; + make_commands("special", xstrdup((char *) s), (size_t) i, + k); + free(s); + break; + case w0: + make_command1("right", store_scaled_f(w, atsize), k); + break; + case x0: + make_command1("right", store_scaled_f(x, atsize), k); + break; + case y0: + make_command1("down", store_scaled_f(y, atsize), k); + break; + case z0: + make_command1("down", store_scaled_f(z, atsize), k); + break; + case nop: + break; + case push: + if (stack_level == vf_stack_size) { + overflow("virtual font stack size", vf_stack_size); + } else { + vf_stack[stack_level].stack_w = w; + vf_stack[stack_level].stack_x = x; + vf_stack[stack_level].stack_y = y; + vf_stack[stack_level].stack_z = z; + incr(stack_level); + make_command0("push", k); + } + break; + case pop: + if (stack_level == 0) { + lua_bad_vf("more POPs than PUSHs in character"); + } else { + decr(stack_level); + w = vf_stack[stack_level].stack_w; + x = vf_stack[stack_level].stack_x; + y = vf_stack[stack_level].stack_y; + z = vf_stack[stack_level].stack_z; + make_command0("pop", k); + } + break; + default: + lua_bad_vf("improver DVI command"); + } + } + } + /* signal end of packet */ + lua_setfield(L, -2, "commands"); + + if (stack_level != 0) + lua_bad_vf("more PUSHs than POPs in character packet"); + if (packet_length != 0) + lua_bad_vf("invalid packet length or DVI command in packet"); + + lua_rawseti(L, -2, cc); + + vf_byte(cmd); + } + lua_setfield(L, -2, "characters"); + + if (cmd != post) + lua_bad_vf("POST command expected"); + xfree(vf_buffer); + return 1; +} + + +@ This function is called from |do_vf|, and fixes up the virtual data +inside an auto-expanded virtual font + +@c +boolean auto_expand_vf(internal_font_number f) +{ + + internal_font_number bf; + int e, k; + int *vf_old_fonts, *vf_new_fonts; + int num = 0; + + if ((!font_auto_expand(f)) || (pdf_font_blink(f) == null_font)) + return false; /* not an auto-expanded font */ + bf = pdf_font_blink(f); + + if (font_type(bf) != virtual_font_type) + return false; /* not a virtual font */ + + e = font_expand_ratio(f); + + vf_old_fonts = packet_local_fonts(bf, &num); + if (num > 0) { + vf_new_fonts = xmalloc((unsigned) ((unsigned) num * sizeof(int))); + for (k = 0; k < num; k++) { + vf_new_fonts[k] = auto_expand_font(vf_old_fonts[k], e); + copy_expand_params(vf_new_fonts[k], vf_old_fonts[k], e); + } + replace_packet_fonts(f, vf_old_fonts, vf_new_fonts, num); + xfree(vf_new_fonts); + xfree(vf_old_fonts); + } + set_font_type(f, virtual_font_type); + return true; +} + +@ @c +internal_font_number auto_expand_font(internal_font_number f, int e) +{ + internal_font_number k; + kerninfo *krn; + charinfo *co; + int i; + scaled w; + k = copy_font(f); + set_font_name(k, font_name(f)); + set_font_expand_ratio(k, e); + for (i = font_bc(k); i <= font_ec(k); i++) { + if (quick_char_exists(k, i)) { + co = get_charinfo(k, i); + w = round_xn_over_d(char_width(f, i), 1000 + e, 1000); + set_charinfo_width(co, w); + w = round_xn_over_d(char_italic(f, i), 1000 + e, 1000); + set_charinfo_italic(co, w); + krn = get_charinfo_kerns(co); + if (krn != NULL) { + while (!kern_end((*krn))) { + kern_kern(*krn) = + round_xn_over_d(kern_kern(*krn), 1000 + e, 1000); + krn++; + } + } + } + } + return k; +} + +@ @c +void vf_expand_local_fonts(internal_font_number f) +{ + internal_font_number lf; + int k, num; + int *vf_old_fonts; + pdfassert(font_type(f) == virtual_font_type); + num = 0; + vf_old_fonts = packet_local_fonts(f, &num); + if (num > 0) { + for (k = 0; k < num; k++) { + lf = vf_old_fonts[k]; + set_expand_params(lf, font_auto_expand(f), + font_expand_ratio(font_stretch(f)), + -font_expand_ratio(font_shrink(f)), + font_step(f), font_expand_ratio(f)); + if (font_type(lf) == virtual_font_type) + vf_expand_local_fonts(lf); + } + xfree(vf_old_fonts); + } +} + +@ @c +internal_font_number +letter_space_font(halfword u, internal_font_number f, int e) +{ + internal_font_number k; + scaled w, r; + + char *new_font_name; + int vf_z; + int vf_alpha; + int vf_beta; + memory_word tmp_w; /* accumulator */ + + + /* read a new font and expand the character widths */ + k = read_font_info(u, font_name(f), font_size(f), font_natural_dir(f)); + set_no_ligatures(k); /* disable ligatures for letter-spaced fonts */ +#if 0 + for (i = 0;i <= font_widths(k);i++) { + set_font_width(k,i,font_width(f,i)+round_xn_over_d(quad(k), e, 1000)); + } +#endif + /* append eg '+100ls' to font name */ + new_font_name = xmalloc((unsigned) (strlen(font_name(k)) + 8)); /* |abs(e) <= 1000| */ + if (e > 0) { + sprintf(new_font_name, "%s+%ils", font_name(k), (int) e); + } else { + /* minus from \%i */ + sprintf(new_font_name, "%s%ils", font_name(k), (int) e); + } + set_font_name(k, new_font_name); + + /* create the corresponding virtual font */ + set_font_type(k, virtual_font_type); + + vf_z = font_size(f); + vf_replace_z(); + w = round_xn_over_d(quad(f), e, 2000); + if (w > 0) { + tmp_b0 = 0; + } else { + tmp_b0 = 255; + w = vf_alpha + w; + } + r = w * vf_beta; + tmp_b1 = (quarterword) (r / vf_z); + r = r % vf_z; + if (r == 0) { + tmp_b2 = 0; + } else { + r = r * 256; + tmp_b2 = (quarterword) (r / vf_z); + r = r % vf_z; + } + if (r == 0) { + tmp_b3 = 0; + } else { + r = r * 256; + tmp_b3 = (quarterword) (r / vf_z); + } +#if 0 + vf_packet_base[k] = new_vf_packet(k); + + for (c=font_bc(k);c<=font_ec(k);c++) { + string_room(17); + append_fnt_set(f); + append_packet(right1 + 3); + append_packet(tmp_b0); + append_packet(tmp_b1); + append_packet(tmp_b2); + append_packet(tmp_b3); + + append_packet(set1); + append_packet(c); + + append_packet(right1 + 3); + append_packet(tmp_b0); + append_packet(tmp_b1); + append_packet(tmp_b2); + append_packet(tmp_b3); + s = make_string(); + store_packet(k, c, s); + flush_str(s); + } +#endif + return k; +} + +@ the fontname has [+-]\d+ls at the end +@c +boolean is_letterspaced_font(internal_font_number f) +{ + char *i, *j; + if (font_type(f) != virtual_font_type) + return false; + j = font_name(f); + i = j + strlen(j); + if ((*(i - 1) != 'l') || (*i != 's')) + return false; + i = i - 2; + while (i >= j) { + if ((*i < '0') || (*i > '9')) + break; + i--; + } + if (i < j) + return false; + if ((*i != '+') && (*i != '-')) + return false; + return true; +} + +@ @c +internal_font_number copy_font_info(internal_font_number f) +{ + return copy_font(f); +} diff --git a/Build/source/texk/web2c/luatexdir/font/vfpacket.c b/Build/source/texk/web2c/luatexdir/font/vfpacket.c deleted file mode 100644 index 161330469e3..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/vfpacket.c +++ /dev/null @@ -1,375 +0,0 @@ -/* vfpacket.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" - -static const char _svn_version[] = - "$Id: vfpacket.c 2414 2009-06-03 12:57:01Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/vfpacket.c $"; - -/* - The |do_vf_packet| procedure is called in order to interpret the - character packet for a virtual character. Such a packet may contain - the instruction to typeset a character from the same or an other - virtual font; in such cases |do_vf_packet| calls itself - recursively. The recursion level, i.e., the number of times this has - happened, is kept in the global variable |packet_cur_s| and should - not exceed |packet_max_recursion|. -*/ - -#define packet_max_recursion 100 - -typedef unsigned char packet_stack_index; /* an index into the stack */ - -typedef struct packet_stack_record { - scaled stack_h; - scaled stack_v; -} packet_stack_record; - - -static packet_stack_index packet_cur_s = 0; /* current recursion level */ -static packet_stack_record packet_stack[packet_max_recursion]; -static packet_stack_index packet_stack_ptr = 0; /* pointer into |packet_stack| */ - - -/* Some macros for processing character packets. */ - -#define do_packet_byte() vf_packets[cur_packet_byte++] - -#define packet_number(fw) { \ - fw = do_packet_byte(); \ - fw = fw*256 + do_packet_byte(); \ - fw = fw*256 + do_packet_byte(); \ - fw = fw*256 + do_packet_byte(); } - -#define packet_scaled(a,fs) { integer fw; \ - fw = do_packet_byte(); \ - if (fw>127) fw = fw - 256; \ - fw = fw*256 + do_packet_byte(); \ - fw = fw*256 + do_packet_byte(); \ - fw = fw*256 + do_packet_byte(); \ - a = store_scaled_f(fw, fs); } - - -/* count the number of bytes in a command packet */ -int vf_packet_bytes(charinfo * co) -{ - real_eight_bits *vf_packets; - integer cur_packet_byte; - unsigned k; - int cmd; - - vf_packets = get_charinfo_packets(co); - if (vf_packets == NULL) { - return 0; - } - cur_packet_byte = 0; - while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { - cur_packet_byte++; - switch (cmd) { - case packet_char_code: - case packet_font_code: - case packet_right_code: - case packet_down_code: - case packet_node_code: - cur_packet_byte += 4; - break; - case packet_push_code: - case packet_pop_code: - break; - case packet_rule_code: - cur_packet_byte += 8; - break; - case packet_special_code: - packet_number(k); /* +4 */ - cur_packet_byte += k; - break; - case packet_image_code: - cur_packet_byte += 4; - break; - case packet_nop_code: - break; - default: - pdf_error(maketexstring("vf"), - maketexstring("invalid DVI command (1)")); - } - }; - return (cur_packet_byte + 1); -} - - -/* typeset the \.{DVI} commands in the - character packet for character |c| in current font |f| */ - -#if 0 /* unused */ -static char *packet_command_names[] = { - "char", "font", "pop", "push", "special", "image", - "right", "down", "rule", "node", "nop", "end", NULL -}; -#endif - - -void do_vf_packet(internal_font_number vf_f, integer c) -{ - internal_font_number lf; - charinfo *co; - scaledpos save_cur; - real_eight_bits *vf_packets; - integer cur_packet_byte; - integer cmd, fs_f; - scaled i; - unsigned k; - str_number s; - - packet_cur_s++; - if (packet_cur_s >= packet_max_recursion) - overflow_string("max level recursion of virtual fonts", - packet_max_recursion); - save_cur = cur; - - lf = 0; /* for -Wall */ - co = get_charinfo(vf_f, c); - vf_packets = get_charinfo_packets(co); - if (vf_packets == NULL) { - packet_cur_s--; - return; - } - cur_packet_byte = 0; - fs_f = font_size(vf_f); - while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { - cur_packet_byte++; - /* - if (cmd>packet_end_code) { - fprintf(stdout, "do_vf_packet(%i,%i) command code = illegal \n", vf_f,c); - } else { - fprintf(stdout, "do_vf_packet(%i,%i) command code = %s\n",vf_f, c, packet_command_names[cmd]); - } - */ - switch (cmd) { - case packet_font_code: - packet_number(lf); - break; - case packet_push_code: - packet_stack[packet_stack_ptr].stack_h = cur.h; - packet_stack[packet_stack_ptr].stack_v = cur.v; - packet_stack_ptr++; - break; - case packet_pop_code: - packet_stack_ptr--; - cur.h = packet_stack[packet_stack_ptr].stack_h; - cur.v = packet_stack[packet_stack_ptr].stack_v; - break; - case packet_char_code: - packet_number(k); - if (!char_exists(lf, k)) { - char_warning(lf, k); - } else { - if (has_packet(lf, k)) - do_vf_packet(lf, k); - else { - pos = synch_p_with_c(cur); - pdf_place_glyph(lf, k); - } - } - cur.h = cur.h + char_width(lf, k); - break; - case packet_rule_code: - packet_scaled(rule_ht, fs_f); - packet_scaled(rule_wd, fs_f); - if ((rule_wd > 0) && (rule_ht > 0)) { - pos = synch_p_with_c(cur); - pdf_place_rule(pos.h, pos.v, rule_wd, rule_ht); - } - cur.h = cur.h + rule_wd; - break; - case packet_right_code: - packet_scaled(i, fs_f); - cur.h = cur.h + i; - break; - case packet_down_code: - packet_scaled(i, fs_f); - cur.v = cur.v + i; - break; - case packet_special_code: - packet_number(k); - string_room(k); - while (k > 0) { - k--; - append_pool_char(do_packet_byte()); - } - s = make_string(); - literal(s, scan_special, false); - flush_str(s); - break; - case packet_image_code: - packet_number(k); - pos = synch_p_with_c(cur); - vf_out_image(k); - break; - case packet_node_code: - packet_number(k); - temp_ptr = k; - pdf_hlist_out(); - break; - case packet_nop_code: - break; - default: - pdf_error(maketexstring("vf"), - maketexstring("invalid DVI command (2)")); - } - }; - cur = save_cur; - packet_cur_s--; -} - - -integer *packet_local_fonts(internal_font_number f, integer * num) -{ - int c, cmd, cur_packet_byte, lf, k, l, i; - integer localfonts[256] = { 0 }; - integer *lfs; - charinfo *co; - - real_eight_bits *vf_packets; - k = 0; - for (c = font_bc(f); c <= font_ec(f); c++) { - if (char_exists(f, c)) { - co = get_charinfo(f, c); - vf_packets = get_charinfo_packets(co); - if (vf_packets == NULL) - continue; - cur_packet_byte = 0; - while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { - cur_packet_byte++; - switch (cmd) { - case packet_font_code: - packet_number(lf); - for (l = 0; l < k; l++) { - if (localfonts[l] == lf) { - break; - } - } - if (l == k) { - localfonts[k++] = lf; - } - break; - case packet_push_code: - case packet_pop_code: - case packet_nop_code: - break; - case packet_char_code: - case packet_right_code: - case packet_down_code: - case packet_node_code: - cur_packet_byte += 4; - break; - case packet_rule_code: - cur_packet_byte += 8; - break; - case packet_special_code: - packet_number(i); - while (i-- > 0) - (void) do_packet_byte(); - break; - case packet_image_code: - cur_packet_byte += 4; - break; - default: - pdf_error(maketexstring("vf"), - maketexstring("invalid DVI command (3)")); - } - } - } - } - *num = k; - if (k > 0) { - lfs = xmalloc(k * sizeof(integer)); - memcpy(lfs, localfonts, k * sizeof(integer)); - return lfs; - } - return NULL; -} - - -void -replace_packet_fonts(internal_font_number f, integer * old_fontid, - integer * new_fontid, int count) -{ - int c, cmd, cur_packet_byte, lf, k, l; - charinfo *co; - real_eight_bits *vf_packets; - - k = 0; - for (c = font_bc(f); c <= font_ec(f); c++) { - if (char_exists(f, c)) { - co = get_charinfo(f, c); - vf_packets = get_charinfo_packets(co); - if (vf_packets == NULL) - continue; - cur_packet_byte = 0; - while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { - cur_packet_byte++; - switch (cmd) { - case packet_font_code: - packet_number(lf); - for (l = 0; l < count; l++) { - if (old_fontid[l] == lf) { - break; - } - } - if (l < count) { - k = new_fontid[l]; - vf_packets[(cur_packet_byte - 4)] = - (k & 0xFF000000) >> 24; - vf_packets[(cur_packet_byte - 3)] = - (k & 0x00FF0000) >> 16; - vf_packets[(cur_packet_byte - 2)] = - (k & 0x0000FF00) >> 8; - vf_packets[(cur_packet_byte - 1)] = (k & 0x000000FF); - } - break; - case packet_push_code: - case packet_pop_code: - case packet_nop_code: - break; - case packet_char_code: - case packet_right_code: - case packet_down_code: - case packet_node_code: - cur_packet_byte += 4; - break; - case packet_rule_code: - cur_packet_byte += 8; - break; - case packet_special_code: - packet_number(k); - while (k-- > 0) - (void) do_packet_byte(); - break; - case packet_image_code: - cur_packet_byte += 4; - break; - default: - pdf_error(maketexstring("vf"), - maketexstring("invalid DVI command (4)")); - } - } - } - } -} diff --git a/Build/source/texk/web2c/luatexdir/font/vfpacket.w b/Build/source/texk/web2c/luatexdir/font/vfpacket.w new file mode 100644 index 00000000000..eb28fcdcc4c --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/vfpacket.w @@ -0,0 +1,375 @@ +% vfpacket.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2009 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" + +static const char _svn_version[] = + "$Id: vfpacket.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/vfpacket.w $"; + + +@ The |do_vf_packet| procedure is called in order to interpret the + character packet for a virtual character. Such a packet may contain + the instruction to typeset a character from the same or an other + virtual font; in such cases |do_vf_packet| calls itself + recursively. The recursion level, i.e., the number of times this has + happened, is kept in the global variable |packet_cur_s| and should + not exceed |packet_max_recursion|. + +@c +#define packet_max_recursion 100 + +typedef unsigned char packet_stack_index; /* an index into the stack */ + +typedef struct packet_stack_record { + scaled stack_h; + scaled stack_v; +} packet_stack_record; + + +static packet_stack_index packet_cur_s = 0; /* current recursion level */ +static packet_stack_record packet_stack[packet_max_recursion]; +static packet_stack_index packet_stack_ptr = 0; /* pointer into |packet_stack| */ + + +@ Some macros for processing character packets. +@c +#define do_packet_byte() vf_packets[cur_packet_byte++] + +#define packet_number(fw) { \ + fw = do_packet_byte(); \ + fw = fw*256 + do_packet_byte(); \ + fw = fw*256 + do_packet_byte(); \ + fw = fw*256 + do_packet_byte(); } + +#define packet_scaled(a,fs) { int fw; \ + fw = do_packet_byte(); \ + if (fw>127) fw = fw - 256; \ + fw = fw*256 + do_packet_byte(); \ + fw = fw*256 + do_packet_byte(); \ + fw = fw*256 + do_packet_byte(); \ + a = store_scaled_f(fw, fs); } + + +@ count the number of bytes in a command packet +@c +int vf_packet_bytes(charinfo * co) +{ + eight_bits *vf_packets; + int cur_packet_byte; + unsigned k; + int cmd; + + vf_packets = get_charinfo_packets(co); + if (vf_packets == NULL) { + return 0; + } + cur_packet_byte = 0; + while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { + cur_packet_byte++; + switch (cmd) { + case packet_char_code: + case packet_font_code: + case packet_right_code: + case packet_down_code: + case packet_node_code: + cur_packet_byte += 4; + break; + case packet_push_code: + case packet_pop_code: + break; + case packet_rule_code: + cur_packet_byte += 8; + break; + case packet_special_code: + packet_number(k); /* +4 */ + cur_packet_byte = (cur_packet_byte + (int) k); + break; + case packet_image_code: + cur_packet_byte += 4; + break; + case packet_nop_code: + break; + default: + pdf_error("vf", "invalid DVI command (1)"); + } + }; + return (cur_packet_byte + 1); +} + + +@ typeset the \.{DVI} commands in the + character packet for character |c| in current font |f| +@c +const char *packet_command_names[] = { + "char", "font", "pop", "push", "special", "image", + "right", "down", "rule", "node", "nop", "end", NULL +}; + + +void do_vf_packet(PDF pdf, internal_font_number vf_f, int c) +{ + internal_font_number lf; + charinfo *co; + scaledpos cur = { 0, 0 }, size; + eight_bits *vf_packets; + int cur_packet_byte; + int cmd, fs_f; + scaled i; + unsigned k; + str_number s; + + posstructure localpos; /* the position structure local within this function */ + posstructure *refpos; /* the list origin pos. on the page, provided by the caller */ + + lf = 0; /* for -Wall */ + packet_cur_s++; + if (packet_cur_s >= packet_max_recursion) + overflow("max level recursion of virtual fonts", packet_max_recursion); + co = get_charinfo(vf_f, c); + vf_packets = get_charinfo_packets(co); + if (vf_packets == NULL) { + packet_cur_s--; + return; + } + + refpos = pdf->posstruct; + pdf->posstruct = &localpos; /* use local structure for recursion */ + localpos.pos = refpos->pos; + localpos.dir = dir_TLT; /* invariably for vf */ + + cur_packet_byte = 0; + fs_f = font_size(vf_f); + while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { + cur_packet_byte++; +#ifdef DEBUG + if (cmd>packet_end_code) { + fprintf(stdout, "do_vf_packet(%i,%i) command code = illegal \n", vf_f,c); + } else { + fprintf(stdout, "do_vf_packet(%i,%i) command code = %s\n",vf_f, c, packet_command_names[cmd]); + } +#endif + switch (cmd) { + case packet_font_code: + packet_number(lf); + break; + case packet_push_code: + packet_stack[packet_stack_ptr].stack_h = cur.h; + packet_stack[packet_stack_ptr].stack_v = cur.v; + packet_stack_ptr++; + break; + case packet_pop_code: + packet_stack_ptr--; + cur.h = packet_stack[packet_stack_ptr].stack_h; + cur.v = packet_stack[packet_stack_ptr].stack_v; + break; + case packet_char_code: + packet_number(k); + if (!char_exists(lf, (int) k)) { + char_warning(lf, (int) k); + } else { + if (has_packet(lf, (int) k)) + do_vf_packet(pdf, lf, (int) k); + else + pdf_place_glyph(pdf, lf, (int) k); + } + cur.h = cur.h + char_width(lf, (int) k); + break; + case packet_rule_code: + packet_scaled(size.v, fs_f); /* height (where is depth?) */ + packet_scaled(size.h, fs_f); + if (size.h > 0 && size.v > 0) + pdf_place_rule(pdf, 0, size); /* the 0 is unused */ + cur.h = cur.h + size.h; + break; + case packet_right_code: + packet_scaled(i, fs_f); + cur.h = cur.h + i; + break; + case packet_down_code: + packet_scaled(i, fs_f); + cur.v = cur.v + i; + break; + case packet_special_code: + packet_number(k); + str_room((unsigned) k); + while (k > 0) { + k--; + append_char(do_packet_byte()); + } + s = make_string(); + pdf_literal(pdf, s, scan_special, false); + flush_str(s); + break; + case packet_image_code: + packet_number(k); + vf_out_image(pdf, k); + break; + case packet_node_code: + packet_number(k); + hlist_out(pdf, (halfword) k); + break; + case packet_nop_code: + break; + default: + pdf_error("vf", "invalid DVI command (2)"); + } + synch_pos_with_cur(&localpos, refpos, cur); /* trivial case, always TLT */ + } + packet_cur_s--; + pdf->posstruct = refpos; +} + +@ @c +int *packet_local_fonts(internal_font_number f, int *num) +{ + int c, cmd, cur_packet_byte, lf, k, l, i; + int localfonts[256] = { 0 }; + int *lfs; + charinfo *co; + + eight_bits *vf_packets; + k = 0; + for (c = font_bc(f); c <= font_ec(f); c++) { + if (quick_char_exists(f, c)) { + co = get_charinfo(f, c); + vf_packets = get_charinfo_packets(co); + if (vf_packets == NULL) + continue; + cur_packet_byte = 0; + while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { + cur_packet_byte++; + switch (cmd) { + case packet_font_code: + packet_number(lf); + for (l = 0; l < k; l++) { + if (localfonts[l] == lf) { + break; + } + } + if (l == k) { + localfonts[k++] = lf; + } + break; + case packet_push_code: + case packet_pop_code: + case packet_nop_code: + break; + case packet_char_code: + case packet_right_code: + case packet_down_code: + case packet_node_code: + cur_packet_byte += 4; + break; + case packet_rule_code: + cur_packet_byte += 8; + break; + case packet_special_code: + packet_number(i); + while (i-- > 0) + (void) do_packet_byte(); + break; + case packet_image_code: + cur_packet_byte += 4; + break; + default: + pdf_error("vf", "invalid DVI command (3)"); + } + } + } + } + *num = k; + if (k > 0) { + lfs = xmalloc((unsigned) ((unsigned) k * sizeof(int))); + memcpy(lfs, localfonts, (size_t) ((unsigned) k * sizeof(int))); + return lfs; + } + return NULL; +} + + +@ @c +void +replace_packet_fonts(internal_font_number f, int *old_fontid, + int *new_fontid, int count) +{ + int c, cmd, cur_packet_byte, lf, k, l; + charinfo *co; + eight_bits *vf_packets; + + k = 0; + for (c = font_bc(f); c <= font_ec(f); c++) { + if (quick_char_exists(f, c)) { + co = get_charinfo(f, c); + vf_packets = get_charinfo_packets(co); + if (vf_packets == NULL) + continue; + cur_packet_byte = 0; + while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) { + cur_packet_byte++; + switch (cmd) { + case packet_font_code: + packet_number(lf); + for (l = 0; l < count; l++) { + if (old_fontid[l] == lf) { + break; + } + } + if (l < count) { + k = new_fontid[l]; + vf_packets[(cur_packet_byte - 4)] = (eight_bits) + ((k & 0xFF000000) >> 24); + vf_packets[(cur_packet_byte - 3)] = (eight_bits) + ((k & 0x00FF0000) >> 16); + vf_packets[(cur_packet_byte - 2)] = (eight_bits) + ((k & 0x0000FF00) >> 8); + vf_packets[(cur_packet_byte - 1)] = + (eight_bits) (k & 0x000000FF); + } + break; + case packet_push_code: + case packet_pop_code: + case packet_nop_code: + break; + case packet_char_code: + case packet_right_code: + case packet_down_code: + case packet_node_code: + cur_packet_byte += 4; + break; + case packet_rule_code: + cur_packet_byte += 8; + break; + case packet_special_code: + packet_number(k); + while (k-- > 0) + (void) do_packet_byte(); + break; + case packet_image_code: + cur_packet_byte += 4; + break; + default: + pdf_error("vf", "invalid DVI command (4)"); + } + } + } + } +} diff --git a/Build/source/texk/web2c/luatexdir/font/writecff.c b/Build/source/texk/web2c/luatexdir/font/writecff.c deleted file mode 100644 index 82b52d96d7c..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writecff.c +++ /dev/null @@ -1,3444 +0,0 @@ -/* writecff.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" - -#include "writecff.h" - -static const char _svn_version[] = - "$Id: writecff.c 2448 2009-06-08 07:43:50Z taco $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writecff.c $"; - -#define get_offset(s,n) get_unsigned(s, (n)) -#define get_card8(a) a->stream[a->offset++] -#define get_card16(a) get_unsigned(a,2) - -#undef b0 -#undef b1 -#undef b2 -#undef b3 - -#define WORK_BUFFER_SIZE 1024 - -static char work_buffer[WORK_BUFFER_SIZE]; - -static unsigned long get_unsigned(cff_font * cff, int n) -{ - unsigned long v = 0; - while (n-- > 0) - v = v * 256 + get_card8(cff); - return v; -} - -#define CFF_ERROR pdftex_fail -#undef WARN -#define WARN pdftex_warn - -const char *const cff_stdstr[CFF_STDSTR_MAX] = { - ".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" -}; - - -/* Only read header part but not body */ -cff_index *cff_get_index_header(cff_font * cff) -{ - cff_index *idx; - card16 i, count; - - idx = xcalloc(1, sizeof(cff_index)); - - idx->count = count = get_card16(cff); - if (count > 0) { - idx->offsize = get_card8(cff); - if (idx->offsize < 1 || idx->offsize > 4) - CFF_ERROR("invalid offsize data"); - - idx->offset = xcalloc(count + 1, sizeof(l_offset)); - for (i = 0; i < count + 1; i++) { - (idx->offset)[i] = get_offset(cff, idx->offsize); - } - - if (idx->offset[0] != 1) - CFF_ERROR("cff_get_index(): invalid index data"); - - idx->data = NULL; - } else { - idx->offsize = 0; - idx->offset = NULL; - idx->data = NULL; - } - - return idx; -} - - - -cff_index *cff_get_index(cff_font * cff) -{ - cff_index *idx; - card16 i, count; - long length; - - idx = xcalloc(1, sizeof(cff_index)); - - idx->count = count = get_card16(cff); - if (count > 0) { - idx->offsize = get_card8(cff); - if (idx->offsize < 1 || idx->offsize > 4) - CFF_ERROR("invalid offsize data"); - - idx->offset = xcalloc((count + 1), sizeof(l_offset)); - for (i = 0; i < count + 1; i++) { - idx->offset[i] = get_offset(cff, idx->offsize); - } - - if (idx->offset[0] != 1) - CFF_ERROR("Invalid CFF Index offset data"); - - length = idx->offset[count] - idx->offset[0]; - - idx->data = xcalloc(length, sizeof(card8)); - memcpy(idx->data, &cff->stream[cff->offset], length); - cff->offset += length; - - } else { - idx->offsize = 0; - idx->offset = NULL; - idx->data = NULL; - } - return idx; -} - - -long cff_pack_index(cff_index * idx, card8 * dest, long destlen) -{ - long len = 0; - unsigned long datalen; - card16 i; - - if (idx->count < 1) { - if (destlen < 2) - CFF_ERROR("Not enough space available..."); - memset(dest, 0, 2); - return 2; - } - - len = cff_index_size(idx); - datalen = idx->offset[idx->count] - 1; - - if (destlen < len) - CFF_ERROR("Not enough space available..."); - - *(dest++) = (idx->count >> 8) & 0xff; - *(dest++) = idx->count & 0xff; - - if (datalen < 0xffUL) { - idx->offsize = 1; - *(dest++) = 1; - for (i = 0; i <= idx->count; i++) { - *(dest++) = (card8) (idx->offset[i] & 0xff); - } - } else if (datalen < 0xffffUL) { - idx->offsize = 2; - *(dest++) = 2; - for (i = 0; i <= idx->count; i++) { - *(dest++) = (card8) ((idx->offset[i] >> 8) & 0xff); - *(dest++) = (card8) (idx->offset[i] & 0xff); - } - } else if (datalen < 0xffffffUL) { - idx->offsize = 3; - *(dest++) = 3; - for (i = 0; i <= idx->count; i++) { - *(dest++) = (card8) ((idx->offset[i] >> 16) & 0xff); - *(dest++) = (card8) ((idx->offset[i] >> 8) & 0xff); - *(dest++) = (card8) (idx->offset[i] & 0xff); - } - } else { - idx->offsize = 4; - *(dest++) = 4; - for (i = 0; i <= idx->count; i++) { - *(dest++) = (card8) ((idx->offset[i] >> 24) & 0xff); - *(dest++) = (card8) ((idx->offset[i] >> 16) & 0xff); - *(dest++) = (card8) ((idx->offset[i] >> 8) & 0xff); - *(dest++) = (card8) (idx->offset[i] & 0xff); - } - } - - memmove(dest, idx->data, idx->offset[idx->count] - 1); - - return len; -} - -long cff_index_size(cff_index * idx) -{ - if (idx->count > 0) { - l_offset datalen; - - datalen = idx->offset[idx->count] - 1; - if (datalen < 0xffUL) { - idx->offsize = 1; - } else if (datalen < 0xffffUL) { - idx->offsize = 2; - } else if (datalen < 0xffffffUL) { - idx->offsize = 3; - } else { - idx->offsize = 4; - } - return (3 + (idx->offsize) * (idx->count + 1) + datalen); - } else { - return 2; - } -} - -cff_index *cff_new_index(card16 count) -{ - cff_index *idx; - - idx = xcalloc(1, sizeof(cff_index)); - idx->count = count; - idx->offsize = 0; - - if (count > 0) { - idx->offset = xcalloc(count + 1, sizeof(l_offset)); - (idx->offset)[0] = 1; - } else { - idx->offset = NULL; - } - idx->data = NULL; - - return idx; -} - - -void cff_release_index(cff_index * idx) -{ - if (idx) { - xfree(idx->data); - xfree(idx->offset); - xfree(idx); - } -} - -void cff_release_dict(cff_dict * dict) -{ - if (dict) { - if (dict->entries) { - int i; - for (i = 0; i < dict->count; i++) { - xfree((dict->entries)[i].values); - } - xfree(dict->entries); - } - xfree(dict); - } -} - - -void cff_release_encoding(cff_encoding * encoding) -{ - if (encoding) { - switch (encoding->format & (~0x80)) { - case 0: - xfree(encoding->data.codes); - break; - case 1: - xfree(encoding->data.range1); - break; - default: - CFF_ERROR("Unknown Encoding format."); - } - if (encoding->format & 0x80) - xfree(encoding->supp); - xfree(encoding); - } -} - -void cff_release_charsets(cff_charsets * charset) -{ - if (charset) { - switch (charset->format) { - case 0: - xfree(charset->data.glyphs); - break; - case 1: - xfree(charset->data.range1); - break; - case 2: - xfree(charset->data.range2); - break; - default: - break; - } - xfree(charset); - } -} - -void cff_release_fdselect(cff_fdselect * fdselect) -{ - if (fdselect) { - if (fdselect->format == 0) { - xfree(fdselect->data.fds); - } else if (fdselect->format == 3) { - xfree(fdselect->data.ranges); - } - xfree(fdselect); - } -} - - -void cff_close(cff_font * cff) -{ - card16 i; - - if (cff) { - if (cff->fontname) - xfree(cff->fontname); - if (cff->name) - cff_release_index(cff->name); - if (cff->topdict) - cff_release_dict(cff->topdict); - if (cff->string) - cff_release_index(cff->string); - if (cff->gsubr) - cff_release_index(cff->gsubr); - if (cff->encoding) - cff_release_encoding(cff->encoding); - if (cff->charsets) - cff_release_charsets(cff->charsets); - if (cff->fdselect) - cff_release_fdselect(cff->fdselect); - if (cff->cstrings) - cff_release_index(cff->cstrings); - if (cff->fdarray) { - for (i = 0; i < cff->num_fds; i++) { - if (cff->fdarray[i]) - cff_release_dict(cff->fdarray[i]); - } - xfree(cff->fdarray); - } - if (cff->private) { - for (i = 0; i < cff->num_fds; i++) { - if (cff->private[i]) - cff_release_dict(cff->private[i]); - } - xfree(cff->private); - } - if (cff->subrs) { - for (i = 0; i < cff->num_fds; i++) { - if (cff->subrs[i]) - cff_release_index(cff->subrs[i]); - } - xfree(cff->subrs); - } - if (cff->_string) - cff_release_index(cff->_string); - xfree(cff); - } - - return; -} - -char *cff_get_name(cff_font * cff) -{ - char *fontname; - l_offset len; - cff_index *idx; - - idx = cff->name; - len = idx->offset[cff->index + 1] - idx->offset[cff->index]; - fontname = xmalloc((len + 1) * sizeof(char)); - memcpy(fontname, idx->data + idx->offset[cff->index] - 1, len); - fontname[len] = '\0'; - - return fontname; -} - - -long cff_set_name(cff_font * cff, char *name) -{ - cff_index *idx; - - if (strlen(name) > 127) - CFF_ERROR("FontName string length too large..."); - - if (cff->name) - cff_release_index(cff->name); - - cff->name = idx = xcalloc(1, sizeof(cff_index)); - idx->count = 1; - idx->offsize = 1; - idx->offset = xmalloc(2 * sizeof(l_offset)); - (idx->offset)[0] = 1; - (idx->offset)[1] = strlen(name) + 1; - idx->data = xcalloc(strlen(name), sizeof(card8)); - memmove(idx->data, name, strlen(name)); /* no trailing '\0' */ - - return 5 + strlen(name); -} - -long cff_put_header(cff_font * cff, card8 * dest, long destlen) -{ - if (destlen < 4) - CFF_ERROR("Not enough space available..."); - - *(dest++) = cff->header_major; - *(dest++) = cff->header_minor; - *(dest++) = 4; /* Additional data in between header and - * Name INDEX ignored. - */ - /* We will set all offset (0) to four-byte integer. */ - *(dest++) = 4; - cff->header_offsize = 4; - - return 4; -} - -#define CFF_PARSE_OK 0 -#define CFF_CFF_ERROR_PARSE_CFF_ERROR -1 -#define CFF_CFF_ERROR_STACK_OVERFLOW -2 -#define CFF_CFF_ERROR_STACK_UNDERFLOW -3 -#define CFF_CFF_ERROR_STACK_RANGECHECK -4 - -#define DICT_ENTRY_MAX 16 - -cff_dict *cff_new_dict(void) -{ - cff_dict *dict; - - dict = xcalloc(1, sizeof(cff_dict)); - dict->max = DICT_ENTRY_MAX; - dict->count = 0; - dict->entries = xcalloc(dict->max, sizeof(cff_dict_entry)); - return dict; -} - -/* - * Operand stack: - * only numbers are stored (as double) - * - * Operand types: - * - * number : double (integer or real) - * boolean: stored as a number - * SID : stored as a number - * array : array of numbers - * delta : array of numbers - */ - -#define CFF_DICT_STACK_LIMIT 64 -static int stack_top = 0; -static double arg_stack[CFF_DICT_STACK_LIMIT]; - -/* - * CFF DICT encoding: - * TODO: default values - */ - -#define CFF_LAST_DICT_OP1 22 -#define CFF_LAST_DICT_OP2 39 -#define CFF_LAST_DICT_OP (CFF_LAST_DICT_OP1 + CFF_LAST_DICT_OP2) - -static struct { - const char *opname; - int argtype; -} dict_operator[CFF_LAST_DICT_OP] = { - { - "version", CFF_TYPE_SID}, { - "Notice", CFF_TYPE_SID}, { - "FullName", CFF_TYPE_SID}, { - "FamilyName", CFF_TYPE_SID}, { - "Weight", CFF_TYPE_SID}, { - "FontBBox", CFF_TYPE_ARRAY}, { - "BlueValues", CFF_TYPE_DELTA}, { - "OtherBlues", CFF_TYPE_DELTA}, { - "FamilyBlues", CFF_TYPE_DELTA}, { - "FamilyOtherBlues", CFF_TYPE_DELTA}, { - "StdHW", CFF_TYPE_NUMBER}, { - "StdVW", CFF_TYPE_NUMBER}, { - NULL, -1}, /* first byte of two-byte operator */ - /* Top */ - { - "UniqueID", CFF_TYPE_NUMBER}, { - "XUID", CFF_TYPE_ARRAY}, { - "charset", CFF_TYPE_OFFSET}, { - "Encoding", CFF_TYPE_OFFSET}, { - "CharStrings", CFF_TYPE_OFFSET}, { - "Private", CFF_TYPE_SZOFF}, /* two numbers (size and offset) */ - /* Private */ - { - "Subrs", CFF_TYPE_OFFSET}, { - "defaultWidthX", CFF_TYPE_NUMBER}, { - "nominalWidthX", CFF_TYPE_NUMBER}, - /* Operator 2 */ - { - "Copyright", CFF_TYPE_SID}, { - "IsFixedPitch", CFF_TYPE_BOOLEAN}, { - "ItalicAngle", CFF_TYPE_NUMBER}, { - "UnderlinePosition", CFF_TYPE_NUMBER}, { - "UnderlineThickness", CFF_TYPE_NUMBER}, { - "PaintType", CFF_TYPE_NUMBER}, { - "CharstringType", CFF_TYPE_NUMBER}, { - "FontMatrix", CFF_TYPE_ARRAY}, { - "StrokeWidth", CFF_TYPE_NUMBER}, { - "BlueScale", CFF_TYPE_NUMBER}, { - "BlueShift", CFF_TYPE_NUMBER}, { - "BlueFuzz", CFF_TYPE_NUMBER}, { - "StemSnapH", CFF_TYPE_DELTA}, { - "StemSnapV", CFF_TYPE_DELTA}, { - "ForceBold", CFF_TYPE_BOOLEAN}, { - NULL, -1}, { - NULL, -1}, { - "LanguageGroup", CFF_TYPE_NUMBER}, { - "ExpansionFactor", CFF_TYPE_NUMBER}, { - "InitialRandomSeed", CFF_TYPE_NUMBER}, { - "SyntheticBase", CFF_TYPE_NUMBER}, { - "PostScript", CFF_TYPE_SID}, { - "BaseFontName", CFF_TYPE_SID}, { - "BaseFontBlend", CFF_TYPE_DELTA}, /* MMaster ? */ - { - NULL, -1}, { - NULL, -1}, { - NULL, -1}, { - NULL, -1}, { - NULL, -1}, { - NULL, -1}, - /* CID-Keyed font */ - { - "ROS", CFF_TYPE_ROS}, /* SID SID number */ - { - "CIDFontVersion", CFF_TYPE_NUMBER}, { - "CIDFontRevision", CFF_TYPE_NUMBER}, { - "CIDFontType", CFF_TYPE_NUMBER}, { - "CIDCount", CFF_TYPE_NUMBER}, { - "UIDBase", CFF_TYPE_NUMBER}, { - "FDArray", CFF_TYPE_OFFSET}, { - "FDSelect", CFF_TYPE_OFFSET}, { -"FontName", CFF_TYPE_SID},}; - -/* Parse DICT data */ -static double get_integer(card8 ** data, card8 * endptr, int *status) -{ - long result = 0; - card8 b0, b1, b2; - - b0 = *(*data)++; - if (b0 == 28 && *data < endptr - 2) { /* shortint */ - b1 = *(*data)++; - b2 = *(*data)++; - result = b1 * 256 + b2; - if (result > 0x7fffL) - result -= 0x10000L; - } else if (b0 == 29 && *data < endptr - 4) { /* longint */ - int i; - result = *(*data)++; - if (result > 0x7f) - result -= 0x100; - for (i = 0; i < 3; i++) { - result = result * 256 + (**data); - *data += 1; - } - } else if (b0 >= 32 && b0 <= 246) { /* int (1) */ - result = b0 - 139; - } else if (b0 >= 247 && b0 <= 250) { /* int (2) */ - b1 = *(*data)++; - result = (b0 - 247) * 256 + b1 + 108; - } else if (b0 >= 251 && b0 <= 254) { - b1 = *(*data)++; - result = -(b0 - 251) * 256 - b1 - 108; - } else { - *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; - } - - return (double) result; -} - -/* Simply uses strtod */ -static double get_real(card8 ** data, card8 * endptr, int *status) -{ - double result = 0.0; - int nibble = 0, pos = 0; - int len = 0, fail = 0; - - if (**data != 30 || *data >= endptr - 1) { - *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; - return 0.0; - } - - *data += 1; /* skip first byte (30) */ - - pos = 0; - while ((!fail) && len < WORK_BUFFER_SIZE - 2 && *data < endptr) { - /* get nibble */ - if (pos % 2) { - nibble = **data & 0x0f; - *data += 1; - } else { - nibble = (**data >> 4) & 0x0f; - } - if (nibble >= 0x00 && nibble <= 0x09) { - work_buffer[len++] = nibble + '0'; - } else if (nibble == 0x0a) { /* . */ - work_buffer[len++] = '.'; - } else if (nibble == 0x0b || nibble == 0x0c) { /* E, E- */ - work_buffer[len++] = 'e'; - if (nibble == 0x0c) - work_buffer[len++] = '-'; - } else if (nibble == 0x0e) { /* `-' */ - work_buffer[len++] = '-'; - } else if (nibble == 0x0d) { /* skip */ - /* do nothing */ - } else if (nibble == 0x0f) { /* end */ - work_buffer[len++] = '\0'; - if (((pos % 2) == 0) && (**data != 0xff)) { - fail = 1; - } - break; - } else { /* invalid */ - fail = 1; - } - pos++; - } - - /* returned values */ - if (fail || nibble != 0x0f) { - *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; - } else { - char *s; - result = strtod(work_buffer, &s); - if (*s != 0 || errno == ERANGE) { - *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; - } - } - - return result; -} - -/* operators */ -static void add_dict(cff_dict * dict, - card8 ** data, card8 * endptr, int *status) -{ - int id, argtype; - - id = **data; - if (id == 0x0c) { - *data += 1; - if (*data >= endptr || - (id = **data + CFF_LAST_DICT_OP1) >= CFF_LAST_DICT_OP) { - *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; - return; - } - } else if (id >= CFF_LAST_DICT_OP1) { - *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; - return; - } - - argtype = dict_operator[id].argtype; - if (dict_operator[id].opname == NULL || argtype < 0) { - *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; - return; - } - - if (dict->count >= dict->max) { - dict->max += DICT_ENTRY_MAX; - /* not zeroed! */ - dict->entries = - xrealloc(dict->entries, dict->max * sizeof(cff_dict_entry)); - } - - (dict->entries)[dict->count].id = id; - (dict->entries)[dict->count].key = dict_operator[id].opname; - if (argtype == CFF_TYPE_NUMBER || - argtype == CFF_TYPE_BOOLEAN || - argtype == CFF_TYPE_SID || argtype == CFF_TYPE_OFFSET) { - /* check for underflow here, as exactly one operand is expected */ - if (stack_top < 1) { - *status = CFF_CFF_ERROR_STACK_UNDERFLOW; - return; - } - stack_top--; - (dict->entries)[dict->count].count = 1; - (dict->entries)[dict->count].values = xcalloc(1, sizeof(double)); - (dict->entries)[dict->count].values[0] = arg_stack[stack_top]; - dict->count += 1; - } else { - /* just ignore operator if there were no operands provided; - don't treat this as underflow (e.g. StemSnapV in TemporaLGCUni-Italic.otf) */ - if (stack_top > 0) { - (dict->entries)[dict->count].count = stack_top; - (dict->entries)[dict->count].values = - xcalloc(stack_top, sizeof(double)); - while (stack_top > 0) { - stack_top--; - (dict->entries)[dict->count].values[stack_top] = - arg_stack[stack_top]; - } - dict->count += 1; - } - } - - *data += 1; - - return; -} - -/* - * All operands are treated as number or array of numbers. - * Private: two numbers, size and offset - * ROS : three numbers, SID, SID, and a number - */ -cff_dict *cff_dict_unpack(card8 * data, card8 * endptr) -{ - cff_dict *dict; - int status = CFF_PARSE_OK; - - stack_top = 0; - - dict = cff_new_dict(); - while (data < endptr && status == CFF_PARSE_OK) { - if (*data < 22) { /* operator */ - add_dict(dict, &data, endptr, &status); - } else if (*data == 30) { /* real - First byte of a sequence (variable) */ - if (stack_top < CFF_DICT_STACK_LIMIT) { - arg_stack[stack_top] = get_real(&data, endptr, &status); - stack_top++; - } else { - status = CFF_CFF_ERROR_STACK_OVERFLOW; - } - } else if (*data == 255 || (*data >= 22 && *data <= 27)) { /* reserved */ - data++; - } else { /* everything else are integer */ - if (stack_top < CFF_DICT_STACK_LIMIT) { - arg_stack[stack_top] = get_integer(&data, endptr, &status); - stack_top++; - } else { - status = CFF_CFF_ERROR_STACK_OVERFLOW; - } - } - } - - if (status != CFF_PARSE_OK) { - pdftex_fail("Parsing CFF DICT failed. (error=%d)", status); - } else if (stack_top != 0) { - WARN("Garbage in CFF DICT data."); - stack_top = 0; - } - - return dict; -} - - -int cff_dict_known(cff_dict * dict, const char *key) -{ - int i; - - for (i = 0; i < dict->count; i++) { - if (key && strcmp(key, (dict->entries)[i].key) == 0 - && (dict->entries)[i].count > 0) - return 1; - } - - return 0; -} - -double cff_dict_get(cff_dict * dict, const char *key, int idx) -{ - double value = 0.0; - int i; - - assert(key && dict); - - for (i = 0; i < dict->count; i++) { - if (strcmp(key, (dict->entries)[i].key) == 0) { - if ((dict->entries)[i].count > idx) - value = (dict->entries)[i].values[idx]; - else - pdftex_fail("Invalid index number."); - break; - } - } - - if (i == dict->count) - pdftex_fail("DICT entry \"%s\" not found.", key); - - return value; -} - -card8 cff_fdselect_lookup(cff_font * cff, card16 gid) -{ - card8 fd = 0xff; - cff_fdselect *fdsel; - - if (cff->fdselect == NULL) - CFF_ERROR("in cff_fdselect_lookup(): FDSelect not available"); - - fdsel = cff->fdselect; - - if (gid >= cff->num_glyphs) - CFF_ERROR("in cff_fdselect_lookup(): Invalid glyph index"); - - switch (fdsel->format) { - case 0: - fd = fdsel->data.fds[gid]; - break; - case 3: - { - if (gid == 0) { - fd = (fdsel->data).ranges[0].fd; - } else { - card16 i; - for (i = 1; i < (fdsel->num_entries); i++) { - if (gid < (fdsel->data).ranges[i].first) - break; - } - fd = (fdsel->data).ranges[i - 1].fd; - } - } - break; - default: - CFF_ERROR("in cff_fdselect_lookup(): Invalid FDSelect format"); - break; - } - - if (fd >= cff->num_fds) - CFF_ERROR("in cff_fdselect_lookup(): Invalid Font DICT index"); - - return fd; -} - -long cff_read_subrs(cff_font * cff) -{ - long len = 0; - long offset; - int i; - - - if ((cff->flag & FONTTYPE_CIDFONT) && cff->fdselect == NULL) { - cff_read_fdselect(cff); - } - - if ((cff->flag & FONTTYPE_CIDFONT) && cff->fdarray == NULL) { - cff_read_fdarray(cff); - } - - if (cff->private == NULL) - cff_read_private(cff); - - if (cff->gsubr == NULL) { - cff->offset = cff->gsubr_offset; - cff->gsubr = cff_get_index(cff); - } - - cff->subrs = xcalloc(cff->num_fds, sizeof(cff_index *)); - if (cff->flag & FONTTYPE_CIDFONT) { - for (i = 0; i < cff->num_fds; i++) { - if (cff->private[i] == NULL || - !cff_dict_known(cff->private[i], "Subrs")) { - (cff->subrs)[i] = NULL; - } else { - offset = (long) cff_dict_get(cff->fdarray[i], "Private", 1); - offset += (long) cff_dict_get(cff->private[i], "Subrs", 0); - cff->offset = offset; - (cff->subrs)[i] = cff_get_index(cff); - len += cff_index_size((cff->subrs)[i]); - } - } - } else { - if (cff->private[0] == NULL || - !cff_dict_known(cff->private[0], "Subrs")) { - (cff->subrs)[0] = NULL; - } else { - offset = (long) cff_dict_get(cff->topdict, "Private", 1); - offset += (long) cff_dict_get(cff->private[0], "Subrs", 0); - cff->offset = offset; - (cff->subrs)[0] = cff_get_index(cff); - len += cff_index_size((cff->subrs)[0]); - } - } - - return len; -} - - -long cff_read_fdarray(cff_font * cff) -{ - long len = 0; - cff_index *idx; - long offset, size; - card16 i; - - if (cff->topdict == NULL) - CFF_ERROR("in cff_read_fdarray(): Top DICT not found"); - - if (!(cff->flag & FONTTYPE_CIDFONT)) - return 0; - - /* must exist */ - offset = (long) cff_dict_get(cff->topdict, "FDArray", 0); - cff->offset = offset; - idx = cff_get_index(cff); - cff->num_fds = (card8) idx->count; - cff->fdarray = xcalloc(idx->count, sizeof(cff_dict *)); - for (i = 0; i < idx->count; i++) { - card8 *data = idx->data + (idx->offset)[i] - 1; - size = (idx->offset)[i + 1] - (idx->offset)[i]; - if (size > 0) { - (cff->fdarray)[i] = cff_dict_unpack(data, data + size); - } else { - (cff->fdarray)[i] = NULL; - } - } - len = cff_index_size(idx); - cff_release_index(idx); - - return len; -} - - -long cff_read_private(cff_font * cff) -{ - long len = 0; - card8 *data; - long offset, size; - - if (cff->flag & FONTTYPE_CIDFONT) { - int i; - - if (cff->fdarray == NULL) - cff_read_fdarray(cff); - - cff->private = xcalloc(cff->num_fds, sizeof(cff_dict *)); - for (i = 0; i < cff->num_fds; i++) { - if (cff->fdarray[i] != NULL && - cff_dict_known(cff->fdarray[i], "Private") && - (size = (long) cff_dict_get(cff->fdarray[i], "Private", 0)) - > 0) { - offset = (long) cff_dict_get(cff->fdarray[i], "Private", 1); - cff->offset = offset; - data = xcalloc(size, sizeof(card8)); - memcpy(data, &cff->stream[cff->offset], size); - cff->offset = size; - (cff->private)[i] = cff_dict_unpack(data, data + size); - xfree(data); - len += size; - } else { - (cff->private)[i] = NULL; - } - } - } else { - cff->num_fds = 1; - cff->private = xcalloc(1, sizeof(cff_dict *)); - if (cff_dict_known(cff->topdict, "Private") && - (size = (long) cff_dict_get(cff->topdict, "Private", 0)) > 0) { - offset = (long) cff_dict_get(cff->topdict, "Private", 1); - cff->offset = offset; - data = xcalloc(size, sizeof(card8)); - memcpy(data, &cff->stream[cff->offset], size); - cff->offset = size; - cff->private[0] = cff_dict_unpack(data, data + size); - xfree(data); - len += size; - } else { - (cff->private)[0] = NULL; - len = 0; - } - } - - return len; -} - - -cff_font *read_cff(unsigned char *buf, long buflength, int n) -{ - cff_font *cff; - cff_index *idx; - long offset; - - - cff = xcalloc(1, sizeof(cff_font)); - - cff->stream = buf; - cff->stream_size = buflength; - cff->index = n; - - cff->header_major = get_card8(cff); - cff->header_minor = get_card8(cff); - cff->header_hdr_size = get_card8(cff); - cff->header_offsize = get_card8(cff); - if (cff->header_offsize < 1 || cff->header_offsize > 4) { - WARN("invalid offsize data"); - cff_close(cff); - return NULL; - } - if (cff->header_major > 1) { - pdftex_warn("CFF major version %u not supported.", cff->header_major); - cff_close(cff); - return NULL; - } - cff->offset = cff->header_hdr_size; - - /* Name INDEX */ - idx = cff_get_index(cff); - if (n > idx->count - 1) { - pdftex_warn("Invalid CFF fontset index number."); - cff_close(cff); - return NULL; - } - - cff->name = idx; - - cff->fontname = cff_get_name(cff); - - /* Top DICT INDEX */ - idx = cff_get_index(cff); - if (n > idx->count - 1) { - WARN("CFF Top DICT not exist..."); - cff_close(cff); - return NULL; - } - cff->topdict = cff_dict_unpack(idx->data + idx->offset[n] - 1, - idx->data + idx->offset[n + 1] - 1); - if (!cff->topdict) { - WARN("Parsing CFF Top DICT data failed..."); - cff_close(cff); - return NULL; - } - cff_release_index(idx); - - if (cff_dict_known(cff->topdict, "CharstringType") && - cff_dict_get(cff->topdict, "CharstringType", 0) != 2) { - WARN("Only Type 2 Charstrings supported..."); - cff_close(cff); - return NULL; - } - - if (cff_dict_known(cff->topdict, "SyntheticBase")) { - WARN("CFF Synthetic font not supported."); - cff_close(cff); - return NULL; - } - - /* String INDEX */ - cff->string = cff_get_index(cff); - - /* offset to GSubr */ - cff->gsubr_offset = cff->offset; - - /* Number of glyphs */ - offset = (long) cff_dict_get(cff->topdict, "CharStrings", 0); - cff->offset = offset; - cff->num_glyphs = get_card16(cff); - - /* Check for font type */ - if (cff_dict_known(cff->topdict, "ROS")) { - cff->flag |= FONTTYPE_CIDFONT; - } else { - cff->flag |= FONTTYPE_FONT; - } - - /* Check for encoding */ - if (cff_dict_known(cff->topdict, "Encoding")) { - offset = (long) cff_dict_get(cff->topdict, "Encoding", 0); - if (offset == 0) { /* predefined */ - cff->flag |= ENCODING_STANDARD; - } else if (offset == 1) { - cff->flag |= ENCODING_EXPERT; - } - } else { - cff->flag |= ENCODING_STANDARD; - } - - cff->offset = cff->gsubr_offset; /* seek back to GSubr */ - - return cff; -} - -/* write a cff for opentype */ - - - -/* Pack DICT data */ -static long pack_integer(card8 * dest, long destlen, long value) -{ - long len = 0; - - if (value >= -107 && value <= 107) { - if (destlen < 1) - CFF_ERROR("Buffer overflow."); - dest[0] = (value + 139) & 0xff; - len = 1; - } else if (value >= 108 && value <= 1131) { - if (destlen < 2) - CFF_ERROR("Buffer overflow."); - value = 0xf700u + value - 108; - dest[0] = (value >> 8) & 0xff; - dest[1] = value & 0xff; - len = 2; - } else if (value >= -1131 && value <= -108) { - if (destlen < 2) - CFF_ERROR("Buffer overflow."); - value = 0xfb00u - value - 108; - dest[0] = (value >> 8) & 0xff; - dest[1] = value & 0xff; - len = 2; - } else if (value >= -32768 && value <= 32767) { /* shortint */ - if (destlen < 3) - CFF_ERROR("Buffer overflow."); - dest[0] = 28; - dest[1] = (value >> 8) & 0xff; - dest[2] = value & 0xff; - len = 3; - } else { /* longint */ - if (destlen < 5) - CFF_ERROR("Buffer overflow."); - dest[0] = 29; - dest[1] = (value >> 24) & 0xff; - dest[2] = (value >> 16) & 0xff; - dest[3] = (value >> 8) & 0xff; - dest[4] = value & 0xff; - len = 5; - } - return len; -} - -static long pack_real(card8 * dest, long destlen, double value) -{ - long e; - int i = 0, pos = 2; -#define CFF_REAL_MAX_LEN 17 - - if (destlen < 2) - CFF_ERROR("Buffer overflow."); - - dest[0] = 30; - - if (value == 0.0) { - dest[1] = 0x0f; - return 2; - } - - if (value < 0.0) { - dest[1] = 0xe0; - value *= -1.0; - pos++; - } - - e = 0; - if (value >= 10.0) { - while (value >= 10.0) { - value /= 10.0; - e++; - } - } else if (value < 1.0) { - while (value < 1.0) { - value *= 10.0; - e--; - } - } - - sprintf(work_buffer, "%1.14g", value); - for (i = 0; i < CFF_REAL_MAX_LEN; i++) { - unsigned char ch = 0; - if (work_buffer[i] == '\0') { - break; - } else if (work_buffer[i] == '.') { - ch = 0x0a; - } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { - ch = work_buffer[i] - '0'; - } else { - CFF_ERROR("Invalid character."); - } - - if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); - - if (pos % 2) { - dest[pos / 2] += ch; - } else { - dest[pos / 2] = (ch << 4); - } - pos++; - } - - if (e > 0) { - if (pos % 2) { - dest[pos / 2] += 0x0b; - } else { - if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); - dest[pos / 2] = 0xb0; - } - pos++; - } else if (e < 0) { - if (pos % 2) { - dest[pos / 2] += 0x0c; - } else { - if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); - dest[pos / 2] = 0xc0; - } - e *= -1; - pos++; - } - - if (e != 0) { - sprintf(work_buffer, "%ld", e); - for (i = 0; i < CFF_REAL_MAX_LEN; i++) { - unsigned char ch = 0; - if (work_buffer[i] == '\0') { - break; - } else if (work_buffer[i] == '.') { - ch = 0x0a; - } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { - ch = work_buffer[i] - '0'; - } else { - CFF_ERROR("Invalid character."); - } - - if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); - - if (pos % 2) { - dest[pos / 2] += ch; - } else { - dest[pos / 2] = (ch << 4); - } - pos++; - } - } - - if (pos % 2) { - dest[pos / 2] += 0x0f; - pos++; - } else { - if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); - dest[pos / 2] = 0xff; - pos += 2; - } - - return pos / 2; -} - -static long cff_dict_put_number(double value, - card8 * dest, long destlen, int type) -{ - long len = 0; - double nearint; - - nearint = floor(value + 0.5); - /* set offset to longint */ - if (type == CFF_TYPE_OFFSET) { - long lvalue; - - lvalue = (long) value; - if (destlen < 5) - CFF_ERROR("Buffer overflow."); - dest[0] = 29; - dest[1] = (lvalue >> 24) & 0xff; - dest[2] = (lvalue >> 16) & 0xff; - dest[3] = (lvalue >> 8) & 0xff; - dest[4] = lvalue & 0xff; - len = 5; - } else if (value > CFF_INT_MAX || value < CFF_INT_MIN || (fabs(value - nearint) > 1.0e-5)) { /* real */ - len = pack_real(dest, destlen, value); - } else { /* integer */ - len = pack_integer(dest, destlen, (long) nearint); - } - - return len; -} - -static long put_dict_entry(cff_dict_entry * de, card8 * dest, long destlen) -{ - long len = 0; - int i, type, id; - - if (de->count > 0) { - id = de->id; - if (dict_operator[id].argtype == CFF_TYPE_OFFSET || - dict_operator[id].argtype == CFF_TYPE_SZOFF) { - type = CFF_TYPE_OFFSET; - } else { - type = CFF_TYPE_NUMBER; - } - for (i = 0; i < de->count; i++) { - len += cff_dict_put_number(de->values[i], - dest + len, destlen - len, type); - } - if (id >= 0 && id < CFF_LAST_DICT_OP1) { - if (len + 1 > destlen) - CFF_ERROR("Buffer overflow."); - dest[len++] = id; - } else if (id >= 0 && id < CFF_LAST_DICT_OP) { - if (len + 2 > destlen) - CFF_ERROR("in cff_dict_pack(): Buffer overflow"); - dest[len++] = 12; - dest[len++] = id - CFF_LAST_DICT_OP1; - } else { - CFF_ERROR("Invalid CFF DICT operator ID."); - } - } - - return len; -} - -long cff_dict_pack(cff_dict * dict, card8 * dest, long destlen) -{ - long len = 0; - int i; - - for (i = 0; i < dict->count; i++) { - if (!strcmp(dict->entries[i].key, "ROS")) { - len += put_dict_entry(&dict->entries[i], dest, destlen); - break; - } - } - for (i = 0; i < dict->count; i++) { - if (strcmp(dict->entries[i].key, "ROS")) { - len += put_dict_entry(&dict->entries[i], dest + len, destlen - len); - } - } - - return len; -} - - -void cff_dict_add(cff_dict * dict, const char *key, int count) -{ - int id, i; - - for (id = 0; id < CFF_LAST_DICT_OP; id++) { - if (key && dict_operator[id].opname && - strcmp(dict_operator[id].opname, key) == 0) - break; - } - - if (id == CFF_LAST_DICT_OP) - CFF_ERROR("Unknown CFF DICT operator."); - - for (i = 0; i < dict->count; i++) { - if ((dict->entries)[i].id == id) { - if ((dict->entries)[i].count != count) - CFF_ERROR("Inconsistent DICT argument number."); - return; - } - } - - if (dict->count + 1 >= dict->max) { - dict->max += 8; - dict->entries = - xrealloc(dict->entries, (dict->max) * sizeof(cff_dict_entry)); - } - - (dict->entries)[dict->count].id = id; - (dict->entries)[dict->count].key = dict_operator[id].opname; - (dict->entries)[dict->count].count = count; - if (count > 0) { - (dict->entries)[dict->count].values = xcalloc(count, sizeof(double)); - memset((dict->entries)[dict->count].values, 0, sizeof(double) * count); - } else { - (dict->entries)[dict->count].values = NULL; - } - dict->count += 1; - - return; -} - - -void cff_dict_remove(cff_dict * dict, const char *key) -{ - int i; - for (i = 0; i < dict->count; i++) { - if (key && strcmp(key, (dict->entries)[i].key) == 0) { - (dict->entries)[i].count = 0; - if ((dict->entries)[i].values) - xfree((dict->entries)[i].values); - (dict->entries)[i].values = NULL; - } - } -} - -void cff_dict_set(cff_dict * dict, const char *key, int idx, double value) -{ - int i; - - assert(dict && key); - - for (i = 0; i < dict->count; i++) { - if (strcmp(key, (dict->entries)[i].key) == 0) { - if ((dict->entries)[i].count > idx) - (dict->entries)[i].values[idx] = value; - else - CFF_ERROR("Invalid index number."); - break; - } - } - - if (i == dict->count) - pdftex_fail("DICT entry \"%s\" not found.", key); -} - - -/* Strings */ -char *cff_get_string(cff_font * cff, s_SID id) -{ - char *result = NULL; - long len; - - if (id < CFF_STDSTR_MAX) { - len = strlen(cff_stdstr[id]); - result = xcalloc(len + 1, sizeof(char)); - memcpy(result, cff_stdstr[id], len); - result[len] = '\0'; - } else if (cff && cff->string) { - cff_index *strings = cff->string; - id -= CFF_STDSTR_MAX; - if (id < strings->count) { - len = (strings->offset)[id + 1] - (strings->offset)[id]; - result = xcalloc(len + 1, sizeof(char)); - memmove(result, strings->data + (strings->offset)[id] - 1, len); - result[len] = '\0'; - } - } - - return result; -} - -long cff_get_sid(cff_font * cff, const char *str) -{ - card16 i; - - if (!cff || !str) - return -1; - - /* I search String INDEX first. */ - if (cff && cff->string) { - cff_index *idx = cff->string; - for (i = 0; i < idx->count; i++) { - if (strlen(str) == (idx->offset)[i + 1] - (idx->offset)[i] && - !memcmp(str, (idx->data) + (idx->offset)[i] - 1, strlen(str))) - return (i + CFF_STDSTR_MAX); - } - } - - for (i = 0; i < CFF_STDSTR_MAX; i++) { - if (!strcmp(str, cff_stdstr[i])) - return i; - } - - return -1; -} - - -void cff_update_string(cff_font * cff) -{ - if (cff == NULL) - CFF_ERROR("CFF font not opened."); - - if (cff->string) - cff_release_index(cff->string); - cff->string = cff->_string; - cff->_string = NULL; -} - - -s_SID cff_add_string(cff_font * cff, const char *str) -{ - card16 idx; - cff_index *strings; - l_offset offset, size; - - if (cff == NULL) - CFF_ERROR("CFF font not opened."); - - if (cff->_string == NULL) - cff->_string = cff_new_index(0); - strings = cff->_string; - - for (idx = 0; idx < strings->count; idx++) { - size = strings->offset[idx + 1] - strings->offset[idx]; - offset = strings->offset[idx]; - if (size == strlen(str) && - !memcmp(strings->data + offset - 1, str, strlen(str))) - return (idx + CFF_STDSTR_MAX); - } - - for (idx = 0; idx < CFF_STDSTR_MAX; idx++) { - if (cff_stdstr[idx] && !strcmp(cff_stdstr[idx], str)) - return idx; - } - offset = (strings->count > 0) ? strings->offset[strings->count] : 1; - strings->offset = - xrealloc(strings->offset, (strings->count + 2) * sizeof(l_offset)); - if (strings->count == 0) - strings->offset[0] = 1; - idx = strings->count; - strings->count += 1; - strings->offset[strings->count] = offset + strlen(str); - strings->data = - xrealloc(strings->data, (offset + strlen(str) - 1) * sizeof(card8)); - memcpy(strings->data + offset - 1, str, strlen(str)); - - return (idx + CFF_STDSTR_MAX); -} - - -void cff_dict_update(cff_dict * dict, cff_font * cff) -{ - int i; - - for (i = 0; i < dict->count; i++) { - if ((dict->entries)[i].count > 0) { - char *str; - int id; - - id = (dict->entries)[i].id; - - if (dict_operator[id].argtype == CFF_TYPE_SID) { - str = cff_get_string(cff, (dict->entries)[i].values[0]); - (dict->entries)[i].values[0] = cff_add_string(cff, str); - xfree(str); - } else if (dict_operator[id].argtype == CFF_TYPE_ROS) { - str = cff_get_string(cff, (dict->entries)[i].values[0]); - (dict->entries)[i].values[0] = cff_add_string(cff, str); - xfree(str); - str = cff_get_string(cff, (dict->entries)[i].values[1]); - (dict->entries)[i].values[1] = cff_add_string(cff, str); - xfree(str); - } - - } - } -} - -/* charsets */ - -long cff_read_charsets(cff_font * cff) -{ - cff_charsets *charset; - long offset, length; - card16 count, i; - - if (cff->topdict == NULL) - CFF_ERROR("Top DICT not available"); - - if (!cff_dict_known(cff->topdict, "charset")) { - cff->flag |= CHARSETS_ISOADOBE; - cff->charsets = NULL; - return 0; - } - - offset = (long) cff_dict_get(cff->topdict, "charset", 0); - - if (offset == 0) { /* predefined */ - cff->flag |= CHARSETS_ISOADOBE; - cff->charsets = NULL; - return 0; - } else if (offset == 1) { - cff->flag |= CHARSETS_EXPERT; - cff->charsets = NULL; - return 0; - } else if (offset == 2) { - cff->flag |= CHARSETS_EXPSUB; - cff->charsets = NULL; - return 0; - } - - cff->offset = offset; - cff->charsets = charset = xcalloc(1, sizeof(cff_charsets)); - charset->format = get_card8(cff); - charset->num_entries = 0; - - count = cff->num_glyphs - 1; - length = 1; - - /* Not sure. Not well documented. */ - switch (charset->format) { - case 0: - charset->num_entries = cff->num_glyphs - 1; /* no .notdef */ - charset->data.glyphs = xcalloc(charset->num_entries, sizeof(s_SID)); - length += (charset->num_entries) * 2; - for (i = 0; i < (charset->num_entries); i++) { - charset->data.glyphs[i] = get_card16(cff); - } - count = 0; - break; - case 1: - { - cff_range1 *ranges = NULL; - while (count > 0 && charset->num_entries < cff->num_glyphs) { - ranges = - xrealloc(ranges, - (charset->num_entries + 1) * sizeof(cff_range1)); - ranges[charset->num_entries].first = get_card16(cff); - ranges[charset->num_entries].n_left = get_card8(cff); - count -= ranges[charset->num_entries].n_left + 1; /* no-overrap */ - charset->num_entries += 1; - charset->data.range1 = ranges; - } - length += (charset->num_entries) * 3; - } - break; - case 2: - { - cff_range2 *ranges = NULL; - while (count > 0 && charset->num_entries < cff->num_glyphs) { - ranges = - xrealloc(ranges, - (charset->num_entries + 1) * sizeof(cff_range2)); - ranges[charset->num_entries].first = get_card16(cff); - ranges[charset->num_entries].n_left = get_card16(cff); - count -= ranges[charset->num_entries].n_left + 1; /* non-overrapping */ - charset->num_entries += 1; - } - charset->data.range2 = ranges; - length += (charset->num_entries) * 4; - } - break; - default: - xfree(charset); - CFF_ERROR("Unknown Charset format"); - break; - } - - if (count > 0) - CFF_ERROR("Charset data possibly broken"); - - return length; -} - -long cff_pack_charsets(cff_font * cff, card8 * dest, long destlen) -{ - long len = 0; - card16 i; - cff_charsets *charset; - - if (cff->flag & HAVE_STANDARD_CHARSETS || cff->charsets == NULL) - return 0; - - if (destlen < 1) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); - - charset = cff->charsets; - - dest[len++] = charset->format; - switch (charset->format) { - case 0: - if (destlen < len + (charset->num_entries) * 2) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); - for (i = 0; i < (charset->num_entries); i++) { - s_SID sid = (charset->data).glyphs[i]; /* or CID */ - dest[len++] = (sid >> 8) & 0xff; - dest[len++] = sid & 0xff; - } - break; - case 1: - { - if (destlen < len + (charset->num_entries) * 3) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); - for (i = 0; i < (charset->num_entries); i++) { - dest[len++] = ((charset->data).range1[i].first >> 8) & 0xff; - dest[len++] = (charset->data).range1[i].first & 0xff; - dest[len++] = (charset->data).range1[i].n_left; - } - } - break; - case 2: - { - if (destlen < len + (charset->num_entries) * 4) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); - for (i = 0; i < (charset->num_entries); i++) { - dest[len++] = ((charset->data).range2[i].first >> 8) & 0xff; - dest[len++] = (charset->data).range2[i].first & 0xff; - dest[len++] = ((charset->data).range2[i].n_left >> 8) & 0xff; - dest[len++] = (charset->data).range2[i].n_left & 0xff; - } - } - break; - default: - CFF_ERROR("Unknown Charset format"); - break; - } - - return len; -} - - - -/* - * Type 2 Charstring support: - * Decode and encode Type 2 charstring - * - * All local/global subroutine calls in a given charstring is replace by the - * content of subroutine charstrings. We do this because some PostScript RIP - * may have problems with sparse subroutine array. Workaround for this is to - * re-order subroutine array so that no gap appears in the subroutine array, - * or put dummy charstrings that contains only `return' in the gap. However, - * re-ordering of subroutine is rather difficult for Type 2 charstrings due - * to the bias which depends on the total number of subroutines. Replacing - * callgsubr/callsubr calls with the content of the corresponding subroutine - * charstring may be more efficient than putting dummy subroutines in the - * case of subsetted font. Adobe distiller seems doing same thing. - * - * And also note that subroutine numbers within subroutines can depend on the - * content of operand stack as follows: - * - * ... l m callsubr << subr #(m+bias): n add callsubr >> ... - * - * I've not implemented the `random' operator which generates a pseudo-random - * number in the range (0, 1] and push them into argument stack. - * How pseudo-random sequences are generated is not documented in the Type 2 - * charstring spec.. - */ - - -#define CS_TYPE2_DEBUG_STR "Type2 Charstring Parser" -#define CS_TYPE2_DEBUG 5 - -/* decoder/encoder status codes */ -#define CS_BUFFER_CFF_ERROR -3 -#define CS_STACK_CFF_ERROR -2 -#define CS_PARSE_CFF_ERROR -1 -#define CS_PARSE_OK 0 -#define CS_PARSE_END 1 -#define CS_SUBR_RETURN 2 -#define CS_CHAR_END 3 - -static int status = CS_PARSE_CFF_ERROR; - -#define DST_NEED(a,b) {if ((a) < (b)) { status = CS_BUFFER_CFF_ERROR ; return ; }} -#define SRC_NEED(a,b) {if ((a) < (b)) { status = CS_PARSE_CFF_ERROR ; return ; }} -#define NEED(a,b) {if ((a) < (b)) { status = CS_STACK_CFF_ERROR ; return ; }} - -/* hintmask and cntrmask need number of stem zones */ -static int num_stems = 0; -static int phase = 0; - -/* subroutine nesting */ -static int cs2_nest = 0; - -/* advance width */ -static int have_width = 0; -static double width = 0.0; - -/* - * Standard Encoding Accented Characters: - * Optional four arguments for endchar. See, CFF spec., p.35. - * This is obsolete feature and is no longer supported. - */ -#if 0 -/* adx ady bchar achar endchar */ -static double seac[4] = { 0.0, 0.0, 0.0, 0.0 }; -#endif - -/* Operand stack and Transient array */ -static int cs2_stack_top = 0; -static double cs2_arg_stack[CS_ARG_STACK_MAX]; -static double trn_array[CS_TRANS_ARRAY_MAX]; - -/* - * Type 2 CharString encoding - */ - -/* - * 1-byte CharString operaotrs: - * cs_escape is first byte of two-byte operator - */ - -/* RESERVED 0 */ -#define cs_hstem 1 -/* RESERVED 2 */ -#define cs_vstem 3 -#define cs_vmoveto 4 -#define cs_rlineto 5 -#define cs_hlineto 6 -#define cs_vlineto 7 -#define cs_rrcurveto 8 -/* cs_closepath 9 : TYPE1 */ -#define cs_callsubr 10 -#define cs_return 11 -#define cs_escape 12 -/* cs_hsbw 13 : TYPE1 */ -#define cs_endchar 14 -/* RESERVED 15 */ -/* RESERVED 16 */ -/* RESERVED 17 */ -#define cs_hstemhm 18 -#define cs_hintmask 19 -#define cs_cntrmask 20 -#define cs_rmoveto 21 -#define cs_hmoveto 22 -#define cs_vstemhm 23 -#define cs_rcurveline 24 -#define cs_rlinecurve 25 -#define cs_vvcurveto 26 -#define cs_hhcurveto 27 -/* SHORTINT 28 : first byte of shortint*/ -#define cs_callgsubr 29 -#define cs_vhcurveto 30 -#define cs_hvcurveto 31 - -/* - * 2-byte CharString operaotrs: - * "dotsection" is obsoleted in Type 2 charstring. - */ - -#define cs_dotsection 0 -/* cs_vstem3 1 : TYPE1 */ -/* cs_hstem3 2 : TYPE1 */ -#define cs_and 3 -#define cs_or 4 -#define cs_not 5 -/* cs_seac 6 : TYPE1 */ -/* cs_sbw 7 : TYPE1 */ -/* RESERVED 8 */ -#define cs_abs 9 -#define cs_add 10 -#define cs_sub 11 -#define cs_div 12 -/* RESERVED 13 */ -#define cs_neg 14 -#define cs_eq 15 -/* cs_callothersubr 16 : TYPE1 */ -/* cs_pop 17 : TYPE1 */ -#define cs_drop 18 -/* RESERVED 19 */ -#define cs_put 20 -#define cs_get 21 -#define cs_ifelse 22 -#define cs_random 23 -#define cs_mul 24 -/* RESERVED 25 */ -#define cs_sqrt 26 -#define cs_dup 27 -#define cs_exch 28 -#define cs_index 29 -#define cs_roll 30 -/* cs_setcurrentpoint 31 : TYPE1 */ -/* RESERVED 32 */ -/* RESERVED 33 */ -#define cs_hflex 34 -#define cs_flex 35 -#define cs_hflex1 36 -#define cs_flex1 37 - -/* - * clear_stack() put all operands sotred in operand stack to dest. - */ -static void clear_stack(card8 ** dest, card8 * limit) -{ - int i; - - for (i = 0; i < cs2_stack_top; i++) { - double value; - long ivalue; - value = cs2_arg_stack[i]; - /* Nearest integer value */ - ivalue = (long) floor(value + 0.5); - if (value >= 0x8000L || value <= (-0x8000L - 1)) { - /* - * This number cannot be represented as a single operand. - * We must use `a b mul ...' or `a c div' to represent large values. - */ - CFF_ERROR("Argument value too large. (This is bug)"); - } else if (fabs(value - ivalue) > 3.0e-5) { - /* 16.16-bit signed fixed value */ - DST_NEED(limit, *dest + 5); - *(*dest)++ = 255; - ivalue = (long) floor(value); /* mantissa */ - *(*dest)++ = (ivalue >> 8) & 0xff; - *(*dest)++ = ivalue & 0xff; - ivalue = (long) ((value - ivalue) * 0x10000l); /* fraction */ - *(*dest)++ = (ivalue >> 8) & 0xff; - *(*dest)++ = ivalue & 0xff; - /* Everything else are integers. */ - } else if (ivalue >= -107 && ivalue <= 107) { - DST_NEED(limit, *dest + 1); - *(*dest)++ = ivalue + 139; - } else if (ivalue >= 108 && ivalue <= 1131) { - DST_NEED(limit, *dest + 2); - ivalue = 0xf700u + ivalue - 108; - *(*dest)++ = (ivalue >> 8) & 0xff; - *(*dest)++ = ivalue & 0xff; - } else if (ivalue >= -1131 && ivalue <= -108) { - DST_NEED(limit, *dest + 2); - ivalue = 0xfb00u - ivalue - 108; - *(*dest)++ = (ivalue >> 8) & 0xff; - *(*dest)++ = ivalue & 0xff; - } else if (ivalue >= -32768 && ivalue <= 32767) { /* shortint */ - DST_NEED(limit, *dest + 3); - *(*dest)++ = 28; - *(*dest)++ = (ivalue >> 8) & 0xff; - *(*dest)++ = (ivalue) & 0xff; - } else { /* Shouldn't come here */ - CFF_ERROR("Unexpected error."); - } - } - - cs2_stack_top = 0; /* clear stack */ - - return; -} - -/* - * Single byte operators: - * Path construction, Operator for finishing a path, Hint operators. - * - * phase: - * 0: inital state - * 1: hint declaration, first stack-clearing operator appeared - * 2: in path construction - */ - -static void -do_operator1(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) -{ - card8 op = **data; - - *data += 1; - - switch (op) { - case cs_hstemhm: - case cs_vstemhm: - /* charstring may have hintmask if above operator have seen */ - case cs_hstem: - case cs_vstem: - if (phase == 0 && (cs2_stack_top % 2)) { - have_width = 1; - width = cs2_arg_stack[0]; - } - num_stems += cs2_stack_top / 2; - clear_stack(dest, limit); - DST_NEED(limit, *dest + 1); - *(*dest)++ = op; - phase = 1; - break; - case cs_hintmask: - case cs_cntrmask: - if (phase < 2) { - if (phase == 0 && (cs2_stack_top % 2)) { - have_width = 1; - width = cs2_arg_stack[0]; - } - num_stems += cs2_stack_top / 2; - } - clear_stack(dest, limit); - DST_NEED(limit, *dest + 1); - *(*dest)++ = op; - if (num_stems > 0) { - int masklen = (num_stems + 7) / 8; - DST_NEED(limit, *dest + masklen); - SRC_NEED(endptr, *data + masklen); - memmove(*dest, *data, masklen); - *data += masklen; - *dest += masklen; - } - phase = 2; - break; - case cs_rmoveto: - if (phase == 0 && (cs2_stack_top % 2)) { - have_width = 1; - width = cs2_arg_stack[0]; - } - clear_stack(dest, limit); - DST_NEED(limit, *dest + 1); - *(*dest)++ = op; - phase = 2; - break; - case cs_hmoveto: - case cs_vmoveto: - if (phase == 0 && (cs2_stack_top % 2) == 0) { - have_width = 1; - width = cs2_arg_stack[0]; - } - clear_stack(dest, limit); - DST_NEED(limit, *dest + 1); - *(*dest)++ = op; - phase = 2; - break; - case cs_endchar: - if (cs2_stack_top == 1) { - have_width = 1; - width = cs2_arg_stack[0]; - clear_stack(dest, limit); - } else if (cs2_stack_top == 4 || cs2_stack_top == 5) { - WARN("\"seac\" character deprecated in Type 2 charstring."); - status = CS_PARSE_CFF_ERROR; - return; - } else if (cs2_stack_top > 0) { - WARN("Operand stack not empty."); - } - DST_NEED(limit, *dest + 1); - *(*dest)++ = op; - status = CS_CHAR_END; - break; - /* above oprators are candidate for first stack-clearing operator */ - case cs_rlineto: - case cs_hlineto: - case cs_vlineto: - case cs_rrcurveto: - case cs_rcurveline: - case cs_rlinecurve: - case cs_vvcurveto: - case cs_hhcurveto: - case cs_vhcurveto: - case cs_hvcurveto: - if (phase < 2) { - WARN("Broken Type 2 charstring."); - status = CS_PARSE_CFF_ERROR; - return; - } - clear_stack(dest, limit); - DST_NEED(limit, *dest + 1); - *(*dest)++ = op; - break; - /* all operotors above are stack-clearing operator */ - /* no output */ - case cs_return: - case cs_callgsubr: - case cs_callsubr: - CFF_ERROR("Unexpected call(g)subr/return"); - break; - default: - /* no-op ? */ - WARN("%s: Unknown charstring operator: 0x%02x", CS_TYPE2_DEBUG_STR, op); - status = CS_PARSE_CFF_ERROR; - break; - } - - return; -} - -/* - * Double byte operators: - * Flex, arithmetic, conditional, and storage operators. - * - * Following operators are not supported: - * random: How random ? - */ -static void -do_operator2(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) -{ - card8 op; - - *data += 1; - - SRC_NEED(endptr, *data + 1); - - op = **data; - *data += 1; - - switch (op) { - case cs_dotsection: /* deprecated */ - WARN("Operator \"dotsection\" deprecated in Type 2 charstring."); - status = CS_PARSE_CFF_ERROR; - return; - break; - case cs_hflex: - case cs_flex: - case cs_hflex1: - case cs_flex1: - if (phase < 2) { - WARN("%s: Broken Type 2 charstring.", CS_TYPE2_DEBUG_STR); - status = CS_PARSE_CFF_ERROR; - return; - } - clear_stack(dest, limit); - DST_NEED(limit, *dest + 2); - *(*dest)++ = cs_escape; - *(*dest)++ = op; - break; - /* all operator above are stack-clearing */ - /* no output */ - case cs_and: - NEED(cs2_stack_top, 2); - cs2_stack_top--; - if (cs2_arg_stack[cs2_stack_top] && cs2_arg_stack[cs2_stack_top - 1]) { - cs2_arg_stack[cs2_stack_top - 1] = 1.0; - } else { - cs2_arg_stack[cs2_stack_top - 1] = 0.0; - } - break; - case cs_or: - NEED(cs2_stack_top, 2); - cs2_stack_top--; - if (cs2_arg_stack[cs2_stack_top] || cs2_arg_stack[cs2_stack_top - 1]) { - cs2_arg_stack[cs2_stack_top - 1] = 1.0; - } else { - cs2_arg_stack[cs2_stack_top - 1] = 0.0; - } - break; - case cs_not: - NEED(cs2_stack_top, 1); - if (cs2_arg_stack[cs2_stack_top - 1]) { - cs2_arg_stack[cs2_stack_top - 1] = 0.0; - } else { - cs2_arg_stack[cs2_stack_top - 1] = 1.0; - } - break; - case cs_abs: - NEED(cs2_stack_top, 1); - cs2_arg_stack[cs2_stack_top - 1] = - fabs(cs2_arg_stack[cs2_stack_top - 1]); - break; - case cs_add: - NEED(cs2_stack_top, 2); - cs2_arg_stack[cs2_stack_top - 2] += cs2_arg_stack[cs2_stack_top - 1]; - cs2_stack_top--; - break; - case cs_sub: - NEED(cs2_stack_top, 2); - cs2_arg_stack[cs2_stack_top - 2] -= cs2_arg_stack[cs2_stack_top - 1]; - cs2_stack_top--; - break; - case cs_div: /* doesn't check overflow */ - NEED(cs2_stack_top, 2); - cs2_arg_stack[cs2_stack_top - 2] /= cs2_arg_stack[cs2_stack_top - 1]; - cs2_stack_top--; - break; - case cs_neg: - NEED(cs2_stack_top, 1); - cs2_arg_stack[cs2_stack_top - 1] *= -1.0; - break; - case cs_eq: - NEED(cs2_stack_top, 2); - cs2_stack_top--; - if (cs2_arg_stack[cs2_stack_top] == cs2_arg_stack[cs2_stack_top - 1]) { - cs2_arg_stack[cs2_stack_top - 1] = 1.0; - } else { - cs2_arg_stack[cs2_stack_top - 1] = 0.0; - } - break; - case cs_drop: - NEED(cs2_stack_top, 1); - cs2_stack_top--; - break; - case cs_put: - NEED(cs2_stack_top, 2); - { - int idx = (int) cs2_arg_stack[--cs2_stack_top]; - NEED(CS_TRANS_ARRAY_MAX, idx); - trn_array[idx] = cs2_arg_stack[--cs2_stack_top]; - } - break; - case cs_get: - NEED(cs2_stack_top, 1); - { - int idx = (int) cs2_arg_stack[cs2_stack_top - 1]; - NEED(CS_TRANS_ARRAY_MAX, idx); - cs2_arg_stack[cs2_stack_top - 1] = trn_array[idx]; - } - break; - case cs_ifelse: - NEED(cs2_stack_top, 4); - cs2_stack_top -= 3; - if (cs2_arg_stack[cs2_stack_top + 1] > cs2_arg_stack[cs2_stack_top + 2]) { - cs2_arg_stack[cs2_stack_top - 1] = cs2_arg_stack[cs2_stack_top]; - } - break; - case cs_mul: - NEED(cs2_stack_top, 2); - cs2_arg_stack[cs2_stack_top - 2] = - cs2_arg_stack[cs2_stack_top - 2] * cs2_arg_stack[cs2_stack_top - 1]; - cs2_stack_top--; - break; - case cs_sqrt: - NEED(cs2_stack_top, 1); - cs2_arg_stack[cs2_stack_top - 1] = - sqrt(cs2_arg_stack[cs2_stack_top - 1]); - break; - case cs_dup: - NEED(cs2_stack_top, 1); - NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); - cs2_arg_stack[cs2_stack_top] = cs2_arg_stack[cs2_stack_top - 1]; - cs2_stack_top++; - break; - case cs_exch: - NEED(cs2_stack_top, 2); - { - double save = cs2_arg_stack[cs2_stack_top - 2]; - cs2_arg_stack[cs2_stack_top - 2] = cs2_arg_stack[cs2_stack_top - 1]; - cs2_arg_stack[cs2_stack_top - 1] = save; - } - break; - case cs_index: - NEED(cs2_stack_top, 2); /* need two arguments at least */ - { - int idx = (int) cs2_arg_stack[cs2_stack_top - 1]; - if (idx < 0) { - cs2_arg_stack[cs2_stack_top - 1] = - cs2_arg_stack[cs2_stack_top - 2]; - } else { - NEED(cs2_stack_top, idx + 2); - cs2_arg_stack[cs2_stack_top - 1] = - cs2_arg_stack[cs2_stack_top - idx - 2]; - } - } - break; - case cs_roll: - NEED(cs2_stack_top, 2); - { - int N, J; - J = (int) cs2_arg_stack[--cs2_stack_top]; - N = (int) cs2_arg_stack[--cs2_stack_top]; - NEED(cs2_stack_top, N); - if (J > 0) { - J = J % N; - while (J-- > 0) { - double save = cs2_arg_stack[cs2_stack_top - 1]; - int i = cs2_stack_top - 1; - while (i > cs2_stack_top - N) { - cs2_arg_stack[i] = cs2_arg_stack[i - 1]; - i--; - } - cs2_arg_stack[i] = save; - } - } else { - J = (-J) % N; - while (J-- > 0) { - double save = cs2_arg_stack[cs2_stack_top - N]; - int i = cs2_stack_top - N; - while (i < cs2_stack_top - 1) { - cs2_arg_stack[i] = cs2_arg_stack[i + 1]; - i++; - } - cs2_arg_stack[i] = save; - } - } - } - break; - case cs_random: - WARN("%s: Charstring operator \"random\" found.", CS_TYPE2_DEBUG_STR); - NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); - cs2_arg_stack[cs2_stack_top++] = 1.0; - break; - default: - /* no-op ? */ - WARN("%s: Unknown charstring operator: 0x0c%02x", CS_TYPE2_DEBUG_STR, - op); - status = CS_PARSE_CFF_ERROR; - break; - } - - return; -} - -/* - * integer: - * exactly the same as the DICT encoding (except 29) - */ -static void cs2_get_integer(card8 ** data, card8 * endptr) -{ - long result = 0; - card8 b0 = **data, b1, b2; - - *data += 1; - - if (b0 == 28) { /* shortint */ - SRC_NEED(endptr, *data + 2); - b1 = **data; - b2 = *(*data + 1); - result = b1 * 256 + b2; - if (result > 0x7fff) - result -= 0x10000L; - *data += 2; - } else if (b0 >= 32 && b0 <= 246) { /* int (1) */ - result = b0 - 139; - } else if (b0 >= 247 && b0 <= 250) { /* int (2) */ - SRC_NEED(endptr, *data + 1); - b1 = **data; - result = (b0 - 247) * 256 + b1 + 108; - *data += 1; - } else if (b0 >= 251 && b0 <= 254) { - SRC_NEED(endptr, *data + 1); - b1 = **data; - result = -(b0 - 251) * 256 - b1 - 108; - *data += 1; - } else { - status = CS_PARSE_CFF_ERROR; - return; - } - - NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); - cs2_arg_stack[cs2_stack_top++] = (double) result; - - return; -} - -/* - * Signed 16.16-bits fixed number for Type 2 charstring encoding - */ -static void get_fixed(card8 ** data, card8 * endptr) -{ - long ivalue; - double rvalue; - - *data += 1; - - SRC_NEED(endptr, *data + 4); - - ivalue = *(*data) * 0x100 + *(*data + 1); - rvalue = (ivalue > 0x7fffL) ? (ivalue - 0x10000L) : ivalue; - ivalue = *(*data + 2) * 0x100 + *(*data + 3); - rvalue += ((double) ivalue) / 0x10000L; - - NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); - cs2_arg_stack[cs2_stack_top++] = rvalue; - *data += 4; - - return; -} - -/* - * Subroutines: - * The bias for subroutine number is introduced in type 2 charstrings. - * - * subr: set to a pointer to the subroutine charstring. - * len: set to the length of subroutine charstring. - * subr_idx: CFF INDEX data that contains subroutines. - * id: biased subroutine number. - */ -static void get_subr(card8 ** subr, long *len, cff_index * subr_idx, long id) -{ - card16 count; - - if (subr_idx == NULL) - CFF_ERROR("%s: Subroutine called but no subroutine found.", - CS_TYPE2_DEBUG_STR); - - count = subr_idx->count; - - /* Adding bias number */ - if (count < 1240) { - id += 107; - } else if (count < 33900) { - id += 1131; - } else { - id += 32768; - } - - if (id > count) - CFF_ERROR("%s: Invalid Subr index: %ld (max=%u)", CS_TYPE2_DEBUG_STR, - id, count); - - *len = (subr_idx->offset)[id + 1] - (subr_idx->offset)[id]; - *subr = subr_idx->data + (subr_idx->offset)[id] - 1; - - return; -} - -/* - * NOTE: - * The Type 2 interpretation of a number encoded in five-bytes (those with - * an initial byte value of 255) differs from how it is interpreted in the - * Type 1 format. - */ - -static void -do_charstring(card8 ** dest, card8 * limit, - card8 ** data, card8 * endptr, - cff_index * gsubr_idx, cff_index * subr_idx) -{ - card8 b0 = 0, *subr; - long len; - - if (cs2_nest > CS_SUBR_NEST_MAX) - CFF_ERROR("%s: Subroutine nested too deeply.", CS_TYPE2_DEBUG_STR); - - cs2_nest++; - - while (*data < endptr && status == CS_PARSE_OK) { - b0 = **data; - if (b0 == 255) { /* 16-bit.16-bit fixed signed number */ - get_fixed(data, endptr); - } else if (b0 == cs_return) { - status = CS_SUBR_RETURN; - } else if (b0 == cs_callgsubr) { - if (cs2_stack_top < 1) { - status = CS_STACK_CFF_ERROR; - } else { - cs2_stack_top--; - get_subr(&subr, &len, gsubr_idx, - (long) cs2_arg_stack[cs2_stack_top]); - if (*dest + len > limit) - CFF_ERROR("%s: Possible buffer overflow.", - CS_TYPE2_DEBUG_STR); - do_charstring(dest, limit, &subr, subr + len, gsubr_idx, - subr_idx); - *data += 1; - } - } else if (b0 == cs_callsubr) { - if (cs2_stack_top < 1) { - status = CS_STACK_CFF_ERROR; - } else { - cs2_stack_top--; - get_subr(&subr, &len, subr_idx, - (long) cs2_arg_stack[cs2_stack_top]); - if (limit < *dest + len) - CFF_ERROR("%s: Possible buffer overflow.", - CS_TYPE2_DEBUG_STR); - do_charstring(dest, limit, &subr, subr + len, gsubr_idx, - subr_idx); - *data += 1; - } - } else if (b0 == cs_escape) { - do_operator2(dest, limit, data, endptr); - } else if (b0 < 32 && b0 != 28) { /* 19, 20 need mask */ - do_operator1(dest, limit, data, endptr); - } else if ((b0 <= 22 && b0 >= 27) || b0 == 31) { /* reserved */ - status = CS_PARSE_CFF_ERROR; /* not an error ? */ - } else { /* integer */ - cs2_get_integer(data, endptr); - } - } - - if (status == CS_SUBR_RETURN) { - status = CS_PARSE_OK; - } else if (status == CS_CHAR_END && *data < endptr) { - WARN("%s: Garbage after endchar.", CS_TYPE2_DEBUG_STR); - } else if (status < CS_PARSE_OK) { /* error */ - CFF_ERROR("%s: Parsing charstring failed: (status=%d, stack=%d)", - CS_TYPE2_DEBUG_STR, status, cs2_stack_top); - } - - cs2_nest--; - - return; -} - -static void cs_parse_init(void) -{ - status = CS_PARSE_OK; - cs2_nest = 0; - phase = 0; - num_stems = 0; - cs2_stack_top = 0; -} - -/* - * Not just copying... - */ -long -cs_copy_charstring(card8 * dst, long dstlen, - card8 * src, long srclen, - cff_index * gsubr, cff_index * subr, - double default_width, double nominal_width, cs_ginfo * ginfo) -{ - card8 *save = dst; - - cs_parse_init(); - - width = 0.0; - have_width = 0; - - /* expand call(g)subrs */ - do_charstring(&dst, dst + dstlen, &src, src + srclen, gsubr, subr); - - if (ginfo) { - ginfo->flags = 0; /* not used */ - if (have_width) { - ginfo->wx = nominal_width + width; - } else { - ginfo->wx = default_width; - } - } - - return (long) (dst - save); -} - -/* encodings */ - -/* - * Encoding and Charset - * - * Encoding and Charset arrays always begin with GID = 1. - */ -long cff_read_encoding(cff_font * cff) -{ - cff_encoding *encoding; - long offset, length; - card8 i; - - if (cff->topdict == NULL) { - CFF_ERROR("Top DICT data not found"); - } - - if (!cff_dict_known(cff->topdict, "Encoding")) { - cff->flag |= ENCODING_STANDARD; - cff->encoding = NULL; - return 0; - } - - offset = (long) cff_dict_get(cff->topdict, "Encoding", 0); - if (offset == 0) { /* predefined */ - cff->flag |= ENCODING_STANDARD; - cff->encoding = NULL; - return 0; - } else if (offset == 1) { - cff->flag |= ENCODING_EXPERT; - cff->encoding = NULL; - return 0; - } - - cff->offset = offset; - cff->encoding = encoding = xcalloc(1, sizeof(cff_encoding)); - encoding->format = get_card8(cff); - length = 1; - - switch (encoding->format & (~0x80)) { - case 0: - encoding->num_entries = get_card8(cff); - (encoding->data).codes = xcalloc(encoding->num_entries, sizeof(card8)); - for (i = 0; i < (encoding->num_entries); i++) { - (encoding->data).codes[i] = get_card8(cff); - } - length += encoding->num_entries + 1; - break; - case 1: - { - cff_range1 *ranges; - encoding->num_entries = get_card8(cff); - encoding->data.range1 = ranges - = xcalloc(encoding->num_entries, sizeof(cff_range1)); - for (i = 0; i < (encoding->num_entries); i++) { - ranges[i].first = get_card8(cff); - ranges[i].n_left = get_card8(cff); - } - length += (encoding->num_entries) * 2 + 1; - } - break; - default: - xfree(encoding); - CFF_ERROR("Unknown Encoding format"); - break; - } - - /* Supplementary data */ - if ((encoding->format) & 0x80) { - cff_map *map; - encoding->num_supps = get_card8(cff); - encoding->supp = map = xcalloc(encoding->num_supps, sizeof(cff_map)); - for (i = 0; i < (encoding->num_supps); i++) { - map[i].code = get_card8(cff); - map[i].glyph = get_card16(cff); /* SID */ - } - length += (encoding->num_supps) * 3 + 1; - } else { - encoding->num_supps = 0; - encoding->supp = NULL; - } - - return length; -} - -long cff_pack_encoding(cff_font * cff, card8 * dest, long destlen) -{ - long len = 0; - cff_encoding *encoding; - card16 i; - - if (cff->flag & HAVE_STANDARD_ENCODING || cff->encoding == NULL) - return 0; - - if (destlen < 2) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); - - encoding = cff->encoding; - - dest[len++] = encoding->format; - dest[len++] = encoding->num_entries; - switch (encoding->format & (~0x80)) { - case 0: - if (destlen < len + encoding->num_entries) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); - for (i = 0; i < (encoding->num_entries); i++) { - dest[len++] = (encoding->data).codes[i]; - } - break; - case 1: - { - if (destlen < len + (encoding->num_entries) * 2) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); - for (i = 0; i < (encoding->num_entries); i++) { - dest[len++] = (encoding->data).range1[i].first & 0xff; - dest[len++] = (encoding->data).range1[i].n_left; - } - } - break; - default: - CFF_ERROR("Unknown Encoding format"); - break; - } - - if ((encoding->format) & 0x80) { - if (destlen < len + (encoding->num_supps) * 3 + 1) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); - dest[len++] = encoding->num_supps; - for (i = 0; i < (encoding->num_supps); i++) { - dest[len++] = (encoding->supp)[i].code; - dest[len++] = ((encoding->supp)[i].glyph >> 8) & 0xff; - dest[len++] = (encoding->supp)[i].glyph & 0xff; - } - } - - return len; -} - -/* CID-Keyed font specific */ -long cff_read_fdselect(cff_font * cff) -{ - cff_fdselect *fdsel; - long offset, length; - card16 i; - - if (cff->topdict == NULL) - CFF_ERROR("Top DICT not available"); - - if (!(cff->flag & FONTTYPE_CIDFONT)) - return 0; - - offset = (long) cff_dict_get(cff->topdict, "FDSelect", 0); - cff->offset = offset; - cff->fdselect = fdsel = xcalloc(1, sizeof(cff_fdselect)); - fdsel->format = get_card8(cff); - - length = 1; - - switch (fdsel->format) { - case 0: - fdsel->num_entries = cff->num_glyphs; - (fdsel->data).fds = xcalloc(fdsel->num_entries, sizeof(card8)); - for (i = 0; i < (fdsel->num_entries); i++) { - (fdsel->data).fds[i] = get_card8(cff); - } - length += fdsel->num_entries; - break; - case 3: - { - cff_range3 *ranges; - fdsel->num_entries = get_card16(cff); - fdsel->data.ranges = ranges = - xcalloc(fdsel->num_entries, sizeof(cff_range3)); - for (i = 0; i < (fdsel->num_entries); i++) { - ranges[i].first = get_card16(cff); - ranges[i].fd = get_card8(cff); - } - if (ranges[0].first != 0) - CFF_ERROR("Range not starting with 0."); - if (cff->num_glyphs != get_card16(cff)) - CFF_ERROR("Sentinel value mismatched with number of glyphs."); - length += (fdsel->num_entries) * 3 + 4; - } - break; - default: - xfree(fdsel); - CFF_ERROR("Unknown FDSelect format."); - break; - } - - return length; -} - - -long cff_pack_fdselect(cff_font * cff, card8 * dest, long destlen) -{ - cff_fdselect *fdsel; - long len = 0; - card16 i; - - if (cff->fdselect == NULL) - return 0; - - if (destlen < 1) - CFF_ERROR("in cff_pack_fdselect(): Buffur overflow"); - - fdsel = cff->fdselect; - - dest[len++] = fdsel->format; - switch (fdsel->format) { - case 0: - if (fdsel->num_entries != cff->num_glyphs) - CFF_ERROR("in cff_pack_fdselect(): Invalid data"); - if (destlen < len + fdsel->num_entries) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); - for (i = 0; i < fdsel->num_entries; i++) { - dest[len++] = (fdsel->data).fds[i]; - } - break; - case 3: - { - if (destlen < len + 2) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); - len += 2; - for (i = 0; i < (fdsel->num_entries); i++) { - if (destlen < len + 3) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); - dest[len++] = ((fdsel->data).ranges[i].first >> 8) & 0xff; - dest[len++] = (fdsel->data).ranges[i].first & 0xff; - dest[len++] = (fdsel->data).ranges[i].fd; - } - if (destlen < len + 2) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); - dest[len++] = (cff->num_glyphs >> 8) & 0xff; - dest[len++] = cff->num_glyphs & 0xff; - dest[1] = ((len / 3 - 1) >> 8) & 0xff; - dest[2] = (len / 3 - 1) & 0xff; - } - break; - default: - CFF_ERROR("Unknown FDSelect format."); - break; - } - - return len; -} - - - -/* - * Create an instance of embeddable font. - */ -static void write_fontfile(cff_font * cffont, char *fullname) -{ - cff_index *topdict, *fdarray, *private; - unsigned char *dest; - long destlen = 0, i, size; - long offset, topdict_offset, fdarray_offset; - - /* DICT sizes (offset set to long int) */ - topdict = cff_new_index(1); - fdarray = cff_new_index(cffont->num_fds); - private = cff_new_index(cffont->num_fds); - - cff_dict_remove(cffont->topdict, "UniqueID"); - cff_dict_remove(cffont->topdict, "XUID"); - cff_dict_remove(cffont->topdict, "Private"); /* some bad font may have */ - cff_dict_remove(cffont->topdict, "Encoding"); /* some bad font may have */ - - topdict->offset[1] = cff_dict_pack(cffont->topdict, - (card8 *) work_buffer, - WORK_BUFFER_SIZE) + 1; - for (i = 0; i < cffont->num_fds; i++) { - size = 0; - if (cffont->private && cffont->private[i]) { - size = cff_dict_pack(cffont->private[i], - (card8 *) work_buffer, WORK_BUFFER_SIZE); - if (size < 1) { /* Private had contained only Subr */ - cff_dict_remove(cffont->fdarray[i], "Private"); - } - } - (private->offset)[i + 1] = (private->offset)[i] + size; - (fdarray->offset)[i + 1] = (fdarray->offset)[i] + - cff_dict_pack(cffont->fdarray[i], - (card8 *) work_buffer, WORK_BUFFER_SIZE); - } - - destlen = 4; /* header size */ - destlen += cff_set_name(cffont, fullname); - destlen += cff_index_size(topdict); - destlen += cff_index_size(cffont->string); - destlen += cff_index_size(cffont->gsubr); - destlen += (cffont->charsets->num_entries) * 2 + 1; /* charset format 0 */ - destlen += (cffont->fdselect->num_entries) * 3 + 5; /* fdselect format 3 */ - destlen += cff_index_size(cffont->cstrings); - destlen += cff_index_size(fdarray); - destlen += private->offset[private->count] - 1; /* Private is not INDEX */ - - dest = xcalloc(destlen, sizeof(card8)); - - offset = 0; - /* Header */ - offset += cff_put_header(cffont, dest + offset, destlen - offset); - /* Name */ - offset += cff_pack_index(cffont->name, dest + offset, destlen - offset); - /* Top DICT */ - topdict_offset = offset; - offset += cff_index_size(topdict); - /* Strings */ - offset += cff_pack_index(cffont->string, dest + offset, destlen - offset); - /* Global Subrs */ - offset += cff_pack_index(cffont->gsubr, dest + offset, destlen - offset); - - /* charset */ - cff_dict_set(cffont->topdict, "charset", 0, offset); - offset += cff_pack_charsets(cffont, dest + offset, destlen - offset); - - /* FDSelect */ - cff_dict_set(cffont->topdict, "FDSelect", 0, offset); - offset += cff_pack_fdselect(cffont, dest + offset, destlen - offset); - - /* CharStrings */ - cff_dict_set(cffont->topdict, "CharStrings", 0, offset); - offset += cff_pack_index(cffont->cstrings, - dest + offset, cff_index_size(cffont->cstrings)); - cff_release_index(cffont->cstrings); - cffont->cstrings = NULL; /* Charstrings cosumes huge memory */ - - /* FDArray and Private */ - cff_dict_set(cffont->topdict, "FDArray", 0, offset); - fdarray_offset = offset; - offset += cff_index_size(fdarray); - - fdarray->data = xcalloc(fdarray->offset[fdarray->count] - 1, sizeof(card8)); - for (i = 0; i < cffont->num_fds; i++) { - size = private->offset[i + 1] - private->offset[i]; - if (cffont->private[i] && size > 0) { - cff_dict_pack(cffont->private[i], dest + offset, size); - cff_dict_set(cffont->fdarray[i], "Private", 0, size); - cff_dict_set(cffont->fdarray[i], "Private", 1, offset); - } - cff_dict_pack(cffont->fdarray[i], - fdarray->data + (fdarray->offset)[i] - 1, - fdarray->offset[fdarray->count] - 1); - offset += size; - } - - cff_pack_index(fdarray, dest + fdarray_offset, cff_index_size(fdarray)); - cff_release_index(fdarray); - cff_release_index(private); - - /* Finally Top DICT */ - topdict->data = xcalloc(topdict->offset[topdict->count] - 1, sizeof(card8)); - cff_dict_pack(cffont->topdict, - topdict->data, topdict->offset[topdict->count] - 1); - cff_pack_index(topdict, dest + topdict_offset, cff_index_size(topdict)); - cff_release_index(topdict); - - for (i = 0; i < offset; i++) - fb_putchar(dest[i]); - - /*fprintf(stdout," (%i/%i)",offset,cffont->stream_size); */ - xfree(dest); - return; -} - - -/* this block is used a few times */ - -#define DO_COPY_CHARSTRING() \ - if ((avl_find(fd->gl_tree,glyph) != NULL)) { \ - size = cs_idx->offset[code+1] - cs_idx->offset[code]; \ - if (size > CS_STR_LEN_MAX) { \ - pdftex_fail("Charstring too long: gid=%u, %ld bytes", code, size); \ - } \ - if (charstring_len + CS_STR_LEN_MAX >= max_len) { \ - max_len = charstring_len + 2 * CS_STR_LEN_MAX; \ - charstrings->data = xrealloc(charstrings->data, max_len*sizeof(card8)); \ - } \ - (charstrings->offset)[gid] = charstring_len + 1; \ - cffont->offset= offset + (cs_idx->offset)[code] - 1; \ - memcpy(data,&cffont->stream[cffont->offset],size); \ - charstring_len += cs_copy_charstring(charstrings->data + charstring_len, \ - max_len - charstring_len, \ - data, size, \ - cffont->gsubr, (cffont->subrs)[0], \ - default_width, nominal_width, NULL); \ - gid++; \ - } - -void write_cff(cff_font * cffont, fd_entry * fd) -{ - cff_index *charstrings, *cs_idx; - - long charstring_len, max_len; - long size, offset = 0; - - card8 *data; - card16 num_glyphs, cs_count, code, gid, last_cid; - - double nominal_width, default_width; - - char *fullname; - - glw_entry *glyph, *found; - struct avl_traverser t; - - fullname = xcalloc(8 + strlen(fd->fontname), 1); - sprintf(fullname, "%s+%s", fd->subset_tag, fd->fontname); - - /* finish parsing the CFF */ - cff_read_private(cffont); - cff_read_subrs(cffont); - - /* - * Widths - */ - if (cffont->private[0] && - cff_dict_known(cffont->private[0], "defaultWidthX")) { - default_width = - (double) cff_dict_get(cffont->private[0], "defaultWidthX", 0); - } else { - default_width = CFF_DEFAULTWIDTHX_DEFAULT; - } - if (cffont->private[0] && - cff_dict_known(cffont->private[0], "nominalWidthX")) { - nominal_width = - (double) cff_dict_get(cffont->private[0], "nominalWidthX", 0); - } else { - nominal_width = CFF_NOMINALWIDTHX_DEFAULT; - } - - num_glyphs = 0; - last_cid = 0; - glyph = xtalloc(1, glw_entry); - - /* insert notdef */ - glyph->id = 0; - if (avl_find(fd->gl_tree, glyph) == NULL) { - avl_insert(fd->gl_tree, glyph); - glyph = xtalloc(1, glw_entry); - } - - avl_t_init(&t, fd->gl_tree); - for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); - found != NULL; found = (glw_entry *) avl_t_next(&t)) { - if (found->id > last_cid) - last_cid = found->id; - num_glyphs++; - } - - { - cff_fdselect *fdselect; - - fdselect = xcalloc(1, sizeof(cff_fdselect)); - fdselect->format = 3; - fdselect->num_entries = 1; - fdselect->data.ranges = xcalloc(1, sizeof(cff_range3)); - fdselect->data.ranges[0].first = 0; - fdselect->data.ranges[0].fd = 0; - cffont->fdselect = fdselect; - } - - { - cff_charsets *charset; - - charset = xcalloc(1, sizeof(cff_charsets)); - charset->format = 0; - charset->num_entries = num_glyphs - 1; - charset->data.glyphs = xcalloc(num_glyphs, sizeof(s_SID)); - - gid = 0; - - avl_t_init(&t, fd->gl_tree); - for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); - found != NULL; found = (glw_entry *) avl_t_next(&t)) { - if (found->id != 0) { - charset->data.glyphs[gid] = found->id; - gid++; - } - } - cffont->charsets = charset; - } - - cff_dict_add(cffont->topdict, "CIDCount", 1); - cff_dict_set(cffont->topdict, "CIDCount", 0, last_cid + 1); - - cffont->fdarray = xcalloc(1, sizeof(cff_dict *)); - cffont->fdarray[0] = cff_new_dict(); - cff_dict_add(cffont->fdarray[0], "FontName", 1); - cff_dict_set(cffont->fdarray[0], "FontName", 0, (double) cff_add_string(cffont, fullname)); /* FIXME: Skip XXXXXX+ */ - cff_dict_add(cffont->fdarray[0], "Private", 2); - cff_dict_set(cffont->fdarray[0], "Private", 0, 0.0); - cff_dict_set(cffont->fdarray[0], "Private", 0, 0.0); - /* FDArray - index offset, not known yet */ - cff_dict_add(cffont->topdict, "FDArray", 1); - cff_dict_set(cffont->topdict, "FDArray", 0, 0.0); - /* FDSelect - offset, not known yet */ - cff_dict_add(cffont->topdict, "FDSelect", 1); - cff_dict_set(cffont->topdict, "FDSelect", 0, 0.0); - - cff_dict_remove(cffont->topdict, "UniqueID"); - cff_dict_remove(cffont->topdict, "XUID"); - cff_dict_remove(cffont->topdict, "Private"); - cff_dict_remove(cffont->topdict, "Encoding"); - - cffont->offset = cff_dict_get(cffont->topdict, "CharStrings", 0); - cs_idx = cff_get_index_header(cffont); - - offset = cffont->offset; - cs_count = cs_idx->count; - if (cs_count < 2) { - CFF_ERROR("No valid charstring data found."); - } - - /* build the new charstrings entry */ - charstrings = cff_new_index(cs_count + 1); - max_len = 2 * CS_STR_LEN_MAX; - charstrings->data = xcalloc(max_len, sizeof(card8)); - charstring_len = 0; - - gid = 0; - data = xcalloc(CS_STR_LEN_MAX, sizeof(card8)); - - { - int i; - for (i = 0; i < cs_count; i++) { - code = i; - glyph->id = code; - DO_COPY_CHARSTRING(); - } - } - - /* this happens if the internal metrics do not agree with the actual disk font */ - if (gid < num_glyphs) { - WARN("embedded subset is smaller than expected: %d instead of %d glyphs.", gid, num_glyphs); - num_glyphs = gid; - } - - xfree(data); - cff_release_index(cs_idx); - - (charstrings->offset)[num_glyphs] = charstring_len + 1; - charstrings->count = num_glyphs; - cffont->num_glyphs = num_glyphs; - cffont->cstrings = charstrings; - - /* - * We don't use subroutines at all. - */ - if (cffont->gsubr) - cff_release_index(cffont->gsubr); - cffont->gsubr = cff_new_index(0); - - if (cffont->subrs && cffont->subrs[0]) - cff_release_index(cffont->subrs[0]); - cffont->subrs[0] = NULL; - - if (cffont->private && (cffont->private)[0]) { - cff_dict_remove((cffont->private)[0], "Subrs"); /* no Subrs */ - } - - cff_add_string(cffont, "Adobe"); - cff_add_string(cffont, "Identity"); - - cff_dict_update(cffont->topdict, cffont); - cff_dict_update(cffont->private[0], cffont); - cff_update_string(cffont); - - /* CFF code need to be rewrote... */ - cff_dict_add(cffont->topdict, "ROS", 3); - cff_dict_set(cffont->topdict, "ROS", 0, - (double) cff_get_sid(cffont, "Adobe")); - cff_dict_set(cffont->topdict, "ROS", 1, - (double) cff_get_sid(cffont, "Identity")); - cff_dict_set(cffont->topdict, "ROS", 2, 0.0); - - write_fontfile(cffont, fullname); - xfree(fullname); - cff_close(cffont); - -} - -#define ERROR(a) { perror(a); return 0; } - -/* Input : SID or CID (16-bit unsigned int) - * Output: glyph index - */ -card16 cff_charsets_lookup(cff_font * cff, card16 cid) -{ - card16 gid = 0; - cff_charsets *charset; - card16 i; - - if (cff->flag & (CHARSETS_ISOADOBE | CHARSETS_EXPERT | CHARSETS_EXPSUB)) { - ERROR("Predefined CFF charsets not supported yet"); - } else if (cff->charsets == NULL) { - ERROR("Charsets data not available"); - } - - if (cid == 0) { - return 0; /* GID 0 (.notdef) */ - } - - charset = cff->charsets; - - gid = 0; - switch (charset->format) { - case 0: - for (i = 0; i < charset->num_entries; i++) { - if (cid == charset->data.glyphs[i]) { - gid = i + 1; - return gid; - } - } - break; - case 1: - for (i = 0; i < charset->num_entries; i++) { - if (cid >= charset->data.range1[i].first && - cid <= - charset->data.range1[i].first + - charset->data.range1[i].n_left) { - gid += cid - charset->data.range1[i].first + 1; - return gid; - } - gid += charset->data.range1[i].n_left + 1; - } - break; - case 2: - for (i = 0; i < charset->num_entries; i++) { - if (cid >= charset->data.range2[i].first && - cid <= - charset->data.range2[i].first + - charset->data.range2[i].n_left) { - gid += cid - charset->data.range2[i].first + 1; - return gid; - } - gid += charset->data.range2[i].n_left + 1; - } - break; - default: - ERROR("Unknown Charset format"); - } - - return 0; /* not found */ -} - - -#define is_cidfont(a) ((a)->flag & FONTTYPE_CIDFONT) -#define CID_MAX 65535 - -void write_cid_cff(cff_font * cffont, fd_entry * fd) -{ - cff_index *charstrings, *cs_idx; - - long charstring_len, max_len; - long size, offset = 0; - - card8 *data; - card16 num_glyphs, cs_count, gid, last_cid; - - - int fdsel, prev_fd, cid_count, cid; - char *fullname; - - glw_entry *glyph; - - unsigned char *CIDToGIDMap = NULL; - - cff_fdselect *fdselect = NULL; - cff_charsets *charset = NULL; - - - if (!is_cidfont(cffont)) { - perror("Not a CIDfont."); - return; - } - - fullname = xcalloc(8 + strlen(fd->fontname), 1); - sprintf(fullname, "%s+%s", fd->subset_tag, fd->fontname); - - /* finish parsing the CFF */ - - if (cff_dict_known(cffont->topdict, "CIDCount")) { - cid_count = (card16) cff_dict_get(cffont->topdict, "CIDCount", 0); - } else { - cid_count = CFF_CIDCOUNT_DEFAULT; - } - cff_read_charsets(cffont); - CIDToGIDMap = xmalloc((2 * cid_count) * sizeof(unsigned char)); - memset(CIDToGIDMap, 0, 2 * cid_count); - - - glyph = xtalloc(1, glw_entry); - /* insert notdef */ - glyph->id = 0; - if (avl_find(fd->gl_tree, glyph) == NULL) { - avl_insert(fd->gl_tree, glyph); - glyph = xtalloc(1, glw_entry); - } - - cid = 0; - last_cid = 0; - num_glyphs = 0; - for (cid = 0; cid <= CID_MAX; cid++) { - glyph->id = cid; - if (avl_find(fd->gl_tree, glyph) != NULL) { - gid = cff_charsets_lookup(cffont, cid); - CIDToGIDMap[2 * cid] = (gid >> 8) & 0xff; - CIDToGIDMap[2 * cid + 1] = gid & 0xff; - last_cid = cid; - num_glyphs++; - } - } - - cff_read_fdselect(cffont); - cff_read_fdarray(cffont); - cff_read_private(cffont); - - cff_read_subrs(cffont); - - - cffont->offset = cff_dict_get(cffont->topdict, "CharStrings", 0); - cs_idx = cff_get_index_header(cffont); - - offset = cffont->offset; - cs_count = cs_idx->count; - if (cs_count < 2) { - CFF_ERROR("No valid charstring data found."); - } - - charset = xcalloc(1, sizeof(cff_charsets)); - charset->format = 0; - charset->num_entries = 0; - charset->data.glyphs = xcalloc(num_glyphs, sizeof(s_SID)); - - fdselect = xcalloc(1, sizeof(cff_fdselect)); - fdselect->format = 3; - fdselect->num_entries = 0; - fdselect->data.ranges = xcalloc(num_glyphs, sizeof(cff_range3)); - - charstrings = cff_new_index(cs_count + 1); - max_len = 2 * CS_STR_LEN_MAX; - charstrings->data = xcalloc(max_len, sizeof(card8)); - charstring_len = 0; - - prev_fd = -1; - gid = 0; - data = xcalloc(CS_STR_LEN_MAX, sizeof(card8)); - for (cid = 0; cid <= last_cid; cid++) { - unsigned short gid_org; - - glyph->id = cid; - if (avl_find(fd->gl_tree, glyph) == NULL) - continue; - - gid_org = (CIDToGIDMap[2 * cid] << 8) | (CIDToGIDMap[2 * cid + 1]); - size = cs_idx->offset[gid_org + 1] - cs_idx->offset[gid_org]; - if (size > CS_STR_LEN_MAX) { - pdftex_fail("Charstring too long: gid=%u, %ld bytes", cid, size); - } - if (charstring_len + CS_STR_LEN_MAX >= max_len) { - max_len = charstring_len + 2 * CS_STR_LEN_MAX; - charstrings->data = - xrealloc(charstrings->data, max_len * sizeof(card8)); - } - (charstrings->offset)[gid] = charstring_len + 1; - cffont->offset = offset + (cs_idx->offset)[gid_org] - 1; - memcpy(data, &cffont->stream[cffont->offset], size); - fdsel = cff_fdselect_lookup(cffont, gid_org); - charstring_len += cs_copy_charstring(charstrings->data + charstring_len, - max_len - charstring_len, - data, size, - cffont->gsubr, - (cffont->subrs)[fdsel], 0, 0, - NULL); - - if (cid > 0 && gid_org > 0) { - charset->data.glyphs[charset->num_entries] = cid; - charset->num_entries += 1; - } - if (fdsel != prev_fd) { - fdselect->data.ranges[fdselect->num_entries].first = gid; - fdselect->data.ranges[fdselect->num_entries].fd = fdsel; - fdselect->num_entries += 1; - prev_fd = fdsel; - } - gid++; - } - - if (gid != num_glyphs) - CFF_ERROR("Unexpected error: %i != %i", gid, num_glyphs); - xfree(data); - cff_release_index(cs_idx); - - xfree(CIDToGIDMap); - - (charstrings->offset)[num_glyphs] = charstring_len + 1; - charstrings->count = num_glyphs; - cffont->num_glyphs = num_glyphs; - cffont->cstrings = charstrings; - - cff_release_charsets(cffont->charsets); - cffont->charsets = charset; - cff_release_fdselect(cffont->fdselect); - cffont->fdselect = fdselect; - - /* - * We don't use subroutines at all. - */ - if (cffont->gsubr) - cff_release_index(cffont->gsubr); - cffont->gsubr = cff_new_index(0); - - for (fdsel = 0; fdsel < cffont->num_fds; fdsel++) { - if (cffont->subrs && cffont->subrs[fdsel]) { - cff_release_index(cffont->subrs[fdsel]); - cffont->subrs[fdsel] = NULL; - } - if (cffont->private && (cffont->private)[fdsel]) { - cff_dict_remove((cffont->private)[fdsel], "Subrs"); /* no Subrs */ - } - } - - write_fontfile(cffont, fullname); - xfree(fullname); - cff_close(cffont); - -} - - -/* here is a sneaky trick: fontforge knows how to convert Type1 to CFF, so - * I have defined a utility function in luafflib.c that does exactly that. - * If it works out ok, I will clean up this code. - */ -#include - -void writetype1w(fd_entry * fd) -{ - cff_font *cff; - int i; - FILE *fp; - ff_entry *ff; - unsigned char *tfm_buffer = NULL; - int tfm_size = 0; - - ff = check_ff_exist(fd->fm->ff_name, 0); - - fp = fopen(ff->ff_path, "rb"); - cur_file_name = ff->ff_path; - - if (!fp) { - fprintf(stderr, "Type1: Could not open Type1 font: %s", cur_file_name); - uexit(1); - } - fclose(fp); - - if (tracefilenames) { - if (is_subsetted(fd->fm)) - tex_printf("<%s", cur_file_name); - else - tex_printf("<<%s", cur_file_name); - } - - (void) ff_createcff(ff->ff_path, &tfm_buffer, &tfm_size); - - if (tfm_size > 0) { - cff = read_cff(tfm_buffer, tfm_size, 0); - if (cff != NULL) { - write_cff(cff, fd); - } else { - for (i = 0; i < tfm_size; i++) - fb_putchar(tfm_buffer[i]); - } - fd->ff_found = 1; - } else { - fprintf(stderr, "Type1: Could not understand Type1 font: %s", - cur_file_name); - uexit(1); - } - if (tracefilenames) { - if (is_subsetted(fd->fm)) - tex_printf(">"); - else - tex_printf(">>"); - } - cur_file_name = NULL; -} diff --git a/Build/source/texk/web2c/luatexdir/font/writecff.h b/Build/source/texk/web2c/luatexdir/font/writecff.h index bec0add205b..266cc9d1f6d 100644 --- a/Build/source/texk/web2c/luatexdir/font/writecff.h +++ b/Build/source/texk/web2c/luatexdir/font/writecff.h @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: writecff.h 2271 2009-04-12 23:42:21Z oneiros $ */ +/* $Id: writecff.h 3400 2010-01-27 16:10:42Z taco $ */ #ifndef _CFF_LIMITS_H_ # define _CFF_LIMITS_H_ @@ -340,5 +340,5 @@ extern long cs_copy_charstring(card8 * dest, long destlen, extern cff_font *read_cff(unsigned char *buf, long buflength, int subf); -extern void write_cff(cff_font * cff, fd_entry * fd); -extern void write_cid_cff(cff_font * cffont, fd_entry * fd); +extern void write_cff(PDF pdf, cff_font * cff, fd_entry * fd); +extern void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd); diff --git a/Build/source/texk/web2c/luatexdir/font/writecff.w b/Build/source/texk/web2c/luatexdir/font/writecff.w new file mode 100644 index 00000000000..91d1f3c9af2 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writecff.w @@ -0,0 +1,3526 @@ +% writecff.w + +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . */ + +@ @c +#include "ptexlib.h" +#include "lua/luatex-api.h" + +#include "font/writecff.h" + +static const char _svn_version[] = + "$Id: writecff.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writecff.w $"; + +@ @c +#define get_offset(s,n) get_unsigned(s, (n)) +#define get_card8(a) (card8)(a->stream[a->offset++]) +#define get_card16(a) (card16)(get_unsigned(a,2)) + +#undef b0 +#undef b1 +#undef b2 +#undef b3 + +#define WORK_BUFFER_SIZE 1024 + +static char work_buffer[WORK_BUFFER_SIZE]; + +static unsigned long get_unsigned(cff_font * cff, int n) +{ + unsigned long v = 0; + while (n-- > 0) + v = v * 256 + get_card8(cff); + return v; +} + +@ @c +#define CFF_ERROR pdftex_fail +#undef WARN +#define WARN pdftex_warn + +const char *const cff_stdstr[CFF_STDSTR_MAX] = { + ".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" +}; + + +@ Only read header part but not body +@c +cff_index *cff_get_index_header(cff_font * cff) +{ + cff_index *idx; + card16 i, count; + + idx = xcalloc(1, sizeof(cff_index)); + + idx->count = count = get_card16(cff); + if (count > 0) { + idx->offsize = get_card8(cff); + if (idx->offsize < 1 || idx->offsize > 4) + CFF_ERROR("invalid offsize data"); + + idx->offset = + xmalloc((unsigned) (((unsigned) count + 1) * sizeof(l_offset))); + for (i = 0; i < count + 1; i++) { + (idx->offset)[i] = get_offset(cff, idx->offsize); + } + + if (idx->offset[0] != 1) + CFF_ERROR("cff_get_index(): invalid index data"); + + idx->data = NULL; + } else { + idx->offsize = 0; + idx->offset = NULL; + idx->data = NULL; + } + + return idx; +} + + + +@ @c +cff_index *cff_get_index(cff_font * cff) +{ + cff_index *idx; + card16 i, count; + size_t length; + + idx = xcalloc(1, sizeof(cff_index)); + + idx->count = count = get_card16(cff); + if (count > 0) { + idx->offsize = get_card8(cff); + if (idx->offsize < 1 || idx->offsize > 4) + CFF_ERROR("invalid offsize data"); + + idx->offset = + xmalloc((unsigned) (((unsigned) count + 1) * sizeof(l_offset))); + for (i = 0; i < count + 1; i++) { + idx->offset[i] = get_offset(cff, idx->offsize); + } + + if (idx->offset[0] != 1) + CFF_ERROR("Invalid CFF Index offset data"); + + length = (size_t) (idx->offset[count] - idx->offset[0]); + + idx->data = xmalloc((unsigned) length * sizeof(card8)); + memcpy(idx->data, &cff->stream[cff->offset], length); + cff->offset += length; + + } else { + idx->offsize = 0; + idx->offset = NULL; + idx->data = NULL; + } + return idx; +} + + +@ @c +long cff_pack_index(cff_index * idx, card8 * dest, long destlen) +{ + long len = 0; + unsigned long datalen; + card16 i; + + if (idx->count < 1) { + if (destlen < 2) + CFF_ERROR("Not enough space available..."); + memset(dest, 0, 2); + return 2; + } + + len = cff_index_size(idx); + datalen = idx->offset[idx->count] - 1; + + if (destlen < len) + CFF_ERROR("Not enough space available..."); + + *(dest++) = (card8) ((idx->count >> 8) & 0xff); + *(dest++) = (card8) (idx->count & 0xff); + + if (datalen < 0xffUL) { + idx->offsize = 1; + *(dest++) = 1; + for (i = 0; i <= idx->count; i++) { + *(dest++) = (card8) (idx->offset[i] & 0xff); + } + } else if (datalen < 0xffffUL) { + idx->offsize = 2; + *(dest++) = 2; + for (i = 0; i <= idx->count; i++) { + *(dest++) = (card8) ((idx->offset[i] >> 8) & 0xff); + *(dest++) = (card8) (idx->offset[i] & 0xff); + } + } else if (datalen < 0xffffffUL) { + idx->offsize = 3; + *(dest++) = 3; + for (i = 0; i <= idx->count; i++) { + *(dest++) = (card8) ((idx->offset[i] >> 16) & 0xff); + *(dest++) = (card8) ((idx->offset[i] >> 8) & 0xff); + *(dest++) = (card8) (idx->offset[i] & 0xff); + } + } else { + idx->offsize = 4; + *(dest++) = 4; + for (i = 0; i <= idx->count; i++) { + *(dest++) = (card8) ((idx->offset[i] >> 24) & 0xff); + *(dest++) = (card8) ((idx->offset[i] >> 16) & 0xff); + *(dest++) = (card8) ((idx->offset[i] >> 8) & 0xff); + *(dest++) = (card8) (idx->offset[i] & 0xff); + } + } + + memmove(dest, idx->data, idx->offset[idx->count] - 1); + + return len; +} + +@ @c +long cff_index_size(cff_index * idx) +{ + if (idx->count > 0) { + l_offset datalen; + + datalen = idx->offset[idx->count] - 1; + if (datalen < 0xffUL) { + idx->offsize = 1; + } else if (datalen < 0xffffUL) { + idx->offsize = 2; + } else if (datalen < 0xffffffUL) { + idx->offsize = 3; + } else { + idx->offsize = 4; + } + return (3 + (idx->offsize) * (idx->count + 1) + (long) datalen); + } else { + return 2; + } +} + +@ @c +cff_index *cff_new_index(card16 count) +{ + cff_index *idx; + + idx = xcalloc(1, sizeof(cff_index)); + idx->count = count; + idx->offsize = 0; + + if (count > 0) { + idx->offset = xcalloc((unsigned) (count + 1), sizeof(l_offset)); + (idx->offset)[0] = 1; + } else { + idx->offset = NULL; + } + idx->data = NULL; + + return idx; +} + + +@ @c +void cff_release_index(cff_index * idx) +{ + if (idx) { + xfree(idx->data); + xfree(idx->offset); + xfree(idx); + } +} + +@ @c +void cff_release_dict(cff_dict * dict) +{ + if (dict) { + if (dict->entries) { + int i; + for (i = 0; i < dict->count; i++) { + xfree((dict->entries)[i].values); + } + xfree(dict->entries); + } + xfree(dict); + } +} + + +@ @c +void cff_release_encoding(cff_encoding * encoding) +{ + if (encoding) { + switch (encoding->format & (~0x80)) { + case 0: + xfree(encoding->data.codes); + break; + case 1: + xfree(encoding->data.range1); + break; + default: + CFF_ERROR("Unknown Encoding format."); + } + if (encoding->format & 0x80) + xfree(encoding->supp); + xfree(encoding); + } +} + +@ @c +void cff_release_charsets(cff_charsets * charset) +{ + if (charset) { + switch (charset->format) { + case 0: + xfree(charset->data.glyphs); + break; + case 1: + xfree(charset->data.range1); + break; + case 2: + xfree(charset->data.range2); + break; + default: + break; + } + xfree(charset); + } +} + +@ @c +void cff_release_fdselect(cff_fdselect * fdselect) +{ + if (fdselect) { + if (fdselect->format == 0) { + xfree(fdselect->data.fds); + } else if (fdselect->format == 3) { + xfree(fdselect->data.ranges); + } + xfree(fdselect); + } +} + + +@ @c +void cff_close(cff_font * cff) +{ + card16 i; + + if (cff) { + xfree(cff->fontname); + if (cff->name) + cff_release_index(cff->name); + if (cff->topdict) + cff_release_dict(cff->topdict); + if (cff->string) + cff_release_index(cff->string); + if (cff->gsubr) + cff_release_index(cff->gsubr); + if (cff->encoding) + cff_release_encoding(cff->encoding); + if (cff->charsets) + cff_release_charsets(cff->charsets); + if (cff->fdselect) + cff_release_fdselect(cff->fdselect); + if (cff->cstrings) + cff_release_index(cff->cstrings); + if (cff->fdarray) { + for (i = 0; i < cff->num_fds; i++) { + if (cff->fdarray[i]) + cff_release_dict(cff->fdarray[i]); + } + xfree(cff->fdarray); + } + if (cff->private) { + for (i = 0; i < cff->num_fds; i++) { + if (cff->private[i]) + cff_release_dict(cff->private[i]); + } + xfree(cff->private); + } + if (cff->subrs) { + for (i = 0; i < cff->num_fds; i++) { + if (cff->subrs[i]) + cff_release_index(cff->subrs[i]); + } + xfree(cff->subrs); + } + if (cff->_string) + cff_release_index(cff->_string); + xfree(cff); + } + + return; +} + +@ @c +char *cff_get_name(cff_font * cff) +{ + char *fontname; + l_offset len; + cff_index *idx; + + idx = cff->name; + len = idx->offset[cff->index + 1] - idx->offset[cff->index]; + fontname = xmalloc((unsigned) (len + 1) * sizeof(char)); + memcpy(fontname, idx->data + idx->offset[cff->index] - 1, len); + fontname[len] = '\0'; + + return fontname; +} + + +@ @c +long cff_set_name(cff_font * cff, char *name) +{ + cff_index *idx; + + if (strlen(name) > 127) + CFF_ERROR("FontName string length too large..."); + + if (cff->name) + cff_release_index(cff->name); + + cff->name = idx = xcalloc(1, sizeof(cff_index)); + idx->count = 1; + idx->offsize = 1; + idx->offset = xmalloc(2 * sizeof(l_offset)); + (idx->offset)[0] = 1; + (idx->offset)[1] = strlen(name) + 1; + idx->data = xmalloc((unsigned) strlen(name) * sizeof(card8)); + memmove(idx->data, name, strlen(name)); /* no trailing |'\0'| */ + + return (long) (5 + strlen(name)); +} + +long cff_put_header(cff_font * cff, card8 * dest, long destlen) +{ + if (destlen < 4) + CFF_ERROR("Not enough space available..."); + + *(dest++) = cff->header_major; + *(dest++) = cff->header_minor; + *(dest++) = 4; /* Additional data in between header and + * Name INDEX ignored. + */ + /* We will set all offset (0) to four-byte integer. */ + *(dest++) = 4; + cff->header_offsize = 4; + + return 4; +} + +@ @c +#define CFF_PARSE_OK 0 +#define CFF_CFF_ERROR_PARSE_CFF_ERROR -1 +#define CFF_CFF_ERROR_STACK_OVERFLOW -2 +#define CFF_CFF_ERROR_STACK_UNDERFLOW -3 +#define CFF_CFF_ERROR_STACK_RANGECHECK -4 + +#define DICT_ENTRY_MAX 16 + +cff_dict *cff_new_dict(void) +{ + cff_dict *dict; + + dict = xcalloc(1, sizeof(cff_dict)); + dict->max = DICT_ENTRY_MAX; + dict->count = 0; + dict->entries = xcalloc((unsigned) dict->max, sizeof(cff_dict_entry)); + return dict; +} + +@ + +Operand stack: + only numbers are stored (as double) + +Operand types: + +number : double (integer or real) +boolean: stored as a number +SID : stored as a number +array : array of numbers +delta : array of numbers + +@c +#define CFF_DICT_STACK_LIMIT 64 +static int stack_top = 0; +static double arg_stack[CFF_DICT_STACK_LIMIT]; + +@ +CFF DICT encoding: +TODO: default values + +@c +#define CFF_LAST_DICT_OP1 22 +#define CFF_LAST_DICT_OP2 39 +#define CFF_LAST_DICT_OP (CFF_LAST_DICT_OP1 + CFF_LAST_DICT_OP2) + +static struct { + const char *opname; + int argtype; +} dict_operator[CFF_LAST_DICT_OP] = { + { + "version", CFF_TYPE_SID}, { + "Notice", CFF_TYPE_SID}, { + "FullName", CFF_TYPE_SID}, { + "FamilyName", CFF_TYPE_SID}, { + "Weight", CFF_TYPE_SID}, { + "FontBBox", CFF_TYPE_ARRAY}, { + "BlueValues", CFF_TYPE_DELTA}, { + "OtherBlues", CFF_TYPE_DELTA}, { + "FamilyBlues", CFF_TYPE_DELTA}, { + "FamilyOtherBlues", CFF_TYPE_DELTA}, { + "StdHW", CFF_TYPE_NUMBER}, { + "StdVW", CFF_TYPE_NUMBER}, { + NULL, -1}, /* first byte of two-byte operator */ + /* Top */ + { + "UniqueID", CFF_TYPE_NUMBER}, { + "XUID", CFF_TYPE_ARRAY}, { + "charset", CFF_TYPE_OFFSET}, { + "Encoding", CFF_TYPE_OFFSET}, { + "CharStrings", CFF_TYPE_OFFSET}, { + "Private", CFF_TYPE_SZOFF}, /* two numbers (size and offset) */ + /* Private */ + { + "Subrs", CFF_TYPE_OFFSET}, { + "defaultWidthX", CFF_TYPE_NUMBER}, { + "nominalWidthX", CFF_TYPE_NUMBER}, + /* Operator 2 */ + { + "Copyright", CFF_TYPE_SID}, { + "IsFixedPitch", CFF_TYPE_BOOLEAN}, { + "ItalicAngle", CFF_TYPE_NUMBER}, { + "UnderlinePosition", CFF_TYPE_NUMBER}, { + "UnderlineThickness", CFF_TYPE_NUMBER}, { + "PaintType", CFF_TYPE_NUMBER}, { + "CharstringType", CFF_TYPE_NUMBER}, { + "FontMatrix", CFF_TYPE_ARRAY}, { + "StrokeWidth", CFF_TYPE_NUMBER}, { + "BlueScale", CFF_TYPE_NUMBER}, { + "BlueShift", CFF_TYPE_NUMBER}, { + "BlueFuzz", CFF_TYPE_NUMBER}, { + "StemSnapH", CFF_TYPE_DELTA}, { + "StemSnapV", CFF_TYPE_DELTA}, { + "ForceBold", CFF_TYPE_BOOLEAN}, { + NULL, -1}, { + NULL, -1}, { + "LanguageGroup", CFF_TYPE_NUMBER}, { + "ExpansionFactor", CFF_TYPE_NUMBER}, { + "InitialRandomSeed", CFF_TYPE_NUMBER}, { + "SyntheticBase", CFF_TYPE_NUMBER}, { + "PostScript", CFF_TYPE_SID}, { + "BaseFontName", CFF_TYPE_SID}, { + "BaseFontBlend", CFF_TYPE_DELTA}, /* MMaster ? */ + { + NULL, -1}, { + NULL, -1}, { + NULL, -1}, { + NULL, -1}, { + NULL, -1}, { + NULL, -1}, + /* CID-Keyed font */ + { + "ROS", CFF_TYPE_ROS}, /* SID SID number */ + { + "CIDFontVersion", CFF_TYPE_NUMBER}, { + "CIDFontRevision", CFF_TYPE_NUMBER}, { + "CIDFontType", CFF_TYPE_NUMBER}, { + "CIDCount", CFF_TYPE_NUMBER}, { + "UIDBase", CFF_TYPE_NUMBER}, { + "FDArray", CFF_TYPE_OFFSET}, { + "FDSelect", CFF_TYPE_OFFSET}, { +"FontName", CFF_TYPE_SID},}; + +@ Parse DICT data +@c +static double get_integer(card8 ** data, card8 * endptr, int *status) +{ + long result = 0; + card8 b0, b1, b2; + + b0 = *(*data)++; + if (b0 == 28 && *data < endptr - 2) { /* shortint */ + b1 = *(*data)++; + b2 = *(*data)++; + result = b1 * 256 + b2; + if (result > 0x7fffL) + result -= 0x10000L; + } else if (b0 == 29 && *data < endptr - 4) { /* longint */ + int i; + result = *(*data)++; + if (result > 0x7f) + result -= 0x100; + for (i = 0; i < 3; i++) { + result = result * 256 + (**data); + *data += 1; + } + } else if (b0 >= 32 && b0 <= 246) { /* int (1) */ + result = b0 - 139; + } else if (b0 >= 247 && b0 <= 250) { /* int (2) */ + b1 = *(*data)++; + result = (b0 - 247) * 256 + b1 + 108; + } else if (b0 >= 251 && b0 <= 254) { + b1 = *(*data)++; + result = -(b0 - 251) * 256 - b1 - 108; + } else { + *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; + } + + return (double) result; +} + +@ Simply uses strtod +@c +static double get_real(card8 ** data, card8 * endptr, int *status) +{ + double result = 0.0; + int nibble = 0, pos = 0; + int len = 0, fail = 0; + + if (**data != 30 || *data >= endptr - 1) { + *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; + return 0.0; + } + + *data += 1; /* skip first byte (30) */ + + pos = 0; + while ((!fail) && len < WORK_BUFFER_SIZE - 2 && *data < endptr) { + /* get nibble */ + if (pos % 2) { + nibble = **data & 0x0f; + *data += 1; + } else { + nibble = (**data >> 4) & 0x0f; + } + if (nibble >= 0x00 && nibble <= 0x09) { + work_buffer[len++] = (char) (nibble + '0'); + } else if (nibble == 0x0a) { /* . */ + work_buffer[len++] = '.'; + } else if (nibble == 0x0b || nibble == 0x0c) { /* E, E- */ + work_buffer[len++] = 'e'; + if (nibble == 0x0c) + work_buffer[len++] = '-'; + } else if (nibble == 0x0e) { /* `-' */ + work_buffer[len++] = '-'; + } else if (nibble == 0x0d) { /* skip */ + /* do nothing */ + } else if (nibble == 0x0f) { /* end */ + work_buffer[len++] = '\0'; + if (((pos % 2) == 0) && (**data != 0xff)) { + fail = 1; + } + break; + } else { /* invalid */ + fail = 1; + } + pos++; + } + + /* returned values */ + if (fail || nibble != 0x0f) { + *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; + } else { + char *s; + result = strtod(work_buffer, &s); + if (*s != 0 || errno == ERANGE) { + *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; + } + } + + return result; +} + +@ operators +@c +static void add_dict(cff_dict * dict, + card8 ** data, card8 * endptr, int *status) +{ + int id, argtype, t; + + id = **data; + if (id == 0x0c) { + *data += 1; + if (*data >= endptr || + (id = **data + CFF_LAST_DICT_OP1) >= CFF_LAST_DICT_OP) { + *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; + return; + } + } else if (id >= CFF_LAST_DICT_OP1) { + *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; + return; + } + + argtype = dict_operator[id].argtype; + if (dict_operator[id].opname == NULL || argtype < 0) { + *status = CFF_CFF_ERROR_PARSE_CFF_ERROR; + return; + } + + if (dict->count >= dict->max) { + dict->max += DICT_ENTRY_MAX; + /* not zeroed! */ + dict->entries = + xrealloc(dict->entries, + (unsigned) ((unsigned) dict->max * + sizeof(cff_dict_entry))); + } + + (dict->entries)[dict->count].id = id; + (dict->entries)[dict->count].key = dict_operator[id].opname; + if (argtype == CFF_TYPE_NUMBER || + argtype == CFF_TYPE_BOOLEAN || + argtype == CFF_TYPE_SID || argtype == CFF_TYPE_OFFSET) { + /* check for underflow here, as exactly one operand is expected */ + if (stack_top < 1) { + *status = CFF_CFF_ERROR_STACK_UNDERFLOW; + return; + } + stack_top--; + (dict->entries)[dict->count].count = 1; + (dict->entries)[dict->count].values = xcalloc(1, sizeof(double)); + (dict->entries)[dict->count].values[0] = arg_stack[stack_top]; + dict->count += 1; + } else { + /* just ignore operator if there were no operands provided; + don't treat this as underflow (e.g. StemSnapV in TemporaLGCUni-Italic.otf) */ + if ((t = stack_top) > 0) { + (dict->entries)[dict->count].count = stack_top; + (dict->entries)[dict->count].values = + xmalloc((unsigned) ((unsigned) stack_top * sizeof(double))); + while (stack_top > 0) { + stack_top--; + (dict->entries)[dict->count].values[stack_top] = + arg_stack[stack_top]; + } + if (t > 3 && strcmp(dict_operator[id].opname, "FontMatrix") == 0) { + /* reset FontMatrix to [0.001 * * 0.001 * *], + fix mantis bug \# 0000200 (acroread "feature") */ + (dict->entries)[dict->count].values[0] = 0.001; + (dict->entries)[dict->count].values[3] = 0.001; + } + dict->count += 1; + } + } + + *data += 1; + + return; +} + + +@ All operands are treated as number or array of numbers. + Private: two numbers, size and offset + ROS : three numbers, SID, SID, and a number + +@c +cff_dict *cff_dict_unpack(card8 * data, card8 * endptr) +{ + cff_dict *dict; + int status = CFF_PARSE_OK; + + stack_top = 0; + + dict = cff_new_dict(); + while (data < endptr && status == CFF_PARSE_OK) { + if (*data < 22) { /* operator */ + add_dict(dict, &data, endptr, &status); + } else if (*data == 30) { /* real - First byte of a sequence (variable) */ + if (stack_top < CFF_DICT_STACK_LIMIT) { + arg_stack[stack_top] = get_real(&data, endptr, &status); + stack_top++; + } else { + status = CFF_CFF_ERROR_STACK_OVERFLOW; + } + } else if (*data == 255 || (*data >= 22 && *data <= 27)) { /* reserved */ + data++; + } else { /* everything else are integer */ + if (stack_top < CFF_DICT_STACK_LIMIT) { + arg_stack[stack_top] = get_integer(&data, endptr, &status); + stack_top++; + } else { + status = CFF_CFF_ERROR_STACK_OVERFLOW; + } + } + } + + if (status != CFF_PARSE_OK) { + pdftex_fail("Parsing CFF DICT failed. (error=%d)", status); + } else if (stack_top != 0) { + WARN("Garbage in CFF DICT data."); + stack_top = 0; + } + + return dict; +} + +@ @c +int cff_dict_known(cff_dict * dict, const char *key) +{ + int i; + + for (i = 0; i < dict->count; i++) { + if (key && strcmp(key, (dict->entries)[i].key) == 0 + && (dict->entries)[i].count > 0) + return 1; + } + + return 0; +} + +@ @c +double cff_dict_get(cff_dict * dict, const char *key, int idx) +{ + double value = 0.0; + int i; + + assert(key && dict); + + for (i = 0; i < dict->count; i++) { + if (strcmp(key, (dict->entries)[i].key) == 0) { + if ((dict->entries)[i].count > idx) + value = (dict->entries)[i].values[idx]; + else + pdftex_fail("Invalid index number."); + break; + } + } + + if (i == dict->count) + pdftex_fail("DICT entry \"%s\" not found.", key); + + return value; +} + +@ @c +card8 cff_fdselect_lookup(cff_font * cff, card16 gid) +{ + card8 fd = 0xff; + cff_fdselect *fdsel; + + if (cff->fdselect == NULL) + CFF_ERROR("in cff_fdselect_lookup(): FDSelect not available"); + + fdsel = cff->fdselect; + + if (gid >= cff->num_glyphs) + CFF_ERROR("in cff_fdselect_lookup(): Invalid glyph index"); + + switch (fdsel->format) { + case 0: + fd = fdsel->data.fds[gid]; + break; + case 3: + { + if (gid == 0) { + fd = (fdsel->data).ranges[0].fd; + } else { + card16 i; + for (i = 1; i < (fdsel->num_entries); i++) { + if (gid < (fdsel->data).ranges[i].first) + break; + } + fd = (fdsel->data).ranges[i - 1].fd; + } + } + break; + default: + CFF_ERROR("in cff_fdselect_lookup(): Invalid FDSelect format"); + break; + } + + if (fd >= cff->num_fds) + CFF_ERROR("in cff_fdselect_lookup(): Invalid Font DICT index"); + + return fd; +} + +@ @c +long cff_read_subrs(cff_font * cff) +{ + long len = 0; + long offset; + int i; + + + if ((cff->flag & FONTTYPE_CIDFONT) && cff->fdselect == NULL) { + cff_read_fdselect(cff); + } + + if ((cff->flag & FONTTYPE_CIDFONT) && cff->fdarray == NULL) { + cff_read_fdarray(cff); + } + + if (cff->private == NULL) + cff_read_private(cff); + + if (cff->gsubr == NULL) { + cff->offset = cff->gsubr_offset; + cff->gsubr = cff_get_index(cff); + } + + cff->subrs = xcalloc(cff->num_fds, sizeof(cff_index *)); + if (cff->flag & FONTTYPE_CIDFONT) { + for (i = 0; i < cff->num_fds; i++) { + if (cff->private[i] == NULL || + !cff_dict_known(cff->private[i], "Subrs")) { + (cff->subrs)[i] = NULL; + } else { + offset = (long) cff_dict_get(cff->fdarray[i], "Private", 1); + offset += (long) cff_dict_get(cff->private[i], "Subrs", 0); + cff->offset = (l_offset) offset; + (cff->subrs)[i] = cff_get_index(cff); + len += cff_index_size((cff->subrs)[i]); + } + } + } else { + if (cff->private[0] == NULL || + !cff_dict_known(cff->private[0], "Subrs")) { + (cff->subrs)[0] = NULL; + } else { + offset = (long) cff_dict_get(cff->topdict, "Private", 1); + offset += (long) cff_dict_get(cff->private[0], "Subrs", 0); + cff->offset = (l_offset) offset; + (cff->subrs)[0] = cff_get_index(cff); + len += cff_index_size((cff->subrs)[0]); + } + } + + return len; +} + + +@ @c +long cff_read_fdarray(cff_font * cff) +{ + long len = 0; + cff_index *idx; + long offset, size; + card16 i; + + if (cff->topdict == NULL) + CFF_ERROR("in cff_read_fdarray(): Top DICT not found"); + + if (!(cff->flag & FONTTYPE_CIDFONT)) + return 0; + + /* must exist */ + offset = (long) cff_dict_get(cff->topdict, "FDArray", 0); + cff->offset = (l_offset) offset; + idx = cff_get_index(cff); + cff->num_fds = (card8) idx->count; + cff->fdarray = xmalloc((unsigned) (idx->count * sizeof(cff_dict *))); + for (i = 0; i < idx->count; i++) { + card8 *data = idx->data + (idx->offset)[i] - 1; + size = (long) ((idx->offset)[i + 1] - (idx->offset)[i]); + if (size > 0) { + (cff->fdarray)[i] = cff_dict_unpack(data, data + size); + } else { + (cff->fdarray)[i] = NULL; + } + } + len = cff_index_size(idx); + cff_release_index(idx); + + return len; +} + + +@ @c +long cff_read_private(cff_font * cff) +{ + long len = 0; + card8 *data; + long offset, size; + + if (cff->flag & FONTTYPE_CIDFONT) { + int i; + + if (cff->fdarray == NULL) + cff_read_fdarray(cff); + + cff->private = xmalloc((unsigned) (cff->num_fds * sizeof(cff_dict *))); + for (i = 0; i < cff->num_fds; i++) { + if (cff->fdarray[i] != NULL && + cff_dict_known(cff->fdarray[i], "Private") && + (size = (long) cff_dict_get(cff->fdarray[i], "Private", 0)) + > 0) { + offset = (long) cff_dict_get(cff->fdarray[i], "Private", 1); + cff->offset = (l_offset) offset; + data = xmalloc((unsigned) size * sizeof(card8)); + memcpy(data, &cff->stream[cff->offset], (size_t) size); + cff->offset = (l_offset) size; + (cff->private)[i] = cff_dict_unpack(data, data + size); + xfree(data); + len += size; + } else { + (cff->private)[i] = NULL; + } + } + } else { + cff->num_fds = 1; + cff->private = xmalloc(sizeof(cff_dict *)); + if (cff_dict_known(cff->topdict, "Private") && + (size = (long) cff_dict_get(cff->topdict, "Private", 0)) > 0) { + offset = (long) cff_dict_get(cff->topdict, "Private", 1); + cff->offset = (l_offset) offset; + data = xmalloc((unsigned) size * sizeof(card8)); + memcpy(data, &cff->stream[cff->offset], (size_t) size); + cff->offset = (l_offset) size; + cff->private[0] = cff_dict_unpack(data, data + size); + xfree(data); + len += size; + } else { + (cff->private)[0] = NULL; + len = 0; + } + } + + return len; +} + + +@ @c +cff_font *read_cff(unsigned char *buf, long buflength, int n) +{ + cff_font *cff; + cff_index *idx; + long offset; + + + cff = xcalloc(1, sizeof(cff_font)); + + cff->stream = buf; + cff->stream_size = (l_offset) buflength; + cff->index = n; + + cff->header_major = get_card8(cff); + cff->header_minor = get_card8(cff); + cff->header_hdr_size = get_card8(cff); + cff->header_offsize = get_card8(cff); + if (cff->header_offsize < 1 || cff->header_offsize > 4) { + WARN("invalid offsize data"); + cff_close(cff); + return NULL; + } + if (cff->header_major > 1) { + pdftex_warn("CFF major version %u not supported.", cff->header_major); + cff_close(cff); + return NULL; + } + cff->offset = cff->header_hdr_size; + + /* Name INDEX */ + idx = cff_get_index(cff); + if (n > idx->count - 1) { + pdftex_warn("Invalid CFF fontset index number."); + cff_close(cff); + return NULL; + } + + cff->name = idx; + + cff->fontname = cff_get_name(cff); + + /* Top DICT INDEX */ + idx = cff_get_index(cff); + if (n > idx->count - 1) { + WARN("CFF Top DICT not exist..."); + cff_close(cff); + return NULL; + } + cff->topdict = cff_dict_unpack(idx->data + idx->offset[n] - 1, + idx->data + idx->offset[n + 1] - 1); + if (!cff->topdict) { + WARN("Parsing CFF Top DICT data failed..."); + cff_close(cff); + return NULL; + } + cff_release_index(idx); + + if (cff_dict_known(cff->topdict, "CharstringType") && + cff_dict_get(cff->topdict, "CharstringType", 0) != 2) { + WARN("Only Type 2 Charstrings supported..."); + cff_close(cff); + return NULL; + } + + if (cff_dict_known(cff->topdict, "SyntheticBase")) { + WARN("CFF Synthetic font not supported."); + cff_close(cff); + return NULL; + } + + /* String INDEX */ + cff->string = cff_get_index(cff); + + /* offset to GSubr */ + cff->gsubr_offset = cff->offset; + + /* Number of glyphs */ + offset = (long) cff_dict_get(cff->topdict, "CharStrings", 0); + cff->offset = (l_offset) offset; + cff->num_glyphs = get_card16(cff); + + /* Check for font type */ + if (cff_dict_known(cff->topdict, "ROS")) { + cff->flag |= FONTTYPE_CIDFONT; + } else { + cff->flag |= FONTTYPE_FONT; + } + + /* Check for encoding */ + if (cff_dict_known(cff->topdict, "Encoding")) { + offset = (long) cff_dict_get(cff->topdict, "Encoding", 0); + if (offset == 0) { /* predefined */ + cff->flag |= ENCODING_STANDARD; + } else if (offset == 1) { + cff->flag |= ENCODING_EXPERT; + } + } else { + cff->flag |= ENCODING_STANDARD; + } + + cff->offset = cff->gsubr_offset; /* seek back to GSubr */ + + return cff; +} + +@* write a cff for opentype. + +@ Pack DICT data +@c +static long pack_integer(card8 * dest, long destlen, long value) +{ + long len = 0; + + if (value >= -107 && value <= 107) { + if (destlen < 1) + CFF_ERROR("Buffer overflow."); + dest[0] = (card8) ((value + 139) & 0xff); + len = 1; + } else if (value >= 108 && value <= 1131) { + if (destlen < 2) + CFF_ERROR("Buffer overflow."); + value = (long) 0xf700u + value - 108; + dest[0] = (card8) ((value >> 8) & 0xff); + dest[1] = (card8) (value & 0xff); + len = 2; + } else if (value >= -1131 && value <= -108) { + if (destlen < 2) + CFF_ERROR("Buffer overflow."); + value = (long) 0xfb00u - value - 108; + dest[0] = (card8) ((value >> 8) & 0xff); + dest[1] = (card8) (value & 0xff); + len = 2; + } else if (value >= -32768 && value <= 32767) { /* shortint */ + if (destlen < 3) + CFF_ERROR("Buffer overflow."); + dest[0] = 28; + dest[1] = (card8) ((value >> 8) & 0xff); + dest[2] = (card8) (value & 0xff); + len = 3; + } else { /* longint */ + if (destlen < 5) + CFF_ERROR("Buffer overflow."); + dest[0] = 29; + dest[1] = (card8) ((value >> 24) & 0xff); + dest[2] = (card8) ((value >> 16) & 0xff); + dest[3] = (card8) ((value >> 8) & 0xff); + dest[4] = (card8) (value & 0xff); + len = 5; + } + return len; +} + +@ @c +static long pack_real(card8 * dest, long destlen, double value) +{ + long e; + int i = 0, pos = 2; +#define CFF_REAL_MAX_LEN 17 + + if (destlen < 2) + CFF_ERROR("Buffer overflow."); + + dest[0] = 30; + + if (value == 0.0) { + dest[1] = 0x0f; + return 2; + } + + if (value < 0.0) { + dest[1] = 0xe0; + value *= -1.0; + pos++; + } + + e = 0; + if (value >= 10.0) { + while (value >= 10.0) { + value /= 10.0; + e++; + } + } else if (value < 1.0) { + while (value < 1.0) { + value *= 10.0; + e--; + } + } + + sprintf(work_buffer, "%1.14g", value); + for (i = 0; i < CFF_REAL_MAX_LEN; i++) { + unsigned char ch = 0; + if (work_buffer[i] == '\0') { + break; + } else if (work_buffer[i] == '.') { + ch = 0x0a; + } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { + ch = (unsigned char) (work_buffer[i] - '0'); + } else { + CFF_ERROR("Invalid character."); + } + + if (destlen < pos / 2 + 1) + CFF_ERROR("Buffer overflow."); + + if (pos % 2) { + dest[pos / 2] = (card8) (dest[pos / 2] + ch); + } else { + dest[pos / 2] = (card8) (ch << 4); + } + pos++; + } + + if (e > 0) { + if (pos % 2) { + dest[pos / 2] = (card8) (dest[pos / 2] + 0x0b); + } else { + if (destlen < pos / 2 + 1) + CFF_ERROR("Buffer overflow."); + dest[pos / 2] = (card8) (0xb0); + } + pos++; + } else if (e < 0) { + if (pos % 2) { + dest[pos / 2] = (card8) (dest[pos / 2] + 0x0c); + } else { + if (destlen < pos / 2 + 1) + CFF_ERROR("Buffer overflow."); + dest[pos / 2] = (card8) (0xc0); + } + e *= -1; + pos++; + } + + if (e != 0) { + sprintf(work_buffer, "%ld", e); + for (i = 0; i < CFF_REAL_MAX_LEN; i++) { + unsigned char ch = 0; + if (work_buffer[i] == '\0') { + break; + } else if (work_buffer[i] == '.') { + ch = 0x0a; + } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { + ch = (unsigned char) (work_buffer[i] - '0'); + } else { + CFF_ERROR("Invalid character."); + } + + if (destlen < pos / 2 + 1) + CFF_ERROR("Buffer overflow."); + + if (pos % 2) { + dest[pos / 2] = (card8) (dest[pos / 2] + ch); + } else { + dest[pos / 2] = (card8) (ch << 4); + } + pos++; + } + } + + if (pos % 2) { + dest[pos / 2] = (card8) (dest[pos / 2] + 0x0f); + pos++; + } else { + if (destlen < pos / 2 + 1) + CFF_ERROR("Buffer overflow."); + dest[pos / 2] = (card8) (0xff); + pos += 2; + } + + return pos / 2; +} + +@ @c +static long cff_dict_put_number(double value, + card8 * dest, long destlen, int type) +{ + long len = 0; + double nearint; + + nearint = floor(value + 0.5); + /* set offset to longint */ + if (type == CFF_TYPE_OFFSET) { + long lvalue; + + lvalue = (long) value; + if (destlen < 5) + CFF_ERROR("Buffer overflow."); + dest[0] = 29; + dest[1] = (card8) ((lvalue >> 24) & 0xff); + dest[2] = (card8) ((lvalue >> 16) & 0xff); + dest[3] = (card8) ((lvalue >> 8) & 0xff); + dest[4] = (card8) (lvalue & 0xff); + len = 5; + } else if (value > CFF_INT_MAX || value < CFF_INT_MIN || (fabs(value - nearint) > 1.0e-5)) { /* real */ + len = pack_real(dest, destlen, value); + } else { /* integer */ + len = pack_integer(dest, destlen, (long) nearint); + } + + return len; +} + +@ @c +static long put_dict_entry(cff_dict_entry * de, card8 * dest, long destlen) +{ + long len = 0; + int i, type, id; + + if (de->count > 0) { + id = de->id; + if (dict_operator[id].argtype == CFF_TYPE_OFFSET || + dict_operator[id].argtype == CFF_TYPE_SZOFF) { + type = CFF_TYPE_OFFSET; + } else { + type = CFF_TYPE_NUMBER; + } + for (i = 0; i < de->count; i++) { + len += cff_dict_put_number(de->values[i], + dest + len, destlen - len, type); + } + if (id >= 0 && id < CFF_LAST_DICT_OP1) { + if (len + 1 > destlen) + CFF_ERROR("Buffer overflow."); + dest[len++] = (card8) id; + } else if (id >= 0 && id < CFF_LAST_DICT_OP) { + if (len + 2 > destlen) + CFF_ERROR("in cff_dict_pack(): Buffer overflow"); + dest[len++] = 12; + dest[len++] = (card8) (id - CFF_LAST_DICT_OP1); + } else { + CFF_ERROR("Invalid CFF DICT operator ID."); + } + } + + return len; +} + +@ @c +long cff_dict_pack(cff_dict * dict, card8 * dest, long destlen) +{ + long len = 0; + int i; + + for (i = 0; i < dict->count; i++) { + if (!strcmp(dict->entries[i].key, "ROS")) { + len += put_dict_entry(&dict->entries[i], dest, destlen); + break; + } + } + for (i = 0; i < dict->count; i++) { + if (strcmp(dict->entries[i].key, "ROS")) { + len += put_dict_entry(&dict->entries[i], dest + len, destlen - len); + } + } + + return len; +} + + +@ @c +void cff_dict_add(cff_dict * dict, const char *key, int count) +{ + int id, i; + + for (id = 0; id < CFF_LAST_DICT_OP; id++) { + if (key && dict_operator[id].opname && + strcmp(dict_operator[id].opname, key) == 0) + break; + } + + if (id == CFF_LAST_DICT_OP) + CFF_ERROR("Unknown CFF DICT operator."); + + for (i = 0; i < dict->count; i++) { + if ((dict->entries)[i].id == id) { + if ((dict->entries)[i].count != count) + CFF_ERROR("Inconsistent DICT argument number."); + return; + } + } + + if (dict->count + 1 >= dict->max) { + dict->max += 8; + dict->entries = + xrealloc(dict->entries, + (unsigned) ((unsigned) dict->max * + sizeof(cff_dict_entry))); + } + + (dict->entries)[dict->count].id = id; + (dict->entries)[dict->count].key = dict_operator[id].opname; + (dict->entries)[dict->count].count = count; + if (count > 0) { + (dict->entries)[dict->count].values = + xcalloc((unsigned) count, sizeof(double)); + } else { + (dict->entries)[dict->count].values = NULL; + } + dict->count += 1; + + return; +} + + +@ @c +void cff_dict_remove(cff_dict * dict, const char *key) +{ + int i; + for (i = 0; i < dict->count; i++) { + if (key && strcmp(key, (dict->entries)[i].key) == 0) { + (dict->entries)[i].count = 0; + xfree((dict->entries)[i].values); + } + } +} + +@ @c +void cff_dict_set(cff_dict * dict, const char *key, int idx, double value) +{ + int i; + + assert(dict && key); + + for (i = 0; i < dict->count; i++) { + if (strcmp(key, (dict->entries)[i].key) == 0) { + if ((dict->entries)[i].count > idx) + (dict->entries)[i].values[idx] = value; + else + CFF_ERROR("Invalid index number."); + break; + } + } + + if (i == dict->count) + pdftex_fail("DICT entry \"%s\" not found.", key); +} + + +@ Strings +@c +char *cff_get_string(cff_font * cff, s_SID id) +{ + char *result = NULL; + size_t len; + + if (id < CFF_STDSTR_MAX) { + len = strlen(cff_stdstr[id]); + result = xmalloc((unsigned) (len + 1) * sizeof(char)); + memcpy(result, cff_stdstr[id], len); + result[len] = '\0'; + } else if (cff && cff->string) { + cff_index *strings = cff->string; + id = (s_SID) (id - CFF_STDSTR_MAX); + if (id < strings->count) { + len = (strings->offset)[id + 1] - (strings->offset)[id]; + result = xmalloc((unsigned) (len + 1) * sizeof(char)); + memmove(result, strings->data + (strings->offset)[id] - 1, len); + result[len] = '\0'; + } + } + + return result; +} + +@ @c +long cff_get_sid(cff_font * cff, const char *str) +{ + card16 i; + + if (!cff || !str) + return -1; + + /* I search String INDEX first. */ + if (cff && cff->string) { + cff_index *idx = cff->string; + for (i = 0; i < idx->count; i++) { + if (strlen(str) == (idx->offset)[i + 1] - (idx->offset)[i] && + !memcmp(str, (idx->data) + (idx->offset)[i] - 1, strlen(str))) + return (i + CFF_STDSTR_MAX); + } + } + + for (i = 0; i < CFF_STDSTR_MAX; i++) { + if (!strcmp(str, cff_stdstr[i])) + return i; + } + + return -1; +} + + +@ @c +void cff_update_string(cff_font * cff) +{ + if (cff == NULL) + CFF_ERROR("CFF font not opened."); + + if (cff->string) + cff_release_index(cff->string); + cff->string = cff->_string; + cff->_string = NULL; +} + + +@ @c +s_SID cff_add_string(cff_font * cff, const char *str) +{ + card16 idx; + cff_index *strings; + l_offset offset, size; + + if (cff == NULL) + CFF_ERROR("CFF font not opened."); + + if (cff->_string == NULL) + cff->_string = cff_new_index(0); + strings = cff->_string; + + for (idx = 0; idx < strings->count; idx++) { + size = strings->offset[idx + 1] - strings->offset[idx]; + offset = strings->offset[idx]; + if (size == strlen(str) && + !memcmp(strings->data + offset - 1, str, strlen(str))) + return (s_SID) (idx + CFF_STDSTR_MAX); + } + + for (idx = 0; idx < CFF_STDSTR_MAX; idx++) { + if (cff_stdstr[idx] && !strcmp(cff_stdstr[idx], str)) + return idx; + } + offset = (strings->count > 0) ? strings->offset[strings->count] : 1; + strings->offset = + xrealloc(strings->offset, + (unsigned) (((unsigned) strings->count + + 2) * sizeof(l_offset))); + if (strings->count == 0) + strings->offset[0] = 1; + idx = strings->count; + strings->count = (card16) (strings->count + 1); + strings->offset[strings->count] = offset + strlen(str); + strings->data = + xrealloc(strings->data, + (unsigned) ((offset + strlen(str) - 1) * sizeof(card8))); + memcpy(strings->data + offset - 1, str, strlen(str)); + + return (s_SID) (idx + CFF_STDSTR_MAX); +} + + +@ @c +void cff_dict_update(cff_dict * dict, cff_font * cff) +{ + int i; + + for (i = 0; i < dict->count; i++) { + if ((dict->entries)[i].count > 0) { + char *str; + int id; + + id = (dict->entries)[i].id; + + if (dict_operator[id].argtype == CFF_TYPE_SID) { + str = cff_get_string(cff, (s_SID) (dict->entries)[i].values[0]); + (dict->entries)[i].values[0] = cff_add_string(cff, str); + xfree(str); + } else if (dict_operator[id].argtype == CFF_TYPE_ROS) { + str = cff_get_string(cff, (s_SID) (dict->entries)[i].values[0]); + (dict->entries)[i].values[0] = cff_add_string(cff, str); + xfree(str); + str = cff_get_string(cff, (s_SID) (dict->entries)[i].values[1]); + (dict->entries)[i].values[1] = cff_add_string(cff, str); + xfree(str); + } + + } + } +} + +@ charsets +@c +long cff_read_charsets(cff_font * cff) +{ + cff_charsets *charset; + long offset, length; + card16 count, i; + + if (cff->topdict == NULL) + CFF_ERROR("Top DICT not available"); + + if (!cff_dict_known(cff->topdict, "charset")) { + cff->flag |= CHARSETS_ISOADOBE; + cff->charsets = NULL; + return 0; + } + + offset = (long) cff_dict_get(cff->topdict, "charset", 0); + + if (offset == 0) { /* predefined */ + cff->flag |= CHARSETS_ISOADOBE; + cff->charsets = NULL; + return 0; + } else if (offset == 1) { + cff->flag |= CHARSETS_EXPERT; + cff->charsets = NULL; + return 0; + } else if (offset == 2) { + cff->flag |= CHARSETS_EXPSUB; + cff->charsets = NULL; + return 0; + } + + cff->offset = (l_offset) offset; + cff->charsets = charset = xcalloc(1, sizeof(cff_charsets)); + charset->format = get_card8(cff); + charset->num_entries = 0; + + count = (card16) (cff->num_glyphs - 1); + length = 1; + + /* Not sure. Not well documented. */ + switch (charset->format) { + case 0: + charset->num_entries = (card16) (cff->num_glyphs - 1); /* no .notdef */ + charset->data.glyphs = + xmalloc((unsigned) (charset->num_entries * sizeof(s_SID))); + length += (charset->num_entries) * 2; + for (i = 0; i < (charset->num_entries); i++) { + charset->data.glyphs[i] = get_card16(cff); + } + count = 0; + break; + case 1: + { + cff_range1 *ranges = NULL; + while (count > 0 && charset->num_entries < cff->num_glyphs) { + ranges = + xrealloc(ranges, + (unsigned) (((unsigned) charset->num_entries + + 1) * sizeof(cff_range1))); + ranges[charset->num_entries].first = get_card16(cff); + ranges[charset->num_entries].n_left = get_card8(cff); + count = (card16) (count - ranges[charset->num_entries].n_left + 1); /* no-overrap */ + charset->num_entries++; + charset->data.range1 = ranges; + } + length += (charset->num_entries) * 3; + } + break; + case 2: + { + cff_range2 *ranges = NULL; + while (count > 0 && charset->num_entries < cff->num_glyphs) { + ranges = + xrealloc(ranges, + (unsigned) (((unsigned) charset->num_entries + + 1) * sizeof(cff_range2))); + ranges[charset->num_entries].first = get_card16(cff); + ranges[charset->num_entries].n_left = get_card16(cff); + count = (card16) (count - (ranges[charset->num_entries].n_left + 1)); /* non-overrapping */ + charset->num_entries++; + } + charset->data.range2 = ranges; + length += (charset->num_entries) * 4; + } + break; + default: + xfree(charset); + CFF_ERROR("Unknown Charset format"); + break; + } + + if (count > 0) { + fprintf(stdout, "count=%d\n", count); + CFF_ERROR("Charset data possibly broken"); + } + + return length; +} + +@ @c +long cff_pack_charsets(cff_font * cff, card8 * dest, long destlen) +{ + long len = 0; + card16 i; + cff_charsets *charset; + + if (cff->flag & HAVE_STANDARD_CHARSETS || cff->charsets == NULL) + return 0; + + if (destlen < 1) + CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + + charset = cff->charsets; + + dest[len++] = charset->format; + switch (charset->format) { + case 0: + if (destlen < len + (charset->num_entries) * 2) + CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + for (i = 0; i < (charset->num_entries); i++) { + s_SID sid = (charset->data).glyphs[i]; /* or CID */ + dest[len++] = (card8) ((sid >> 8) & 0xff); + dest[len++] = (card8) (sid & 0xff); + } + break; + case 1: + { + if (destlen < len + (charset->num_entries) * 3) + CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + for (i = 0; i < (charset->num_entries); i++) { + dest[len++] = + (card8) (((charset->data).range1[i].first >> 8) & 0xff); + dest[len++] = (card8) ((charset->data).range1[i].first & 0xff); + dest[len++] = (card8) ((charset->data).range1[i].n_left); + } + } + break; + case 2: + { + if (destlen < len + (charset->num_entries) * 4) + CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + for (i = 0; i < (charset->num_entries); i++) { + dest[len++] = + (card8) (((charset->data).range2[i].first >> 8) & 0xff); + dest[len++] = (card8) ((charset->data).range2[i].first & 0xff); + dest[len++] = + (card8) (((charset->data).range2[i].n_left >> 8) & 0xff); + dest[len++] = (card8) ((charset->data).range2[i].n_left & 0xff); + } + } + break; + default: + CFF_ERROR("Unknown Charset format"); + break; + } + + return len; +} + + + +@* Type 2 Charstring support. + +Decode and encode Type 2 charstring + +All local/global subroutine calls in a given charstring is replace by the +content of subroutine charstrings. We do this because some PostScript RIP +may have problems with sparse subroutine array. Workaround for this is to +re-order subroutine array so that no gap appears in the subroutine array, +or put dummy charstrings that contains only `return' in the gap. However, +re-ordering of subroutine is rather difficult for Type 2 charstrings due +to the bias which depends on the total number of subroutines. Replacing +callgsubr/callsubr calls with the content of the corresponding subroutine +charstring may be more efficient than putting dummy subroutines in the +case of subsetted font. Adobe distiller seems doing same thing. + +And also note that subroutine numbers within subroutines can depend on the +content of operand stack as follows: + +\.{ ... l m callsubr << subr \#(m+bias): n add callsubr >> ...} + +I've not implemented the `random' operator which generates a pseudo-random +number in the range (0, 1] and push them into argument stack. +How pseudo-random sequences are generated is not documented in the Type 2 +charstring spec.. + + +@c +#define CS_TYPE2_DEBUG_STR "Type2 Charstring Parser" +#define CS_TYPE2_DEBUG 5 + +/* decoder/encoder status codes */ +#define CS_BUFFER_CFF_ERROR -3 +#define CS_STACK_CFF_ERROR -2 +#define CS_PARSE_CFF_ERROR -1 +#define CS_PARSE_OK 0 +#define CS_PARSE_END 1 +#define CS_SUBR_RETURN 2 +#define CS_CHAR_END 3 + +static int status = CS_PARSE_CFF_ERROR; + +#define DST_NEED(a,b) {if ((a) < (b)) { status = CS_BUFFER_CFF_ERROR ; return ; }} +#define SRC_NEED(a,b) {if ((a) < (b)) { status = CS_PARSE_CFF_ERROR ; return ; }} +#define NEED(a,b) {if ((a) < (b)) { status = CS_STACK_CFF_ERROR ; return ; }} + +/* hintmask and cntrmask need number of stem zones */ +static int num_stems = 0; +static int phase = 0; + +/* subroutine nesting */ +static int cs2_nest = 0; + +/* advance width */ +static int have_width = 0; +static double width = 0.0; + +@ + Standard Encoding Accented Characters: + Optional four arguments for endchar. See, CFF spec., p.35. + This is obsolete feature and is no longer supported. +@c +#if 0 +/* adx ady bchar achar endchar */ +static double seac[4] = { 0.0, 0.0, 0.0, 0.0 }; +#endif + +@ Operand stack and Transient array +@c +static int cs2_stack_top = 0; +static double cs2_arg_stack[CS_ARG_STACK_MAX]; +static double trn_array[CS_TRANS_ARRAY_MAX]; + +@ Type 2 CharString encoding +@c + +/* + 1-byte CharString operaotrs: + |cs_escape| is first byte of two-byte operator +*/ + +/* RESERVED 0 */ +#define cs_hstem 1 +/* RESERVED 2 */ +#define cs_vstem 3 +#define cs_vmoveto 4 +#define cs_rlineto 5 +#define cs_hlineto 6 +#define cs_vlineto 7 +#define cs_rrcurveto 8 +/* |cs_closepath| 9 : TYPE1 */ +#define cs_callsubr 10 +#define cs_return 11 +#define cs_escape 12 +/* |cs_hsbw| 13 : TYPE1 */ +#define cs_endchar 14 +/* RESERVED 15 */ +/* RESERVED 16 */ +/* RESERVED 17 */ +#define cs_hstemhm 18 +#define cs_hintmask 19 +#define cs_cntrmask 20 +#define cs_rmoveto 21 +#define cs_hmoveto 22 +#define cs_vstemhm 23 +#define cs_rcurveline 24 +#define cs_rlinecurve 25 +#define cs_vvcurveto 26 +#define cs_hhcurveto 27 +/* SHORTINT 28 : first byte of shortint*/ +#define cs_callgsubr 29 +#define cs_vhcurveto 30 +#define cs_hvcurveto 31 + +/* + 2-byte CharString operaotrs: + "dotsection" is obsoleted in Type 2 charstring. + */ + +#define cs_dotsection 0 +/* |cs_vstem3| 1 : TYPE1 */ +/* |cs_hstem3| 2 : TYPE1 */ +#define cs_and 3 +#define cs_or 4 +#define cs_not 5 +/* |cs_seac| 6 : TYPE1 */ +/* |cs_sbw| 7 : TYPE1 */ +/* RESERVED 8 */ +#define cs_abs 9 +#define cs_add 10 +#define cs_sub 11 +#define cs_div 12 +/* RESERVED 13 */ +#define cs_neg 14 +#define cs_eq 15 +/* |cs_callothersubr| 16 : TYPE1 */ +/* |cs_pop| 17 : TYPE1 */ +#define cs_drop 18 +/* RESERVED 19 */ +#define cs_put 20 +#define cs_get 21 +#define cs_ifelse 22 +#define cs_random 23 +#define cs_mul 24 +/* RESERVED 25 */ +#define cs_sqrt 26 +#define cs_dup 27 +#define cs_exch 28 +#define cs_index 29 +#define cs_roll 30 +/* |cs_setcurrentpoint| 31 : TYPE1 */ +/* RESERVED 32 */ +/* RESERVED 33 */ +#define cs_hflex 34 +#define cs_flex 35 +#define cs_hflex1 36 +#define cs_flex1 37 + +@ +|clear_stack()| put all operands sotred in operand stack to dest. +@c +static void clear_stack(card8 ** dest, card8 * limit) +{ + int i; + + for (i = 0; i < cs2_stack_top; i++) { + double value; + long ivalue; + value = cs2_arg_stack[i]; + /* Nearest integer value */ + ivalue = (long) floor(value + 0.5); + if (value >= 0x8000L || value <= (-0x8000L - 1)) { + /* + This number cannot be represented as a single operand. + We must use `a b mul ...' or `a c div' to represent large values. + */ + CFF_ERROR("Argument value too large. (This is bug)"); + } else if (fabs(value - (double) ivalue) > 3.0e-5) { + /* 16.16-bit signed fixed value */ + DST_NEED(limit, *dest + 5); + *(*dest)++ = 255; + ivalue = (long) floor(value); /* mantissa */ + *(*dest)++ = (card8) ((ivalue >> 8) & 0xff); + *(*dest)++ = (card8) (ivalue & 0xff); + ivalue = (long) ((value - (double) ivalue) * 0x10000l); /* fraction */ + *(*dest)++ = (card8) ((ivalue >> 8) & 0xff); + *(*dest)++ = (card8) (ivalue & 0xff); + /* Everything else are integers. */ + } else if (ivalue >= -107 && ivalue <= 107) { + DST_NEED(limit, *dest + 1); + *(*dest)++ = (card8) (ivalue + 139); + } else if (ivalue >= 108 && ivalue <= 1131) { + DST_NEED(limit, *dest + 2); + ivalue = (long) 0xf700u + ivalue - 108; + *(*dest)++ = (card8) ((ivalue >> 8) & 0xff); + *(*dest)++ = (card8) (ivalue & 0xff); + } else if (ivalue >= -1131 && ivalue <= -108) { + DST_NEED(limit, *dest + 2); + ivalue = (long) 0xfb00u - ivalue - 108; + *(*dest)++ = (card8) ((ivalue >> 8) & 0xff); + *(*dest)++ = (card8) (ivalue & 0xff); + } else if (ivalue >= -32768 && ivalue <= 32767) { /* shortint */ + DST_NEED(limit, *dest + 3); + *(*dest)++ = 28; + *(*dest)++ = (card8) ((ivalue >> 8) & 0xff); + *(*dest)++ = (card8) ((ivalue) & 0xff); + } else { /* Shouldn't come here */ + CFF_ERROR("Unexpected error."); + } + } + + cs2_stack_top = 0; /* clear stack */ + + return; +} + +@ + Single byte operators: + Path construction, Operator for finishing a path, Hint operators. + + phase: + \item 0: inital state + \item 1: hint declaration, first stack-clearing operator appeared + \item 2: in path construction + +@c +static void +do_operator1(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) +{ + card8 op = **data; + + *data += 1; + + switch (op) { + case cs_hstemhm: + case cs_vstemhm: + /* charstring may have hintmask if above operator have seen */ + case cs_hstem: + case cs_vstem: + if (phase == 0 && (cs2_stack_top % 2)) { + have_width = 1; + width = cs2_arg_stack[0]; + } + num_stems += cs2_stack_top / 2; + clear_stack(dest, limit); + DST_NEED(limit, *dest + 1); + *(*dest)++ = op; + phase = 1; + break; + case cs_hintmask: + case cs_cntrmask: + if (phase < 2) { + if (phase == 0 && (cs2_stack_top % 2)) { + have_width = 1; + width = cs2_arg_stack[0]; + } + num_stems += cs2_stack_top / 2; + } + clear_stack(dest, limit); + DST_NEED(limit, *dest + 1); + *(*dest)++ = op; + if (num_stems > 0) { + int masklen = (num_stems + 7) / 8; + DST_NEED(limit, *dest + masklen); + SRC_NEED(endptr, *data + masklen); + memmove(*dest, *data, (size_t) masklen); + *data += masklen; + *dest += masklen; + } + phase = 2; + break; + case cs_rmoveto: + if (phase == 0 && (cs2_stack_top % 2)) { + have_width = 1; + width = cs2_arg_stack[0]; + } + clear_stack(dest, limit); + DST_NEED(limit, *dest + 1); + *(*dest)++ = op; + phase = 2; + break; + case cs_hmoveto: + case cs_vmoveto: + if (phase == 0 && (cs2_stack_top % 2) == 0) { + have_width = 1; + width = cs2_arg_stack[0]; + } + clear_stack(dest, limit); + DST_NEED(limit, *dest + 1); + *(*dest)++ = op; + phase = 2; + break; + case cs_endchar: + if (cs2_stack_top == 1) { + have_width = 1; + width = cs2_arg_stack[0]; + clear_stack(dest, limit); + } else if (cs2_stack_top == 4 || cs2_stack_top == 5) { + WARN("\"seac\" character deprecated in Type 2 charstring."); + status = CS_PARSE_CFF_ERROR; + return; + } else if (cs2_stack_top > 0) { + WARN("Operand stack not empty."); + } + DST_NEED(limit, *dest + 1); + *(*dest)++ = op; + status = CS_CHAR_END; + break; + /* above oprators are candidate for first stack-clearing operator */ + case cs_rlineto: + case cs_hlineto: + case cs_vlineto: + case cs_rrcurveto: + case cs_rcurveline: + case cs_rlinecurve: + case cs_vvcurveto: + case cs_hhcurveto: + case cs_vhcurveto: + case cs_hvcurveto: + if (phase < 2) { + WARN("Broken Type 2 charstring."); + status = CS_PARSE_CFF_ERROR; + return; + } + clear_stack(dest, limit); + DST_NEED(limit, *dest + 1); + *(*dest)++ = op; + break; + /* all operotors above are stack-clearing operator */ + /* no output */ + case cs_return: + case cs_callgsubr: + case cs_callsubr: + CFF_ERROR("Unexpected call(g)subr/return"); + break; + default: + /* no-op ? */ + WARN("%s: Unknown charstring operator: 0x%02x", CS_TYPE2_DEBUG_STR, op); + status = CS_PARSE_CFF_ERROR; + break; + } + + return; +} + +@ + Double byte operators: + Flex, arithmetic, conditional, and storage operators. + + Following operators are not supported: + random: How random ? + +@c +static void +do_operator2(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) +{ + card8 op; + + *data += 1; + + SRC_NEED(endptr, *data + 1); + + op = **data; + *data += 1; + + switch (op) { + case cs_dotsection: /* deprecated */ + WARN("Operator \"dotsection\" deprecated in Type 2 charstring."); + status = CS_PARSE_CFF_ERROR; + return; + break; + case cs_hflex: + case cs_flex: + case cs_hflex1: + case cs_flex1: + if (phase < 2) { + WARN("%s: Broken Type 2 charstring.", CS_TYPE2_DEBUG_STR); + status = CS_PARSE_CFF_ERROR; + return; + } + clear_stack(dest, limit); + DST_NEED(limit, *dest + 2); + *(*dest)++ = cs_escape; + *(*dest)++ = op; + break; + /* all operator above are stack-clearing */ + /* no output */ + case cs_and: + NEED(cs2_stack_top, 2); + cs2_stack_top--; + if (cs2_arg_stack[cs2_stack_top] && cs2_arg_stack[cs2_stack_top - 1]) { + cs2_arg_stack[cs2_stack_top - 1] = 1.0; + } else { + cs2_arg_stack[cs2_stack_top - 1] = 0.0; + } + break; + case cs_or: + NEED(cs2_stack_top, 2); + cs2_stack_top--; + if (cs2_arg_stack[cs2_stack_top] || cs2_arg_stack[cs2_stack_top - 1]) { + cs2_arg_stack[cs2_stack_top - 1] = 1.0; + } else { + cs2_arg_stack[cs2_stack_top - 1] = 0.0; + } + break; + case cs_not: + NEED(cs2_stack_top, 1); + if (cs2_arg_stack[cs2_stack_top - 1]) { + cs2_arg_stack[cs2_stack_top - 1] = 0.0; + } else { + cs2_arg_stack[cs2_stack_top - 1] = 1.0; + } + break; + case cs_abs: + NEED(cs2_stack_top, 1); + cs2_arg_stack[cs2_stack_top - 1] = + fabs(cs2_arg_stack[cs2_stack_top - 1]); + break; + case cs_add: + NEED(cs2_stack_top, 2); + cs2_arg_stack[cs2_stack_top - 2] += cs2_arg_stack[cs2_stack_top - 1]; + cs2_stack_top--; + break; + case cs_sub: + NEED(cs2_stack_top, 2); + cs2_arg_stack[cs2_stack_top - 2] -= cs2_arg_stack[cs2_stack_top - 1]; + cs2_stack_top--; + break; + case cs_div: /* doesn't check overflow */ + NEED(cs2_stack_top, 2); + cs2_arg_stack[cs2_stack_top - 2] /= cs2_arg_stack[cs2_stack_top - 1]; + cs2_stack_top--; + break; + case cs_neg: + NEED(cs2_stack_top, 1); + cs2_arg_stack[cs2_stack_top - 1] *= -1.0; + break; + case cs_eq: + NEED(cs2_stack_top, 2); + cs2_stack_top--; + if (cs2_arg_stack[cs2_stack_top] == cs2_arg_stack[cs2_stack_top - 1]) { + cs2_arg_stack[cs2_stack_top - 1] = 1.0; + } else { + cs2_arg_stack[cs2_stack_top - 1] = 0.0; + } + break; + case cs_drop: + NEED(cs2_stack_top, 1); + cs2_stack_top--; + break; + case cs_put: + NEED(cs2_stack_top, 2); + { + int idx = (int) cs2_arg_stack[--cs2_stack_top]; + NEED(CS_TRANS_ARRAY_MAX, idx); + trn_array[idx] = cs2_arg_stack[--cs2_stack_top]; + } + break; + case cs_get: + NEED(cs2_stack_top, 1); + { + int idx = (int) cs2_arg_stack[cs2_stack_top - 1]; + NEED(CS_TRANS_ARRAY_MAX, idx); + cs2_arg_stack[cs2_stack_top - 1] = trn_array[idx]; + } + break; + case cs_ifelse: + NEED(cs2_stack_top, 4); + cs2_stack_top -= 3; + if (cs2_arg_stack[cs2_stack_top + 1] > cs2_arg_stack[cs2_stack_top + 2]) { + cs2_arg_stack[cs2_stack_top - 1] = cs2_arg_stack[cs2_stack_top]; + } + break; + case cs_mul: + NEED(cs2_stack_top, 2); + cs2_arg_stack[cs2_stack_top - 2] = + cs2_arg_stack[cs2_stack_top - 2] * cs2_arg_stack[cs2_stack_top - 1]; + cs2_stack_top--; + break; + case cs_sqrt: + NEED(cs2_stack_top, 1); + cs2_arg_stack[cs2_stack_top - 1] = + sqrt(cs2_arg_stack[cs2_stack_top - 1]); + break; + case cs_dup: + NEED(cs2_stack_top, 1); + NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); + cs2_arg_stack[cs2_stack_top] = cs2_arg_stack[cs2_stack_top - 1]; + cs2_stack_top++; + break; + case cs_exch: + NEED(cs2_stack_top, 2); + { + double save = cs2_arg_stack[cs2_stack_top - 2]; + cs2_arg_stack[cs2_stack_top - 2] = cs2_arg_stack[cs2_stack_top - 1]; + cs2_arg_stack[cs2_stack_top - 1] = save; + } + break; + case cs_index: + NEED(cs2_stack_top, 2); /* need two arguments at least */ + { + int idx = (int) cs2_arg_stack[cs2_stack_top - 1]; + if (idx < 0) { + cs2_arg_stack[cs2_stack_top - 1] = + cs2_arg_stack[cs2_stack_top - 2]; + } else { + NEED(cs2_stack_top, idx + 2); + cs2_arg_stack[cs2_stack_top - 1] = + cs2_arg_stack[cs2_stack_top - idx - 2]; + } + } + break; + case cs_roll: + NEED(cs2_stack_top, 2); + { + int N, J; + J = (int) cs2_arg_stack[--cs2_stack_top]; + N = (int) cs2_arg_stack[--cs2_stack_top]; + NEED(cs2_stack_top, N); + if (J > 0) { + J = J % N; + while (J-- > 0) { + double save = cs2_arg_stack[cs2_stack_top - 1]; + int i = cs2_stack_top - 1; + while (i > cs2_stack_top - N) { + cs2_arg_stack[i] = cs2_arg_stack[i - 1]; + i--; + } + cs2_arg_stack[i] = save; + } + } else { + J = (-J) % N; + while (J-- > 0) { + double save = cs2_arg_stack[cs2_stack_top - N]; + int i = cs2_stack_top - N; + while (i < cs2_stack_top - 1) { + cs2_arg_stack[i] = cs2_arg_stack[i + 1]; + i++; + } + cs2_arg_stack[i] = save; + } + } + } + break; + case cs_random: + WARN("%s: Charstring operator \"random\" found.", CS_TYPE2_DEBUG_STR); + NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); + cs2_arg_stack[cs2_stack_top++] = 1.0; + break; + default: + /* no-op ? */ + WARN("%s: Unknown charstring operator: 0x0c%02x", CS_TYPE2_DEBUG_STR, + op); + status = CS_PARSE_CFF_ERROR; + break; + } + + return; +} + +@ + integer: + exactly the same as the DICT encoding (except 29) +@c +static void cs2_get_integer(card8 ** data, card8 * endptr) +{ + long result = 0; + card8 b0 = **data, b1, b2; + + *data += 1; + + if (b0 == 28) { /* shortint */ + SRC_NEED(endptr, *data + 2); + b1 = **data; + b2 = *(*data + 1); + result = b1 * 256 + b2; + if (result > 0x7fff) + result -= 0x10000L; + *data += 2; + } else if (b0 >= 32 && b0 <= 246) { /* int (1) */ + result = b0 - 139; + } else if (b0 >= 247 && b0 <= 250) { /* int (2) */ + SRC_NEED(endptr, *data + 1); + b1 = **data; + result = (b0 - 247) * 256 + b1 + 108; + *data += 1; + } else if (b0 >= 251 && b0 <= 254) { + SRC_NEED(endptr, *data + 1); + b1 = **data; + result = -(b0 - 251) * 256 - b1 - 108; + *data += 1; + } else { + status = CS_PARSE_CFF_ERROR; + return; + } + + NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); + cs2_arg_stack[cs2_stack_top++] = (double) result; + + return; +} + +@ +Signed 16.16-bits fixed number for Type 2 charstring encoding +@c +static void get_fixed(card8 ** data, card8 * endptr) +{ + long ivalue; + double rvalue; + + *data += 1; + + SRC_NEED(endptr, *data + 4); + + ivalue = *(*data) * 0x100 + *(*data + 1); + rvalue = (double) ((ivalue > 0x7fffL) ? (ivalue - 0x10000L) : ivalue); + ivalue = *(*data + 2) * 0x100 + *(*data + 3); + rvalue += ((double) ivalue) / 0x10000L; + + NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); + cs2_arg_stack[cs2_stack_top++] = rvalue; + *data += 4; + + return; +} + +@ + Subroutines: + The bias for subroutine number is introduced in type 2 charstrings. + + subr: set to a pointer to the subroutine charstring. + len: set to the length of subroutine charstring. + |subr_idx|: CFF INDEX data that contains subroutines. + id: biased subroutine number. + +@c +static void get_subr(card8 ** subr, long *len, cff_index * subr_idx, long id) +{ + card16 count; + + if (subr_idx == NULL) + CFF_ERROR("%s: Subroutine called but no subroutine found.", + CS_TYPE2_DEBUG_STR); + + count = subr_idx->count; + + /* Adding bias number */ + if (count < 1240) { + id += 107; + } else if (count < 33900) { + id += 1131; + } else { + id += 32768; + } + + if (id > count) + CFF_ERROR("%s: Invalid Subr index: %ld (max=%u)", CS_TYPE2_DEBUG_STR, + id, count); + + *len = (long) ((subr_idx->offset)[id + 1] - (subr_idx->offset)[id]); + *subr = subr_idx->data + (subr_idx->offset)[id] - 1; + + return; +} + + +@ NOTE: + The Type 2 interpretation of a number encoded in five-bytes (those with + an initial byte value of 255) differs from how it is interpreted in the + Type 1 format. + +@c +static void +do_charstring(card8 ** dest, card8 * limit, + card8 ** data, card8 * endptr, + cff_index * gsubr_idx, cff_index * subr_idx) +{ + card8 b0 = 0, *subr; + long len; + + if (cs2_nest > CS_SUBR_NEST_MAX) + CFF_ERROR("%s: Subroutine nested too deeply.", CS_TYPE2_DEBUG_STR); + + cs2_nest++; + + while (*data < endptr && status == CS_PARSE_OK) { + b0 = **data; + if (b0 == 255) { /* 16-bit.16-bit fixed signed number */ + get_fixed(data, endptr); + } else if (b0 == cs_return) { + status = CS_SUBR_RETURN; + } else if (b0 == cs_callgsubr) { + if (cs2_stack_top < 1) { + status = CS_STACK_CFF_ERROR; + } else { + cs2_stack_top--; + get_subr(&subr, &len, gsubr_idx, + (long) cs2_arg_stack[cs2_stack_top]); + if (*dest + len > limit) + CFF_ERROR("%s: Possible buffer overflow.", + CS_TYPE2_DEBUG_STR); + do_charstring(dest, limit, &subr, subr + len, gsubr_idx, + subr_idx); + *data += 1; + } + } else if (b0 == cs_callsubr) { + if (cs2_stack_top < 1) { + status = CS_STACK_CFF_ERROR; + } else { + cs2_stack_top--; + get_subr(&subr, &len, subr_idx, + (long) cs2_arg_stack[cs2_stack_top]); + if (limit < *dest + len) + CFF_ERROR("%s: Possible buffer overflow.", + CS_TYPE2_DEBUG_STR); + do_charstring(dest, limit, &subr, subr + len, gsubr_idx, + subr_idx); + *data += 1; + } + } else if (b0 == cs_escape) { + do_operator2(dest, limit, data, endptr); + } else if (b0 < 32 && b0 != 28) { /* 19, 20 need mask */ + do_operator1(dest, limit, data, endptr); + } else if ((b0 <= 22 && b0 >= 27) || b0 == 31) { /* reserved */ + status = CS_PARSE_CFF_ERROR; /* not an error ? */ + } else { /* integer */ + cs2_get_integer(data, endptr); + } + } + + if (status == CS_SUBR_RETURN) { + status = CS_PARSE_OK; + } else if (status == CS_CHAR_END && *data < endptr) { + WARN("%s: Garbage after endchar.", CS_TYPE2_DEBUG_STR); + } else if (status < CS_PARSE_OK) { /* error */ + CFF_ERROR("%s: Parsing charstring failed: (status=%d, stack=%d)", + CS_TYPE2_DEBUG_STR, status, cs2_stack_top); + } + + cs2_nest--; + + return; +} + +@ @c +static void cs_parse_init(void) +{ + status = CS_PARSE_OK; + cs2_nest = 0; + phase = 0; + num_stems = 0; + cs2_stack_top = 0; +} + + +@ Not just copying... +@c +long +cs_copy_charstring(card8 * dst, long dstlen, + card8 * src, long srclen, + cff_index * gsubr, cff_index * subr, + double default_width, double nominal_width, cs_ginfo * ginfo) +{ + card8 *save = dst; + + cs_parse_init(); + + width = 0.0; + have_width = 0; + + /* expand call(g)subrs */ + do_charstring(&dst, dst + dstlen, &src, src + srclen, gsubr, subr); + + if (ginfo) { + ginfo->flags = 0; /* not used */ + if (have_width) { + ginfo->wx = nominal_width + width; + } else { + ginfo->wx = default_width; + } + } + + return (long) (dst - save); +} + +@* encodings. + +@ Encoding and Charset + +Encoding and Charset arrays always begin with GID = 1. + +@c +long cff_read_encoding(cff_font * cff) +{ + cff_encoding *encoding; + long offset, length; + card8 i; + + if (cff->topdict == NULL) { + CFF_ERROR("Top DICT data not found"); + } + + if (!cff_dict_known(cff->topdict, "Encoding")) { + cff->flag |= ENCODING_STANDARD; + cff->encoding = NULL; + return 0; + } + + offset = (long) cff_dict_get(cff->topdict, "Encoding", 0); + if (offset == 0) { /* predefined */ + cff->flag |= ENCODING_STANDARD; + cff->encoding = NULL; + return 0; + } else if (offset == 1) { + cff->flag |= ENCODING_EXPERT; + cff->encoding = NULL; + return 0; + } + + cff->offset = (l_offset) offset; + cff->encoding = encoding = xcalloc(1, sizeof(cff_encoding)); + encoding->format = get_card8(cff); + length = 1; + + switch (encoding->format & (~0x80)) { + case 0: + encoding->num_entries = get_card8(cff); + (encoding->data).codes = xmalloc(encoding->num_entries * sizeof(card8)); + for (i = 0; i < (encoding->num_entries); i++) { + (encoding->data).codes[i] = get_card8(cff); + } + length += encoding->num_entries + 1; + break; + case 1: + { + cff_range1 *ranges; + encoding->num_entries = get_card8(cff); + encoding->data.range1 = ranges + = xcalloc(encoding->num_entries, sizeof(cff_range1)); + for (i = 0; i < (encoding->num_entries); i++) { + ranges[i].first = get_card8(cff); + ranges[i].n_left = get_card8(cff); + } + length += (encoding->num_entries) * 2 + 1; + } + break; + default: + xfree(encoding); + CFF_ERROR("Unknown Encoding format"); + break; + } + + /* Supplementary data */ + if ((encoding->format) & 0x80) { + cff_map *map; + encoding->num_supps = get_card8(cff); + encoding->supp = map = xcalloc(encoding->num_supps, sizeof(cff_map)); + for (i = 0; i < (encoding->num_supps); i++) { + map[i].code = get_card8(cff); + map[i].glyph = get_card16(cff); /* SID */ + } + length += (encoding->num_supps) * 3 + 1; + } else { + encoding->num_supps = 0; + encoding->supp = NULL; + } + + return length; +} + +@ @c +long cff_pack_encoding(cff_font * cff, card8 * dest, long destlen) +{ + long len = 0; + cff_encoding *encoding; + card16 i; + + if (cff->flag & HAVE_STANDARD_ENCODING || cff->encoding == NULL) + return 0; + + if (destlen < 2) + CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + + encoding = cff->encoding; + + dest[len++] = encoding->format; + dest[len++] = encoding->num_entries; + switch (encoding->format & (~0x80)) { + case 0: + if (destlen < len + encoding->num_entries) + CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + for (i = 0; i < (encoding->num_entries); i++) { + dest[len++] = (encoding->data).codes[i]; + } + break; + case 1: + { + if (destlen < len + (encoding->num_entries) * 2) + CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + for (i = 0; i < (encoding->num_entries); i++) { + dest[len++] = (card8) ((encoding->data).range1[i].first & 0xff); + dest[len++] = (card8) ((encoding->data).range1[i].n_left); + } + } + break; + default: + CFF_ERROR("Unknown Encoding format"); + break; + } + + if ((encoding->format) & 0x80) { + if (destlen < len + (encoding->num_supps) * 3 + 1) + CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + dest[len++] = encoding->num_supps; + for (i = 0; i < (encoding->num_supps); i++) { + dest[len++] = (card8) ((encoding->supp)[i].code); + dest[len++] = (card8) (((encoding->supp)[i].glyph >> 8) & 0xff); + dest[len++] = (card8) ((encoding->supp)[i].glyph & 0xff); + } + } + + return len; +} + +@ CID-Keyed font specific +@c +long cff_read_fdselect(cff_font * cff) +{ + cff_fdselect *fdsel; + long offset, length; + card16 i; + + if (cff->topdict == NULL) + CFF_ERROR("Top DICT not available"); + + if (!(cff->flag & FONTTYPE_CIDFONT)) + return 0; + + offset = (long) cff_dict_get(cff->topdict, "FDSelect", 0); + cff->offset = (l_offset) offset; + cff->fdselect = fdsel = xcalloc(1, sizeof(cff_fdselect)); + fdsel->format = get_card8(cff); + + length = 1; + + switch (fdsel->format) { + case 0: + fdsel->num_entries = cff->num_glyphs; + (fdsel->data).fds = xmalloc(fdsel->num_entries * sizeof(card8)); + for (i = 0; i < (fdsel->num_entries); i++) { + (fdsel->data).fds[i] = get_card8(cff); + } + length += fdsel->num_entries; + break; + case 3: + { + cff_range3 *ranges; + fdsel->num_entries = get_card16(cff); + fdsel->data.ranges = ranges = + xcalloc(fdsel->num_entries, sizeof(cff_range3)); + for (i = 0; i < (fdsel->num_entries); i++) { + ranges[i].first = get_card16(cff); + ranges[i].fd = get_card8(cff); + } + if (ranges[0].first != 0) + CFF_ERROR("Range not starting with 0."); + if (cff->num_glyphs != get_card16(cff)) + CFF_ERROR("Sentinel value mismatched with number of glyphs."); + length += (fdsel->num_entries) * 3 + 4; + } + break; + default: + xfree(fdsel); + CFF_ERROR("Unknown FDSelect format."); + break; + } + + return length; +} + + +@ @c +long cff_pack_fdselect(cff_font * cff, card8 * dest, long destlen) +{ + cff_fdselect *fdsel; + long len = 0; + card16 i; + + if (cff->fdselect == NULL) + return 0; + + if (destlen < 1) + CFF_ERROR("in cff_pack_fdselect(): Buffur overflow"); + + fdsel = cff->fdselect; + + dest[len++] = fdsel->format; + switch (fdsel->format) { + case 0: + if (fdsel->num_entries != cff->num_glyphs) + CFF_ERROR("in cff_pack_fdselect(): Invalid data"); + if (destlen < len + fdsel->num_entries) + CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + for (i = 0; i < fdsel->num_entries; i++) { + dest[len++] = (fdsel->data).fds[i]; + } + break; + case 3: + { + if (destlen < len + 2) + CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + len += 2; + for (i = 0; i < (fdsel->num_entries); i++) { + if (destlen < len + 3) + CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + dest[len++] = + (card8) (((fdsel->data).ranges[i].first >> 8) & 0xff); + dest[len++] = (card8) ((fdsel->data).ranges[i].first & 0xff); + dest[len++] = (card8) ((fdsel->data).ranges[i].fd); + } + if (destlen < len + 2) + CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + dest[len++] = (card8) ((cff->num_glyphs >> 8) & 0xff); + dest[len++] = (card8) (cff->num_glyphs & 0xff); + dest[1] = (card8) (((len / 3 - 1) >> 8) & 0xff); + dest[2] = (card8) ((len / 3 - 1) & 0xff); + } + break; + default: + CFF_ERROR("Unknown FDSelect format."); + break; + } + + return len; +} + + + +@ Create an instance of embeddable font. + +@c +static void write_fontfile(PDF pdf, cff_font * cffont, char *fullname) +{ + cff_index *topdict, *fdarray, *private; + unsigned char *dest; + long destlen = 0, i, size; + long offset, topdict_offset, fdarray_offset; + + /* DICT sizes (offset set to long int) */ + topdict = cff_new_index(1); + fdarray = cff_new_index(cffont->num_fds); + private = cff_new_index(cffont->num_fds); + + cff_dict_remove(cffont->topdict, "UniqueID"); + cff_dict_remove(cffont->topdict, "XUID"); + cff_dict_remove(cffont->topdict, "Private"); /* some bad font may have */ + cff_dict_remove(cffont->topdict, "Encoding"); /* some bad font may have */ + + topdict->offset[1] = (l_offset) cff_dict_pack(cffont->topdict, + (card8 *) work_buffer, + WORK_BUFFER_SIZE) + 1; + for (i = 0; i < cffont->num_fds; i++) { + size = 0; + if (cffont->private && cffont->private[i]) { + size = cff_dict_pack(cffont->private[i], + (card8 *) work_buffer, WORK_BUFFER_SIZE); + if (size < 1) { /* Private had contained only Subr */ + cff_dict_remove(cffont->fdarray[i], "Private"); + } + } + (private->offset)[i + 1] = + (unsigned long) ((private->offset)[i] + (unsigned) size); + (fdarray->offset)[i + 1] = + (unsigned long) ((fdarray->offset)[i] + (unsigned) + cff_dict_pack(cffont->fdarray[i], + (card8 *) work_buffer, + WORK_BUFFER_SIZE)); + } + + destlen = 4; /* header size */ + destlen += cff_set_name(cffont, fullname); + destlen += cff_index_size(topdict); + destlen += cff_index_size(cffont->string); + destlen += cff_index_size(cffont->gsubr); + destlen += (cffont->charsets->num_entries) * 2 + 1; /* charset format 0 */ + destlen += (cffont->fdselect->num_entries) * 3 + 5; /* fdselect format 3 */ + destlen += cff_index_size(cffont->cstrings); + destlen += cff_index_size(fdarray); + destlen = (long) (destlen + (long) private->offset[private->count] - 1); /* Private is not INDEX */ + + dest = xcalloc((unsigned) destlen, sizeof(card8)); + + offset = 0; + /* Header */ + offset += cff_put_header(cffont, dest + offset, destlen - offset); + /* Name */ + offset += cff_pack_index(cffont->name, dest + offset, destlen - offset); + /* Top DICT */ + topdict_offset = offset; + offset += cff_index_size(topdict); + /* Strings */ + offset += cff_pack_index(cffont->string, dest + offset, destlen - offset); + /* Global Subrs */ + offset += cff_pack_index(cffont->gsubr, dest + offset, destlen - offset); + + /* charset */ + cff_dict_set(cffont->topdict, "charset", 0, (double) offset); + offset += cff_pack_charsets(cffont, dest + offset, destlen - offset); + + /* FDSelect */ + cff_dict_set(cffont->topdict, "FDSelect", 0, (double) offset); + offset += cff_pack_fdselect(cffont, dest + offset, destlen - offset); + + /* CharStrings */ + cff_dict_set(cffont->topdict, "CharStrings", 0, (double) offset); + offset += cff_pack_index(cffont->cstrings, + dest + offset, cff_index_size(cffont->cstrings)); + cff_release_index(cffont->cstrings); + cffont->cstrings = NULL; /* Charstrings cosumes huge memory */ + + /* FDArray and Private */ + cff_dict_set(cffont->topdict, "FDArray", 0, (double) offset); + fdarray_offset = offset; + offset += cff_index_size(fdarray); + + fdarray->data = + xcalloc((unsigned) (fdarray->offset[fdarray->count] - 1), + sizeof(card8)); + for (i = 0; i < cffont->num_fds; i++) { + size = (long) (private->offset[i + 1] - private->offset[i]); + if (cffont->private[i] && size > 0) { + cff_dict_pack(cffont->private[i], dest + offset, size); + cff_dict_set(cffont->fdarray[i], "Private", 0, (double) size); + cff_dict_set(cffont->fdarray[i], "Private", 1, (double) offset); + } + cff_dict_pack(cffont->fdarray[i], + fdarray->data + (fdarray->offset)[i] - 1, + (long) (fdarray->offset[fdarray->count] - 1)); + offset += size; + } + + cff_pack_index(fdarray, dest + fdarray_offset, cff_index_size(fdarray)); + cff_release_index(fdarray); + cff_release_index(private); + + /* Finally Top DICT */ + topdict->data = + xcalloc((unsigned) (topdict->offset[topdict->count] - 1), + sizeof(card8)); + cff_dict_pack(cffont->topdict, topdict->data, + (long) (topdict->offset[topdict->count] - 1)); + cff_pack_index(topdict, dest + topdict_offset, cff_index_size(topdict)); + cff_release_index(topdict); + + for (i = 0; i < offset; i++) + fb_putchar(pdf, dest[i]); + + xfree(dest); + return; +} + + +@ this block is used a few times +@c +#define DO_COPY_CHARSTRING() \ + if ((avl_find(fd->gl_tree,glyph) != NULL)) { \ + size = (long)(cs_idx->offset[code+1] - cs_idx->offset[code]); \ + if (size > CS_STR_LEN_MAX) { \ + pdftex_fail("Charstring too long: gid=%u, %ld bytes", code, size); \ + } \ + if (charstring_len + CS_STR_LEN_MAX >= max_len) { \ + max_len = (long)(charstring_len + 2 * CS_STR_LEN_MAX); \ + charstrings->data = xrealloc(charstrings->data, (unsigned)((unsigned)max_len*sizeof(card8))); \ + } \ + (charstrings->offset)[gid] = (unsigned)(charstring_len + 1); \ + cffont->offset= (l_offset)((unsigned)offset + (cs_idx->offset)[code] - 1); \ + memcpy(data,&cffont->stream[cffont->offset],(size_t)size); \ + charstring_len += cs_copy_charstring(charstrings->data + charstring_len, \ + max_len - charstring_len, \ + data, size, \ + cffont->gsubr, (cffont->subrs)[0], \ + default_width, nominal_width, NULL); \ + gid++; \ + } + +@ @c +void write_cff(PDF pdf, cff_font * cffont, fd_entry * fd) +{ + cff_index *charstrings, *cs_idx; + + long charstring_len, max_len; + long size, offset = 0; + + card8 *data; + card16 num_glyphs, cs_count, code, gid, last_cid; + + double nominal_width, default_width; + + char *fullname; + + glw_entry *glyph, *found; + struct avl_traverser t; + + fullname = xcalloc((unsigned) (8 + strlen(fd->fontname)), 1); + sprintf(fullname, "%s+%s", fd->subset_tag, fd->fontname); + + /* finish parsing the CFF */ + cff_read_private(cffont); + cff_read_subrs(cffont); + + /* + Widths + */ + if (cffont->private[0] && + cff_dict_known(cffont->private[0], "defaultWidthX")) { + default_width = + (double) cff_dict_get(cffont->private[0], "defaultWidthX", 0); + } else { + default_width = CFF_DEFAULTWIDTHX_DEFAULT; + } + if (cffont->private[0] && + cff_dict_known(cffont->private[0], "nominalWidthX")) { + nominal_width = + (double) cff_dict_get(cffont->private[0], "nominalWidthX", 0); + } else { + nominal_width = CFF_NOMINALWIDTHX_DEFAULT; + } + + num_glyphs = 0; + last_cid = 0; + glyph = xtalloc(1, glw_entry); + + /* insert notdef */ + glyph->id = 0; + if (avl_find(fd->gl_tree, glyph) == NULL) { + avl_insert(fd->gl_tree, glyph); + glyph = xtalloc(1, glw_entry); + } + + avl_t_init(&t, fd->gl_tree); + for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); + found != NULL; found = (glw_entry *) avl_t_next(&t)) { + if (found->id > last_cid) + last_cid = (card16) found->id; + num_glyphs++; + } + + { + cff_fdselect *fdselect; + + fdselect = xcalloc(1, sizeof(cff_fdselect)); + fdselect->format = 3; + fdselect->num_entries = 1; + fdselect->data.ranges = xcalloc(1, sizeof(cff_range3)); + fdselect->data.ranges[0].first = 0; + fdselect->data.ranges[0].fd = 0; + cffont->fdselect = fdselect; + } + + { + cff_charsets *charset; + + charset = xcalloc(1, sizeof(cff_charsets)); + charset->format = 0; + charset->num_entries = (card16) (num_glyphs - 1); + charset->data.glyphs = xcalloc(num_glyphs, sizeof(s_SID)); + + gid = 0; + + avl_t_init(&t, fd->gl_tree); + for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); + found != NULL; found = (glw_entry *) avl_t_next(&t)) { + if (found->id != 0) { + charset->data.glyphs[gid] = (s_SID) found->id; + gid++; + } + } + cffont->charsets = charset; + } + + cff_dict_add(cffont->topdict, "CIDCount", 1); + cff_dict_set(cffont->topdict, "CIDCount", 0, last_cid + 1); + + cffont->fdarray = xcalloc(1, sizeof(cff_dict *)); + cffont->fdarray[0] = cff_new_dict(); + cff_dict_add(cffont->fdarray[0], "FontName", 1); + cff_dict_set(cffont->fdarray[0], "FontName", 0, (double) cff_add_string(cffont, fullname)); /* FIXME: Skip XXXXXX+ */ + cff_dict_add(cffont->fdarray[0], "Private", 2); + cff_dict_set(cffont->fdarray[0], "Private", 0, 0.0); + cff_dict_set(cffont->fdarray[0], "Private", 0, 0.0); + /* FDArray - index offset, not known yet */ + cff_dict_add(cffont->topdict, "FDArray", 1); + cff_dict_set(cffont->topdict, "FDArray", 0, 0.0); + /* FDSelect - offset, not known yet */ + cff_dict_add(cffont->topdict, "FDSelect", 1); + cff_dict_set(cffont->topdict, "FDSelect", 0, 0.0); + + cff_dict_remove(cffont->topdict, "UniqueID"); + cff_dict_remove(cffont->topdict, "XUID"); + cff_dict_remove(cffont->topdict, "Private"); + cff_dict_remove(cffont->topdict, "Encoding"); + + cffont->offset = (l_offset) cff_dict_get(cffont->topdict, "CharStrings", 0); + cs_idx = cff_get_index_header(cffont); + + offset = (long) cffont->offset; + cs_count = cs_idx->count; + if (cs_count < 2) { + CFF_ERROR("No valid charstring data found."); + } + + /* build the new charstrings entry */ + charstrings = cff_new_index((card16) (cs_count + 1)); + max_len = 2 * CS_STR_LEN_MAX; + charstrings->data = xcalloc((unsigned) max_len, sizeof(card8)); + charstring_len = 0; + + gid = 0; + data = xcalloc(CS_STR_LEN_MAX, sizeof(card8)); + + { + int i; + for (i = 0; i < cs_count; i++) { + code = (card16) i; + glyph->id = code; + DO_COPY_CHARSTRING(); + } + } + + /* this happens if the internal metrics do not agree with the actual disk font */ + if (gid < num_glyphs) { + WARN("embedded subset is smaller than expected: %d instead of %d glyphs.", gid, num_glyphs); + num_glyphs = gid; + } + + xfree(data); + cff_release_index(cs_idx); + + (charstrings->offset)[num_glyphs] = (l_offset) (charstring_len + 1); + charstrings->count = num_glyphs; + cffont->num_glyphs = num_glyphs; + cffont->cstrings = charstrings; + + /* + We don't use subroutines at all. + */ + if (cffont->gsubr) + cff_release_index(cffont->gsubr); + cffont->gsubr = cff_new_index(0); + + if (cffont->subrs && cffont->subrs[0]) + cff_release_index(cffont->subrs[0]); + cffont->subrs[0] = NULL; + + if (cffont->private && (cffont->private)[0]) { + cff_dict_remove((cffont->private)[0], "Subrs"); /* no Subrs */ + } + + cff_add_string(cffont, "Adobe"); + cff_add_string(cffont, "Identity"); + + cff_dict_update(cffont->topdict, cffont); + cff_dict_update(cffont->private[0], cffont); + cff_update_string(cffont); + + /* CFF code need to be rewrote... */ + cff_dict_add(cffont->topdict, "ROS", 3); + cff_dict_set(cffont->topdict, "ROS", 0, + (double) cff_get_sid(cffont, "Adobe")); + cff_dict_set(cffont->topdict, "ROS", 1, + (double) cff_get_sid(cffont, "Identity")); + cff_dict_set(cffont->topdict, "ROS", 2, 0.0); + + write_fontfile(pdf, cffont, fullname); + xfree(fullname); + cff_close(cffont); + +} + +@ @c +#undef ERROR /* for mingw */ +#define ERROR(a) { perror(a); return 0; } + +@ Input : SID or CID (16-bit unsigned int) + Output: glyph index + +@c +card16 cff_charsets_lookup(cff_font * cff, card16 cid) +{ + card16 gid = 0; + cff_charsets *charset; + card16 i; + + if (cff->flag & (CHARSETS_ISOADOBE | CHARSETS_EXPERT | CHARSETS_EXPSUB)) { + ERROR("Predefined CFF charsets not supported yet"); + } else if (cff->charsets == NULL) { + ERROR("Charsets data not available"); + } + + if (cid == 0) { + return 0; /* GID 0 (.notdef) */ + } + + charset = cff->charsets; + + gid = 0; + switch (charset->format) { + case 0: + for (i = 0; i < charset->num_entries; i++) { + if (cid == charset->data.glyphs[i]) { + gid = (card16) (i + 1); + return gid; + } + } + break; + case 1: + for (i = 0; i < charset->num_entries; i++) { + if (cid >= charset->data.range1[i].first && + cid <= + charset->data.range1[i].first + + charset->data.range1[i].n_left) { + gid = (card16) (gid + cid - charset->data.range1[i].first + 1); + return gid; + } + gid = (card16) (gid + charset->data.range1[i].n_left + 1); + } + break; + case 2: + for (i = 0; i < charset->num_entries; i++) { + if (cid >= charset->data.range2[i].first && + cid <= + charset->data.range2[i].first + + charset->data.range2[i].n_left) { + gid = (card16) (gid + cid - charset->data.range2[i].first + 1); + return gid; + } + gid = (card16) (gid + charset->data.range2[i].n_left + 1); + } + break; + default: + ERROR("Unknown Charset format"); + } + + return 0; /* not found */ +} + + +@ @c +#define is_cidfont(a) ((a)->flag & FONTTYPE_CIDFONT) +#define CID_MAX 65535 + +void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd) +{ + cff_index *charstrings, *cs_idx; + + long charstring_len, max_len; + long size, offset = 0; + + card8 *data; + card16 num_glyphs, cs_count, gid, last_cid; + + + int fdsel, prev_fd, cid_count, cid; + char *fullname; + + glw_entry *glyph; + + unsigned char *CIDToGIDMap = NULL; + + cff_fdselect *fdselect = NULL; + cff_charsets *charset = NULL; + + + if (!is_cidfont(cffont)) { + perror("Not a CIDfont."); + return; + } + + fullname = xcalloc((unsigned) (8 + strlen(fd->fontname)), 1); + sprintf(fullname, "%s+%s", fd->subset_tag, fd->fontname); + + /* finish parsing the CFF */ + + if (cff_dict_known(cffont->topdict, "CIDCount")) { + cid_count = (card16) cff_dict_get(cffont->topdict, "CIDCount", 0); + } else { + cid_count = CFF_CIDCOUNT_DEFAULT; + } + cff_read_charsets(cffont); + CIDToGIDMap = xmalloc((unsigned) + ((2 * (unsigned) cid_count) * sizeof(unsigned char))); + memset(CIDToGIDMap, 0, (size_t) (2 * cid_count)); + + + glyph = xtalloc(1, glw_entry); + /* insert notdef */ + glyph->id = 0; + if (avl_find(fd->gl_tree, glyph) == NULL) { + avl_insert(fd->gl_tree, glyph); + glyph = xtalloc(1, glw_entry); + } + + cid = 0; + last_cid = 0; + num_glyphs = 0; + for (cid = 0; cid <= CID_MAX; cid++) { + glyph->id = (unsigned) cid; + if (avl_find(fd->gl_tree, glyph) != NULL) { + gid = (card16) cff_charsets_lookup(cffont, (card16) cid); + CIDToGIDMap[2 * cid] = (unsigned char) ((gid >> 8) & 0xff); + CIDToGIDMap[2 * cid + 1] = (unsigned char) (gid & 0xff); + last_cid = (card16) cid; + num_glyphs++; + } + } + + cff_read_fdselect(cffont); + cff_read_fdarray(cffont); + cff_read_private(cffont); + + cff_read_subrs(cffont); + + + cffont->offset = (l_offset) cff_dict_get(cffont->topdict, "CharStrings", 0); + cs_idx = cff_get_index_header(cffont); + + offset = (long) cffont->offset; + cs_count = cs_idx->count; + if (cs_count < 2) { + CFF_ERROR("No valid charstring data found."); + } + + charset = xcalloc(1, sizeof(cff_charsets)); + charset->format = 0; + charset->num_entries = 0; + charset->data.glyphs = xcalloc(num_glyphs, sizeof(s_SID)); + + fdselect = xcalloc(1, sizeof(cff_fdselect)); + fdselect->format = 3; + fdselect->num_entries = 0; + fdselect->data.ranges = xcalloc(num_glyphs, sizeof(cff_range3)); + + charstrings = cff_new_index((card16) (cs_count + 1)); + max_len = 2 * CS_STR_LEN_MAX; + charstrings->data = xcalloc((unsigned) max_len, sizeof(card8)); + charstring_len = 0; + + prev_fd = -1; + gid = 0; + data = xcalloc(CS_STR_LEN_MAX, sizeof(card8)); + for (cid = 0; cid <= last_cid; cid++) { + unsigned short gid_org; + + glyph->id = (unsigned) cid; + if (avl_find(fd->gl_tree, glyph) == NULL) + continue; + + gid_org = + (short unsigned) ((CIDToGIDMap[2 * cid] << 8) | + (CIDToGIDMap[2 * cid + 1])); + size = (long) (cs_idx->offset[gid_org + 1] - cs_idx->offset[gid_org]); + if (size > CS_STR_LEN_MAX) { + pdftex_fail("Charstring too long: gid=%u, %ld bytes", cid, size); + } + if (charstring_len + CS_STR_LEN_MAX >= max_len) { + max_len = charstring_len + 2 * CS_STR_LEN_MAX; + charstrings->data = + xrealloc(charstrings->data, + (unsigned) ((unsigned) max_len * sizeof(card8))); + } + (charstrings->offset)[gid] = (l_offset) (charstring_len + 1); + cffont->offset = + (l_offset) ((unsigned) offset + (cs_idx->offset)[gid_org] - 1); + memcpy(data, &cffont->stream[cffont->offset], (size_t) size); + fdsel = cff_fdselect_lookup(cffont, gid_org); + charstring_len += cs_copy_charstring(charstrings->data + charstring_len, + max_len - charstring_len, + data, size, + cffont->gsubr, + (cffont->subrs)[fdsel], 0, 0, + NULL); + + if (cid > 0 && gid_org > 0) { + charset->data.glyphs[charset->num_entries] = (s_SID) cid; + charset->num_entries++; + } + if (fdsel != prev_fd) { + fdselect->data.ranges[fdselect->num_entries].first = gid; + fdselect->data.ranges[fdselect->num_entries].fd = (card8) fdsel; + fdselect->num_entries++; + prev_fd = fdsel; + } + gid++; + } + + if (gid != num_glyphs) + CFF_ERROR("Unexpected error: %i != %i", gid, num_glyphs); + xfree(data); + cff_release_index(cs_idx); + + xfree(CIDToGIDMap); + + (charstrings->offset)[num_glyphs] = (l_offset) (charstring_len + 1); + charstrings->count = num_glyphs; + cffont->num_glyphs = num_glyphs; + cffont->cstrings = charstrings; + + cff_release_charsets(cffont->charsets); + cffont->charsets = charset; + cff_release_fdselect(cffont->fdselect); + cffont->fdselect = fdselect; + + /* + * We don't use subroutines at all. + */ + if (cffont->gsubr) + cff_release_index(cffont->gsubr); + cffont->gsubr = cff_new_index(0); + + for (fdsel = 0; fdsel < cffont->num_fds; fdsel++) { + if (cffont->subrs && cffont->subrs[fdsel]) { + cff_release_index(cffont->subrs[fdsel]); + cffont->subrs[fdsel] = NULL; + } + if (cffont->private && (cffont->private)[fdsel]) { + cff_dict_remove((cffont->private)[fdsel], "Subrs"); /* no Subrs */ + } + } + + write_fontfile(pdf, cffont, fullname); + xfree(fullname); + cff_close(cffont); + +} + +@ here is a sneaky trick: fontforge knows how to convert Type1 to CFF, so +I have defined a utility function in luafflib.c that does exactly that. +If it works out ok, I will clean up this code. + +@c +void writetype1w(PDF pdf, fd_entry * fd) +{ + cff_font *cff; + int i; + FILE *fp; + ff_entry *ff; + unsigned char *tfm_buffer = NULL; + int tfm_size = 0; + + ff = check_ff_exist(fd->fm->ff_name, 0); + + fp = fopen(ff->ff_path, "rb"); + cur_file_name = ff->ff_path; + + if (!fp) { + fprintf(stderr, "Type1: Could not open Type1 font: %s", cur_file_name); + uexit(1); + } + fclose(fp); + + if (tracefilenames) { + if (is_subsetted(fd->fm)) + tex_printf("<%s", cur_file_name); + else + tex_printf("<<%s", cur_file_name); + } + + (void) ff_createcff(ff->ff_path, &tfm_buffer, &tfm_size); + + if (tfm_size > 0) { + cff = read_cff(tfm_buffer, tfm_size, 0); + if (cff != NULL) { + write_cff(pdf, cff, fd); + } else { + for (i = 0; i < tfm_size; i++) + fb_putchar(pdf, tfm_buffer[i]); + } + fd->ff_found = 1; + } else { + fprintf(stderr, "Type1: Could not understand Type1 font: %s", + cur_file_name); + uexit(1); + } + if (tracefilenames) { + if (is_subsetted(fd->fm)) + tex_printf(">"); + else + tex_printf(">>"); + } + cur_file_name = NULL; +} diff --git a/Build/source/texk/web2c/luatexdir/font/writeenc.c b/Build/source/texk/web2c/luatexdir/font/writeenc.c deleted file mode 100644 index e0cd7bc43a0..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writeenc.c +++ /dev/null @@ -1,187 +0,0 @@ -/* writeenc.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "inc-epdf.h" - -static const char _svn_version[] = - "$Id: writeenc.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writeenc.c $"; - -/**********************************************************************/ -/* All encoding entries go into AVL tree for fast search by name. */ - -struct avl_table *fe_tree = NULL; - -/* AVL sort fe_entry into fe_tree by name */ - -static int comp_fe_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(((const fe_entry *) pa)->name, ((const fe_entry *) pb)->name); -} - -static fe_entry *new_fe_entry(void) -{ - fe_entry *fe; - fe = xtalloc(1, fe_entry); - fe->name = NULL; - fe->fe_objnum = 0; - fe->glyph_names = NULL; /* encoding file not yet read in */ - fe->tx_tree = NULL; - return fe; -} - -static fe_entry *lookup_fe_entry(char *s) -{ - fe_entry fe; - assert(s != NULL); - fe.name = s; - if (fe_tree == NULL) { - fe_tree = avl_create(comp_fe_entry, NULL, &avl_xallocator); - assert(fe_tree != NULL); - } - return (fe_entry *) avl_find(fe_tree, &fe); -} - -static void register_fe_entry(fe_entry * fe) -{ - void **aa; - if (fe_tree == NULL) { - fe_tree = avl_create(comp_fe_entry, NULL, &avl_xallocator); - assert(fe_tree != NULL); - } - assert(fe != NULL); - assert(fe->name != NULL); - assert(lookup_fe_entry(fe->name) == NULL); /* encoding not yet registered */ - aa = avl_probe(fe_tree, fe); - assert(aa != NULL); -} - -fe_entry *get_fe_entry(char *s) -{ - fe_entry *fe; - char **gl; - if ((fe = lookup_fe_entry(s)) == NULL && (gl = load_enc_file(s)) != NULL) { - fe = new_fe_entry(); - fe->name = s; - fe->glyph_names = gl; - register_fe_entry(fe); - } - return fe; -} - -/**********************************************************************/ - -void epdf_write_enc(char **glyph_names, integer fe_objnum) -{ - int i, i_old; - assert(glyph_names != NULL); - assert(fe_objnum != 0); - pdf_begin_dict(fe_objnum, 1); - pdf_puts("/Type /Encoding\n"); - pdf_puts("/Differences ["); - for (i = 0, i_old = -2; i < 256; i++) - if (glyph_names[i] != notdef) { - if (i == i_old + 1) /* no gap */ - pdf_printf("/%s", glyph_names[i]); - else { - if (i_old == -2) - pdf_printf("%i/%s", i, glyph_names[i]); - else - pdf_printf(" %i/%s", i, glyph_names[i]); - } - i_old = i; - } - pdf_puts("]\n"); - pdf_end_dict(); -} - -static void write_enc(char **glyph_names, struct avl_table *tx_tree, integer fe_objnum) -{ - int i_old, *p; - struct avl_traverser t; - assert(glyph_names != NULL); - assert(tx_tree != NULL); - assert(fe_objnum != 0); - pdf_begin_dict(fe_objnum, 1); - pdf_puts("/Type /Encoding\n"); - pdf_puts("/Differences ["); - avl_t_init(&t, tx_tree); - for (i_old = -2, p = (int *) avl_t_first(&t, tx_tree); p != NULL; - p = (int *) avl_t_next(&t)) { - if (*p == i_old + 1) /* no gap */ - pdf_printf("/%s", glyph_names[*p]); - else { - if (i_old == -2) - pdf_printf("%i/%s", *p, glyph_names[*p]); - else - pdf_printf(" %i/%s", *p, glyph_names[*p]); - } - i_old = *p; - } - pdf_puts("]\n"); - pdf_end_dict(); -} - -static void write_fontencoding(fe_entry * fe) -{ - assert(fe != NULL); - write_enc(fe->glyph_names, fe->tx_tree, fe->fe_objnum); -} - -void write_fontencodings(void) -{ - fe_entry *fe; - struct avl_traverser t; - if (fe_tree == NULL) - return; - avl_t_init(&t, fe_tree); - for (fe = (fe_entry *) avl_t_first(&t, fe_tree); fe != NULL; - fe = (fe_entry *) avl_t_next(&t)) - if (fe->fe_objnum != 0) - write_fontencoding(fe); -} - -/**********************************************************************/ -/* cleaning up... */ - -static void destroy_fe_entry(void *pa, void *pb) -{ - fe_entry *p; - int i; - (void) pb; - p = (fe_entry *) pa; - xfree(p->name); - if (p->glyph_names != NULL) - for (i = 0; i < 256; i++) - if (p->glyph_names[i] != notdef) - xfree(p->glyph_names[i]); - xfree(p->glyph_names); - xfree(p); -} - -void enc_free(void) -{ - if (fe_tree != NULL) - avl_destroy(fe_tree, destroy_fe_entry); - fe_tree = NULL; -} - -/**********************************************************************/ diff --git a/Build/source/texk/web2c/luatexdir/font/writeenc.w b/Build/source/texk/web2c/luatexdir/font/writeenc.w new file mode 100644 index 00000000000..1b98c824970 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writeenc.w @@ -0,0 +1,161 @@ +% writeenc.w +% +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2008 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . */ + +@ @c +#include "ptexlib.h" + +static const char _svn_version[] = + "$Id: writeenc.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writeenc.w $"; + +@ All encoding entries go into AVL tree for fast search by name. +@c +struct avl_table *fe_tree = NULL; + +@ AVL sort |fe_entry| into |fe_tree| by name +@c +static int comp_fe_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return strcmp(((const fe_entry *) pa)->name, ((const fe_entry *) pb)->name); +} + +fe_entry *new_fe_entry(void) +{ + fe_entry *fe; + fe = xtalloc(1, fe_entry); + fe->name = NULL; + fe->fe_objnum = 0; + fe->glyph_names = NULL; /* encoding file not yet read in */ + fe->tx_tree = NULL; + return fe; +} + +fe_entry *lookup_fe_entry(char *s) +{ + fe_entry fe; + assert(s != NULL); + fe.name = s; + if (fe_tree == NULL) { + fe_tree = avl_create(comp_fe_entry, NULL, &avl_xallocator); + assert(fe_tree != NULL); + } + return (fe_entry *) avl_find(fe_tree, &fe); +} + +void register_fe_entry(fe_entry * fe) +{ + void **aa; + if (fe_tree == NULL) { + fe_tree = avl_create(comp_fe_entry, NULL, &avl_xallocator); + assert(fe_tree != NULL); + } + assert(fe != NULL); + assert(fe->name != NULL); + assert(lookup_fe_entry(fe->name) == NULL); /* encoding not yet registered */ + aa = avl_probe(fe_tree, fe); + assert(aa != NULL); +} + +fe_entry *get_fe_entry(char *s) +{ + fe_entry *fe; + char **gl; + if ((fe = lookup_fe_entry(s)) == NULL && (gl = load_enc_file(s)) != NULL) { + fe = new_fe_entry(); + fe->name = s; + fe->glyph_names = gl; + register_fe_entry(fe); + } + return fe; +} + +@ @c +void write_enc(PDF pdf, char **glyph_names, struct avl_table *tx_tree, + int fe_objnum) +{ + int i_old, *p; + struct avl_traverser t; + assert(glyph_names != NULL); + assert(tx_tree != NULL); + assert(fe_objnum != 0); + pdf_begin_dict(pdf, fe_objnum, 1); + pdf_puts(pdf, "/Type /Encoding\n"); + pdf_puts(pdf, "/Differences ["); + avl_t_init(&t, tx_tree); + for (i_old = -2, p = (int *) avl_t_first(&t, tx_tree); p != NULL; + p = (int *) avl_t_next(&t)) { + if (*p == i_old + 1) /* no gap */ + pdf_printf(pdf, "/%s", glyph_names[*p]); + else { + if (i_old == -2) + pdf_printf(pdf, "%i/%s", *p, glyph_names[*p]); + else + pdf_printf(pdf, " %i/%s", *p, glyph_names[*p]); + } + i_old = *p; + } + pdf_puts(pdf, "]\n"); + pdf_end_dict(pdf); +} + +void write_fontencoding(PDF pdf, fe_entry * fe) +{ + assert(fe != NULL); + write_enc(pdf, fe->glyph_names, fe->tx_tree, fe->fe_objnum); +} + +void write_fontencodings(PDF pdf) +{ + fe_entry *fe; + struct avl_traverser t; + if (fe_tree == NULL) + return; + avl_t_init(&t, fe_tree); + for (fe = (fe_entry *) avl_t_first(&t, fe_tree); fe != NULL; + fe = (fe_entry *) avl_t_next(&t)) + if (fe->fe_objnum != 0) + write_fontencoding(pdf, fe); +} + +@ cleaning up... +@c + +static void destroy_fe_entry(void *pa, void *pb) +{ + fe_entry *p; + int i; + (void) pb; + p = (fe_entry *) pa; + xfree(p->name); + if (p->glyph_names != NULL) + for (i = 0; i < 256; i++) + if (p->glyph_names[i] != notdef) + xfree(p->glyph_names[i]); + xfree(p->glyph_names); + xfree(p); +} + +void enc_free(void) +{ + if (fe_tree != NULL) + avl_destroy(fe_tree, destroy_fe_entry); + fe_tree = NULL; +} diff --git a/Build/source/texk/web2c/luatexdir/font/writefont.c b/Build/source/texk/web2c/luatexdir/font/writefont.c deleted file mode 100644 index 5dd861f88ee..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writefont.c +++ /dev/null @@ -1,1025 +0,0 @@ -/* writefont.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "luatexfont.h" - -static const char _svn_version[] = - "$Id: writefont.c 2331 2009-04-18 16:39:50Z hhenkel $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writefont.c $"; - -void write_cid_fontdictionary(fo_entry * fo, internalfontnumber f); -void create_cid_fontdictionary(fm_entry * fm, integer font_objnum, - internalfontnumber f); - -const key_entry font_key[FONT_KEYS_NUM] = { - {"Ascent", "Ascender", 1} - , {"CapHeight", "CapHeight", 1} - , {"Descent", "Descender", 1} - , {"ItalicAngle", "ItalicAngle", 1} - , {"StemV", "StdVW", 1} - , {"XHeight", "XHeight", 1} - , {"FontBBox", "FontBBox", 1} - , {"", "", 0} - , {"", "", 0} - , {"", "", 0} - , {"FontName", "FontName", 1} -}; - -/**********************************************************************/ - -struct avl_table *fo_tree = NULL; /* tree of font dictionaries */ -struct avl_table *fd_tree = NULL; /* tree of font descriptor objects */ - -static int comp_fo_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(((const fo_entry *) pa)->fm->tfm_name, - ((const fo_entry *) pb)->fm->tfm_name); -} - -static int comp_fd_entry(const void *pa, const void *pb, void *p) -{ - int i; - const fd_entry *p1 = (const fd_entry *) pa, *p2 = (const fd_entry *) pb; - (void) p; - assert(p1->fm != NULL && is_fontfile(p1->fm) && - p2->fm != NULL && is_fontfile(p2->fm)); - if ((i = strcmp(p1->fm->ff_name, p2->fm->ff_name)) != 0) - return i; - cmp_return(p1->fm->slant, p2->fm->slant); - cmp_return(p1->fm->extend, p2->fm->extend); - return 0; -} - -/**********************************************************************/ -/* initialize data structure for /Type /Font */ - -static fo_entry *new_fo_entry(void) -{ - fo_entry *fo; - fo = xtalloc(1, fo_entry); - fo->fo_objnum = 0; - fo->tex_font = 0; - fo->fm = NULL; - fo->fd = NULL; - fo->fe = NULL; - fo->cw_objnum = 0; - fo->first_char = 1; - fo->last_char = 0; - fo->tx_tree = NULL; - fo->tounicode_objnum = 0; - return fo; -} - -/* initialize data structure for /Type /FontDescriptor */ - -fd_entry *new_fd_entry(void) -{ - fd_entry *fd; - int i; - fd = xtalloc(1, fd_entry); - fd->fd_objnum = 0; - fd->fontname = NULL; - fd->subset_tag = NULL; - fd->ff_found = false; - fd->ff_objnum = 0; - fd->fn_objnum = 0; - fd->all_glyphs = false; - fd->write_ttf_glyph_names = false; - for (i = 0; i < FONT_KEYS_NUM; i++) { - fd->font_dim[i].val = 0; - fd->font_dim[i].set = false; - } - fd->fe = NULL; - fd->builtin_glyph_names = NULL; - fd->fm = NULL; - fd->tx_tree = NULL; - fd->gl_tree = NULL; - return fd; -} - -/**********************************************************************/ -/* - * Only fallback values of font metrics are taken from the TFM info - * of f by preset_fontmetrics(). During reading of the font file, - * these values are replaced by metrics from the font, if available. - */ - -static void preset_fontmetrics(fd_entry * fd, internalfontnumber f) -{ - int i; - fd->font_dim[ITALIC_ANGLE_CODE].val = - divide_scaled(-atan(get_slant(f) / 65536.0) * (180 / M_PI), - pdf_font_size(f), 3); - fd->font_dim[ASCENT_CODE].val = - divide_scaled(char_height(f, 'h'), pdf_font_size(f), 3); - fd->font_dim[CAPHEIGHT_CODE].val = - divide_scaled(char_height(f, 'H'), pdf_font_size(f), 3); - i = -divide_scaled(char_depth(f, 'y'), pdf_font_size(f), 3); - fd->font_dim[DESCENT_CODE].val = i < 0 ? i : 0; - fd->font_dim[STEMV_CODE].val = - divide_scaled(char_width(f, '.') / 3, pdf_font_size(f), 3); - fd->font_dim[XHEIGHT_CODE].val = - divide_scaled(get_x_height(f), pdf_font_size(f), 3); - fd->font_dim[FONTBBOX1_CODE].val = 0; - fd->font_dim[FONTBBOX2_CODE].val = fd->font_dim[DESCENT_CODE].val; - fd->font_dim[FONTBBOX3_CODE].val = - divide_scaled(get_quad(f), pdf_font_size(f), 3); - fd->font_dim[FONTBBOX4_CODE].val = - fd->font_dim[CAPHEIGHT_CODE].val > fd->font_dim[ASCENT_CODE].val ? - fd->font_dim[CAPHEIGHT_CODE].val : fd->font_dim[ASCENT_CODE].val; - for (i = 0; i < INT_KEYS_NUM; i++) - fd->font_dim[i].set = true; -} - -static void fix_fontmetrics(fd_entry * fd) -{ - int i; - intparm *p = (intparm *) fd->font_dim; - assert(p[FONTBBOX1_CODE].set && p[FONTBBOX2_CODE].set - && p[FONTBBOX3_CODE].set && p[FONTBBOX4_CODE].set); - /* make sure there is a rectangle */ - if (p[FONTBBOX3_CODE].val < p[FONTBBOX1_CODE].val) { - i = p[FONTBBOX3_CODE].val; - p[FONTBBOX3_CODE].val = p[FONTBBOX1_CODE].val; - p[FONTBBOX1_CODE].val = i; - } else if (p[FONTBBOX3_CODE].val == p[FONTBBOX1_CODE].val) - p[FONTBBOX3_CODE].val = p[FONTBBOX1_CODE].val + 1; - if (p[FONTBBOX4_CODE].val < p[FONTBBOX2_CODE].val) { - i = p[FONTBBOX4_CODE].val; - p[FONTBBOX4_CODE].val = p[FONTBBOX2_CODE].val; - p[FONTBBOX2_CODE].val = i; - } else if (p[FONTBBOX4_CODE].val == p[FONTBBOX2_CODE].val) - p[FONTBBOX4_CODE].val = p[FONTBBOX2_CODE].val + 1; - if (!p[ASCENT_CODE].set) { - p[ASCENT_CODE].val = p[FONTBBOX4_CODE].val; - p[ASCENT_CODE].set = true; - } - if (!p[DESCENT_CODE].set) { - p[DESCENT_CODE].val = p[FONTBBOX2_CODE].val; - p[DESCENT_CODE].set = true; - } - if (!p[CAPHEIGHT_CODE].set) { - p[CAPHEIGHT_CODE].val = p[FONTBBOX4_CODE].val; - p[CAPHEIGHT_CODE].set = true; - } -} - -static void write_fontmetrics(fd_entry * fd) -{ - int i; - fix_fontmetrics(fd); - pdf_printf("/%s [%i %i %i %i]\n", font_key[FONTBBOX1_CODE].pdfname, - (int) fd->font_dim[FONTBBOX1_CODE].val, - (int) fd->font_dim[FONTBBOX2_CODE].val, - (int) fd->font_dim[FONTBBOX3_CODE].val, - (int) fd->font_dim[FONTBBOX4_CODE].val); - for (i = 0; i < GEN_KEY_NUM; i++) - if (fd->font_dim[i].set) - pdf_printf("/%s %i\n", font_key[i].pdfname, fd->font_dim[i].val); -} - -/**********************************************************************/ - -static void preset_fontname(fo_entry * fo) -{ - if (fo->fm->ps_name != NULL) - fo->fd->fontname = xstrdup(fo->fm->ps_name); /* just fallback */ - else - fo->fd->fontname = xstrdup(fo->fm->tfm_name); -} - -static void write_fontname(fd_entry * fd, const char *key) -{ - assert(fd->fontname != NULL); - pdf_puts("/"); - if (key != NULL) - pdf_printf("%s /", key); - if (fd->subset_tag != NULL) - pdf_printf("%s+", fd->subset_tag); - pdf_printf("%s\n", fd->fontname); -} - -static void write_fontname_object(fd_entry * fd) -{ - assert(fd->fn_objnum != 0); - pdf_begin_obj(fd->fn_objnum, 1); - write_fontname(fd, NULL); - pdf_end_obj(); -} - -/**********************************************************************/ - -fd_entry *lookup_fd_entry(char *s, integer slant, integer extend) -{ - fd_entry fd; - fm_entry fm; - assert(s != NULL); - fm.ff_name = s; - fm.slant = slant; - fm.extend = extend; - fd.fm = &fm; - if (fd_tree == NULL) { - fd_tree = avl_create(comp_fd_entry, NULL, &avl_xallocator); - assert(fd_tree != NULL); - } - return (fd_entry *) avl_find(fd_tree, &fd); -} - -static fd_entry *lookup_fontdescriptor(fo_entry * fo) -{ - assert(fo != NULL); - assert(fo->fm != NULL); - assert(is_fontfile(fo->fm)); - return lookup_fd_entry(fo->fm->ff_name, fo->fm->slant, fo->fm->extend); -} - -void register_fd_entry(fd_entry * fd) -{ - void **aa; - if (fd_tree == NULL) { - fd_tree = avl_create(comp_fd_entry, NULL, &avl_xallocator); - assert(fd_tree != NULL); - } - assert(fd != NULL && fd->fm != NULL && is_fontfile(fd->fm)); - assert(lookup_fd_entry(fd->fm->ff_name, fd->fm->slant, fd->fm->extend) == NULL); /* font descriptor not yet registered */ - aa = avl_probe(fd_tree, fd); - assert(aa != NULL); -} - -static void create_fontdescriptor(fo_entry * fo, internalfontnumber f) -{ - assert(fo != NULL); - assert(fo->fm != NULL); - assert(fo->fd == NULL); - fo->fd = new_fd_entry(); - preset_fontname(fo); - preset_fontmetrics(fo->fd, f); - fo->fd->fe = fo->fe; /* encoding needed by TrueType writing */ - fo->fd->fm = fo->fm; /* map entry needed by TrueType writing */ - fo->fd->gl_tree = avl_create(comp_string_entry, NULL, &avl_xallocator); - assert(fo->fd->gl_tree != NULL); -} - -integer get_fd_objnum(fd_entry * fd) -{ - assert(fd->fd_objnum != 0); - return fd->fd_objnum; -} - -integer get_fn_objnum(fd_entry * fd) -{ - if (fd->fn_objnum == 0) - fd->fn_objnum = pdf_new_objnum(); - return fd->fn_objnum; -} - -void embed_whole_font(fd_entry * fd) -{ - fd->all_glyphs = true; -} - -/**********************************************************************/ -/* - * For all used characters of TeX font f, get corresponding glyph names - * from external reencoding (.enc) file and collect these in the glyph - * tree gl_tree of font descriptor fd referenced by font dictionary fo. - */ - -static void mark_reenc_glyphs(fo_entry * fo, internalfontnumber f) -{ - int i; - char **g; - void **aa; - assert(fo->fe != NULL); - if (is_subsetted(fo->fm)) { - assert(is_included(fo->fm)); - /* mark glyphs from TeX (externally reencoded characters) */ - g = fo->fe->glyph_names; - for (i = fo->first_char; i <= fo->last_char; i++) { - if (pdf_char_marked(f, i) && g[i] != notdef - && (char *) avl_find(fo->fd->gl_tree, g[i]) == NULL) { - aa = avl_probe(fo->fd->gl_tree, xstrdup(g[i])); - assert(aa != NULL); - } - } - } -} - -/* - * Function mark_chars() has 2 uses: - * 1. Mark characters as chars on TeX level. - * 2. Mark encoding pairs used by TeX to optimize encoding vector. - */ - -static struct avl_table *mark_chars(fo_entry * fo, struct avl_table *tx_tree, - internalfontnumber f) -{ - int i, *j; - void **aa; - if (tx_tree == NULL) { - tx_tree = avl_create(comp_int_entry, NULL, &avl_xallocator); - assert(tx_tree != NULL); - } - for (i = fo->first_char; i <= fo->last_char; i++) { - if (pdf_char_marked(f, i) && (int *) avl_find(tx_tree, &i) == NULL) { - j = xtalloc(1, int); - *j = i; - aa = avl_probe(tx_tree, j); - assert(aa != NULL); - } - } - return tx_tree; -} - -/**********************************************************************/ - -static void get_char_range(fo_entry * fo, internalfontnumber f) -{ - int i; - assert(fo != NULL); - for (i = font_bc(f); i <= font_ec(f); i++) /* search for first_char and last_char */ - if (pdf_char_marked(f, i)) - break; - fo->first_char = i; - for (i = font_ec(f); i >= font_bc(f); i--) - if (pdf_char_marked(f, i)) - break; - fo->last_char = i; - if ((fo->first_char > fo->last_char) - || !pdf_char_marked(f, fo->first_char)) { /* no character used from this font */ - fo->last_char = 0; - fo->first_char = fo->last_char + 1; - } -} - -static int font_has_subset(internalfontnumber f) -{ - int i, s; - for (i = font_bc(f); i <= font_ec(f); i++) /* search for first_char and last_char */ - if (pdf_char_marked(f, i)) - break; - s = i; - for (i = font_ec(f); i >= font_bc(f); i--) - if (pdf_char_marked(f, i)) - break; - if (s > i) - return 0; - else - return 1; -} - -static void write_charwidth_array(fo_entry * fo, internalfontnumber f) -{ - int i, j, *ip, *fip; - struct avl_traverser t; - assert(fo->tx_tree != NULL); - assert(fo->cw_objnum == 0); - fo->cw_objnum = pdf_new_objnum(); - pdf_begin_obj(fo->cw_objnum, 1); - avl_t_init(&t, fo->tx_tree); - fip = (int *) avl_t_first(&t, fo->tx_tree); - assert(fip != NULL); - pdf_puts("["); - for (ip = fip, j = *ip; ip != NULL; ip = (int *) avl_t_next(&t)) { - if (ip != fip) - pdf_puts(" "); - i = *ip; - while (j < i - 1) { - pdf_puts("0 "); - j++; - } - j = i; - pdf_print_charwidth(f, i); - } - pdf_puts("]\n"); - pdf_end_obj(); -} - -/**********************************************************************/ -/* - * Remark: Font objects from embedded PDF files are never registered - * into fo_tree; they are individually written out. - */ - -static fo_entry *lookup_fo_entry(char *s) -{ - fo_entry fo; - fm_entry fm; - assert(s != NULL); - fm.tfm_name = s; - fo.fm = &fm; - if (fo_tree == NULL) { - fo_tree = avl_create(comp_fo_entry, NULL, &avl_xallocator); - assert(fo_tree != NULL); - } - return (fo_entry *) avl_find(fo_tree, &fo); -} - -static void register_fo_entry(fo_entry * fo) -{ - void **aa; - if (fo_tree == NULL) { - fo_tree = avl_create(comp_fo_entry, NULL, &avl_xallocator); - assert(fo_tree != NULL); - } - assert(fo != NULL); - assert(fo->fm != NULL); - assert(fo->fm->tfm_name != NULL); - assert(lookup_fo_entry(fo->fm->tfm_name) == NULL); - aa = avl_probe(fo_tree, fo); - assert(aa != NULL); -} - -/**********************************************************************/ - -static void write_fontfile(fd_entry * fd) -{ - assert(is_included(fd->fm)); - if (is_cidkeyed(fd->fm)) { - if (is_opentype(fd->fm)) - writetype0(fd); - else if (is_truetype(fd->fm)) - writetype2(fd); - else if (is_type1(fd->fm)) - writetype1w(fd); - else - assert(0); - } else { - if (is_type1(fd->fm)) - writet1(fd); - else if (is_truetype(fd->fm)) - writettf(fd); - else if (is_opentype(fd->fm)) - writeotf(fd); - else - assert(0); - } - if (!fd->ff_found) - return; - assert(fd->ff_objnum == 0); - fd->ff_objnum = pdf_new_objnum(); - pdf_begin_dict(fd->ff_objnum, 0); /* font file stream */ - if (is_cidkeyed(fd->fm)) { - /* No subtype is used for TrueType-based OpenType fonts */ - if (is_opentype(fd->fm) || is_type1(fd->fm)) - pdf_puts("/Subtype /CIDFontType0C\n"); - /* else - pdf_puts("/Subtype /OpenType\n"); */ - } else { - if (is_type1(fd->fm)) - pdf_printf("/Length1 %i\n/Length2 %i\n/Length3 %i\n", - (int) t1_length1, (int) t1_length2, (int) t1_length3); - else if (is_truetype(fd->fm)) - pdf_printf("/Length1 %i\n", (int) ttf_length); - else if (is_opentype(fd->fm)) - pdf_puts("/Subtype /Type1C\n"); - else - assert(0); - } - pdf_begin_stream(); - fb_flush(); - pdf_end_stream(); -} - -/**********************************************************************/ - -static void write_fontdescriptor(fd_entry * fd) -{ - static const int std_flags[] = { - /* indices for << start with 0, but bits start with 1, so the numbers - * for << are 1 lower than the bits in table 5.20 */ - /* *INDENT-OFF* */ - 1 + 2 + (1 << 5), /* Courier */ - 1 + 2 + (1 << 5) + (1 << 18),/* Courier-Bold */ - 1 + 2 + (1 << 5) + (1 << 6), /* Courier-Oblique */ - 1 + 2 + (1 << 5) + (1 << 6) + (1 << 18),/* Courier-BoldOblique */ - (1 << 5), /* Helvetica */ - (1 << 5) + (1 << 18),/* Helvetica-Bold */ - (1 << 5) + (1 << 6), /* Helvetica-Oblique */ - (1 << 5) + (1 << 6) + (1 << 18),/* Helvetica-BoldOblique */ - 4, /* Symbol */ - 2 + (1 << 5), /* Times-Roman */ - 2 + (1 << 5) + (1 << 18),/* Times-Bold */ - 2 + (1 << 5) + (1 << 6), /* Times-Italic */ - 2 + (1 << 5) + (1 << 6) + (1 << 18),/* Times-BoldItalic */ - 4 /* ZapfDingbats */ - /* *INDENT-ON* */ - }; - char *glyph; - struct avl_traverser t; - int fd_flags; - assert(fd != NULL && fd->fm != NULL); - - if (is_fontfile(fd->fm)) - write_fontfile(fd); /* this will set fd->ff_found if font file is found */ - if (fd->fn_objnum != 0) - write_fontname_object(fd); - if (fd->fd_objnum == 0) - fd->fd_objnum = pdf_new_objnum(); - pdf_begin_dict(fd->fd_objnum, 1); - pdf_puts("/Type /FontDescriptor\n"); - write_fontname(fd, "FontName"); - if (fd->fm->fd_flags != FD_FLAGS_NOT_SET_IN_MAPLINE) - fd_flags = (int) fd->fm->fd_flags; - else if (fd->ff_found) - fd_flags = FD_FLAGS_DEFAULT_EMBED; - else { - fd_flags = is_std_t1font(fd->fm) - ? std_flags[check_std_t1font(fd->fm->ps_name)] - : FD_FLAGS_DEFAULT_NON_EMBED; - pdftex_warn - ("No flags specified for non-embedded font `%s' (%s) (I'm using %i): " - "fix your map entry.", - fd->fm->ps_name != NULL ? fd->fm->ps_name : "No name given", - fd->fm->tfm_name, fd_flags); - } - pdf_printf("/Flags %i\n", fd_flags); - write_fontmetrics(fd); - if (is_cidkeyed(fd->fm)) { - if (is_type1(fd->fm)) - pdf_printf("/FontFile3 %i 0 R\n", (int) fd->ff_objnum); - else if (is_truetype(fd->fm)) - pdf_printf("/FontFile2 %i 0 R\n", (int) fd->ff_objnum); - else if (is_opentype(fd->fm)) - pdf_printf("/FontFile3 %i 0 R\n", (int) fd->ff_objnum); - else - assert(0); - } else { - if (fd->ff_found) { - if (is_subsetted(fd->fm) && is_type1(fd->fm)) { - /* /CharSet is optional; names may appear in any order */ - assert(fd->gl_tree != NULL); - avl_t_init(&t, fd->gl_tree); - pdf_puts("/CharSet ("); - for (glyph = (char *) avl_t_first(&t, fd->gl_tree); - glyph != NULL; glyph = (char *) avl_t_next(&t)) - pdf_printf("/%s", glyph); - pdf_puts(")\n"); - } - if (is_type1(fd->fm)) - pdf_printf("/FontFile %i 0 R\n", (int) fd->ff_objnum); - else if (is_truetype(fd->fm)) - pdf_printf("/FontFile2 %i 0 R\n", (int) fd->ff_objnum); - else if (is_opentype(fd->fm)) - pdf_printf("/FontFile3 %i 0 R\n", (int) fd->ff_objnum); - else - assert(0); - } - } - /* TODO: Optional keys for CID fonts. - - The most interesting ones are - /Style << /Panose <12-byte string>>> - and - /CIDSET - the latter can be used in subsets, to give the included CIDs - as a bitmap on the whole list. - */ - pdf_end_dict(); -} - -static void write_fontdescriptors(void) -{ - fd_entry *fd; - struct avl_traverser t; - if (fd_tree == NULL) - return; - avl_t_init(&t, fd_tree); - for (fd = (fd_entry *) avl_t_first(&t, fd_tree); fd != NULL; - fd = (fd_entry *) avl_t_next(&t)) - write_fontdescriptor(fd); -} - -/**********************************************************************/ - -static void write_fontdictionary(fo_entry * fo) -{ - assert(fo != NULL); - assert(fo->fm != NULL); - assert(fo->fo_objnum != 0); /* reserved as pdf_font_num(f) in pdftex.web */ - - /* write ToUnicode entry if needed */ - if (fixed_gen_tounicode > 0 && fo->fd != NULL) { - if (fo->fe != NULL) { - fo->tounicode_objnum = - write_tounicode(fo->fe->glyph_names, fo->fe->name); - } else if (is_type1(fo->fm)) { - assert(fo->fd->builtin_glyph_names != NULL); - fo->tounicode_objnum = - write_tounicode(fo->fd->builtin_glyph_names, fo->fm->tfm_name); - } - } - - pdf_begin_dict(fo->fo_objnum, 1); - pdf_puts("/Type /Font\n"); - pdf_puts("/Subtype /"); - if (is_type1(fo->fm)) - pdf_printf("%s\n", "Type1"); - else if (is_truetype(fo->fm)) - pdf_printf("%s\n", "TrueType"); - else if (is_opentype(fo->fm)) - pdf_printf("%s\n", "Type1"); - else - assert(0); - assert(fo->fd != NULL && fo->fd->fd_objnum != 0); - write_fontname(fo->fd, "BaseFont"); - pdf_printf("/FontDescriptor %i 0 R\n", (int) fo->fd->fd_objnum); - assert(fo->cw_objnum != 0); - pdf_printf("/FirstChar %i\n/LastChar %i\n/Widths %i 0 R\n", - (int) fo->first_char, (int) fo->last_char, (int) fo->cw_objnum); - if ((is_type1(fo->fm) || is_opentype(fo->fm)) && fo->fe != NULL - && fo->fe->fe_objnum != 0) - pdf_printf("/Encoding %i 0 R\n", (int) fo->fe->fe_objnum); - if (fo->tounicode_objnum != 0) - pdf_printf("/ToUnicode %i 0 R\n", (int) fo->tounicode_objnum); - if (pdf_font_attr(fo->tex_font) != get_nullstr()) { - pdf_print(pdf_font_attr(fo->tex_font)); - pdf_puts("\n"); - } - pdf_end_dict(); -} - -static void write_fontdictionaries(void) -{ - fo_entry *fo; - struct avl_traverser t; - if (fo_tree == NULL) - return; - avl_t_init(&t, fo_tree); - for (fo = (fo_entry *) avl_t_first(&t, fo_tree); fo != NULL; - fo = (fo_entry *) avl_t_next(&t)) - write_fontdictionary(fo); -} - -/**********************************************************************/ -/* - * Final flush of all font related stuff by call from - * @= in pdftex.web. - */ - -void write_fontstuff(void) -{ - write_fontdescriptors(); - write_fontencodings(); /* see writeenc.c */ - write_fontdictionaries(); -} - -/**********************************************************************/ - -static void create_fontdictionary(fm_entry * fm, integer font_objnum, - internalfontnumber f) -{ - fo_entry *fo = new_fo_entry(); - get_char_range(fo, f); /* set fo->first_char and fo->last_char from f */ - if (fo->last_char > 255) - fo->last_char = 255; /* added 9-4-2008, mantis #25 */ - assert(fo->last_char >= fo->first_char); - fo->fm = fm; - fo->fo_objnum = font_objnum; - fo->tex_font = f; - if (is_reencoded(fo->fm)) { /* at least the map entry tells so */ - fo->fe = get_fe_entry(fo->fm->encname); /* returns NULL if .enc file couldn't be opened */ - if (fo->fe != NULL && (is_type1(fo->fm) || is_opentype(fo->fm))) { - if (fo->fe->fe_objnum == 0) - fo->fe->fe_objnum = pdf_new_objnum(); /* then it will be written out */ - /* mark encoding pairs used by TeX to optimize encoding vector */ - fo->fe->tx_tree = mark_chars(fo, fo->fe->tx_tree, f); - } - } - fo->tx_tree = mark_chars(fo, fo->tx_tree, f); /* for write_charwidth_array() */ - write_charwidth_array(fo, f); - if (!is_builtin(fo->fm)) { - if (is_type1(fo->fm)) { - if ((fo->fd = lookup_fontdescriptor(fo)) == NULL) { - create_fontdescriptor(fo, f); - register_fd_entry(fo->fd); - } - } else - create_fontdescriptor(fo, f); - if (fo->fe != NULL) { - mark_reenc_glyphs(fo, f); - if (!is_type1(fo->fm)) { - /* mark reencoded characters as chars on TeX level */ - assert(fo->fd->tx_tree == NULL); - fo->fd->tx_tree = mark_chars(fo, fo->fd->tx_tree, f); - if (is_truetype(fo->fm)) - fo->fd->write_ttf_glyph_names = true; - } - } else - /* mark non-reencoded characters as chars on TeX level */ - fo->fd->tx_tree = mark_chars(fo, fo->fd->tx_tree, f); - if (!is_type1(fo->fm)) - write_fontdescriptor(fo->fd); - } else { - /* builtin fonts still need the /Widths array and /FontDescriptor - * (to avoid error 'font FOO contains bad /BBox') - */ - create_fontdescriptor(fo, f); - write_fontdescriptor(fo->fd); - if (!is_std_t1font(fo->fm)) - pdftex_warn("font `%s' is not a standard font; " - "I suppose it is available to your PDF viewer then", - fo->fm->ps_name); - } - if (is_type1(fo->fm)) - register_fo_entry(fo); - else - write_fontdictionary(fo); -} - -/**********************************************************************/ - -static int has_ttf_outlines(fm_entry * fm) -{ - FILE *f = fopen(fm->ff_name, "rb"); - if (f != NULL) { - int ch1 = getc(f); - int ch2 = getc(f); - int ch3 = getc(f); - int ch4 = getc(f); - fclose(f); - if (ch1 == 'O' && ch2 == 'T' && ch3 == 'T' && ch4 == 'O') - return 0; - return 1; - } - return 0; -} - -void do_pdf_font(integer font_objnum, internalfontnumber f) -{ - fm_entry *fm; - /* This is not 100% true: CID is actually needed whenever (and - * only) there are more than 256 separate glyphs used. But for - * now, just assume the user knows what he is doing; - */ - if (!font_has_subset(f)) - return; - - if (font_encodingbytes(f) == 2) { - /* Create a virtual font map entry, as this is needed by the - * rest of the font inclusion mechanism. - */ - fm = new_fm_entry(); - fm->tfm_name = font_name(f); /* or whatever, not a real tfm */ - fm->ff_name = font_filename(f); /* the actual file */ - fm->encname = font_encodingname(f); /* for the CIDSystemInfo */ - fm->ps_name = font_fullname(f); /* the true name */ - fm->slant = font_slant(f); /* slant factor */ - fm->extend = font_extend(f); /* extension factor */ - fm->fd_flags = 4; /* can perhaps be done better */ - fm->in_use = true; - - switch (font_format(f)) { - case opentype_format: - if (has_ttf_outlines(fm)) { - set_truetype(fm); - } else { - set_opentype(fm); - } - break; - case truetype_format: - set_truetype(fm); - break; - case type1_format: - set_type1(fm); - break; - default: - pdftex_fail - ("writefont.c: The file format (%s) for font `%s' is incompatible with wide characters\n", - font_format_name(f), font_name(f)); - } - /* This makes "unknown" default to subsetted inclusion */ - if (font_embedding(f) != no_embedding) { - set_included(fm); - if (font_embedding(f) != full_embedding) { - set_subsetted(fm); - } - } - set_cidkeyed(fm); - create_cid_fontdictionary(fm, font_objnum, f); - - } else { - fm = hasfmentry(f) ? (fm_entry *) font_map(f) : NULL; - if (fm == NULL || (fm->ps_name == NULL && fm->ff_name == NULL)) - writet3(font_objnum, f); - else - create_fontdictionary(fm, font_objnum, f); - } -} - -/**********************************************************************/ - - -/* - The glyph width is included in |glw_entry|, because that width - depends on the value it has in the font where it is actually - typeset from, not the font that is the 'owner' of the fd entry. - - TODO: It is possible that the user messes with the metric width, - but handling that properly would require access to the 'hmtx' table - at this point in the program. -*/ - -static int comp_glw_entry(const void *pa, const void *pb, void *p) -{ - unsigned short i, j; - (void) p; - i = (*(const glw_entry *) pa).id; - j = (*(const glw_entry *) pb).id; - cmp_return(i, j); - return 0; -} - -static void create_cid_fontdescriptor(fo_entry * fo, internalfontnumber f) -{ - assert(fo != NULL); - assert(fo->fm != NULL); - assert(fo->fd == NULL); - fo->fd = new_fd_entry(); - preset_fontname(fo); - preset_fontmetrics(fo->fd, f); - fo->fd->fe = fo->fe; /* encoding needed by TrueType writing */ - fo->fd->fm = fo->fm; /* map entry needed by TrueType writing */ - fo->fd->gl_tree = avl_create(comp_glw_entry, NULL, &avl_xallocator); - assert(fo->fd->gl_tree != NULL); -} - -/* - The values |font_bc()| and |font_ec()| are potentially large - character ids, but the strings that are written out use CID - indexes, and those are limited to 16-bit values. -*/ - -static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f) -{ - int i, k, l; - glw_entry *j; - void *aa; - for (k = 1; k <= max_font_id(); k++) { - if (k == f || -f == pdf_font_num(k)) { - l = pdf_font_size(k); - for (i = font_bc(k); i <= font_ec(k); i++) { - if (char_exists(k, i) && char_used(k, i)) { - j = xtalloc(1, glw_entry); - j->id = char_index(k, i); - j->wd = divide_scaled_n(char_width(k, i), l, 10000.0); - if ((glw_entry *) avl_find(fo->fd->gl_tree, j) == NULL) { - aa = avl_probe(fo->fd->gl_tree, j); - assert(aa != NULL); - } else { - xfree(j); - } - } - } - } - } -} - -/* - It is possible to compress the widths array even better, by using the - alternate 'range' syntax and possibly even using /DW to set - a default value. - - There is a some optimization here already: glyphs that are - not used do not appear in the widths array at all. - - We have to make sure that we do not output an (incorrect!) - width for a character that exists in the font, but is not used - in typesetting. An enormous negative width is used as sentinel value -*/ - - -static void write_cid_charwidth_array(fo_entry * fo) -{ - int i, j; - glw_entry *glyph; - struct avl_traverser t; - - assert(fo->cw_objnum == 0); - fo->cw_objnum = pdf_new_objnum(); - pdf_begin_obj(fo->cw_objnum, 1); - avl_t_init(&t, fo->fd->gl_tree); - glyph = (glw_entry *) avl_t_first(&t, fo->fd->gl_tree); - assert(glyph != NULL); - i = glyph->id; - pdf_printf("[ %i [", i); - for (; glyph != NULL; glyph = (glw_entry *) avl_t_next(&t)) { - j = glyph->wd; - if (glyph->id > (unsigned) (i + 1)) { - pdf_printf("] %i [", glyph->id); - j = glyph->wd; - } - if (glyph->id == (unsigned) (i + 1)) - pdf_puts(" "); - - if (j < 0) { - pdf_puts("-"); - j = -j; - } - - /* pdf_print_charwidth(f, i); */ - - pdf_printf("%i", (j / 10)); - if ((j % 10) != 0) - pdf_printf(".%i", (j % 10)); - - i = glyph->id; - } - pdf_puts("]]\n"); - pdf_end_obj(); -} - - -void create_cid_fontdictionary(fm_entry * fm, integer font_objnum, - internalfontnumber f) -{ - fo_entry *fo = new_fo_entry(); - get_char_range(fo, f); /* set fo->first_char and fo->last_char from f */ - assert(fo->last_char >= fo->first_char); - fo->fm = fm; - fo->fo_objnum = font_objnum; - fo->tex_font = f; - create_cid_fontdescriptor(fo, f); - mark_cid_subset_glyphs(fo, f); - if (is_subsetted(fo->fm)) { - /* - this is a bit sneaky. |make_subset_tag()| actually expects the glyph tree - to contain strings instead of |glw_entry| items. However, all calculations - are done using explicit typecasts, so it works out ok. - */ - make_subset_tag(fo->fd); - } - write_cid_charwidth_array(fo); - write_fontdescriptor(fo->fd); - - write_cid_fontdictionary(fo, f); - xfree(fo); -} - -void write_cid_fontdictionary(fo_entry * fo, internalfontnumber f) -{ - int i; - - fo->tounicode_objnum = write_cid_tounicode(fo, f); - - pdf_begin_dict(fo->fo_objnum, 1); - pdf_puts("/Type /Font\n"); - pdf_puts("/Subtype /Type0\n"); - pdf_puts("/Encoding /Identity-H\n"); - write_fontname(fo->fd, "BaseFont"); - i = pdf_new_objnum(); - pdf_printf("/DescendantFonts [%i 0 R]\n", i); - /* todo: the ToUnicode CMap */ - if (fo->tounicode_objnum != 0) - pdf_printf("/ToUnicode %i 0 R\n", (int) fo->tounicode_objnum); - - pdf_end_dict(); - - pdf_begin_dict(i, 1); - pdf_puts("/Type /Font\n"); - if (is_opentype(fo->fm) || is_type1(fo->fm)) { - pdf_puts("/Subtype /CIDFontType0\n"); - } else { - pdf_puts("/Subtype /CIDFontType2\n"); - pdf_printf("/CIDToGIDMap /Identity\n"); - } - write_fontname(fo->fd, "BaseFont"); - pdf_printf("/FontDescriptor %i 0 R\n", (int) fo->fd->fd_objnum); - pdf_printf("/W %i 0 R\n", (int) fo->cw_objnum); - pdf_printf("/CIDSystemInfo <<\n"); - pdf_printf("/Registry (%s)\n", - (font_cidregistry(f) ? font_cidregistry(f) : "Adobe")); - pdf_printf("/Ordering (%s)\n", - (font_cidordering(f) ? font_cidordering(f) : "Identity")); - pdf_printf("/Supplement %u\n", (unsigned int) font_cidsupplement(f)); - pdf_printf(">>\n"); - - /* I doubt there is anything useful that could be written here */ - /* - if (pdf_font_attr(fo->tex_font) != get_nullstr()) { - pdf_print(pdf_font_attr(fo->tex_font)); - pdf_puts("\n"); - } - */ - pdf_end_dict(); - -} diff --git a/Build/source/texk/web2c/luatexdir/font/writefont.w b/Build/source/texk/web2c/luatexdir/font/writefont.w new file mode 100644 index 00000000000..523cae59740 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writefont.w @@ -0,0 +1,1010 @@ +% writefont.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . */ + +@ @c +static const char _svn_version[] = + "$Id: writefont.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writefont.w $"; + +#include "ptexlib.h" +#include "lua/luatex-api.h" + +void write_cid_fontdictionary(PDF pdf, fo_entry * fo, internal_font_number f); +static void create_cid_fontdictionary(PDF pdf, internal_font_number f); + +const key_entry font_key[FONT_KEYS_NUM] = { + {"Ascent", "Ascender", 1} + , {"CapHeight", "CapHeight", 1} + , {"Descent", "Descender", 1} + , {"ItalicAngle", "ItalicAngle", 1} + , {"StemV", "StdVW", 1} + , {"XHeight", "XHeight", 1} + , {"FontBBox", "FontBBox", 1} + , {"", "", 0} + , {"", "", 0} + , {"", "", 0} + , {"FontName", "FontName", 1} +}; + +@ +@c +struct avl_table *fo_tree = NULL; /* tree of font dictionaries */ +struct avl_table *fd_tree = NULL; /* tree of font descriptor objects */ + +static int comp_fo_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return strcmp(((const fo_entry *) pa)->fm->tfm_name, + ((const fo_entry *) pb)->fm->tfm_name); +} + +static int comp_fd_entry(const void *pa, const void *pb, void *p) +{ + const fd_entry *p1 = (const fd_entry *) pa, *p2 = (const fd_entry *) pb; + (void) p; + assert(p1->fm != NULL && is_fontfile(p1->fm) && + p2->fm != NULL && is_fontfile(p2->fm)); + return strcmp(p1->fm->ff_name, p2->fm->ff_name); +} + +@ initialize data structure for /Type /Font +@c +fo_entry *new_fo_entry(void) +{ + fo_entry *fo; + fo = xtalloc(1, fo_entry); + fo->fo_objnum = 0; + fo->tex_font = 0; + fo->fm = NULL; + fo->fd = NULL; + fo->fe = NULL; + fo->cw_objnum = 0; + fo->first_char = 1; + fo->last_char = 0; + fo->tx_tree = NULL; + fo->tounicode_objnum = 0; + return fo; +} + +@ initialize data structure for /Type /FontDescriptor +@c +fd_entry *new_fd_entry(void) +{ + fd_entry *fd; + int i; + fd = xtalloc(1, fd_entry); + fd->fd_objnum = 0; + fd->fontname = NULL; + fd->subset_tag = NULL; + fd->ff_found = false; + fd->ff_objnum = 0; + fd->all_glyphs = false; + fd->write_ttf_glyph_names = false; + for (i = 0; i < FONT_KEYS_NUM; i++) { + fd->font_dim[i].val = 0; + fd->font_dim[i].set = false; + } + fd->fe = NULL; + fd->builtin_glyph_names = NULL; + fd->fm = NULL; + fd->tx_tree = NULL; + fd->gl_tree = NULL; + return fd; +} + +@ +Only fallback values of font metrics are taken from the TFM info +of |f| by |preset_fontmetrics|. During reading of the font file, +these values are replaced by metrics from the font, if available. + +@c +static void preset_fontmetrics(fd_entry * fd, internal_font_number f) +{ + int i; + fd->font_dim[ITALIC_ANGLE_CODE].val = 0; + fd->font_dim[ASCENT_CODE].val = + divide_scaled(char_height(f, 'h'), font_size(f), 3); + fd->font_dim[CAPHEIGHT_CODE].val = + divide_scaled(char_height(f, 'H'), font_size(f), 3); + i = -divide_scaled(char_depth(f, 'y'), font_size(f), 3); + fd->font_dim[DESCENT_CODE].val = i < 0 ? i : 0; + fd->font_dim[STEMV_CODE].val = + divide_scaled(char_width(f, '.') / 3, font_size(f), 3); + fd->font_dim[XHEIGHT_CODE].val = + divide_scaled(get_x_height(f), font_size(f), 3); + fd->font_dim[FONTBBOX1_CODE].val = 0; + fd->font_dim[FONTBBOX2_CODE].val = fd->font_dim[DESCENT_CODE].val; + fd->font_dim[FONTBBOX3_CODE].val = + divide_scaled(get_quad(f), font_size(f), 3); + fd->font_dim[FONTBBOX4_CODE].val = + fd->font_dim[CAPHEIGHT_CODE].val > fd->font_dim[ASCENT_CODE].val ? + fd->font_dim[CAPHEIGHT_CODE].val : fd->font_dim[ASCENT_CODE].val; + for (i = 0; i < INT_KEYS_NUM; i++) + fd->font_dim[i].set = true; +} + +static void fix_fontmetrics(fd_entry * fd) +{ + int i; + intparm *p = (intparm *) fd->font_dim; + assert(p[FONTBBOX1_CODE].set && p[FONTBBOX2_CODE].set + && p[FONTBBOX3_CODE].set && p[FONTBBOX4_CODE].set); + /* make sure there is a rectangle */ + if (p[FONTBBOX3_CODE].val < p[FONTBBOX1_CODE].val) { + i = p[FONTBBOX3_CODE].val; + p[FONTBBOX3_CODE].val = p[FONTBBOX1_CODE].val; + p[FONTBBOX1_CODE].val = i; + } else if (p[FONTBBOX3_CODE].val == p[FONTBBOX1_CODE].val) + p[FONTBBOX3_CODE].val = p[FONTBBOX1_CODE].val + 1; + if (p[FONTBBOX4_CODE].val < p[FONTBBOX2_CODE].val) { + i = p[FONTBBOX4_CODE].val; + p[FONTBBOX4_CODE].val = p[FONTBBOX2_CODE].val; + p[FONTBBOX2_CODE].val = i; + } else if (p[FONTBBOX4_CODE].val == p[FONTBBOX2_CODE].val) + p[FONTBBOX4_CODE].val = p[FONTBBOX2_CODE].val + 1; + if (!p[ASCENT_CODE].set) { + p[ASCENT_CODE].val = p[FONTBBOX4_CODE].val; + p[ASCENT_CODE].set = true; + } + if (!p[DESCENT_CODE].set) { + p[DESCENT_CODE].val = p[FONTBBOX2_CODE].val; + p[DESCENT_CODE].set = true; + } + if (!p[CAPHEIGHT_CODE].set) { + p[CAPHEIGHT_CODE].val = p[FONTBBOX4_CODE].val; + p[CAPHEIGHT_CODE].set = true; + } +} + +static void write_fontmetrics(PDF pdf, fd_entry * fd) +{ + int i; + fix_fontmetrics(fd); + pdf_printf(pdf, "/%s [%i %i %i %i]\n", font_key[FONTBBOX1_CODE].pdfname, + (int) fd->font_dim[FONTBBOX1_CODE].val, + (int) fd->font_dim[FONTBBOX2_CODE].val, + (int) fd->font_dim[FONTBBOX3_CODE].val, + (int) fd->font_dim[FONTBBOX4_CODE].val); + for (i = 0; i < GEN_KEY_NUM; i++) + if (fd->font_dim[i].set) + pdf_printf(pdf, "/%s %i\n", font_key[i].pdfname, + fd->font_dim[i].val); +} + +@ +@c +static void preset_fontname(fo_entry * fo, internal_font_number f) +{ + if (fo->fm->ps_name != NULL) + fo->fd->fontname = xstrdup(fo->fm->ps_name); /* just fallback */ + else if (font_fullname(f) != NULL) + fo->fd->fontname = xstrdup(font_fullname(f)); + else + fo->fd->fontname = xstrdup(fo->fm->tfm_name); +} + +static void write_fontname(PDF pdf, fd_entry * fd, const char *key) +{ + assert(fd->fontname != NULL); + pdf_puts(pdf, "/"); + if (key != NULL) + pdf_printf(pdf, "%s /", key); + if (fd->subset_tag != NULL) + pdf_printf(pdf, "%s+", fd->subset_tag); + pdf_printf(pdf, "%s\n", fd->fontname); +} + +@ +@c +fd_entry *lookup_fd_entry(char *s) +{ + fd_entry fd; + fm_entry fm; + assert(s != NULL); + fm.ff_name = s; + fd.fm = &fm; + if (fd_tree == NULL) { + fd_tree = avl_create(comp_fd_entry, NULL, &avl_xallocator); + assert(fd_tree != NULL); + } + return (fd_entry *) avl_find(fd_tree, &fd); +} + +fd_entry *lookup_fontdescriptor(fo_entry * fo) +{ + assert(fo != NULL); + assert(fo->fm != NULL); + assert(is_fontfile(fo->fm)); + return lookup_fd_entry(fo->fm->ff_name); +} + +void register_fd_entry(fd_entry * fd) +{ + void **aa; + if (fd_tree == NULL) { + fd_tree = avl_create(comp_fd_entry, NULL, &avl_xallocator); + assert(fd_tree != NULL); + } + assert(fd != NULL && fd->fm != NULL && is_fontfile(fd->fm)); + assert(lookup_fd_entry(fd->fm->ff_name) == NULL); /* font descriptor not yet registered */ + aa = avl_probe(fd_tree, fd); + assert(aa != NULL); +} + +void create_fontdescriptor(fo_entry * fo, internal_font_number f) +{ + assert(fo != NULL); + assert(fo->fm != NULL); + assert(fo->fd == NULL); + fo->fd = new_fd_entry(); + preset_fontname(fo, f); + preset_fontmetrics(fo->fd, f); + fo->fd->fe = fo->fe; /* encoding needed by TrueType writing */ + fo->fd->fm = fo->fm; /* map entry needed by TrueType writing */ + fo->fd->gl_tree = avl_create(comp_string_entry, NULL, &avl_xallocator); + assert(fo->fd->gl_tree != NULL); +} + +@ +For all used characters of \TeX font |f|, get corresponding glyph names +from external reencoding (.enc) file and collect these in the glyph +tree |gl_tree| of font descriptor |fd| referenced by font dictionary |fo|. + +@c +void mark_reenc_glyphs(fo_entry * fo, internal_font_number f) +{ + int i; + char **g; + void **aa; + assert(fo->fe != NULL); + if (is_subsetted(fo->fm)) { + assert(is_included(fo->fm)); + /* mark glyphs from TeX (externally reencoded characters) */ + g = fo->fe->glyph_names; + for (i = fo->first_char; i <= fo->last_char; i++) { + if (pdf_char_marked(f, i) && g[i] != notdef + && (char *) avl_find(fo->fd->gl_tree, g[i]) == NULL) { + aa = avl_probe(fo->fd->gl_tree, xstrdup(g[i])); + assert(aa != NULL); + } + } + } +} + +@ +Function |mark_chars| has 2 uses: +\item 1. Mark characters as chars on \TeX\ level. +\item 2. Mark encoding pairs used by \TeX\ to optimize encoding vector. + +@c +struct avl_table *mark_chars(fo_entry * fo, struct avl_table *tx_tree, + internal_font_number f) +{ + int i, *j; + void **aa; + if (tx_tree == NULL) { + tx_tree = avl_create(comp_int_entry, NULL, &avl_xallocator); + assert(tx_tree != NULL); + } + for (i = fo->first_char; i <= fo->last_char; i++) { + if (pdf_char_marked(f, i) && (int *) avl_find(tx_tree, &i) == NULL) { + j = xtalloc(1, int); + *j = i; + aa = avl_probe(tx_tree, j); + assert(aa != NULL); + } + } + return tx_tree; +} + +@ +@c +void get_char_range(fo_entry * fo, internal_font_number f) +{ + int i; + assert(fo != NULL); + for (i = font_bc(f); i <= font_ec(f); i++) /* search for |first_char| and |last_char| */ + if (pdf_char_marked(f, i)) + break; + fo->first_char = i; + for (i = font_ec(f); i >= font_bc(f); i--) + if (pdf_char_marked(f, i)) + break; + fo->last_char = i; + if ((fo->first_char > fo->last_char) + || !pdf_char_marked(f, fo->first_char)) { /* no character used from this font */ + fo->last_char = 0; + fo->first_char = fo->last_char + 1; + } +} + +static int font_has_subset(internal_font_number f) +{ + int i, s; + for (i = font_bc(f); i <= font_ec(f); i++) /* search for |first_char| and |last_char| */ + if (pdf_char_marked(f, i)) + break; + s = i; + for (i = font_ec(f); i >= font_bc(f); i--) + if (pdf_char_marked(f, i)) + break; + if (s > i) + return 0; + else + return 1; +} + +@ +@c +static void write_charwidth_array(PDF pdf, fo_entry * fo, + internal_font_number f) +{ + int i, j, *ip, *fip; + struct avl_traverser t; + assert(fo->tx_tree != NULL); + assert(fo->cw_objnum == 0); + fo->cw_objnum = pdf_new_objnum(pdf); + pdf_begin_obj(pdf, fo->cw_objnum, 1); + avl_t_init(&t, fo->tx_tree); + fip = (int *) avl_t_first(&t, fo->tx_tree); + assert(fip != NULL); + pdf_puts(pdf, "["); + for (ip = fip, j = *ip; ip != NULL; ip = (int *) avl_t_next(&t)) { + if (ip != fip) + pdf_puts(pdf, " "); + i = *ip; + while (j < i - 1) { + pdf_puts(pdf, "0 "); + j++; + } + j = i; + pdf_print_charwidth(pdf, f, i); + } + pdf_puts(pdf, "]\n"); + pdf_end_obj(pdf); +} + +@ Remark: Font objects from embedded PDF files are never registered +into |fo_tree|; they are individually written out. +@c +fo_entry *lookup_fo_entry(char *s) +{ + fo_entry fo; + fm_entry fm; + assert(s != NULL); + fm.tfm_name = s; + fo.fm = &fm; + if (fo_tree == NULL) { + fo_tree = avl_create(comp_fo_entry, NULL, &avl_xallocator); + assert(fo_tree != NULL); + } + return (fo_entry *) avl_find(fo_tree, &fo); +} + +void register_fo_entry(fo_entry * fo) +{ + void **aa; + if (fo_tree == NULL) { + fo_tree = avl_create(comp_fo_entry, NULL, &avl_xallocator); + assert(fo_tree != NULL); + } + assert(fo != NULL); + assert(fo->fm != NULL); + assert(fo->fm->tfm_name != NULL); + assert(lookup_fo_entry(fo->fm->tfm_name) == NULL); + aa = avl_probe(fo_tree, fo); + assert(aa != NULL); +} + +@ +@c +static void write_fontfile(PDF pdf, fd_entry * fd) +{ + assert(is_included(fd->fm)); + if (is_cidkeyed(fd->fm)) { + if (is_opentype(fd->fm)) + writetype0(pdf, fd); + else if (is_truetype(fd->fm)) + writetype2(pdf, fd); + else if (is_type1(fd->fm)) + writetype1w(pdf, fd); + else + assert(0); + } else { + if (is_type1(fd->fm)) + writet1(pdf, fd); + else if (is_truetype(fd->fm)) + writettf(pdf, fd); + else if (is_opentype(fd->fm)) + writeotf(pdf, fd); + else + assert(0); + } + if (!fd->ff_found) + return; + assert(fd->ff_objnum == 0); + fd->ff_objnum = pdf_new_objnum(pdf); + pdf_begin_dict(pdf, fd->ff_objnum, 0); /* font file stream */ + if (is_cidkeyed(fd->fm)) { + /* No subtype is used for TrueType-based OpenType fonts */ + if (is_opentype(fd->fm) || is_type1(fd->fm)) + pdf_puts(pdf, "/Subtype /CIDFontType0C\n"); +#if 0 + else + pdf_puts(pdf,"/Subtype /OpenType\n"); +#endif + } else { + if (is_type1(fd->fm)) + pdf_printf(pdf, "/Length1 %i\n/Length2 %i\n/Length3 %i\n", + (int) t1_length1, (int) t1_length2, (int) t1_length3); + else if (is_truetype(fd->fm)) + pdf_printf(pdf, "/Length1 %i\n", (int) ttf_length); + else if (is_opentype(fd->fm)) + pdf_puts(pdf, "/Subtype /Type1C\n"); + else + assert(0); + } + pdf_begin_stream(pdf); + fb_flush(pdf); + pdf_end_stream(pdf); +} + +@ +@c +static void write_fontdescriptor(PDF pdf, fd_entry * fd) +{ + static const int std_flags[] = { + /* indices for << start with 0, but bits start with 1, so the numbers + * for << are 1 lower than the bits in table 5.20 */ + /* *INDENT-OFF* */ + 1 + 2 + (1 << 5), /* Courier */ + 1 + 2 + (1 << 5) + (1 << 18),/* Courier-Bold */ + 1 + 2 + (1 << 5) + (1 << 6), /* Courier-Oblique */ + 1 + 2 + (1 << 5) + (1 << 6) + (1 << 18),/* Courier-BoldOblique */ + (1 << 5), /* Helvetica */ + (1 << 5) + (1 << 18),/* Helvetica-Bold */ + (1 << 5) + (1 << 6), /* Helvetica-Oblique */ + (1 << 5) + (1 << 6) + (1 << 18),/* Helvetica-BoldOblique */ + 4, /* Symbol */ + 2 + (1 << 5), /* Times-Roman */ + 2 + (1 << 5) + (1 << 18),/* Times-Bold */ + 2 + (1 << 5) + (1 << 6), /* Times-Italic */ + 2 + (1 << 5) + (1 << 6) + (1 << 18),/* Times-BoldItalic */ + 4 /* ZapfDingbats */ + /* *INDENT-ON* */ + }; + char *glyph; + struct avl_traverser t; + int fd_flags; + assert(fd != NULL && fd->fm != NULL); + + if (is_fontfile(fd->fm) && is_included(fd->fm)) + write_fontfile(pdf, fd); /* this will set |fd->ff_found| if font file is found */ + if (fd->fd_objnum == 0) + fd->fd_objnum = pdf_new_objnum(pdf); + pdf_begin_dict(pdf, fd->fd_objnum, 1); + pdf_puts(pdf, "/Type /FontDescriptor\n"); + write_fontname(pdf, fd, "FontName"); + if (fd->fm->fd_flags != FD_FLAGS_NOT_SET_IN_MAPLINE) + fd_flags = (int) fd->fm->fd_flags; + else if (fd->ff_found) + fd_flags = FD_FLAGS_DEFAULT_EMBED; + else { + fd_flags = is_std_t1font(fd->fm) + ? std_flags[check_std_t1font(fd->fm->ps_name)] + : FD_FLAGS_DEFAULT_NON_EMBED; + pdftex_warn + ("No flags specified for non-embedded font `%s' (%s) (I'm using %i): " + "fix your map entry.", + fd->fm->ps_name != NULL ? fd->fm->ps_name : "No name given", + fd->fm->tfm_name, fd_flags); + } + pdf_printf(pdf, "/Flags %i\n", fd_flags); + write_fontmetrics(pdf, fd); + if (is_cidkeyed(fd->fm)) { + if (is_type1(fd->fm)) + pdf_printf(pdf, "/FontFile3 %i 0 R\n", (int) fd->ff_objnum); + else if (is_truetype(fd->fm)) + pdf_printf(pdf, "/FontFile2 %i 0 R\n", (int) fd->ff_objnum); + else if (is_opentype(fd->fm)) + pdf_printf(pdf, "/FontFile3 %i 0 R\n", (int) fd->ff_objnum); + else + assert(0); + } else { + if (fd->ff_found) { + if (is_subsetted(fd->fm) && is_type1(fd->fm)) { + /* /CharSet is optional; names may appear in any order */ + assert(fd->gl_tree != NULL); + avl_t_init(&t, fd->gl_tree); + pdf_puts(pdf, "/CharSet ("); + for (glyph = (char *) avl_t_first(&t, fd->gl_tree); + glyph != NULL; glyph = (char *) avl_t_next(&t)) + pdf_printf(pdf, "/%s", glyph); + pdf_puts(pdf, ")\n"); + } + if (is_type1(fd->fm)) + pdf_printf(pdf, "/FontFile %i 0 R\n", (int) fd->ff_objnum); + else if (is_truetype(fd->fm)) + pdf_printf(pdf, "/FontFile2 %i 0 R\n", (int) fd->ff_objnum); + else if (is_opentype(fd->fm)) + pdf_printf(pdf, "/FontFile3 %i 0 R\n", (int) fd->ff_objnum); + else + assert(0); + } + } + /* TODO: Optional keys for CID fonts. + + The most interesting ones are + \.{/Style << /Panose <12-byte string>>>} + and + \.{/CIDSET } + the latter can be used in subsets, to give the included CIDs + as a bitmap on the whole list. + */ + pdf_end_dict(pdf); +} + +void write_fontdescriptors(PDF pdf) +{ + fd_entry *fd; + struct avl_traverser t; + if (fd_tree == NULL) + return; + avl_t_init(&t, fd_tree); + for (fd = (fd_entry *) avl_t_first(&t, fd_tree); fd != NULL; + fd = (fd_entry *) avl_t_next(&t)) + write_fontdescriptor(pdf, fd); +} + +@ +@c +void write_fontdictionary(PDF pdf, fo_entry * fo) +{ + assert(fo != NULL); + assert(fo->fm != NULL); + assert(fo->fo_objnum != 0); /* reserved as |pdf_font_num(f)| elsewhere */ + + /* write ToUnicode entry if needed */ + if (pdf->gen_tounicode > 0 && fo->fd != NULL) { + if (fo->fe != NULL) { + fo->tounicode_objnum = + write_tounicode(pdf, fo->fe->glyph_names, fo->fe->name); + } else if (is_type1(fo->fm)) { + assert(fo->fd->builtin_glyph_names != NULL); + fo->tounicode_objnum = + write_tounicode(pdf, fo->fd->builtin_glyph_names, + fo->fm->tfm_name); + } + } + pdf_begin_dict(pdf, fo->fo_objnum, 1); + pdf_puts(pdf, "/Type /Font\n"); + pdf_puts(pdf, "/Subtype /"); + if (is_type1(fo->fm)) + pdf_printf(pdf, "%s\n", "Type1"); + else if (is_truetype(fo->fm)) + pdf_printf(pdf, "%s\n", "TrueType"); + else if (is_opentype(fo->fm)) + pdf_printf(pdf, "%s\n", "Type1"); + else + assert(0); + assert(fo->fd != NULL && fo->fd->fd_objnum != 0); + write_fontname(pdf, fo->fd, "BaseFont"); + pdf_printf(pdf, "/FontDescriptor %i 0 R\n", (int) fo->fd->fd_objnum); + assert(fo->cw_objnum != 0); + pdf_printf(pdf, "/FirstChar %i\n/LastChar %i\n/Widths %i 0 R\n", + (int) fo->first_char, (int) fo->last_char, (int) fo->cw_objnum); + if ((is_type1(fo->fm) || is_opentype(fo->fm)) && fo->fe != NULL + && fo->fe->fe_objnum != 0) + pdf_printf(pdf, "/Encoding %i 0 R\n", (int) fo->fe->fe_objnum); + if (fo->tounicode_objnum != 0) + pdf_printf(pdf, "/ToUnicode %i 0 R\n", (int) fo->tounicode_objnum); + if (pdf_font_attr(fo->tex_font) != get_nullstr() && + pdf_font_attr(fo->tex_font) != 0) { + pdf_print(pdf, pdf_font_attr(fo->tex_font)); + pdf_puts(pdf, "\n"); + } + pdf_end_dict(pdf); +} + +void write_fontdictionaries(PDF pdf) +{ + fo_entry *fo; + struct avl_traverser t; + if (fo_tree == NULL) + return; + avl_t_init(&t, fo_tree); + for (fo = (fo_entry *) avl_t_first(&t, fo_tree); fo != NULL; + fo = (fo_entry *) avl_t_next(&t)) + write_fontdictionary(pdf, fo); +} + +@ Final flush of all font related stuff by call from + \.{Output fonts definitions} elsewhere + +@c +void write_fontstuff(PDF pdf) +{ + write_fontdescriptors(pdf); + write_fontencodings(pdf); /* see \.{writeenc.w} */ + write_fontdictionaries(pdf); +} + +@ +@c +static void create_fontdictionary(PDF pdf, internal_font_number f) +{ + fo_entry *fo = new_fo_entry(); + fm_entry *fm = font_map(f); + get_char_range(fo, f); /* set |fo->first_char| and |fo->last_char| from |f| */ + if (fo->last_char > 255) + fo->last_char = 255; /* added 9-4-2008, mantis \#25 */ + assert(fo->last_char >= fo->first_char); + fo->fm = fm; + fo->fo_objnum = pdf_font_num(f); + fo->tex_font = f; + if (is_reencoded(fo->fm)) { /* at least the map entry tells so */ + fo->fe = get_fe_entry(fo->fm->encname); /* returns |NULL| if .enc file couldn't be opened */ + if (fo->fe != NULL && (is_type1(fo->fm) || is_opentype(fo->fm))) { + if (fo->fe->fe_objnum == 0) + fo->fe->fe_objnum = pdf_new_objnum(pdf); /* then it will be written out */ + /* mark encoding pairs used by TeX to optimize encoding vector */ + fo->fe->tx_tree = mark_chars(fo, fo->fe->tx_tree, f); + } + } + fo->tx_tree = mark_chars(fo, fo->tx_tree, f); /* for |write_charwidth_array| */ + write_charwidth_array(pdf, fo, f); + if (!is_builtin(fo->fm)) { + if (is_type1(fo->fm)) { + if ((fo->fd = lookup_fontdescriptor(fo)) == NULL) { + create_fontdescriptor(fo, f); + register_fd_entry(fo->fd); + } + } else + create_fontdescriptor(fo, f); + if (fo->fe != NULL) { + mark_reenc_glyphs(fo, f); + if (!is_type1(fo->fm)) { + /* mark reencoded characters as chars on TeX level */ + assert(fo->fd->tx_tree == NULL); + fo->fd->tx_tree = mark_chars(fo, fo->fd->tx_tree, f); + if (is_truetype(fo->fm)) + fo->fd->write_ttf_glyph_names = true; + } + } else + /* mark non-reencoded characters as chars on TeX level */ + fo->fd->tx_tree = mark_chars(fo, fo->fd->tx_tree, f); + if (!is_type1(fo->fm)) + write_fontdescriptor(pdf, fo->fd); + } else { + /* builtin fonts still need the /Widths array and /FontDescriptor + * (to avoid error 'font FOO contains bad /BBox') + */ + create_fontdescriptor(fo, f); + write_fontdescriptor(pdf, fo->fd); + if (!is_std_t1font(fo->fm)) + pdftex_warn("font `%s' is not a standard font; " + "I suppose it is available to your PDF viewer then", + fo->fm->ps_name); + } + if (is_type1(fo->fm)) + register_fo_entry(fo); + else + write_fontdictionary(pdf, fo); +} + +@ +@c +static int has_ttf_outlines(fm_entry * fm) +{ + FILE *f = fopen(fm->ff_name, "rb"); + if (f != NULL) { + int ch1 = getc(f); + int ch2 = getc(f); + int ch3 = getc(f); + int ch4 = getc(f); + fclose(f); + if (ch1 == 'O' && ch2 == 'T' && ch3 == 'T' && ch4 == 'O') + return 0; + return 1; + } + return 0; +} + +void do_pdf_font(PDF pdf, internal_font_number f) +{ + int del_file = 0; + fm_entry *fm; + /* TODO This is not 100\% true: CID is actually needed whenever (and + only) there are more than 256 separate glyphs used. But for + now, just assume the user knows what he is doing; + */ + if (!font_has_subset(f)) + return; + + if (font_encodingbytes(f) == 2) { + /* Create a virtual font map entry, as this is needed by the + rest of the font inclusion mechanism. + */ + fm = font_map(f) = new_fm_entry(); + fm->tfm_name = font_name(f); /* or whatever, not a real tfm */ + fm->ff_name = font_filename(f); /* the actual file */ + if (font_psname(f) != NULL) + fm->ps_name = font_psname(f); /* the true name */ + else + fm->ps_name = font_fullname(f); /* the true name */ + if (fm->ff_name + && strlen(fm->ff_name) >= 6 + && strstr(fm->ff_name, + ".dfont") == (fm->ff_name + strlen(fm->ff_name) - 6)) { + /* In case of a .dfont, we will extract the correct ttf here, + and adjust |fm->ff_name| to point to the temporary file. + This file will be deleted later. Todo: keep a nicer name + somewhere for the terminal message. + */ + char *s = FindResourceTtfFont(fm->ff_name, fm->ps_name); + if (s != NULL) { + fm->ff_name = s; + del_file = 1; + } else { + pdftex_fail + ("writefont.c: The file (%s) does not contain font `%s'", + fm->ff_name, fm->ps_name); + } + } + fm->encname = font_encodingname(f); /* for the CIDSystemInfo */ + fm->slant = font_slant(f); /* slant factor */ + set_slantset(fm); + fm->extend = font_extend(f); /* extension factor */ + set_extendset(fm); + fm->fd_flags = 4; /* can perhaps be done better */ + set_inuse(fm); + + switch (font_format(f)) { + case opentype_format: + if (has_ttf_outlines(fm)) { + set_truetype(fm); + } else { + set_opentype(fm); + } + break; + case truetype_format: + set_truetype(fm); + break; + case type1_format: + set_type1(fm); + break; + default: + pdftex_fail + ("writefont.c: The file format (%s) for font `%s' is incompatible with wide characters\n", + font_format_name(f), font_name(f)); + } + /* This makes "unknown" default to subsetted inclusion */ + if (font_embedding(f) != no_embedding) { + set_included(fm); + if (font_embedding(f) != full_embedding) { + set_subsetted(fm); + } + } + set_cidkeyed(fm); + create_cid_fontdictionary(pdf, f); + + if (del_file) + unlink(fm->ff_name); + + } else { + /* by now |font_map(f)|, if any, should have been set via |pdf_init_font()| */ + if ((fm = font_map(f)) == NULL + || (fm->ps_name == NULL && fm->ff_name == NULL)) + writet3(pdf, f); + else + create_fontdictionary(pdf, f); + } +} + +@ The glyph width is included in |glw_entry|, because that width + depends on the value it has in the font where it is actually + typeset from, not the font that is the 'owner' of the fd entry. + + TODO: It is possible that the user messes with the metric width, + but handling that properly would require access to the 'hmtx' table + at this point in the program. + +@c +int comp_glw_entry(const void *pa, const void *pb, void *p + __attribute__ ((unused))) +{ + unsigned short i, j; + + i = (unsigned short) (*(const glw_entry *) pa).id; + j = (unsigned short) (*(const glw_entry *) pb).id; + cmp_return(i, j); + return 0; +} + +void create_cid_fontdescriptor(fo_entry * fo, internal_font_number f) +{ + assert(fo != NULL); + assert(fo->fm != NULL); + assert(fo->fd == NULL); + fo->fd = new_fd_entry(); + preset_fontname(fo, f); + preset_fontmetrics(fo->fd, f); + fo->fd->fe = fo->fe; /* encoding needed by TrueType writing */ + fo->fd->fm = fo->fm; /* map entry needed by TrueType writing */ + fo->fd->gl_tree = avl_create(comp_glw_entry, NULL, &avl_xallocator); + assert(fo->fd->gl_tree != NULL); +} + + +@ The values |font_bc()| and |font_ec()| are potentially large + character ids, but the strings that are written out use CID + indexes, and those are limited to 16-bit values. + +@c +static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f) +{ + int i, k, l; + glw_entry *j; + void *aa; + for (k = 1; k <= max_font_id(); k++) { + if (k == f || -f == pdf_font_num(k)) { + l = font_size(k); + for (i = font_bc(k); i <= font_ec(k); i++) { + if (quick_char_exists(k, i) && char_used(k, i)) { + j = xtalloc(1, glw_entry); + j->id = (unsigned) char_index(k, i); + j->wd = divide_scaled_n(char_width(k, i), l, 10000.0); + if ((glw_entry *) avl_find(fo->fd->gl_tree, j) == NULL) { + aa = avl_probe(fo->fd->gl_tree, j); + assert(aa != NULL); + } else { + xfree(j); + } + } + } + } + } +} + + +@ It is possible to compress the widths array even better, by using the + alternate 'range' syntax and possibly even using /DW to set + a default value. + + There is a some optimization here already: glyphs that are + not used do not appear in the widths array at all. + + We have to make sure that we do not output an (incorrect!) + width for a character that exists in the font, but is not used + in typesetting. An enormous negative width is used as sentinel value + +@c +static void write_cid_charwidth_array(PDF pdf, fo_entry * fo) +{ + int i, j; + glw_entry *glyph; + struct avl_traverser t; + + assert(fo->cw_objnum == 0); + fo->cw_objnum = pdf_new_objnum(pdf); + pdf_begin_obj(pdf, fo->cw_objnum, 1); + avl_t_init(&t, fo->fd->gl_tree); + glyph = (glw_entry *) avl_t_first(&t, fo->fd->gl_tree); + assert(glyph != NULL); + i = (int) glyph->id; + pdf_printf(pdf, "[ %i [", i); + for (; glyph != NULL; glyph = (glw_entry *) avl_t_next(&t)) { + j = glyph->wd; + if (glyph->id > (unsigned) (i + 1)) { + pdf_printf(pdf, "] %i [", glyph->id); + j = glyph->wd; + } + if (glyph->id == (unsigned) (i + 1)) + pdf_puts(pdf, " "); + + if (j < 0) { + pdf_puts(pdf, "-"); + j = -j; + } + + pdf_printf(pdf, "%i", (j / 10)); + if ((j % 10) != 0) + pdf_printf(pdf, ".%i", (j % 10)); + + i = (int) glyph->id; + } + pdf_puts(pdf, "]]\n"); + pdf_end_obj(pdf); +} + +static void create_cid_fontdictionary(PDF pdf, internal_font_number f) +{ + fm_entry *fm = font_map(f); + fo_entry *fo = new_fo_entry(); + get_char_range(fo, f); /* set |fo->first_char| and |fo->last_char| from |f| */ + assert(fo->last_char >= fo->first_char); + fo->fm = fm; + fo->fo_objnum = pdf_font_num(f); + fo->tex_font = f; + create_cid_fontdescriptor(fo, f); + mark_cid_subset_glyphs(fo, f); + if (is_subsetted(fo->fm)) { + /* + this is a bit sneaky. |make_subset_tag()| actually expects the glyph tree + to contain strings instead of |glw_entry| items. However, all calculations + are done using explicit typecasts, so it works out ok. + */ + make_subset_tag(fo->fd); + } + write_cid_charwidth_array(pdf, fo); + write_fontdescriptor(pdf, fo->fd); + + write_cid_fontdictionary(pdf, fo, f); + xfree(fo); +} + +@ @c +void write_cid_fontdictionary(PDF pdf, fo_entry * fo, internal_font_number f) +{ + int i; + + fo->tounicode_objnum = write_cid_tounicode(pdf, fo, f); + + pdf_begin_dict(pdf, fo->fo_objnum, 1); + pdf_puts(pdf, "/Type /Font\n"); + pdf_puts(pdf, "/Subtype /Type0\n"); + pdf_puts(pdf, "/Encoding /Identity-H\n"); + write_fontname(pdf, fo->fd, "BaseFont"); + i = pdf_new_objnum(pdf); + pdf_printf(pdf, "/DescendantFonts [%i 0 R]\n", i); + /* todo: the ToUnicode CMap */ + if (fo->tounicode_objnum != 0) + pdf_printf(pdf, "/ToUnicode %i 0 R\n", (int) fo->tounicode_objnum); + + pdf_end_dict(pdf); + + pdf_begin_dict(pdf, i, 1); + pdf_puts(pdf, "/Type /Font\n"); + if (is_opentype(fo->fm) || is_type1(fo->fm)) { + pdf_puts(pdf, "/Subtype /CIDFontType0\n"); + } else { + pdf_puts(pdf, "/Subtype /CIDFontType2\n"); + pdf_printf(pdf, "/CIDToGIDMap /Identity\n"); + } + write_fontname(pdf, fo->fd, "BaseFont"); + pdf_printf(pdf, "/FontDescriptor %i 0 R\n", (int) fo->fd->fd_objnum); + pdf_printf(pdf, "/W %i 0 R\n", (int) fo->cw_objnum); + pdf_printf(pdf, "/CIDSystemInfo <<\n"); + pdf_printf(pdf, "/Registry (%s)\n", + (font_cidregistry(f) ? font_cidregistry(f) : "Adobe")); + pdf_printf(pdf, "/Ordering (%s)\n", + (font_cidordering(f) ? font_cidordering(f) : "Identity")); + pdf_printf(pdf, "/Supplement %u\n", (unsigned int) font_cidsupplement(f)); + pdf_printf(pdf, ">>\n"); + + /* I doubt there is anything useful that could be written here */ +#if 0 + if (pdf_font_attr(fo->tex_font) != get_nullstr()) { + pdf_print(pdf_font_attr(fo->tex_font)); + pdf_puts(pdf,"\n"); + } +#endif + pdf_end_dict(pdf); +} diff --git a/Build/source/texk/web2c/luatexdir/font/writet1.c b/Build/source/texk/web2c/luatexdir/font/writet1.c deleted file mode 100644 index 01881ccbb52..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writet1.c +++ /dev/null @@ -1,1814 +0,0 @@ -/* writet1.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include -#include "luatex-api.h" - -static const char _svn_version[] = - "$Id: writet1.c 2599 2009-06-25 10:35:26Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writet1.c $"; - -#define t1_log(str) if(tracefilenames) tex_printf("%s", str) -#define get_length1() t1_length1 = t1_offset() - t1_save_offset -#define get_length2() t1_length2 = t1_offset() - t1_save_offset -#define get_length3() t1_length3 = fixedcontent? t1_offset() - t1_save_offset : 0 -#define save_offset() t1_save_offset = t1_offset() - -#define t1_putchar fb_putchar -#define t1_offset fb_offset -#define out_eexec_char t1_putchar - -#define end_last_eexec_line() \ - t1_eexec_encrypt = false -#define t1_char(c) c -#define embed_all_glyphs(tex_font) fm_cur->all_glyphs -#define extra_charset() fm_cur->charset -#define update_subset_tag() \ - strncpy(fb_array + t1_fontname_offset, fm_cur->subset_tag, 6) -#define fixedcontent false - -integer t1_length1, t1_length2, t1_length3; -static integer t1_save_offset; -static integer t1_fontname_offset; - -static unsigned char *t1_buffer = NULL; -static integer t1_size = 0; -static integer t1_curbyte = 0; - -#define t1_read_file() \ - readbinfile(t1_file,&t1_buffer,&t1_size) -#define t1_close() xfclose(t1_file,cur_file_name) -#define t1_getchar() t1_buffer[t1_curbyte++] -#define t1_ungetchar(c) t1_curbyte-- -#define t1_eof() (t1_curbyte>t1_size) - -#define t1_prefix(s) str_prefix(t1_line_array, s) -#define t1_buf_prefix(s) str_prefix(t1_buf_array, s) -#define t1_suffix(s) str_suffix(t1_line_array, t1_line_ptr, s) -#define t1_buf_suffix(s) str_suffix(t1_buf_array, t1_buf_ptr, s) -#define t1_charstrings() strstr(t1_line_array, charstringname) -#define t1_subrs() t1_prefix("/Subrs") -#define t1_end_eexec() t1_suffix("mark currentfile closefile") -#define t1_cleartomark() t1_prefix("cleartomark") - -static unsigned char *enc_buffer = NULL; -static integer enc_size = 0; -static integer enc_curbyte = 0; - -#define enc_open() \ - (enc_file = fopen((char *)nameoffile+1, FOPEN_RBIN_MODE)) -#define enc_read_file() \ - readbinfile(enc_file,&enc_buffer,&enc_size) -#define enc_close() xfclose(enc_file,cur_file_name) -#define enc_getchar() enc_buffer[enc_curbyte++] -#define enc_eof() (enc_curbyte>enc_size) - -#define valid_code(c) (c >= 0 && c < 256) -#define fixedcontent false - -static const char *standard_glyph_names[256] = { - /* 0x00 */ - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, - /* 0x10 */ - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, - /* 0x20 */ - "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", - "ampersand", "quoteright", "parenleft", "parenright", "asterisk", - "plus", "comma", "hyphen", "period", "slash", - /* 0x30 */ - "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", - "nine", "colon", "semicolon", "less", "equal", "greater", "question", - /* 0x40 */ - "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", - "O", - /* 0x50 */ - "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", - "backslash", "bracketright", "asciicircum", "underscore", - /* 0x60 */ - "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", - "m", "n", "o", - /* 0x70 */ - "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", - "braceright", "asciitilde", notdef, - /* 0x80 */ - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, - /* 0x90 */ - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, - /* 0xa0 */ - notdef, "exclamdown", "cent", "sterling", "fraction", "yen", "florin", - "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", - "guilsinglleft", "guilsinglright", "fi", "fl", - /* 0xb0 */ - notdef, "endash", "dagger", "daggerdbl", "periodcentered", notdef, - "paragraph", "bullet", "quotesinglbase", "quotedblbase", - "quotedblright", "guillemotright", "ellipsis", "perthousand", notdef, - "questiondown", - /* 0xc0 */ - notdef, "grave", "acute", "circumflex", "tilde", "macron", "breve", - "dotaccent", "dieresis", notdef, - "ring", "cedilla", notdef, "hungarumlaut", "ogonek", "caron", - /* 0xd0 */ - "emdash", notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, - /* 0xe0 */ - notdef, "AE", notdef, "ordfeminine", notdef, notdef, notdef, notdef, - "Lslash", "Oslash", "OE", "ordmasculine", notdef, notdef, notdef, - notdef, - /* 0xf0 */ - notdef, "ae", notdef, notdef, notdef, "dotlessi", notdef, notdef, "lslash", - "oslash", "oe", "germandbls", notdef, notdef, notdef, notdef -}; - -static fd_entry *fd_cur; - -static char charstringname[] = "/CharStrings"; - -enum { ENC_STANDARD, ENC_BUILTIN } t1_encoding; - -#define T1_BUF_SIZE 0x10 -#define ENC_BUF_SIZE 0x1000 - -#define CS_HSTEM 1 -#define CS_VSTEM 3 -#define CS_VMOVETO 4 -#define CS_RLINETO 5 -#define CS_HLINETO 6 -#define CS_VLINETO 7 -#define CS_RRCURVETO 8 -#define CS_CLOSEPATH 9 -#define CS_CALLSUBR 10 -#define CS_RETURN 11 -#define CS_ESCAPE 12 -#define CS_HSBW 13 -#define CS_ENDCHAR 14 -#define CS_RMOVETO 21 -#define CS_HMOVETO 22 -#define CS_VHCURVETO 30 -#define CS_HVCURVETO 31 -#define CS_1BYTE_MAX (CS_HVCURVETO + 1) - -#define CS_DOTSECTION CS_1BYTE_MAX + 0 -#define CS_VSTEM3 CS_1BYTE_MAX + 1 -#define CS_HSTEM3 CS_1BYTE_MAX + 2 -#define CS_SEAC CS_1BYTE_MAX + 6 -#define CS_SBW CS_1BYTE_MAX + 7 -#define CS_DIV CS_1BYTE_MAX + 12 -#define CS_CALLOTHERSUBR CS_1BYTE_MAX + 16 -#define CS_POP CS_1BYTE_MAX + 17 -#define CS_SETCURRENTPOINT CS_1BYTE_MAX + 33 -#define CS_2BYTE_MAX (CS_SETCURRENTPOINT + 1) -#define CS_MAX CS_2BYTE_MAX - -typedef unsigned char byte; - -typedef struct { - byte nargs; /* number of arguments */ - boolean bottom; /* take arguments from bottom of stack? */ - boolean clear; /* clear stack? */ - boolean valid; -} cc_entry; /* CharString Command */ - -typedef struct { - char *name; /* glyph name (or notdef for Subrs entry) */ - byte *data; - unsigned short len; /* length of the whole string */ - unsigned short cslen; /* length of the encoded part of the string */ - boolean used; - boolean valid; -} cs_entry; - -static unsigned short t1_dr, t1_er; -static const unsigned short t1_c1 = 52845, t1_c2 = 22719; -static unsigned short t1_cslen; -static short t1_lenIV; -static char enc_line[ENC_BUF_SIZE]; - -/* define t1_line_ptr, t1_line_array & t1_line_limit */ -typedef char t1_line_entry; -define_array(t1_line); - -/* define t1_buf_ptr, t1_buf_array & t1_buf_limit */ -typedef char t1_buf_entry; -define_array(t1_buf); - -static int cs_start; - -static cs_entry *cs_tab, *cs_ptr, *cs_notdef; -static char *cs_dict_start, *cs_dict_end; -static int cs_counter, cs_size, cs_size_pos; - -static cs_entry *subr_tab; -static char *subr_array_start, *subr_array_end; -static int subr_max, subr_size, subr_size_pos; - -/* This list contains the begin/end tokens commonly used in the */ -/* /Subrs array of a Type 1 font. */ - -static const char *cs_token_pairs_list[][2] = { - {" RD", "NP"}, - {" -|", "|"}, - {" RD", "noaccess put"}, - {" -|", "noaccess put"}, - {NULL, NULL} -}; -static const char **cs_token_pair; - -static boolean t1_pfa, t1_cs, t1_scan, t1_eexec_encrypt, t1_synthetic; -static int t1_in_eexec; /* 0 before eexec-encrypted, 1 during, 2 after */ -static long t1_block_length; -static int last_hexbyte; -static FILE *t1_file; -static FILE *enc_file; - -static void enc_getline(void) -{ - char *p; - int c; - restart: - if (enc_eof()) - pdftex_fail("unexpected end of file"); - p = enc_line; - do { - c = enc_getchar(); - append_char_to_buf(c, p, enc_line, ENC_BUF_SIZE); - } - while (c != 10 && !enc_eof()); - append_eol(p, enc_line, ENC_BUF_SIZE); - if (p - enc_line < 2 || *enc_line == '%') - goto restart; -} - -/* read encoding from .enc file, return glyph_names array, or pdffail() */ - -char **load_enc_file(char *enc_name) -{ - int callback_id = 0; - int file_opened = 0; - char *ftemp = NULL; - char buf[ENC_BUF_SIZE], *p, *r; - int i, names_count; - char **glyph_names; - char *tempname; - set_cur_file_name(enc_name); - callback_id = callback_defined(find_enc_file_callback); - if (callback_id > 0) { - if (run_callback - (callback_id, "S->S", (char *) (nameoffile + 1), &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } else { - pdftex_fail("cannot find encoding file for reading"); - } - } - } else { - ftemp = kpse_find_file((char *) (nameoffile + 1), kpse_enc_format, 0); - if (ftemp == NULL) { - pdftex_fail("cannot find encoding file for reading"); - } else { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } - } - callback_id = callback_defined(read_enc_file_callback); - enc_curbyte = 0; - enc_size = 0; - if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", (char *) (nameoffile + 1), - &file_opened, &enc_buffer, &enc_size)) { - if ((!file_opened) || enc_size == 0) { - pdftex_fail("cannot open encoding file for reading"); - } - } - } else { - if (!enc_open()) { - pdftex_fail("cannot open encoding file for reading"); - } - enc_read_file(); - enc_close(); - } - glyph_names = xtalloc(256, char *); - for (i = 0; i < 256; i++) - glyph_names[i] = (char *) notdef; - t1_log("{"); - - tempname = xmalloc(namelength + 2); - strcpy(tempname, (char *) (nameoffile + 1)); - set_cur_file_name(tempname); - t1_log(cur_file_name); - enc_getline(); - if (*enc_line != '/' || (r = strchr(enc_line, '[')) == NULL) { - remove_eol(r, enc_line); - pdftex_fail - ("invalid encoding vector (a name or `[' missing): `%s'", enc_line); - } - names_count = 0; - r++; /* skip '[' */ - skip(r, ' '); - for (;;) { - while (*r == '/') { - for (p = buf, r++; - *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); - *p = 0; - skip(r, ' '); - if (names_count > 256) - pdftex_fail("encoding vector contains more than 256 names"); - if (strcmp(buf, notdef) != 0) - glyph_names[names_count] = xstrdup(buf); - names_count++; - } - if (*r != 10 && *r != '%') { - if (strncmp(r, "] def", strlen("] def")) == 0) - goto done; - else { - remove_eol(r, enc_line); - pdftex_fail - ("invalid encoding vector: a name or `] def' expected: `%s'", - enc_line); - } - } - enc_getline(); - r = enc_line; - } - done: - t1_log("}"); - cur_file_name = NULL; - xfree(enc_buffer); - return glyph_names; -} - -#if 0 /* unused */ -static void free_glyph_names(char **glyph_names) -{ - int i; - assert(glyph_names != NULL); - for (i = 0; i < 256; i++) - if (glyph_names[i] != notdef) - xfree(glyph_names[i]); - xfree(glyph_names); -} -#endif - - -static void t1_check_pfa(void) -{ - const int c = t1_getchar(); - t1_pfa = (c != 128) ? true : false; - t1_ungetchar(c); -} - -static int t1_getbyte(void) -{ - int c = t1_getchar(); - if (t1_pfa) - return c; - if (t1_block_length == 0) { - if (c != 128) - pdftex_fail("invalid marker"); - c = t1_getchar(); - if (c == 3) { - while (!t1_eof()) - (void) t1_getchar(); - return EOF; - } - t1_block_length = t1_getchar() & 0xff; - t1_block_length |= (t1_getchar() & 0xff) << 8; - t1_block_length |= (t1_getchar() & 0xff) << 16; - t1_block_length |= (t1_getchar() & 0xff) << 24; - c = t1_getchar(); - } - t1_block_length--; - return c; -} - -static int hexval(int c) -{ - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - else if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - else if (c >= '0' && c <= '9') - return c - '0'; - else - return -1; -} - -static byte edecrypt(byte cipher) -{ - byte plain; - if (t1_pfa) { - while (cipher == 10 || cipher == 13) - cipher = t1_getbyte(); - last_hexbyte = cipher = (hexval(cipher) << 4) + hexval(t1_getbyte()); - } - plain = (cipher ^ (t1_dr >> 8)); - t1_dr = (cipher + t1_dr) * t1_c1 + t1_c2; - return plain; -} - -static byte cdecrypt(byte cipher, unsigned short *cr) -{ - const byte plain = (cipher ^ (*cr >> 8)); - *cr = (cipher + *cr) * t1_c1 + t1_c2; - return plain; -} - -static byte eencrypt(byte plain) -{ - const byte cipher = (plain ^ (t1_er >> 8)); - t1_er = (cipher + t1_er) * t1_c1 + t1_c2; - return cipher; -} - -static byte cencrypt(byte plain, unsigned short *cr) -{ - const byte cipher = (plain ^ (*cr >> 8)); - *cr = (cipher + *cr) * t1_c1 + t1_c2; - return cipher; -} - -static char *eol(char *s) -{ - char *p = strend(s); - if (p - s > 1 && p[-1] != 10) { - *p++ = 10; - *p = 0; - } - return p; -} - -static float t1_scan_num(char *p, char **r) -{ - float f; - skip(p, ' '); - if (sscanf(p, "%g", &f) != 1) { - remove_eol(p, t1_line_array); - pdftex_fail("a number expected: `%s'", t1_line_array); - } - if (r != NULL) { - for (; isdigit(*p) || *p == '.' || - *p == 'e' || *p == 'E' || *p == '+' || *p == '-'; p++); - *r = p; - } - return f; -} - -static boolean str_suffix(const char *begin_buf, const char *end_buf, - const char *s) -{ - const char *s1 = end_buf - 1, *s2 = strend(s) - 1; - if (*s1 == 10) - s1--; - while (s1 >= begin_buf && s2 >= s) { - if (*s1-- != *s2--) - return false; - } - return s2 < s; -} - -static void t1_getline(void) -{ - int c, l, eexec_scan; - char *p; - static const char eexec_str[] = "currentfile eexec"; - static int eexec_len = 17; /* strlen(eexec_str) */ - restart: - if (t1_eof()) - pdftex_fail("unexpected end of file"); - t1_line_ptr = t1_line_array; - alloc_array(t1_line, 1, T1_BUF_SIZE); - t1_cslen = 0; - eexec_scan = 0; - c = t1_getbyte(); - if (c == EOF) - goto exit; - while (!t1_eof()) { - if (t1_in_eexec == 1) - c = edecrypt(c); - alloc_array(t1_line, 1, T1_BUF_SIZE); - append_char_to_buf(c, t1_line_ptr, t1_line_array, t1_line_limit); - if (t1_in_eexec == 0 && eexec_scan >= 0 && eexec_scan < eexec_len) { - if (t1_line_array[eexec_scan] == eexec_str[eexec_scan]) - eexec_scan++; - else - eexec_scan = -1; - } - if (c == 10 || (t1_pfa && eexec_scan == eexec_len && c == 32)) - break; - if (t1_cs && t1_cslen == 0 && (t1_line_ptr - t1_line_array > 4) && - (t1_suffix(" RD ") || t1_suffix(" -| "))) { - p = t1_line_ptr - 5; - while (*p != ' ') - p--; - t1_cslen = l = t1_scan_num(p + 1, 0); - cs_start = t1_line_ptr - t1_line_array; /* cs_start is an index now */ - alloc_array(t1_line, l, T1_BUF_SIZE); - while (l-- > 0) - *t1_line_ptr++ = edecrypt(t1_getbyte()); - } - c = t1_getbyte(); - } - alloc_array(t1_line, 2, T1_BUF_SIZE); /* append_eol can append 2 chars */ - append_eol(t1_line_ptr, t1_line_array, t1_line_limit); - if (t1_line_ptr - t1_line_array < 2) - goto restart; - if (eexec_scan == eexec_len) - t1_in_eexec = 1; - exit: - /* ensure that t1_buf_array has as much room as t1_line_array */ - t1_buf_ptr = t1_buf_array; - alloc_array(t1_buf, t1_line_limit, t1_line_limit); -} - -static void t1_putline(void) -{ - char *p = t1_line_array; - if (t1_line_ptr - t1_line_array <= 1) - return; - if (t1_eexec_encrypt) { - while (p < t1_line_ptr) - t1_putchar(eencrypt(*p++)); - } else - while (p < t1_line_ptr) - t1_putchar(*p++); -} - -static void t1_puts(const char *s) -{ - if (s != t1_line_array) - strcpy(t1_line_array, s); - t1_line_ptr = strend(t1_line_array); - t1_putline(); -} - -__attribute__ ((format(printf, 1, 2))) -static void t1_printf(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - vsprintf(t1_line_array, fmt, args); - t1_puts(t1_line_array); - va_end(args); -} - -static void t1_init_params(const char *open_name_prefix) -{ - t1_log(open_name_prefix); - t1_log(cur_file_name); - t1_lenIV = 4; - t1_dr = 55665; - t1_er = 55665; - t1_in_eexec = 0; - t1_cs = false; - t1_scan = true; - t1_synthetic = false; - t1_eexec_encrypt = false; - t1_block_length = 0; - t1_check_pfa(); -} - -static void t1_close_font_file(const char *close_name_suffix) -{ - t1_log(close_name_suffix); - cur_file_name = NULL; -} - -static void t1_check_block_len(boolean decrypt) -{ - int l, c; - if (t1_block_length == 0) - return; - c = t1_getbyte(); - if (decrypt) - c = edecrypt(c); - l = t1_block_length; - if (!(l == 0 && (c == 10 || c == 13))) { - pdftex_fail("%i bytes more than expected were ignored", l + 1); - } -} - -static void t1_start_eexec(void) -{ - int i; - assert(is_included(fd_cur->fm)); - get_length1(); - save_offset(); - - if (!t1_pfa) - t1_check_block_len(false); - for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) { - edecrypt(t1_getbyte()); - *t1_line_ptr++ = 0; - } - t1_eexec_encrypt = true; - t1_putline(); /* to put the first four bytes */ -} - -static void t1_stop_eexec(void) -{ - int c; - assert(is_included(fd_cur->fm)); - get_length2(); - save_offset(); - t1_eexec_encrypt = false; - if (!t1_pfa) - t1_check_block_len(true); - else { - c = edecrypt(t1_getbyte()); - if (!(c == 10 || c == 13)) { - if (last_hexbyte == 0) - t1_puts("00"); - else - pdftex_fail("unexpected data after eexec"); - } - } - t1_cs = false; - t1_in_eexec = 2; -} - -/* macros for various transforms; currently only slant and extend are used */ - -#define do_xshift(x,a) {x[4]+=a;} -#define do_yshift(x,a) {x[5]+=a;} -#define do_xscale(x,a) {x[0]*=a; x[2]*=a; x[4]*=a;} -#define do_yscale(x,a) {x[1]*=a; x[3]*=a; x[5]*=a;} -#define do_extend(x,a) {do_xscale(x,a);} -#define do_scale(x,a) {do_xscale(x,a); do_yscale(x,a);} -#define do_slant(x,a) {x[0]+=x[1]*(a); x[2]+=x[3]*(a); x[4]+=x[5]*(a);} -#define do_shear(x,a) {x[1]+=x[0]*(a); x[3]+=x[2]*(a); x[5]+=x[4]*(a);} -#define do_rotate(x,a) \ - {float t, u=cos(a), v=sin(a); \ - t =x[0]*u+x[1]*-v; \ - x[1] =x[0]*v+x[1]* u; x[0]=t; \ - t =x[2]*u+x[3]*-v; \ - x[3] =x[2]*v+x[3]* u; x[2]=t; \ - t =x[4]*u+x[5]*-v; \ - x[5] =x[4]*v+x[5]* u; x[4]=t;} - -static void t1_modify_fm(void) -{ - /* - * font matrix is given as six numbers a0..a5, which stands for the matrix - * - * a0 a1 0 - * M = a2 a3 0 - * a4 a5 1 - * - * ExtendFont is given as - * - * e 0 0 - * E = 0 1 0 - * 0 0 1 - * - * SlantFont is given as - * - * 1 0 0 - * S = s 1 0 - * 0 0 1 - * - * The slant transform must be done _before_ the extend transform - * for compatibility! - */ - float a[6]; - int i, c; - char *p, *q, *r; - if ((p = strchr(t1_line_array, '[')) == 0) - if ((p = strchr(t1_line_array, '{')) == 0) { - remove_eol(p, t1_line_array); - pdftex_fail("FontMatrix: an array expected: `%s'", t1_line_array); - } - c = *p++; /* save the character '[' resp. '{' */ - strncpy(t1_buf_array, t1_line_array, (size_t) (p - t1_line_array)); - r = t1_buf_array + (p - t1_line_array); - for (i = 0; i < 6; i++) { - a[i] = t1_scan_num(p, &q); - p = q; - } - if (fm_slant(fd_cur->fm) != 0) - do_slant(a, fm_slant(fd_cur->fm) * 1E-3); - if (fm_extend(fd_cur->fm) != 0) - do_extend(a, fm_extend(fd_cur->fm) * 1E-3); - for (i = 0; i < 6; i++) { - sprintf(r, "%g ", a[i]); - r = strend(r); - } - if (c == '[') { - while (*p != ']' && *p != 0) - p++; - } else { - while (*p != '}' && *p != 0) - p++; - } - if (*p == 0) { - remove_eol(p, t1_line_array); - pdftex_fail - ("FontMatrix: cannot find the corresponding character to '%c': `%s'", - c, t1_line_array); - } - strcpy(r, p); - strcpy(t1_line_array, t1_buf_array); - t1_line_ptr = eol(t1_line_array); -} - -static void t1_modify_italic(void) -{ - float a; - char *p, *r; - if (fm_slant(fd_cur->fm) == 0) - return; - p = strchr(t1_line_array, ' '); - strncpy(t1_buf_array, t1_line_array, (size_t) (p - t1_line_array + 1)); - a = t1_scan_num(p + 1, &r); - a -= atan(fm_slant(fd_cur->fm) * 1E-3) * (180 / M_PI); - sprintf(t1_buf_array + (p - t1_line_array + 1), "%g", a); - strcpy(strend(t1_buf_array), r); - strcpy(t1_line_array, t1_buf_array); - t1_line_ptr = eol(t1_line_array); - fd_cur->font_dim[ITALIC_ANGLE_CODE].val = round(a); - fd_cur->font_dim[ITALIC_ANGLE_CODE].set = true; -} - -static void t1_scan_keys(void) -{ - int i, k; - char *p, *q, *r; - const key_entry *key; - if (fm_extend(fd_cur->fm) != 0 || fm_slant(fd_cur->fm) != 0) { - if (t1_prefix("/FontMatrix")) { - t1_modify_fm(); - return; - } - if (t1_prefix("/ItalicAngle")) { - t1_modify_italic(); - return; - } - } - if (t1_prefix("/FontType")) { - p = t1_line_array + strlen("FontType") + 1; - if ((i = t1_scan_num(p, 0)) != 1) - pdftex_fail("Type%d fonts unsupported by pdfTeX", i); - return; - } - for (key = font_key; key - font_key < FONT_KEYS_NUM; key++) { - if (key->t1name[0] != '\0' && - str_prefix(t1_line_array + 1, key->t1name)) - break; - } - if (key - font_key == FONT_KEYS_NUM) - return; - p = t1_line_array + strlen(key->t1name) + 1; - skip(p, ' '); - if ((k = key - font_key) == FONTNAME_CODE) { - if (*p != '/') { - remove_eol(p, t1_line_array); - pdftex_fail("a name expected: `%s'", t1_line_array); - } - r = ++p; /* skip the slash */ - for (q = t1_buf_array; *p != ' ' && *p != 10; *q++ = *p++); - *q = 0; - if (fm_slant(fd_cur->fm) != 0) { - sprintf(q, "-Slant_%i", (int) fm_slant(fd_cur->fm)); - q = strend(q); - } - if (fm_extend(fd_cur->fm) != 0) { - sprintf(q, "-Extend_%i", (int) fm_extend(fd_cur->fm)); - } - xfree(fd_cur->fontname); - fd_cur->fontname = xstrdup(t1_buf_array); - /* at this moment we cannot call make_subset_tag() yet, as the encoding - * is not read; thus we mark the offset of the subset tag and write it - * later */ - if (is_subsetted(fd_cur->fm)) { - assert(is_included(fd_cur->fm)); - t1_fontname_offset = t1_offset() + (r - t1_line_array); - strcpy(t1_buf_array, p); - sprintf(r, "ABCDEF+%s%s", fd_cur->fontname, t1_buf_array); - t1_line_ptr = eol(r); - } - return; - } - if ((k == STEMV_CODE || k == FONTBBOX1_CODE) - && (*p == '[' || *p == '{')) - p++; - if (k == FONTBBOX1_CODE) { - for (i = 0; i < 4; i++, k++) { - fd_cur->font_dim[k].val = t1_scan_num(p, &r); - fd_cur->font_dim[k].set = true; - p = r; - } - return; - } - fd_cur->font_dim[k].val = t1_scan_num(p, 0); - fd_cur->font_dim[k].set = true; -} - -static void t1_scan_param(void) -{ - static const char *lenIV = "/lenIV"; - if (!t1_scan || *t1_line_array != '/') - return; - if (t1_prefix(lenIV)) { - t1_lenIV = t1_scan_num(t1_line_array + strlen(lenIV), 0); - if (t1_lenIV < 0) - pdftex_fail("negative value of lenIV is not supported"); - return; - } - t1_scan_keys(); -} - -static void copy_glyph_names(char **glyph_names, int a, int b) -{ - if (glyph_names[b] != notdef) { - xfree(glyph_names[b]); - glyph_names[b] = (char *) notdef; - } - if (glyph_names[a] != notdef) { - glyph_names[b] = xstrdup(glyph_names[a]); - } -} - -/* read encoding from Type1 font file, return glyph_names array, or pdffail() */ - -static char **t1_builtin_enc(void) -{ - int i, a, b, c, counter = 0; - char *r, *p, **glyph_names; - /* At this moment "/Encoding" is the prefix of t1_line_array */ - glyph_names = xtalloc(256, char *); - for (i = 0; i < 256; i++) - glyph_names[i] = (char *) notdef; - if (t1_suffix("def")) { /* predefined encoding */ - sscanf(t1_line_array + strlen("/Encoding"), "%256s", t1_buf_array); - if (strcmp(t1_buf_array, "StandardEncoding") == 0) { - t1_encoding = ENC_STANDARD; - for (i = 0; i < 256; i++) { - if (standard_glyph_names[i] != notdef) - glyph_names[i] = xstrdup(standard_glyph_names[i]); - } - return glyph_names; - } else - pdftex_fail - ("cannot subset font (unknown predefined encoding `%s')", - t1_buf_array); - } - /* At this moment "/Encoding" is the prefix of t1_line_array, and the encoding is - * not a predefined encoding. - * - * We have two possible forms of Encoding vector. The first case is - * - * /Encoding [/a /b /c...] readonly def - * - * and the second case can look like - * - * /Encoding 256 array 0 1 255 {1 index exch /.notdef put} for - * dup 0 /x put - * dup 1 /y put - * ... - * readonly def - */ - t1_encoding = ENC_BUILTIN; - if (t1_prefix("/Encoding [") || t1_prefix("/Encoding[")) { /* the first case */ - r = strchr(t1_line_array, '[') + 1; - skip(r, ' '); - for (;;) { - while (*r == '/') { - for (p = t1_buf_array, r++; - *r != 32 && *r != 10 && *r != ']' && *r != '/'; - *p++ = *r++); - *p = 0; - skip(r, ' '); - if (counter > 255) - pdftex_fail("encoding vector contains more than 256 names"); - if (strcmp(t1_buf_array, notdef) != 0) - glyph_names[counter] = xstrdup(t1_buf_array); - counter++; - } - if (*r != 10 && *r != '%') { - if (str_prefix(r, "] def") - || str_prefix(r, "] readonly def")) - break; - else { - remove_eol(r, t1_line_array); - pdftex_fail - ("a name or `] def' or `] readonly def' expected: `%s'", - t1_line_array); - } - } - t1_getline(); - r = t1_line_array; - } - } else { /* the second case */ - p = strchr(t1_line_array, 10); - for (;;) { - if (*p == 10) { - t1_getline(); - p = t1_line_array; - } - /* - check for `dup put' - */ - if (sscanf(p, "dup %i%256s put", &i, t1_buf_array) == 2 && - *t1_buf_array == '/' && valid_code(i)) { - if (strcmp(t1_buf_array + 1, notdef) != 0) - glyph_names[i] = xstrdup(t1_buf_array + 1); - p = strstr(p, " put") + strlen(" put"); - skip(p, ' '); - } - /* - check for `dup dup exch get put' - */ - else if (sscanf(p, "dup dup %i exch %i get put", &b, &a) == 2 - && valid_code(a) && valid_code(b)) { - copy_glyph_names(glyph_names, a, b); - p = strstr(p, " get put") + strlen(" get put"); - skip(p, ' '); - } - /* - check for `dup dup getinterval exch putinterval' - */ - else if (sscanf - (p, "dup dup %i %i getinterval %i exch putinterval", - &a, &c, &b) == 3 && valid_code(a) && valid_code(b) - && valid_code(c)) { - for (i = 0; i < c; i++) - copy_glyph_names(glyph_names, a + i, b + i); - p = strstr(p, " putinterval") + strlen(" putinterval"); - skip(p, ' '); - } - /* - check for `def' or `readonly def' - */ - else if ((p == t1_line_array || (p > t1_line_array && p[-1] == ' ')) - && strcmp(p, "def\n") == 0) - return glyph_names; - /* - skip an unrecognizable word - */ - else { - while (*p != ' ' && *p != 10) - p++; - skip(p, ' '); - } - } - } - return glyph_names; -} - - -static void t1_check_end(void) -{ - if (t1_eof()) - return; - t1_getline(); - if (t1_prefix("{restore}")) - t1_putline(); -} - -static boolean t1_open_fontfile(const char *open_name_prefix) -{ - int callback_id = 0; - int file_opened = 0; - char *ftemp = NULL; - ff_entry *ff; - ff = check_ff_exist(fd_cur->fm->ff_name, is_truetype(fd_cur->fm)); - t1_curbyte = 0; - t1_size = 0; - if (ff->ff_path != NULL) { - callback_id = callback_defined(find_type1_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->S", ff->ff_path, &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - strcpy(ff->ff_path, ftemp); - } - } - } - callback_id = callback_defined(read_type1_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", ff->ff_path, - &file_opened, &t1_buffer, &t1_size) - && file_opened && t1_size > 0) { - cur_file_name = ff->ff_path; - } else { - set_cur_file_name(fd_cur->fm->ff_name); - pdftex_warn("cannot open Type 1 font file for reading"); - return false; - } - } else { - t1_file = xfopen(cur_file_name = ff->ff_path, FOPEN_RBIN_MODE); - t1_read_file(); - t1_close(); - } - recorder_record_input(ff->ff_path); - } else { - set_cur_file_name(fd_cur->fm->ff_name); - pdftex_fail("cannot open Type 1 font file for reading"); - return false; - } - t1_init_params(open_name_prefix); - return true; -} - -static void t1_include(void) -{ - do { - t1_getline(); - t1_scan_param(); - t1_putline(); - } - while (t1_in_eexec == 0); - t1_start_eexec(); - do { - t1_getline(); - t1_scan_param(); - t1_putline(); - } - while (!(t1_charstrings() || t1_subrs())); - t1_cs = true; - do { - t1_getline(); - t1_putline(); - } - while (!t1_end_eexec()); - t1_stop_eexec(); - if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ - do { - t1_getline(); - t1_putline(); - } - while (!t1_cleartomark()); - t1_check_end(); /* write "{restore}if" if found */ - } - get_length3(); -} - -#define check_subr(subr) \ - if (subr >= subr_size || subr < 0) \ - pdftex_fail("Subrs array: entry index out of range (%i)", subr); - -static const char **check_cs_token_pair(void) -{ - const char **p = (const char **) cs_token_pairs_list; - for (; p[0] != NULL; ++p) - if (t1_buf_prefix(p[0]) && t1_buf_suffix(p[1])) - return p; - return NULL; -} - -static void cs_store(boolean is_subr) -{ - char *p; - cs_entry *ptr; - int subr; - for (p = t1_line_array, t1_buf_ptr = t1_buf_array; *p != ' '; - *t1_buf_ptr++ = *p++); - *t1_buf_ptr = 0; - if (is_subr) { - subr = t1_scan_num(p + 1, 0); - check_subr(subr); - ptr = subr_tab + subr; - } else { - ptr = cs_ptr++; - if (cs_ptr - cs_tab > cs_size) - pdftex_fail - ("CharStrings dict: more entries than dict size (%i)", cs_size); - if (strcmp(t1_buf_array + 1, notdef) == 0) /* skip the slash */ - ptr->name = (char *) notdef; - else - ptr->name = xstrdup(t1_buf_array + 1); - } - /* copy " RD " + cs data to t1_buf_array */ - memcpy(t1_buf_array, t1_line_array + cs_start - 4, - (unsigned) (t1_cslen + 4)); - /* copy the end of cs data to t1_buf_array */ - for (p = t1_line_array + cs_start + t1_cslen, t1_buf_ptr = - t1_buf_array + t1_cslen + 4; *p != 10; *t1_buf_ptr++ = *p++); - *t1_buf_ptr++ = 10; - if (is_subr && cs_token_pair == NULL) - cs_token_pair = check_cs_token_pair(); - ptr->len = t1_buf_ptr - t1_buf_array; - ptr->cslen = t1_cslen; - xfree(ptr->data); /* mem leak? */ - ptr->data = xtalloc(ptr->len, byte); - memcpy(ptr->data, t1_buf_array, ptr->len); - ptr->valid = true; -} - -#define store_subr() cs_store(true) -#define store_cs() cs_store(false) - -#define CC_STACK_SIZE 24 - -static integer cc_stack[CC_STACK_SIZE], *stack_ptr = cc_stack; -static cc_entry cc_tab[CS_MAX]; -static boolean is_cc_init = false; - - -#define cc_pop(N) \ - if (stack_ptr - cc_stack < (N)) \ - stack_error(N); \ - stack_ptr -= N - -#define stack_error(N) { \ - pdftex_fail("CharString: invalid access (%i) to stack (%i entries)", \ - (int) N, (int)(stack_ptr - cc_stack)); \ - goto cs_error; \ -} - -/* -static integer cc_get(integer index) -{ - if (index < 0) { - if (stack_ptr + index < cc_stack ) - stack_error(stack_ptr - cc_stack + index); - return *(stack_ptr + index); - } - else { - if (cc_stack + index >= stack_ptr) - stack_error(index); - return cc_stack[index]; - } -} -*/ - -#define cc_get(N) ((N) < 0 ? *(stack_ptr + (N)) : *(cc_stack + (N))) - -#define cc_push(V) *stack_ptr++ = V -#define cc_clear() stack_ptr = cc_stack - -#define set_cc(N, B, A, C) \ - cc_tab[N].nargs = A; \ - cc_tab[N].bottom = B; \ - cc_tab[N].clear = C; \ - cc_tab[N].valid = true - -static void cc_init(void) -{ - int i; - if (is_cc_init) - return; - for (i = 0; i < CS_MAX; i++) - cc_tab[i].valid = false; - set_cc(CS_HSTEM, true, 2, true); - set_cc(CS_VSTEM, true, 2, true); - set_cc(CS_VMOVETO, true, 1, true); - set_cc(CS_RLINETO, true, 2, true); - set_cc(CS_HLINETO, true, 1, true); - set_cc(CS_VLINETO, true, 1, true); - set_cc(CS_RRCURVETO, true, 6, true); - set_cc(CS_CLOSEPATH, false, 0, true); - set_cc(CS_CALLSUBR, false, 1, false); - set_cc(CS_RETURN, false, 0, false); - /* - set_cc(CS_ESCAPE, false, 0, false); - */ - set_cc(CS_HSBW, true, 2, true); - set_cc(CS_ENDCHAR, false, 0, true); - set_cc(CS_RMOVETO, true, 2, true); - set_cc(CS_HMOVETO, true, 1, true); - set_cc(CS_VHCURVETO, true, 4, true); - set_cc(CS_HVCURVETO, true, 4, true); - set_cc(CS_DOTSECTION, false, 0, true); - set_cc(CS_VSTEM3, true, 6, true); - set_cc(CS_HSTEM3, true, 6, true); - set_cc(CS_SEAC, true, 5, true); - set_cc(CS_SBW, true, 4, true); - set_cc(CS_DIV, false, 2, false); - set_cc(CS_CALLOTHERSUBR, false, 0, false); - set_cc(CS_POP, false, 0, false); - set_cc(CS_SETCURRENTPOINT, true, 2, true); - is_cc_init = true; -} - -#define cs_getchar() cdecrypt(*data++, &cr) - -#define mark_subr(n) cs_mark(0, n) -#define mark_cs(s) cs_mark(s, 0) - -__attribute__ ((format(printf, 3, 4))) -static void cs_fail(const char *cs_name, int subr, const char *fmt, ...) -{ - char buf[SMALL_BUF_SIZE]; - va_list args; - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); - if (cs_name == NULL) - pdftex_fail("Subr (%i): %s", (int) subr, buf); - else - pdftex_fail("CharString (/%s): %s", cs_name, buf); -} - -/* fix a return-less subr by appending CS_RETURN */ -static void append_cs_return(cs_entry * ptr) -{ - unsigned short cr; - int i; - byte *p, *q, *data, *new_data; - assert(ptr != NULL && ptr->valid && ptr->used); - - /* decrypt the cs data to t1_buf_array, append CS_RETURN */ - p = (byte *) t1_buf_array; - data = ptr->data + 4; - cr = 4330; - for (i = 0; i < ptr->cslen; i++) - *p++ = cs_getchar(); - *p = CS_RETURN; - - /* encrypt the new cs data to new_data */ - new_data = xtalloc(ptr->len + 1, byte); - memcpy(new_data, ptr->data, 4); - p = new_data + 4; - q = (byte *) t1_buf_array; - cr = 4330; - for (i = 0; i < ptr->cslen + 1; i++) - *p++ = cencrypt(*q++, &cr); - memcpy(p, ptr->data + 4 + ptr->cslen, ptr->len - ptr->cslen - 4); - - /* update *ptr */ - xfree(ptr->data); - ptr->data = new_data; - ptr->len++; - ptr->cslen++; -} - -static void cs_mark(const char *cs_name, int subr) -{ - byte *data; - int i, b, cs_len; - int last_cmd = 0; - integer a, a1, a2; - unsigned short cr; - static integer lastargOtherSubr3 = 3; /* the argument of last call to - OtherSubrs[3] */ - cs_entry *ptr; - cc_entry *cc; - if (cs_name == NULL) { - check_subr(subr); - ptr = subr_tab + subr; - if (!ptr->valid) - return; - } else { - if (cs_notdef != NULL && - (cs_name == notdef || strcmp(cs_name, notdef) == 0)) - ptr = cs_notdef; - else { - for (ptr = cs_tab; ptr < cs_ptr; ptr++) - if (strcmp(ptr->name, cs_name) == 0) - break; - if (ptr == cs_ptr) { - pdftex_warn("glyph `%s' undefined", cs_name); - return; - } - if (ptr->name == notdef) - cs_notdef = ptr; - } - } - /* only marked CharString entries and invalid entries can be skipped; - valid marked subrs must be parsed to keep the stack in sync */ - if (!ptr->valid || (ptr->used && cs_name != NULL)) - return; - ptr->used = true; - cr = 4330; - cs_len = ptr->cslen; - data = ptr->data + 4; - for (i = 0; i < t1_lenIV; i++, cs_len--) - cs_getchar(); - while (cs_len > 0) { - --cs_len; - b = cs_getchar(); - if (b >= 32) { - if (b <= 246) - a = b - 139; - else if (b <= 250) { - --cs_len; - a = ((b - 247) << 8) + 108 + cs_getchar(); - } else if (b <= 254) { - --cs_len; - a = -((b - 251) << 8) - 108 - cs_getchar(); - } else { - cs_len -= 4; - a = (cs_getchar() & 0xff) << 24; - a |= (cs_getchar() & 0xff) << 16; - a |= (cs_getchar() & 0xff) << 8; - a |= (cs_getchar() & 0xff) << 0; - if (sizeof(integer) > 4 && (a & 0x80000000)) - a |= ~0x7FFFFFFF; - } - cc_push(a); - } else { - if (b == CS_ESCAPE) { - b = cs_getchar() + CS_1BYTE_MAX; - cs_len--; - } - if (b >= CS_MAX) { - cs_fail(cs_name, subr, "command value out of range: %i", - (int) b); - goto cs_error; - } - cc = cc_tab + b; - if (!cc->valid) { - cs_fail(cs_name, subr, "command not valid: %i", (int) b); - goto cs_error; - } - if (cc->bottom) { - if (stack_ptr - cc_stack < cc->nargs) - cs_fail(cs_name, subr, - "less arguments on stack (%i) than required (%i)", - (int) (stack_ptr - cc_stack), (int) cc->nargs); - else if (stack_ptr - cc_stack > cc->nargs) - cs_fail(cs_name, subr, - "more arguments on stack (%i) than required (%i)", - (int) (stack_ptr - cc_stack), (int) cc->nargs); - } - last_cmd = b; - switch (cc - cc_tab) { - case CS_CALLSUBR: - a1 = cc_get(-1); - cc_pop(1); - mark_subr(a1); - if (!subr_tab[a1].valid) { - cs_fail(cs_name, subr, "cannot call subr (%i)", (int) a1); - goto cs_error; - } - break; - case CS_DIV: - cc_pop(2); - cc_push(0); - break; - case CS_CALLOTHERSUBR: - if (cc_get(-1) == 3) - lastargOtherSubr3 = cc_get(-3); - a1 = cc_get(-2) + 2; - cc_pop(a1); - break; - case CS_POP: - cc_push(lastargOtherSubr3); - /* the only case when we care about the value being pushed onto - stack is when POP follows CALLOTHERSUBR (changing hints by - OtherSubrs[3]) - */ - break; - case CS_SEAC: - a1 = cc_get(3); - a2 = cc_get(4); - cc_clear(); - mark_cs(standard_glyph_names[a1]); - mark_cs(standard_glyph_names[a2]); - break; - default: - if (cc->clear) - cc_clear(); - } - } - } - if (cs_name == NULL && last_cmd != CS_RETURN) { - pdftex_warn("last command in subr `%i' is not a RETURN; " - "I will add it now but please consider fixing the font", - (int) subr); - append_cs_return(ptr); - } - return; - cs_error: /* an error occured during parsing */ - cc_clear(); - ptr->valid = false; - ptr->used = false; -} - -/**********************************************************************/ -/* AVL search tree for glyph code by glyph name */ - -static int comp_t1_glyphs(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(*((const char * const *) pa), *((const char * const *) pb)); -} - -static struct avl_table *create_t1_glyph_tree(char **glyph_names) -{ - int i; - void **aa; - static struct avl_table *gl_tree; - gl_tree = avl_create(comp_t1_glyphs, NULL, &avl_xallocator); - assert(gl_tree != NULL); - for (i = 0; i < 256; i++) { - if (glyph_names[i] != notdef && - (char **) avl_find(gl_tree, &glyph_names[i]) == NULL) { - /* no strdup here, just point to the glyph_names array members */ - aa = avl_probe(gl_tree, &glyph_names[i]); - assert(aa != NULL); - } - } - return gl_tree; -} - -static void destroy_t1_glyph_tree(struct avl_table *gl_tree) -{ - assert(gl_tree != NULL); - avl_destroy(gl_tree, NULL); -} - -/**********************************************************************/ - -static void t1_subset_ascii_part(void) -{ - int j, *p; - char *glyph, **gg, **glyph_names; - struct avl_table *gl_tree; - struct avl_traverser t; - void **aa; - assert(fd_cur != NULL); - assert(fd_cur->gl_tree != NULL); - t1_getline(); - while (!t1_prefix("/Encoding")) { - t1_scan_param(); - t1_putline(); - t1_getline(); - } - glyph_names = t1_builtin_enc(); - fd_cur->builtin_glyph_names = glyph_names; - if (is_subsetted(fd_cur->fm)) { - assert(is_included(fd_cur->fm)); - if (fd_cur->tx_tree != NULL) { - /* take over collected non-reencoded characters from TeX */ - avl_t_init(&t, fd_cur->tx_tree); - for (p = (int *) avl_t_first(&t, fd_cur->tx_tree); p != NULL; - p = (int *) avl_t_next(&t)) { - if ((char *) avl_find(fd_cur->gl_tree, glyph_names[*p]) == NULL) { - glyph = xstrdup(glyph_names[*p]); - aa = avl_probe(fd_cur->gl_tree, glyph); - assert(aa != NULL); - } - } - } - make_subset_tag(fd_cur); - assert(t1_fontname_offset != 0); - strncpy(fb_array + t1_fontname_offset, fd_cur->subset_tag, 6); - } - /* now really all glyphs needed from this font are in the fd_cur->gl_tree */ - if (t1_encoding == ENC_STANDARD) - t1_puts("/Encoding StandardEncoding def\n"); - else { - t1_puts - ("/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n"); - gl_tree = create_t1_glyph_tree(glyph_names); - avl_t_init(&t, fd_cur->gl_tree); - j = 0; - for (glyph = (char *) avl_t_first(&t, fd_cur->gl_tree); glyph != NULL; - glyph = (char *) avl_t_next(&t)) { - if ((gg = (char **) avl_find(gl_tree, &glyph)) != NULL) { - t1_printf("dup %i /%s put\n", (int) (gg - glyph_names), *gg); - j++; - } - } - destroy_t1_glyph_tree(gl_tree); - if (j == 0) - /* We didn't mark anything for the Encoding array. */ - /* We add "dup 0 /.notdef put" for compatibility */ - /* with Acrobat 5.0. */ - t1_puts("dup 0 /.notdef put\n"); - t1_puts("readonly def\n"); - } - do { - t1_getline(); - t1_scan_param(); - if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */ - t1_putline(); - } - while (t1_in_eexec == 0); -} - - -static void cs_init(void) -{ - cs_ptr = cs_tab = NULL; - cs_dict_start = cs_dict_end = NULL; - cs_counter = cs_size = cs_size_pos = 0; - cs_token_pair = NULL; - subr_tab = NULL; - subr_array_start = subr_array_end = NULL; - subr_max = subr_size = subr_size_pos = 0; -} - -static void init_cs_entry(cs_entry * cs) -{ - cs->data = NULL; - cs->name = NULL; - cs->len = 0; - cs->cslen = 0; - cs->used = false; - cs->valid = false; -} - -static void t1_read_subrs(void) -{ - int i, s; - cs_entry *ptr; - t1_getline(); - while (!(t1_charstrings() || t1_subrs())) { - t1_scan_param(); - if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */ - t1_putline(); - t1_getline(); - } - found: - t1_cs = true; - t1_scan = false; - if (!t1_subrs()) - return; - subr_size_pos = strlen("/Subrs") + 1; - /* subr_size_pos points to the number indicating dict size after "/Subrs" */ - subr_size = t1_scan_num(t1_line_array + subr_size_pos, 0); - if (subr_size == 0) { - while (!t1_charstrings()) - t1_getline(); - return; - } - subr_tab = xtalloc(subr_size, cs_entry); - for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - init_cs_entry(ptr); - subr_array_start = xstrdup(t1_line_array); - t1_getline(); - while (t1_cslen) { - store_subr(); - t1_getline(); - } - /* mark the first four entries without parsing */ - for (i = 0; i < subr_size && i < 4; i++) - subr_tab[i].used = true; - /* the end of the Subrs array might have more than one line so we need to - concatnate them to subr_array_end. Unfortunately some fonts don't have - the Subrs array followed by the CharStrings dict immediately (synthetic - fonts). If we cannot find CharStrings in next POST_SUBRS_SCAN lines then - we will treat the font as synthetic and ignore everything until next - Subrs is found - */ -#define POST_SUBRS_SCAN 5 - s = 0; - *t1_buf_array = 0; - for (i = 0; i < POST_SUBRS_SCAN; i++) { - if (t1_charstrings()) - break; - s += t1_line_ptr - t1_line_array; - alloc_array(t1_buf, s, T1_BUF_SIZE); - strcat(t1_buf_array, t1_line_array); - t1_getline(); - } - subr_array_end = xstrdup(t1_buf_array); - if (i == POST_SUBRS_SCAN) { /* CharStrings not found; - suppose synthetic font */ - for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - if (ptr->valid) - xfree(ptr->data); - xfree(subr_tab); - xfree(subr_array_start); - xfree(subr_array_end); - cs_init(); - t1_cs = false; - t1_synthetic = true; - while (!(t1_charstrings() || t1_subrs())) - t1_getline(); - goto found; - } -} - -#define t1_subr_flush() t1_flush_cs(true) -#define t1_cs_flush() t1_flush_cs(false) - -static void t1_flush_cs(boolean is_subr) -{ - char *p; - byte *r, *return_cs = NULL; - cs_entry *tab, *end_tab, *ptr; - char *start_line, *line_end; - int count, size_pos; - unsigned short cr, cs_len; - if (is_subr) { - start_line = subr_array_start; - line_end = subr_array_end; - size_pos = subr_size_pos; - tab = subr_tab; - count = subr_max + 1; - end_tab = subr_tab + count; - } else { - start_line = cs_dict_start; - line_end = cs_dict_end; - size_pos = cs_size_pos; - tab = cs_tab; - end_tab = cs_ptr; - count = cs_counter; - } - t1_line_ptr = t1_line_array; - for (p = start_line; p - start_line < size_pos;) - *t1_line_ptr++ = *p++; - while (isdigit(*p)) - p++; - sprintf(t1_line_ptr, "%u", count); - strcat(t1_line_ptr, p); - t1_line_ptr = eol(t1_line_array); - t1_putline(); - - cs_len = 0; /* for -Wall */ - /* create return_cs to replace unsused subr's */ - if (is_subr) { - cr = 4330; - cs_len = 0; - /* at this point we have t1_lenIV >= 0; - * a negative value would be caught in t1_scan_param() */ - return_cs = xtalloc(t1_lenIV + 1, byte); - for (cs_len = 0, r = return_cs; cs_len < t1_lenIV; cs_len++, r++) - *r = cencrypt(0x00, &cr); - *r = cencrypt(CS_RETURN, &cr); - cs_len++; - } - - for (ptr = tab; ptr < end_tab; ptr++) { - if (ptr->used) { - if (is_subr) - sprintf(t1_line_array, "dup %li %u", (long int) (ptr - tab), - ptr->cslen); - else - sprintf(t1_line_array, "/%s %u", ptr->name, ptr->cslen); - p = strend(t1_line_array); - memcpy(p, ptr->data, ptr->len); - t1_line_ptr = p + ptr->len; - t1_putline(); - } else { - /* replace unsused subr's by return_cs */ - if (is_subr) { - sprintf(t1_line_array, "dup %li %u%s ", (long int) (ptr - tab), - cs_len, cs_token_pair[0]); - p = strend(t1_line_array); - memcpy(p, return_cs, cs_len); - t1_line_ptr = p + cs_len; - t1_putline(); - sprintf(t1_line_array, " %s", cs_token_pair[1]); - t1_line_ptr = eol(t1_line_array); - t1_putline(); - } - } - xfree(ptr->data); - if (ptr->name != notdef) - xfree(ptr->name); - } - sprintf(t1_line_array, "%s", line_end); - t1_line_ptr = eol(t1_line_array); - t1_putline(); - if (is_subr) - xfree(return_cs); - xfree(tab); - xfree(start_line); - xfree(line_end); -} - -static void t1_mark_glyphs(void) -{ - char *glyph; - struct avl_traverser t; - cs_entry *ptr; - if (t1_synthetic || fd_cur->all_glyphs) { /* mark everything */ - if (cs_tab != NULL) - for (ptr = cs_tab; ptr < cs_ptr; ptr++) - if (ptr->valid) - ptr->used = true; - if (subr_tab != NULL) { - for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - if (ptr->valid) - ptr->used = true; - subr_max = subr_size - 1; - } - return; - } - mark_cs(notdef); - avl_t_init(&t, fd_cur->gl_tree); - for (glyph = (char *) avl_t_first(&t, fd_cur->gl_tree); glyph != NULL; - glyph = (char *) avl_t_next(&t)) { - mark_cs(glyph); - } - if (subr_tab != NULL) - for (subr_max = -1, ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - if (ptr->used && ptr - subr_tab > subr_max) - subr_max = ptr - subr_tab; -} - - -static void t1_subset_charstrings(void) -{ - cs_entry *ptr; - cs_size_pos = strstr(t1_line_array, charstringname) + strlen(charstringname) - - t1_line_array + 1; - /* cs_size_pos points to the number indicating - dict size after "/CharStrings" */ - cs_size = t1_scan_num(t1_line_array + cs_size_pos, 0); - cs_ptr = cs_tab = xtalloc(cs_size, cs_entry); - for (ptr = cs_tab; ptr - cs_tab < cs_size; ptr++) - init_cs_entry(ptr); - cs_notdef = NULL; - cs_dict_start = xstrdup(t1_line_array); - t1_getline(); - while (t1_cslen) { - store_cs(); - t1_getline(); - } - cs_dict_end = xstrdup(t1_line_array); - t1_mark_glyphs(); - if (subr_tab != NULL) { - if (cs_token_pair == NULL) - pdftex_fail - ("This Type 1 font uses mismatched subroutine begin/end token pairs."); - t1_subr_flush(); - } - for (cs_counter = 0, ptr = cs_tab; ptr < cs_ptr; ptr++) - if (ptr->used) - cs_counter++; - t1_cs_flush(); -} - -static void t1_subset_end(void) -{ - if (t1_synthetic) { /* copy to "dup /FontName get exch definefont pop" */ - while (!strstr(t1_line_array, "definefont")) { - t1_getline(); - t1_putline(); - } - while (!t1_end_eexec()) - t1_getline(); /* ignore the rest */ - t1_putline(); /* write "mark currentfile closefile" */ - } else - while (!t1_end_eexec()) { /* copy to "mark currentfile closefile" */ - t1_getline(); - t1_putline(); - } - t1_stop_eexec(); - if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ - while (!t1_cleartomark()) { - t1_getline(); - t1_putline(); - } - if (!t1_synthetic) /* don't check "{restore}if" for synthetic fonts */ - t1_check_end(); /* write "{restore}if" if found */ - } - get_length3(); -} - -void writet1(fd_entry * fd) -{ - fd_cur = fd; /* fd_cur is global inside writet1.c */ - assert(fd_cur->fm != NULL); - assert(is_type1(fd->fm)); - assert(is_included(fd->fm)); - - t1_save_offset = 0; - if (!is_subsetted(fd_cur->fm)) { /* include entire font */ - if (!(fd->ff_found = t1_open_fontfile("<<"))) - return; - t1_include(); - t1_close_font_file(">>"); - xfree(t1_buffer); - return; - } - /* partial downloading */ - if (!(fd->ff_found = t1_open_fontfile("<"))) - return; - t1_subset_ascii_part(); - t1_start_eexec(); - cc_init(); - cs_init(); - t1_read_subrs(); - t1_subset_charstrings(); - t1_subset_end(); - t1_close_font_file(">"); - xfree(t1_buffer); -} - -void t1_free(void) -{ - xfree(t1_line_array); - xfree(t1_buf_array); -} diff --git a/Build/source/texk/web2c/luatexdir/font/writet1.w b/Build/source/texk/web2c/luatexdir/font/writet1.w new file mode 100644 index 00000000000..69ac40bac04 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writet1.w @@ -0,0 +1,1726 @@ +% writet1.w +% +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2009 Taco Hoekwater +% +% This file is part of LuaTeX. +% +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. +% +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. +% +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: writet1.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writet1.w $"; + +#include "ptexlib.h" +#include + +#define t1_log(str) if(tracefilenames) tex_printf("%s", str) +#define get_length1() t1_length1 = t1_offset() - t1_save_offset +#define get_length2() t1_length2 = t1_offset() - t1_save_offset +#define get_length3() t1_length3 = fixedcontent? t1_offset() - t1_save_offset : 0 +#define save_offset() t1_save_offset = t1_offset() + +#define t1_putchar(A) fb_putchar(pdf,(A)) +#define t1_offset() fb_offset(pdf) +#define out_eexec_char t1_putchar + +#define end_last_eexec_line() \ + t1_eexec_encrypt = false +#define t1_char(c) c +#define embed_all_glyphs(tex_font) fm_cur->all_glyphs +#define extra_charset() fm_cur->charset +#define update_subset_tag() \ + strncpy(pdf->fb_array + t1_fontname_offset, fm_cur->subset_tag, 6) +#define fixedcontent false + +int t1_length1, t1_length2, t1_length3; +static int t1_save_offset; +static int t1_fontname_offset; + +static unsigned char *t1_buffer = NULL; +static int t1_size = 0; +static int t1_curbyte = 0; + +@ @c +#define t1_read_file() \ + readbinfile(t1_file,&t1_buffer,&t1_size) +#define t1_close() xfclose(t1_file,cur_file_name) +#define t1_getchar() t1_buffer[t1_curbyte++] +#define t1_ungetchar(c) t1_curbyte-- +#define t1_eof() (t1_curbyte>t1_size) + +#define t1_prefix(s) str_prefix(t1_line_array, s) +#define t1_buf_prefix(s) str_prefix(t1_buf_array, s) +#define t1_suffix(s) str_suffix(t1_line_array, t1_line_ptr, s) +#define t1_buf_suffix(s) str_suffix(t1_buf_array, t1_buf_ptr, s) +#define t1_charstrings() strstr(t1_line_array, charstringname) +#define t1_subrs() t1_prefix("/Subrs") +#define t1_end_eexec() t1_suffix("mark currentfile closefile") +#define t1_cleartomark() t1_prefix("cleartomark") + +static unsigned char *enc_buffer = NULL; +static int enc_size = 0; +static int enc_curbyte = 0; + +@ @c +#define enc_open(a) \ + (enc_file = fopen((char *)(a), FOPEN_RBIN_MODE)) +#define enc_read_file() \ + readbinfile(enc_file,&enc_buffer,&enc_size) +#define enc_close() xfclose(enc_file,cur_file_name) +#define enc_getchar() enc_buffer[enc_curbyte++] +#define enc_eof() (enc_curbyte>enc_size) + +#define valid_code(c) (c >= 0 && c < 256) +#define fixedcontent false + +@ @c +static const char *standard_glyph_names[256] = { + /* 0x00 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0x10 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0x20 */ + "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", + "ampersand", "quoteright", "parenleft", "parenright", "asterisk", + "plus", "comma", "hyphen", "period", "slash", + /* 0x30 */ + "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", + "nine", "colon", "semicolon", "less", "equal", "greater", "question", + /* 0x40 */ + "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", + "O", + /* 0x50 */ + "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", + "backslash", "bracketright", "asciicircum", "underscore", + /* 0x60 */ + "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", + "m", "n", "o", + /* 0x70 */ + "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", + "braceright", "asciitilde", notdef, + /* 0x80 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0x90 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0xa0 */ + notdef, "exclamdown", "cent", "sterling", "fraction", "yen", "florin", + "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", + "guilsinglleft", "guilsinglright", "fi", "fl", + /* 0xb0 */ + notdef, "endash", "dagger", "daggerdbl", "periodcentered", notdef, + "paragraph", "bullet", "quotesinglbase", "quotedblbase", + "quotedblright", "guillemotright", "ellipsis", "perthousand", notdef, + "questiondown", + /* 0xc0 */ + notdef, "grave", "acute", "circumflex", "tilde", "macron", "breve", + "dotaccent", "dieresis", notdef, + "ring", "cedilla", notdef, "hungarumlaut", "ogonek", "caron", + /* 0xd0 */ + "emdash", notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0xe0 */ + notdef, "AE", notdef, "ordfeminine", notdef, notdef, notdef, notdef, + "Lslash", "Oslash", "OE", "ordmasculine", notdef, notdef, notdef, + notdef, + /* 0xf0 */ + notdef, "ae", notdef, notdef, notdef, "dotlessi", notdef, notdef, "lslash", + "oslash", "oe", "germandbls", notdef, notdef, notdef, notdef +}; + +@ @c +static fd_entry *fd_cur; + +static char charstringname[] = "/CharStrings"; + +enum { ENC_STANDARD, ENC_BUILTIN } t1_encoding; + +#define T1_BUF_SIZE 0x10 +#define ENC_BUF_SIZE 0x1000 + +@ @c +#define CS_HSTEM 1 +#define CS_VSTEM 3 +#define CS_VMOVETO 4 +#define CS_RLINETO 5 +#define CS_HLINETO 6 +#define CS_VLINETO 7 +#define CS_RRCURVETO 8 +#define CS_CLOSEPATH 9 +#define CS_CALLSUBR 10 +#define CS_RETURN 11 +#define CS_ESCAPE 12 +#define CS_HSBW 13 +#define CS_ENDCHAR 14 +#define CS_RMOVETO 21 +#define CS_HMOVETO 22 +#define CS_VHCURVETO 30 +#define CS_HVCURVETO 31 +#define CS_1BYTE_MAX (CS_HVCURVETO + 1) + +#define CS_DOTSECTION CS_1BYTE_MAX + 0 +#define CS_VSTEM3 CS_1BYTE_MAX + 1 +#define CS_HSTEM3 CS_1BYTE_MAX + 2 +#define CS_SEAC CS_1BYTE_MAX + 6 +#define CS_SBW CS_1BYTE_MAX + 7 +#define CS_DIV CS_1BYTE_MAX + 12 +#define CS_CALLOTHERSUBR CS_1BYTE_MAX + 16 +#define CS_POP CS_1BYTE_MAX + 17 +#define CS_SETCURRENTPOINT CS_1BYTE_MAX + 33 +#define CS_2BYTE_MAX (CS_SETCURRENTPOINT + 1) +#define CS_MAX CS_2BYTE_MAX + +@ @c +typedef unsigned char byte; + +typedef struct { + byte nargs; /* number of arguments */ + boolean bottom; /* take arguments from bottom of stack? */ + boolean clear; /* clear stack? */ + boolean valid; +} cc_entry; /* CharString Command */ + +typedef struct { + char *name; /* glyph name (or notdef for Subrs entry) */ + byte *data; + unsigned short len; /* length of the whole string */ + unsigned short cslen; /* length of the encoded part of the string */ + boolean used; + boolean valid; +} cs_entry; + +static unsigned short t1_dr, t1_er; +static const unsigned short t1_c1 = 52845, t1_c2 = 22719; +static unsigned short t1_cslen; +static short t1_lenIV; +static char enc_line[ENC_BUF_SIZE]; + +@ define |t1_line_ptr|, |t1_line_array|, and |t1_line_limit| +@c +#define t1_line_entry char +define_array(t1_line); + +@ define |t1_buf_ptr|, |t1_buf_array|, and |t1_buf_limit| +@c +#define t1_buf_entry char +define_array(t1_buf); + +static int cs_start; + +static cs_entry *cs_tab, *cs_ptr, *cs_notdef; +static char *cs_dict_start, *cs_dict_end; +static int cs_counter, cs_size, cs_size_pos; + +static cs_entry *subr_tab; +static char *subr_array_start, *subr_array_end; +static int subr_max, subr_size, subr_size_pos; + +@ This list contains the begin/end tokens commonly used in the +/Subrs array of a Type 1 font. + +@c +static const char *cs_token_pairs_list[][2] = { + {" RD", "NP"}, + {" -|", "|"}, + {" RD", "noaccess put"}, + {" -|", "noaccess put"}, + {NULL, NULL} +}; + +@ @c +static const char **cs_token_pair; + +static boolean t1_pfa, t1_cs, t1_scan, t1_eexec_encrypt, t1_synthetic; +static int t1_in_eexec; /* 0 before eexec-encrypted, 1 during, 2 after */ +static long t1_block_length; +static int last_hexbyte; +static FILE *t1_file; +static FILE *enc_file; + +@ @c +static void enc_getline(void) +{ + char *p; + char c; + restart: + if (enc_eof()) + pdftex_fail("unexpected end of file"); + p = enc_line; + do { + c = (char) enc_getchar(); + append_char_to_buf(c, p, enc_line, ENC_BUF_SIZE); + } + while (c != 10 && !enc_eof()); + append_eol(p, enc_line, ENC_BUF_SIZE); + if (p - enc_line < 2 || *enc_line == '%') + goto restart; +} + +@ read encoding from .enc file, return |glyph_names array|, or |pdffail()| +@c +char **load_enc_file(char *enc_name) +{ + int callback_id = 0; + int file_opened = 0; + + char buf[ENC_BUF_SIZE], *p, *r; + int i, names_count; + char **glyph_names; + + cur_file_name = luatex_find_file(enc_name, find_enc_file_callback); + + if (cur_file_name == NULL) { + pdftex_fail("cannot find encoding file for reading"); + } + callback_id = callback_defined(read_enc_file_callback); + enc_curbyte = 0; + enc_size = 0; + if (callback_id > 0) { + if (run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &enc_buffer, &enc_size)) { + if ((!file_opened) || enc_size == 0) { + pdftex_fail("cannot open encoding file for reading"); + } + } + } else { + if (!enc_open(cur_file_name)) { + pdftex_fail("cannot open encoding file for reading"); + } + enc_read_file(); + enc_close(); + } + glyph_names = xtalloc(256, char *); + for (i = 0; i < 256; i++) + glyph_names[i] = (char *) notdef; + t1_log("{"); + + t1_log(cur_file_name); + enc_getline(); + if (*enc_line != '/' || (r = strchr(enc_line, '[')) == NULL) { + remove_eol(r, enc_line); + pdftex_fail + ("invalid encoding vector (a name or `[' missing): `%s'", enc_line); + } + names_count = 0; + r++; /* skip '[' */ + skip(r, ' '); + for (;;) { + while (*r == '/') { + for (p = buf, r++; + *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); + *p = 0; + skip(r, ' '); + if (names_count > 256) + pdftex_fail("encoding vector contains more than 256 names"); + if (strcmp(buf, notdef) != 0) + glyph_names[names_count] = xstrdup(buf); + names_count++; + } + if (*r != 10 && *r != '%') { + if (strncmp(r, "] def", strlen("] def")) == 0) + goto done; + else { + remove_eol(r, enc_line); + pdftex_fail + ("invalid encoding vector: a name or `] def' expected: `%s'", + enc_line); + } + } + enc_getline(); + r = enc_line; + } + done: + t1_log("}"); + cur_file_name = NULL; + xfree(enc_buffer); + return glyph_names; +} + +@ @c +void free_glyph_names(char **glyph_names) +{ + int i; + assert(glyph_names != NULL); + for (i = 0; i < 256; i++) + if (glyph_names[i] != notdef) + xfree(glyph_names[i]); + xfree(glyph_names); +} + + +static void t1_check_pfa(void) +{ + const int c = t1_getchar(); + t1_pfa = (c != 128) ? true : false; + t1_ungetchar(c); +} + +static int t1_getbyte(void) +{ + int c = t1_getchar(); + if (t1_pfa) + return c; + if (t1_block_length == 0) { + if (c != 128) + pdftex_fail("invalid marker"); + c = t1_getchar(); + if (c == 3) { + while (!t1_eof()) + (void) t1_getchar(); + return EOF; + } + t1_block_length = t1_getchar() & 0xff; + t1_block_length |= (t1_getchar() & 0xff) << 8; + t1_block_length |= (t1_getchar() & 0xff) << 16; + t1_block_length |= (t1_getchar() & 0xff) << 24; + c = t1_getchar(); + } + t1_block_length--; + return c; +} + +static int hexval(int c) +{ + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + else if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + else if (c >= '0' && c <= '9') + return c - '0'; + else + return -1; +} + +static byte edecrypt(byte cipher) +{ + byte plain; + if (t1_pfa) { + while (cipher == 10 || cipher == 13) + cipher = (byte) t1_getbyte(); + last_hexbyte = cipher = + (byte) ((hexval(cipher) << 4) + hexval(t1_getbyte())); + } + plain = (byte) (cipher ^ (t1_dr >> 8)); + t1_dr = (unsigned short) ((cipher + t1_dr) * t1_c1 + t1_c2); + return plain; +} + +static byte cdecrypt(byte cipher, unsigned short *cr) +{ + const byte plain = (byte) (cipher ^ (*cr >> 8)); + *cr = (unsigned short) ((cipher + *cr) * t1_c1 + t1_c2); + return plain; +} + +static byte eencrypt(byte plain) +{ + const byte cipher = (byte) (plain ^ (t1_er >> 8)); + t1_er = (unsigned short) ((cipher + t1_er) * t1_c1 + t1_c2); + return cipher; +} + +static byte cencrypt(byte plain, unsigned short *cr) +{ + const byte cipher = (byte) (plain ^ (*cr >> 8)); + *cr = (unsigned short) ((cipher + *cr) * t1_c1 + t1_c2); + return cipher; +} + +static char *eol(char *s) +{ + char *p = strend(s); + if (p - s > 1 && p[-1] != 10) { + *p++ = 10; + *p = 0; + } + return p; +} + +static float t1_scan_num(char *p, char **r) +{ + float f; + skip(p, ' '); + if (sscanf(p, "%g", &f) != 1) { + remove_eol(p, t1_line_array); + pdftex_fail("a number expected: `%s'", t1_line_array); + } + if (r != NULL) { + for (; isdigit(*p) || *p == '.' || + *p == 'e' || *p == 'E' || *p == '+' || *p == '-'; p++); + *r = p; + } + return f; +} + +static boolean str_suffix(const char *begin_buf, const char *end_buf, + const char *s) +{ + const char *s1 = end_buf - 1, *s2 = strend(s) - 1; + if (*s1 == 10) + s1--; + while (s1 >= begin_buf && s2 >= s) { + if (*s1-- != *s2--) + return false; + } + return s2 < s; +} + +@ @c +static void t1_getline(void) +{ + int c, l, eexec_scan; + char *p; + static const char eexec_str[] = "currentfile eexec"; + static int eexec_len = 17; /* |strlen(eexec_str)| */ + restart: + if (t1_eof()) + pdftex_fail("unexpected end of file"); + t1_line_ptr = t1_line_array; + alloc_array(t1_line, 1, T1_BUF_SIZE); + t1_cslen = 0; + eexec_scan = 0; + c = t1_getbyte(); + if (c == EOF) + goto exit; + while (!t1_eof()) { + if (t1_in_eexec == 1) + c = edecrypt((byte) c); + alloc_array(t1_line, 1, T1_BUF_SIZE); + { + char cc = (char) c; + append_char_to_buf(cc, t1_line_ptr, t1_line_array, t1_line_limit); + } + if (t1_in_eexec == 0 && eexec_scan >= 0 && eexec_scan < eexec_len) { + if (t1_line_array[eexec_scan] == eexec_str[eexec_scan]) + eexec_scan++; + else + eexec_scan = -1; + } + if (c == 10 || c == 13 + || (t1_pfa && eexec_scan == eexec_len && c == 32)) { + break; + } + if (t1_cs && t1_cslen == 0 && (t1_line_ptr - t1_line_array > 4) && + (t1_suffix(" RD ") || t1_suffix(" -| "))) { + p = t1_line_ptr - 5; + while (*p != ' ') + p--; + l = (int) t1_scan_num(p + 1, 0); + t1_cslen = (unsigned short) l; + cs_start = (int) (t1_line_ptr - t1_line_array); /* |cs_start| is an index now */ + alloc_array(t1_line, l, T1_BUF_SIZE); + while (l-- > 0) + *t1_line_ptr++ = (t1_line_entry) edecrypt((byte) t1_getbyte()); + } + c = t1_getbyte(); + } + alloc_array(t1_line, 2, T1_BUF_SIZE); /* |append_eol| can append 2 chars */ + append_eol(t1_line_ptr, t1_line_array, t1_line_limit); + if (t1_line_ptr - t1_line_array < 2) + goto restart; + if (eexec_scan == eexec_len) + t1_in_eexec = 1; + exit: + /* ensure that |t1_buf_array| has as much room as |t1_line_array| */ + t1_buf_ptr = t1_buf_array; + alloc_array(t1_buf, t1_line_limit, t1_line_limit); +} + +@ @c +static void t1_putline(PDF pdf) +{ + char *p = t1_line_array; + if (t1_line_ptr - t1_line_array <= 1) + return; + if (t1_eexec_encrypt) { + while (p < t1_line_ptr) + t1_putchar((eight_bits) eencrypt((byte) * p++)); + } else + while (p < t1_line_ptr) + t1_putchar((eight_bits) * p++); +} + +static void t1_puts(PDF pdf, const char *s) +{ + if (s != t1_line_array) + strcpy(t1_line_array, s); + t1_line_ptr = strend(t1_line_array); + t1_putline(pdf); +} + +__attribute__ ((format(printf, 2, 3))) +static void t1_printf(PDF pdf, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vsprintf(t1_line_array, fmt, args); + t1_puts(pdf, t1_line_array); + va_end(args); +} + +@ @c +static void t1_init_params(const char *open_name_prefix) +{ + t1_log(open_name_prefix); + t1_log(cur_file_name); + t1_lenIV = 4; + t1_dr = 55665; + t1_er = 55665; + t1_in_eexec = 0; + t1_cs = false; + t1_scan = true; + t1_synthetic = false; + t1_eexec_encrypt = false; + t1_block_length = 0; + t1_check_pfa(); +} + +static void t1_close_font_file(const char *close_name_suffix) +{ + t1_log(close_name_suffix); + cur_file_name = NULL; +} + +static void t1_check_block_len(boolean decrypt) +{ + int l, c; + if (t1_block_length == 0) + return; + c = t1_getbyte(); + if (decrypt) + c = edecrypt((byte) c); + l = (int) t1_block_length; + if (!(l == 0 && (c == 10 || c == 13))) { + pdftex_fail("%i bytes more than expected were ignored", l + 1); + } +} + +@ @c +static void t1_start_eexec(PDF pdf) +{ + int i; + assert(is_included(fd_cur->fm)); + get_length1(); + save_offset(); + + if (!t1_pfa) + t1_check_block_len(false); + for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) { + edecrypt((byte) t1_getbyte()); + *t1_line_ptr++ = 0; + } + t1_eexec_encrypt = true; + t1_putline(pdf); /* to put the first four bytes */ +} + +static void t1_stop_eexec(PDF pdf) +{ + int c; + assert(is_included(fd_cur->fm)); + get_length2(); + save_offset(); + t1_eexec_encrypt = false; + if (!t1_pfa) + t1_check_block_len(true); + else { + c = edecrypt((byte) t1_getbyte()); + if (!(c == 10 || c == 13)) { + if (last_hexbyte == 0) + t1_puts(pdf, "00"); + else + pdftex_fail("unexpected data after eexec"); + } + } + t1_cs = false; + t1_in_eexec = 2; +} + +@ macros for various transforms; unused, left for reference + +@c +#ifdef T1TRANSFORMMACROS +# define do_xshift(x,a) {x[4]+=a;} +# define do_yshift(x,a) {x[5]+=a;} +# define do_xscale(x,a) {x[0]*=a; x[2]*=a; x[4]*=a;} +# define do_yscale(x,a) {x[1]*=a; x[3]*=a; x[5]*=a;} +# define do_extend(x,a) {do_xscale(x,a);} +# define do_scale(x,a) {do_xscale(x,a); do_yscale(x,a);} +# define do_slant(x,a) {x[0]+=x[1]*(a); x[2]+=x[3]*(a); x[4]+=x[5]*(a);} +# define do_shear(x,a) {x[1]+=x[0]*(a); x[3]+=x[2]*(a); x[5]+=x[4]*(a);} +# define do_rotate(x,a) \ + {float t, u=cos(a), v=sin(a); \ + t =x[0]*u+x[1]*-v; \ + x[1] =x[0]*v+x[1]* u; x[0]=t; \ + t =x[2]*u+x[3]*-v; \ + x[3] =x[2]*v+x[3]* u; x[2]=t; \ + t =x[4]*u+x[5]*-v; \ + x[5] =x[4]*v+x[5]* u; x[4]=t;} +#endif + +@ @c +static void t1_scan_keys(PDF pdf) +{ + int i, k; + char *p, *q, *r; + const key_entry *key; + if (t1_prefix("/FontType")) { + p = t1_line_array + strlen("FontType") + 1; + if ((i = (int) t1_scan_num(p, 0)) != 1) + pdftex_fail("Type%d fonts unsupported by pdfTeX", i); + return; + } + for (key = (const key_entry *) font_key; key - font_key < FONT_KEYS_NUM; + key++) { + if (key->t1name[0] != '\0' + && str_prefix(t1_line_array + 1, key->t1name)) + break; + } + if (key - font_key == FONT_KEYS_NUM) + return; + p = t1_line_array + strlen(key->t1name) + 1; + skip(p, ' '); + if ((k = (int) (key - font_key)) == FONTNAME_CODE) { + if (*p != '/') { + remove_eol(p, t1_line_array); + pdftex_fail("a name expected: `%s'", t1_line_array); + } + r = ++p; /* skip the slash */ + for (q = t1_buf_array; *p != ' ' && *p != 10; *q++ = *p++); + *q = 0; + xfree(fd_cur->fontname); + fd_cur->fontname = xstrdup(t1_buf_array); + /* at this moment we cannot call |make_subset_tag()| yet, as the encoding + is not read; thus we mark the offset of the subset tag and write it + later */ + if (is_subsetted(fd_cur->fm)) { + assert(is_included(fd_cur->fm)); + t1_fontname_offset = (int) (t1_offset() + (r - t1_line_array)); + strcpy(t1_buf_array, p); + sprintf(r, "ABCDEF+%s%s", fd_cur->fontname, t1_buf_array); + t1_line_ptr = eol(r); + } + return; + } + if ((k == STEMV_CODE || k == FONTBBOX1_CODE) && (*p == '[' || *p == '{')) + p++; + if (k == FONTBBOX1_CODE) { + for (i = 0; i < 4; i++, k++) { + fd_cur->font_dim[k].val = (int) t1_scan_num(p, &r); + fd_cur->font_dim[k].set = true; + p = r; + } + return; + } + fd_cur->font_dim[k].val = (int) t1_scan_num(p, 0); + fd_cur->font_dim[k].set = true; +} + +@ @c +static void t1_scan_param(PDF pdf) +{ + static const char *lenIV = "/lenIV"; + if (!t1_scan || *t1_line_array != '/') + return; + if (t1_prefix(lenIV)) { + t1_lenIV = (short) t1_scan_num(t1_line_array + strlen(lenIV), 0); + if (t1_lenIV < 0) + pdftex_fail("negative value of lenIV is not supported"); + return; + } + t1_scan_keys(pdf); +} + +static void copy_glyph_names(char **glyph_names, int a, int b) +{ + if (glyph_names[b] != notdef) { + xfree(glyph_names[b]); + glyph_names[b] = (char *) notdef; + } + if (glyph_names[a] != notdef) { + glyph_names[b] = xstrdup(glyph_names[a]); + } +} + +@ read encoding from Type1 font file, return |glyph_names| array, or |pdffail()| + +@c +char **t1_builtin_enc(void) +{ + int i, a, b, c, counter = 0; + char *r, *p, **glyph_names; + /* At this moment \.{/Encoding} is the prefix of |t1_line_array| */ + glyph_names = xtalloc(256, char *); + for (i = 0; i < 256; i++) + glyph_names[i] = (char *) notdef; + if (t1_suffix("def")) { /* predefined encoding */ + sscanf(t1_line_array + strlen("/Encoding"), "%256s", t1_buf_array); + if (strcmp(t1_buf_array, "StandardEncoding") == 0) { + t1_encoding = ENC_STANDARD; + for (i = 0; i < 256; i++) { + if (standard_glyph_names[i] != notdef) + glyph_names[i] = xstrdup(standard_glyph_names[i]); + } + return glyph_names; + } else + pdftex_fail + ("cannot subset font (unknown predefined encoding `%s')", + t1_buf_array); + } + /* At this moment \.{/Encoding} is the prefix of |t1_line_array|, and the encoding is + not a predefined encoding. + + We have two possible forms of Encoding vector. The first case is + + \.{/Encoding [/a /b /c...] readonly def} + + and the second case can look like + + {\obeylines + \.{/Encoding 256 array 0 1 255 {1 index exch /.notdef put} for} + \.{dup 0 /x put} + \.{dup 1 /y put} + \.{...} + \.{readonly def}} + */ + t1_encoding = ENC_BUILTIN; + if (t1_prefix("/Encoding [") || t1_prefix("/Encoding[")) { /* the first case */ + r = strchr(t1_line_array, '[') + 1; + skip(r, ' '); + for (;;) { + while (*r == '/') { + for (p = t1_buf_array, r++; + *r != 32 && *r != 10 && *r != ']' && *r != '/'; + *p++ = *r++); + *p = 0; + skip(r, ' '); + if (counter > 255) + pdftex_fail("encoding vector contains more than 256 names"); + if (strcmp(t1_buf_array, notdef) != 0) + glyph_names[counter] = xstrdup(t1_buf_array); + counter++; + } + if (*r != 10 && *r != '%') { + if (str_prefix(r, "] def") || str_prefix(r, "] readonly def")) + break; + else { + remove_eol(r, t1_line_array); + pdftex_fail + ("a name or `] def' or `] readonly def' expected: `%s'", + t1_line_array); + } + } + t1_getline(); + r = t1_line_array; + } + } else { /* the second case */ + p = strchr(t1_line_array, 10); + for (;;) { + if (*p == 10) { + t1_getline(); + p = t1_line_array; + } + /* + check for \.{dup put} + */ + if (sscanf(p, "dup %i%256s put", &i, t1_buf_array) == 2 && + *t1_buf_array == '/' && valid_code(i)) { + if (strcmp(t1_buf_array + 1, notdef) != 0) + glyph_names[i] = xstrdup(t1_buf_array + 1); + p = strstr(p, " put") + strlen(" put"); + skip(p, ' '); + } + /* + check for \.{dup dup exch get put} + */ + else if (sscanf(p, "dup dup %i exch %i get put", &b, &a) == 2 + && valid_code(a) && valid_code(b)) { + copy_glyph_names(glyph_names, a, b); + p = strstr(p, " get put") + strlen(" get put"); + skip(p, ' '); + } + /* + check for \.{dup dup getinterval exch putinterval} + */ + else if (sscanf + (p, "dup dup %i %i getinterval %i exch putinterval", + &a, &c, &b) == 3 && valid_code(a) && valid_code(b) + && valid_code(c)) { + for (i = 0; i < c; i++) + copy_glyph_names(glyph_names, a + i, b + i); + p = strstr(p, " putinterval") + strlen(" putinterval"); + skip(p, ' '); + } + /* + check for \.{def} or \.{readonly def} + */ + else if ((p == t1_line_array || (p > t1_line_array && p[-1] == ' ')) + && strcmp(p, "def\n") == 0) + return glyph_names; + /* + skip an unrecognizable word + */ + else { + while (*p != ' ' && *p != 10) + p++; + skip(p, ' '); + } + } + } + return glyph_names; +} + + +@ +@c +static void t1_check_end(PDF pdf) +{ + if (t1_eof()) + return; + t1_getline(); + if (t1_prefix("{restore}")) + t1_putline(pdf); +} + +@ +@c +static boolean t1_open_fontfile(const char *open_name_prefix) +{ + ff_entry *ff; + int callback_id = 0; + int file_opened = 0; + t1_curbyte = 0; + t1_size = 0; + ff = check_ff_exist(fd_cur->fm->ff_name, is_truetype(fd_cur->fm)); + if (ff->ff_path == NULL) { + pdftex_fail("cannot open Type 1 font file for reading (%s)", + fd_cur->fm->ff_name); + return false; + } + cur_file_name = luatex_find_file(ff->ff_path, find_type1_file_callback); + if (cur_file_name == NULL) { + pdftex_fail("cannot open Type 1 font file for reading (%s)", + ff->ff_path); + return false; + } + callback_id = callback_defined(read_type1_file_callback); + if (callback_id > 0) { + if (!run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &t1_buffer, &t1_size) + && file_opened && t1_size > 0) { + pdftex_warn("cannot open Type 1 font file for reading (%s)", + cur_file_name); + return false; + } + } else { + t1_file = xfopen(cur_file_name, FOPEN_RBIN_MODE); + t1_read_file(); + t1_close(); + } + recorder_record_input(cur_file_name); + t1_init_params(open_name_prefix); + return true; +} + +static void t1_include(PDF pdf) +{ + do { + t1_getline(); + t1_scan_param(pdf); + t1_putline(pdf); + } + while (t1_in_eexec == 0); + t1_start_eexec(pdf); + do { + t1_getline(); + t1_scan_param(pdf); + t1_putline(pdf); + } + while (!(t1_charstrings() || t1_subrs())); + t1_cs = true; + do { + t1_getline(); + t1_putline(pdf); + } + while (!t1_end_eexec()); + t1_stop_eexec(pdf); + if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ + do { + t1_getline(); + t1_putline(pdf); + } + while (!t1_cleartomark()); + t1_check_end(pdf); /* write "{restore}if" if found */ + } + get_length3(); +} + +@ +@c +#define check_subr(subr) \ + if (subr >= subr_size || subr < 0) \ + pdftex_fail("Subrs array: entry index out of range (%i)", subr); + +static const char **check_cs_token_pair(void) +{ + const char **p = (const char **) cs_token_pairs_list; + for (; p[0] != NULL; ++p) + if (t1_buf_prefix(p[0]) && t1_buf_suffix(p[1])) + return p; + return NULL; +} + +static void cs_store(boolean is_subr) +{ + char *p; + cs_entry *ptr; + int subr; + for (p = t1_line_array, t1_buf_ptr = t1_buf_array; *p != ' '; + *t1_buf_ptr++ = *p++); + *t1_buf_ptr = 0; + if (is_subr) { + subr = (int) t1_scan_num(p + 1, 0); + check_subr(subr); + ptr = subr_tab + subr; + } else { + ptr = cs_ptr++; + if (cs_ptr - cs_tab > cs_size) + pdftex_fail + ("CharStrings dict: more entries than dict size (%i)", cs_size); + if (strcmp(t1_buf_array + 1, notdef) == 0) /* skip the slash */ + ptr->name = (char *) notdef; + else + ptr->name = xstrdup(t1_buf_array + 1); + } + /* copy |" RD " + cs data| to |t1_buf_array| */ + memcpy(t1_buf_array, t1_line_array + cs_start - 4, + (unsigned) (t1_cslen + 4)); + /* copy the end of cs data to |t1_buf_array| */ + for (p = t1_line_array + cs_start + t1_cslen, t1_buf_ptr = + t1_buf_array + t1_cslen + 4; *p != 10; *t1_buf_ptr++ = *p++); + *t1_buf_ptr++ = 10; + if (is_subr && cs_token_pair == NULL) + cs_token_pair = check_cs_token_pair(); + ptr->len = (unsigned short) (t1_buf_ptr - t1_buf_array); + ptr->cslen = t1_cslen; + xfree(ptr->data); /* mem leak? */ + ptr->data = xtalloc(ptr->len, byte); + memcpy(ptr->data, t1_buf_array, ptr->len); + ptr->valid = true; +} + +@ +@c +#define store_subr() cs_store(true) +#define store_cs() cs_store(false) + +#define CC_STACK_SIZE 24 + +static int cc_stack[CC_STACK_SIZE], *stack_ptr = cc_stack; +static cc_entry cc_tab[CS_MAX]; +static boolean is_cc_init = false; + + +#define cc_pop(N) \ + if (stack_ptr - cc_stack < (N)) \ + stack_error(N); \ + stack_ptr -= N + +#define stack_error(N) { \ + pdftex_fail("CharString: invalid access (%i) to stack (%i entries)", \ + (int) N, (int)(stack_ptr - cc_stack)); \ + goto cs_error; \ +} + +#define cc_get(N) ((N) < 0 ? *(stack_ptr + (N)) : *(cc_stack + (N))) + +#define cc_push(V) *stack_ptr++ = V +#define cc_clear() stack_ptr = cc_stack + +#define set_cc(N, B, A, C) \ + cc_tab[N].nargs = A; \ + cc_tab[N].bottom = B; \ + cc_tab[N].clear = C; \ + cc_tab[N].valid = true + +static void cc_init(void) +{ + int i; + if (is_cc_init) + return; + for (i = 0; i < CS_MAX; i++) + cc_tab[i].valid = false; + set_cc(CS_HSTEM, true, 2, true); + set_cc(CS_VSTEM, true, 2, true); + set_cc(CS_VMOVETO, true, 1, true); + set_cc(CS_RLINETO, true, 2, true); + set_cc(CS_HLINETO, true, 1, true); + set_cc(CS_VLINETO, true, 1, true); + set_cc(CS_RRCURVETO, true, 6, true); + set_cc(CS_CLOSEPATH, false, 0, true); + set_cc(CS_CALLSUBR, false, 1, false); + set_cc(CS_RETURN, false, 0, false); +#if 0 + set_cc(CS_ESCAPE, false, 0, false); +#endif + set_cc(CS_HSBW, true, 2, true); + set_cc(CS_ENDCHAR, false, 0, true); + set_cc(CS_RMOVETO, true, 2, true); + set_cc(CS_HMOVETO, true, 1, true); + set_cc(CS_VHCURVETO, true, 4, true); + set_cc(CS_HVCURVETO, true, 4, true); + set_cc(CS_DOTSECTION, false, 0, true); + set_cc(CS_VSTEM3, true, 6, true); + set_cc(CS_HSTEM3, true, 6, true); + set_cc(CS_SEAC, true, 5, true); + set_cc(CS_SBW, true, 4, true); + set_cc(CS_DIV, false, 2, false); + set_cc(CS_CALLOTHERSUBR, false, 0, false); + set_cc(CS_POP, false, 0, false); + set_cc(CS_SETCURRENTPOINT, true, 2, true); + is_cc_init = true; +} + +@ +@c +#define cs_getchar() cdecrypt(*data++, &cr) + +#define mark_subr(n) cs_mark(0, n) +#define mark_cs(s) cs_mark(s, 0) + +__attribute__ ((noreturn, format(printf, 3, 4))) +static void cs_fail(const char *cs_name, int subr, const char *fmt, ...) +{ + char buf[SMALL_BUF_SIZE]; + va_list args; + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); + if (cs_name == NULL) + pdftex_fail("Subr (%i): %s", (int) subr, buf); + else + pdftex_fail("CharString (/%s): %s", cs_name, buf); +} + +@ fix a return-less subr by appending |CS_RETURN| +@c +static void append_cs_return(cs_entry * ptr) +{ + unsigned short cr; + int i; + byte *p, *q, *data, *new_data; + assert(ptr != NULL && ptr->valid && ptr->used); + + /* decrypt the cs data to |t1_buf_array|, append |CS_RETURN| */ + p = (byte *) t1_buf_array; + data = ptr->data + 4; + cr = 4330; + for (i = 0; i < ptr->cslen; i++) + *p++ = cs_getchar(); + *p = CS_RETURN; + + /* encrypt the new cs data to |new_data| */ + new_data = xtalloc((unsigned) (ptr->len + 1), byte); + memcpy(new_data, ptr->data, 4); + p = new_data + 4; + q = (byte *) t1_buf_array; + cr = 4330; + for (i = 0; i < ptr->cslen + 1; i++) + *p++ = cencrypt(*q++, &cr); + memcpy(p, ptr->data + 4 + ptr->cslen, (size_t) (ptr->len - ptr->cslen - 4)); + + /* update |*ptr| */ + xfree(ptr->data); + ptr->data = new_data; + ptr->len++; + ptr->cslen++; +} + +@ +@c +static void cs_mark(const char *cs_name, int subr) +{ + byte *data; + int i, b, cs_len; + int last_cmd = 0; + int a, a1, a2; + unsigned short cr; + static int lastargOtherSubr3 = 3; /* the argument of last call to + OtherSubrs[3] */ + cs_entry *ptr; + cc_entry *cc; + if (cs_name == NULL) { + check_subr(subr); + ptr = subr_tab + subr; + if (!ptr->valid) + return; + } else { + if (cs_notdef != NULL && + (cs_name == notdef || strcmp(cs_name, notdef) == 0)) + ptr = cs_notdef; + else { + for (ptr = cs_tab; ptr < cs_ptr; ptr++) + if (strcmp(ptr->name, cs_name) == 0) + break; + if (ptr == cs_ptr) { + pdftex_warn("glyph `%s' undefined", cs_name); + return; + } + if (ptr->name == notdef) + cs_notdef = ptr; + } + } + /* only marked CharString entries and invalid entries can be skipped; + valid marked subrs must be parsed to keep the stack in sync */ + if (!ptr->valid || (ptr->used && cs_name != NULL)) + return; + ptr->used = true; + cr = 4330; + cs_len = ptr->cslen; + data = ptr->data + 4; + for (i = 0; i < t1_lenIV; i++, cs_len--) + cs_getchar(); + while (cs_len > 0) { + --cs_len; + b = cs_getchar(); + if (b >= 32) { + if (b <= 246) + a = b - 139; + else if (b <= 250) { + --cs_len; + a = ((b - 247) << 8) + 108 + cs_getchar(); + } else if (b <= 254) { + --cs_len; + a = -((b - 251) << 8) - 108 - cs_getchar(); + } else { + cs_len -= 4; + a = (cs_getchar() & 0xff) << 24; + a |= (cs_getchar() & 0xff) << 16; + a |= (cs_getchar() & 0xff) << 8; + a |= (cs_getchar() & 0xff) << 0; + if (sizeof(int) > 4 && (a & 0x80000000)) + a |= ~0x7FFFFFFF; + } + cc_push(a); + } else { + if (b == CS_ESCAPE) { + b = cs_getchar() + CS_1BYTE_MAX; + cs_len--; + } + if (b >= CS_MAX) { + cs_fail(cs_name, subr, "command value out of range: %i", + (int) b); + goto cs_error; + } + cc = cc_tab + b; + if (!cc->valid) { + cs_fail(cs_name, subr, "command not valid: %i", (int) b); + goto cs_error; + } + if (cc->bottom) { + if (stack_ptr - cc_stack < cc->nargs) + cs_fail(cs_name, subr, + "less arguments on stack (%i) than required (%i)", + (int) (stack_ptr - cc_stack), (int) cc->nargs); + else if (stack_ptr - cc_stack > cc->nargs) + cs_fail(cs_name, subr, + "more arguments on stack (%i) than required (%i)", + (int) (stack_ptr - cc_stack), (int) cc->nargs); + } + last_cmd = b; + switch (cc - cc_tab) { + case CS_CALLSUBR: + a1 = cc_get(-1); + cc_pop(1); + mark_subr(a1); + if (!subr_tab[a1].valid) { + cs_fail(cs_name, subr, "cannot call subr (%i)", (int) a1); + goto cs_error; + } + break; + case CS_DIV: + cc_pop(2); + cc_push(0); + break; + case CS_CALLOTHERSUBR: + if (cc_get(-1) == 3) + lastargOtherSubr3 = cc_get(-3); + a1 = cc_get(-2) + 2; + cc_pop(a1); + break; + case CS_POP: + cc_push(lastargOtherSubr3); + /* the only case when we care about the value being pushed onto + stack is when POP follows CALLOTHERSUBR (changing hints by + OtherSubrs[3]) + */ + break; + case CS_SEAC: + a1 = cc_get(3); + a2 = cc_get(4); + cc_clear(); + mark_cs(standard_glyph_names[a1]); + mark_cs(standard_glyph_names[a2]); + break; + default: + if (cc->clear) + cc_clear(); + } + } + } + if (cs_name == NULL && last_cmd != CS_RETURN) { + pdftex_warn("last command in subr `%i' is not a RETURN; " + "I will add it now but please consider fixing the font", + (int) subr); + append_cs_return(ptr); + } + return; + cs_error: /* an error occured during parsing */ + cc_clear(); + ptr->valid = false; + ptr->used = false; +} + +@ AVL search tree for glyph code by glyph name +@c +static int comp_t1_glyphs(const void *pa, const void *pb, void *p + __attribute__ ((unused))) +{ + return strcmp(*(const char *const *) pa, *(const char *const *) pb); +} + +struct avl_table *create_t1_glyph_tree(char **glyph_names) +{ + int i; + void **aa; + static struct avl_table *gl_tree; + gl_tree = avl_create(comp_t1_glyphs, NULL, &avl_xallocator); + assert(gl_tree != NULL); + for (i = 0; i < 256; i++) { + if (glyph_names[i] != notdef && + (char **) avl_find(gl_tree, &glyph_names[i]) == NULL) { + /* no |strdup| here, just point to the |glyph_names| array members */ + aa = avl_probe(gl_tree, &glyph_names[i]); + assert(aa != NULL); + } + } + return gl_tree; +} + +void destroy_t1_glyph_tree(struct avl_table *gl_tree) +{ + assert(gl_tree != NULL); + avl_destroy(gl_tree, NULL); +} + +@ +@c +static void t1_subset_ascii_part(PDF pdf) +{ + int j, *p; + char *glyph, **gg, **glyph_names; + struct avl_table *gl_tree; + struct avl_traverser t; + void **aa; + assert(fd_cur != NULL); + assert(fd_cur->gl_tree != NULL); + t1_getline(); + while (!t1_prefix("/Encoding")) { + t1_scan_param(pdf); + t1_putline(pdf); + t1_getline(); + } + glyph_names = t1_builtin_enc(); + fd_cur->builtin_glyph_names = glyph_names; + if (is_subsetted(fd_cur->fm)) { + assert(is_included(fd_cur->fm)); + if (fd_cur->tx_tree != NULL) { + /* take over collected non-reencoded characters from \TeX */ + avl_t_init(&t, fd_cur->tx_tree); + for (p = (int *) avl_t_first(&t, fd_cur->tx_tree); p != NULL; + p = (int *) avl_t_next(&t)) { + if ((char *) avl_find(fd_cur->gl_tree, glyph_names[*p]) == NULL) { + glyph = xstrdup(glyph_names[*p]); + aa = avl_probe(fd_cur->gl_tree, glyph); + assert(aa != NULL); + } + } + } + make_subset_tag(fd_cur); + assert(t1_fontname_offset != 0); + strncpy(pdf->fb_array + t1_fontname_offset, fd_cur->subset_tag, 6); + } + /* now really all glyphs needed from this font are in the |fd_cur->gl_tree| */ + if (t1_encoding == ENC_STANDARD) + t1_puts(pdf, "/Encoding StandardEncoding def\n"); + else { + t1_puts + (pdf, + "/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n"); + gl_tree = create_t1_glyph_tree(glyph_names); + avl_t_init(&t, fd_cur->gl_tree); + j = 0; + for (glyph = (char *) avl_t_first(&t, fd_cur->gl_tree); glyph != NULL; + glyph = (char *) avl_t_next(&t)) { + if ((gg = (char **) avl_find(gl_tree, &glyph)) != NULL) { + t1_printf(pdf, "dup %i /%s put\n", (int) (gg - glyph_names), + *gg); + j++; + } + } + destroy_t1_glyph_tree(gl_tree); + if (j == 0) + /* We didn't mark anything for the Encoding array. + We add \.{dup 0 /.notdef put} for compatibility with Acrobat 5.0. */ + t1_puts(pdf, "dup 0 /.notdef put\n"); + t1_puts(pdf, "readonly def\n"); + } + do { + t1_getline(); + t1_scan_param(pdf); + if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */ + t1_putline(pdf); + } + while (t1_in_eexec == 0); +} + + +@ +@c +static void cs_init(void) +{ + cs_ptr = cs_tab = NULL; + cs_dict_start = cs_dict_end = NULL; + cs_counter = cs_size = cs_size_pos = 0; + cs_token_pair = NULL; + subr_tab = NULL; + subr_array_start = subr_array_end = NULL; + subr_max = subr_size = subr_size_pos = 0; +} + +static void init_cs_entry(cs_entry * cs) +{ + cs->data = NULL; + cs->name = NULL; + cs->len = 0; + cs->cslen = 0; + cs->used = false; + cs->valid = false; +} + +@ +@c +static void t1_read_subrs(PDF pdf) +{ + int i, s; + cs_entry *ptr; + t1_getline(); + while (!(t1_charstrings() || t1_subrs())) { + t1_scan_param(pdf); + if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */ + t1_putline(pdf); + t1_getline(); + } + found: + t1_cs = true; + t1_scan = false; + if (!t1_subrs()) + return; + subr_size_pos = strlen("/Subrs") + 1; + /* |subr_size_pos| points to the number indicating dict size after |"Subrs"| */ + subr_size = (int) t1_scan_num(t1_line_array + subr_size_pos, 0); + if (subr_size == 0) { + while (!t1_charstrings()) + t1_getline(); + return; + } + subr_tab = xtalloc((unsigned) subr_size, cs_entry); + for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) + init_cs_entry(ptr); + subr_array_start = xstrdup(t1_line_array); + t1_getline(); + while (t1_cslen) { + store_subr(); + t1_getline(); + } + /* mark the first four entries without parsing */ + for (i = 0; i < subr_size && i < 4; i++) + subr_tab[i].used = true; + /* the end of the Subrs array might have more than one line so we need to + concatenate them to |subr_array_end|. Unfortunately some fonts don't have + the Subrs array followed by the CharStrings dict immediately (synthetic + fonts). If we cannot find CharStrings in next |POST_SUBRS_SCAN| lines then + we will treat the font as synthetic and ignore everything until next + Subrs is found + */ +#define POST_SUBRS_SCAN 5 + s = 0; + *t1_buf_array = 0; + for (i = 0; i < POST_SUBRS_SCAN; i++) { + if (t1_charstrings()) + break; + s = (int) (s + t1_line_ptr - t1_line_array); + alloc_array(t1_buf, s, T1_BUF_SIZE); + strcat(t1_buf_array, t1_line_array); + t1_getline(); + } + subr_array_end = xstrdup(t1_buf_array); + if (i == POST_SUBRS_SCAN) { /* CharStrings not found; + suppose synthetic font */ + for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) + if (ptr->valid) + xfree(ptr->data); + xfree(subr_tab); + xfree(subr_array_start); + xfree(subr_array_end); + cs_init(); + t1_cs = false; + t1_synthetic = true; + while (!(t1_charstrings() || t1_subrs())) + t1_getline(); + goto found; + } +} + +@ +@c +#define t1_subr_flush() t1_flush_cs(pdf, true) +#define t1_cs_flush() t1_flush_cs(pdf, false) + +static void t1_flush_cs(PDF pdf, boolean is_subr) +{ + char *p; + byte *r, *return_cs = NULL; + cs_entry *tab, *end_tab, *ptr; + char *start_line, *line_end; + int count, size_pos; + unsigned short cr, cs_len; + if (is_subr) { + start_line = subr_array_start; + line_end = subr_array_end; + size_pos = subr_size_pos; + tab = subr_tab; + count = subr_max + 1; + end_tab = subr_tab + count; + } else { + start_line = cs_dict_start; + line_end = cs_dict_end; + size_pos = cs_size_pos; + tab = cs_tab; + end_tab = cs_ptr; + count = cs_counter; + } + t1_line_ptr = t1_line_array; + for (p = start_line; p - start_line < size_pos;) + *t1_line_ptr++ = *p++; + while (isdigit(*p)) + p++; + sprintf(t1_line_ptr, "%u", count); + strcat(t1_line_ptr, p); + t1_line_ptr = eol(t1_line_array); + t1_putline(pdf); + + cs_len = 0; /* for -Wall */ + /* create |return_cs| to replace unsused subr's */ + if (is_subr) { + cr = 4330; + cs_len = 0; + /* at this point we have |t1_lenIV >= 0;| + a negative value would be caught in |t1_scan_param| */ + return_cs = xtalloc((unsigned) (t1_lenIV + 1), byte); + for (cs_len = 0, r = return_cs; cs_len < t1_lenIV; cs_len++, r++) + *r = cencrypt(0x00, &cr); + *r = cencrypt(CS_RETURN, &cr); + cs_len++; + } + + for (ptr = tab; ptr < end_tab; ptr++) { + if (ptr->used) { + if (is_subr) + sprintf(t1_line_array, "dup %li %u", (long int) (ptr - tab), + ptr->cslen); + else + sprintf(t1_line_array, "/%s %u", ptr->name, ptr->cslen); + p = strend(t1_line_array); + memcpy(p, ptr->data, ptr->len); + t1_line_ptr = p + ptr->len; + t1_putline(pdf); + } else { + /* replace unsused subr's by |return_cs| */ + if (is_subr) { + sprintf(t1_line_array, "dup %li %u%s ", (long int) (ptr - tab), + cs_len, cs_token_pair[0]); + p = strend(t1_line_array); + memcpy(p, return_cs, cs_len); + t1_line_ptr = p + cs_len; + t1_putline(pdf); + sprintf(t1_line_array, " %s", cs_token_pair[1]); + t1_line_ptr = eol(t1_line_array); + t1_putline(pdf); + } + } + xfree(ptr->data); + if (ptr->name != notdef) + xfree(ptr->name); + } + sprintf(t1_line_array, "%s", line_end); + t1_line_ptr = eol(t1_line_array); + t1_putline(pdf); + if (is_subr) + xfree(return_cs); + xfree(tab); + xfree(start_line); + xfree(line_end); +} + +@ +@c +static void t1_mark_glyphs(void) +{ + char *glyph; + struct avl_traverser t; + cs_entry *ptr; + if (t1_synthetic || fd_cur->all_glyphs) { /* mark everything */ + if (cs_tab != NULL) + for (ptr = cs_tab; ptr < cs_ptr; ptr++) + if (ptr->valid) + ptr->used = true; + if (subr_tab != NULL) { + for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) + if (ptr->valid) + ptr->used = true; + subr_max = subr_size - 1; + } + return; + } + mark_cs(notdef); + avl_t_init(&t, fd_cur->gl_tree); + for (glyph = (char *) avl_t_first(&t, fd_cur->gl_tree); glyph != NULL; + glyph = (char *) avl_t_next(&t)) { + mark_cs(glyph); + } + if (subr_tab != NULL) + for (subr_max = -1, ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) + if (ptr->used && ptr - subr_tab > subr_max) + subr_max = (int) (ptr - subr_tab); +} + + +@ +@c +static void t1_subset_charstrings(PDF pdf) +{ + cs_entry *ptr; + cs_size_pos = (int) (strstr(t1_line_array, + charstringname) + strlen(charstringname) - + t1_line_array + 1); + /* |cs_size_pos| points to the number indicating + dict size after |"/CharStrings"| */ + cs_size = (int) t1_scan_num(t1_line_array + cs_size_pos, 0); + cs_ptr = cs_tab = xtalloc((unsigned) cs_size, cs_entry); + for (ptr = cs_tab; ptr - cs_tab < cs_size; ptr++) + init_cs_entry(ptr); + cs_notdef = NULL; + cs_dict_start = xstrdup(t1_line_array); + t1_getline(); + while (t1_cslen) { + store_cs(); + t1_getline(); + } + cs_dict_end = xstrdup(t1_line_array); + t1_mark_glyphs(); + if (subr_tab != NULL) { + if (cs_token_pair == NULL) + pdftex_fail + ("This Type 1 font uses mismatched subroutine begin/end token pairs."); + t1_subr_flush(); + } + for (cs_counter = 0, ptr = cs_tab; ptr < cs_ptr; ptr++) + if (ptr->used) + cs_counter++; + t1_cs_flush(); +} + +@ +@c +static void t1_subset_end(PDF pdf) +{ + if (t1_synthetic) { /* copy to \.{dup /FontName get exch definefont pop} */ + while (!strstr(t1_line_array, "definefont")) { + t1_getline(); + t1_putline(pdf); + } + while (!t1_end_eexec()) + t1_getline(); /* ignore the rest */ + t1_putline(pdf); /* write \.{mark currentfile closefile} */ + } else + while (!t1_end_eexec()) { /* copy to \.{mark currentfile closefile} */ + t1_getline(); + t1_putline(pdf); + } + t1_stop_eexec(pdf); + if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ + while (!t1_cleartomark()) { + t1_getline(); + t1_putline(pdf); + } + if (!t1_synthetic) /* don't check \.{{restore}if} for synthetic fonts */ + t1_check_end(pdf); /* write \.{{restore}if} if found */ + } + get_length3(); +} + +@ +@c +void writet1(PDF pdf, fd_entry * fd) +{ + fd_cur = fd; /* |fd_cur| is global inside \.{writet1.w} */ + assert(fd_cur->fm != NULL); + assert(is_type1(fd->fm)); + assert(is_included(fd->fm)); + + t1_save_offset = 0; + if (!is_subsetted(fd_cur->fm)) { /* include entire font */ + if (!(fd->ff_found = t1_open_fontfile("<<"))) + return; + t1_include(pdf); + t1_close_font_file(">>"); + xfree(t1_buffer); + return; + } + /* partial downloading */ + if (!(fd->ff_found = t1_open_fontfile("<"))) + return; + t1_subset_ascii_part(pdf); + t1_start_eexec(pdf); + cc_init(); + cs_init(); + t1_read_subrs(pdf); + t1_subset_charstrings(pdf); + t1_subset_end(pdf); + t1_close_font_file(">"); + xfree(t1_buffer); +} + +@ +@c +void t1_free(void) +{ + xfree(t1_line_array); + xfree(t1_buf_array); +} diff --git a/Build/source/texk/web2c/luatexdir/font/writet3.c b/Build/source/texk/web2c/luatexdir/font/writet3.c deleted file mode 100644 index 30dab2e8b14..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writet3.c +++ /dev/null @@ -1,338 +0,0 @@ -/* writet3.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include -#include -#include -#include "luatexfont.h" - -static const char _svn_version[] = - "$Id: writet3.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writet3.c $"; - -#define T3_BUF_SIZE 1024 - -typedef char t3_line_entry; -define_array(t3_line); - -FILE *t3_file; -static boolean t3_image_used; - -static integer t3_char_procs[256]; -static float t3_char_widths[256]; -static int t3_glyph_num; -static float t3_font_scale; -static integer t3_b0, t3_b1, t3_b2, t3_b3; -static boolean is_pk_font; - -/* not static because used by pkin.c */ -unsigned char *t3_buffer = NULL; -integer t3_size = 0; -integer t3_curbyte = 0; - -#define t3_check_eof() \ - if (t3_eof()) \ - pdftex_fail("unexpected end of file"); - - -static void update_bbox(integer llx, integer lly, integer urx, integer ury, - boolean is_first_glyph) -{ - if (is_first_glyph) { - t3_b0 = llx; - t3_b1 = lly; - t3_b2 = urx; - t3_b3 = ury; - } else { - if (llx < t3_b0) - t3_b0 = llx; - if (lly < t3_b1) - t3_b1 = lly; - if (urx > t3_b2) - t3_b2 = urx; - if (ury > t3_b3) - t3_b3 = ury; - } -} - -static integer get_pk_font_scale(internalfontnumber f) -{ - return - divide_scaled(pk_scale_factor, - divide_scaled(pdf_font_size(f), one_hundred_bp, - fixed_decimal_digits + 2), 0); -} - -static integer pk_char_width(internalfontnumber f, scaled w) -{ - return - divide_scaled(divide_scaled(w, pdf_font_size(f), 7), - get_pk_font_scale(f), 0); -} - -scaled get_pk_char_width(internalfontnumber f, scaled w) -{ - return (get_pk_font_scale(f) / 100000.0) * - (pk_char_width(f, w) / 100.0) * pdf_font_size(f); -} - -static boolean writepk(internalfontnumber f) -{ - kpse_glyph_file_type font_ret; - integer llx, lly, urx, ury; - integer cw, rw, i, j; - halfword *row; - char *name; - char *ftemp = NULL; - chardesc cd; - boolean is_null_glyph, check_preamble; - integer dpi; - int callback_id = 0; - int file_opened = 0; - int mallocsize = 0; - if (t3_buffer != NULL) { - xfree(t3_buffer); - t3_buffer = NULL; - } - t3_curbyte = 0; - t3_size = 0; - - callback_id = callback_defined(find_pk_file_callback); - - if (callback_id > 0) { - dpi = round(fixed_pk_resolution * - (((float) pdf_font_size(f)) / font_dsize(f))); - /* .dpi/.pk */ - cur_file_name = font_name(f); - mallocsize = strlen(cur_file_name) + 24 + 9; - name = xmalloc(mallocsize); - snprintf(name, mallocsize, "%ddpi/%s.%dpk", (int) fixed_pk_resolution, - cur_file_name, (int) dpi); - if (run_callback(callback_id, "S->S", name, &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - free(name); - name = xstrdup(ftemp); - free(ftemp); - } - } - } else { - dpi = - kpse_magstep_fix(round - (fixed_pk_resolution * - (((float) pdf_font_size(f)) / font_dsize(f))), - fixed_pk_resolution, NULL); - cur_file_name = font_name(f); - name = kpse_find_pk(cur_file_name, (unsigned) dpi, &font_ret); - if (name == NULL || - !FILESTRCASEEQ(cur_file_name, font_ret.name) || - !kpse_bitmap_tolerance((float) font_ret.dpi, (float) dpi)) { - pdftex_fail("Font %s at %i not found", cur_file_name, (int) dpi); - } - } - callback_id = callback_defined(read_pk_file_callback); - if (callback_id > 0) { - if (! - (run_callback - (callback_id, "S->bSd", name, &file_opened, &t3_buffer, &t3_size) - && file_opened && t3_size > 0)) { - pdftex_warn("Font %s at %i not found", cur_file_name, (int) dpi); - cur_file_name = NULL; - return false; - } - } else { - t3_file = xfopen(name, FOPEN_RBIN_MODE); - recorder_record_input(name); - t3_read_file(); - t3_close(); - } - t3_image_used = true; - is_pk_font = true; - if (tracefilenames) - tex_printf(" <%s", (char *) name); - cd.rastersize = 256; - cd.raster = xtalloc(cd.rastersize, halfword); - check_preamble = true; - while (readchar(check_preamble, &cd) != 0) { - check_preamble = false; - if (!pdf_char_marked(f, cd.charcode)) - continue; - t3_char_widths[cd.charcode] = - pk_char_width(f, get_charwidth(f, cd.charcode)); - if (cd.cwidth < 1 || cd.cheight < 1) { - cd.xescape = cd.cwidth = round(t3_char_widths[cd.charcode] / 100.0); - cd.cheight = 1; - cd.xoff = 0; - cd.yoff = 0; - is_null_glyph = true; - } else - is_null_glyph = false; - llx = -cd.xoff; - lly = cd.yoff - cd.cheight + 1; - urx = cd.cwidth + llx + 1; - ury = cd.cheight + lly; - update_bbox(llx, lly, urx, ury, t3_glyph_num == 0); - t3_glyph_num++; - pdf_new_dict(0, 0, 0); - t3_char_procs[cd.charcode] = obj_ptr; - pdf_begin_stream(); - pdf_print_real(t3_char_widths[cd.charcode], 2); - pdf_printf(" 0 %i %i %i %i d1\n", - (int) llx, (int) lly, (int) urx, (int) ury); - if (is_null_glyph) - goto end_stream; - pdf_printf("q\n%i 0 0 %i %i %i cm\nBI\n", (int) cd.cwidth, - (int) cd.cheight, (int) llx, (int) lly); - pdf_printf("/W %i\n/H %i\n", (int) cd.cwidth, (int) cd.cheight); - pdf_puts("/IM true\n/BPC 1\n/D [1 0]\nID "); - cw = (cd.cwidth + 7) / 8; - rw = (cd.cwidth + 15) / 16; - row = cd.raster; - for (i = 0; i < cd.cheight; i++) { - for (j = 0; j < rw - 1; j++) { - pdfout(*row / 256); - pdfout(*row % 256); - row++; - } - pdfout(*row / 256); - if (2 * rw == cw) - pdfout(*row % 256); - row++; - } - pdf_puts("\nEI\nQ\n"); - end_stream: - pdf_end_stream(); - } - xfree(cd.raster); - cur_file_name = NULL; - return true; -} - -void writet3(int objnum, internalfontnumber f) -{ - - int i; - integer wptr, eptr, cptr; - int first_char, last_char; - integer pk_font_scale; - boolean is_notdef; - - - t3_glyph_num = 0; - t3_image_used = false; - for (i = 0; i < 256; i++) { - t3_char_procs[i] = 0; - t3_char_widths[i] = 0; - } - pack_file_name(tex_font_name(f), get_nullstr(), maketexlstring(".pgc", 4)); - cur_file_name = makecstring(make_name_string()); - is_pk_font = false; - - if (t3_buffer != NULL) { - xfree(t3_buffer); - t3_buffer = NULL; - } - t3_curbyte = 0; - t3_size = 0; - if (!writepk(f)) { - cur_file_name = NULL; - return; - } - for (i = font_bc(f); i <= font_ec(f); i++) - if (pdf_char_marked(f, i)) - break; - first_char = i; - for (i = font_ec(f); i > first_char; i--) - if (pdf_char_marked(f, i)) - break; - last_char = i; - pdf_begin_dict(objnum, 1); /* Type 3 font dictionary */ - pdf_puts("/Type /Font\n/Subtype /Type3\n"); - pdf_printf("/Name /F%i\n", (int) f); - if (pdf_font_attr(f) != get_nullstr()) { - pdf_print(pdf_font_attr(f)); - pdf_puts("\n"); - } - if (is_pk_font) { - pk_font_scale = get_pk_font_scale(f); - pdf_puts("/FontMatrix ["); - pdf_print_real(pk_font_scale, 5); - pdf_puts(" 0 0 "); - pdf_print_real(pk_font_scale, 5); - pdf_puts(" 0 0]\n"); - } else - pdf_printf("/FontMatrix [%g 0 0 %g 0 0]\n", - (double) t3_font_scale, (double) t3_font_scale); - pdf_printf("/%s [ %i %i %i %i ]\n", - font_key[FONTBBOX1_CODE].pdfname, - (int) t3_b0, (int) t3_b1, (int) t3_b2, (int) t3_b3); - pdf_printf("/Resources << /ProcSet [ /PDF %s] >>\n", - t3_image_used ? "/ImageB " : ""); - pdf_printf("/FirstChar %i\n/LastChar %i\n", first_char, last_char); - wptr = pdf_new_objnum(); - eptr = pdf_new_objnum(); - cptr = pdf_new_objnum(); - pdf_printf("/Widths %i 0 R\n/Encoding %i 0 R\n/CharProcs %i 0 R\n", - (int) wptr, (int) eptr, (int) cptr); - pdf_end_dict(); - pdf_begin_obj(wptr, 1); /* chars width array */ - pdf_puts("["); - if (is_pk_font) - for (i = first_char; i <= last_char; i++) { - pdf_print_real(t3_char_widths[i], 2); - pdf_puts(" "); - } else - for (i = first_char; i <= last_char; i++) - pdf_printf("%i ", (int) t3_char_widths[i]); - pdf_puts("]\n"); - pdf_end_obj(); - pdf_begin_dict(eptr, 1); /* encoding dictionary */ - pdf_printf("/Type /Encoding\n/Differences [%i", first_char); - if (t3_char_procs[first_char] == 0) { - pdf_printf("/%s", notdef); - is_notdef = true; - } else { - pdf_printf("/a%i", first_char); - is_notdef = false; - } - for (i = first_char + 1; i <= last_char; i++) { - if (t3_char_procs[i] == 0) { - if (!is_notdef) { - pdf_printf(" %i/%s", i, notdef); - is_notdef = true; - } - } else { - if (is_notdef) { - pdf_printf(" %i", i); - is_notdef = false; - } - pdf_printf("/a%i", i); - } - } - pdf_puts("]\n"); - pdf_end_dict(); - pdf_begin_dict(cptr, 1); /* CharProcs dictionary */ - for (i = first_char; i <= last_char; i++) - if (t3_char_procs[i] != 0) - pdf_printf("/a%i %i 0 R\n", (int) i, (int) t3_char_procs[i]); - pdf_end_dict(); - if (tracefilenames) - tex_printf(">"); - cur_file_name = NULL; -} diff --git a/Build/source/texk/web2c/luatexdir/font/writet3.w b/Build/source/texk/web2c/luatexdir/font/writet3.w new file mode 100644 index 00000000000..9301ba5f4f3 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writet3.w @@ -0,0 +1,331 @@ +% writet3.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: writet3.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writet3.w $"; + +#include "ptexlib.h" +#include +#include +#include + +#define T3_BUF_SIZE 1024 + +typedef char t3_line_entry; +define_array(t3_line); + +FILE *t3_file; +static boolean t3_image_used; + +static int t3_char_procs[256]; +static float t3_char_widths[256]; +static int t3_glyph_num; +static float t3_font_scale; +static int t3_b0, t3_b1, t3_b2, t3_b3; +static boolean is_pk_font; + +/* not static because used by pkin.c */ +unsigned char *t3_buffer = NULL; +int t3_size = 0; +int t3_curbyte = 0; + +#define t3_check_eof() \ + if (t3_eof()) \ + pdftex_fail("unexpected end of file"); + +@ +@c +static void update_bbox(int llx, int lly, int urx, int ury, + boolean is_first_glyph) +{ + if (is_first_glyph) { + t3_b0 = llx; + t3_b1 = lly; + t3_b2 = urx; + t3_b3 = ury; + } else { + if (llx < t3_b0) + t3_b0 = llx; + if (lly < t3_b1) + t3_b1 = lly; + if (urx > t3_b2) + t3_b2 = urx; + if (ury > t3_b3) + t3_b3 = ury; + } +} + +static int get_pk_font_scale(internal_font_number f, int precision, + int scale_factor) +{ + return + divide_scaled(scale_factor, + divide_scaled(font_size(f), one_hundred_bp, + precision + 2), 0); +} + +static int pk_char_width(internal_font_number f, scaled w, int precision, + int scale_factor) +{ + return + divide_scaled(divide_scaled(w, font_size(f), 7), + get_pk_font_scale(f, precision, scale_factor), 0); +} + +@ +@c +static boolean writepk(PDF pdf, internal_font_number f) +{ + kpse_glyph_file_type font_ret; + int llx, lly, urx, ury; + int cw, rw, i, j; + halfword *row; + char *name; + char *ftemp = NULL; + chardesc cd; + boolean is_null_glyph, check_preamble; + int dpi; + int callback_id = 0; + int file_opened = 0; + unsigned mallocsize = 0; + xfree(t3_buffer); + t3_curbyte = 0; + t3_size = 0; + + callback_id = callback_defined(find_pk_file_callback); + + if (callback_id > 0) { + dpi = round((float) pdf->pk_resolution * + (((float) font_size(f)) / (float) font_dsize(f))); + /* .dpi/.pk */ + cur_file_name = font_name(f); + mallocsize = (unsigned) (strlen(cur_file_name) + 24 + 9); + name = xmalloc(mallocsize); + snprintf(name, (size_t) mallocsize, "%ddpi/%s.%dpk", + (int) pdf->pk_resolution, cur_file_name, (int) dpi); + if (run_callback(callback_id, "S->S", name, &ftemp)) { + if (ftemp != NULL && strlen(ftemp)) { + free(name); + name = xstrdup(ftemp); + free(ftemp); + } + } + } else { + dpi = (int) + kpse_magstep_fix((unsigned) round + ((float) pdf->pk_resolution * + ((float) font_size(f) / (float) font_dsize(f))), + (unsigned) pdf->pk_resolution, NULL); + cur_file_name = font_name(f); + name = kpse_find_pk(cur_file_name, (unsigned) dpi, &font_ret); + if (name == NULL || + !FILESTRCASEEQ(cur_file_name, font_ret.name) || + !kpse_bitmap_tolerance((float) font_ret.dpi, (float) dpi)) { + pdftex_fail("Font %s at %i not found", cur_file_name, (int) dpi); + } + } + callback_id = callback_defined(read_pk_file_callback); + if (callback_id > 0) { + if (! + (run_callback + (callback_id, "S->bSd", name, &file_opened, &t3_buffer, &t3_size) + && file_opened && t3_size > 0)) { + pdftex_warn("Font %s at %i not found", cur_file_name, (int) dpi); + cur_file_name = NULL; + return false; + } + } else { + t3_file = xfopen(name, FOPEN_RBIN_MODE); + recorder_record_input(name); + t3_read_file(); + t3_close(); + } + t3_image_used = true; + is_pk_font = true; + if (tracefilenames) + tex_printf(" <%s", (char *) name); + cd.rastersize = 256; + cd.raster = xtalloc((unsigned long) cd.rastersize, halfword); + check_preamble = true; + while (readchar(check_preamble, &cd) != 0) { + check_preamble = false; + if (!pdf_char_marked(f, cd.charcode)) + continue; + t3_char_widths[cd.charcode] = (float) + pk_char_width(f, get_charwidth(f, cd.charcode), + pdf->decimal_digits, pdf->pk_scale_factor); + if (cd.cwidth < 1 || cd.cheight < 1) { + cd.xescape = cd.cwidth = round(t3_char_widths[cd.charcode] / 100.0); + cd.cheight = 1; + cd.xoff = 0; + cd.yoff = 0; + is_null_glyph = true; + } else + is_null_glyph = false; + llx = -cd.xoff; + lly = cd.yoff - cd.cheight + 1; + urx = cd.cwidth + llx + 1; + ury = cd.cheight + lly; + update_bbox(llx, lly, urx, ury, t3_glyph_num == 0); + t3_glyph_num++; + pdf_new_dict(pdf, obj_type_others, 0, 0); + t3_char_procs[cd.charcode] = pdf->obj_ptr; + pdf_begin_stream(pdf); + pdf_print_real(pdf, (int) t3_char_widths[cd.charcode], 2); + pdf_printf(pdf, " 0 %i %i %i %i d1\n", + (int) llx, (int) lly, (int) urx, (int) ury); + if (is_null_glyph) + goto end_stream; + pdf_printf(pdf, "q\n%i 0 0 %i %i %i cm\nBI\n", (int) cd.cwidth, + (int) cd.cheight, (int) llx, (int) lly); + pdf_printf(pdf, "/W %i\n/H %i\n", (int) cd.cwidth, (int) cd.cheight); + pdf_puts(pdf, "/IM true\n/BPC 1\n/D [1 0]\nID "); + cw = (cd.cwidth + 7) / 8; + rw = (cd.cwidth + 15) / 16; + row = cd.raster; + for (i = 0; i < cd.cheight; i++) { + for (j = 0; j < rw - 1; j++) { + pdf_out(pdf, (unsigned char) (*row / 256)); + pdf_out(pdf, (unsigned char) (*row % 256)); + row++; + } + pdf_out(pdf, (unsigned char) (*row / 256)); + if (2 * rw == cw) + pdf_out(pdf, (unsigned char) (*row % 256)); + row++; + } + pdf_puts(pdf, "\nEI\nQ\n"); + end_stream: + pdf_end_stream(pdf); + } + xfree(cd.raster); + cur_file_name = NULL; + return true; +} + +@ +@c +void writet3(PDF pdf, internal_font_number f) +{ + + int i; + int wptr, eptr, cptr; + int first_char, last_char; + int pk_font_scale; + boolean is_notdef; + + t3_glyph_num = 0; + t3_image_used = false; + for (i = 0; i < 256; i++) { + t3_char_procs[i] = 0; + t3_char_widths[i] = 0; + } + is_pk_font = false; + + xfree(t3_buffer); + t3_curbyte = 0; + t3_size = 0; + if (!writepk(pdf, f)) + return; + for (i = font_bc(f); i <= font_ec(f); i++) + if (pdf_char_marked(f, i)) + break; + first_char = i; + for (i = font_ec(f); i > first_char; i--) + if (pdf_char_marked(f, i)) + break; + last_char = i; + pdf_begin_dict(pdf, pdf_font_num(f), 1); /* Type 3 font dictionary */ + pdf_puts(pdf, "/Type /Font\n/Subtype /Type3\n"); + pdf_printf(pdf, "/Name /F%i\n", (int) f); + if (pdf_font_attr(f) != get_nullstr() && pdf_font_attr(f) != 0) { + pdf_print(pdf, pdf_font_attr(f)); + pdf_puts(pdf, "\n"); + } + if (is_pk_font) { + pk_font_scale = + get_pk_font_scale(f, pdf->decimal_digits, pdf->pk_scale_factor); + pdf_puts(pdf, "/FontMatrix ["); + pdf_print_real(pdf, pk_font_scale, 5); + pdf_puts(pdf, " 0 0 "); + pdf_print_real(pdf, pk_font_scale, 5); + pdf_puts(pdf, " 0 0]\n"); + } else + pdf_printf(pdf, "/FontMatrix [%g 0 0 %g 0 0]\n", + (double) t3_font_scale, (double) t3_font_scale); + pdf_printf(pdf, "/%s [ %i %i %i %i ]\n", + font_key[FONTBBOX1_CODE].pdfname, + (int) t3_b0, (int) t3_b1, (int) t3_b2, (int) t3_b3); + pdf_printf(pdf, "/Resources << /ProcSet [ /PDF %s] >>\n", + t3_image_used ? "/ImageB " : ""); + pdf_printf(pdf, "/FirstChar %i\n/LastChar %i\n", first_char, last_char); + wptr = pdf_new_objnum(pdf); + eptr = pdf_new_objnum(pdf); + cptr = pdf_new_objnum(pdf); + pdf_printf(pdf, "/Widths %i 0 R\n/Encoding %i 0 R\n/CharProcs %i 0 R\n", + (int) wptr, (int) eptr, (int) cptr); + pdf_end_dict(pdf); + pdf_begin_obj(pdf, wptr, 1); /* chars width array */ + pdf_puts(pdf, "["); + if (is_pk_font) + for (i = first_char; i <= last_char; i++) { + pdf_print_real(pdf, (int) t3_char_widths[i], 2); + pdf_puts(pdf, " "); + } else + for (i = first_char; i <= last_char; i++) + pdf_printf(pdf, "%i ", (int) t3_char_widths[i]); + pdf_puts(pdf, "]\n"); + pdf_end_obj(pdf); + pdf_begin_dict(pdf, eptr, 1); /* encoding dictionary */ + pdf_printf(pdf, "/Type /Encoding\n/Differences [%i", first_char); + if (t3_char_procs[first_char] == 0) { + pdf_printf(pdf, "/%s", notdef); + is_notdef = true; + } else { + pdf_printf(pdf, "/a%i", first_char); + is_notdef = false; + } + for (i = first_char + 1; i <= last_char; i++) { + if (t3_char_procs[i] == 0) { + if (!is_notdef) { + pdf_printf(pdf, " %i/%s", i, notdef); + is_notdef = true; + } + } else { + if (is_notdef) { + pdf_printf(pdf, " %i", i); + is_notdef = false; + } + pdf_printf(pdf, "/a%i", i); + } + } + pdf_puts(pdf, "]\n"); + pdf_end_dict(pdf); + pdf_begin_dict(pdf, cptr, 1); /* CharProcs dictionary */ + for (i = first_char; i <= last_char; i++) + if (t3_char_procs[i] != 0) + pdf_printf(pdf, "/a%i %i 0 R\n", (int) i, (int) t3_char_procs[i]); + pdf_end_dict(pdf); + if (tracefilenames) + tex_printf(">"); + cur_file_name = NULL; +} diff --git a/Build/source/texk/web2c/luatexdir/font/writettf.c b/Build/source/texk/web2c/luatexdir/font/writettf.c deleted file mode 100644 index 0e4bb43802c..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writettf.c +++ /dev/null @@ -1,1518 +0,0 @@ -/* writettf.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "writettf.h" -#include - -static const char _svn_version[] = - "$Id: writettf.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writettf.c $"; - -#define DEFAULT_NTABS 14 -#define NEW_CMAP_SIZE 2 - -#define ttf_putchar fb_putchar -#define ttf_offset fb_offset -#define ttf_seek_outbuf fb_seek - - /* #define INFILE ttf_file */ - -unsigned char *ttf_buffer = NULL; -integer ttf_size = 0; -integer ttf_curbyte = 0; - -typedef struct { - const char *name; /* name of glyph */ - long code; /* charcode in case of subfonts */ - long newindex; /* new index of glyph in output file */ -} ttfenc_entry; - -typedef struct { - TTF_USHORT platform_id; - TTF_USHORT encoding_id; - TTF_USHORT language_id; - TTF_USHORT name_id; - TTF_USHORT length; - TTF_USHORT offset; - TTF_USHORT new_offset; - TTF_USHORT new_length; -} name_record; - -typedef struct { - char *ttf_name; - TTF_USHORT pid; - TTF_USHORT eid; - long *table; -} ttf_cmap_entry; - -static TTF_USHORT ntabs; -static TTF_USHORT upem; -static TTF_FIXED post_format; -static TTF_SHORT loca_format; -static TTF_ULONG last_glyf_offset; -static TTF_USHORT glyphs_count; -static TTF_USHORT new_glyphs_count; -static TTF_USHORT nhmtxs; -static TTF_USHORT new_ntabs; - -glyph_entry *glyph_tab; -dirtab_entry *dir_tab; - -static long *glyph_index; -static cmap_entry *cmap_tab, new_cmap_tab[NEW_CMAP_SIZE]; -static name_record *name_tab; -static int name_record_num; -static char *name_buf; -static int name_buf_size; -static char *glyph_name_buf; -static TTF_ULONG checksum; -static TTF_ULONG tab_length; -static TTF_ULONG tmp_ulong; -static TTF_ULONG checkSumAdjustment_offset; -FILE *ttf_file; -static ttfenc_entry ttfenc_tab[256]; - -fd_entry *fd_cur; /* pointer to the current font descriptor */ - -static struct avl_table *ttf_cmap_tree = NULL; - -integer ttf_length; - -#include "macnames.c" - -static const char *newtabnames[] = { - "OS/2", - "PCLT", - "cmap", - "cvt ", - "fpgm", - "glyf", - "head", - "hhea", - "hmtx", - "loca", - "maxp", - "name", - "post", - "prep" -}; - -static ttf_cmap_entry *new_ttf_cmap_entry(void) -{ - ttf_cmap_entry *e; - e = xtalloc(1, ttf_cmap_entry); - e->ttf_name = NULL; - e->table = NULL; - return e; -} - -static void destroy_ttf_cmap_entry(void *pa, void *pb) -{ - ttf_cmap_entry *p; - (void) pb; - p = (ttf_cmap_entry *) pa; - xfree(p->ttf_name); - xfree(p->table); - xfree(p); -} - -void ttf_free(void) -{ - if (ttf_cmap_tree != NULL) - avl_destroy(ttf_cmap_tree, destroy_ttf_cmap_entry); -} - -static int comp_ttf_cmap_entry(const void *pa, const void *pb, void *p) -{ - const ttf_cmap_entry *p1 = (const ttf_cmap_entry *) pa, - *p2 = (const ttf_cmap_entry *) pb; - int i; - (void) p; - assert(p1->ttf_name != NULL && p2->ttf_name != NULL); - if ((i = strcmp(p1->ttf_name, p2->ttf_name)) != 0) - return i; - cmp_return(p1->pid, p2->pid); - cmp_return(p1->eid, p2->eid); - return 0; -} - -static unsigned char ttf_addchksm(unsigned char b) -{ - tmp_ulong = (tmp_ulong << 8) + b; - tab_length++; - if (tab_length % 4 == 0) { - checksum += tmp_ulong; - tmp_ulong = 0; - } - return b; -} - -static TTF_ULONG ttf_getchksm(void) -{ - while (tab_length % 4 != 0) - ttf_putchar(ttf_addchksm(0)); /* ttf_addchksm updates tab_length */ - return checksum; -} - -long ttf_putnum(int s, long n) -{ - long i = n; - char buf[TTF_LONG_SIZE + 1], *p = buf; - while (s-- > 0) { - *p++ = i & 0xFF; - i >>= 8; - } - p--; - while (p >= buf) - ttf_putchar(ttf_addchksm(*p--)); - return n; -} - -long ttf_getnum(int s) -{ - long i = 0; - int c; - while (s > 0) { - if (ttf_eof()) - pdftex_fail("unexpected EOF"); - c = ttf_getchar(); - i = (i << 8) + c; - s--; - } - return i; -} - -static long ttf_funit(long n) -{ - if (n < 0) - return -((-n / upem) * 1000 + ((-n % upem) * 1000) / upem); - else - return (n / upem) * 1000 + ((n % upem) * 1000) / upem; -} - -static void ttf_ncopy(int n) -{ - while (n-- > 0) - copy_byte(); -} - -dirtab_entry *ttf_name_lookup(const char *s, boolean required) -{ - dirtab_entry *tab; - for (tab = dir_tab; tab - dir_tab < ntabs; tab++) - if (strncmp(tab->tag, s, 4) == 0) - break; - if (tab - dir_tab == ntabs) { - if (required) - pdftex_fail("can't find table `%s'", s); - else - tab = NULL; - } - return tab; -} - -dirtab_entry *ttf_seek_tab(const char *name, TTF_LONG offset) -{ - dirtab_entry *tab = ttf_name_lookup(name, true); - /*xfseek (INFILE, tab->offset + offset, SEEK_SET, cur_file_name); */ - ttf_curbyte = tab->offset + offset; - return tab; -} - -static void ttf_seek_off(TTF_LONG offset) -{ - ttf_curbyte = offset; - //xfseek (INFILE, offset, SEEK_SET, cur_file_name); -} - -static void ttf_copy_encoding(void) -{ - int i, *q; - void **aa; - char **glyph_names; - long *charcodes; - static char buf[SMALL_BUF_SIZE]; - struct avl_traverser t; - ttfenc_entry *e = ttfenc_tab; - - assert(fd_cur->tx_tree != NULL); /* this must be set in create_fontdictionary */ - - if (fd_cur->fe != NULL) { - glyph_names = fd_cur->fe->glyph_names; - assert(glyph_names != NULL); - - for (i = 0; i < 256; i++) - ttfenc_tab[i].name = notdef; - - /* a workaround for a bug of AcroReader 4.0 */ - if (strcmp(glyph_names[97], "a") == 0) { - q = xtalloc(1, int); - *q = 'a'; - aa = avl_probe(fd_cur->tx_tree, q); - assert(aa != NULL); - } - /* end of workaround */ - - /* take over collected characters from TeX, reencode them */ - avl_t_init(&t, fd_cur->tx_tree); - for (q = (int *) avl_t_first(&t, fd_cur->tx_tree); q != NULL; - q = (int *) avl_t_next(&t)) { - assert(*q >= 0 && *q < 256); - ttfenc_tab[*q].name = glyph_names[*q]; - } - make_subset_tag(fd_cur); - } else if (is_subfont(fd_cur->fm)) { - charcodes = fd_cur->fm->subfont->charcodes; - assert(charcodes != NULL); - - for (i = 0; i < 256; i++) - ttfenc_tab[i].code = -1; - - /* take over collected characters from TeX */ - avl_t_init(&t, fd_cur->tx_tree); - for (q = (int *) avl_t_first(&t, fd_cur->tx_tree); q != NULL; - q = (int *) avl_t_next(&t)) { - assert(*q >= 0 && *q < 256); - e = ttfenc_tab + *q; - e->code = charcodes[*q]; - if (e->code == -1) - pdftex_warn - ("character %i in subfont %s is not mapped to any charcode", - *q, fd_cur->fm->tfm_name); - else { - assert(e->code < 0x10000); - sprintf(buf, "/c%4.4X", (int) e->code); - aa = avl_probe(fd_cur->gl_tree, xstrdup(buf)); - assert(aa != NULL); - } - } - make_subset_tag(fd_cur); - } else - assert(0); -} - -#define ttf_append_byte(B)\ -do {\ - if (name_tab[i].platform_id == 3)\ - *q++ = 0;\ - *q++ = B;\ -} while (0) - -static char *strip_spaces_and_delims(char *s, int l) -{ - static char buf[SMALL_BUF_SIZE]; - char *p = buf; - int i; - - assert(l >= 0 && l < (int) sizeof(buf)); - - for (i = 0; i < l; s++, i++) { - if (*s == '(' || *s == ')' || *s == '<' || *s == '>' || - *s == '[' || *s == ']' || *s == '{' || *s == '}' || - *s == '/' || *s == '%' || isspace(*s)) - continue; - *p++ = *s; - } - *p = 0; - return buf; -} - -static void ttf_read_name(void) -{ - int i, j; - dirtab_entry *tab = ttf_seek_tab("name", TTF_USHORT_SIZE); - char *p, buf[SMALL_BUF_SIZE]; - name_record_num = get_ushort(); - name_tab = xtalloc(name_record_num, name_record); - name_buf_size = tab->length - - (3 * TTF_USHORT_SIZE + name_record_num * 6 * TTF_USHORT_SIZE); - name_buf = xtalloc(name_buf_size, char); - ttf_skip(TTF_USHORT_SIZE); - for (i = 0; i < name_record_num; i++) { - name_tab[i].platform_id = get_ushort(); - name_tab[i].encoding_id = get_ushort(); - name_tab[i].language_id = get_ushort(); - name_tab[i].name_id = get_ushort(); - name_tab[i].length = get_ushort(); - name_tab[i].offset = get_ushort(); - } - for (p = name_buf; p - name_buf < name_buf_size; p++) - *p = get_char(); - /* look for PS font name */ - for (i = 0; i < name_record_num; i++) { - if (name_tab[i].platform_id == 1 && - name_tab[i].encoding_id == 0 && name_tab[i].name_id == 6) { - xfree(fd_cur->fontname); - fd_cur->fontname = - xstrdup(strip_spaces_and_delims(name_buf + name_tab[i].offset, - name_tab[i].length)); - fd_cur->font_dim[FONTNAME_CODE].set = true; - break; - } - } - if (!fd_cur->font_dim[FONTNAME_CODE].set) { - for (i = 0; i < name_record_num; i++) { - if (name_tab[i].platform_id == 3 && - (name_tab[i].encoding_id == 0 || name_tab[i].encoding_id == 1) - && name_tab[i].name_id == 6) { - xfree(fd_cur->fontname); - assert(name_tab[i].length < sizeof(buf)); - for (j = 0, p = buf; j < name_tab[i].length; j += 2) - *p++ = name_buf[name_tab[i].offset + j + 1]; - *p = 0; - fd_cur->fontname = - xstrdup(strip_spaces_and_delims(buf, strlen(buf))); - fd_cur->font_dim[FONTNAME_CODE].set = true; - break; - } - } - } -} - -static void ttf_read_mapx(void) -{ - glyph_entry *glyph; - ttf_seek_tab("maxp", TTF_FIXED_SIZE); - glyph_tab = xtalloc(1 + (glyphs_count = get_ushort()), glyph_entry); - for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count; glyph++) { - glyph->newindex = -1; - glyph->newoffset = 0; - glyph->name_index = 0; - glyph->name = notdef; - } - glyph_index = xtalloc(glyphs_count, long); - glyph_index[0] = 0; /* index of ".notdef" glyph */ - glyph_index[1] = 1; /* index of ".null" glyph */ -} - -void ttf_read_head(void) -{ - ttf_seek_tab("head", - 2 * TTF_FIXED_SIZE + 2 * TTF_ULONG_SIZE + TTF_USHORT_SIZE); - upem = get_ushort(); - ttf_skip(16); - fd_cur->font_dim[FONTBBOX1_CODE].val = ttf_funit(get_fword()); - fd_cur->font_dim[FONTBBOX2_CODE].val = ttf_funit(get_fword()); - fd_cur->font_dim[FONTBBOX3_CODE].val = ttf_funit(get_fword()); - fd_cur->font_dim[FONTBBOX4_CODE].val = ttf_funit(get_fword()); - fd_cur->font_dim[FONTBBOX1_CODE].set = true; - fd_cur->font_dim[FONTBBOX2_CODE].set = true; - fd_cur->font_dim[FONTBBOX3_CODE].set = true; - fd_cur->font_dim[FONTBBOX4_CODE].set = true; - ttf_skip(2 * TTF_USHORT_SIZE + TTF_SHORT_SIZE); - loca_format = get_short(); -} - -void ttf_read_hhea(void) -{ - ttf_seek_tab("hhea", TTF_FIXED_SIZE); - fd_cur->font_dim[ASCENT_CODE].val = ttf_funit(get_fword()); - fd_cur->font_dim[DESCENT_CODE].val = ttf_funit(get_fword()); - fd_cur->font_dim[ASCENT_CODE].set = true; - fd_cur->font_dim[DESCENT_CODE].set = true; - ttf_skip(TTF_FWORD_SIZE + TTF_UFWORD_SIZE + 3 * TTF_FWORD_SIZE + - 8 * TTF_SHORT_SIZE); - nhmtxs = get_ushort(); -} - -void ttf_read_pclt(void) -{ - if (ttf_name_lookup("PCLT", false) == NULL) - return; - ttf_seek_tab("PCLT", TTF_FIXED_SIZE + TTF_ULONG_SIZE + TTF_USHORT_SIZE); - fd_cur->font_dim[XHEIGHT_CODE].val = ttf_funit(get_ushort()); - ttf_skip(2 * TTF_USHORT_SIZE); - fd_cur->font_dim[CAPHEIGHT_CODE].val = ttf_funit(get_ushort()); - fd_cur->font_dim[XHEIGHT_CODE].set = true; - fd_cur->font_dim[CAPHEIGHT_CODE].set = true; -} - -static void ttf_read_hmtx(void) -{ - glyph_entry *glyph; - TTF_UFWORD last_advWidth; - ttf_seek_tab("hmtx", 0); - for (glyph = glyph_tab; glyph - glyph_tab < nhmtxs; glyph++) { - glyph->advWidth = get_ufword(); - glyph->lsb = get_ufword(); - } - if (nhmtxs < glyphs_count) { - last_advWidth = glyph[-1].advWidth; - for (; glyph - glyph_tab < glyphs_count; glyph++) { - glyph->advWidth = last_advWidth; - glyph->lsb = get_ufword(); - } - } -} - -void ttf_read_post(void) -{ - int k, nnames; - long length; - long int_part, frac_part; - int sign = 1; - TTF_FIXED italic_angle; - char *p; - glyph_entry *glyph; - const dirtab_entry *tab = ttf_seek_tab("post", 0); - post_format = get_fixed(); - italic_angle = get_fixed(); - int_part = italic_angle >> 16; - if (int_part > 0x7FFF) { /* a negative number */ - int_part = 0x10000 - int_part; - sign = -1; - } - frac_part = italic_angle % 0x10000; - fd_cur->font_dim[ITALIC_ANGLE_CODE].val = - sign * (int_part + frac_part * 1.0 / 0x10000); - fd_cur->font_dim[ITALIC_ANGLE_CODE].set = true; - if (glyph_tab == NULL) - return; /* being called from writeotf() */ - ttf_skip(2 * TTF_FWORD_SIZE + 5 * TTF_ULONG_SIZE); - switch (post_format) { - case 0x10000: - for (glyph = glyph_tab; glyph - glyph_tab < NMACGLYPHS; glyph++) { - glyph->name = mac_glyph_names[glyph - glyph_tab]; - glyph->name_index = glyph - glyph_tab; - } - break; - case 0x20000: - nnames = get_ushort(); /* some fonts have this value different from nglyphs */ - for (glyph = glyph_tab; glyph - glyph_tab < nnames; glyph++) - glyph->name_index = get_ushort(); - /*length = tab->length - (xftell (INFILE, cur_file_name) - tab->offset); */ - length = tab->length - (ttf_curbyte - tab->offset); - glyph_name_buf = xtalloc(length, char); - for (p = glyph_name_buf; p - glyph_name_buf < length;) { - for (k = get_byte(); k > 0; k--) - *p++ = get_char(); - *p++ = 0; - } - for (glyph = glyph_tab; glyph - glyph_tab < nnames; glyph++) { - if (glyph->name_index < NMACGLYPHS) - glyph->name = mac_glyph_names[glyph->name_index]; - else { - p = glyph_name_buf; - k = glyph->name_index - NMACGLYPHS; - for (; k > 0; k--) - p = strend(p) + 1; - glyph->name = p; - } - } - break; - case 0x00030000: - for (glyph = glyph_tab; glyph - glyph_tab < NMACGLYPHS; glyph++) { - glyph->name_index = glyph - glyph_tab; - } - break; - default: - pdftex_fail("unsupported format (%.8X) of `post' table", - (unsigned int) post_format); - } -} - -static void ttf_read_loca(void) -{ - glyph_entry *glyph; - ttf_seek_tab("loca", 0); - if (loca_format != 0) - for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count + 1; glyph++) - glyph->offset = get_ulong(); - else - for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count + 1; glyph++) - glyph->offset = get_ushort() << 1; -} - -void ttf_read_tabdir(void) -{ - int i; - dirtab_entry *tab; - ttf_skip(TTF_FIXED_SIZE); /* ignore the sfnt number */ - dir_tab = xtalloc(ntabs = get_ushort(), dirtab_entry); - ttf_skip(3 * TTF_USHORT_SIZE); - for (tab = dir_tab; tab - dir_tab < ntabs; tab++) { - for (i = 0; i < 4; i++) - tab->tag[i] = get_char(); - tab->checksum = get_ulong(); - tab->offset = get_ulong(); - tab->length = get_ulong(); - } -} - -static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid, - boolean warn) -{ - seg_entry *seg_tab, *s; - TTF_USHORT *glyphId, format, segCount; - TTF_USHORT ncmapsubtabs, tmp_pid, tmp_eid; - TTF_ULONG cmap_offset, tmp_offset; - long n, i, k, length, index; - ttf_cmap_entry tmp_e, *p; - void **aa; - - /* loop up in ttf_cmap_tree first, return if found */ - tmp_e.ttf_name = ttf_name; - tmp_e.pid = pid; - tmp_e.eid = eid; - if (ttf_cmap_tree == NULL) { - ttf_cmap_tree = avl_create(comp_ttf_cmap_entry, NULL, &avl_xallocator); - assert(ttf_cmap_tree != NULL); - } - p = (ttf_cmap_entry *) avl_find(ttf_cmap_tree, &tmp_e); - if (p != NULL) - return p; - - /* not found, have to read it */ - ttf_seek_tab("cmap", TTF_USHORT_SIZE); /* skip the table vesrion number (=0) */ - ncmapsubtabs = get_ushort(); - /* cmap_offset = xftell (INFILE, cur_file_name) - 2 * TTF_USHORT_SIZE; */ - cmap_offset = ttf_curbyte - 2 * TTF_USHORT_SIZE; - cmap_tab = xtalloc(ncmapsubtabs, cmap_entry); - for (i = 0; i < ncmapsubtabs; ++i) { - tmp_pid = get_ushort(); - tmp_eid = get_ushort(); - tmp_offset = get_ulong(); - if (tmp_pid == pid && tmp_eid == eid) { - ttf_seek_off(cmap_offset + tmp_offset); - format = get_ushort(); - if (format == 4) - goto read_cmap_format_4; - else { - if (warn) - pdftex_warn("cmap format %i unsupported", format); - return NULL; - } - } - } - if (warn) - pdftex_warn("cannot find cmap subtable for (pid,eid) = (%i, %i)", - pid, eid); - return NULL; - read_cmap_format_4: - /* initialize the new entry */ - p = new_ttf_cmap_entry(); - p->ttf_name = xstrdup(ttf_name); - p->pid = pid; - p->eid = eid; - p->table = xtalloc(0x10000, long); - for (i = 0; i < 0x10000; ++i) - p->table[i] = -1; /* unassigned yet */ - - /* read the subtable */ - length = get_ushort(); /* length of subtable */ - (void) get_ushort(); /* skip the version number */ - segCount = get_ushort() / 2; - (void) get_ushort(); /* skip searchRange */ - (void) get_ushort(); /* skip entrySelector */ - (void) get_ushort(); /* skip rangeShift */ - seg_tab = xtalloc(segCount, seg_entry); - for (s = seg_tab; s - seg_tab < segCount; s++) - s->endCode = get_ushort(); - (void) get_ushort(); /* skip reversedPad */ - for (s = seg_tab; s - seg_tab < segCount; s++) - s->startCode = get_ushort(); - for (s = seg_tab; s - seg_tab < segCount; s++) - s->idDelta = get_ushort(); - for (s = seg_tab; s - seg_tab < segCount; s++) - s->idRangeOffset = get_ushort(); - length -= 8 * TTF_USHORT_SIZE + 4 * segCount * TTF_USHORT_SIZE; - n = length / TTF_USHORT_SIZE; /* number of glyphID's */ - glyphId = xtalloc(n, TTF_USHORT); - for (i = 0; i < n; i++) - glyphId[i] = get_ushort(); - for (s = seg_tab; s - seg_tab < segCount; s++) { - for (i = s->startCode; i <= s->endCode; i++) { - if (i == 0xFFFF) - break; - if (s->idRangeOffset != 0xFFFF) { - if (s->idRangeOffset == 0) - index = (s->idDelta + i) & 0xFFFF; - else { - k = (i - s->startCode) + s->idRangeOffset / 2 + - (s - seg_tab) - segCount; - assert(k >= 0 && k < n); - index = glyphId[k]; - if (index != 0) - index = (index + s->idDelta) & 0xFFFF; - } - if (index >= glyphs_count) - pdftex_fail("cmap: glyph index %li out of range [0..%i)", - index, glyphs_count); - if (p->table[i] != -1) - pdftex_warn - ("cmap: multiple glyphs are mapped to unicode %.4lX, " - "only %li will be used (glyph %li being ignored)", i, - p->table[i], index); - else - p->table[i] = index; - } - } - } - xfree(seg_tab); - xfree(glyphId); - aa = avl_probe(ttf_cmap_tree, p); - assert(aa != NULL); - return p; -} - -static void ttf_read_font(void) -{ - ttf_read_tabdir(); - if (ttf_name_lookup("PCLT", false) == NULL) - new_ntabs--; - if (ttf_name_lookup("fpgm", false) == NULL) - new_ntabs--; - if (ttf_name_lookup("cvt ", false) == NULL) - new_ntabs--; - if (ttf_name_lookup("prep", false) == NULL) - new_ntabs--; - ttf_read_mapx(); - ttf_read_head(); - ttf_read_hhea(); - ttf_read_pclt(); - ttf_read_hmtx(); - ttf_read_post(); - ttf_read_loca(); - ttf_read_name(); -} - -static void ttf_reset_chksm(dirtab_entry * tab) -{ - checksum = 0; - tab_length = 0; - tmp_ulong = 0; - tab->offset = ttf_offset(); - if (tab->offset % 4 != 0) - pdftex_warn("offset of `%4.4s' is not a multiple of 4", tab->tag); -} - - -static void ttf_set_chksm(dirtab_entry * tab) -{ - tab->length = ttf_offset() - tab->offset; - tab->checksum = ttf_getchksm(); -} - -static void ttf_copytab(const char *name) -{ - long i; - dirtab_entry *tab = ttf_seek_tab(name, 0); - ttf_reset_chksm(tab); - for (i = tab->length; i > 0; i--) - copy_char(); - ttf_set_chksm(tab); -} - -#define BYTE_ENCODING_LENGTH \ - ((256)*TTF_BYTE_SIZE + 3*TTF_USHORT_SIZE) - -static void ttf_byte_encoding(void) -{ - ttfenc_entry *e; - (void) put_ushort(0); /* format number (0: byte encoding table) */ - (void) put_ushort(BYTE_ENCODING_LENGTH); /* length of table */ - (void) put_ushort(0); /* version number */ - for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) - if (e->newindex < 256) { - put_byte(e->newindex); - } else { - if (e->name != notdef) - pdftex_warn - ("glyph `%s' has been mapped to `%s' in `ttf_byte_encoding' cmap table", - e->name, notdef); - put_byte(0); /* notdef */ - } -} - -#define TRIMMED_TABLE_MAP_LENGTH (TTF_USHORT_SIZE*(5 + (256))) - -static void ttf_trimmed_table_map(void) -{ - ttfenc_entry *e; - (void) put_ushort(6); /* format number (6): trimmed table mapping */ - (void) put_ushort(TRIMMED_TABLE_MAP_LENGTH); - (void) put_ushort(0); /* version number (0) */ - (void) put_ushort(0); /* first character code */ - (void) put_ushort(256); /* number of character code in table */ - for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) - (void) put_ushort(e->newindex); -} - -#define SEG_MAP_DELTA_LENGTH ((16 + (256))*TTF_USHORT_SIZE) - -static void ttf_seg_map_delta(void) -{ - ttfenc_entry *e; - (void) put_ushort(4); /* format number (4: segment mapping to delta values) */ - (void) put_ushort(SEG_MAP_DELTA_LENGTH); - (void) put_ushort(0); /* version number */ - (void) put_ushort(4); /* 2*segCount */ - (void) put_ushort(4); /* searchRange */ - (void) put_ushort(1); /* entrySelector */ - (void) put_ushort(0); /* rangeShift */ - (void) put_ushort(0xF0FF); /* endCount[0] */ - (void) put_ushort(0xFFFF); /* endCount[1] */ - (void) put_ushort(0); /* reversedPad */ - (void) put_ushort(0xF000); /* startCount[0] */ - (void) put_ushort(0xFFFF); /* startCount[1] */ - (void) put_ushort(0); /* idDelta[0] */ - (void) put_ushort(1); /* idDelta[1] */ - (void) put_ushort(2 * TTF_USHORT_SIZE); /* idRangeOffset[0] */ - (void) put_ushort(0); /* idRangeOffset[1] */ - for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) - (void) put_ushort(e->newindex); -} - -#define CMAP_ENTRY_LENGTH (2*TTF_USHORT_SIZE + TTF_ULONG_SIZE) - -static void ttf_select_cmap(void) -{ - assert(sizeof(new_cmap_tab) <= NEW_CMAP_SIZE * sizeof(cmap_entry)); - new_cmap_tab[0].platform_id = 1; /* Macintosh */ - new_cmap_tab[0].encoding_id = 0; /* Symbol; ignore code page */ - new_cmap_tab[0].format = new_glyphs_count < 256 ? 0 /* byte encoding */ - : 6; /* trimmed table mapping */ - new_cmap_tab[1].platform_id = 3; /* Microsoft */ - new_cmap_tab[1].encoding_id = 0; /* Symbol; ignore code page */ - new_cmap_tab[1].format = 4; /* segment mapping to delta */ -} - -static void ttf_write_cmap(void) -{ - cmap_entry *ce; - long offset; - dirtab_entry *tab = ttf_name_lookup("cmap", true); - ttf_select_cmap(); - ttf_reset_chksm(tab); - (void) put_ushort(0); /* table version number (0) */ - (void) put_ushort(NEW_CMAP_SIZE); /* number of encoding tables */ - offset = 2 * TTF_USHORT_SIZE + NEW_CMAP_SIZE * CMAP_ENTRY_LENGTH; - for (ce = new_cmap_tab; ce - new_cmap_tab < NEW_CMAP_SIZE; ce++) { - ce->offset = offset; - switch (ce->format) { - case 0: - offset += BYTE_ENCODING_LENGTH; - break; - case 4: - offset += SEG_MAP_DELTA_LENGTH; - break; - case 6: - offset += TRIMMED_TABLE_MAP_LENGTH; - break; - default: - pdftex_fail("invalid format (it should not have happened)"); - } - (void) put_ushort(ce->platform_id); - (void) put_ushort(ce->encoding_id); - put_ulong(ce->offset); - } - for (ce = new_cmap_tab; ce - new_cmap_tab < NEW_CMAP_SIZE; ce++) { - switch (ce->format) { - case 0: - ttf_byte_encoding(); - break; - case 4: - ttf_seg_map_delta(); - break; - case 6: - ttf_trimmed_table_map(); - break; - } - } - ttf_set_chksm(tab); -} - -static int prepend_subset_tags(int index, char *p) -{ - boolean is_unicode; - int i; - assert(index >= 0 && index < name_record_num && fd_cur->subset_tag != NULL); - is_unicode = (name_tab[index].platform_id == 3); - if (is_unicode) { - for (i = 0; i < 6; ++i) { - *p++ = 0; - *p++ = fd_cur->subset_tag[i]; - } - *p++ = 0; - *p++ = '+'; - return 14; - } else { - strncpy(p, fd_cur->subset_tag, 6); - p += 6; - *p++ = '+'; - return 7; - } -} - - -static void ttf_write_name(void) -{ - int i, l; - char *p; - int new_name_buf_size; - char *new_name_buf; - name_record *n; - dirtab_entry *tab = ttf_name_lookup("name", true); - if (is_subsetted(fd_cur->fm)) { - l = 0; - for (i = 0; i < name_record_num; i++) - l += name_tab[i].length + 14; /* maximum lengh of new stogare area */ - new_name_buf = xtalloc(l, char); - /* additional space for subset tags */ - p = new_name_buf; - for (i = 0; i < name_record_num; i++) { - n = name_tab + i; - n->new_offset = p - new_name_buf; - if ((n->name_id == 1 || n->name_id == 3 || - n->name_id == 4 || n->name_id == 6) && - ((n->platform_id == 1 && n->encoding_id == 0) || - (n->platform_id == 3 && n->encoding_id == 0) || - (n->platform_id == 3 && n->encoding_id == 1))) { - l = prepend_subset_tags(i, p); - p += l; - } else - l = 0; - memcpy(p, name_buf + n->offset, n->length); - p += n->length; - n->new_length = n->length + l; - } - new_name_buf_size = p - new_name_buf; - } else { - new_name_buf = name_buf; - new_name_buf_size = name_buf_size; - } - ttf_reset_chksm(tab); - (void) put_ushort(0); /* Format selector */ - (void) put_ushort(name_record_num); - (void) put_ushort(3 * TTF_USHORT_SIZE + - name_record_num * 6 * TTF_USHORT_SIZE); - for (i = 0; i < name_record_num; i++) { - (void) put_ushort(name_tab[i].platform_id); - (void) put_ushort(name_tab[i].encoding_id); - (void) put_ushort(name_tab[i].language_id); - (void) put_ushort(name_tab[i].name_id); - (void) put_ushort(name_tab[i].new_length); - (void) put_ushort(name_tab[i].new_offset); - } - for (p = new_name_buf; p - new_name_buf < new_name_buf_size; p++) - put_char(*p); - ttf_set_chksm(tab); - if (new_name_buf != name_buf) - xfree(new_name_buf); -} - -static void ttf_write_dirtab(void) -{ - dirtab_entry *tab; - TTF_ULONG i, k; - char *p; - const integer save_offset = ttf_offset(); - ttf_seek_outbuf(TABDIR_OFF); - if (is_subsetted(fd_cur->fm)) { - for (i = 0; i < DEFAULT_NTABS; i++) { - tab = ttf_name_lookup(newtabnames[i], false); - if (tab == NULL) - continue; - for (k = 0; k < 4; k++) - put_char(tab->tag[k]); - put_ulong(tab->checksum); - put_ulong(tab->offset); - put_ulong(tab->length); - } - } else { - for (tab = dir_tab; tab - dir_tab < ntabs; tab++) { - for (k = 0; k < 4; k++) - put_char(tab->tag[k]); - put_ulong(tab->checksum); - put_ulong(tab->offset); - put_ulong(tab->length); - } - } - /* adjust checkSumAdjustment */ - tmp_ulong = 0; - checksum = 0; - for (p = fb_array, i = 0; i < (unsigned) save_offset;) { - tmp_ulong = (tmp_ulong << 8) + *p++; - i++; - if (i % 4 == 0) { - checksum += tmp_ulong; - tmp_ulong = 0; - } - } - if (i % 4 != 0) { - pdftex_warn("font length is not a multiple of 4 (%li)", i); - checksum <<= 8 * (4 - i % 4); - } - k = 0xB1B0AFBA - checksum; - ttf_seek_outbuf(checkSumAdjustment_offset); - put_ulong(k); - ttf_seek_outbuf(save_offset); -} - -static void ttf_write_glyf(void) -{ - long *id, k; - TTF_USHORT idx; - TTF_USHORT flags; - dirtab_entry *tab = ttf_name_lookup("glyf", true); - const long glyf_offset = tab->offset; - const long new_glyf_offset = ttf_offset(); - ttf_reset_chksm(tab); - for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { - glyph_tab[*id].newoffset = ttf_offset() - new_glyf_offset; - if (glyph_tab[*id].offset != glyph_tab[*id + 1].offset) { - ttf_seek_off(glyf_offset + glyph_tab[*id].offset); - k = copy_short(); - ttf_ncopy(4 * TTF_FWORD_SIZE); - if (k < 0) { - do { - flags = copy_ushort(); - idx = get_ushort(); - if (glyph_tab[idx].newindex < 0) { - glyph_tab[idx].newindex = new_glyphs_count; - glyph_index[new_glyphs_count++] = idx; - /* - N.B.: Here we change `new_glyphs_count', - which appears in the condition of the `for' loop - */ - } - (void) put_ushort(glyph_tab[idx].newindex); - if (flags & ARG_1_AND_2_ARE_WORDS) - ttf_ncopy(2 * TTF_SHORT_SIZE); - else - ttf_ncopy(TTF_USHORT_SIZE); - if (flags & WE_HAVE_A_SCALE) - ttf_ncopy(TTF_F2DOT14_SIZE); - else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) - ttf_ncopy(2 * TTF_F2DOT14_SIZE); - else if (flags & WE_HAVE_A_TWO_BY_TWO) - ttf_ncopy(4 * TTF_F2DOT14_SIZE); - } while (flags & MORE_COMPONENTS); - if (flags & WE_HAVE_INSTRUCTIONS) - ttf_ncopy(copy_ushort()); - } else - ttf_ncopy(glyph_tab[*id + 1].offset - glyph_tab[*id].offset - - TTF_USHORT_SIZE - 4 * TTF_FWORD_SIZE); - } - } - last_glyf_offset = ttf_offset() - new_glyf_offset; - ttf_set_chksm(tab); -} - -static void ttf_reindex_glyphs(void) -{ - ttfenc_entry *e; - glyph_entry *glyph; - int index; - long *t; - ttf_cmap_entry *cmap = NULL; - boolean cmap_not_found = false; - - /* - * reindexing glyphs: we append index of used glyphs to `glyph_index' - * while going through `ttfenc_tab'. After appending a new entry to - * `glyph_index' we set field `newindex' of corresponding entries in both - * `glyph_tab' and `ttfenc_tab' to the newly created index - */ - for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) { - e->newindex = 0; /* index of ".notdef" glyph */ - - /* handle case of subfonts first */ - if (is_subfont(fd_cur->fm)) { - if (e->code == -1) - continue; - assert(fd_cur->fm->pid != -1 && fd_cur->fm->eid != -1); - if (cmap == NULL && !cmap_not_found) { - cmap = - ttf_read_cmap(fd_cur->fm->ff_name, fd_cur->fm->pid, - fd_cur->fm->eid, true); - if (cmap == NULL) - cmap_not_found = true; - } - if (cmap == NULL) - continue; - t = cmap->table; - assert(t != NULL && e->code < 0x10000); - if (t[e->code] < 0) { - pdftex_warn - ("subfont %s: wrong mapping: character %li --> 0x%4.4lX --> .notdef", - fd_cur->fm->tfm_name, (long) (e - ttfenc_tab), e->code); - continue; - } - assert(t[e->code] >= 0 && t[e->code] < glyphs_count); /* t has been read from ttf */ - glyph = glyph_tab + t[e->code]; - goto append_new_glyph; - } - - /* handle case of reencoded fonts */ - if (e->name == notdef) - continue; - /* scan form `index123' */ - if (sscanf(e->name, GLYPH_PREFIX_INDEX "%i", &index) == 1) { - if (index >= glyphs_count) { - pdftex_warn("`%s' out of valid range [0..%i)", - e->name, glyphs_count); - continue; - } - glyph = glyph_tab + index; - goto append_new_glyph; - } - /* scan form `uniABCD' */ - if (sscanf(e->name, GLYPH_PREFIX_UNICODE "%X", &index) == 1) { - if (cmap == NULL && !cmap_not_found) { - /* need to read the unicode mapping, ie (pid,eid) = (3,1) or (0,3) */ - cmap = ttf_read_cmap(fd_cur->fm->ff_name, 3, 1, false); - if (cmap == NULL) - cmap = ttf_read_cmap(fd_cur->fm->ff_name, 0, 3, false); - if (cmap == NULL) { - pdftex_warn - ("no unicode mapping found, all `uniXXXX' names will be ignored"); - cmap_not_found = true; /* once only */ - } - } - if (cmap == NULL) - continue; - t = cmap->table; - assert(t != NULL); - if (t[index] != -1) { - if (t[index] >= glyphs_count) { - pdftex_warn - ("`%s' is mapped to index %li which is out of valid range [0..%i)", - e->name, t[index], glyphs_count); - continue; - } - glyph = glyph_tab + t[index]; - goto append_new_glyph; - } else { - pdftex_warn("`unicode %s%.4X' is not mapped to any glyph", - GLYPH_PREFIX_UNICODE, index); - continue; - } - } - /* look up by name */ - for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count; glyph++) - if (glyph->name != notdef && strcmp(glyph->name, e->name) == 0) - break; - if (!(glyph - glyph_tab < glyphs_count)) { - pdftex_warn("glyph `%s' not found", e->name); - continue; - } - append_new_glyph: - assert(glyph > glyph_tab && glyph - glyph_tab < glyphs_count); - if (glyph->newindex < 0) { - glyph_index[new_glyphs_count] = (short) (glyph - glyph_tab); - glyph->newindex = new_glyphs_count; - new_glyphs_count++; - } - e->newindex = glyph->newindex; - } -} - -static void ttf_write_head(void) -{ - dirtab_entry *tab; - tab = ttf_seek_tab("head", 0); - ttf_reset_chksm(tab); - ttf_ncopy(2 * TTF_FIXED_SIZE); - checkSumAdjustment_offset = ttf_offset(); - put_ulong(0); - ttf_skip(TTF_ULONG_SIZE); /* skip checkSumAdjustment */ - ttf_ncopy(TTF_ULONG_SIZE + 2 * TTF_USHORT_SIZE + 16 + - 4 * TTF_FWORD_SIZE + 2 * TTF_USHORT_SIZE + TTF_SHORT_SIZE); - if (is_subsetted(fd_cur->fm)) { - (void) put_short(loca_format); - (void) put_short(0); - } else - ttf_ncopy(2 * TTF_SHORT_SIZE); - ttf_set_chksm(tab); -} - -static void ttf_write_hhea(void) -{ - dirtab_entry *tab; - tab = ttf_seek_tab("hhea", 0); - ttf_reset_chksm(tab); - ttf_ncopy(TTF_FIXED_SIZE + 3 * TTF_FWORD_SIZE + TTF_UFWORD_SIZE + - 3 * TTF_FWORD_SIZE + 8 * TTF_SHORT_SIZE); - (void) put_ushort(new_glyphs_count); - ttf_set_chksm(tab); -} - -static void ttf_write_htmx(void) -{ - long *id; - dirtab_entry *tab = ttf_seek_tab("hmtx", 0); - ttf_reset_chksm(tab); - for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { - put_ufword(glyph_tab[*id].advWidth); - put_ufword(glyph_tab[*id].lsb); - } - ttf_set_chksm(tab); -} - -static void ttf_write_loca(void) -{ - long *id; - dirtab_entry *tab = ttf_seek_tab("loca", 0); - ttf_reset_chksm(tab); - loca_format = 0; - if (last_glyf_offset >= 0x00020000 || (last_glyf_offset & 1)) - loca_format = 1; - else - for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) - if (glyph_tab[*id].newoffset & 1) { - loca_format = 1; - break; - } - if (loca_format != 0) { - for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) - put_ulong(glyph_tab[*id].newoffset); - put_ulong(last_glyf_offset); - } else { - for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) - (void) put_ushort(glyph_tab[*id].newoffset / 2); - (void) put_ushort(last_glyf_offset / 2); - } - ttf_set_chksm(tab); -} - -static void ttf_write_mapx(void) -{ - dirtab_entry *tab = ttf_seek_tab("maxp", TTF_FIXED_SIZE + TTF_USHORT_SIZE); - ttf_reset_chksm(tab); - put_fixed(0x00010000); - (void) put_ushort(new_glyphs_count); - ttf_ncopy(13 * TTF_USHORT_SIZE); - ttf_set_chksm(tab); -} - -static void ttf_write_OS2(void) -{ - dirtab_entry *tab = ttf_seek_tab("OS/2", 0); - TTF_USHORT version; - ttf_reset_chksm(tab); - version = get_ushort(); - if (version > 3) - pdftex_fail("unknown version of OS/2 table (%.4X)", version); - (void) put_ushort(0x0001); /* fix version to 1 */ - ttf_ncopy(2 * TTF_USHORT_SIZE + 13 * TTF_SHORT_SIZE + 10 * TTF_BYTE_SIZE); - ttf_skip(4 * TTF_ULONG_SIZE); /* ulUnicodeRange 1--4 */ - put_ulong(0x00000003); /* Basic Latin + Latin-1 Supplement (0x0000--0x00FF) */ - put_ulong(0x10000000); /* Private Use (0xE000--0xF8FF) */ - put_ulong(0x00000000); - put_ulong(0x00000000); - ttf_ncopy(4 * TTF_CHAR_SIZE + TTF_USHORT_SIZE); /* achVendID + fsSelection */ - ttf_skip(2 * TTF_USHORT_SIZE); - (void) put_ushort(0x0000); /* usFirstCharIndex */ - (void) put_ushort(0xF0FF); /* usLastCharIndex */ - ttf_ncopy(5 * TTF_USHORT_SIZE); - /* for version 0 the OS/2 table ends here, the rest is for version 1 */ - put_ulong(0x80000000); /* Symbol Character Set---don't use any code page */ - put_ulong(0x00000000); - ttf_set_chksm(tab); -} - -static boolean unsafe_name(const char *s) -{ - const char **p; - for (p = ambiguous_names; *p != NULL; p++) - if (strcmp(s, *p) == 0) - return true; - return false; -} - -static void ttf_write_post(void) -{ - dirtab_entry *tab = ttf_seek_tab("post", TTF_FIXED_SIZE); - glyph_entry *glyph; - const char *s; - long *id; - int l; - ttf_reset_chksm(tab); - if (!fd_cur->write_ttf_glyph_names || post_format == 0x00030000) { - put_fixed(0x00030000); - ttf_ncopy(TTF_FIXED_SIZE + 2 * TTF_FWORD_SIZE + 5 * TTF_ULONG_SIZE); - } else { - put_fixed(0x00020000); - ttf_ncopy(TTF_FIXED_SIZE + 2 * TTF_FWORD_SIZE + 5 * TTF_ULONG_SIZE); - (void) put_ushort(new_glyphs_count); - k = 0; - for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { - glyph = glyph_tab + *id; - if (glyph->name_index >= NMACGLYPHS || unsafe_name(glyph->name)) - glyph->name_index = NMACGLYPHS + k++; - (void) put_ushort(glyph->name_index); - } - for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { - glyph = glyph_tab + *id; - if (glyph->name_index >= NMACGLYPHS) { - s = glyph->name; - l = strlen(s); - put_byte(l); - while (l-- > 0) - put_char(*s++); - } - } - } - ttf_set_chksm(tab); -} - -static void ttf_init_font(int n) -{ - int i, k; - for (i = 1, k = 0; i <= n; i <<= 1, k++); - put_fixed(0x00010000); /* font version */ - (void) put_ushort(n); /* number of tables */ - (void) put_ushort(i << 3); /* search range */ - (void) put_ushort(k - 1); /* entry selector */ - (void) put_ushort((n << 4) - (i << 3)); /* range shift */ - ttf_seek_outbuf(TABDIR_OFF + n * 4 * TTF_ULONG_SIZE); -} - -static void ttf_subset_font(void) -{ - ttf_init_font(new_ntabs); - if (ttf_name_lookup("PCLT", false) != NULL) - ttf_copytab("PCLT"); - if (ttf_name_lookup("fpgm", false) != NULL) - ttf_copytab("fpgm"); - if (ttf_name_lookup("cvt ", false) != NULL) - ttf_copytab("cvt "); - if (ttf_name_lookup("prep", false) != NULL) - ttf_copytab("prep"); - ttf_reindex_glyphs(); - ttf_write_glyf(); - ttf_write_loca(); - ttf_write_OS2(); - ttf_write_head(); - ttf_write_hhea(); - ttf_write_htmx(); - ttf_write_mapx(); - ttf_write_name(); - ttf_write_post(); - ttf_write_cmap(); - ttf_write_dirtab(); -} - -static void ttf_copy_font(void) -{ - dirtab_entry *tab; - ttf_init_font(ntabs); - for (tab = dir_tab; tab - dir_tab < ntabs; tab++) { - if (strncmp(tab->tag, "head", 4) == 0) - ttf_write_head(); - else - ttf_copytab(tab->tag); - } - ttf_write_dirtab(); -} - -void writettf(fd_entry * fd) -{ - int callback_id; - int file_opened = 0; - char *ftemp = NULL; - fd_cur = fd; /* fd_cur is global inside writettf.c */ - assert(fd_cur->fm != NULL); - assert(is_truetype(fd_cur->fm)); - assert(is_included(fd_cur->fm)); - - set_cur_file_name(fd_cur->fm->ff_name); - - if (is_subsetted(fd_cur->fm) && (fd_cur->fe == NULL) - && !is_subfont(fd_cur->fm)) { - pdftex_fail("Subset TrueType must be a reencoded or a subfont"); - } - ttf_curbyte = 0; - ttf_size = 0; - callback_id = callback_defined(find_truetype_file_callback); - if (callback_id > 0) { - if (run_callback - (callback_id, "S->S", (char *) (nameoffile + 1), &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } - } - } - - callback_id = callback_defined(read_truetype_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", (char *) (nameoffile + 1), - &file_opened, &ttf_buffer, &ttf_size) && - file_opened && ttf_size > 0) { - } else { - pdftex_fail("cannot open TrueType font file for reading"); - } - } else { - if (!ttf_open()) { - pdftex_fail("cannot open TrueType font file for reading"); - } - ttf_read_file(); - ttf_close(); - } - cur_file_name = (char *) nameoffile + 1; - if (tracefilenames) { - if (is_subsetted(fd_cur->fm)) - tex_printf("<%s", cur_file_name); - else - tex_printf("<<%s", cur_file_name); - } - fd_cur->ff_found = true; - new_glyphs_count = 2; - new_ntabs = DEFAULT_NTABS; - dir_tab = NULL; - glyph_tab = NULL; - glyph_index = NULL; - glyph_name_buf = NULL; - name_tab = NULL; - name_buf = NULL; - ttf_read_font(); - - pdf_save_offset = pdfoffset(); - pdf_flush(); - - if (is_subsetted(fd_cur->fm)) { - ttf_copy_encoding(); - ttf_subset_font(); - } else - ttf_copy_font(); - ttf_length = ttf_offset(); - - xfree(dir_tab); - xfree(glyph_tab); - xfree(glyph_index); - xfree(glyph_name_buf); - xfree(name_tab); - xfree(name_buf); - if (tracefilenames) { - if (is_subsetted(fd_cur->fm)) - tex_printf(">"); - else - tex_printf(">>"); - } - xfree(ttf_buffer); - cur_file_name = NULL; -} - -static void do_writeotf(fd_entry * fd) -{ - long i; - dirtab_entry *tab; - (void) fd; - dir_tab = NULL; - glyph_tab = NULL; - if (tracefilenames) - tex_printf("<<%s", cur_file_name); - ttf_read_tabdir(); - /* read font parameters */ - if (ttf_name_lookup("head", false) != NULL) - ttf_read_head(); - if (ttf_name_lookup("hhea", false) != NULL) - ttf_read_hhea(); - if (ttf_name_lookup("PCLT", false) != NULL) - ttf_read_pclt(); - if (ttf_name_lookup("post", false) != NULL) - ttf_read_post(); - /* copy font file */ - tab = ttf_seek_tab("CFF ", 0); - for (i = tab->length; i > 0; i--) - copy_char(); - xfree(dir_tab); - /* ttf_close (); */ - if (tracefilenames) - tex_printf(">>"); -} - -void writeotf(fd_entry * fd) -{ - int callback_id; - int file_opened = 0; - char *ftemp = NULL; - - - fd_cur = fd; /* fd_cur is global inside writettf.c */ - assert(fd_cur->fm != NULL); - assert(is_opentype(fd_cur->fm)); - assert(is_included(fd_cur->fm)); - - set_cur_file_name(fd_cur->fm->ff_name); - ttf_curbyte = 0; - ttf_size = 0; - callback_id = callback_defined(find_opentype_file_callback); - if (callback_id > 0) { - if (run_callback - (callback_id, "S->S", (char *) (nameoffile + 1), &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } - } - } - callback_id = callback_defined(read_opentype_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", (char *) (nameoffile + 1), - &file_opened, &ttf_buffer, &ttf_size) && - file_opened && ttf_size > 0) { - } else { - pdftex_fail("cannot open OpenType font file for reading"); - } - } else { - if (!otf_open()) { - pdftex_fail("cannot open OpenType font file for reading"); - } - ttf_read_file(); - ttf_close(); - } - - cur_file_name = (char *) nameoffile + 1; - fd_cur->ff_found = true; - do_writeotf(fd); - xfree(ttf_buffer); - cur_file_name = NULL; -} - -/* - To calculate the checkSum for the 'head' table which itself includes the - checkSumAdjustment entry for the entire font, do the following: - - * Set the checkSumAdjustment to 0. - * Calculate the checksum for all the tables including the 'head' table - and enter that value into the table directory. - * Calculate the checksum for the entire font. - * Subtract that value from the hex value B1B0AFBA. - * Store the result in checkSumAdjustment. - - The checkSum for the 'head table which includes the checkSumAdjustment - entry for the entire font is now incorrect. That is not a problem. Do not - change it. An application attempting to verify that the 'head' table has - not changed should calculate the checkSum for that table by not including - the checkSumAdjustment value, and compare the result with the entry in the - table directory. - - The table directory also includes the offset of the associated tagged - table from the beginning of the font file and the length of that table. - */ diff --git a/Build/source/texk/web2c/luatexdir/font/writettf.h b/Build/source/texk/web2c/luatexdir/font/writettf.h index 03b5cc9da12..a66cf011251 100644 --- a/Build/source/texk/web2c/luatexdir/font/writettf.h +++ b/Build/source/texk/web2c/luatexdir/font/writettf.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: writettf.h 2271 2009-04-12 23:42:21Z oneiros $ */ +/* $Id: writettf.h 3400 2010-01-27 16:10:42Z taco $ */ #ifndef WRITETTF_H # define WRITETTF_H 1 @@ -74,7 +74,7 @@ typedef unsigned short TTF_F2DOT14; # define get_ufword() get_type(TTF_UFWORD) # define get_f2dot14() get_type(TTF_F2DOT14) -# define put_num(t,n) ((t)ttf_putnum(t##_SIZE, n)) +# define put_num(t,n) ((t)ttf_putnum(pdf,t##_SIZE, n)) # define put_char(n) (void)put_num(TTF_CHAR, n) # define put_byte(n) (void)put_num(TTF_BYTE, n) @@ -146,8 +146,8 @@ typedef struct { extern fd_entry *fd_cur; /* pointer to the current font descriptor */ extern unsigned char *ttf_buffer; -extern integer ttf_size; -extern integer ttf_curbyte; +extern int ttf_size; +extern int ttf_curbyte; extern glyph_entry *glyph_tab; extern dirtab_entry *dir_tab; extern dirtab_entry *ttf_name_lookup(const char *s, boolean required); @@ -161,16 +161,16 @@ extern void ttf_read_post(void); extern FILE *ttf_file; -# define ttf_open() \ - (ttf_file = fopen((char *) nameoffile + 1, FOPEN_RBIN_MODE)) -# define otf_open() \ - (ttf_file = fopen((char *) nameoffile + 1, FOPEN_RBIN_MODE)) +# define ttf_open(a) \ + (ttf_file = fopen((char *) (a), FOPEN_RBIN_MODE)) +# define otf_open(a) \ + (ttf_file = fopen((char *) (a), FOPEN_RBIN_MODE)) # define ttf_read_file() \ readbinfile(ttf_file,&ttf_buffer,&ttf_size) # define ttf_close() xfclose(ttf_file,cur_file_name) # define ttf_getchar() ttf_buffer[ttf_curbyte++] # define ttf_eof() (ttf_curbyte>ttf_size) -extern long ttf_putnum(int s, long n); +extern long ttf_putnum(PDF pdf, int s, long n); extern long ttf_getnum(int s); #endif diff --git a/Build/source/texk/web2c/luatexdir/font/writettf.w b/Build/source/texk/web2c/luatexdir/font/writettf.w new file mode 100644 index 00000000000..bbeb346c020 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writettf.w @@ -0,0 +1,1834 @@ +% writettf.w +% +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" +#include "font/writettf.h" +#include + +static const char _svn_version[] = + "$Id: writettf.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writettf.w $"; + +#define DEFAULT_NTABS 14 +#define NEW_CMAP_SIZE 2 + +#define ttf_putchar(A) fb_putchar(pdf,(A)) +#define ttf_offset() fb_offset(pdf) +#define ttf_seek_outbuf(A) fb_seek(pdf,(A)) + +unsigned char *ttf_buffer = NULL; +int ttf_size = 0; +int ttf_curbyte = 0; + +typedef struct { + char *name; /* name of glyph */ + long code; /* charcode in case of subfonts */ + long newindex; /* new index of glyph in output file */ + +} ttfenc_entry; + +typedef struct { + TTF_USHORT platform_id; + TTF_USHORT encoding_id; + TTF_USHORT language_id; + TTF_USHORT name_id; + TTF_USHORT length; + TTF_USHORT offset; + TTF_USHORT new_offset; + TTF_USHORT new_length; +} name_record; + +typedef struct { + char *ttf_name; + TTF_USHORT pid; + TTF_USHORT eid; + long *table; +} ttf_cmap_entry; + +static TTF_USHORT ntabs; +static TTF_USHORT upem; +static TTF_FIXED post_format; +static TTF_SHORT loca_format; +static TTF_ULONG last_glyf_offset; +static TTF_USHORT glyphs_count; +static TTF_USHORT new_glyphs_count; +static TTF_USHORT nhmtxs; +static TTF_USHORT new_ntabs; + +glyph_entry *glyph_tab; +dirtab_entry *dir_tab; + +static long *glyph_index; +static cmap_entry *cmap_tab, new_cmap_tab[NEW_CMAP_SIZE]; +static name_record *name_tab; +static int name_record_num; +static char *name_buf; +static int name_buf_size; +static char *glyph_name_buf; +static TTF_ULONG checksum; +static TTF_ULONG tab_length; +static TTF_ULONG tmp_ulong; +static TTF_ULONG checkSumAdjustment_offset; +FILE *ttf_file; +static ttfenc_entry ttfenc_tab[256]; + +fd_entry *fd_cur; /* pointer to the current font descriptor */ + +static struct avl_table *ttf_cmap_tree = NULL; + +int ttf_length; + +@ This used to be macnames.c + +@c +char notdef[] = ".notdef"; + +const char *mac_glyph_names[] = { +/* 0x00 */ + notdef, + ".null", + "CR", + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quotesingle", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", +/* 0x10 */ + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", +/* 0x20 */ + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", +/* 0x30 */ + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", +/* 0x40 */ + "bracketright", + "asciicircum", + "underscore", + "grave", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", +/* 0x50 */ + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", +/* 0x60 */ + "braceright", + "asciitilde", + "Adieresis", + "Aring", + "Ccedilla", + "Eacute", + "Ntilde", + "Odieresis", + "Udieresis", + "aacute", + "agrave", + "acircumflex", + "adieresis", + "atilde", + "aring", + "ccedilla", +/* 0x70 */ + "eacute", + "egrave", + "ecircumflex", + "edieresis", + "iacute", + "igrave", + "icircumflex", + "idieresis", + "ntilde", + "oacute", + "ograve", + "ocircumflex", + "odieresis", + "otilde", + "uacute", + "ugrave", +/* 0x80 */ + "ucircumflex", + "udieresis", + "dagger", + "degree", + "cent", + "sterling", + "section", + "bullet", + "paragraph", + "germandbls", + "registered", + "copyright", + "trademark", + "acute", + "dieresis", + "notequal", +/* 0x90 */ + "AE", + "Oslash", + "infinity", + "plusminus", + "lessequal", + "greaterequal", + "yen", + "mu", + "partialdiff", + "Sigma", + "Pi", + "pi", + "integral", + "ordfeminine", + "ordmasculine", + "Omega", +/* 0xa0 */ + "ae", + "oslash", + "questiondown", + "exclamdown", + "logicalnot", + "radical", + "florin", + "approxequal", + "Delta", + "guillemotleft", + "guillemotright", + "ellipsis", + "nbspace", + "Agrave", + "Atilde", + "Otilde", +/* 0xb0 */ + "OE", + "oe", + "endash", + "emdash", + "quotedblleft", + "quotedblright", + "quoteleft", + "quoteright", + "divide", + "lozenge", + "ydieresis", + "Ydieresis", + "fraction", + "currency", + "guilsinglleft", + "guilsinglright", +/* 0xc0 */ + "fi", + "fl", + "daggerdbl", + "periodcentered", + "quotesinglbase", + "quotedblbase", + "perthousand", + "Acircumflex", + "Ecircumflex", + "Aacute", + "Edieresis", + "Egrave", + "Iacute", + "Icircumflex", + "Idieresis", + "Igrave", +/* 0xd0 */ + "Oacute", + "Ocircumflex", + "applelogo", + "Ograve", + "Uacute", + "Ucircumflex", + "Ugrave", + "dotlessi", + "circumflex", + "tilde", + "macron", + "breve", + "dotaccent", + "ring", + "cedilla", + "hungarumlaut", +/* 0xe0 */ + "ogonek", + "caron", + "Lslash", + "lslash", + "Scaron", + "scaron", + "Zcaron", + "zcaron", + "brokenbar", + "Eth", + "eth", + "Yacute", + "yacute", + "Thorn", + "thorn", + "minus", +/* 0xf0 */ + "multiply", + "onesuperior", + "twosuperior", + "threesuperior", + "onehalf", + "onequarter", + "threequarters", + "franc", + "Gbreve", + "gbreve", + "Idot", + "Scedilla", + "scedilla", + "Cacute", + "cacute", + "Ccaron", +/* 0x100 */ + "ccaron", + "dmacron" +}; + +const char *ambiguous_names[] = { + "Delta", /* increment */ + "Omega", /* Ohm */ + "Pi", /* product */ + "Sigma", /* summation */ + "dmacron", /* dslash */ + "macron", /* overscore */ + "periodcentered", /* middot */ + NULL +}; + +static const char *newtabnames[] = { + "OS/2", + "PCLT", + "cmap", + "cvt ", + "fpgm", + "glyf", + "head", + "hhea", + "hmtx", + "loca", + "maxp", + "name", + "post", + "prep" +}; + +@ Back to code. Low-level helpers first. + +@c +ttf_cmap_entry *new_ttf_cmap_entry(void) +{ + ttf_cmap_entry *e; + e = xtalloc(1, ttf_cmap_entry); + e->ttf_name = NULL; + e->table = NULL; + return e; +} + +static void destroy_ttf_cmap_entry(void *pa, void *pb) +{ + ttf_cmap_entry *p; + (void) pb; + p = (ttf_cmap_entry *) pa; + xfree(p->ttf_name); + xfree(p->table); + xfree(p); +} + +void ttf_free(void) +{ + if (ttf_cmap_tree != NULL) + avl_destroy(ttf_cmap_tree, destroy_ttf_cmap_entry); +} + +static int comp_ttf_cmap_entry(const void *pa, const void *pb, void *p) +{ + const ttf_cmap_entry *p1 = (const ttf_cmap_entry *) pa, + *p2 = (const ttf_cmap_entry *) pb; + int i; + (void) p; + assert(p1->ttf_name != NULL && p2->ttf_name != NULL); + if ((i = strcmp(p1->ttf_name, p2->ttf_name)) != 0) + return i; + cmp_return(p1->pid, p2->pid); + cmp_return(p1->eid, p2->eid); + return 0; +} + +static unsigned char ttf_addchksm(unsigned char b) +{ + tmp_ulong = (tmp_ulong << 8) + b; + tab_length++; + if (tab_length % 4 == 0) { + checksum += tmp_ulong; + tmp_ulong = 0; + } + return b; +} + +static TTF_ULONG ttf_getchksm(PDF pdf) +{ + while (tab_length % 4 != 0) + ttf_putchar(ttf_addchksm(0)); /* |ttf_addchksm| updates |tab_length| */ + return checksum; +} + +long ttf_putnum(PDF pdf, int s, long n) +{ + long i = n; + char buf[TTF_LONG_SIZE + 1], *p = buf; + while (s-- > 0) { + *p++ = (char) (i & 0xFF); + i >>= 8; + } + p--; + while (p >= buf) + ttf_putchar(ttf_addchksm((unsigned char) (*p--))); + return n; +} + +long ttf_getnum(int s) +{ + long i = 0; + int c; + while (s > 0) { + if (ttf_eof()) + pdftex_fail("unexpected EOF"); + c = ttf_getchar(); + i = (i << 8) + c; + s--; + } + return i; +} + +static long ttf_funit(long n) +{ + if (n < 0) + return -((-n / upem) * 1000 + ((-n % upem) * 1000) / upem); + else + return (n / upem) * 1000 + ((n % upem) * 1000) / upem; +} + +static void ttf_ncopy(PDF pdf, int n) +{ + while (n-- > 0) + copy_byte(); +} + +dirtab_entry *ttf_name_lookup(const char *s, boolean required) +{ + dirtab_entry *tab; + for (tab = dir_tab; tab - dir_tab < ntabs; tab++) + if (strncmp(tab->tag, s, 4) == 0) + break; + if (tab - dir_tab == ntabs) { + if (required) + pdftex_fail("can't find table `%s'", s); + else + tab = NULL; + } + return tab; +} + +dirtab_entry *ttf_seek_tab(const char *name, TTF_LONG offset) +{ + dirtab_entry *tab = ttf_name_lookup(name, true); + ttf_curbyte = (int) (tab->offset + (unsigned long) offset); + return tab; +} + +static void ttf_seek_off(TTF_LONG offset) +{ + ttf_curbyte = (int) offset; +} + +static void ttf_copy_encoding(void) +{ + int i, *q; + void **aa; + char **glyph_names; + long *charcodes; + static char buf[SMALL_BUF_SIZE]; + struct avl_traverser t; + ttfenc_entry *e = ttfenc_tab; + + assert(fd_cur->tx_tree != NULL); /* this must be set in |create_fontdictionary| */ + + if (fd_cur->fe != NULL) { + glyph_names = fd_cur->fe->glyph_names; + assert(glyph_names != NULL); + + for (i = 0; i < 256; i++) + ttfenc_tab[i].name = (char *) notdef; + + /* a workaround for a bug of AcroReader 4.0 */ + if (strcmp(glyph_names[97], "a") == 0) { + q = xtalloc(1, int); + *q = 'a'; + aa = avl_probe(fd_cur->tx_tree, q); + assert(aa != NULL); + } + /* end of workaround */ + + /* take over collected characters from \TeX, reencode them */ + avl_t_init(&t, fd_cur->tx_tree); + for (q = (int *) avl_t_first(&t, fd_cur->tx_tree); q != NULL; + q = (int *) avl_t_next(&t)) { + assert(*q >= 0 && *q < 256); + ttfenc_tab[*q].name = glyph_names[*q]; + } + make_subset_tag(fd_cur); + } else if (is_subfont(fd_cur->fm)) { + charcodes = fd_cur->fm->subfont->charcodes; + assert(charcodes != NULL); + + for (i = 0; i < 256; i++) + ttfenc_tab[i].code = -1; + + /* take over collected characters from \TeX */ + avl_t_init(&t, fd_cur->tx_tree); + for (q = (int *) avl_t_first(&t, fd_cur->tx_tree); q != NULL; + q = (int *) avl_t_next(&t)) { + assert(*q >= 0 && *q < 256); + e = ttfenc_tab + *q; + e->code = charcodes[*q]; + if (e->code == -1) + pdftex_warn + ("character %i in subfont %s is not mapped to any charcode", + *q, fd_cur->fm->tfm_name); + else { + assert(e->code < 0x10000); + sprintf(buf, "/c%4.4X", (int) e->code); + aa = avl_probe(fd_cur->gl_tree, xstrdup(buf)); + assert(aa != NULL); + } + } + make_subset_tag(fd_cur); + } else + assert(0); +} + +@ +@c +#define ttf_append_byte(B)\ +do {\ + if (name_tab[i].platform_id == 3)\ + *q++ = 0;\ + *q++ = B;\ +} while (0) + +static char *strip_spaces_and_delims(char *s, int l) +{ + static char buf[SMALL_BUF_SIZE]; + char *p = buf; + int i; + + assert(l >= 0 && l < (int) sizeof(buf)); + + for (i = 0; i < l; s++, i++) { + if (*s == '(' || *s == ')' || *s == '<' || *s == '>' || + *s == '[' || *s == ']' || *s == '{' || *s == '}' || + *s == '/' || *s == '%' || isspace(*s)) + continue; + *p++ = *s; + } + *p = 0; + return buf; +} + +static void ttf_read_name(void) +{ + int i, j; + dirtab_entry *tab = ttf_seek_tab("name", TTF_USHORT_SIZE); + char *p, buf[SMALL_BUF_SIZE]; + name_record_num = get_ushort(); + name_tab = xtalloc((unsigned) name_record_num, name_record); + name_buf_size = (int) ((unsigned) tab->length - + (3 * TTF_USHORT_SIZE + + (TTF_ULONG) name_record_num * 6 * TTF_USHORT_SIZE)); + name_buf = xtalloc((unsigned) name_buf_size, char); + ttf_skip(TTF_USHORT_SIZE); + for (i = 0; i < name_record_num; i++) { + name_tab[i].platform_id = get_ushort(); + name_tab[i].encoding_id = get_ushort(); + name_tab[i].language_id = get_ushort(); + name_tab[i].name_id = get_ushort(); + name_tab[i].length = get_ushort(); + name_tab[i].offset = get_ushort(); + } + for (p = name_buf; p - name_buf < name_buf_size; p++) + *p = get_char(); + /* look for PS font name */ + for (i = 0; i < name_record_num; i++) { + if (name_tab[i].platform_id == 1 && + name_tab[i].encoding_id == 0 && name_tab[i].name_id == 6) { + xfree(fd_cur->fontname); + fd_cur->fontname = + xstrdup(strip_spaces_and_delims(name_buf + name_tab[i].offset, + name_tab[i].length)); + fd_cur->font_dim[FONTNAME_CODE].set = true; + break; + } + } + if (!fd_cur->font_dim[FONTNAME_CODE].set) { + for (i = 0; i < name_record_num; i++) { + if (name_tab[i].platform_id == 3 && + (name_tab[i].encoding_id == 0 || name_tab[i].encoding_id == 1) + && name_tab[i].name_id == 6) { + xfree(fd_cur->fontname); + assert(name_tab[i].length < sizeof(buf)); + for (j = 0, p = buf; j < name_tab[i].length; j += 2) + *p++ = name_buf[name_tab[i].offset + j + 1]; + *p = 0; + fd_cur->fontname = + xstrdup(strip_spaces_and_delims(buf, (int) strlen(buf))); + fd_cur->font_dim[FONTNAME_CODE].set = true; + break; + } + } + } +} + +static void ttf_read_mapx(void) +{ + glyph_entry *glyph; + ttf_seek_tab("maxp", TTF_FIXED_SIZE); + glyph_tab = + xtalloc((unsigned) (1 + (glyphs_count = get_ushort())), glyph_entry); + for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count; glyph++) { + glyph->newindex = -1; + glyph->newoffset = 0; + glyph->name_index = 0; + glyph->name = (char *) notdef; + } + glyph_index = xtalloc((unsigned) (glyphs_count + 1), long); + glyph_index[0] = 0; /* index of ".notdef" glyph */ + glyph_index[1] = 1; /* index of ".null" glyph */ +} + +void ttf_read_head(void) +{ + ttf_seek_tab("head", + 2 * TTF_FIXED_SIZE + 2 * TTF_ULONG_SIZE + TTF_USHORT_SIZE); + upem = get_ushort(); + ttf_skip(16); + fd_cur->font_dim[FONTBBOX1_CODE].val = (int) ttf_funit(get_fword()); + fd_cur->font_dim[FONTBBOX2_CODE].val = (int) ttf_funit(get_fword()); + fd_cur->font_dim[FONTBBOX3_CODE].val = (int) ttf_funit(get_fword()); + fd_cur->font_dim[FONTBBOX4_CODE].val = (int) ttf_funit(get_fword()); + fd_cur->font_dim[FONTBBOX1_CODE].set = true; + fd_cur->font_dim[FONTBBOX2_CODE].set = true; + fd_cur->font_dim[FONTBBOX3_CODE].set = true; + fd_cur->font_dim[FONTBBOX4_CODE].set = true; + ttf_skip(2 * TTF_USHORT_SIZE + TTF_SHORT_SIZE); + loca_format = get_short(); +} + +void ttf_read_hhea(void) +{ + ttf_seek_tab("hhea", TTF_FIXED_SIZE); + fd_cur->font_dim[ASCENT_CODE].val = (int) ttf_funit(get_fword()); + fd_cur->font_dim[DESCENT_CODE].val = (int) ttf_funit(get_fword()); + fd_cur->font_dim[ASCENT_CODE].set = true; + fd_cur->font_dim[DESCENT_CODE].set = true; + ttf_skip(TTF_FWORD_SIZE + TTF_UFWORD_SIZE + 3 * TTF_FWORD_SIZE + + 8 * TTF_SHORT_SIZE); + nhmtxs = get_ushort(); +} + +void ttf_read_pclt(void) +{ + if (ttf_name_lookup("PCLT", false) == NULL) + return; + ttf_seek_tab("PCLT", TTF_FIXED_SIZE + TTF_ULONG_SIZE + TTF_USHORT_SIZE); + fd_cur->font_dim[XHEIGHT_CODE].val = (int) ttf_funit(get_ushort()); + ttf_skip(2 * TTF_USHORT_SIZE); + fd_cur->font_dim[CAPHEIGHT_CODE].val = (int) ttf_funit(get_ushort()); + fd_cur->font_dim[XHEIGHT_CODE].set = true; + fd_cur->font_dim[CAPHEIGHT_CODE].set = true; +} + +static void ttf_read_hmtx(void) +{ + glyph_entry *glyph; + TTF_UFWORD last_advWidth; + ttf_seek_tab("hmtx", 0); + for (glyph = glyph_tab; glyph - glyph_tab < nhmtxs; glyph++) { + glyph->advWidth = get_ufword(); + glyph->lsb = (TTF_FWORD) get_ufword(); + } + if (nhmtxs < glyphs_count) { + last_advWidth = glyph[-1].advWidth; + for (; glyph - glyph_tab < glyphs_count; glyph++) { + glyph->advWidth = last_advWidth; + glyph->lsb = (TTF_FWORD) get_ufword(); + } + } +} + +void ttf_read_post(void) +{ + int k, nnames; + long length; + long int_part, frac_part; + int sign = 1; + TTF_FIXED italic_angle; + char *p; + glyph_entry *glyph; + const dirtab_entry *tab = ttf_seek_tab("post", 0); + post_format = get_fixed(); + italic_angle = get_fixed(); + int_part = (long) (italic_angle >> 16); + if (int_part > 0x7FFF) { /* a negative number */ + int_part = 0x10000 - int_part; + sign = -1; + } + frac_part = (long) (italic_angle % 0x10000); + fd_cur->font_dim[ITALIC_ANGLE_CODE].val = + (int) (sign * ((double) int_part + (double) frac_part * 1.0 / 0x10000)); + fd_cur->font_dim[ITALIC_ANGLE_CODE].set = true; + if (glyph_tab == NULL) + return; /* being called from writeotf() */ + ttf_skip(2 * TTF_FWORD_SIZE + 5 * TTF_ULONG_SIZE); + switch (post_format) { + case 0x10000: + for (glyph = glyph_tab; glyph - glyph_tab < NMACGLYPHS; glyph++) { + glyph->name = (const char *) mac_glyph_names[glyph - glyph_tab]; + glyph->name_index = (TTF_USHORT) (glyph - glyph_tab); + } + break; + case 0x20000: + nnames = get_ushort(); /* some fonts have this value different from nglyphs */ + for (glyph = glyph_tab; glyph - glyph_tab < nnames; glyph++) + glyph->name_index = get_ushort(); + length = + (long) ((long) tab->length - + (long) ((long) ttf_curbyte - (long) tab->offset)); + glyph_name_buf = xtalloc((unsigned) length, char); + for (p = glyph_name_buf; p - glyph_name_buf < length;) { + for (k = get_byte(); k > 0; k--) + *p++ = get_char(); + *p++ = 0; + } + for (glyph = glyph_tab; glyph - glyph_tab < nnames; glyph++) { + if (glyph->name_index < NMACGLYPHS) + glyph->name = mac_glyph_names[glyph->name_index]; + else { + p = glyph_name_buf; + k = glyph->name_index - NMACGLYPHS; + for (; k > 0; k--) + p = strend(p) + 1; + glyph->name = p; + } + } + break; + case 0x00030000: + for (glyph = glyph_tab; glyph - glyph_tab < NMACGLYPHS; glyph++) { + glyph->name_index = (TTF_USHORT) (glyph - glyph_tab); + } + break; + default: + pdftex_fail("unsupported format (%.8X) of `post' table", + (unsigned int) post_format); + } +} + +static void ttf_read_loca(void) +{ + glyph_entry *glyph; + ttf_seek_tab("loca", 0); + if (loca_format != 0) + for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count + 1; glyph++) + glyph->offset = (TTF_LONG) get_ulong(); + else + for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count + 1; glyph++) + glyph->offset = get_ushort() << 1; +} + +void ttf_read_tabdir(void) +{ + int i; + dirtab_entry *tab; + ttf_skip(TTF_FIXED_SIZE); /* ignore the sfnt number */ + dir_tab = xtalloc(ntabs = get_ushort(), dirtab_entry); + ttf_skip(3 * TTF_USHORT_SIZE); + for (tab = dir_tab; tab - dir_tab < ntabs; tab++) { + for (i = 0; i < 4; i++) + tab->tag[i] = get_char(); + tab->checksum = get_ulong(); + tab->offset = get_ulong(); + tab->length = get_ulong(); + } +} + +static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid, + boolean warn) +{ + seg_entry *seg_tab, *s; + TTF_USHORT *glyphId, format, segCount; + TTF_USHORT ncmapsubtabs, tmp_pid, tmp_eid; + TTF_ULONG cmap_offset, tmp_offset; + long n, i, k, length, index; + ttf_cmap_entry tmp_e, *p; + void **aa; + + /* look up in |ttf_cmap_tree| first, return if found */ + tmp_e.ttf_name = ttf_name; + tmp_e.pid = (TTF_USHORT) pid; + tmp_e.eid = (TTF_USHORT) eid; + if (ttf_cmap_tree == NULL) { + ttf_cmap_tree = avl_create(comp_ttf_cmap_entry, NULL, &avl_xallocator); + assert(ttf_cmap_tree != NULL); + } + p = (ttf_cmap_entry *) avl_find(ttf_cmap_tree, &tmp_e); + if (p != NULL) + return p; + + /* not found, have to read it */ + ttf_seek_tab("cmap", TTF_USHORT_SIZE); /* skip the table version number (=0) */ + ncmapsubtabs = get_ushort(); + cmap_offset = (TTF_ULONG) (ttf_curbyte - 2 * TTF_USHORT_SIZE); + cmap_tab = xtalloc(ncmapsubtabs, cmap_entry); + for (i = 0; i < ncmapsubtabs; ++i) { + tmp_pid = get_ushort(); + tmp_eid = get_ushort(); + tmp_offset = get_ulong(); + if (tmp_pid == pid && tmp_eid == eid) { + ttf_seek_off((TTF_LONG) (cmap_offset + tmp_offset)); + format = get_ushort(); + if (format == 4) + goto read_cmap_format_4; + else { + if (warn) + pdftex_warn("cmap format %i unsupported", format); + return NULL; + } + } + } + if (warn) + pdftex_warn("cannot find cmap subtable for (pid,eid) = (%i, %i)", + pid, eid); + return NULL; + read_cmap_format_4: + /* initialize the new entry */ + p = new_ttf_cmap_entry(); + p->ttf_name = xstrdup(ttf_name); + p->pid = (TTF_USHORT) pid; + p->eid = (TTF_USHORT) eid; + p->table = xtalloc(0x10000, long); + for (i = 0; i < 0x10000; ++i) + p->table[i] = -1; /* unassigned yet */ + + /* read the subtable */ + length = get_ushort(); /* length of subtable */ + (void) get_ushort(); /* skip the version number */ + segCount = get_ushort() / 2; + (void) get_ushort(); /* skip searchRange */ + (void) get_ushort(); /* skip entrySelector */ + (void) get_ushort(); /* skip rangeShift */ + seg_tab = xtalloc(segCount, seg_entry); + for (s = seg_tab; s - seg_tab < segCount; s++) + s->endCode = get_ushort(); + (void) get_ushort(); /* skip reversedPad */ + for (s = seg_tab; s - seg_tab < segCount; s++) + s->startCode = get_ushort(); + for (s = seg_tab; s - seg_tab < segCount; s++) + s->idDelta = get_ushort(); + for (s = seg_tab; s - seg_tab < segCount; s++) + s->idRangeOffset = get_ushort(); + length -= 8 * TTF_USHORT_SIZE + 4 * segCount * TTF_USHORT_SIZE; + n = length / TTF_USHORT_SIZE; /* number of glyphID's */ + glyphId = xtalloc((unsigned) n, TTF_USHORT); + for (i = 0; i < n; i++) + glyphId[i] = get_ushort(); + for (s = seg_tab; s - seg_tab < segCount; s++) { + for (i = s->startCode; i <= s->endCode; i++) { + if (i == 0xFFFF) + break; + if (s->idRangeOffset != 0xFFFF) { + if (s->idRangeOffset == 0) + index = (s->idDelta + i) & 0xFFFF; + else { + k = (i - s->startCode) + s->idRangeOffset / 2 + + (s - seg_tab) - segCount; + assert(k >= 0 && k < n); + index = glyphId[k]; + if (index != 0) + index = (index + s->idDelta) & 0xFFFF; + } + if (index >= glyphs_count) + pdftex_fail("cmap: glyph index %li out of range [0..%i)", + index, glyphs_count); + if (p->table[i] != -1) + pdftex_warn + ("cmap: multiple glyphs are mapped to unicode %.4lX, " + "only %li will be used (glyph %li being ignored)", i, + p->table[i], index); + else + p->table[i] = index; + } + } + } + xfree(seg_tab); + xfree(glyphId); + aa = avl_probe(ttf_cmap_tree, p); + assert(aa != NULL); + return p; +} + +@ +@c +static void ttf_read_font(void) +{ + ttf_read_tabdir(); + if (ttf_name_lookup("PCLT", false) == NULL) + new_ntabs--; + if (ttf_name_lookup("fpgm", false) == NULL) + new_ntabs--; + if (ttf_name_lookup("cvt ", false) == NULL) + new_ntabs--; + if (ttf_name_lookup("prep", false) == NULL) + new_ntabs--; + ttf_read_mapx(); + ttf_read_head(); + ttf_read_hhea(); + ttf_read_pclt(); + ttf_read_hmtx(); + ttf_read_post(); + ttf_read_loca(); + ttf_read_name(); +} + +static void ttf_reset_chksm(PDF pdf, dirtab_entry * tab) +{ + checksum = 0; + tab_length = 0; + tmp_ulong = 0; + tab->offset = (TTF_ULONG) ttf_offset(); + if (tab->offset % 4 != 0) + pdftex_warn("offset of `%4.4s' is not a multiple of 4", tab->tag); +} + + +static void ttf_set_chksm(PDF pdf, dirtab_entry * tab) +{ + tab->length = (TTF_ULONG) ttf_offset() - tab->offset; + tab->checksum = ttf_getchksm(pdf); +} + +static void ttf_copytab(PDF pdf, const char *name) +{ + long i; + dirtab_entry *tab = ttf_seek_tab(name, 0); + ttf_reset_chksm(pdf, tab); + for (i = (long) tab->length; i > 0; i--) + copy_char(); + ttf_set_chksm(pdf, tab); +} + +@ +@c +#define BYTE_ENCODING_LENGTH \ + ((256)*TTF_BYTE_SIZE + 3*TTF_USHORT_SIZE) + +static void ttf_byte_encoding(PDF pdf) +{ + ttfenc_entry *e; + (void) put_ushort(0); /* format number (0: byte encoding table) */ + (void) put_ushort(BYTE_ENCODING_LENGTH); /* length of table */ + (void) put_ushort(0); /* version number */ + for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) + if (e->newindex < 256) { + put_byte(e->newindex); + } else { + if (e->name != notdef) + pdftex_warn + ("glyph `%s' has been mapped to `%s' in `ttf_byte_encoding' cmap table", + e->name, notdef); + put_byte(0); /* notdef */ + } +} + +@ +@c +#define TRIMMED_TABLE_MAP_LENGTH (TTF_USHORT_SIZE*(5 + (256))) + +static void ttf_trimmed_table_map(PDF pdf) +{ + ttfenc_entry *e; + (void) put_ushort(6); /* format number (6): trimmed table mapping */ + (void) put_ushort(TRIMMED_TABLE_MAP_LENGTH); + (void) put_ushort(0); /* version number (0) */ + (void) put_ushort(0); /* first character code */ + (void) put_ushort(256); /* number of character code in table */ + for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) + (void) put_ushort(e->newindex); +} + +@ +@c +#define SEG_MAP_DELTA_LENGTH ((16 + (256))*TTF_USHORT_SIZE) + +static void ttf_seg_map_delta(PDF pdf) +{ + ttfenc_entry *e; + (void) put_ushort(4); /* format number (4: segment mapping to delta values) */ + (void) put_ushort(SEG_MAP_DELTA_LENGTH); + (void) put_ushort(0); /* version number */ + (void) put_ushort(4); /* 2*segCount */ + (void) put_ushort(4); /* searchRange */ + (void) put_ushort(1); /* entrySelector */ + (void) put_ushort(0); /* rangeShift */ + (void) put_ushort(0xF0FF); /* endCount[0] */ + (void) put_ushort(0xFFFF); /* endCount[1] */ + (void) put_ushort(0); /* reversedPad */ + (void) put_ushort(0xF000); /* startCount[0] */ + (void) put_ushort(0xFFFF); /* startCount[1] */ + (void) put_ushort(0); /* idDelta[0] */ + (void) put_ushort(1); /* idDelta[1] */ + (void) put_ushort(2 * TTF_USHORT_SIZE); /* idRangeOffset[0] */ + (void) put_ushort(0); /* idRangeOffset[1] */ + for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) + (void) put_ushort(e->newindex); +} + +@ +@c +#define CMAP_ENTRY_LENGTH (2*TTF_USHORT_SIZE + TTF_ULONG_SIZE) + +static void ttf_select_cmap(void) +{ + assert(sizeof(new_cmap_tab) <= NEW_CMAP_SIZE * sizeof(cmap_entry)); + new_cmap_tab[0].platform_id = 1; /* Macintosh */ + new_cmap_tab[0].encoding_id = 0; /* Symbol; ignore code page */ + new_cmap_tab[0].format = (TTF_USHORT) (new_glyphs_count < 256 ? 0 /* byte encoding */ + : 6); /* trimmed table mapping */ + new_cmap_tab[1].platform_id = 3; /* Microsoft */ + new_cmap_tab[1].encoding_id = 0; /* Symbol; ignore code page */ + new_cmap_tab[1].format = 4; /* segment mapping to delta */ +} + +static void ttf_write_cmap(PDF pdf) +{ + cmap_entry *ce; + long offset; + dirtab_entry *tab = ttf_name_lookup("cmap", true); + ttf_select_cmap(); + ttf_reset_chksm(pdf, tab); + (void) put_ushort(0); /* table version number (0) */ + (void) put_ushort(NEW_CMAP_SIZE); /* number of encoding tables */ + offset = 2 * TTF_USHORT_SIZE + NEW_CMAP_SIZE * CMAP_ENTRY_LENGTH; + for (ce = new_cmap_tab; ce - new_cmap_tab < NEW_CMAP_SIZE; ce++) { + ce->offset = (TTF_ULONG) offset; + switch (ce->format) { + case 0: + offset += BYTE_ENCODING_LENGTH; + break; + case 4: + offset += SEG_MAP_DELTA_LENGTH; + break; + case 6: + offset += TRIMMED_TABLE_MAP_LENGTH; + break; + default: + pdftex_fail("invalid format (it should not have happened)"); + } + (void) put_ushort(ce->platform_id); + (void) put_ushort(ce->encoding_id); + put_ulong((long) ce->offset); + } + for (ce = new_cmap_tab; ce - new_cmap_tab < NEW_CMAP_SIZE; ce++) { + switch (ce->format) { + case 0: + ttf_byte_encoding(pdf); + break; + case 4: + ttf_seg_map_delta(pdf); + break; + case 6: + ttf_trimmed_table_map(pdf); + break; + } + } + ttf_set_chksm(pdf, tab); +} + +@ +@c +static int prepend_subset_tags(int index, char *p) +{ + boolean is_unicode; + int i; + assert(index >= 0 && index < name_record_num && fd_cur->subset_tag != NULL); + is_unicode = (name_tab[index].platform_id == 3); + if (is_unicode) { + for (i = 0; i < 6; ++i) { + *p++ = 0; + *p++ = fd_cur->subset_tag[i]; + } + *p++ = 0; + *p++ = '+'; + return 14; + } else { + strncpy(p, fd_cur->subset_tag, 6); + p += 6; + *p++ = '+'; + return 7; + } +} + + +static void ttf_write_name(PDF pdf) +{ + int i, l; + char *p; + int new_name_buf_size; + char *new_name_buf; + name_record *n; + dirtab_entry *tab = ttf_name_lookup("name", true); + if (is_subsetted(fd_cur->fm)) { + l = 0; + for (i = 0; i < name_record_num; i++) + l += name_tab[i].length + 14; /* maximum lengh of new stogare area */ + new_name_buf = xtalloc((unsigned) l, char); + /* additional space for subset tags */ + p = new_name_buf; + for (i = 0; i < name_record_num; i++) { + n = name_tab + i; + n->new_offset = (TTF_USHORT) (p - new_name_buf); + if ((n->name_id == 1 || n->name_id == 3 || + n->name_id == 4 || n->name_id == 6) && + ((n->platform_id == 1 && n->encoding_id == 0) || + (n->platform_id == 3 && n->encoding_id == 0) || + (n->platform_id == 3 && n->encoding_id == 1))) { + l = prepend_subset_tags(i, p); + p += l; + } else + l = 0; + memcpy(p, name_buf + n->offset, n->length); + p += n->length; + n->new_length = (TTF_USHORT) (n->length + l); + } + new_name_buf_size = (int) (p - new_name_buf); + } else { + new_name_buf = name_buf; + new_name_buf_size = name_buf_size; + } + ttf_reset_chksm(pdf, tab); + (void) put_ushort(0); /* Format selector */ + (void) put_ushort(name_record_num); + (void) put_ushort(3 * TTF_USHORT_SIZE + + name_record_num * 6 * TTF_USHORT_SIZE); + for (i = 0; i < name_record_num; i++) { + (void) put_ushort(name_tab[i].platform_id); + (void) put_ushort(name_tab[i].encoding_id); + (void) put_ushort(name_tab[i].language_id); + (void) put_ushort(name_tab[i].name_id); + (void) put_ushort(name_tab[i].new_length); + (void) put_ushort(name_tab[i].new_offset); + } + for (p = new_name_buf; p - new_name_buf < new_name_buf_size; p++) + put_char(*p); + ttf_set_chksm(pdf, tab); + if (new_name_buf != name_buf) + xfree(new_name_buf); +} + +@ +@c +static void ttf_write_dirtab(PDF pdf) +{ + dirtab_entry *tab; + TTF_ULONG i, k; + char *p; + const int save_offset = ttf_offset(); + ttf_seek_outbuf(TABDIR_OFF); + if (is_subsetted(fd_cur->fm)) { + for (i = 0; i < DEFAULT_NTABS; i++) { + tab = ttf_name_lookup(newtabnames[i], false); + if (tab == NULL) + continue; + for (k = 0; k < 4; k++) + put_char(tab->tag[k]); + put_ulong((long) tab->checksum); + put_ulong((long) tab->offset); + put_ulong((long) tab->length); + } + } else { + for (tab = dir_tab; tab - dir_tab < ntabs; tab++) { + for (k = 0; k < 4; k++) + put_char(tab->tag[k]); + put_ulong((long) tab->checksum); + put_ulong((long) tab->offset); + put_ulong((long) tab->length); + } + } + /* adjust checkSumAdjustment */ + tmp_ulong = 0; + checksum = 0; + for (p = pdf->fb_array, i = 0; i < (unsigned) save_offset;) { + tmp_ulong = (tmp_ulong << 8) + (TTF_ULONG) * p++; + i++; + if (i % 4 == 0) { + checksum += tmp_ulong; + tmp_ulong = 0; + } + } + if (i % 4 != 0) { + pdftex_warn("font length is not a multiple of 4 (%li)", i); + checksum <<= 8 * (4 - i % 4); + } + k = 0xB1B0AFBA - checksum; + ttf_seek_outbuf((int) checkSumAdjustment_offset); + put_ulong((long) k); + ttf_seek_outbuf(save_offset); +} + +@ +@c +static void ttf_write_glyf(PDF pdf) +{ + long *id, k; + TTF_USHORT idx; + TTF_USHORT flags; + dirtab_entry *tab = ttf_name_lookup("glyf", true); + const long glyf_offset = (long) tab->offset; + const long new_glyf_offset = ttf_offset(); + ttf_reset_chksm(pdf, tab); + for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { + glyph_tab[*id].newoffset = ttf_offset() - new_glyf_offset; + if (glyph_tab[*id].offset != glyph_tab[*id + 1].offset) { + ttf_seek_off(glyf_offset + glyph_tab[*id].offset); + k = copy_short(); + ttf_ncopy(pdf, 4 * TTF_FWORD_SIZE); + if (k < 0) { + do { + flags = copy_ushort(); + idx = get_ushort(); + if (glyph_tab[idx].newindex < 0) { + glyph_tab[idx].newindex = (TTF_SHORT) new_glyphs_count; + glyph_index[new_glyphs_count++] = idx; + /* + N.B.: Here we change |new_glyphs_count|, + which appears in the condition of the |for| loop + */ + } + (void) put_ushort(glyph_tab[idx].newindex); + if (flags & ARG_1_AND_2_ARE_WORDS) + ttf_ncopy(pdf, 2 * TTF_SHORT_SIZE); + else + ttf_ncopy(pdf, TTF_USHORT_SIZE); + if (flags & WE_HAVE_A_SCALE) + ttf_ncopy(pdf, TTF_F2DOT14_SIZE); + else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) + ttf_ncopy(pdf, 2 * TTF_F2DOT14_SIZE); + else if (flags & WE_HAVE_A_TWO_BY_TWO) + ttf_ncopy(pdf, 4 * TTF_F2DOT14_SIZE); + } while (flags & MORE_COMPONENTS); + if (flags & WE_HAVE_INSTRUCTIONS) + ttf_ncopy(pdf, copy_ushort()); + } else + ttf_ncopy(pdf, (int) + (glyph_tab[*id + 1].offset - glyph_tab[*id].offset - + TTF_USHORT_SIZE - 4 * TTF_FWORD_SIZE)); + } + } + last_glyf_offset = (TTF_ULONG) ttf_offset() - (TTF_ULONG) new_glyf_offset; + ttf_set_chksm(pdf, tab); +} + +@ Reindexing glyphs: we append index of used glyphs to |glyph_index| + while going through |ttfenc_tab|. After appending a new entry to + |glyph_index| we set field |newindex| of corresponding entries in both + |glyph_tab| and |ttfenc_tab| to the newly created index. + +@c +static void ttf_reindex_glyphs(void) +{ + ttfenc_entry *e; + glyph_entry *glyph; + int index; + long *t; + ttf_cmap_entry *cmap = NULL; + boolean cmap_not_found = false; + + for (e = ttfenc_tab; e - ttfenc_tab < 256; e++) { + e->newindex = 0; /* index of ".notdef" glyph */ + + /* handle case of subfonts first */ + if (is_subfont(fd_cur->fm)) { + if (e->code == -1) + continue; + assert(fd_cur->fm->pid != -1 && fd_cur->fm->eid != -1); + if (cmap == NULL && !cmap_not_found) { + cmap = + ttf_read_cmap(fd_cur->fm->ff_name, fd_cur->fm->pid, + fd_cur->fm->eid, true); + if (cmap == NULL) + cmap_not_found = true; + } + if (cmap == NULL) + continue; + t = cmap->table; + assert(t != NULL && e->code < 0x10000); + if (t[e->code] < 0) { + pdftex_warn + ("subfont %s: wrong mapping: character %li --> 0x%4.4lX --> .notdef", + fd_cur->fm->tfm_name, (long) (e - ttfenc_tab), e->code); + continue; + } + assert(t[e->code] >= 0 && t[e->code] < glyphs_count); /* t has been read from ttf */ + glyph = glyph_tab + t[e->code]; + goto append_new_glyph; + } + + /* handle case of reencoded fonts */ + if (e->name == notdef) + continue; + /* scan form `index123' */ + if (sscanf(e->name, GLYPH_PREFIX_INDEX "%i", &index) == 1) { + if (index >= glyphs_count) { + pdftex_warn("`%s' out of valid range [0..%i)", + e->name, glyphs_count); + continue; + } + glyph = glyph_tab + index; + goto append_new_glyph; + } + /* scan form `uniABCD' */ + if (sscanf(e->name, GLYPH_PREFIX_UNICODE "%X", &index) == 1) { + if (cmap == NULL && !cmap_not_found) { + /* need to read the unicode mapping, ie (pid,eid) = (3,1) or (0,3) */ + cmap = ttf_read_cmap(fd_cur->fm->ff_name, 3, 1, false); + if (cmap == NULL) + cmap = ttf_read_cmap(fd_cur->fm->ff_name, 0, 3, false); + if (cmap == NULL) { + pdftex_warn + ("no unicode mapping found, all `uniXXXX' names will be ignored"); + cmap_not_found = true; /* once only */ + } + } + if (cmap == NULL) + continue; + t = cmap->table; + assert(t != NULL); + if (t[index] != -1) { + if (t[index] >= glyphs_count) { + pdftex_warn + ("`%s' is mapped to index %li which is out of valid range [0..%i)", + e->name, t[index], glyphs_count); + continue; + } + glyph = glyph_tab + t[index]; + goto append_new_glyph; + } else { + pdftex_warn("`unicode %s%.4X' is not mapped to any glyph", + GLYPH_PREFIX_UNICODE, index); + continue; + } + } + /* look up by name */ + for (glyph = glyph_tab; glyph - glyph_tab < glyphs_count; glyph++) + if (glyph->name != notdef && strcmp(glyph->name, e->name) == 0) + break; + if (!(glyph - glyph_tab < glyphs_count)) { + pdftex_warn("glyph `%s' not found", e->name); + continue; + } + append_new_glyph: + assert(glyph > glyph_tab && glyph - glyph_tab < glyphs_count); + if (glyph->newindex < 0) { + glyph_index[new_glyphs_count] = (short) (glyph - glyph_tab); + glyph->newindex = (TTF_SHORT) new_glyphs_count; + new_glyphs_count++; + } + e->newindex = glyph->newindex; + } +} + +@ To calculate the checkSum for the 'head' table which itself includes the + checkSumAdjustment entry for the entire font, do the following: + + \item Set the checkSumAdjustment to 0. + \item Calculate the checksum for all the tables including the 'head' table + and enter that value into the table directory. + \item Calculate the checksum for the entire font. + \item Subtract that value from the hex value B1B0AFBA. + \item Store the result in checkSumAdjustment. + + The checkSum for the 'head table which includes the checkSumAdjustment + entry for the entire font is now incorrect. That is not a problem. Do not + change it. An application attempting to verify that the 'head' table has + not changed should calculate the checkSum for that table by not including + the checkSumAdjustment value, and compare the result with the entry in the + table directory. + + The table directory also includes the offset of the associated tagged + table from the beginning of the font file and the length of that table. + + +@c +static void ttf_write_head(PDF pdf) +{ + dirtab_entry *tab; + tab = ttf_seek_tab("head", 0); + ttf_reset_chksm(pdf, tab); + ttf_ncopy(pdf, 2 * TTF_FIXED_SIZE); + checkSumAdjustment_offset = (TTF_ULONG) ttf_offset(); + put_ulong(0); + ttf_skip(TTF_ULONG_SIZE); /* skip checkSumAdjustment */ + ttf_ncopy(pdf, TTF_ULONG_SIZE + 2 * TTF_USHORT_SIZE + 16 + + 4 * TTF_FWORD_SIZE + 2 * TTF_USHORT_SIZE + TTF_SHORT_SIZE); + if (is_subsetted(fd_cur->fm)) { + (void) put_short(loca_format); + (void) put_short(0); + } else + ttf_ncopy(pdf, 2 * TTF_SHORT_SIZE); + ttf_set_chksm(pdf, tab); +} + +@ +@c +static void ttf_write_hhea(PDF pdf) +{ + dirtab_entry *tab; + tab = ttf_seek_tab("hhea", 0); + ttf_reset_chksm(pdf, tab); + ttf_ncopy(pdf, TTF_FIXED_SIZE + 3 * TTF_FWORD_SIZE + TTF_UFWORD_SIZE + + 3 * TTF_FWORD_SIZE + 8 * TTF_SHORT_SIZE); + (void) put_ushort(new_glyphs_count); + ttf_set_chksm(pdf, tab); +} + +@ +@c +static void ttf_write_htmx(PDF pdf) +{ + long *id; + dirtab_entry *tab = ttf_seek_tab("hmtx", 0); + ttf_reset_chksm(pdf, tab); + for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { + put_ufword(glyph_tab[*id].advWidth); + put_ufword(glyph_tab[*id].lsb); + } + ttf_set_chksm(pdf, tab); +} + +@ +@c +static void ttf_write_loca(PDF pdf) +{ + long *id; + dirtab_entry *tab = ttf_seek_tab("loca", 0); + ttf_reset_chksm(pdf, tab); + loca_format = 0; + if (last_glyf_offset >= 0x00020000 || (last_glyf_offset & 1)) + loca_format = 1; + else + for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) + if (glyph_tab[*id].newoffset & 1) { + loca_format = 1; + break; + } + if (loca_format != 0) { + for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) + put_ulong(glyph_tab[*id].newoffset); + put_ulong((long) last_glyf_offset); + } else { + for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) + (void) put_ushort(glyph_tab[*id].newoffset / 2); + (void) put_ushort((long) (last_glyf_offset / 2)); + } + ttf_set_chksm(pdf, tab); +} + +@ +@c +static void ttf_write_mapx(PDF pdf) +{ + dirtab_entry *tab = ttf_seek_tab("maxp", TTF_FIXED_SIZE + TTF_USHORT_SIZE); + ttf_reset_chksm(pdf, tab); + put_fixed(0x00010000); + (void) put_ushort(new_glyphs_count); + ttf_ncopy(pdf, 13 * TTF_USHORT_SIZE); + ttf_set_chksm(pdf, tab); +} + +@ +@c +static void ttf_write_OS2(PDF pdf) +{ + dirtab_entry *tab = ttf_seek_tab("OS/2", 0); + TTF_USHORT version; + ttf_reset_chksm(pdf, tab); + version = get_ushort(); + if (version > 3) + pdftex_fail("unknown version of OS/2 table (%.4X)", version); + (void) put_ushort(0x0001); /* fix version to 1 */ + ttf_ncopy(pdf, + 2 * TTF_USHORT_SIZE + 13 * TTF_SHORT_SIZE + 10 * TTF_BYTE_SIZE); + ttf_skip(4 * TTF_ULONG_SIZE); /* ulUnicodeRange 1--4 */ + put_ulong(0x00000003); /* Basic Latin + Latin-1 Supplement (0x0000--0x00FF) */ + put_ulong(0x10000000); /* Private Use (0xE000--0xF8FF) */ + put_ulong(0x00000000); + put_ulong(0x00000000); + ttf_ncopy(pdf, 4 * TTF_CHAR_SIZE + TTF_USHORT_SIZE); /* achVendID + fsSelection */ + ttf_skip(2 * TTF_USHORT_SIZE); + (void) put_ushort(0x0000); /* usFirstCharIndex */ + (void) put_ushort(0xF0FF); /* usLastCharIndex */ + ttf_ncopy(pdf, 5 * TTF_USHORT_SIZE); + /* for version 0 the OS/2 table ends here, the rest is for version 1 */ + put_ulong(0x80000000); /* Symbol Character Set---don't use any code page */ + put_ulong(0x00000000); + ttf_set_chksm(pdf, tab); +} + +@ +@c +static boolean unsafe_name(const char *s) +{ + const char **p; + for (p = ambiguous_names; *p != NULL; p++) + if (strcmp(s, *p) == 0) + return true; + return false; +} + +static void ttf_write_post(PDF pdf) +{ + dirtab_entry *tab = ttf_seek_tab("post", TTF_FIXED_SIZE); + glyph_entry *glyph; + const char *s; + long *id; + int k, l; + ttf_reset_chksm(pdf, tab); + if (!fd_cur->write_ttf_glyph_names || post_format == 0x00030000) { + put_fixed(0x00030000); + ttf_ncopy(pdf, + TTF_FIXED_SIZE + 2 * TTF_FWORD_SIZE + 5 * TTF_ULONG_SIZE); + } else { + put_fixed(0x00020000); + ttf_ncopy(pdf, + TTF_FIXED_SIZE + 2 * TTF_FWORD_SIZE + 5 * TTF_ULONG_SIZE); + (void) put_ushort(new_glyphs_count); + k = 0; + for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { + glyph = glyph_tab + *id; + if (glyph->name_index >= NMACGLYPHS || unsafe_name(glyph->name)) + glyph->name_index = (TTF_USHORT) (NMACGLYPHS + k++); + (void) put_ushort(glyph->name_index); + } + for (id = glyph_index; id - glyph_index < new_glyphs_count; id++) { + glyph = glyph_tab + *id; + if (glyph->name_index >= NMACGLYPHS) { + s = glyph->name; + l = (int) strlen(s); + put_byte(l); + while (l-- > 0) + put_char(*s++); + } + } + } + ttf_set_chksm(pdf, tab); +} + +@ +@c +static void ttf_init_font(PDF pdf, int n) +{ + int i, k; + for (i = 1, k = 0; i <= n; i <<= 1, k++); + put_fixed(0x00010000); /* font version */ + (void) put_ushort(n); /* number of tables */ + (void) put_ushort(i << 3); /* search range */ + (void) put_ushort(k - 1); /* entry selector */ + (void) put_ushort((n << 4) - (i << 3)); /* range shift */ + ttf_seek_outbuf(TABDIR_OFF + n * 4 * TTF_ULONG_SIZE); +} + +@ +@c +static void ttf_subset_font(PDF pdf) +{ + ttf_init_font(pdf, new_ntabs); + if (ttf_name_lookup("PCLT", false) != NULL) + ttf_copytab(pdf, "PCLT"); + if (ttf_name_lookup("fpgm", false) != NULL) + ttf_copytab(pdf, "fpgm"); + if (ttf_name_lookup("cvt ", false) != NULL) + ttf_copytab(pdf, "cvt "); + if (ttf_name_lookup("prep", false) != NULL) + ttf_copytab(pdf, "prep"); + ttf_reindex_glyphs(); + ttf_write_glyf(pdf); + ttf_write_loca(pdf); + ttf_write_OS2(pdf); + ttf_write_head(pdf); + ttf_write_hhea(pdf); + ttf_write_htmx(pdf); + ttf_write_mapx(pdf); + ttf_write_name(pdf); + ttf_write_post(pdf); + ttf_write_cmap(pdf); + ttf_write_dirtab(pdf); +} + +@ +@c +static void ttf_copy_font(PDF pdf) +{ + dirtab_entry *tab; + ttf_init_font(pdf, ntabs); + for (tab = dir_tab; tab - dir_tab < ntabs; tab++) { + if (strncmp(tab->tag, "head", 4) == 0) + ttf_write_head(pdf); + else + ttf_copytab(pdf, tab->tag); + } + ttf_write_dirtab(pdf); +} + +@ +@c +void writettf(PDF pdf, fd_entry * fd) +{ + int callback_id; + int file_opened = 0; + fd_cur = fd; /* |fd_cur| is global inside \.{writettf.w} */ + assert(fd_cur->fm != NULL); + assert(is_truetype(fd_cur->fm)); + assert(is_included(fd_cur->fm)); + + if (is_subsetted(fd_cur->fm) && (fd_cur->fe == NULL) + && !is_subfont(fd_cur->fm)) { + pdftex_fail("Subset TrueType must be a reencoded or a subfont"); + } + ttf_curbyte = 0; + ttf_size = 0; + + cur_file_name = + luatex_find_file(fd_cur->fm->ff_name, find_truetype_file_callback); + if (cur_file_name == NULL) { + pdftex_fail("cannot find TrueType font file for reading"); + } + callback_id = callback_defined(read_truetype_file_callback); + if (callback_id > 0) { + if (run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &ttf_buffer, &ttf_size) && + file_opened && ttf_size > 0) { + } else { + pdftex_fail("cannot open TrueType font file for reading"); + } + } else { + if (!ttf_open(cur_file_name)) { + pdftex_fail("cannot open TrueType font file for reading"); + } + ttf_read_file(); + ttf_close(); + } + if (tracefilenames) { + if (is_subsetted(fd_cur->fm)) + tex_printf("<%s", cur_file_name); + else + tex_printf("<<%s", cur_file_name); + } + fd_cur->ff_found = true; + new_glyphs_count = 2; + new_ntabs = DEFAULT_NTABS; + dir_tab = NULL; + glyph_tab = NULL; + glyph_index = NULL; + glyph_name_buf = NULL; + name_tab = NULL; + name_buf = NULL; + ttf_read_font(); + + pdf_save_offset(pdf); + pdf_flush(pdf); + + if (is_subsetted(fd_cur->fm)) { + ttf_copy_encoding(); + ttf_subset_font(pdf); + } else + ttf_copy_font(pdf); + ttf_length = ttf_offset(); + + xfree(dir_tab); + xfree(glyph_tab); + xfree(glyph_index); + xfree(glyph_name_buf); + xfree(name_tab); + xfree(name_buf); + if (tracefilenames) { + if (is_subsetted(fd_cur->fm)) + tex_printf(">"); + else + tex_printf(">>"); + } + xfree(ttf_buffer); + cur_file_name = NULL; +} + +void do_writeotf(PDF pdf, fd_entry * fd) +{ + long i; + dirtab_entry *tab; + (void) fd; + dir_tab = NULL; + glyph_tab = NULL; + if (tracefilenames) + tex_printf("<<%s", cur_file_name); + ttf_read_tabdir(); + /* read font parameters */ + if (ttf_name_lookup("head", false) != NULL) + ttf_read_head(); + if (ttf_name_lookup("hhea", false) != NULL) + ttf_read_hhea(); + if (ttf_name_lookup("PCLT", false) != NULL) + ttf_read_pclt(); + if (ttf_name_lookup("post", false) != NULL) + ttf_read_post(); + /* copy font file */ + tab = ttf_seek_tab("CFF ", 0); + for (i = (long) tab->length; i > 0; i--) + copy_char(); + xfree(dir_tab); + if (tracefilenames) + tex_printf(">>"); +} + +@ +@c +void writeotf(PDF pdf, fd_entry * fd) +{ + int callback_id; + int file_opened = 0; + + fd_cur = fd; + assert(fd_cur->fm != NULL); + assert(is_opentype(fd_cur->fm)); + assert(is_included(fd_cur->fm)); + + ttf_curbyte = 0; + ttf_size = 0; + cur_file_name = + luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback); + if (cur_file_name == NULL) { + pdftex_fail("cannot find OpenType font file for reading"); + } + callback_id = callback_defined(read_opentype_file_callback); + if (callback_id > 0) { + if (run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &ttf_buffer, &ttf_size) && + file_opened && ttf_size > 0) { + } else { + pdftex_fail("cannot open OpenType font file for reading"); + } + } else { + if (!otf_open(cur_file_name)) { + pdftex_fail("cannot open OpenType font file for reading"); + } + ttf_read_file(); + ttf_close(); + } + + fd_cur->ff_found = true; + do_writeotf(pdf, fd); + xfree(ttf_buffer); + cur_file_name = NULL; +} + diff --git a/Build/source/texk/web2c/luatexdir/font/writetype0.c b/Build/source/texk/web2c/luatexdir/font/writetype0.c deleted file mode 100644 index 796c6e5aa37..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writetype0.c +++ /dev/null @@ -1,125 +0,0 @@ -/* writetype0.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "writettf.h" -#include "writecff.h" - -static const char _svn_version[] = - "$Id: writetype0.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writetype0.c $"; - -void writetype0(fd_entry * fd) -{ - int callback_id; - int file_opened = 0; - char *ftemp = NULL; - long i; - dirtab_entry *tab; - cff_font *cff; - - dir_tab = NULL; - glyph_tab = NULL; - - fd_cur = fd; /* fd_cur is global inside writettf.c */ - assert(fd_cur->fm != NULL); - assert(is_opentype(fd_cur->fm)); - assert(is_included(fd_cur->fm)); - - set_cur_file_name(fd_cur->fm->ff_name); - ttf_curbyte = 0; - ttf_size = 0; - callback_id = callback_defined(find_opentype_file_callback); - if (callback_id > 0) { - if (run_callback - (callback_id, "S->S", (char *) (nameoffile + 1), &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } - } - } - callback_id = callback_defined(read_opentype_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", (char *) (nameoffile + 1), - &file_opened, &ttf_buffer, &ttf_size) && - file_opened && ttf_size > 0) { - } else { - pdftex_fail("cannot open OpenType font file for reading"); - } - } else { - if (!otf_open()) { - pdftex_fail("cannot open OpenType font file for reading"); - } - ttf_read_file(); - ttf_close(); - } - - cur_file_name = (char *) nameoffile + 1; - fd_cur->ff_found = true; - - if (tracefilenames) { - if (is_subsetted(fd_cur->fm)) - tex_printf("<%s", cur_file_name); - else - tex_printf("<<%s", cur_file_name); - } - ttf_read_tabdir(); - /* read font parameters */ - if (ttf_name_lookup("head", false) != NULL) - ttf_read_head(); - if (ttf_name_lookup("hhea", false) != NULL) - ttf_read_hhea(); - if (ttf_name_lookup("PCLT", false) != NULL) - ttf_read_pclt(); - if (ttf_name_lookup("post", false) != NULL) - ttf_read_post(); - - /* copy font file */ - tab = ttf_seek_tab("CFF ", 0); - - /* TODO the next 0 is a subfont index */ - cff = read_cff(ttf_buffer + ttf_curbyte, tab->length, 0); - if (cff != NULL) { - if (cff_is_cidfont(cff)) { - write_cid_cff(cff, fd_cur); - /* - for (i = tab->length; i > 0; i--) - fb_putchar (ttf_getnum(1)); - */ - } else { - write_cff(cff, fd_cur); - } - } else { - /* not understood, just do a copy */ - for (i = tab->length; i > 0; i--) - fb_putchar(ttf_getnum(1)); - } - xfree(dir_tab); - xfree(ttf_buffer); - if (tracefilenames) { - if (is_subsetted(fd_cur->fm)) - tex_printf(">"); - else - tex_printf(">>"); - } - cur_file_name = NULL; -} diff --git a/Build/source/texk/web2c/luatexdir/font/writetype0.w b/Build/source/texk/web2c/luatexdir/font/writetype0.w new file mode 100644 index 00000000000..f902ad89a2a --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writetype0.w @@ -0,0 +1,123 @@ +% writetype0.w +% +% Copyright 2006-2008 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" +#include "font/writettf.h" +#include "font/writecff.h" + +static const char _svn_version[] = + "$Id: writetype0.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writetype0.w $"; + +@ @c +void writetype0(PDF pdf, fd_entry * fd) +{ + int callback_id; + int file_opened = 0; + long i; + dirtab_entry *tab; + cff_font *cff; + + dir_tab = NULL; + glyph_tab = NULL; + + fd_cur = fd; /* |fd_cur| is global inside \.{writettf.w} */ + assert(fd_cur->fm != NULL); + assert(is_opentype(fd_cur->fm)); + assert(is_included(fd_cur->fm)); + + ttf_curbyte = 0; + ttf_size = 0; + cur_file_name = + luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback); + if (cur_file_name == NULL) { + pdftex_fail("cannot find OpenType font file for reading"); + } + callback_id = callback_defined(read_opentype_file_callback); + if (callback_id > 0) { + if (run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &ttf_buffer, &ttf_size) && + file_opened && ttf_size > 0) { + } else { + pdftex_fail("cannot open OpenType font file for reading"); + } + } else { + if (!otf_open(cur_file_name)) { + pdftex_fail("cannot open OpenType font file for reading"); + } + ttf_read_file(); + ttf_close(); + } + + fd_cur->ff_found = true; + + if (tracefilenames) { + if (is_subsetted(fd_cur->fm)) + tex_printf("<%s", cur_file_name); + else + tex_printf("<<%s", cur_file_name); + } + ttf_read_tabdir(); + /* read font parameters */ + if (ttf_name_lookup("head", false) != NULL) + ttf_read_head(); + if (ttf_name_lookup("hhea", false) != NULL) + ttf_read_hhea(); + if (ttf_name_lookup("PCLT", false) != NULL) + ttf_read_pclt(); + if (ttf_name_lookup("post", false) != NULL) + ttf_read_post(); + + /* copy font file */ + tab = ttf_seek_tab("CFF ", 0); + + /* TODO the next 0 is a subfont index */ + cff = read_cff(ttf_buffer + ttf_curbyte, (long) tab->length, 0); + if (!is_subsetted(fd_cur->fm)) { + /* not subsetted, just do a copy */ + for (i = (long) tab->length; i > 0; i--) + fb_putchar(pdf, (eight_bits) ttf_getnum(1)); + } else { + if (cff != NULL) { + if (cff_is_cidfont(cff)) { + write_cid_cff(pdf, cff, fd_cur); +#if 0 + for (i = tab->length; i > 0; i--) + fb_putchar (ttf_getnum(1)); +#endif + } else { + write_cff(pdf, cff, fd_cur); + } + } else { + /* not understood, just do a copy */ + for (i = (long) tab->length; i > 0; i--) + fb_putchar(pdf, (eight_bits) ttf_getnum(1)); + } + } + xfree(dir_tab); + xfree(ttf_buffer); + if (tracefilenames) { + if (is_subsetted(fd_cur->fm)) + tex_printf(">"); + else + tex_printf(">>"); + } + cur_file_name = NULL; +} diff --git a/Build/source/texk/web2c/luatexdir/font/writetype2.c b/Build/source/texk/web2c/luatexdir/font/writetype2.c deleted file mode 100644 index 4d187b59a83..00000000000 --- a/Build/source/texk/web2c/luatexdir/font/writetype2.c +++ /dev/null @@ -1,442 +0,0 @@ -/* writetype0.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "writettf.h" -#include "writecff.h" - -#include "sfnt.h" -#include "tt_glyf.h" - -static const char _svn_version[] = - "$Id: writetype2.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/writetype2.c $"; - -/* forward*/ -void make_tt_subset(fd_entry * fd, unsigned char *buffer, integer buflen); - -unsigned long cidtogid_obj = 0; - -/* low-level helpers */ - -#define test_loc(l) \ - if ((f->loc+l)>f->buflen) { \ - fprintf (stderr,"File ended prematurely\n"); \ - uexit(1); \ - } - - -BYTE get_unsigned_byte(sfnt * f) -{ - test_loc(1); - return (BYTE) f->buffer[(f->loc++)]; -}; - -ICHAR get_signed_byte(sfnt * f) -{ - test_loc(1); - return (ICHAR) f->buffer[(f->loc++)]; -}; - -USHORT get_unsigned_pair(sfnt * f) -{ - USHORT l; - test_loc(2); - l = f->buffer[(f->loc++)]; - l = l * 0x100 + f->buffer[(f->loc++)]; - return l; -}; - -SHORT get_signed_pair(sfnt * f) -{ - long l; - test_loc(2); - l = f->buffer[(f->loc++)]; - if (l > 0x80) - l -= 0x100; - l = l * 0x100 + f->buffer[(f->loc++)]; - return l; -}; - -ULONG get_unsigned_quad(sfnt * f) -{ - ULONG l; - test_loc(4); - l = f->buffer[(f->loc++)]; - l = l * 0x100 + f->buffer[(f->loc++)]; - l = l * 0x100 + f->buffer[(f->loc++)]; - l = l * 0x100 + f->buffer[(f->loc++)]; - return l; -}; - -int do_sfnt_read(unsigned char *dest, int len, sfnt * f) -{ - int i; - test_loc(len); - for (i = 0; i < len; i++) { - *(dest + i) = f->buffer[f->loc + i]; - } - f->loc += len; - return len; -}; - -pdf_obj *pdf_new_stream(void) -{ - pdf_obj *stream = xmalloc(sizeof(pdf_obj)); - stream->length = 0; - stream->data = NULL; - return stream; -}; - -void pdf_add_stream(pdf_obj * stream, unsigned char *buf, long len) -{ - int i; - assert(stream != NULL); - if (stream->data == NULL) { - stream->data = xmalloc(len); - } else { - stream->data = xrealloc(stream->data, len + stream->length); - } - for (i = 0; i < len; i++) { - *(stream->data + stream->length + i) = *(buf + i); - } - stream->length += len; -}; - -void pdf_release_obj(pdf_obj * stream) -{ - if (stream != NULL) { - if (stream->data != NULL) { - xfree(stream->data); - } - xfree(stream); - } -}; - - -void writetype2(fd_entry * fd) -{ - int callback_id; - int file_opened = 0; - char *ftemp = NULL; - - glyph_tab = NULL; - - fd_cur = fd; /* fd_cur is global inside writettf.c */ - assert(fd_cur->fm != NULL); - assert(is_truetype(fd_cur->fm)); - - if (!is_subsetted(fd_cur->fm)) { - writettf(fd); - return; - } - - assert(is_included(fd_cur->fm)); - - set_cur_file_name(fd_cur->fm->ff_name); - ttf_curbyte = 0; - ttf_size = 0; - callback_id = callback_defined(find_opentype_file_callback); - if (callback_id > 0) { - if (run_callback - (callback_id, "S->S", (char *) (nameoffile + 1), &ftemp)) { - if (ftemp != NULL && strlen(ftemp)) { - free(nameoffile); - namelength = strlen(ftemp); - nameoffile = xmalloc(namelength + 2); - strcpy((char *) (nameoffile + 1), ftemp); - free(ftemp); - } - } - } - callback_id = callback_defined(read_opentype_file_callback); - if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", (char *) (nameoffile + 1), - &file_opened, &ttf_buffer, &ttf_size) && - file_opened && ttf_size > 0) { - } else { - pdftex_fail("cannot open OpenType font file for reading"); - } - } else { - if (!otf_open()) { - pdftex_fail("cannot open OpenType font file for reading"); - } - ttf_read_file(); - ttf_close(); - } - - cur_file_name = (char *) nameoffile + 1; - fd_cur->ff_found = true; - - if (tracefilenames) { - if (is_subsetted(fd_cur->fm)) - tex_printf("<%s", cur_file_name); - else - tex_printf("<<%s", cur_file_name); - } - - /* here is the real work */ - - make_tt_subset(fd, ttf_buffer, ttf_size); - - /*xfree (dir_tab); */ - xfree(ttf_buffer); - if (tracefilenames) { - if (is_subsetted(fd_cur->fm)) - tex_printf(">"); - else - tex_printf(">>"); - } - cur_file_name = NULL; -} - -/* - * PDF viewer applications use following tables (CIDFontType 2) - * - * head, hhea, loca, maxp, glyf, hmtx, fpgm, cvt_, prep - * - * - from PDF Ref. v.1.3, 2nd ed. - * - * The fpgm, cvt_, and prep tables appears only when TrueType instructions - * requires them. Those tables must be preserved if they exist. - * We use must_exist flag to indicate `preserve it if present' - * and to make sure not to cause an error when it does not exist. - * - * post and name table must exist in ordinary TrueType font file, - * but when a TrueType font is converted to CIDFontType 2 font, those tables - * are no longer required. - * - * The OS/2 table (required for TrueType font for Windows and OS/2) contains - * liscencing information, but PDF viewers seems not using them. - * - * The 'name' table added. See comments in ttf.c. - */ - -static struct { - const char *name; - int must_exist; -} required_table[] = { - { - "OS/2", 0}, { - "cmap", 0}, { - "head", 1}, { - "hhea", 1}, { - "loca", 1}, { - "maxp", 1}, { - "name", 1}, { - "glyf", 1}, { - "hmtx", 1}, { - "fpgm", 0}, { - "cvt ", 0}, { - "prep", 0}, { - NULL, 0} -}; - - -static unsigned long ttc_read_offset(sfnt * sfont, int ttc_idx) -{ - long version; - unsigned long offset = 0; - unsigned long num_dirs = 0; - - sfnt_seek_set(sfont, 4); /* skip version tag */ - - version = sfnt_get_ulong(sfont); - num_dirs = sfnt_get_ulong(sfont); - if (ttc_idx < 0 || ttc_idx > (int) (num_dirs - 1)) { - fprintf(stderr, "Invalid TTC index number\n"); - uexit(1); - } - - sfnt_seek_set(sfont, 12 + ttc_idx * 4); - offset = sfnt_get_ulong(sfont); - - return offset; -} - -#include - -void make_tt_subset(fd_entry * fd, unsigned char *buffer, integer buflen) -{ - - long i, cid; - unsigned int last_cid; - glw_entry *found; - struct avl_traverser t; - unsigned char *cidtogidmap; - unsigned short num_glyphs, gid; - struct tt_glyphs *glyphs; - char *used_chars; - sfnt *sfont; - pdf_obj *fontfile; - int verbose = 0, error = 0; - - cidtogidmap = NULL; - - sfont = sfnt_open(buffer, buflen); - - if (sfont->type == SFNT_TYPE_TTC) { - i = ff_get_ttc_index(fd->fm->ff_name, fd->fm->ps_name); - error = sfnt_read_table_directory(sfont, ttc_read_offset(sfont, i)); - } else { - error = sfnt_read_table_directory(sfont, 0); - } - - if (error < 0) { - fprintf(stderr, "Could not parse the ttf directory.\n"); - uexit(1); - } - - glyphs = tt_build_init(); - - last_cid = 0; - - avl_t_init(&t, fd->gl_tree); - for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); - found != NULL; found = (glw_entry *) avl_t_next(&t)) { - if (found->id > last_cid) - last_cid = found->id; - } - -#ifndef NO_GHOSTSCRIPT_BUG - cidtogidmap = NULL; -#else - cidtogidmap = xmalloc(((last_cid + 1) * 2) * sizeof(unsigned char)); - memset(cidtogidmap, 0, (last_cid + 1) * 2); -#endif - - /* fill used_chars */ - used_chars = xmalloc((last_cid + 1) * sizeof(char)); - memset(used_chars, 0, (last_cid + 1)); - avl_t_init(&t, fd->gl_tree); - for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); - found != NULL; found = (glw_entry *) avl_t_next(&t)) { - used_chars[found->id] = 1; - } - - /* - * Map CIDs to GIDs. - */ - - num_glyphs = 1; /* .notdef */ - for (cid = 1; cid <= (long) last_cid; cid++) { - if (used_chars[cid] == 0) - continue; - gid = cid; - - -#ifndef NO_GHOSTSCRIPT_BUG - gid = tt_add_glyph(glyphs, gid, cid); -#else - gid = tt_add_glyph(glyphs, gid, num_glyphs); - cidtogidmap[2 * cid] = gid >> 8; - cidtogidmap[2 * cid + 1] = gid & 0xff; -#endif /* !NO_GHOSTSCRIPT_BUG */ - - num_glyphs++; - } - - if (num_glyphs == 1) { - fprintf(stderr, "No glyphs in subset?.\n"); - uexit(1); - } - - if (tt_build_tables(sfont, glyphs) < 0) { - fprintf(stderr, "Could not parse the ttf buffer.\n"); - uexit(1); - } - - if (verbose > 1) { - fprintf(stdout, "[%u glyphs (Max CID: %u)]", glyphs->num_glyphs, - last_cid); - } - - tt_build_finish(glyphs); - - /* Create font file */ - - for (i = 0; required_table[i].name; i++) { - if (sfnt_require_table(sfont, - required_table[i].name, - required_table[i].must_exist) < 0) { - fprintf(stderr, "Some required TrueType table does not exist."); - uexit(1); - } - } - - fontfile = sfnt_create_FontFile_stream(sfont); - - if (verbose > 1) { - fprintf(stdout, "[%ld bytes]", fontfile->length); - } - - /* squeeze in the cidgidmap */ - if (cidtogidmap != NULL) { - cidtogid_obj = pdf_new_objnum(); - pdf_begin_dict(cidtogid_obj, 0); - pdf_printf("/Length %i\n", ((last_cid + 1) * 2)); - pdf_end_dict(); - pdf_printf("stream\n"); - pdfroom((last_cid + 1) * 2); - for (i = 0; i < ((int) (last_cid + 1) * 2); i++) { - pdf_buf[pdf_ptr++] = cidtogidmap[i]; - } - pdf_printf("\nendstream\n"); - } - - /* the tff subset */ - for (i = 0; i < (int) (fontfile->length); i++) - fb_putchar(fontfile->data[i]); - - pdf_release_obj(fontfile); - - /* other stuff that needs fixing: */ - - /* - * DW, W, DW2, and W2 - */ - /* - if (opt_flags & CIDFONT_FORCE_FIXEDPITCH) { - pdf_add_dict(font->fontdict, - pdf_new_name("DW"), pdf_new_number(1000.0)); - } else { - add_TTCIDHMetrics(font->fontdict, glyphs, used_chars, cidtogidmap, last_cid); - if (v_used_chars) - add_TTCIDVMetrics(font->fontdict, glyphs, used_chars, cidtogidmap, last_cid); - } - */ - - /* - * CIDSet - */ - /* - { - pdf_obj *cidset; - - cidset = pdf_new_stream(STREAM_COMPRESS); - pdf_add_stream(cidset, used_chars, last_cid/8 + 1); - pdf_add_dict(font->descriptor, - pdf_new_name("CIDSet"), - pdf_ref_obj(cidset)); - pdf_release_obj(cidset); - } - */ - xfree(used_chars); - sfnt_close(sfont); - return; -} diff --git a/Build/source/texk/web2c/luatexdir/font/writetype2.w b/Build/source/texk/web2c/luatexdir/font/writetype2.w new file mode 100644 index 00000000000..5081d9f0986 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/font/writetype2.w @@ -0,0 +1,427 @@ +% writetype0.w +% +% Copyright 2006-2010 Taco Hoekwater +% +% This file is part of LuaTeX. +% +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. +% +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. +% +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" +#include "font/writettf.h" +#include "font/writecff.h" +#include "lua/luatex-api.h" + +#include "font/sfnt.h" +#include "font/tt_glyf.h" + +static const char _svn_version[] = + "$Id: writetype2.w 3584 2010-04-02 17:45:55Z hhenkel $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/font/writetype2.w $"; + +@ forward declaration +@c +void make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buffer, int buflen); + +@ @c +unsigned long cidtogid_obj = 0; + +@ low-level helpers +@c +#define test_loc(l) \ + if ((f->loc+l)>f->buflen) { \ + fprintf (stderr,"File ended prematurely\n"); \ + uexit(1); \ + } + + +BYTE get_unsigned_byte(sfnt * f) +{ + test_loc(1); + return (BYTE) f->buffer[(f->loc++)]; +} + +ICHAR get_signed_byte(sfnt * f) +{ + test_loc(1); + return (ICHAR) f->buffer[(f->loc++)]; +} + +USHORT get_unsigned_pair(sfnt * f) +{ + USHORT l; + test_loc(2); + l = f->buffer[(f->loc++)]; + l = (USHORT) (l * 0x100 + f->buffer[(f->loc++)]); + return l; +} + +SHORT get_signed_pair(sfnt * f) +{ + long l; + test_loc(2); + l = f->buffer[(f->loc++)]; + if (l > 0x80) + l -= 0x100; + l = l * 0x100 + f->buffer[(f->loc++)]; + return (SHORT) l; +} + +ULONG get_unsigned_quad(sfnt * f) +{ + ULONG l; + test_loc(4); + l = f->buffer[(f->loc++)]; + l = l * 0x100 + f->buffer[(f->loc++)]; + l = l * 0x100 + f->buffer[(f->loc++)]; + l = l * 0x100 + f->buffer[(f->loc++)]; + return l; +} + +int do_sfnt_read(unsigned char *dest, int len, sfnt * f) +{ + int i; + test_loc(len); + for (i = 0; i < len; i++) { + *(dest + i) = f->buffer[f->loc + i]; + } + f->loc += len; + return len; +} + +pdf_obj *pdf_new_stream(void) +{ + pdf_obj *stream = xmalloc(sizeof(pdf_obj)); + stream->length = 0; + stream->data = NULL; + return stream; +} + +void pdf_add_stream(pdf_obj * stream, unsigned char *buf, long len) +{ + int i; + assert(stream != NULL); + if (stream->data == NULL) { + stream->data = xmalloc((unsigned) len); + } else { + stream->data = + xrealloc(stream->data, (unsigned) len + (unsigned) stream->length); + } + for (i = 0; i < len; i++) { + *(stream->data + stream->length + i) = *(buf + i); + } + stream->length += (unsigned) len; +} + +void pdf_release_obj(pdf_obj * stream) +{ + if (stream != NULL) { + if (stream->data != NULL) { + xfree(stream->data); + } + xfree(stream); + } +} + +@ The main function. +@c +void writetype2(PDF pdf, fd_entry * fd) +{ + int callback_id; + int file_opened = 0; + + glyph_tab = NULL; + + fd_cur = fd; /* |fd_cur| is global inside \.{writettf.w} */ + assert(fd_cur->fm != NULL); + assert(is_truetype(fd_cur->fm)); + assert(is_included(fd_cur->fm)); + + ttf_curbyte = 0; + ttf_size = 0; + cur_file_name = + luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback); + if (cur_file_name == NULL) { + pdftex_fail("cannot find OpenType font file for reading"); + } + callback_id = callback_defined(read_opentype_file_callback); + if (callback_id > 0) { + if (run_callback(callback_id, "S->bSd", cur_file_name, + &file_opened, &ttf_buffer, &ttf_size) && + file_opened && ttf_size > 0) { + } else { + pdftex_fail("cannot open OpenType font file for reading"); + } + } else { + if (!otf_open(cur_file_name)) { + pdftex_fail("cannot open OpenType font file for reading"); + } + ttf_read_file(); + ttf_close(); + } + + fd_cur->ff_found = true; + + if (tracefilenames) { + if (is_subsetted(fd_cur->fm)) + tex_printf("<%s", cur_file_name); + else + tex_printf("<<%s", cur_file_name); + } + + /* here is the real work */ + + make_tt_subset(pdf, fd, ttf_buffer, ttf_size); +#if 0 + xfree (dir_tab); +#endif + xfree(ttf_buffer); + if (tracefilenames) { + if (is_subsetted(fd_cur->fm)) + tex_printf(">"); + else + tex_printf(">>"); + } + cur_file_name = NULL; +} + +@ PDF viewer applications use following tables (CIDFontType 2) + +\.{head, hhea, loca, maxp, glyf, hmtx, fpgm, cvt\_, prep} + +\rightline{from PDF Ref. v.1.3, 2nd ed.} + + The \.{fpgm}, \.{cvt\_} and \.{prep} tables appears only when TrueType instructions + requires them. Those tables must be preserved if they exist. + We use |must_exist| flag to indicate `preserve it if present' + and to make sure not to cause an error when it does not exist. + + \.{post} and \.{name} table must exist in ordinary TrueType font file, + but when a TrueType font is converted to CIDFontType 2 font, those tables + are no longer required. + + The OS/2 table (required for TrueType font for Windows and OS/2) contains + liscencing information, but PDF viewers seems not using them. + + The \.{name} table added. See comments in \.{writettf.w}. + +@c +static struct { + const char *name; + int must_exist; +} required_table[] = { + { + "OS/2", 0}, { + "cmap", 0}, { + "head", 1}, { + "hhea", 1}, { + "loca", 1}, { + "maxp", 0}, { + "name", 1}, { + "glyf", 1}, { + "hmtx", 1}, { + "fpgm", 0}, { + "cvt ", 0}, { + "prep", 0}, { + NULL, 0} +}; + + +unsigned long ttc_read_offset(sfnt * sfont, int ttc_idx) +{ + ULONG version; + unsigned long offset = 0; + unsigned long num_dirs = 0; + + sfnt_seek_set(sfont, 4); /* skip version tag */ + + version = sfnt_get_ulong(sfont); + num_dirs = sfnt_get_ulong(sfont); + if (ttc_idx < 0 || ttc_idx > (int) (num_dirs - 1)) { + fprintf(stderr, "Invalid TTC index number\n"); + uexit(1); + } + sfnt_seek_set(sfont, 12 + ttc_idx * 4); + offset = sfnt_get_ulong(sfont); + + return offset; +} + +@ Creating the subset. +@c +void make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buffer, int buflen) +{ + + long i, cid; + unsigned int last_cid; + glw_entry *found; + struct avl_traverser t; + unsigned char *cidtogidmap; + unsigned short num_glyphs, gid; + struct tt_glyphs *glyphs; + char *used_chars = NULL; + sfnt *sfont; + pdf_obj *fontfile; + int verbose = 0, error = 0; + + cidtogidmap = NULL; + + sfont = sfnt_open(buffer, buflen); + + if (sfont->type == SFNT_TYPE_TTC) { + i = ff_get_ttc_index(fd->fm->ff_name, fd->fm->ps_name); + tex_printf("(%s:%ld)", (fd->fm->ps_name ? fd->fm->ps_name : ""), i); + error = + sfnt_read_table_directory(sfont, ttc_read_offset(sfont, (int) i)); + } else { + error = sfnt_read_table_directory(sfont, 0); + } + + if (error < 0) { + fprintf(stderr, "Could not parse the ttf directory.\n"); + uexit(1); + } + if (is_subsetted(fd->fm)) { + /* rebuild the glyph tables and create a fresh cidmap */ + glyphs = tt_build_init(); + + last_cid = 0; + + avl_t_init(&t, fd->gl_tree); + for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); + found != NULL; found = (glw_entry *) avl_t_next(&t)) { + if (found->id > last_cid) + last_cid = found->id; + } + +#ifndef NO_GHOSTSCRIPT_BUG + cidtogidmap = NULL; +#else + cidtogidmap = xmalloc(((last_cid + 1) * 2) * sizeof(unsigned char)); + memset(cidtogidmap, 0, (last_cid + 1) * 2); +#endif + + /* fill |used_chars| */ + used_chars = xmalloc((last_cid + 1) * sizeof(char)); + memset(used_chars, 0, (last_cid + 1)); + avl_t_init(&t, fd->gl_tree); + for (found = (glw_entry *) avl_t_first(&t, fd->gl_tree); + found != NULL; found = (glw_entry *) avl_t_next(&t)) { + used_chars[found->id] = 1; + } + + /* Map CIDs to GIDs. */ + + num_glyphs = 1; /* \.{.notdef} */ + for (cid = 1; cid <= (long) last_cid; cid++) { + if (used_chars[cid] == 0) + continue; + gid = (short unsigned) cid; + + +#ifndef NO_GHOSTSCRIPT_BUG + gid = tt_add_glyph(glyphs, (USHORT) gid, (USHORT) cid); +#else + gid = tt_add_glyph(glyphs, (USHORT) gid, (USHORT) num_glyphs); + cidtogidmap[2 * cid] = gid >> 8; + cidtogidmap[2 * cid + 1] = gid & 0xff; +#endif /* |!NO_GHOSTSCRIPT_BUG| */ + + num_glyphs++; + } + + if (num_glyphs == 1) { + fprintf(stderr, "No glyphs in subset?.\n"); + uexit(1); + } + + if (tt_build_tables(sfont, glyphs) < 0) { + fprintf(stderr, "Could not parse the ttf buffer.\n"); + uexit(1); + } + + if (verbose > 1) { + fprintf(stdout, "[%u glyphs (Max CID: %u)]", glyphs->num_glyphs, + last_cid); + } + + tt_build_finish(glyphs); + } + + /* Create font file */ + + for (i = 0; required_table[i].name; i++) { + if (sfnt_require_table(sfont, + required_table[i].name, + required_table[i].must_exist) < 0) { + fprintf(stderr, "Some required TrueType table does not exist."); + uexit(1); + } + } + + fontfile = sfnt_create_FontFile_stream(sfont); + + if (verbose > 1) { + fprintf(stdout, "[%ld bytes]", fontfile->length); + } + + /* squeeze in the cidgidmap */ + if (cidtogidmap != NULL) { + cidtogid_obj = (unsigned long) pdf_new_objnum(pdf); + pdf_begin_dict(pdf, (int) cidtogid_obj, 0); + pdf_printf(pdf, "/Length %i\n", ((last_cid + 1) * 2)); + pdf_end_dict(pdf); + pdf_printf(pdf, "stream\n"); + pdf_room(pdf, (int) ((last_cid + 1) * 2)); + for (i = 0; i < ((int) (last_cid + 1) * 2); i++) { + pdf_quick_out(pdf, cidtogidmap[i]); + } + pdf_printf(pdf, "\nendstream\n"); + } + + /* the tff subset */ + for (i = 0; i < (int) (fontfile->length); i++) + fb_putchar(pdf, fontfile->data[i]); + + pdf_release_obj(fontfile); + + /* TODO other stuff that needs fixing: */ + + /* DW, W, DW2, and W2 */ +#if 0 + if (opt_flags & CIDFONT_FORCE_FIXEDPITCH) { + pdf_add_dict(font->fontdict, + pdf_new_name("DW"), pdf_new_number(1000.0)); + } else { + add_TTCIDHMetrics(font->fontdict, glyphs, used_chars, cidtogidmap, last_cid); + if (v_used_chars) + add_TTCIDVMetrics(font->fontdict, glyphs, used_chars, cidtogidmap, last_cid); + } +#endif + /* CIDSet */ +#if 0 + { + pdf_obj *cidset; + + cidset = pdf_new_stream(STREAM_COMPRESS); + pdf_add_stream(cidset, used_chars, last_cid/8 + 1); + pdf_add_dict(font->descriptor, + pdf_new_name("CIDSet"), + pdf_ref_obj(cidset)); + pdf_release_obj(cidset); + } +#endif + xfree(used_chars); + sfnt_close(sfont); + return; +} diff --git a/Build/source/texk/web2c/luatexdir/get_svnversion.sh b/Build/source/texk/web2c/luatexdir/get_svnversion.sh deleted file mode 100755 index 1c544342799..00000000000 --- a/Build/source/texk/web2c/luatexdir/get_svnversion.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -srcdir=$1 -if [ -e "`which svnversion`" ] && [ -e "`which sed`" ]; then - REV=`svnversion $srcdir | sed 's/^\([0-9]\+\).*/\1/'` - case $REV in *[^0-9]*) - echo unknown - exit 0 - ;; - esac - echo $REV -else - echo unknown -fi \ No newline at end of file diff --git a/Build/source/texk/web2c/luatexdir/getluatexsvnversion.sh b/Build/source/texk/web2c/luatexdir/getluatexsvnversion.sh new file mode 100755 index 00000000000..a59bc81db56 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/getluatexsvnversion.sh @@ -0,0 +1,25 @@ +#! /bin/sh + +# This script should be run within the source directory. + +$DEBUG + +FILE="texk/web2c/luatexdir/luatex_svnversion.h" + +LANG=C +if [ ! -r $FILE ] +then + echo '#define luatex_svn_revision -1' > $FILE +fi +if ( [ -d ./.svn ] && svnversion > /dev/null ) +then + # svn up > /dev/null + DEFREV=`cat $FILE` + SVNREV=`svnversion -c . | sed -ne 's/^[0-9]*:*\([0-9]*\).*/#define luatex_svn_revision \1/p'` + test "$DEFREV" != "$SVNREV" && echo "$SVNREV" > $FILE +elif ( [ -f ../.git/refs/remotes/git-svn ] && git svn --version > /dev/null ) +then + DEFREV=`cat $FILE` + SVNREV=`git svn info | sed -ne 's/^Revision: \([0-9]*\).*$/#define luatex_svn_revision \1/p'` + test "$DEFREV" != "$SVNREV" && echo "$SVNREV" > $FILE +fi diff --git a/Build/source/texk/web2c/luatexdir/hyphen.h b/Build/source/texk/web2c/luatexdir/hyphen.h deleted file mode 100644 index 842049e263c..00000000000 --- a/Build/source/texk/web2c/luatexdir/hyphen.h +++ /dev/null @@ -1,61 +0,0 @@ -/* LibHnj is dual licensed under LGPL and MPL. Boilerplate for both - * licenses follows. - */ - -/* LibHnj - a library for high quality hyphenation and justification - * Copyright (C) 1998 Raph Levien, (C) 2001 ALTLinux, Moscow - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307 USA. -*/ - -/* - * The contents of this file are subject to the Mozilla Public License - * Version 1.0 (the "MPL"); you may not use this file except in - * compliance with the MPL. You may obtain a copy of the MPL at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the MPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL - * for the specific language governing rights and limitations under the - * MPL. - * - */ -#ifndef __HYPHEN_H__ -# define __HYPHEN_H__ - -# ifdef __cplusplus -extern "C" { -# endif /* __cplusplus */ - - typedef struct _HyphenDict HyphenDict; - -# include "ptexlib.h" -# include "nodes.h" - - HyphenDict *hnj_hyphen_new(void); - void hnj_hyphen_load(HyphenDict * dict, const unsigned char *fn); - void hnj_hyphen_free(HyphenDict * dict); - void hnj_hyphen_clear(HyphenDict * dict); - void hnj_hyphen_hyphenate(HyphenDict * dict, halfword first, halfword last, - int size, halfword left, halfword right, - lang_variables * lan); - unsigned char *hnj_serialize(HyphenDict *); - void hnj_free_serialize(unsigned char *); - -# ifdef __cplusplus -} -# endif /* __cplusplus */ -#endif /* __HYPHEN_H__ */ diff --git a/Build/source/texk/web2c/luatexdir/image/epdf.c b/Build/source/texk/web2c/luatexdir/image/epdf.c deleted file mode 100644 index cf86a38fa34..00000000000 --- a/Build/source/texk/web2c/luatexdir/image/epdf.c +++ /dev/null @@ -1,81 +0,0 @@ -/* epdf.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "ptexlib.h" -#include "inc-epdf.h" - -#include - -static const char _svn_version[] = - "$Id: epdf.c 2599 2009-06-25 10:35:26Z taco $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/image/epdf.c $"; - -fd_entry *epdf_create_fontdescriptor(fm_entry * fm, int stemV) -{ - fd_entry *fd; - if ((fd = lookup_fd_entry(fm->ff_name, fm->slant, fm->extend)) == NULL) { - fm->in_use = true; - fd = new_fd_entry(); - fd->fm = fm; - register_fd_entry(fd); - fd->fd_objnum = pdf_new_objnum(); - assert(fm->ps_name != NULL); - fd->fontname = xstrdup(fm->ps_name); /* just fallback */ - // stemV must be copied - fd->font_dim[STEMV_CODE].val = stemV; - fd->font_dim[STEMV_CODE].set = true; - fd->gl_tree = avl_create(comp_string_entry, NULL, &avl_xallocator); - assert(fd->gl_tree != NULL); - } - return fd; -} - -/*********************************************************************** - * Mark glyphs used by embedded PDF file: - * 1. build fontdescriptor, if not yet existing - * 2. mark glyphs directly there - * - * Input charset from xpdf is a string of glyph names including - * leading slashes, but without blanks between them, like: /a/b/c -***********************************************************************/ - -void epdf_mark_glyphs(fd_entry * fd, char *charset) -{ - char *p, *q, *s; - char *glyph; - void **aa; - if (charset == NULL) - return; - assert(fd != NULL); - for (s = charset + 1, q = charset + strlen(charset); s < q; s = p + 1) { - for (p = s; *p != '\0' && *p != '/'; p++); - *p = '\0'; - if ((char *) avl_find(fd->gl_tree, s) == NULL) { - glyph = xstrdup(s); - aa = avl_probe(fd->gl_tree, glyph); - assert(aa != NULL); - } - } -} - -void epdf_free(void) -{ - epdf_check_mem(); -} diff --git a/Build/source/texk/web2c/luatexdir/image/epdf.h b/Build/source/texk/web2c/luatexdir/image/epdf.h index c619b20f08f..6d2632b0e54 100644 --- a/Build/source/texk/web2c/luatexdir/image/epdf.h +++ b/Build/source/texk/web2c/luatexdir/image/epdf.h @@ -1,8 +1,7 @@ /* epdf.h Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. LuaTeX is free software; you can redistribute it and/or modify it under @@ -18,11 +17,50 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: epdf.h 2327 2009-04-18 12:47:21Z hhenkel $ */ +/* $Id: epdf.h 3407 2010-01-28 16:27:39Z taco $ */ + +// this is the common header file for C++ sources pdftoepdf.cc and lepdflib.cc + +#ifndef EPDF_H +# define EPDF_H + +# include +# include +# include +# include +# include +# include +# include +# ifdef POPPLER_VERSION +# define GString GooString +# include +# include +# include +# include +# include +# else +# include +# include +# include +# include +# include +# endif +# include "Object.h" +# include "Stream.h" +# include "Array.h" +# include "Dict.h" +# include "XRef.h" +# include "Catalog.h" +# include "Link.h" +# include "Page.h" +# include "GfxFont.h" +# include "PDFDoc.h" +# include "GlobalParams.h" +# include "Error.h" extern "C" { -#include +# include extern char *xstrdup(const char *); @@ -30,91 +68,106 @@ extern "C" { typedef const char *const_string; /* including kpathsea/types.h doesn't work on some systems */ -#define KPATHSEA_CONFIG_H /* avoid including other kpathsea header files */ +# define KPATHSEA_CONFIG_H /* avoid including other kpathsea header files */ /* from web2c/config.h */ -#ifdef CONFIG_H /* CONFIG_H has been defined by some xpdf */ -# undef CONFIG_H /* header file */ -#endif +# ifdef CONFIG_H /* CONFIG_H has been defined by some xpdf */ +# undef CONFIG_H /* header file */ +# endif -#include /* define SIZEOF_LONG */ -#include /* define type integer */ +# include /* define SIZEOF_LONG */ -#include -#include "openbsd-compat.h" -#include "image.h" -#include "../utils/avlstuff.h" +# include "openbsd-compat.h" +# include "image.h" +# include "utils/avlstuff.h" +# include "pdf/pdftypes.h" - extern void unrefPdfDocument(char *); +# include "lua51/lua.h" +# include "lua51/lauxlib.h" - extern integer epdf_page_box; - extern void *epdf_xref; - extern integer epdf_lastGroupObjectNum; - - extern integer pdf_box_spec_media; - extern integer pdf_box_spec_crop; - extern integer pdf_box_spec_bleed; - extern integer pdf_box_spec_trim; - extern integer pdf_box_spec_art; - - extern longinteger pdf_stream_length; - extern longinteger pdf_ptr; - extern integer pool_ptr; - typedef unsigned char eight_bits; - extern eight_bits *pdf_buf; - extern integer pdf_buf_size; - extern integer pdf_os_mode; - extern eight_bits pdf_last_byte; - extern integer fixed_inclusion_copy_font; - - extern char notdef[]; - - extern integer fixed_replace_font; - - extern int is_subsetable(struct fm_entry *); - extern struct fm_entry *lookup_fontmap(char *); - extern integer get_fontfile(struct fm_entry *); - extern integer get_fontname(struct fm_entry *); - extern integer pdf_new_objnum(void); - extern void read_pdf_info(image_dict *, integer, integer); - extern void embed_whole_font(struct fd_entry *); - extern void epdf_check_mem(void); + /* pdfgen.c */ + __attribute__ ((format(printf, 2, 3))) + extern void pdf_printf(PDF, const char *fmt, ...); + extern void pdf_puts(PDF, const char *); + extern void pdf_begin_obj(PDF, int, bool); + extern void pdf_end_obj(PDF); + extern void pdf_begin_stream(PDF); + extern void pdf_end_stream(PDF); + extern void pdf_room(PDF, int); +# define pdf_out(B,A) do { pdf_room(B,1); B->buf[B->ptr++] = A; } while (0) + + /* pdftables.c */ + extern int pdf_new_objnum(PDF); + + /* epdf.c */ extern void epdf_free(void); + + /* pdftoepdf.cc */ + extern void read_pdf_info(image_dict *, int, int, img_readtype_e); + extern void write_epdf(PDF, image_dict *); + extern void unrefPdfDocument(char *); + extern void epdf_check_mem(void); + + /* utils.c */ __attribute__ ((format(printf, 1, 2))) - extern void pdf_printf(const char *fmt, ...); - extern void pdf_puts(const char *); - extern void pdf_begin_stream(void); - extern void pdf_end_obj(void); - extern void pdf_end_stream(void); - extern void pdf_flush(void); + extern void pdftex_warn(const char *fmt, ...); __attribute__ ((noreturn, format(printf, 1, 2))) extern void pdftex_fail(const char *fmt, ...); - __attribute__ ((format(printf, 1, 2))) - extern void pdftex_warn(const char *fmt, ...); - __attribute__ ((format(printf, 1, 2))) - extern void tex_printf(const char *, ...); - extern void write_epdf(image_dict *); - extern void write_additional_epdf_objects(void); - extern void zpdf_begin_dict(integer, bool); - extern void zpdf_begin_obj(integer, bool); - extern void zpdf_create_obj(integer, integer); - extern void zpdf_new_dict(integer, integer, bool); - extern void zpdf_os_get_os_buf(integer); - -/* epdf.c */ - extern int get_fd_objnum(struct fd_entry *); - extern int get_fn_objnum(struct fd_entry *); - -#include "../inc-epdf.h" - -/* utils.c */ extern char *convertStringToPDFString(char *in, int len); extern char *stripzeros(char *a); -/* config.c */ - extern integer cfgpar(integer); - -/* avlstuff.c */ - extern void avl_put_obj(integer, integer); - extern integer avl_find_obj(integer, integer, integer); -} + /* lepdflib.c */ + int luaopen_epdf(lua_State * L); + +}; + +/**********************************************************************/ + +// PdfObject encapsulates the xpdf Object type, +// and properly frees its resources on destruction. +// Use obj-> to access members of the Object, +// and &obj to get a pointer to the object. +// It is no longer necessary to call Object::free explicitely. + +// *INDENT-OFF* +class PdfObject { + public: + PdfObject() { // nothing + } + ~PdfObject() { + iObject.free(); + } + Object *operator->() { + return &iObject; + } + Object *operator&() { + return &iObject; + } + private: // no copying or assigning + PdfObject(const PdfObject &); + void operator=(const PdfObject &); + public: + Object iObject; +}; +// *INDENT-ON* + +/**********************************************************************/ + +struct InObj { + Ref ref; // ref in original PDF + int num; // new object number in output PDF + InObj *next; // next entry in list of indirect objects +}; + +struct PdfDocument { + char *file_path; // full file name including path + char *checksum; // for reopening + PDFDoc *doc; + InObj *inObjList; // temporary linked list + avl_table *ObjMapTree; // permanent over luatex run + int occurences; // number of references to the PdfDocument; it can be deleted when occurences == 0 +}; + +PdfDocument *refPdfDocument(char *file_path); + +#endif /* EPDF_H */ diff --git a/Build/source/texk/web2c/luatexdir/image/epdf.w b/Build/source/texk/web2c/luatexdir/image/epdf.w new file mode 100644 index 00000000000..c52f148ffdf --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/image/epdf.w @@ -0,0 +1,34 @@ +% epdf.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2009 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: epdf.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/image/epdf.w $"; + +#include "ptexlib.h" + +@ This must the be shortest C file we have that actually does something. + +@c +void epdf_free(void) +{ + epdf_check_mem(); +} diff --git a/Build/source/texk/web2c/luatexdir/image/image.h b/Build/source/texk/web2c/luatexdir/image/image.h index a2d47f6a471..c4d0c3963f7 100644 --- a/Build/source/texk/web2c/luatexdir/image/image.h +++ b/Build/source/texk/web2c/luatexdir/image/image.h @@ -1,7 +1,7 @@ /* image.h Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -18,23 +18,20 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: image.h 2336 2009-04-19 08:38:24Z hhenkel $ */ +/* $Id: image.h 3388 2010-01-26 10:59:04Z taco $ */ #ifndef IMAGE_H # define IMAGE_H # include +# include "pdf/pdftypes.h" /* for scaled_whd */ # define JPG_UINT16 unsigned int # define JPG_UINT32 unsigned long # define JPG_UINT8 unsigned char -# define IMAGE_COLOR_B 1 -# define IMAGE_COLOR_C 2 -# define IMAGE_COLOR_I 4 - -extern integer zround(double); /* from zround.c */ -# define bp2int(p) zround(p * (one_hundred_bp / 100.0)) +extern int do_zround(double r); /* from utils.c */ +# define bp2int(p) do_zround(p * (one_hundred_bp / 100.0)) # define int2bp(i) (i * 100.0 / one_hundred_bp) # define TYPE_IMG "image" @@ -83,31 +80,33 @@ typedef enum { PDF_BOX_SPEC_NONE, PDF_BOX_SPEC_MEDIA, PDF_BOX_SPEC_CROP, /**********************************************************************/ typedef struct { - integer objnum; - integer index; /* /Im1, /Im2, ... */ - integer x_size; /* dimensions in pixel counts as in JPG/PNG/JBIG2 file */ - integer y_size; - integer x_orig; /* origin in sp for PDF files */ - integer y_orig; - integer x_res; /* pixel resolution as in JPG/PNG/JBIG2 file */ - integer y_res; - integer rotation; /* rotation (multiples of 90 deg.) for PDF files */ - integer colorspace; /* number of /ColorSpace object */ - integer group_ref; /* if it's <=0, the page has no group */ - integer total_pages; - integer page_num; /* requested page (by number) */ + int objnum; + int index; /* /Im1, /Im2, ... */ + scaled_whd dimen; /* TeX dimensions given to \pdfximage */ + int transform; /* transform given to \pdfximage */ + int x_size; /* dimensions in pixel counts as in JPG/PNG/JBIG2 file */ + int y_size; + int x_orig; /* origin in sp for PDF files */ + int y_orig; + int x_res; /* pixel resolution as in JPG/PNG/JBIG2 file */ + int y_res; + int rotation; /* rotation (multiples of 90 deg.) for PDF files */ + int colorspace; /* number of /ColorSpace object */ + int group_ref; /* if it's <=0, the page has no group */ + int total_pages; + int page_num; /* requested page (by number) */ char *pagename; /* requested page (by name) */ char *filename; /* requested raw file name */ char *filepath; /* full file path after kpathsea */ char *attr; /* additional image dict entries */ FILE *file; imgtype_e image_type; - int color_space; /* used color space. See JPG_ constants */ + int procset; /* /ProcSet flags */ int color_depth; /* color depth */ pdfboxspec_e page_box_spec; /* PDF page box spec.: media/crop/bleed/trim/art */ - integer bbox[4]; + int bbox[4]; dict_state state; - integer flags; + int flags; union { pdf_stream_struct *pdfstream; png_img_struct *png; @@ -118,6 +117,11 @@ typedef struct { # define img_objnum(N) ((N)->objnum) # define img_index(N) ((N)->index) +# define img_dimen(N) ((N)->dimen) +# define img_width(N) ((N)->dimen.wd) +# define img_height(N) ((N)->dimen.ht) +# define img_depth(N) ((N)->dimen.dp) +# define img_transform(N) ((N)->transform) # define img_xsize(N) ((N)->x_size) # define img_ysize(N) ((N)->y_size) # define img_xorig(N) ((N)->x_orig) @@ -135,11 +139,12 @@ typedef struct { # define img_attr(N) ((N)->attr) # define img_file(N) ((N)->file) # define img_type(N) ((N)->image_type) -# define img_color(N) ((N)->color_space) +# define img_procset(N) ((N)->procset) # define img_colordepth(N) ((N)->color_depth) # define img_pagebox(N) ((N)->page_box_spec) # define img_bbox(N) ((N)->bbox) # define img_state(N) ((N)->state) +# define img_flags(N) ((N)->flags) # define img_pdfstream_ptr(N) ((N)->img_struct.pdfstream) # define img_pdfstream_stream(N) ((N)->img_struct.pdfstream->stream) @@ -154,42 +159,39 @@ typedef struct { # define img_jb2_ptr(N) ((N)->img_struct.jb2) # define F_FLAG_BBOX (1 << 0) +# define F_FLAG_GROUP (1 << 1) # define img_set_bbox(N) (img_flags(N) |= F_FLAG_BBOX) # define img_unset_bbox(N) (img_flags(N) &= ~F_FLAG_BBOX) # define img_is_bbox(N) ((img_flags(N) & F_FLAG_BBOX) != 0) +# define img_set_group(N) (img_flags(N) |= F_FLAG_GROUP) +# define img_unset_group(N) (img_flags(N) &= ~F_FLAG_GROUP) +# define img_is_group(N) ((img_flags(N) & F_FLAG_GROUP) != 0) + +# define epdf_xsize(a) img_xsize(idict_array[a]) +# define epdf_ysize(a) img_ysize(idict_array[a]) +# define epdf_orig_x(a) img_xorig(idict_array[a]) +# define epdf_orig_y(a) img_yorig(idict_array[a]) + +# define is_pdf_image(a) (img_type(idict_array[a]) == IMG_TYPE_PDF) +# define is_png_image(a) (img_type(idict_array[a]) == IMG_TYPE_PNG) + +# define img_is_refered(N) (img_index(N) != -1) + /**********************************************************************/ +/* image structure corresponds to pdfrefximage node */ typedef struct { - integer width; /* requested/actual TeX dimensions */ - integer height; - integer depth; - integer transform; - integer flags; + scaled_whd dimen; /* requested/actual TeX dimensions */ + int transform; image_dict *dict; - int array_idx; /* index within img_array */ int dict_ref; /* luaL_ref() reference */ } image; -# define img_width(N) ((N)->width) -# define img_height(N) ((N)->height) -# define img_depth(N) ((N)->depth) -# define img_transform(N) ((N)->transform) -# define img_flags(N) ((N)->flags) # define img_dict(N) ((N)->dict) -# define img_arrayidx(N) ((N)->array_idx) # define img_dictref(N) ((N)->dict_ref) -# define img_is_refered(N) (img_arrayidx(N) != -1) - -# define F_FLAG_SCALED (1 << 0) - -# define img_flags(N) ((N)->flags) -# define img_set_scaled(N) (img_flags(N) |= F_FLAG_SCALED) -# define img_unset_scaled(N) (img_flags(N) &= ~F_FLAG_SCALED) -# define img_is_scaled(N) ((img_flags(N) & F_FLAG_SCALED) != 0) - # define set_wd_running(N) (img_width(N) = null_flag) # define set_ht_running(N) (img_height(N) = null_flag) # define set_dp_running(N) (img_depth(N) = null_flag) diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.cc b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.cc index 536c6398cd7..8a177163a76 100644 --- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.cc +++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.cc @@ -1,7 +1,7 @@ /* pdftoepdf.cc - + Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -18,46 +18,13 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include -#include -#include -#include -#include -#include -#ifdef POPPLER_VERSION -# define GString GooString -# include -# include -# include -# include -# include -#else -# include -# include -# include -# include -# include -#endif -#include "Object.h" -#include "Stream.h" -#include "Array.h" -#include "Dict.h" -#include "XRef.h" -#include "Catalog.h" -#include "Link.h" -#include "Page.h" -#include "GfxFont.h" -#include "PDFDoc.h" -#include "GlobalParams.h" -#include "Error.h" +static const char _svn_version[] = + "$Id: pdftoepdf.cc 3431 2010-02-17 20:35:50Z oneiros $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/image/pdftoepdf.cc $"; #include "epdf.h" -static const char _svn_version[] = - "$Id: pdftoepdf.cc 2448 2009-06-08 07:43:50Z taco $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/image/pdftoepdf.cc $"; - -#define one_hundred_bp 6578176 /* 7227 * 65536 / 72 */ +#define one_hundred_bp 6578176 // one_hundred_bp = 7227 * 65536 / 72 // This file is mostly C and not very much C++; it's just used to interface // the functions of xpdf, which happens to be written in C++. @@ -67,81 +34,16 @@ static const char _svn_version[] = #define pdfkeyprefix "PTEX" -// PdfObject encapsulates the xpdf Object type, -// and properly frees its resources on destruction. -// Use obj-> to access members of the Object, -// and &obj to get a pointer to the object. -// It is no longer necessary to call Object::free explicitely. - -/* *INDENT-OFF* */ -class PdfObject { - public: - PdfObject() { // nothing - } - ~PdfObject() { - iObject.free(); - } - Object *operator->() { - return &iObject; - } - Object *operator&() { - return &iObject; - } - private: // no copying or assigning - PdfObject(const PdfObject &); - void operator=(const PdfObject &); - public: - Object iObject; -}; -/* *INDENT-ON* */ - -// When copying the Resources of the selected page, all objects are copied -// recusively top-down. Indirect objects however are not fetched during -// copying, but get a new object number from pdfTeX and then will be -// appended into a linked list. Duplicates are checked and removed from the -// list of indirect objects during appending. - -enum InObjType { objFont, objFontDesc, objOther }; - -struct InObj { - Ref ref; // ref in original PDF - InObjType type; // object type - integer num; // new object number in output PDF - fd_entry *fd; // pointer to /FontDescriptor object structure - integer enc_objnum; // Encoding for objFont - int written; // has it been written to output PDF? - InObj *next; // next entry in list of indirect objects -}; - -struct UsedEncoding { - integer enc_objnum; - GfxFont *font; - UsedEncoding *next; -}; - -static XRef *xref = NULL; -static InObj *inObjList = NULL; -static UsedEncoding *encodingList; static GBool isInit = gFalse; -static bool groupIsIndirect; -static PdfObject lastGroup; //********************************************************************** -// Maintain AVL tree of open embedded PDF files +// Maintain AVL tree of all PDF files for embedding static avl_table *PdfDocumentTree = NULL; -struct PdfDocument { - char *file_path; // full file name including path - PDFDoc *doc; - XRef *xref; - InObj *inObjList; - int occurences; // number of references to the PdfDocument; it can be deleted when occurences == 0 -}; - -/* AVL sort PdfDocument into PdfDocumentTree by file_path */ +// AVL sort PdfDocument into PdfDocumentTree by file_path -static int CompPdfDocument(const void *pa, const void *pb, void *p) +static int CompPdfDocument(const void *pa, const void *pb, void * /*p */ ) { return strcmp(((const PdfDocument *) pa)->file_path, ((const PdfDocument *) pb)->file_path); @@ -154,8 +56,7 @@ static PdfDocument *findPdfDocument(char *file_path) PdfDocument *pdf_doc, tmp; assert(file_path != NULL); if (PdfDocumentTree == NULL) - PdfDocumentTree = avl_create(CompPdfDocument, NULL, &avl_xallocator); - assert(PdfDocumentTree != NULL); + return NULL; tmp.file_path = file_path; pdf_doc = (PdfDocument *) avl_find(PdfDocumentTree, &tmp); return pdf_doc; @@ -164,26 +65,35 @@ static PdfDocument *findPdfDocument(char *file_path) // Returns pointer to PdfDocument structure for PDF file. // Creates a new structure if it doesn't exist yet. -static PdfDocument *refPdfDocument(char *file_path) +char *get_file_checksum(char *a); + +PdfDocument *refPdfDocument(char *file_path) { PdfDocument *pdf_doc = findPdfDocument(file_path); if (pdf_doc == NULL) { + if (PdfDocumentTree == NULL) + PdfDocumentTree = + avl_create(CompPdfDocument, NULL, &avl_xallocator); pdf_doc = new PdfDocument; pdf_doc->file_path = xstrdup(file_path); + pdf_doc->checksum = get_file_checksum(file_path); void **aa = avl_probe(PdfDocumentTree, pdf_doc); assert(aa != NULL); + pdf_doc->ObjMapTree = NULL; + pdf_doc->doc = NULL; + } + if (pdf_doc->doc == NULL) { GString *docName = new GString(pdf_doc->file_path); pdf_doc->doc = new PDFDoc(docName); // takes ownership of docName if (!pdf_doc->doc->isOk() || !pdf_doc->doc->okToPrint()) pdftex_fail("xpdf: reading PDF image failed"); - pdf_doc->xref = NULL; pdf_doc->inObjList = NULL; pdf_doc->occurences = 0; // 0 = unreferenced + } #ifdef DEBUG - fprintf(stderr, "\nluatex Debug: Creating %s (%d)\n", - pdf_doc->file_path, pdf_doc->occurences); + fprintf(stderr, "\nluatex Debug: Creating %s (%d)\n", + pdf_doc->file_path, pdf_doc->occurences); #endif - } pdf_doc->occurences++; #ifdef DEBUG fprintf(stderr, "\nluatex Debug: Incrementing %s (%d)\n", @@ -192,293 +102,94 @@ static PdfDocument *refPdfDocument(char *file_path) return pdf_doc; } -static void deletePdfDocument(PdfDocument *); +//********************************************************************** +// AVL sort ObjMap into ObjMapTree by object number and generation -// Called when an image has been written and its resources in image_tab are -// freed and it's not referenced anymore. +// keep the ObjMap struct small, as these are accumulated until the end -void unrefPdfDocument(char *file_path) +struct ObjMap { + Ref in; // object num/gen in orig. PDF file + int out_num; // object num after embedding (gen == 0) +}; + +static int CompObjMap(const void *pa, const void *pb, void * /*p */ ) { - PdfDocument *pdf_doc = findPdfDocument(file_path); - assert(pdf_doc != NULL); - assert(pdf_doc->occurences > 0); // aim for point landing - pdf_doc->occurences--; -#ifdef DEBUG - fprintf(stderr, "\nluatex Debug: Decrementing %s (%d)\n", - pdf_doc->file_path, pdf_doc->occurences); -#endif - if (pdf_doc->occurences == 0) { -#ifdef DEBUG - fprintf(stderr, "\nluatex Debug: Deleting %s\n", pdf_doc->file_path); -#endif - void *a = avl_delete(PdfDocumentTree, pdf_doc); - assert((PdfDocument *) a == pdf_doc); - deletePdfDocument(pdf_doc); - } + const Ref *a = &(((const ObjMap *) pa)->in); + const Ref *b = &(((const ObjMap *) pb)->in); + if (a->num > b->num) + return 1; + if (a->num < b->num) + return -1; + if (a->gen == b->gen) // most likely gen == 0 anyway + return 0; + if (a->gen < b->gen) + return -1; + return 1; } -//********************************************************************** - -// Replacement for -// Object *initDict(Dict *dict1){ initObj(objDict); dict = dict1; return this; } - -static void initDictFromDict(PdfObject & obj, Dict * dict) +static ObjMap *findObjMap(PdfDocument * pdf_doc, Ref in) { - obj->initDict(xref); - for (int i = 0, l = dict->getLength(); i < l; i++) { - Object obj1; - obj->dictAdd(copyString(dict->getKey(i)), dict->getValNF(i, &obj1)); - } + ObjMap *obj_map, tmp; + assert(pdf_doc != NULL); + if (pdf_doc->ObjMapTree == NULL) + return NULL; + tmp.in = in; + obj_map = (ObjMap *) avl_find(pdf_doc->ObjMapTree, &tmp); + return obj_map; } -static int addEncoding(GfxFont * gfont) +static void addObjMap(PdfDocument * pdf_doc, Ref in, int out_num) { - UsedEncoding *n; - n = new UsedEncoding; - n->next = encodingList; - encodingList = n; - n->font = gfont; - n->enc_objnum = pdf_new_objnum(); - return n->enc_objnum; + ObjMap *obj_map = NULL; + assert(findObjMap(pdf_doc, in) == NULL); + if (pdf_doc->ObjMapTree == NULL) + pdf_doc->ObjMapTree = avl_create(CompObjMap, NULL, &avl_xallocator); + obj_map = new ObjMap; + obj_map->in = in; + obj_map->out_num = out_num; + void **aa = avl_probe(pdf_doc->ObjMapTree, obj_map); + assert(aa != NULL); } -#define addFont(ref, fd, enc_objnum) \ - addInObj(objFont, ref, fd, enc_objnum) +// When copying the Resources of the selected page, all objects are +// copied recursively top-down. The findObjMap() function checks if an +// object has already been copied; if so, instead of copying just the +// new object number will be referenced. The ObjMapTree guarantees, +// that during the entire LuaTeX run any object from any embedded PDF +// file will end up max. once in the output PDF file. Indirect objects +// are not fetched during copying, but get a new object number from +// LuaTeX and then will be appended into a linked list. -// addFontDesc is only used to avoid writing the original FontDescriptor -// from the PDF file. - -#define addFontDesc(ref, fd) \ - addInObj(objFontDesc, ref, fd, 0) - -#define addOther(ref) \ - addInObj(objOther, ref, NULL, 0) - -static int addInObj(InObjType type, Ref ref, fd_entry * fd, integer e) +static int addInObj(PDF pdf, PdfDocument * pdf_doc, Ref ref) { - InObj *p, *q, *n = new InObj; - if (ref.num == 0) - pdftex_fail("PDF inclusion: invalid reference"); + ObjMap *obj_map; + InObj *p, *q, *n; + if (ref.num == 0) { + pdftex_fail("PDF inclusion: reference to invalid object" + " (is the included pdf broken?)"); + } + if ((obj_map = findObjMap(pdf_doc, ref)) != NULL) + return obj_map->out_num; + n = new InObj; n->ref = ref; - n->type = type; n->next = NULL; - n->fd = fd; - n->enc_objnum = e; - n->written = 0; - if (inObjList == NULL) - inObjList = n; + n->num = pdf_new_objnum(pdf); + addObjMap(pdf_doc, ref, n->num); + if (pdf_doc->inObjList == NULL) + pdf_doc->inObjList = n; else { - for (p = inObjList; p != NULL; p = p->next) { - if (p->ref.num == ref.num && p->ref.gen == ref.gen) { - delete n; - return p->num; - } - q = p; - } // it is important to add new objects at the end of the list, // because new objects are being added while the list is being // written out by writeRefs(). + for (p = pdf_doc->inObjList; p != NULL; p = p->next) + q = p; q->next = n; } - if (type == objFontDesc) - n->num = get_fd_objnum(fd); - else - n->num = pdf_new_objnum(); return n->num; } -static void copyName(char *s) -{ - pdf_puts("/"); - for (; *s != 0; s++) { - if (isdigit(*s) || isupper(*s) || islower(*s) || *s == '_' || - *s == '.' || *s == '-' || *s == '+') - pdfout(*s); - else - pdf_printf("#%.2X", *s & 0xFF); - } -} - -static int getNewObjectNumber(Ref ref) -{ - InObj *p; - if (inObjList == 0) { - pdftex_fail("No objects copied yet"); - } else { - for (p = inObjList; p != 0; p = p->next) { - if (p->ref.num == ref.num && p->ref.gen == ref.gen) { - return p->num; - } - } - pdftex_fail("Object not yet copied: %i %i", ref.num, ref.gen); - } -} - -static void copyObject(Object *); - -static void copyDictEntry(Object * obj, int i) -{ - PdfObject obj1; - copyName(obj->dictGetKey(i)); - pdf_puts(" "); - obj->dictGetValNF(i, &obj1); - copyObject(&obj1); - pdf_puts("\n"); -} - -static void copyDict(Object * obj) -{ - int i, l; - if (!obj->isDict()) - pdftex_fail("PDF inclusion: invalid dict type <%s>", - obj->getTypeName()); - for (i = 0, l = obj->dictGetLength(); i < l; ++i) - copyDictEntry(obj, i); -} - -static void copyFontDict(Object * obj, InObj * r) -{ - int i, l; - char *key; - if (!obj->isDict()) - pdftex_fail("PDF inclusion: invalid dict type <%s>", - obj->getTypeName()); - pdf_puts("<<\n"); - assert(r->type == objFont); // FontDescriptor is in fd_tree - for (i = 0, l = obj->dictGetLength(); i < l; ++i) { - key = obj->dictGetKey(i); - if (strncmp("FontDescriptor", key, strlen("FontDescriptor")) == 0 - || strncmp("BaseFont", key, strlen("BaseFont")) == 0 - || strncmp("Encoding", key, strlen("Encoding")) == 0) - continue; // skip original values - copyDictEntry(obj, i); - } - // write new FontDescriptor, BaseFont, and Encoding - pdf_printf("/FontDescriptor %d 0 R\n", (int) get_fd_objnum(r->fd)); - pdf_printf("/BaseFont %d 0 R\n", (int) get_fn_objnum(r->fd)); - pdf_printf("/Encoding %d 0 R\n", (int) r->enc_objnum); - pdf_puts(">>"); -} - -static void copyStream(Stream * str) -{ - int c; - str->reset(); - while ((c = str->getChar()) != EOF) { - pdfout(c); - pdf_last_byte = c; - } -} - -static void copyProcSet(Object * obj) -{ - int i, l; - PdfObject procset; - if (!obj->isArray()) - pdftex_fail("PDF inclusion: invalid ProcSet array type <%s>", - obj->getTypeName()); - pdf_puts("/ProcSet [ "); - for (i = 0, l = obj->arrayGetLength(); i < l; ++i) { - obj->arrayGetNF(i, &procset); - if (!procset->isName()) - pdftex_fail("PDF inclusion: invalid ProcSet entry type <%s>", - procset->getTypeName()); - copyName(procset->getName()); - pdf_puts(" "); - } - pdf_puts("]\n"); -} - -#define REPLACE_TYPE1C true - -static void copyFont(char *tag, Object * fontRef) -{ - PdfObject fontdict, subtype, basefont, fontdescRef, fontdesc, charset, - fontfile, ffsubtype, stemV; - GfxFont *gfont; - fd_entry *fd; - fm_entry *fontmap; - // Check whether the font has already been embedded before analysing it. - InObj *p; - Ref ref = fontRef->getRef(); - for (p = inObjList; p; p = p->next) { - if (p->ref.num == ref.num && p->ref.gen == ref.gen) { - copyName(tag); - pdf_printf(" %d 0 R ", (int) p->num); - return; - } - } - // Only handle included Type1 (and Type1C) fonts; anything else will be copied. - // Type1C fonts are replaced by Type1 fonts, if REPLACE_TYPE1C is true. - if (!fixed_inclusion_copy_font && fontRef->fetch(xref, &fontdict)->isDict() - && fontdict->dictLookup("Subtype", &subtype)->isName() - && !strcmp(subtype->getName(), "Type1") - && fontdict->dictLookup("BaseFont", &basefont)->isName() - && fontdict->dictLookupNF("FontDescriptor", &fontdescRef)->isRef() - && fontdescRef->fetch(xref, &fontdesc)->isDict() - && (fontdesc->dictLookup("FontFile", &fontfile)->isStream() - || (REPLACE_TYPE1C - && fontdesc->dictLookup("FontFile3", &fontfile)->isStream() - && fontfile->streamGetDict()->lookup("Subtype", - &ffsubtype)->isName() - && !strcmp(ffsubtype->getName(), "Type1C"))) - && (fontmap = lookup_fontmap(basefont->getName())) != NULL) { - // copy the value of /StemV - fontdesc->dictLookup("StemV", &stemV); - fd = epdf_create_fontdescriptor(fontmap, stemV->getInt()); - if (fontdesc->dictLookup("CharSet", &charset) && - charset->isString() && is_subsetable(fontmap)) - epdf_mark_glyphs(fd, charset->getString()->getCString()); - else - embed_whole_font(fd); - addFontDesc(fontdescRef->getRef(), fd); - copyName(tag); - gfont = GfxFont::makeFont(xref, tag, fontRef->getRef(), - fontdict->getDict()); - pdf_printf(" %d 0 R ", addFont(fontRef->getRef(), fd, - addEncoding(gfont))); - } else { - copyName(tag); - pdf_puts(" "); - copyObject(fontRef); - } -} - -static void copyFontResources(Object * obj) -{ - PdfObject fontRef; - int i, l; - if (!obj->isDict()) - pdftex_fail("PDF inclusion: invalid font resources dict type <%s>", - obj->getTypeName()); - pdf_puts("/Font << "); - for (i = 0, l = obj->dictGetLength(); i < l; ++i) { - obj->dictGetValNF(i, &fontRef); - if (fontRef->isRef()) - copyFont(obj->dictGetKey(i), &fontRef); - else - pdftex_fail("PDF inclusion: invalid font in reference type <%s>", - fontRef->getTypeName()); - } - pdf_puts(">>\n"); -} - -static void copyOtherResources(Object * obj, char *key) -{ - // copies all other resources (write_epdf handles Fonts and ProcSets), - // but gives a warning if an object is not a dictionary. - - if (!obj->isDict()) - //FIXME: Write the message only to the log file - pdftex_warn("PDF inclusion: invalid other resource which is no dict" - " (key '%s', type <%s>); copying it anyway.", - key, obj->getTypeName()); - copyName(key); - pdf_puts(" "); - copyObject(obj); -} - -// Function onverts double to string; very small and very large numbers +//********************************************************************** +// Function converts double to string; very small and very large numbers // are NOT converted to scientific notation. // n must be a number or real conforming to the implementation limits // of PDF as specified in appendix C.1 of the PDF Ref. @@ -536,165 +247,215 @@ static char *convertNumToPDF(double n) return (char *) buf; } -static void copyObject(Object * obj) +static void copyObject(PDF, PdfDocument *, Object *); + +static void copyString(PDF pdf, GString * string) { - PdfObject obj1; - int i, l, c; - Ref ref; char *p; - GString *s; - if (obj->isBool()) { - pdf_printf("%s", obj->getBool()? "true" : "false"); - } else if (obj->isInt()) { - pdf_printf("%i", obj->getInt()); - } else if (obj->isReal()) { - pdf_printf("%s", convertNumToPDF(obj->getReal())); - } else if (obj->isNum()) { - pdf_printf("%s", convertNumToPDF(obj->getNum())); - } else if (obj->isString()) { - s = obj->getString(); - p = s->getCString(); - l = s->getLength(); - if (strlen(p) == (unsigned int) l) { - pdf_puts("("); - for (; *p != 0; p++) { - c = (unsigned char) *p; - if (c == '(' || c == ')' || c == '\\') - pdf_printf("\\%c", c); - else if (c < 0x20 || c > 0x7F) - pdf_printf("\\%03o", c); - else - pdfout(c); - } - pdf_puts(")"); - } else { - pdf_puts("<"); - for (i = 0; i < l; i++) { - c = s->getChar(i) & 0xFF; - pdf_printf("%.2x", c); - } - pdf_puts(">"); - } - } else if (obj->isName()) { - copyName(obj->getName()); - } else if (obj->isNull()) { - pdf_puts("null"); - } else if (obj->isArray()) { - pdf_puts("["); - for (i = 0, l = obj->arrayGetLength(); i < l; ++i) { - obj->arrayGetNF(i, &obj1); - if (!obj1->isName()) - pdf_puts(" "); - copyObject(&obj1); + unsigned char c; + size_t i, l; + p = string->getCString(); + l = (size_t) string->getLength(); + if (strlen(p) == l) { + pdf_puts(pdf, "("); + for (; *p != 0; p++) { + c = (unsigned char) *p; + if (c == '(' || c == ')' || c == '\\') + pdf_printf(pdf, "\\%c", c); + else if (c < 0x20 || c > 0x7F) + pdf_printf(pdf, "\\%03o", (int) c); + else + pdf_out(pdf, c); } - pdf_puts("]"); - } else if (obj->isDict()) { - pdf_puts("<<\n"); - copyDict(obj); - pdf_puts(">>"); - } else if (obj->isStream()) { - initDictFromDict(obj1, obj->streamGetDict()); - obj->streamGetDict()->incRef(); - pdf_puts("<<\n"); - copyDict(&obj1); - pdf_puts(">>\n"); - pdf_puts("stream\n"); - copyStream(obj->getStream()->getUndecodedStream()); - if (pdf_last_byte != '\n') - pdf_puts("\n"); - pdf_puts("endstream"); // can't simply write pdf_end_stream() - } else if (obj->isRef()) { - ref = obj->getRef(); - if (ref.num == 0) { - pdftex_fail - ("PDF inclusion: reference to invalid object" - " (is the included pdf broken?)"); - } else - pdf_printf("%d 0 R", addOther(ref)); + pdf_puts(pdf, ")"); } else { - pdftex_fail("PDF inclusion: type <%s> cannot be copied", - obj->getTypeName()); + pdf_puts(pdf, "<"); + for (i = 0; i < l; i++) { + c = (unsigned char) string->getChar(i); + pdf_printf(pdf, "%.2x", (int) c); + } + pdf_puts(pdf, ">"); } } -static void writeRefs() +static void copyName(PDF pdf, char *s) { - InObj *r; - for (r = inObjList; r != NULL; r = r->next) { - if (!r->written) { - Object obj1; - r->written = 1; - xref->fetch(r->ref.num, r->ref.gen, &obj1); - if (r->type == objFont) { - assert(!obj1.isStream()); - zpdf_begin_obj(r->num, 2); // \pdfobjcompresslevel = 2 is for this - copyFontDict(&obj1, r); - pdf_puts("\n"); - pdf_end_obj(); - } else if (r->type != objFontDesc) { // /FontDescriptor is written via write_fontdescriptor() - if (obj1.isStream()) - zpdf_begin_obj(r->num, 0); - else - zpdf_begin_obj(r->num, 2); // \pdfobjcompresslevel = 2 is for this - copyObject(&obj1); - pdf_puts("\n"); - pdf_end_obj(); - } - obj1.free(); - } + pdf_puts(pdf, "/"); + for (; *s != 0; s++) { + if (isdigit(*s) || isupper(*s) || islower(*s) || *s == '_' || + *s == '.' || *s == '-' || *s == '+') + pdf_out(pdf, *s); + else + pdf_printf(pdf, "#%.2X", *s & 0xFF); } } -static void writeEncodings() +static void copyArray(PDF pdf, PdfDocument * pdf_doc, Array * array) { - UsedEncoding *r, *n; - char *glyphNames[256], *s; - int i; - for (r = encodingList; r != NULL; r = r->next) { - for (i = 0; i < 256; i++) { - if (r->font->isCIDFont()) { - pdftex_fail - ("PDF inclusion: CID fonts are not supported" - " (try to disable font replacement to fix this)"); - } - if ((s = ((Gfx8BitFont *) r->font)->getCharName(i)) != NULL) - glyphNames[i] = s; - else - glyphNames[i] = notdef; - } - epdf_write_enc(glyphNames, r->enc_objnum); + int i, l; + PdfObject obj1; + pdf_puts(pdf, "["); + for (i = 0, l = array->getLength(); i < l; ++i) { + array->getNF(i, &obj1); + if (!obj1->isName()) + pdf_puts(pdf, " "); + copyObject(pdf, pdf_doc, &obj1); + } + pdf_puts(pdf, "]"); +} + +static void copyDict(PDF pdf, PdfDocument * pdf_doc, Dict * dict) +{ + int i, l; + PdfObject obj1; + pdf_puts(pdf, "<<"); + for (i = 0, l = dict->getLength(); i < l; ++i) { + copyName(pdf, dict->getKey(i)); + pdf_puts(pdf, " "); + dict->getValNF(i, &obj1); + copyObject(pdf, pdf_doc, &obj1); + pdf_puts(pdf, "\n"); + } + pdf_puts(pdf, ">>"); +} + +static void copyStreamStream(PDF pdf, Stream * str) +{ + int c; + str->reset(); + while ((c = str->getChar()) != EOF) { + pdf_out(pdf, c); + pdf->last_byte = c; + } +} + +static void copyStream(PDF pdf, PdfDocument * pdf_doc, Stream * stream) +{ + copyDict(pdf, pdf_doc, stream->getDict()); + pdf_puts(pdf, "stream\n"); + copyStreamStream(pdf, stream->getUndecodedStream()); + if (pdf->last_byte != '\n') + pdf_puts(pdf, "\n"); + pdf_puts(pdf, "endstream"); // can't simply write pdf_end_stream() +} + +static void copyObject(PDF pdf, PdfDocument * pdf_doc, Object * obj) +{ + switch (obj->getType()) { + case objBool: + pdf_printf(pdf, "%s", obj->getBool()? "true" : "false"); + break; + case objInt: + pdf_printf(pdf, "%i", obj->getInt()); + break; + case objReal: + pdf_printf(pdf, "%s", convertNumToPDF(obj->getReal())); + break; + // not needed: + // GBool isNum() { return type == objInt || type == objReal; } + case objString: + copyString(pdf, obj->getString()); + break; + case objName: + copyName(pdf, obj->getName()); + break; + case objNull: + pdf_puts(pdf, "null"); + break; + case objArray: + copyArray(pdf, pdf_doc, obj->getArray()); + break; + case objDict: + copyDict(pdf, pdf_doc, obj->getDict()); + break; + case objStream: + copyStream(pdf, pdf_doc, obj->getStream()); + break; + case objRef: + pdf_printf(pdf, "%d 0 R", addInObj(pdf, pdf_doc, obj->getRef())); + break; + case objCmd: + case objError: + case objEOF: + case objNone: + pdftex_fail("PDF inclusion: type <%s> cannot be copied", + obj->getTypeName()); + break; + default: + assert(0); // xpdf doesn't have any other types } - for (r = encodingList; r != NULL; r = n) { +} + +//********************************************************************** + +static void writeRefs(PDF pdf, PdfDocument * pdf_doc) +{ + InObj *r, *n; + XRef *xref; + xref = pdf_doc->doc->getXRef(); + for (r = pdf_doc->inObjList; r != NULL;) { + PdfObject obj1; + xref->fetch(r->ref.num, r->ref.gen, &obj1); + if (obj1->isStream()) + pdf_begin_obj(pdf, r->num, 0); + else + pdf_begin_obj(pdf, r->num, 2); // \pdfobjcompresslevel = 2 is for this + copyObject(pdf, pdf_doc, &obj1); + pdf_puts(pdf, "\n"); + pdf_end_obj(pdf); n = r->next; -#ifdef POPPLER_VERSION - r->font->decRefCnt(); -#else - delete r->font; -#endif delete r; + pdf_doc->inObjList = r = n; } } -// get the pagebox according to the pagebox_spec +// get the pagebox coordinates according to the pagebox_spec -static PDFRectangle *get_pagebox(Page * page, integer pagebox_spec) +static PDFRectangle *get_pagebox(Page * page, int pagebox_spec) { - if (pagebox_spec == pdf_box_spec_media) + switch (pagebox_spec) { + case PDF_BOX_SPEC_MEDIA: return page->getMediaBox(); - else if (pagebox_spec == pdf_box_spec_crop) + break; + case PDF_BOX_SPEC_CROP: return page->getCropBox(); - else if (pagebox_spec == pdf_box_spec_bleed) + break; + case PDF_BOX_SPEC_BLEED: return page->getBleedBox(); - else if (pagebox_spec == pdf_box_spec_trim) + break; + case PDF_BOX_SPEC_TRIM: return page->getTrimBox(); - else if (pagebox_spec == pdf_box_spec_art) + break; + case PDF_BOX_SPEC_ART: return page->getArtBox(); - else + break; + default: pdftex_fail("PDF inclusion: unknown value of pagebox spec (%i)", (int) pagebox_spec); + } return page->getMediaBox(); // to make the compiler happy } +#define PDF_CHECKSUM_SIZE 32 +char *get_file_checksum(char *a) +{ + struct stat finfo; + char *ck = NULL; + if (stat(a, &finfo) == 0) { + off_t size = finfo.st_size; + time_t mtime = finfo.st_mtime; + ck = (char *) malloc(PDF_CHECKSUM_SIZE); + if (ck == NULL) + pdftex_fail("PDF inclusion: out of memory while processing '%s'", + a); + snprintf(ck, PDF_CHECKSUM_SIZE, "%llu_%llu", (unsigned long long) size, + (unsigned long long) mtime); + } else { + pdftex_fail("PDF inclusion: could not stat() file '%s'", a); + } + return ck; +} + // Reads various information about the PDF and sets it up for later inclusion. // This will fail if the PDF version of the PDF is higher than // minor_pdf_version_wanted or page_name is given and can not be found. @@ -702,47 +463,37 @@ static PDFRectangle *get_pagebox(Page * page, integer pagebox_spec) // Returns the page number. void -read_pdf_info(image_dict * idict, integer minor_pdf_version_wanted, - integer pdf_inclusion_errorlevel) +read_pdf_info(image_dict * idict, int minor_pdf_version_wanted, + int pdf_inclusion_errorlevel, img_readtype_e readtype) { PdfDocument *pdf_doc; Page *page; int rotate; + char *checksum; PDFRectangle *pagebox; -#ifdef HAVE_GETPDFMAJORVERSION - int pdf_major_version_found, pdf_minor_version_found; -#else - float pdf_version_found, pdf_version_wanted; -#endif - float xsize, ysize, xorig, yorig; + float pdf_version_found, pdf_version_wanted, xsize, ysize, xorig, yorig; assert(idict != NULL); assert(img_type(idict) == IMG_TYPE_PDF); + assert(readtype == IMG_CLOSEINBETWEEN); // only this is implemented // initialize if (isInit == gFalse) { globalParams = new GlobalParams(); globalParams->setErrQuiet(gFalse); isInit = gTrue; } + // calculate a checksum string + checksum = get_file_checksum(img_filepath(idict)); // open PDF file pdf_doc = refPdfDocument(img_filepath(idict)); + if (strncmp(pdf_doc->checksum, checksum, PDF_CHECKSUM_SIZE) != 0) { + pdftex_fail("PDF inclusion: file has changed '%s'", + img_filename(idict)); + } + free(checksum); // check PDF version // this works only for PDF 1.x -- but since any versions of PDF newer // than 1.x will not be backwards compatible to PDF 1.x, pdfTeX will // then have to changed drastically anyway. -#ifdef HAVE_GETPDFMAJORVERSION - pdf_major_version_found = pdf_doc->doc->getPDFMajorVersion(); - pdf_minor_version_found = pdf_doc->doc->getPDFMinorVersion(); - if ((pdf_major_version_found > 1) - || (pdf_minor_version_found > minor_pdf_version_wanted)) { - const char *msg = - "PDF inclusion: found PDF version <%d.%d>, but at most version <1.%d> allowed"; - if (pdf_inclusion_errorlevel > 0) { - pdftex_fail(msg, pdf_major_version_found, pdf_minor_version_found, minor_pdf_version_wanted); - } else { - pdftex_warn(msg, pdf_major_version_found, pdf_minor_version_found, minor_pdf_version_wanted); - } - } -#else pdf_version_found = pdf_doc->doc->getPDFVersion(); pdf_version_wanted = 1 + (minor_pdf_version_wanted * 0.1); if (pdf_version_found > pdf_version_wanted + 0.01) { @@ -754,7 +505,6 @@ read_pdf_info(image_dict * idict, integer minor_pdf_version_wanted, pdftex_warn(msg, pdf_version_found, pdf_version_wanted); } } -#endif img_totalpages(idict) = pdf_doc->doc->getCatalog()->getNumPages(); if (img_pagename(idict)) { // get page by name @@ -777,11 +527,10 @@ read_pdf_info(image_dict * idict, integer minor_pdf_version_wanted, pdftex_fail("PDF inclusion: required page <%i> does not exist", (int) img_pagenum(idict)); } - pdf_doc->xref = pdf_doc->doc->getXRef(); // get the required page page = pdf_doc->doc->getCatalog()->getPage(img_pagenum(idict)); - // get the pagebox (media, crop...) to use. + // get the pagebox coordinates (media, crop,...) to use. pagebox = get_pagebox(page, img_pagebox(idict)); if (pagebox->x2 > pagebox->x1) { xorig = pagebox->x1; @@ -824,67 +573,60 @@ read_pdf_info(image_dict * idict, integer minor_pdf_version_wanted, ("PDF inclusion: " "/Rotate parameter in PDF file not multiple of 90 degrees."); } - if (page->getGroup() != NULL) { - initDictFromDict(lastGroup, page->getGroup()); - if (lastGroup->dictGetLength() > 0) { - groupIsIndirect = lastGroup->isRef(); - if (groupIsIndirect) { - // FIXME: Here we already copy the object. It would be - // better to do this only after write_epdf, otherwise we - // may copy ununsed /Group objects - copyObject(&lastGroup); - epdf_lastGroupObjectNum = - getNewObjectNumber(lastGroup->getRef()); - } else { - // make the group an indirect object; copying is done later - // by write_additional_epdf_objects after write_epdf - epdf_lastGroupObjectNum = pdf_new_objnum(); - } - pdf_puts("\n"); - } - } else { - epdf_lastGroupObjectNum = 0; - } + // currently unused info whether PDF contains a /Group + if (page->getGroup() != NULL) + img_set_group(idict); + + if (readtype == IMG_CLOSEINBETWEEN) + unrefPdfDocument(img_filepath(idict)); } +//********************************************************************** // Writes the current epf_doc. -// Here the included PDF is copied, so most errors that can happen during PDF -// inclusion will arise here. +// Here the included PDF is copied, so most errors that can happen +// during PDF inclusion will arise here. -static void write_epdf1(image_dict * idict) +static void write_epdf1(PDF pdf, image_dict * idict) { + PdfDocument *pdf_doc; Page *page; - PdfObject contents, obj1, obj2; - PdfObject metadata, pieceinfo, separationInfo; - Object info; - char *key; + PdfObject info, contents, metadata, obj1; + Object *metadataNF, *resourcesNF; + char *checksum; char s[256]; int i, l; - PdfDocument *pdf_doc = (PdfDocument *) findPdfDocument(img_filepath(idict)); - assert(pdf_doc != NULL); - xref = pdf_doc->xref; - inObjList = pdf_doc->inObjList; - encodingList = NULL; + assert(idict != NULL); + // calculate a checksum string + checksum = get_file_checksum(img_filepath(idict)); + // open PDF file + pdf_doc = refPdfDocument(img_filepath(idict)); + if (strncmp(pdf_doc->checksum, checksum, PDF_CHECKSUM_SIZE) != 0) { + pdftex_fail("PDF inclusion: file has changed '%s'", + img_filename(idict)); + } + free(checksum); + (void) pdf_doc->doc->getCatalog()->getPage(img_pagenum(idict)); page = pdf_doc->doc->getCatalog()->getPage(img_pagenum(idict)); PDFRectangle *pagebox; float bbox[4]; // write the Page header - pdf_puts("/Type /XObject\n/Subtype /Form\n"); + pdf_puts(pdf, "/Type /XObject\n/Subtype /Form\n"); if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) - pdf_printf("%s\n", img_attr(idict)); - pdf_puts("/FormType 1\n"); + pdf_printf(pdf, "%s\n", img_attr(idict)); + pdf_puts(pdf, "/FormType 1\n"); // write additional information - pdf_printf("/%s.FileName (%s)\n", pdfkeyprefix, + pdf_printf(pdf, "/%s.FileName (%s)\n", pdfkeyprefix, convertStringToPDFString(pdf_doc->file_path, strlen(pdf_doc->file_path))); - pdf_printf("/%s.PageNumber %i\n", pdfkeyprefix, (int) img_pagenum(idict)); + pdf_printf(pdf, "/%s.PageNumber %i\n", pdfkeyprefix, + (int) img_pagenum(idict)); pdf_doc->doc->getDocInfoNF(&info); - if (info.isRef()) { + if (info->isRef()) { // the info dict must be indirect (PDF Ref p. 61) - pdf_printf("/%s.InfoDict ", pdfkeyprefix); - pdf_printf("%d 0 R\n", addOther(info.getRef())); + pdf_printf(pdf, "/%s.InfoDict ", pdfkeyprefix); + pdf_printf(pdf, "%d 0 R\n", addInObj(pdf, pdf_doc, info->getRef())); } if (img_is_bbox(idict)) { bbox[0] = int2bp(img_bbox(idict)[0]); @@ -892,7 +634,7 @@ static void write_epdf1(image_dict * idict) bbox[2] = int2bp(img_bbox(idict)[2]); bbox[3] = int2bp(img_bbox(idict)[3]); } else { - // get the pagebox (media, crop...) to use. + // get the pagebox coordinates (media, crop,...) to use. pagebox = get_pagebox(page, img_pagebox(idict)); bbox[0] = pagebox->x1; bbox[1] = pagebox->y1; @@ -901,77 +643,57 @@ static void write_epdf1(image_dict * idict) } sprintf(s, "/BBox [%.8f %.8f %.8f %.8f]\n", bbox[0], bbox[1], bbox[2], bbox[3]); - pdf_puts(stripzeros(s)); + pdf_puts(pdf, stripzeros(s)); // The /Matrix calculation is replaced by transforms in out_img(). - // write the page Group if it's there - if (epdf_lastGroupObjectNum > 0) { - if (page->getGroup() != NULL) { - initDictFromDict(lastGroup, page->getGroup()); - if (lastGroup->dictGetLength() > 0) { - pdf_puts("/Group "); - groupIsIndirect = lastGroup->isRef(); - pdf_printf("%d 0 R", (int) epdf_lastGroupObjectNum); - pdf_puts("\n"); - } - } + // Now all relevant parts of the /Page dictionary are copied: + + // write the /Resources dictionary + if (page->getResourceDict() == NULL) { + // Resources can be missing (files without them have been spotted + // in the wild); in which case the /Resouces of the /Page will be used. + // "This practice is not recommended". + pdftex_warn + ("PDF inclusion: /Resources missing. 'This practice is not recommended' (PDF Ref.)"); + } else { +#if 0 // TEMP, waiting for XPDF patch + resourcesNF = page->getResourcesNF(); + pdf_puts(pdf, "/Resources "); + copyObject(pdf, pdf_doc, resourcesNF); +#endif } - // write the page Metadata if it's there + // write the page /Metadata if it's there (as a stream it must be indirect) if (page->getMetadata() != NULL) { - metadata->initStream(page->getMetadata()); - pdf_puts("/Metadata "); - copyObject(&metadata); - pdf_puts("\n"); +#if 0 // TEMP, waiting for XPDF patch + metadataNF = page->getMetadataNF(); // *NF = "don't resolve indirects" + if (!metadataNF->isRef()) + pdftex_warn("PDF inclusion: /Metadata must be indirect object"); + else { + pdf_printf(pdf, "/Metadata %d 0 R", + addInObj(pdf, pdf_doc, metadataNF->getRef())); + } +#endif } - // write the page PieceInfo if it's there + // write the page /Group if it's there + if (page->getGroup() != NULL) { + pdf_puts(pdf, "/Group "); + copyDict(pdf, pdf_doc, page->getGroup()); + } + // write the page /PieceInfo if it's there if (page->getPieceInfo() != NULL) { - initDictFromDict(pieceinfo, page->getPieceInfo()); - if (pieceinfo->dictGetLength() > 0) { - pdf_puts("/PieceInfo "); - copyObject(&pieceinfo); - pdf_puts("\n"); - } + pdf_puts(pdf, "/PieceInfo "); + copyDict(pdf, pdf_doc, page->getPieceInfo()); + } + // write the page /SeparationInfo if it's there + if (page->getSeparationInfo() != NULL) { + pdf_puts(pdf, "/SeparationInfo "); + copyDict(pdf, pdf_doc, page->getSeparationInfo()); } // copy LastModified (needed when PieceInfo is there) if (page->getLastModified() != NULL) { - pdf_printf("/LastModified (%s)\n", + pdf_printf(pdf, "/LastModified (%s)\n", page->getLastModified()->getCString()); } - // write the page SeparationInfo if it's there - if (page->getSeparationInfo() != NULL) { - initDictFromDict(separationInfo, page->getSeparationInfo()); - if (separationInfo->dictGetLength() > 0) { - pdf_puts("/SeparationInfo "); - copyObject(&separationInfo); - pdf_puts("\n"); - } - } - // write the Resources dictionary - if (page->getResourceDict() == NULL) { - // Resources can be missing (files without them have been spotted - // in the wild); in which case the /Resouces of the /Page will be used. - // "This practice is not recommended". - pdftex_warn - ("PDF inclusion: /Resources missing. 'This practice is not recommended' (PDF Ref)"); - } else { - initDictFromDict(obj1, page->getResourceDict()); - page->getResourceDict()->incRef(); - if (!obj1->isDict()) - pdftex_fail("PDF inclusion: invalid resources dict type <%s>", - obj1->getTypeName()); - pdf_puts("/Resources <<\n"); - for (i = 0, l = obj1->dictGetLength(); i < l; ++i) { - obj1->dictGetVal(i, &obj2); - key = obj1->dictGetKey(i); - if (strcmp("Font", key) == 0) - copyFontResources(&obj2); - else if (strcmp("ProcSet", key) == 0) - copyProcSet(&obj2); - else - copyOtherResources(&obj2, key); - } - pdf_puts(">>\n"); - } // write the page contents page->getContents(&contents); if (contents->isStream()) { @@ -979,84 +701,108 @@ static void write_epdf1(image_dict * idict) // of \pdfcompresslevel // // pdfbeginstream(); - // copyStream(contents->getStream()); + // copyStreamStream(contents->getStream()); // pdfendstream(); // Variant B: copy stream without recompressing // - contents->streamGetDict()->lookup("F", &obj1); + contents->streamGetDict()->lookup((char *) "F", &obj1); if (!obj1->isNull()) { pdftex_fail("PDF inclusion: Unsupported external stream"); } - contents->streamGetDict()->lookup("Length", &obj1); + contents->streamGetDict()->lookup((char *) "Length", &obj1); assert(!obj1->isNull()); - pdf_puts("/Length "); - copyObject(&obj1); - pdf_puts("\n"); - contents->streamGetDict()->lookup("Filter", &obj1); + pdf_puts(pdf, "/Length "); + copyObject(pdf, pdf_doc, &obj1); + pdf_puts(pdf, "\n"); + contents->streamGetDict()->lookup((char *) "Filter", &obj1); if (!obj1->isNull()) { - pdf_puts("/Filter "); - copyObject(&obj1); - pdf_puts("\n"); - contents->streamGetDict()->lookup("DecodeParms", &obj1); + pdf_puts(pdf, "/Filter "); + copyObject(pdf, pdf_doc, &obj1); + pdf_puts(pdf, "\n"); + contents->streamGetDict()->lookup((char *) "DecodeParms", &obj1); if (!obj1->isNull()) { - pdf_puts("/DecodeParms "); - copyObject(&obj1); - pdf_puts("\n"); + pdf_puts(pdf, "/DecodeParms "); + copyObject(pdf, pdf_doc, &obj1); + pdf_puts(pdf, "\n"); } } - pdf_puts(">>\nstream\n"); - copyStream(contents->getStream()->getBaseStream()); - pdf_end_stream(); + pdf_puts(pdf, ">>\nstream\n"); + copyStreamStream(pdf, contents->getStream()->getBaseStream()); + pdf_end_stream(pdf); } else if (contents->isArray()) { - pdf_begin_stream(); + pdf_begin_stream(pdf); for (i = 0, l = contents->arrayGetLength(); i < l; ++i) { - Object contentsobj; - copyStream((contents->arrayGet(i, &contentsobj))->getStream()); - contentsobj.free(); + PdfObject contentsobj; + copyStreamStream(pdf, + (contents->arrayGet(i, &contentsobj))-> + getStream()); + if (i < (l - 1)) { + // put a space between streams to be on the safe side (streams + // should have a trailing space here, but one never knows) + pdf_puts(pdf, " "); + } } - pdf_end_stream(); + pdf_end_stream(pdf); } else { // the contents are optional, but we need to include an empty stream - pdf_begin_stream(); - pdf_end_stream(); + pdf_begin_stream(pdf); + pdf_end_stream(pdf); } // write out all indirect objects - writeRefs(); - // write out all used encodings (and delete list) - writeEncodings(); - // save object list - pdf_doc->inObjList = inObjList; - assert(xref == pdf_doc->xref); // xref should be unchanged + writeRefs(pdf, pdf_doc); } -void write_epdf(image_dict * idict) +// this relay function is needed to keep some destructor quiet (???) + +void write_epdf(PDF pdf, image_dict * idict) { - assert(idict != NULL); - write_epdf1(idict); + write_epdf1(pdf, idict); unrefPdfDocument(img_filepath(idict)); } //********************************************************************** // Deallocate a PdfDocument with all its resources -static void deletePdfDocument(PdfDocument * pdf_doc) +static void deletePdfDocumentPdfDoc(PdfDocument * pdf_doc) { - assert(pdf_doc != NULL); - // free PdfDocument's resources InObj *r, *n; + assert(pdf_doc != NULL); + // this may be probably needed for an emergency destroyPdfDocument() for (r = pdf_doc->inObjList; r != NULL; r = n) { n = r->next; delete r; } delete pdf_doc->doc; - xfree(pdf_doc->file_path); - delete pdf_doc; + pdf_doc->doc = NULL; } -static void destroyPdfDocument(void *pa, void *pb) +static void destroyPdfDocument(void *pa, void * /*pb */ ) { PdfDocument *pdf_doc = (PdfDocument *) pa; - deletePdfDocument(pdf_doc); + deletePdfDocumentPdfDoc(pdf_doc); + // TODO: delete rest of pdf_doc +} + +// Called when an image has been written and its resources in image_tab are +// freed and it's not referenced anymore. + +void unrefPdfDocument(char *file_path) +{ + PdfDocument *pdf_doc = findPdfDocument(file_path); + assert(pdf_doc != NULL); + assert(pdf_doc->occurences > 0); // aim for point landing + pdf_doc->occurences--; +#ifdef DEBUG + fprintf(stderr, "\nluatex Debug: Decrementing %s (%d)\n", + pdf_doc->file_path, pdf_doc->occurences); +#endif + if (pdf_doc->occurences == 0) { +#ifdef DEBUG + fprintf(stderr, "\nluatex Debug: Deleting %s\n", pdf_doc->file_path); +#endif + assert(pdf_doc->inObjList == NULL); // should be eaten up already + deletePdfDocumentPdfDoc(pdf_doc); + } } // Called when PDF embedding system is finalized. @@ -1071,14 +817,3 @@ void epdf_check_mem() delete globalParams; isInit = gFalse; } - -// Called after the xobject generated by write_epdf has been finished; used to -// write out objects that have been made indirect -void write_additional_epdf_objects(void) -{ - if ((epdf_lastGroupObjectNum > 0) && !groupIsIndirect) { - zpdf_begin_obj(epdf_lastGroupObjectNum, 2); - copyObject(&lastGroup); - pdf_end_obj(); - } -} diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h index 50d89c0a861..05bb85eeaa5 100644 --- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h +++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h @@ -18,22 +18,20 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: pdftoepdf.h 2331 2009-04-18 16:39:50Z hhenkel $ */ +/* $Id: pdftoepdf.h 3319 2009-12-27 20:05:36Z hhenkel $ */ #ifndef PDFTOEPDF_H # define PDFTOEPDF_H # include "image.h" -void read_pdf_info(image_dict *, integer, integer); +void read_pdf_info(image_dict *, int, int, img_readtype_e); void unrefPdfDocument(char *); -void write_additional_epdf_objects(void); -void write_epdf(image_dict *); +void write_epdf(PDF, image_dict *); void epdf_check_mem(void); /* epdf.c --- this should go in an own header file */ -extern integer get_fontfile_num(int); -extern integer get_fontname_num(int); + extern void epdf_free(void); #endif /* PDFTOEPDF_H */ diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.c b/Build/source/texk/web2c/luatexdir/image/writeimg.c deleted file mode 100644 index f570fd46996..00000000000 --- a/Build/source/texk/web2c/luatexdir/image/writeimg.c +++ /dev/null @@ -1,959 +0,0 @@ -/* writeimg.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include -#include "ptexlib.h" -#include -#include - -#include "image.h" -#include "writejpg.h" -#include "writepng.h" -#include "writejbig2.h" -#include "pdftoepdf.h" - -#include <../lua51/lua.h> -#include <../lua51/lauxlib.h> - -static const char _svn_version[] = - "$Id: writeimg.c 2448 2009-06-08 07:43:50Z taco $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/image/writeimg.c $"; - -/**********************************************************************/ -/* - Patch ImageTypeDetection 2003/02/08 by Heiko Oberdiek. - - Function "readimage" performs some basic initializations. - Then it looks at the file extension to determine the - image type and calls specific code/functions. - The main disadvantage is that standard file extensions - have to be used, otherwise pdfTeX is not able to detect - the correct image type. - - The patch now looks at the file header first regardless of - the file extension. This is implemented in function - "check_type_by_header". If this check fails, the traditional - test of standard file extension is tried, done in function - "check_type_by_extension". - - Magic headers: - - * "PNG (Portable Network Graphics) Specification", Version 1.2 - (http://www.libpng.org/pub/png): - - | 3.1. PNG file signature - | - | The first eight bytes of a PNG file always contain the following - | (decimal) values: - | - | 137 80 78 71 13 10 26 10 - - Translation to C: "\x89PNG\r\n\x1A\n" - - * "JPEG File Interchange Format", Version 1.02: - - | o you can identify a JFIF file by looking for the following - | sequence: X'FF', SOI X'FF', APP0, <2 bytes to be skipped>, - | "JFIF", X'00'. - - Function "check_type_by_header" only looks at the first two bytes: - "\xFF\xD8" - - * ISO/IEC JTC 1/SC 29/WG 1 - (ITU-T SG8) - Coding of Still Pictures - Title: 14492 FCD - Source: JBIG Committee - Project: JTC 1.29.10 - Status: Final Committee Draft - - | D.4.1, ID string - | - | This is an 8-byte sequence containing 0x97 0x4A 0x42 0x32 0x0D 0x0A - | 0x1A 0x0A. - - * "PDF Reference", third edition: - * The first line should contain "%PDF-1.0" until "%PDF-1.4" - (section 3.4.1 "File Header"). - * The "implementation notes" say: - - | 3.4.1, File Header - | 12. Acrobat viewers require only that the header appear - | somewhere within the first 1024 bytes of the file. - | 13. Acrobat viewers will also accept a header of the form - | %!PS-Adobe-N.n PDF-M.m - - The check in function "check_type_by_header" only implements - the first issue. The implementation notes are not considered. - Therefore files with garbage at start of file must have the - standard extension. - - Functions "check_type_by_header" and "check_type_by_extension": - img_type(img) is set to IMG_TYPE_NONE by new_image_dict(). - Both functions try to detect a type and set img_type(img). - Thus a value other than IMG_TYPE_NONE indicates that a - type has been found. -*/ - -#define HEADER_JPG "\xFF\xD8" -#define HEADER_PNG "\x89PNG\r\n\x1A\n" -#define HEADER_JBIG2 "\x97\x4A\x42\x32\x0D\x0A\x1A\x0A" -#define HEADER_PDF "%PDF-1." -#define MAX_HEADER (sizeof(HEADER_PNG)-1) - -integer epdf_lastGroupObjectNum; - -static void check_type_by_header(image_dict * idict) -{ - int i; - FILE *file = NULL; - char header[MAX_HEADER]; - - assert(idict != NULL); - if (img_type(idict) != IMG_TYPE_NONE) /* nothing to do */ - return; - /* read the header */ - file = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); - for (i = 0; (unsigned) i < MAX_HEADER; i++) { - header[i] = xgetc(file); - if (feof(file)) - pdftex_fail("reading image file failed"); - } - xfclose(file, img_filepath(idict)); - /* tests */ - if (strncmp(header, HEADER_JPG, sizeof(HEADER_JPG) - 1) == 0) - img_type(idict) = IMG_TYPE_JPG; - else if (strncmp(header, HEADER_PNG, sizeof(HEADER_PNG) - 1) == 0) - img_type(idict) = IMG_TYPE_PNG; - else if (strncmp(header, HEADER_JBIG2, sizeof(HEADER_JBIG2) - 1) == 0) - img_type(idict) = IMG_TYPE_JBIG2; - else if (strncmp(header, HEADER_PDF, sizeof(HEADER_PDF) - 1) == 0) - img_type(idict) = IMG_TYPE_PDF; -} - -static void check_type_by_extension(image_dict * idict) -{ - char *image_suffix; - - assert(idict != NULL); - if (img_type(idict) != IMG_TYPE_NONE) /* nothing to do */ - return; - /* tests */ - if ((image_suffix = strrchr(img_filename(idict), '.')) == 0) - img_type(idict) = IMG_TYPE_NONE; - else if (strcasecmp(image_suffix, ".png") == 0) - img_type(idict) = IMG_TYPE_PNG; - else if (strcasecmp(image_suffix, ".jpg") == 0 || - strcasecmp(image_suffix, ".jpeg") == 0) - img_type(idict) = IMG_TYPE_JPG; - else if (strcasecmp(image_suffix, ".jbig2") == 0 || - strcasecmp(image_suffix, ".jb2") == 0) - img_type(idict) = IMG_TYPE_JBIG2; - else if (strcasecmp(image_suffix, ".pdf") == 0) - img_type(idict) = IMG_TYPE_PDF; -} - -/**********************************************************************/ - -void new_img_pdfstream_struct(image_dict * p) -{ - assert(p != NULL); - assert(img_pdfstream_ptr(p) == NULL); - img_pdfstream_ptr(p) = xtalloc(1, pdf_stream_struct); - img_pdfstream_stream(p) = NULL; -} - -/**********************************************************************/ - -void init_image(image * p) -{ - assert(p != NULL); - set_wd_running(p); - set_ht_running(p); - set_dp_running(p); - img_transform(p) = 0; - img_flags(p) = 0; - img_unset_scaled(p); - img_dict(p) = NULL; - img_arrayidx(p) = -1; /* -1 = unused, used count from 0 */ - img_dictref(p) = LUA_NOREF; -} - -image *new_image(void) -{ - image *p = xtalloc(1, image); - init_image(p); - return p; -} - -void init_image_dict(image_dict * p) -{ - assert(p != NULL); - img_objnum(p) = 0; - img_index(p) = 0; - img_xsize(p) = 0; - img_ysize(p) = 0; - img_xorig(p) = 0; - img_yorig(p) = 0; - img_xres(p) = 0; - img_yres(p) = 0; - img_rotation(p) = 0; - img_colorspace(p) = 0; - img_group_ref(p) = 0; - img_totalpages(p) = 0; - img_pagenum(p) = 1; - img_pagename(p) = NULL; - img_filename(p) = NULL; - img_filepath(p) = NULL; - img_attr(p) = NULL; - img_file(p) = NULL; - img_type(p) = IMG_TYPE_NONE; - img_color(p) = 0; - img_colordepth(p) = 0; - img_pagebox(p) = PDF_BOX_SPEC_MEDIA; - img_bbox(p)[0] = 0; - img_bbox(p)[1] = 0; - img_bbox(p)[2] = 0; - img_bbox(p)[3] = 0; - img_unset_bbox(p); - img_state(p) = DICT_NEW; - img_png_ptr(p) = NULL; /* union */ -} - -image_dict *new_image_dict(void) -{ - image_dict *p = xtalloc(1, image_dict); - init_image_dict(p); - return p; -} - -static void free_dict_strings(image_dict * p) -{ - if (img_filename(p) != NULL) - xfree(img_filename(p)); - img_filename(p) = NULL; - if (img_filepath(p) != NULL) - xfree(img_filepath(p)); - img_filepath(p) = NULL; - if (img_attr(p) != NULL) - xfree(img_attr(p)); - img_attr(p) = NULL; - if (img_pagename(p) != NULL) - xfree(img_pagename(p)); - img_pagename(p) = NULL; -} - -void free_image_dict(image_dict * p) -{ - if (ini_version) - return; /* The image may be \dump{}ed to a format */ - /* called from limglib.c */ - assert(img_state(p) < DICT_REFERED); - switch (img_type(p)) { - case IMG_TYPE_PDF: - unrefPdfDocument(img_filepath(p)); - break; - case IMG_TYPE_PNG: /* assuming IMG_CLOSEINBETWEEN */ - assert(img_png_ptr(p) == NULL); - break; - case IMG_TYPE_JPG: /* assuming IMG_CLOSEINBETWEEN */ - assert(img_jpg_ptr(p) == NULL); - break; - case IMG_TYPE_JBIG2: /* todo: writejbig2.c cleanup */ - break; - case IMG_TYPE_PDFSTREAM: - if (img_pdfstream_ptr(p) != NULL) { - if (img_pdfstream_stream(p) != NULL) - xfree(img_pdfstream_stream(p)); - xfree(img_pdfstream_ptr(p)); - } - break; - case IMG_TYPE_NONE: - break; - default: - assert(0); - } - free_dict_strings(p); - assert(img_file(p) == NULL); - xfree(p); -} - -/**********************************************************************/ - -void pdf_print_resname_prefix(void) -{ - if (pdf_resname_prefix != 0) - pdf_printf(makecstring(pdf_resname_prefix)); -} - -void read_img(image_dict * idict, integer pdf_minor_version, - integer pdf_inclusion_errorlevel) -{ - char *filepath; - int callback_id; - assert(idict != NULL); - if (img_filename(idict) == NULL) - pdftex_fail("image file name missing"); - callback_id = callback_defined(find_image_file_callback); - if (img_filepath(idict) == NULL) { - if (callback_id > 0 - && run_callback(callback_id, "S->S", img_filename(idict), - &filepath)) { - if (filepath && (strlen(filepath) > 0)) - img_filepath(idict) = strdup(filepath); - } else - img_filepath(idict) = - kpse_find_file(img_filename(idict), kpse_tex_format, true); - } - if (img_filepath(idict) == NULL) - pdftex_fail("cannot find image file"); - recorder_record_input(img_filename(idict)); - /* type checks */ - check_type_by_header(idict); - check_type_by_extension(idict); - /* read image */ - switch (img_type(idict)) { - case IMG_TYPE_PDF: - read_pdf_info(idict, pdf_minor_version, pdf_inclusion_errorlevel); - img_group_ref(idict) = epdf_lastGroupObjectNum; - break; - case IMG_TYPE_PNG: - read_png_info(idict, IMG_CLOSEINBETWEEN); - break; - case IMG_TYPE_JPG: - read_jpg_info(idict, IMG_CLOSEINBETWEEN); - break; - case IMG_TYPE_JBIG2: - if (pdf_minor_version < 4) { - pdftex_fail - ("JBIG2 images only possible with at least PDF 1.4; you are generating PDF 1.%i", - (int) pdf_minor_version); - } - read_jbig2_info(idict); - break; - default: - pdftex_fail("internal error: unknown image type (2)"); - } - cur_file_name = NULL; - if (img_state(idict) < DICT_FILESCANNED) - img_state(idict) = DICT_FILESCANNED; -} - -// Within scale_img() only image width and height matter; -// the offsets and positioning are not interesting here. -// But one needs rotation info to swap width and height. -// img_rotation() comes from the optional /Rotate key in the PDF file. - -void scale_img(image * img) -{ - integer x, y, xr, yr, tmp; /* size and resolution of image */ - scaled w = 0, h = 0; /* indeed size corresponds to image resolution */ - integer default_res; - image_dict *idict; - assert(img != NULL); - idict = img_dict(img); - assert(idict != NULL); - if ((img_type(idict) == IMG_TYPE_PDF - || img_type(idict) == IMG_TYPE_PDFSTREAM) && img_is_bbox(idict)) { - x = img_xsize(idict) = img_bbox(idict)[2] - img_bbox(idict)[0]; /* dimensions from image.bbox */ - y = img_ysize(idict) = img_bbox(idict)[3] - img_bbox(idict)[1]; - img_xorig(idict) = img_bbox(idict)[0]; - img_yorig(idict) = img_bbox(idict)[1]; - } else { - x = img_xsize(idict); /* dimensions, resolutions from image file */ - y = img_ysize(idict); - } - xr = img_xres(idict); - yr = img_yres(idict); - if (x <= 0 || y <= 0 || xr < 0 || yr < 0) - pdftex_fail("ext1: invalid image dimensions"); - if (xr > 65535 || yr > 65535) { - xr = 0; - yr = 0; - pdftex_warn("ext1: too large image resolution ignored"); - } - if (((img_transform(img) - img_rotation(idict)) & 1) == 1) { - tmp = x; - x = y; - y = tmp; - tmp = xr; - xr = yr; - yr = tmp; - } - if (img_type(idict) == IMG_TYPE_PDF - || img_type(idict) == IMG_TYPE_PDFSTREAM) { - w = x; - h = y; - } else { - default_res = fix_int(get_pdf_image_resolution(), 0, 65535); - if (default_res > 0 && (xr == 0 || yr == 0)) { - xr = default_res; - yr = default_res; - } - if (is_wd_running(img) && is_ht_running(img)) { - if (xr > 0 && yr > 0) { - w = ext_xn_over_d(one_hundred_inch, x, 100 * xr); - h = ext_xn_over_d(one_hundred_inch, y, 100 * yr); - } else { - w = ext_xn_over_d(one_hundred_inch, x, 7200); - h = ext_xn_over_d(one_hundred_inch, y, 7200); - } - } - } - if (is_wd_running(img) && is_ht_running(img) && is_dp_running(img)) { - img_width(img) = w; - img_height(img) = h; - img_depth(img) = 0; - } else if (is_wd_running(img)) { - /* image depth or height is explicitly specified */ - if (is_ht_running(img)) { - /* image depth is explicitly specified */ - img_width(img) = ext_xn_over_d(h, x, y); - img_height(img) = h - img_depth(img); - } else if (is_dp_running(img)) { - /* image height is explicitly specified */ - img_width(img) = ext_xn_over_d(img_height(img), x, y); - img_depth(img) = 0; - } else { - /* both image depth and height are explicitly specified */ - img_width(img) = - ext_xn_over_d(img_height(img) + img_depth(img), x, y); - } - } else { - /* image width is explicitly specified */ - if (is_ht_running(img) && is_dp_running(img)) { - /* both image depth and height are not specified */ - img_height(img) = ext_xn_over_d(img_width(img), y, x); - img_depth(img) = 0; - } - /* image depth is explicitly specified */ - else if (is_ht_running(img)) { - img_height(img) = - ext_xn_over_d(img_width(img), y, x) - img_depth(img); - } - /* image height is explicitly specified */ - else if (is_dp_running(img)) { - img_depth(img) = 0; - } - /* else both image depth and height are explicitly specified */ - } - img_set_scaled(img); -} - -static void out_img(image * img, pdfstructure * p, scaledpos * pos) -{ - float a[6]; /* transformation matrix */ - float xoff, yoff, tmp; - int r; /* number of digits after the decimal point */ - int k; - scaled wd, ht, dp; - scaledpos tmppos; - pdffloat cm[6]; - image_dict *idict; - integer groupref; /* added from web for 1.40.8 */ - assert(img != 0); - idict = img_dict(img); - assert(idict != 0); - wd = img_width(img); - ht = img_height(img); - dp = img_depth(img); - a[0] = a[3] = 1.0e6; - a[1] = a[2] = 0; - if (img_type(idict) == IMG_TYPE_PDF - || img_type(idict) == IMG_TYPE_PDFSTREAM) { - a[0] /= img_xsize(idict); - a[3] /= img_ysize(idict); - xoff = (float) img_xorig(idict) / img_xsize(idict); - yoff = (float) img_yorig(idict) / img_ysize(idict); - r = 6; - } else { - /* added from web for 1.40.8 */ - if (img_type(idict) == IMG_TYPE_PNG) { - groupref = img_group_ref(idict); - if ((groupref > 0) && (pdf_page_group_val < 1)) - pdf_page_group_val = groupref; - } - /* /added from web */ - a[0] /= one_hundred_bp; - a[3] = a[0]; - xoff = yoff = 0; - r = 4; - } - if ((img_transform(img) & 7) > 3) { // mirror cases - a[0] *= -1; - xoff *= -1; - } - switch ((img_transform(img) + img_rotation(idict)) & 3) { - case 0: /* no transform */ - break; - case 1: /* rot. 90 deg. (counterclockwise) */ - a[1] = a[0]; - a[2] = -a[3]; - a[3] = a[0] = 0; - tmp = yoff; - yoff = xoff; - xoff = -tmp; - break; - case 2: /* rot. 180 deg. (counterclockwise) */ - a[0] *= -1; - a[3] *= -1; - xoff *= -1; - yoff *= -1; - break; - case 3: /* rot. 270 deg. (counterclockwise) */ - a[1] = -a[0]; - a[2] = a[3]; - a[3] = a[0] = 0; - tmp = yoff; - yoff = -xoff; - xoff = tmp; - break; - default:; - } - xoff *= wd; - yoff *= ht + dp; - a[0] *= wd; - a[1] *= ht + dp; - a[2] *= wd; - a[3] *= ht + dp; - a[4] = pos->h - xoff; - a[5] = pos->v - yoff; - k = img_transform(img) + img_rotation(idict); - if ((img_transform(img) & 7) > 3) - k++; - switch (k & 3) { - case 0: /* no transform */ - break; - case 1: /* rot. 90 deg. (counterclockwise) */ - a[4] += wd; - break; - case 2: /* rot. 180 deg. */ - a[4] += wd; - a[5] += ht + dp; - break; - case 3: /* rot. 270 deg. */ - a[5] += ht + dp; - break; - default:; - } - /* the following is a kludge, TODO: use pdfpage.c functions */ - setpdffloat(cm[0], round(a[0]), r); - setpdffloat(cm[1], round(a[1]), r); - setpdffloat(cm[2], round(a[2]), r); - setpdffloat(cm[3], round(a[3]), r); - tmppos.h = round(a[4]); - tmppos.v = round(a[5]); - (void) calc_pdfpos(p, &tmppos); - cm[4] = p->cm[4]; - cm[5] = p->cm[5]; - pdf_goto_pagemode(); - if (pdf_page_group_val < 1) - pdf_page_group_val = img_group_ref(idict); /* added from web for 1.40.8 */ - pdf_printf("q\n"); - pdf_print_cm(cm); - pdf_printf("/Im"); - pdf_print_int(img_index(idict)); - pdf_print_resname_prefix(); - pdf_printf(" Do\nQ\n"); - if (img_state(idict) < DICT_OUTIMG) - img_state(idict) = DICT_OUTIMG; -} - -void write_img(image_dict * idict) -{ - assert(idict != NULL); - if (img_state(idict) < DICT_WRITTEN) { - if (tracefilenames) - tex_printf(" <%s", img_filepath(idict)); - switch (img_type(idict)) { - case IMG_TYPE_PNG: - write_png(idict); - break; - case IMG_TYPE_JPG: - write_jpg(idict); - break; - case IMG_TYPE_JBIG2: - write_jbig2(idict); - break; - case IMG_TYPE_PDF: - write_epdf(idict); - epdf_lastGroupObjectNum = img_group_ref(idict); - break; - case IMG_TYPE_PDFSTREAM: - write_pdfstream(idict); - break; - default: - pdftex_fail("internal error: unknown image type (1)"); - } - if (tracefilenames) - tex_printf(">"); - if (img_type(idict) == IMG_TYPE_PDF) { - write_additional_epdf_objects(); - } else { - if (img_type(idict) == IMG_TYPE_PNG) { - write_additional_png_objects(); - } - } - } - if (img_state(idict) < DICT_WRITTEN) - img_state(idict) = DICT_WRITTEN; -} - -/**********************************************************************/ - -void check_pdfstream_dict(image_dict * idict) -{ - if (!img_is_bbox(idict)) - pdftex_fail("image.stream: no bbox given"); - if (img_state(idict) < DICT_FILESCANNED) - img_state(idict) = DICT_FILESCANNED; -} - -void write_pdfstream(image_dict * idict) -{ - char s[256]; - assert(img_pdfstream_ptr(idict) != NULL); - assert(img_is_bbox(idict)); - pdf_puts("/Type /XObject\n/Subtype /Form\n"); - if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) - pdf_printf("%s\n", img_attr(idict)); - pdf_puts("/FormType 1\n"); - sprintf(s, "/BBox [%.8f %.8f %.8f %.8f]\n", int2bp(img_bbox(idict)[0]), - int2bp(img_bbox(idict)[1]), int2bp(img_bbox(idict)[2]), - int2bp(img_bbox(idict)[3])); - pdf_printf(stripzeros(s)); - pdf_begin_stream(); - if (img_pdfstream_stream(idict) != NULL) - pdf_puts(img_pdfstream_stream(idict)); - pdf_end_stream(); -} - -/**********************************************************************/ - -typedef image *img_entry; -/* define img_ptr, img_array, & img_limit */ -/* avoid use of size_t */ -img_entry *img_ptr, *img_array = NULL; -size_t img_limit; - -integer img_to_array(image * img) -{ - assert(img != NULL); - alloc_array(img, 1, SMALL_BUF_SIZE); - *img_ptr = img; - return img_ptr++ - img_array; /* now img is read-only */ -} - -/**********************************************************************/ - -/* To allow the use of \pdfrefximage inside saved boxes in -ini mode, - * the information in the array has to be (un)dumped with the format. - * The next two routines take care of that. - * - * Most of the work involved in setting up the images is simply - * executed again. This solves the many possible errors resulting from - * the split in two separate runs. - - * There was only one problem remaining: The pdfversion and - * pdfinclusionerrorlevel can have changed inbetween the call to - * readimage() and dump time. That is why they are passed as arguments - * to undumpimagemeta once more. - */ - -/* some of the dumped values are really type int, not integer, - * but since the macro falls back to generic_dump anyway, that - * does not matter. - */ - -#define dumpinteger generic_dump -#define undumpinteger generic_undump - -/* (un)dumping a string means dumping the allocation size, followed - * by the bytes. The trailing \0 is dumped as well, because that - * makes the code simpler. - */ - -#define dumpcharptr(a) \ - do { \ - integer x; \ - if (a!=NULL) { \ - x = strlen(a)+1; \ - dumpinteger(x); dump_things(*a, x); \ - } else { \ - x = 0; dumpinteger(x); \ - } \ - } while (0) - -#define undumpcharptr(s) \ - do { \ - integer x; \ - char *a; \ - undumpinteger (x); \ - if (x>0) { \ - a = malloc(x); \ - undump_things(*a,x); \ - s = a ; \ - } else { s = NULL; } \ - } while (0) - -void dumpimagemeta(void) -{ - int cur_image, i; - image *img; - image_dict *idict; - - dumpinteger(img_limit); - cur_image = (img_ptr - img_array); - dumpinteger(cur_image); - - for (i = 0; i < cur_image; i++) { - img = img_array[i]; - assert(img != NULL); - idict = img_dict(img); - dumpcharptr(img_filename(idict)); - dumpinteger(img_type(idict)); - dumpinteger(img_color(idict)); - dumpinteger(img_width(img)); - dumpinteger(img_height(img)); - dumpinteger(img_xres(idict)); - dumpinteger(img_yres(idict)); - dumpinteger(img_totalpages(idict)); - dumpinteger(img_colorspace(idict)); - dumpinteger(img_group_ref(idict)); - - /* the image_struct is not dumped at all, except for a few - variables that are needed to restore the contents */ - - if (img_type(idict) == IMG_TYPE_PDF) { - dumpinteger(img_pagebox(idict)); - dumpinteger(img_pagenum(idict)); - } else if (img_type(idict) == IMG_TYPE_JBIG2) { - dumpinteger(img_pagenum(idict)); - } - - } -} - -void undumpimagemeta(integer pdfversion, integer pdfinclusionerrorlevel) -{ - int cur_image, i; - image *img; - image_dict *idict; - - undumpinteger(img_limit); - - img_array = xtalloc(img_limit, img_entry); - undumpinteger(cur_image); - img_ptr = img_array + cur_image; - - for (i = 0; i < cur_image; i++) { - img = new_image(); - assert(img_arrayidx(img) == -1); - img_arrayidx(img) = img_to_array(img); - idict = img_dict(img) = new_image_dict(); - assert(idict != NULL); - undumpcharptr(img_filename(idict)); - undumpinteger(img_type(idict)); - undumpinteger(img_color(idict)); - undumpinteger(img_width(img)); - undumpinteger(img_height(img)); - undumpinteger(img_xres(idict)); - undumpinteger(img_yres(idict)); - undumpinteger(img_totalpages(idict)); - undumpinteger(img_colorspace(idict)); - undumpinteger(img_group_ref(idict)); - - switch (img_type(idict)) { - case IMG_TYPE_PDF: - undumpinteger(img_pagebox(idict)); - undumpinteger(img_pagenum(idict)); - break; - case IMG_TYPE_PNG: - break; - case IMG_TYPE_JPG: - break; - case IMG_TYPE_JBIG2: - if (pdfversion < 4) { - pdftex_fail - ("JBIG2 images only possible with at least PDF 1.4; you are generating PDF 1.%i", - (int) pdfversion); - } - undumpinteger(img_pagenum(idict)); - break; - default: - pdftex_fail("unknown type of image"); - } - read_img(idict, pdfversion, pdfinclusionerrorlevel); - } -} - -/**********************************************************************/ -/* stuff to be accessible from TeX */ - -integer read_image(integer objnum, integer index, str_number filename, - integer page_num, str_number page_name, str_number attr, - integer colorspace, integer page_box, - integer pdf_minor_version, integer pdf_inclusion_errorlevel) -{ - image_dict *idict; - image *a = new_image(); - assert(img_arrayidx(a) == -1); - img_arrayidx(a) = img_to_array(a); - idict = img_dict(a) = new_image_dict(); - assert(idict != NULL); - img_objnum(idict) = objnum; - img_index(idict) = index; - /* img_xsize, img_ysize, img_xres, img_yres set by read_img() */ - img_colorspace(idict) = colorspace; - img_pagenum(idict) = page_num; - /* img_totalpages set by read_img() */ - if (page_name != 0) - img_pagename(idict) = xstrdup(makecstring(page_name)); - cur_file_name = makecfilename(filename); - assert(cur_file_name != NULL); - img_filename(idict) = xstrdup(cur_file_name); - if (attr != 0) - img_attr(idict) = xstrdup(makecstring(attr)); - img_pagebox(idict) = page_box; - read_img(idict, pdf_minor_version, pdf_inclusion_errorlevel); - img_unset_scaled(a); - return img_arrayidx(a); -} - -void set_image_dimensions(integer ref, integer wd, integer ht, integer dp) -{ - image *a = img_array[ref]; - img_width(a) = wd; - img_height(a) = ht; - img_depth(a) = dp; -} - -void scale_image(integer ref) -{ - scale_img(img_array[ref]); -} - -void out_image(integer ref, scaled hpos, scaled vpos) -{ - image *a = img_array[ref]; - scaledpos pos; - pos.h = hpos; - pos.v = vpos; - out_img(a, pstruct, &pos); -} - -void write_image(integer ref) -{ - write_img(img_dict(img_array[ref])); -} - -integer image_pages(integer ref) -{ - return img_totalpages(img_dict(img_array[ref])); -} - -integer image_colordepth(integer ref) -{ - return img_colordepth(img_dict(img_array[ref])); -} - -#if 0 /* unused */ -static integer image_group_ref(integer ref) -{ - return img_group_ref(img_dict(img_array[ref])); -} -#endif - -/* The following five functions are for \pdfximagebbox */ - -integer epdf_xsize(integer ref) -{ - return img_xsize(img_dict(img_array[ref])); -} - -integer epdf_ysize(integer ref) -{ - return img_ysize(img_dict(img_array[ref])); -} - -integer epdf_orig_x(integer ref) -{ - return img_xorig(img_dict(img_array[ref])); -} - -integer epdf_orig_y(integer ref) -{ - return img_yorig(img_dict(img_array[ref])); -} - -boolean is_pdf_image(integer ref) -{ - return img_type(img_dict(img_array[ref])) == IMG_TYPE_PDF; -} - -boolean is_png_image(integer ref) -{ - return img_type(img_dict(img_array[ref])) == IMG_TYPE_PNG; -} - -integer image_objnum(integer ref) -{ - return img_objnum(img_dict(img_array[ref])); -} - -integer image_index(integer ref) -{ - return img_index(img_dict(img_array[ref])); -} - -integer image_width(integer ref) -{ - return img_width(img_array[ref]); -} - -integer image_height(integer ref) -{ - return img_height(img_array[ref]); -} - -integer image_depth(integer ref) -{ - return img_depth(img_array[ref]); -} - -void update_image_procset(integer ref) -{ - pdf_image_procset |= img_color(img_dict(img_array[ref])); -} - -boolean check_image_b(integer procset) -{ - return procset & IMAGE_COLOR_B; -} - -boolean check_image_c(integer procset) -{ - return procset & IMAGE_COLOR_C; -} - -boolean check_image_i(integer procset) -{ - return procset & IMAGE_COLOR_I; -} diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.h b/Build/source/texk/web2c/luatexdir/image/writeimg.h index bee82acaa97..66ef946d842 100644 --- a/Build/source/texk/web2c/luatexdir/image/writeimg.h +++ b/Build/source/texk/web2c/luatexdir/image/writeimg.h @@ -18,50 +18,35 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: writeimg.h 2448 2009-06-08 07:43:50Z taco $ */ +/* $Id: writeimg.h 3388 2010-01-26 10:59:04Z taco $ */ #ifndef WRITEIMG_H # define WRITEIMG_H +# include "dvi/dvigen.h" /* for scaled_whd only */ # include "image.h" +# include "pdf/pdfpage.h" -boolean check_image_b(integer); -boolean check_image_c(integer); -boolean check_image_i(integer); -boolean is_pdf_image(integer); -boolean is_png_image(integer); -image_dict *new_image_dict(void); +typedef image_dict *idict_entry; +idict_entry *idict_array; + +void new_img_pdfstream_struct(image_dict *); image *new_image(void); -integer epdf_orig_x(integer i); -integer epdf_orig_y(integer i); -integer epdf_xsize(integer i); -integer epdf_ysize(integer i); -integer image_colordepth(integer img); -integer image_depth(integer); -integer image_height(integer); -integer image_index(integer); -integer image_objnum(integer); -integer image_pages(integer); -integer image_width(integer); -integer img_to_array(image *); -integer read_image(integer, integer, str_number, integer, str_number, - str_number, integer, integer, integer, integer); +/*void init_image_dict(image_dict *);*/ +image_dict *new_image_dict(void); +void free_image_dict(image_dict * p); +void read_img(PDF, image_dict *, int, int); +void scan_pdfximage(PDF pdf); +void scan_pdfrefximage(PDF pdf); +scaled_whd tex_scale(scaled_whd nat, scaled_whd tex); +scaled_whd scale_img(image_dict *, scaled_whd, int); +void write_img(PDF, image_dict *); +void pdf_write_image(PDF pdf, int n); void check_pdfstream_dict(image_dict *); +void write_pdfstream(PDF, image_dict *); +void idict_to_array(image_dict *); void dumpimagemeta(void); -void free_image_dict(image_dict * p); -void init_image_dict(image_dict *); -void init_image(image *); -void new_img_pdfstream_struct(image_dict *); -void out_image(integer, scaled, scaled); -void pdf_print_resname_prefix(void); -void read_img(image_dict *, integer, integer); -void scale_image(integer); -void scale_img(image *); -void set_image_dimensions(integer, integer, integer, integer); -void undumpimagemeta(integer, integer); -void update_image_procset(integer); -void write_image(integer); -void write_img(image_dict *); -void write_pdfstream(image_dict *); +void undumpimagemeta(PDF, int, int); +scaled_whd scan_alt_rule(void); #endif /* WRITEIMG_H */ diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.w b/Build/source/texk/web2c/luatexdir/image/writeimg.w new file mode 100644 index 00000000000..a6b03ee4290 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/image/writeimg.w @@ -0,0 +1,823 @@ +% writeimg.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@* Image inclusion. + +@ @c +static const char _svn_version[] = + "$Id: writeimg.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/image/writeimg.w $"; + +#include +#include "ptexlib.h" +#include +#include + +@ @c +#include "image/image.h" +#include "image/writejpg.h" +#include "image/writepng.h" +#include "image/writejbig2.h" + +#include "lua51/lua.h" /* for |LUA_NOREF| */ +#include "lua51/lauxlib.h" + +@ @c +#define pdf_image_resolution int_par(pdf_image_resolution_code) +#define pdf_pagebox int_par(pdf_pagebox_code) + +@* Patch ImageTypeDetection 2003/02/08 by Heiko Oberdiek. + + Function |readimage| performs some basic initializations. + Then it looks at the file extension to determine the + image type and calls specific code/functions. + + The main disadvantage is that standard file extensions + have to be used, otherwise pdfTeX is not able to detect + the correct image type. + + The patch now looks at the file header first regardless of + the file extension. This is implemented in function + |check_type_by_header|. If this check fails, the traditional + test of standard file extension is tried, done in function + |check_type_by_extension|. + + Magic headers: + + * "PNG (Portable Network Graphics) Specification", Version 1.2 + (http://www.libpng.org/pub/png): + + 3.1. PNG file signature + + The first eight bytes of a PNG file always contain the following + (decimal) values: + + 137 80 78 71 13 10 26 10 + + Translation to C: |"\x89PNG\r\n\x1A\n"| + + * "JPEG File Interchange Format", Version 1.02: + + o you can identify a JFIF file by looking for the following + sequence: X'FF', SOI X'FF', APP0, <2 bytes to be skipped>, + "JFIF", X'00'. + + Function |check_type_by_header| only looks at the first two bytes: + |"\xFF\xD8"| + + * ISO/IEC JTC 1/SC 29/WG 1 + (ITU-T SG8) + Coding of Still Pictures + Title: 14492 FCD + Source: JBIG Committee + Project: JTC 1.29.10 + Status: Final Committee Draft + + D.4.1, ID string + + This is an 8-byte sequence containing 0x97 0x4A 0x42 0x32 0x0D 0x0A + 0x1A 0x0A. + + * "PDF Reference", third edition: + + * The first line should contain "\%PDF-1.0" until "\%PDF-1.4" + (section 3.4.1 "File Header"). + * The "implementation notes" say: + + 3.4.1, File Header + 12. Acrobat viewers require only that the header appear + somewhere within the first 1024 bytes of the file. + 13. Acrobat viewers will also accept a header of the form + \%!PS-Adobe-N.n PDF-M.m + + The check in function |check_type_by_header| only implements + the first issue. The implementation notes are not considered. + Therefore files with garbage at start of file must have the + standard extension. + + Functions |check_type_by_header| and |check_type_by_extension|: + |img_type(img)| is set to |IMG_TYPE_NONE| by |new_image_dict()|. + Both functions try to detect a type and set |img_type(img)|. + Thus a value other than |IMG_TYPE_NONE| indicates that a + type has been found. + +@c +#define HEADER_JPG "\xFF\xD8" +#define HEADER_PNG "\x89PNG\r\n\x1A\n" +#define HEADER_JBIG2 "\x97\x4A\x42\x32\x0D\x0A\x1A\x0A" +#define HEADER_PDF "%PDF-1." +#define MAX_HEADER (sizeof(HEADER_PNG)-1) + +static void check_type_by_header(image_dict * idict) +{ + int i; + FILE *file = NULL; + char header[MAX_HEADER]; + + assert(idict != NULL); + if (img_type(idict) != IMG_TYPE_NONE) /* nothing to do */ + return; + /* read the header */ + file = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); + for (i = 0; (unsigned) i < MAX_HEADER; i++) { + header[i] = (char) xgetc(file); + if (feof(file)) + pdftex_fail("reading image file failed"); + } + xfclose(file, img_filepath(idict)); + /* tests */ + if (strncmp(header, HEADER_JPG, sizeof(HEADER_JPG) - 1) == 0) + img_type(idict) = IMG_TYPE_JPG; + else if (strncmp(header, HEADER_PNG, sizeof(HEADER_PNG) - 1) == 0) + img_type(idict) = IMG_TYPE_PNG; + else if (strncmp(header, HEADER_JBIG2, sizeof(HEADER_JBIG2) - 1) == 0) + img_type(idict) = IMG_TYPE_JBIG2; + else if (strncmp(header, HEADER_PDF, sizeof(HEADER_PDF) - 1) == 0) + img_type(idict) = IMG_TYPE_PDF; +} + +@ @c +static void check_type_by_extension(image_dict * idict) +{ + char *image_suffix; + + assert(idict != NULL); + if (img_type(idict) != IMG_TYPE_NONE) /* nothing to do */ + return; + /* tests */ + if ((image_suffix = strrchr(img_filename(idict), '.')) == 0) + img_type(idict) = IMG_TYPE_NONE; + else if (strcasecmp(image_suffix, ".png") == 0) + img_type(idict) = IMG_TYPE_PNG; + else if (strcasecmp(image_suffix, ".jpg") == 0 || + strcasecmp(image_suffix, ".jpeg") == 0) + img_type(idict) = IMG_TYPE_JPG; + else if (strcasecmp(image_suffix, ".jbig2") == 0 || + strcasecmp(image_suffix, ".jb2") == 0) + img_type(idict) = IMG_TYPE_JBIG2; + else if (strcasecmp(image_suffix, ".pdf") == 0) + img_type(idict) = IMG_TYPE_PDF; +} + +@ @c +void new_img_pdfstream_struct(image_dict * p) +{ + assert(p != NULL); + assert(img_pdfstream_ptr(p) == NULL); + img_pdfstream_ptr(p) = xtalloc(1, pdf_stream_struct); + img_pdfstream_stream(p) = NULL; +} + +@ @c +static void init_image(image * p) +{ + assert(p != NULL); + set_wd_running(p); + set_ht_running(p); + set_dp_running(p); + img_transform(p) = 0; + img_dict(p) = NULL; + img_dictref(p) = LUA_NOREF; +} + +@ @c +image *new_image(void) +{ + image *p = xtalloc(1, image); + init_image(p); + return p; +} + +@ @c +static void init_image_dict(image_dict * p) +{ + assert(p != NULL); + memset(p, 0, sizeof(image_dict)); + set_wd_running(p); + set_ht_running(p); + set_dp_running(p); + img_transform(p) = 0; + img_pagenum(p) = 1; + img_type(p) = IMG_TYPE_NONE; + img_pagebox(p) = PDF_BOX_SPEC_MEDIA; + img_unset_bbox(p); + img_unset_group(p); + img_state(p) = DICT_NEW; + img_index(p) = -1; /* -1 = unused, used count from 0 */ +} + +@ @c +image_dict *new_image_dict(void) +{ + image_dict *p = xtalloc(1, image_dict); + init_image_dict(p); + return p; +} + +@ @c +static void free_dict_strings(image_dict * p) +{ + xfree(img_filename(p)); + xfree(img_filepath(p)); + xfree(img_attr(p)); + xfree(img_pagename(p)); +} + +@ @c +void free_image_dict(image_dict * p) +{ + if (ini_version) + return; /* The image may be \.{\\dump}ed to a format */ + /* called from limglib.c */ + assert(img_state(p) < DICT_REFERED); + switch (img_type(p)) { + case IMG_TYPE_PDF: + unrefPdfDocument(img_filepath(p)); + break; + case IMG_TYPE_PNG: /* assuming |IMG_CLOSEINBETWEEN| */ + assert(img_png_ptr(p) == NULL); + break; + case IMG_TYPE_JPG: /* assuming |IMG_CLOSEINBETWEEN| */ + assert(img_jpg_ptr(p) == NULL); + break; + case IMG_TYPE_JBIG2: /* todo: writejbig2.w cleanup */ + break; + case IMG_TYPE_PDFSTREAM: + if (img_pdfstream_ptr(p) != NULL) { + xfree(img_pdfstream_stream(p)); + xfree(img_pdfstream_ptr(p)); + } + break; + case IMG_TYPE_NONE: + break; + default: + assert(0); + } + free_dict_strings(p); + assert(img_file(p) == NULL); + xfree(p); +} + +@ @c +void read_img(PDF pdf, + image_dict * idict, int minor_version, int inclusion_errorlevel) +{ + char *filepath; + int callback_id; + assert(idict != NULL); + if (img_filename(idict) == NULL) + pdftex_fail("image file name missing"); + callback_id = callback_defined(find_image_file_callback); + if (img_filepath(idict) == NULL) { + if (callback_id > 0 + && run_callback(callback_id, "S->S", img_filename(idict), + &filepath)) { + if (filepath && (strlen(filepath) > 0)) + img_filepath(idict) = strdup(filepath); + } else + img_filepath(idict) = + kpse_find_file(img_filename(idict), kpse_tex_format, true); + if (img_filepath(idict) == NULL) + pdftex_fail("cannot find image file"); + } + recorder_record_input(img_filename(idict)); + /* type checks */ + check_type_by_header(idict); + check_type_by_extension(idict); + /* read image */ + switch (img_type(idict)) { + case IMG_TYPE_PDF: + assert(pdf != NULL); /* TODO! */ + read_pdf_info(idict, minor_version, inclusion_errorlevel, + IMG_CLOSEINBETWEEN); + break; + case IMG_TYPE_PNG: + read_png_info(pdf, idict, IMG_CLOSEINBETWEEN); + break; + case IMG_TYPE_JPG: + read_jpg_info(pdf, idict, IMG_CLOSEINBETWEEN); + break; + case IMG_TYPE_JBIG2: + if (minor_version < 4) { + pdftex_fail + ("JBIG2 images only possible with at least PDF 1.4; you are generating PDF 1.%i", + (int) minor_version); + } + read_jbig2_info(idict); + break; + default: + pdftex_fail("internal error: unknown image type (2)"); + } + cur_file_name = NULL; + if (img_state(idict) < DICT_FILESCANNED) + img_state(idict) = DICT_FILESCANNED; +} + +@ @c +static image_dict *read_image(PDF pdf, char *file_name, int page_num, + char *page_name, int colorspace, + int page_box, int minor_version, + int inclusion_errorlevel) +{ + image *a = new_image(); + image_dict *idict = img_dict(a) = new_image_dict(); + incr(pdf->ximage_count); + pdf_create_obj(pdf, obj_type_ximage, pdf->ximage_count); + img_objnum(idict) = pdf->obj_ptr; + img_index(idict) = pdf->ximage_count; + set_obj_data_ptr(pdf, img_objnum(idict), img_index(idict)); + idict_to_array(idict); + img_colorspace(idict) = colorspace; + img_pagenum(idict) = page_num; + img_pagename(idict) = page_name; + assert(file_name != NULL); + cur_file_name = file_name; + img_filename(idict) = file_name; + img_pagebox(idict) = page_box; + read_img(pdf, idict, minor_version, inclusion_errorlevel); + return idict; +} + +@ scans PDF pagebox specification +@c +static pdfboxspec_e scan_pdf_box_spec(void) +{ + if (scan_keyword("mediabox")) + return PDF_BOX_SPEC_MEDIA; + else if (scan_keyword("cropbox")) + return PDF_BOX_SPEC_CROP; + else if (scan_keyword("bleedbox")) + return PDF_BOX_SPEC_BLEED; + else if (scan_keyword("trimbox")) + return PDF_BOX_SPEC_TRIM; + else if (scan_keyword("artbox")) + return PDF_BOX_SPEC_ART; + return PDF_BOX_SPEC_NONE; +} + +@ @c +void scan_pdfximage(PDF pdf) +{ + scaled_whd alt_rule; + image_dict *idict; + int transform = 0, page = 1, pagebox, colorspace = 0; + char *named = NULL, *attr = NULL, *file_name = NULL; + alt_rule = scan_alt_rule(); /* scans || to |alt_rule| */ + if (scan_keyword("attr")) { + scan_pdf_ext_toks(); + attr = tokenlist_to_cstring(def_ref, true, NULL); + delete_token_ref(def_ref); + } + if (scan_keyword("named")) { + scan_pdf_ext_toks(); + named = tokenlist_to_cstring(def_ref, true, NULL); + delete_token_ref(def_ref); + page = 0; + } else if (scan_keyword("page")) { + scan_int(); + page = cur_val; + } + if (scan_keyword("colorspace")) { + scan_int(); + colorspace = cur_val; + } + pagebox = scan_pdf_box_spec(); + if (pagebox == PDF_BOX_SPEC_NONE) { + pagebox = pdf_pagebox; + if (pagebox == PDF_BOX_SPEC_NONE) + pagebox = PDF_BOX_SPEC_CROP; + } + scan_pdf_ext_toks(); + file_name = tokenlist_to_cstring(def_ref, true, NULL); + assert(file_name != NULL); + delete_token_ref(def_ref); + idict = + read_image(pdf, file_name, page, named, colorspace, pagebox, + pdf_minor_version, pdf_inclusion_errorlevel); + img_attr(idict) = attr; + img_dimen(idict) = alt_rule; + img_transform(idict) = transform; + pdf_last_ximage = img_objnum(idict); + pdf_last_ximage_pages = img_totalpages(idict); + pdf_last_ximage_colordepth = img_colordepth(idict); +} + +@ @c +#define tail cur_list.tail_field + +void scan_pdfrefximage(PDF pdf) +{ + int transform = 0; /* one could scan transform as well */ + image_dict *idict; + scaled_whd alt_rule, dim; + alt_rule = scan_alt_rule(); /* scans || to |alt_rule| */ + scan_int(); + check_obj_exists(pdf, obj_type_ximage, cur_val); + new_whatsit(pdf_refximage_node); + idict = idict_array[obj_data_ptr(pdf, cur_val)]; + if (alt_rule.wd != null_flag || alt_rule.ht != null_flag + || alt_rule.dp != null_flag) + dim = scale_img(idict, alt_rule, transform); + else + dim = scale_img(idict, img_dimen(idict), img_transform(idict)); + width(tail) = dim.wd; + height(tail) = dim.ht; + depth(tail) = dim.dp; + pdf_ximage_transform(tail) = transform; + pdf_ximage_index(tail) = img_index(idict); +} + +@ |tex_scale()| sequence of decisions: + +{\obeylines\obeyspaces\tt +wd ht dp : res = tex; +wd ht -- +wd -- dp +wd -- -- +-- ht dp +-- ht -- +-- -- dp +-- -- -- : res = nat; +} + +@c +scaled_whd tex_scale(scaled_whd nat, scaled_whd tex) +{ + scaled_whd res; + if (!is_running(tex.wd) && !is_running(tex.ht) && !is_running(tex.dp)) { + /* width, height, and depth specified */ + res = tex; + } else /* max. 2 dimensions are specified */ if (!is_running(tex.wd)) { + res.wd = tex.wd; + if (!is_running(tex.ht)) { + res.ht = tex.ht; + /* width and height specified */ + res.dp = ext_xn_over_d(tex.ht, nat.dp, nat.ht); + } else if (!is_running(tex.dp)) { + res.dp = tex.dp; + /* width and depth specified */ + res.ht = ext_xn_over_d(tex.wd, nat.ht + nat.dp, nat.wd) - tex.dp; + } else { + /* only width specified */ + res.ht = ext_xn_over_d(tex.wd, nat.ht, nat.wd); + res.dp = ext_xn_over_d(tex.wd, nat.dp, nat.wd); + } + } else if (!is_running(tex.ht)) { + res.ht = tex.ht; + if (!is_running(tex.dp)) { + res.dp = tex.dp; + /* height and depth specified */ + res.wd = ext_xn_over_d(tex.ht + tex.dp, nat.wd, nat.ht + nat.dp); + } else { + /* only height specified */ + res.wd = ext_xn_over_d(tex.ht, nat.wd, nat.ht); + res.dp = ext_xn_over_d(tex.ht, nat.dp, nat.ht); + } + } else if (!is_running(tex.dp)) { + res.dp = tex.dp; + /* only depth specified */ + res.ht = nat.ht - (tex.dp - nat.dp); + res.wd = nat.wd; + } else { + /* nothing specified */ + res = nat; + } + return res; +} + +@ Within |scale_img()| only image width and height matter; +the offsets and positioning are not interesting here. +But one needs rotation info to swap width and height. +|img_rotation()| comes from the optional /Rotate key in the PDF file. + +@c +scaled_whd scale_img(image_dict * idict, scaled_whd alt_rule, int transform) +{ + int x, y, xr, yr, tmp; /* size and resolution of image */ + scaled_whd nat; /* natural size corresponding to image resolution */ + int default_res; + assert(idict != NULL); + if ((img_type(idict) == IMG_TYPE_PDF + || img_type(idict) == IMG_TYPE_PDFSTREAM) && img_is_bbox(idict)) { + x = img_xsize(idict) = img_bbox(idict)[2] - img_bbox(idict)[0]; /* dimensions from image.bbox */ + y = img_ysize(idict) = img_bbox(idict)[3] - img_bbox(idict)[1]; + img_xorig(idict) = img_bbox(idict)[0]; + img_yorig(idict) = img_bbox(idict)[1]; + } else { + x = img_xsize(idict); /* dimensions, resolutions from image file */ + y = img_ysize(idict); + } + xr = img_xres(idict); + yr = img_yres(idict); + if (x <= 0 || y <= 0 || xr < 0 || yr < 0) + pdftex_fail("ext1: invalid image dimensions"); + if (xr > 65535 || yr > 65535) { + xr = 0; + yr = 0; + pdftex_warn("ext1: too large image resolution ignored"); + } + if (((transform - img_rotation(idict)) & 1) == 1) { + tmp = x; + x = y; + y = tmp; + tmp = xr; + xr = yr; + yr = tmp; + } + nat.dp = 0; /* always for images */ + if (img_type(idict) == IMG_TYPE_PDF + || img_type(idict) == IMG_TYPE_PDFSTREAM) { + nat.wd = x; + nat.ht = y; + } else { + default_res = fix_int(pdf_image_resolution, 0, 65535); + if (default_res > 0 && (xr == 0 || yr == 0)) { + xr = default_res; + yr = default_res; + } + if (xr > 0 && yr > 0) { + nat.wd = ext_xn_over_d(one_hundred_inch, x, 100 * xr); + nat.ht = ext_xn_over_d(one_hundred_inch, y, 100 * yr); + } else { + nat.wd = ext_xn_over_d(one_hundred_inch, x, 7200); + nat.ht = ext_xn_over_d(one_hundred_inch, y, 7200); + } + } + return tex_scale(nat, alt_rule); +} + +@ @c +void write_img(PDF pdf, image_dict * idict) +{ + assert(idict != NULL); + if (img_state(idict) < DICT_WRITTEN) { + if (tracefilenames) + tex_printf(" <%s", img_filepath(idict)); + switch (img_type(idict)) { + case IMG_TYPE_PNG: + write_png(pdf, idict); + break; + case IMG_TYPE_JPG: + write_jpg(pdf, idict); + break; + case IMG_TYPE_JBIG2: + write_jbig2(pdf, idict); + break; + case IMG_TYPE_PDF: + write_epdf(pdf, idict); + break; + case IMG_TYPE_PDFSTREAM: + write_pdfstream(pdf, idict); + break; + default: + pdftex_fail("internal error: unknown image type (1)"); + } + if (tracefilenames) + tex_printf(">"); + if (img_type(idict) == IMG_TYPE_PNG) { + write_additional_png_objects(pdf); + } + } + if (img_state(idict) < DICT_WRITTEN) + img_state(idict) = DICT_WRITTEN; +} + +@ write an image +@c +void pdf_write_image(PDF pdf, int n) +{ + pdf_begin_dict(pdf, n, 0); + if (pdf->draftmode == 0) + write_img(pdf, idict_array[obj_data_ptr(pdf, n)]); +} + +@ @c +void check_pdfstream_dict(image_dict * idict) +{ + if (!img_is_bbox(idict)) + pdftex_fail("image.stream: no bbox given"); + if (img_state(idict) < DICT_FILESCANNED) + img_state(idict) = DICT_FILESCANNED; +} + +@ @c +void write_pdfstream(PDF pdf, image_dict * idict) +{ + char s[256]; + assert(img_pdfstream_ptr(idict) != NULL); + assert(img_is_bbox(idict)); + pdf_puts(pdf, "/Type /XObject\n/Subtype /Form\n"); + if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) + pdf_printf(pdf, "%s\n", img_attr(idict)); + pdf_puts(pdf, "/FormType 1\n"); + sprintf(s, "/BBox [%.8f %.8f %.8f %.8f]\n", int2bp(img_bbox(idict)[0]), + int2bp(img_bbox(idict)[1]), int2bp(img_bbox(idict)[2]), + int2bp(img_bbox(idict)[3])); + pdf_printf(pdf, stripzeros(s)); + pdf_begin_stream(pdf); + if (img_pdfstream_stream(idict) != NULL) + pdf_puts(pdf, img_pdfstream_stream(idict)); + pdf_end_stream(pdf); +} + +@ @c +/* define |idict_ptr|, |idict_array|, and |idict_limit| */ +idict_entry *idict_ptr, *idict_array = NULL; +size_t idict_limit; + +void idict_to_array(image_dict * idict) +{ + assert(idict != NULL); + if (idict_ptr - idict_array == 0) { /* align to count from 1 */ + alloc_array(idict, 1, SMALL_BUF_SIZE); /* /Im0 unused */ + idict_ptr++; + } + alloc_array(idict, 1, SMALL_BUF_SIZE); + *idict_ptr = idict; + assert(img_index(idict) == idict_ptr - idict_array); + idict_ptr++; +} + + +@ To allow the use of \.{\\pdfrefximage} inside saved boxes in -ini mode, +the information in the array has to be (un)dumped with the format. +The next two routines take care of that. + +Most of the work involved in setting up the images is simply +executed again. This solves the many possible errors resulting from +the split in two separate runs. + +There was only one problem remaining: The pdfversion and +pdfinclusionerrorlevel can have changed inbetween the call to +|readimage()| and dump time. That is why they are passed as arguments +to undumpimagemeta once more. + +some of the dumped values are really type int, not integer, +but since the macro falls back to |generic_dump| anyway, that +does not matter. + +@c +#define dumpinteger generic_dump +#define undumpinteger generic_undump + +@ (un)dumping a string means dumping the allocation size, followed + by the bytes. The trailing \.{\\0} is dumped as well, because that + makes the code simpler. + +@c +#define dumpcharptr(a) \ + do { \ + int x; \ + if (a!=NULL) { \ + x = (int)strlen(a)+1; \ + dumpinteger(x); dump_things(*a, x); \ + } else { \ + x = 0; dumpinteger(x); \ + } \ + } while (0) + +#define undumpcharptr(s) \ + do { \ + int x; \ + char *a; \ + undumpinteger (x); \ + if (x>0) { \ + a = xmalloc((unsigned)x); \ + undump_things(*a,x); \ + s = a ; \ + } else { s = NULL; } \ + } while (0) + +@ @c +void dumpimagemeta(void) +{ + int cur_index, i; + image_dict *idict; + + i = (int) idict_limit; + dumpinteger(i); + cur_index = (int) (idict_ptr - idict_array); + dumpinteger(cur_index); + + for (i = 1; i < cur_index; i++) { + idict = idict_array[i]; + assert(idict != NULL); + dumpcharptr(img_filename(idict)); + dumpinteger(img_type(idict)); + dumpinteger(img_procset(idict)); + dumpinteger(img_xsize(idict)); + dumpinteger(img_ysize(idict)); + dumpinteger(img_xres(idict)); + dumpinteger(img_yres(idict)); + dumpinteger(img_totalpages(idict)); + dumpinteger(img_colorspace(idict)); + + /* the |image_struct| is not dumped at all, except for a few + variables that are needed to restore the contents */ + + if (img_type(idict) == IMG_TYPE_PDF) { + dumpinteger(img_pagebox(idict)); + dumpinteger(img_pagenum(idict)); + } else if (img_type(idict) == IMG_TYPE_JBIG2) { + dumpinteger(img_pagenum(idict)); + } + + } +} + +@ @c +void undumpimagemeta(PDF pdf, int pdfversion, int pdfinclusionerrorlevel) +{ + int cur_index, i; + image_dict *idict; + + assert(pdf != NULL); + undumpinteger(i); + idict_limit = (size_t) i; + + idict_array = xtalloc(idict_limit, idict_entry); + undumpinteger(cur_index); + idict_ptr = idict_array + cur_index; + + for (i = 1; i < cur_index; i++) { + idict = new_image_dict(); + assert(idict != NULL); + assert(img_index(idict) == -1); + idict_to_array(idict); + undumpcharptr(img_filename(idict)); + undumpinteger(img_type(idict)); + undumpinteger(img_procset(idict)); + undumpinteger(img_xsize(idict)); + undumpinteger(img_ysize(idict)); + undumpinteger(img_xres(idict)); + undumpinteger(img_yres(idict)); + undumpinteger(img_totalpages(idict)); + undumpinteger(img_colorspace(idict)); + + switch (img_type(idict)) { + case IMG_TYPE_PDF: + undumpinteger(img_pagebox(idict)); + undumpinteger(img_pagenum(idict)); + break; + case IMG_TYPE_PNG: + break; + case IMG_TYPE_JPG: + break; + case IMG_TYPE_JBIG2: + if (pdfversion < 4) { + pdftex_fail + ("JBIG2 images only possible with at least PDF 1.4; you are generating PDF 1.%i", + (int) pdfversion); + } + undumpinteger(img_pagenum(idict)); + break; + default: + pdftex_fail("unknown type of image"); + } + read_img(pdf, idict, pdfversion, pdfinclusionerrorlevel); + } +} + +@ scans rule spec to |alt_rule| +@c +scaled_whd scan_alt_rule(void) +{ + scaled_whd alt_rule; + alt_rule.wd = null_flag; + alt_rule.ht = null_flag; + alt_rule.dp = null_flag; + RESWITCH: + if (scan_keyword("width")) { + scan_normal_dimen(); + alt_rule.wd = cur_val; + goto RESWITCH; + } + if (scan_keyword("height")) { + scan_normal_dimen(); + alt_rule.ht = cur_val; + goto RESWITCH; + } + if (scan_keyword("depth")) { + scan_normal_dimen(); + alt_rule.dp = cur_val; + goto RESWITCH; + } + return alt_rule; +} diff --git a/Build/source/texk/web2c/luatexdir/image/writejbig2.c b/Build/source/texk/web2c/luatexdir/image/writejbig2.c deleted file mode 100644 index c22c27e11b6..00000000000 --- a/Build/source/texk/web2c/luatexdir/image/writejbig2.c +++ /dev/null @@ -1,852 +0,0 @@ -/* writejbig2.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -/*********************************************************************** - -This is experimental JBIG2 image support to pdfTeX. JBIG2 image decoding -is part of Adobe PDF-1.4, and requires Acroread 5.0 or later. - -References -========== - -* 14492 FCD: Information technology -- coded representation of picture -and audio information -- lossy/lossless coding of bi-level images / -JBIG committee, 1999 July 16. This JBIG2 Working Draft is available from -http://www.jpeg.org/public/fcd14492.pdf. The references in the C-code -correspond to the sections of this document. - -* PDF Reference, 5th edition, version 1.6, 1985--2005 Adobe Systems -Incorporated. Available online: - -http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf - -News -==== - -31 May 2006: no need to wait for endoffileflag in sequential access -organization. - -10 May 2006: ygetc() for some catching of broken JBIG2 files; modify to -accept Example 3.4 from PDFRef 5th ed. with short end-of-file segment. - -09 May 2006: pages_maketree() and segments_maketree() by AVL tree, -some cleaning up. - -06 May 2006: File list replaced by AVL tree; new_fileinfo(), -new_pageinfo(). - -04 May 2006: Updated for pdftex-1.40-beta-20060213. - -08 Jan. 2003: Added flushjbig2page0objects() function. Now at the end -of the pdfTeX run all pending page0 objects are written out. - -08 Jan. 2003: Release on private webpage. - -04 Jan. 2003: Completely rewritten. Now with some data structures. -Rudimentary local file and image bookkeeping. Multiple image inclusion -from one JBIG2 file. Only required page0 segments are marked for -inclusion. - -13 Nov. 2002: pdfcrypting removed. - -08 Dec. 2002: bug in page 0 stream writing repaired. -Strategy for multiple page inclusion from same JBIG2 file: When writing -1st image, create fresh PDF object for page 0, and include any page -0 segments from complete file (even if these segments are not needed -for image). When writing next image, check by filename comparison if -PDF object for page 0 of this JBIG2 file has already been written. This -can only remember the file name for the direct predecessor JBIG2 image -(but images of other types might come inbetween). If such page 0 PDF -object exists, reference it. Else create fresh one. - -09 Dec. 2002: JBIG2 seg. page numbers > 0 are now set to 1, see PDF Ref. - -***********************************************************************/ - -static const char _svn_version[] = - "$Id: writejbig2.c 2315 2009-04-17 23:34:42Z hhenkel $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/image/writejbig2.c $"; - -#undef DEBUG - -#include -#include -#include -#include "ptexlib.h" -#include "ptexmac.h" -#include "image.h" - -/**********************************************************************/ - -/* 7.3 Segment types */ -#define M_SymbolDictionary 0 -#define M_IntermediateTextRegion 4 -#define M_ImmediateTextRegion 6 -#define M_ImmediateLosslessTextRegion 7 -#define M_PatternDictionary 16 -#define M_IntermediateHalftoneRegion 20 -#define M_ImmediateHalftoneRegion 22 -#define M_ImmediateLosslessHalftoneRegion 23 -#define M_IntermediateGenericRegion 36 -#define M_ImmediateGenericRegion 38 -#define M_ImmediateLosslessGenericRegion 39 -#define M_IntermediateGenericRefinementRegion 40 -#define M_ImmediateGenericRefinementRegion 42 -#define M_ImmediateLosslessGenericRefinementRegion 43 -#define M_PageInformation 48 -#define M_EndOfPage 49 -#define M_EndOfStripe 50 -#define M_EndOfFile 51 -#define M_Profiles 52 -#define M_Tables 53 -#define M_Extension 62 - -/**********************************************************************/ - -typedef enum { INITIAL, HAVEINFO, WRITEPDF } PHASE; - -typedef struct _LITEM { - struct _LITEM *prev; - struct _LITEM *next; - void *d; /* data */ -} LITEM; - -typedef struct _LIST { - LITEM *first; - LITEM *last; - struct avl_table *tree; -} LIST; - -typedef struct _SEGINFO { - unsigned long segnum; - boolean isrefered; - boolean refers; - unsigned int seghdrflags; /* set by readseghdr() */ - boolean pageassocsizeflag; /* set by readseghdr() */ - unsigned int reftosegcount; /* set by readseghdr() */ - unsigned int countofrefered; /* set by readseghdr() */ - unsigned int fieldlen; /* set by readseghdr() */ - unsigned int segnumwidth; /* set by readseghdr() */ - long segpage; /* set by readseghdr() */ - unsigned long segdatalen; /* set by readseghdr() */ - unsigned long hdrstart; /* set by readseghdr() */ - unsigned long hdrend; /* set by readseghdr() */ - unsigned long datastart; - unsigned long dataend; - boolean endofstripeflag; /* set by checkseghdrflags() */ - boolean endofpageflag; /* set by checkseghdrflags() */ - boolean pageinfoflag; /* set by checkseghdrflags() */ - boolean endoffileflag; /* set by checkseghdrflags() */ -} SEGINFO; - -typedef struct _PAGEINFO { - LIST segments; /* segments associated with page */ - unsigned long pagenum; - unsigned int width; - unsigned int height; - unsigned int xres; - unsigned int yres; - unsigned int pagesegmentflags; - unsigned int stripinginfo; - unsigned int stripedheight; -} PAGEINFO; - -typedef struct _FILEINFO { - FILE *file; - char *filepath; - long filesize; - LIST pages; /* not including page0 */ - LIST page0; - unsigned int filehdrflags; /* set by readfilehdr() */ - boolean sequentialaccess; /* set by readfilehdr() */ - unsigned long numofpages; /* set by readfilehdr() */ - unsigned long streamstart; /* set by get_jbig2_info() */ - unsigned long pdfpage0objnum; - PHASE phase; -} FILEINFO; - -/**********************************************************************/ - -static struct avl_table *file_tree = NULL; - -static int comp_file_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return strcmp(((const FILEINFO *) pa)->filepath, - ((const FILEINFO *) pb)->filepath); -} - -static int comp_page_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return ((const PAGEINFO *) pa)->pagenum - ((const PAGEINFO *) pb)->pagenum; -} - -static int comp_segment_entry(const void *pa, const void *pb, void *p) -{ - (void) p; - return ((const SEGINFO *) pa)->segnum - ((const SEGINFO *) pb)->segnum; -} - -/**********************************************************************/ - -static int ygetc(FILE * stream) -{ - int c = getc(stream); - if (c < 0) { - if (c == EOF) - pdftex_fail("getc() failed; premature end of JBIG2 image file"); - else - pdftex_fail("getc() failed (can't happen)"); - } - return c; -} - -/**********************************************************************/ - -static void initlinkedlist(LIST * lp) -{ - lp->first = NULL; - lp->last = NULL; - lp->tree = NULL; -} - -static LIST *litem_append(LIST * lp) -{ - LITEM *ip; - ip = xtalloc(1, LITEM); - if (lp->first == NULL) { - lp->first = ip; - ip->prev = NULL; - } else { - lp->last->next = ip; - ip->prev = lp->last; - } - lp->last = ip; - ip->next = NULL; - ip->d = NULL; - return lp; -} - -/**********************************************************************/ - -static FILEINFO *new_fileinfo(void) -{ - FILEINFO *fip; - fip = xtalloc(1, FILEINFO); - fip->file = NULL; - fip->filepath = NULL; - fip->filesize = 0; - initlinkedlist(&(fip->pages)); - initlinkedlist(&(fip->page0)); - fip->filehdrflags = 0; - fip->sequentialaccess = false; - fip->numofpages = 0; - fip->streamstart = 0; - fip->pdfpage0objnum = 0; - fip->phase = INITIAL; - return fip; -} - -static PAGEINFO *new_pageinfo(void) -{ - PAGEINFO *pip; - pip = xtalloc(1, PAGEINFO); - initlinkedlist(&(pip->segments)); - pip->pagenum = 0; - pip->width = 0; - pip->height = 0; - pip->xres = 0; - pip->yres = 0; - pip->pagesegmentflags = 0; - pip->stripinginfo = 0; - pip->stripedheight = 0; - return pip; -} - -static void init_seginfo(SEGINFO * sip) -{ - sip->segnum = 0; - sip->isrefered = false; - sip->refers = false; - sip->seghdrflags = 0; - sip->pageassocsizeflag = false; - sip->reftosegcount = 0; - sip->countofrefered = 0; - sip->fieldlen = 0; - sip->segnumwidth = 0; - sip->segpage = 0; - sip->segdatalen = 0; - sip->hdrstart = 0; - sip->hdrend = 0; - sip->datastart = 0; - sip->dataend = 0; - sip->endofstripeflag = false; - sip->endofpageflag = false; - sip->pageinfoflag = false; - sip->endoffileflag = false; -} - -/**********************************************************************/ - -static void pages_maketree(LIST * plp) -{ - LITEM *ip; - void **aa; - assert(plp->tree == NULL); - plp->tree = avl_create(comp_page_entry, NULL, &avl_xallocator); - assert(plp->tree != NULL); - for (ip = plp->first; ip != NULL; ip = ip->next) { - aa = avl_probe(plp->tree, (PAGEINFO *) ip->d); - assert(aa != NULL); - } -} - -static void segments_maketree(LIST * slp) -{ - LITEM *ip; - void **aa; - assert(slp->tree == NULL); - slp->tree = avl_create(comp_segment_entry, NULL, &avl_xallocator); - assert(slp->tree != NULL); - for (ip = slp->first; ip != NULL; ip = ip->next) { - aa = avl_probe(slp->tree, (SEGINFO *) ip->d); - assert(aa != NULL); - } -} - -/**********************************************************************/ - -static PAGEINFO *find_pageinfo(LIST * plp, unsigned long pagenum) -{ - PAGEINFO tmp; - tmp.pagenum = pagenum; - assert(plp->tree != NULL); - return (PAGEINFO *) avl_find(plp->tree, &tmp); -} - -static SEGINFO *find_seginfo(LIST * slp, unsigned long segnum) -{ - SEGINFO tmp; - tmp.segnum = segnum; - assert(slp->tree != NULL); - return (SEGINFO *) avl_find(slp->tree, &tmp); -} - -/**********************************************************************/ - -static unsigned int read2bytes(FILE * f) -{ - unsigned int c = ygetc(f); - return (c << 8) + ygetc(f); -} - -static unsigned long read4bytes(FILE * f) -{ - unsigned int l = read2bytes(f); - return (l << 16) + read2bytes(f); -} - -/**********************************************************************/ - -static unsigned long getstreamlen(LITEM * slip, boolean refer) -{ - SEGINFO *sip; - unsigned long len = 0; - for (; slip != NULL; slip = slip->next) { - sip = slip->d; - if (refer || sip->isrefered) - len += sip->hdrend - sip->hdrstart + sip->dataend - sip->datastart; - } - return len; -} - -/**********************************************************************/ - -static void readfilehdr(FILEINFO * fip) -{ - unsigned int i; - /* Annex D.4 File header syntax */ - /* Annex D.4.1 ID string */ - unsigned char jbig2_id[] = { 0x97, 'J', 'B', '2', 0x0d, 0x0a, 0x1a, 0x0a }; - xfseek(fip->file, 0, SEEK_SET, fip->filepath); - for (i = 0; i < 8; i++) - if (ygetc(fip->file) != jbig2_id[i]) - pdftex_fail - ("readfilehdr(): reading JBIG2 image file failed: ID string missing"); - /* Annex D.4.2 File header flags */ - fip->filehdrflags = ygetc(fip->file); - fip->sequentialaccess = (fip->filehdrflags & 0x01) ? true : false; - if (fip->sequentialaccess) { /* Annex D.1 vs. Annex D.2 */ - xfseek(fip->file, 0, SEEK_END, fip->filepath); - fip->filesize = (long) xftello(fip->file, fip->filepath); - xfseek(fip->file, 9, SEEK_SET, fip->filepath); - } - /* Annex D.4.3 Number of pages */ - if (!(fip->filehdrflags >> 1) & 0x01) /* known number of pages */ - fip->numofpages = read4bytes(fip->file); - /* --- at end of file header --- */ -} - -/**********************************************************************/ - -static void checkseghdrflags(SEGINFO * sip) -{ - sip->endofstripeflag = false; - sip->endofpageflag = false; - sip->pageinfoflag = false; - sip->endoffileflag = false; - /* 7.3 Segment types */ - switch (sip->seghdrflags & 0x3f) { - case M_SymbolDictionary: - case M_IntermediateTextRegion: - case M_ImmediateTextRegion: - case M_ImmediateLosslessTextRegion: - case M_PatternDictionary: - case M_IntermediateHalftoneRegion: - case M_ImmediateHalftoneRegion: - case M_ImmediateLosslessHalftoneRegion: - case M_IntermediateGenericRegion: - case M_ImmediateGenericRegion: - case M_ImmediateLosslessGenericRegion: - case M_IntermediateGenericRefinementRegion: - case M_ImmediateGenericRefinementRegion: - case M_ImmediateLosslessGenericRefinementRegion: - break; - case M_PageInformation: - sip->pageinfoflag = true; - break; - case M_EndOfPage: - sip->endofpageflag = true; - break; - case M_EndOfStripe: - sip->endofstripeflag = true; - break; - case M_EndOfFile: - sip->endoffileflag = true; - break; - case M_Profiles: - case M_Tables: - case M_Extension: - break; - default: - pdftex_fail - ("checkseghdrflags(): unknown segment type in JBIG2 image file"); - break; - } -} - -/**********************************************************************/ -/* for first reading of file; return value tells if header been read */ - -static boolean readseghdr(FILEINFO * fip, SEGINFO * sip) -{ - unsigned int i; - sip->hdrstart = xftell(fip->file, fip->filepath); - if (fip->sequentialaccess && sip->hdrstart == (unsigned) fip->filesize) - return false; /* no endoffileflag is ok for sequentialaccess */ -#ifdef DEBUG - printf("\nhdrstart %d\n", sip->hdrstart); -#endif - /* 7.2.2 Segment number */ - sip->segnum = read4bytes(fip->file); -#ifdef DEBUG - printf(" segnum %d\n", sip->segnum); -#endif - /* 7.2.3 Segment header flags */ - sip->seghdrflags = ygetc(fip->file); -#ifdef DEBUG - printf(" hdrflags %d\n", sip->seghdrflags & 0x3f); -#endif - checkseghdrflags(sip); - if (fip->sequentialaccess && sip->endoffileflag) /* accept shorter segment, */ - return true; /* makes it compliant with Example 3.4 of PDFRef. 5th ed. */ - sip->pageassocsizeflag = ((sip->seghdrflags >> 6) & 0x01) ? true : false; - /* 7.2.4 Referred-to segment count and retention flags */ - sip->reftosegcount = (unsigned int) ygetc(fip->file); - sip->countofrefered = sip->reftosegcount >> 5; - if (sip->countofrefered < 5) - sip->fieldlen = 1; - else { - sip->fieldlen = 5 + sip->countofrefered / 8; - xfseek(fip->file, sip->fieldlen - 1, SEEK_CUR, fip->filepath); - } - /* 7.2.5 Referred-to segment numbers */ - if (sip->segnum <= 256) - sip->segnumwidth = 1; - else if (sip->segnum <= 65536) - sip->segnumwidth = 2; - else - sip->segnumwidth = 4; - for (i = 0; i < sip->countofrefered; i++) { - switch (sip->segnumwidth) { - case 1: - (void) ygetc(fip->file); - break; - case 2: - (void) read2bytes(fip->file); - break; - case 4: - (void) read4bytes(fip->file); - break; - } - } - /* 7.2.6 Segment page association */ - if (sip->pageassocsizeflag) - sip->segpage = read4bytes(fip->file); - else - sip->segpage = ygetc(fip->file); - /* 7.2.7 Segment data length */ - sip->segdatalen = read4bytes(fip->file); - sip->hdrend = (long) xftello(fip->file, fip->filepath); - /* ---- at end of segment header ---- */ - return true; -} - -/**********************************************************************/ - -static void checkseghdr(FILEINFO * fip, SEGINFO * sip); - -static void markpage0seg(FILEINFO * fip, unsigned long referedseg) -{ - PAGEINFO *pip; - SEGINFO *sip; - pip = fip->page0.first->d; - sip = find_seginfo(&(pip->segments), referedseg); - if (sip != NULL) { - if (!sip->refers && sip->countofrefered > 0) - checkseghdr(fip, sip); - sip->isrefered = true; - } -} - -/**********************************************************************/ -/* for writing, marks refered page0 segments, sets segpage > 0 to 1 */ - -static void writeseghdr(FILEINFO * fip, SEGINFO * sip) -{ - unsigned int i; - unsigned long referedseg = 0; - /* 7.2.2 Segment number */ - /* 7.2.3 Segment header flags */ - /* 7.2.4 Referred-to segment count and retention flags */ - for (i = 0; i < 5 + sip->fieldlen; i++) - pdfout(ygetc(fip->file)); - /* 7.2.5 Referred-to segment numbers */ - for (i = 0; i < sip->countofrefered; i++) { - switch (sip->segnumwidth) { - case 1: - referedseg = ygetc(fip->file); - pdfout(referedseg); - break; - case 2: - referedseg = read2bytes(fip->file); - pdfout((referedseg >> 8) & 0xff); - pdfout(referedseg & 0xff); - break; - case 4: - referedseg = read4bytes(fip->file); - pdfout((referedseg >> 24) & 0xff); - pdfout((referedseg >> 16) & 0xff); - pdfout((referedseg >> 8) & 0xff); - pdfout(referedseg & 0xff); - break; - } - if (fip->page0.last != NULL && !sip->refers) - markpage0seg(fip, referedseg); - } - if (sip->countofrefered > 0) - sip->refers = true; - /* 7.2.6 Segment page association */ - if (sip->pageassocsizeflag) - for (i = 0; i < 3; i++) { - (void) ygetc(fip->file); - pdfout(0); - } - (void) ygetc(fip->file); - pdfout((sip->segpage > 0) ? 1 : 0); - /* 7.2.7 Segment data length */ - for (i = 0; i < 4; i++) - pdfout(ygetc(fip->file)); - /* ---- at end of segment header ---- */ -} - -/**********************************************************************/ -/* for recursive marking of refered page0 segments */ - -static void checkseghdr(FILEINFO * fip, SEGINFO * sip) -{ - unsigned int i; - unsigned long referedseg = 0; - /* 7.2.2 Segment number */ - /* 7.2.3 Segment header flags */ - /* 7.2.4 Referred-to segment count and retention flags */ - xfseek(fip->file, 5 + sip->fieldlen, SEEK_CUR, fip->filepath); - /* 7.2.5 Referred-to segment numbers */ - for (i = 0; i < sip->countofrefered; i++) { - switch (sip->segnumwidth) { - case 1: - referedseg = ygetc(fip->file); - break; - case 2: - referedseg = read2bytes(fip->file); - break; - case 4: - referedseg = read4bytes(fip->file); - break; - } - if (!sip->refers) - markpage0seg(fip, referedseg); - } - if (sip->countofrefered > 0) - sip->refers = true; - /* 7.2.6 Segment page association */ - /* 7.2.7 Segment data length */ - if (sip->pageassocsizeflag) - xfseek(fip->file, 8, SEEK_CUR, fip->filepath); - else - xfseek(fip->file, 5, SEEK_CUR, fip->filepath); - /* ---- at end of segment header ---- */ -} - -/**********************************************************************/ - -static unsigned long findstreamstart(FILEINFO * fip) -{ - SEGINFO tmp; - assert(!fip->sequentialaccess); /* D.2 Random-access organisation */ - do /* find random-access stream start */ - (void) readseghdr(fip, &tmp); - while (!tmp.endoffileflag); - fip->streamstart = tmp.hdrend; - readfilehdr(fip); - return fip->streamstart; -} - -/**********************************************************************/ - -static void rd_jbig2_info(FILEINFO * fip) -{ - unsigned long seekdist = 0; /* for sequential-access only */ - unsigned long streampos = 0; /* for random-access only */ - unsigned long currentpage = 0; - boolean sipavail = false; - PAGEINFO *pip; - SEGINFO *sip = NULL; - LIST *plp, *slp; - fip->file = xfopen(fip->filepath, FOPEN_RBIN_MODE); - readfilehdr(fip); - if (!fip->sequentialaccess) /* D.2 Random-access organisation */ - streampos = findstreamstart(fip); - while (true) { /* loop over segments */ - if (!sipavail) { - sip = xtalloc(1, SEGINFO); - sipavail = true; - } - init_seginfo(sip); - if (!readseghdr(fip, sip) || sip->endoffileflag) - break; - if (sip->segpage > 0) { - if (sip->segpage > (int) currentpage) { - plp = litem_append(&(fip->pages)); - plp->last->d = new_pageinfo(); - currentpage = sip->segpage; - } - pip = fip->pages.last->d; - } else { - if (fip->page0.last == NULL) { - plp = litem_append(&(fip->page0)); - plp->last->d = new_pageinfo(); - } - pip = fip->page0.last->d; - } - if (!sip->endofpageflag) { - slp = litem_append(&(pip->segments)); - slp->last->d = sip; - sipavail = false; - } - if (!fip->sequentialaccess) - sip->datastart = streampos; - else - sip->datastart = sip->hdrend; - sip->dataend = sip->datastart + sip->segdatalen; - if (!fip->sequentialaccess - && (sip->pageinfoflag || sip->endofstripeflag)) - xfseeko(fip->file, sip->datastart, SEEK_SET, fip->filepath); - seekdist = sip->segdatalen; - /* 7.4.8 Page information segment syntax */ - if (sip->pageinfoflag) { - pip->pagenum = sip->segpage; - pip->width = read4bytes(fip->file); - pip->height = read4bytes(fip->file); - pip->xres = read4bytes(fip->file); - pip->yres = read4bytes(fip->file); - pip->pagesegmentflags = ygetc(fip->file); - /* 7.4.8.6 Page striping information */ - pip->stripinginfo = read2bytes(fip->file); - seekdist -= 19; - } - if (sip->endofstripeflag) { - pip->stripedheight = read4bytes(fip->file); - seekdist -= 4; - } - if (!fip->sequentialaccess - && (sip->pageinfoflag || sip->endofstripeflag)) - xfseeko(fip->file, sip->hdrend, SEEK_SET, fip->filepath); - if (!fip->sequentialaccess) - streampos += sip->segdatalen; - if (fip->sequentialaccess) - xfseeko(fip->file, seekdist, SEEK_CUR, fip->filepath); - if (sip->endofpageflag && currentpage && (pip->stripinginfo >> 15)) - pip->height = pip->stripedheight; - } - fip->phase = HAVEINFO; - if (sipavail) - xfree(sip); - xfclose(fip->file, fip->filepath); -} - -/**********************************************************************/ - -static void wr_jbig2(FILEINFO * fip, unsigned long page) -{ - LITEM *slip; - PAGEINFO *pip; - SEGINFO *sip; - unsigned long i; - if (page > 0) { - pip = find_pageinfo(&(fip->pages), page); - assert(pip != NULL); - pdf_puts("/Type /XObject\n/Subtype /Image\n"); - pdf_printf("/Width %i\n", pip->width); - pdf_printf("/Height %i\n", pip->height); - pdf_puts("/ColorSpace /DeviceGray\n"); - pdf_puts("/BitsPerComponent 1\n"); - pdf_printf("/Length %lu\n", getstreamlen(pip->segments.first, true)); - pdf_puts("/Filter [/JBIG2Decode]\n"); - if (fip->page0.last != NULL) { - if (fip->pdfpage0objnum == 0) { - pdf_create_obj(0, 0); - fip->pdfpage0objnum = obj_ptr; - } - pdf_printf("/DecodeParms [<< /JBIG2Globals %lu 0 R >>]\n", - fip->pdfpage0objnum); - } - } else { - pip = find_pageinfo(&(fip->page0), page); - assert(pip != NULL); - pdf_begin_dict(fip->pdfpage0objnum, 0); - pdf_printf("/Length %lu\n", getstreamlen(pip->segments.first, false)); - } - pdf_puts(">>\n"); - pdf_puts("stream\n"); - fip->file = xfopen(fip->filepath, FOPEN_RBIN_MODE); - for (slip = pip->segments.first; slip != NULL; slip = slip->next) { /* loop over page segments */ - sip = slip->d; - if (sip->isrefered || page > 0) { - xfseeko(fip->file, sip->hdrstart, SEEK_SET, fip->filepath); - /* mark refered-to page 0 segments, change segpages > 1 to 1 */ - writeseghdr(fip, sip); - xfseeko(fip->file, sip->datastart, SEEK_SET, fip->filepath); - for (i = sip->datastart; i < sip->dataend; i++) - pdfout(ygetc(fip->file)); - } - } - pdf_end_stream(); - xfclose(fip->file, fip->filepath); -} - -/**********************************************************************/ - -void read_jbig2_info(image_dict * idict) -{ - FILEINFO *fip, tmp; - PAGEINFO *pip; - void **aa; - assert(idict != NULL); - img_type(idict) = IMG_TYPE_JBIG2; - if (img_pagenum(idict) < 1) - pdftex_fail - ("read_jbig2_info(): page %d not in JBIG2 image file; page must be > 0", - (int) img_pagenum(idict)); - if (file_tree == NULL) { - file_tree = avl_create(comp_file_entry, NULL, &avl_xallocator); - assert(file_tree != NULL); - } - tmp.filepath = img_filepath(idict); - fip = (FILEINFO *) avl_find(file_tree, &tmp); - if (fip == NULL) { - fip = new_fileinfo(); - fip->filepath = xstrdup(img_filepath(idict)); - aa = avl_probe(file_tree, fip); - assert(aa != NULL); - } - if (fip->phase == INITIAL) { - rd_jbig2_info(fip); - pages_maketree(&(fip->pages)); - if (fip->page0.last != NULL) { - pages_maketree(&(fip->page0)); - pip = fip->page0.first->d; - segments_maketree(&(pip->segments)); - } - } - pip = find_pageinfo(&(fip->pages), img_pagenum(idict)); - if (pip == NULL) - pdftex_fail("read_jbig2_info(): page %d not found in JBIG2 image file", - (int) img_pagenum(idict)); - img_totalpages(idict) = fip->numofpages; - img_xsize(idict) = pip->width; - img_ysize(idict) = pip->height; - img_xres(idict) = (int) (pip->xres * 0.0254 + 0.5); - img_yres(idict) = (int) (pip->yres * 0.0254 + 0.5); - img_colordepth(idict) = 1; -} - -void write_jbig2(image_dict * idict) -{ - FILEINFO *fip, tmp; - PAGEINFO *pip; - assert(idict != NULL); - assert(file_tree != NULL); - tmp.filepath = img_filepath(idict); - fip = (FILEINFO *) avl_find(file_tree, &tmp); - assert(fip != NULL); - assert(fip->phase == HAVEINFO); /* don't write before rd_jbig2_info() call */ - pip = find_pageinfo(&(fip->pages), img_pagenum(idict)); - assert(pip != NULL); - wr_jbig2(fip, pip->pagenum); - img_file(idict) = NULL; -} - -void flush_jbig2_page0_objects(void) -{ - FILEINFO *fip; - struct avl_traverser t; - if (file_tree != NULL) { - avl_t_init(&t, file_tree); - for (fip = avl_t_first(&t, file_tree); fip != NULL; - fip = avl_t_next(&t)) { - if (fip->page0.last != NULL) - wr_jbig2(fip, 0); - } - } -} - -/**********************************************************************/ diff --git a/Build/source/texk/web2c/luatexdir/image/writejbig2.h b/Build/source/texk/web2c/luatexdir/image/writejbig2.h index f28e91281fe..a5715d5732e 100644 --- a/Build/source/texk/web2c/luatexdir/image/writejbig2.h +++ b/Build/source/texk/web2c/luatexdir/image/writejbig2.h @@ -18,15 +18,15 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: writejbig2.h 2327 2009-04-18 12:47:21Z hhenkel $ */ +/* $Id: writejbig2.h 2579 2009-06-23 14:12:23Z taco $ */ #ifndef WRITEJBIG2_H # define WRITEJBIG2_H # include "image.h" -void flush_jbig2_page0_objects(void); +void flush_jbig2_page0_objects(PDF); void read_jbig2_info(image_dict *); -void write_jbig2(image_dict *); +void write_jbig2(PDF, image_dict *); #endif /* WRITEJBIG"_H */ diff --git a/Build/source/texk/web2c/luatexdir/image/writejbig2.w b/Build/source/texk/web2c/luatexdir/image/writejbig2.w new file mode 100644 index 00000000000..936ae29c6bd --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/image/writejbig2.w @@ -0,0 +1,841 @@ +% writejbig2.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2009 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ + +This is experimental JBIG2 image support to pdfTeX. JBIG2 image decoding +is part of Adobe PDF-1.4, and requires Acroread 5.0 or later. + +References +========== + +* 14492 FCD: Information technology -- coded representation of picture +and audio information -- lossy/lossless coding of bi-level images / +JBIG committee, 1999 July 16. This JBIG2 Working Draft is available from +http://www.jpeg.org/public/fcd14492.pdf. The references in the C-code +correspond to the sections of this document. + +* PDF Reference, 5th edition, version 1.6, 1985--2005 Adobe Systems +Incorporated. Available online: + +http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf + +News +==== + +31 May 2006: no need to wait for |endoffileflag| in sequential access +organization. + +10 May 2006: |ygetc()| for some catching of broken JBIG2 files; modify to +accept Example 3.4 from PDFRef 5th ed. with short end-of-file segment. + +09 May 2006: |pages_maketree()| and |segments_maketree()| by AVL tree, +some cleaning up. + +06 May 2006: File list replaced by AVL tree; |new_fileinfo()|, +|new_pageinfo()|. + +04 May 2006: Updated for pdftex-1.40-beta-20060213. + +08 Jan. 2003: Added |flushjbig2page0objects()| function. Now at the end +of the pdfTeX run all pending page0 objects are written out. + +08 Jan. 2003: Release on private webpage. + +04 Jan. 2003: Completely rewritten. Now with some data structures. +Rudimentary local file and image bookkeeping. Multiple image inclusion +from one JBIG2 file. Only required page0 segments are marked for +inclusion. + +13 Nov. 2002: pdfcrypting removed. + +08 Dec. 2002: bug in page 0 stream writing repaired. +Strategy for multiple page inclusion from same JBIG2 file: When writing +1st image, create fresh PDF object for page 0, and include any page +0 segments from complete file (even if these segments are not needed +for image). When writing next image, check by filename comparison if +PDF object for page 0 of this JBIG2 file has already been written. This +can only remember the file name for the direct predecessor JBIG2 image +(but images of other types might come inbetween). If such page 0 PDF +object exists, reference it. Else create fresh one. + +09 Dec. 2002: JBIG2 seg. page numbers > 0 are now set to 1, see PDF Ref. + +@ @c +static const char _svn_version[] = + "$Id: writejbig2.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/image/writejbig2.w $"; + +#undef DEBUG + +#include +#include +#include +#include "ptexlib.h" +#include "image/image.h" + +@ @c +/* 7.3 Segment types */ +#define M_SymbolDictionary 0 +#define M_IntermediateTextRegion 4 +#define M_ImmediateTextRegion 6 +#define M_ImmediateLosslessTextRegion 7 +#define M_PatternDictionary 16 +#define M_IntermediateHalftoneRegion 20 +#define M_ImmediateHalftoneRegion 22 +#define M_ImmediateLosslessHalftoneRegion 23 +#define M_IntermediateGenericRegion 36 +#define M_ImmediateGenericRegion 38 +#define M_ImmediateLosslessGenericRegion 39 +#define M_IntermediateGenericRefinementRegion 40 +#define M_ImmediateGenericRefinementRegion 42 +#define M_ImmediateLosslessGenericRefinementRegion 43 +#define M_PageInformation 48 +#define M_EndOfPage 49 +#define M_EndOfStripe 50 +#define M_EndOfFile 51 +#define M_Profiles 52 +#define M_Tables 53 +#define M_Extension 62 + +@ @c +typedef enum { INITIAL, HAVEINFO, WRITEPDF } PHASE; + +typedef struct _LITEM { + struct _LITEM *prev; + struct _LITEM *next; + void *d; /* data */ +} LITEM; + +typedef struct _LIST { + LITEM *first; + LITEM *last; + struct avl_table *tree; +} LIST; + +typedef struct _SEGINFO { + unsigned long segnum; + boolean isrefered; + boolean refers; + unsigned int seghdrflags; /* set by readseghdr() */ + boolean pageassocsizeflag; /* set by readseghdr() */ + unsigned int reftosegcount; /* set by readseghdr() */ + unsigned int countofrefered; /* set by readseghdr() */ + unsigned int fieldlen; /* set by readseghdr() */ + unsigned int segnumwidth; /* set by readseghdr() */ + long segpage; /* set by readseghdr() */ + unsigned long segdatalen; /* set by readseghdr() */ + unsigned long hdrstart; /* set by readseghdr() */ + unsigned long hdrend; /* set by readseghdr() */ + unsigned long datastart; + unsigned long dataend; + boolean endofstripeflag; /* set by checkseghdrflags() */ + boolean endofpageflag; /* set by checkseghdrflags() */ + boolean pageinfoflag; /* set by checkseghdrflags() */ + boolean endoffileflag; /* set by checkseghdrflags() */ +} SEGINFO; + +typedef struct _PAGEINFO { + LIST segments; /* segments associated with page */ + unsigned long pagenum; + unsigned int width; + unsigned int height; + unsigned int xres; + unsigned int yres; + unsigned int pagesegmentflags; + unsigned int stripinginfo; + unsigned int stripedheight; +} PAGEINFO; + +typedef struct _FILEINFO { + FILE *file; + char *filepath; + long filesize; + LIST pages; /* not including page0 */ + LIST page0; + unsigned int filehdrflags; /* set by readfilehdr() */ + boolean sequentialaccess; /* set by readfilehdr() */ + unsigned long numofpages; /* set by readfilehdr() */ + unsigned long streamstart; /* set by |get_jbig2_info()| */ + unsigned long pdfpage0objnum; + PHASE phase; +} FILEINFO; + +@ @c +static struct avl_table *file_tree = NULL; + +static int comp_file_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return strcmp(((const FILEINFO *) pa)->filepath, + ((const FILEINFO *) pb)->filepath); +} + +static int comp_page_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return (int) (((const PAGEINFO *) pa)->pagenum - + ((const PAGEINFO *) pb)->pagenum); +} + +static int comp_segment_entry(const void *pa, const void *pb, void *p) +{ + (void) p; + return (int) (((const SEGINFO *) pa)->segnum - + ((const SEGINFO *) pb)->segnum); +} + +@ @c +static int ygetc(FILE * stream) +{ + int c = getc(stream); + if (c < 0) { + if (c == EOF) + pdftex_fail("getc() failed; premature end of JBIG2 image file"); + else + pdftex_fail("getc() failed (can't happen)"); + } + return c; +} + +@ @c +static void initlinkedlist(LIST * lp) +{ + lp->first = NULL; + lp->last = NULL; + lp->tree = NULL; +} + +static LIST *litem_append(LIST * lp) +{ + LITEM *ip; + ip = xtalloc(1, LITEM); + if (lp->first == NULL) { + lp->first = ip; + ip->prev = NULL; + } else { + lp->last->next = ip; + ip->prev = lp->last; + } + lp->last = ip; + ip->next = NULL; + ip->d = NULL; + return lp; +} + +@ @c +static FILEINFO *new_fileinfo(void) +{ + FILEINFO *fip; + fip = xtalloc(1, FILEINFO); + fip->file = NULL; + fip->filepath = NULL; + fip->filesize = 0; + initlinkedlist(&(fip->pages)); + initlinkedlist(&(fip->page0)); + fip->filehdrflags = 0; + fip->sequentialaccess = false; + fip->numofpages = 0; + fip->streamstart = 0; + fip->pdfpage0objnum = 0; + fip->phase = INITIAL; + return fip; +} + +@ @c +static PAGEINFO *new_pageinfo(void) +{ + PAGEINFO *pip; + pip = xtalloc(1, PAGEINFO); + initlinkedlist(&(pip->segments)); + pip->pagenum = 0; + pip->width = 0; + pip->height = 0; + pip->xres = 0; + pip->yres = 0; + pip->pagesegmentflags = 0; + pip->stripinginfo = 0; + pip->stripedheight = 0; + return pip; +} + +@ @c +static void init_seginfo(SEGINFO * sip) +{ + sip->segnum = 0; + sip->isrefered = false; + sip->refers = false; + sip->seghdrflags = 0; + sip->pageassocsizeflag = false; + sip->reftosegcount = 0; + sip->countofrefered = 0; + sip->fieldlen = 0; + sip->segnumwidth = 0; + sip->segpage = 0; + sip->segdatalen = 0; + sip->hdrstart = 0; + sip->hdrend = 0; + sip->datastart = 0; + sip->dataend = 0; + sip->endofstripeflag = false; + sip->endofpageflag = false; + sip->pageinfoflag = false; + sip->endoffileflag = false; +} + +@ @c +static void pages_maketree(LIST * plp) +{ + LITEM *ip; + void **aa; + assert(plp->tree == NULL); + plp->tree = avl_create(comp_page_entry, NULL, &avl_xallocator); + assert(plp->tree != NULL); + for (ip = plp->first; ip != NULL; ip = ip->next) { + aa = avl_probe(plp->tree, (PAGEINFO *) ip->d); + assert(aa != NULL); + } +} + +@ @c +static void segments_maketree(LIST * slp) +{ + LITEM *ip; + void **aa; + assert(slp->tree == NULL); + slp->tree = avl_create(comp_segment_entry, NULL, &avl_xallocator); + assert(slp->tree != NULL); + for (ip = slp->first; ip != NULL; ip = ip->next) { + aa = avl_probe(slp->tree, (SEGINFO *) ip->d); + assert(aa != NULL); + } +} + +@ @c +static PAGEINFO *find_pageinfo(LIST * plp, unsigned long pagenum) +{ + PAGEINFO tmp; + tmp.pagenum = pagenum; + assert(plp->tree != NULL); + return (PAGEINFO *) avl_find(plp->tree, &tmp); +} + +@ @c +static SEGINFO *find_seginfo(LIST * slp, unsigned long segnum) +{ + SEGINFO tmp; + tmp.segnum = segnum; + assert(slp->tree != NULL); + return (SEGINFO *) avl_find(slp->tree, &tmp); +} + +@ @c +static unsigned int read2bytes(FILE * f) +{ + unsigned int c = (unsigned int) ygetc(f); + return (c << 8) + (unsigned int) ygetc(f); +} + +@ @c +static unsigned long read4bytes(FILE * f) +{ + unsigned int l = read2bytes(f); + return (l << 16) + read2bytes(f); +} + +@ @c +static unsigned long getstreamlen(LITEM * slip, boolean refer) +{ + SEGINFO *sip; + unsigned long len = 0; + for (; slip != NULL; slip = slip->next) { + sip = slip->d; + if (refer || sip->isrefered) + len += sip->hdrend - sip->hdrstart + sip->dataend - sip->datastart; + } + return len; +} + +@ @c +static void readfilehdr(FILEINFO * fip) +{ + unsigned int i; + /* Annex D.4 File header syntax */ + /* Annex D.4.1 ID string */ + unsigned char jbig2_id[] = { 0x97, 'J', 'B', '2', 0x0d, 0x0a, 0x1a, 0x0a }; + xfseek(fip->file, 0, SEEK_SET, fip->filepath); + for (i = 0; i < 8; i++) + if (ygetc(fip->file) != jbig2_id[i]) + pdftex_fail + ("readfilehdr(): reading JBIG2 image file failed: ID string missing"); + /* Annex D.4.2 File header flags */ + fip->filehdrflags = (unsigned int) ygetc(fip->file); + fip->sequentialaccess = (fip->filehdrflags & 0x01) ? true : false; + if (fip->sequentialaccess) { /* Annex D.1 vs. Annex D.2 */ + xfseek(fip->file, 0, SEEK_END, fip->filepath); + fip->filesize = (long) xftello(fip->file, fip->filepath); + xfseek(fip->file, 9, SEEK_SET, fip->filepath); + } + /* Annex D.4.3 Number of pages */ + if (!(fip->filehdrflags >> 1) & 0x01) /* known number of pages */ + fip->numofpages = read4bytes(fip->file); + /* --- at end of file header --- */ +} + +@ @c +static void checkseghdrflags(SEGINFO * sip) +{ + sip->endofstripeflag = false; + sip->endofpageflag = false; + sip->pageinfoflag = false; + sip->endoffileflag = false; + /* 7.3 Segment types */ + switch (sip->seghdrflags & 0x3f) { + case M_SymbolDictionary: + case M_IntermediateTextRegion: + case M_ImmediateTextRegion: + case M_ImmediateLosslessTextRegion: + case M_PatternDictionary: + case M_IntermediateHalftoneRegion: + case M_ImmediateHalftoneRegion: + case M_ImmediateLosslessHalftoneRegion: + case M_IntermediateGenericRegion: + case M_ImmediateGenericRegion: + case M_ImmediateLosslessGenericRegion: + case M_IntermediateGenericRefinementRegion: + case M_ImmediateGenericRefinementRegion: + case M_ImmediateLosslessGenericRefinementRegion: + break; + case M_PageInformation: + sip->pageinfoflag = true; + break; + case M_EndOfPage: + sip->endofpageflag = true; + break; + case M_EndOfStripe: + sip->endofstripeflag = true; + break; + case M_EndOfFile: + sip->endoffileflag = true; + break; + case M_Profiles: + case M_Tables: + case M_Extension: + break; + default: + pdftex_fail + ("checkseghdrflags(): unknown segment type in JBIG2 image file"); + break; + } +} + +@ for first reading of file; return value tells if header been read + +@c +static boolean readseghdr(FILEINFO * fip, SEGINFO * sip) +{ + unsigned int i; + sip->hdrstart = xftell(fip->file, fip->filepath); + if (fip->sequentialaccess && sip->hdrstart == (unsigned) fip->filesize) + return false; /* no endoffileflag is ok for sequentialaccess */ +#ifdef DEBUG + printf("\nhdrstart %d\n", sip->hdrstart); +#endif + /* 7.2.2 Segment number */ + sip->segnum = read4bytes(fip->file); +#ifdef DEBUG + printf(" segnum %d\n", sip->segnum); +#endif + /* 7.2.3 Segment header flags */ + sip->seghdrflags = (unsigned int) ygetc(fip->file); +#ifdef DEBUG + printf(" hdrflags %d\n", sip->seghdrflags & 0x3f); +#endif + checkseghdrflags(sip); + if (fip->sequentialaccess && sip->endoffileflag) /* accept shorter segment, */ + return true; /* makes it compliant with Example 3.4 of PDFRef. 5th ed. */ + sip->pageassocsizeflag = ((sip->seghdrflags >> 6) & 0x01) ? true : false; + /* 7.2.4 Referred-to segment count and retention flags */ + sip->reftosegcount = (unsigned int) ygetc(fip->file); + sip->countofrefered = sip->reftosegcount >> 5; + if (sip->countofrefered < 5) + sip->fieldlen = 1; + else { + sip->fieldlen = 5 + sip->countofrefered / 8; + xfseek(fip->file, sip->fieldlen - 1, SEEK_CUR, fip->filepath); + } + /* 7.2.5 Referred-to segment numbers */ + if (sip->segnum <= 256) + sip->segnumwidth = 1; + else if (sip->segnum <= 65536) + sip->segnumwidth = 2; + else + sip->segnumwidth = 4; + for (i = 0; i < sip->countofrefered; i++) { + switch (sip->segnumwidth) { + case 1: + (void) ygetc(fip->file); + break; + case 2: + (void) read2bytes(fip->file); + break; + case 4: + (void) read4bytes(fip->file); + break; + } + } + /* 7.2.6 Segment page association */ + if (sip->pageassocsizeflag) + sip->segpage = (long int) read4bytes(fip->file); + else + sip->segpage = ygetc(fip->file); + /* 7.2.7 Segment data length */ + sip->segdatalen = read4bytes(fip->file); + sip->hdrend = (unsigned long) xftello(fip->file, fip->filepath); + /* ---- at end of segment header ---- */ + return true; +} + +@ @c +static void checkseghdr(FILEINFO * fip, SEGINFO * sip); + +static void markpage0seg(FILEINFO * fip, unsigned long referedseg) +{ + PAGEINFO *pip; + SEGINFO *sip; + pip = fip->page0.first->d; + sip = find_seginfo(&(pip->segments), referedseg); + if (sip != NULL) { + if (!sip->refers && sip->countofrefered > 0) + checkseghdr(fip, sip); + sip->isrefered = true; + } +} + +@ for writing, marks refered page0 segments, sets segpage > 0 to 1 + +@c +static void writeseghdr(PDF pdf, FILEINFO * fip, SEGINFO * sip) +{ + unsigned int i; + unsigned long referedseg = 0; + /* 7.2.2 Segment number */ + /* 7.2.3 Segment header flags */ + /* 7.2.4 Referred-to segment count and retention flags */ + for (i = 0; i < 5 + sip->fieldlen; i++) + pdf_out(pdf, ygetc(fip->file)); + /* 7.2.5 Referred-to segment numbers */ + for (i = 0; i < sip->countofrefered; i++) { + switch (sip->segnumwidth) { + case 1: + referedseg = (unsigned long) ygetc(fip->file); + pdf_out(pdf, referedseg); + break; + case 2: + referedseg = read2bytes(fip->file); + pdf_out(pdf, (referedseg >> 8) & 0xff); + pdf_out(pdf, referedseg & 0xff); + break; + case 4: + referedseg = read4bytes(fip->file); + pdf_out(pdf, (referedseg >> 24) & 0xff); + pdf_out(pdf, (referedseg >> 16) & 0xff); + pdf_out(pdf, (referedseg >> 8) & 0xff); + pdf_out(pdf, referedseg & 0xff); + break; + } + if (fip->page0.last != NULL && !sip->refers) + markpage0seg(fip, referedseg); + } + if (sip->countofrefered > 0) + sip->refers = true; + /* 7.2.6 Segment page association */ + if (sip->pageassocsizeflag) + for (i = 0; i < 3; i++) { + (void) ygetc(fip->file); + pdf_out(pdf, 0); + } + (void) ygetc(fip->file); + pdf_out(pdf, (unsigned char) ((sip->segpage > 0) ? 1 : 0)); + /* 7.2.7 Segment data length */ + for (i = 0; i < 4; i++) + pdf_out(pdf, ygetc(fip->file)); + /* ---- at end of segment header ---- */ +} + +@ for recursive marking of refered page0 segments +@c +static void checkseghdr(FILEINFO * fip, SEGINFO * sip) +{ + unsigned int i; + unsigned long referedseg = 0; + /* 7.2.2 Segment number */ + /* 7.2.3 Segment header flags */ + /* 7.2.4 Referred-to segment count and retention flags */ + xfseek(fip->file, 5 + sip->fieldlen, SEEK_CUR, fip->filepath); + /* 7.2.5 Referred-to segment numbers */ + for (i = 0; i < sip->countofrefered; i++) { + switch (sip->segnumwidth) { + case 1: + referedseg = (unsigned long) ygetc(fip->file); + break; + case 2: + referedseg = read2bytes(fip->file); + break; + case 4: + referedseg = read4bytes(fip->file); + break; + } + if (!sip->refers) + markpage0seg(fip, referedseg); + } + if (sip->countofrefered > 0) + sip->refers = true; + /* 7.2.6 Segment page association */ + /* 7.2.7 Segment data length */ + if (sip->pageassocsizeflag) + xfseek(fip->file, 8, SEEK_CUR, fip->filepath); + else + xfseek(fip->file, 5, SEEK_CUR, fip->filepath); + /* ---- at end of segment header ---- */ +} + +@ @c +static unsigned long findstreamstart(FILEINFO * fip) +{ + SEGINFO tmp; + assert(!fip->sequentialaccess); /* D.2 Random-access organisation */ + do /* find random-access stream start */ + (void) readseghdr(fip, &tmp); + while (!tmp.endoffileflag); + fip->streamstart = tmp.hdrend; + readfilehdr(fip); + return fip->streamstart; +} + +@ @c +static void rd_jbig2_info(FILEINFO * fip) +{ + unsigned long seekdist = 0; /* for sequential-access only */ + unsigned long streampos = 0; /* for random-access only */ + unsigned long currentpage = 0; + boolean sipavail = false; + PAGEINFO *pip; + SEGINFO *sip = NULL; + LIST *plp, *slp; + fip->file = xfopen(fip->filepath, FOPEN_RBIN_MODE); + readfilehdr(fip); + if (!fip->sequentialaccess) /* D.2 Random-access organisation */ + streampos = findstreamstart(fip); + while (true) { /* loop over segments */ + if (!sipavail) { + sip = xtalloc(1, SEGINFO); + sipavail = true; + } + init_seginfo(sip); + if (!readseghdr(fip, sip) || sip->endoffileflag) + break; + if (sip->segpage > 0) { + if (sip->segpage > (int) currentpage) { + plp = litem_append(&(fip->pages)); + plp->last->d = new_pageinfo(); + currentpage = (unsigned long) sip->segpage; + } + pip = fip->pages.last->d; + } else { + if (fip->page0.last == NULL) { + plp = litem_append(&(fip->page0)); + plp->last->d = new_pageinfo(); + } + pip = fip->page0.last->d; + } + if (!sip->endofpageflag) { + slp = litem_append(&(pip->segments)); + slp->last->d = sip; + sipavail = false; + } + if (!fip->sequentialaccess) + sip->datastart = streampos; + else + sip->datastart = sip->hdrend; + sip->dataend = sip->datastart + sip->segdatalen; + if (!fip->sequentialaccess + && (sip->pageinfoflag || sip->endofstripeflag)) + xfseeko(fip->file, (off_t) sip->datastart, SEEK_SET, fip->filepath); + seekdist = sip->segdatalen; + /* 7.4.8 Page information segment syntax */ + if (sip->pageinfoflag) { + pip->pagenum = (unsigned long) sip->segpage; + pip->width = (unsigned) read4bytes(fip->file); + pip->height = (unsigned) read4bytes(fip->file); + pip->xres = (unsigned) read4bytes(fip->file); + pip->yres = (unsigned) read4bytes(fip->file); + pip->pagesegmentflags = (unsigned) ygetc(fip->file); + /* 7.4.8.6 Page striping information */ + pip->stripinginfo = read2bytes(fip->file); + seekdist -= 19; + } + if (sip->endofstripeflag) { + pip->stripedheight = (unsigned) read4bytes(fip->file); + seekdist -= 4; + } + if (!fip->sequentialaccess + && (sip->pageinfoflag || sip->endofstripeflag)) + xfseeko(fip->file, (off_t) sip->hdrend, SEEK_SET, fip->filepath); + if (!fip->sequentialaccess) + streampos += sip->segdatalen; + if (fip->sequentialaccess) + xfseeko(fip->file, (off_t) seekdist, SEEK_CUR, fip->filepath); + if (sip->endofpageflag && currentpage && (pip->stripinginfo >> 15)) + pip->height = pip->stripedheight; + } + fip->phase = HAVEINFO; + if (sipavail) + xfree(sip); + xfclose(fip->file, fip->filepath); +} + +@ @c +static void wr_jbig2(PDF pdf, FILEINFO * fip, unsigned long page) +{ + LITEM *slip; + PAGEINFO *pip; + SEGINFO *sip; + unsigned long i; + if (page > 0) { + pip = find_pageinfo(&(fip->pages), page); + assert(pip != NULL); + pdf_puts(pdf, "/Type /XObject\n/Subtype /Image\n"); + pdf_printf(pdf, "/Width %i\n", pip->width); + pdf_printf(pdf, "/Height %i\n", pip->height); + pdf_puts(pdf, "/ColorSpace /DeviceGray\n"); + pdf_puts(pdf, "/BitsPerComponent 1\n"); + pdf_printf(pdf, "/Length %lu\n", + getstreamlen(pip->segments.first, true)); + pdf_puts(pdf, "/Filter [/JBIG2Decode]\n"); + if (fip->page0.last != NULL) { + if (fip->pdfpage0objnum == 0) { + pdf_create_obj(pdf, obj_type_others, 0); + fip->pdfpage0objnum = (unsigned long) pdf->obj_ptr; + } + pdf_printf(pdf, "/DecodeParms [<< /JBIG2Globals %lu 0 R >>]\n", + fip->pdfpage0objnum); + } + } else { + pip = find_pageinfo(&(fip->page0), page); + assert(pip != NULL); + pdf_begin_dict(pdf, (int) fip->pdfpage0objnum, 0); + pdf_printf(pdf, "/Length %lu\n", + getstreamlen(pip->segments.first, false)); + } + pdf_puts(pdf, ">>\n"); + pdf_puts(pdf, "stream\n"); + fip->file = xfopen(fip->filepath, FOPEN_RBIN_MODE); + for (slip = pip->segments.first; slip != NULL; slip = slip->next) { /* loop over page segments */ + sip = slip->d; + if (sip->isrefered || page > 0) { + xfseeko(fip->file, (off_t) sip->hdrstart, SEEK_SET, fip->filepath); + /* mark refered-to page 0 segments, change segpages > 1 to 1 */ + writeseghdr(pdf, fip, sip); + xfseeko(fip->file, (off_t) sip->datastart, SEEK_SET, fip->filepath); + for (i = sip->datastart; i < sip->dataend; i++) + pdf_out(pdf, ygetc(fip->file)); + } + } + pdf_end_stream(pdf); + xfclose(fip->file, fip->filepath); +} + +@ @c +void read_jbig2_info(image_dict * idict) +{ + FILEINFO *fip, tmp; + PAGEINFO *pip; + void **aa; + assert(idict != NULL); + img_type(idict) = IMG_TYPE_JBIG2; + if (img_pagenum(idict) < 1) + pdftex_fail + ("read_jbig2_info(): page %d not in JBIG2 image file; page must be > 0", + (int) img_pagenum(idict)); + if (file_tree == NULL) { + file_tree = avl_create(comp_file_entry, NULL, &avl_xallocator); + assert(file_tree != NULL); + } + tmp.filepath = img_filepath(idict); + fip = (FILEINFO *) avl_find(file_tree, &tmp); + if (fip == NULL) { + fip = new_fileinfo(); + fip->filepath = xstrdup(img_filepath(idict)); + aa = avl_probe(file_tree, fip); + assert(aa != NULL); + } + if (fip->phase == INITIAL) { + rd_jbig2_info(fip); + pages_maketree(&(fip->pages)); + if (fip->page0.last != NULL) { + pages_maketree(&(fip->page0)); + pip = fip->page0.first->d; + segments_maketree(&(pip->segments)); + } + } + pip = find_pageinfo(&(fip->pages), (unsigned long) img_pagenum(idict)); + if (pip == NULL) + pdftex_fail("read_jbig2_info(): page %d not found in JBIG2 image file", + (int) img_pagenum(idict)); + img_totalpages(idict) = (int) fip->numofpages; + img_xsize(idict) = (int) pip->width; + img_ysize(idict) = (int) pip->height; + img_xres(idict) = (int) (pip->xres * 0.0254 + 0.5); + img_yres(idict) = (int) (pip->yres * 0.0254 + 0.5); + img_colordepth(idict) = 1; +} + +@ @c +void write_jbig2(PDF pdf, image_dict * idict) +{ + FILEINFO *fip, tmp; + PAGEINFO *pip; + assert(idict != NULL); + assert(file_tree != NULL); + tmp.filepath = img_filepath(idict); + fip = (FILEINFO *) avl_find(file_tree, &tmp); + assert(fip != NULL); + assert(fip->phase == HAVEINFO); /* don't write before |rd_jbig2_info()| call */ + pip = find_pageinfo(&(fip->pages), (unsigned long) img_pagenum(idict)); + assert(pip != NULL); + wr_jbig2(pdf, fip, pip->pagenum); + img_file(idict) = NULL; +} + +@ @c +void flush_jbig2_page0_objects(PDF pdf) +{ + FILEINFO *fip; + struct avl_traverser t; + if (file_tree != NULL) { + avl_t_init(&t, file_tree); + for (fip = avl_t_first(&t, file_tree); fip != NULL; + fip = avl_t_next(&t)) { + if (fip->page0.last != NULL) + wr_jbig2(pdf, fip, 0); + } + } +} diff --git a/Build/source/texk/web2c/luatexdir/image/writejpg.c b/Build/source/texk/web2c/luatexdir/image/writejpg.c deleted file mode 100644 index 187c55ea6c2..00000000000 --- a/Build/source/texk/web2c/luatexdir/image/writejpg.c +++ /dev/null @@ -1,281 +0,0 @@ -/* writejpg.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include -#include "ptexlib.h" -#include "image.h" -#include "writejpg.h" - -static const char _svn_version[] = - "$Id: writejpg.c 2320 2009-04-18 08:52:30Z hhenkel $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/image/writejpg.c $"; - -#define JPG_GRAY 1 /* Gray color space, use /DeviceGray */ -#define JPG_RGB 3 /* RGB color space, use /DeviceRGB */ -#define JPG_CMYK 4 /* CMYK color space, use /DeviceCMYK */ - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, /* baseline DCT */ - M_SOF1 = 0xc1, /* extended sequential DCT */ - M_SOF2 = 0xc2, /* progressive DCT */ - M_SOF3 = 0xc3, /* lossless (sequential) */ - - M_SOF5 = 0xc5, /* differential sequential DCT */ - M_SOF6 = 0xc6, /* differential progressive DCT */ - M_SOF7 = 0xc7, /* differential lossless */ - - M_JPG = 0xc8, /* JPEG extensions */ - M_SOF9 = 0xc9, /* extended sequential DCT */ - M_SOF10 = 0xca, /* progressive DCT */ - M_SOF11 = 0xcb, /* lossless (sequential) */ - - M_SOF13 = 0xcd, /* differential sequential DCT */ - M_SOF14 = 0xce, /* differential progressive DCT */ - M_SOF15 = 0xcf, /* differential lossless */ - - M_DHT = 0xc4, /* define Huffman tables */ - - M_DAC = 0xcc, /* define arithmetic conditioning table */ - - M_RST0 = 0xd0, /* restart */ - M_RST1 = 0xd1, /* restart */ - M_RST2 = 0xd2, /* restart */ - M_RST3 = 0xd3, /* restart */ - M_RST4 = 0xd4, /* restart */ - M_RST5 = 0xd5, /* restart */ - M_RST6 = 0xd6, /* restart */ - M_RST7 = 0xd7, /* restart */ - - M_SOI = 0xd8, /* start of image */ - M_EOI = 0xd9, /* end of image */ - M_SOS = 0xda, /* start of scan */ - M_DQT = 0xdb, /* define quantization tables */ - M_DNL = 0xdc, /* define number of lines */ - M_DRI = 0xdd, /* define restart interval */ - M_DHP = 0xde, /* define hierarchical progression */ - M_EXP = 0xdf, /* expand reference image(s) */ - - M_APP0 = 0xe0, /* application marker, used for JFIF */ - M_APP1 = 0xe1, /* application marker */ - M_APP2 = 0xe2, /* application marker */ - M_APP3 = 0xe3, /* application marker */ - M_APP4 = 0xe4, /* application marker */ - M_APP5 = 0xe5, /* application marker */ - M_APP6 = 0xe6, /* application marker */ - M_APP7 = 0xe7, /* application marker */ - M_APP8 = 0xe8, /* application marker */ - M_APP9 = 0xe9, /* application marker */ - M_APP10 = 0xea, /* application marker */ - M_APP11 = 0xeb, /* application marker */ - M_APP12 = 0xec, /* application marker */ - M_APP13 = 0xed, /* application marker */ - M_APP14 = 0xee, /* application marker, used by Adobe */ - M_APP15 = 0xef, /* application marker */ - - M_JPG0 = 0xf0, /* reserved for JPEG extensions */ - M_JPG13 = 0xfd, /* reserved for JPEG extensions */ - M_COM = 0xfe, /* comment */ - - M_TEM = 0x01, /* temporary use */ - - M_ERROR = 0x100 /* dummy marker, internal use only */ -} JPEG_MARKER; - -static JPG_UINT16 read2bytes(FILE * f) -{ - int c = xgetc(f); - return (c << 8) + xgetc(f); -} - -static void close_and_cleanup_jpg(image_dict * idict) -{ - assert(idict != NULL); - assert(img_file(idict) != NULL); - assert(img_filepath(idict) != NULL); - xfclose(img_file(idict), img_filepath(idict)); - img_file(idict) = NULL; - assert(img_jpg_ptr(idict) != NULL); - xfree(img_jpg_ptr(idict)); - img_jpg_ptr(idict) = NULL; -} - -void read_jpg_info(image_dict * idict, img_readtype_e readtype) -{ - int i, units = 0; - unsigned char jpg_id[] = "JFIF"; - assert(idict != NULL); - assert(img_type(idict) == IMG_TYPE_JPG); - img_totalpages(idict) = 1; - img_pagenum(idict) = 1; - img_xres(idict) = img_yres(idict) = 0; - assert(img_file(idict) == NULL); - img_file(idict) = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); - assert(img_jpg_ptr(idict) == NULL); - img_jpg_ptr(idict) = xtalloc(1, jpg_img_struct); - xfseek(img_file(idict), 0, SEEK_END, img_filepath(idict)); - img_jpg_ptr(idict)->length = xftell(img_file(idict), img_filepath(idict)); - xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); - if (read2bytes(img_file(idict)) != 0xFFD8) - pdftex_fail("reading JPEG image failed (no JPEG header found)"); - /* currently only true JFIF files allow extracting img_xres and img_yres */ - if (read2bytes(img_file(idict)) == 0xFFE0) { /* check for JFIF */ - (void) read2bytes(img_file(idict)); - for (i = 0; i < 5; i++) { - if (xgetc(img_file(idict)) != jpg_id[i]) - break; - } - if (i == 5) { /* it's JFIF */ - read2bytes(img_file(idict)); - units = xgetc(img_file(idict)); - img_xres(idict) = read2bytes(img_file(idict)); - img_yres(idict) = read2bytes(img_file(idict)); - switch (units) { - case 1: - break; /* pixels per inch */ - case 2: - img_xres(idict) *= 2.54; - img_yres(idict) *= 2.54; - break; /* pixels per cm */ - default: - img_xres(idict) = img_yres(idict) = 0; - break; - } - } - } - xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); - while (1) { - if (feof(img_file(idict))) - pdftex_fail("reading JPEG image failed (premature file end)"); - if (fgetc(img_file(idict)) != 0xFF) - pdftex_fail("reading JPEG image failed (no marker found)"); - switch (xgetc(img_file(idict))) { - case M_SOF5: - case M_SOF6: - case M_SOF7: - case M_SOF9: - case M_SOF10: - case M_SOF11: - case M_SOF13: - case M_SOF14: - case M_SOF15: - pdftex_fail("unsupported type of compression"); - case M_SOF2: - if (fixed_pdf_minor_version <= 2) - pdftex_fail("cannot use progressive DCT with PDF-1.2"); - case M_SOF0: - case M_SOF1: - case M_SOF3: - (void) read2bytes(img_file(idict)); /* read segment length */ - img_colordepth(idict) = xgetc(img_file(idict)); - img_ysize(idict) = read2bytes(img_file(idict)); - img_xsize(idict) = read2bytes(img_file(idict)); - img_jpg_color(idict) = xgetc(img_file(idict)); - xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); - switch (img_jpg_color(idict)) { - case JPG_GRAY: - img_color(idict) = IMAGE_COLOR_B; - break; - case JPG_RGB: - img_color(idict) = IMAGE_COLOR_C; - break; - case JPG_CMYK: - img_color(idict) = IMAGE_COLOR_C; - break; - default: - pdftex_fail("Unsupported color space %i", - (int) img_jpg_color(idict)); - } - if (readtype == IMG_CLOSEINBETWEEN) - close_and_cleanup_jpg(idict); - return; - case M_SOI: /* ignore markers without parameters */ - case M_EOI: - case M_TEM: - case M_RST0: - case M_RST1: - case M_RST2: - case M_RST3: - case M_RST4: - case M_RST5: - case M_RST6: - case M_RST7: - break; - default: /* skip variable length markers */ - xfseek(img_file(idict), read2bytes(img_file(idict)) - 2, - SEEK_CUR, img_filepath(idict)); - break; - } - } - assert(0); -} - -static void reopen_jpg(image_dict * idict) -{ - integer width, height, xres, yres; - width = img_xsize(idict); - height = img_ysize(idict); - xres = img_xres(idict); - yres = img_yres(idict); - read_jpg_info(idict, IMG_KEEPOPEN); - if (width != img_xsize(idict) || height != img_ysize(idict) - || xres != img_xres(idict) || yres != img_yres(idict)) - pdftex_fail("writejpg: image dimensions have changed"); -} - -void write_jpg(image_dict * idict) -{ - long unsigned l; - FILE *f; - assert(idict != NULL); - if (img_file(idict) == NULL) - reopen_jpg(idict); - assert(img_jpg_ptr(idict) != NULL); - pdf_puts("/Type /XObject\n/Subtype /Image\n"); - if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) - pdf_printf("%s\n", img_attr(idict)); - pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n/Length %i\n", - (int) img_xsize(idict), - (int) img_ysize(idict), - (int) img_colordepth(idict), (int) img_jpg_ptr(idict)->length); - pdf_puts("/ColorSpace "); - if (img_colorspace(idict) != 0) { - pdf_printf("%i 0 R\n", (int) img_colorspace(idict)); - } else { - switch (img_jpg_color(idict)) { - case JPG_GRAY: - pdf_puts("/DeviceGray\n"); - break; - case JPG_RGB: - pdf_puts("/DeviceRGB\n"); - break; - case JPG_CMYK: - pdf_puts("/DeviceCMYK\n/Decode [1 0 1 0 1 0 1 0]\n"); - break; - default: - pdftex_fail("Unsupported color space %i", - (int) img_jpg_color(idict)); - } - } - pdf_puts("/Filter /DCTDecode\n>>\nstream\n"); - for (l = img_jpg_ptr(idict)->length, f = img_file(idict); l > 0; l--) - pdfout(xgetc(f)); - pdf_end_stream(); - close_and_cleanup_jpg(idict); -} diff --git a/Build/source/texk/web2c/luatexdir/image/writejpg.h b/Build/source/texk/web2c/luatexdir/image/writejpg.h index bd497c9e114..d3c7cdb806a 100644 --- a/Build/source/texk/web2c/luatexdir/image/writejpg.h +++ b/Build/source/texk/web2c/luatexdir/image/writejpg.h @@ -18,14 +18,14 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: writejpg.h 2327 2009-04-18 12:47:21Z hhenkel $ */ +/* $Id: writejpg.h 2653 2009-06-27 14:30:05Z taco $ */ #ifndef WRITEJPG_H # define WRITEJPG_H # include "image.h" -void read_jpg_info(image_dict *, img_readtype_e); -void write_jpg(image_dict *); +void read_jpg_info(PDF, image_dict *, img_readtype_e); +void write_jpg(PDF, image_dict *); #endif /* WRITEJPG_H */ diff --git a/Build/source/texk/web2c/luatexdir/image/writejpg.w b/Build/source/texk/web2c/luatexdir/image/writejpg.w new file mode 100644 index 00000000000..cb0e2fedcde --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/image/writejpg.w @@ -0,0 +1,294 @@ +% writejpg.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: writejpg.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/image/writejpg.w $"; + +#include +#include "ptexlib.h" +#include "image/image.h" + +@ @c +#define JPG_GRAY 1 /* Gray color space, use /DeviceGray */ +#define JPG_RGB 3 /* RGB color space, use /DeviceRGB */ +#define JPG_CMYK 4 /* CMYK color space, use /DeviceCMYK */ + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, /* baseline DCT */ + M_SOF1 = 0xc1, /* extended sequential DCT */ + M_SOF2 = 0xc2, /* progressive DCT */ + M_SOF3 = 0xc3, /* lossless (sequential) */ + + M_SOF5 = 0xc5, /* differential sequential DCT */ + M_SOF6 = 0xc6, /* differential progressive DCT */ + M_SOF7 = 0xc7, /* differential lossless */ + + M_JPG = 0xc8, /* JPEG extensions */ + M_SOF9 = 0xc9, /* extended sequential DCT */ + M_SOF10 = 0xca, /* progressive DCT */ + M_SOF11 = 0xcb, /* lossless (sequential) */ + + M_SOF13 = 0xcd, /* differential sequential DCT */ + M_SOF14 = 0xce, /* differential progressive DCT */ + M_SOF15 = 0xcf, /* differential lossless */ + + M_DHT = 0xc4, /* define Huffman tables */ + + M_DAC = 0xcc, /* define arithmetic conditioning table */ + + M_RST0 = 0xd0, /* restart */ + M_RST1 = 0xd1, /* restart */ + M_RST2 = 0xd2, /* restart */ + M_RST3 = 0xd3, /* restart */ + M_RST4 = 0xd4, /* restart */ + M_RST5 = 0xd5, /* restart */ + M_RST6 = 0xd6, /* restart */ + M_RST7 = 0xd7, /* restart */ + + M_SOI = 0xd8, /* start of image */ + M_EOI = 0xd9, /* end of image */ + M_SOS = 0xda, /* start of scan */ + M_DQT = 0xdb, /* define quantization tables */ + M_DNL = 0xdc, /* define number of lines */ + M_DRI = 0xdd, /* define restart interval */ + M_DHP = 0xde, /* define hierarchical progression */ + M_EXP = 0xdf, /* expand reference image(s) */ + + M_APP0 = 0xe0, /* application marker, used for JFIF */ + M_APP1 = 0xe1, /* application marker */ + M_APP2 = 0xe2, /* application marker */ + M_APP3 = 0xe3, /* application marker */ + M_APP4 = 0xe4, /* application marker */ + M_APP5 = 0xe5, /* application marker */ + M_APP6 = 0xe6, /* application marker */ + M_APP7 = 0xe7, /* application marker */ + M_APP8 = 0xe8, /* application marker */ + M_APP9 = 0xe9, /* application marker */ + M_APP10 = 0xea, /* application marker */ + M_APP11 = 0xeb, /* application marker */ + M_APP12 = 0xec, /* application marker */ + M_APP13 = 0xed, /* application marker */ + M_APP14 = 0xee, /* application marker, used by Adobe */ + M_APP15 = 0xef, /* application marker */ + + M_JPG0 = 0xf0, /* reserved for JPEG extensions */ + M_JPG13 = 0xfd, /* reserved for JPEG extensions */ + M_COM = 0xfe, /* comment */ + + M_TEM = 0x01, /* temporary use */ + + M_ERROR = 0x100 /* dummy marker, internal use only */ +} JPEG_MARKER; + +@ @c +static JPG_UINT16 read2bytes(FILE * f) +{ + int c = xgetc(f); + return (JPG_UINT16) ((c << 8) + (int) xgetc(f)); +} + +@ @c +static void close_and_cleanup_jpg(image_dict * idict) +{ + assert(idict != NULL); + assert(img_file(idict) != NULL); + assert(img_filepath(idict) != NULL); + xfclose(img_file(idict), img_filepath(idict)); + img_file(idict) = NULL; + assert(img_jpg_ptr(idict) != NULL); + xfree(img_jpg_ptr(idict)); + img_jpg_ptr(idict) = NULL; +} + +@ @c +void read_jpg_info(PDF pdf, image_dict * idict, img_readtype_e readtype) +{ + int i, units = 0; + unsigned char jpg_id[] = "JFIF"; + assert(idict != NULL); + assert(img_type(idict) == IMG_TYPE_JPG); + img_totalpages(idict) = 1; + img_pagenum(idict) = 1; + img_xres(idict) = img_yres(idict) = 0; + assert(img_file(idict) == NULL); + img_file(idict) = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); + assert(img_jpg_ptr(idict) == NULL); + img_jpg_ptr(idict) = xtalloc(1, jpg_img_struct); + xfseek(img_file(idict), 0, SEEK_END, img_filepath(idict)); + img_jpg_ptr(idict)->length = xftell(img_file(idict), img_filepath(idict)); + xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); + if (read2bytes(img_file(idict)) != 0xFFD8) + pdftex_fail("reading JPEG image failed (no JPEG header found)"); + /* currently only true JFIF files allow extracting |img_xres| and |img_yres| */ + if (read2bytes(img_file(idict)) == 0xFFE0) { /* check for JFIF */ + (void) read2bytes(img_file(idict)); + for (i = 0; i < 5; i++) { + if (xgetc(img_file(idict)) != jpg_id[i]) + break; + } + if (i == 5) { /* it's JFIF */ + read2bytes(img_file(idict)); + units = xgetc(img_file(idict)); + img_xres(idict) = (int) read2bytes(img_file(idict)); + img_yres(idict) = (int) read2bytes(img_file(idict)); + switch (units) { + case 1: + break; /* pixels per inch */ + case 2: + img_xres(idict) = (int) ((double) img_xres(idict) * 2.54); + img_yres(idict) = (int) ((double) img_yres(idict) * 2.54); + break; /* pixels per cm */ + default: + img_xres(idict) = img_yres(idict) = 0; + break; + } + } + /* if either xres or yres is 0 but the other isn't, set it to the value of the other */ + if ((img_xres(idict) == 0) && (img_yres(idict) != 0)) { + img_xres(idict) = img_yres(idict); + } + if ((img_yres(idict) == 0) && (img_xres(idict) != 0)) { + img_yres(idict) = img_xres(idict); + } + } + xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); + while (1) { + if (feof(img_file(idict))) + pdftex_fail("reading JPEG image failed (premature file end)"); + if (fgetc(img_file(idict)) != 0xFF) + pdftex_fail("reading JPEG image failed (no marker found)"); + switch (xgetc(img_file(idict))) { + case M_SOF5: + case M_SOF6: + case M_SOF7: + case M_SOF9: + case M_SOF10: + case M_SOF11: + case M_SOF13: + case M_SOF14: + case M_SOF15: + pdftex_fail("unsupported type of compression"); + case M_SOF2: + if (pdf->minor_version <= 2) + pdftex_fail("cannot use progressive DCT with PDF-1.2"); + case M_SOF0: + case M_SOF1: + case M_SOF3: + (void) read2bytes(img_file(idict)); /* read segment length */ + img_colordepth(idict) = xgetc(img_file(idict)); + img_ysize(idict) = (int) read2bytes(img_file(idict)); + img_xsize(idict) = (int) read2bytes(img_file(idict)); + img_jpg_color(idict) = xgetc(img_file(idict)); + xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); + switch (img_jpg_color(idict)) { + case JPG_GRAY: + img_procset(idict) |= PROCSET_IMAGE_B; + break; + case JPG_RGB: + img_procset(idict) |= PROCSET_IMAGE_C; + break; + case JPG_CMYK: + img_procset(idict) |= PROCSET_IMAGE_C; + break; + default: + pdftex_fail("Unsupported color space %i", + (int) img_jpg_color(idict)); + } + if (readtype == IMG_CLOSEINBETWEEN) + close_and_cleanup_jpg(idict); + return; + case M_SOI: /* ignore markers without parameters */ + case M_EOI: + case M_TEM: + case M_RST0: + case M_RST1: + case M_RST2: + case M_RST3: + case M_RST4: + case M_RST5: + case M_RST6: + case M_RST7: + break; + default: /* skip variable length markers */ + xfseek(img_file(idict), read2bytes(img_file(idict)) - 2, + SEEK_CUR, img_filepath(idict)); + break; + } + } + assert(0); +} + +@ @c +static void reopen_jpg(PDF pdf, image_dict * idict) +{ + int width, height, xres, yres; + width = img_xsize(idict); + height = img_ysize(idict); + xres = img_xres(idict); + yres = img_yres(idict); + read_jpg_info(pdf, idict, IMG_KEEPOPEN); + if (width != img_xsize(idict) || height != img_ysize(idict) + || xres != img_xres(idict) || yres != img_yres(idict)) + pdftex_fail("writejpg: image dimensions have changed"); +} + +@ @c +void write_jpg(PDF pdf, image_dict * idict) +{ + long unsigned l; + FILE *f; + assert(idict != NULL); + if (img_file(idict) == NULL) + reopen_jpg(pdf, idict); + assert(img_jpg_ptr(idict) != NULL); + pdf_puts(pdf, "/Type /XObject\n/Subtype /Image\n"); + if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) + pdf_printf(pdf, "%s\n", img_attr(idict)); + pdf_printf(pdf, "/Width %i\n/Height %i\n/BitsPerComponent %i\n/Length %i\n", + (int) img_xsize(idict), + (int) img_ysize(idict), + (int) img_colordepth(idict), (int) img_jpg_ptr(idict)->length); + pdf_puts(pdf, "/ColorSpace "); + if (img_colorspace(idict) != 0) { + pdf_printf(pdf, "%i 0 R\n", (int) img_colorspace(idict)); + } else { + switch (img_jpg_color(idict)) { + case JPG_GRAY: + pdf_puts(pdf, "/DeviceGray\n"); + break; + case JPG_RGB: + pdf_puts(pdf, "/DeviceRGB\n"); + break; + case JPG_CMYK: + pdf_puts(pdf, "/DeviceCMYK\n/Decode [1 0 1 0 1 0 1 0]\n"); + break; + default: + pdftex_fail("Unsupported color space %i", + (int) img_jpg_color(idict)); + } + } + pdf_puts(pdf, "/Filter /DCTDecode\n>>\nstream\n"); + for (l = img_jpg_ptr(idict)->length, f = img_file(idict); l > 0; l--) + pdf_out(pdf, xgetc(f)); + pdf_end_stream(pdf); + close_and_cleanup_jpg(idict); +} diff --git a/Build/source/texk/web2c/luatexdir/image/writepng.c b/Build/source/texk/web2c/luatexdir/image/writepng.c deleted file mode 100644 index 154a8a351c2..00000000000 --- a/Build/source/texk/web2c/luatexdir/image/writepng.c +++ /dev/null @@ -1,673 +0,0 @@ -/* writepng.c - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2009 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include -#include "ptexlib.h" -#include "image.h" -#include "writepng.h" - -static const char _svn_version[] = - "$Id: writepng.c 2317 2009-04-18 00:12:18Z hhenkel $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/image/writepng.c $"; - -static int transparent_page_group = -1; - -static void close_and_cleanup_png(image_dict * idict) -{ - assert(idict != NULL); - assert(img_file(idict) != NULL); - assert(img_filepath(idict) != NULL); - xfclose(img_file(idict), img_filepath(idict)); - img_file(idict) = NULL; - assert(img_png_ptr(idict) != NULL); - png_destroy_read_struct(&(img_png_png_ptr(idict)), - &(img_png_info_ptr(idict)), NULL); - xfree(img_png_ptr(idict)); - img_png_ptr(idict) = NULL; -} - -void read_png_info(image_dict * idict, img_readtype_e readtype) -{ - double gamma; - png_structp png_p; - png_infop info_p; - assert(idict != NULL); - assert(img_type(idict) == IMG_TYPE_PNG); - img_totalpages(idict) = 1; - img_pagenum(idict) = 1; - img_xres(idict) = img_yres(idict) = 0; - assert(img_file(idict) == NULL); - img_file(idict) = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); - assert(img_png_ptr(idict) == NULL); - img_png_ptr(idict) = xtalloc(1, png_img_struct); - if ((png_p = png_create_read_struct(PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL)) == NULL) - pdftex_fail("libpng: png_create_read_struct() failed"); - img_png_png_ptr(idict) = png_p; - if ((info_p = png_create_info_struct(png_p)) == NULL) - pdftex_fail("libpng: png_create_info_struct() failed"); - img_png_info_ptr(idict) = info_p; - if (setjmp(png_p->jmpbuf)) - pdftex_fail("libpng: internal error"); - png_init_io(png_p, img_file(idict)); - png_read_info(png_p, info_p); - /* simple transparency support */ - if (png_get_valid(png_p, info_p, PNG_INFO_tRNS)) { - png_set_tRNS_to_alpha(png_p); - } - /* alpha channel support */ - if (fixed_pdf_minor_version < 4 && png_p->color_type | PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_p); - /* 16bit depth support */ - if (fixed_pdf_minor_version < 5) - fixed_image_hicolor = 0; - if (info_p->bit_depth == 16 && !fixed_image_hicolor) - png_set_strip_16(png_p); - /* gamma support */ - if (fixed_image_apply_gamma) { - if (png_get_gAMA(png_p, info_p, &gamma)) - png_set_gamma(png_p, (fixed_gamma / 1000.0), gamma); - else - png_set_gamma(png_p, (fixed_gamma / 1000.0), - (1000.0 / fixed_image_gamma)); - } - /* reset structure */ - png_read_update_info(png_p, info_p); - /* resolution support */ - img_xsize(idict) = info_p->width; - img_ysize(idict) = info_p->height; - if (info_p->valid & PNG_INFO_pHYs) { - img_xres(idict) = - round(0.0254 * png_get_x_pixels_per_meter(png_p, info_p)); - img_yres(idict) = - round(0.0254 * png_get_y_pixels_per_meter(png_p, info_p)); - } - switch (info_p->color_type) { - case PNG_COLOR_TYPE_PALETTE: - img_color(idict) = IMAGE_COLOR_C | IMAGE_COLOR_I; - break; - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_GRAY_ALPHA: - img_color(idict) = IMAGE_COLOR_B; - break; - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - img_color(idict) = IMAGE_COLOR_C; - break; - default: - pdftex_fail("unsupported type of color_type <%i>", info_p->color_type); - } - img_colordepth(idict) = info_p->bit_depth; - if (readtype == IMG_CLOSEINBETWEEN) - close_and_cleanup_png(idict); -} - -#define write_gray_pixel_16(r) \ - if (j % 4 == 0||j % 4 == 1) pdf_buf[pdf_ptr++] = *r++; \ - else smask[smask_ptr++] = *r++ - -#define write_gray_pixel_8(r) \ - if (j % 2 == 0) pdf_buf[pdf_ptr++] = *r++; \ - else smask[smask_ptr++] = *r++ - -#define write_rgb_pixel_16(r) \ - if (!(j % 8 == 6||j % 8 == 7)) pdf_buf[pdf_ptr++] = *r++; \ - else smask[smask_ptr++] = *r++ - -#define write_rgb_pixel_8(r) \ - if (j % 4 != 3) pdf_buf[pdf_ptr++] = *r++; \ - else smask[smask_ptr++] = *r++ - -#define write_simple_pixel(r) pdf_buf[pdf_ptr++] = *r++ - -#define write_noninterlaced(outmac) \ - for (i = 0; i < (int)info_p->height; i++) { \ - png_read_row(png_p, row, NULL); \ - r = row; \ - k = info_p->rowbytes; \ - while(k > 0) { \ - l = (k > pdf_buf_size)? pdf_buf_size : k; \ - pdfroom(l); \ - for (j = 0; j < l; j++) { \ - outmac; \ - } \ - k -= l; \ - } \ - } - -#define write_interlaced(outmac) \ - for (i = 0; i < (int)info_p->height; i++) { \ - row = rows[i]; \ - k = info_p->rowbytes; \ - while(k > 0) { \ - l = (k > pdf_buf_size)? pdf_buf_size : k;\ - pdfroom(l); \ - for (j = 0; j < l; j++) { \ - outmac; \ - } \ - k -= l; \ - } \ - xfree(rows[i]); \ - } - -static void write_png_palette(image_dict * idict) -{ - int i, j, k, l; - png_structp png_p = img_png_png_ptr(idict); - png_infop info_p = img_png_info_ptr(idict); - png_bytep row, r, *rows; - integer palette_objnum = 0; - if (img_colorspace(idict) != 0) { - pdf_printf("%i 0 R\n", (int) img_colorspace(idict)); - } else { - pdf_create_obj(0, 0); - palette_objnum = obj_ptr; - pdf_printf("[/Indexed /DeviceRGB %i %i 0 R]\n", - (int) (info_p->num_palette - 1), (int) palette_objnum); - } - pdf_begin_stream(); - if (info_p->interlace_type == PNG_INTERLACE_NONE) { - row = xtalloc(info_p->rowbytes, png_byte); - write_noninterlaced(write_simple_pixel(r)); - xfree(row); - } else { - if (info_p->height * info_p->rowbytes >= 10240000L) - pdftex_warn - ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); - rows = xtalloc(info_p->height, png_bytep); - for (i = 0; (unsigned) i < info_p->height; i++) - rows[i] = xtalloc(info_p->rowbytes, png_byte); - png_read_image(png_p, rows); - write_interlaced(write_simple_pixel(row)); - xfree(rows); - } - pdf_end_stream(); - if (palette_objnum > 0) { - pdf_begin_dict(palette_objnum, 0); - pdf_begin_stream(); - for (i = 0; (unsigned) i < info_p->num_palette; i++) { - pdfroom(3); - pdf_buf[pdf_ptr++] = info_p->palette[i].red; - pdf_buf[pdf_ptr++] = info_p->palette[i].green; - pdf_buf[pdf_ptr++] = info_p->palette[i].blue; - } - pdf_end_stream(); - } -} - -static void write_png_gray(image_dict * idict) -{ - int i, j, k, l; - png_structp png_p = img_png_png_ptr(idict); - png_infop info_p = img_png_info_ptr(idict); - png_bytep row, r, *rows; - if (img_colorspace(idict) != 0) { - pdf_printf("%i 0 R\n", (int) img_colorspace(idict)); - } else { - pdf_puts("/DeviceGray\n"); - } - pdf_begin_stream(); - if (info_p->interlace_type == PNG_INTERLACE_NONE) { - row = xtalloc(info_p->rowbytes, png_byte); - write_noninterlaced(write_simple_pixel(r)); - xfree(row); - } else { - if (info_p->height * info_p->rowbytes >= 10240000L) - pdftex_warn - ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); - rows = xtalloc(info_p->height, png_bytep); - for (i = 0; (unsigned) i < info_p->height; i++) - rows[i] = xtalloc(info_p->rowbytes, png_byte); - png_read_image(png_p, rows); - write_interlaced(write_simple_pixel(row)); - xfree(rows); - } - pdf_end_stream(); -} - -static void write_png_gray_alpha(image_dict * idict) -{ - int i, j, k, l; - png_structp png_p = img_png_png_ptr(idict); - png_infop info_p = img_png_info_ptr(idict); - png_bytep row, r, *rows; - integer smask_objnum = 0; - png_bytep smask; - integer smask_ptr = 0; - integer smask_size = 0; - int bitdepth; - if (img_colorspace(idict) != 0) { - pdf_printf("%i 0 R\n", (int) img_colorspace(idict)); - } else { - pdf_puts("/DeviceGray\n"); - } - pdf_create_obj(0, 0); - smask_objnum = obj_ptr; - pdf_printf("/SMask %i 0 R\n", (int) smask_objnum); - smask_size = (info_p->rowbytes / 2) * info_p->height; - smask = xtalloc(smask_size, png_byte); - pdf_begin_stream(); - if (info_p->interlace_type == PNG_INTERLACE_NONE) { - row = xtalloc(info_p->rowbytes, png_byte); - if ((info_p->bit_depth == 16) && fixed_image_hicolor) { - write_noninterlaced(write_gray_pixel_16(r)); - } else { - write_noninterlaced(write_gray_pixel_8(r)); - } - xfree(row); - } else { - if (info_p->height * info_p->rowbytes >= 10240000L) - pdftex_warn - ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); - rows = xtalloc(info_p->height, png_bytep); - for (i = 0; (unsigned) i < info_p->height; i++) - rows[i] = xtalloc(info_p->rowbytes, png_byte); - png_read_image(png_p, rows); - if ((info_p->bit_depth == 16) && fixed_image_hicolor) { - write_interlaced(write_gray_pixel_16(row)); - } else { - write_interlaced(write_gray_pixel_8(row)); - } - xfree(rows); - } - pdf_end_stream(); - pdf_flush(); - /* now write the Smask object */ - bitdepth = (int) info_p->bit_depth; - pdf_begin_dict(smask_objnum, 0); - pdf_puts("/Type /XObject\n/Subtype /Image\n"); - if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) - pdf_printf("%s\n", img_attr(idict)); - pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n", - (int) info_p->width, - (int) info_p->height, (bitdepth == 16 ? 8 : bitdepth)); - pdf_puts("/ColorSpace /DeviceGray\n"); - pdf_begin_stream(); - for (i = 0; i < smask_size; i++) { - if (i % 8 == 0) - pdfroom(8); - pdf_buf[pdf_ptr++] = smask[i]; - if (bitdepth == 16) - i++; - } - pdf_end_stream(); - xfree(smask); -} - -static void write_png_rgb(image_dict * idict) -{ - int i, j, k, l; - png_structp png_p = img_png_png_ptr(idict); - png_infop info_p = img_png_info_ptr(idict); - png_bytep row, r, *rows; - if (img_colorspace(idict) != 0) { - pdf_printf("%i 0 R\n", (int) img_colorspace(idict)); - } else { - pdf_puts("/DeviceRGB\n"); - } - pdf_begin_stream(); - if (info_p->interlace_type == PNG_INTERLACE_NONE) { - row = xtalloc(info_p->rowbytes, png_byte); - write_noninterlaced(write_simple_pixel(r)); - xfree(row); - } else { - if (info_p->height * info_p->rowbytes >= 10240000L) - pdftex_warn - ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); - rows = xtalloc(info_p->height, png_bytep); - for (i = 0; (unsigned) i < info_p->height; i++) - rows[i] = xtalloc(info_p->rowbytes, png_byte); - png_read_image(png_p, rows); - write_interlaced(write_simple_pixel(row)); - xfree(rows); - } - pdf_end_stream(); -} - -static void write_png_rgb_alpha(image_dict * idict) -{ - int i, j, k, l; - png_structp png_p = img_png_png_ptr(idict); - png_infop info_p = img_png_info_ptr(idict); - png_bytep row, r, *rows; - integer smask_objnum = 0; - png_bytep smask; - integer smask_ptr = 0; - integer smask_size = 0; - int bitdepth; - if (img_colorspace(idict) != 0) { - pdf_printf("%i 0 R\n", (int) img_colorspace(idict)); - } else { - pdf_puts("/DeviceRGB\n"); - } - pdf_create_obj(0, 0); - smask_objnum = obj_ptr; - pdf_printf("/SMask %i 0 R\n", (int) smask_objnum); - smask_size = (info_p->rowbytes / 2) * info_p->height; - smask = xtalloc(smask_size, png_byte); - pdf_begin_stream(); - if (info_p->interlace_type == PNG_INTERLACE_NONE) { - row = xtalloc(info_p->rowbytes, png_byte); - if ((info_p->bit_depth == 16) && fixed_image_hicolor) { - write_noninterlaced(write_rgb_pixel_16(r)); - } else { - write_noninterlaced(write_rgb_pixel_8(r)); - } - xfree(row); - } else { - if (info_p->height * info_p->rowbytes >= 10240000L) - pdftex_warn - ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); - rows = xtalloc(info_p->height, png_bytep); - for (i = 0; (unsigned) i < info_p->height; i++) - rows[i] = xtalloc(info_p->rowbytes, png_byte); - png_read_image(png_p, rows); - if ((info_p->bit_depth == 16) && fixed_image_hicolor) { - write_interlaced(write_rgb_pixel_16(row)); - } else { - write_interlaced(write_rgb_pixel_8(row)); - } - xfree(rows); - } - pdf_end_stream(); - pdf_flush(); - /* now write the Smask object */ - if (smask_objnum > 0) { - bitdepth = (int) info_p->bit_depth; - pdf_begin_dict(smask_objnum, 0); - pdf_puts("/Type /XObject\n/Subtype /Image\n"); - if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) - pdf_printf("%s\n", img_attr(idict)); - pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n", - (int) info_p->width, - (int) info_p->height, (bitdepth == 16 ? 8 : bitdepth)); - pdf_puts("/ColorSpace /DeviceGray\n"); - pdf_begin_stream(); - for (i = 0; i < smask_size; i++) { - if (i % 8 == 0) - pdfroom(8); - pdf_buf[pdf_ptr++] = smask[i]; - if (bitdepth == 16) - i++; - } - xfree(smask); - pdf_end_stream(); - } -} - -/**********************************************************************/ -/* - * The |copy_png| function is from Hartmut Henkel. The goal is to use - * pdf's native FlateDecode support if that is possible. - * - * Only a subset of the png files allows this, but when possible it - * greatly improves inclusion speed. - * - * Code cheerfully gleaned from Thomas Merz' PDFlib, - * file p_png.c "SPNG - Simple PNG" - */ - -static int spng_getint(FILE * fp) -{ - unsigned char buf[4]; - if (fread(buf, 1, 4, fp) != 4) - pdftex_fail("writepng: reading chunk type failed"); - return ((((((int) buf[0] << 8) + buf[1]) << 8) + buf[2]) << 8) + buf[3]; -} - -#define SPNG_CHUNK_IDAT 0x49444154 -#define SPNG_CHUNK_IEND 0x49454E44 - -static void copy_png(image_dict * idict) -{ - png_structp png_p; - png_infop info_p; - FILE *fp; - int i, len, type, streamlength = 0; - boolean endflag = false; - int idat = 0; /* flag to check continuous IDAT chunks sequence */ - assert(idict != NULL); - png_p = img_png_png_ptr(idict); - info_p = img_png_info_ptr(idict); - fp = (FILE *) png_p->io_ptr; - /* 1st pass to find overall stream /Length */ - if (fseek(fp, 8, SEEK_SET) != 0) - pdftex_fail("writepng: fseek in PNG file failed"); - do { - len = spng_getint(fp); - type = spng_getint(fp); - switch (type) { - case SPNG_CHUNK_IEND: - endflag = true; - break; - case SPNG_CHUNK_IDAT: - streamlength += len; - default: - if (fseek(fp, len + 4, SEEK_CUR) != 0) - pdftex_fail("writepng: fseek in PNG file failed"); - } - } while (endflag == false); - pdf_printf("/Length %d\n" - "/Filter/FlateDecode\n" - "/DecodeParms<<" - "/Colors %d" - "/Columns %d" - "/BitsPerComponent %i" - "/Predictor 10>>\n>>\nstream\n", streamlength, - info_p->color_type == 2 ? 3 : 1, - (int) info_p->width, info_p->bit_depth); - /* 2nd pass to copy data */ - endflag = false; - if (fseek(fp, 8, SEEK_SET) != 0) - pdftex_fail("writepng: fseek in PNG file failed"); - do { - len = spng_getint(fp); - type = spng_getint(fp); - switch (type) { - case SPNG_CHUNK_IDAT: /* do copy */ - if (idat == 2) - pdftex_fail("writepng: IDAT chunk sequence broken"); - idat = 1; - while (len > 0) { - i = (len > pdf_buf_size) ? pdf_buf_size : len; - pdfroom(i); - fread(&pdf_buf[pdf_ptr], 1, i, fp); - pdf_ptr += i; - len -= i; - } - if (fseek(fp, 4, SEEK_CUR) != 0) - pdftex_fail("writepng: fseek in PNG file failed"); - break; - case SPNG_CHUNK_IEND: /* done */ - pdf_end_stream(); - endflag = true; - break; - default: - if (idat == 1) - idat = 2; - if (fseek(fp, len + 4, SEEK_CUR) != 0) - pdftex_fail("writepng: fseek in PNG file failed"); - } - } while (endflag == false); -} - -static void reopen_png(image_dict * idict) -{ - integer width, height, xres, yres; - width = img_xsize(idict); /* do consistency check */ - height = img_ysize(idict); - xres = img_xres(idict); - yres = img_yres(idict); - read_png_info(idict, IMG_KEEPOPEN); - if (width != img_xsize(idict) || height != img_ysize(idict) - || xres != img_xres(idict) || yres != img_yres(idict)) - pdftex_fail("writepng: image dimensions have changed"); -} - -static boolean last_png_needs_page_group; - -void write_png(image_dict * idict) -{ - double gamma, checked_gamma; - int i; - integer palette_objnum = 0; - png_structp png_p; - png_infop info_p; - assert(idict != NULL); - last_png_needs_page_group = false; - if (img_file(idict) == NULL) - reopen_png(idict); - assert(img_png_ptr(idict) != NULL); - png_p = img_png_png_ptr(idict); - info_p = img_png_info_ptr(idict); - if (fixed_pdf_minor_version < 5) - fixed_image_hicolor = 0; - pdf_puts("/Type /XObject\n/Subtype /Image\n"); - if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) - pdf_printf("%s\n", img_attr(idict)); - pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n", - (int) info_p->width, - (int) info_p->height, (int) info_p->bit_depth); - pdf_puts("/ColorSpace "); - checked_gamma = 1.0; - if (fixed_image_apply_gamma) { - if (png_get_gAMA(png_p, info_p, &gamma)) { - checked_gamma = (fixed_gamma / 1000.0) * gamma; - } else { - checked_gamma = - (fixed_gamma / 1000.0) * (1000.0 / fixed_image_gamma); - } - } - /* the switching between |info_p| and |png_p| queries has been trial and error. - */ - if (fixed_pdf_minor_version > 1 && info_p->interlace_type == PNG_INTERLACE_NONE && (png_p->transformations == 0 || png_p->transformations == 0x2000) /* gamma */ - &&!(png_p->color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - png_p->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - && (fixed_image_hicolor || (png_p->bit_depth <= 8)) - && (checked_gamma <= 1.01 && checked_gamma > 0.99) - ) { - if (img_colorspace(idict) != 0) { - pdf_printf("%i 0 R\n", (int) img_colorspace(idict)); - } else { - switch (info_p->color_type) { - case PNG_COLOR_TYPE_PALETTE: - pdf_create_obj(0, 0); - palette_objnum = obj_ptr; - pdf_printf("[/Indexed /DeviceRGB %i %i 0 R]\n", - (int) (info_p->num_palette - 1), - (int) palette_objnum); - break; - case PNG_COLOR_TYPE_GRAY: - pdf_puts("/DeviceGray\n"); - break; - default: /* RGB */ - pdf_puts("/DeviceRGB\n"); - }; - } - if (tracefilenames) - tex_printf(" (PNG copy)"); - copy_png(idict); - if (palette_objnum > 0) { - pdf_begin_dict(palette_objnum, 0); - pdf_begin_stream(); - for (i = 0; (unsigned) i < info_p->num_palette; i++) { - pdfroom(3); - pdf_buf[pdf_ptr++] = info_p->palette[i].red; - pdf_buf[pdf_ptr++] = info_p->palette[i].green; - pdf_buf[pdf_ptr++] = info_p->palette[i].blue; - } - pdf_end_stream(); - } - } else { - if (0) { - tex_printf(" PNG copy skipped because: "); - if (fixed_image_apply_gamma && - (checked_gamma > 1.01 || checked_gamma < 0.99)) - tex_printf("gamma delta=%lf ", checked_gamma); - if (png_p->transformations != PNG_TRANSFORM_IDENTITY) - tex_printf("transform=%lu", (long) png_p->transformations); - if ((info_p->color_type != PNG_COLOR_TYPE_GRAY) - && (info_p->color_type != PNG_COLOR_TYPE_RGB) - && (info_p->color_type != PNG_COLOR_TYPE_PALETTE)) - tex_printf("colortype "); - if (fixed_pdf_minor_version <= 1) - tex_printf("version=%d ", (int) fixed_pdf_minor_version); - if (info_p->interlace_type != PNG_INTERLACE_NONE) - tex_printf("interlaced "); - if (info_p->bit_depth > 8) - tex_printf("bitdepth=%d ", info_p->bit_depth); - if (png_get_valid(png_p, info_p, PNG_INFO_tRNS)) - tex_printf("simple transparancy "); - } - switch (info_p->color_type) { - case PNG_COLOR_TYPE_PALETTE: - write_png_palette(idict); - break; - case PNG_COLOR_TYPE_GRAY: - write_png_gray(idict); - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - if (fixed_pdf_minor_version >= 4) { - write_png_gray_alpha(idict); - last_png_needs_page_group = true; - } else - write_png_gray(idict); - break; - case PNG_COLOR_TYPE_RGB: - write_png_rgb(idict); - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - if (fixed_pdf_minor_version >= 4) { - write_png_rgb_alpha(idict); - last_png_needs_page_group = true; - } else - write_png_rgb(idict); - break; - default: - pdftex_fail("unsupported type of color_type <%i>", - info_p->color_type); - } - } - pdf_flush(); - close_and_cleanup_png(idict); -} - -static boolean transparent_page_group_was_written = false; - -/* Called after the xobject generated by write_png has been finished; used to - * write out additional objects */ - -void write_additional_png_objects(void) -{ - return; /* this interferes with current macro-based usage and cannot be configured */ - if (last_png_needs_page_group) { - if (!transparent_page_group_was_written && transparent_page_group > 1) { - /* create new group object */ - transparent_page_group_was_written = true; - pdf_begin_obj(transparent_page_group, 2); - if (get_pdf_compress_level() == 0) { - pdf_puts("%PTEX Group needed for transparent pngs\n"); - } - pdf_puts - ("<>\n"); - pdf_end_obj(); - } - } -} diff --git a/Build/source/texk/web2c/luatexdir/image/writepng.h b/Build/source/texk/web2c/luatexdir/image/writepng.h index 4683e694a0c..56a96436389 100644 --- a/Build/source/texk/web2c/luatexdir/image/writepng.h +++ b/Build/source/texk/web2c/luatexdir/image/writepng.h @@ -18,15 +18,15 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -/* $Id: writepng.h 2327 2009-04-18 12:47:21Z hhenkel $ */ +/* $Id: writepng.h 2580 2009-06-23 15:55:52Z taco $ */ #ifndef WRITEPNG_H # define WRITEPNG_H # include "image.h" -void read_png_info(image_dict *, img_readtype_e); -void write_additional_png_objects(void); -void write_png(image_dict *); +void read_png_info(PDF, image_dict *, img_readtype_e); +void write_additional_png_objects(PDF); +void write_png(PDF, image_dict *); #endif /* WRITEPNG_H */ diff --git a/Build/source/texk/web2c/luatexdir/image/writepng.w b/Build/source/texk/web2c/luatexdir/image/writepng.w new file mode 100644 index 00000000000..1b8ecb56b49 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/image/writepng.w @@ -0,0 +1,689 @@ +% writepng.w + +% Copyright 1996-2006 Han The Thanh +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: writepng.w 3584 2010-04-02 17:45:55Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/image/writepng.w $"; + +#include +#include "ptexlib.h" +#include "image/image.h" + +@ @c +static int transparent_page_group = -1; + +static void close_and_cleanup_png(image_dict * idict) +{ + assert(idict != NULL); + assert(img_file(idict) != NULL); + assert(img_filepath(idict) != NULL); + xfclose(img_file(idict), img_filepath(idict)); + img_file(idict) = NULL; + assert(img_png_ptr(idict) != NULL); + png_destroy_read_struct(&(img_png_png_ptr(idict)), + &(img_png_info_ptr(idict)), NULL); + xfree(img_png_ptr(idict)); + img_png_ptr(idict) = NULL; +} + +@ @c +void read_png_info(PDF pdf, image_dict * idict, img_readtype_e readtype) +{ + double gamma; + png_structp png_p; + png_infop info_p; + assert(idict != NULL); + assert(img_type(idict) == IMG_TYPE_PNG); + img_totalpages(idict) = 1; + img_pagenum(idict) = 1; + img_xres(idict) = img_yres(idict) = 0; + assert(img_file(idict) == NULL); + img_file(idict) = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); + assert(img_png_ptr(idict) == NULL); + img_png_ptr(idict) = xtalloc(1, png_img_struct); + if ((png_p = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL)) == NULL) + pdftex_fail("libpng: png_create_read_struct() failed"); + img_png_png_ptr(idict) = png_p; + if ((info_p = png_create_info_struct(png_p)) == NULL) + pdftex_fail("libpng: png_create_info_struct() failed"); + img_png_info_ptr(idict) = info_p; + if (setjmp(png_p->jmpbuf)) + pdftex_fail("libpng: internal error"); + png_init_io(png_p, img_file(idict)); + png_read_info(png_p, info_p); + /* simple transparency support */ + if (png_get_valid(png_p, info_p, PNG_INFO_tRNS)) { + png_set_tRNS_to_alpha(png_p); + } + /* alpha channel support */ + if (pdf->minor_version < 4 && png_p->color_type | PNG_COLOR_MASK_ALPHA) + png_set_strip_alpha(png_p); + /* 16bit depth support */ + if (pdf->minor_version < 5) + pdf->image_hicolor = 0; + if ((info_p->bit_depth == 16) && (pdf->image_hicolor == 0)) + png_set_strip_16(png_p); + /* gamma support */ + if (pdf->image_apply_gamma) { + if (png_get_gAMA(png_p, info_p, &gamma)) + png_set_gamma(png_p, (pdf->gamma / 1000.0), gamma); + else + png_set_gamma(png_p, (pdf->gamma / 1000.0), + (1000.0 / pdf->image_gamma)); + } + /* reset structure */ + png_read_update_info(png_p, info_p); + /* resolution support */ + img_xsize(idict) = (int) info_p->width; + img_ysize(idict) = (int) info_p->height; + if (info_p->valid & PNG_INFO_pHYs) { + img_xres(idict) = + round(0.0254 * (double) png_get_x_pixels_per_meter(png_p, info_p)); + img_yres(idict) = + round(0.0254 * (double) png_get_y_pixels_per_meter(png_p, info_p)); + } + switch (info_p->color_type) { + case PNG_COLOR_TYPE_PALETTE: + img_procset(idict) |= PROCSET_IMAGE_C | PROCSET_IMAGE_I; + break; + case PNG_COLOR_TYPE_GRAY: + case PNG_COLOR_TYPE_GRAY_ALPHA: + img_procset(idict) |= PROCSET_IMAGE_B; + break; + case PNG_COLOR_TYPE_RGB: + case PNG_COLOR_TYPE_RGB_ALPHA: + img_procset(idict) |= PROCSET_IMAGE_C; + break; + default: + pdftex_fail("unsupported type of color_type <%i>", info_p->color_type); + } + img_colordepth(idict) = info_p->bit_depth; + if (readtype == IMG_CLOSEINBETWEEN) + close_and_cleanup_png(idict); +} + +@ @c +#define write_gray_pixel_16(r) \ + if (j % 4 == 0||j % 4 == 1) pdf_quick_out(pdf,*r++); \ + else smask[smask_ptr++] = *r++ + +#define write_gray_pixel_8(r) \ + if (j % 2 == 0) pdf_quick_out(pdf,*r++); \ + else smask[smask_ptr++] = *r++ + +#define write_rgb_pixel_16(r) \ + if (!(j % 8 == 6||j % 8 == 7)) pdf_quick_out(pdf,*r++); \ + else smask[smask_ptr++] = *r++ + +#define write_rgb_pixel_8(r) \ + if (j % 4 != 3) pdf_quick_out(pdf,*r++); \ + else smask[smask_ptr++] = *r++ + +#define write_simple_pixel(r) pdf_quick_out(pdf,*r++) + +#define write_noninterlaced(outmac) \ + for (i = 0; i < (int)info_p->height; i++) { \ + png_read_row(png_p, row, NULL); \ + r = row; \ + k = (int)info_p->rowbytes; \ + while(k > 0) { \ + l = (k > pdf->buf_size)? pdf->buf_size : k; \ + pdf_room(pdf,l); \ + for (j = 0; j < l; j++) { \ + outmac; \ + } \ + k -= l; \ + } \ + } + +#define write_interlaced(outmac) \ + for (i = 0; i < (int)info_p->height; i++) { \ + row = rows[i]; \ + k = (int)info_p->rowbytes; \ + while(k > 0) { \ + l = (k > pdf->buf_size)?pdf->buf_size: k;\ + pdf_room(pdf,l); \ + for (j = 0; j < l; j++) { \ + outmac; \ + } \ + k -= l; \ + } \ + xfree(rows[i]); \ + } + +@ @c +static void write_png_palette(PDF pdf, image_dict * idict) +{ + int i, j, k, l; + png_structp png_p = img_png_png_ptr(idict); + png_infop info_p = img_png_info_ptr(idict); + png_bytep row, r, *rows; + int palette_objnum = 0; + if (img_colorspace(idict) != 0) { + pdf_printf(pdf, "%i 0 R\n", (int) img_colorspace(idict)); + } else { + pdf_create_obj(pdf, obj_type_others, 0); + palette_objnum = pdf->obj_ptr; + pdf_printf(pdf, "[/Indexed /DeviceRGB %i %i 0 R]\n", + (int) (info_p->num_palette - 1), (int) palette_objnum); + } + pdf_begin_stream(pdf); + if (info_p->interlace_type == PNG_INTERLACE_NONE) { + row = xtalloc(info_p->rowbytes, png_byte); + write_noninterlaced(write_simple_pixel(r)); + xfree(row); + } else { + if (info_p->height * info_p->rowbytes >= 10240000L) + pdftex_warn + ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); + rows = xtalloc(info_p->height, png_bytep); + for (i = 0; (unsigned) i < info_p->height; i++) + rows[i] = xtalloc(info_p->rowbytes, png_byte); + png_read_image(png_p, rows); + write_interlaced(write_simple_pixel(row)); + xfree(rows); + } + pdf_end_stream(pdf); + if (palette_objnum > 0) { + pdf_begin_dict(pdf, palette_objnum, 0); + pdf_begin_stream(pdf); + for (i = 0; (unsigned) i < info_p->num_palette; i++) { + pdf_room(pdf, 3); + pdf_quick_out(pdf, info_p->palette[i].red); + pdf_quick_out(pdf, info_p->palette[i].green); + pdf_quick_out(pdf, info_p->palette[i].blue); + } + pdf_end_stream(pdf); + } +} + +@ @c +static void write_png_gray(PDF pdf, image_dict * idict) +{ + int i, j, k, l; + png_structp png_p = img_png_png_ptr(idict); + png_infop info_p = img_png_info_ptr(idict); + png_bytep row, r, *rows; + if (img_colorspace(idict) != 0) { + pdf_printf(pdf, "%i 0 R\n", (int) img_colorspace(idict)); + } else { + pdf_puts(pdf, "/DeviceGray\n"); + } + pdf_begin_stream(pdf); + if (info_p->interlace_type == PNG_INTERLACE_NONE) { + row = xtalloc(info_p->rowbytes, png_byte); + write_noninterlaced(write_simple_pixel(r)); + xfree(row); + } else { + if (info_p->height * info_p->rowbytes >= 10240000L) + pdftex_warn + ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); + rows = xtalloc(info_p->height, png_bytep); + for (i = 0; (unsigned) i < info_p->height; i++) + rows[i] = xtalloc(info_p->rowbytes, png_byte); + png_read_image(png_p, rows); + write_interlaced(write_simple_pixel(row)); + xfree(rows); + } + pdf_end_stream(pdf); +} + +@ @c +static void write_png_gray_alpha(PDF pdf, image_dict * idict) +{ + int i, j, k, l; + png_structp png_p = img_png_png_ptr(idict); + png_infop info_p = img_png_info_ptr(idict); + png_bytep row, r, *rows; + int smask_objnum = 0; + png_bytep smask; + int smask_ptr = 0; + int smask_size = 0; + int bitdepth; + if (img_colorspace(idict) != 0) { + pdf_printf(pdf, "%i 0 R\n", (int) img_colorspace(idict)); + } else { + pdf_puts(pdf, "/DeviceGray\n"); + } + pdf_create_obj(pdf, obj_type_others, 0); + smask_objnum = pdf->obj_ptr; + pdf_printf(pdf, "/SMask %i 0 R\n", (int) smask_objnum); + smask_size = (int) ((info_p->rowbytes / 2) * info_p->height); + smask = xtalloc((unsigned) smask_size, png_byte); + pdf_begin_stream(pdf); + if (info_p->interlace_type == PNG_INTERLACE_NONE) { + row = xtalloc(info_p->rowbytes, png_byte); + if ((info_p->bit_depth == 16) && (pdf->image_hicolor != 0)) { + write_noninterlaced(write_gray_pixel_16(r)); + } else { + write_noninterlaced(write_gray_pixel_8(r)); + } + xfree(row); + } else { + if (info_p->height * info_p->rowbytes >= 10240000L) + pdftex_warn + ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); + rows = xtalloc(info_p->height, png_bytep); + for (i = 0; (unsigned) i < info_p->height; i++) + rows[i] = xtalloc(info_p->rowbytes, png_byte); + png_read_image(png_p, rows); + if ((info_p->bit_depth == 16) && (pdf->image_hicolor != 0)) { + write_interlaced(write_gray_pixel_16(row)); + } else { + write_interlaced(write_gray_pixel_8(row)); + } + xfree(rows); + } + pdf_end_stream(pdf); + pdf_flush(pdf); + /* now write the Smask object */ + bitdepth = (int) info_p->bit_depth; + pdf_begin_dict(pdf, smask_objnum, 0); + pdf_puts(pdf, "/Type /XObject\n/Subtype /Image\n"); + if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) + pdf_printf(pdf, "%s\n", img_attr(idict)); + pdf_printf(pdf, "/Width %i\n/Height %i\n/BitsPerComponent %i\n", + (int) info_p->width, + (int) info_p->height, (bitdepth == 16 ? 8 : bitdepth)); + pdf_puts(pdf, "/ColorSpace /DeviceGray\n"); + pdf_begin_stream(pdf); + for (i = 0; i < smask_size; i++) { + if (i % 8 == 0) + pdf_room(pdf, 8); + pdf_quick_out(pdf, smask[i]); + if (bitdepth == 16) + i++; + } + pdf_end_stream(pdf); + xfree(smask); +} + +@ @c +static void write_png_rgb(PDF pdf, image_dict * idict) +{ + int i, j, k, l; + png_structp png_p = img_png_png_ptr(idict); + png_infop info_p = img_png_info_ptr(idict); + png_bytep row, r, *rows; + if (img_colorspace(idict) != 0) { + pdf_printf(pdf, "%i 0 R\n", (int) img_colorspace(idict)); + } else { + pdf_puts(pdf, "/DeviceRGB\n"); + } + pdf_begin_stream(pdf); + if (info_p->interlace_type == PNG_INTERLACE_NONE) { + row = xtalloc(info_p->rowbytes, png_byte); + write_noninterlaced(write_simple_pixel(r)); + xfree(row); + } else { + if (info_p->height * info_p->rowbytes >= 10240000L) + pdftex_warn + ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); + rows = xtalloc(info_p->height, png_bytep); + for (i = 0; (unsigned) i < info_p->height; i++) + rows[i] = xtalloc(info_p->rowbytes, png_byte); + png_read_image(png_p, rows); + write_interlaced(write_simple_pixel(row)); + xfree(rows); + } + pdf_end_stream(pdf); +} + +@ @c +static void write_png_rgb_alpha(PDF pdf, image_dict * idict) +{ + int i, j, k, l; + png_structp png_p = img_png_png_ptr(idict); + png_infop info_p = img_png_info_ptr(idict); + png_bytep row, r, *rows; + int smask_objnum = 0; + png_bytep smask; + int smask_ptr = 0; + int smask_size = 0; + int bitdepth; + if (img_colorspace(idict) != 0) { + pdf_printf(pdf, "%i 0 R\n", (int) img_colorspace(idict)); + } else { + pdf_puts(pdf, "/DeviceRGB\n"); + } + pdf_create_obj(pdf, obj_type_others, 0); + smask_objnum = pdf->obj_ptr; + pdf_printf(pdf, "/SMask %i 0 R\n", (int) smask_objnum); + smask_size = (int) ((info_p->rowbytes / 2) * info_p->height); + smask = xtalloc((unsigned) smask_size, png_byte); + pdf_begin_stream(pdf); + if (info_p->interlace_type == PNG_INTERLACE_NONE) { + row = xtalloc(info_p->rowbytes, png_byte); + if ((info_p->bit_depth == 16) && (pdf->image_hicolor != 0)) { + write_noninterlaced(write_rgb_pixel_16(r)); + } else { + write_noninterlaced(write_rgb_pixel_8(r)); + } + xfree(row); + } else { + if (info_p->height * info_p->rowbytes >= 10240000L) + pdftex_warn + ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)"); + rows = xtalloc(info_p->height, png_bytep); + for (i = 0; (unsigned) i < info_p->height; i++) + rows[i] = xtalloc(info_p->rowbytes, png_byte); + png_read_image(png_p, rows); + if ((info_p->bit_depth == 16) && (pdf->image_hicolor != 0)) { + write_interlaced(write_rgb_pixel_16(row)); + } else { + write_interlaced(write_rgb_pixel_8(row)); + } + xfree(rows); + } + pdf_end_stream(pdf); + pdf_flush(pdf); + /* now write the Smask object */ + if (smask_objnum > 0) { + bitdepth = (int) info_p->bit_depth; + pdf_begin_dict(pdf, smask_objnum, 0); + pdf_puts(pdf, "/Type /XObject\n/Subtype /Image\n"); + if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) + pdf_printf(pdf, "%s\n", img_attr(idict)); + pdf_printf(pdf, "/Width %i\n/Height %i\n/BitsPerComponent %i\n", + (int) info_p->width, + (int) info_p->height, (bitdepth == 16 ? 8 : bitdepth)); + pdf_puts(pdf, "/ColorSpace /DeviceGray\n"); + pdf_begin_stream(pdf); + for (i = 0; i < smask_size; i++) { + if (i % 8 == 0) + pdf_room(pdf, 8); + pdf_quick_out(pdf, smask[i]); + if (bitdepth == 16) + i++; + } + xfree(smask); + pdf_end_stream(pdf); + } +} + +@ The |copy_png| function is from Hartmut Henkel. The goal is to use +pdf's native FlateDecode support if that is possible. + +Only a subset of the png files allows this, but when possible it +greatly improves inclusion speed. + +Code cheerfully gleaned from Thomas Merz' PDFlib, +file |p_png.c| "SPNG - Simple PNG" + + +@c +static int spng_getint(FILE * fp) +{ + unsigned char buf[4]; + if (fread(buf, 1, 4, fp) != 4) + pdftex_fail("writepng: reading chunk type failed"); + return ((((((int) buf[0] << 8) + buf[1]) << 8) + buf[2]) << 8) + buf[3]; +} + +#define SPNG_CHUNK_IDAT 0x49444154 +#define SPNG_CHUNK_IEND 0x49454E44 + +static void copy_png(PDF pdf, image_dict * idict) +{ + png_structp png_p; + png_infop info_p; + FILE *fp; + int i, len, type, streamlength = 0; + boolean endflag = false; + int idat = 0; /* flag to check continuous IDAT chunks sequence */ + assert(idict != NULL); + png_p = img_png_png_ptr(idict); + info_p = img_png_info_ptr(idict); + fp = (FILE *) png_p->io_ptr; + /* 1st pass to find overall stream /Length */ + if (fseek(fp, 8, SEEK_SET) != 0) + pdftex_fail("writepng: fseek in PNG file failed"); + do { + len = spng_getint(fp); + type = spng_getint(fp); + switch (type) { + case SPNG_CHUNK_IEND: + endflag = true; + break; + case SPNG_CHUNK_IDAT: + streamlength += len; + default: + if (fseek(fp, len + 4, SEEK_CUR) != 0) + pdftex_fail("writepng: fseek in PNG file failed"); + } + } while (endflag == false); + pdf_printf(pdf, "/Length %d\n" + "/Filter/FlateDecode\n" + "/DecodeParms<<" + "/Colors %d" + "/Columns %d" + "/BitsPerComponent %i" + "/Predictor 10>>\n>>\nstream\n", streamlength, + info_p->color_type == 2 ? 3 : 1, + (int) info_p->width, info_p->bit_depth); + /* 2nd pass to copy data */ + endflag = false; + if (fseek(fp, 8, SEEK_SET) != 0) + pdftex_fail("writepng: fseek in PNG file failed"); + do { + len = spng_getint(fp); + type = spng_getint(fp); + switch (type) { + case SPNG_CHUNK_IDAT: /* do copy */ + if (idat == 2) + pdftex_fail("writepng: IDAT chunk sequence broken"); + idat = 1; + while (len > 0) { + i = (len > pdf->buf_size) ? pdf->buf_size : len; + pdf_room(pdf, i); + fread(&pdf->buf[pdf->ptr], 1, (size_t) i, fp); + pdf->ptr += i; + len -= i; + } + if (fseek(fp, 4, SEEK_CUR) != 0) + pdftex_fail("writepng: fseek in PNG file failed"); + break; + case SPNG_CHUNK_IEND: /* done */ + pdf_end_stream(pdf); + endflag = true; + break; + default: + if (idat == 1) + idat = 2; + if (fseek(fp, len + 4, SEEK_CUR) != 0) + pdftex_fail("writepng: fseek in PNG file failed"); + } + } while (endflag == false); +} + +@ @c +static void reopen_png(PDF pdf, image_dict * idict) +{ + int width, height, xres, yres; + width = img_xsize(idict); /* do consistency check */ + height = img_ysize(idict); + xres = img_xres(idict); + yres = img_yres(idict); + read_png_info(pdf, idict, IMG_KEEPOPEN); + if (width != img_xsize(idict) || height != img_ysize(idict) + || xres != img_xres(idict) || yres != img_yres(idict)) + pdftex_fail("writepng: image dimensions have changed"); +} + +@ @c +static boolean last_png_needs_page_group; + +void write_png(PDF pdf, image_dict * idict) +{ + double gamma, checked_gamma; + int i; + int palette_objnum = 0; + png_structp png_p; + png_infop info_p; + assert(idict != NULL); + last_png_needs_page_group = false; + if (img_file(idict) == NULL) + reopen_png(pdf, idict); + assert(img_png_ptr(idict) != NULL); + png_p = img_png_png_ptr(idict); + info_p = img_png_info_ptr(idict); + if (pdf->minor_version < 5) + pdf->image_hicolor = 0; + pdf_puts(pdf, "/Type /XObject\n/Subtype /Image\n"); + if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) + pdf_printf(pdf, "%s\n", img_attr(idict)); + pdf_printf(pdf, "/Width %i\n/Height %i\n/BitsPerComponent %i\n", + (int) info_p->width, + (int) info_p->height, (int) info_p->bit_depth); + pdf_puts(pdf, "/ColorSpace "); + checked_gamma = 1.0; + if (pdf->image_apply_gamma) { + if (png_get_gAMA(png_p, info_p, &gamma)) { + checked_gamma = (pdf->gamma / 1000.0) * gamma; + } else { + checked_gamma = (pdf->gamma / 1000.0) * (1000.0 / pdf->image_gamma); + } + } + /* the switching between |info_p| and |png_p| queries has been trial and error. + */ + if (pdf->minor_version > 1 && info_p->interlace_type == PNG_INTERLACE_NONE && + (png_p->transformations == 0 || png_p->transformations == 0x2000) /* gamma */ + &&!(png_p->color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + png_p->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + && ((pdf->image_hicolor != 0) || (png_p->bit_depth <= 8)) + && (checked_gamma <= 1.01 && checked_gamma > 0.99) + ) { + if (img_colorspace(idict) != 0) { + pdf_printf(pdf, "%i 0 R\n", (int) img_colorspace(idict)); + } else { + switch (info_p->color_type) { + case PNG_COLOR_TYPE_PALETTE: + pdf_create_obj(pdf, obj_type_others, 0); + palette_objnum = pdf->obj_ptr; + pdf_printf(pdf, "[/Indexed /DeviceRGB %i %i 0 R]\n", + (int) (info_p->num_palette - 1), + (int) palette_objnum); + break; + case PNG_COLOR_TYPE_GRAY: + pdf_puts(pdf, "/DeviceGray\n"); + break; + default: /* RGB */ + pdf_puts(pdf, "/DeviceRGB\n"); + }; + } + if (tracefilenames) + tex_printf(" (PNG copy)"); + copy_png(pdf, idict); + if (palette_objnum > 0) { + pdf_begin_dict(pdf, palette_objnum, 0); + pdf_begin_stream(pdf); + for (i = 0; (unsigned) i < info_p->num_palette; i++) { + pdf_room(pdf, 3); + pdf_quick_out(pdf, info_p->palette[i].red); + pdf_quick_out(pdf, info_p->palette[i].green); + pdf_quick_out(pdf, info_p->palette[i].blue); + } + pdf_end_stream(pdf); + } + } else { + if (0) { + tex_printf(" PNG copy skipped because: "); + if ((pdf->image_apply_gamma != 0) && + (checked_gamma > 1.01 || checked_gamma < 0.99)) + tex_printf("gamma delta=%lf ", checked_gamma); + if (png_p->transformations != PNG_TRANSFORM_IDENTITY) + tex_printf("transform=%lu", (long) png_p->transformations); + if ((info_p->color_type != PNG_COLOR_TYPE_GRAY) + && (info_p->color_type != PNG_COLOR_TYPE_RGB) + && (info_p->color_type != PNG_COLOR_TYPE_PALETTE)) + tex_printf("colortype "); + if (pdf->minor_version <= 1) + tex_printf("version=%d ", pdf->minor_version); + if (info_p->interlace_type != PNG_INTERLACE_NONE) + tex_printf("interlaced "); + if (info_p->bit_depth > 8) + tex_printf("bitdepth=%d ", info_p->bit_depth); + if (png_get_valid(png_p, info_p, PNG_INFO_tRNS)) + tex_printf("simple transparancy "); + } + switch (info_p->color_type) { + case PNG_COLOR_TYPE_PALETTE: + write_png_palette(pdf, idict); + break; + case PNG_COLOR_TYPE_GRAY: + write_png_gray(pdf, idict); + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: + if (pdf->minor_version >= 4) { + write_png_gray_alpha(pdf, idict); + last_png_needs_page_group = true; + } else + write_png_gray(pdf, idict); + break; + case PNG_COLOR_TYPE_RGB: + write_png_rgb(pdf, idict); + break; + case PNG_COLOR_TYPE_RGB_ALPHA: + if (pdf->minor_version >= 4) { + write_png_rgb_alpha(pdf, idict); + last_png_needs_page_group = true; + } else + write_png_rgb(pdf, idict); + break; + default: + pdftex_fail("unsupported type of color_type <%i>", + info_p->color_type); + } + } + pdf_flush(pdf); + close_and_cleanup_png(idict); +} + +@ @c +static boolean transparent_page_group_was_written = false; + +@ Called after the xobject generated by |write_png| has been finished; used to +write out additional objects +@c +void write_additional_png_objects(PDF pdf) +{ + (void) pdf; + (void) transparent_page_group; + (void) transparent_page_group_was_written; + return; /* this interferes with current macro-based usage and cannot be configured */ +#if 0 + if (last_png_needs_page_group) { + if (!transparent_page_group_was_written && transparent_page_group > 1) { + /* create new group object */ + transparent_page_group_was_written = true; + pdf_begin_obj(pdf, transparent_page_group, 2); + if (pdf->compress_level == 0) { + pdf_puts(pdf, "%PTEX Group needed for transparent pngs\n"); + } + pdf_puts + (pdf, + "<>\n"); + pdf_end_obj(pdf); + } + } +#endif +} diff --git a/Build/source/texk/web2c/luatexdir/inc-epdf.h b/Build/source/texk/web2c/luatexdir/inc-epdf.h deleted file mode 100644 index b59a2e1be9f..00000000000 --- a/Build/source/texk/web2c/luatexdir/inc-epdf.h +++ /dev/null @@ -1,8 +0,0 @@ -/* prototypes used in image/pdftoepdf.cc and in C code */ - -/* image/epdf.c */ - extern void epdf_mark_glyphs(fd_entry *, char *); - extern fd_entry *epdf_create_fontdescriptor(fm_entry *, int); - -/* font/writeenc.c */ - extern void epdf_write_enc(char **, integer); diff --git a/Build/source/texk/web2c/luatexdir/inc-extra.h b/Build/source/texk/web2c/luatexdir/inc-extra.h deleted file mode 100644 index 98ca98f8670..00000000000 --- a/Build/source/texk/web2c/luatexdir/inc-extra.h +++ /dev/null @@ -1,4 +0,0 @@ -/* from lua/lnodelib.c */ - -extern halfword *check_isnode(lua_State * L, int ud); -extern void lua_nodelib_push_fast(lua_State * L, halfword n); diff --git a/Build/source/texk/web2c/luatexdir/inc-vfovf.h b/Build/source/texk/web2c/luatexdir/inc-vfovf.h deleted file mode 100644 index eb624f9519c..00000000000 --- a/Build/source/texk/web2c/luatexdir/inc-vfovf.h +++ /dev/null @@ -1,2 +0,0 @@ -/* this function is in vfovf.c for the moment */ -extern int make_vf_table(lua_State * L, const char *name, scaled s); diff --git a/Build/source/texk/web2c/luatexdir/lang/hnjalloc.c b/Build/source/texk/web2c/luatexdir/lang/hnjalloc.c deleted file mode 100644 index 6072152f4f5..00000000000 --- a/Build/source/texk/web2c/luatexdir/lang/hnjalloc.c +++ /dev/null @@ -1,74 +0,0 @@ -/* LibHnj is dual licensed under LGPL and MPL. Boilerplate for both - * licenses follows. - */ - -/* LibHnj - a library for high quality hyphenation and justification - * Copyright (C) 1998 Raph Levien, (C) 2001 ALTLinux, Moscow - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307 USA. -*/ - -/* - * The contents of this file are subject to the Mozilla Public License - * Version 1.0 (the "MPL"); you may not use this file except in - * compliance with the MPL. You may obtain a copy of the MPL at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the MPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL - * for the specific language governing rights and limitations under the - * MPL. - * - */ -/* wrappers for malloc */ - -#include -#include - -#include "hnjalloc.h" - -void * -hnj_malloc (int size) -{ - void *p; - - p = malloc (size); - if (p == NULL) - { - fprintf (stderr, "can't allocate %d bytes\n", size); - exit (1); - } - return p; -} - -void * -hnj_realloc (void *p, int size) -{ - p = realloc (p, size); - if (p == NULL) - { - fprintf (stderr, "can't allocate %d bytes\n", size); - exit (1); - } - return p; -} - -void -hnj_free (void *p) -{ - free (p); -} - diff --git a/Build/source/texk/web2c/luatexdir/lang/hnjalloc.h b/Build/source/texk/web2c/luatexdir/lang/hnjalloc.h index db82fb9c758..1af5a3f0ea3 100644 --- a/Build/source/texk/web2c/luatexdir/lang/hnjalloc.h +++ b/Build/source/texk/web2c/luatexdir/lang/hnjalloc.h @@ -35,12 +35,8 @@ */ /* wrappers for malloc */ -void * -hnj_malloc (int size); +void *hnj_malloc(int size); -void * -hnj_realloc (void *p, int size); - -void -hnj_free (void *p); +void *hnj_realloc(void *p, int size); +void hnj_free(void *p); diff --git a/Build/source/texk/web2c/luatexdir/lang/hnjalloc.w b/Build/source/texk/web2c/luatexdir/lang/hnjalloc.w new file mode 100644 index 00000000000..c7d595cdd75 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lang/hnjalloc.w @@ -0,0 +1,66 @@ +% LibHnj is dual licensed under LGPL and MPL. Boilerplate for both +% licenses follows. +% +% +% LibHnj - a library for high quality hyphenation and justification +% Copyright (C) 1998 Raph Levien, (C) 2001 ALTLinux, Moscow +% +% This library is free software; you can redistribute it and/or +% modify it under the terms of the GNU Library General Public +% License as published by the Free Software Foundation; either +% version 2 of the License, or (at your option) any later version. +% +% This library is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +% Library General Public License for more details. +% +% You should have received a copy of the GNU Library General Public +% License along with this library; if not, write to the +% Free Software Foundation, Inc., 59 Temple Place - Suite 330, +% Boston, MA 02111-1307 USA. +% +% +% +% The contents of this file are subject to the Mozilla Public License +% Version 1.0 (the "MPL"); you may not use this file except in +% compliance with the MPL. You may obtain a copy of the MPL at +% http://www.mozilla.org/MPL/ +% +% Software distributed under the MPL is distributed on an "AS IS" basis, +% WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL +% for the specific language governing rights and limitations under the +% MPL. + +@ wrappers for malloc +@c + +#include +#include + +void *hnj_malloc(int size) +{ + void *p; + + p = malloc((size_t) size); + if (p == NULL) { + fprintf(stderr, "can't allocate %d bytes\n", size); + exit(1); + } + return p; +} + +void *hnj_realloc(void *p, int size) +{ + p = realloc(p, (size_t) size); + if (p == NULL) { + fprintf(stderr, "can't allocate %d bytes\n", size); + exit(1); + } + return p; +} + +void hnj_free(void *p) +{ + free(p); +} diff --git a/Build/source/texk/web2c/luatexdir/lang/hyphen.c b/Build/source/texk/web2c/luatexdir/lang/hyphen.c deleted file mode 100644 index edcad69adff..00000000000 --- a/Build/source/texk/web2c/luatexdir/lang/hyphen.c +++ /dev/null @@ -1,850 +0,0 @@ -/* Libhnj is dual licensed under LGPL and MPL. Boilerplate for both - * licenses follows. - */ - -/* LibHnj - a library for high quality hyphenation and justification - * Copyright (C) 1998 Raph Levien, - * (C) 2001 ALTLinux, Moscow (http://www.alt-linux.org), - * (C) 2001 Peter Novodvorsky (nidd@cs.msu.su) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307 USA. -*/ - -/* - * The contents of this file are subject to the Mozilla Public License - * Version 1.0 (the "MPL"); you may not use this file except in - * compliance with the MPL. You may obtain a copy of the MPL at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the MPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL - * for the specific language governing rights and limitations under the - * MPL. - * - */ -#include /* for NULL, malloc */ -#include /* for fprintf */ -#include /* for strdup */ -#include /* for malloc used by substring inclusion*/ - -#define MAXPATHS 40960 - -#ifdef UNX -#include /* for exit */ -#endif - -#include - -/*#define VERBOSE*/ - -#include "hnjalloc.h" -#include "hyphen.h" - -static const char _svn_version[] = - "$Id: hyphen.c 1696 2008-12-28 21:02:34Z oneiros $ $URL: http://scm.foundry.supelec.fr/svn/luatex/trunk/src/texk/web2c/luatexdir/lang/texlang.c $"; - -/* SHOULD BE MOVED TO SEPARATE LIBRARY */ -static unsigned char * hnj_strdup( - const unsigned char *s -) { - unsigned char *new; - int l; - - l = strlen ((const char*)s); - new = hnj_malloc (l + 1); - memcpy (new, s, l); - new[l] = 0; - return new; -} - -static int is_utf8_follow( - unsigned char c -) { - if (c>=0x80 && c<0xC0) return 1; - return 0; -} - -/* -------------------------------------------------------------------- - * - * Type definitions - * - * -------------------------------------------------------------------- - */ - -/* a little bit of a hash table implementation. This simply maps strings - to state numbers */ - -typedef struct _HashTab HashTab; -typedef struct _HashEntry HashEntry; -typedef struct _HashIter HashIter; -typedef union _HashVal HashVal; - -/* A cheap, but effective, hack. */ -#define HASH_SIZE 31627 - -struct _HashTab { - HashEntry *entries[HASH_SIZE]; -}; - -union _HashVal { - int state; - char* hyppat; -}; - -struct _HashEntry { - HashEntry *next; - unsigned char *key; - HashVal u; -}; - -struct _HashIter { - HashEntry** e; - HashEntry* cur; - int ndx; -}; - -/* State machine */ -typedef struct _HyphenState HyphenState; -typedef struct _HyphenTrans HyphenTrans; -#define MAX_CHARS 256 -#define MAX_NAME 20 - -struct _HyphenDict { - int num_states; - int pat_length; - char cset[MAX_NAME]; - HyphenState *states; - HashTab *patterns; - HashTab *merged; - HashTab *state_num; -}; - -struct _HyphenState { - char *match; - /*char *repl;*/ - /*signed char replindex;*/ - /*signed char replcut;*/ - int fallback_state; - int num_trans; - HyphenTrans *trans; -}; - -struct _HyphenTrans { - int uni_ch; - int new_state; -}; - - -/* Combine two right-aligned number patterns, 04000 + 020 becomes 04020*/ -static char *combine( - char *expr, - const char *subexpr -) { - int l1 = strlen(expr); - int l2 = strlen(subexpr); - int off = l1-l2; - int j; - /* this works also for utf8 sequences because the substring is identical - * to the last substring-length bytes of expr except for the (single byte) - * hyphenation encoders - */ - for (j=0; je = h->entries; - i->cur = NULL; - i->ndx = -1; - return i; -} - - -static int nextHashStealPattern( - HashIter*i, - unsigned char**word, - char **pattern -) { - while (i->cur==NULL) { - if (i->ndx >= HASH_SIZE-1) return 0; - i->cur = i->e[++i->ndx]; - } - *word = i->cur->key; - *pattern = i->cur->u.hyppat; - i->cur->u.hyppat = NULL; - i->cur = i->cur->next; - return 1; -} - - -static int nextHash( - HashIter*i, - unsigned char**word -) { - while (i->cur==NULL) { - if (i->ndx >= HASH_SIZE-1) return 0; - i->cur = i->e[++i->ndx]; - } - *word = i->cur->key; - i->cur = i->cur->next; - return 1; -} - - -static int eachHash( - HashIter*i, - unsigned char**word, - char**pattern -) { - while (i->cur==NULL) { - if (i->ndx >= HASH_SIZE-1) return 0; - i->cur = i->e[++i->ndx]; - } - *word = i->cur->key; - *pattern = i->cur->u.hyppat; - i->cur = i->cur->next; - return 1; -} - - -static void delete_HashIter( - HashIter*i -) { - hnj_free(i); -} - - -/* a char* hash function from ASU - adapted from Gtk+ */ -static unsigned int hnj_string_hash ( - const unsigned char *s -) { - const unsigned char *p; - unsigned int h=0, g; - - for (p = s; *p != '\0'; p += 1) { - h = ( h << 4 ) + *p; - if ( ( g = h & 0xf0000000 ) ) { - h = h ^ (g >> 24); - h = h ^ g; - } - } - return h /* % M */; -} - - -/* assumes that key is not already present! */ -static void state_insert( - HashTab *hashtab, - unsigned char *key, - int state -) { - int i; - HashEntry *e; - - i = hnj_string_hash (key) % HASH_SIZE; - e = hnj_malloc (sizeof(HashEntry)); - e->next = hashtab->entries[i]; - e->key = key; - e->u.state = state; - hashtab->entries[i] = e; -} - - -/* assumes that key is not already present! */ -static void hyppat_insert( - HashTab *hashtab, - unsigned char *key, - char* hyppat -) { - int i; - HashEntry *e; - - i = hnj_string_hash (key) % HASH_SIZE; - for (e = hashtab->entries[i]; e; e=e->next) { - if (strcmp((char*)e->key,(char*)key)==0) { - if (e->u.hyppat) { - if (hyppat && strcmp((char*)e->u.hyppat,(char*)hyppat)!=0) { - int s = maketexstring("Conflicting pattern ignored"); - do_print_err(s); - error(); - flush_str(s); - } - hnj_free(e->u.hyppat); - } - e->u.hyppat = hyppat; - hnj_free(key); - return; - } - } - e = hnj_malloc (sizeof(HashEntry)); - e->next = hashtab->entries[i]; - e->key = key; - e->u.hyppat = hyppat; - hashtab->entries[i] = e; -} - - -/* return state if found, otherwise -1 */ -static int state_lookup( - HashTab *hashtab, - const unsigned char *key -) { - int i; - HashEntry *e; - - i = hnj_string_hash (key) % HASH_SIZE; - for (e = hashtab->entries[i]; e; e = e->next) { - if (!strcmp ((const char*)key, (const char*)e->key)) { - return e->u.state; - } - } - return -1; -} - - -/* return state if found, otherwise -1 */ -static char* hyppat_lookup( - HashTab *hashtab, - const unsigned char *chars, - int l -) { - int i; - HashEntry *e; - unsigned char key[128]; /* should be ample*/ - strncpy((char*)key,(const char*)chars,l); key[l]=0; - i = hnj_string_hash (key) % HASH_SIZE; - for (e = hashtab->entries[i]; e; e = e->next) { - if (!strcmp ((char*)key, (char*)e->key)) { - return e->u.hyppat; - } - } - return NULL; -} - - -/* Get the state number, allocating a new state if necessary. */ -static int hnj_get_state( - HyphenDict *dict, - const unsigned char *string, - int *state_num -) { - *state_num = state_lookup(dict->state_num, string); - - if (*state_num >= 0) - return *state_num; - - state_insert(dict->state_num, hnj_strdup(string), dict->num_states); - /* predicate is true if dict->num_states is a power of two */ - if (!(dict->num_states & (dict->num_states - 1))) { - dict->states = hnj_realloc( - dict->states, - (dict->num_states << 1) * sizeof(HyphenState)); - } - dict->states[dict->num_states].match = NULL; - dict->states[dict->num_states].fallback_state = -1; - dict->states[dict->num_states].num_trans = 0; - dict->states[dict->num_states].trans = NULL; - return dict->num_states++; -} - - -/* add a transition from state1 to state2 through ch - assumes that the - transition does not already exist */ -static void hnj_add_trans( - HyphenDict *dict, - int state1, - int state2, - int uni_ch -) { - int num_trans; - /* TH: this test was a bit too strict, it is quite normal for old - patterns to have chars in the range 0-31 or 127-159 (inclusive). - To ease the transition, let's only disallow NUL for now - (this is probably a requirement of the code anyway). - */ - if (uni_ch==0) { - fprintf(stderr,"Character out of bounds: u%04x \n",uni_ch); - exit(1); - } - num_trans = dict->states[state1].num_trans; - if (num_trans == 0) { - dict->states[state1].trans = hnj_malloc(sizeof(HyphenTrans)); - } else if (!(num_trans & (num_trans - 1))) { - dict->states[state1].trans = hnj_realloc( - dict->states[state1].trans, - (num_trans << 1) * sizeof(HyphenTrans)); - } - dict->states[state1].trans[num_trans].uni_ch = uni_ch; - dict->states[state1].trans[num_trans].new_state = state2; - dict->states[state1].num_trans++; -} - - -#ifdef VERBOSE - -static unsigned char *get_state_str( - int state -) { - int i; - HashEntry *e; - - for (i = 0; i < HASH_SIZE; i++) - for (e = global->entries[i]; e; e = e->next) - if (e->u.state == state) - return e->key; - return NULL; -} -#endif - - -/* I've changed the semantics a bit here: hnj_hyphen_load used to - operate on a file, but now the argument is a string buffer. - */ - -static const unsigned char* next_pattern( - size_t* length, - const unsigned char **buf -) { - const unsigned char *here, *rover = *buf; - while (*rover && isspace(*rover)) rover++; - here = rover; - while (*rover) { - if (isspace(*rover)) { - *length = rover-here; - *buf = rover; - return here; - } - rover++; - } - *length = rover-here; - *buf = rover; - return *length ? here : NULL; /* zero sensed */ -} - -static void init_hash( - HashTab**h -) { - int i; - if (*h) return; - *h = hnj_malloc(sizeof(HashTab)); - for (i = 0; i < HASH_SIZE; i++) (*h)->entries[i] = NULL; -} - - -static void clear_state_hash( - HashTab**h -) { - int i; - if (*h==NULL) return; - for (i = 0; i < HASH_SIZE; i++) { - HashEntry *e, *next; - for (e = (*h)->entries[i]; e; e = next) { - next = e->next; - hnj_free (e->key); - hnj_free (e); - } - } - hnj_free(*h); - *h=NULL; -} - - -static void clear_hyppat_hash( - HashTab**h -) { - int i; - if (*h==NULL) return; - for (i = 0; i < HASH_SIZE; i++) { - HashEntry *e, *next; - for (e = (*h)->entries[i]; e; e = next) { - next = e->next; - hnj_free(e->key); - if (e->u.hyppat) hnj_free(e->u.hyppat); - hnj_free(e); - } - } - hnj_free(*h); - *h=NULL; -} - - -static void init_dict( - HyphenDict* dict -) { - dict->num_states = 1; - dict->pat_length = 0; - dict->states = hnj_malloc (sizeof(HyphenState)); - dict->states[0].match = NULL; - dict->states[0].fallback_state = -1; - dict->states[0].num_trans = 0; - dict->states[0].trans = NULL; - dict->patterns = NULL; - dict->merged = NULL; - dict->state_num = NULL; - init_hash(&dict->patterns); -} - - -static void clear_dict( - HyphenDict* dict -) { - int state_num; - for (state_num = 0; state_num < dict->num_states; state_num++) { - HyphenState *hstate = &dict->states[state_num]; - if (hstate->match) hnj_free (hstate->match); - if (hstate->trans) hnj_free (hstate->trans); - } - hnj_free (dict->states); - clear_hyppat_hash(&dict->patterns); - clear_hyppat_hash(&dict->merged); - clear_state_hash(&dict->state_num); -} - - - -HyphenDict* hnj_hyphen_new(void) { - HyphenDict* dict = hnj_malloc (sizeof(HyphenDict)); - init_dict(dict); - return dict; -} - - -void hnj_hyphen_clear( - HyphenDict* dict -) { - clear_dict(dict); - init_dict(dict); -} - - -void hnj_hyphen_free( - HyphenDict *dict -) { - clear_dict(dict); - hnj_free(dict); -} - -unsigned char* hnj_serialize( - HyphenDict* dict -) { - HashIter *v; - unsigned char* word; - char* pattern; - unsigned char* buf = hnj_malloc(dict->pat_length); - unsigned char* cur = buf; - v = new_HashIter(dict->patterns); - while (eachHash(v,&word,&pattern)) { - int i=0, e=0; - while(word[e+i]) { - if (pattern[i]!='0') *cur++ = (unsigned char) pattern[i]; - *cur++ = word[e+i++]; - while (is_utf8_follow(word[e+i])) *cur++ = word[i+e++]; - } - if (pattern[i]!='0') *cur++ = (unsigned char) pattern[i]; - *cur++ = ' '; - } - delete_HashIter(v); - *cur = 0; - return buf; -} - - -void hnj_free_serialize( - unsigned char* c -) { - hnj_free(c); -} - - -/* hyphenation pattern: - * signed bytes - * 0 indicates end (actually any negative number) - * : prio(1+),startpos,length,len1,[replace],len2,[replace] - * most basic example is: - * p n 0 0 0 - * for a hyphenation point between characters - */ - - -void hnj_hyphen_load( - HyphenDict* dict, - const unsigned char *f -) { - int state_num, last_state; - int i, j = 0; - int ch; - int found; - HashEntry *e; - HashIter *v; - unsigned char* word; - char* pattern; - size_t l = 0; - - - /***************************************/ - - const unsigned char* format; - const unsigned char* begin = f; - unsigned char *pat; - char *org; - while((format = next_pattern(&l,&f))!=NULL) { - int i,j,e; - /* - printf("%s\n",format); - char* repl = strnchr(format, '/',l); - int replindex = 0; - int replcut = 0; - if (repl) { - int clen = l-(repl-format); - l = repl-format; - char * index = strnchr(repl + 1, ',',clen); - if (index) { - char * index2 = strnchr(index + 1, ',',clen-(index-repl)); - if (index2) { - replindex = (signed char) atoi(index + 1) - 1; - replcut = (signed char) atoi(index2 + 1); - } - } else { - hnj_strchomp(repl + 1); - replindex = 0; - replcut = strlen(buf); - } - repl = hnj_strdup(repl + 1); - } - */ - for (i=0,j=0,e=0; (unsigned)i='0'&&format[i]<='9') j++; - if (is_utf8_follow(format[i])) e++; - } - /* l-e => number of _characters_ not _bytes_*/ - /* l-j => number of pattern bytes */ - /* l-e-j => number of pattern characters*/ - pat = (unsigned char*) malloc(1+l-j); - org = ( char*) malloc(2+l-e-j); - /* remove hyphenation encoders (digits) from pat*/ - org[0] = '0'; - for (i=0,j=0,e=0; (unsigned)i'9') { - pat[e+j++] = c; - org[j] = '0'; - } else { - org[j] = c; - } - } - pat[e+j] = 0; - org[j+1] = 0; - hyppat_insert(dict->patterns,pat,org); - } - dict->pat_length += (f-begin)+2; /* 2 for spurious spaces*/ - init_hash(&dict->merged); - v = new_HashIter(dict->patterns); - while (nextHash(v,&word)) { - int wordsize = strlen((char*)word); - int j,l; - for (l=1; l<=wordsize; l++) { - if (is_utf8_follow(word[l])) continue; /* Do not clip an utf8 sequence*/ - for (j=1; j<=l; j++) { - char *subpat_pat; - int i = l-j; - if (is_utf8_follow(word[i])) continue; /* Do not start halfway an utf8 sequence*/ - if ((subpat_pat = hyppat_lookup(dict->patterns,word+i,j))!=NULL) { - char* newpat_pat; - if ((newpat_pat = hyppat_lookup(dict->merged,word,l))==NULL) { - char *neworg; - unsigned char *newword=(unsigned char*)malloc(l+1); - int e=0; - strncpy((char*)newword, (char*)word,l); newword[l]=0; - for (i=0; imerged,newword,combine(neworg,subpat_pat)); - } else { - combine(newpat_pat,subpat_pat); - } - } - } - } - } - delete_HashIter(v); - - init_hash(&dict->state_num); - state_insert(dict->state_num, hnj_strdup((const unsigned char*)""), 0); - v = new_HashIter(dict->merged); - while (nextHashStealPattern(v,&word,&pattern)) { - static unsigned char mask[] = {0x3F,0x1F,0xF,0x7}; - int j = strlen((char*)word); -#ifdef VERBOSE - printf ("word %s pattern %s, j = %d\n", word, pattern, j); -#endif - state_num = hnj_get_state( dict, word, &found ); - dict->states[state_num].match = pattern; - - /* now, put in the prefix transitions */ - while (found < 0) { - j--; - last_state = state_num; - ch = word[j]; - if (ch>=0x80) { - int m; - int i=1; - while (is_utf8_follow(word[j-i])) i++; - ch = word[j-i] & mask[i]; - m = j-i; - while (i--) { - ch = (ch<<6)+(0x3F & word[j-i]); - } - j = m; - } - word[j] = '\0'; - state_num = hnj_get_state (dict, word, &found); - hnj_add_trans (dict, state_num, last_state, ch); - } - } - delete_HashIter(v); - clear_hyppat_hash(&dict->merged); - - /***************************************/ - - /* put in the fallback states */ - for (i = 0; i < HASH_SIZE; i++) { - for (e = dict->state_num->entries[i]; e; e = e->next) { - /* do not do state==0 otherwise things get confused*/ - if (e->u.state) { - for (j = 1; 1; j++) { - state_num = state_lookup(dict->state_num, e->key + j); - if (state_num >= 0) break; - } - dict->states[e->u.state].fallback_state = state_num; - } - } - } -#ifdef VERBOSE - for (i = 0; i < HASH_SIZE; i++) { - for (e = dict->state_num->entries[i]; e; e = e->next) { - printf ("%d string %s state %d, fallback=%d\n", i, e->key, e->u.state, - dict->states[e->u.state].fallback_state); - for (j = 0; j < dict->states[e->u.state].num_trans; j++) { - printf (" u%4x->%d\n", (int)dict->states[e->u.state].trans[j].uni_ch, - dict->states[e->u.state].trans[j].new_state); - } - } - } -#endif - clear_state_hash(&dict->state_num); -} - - -void hnj_hyphen_hyphenate( - HyphenDict *dict, - halfword first, - halfword last, - int length, - halfword left, - halfword right, - lang_variables *lan -) { - int char_num; - halfword here; - int state = 0; - /* +2 for dots at each end, +1 for points /outside/ characters*/ - int ext_word_len = length+2; - int hyphen_len = ext_word_len+1; - /*char *hyphens = hnj_malloc((hyphen_len*2)+1); */ /* LATER */ - char *hyphens = hnj_malloc(hyphen_len+1); - - /* Add a '.' to beginning and end to facilitate matching*/ - set_vlink(begin_point,first); - set_vlink(end_point,get_vlink(last)); - set_vlink(last,end_point); - - for (char_num = 0; char_num < hyphen_len; char_num++) { - /* hyphens[char_num*2] = '0'; */ /* LATER */ - /* hyphens[char_num*2+1] = '0'; */ /* LATER */ - hyphens[char_num] = '0'; - } - /*hyphens[hyphen_len*2] = 0; */ /* LATER */ - hyphens[hyphen_len] = 0; - - /* now, run the finite state machine */ - for (char_num=0, here=begin_point; here!=get_vlink(end_point); here=get_vlink(here)) { - - int ch; - if (here == begin_point || here == end_point) - ch='.'; - else - ch = get_lc_code(get_character(here)); - while (state!=-1) { - /* printf("%*s%s%c",char_num-strlen(get_state_str(state)),"",get_state_str(state),(char)ch);*/ - HyphenState *hstate = &dict->states[state]; - int k; - for (k = 0; k < hstate->num_trans; k++) { - if (hstate->trans[k].uni_ch == ch) { - char *match; - state = hstate->trans[k].new_state; - /* printf(" state %d\n",state);*/ - match = dict->states[state].match; - if (match) { - /* +2 because: - * 1 string length is one bigger than offset - * 1 hyphenation starts before first character - */ - int offset = char_num + 2 - strlen (match); - /* printf ("%*s%s\n", offset,"", match);*/ - int m; - for (m = 0; match[m]; m++) { - if (hyphens[offset+m] < match[m]) hyphens[offset+m] = match[m]; - } - } - goto try_next_letter; - } - } - state = hstate->fallback_state; - /* printf (" back to %d\n", state);*/ - } - /* nothing worked, let's go to the next character*/ - state = 0; -try_next_letter: ; - char_num++; - } - - /* restore the correct pointers*/ - set_vlink(last,get_vlink(end_point)); - - /* pattern is ^.^w^o^r^d^.^ word_len=4, ext_word_len=6, hyphens=7 - * check ^ ^ ^ so drop first two and stop after word_len-1 - */ - for (here=first,char_num=2; here!=left; here=get_vlink(here)) char_num++; - for (; here!=right; here=get_vlink(here)) { - if (hyphens[char_num] & 1) - here = insert_syllable_discretionary(here, lan); - char_num++; - } - hnj_free(hyphens); -} diff --git a/Build/source/texk/web2c/luatexdir/lang/hyphen.h b/Build/source/texk/web2c/luatexdir/lang/hyphen.h new file mode 100644 index 00000000000..8e5e5785c93 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lang/hyphen.h @@ -0,0 +1,60 @@ +/* LibHnj is dual licensed under LGPL and MPL. Boilerplate for both + * licenses follows. + */ + +/* LibHnj - a library for high quality hyphenation and justification + * Copyright (C) 1998 Raph Levien, (C) 2001 ALTLinux, Moscow + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307 USA. +*/ + +/* + * The contents of this file are subject to the Mozilla Public License + * Version 1.0 (the "MPL"); you may not use this file except in + * compliance with the MPL. You may obtain a copy of the MPL at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the MPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL + * for the specific language governing rights and limitations under the + * MPL. + * + */ +#ifndef __HYPHEN_H__ +# define __HYPHEN_H__ + +# ifdef __cplusplus +extern "C" { +# endif /* __cplusplus */ + + typedef struct _HyphenDict HyphenDict; + +# include "ptexlib.h" + + HyphenDict *hnj_hyphen_new(void); + void hnj_hyphen_load(HyphenDict * dict, const unsigned char *fn); + void hnj_hyphen_free(HyphenDict * dict); + void hnj_hyphen_clear(HyphenDict * dict); + void hnj_hyphen_hyphenate(HyphenDict * dict, halfword first, halfword last, + int size, halfword left, halfword right, + lang_variables * lan); + unsigned char *hnj_serialize(HyphenDict *); + void hnj_free_serialize(unsigned char *); + +# ifdef __cplusplus +} +# endif /* __cplusplus */ +#endif /* __HYPHEN_H__ */ diff --git a/Build/source/texk/web2c/luatexdir/lang/hyphen.w b/Build/source/texk/web2c/luatexdir/lang/hyphen.w new file mode 100644 index 00000000000..f7bbe6bd843 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lang/hyphen.w @@ -0,0 +1,857 @@ +% Libhnj is dual licensed under LGPL and MPL. Boilerplate for both +% licenses follows. +% +% +% LibHnj - a library for high quality hyphenation and justification +% Copyright (C) 1998 Raph Levien, +% (C) 2001 ALTLinux, Moscow (http://www.alt-linux.org), +% (C) 2001 Peter Novodvorsky (nidd@@cs.msu.su) +% +% This library is free software; you can redistribute it and/or +% modify it under the terms of the GNU Library General Public +% License as published by the Free Software Foundation; either +% version 2 of the License, or (at your option) any later version. +% +% This library is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +% Library General Public License for more details. +% +% You should have received a copy of the GNU Library General Public +% License along with this library; if not, write to the +% Free Software Foundation, Inc., 59 Temple Place - Suite 330, +% Boston, MA 02111-1307 USA. +% +% +% +% The contents of this file are subject to the Mozilla Public License +% Version 1.0 (the "MPL"); you may not use this file except in +% compliance with the MPL. You may obtain a copy of the MPL at +% http://www.mozilla.org/MPL/ +% +% Software distributed under the MPL is distributed on an "AS IS" basis, +% WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL +% for the specific language governing rights and limitations under the +% MPL. + + +@ @c +#include /* for NULL, malloc */ +#include /* for fprintf */ +#include /* for strdup */ +#include /* for malloc used by substring inclusion */ + +#define MAXPATHS 40960 + +#ifdef UNX +# include /* for exit */ +#endif + +#include + +#define noVERBOSE + +#include "lang/hnjalloc.h" +#include "lang/hyphen.h" + +@ @c +static const char _svn_version[] = + "$Id: hyphen.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lang/hyphen.w $"; + +@ TODO: should be moved to separate library + +@c +static unsigned char *hnj_strdup(const unsigned char *s) +{ + unsigned char *new; + size_t l; + + l = strlen((const char *) s); + new = hnj_malloc((int) l + 1); + memcpy(new, s, l); + new[l] = 0; + return new; +} + +static int is_utf8_follow(unsigned char c) +{ + if (c >= 0x80 && c < 0xC0) + return 1; + return 0; +} + +@* Type definitions. + +@ a little bit of a hash table implementation. This simply maps strings + to state numbers + +@c +typedef struct _HashTab HashTab; +typedef struct _HashEntry HashEntry; +typedef struct _HashIter HashIter; +typedef union _HashVal HashVal; + +/* A cheap, but effective, hack. */ +#define HASH_SIZE 31627 + +struct _HashTab { + HashEntry *entries[HASH_SIZE]; +}; + +union _HashVal { + int state; + char *hyppat; +}; + +struct _HashEntry { + HashEntry *next; + unsigned char *key; + HashVal u; +}; + +struct _HashIter { + HashEntry **e; + HashEntry *cur; + int ndx; +}; + +@ State machine + +@c +typedef struct _HyphenState HyphenState; +typedef struct _HyphenTrans HyphenTrans; +#define MAX_CHARS 256 +#define MAX_NAME 20 + +struct _HyphenDict { + int num_states; + int pat_length; + char cset[MAX_NAME]; + HyphenState *states; + HashTab *patterns; + HashTab *merged; + HashTab *state_num; +}; + +struct _HyphenState { + char *match; + /*char *repl; */ + /*signed char replindex; */ + /*signed char replcut; */ + int fallback_state; + int num_trans; + HyphenTrans *trans; +}; + +struct _HyphenTrans { + int uni_ch; + int new_state; +}; + + +@ Combine two right-aligned number patterns, 04000 + 020 becomes 04020 + +@c +static char *combine(char *expr, const char *subexpr) +{ + size_t l1 = strlen(expr); + size_t l2 = strlen(subexpr); + size_t off = l1 - l2; + unsigned j; + /* this works also for utf8 sequences because the substring is identical + to the last substring-length bytes of expr except for the (single byte) + hyphenation encoders + */ + for (j = 0; j < l2; j++) { + if (expr[off + j] < subexpr[j]) + expr[off + j] = subexpr[j]; + } + return expr; +} + + +@ ORIGINAL CODE +@c +HashIter *new_HashIter(HashTab * h) +{ + HashIter *i = hnj_malloc(sizeof(HashIter)); + i->e = h->entries; + i->cur = NULL; + i->ndx = -1; + return i; +} + + +int nextHashStealPattern(HashIter * i, unsigned char **word, char **pattern) +{ + while (i->cur == NULL) { + if (i->ndx >= HASH_SIZE - 1) + return 0; + i->cur = i->e[++i->ndx]; + } + *word = i->cur->key; + *pattern = i->cur->u.hyppat; + i->cur->u.hyppat = NULL; + i->cur = i->cur->next; + return 1; +} + + +int nextHash(HashIter * i, unsigned char **word) +{ + while (i->cur == NULL) { + if (i->ndx >= HASH_SIZE - 1) + return 0; + i->cur = i->e[++i->ndx]; + } + *word = i->cur->key; + i->cur = i->cur->next; + return 1; +} + + +int eachHash(HashIter * i, unsigned char **word, char **pattern) +{ + while (i->cur == NULL) { + if (i->ndx >= HASH_SIZE - 1) + return 0; + i->cur = i->e[++i->ndx]; + } + *word = i->cur->key; + *pattern = i->cur->u.hyppat; + i->cur = i->cur->next; + return 1; +} + + +void delete_HashIter(HashIter * i) +{ + hnj_free(i); +} + + +@ a |char*| hash function from ASU - adapted from Gtk+ + +@c +static unsigned int hnj_string_hash(const unsigned char *s) +{ + const unsigned char *p; + unsigned int h = 0, g; + + for (p = s; *p != '\0'; p += 1) { + h = (h << 4) + *p; + if ((g = (h & 0xf0000000))) { + h = h ^ (g >> 24); + h = h ^ g; + } + } + return h /* \% M */ ; +} + + +@ assumes that key is not already present! + +@c +static void state_insert(HashTab * hashtab, unsigned char *key, int state) +{ + int i; + HashEntry *e; + + i = (int) (hnj_string_hash(key) % HASH_SIZE); + e = hnj_malloc(sizeof(HashEntry)); + e->next = hashtab->entries[i]; + e->key = key; + e->u.state = state; + hashtab->entries[i] = e; +} + + +@ assumes that key is not already present! + +@c +static void hyppat_insert(HashTab * hashtab, unsigned char *key, char *hyppat) +{ + int i; + HashEntry *e; + + i = (int) (hnj_string_hash(key) % HASH_SIZE); + for (e = hashtab->entries[i]; e; e = e->next) { + if (strcmp((char *) e->key, (char *) key) == 0) { + if (e->u.hyppat) { + if (hyppat + && strcmp((char *) e->u.hyppat, (char *) hyppat) != 0) { + print_err("Conflicting pattern ignored"); + error(); + } + hnj_free(e->u.hyppat); + } + e->u.hyppat = hyppat; + hnj_free(key); + return; + } + } + e = hnj_malloc(sizeof(HashEntry)); + e->next = hashtab->entries[i]; + e->key = key; + e->u.hyppat = hyppat; + hashtab->entries[i] = e; +} + + +@ return state if found, otherwise $-1$ + +@c +static int state_lookup(HashTab * hashtab, const unsigned char *key) +{ + int i; + HashEntry *e; + + i = (int) (hnj_string_hash(key) % HASH_SIZE); + for (e = hashtab->entries[i]; e; e = e->next) { + if (!strcmp((const char *) key, (const char *) e->key)) { + return e->u.state; + } + } + return -1; +} + + +@ return state if found, otherwise $-1$ + +@c +static char *hyppat_lookup(HashTab * hashtab, const unsigned char *chars, int l) +{ + int i; + HashEntry *e; + unsigned char key[128]; /* should be ample */ + strncpy((char *) key, (const char *) chars, (size_t) l); + key[l] = 0; + i = (int) (hnj_string_hash(key) % HASH_SIZE); + for (e = hashtab->entries[i]; e; e = e->next) { + if (!strcmp((char *) key, (char *) e->key)) { + return e->u.hyppat; + } + } + return NULL; +} + + +@ Get the state number, allocating a new state if necessary. + +@c +static int hnj_get_state(HyphenDict * dict, + const unsigned char *str, int *state_num) +{ + *state_num = state_lookup(dict->state_num, str); + + if (*state_num >= 0) + return *state_num; + + state_insert(dict->state_num, hnj_strdup(str), dict->num_states); + /* predicate is true if |dict->num_states| is a power of two */ + if (!(dict->num_states & (dict->num_states - 1))) { + dict->states = hnj_realloc(dict->states, + (int) ((dict->num_states << 1) * + (int) sizeof(HyphenState))); + } + dict->states[dict->num_states].match = NULL; + dict->states[dict->num_states].fallback_state = -1; + dict->states[dict->num_states].num_trans = 0; + dict->states[dict->num_states].trans = NULL; + return dict->num_states++; +} + + +@ Add a transition from state1 to state2 through ch - assumes that the + transition does not already exist + +@c +static void hnj_add_trans(HyphenDict * dict, int state1, int state2, int uni_ch) +{ + int num_trans; + /* TH: this test was a bit too strict, it is quite normal for old + patterns to have chars in the range 0-31 or 127-159 (inclusive). + To ease the transition, let's only disallow NUL for now + (this is probably a requirement of the code anyway). + */ + if (uni_ch == 0) { + fprintf(stderr, "Character out of bounds: u%04x \n", uni_ch); + exit(1); + } + num_trans = dict->states[state1].num_trans; + if (num_trans == 0) { + dict->states[state1].trans = hnj_malloc(sizeof(HyphenTrans)); + } else if (!(num_trans & (num_trans - 1))) { + dict->states[state1].trans = hnj_realloc(dict->states[state1].trans, + (int) (num_trans << 1 * + sizeof(HyphenTrans))); + } + dict->states[state1].trans[num_trans].uni_ch = uni_ch; + dict->states[state1].trans[num_trans].new_state = state2; + dict->states[state1].num_trans++; +} + + +#ifdef VERBOSE + +static unsigned char *get_state_str(int state) +{ + int i; + HashEntry *e; + + for (i = 0; i < HASH_SIZE; i++) + for (e = global->entries[i]; e; e = e->next) + if (e->u.state == state) + return e->key; + return NULL; +} +#endif + + +@ I've changed the semantics a bit here: |hnj_hyphen_load| used to + operate on a file, but now the argument is a string buffer. + +@c +static const unsigned char *next_pattern(size_t * length, + const unsigned char **buf) +{ + const unsigned char *here, *rover = *buf; + while (*rover && isspace(*rover)) + rover++; + here = rover; + while (*rover) { + if (isspace(*rover)) { + *length = (size_t) (rover - here); + *buf = rover; + return here; + } + rover++; + } + *length = (size_t) (rover - here); + *buf = rover; + return *length ? here : NULL; /* zero sensed */ +} + +static void init_hash(HashTab ** h) +{ + int i; + if (*h) + return; + *h = hnj_malloc(sizeof(HashTab)); + for (i = 0; i < HASH_SIZE; i++) + (*h)->entries[i] = NULL; +} + + +static void clear_state_hash(HashTab ** h) +{ + int i; + if (*h == NULL) + return; + for (i = 0; i < HASH_SIZE; i++) { + HashEntry *e, *next; + for (e = (*h)->entries[i]; e; e = next) { + next = e->next; + hnj_free(e->key); + hnj_free(e); + } + } + hnj_free(*h); + *h = NULL; +} + + +static void clear_hyppat_hash(HashTab ** h) +{ + int i; + if (*h == NULL) + return; + for (i = 0; i < HASH_SIZE; i++) { + HashEntry *e, *next; + for (e = (*h)->entries[i]; e; e = next) { + next = e->next; + hnj_free(e->key); + if (e->u.hyppat) + hnj_free(e->u.hyppat); + hnj_free(e); + } + } + hnj_free(*h); + *h = NULL; +} + + +static void init_dict(HyphenDict * dict) +{ + dict->num_states = 1; + dict->pat_length = 0; + dict->states = hnj_malloc(sizeof(HyphenState)); + dict->states[0].match = NULL; + dict->states[0].fallback_state = -1; + dict->states[0].num_trans = 0; + dict->states[0].trans = NULL; + dict->patterns = NULL; + dict->merged = NULL; + dict->state_num = NULL; + init_hash(&dict->patterns); +} + + +static void clear_dict(HyphenDict * dict) +{ + int state_num; + for (state_num = 0; state_num < dict->num_states; state_num++) { + HyphenState *hstate = &dict->states[state_num]; + if (hstate->match) + hnj_free(hstate->match); + if (hstate->trans) + hnj_free(hstate->trans); + } + hnj_free(dict->states); + clear_hyppat_hash(&dict->patterns); + clear_hyppat_hash(&dict->merged); + clear_state_hash(&dict->state_num); +} + + + +HyphenDict *hnj_hyphen_new(void) +{ + HyphenDict *dict = hnj_malloc(sizeof(HyphenDict)); + init_dict(dict); + return dict; +} + + +void hnj_hyphen_clear(HyphenDict * dict) +{ + clear_dict(dict); + init_dict(dict); +} + + +void hnj_hyphen_free(HyphenDict * dict) +{ + clear_dict(dict); + hnj_free(dict); +} + +unsigned char *hnj_serialize(HyphenDict * dict) +{ + HashIter *v; + unsigned char *word; + char *pattern; + unsigned char *buf = hnj_malloc(dict->pat_length); + unsigned char *cur = buf; + v = new_HashIter(dict->patterns); + while (eachHash(v, &word, &pattern)) { + int i = 0, e = 0; + while (word[e + i]) { + if (pattern[i] != '0') + *cur++ = (unsigned char) pattern[i]; + *cur++ = word[e + i++]; + while (is_utf8_follow(word[e + i])) + *cur++ = word[i + e++]; + } + if (pattern[i] != '0') + *cur++ = (unsigned char) pattern[i]; + *cur++ = ' '; + } + delete_HashIter(v); + *cur = 0; + return buf; +} + + +void hnj_free_serialize(unsigned char *c) +{ + hnj_free(c); +} + + +@ hyphenation pattern: + +signed bytes + +0 indicates end (actually any negative number) + +: prio(1+),startpos,length,len1,[replace],len2,[replace] + +most basic example is: + +p n 0 0 0 + +for a hyphenation point between characters + + +@c +void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f) +{ + int state_num, last_state; + int i, j = 0; + int ch; + int found; + HashEntry *e; + HashIter *v; + unsigned char *word; + char *pattern; + size_t l = 0; + + const unsigned char *format; + const unsigned char *begin = f; + unsigned char *pat; + char *org; + while ((format = next_pattern(&l, &f)) != NULL) { + int i, j, e; +#if 0 + printf("%s\n",format); + char* repl = strnchr(format, '/',l); + int replindex = 0; + int replcut = 0; + if (repl) { + int clen = l-(repl-format); + l = repl-format; + char * index = strnchr(repl + 1, ',',clen); + if (index) { + char * index2 = strnchr(index + 1, ',',clen-(index-repl)); + if (index2) { + replindex = (signed char) atoi(index + 1) - 1; + replcut = (signed char) atoi(index2 + 1); + } + } else { + hnj_strchomp(repl + 1); + replindex = 0; + replcut = strlen(buf); + } + repl = hnj_strdup(repl + 1); + } +#endif + for (i = 0, j = 0, e = 0; (unsigned) i < l; i++) { + if (format[i] >= '0' && format[i] <= '9') + j++; + if (is_utf8_follow(format[i])) + e++; + } + /* |l-e| => number of {\it characters} not {\it bytes} */ + /* |l-j| => number of pattern bytes */ + /* |l-e-j| => number of pattern characters */ + pat = (unsigned char *) malloc((1 + l - (size_t) j)); + org = (char *) malloc((size_t) (2 + l - (size_t) e - (size_t) j)); + /* remove hyphenation encoders (digits) from pat */ + org[0] = '0'; + for (i = 0, j = 0, e = 0; (unsigned) i < l; i++) { + unsigned char c = format[i]; + if (is_utf8_follow(c)) { + pat[j + e++] = c; + } else if (c < '0' || c > '9') { + pat[e + j++] = c; + org[j] = '0'; + } else { + org[j] = (char) c; + } + } + pat[e + j] = 0; + org[j + 1] = 0; + hyppat_insert(dict->patterns, pat, org); + } + dict->pat_length += (int) ((f - begin) + 2); /* 2 for spurious spaces */ + init_hash(&dict->merged); + v = new_HashIter(dict->patterns); + while (nextHash(v, &word)) { + int wordsize = (int) strlen((char *) word); + int j, l; + for (l = 1; l <= wordsize; l++) { + if (is_utf8_follow(word[l])) + continue; /* Do not clip an utf8 sequence */ + for (j = 1; j <= l; j++) { + char *subpat_pat; + int i = l - j; + if (is_utf8_follow(word[i])) + continue; /* Do not start halfway an utf8 sequence */ + if ((subpat_pat = + hyppat_lookup(dict->patterns, word + i, j)) != NULL) { + char *newpat_pat; + if ((newpat_pat = + hyppat_lookup(dict->merged, word, l)) == NULL) { + char *neworg; + unsigned char *newword = + (unsigned char *) malloc((size_t) (l + 1)); + int e = 0; + strncpy((char *) newword, (char *) word, (size_t) l); + newword[l] = 0; + for (i = 0; i < l; i++) + if (is_utf8_follow(newword[i])) + e++; + neworg = malloc((size_t) (l + 2 - e)); + sprintf(neworg, "%0*d", l + 1 - e, 0); /* fill with right amount of '0' */ + hyppat_insert(dict->merged, newword, + combine(neworg, subpat_pat)); + } else { + combine(newpat_pat, subpat_pat); + } + } + } + } + } + delete_HashIter(v); + + init_hash(&dict->state_num); + state_insert(dict->state_num, hnj_strdup((const unsigned char *) ""), 0); + v = new_HashIter(dict->merged); + while (nextHashStealPattern(v, &word, &pattern)) { + static unsigned char mask[] = { 0x3F, 0x1F, 0xF, 0x7 }; + int j = (int) strlen((char *) word); +#ifdef VERBOSE + printf("word %s pattern %s, j = %d\n", word, pattern, j); +#endif + state_num = hnj_get_state(dict, word, &found); + dict->states[state_num].match = pattern; + + /* now, put in the prefix transitions */ + while (found < 0) { + j--; + last_state = state_num; + ch = word[j]; + if (ch >= 0x80) { + int m; + int i = 1; + while (is_utf8_follow(word[j - i])) + i++; + ch = word[j - i] & mask[i]; + m = j - i; + while (i--) { + ch = (ch << 6) + (0x3F & word[j - i]); + } + j = m; + } + word[j] = '\0'; + state_num = hnj_get_state(dict, word, &found); + hnj_add_trans(dict, state_num, last_state, ch); + } + } + delete_HashIter(v); + clear_hyppat_hash(&dict->merged); + + /* put in the fallback states */ + for (i = 0; i < HASH_SIZE; i++) { + for (e = dict->state_num->entries[i]; e; e = e->next) { + /* do not do state==0 otherwise things get confused */ + if (e->u.state) { + for (j = 1; 1; j++) { + state_num = state_lookup(dict->state_num, e->key + j); + if (state_num >= 0) + break; + } + dict->states[e->u.state].fallback_state = state_num; + } + } + } +#ifdef VERBOSE + for (i = 0; i < HASH_SIZE; i++) { + for (e = dict->state_num->entries[i]; e; e = e->next) { + printf("%d string %s state %d, fallback=%d\n", i, e->key, + e->u.state, dict->states[e->u.state].fallback_state); + for (j = 0; j < dict->states[e->u.state].num_trans; j++) { + printf(" u%4x->%d\n", + (int) dict->states[e->u.state].trans[j].uni_ch, + dict->states[e->u.state].trans[j].new_state); + } + } + } +#endif + clear_state_hash(&dict->state_num); +} + +@ @c +void hnj_hyphen_hyphenate(HyphenDict * dict, + halfword first, + halfword last, + int length, + halfword left, halfword right, lang_variables * lan) +{ + int char_num; + halfword here; + int state = 0; + /* +2 for dots at each end, +1 for points /outside/ characters */ + int ext_word_len = length + 2; + int hyphen_len = ext_word_len + 1; + char *hyphens = hnj_malloc(hyphen_len + 1); + + /* Add a '.' to beginning and end to facilitate matching */ + set_vlink(begin_point, first); + set_vlink(end_point, get_vlink(last)); + set_vlink(last, end_point); + + for (char_num = 0; char_num < hyphen_len; char_num++) { + hyphens[char_num] = '0'; + } + hyphens[hyphen_len] = 0; + + /* now, run the finite state machine */ + for (char_num = 0, here = begin_point; here != get_vlink(end_point); + here = get_vlink(here)) { + + int ch; + if (here == begin_point || here == end_point) + ch = '.'; + else + ch = get_lc_code(get_character(here)); + while (state != -1) { +#if 0 + printf("%*s%s%c",char_num-strlen(get_state_str(state)),"",get_state_str(state),(char)ch); +#endif + HyphenState *hstate = &dict->states[state]; + int k; + for (k = 0; k < hstate->num_trans; k++) { + if (hstate->trans[k].uni_ch == ch) { + char *match; + state = hstate->trans[k].new_state; +#if 0 + printf(" state %d\n",state); +#endif + match = dict->states[state].match; + if (match) { + /* +2 because: + 1 string length is one bigger than offset + 1 hyphenation starts before first character + */ + int offset = (int) (char_num + 2 - (int) strlen(match)); +#if 0 + printf ("%*s%s\n", offset,"", match); +#endif + int m; + for (m = 0; match[m]; m++) { + if (hyphens[offset + m] < match[m]) + hyphens[offset + m] = match[m]; + } + } + goto try_next_letter; + } + } + state = hstate->fallback_state; +#if 0 + printf (" back to %d\n", state); +#endif + } + /* nothing worked, let's go to the next character */ + state = 0; + try_next_letter:; + char_num++; + } + + /* restore the correct pointers */ + set_vlink(last, get_vlink(end_point)); + + /* pattern is \.{\^.\^w\^o\^r\^d\^.\^} |word_len|=4, |ext_word_len|=6, |hyphens|=7 + * check \.{ \^ \^ \^ } so drop first two and stop after |word_len-1| + */ + for (here = first, char_num = 2; here != left; here = get_vlink(here)) + char_num++; + for (; here != right; here = get_vlink(here)) { + if (hyphens[char_num] & 1) + here = insert_syllable_discretionary(here, lan); + char_num++; + } + hnj_free(hyphens); +} diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.c b/Build/source/texk/web2c/luatexdir/lang/texlang.c deleted file mode 100644 index 5a17b2c34b6..00000000000 --- a/Build/source/texk/web2c/luatexdir/lang/texlang.c +++ /dev/null @@ -1,1025 +0,0 @@ -/* texlang.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "luatex-api.h" -#include - -#include - -#include "nodes.h" -#include "font/texfont.h" -#include "hyphen.h" - -static const char _svn_version[] = - "$Id: texlang.c 2596 2009-06-25 09:26:59Z taco $ $URL: http://scm.foundry.supelec.fr/svn/luatex/trunk/src/texk/web2c/luatexdir/lang/texlang.c $"; - -/* functions copied from the fontforge unicode library */ - -static unsigned int *utf82u_strcpy(unsigned int * ubuf, const char *utf8buf) -{ - int len = strlen(utf8buf) + 1; - unsigned int *upt = ubuf, *uend = ubuf + len - 1; - const unsigned char *pt = (const unsigned char *) utf8buf, *end = pt + strlen(utf8buf); - int w, w2; - - while (pt < end && *pt != '\0' && upt < uend) { - if (*pt <= 127) - *upt = *pt++; - else if (*pt <= 0xdf) { - *upt = ((*pt & 0x1f) << 6) | (pt[1] & 0x3f); - pt += 2; - } else if (*pt <= 0xef) { - *upt = ((*pt & 0xf) << 12) | ((pt[1] & 0x3f) << 6) | (pt[2] & 0x3f); - pt += 3; - } else { - w = (((*pt & 0x7) << 2) | ((pt[1] & 0x30) >> 4)) - 1; - w = (w << 6) | ((pt[1] & 0xf) << 2) | ((pt[2] & 0x30) >> 4); - w2 = ((pt[2] & 0xf) << 6) | (pt[3] & 0x3f); - *upt = w * 0x400 + w2 + 0x10000; - pt += 4; - } - ++upt; - } - *upt = '\0'; - return (ubuf); -} - -char *utf8_idpb(char *utf8_text, unsigned int ch) -{ - /* Increment and deposit character */ - if (ch >= 17 * 65536) - return (utf8_text); - - if (ch <= 127) - *utf8_text++ = ch; - else if (ch <= 0x7ff) { - *utf8_text++ = 0xc0 | (ch >> 6); - *utf8_text++ = 0x80 | (ch & 0x3f); - } else if (ch <= 0xffff) { - *utf8_text++ = 0xe0 | (ch >> 12); - *utf8_text++ = 0x80 | ((ch >> 6) & 0x3f); - *utf8_text++ = 0x80 | (ch & 0x3f); - } else { - unsigned int val = ch - 0x10000; - int u = ((val & 0xf0000) >> 16) + 1, z = (val & 0x0f000) >> 12, y = - (val & 0x00fc0) >> 6, x = val & 0x0003f; - *utf8_text++ = 0xf0 | (u >> 2); - *utf8_text++ = 0x80 | ((u & 3) << 4) | z; - *utf8_text++ = 0x80 | y; - *utf8_text++ = 0x80 | x; - } - return (utf8_text); -} - -static int u_strlen(register unsigned int * str) -{ - register int len = 0; - while (*str++ != '\0') - ++len; - return (len); -} - -#define noVERBOSE - -#define MAX_TEX_LANGUAGES 32768 - -static struct tex_language *tex_languages[MAX_TEX_LANGUAGES] = { NULL }; -static int next_lang_id = 0; - -struct tex_language *new_language(int n) -{ - struct tex_language *lang; - unsigned l; - if (n >= 0) { - l = (unsigned) n; - if (l != (MAX_TEX_LANGUAGES - 1)) - if (next_lang_id <= n) - next_lang_id = n + 1; - } else { - while (tex_languages[next_lang_id] != NULL) - next_lang_id++; - l = next_lang_id++; - } - if (l < (MAX_TEX_LANGUAGES - 1) && tex_languages[l] == NULL) { - lang = xmalloc(sizeof(struct tex_language)); - tex_languages[l] = lang; - lang->id = l; - lang->exceptions = 0; - lang->patterns = NULL; - lang->pre_hyphen_char = '-'; - lang->post_hyphen_char = 0; - lang->pre_exhyphen_char = 0; - lang->post_exhyphen_char = 0; - return lang; - } else { - return NULL; - } -} - -struct tex_language *get_language(int n) -{ - if (n >= 0 && n < MAX_TEX_LANGUAGES) { - if (tex_languages[n] != NULL) { - return tex_languages[n]; - } else { - return new_language(n); - } - } else { - return NULL; - } -} - -void set_pre_hyphen_char(integer n, integer v) -{ - struct tex_language *l = get_language((int) n); - if (l != NULL) - l->pre_hyphen_char = (int) v; -} - -void set_post_hyphen_char(integer n, integer v) -{ - struct tex_language *l = get_language((int) n); - if (l != NULL) - l->post_hyphen_char = (int) v; -} - - -void set_pre_exhyphen_char(integer n, integer v) -{ - struct tex_language *l = get_language((int) n); - if (l != NULL) - l->pre_exhyphen_char = (int) v; -} - -void set_post_exhyphen_char(integer n, integer v) -{ - struct tex_language *l = get_language((int) n); - if (l != NULL) - l->post_exhyphen_char = (int) v; -} - - - -integer get_pre_hyphen_char(integer n) -{ - struct tex_language *l = get_language((int) n); - if (l == NULL) - return -1; - return (integer) l->pre_hyphen_char; -} - -integer get_post_hyphen_char(integer n) -{ - struct tex_language *l = get_language((int) n); - if (l == NULL) - return -1; - return (integer) l->post_hyphen_char; -} - - -integer get_pre_exhyphen_char(integer n) -{ - struct tex_language *l = get_language((int) n); - if (l == NULL) - return -1; - return (integer) l->pre_exhyphen_char; -} - -integer get_post_exhyphen_char(integer n) -{ - struct tex_language *l = get_language((int) n); - if (l == NULL) - return -1; - return (integer) l->post_exhyphen_char; -} - -void load_patterns(struct tex_language *lang, const unsigned char *buffer) -{ - if (lang == NULL || buffer == NULL || strlen((const char *) buffer) == 0) - return; - if (lang->patterns == NULL) { - lang->patterns = hnj_hyphen_new(); - } - hnj_hyphen_load(lang->patterns, buffer); -} - -void clear_patterns(struct tex_language *lang) -{ - if (lang == NULL) - return; - if (lang->patterns != NULL) { - hnj_hyphen_clear(lang->patterns); - } -} - -void load_tex_patterns(int curlang, halfword head) -{ - char *s = tokenlist_to_cstring(head, 1, NULL); - load_patterns(get_language(curlang), (const unsigned char *) s); -} - - -#define STORE_CHAR(x) do { \ - word[w] = x; \ - if (wexceptions == 0) { - lua_newtable(L); - lang->exceptions = luaL_ref(L, LUA_REGISTRYINDEX); - } - lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions); - s = (const char *) buffer; - while (*s) { - while (isspace(*s)) - s++; - if (*s) { - value = s; - s = clean_hyphenation(s, &cleaned); - if (cleaned != NULL) { - if ((s - value) > 0) { - lua_pushstring(L, cleaned); - lua_pushlstring(L, value, (s - value)); - lua_rawset(L, -3); - } - free(cleaned); - } else { -#ifdef VERBOSE - fprintf(stderr, "skipping invalid hyphenation exception: %s\n", - value); -#endif - } - } - } -} - -void clear_hyphenation(struct tex_language *lang) -{ - if (lang == NULL) - return; - if (lang->exceptions != 0) { - luaL_unref(Luas, LUA_REGISTRYINDEX, lang->exceptions); - lang->exceptions = 0; - } -} - - -void load_tex_hyphenation(int curlang, halfword head) -{ - char *s = tokenlist_to_cstring(head, 1, NULL); - load_hyphenation(get_language(curlang), (const unsigned char *) s); -} - -/* TODO: clean this up. The delete_attribute_ref() statements are not very - nice, but needed. Also, in the post-break, it would be nicer to get the - attribute list from vlink(n). No rush, as it is currently not used much. */ - -halfword insert_discretionary(halfword t, halfword pre, halfword post, - halfword replace) -{ - halfword g, n; - int f; - n = new_node(disc_node, syllable_disc); - try_couple_nodes(n, vlink(t)); - couple_nodes(t, n); - if (replace != null) - f = font(replace); - else - f = get_cur_font(); /* for compound words following explicit hyphens */ - for (g = pre; g != null; g = vlink(g)) { - font(g) = f; - if (node_attr(t) != null) { - delete_attribute_ref(node_attr(g)); - node_attr(g) = node_attr(t); - attr_list_ref(node_attr(t)) += 1; - } - } - for (g = post; g != null; g = vlink(g)) { - font(g) = f; - if (node_attr(t) != null) { - delete_attribute_ref(node_attr(g)); - node_attr(g) = node_attr(t); - attr_list_ref(node_attr(t)) += 1; - } - } - for (g = replace; g != null; g = vlink(g)) { - if (node_attr(t) != null) { - delete_attribute_ref(node_attr(g)); - node_attr(g) = node_attr(t); - attr_list_ref(node_attr(t)) += 1; - } - } - if (node_attr(t) != null) { - delete_attribute_ref(node_attr(vlink(t))); - node_attr(vlink(t)) = node_attr(t); - attr_list_ref(node_attr(t)) += 1; - } - t = vlink(t); - set_disc_field(pre_break(t), pre); - set_disc_field(post_break(t), post); - set_disc_field(no_break(t), replace); - return t; -} - -halfword insert_syllable_discretionary(halfword t, lang_variables * lan) -{ - halfword g, n; - n = new_node(disc_node, syllable_disc); - couple_nodes(n, vlink(t)); - couple_nodes(t, n); - delete_attribute_ref(node_attr(n)); - if (node_attr(t) != null) { - node_attr(n) = node_attr(t); - attr_list_ref(node_attr(t))++; - } else { - node_attr(n) = null; - } - if (lan->pre_hyphen_char > 0) { - g = raw_glyph_node(); - set_to_character(g); - character(g) = lan->pre_hyphen_char; - font(g) = font(t); - lang_data(g) = lang_data(t); - if (node_attr(t) != null) { - node_attr(g) = node_attr(t); - attr_list_ref(node_attr(t))++; - } - set_disc_field(pre_break(n), g); - } - - if (lan->post_hyphen_char > 0) { - t = vlink(n); - g = raw_glyph_node(); - set_to_character(g); - character(g) = lan->post_hyphen_char; - font(g) = font(t); - lang_data(g) = lang_data(t); - if (node_attr(t) != null) { - node_attr(g) = node_attr(t); - attr_list_ref(node_attr(t)) += 1; - } - set_disc_field(post_break(n), g); - } - return n; -} - -halfword insert_word_discretionary(halfword t, lang_variables * lan) -{ - halfword pre = null, pos = null; - if (lan->pre_exhyphen_char > 0) - pre = insert_character(null, lan->pre_exhyphen_char); - if (lan->post_exhyphen_char > 0) - pos = insert_character(null, lan->post_exhyphen_char); - return insert_discretionary(t, pre, pos, null); -} - -halfword compound_word_break(halfword t, int clang) -{ - int disc; - lang_variables langdata; - langdata.pre_exhyphen_char = get_pre_exhyphen_char(clang); - langdata.post_exhyphen_char = get_post_exhyphen_char(clang); - disc = insert_word_discretionary(t, &langdata); - return disc; -} - - -halfword insert_complex_discretionary(halfword t, lang_variables * lan, - halfword pre, halfword pos, - halfword replace) -{ - (void) lan; - return insert_discretionary(t, pre, pos, replace); -} - - -halfword insert_character(halfword t, int c) -{ - halfword p; - p = new_node(glyph_node, 0); - set_to_character(p); - character(p) = c; - if (t != null) { - couple_nodes(t, p); - } - return p; -} - - -void set_disc_field(halfword f, halfword t) -{ - if (t != null) { - couple_nodes(f, t); - tlink(f) = tail_of_list(t); - } else { - vlink(f) = null; - tlink(f) = null; - } -} - - - -static char *hyphenation_exception(int exceptions, char *w) -{ - char *ret = NULL; - lua_State *L = Luas; - lua_checkstack(L, 2); - lua_rawgeti(L, LUA_REGISTRYINDEX, exceptions); - if (lua_istable(L, -1)) { /* ?? */ - lua_pushstring(L, w); /* word table */ - lua_rawget(L, -2); - if (lua_isstring(L, -1)) { - ret = xstrdup(lua_tostring(L, -1)); - } - lua_pop(L, 2); - } else { - lua_pop(L, 1); - } - return ret; -} - - -char *exception_strings(struct tex_language *lang) -{ - const char *value; - size_t size = 0, current = 0; - size_t l = 0; - char *ret = NULL; - lua_State *L = Luas; - if (lang->exceptions == 0) - return NULL; - lua_checkstack(L, 2); - lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions); - if (lua_istable(L, -1)) { - /* iterate and join */ - lua_pushnil(L); /* first key */ - while (lua_next(L, -2) != 0) { - value = lua_tolstring(L, -1, &l); - if (current + 2 + l > size) { - ret = xrealloc(ret, (1.2 * size) + current + l + 1024); - size = (1.2 * size) + current + l + 1024; - } - *(ret + current) = ' '; - strcpy(ret + current + 1, value); - current += l + 1; - lua_pop(L, 1); - } - } - return ret; -} - - -/* the sequence from |wordstart| to |r| can contain only normal characters */ -/* it could be faster to modify a halfword pointer and return an integer */ - -static halfword find_exception_part(unsigned int *j, int *uword, int len) -{ - halfword g = null, gg = null; - register int i = *j; - i++; /* this puts uword[i] on the '{' */ - while (i < len && uword[i + 1] != '}') { - if (g == null) { - gg = new_char(0, uword[i + 1]); - g = gg; - } else { - halfword s = new_char(0, uword[i + 1]); - couple_nodes(g, s); - g = vlink(g); - } - i++; - } - *j = ++i; - return gg; -} - -static int count_exception_part(unsigned int *j, int *uword, int len) -{ - int ret = 0; - register int i = *j; - i++; /* this puts uword[i] on the '{' */ - while (i < len && uword[i + 1] != '}') { - ret++; - i++; - } - *j = ++i; - return ret; -} - - -static const char *PAT_ERROR[] = { - "Exception discretionaries should contain three pairs of braced items.", - "No intervening spaces are allowed.", - NULL -}; - -static void do_exception(halfword wordstart, halfword r, char *replacement) -{ - unsigned i; - halfword t; - unsigned len; - int clang; - lang_variables langdata; - int uword[MAX_WORD_LEN + 1] = { 0 }; - (void) utf82u_strcpy((unsigned int *) uword, replacement); - len = u_strlen((unsigned int *) uword); - i = 0; - t = wordstart; - clang = char_lang(wordstart); - langdata.pre_hyphen_char = get_pre_hyphen_char(clang); - langdata.post_hyphen_char = get_post_hyphen_char(clang); - - for (i = 0; i < len; i++) { - if (uword[i + 1] == '-') { /* a hyphen follows */ - while (vlink(t) != r - && (type(t) != glyph_node || !is_simple_character(t))) - t = vlink(t); - if (vlink(t) == r) - break; - insert_syllable_discretionary(t, &langdata); - t = vlink(t); /* skip the new disc */ - } else if (uword[i + 1] == '=') { - /* do nothing ? */ - t = vlink(t); - } else if (uword[i + 1] == '{') { - halfword gg, hh, replace = null; - int repl; - gg = find_exception_part(&i, uword, len); - if (i == len || uword[i + 1] != '{') { - tex_error("broken pattern 1", PAT_ERROR); - } - hh = find_exception_part(&i, uword, len); - if (i == len || uword[i + 1] != '{') { - tex_error("broken pattern 2", PAT_ERROR); - } - repl = count_exception_part(&i, uword, len); - if (i == len) { - tex_error("broken pattern 3", PAT_ERROR); - } - /*i++; *//* jump over the last right brace */ - if (vlink(t) == r) - break; - if (repl > 0) { - halfword q = t; - replace = vlink(q); - while (repl > 0 && q != null) { - q = vlink(q); - if (type(q) == glyph_node) { - repl--; - } - } - try_couple_nodes(t, vlink(q)); - vlink(q) = null; - } - t = insert_discretionary(t, gg, hh, replace); - t = vlink(t); /* skip the new disc */ - } else { - t = vlink(t); - } - } -} - -/* This is a documentation section from the pascal web file. It is not -true any more, but I do not have time right now to rewrite it -- Taco - -When the line-breaking routine is unable to find a feasible sequence of -breakpoints, it makes a second pass over the paragraph, attempting to -hyphenate the hyphenatable words. The goal of hyphenation is to insert -discretionary material into the paragraph so that there are more -potential places to break. - -The general rules for hyphenation are somewhat complex and technical, -because we want to be able to hyphenate words that are preceded or -followed by punctuation marks, and because we want the rules to work -for languages other than English. We also must contend with the fact -that hyphens might radically alter the ligature and kerning structure -of a word. - -A sequence of characters will be considered for hyphenation only if it -belongs to a ``potentially hyphenatable part'' of the current paragraph. -This is a sequence of nodes $p_0p_1\ldots p_m$ where $p_0$ is a glue node, -$p_1\ldots p_{m-1}$ are either character or ligature or whatsit or -implicit kern nodes, and $p_m$ is a glue or penalty or insertion or adjust -or mark or whatsit or explicit kern node. (Therefore hyphenation is -disabled by boxes, math formulas, and discretionary nodes already inserted -by the user.) The ligature nodes among $p_1\ldots p_{m-1}$ are effectively -expanded into the original non-ligature characters; the kern nodes and -whatsits are ignored. Each character |c| is now classified as either a -nonletter (if |lc_code(c)=0|), a lowercase letter (if -|lc_code(c)=c|), or an uppercase letter (otherwise); an uppercase letter -is treated as if it were |lc_code(c)| for purposes of hyphenation. The -characters generated by $p_1\ldots p_{m-1}$ may begin with nonletters; let -$c_1$ be the first letter that is not in the middle of a ligature. Whatsit -nodes preceding $c_1$ are ignored; a whatsit found after $c_1$ will be the -terminating node $p_m$. All characters that do not have the same font as -$c_1$ will be treated as nonletters. The |hyphen_char| for that font -must be between 0 and 255, otherwise hyphenation will not be attempted. -\TeX\ looks ahead for as many consecutive letters $c_1\ldots c_n$ as -possible; however, |n| must be less than 64, so a character that would -otherwise be $c_{64}$ is effectively not a letter. Furthermore $c_n$ must -not be in the middle of a ligature. In this way we obtain a string of -letters $c_1\ldots c_n$ that are generated by nodes $p_a\ldots p_b$, where -|1<=a<=b+1<=m|. If |n>=l_hyf+r_hyf|, this string qualifies for hyphenation; -however, |uc_hyph| must be positive, if $c_1$ is uppercase. - -The hyphenation process takes place in three stages. First, the candidate -sequence $c_1\ldots c_n$ is found; then potential positions for hyphens -are determined by referring to hyphenation tables; and finally, the nodes -$p_a\ldots p_b$ are replaced by a new sequence of nodes that includes the -discretionary breaks found. - -Fortunately, we do not have to do all this calculation very often, because -of the way it has been taken out of \TeX's inner loop. For example, when -the second edition of the author's 700-page book {\sl Seminumerical -Algorithms} was typeset by \TeX, only about 1.2 hyphenations needed to be -@^Knuth, Donald Ervin@> -tried per paragraph, since the line breaking algorithm needed to use two -passes on only about 5 per cent of the paragraphs. - - -When a word been set up to contain a candidate for hyphenation, -\TeX\ first looks to see if it is in the user's exception dictionary. If not, -hyphens are inserted based on patterns that appear within the given word, -using an algorithm due to Frank~M. Liang. -@^Liang, Franklin Mark@> -*/ - -/* - * This is incompatible with TEX because the first word of a paragraph - * can be hyphenated, but most european users seem to agree that - * prohibiting hyphenation there was not the best idea ever. - */ - -static halfword find_next_wordstart(halfword r) -{ - register int l; - register int start_ok = 1; - int mathlevel = 1; - while (r != null) { - switch (type(r)) { - case glue_node: - start_ok = 1; - break; - case math_node: - while (mathlevel > 0) { - r = vlink(r); - if (r == null) - return r; - if (type(r) == math_node) { - if (subtype(r) == before) { - mathlevel++; - } else { - mathlevel--; - } - } - } - break; - case glyph_node: - if (start_ok && - is_simple_character(r) && - (l = get_lc_code(character(r))) > 0 && - (char_uchyph(r) || l == character(r))) - return r; - break; - default: - start_ok = 0; - break; - } - r = vlink(r); - } - return r; -} - -static int valid_wordend(halfword s) -{ - register halfword r = s; - register int clang = char_lang(s); - if (r == null) - return 1; - while ((r != null) && ((type(r) == glyph_node && is_simple_character(r) - && clang == char_lang(r)) || (type(r) == kern_node - && subtype(r) == - normal))) { - r = vlink(r); - } - if (r == null || (type(r) == glyph_node && is_simple_character(r) - && clang != char_lang(r)) || type(r) == glue_node - || type(r) == whatsit_node || type(r) == ins_node - || type(r) == adjust_node || type(r) == penalty_node - || (type(r) == kern_node && subtype(r) == explicit)) - return 1; - return 0; -} - -void hnj_hyphenation(halfword head, halfword tail) -{ - int lchar, i; - struct tex_language *lang; - lang_variables langdata; - char utf8word[(4 * MAX_WORD_LEN) + 1] = { 0 }; - int wordlen = 0; - char *hy = utf8word; - char *replacement = NULL; - halfword s, r = head, wordstart = null, save_tail = null, left = - null, right = null; - - /* this first movement assures two things: - * a) that we won't waste lots of time on something that has been - * handled already (in that case, none of the glyphs match |simple_character|). - * b) that the first word can be hyphenated. if the movement was - * not explicit, then the indentation at the start of a paragraph - * list would make find_next_wordstart() look too far ahead. - */ - - while (r != null && (type(r) != glyph_node || !is_simple_character(r))) { - r = vlink(r); - } - /* this will make |r| a glyph node with subtype_character */ - r = find_next_wordstart(r); - if (r == null) - return; - - assert(tail != null); - save_tail = vlink(tail); - s = new_penalty(0); - couple_nodes(tail, s); - - while (r != null) { /* could be while(1), but let's be paranoid */ - int clang, lhmin, rhmin; - halfword hyf_font; - halfword end_word = r; - wordstart = r; - assert(is_simple_character(wordstart)); - hyf_font = font(wordstart); - if (hyphen_char(hyf_font) < 0) /* for backward compat */ - hyf_font = 0; - clang = char_lang(wordstart); - lhmin = char_lhmin(wordstart); - rhmin = char_rhmin(wordstart); - langdata.pre_hyphen_char = get_pre_hyphen_char(clang); - langdata.post_hyphen_char = get_post_hyphen_char(clang); - while (r != null && - type(r) == glyph_node && - is_simple_character(r) && - clang == char_lang(r) && - (lchar = get_lc_code(character(r))) > 0) { - wordlen++; - hy = utf8_idpb(hy, lchar); - /* this should not be needed any more */ - /*if (vlink(r)!=null) alink(vlink(r))=r; */ - end_word = r; - r = vlink(r); - } - if (valid_wordend(r) && wordlen >= lhmin + rhmin - && (hyf_font != 0) && (lang = tex_languages[clang]) != NULL) { - *hy = 0; - if (lang->exceptions != 0 && - (replacement = - hyphenation_exception(lang->exceptions, utf8word)) != NULL) { -#ifdef VERBOSE - fprintf(stderr, "replacing %s (c=%d) by %s\n", utf8word, clang, - replacement); -#endif - do_exception(wordstart, r, replacement); - free(replacement); - } else if (lang->patterns != NULL) { - - left = wordstart; - for (i = lhmin; i > 1; i--) { - left = vlink(left); - while (!is_simple_character(left)) - left = vlink(left); - } - right = r; - for (i = rhmin; i > 0; i--) { - right = alink(right); - while (!is_simple_character(right)) - right = alink(right); - } - -#ifdef VERBOSE - fprintf(stderr, "hyphenate %s (c=%d,l=%d,r=%d) from %c to %c\n", - utf8word, clang, lhmin, rhmin, character(left), - character(right)); -#endif - (void) hnj_hyphen_hyphenate(lang->patterns, wordstart, end_word, - wordlen, left, right, &langdata); - } - } - wordlen = 0; - hy = utf8word; - if (r == null) - break; - r = find_next_wordstart(r); - } - flush_node(vlink(tail)); - vlink(tail) = save_tail; -} - - -void new_hyphenation(halfword head, halfword tail) -{ - register int callback_id = 0; - if (head == null || vlink(head) == null) - return; - fix_node_list(head); /* TODO: use couple_nodes() in append_tail()! */ - callback_id = callback_defined(hyphenate_callback); - if (callback_id > 0) { - lua_State *L = Luas; - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); - return; - } - nodelist_to_lua(L, head); - nodelist_to_lua(L, tail); - if (lua_pcall(L, 2, 0, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); - lua_error(L); - return; - } - lua_pop(L, 1); - } else if (callback_id == 0) { - hnj_hyphenation(head, tail); - } -} - -/* dumping and undumping fonts */ - -#define dump_string(a) \ - if (a!=NULL) { \ - x = strlen(a)+1; \ - dump_int(x); dump_things(*a, x); \ - } else { \ - x = 0; dump_int(x); \ - } - - -static void dump_one_language(int i) -{ - char *s = NULL; - integer x = 0; - struct tex_language *lang; - lang = tex_languages[i]; - dump_int(lang->id); - dump_int(lang->pre_hyphen_char); - dump_int(lang->post_hyphen_char); - dump_int(lang->pre_exhyphen_char); - dump_int(lang->post_exhyphen_char); - if (lang->patterns != NULL) { - s = (char *) hnj_serialize(lang->patterns); - } - dump_string(s); - if (s != NULL) { - free(s); - s = NULL; - } - if (lang->exceptions != 0) - s = exception_strings(lang); - dump_string(s); - if (s != NULL) { - free(s); - } - free(lang); -} - -void dump_language_data(void) -{ - integer i; - dump_int(next_lang_id); - for (i = 0; i < next_lang_id; i++) { - if (tex_languages[i]) { - dump_int(1); - dump_one_language(i); - } else { - dump_int(0); - } - } -} - - -static void undump_one_language(int i) -{ - char *s = NULL; - integer x = 0; - struct tex_language *lang = get_language(i); - undump_int(x); - lang->id = x; - undump_int(x); - lang->pre_hyphen_char = x; - undump_int(x); - lang->post_hyphen_char = x; - undump_int(x); - lang->pre_exhyphen_char = x; - undump_int(x); - lang->post_exhyphen_char = x; - /* patterns */ - undump_int(x); - if (x > 0) { - s = xmalloc(x); - undump_things(*s, x); - load_patterns(lang, (const unsigned char *) s); - free(s); - } - /* exceptions */ - undump_int(x); - if (x > 0) { - s = xmalloc(x); - undump_things(*s, x); - load_hyphenation(lang, (const unsigned char *) s); - free(s); - } -} - -void undump_language_data(void) -{ - integer i, x, numlangs; - undump_int(numlangs); - next_lang_id = numlangs; - for (i = 0; i < numlangs; i++) { - undump_int(x); - if (x == 1) { - undump_one_language(i); - } - } -} diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.h b/Build/source/texk/web2c/luatexdir/lang/texlang.h new file mode 100644 index 00000000000..b312dab1a3a --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lang/texlang.h @@ -0,0 +1,82 @@ +/* texlang.h + + Copyright 2009 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ + +/* $Id: texlang.h 3394 2010-01-26 14:20:46Z taco $ */ + +#ifndef TEXLANG_H +# define TEXLANG_H + +typedef struct _lang_variables { + int pre_hyphen_char; + int post_hyphen_char; + int pre_exhyphen_char; + int post_exhyphen_char; +} lang_variables; + +# include "lang/hyphen.h" + +struct tex_language { + HyphenDict *patterns; + int exceptions; /* lua registry pointer, should be replaced */ + int id; + int pre_hyphen_char; + int post_hyphen_char; + int pre_exhyphen_char; + int post_exhyphen_char; +}; + +# define MAX_WORD_LEN 256 /* in chars */ + +extern struct tex_language *new_language(int n); +extern struct tex_language *get_language(int n); +extern void load_patterns(struct tex_language *lang, const unsigned char *buf); +extern void load_hyphenation(struct tex_language *lang, + const unsigned char *buf); +extern int hyphenate_string(struct tex_language *lang, char *w, char **ret); + +extern void new_hyphenation(halfword h, halfword t); +extern void clear_patterns(struct tex_language *lang); +extern void clear_hyphenation(struct tex_language *lang); +extern const char *clean_hyphenation(const char *buffer, char **cleaned); +extern void hnj_hyphenation(halfword head, halfword tail); + +extern void set_pre_hyphen_char(int lan, int val); +extern void set_post_hyphen_char(int lan, int val); +extern int get_pre_hyphen_char(int lan); +extern int get_post_hyphen_char(int lan); + +extern void set_pre_exhyphen_char(int lan, int val); +extern void set_post_exhyphen_char(int lan, int val); +extern int get_pre_exhyphen_char(int lan); +extern int get_post_exhyphen_char(int lan); +extern halfword compound_word_break(halfword t, int clang); + +extern void dump_language_data(void); +extern void undump_language_data(void); +extern char *exception_strings(struct tex_language *lang); + +extern void new_hyph_exceptions(void); +extern void new_patterns(void); +extern void new_pre_hyphen_char(void); +extern void new_post_hyphen_char(void); +extern void new_pre_exhyphen_char(void); +extern void new_post_exhyphen_char(void); + + +#endif diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.w b/Build/source/texk/web2c/luatexdir/lang/texlang.w new file mode 100644 index 00000000000..6fcb7180820 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lang/texlang.w @@ -0,0 +1,1111 @@ +% texlang.w +% +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "ptexlib.h" + +#include + +#include "lua/luatex-api.h" + + +static const char _svn_version[] = + "$Id: texlang.w 3584 2010-04-02 17:45:55Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lang/texlang.w $"; + + +@ Low-level helpers + +@c +static char *uni2string(char *utf8_text, unsigned ch) +{ + /* Increment and deposit character */ + if (ch >= 17 * 65536) + return (utf8_text); + + if (ch <= 127) + *utf8_text++ = (char) ch; + else if (ch <= 0x7ff) { + *utf8_text++ = (char) (0xc0 | (ch >> 6)); + *utf8_text++ = (char) (0x80 | (ch & 0x3f)); + } else if (ch <= 0xffff) { + *utf8_text++ = (char) (0xe0 | (ch >> 12)); + *utf8_text++ = (char) (0x80 | ((ch >> 6) & 0x3f)); + *utf8_text++ = (char) (0x80 | (ch & 0x3f)); + } else { + unsigned val = ch - 0x10000; + unsigned u = ((val & 0xf0000) >> 16) + 1, z = (val & 0x0f000) >> 12, y = + (val & 0x00fc0) >> 6, x = val & 0x0003f; + *utf8_text++ = (char) (0xf0 | (u >> 2)); + *utf8_text++ = (char) (0x80 | ((u & 3) << 4) | z); + *utf8_text++ = (char) (0x80 | y); + *utf8_text++ = (char) (0x80 | x); + } + return (utf8_text); +} + +static unsigned u_length(register unsigned int *str) +{ + register unsigned len = 0; + while (*str++ != '\0') + ++len; + return (len); +} + + +static void utf82u_strcpy(unsigned int *ubuf, const char *utf8buf) +{ + int len = (int) strlen(utf8buf) + 1; + unsigned int *upt = ubuf, *uend = ubuf + len - 1; + const unsigned char *pt = (const unsigned char *) utf8buf, *end = + pt + strlen(utf8buf); + int w, w2; + + while (pt < end && *pt != '\0' && upt < uend) { + if (*pt <= 127) + *upt = *pt++; + else if (*pt <= 0xdf) { + *upt = (unsigned int) (((*pt & 0x1f) << 6) | (pt[1] & 0x3f)); + pt += 2; + } else if (*pt <= 0xef) { + *upt = + (unsigned int) (((*pt & 0xf) << 12) | ((pt[1] & 0x3f) << 6) | + (pt[2] & 0x3f)); + pt += 3; + } else { + w = (((*pt & 0x7) << 2) | ((pt[1] & 0x30) >> 4)) - 1; + w = (w << 6) | ((pt[1] & 0xf) << 2) | ((pt[2] & 0x30) >> 4); + w2 = ((pt[2] & 0xf) << 6) | (pt[3] & 0x3f); + *upt = (unsigned int) (w * 0x400 + w2 + 0x10000); + pt += 4; + } + ++upt; + } + *upt = '\0'; +} + +@ @c +#define noVERBOSE + +#define MAX_TEX_LANGUAGES 32768 + +static struct tex_language *tex_languages[MAX_TEX_LANGUAGES] = { NULL }; + +static int next_lang_id = 0; + +struct tex_language *new_language(int n) +{ + struct tex_language *lang; + unsigned l; + if (n >= 0) { + l = (unsigned) n; + if (l != (MAX_TEX_LANGUAGES - 1)) + if (next_lang_id <= n) + next_lang_id = n + 1; + } else { + while (tex_languages[next_lang_id] != NULL) + next_lang_id++; + l = (unsigned) next_lang_id++; + } + if (l < (MAX_TEX_LANGUAGES - 1) && tex_languages[l] == NULL) { + lang = xmalloc(sizeof(struct tex_language)); + tex_languages[l] = lang; + lang->id = (int) l; + lang->exceptions = 0; + lang->patterns = NULL; + lang->pre_hyphen_char = '-'; + lang->post_hyphen_char = 0; + lang->pre_exhyphen_char = 0; + lang->post_exhyphen_char = 0; + return lang; + } else { + return NULL; + } +} + +struct tex_language *get_language(int n) +{ + if (n >= 0 && n < MAX_TEX_LANGUAGES) { + if (tex_languages[n] != NULL) { + return tex_languages[n]; + } else { + return new_language(n); + } + } else { + return NULL; + } +} + +@ @c +void set_pre_hyphen_char(int n, int v) +{ + struct tex_language *l = get_language((int) n); + if (l != NULL) + l->pre_hyphen_char = (int) v; +} + +void set_post_hyphen_char(int n, int v) +{ + struct tex_language *l = get_language((int) n); + if (l != NULL) + l->post_hyphen_char = (int) v; +} + + +void set_pre_exhyphen_char(int n, int v) +{ + struct tex_language *l = get_language((int) n); + if (l != NULL) + l->pre_exhyphen_char = (int) v; +} + +void set_post_exhyphen_char(int n, int v) +{ + struct tex_language *l = get_language((int) n); + if (l != NULL) + l->post_exhyphen_char = (int) v; +} + + +int get_pre_hyphen_char(int n) +{ + struct tex_language *l = get_language((int) n); + if (l == NULL) + return -1; + return (int) l->pre_hyphen_char; +} + +int get_post_hyphen_char(int n) +{ + struct tex_language *l = get_language((int) n); + if (l == NULL) + return -1; + return (int) l->post_hyphen_char; +} + + +int get_pre_exhyphen_char(int n) +{ + struct tex_language *l = get_language((int) n); + if (l == NULL) + return -1; + return (int) l->pre_exhyphen_char; +} + +int get_post_exhyphen_char(int n) +{ + struct tex_language *l = get_language((int) n); + if (l == NULL) + return -1; + return (int) l->post_exhyphen_char; +} + +@ @c +void load_patterns(struct tex_language *lang, const unsigned char *buffer) +{ + if (lang == NULL || buffer == NULL || strlen((const char *) buffer) == 0) + return; + if (lang->patterns == NULL) { + lang->patterns = hnj_hyphen_new(); + } + hnj_hyphen_load(lang->patterns, buffer); +} + +void clear_patterns(struct tex_language *lang) +{ + if (lang == NULL) + return; + if (lang->patterns != NULL) { + hnj_hyphen_clear(lang->patterns); + } +} + +void load_tex_patterns(int curlang, halfword head) +{ + char *s = tokenlist_to_cstring(head, 1, NULL); + load_patterns(get_language(curlang), (unsigned char *) s); +} + + +@ @c +#define STORE_CHAR(x) do { \ + word[w] = (unsigned char)x; \ + if (wexceptions == 0) { + lua_newtable(L); + lang->exceptions = luaL_ref(L, LUA_REGISTRYINDEX); + } + lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions); + s = (const char *) buffer; + while (*s) { + while (isspace(*s)) + s++; + if (*s) { + value = s; + s = clean_hyphenation(s, &cleaned); + if (cleaned != NULL) { + if ((s - value) > 0) { + lua_pushstring(L, cleaned); + lua_pushlstring(L, value, (size_t) (s - value)); + lua_rawset(L, -3); + } + free(cleaned); + } else { +#ifdef VERBOSE + fprintf(stderr, "skipping invalid hyphenation exception: %s\n", + value); +#endif + } + } + } +} + +void clear_hyphenation(struct tex_language *lang) +{ + if (lang == NULL) + return; + if (lang->exceptions != 0) { + luaL_unref(Luas, LUA_REGISTRYINDEX, lang->exceptions); + lang->exceptions = 0; + } +} + + +void load_tex_hyphenation(int curlang, halfword head) +{ + char *s = tokenlist_to_cstring(head, 1, NULL); + load_hyphenation(get_language(curlang), (unsigned char *) s); +} + +@ TODO: clean this up. The |delete_attribute_ref()| statements are not very + nice, but needed. Also, in the post-break, it would be nicer to get the + attribute list from |vlink(n)|. No rush, as it is currently not used much. + +@c +halfword insert_discretionary(halfword t, halfword pre, halfword post, + halfword replace) +{ + halfword g, n; + int f; + n = new_node(disc_node, syllable_disc); + try_couple_nodes(n, vlink(t)); + couple_nodes(t, n); + if (replace != null) + f = font(replace); + else + f = get_cur_font(); /* for compound words following explicit hyphens */ + for (g = pre; g != null; g = vlink(g)) { + font(g) = f; + if (node_attr(t) != null) { + delete_attribute_ref(node_attr(g)); + node_attr(g) = node_attr(t); + attr_list_ref(node_attr(t)) += 1; + } + } + for (g = post; g != null; g = vlink(g)) { + font(g) = f; + if (node_attr(t) != null) { + delete_attribute_ref(node_attr(g)); + node_attr(g) = node_attr(t); + attr_list_ref(node_attr(t)) += 1; + } + } + for (g = replace; g != null; g = vlink(g)) { + if (node_attr(t) != null) { + delete_attribute_ref(node_attr(g)); + node_attr(g) = node_attr(t); + attr_list_ref(node_attr(t)) += 1; + } + } + if (node_attr(t) != null) { + delete_attribute_ref(node_attr(vlink(t))); + node_attr(vlink(t)) = node_attr(t); + attr_list_ref(node_attr(t)) += 1; + } + t = vlink(t); + set_disc_field(pre_break(t), pre); + set_disc_field(post_break(t), post); + set_disc_field(no_break(t), replace); + return t; +} + +halfword insert_syllable_discretionary(halfword t, lang_variables * lan) +{ + halfword g, n; + n = new_node(disc_node, syllable_disc); + couple_nodes(n, vlink(t)); + couple_nodes(t, n); + delete_attribute_ref(node_attr(n)); + if (node_attr(t) != null) { + node_attr(n) = node_attr(t); + attr_list_ref(node_attr(t))++; + } else { + node_attr(n) = null; + } + if (lan->pre_hyphen_char > 0) { + g = raw_glyph_node(); + set_to_character(g); + character(g) = lan->pre_hyphen_char; + font(g) = font(t); + lang_data(g) = lang_data(t); + if (node_attr(t) != null) { + node_attr(g) = node_attr(t); + attr_list_ref(node_attr(t))++; + } + set_disc_field(pre_break(n), g); + } + + if (lan->post_hyphen_char > 0) { + t = vlink(n); + g = raw_glyph_node(); + set_to_character(g); + character(g) = lan->post_hyphen_char; + font(g) = font(t); + lang_data(g) = lang_data(t); + if (node_attr(t) != null) { + node_attr(g) = node_attr(t); + attr_list_ref(node_attr(t)) += 1; + } + set_disc_field(post_break(n), g); + } + return n; +} + +halfword insert_word_discretionary(halfword t, lang_variables * lan) +{ + halfword pre = null, pos = null; + if (lan->pre_exhyphen_char > 0) + pre = insert_character(null, lan->pre_exhyphen_char); + if (lan->post_exhyphen_char > 0) + pos = insert_character(null, lan->post_exhyphen_char); + return insert_discretionary(t, pre, pos, null); +} + +@ @c +halfword compound_word_break(halfword t, int clang) +{ + int disc; + lang_variables langdata; + langdata.pre_exhyphen_char = get_pre_exhyphen_char(clang); + langdata.post_exhyphen_char = get_post_exhyphen_char(clang); + disc = insert_word_discretionary(t, &langdata); + return disc; +} + + +halfword insert_complex_discretionary(halfword t, lang_variables * lan, + halfword pre, halfword pos, + halfword replace) +{ + (void) lan; + return insert_discretionary(t, pre, pos, replace); +} + + +halfword insert_character(halfword t, int c) +{ + halfword p; + p = new_node(glyph_node, 0); + set_to_character(p); + character(p) = c; + if (t != null) { + couple_nodes(t, p); + } + return p; +} + +@ @c +void set_disc_field(halfword f, halfword t) +{ + if (t != null) { + couple_nodes(f, t); + tlink(f) = tail_of_list(t); + } else { + vlink(f) = null; + tlink(f) = null; + } +} + + + +@ @c +char *hyphenation_exception(int exceptions, char *w) +{ + char *ret = NULL; + lua_State *L = Luas; + lua_checkstack(L, 2); + lua_rawgeti(L, LUA_REGISTRYINDEX, exceptions); + if (lua_istable(L, -1)) { /* ?? */ + lua_pushstring(L, w); /* word table */ + lua_rawget(L, -2); + if (lua_isstring(L, -1)) { + ret = xstrdup(lua_tostring(L, -1)); + } + lua_pop(L, 2); + } else { + lua_pop(L, 1); + } + return ret; +} + + +@ @c +char *exception_strings(struct tex_language *lang) +{ + const char *value; + size_t size = 0, current = 0; + size_t l = 0; + char *ret = NULL; + lua_State *L = Luas; + if (lang->exceptions == 0) + return NULL; + lua_checkstack(L, 2); + lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions); + if (lua_istable(L, -1)) { + /* iterate and join */ + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + value = lua_tolstring(L, -1, &l); + if (current + 2 + l > size) { + ret = + xrealloc(ret, + (unsigned) ((size + size / 5) + current + l + + 1024)); + size = (size + size / 5) + current + l + 1024; + } + *(ret + current) = ' '; + strcpy(ret + current + 1, value); + current += l + 1; + lua_pop(L, 1); + } + } + return ret; +} + + +@ the sequence from |wordstart| to |r| can contain only normal characters +it could be faster to modify a halfword pointer and return an integer + +@c +halfword find_exception_part(unsigned int *j, unsigned int *uword, int len) +{ + halfword g = null, gg = null; + register unsigned i = *j; + i++; /* this puts uword[i] on the |{| */ + while (i < (unsigned) len && uword[i + 1] != '}') { + if (g == null) { + gg = new_char(0, (int) uword[i + 1]); + g = gg; + } else { + halfword s = new_char(0, (int) uword[i + 1]); + couple_nodes(g, s); + g = vlink(g); + } + i++; + } + *j = ++i; + return gg; +} + +int count_exception_part(unsigned int *j, unsigned int *uword, int len) +{ + int ret = 0; + register unsigned i = *j; + i++; /* this puts uword[i] on the |{| */ + while (i < (unsigned) len && uword[i + 1] != '}') { + ret++; + i++; + } + *j = ++i; + return ret; +} + + +@ @c +static const char *PAT_ERROR[] = { + "Exception discretionaries should contain three pairs of braced items.", + "No intervening spaces are allowed.", + NULL +}; + +void do_exception(halfword wordstart, halfword r, char *replacement) +{ + unsigned i; + halfword t; + unsigned len; + int clang; + lang_variables langdata; + unsigned uword[MAX_WORD_LEN + 1] = { 0 }; + utf82u_strcpy(uword, replacement); + len = u_length(uword); + i = 0; + t = wordstart; + clang = char_lang(wordstart); + langdata.pre_hyphen_char = get_pre_hyphen_char(clang); + langdata.post_hyphen_char = get_post_hyphen_char(clang); + + for (i = 0; i < len; i++) { + if (uword[i + 1] == '-') { /* a hyphen follows */ + while (vlink(t) != r + && (type(t) != glyph_node || !is_simple_character(t))) + t = vlink(t); + if (vlink(t) == r) + break; + insert_syllable_discretionary(t, &langdata); + t = vlink(t); /* skip the new disc */ + } else if (uword[i + 1] == '=') { + /* do nothing ? */ + t = vlink(t); + } else if (uword[i + 1] == '{') { + halfword gg, hh, replace = null; + int repl; + gg = find_exception_part(&i, uword, (int) len); + if (i == len || uword[i + 1] != '{') { + tex_error("broken pattern 1", PAT_ERROR); + } + hh = find_exception_part(&i, uword, (int) len); + if (i == len || uword[i + 1] != '{') { + tex_error("broken pattern 2", PAT_ERROR); + } + repl = count_exception_part(&i, uword, (int) len); + if (i == len) { + tex_error("broken pattern 3", PAT_ERROR); + } + /*i++; *//* jump over the last right brace */ + if (vlink(t) == r) + break; + if (repl > 0) { + halfword q = t; + replace = vlink(q); + while (repl > 0 && q != null) { + q = vlink(q); + if (type(q) == glyph_node) { + repl--; + } + } + try_couple_nodes(t, vlink(q)); + vlink(q) = null; + } + t = insert_discretionary(t, gg, hh, replace); + t = vlink(t); /* skip the new disc */ + } else { + t = vlink(t); + } + } +} + +@ This is a documentation section from the pascal web file. It is not +true any more, but I do not have time right now to rewrite it -- Taco + +When the line-breaking routine is unable to find a feasible sequence of +breakpoints, it makes a second pass over the paragraph, attempting to +hyphenate the hyphenatable words. The goal of hyphenation is to insert +discretionary material into the paragraph so that there are more +potential places to break. + +The general rules for hyphenation are somewhat complex and technical, +because we want to be able to hyphenate words that are preceded or +followed by punctuation marks, and because we want the rules to work +for languages other than English. We also must contend with the fact +that hyphens might radically alter the ligature and kerning structure +of a word. + +A sequence of characters will be considered for hyphenation only if it +belongs to a ``potentially hyphenatable part'' of the current paragraph. +This is a sequence of nodes $p_0p_1\ldots p_m$ where $p_0$ is a glue node, +$p_1\ldots p_{m-1}$ are either character or ligature or whatsit or +implicit kern nodes, and $p_m$ is a glue or penalty or insertion or adjust +or mark or whatsit or explicit kern node. (Therefore hyphenation is +disabled by boxes, math formulas, and discretionary nodes already inserted +by the user.) The ligature nodes among $p_1\ldots p_{m-1}$ are effectively +expanded into the original non-ligature characters; the kern nodes and +whatsits are ignored. Each character |c| is now classified as either a +nonletter (if |lc_code(c)=0|), a lowercase letter (if +|lc_code(c)=c|), or an uppercase letter (otherwise); an uppercase letter +is treated as if it were |lc_code(c)| for purposes of hyphenation. The +characters generated by $p_1\ldots p_{m-1}$ may begin with nonletters; let +$c_1$ be the first letter that is not in the middle of a ligature. Whatsit +nodes preceding $c_1$ are ignored; a whatsit found after $c_1$ will be the +terminating node $p_m$. All characters that do not have the same font as +$c_1$ will be treated as nonletters. The |hyphen_char| for that font +must be between 0 and 255, otherwise hyphenation will not be attempted. +\TeX\ looks ahead for as many consecutive letters $c_1\ldots c_n$ as +possible; however, |n| must be less than 64, so a character that would +otherwise be $c_{64}$ is effectively not a letter. Furthermore $c_n$ must +not be in the middle of a ligature. In this way we obtain a string of +letters $c_1\ldots c_n$ that are generated by nodes $p_a\ldots p_b$, where +|1<=a<=b+1<=m|. If |n>=l_hyf+r_hyf|, this string qualifies for hyphenation; +however, |uc_hyph| must be positive, if $c_1$ is uppercase. + +The hyphenation process takes place in three stages. First, the candidate +sequence $c_1\ldots c_n$ is found; then potential positions for hyphens +are determined by referring to hyphenation tables; and finally, the nodes +$p_a\ldots p_b$ are replaced by a new sequence of nodes that includes the +discretionary breaks found. + +Fortunately, we do not have to do all this calculation very often, because +of the way it has been taken out of \TeX's inner loop. For example, when +the second edition of the author's 700-page book {\sl Seminumerical +Algorithms} was typeset by \TeX, only about 1.2 hyphenations needed to be +@^Knuth, Donald Ervin@> +tried per paragraph, since the line breaking algorithm needed to use two +passes on only about 5 per cent of the paragraphs. + + +When a word been set up to contain a candidate for hyphenation, +\TeX\ first looks to see if it is in the user's exception dictionary. If not, +hyphens are inserted based on patterns that appear within the given word, +using an algorithm due to Frank~M. Liang. +@^Liang, Franklin Mark@> + + +@ This is incompatible with TEX because the first word of a paragraph +can be hyphenated, but most european users seem to agree that +prohibiting hyphenation there was not the best idea ever. + +@c +halfword find_next_wordstart(halfword r) +{ + register int l; + register int start_ok = 1; + int mathlevel = 1; + while (r != null) { + switch (type(r)) { + case glue_node: + start_ok = 1; + break; + case math_node: + while (mathlevel > 0) { + r = vlink(r); + if (r == null) + return r; + if (type(r) == math_node) { + if (subtype(r) == before) { + mathlevel++; + } else { + mathlevel--; + } + } + } + break; + case glyph_node: + if (start_ok && + is_simple_character(r) && + (l = get_lc_code(character(r))) > 0 && + (char_uchyph(r) || l == character(r))) + return r; + break; + default: + start_ok = 0; + break; + } + r = vlink(r); + } + return r; +} + +@ @c +int valid_wordend(halfword s) +{ + register halfword r = s; + register int clang = char_lang(s); + if (r == null) + return 1; + while ((r != null) && ((type(r) == glyph_node && is_simple_character(r) + && clang == char_lang(r)) || + (type(r) == kern_node && (subtype(r) == normal)) + )) { + r = vlink(r); + } + if (r == null || (type(r) == glyph_node && is_simple_character(r) + && clang != char_lang(r)) || type(r) == glue_node + || type(r) == whatsit_node || type(r) == ins_node + || type(r) == adjust_node || type(r) == penalty_node + || (type(r) == kern_node + && (subtype(r) == explicit || subtype(r) == acc_kern))) + return 1; + return 0; +} + +@ @c +void hnj_hyphenation(halfword head, halfword tail) +{ + int lchar, i; + struct tex_language *lang; + lang_variables langdata; + char utf8word[(4 * MAX_WORD_LEN) + 1] = { 0 }; + int wordlen = 0; + char *hy = utf8word; + char *replacement = NULL; + halfword s, r = head, wordstart = null, save_tail = null, left = + null, right = null; + + /* this first movement assures two things: + \item{a)} that we won't waste lots of time on something that has been + handled already (in that case, none of the glyphs match |simple_character|). + \item{b)} that the first word can be hyphenated. if the movement was + not explicit, then the indentation at the start of a paragraph + list would make |find_next_wordstart()| look too far ahead. + */ + + while (r != null && (type(r) != glyph_node || !is_simple_character(r))) { + r = vlink(r); + } + /* this will make |r| a glyph node with subtype character */ + r = find_next_wordstart(r); + if (r == null) + return; + + assert(tail != null); + save_tail = vlink(tail); + s = new_penalty(0); + couple_nodes(tail, s); + + while (r != null) { /* could be while(1), but let's be paranoid */ + int clang, lhmin, rhmin; + halfword hyf_font; + halfword end_word = r; + wordstart = r; + assert(is_simple_character(wordstart)); + hyf_font = font(wordstart); + if (hyphen_char(hyf_font) < 0) /* for backward compat */ + hyf_font = 0; + clang = char_lang(wordstart); + lhmin = char_lhmin(wordstart); + rhmin = char_rhmin(wordstart); + langdata.pre_hyphen_char = get_pre_hyphen_char(clang); + langdata.post_hyphen_char = get_post_hyphen_char(clang); + while (r != null && + type(r) == glyph_node && + is_simple_character(r) && + clang == char_lang(r) && + (lchar = get_lc_code(character(r))) > 0) { + wordlen++; + hy = uni2string(hy, (unsigned) lchar); + /* this should not be needed any more */ + /*if (vlink(r)!=null) alink(vlink(r))=r; */ + end_word = r; + r = vlink(r); + } + if (valid_wordend(r) && wordlen >= lhmin + rhmin + && (hyf_font != 0) && (lang = tex_languages[clang]) != NULL) { + *hy = 0; + if (lang->exceptions != 0 && + (replacement = + hyphenation_exception(lang->exceptions, utf8word)) != NULL) { +#ifdef VERBOSE + fprintf(stderr, "replacing %s (c=%d) by %s\n", utf8word, clang, + replacement); +#endif + do_exception(wordstart, r, replacement); + free(replacement); + } else if (lang->patterns != NULL) { + + left = wordstart; + for (i = lhmin; i > 1; i--) { + left = vlink(left); + while (!is_simple_character(left)) + left = vlink(left); + } + right = r; + for (i = rhmin; i > 0; i--) { + right = alink(right); + while (!is_simple_character(right)) + right = alink(right); + } + +#ifdef VERBOSE + fprintf(stderr, "hyphenate %s (c=%d,l=%d,r=%d) from %c to %c\n", + utf8word, clang, lhmin, rhmin, character(left), + character(right)); +#endif + (void) hnj_hyphen_hyphenate(lang->patterns, wordstart, end_word, + wordlen, left, right, &langdata); + } + } + wordlen = 0; + hy = utf8word; + if (r == null) + break; + r = find_next_wordstart(r); + } + flush_node(vlink(tail)); + vlink(tail) = save_tail; +} + + +@ @c +void new_hyphenation(halfword head, halfword tail) +{ + register int callback_id = 0; + if (head == null || vlink(head) == null) + return; + fix_node_list(head); + callback_id = callback_defined(hyphenate_callback); + if (callback_id > 0) { + lua_State *L = Luas; + if (!get_callback(L, callback_id)) { + lua_pop(L, 2); + return; + } + nodelist_to_lua(L, head); + nodelist_to_lua(L, tail); + if (lua_pcall(L, 2, 0, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 2); + lua_error(L); + return; + } + lua_pop(L, 1); + } else if (callback_id == 0) { + hnj_hyphenation(head, tail); + } +} + +@ dumping and undumping languages + +@c +#define dump_string(a) \ + if (a!=NULL) { \ + x = (int)strlen(a)+1; \ + dump_int(x); dump_things(*a, x); \ + } else { \ + x = 0; dump_int(x); \ + } + + +void dump_one_language(int i) +{ + char *s = NULL; + int x = 0; + struct tex_language *lang; + lang = tex_languages[i]; + dump_int(lang->id); + dump_int(lang->pre_hyphen_char); + dump_int(lang->post_hyphen_char); + dump_int(lang->pre_exhyphen_char); + dump_int(lang->post_exhyphen_char); + if (lang->patterns != NULL) { + s = (char *) hnj_serialize(lang->patterns); + } + dump_string(s); + if (s != NULL) { + free(s); + s = NULL; + } + if (lang->exceptions != 0) + s = exception_strings(lang); + dump_string(s); + if (s != NULL) { + free(s); + } + free(lang); +} + +void dump_language_data(void) +{ + int i; + dump_int(next_lang_id); + for (i = 0; i < next_lang_id; i++) { + if (tex_languages[i]) { + dump_int(1); + dump_one_language(i); + } else { + dump_int(0); + } + } +} + + +void undump_one_language(int i) +{ + char *s = NULL; + int x = 0; + struct tex_language *lang = get_language(i); + undump_int(x); + lang->id = x; + undump_int(x); + lang->pre_hyphen_char = x; + undump_int(x); + lang->post_hyphen_char = x; + undump_int(x); + lang->pre_exhyphen_char = x; + undump_int(x); + lang->post_exhyphen_char = x; + /* patterns */ + undump_int(x); + if (x > 0) { + s = xmalloc((unsigned) x); + undump_things(*s, x); + load_patterns(lang, (unsigned char *) s); + free(s); + } + /* exceptions */ + undump_int(x); + if (x > 0) { + s = xmalloc((unsigned) x); + undump_things(*s, x); + load_hyphenation(lang, (unsigned char *) s); + free(s); + } +} + +void undump_language_data(void) +{ + int i, x, numlangs; + undump_int(numlangs); + next_lang_id = numlangs; + for (i = 0; i < numlangs; i++) { + undump_int(x); + if (x == 1) { + undump_one_language(i); + } + } +} + + +@ When \TeX\ has scanned `\.{\\hyphenation}', it calls on a procedure named +|new_hyph_exceptions| to do the right thing. + +@c +void new_hyph_exceptions(void) +{ /* enters new exceptions */ + (void) scan_toks(false, true); + load_tex_hyphenation(int_par(language_code), def_ref); + flush_list(def_ref); +} + +@ Similarly, when \TeX\ has scanned `\.{\\patterns}', it calls on a +procedure named |new_patterns|. + +@c +void new_patterns(void) +{ /* initializes the hyphenation pattern data */ + (void) scan_toks(false, true); + load_tex_patterns(int_par(language_code), def_ref); + flush_list(def_ref); +} + +@ `\.{\\prehyphenchar}', sets the |pre_break| character, and +`\.{\\posthyphenchar}' the |post_break| character. Their respective +defaults are ascii hyphen ("-") and zero (nul). + +@c +void new_pre_hyphen_char(void) +{ + scan_optional_equals(); + scan_int(); + set_pre_hyphen_char(int_par(language_code), cur_val); +} + +void new_post_hyphen_char(void) +{ + scan_optional_equals(); + scan_int(); + set_post_hyphen_char(int_par(language_code), cur_val); +} + + +@ `\.{\\preexhyphenchar}', sets the |pre_break| character, and +`\.{\\postexhyphenchar}' the |post_break| character. Their +defaults are both zero (nul). + +@c +void new_pre_exhyphen_char(void) +{ + scan_optional_equals(); + scan_int(); + set_pre_exhyphen_char(int_par(language_code), cur_val); +} + +void new_post_exhyphen_char(void) +{ + scan_optional_equals(); + scan_int(); + set_post_exhyphen_char(int_par(language_code), cur_val); +} diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c index adbbd43becb..c29f2de0e96 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -17,13 +17,11 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include +#include "lua/luatex-api.h" +#include "ptexlib.h" static const char _svn_version[] = - "$Id: lcallbacklib.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/lcallbacklib.c $"; - -static int do_run_callback(int special, const char *values, va_list vl); + "$Id: lcallbacklib.c 3404 2010-01-28 11:17:10Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/lcallbacklib.c $"; int callback_count = 0; int saved_callback_count = 0; @@ -49,7 +47,7 @@ static const char *const callbacknames[] = { "find_sfd_file", "read_sfd_file", "find_pk_file", "read_pk_file", "show_error_hook", - "process_input_buffer", + "process_input_buffer", "process_output_buffer", "start_page_number", "stop_page_number", "start_run", "stop_run", "define_font", @@ -79,9 +77,9 @@ void get_lua_boolean(const char *table, const char *name, boolean * target) if (lua_istable(Luas, -1)) { lua_getfield(Luas, -1, name); if (lua_isboolean(Luas, -1)) { - *target = (lua_toboolean(Luas, -1)); + *target = (boolean) (lua_toboolean(Luas, -1)); } else if (lua_isnumber(Luas, -1)) { - *target = (lua_tonumber(Luas, -1) == 0 ? 0 : 1); + *target = (boolean) (lua_tonumber(Luas, -1) == 0 ? 0 : 1); } } lua_settop(Luas, stacktop); @@ -97,16 +95,16 @@ void get_saved_lua_boolean(int r, const char *name, boolean * target) if (lua_istable(Luas, -1)) { lua_getfield(Luas, -1, name); if (lua_isboolean(Luas, -1)) { - *target = lua_toboolean(Luas, -1); + *target = (boolean) lua_toboolean(Luas, -1); } else if (lua_isnumber(Luas, -1)) { - *target = (lua_tonumber(Luas, -1) == 0 ? 0 : 1); + *target = (boolean) (lua_tonumber(Luas, -1) == 0 ? 0 : 1); } } lua_settop(Luas, stacktop); return; } -void get_lua_number(const char *table, const char *name, integer * target) +void get_lua_number(const char *table, const char *name, int *target) { int stacktop; stacktop = lua_gettop(Luas); @@ -115,14 +113,14 @@ void get_lua_number(const char *table, const char *name, integer * target) if (lua_istable(Luas, -1)) { lua_getfield(Luas, -1, name); if (lua_isnumber(Luas, -1)) { - *target = lua_tonumber(Luas, -1); + lua_number2int(*target, lua_tonumber(Luas, -1)); } } lua_settop(Luas, stacktop); return; } -void get_saved_lua_number(int r, const char *name, integer * target) +void get_saved_lua_number(int r, const char *name, int *target) { int stacktop; stacktop = lua_gettop(Luas); @@ -131,7 +129,7 @@ void get_saved_lua_number(int r, const char *name, integer * target) if (lua_istable(Luas, -1)) { lua_getfield(Luas, -1, name); if (lua_isnumber(Luas, -1)) { - *target = lua_tonumber(Luas, -1); + lua_number2int(*target, lua_tonumber(Luas, -1)); } } lua_settop(Luas, stacktop); @@ -139,7 +137,7 @@ void get_saved_lua_number(int r, const char *name, integer * target) } -void get_lua_string(const char *table, const char *name, const char **target) +void get_lua_string(const char *table, const char *name, char **target) { int stacktop; stacktop = lua_gettop(Luas); @@ -148,14 +146,14 @@ void get_lua_string(const char *table, const char *name, const char **target) if (lua_istable(Luas, -1)) { lua_getfield(Luas, -1, name); if (lua_isstring(Luas, -1)) { - *target = lua_tostring(Luas, -1); + *target = xstrdup(lua_tostring(Luas, -1)); } } lua_settop(Luas, stacktop); return; } -void get_saved_lua_string(int r, const char *name, const char **target) +void get_saved_lua_string(int r, const char *name, char **target) { int stacktop; stacktop = lua_gettop(Luas); @@ -164,7 +162,7 @@ void get_saved_lua_string(int r, const char *name, const char **target) if (lua_istable(Luas, -1)) { lua_getfield(Luas, -1, name); if (lua_isstring(Luas, -1)) { - *target = lua_tostring(Luas, -1); + *target = xstrdup(lua_tostring(Luas, -1)); } } lua_settop(Luas, stacktop); @@ -266,7 +264,7 @@ int do_run_callback(int special, const char *values, va_list vl) } ss = index(values, '>'); assert(ss); - luaL_checkstack(L, (ss - values + 1), "out of stack space"); + luaL_checkstack(L, (int) (ss - values + 1), "out of stack space"); ss = NULL; for (narg = 0; *values; narg++) { switch (*values++) { @@ -289,7 +287,8 @@ int do_run_callback(int special, const char *values, va_list vl) lua_pushboolean(L, va_arg(vl, int)); break; case CALLBACK_LINE: /* a buffer section, with implied start */ - lua_pushlstring(L, (char *) (buffer + first), va_arg(vl, int)); + lua_pushlstring(L, (char *) (buffer + first), + (size_t) va_arg(vl, int)); break; case '-': narg--; @@ -301,7 +300,7 @@ int do_run_callback(int special, const char *values, va_list vl) } } ENDARGS: - nres = strlen(values); + nres = (int) strlen(values); if (special == 1) { nres++; } @@ -350,7 +349,7 @@ int do_run_callback(int special, const char *values, va_list vl) lua_typename(L, lua_type(L, nres))); goto EXIT; } - b = lua_tonumber(L, nres); + lua_number2int(b, lua_tonumber(L, nres)); *va_arg(vl, int *) = b; break; case CALLBACK_LINE: /* TeX line */ @@ -365,9 +364,9 @@ int do_run_callback(int special, const char *values, va_list vl) bufloc = va_arg(vl, int *); if (len != 0) { ret = *bufloc; - check_buffer_overflow(ret + len); + check_buffer_overflow(ret + (int) len); strncpy((char *) (buffer + ret), s, len); - *bufloc += len; + *bufloc += (int) len; /* while (len--) { buffer[(*bufloc)++] = *s++; } */ while ((*bufloc) - 1 > ret && buffer[(*bufloc) - 1] == ' ') (*bufloc)--; @@ -404,7 +403,7 @@ int do_run_callback(int special, const char *values, va_list vl) if (s == NULL) /* |len| can be zero */ *va_arg(vl, int *) = 0; else { - ss = xmalloc(len + 1); + ss = xmalloc((unsigned) (len + 1)); (void) memcpy(ss, s, (len + 1)); *va_arg(vl, char **) = ss; } diff --git a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc new file mode 100644 index 00000000000..551cc2d1ee3 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc @@ -0,0 +1,58 @@ +/* lepdflib.cc + + Copyright 2009-2010 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ + +static const char _svn_version[] = + "$Id: lepdflib.cc 3366 2010-01-20 14:49:31Z taco $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/lepdflib.cc $"; + +#include "image/epdf.h" + +//********************************************************************** + +int l_new_pdfdoc(lua_State * L) +{ + PdfDocument *pdf_doc; + char *file_path; + if (lua_gettop(L) != 1) + luaL_error(L, "epdf.new() needs exactly 1 argument"); + if (!lua_isstring(L, -1)) + luaL_error(L, "epdf.new() needs filename (string)"); + file_path = (char *) lua_tostring(L, -1); + + printf("\n======================== 1 <%s>\n", file_path); + + pdf_doc = refPdfDocument(file_path); + + return 0; +} + +//********************************************************************** + +static const struct luaL_Reg epdflib[] = { + // {"new", l_new_pdfdoc}, + {NULL, NULL} /* sentinel */ +}; + +int luaopen_epdf(lua_State * L) +{ + luaL_register(L, "epdf", epdflib); + return 1; +} + +//********************************************************************** diff --git a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c index c07da9d0717..32b9e776fc1 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c @@ -1,6 +1,6 @@ /* lfontlib.c - Copyright 2006-2008 Taco Hoekwater + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,12 +17,12 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include -#include "nodes.h" +#include "lua/luatex-api.h" +#include "ptexlib.h" + static const char _svn_version[] = - "$Id: lfontlib.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/lfontlib.c $"; + "$Id: lfontlib.c 3551 2010-03-26 14:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/lfontlib.c $"; #define TIMERS 0 @@ -30,7 +30,6 @@ static const char _svn_version[] = # include #endif -#include "inc-vfovf.h" static int get_fontid(void) { @@ -42,14 +41,14 @@ static int get_fontid(void) static int font_read_tfm(lua_State * L) { - internalfontnumber f; + internal_font_number f; scaled s; int k; const char *cnom; if (lua_isstring(L, 1)) { cnom = lua_tostring(L, 1); if (lua_isnumber(L, 2)) { - s = (integer) lua_tonumber(L, 2); + lua_number2int(s, lua_tonumber(L, 2)); if (strlen(cnom)) { f = get_fontid(); if (read_tfm_info(f, cnom, s)) { @@ -58,20 +57,16 @@ static int font_read_tfm(lua_State * L) return k; } else { delete_font(f); - lua_pushstring(L, "font loading failed"); - lua_error(L); + luaL_error(L, "font loading failed"); } } else { - lua_pushstring(L, "expected tfm name as first argument"); - lua_error(L); + luaL_error(L, "expected tfm name as first argument"); } } else { - lua_pushstring(L, "expected an integer size as second argument"); - lua_error(L); + luaL_error(L, "expected an integer size as second argument"); } } else { - lua_pushstring(L, "expected tfm name as first argument"); - lua_error(L); + luaL_error(L, "expected tfm name as first argument"); } return 2; /* not reached */ } @@ -79,24 +74,22 @@ static int font_read_tfm(lua_State * L) static int font_read_vf(lua_State * L) { - scaled s; + int i; const char *cnom; if (lua_isstring(L, 1)) { cnom = lua_tostring(L, 1); if (strlen(cnom)) { if (lua_isnumber(L, 2)) { - s = lua_tonumber(L, 2); - return make_vf_table(L, cnom, s); + lua_number2int(i, lua_tonumber(L, 2)); + return make_vf_table(L, cnom, (scaled) i); } else { - lua_pushstring(L, + luaL_error(L, "expected an integer size as second argument"); - lua_error(L); return 2; } } } - lua_pushstring(L, "expected vf name as first argument"); - lua_error(L); + luaL_error(L, "expected vf name as first argument"); return 2; /* not reached */ } @@ -109,8 +102,7 @@ static int tex_current_font(lua_State * L) zset_cur_font(i); return 0; } else { - lua_pushstring(L, "expected a valid font id"); - lua_error(L); + luaL_error(L, "expected a valid font id"); return 2; /* not reached */ } } else { @@ -129,8 +121,8 @@ static int tex_max_font(lua_State * L) static int tex_each_font_next(lua_State * L) { int i, m; /* id */ - m = lua_tonumber(L, 1); - i = lua_tonumber(L, 2); + lua_number2int(m, lua_tonumber(L, 1)); + lua_number2int(i, lua_tonumber(L, 2)); i++; while (i <= m && !is_valid_font(i)) i++; @@ -139,7 +131,8 @@ static int tex_each_font_next(lua_State * L) return 1; } else { lua_pushnumber(L, i); - font_to_lua(L, i); + if (!font_to_lua(L, i)) + lua_pushnil(L); return 2; } } @@ -168,8 +161,7 @@ static int frozenfont(lua_State * L) } return 1; } else { - lua_pushstring(L, "expected an integer argument"); - lua_error(L); + luaL_error(L, "expected an integer argument"); } return 0; /* not reached */ } @@ -185,13 +177,11 @@ static int setfont(lua_State * L) if (!(font_touched(i) || font_used(i))) { font_from_lua(L, i); } else { - lua_pushstring(L, + luaL_error(L, "that font has been accessed already, changing it is forbidden"); - lua_error(L); } } else { - lua_pushstring(L, "that integer id is not a valid font"); - lua_error(L); + luaL_error(L, "that integer id is not a valid font"); } } return 0; @@ -227,8 +217,7 @@ static int deffont(lua_State * L) } else { lua_pop(L, 1); /* pop the broken table */ delete_font(i); - lua_pushstring(L, "font creation failed"); - lua_error(L); + luaL_error(L, "font creation failed"); } return 0; /* not reached */ } @@ -254,6 +243,30 @@ static int getfont(lua_State * L) } +static int getfontid(lua_State * L) +{ + const char *s; + size_t ff; + int cur_cs; + int f; + if (lua_type(L, 1) == LUA_TSTRING) { + s = lua_tolstring(L, 1, &ff); + cur_cs = string_lookup(s, ff); + if (cur_cs == undefined_control_sequence || cur_cs == undefined_cs_cmd + || eq_type(cur_cs) != set_font_cmd) { + lua_pushstring(L, "not a valid font csname"); + f = -1; + } else { + f = equiv(cur_cs); + } + lua_pushnumber(L, f); + } else { + luaL_error(L, "expected font csname string as argument"); + } + return 1; +} + + static const struct luaL_reg fontlib[] = { {"read_tfm", font_read_tfm}, {"read_vf", font_read_vf}, @@ -264,6 +277,7 @@ static const struct luaL_reg fontlib[] = { {"setfont", setfont}, {"define", deffont}, {"nextid", nextfontid}, + {"id", getfontid}, {"frozen", frozenfont}, {NULL, NULL} /* sentinel */ }; diff --git a/Build/source/texk/web2c/luatexdir/lua/limglib.c b/Build/source/texk/web2c/luatexdir/lua/limglib.c index 7663d022c03..0c2d7e4d65e 100644 --- a/Build/source/texk/web2c/luatexdir/lua/limglib.c +++ b/Build/source/texk/web2c/luatexdir/lua/limglib.c @@ -1,6 +1,6 @@ /* limglib.c - Copyright 2006-2008 Taco Hoekwater + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,18 +17,17 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ +static const char _svn_version[] = + "$Id: limglib.c 3404 2010-01-28 11:17:10Z taco $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/limglib.c $"; + #include #include #include -#include <../lua51/lua.h> -#include <../lua51/lauxlib.h> -#include -#include "luatex-api.h" -#include "inc-extra.h" - -static const char _svn_version[] = - "$Id: limglib.c 2329 2009-04-18 14:25:30Z hhenkel $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/limglib.c $"; +#include "lua51/lua.h" +#include "lua51/lauxlib.h" +#include "ptexlib.h" +#include "lua/luatex-api.h" /**********************************************************************/ @@ -48,7 +47,7 @@ void stackDump(lua_State * L, char *s) printf(lua_toboolean(L, i) ? "true" : "false"); break; case LUA_TNUMBER: /* numbers */ - printf("%g", lua_tonumber(L, i)); + printf("%g", (double) lua_tonumber(L, i)); break; default: /* other values */ printf("%s", lua_typename(L, t)); @@ -68,12 +67,7 @@ typedef enum { P__ZERO, P_ATTR, P_BBOX, P_COLORDEPTH, P_COLORSPACE, P_DEPTH, P_WIDTH, P_XRES, P_XSIZE, P_YRES, P_YSIZE, P__SENTINEL } parm_idx; -typedef struct { - const char *name; /* parameter name */ - parm_idx idx; /* index within img_parms array */ -} parm_struct; - -const parm_struct img_parms[] = { +static const parm_struct img_parms[] = { {NULL, P__ZERO}, /* dummy; lua indices run from 1 */ {"attr", P_ATTR}, {"bbox", P_BBOX}, @@ -120,7 +114,7 @@ static void image_to_lua(lua_State * L, image * a) if (!lua_isnumber(L, -1)) /* !i k u ... */ luaL_error(L, "image_to_lua(): %s is not a valid image key", lua_tostring(L, -2)); - i = lua_tointeger(L, -1); /* i k u ... */ + i = (int) lua_tointeger(L, -1); /* i k u ... */ lua_pop(L, 2); /* u ... */ switch (i) { case P_WIDTH: @@ -281,59 +275,47 @@ static void lua_to_image(lua_State * L, image * a) if (!lua_isnumber(L, -1)) /* !i v k t ... */ luaL_error(L, "lua_to_image(): %s is not a valid image key", lua_tostring(L, -3)); - i = lua_tointeger(L, -1); /* i v k t ... */ + i = (int) lua_tointeger(L, -1); /* i v k t ... */ lua_pop(L, 1); /* v k t ... */ switch (i) { case P_WIDTH: - if (img_is_refered(a)) - luaL_error(L, "image.width is now read-only"); if (lua_isnil(L, -1)) set_wd_running(a); else if (lua_type(L, -1) == LUA_TNUMBER) - img_width(a) = lua_tointeger(L, -1); + img_width(a) = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) img_width(a) = dimen_to_number(L, lua_tostring(L, -1)); else luaL_error(L, "image.width needs integer or nil value or dimension string"); - img_unset_scaled(a); break; case P_HEIGHT: - if (img_is_refered(a)) - luaL_error(L, "image.height is now read-only"); if (lua_isnil(L, -1)) set_ht_running(a); else if (lua_type(L, -1) == LUA_TNUMBER) - img_height(a) = lua_tointeger(L, -1); + img_height(a) = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) img_height(a) = dimen_to_number(L, lua_tostring(L, -1)); else luaL_error(L, "image.height needs integer or nil value or dimension string"); - img_unset_scaled(a); break; case P_DEPTH: - if (img_is_refered(a)) - luaL_error(L, "image.depth is now read-only"); if (lua_isnil(L, -1)) set_dp_running(a); else if (lua_type(L, -1) == LUA_TNUMBER) - img_depth(a) = lua_tointeger(L, -1); + img_depth(a) = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) img_depth(a) = dimen_to_number(L, lua_tostring(L, -1)); else luaL_error(L, "image.depth needs integer or nil value or dimension string"); - img_unset_scaled(a); break; case P_TRANSFORM: - if (img_is_refered(a)) - luaL_error(L, "image.transform is now read-only"); if (lua_isnumber(L, -1)) - img_transform(a) = lua_tointeger(L, -1); + img_transform(a) = (int) lua_tointeger(L, -1); else luaL_error(L, "image.transform needs integer value"); - img_unset_scaled(a); break; /* now follow all image_dict entries */ case P_FILENAME: @@ -342,8 +324,7 @@ static void lua_to_image(lua_State * L, image * a) if (img_type(d) == IMG_TYPE_PDFSTREAM) luaL_error(L, "image.filename can't be used with image.stream"); if (lua_isstring(L, -1)) { - if (img_filename(d) != NULL) - xfree(img_filename(d)); + xfree(img_filename(d)); img_filename(d) = xstrdup(lua_tostring(L, -1)); } else luaL_error(L, "image.filename needs string value"); @@ -352,8 +333,7 @@ static void lua_to_image(lua_State * L, image * a) if (img_state(d) >= DICT_FILESCANNED) luaL_error(L, "image.attr is now read-only"); if (lua_isstring(L, -1) || lua_isnil(L, -1)) { - if (img_attr(d) != NULL) - xfree(img_attr(d)); + xfree(img_attr(d)); if (lua_isstring(L, -1)) img_attr(d) = xstrdup(lua_tostring(L, -1)); } else @@ -363,15 +343,12 @@ static void lua_to_image(lua_State * L, image * a) if (img_state(d) >= DICT_FILESCANNED) luaL_error(L, "image.page is now read-only"); if (lua_type(L, -1) == LUA_TSTRING) { - if (img_pagename(d) != NULL) - xfree(img_pagename(d)); + xfree(img_pagename(d)); img_pagename(d) = xstrdup(lua_tostring(L, -1)); img_pagenum(d) = 0; } else if (lua_type(L, -1) == LUA_TNUMBER) { - img_pagenum(d) = lua_tointeger(L, -1); - if (img_pagename(d) != NULL) - xfree(img_pagename(d)); - img_pagename(d) = NULL; + img_pagenum(d) = (int) lua_tointeger(L, -1); + xfree(img_pagename(d)); } else luaL_error(L, "image.page needs integer or string value"); break; @@ -381,7 +358,7 @@ static void lua_to_image(lua_State * L, image * a) if (lua_isnil(L, -1)) img_colorspace(d) = 0; else if (lua_isnumber(L, -1)) - img_colorspace(d) = lua_tointeger(L, -1); + img_colorspace(d) = (int) lua_tointeger(L, -1); else luaL_error(L, "image.colorspace needs integer or nil value"); break; @@ -406,17 +383,15 @@ static void lua_to_image(lua_State * L, image * a) lua_pushinteger(L, i); /* idx v k t ... */ lua_gettable(L, -2); /* int v k t ... */ if (lua_type(L, -1) == LUA_TNUMBER) - img_bbox(d)[i - 1] = lua_tointeger(L, -1); + img_bbox(d)[i - 1] = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) - img_bbox(d)[i - 1] = - dimen_to_number(L, lua_tostring(L, -1)); + img_bbox(d)[i - 1] = dimen_to_number(L, lua_tostring(L, -1)); else luaL_error(L, "image.bbox table needs integer value or dimension string elements"); lua_pop(L, 1); /* v k t ... */ } img_set_bbox(d); - img_unset_scaled(a); break; case P_STREAM: if (img_filename(d) != NULL) @@ -425,11 +400,9 @@ static void lua_to_image(lua_State * L, image * a) luaL_error(L, "image.stream is now read-only"); if (img_pdfstream_ptr(d) == NULL) new_img_pdfstream_struct(d); - if (img_pdfstream_stream(d) != NULL) - xfree(img_pdfstream_stream(d)); + xfree(img_pdfstream_stream(d)); img_pdfstream_stream(d) = xstrdup(lua_tostring(L, -1)); img_type(d) = IMG_TYPE_PDFSTREAM; - img_unset_scaled(a); break; case P_FILEPATH: case P_TOTALPAGES: @@ -451,17 +424,7 @@ static void lua_to_image(lua_State * L, image * a) /**********************************************************************/ -static void fix_image_size(lua_State * L, image * a) -{ - if (!img_is_scaled(a) || is_wd_running(a) || is_ht_running(a) - || is_dp_running(a)) { - if (img_is_refered(a)) - luaL_error(L, "image is read-only"); - scale_img(a); - } -} - -static void copy_image(lua_State * L, lua_Number scale) +void copy_image(lua_State * L, lua_Number scale) { image *a, **aa, *b, **bb; if (lua_gettop(L) != 1) @@ -474,11 +437,11 @@ static void copy_image(lua_State * L, lua_Number scale) lua_setmetatable(L, -2); /* b */ b = *bb = new_image(); if (!is_wd_running(a)) - img_width(b) = zround(img_width(a) * scale); + img_width(b) = do_zround(img_width(a) * scale); if (!is_ht_running(a)) - img_height(b) = zround(img_height(a) * scale); + img_height(b) = do_zround(img_height(a) * scale); if (!is_dp_running(a)) - img_depth(b) = zround(img_depth(a) * scale); + img_depth(b) = do_zround(img_depth(a) * scale); img_transform(b) = img_transform(a); img_dict(b) = img_dict(a); if (img_dictref(a) != LUA_NOREF) { @@ -530,7 +493,7 @@ static int l_copy_image(lua_State * L) return 1; /* image */ } -static void read_scale_img(lua_State * L, image * a) +static void read_scale_img(image * a) { image_dict *ad; assert(a != NULL); @@ -540,18 +503,13 @@ static void read_scale_img(lua_State * L, image * a) if (img_type(ad) == IMG_TYPE_PDFSTREAM) check_pdfstream_dict(ad); else { - /* check_pdfminorversion() should not be here, as it belongs - * to the output functions, and it is too early here to start - * already the PDF file only for image file scanning; but - * it's needed as several fixed_* parameters are used early, - * e. g. by read_png_info(). */ - check_pdfminorversion(); - read_img(ad, get_pdf_minor_version(), - get_pdf_inclusion_errorlevel()); - img_unset_scaled(a); + fix_pdf_minorversion(static_pdf); + read_img(static_pdf, + ad, pdf_minor_version, pdf_inclusion_errorlevel); } } - fix_image_size(L, a); + if (is_wd_running(a) || is_ht_running(a) || is_dp_running(a)) + img_dimen(a) = scale_img(ad, img_dimen(a), img_transform(a)); } static int l_scan_image(lua_State * L) @@ -563,13 +521,13 @@ static int l_scan_image(lua_State * L) (void) l_new_image(L); /* image --- if everything worked well */ aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); /* image */ a = *aa; - check_pdfoutput(maketexstring("img.scan()"), true); - flush_str(last_tex_string); - read_scale_img(L, a); + check_o_mode(static_pdf, "img.scan()", 1 << OMODE_PDF, false); + /* flush_str(last_tex_string); *//* ?? */ + read_scale_img(a); return 1; /* image */ } -static halfword img_to_node(image * a, integer ref) +static halfword img_to_node(image * a) { image_dict *ad; halfword n; @@ -578,10 +536,11 @@ static halfword img_to_node(image * a, integer ref) assert(ad != NULL); assert(img_objnum(ad) != 0); n = new_node(whatsit_node, pdf_refximage_node); - pdf_ximage_ref(n) = ref; - pdf_width(n) = img_width(a); - pdf_height(n) = img_height(a); - pdf_depth(n) = img_depth(a); + pdf_ximage_index(n) = img_index(ad); + width(n) = img_width(a); + height(n) = img_height(a); + depth(n) = img_depth(a); + pdf_ximage_transform(n) = img_transform(a); return n; } @@ -589,22 +548,21 @@ typedef enum { WR_WRITE, WR_IMMEDIATEWRITE, WR_NODE, WR_VF_IMG } wrtype_e; const char *wrtype_s[] = { "img.write()", "img.immediatewrite()", "img.node()", "write vf image" }; -static void setup_image(lua_State * L, image * a, wrtype_e writetype) +static void setup_image(PDF pdf, image * a, wrtype_e writetype) { image_dict *ad; assert(a != NULL); ad = img_dict(a); - check_pdfoutput(maketexstring(wrtype_s[writetype]), true); - flush_str(last_tex_string); - read_scale_img(L, a); - if (img_arrayidx(a) == -1) - img_arrayidx(a) = img_to_array(a); /* now a is read-only */ + check_o_mode(pdf, wrtype_s[writetype], 1 << OMODE_PDF, false); + /* flush_str(last_tex_string); *//* ?? */ + read_scale_img(a); if (img_objnum(ad) == 0) { /* latest needed just before out_img() */ - pdf_ximage_count++; - pdf_create_obj(obj_type_ximage, pdf_ximage_count); - img_objnum(ad) = obj_ptr; - img_index(ad) = pdf_ximage_count; - obj_data_ptr(obj_ptr) = img_arrayidx(a); + pdf->ximage_count++; + pdf_create_obj(pdf, obj_type_ximage, pdf->ximage_count); + img_objnum(ad) = pdf->obj_ptr; + img_index(ad) = pdf->ximage_count; + idict_to_array(ad); /* now ad is read-only */ + obj_data_ptr(pdf, pdf->obj_ptr) = img_index(ad); } } @@ -620,20 +578,19 @@ static void write_image_or_node(lua_State * L, wrtype_e writetype) aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); /* image */ a = *aa; ad = img_dict(a); - setup_image(L, a, writetype); + setup_image(static_pdf, a, writetype); switch (writetype) { case WR_WRITE: - n = img_to_node(a, img_arrayidx(a)); - new_tail_append(n); + n = img_to_node(a); + tail_append(n); break; /* image */ case WR_IMMEDIATEWRITE: - check_pdfminorversion(); /* does initialization stuff */ - pdf_begin_dict(img_objnum(ad), 0); - write_img(ad); + pdf_begin_dict(static_pdf, img_objnum(ad), 0); + write_img(static_pdf, ad); break; /* image */ case WR_NODE: /* image */ lua_pop(L, 1); /* - */ - n = img_to_node(a, img_arrayidx(a)); + n = img_to_node(a); lua_nodelib_push_fast(L, n); break; /* node */ default: @@ -651,6 +608,7 @@ static int l_write_image(lua_State * L) static int l_immediatewrite_image(lua_State * L) { + check_o_mode(static_pdf, "img.immediatewrite()", 1 << OMODE_PDF, true); write_image_or_node(L, WR_IMMEDIATEWRITE); return 1; /* image */ } @@ -720,16 +678,18 @@ static const struct luaL_Reg imglib[] = { /**********************************************************************/ -void vf_out_image(unsigned i) +void vf_out_image(PDF pdf, unsigned i) { image *a, **aa; + image_dict *ad; lua_State *L = Luas; /* ... */ - lua_rawgeti(L, LUA_GLOBALSINDEX, i); /* image ... */ + lua_rawgeti(L, LUA_GLOBALSINDEX, (int) i); /* image ... */ aa = (image **) luaL_checkudata(L, -1, TYPE_IMG); a = *aa; - setup_image(L, a, WR_VF_IMG); /* image ... */ - assert(img_is_refered(a)); - output_image(img_arrayidx(a)); + ad = img_dict(a); + assert(ad != NULL); + setup_image(pdf, a, WR_VF_IMG); /* image ... */ + place_img(pdf, ad, img_dimen(a), img_transform(a)); lua_pop(L, 1); /* ... */ } @@ -784,13 +744,15 @@ static int m_img_print(lua_State * L) static int m_img_gc(lua_State * L) { image *a, **aa; + image_dict *d; aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); a = *aa; + d = img_dict(*aa); #ifdef DEBUG printf("\n===== IMG GC ===== a=%d ad=%d\n", a, img_dict(a)); #endif luaL_unref(L, LUA_GLOBALSINDEX, img_dictref(a)); - if (!img_is_refered(a)) + if (!img_is_refered(d)) xfree(a); return 0; } @@ -827,19 +789,6 @@ static const struct luaL_Reg img_dict_m[] = { /**********************************************************************/ -static void preset_environment(lua_State * L, const parm_struct * p) -{ - int i; - lua_newtable(L); /* t */ - for (i = 1, ++p; p->name != NULL; i++, p++) { - assert(i == (int) p->idx); - lua_pushstring(L, p->name); /* k t */ - lua_pushinteger(L, (int) p->idx); /* v k t */ - lua_settable(L, -3); /* t */ - } - lua_replace(L, LUA_ENVIRONINDEX); /* - */ -} - int luaopen_img(lua_State * L) { preset_environment(L, img_parms); diff --git a/Build/source/texk/web2c/luatexdir/lua/liolib.c b/Build/source/texk/web2c/luatexdir/lua/liolib.c index 28cfced022e..93d21b23697 100644 --- a/Build/source/texk/web2c/luatexdir/lua/liolib.c +++ b/Build/source/texk/web2c/luatexdir/lua/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c 2376 2009-05-08 08:40:13Z taco $ +** $Id: liolib.c 3404 2010-01-28 11:17:10Z taco $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -22,7 +22,7 @@ #include "lauxlib.h" #include "lualib.h" -#include +#include "ptexlib.h" #define IO_INPUT 1 #define IO_OUTPUT 2 @@ -203,7 +203,7 @@ static int io_popen(lua_State * L) if (restrictedshell == 0) allow = 1; else - allow = shell_cmd_is_allowed(cmd, &safecmd, &cmdname); + allow = shell_cmd_is_allowed(&cmd, &safecmd, &cmdname); if (allow == 1) { *pf = lua_popen(L, cmd, mode); @@ -415,16 +415,16 @@ static int read_chars(lua_State * L, FILE * f, size_t n) static int read_all(lua_State * L, FILE * f) { /* attempt to speed up reading whole files */ - size_t rlen; /* how much to read */ + long rlen; /* how much to read */ size_t nr; /* number of chars actually read */ - size_t old; /* old file location */ + long old; /* old file location */ char *p; old = ftell(f); if (old > 0 && (fseek(f, 0, SEEK_END) >= 0) && ((rlen = ftell(f)) > 0) && rlen < 1000 * 1000 * 100) { /* 100 MB */ fseek(f, old, SEEK_SET); - p = malloc(rlen); + p = malloc((size_t) rlen); if (p != NULL) { - nr = fread(p, sizeof(char), rlen, f); + nr = fread(p, sizeof(char), (size_t) rlen, f); lua_pushlstring(L, p, nr); free(p); return 1; @@ -565,12 +565,13 @@ static int f_seek(lua_State * L) static int f_setvbuf(lua_State * L) { + int sz, op, res; static const int mode[] = { _IONBF, _IOFBF, _IOLBF }; static const char *const modenames[] = { "no", "full", "line", NULL }; FILE *f = tofile(L); - int op = luaL_checkoption(L, 2, NULL, modenames); - lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); - int res = setvbuf(f, NULL, mode[op], sz); + op = luaL_checkoption(L, 2, NULL, modenames); + lua_number2int(sz, luaL_optinteger(L, 3, LUAL_BUFFERSIZE)); + res = setvbuf(f, NULL, mode[op], (size_t) sz); return pushresult(L, res == 0, NULL); } diff --git a/Build/source/texk/web2c/luatexdir/lua/lkpselib.c b/Build/source/texk/web2c/luatexdir/lua/lkpselib.c index 71c772eb732..16c6a4ba23a 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lkpselib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lkpselib.c @@ -17,17 +17,20 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include +#include "lua/luatex-api.h" +#include "ptexlib.h" #include #include #include #include +#include +#include +#include static const char _svn_version[] = - "$Id: lkpselib.c 2414 2009-06-03 12:57:01Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/lkpselib.c $"; + "$Id: lkpselib.c 3551 2010-03-26 14:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/lkpselib.c $"; -static const int filetypes[] = { +static const unsigned filetypes[] = { kpse_gf_format, kpse_pk_format, kpse_any_glyph_format, @@ -83,7 +86,8 @@ static const int filetypes[] = { kpse_fea_format, kpse_cid_format, kpse_mlbib_format, - kpse_mlbst_format + kpse_mlbst_format, + kpse_clua_format }; static const char *const filetypenames[] = { @@ -143,6 +147,7 @@ static const char *const filetypenames[] = { "cid maps", "mlbib", "mlbst", + "clua", NULL }; @@ -155,8 +160,7 @@ int program_name_set = 0; #define TEST_PROGRAM_NAME_SET do { \ if (! program_name_set) { \ - lua_pushstring(L, "Please call kpse.set_program_name() before using the library"); \ - return lua_error(L); \ + return luaL_error(L, "Please call kpse.set_program_name() before using the library"); \ } \ } while (0) @@ -164,12 +168,11 @@ static int find_file(lua_State * L) { int i; const char *st; - int ftype = kpse_tex_format; + unsigned ftype = kpse_tex_format; int mexist = 0; TEST_PROGRAM_NAME_SET; if (!lua_isstring(L, 1)) { - lua_pushstring(L, "not a file name"); - lua_error(L); + luaL_error(L, "not a file name"); } st = lua_tostring(L, 1); i = lua_gettop(L); @@ -177,7 +180,7 @@ static int find_file(lua_State * L) if (lua_isboolean(L, i)) { mexist = lua_toboolean(L, i); } else if (lua_isnumber(L, i)) { - mexist = lua_tonumber(L, i); + lua_number2int(mexist, lua_tonumber(L, i)); } else if (lua_isstring(L, i)) { int op = luaL_checkoption(L, i, NULL, filetypenames); ftype = filetypes[op]; @@ -188,7 +191,7 @@ static int find_file(lua_State * L) ftype == kpse_gf_format || ftype == kpse_any_glyph_format) { /* ret.format, ret.name, ret.dpi */ kpse_glyph_file_type ret; - lua_pushstring(L, kpse_find_glyph(st, mexist, ftype, &ret)); + lua_pushstring(L, kpse_find_glyph(st, (unsigned) mexist, ftype, &ret)); } else { if (mexist > 0) mexist = 1; @@ -203,16 +206,16 @@ static int find_file(lua_State * L) static int lua_kpathsea_find_file(lua_State * L) { int i; - int ftype = kpse_tex_format; + unsigned ftype = kpse_tex_format; int mexist = 0; kpathsea *kp = (kpathsea *) luaL_checkudata(L, 1, KPATHSEA_METATABLE); const char *st = luaL_checkstring(L, 2); i = lua_gettop(L); while (i > 2) { if (lua_isboolean(L, i)) { - mexist = lua_toboolean(L, i); + mexist = (boolean) lua_toboolean(L, i); } else if (lua_isnumber(L, i)) { - mexist = lua_tonumber(L, i); + lua_number2int(mexist, lua_tonumber(L, i)); } else if (lua_isstring(L, i)) { int op = luaL_checkoption(L, i, NULL, filetypenames); ftype = filetypes[op]; @@ -223,7 +226,9 @@ static int lua_kpathsea_find_file(lua_State * L) ftype == kpse_gf_format || ftype == kpse_any_glyph_format) { /* ret.format, ret.name, ret.dpi */ kpse_glyph_file_type ret; - lua_pushstring(L, kpathsea_find_glyph(*kp, st, mexist, ftype, &ret)); + lua_pushstring(L, + kpathsea_find_glyph(*kp, st, (unsigned) mexist, ftype, + &ret)); } else { if (mexist > 0) mexist = 1; @@ -238,7 +243,7 @@ static int lua_kpathsea_find_file(lua_State * L) static int show_path(lua_State * L) { int op = luaL_checkoption(L, -1, "tex", filetypenames); - int user_format = filetypes[op]; + unsigned user_format = filetypes[op]; TEST_PROGRAM_NAME_SET; if (!kpse_format_info[user_format].type) /* needed if arg was numeric */ kpse_init_format(user_format); @@ -250,7 +255,7 @@ static int lua_kpathsea_show_path(lua_State * L) { kpathsea *kp = (kpathsea *) luaL_checkudata(L, 1, KPATHSEA_METATABLE); int op = luaL_checkoption(L, -1, "tex", filetypenames); - int user_format = filetypes[op]; + unsigned user_format = filetypes[op]; if (!(*kp)->format_info[user_format].type) /* needed if arg was numeric */ kpathsea_init_format(*kp, user_format); lua_pushstring(L, (*kp)->format_info[user_format].path); @@ -323,6 +328,374 @@ static int lua_kpathsea_var_value(lua_State * L) return 1; } +static unsigned find_dpi(const_string s) +{ + unsigned dpi_number = 0; + string extension = find_suffix(s); + + if (extension != NULL) + sscanf(extension, "%u", &dpi_number); + + return dpi_number; +} + +/* Return newly-allocated NULL-terminated list of strings from MATCHES + that are prefixed with any of the subdirectories in SUBDIRS. That + is, for a string S in MATCHES, its dirname must end with one of the + elements in SUBDIRS. For instance, if subdir=foo/bar, that will + match a string foo/bar/baz or /some/texmf/foo/bar/baz. + + We don't reallocate the actual strings, just the list elements. + Perhaps later we will implement wildcards or // or something. */ + +static string *subdir_match(str_list_type subdirs, string * matches) +{ + string *ret = XTALLOC1(string); + unsigned len = 1; + unsigned m; + + for (m = 0; matches[m]; m++) { + size_t loc; + unsigned e; + string s = xstrdup(matches[m]); + for (loc = strlen(s); loc > 0 && !IS_DIR_SEP(s[loc - 1]); loc--); + while (loc > 0 && IS_DIR_SEP(s[loc - 1])) { + loc--; + } + s[loc] = 0; /* wipe out basename */ + + for (e = 0; e < STR_LIST_LENGTH(subdirs); e++) { + string subdir = STR_LIST_ELT(subdirs, e); + size_t subdir_len = strlen(subdir); + while (subdir_len > 0 && IS_DIR_SEP(subdir[subdir_len - 1])) { + subdir_len--; + subdir[subdir_len] = 0; /* remove trailing slashes from subdir spec */ + } + if (FILESTRCASEEQ(subdir, s + loc - subdir_len)) { + /* matched, save this one. */ + XRETALLOC(ret, len + 1, string); + ret[len - 1] = matches[m]; + len++; + } + } + free(s); + } + ret[len - 1] = NULL; + return ret; +} + +/* Use the file type from -format if that was specified (i.e., the + user_format global variable), else guess dynamically from NAME. + Return kpse_last_format if undeterminable. This function is also + used to parse the -format string, a case which we distinguish by + setting is_filename to false. + + A few filenames have been hard-coded for format types that + differ from what would be inferred from their extensions. */ + +static kpse_file_format_type +find_format(kpathsea kpse, const_string name, boolean is_filename) +{ + kpse_file_format_type ret; + + if (FILESTRCASEEQ(name, "config.ps")) { + ret = kpse_dvips_config_format; + } else if (FILESTRCASEEQ(name, "dvipdfmx.cfg")) { + ret = kpse_program_text_format; + } else if (FILESTRCASEEQ(name, "fmtutil.cnf")) { + ret = kpse_web2c_format; + } else if (FILESTRCASEEQ(name, "glyphlist.txt")) { + ret = kpse_fontmap_format; + } else if (FILESTRCASEEQ(name, "mktex.cnf")) { + ret = kpse_web2c_format; + } else if (FILESTRCASEEQ(name, "pdfglyphlist.txt")) { + ret = kpse_fontmap_format; + } else if (FILESTRCASEEQ(name, "pdftex.cfg")) { + ret = kpse_pdftex_config_format; + } else if (FILESTRCASEEQ(name, "texmf.cnf")) { + ret = kpse_cnf_format; + } else if (FILESTRCASEEQ(name, "updmap.cfg")) { + ret = kpse_web2c_format; + } else if (FILESTRCASEEQ(name, "XDvi")) { + ret = kpse_program_text_format; + } else { + int f = 0; /* kpse_file_format_type */ + size_t name_len = strlen(name); + +/* Have to rely on `try_len' being declared here, since we can't assume + GNU C and statement expressions. */ +#define TRY_SUFFIX(ftry) (\ + try_len = (ftry) ? strlen (ftry) : 0, \ + (ftry) && try_len <= name_len \ + && FILESTRCASEEQ (ftry, name + name_len - try_len)) + + while (f != kpse_last_format) { + size_t try_len; + const_string *ext; + const_string ftry; + boolean found = false; + + if (!kpse->format_info[f].type) + kpathsea_init_format(kpse, (kpse_file_format_type) f); + + if (!is_filename) { + /* Allow the long name, but only in the -format option. We don't + want a filename confused with a format name. */ + ftry = kpse->format_info[f].type; + found = TRY_SUFFIX(ftry); + } + for (ext = kpse->format_info[f].suffix; !found && ext && *ext; + ext++) { + found = TRY_SUFFIX(*ext); + } + for (ext = kpse->format_info[f].alt_suffix; !found && ext && *ext; + ext++) { + found = TRY_SUFFIX(*ext); + } + + if (found) + break; + + /* Some trickery here: the extensions for kpse_fmt_format can + * clash with other extensions in use, and we prefer for those + * others to be preferred. And we don't want to change the + * integer value of kpse_fmt_format. So skip it when first + * enountered, then use it when we've done everything else, + * and use it as the end-guard. + */ + if (f == kpse_fmt_format) { + f = kpse_last_format; + } else if (++f == kpse_fmt_format) { + f++; + } else if (f == kpse_last_format) { + f = kpse_fmt_format; + } + } + + /* If there was a match, f will be one past the correct value. */ + ret = f; + } + + return ret; +} + +/* kpse:lookup("plain.tex", {}) */ +static int do_lua_kpathsea_lookup(lua_State * L, kpathsea kpse, int idx) +{ + int i; + string ret = NULL; + string *ret_list = NULL; + const_string name = NULL; + string user_path = NULL; + boolean show_all = false; + boolean must_exist = false; + kpse_file_format_type user_format = kpse_last_format; + int dpi = 600; + str_list_type subdir_paths = { 0, NULL }; + unsigned saved_debug = kpse->debug; + int saved_mktexpk = kpse->format_info[kpse_pk_format].program_enabled_p; + int saved_mktexmf = kpse->format_info[kpse_mf_format].program_enabled_p; + int saved_mktextex = kpse->format_info[kpse_tex_format].program_enabled_p; + int saved_mktextfm = kpse->format_info[kpse_tfm_format].program_enabled_p; + name = luaL_checkstring(L, idx); + /* todo: fetch parameter values */ + + if (lua_type(L, idx + 1) == LUA_TTABLE) { + lua_pushstring(L, "format"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TSTRING) { + int op = luaL_checkoption(L, -1, NULL, filetypenames); + user_format = filetypes[op]; + } + lua_pop(L, 1); + lua_pushstring(L, "dpi"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_number2int(dpi, lua_tonumber(L, -1)); + } + lua_pop(L, 1); + lua_pushstring(L, "debug"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TNUMBER) { + int d = 0; + lua_number2int(d, lua_tonumber(L, -1)); + kpse->debug |= d; + } + lua_pop(L, 1); + lua_pushstring(L, "path"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TSTRING) { + user_path = xstrdup(lua_tostring(L, -1)); + } + lua_pop(L, 1); + lua_pushstring(L, "all"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TBOOLEAN) { + show_all = lua_toboolean(L, -1); + } + lua_pop(L, 1); + + lua_pushstring(L, "mktexpk"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TBOOLEAN) { + kpathsea_maketex_option(kpse, "pk", lua_toboolean(L, -1)); + } + lua_pop(L, 1); + + lua_pushstring(L, "mktextex"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TBOOLEAN) { + kpathsea_maketex_option(kpse, "tex", lua_toboolean(L, -1)); + } + lua_pop(L, 1); + + lua_pushstring(L, "mktexmf"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TBOOLEAN) { + kpathsea_maketex_option(kpse, "mf", lua_toboolean(L, -1)); + } + lua_pop(L, 1); + + lua_pushstring(L, "mktextfm"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TBOOLEAN) { + kpathsea_maketex_option(kpse, "tfm", lua_toboolean(L, -1)); + } + lua_pop(L, 1); + + + lua_pushstring(L, "must-exist"); + lua_gettable(L, idx + 1); + if (lua_type(L, -1) == LUA_TBOOLEAN) { + must_exist = lua_toboolean(L, -1); + } + lua_pop(L, 1); + lua_pushstring(L, "subdir"); + lua_gettable(L, idx + 1); + if (lua_istable(L, -1)) { + lua_pushnil(L); + while (lua_next(L, -2) != 0) { /* numeric value */ + if (lua_isstring(L, -1)) { + char *s = xstrdup(lua_tostring(L, -1)); + str_list_add(&subdir_paths, s); + xfree(s); + } + lua_pop(L, 1); + } + } else if (lua_isstring(L, -1)) { + char *s = xstrdup(lua_tostring(L, -1)); + str_list_add(&subdir_paths, s); + xfree(s); + } + lua_pop(L, 1); + if (STR_LIST_LENGTH(subdir_paths) > 0) { + show_all = 1; + } + } + if (user_path) { + /* Translate ; to : if that's our ENV_SEP. See cnf.c. */ + if (IS_ENV_SEP(':')) { + string loc; + for (loc = user_path; *loc; loc++) { + if (*loc == ';') + *loc = ':'; + } + } + user_path = kpathsea_path_expand(kpse, user_path); + if (show_all) { + ret_list = kpathsea_all_path_search(kpse, user_path, name); + } else { + ret = kpathsea_path_search(kpse, user_path, name, must_exist); + } + free(user_path); + } else { + /* No user-specified search path, check user format or guess from NAME. */ + kpse_file_format_type fmt; + if (user_format != kpse_last_format) + fmt = user_format; + else + fmt = find_format(kpse, name, true); + + switch (fmt) { + case kpse_pk_format: + case kpse_gf_format: + case kpse_any_glyph_format: + { + kpse_glyph_file_type glyph_ret; + /* Try to extract the resolution from the name. */ + unsigned local_dpi = find_dpi(name); + if (!local_dpi) + local_dpi = (unsigned) dpi; + ret = + kpathsea_find_glyph(kpse, remove_suffix(name), local_dpi, + fmt, &glyph_ret); + } + break; + + case kpse_last_format: + /* If the suffix isn't recognized, assume it's a tex file. */ + fmt = kpse_tex_format; + /* fall through */ + + default: + if (show_all) { + ret_list = + kpathsea_find_file_generic(kpse, name, fmt, must_exist, + true); + } else { + ret = kpathsea_find_file(kpse, name, fmt, must_exist); + } + } + } + + /* Turn single return into a null-terminated list for uniform treatment. */ + if (ret) { + ret_list = XTALLOC(2, string); + ret_list[0] = ret; + ret_list[1] = NULL; + } + + /* Filter by subdirectories, if specified. */ + if (STR_LIST_LENGTH(subdir_paths) > 0) { + string *new_list = subdir_match(subdir_paths, ret_list); + free(ret_list); + ret_list = new_list; + } + kpse->debug = saved_debug; + kpse->format_info[kpse_pk_format].program_enabled_p = saved_mktexpk; + kpse->format_info[kpse_mf_format].program_enabled_p = saved_mktexmf; + kpse->format_info[kpse_tex_format].program_enabled_p = saved_mktextex; + kpse->format_info[kpse_tfm_format].program_enabled_p = saved_mktextfm; + + /* Print output. */ + i = 0; + if (ret_list) { + for (; ret_list[i]; i++) { + lua_pushstring(L, ret_list[i]); + } + free(ret_list); + } + if (i == 0) { + i++; + lua_pushnil(L); + } + return i; +} + + +static int lua_kpathsea_lookup(lua_State * L) +{ + kpathsea *kpsep = (kpathsea *) luaL_checkudata(L, 1, KPATHSEA_METATABLE); + kpathsea kpse = *kpsep; + return do_lua_kpathsea_lookup(L, kpse, 2); +} + +static int lua_kpse_lookup(lua_State * L) +{ + TEST_PROGRAM_NAME_SET; + return do_lua_kpathsea_lookup(L, kpse_def, 1); +} + /* Engine support is a bit of a problem, because we do not want * to interfere with the normal format discovery of |luatex|. @@ -354,7 +727,7 @@ static int set_program_name(lua_State * L) static int init_prog(lua_State * L) { const char *prefix = luaL_checkstring(L, 1); - unsigned dpi = luaL_checkinteger(L, 2); + unsigned dpi = (unsigned) luaL_checkinteger(L, 2); const char *mode = luaL_checkstring(L, 3); const char *fallback = luaL_optstring(L, 4, NULL); TEST_PROGRAM_NAME_SET; @@ -366,18 +739,24 @@ static int lua_kpathsea_init_prog(lua_State * L) { kpathsea *kp = (kpathsea *) luaL_checkudata(L, 1, KPATHSEA_METATABLE); const char *prefix = luaL_checkstring(L, 2); - unsigned dpi = luaL_checkinteger(L, 3); + unsigned dpi = (unsigned) luaL_checkinteger(L, 3); const char *mode = luaL_checkstring(L, 4); const char *fallback = luaL_optstring(L, 5, NULL); kpathsea_init_prog(*kp, prefix, dpi, mode, fallback); return 0; } +static int lua_kpse_version(lua_State * L) +{ + lua_pushstring(L, kpathsea_version_string); + return 1; +} + static int readable_file(lua_State * L) { const char *name = luaL_checkstring(L, 1); TEST_PROGRAM_NAME_SET; - lua_pushstring(L, kpse_readable_file(name)); + lua_pushstring(L, (char *) kpse_readable_file(name)); return 1; } @@ -385,7 +764,7 @@ static int lua_kpathsea_readable_file(lua_State * L) { kpathsea *kp = (kpathsea *) luaL_checkudata(L, 1, KPATHSEA_METATABLE); const char *name = luaL_checkstring(L, 2); - lua_pushstring(L, kpathsea_readable_file(*kp, name)); + lua_pushstring(L, (char *) kpathsea_readable_file(*kp, name)); return 1; } @@ -422,6 +801,8 @@ static const struct luaL_reg kpselib_m[] = { {"expand_braces", lua_kpathsea_expand_braces}, {"var_value", lua_kpathsea_var_value}, {"show_path", lua_kpathsea_show_path}, + {"lookup", lua_kpathsea_lookup}, + {"version", lua_kpse_version}, {NULL, NULL} /* sentinel */ }; @@ -436,6 +817,8 @@ static const struct luaL_reg kpselib_l[] = { {"expand_braces", expand_braces}, {"var_value", var_value}, {"show_path", show_path}, + {"lookup", lua_kpse_lookup}, + {"version", lua_kpse_version}, {NULL, NULL} /* sentinel */ }; diff --git a/Build/source/texk/web2c/luatexdir/lua/llanglib.c b/Build/source/texk/web2c/luatexdir/lua/llanglib.c index 2e5544ca37f..093593d1301 100644 --- a/Build/source/texk/web2c/luatexdir/lua/llanglib.c +++ b/Build/source/texk/web2c/luatexdir/lua/llanglib.c @@ -17,20 +17,18 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include +#include "lua/luatex-api.h" +#include "ptexlib.h" + -#include "nodes.h" -#include "inc-extra.h" static const char _svn_version[] = - "$Id: llanglib.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/llanglib.c $"; + "$Id: llanglib.c 3551 2010-03-26 14:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/llanglib.c $"; #define LANG_METATABLE "luatex.lang" #define check_islang(L,b) (struct tex_language **)luaL_checkudata(L,b,LANG_METATABLE) - static int lang_new(lua_State * L) { struct tex_language **lang; @@ -38,16 +36,16 @@ static int lang_new(lua_State * L) lang = lua_newuserdata(L, sizeof(struct tex_language *)); *lang = new_language(-1); if (!*lang) { - lua_pushstring(L, "lang.new(): no room for a new language"); - return lua_error(L); + return luaL_error(L, "lang.new(): no room for a new language"); } } else { + int lualang; lang = lua_newuserdata(L, sizeof(struct tex_language *)); - *lang = get_language(lua_tonumber(L, 1)); + lua_number2int(lualang, lua_tonumber(L, 1)); + *lang = get_language(lualang); if (!*lang) { - lua_pushfstring(L, "lang.new(%d): undefined language", + return luaL_error(L, "lang.new(%d): undefined language", lua_tonumber(L, 1)); - return lua_error(L); } } luaL_getmetatable(L, LANG_METATABLE); @@ -69,8 +67,7 @@ static int lang_patterns(lua_State * L) lang_ptr = check_islang(L, 1); if (lua_gettop(L) != 1) { if (!lua_isstring(L, 2)) { - lua_pushstring(L, "lang.patterns(): argument should be a string"); - return lua_error(L); + return luaL_error(L, "lang.patterns(): argument should be a string"); } load_patterns(*lang_ptr, (const unsigned char *) lua_tostring(L, 2)); return 0; @@ -99,9 +96,8 @@ static int lang_hyphenation(lua_State * L) lang_ptr = check_islang(L, 1); if (lua_gettop(L) != 1) { if (!lua_isstring(L, 2)) { - lua_pushstring(L, + return luaL_error(L, "lang.hyphenation(): argument should be a string"); - return lua_error(L); } load_hyphenation(*lang_ptr, (const unsigned char *) lua_tostring(L, 2)); return 0; @@ -121,11 +117,10 @@ static int lang_pre_hyphen_char(lua_State * L) lang_ptr = check_islang(L, 1); if (lua_gettop(L) != 1) { if (!lua_isnumber(L, 2)) { - lua_pushstring(L, + return luaL_error(L, "lang.prehyphenchar(): argument should be a character number"); - return lua_error(L); } - (*lang_ptr)->pre_hyphen_char = lua_tonumber(L, 2); + lua_number2int((*lang_ptr)->pre_hyphen_char, lua_tonumber(L, 2)); return 0; } else { lua_pushnumber(L, (*lang_ptr)->pre_hyphen_char); @@ -139,11 +134,10 @@ static int lang_post_hyphen_char(lua_State * L) lang_ptr = check_islang(L, 1); if (lua_gettop(L) != 1) { if (!lua_isnumber(L, 2)) { - lua_pushstring(L, + return luaL_error(L, "lang.posthyphenchar(): argument should be a character number"); - return lua_error(L); } - (*lang_ptr)->post_hyphen_char = lua_tonumber(L, 2); + lua_number2int((*lang_ptr)->post_hyphen_char, lua_tonumber(L, 2)); return 0; } else { lua_pushnumber(L, (*lang_ptr)->post_hyphen_char); @@ -158,11 +152,10 @@ static int lang_pre_exhyphen_char(lua_State * L) lang_ptr = check_islang(L, 1); if (lua_gettop(L) != 1) { if (!lua_isnumber(L, 2)) { - lua_pushstring(L, + return luaL_error(L, "lang.preexhyphenchar(): argument should be a character number"); - return lua_error(L); } - (*lang_ptr)->pre_exhyphen_char = lua_tonumber(L, 2); + lua_number2int((*lang_ptr)->pre_exhyphen_char, lua_tonumber(L, 2)); return 0; } else { lua_pushnumber(L, (*lang_ptr)->pre_exhyphen_char); @@ -176,11 +169,10 @@ static int lang_post_exhyphen_char(lua_State * L) lang_ptr = check_islang(L, 1); if (lua_gettop(L) != 1) { if (!lua_isnumber(L, 2)) { - lua_pushstring(L, + return luaL_error(L, "lang.postexhyphenchar(): argument should be a character number"); - return lua_error(L); } - (*lang_ptr)->post_exhyphen_char = lua_tonumber(L, 2); + lua_number2int((*lang_ptr)->post_exhyphen_char, lua_tonumber(L, 2)); return 0; } else { lua_pushnumber(L, (*lang_ptr)->post_exhyphen_char); @@ -202,8 +194,7 @@ static int do_lang_clean(lua_State * L) { char *cleaned; if (!lua_isstring(L, 1)) { - lua_pushstring(L, "lang.clean(): argument should be a string"); - return lua_error(L); + return luaL_error(L, "lang.clean(): argument should be a string"); } (void) clean_hyphenation(lua_tostring(L, 1), &cleaned); lua_pushstring(L, cleaned); @@ -212,17 +203,18 @@ static int do_lang_clean(lua_State * L) static int do_lang_hyphenate(lua_State * L) { - halfword *h, *t; + halfword *h, *t, tt; h = check_isnode(L, 1); if (lua_isuserdata(L, 2)) { t = check_isnode(L, 2); + tt = *t; lua_pop(L, 1); } else { - t = h; - while (vlink(*t) != null) - *t = vlink(*t); + tt = *h; + while (vlink(tt) != null) + tt = vlink(tt); } - hnj_hyphenation(*h, *t); + hnj_hyphenation(*h, tt); lua_pushboolean(L, 1); return 1; } diff --git a/Build/source/texk/web2c/luatexdir/lua/llualib.c b/Build/source/texk/web2c/luatexdir/lua/llualib.c index 57cffe36ab1..eded8dd8f25 100644 --- a/Build/source/texk/web2c/luatexdir/lua/llualib.c +++ b/Build/source/texk/web2c/luatexdir/lua/llualib.c @@ -17,11 +17,11 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include +#include "lua/luatex-api.h" +#include "ptexlib.h" static const char _svn_version[] = - "$Id: llualib.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/llualib.c $"; + "$Id: llualib.c 3551 2010-03-26 14:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/llualib.c $"; #define LOAD_BUF_SIZE 256 #define UINT_MAX32 0xFFFFFFFF @@ -38,7 +38,7 @@ static bytecode *lua_bytecode_registers = NULL; int luabytecode_max = -1; unsigned int luabytecode_bytes = 0; -static char *luanames[65536] = { NULL }; +char *luanames[65536] = { NULL }; char *get_lua_name(int i) { @@ -49,8 +49,8 @@ char *get_lua_name(int i) void dump_luac_registers(void) { - integer x; - integer k, n; + int x; + int k, n; bytecode b; dump_int(luabytecode_max); if (lua_bytecode_registers != NULL) { @@ -72,7 +72,7 @@ void dump_luac_registers(void) for (k = 0; k < 65536; k++) { char *a = luanames[k]; if (a != NULL) { - x = strlen(a) + 1; + x = (int) strlen(a) + 1; dump_int(x); dump_things(*a, x); } else { @@ -84,18 +84,18 @@ void dump_luac_registers(void) void undump_luac_registers(void) { - integer x; - integer k, n; + int x; + int k, n; unsigned int i; bytecode b; undump_int(luabytecode_max); if (luabytecode_max >= 0) { - i = (luabytecode_max + 1); - if ((int) (UINT_MAX32 / sizeof(bytecode) + 1) <= i) { - lua_fatal_error(maketexstring("Corrupt format file")); + i = (unsigned) (luabytecode_max + 1); + if ((int) (UINT_MAX32 / (int) sizeof(bytecode) + 1) <= i) { + lua_fatal_error("Corrupt format file"); } - lua_bytecode_registers = xmalloc(i * sizeof(bytecode)); - luabytecode_bytes = i * sizeof(bytecode); + lua_bytecode_registers = xmalloc((unsigned) (i * sizeof(bytecode))); + luabytecode_bytes = (unsigned) (i * sizeof(bytecode)); for (i = 0; i <= (unsigned) luabytecode_max; i++) { lua_bytecode_registers[i].done = 0; lua_bytecode_registers[i].size = 0; @@ -106,9 +106,9 @@ void undump_luac_registers(void) undump_int(k); undump_int(x); b.size = x; - b.buf = xmalloc(b.size); - luabytecode_bytes += b.size; - memset(b.buf, 0, b.size); + b.buf = xmalloc((unsigned) b.size); + luabytecode_bytes += (unsigned) b.size; + memset(b.buf, 0, (size_t) b.size); do_zundump((char *) b.buf, 1, b.size, DUMP_FILE); lua_bytecode_registers[k].size = b.size; lua_bytecode_registers[k].alloc = b.size; @@ -118,7 +118,7 @@ void undump_luac_registers(void) for (k = 0; k < 65536; k++) { undump_int(x); if (x > 0) { - char *s = xmalloc(x); + char *s = xmalloc((unsigned) x); undump_things(*s, x); luanames[k] = s; } @@ -157,21 +157,23 @@ static int bytecode_register_shadow_get(lua_State * L, int k) } -static int writer(lua_State * L, const void *b, size_t size, void *B) +int writer(lua_State * L, const void *b, size_t size, void *B) { bytecode *buf = (bytecode *) B; (void) L; /* for -Wunused */ - if ((int) (buf->size + size) > buf->alloc) { - buf->buf = xrealloc(buf->buf, buf->alloc + size + LOAD_BUF_SIZE); - buf->alloc = buf->alloc + size + LOAD_BUF_SIZE; + if ((int) (buf->size + (int) size) > buf->alloc) { + buf->buf = + xrealloc(buf->buf, + (unsigned) (buf->alloc + (int) size + LOAD_BUF_SIZE)); + buf->alloc = buf->alloc + (int) size + LOAD_BUF_SIZE; } memcpy(buf->buf + buf->size, b, size); - buf->size += size; - luabytecode_bytes += size; + buf->size += (int) size; + luabytecode_bytes += (unsigned) size; return 0; } -static const char *reader(lua_State * L, void *ud, size_t * size) +const char *reader(lua_State * L, void *ud, size_t * size) { bytecode *buf = (bytecode *) ud; (void) L; /* for -Wunused */ @@ -180,12 +182,12 @@ static const char *reader(lua_State * L, void *ud, size_t * size) buf->done = 0; return NULL; } - *size = buf->size; + *size = (size_t) buf->size; buf->done = buf->size; return (const char *) buf->buf; } -static int get_bytecode(lua_State * L) +int get_bytecode(lua_State * L) { int k; k = (int) luaL_checkinteger(L, -1); @@ -196,8 +198,7 @@ static int get_bytecode(lua_State * L) if (lua_load (L, reader, (void *) (lua_bytecode_registers + k), "bytecode")) { - lua_error(L); - lua_pushnil(L); + return luaL_error(L, "bad bytecode register"); } else { lua_pushvalue(L, -1); bytecode_register_shadow_set(L, k); @@ -209,34 +210,34 @@ static int get_bytecode(lua_State * L) return 1; } -static int set_bytecode(lua_State * L) +int set_bytecode(lua_State * L) { int k, ltype; unsigned int i; k = (int) luaL_checkinteger(L, -2); - i = k + 1; + i = (unsigned) k + 1; if ((int) (UINT_MAX32 / sizeof(bytecode) + 1) < i) { - lua_pushstring(L, "value too large"); - lua_error(L); + luaL_error(L, "value too large"); } if (k < 0) { - lua_pushstring(L, "negative values not allowed"); - lua_error(L); + luaL_error(L, "negative values not allowed"); } ltype = lua_type(L, -1); if (ltype != LUA_TFUNCTION && ltype != LUA_TNIL) { - lua_pushstring(L, "unsupported type"); - lua_error(L); + luaL_error(L, "unsupported type"); } if (k > luabytecode_max) { - i = sizeof(bytecode) * (k + 1); + i = (unsigned) (sizeof(bytecode) * ((unsigned) k + 1)); lua_bytecode_registers = xrealloc(lua_bytecode_registers, i); if (luabytecode_max == -1) { - luabytecode_bytes += sizeof(bytecode) * (k + 1); + luabytecode_bytes += + (unsigned) (sizeof(bytecode) * (unsigned) (k + 1)); } else { - luabytecode_bytes += sizeof(bytecode) * (k + 1 - luabytecode_max); + luabytecode_bytes += + (unsigned) (sizeof(bytecode) * + (unsigned) (k + 1 - luabytecode_max)); } - for (i = (luabytecode_max + 1); i <= (unsigned) k; i++) { + for (i = (unsigned) (luabytecode_max + 1); i <= (unsigned) k; i++) { lua_bytecode_registers[i].buf = NULL; lua_bytecode_registers[i].size = 0; lua_bytecode_registers[i].done = 0; @@ -245,8 +246,7 @@ static int set_bytecode(lua_State * L) } if (lua_bytecode_registers[k].buf != NULL) { xfree(lua_bytecode_registers[k].buf); - luabytecode_bytes -= lua_bytecode_registers[k].size; - lua_bytecode_registers[k].buf = NULL; + luabytecode_bytes -= (unsigned) lua_bytecode_registers[k].size; lua_bytecode_registers[k].size = 0; lua_bytecode_registers[k].done = 0; lua_pushnil(L); @@ -263,7 +263,7 @@ static int set_bytecode(lua_State * L) } -static int set_luaname(lua_State * L) +int set_luaname(lua_State * L) { int k; const char *s; @@ -286,7 +286,7 @@ static int set_luaname(lua_State * L) return 0; } -static int get_luaname(lua_State * L) +int get_luaname(lua_State * L) { int k; k = (int) luaL_checkinteger(L, 2); @@ -314,7 +314,7 @@ static const struct luaL_reg lualib[] = { {NULL, NULL} /* sentinel */ }; -int luaopen_lua(lua_State * L, const char *fname) +int luaopen_lua(lua_State * L, char *fname) { luaL_register(L, "lua", lualib); make_table(L, "bytecode", "getbytecode", "setbytecode"); diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c index 4b5738da4be..3b626826e58 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -1,6 +1,6 @@ /* lnodelib.c - Copyright 2006-2008 Taco Hoekwater + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,20 +17,16 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include - -#include "nodes.h" -#include "inc-extra.h" - -#include "commands.h" - static const char _svn_version[] = - "$Id: lnodelib.c 2476 2009-06-12 19:39:05Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/lnodelib.c $"; + "$Id: lnodelib.c 3560 2010-03-29 09:27:08Z taco $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/lnodelib.c $"; + +#include "lua/luatex-api.h" +#include "ptexlib.h" #define init_luaS_index(a) do { \ lua_pushliteral(L,#a); \ - luaS_##a##_ptr = lua_tostring(L,-1); \ + luaS_##a##_ptr = lua_tostring(L,-1); \ luaS_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \ } while (0) @@ -77,7 +73,7 @@ int do_get_node_type_id(lua_State * L, int n, node_info * data) return j; } } else if (lua_type(L, n) == LUA_TNUMBER) { - register int i = lua_tointeger(L, n); + register int i = (int) lua_tointeger(L, n); for (j = 0; data[j].id != -1; j++) { if (data[j].id == i) return j; @@ -95,13 +91,10 @@ int get_valid_node_type_id(lua_State * L, int n) int i = get_node_type_id(L, n); if (i == -1) { if (lua_type(L, n) == LUA_TSTRING) { - lua_pushfstring(L, "Invalid node type id: %s", - (const char *) lua_tostring(L, n)); + luaL_error(L, "Invalid node type id: %s", lua_tostring(L, n)); } else { - lua_pushfstring(L, "Invalid node type id: %d", - (int) lua_tonumber(L, n)); + luaL_error(L, "Invalid node type id: %d", lua_tonumber(L, n)); } - return lua_error(L); } return i; } @@ -112,13 +105,12 @@ int get_valid_node_subtype_id(lua_State * L, int n) int i = get_node_subtype_id(L, n); if (i == -1) { if (lua_type(L, n) == LUA_TSTRING) { - lua_pushfstring(L, "Invalid whatsit node id: %s", - (const char *) lua_tostring(L, n)); + luaL_error(L, "Invalid whatsit node id: %s", + lua_tostring(L, n)); } else { - lua_pushfstring(L, "Invalid whatsit node id: %d", - (int) lua_tonumber(L, n)); + luaL_error(L, "Invalid whatsit node id: %d", + lua_tonumber(L, n)); } - return lua_error(L); } return i; } @@ -138,7 +130,7 @@ void lua_nodelib_push(lua_State * L) halfword *a; n = -1; if (lua_isnumber(L, -1)) { - n = lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); } lua_pop(L, 1); if ((n == null) || (n < 0) || (n > var_mem_max)) { @@ -153,6 +145,29 @@ void lua_nodelib_push(lua_State * L) return; } +/* |spec_ptr| fields can legally be zero, which is why there is a special function. */ + +static void lua_nodelib_push_spec(lua_State * L) +{ + halfword n; + halfword *a; + n = -1; + if (lua_isnumber(L, -1)) { + n = (halfword) lua_tointeger(L, -1); + } + lua_pop(L, 1); + if ((n < 0) || (n > var_mem_max)) { + lua_pushnil(L); + } else { + a = lua_newuserdata(L, sizeof(halfword)); + *a = n; + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); + lua_gettable(L, LUA_REGISTRYINDEX); + lua_setmetatable(L, -2); + } + return; +} + void lua_nodelib_push_fast(lua_State * L, halfword n) { halfword *a; @@ -169,7 +184,7 @@ void lua_nodelib_push_fast(lua_State * L, halfword n) static int lua_nodelib_id(lua_State * L) { - integer i = get_node_type_id(L, 1); + int i = get_node_type_id(L, 1); if (i >= 0) { lua_pushnumber(L, i); } else { @@ -181,7 +196,7 @@ static int lua_nodelib_id(lua_State * L) static int lua_nodelib_subtype(lua_State * L) { - integer i = get_node_subtype_id(L, 1); + int i = get_node_subtype_id(L, 1); if (i >= 0) { lua_pushnumber(L, i); } else { @@ -194,7 +209,7 @@ static int lua_nodelib_subtype(lua_State * L) static int lua_nodelib_type(lua_State * L) { - integer i = get_node_type_id(L, 1); + int i = get_node_type_id(L, 1); if (i >= 0) { lua_pushstring(L, node_data[i].name); } else { @@ -218,14 +233,13 @@ static int lua_nodelib_new(lua_State * L) j = get_valid_node_subtype_id(L, 2); } if (j < 0) { - lua_pushstring(L, + luaL_error(L, "Creating a whatsit requires the subtype number as a second argument"); - lua_error(L); } } else { j = 0; if (lua_gettop(L) > 1) { - j = lua_tointeger(L, 2); + j = (int) lua_tointeger(L, 2); } } n = new_node(i, j); @@ -284,8 +298,7 @@ static int lua_nodelib_remove(lua_State * L) { halfword head, current, t; if (lua_gettop(L) < 2) { - lua_pushstring(L, "Not enough arguments for node.remove()"); - lua_error(L); + luaL_error(L, "Not enough arguments for node.remove()"); } head = *(check_isnode(L, 1)); if (lua_isnil(L, 2)) { @@ -304,9 +317,8 @@ static int lua_nodelib_remove(lua_State * L) if (t == null || vlink(t) != current) { set_t_to_prev(head, current); if (t == null) { /* error! */ - lua_pushstring(L, + luaL_error(L, "Attempt to node.remove() a non-existing node"); - lua_error(L); } } /* t is now the previous node */ @@ -329,8 +341,7 @@ static int lua_nodelib_insert_before(lua_State * L) { halfword head, current, n, t; if (lua_gettop(L) < 3) { - lua_pushstring(L, "Not enough arguments for node.insert_before()"); - lua_error(L); + luaL_error(L, "Not enough arguments for node.insert_before()"); } if (lua_isnil(L, 3)) { lua_pop(L, 1); @@ -357,9 +368,8 @@ static int lua_nodelib_insert_before(lua_State * L) if (t == null || vlink(t) != current) { set_t_to_prev(head, current); if (t == null) { /* error! */ - lua_pushstring(L, + luaL_error(L, "Attempt to node.insert_before() a non-existing node"); - lua_error(L); } } couple_nodes(t, n); @@ -379,8 +389,7 @@ static int lua_nodelib_insert_after(lua_State * L) { halfword head, current, n; if (lua_gettop(L) < 3) { - lua_pushstring(L, "Not enough arguments for node.insert_after()"); - lua_error(L); + luaL_error(L, "Not enough arguments for node.insert_after()"); } if (lua_isnil(L, 3)) { lua_pop(L, 1); @@ -417,13 +426,17 @@ static int lua_nodelib_insert_after(lua_State * L) static int lua_nodelib_copy_list(lua_State * L) { - halfword *n; + halfword n, s = null; halfword m; if (lua_isnil(L, 1)) return 1; /* the nil itself */ - n = check_isnode(L, 1); - m = copy_node_list(*n); - lua_nodelib_push_fast(L, m); + n = *check_isnode(L, 1); + if ((lua_gettop(L) > 1) && (!lua_isnil(L,2))) { + s = *check_isnode(L, 2); + } + m = do_copy_node_list(n, s); + lua_pushnumber(L, m); + lua_nodelib_push(L); return 1; } @@ -452,10 +465,10 @@ static int lua_nodelib_append(lua_State * L) for (i = 1; i <= j; i++) { n = check_isnode(L, i); m = *n; - new_tail_append(m); + tail_append(m); while (vlink(m) != null) { m = vlink(m); - new_tail_append(m); + tail_append(m); } } return 0; @@ -478,11 +491,12 @@ static int lua_nodelib_hpack(lua_State * L) { halfword n, p; const char *s; - integer w = 0; + int w = 0; int m = 1; + int d = -1; n = *(check_isnode(L, 1)); if (lua_gettop(L) > 1) { - w = lua_tointeger(L, 2); + w = (int) lua_tointeger(L, 2); if (lua_gettop(L) > 2) { if (lua_type(L, 3) == LUA_TSTRING) { s = lua_tostring(L, 3); @@ -490,23 +504,78 @@ static int lua_nodelib_hpack(lua_State * L) m = 1; else if (strcmp(s, "exactly") == 0) m = 0; + else if (strcmp(s, "cal_expand_ratio") == 0) + m = 2; + else if (strcmp(s, "subst_ex_font") == 0) + m = 3; else { - lua_pushstring(L, + luaL_error(L, "3rd argument should be either additional or exactly"); - lua_error(L); } - } - - else if (lua_type(L, 3) == LUA_TNUMBER) { - m = lua_tonumber(L, 3); + } else if (lua_type(L, 3) == LUA_TNUMBER) { + lua_number2int(m, lua_tonumber(L, 3)); } else { lua_pushstring(L, "incorrect 3rd argument"); } + if (lua_gettop(L) > 3) { + if (lua_type(L, 4) == LUA_TSTRING) { + d = nodelib_getdir(L, 4); + } else { + lua_pushstring(L, "incorrect 4th argument"); + } + } } } - p = hpack(n, w, m); + p = hpack(n, w, m, d); lua_nodelib_push_fast(L, p); - return 1; + lua_pushnumber(L, last_badness); + return 2; +} + + +static int lua_nodelib_dimensions(lua_State * L) +{ + int top; + top = lua_gettop(L); + if (top > 0) { + scaled_whd siz; + glue_ratio g_mult = 1.0; + int g_sign = normal; + int g_order = normal; + int i = 1; + int d = -1; + halfword n = null, p = null; + if (lua_isnumber(L, 1)) { + if (top < 4) { + lua_pushnil(L); + return 1; + } + i += 3; + g_mult = (glue_ratio) lua_tonumber(L, 1); + lua_number2int(g_sign, lua_tonumber(L, 2)); + lua_number2int(g_order, lua_tonumber(L, 3)); + } + n = *(check_isnode(L, i)); + if (lua_gettop(L) > i && !lua_isnil(L, (i + 1))) { + if (lua_type(L, (i + 1)) == LUA_TSTRING) { + d = nodelib_getdir(L, (i + 1)); + } else { + p = *(check_isnode(L, (i + 1))); + } + } + if (lua_gettop(L) > (i + 1) && lua_type(L, (i + 2)) == LUA_TSTRING) { + d = nodelib_getdir(L, (i + 2)); + } + siz = natural_sizes(n, p, g_mult, g_sign, g_order, d); + lua_pushnumber(L, siz.wd); + lua_pushnumber(L, siz.ht); + lua_pushnumber(L, siz.dp); + return 3; + } else { + luaL_error(L, + "missing argument to 'dimensions' (luatex_node expected)"); + } + return 0; /* not reached */ } @@ -515,11 +584,12 @@ static int lua_nodelib_vpack(lua_State * L) { halfword n, p; const char *s; - integer w = 0; + int w = 0; int m = 1; + int d = -1; n = *(check_isnode(L, 1)); if (lua_gettop(L) > 1) { - w = lua_tointeger(L, 2); + w = (int) lua_tointeger(L, 2); if (lua_gettop(L) > 2) { if (lua_type(L, 3) == LUA_TSTRING) { s = lua_tostring(L, 3); @@ -528,22 +598,29 @@ static int lua_nodelib_vpack(lua_State * L) else if (strcmp(s, "exactly") == 0) m = 0; else { - lua_pushstring(L, + luaL_error(L, "3rd argument should be either additional or exactly"); - lua_error(L); + } + if (lua_gettop(L) > 3) { + if (lua_type(L, 4) == LUA_TSTRING) { + d = nodelib_getdir(L, 4); + } else { + lua_pushstring(L, "incorrect 4th argument"); + } } } else if (lua_type(L, 3) == LUA_TNUMBER) { - m = lua_tonumber(L, 3); + lua_number2int(m, lua_tonumber(L, 3)); } else { lua_pushstring(L, "incorrect 3rd argument"); } } } - p = vpackage(n, w, m, max_dimen); + p = vpackage(n, w, m, max_dimen, d); lua_nodelib_push_fast(L, p); - return 1; + lua_pushnumber(L, last_badness); + return 2; } @@ -558,10 +635,7 @@ static int lua_nodelib_mlist_to_hlist(lua_State * L) w = luaL_checkoption(L, 2, "text", math_style_names); luaL_checkany(L, 3); m = lua_toboolean(L, 3); - cur_mlist = n; - cur_style = w; - mlist_penalties = m; - mlist_to_hlist(); + mlist_to_hlist_args(n, w, m); lua_nodelib_push_fast(L, vlink(temp_head)); return 1; } @@ -569,9 +643,9 @@ static int lua_nodelib_mlist_to_hlist(lua_State * L) static int lua_nodelib_mfont(lua_State * L) { int f, s; - f = luaL_checkinteger(L, 1); + f = (int) luaL_checkinteger(L, 1); if (lua_gettop(L) == 2) - s = lua_tointeger(L, 2); /* this should be a multiple of 256 ! */ + s = (int) lua_tointeger(L, 2); /* this should be a multiple of 256 ! */ else s = 0; lua_pushnumber(L, fam_fnt(f, s)); @@ -605,9 +679,13 @@ make_luaS_index(uchyph); make_luaS_index(components); make_luaS_index(xoffset); make_luaS_index(yoffset); +make_luaS_index(width); +make_luaS_index(height); +make_luaS_index(depth); +make_luaS_index(expansion_factor); -static void initialize_luaS_indexes(lua_State * L) +void initialize_luaS_indexes(lua_State * L) { init_luaS_index(id); init_luaS_index(next); @@ -623,6 +701,10 @@ static void initialize_luaS_indexes(lua_State * L) init_luaS_index(components); init_luaS_index(xoffset); init_luaS_index(yoffset); + init_luaS_index(width); + init_luaS_index(height); + init_luaS_index(depth); + init_luaS_index(expansion_factor); } static int get_node_field_id(lua_State * L, int n, int node) @@ -658,6 +740,14 @@ static int get_node_field_id(lua_State * L, int n, int node) return 11; } else if (luaS_ptr_eq(s, yoffset)) { return 12; + } else if (luaS_ptr_eq(s, width)) { + return 13; + } else if (luaS_ptr_eq(s, height)) { + return 14; + } else if (luaS_ptr_eq(s, depth)) { + return 15; + } else if (luaS_ptr_eq(s, expansion_factor)) { + return 16; } } else if (luaS_ptr_eq(s, prev)) { return -1; @@ -683,9 +773,8 @@ static int get_valid_node_field_id(lua_State * L, int n, int node) int i = get_node_field_id(L, n, node); if (i == -2) { const char *s = lua_tostring(L, n); - lua_pushfstring(L, "Invalid field id %s for node type %s (%d)", s, + luaL_error(L, "Invalid field id %s for node type %s (%d)", s, node_data[type(node)].name, subtype(node)); - lua_error(L); } return i; } @@ -778,6 +867,24 @@ static int lua_nodelib_tail(lua_State * L) return 1; } +static int lua_nodelib_tail_only(lua_State * L) +{ + halfword *n; + halfword t; + if (lua_isnil(L, 1)) + return 1; /* the nil itself */ + n = check_isnode(L, 1); + t = *n; + if (t == null) + return 1; /* the old userdata */ + while (vlink(t) != null) { + t = vlink(t); + } + lua_nodelib_push_fast(L, t); + return 1; +} + + /* a few utility functions for attribute stuff */ static int lua_nodelib_has_attribute(lua_State * L) @@ -786,8 +893,8 @@ static int lua_nodelib_has_attribute(lua_State * L) int i, val; n = check_isnode(L, 1); if (n != NULL) { - i = lua_tointeger(L, 2); - val = luaL_optinteger(L, 3, UNUSED_ATTRIBUTE); + i = (int) lua_tointeger(L, 2); + val = (int) luaL_optinteger(L, 3, UNUSED_ATTRIBUTE); if ((val = has_attribute(*n, i, val)) > UNUSED_ATTRIBUTE) { lua_pushnumber(L, val); return 1; @@ -802,8 +909,8 @@ static int lua_nodelib_set_attribute(lua_State * L) halfword *n; int i, val; if (lua_gettop(L) == 3) { - i = lua_tointeger(L, 2); - val = lua_tointeger(L, 3); + i = (int) lua_tointeger(L, 2); + val = (int) lua_tointeger(L, 3); n = check_isnode(L, 1); if (val == UNUSED_ATTRIBUTE) { (void) unset_attribute(*n, i, val); @@ -811,8 +918,7 @@ static int lua_nodelib_set_attribute(lua_State * L) set_attribute(*n, i, val); } } else { - lua_pushstring(L, "incorrect number of arguments"); - lua_error(L); + luaL_error(L, "incorrect number of arguments"); } return 0; } @@ -823,8 +929,8 @@ static int lua_nodelib_unset_attribute(lua_State * L) halfword *n; int i, val, ret; if (lua_gettop(L) <= 3) { - i = luaL_checknumber(L, 2); - val = luaL_optnumber(L, 3, UNUSED_ATTRIBUTE); + lua_number2int(i, luaL_checknumber(L, 2)); + lua_number2int(val, luaL_optnumber(L, 3, UNUSED_ATTRIBUTE)); n = check_isnode(L, 1); ret = unset_attribute(*n, i, val); if (ret > UNUSED_ATTRIBUTE) { @@ -834,8 +940,7 @@ static int lua_nodelib_unset_attribute(lua_State * L) } return 1; } else { - lua_pushstring(L, "incorrect number of arguments"); - return lua_error(L); + return luaL_error(L, "incorrect number of arguments"); } } @@ -851,7 +956,7 @@ static int nodelib_aux_nil(lua_State * L) static int nodelib_aux_next_filtered(lua_State * L) { register halfword t; /* traverser */ - register int i = lua_tointeger(L, lua_upvalueindex(1)); + register int i = (int) lua_tointeger(L, lua_upvalueindex(1)); if (lua_isnil(L, 2)) { /* first call */ t = *check_isnode(L, 1); } else { @@ -955,7 +1060,7 @@ static int lua_nodelib_count(lua_State * L) halfword n; halfword m = null; int i = -1; - i = lua_tointeger(L, 1); + i = (int) lua_tointeger(L, 1); if (lua_isnil(L, 2)) { lua_pushnumber(L, 0); return 1; @@ -970,23 +1075,32 @@ static int lua_nodelib_count(lua_State * L) #define nodelib_pushlist(L,n) { lua_pushnumber(L,n); lua_nodelib_push(L); } #define nodelib_pushattr(L,n) { lua_pushnumber(L,n); lua_nodelib_push(L); } -#define nodelib_pushspec(L,n) { lua_pushnumber(L,n); lua_nodelib_push(L); } +#define nodelib_pushspec(L,n) { lua_pushnumber(L,n); lua_nodelib_push_spec(L); } #define nodelib_pushaction(L,n) { lua_pushnumber(L,n); lua_nodelib_push(L); } -#define nodelib_pushstring(L,n) { lua_pushstring(L,makecstring(n)); } +#define nodelib_pushstring(L,n) { char *ss=makecstring(n); lua_pushstring(L,ss); free(ss); } static void nodelib_pushdir(lua_State * L, int n, boolean dirnode) { - int f = 0; - char dirstring[5] = { 0 }; + char s[2]; if (dirnode) { - dirstring[f++] = (n < 0 ? '-' : '+'); + s[0] = (char) (n < 0 ? '-' : '+'); + s[1] = 0; + } else { + s[0] = 0; } if (n < 0) n += 64; - dirstring[f++] = dir_names[(int) dir_primary[n]]; - dirstring[f++] = dir_names[(int) dir_secondary[n]]; - dirstring[f++] = dir_names[(int) dir_tertiary[n]]; - lua_pushstring(L, dirstring); + if (n == dir_TLT) { + lua_pushfstring(L, "%sTLT", s); + } else if (n == dir_TRT) { + lua_pushfstring(L, "%sTRT", s); + } else if (n == dir_LTL) { + lua_pushfstring(L, "%sLTL", s); + } else if (n == dir_RTT) { + lua_pushfstring(L, "%sRTT", s); + } else { + lua_pushstring(L, "???"); + } } static void lua_nodelib_getfield_whatsit(lua_State * L, int n, int field) @@ -1116,13 +1230,13 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, int field) case pdf_refxform_node: switch (field) { case 4: - lua_pushnumber(L, pdf_width(n)); + lua_pushnumber(L, width(n)); break; case 5: - lua_pushnumber(L, pdf_height(n)); + lua_pushnumber(L, depth(n)); break; case 6: - lua_pushnumber(L, pdf_depth(n)); + lua_pushnumber(L, height(n)); break; case 7: lua_pushnumber(L, pdf_xform_objnum(n)); @@ -1134,16 +1248,19 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, int field) case pdf_refximage_node: switch (field) { case 4: - lua_pushnumber(L, pdf_width(n)); + lua_pushnumber(L, width(n)); break; case 5: - lua_pushnumber(L, pdf_height(n)); + lua_pushnumber(L, depth(n)); break; case 6: - lua_pushnumber(L, pdf_depth(n)); + lua_pushnumber(L, height(n)); break; case 7: - lua_pushnumber(L, pdf_ximage_objnum(n)); + lua_pushnumber(L, pdf_ximage_transform(n)); + break; + case 8: + lua_pushnumber(L, pdf_ximage_index(n)); break; default: lua_pushnil(L); @@ -1152,13 +1269,13 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, int field) case pdf_annot_node: switch (field) { case 4: - lua_pushnumber(L, pdf_width(n)); + lua_pushnumber(L, width(n)); break; case 5: - lua_pushnumber(L, pdf_height(n)); + lua_pushnumber(L, depth(n)); break; case 6: - lua_pushnumber(L, pdf_depth(n)); + lua_pushnumber(L, height(n)); break; case 7: lua_pushnumber(L, pdf_annot_objnum(n)); @@ -1173,13 +1290,13 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, int field) case pdf_start_link_node: switch (field) { case 4: - lua_pushnumber(L, pdf_width(n)); + lua_pushnumber(L, width(n)); break; case 5: - lua_pushnumber(L, pdf_height(n)); + lua_pushnumber(L, depth(n)); break; case 6: - lua_pushnumber(L, pdf_depth(n)); + lua_pushnumber(L, height(n)); break; case 7: lua_pushnumber(L, pdf_link_objnum(n)); @@ -1197,13 +1314,13 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, int field) case pdf_dest_node: switch (field) { case 4: - lua_pushnumber(L, pdf_width(n)); + lua_pushnumber(L, width(n)); break; case 5: - lua_pushnumber(L, pdf_height(n)); + lua_pushnumber(L, depth(n)); break; case 6: - lua_pushnumber(L, pdf_depth(n)); + lua_pushnumber(L, height(n)); break; case 7: lua_pushnumber(L, pdf_dest_named_id(n)); @@ -1231,13 +1348,13 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, int field) case pdf_start_thread_node: switch (field) { case 4: - lua_pushnumber(L, pdf_width(n)); + lua_pushnumber(L, width(n)); break; case 5: - lua_pushnumber(L, pdf_height(n)); + lua_pushnumber(L, depth(n)); break; case 6: - lua_pushnumber(L, pdf_depth(n)); + lua_pushnumber(L, height(n)); break; case 7: lua_pushnumber(L, pdf_thread_named_id(n)); @@ -1588,6 +1705,9 @@ static int lua_nodelib_getfield(lua_State * L) case 8: lua_pushnumber(L, glue_ref_count(n)); break; + case 9: + lua_pushboolean(L, valid_node(n)); + break; default: lua_pushnil(L); } @@ -1600,6 +1720,8 @@ static int lua_nodelib_getfield(lua_State * L) case 4: lua_pushnumber(L, width(n)); break; + case 5: + lua_pushnumber(L, ex_kern(n)); default: lua_pushnil(L); } @@ -1648,6 +1770,18 @@ static int lua_nodelib_getfield(lua_State * L) case 12: lua_pushnumber(L, y_displace(n)); break; + case 13: + lua_pushnumber(L, char_width(font(n),character(n))); + break; + case 14: + lua_pushnumber(L, char_height(font(n),character(n))); + break; + case 15: + lua_pushnumber(L, char_depth(font(n),character(n))); + break; + case 16: + lua_pushnumber(L, ex_glyph(n)); + break; default: lua_pushnil(L); } @@ -1878,10 +2012,10 @@ static int lua_nodelib_getfield(lua_State * L) case 2: lua_pushnumber(L, subtype(n)); break; - case 3: + case 4: lua_pushnumber(L, width(n)); break; - case 4: + case 5: nodelib_pushlist(L, margin_char(n)); break; default: @@ -1970,11 +2104,10 @@ static int nodelib_getlist(lua_State * L, int n) } } -static int nodelib_getdir(lua_State * L, int n) +int nodelib_getdir(lua_State * L, int n) { const char *s = NULL; int d = 32; /* invalid number */ - int a = -1, b = -1, c = -1; if (lua_type(L, n) == LUA_TSTRING) { s = lua_tostring(L, n); if (strlen(s) == 3) { @@ -1988,42 +2121,22 @@ static int nodelib_getdir(lua_State * L, int n) s++; } if (strlen(s) == 3) { - switch (*s) { - /* *INDENT-OFF* */ - case 'T': a=0; break; - case 'L': a=1; break; - case 'B': a=2; break; - case 'R': a=3; break; - /* *INDENT-ON* */ - } - switch (*(s + 1)) { - /* *INDENT-OFF* */ - case 'T': b=0; break; - case 'L': b=1; break; - case 'B': b=2; break; - case 'R': b=3; break; - /* *INDENT-ON* */ + if (strcmp(s, "TLT") == 0) { + d += dir_TLT; + } else if (strcmp(s, "TRT") == 0) { + d += dir_TRT; + } else if (strcmp(s, "LTL") == 0) { + d += dir_LTL; + } else if (strcmp(s, "RTT") == 0) { + d += dir_RTT; } - switch (*(s + 2)) { - /* *INDENT-OFF* */ - case 'T': c=0; break; - case 'L': c=1; break; - case 'B': c=2; break; - case 'R': c=3; break; - /* *INDENT-ON* */ - } - } - if (a != -1 && b != -1 && c != -1 && !dir_parallel(a, b)) { - d += (a * 8 + dir_rearrange[b] * 4 + c); } - } else if (lua_isnumber(L, n)) { - d = lua_tonumber(L, n); + } else { + luaL_error(L, "Direction specifiers have to be strings"); } if ((d > 31) || (d < -64) || (d < 0 && (d + 64) > 31)) { d = 0; - lua_pushfstring(L, "Bad direction specifier %s", - (const char *) lua_tostring(L, n)); - lua_error(L); + luaL_error(L, "Bad direction specifier %s", lua_tostring(L, n)); } return d; } @@ -2056,9 +2169,8 @@ static void nodelib_setattr(lua_State * L, int stackindex, halfword n) static int nodelib_cantset(lua_State * L, int field, int n) { - lua_pushfstring(L, "You cannot set field %d in a node of type %s", + luaL_error(L, "You cannot set field %d in a node of type %s", field, node_data[type(n)].name); - lua_error(L); return 0; } @@ -2068,7 +2180,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case open_node: switch (field) { case 4: - write_stream(n) = lua_tointeger(L, 3); + write_stream(n) = (halfword) lua_tointeger(L, 3); break; case 5: open_name(n) = nodelib_getstring(L, 3); @@ -2086,7 +2198,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case write_node: switch (field) { case 4: - write_stream(n) = lua_tointeger(L, 3); + write_stream(n) = (halfword) lua_tointeger(L, 3); break; case 5: write_tokens(n) = nodelib_gettoks(L, 3); @@ -2098,7 +2210,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case close_node: switch (field) { case 4: - write_stream(n) = lua_tointeger(L, 3); + write_stream(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2116,10 +2228,10 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case local_par_node: switch (field) { case 4: - local_pen_inter(n) = lua_tointeger(L, 3); + local_pen_inter(n) = (halfword) lua_tointeger(L, 3); break; case 5: - local_pen_broken(n) = lua_tointeger(L, 3); + local_pen_broken(n) = (halfword) lua_tointeger(L, 3); break; case 6: local_par_dir(n) = nodelib_getdir(L, 3); @@ -2128,13 +2240,13 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) local_box_left(n) = nodelib_getlist(L, 3); break; case 8: - local_box_left_width(n) = lua_tointeger(L, 3); + local_box_left_width(n) = (halfword) lua_tointeger(L, 3); break; case 9: local_box_right(n) = nodelib_getlist(L, 3); break; case 10: - local_box_right_width(n) = lua_tointeger(L, 3); + local_box_right_width(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2146,13 +2258,13 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) dir_dir(n) = nodelib_getdir(L, 3); break; case 5: - dir_level(n) = lua_tointeger(L, 3); + dir_level(n) = (halfword) lua_tointeger(L, 3); break; case 6: - dir_dvi_ptr(n) = lua_tointeger(L, 3); + dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3); break; case 7: - dir_dvi_h(n) = lua_tointeger(L, 3); + dir_dvi_h(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2161,7 +2273,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_literal_node: switch (field) { case 4: - pdf_literal_mode(n) = lua_tointeger(L, 3); + pdf_literal_mode(n) = (quarterword) lua_tointeger(L, 3); break; case 5: if (ini_version) { @@ -2179,7 +2291,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_refobj_node: switch (field) { case 4: - pdf_obj_objnum(n) = lua_tointeger(L, 3); + pdf_obj_objnum(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2188,16 +2300,16 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_refxform_node: switch (field) { case 4: - pdf_width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_height(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - pdf_depth(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_xform_objnum(n) = lua_tointeger(L, 3); + pdf_xform_objnum(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2206,16 +2318,19 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_refximage_node: switch (field) { case 4: - pdf_width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_height(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - pdf_depth(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_ximage_objnum(n) = lua_tointeger(L, 3); + pdf_ximage_transform(n) = (halfword) lua_tointeger(L, 3); + break; + case 8: + pdf_ximage_index(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2224,16 +2339,16 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_annot_node: switch (field) { case 4: - pdf_width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_height(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - pdf_depth(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_annot_objnum(n) = lua_tointeger(L, 3); + pdf_annot_objnum(n) = (halfword) lua_tointeger(L, 3); break; case 8: pdf_annot_data(n) = nodelib_gettoks(L, 3); @@ -2245,16 +2360,16 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_start_link_node: switch (field) { case 4: - pdf_width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_height(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - pdf_depth(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_link_objnum(n) = lua_tointeger(L, 3); + pdf_link_objnum(n) = (halfword) lua_tointeger(L, 3); break; case 8: pdf_link_attr(n) = nodelib_gettoks(L, 3); @@ -2275,31 +2390,31 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_dest_node: switch (field) { case 4: - pdf_width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_height(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - pdf_depth(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_dest_named_id(n) = lua_tointeger(L, 3); + pdf_dest_named_id(n) = (quarterword) lua_tointeger(L, 3); break; case 8: if (pdf_dest_named_id(n) == 1) pdf_dest_id(n) = nodelib_gettoks(L, 3); else - pdf_dest_id(n) = lua_tointeger(L, 3); + pdf_dest_id(n) = (halfword) lua_tointeger(L, 3); break; case 9: - pdf_dest_type(n) = lua_tointeger(L, 3); + pdf_dest_type(n) = (quarterword) lua_tointeger(L, 3); break; case 10: - pdf_dest_xyz_zoom(n) = lua_tointeger(L, 3); + pdf_dest_xyz_zoom(n) = (halfword) lua_tointeger(L, 3); break; case 11: - pdf_dest_objnum(n) = lua_tointeger(L, 3); + pdf_dest_objnum(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2309,22 +2424,22 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_start_thread_node: switch (field) { case 4: - pdf_width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_height(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - pdf_depth(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_thread_named_id(n) = lua_tointeger(L, 3); + pdf_thread_named_id(n) = (quarterword) lua_tointeger(L, 3); break; case 8: if (pdf_thread_named_id(n) == 1) pdf_thread_id(n) = nodelib_gettoks(L, 3); else - pdf_thread_id(n) = lua_tointeger(L, 3); + pdf_thread_id(n) = (halfword) lua_tointeger(L, 3); break; case 9: pdf_thread_attr(n) = nodelib_gettoks(L, 3); @@ -2340,7 +2455,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case late_lua_node: switch (field) { case 4: - late_lua_reg(n) = lua_tointeger(L, 3); + late_lua_reg(n) = (halfword) lua_tointeger(L, 3); break; case 5: late_lua_data(n) = nodelib_gettoks(L, 3); @@ -2355,7 +2470,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case close_lua_node: switch (field) { case 4: - late_lua_reg(n) = lua_tointeger(L, 3); + late_lua_reg(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2364,10 +2479,10 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_colorstack_node: switch (field) { case 4: - pdf_colorstack_stack(n) = lua_tointeger(L, 3); + pdf_colorstack_stack(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_colorstack_cmd(n) = lua_tointeger(L, 3); + pdf_colorstack_cmd(n) = (halfword) lua_tointeger(L, 3); break; case 6: pdf_colorstack_data(n) = nodelib_gettoks(L, 3); @@ -2393,10 +2508,10 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case user_defined_node: switch (field) { case 4: - user_node_id(n) = lua_tointeger(L, 3); + user_node_id(n) = (halfword) lua_tointeger(L, 3); break; case 5: - user_node_type(n) = lua_tointeger(L, 3); + user_node_type(n) = (halfword) lua_tointeger(L, 3); break; case 6: switch (user_node_type(n)) { @@ -2404,7 +2519,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) user_node_value(n) = nodelib_getlist(L, 3); break; case 'd': - user_node_value(n) = lua_tointeger(L, 3); + user_node_value(n) = (halfword) lua_tointeger(L, 3); break; case 'n': user_node_value(n) = nodelib_getlist(L, 3); @@ -2416,7 +2531,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) user_node_value(n) = nodelib_gettoks(L, 3); break; default: - user_node_value(n) = lua_tointeger(L, 3); + user_node_value(n) = (halfword) lua_tointeger(L, 3); break; } break; @@ -2439,6 +2554,11 @@ static int lua_nodelib_setfield(lua_State * L) field = get_valid_node_field_id(L, 2, n); if (field < -1) return 0; + if (field !=0 && /* .next assignments are always allowed */ + !valid_node(n)) { + return luaL_error(L, "You can't assign to this %s node (%d)\n", node_data[type(n)].name, n); + /* return implied */ + } if (field == 0) { vlink(n) = nodelib_getlist(L, 3); } else if (field == -1) { @@ -2448,34 +2568,38 @@ static int lua_nodelib_setfield(lua_State * L) } else if (type(n) == glyph_node) { switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - character(n) = lua_tointeger(L, 3); + character(n) = (halfword) lua_tointeger(L, 3); break; case 5: - font(n) = lua_tointeger(L, 3); + font(n) = (halfword) lua_tointeger(L, 3); break; case 6: - set_char_lang(n, lua_tointeger(L, 3)); + set_char_lang(n, (halfword) lua_tointeger(L, 3)); break; case 7: - set_char_lhmin(n, lua_tointeger(L, 3)); + set_char_lhmin(n, (halfword) lua_tointeger(L, 3)); break; case 8: - set_char_rhmin(n, lua_tointeger(L, 3)); + set_char_rhmin(n, (halfword) lua_tointeger(L, 3)); break; case 9: - set_char_uchyph(n, lua_tointeger(L, 3)); + set_char_uchyph(n, (halfword) lua_tointeger(L, 3)); break; case 10: lig_ptr(n) = nodelib_getlist(L, 3); break; case 11: - x_displace(n) = lua_tointeger(L, 3); + x_displace(n) = (halfword) lua_tointeger(L, 3); break; case 12: - y_displace(n) = lua_tointeger(L, 3); + y_displace(n) = (halfword) lua_tointeger(L, 3); + break; + /* 13,14,15 are virtual width, height, depth */ + case 16: + ex_glyph(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2486,31 +2610,31 @@ static int lua_nodelib_setfield(lua_State * L) case vlist_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: box_dir(n) = nodelib_getdir(L, 3); break; case 8: - shift_amount(n) = lua_tointeger(L, 3); + shift_amount(n) = (halfword) lua_tointeger(L, 3); break; case 9: - glue_order(n) = lua_tointeger(L, 3); + glue_order(n) = (quarterword) lua_tointeger(L, 3); break; case 10: - glue_sign(n) = lua_tointeger(L, 3); + glue_sign(n) = (quarterword) lua_tointeger(L, 3); break; case 11: - glue_set(n) = (double) lua_tonumber(L, 3); + glue_set(n) = (glue_ratio) lua_tonumber(L, 3); break; case 12: list_ptr(n) = nodelib_getlist(L, 3); @@ -2524,31 +2648,31 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 4: - width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - box_dir(n) = lua_tointeger(L, 3); + box_dir(n) = (halfword) lua_tointeger(L, 3); break; case 8: - glue_shrink(n) = lua_tointeger(L, 3); + glue_shrink(n) = (halfword) lua_tointeger(L, 3); break; case 9: - glue_order(n) = lua_tointeger(L, 3); + glue_order(n) = (quarterword) lua_tointeger(L, 3); break; case 10: - glue_sign(n) = lua_tointeger(L, 3); + glue_sign(n) = (quarterword) lua_tointeger(L, 3); break; case 11: - glue_stretch(n) = lua_tointeger(L, 3); + glue_stretch(n) = (halfword) lua_tointeger(L, 3); break; case 12: - span_count(n) = lua_tointeger(L, 3); + span_count(n) = (quarterword) lua_tointeger(L, 3); break; case 13: list_ptr(n) = nodelib_getlist(L, 3); @@ -2562,13 +2686,13 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 4: - width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: rule_dir(n) = nodelib_getdir(L, 3); @@ -2580,16 +2704,16 @@ static int lua_nodelib_setfield(lua_State * L) case ins_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - float_cost(n) = lua_tointeger(L, 3); + float_cost(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: split_top_ptr(n) = nodelib_getspec(L, 3); @@ -2604,10 +2728,10 @@ static int lua_nodelib_setfield(lua_State * L) case mark_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - mark_class(n) = lua_tointeger(L, 3); + mark_class(n) = (halfword) lua_tointeger(L, 3); break; case 5: mark_ptr(n) = nodelib_gettoks(L, 3); @@ -2619,7 +2743,7 @@ static int lua_nodelib_setfield(lua_State * L) case adjust_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: adjust_ptr(n) = nodelib_getlist(L, 3); @@ -2631,7 +2755,7 @@ static int lua_nodelib_setfield(lua_State * L) case disc_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: set_disc_field(pre_break(n), nodelib_getlist(L, 3)); @@ -2649,10 +2773,10 @@ static int lua_nodelib_setfield(lua_State * L) case math_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - surround(n) = lua_tointeger(L, 3); + surround(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2661,7 +2785,7 @@ static int lua_nodelib_setfield(lua_State * L) case glue_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: glue_ptr(n) = nodelib_getspec(L, 3); @@ -2678,34 +2802,38 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 3: - width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 4: - stretch(n) = lua_tointeger(L, 3); + stretch(n) = (halfword) lua_tointeger(L, 3); break; case 5: - shrink(n) = lua_tointeger(L, 3); + shrink(n) = (halfword) lua_tointeger(L, 3); break; case 6: - stretch_order(n) = lua_tointeger(L, 3); + stretch_order(n) = (quarterword) lua_tointeger(L, 3); break; case 7: - shrink_order(n) = lua_tointeger(L, 3); + shrink_order(n) = (quarterword) lua_tointeger(L, 3); break; case 8: - glue_ref_count(n) = lua_tointeger(L, 3); + glue_ref_count(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); + } break; case kern_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - width(n) = lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); + break; + case 5: + ex_kern(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2716,7 +2844,7 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 4: - penalty(n) = lua_tointeger(L, 3); + penalty(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2727,29 +2855,29 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 3: - pdf_action_type(n) = lua_tointeger(L, 3); + pdf_action_type(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - pdf_action_named_id(n) = lua_tointeger(L, 3); + pdf_action_named_id(n) = (quarterword) lua_tointeger(L, 3); break; case 5: if (pdf_action_named_id(n) == 1) { pdf_action_id(n) = nodelib_gettoks(L, 3); } else { - pdf_action_id(n) = lua_tointeger(L, 3); + pdf_action_id(n) = (halfword) lua_tointeger(L, 3); } break; case 6: pdf_action_file(n) = nodelib_gettoks(L, 3); break; case 7: - pdf_action_new_window(n) = lua_tointeger(L, 3); + pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3); break; case 8: pdf_action_tokens(n) = nodelib_gettoks(L, 3); break; case 9: - pdf_action_refcount(n) = lua_tointeger(L, 3); + pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2760,7 +2888,9 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 4: - subtype(n) = luaL_checkoption(L, 3, "text", math_style_names); + subtype(n) = + (quarterword) luaL_checkoption(L, 3, "text", + math_style_names); break; default: return nodelib_cantset(L, field, n); @@ -2769,7 +2899,7 @@ static int lua_nodelib_setfield(lua_State * L) case choice_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: display_mlist(n) = nodelib_getlist(L, 3); @@ -2790,7 +2920,7 @@ static int lua_nodelib_setfield(lua_State * L) case simple_noad: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: nucleus(n) = nodelib_getlist(L, 3); @@ -2808,7 +2938,7 @@ static int lua_nodelib_setfield(lua_State * L) case radical_noad: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: nucleus(n) = nodelib_getlist(L, 3); @@ -2832,10 +2962,10 @@ static int lua_nodelib_setfield(lua_State * L) case fraction_noad: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - thickness(n) = lua_tointeger(L, 3); + thickness(n) = (halfword) lua_tointeger(L, 3); break; case 5: numerator(n) = nodelib_getlist(L, 3); @@ -2856,7 +2986,7 @@ static int lua_nodelib_setfield(lua_State * L) case accent_noad: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: nucleus(n) = nodelib_getlist(L, 3); @@ -2880,7 +3010,7 @@ static int lua_nodelib_setfield(lua_State * L) case fence_noad: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: delimiter(n) = nodelib_getlist(L, 3); @@ -2893,13 +3023,13 @@ static int lua_nodelib_setfield(lua_State * L) case math_text_char_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - math_fam(n) = lua_tointeger(L, 3); + math_fam(n) = (halfword) lua_tointeger(L, 3); break; case 5: - math_character(n) = lua_tointeger(L, 3); + math_character(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2909,7 +3039,7 @@ static int lua_nodelib_setfield(lua_State * L) case sub_mlist_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: math_list(n) = nodelib_getlist(L, 3); @@ -2921,19 +3051,19 @@ static int lua_nodelib_setfield(lua_State * L) case delim_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - small_fam(n) = lua_tointeger(L, 3); + small_fam(n) = (halfword) lua_tointeger(L, 3); break; case 5: - small_char(n) = lua_tointeger(L, 3); + small_char(n) = (halfword) lua_tointeger(L, 3); break; case 6: - large_fam(n) = lua_tointeger(L, 3); + large_fam(n) = (halfword) lua_tointeger(L, 3); break; case 7: - large_char(n) = lua_tointeger(L, 3); + large_char(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2942,12 +3072,12 @@ static int lua_nodelib_setfield(lua_State * L) case margin_kern_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); - break; - case 3: - width(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: + width(n) = (halfword) lua_tointeger(L, 3); + break; + case 5: margin_char(n) = nodelib_getlist(L, 3); break; default: @@ -2957,7 +3087,7 @@ static int lua_nodelib_setfield(lua_State * L) case inserting_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 3: last_ins_ptr(n) = nodelib_getlist(L, 3); @@ -2972,7 +3102,7 @@ static int lua_nodelib_setfield(lua_State * L) case split_up_node: switch (field) { case 2: - subtype(n) = lua_tointeger(L, 3); + subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 3: last_ins_ptr(n) = nodelib_getlist(L, 3); @@ -3003,10 +3133,10 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 3: - attribute_id(n) = lua_tointeger(L, 3); + attribute_id(n) = (halfword) lua_tointeger(L, 3); break; case 4: - attribute_value(n) = lua_tointeger(L, 3); + attribute_value(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -3118,7 +3248,7 @@ static int lua_nodelib_protect_glyphs(lua_State * L) register int s = subtype(head); if (s <= 256) { t = 1; - subtype(head) = (s == 1 ? 256 : 256 + s); + subtype(head) = (quarterword) (s == 1 ? 256 : 256 + s); } } head = vlink(head); @@ -3137,7 +3267,7 @@ static int lua_nodelib_unprotect_glyphs(lua_State * L) register int s = subtype(head); if (s > 256) { t = 1; - subtype(head) = s - 256; + subtype(head) = (quarterword) (s - 256); } } head = vlink(head); @@ -3178,7 +3308,7 @@ static int lua_nodelib_first_character(lua_State * L) /* this is too simplistic, but it helps Hans to get going */ -static halfword do_ligature_n(halfword prev, halfword stop, halfword lig) +halfword do_ligature_n(halfword prev, halfword stop, halfword lig) { vlink(lig) = vlink(stop); vlink(stop) = null; @@ -3216,6 +3346,14 @@ static int lua_nodelib_usedlist(lua_State * L) return 1; } +/* node.protrusion_skipable(node m) */ +static int lua_nodelib_cp_skipable(lua_State * L) +{ + halfword n; + n = *(check_isnode(L, 1)); + lua_pushboolean(L, cp_skipable(n)); + return 1; +} static const struct luaL_reg nodelib_f[] = { {"id", lua_nodelib_id}, @@ -3226,6 +3364,7 @@ static const struct luaL_reg nodelib_f[] = { {"count", lua_nodelib_count}, {"traverse", lua_nodelib_traverse}, {"traverse_id", lua_nodelib_traverse_filtered}, + {"tail", lua_nodelib_tail_only}, {"slide", lua_nodelib_tail}, {"types", lua_nodelib_types}, {"whatsits", lua_nodelib_whatsits}, @@ -3240,6 +3379,7 @@ static const struct luaL_reg nodelib_f[] = { {"last_node", lua_nodelib_last_node}, {"copy", lua_nodelib_copy}, {"copy_list", lua_nodelib_copy_list}, + {"dimensions", lua_nodelib_dimensions}, {"hpack", lua_nodelib_hpack}, {"vpack", lua_nodelib_vpack}, {"mlist_to_hlist", lua_nodelib_mlist_to_hlist}, @@ -3254,7 +3394,8 @@ static const struct luaL_reg nodelib_f[] = { {"usedlist", lua_nodelib_usedlist}, {"protect_glyphs", lua_nodelib_protect_glyphs}, {"unprotect_glyphs", lua_nodelib_unprotect_glyphs}, - {NULL, NULL} /* sentinel */ + {"protrusion_skipable", lua_nodelib_cp_skipable}, + {NULL, NULL} /* sentinel */ }; static const struct luaL_reg nodelib_m[] = { diff --git a/Build/source/texk/web2c/luatexdir/lua/loslibext.c b/Build/source/texk/web2c/luatexdir/lua/loslibext.c index f79b0f0daf0..9130f488d59 100644 --- a/Build/source/texk/web2c/luatexdir/lua/loslibext.c +++ b/Build/source/texk/web2c/luatexdir/lua/loslibext.c @@ -17,17 +17,17 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include +#include "lua/luatex-api.h" +#include "ptexlib.h" -#include -#include +#include +#include #include static const char _svn_version[] = - "$Id: loslibext.c 2376 2009-05-08 08:40:13Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/loslibext.c $"; + "$Id: loslibext.c 3518 2010-03-17 09:57:13Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/loslibext.c $"; -#if defined(_WIN32) || defined(WIN32) || defined(__NT__) +#if defined(_WIN32) || defined(__NT__) # define MKDIR(a,b) mkdir(a) #else # define MKDIR(a,b) mkdir(a,b) @@ -39,7 +39,7 @@ static const char _svn_version[] = successfully compile without major prorting effort (amiga|mac|os2|vms) */ -#if defined(_WIN32) || defined(WIN32) || defined(__NT__) +#if defined(_WIN32) || defined(__NT__) # define OS_PLATTYPE "windows" # define OS_PLATNAME "windows" #elif defined(__GO32__) || defined(__DJGPP__) || defined(__DOS__) @@ -51,6 +51,8 @@ static const char _svn_version[] = /* this is just a first guess */ # if defined(__BSD__) # define OS_PLATNAME "bsd" +# elif defined(__CYGWIN__) +# define OS_PLATNAME "cygwin" # elif defined(__SYSV__) # define OS_PLATNAME "sysv" # else @@ -63,6 +65,9 @@ static const char _svn_version[] = # elif defined(__FREEBSD__) || defined(__FreeBSD__) || defined(__FreeBSD) # undef OS_PLATNAME # define OS_PLATNAME "freebsd" +# elif defined(__FreeBSD_kernel__) +# undef OS_PLATNAME +# define OS_PLATNAME "kfreebsd" # elif defined(__OPENBSD__) || defined(__OpenBSD) # undef OS_PLATNAME # define OS_PLATNAME "openbsd" @@ -81,6 +86,9 @@ static const char _svn_version[] = # elif defined(__MACH__) && defined(__APPLE__) # undef OS_PLATNAME # define OS_PLATNAME "macosx" +# elif defined(__GNU__) +# undef OS_PLATNAME +# define OS_PLATNAME "gnu" # endif #endif @@ -93,7 +101,7 @@ static const char _svn_version[] = * gettimeofday() for win32 is using an alternative definition */ -#if (! defined(WIN32)) && (! defined(__SUNOS__)) +#if (! defined(_WIN32)) && (! defined(__SUNOS__)) # include /* gettimeofday() */ # include /* times() */ # include @@ -103,7 +111,7 @@ static const char _svn_version[] = #define DONT_REALLY_EXIT 1 -#ifdef WIN32 +#ifdef _WIN32 # include # define spawn_command(a,b,c) _spawnvpe(_P_WAIT,(const char *)a,(const char* const*)b,(const char* const*)c) # if DONT_REALLY_EXIT @@ -117,7 +125,7 @@ static const char _svn_version[] = static int exec_command(const char *file, char *const *argv, char *const *envp) { - char path[PATH_MAX]; + char *path; const char *searchpath, *esp; size_t prefixlen, filelen, totallen; @@ -125,6 +133,7 @@ static int exec_command(const char *file, char *const *argv, char *const *envp) return execve(file, argv, envp); filelen = strlen(file); + path = NULL; searchpath = getenv("PATH"); if (!searchpath) @@ -135,20 +144,26 @@ static int exec_command(const char *file, char *const *argv, char *const *envp) do { esp = strchr(searchpath, ':'); if (esp) - prefixlen = esp - searchpath; + prefixlen = (size_t) (esp - searchpath); else prefixlen = strlen(searchpath); if (prefixlen == 0 || searchpath[prefixlen - 1] == '/') { totallen = prefixlen + filelen; +# ifdef PATH_MAX if (totallen >= PATH_MAX) continue; +# endif + path = malloc(totallen + 1); memcpy(path, searchpath, prefixlen); memcpy(path + prefixlen, file, filelen); } else { totallen = prefixlen + filelen + 1; +# ifdef PATH_MAX if (totallen >= PATH_MAX) continue; +# endif + path = malloc(totallen + 1); memcpy(path, searchpath, prefixlen); path[prefixlen] = '/'; memcpy(path + prefixlen + 1, file, filelen); @@ -156,6 +171,8 @@ static int exec_command(const char *file, char *const *argv, char *const *envp) path[totallen] = '\0'; execve(path, argv, envp); + free(path); + path = NULL; if (errno == E2BIG || errno == ENOEXEC || errno == ENOMEM || errno == ETXTBSY) break; /* Report this as an error, no more search */ @@ -242,13 +259,44 @@ static int spawn_command(const char *file, char *const *argv, char *const *envp) #endif -extern char **environ; +#ifdef _WIN32 +static char *get_command_name(char *maincmd) +{ + /* retrieve argv[0] part from the command string, + it will be truncated to MAX_PATH if it's too long */ + char *cmdname = (char *) malloc(sizeof(char) * MAX_PATH); + int i, k, quoted; + quoted = k = 0; + for (i = 0; (i < MAX_PATH) && maincmd[i] && + (maincmd[i] != ' ' && maincmd[i] != '\t' || quoted); i++) { + if (maincmd[i] == '"') { + quoted = !quoted; + } else { + cmdname[k] = maincmd[i]; + k++; + } + } + cmdname[k] = '\0'; + return cmdname; +} +#endif -static char **do_split_command(const char *maincmd) +static char **do_split_command(const char *maincmd, char **runcmd) { + char **cmdline = NULL; +#ifdef _WIN32 + /* On WIN32 don't split anything, because + _spawnvpe can't put it back together properly + if there are quoted arguments with spaces. + Instead, dump everything into one argument + and it will be passed through as is */ + cmdline = malloc(sizeof(char *) * 2); + cmdline[0] = xstrdup(maincmd); + cmdline[1] = NULL; + *runcmd = get_command_name(cmdline[0]); +#else char *piece, *start_piece; const char *cmd; - char **cmdline = NULL; unsigned int i, j; int ret = 0; int in_string = 0; @@ -298,12 +346,15 @@ static char **do_split_command(const char *maincmd) quoted = 0; } xfree(start_piece); + *runcmd = cmdline[0]; +#endif return cmdline; } static char **do_flatten_command(lua_State * L, char **runcmd) { - unsigned int i, j; + unsigned int i; + int j; const char *s; char **cmdline = NULL; *runcmd = NULL; @@ -318,10 +369,10 @@ static char **do_flatten_command(lua_State * L, char **runcmd) } if (j == 1) return NULL; - cmdline = malloc(sizeof(char *) * (j + 1)); - for (i = 1; i <= j; i++) { + cmdline = malloc(sizeof(char *) * (unsigned) (j + 1)); + for (i = 1; i <= (unsigned) j; i++) { cmdline[i] = NULL; - lua_rawgeti(L, -1, i); + lua_rawgeti(L, -1, (int) i); if (lua_isnil(L, -1) || (s = lua_tostring(L, -1)) == NULL) { lua_pop(L, 1); if (i == 1) { @@ -339,7 +390,11 @@ static char **do_flatten_command(lua_State * L, char **runcmd) lua_rawgeti(L, -1, 0); if (lua_isnil(L, -1) || (s = lua_tostring(L, -1)) == NULL) { +#ifdef _WIN32 + *runcmd = get_command_name(cmdline[0]); +#else *runcmd = cmdline[0]; +#endif } else { *runcmd = xstrdup(s); } @@ -369,8 +424,7 @@ static int os_exec(lua_State * L) } if (lua_type(L, 1) == LUA_TSTRING) { maincmd = lua_tostring(L, 1); - cmdline = do_split_command(maincmd); - runcmd = cmdline[0]; + cmdline = do_split_command(maincmd, &runcmd); } else if (lua_type(L, 1) == LUA_TTABLE) { cmdline = do_flatten_command(L, &runcmd); } @@ -380,13 +434,15 @@ static int os_exec(lua_State * L) * but I am not so eager to attempt to fix that. Just document * that os.exec() checks only the command name. */ - if (restrictedshell == 0) + if (restrictedshell == 0) { allow = 1; - else - allow = shell_cmd_is_allowed(runcmd, &safecmd, &cmdname); + } else { + const char *theruncmd = runcmd; + allow = shell_cmd_is_allowed(&theruncmd, &safecmd, &cmdname); + } if (allow > 0 && cmdline != NULL && runcmd != NULL) { -#if defined(WIN32) && DONT_REALLY_EXIT +#if defined(_WIN32) && DONT_REALLY_EXIT if (allow == 2) exec_command(safecmd, cmdline, environ); else @@ -449,8 +505,7 @@ static int os_spawn(lua_State * L) } if (lua_type(L, 1) == LUA_TSTRING) { maincmd = lua_tostring(L, 1); - cmdline = do_split_command(maincmd); - runcmd = cmdline[0]; + cmdline = do_split_command(maincmd, &runcmd); } else if (lua_type(L, 1) == LUA_TTABLE) { cmdline = do_flatten_command(L, &runcmd); } @@ -460,10 +515,12 @@ static int os_spawn(lua_State * L) * but I am not so eager to attempt to fix that. Just document * that os.exec() checks only the command name. */ - if (restrictedshell == 0) + if (restrictedshell == 0) { allow = 1; - else - allow = shell_cmd_is_allowed(runcmd, &safecmd, &cmdname); + } else { + const char *theruncmd = runcmd; + allow = shell_cmd_is_allowed(&theruncmd, &safecmd, &cmdname); + } if (allow > 0 && cmdline != NULL && runcmd != NULL) { if (allow == 2) i = spawn_command(safecmd, cmdline, environ); @@ -479,7 +536,7 @@ static int os_spawn(lua_State * L) } else if (i == -1) { /* this branch covers WIN32 as well as fork() and waitpid() errors */ do_error_return(strerror(errno), errno); -#ifndef WIN32 +#ifndef _WIN32 } else if (i == INVALID_RET_E2BIG) { do_error_return(strerror(E2BIG), i); } else if (i == INVALID_RET_ENOENT) { @@ -518,19 +575,19 @@ static int os_spawn(lua_State * L) static int os_setenv(lua_State * L) { - char *value; const char *key, *val; + char *value; key = luaL_optstring(L, 1, NULL); val = luaL_optstring(L, 2, NULL); if (key) { if (val) { - value = xmalloc(strlen(key) + strlen(val) + 2); + value = xmalloc((unsigned) (strlen(key) + strlen(val) + 2)); sprintf(value, "%s=%s", key, val); if (putenv(value)) { return luaL_error(L, "unable to change environment"); } } else { -#if defined(WIN32) || defined(__sun__) || defined(__sun) || defined(_AIX) +#if defined(_WIN32) || defined(__sun__) || defined(__sun) || defined(_AIX) value = xmalloc(strlen(key) + 2); sprintf(value, "%s=", key); if (putenv(value)) { @@ -546,7 +603,7 @@ static int os_setenv(lua_State * L) } -static void find_env(lua_State * L) +void find_env(lua_State * L) { char *envitem, *envitem_orig; char *envkey; @@ -583,17 +640,17 @@ static int ex_sleep(lua_State * L) { lua_Number interval = luaL_checknumber(L, 1); lua_Number units = luaL_optnumber(L, 2, 1); -#ifdef WIN32 - Sleep(1e3 * interval / units); +#ifdef _WIN32 + Sleep((DWORD) (1e3 * interval / units)); #else /* assumes posix or bsd */ - usleep(1e6 * interval / units); + usleep((unsigned) (1e6 * interval / units)); #endif return 0; } -#ifdef WIN32 +#ifdef _WIN32 # define _UTSNAME_LENGTH 65 /* Structure describing the system and machine. */ @@ -754,7 +811,7 @@ static int ex_uname(lua_State * L) } -#if (! defined (WIN32)) && (! defined (__SUNOS__)) +#if (! defined (_WIN32)) && (! defined (__SUNOS__)) static int os_times(lua_State * L) { struct tms r; @@ -791,7 +848,7 @@ static int os_times(lua_State * L) static int os_gettimeofday(lua_State * L) { double v; -# ifndef WIN32 +# ifndef _WIN32 struct timeval tv; gettimeofday(&tv, NULL); v = (double) tv.tv_sec + (double) tv.tv_usec / 1000000.0; @@ -813,21 +870,20 @@ static int os_gettimeofday(lua_State * L) } #endif -#ifndef HAVE_MKDTEMP static const char repl[] = "0123456789abcdefghijklmnopqrstuvwxyz"; static int dirs_made = 0; #define MAXTRIES 36*36*36 -static char *do_mkdtemp(char *tmpl) +char *do_mkdtemp(char *tmpl) { int count; int value; char *xes = &tmpl[strlen(tmpl) - 6]; /* this is not really all that random, but it will do */ if (dirs_made == 0) { - srand(time(NULL)); + srand((unsigned) time(NULL)); } value = rand(); for (count = 0; count < MAXTRIES; value += 8413, ++count) { @@ -852,7 +908,6 @@ static char *do_mkdtemp(char *tmpl) } return NULL; } -#endif static int os_tmpdir(lua_State * L) { @@ -900,7 +955,7 @@ static int os_execute(lua_State * L) if (restrictedshell == 0) allow = 1; else - allow = shell_cmd_is_allowed(cmd, &safecmd, &cmdname); + allow = shell_cmd_is_allowed(&cmd, &safecmd, &cmdname); if (allow == 1) { lua_pushinteger(L, system(cmd)); @@ -937,7 +992,7 @@ void open_oslibext(lua_State * L, int safer_option) lua_setfield(L, -2, "name"); lua_pushcfunction(L, ex_uname); lua_setfield(L, -2, "uname"); -#if (! defined (WIN32)) && (! defined (__SUNOS__)) +#if (! defined (_WIN32)) && (! defined (__SUNOS__)) lua_pushcfunction(L, os_times); lua_setfield(L, -2, "times"); #endif diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c index 6de1ae112a9..b715f02b24b 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c @@ -1,6 +1,6 @@ /* lpdflib.c - - Copyright 2006-2008 Taco Hoekwater + + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,151 +17,751 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include - static const char _svn_version[] = - "$Id: lpdflib.c 2329 2009-04-18 14:25:30Z hhenkel $ " - "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/lpdflib.c $"; + "$Id: lpdflib.c 3582 2010-04-02 16:37:08Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/lpdflib.c $"; -static int findcurv(lua_State * L) -{ - int j; - j = get_cur_v(); - lua_pushnumber(L, j); - return 1; -} +#include "lua/luatex-api.h" +#include "ptexlib.h" -static int findcurh(lua_State * L) -{ - int j; - j = get_cur_h(); - lua_pushnumber(L, j); - return 1; +#define buf_to_pdfbuf_macro(p, s, l) \ +for (i = 0; i < (l); i++) { \ + if (i % 16 == 0) \ + pdf_room(p, 16); \ + pdf_quick_out(p, ((const unsigned char *) (s))[i]); \ } -static int luapdfprint(lua_State * L) +int luapdfprint(lua_State * L) { int n; unsigned i; - size_t len; - const char *outputstr, *st; + const_lstring st, modestr; ctm_transform_modes literal_mode; + st.s = modestr.s = NULL; n = lua_gettop(L); if (!lua_isstring(L, -1)) { - lua_pushstring(L, "no string to print"); - lua_error(L); + luaL_error(L, "no string to print"); } literal_mode = set_origin; if (n == 2) { if (!lua_isstring(L, -2)) { - lua_pushstring(L, "invalid argument for print literal mode"); - lua_error(L); + luaL_error(L, "invalid argument for print literal mode"); } else { - outputstr = lua_tostring(L, -2); - if (strcmp(outputstr, "direct") == 0) + modestr.s = lua_tolstring(L, -2, &modestr.l); + if (modestr.l == 6 && strncmp(modestr.s, "direct", 6) == 0) literal_mode = direct_always; - else if (strcmp(outputstr, "page") == 0) + else if (modestr.l == 4 && strncmp(modestr.s, "page", 4) == 0) literal_mode = direct_page; else { - lua_pushstring(L, "invalid argument for print literal mode"); - lua_error(L); + luaL_error(L, "invalid argument for print literal mode"); } } } else { if (n != 1) { - lua_pushstring(L, "invalid number of arguments"); - lua_error(L); + luaL_error(L, "invalid number of arguments"); } } - check_pdfminorversion(); + check_o_mode(static_pdf, "pdf.print()", 1 << OMODE_PDF, true); switch (literal_mode) { case (set_origin): - pdf_goto_pagemode(); - pos = synch_p_with_c(cur); - pdf_set_pos(pos.h, pos.v); + pdf_goto_pagemode(static_pdf); + pdf_set_pos(static_pdf, static_pdf->posstruct->pos); + (void) calc_pdfpos(static_pdf->pstruct, static_pdf->posstruct->pos); break; case (direct_page): - pdf_goto_pagemode(); + pdf_goto_pagemode(static_pdf); + (void) calc_pdfpos(static_pdf->pstruct, static_pdf->posstruct->pos); break; case (direct_always): - pdf_end_string_nl(); + pdf_end_string_nl(static_pdf); break; default: assert(0); } - st = lua_tolstring(L, n, &len); - for (i = 0; i < len; i++) { - if (i % 16 == 0) - pdfroom(16); - pdf_buf[pdf_ptr++] = st[i]; - } + st.s = lua_tolstring(L, n, &st.l); + buf_to_pdfbuf_macro(static_pdf, st.s, st.l); return 0; } +unsigned char *fread_to_buf(lua_State * L, const char *filename, size_t * len) +{ + int i = 0; + int ilen = 0; + FILE *f; + unsigned char *buf = NULL; + if ((f = fopen(filename, "rb")) == NULL) + luaL_error(L, "pdf.immediateobj() cannot open input file"); + if ((i = readbinfile(f, &buf, &ilen)) == 0) + luaL_error(L, "pdf.immediateobj() cannot read input file"); + fclose(f); + *len = (size_t) ilen; + return buf; +} + static int l_immediateobj(lua_State * L) { + int n, first_arg = 1; unsigned i; - size_t len; - const char *st; - if (!lua_isstring(L, -1)) - luaL_error(L, "pdf.immediateobj needs string value"); - pdf_create_obj(obj_type_others, 0); - pdf_begin_obj(obj_ptr, 1); - st = lua_tolstring(L, -1, &len); - for (i = 0; i < len; i++) { - if (i % 16 == 0) - pdfroom(16); - pdf_buf[pdf_ptr++] = st[i]; - } - pdf_puts("\n"); - pdf_end_obj(); - lua_pop(L, 1); - lua_pushinteger(L, obj_ptr); + int k; + lstring buf; + const_lstring st1, st2, st3; + st1.s = st2.s = st3.s = NULL; + check_o_mode(static_pdf, "immediateobj()", 1 << OMODE_PDF, true); + n = lua_gettop(L); + if (n > 0 && lua_type(L, 1) == LUA_TNUMBER) { + first_arg++; + lua_number2int(k, lua_tonumber(L, 1)); + check_obj_exists(static_pdf, obj_type_obj, k); + if (is_obj_scheduled(static_pdf, k) || obj_data_ptr(static_pdf, k) != 0) + luaL_error(L, "pdf.immediateobj() object in use"); + } else { + incr(static_pdf->obj_count); + pdf_create_obj(static_pdf, obj_type_obj, static_pdf->sys_obj_ptr + 1); + k = static_pdf->sys_obj_ptr; + } + pdf_last_obj = k; + switch (n - first_arg + 1) { + case 0: + luaL_error(L, "pdf.immediateobj() needs at least one argument"); + break; + case 1: + if (!lua_isstring(L, first_arg)) + luaL_error(L, "pdf.immediateobj() 1st argument must be string"); + pdf_begin_obj(static_pdf, k, 1); + st1.s = lua_tolstring(L, first_arg, &st1.l); + buf_to_pdfbuf_macro(static_pdf, st1.s, st1.l); + if (st1.s[st1.l - 1] != '\n') + pdf_puts(static_pdf, "\n"); + pdf_end_obj(static_pdf); + break; + case 2: + case 3: + if (!lua_isstring(L, first_arg)) + luaL_error(L, "pdf.immediateobj() 1st argument must be string"); + if (!lua_isstring(L, first_arg + 1)) + luaL_error(L, "pdf.immediateobj() 2nd argument must be string"); + st1.s = lua_tolstring(L, first_arg, &st1.l); + st2.s = lua_tolstring(L, first_arg + 1, &st2.l); + if (st1.l == 4 && strncmp((const char *) st1.s, "file", 4) == 0) { + if (n == first_arg + 2) + luaL_error(L, + "pdf.immediateobj() 3rd argument forbidden in file mode"); + pdf_begin_obj(static_pdf, k, 1); + buf.s = fread_to_buf(L, st2.s, &buf.l); + buf_to_pdfbuf_macro(static_pdf, buf.s, buf.l); + if (buf.s[buf.l - 1] != '\n') + pdf_puts(static_pdf, "\n"); + xfree(buf.s); + pdf_end_obj(static_pdf); + } else { + pdf_begin_dict(static_pdf, k, 0); /* 0 = not an object stream candidate! */ + if (n == first_arg + 2) { /* write attr text */ + if (!lua_isstring(L, first_arg + 2)) + luaL_error(L, + "pdf.immediateobj() 3rd argument must be string"); + st3.s = lua_tolstring(L, first_arg + 2, &st3.l); + buf_to_pdfbuf_macro(static_pdf, st3.s, st3.l); + if (st3.s[st3.l - 1] != '\n') + pdf_puts(static_pdf, "\n"); + } + pdf_begin_stream(static_pdf); + if (st1.l == 6 && strncmp((const char *) st1.s, "stream", 6) == 0) { + buf_to_pdfbuf_macro(static_pdf, st2.s, st2.l); + } else if (st1.l == 10 + && strncmp((const char *) st1.s, "streamfile", + 10) == 0) { + buf.s = fread_to_buf(L, st2.s, &buf.l); + buf_to_pdfbuf_macro(static_pdf, buf.s, buf.l); + xfree(buf.s); + } else + luaL_error(L, "pdf.immediateobj() invalid argument"); + pdf_end_stream(static_pdf); + } + break; + default: + luaL_error(L, "pdf.immediateobj() allows max. 3 arguments"); + } + lua_pushinteger(L, k); return 1; } +/**********************************************************************/ +/* for LUA_ENVIRONINDEX table lookup (instead of repeated strcmp()) */ + +typedef enum { P__ZERO, + P_CATALOG, + P_H, + P_INFO, + P_NAMES, + P_PAGEATTRIBUTES, + P_PAGERESOURCES, + P_PAGESATTRIBUTES, + P_PDFCATALOG, + P_PDFINFO, + P_PDFNAMES, + P_PDFTRAILER, + P_RAW, + P_STREAM, + P_TRAILER, + P_V, + P__SENTINEL +} parm_idx; + +static const parm_struct pdf_parms[] = { + {NULL, P__ZERO}, /* dummy; lua indices run from 1 */ + {"catalog", P_CATALOG}, + {"h", P_H}, + {"info", P_INFO}, + {"names", P_NAMES}, + {"pageattributes", P_PAGEATTRIBUTES}, + {"pageresources", P_PAGERESOURCES}, + {"pagesattributes", P_PAGESATTRIBUTES}, + {"pdfcatalog", P_PDFCATALOG}, /* obsolescent */ + {"pdfinfo", P_PDFINFO}, /* obsolescent */ + {"pdfnames", P_PDFNAMES}, /* obsolescent */ + {"pdftrailer", P_PDFTRAILER}, /* obsolescent */ + {"raw", P_RAW}, + {"stream", P_STREAM}, + {"trailer", P_TRAILER}, + {"v", P_V}, + {NULL, P__SENTINEL} +}; + +/**********************************************************************/ + +static int table_obj(lua_State * L) +{ + int k, type; + int compress_level = -1; /* unset */ + int os_level = 1; /* default: put non-stream objects into object streams */ + int saved_compress_level = static_pdf->compress_level; + const_lstring attr, st; + lstring buf; + size_t i; + int immediate = 0; /* default: not immediate */ + attr.s = st.s = NULL; + attr.l = 0; + assert(lua_istable(L, 1)); /* t */ + + /* get object "type" */ + + lua_pushstring(L, "type"); /* ks t */ + lua_gettable(L, -2); /* vs? t */ + if (lua_isnil(L, -1)) /* !vs t */ + luaL_error(L, "pdf.obj(): object \"type\" missing"); + if (!lua_isstring(L, -1)) /* !vs t */ + luaL_error(L, "pdf.obj(): object \"type\" must be string"); + lua_pushvalue(L, -1); /* vs vs t */ + lua_gettable(L, LUA_ENVIRONINDEX); /* i? vs t */ + if (!lua_isnumber(L, -1)) /* !i vs t */ + luaL_error(L, "pdf.obj(): \"%s\" is not a valid object type", + lua_tostring(L, -2)); + type = (int) lua_tointeger(L, -1); /* i vs t */ + switch (type) { + case P_RAW: + case P_STREAM: + break; + default: + luaL_error(L, "pdf.obj(): \"%s\" is not a valid object type", lua_tostring(L, -2)); /* i vs t */ + } + lua_pop(L, 2); /* t */ + + /* get optional "immediate" */ + + lua_pushstring(L, "immediate"); /* ks t */ + lua_gettable(L, -2); /* b? t */ + if (!lua_isnil(L, -1)) { /* b? t */ + if (!lua_isboolean(L, -1)) /* !b t */ + luaL_error(L, "pdf.obj(): \"immediate\" must be boolean"); + immediate = lua_toboolean(L, -1); /* 0 or 1 */ + } + lua_pop(L, 1); /* t */ + + /* is a reserved object referenced by "objnum"? */ + + lua_pushstring(L, "objnum"); /* ks t */ + lua_gettable(L, -2); /* vi? t */ + if (!lua_isnil(L, -1)) { /* vi? t */ + if (!lua_isnumber(L, -1)) /* !vi t */ + luaL_error(L, "pdf.obj(): \"objnum\" must be integer"); + k = (int) lua_tointeger(L, -1); /* vi t */ + check_obj_exists(static_pdf, obj_type_obj, k); + if (is_obj_scheduled(static_pdf, k) || obj_data_ptr(static_pdf, k) != 0) + luaL_error(L, "pdf.obj() object in use"); + } else { + incr(static_pdf->obj_count); + pdf_create_obj(static_pdf, obj_type_obj, static_pdf->sys_obj_ptr + 1); + k = static_pdf->sys_obj_ptr; + } + pdf_last_obj = k; + if (immediate == 0) { + obj_data_ptr(static_pdf, k) = pdf_get_mem(static_pdf, pdfmem_obj_size); + init_obj_obj(static_pdf, k); + } + lua_pop(L, 1); /* t */ + + /* get optional "attr" (allowed only for stream case) */ + + lua_pushstring(L, "attr"); /* ks t */ + lua_gettable(L, -2); /* attr-s? t */ + if (!lua_isnil(L, -1)) { /* attr-s? t */ + if (type != P_STREAM) + luaL_error(L, + "pdf.obj(): \"attr\" key not allowed for non-stream object"); + if (!lua_isstring(L, -1)) /* !attr-s t */ + luaL_error(L, "pdf.obj(): object \"attr\" must be string"); + if (immediate == 1) { + attr.s = lua_tolstring(L, -1, &attr.l); /* attr-s t */ + lua_pop(L, 1); /* t */ + } else + obj_obj_stream_attr(static_pdf, k) = luaL_ref(Luas, LUA_REGISTRYINDEX); /* t */ + } else + lua_pop(L, 1); /* t */ + + /* get optional "compresslevel" (allowed only for stream case) */ + + lua_pushstring(L, "compresslevel"); /* ks t */ + lua_gettable(L, -2); /* vi? t */ + if (!lua_isnil(L, -1)) { /* vi? t */ + if (type == P_RAW) + luaL_error(L, + "pdf.obj(): \"compresslevel\" key not allowed for raw object"); + if (!lua_isnumber(L, -1)) /* !vi t */ + luaL_error(L, "pdf.obj(): \"compresslevel\" must be integer"); + compress_level = (int) lua_tointeger(L, -1); /* vi t */ + if (compress_level > 9) + luaL_error(L, "pdf.obj(): \"compresslevel\" must be <= 9"); + else if (compress_level < 0) + luaL_error(L, "pdf.obj(): \"compresslevel\" must be >= 0"); + if (immediate == 0) + obj_obj_pdfcompresslevel(static_pdf, k) = compress_level; + } + lua_pop(L, 1); /* t */ + + /* get optional "objcompression" (allowed only for non-stream case) */ + + lua_pushstring(L, "objcompression"); /* ks t */ + lua_gettable(L, -2); /* b? t */ + if (!lua_isnil(L, -1)) { /* b? t */ + if (type == P_STREAM) + luaL_error(L, + "pdf.obj(): \"objcompression\" key not allowed for stream object"); + if (!lua_isboolean(L, -1)) /* !b t */ + luaL_error(L, "pdf.obj(): \"objcompression\" must be boolean"); + os_level = lua_toboolean(L, -1); /* 0 or 1 */ + /* 0: never compress; 1: depends then on \pdfobjcompresslevel */ + if (immediate == 0) + obj_obj_pdfoslevel(static_pdf, k) = os_level; + } + lua_pop(L, 1); /* t */ + + /* now the object contents for all cases are handled */ + + lua_pushstring(L, "string"); /* ks t */ + lua_gettable(L, -2); /* string-s? t */ + lua_pushstring(L, "file"); /* ks string-s? t */ + lua_gettable(L, -3); /* file-s? string-s? t */ + if (!lua_isnil(L, -1) && !lua_isnil(L, -2)) /* file-s? string-s? t */ + luaL_error(L, + "pdf.obj(): \"string\" and \"file\" must not be given together"); + if (lua_isnil(L, -1) && lua_isnil(L, -2)) /* nil nil t */ + luaL_error(L, "pdf.obj(): no \"string\" or \"file\" given"); + + switch (type) { + case P_RAW: + if (immediate == 1) + pdf_begin_obj(static_pdf, k, os_level); + if (!lua_isnil(L, -2)) { /* file-s? string-s? t */ + /* from string */ + lua_pop(L, 1); /* string-s? t */ + if (!lua_isstring(L, -1)) /* !string-s t */ + luaL_error(L, + "pdf.obj(): \"string\" must be string for raw object"); + if (immediate == 1) { + st.s = lua_tolstring(L, -1, &st.l); + buf_to_pdfbuf_macro(static_pdf, st.s, st.l); + if (st.s[st.l - 1] != '\n') + pdf_puts(static_pdf, "\n"); + } else + obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); /* t */ + } else { + /* from file */ + if (!lua_isstring(L, -1)) /* !file-s nil t */ + luaL_error(L, + "pdf.obj(): \"file\" name must be string for raw object"); + if (immediate == 1) { + st.s = lua_tolstring(L, -1, &st.l); /* file-s nil t */ + buf.s = fread_to_buf(L, st.s, &buf.l); + buf_to_pdfbuf_macro(static_pdf, buf.s, buf.l); + if (buf.s[buf.l - 1] != '\n') + pdf_puts(static_pdf, "\n"); + xfree(buf.s); + } else { + set_obj_obj_is_file(static_pdf, k); + obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); /* nil t */ + } + } + if (immediate == 1) + pdf_end_obj(static_pdf); + break; + case P_STREAM: + if (immediate == 1) { + pdf_begin_dict(static_pdf, k, 0); /* 0 = not an object stream candidate! */ + if (attr.s != NULL) { + buf_to_pdfbuf_macro(static_pdf, attr.s, attr.l); + if (attr.s[attr.l - 1] != '\n') + pdf_puts(static_pdf, "\n"); + } + if (compress_level > -1) + static_pdf->compress_level = compress_level; + pdf_begin_stream(static_pdf); + } else { + set_obj_obj_is_stream(static_pdf, k); + if (compress_level > -1) + obj_obj_pdfcompresslevel(static_pdf, k) = compress_level; + } + if (!lua_isnil(L, -2)) { /* file-s? string-s? t */ + /* from string */ + lua_pop(L, 1); /* string-s? t */ + if (!lua_isstring(L, -1)) /* !string-s t */ + luaL_error(L, + "pdf.obj(): \"string\" must be string for stream object"); + if (immediate == 1) { + st.s = lua_tolstring(L, -1, &st.l); /* string-s t */ + buf_to_pdfbuf_macro(static_pdf, st.s, st.l); + } else + obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); /* t */ + } else { + /* from file */ + if (!lua_isstring(L, -1)) /* !file-s nil t */ + luaL_error(L, + "pdf.obj(): \"file\" name must be string for stream object"); + if (immediate == 1) { + st.s = lua_tolstring(L, -1, &st.l); /* file-s nil t */ + buf.s = fread_to_buf(L, st.s, &buf.l); + buf_to_pdfbuf_macro(static_pdf, buf.s, buf.l); + xfree(buf.s); + } else { + set_obj_obj_is_file(static_pdf, k); + obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); /* nil t */ + } + } + if (immediate == 1) + pdf_end_stream(static_pdf); + break; + default: + assert(0); + } + static_pdf->compress_level = saved_compress_level; + return k; +} + +static int orig_obj(lua_State * L) +{ + int n, first_arg = 1; + int k; + const_lstring st; + st.s = NULL; + n = lua_gettop(L); + if (n > 0 && lua_type(L, 1) == LUA_TNUMBER) { + first_arg++; + lua_number2int(k, lua_tonumber(L, 1)); + check_obj_exists(static_pdf, obj_type_obj, k); + if (is_obj_scheduled(static_pdf, k) || obj_data_ptr(static_pdf, k) != 0) + luaL_error(L, "pdf.obj() object in use"); + } else { + incr(static_pdf->obj_count); + pdf_create_obj(static_pdf, obj_type_obj, static_pdf->sys_obj_ptr + 1); + k = static_pdf->sys_obj_ptr; + } + pdf_last_obj = k; + obj_data_ptr(static_pdf, k) = pdf_get_mem(static_pdf, pdfmem_obj_size); + init_obj_obj(static_pdf, k); + switch (n - first_arg + 1) { + case 0: + luaL_error(L, "pdf.obj() needs at least one argument"); + break; + case 1: + if (!lua_isstring(L, first_arg)) + luaL_error(L, "pdf.obj() 1st argument must be string"); + break; + case 2: + case 3: + if (!lua_isstring(L, first_arg)) + luaL_error(L, "pdf.obj() 1st argument must be string"); + if (!lua_isstring(L, first_arg + 1)) + luaL_error(L, "pdf.obj() 2nd argument must be string"); + st.s = lua_tolstring(L, first_arg, &st.l); + if (st.l == 4 && strncmp((const char *) st.s, "file", 4) == 0) { + if (n == first_arg + 2) + luaL_error(L, "pdf.obj() 3rd argument forbidden in file mode"); + set_obj_obj_is_file(static_pdf, k); + } else { + if (n == first_arg + 2) { /* write attr text */ + if (!lua_isstring(L, -1)) + luaL_error(L, "pdf.obj() 3rd argument must be string"); + obj_obj_stream_attr(static_pdf, k) = + luaL_ref(Luas, LUA_REGISTRYINDEX); + } + if (st.l == 6 && strncmp((const char *) st.s, "stream", 6) == 0) { + set_obj_obj_is_stream(static_pdf, k); + } else if (st.l == 10 + && strncmp((const char *) st.s, "streamfile", 10) == 0) { + set_obj_obj_is_stream(static_pdf, k); + set_obj_obj_is_file(static_pdf, k); + } else + luaL_error(L, "pdf.obj() invalid argument"); + } + break; + default: + luaL_error(L, "pdf.obj() allows max. 3 arguments"); + } + obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); + return k; +} + +static int l_obj(lua_State * L) +{ + int n; + int k; + ensure_output_state(static_pdf, ST_HEADER_WRITTEN); + n = lua_gettop(L); + if (n == 1 && lua_istable(L, 1)) + k = table_obj(L); /* new */ + else + k = orig_obj(L); + lua_pushinteger(L, k); + return 1; +} + +static int l_reserveobj(lua_State * L) +{ + int n; + const_lstring st; + st.s = 0; + n = lua_gettop(L); + switch (n) { + case 0: + incr(static_pdf->obj_count); + pdf_create_obj(static_pdf, obj_type_obj, static_pdf->sys_obj_ptr + 1); + pdf_last_obj = static_pdf->sys_obj_ptr; + break; + case 1: + if (!lua_isstring(L, -1)) + luaL_error(L, "pdf.reserveobj() optional argument must be string"); + st.s = lua_tolstring(L, 1, &st.l); + if (st.l == 5 && strncmp((const char *) st.s, "annot", 5) == 0) { + pdf_create_obj(static_pdf, obj_type_annot, 0); + pdf_last_annot = static_pdf->sys_obj_ptr; + } else { + luaL_error(L, "pdf.reserveobj() optional string must be \"annot\""); + } + lua_pop(L, 1); + break; + default: + luaL_error(L, "pdf.reserveobj() allows max. 1 argument"); + } + lua_pushinteger(L, static_pdf->obj_ptr); + return 1; +} + +static int l_registerannot(lua_State * L) +{ + int n, i; + n = lua_gettop(L); + switch (n) { + case 1: + if (!is_shipping_page) + luaL_error(L, "pdf.registerannot() can only be used in late lua"); + i = (int) luaL_checkinteger(L, 1); + if (i <= 0) + luaL_error(L, + "pdf.registerannot() can only register positive object numbers"); + addto_page_resources(static_pdf, obj_type_annot, -i); + break; + default: + luaL_error(L, "pdf.registerannot() needs exactly 1 argument"); + } + return 0; +} + static int getpdf(lua_State * L) { + char *s; const char *st; - if (lua_isstring(L, 2)) { - st = lua_tostring(L, 2); - if (st && *st) { - if (*st == 'h') - return findcurh(L); - else if (*st == 'v') - return findcurv(L); + int i, l; + if (lua_isstring(L, 2) && (st = lua_tostring(L, 2)) != NULL) { + lua_pushvalue(L, 2); /* st ... */ + lua_gettable(L, LUA_ENVIRONINDEX); /* i? ... */ + if (lua_isnumber(L, -1)) { /* i ... */ + i = (int) lua_tointeger(L, -1); /* i ... */ + lua_pop(L, 1); /* ... */ + switch (i) { + case P_PAGEATTRIBUTES: + s = tokenlist_to_cstring(pdf_pageattributes_toks, true, &l); + lua_pushlstring(L, s, (size_t) l); + break; + case P_PAGERESOURCES: + s = tokenlist_to_cstring(pdf_pageresources_toks, true, &l); + lua_pushlstring(L, s, (size_t) l); + break; + case P_PAGESATTRIBUTES: + s = tokenlist_to_cstring(pdf_pagesattributes_toks, true, &l); + lua_pushlstring(L, s, (size_t) l); + break; + case P_PDFCATALOG: + case P_CATALOG: + s = tokenlist_to_cstring(pdf_catalog_toks, true, &l); + lua_pushlstring(L, s, (size_t) l); + break; + case P_PDFINFO: + case P_INFO: + s = tokenlist_to_cstring(pdf_info_toks, true, &l); + lua_pushlstring(L, s, (size_t) l); + break; + case P_PDFNAMES: + case P_NAMES: + s = tokenlist_to_cstring(pdf_names_toks, true, &l); + lua_pushlstring(L, s, (size_t) l); + break; + case P_PDFTRAILER: + case P_TRAILER: + s = tokenlist_to_cstring(pdf_trailer_toks, true, &l); + lua_pushlstring(L, s, (size_t) l); + break; + case P_H: + lua_pushnumber(L, static_pdf->posstruct->pos.h); + break; + case P_V: + lua_pushnumber(L, static_pdf->posstruct->pos.v); + break; + default: + lua_rawget(L, -2); + } + } else { + lua_pop(L, 1); /* ... */ + lua_rawget(L, -2); } + } else { + lua_pushnil(L); } - lua_pushnil(L); return 1; } static int setpdf(lua_State * L) { - return (L == NULL ? 0 : 0); /* for -Wall */ + int i; + if (lua_gettop(L) != 3) { + return 0; + } + (void) luaL_checkstring(L, 2); /* ... */ + lua_pushvalue(L, 2); /* st ... */ + lua_gettable(L, LUA_ENVIRONINDEX); /* i? ... */ + if (lua_isnumber(L, -1)) { /* i ... */ + i = (int) lua_tointeger(L, -1); /* i ... */ + lua_pop(L, 1); /* ... */ + switch (i) { + case P_PAGEATTRIBUTES: + pdf_pageattributes_toks = tokenlist_from_lua(L); + break; + case P_PAGERESOURCES: + pdf_pageresources_toks = tokenlist_from_lua(L); + break; + case P_PAGESATTRIBUTES: + pdf_pagesattributes_toks = tokenlist_from_lua(L); + break; + case P_PDFCATALOG: + case P_CATALOG: + pdf_catalog_toks = tokenlist_from_lua(L); + break; + case P_PDFINFO: + case P_INFO: + pdf_info_toks = tokenlist_from_lua(L); + break; + case P_PDFNAMES: + case P_NAMES: + pdf_names_toks = tokenlist_from_lua(L); + break; + case P_PDFTRAILER: + case P_TRAILER: + pdf_trailer_toks = tokenlist_from_lua(L); + break; + case P_H: + case P_V: + /* can't set |h| and |v| yet */ + default: + lua_rawset(L, -3); + } + } else { + lua_pop(L, 1); /* ... */ + lua_rawset(L, -3); + } + return 0; +} + +static int l_mapfile(lua_State * L) +{ + char *s; + const char *st; + if (lua_isstring(L, -1) && (st = lua_tostring(L, -1)) != NULL) { + s = xstrdup(st); + process_map_item(s, MAPFILE); + free(s); + } + return 0; +} + +static int l_mapline(lua_State * L) +{ + char *s; + const char *st; + if (lua_isstring(L, -1) && (st = lua_tostring(L, -1)) != NULL) { + s = xstrdup(st); + process_map_item(s, MAPLINE); + free(s); + } + return 0; +} + +static int l_pdfmapfile(lua_State * L) +{ + luaL_error(L, "pdf.pdfmapfile() is obsolete. Use pdf.mapfile() instead."); + return 0; +} + +static int l_pdfmapline(lua_State * L) +{ + luaL_error(L, "pdf.pdfmapline() is obsolete. Use pdf.mapline() instead."); + return 0; } static const struct luaL_reg pdflib[] = { - {"print", luapdfprint}, {"immediateobj", l_immediateobj}, + {"mapfile", l_mapfile}, + {"mapline", l_mapline}, + {"obj", l_obj}, + {"pdfmapfile", l_pdfmapfile}, /* obsolete */ + {"pdfmapline", l_pdfmapline}, /* obsolete */ + {"print", luapdfprint}, + {"registerannot", l_registerannot}, + {"reserveobj", l_reserveobj}, {NULL, NULL} /* sentinel */ }; +/**********************************************************************/ int luaopen_pdf(lua_State * L) { + preset_environment(L, pdf_parms); luaL_register(L, "pdf", pdflib); /* build meta table */ luaL_newmetatable(L, "pdf_meta"); lua_pushstring(L, "__index"); lua_pushcfunction(L, getpdf); /* do these later, NYI */ - if (0) { - lua_settable(L, -3); - lua_pushstring(L, "__newindex"); - lua_pushcfunction(L, setpdf); - } + lua_settable(L, -3); + lua_pushstring(L, "__newindex"); + lua_pushcfunction(L, setpdf); lua_settable(L, -3); lua_setmetatable(L, -2); /* meta to itself */ return 1; diff --git a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c index 1f264cd55bb..4d233c43e4a 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c @@ -1,6 +1,6 @@ /* lstatslib.c - Copyright 2006-2008 Taco Hoekwater + Copyright 2006-2009 Taco Hoekwater This file is part of LuaTeX. @@ -17,13 +17,12 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include -#include "inc-extra.h" - - static const char _svn_version[] = - "$Id: lstatslib.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/lstatslib.c $"; + "$Id: lstatslib.c 3477 2010-03-12 13:59:34Z taco $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/lstatslib.c $"; + +#include "lua/luatex-api.h" +#include "ptexlib.h" typedef struct statistic { const char *name; @@ -32,48 +31,147 @@ typedef struct statistic { } statistic; typedef const char *(*charfunc) (void); -typedef integer(*intfunc) (void); +typedef lua_Number(*numfunc) (void); +typedef int (*intfunc) (void); static const char *getbanner(void) { - return ptexbanner; + return (const char *) ptexbanner; +} + +static const char *getlogname(void) +{ + return (const char *) texmf_log_name; +} + +static const char *get_pdftex_banner(void) +{ + return (const char *) pdftex_banner; +} + +static const char *get_output_file_name(void) +{ + if (static_pdf != NULL) + return (const char *) static_pdf->file_name; + return NULL; +} + +static const char *getfilename(void) +{ + int t = 0; + int level = in_open; + while ((level > 0)) { + t = input_stack[level--].name_field; + if (t >= STRING_OFFSET) + return (const char *) str_string(t); + } + return ""; +} + +static const char *getlasterror(void) +{ + return last_error; +} + +static const char *luatexrevision(void) +{ + return (const char *) (strrchr(luatex_version_string, '.') + 1); +} + +static lua_Number get_pdf_gone(void) +{ + if (static_pdf != NULL) + return (lua_Number) static_pdf->gone; + return (lua_Number) 0; } -/* hack, I really should implement the makecstring */ -static char *getfilename(void) +static lua_Number get_pdf_ptr(void) { - integer t; - t = get_current_name(); - if (t > (1 << 21)) - return makecstring(t); - else - return xstrdup(""); + if (static_pdf != NULL) + return (lua_Number) static_pdf->ptr; + return (lua_Number) 0; } -static char *getlasterror(void) +static lua_Number get_pdf_os_cntr(void) { - return makecstring(last_error); + if (static_pdf != NULL) + return (lua_Number) static_pdf->os_cntr; + return (lua_Number) 0; } -static char *luatexrevision(void) +static lua_Number get_pdf_os_objidx(void) { - return makecstring(get_luatexrevision()); + if (static_pdf != NULL) + return (lua_Number) static_pdf->os_idx; + return (lua_Number) 0; +} + +static lua_Number get_pdf_mem_size(void) +{ + if (static_pdf != NULL) + return (lua_Number) static_pdf->mem_size; + return (lua_Number) 0; +} + +static lua_Number get_pdf_mem_ptr(void) +{ + if (static_pdf != NULL) + return (lua_Number) static_pdf->mem_ptr; + return (lua_Number) 0; +} + + +static lua_Number get_obj_ptr(void) +{ + if (static_pdf != NULL) + return (lua_Number) static_pdf->obj_ptr; + return (lua_Number) 0; +} + +static lua_Number get_obj_tab_size(void) +{ + if (static_pdf != NULL) + return (lua_Number) static_pdf->obj_tab_size; + return (lua_Number) 0; +} + +static lua_Number get_dest_names_size(void) +{ + if (static_pdf != NULL) + return (lua_Number) static_pdf->dest_names_size; + return (lua_Number) 0; +} + +static lua_Number get_dest_names_ptr(void) +{ + if (static_pdf != NULL) + return (lua_Number) static_pdf->dest_names_ptr; + return (lua_Number) 0; +} + +static int get_hash_size(void) +{ + return hash_size; /* is a #define */ } static int luastate_max = 1; /* fixed value */ +/* temp, for backward compat */ +static int init_pool_ptr = 0; + static struct statistic stats[] = { - {"pdf_gone", 'g', &pdf_gone}, - {"pdf_ptr", 'g', &pdf_ptr}, + {"pdf_gone", 'N', &get_pdf_gone}, + {"pdf_ptr", 'N', &get_pdf_ptr}, {"dvi_gone", 'g', &dvi_offset}, {"dvi_ptr", 'g', &dvi_ptr}, {"total_pages", 'g', &total_pages}, - {"output_file_name", 's', &output_file_name}, - {"log_name", 's', &texmf_log_name}, /* weird */ - {"banner", 'S', &getbanner}, - {"pdftex_banner", 's', &pdftex_banner}, + {"output_file_name", 'S', (void *) &get_output_file_name}, + {"log_name", 'S', (void *) &getlogname}, + {"banner", 'S', (void *) &getbanner}, + {"pdftex_banner", 'S', (void *) &get_pdftex_banner}, + {"luatex_svn", 'G', &get_luatexsvn}, {"luatex_version", 'G', &get_luatexversion}, - {"luatex_revision", 'S', &luatexrevision}, + {"luatex_revision", 'S', (void *) &luatexrevision}, {"ini_version", 'b', &ini_version}, /* * mem stat @@ -86,7 +184,7 @@ static struct statistic stats[] = { {"str_ptr", 'g', &str_ptr}, {"init_str_ptr", 'g', &init_str_ptr}, {"max_strings", 'g', &max_strings}, - {"pool_ptr", 'g', &pool_ptr}, + {"pool_ptr", 'g', &pool_size}, {"init_pool_ptr", 'g', &init_pool_ptr}, {"pool_size", 'g', &pool_size}, {"var_mem_max", 'g', &var_mem_max}, @@ -109,21 +207,21 @@ static struct statistic stats[] = { {"buf_size", 'g', &buf_size}, {"save_size", 'g', &save_size}, /* pdf stats */ - {"obj_ptr", 'g', &obj_ptr}, - {"obj_tab_size", 'g', &obj_tab_size}, - {"pdf_os_cntr", 'g', &pdf_os_cntr}, - {"pdf_os_objidx", 'g', &pdf_os_objidx}, - {"pdf_dest_names_ptr", 'g', &pdf_dest_names_ptr}, - {"dest_names_size", 'g', &dest_names_size}, - {"pdf_mem_ptr", 'g', &pdf_mem_ptr}, - {"pdf_mem_size", 'g', &pdf_mem_size}, + {"obj_ptr", 'N', &get_obj_ptr}, + {"obj_tab_size", 'N', &get_obj_tab_size}, + {"pdf_os_cntr", 'N', &get_pdf_os_cntr}, + {"pdf_os_objidx", 'N', &get_pdf_os_objidx}, + {"pdf_dest_names_ptr", 'N', &get_dest_names_ptr}, + {"dest_names_size", 'N', &get_dest_names_size}, + {"pdf_mem_ptr", 'N', &get_pdf_mem_ptr}, + {"pdf_mem_size", 'N', &get_pdf_mem_size}, {"largest_used_mark", 'g', &biggest_used_mark}, - {"filename", 'S', &getfilename}, - {"inputid", 'G', &get_current_name}, + {"filename", 'S', (void *) &getfilename}, + {"inputid", 'g', &(iname)}, {"linenumber", 'g', &line}, - {"lasterrorstring", 'S', &getlasterror}, + {"lasterrorstring", 'S', (void *) &getlasterror}, {"luabytecodes", 'g', &luabytecode_max}, {"luabytecode_bytes", 'g', &luabytecode_bytes}, @@ -137,7 +235,6 @@ static struct statistic stats[] = { {NULL, 0, 0} }; - static int stats_name_to_id(const char *name) { int i; @@ -154,6 +251,7 @@ static int do_getstat(lua_State * L, int i) const char *st; charfunc f; intfunc g; + numfunc n; int str; t = stats[i].type; switch (t) { @@ -163,19 +261,25 @@ static int do_getstat(lua_State * L, int i) lua_pushstring(L, st); break; case 's': - str = *(integer *) (stats[i].value); + str = *(int *) (stats[i].value); if (str) { - lua_pushstring(L, makecstring(str)); + char *ss = makecstring(str); + lua_pushstring(L, ss); + free(ss); } else { lua_pushnil(L); } break; + case 'N': + n = stats[i].value; + lua_pushnumber(L, n()); + break; case 'G': g = stats[i].value; lua_pushnumber(L, g()); break; case 'g': - lua_pushnumber(L, *(integer *) (stats[i].value)); + lua_pushnumber(L, *(int *) (stats[i].value)); break; case 'B': g = stats[i].value; @@ -188,7 +292,7 @@ static int do_getstat(lua_State * L, int i) lua_pushnil(L); break; case 'b': - lua_pushboolean(L, *(integer *) (stats[i].value)); + lua_pushboolean(L, *(int *) (stats[i].value)); break; default: lua_pushnil(L); diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c b/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c index 458b4e240bc..79f92f83d53 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c @@ -1,6 +1,6 @@ /* ltexiolib.c - Copyright 2006-2008 Taco Hoekwater + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,17 +17,17 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include +#include "lua/luatex-api.h" +#include "ptexlib.h" static const char _svn_version[] = - "$Id: ltexiolib.c 2321 2009-04-18 09:17:13Z hhenkel $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/ltexiolib.c $"; + "$Id: ltexiolib.c 3550 2010-03-26 14:37:09Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/ltexiolib.c $"; -typedef void (*texio_printer) (str_number s); +typedef void (*texio_printer) (const char *); static char *loggable_info = NULL; -static boolean get_selector_value(lua_State * L, int i, char *l) +static boolean get_selector_value(lua_State * L, int i, int *l) { boolean r = false; if (lua_isstring(L, i)) { @@ -43,24 +43,19 @@ static boolean get_selector_value(lua_State * L, int i, char *l) r = true; } } else { - lua_pushstring(L, "first argument is not a string"); - lua_error(L); + luaL_error(L, "first argument is not a string"); } return r; } static int do_texio_print(lua_State * L, texio_printer printfunction) { - str_number texs; const char *s; - size_t k; int i = 1; - str_number u = 0; - char save_selector = selector; + int save_selector = selector; int n = lua_gettop(L); if (n == 0 || !lua_isstring(L, -1)) { - lua_pushstring(L, "no string to print"); - lua_error(L); + luaL_error(L, "no string to print"); } if (n > 1) { if (get_selector_value(L, i, &selector)) @@ -70,23 +65,15 @@ static int do_texio_print(lua_State * L, texio_printer printfunction) && selector != term_and_log) { normalize_selector(); /* sets selector */ } - /* just in case there is a string in progress */ - if (str_start[str_ptr - 0x200000] < pool_ptr) - u = make_string(); for (; i <= n; i++) { if (lua_isstring(L, i)) { - s = lua_tolstring(L, i, &k); - texs = maketexlstring(s, k); - printfunction(texs); - flush_str(texs); + s = lua_tostring(L, i); + printfunction(s); } else { - lua_pushstring(L, "argument is not a string"); - lua_error(L); + luaL_error(L, "argument is not a string"); } } selector = save_selector; - if (u != 0) - str_ptr--; return 0; } @@ -94,7 +81,7 @@ static void do_texio_ini_print(lua_State * L, const char *extra) { const char *s; int i = 1; - char l = term_and_log; + int l = term_and_log; int n = lua_gettop(L); if (n > 1) { if (get_selector_value(L, i, &l)) @@ -120,20 +107,20 @@ static void do_texio_ini_print(lua_State * L, const char *extra) static int texio_print(lua_State * L) { - if (ready_already != 314159 || pool_ptr == 0 || job_name == 0) { + if (ready_already != 314159 || job_name == 0) { do_texio_ini_print(L, ""); return 0; } - return do_texio_print(L, zprint); + return do_texio_print(L, tprint); } static int texio_printnl(lua_State * L) { - if (ready_already != 314159 || pool_ptr == 0 || job_name == 0) { + if (ready_already != 314159 || job_name == 0) { do_texio_ini_print(L, "\n"); return 0; } - return do_texio_print(L, zprint_nl); + return do_texio_print(L, tprint_nl); } /* at the point this function is called, the selector is log_only */ diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c index 82a54cc35bc..fa0544a1853 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -1,6 +1,6 @@ /* ltexlib.c - Copyright 2006-2009 Taco Hoekwater + Copyright 2006-2010 Taco Hoekwater This file is part of LuaTeX. @@ -17,22 +17,29 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include -#include "nodes.h" -#include "inc-extra.h" -#include "commands.h" -#include "tokens.h" +#include "lua/luatex-api.h" +#include "ptexlib.h" + + static const char _svn_version[] = - "$Id: ltexlib.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/ltexlib.c $"; + "$Id: ltexlib.c 3550 2010-03-26 14:37:09Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/ltexlib.c $"; + +#define attribute(A) eqtb[attribute_base+(A)].hh.rh +#define dimen(A) eqtb[scaled_base+(A)].hh.rh +#undef skip +#define skip(A) eqtb[skip_base+(A)].hh.rh +#define mu_skip(A) eqtb[mu_skip_base+(A)].hh.rh +#define count(A) eqtb[count_base+(A)].hh.rh +#define box(A) equiv(box_base+(A)) + typedef struct { char *text; unsigned int tsize; void *next; boolean partial; - integer cattable; + int cattable; } rope; typedef struct { @@ -51,20 +58,20 @@ static int spindle_size = 0; static spindle *spindles = NULL; static int spindle_index = 0; -static void luac_store(lua_State * L, int i, int partial, integer cattable) +static void luac_store(lua_State * L, int i, int partial, int cattable) { char *st; const char *sttemp; size_t tsize; rope *rn = NULL; sttemp = lua_tolstring(L, i, &tsize); - st = xmalloc((tsize + 1)); + st = xmalloc((unsigned) (tsize + 1)); memcpy(st, sttemp, (tsize + 1)); if (st) { luacstrings++; rn = (rope *) xmalloc(sizeof(rope)); rn->text = st; - rn->tsize = tsize; + rn->tsize = (unsigned) tsize; rn->partial = partial; rn->cattable = cattable; rn->next = NULL; @@ -83,12 +90,12 @@ static void luac_store(lua_State * L, int i, int partial, integer cattable) static int do_luacprint(lua_State * L, int partial, int deftable) { int i, n; - integer cattable = (integer) deftable; + int cattable = deftable; int startstrings = 1; n = lua_gettop(L); if (cattable != NO_CAT_TABLE) { if (lua_type(L, 1) == LUA_TNUMBER && n > 1) { - cattable = lua_tonumber(L, 1); + lua_number2int(cattable, lua_tonumber(L, 1)); startstrings = 2; } } @@ -105,8 +112,7 @@ static int do_luacprint(lua_State * L, int partial, int deftable) } else { for (i = startstrings; i <= n; i++) { if (!lua_isstring(L, i)) { - lua_pushstring(L, "no string to print"); - lua_error(L); + luaL_error(L, "no string to print"); } luac_store(L, i, partial, cattable); } @@ -114,24 +120,61 @@ static int do_luacprint(lua_State * L, int partial, int deftable) return 0; } -static int luacwrite(lua_State * L) +int luacwrite(lua_State * L) { return do_luacprint(L, FULL_LINE, NO_CAT_TABLE); } -static int luacprint(lua_State * L) +int luacprint(lua_State * L) { return do_luacprint(L, FULL_LINE, DEFAULT_CAT_TABLE); } -static int luacsprint(lua_State * L) +int luacsprint(lua_State * L) { return do_luacprint(L, PARTIAL_LINE, DEFAULT_CAT_TABLE); } -integer luacstring_cattable(void) +int luactprint(lua_State * L) { - return (integer) read_spindle.tail->cattable; + int i, j, n; + int cattable, startstrings; + n = lua_gettop(L); + for (i = 1; i <= n; i++) { + cattable = DEFAULT_CAT_TABLE; + startstrings = 1; + if (lua_type(L, i) != LUA_TTABLE) { + luaL_error(L, "no string to print"); + } + lua_pushvalue(L, i); /* push the table */ + lua_pushnumber(L, 1); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_number2int(cattable, lua_tonumber(L, -1)); + startstrings = 2; + } + lua_pop(L, 1); + + for (j = startstrings;; j++) { + lua_pushnumber(L, j); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + luac_store(L, -1, PARTIAL_LINE, cattable); + lua_pop(L, 1); + } else { + lua_pop(L, 1); + break; + } + } + lua_pop(L, 1); /* pop the table */ + } + return 0; +} + + +int luacstring_cattable(void) +{ + return (int) read_spindle.tail->cattable; } int luacstring_partial(void) @@ -164,11 +207,10 @@ int luacstring_input(void) /* put that thing in the buffer */ last = first; ret = last; - check_buffer_overflow(last + t->tsize); - /* make sure it fits in the pool as well (for show_token_list c.s) */ - check_pool_overflow(pool_ptr + t->tsize); + check_buffer_overflow(last + (int) t->tsize); + while (t->tsize-- > 0) - buffer[last++] = *st++; + buffer[last++] = (packed_ASCII_code) * st++; if (!t->partial) { while (last - 1 > ret && buffer[last - 1] == ' ') last--; @@ -190,7 +232,10 @@ void luacstring_start(int n) (void) n; /* for -W */ spindle_index++; if (spindle_size == spindle_index) { /* add a new one */ - spindles = xrealloc(spindles, sizeof(spindle) * (spindle_size + 1)); + spindles = + xrealloc(spindles, + (unsigned) (sizeof(spindle) * + (unsigned) (spindle_size + 1))); spindles[spindle_index].head = NULL; spindles[spindle_index].tail = NULL; spindles[spindle_index].complete = 0; @@ -222,70 +267,330 @@ void luacstring_close(int n) /* local (static) versions */ -#define width_offset 1 -#define depth_offset 2 -#define height_offset 3 - #define check_index_range(j,s) \ if (j<0 || j > 65535) { \ - lua_pushfstring(L, "incorrect index value %d for tex.%s()", (int)j, s); \ - lua_error(L); } + luaL_error(L, "incorrect index value %d for tex.%s()", (int)j, s); } + + +static const char *scan_integer_part(lua_State * L, const char *ss, int *ret, + int *radix_ret) +{ + boolean negative = false; /* should the answer be negated? */ + int m; /* |$2^{31}$ / radix|, the threshold of danger */ + int d; /* the digit just scanned */ + boolean vacuous; /* have no digits appeared? */ + boolean OK_so_far; /* has an error message been issued? */ + int radix = 0; /* the radix of the integer */ + int c = 0; /* the current character */ + const char *s; /* where we stopped in the string |ss| */ + integer cur_val = 0; /* return value */ + s = ss; + do { + do { + c = *s++; + } while (c && c == ' '); + if (c == '-') { + negative = !negative; + c = '+'; + } + } while (c == '+'); + + + radix = 10; + m = 214748364; + if (c == '\'') { + radix = 8; + m = 02000000000; + c = *s++; + } else if (c == '"') { + radix = 16; + m = 01000000000; + c = *s++; + } + vacuous = true; + cur_val = 0; + OK_so_far = true; + + /* Accumulate the constant until |cur_tok| is not a suitable digit */ + while (1) { + if ((c < '0' + radix) && (c >= '0') && (c <= '0' + 9)) { + d = c - '0'; + } else if (radix == 16) { + if ((c <= 'A' + 5) && (c >= 'A')) { + d = c - 'A' + 10; + } else if ((c <= 'a' + 5) && (c >= 'a')) { + d = c - 'a' + 10; + } else { + break; + } + } else { + break; + } + vacuous = false; + if ((cur_val >= m) && ((cur_val > m) || (d > 7) || (radix != 10))) { + if (OK_so_far) { + luaL_error(L, "Number too big"); + cur_val = infinity; + OK_so_far = false; + } + } else { + cur_val = cur_val * radix + d; + } + c = *s++; + } + if (vacuous) { + /* Express astonishment that no number was here */ + luaL_error(L, "Missing number, treated as zero"); + } + if (negative) + cur_val = -cur_val; + *ret = cur_val; + *radix_ret = radix; + if (c != ' ' && s > ss) + s--; + return s; +} + +#define set_conversion(A,B) do { num=(A); denom=(B); } while(0) + + +static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) +/* sets |cur_val| to a dimension */ +{ + boolean negative = false; /* should the answer be negated? */ + int f = 0; /* numerator of a fraction whose denominator is $2^{16}$ */ + int num, denom; /* conversion ratio for the scanned units */ + int k; /* number of digits in a decimal fraction */ + scaled v; /* an internal dimension */ + int save_cur_val; /* temporary storage of |cur_val| */ + int arith_error = false; + int c; /* the current character */ + const char *s = ss; /* where we are in the string */ + int radix = 0; /* the current radix */ + int rdig[18]; /* to save the |dig[]| array */ + int saved_tex_remainder; /* to save |tex_remainder| */ + int saved_arith_error; /* to save |arith_error| */ + int saved_cur_val; /* to save the global |cur_val| */ + saved_tex_remainder = tex_remainder; + saved_arith_error = arith_error; + saved_cur_val = cur_val; + /* Get the next non-blank non-sign... */ + do { + /* Get the next non-blank non-call token */ + do { + c = *s++; + } while (c && c == ' '); + if (c == '-') { + negative = !negative; + c = '+'; + } + } while (c == '+'); + if (c == ',') { + c = '.'; + } + if (c != '.') { + s = scan_integer_part(L, (s > ss ? (s - 1) : ss), &cur_val, &radix); + c = *s; + } else { + radix = 10; + cur_val = 0; + c = *(--s); + } + if (c == ',') + c = '.'; + if ((radix == 10) && (c == '.')) { + /* Scan decimal fraction */ + for (k = 0; k < 18; k++) + rdig[k] = dig[k]; + k = 0; + s++; /* get rid of the '.' */ + while (1) { + c = *s++; + if ((c > '0' + 9) || (c < '0')) + break; + if (k < 17) { /* digits for |k>=17| cannot affect the result */ + dig[k++] = c - '0'; + } + } + f = round_decimals(k); + if (c != ' ') + c = *(--s); + for (k = 0; k < 18; k++) + dig[k] = rdig[k]; + } + if (cur_val < 0) { /* in this case |f=0| */ + negative = !negative; + cur_val = -cur_val; + } + + /* Scan for (u)units that are internal dimensions; + |goto attach_sign| with |cur_val| set if found */ + save_cur_val = cur_val; + /* Get the next non-blank non-call... */ + do { + c = *s++; + } while (c && c == ' '); + if (c != ' ') + c = *(--s); + if (strncmp(s, "em", 2) == 0) { + s += 2; + v = (quad(get_cur_font())); + } else if (strncmp(s, "ex", 2) == 0) { + s += 2; + v = (x_height(get_cur_font())); + } else if (strncmp(s, "px", 2) == 0) { + s += 2; + v = dimen_par(pdf_px_dimen_code); + } else { + goto NOT_FOUND; + } + c = *s++; + if (c != ' ') { + c = *(--s); + } + cur_val = nx_plus_y(save_cur_val, v, xn_over_d(v, f, 0200000)); + goto ATTACH_SIGN; + NOT_FOUND: + + /* Scan for (m)\.{mu} units and |goto attach_fraction| */ + if (strncmp(s, "mu", 2) == 0) { + s += 2; + goto ATTACH_FRACTION; + } + if (strncmp(s, "true", 4) == 0) { + /* Adjust (f)for the magnification ratio */ + s += 4; + prepare_mag(); + if (int_par(mag_code) != 1000) { + cur_val = xn_over_d(cur_val, 1000, int_par(mag_code)); + f = (1000 * f + 0200000 * tex_remainder) / int_par(mag_code); + cur_val = cur_val + (f / 0200000); + f = f % 0200000; + } + do { + c = *s++; + } while (c && c == ' '); + c = *(--s); + } + if (strncmp(s, "pt", 2) == 0) { + s += 2; + goto ATTACH_FRACTION; /* the easy case */ + } + /* Scan for (a)all other units and adjust |cur_val| and |f| accordingly; + |goto done| in the case of scaled points */ + + if (strncmp(s, "in", 2) == 0) { + s += 2; + set_conversion(7227, 100); + } else if (strncmp(s, "pc", 2) == 0) { + s += 2; + set_conversion(12, 1); + } else if (strncmp(s, "cm", 2) == 0) { + s += 2; + set_conversion(7227, 254); + } else if (strncmp(s, "mm", 2) == 0) { + s += 2; + set_conversion(7227, 2540); + } else if (strncmp(s, "bp", 2) == 0) { + s += 2; + set_conversion(7227, 7200); + } else if (strncmp(s, "dd", 2) == 0) { + s += 2; + set_conversion(1238, 1157); + } else if (strncmp(s, "cc", 2) == 0) { + s += 2; + set_conversion(14856, 1157); + } else if (strncmp(s, "nd", 2) == 0) { + s += 2; + set_conversion(685, 642); + } else if (strncmp(s, "nc", 2) == 0) { + s += 2; + set_conversion(1370, 107); + } else if (strncmp(s, "sp", 2) == 0) { + s += 2; + goto DONE; + } else { + /* Complain about unknown unit and |goto done2| */ + luaL_error(L, "Illegal unit of measure (pt inserted)"); + goto DONE2; + } + cur_val = xn_over_d(cur_val, num, denom); + f = (num * f + 0200000 * tex_remainder) / denom; + cur_val = cur_val + (f / 0200000); + f = f % 0200000; + DONE2: + ATTACH_FRACTION: + if (cur_val >= 040000) + arith_error = true; + else + cur_val = cur_val * 65536 + f; + DONE: + /* Scan an optional space */ + c = *s++; + if (c != ' ') + s--; + ATTACH_SIGN: + if (arith_error || (abs(cur_val) >= 010000000000)) { + /* Report that this dimension is out of range */ + luaL_error(L, "Dimension too large"); + cur_val = max_dimen; + } + if (negative) + cur_val = -cur_val; + *ret = cur_val; + tex_remainder = saved_tex_remainder; + arith_error = saved_arith_error; + cur_val = saved_cur_val; + return s; +} int dimen_to_number(lua_State * L, const char *s) { - double v; - char *d; - int j; - v = strtod(s, &d); - if (strcmp(d, "in") == 0) { - j = (int) (((v * 7227) / 100) * 65536); - } else if (strcmp(d, "pc") == 0) { - j = (int) ((v * 12) * 65536); - } else if (strcmp(d, "cm") == 0) { - j = (int) (((v * 7227) / 254) * 65536); - } else if (strcmp(d, "mm") == 0) { - j = (int) (((v * 7227) / 2540) * 65536); - } else if (strcmp(d, "bp") == 0) { - j = (int) (((v * 7227) / 7200) * 65536); - } else if (strcmp(d, "dd") == 0) { - j = (int) (((v * 1238) / 1157) * 65536); - } else if (strcmp(d, "cc") == 0) { - j = (int) (((v * 14856) / 1157) * 65536); - } else if (strcmp(d, "nd") == 0) { - j = (int) (((v * 21681) / 20320) * 65536); - } else if (strcmp(d, "nc") == 0) { - j = (int) (((v * 65043) / 5080) * 65536); - } else if (strcmp(d, "pt") == 0) { - j = (int) (v * 65536); - } else if (strcmp(d, "sp") == 0) { - j = (int) (v); - } else { - lua_pushstring(L, "unknown dimension specifier"); - lua_error(L); + int j = 0; + const char *d = scan_dimen_part(L, s, &j); + if (*d) { + luaL_error(L, "conversion failed (trailing junk?)"); j = 0; } return j; } -static integer get_item_index(lua_State * L, int i, integer base) +static int tex_scaledimen(lua_State * L) +{ /* following vsetdimen() */ + int sp; + if (!lua_isnumber(L, 1)) { + if (lua_isstring(L, 1)) { + sp = dimen_to_number(L, lua_tostring(L, 1)); + } else { + luaL_error(L, "argument must be a string or a number"); + return 0; + } + } else { + lua_number2int(sp, lua_tonumber(L, 1)); + } + lua_pushnumber(L, sp); + return 1; +} + + +int get_item_index(lua_State * L, int i, int base) { size_t kk; - integer k; + int k; int cur_cs; const char *s; if (lua_type(L, i) == LUA_TSTRING) { s = lua_tolstring(L, i, &kk); cur_cs = string_lookup(s, kk); - if (cur_cs == static_undefined_control_sequence || - is_undefined_cs(cur_cs)) { + if (cur_cs == undefined_control_sequence || cur_cs == undefined_cs_cmd) { k = -1; /* guarandeed invalid */ } else { - k = (zget_equiv(cur_cs) - base); + k = (equiv(cur_cs) - base); } } else { - k = (integer) luaL_checkinteger(L, i); + k = (int) luaL_checkinteger(L, i); } return k; } @@ -294,28 +599,28 @@ static integer get_item_index(lua_State * L, int i, integer base) static int vsetdimen(lua_State * L, int is_global) { int i, j, err; - integer k; - integer save_global_defs = int_par(param_global_defs_code); + int k; + int save_global_defs = int_par(global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(global_defs_code) = 1; i = lua_gettop(L); j = 0; /* find the value */ - if (!lua_isnumber(L, i)) + if (!lua_isnumber(L, i)) { if (lua_isstring(L, i)) { j = dimen_to_number(L, lua_tostring(L, i)); } else { - lua_pushstring(L, "unsupported value type"); - lua_error(L); - } else - j = (int) lua_tonumber(L, i); - k = get_item_index(L, (i - 1), get_scaled_base()); + luaL_error(L, "unsupported value type"); + } + } else { + lua_number2int(j, lua_tonumber(L, i)); + } + k = get_item_index(L, (i - 1), scaled_base); check_index_range(k, "setdimen"); err = set_tex_dimen_register(k, j); - int_par(param_global_defs_code) = save_global_defs; + int_par(global_defs_code) = save_global_defs; if (err) { - lua_pushstring(L, "incorrect value"); - lua_error(L); + luaL_error(L, "incorrect value"); } return 0; } @@ -335,8 +640,8 @@ static int setdimen(lua_State * L) static int getdimen(lua_State * L) { int j; - integer k; - k = get_item_index(L, lua_gettop(L), get_scaled_base()); + int k; + k = get_item_index(L, lua_gettop(L), scaled_base); check_index_range(k, "getdimen"); j = get_tex_dimen_register(k); lua_pushnumber(L, j); @@ -347,19 +652,18 @@ static int vsetskip(lua_State * L, int is_global) { int i, err; halfword *j; - integer k; - integer save_global_defs = int_par(param_global_defs_code); + int k; + int save_global_defs = int_par(global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(global_defs_code) = 1; i = lua_gettop(L); j = check_isnode(L, i); /* the value */ - k = get_item_index(L, (i - 1), get_skip_base()); + k = get_item_index(L, (i - 1), skip_base); check_index_range(k, "setskip"); /* the index */ err = set_tex_skip_register(k, *j); - int_par(param_global_defs_code) = save_global_defs; + int_par(global_defs_code) = save_global_defs; if (err) { - lua_pushstring(L, "incorrect value"); - lua_error(L); + luaL_error(L, "incorrect value"); } return 0; } @@ -376,11 +680,11 @@ static int setskip(lua_State * L) return vsetskip(L, isglobal); } -static int getskip(lua_State * L) +int getskip(lua_State * L) { halfword j; - integer k; - k = get_item_index(L, lua_gettop(L), get_skip_base()); + int k; + k = get_item_index(L, lua_gettop(L), skip_base); check_index_range(k, "getskip"); j = get_tex_skip_register(k); lua_nodelib_push_fast(L, j); @@ -392,19 +696,18 @@ static int getskip(lua_State * L) static int vsetcount(lua_State * L, int is_global) { int i, j, err; - integer k; - integer save_global_defs = int_par(param_global_defs_code); + int k; + int save_global_defs = int_par(global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(global_defs_code) = 1; i = lua_gettop(L); j = (int) luaL_checkinteger(L, i); - k = get_item_index(L, (i - 1), get_count_base()); + k = get_item_index(L, (i - 1), count_base); check_index_range(k, "setcount"); err = set_tex_count_register(k, j); - int_par(param_global_defs_code) = save_global_defs; + int_par(global_defs_code) = save_global_defs; if (err) { - lua_pushstring(L, "incorrect value"); - lua_error(L); + luaL_error(L, "incorrect value"); } return 0; } @@ -424,8 +727,8 @@ static int setcount(lua_State * L) static int getcount(lua_State * L) { int j; - integer k; - k = get_item_index(L, lua_gettop(L), get_count_base()); + int k; + k = get_item_index(L, lua_gettop(L), count_base); check_index_range(k, "getcount"); j = get_tex_count_register(k); lua_pushnumber(L, j); @@ -436,19 +739,18 @@ static int getcount(lua_State * L) static int vsetattribute(lua_State * L, int is_global) { int i, j, err; - integer k; - integer save_global_defs = int_par(param_global_defs_code); + int k; + int save_global_defs = int_par(global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(global_defs_code) = 1; i = lua_gettop(L); j = (int) luaL_checkinteger(L, i); - k = get_item_index(L, (i - 1), get_attribute_base()); + k = get_item_index(L, (i - 1), attribute_base); check_index_range(k, "setattribute"); err = set_tex_attribute_register(k, j); - int_par(param_global_defs_code) = save_global_defs; + int_par(global_defs_code) = save_global_defs; if (err) { - lua_pushstring(L, "incorrect value"); - lua_error(L); + luaL_error(L, "incorrect value"); } return 0; } @@ -468,38 +770,34 @@ static int setattribute(lua_State * L) static int getattribute(lua_State * L) { int j; - integer k; - k = get_item_index(L, lua_gettop(L), get_attribute_base()); + int k; + k = get_item_index(L, lua_gettop(L), attribute_base); check_index_range(k, "getattribute"); j = get_tex_attribute_register(k); lua_pushnumber(L, j); return 1; } -static int vsettoks(lua_State * L, int is_global) +int vsettoks(lua_State * L, int is_global) { - int i, j, err; - size_t len; - integer k; - const char *st; - integer save_global_defs = int_par(param_global_defs_code); + int i, err; + int k; + lstring str; + int save_global_defs = int_par(global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(global_defs_code) = 1; i = lua_gettop(L); if (!lua_isstring(L, i)) { - lua_pushstring(L, "unsupported value type"); - lua_error(L); + luaL_error(L, "unsupported value type"); } - st = lua_tolstring(L, i, &len); - k = get_item_index(L, (i - 1), get_toks_base()); + str.s = (unsigned char *) xstrdup(lua_tolstring(L, i, &str.l)); + k = get_item_index(L, (i - 1), toks_base); check_index_range(k, "settoks"); - j = maketexlstring(st, len); - err = zset_tex_toks_register(k, j); - int_par(param_global_defs_code) = save_global_defs; + err = set_tex_toks_register(k, str); + xfree(str.s); + int_par(global_defs_code) = save_global_defs; if (err) { - flush_str(j); - lua_pushstring(L, "incorrect value"); - lua_error(L); + luaL_error(L, "incorrect value"); } return 0; } @@ -518,12 +816,15 @@ static int settoks(lua_State * L) static int gettoks(lua_State * L) { - integer k; + int k; str_number t; - k = get_item_index(L, lua_gettop(L), get_toks_base()); + char *ss; + k = get_item_index(L, lua_gettop(L), toks_base); check_index_range(k, "gettoks"); t = get_tex_toks_register(k); - lua_pushstring(L, makecstring(t)); + ss = makecstring(t); + lua_pushstring(L, ss); + free(ss); flush_str(t); return 1; } @@ -531,19 +832,19 @@ static int gettoks(lua_State * L) static int get_box_id(lua_State * L, int i) { const char *s; - integer cur_cs, cur_cmd; + int cur_cs, cur_cmd; size_t k = 0; int j = -1; if (lua_type(L, i) == LUA_TSTRING) { s = lua_tolstring(L, i, &k); cur_cs = string_lookup(s, k); - cur_cmd = zget_eq_type(cur_cs); + cur_cmd = eq_type(cur_cs); if (cur_cmd == char_given_cmd || cur_cmd == math_given_cmd || cur_cmd == omath_given_cmd) { - j = zget_equiv(cur_cs); + j = equiv(cur_cs); } } else { - j = (int) lua_tonumber(L, (i)); + lua_number2int(j, lua_tonumber(L, (i))); } return j; } @@ -561,9 +862,9 @@ static int getbox(lua_State * L) static int vsetbox(lua_State * L, int is_global) { int i, j, k, err; - integer save_global_defs = int_par(param_global_defs_code); + int save_global_defs = int_par(global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(global_defs_code) = 1; k = get_box_id(L, -2); check_index_range(k, "setbox"); i = get_tex_box_register(k); @@ -575,12 +876,17 @@ static int vsetbox(lua_State * L, int is_global) return 0; } else { j = nodelist_from_lua(L); + if (j != null && type(j) != hlist_node && type(j) != vlist_node) { + luaL_error(L, "setbox: incompatible node type (%s)\n", + get_node_name(type(j), subtype(j))); + return 0; + } + } err = set_tex_box_register(k, j); - int_par(param_global_defs_code) = save_global_defs; + int_par(global_defs_code) = save_global_defs; if (err) { - lua_pushstring(L, "incorrect value"); - lua_error(L); + luaL_error(L, "incorrect value"); } return 0; } @@ -604,8 +910,7 @@ static int getboxdim(lua_State * L, int whichdim) j = get_box_id(L, i); lua_settop(L, (i - 2)); /* table at -1 */ if (j < 0 || j > 65535) { - lua_pushstring(L, "incorrect index"); - lua_error(L); + luaL_error(L, "incorrect index"); } switch (whichdim) { case width_offset: @@ -620,17 +925,17 @@ static int getboxdim(lua_State * L, int whichdim) return 1; } -static int getboxwd(lua_State * L) +int getboxwd(lua_State * L) { return getboxdim(L, width_offset); } -static int getboxht(lua_State * L) +int getboxht(lua_State * L) { return getboxdim(L, height_offset); } -static int getboxdp(lua_State * L) +int getboxdp(lua_State * L) { return getboxdim(L, depth_offset); } @@ -638,20 +943,19 @@ static int getboxdp(lua_State * L) static int vsetboxdim(lua_State * L, int whichdim, int is_global) { int i, j, k, err; - integer save_global_defs = int_par(param_global_defs_code); + int save_global_defs = int_par(global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(global_defs_code) = 1; i = lua_gettop(L); if (!lua_isnumber(L, i)) { j = dimen_to_number(L, lua_tostring(L, i)); } else { - j = (int) lua_tonumber(L, i); + lua_number2int(j, lua_tonumber(L, i)); } k = get_box_id(L, (i - 1)); lua_settop(L, (i - 3)); /* table at -2 */ if (k < 0 || k > 65535) { - lua_pushstring(L, "incorrect index"); - lua_error(L); + luaL_error(L, "incorrect index"); } err = 0; switch (whichdim) { @@ -664,10 +968,9 @@ static int vsetboxdim(lua_State * L, int whichdim, int is_global) case depth_offset: err = set_tex_box_depth(k, j); } - int_par(param_global_defs_code) = save_global_defs; + int_par(global_defs_code) = save_global_defs; if (err) { - lua_pushstring(L, "not a box"); - lua_error(L); + luaL_error(L, "not a box"); } return 0; } @@ -708,7 +1011,7 @@ static int setboxdp(lua_State * L) return vsetboxdim(L, depth_offset, isglobal); } -static int settex(lua_State * L) +int settex(lua_State * L) { const char *st; int i, j, texstr; @@ -728,94 +1031,84 @@ static int settex(lua_State * L) } cur_cs = string_lookup(st, k); flush_str(texstr); - cur_cmd = zget_eq_type(cur_cs); + cur_cmd = eq_type(cur_cs); if (is_int_assign(cur_cmd)) { if (lua_isnumber(L, i)) { + int luai; + lua_number2int(luai, lua_tonumber(L, i)); assign_internal_value((isglobal ? 4 : 0), - zget_equiv(cur_cs), lua_tonumber(L, - i)); + equiv(cur_cs), luai); } else { - lua_pushstring(L, "unsupported value type"); - lua_error(L); + luaL_error(L, "unsupported value type"); } } else if (is_dim_assign(cur_cmd)) { if (!lua_isnumber(L, i)) { if (lua_isstring(L, i)) { j = dimen_to_number(L, lua_tostring(L, i)); } else { - lua_pushstring(L, "unsupported value type"); - lua_error(L); + luaL_error(L, "unsupported value type"); } } else { - j = (int) lua_tonumber(L, i); + lua_number2int(j, lua_tonumber(L, i)); } - assign_internal_value((isglobal ? 4 : 0), zget_equiv(cur_cs), - j); + assign_internal_value((isglobal ? 4 : 0), equiv(cur_cs), j); + } else if (is_toks_assign(cur_cmd)) { + if (lua_isstring(L, i)) { + j = tokenlist_from_lua(L); /* uses stack -1 */ + assign_internal_value((isglobal ? 4 : 0), equiv(cur_cs), j); + + } else { + luaL_error(L, "unsupported value type"); + } + } else { - lua_pushstring(L, "unsupported tex internal assignment"); - lua_error(L); + luaL_error(L, "unsupported tex internal assignment"); } } else { - lua_rawset(L, (i - 2)); + if (lua_istable(L, (i - 2))) + lua_rawset(L, (i - 2)); } } else { - lua_rawset(L, (i - 2)); + if (lua_istable(L, (i - 2))) + lua_rawset(L, (i - 2)); } return 0; } -#if 0 /* unused */ -static char *get_something_internal(int cur_cmd, int cur_code) -{ - int texstr; - char *str; - int save_cur_val, save_cur_val_level; - save_cur_val = cur_val; - save_cur_val_level = cur_val_level; - zscan_something_simple(cur_cmd, cur_code); - texstr = the_scanned_result(); - cur_val = save_cur_val; - cur_val_level = save_cur_val_level; - str = makecstring(texstr); - flush_str(texstr); - return str; -} -#endif - -static int do_convert(lua_State * L, int cur_code) +int do_convert(lua_State * L, int cur_code) { int texstr; - integer i = -1; + int i = -1; char *str = NULL; switch (cur_code) { - case convert_pdf_creation_date_code: /* ? */ - case convert_pdf_insert_ht_code: /* arg */ - case convert_pdf_ximage_bbox_code: /* arg 2 ints */ - case convert_lua_code: /* arg complex */ - case convert_lua_escape_string_code: /* arg token list */ - case convert_pdf_colorstack_init_code: /* arg complex */ - case convert_left_margin_kern_code: /* arg box */ - case convert_right_margin_kern_code: /* arg box */ + case pdf_creation_date_code: /* ? */ + case pdf_insert_ht_code: /* arg */ + case pdf_ximage_bbox_code: /* arg 2 ints */ + case lua_code: /* arg complex */ + case lua_escape_string_code: /* arg token list */ + case pdf_colorstack_init_code: /* arg complex */ + case left_margin_kern_code: /* arg box */ + case right_margin_kern_code: /* arg box */ break; - case convert_string_code: /* arg token */ - case convert_meaning_code: /* arg token */ + case string_code: /* arg token */ + case meaning_code: /* arg token */ break; /* the next fall through, and come from 'official' indices! */ - case convert_font_name_code: /* arg fontid */ - case convert_font_identifier_code: /* arg fontid */ - case convert_pdf_font_name_code: /* arg fontid */ - case convert_pdf_font_objnum_code: /* arg fontid */ - case convert_pdf_font_size_code: /* arg fontid */ - case convert_uniform_deviate_code: /* arg int */ - case convert_number_code: /* arg int */ - case convert_roman_numeral_code: /* arg int */ - case convert_pdf_page_ref_code: /* arg int */ - case convert_pdf_xform_name_code: /* arg int */ + case font_name_code: /* arg fontid */ + case font_identifier_code: /* arg fontid */ + case pdf_font_name_code: /* arg fontid */ + case pdf_font_objnum_code: /* arg fontid */ + case pdf_font_size_code: /* arg fontid */ + case uniform_deviate_code: /* arg int */ + case number_code: /* arg int */ + case roman_numeral_code: /* arg int */ + case pdf_page_ref_code: /* arg int */ + case pdf_xform_name_code: /* arg int */ if (lua_gettop(L) < 1) { /* error */ } - i = lua_tonumber(L, 1); /* these fall through! */ + lua_number2int(i, lua_tonumber(L, 1)); /* these fall through! */ default: texstr = the_convert_string(cur_code, i); if (texstr) { @@ -823,22 +1116,24 @@ static int do_convert(lua_State * L, int cur_code) flush_str(texstr); } } - if (str) + if (str) { lua_pushstring(L, str); - else + free(str); + } else { lua_pushnil(L); + } return 1; } -static int do_scan_internal(lua_State * L, int cur_cmd, int cur_code) +int do_scan_internal(lua_State * L, int cur_cmd, int cur_code) { int texstr; char *str = NULL; int save_cur_val, save_cur_val_level; save_cur_val = cur_val; save_cur_val_level = cur_val_level; - zscan_something_simple(cur_cmd, cur_code); + scan_something_simple(cur_cmd, cur_code); if (cur_val_level == int_val_level || cur_val_level == dimen_val_level || cur_val_level == attr_val_level) { @@ -848,10 +1143,12 @@ static int do_scan_internal(lua_State * L, int cur_cmd, int cur_code) } else { /* dir_val_level, mu_val_level, tok_val_level */ texstr = the_scanned_result(); str = makecstring(texstr); - if (str) + if (str) { lua_pushstring(L, str); - else + free(str); + } else { lua_pushnil(L); + } flush_str(texstr); } cur_val = save_cur_val; @@ -859,74 +1156,74 @@ static int do_scan_internal(lua_State * L, int cur_cmd, int cur_code) return 1; } -static int do_lastitem(lua_State * L, int cur_code) +int do_lastitem(lua_State * L, int cur_code) { int retval = 1; switch (cur_code) { /* the next two do not actually exist */ - case last_item_lastattr_code: - case last_item_attrexpr_code: + case lastattr_code: + case attrexpr_code: lua_pushnil(L); break; /* the expressions do something complicated with arguments, yuck */ - case last_item_numexpr_code: - case last_item_dimexpr_code: - case last_item_glueexpr_code: - case last_item_muexpr_code: + case numexpr_code: + case dimexpr_code: + case glueexpr_code: + case muexpr_code: lua_pushnil(L); break; /* these read a glue or muglue, todo */ - case last_item_mu_to_glue_code: - case last_item_glue_to_mu_code: - case last_item_glue_stretch_order_code: - case last_item_glue_shrink_order_code: - case last_item_glue_stretch_code: - case last_item_glue_shrink_code: + case mu_to_glue_code: + case glue_to_mu_code: + case glue_stretch_order_code: + case glue_shrink_order_code: + case glue_stretch_code: + case glue_shrink_code: lua_pushnil(L); break; /* these read a fontid and a char, todo */ - case last_item_font_char_wd_code: - case last_item_font_char_ht_code: - case last_item_font_char_dp_code: - case last_item_font_char_ic_code: + case font_char_wd_code: + case font_char_ht_code: + case font_char_dp_code: + case font_char_ic_code: lua_pushnil(L); break; /* these read an integer, todo */ - case last_item_par_shape_length_code: - case last_item_par_shape_indent_code: - case last_item_par_shape_dimen_code: + case par_shape_length_code: + case par_shape_indent_code: + case par_shape_dimen_code: lua_pushnil(L); break; - case last_item_lastpenalty_code: - case last_item_lastkern_code: - case last_item_lastskip_code: - case last_item_last_node_type_code: - case last_item_input_line_no_code: - case last_item_badness_code: - case last_item_pdftex_version_code: - case last_item_pdf_last_obj_code: - case last_item_pdf_last_xform_code: - case last_item_pdf_last_ximage_code: - case last_item_pdf_last_ximage_pages_code: - case last_item_pdf_last_annot_code: - case last_item_pdf_last_x_pos_code: - case last_item_pdf_last_y_pos_code: - case last_item_pdf_retval_code: - case last_item_pdf_last_ximage_colordepth_code: - case last_item_random_seed_code: - case last_item_pdf_last_link_code: - case last_item_luatex_version_code: - case last_item_Aleph_version_code: - case last_item_Omega_version_code: - case last_item_Aleph_minor_version_code: - case last_item_Omega_minor_version_code: - case last_item_eTeX_minor_version_code: - case last_item_eTeX_version_code: - case last_item_current_group_level_code: - case last_item_current_group_type_code: - case last_item_current_if_level_code: - case last_item_current_if_type_code: - case last_item_current_if_branch_code: + case lastpenalty_code: + case lastkern_code: + case lastskip_code: + case last_node_type_code: + case input_line_no_code: + case badness_code: + case pdftex_version_code: + case pdf_last_obj_code: + case pdf_last_xform_code: + case pdf_last_ximage_code: + case pdf_last_ximage_pages_code: + case pdf_last_annot_code: + case pdf_last_x_pos_code: + case pdf_last_y_pos_code: + case pdf_retval_code: + case pdf_last_ximage_colordepth_code: + case random_seed_code: + case pdf_last_link_code: + case luatex_version_code: + case Aleph_version_code: + case Omega_version_code: + case Aleph_minor_version_code: + case Omega_minor_version_code: + case eTeX_minor_version_code: + case eTeX_version_code: + case current_group_level_code: + case current_group_type_code: + case current_if_level_code: + case current_if_type_code: + case current_if_branch_code: retval = do_scan_internal(L, last_item_cmd, cur_code); break; default: @@ -939,7 +1236,7 @@ static int do_lastitem(lua_State * L, int cur_code) static int tex_setmathparm(lua_State * L) { int i, j; - scaled k; + int k; int n; int l = cur_level; n = lua_gettop(L); @@ -952,8 +1249,8 @@ static int tex_setmathparm(lua_State * L) } i = luaL_checkoption(L, (n - 2), NULL, math_param_names); j = luaL_checkoption(L, (n - 1), NULL, math_style_names); - k = (scaled) lua_tonumber(L, n); - def_math_param(i, j, k, l); + lua_number2int(k, lua_tonumber(L, n)); + def_math_param(i, j, (scaled) k, l); } return 0; } @@ -973,59 +1270,59 @@ static int tex_getmathparm(lua_State * L) static int getfontname(lua_State * L) { - return do_convert(L, convert_font_name_code); + return do_convert(L, font_name_code); } static int getfontidentifier(lua_State * L) { - return do_convert(L, convert_font_identifier_code); + return do_convert(L, font_identifier_code); } static int getpdffontname(lua_State * L) { - return do_convert(L, convert_pdf_font_name_code); + return do_convert(L, pdf_font_name_code); } static int getpdffontobjnum(lua_State * L) { - return do_convert(L, convert_pdf_font_objnum_code); + return do_convert(L, pdf_font_objnum_code); } static int getpdffontsize(lua_State * L) { - return do_convert(L, convert_pdf_font_size_code); + return do_convert(L, pdf_font_size_code); } static int getuniformdeviate(lua_State * L) { - return do_convert(L, convert_uniform_deviate_code); + return do_convert(L, uniform_deviate_code); } static int getnumber(lua_State * L) { - return do_convert(L, convert_number_code); + return do_convert(L, number_code); } static int getromannumeral(lua_State * L) { - return do_convert(L, convert_roman_numeral_code); + return do_convert(L, roman_numeral_code); } static int getpdfpageref(lua_State * L) { - return do_convert(L, convert_pdf_page_ref_code); + return do_convert(L, pdf_page_ref_code); } static int getpdfxformname(lua_State * L) { - return do_convert(L, convert_pdf_xform_name_code); + return do_convert(L, pdf_xform_name_code); } -static int get_parshape(lua_State * L) +int get_parshape(lua_State * L) { int n; - halfword par_shape_ptr = get_par_shape_ptr(); + halfword par_shape_ptr = equiv(par_shape_loc); if (par_shape_ptr != 0) { int m = 1; n = vinfo(par_shape_ptr + 1); @@ -1046,7 +1343,7 @@ static int get_parshape(lua_State * L) } -static int gettex(lua_State * L) +int gettex(lua_State * L) { int cur_cs = -1; int retval = 1; /* default is to return nil */ @@ -1100,7 +1397,7 @@ static int gettex(lua_State * L) } -static int getlist(lua_State * L) +int getlist(lua_State * L) { const char *str; if (lua_isstring(L, 2)) { @@ -1148,7 +1445,7 @@ static int getlist(lua_State * L) return 1; } -static int setlist(lua_State * L) +int setlist(lua_State * L) { halfword *n_ptr; const char *str; @@ -1156,9 +1453,9 @@ static int setlist(lua_State * L) if (lua_isstring(L, 2)) { str = lua_tostring(L, 2); if (strcmp(str, "best_size") == 0) { - best_size = lua_tointeger(L, 3); + best_size = (int) lua_tointeger(L, 3); } else if (strcmp(str, "least_page_cost") == 0) { - least_page_cost = lua_tointeger(L, 3); + least_page_cost = (int) lua_tointeger(L, 3); } else { if (!lua_isnil(L, 3)) { n_ptr = check_isnode(L, 3); @@ -1176,10 +1473,7 @@ static int setlist(lua_State * L) } else if (strcmp(str, "contrib_head") == 0) { vlink(contrib_head) = n; if (n == 0) { - if (nest_ptr == 0) - cur_list.tail_field = contrib_head; /* vertical mode */ - else - nest[0].tail_field = contrib_head; /* other modes */ + contrib_tail = contrib_head; } } else if (strcmp(str, "best_page_break") == 0) { best_page_break = n; @@ -1204,11 +1498,142 @@ static int setlist(lua_State * L) return 0; } -#define infinity 2147483647 +#define NEST_METATABLE "luatex.nest" + +static int lua_nest_getfield(lua_State * L) +{ + list_state_record *r, **rv = lua_touserdata(L, -2); + const char *field = lua_tostring(L, -1); + r = *rv; + if (strcmp(field, "mode") == 0) { + lua_pushnumber(L, r->mode_field); + } else if (strcmp(field, "head") == 0) { + lua_nodelib_push_fast(L, r->head_field); + } else if (strcmp(field, "tail") == 0) { + lua_nodelib_push_fast(L, r->tail_field); + } else if (strcmp(field, "delimptr") == 0) { + lua_pushnumber(L, r->eTeX_aux_field); + lua_nodelib_push(L); + } else if (strcmp(field, "prevgraf") == 0) { + lua_pushnumber(L, r->pg_field); + } else if (strcmp(field, "modeline") == 0) { + lua_pushnumber(L, r->ml_field); + } else if (strcmp(field, "prevdepth") == 0) { + lua_pushnumber(L, r->prev_depth_field); + } else if (strcmp(field, "spacefactor") == 0) { + lua_pushnumber(L, r->space_factor_field); + } else if (strcmp(field, "noad") == 0) { + lua_pushnumber(L, r->incompleat_noad_field); + lua_nodelib_push(L); + } else if (strcmp(field, "dirs") == 0) { + lua_pushnumber(L, r->dirs_field); + lua_nodelib_push(L); + } else if (strcmp(field, "mathdir") == 0) { + lua_pushboolean(L, r->math_field); + } else if (strcmp(field, "mathstyle") == 0) { + lua_pushnumber(L, r->math_style_field); + } else { + lua_pushnil(L); + } + return 1; +} + +static int lua_nest_setfield(lua_State * L) +{ + halfword *n; + int i; + list_state_record *r, **rv = lua_touserdata(L, -3); + const char *field = lua_tostring(L, -2); + r = *rv; + if (strcmp(field, "mode") == 0) { + lua_number2int(i, lua_tonumber(L, -1)); + r->mode_field = i; + } else if (strcmp(field, "head") == 0) { + n = check_isnode(L, -1); + r->head_field = *n; + } else if (strcmp(field, "tail") == 0) { + n = check_isnode(L, -1); + r->tail_field = *n; + } else if (strcmp(field, "delimptr") == 0) { + n = check_isnode(L, -1); + r->eTeX_aux_field = *n; + } else if (strcmp(field, "prevgraf") == 0) { + lua_number2int(i, lua_tonumber(L, -1)); + r->pg_field = i; + } else if (strcmp(field, "modeline") == 0) { + lua_number2int(i, lua_tonumber(L, -1)); + r->ml_field = i; + } else if (strcmp(field, "prevdepth") == 0) { + lua_number2int(i, lua_tonumber(L, -1)); + r->prev_depth_field = i; + } else if (strcmp(field, "spacefactor") == 0) { + lua_number2int(i, lua_tonumber(L, -1)); + r->space_factor_field = i; + } else if (strcmp(field, "noad") == 0) { + n = check_isnode(L, -1); + r->incompleat_noad_field = *n; + } else if (strcmp(field, "dirs") == 0) { + n = check_isnode(L, -1); + r->dirs_field = *n; + } else if (strcmp(field, "mathdir") == 0) { + r->math_field = lua_toboolean(L, -1); + } else if (strcmp(field, "mathstyle") == 0) { + lua_number2int(i, lua_tonumber(L, -1)); + r->math_style_field = i; + } + return 0; +} + +static const struct luaL_reg nest_m[] = { + {"__index", lua_nest_getfield}, + {"__newindex", lua_nest_setfield}, + {NULL, NULL} /* sentinel */ +}; + +static void init_nest_lib(lua_State * L) +{ + luaL_newmetatable(L, NEST_METATABLE); + luaL_register(L, NULL, nest_m); + lua_pop(L, 1); +} + +static int getnest(lua_State * L) +{ + int ptr; + list_state_record **nestitem; + if (lua_isnumber(L, 2)) { + lua_number2int(ptr, lua_tonumber(L, 2)); + if (ptr >= 0 && ptr <= nest_ptr) { + nestitem = lua_newuserdata(L, sizeof(list_state_record *)); + *nestitem = &nest[ptr]; + luaL_getmetatable(L, NEST_METATABLE); + lua_setmetatable(L, -2); + } else { + lua_pushnil(L); + } + } else if (lua_isstring(L, 2)) { + const char *s = lua_tostring(L, 2); + if (strcmp(s, "ptr") == 0) { + lua_pushnumber(L, nest_ptr); + } else { + lua_pushnil(L); + } + } else { + lua_pushnil(L); + } + return 1; +} + +static int setnest(lua_State * L) +{ + luaL_error(L, "You can't modify the semantic nest array directly"); + return 2; +} static int do_integer_error(double m) { - const char *help[] = { "I can only go up to 2147483647='17777777777=" "7FFFFFFF,", + const char *help[] = + { "I can only go up to 2147483647='17777777777=" "7FFFFFFF,", "so I'm using that number instead of yours.", NULL }; @@ -1219,7 +1644,7 @@ static int do_integer_error(double m) static int tex_roundnumber(lua_State * L) { - double m = lua_tonumber(L, 1) + 0.5; + double m = (double) lua_tonumber(L, 1) + 0.5; if (abs(m) > (double) infinity) lua_pushnumber(L, do_integer_error(m)); else @@ -1237,7 +1662,7 @@ static int tex_scaletable(lua_State * L) lua_pushvalue(L, -2); lua_insert(L, -2); if (lua_isnumber(L, -1)) { - double m = lua_tonumber(L, -1) * delta + 0.5; + double m = (double) lua_tonumber(L, -1) * delta + 0.5; lua_pop(L, 1); if (abs(m) > (double) infinity) lua_pushnumber(L, do_integer_error(m)); @@ -1247,7 +1672,7 @@ static int tex_scaletable(lua_State * L) lua_rawset(L, 3); } } else if (lua_isnumber(L, 1)) { - double m = lua_tonumber(L, 1) * delta + 0.5; + double m = (double) lua_tonumber(L, 1) * delta + 0.5; if (abs(m) > (double) infinity) lua_pushnumber(L, do_integer_error(m)); else @@ -1280,7 +1705,7 @@ static int tex_definefont(lua_State * L) i = 2; } csname = luaL_checklstring(L, i, &l); - f = luaL_checkinteger(L, (i + 1)); + f = (int) luaL_checkinteger(L, (i + 1)); t = maketexlstring(csname, l); no_new_control_sequence = 0; u = string_lookup(csname, l); @@ -1289,8 +1714,8 @@ static int tex_definefont(lua_State * L) geq_define(u, set_font_cmd, f); else eq_define(u, set_font_cmd, f); - zeqtb[get_font_id_base() + f] = zeqtb[u]; - hash_text(get_font_id_base() + f) = t; + eqtb[font_id_base + f] = eqtb[u]; + hash_text(font_id_base + f) = t; return 0; } @@ -1299,14 +1724,15 @@ static int tex_hashpairs(lua_State * L) int cmd, chr; str_number s = 0; int cs = 1; - int eqtb_size = get_eqtb_size(); lua_newtable(L); while (cs < eqtb_size) { s = hash_text(cs); if (s > 0) { - lua_pushstring(L, makecstring(s)); - cmd = zget_eq_type(cs); - chr = zget_equiv(cs); + char *ss = makecstring(s); + lua_pushstring(L, ss); + free(ss); + cmd = eq_type(cs); + chr = equiv(cs); make_token_table(L, cmd, chr, cs); lua_rawset(L, -3); } @@ -1324,7 +1750,9 @@ static int tex_primitives(lua_State * L) while (cs < prim_size) { s = get_prim_text(cs); if (s > 0) { - lua_pushstring(L, makecstring(s)); + char *ss = makecstring(s); + lua_pushstring(L, ss); + free(ss); cmd = get_prim_eq_type(cs); chr = get_prim_equiv(cs); make_token_table(L, cmd, chr, 0); @@ -1373,7 +1801,9 @@ static int tex_extraprimitives(lua_State * L) s = get_prim_text(cs); if (s > 0) { if (get_prim_origin(cs) & mask) { - lua_pushstring(L, makecstring(s)); + char *ss = makecstring(s); + lua_pushstring(L, ss); + free(ss); lua_rawseti(L, -2, i++); } } @@ -1386,8 +1816,7 @@ static int tex_enableprimitives(lua_State * L) { int n = lua_gettop(L); if (n != 2) { - lua_pushstring(L, "wrong number of arguments"); - lua_error(L); + luaL_error(L, "wrong number of arguments"); } else { size_t l; int i; @@ -1404,24 +1833,25 @@ static int tex_enableprimitives(lua_State * L) halfword prim_val = prim_lookup(s); if (prim_val != undefined_primitive) { char *newprim; - integer val; + int val; size_t newl; halfword cur_cmd = get_prim_eq_type(prim_val); halfword cur_chr = get_prim_equiv(prim_val); if (strncmp(pre, prim, l) != 0) { /* not a prefix */ newl = strlen(prim) + l; - newprim = (char *) xmalloc(newl + 1); + newprim = (char *) xmalloc((unsigned) (newl + 1)); strcpy(newprim, pre); strcat(newprim + l, prim); } else { newl = strlen(prim); - newprim = (char *) xmalloc(newl + 1); + newprim = (char *) xmalloc((unsigned) (newl + 1)); strcpy(newprim, prim); } val = string_lookup(newprim, newl); - if (val == static_undefined_control_sequence || - zget_eq_type(val) == undefined_cs_cmd) { - primitive_def(newprim, newl, cur_cmd, cur_chr); + if (val == undefined_control_sequence || + eq_type(val) == undefined_cs_cmd) { + primitive_def(newprim, newl, (quarterword) cur_cmd, + cur_chr); } free(newprim); } @@ -1436,17 +1866,390 @@ static int tex_enableprimitives(lua_State * L) lua_pop(L, 1); /* the table */ no_new_control_sequence = nncs; } else { - lua_pushstring(L, "Expected an array of names as second argument"); - lua_error(L); + luaL_error(L, "Expected an array of names as second argument"); + } + } + return 0; +} + +#define get_int_par(A,B,C) do { \ + lua_pushstring(L,(A)); \ + lua_gettable(L,-2); \ + if (lua_type(L, -1) == LUA_TNUMBER) { \ + lua_number2int(B,lua_tonumber(L, -1)); \ + } else { \ + B = (C); \ + } \ + lua_pop(L,1); \ + } while (0) + + +#define get_intx_par(A,B,C,D,E) do { \ + lua_pushstring(L,(A)); \ + lua_gettable(L,-2); \ + if (lua_type(L, -1) == LUA_TNUMBER) { \ + lua_number2int(B,lua_tonumber(L, -1)); \ + D = null; \ + } else if (lua_type(L, -1) == LUA_TTABLE){ \ + B = 0; \ + D = nodelib_topenalties(L, lua_gettop(L)); \ + } else { \ + B = (C); \ + D = (E); \ + } \ + lua_pop(L,1); \ + } while (0) + +#define get_dimen_par(A,B,C) do { \ + lua_pushstring(L,(A)); \ + lua_gettable(L,-2); \ + if (lua_type(L, -1) == LUA_TNUMBER) { \ + lua_number2int(B,lua_tonumber(L, -1)); \ + } else { \ + B = (C); \ + } \ + lua_pop(L,1); \ + } while (0) + + +#define get_glue_par(A,B,C) do { \ + lua_pushstring(L,(A)); \ + lua_gettable(L,-2); \ + if (lua_type(L, -1) != LUA_TNIL) { \ + B = *check_isnode(L, -1); \ + } else { \ + B = (C); \ + } \ + lua_pop(L,1); \ + } while (0) + + +static halfword nodelib_toparshape(lua_State * L, int i) +{ + halfword p; + int n = 0; + int width, indent, j; + /* find |n| */ + lua_pushnil(L); + while (lua_next(L, i) != 0) { + n++; + lua_pop(L, 1); + } + if (n == 0) + return null; + p = new_node(shape_node, 2 * (n + 1) + 1); + vinfo(p + 1) = n; + /* fill |p| */ + lua_pushnil(L); + j = 0; + while (lua_next(L, i) != 0) { + /* don't give an error for non-tables, we may add special syntaxes at some point */ + j++; + if (lua_type(L, i) == LUA_TTABLE) { + lua_rawgeti(L, -1, 1); /* indent */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_number2int(indent, lua_tonumber(L, -1)); + lua_pop(L, 1); + lua_rawgeti(L, -1, 2); /* width */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_number2int(width, lua_tonumber(L, -1)); + lua_pop(L, 1); + varmem[p + 2 * j].cint = indent; + varmem[p + 2 * j + 1].cint = width; + } + } + } + lua_pop(L, 1); + } + return p; +} + +/* penalties */ + +static halfword nodelib_topenalties(lua_State * L, int i) +{ + halfword p; + int n = 0; + int j; + /* find |n| */ + lua_pushnil(L); + while (lua_next(L, i) != 0) { + n++; + lua_pop(L, 1); + } + if (n == 0) + return null; + p = new_node(shape_node, 2 * ((n / 2) + 1) + 1 + 1); + vinfo(p + 1) = (n / 2) + 1; + varmem[p + 2].cint = n; + lua_pushnil(L); + j = 2; + while (lua_next(L, i) != 0) { + j++; + if (lua_isnumber(L, -1)) { + int pen = 0; + lua_number2int(pen, lua_tonumber(L, -1)); + varmem[p+j].cint = pen; + } + lua_pop(L, 1); + } + if (!odd(n)) + varmem[p+j+1].cint = 0; + return p; +} + + + + +static int tex_run_linebreak(lua_State * L) +{ + + halfword *j; + halfword p; + halfword final_par_glue; + int paragraph_dir = 0; + /* locally initialized parameters for line breaking */ + int pretolerance, tracingparagraphs, tolerance, looseness, hyphenpenalty, + exhyphenpenalty, pdfadjustspacing, adjdemerits, pdfprotrudechars, + linepenalty, lastlinefit, doublehyphendemerits, finalhyphendemerits, + hangafter, interlinepenalty, widowpenalty, clubpenalty, brokenpenalty; + halfword emergencystretch, hangindent, hsize, leftskip, rightskip, + pdfeachlineheight, pdfeachlinedepth, pdffirstlineheight, + pdflastlinedepth, pdfignoreddimen, parshape; + int fewest_demerits = 0, actual_looseness = 0; + halfword clubpenalties, interlinepenalties, widowpenalties; + + /* push a new nest level */ + push_nest(); + /* save_vlink_cur_head = vlink(cur_list.head_field); */ + + j = check_isnode(L, 1); /* the value */ + vlink(temp_head) = *j; + p = *j; + if ((!is_char_node(vlink(*j))) + && ((type(vlink(*j)) == whatsit_node) + && (subtype(vlink(*j)) == local_par_node))) { + paragraph_dir = local_par_dir(vlink(*j)); + } + + while (vlink(p) != null) + p = vlink(p); + final_par_glue = p; + + /* initialize local parameters */ + + if (lua_gettop(L) != 2 || lua_type(L, 2) != LUA_TTABLE) { + lua_checkstack(L, 3); + lua_newtable(L); + } + lua_pushstring(L, "pardir"); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + paragraph_dir = nodelib_getdir(L, -1); + } + lua_pop(L, 1); + + lua_pushstring(L, "parshape"); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TTABLE) { + parshape = nodelib_toparshape(L, lua_gettop(L)); + } else { + parshape = equiv(par_shape_loc); + } + lua_pop(L, 1); + + get_int_par("pretolerance", pretolerance, int_par(pretolerance_code)); + get_int_par("tracingparagraphs", tracingparagraphs, + int_par(tracing_paragraphs_code)); + get_int_par("tolerance", tolerance, int_par(tolerance_code)); + get_int_par("looseness", looseness, int_par(looseness_code)); + get_int_par("hyphenpenalty", hyphenpenalty, int_par(hyphen_penalty_code)); + get_int_par("exhyphenpenalty", exhyphenpenalty, + int_par(ex_hyphen_penalty_code)); + get_int_par("pdfadjustspacing", pdfadjustspacing, + int_par(pdf_adjust_spacing_code)); + get_int_par("adjdemerits", adjdemerits, int_par(adj_demerits_code)); + get_int_par("pdfprotrudechars", pdfprotrudechars, + int_par(pdf_protrude_chars_code)); + get_int_par("linepenalty", linepenalty, int_par(line_penalty_code)); + get_int_par("lastlinefit", lastlinefit, int_par(last_line_fit_code)); + get_int_par("doublehyphendemerits", doublehyphendemerits, + int_par(double_hyphen_demerits_code)); + get_int_par("finalhyphendemerits", finalhyphendemerits, + int_par(final_hyphen_demerits_code)); + get_int_par("hangafter", hangafter, int_par(hang_after_code)); + get_intx_par("interlinepenalty", interlinepenalty,int_par(inter_line_penalty_code), + interlinepenalties, equiv(inter_line_penalties_loc)); + get_intx_par("clubpenalty", clubpenalty, int_par(club_penalty_code), + clubpenalties, equiv(club_penalties_loc)); + get_intx_par("widowpenalty", widowpenalty, int_par(widow_penalty_code), + widowpenalties, equiv(widow_penalties_loc)); + get_int_par("brokenpenalty", brokenpenalty, int_par(broken_penalty_code)); + get_dimen_par("emergencystretch", emergencystretch, + dimen_par(emergency_stretch_code)); + get_dimen_par("hangindent", hangindent, dimen_par(hang_indent_code)); + get_dimen_par("hsize", hsize, dimen_par(hsize_code)); + get_glue_par("leftskip", leftskip, glue_par(left_skip_code)); + get_glue_par("rightskip", rightskip, glue_par(right_skip_code)); + get_dimen_par("pdfeachlineheight", pdfeachlineheight, + dimen_par(pdf_each_line_height_code)); + get_dimen_par("pdfeachlinedepth", pdfeachlinedepth, + dimen_par(pdf_each_line_depth_code)); + get_dimen_par("pdffirstlineheight", pdffirstlineheight, + dimen_par(pdf_first_line_height_code)); + get_dimen_par("pdflastlinedepth", pdflastlinedepth, + dimen_par(pdf_last_line_depth_code)); + get_dimen_par("pdfignoreddimen", pdfignoreddimen, + dimen_par(pdf_ignored_dimen_code)); + + ext_do_line_break(paragraph_dir, + pretolerance, tracingparagraphs, tolerance, + emergencystretch, + looseness, hyphenpenalty, exhyphenpenalty, + pdfadjustspacing, + parshape, + adjdemerits, pdfprotrudechars, + linepenalty, lastlinefit, + doublehyphendemerits, finalhyphendemerits, + hangindent, hsize, hangafter, leftskip, rightskip, + pdfeachlineheight, pdfeachlinedepth, + pdffirstlineheight, pdflastlinedepth, + interlinepenalties, + interlinepenalty, clubpenalty, + clubpenalties, + widowpenalties, + widowpenalty, brokenpenalty, + final_par_glue, pdfignoreddimen); + + /* return the generated list, and its prevdepth */ + get_linebreak_info (&fewest_demerits, &actual_looseness) ; + lua_nodelib_push_fast(L, vlink(cur_list.head_field)); + lua_newtable(L); + lua_pushstring(L, "demerits"); + lua_pushnumber(L, fewest_demerits); + lua_settable(L, -3); + lua_pushstring(L, "looseness"); + lua_pushnumber(L, actual_looseness); + lua_settable(L, -3); + lua_pushstring(L, "prevdepth"); + lua_pushnumber(L, cur_list.prev_depth_field); + lua_settable(L, -3); + lua_pushstring(L, "prevgraf"); + lua_pushnumber(L, cur_list.pg_field); + lua_settable(L, -3); + + /* restore nest stack */ + pop_nest(); + if (parshape != equiv(par_shape_loc)) + flush_node(parshape); + return 2; +} + +static int tex_shipout(lua_State * L) +{ + int boxnum = get_box_id(L, 1); + ship_out(static_pdf, box(boxnum), true); + box(boxnum) = null; + return 0; +} + +static int tex_badness(lua_State * L) +{ + scaled t,s; + lua_number2int(t,lua_tonumber(L,1)); + lua_number2int(s,lua_tonumber(L,2)); + lua_pushnumber(L, badness(t,s)); + return 1; +} + + +static int tex_run_boot(lua_State * L) +{ + int n = lua_gettop(L); + const char *format = NULL; + if (n >= 1) { + ini_version = 0; + format = luaL_checkstring(L, 1); + } else { + ini_version = 1; + } + if (main_initialize()) { /* > 0 = failure */ + lua_pushboolean(L, 0); /* false */ + return 1; + } + if (format) { + if (!zopen_w_input(&fmt_file, format, DUMP_FORMAT, FOPEN_RBIN_MODE)) { + lua_pushboolean(L, 0); /* false */ + return 1; } + if (!load_fmt_file(format)) { + zwclose(fmt_file); + lua_pushboolean(L, 0); /* false */ + return 1; + } + zwclose(fmt_file); } + fix_date_and_time(); + if (format == NULL) + make_pdftex_banner(); + random_seed = (microseconds * 1000) + (epochseconds % 1000000); + init_randoms(random_seed); + initialize_math(); + fixup_selector(log_opened); + check_texconfig_init(); + text_dir_ptr = new_dir(0); + history = spotless; /* ready to go! */ + /* Initialize synctex primitive */ + synctexinitcommand(); + /* tex is ready to go, now */ + unhide_lua_table(Luas, "tex", tex_table_id); + unhide_lua_table(Luas, "pdf", pdf_table_id); + unhide_lua_table(Luas, "token", token_table_id); + unhide_lua_table(Luas, "node", node_table_id); + + lua_pushboolean(L, 1); /* true */ + return 1; + +} + +static int tex_run_main(lua_State * L) +{ + (void) L; + main_control(); return 0; } +static int tex_run_end(lua_State * L) +{ + (void) L; + final_cleanup(); /* prepare for death */ + close_files_and_terminate(); + do_final_end(); + return 0; +} + +void init_tex_table(lua_State * L) +{ + lua_createtable(L, 0, 3); + lua_pushcfunction(L, tex_run_boot); + lua_setfield(L, -2, "initialize"); + lua_pushcfunction(L, tex_run_main); + lua_setfield(L, -2, "run"); + lua_pushcfunction(L, tex_run_end); + lua_setfield(L, -2, "finish"); + lua_setglobal(L, "tex"); +} + + + static const struct luaL_reg texlib[] = { + {"run", tex_run_main}, /* may be needed */ + {"finish", tex_run_end}, /* may be needed */ + {"write", luacwrite}, {"write", luacwrite}, {"print", luacprint}, + {"tprint", luactprint}, {"sprint", luacsprint}, {"set", settex}, {"get", gettex}, @@ -1470,8 +2273,11 @@ static const struct luaL_reg texlib[] = { {"getboxht", getboxht}, {"setboxdp", setboxdp}, {"getboxdp", getboxdp}, + {"setnest", setnest}, + {"getnest", getnest}, {"round", tex_roundnumber}, {"scale", tex_scaletable}, + {"sp", tex_scaledimen}, {"fontname", getfontname}, {"fontidentifier", getfontidentifier}, {"pdffontname", getpdffontname}, @@ -1487,8 +2293,11 @@ static const struct luaL_reg texlib[] = { {"primitives", tex_primitives}, {"extraprimitives", tex_extraprimitives}, {"enableprimitives", tex_enableprimitives}, + {"shipout", tex_shipout}, + {"badness", tex_badness}, {"setmath", tex_setmathparm}, {"getmath", tex_getmathparm}, + {"linebreak", tex_run_linebreak}, {NULL, NULL} /* sentinel */ }; @@ -1506,7 +2315,9 @@ int luaopen_tex(lua_State * L) make_table(L, "ht", "getboxht", "setboxht"); make_table(L, "dp", "getboxdp", "setboxdp"); make_table(L, "lists", "getlist", "setlist"); + make_table(L, "nest", "getnest", "setnest"); /* *INDENT-ON* */ + init_nest_lib(L); /* make the meta entries */ /* fetch it back */ luaL_newmetatable(L, "tex_meta"); @@ -1525,6 +2336,5 @@ int luaopen_tex(lua_State * L) spindle_size = 1; /* a somewhat odd place for this assert, maybe */ assert(command_names[data_cmd].command_offset == data_cmd); - assert(param_int_pars == (get_count_base() - get_int_base())); return 1; } diff --git a/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c b/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c index 1ba1e609aef..02e6d84dff6 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c @@ -17,17 +17,11 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see . */ -#include "luatex-api.h" -#include -#include "tokens.h" +#include "lua/luatex-api.h" +#include "ptexlib.h" static const char _svn_version[] = - "$Id: ltokenlib.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/ltokenlib.c $"; - -static int max_command = 0; -static int null_cs = 0; - -#define protected_token 0x1C00001 + "$Id: ltokenlib.c 3404 2010-01-28 11:17:10Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/ltokenlib.c $"; #define is_valid_token(L,i) (lua_istable(L,i) && lua_objlen(L,i)==3) #define get_token_cmd(L,i) lua_rawgeti(L,i,1) @@ -36,17 +30,28 @@ static int null_cs = 0; #define is_active_string(s) (strlen((char *)s)>3 && *s==0xEF && *(s+1)==0xBF && *(s+2)==0xBF) +static unsigned char *get_cs_text(int cs) +{ + if (cs == null_cs) + return (unsigned char *) xstrdup("\\csname\\endcsname"); + else if ((cs_text(cs) < 0) || (cs_text(cs) >= str_ptr)) + return (unsigned char *) xstrdup(""); + else + return (unsigned char *) makecstring(cs_text(cs)); +} + + static int test_expandable(lua_State * L) { - integer cmd = -1; + int cmd = -1; if (is_valid_token(L, -1)) { get_token_cmd(L, -1); if (lua_isnumber(L, -1)) { - cmd = lua_tointeger(L, -1); + cmd = (int) lua_tointeger(L, -1); } else if (lua_isstring(L, -1)) { cmd = get_command_id(lua_tostring(L, -1)); } - if (cmd > max_command) { + if (cmd > max_command_cmd) { lua_pushboolean(L, 1); } else { lua_pushboolean(L, 0); @@ -60,15 +65,15 @@ static int test_expandable(lua_State * L) static int test_protected(lua_State * L) { - integer chr = -1; + int chr = -1; if (is_valid_token(L, -1)) { get_token_chr(L, -1); if (lua_isnumber(L, -1)) { - chr = lua_tointeger(L, -1); + chr = (int) lua_tointeger(L, -1); } else if (lua_isstring(L, -1)) { chr = get_command_id(lua_tostring(L, -1)); } - if (fixmem[fixmem[chr].hhrh].hhlh == protected_token) { + if (token_info(token_link(chr)) == protected_token) { lua_pushboolean(L, 1); } else { lua_pushboolean(L, 0); @@ -82,15 +87,14 @@ static int test_protected(lua_State * L) static int test_activechar(lua_State * L) { if (is_valid_token(L, -1)) { - str_number n; - integer cs = 0; + unsigned char *s; + int cs = 0; get_token_cs(L, -1); if (lua_isnumber(L, -1)) { - cs = lua_tointeger(L, -1); + cs = (int) lua_tointeger(L, -1); } lua_pop(L, 1); - if (cs != 0 && (n = zget_cs_text(cs)) && n > 0) { - unsigned char *s = (unsigned char *) makecstring(n); + if (cs != 0 && ((s = get_cs_text(cs)) != (unsigned char *) NULL)) { if (is_active_string(s)) { free(s); lua_pushboolean(L, 1); @@ -110,7 +114,7 @@ static int run_get_command_name(lua_State * L) if (is_valid_token(L, -1)) { get_token_cmd(L, -1); if (lua_isnumber(L, -1)) { - cs = lua_tointeger(L, -1); + cs = (int) lua_tointeger(L, -1); lua_pushstring(L, command_names[cs].cmd_name); } else { lua_pushstring(L, ""); @@ -124,23 +128,22 @@ static int run_get_command_name(lua_State * L) static int run_get_csname_name(lua_State * L) { - int cs, cmd, n; - + int cs, cmd; + unsigned char *s; if (is_valid_token(L, -1)) { get_token_cmd(L, -1); if (lua_isnumber(L, -1)) { - cmd = lua_tointeger(L, -1); + cmd = (int) lua_tointeger(L, -1); } lua_pop(L, 1); cs = 0; get_token_cs(L, -1); if (lua_isnumber(L, -1)) { - cs = lua_tointeger(L, -1); + cs = (int) lua_tointeger(L, -1); } lua_pop(L, 1); - if (cs != 0 && (n = zget_cs_text(cs)) && n >= 0) { - unsigned char *s = (unsigned char *) makecstring(n); + if (cs != 0 && ((s = get_cs_text(cs)) != (unsigned char *) NULL)) { if (is_active_string(s)) lua_pushstring(L, (char *) (s + 3)); else @@ -171,9 +174,9 @@ static int run_get_csname_id(lua_State * L) size_t k, cs = 0; if (lua_isstring(L, -1)) { s = lua_tolstring(L, -1, &k); - cs = string_lookup(s, k); + cs = (size_t) string_lookup(s, k); } - lua_pushnumber(L, cs); + lua_pushnumber(L, (lua_Number) cs); return 1; } @@ -212,17 +215,17 @@ static int run_lookup(lua_State * L) { const char *s; size_t l; - integer cs, cmd, chr; + int cs, cmd, chr; int save_nncs; if (lua_isstring(L, -1)) { s = lua_tolstring(L, -1, &l); if (l > 0) { save_nncs = no_new_control_sequence; no_new_control_sequence = true; - cs = id_lookup((last + 1), l); /* cleans up the lookup buffer */ + cs = id_lookup((last + 1), (int) l); /* cleans up the lookup buffer */ cs = string_lookup(s, l); - cmd = zget_eq_type(cs); - chr = zget_equiv(cs); + cmd = eq_type(cs); + chr = equiv(cs); make_token_table(L, cmd, chr, cs); no_new_control_sequence = save_nncs; return 1; @@ -234,11 +237,11 @@ static int run_lookup(lua_State * L) static int run_build(lua_State * L) { - integer cmd, chr, cs; + int cmd, chr, cs; if (lua_isnumber(L, 1)) { cs = 0; - chr = lua_tointeger(L, 1); - cmd = luaL_optinteger(L, 2, get_char_cat_code(chr)); + chr = (int) lua_tointeger(L, 1); + cmd = (int) luaL_optinteger(L, 2, get_char_cat_code(chr)); if (cmd == 0 || cmd == 9 || cmd == 14 || cmd == 15) { fprintf(stdout, "\n\nluatex error: not a good token.\nCatcode %i can not be returned, so I replaced it by 12 (other)", @@ -248,8 +251,8 @@ static int run_build(lua_State * L) } if (cmd == 13) { cs = active_to_cs(chr, false); - cmd = zget_eq_type(cs); - chr = zget_equiv(cs); + cmd = eq_type(cs); + chr = equiv(cs); } make_token_table(L, cmd, chr, cs); return 1; @@ -277,7 +280,5 @@ static const struct luaL_reg tokenlib[] = { int luaopen_token(lua_State * L) { luaL_register(L, "token", tokenlib); - max_command = get_max_command(); - null_cs = get_nullcs(); return 1; } diff --git a/Build/source/texk/web2c/luatexdir/lua/luagen.h b/Build/source/texk/web2c/luatexdir/lua/luagen.h new file mode 100644 index 00000000000..9ab2e8e8c2f --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/luagen.h @@ -0,0 +1,27 @@ +/* luagen.h + + Copyright 2009 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ + +/* $Id: luagen.h 3261 2009-12-18 11:38:21Z taco $ */ + +extern void lua_begin_page(PDF pdf); +extern void lua_end_page(PDF pdf); + +extern void lua_place_glyph(PDF pdf, internal_font_number f, int c); +extern void lua_place_rule(PDF pdf, scaledpos size); +extern void finish_lua_file(PDF pdf); diff --git a/Build/source/texk/web2c/luatexdir/lua/luagen.w b/Build/source/texk/web2c/luatexdir/lua/luagen.w new file mode 100644 index 00000000000..292176575c0 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/luagen.w @@ -0,0 +1,55 @@ +% luagen.w +% +% Copyright 2009 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: luagen.w 3583 2010-04-02 17:40:44Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/luagen.w $"; + +#include "ptexlib.h" +#include "pdf/pdfpage.h" + +@ @c +void lua_begin_page(PDF pdf) +{ + (void) pdf; +} + +void lua_end_page(PDF pdf) +{ + (void) pdf; +} + +void lua_place_glyph(PDF pdf, internal_font_number f, int c) +{ + (void) pdf; + (void) f; + printf("%c", (int) c); +} + +void lua_place_rule(PDF pdf, scaledpos size) +{ + (void) pdf; + (void) size; +} + +void finish_lua_file(PDF pdf) +{ + (void) pdf; +} diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.c b/Build/source/texk/web2c/luatexdir/lua/luainit.c deleted file mode 100644 index 917cf462f7e..00000000000 --- a/Build/source/texk/web2c/luatexdir/lua/luainit.c +++ /dev/null @@ -1,655 +0,0 @@ -/* luainit.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include - -#include "luatex-api.h" -#include - -#include - -static const char _svn_version[] = - "$Id: luainit.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/luainit.c $"; - -/* TH: TODO - * - * This file is getting a bit messy, but it is not simple to fix unilaterally. - * - * Better to wait until Karl has some time (after texlive 2008) so we can - * synchronize with kpathsea. One problem, for instance, is that I would - * like to resolve the full executable path. kpse_set_program_name() does - * that, indirectly (by setting SELFAUTOLOC in the environment), but it - * does much more, making it hard to use for our purpose. - * - * In fact, it sets three C variables: - * program_invocation_name program_invocation_short_name kpse->program_name - * and four environment variables: - * SELFAUTOLOC SELFAUTODIR SELFAUTOPARENT progname - * - */ - -const_string LUATEX_IHELP[] = { - "Usage: luatex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS]", - " or: luatex --lua=FILE [OPTION]... \\FIRST-LINE", - " or: luatex --lua=FILE [OPTION]... &FMT ARGS", - " Run LuaTeX on TEXNAME, usually creating TEXNAME.pdf.", - " Any remaining COMMANDS are processed as luatex input, after TEXNAME is read.", - "", - " Alternatively, if the first non-option argument begins with a backslash,", - " luatex interprets all non-option arguments as an input line.", - "", - " Alternatively, if the first non-option argument begins with a &, the", - " next word is taken as the FMT to read, overriding all else. Any", - " remaining arguments are processed as above.", - "", - " If no arguments or options are specified, prompt for input.", - "", - " --lua=FILE the lua initialization file", - " --nosocket disable the luasocket (network) library", - " --safer disable easily exploitable lua commands", - " --fmt=FORMAT load the format file FORMAT", - " --ini be initex, for dumping formats", - " --help display this help and exit", - " --version output version information and exit", - "", - " Alternate behaviour models can be obtained by special switches", - "", - " --luaonly run a lua file, then exit", - " --luaconly byte-compile a lua file, then exit", - NULL -}; - -static char *ex_selfdir(char *argv0) -{ -#if defined(WIN32) - char short_path[PATH_MAX], path[PATH_MAX], *fp; - - /* SearchPath() always gives back an absolute directory */ - if (SearchPath(NULL, argv0, ".exe", PATH_MAX, short_path, &fp) == 0) - FATAL1("Can't determine where the executable %s is.\n", argv0); - if (!win32_get_long_filename(short_path, path, sizeof(path))) { - FATAL1("This path points to an invalid file : %s\n", short_path); - } - /* slashify the dirname */ - for (fp = path; fp && *fp; fp++) - if (IS_DIR_SEP(*fp)) - *fp = DIR_SEP; - /* sdir will be the directory of the executable, ie: c:/TeX/bin */ - return xdirname(path); -#else - return kpse_selfdir(argv0); -#endif -} - -static void -prepare_cmdline(lua_State * L, char **argv, int argc, int zero_offset) -{ - int i; - char *s; - luaL_checkstack(L, argc + 3, "too many arguments to script"); - lua_createtable(L, 0, 0); - for (i = 0; i < argc; i++) { - lua_pushstring(L, argv[i]); - lua_rawseti(L, -2, (i - zero_offset)); - } - lua_setglobal(L, "arg"); - lua_getglobal(L, "os"); - s = ex_selfdir(argv[0]); - lua_pushstring(L, s); - xfree(s); - lua_setfield(L, -2, "selfdir"); - return; -} - -const_string input_name = NULL; - -static const_string user_progname = NULL; - -const char *startup_filename = NULL; -int lua_only = 0; -int lua_offset = 0; - -int safer_option = 0; -int nosocket_option = 0; - -/* Reading the options. */ - -/* Test whether getopt found an option ``A''. - Assumes the option index is in the variable `option_index', and the - option table in a variable `long_options'. */ -#define ARGUMENT_IS(a) STREQ (long_options[option_index].name, a) - -/* SunOS cc can't initialize automatic structs, so make this static. */ -static struct option long_options[] -= { {"fmt", 1, 0, 0}, -{"lua", 1, 0, 0}, -{"luaonly", 0, 0, 0}, -{"safer", 0, &safer_option, 1}, -{"nosocket", 0, &nosocket_option, 1}, -{"help", 0, 0, 0}, -{"ini", 0, &ini_version, 1}, -{"interaction", 1, 0, 0}, -{"halt-on-error", 0, &haltonerrorp, 1}, -{"kpathsea-debug", 1, 0, 0}, -{"progname", 1, 0, 0}, -{"version", 0, 0, 0}, -{"credits", 0, 0, 0}, -{"recorder", 0, &recorder_enabled, 1}, -{"etex", 0, 0, 0}, -{"output-comment", 1, 0, 0}, -{"output-directory", 1, 0, 0}, -{"draftmode", 0, 0, 0}, -{"output-format", 1, 0, 0}, -{"shell-escape", 0, &shellenabledp, 1}, -{"no-shell-escape", 0, &shellenabledp, -1}, -{"shell-escape", 0, &shellenabledp, 1}, -{"no-shell-escape", 0, &shellenabledp, -1}, -{"enable-write18", 0, &shellenabledp, 1}, -{"disable-write18", 0, &shellenabledp, -1}, -{"shell-restricted", 0, 0, 0}, -{"debug-format", 0, &debug_format_file, 1}, -{"file-line-error-style", 0, &filelineerrorstylep, 1}, -{"no-file-line-error-style", 0, &filelineerrorstylep, -1}, - /* Shorter option names for the above. */ -{"file-line-error", 0, &filelineerrorstylep, 1}, -{"no-file-line-error", 0, &filelineerrorstylep, -1}, -{"jobname", 1, 0, 0}, -{"parse-first-line", 0, &parsefirstlinep, 1}, -{"no-parse-first-line", 0, &parsefirstlinep, -1}, -{"translate-file", 1, 0, 0}, -{"default-translate-file", 1, 0, 0}, -{"8bit", 0, 0, 0}, -{"mktex", 1, 0, 0}, -{"no-mktex", 1, 0, 0}, -/* Synchronization: just like "interaction" above */ -{"synctex", 1, 0, 0}, -{0, 0, 0, 0} -}; - -static void parse_options(int argc, char **argv) -{ - int g; /* `getopt' return code. */ - int option_index; - char *firstfile = NULL; - opterr = 0; /* dont whine */ - for (;;) { - g = getopt_long_only(argc, argv, "+", long_options, &option_index); - - if (g == -1) /* End of arguments, exit the loop. */ - break; - if (g == '?') /* Unknown option. */ - continue; - - assert(g == 0); /* We have no short option names. */ - - if (ARGUMENT_IS("luaonly")) { - lua_only = 1; - lua_offset = optind; - luainit = 1; - } else if (ARGUMENT_IS("lua")) { - startup_filename = optarg; - lua_offset = (optind - 1); - luainit = 1; - - } else if (ARGUMENT_IS("kpathsea-debug")) { - kpathsea_debug |= atoi(optarg); - - } else if (ARGUMENT_IS("progname")) { - user_progname = optarg; - - } else if (ARGUMENT_IS("jobname")) { - c_job_name = optarg; - - } else if (ARGUMENT_IS("fmt")) { - dump_name = optarg; - - } else if (ARGUMENT_IS("output-directory")) { - output_directory = optarg; - - } else if (ARGUMENT_IS("output-comment")) { - unsigned len = strlen(optarg); - if (len < 256) { - output_comment = optarg; - } else { - WARNING2("Comment truncated to 255 characters from %d. (%s)", - len, optarg); - output_comment = (string) xmalloc(256); - strncpy(output_comment, optarg, 255); - output_comment[255] = 0; - } - - } else if (ARGUMENT_IS("shell-restricted")) { - shellenabledp = 1; - restrictedshell = 1; - - } else if (ARGUMENT_IS("output-format")) { - pdf_output_option = 1; - if (strcmp(optarg, "dvi") == 0) { - pdf_output_value = 0; - } else if (strcmp(optarg, "pdf") == 0) { - pdf_output_value = 2; - } else { - WARNING1("Ignoring unknown value `%s' for --output-format", - optarg); - pdf_output_option = 0; - } - - } else if (ARGUMENT_IS("draftmode")) { - pdf_draftmode_option = 1; - pdf_draftmode_value = 1; - - } else if (ARGUMENT_IS("mktex")) { - kpse_maketex_option(optarg, true); - - } else if (ARGUMENT_IS("no-mktex")) { - kpse_maketex_option(optarg, false); - - } else if (ARGUMENT_IS("interaction")) { - /* These numbers match @d's in *.ch */ - if (STREQ(optarg, "batchmode")) { - interactionoption = 0; - } else if (STREQ(optarg, "nonstopmode")) { - interactionoption = 1; - } else if (STREQ(optarg, "scrollmode")) { - interactionoption = 2; - } else if (STREQ(optarg, "errorstopmode")) { - interactionoption = 3; - } else { - WARNING1("Ignoring unknown argument `%s' to --interaction", - optarg); - } - - } else if (ARGUMENT_IS("synctex")) { - /* Synchronize TeXnology: catching the command line option as a long */ - synctexoption = (int) strtol(optarg, NULL, 0); - - } else if (ARGUMENT_IS("help")) { - usagehelp(LUATEX_IHELP, BUG_ADDRESS); - - } else if (ARGUMENT_IS("version")) { - print_version_banner(); - /* *INDENT-OFF* */ - puts("\n\nExecute 'luatex --credits' for credits and version details.\n\n" - "There is NO warranty. Redistribution of this software is covered by\n" - "the terms of the GNU General Public License, version 2. For more\n" - "information about these matters, see the file named COPYING and\n" - "the LuaTeX source.\n\n" - "Copyright 2009 Taco Hoekwater, the LuaTeX Team.\n"); - /* *INDENT-ON* */ - uexit(0); - } else if (ARGUMENT_IS("credits")) { - char *versions; - initversionstring(&versions); - print_version_banner(); - /* *INDENT-OFF* */ - puts("\n\nThe LuaTeX team is Hans Hagen, Hartmut Henkel, Taco Hoekwater.\n" - "LuaTeX merges and builds upon (parts of) the code from these projects:\n\n" - "tex by Donald Knuth\n" - "etex by Peter Breitenlohner, Phil Taylor and friends\n" - "omega by John Plaice and Yannis Haralambous\n" - "aleph by Giuseppe Bilotta\n" - "pdftex by Han The Thanh and friends\n" - "kpathsea by Karl Berry, Olaf Weber and others\n" - "lua by Roberto Ierusalimschy, Waldemar Celes,\n" - " Luiz Henrique de Figueiredo\n" - "metapost by John Hobby, Taco Hoekwater and friends.\n" - "xpdf by Derek Noonburg (partial)\n" - "fontforge by George Williams (partial)\n\n" - "Some extensions to lua and additional lua libraries are used, as well as\n" - "libraries for graphic inclusion. More details can be found in the source.\n" - "Code development was sponsored by a grant from Colorado State University\n" - "via the 'oriental tex' project, the TeX User Groups, and donations.\n"); - /* *INDENT-ON* */ - puts(versions); - uexit(0); - } - } - /* attempt to find dump_name */ - if (argv[optind] && argv[optind][0] == '&') { - dump_name = strdup(argv[optind] + 1); - } else if (argv[optind] && argv[optind][0] != '\\') { - if (argv[optind][0] == '*') { - input_name = strdup(argv[optind] + 1); - } else { - firstfile = strdup(argv[optind]); - if (lua_only) { - startup_filename = firstfile; - } else { - if ((strstr(firstfile, ".lua") == - firstfile + strlen(firstfile) - 4) - || (strstr(firstfile, ".luc") == - firstfile + strlen(firstfile) - 4) - || (strstr(firstfile, ".LUA") == - firstfile + strlen(firstfile) - 4) - || (strstr(firstfile, ".LUC") == - firstfile + strlen(firstfile) - 4) - || (strstr(argv[0], "luatexlua") != NULL) - || (strstr(argv[0], "texlua") != NULL)) { - startup_filename = firstfile; - lua_only = 1; - lua_offset = optind; - luainit = 1; - } else { - input_name = firstfile; - } - } - } - } else { - if ((strstr(argv[0], "luatexlua") != NULL) || - (strstr(argv[0], "texlua") != NULL)) { - lua_only = 1; - luainit = 1; - } - } - if (safer_option) /* --safer implies --nosocket */ - nosocket_option = 1; - - /* Finalize the input filename. */ - if (input_name != NULL) { - argv[optind] = normalize_quotes(input_name, "argument"); - } -} - -/* test for readability */ -#define is_readable(a) (stat(a,&finfo)==0) && S_ISREG(finfo.st_mode) && \ - (f=fopen(a,"r")) != NULL && !fclose(f) - -static const char *find_filename(const char *name, const char *envkey) -{ - struct stat finfo; - char *dirname = NULL; - char *filename = NULL; - FILE *f; - if (is_readable(name)) { - return name; - } else { - dirname = getenv(envkey); - if ((dirname != NULL) && strlen(dirname)) { - dirname = strdup(getenv(envkey)); - if (*(dirname + strlen(dirname) - 1) == '/') { - *(dirname + strlen(dirname) - 1) = 0; - } - filename = xmalloc(strlen(dirname) + strlen(name) + 2); - filename = concat3(dirname, "/", name); - if (is_readable(filename)) { - xfree(dirname); - return filename; - } - xfree(filename); - } - } - return NULL; -} - - -static char *cleaned_invocation_name(char *arg) -{ - char *ret, *dot; - const char *start = xbasename(arg); - ret = xstrdup(start); - dot = index(ret, '.'); - if (dot != NULL) { - *dot = 0; /* chop */ - } - return ret; -} - -static void init_kpse(void) -{ - - if (!user_progname) { - user_progname = dump_name; - } else if (!dump_name) { - dump_name = user_progname; - } - if (!user_progname) { - if (ini_version) { - user_progname = input_name; - if (!user_progname) { - user_progname = cleaned_invocation_name(argv[0]); - } - } else { - if (!dump_name) { - dump_name = cleaned_invocation_name(argv[0]); - } - user_progname = dump_name; - } - } - kpse_set_program_enabled(kpse_fmt_format, MAKE_TEX_FMT_BY_DEFAULT, - kpse_src_compile); - - kpse_set_program_name(argv[0], user_progname); - init_shell_escape(); /* set up 'restrictedshell' */ - program_name_set = 1; -} - -static void fix_dumpname(void) -{ - int dist; - if (dump_name) { - /* adjust array for Pascal and provide extension, if needed */ - dist = strlen(dump_name) - strlen(DUMP_EXT); - if (strstr(dump_name, DUMP_EXT) == dump_name + dist) - DUMP_VAR = concat(" ", dump_name); - else - DUMP_VAR = concat3(" ", dump_name, DUMP_EXT); - DUMP_LENGTH_VAR = strlen(DUMP_VAR + 1); - } else { - /* For dump_name to be NULL is a bug. */ - if (!ini_version) - abort(); - } -} - -void lua_initialize(int ac, char **av) -{ - - char *given_file = NULL; - int kpse_init; - int tex_table_id; - int pdf_table_id; - int token_table_id; - int node_table_id; - /* Non-const initialized variables for putenv(). */ - static char LC_CTYPE_C[] = "LC_CTYPE=C"; - static char LC_COLLATE_C[] = "LC_COLLATE=C"; - static char LC_NUMERIC_C[] = "LC_NUMERIC=C"; - static char engine_luatex[] = "engine=luatex"; - /* Save to pass along to topenin. */ - argc = ac; - argv = av; - - ptexbanner = BANNER; - - program_invocation_name = cleaned_invocation_name(argv[0]); - - /* be 'luac' */ - if (argc > 1 && - (STREQ(program_invocation_name, "texluac") || - STREQ(argv[1], "--luaconly") || STREQ(argv[1], "--luac"))) { - exit(luac_main(ac, av)); - } - - /* Must be initialized before options are parsed. */ - interactionoption = 4; - dump_name = NULL; - - /* 0 means "disable Synchronize TeXnology". - * synctexoption is a *.web variable. - * We initialize it to a weird value to catch the -synctex command line flag - * At runtime, if synctexoption is not INT_MAX, then it contains the command line option provided, - * otherwise no such option was given by the user. */ -#define SYNCTEX_NO_OPTION INT_MAX - synctexoption = SYNCTEX_NO_OPTION; - - /* parse commandline */ - parse_options(ac, av); - if (lua_only) - shellenabledp = true; - - /* make sure that the locale is 'sane' (for lua) */ - putenv(LC_CTYPE_C); - putenv(LC_COLLATE_C); - putenv(LC_NUMERIC_C); - - /* this is sometimes needed */ - putenv(engine_luatex); - - luainterpreter(); - - prepare_cmdline(Luas, argv, argc, lua_offset); /* collect arguments */ - - if (startup_filename != NULL) { - given_file = xstrdup(startup_filename); - startup_filename = find_filename(startup_filename, "LUATEXDIR"); - } - /* now run the file */ - if (startup_filename != NULL) { - const char *v1; - /* hide the 'tex' and 'pdf' table */ - tex_table_id = hide_lua_table(Luas, "tex"); - token_table_id = hide_lua_table(Luas, "token"); - node_table_id = hide_lua_table(Luas, "node"); - pdf_table_id = hide_lua_table(Luas, "pdf"); - - if (luaL_loadfile(Luas, startup_filename)) { - fprintf(stdout, "%s\n", lua_tostring(Luas, -1)); - exit(1); - } - if (lua_pcall(Luas, 0, 0, 0)) { - fprintf(stdout, "%s\n", lua_tostring(Luas, -1)); - exit(1); - } - /* no filename? quit now! */ - if (!input_name) { - get_lua_string("texconfig", "jobname", &input_name); - } - if (!dump_name) { - get_lua_string("texconfig", "formatname", &dump_name); - } - if ((lua_only) || ((!input_name) && (!dump_name))) { - if (given_file) - free(given_file); - /* this is not strictly needed but it pleases valgrind */ - lua_close(Luas); - exit(0); - } - /* unhide the 'tex' and 'pdf' table */ - unhide_lua_table(Luas, "tex", tex_table_id); - unhide_lua_table(Luas, "pdf", pdf_table_id); - unhide_lua_table(Luas, "token", token_table_id); - unhide_lua_table(Luas, "node", node_table_id); - - /* kpse_init */ - kpse_init = -1; - get_lua_boolean("texconfig", "kpse_init", &kpse_init); - - if (kpse_init != 0) { - luainit = 0; /* re-enable loading of texmf.cnf values, see luatex.ch */ - init_kpse(); - } - /* prohibit_file_trace (boolean) */ - tracefilenames = 1; - get_lua_boolean("texconfig", "trace_file_names", &tracefilenames); - - /* file_line_error */ - filelineerrorstylep = false; - get_lua_boolean("texconfig", "file_line_error", &filelineerrorstylep); - - /* halt_on_error */ - haltonerrorp = false; - get_lua_boolean("texconfig", "halt_on_error", &haltonerrorp); - - /* restrictedshell */ - v1 = NULL; - get_lua_string("texconfig", "shell_escape", &v1); - if (v1) { - if (*v1 == 't' || *v1 == 'y' || *v1 == '1') { - shellenabledp = 1; - } else if (*v1 == 'p') { - shellenabledp = 1; - restrictedshell = 1; - } - } - /* If shell escapes are restricted, get allowed cmds from cnf. */ - if (shellenabledp && restrictedshell == 1) { - v1 = NULL; - get_lua_string("texconfig", "shell_escape_commands", &v1); - if (v1) { - mk_shellcmdlist(v1); - } - } - - fix_dumpname(); - - } else { - if (luainit) { - if (given_file) { - fprintf(stdout, "%s file %s not found\n", - (lua_only ? "Script" : "Configuration"), given_file); - free(given_file); - } else { - fprintf(stdout, "No %s file given\n", - (lua_only ? "script" : "configuration")); - } - exit(1); - } else { - /* init */ - init_kpse(); - fix_dumpname(); - } - } -} - -void check_texconfig_init(void) -{ - if (Luas != NULL) { - lua_getglobal(Luas, "texconfig"); - if (lua_istable(Luas, -1)) { - lua_getfield(Luas, -1, "init"); - if (lua_isfunction(Luas, -1)) { - int i = lua_pcall(Luas, 0, 0, 0); - if (i != 0) { - /* Can't be more precise here, called before TeX initialization */ - fprintf(stderr, "This went wrong: %s\n", - lua_tostring(Luas, -1)); - error(); - } - } - } - } -} - -void write_svnversion(const char *v) -{ - char *a_head, *n; - char *a = strdup(v); - size_t l = strlen("$Id: luatex.web "); - if (a != NULL) { - a_head = a; - if (strlen(a) > l) - a += l; - n = a; - while (*n != '\0' && *n != ' ') - n++; - *n = '\0'; - fprintf(stdout, " luatex.web >= v%s", a); - free(a_head); - } -} diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w new file mode 100644 index 00000000000..cd8c8872a7f --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w @@ -0,0 +1,930 @@ +% luainit.w +% +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "openbsd-compat.h" +#ifdef HAVE_ASPRINTF /* asprintf is not defined in openbsd-compat.h, but in stdio.h */ +# include +#endif +#include + +#include "lua/luatex-api.h" +#include "ptexlib.h" + +static const char _svn_version[] = + "$Id: luainit.w 3583 2010-04-02 17:40:44Z hhenkel $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/luainit.w $"; + +@ +TH: TODO + +This file is getting a bit messy, but it is not simple to fix unilaterally. + +Better to wait until Karl has some time (after texlive 2008) so we can +synchronize with kpathsea. One problem, for instance, is that I would +like to resolve the full executable path. |kpse_set_program_name()| does +that, indirectly (by setting SELFAUTOLOC in the environment), but it +does much more, making it hard to use for our purpose. + +In fact, it sets three C variables: + + |program_invocation_name| |program_invocation_short_name| |kpse->program_name| + +and four environment variables: + + SELFAUTOLOC SELFAUTODIR SELFAUTOPARENT progname + +@c +const_string LUATEX_IHELP[] = { + "Usage: luatex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS]", + " or: luatex --lua=FILE [OPTION]... \\FIRST-LINE", + " or: luatex --lua=FILE [OPTION]... &FMT ARGS", + " Run LuaTeX on TEXNAME, usually creating TEXNAME.pdf.", + " Any remaining COMMANDS are processed as luatex input, after TEXNAME is read.", + "", + " Alternatively, if the first non-option argument begins with a backslash,", + " luatex interprets all non-option arguments as an input line.", + "", + " Alternatively, if the first non-option argument begins with a &, the", + " next word is taken as the FMT to read, overriding all else. Any", + " remaining arguments are processed as above.", + "", + " If no arguments or options are specified, prompt for input.", + "", + " The following regular options are understood: ", + "", + " --8bit ignored, input is assumed to be in UTF-8 encoding", + " --credits display credits and exit", + " --debug-format enable format debugging", + " --default-translate-file= ignored, input is assumed to be in UTF-8 encoding", + " --disable-write18 disable \\write18{SHELL COMMAND}", + " --draftmode switch on draft mode (generates no output PDF)", + " --enable-write18 enable \\write18{SHELL COMMAND}", + " --etex ignored, the etex extensions are always active", + " --[no-]file-line-error disable/enable file:line:error style messages", + " --[no-]file-line-error-style aliases of --[no-]file-line-error", + " --fmt=FORMAT load the format file FORMAT", + " --halt-on-error stop processing at the first error", + " --help display help and exit", + " --ini be iniluatex, for dumping formats", + " --interaction=STRING set interaction mode (STRING=batchmode/nonstopmode/scrollmode/errorstopmode)", + " --jobname=STRING set the job name to STRING", + " --kpathsea-debug=NUMBER set path searching debugging flags according to the bits of NUMBER", + " --lua=s load and execute a lua initialization script", + " --[no-]mktex=FMT disable/enable mktexFMT generation (FMT=tex/tfm)", + " --nosocket disable the lua socket library", + " --output-comment=STRING use STRING for DVI file comment instead of date (no effect for PDF)", + " --output-directory=DIR use DIR as the directory to write files to", + " --output-format=FORMAT use FORMAT for job output; FORMAT is 'dvi' or 'pdf'", + " --[no-]parse-first-line disable/enable parsing of the first line of the input file", + " --progname=STRING set the program name to STRING", + " --recorder enable filename recorder", + " --safer disable easily exploitable lua commands", + " --[no-]shell-escape disable/enable \\write18{SHELL COMMAND}", + " --shell-restricted restrict \\write18 to a list of commands given in texmf.cnf", + " --synctex=NUMBER enable synctex", + " --translate-file= ignored, input is assumed to be in UTF-8 encoding", + " --version display version and exit", + "", + "Alternate behaviour models can be obtained by special switches", + "", + " --luaonly run a lua file, then exit", + " --luaconly byte-compile a lua file, then exit", + "", + "See the reference manual for more information about the startup process.", + NULL +}; + +@ @c +char *ex_selfdir(char *argv0) +{ +#if defined(WIN32) + char short_path[PATH_MAX], path[PATH_MAX], *fp; + + /* SearchPath() always gives back an absolute directory */ + if (SearchPath(NULL, argv0, ".exe", PATH_MAX, short_path, &fp) == 0) + FATAL1("Can't determine where the executable %s is.\n", argv0); + /* slashify the dirname */ + for (fp = path; fp && *fp; fp++) + if (IS_DIR_SEP(*fp)) + *fp = DIR_SEP; + /* sdir will be the directory of the executable, ie: c:/TeX/bin */ + return xdirname(path); +#else + return kpse_selfdir(argv0); +#endif +} + +@ @c +static void +prepare_cmdline(lua_State * L, char **argv, int argc, int zero_offset) +{ + int i; + char *s; + luaL_checkstack(L, argc + 3, "too many arguments to script"); + lua_createtable(L, 0, 0); + for (i = 0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, (i - zero_offset)); + } + lua_setglobal(L, "arg"); + lua_getglobal(L, "os"); + s = ex_selfdir(argv[0]); + lua_pushstring(L, s); + xfree(s); + lua_setfield(L, -2, "selfdir"); + return; +} + +@ @c +string input_name = NULL; + +static string user_progname = NULL; + +char *startup_filename = NULL; +int lua_only = 0; +int lua_offset = 0; + +int safer_option = 0; +int nosocket_option = 0; + +@ Reading the options. + +@ Test whether getopt found an option ``A''. +Assumes the option index is in the variable |option_index|, and the +option table in a variable |long_options|. + +@c +#define ARGUMENT_IS(a) STREQ (long_options[option_index].name, a) + +/* SunOS cc can't initialize automatic structs, so make this static. */ +static struct option long_options[] += { {"fmt", 1, 0, 0}, +{"lua", 1, 0, 0}, +{"luaonly", 0, 0, 0}, +{"safer", 0, &safer_option, 1}, +{"nosocket", 0, &nosocket_option, 1}, +{"help", 0, 0, 0}, +{"ini", 0, &ini_version, 1}, +{"interaction", 1, 0, 0}, +{"halt-on-error", 0, &haltonerrorp, 1}, +{"kpathsea-debug", 1, 0, 0}, +{"progname", 1, 0, 0}, +{"version", 0, 0, 0}, +{"credits", 0, 0, 0}, +{"recorder", 0, &recorder_enabled, 1}, +{"etex", 0, 0, 0}, +{"output-comment", 1, 0, 0}, +{"output-directory", 1, 0, 0}, +{"draftmode", 0, 0, 0}, +{"output-format", 1, 0, 0}, +{"shell-escape", 0, &shellenabledp, 1}, +{"no-shell-escape", 0, &shellenabledp, -1}, +{"enable-write18", 0, &shellenabledp, 1}, +{"disable-write18", 0, &shellenabledp, -1}, +{"shell-restricted", 0, 0, 0}, +{"debug-format", 0, &debug_format_file, 1}, +{"file-line-error-style", 0, &filelineerrorstylep, 1}, +{"no-file-line-error-style", 0, &filelineerrorstylep, -1}, + /* Shorter option names for the above. */ +{"file-line-error", 0, &filelineerrorstylep, 1}, +{"no-file-line-error", 0, &filelineerrorstylep, -1}, +{"jobname", 1, 0, 0}, +{"parse-first-line", 0, &parsefirstlinep, 1}, +{"no-parse-first-line", 0, &parsefirstlinep, -1}, +{"translate-file", 1, 0, 0}, +{"default-translate-file", 1, 0, 0}, +{"8bit", 0, 0, 0}, +{"mktex", 1, 0, 0}, +{"no-mktex", 1, 0, 0}, +/* Synchronization: just like "interaction" above */ +{"synctex", 1, 0, 0}, +{0, 0, 0, 0} +}; + +@ @c +static void parse_options(int argc, char **argv) +{ + int g; /* `getopt' return code. */ + int option_index; + char *firstfile = NULL; + opterr = 0; /* dont whine */ + for (;;) { + g = getopt_long_only(argc, argv, "+", long_options, &option_index); + + if (g == -1) /* End of arguments, exit the loop. */ + break; + if (g == '?') /* Unknown option. */ + continue; + + assert(g == 0); /* We have no short option names. */ + + if (ARGUMENT_IS("luaonly")) { + lua_only = 1; + lua_offset = optind; + luainit = 1; + } else if (ARGUMENT_IS("lua")) { + startup_filename = optarg; + lua_offset = (optind - 1); + luainit = 1; + + } else if (ARGUMENT_IS("kpathsea-debug")) { + kpathsea_debug |= atoi(optarg); + + } else if (ARGUMENT_IS("progname")) { + user_progname = optarg; + + } else if (ARGUMENT_IS("jobname")) { + c_job_name = optarg; + + } else if (ARGUMENT_IS("fmt")) { + dump_name = optarg; + + } else if (ARGUMENT_IS("output-directory")) { + output_directory = optarg; + + } else if (ARGUMENT_IS("output-comment")) { + size_t len = strlen(optarg); + if (len < 256) { + output_comment = optarg; + } else { + WARNING2("Comment truncated to 255 characters from %d. (%s)", + (int) len, optarg); + output_comment = (string) xmalloc(256); + strncpy(output_comment, optarg, 255); + output_comment[255] = 0; + } + + } else if (ARGUMENT_IS("shell-restricted")) { + shellenabledp = 1; + restrictedshell = 1; + + } else if (ARGUMENT_IS("output-format")) { + pdf_output_option = 1; + if (strcmp(optarg, "dvi") == 0) { + pdf_output_value = 0; + } else if (strcmp(optarg, "pdf") == 0) { + pdf_output_value = 2; + } else { + WARNING1("Ignoring unknown value `%s' for --output-format", + optarg); + pdf_output_option = 0; + } + + } else if (ARGUMENT_IS("draftmode")) { + pdf_draftmode_option = 1; + pdf_draftmode_value = 1; + + } else if (ARGUMENT_IS("mktex")) { + kpse_maketex_option(optarg, true); + + } else if (ARGUMENT_IS("no-mktex")) { + kpse_maketex_option(optarg, false); + + } else if (ARGUMENT_IS("interaction")) { + /* These numbers match CPP defines */ + if (STREQ(optarg, "batchmode")) { + interactionoption = 0; + } else if (STREQ(optarg, "nonstopmode")) { + interactionoption = 1; + } else if (STREQ(optarg, "scrollmode")) { + interactionoption = 2; + } else if (STREQ(optarg, "errorstopmode")) { + interactionoption = 3; + } else { + WARNING1("Ignoring unknown argument `%s' to --interaction", + optarg); + } + + } else if (ARGUMENT_IS("synctex")) { + /* Synchronize TeXnology: catching the command line option as a long */ + synctexoption = (int) strtol(optarg, NULL, 0); + + } else if (ARGUMENT_IS("help")) { + usagehelp(LUATEX_IHELP, BUG_ADDRESS); + + } else if (ARGUMENT_IS("version")) { + print_version_banner(); + /* *INDENT-OFF* */ + puts("\n\nExecute 'luatex --credits' for credits and version details.\n\n" + "There is NO warranty. Redistribution of this software is covered by\n" + "the terms of the GNU General Public License, version 2. For more\n" + "information about these matters, see the file named COPYING and\n" + "the LuaTeX source.\n\n" + "Copyright 2009 Taco Hoekwater, the LuaTeX Team.\n"); + /* *INDENT-ON* */ + uexit(0); + } else if (ARGUMENT_IS("credits")) { + char *versions; + initversionstring(&versions); + print_version_banner(); + /* *INDENT-OFF* */ + puts("\n\nThe LuaTeX team is Hans Hagen, Hartmut Henkel, Taco Hoekwater.\n" + "LuaTeX merges and builds upon (parts of) the code from these projects:\n\n" + "tex by Donald Knuth\n" + "etex by Peter Breitenlohner, Phil Taylor and friends\n" + "omega by John Plaice and Yannis Haralambous\n" + "aleph by Giuseppe Bilotta\n" + "pdftex by Han The Thanh and friends\n" + "kpathsea by Karl Berry, Olaf Weber and others\n" + "lua by Roberto Ierusalimschy, Waldemar Celes,\n" + " Luiz Henrique de Figueiredo\n" + "metapost by John Hobby, Taco Hoekwater and friends.\n" + "xpdf by Derek Noonburg (partial)\n" + "fontforge by George Williams (partial)\n\n" + "Some extensions to lua and additional lua libraries are used, as well as\n" + "libraries for graphic inclusion. More details can be found in the source.\n" + "Code development was sponsored by a grant from Colorado State University\n" + "via the 'oriental tex' project, the TeX User Groups, and donations.\n"); + /* *INDENT-ON* */ + puts(versions); + uexit(0); + } + } + /* attempt to find |dump_name| */ + if (argv[optind] && argv[optind][0] == '&') { + dump_name = strdup(argv[optind] + 1); + } else if (argv[optind] && argv[optind][0] != '\\') { + if (argv[optind][0] == '*') { + input_name = strdup(argv[optind] + 1); + } else { + firstfile = strdup(argv[optind]); + if (lua_only) { + startup_filename = firstfile; + } else { + if ((strstr(firstfile, ".lua") == + firstfile + strlen(firstfile) - 4) + || (strstr(firstfile, ".luc") == + firstfile + strlen(firstfile) - 4) + || (strstr(firstfile, ".LUA") == + firstfile + strlen(firstfile) - 4) + || (strstr(firstfile, ".LUC") == + firstfile + strlen(firstfile) - 4) + || (strstr(argv[0], "luatexlua") != NULL) + || (strstr(argv[0], "texlua") != NULL)) { + startup_filename = firstfile; + lua_only = 1; + lua_offset = optind; + luainit = 1; + } else { + input_name = firstfile; + } + } + } + } else { + if ((strstr(argv[0], "luatexlua") != NULL) || + (strstr(argv[0], "texlua") != NULL)) { + lua_only = 1; + luainit = 1; + } + } + if (safer_option) /* --safer implies --nosocket */ + nosocket_option = 1; + + /* Finalize the input filename. */ + if (input_name != NULL) { + argv[optind] = normalize_quotes(input_name, "argument"); + } +} + +@ test for readability +@c +#define is_readable(a) (stat(a,&finfo)==0) && S_ISREG(finfo.st_mode) && \ + (f=fopen(a,"r")) != NULL && !fclose(f) + +@ @c +static char *find_filename(char *name, const char *envkey) +{ + struct stat finfo; + char *dirname = NULL; + char *filename = NULL; + FILE *f; + if (is_readable(name)) { + return name; + } else { + dirname = getenv(envkey); + if ((dirname != NULL) && strlen(dirname)) { + dirname = strdup(getenv(envkey)); + if (*(dirname + strlen(dirname) - 1) == '/') { + *(dirname + strlen(dirname) - 1) = 0; + } + filename = xmalloc((unsigned) (strlen(dirname) + strlen(name) + 2)); + filename = concat3(dirname, "/", name); + if (is_readable(filename)) { + xfree(dirname); + return filename; + } + xfree(filename); + } + } + return NULL; +} + + +@ @c +char *cleaned_invocation_name(char *arg) +{ + char *ret, *dot; + const char *start = xbasename(arg); + ret = xstrdup(start); + dot = index(ret, '.'); + if (dot != NULL) { + *dot = 0; /* chop */ + } + return ret; +} + +@ @c +void init_kpse(void) +{ + + if (!user_progname) { + user_progname = dump_name; + } else if (!dump_name) { + dump_name = user_progname; + } + if (!user_progname) { + if (ini_version) { + user_progname = input_name; + if (!user_progname) { + user_progname = cleaned_invocation_name(argv[0]); + } + } else { + if (!dump_name) { + dump_name = cleaned_invocation_name(argv[0]); + } + user_progname = dump_name; + } + } + kpse_set_program_enabled(kpse_fmt_format, MAKE_TEX_FMT_BY_DEFAULT, + kpse_src_compile); + + kpse_set_program_name(argv[0], user_progname); + init_shell_escape(); /* set up 'restrictedshell' */ + program_name_set = 1; +} + +@ @c +void fix_dumpname(void) +{ + int dist; + if (dump_name) { + /* adjust array for Pascal and provide extension, if needed */ + dist = (int) (strlen(dump_name) - strlen(DUMP_EXT)); + if (strstr(dump_name, DUMP_EXT) == dump_name + dist) + TEX_format_default = dump_name; + else + TEX_format_default = concat(dump_name, DUMP_EXT); + } else { + /* For |dump_name| to be NULL is a bug. */ + if (!ini_version) + abort(); + } +} + +@ lua require patch + +@ Auxiliary function for kpse search + +@c +static const char *luatex_kpse_find_aux(lua_State *L, const char *name, + kpse_file_format_type format, const char *errname) +{ + const char *filename; + const char *altname; + altname = luaL_gsub(L, name, ".", "/"); /* Lua convention */ + filename = kpse_find_file(altname, format, false); + if (filename == NULL) { + filename = kpse_find_file(name, format, false); + } + if (filename == NULL) { + lua_pushfstring(L, "\n\t[kpse %s searcher] file not found: " LUA_QS, + errname, name); + } + return filename; +} + +@ The lua search function. + +When kpathsea is not initialized, then it runs the +normal lua function that is saved in the registry, otherwise +it uses kpathsea. + +two registry ref variables are needed: one for the actual lua +function, the other for its environment . + +@c +static int lua_loader_function = 0; +static int lua_loader_env = 0; + +static int luatex_kpse_lua_find(lua_State * L) +{ + const char *filename; + const char *name; + name = luaL_checkstring(L, 1); + if (program_name_set == 0) { + lua_CFunction orig_func; + lua_rawgeti(L, LUA_REGISTRYINDEX, lua_loader_function); + lua_rawgeti(L, LUA_REGISTRYINDEX, lua_loader_env); + lua_replace(L, LUA_ENVIRONINDEX); + orig_func = lua_tocfunction(L, -1); + lua_pop(L, 1); + return (orig_func) (L); + } + filename = luatex_kpse_find_aux(L, name, kpse_lua_format, "lua"); + if (filename == NULL) + return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) { + luaL_error(L, "error loading module %s from file %s:\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); + } + return 1; /* library loaded successfully */ +} + +@ @c +static int clua_loader_function = 0; +static int clua_loader_env = 0; + +static int luatex_kpse_clua_find(lua_State * L) +{ + const char *filename; + const char *name; + if (safer_option) { + lua_pushliteral(L, "\n\t[C searcher disabled in safer mode]"); + return 1; /* library not found in this path */ + } + name = luaL_checkstring(L, 1); + if (program_name_set == 0) { + lua_CFunction orig_func; + lua_rawgeti(L, LUA_REGISTRYINDEX, clua_loader_function); + lua_rawgeti(L, LUA_REGISTRYINDEX, clua_loader_env); + lua_replace(L, LUA_ENVIRONINDEX); + orig_func = lua_tocfunction(L, -1); + lua_pop(L, 1); + return (orig_func) (L); + } + filename = luatex_kpse_find_aux(L, name, kpse_clua_format, "C"); + if (filename == NULL) + return 1; /* library not found in this path */ + return loader_C_luatex(L, name, filename); +} + +@ @c +static int clua_loadall_function = 0; +static int clua_loadall_env = 0; + +static int luatex_kpse_cluaall_find(lua_State * L) +{ + const char *filename; + const char *name; + char *fixedname; + const char *p = NULL; + if (safer_option) { + lua_pushliteral(L, "\n\t[All-in-one searcher disabled in safer mode]"); + return 1; /* library not found in this path */ + } + name = luaL_checkstring(L, 1); + p = strchr(name, '.'); + if (program_name_set == 0) { + lua_CFunction orig_func; + lua_rawgeti(L, LUA_REGISTRYINDEX, clua_loadall_function); + lua_rawgeti(L, LUA_REGISTRYINDEX, clua_loadall_env); + lua_replace(L, LUA_ENVIRONINDEX); + orig_func = lua_tocfunction(L, -1); + lua_pop(L, 1); + return (orig_func) (L); + } + if (p == NULL) return 0; /* is root */ + fixedname = xmalloc((size_t)(p - name)+1); + memcpy(fixedname,name,(size_t)(p - name)); + fixedname[(p - name)] = '\0'; + filename = luatex_kpse_find_aux(L, fixedname, kpse_clua_format, "All-in-one"); + free(fixedname); + if (filename == NULL) + return 1; /* library not found in this path */ + return loader_Call_luatex(L, name, filename); +} + +@ Setting up the new search functions. + + This replaces package.loaders[2] with the function defined above. + +@c +static void setup_lua_path(lua_State * L) +{ + lua_getglobal(L, "package"); + lua_getfield(L, -1, "loaders"); + lua_rawgeti(L, -1, 2); /* package.loaders[2] */ + lua_getfenv(L, -1); + lua_loader_env = luaL_ref(L, LUA_REGISTRYINDEX); + lua_loader_function = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushcfunction(L, luatex_kpse_lua_find); + lua_rawseti(L, -2, 2); /* replace the normal lua loader */ + + lua_rawgeti(L, -1, 3); /* package.loaders[3] */ + lua_getfenv(L, -1); + clua_loader_env = luaL_ref(L, LUA_REGISTRYINDEX); + clua_loader_function = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushcfunction(L, luatex_kpse_clua_find); + lua_rawseti(L, -2, 3); /* replace the normal lua lib loader */ + + lua_rawgeti(L, -1, 4); /* package.loaders[4] */ + lua_getfenv(L, -1); + clua_loadall_env = luaL_ref(L, LUA_REGISTRYINDEX); + clua_loadall_function = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushcfunction(L, luatex_kpse_cluaall_find); + lua_rawseti(L, -2, 4); /* replace the normal lua lib loader */ + + lua_pop(L, 2); /* pop the array and table */ +} + +@ helper variables for the safe keeping of table ids + +@c +int tex_table_id; +int pdf_table_id; +int token_table_id; +int node_table_id; + + +#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__) +char **suffixlist; + +# define EXE_SUFFIXES ".com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.ws;.tcl;.py;.pyw" + +@ @c +static void mk_suffixlist(void) +{ + char **p; + char *q, *r, *v; + int n; + +# if defined(__CYGWIN__) + v = xstrdup(EXE_SUFFIXES); +# else + v = (char *) getenv("PATHEXT"); + if (v) /* strlwr() exists also in MingW */ + v = (char *) strlwr(xstrdup(v)); + else + v = xstrdup(EXE_SUFFIXES); +# endif + + q = v; + n = 0; + + while ((r = strchr(q, ';')) != NULL) { + n++; + r++; + q = r; + } + if (*q) + n++; + suffixlist = (char **) xmalloc((n + 2) * sizeof(char *)); + p = suffixlist; + *p = xstrdup(".dll"); + p++; + q = v; + while ((r = strchr(q, ';')) != NULL) { + *r = '\0'; + *p = xstrdup(q); + p++; + r++; + q = r; + } + if (*q) { + *p = xstrdup(q); + p++; + } + *p = NULL; + free(v); +} +#endif + +@ @c +void lua_initialize(int ac, char **av) +{ + + char *given_file = NULL; + char *banner; + int kpse_init; + static char LC_CTYPE_C[] = "LC_CTYPE=C"; + static char LC_COLLATE_C[] = "LC_COLLATE=C"; + static char LC_NUMERIC_C[] = "LC_NUMERIC=C"; + static char engine_luatex[] = "engine=luatex"; + /* Save to pass along to topenin. */ + argc = ac; + argv = av; + + if (luatex_svn < 0) { + if (asprintf(&banner, "This is LuaTeX, Version %s-%d", + luatex_version_string, luatex_date_info) < 0) { + exit(EXIT_FAILURE); + } + } else { + if (asprintf(&banner, "This is LuaTeX, Version %s-%d (rev %d)", + luatex_version_string, luatex_date_info, luatex_svn) < 0) { + exit(EXIT_FAILURE); + } + } + ptexbanner = banner; + + program_invocation_name = cleaned_invocation_name(argv[0]); + + /* be 'luac' */ + if (argc > 1 && + (STREQ(program_invocation_name, "texluac") || + STREQ(argv[1], "--luaconly") || STREQ(argv[1], "--luac"))) { + exit(luac_main(ac, av)); + } +#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__) + mk_suffixlist(); +#endif + + /* Must be initialized before options are parsed. */ + interactionoption = 4; + dump_name = NULL; + + /* 0 means "disable Synchronize TeXnology". + synctexoption is a *.web variable. + We initialize it to a weird value to catch the -synctex command line flag + At runtime, if synctexoption is not |INT_MAX|, then it contains the command line option provided, + otherwise no such option was given by the user. */ +#define SYNCTEX_NO_OPTION INT_MAX + synctexoption = SYNCTEX_NO_OPTION; + + /* parse commandline */ + parse_options(ac, av); + if (lua_only) + shellenabledp = true; + + /* make sure that the locale is 'sane' (for lua) */ + + putenv(LC_CTYPE_C); + putenv(LC_COLLATE_C); + putenv(LC_NUMERIC_C); + + /* this is sometimes needed */ + putenv(engine_luatex); + + luainterpreter(); + + prepare_cmdline(Luas, argv, argc, lua_offset); /* collect arguments */ + setup_lua_path(Luas); + + if (startup_filename != NULL) { + given_file = xstrdup(startup_filename); + startup_filename = find_filename(startup_filename, "LUATEXDIR"); + } + /* now run the file */ + if (startup_filename != NULL) { + char *v1; + /* hide the 'tex' and 'pdf' table */ + tex_table_id = hide_lua_table(Luas, "tex"); + token_table_id = hide_lua_table(Luas, "token"); + node_table_id = hide_lua_table(Luas, "node"); + pdf_table_id = hide_lua_table(Luas, "pdf"); + + if (luaL_loadfile(Luas, startup_filename)) { + fprintf(stdout, "%s\n", lua_tostring(Luas, -1)); + exit(1); + } + /* */ + init_tex_table(Luas); + if (lua_pcall(Luas, 0, 0, 0)) { + fprintf(stdout, "%s\n", lua_tostring(Luas, -1)); + exit(1); + } + /* no filename? quit now! */ + if (!input_name) { + get_lua_string("texconfig", "jobname", &input_name); + } + if (!dump_name) { + get_lua_string("texconfig", "formatname", &dump_name); + } + if ((lua_only) || ((!input_name) && (!dump_name))) { + if (given_file) + free(given_file); + /* this is not strictly needed but it pleases valgrind */ + lua_close(Luas); + exit(0); + } + /* unhide the 'tex' and 'pdf' table */ + unhide_lua_table(Luas, "tex", tex_table_id); + unhide_lua_table(Luas, "pdf", pdf_table_id); + unhide_lua_table(Luas, "token", token_table_id); + unhide_lua_table(Luas, "node", node_table_id); + + /* |kpse_init| */ + kpse_init = -1; + get_lua_boolean("texconfig", "kpse_init", &kpse_init); + + if (kpse_init != 0) { + luainit = 0; /* re-enable loading of texmf.cnf values, see luatex.ch */ + init_kpse(); + } + /* |prohibit_file_trace| (boolean) */ + tracefilenames = 1; + get_lua_boolean("texconfig", "trace_file_names", &tracefilenames); + + /* |file_line_error| */ + filelineerrorstylep = false; + get_lua_boolean("texconfig", "file_line_error", &filelineerrorstylep); + + /* |halt_on_error| */ + haltonerrorp = false; + get_lua_boolean("texconfig", "halt_on_error", &haltonerrorp); + + /* |restrictedshell| */ + v1 = NULL; + get_lua_string("texconfig", "shell_escape", &v1); + if (v1) { + if (*v1 == 't' || *v1 == 'y' || *v1 == '1') { + shellenabledp = 1; + } else if (*v1 == 'p') { + shellenabledp = 1; + restrictedshell = 1; + } + } + /* If shell escapes are restricted, get allowed cmds from cnf. */ + if (shellenabledp && restrictedshell == 1) { + v1 = NULL; + get_lua_string("texconfig", "shell_escape_commands", &v1); + if (v1) { + mk_shellcmdlist(v1); + } + } + + fix_dumpname(); + + } else { + if (luainit) { + if (given_file) { + fprintf(stdout, "%s file %s not found\n", + (lua_only ? "Script" : "Configuration"), given_file); + free(given_file); + } else { + fprintf(stdout, "No %s file given\n", + (lua_only ? "script" : "configuration")); + } + exit(1); + } else { + /* init */ + init_kpse(); + fix_dumpname(); + } + } +} + +@ @c +void check_texconfig_init(void) +{ + if (Luas != NULL) { + lua_getglobal(Luas, "texconfig"); + if (lua_istable(Luas, -1)) { + lua_getfield(Luas, -1, "init"); + if (lua_isfunction(Luas, -1)) { + int i = lua_pcall(Luas, 0, 0, 0); + if (i != 0) { + /* Can't be more precise here, called before TeX initialization */ + fprintf(stderr, "This went wrong: %s\n", + lua_tostring(Luas, -1)); + error(); + } + } + } + } +} + +@ @c +void write_svnversion(char *v) +{ + char *a_head, *n; + char *a = strdup(v); + size_t l = strlen("$Id: luatex.web "); + if (a != NULL) { + a_head = a; + if (strlen(a) > l) + a += l; + n = a; + while (*n != '\0' && *n != ' ') + n++; + *n = '\0'; + fprintf(stdout, " luatex.web >= v%s", a); + free(a_head); + } +} diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.c b/Build/source/texk/web2c/luatexdir/lua/luanode.c deleted file mode 100644 index a9daa106920..00000000000 --- a/Build/source/texk/web2c/luatexdir/lua/luanode.c +++ /dev/null @@ -1,330 +0,0 @@ -/* luanode.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "luatex-api.h" -#include -#include "nodes.h" - -static const char _svn_version[] = - "$Id: luanode.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/luanode.c $"; - -#undef link /* defined by cpascal.h */ -#define info(a) fixmem[(a)].hhlh -#define link(a) fixmem[(a)].hhrh - -static const char *group_code_names[] = { - "", - "simple", - "hbox", - "adjusted_hbox", - "vbox", - "vtop", - "align", - "no_align", - "output", - "math", - "disc", - "insert", - "vcenter", - "math_choice", - "semi_simple", - "math_shift", - "math_left", - "local_box", - "split_off", - "split_keep", - "preamble", - "align_set", - "fin_row" -}; - -static const char *pack_type_name[] = { "exactly", "additional" }; - - -void lua_node_filter_s(int filterid, const char *extrainfo) -{ - lua_State *L = Luas; - int s_top = lua_gettop(L); - int callback_id = callback_defined(filterid); - if (callback_id <= 0) - return; - if (!get_callback(L, callback_id)) { - lua_settop(L, s_top); - return; - } - lua_pushstring(L, extrainfo); /* arg 1 */ - if (lua_pcall(L, 1, 0, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); - error(); - return; - } - lua_settop(L, s_top); - return; -} - -void -lua_node_filter(int filterid, int xextrainfo, halfword head_node, - halfword * tail_node) -{ - halfword ret; - int a; - lua_State *L = Luas; - const char *extrainfo = group_code_names[xextrainfo]; - int callback_id = callback_defined(filterid); - if (head_node == null || vlink(head_node) == null || callback_id <= 0) - return; - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); - return; - } - nodelist_to_lua(L, vlink(head_node)); /* arg 1 */ - lua_pushstring(L, extrainfo); /* arg 2 */ - if (lua_pcall(L, 2, 1, 0) != 0) { /* no arg, 1 result */ - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); - error(); - return; - } - if (lua_isboolean(L, -1)) { - if (lua_toboolean(L, -1) != 1) { - flush_node_list(vlink(head_node)); - vlink(head_node) = null; - } - } else { - a = nodelist_from_lua(L); - vlink(head_node) = a; - } - lua_pop(L, 2); /* result and callback container table */ - if (fix_node_lists) - fix_node_list(head_node); - ret = vlink(head_node); - if (ret != null) { - while (vlink(ret) != null) - ret = vlink(ret); - *tail_node = ret; - } else { - *tail_node = head_node; - } - return; -} - - -int -lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head) -{ - int a; - register halfword *p; - int ret = 0; /* failure */ - lua_State *L = Luas; - int callback_id = callback_defined(linebreak_filter_callback); - if (head_node == null || vlink(head_node) == null || callback_id <= 0) - return ret; - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); - return ret; - } - nodelist_to_lua(L, vlink(head_node)); /* arg 1 */ - lua_pushboolean(L, is_broken); /* arg 2 */ - if (lua_pcall(L, 2, 1, 0) != 0) { /* no arg, 1 result */ - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); - error(); - return ret; - } - - p = lua_touserdata(L, -1); - if (p != NULL) { - a = nodelist_from_lua(L); - vlink(*new_head) = a; - ret = 1; - } - lua_pop(L, 2); /* result and callback container table */ - return ret; -} - - - -halfword -lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo) -{ - halfword ret; - lua_State *L = Luas; - int callback_id = callback_defined(hpack_filter_callback); - if (head_node == null || callback_id <= 0) - return head_node; - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); - return head_node; - } - nodelist_to_lua(L, head_node); - lua_pushstring(L, group_code_names[extrainfo]); - lua_pushnumber(L, size); - lua_pushstring(L, pack_type_name[pack_type]); - if (lua_pcall(L, 4, 1, 0) != 0) { /* no arg, 1 result */ - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); - error(); - return head_node; - } - ret = head_node; - if (lua_isboolean(L, -1)) { - if (lua_toboolean(L, -1) != 1) { - flush_node_list(head_node); - ret = null; - } - } else { - ret = nodelist_from_lua(L); - } - lua_pop(L, 2); /* result and callback container table */ - /* lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE); */ - if (fix_node_lists) - fix_node_list(ret); - return ret; -} - -halfword -lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd, - int extrainfo) -{ - halfword ret; - integer callback_id; - lua_State *L = Luas; - if (head_node == null) - return head_node; - if (strcmp("output", group_code_names[extrainfo]) == 0) { - callback_id = callback_defined(pre_output_filter_callback); - } else { - callback_id = callback_defined(vpack_filter_callback); - } - if (callback_id <= 0) { - return head_node; - } - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); - return head_node; - } - nodelist_to_lua(L, head_node); - lua_pushstring(L, group_code_names[extrainfo]); - lua_pushnumber(L, size); - lua_pushstring(L, pack_type_name[pack_type]); - lua_pushnumber(L, maxd); - if (lua_pcall(L, 5, 1, 0) != 0) { /* no arg, 1 result */ - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); - error(); - return head_node; - } - ret = head_node; - if (lua_isboolean(L, -1)) { - if (lua_toboolean(L, -1) != 1) { - flush_node_list(head_node); - ret = null; - } - } else { - ret = nodelist_from_lua(L); - } - lua_pop(L, 2); /* result and callback container table */ - /* lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE); */ - if (fix_node_lists) - fix_node_list(ret); - return ret; -} - - -/* This is a quick hack to fix etex's \lastnodetype now that - * there are many more visible node types. TODO: check the - * eTeX manual for the expected return values. - */ - -int visible_last_node_type(int n) -{ - int i = type(n); - if ((i != math_node) && (i <= unset_node)) - return i + 1; - if (i == glyph_node) - return -1; - if (i == whatsit_node && subtype(n) == local_par_node) - return -1; - if (i == 255) - return -1; /* this is not right, probably dir nodes! */ - return last_known_node + 1; -} - -void lua_pdf_literal(int i) -{ - const char *s; - size_t l = 0; - lua_rawgeti(Luas, LUA_REGISTRYINDEX, i); - s = lua_tolstring(Luas, -1, &l); - while (l--) { - pdf_room(1); - pdf_buf[pdf_ptr++] = *s++; - } - pdf_buf[pdf_ptr++] = 10; /* pdf_print_nl */ - lua_pop(Luas, 1); -} - -void copy_pdf_literal(pointer r, pointer p) -{ - pdf_literal_type(r) = pdf_literal_type(p); - pdf_literal_mode(r) = pdf_literal_mode(p); - if (pdf_literal_type(p) == normal) { - pdf_literal_data(r) = pdf_literal_data(p); - add_token_ref(pdf_literal_data(p)); - } else { - lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf_literal_data(p)); - pdf_literal_data(r) = luaL_ref(Luas, LUA_REGISTRYINDEX); - } -} - - -void free_pdf_literal(pointer p) -{ - if (pdf_literal_type(p) == normal) { - delete_token_ref(pdf_literal_data(p)); - } else { - luaL_unref(Luas, LUA_REGISTRYINDEX, pdf_literal_data(p)); - } -} - -void show_pdf_literal(pointer p) -{ - tprint_esc("pdfliteral"); - switch (pdf_literal_mode(p)) { - case set_origin: - break; - case direct_page: - tprint(" page"); - break; - case direct_always: - tprint(" direct"); - break; - default: - tconfusion("literal2"); - break; - } - if (pdf_literal_type(p) == normal) { - print_mark(pdf_literal_data(p)); - } else { - lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf_literal_data(p)); - tprint(lua_tostring(Luas, -1)); - lua_pop(Luas, 1); - } -} diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.w b/Build/source/texk/web2c/luatexdir/lua/luanode.w new file mode 100644 index 00000000000..81e6b4fa74e --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/luanode.w @@ -0,0 +1,360 @@ +% luanode.w +% +% Copyright 2006-2008 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "lua/luatex-api.h" +#include "ptexlib.h" + + +static const char _svn_version[] = + "$Id: luanode.w 3583 2010-04-02 17:40:44Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/luanode.w $"; + +@ @c +static const char *group_code_names[] = { + "", + "simple", + "hbox", + "adjusted_hbox", + "vbox", + "vtop", + "align", + "no_align", + "output", + "math", + "disc", + "insert", + "vcenter", + "math_choice", + "semi_simple", + "math_shift", + "math_left", + "local_box", + "split_off", + "split_keep", + "preamble", + "align_set", + "fin_row" +}; + +const char *pack_type_name[] = { "exactly", "additional" }; + + +@ @c +void lua_node_filter_s(int filterid, const char *extrainfo) +{ + lua_State *L = Luas; + int s_top = lua_gettop(L); + int callback_id = callback_defined(filterid); + if (callback_id <= 0) + return; + if (!get_callback(L, callback_id)) { + lua_settop(L, s_top); + return; + } + lua_pushstring(L, extrainfo); /* arg 1 */ + if (lua_pcall(L, 1, 0, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_settop(L, s_top); + error(); + return; + } + lua_settop(L, s_top); + return; +} + +@ @c +void +lua_node_filter(int filterid, int xextrainfo, halfword head_node, + halfword * tail_node) +{ + halfword ret; + int a; + lua_State *L = Luas; + const char *extrainfo = group_code_names[xextrainfo]; + int callback_id = callback_defined(filterid); + if (head_node == null || vlink(head_node) == null || callback_id <= 0) + return; + if (!get_callback(L, callback_id)) { + lua_pop(L, 2); + return; + } + nodelist_to_lua(L, vlink(head_node)); /* arg 1 */ + lua_pushstring(L, extrainfo); /* arg 2 */ + if (lua_pcall(L, 2, 1, 0) != 0) { /* no arg, 1 result */ + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 2); + error(); + return; + } + if (lua_isboolean(L, -1)) { + if (lua_toboolean(L, -1) != 1) { + flush_node_list(vlink(head_node)); + vlink(head_node) = null; + } + } else { + a = nodelist_from_lua(L); + vlink(head_node) = a; + } + lua_pop(L, 2); /* result and callback container table */ + if (fix_node_lists) + fix_node_list(head_node); + ret = vlink(head_node); + if (ret != null) { + while (vlink(ret) != null) + ret = vlink(ret); + *tail_node = ret; + } else { + *tail_node = head_node; + } + return; +} + + +@ @c +int +lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head) +{ + int a; + register halfword *p; + int ret = 0; /* failure */ + lua_State *L = Luas; + int callback_id = callback_defined(linebreak_filter_callback); + if (head_node == null || vlink(head_node) == null || callback_id <= 0) + return ret; + if (!get_callback(L, callback_id)) { + lua_pop(L, 2); + return ret; + } + nodelist_to_lua(L, vlink(head_node)); /* arg 1 */ + lua_pushboolean(L, is_broken); /* arg 2 */ + if (lua_pcall(L, 2, 1, 0) != 0) { /* no arg, 1 result */ + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 2); + error(); + return ret; + } + + p = lua_touserdata(L, -1); + if (p != NULL) { + a = nodelist_from_lua(L); + vlink(*new_head) = a; + ret = 1; + } + lua_pop(L, 2); /* result and callback container table */ + return ret; +} + + + +@ @c +halfword +lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, + int pack_direction) +{ + halfword ret; + lua_State *L = Luas; + int callback_id = callback_defined(hpack_filter_callback); + if (head_node == null || callback_id <= 0) + return head_node; + if (!get_callback(L, callback_id)) { + lua_pop(L, 2); + return head_node; + } + nodelist_to_lua(L, head_node); + lua_pushstring(L, group_code_names[extrainfo]); + lua_pushnumber(L, size); + lua_pushstring(L, pack_type_name[pack_type]); + if (pack_direction >= 0) + lua_pushstring(L, string_dir(pack_direction)); + else + lua_pushnil(L); + if (lua_pcall(L, 5, 1, 0) != 0) { /* no arg, 1 result */ + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 2); + error(); + return head_node; + } + ret = head_node; + if (lua_isboolean(L, -1)) { + if (lua_toboolean(L, -1) != 1) { + flush_node_list(head_node); + ret = null; + } + } else { + ret = nodelist_from_lua(L); + } + lua_pop(L, 2); /* result and callback container table */ +#if 0 + lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE); +#endif + if (fix_node_lists) + fix_node_list(ret); + return ret; +} + +@ @c +halfword +lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd, + int extrainfo, int pack_direction) +{ + halfword ret; + int callback_id; + lua_State *L = Luas; + if (head_node == null) + return head_node; + if (strcmp("output", group_code_names[extrainfo]) == 0) { + callback_id = callback_defined(pre_output_filter_callback); + } else { + callback_id = callback_defined(vpack_filter_callback); + } + if (callback_id <= 0) { + return head_node; + } + if (!get_callback(L, callback_id)) { + lua_pop(L, 2); + return head_node; + } + nodelist_to_lua(L, head_node); + lua_pushstring(L, group_code_names[extrainfo]); + lua_pushnumber(L, size); + lua_pushstring(L, pack_type_name[pack_type]); + lua_pushnumber(L, maxd); + if (pack_direction >= 0) + lua_pushstring(L, string_dir(pack_direction)); + else + lua_pushnil(L); + if (lua_pcall(L, 6, 1, 0) != 0) { /* no arg, 1 result */ + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 2); + error(); + return head_node; + } + ret = head_node; + if (lua_isboolean(L, -1)) { + if (lua_toboolean(L, -1) != 1) { + flush_node_list(head_node); + ret = null; + } + } else { + ret = nodelist_from_lua(L); + } + lua_pop(L, 2); /* result and callback container table */ +#if 0 + lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE); +#endif + if (fix_node_lists) + fix_node_list(ret); + return ret; +} + + +@ This is a quick hack to fix etex's \.{\\lastnodetype} now that + there are many more visible node types. TODO: check the + eTeX manual for the expected return values. + +@c +int visible_last_node_type(int n) +{ + int i = type(n); + if (i == whatsit_node && subtype(n) == local_par_node) + return -1; + if (i == glyph_node) { + if (is_ligature(n)) + return 7; /* old ligature value */ + else + return 0; /* old character value */ + } + if (i <= unset_node) { + return i + 1; + } else if (i <= delim_node) { + return 15; /* so-called math nodes */ + } else { + return -1; + } +} + +@ @c +void lua_pdf_literal(PDF pdf, int i) +{ + const char *s = NULL; + size_t l = 0; + lua_rawgeti(Luas, LUA_REGISTRYINDEX, i); + s = lua_tolstring(Luas, -1, &l); + if (l < max_single_pdf_print) { + pdf_out_block(pdf, s, l); + } else { + while (l--) { + pdf_out(pdf, *s++); + } + } + pdf_out(pdf, 10); /* |pdf_print_nl| */ + lua_pop(Luas, 1); +} + +@ @c +void copy_pdf_literal(pointer r, pointer p) +{ + pdf_literal_type(r) = pdf_literal_type(p); + pdf_literal_mode(r) = pdf_literal_mode(p); + if (pdf_literal_type(p) == normal) { + pdf_literal_data(r) = pdf_literal_data(p); + add_token_ref(pdf_literal_data(p)); + } else { + lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf_literal_data(p)); + pdf_literal_data(r) = luaL_ref(Luas, LUA_REGISTRYINDEX); + } +} + + +@ @c +void free_pdf_literal(pointer p) +{ + if (pdf_literal_type(p) == normal) { + delete_token_ref(pdf_literal_data(p)); + } else { + luaL_unref(Luas, LUA_REGISTRYINDEX, pdf_literal_data(p)); + } +} + +@ @c +void show_pdf_literal(pointer p) +{ + tprint_esc("pdfliteral"); + switch (pdf_literal_mode(p)) { + case set_origin: + break; + case direct_page: + tprint(" page"); + break; + case direct_always: + tprint(" direct"); + break; + default: + confusion("literal2"); + break; + } + if (pdf_literal_type(p) == normal) { + print_mark(pdf_literal_data(p)); + } else { + lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf_literal_data(p)); + tprint(lua_tostring(Luas, -1)); + lua_pop(Luas, 1); + } +} diff --git a/Build/source/texk/web2c/luatexdir/lua/luastuff.c b/Build/source/texk/web2c/luatexdir/lua/luastuff.c deleted file mode 100644 index 75bdaf367ef..00000000000 --- a/Build/source/texk/web2c/luatexdir/lua/luastuff.c +++ /dev/null @@ -1,406 +0,0 @@ -/* luastuff.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "luatex-api.h" -#include - -static const char _svn_version[] = - "$Id: luastuff.c 2321 2009-04-18 09:17:13Z hhenkel $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/luastuff.c $"; - -lua_State *Luas = NULL; - -int luastate_bytes = 0; - -int lua_active = 0; - -void make_table(lua_State * L, const char *tab, const char *getfunc, const char *setfunc) -{ - /* make the table *//* [{}] */ - lua_pushstring(L, tab); /* [{},"dimen"] */ - lua_newtable(L); /* [{},"dimen",{}] */ - lua_settable(L, -3); /* [{}] */ - /* fetch it back */ - lua_pushstring(L, tab); /* [{},"dimen"] */ - lua_gettable(L, -2); /* [{},{}] */ - /* make the meta entries */ - luaL_newmetatable(L, tab); /* [{},{},{}] */ - lua_pushstring(L, "__index"); /* [{},{},{},"__index"] */ - lua_pushstring(L, getfunc); /* [{},{},{},"__index","getdimen"] */ - lua_gettable(L, -5); /* [{},{},{},"__index",] */ - lua_settable(L, -3); /* [{},{},{}] */ - lua_pushstring(L, "__newindex"); /* [{},{},{},"__newindex"] */ - lua_pushstring(L, setfunc); /* [{},{},{},"__newindex","setdimen"] */ - lua_gettable(L, -5); /* [{},{},{},"__newindex",] */ - lua_settable(L, -3); /* [{},{},{}] */ - lua_setmetatable(L, -2); /* [{},{}] : assign the metatable */ - lua_pop(L, 1); /* [{}] : clean the stack */ -} - -static -const char *getS(lua_State * L, void *ud, size_t * size) -{ - LoadS *ls = (LoadS *) ud; - (void) L; - if (ls->size == 0) - return NULL; - *size = ls->size; - ls->size = 0; - return ls->s; -} - -static void *my_luaalloc(void *ud, void *ptr, size_t osize, size_t nsize) -{ - void *ret = NULL; - (void) ud; /* for -Wunused */ - if (nsize == 0) - free(ptr); - else - ret = realloc(ptr, nsize); - luastate_bytes += (nsize - osize); - return ret; -} - -static int my_luapanic(lua_State * L) -{ - (void) L; /* to avoid warnings */ - fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", - lua_tostring(L, -1)); - return 0; -} - -static const luaL_Reg lualibs[] = { - {"", luaopen_base}, - {"package", luaopen_package}, - {"table", luaopen_table}, - {"io", luaopen_io}, - {"os", luaopen_os}, - {"string", luaopen_string}, - {"math", luaopen_math}, - {"debug", luaopen_debug}, - {"unicode", luaopen_unicode}, - {"zip", luaopen_zip}, - {"lpeg", luaopen_lpeg}, - {"md5", luaopen_md5}, - {"lfs", luaopen_lfs}, - {"profiler", luaopen_profiler}, - {NULL, NULL} -}; - - -static void do_openlibs(lua_State * L) -{ - const luaL_Reg *lib = lualibs; - for (; lib->func; lib++) { - lua_pushcfunction(L, lib->func); - lua_pushstring(L, lib->name); - lua_call(L, 1, 0); - } -} - -void luainterpreter(void) -{ - lua_State *L; - L = lua_newstate(my_luaalloc, NULL); - if (L == NULL) { - fprintf(stderr, "Can't create the Lua state.\n"); - return; - } - lua_atpanic(L, &my_luapanic); - - do_openlibs(L); /* does all the 'simple' libraries */ - - open_oslibext(L, safer_option); - - lua_getglobal(L, "package"); - lua_pushstring(L, ""); - lua_setfield(L, -2, "cpath"); - lua_pop(L, 1); /* pop the table */ - - /* luasockets */ - /* socket and mime are a bit tricky to open because - * they use a load-time dependency that has to be - * worked around for luatex, where the C module is - * loaded way before the lua module. - */ - if (!nosocket_option) { - lua_getglobal(L, "package"); - lua_getfield(L, -1, "loaded"); - if (!lua_istable(L, -1)) { - lua_newtable(L); - lua_setfield(L, -2, "loaded"); - lua_getfield(L, -1, "loaded"); - } - luaopen_socket_core(L); - lua_setfield(L, -2, "socket.core"); - lua_pushnil(L); - lua_setfield(L, -2, "socket"); /* package.loaded.socket = nil */ - - luaopen_mime_core(L); - lua_setfield(L, -2, "mime.core"); - lua_pushnil(L); - lua_setfield(L, -2, "mime"); /* package.loaded.mime = nil */ - lua_pop(L, 2); /* pop the tables */ - - luatex_socketlua_open(L); /* preload the pure lua modules */ - } - /* zlib. slightly odd calling convention */ - luaopen_zlib(L); - lua_setglobal(L, "zlib"); - luaopen_gzip(L); - - /* our own libraries */ - luaopen_ff(L); - luaopen_pdf(L); - luaopen_tex(L); - luaopen_token(L); - luaopen_node(L); - luaopen_texio(L); - luaopen_kpse(L); - luaopen_callback(L); - luaopen_lua(L, startup_filename); - luaopen_stats(L); - luaopen_font(L); - luaopen_lang(L); - luaopen_mplib(L); - - /* luaopen_img(L); */ - lua_pushcfunction(L, luaopen_img); - lua_pushstring(L, "img"); - lua_call(L, 1, 0); - - lua_createtable(L, 0, 0); - lua_setglobal(L, "texconfig"); - - if (safer_option) { - /* disable some stuff if --safer */ - (void) hide_lua_value(L, "os", "execute"); - (void) hide_lua_value(L, "os", "rename"); - (void) hide_lua_value(L, "os", "remove"); - (void) hide_lua_value(L, "io", "popen"); - /* make io.open only read files */ - luaL_checkstack(L, 2, "out of stack space"); - lua_getglobal(L, "io"); - lua_getfield(L, -1, "open_ro"); - lua_setfield(L, -2, "open"); - (void) hide_lua_value(L, "io", "tmpfile"); - (void) hide_lua_value(L, "io", "output"); - (void) hide_lua_value(L, "lfs", "chdir"); - (void) hide_lua_value(L, "lfs", "lock"); - (void) hide_lua_value(L, "lfs", "touch"); - (void) hide_lua_value(L, "lfs", "rmdir"); - (void) hide_lua_value(L, "lfs", "mkdir"); - } - Luas = L; -} - -int hide_lua_table(lua_State * L, const char *name) -{ - int r = 0; - lua_getglobal(L, name); - if (lua_istable(L, -1)) { - r = luaL_ref(L, LUA_REGISTRYINDEX); - lua_pushnil(L); - lua_setglobal(L, name); - } - return r; -} - -void unhide_lua_table(lua_State * L, const char *name, int r) -{ - lua_rawgeti(L, LUA_REGISTRYINDEX, r); - lua_setglobal(L, name); - luaL_unref(L, LUA_REGISTRYINDEX, r); -} - -int hide_lua_value(lua_State * L, const char *name, const char *item) -{ - int r = 0; - lua_getglobal(L, name); - if (lua_istable(L, -1)) { - lua_getfield(L, -1, item); - r = luaL_ref(L, LUA_REGISTRYINDEX); - lua_pushnil(L); - lua_setfield(L, -2, item); - } - return r; -} - -void unhide_lua_value(lua_State * L, const char *name, const char *item, int r) -{ - lua_getglobal(L, name); - if (lua_istable(L, -1)) { - lua_rawgeti(L, LUA_REGISTRYINDEX, r); - lua_setfield(L, -2, item); - luaL_unref(L, LUA_REGISTRYINDEX, r); - } -} - - -static int lua_traceback(lua_State * L) -{ - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); - if (!lua_istable(L, -1)) { - lua_pop(L, 1); - return 1; - } - lua_getfield(L, -1, "traceback"); - if (!lua_isfunction(L, -1)) { - lua_pop(L, 2); - return 1; - } - lua_pushvalue(L, 1); /* pass error message */ - lua_pushinteger(L, 2); /* skip this function and traceback */ - lua_call(L, 2, 1); /* call debug.traceback */ - return 1; -} - -void luacall(int p, int nameptr) -{ - LoadS ls; - int i, l; - char *lua_id; - char *s = NULL; - - if (Luas == NULL) { - luainterpreter(); - } - l = 0; - lua_active++; - s = tokenlist_to_cstring(p, 1, &l); - ls.s = s; - ls.size = l; - - if (ls.size > 0) { - if (nameptr > 0) { - lua_id = tokenlist_to_cstring(nameptr, 1, &l); - } else if (nameptr < 0) { - char *tmp = get_lua_name((nameptr + 65536)); - if (tmp != NULL) - lua_id = xstrdup(tmp); - else - lua_id = xstrdup("\\latelua "); - } else { - lua_id = xmalloc(20); - snprintf((char *) lua_id, 20, "\\latelua "); - } - - i = lua_load(Luas, getS, &ls, lua_id); - if (i != 0) { - Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1)); - } else { - int base = lua_gettop(Luas); /* function index */ - lua_checkstack(Luas, 1); - lua_pushcfunction(Luas, lua_traceback); /* push traceback function */ - lua_insert(Luas, base); /* put it under chunk */ - i = lua_pcall(Luas, 0, 0, base); - lua_remove(Luas, base); /* remove traceback function */ - if (i != 0) { - lua_gc(Luas, LUA_GCCOLLECT, 0); - Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); - } - } - xfree(lua_id); - } - lua_active--; -} - -void luatokencall(int p, int nameptr) -{ - LoadS ls; - int i, l; - char *s = NULL; - char *lua_id; - assert(Luas); - l = 0; - lua_active++; - s = tokenlist_to_cstring(p, 1, &l); - ls.s = s; - ls.size = l; - if (ls.size > 0) { - if (nameptr > 0) { - lua_id = tokenlist_to_cstring(nameptr, 1, &l); - } else if (nameptr < 0) { - char *tmp = get_lua_name((nameptr + 65536)); - if (tmp != NULL) - lua_id = xstrdup(tmp); - else - lua_id = xstrdup("\\directlua "); - } else { - lua_id = xstrdup("\\directlua "); - } - i = lua_load(Luas, getS, &ls, lua_id); - xfree(s); - if (i != 0) { - Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1)); - } else { - int base = lua_gettop(Luas); /* function index */ - lua_checkstack(Luas, 1); - lua_pushcfunction(Luas, lua_traceback); /* push traceback function */ - lua_insert(Luas, base); /* put it under chunk */ - i = lua_pcall(Luas, 0, 0, base); - lua_remove(Luas, base); /* remove traceback function */ - if (i != 0) { - lua_gc(Luas, LUA_GCCOLLECT, 0); - Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); - } - } - xfree(lua_id); - } - lua_active--; -} - - - -void luatex_load_init(int s, LoadS * ls) -{ - ls->s = (const char *) &(str_pool[str_start[s]]); - ls->size = str_start[s + 1] - str_start[s]; -} - - -lua_State *luatex_error(lua_State * L, int is_fatal) -{ - - str_number s; - const char *luaerr; - size_t len = 0; - char *err = NULL; - if (lua_isstring(L, -1)) { - luaerr = lua_tolstring(L, -1, &len); - err = (char *) xmalloc(len + 1); - len = snprintf(err, (len + 1), "%s", luaerr); - } - if (is_fatal > 0) { - /* Normally a memory error from lua. - The pool may overflow during the maketexlstring(), but we - are crashing anyway so we may as well abort on the pool size */ - s = maketexlstring(err, len); - lua_fatal_error(s); - /* never reached */ - xfree(err); - lua_close(L); - return (lua_State *) NULL; - } else { - s = maketexlstring(err, len); - lua_norm_error(s); - flush_str(s); - xfree(err); - return L; - } -} diff --git a/Build/source/texk/web2c/luatexdir/lua/luastuff.w b/Build/source/texk/web2c/luatexdir/lua/luastuff.w new file mode 100644 index 00000000000..06547bc4de9 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/luastuff.w @@ -0,0 +1,493 @@ +% luastuff.w + +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +static const char _svn_version[] = + "$Id: luastuff.w 3583 2010-04-02 17:40:44Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/luastuff.w $"; + +#include "lua/luatex-api.h" +#include "ptexlib.h" + +@ @c +lua_State *Luas = NULL; + +int luastate_bytes = 0; + +int lua_active = 0; + +@ @c +void make_table(lua_State * L, const char *tab, const char *getfunc, + const char *setfunc) +{ + /* make the table *//* |[{}]| */ + lua_pushstring(L, tab); /* |[{},"dimen"]| */ + lua_newtable(L); /* |[{},"dimen",{}]| */ + lua_settable(L, -3); /* |[{}]| */ + /* fetch it back */ + lua_pushstring(L, tab); /* |[{},"dimen"]| */ + lua_gettable(L, -2); /* |[{},{}]| */ + /* make the meta entries */ + luaL_newmetatable(L, tab); /* |[{},{},{}]| */ + lua_pushstring(L, "__index"); /* |[{},{},{},"__index"]| */ + lua_pushstring(L, getfunc); /* |[{},{},{},"__index","getdimen"]| */ + lua_gettable(L, -5); /* |[{},{},{},"__index",]| */ + lua_settable(L, -3); /* |[{},{},{}]| */ + lua_pushstring(L, "__newindex"); /* |[{},{},{},"__newindex"]| */ + lua_pushstring(L, setfunc); /* |[{},{},{},"__newindex","setdimen"]| */ + lua_gettable(L, -5); /* |[{},{},{},"__newindex",]| */ + lua_settable(L, -3); /* |[{},{},{}]| */ + lua_setmetatable(L, -2); /* |[{},{}]| : assign the metatable */ + lua_pop(L, 1); /* |[{}]| : clean the stack */ +} + +@ @c +static +const char *getS(lua_State * L, void *ud, size_t * size) +{ + LoadS *ls = (LoadS *) ud; + (void) L; + if (ls->size == 0) + return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + +@ @c +void *my_luaalloc(void *ud, void *ptr, size_t osize, size_t nsize) +{ + void *ret = NULL; + (void) ud; /* for -Wunused */ + if (nsize == 0) + free(ptr); + else + ret = realloc(ptr, nsize); + luastate_bytes += (int) (nsize - osize); + return ret; +} + +@ @c +static int my_luapanic(lua_State * L) +{ + (void) L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + +@ @c +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {"package", luaopen_package}, + {"table", luaopen_table}, + {"io", luaopen_io}, + {"os", luaopen_os}, + {"string", luaopen_string}, + {"math", luaopen_math}, + {"debug", luaopen_debug}, + {"unicode", luaopen_unicode}, + {"zip", luaopen_zip}, + {"lpeg", luaopen_lpeg}, + {"md5", luaopen_md5}, + {"lfs", luaopen_lfs}, + {"profiler", luaopen_profiler}, + {NULL, NULL} +}; + + +@ @c +static void do_openlibs(lua_State * L) +{ + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + +@ @c +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + +@ @c +static int luatex_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + if (!lua_only && !fname) { + if (interaction == batch_mode) { + lua_pushnil(L); + lua_pushstring(L, "reading from stdin is disabled in batch mode"); + return 2; /* return nil plus error message */ + } else { + tprint_nl("lua> "); + } + } + return load_aux(L, luaL_loadfile(L, fname)); +} + +@ @c +static int luatex_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (!lua_only && !fname) { + if (interaction == batch_mode) { + lua_pushnil(L); + lua_pushstring(L, "reading from stdin is disabled in batch mode"); + return 2; /* return nil plus error message */ + } else { + tprint_nl("lua> "); + } + } + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +@ @c +void luainterpreter(void) +{ + lua_State *L; + L = lua_newstate(my_luaalloc, NULL); + if (L == NULL) { + fprintf(stderr, "Can't create the Lua state.\n"); + return; + } + lua_atpanic(L, &my_luapanic); + + do_openlibs(L); /* does all the 'simple' libraries */ + + lua_pushcfunction(L,luatex_dofile); + lua_setglobal(L, "dofile"); + lua_pushcfunction(L,luatex_loadfile); + lua_setglobal(L, "loadfile"); + + luatex_md5_lua_open(L); + + open_oslibext(L, safer_option); + + /* luasockets */ + /* socket and mime are a bit tricky to open because + they use a load-time dependency that has to be + worked around for luatex, where the C module is + loaded way before the lua module. + */ + if (!nosocket_option) { + lua_getglobal(L, "package"); + lua_getfield(L, -1, "loaded"); + if (!lua_istable(L, -1)) { + lua_newtable(L); + lua_setfield(L, -2, "loaded"); + lua_getfield(L, -1, "loaded"); + } + luaopen_socket_core(L); + lua_setfield(L, -2, "socket.core"); + lua_pushnil(L); + lua_setfield(L, -2, "socket"); /* package.loaded.socket = nil */ + + luaopen_mime_core(L); + lua_setfield(L, -2, "mime.core"); + lua_pushnil(L); + lua_setfield(L, -2, "mime"); /* package.loaded.mime = nil */ + lua_pop(L, 2); /* pop the tables */ + + luatex_socketlua_open(L); /* preload the pure lua modules */ + } + /* zlib. slightly odd calling convention */ + luaopen_zlib(L); + lua_setglobal(L, "zlib"); + luaopen_gzip(L); + + /* our own libraries */ + luaopen_ff(L); + luaopen_tex(L); + luaopen_token(L); + luaopen_node(L); + luaopen_texio(L); + luaopen_kpse(L); + luaopen_callback(L); + luaopen_lua(L, startup_filename); + luaopen_stats(L); + luaopen_font(L); + luaopen_lang(L); + luaopen_mplib(L); + + /* |luaopen_pdf(L);| */ + /* environment table at |LUA_ENVIRONINDEX| needs to load this way: */ + lua_pushcfunction(L, luaopen_pdf); + lua_pushstring(L, "pdf"); + lua_call(L, 1, 0); + + /* |luaopen_img(L);| */ + lua_pushcfunction(L, luaopen_img); + lua_pushstring(L, "img"); + lua_call(L, 1, 0); + + /* |luaopen_epdf(L);| */ + lua_pushcfunction(L, luaopen_epdf); + lua_pushstring(L, "epdf"); + lua_call(L, 1, 0); + + lua_createtable(L, 0, 0); + lua_setglobal(L, "texconfig"); + + if (safer_option) { + /* disable some stuff if --safer */ + (void) hide_lua_value(L, "os", "execute"); + (void) hide_lua_value(L, "os", "rename"); + (void) hide_lua_value(L, "os", "remove"); + (void) hide_lua_value(L, "io", "popen"); + /* make io.open only read files */ + luaL_checkstack(L, 2, "out of stack space"); + lua_getglobal(L, "io"); + lua_getfield(L, -1, "open_ro"); + lua_setfield(L, -2, "open"); + (void) hide_lua_value(L, "io", "tmpfile"); + (void) hide_lua_value(L, "io", "output"); + (void) hide_lua_value(L, "lfs", "chdir"); + (void) hide_lua_value(L, "lfs", "lock"); + (void) hide_lua_value(L, "lfs", "touch"); + (void) hide_lua_value(L, "lfs", "rmdir"); + (void) hide_lua_value(L, "lfs", "mkdir"); + } + Luas = L; +} + +@ @c +int hide_lua_table(lua_State * L, const char *name) +{ + int r = 0; + lua_getglobal(L, name); + if (lua_istable(L, -1)) { + r = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushnil(L); + lua_setglobal(L, name); + } + return r; +} + +@ @c +void unhide_lua_table(lua_State * L, const char *name, int r) +{ + lua_rawgeti(L, LUA_REGISTRYINDEX, r); + lua_setglobal(L, name); + luaL_unref(L, LUA_REGISTRYINDEX, r); +} + +@ @c +int hide_lua_value(lua_State * L, const char *name, const char *item) +{ + int r = 0; + lua_getglobal(L, name); + if (lua_istable(L, -1)) { + lua_getfield(L, -1, item); + r = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushnil(L); + lua_setfield(L, -2, item); + } + return r; +} + +@ @c +void unhide_lua_value(lua_State * L, const char *name, const char *item, int r) +{ + lua_getglobal(L, name); + if (lua_istable(L, -1)) { + lua_rawgeti(L, LUA_REGISTRYINDEX, r); + lua_setfield(L, -2, item); + luaL_unref(L, LUA_REGISTRYINDEX, r); + } +} + + +@ @c +int lua_traceback(lua_State * L) +{ + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; +} + +@ @c +static void luacall(int p, int nameptr) +{ + LoadS ls; + int i, l; + char *lua_id; + char *s = NULL; + + if (Luas == NULL) { + luainterpreter(); + } + l = 0; + lua_active++; + s = tokenlist_to_cstring(p, 1, &l); + ls.s = s; + ls.size = (size_t) l; + + if (ls.size > 0) { + if (nameptr > 0) { + lua_id = tokenlist_to_cstring(nameptr, 1, &l); + } else if (nameptr < 0) { + char *tmp = get_lua_name((nameptr + 65536)); + if (tmp != NULL) + lua_id = xstrdup(tmp); + else + lua_id = xstrdup("\\latelua "); + } else { + lua_id = xmalloc(20); + snprintf((char *) lua_id, 20, "\\latelua "); + } + + i = lua_load(Luas, getS, &ls, lua_id); + if (i != 0) { + Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1)); + } else { + int base = lua_gettop(Luas); /* function index */ + lua_checkstack(Luas, 1); + lua_pushcfunction(Luas, lua_traceback); /* push traceback function */ + lua_insert(Luas, base); /* put it under chunk */ + i = lua_pcall(Luas, 0, 0, base); + lua_remove(Luas, base); /* remove traceback function */ + if (i != 0) { + lua_gc(Luas, LUA_GCCOLLECT, 0); + Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); + } + } + xfree(lua_id); + } + lua_active--; +} + +@ @c +void late_lua(PDF pdf, halfword p) +{ + (void) pdf; + expand_macros_in_tokenlist(p); /* sets |def_ref| */ + luacall(def_ref, late_lua_name(p)); + flush_list(def_ref); +} + +@ @c +void luatokencall(int p, int nameptr) +{ + LoadS ls; + int i, l; + char *s = NULL; + char *lua_id; + assert(Luas); + l = 0; + lua_active++; + s = tokenlist_to_cstring(p, 1, &l); + ls.s = s; + ls.size = (size_t) l; + if (ls.size > 0) { + if (nameptr > 0) { + lua_id = tokenlist_to_cstring(nameptr, 1, &l); + } else if (nameptr < 0) { + char *tmp = get_lua_name((nameptr + 65536)); + if (tmp != NULL) + lua_id = xstrdup(tmp); + else + lua_id = xstrdup("\\directlua "); + } else { + lua_id = xstrdup("\\directlua "); + } + i = lua_load(Luas, getS, &ls, lua_id); + xfree(s); + if (i != 0) { + Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1)); + } else { + int base = lua_gettop(Luas); /* function index */ + lua_checkstack(Luas, 1); + lua_pushcfunction(Luas, lua_traceback); /* push traceback function */ + lua_insert(Luas, base); /* put it under chunk */ + i = lua_pcall(Luas, 0, 0, base); + lua_remove(Luas, base); /* remove traceback function */ + if (i != 0) { + lua_gc(Luas, LUA_GCCOLLECT, 0); + Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); + } + } + xfree(lua_id); + } + lua_active--; +} + +@ @c +lua_State *luatex_error(lua_State * L, int is_fatal) +{ + + const char *luaerr; + size_t len = 0; + char *err = NULL; + if (lua_isstring(L, -1)) { + luaerr = lua_tolstring(L, -1, &len); + err = (char *) xmalloc((unsigned) (len + 1)); + len = (size_t) snprintf(err, (len + 1), "%s", luaerr); + } + if (is_fatal > 0) { + /* Normally a memory error from lua. + The pool may overflow during the |maketexlstring()|, but we + are crashing anyway so we may as well abort on the pool size */ + lua_fatal_error(err); + /* never reached */ + xfree(err); + lua_close(L); + return (lua_State *) NULL; + } else { + lua_norm_error(err); + xfree(err); + return L; + } +} + +@ @c +void preset_environment(lua_State * L, const parm_struct * p) +{ + int i; + assert(L != NULL); + lua_newtable(L); /* t */ + for (i = 1, ++p; p->name != NULL; i++, p++) { + assert(i == p->idx); + lua_pushstring(L, p->name); /* k t */ + lua_pushinteger(L, p->idx); /* v k t */ + lua_settable(L, -3); /* t */ + } + lua_replace(L, LUA_ENVIRONINDEX); /* - */ +} diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h new file mode 100644 index 00000000000..155fb6a3cb6 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h @@ -0,0 +1,202 @@ +/* luatex-api.h + + Copyright 2006-2010 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ + +/* $Id: luatex-api.h 3558 2010-03-29 07:21:45Z taco $ */ + +#ifndef LUATEX_API_H +# define LUATEX_API_H 1 + +# include +# include +# include +# include "lua51/lua.h" +# include "lua51/lauxlib.h" +# include "lua51/lualib.h" + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + +extern lua_State *Luas; + +extern void make_table(lua_State * L, const char *tab, const char *getfunc, + const char *setfunc); + +extern int luac_main(int argc, char *argv[]); + +extern int luaopen_tex(lua_State * L); + +extern int luaopen_pdf(lua_State * L); + +# define LUA_TEXFILEHANDLE "TEXFILE*" + +extern int luaopen_texio(lua_State * L); + +extern int luaopen_lang(lua_State * L); + +extern lua_State *luatex_error(lua_State * L, int fatal); + +extern int luaopen_unicode(lua_State * L); +extern int luaopen_zip(lua_State * L); +extern int luaopen_lfs(lua_State * L); +extern int luaopen_lpeg(lua_State * L); +extern int luaopen_md5(lua_State * L); +extern int luatex_md5_lua_open(lua_State * L); + +extern int luaopen_zlib(lua_State * L); +extern int luaopen_gzip(lua_State * L); +extern int luaopen_ff(lua_State * L); +extern int luaopen_profiler(lua_State * L); + +extern int luaopen_socket_core(lua_State * L); +extern int luaopen_mime_core(lua_State * L); +extern void luatex_socketlua_open(lua_State * L); + +extern int luaopen_img(lua_State * L); +extern int l_new_image(lua_State * L); +extern int luaopen_epdf(lua_State * L); +extern int luaopen_mplib(lua_State * L); + +extern void open_oslibext(lua_State * L, int safer_option); + +extern void initfilecallbackids(int max); +extern void setinputfilecallbackid(int n, int i); +extern void setreadfilecallbackid(int n, int i); +extern int getinputfilecallbackid(int n); +extern int getreadfilecallbackid(int n); + +extern void lua_initialize(int ac, char **av); + +extern int luaopen_kpse(lua_State * L); + +extern int luaopen_callback(lua_State * L); + +extern int luaopen_lua(lua_State * L, char *fname); + +extern int luaopen_stats(lua_State * L); + +extern int luaopen_font(lua_State * L); +extern int font_to_lua(lua_State * L, int f); +extern int font_from_lua(lua_State * L, int f); /* return is boolean */ + +extern int luaopen_token(lua_State * L); +extern void tokenlist_to_lua(lua_State * L, int p); +extern void tokenlist_to_luastring(lua_State * L, int p); +extern int tokenlist_from_lua(lua_State * L); + +extern void lua_nodelib_push(lua_State * L); +extern int nodelib_getdir(lua_State * L, int n); + +extern int luaopen_node(lua_State * L); +extern void nodelist_to_lua(lua_State * L, int n); +extern int nodelist_from_lua(lua_State * L); + +extern int dimen_to_number(lua_State * L, const char *s); + +extern int get_command_id(const char *s); + +extern void dump_luac_registers(void); + +extern void undump_luac_registers(void); + +extern int lua_only; + +extern void unhide_lua_table(lua_State * lua, const char *name, int r); +extern int hide_lua_table(lua_State * lua, const char *name); + +extern void unhide_lua_value(lua_State * lua, const char *name, + const char *item, int r); +extern int hide_lua_value(lua_State * lua, const char *name, const char *item); + +typedef struct command_item_ { + const char *cmd_name; + int command_offset; + const char **commands; +} command_item; + +extern command_item command_names[]; +extern int callback_callbacks_id; + +extern void luainterpreter(void); + +extern int luabytecode_max; +extern unsigned int luabytecode_bytes; +extern int luastate_bytes; + +extern int callback_count; +extern int saved_callback_count; + +extern const char *ptexbanner; + +/* luastuff.h */ + +typedef struct { + const char *name; /* parameter name */ + int idx; /* index within img_parms array */ +} parm_struct; + +extern void preset_environment(lua_State * L, const parm_struct * p); + +extern char *startup_filename; +extern int safer_option; +extern int nosocket_option; + +extern char *last_source_name; +extern int last_lineno; + +extern int program_name_set; /* in lkpselib.c */ + +/* for topenin() */ +extern char **argv; +extern int argc; + + +extern int loader_C_luatex(lua_State * L, const char *name, + const char *filename); +extern int loader_Call_luatex (lua_State *L, const char *name, + const char *filename); + + +extern void init_tex_table(lua_State * L); + +extern int tex_table_id; +extern int pdf_table_id; +extern int token_table_id; +extern int node_table_id; +extern int main_initialize(void); + +extern int do_run_callback(int special, const char *values, va_list vl); +extern int lua_traceback(lua_State * L); + +extern int luainit; + +extern char *luanames[]; + +extern int ff_get_ttc_index(char *ffname, char *psname); /* luafontloader/src/luafflib.c */ +extern int ff_createcff(char *, unsigned char **, int *); /* luafontloader/src/luafflib.c */ + +extern char *FindResourceTtfFont(char *filename, char *fontname); /* luafontloader/fontforge/fontforge/macbinary.c */ + +extern char charsetstr[]; /* from mpdir/psout.w */ + +extern char **environ; + + +#endif diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex.c b/Build/source/texk/web2c/luatexdir/lua/luatex.c deleted file mode 100644 index 88903fe338b..00000000000 --- a/Build/source/texk/web2c/luatexdir/lua/luatex.c +++ /dev/null @@ -1,364 +0,0 @@ -/* luatex.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "luatex-api.h" -#include -#include - -static const char _svn_version[] = - "$Id: luatex.c 2599 2009-06-25 10:35:26Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/luatex.c $"; - -/* do this aleph stuff here, for now */ - -void b_test_in(void) -{ - if (program_name_set) { - string fname = kpse_find_file((char *) (nameoffile + 1), - kpse_program_binary_format, true); - if (fname) { - libcfree(nameoffile); - nameoffile = xmalloc(2 + strlen(fname)); - namelength = strlen(fname); - strcpy((char *) nameoffile + 1, fname); - } else { - libcfree(nameoffile); - nameoffile = xmalloc(2); - namelength = 0; - nameoffile[0] = 0; - nameoffile[1] = 0; - } - } -} - - -int **ocp_tables; -static int ocp_entries = 0; - -void -allocate_ocp_table (int ocp_number, int ocp_size) -{ - int i; - if (ocp_entries == 0) { - ocp_tables = (int **) xmalloc(256 * sizeof(int **)); - ocp_entries = 256; - } else if ((ocp_number == 256) && (ocp_entries == 256)) { - ocp_tables = xrealloc(ocp_tables, 65536); - ocp_entries = 65536; - } - ocp_tables[ocp_number] = (int *) xmalloc((1 + ocp_size) * sizeof(int)); - ocp_tables[ocp_number][0] = ocp_size; - for (i = 1; i <= ocp_size; i++) { - ocp_tables[ocp_number][i] = 0; - } -} - -void -dump_ocp_table (int ocp_number) -{ - dump_things(ocp_tables[ocp_number][0], ocp_tables[ocp_number][0] + 1); -} - -void -undump_ocp_table (int ocp_number) -{ - int sizeword; - if (ocp_entries == 0) { - ocp_tables = (int **) xmalloc(256 * sizeof(int **)); - ocp_entries = 256; - } else if ((ocp_number == 256) && (ocp_entries == 256)) { - ocp_tables = xrealloc(ocp_tables, 65536); - ocp_entries = 65536; - } - undump_things(sizeword, 1); - ocp_tables[ocp_number] = (int *) xmalloc((1 + sizeword) * sizeof(int)); - ocp_tables[ocp_number][0] = sizeword; - undump_things(ocp_tables[ocp_number][1], sizeword); -} - - -void -run_external_ocp (string external_ocp_name) -{ - char *in_file_name; - char *out_file_name; - FILE *in_file; - FILE *out_file; - int in_file_fd; - int out_file_fd; - char command_line[400]; - int i; - unsigned c; - int c_in; -#ifdef WIN32 - char *tempenv; - -# define null_string(s) ((s == NULL) || (*s == '\0')) - - tempenv = getenv("TMPDIR"); - if (null_string(tempenv)) - tempenv = getenv("TEMP"); - if (null_string(tempenv)) - tempenv = getenv("TMP"); - if (null_string(tempenv)) - tempenv = "c:/tmp"; /* "/tmp" is not good if we are on a CD-ROM */ - in_file_name = concat(tempenv, "/__aleph__in__XXXXXX"); - mktemp(in_file_name); - in_file = fopen(in_file_name, FOPEN_WBIN_MODE); -#else - in_file_name = strdup("/tmp/__aleph__in__XXXXXX"); - in_file_fd = mkstemp(in_file_name); - in_file = fdopen(in_file_fd, FOPEN_WBIN_MODE); -#endif /* WIN32 */ - - - for (i = 1; i <= otp_input_end; i++) { - c = otp_input_buf[i]; - if (c > 0xffff) { - fprintf(stderr, "Aleph does not currently support 31-bit chars\n"); - exit(1); - } - if (c > 0x4000000) { - fputc(0xfc | ((c >> 30) & 0x1), in_file); - fputc(0x80 | ((c >> 24) & 0x3f), in_file); - fputc(0x80 | ((c >> 18) & 0x3f), in_file); - fputc(0x80 | ((c >> 12) & 0x3f), in_file); - fputc(0x80 | ((c >> 6) & 0x3f), in_file); - fputc(0x80 | (c & 0x3f), in_file); - } else if (c > 0x200000) { - fputc(0xf8 | ((c >> 24) & 0x3), in_file); - fputc(0x80 | ((c >> 18) & 0x3f), in_file); - fputc(0x80 | ((c >> 12) & 0x3f), in_file); - fputc(0x80 | ((c >> 6) & 0x3f), in_file); - fputc(0x80 | (c & 0x3f), in_file); - } else if (c > 0x10000) { - fputc(0xf0 | ((c >> 18) & 0x7), in_file); - fputc(0x80 | ((c >> 12) & 0x3f), in_file); - fputc(0x80 | ((c >> 6) & 0x3f), in_file); - fputc(0x80 | (c & 0x3f), in_file); - } else if (c > 0x800) { - fputc(0xe0 | ((c >> 12) & 0xf), in_file); - fputc(0x80 | ((c >> 6) & 0x3f), in_file); - fputc(0x80 | (c & 0x3f), in_file); - } else if (c > 0x80) { - fputc(0xc0 | ((c >> 6) & 0x1f), in_file); - fputc(0x80 | (c & 0x3f), in_file); - } else { - fputc(c & 0x7f, in_file); - } - } - fclose(in_file); - -#define advance_cin if ((c_in = fgetc(out_file)) == -1) { \ - fprintf(stderr, "File contains bad char\n"); \ - goto end_of_while; \ - } - -#ifdef WIN32 - out_file_name = concat(tempenv, "/__aleph__out__XXXXXX"); - mktemp(out_file_name); - out_file = fopen(out_file_name, FOPEN_RBIN_MODE); -#else - out_file_name = strdup("/tmp/__aleph__out__XXXXXX"); - out_file_fd = mkstemp(out_file_name); - out_file = fdopen(out_file_fd, FOPEN_RBIN_MODE); -#endif - - sprintf(command_line, "%s <%s >%s\n", - external_ocp_name + 1, in_file_name, out_file_name); - system(command_line); - otp_output_end = 0; - otp_output_buf[otp_output_end] = 0; - while ((c_in = fgetc(out_file)) != -1) { - if (c_in >= 0xfc) { - c = (c_in & 0x1) << 30; - advance_cin; - c |= (c_in & 0x3f) << 24; - advance_cin; - c |= (c_in & 0x3f) << 18; - advance_cin; - c |= (c_in & 0x3f) << 12; - advance_cin; - c |= (c_in & 0x3f) << 6; - advance_cin; - c |= c_in & 0x3f; - } else if (c_in >= 0xf8) { - c = (c_in & 0x3) << 24; - advance_cin; - c |= (c_in & 0x3f) << 18; - advance_cin; - c |= (c_in & 0x3f) << 12; - advance_cin; - c |= (c_in & 0x3f) << 6; - advance_cin; - c |= c_in & 0x3f; - } else if (c_in >= 0xf0) { - c = (c_in & 0x7) << 18; - advance_cin; - c |= (c_in & 0x3f) << 12; - advance_cin; - c |= (c_in & 0x3f) << 6; - advance_cin; - c |= c_in & 0x3f; - } else if (c_in >= 0xe0) { - c = (c_in & 0xf) << 12; - advance_cin; - c |= (c_in & 0x3f) << 6; - advance_cin; - c |= c_in & 0x3f; - } else if (c_in >= 0x80) { - c = (c_in & 0x1f) << 6; - advance_cin; - c |= c_in & 0x3f; - } else { - c = c_in & 0x7f; - } - otp_output_buf[++otp_output_end] = c; - } - fclose(out_file); - - end_of_while: - remove(in_file_name); - remove(out_file_name); -} - -/* Read and write dump files through zlib */ - -/* Earlier versions recast *f from FILE * to gzFile, but there is - * no guarantee that these have the same size, so a static variable - * is needed. - */ - -static gzFile gz_fmtfile = NULL; - -void do_zdump(char *p, int item_size, int nitems, FILE * out_file) -{ - int err; - (void) out_file; - if (nitems == 0) - return; - if (gzwrite(gz_fmtfile, (void *) p, item_size * nitems) != - item_size * nitems) { - fprintf(stderr, "! Could not write %d %d-byte item(s): %s.\n", nitems, - item_size, gzerror(gz_fmtfile, &err)); - uexit(1); - } -} - -void do_zundump(char *p, int item_size, int nitems, FILE * in_file) -{ - int err; - (void) in_file; - if (nitems == 0) - return; - if (gzread(gz_fmtfile, (void *) p, item_size * nitems) <= 0) { - fprintf(stderr, "Could not undump %d %d-byte item(s): %s.\n", - nitems, item_size, gzerror(gz_fmtfile, &err)); - uexit(1); - } -} - -#define COMPRESSION "R3" - -boolean zopen_w_input(FILE ** f, int format, const_string fopen_mode) -{ - int callbackid; - int res; - char *fnam; - callbackid = callback_defined(find_format_file_callback); - if (callbackid > 0) { - res = run_callback(callbackid, "S->S", (nameoffile + 1), &fnam); - if (res && fnam && strlen(fnam) > 0) { - xfree(nameoffile); - nameoffile = xmalloc(strlen(fnam) + 2); - memcpy((nameoffile + 1), fnam, strlen(fnam)); - *(nameoffile + strlen(fnam) + 1) = 0; - *f = xfopen(fnam, fopen_mode); - if (*f == NULL) { - return 0; - } - } else { - return 0; - } - } else { - res = open_input(f, format, fopen_mode); - } - if (res) { - gz_fmtfile = gzdopen(fileno(*f), "rb" COMPRESSION); - } - return res; -} - -boolean zopen_w_output(FILE ** f, const_string fopen_mode) -{ - int res = 1; - if (luainit) { - *f = fopen((const_string) (nameoffile + 1), fopen_mode); - if (*f == NULL) { - return 0; - } - } else { - res = open_output(f, fopen_mode); - } - if (res) { - gz_fmtfile = gzdopen(fileno(*f), "wb" COMPRESSION); - } - return res; -} - -void zwclose(FILE * f) -{ - (void) f; - gzclose(gz_fmtfile); -} - -/* create the dvi or pdf file */ - -int open_outfile(FILE ** f, const char *name, const char *mode) -{ - FILE *res; - res = fopen(name, mode); - if (res != NULL) { - *f = res; - return 1; - } - return 0; -} - - -/* the caller sets tfm_buffer=NULL and tfm_size=0 */ - -int readbinfile(FILE * f, unsigned char **tfm_buffer, integer * tfm_size) -{ - void *buf; - int size; - if (fseek(f, 0, SEEK_END) == 0) { - size = ftell(f); - if (size > 0) { - buf = xmalloc(size); - if (fseek(f, 0, SEEK_SET) == 0) { - if (fread((void *) buf, size, 1, f) == 1) { - *tfm_buffer = (unsigned char *) buf; - *tfm_size = (integer) size; - return 1; - } - } - } - } /* seek failed, or zero-sized file */ - return 0; -} diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.c b/Build/source/texk/web2c/luatexdir/lua/luatoken.c deleted file mode 100644 index 628dbf21478..00000000000 --- a/Build/source/texk/web2c/luatexdir/lua/luatoken.c +++ /dev/null @@ -1,602 +0,0 @@ -/* luatoken.c - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -#include "luatex-api.h" -#include - -#include "tokens.h" -#include "commands.h" - -static const char _svn_version[] = - "$Id: luatoken.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/luatoken.c $"; - -command_item command_names[] = { - {"relax", relax_cmd, NULL}, - {"left_brace", left_brace_cmd, NULL}, - {"right_brace", right_brace_cmd, NULL}, - {"math_shift", math_shift_cmd, NULL}, - {"tab_mark", tab_mark_cmd, NULL}, - {"car_ret", car_ret_cmd, NULL}, - {"mac_param", mac_param_cmd, NULL}, - {"sup_mark", sup_mark_cmd, NULL}, - {"sub_mark", sub_mark_cmd, NULL}, - {"endv", endv_cmd, NULL}, - {"spacer", spacer_cmd, NULL}, - {"letter", letter_cmd, NULL}, - {"other_char", other_char_cmd, NULL}, - {"par_end", par_end_cmd, NULL}, - {"stop", stop_cmd, NULL}, - {"delim_num", delim_num_cmd, NULL}, - {"char_num", char_num_cmd, NULL}, - {"math_char_num", math_char_num_cmd, NULL}, - {"mark", mark_cmd, NULL}, - {"xray", xray_cmd, NULL}, - {"make_box", make_box_cmd, NULL}, - {"hmove", hmove_cmd, NULL}, - {"vmove", vmove_cmd, NULL}, - {"un_hbox", un_hbox_cmd, NULL}, - {"un_vbox", un_vbox_cmd, NULL}, - {"remove_item", remove_item_cmd, NULL}, - {"hskip", hskip_cmd, NULL}, - {"vskip", vskip_cmd, NULL}, - {"mskip", mskip_cmd, NULL}, - {"kern", kern_cmd, NULL}, - {"mkern", mkern_cmd, NULL}, - {"leader_ship", leader_ship_cmd, NULL}, - {"halign", halign_cmd, NULL}, - {"valign", valign_cmd, NULL}, - {"no_align", no_align_cmd, NULL}, - {"vrule", vrule_cmd, NULL}, - {"hrule", hrule_cmd, NULL}, - {"insert", insert_cmd, NULL}, - {"vadjust", vadjust_cmd, NULL}, - {"ignore_spaces", ignore_spaces_cmd, NULL}, - {"after_assignment", after_assignment_cmd, NULL}, - {"after_group", after_group_cmd, NULL}, - {"break_penalty", break_penalty_cmd, NULL}, - {"start_par", start_par_cmd, NULL}, - {"ital_corr", ital_corr_cmd, NULL}, - {"accent", accent_cmd, NULL}, - {"math_accent", math_accent_cmd, NULL}, - {"discretionary", discretionary_cmd, NULL}, - {"eq_no", eq_no_cmd, NULL}, - {"left_right", left_right_cmd, NULL}, - {"math_comp", math_comp_cmd, NULL}, - {"limit_switch", limit_switch_cmd, NULL}, - {"above", above_cmd, NULL}, - {"math_style", math_style_cmd, NULL}, - {"math_choice", math_choice_cmd, NULL}, - {"non_script", non_script_cmd, NULL}, - {"vcenter", vcenter_cmd, NULL}, - {"case_shift", case_shift_cmd, NULL}, - {"message", message_cmd, NULL}, - {"extension", extension_cmd, NULL}, - {"in_stream", in_stream_cmd, NULL}, - {"begin_group", begin_group_cmd, NULL}, - {"end_group", end_group_cmd, NULL}, - {"omit", omit_cmd, NULL}, - {"ex_space", ex_space_cmd, NULL}, - {"no_boundary", no_boundary_cmd, NULL}, - {"radical", radical_cmd, NULL}, - {"super_sub_script", super_sub_script_cmd, NULL}, - {"math_shift_cs", math_shift_cs_cmd, NULL}, - {"end_cs_name", end_cs_name_cmd, NULL}, - {"char_ghost", char_ghost_cmd, NULL}, - {"assign_local_box", assign_local_box_cmd, NULL}, - {"char_given", char_given_cmd, NULL}, - {"math_given", math_given_cmd, NULL}, - {"omath_given", omath_given_cmd, NULL}, - {"xmath_given", xmath_given_cmd, NULL}, - {"last_item", last_item_cmd, NULL}, - {"toks_register", toks_register_cmd, NULL}, - {"assign_toks", assign_toks_cmd, NULL}, - {"assign_int", assign_int_cmd, NULL}, - {"assign_attr", assign_attr_cmd, NULL}, - {"assign_dimen", assign_dimen_cmd, NULL}, - {"assign_glue", assign_glue_cmd, NULL}, - {"assign_mu_glue", assign_mu_glue_cmd, NULL}, - {"assign_font_dimen", assign_font_dimen_cmd, NULL}, - {"assign_font_int", assign_font_int_cmd, NULL}, - {"set_aux", set_aux_cmd, NULL}, - {"set_prev_graf", set_prev_graf_cmd, NULL}, - {"set_page_dimen", set_page_dimen_cmd, NULL}, - {"set_page_int", set_page_int_cmd, NULL}, - {"set_box_dimen", set_box_dimen_cmd, NULL}, - {"set_tex_shape", set_tex_shape_cmd, NULL}, - {"set_etex_shape", set_etex_shape_cmd, NULL}, - {"def_char_code", def_char_code_cmd, NULL}, - {"def_del_code", def_del_code_cmd, NULL}, - {"extdef_math_code", extdef_math_code_cmd, NULL}, - {"extdef_del_code", extdef_del_code_cmd, NULL}, - {"def_family", def_family_cmd, NULL}, - {"set_math_param", set_math_param_cmd, NULL}, - {"set_font", set_font_cmd, NULL}, - {"def_font", def_font_cmd, NULL}, - {"register", register_cmd, NULL}, - {"assign_box_dir", assign_box_dir_cmd, NULL}, - {"assign_dir", assign_dir_cmd, NULL}, - {"advance", advance_cmd, NULL}, - {"multiply", multiply_cmd, NULL}, - {"divide", divide_cmd, NULL}, - {"prefix", prefix_cmd, NULL}, - {"let", let_cmd, NULL}, - {"shorthand_def", shorthand_def_cmd, NULL}, - {"read_to_cs", read_to_cs_cmd, NULL}, - {"def", def_cmd, NULL}, - {"set_box", set_box_cmd, NULL}, - {"hyph_data", hyph_data_cmd, NULL}, - {"set_interaction", set_interaction_cmd, NULL}, - {"letterspace_font", letterspace_font_cmd, NULL}, - {"pdf_copy_font", pdf_copy_font_cmd, NULL}, - {"set_ocp", set_ocp_cmd, NULL}, - {"def_ocp", def_ocp_cmd, NULL}, - {"set_ocp_list", set_ocp_list_cmd, NULL}, - {"def_ocp_list", def_ocp_list_cmd, NULL}, - {"clear_ocp_lists", clear_ocp_lists_cmd, NULL}, - {"push_ocp_list", push_ocp_list_cmd, NULL}, - {"pop_ocp_list", pop_ocp_list_cmd, NULL}, - {"ocp_list_op", ocp_list_op_cmd, NULL}, - {"ocp_trace_level", ocp_trace_level_cmd, NULL}, - {"undefined_cs", undefined_cs_cmd, NULL}, - {"expand_after", expand_after_cmd, NULL}, - {"no_expand", no_expand_cmd, NULL}, - {"input", input_cmd, NULL}, - {"if_test", if_test_cmd, NULL}, - {"fi_or_else", fi_or_else_cmd, NULL}, - {"cs_name", cs_name_cmd, NULL}, - {"convert", convert_cmd, NULL}, - {"the", the_cmd, NULL}, - {"top_bot_mark", top_bot_mark_cmd, NULL}, - {"call", call_cmd, NULL}, - {"long_call", long_call_cmd, NULL}, - {"outer_call", outer_call_cmd, NULL}, - {"long_outer_call", long_outer_call_cmd, NULL}, - {"end_template", end_template_cmd, NULL}, - {"dont_expand", dont_expand_cmd, NULL}, - {"glue_ref", glue_ref_cmd, NULL}, - {"shape_ref", shape_ref_cmd, NULL}, - {"box_ref", box_ref_cmd, NULL}, - {"data", data_cmd, NULL}, - {NULL, 0, NULL} -}; - - -int get_command_id(const char *s) -{ - int i; - int cmd = -1; - for (i = 0; command_names[i].cmd_name != NULL; i++) { - if (strcmp(s, command_names[i].cmd_name) == 0) - break; - } - if (command_names[i].cmd_name != NULL) { - cmd = i; - } - return cmd; -} - -static int get_cur_cmd(lua_State * L) -{ - int r = 0; - int len = lua_objlen(L, -1); - cur_cs = 0; - if (len == 3 || len == 2) { - r = 1; - lua_rawgeti(L, -1, 1); - cur_cmd = lua_tointeger(L, -1); - lua_rawgeti(L, -2, 2); - cur_chr = lua_tointeger(L, -1); - if (len == 3) { - lua_rawgeti(L, -3, 3); - cur_cs = lua_tointeger(L, -1); - } - lua_pop(L, len); - if (cur_cs == 0) - cur_tok = (cur_cmd * string_offset) + cur_chr; - else - cur_tok = cs_token_flag + cur_cs; - } - return r; -} - - -static int token_from_lua(lua_State * L) -{ - int cmd, chr; - int cs = 0; - int len = lua_objlen(L, -1); - if (len == 3 || len == 2) { - lua_rawgeti(L, -1, 1); - cmd = lua_tointeger(L, -1); - lua_rawgeti(L, -2, 2); - chr = lua_tointeger(L, -1); - if (len == 3) { - lua_rawgeti(L, -3, 3); - cs = lua_tointeger(L, -1); - } - lua_pop(L, len); - if (cs == 0) { - return (cmd * string_offset) + chr; - } else { - return cs_token_flag + cs; - } - } - return -1; -} - -static int get_cur_cs(lua_State * L) -{ - const char *s; - unsigned j; - size_t l; - integer cs; - int save_nncs; - int ret; - ret = 0; - cur_cs = 0; - lua_getfield(L, -1, "name"); - if (lua_isstring(L, -1)) { - s = lua_tolstring(L, -1, &l); - if (l > 0) { - if ((int) (last + l) > buf_size) - check_buffer_overflow(last + l); - for (j = 0; j < l; j++) { - buffer[last + 1 + j] = *s++; - } - save_nncs = no_new_control_sequence; - no_new_control_sequence = false; - cs = id_lookup((last + 1), l); - cur_tok = cs_token_flag + cs; - cur_cmd = zget_eq_type(cs); - cur_chr = zget_equiv(cs); - no_new_control_sequence = save_nncs; - ret = 1; - } - } - lua_pop(L, 1); - return ret; -} - - -#define make_room(a) \ - if ((i+a+1)>alloci) { \ - ret = xrealloc(ret,alloci+64); \ - alloci = alloci + 64; \ - } - - -#define append_i_byte(a) ret[i++] = a - -#define Print_char(a) make_room(1); append_i_byte(a) - -#define Print_uchar(s) { \ - make_room(4); \ - if (s<=0x7F) { \ - append_i_byte(s); \ - } else if (s<=0x7FF) { \ - append_i_byte(0xC0 + (s / 0x40)); \ - append_i_byte(0x80 + (s % 0x40)); \ - } else if (s<=0xFFFF) { \ - append_i_byte(0xE0 + (s / 0x1000)); \ - append_i_byte(0x80 + ((s % 0x1000) / 0x40)); \ - append_i_byte(0x80 + ((s % 0x1000) % 0x40)); \ - } else if (s>=0x110000) { \ - append_i_byte(s-0x11000); \ - } else { \ - append_i_byte(0xF0 + (s / 0x40000)); \ - append_i_byte(0x80 + ((s % 0x40000) / 0x1000)); \ - append_i_byte(0x80 + (((s % 0x40000) % 0x1000) / 0x40)); \ - append_i_byte(0x80 + (((s % 0x40000) % 0x1000) % 0x40)); \ - } } - - -#define Print_esc(b) { \ - const char *v = b; \ - if (e>0 && e=0xF0))|| \ - ((length(a)==3)&&(str_pool[str_start_macro(a)]>=0xE0))|| \ - ((length(a)==2)&&(str_pool[str_start_macro(a)]>=0xC0)) - -#define is_active_cs(a) (length(a)>3 && \ - (str_pool[str_start_macro(a)] == 0xEF) && \ - (str_pool[str_start_macro(a)+1] == 0xBF) && \ - (str_pool[str_start_macro(a)+2] == 0xBF)) - -#define is_cat_letter(a) \ - (get_char_cat_code(pool_to_unichar(str_start_macro(a))) == 11) - -static int null_cs = 0; -static int eqtb_size = 0; - -/* 2,720,652 */ -char *tokenlist_to_cstring(int pp, int inhibit_par, int *siz) -{ - register integer p, c, m; - integer q; - integer infop; - char *s; - int e; - char *ret; - int match_chr = '#'; - int n = '0'; - int alloci = 1024; - int i = 0; - p = pp; - if (p == null || link(p) == null) { - if (siz != NULL) - *siz = 0; - return NULL; - } - ret = xmalloc(alloci); - p = link(p); /* skip refcount */ - if (null_cs == 0) { - null_cs = get_nullcs(); - eqtb_size = get_eqtb_size(); - } - e = get_escape_char(); - while (p != null) { - if (p < fix_mem_min || p > fix_mem_end) { - Print_esc("CLOBBERED."); - break; - } - infop = info(p); - if (infop >= cs_token_flag) { - if (!(inhibit_par && infop == par_token)) { - q = infop - cs_token_flag; - if (q < hash_base) { - if (q == null_cs) { - /* Print_esc("csname"); Print_esc("endcsname"); */ - } - } else if ((q >= static_undefined_control_sequence) - && ((q <= eqtb_size) - || (q > eqtb_size + hash_extra))) { - Print_esc("IMPOSSIBLE."); - } else if ((zget_cs_text(q) < 0) - || (zget_cs_text(q) >= str_ptr)) { - Print_esc("NONEXISTENT."); - } else { - str_number txt = zget_cs_text(q); - s = makecstring(txt); - if (is_active_cs(txt)) { - s = s + 3; - while (*s) { - Print_char(*s); - s++; - } - } else { - Print_uchar(e); - while (*s) { - Print_char(*s); - s++; - } - if ((!single_letter(zget_cs_text(q))) - || is_cat_letter(zget_cs_text(q))) { - Print_char(' '); - } - } - } - } - } else { - if (infop < 0) { - Print_esc("BAD."); - } else { - m = infop >> string_offset_bits; - c = infop & (string_offset - 1); - switch (m) { - case 10: - case 11: - case 12: - case 1: - case 2: - case 3: - case 4: - case 7: - case 8: - Print_uchar(c); - break; - case 6: - /* Print_uchar(c); */ - Print_uchar(c); - break; - case 5: - Print_uchar(match_chr); - if (c <= 9) { - Print_char(c + '0'); - } else { - Print_char('!'); - xfree(ret); - return NULL; - } - break; - case 13: - match_chr = c; - Print_uchar(c); - n++; - Print_char(n); - if (n > '9') { - xfree(ret); - return NULL; - } - break; - case 14: - if (c == 0) { - Print_char('-'); - Print_char('>'); - } - break; - default: - Print_esc("BAD."); - break; - } - } - } - p = link(p); - } - ret[i] = 0; - if (siz != NULL) - *siz = i; - return ret; -} - - -void tokenlist_to_lua(lua_State * L, int p) -{ - int cmd, chr, cs; - int v; - int i = 1; - v = p; - while (v != null && v < fix_mem_end) { - i++; - v = link(v); - } - i = 1; - lua_createtable(L, i, 0); - while (p != null && p < fix_mem_end) { - if (info(p) >= cs_token_flag) { - cs = info(p) - cs_token_flag; - cmd = zget_eq_type(cs); - chr = zget_equiv(cs); - make_token_table(L, cmd, chr, cs); - } else { - cmd = info(p) / string_offset; - chr = info(p) % string_offset; - make_token_table(L, cmd, chr, 0); - } - lua_rawseti(L, -2, i++); - p = link(p); - } -} - - -void tokenlist_to_luastring(lua_State * L, int p) -{ - int l; - char *s; - s = tokenlist_to_cstring(p, 1, &l); - lua_pushlstring(L, s, l); -} - - -int tokenlist_from_lua(lua_State * L) -{ - const char *s; - int tok; - size_t i, j; - halfword p, q, r; - r = get_avail(); - info(r) = 0; /* ref count */ - link(r) = null; - p = r; - if (lua_istable(L, -1)) { - j = lua_objlen(L, -1); - if (j > 0) { - for (i = 1; i <= j; i++) { - lua_rawgeti(L, -1, i); - tok = token_from_lua(L); - if (tok >= 0) { - store_new_token(tok); - } - lua_pop(L, 1); - }; - } - return r; - } else if (lua_isstring(L, -1)) { - s = lua_tolstring(L, -1, &j); - for (i = 0; i < j; i++) { - if (s[i] == 32) { - tok = (10 * string_offset) + s[i]; - } else { - tok = (12 * string_offset) + s[i]; - } - store_new_token(tok); - } - return r; - } else { - free_avail(r); - return null; - } -} - -void do_get_token_lua(integer callback_id) -{ - lua_State *L = Luas; - while (1) { - if (!get_callback(L, callback_id)) { - get_next(); - lua_pop(L, 2); /* the not-a-function callback and the container */ - break; - } - if (lua_pcall(L, 0, 1, 0) != 0) { /* no arg, 1 result */ - tex_error(lua_tostring(L, -1), NULL); - lua_pop(L, 2); /* container and result */ - break; - } - if (lua_istable(L, -1)) { - lua_rawgeti(L, -1, 1); - if (lua_istable(L, -1)) { /* container, result, result[1] */ - integer p, q, r; - int i, j; - lua_pop(L, 1); /* container, result */ - /* build a token list */ - r = get_avail(); - p = r; - j = lua_objlen(L, -1); - if (j > 0) { - for (i = 1; i <= j; i++) { - lua_rawgeti(L, -1, i); - if (get_cur_cmd(L) || get_cur_cs(L)) { - store_new_token(cur_tok); - } - lua_pop(L, 1); - } - } - if (p != r) { - p = link(r); - free_avail(r); - begin_token_list(p, inserted); - cur_input.nofilter_field = true; - get_next(); - } else { - tex_error("error: illegal or empty token list returned", - NULL); - } - lua_pop(L, 2); - break; - } else { /* container, result, whatever */ - lua_pop(L, 1); /* container, result */ - if (get_cur_cmd(L) || get_cur_cs(L)) { - lua_pop(L, 2); - break; - } else { - lua_pop(L, 2); - continue; - } - } - } else { - lua_pop(L, 2); /* container, result */ - } - } - return; -} diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.w b/Build/source/texk/web2c/luatexdir/lua/luatoken.w new file mode 100644 index 00000000000..7a96fcd1a11 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/luatoken.w @@ -0,0 +1,423 @@ +% luatoken.w +% +% Copyright 2006-2010 Taco Hoekwater + +% This file is part of LuaTeX. + +% LuaTeX is free software; you can redistribute it and/or modify it under +% the terms of the GNU General Public License as published by the Free +% Software Foundation; either version 2 of the License, or (at your +% option) any later version. + +% LuaTeX is distributed in the hope that it will be useful, but WITHOUT +% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +% License for more details. + +% You should have received a copy of the GNU General Public License along +% with LuaTeX; if not, see . + +@ @c +#include "lua/luatex-api.h" +#include "ptexlib.h" + +static const char _svn_version[] = + "$Id: luatoken.w 3583 2010-04-02 17:40:44Z hhenkel $ " +"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/luatoken.w $"; + +@ @c +command_item command_names[] = { + {"relax", relax_cmd, NULL}, + {"left_brace", left_brace_cmd, NULL}, + {"right_brace", right_brace_cmd, NULL}, + {"math_shift", math_shift_cmd, NULL}, + {"tab_mark", tab_mark_cmd, NULL}, + {"car_ret", car_ret_cmd, NULL}, + {"mac_param", mac_param_cmd, NULL}, + {"sup_mark", sup_mark_cmd, NULL}, + {"sub_mark", sub_mark_cmd, NULL}, + {"endv", endv_cmd, NULL}, + {"spacer", spacer_cmd, NULL}, + {"letter", letter_cmd, NULL}, + {"other_char", other_char_cmd, NULL}, + {"par_end", par_end_cmd, NULL}, + {"stop", stop_cmd, NULL}, + {"delim_num", delim_num_cmd, NULL}, + {"char_num", char_num_cmd, NULL}, + {"math_char_num", math_char_num_cmd, NULL}, + {"mark", mark_cmd, NULL}, + {"xray", xray_cmd, NULL}, + {"make_box", make_box_cmd, NULL}, + {"hmove", hmove_cmd, NULL}, + {"vmove", vmove_cmd, NULL}, + {"un_hbox", un_hbox_cmd, NULL}, + {"un_vbox", un_vbox_cmd, NULL}, + {"remove_item", remove_item_cmd, NULL}, + {"hskip", hskip_cmd, NULL}, + {"vskip", vskip_cmd, NULL}, + {"mskip", mskip_cmd, NULL}, + {"kern", kern_cmd, NULL}, + {"mkern", mkern_cmd, NULL}, + {"leader_ship", leader_ship_cmd, NULL}, + {"halign", halign_cmd, NULL}, + {"valign", valign_cmd, NULL}, + {"no_align", no_align_cmd, NULL}, + {"vrule", vrule_cmd, NULL}, + {"hrule", hrule_cmd, NULL}, + {"insert", insert_cmd, NULL}, + {"vadjust", vadjust_cmd, NULL}, + {"ignore_spaces", ignore_spaces_cmd, NULL}, + {"after_assignment", after_assignment_cmd, NULL}, + {"after_group", after_group_cmd, NULL}, + {"break_penalty", break_penalty_cmd, NULL}, + {"start_par", start_par_cmd, NULL}, + {"ital_corr", ital_corr_cmd, NULL}, + {"accent", accent_cmd, NULL}, + {"math_accent", math_accent_cmd, NULL}, + {"discretionary", discretionary_cmd, NULL}, + {"eq_no", eq_no_cmd, NULL}, + {"left_right", left_right_cmd, NULL}, + {"math_comp", math_comp_cmd, NULL}, + {"limit_switch", limit_switch_cmd, NULL}, + {"above", above_cmd, NULL}, + {"math_style", math_style_cmd, NULL}, + {"math_choice", math_choice_cmd, NULL}, + {"non_script", non_script_cmd, NULL}, + {"vcenter", vcenter_cmd, NULL}, + {"case_shift", case_shift_cmd, NULL}, + {"message", message_cmd, NULL}, + {"extension", extension_cmd, NULL}, + {"in_stream", in_stream_cmd, NULL}, + {"begin_group", begin_group_cmd, NULL}, + {"end_group", end_group_cmd, NULL}, + {"omit", omit_cmd, NULL}, + {"ex_space", ex_space_cmd, NULL}, + {"no_boundary", no_boundary_cmd, NULL}, + {"radical", radical_cmd, NULL}, + {"super_sub_script", super_sub_script_cmd, NULL}, + {"math_shift_cs", math_shift_cs_cmd, NULL}, + {"end_cs_name", end_cs_name_cmd, NULL}, + {"char_ghost", char_ghost_cmd, NULL}, + {"assign_local_box", assign_local_box_cmd, NULL}, + {"char_given", char_given_cmd, NULL}, + {"math_given", math_given_cmd, NULL}, + {"omath_given", omath_given_cmd, NULL}, + {"xmath_given", xmath_given_cmd, NULL}, + {"last_item", last_item_cmd, NULL}, + {"toks_register", toks_register_cmd, NULL}, + {"assign_toks", assign_toks_cmd, NULL}, + {"assign_int", assign_int_cmd, NULL}, + {"assign_attr", assign_attr_cmd, NULL}, + {"assign_dimen", assign_dimen_cmd, NULL}, + {"assign_glue", assign_glue_cmd, NULL}, + {"assign_mu_glue", assign_mu_glue_cmd, NULL}, + {"assign_font_dimen", assign_font_dimen_cmd, NULL}, + {"assign_font_int", assign_font_int_cmd, NULL}, + {"set_aux", set_aux_cmd, NULL}, + {"set_prev_graf", set_prev_graf_cmd, NULL}, + {"set_page_dimen", set_page_dimen_cmd, NULL}, + {"set_page_int", set_page_int_cmd, NULL}, + {"set_box_dimen", set_box_dimen_cmd, NULL}, + {"set_tex_shape", set_tex_shape_cmd, NULL}, + {"set_etex_shape", set_etex_shape_cmd, NULL}, + {"def_char_code", def_char_code_cmd, NULL}, + {"def_del_code", def_del_code_cmd, NULL}, + {"extdef_math_code", extdef_math_code_cmd, NULL}, + {"extdef_del_code", extdef_del_code_cmd, NULL}, + {"def_family", def_family_cmd, NULL}, + {"set_math_param", set_math_param_cmd, NULL}, + {"set_font", set_font_cmd, NULL}, + {"def_font", def_font_cmd, NULL}, + {"register", register_cmd, NULL}, + {"assign_box_dir", assign_box_dir_cmd, NULL}, + {"assign_dir", assign_dir_cmd, NULL}, + {"advance", advance_cmd, NULL}, + {"multiply", multiply_cmd, NULL}, + {"divide", divide_cmd, NULL}, + {"prefix", prefix_cmd, NULL}, + {"let", let_cmd, NULL}, + {"shorthand_def", shorthand_def_cmd, NULL}, + {"read_to_cs", read_to_cs_cmd, NULL}, + {"def", def_cmd, NULL}, + {"set_box", set_box_cmd, NULL}, + {"hyph_data", hyph_data_cmd, NULL}, + {"set_interaction", set_interaction_cmd, NULL}, + {"letterspace_font", letterspace_font_cmd, NULL}, + {"pdf_copy_font", pdf_copy_font_cmd, NULL}, + {"set_ocp", set_ocp_cmd, NULL}, + {"def_ocp", def_ocp_cmd, NULL}, + {"set_ocp_list", set_ocp_list_cmd, NULL}, + {"def_ocp_list", def_ocp_list_cmd, NULL}, + {"clear_ocp_lists", clear_ocp_lists_cmd, NULL}, + {"push_ocp_list", push_ocp_list_cmd, NULL}, + {"pop_ocp_list", pop_ocp_list_cmd, NULL}, + {"ocp_list_op", ocp_list_op_cmd, NULL}, + {"ocp_trace_level", ocp_trace_level_cmd, NULL}, + {"undefined_cs", undefined_cs_cmd, NULL}, + {"expand_after", expand_after_cmd, NULL}, + {"no_expand", no_expand_cmd, NULL}, + {"input", input_cmd, NULL}, + {"if_test", if_test_cmd, NULL}, + {"fi_or_else", fi_or_else_cmd, NULL}, + {"cs_name", cs_name_cmd, NULL}, + {"convert", convert_cmd, NULL}, + {"the", the_cmd, NULL}, + {"top_bot_mark", top_bot_mark_cmd, NULL}, + {"call", call_cmd, NULL}, + {"long_call", long_call_cmd, NULL}, + {"outer_call", outer_call_cmd, NULL}, + {"long_outer_call", long_outer_call_cmd, NULL}, + {"end_template", end_template_cmd, NULL}, + {"dont_expand", dont_expand_cmd, NULL}, + {"glue_ref", glue_ref_cmd, NULL}, + {"shape_ref", shape_ref_cmd, NULL}, + {"box_ref", box_ref_cmd, NULL}, + {"data", data_cmd, NULL}, + {NULL, 0, NULL} +}; + + +@ @c +int get_command_id(const char *s) +{ + int i; + int cmd = -1; + for (i = 0; command_names[i].cmd_name != NULL; i++) { + if (strcmp(s, command_names[i].cmd_name) == 0) + break; + } + if (command_names[i].cmd_name != NULL) { + cmd = i; + } + return cmd; +} + +@ @c +static int get_cur_cmd(lua_State * L) +{ + int r = 0; + size_t len = lua_objlen(L, -1); + cur_cs = 0; + if (len == 3 || len == 2) { + r = 1; + lua_rawgeti(L, -1, 1); + cur_cmd = (int) lua_tointeger(L, -1); + lua_rawgeti(L, -2, 2); + cur_chr = (halfword) lua_tointeger(L, -1); + if (len == 3) { + lua_rawgeti(L, -3, 3); + cur_cs = (halfword) lua_tointeger(L, -1); + } + lua_pop(L, (int) len); + if (cur_cs == 0) + cur_tok = token_val(cur_cmd, cur_chr); + else + cur_tok = cs_token_flag + cur_cs; + } + return r; +} + + +@ @c +static int token_from_lua(lua_State * L) +{ + int cmd, chr; + int cs = 0; + size_t len = lua_objlen(L, -1); + if (len == 3 || len == 2) { + lua_rawgeti(L, -1, 1); + cmd = (int) lua_tointeger(L, -1); + lua_rawgeti(L, -2, 2); + chr = (int) lua_tointeger(L, -1); + if (len == 3) { + lua_rawgeti(L, -3, 3); + cs = (int) lua_tointeger(L, -1); + } + lua_pop(L, (int) len); + if (cs == 0) { + return token_val(cmd, chr); + } else { + return cs_token_flag + cs; + } + } + return -1; +} + +@ @c +static int get_cur_cs(lua_State * L) +{ + const char *s; + unsigned j; + size_t l; + int cs; + int save_nncs; + int ret; + ret = 0; + cur_cs = 0; + lua_getfield(L, -1, "name"); + if (lua_isstring(L, -1)) { + s = lua_tolstring(L, -1, &l); + if (l > 0) { + if ((last + (int) l) > buf_size) + check_buffer_overflow((last + (int) l)); + for (j = 0; j < l; j++) { + buffer[(unsigned) last + 1 + j] = (packed_ASCII_code) * s++; + } + save_nncs = no_new_control_sequence; + no_new_control_sequence = false; + cs = id_lookup((last + 1), (int) l); + cur_tok = cs_token_flag + cs; + cur_cmd = eq_type(cs); + cur_chr = equiv(cs); + no_new_control_sequence = save_nncs; + ret = 1; + } + } + lua_pop(L, 1); + return ret; +} + +@ @c +void tokenlist_to_lua(lua_State * L, int p) +{ + int cmd, chr, cs; + int v; + int i = 1; + v = p; + while (v != null && v < (int) fix_mem_end) { + i++; + v = token_link(v); + } + i = 1; + lua_createtable(L, i, 0); + while (p != null && p < (int) fix_mem_end) { + if (token_info(p) >= cs_token_flag) { + cs = token_info(p) - cs_token_flag; + cmd = eq_type(cs); + chr = equiv(cs); + make_token_table(L, cmd, chr, cs); + } else { + cmd = token_cmd(token_info(p)); + chr = token_chr(token_info(p)); + make_token_table(L, cmd, chr, 0); + } + lua_rawseti(L, -2, i++); + p = token_link(p); + } +} + +@ @c +void tokenlist_to_luastring(lua_State * L, int p) +{ + int l; + char *s; + s = tokenlist_to_cstring(p, 1, &l); + lua_pushlstring(L, s, (size_t) l); +} + + +@ @c +int tokenlist_from_lua(lua_State * L) +{ + const char *s; + int tok; + size_t i, j; + halfword p, q, r; + r = get_avail(); + token_info(r) = 0; /* ref count */ + token_link(r) = null; + p = r; + if (lua_istable(L, -1)) { + j = lua_objlen(L, -1); + if (j > 0) { + for (i = 1; i <= j; i++) { + lua_rawgeti(L, -1, (int) i); + tok = token_from_lua(L); + if (tok >= 0) { + store_new_token(tok); + } + lua_pop(L, 1); + }; + } + return r; + } else if (lua_isstring(L, -1)) { + s = lua_tolstring(L, -1, &j); + for (i = 0; i < j; i++) { + if (s[i] == 32) { + tok = token_val(10, s[i]); + } else { + int j = (int) str2uni((const unsigned char *) (s + i)); + i = i + (size_t) (utf8_size(j) - 1); + tok = token_val(12, j); + } + store_new_token(tok); + } + return r; + } else { + free_avail(r); + return null; + } +} + +@ @c +void do_get_token_lua(int callback_id) +{ + lua_State *L = Luas; + while (1) { + if (!get_callback(L, callback_id)) { + get_next(); + lua_pop(L, 2); /* the not-a-function callback and the container */ + break; + } + if (lua_pcall(L, 0, 1, 0) != 0) { /* no arg, 1 result */ + tex_error(lua_tostring(L, -1), NULL); + lua_pop(L, 2); /* container and result */ + break; + } + if (lua_istable(L, -1)) { + lua_rawgeti(L, -1, 1); + if (lua_istable(L, -1)) { /* container, result, result[1] */ + int p, q, r; + size_t i, j; + lua_pop(L, 1); /* container, result */ + /* build a token list */ + r = get_avail(); + p = r; + j = lua_objlen(L, -1); + if (j > 0) { + for (i = 1; i <= j; i++) { + lua_rawgeti(L, -1, (int) i); + if (get_cur_cmd(L) || get_cur_cs(L)) { + store_new_token(cur_tok); + } + lua_pop(L, 1); + } + } + if (p != r) { + p = token_link(r); + free_avail(r); + begin_token_list(p, inserted); + cur_input.nofilter_field = true; + get_next(); + } else { + tex_error("error: illegal or empty token list returned", + NULL); + } + lua_pop(L, 2); + break; + } else { /* container, result, whatever */ + lua_pop(L, 1); /* container, result */ + if (get_cur_cmd(L) || get_cur_cs(L)) { + lua_pop(L, 2); + break; + } else { + lua_pop(L, 2); + continue; + } + } + } else { + lua_pop(L, 2); /* container, result */ + } + } + return; +} diff --git a/Build/source/texk/web2c/luatexdir/lua/texluac.c b/Build/source/texk/web2c/luatexdir/lua/texluac.c deleted file mode 100644 index c994785bd08..00000000000 --- a/Build/source/texk/web2c/luatexdir/lua/texluac.c +++ /dev/null @@ -1,231 +0,0 @@ -/* texlua.c - -* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. -* -* 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. - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. -*/ - -#include -#include -#include -#include - -#define luac_c -#define LUA_CORE - -#include <../lua51/lua.h> -#include <../lua51/lauxlib.h> - -#include <../lua51/ldo.h> -#include <../lua51/lfunc.h> -#include <../lua51/lmem.h> -#include <../lua51/lobject.h> -#include <../lua51/lopcodes.h> -#include <../lua51/lstring.h> -#include <../lua51/lundump.h> - -#include "luatex-api.h" - -static const char _svn_version[] = - "$Id: texluac.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/texluac.c $"; - -#define PROGNAME "texluac" /* default program name */ -#define OUTPUT PROGNAME ".out" /* default output file */ - -static int dumping = 1; /* dump bytecodes? */ -static int stripping = 0; /* strip debug information? */ -static char Output[] = { OUTPUT }; /* default output file name */ -static const char *output = Output; /* actual output file name */ -static const char *progname = PROGNAME; /* actual program name */ - -static void fatal(const char *message) -{ - fprintf(stderr, "%s: %s\n", progname, message); - exit(EXIT_FAILURE); -} - -static void cannot(const char *what) -{ - fprintf(stderr, "%s: cannot %s %s: %s\n", progname, what, output, - strerror(errno)); - exit(EXIT_FAILURE); -} - -static void usage(const char *message) -{ - if (*message == '-') - fprintf(stderr, "%s: unrecognized option " LUA_QS "\n", progname, - message); - else - fprintf(stderr, "%s: %s\n", progname, message); - fprintf(stderr, - "usage: %s [options] [filenames].\n" - "Available options are:\n" - " - process stdin\n" - " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" - " -p parse only\n" - " -s strip debug information\n" - " -v show version information\n" - " -- stop handling options\n", progname, Output); - exit(EXIT_FAILURE); -} - -#define IS(s) (strcmp(argv[i],s)==0) - -static int doargs(int argc, char *argv[]) -{ - int i; - int version = 0; - if (argv[0] != NULL && *argv[0] != 0) - progname = argv[0]; - for (i = 1; i < argc; i++) { - if (*argv[i] != '-') /* end of options; keep it */ - break; - else if (IS("--")) { /* end of options; skip it */ - ++i; - if (version) - ++version; - break; - } else if (IS("-")) /* end of options; use stdin */ - break; - else if (IS("-o")) { /* output file */ - output = argv[++i]; - if (output == NULL || *output == 0) - usage(LUA_QL("-o") " needs argument"); - if (IS("-")) - output = NULL; - } else if (IS("-p")) /* parse only */ - dumping = 0; - else if (IS("-s")) /* strip debug information */ - stripping = 1; - else if (IS("-v")) /* show version */ - ++version; - else if (IS("--luaconly")) /* ignore */ - ; - else if (IS("--luac")) /* ignore */ - ; - else /* unknown option */ - usage(argv[i]); - } - if (i == argc && (!dumping)) { - dumping = 0; - argv[--i] = Output; - } - if (version) { - printf("%s %s\n", LUA_RELEASE, LUA_COPYRIGHT); - if (version == argc - 1) - exit(EXIT_SUCCESS); - } - return i; -} - -#define toproto(L,i) (clvalue(L->top+(i))->l.p) - -static const Proto *combine(lua_State * L, int n) -{ - if (n == 1) - return toproto(L, -1); - else { - int i, pc; - Proto *f = luaF_newproto(L); - setptvalue2s(L, L->top, f); - incr_top(L); - f->source = luaS_newliteral(L, "=(" PROGNAME ")"); - f->maxstacksize = 1; - pc = 2 * n + 1; - f->code = luaM_newvector(L, pc, Instruction); - f->sizecode = pc; - f->p = luaM_newvector(L, n, Proto *); - f->sizep = n; - pc = 0; - for (i = 0; i < n; i++) { - f->p[i] = toproto(L, i - n - 1); - f->code[pc++] = CREATE_ABx(OP_CLOSURE, 0, i); - f->code[pc++] = CREATE_ABC(OP_CALL, 0, 1, 1); - } - f->code[pc++] = CREATE_ABC(OP_RETURN, 0, 1, 0); - return f; - } -} - -static int writer(lua_State * L, const void *p, size_t size, void *u) -{ - UNUSED(L); - return (fwrite(p, size, 1, (FILE *) u) != 1) && (size != 0); -} - -struct Smain { - int argc; - char **argv; -}; - -static int pmain(lua_State * L) -{ - struct Smain *s = (struct Smain *) lua_touserdata(L, 1); - int argc = s->argc; - char **argv = s->argv; - const Proto *f; - int i; - if (!lua_checkstack(L, argc)) - fatal("too many input files"); - for (i = 0; i < argc; i++) { - const char *filename = IS("-") ? NULL : argv[i]; - if (luaL_loadfile(L, filename) != 0) - fatal(lua_tostring(L, -1)); - } - f = combine(L, argc); - if (dumping) { - FILE *D = (output == NULL) ? stdout : fopen(output, "wb"); - if (D == NULL) - cannot("open"); - lua_lock(L); - luaU_dump(L, f, writer, D, stripping); - lua_unlock(L); - if (ferror(D)) - cannot("write"); - if (fclose(D)) - cannot("close"); - } - return 0; -} - -int luac_main(int argc, char *argv[]) -{ - lua_State *L; - struct Smain s; - int i = doargs(argc, argv); - argc -= i; - argv += i; - if (argc <= 0) - usage("no input files given"); - L = lua_open(); - if (L == NULL) - fatal("not enough memory for state"); - s.argc = argc; - s.argv = argv; - if (lua_cpcall(L, pmain, &s) != 0) - fatal(lua_tostring(L, -1)); - lua_close(L); - return EXIT_SUCCESS; -} diff --git a/Build/source/texk/web2c/luatexdir/lua/texluac.w b/Build/source/texk/web2c/luatexdir/lua/texluac.w new file mode 100644 index 00000000000..108e27864dc --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/lua/texluac.w @@ -0,0 +1,243 @@ +% texlua.w +% +% Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. +% Copyright 2006-2010 Taco Hoekwater +% +% 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 file is part of LuaTeX. + +@ @c +#include +#include +#include +#include + +#define luac_c +#define LUA_CORE + +#include "lua51/lua.h" +#include "lua51/lauxlib.h" + +#include "lua51/ldo.h" +#include "lua51/lfunc.h" +#include "lua51/lmem.h" +#include "lua51/lobject.h" +#include "lua51/lopcodes.h" +#include "lua51/lstring.h" +#include "lua51/lundump.h" + +@ @c +static const char _svn_version[] = + "$Id: texluac.w 3583 2010-04-02 17:40:44Z hhenkel $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/lua/texluac.w $"; + +@ @c +#define PROGNAME "texluac" /* default program name */ +#define OUTPUT PROGNAME ".out" /* default output file */ + +static int dumping = 1; /* dump bytecodes? */ +static int stripping = 0; /* strip debug information? */ +static char Output[] = { OUTPUT }; /* default output file name */ + +static const char *output = Output; /* actual output file name */ +static const char *progname = PROGNAME; /* actual program name */ + +@ @c +__attribute__ ((noreturn)) +static void fatal(const char *message) +{ + fprintf(stderr, "%s: %s\n", progname, message); + exit(EXIT_FAILURE); +} + +@ @c +__attribute__ ((noreturn)) +static void cannot(const char *what) +{ + fprintf(stderr, "%s: cannot %s %s: %s\n", progname, what, output, + strerror(errno)); + exit(EXIT_FAILURE); +} + +@ @c +__attribute__ ((noreturn)) +static void usage(const char *message) +{ + if (*message == '-') + fprintf(stderr, "%s: unrecognized option " LUA_QS "\n", progname, + message); + else + fprintf(stderr, "%s: %s\n", progname, message); + fprintf(stderr, + "usage: %s [options] [filenames].\n" + "Available options are:\n" + " - process stdin\n" + " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n", progname, Output); + exit(EXIT_FAILURE); +} + +@ @c +#define IS(s) (strcmp(argv[i],s)==0) + +static int doargs(int argc, char *argv[]) +{ + int i; + int version = 0; + if (argv[0] != NULL && *argv[0] != 0) + progname = argv[0]; + for (i = 1; i < argc; i++) { + if (*argv[i] != '-') /* end of options; keep it */ + break; + else if (IS("--")) { /* end of options; skip it */ + ++i; + if (version) + ++version; + break; + } else if (IS("-")) /* end of options; use stdin */ + break; + else if (IS("-o")) { /* output file */ + output = argv[++i]; + if (output == NULL || *output == 0) + usage(LUA_QL("-o") " needs argument"); + if (IS("-")) + output = NULL; + } else if (IS("-p")) /* parse only */ + dumping = 0; + else if (IS("-s")) /* strip debug information */ + stripping = 1; + else if (IS("-v")) /* show version */ + ++version; + else if (IS("--luaconly")) /* ignore */ + ; + else if (IS("--luac")) /* ignore */ + ; + else /* unknown option */ + usage(argv[i]); + } + if (i == argc && (!dumping)) { + dumping = 0; + argv[--i] = Output; + } + if (version) { + printf("%s %s\n", LUA_RELEASE, LUA_COPYRIGHT); + if (version == argc - 1) + exit(EXIT_SUCCESS); + } + return i; +} + +@ @c +#define toproto(L,i) (clvalue(L->top+(i))->l.p) + +static const Proto *combine(lua_State * L, int n) +{ + if (n == 1) + return toproto(L, -1); + else { + int i, pc; + Proto *f = luaF_newproto(L); + setptvalue2s(L, L->top, f); + incr_top(L); + f->source = luaS_newliteral(L, "=(" PROGNAME ")"); + f->maxstacksize = 1; + pc = 2 * n + 1; + f->code = luaM_newvector(L, (unsigned long) pc, Instruction); + f->sizecode = pc; + f->p = luaM_newvector(L, (unsigned long) n, Proto *); + f->sizep = n; + pc = 0; + for (i = 0; i < n; i++) { + f->p[i] = toproto(L, i - n - 1); + f->code[pc++] = CREATE_ABx(OP_CLOSURE, 0, i); + f->code[pc++] = CREATE_ABC(OP_CALL, 0, 1, 1); + } + f->code[pc++] = CREATE_ABC(OP_RETURN, 0, 1, 0); + return f; + } +} + +@ @c +static int writer(lua_State * L, const void *p, size_t size, void *u) +{ + UNUSED(L); + return (fwrite(p, size, 1, (FILE *) u) != 1) && (size != 0); +} + +@ @c +struct Smain { + int argc; + char **argv; +}; + +@ @c +static int pmain(lua_State * L) +{ + struct Smain *s = (struct Smain *) lua_touserdata(L, 1); + int argc = s->argc; + char **argv = s->argv; + const Proto *f; + int i; + if (!lua_checkstack(L, argc)) + fatal("too many input files"); + for (i = 0; i < argc; i++) { + const char *filename = IS("-") ? NULL : argv[i]; + if (luaL_loadfile(L, filename) != 0) + fatal(lua_tostring(L, -1)); + } + f = combine(L, argc); + if (dumping) { + FILE *D = (output == NULL) ? stdout : fopen(output, "wb"); + if (D == NULL) + cannot("open"); + lua_lock(L); + luaU_dump(L, f, writer, D, stripping); + lua_unlock(L); + if (ferror(D)) + cannot("write"); + if (fclose(D)) + cannot("close"); + } + return 0; +} + +@ @c +int luac_main(int argc, char *argv[]) +{ + lua_State *L; + struct Smain s; + int i = doargs(argc, argv); + argc -= i; + argv += i; + if (argc <= 0) + usage("no input files given"); + L = lua_open(); + if (L == NULL) + fatal("not enough memory for state"); + s.argc = argc; + s.argv = argv; + if (lua_cpcall(L, pmain, &s) != 0) + fatal(lua_tostring(L, -1)); + lua_close(L); + return EXIT_SUCCESS; +} diff --git a/Build/source/texk/web2c/luatexdir/lua51/lcoco.c b/Build/source/texk/web2c/luatexdir/lua51/lcoco.c index 45080285eae..2a234edbfc7 100644 --- a/Build/source/texk/web2c/luatexdir/lua51/lcoco.c +++ b/Build/source/texk/web2c/luatexdir/lua51/lcoco.c @@ -468,7 +468,7 @@ typedef void (*coco_MainFunc)(void); /* Don't use multiples of 64K to avoid D-cache aliasing conflicts. */ #ifndef COCO_DEFAULT_CSTACKSIZE -#define COCO_DEFAULT_CSTACKSIZE (65536-4096) +#define COCO_DEFAULT_CSTACKSIZE ((16*65536)-4096) #endif static int defaultcstacksize = COCO_DEFAULT_CSTACKSIZE; diff --git a/Build/source/texk/web2c/luatexdir/lua51/loadlib.c b/Build/source/texk/web2c/luatexdir/lua51/loadlib.c index 0d401eba1cf..ea62dff7a16 100644 --- a/Build/source/texk/web2c/luatexdir/lua51/loadlib.c +++ b/Build/source/texk/web2c/luatexdir/lua51/loadlib.c @@ -410,6 +410,14 @@ static int loader_C (lua_State *L) { return 1; /* library loaded successfully */ } +int loader_C_luatex (lua_State *L, const char *name, const char *filename) { + const char *funcname; + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + static int loader_Croot (lua_State *L) { const char *funcname; @@ -431,6 +439,21 @@ static int loader_Croot (lua_State *L) { return 1; } +int loader_Call_luatex (lua_State *L, const char *name, const char *filename) { + const char *funcname; + int stat; + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; /* library loaded successfully */ +} + + static int loader_preload (lua_State *L) { const char *name = luaL_checkstring(L, 1); diff --git a/Build/source/texk/web2c/luatexdir/lua51/luaconf.h b/Build/source/texk/web2c/luatexdir/lua51/luaconf.h index 0650f2c7f64..fac58d8cb5c 100644 --- a/Build/source/texk/web2c/luatexdir/lua51/luaconf.h +++ b/Build/source/texk/web2c/luatexdir/lua51/luaconf.h @@ -11,6 +11,7 @@ #include #include +#include /* ** ================================================================== @@ -44,6 +45,11 @@ #define LUA_DL_DYLD /* does not need extra library */ #endif +#if !defined(_WIN32) +#if defined(HAVE_DLFCN_H) +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#endif +#endif /* @@ -521,15 +527,23 @@ #define LUA_NUMBER_SCAN "%lf" #define LUA_NUMBER_FMT "%.14g" -#define lua_number2str(s,n) if (((n)<0.000001) && ((n)>-0.000001)) \ - sprintf((s), "0"); else if (((n)<0.0001) && ((n)>-0.0001)) { \ - sprintf((s), "%.6f", (n)); \ - if (n>0) { if (s[7] == '0') { s[7] = 0; } } \ - else { if (s[8] == '0') { s[8] = 0; } } \ - } else sprintf((s), LUA_NUMBER_FMT, (n)); - - -#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_number2str(s,n) do { \ + if (n<0.0001 && n>=-0.0001) { \ + sprintf((s), "%.14f", (n)); \ + if (strchr(s,'.')) { \ + size_t s_l ; \ + s_l = strlen(s); \ + while (s_l>0 && s_l--) { \ + if (s[s_l] == '0') s[s_l] = '\0'; \ + else break; \ + } \ + if (s[s_l] == '.') s[s_l] = '\0'; \ + } \ + } else sprintf((s), LUA_NUMBER_FMT, (n)); \ + } while (0) + + +#define LUAI_MAXNUMBER2STR 64 /* 16 digits, sign, point, and \0 */ #define lua_str2number(s,p) strtod((s), (p)) @@ -568,7 +582,8 @@ /* On a Microsoft compiler, use assembler */ #if defined(_MSC_VER) -#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2int(i,d) \ +{int N__; double D__=d; {__asm fld D__ __asm fistp N__} i = N__;} #define lua_number2integer(i,n) lua_number2int(i, n) /* the next trick should work on any Pentium, but sometimes clashes diff --git a/Build/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c b/Build/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c index cdcbcf0d90f..c4598e41aae 100644 --- a/Build/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c +++ b/Build/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c @@ -34,6 +34,7 @@ #include #include #include +#include #else #include #include @@ -566,7 +567,7 @@ static void push_st_size (lua_State *L, STAT_STRUCT *info) { lua_pushnumber (L, (lua_Number)info->st_size); } /* permssions string */ -static void push_st_perm (lua_State *L, struct stat *info) { +static void push_st_perm (lua_State *L, STAT_STRUCT *info) { lua_pushstring (L, perm2string (info->st_mode)); } #ifndef _WIN32 @@ -653,6 +654,28 @@ static int _file_info_ (lua_State *L, int (*st)(const char*, STAT_STRUCT*)) { return 1; } +#ifndef WIN32 +static int pusherror(lua_State *L, const char *info) +{ + lua_pushnil(L); + if (info==NULL) + lua_pushstring(L, strerror(errno)); + else + lua_pushfstring(L, "%s: %s", info, strerror(errno)); + lua_pushinteger(L, errno); + return 3; +} + +static int Preadlink(lua_State *L) /** readlink(path) */ +{ + char b[PATH_MAX]; + const char *path = luaL_checkstring(L, 1); + int n = readlink(path, b, sizeof(b)); + if (n==-1) return pusherror(L, path); + lua_pushlstring(L, b, n); + return 1; +} +#endif /* ** Get file information using stat. @@ -661,7 +684,6 @@ static int file_info (lua_State *L) { return _file_info_ (L, STAT_FUNC); } - /* ** Get symbolic link information using lstat. */ @@ -669,12 +691,44 @@ static int file_info (lua_State *L) { static int link_info (lua_State *L) { return _file_info_ (L, LSTAT_FUNC); } +static int read_link (lua_State *L) { + return Preadlink (L); +} +static int get_short_name (lua_State *L) { + /* simply do nothing */ + return 1; +} #else static int link_info (lua_State *L) { lua_pushboolean(L, 0); lua_pushliteral(L, "symlinkattributes not supported on this platform"); return 2; } +static int read_link (lua_State *L) { + lua_pushboolean(L, 0); + lua_pushliteral(L, "readlink not supported on this platform"); + return 2; +} +static int get_short_name (lua_State *L) { + long length = 0; + TCHAR* buffer = NULL; + const char *lpszPath = luaL_checkstring (L, 1); + length = GetShortPathName(lpszPath, NULL, 0); + if (length == 0) { + lua_pushnil(L); + lua_pushfstring(L, "operating system error: %d", (int)GetLastError()); + return 2; + } + buffer = (TCHAR *)xmalloc(length * sizeof(TCHAR)); + length = GetShortPathName(lpszPath, buffer, length); + if (length == 0) { + lua_pushnil(L); + lua_pushfstring(L, "operating system error: %d", (int)GetLastError()); + return 2; + } + lua_pushlstring(L, (const char *)buffer, (size_t)length); + return 1; +} #endif @@ -744,6 +798,8 @@ static const struct luaL_reg fslib[] = { {"mkdir", make_dir}, {"rmdir", remove_dir}, {"symlinkattributes", link_info}, + {"readlink", read_link}, + {"shortname", get_short_name}, {"setmode", lfs_f_setmode}, {"touch", file_utime}, {"unlock", file_unlock}, diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in index ea21c43be1d..7cb2bc9acfe 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in @@ -14,7 +14,7 @@ GU_AGE=0 LIBTOOL = @LIBTOOL@ CC = @CC@ -libgunicode_OBJECTS = ArabicForms.lo alphabet.lo backtrns.lo char.lo \ +libgunicode_OBJECTS = ArabicForms.lo alphabet.lo char.lo \ cjk.lo memory.lo ucharmap.lo unialt.lo ustring.lo utype.lo \ gwwiconv.lo diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c index a2f01f3131a..412947d5b70 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c @@ -1,7 +1,10 @@ #include +#ifdef TO_CJK_ICONV const unsigned short u_allzeros[256] = { 0 }; +#endif +#ifdef FROM_CJK_ICONV const unichar_t unicode_from_jis208[] = { 0x2003, 0x3001, 0x3002, 0xff0c, 0xff0e, 0x30fb, 0xff1a, 0xff1b, 0xff1f, 0xff01, 0x309b, 0x309c, 0x00b4, 0xff40, 0x00a8, 0xff3e, @@ -2219,7 +2222,9 @@ const unichar_t unicode_from_jis212[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x2003, 0x3001, 0x3002, 0xff0c, 0xff0e, 0x30fb, 0xff1a, 0xff1b, 0xff1f, 0xff01, 0x309b, 0x309c }; +#endif +#ifdef TO_CJK_ICONV static const unsigned short jis_from_unicode_0[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -5806,6 +5811,9 @@ static const unsigned short * const jis_from_unicode_[] = { struct charmap2 jis_from_unicode = { 0, 255, (unsigned short **) jis_from_unicode_, (unichar_t *) unicode_from_jis212 }; +#endif + +#ifdef FROM_CJK_ICONV const unichar_t unicode_from_big5[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -8881,7 +8889,9 @@ const unichar_t unicode_from_big5[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe4f, 0xffffffff, 0x00ff, 0x0000, 0x0100, 0x0002, 0x6000, 0x804f240 }; +#endif +#ifdef TO_CJK_ICONV static const unsigned short big5_from_unicode_0[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -12712,7 +12722,9 @@ static const unsigned short * const big5_from_unicode_[] = { }; struct charmap2 big5_from_unicode = { 0, 255, (unsigned short **) big5_from_unicode_, (unichar_t *) unicode_from_big5 }; +#endif +#ifdef FROM_CJK_ICONV const unichar_t unicode_from_big5hkscs[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -16812,7 +16824,9 @@ const unichar_t unicode_from_big5hkscs[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x79d4, 0xfefe, 0x00ff, 0x0000, 0x0100, 0x0005, 0x8000, 0x804f240 }; +#endif +#ifdef TO_CJK_ICONV static const unsigned short big5hkscs_from_unicode_0[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -22534,6 +22548,9 @@ static const unsigned short * const big5hkscs_from_unicode_[] = { struct charmap2 big5hkscs_from_unicode = { 0, 255, (unsigned short **) big5hkscs_from_unicode_, (unichar_t *) unicode_from_big5hkscs }; +#endif + +#ifdef FROM_CJK_ICONV const unichar_t unicode_from_ksc5601[] = { 0x3164, 0x3001, 0x3002, 0x30fb, 0x2025, 0x22ef, 0x00a8, 0x3003, 0x2013, 0x2014, 0x2016, 0xff3c, 0xff5e, 0x2018, 0x2019, 0x201c, @@ -23642,7 +23659,9 @@ const unichar_t unicode_from_ksc5601[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000, 0x0000, 0x79d4, 0x0004, 0x2288, 0x804f240 }; +#endif +#ifdef TO_CJK_ICONV static unsigned short ksc5601_from_unicode_0[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -28909,6 +28928,9 @@ static const unsigned short * const ksc5601_from_unicode_[] = { struct charmap2 ksc5601_from_unicode = { 0, 255, (unsigned short **) ksc5601_from_unicode_, (unichar_t *) unicode_from_ksc5601 }; +#endif + +#ifdef FROM_CJK_ICONV const unichar_t unicode_from_johab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -32880,7 +32902,9 @@ const unichar_t unicode_from_johab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3164, 0x3001, 0x3002, 0x30fb, 0x2025, 0x22ef, 0x00a8, 0x3003 }; +#endif +#ifdef TO_CJK_ICONV static unsigned short johab_from_unicode_0[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -38147,6 +38171,9 @@ static const unsigned short * const johab_from_unicode_[] = { struct charmap2 johab_from_unicode = { 0, 255, (unsigned short **) johab_from_unicode_, (unichar_t *) unicode_from_johab }; +#endif + +#ifdef FROM_CJK_ICONV const unichar_t unicode_from_gb2312[] = { 0x3000, 0x3001, 0x3002, 0x00b7, 0x02c9, 0x02c7, 0x00a8, 0x3003, 0x3005, 0x2014, 0xff5e, 0x2016, 0x2026, 0x2018, 0x2019, 0x201c, @@ -39255,7 +39282,9 @@ const unichar_t unicode_from_gb2312[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x9f44, 0xffffffff, 0x00ff, 0x0000, 0x0100, 0x0003, 0x2288, 0x804f240, 0x0100, 0x0005, 0x00f8, 0x42130a14 }; +#endif +#ifdef TO_CJK_ICONV static unsigned short gb2312_from_unicode_0[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -43017,3 +43046,4 @@ static const unsigned short * const gb2312_from_unicode_[] = { struct charmap2 gb2312_from_unicode = { 0, 255, (unsigned short **) gb2312_from_unicode_, (unichar_t *) unicode_from_gb2312 }; +#endif diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c index 5576de5c18e..70f9e064dc3 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c @@ -114,16 +114,14 @@ static enum encoding name_to_enc(const char *encname) { { "mac", e_mac }, { "Macintosh", e_mac }, { "MS-ANSI", e_win }, +#ifdef FROM_CJK_ICONV { "EUC-KR", e_wansung }, { "johab", e_johab }, - { "ISO-2022-KR", e_jiskorean }, - { "ISO-2022-CN", e_jisgb }, { "EUC-CN", e_jisgbpk }, { "big5", e_big5 }, { "big5hkscs", e_big5hkscs }, - { "ISO-2022-JP", e_jis }, - { "ISO-2022-JP-2", e_jis2 }, { "Sjis", e_sjis }, +#endif { "UTF-8", e_utf8 }, { "UTF8", e_utf8 }, { NULL }}; @@ -242,6 +240,7 @@ return( (size_t) -1 ); /* Incomplete multi-byte sequence */ } else return( (size_t) -1 ); } +#ifdef TO_CJK_ICONV } else if ( cd->to==e_johab || cd->to==e_big5 || cd->to==e_big5hkscs ) { struct charmap2 *table = cd->to==e_johab ? &johab_from_unicode : cd->to==e_big5 ? &big5_from_unicode : @@ -274,6 +273,8 @@ return( (size_t) -1 ); } else return( (size_t) -1 ); } +#endif +#ifdef TO_CJK_ICONV } else if ( cd->to==e_wansung || cd->to==e_jisgbpk ) { struct charmap2 *table = cd->to==e_wansung ? &ksc5601_from_unicode : &gb2312_from_unicode; @@ -305,6 +306,8 @@ return( (size_t) -1 ); } else return( (size_t) -1 ); } +#endif +#ifdef TO_CJK_ICONV } else if ( cd->to==e_sjis ) { unsigned char *plane1; unsigned short *plane; @@ -341,39 +344,7 @@ return( (size_t) -1 ); } else return( (size_t) -1 ); } - } else if ( cd->to==e_jis || cd->to==e_jis2 || - cd->to==e_jiskorean || cd->to==e_jisgb ) { - struct charmap2 *table = cd->to==e_jisgb ? &gb2312_from_unicode : - cd->to==e_jiskorean ? &ksc5601_from_unicode : - &jis_from_unicode; - unsigned short *plane; - while ( *inlen>1 && *outlen>1 ) { - int highch, lowch; - if ( endian == end_little ) { - highch = ((unsigned char *) *inbuf)[1], lowch = *(unsigned char *) *inbuf; - } else { - highch = *(unsigned char *) *inbuf, lowch = ((unsigned char *) *inbuf)[1]; - } - if ( highch>=table->first && highch<=table->last && - (plane = table->table[highch])!=NULL && - (ch=plane[lowch])!=0 ) { - if ( ch>=0x8000 ) { - if ( cd->to!=e_jis2 ) -return( (size_t) -1 ); - ch -= 0x8000; - } else { - if ( cd->to==e_jis2 ) -return( (size_t) -1 ); - } - *((*outbuf)++) = (ch>>8); - *((*outbuf)++) = (ch&0xff); - *outlen -= 2; - *inlen -= 2; - *inbuf += 2; - ++char_cnt; - } else -return( (size_t) -1 ); - } +#endif } else if ( cd->to==e_utf8 ) { while ( *inlen>1 && *outlen>0 ) { unichar_t uch; @@ -450,6 +421,7 @@ return( (size_t) -1 ); /* Incomplete multi-byte sequence */ } else return( (size_t) -1 ); } +#ifdef TO_CJK_ICONV } else if ( cd->to==e_johab || cd->to==e_big5 || cd->to==e_big5hkscs ) { struct charmap2 *table = cd->to==e_johab ? &johab_from_unicode : cd->to==e_big5 ? &big5_from_unicode : @@ -482,6 +454,8 @@ return( (size_t) -1 ); } else return( (size_t) -1 ); } +#endif +#ifdef TO_CJK_ICONV } else if ( cd->to==e_wansung || cd->to==e_jisgbpk ) { struct charmap2 *table = cd->to==e_wansung ? &ksc5601_from_unicode : &gb2312_from_unicode; @@ -513,6 +487,8 @@ return( (size_t) -1 ); } else return( (size_t) -1 ); } +#endif +#ifdef TO_CJK_ICONV } else if ( cd->to==e_sjis ) { unsigned char *plane1; unsigned short *plane; @@ -549,39 +525,7 @@ return( (size_t) -1 ); } else return( (size_t) -1 ); } - } else if ( cd->to==e_jis || cd->to==e_jis2 || - cd->to==e_jiskorean || cd->to==e_jisgb ) { - struct charmap2 *table = cd->to==e_jisgb ? &gb2312_from_unicode : - cd->to==e_jiskorean ? &ksc5601_from_unicode : - &jis_from_unicode; - unsigned short *plane; - while ( *inlen>1 && *outlen>1 ) { - int highch, lowch; - if ( endian == end_little ) { - highch = ((unsigned char *) *inbuf)[1], lowch = *(unsigned char *) *inbuf; - } else { - highch = ((unsigned char *) *inbuf)[2], lowch = ((unsigned char *) *inbuf)[3]; - } - if ( highch>=table->first && highch<=table->last && - (plane = table->table[highch])!=NULL && - (ch=plane[lowch])!=0 ) { - if ( ch>=0x8000 ) { - if ( cd->to!=e_jis2 ) -return( (size_t) -1 ); - ch -= 0x8000; - } else { - if ( cd->to==e_jis2 ) -return( (size_t) -1 ); - } - *((*outbuf)++) = (ch>>8); - *((*outbuf)++) = (ch&0xff); - *outlen -= 2; - *inlen -= 4; - *inbuf += 4; - ++char_cnt; - } else -return( (size_t) -1 ); - } +#endif } else if ( cd->to==e_utf8 ) { while ( *inlen>1 && *outlen>0 ) { int uch; @@ -648,62 +592,7 @@ return( (size_t) -1 ); *outlen -= sizeof(unichar_t); ++char_cnt; } - } else if ( cd->from==e_jis || cd->from==e_jis2 || - cd->from==e_jiskorean || cd->from==e_jisgb ) { - table = cd->from==e_jisgb ? unicode_from_gb2312 : - cd->from==e_jiskorean ? unicode_from_ksc5601 : - cd->from==e_jis ? unicode_from_jis208 : - unicode_from_jis212; - while ( *inlen>1 && *outlen>1 ) { - unsigned char *ipt = (unsigned char *) *inbuf; - int ch; - if ( *ipt<0x21 || *ipt>0x7e || ipt[1]<0x21 || ipt[1]>0x7e ) -return( (size_t) -1 ); - ch = (*ipt-0x21)*94 + (ipt[1]-0x21); - ch = table[ch]; - *inlen -= 2; - *inbuf = (char *) ipt+2; - if ( endian==end_little ) { - *((*outbuf)++) = ch&0xff; - *((*outbuf)++) = ch>>8; - } else { - *((*outbuf)++) = ch>>8; - *((*outbuf)++) = ch&0xff; - } - *outlen -= sizeof(unichar_t); - ++char_cnt; - } - if ( *inlen==1 && *outlen>0 ) -return( (size_t) -1 ); /* Incomplete multi-byte sequence */ - } else if ( cd->from==e_wansung || cd->from==e_jisgbpk ) { - table = cd->from==e_jisgbpk ? unicode_from_gb2312 : - unicode_from_ksc5601 ; - while ( *inlen>0 && *outlen>1 ) { - unsigned char *ipt = (unsigned char *) *inbuf; - int ch; - if ( *ipt<0x7f ) { - ch = *ipt; - --*inlen; - *inbuf = (char *) ipt+1; - } else { - if ( *ipt<0xa1 || *ipt>0xfe || ipt[1]<0xa1 || ipt[1]>0xfe || - *inlen==1 ) -return( (size_t) -1 ); - ch = (*ipt-0xa1)*94 + (ipt[1]-0xa1); - ch = table[ch]; - *inlen -= 2;; - *inbuf = (char *) ipt+2; - } - if ( endian==end_little ) { - *((*outbuf)++) = ch&0xff; - *((*outbuf)++) = ch>>8; - } else { - *((*outbuf)++) = ch>>8; - *((*outbuf)++) = ch&0xff; - } - *outlen -= sizeof(unichar_t); - ++char_cnt; - } +#ifdef FROM_CJK_ICONV } else if ( cd->from==e_johab || cd->from==e_big5 || cd->from==e_big5hkscs ) { int offset; if ( cd->from==e_big5 ) { @@ -786,6 +675,7 @@ return( (size_t) -1 ); *outlen -= sizeof(unichar_t); ++char_cnt; } +#endif } else if ( cd->from==e_utf8 ) { while ( *inlen>0 && *outlen>sizeof(unichar_t) ) { unsigned char *ipt = (unsigned char *) *inbuf; @@ -856,37 +746,7 @@ return( (size_t) -1 ); *outlen -= sizeof(unichar_t); ++char_cnt; } - } else if ( cd->from==e_jis || cd->from==e_jis2 || - cd->from==e_jiskorean || cd->from==e_jisgb ) { - table = cd->from==e_jisgb ? unicode_from_gb2312 : - cd->from==e_jiskorean ? unicode_from_ksc5601 : - cd->from==e_jis ? unicode_from_jis208 : - unicode_from_jis212; - while ( *inlen>1 && *outlen>1 ) { - unsigned char *ipt = (unsigned char *) *inbuf; - int ch; - if ( *ipt<0x21 || *ipt>0x7e || ipt[1]<0x21 || ipt[1]>0x7e ) -return( (size_t) -1 ); - ch = (*ipt-0x21)*94 + (ipt[1]-0x21); - ch = table[ch]; - *inlen -= 2; - *inbuf = (char *) ipt+2; - if ( endian==end_little ) { - *((*outbuf)++) = 0; - *((*outbuf)++) = 0; - *((*outbuf)++) = ch&0xff; - *((*outbuf)++) = ch>>8; - } else { - *((*outbuf)++) = ch>>8; - *((*outbuf)++) = ch&0xff; - *((*outbuf)++) = 0; - *((*outbuf)++) = 0; - } - *outlen -= sizeof(unichar_t); - ++char_cnt; - } - if ( *inlen==1 && *outlen>0 ) -return( (size_t) -1 ); /* Incomplete multi-byte sequence */ +#ifdef FROM_CJK_ICONV } else if ( cd->from==e_wansung || cd->from==e_jisgbpk ) { table = cd->from==e_jisgbpk ? unicode_from_gb2312 : unicode_from_ksc5601 ; @@ -1010,6 +870,7 @@ return( (size_t) -1 ); *outlen -= sizeof(unichar_t); ++char_cnt; } +#endif } else if ( cd->from==e_utf8 ) { while ( *inlen>0 && *outlen>sizeof(unichar_t) ) { unsigned char *ipt = (unsigned char *) *inbuf; diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c index 316234246a9..b97aa3a633f 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c @@ -75,6 +75,7 @@ unichar_t *encoding2u_strncpy(unichar_t *uto, const char *_from, int n, enum enc fprintf( stderr, "Unexpected encoding %d, I'll pretend it's latin1\n", cs ); } return( encoding2u_strncpy(uto,_from,n,e_iso8859_1)); +#ifdef FROM_CJK_ICONV case e_johab: case e_big5: case e_big5hkscs: if ( cs==e_big5 ) { offset = 0xa100; @@ -141,6 +142,7 @@ return( encoding2u_strncpy(uto,_from,n,e_iso8859_1)); --n; } break; +#endif } } else if ( cs==e_unicode ) { unichar_t *ufrom = (unichar_t *) from; @@ -206,194 +208,6 @@ return( encoding2u_strncpy(uto,_from,n,e_iso8859_1)); return( uto ); } -char *u2encoding_strncpy(char *to, const unichar_t *ufrom, int n, enum encoding cs) { - char *pt = to; - - /* we just ignore anything that doesn't fit in the encoding we look at */ - if ( cs0 ) { - int ch = *ufrom; - if ( ch<127 ) { - *pt++ = ch; - --n; - } - ++ufrom; - } - } else { - while ( *ufrom && n>0 ) { - int highch = *ufrom>>8, ch; - if ( highch>=table->first && highch<=table->last && - (plane = table->table[highch])!=NULL && - (ch=plane[*ufrom&0xff])!=0 ) { - *pt++ = ch; - --n; - } - ++ufrom; - } - } - if ( n>0 ) - *pt = '\0'; - } else if ( cs0 ) { - int highch = *ufrom>>8, ch; - if ( *ufrom<0x80 ) { - *pt++ = *ufrom; - --n; - } else if ( highch>=table->first && highch<=table->last && - (plane = table->table[highch-table->first])!=NULL && - (ch=plane[*ufrom&0xff])!=0 ) { - *pt++ = ch>>8; - *pt++ = ch&0xff; - n -= 2; - } - ufrom ++; - } - break; - case e_wansung: - while ( *ufrom && n>0 ) { - int highch = *ufrom>>8, ch; - if ( *ufrom<0x80 ) { - *pt++ = *ufrom; - --n; - } else if ( highch>=ksc5601_from_unicode.first && highch<=ksc5601_from_unicode.last && - (plane = ksc5601_from_unicode.table[highch-ksc5601_from_unicode.first])!=NULL && - (ch=plane[*ufrom&0xff])!=0 ) { - *pt++ = (ch>>8) + 0x80; - *pt++ = (ch&0xff) + 0x80; - n -= 2; - } - ufrom ++; - } - break; - case e_jisgb: - while ( *ufrom && n>0 ) { - int highch = *ufrom>>8, ch; - if ( *ufrom<0x80 ) { - *pt++ = *ufrom; - --n; - } else if ( highch>=gb2312_from_unicode.first && highch<=gb2312_from_unicode.last && - (plane = gb2312_from_unicode.table[highch-gb2312_from_unicode.first])!=NULL && - (ch=plane[*ufrom&0xff])!=0 ) { - *pt++ = (ch>>8) + 0x80; - *pt++ = (ch&0xff) + 0x80; - n -= 2; - } - ufrom ++; - } - break; - case e_sjis: - while ( *ufrom && n>0 ) { - int highch = *ufrom>>8, ch; - if ( highch>=jis201_from_unicode.first && highch<=jis201_from_unicode.last && - (plane1 = jis201_from_unicode.table[highch-jis201_from_unicode.first])!=NULL && - (ch=plane1[*ufrom&0xff])!=0 ) { - *pt++ = ch; - --n; - } else if ( *ufrom<' ' ) { /* control chars */ - *pt++ = *ufrom; - --n; - } else if ( highch>=jis_from_unicode.first && highch<=jis_from_unicode.last && - (plane = jis_from_unicode.table[highch-jis_from_unicode.first])!=NULL && - (ch=plane[*ufrom&0xff])!=0 && ch<0x8000 ) { /* no jis212 */ - int j1 = ch>>8, j2 = ch&0xff; - int ro = j1<95 ? 112 : 176; - int co = (j1&1) ? (j2>95?32:31) : 126; - *pt++ = ((j1+1)>>1)+ro; - *pt++ = j2+co; - n -= 2; - } - ++ufrom; - } - break; - } - if ( n>0 ) - *pt = '\0'; - } else if ( cs==e_unicode ) { - unichar_t *uto = (unichar_t *) to; - while ( *ufrom && n>1 ) { - *uto++ = *ufrom++; - n-=sizeof(unichar_t); - } - if ( n>1 ) - *uto = '\0'; - } else if ( cs==e_unicode_backwards ) { - unichar_t *uto = (unichar_t *) to; - while ( *ufrom && n>sizeof(unichar_t)-1 ) { -#ifdef UNICHAR_16 - unichar_t ch = (*ufrom>>8)|((*ufrom&0xff)<<8); -#else - unichar_t ch = (*ufrom>>24)|((*ufrom>>8)&0xff00)| - ((*ufrom<<8)&0xff0000)|(*ufrom<<24); -#endif - *uto++ = ch; - ++ufrom; - n-=sizeof(unichar_t); - } - if ( n>1 ) - *uto = '\0'; - } else if ( cs==e_utf8 ) { - while ( *ufrom ) { - if ( *ufrom<0x80 ) { - if ( n<=1 ) - break; - *pt++ = *ufrom; - --n; - } else if ( *ufrom<0x800 ) { - if ( n<=2 ) - break; - *pt++ = 0xc0 | (*ufrom>>6); - *pt++ = 0x80 | (*ufrom&0x3f); - n -= 2; - } else if ( *ufrom>=0xd800 && *ufrom<0xdc00 && ufrom[1]>=0xdc00 && ufrom[1]<0xe000 ) { - int u = ((*ufrom>>6)&0xf)+1, y = ((*ufrom&3)<<4) | ((ufrom[1]>>6)&0xf); - if ( n<=4 ) - break; - *pt++ = 0xf0 | (u>>2); - *pt++ = 0x80 | ((u&3)<<4) | ((*ufrom>>2)&0xf); - *pt++ = 0x80 | y; - *pt++ = 0x80 | (ufrom[1]&0x3f); - n -= 4; - } else { - if ( n<=3 ) - break; - *pt++ = 0xe0 | (*ufrom>>12); - *pt++ = 0x80 | ((*ufrom>>6)&0x3f); - *pt++ = 0x80 | (*ufrom&0x3f); - } - ++ufrom; - } - if ( n>1 ) - *pt = '\0'; - } else { - if ( !bad_enc_warn ) { - bad_enc_warn = true; - fprintf( stderr, "Unexpected encoding %d, I'll pretend it's latin1\n", cs ); - } -return( u2encoding_strncpy(to,ufrom,n,e_iso8859_1)); - } - -return( to ); -} #if HAVE_ICONV_H static char *old_local_name=NULL; @@ -522,23 +336,6 @@ return( uto ); return( encoding2u_strncpy(uto,from,n,local_encoding)); } -char *u2def_strncpy(char *to, const unichar_t *ufrom, int n) { -#if HAVE_ICONV_H - if ( my_iconv_setup() ) { - size_t in_left = sizeof(unichar_t)*n, out_left = n; - char *cfrom = (char *) ufrom, *cto=to; - iconv(from_unicode, (iconv_arg2_t) &cfrom, &in_left, &cto, &out_left); - if ( cto=e_first2byte ) - len *= 2; - to = galloc(len+sizeof(unichar_t)); - ret = u2encoding_strncpy(to,ufrom,len,local_encoding); - if ( ret==NULL ) - free( to ); - else if ( local_encodingglyphcnt; ++i ) { if ( sf->glyphs[i]!=NULL && sf->glyphs[i]->layers[layer].splines!=NULL ) { int enc = sf->glyphs[i]->unicodeenc; +#ifndef LUA_FF_LIB const unichar_t *upt; +#endif if ( enc<0x10000 && isalnum(enc) && ((enc>=32 && enc<128 ) || enc == 0xfe || enc==0xf0 || enc==0xdf || enc==0x131 || (enc>=0x391 && enc<=0x3f3 ) || (enc>=0x400 && enc<=0x4e9 ) )) { /* no accented characters (or ligatures) */ +#ifndef LUA_FF_LIB if ( unicode_alternates[enc>>8]!=NULL && (upt =unicode_alternates[enc>>8][enc&0xff])!=NULL && upt[1]!='\0' ) continue; +#endif SplineCharFindBounds(sf->glyphs[i],&b); if ( b.miny==0 && b.maxy==0 ) continue; @@ -256,16 +260,20 @@ void FindBlues( SplineFont *sf, int layer, real blues[14], real otherblues[10]) base[3] = base[4] = 0; for ( i=0; iglyphcnt; ++i ) if ( sf->glyphs[i]!=NULL ) { int enc = sf->glyphs[i]->unicodeenc; +#ifndef LUA_FF_LIB const unichar_t *upt; +#endif if ( enc<0x10000 && isalnum(enc) && ((enc>=32 && enc<128 ) || enc == 0xfe || enc==0xf0 || enc==0xdf || (enc>=0x391 && enc<=0x3f3 ) || (enc>=0x400 && enc<=0x4e9 ) )) { /* no accented characters (or ligatures) */ +#ifndef LUA_FF_LIB if ( unicode_alternates[enc>>8]!=NULL && (upt =unicode_alternates[enc>>8][enc&0xff])!=NULL && upt[1]!='\0' ) continue; +#endif SplineCharFindBounds(sf->glyphs[i],&b); if ( b.miny==0 && b.maxy==0 ) continue; diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c index 6fccf29e8ae..b4be6b5b5fe 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c @@ -289,16 +289,8 @@ return( &unicodefull ); /* Mac seems to work ok */ if ( strcasecmp(name,"win")==0 || strcasecmp(name,"ansi")==0 ) iconv_name = "MS-ANSI"; /* "WINDOWS-1252";*/ - else if ( strncasecmp(name,"jis208",6)==0 || strncasecmp(name,"jisx0208",8)==0 ) - iconv_name = "ISO-2022-JP"; - else if ( strncasecmp(name,"jis212",6)==0 || strncasecmp(name,"jisx0212",8)==0 ) - iconv_name = "ISO-2022-JP-2"; - else if ( strncasecmp(name,"ksc5601",7)==0 ) - iconv_name = "ISO-2022-KR"; else if ( strcasecmp(name,"gb2312pk")==0 || strcasecmp(name,"gb2312packed")==0 ) - iconv_name = "EUC-CN"; - else if ( strncasecmp(name,"gb2312",6)==0 ) - iconv_name = "ISO-2022-CN"; + iconv_name = "EUC-CN"; else if ( strcasecmp(name,"wansung")==0 ) iconv_name = "EUC-KR"; else if ( strcasecmp(name,"EUC-CN")==0 ) { @@ -720,8 +712,7 @@ return( maybe ); maybefile = NULL; } } else { - file = utf82def_copy(uret); - free(uret); + file = uret; /* no utf82def() call for luatex */ } } diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c index 2f92df3e03e..63212410578 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c @@ -36,15 +36,15 @@ #include "ttf.h" #include "psfont.h" #ifdef LUA_FF_LIB -#undef __Mac +# undef __Mac #endif #if __Mac -# include -# include +# include +# include #else -# include -#undef __Mac -#define __Mac 0 +# include +# undef __Mac +# define __Mac 0 #endif const int mac_dpi = 72; @@ -123,82 +123,90 @@ struct resourcetype { struct macbinaryheader { char *macfilename; - char *binfilename; /* if macfilename is null and this is set we will figure out macfilename by removing .bin */ + char *binfilename; /* if macfilename is null and this is set we will figure out macfilename by removing .bin */ uint32 type; uint32 creator; }; - + enum psstyle_flags { psf_bold = 1, psf_italic = 2, psf_outline = 4, - psf_shadow = 0x8, psf_condense = 0x10, psf_extend = 0x20 }; + psf_shadow = 0x8, psf_condense = 0x10, psf_extend = 0x20 +}; -uint16 _MacStyleCode( char *styles, SplineFont *sf, uint16 *psstylecode ) { - unsigned short stylecode= 0, psstyle=0; +uint16 _MacStyleCode(char *styles, SplineFont * sf, uint16 * psstylecode) +{ + unsigned short stylecode = 0, psstyle = 0; - if ( strstrmatch( styles, "Bold" ) || strstrmatch(styles,"Demi") || - strstrmatch( styles,"Heav") || strstrmatch(styles,"Blac") || + if (strstrmatch(styles, "Bold") || strstrmatch(styles, "Demi") || + strstrmatch(styles, "Heav") || strstrmatch(styles, "Blac") || /* A few fonts have German/French styles in their names */ - strstrmatch( styles,"Fett") || strstrmatch(styles,"Gras") ) { - stylecode = sf_bold; - psstyle = psf_bold; - } else if ( sf!=NULL && sf->weight!=NULL && - (strstrmatch( sf->weight, "Bold" ) || strstrmatch(sf->weight,"Demi") || - strstrmatch( sf->weight,"Heav") || strstrmatch(sf->weight,"Blac") || - strstrmatch( sf->weight,"Fett") || strstrmatch(sf->weight,"Gras")) ) { - stylecode = sf_bold; - psstyle = psf_bold; + strstrmatch(styles, "Fett") || strstrmatch(styles, "Gras")) { + stylecode = sf_bold; + psstyle = psf_bold; + } else if (sf != NULL && sf->weight != NULL && + (strstrmatch(sf->weight, "Bold") + || strstrmatch(sf->weight, "Demi") + || strstrmatch(sf->weight, "Heav") + || strstrmatch(sf->weight, "Blac") + || strstrmatch(sf->weight, "Fett") + || strstrmatch(sf->weight, "Gras"))) { + stylecode = sf_bold; + psstyle = psf_bold; } /* URW uses four leter abbreviations of Italic and Oblique */ /* Somebody else uses two letter abbrevs */ - if ( (sf!=NULL && sf->italicangle!=0) || - strstrmatch( styles, "Ital" ) || - strstrmatch( styles, "Obli" ) || - strstrmatch(styles, "Slanted") || - strstrmatch(styles, "Kurs") || - strstr( styles,"It" ) ) { - stylecode |= sf_italic; - psstyle |= psf_italic; + if ((sf != NULL && sf->italicangle != 0) || + strstrmatch(styles, "Ital") || + strstrmatch(styles, "Obli") || + strstrmatch(styles, "Slanted") || + strstrmatch(styles, "Kurs") || strstr(styles, "It")) { + stylecode |= sf_italic; + psstyle |= psf_italic; } - if ( strstrmatch( styles, "Underline" ) ) { - stylecode |= sf_underline; + if (strstrmatch(styles, "Underline")) { + stylecode |= sf_underline; } - if ( strstrmatch( styles, "Outl" ) ) { - stylecode |= sf_outline; - psstyle |= psf_outline; + if (strstrmatch(styles, "Outl")) { + stylecode |= sf_outline; + psstyle |= psf_outline; } - if ( strstr(styles,"Shadow")!=NULL ) { - stylecode |= sf_shadow; - psstyle |= psf_shadow; + if (strstr(styles, "Shadow") != NULL) { + stylecode |= sf_shadow; + psstyle |= psf_shadow; } - if ( strstrmatch( styles, "Cond" ) || strstr( styles,"Cn") || - strstrmatch( styles, "Narrow") ) { - stylecode |= sf_condense; - psstyle |= psf_condense; + if (strstrmatch(styles, "Cond") || strstr(styles, "Cn") || + strstrmatch(styles, "Narrow")) { + stylecode |= sf_condense; + psstyle |= psf_condense; } - if ( strstrmatch( styles, "Exte" ) || strstr( styles,"Ex") ) { - stylecode |= sf_extend; - psstyle |= psf_extend; + if (strstrmatch(styles, "Exte") || strstr(styles, "Ex")) { + stylecode |= sf_extend; + psstyle |= psf_extend; } - if ( (psstyle&psf_extend) && (psstyle&psf_condense) ) { - if ( sf!=NULL ) - LogError( _("Warning: %s(%s) is both extended and condensed. That's impossible.\n"), - sf->fontname, sf->origname ); - else - LogError( _("Warning: Both extended and condensed. That's impossible.\n") ); - psstyle &= ~psf_extend; - stylecode &= ~sf_extend; + if ((psstyle & psf_extend) && (psstyle & psf_condense)) { + if (sf != NULL) + LogError(_ + ("Warning: %s(%s) is both extended and condensed. That's impossible.\n"), + sf->fontname, sf->origname); + else + LogError(_ + ("Warning: Both extended and condensed. That's impossible.\n")); + psstyle &= ~psf_extend; + stylecode &= ~sf_extend; } - if ( psstylecode!=NULL ) - *psstylecode = psstyle; -return( stylecode ); + if (psstylecode != NULL) + *psstylecode = psstyle; + return (stylecode); } /* ******************************** Reading ********************************* */ -static SplineFont *SearchPostscriptResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, - long name_list, int flags) { +static SplineFont *SearchPostscriptResources(FILE * f, long rlistpos, + int subcnt, long rdata_pos, + long name_list, int flags) +{ long here = ftell(f); long *offsets, lenpos; int rname = -1, tmp; @@ -209,242 +217,257 @@ static SplineFont *SearchPostscriptResources(FILE *f,long rlistpos,int subcnt,lo /* postscript font. It appears to be split up into chunks where the */ /* maximum chunk size is 0x800, each section (ascii, binary, ascii, eof) */ /* has its own set of chunks (ie chunks don't cross sections) */ - char *buffer=NULL; + char *buffer = NULL; int max = 0; FILE *pfb; FontDict *fd; SplineFont *sf; - (void)name_list; - fseek(f,rlistpos,SEEK_SET); - rsrcids = gcalloc(subcnt,sizeof(short)); - offsets = gcalloc(subcnt,sizeof(long)); - for ( i=0; i>24,pfb); - putc((len>>16)&0xff,pfb); - putc((len>>8)&0xff,pfb); - putc(len&0xff,pfb); - fseek(pfb,hold,SEEK_SET); - if ( ch1==5 ) /* end of font mark */ - break; - putc(0x80,pfb); - putc(ch1,pfb); - lenpos = ftell(pfb); - putc(0,pfb); - putc(0,pfb); - putc(0,pfb); - putc(0,pfb); - type = ch1; - len = rlen; - } - if ( rlen>max ) { - free(buffer); - max = rlen; - if ( max<0x800 ) max = 0x800; - buffer=galloc(max); - if ( buffer==NULL ) { - LogError( _("Out of memory\n") ); - exit( 1 ); - } - } - fread(buffer,1,rlen,f); - fwrite(buffer,1,rlen,pfb); + for (i = 0; i < subcnt; ++i) { + for (j = 0; j < subcnt; ++j) + if (rsrcids[j] == id) + break; + if (j == subcnt) { + LogError(_("Missing POST resource %u\n"), id); + break; + } + id = id + 1; + fseek(f, offsets[j], SEEK_SET); + rlen = getlong(f); + ch1 = getc(f); + ch2 = getc(f); + rlen -= 2; /* those two bytes don't count as real data */ + if (ch1 == type) + len += rlen; + else { + long hold = ftell(pfb); + fseek(pfb, lenpos, SEEK_SET); + putc(len >> 24, pfb); + putc((len >> 16) & 0xff, pfb); + putc((len >> 8) & 0xff, pfb); + putc(len & 0xff, pfb); + fseek(pfb, hold, SEEK_SET); + if (ch1 == 5) /* end of font mark */ + break; + putc(0x80, pfb); + putc(ch1, pfb); + lenpos = ftell(pfb); + putc(0, pfb); + putc(0, pfb); + putc(0, pfb); + putc(0, pfb); + type = ch1; + len = rlen; + } + if (rlen > max) { + free(buffer); + max = rlen; + if (max < 0x800) + max = 0x800; + buffer = galloc(max); + if (buffer == NULL) { + LogError(_("Out of memory\n")); + exit(1); + } + } + fread(buffer, 1, rlen, f); + fwrite(buffer, 1, rlen, pfb); } free(buffer); free(offsets); - free(rsrcids); - putc(0x80,pfb); - putc(3,pfb); - fseek(pfb,lenpos,SEEK_SET); - putc(len>>24,pfb); - putc((len>>16)&0xff,pfb); - putc((len>>8)&0xff,pfb); - putc(len&0xff,pfb); - fseek(f,here,SEEK_SET); + free(rsrcids); + putc(0x80, pfb); + putc(3, pfb); + fseek(pfb, lenpos, SEEK_SET); + putc(len >> 24, pfb); + putc((len >> 16) & 0xff, pfb); + putc((len >> 8) & 0xff, pfb); + putc(len & 0xff, pfb); + fseek(f, here, SEEK_SET); rewind(pfb); - if ( flags&ttf_onlynames ) -return( (SplineFont *) _NamesReadPostscript(pfb) ); /* This closes the font for us */ + if (flags & ttf_onlynames) + return ((SplineFont *) _NamesReadPostscript(pfb)); /* This closes the font for us */ fd = _ReadPSFont(pfb); sf = NULL; - if ( fd!=NULL ) { - sf = SplineFontFromPSFont(fd); - PSFontFree(fd); - /* There is no FOND in a postscript file, so we can't read any kerning*/ + if (fd != NULL) { + sf = SplineFontFromPSFont(fd); + PSFontFree(fd); + /* There is no FOND in a postscript file, so we can't read any kerning */ } fclose(pfb); -return( sf ); + return (sf); } -static SplineFont *SearchTtfResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, - long name_list,char *filename,int flags,enum openflags openflags) { +static SplineFont *SearchTtfResources(FILE * f, long rlistpos, int subcnt, + long rdata_pos, long name_list, + char *filename, int flags, + enum openflags openflags) +{ long here, start = ftell(f); long roff; int rname = -1; int ch1, ch2; int len, i, rlen, ilen; /* The sfnt resource is just a copy of the ttf file */ - char *buffer=NULL; + char *buffer = NULL; int max = 0; FILE *ttf; SplineFont *sf; int which = 0; char **names; - char *pt,*lparen, *rparen; - char *chosenname=NULL; - (void)name_list; - fseek(f,rlistpos,SEEK_SET); - if ( subcnt>1 || (flags&ttf_onlynames) ) { - names = gcalloc(subcnt+1,sizeof(char *)); - for ( i=0; i=0; --which ) - if ( strcmp(names[which],find)==0 ) - break; - if ( which==-1 ) { - char *end; - which = strtol(find,&end,10); - if ( *end!='\0' ) - which = -1; - } - if ( which==-1 ) { - char *fn = copy(filename); - fn[lparen-filename] = '\0'; - ff_post_error(_("Not in Collection"),_("%s is not in %.100s"),find,fn); - free(fn); - } - free(find); - } else - which = 0; - if ( lparen==NULL && which!=-1 ) - chosenname = copy(names[which]); - for ( i=0; i 1 || (flags & ttf_onlynames)) { + names = gcalloc(subcnt + 1, sizeof(char *)); + for (i = 0; i < subcnt; ++i) { + /* resource id = */ getushort(f); + /* rname = (short) */ getushort(f); + /* flags = */ getc(f); + ch1 = getc(f); + ch2 = getc(f); + roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f)); + /* mbz = */ getlong(f); + here = ftell(f); + names[i] = TTFGetFontName(f, roff + 4, roff + 4); + if (names[i] == NULL) { + char buffer[32]; + sprintf(buffer, "Nameless%d", i); + names[i] = copy(buffer); + } + fseek(f, here, SEEK_SET); + } + if (flags & ttf_onlynames) { + return ((SplineFont *) names); + } + if ((pt = strrchr(filename, '/')) == NULL) + pt = filename; + /* Someone gave me a font "Nafees Nastaleeq(Updated).ttf" and complained */ + /* that ff wouldn't open it */ + /* Now someone will complain about "Nafees(Updated).ttc(fo(ob)ar)" */ + if ((lparen = strrchr(pt, '(')) != NULL && + (rparen = strrchr(lparen, ')')) != NULL && rparen[1] == '\0') { + char *find = copy(lparen + 1); + pt = strchr(find, ')'); + if (pt != NULL) + *pt = '\0'; + for (which = subcnt - 1; which >= 0; --which) + if (strcmp(names[which], find) == 0) + break; + if (which == -1) { + char *end; + which = strtol(find, &end, 10); + if (*end != '\0') + which = -1; + } + if (which == -1) { + char *fn = copy(filename); + fn[lparen - filename] = '\0'; + ff_post_error(_("Not in Collection"), _("%s is not in %.100s"), + find, fn); + free(fn); + } + free(find); + } else + which = 0; + if (lparen == NULL && which != -1) + chosenname = copy(names[which]); + for (i = 0; i < subcnt; ++i) + free(names[i]); + free(names); + fseek(f, rlistpos, SEEK_SET); } - for ( i=0; i16*1024 ) - ilen = 16*1024; - if ( ilen>max ) { - free(buffer); - max = ilen; - if ( max<0x800 ) max = 0x800; - buffer=malloc(max); - } - for ( len=0; lenchosenname==NULL ) sf->chosenname = chosenname; -return( sf ); - } - fseek(f,here,SEEK_SET); + for (i = 0; i < subcnt; ++i) { + /* resource id = */ getushort(f); + rname = (short) getushort(f); + /* flags = */ getc(f); + ch1 = getc(f); + ch2 = getc(f); + roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f)); + /* mbz = */ getlong(f); + if (i != which) + continue; + here = ftell(f); + + ttf = tmpfile(); + if (ttf == NULL) { + LogError(_("Can't open temporary file for truetype output.\n")); + continue; + } + + fseek(f, roff, SEEK_SET); + ilen = rlen = getlong(f); + if (rlen > 16 * 1024) + ilen = 16 * 1024; + if (ilen > max) { + free(buffer); + max = ilen; + if (max < 0x800) + max = 0x800; + buffer = malloc(max); + } + for (len = 0; len < rlen;) { + int temp = ilen; + if (rlen - len < ilen) + temp = rlen - len; + temp = fread(buffer, 1, temp, f); + if (temp == EOF) + break; + fwrite(buffer, 1, temp, ttf); + len += temp; + } + rewind(ttf); + sf = _SFReadTTF(ttf, flags, openflags, NULL, NULL); + fclose(ttf); + if (sf != NULL) { + free(buffer); + fseek(f, start, SEEK_SET); + if (sf->chosenname == NULL) + sf->chosenname = chosenname; + return (sf); + } + fseek(f, here, SEEK_SET); } free(chosenname); free(buffer); - fseek(f,start,SEEK_SET); -return( NULL ); + fseek(f, start, SEEK_SET); + return (NULL); } typedef struct fond { @@ -452,69 +475,70 @@ typedef struct fond { int first, last; int assoc_cnt; struct assoc { - short size, style, id; + short size, style, id; } *assoc; - /* size==0 => scalable */ - /* style>>8 is the bit depth (0=>1, 1=>2, 2=>4, 3=>8) */ - /* search order for ID is sfnt, NFNT, FONT */ + /* size==0 => scalable */ + /* style>>8 is the bit depth (0=>1, 1=>2, 2=>4, 3=>8) */ + /* search order for ID is sfnt, NFNT, FONT */ int stylewidthcnt; struct stylewidths { - short style; - short *widthtab; /* 4.12 fixed number with the width specified as a fraction of an em */ + short style; + short *widthtab; /* 4.12 fixed number with the width specified as a fraction of an em */ } *stylewidths; int stylekerncnt; struct stylekerns { - short style; - int kernpairs; - struct kerns { - unsigned char ch1, ch2; - short offset; /* 4.12 */ - } *kerns; + short style; + int kernpairs; + struct kerns { + unsigned char ch1, ch2; + short offset; /* 4.12 */ + } *kerns; } *stylekerns; char *psnames[48]; struct fond *next; } FOND; struct MacFontRec { - short fontType; - short firstChar; - short lastChar; - short widthMax; - short kernMax; /* bb learing */ - short Descent; /* maximum negative distance below baseline*/ - short fRectWidth; /* bounding box width */ - short fRectHeight; /* bounding box height */ - unsigned short *offsetWidths;/* offset to start of offset/width table */ - /* 0xffff => undefined, else high byte is offset in locTable, */ - /* low byte is width */ - short ascent; - short descent; - short leading; - short rowWords; /* shorts per row */ - unsigned short *fontImage; /* rowWords*fRectHeight */ - /* Images for all characters plus one extra for undefined */ - unsigned short *locs; /* lastchar-firstchar+3 words */ - /* Horizontal offset to start of n'th character. Note: applies */ - /* to each row. Missing characters have same loc as following */ + short fontType; + short firstChar; + short lastChar; + short widthMax; + short kernMax; /* bb learing */ + short Descent; /* maximum negative distance below baseline */ + short fRectWidth; /* bounding box width */ + short fRectHeight; /* bounding box height */ + unsigned short *offsetWidths; /* offset to start of offset/width table */ + /* 0xffff => undefined, else high byte is offset in locTable, */ + /* low byte is width */ + short ascent; + short descent; + short leading; + short rowWords; /* shorts per row */ + unsigned short *fontImage; /* rowWords*fRectHeight */ + /* Images for all characters plus one extra for undefined */ + unsigned short *locs; /* lastchar-firstchar+3 words */ + /* Horizontal offset to start of n'th character. Note: applies */ + /* to each row. Missing characters have same loc as following */ }; -static void FondListFree(FOND *list) { +static void FondListFree(FOND * list) +{ FOND *next; int i; - while ( list!=NULL ) { - next = list->next; - free(list->assoc); - for ( i=0; istylewidthcnt; ++i ) - free(list->stylewidths[i].widthtab); - free(list->stylewidths); - for ( i=0; istylekerncnt; ++i ) - free(list->stylekerns[i].kerns); - free(list->stylekerns); - for ( i=0; i<48; ++i ) - free(list->psnames[i]); - free(list); - list = next; + while (list != NULL) { + next = list->next; + free(list->assoc); + for (i = 0; i < list->stylewidthcnt; ++i) + free(list->stylewidths[i].widthtab); + free(list->stylewidths); + for (i = 0; i < list->stylekerncnt; ++i) + free(list->stylekerns[i].kerns); + free(list->stylekerns); + for (i = 0; i < 48; ++i) + free(list->psnames[i]); + free(list); + list = next; } } @@ -526,180 +550,190 @@ static void FondListFree(FOND *list) { /* to get the font association tables */ /* to get the style flags */ /* http://developer.apple.com/techpubs/mac/Text/Text-269.html */ -static FOND *BuildFondList(FILE *f,long rlistpos,int subcnt,long rdata_pos, - long name_list,int flags) { +static FOND *BuildFondList(FILE * f, long rlistpos, int subcnt, long rdata_pos, + long name_list, int flags) +{ long here, start = ftell(f); long offset; int rname = -1; char name[300]; int ch1, ch2; int i, j, k, cnt, isfixed; - FOND *head=NULL, *cur; + FOND *head = NULL, *cur; long widoff, kernoff, styleoff; - fseek(f,rlistpos,SEEK_SET); - for ( i=0; inext = head; - head = cur; - - if ( rname!=-1 ) { - fseek(f,name_list+rname,SEEK_SET); - ch1 = getc(f); - fread(name,1,ch1,f); - name[ch1] = '\0'; - cur->fondname = copy(name); - } - - offset += 4; - fseek(f,offset,SEEK_SET); - isfixed = getushort(f)&0x8000?1:0; - /* family id = */ getushort(f); - cur->first = getushort(f); - cur->last = getushort(f); + fseek(f, rlistpos, SEEK_SET); + for (i = 0; i < subcnt; ++i) { + /* resource id = */ getushort(f); + rname = (short) getushort(f); + /* flags = */ getc(f); + ch1 = getc(f); + ch2 = getc(f); + offset = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f)); + /* mbz = */ getlong(f); + here = ftell(f); + + cur = gcalloc(1, sizeof(FOND)); + cur->next = head; + head = cur; + + if (rname != -1) { + fseek(f, name_list + rname, SEEK_SET); + ch1 = getc(f); + fread(name, 1, ch1, f); + name[ch1] = '\0'; + cur->fondname = copy(name); + } + + offset += 4; + fseek(f, offset, SEEK_SET); + isfixed = getushort(f) & 0x8000 ? 1 : 0; + /* family id = */ getushort(f); + cur->first = getushort(f); + cur->last = getushort(f); /* on a 1 point font... */ - /* ascent = */ getushort(f); - /* descent = (short) */ getushort(f); - /* leading = */ getushort(f); - /* widmax = */ getushort(f); - if ( (widoff = getlong(f))!=0 ) widoff += offset; - if ( (kernoff = getlong(f))!=0 ) kernoff += offset; - if ( (styleoff = getlong(f))!=0 ) styleoff += offset; - for ( j=0; j<9; ++j ) - getushort(f); - /* internal & undefined, for international scripts = */ getlong(f); - /* version = */ getushort(f); - cur->assoc_cnt = getushort(f)+1; - cur->assoc = gcalloc(cur->assoc_cnt,sizeof(struct assoc)); - for ( j=0; jassoc_cnt; ++j ) { - cur->assoc[j].size = getushort(f); - cur->assoc[j].style = getushort(f); - cur->assoc[j].id = getushort(f); - } - if ( widoff!=0 ) { - fseek(f,widoff,SEEK_SET); - cnt = getushort(f)+1; - cur->stylewidthcnt = cnt; - cur->stylewidths = gcalloc(cnt,sizeof(struct stylewidths)); - for ( j=0; jstylewidths[j].style = getushort(f); - cur->stylewidths[j].widthtab = galloc((cur->last-cur->first+3)*sizeof(short)); - for ( k=cur->first; k<=cur->last+2; ++k ) - cur->stylewidths[j].widthtab[k] = getushort(f); - } - } - if ( kernoff!=0 && (flags&ttf_onlykerns) ) { - fseek(f,kernoff,SEEK_SET); - cnt = getushort(f)+1; - cur->stylekerncnt = cnt; - cur->stylekerns = gcalloc(cnt,sizeof(struct stylekerns)); - for ( j=0; jstylekerns[j].style = getushort(f); - cur->stylekerns[j].kernpairs = getushort(f); - cur->stylekerns[j].kerns = galloc(cur->stylekerns[j].kernpairs*sizeof(struct kerns)); - for ( k=0; kstylekerns[j].kernpairs; ++k ) { - cur->stylekerns[j].kerns[k].ch1 = getc(f); - cur->stylekerns[j].kerns[k].ch2 = getc(f); - cur->stylekerns[j].kerns[k].offset = getushort(f); - } - } - } - if ( styleoff!=0 ) { - uint8 stringoffsets[48]; - int strcnt, stringlen, format; - char **strings, *pt; - fseek(f,styleoff,SEEK_SET); - /* class = */ getushort(f); - /* glyph encoding offset = */ getlong(f); - /* reserved = */ getlong(f); - for ( j=0; j<48; ++j ) - stringoffsets[j] = getc(f); - strcnt = getushort(f); - strings = galloc(strcnt*sizeof(char *)); - for ( j=0; j=0; --k ) - if ( stringoffsets[j]==stringoffsets[k] ) - break; - if ( k!=-1 ) - continue; /* this style doesn't exist */ - format = stringoffsets[j]-1; - stringlen = strings[0][0]; - if ( format!=0 ) - for ( k=0; kpsnames[j] = galloc(stringlen+1); - strcpy(pt,strings[ 0 ]+1); - pt += strings[ 0 ][0]; - if ( format!=0 ) - for ( k=0; kassoc_cnt = getushort(f) + 1; + cur->assoc = gcalloc(cur->assoc_cnt, sizeof(struct assoc)); + for (j = 0; j < cur->assoc_cnt; ++j) { + cur->assoc[j].size = getushort(f); + cur->assoc[j].style = getushort(f); + cur->assoc[j].id = getushort(f); + } + if (widoff != 0) { + fseek(f, widoff, SEEK_SET); + cnt = getushort(f) + 1; + cur->stylewidthcnt = cnt; + cur->stylewidths = gcalloc(cnt, sizeof(struct stylewidths)); + for (j = 0; j < cnt; ++j) { + cur->stylewidths[j].style = getushort(f); + cur->stylewidths[j].widthtab = + galloc((cur->last - cur->first + 3) * sizeof(short)); + for (k = cur->first; k <= cur->last + 2; ++k) + cur->stylewidths[j].widthtab[k] = getushort(f); + } + } + if (kernoff != 0 && (flags & ttf_onlykerns)) { + fseek(f, kernoff, SEEK_SET); + cnt = getushort(f) + 1; + cur->stylekerncnt = cnt; + cur->stylekerns = gcalloc(cnt, sizeof(struct stylekerns)); + for (j = 0; j < cnt; ++j) { + cur->stylekerns[j].style = getushort(f); + cur->stylekerns[j].kernpairs = getushort(f); + cur->stylekerns[j].kerns = + galloc(cur->stylekerns[j].kernpairs * sizeof(struct kerns)); + for (k = 0; k < cur->stylekerns[j].kernpairs; ++k) { + cur->stylekerns[j].kerns[k].ch1 = getc(f); + cur->stylekerns[j].kerns[k].ch2 = getc(f); + cur->stylekerns[j].kerns[k].offset = getushort(f); + } + } + } + if (styleoff != 0) { + uint8 stringoffsets[48]; + int strcnt, stringlen, format; + char **strings, *pt; + fseek(f, styleoff, SEEK_SET); + /* class = */ getushort(f); + /* glyph encoding offset = */ getlong(f); + /* reserved = */ getlong(f); + for (j = 0; j < 48; ++j) + stringoffsets[j] = getc(f); + strcnt = getushort(f); + strings = galloc(strcnt * sizeof(char *)); + for (j = 0; j < strcnt; ++j) { + stringlen = getc(f); + strings[j] = galloc(stringlen + 2); + strings[j][0] = stringlen; + strings[j][stringlen + 1] = '\0'; + for (k = 0; k < stringlen; ++k) + strings[j][k + 1] = getc(f); + } + for (j = 0; j < 48; ++j) { + for (k = j - 1; k >= 0; --k) + if (stringoffsets[j] == stringoffsets[k]) + break; + if (k != -1) + continue; /* this style doesn't exist */ + format = stringoffsets[j] - 1; + stringlen = strings[0][0]; + if (format != 0) + for (k = 0; k < strings[format][0]; ++k) + stringlen += strings[strings[format][k + 1] - 1][0]; + pt = cur->psnames[j] = galloc(stringlen + 1); + strcpy(pt, strings[0] + 1); + pt += strings[0][0]; + if (format != 0) + for (k = 0; k < strings[format][0]; ++k) { + strcpy(pt, strings[strings[format][k + 1] - 1] + 1); + pt += strings[strings[format][k + 1] - 1][0]; + } + *pt = '\0'; + } + for (j = 0; j < strcnt; ++j) + free(strings[j]); + free(strings); + } + fseek(f, here, SEEK_SET); } - fseek(f,start,SEEK_SET); -return( head ); + fseek(f, start, SEEK_SET); + return (head); } -static char *BuildName(char *family,int style) { +static char *BuildName(char *family, int style) +{ char buffer[350]; - strncpy(buffer,family,200); - if ( style!=0 ) - strcat(buffer,"-"); - if ( style&sf_bold ) - strcat(buffer,"Bold"); - if ( style&sf_italic ) - strcat(buffer,"Italic"); - if ( style&sf_underline ) - strcat(buffer,"Underline"); - if ( style&sf_outline ) - strcat(buffer,"Outline"); - if ( style&sf_shadow ) - strcat(buffer,"Shadow"); - if ( style&sf_condense ) - strcat(buffer,"Condensed"); - if ( style&sf_extend ) - strcat(buffer,"Extended"); -return( copy(buffer)); + strncpy(buffer, family, 200); + if (style != 0) + strcat(buffer, "-"); + if (style & sf_bold) + strcat(buffer, "Bold"); + if (style & sf_italic) + strcat(buffer, "Italic"); + if (style & sf_underline) + strcat(buffer, "Underline"); + if (style & sf_outline) + strcat(buffer, "Outline"); + if (style & sf_shadow) + strcat(buffer, "Shadow"); + if (style & sf_condense) + strcat(buffer, "Condensed"); + if (style & sf_extend) + strcat(buffer, "Extended"); + return (copy(buffer)); } -static int GuessStyle(char *fontname,int *styles,int style_cnt) { +static int GuessStyle(char *fontname, int *styles, int style_cnt) +{ int which, style; - char *stylenames = _GetModifiers(fontname,NULL,NULL); + char *stylenames = _GetModifiers(fontname, NULL, NULL); - style = _MacStyleCode(stylenames,NULL,NULL); - for ( which = style_cnt; which>=0; --which ) - if ( styles[which] == style ) -return( which ); + style = _MacStyleCode(stylenames, NULL, NULL); + for (which = style_cnt; which >= 0; --which) + if (styles[which] == style) + return (which); -return( -1 ); + return (-1); } -static FOND *PickFOND(FOND *fondlist,char *filename,char **name, int *style) { - int i,j; +static FOND *PickFOND(FOND * fondlist, char *filename, char **name, int *style) +{ + int i, j; FOND *test; uint8 stylesused[96]; char **names; @@ -709,163 +743,180 @@ static FOND *PickFOND(FOND *fondlist,char *filename,char **name, int *style) { char *pt, *lparen; char *find = NULL; - if ((pt = strrchr(filename,'/'))!=NULL ) pt = filename; - if ( (lparen = strchr(filename,'('))!=NULL && strchr(lparen,')')!=NULL ) { - find = copy(lparen+1); - pt = strchr(find,')'); - if ( pt!=NULL ) *pt='\0'; - for ( test=fondlist; test!=NULL; test=test->next ) { - for ( i=0; i<48; ++i ) - if ( test->psnames[i]!=NULL && strcmp(find,test->psnames[i])==0 ) { - *style = (i&3) | ((i&~3)<<1); /* PS styles skip underline bit */ - *name = copy(test->psnames[i]); -return( test ); - } - } + if ((pt = strrchr(filename, '/')) != NULL) + pt = filename; + if ((lparen = strchr(filename, '(')) != NULL && strchr(lparen, ')') != NULL) { + find = copy(lparen + 1); + pt = strchr(find, ')'); + if (pt != NULL) + *pt = '\0'; + for (test = fondlist; test != NULL; test = test->next) { + for (i = 0; i < 48; ++i) + if (test->psnames[i] != NULL + && strcmp(find, test->psnames[i]) == 0) { + *style = (i & 3) | ((i & ~3) << 1); /* PS styles skip underline bit */ + *name = copy(test->psnames[i]); + return (test); + } + } } /* The file may contain multiple families, and each family may contain */ /* multiple styles (and each style may contain multiple sizes, but that's */ /* not an issue for us here) */ names = NULL; - for ( i=0; i<2; ++i ) { - cnt = 0; - for ( test=fondlist; test!=NULL; test=test->next ) if ( test->fondname!=NULL ) { - memset(stylesused,0,sizeof(stylesused)); - for ( j=0; jassoc_cnt; ++j ) { - if ( test->assoc[j].size!=0 && !stylesused[test->assoc[j].style]) { - stylesused[test->assoc[j].style]=true; - if ( names!=NULL ) { - names[cnt] = BuildName(test->fondname,test->assoc[j].style); - styles[cnt] = test->assoc[j].style; - fonds[cnt] = test; - } - ++cnt; - } - } - } - if ( names==NULL ) { - names = gcalloc(cnt+1,sizeof(char *)); - fonds = galloc(cnt*sizeof(FOND *)); - styles = galloc(cnt*sizeof(int)); - } + for (i = 0; i < 2; ++i) { + cnt = 0; + for (test = fondlist; test != NULL; test = test->next) + if (test->fondname != NULL) { + memset(stylesused, 0, sizeof(stylesused)); + for (j = 0; j < test->assoc_cnt; ++j) { + if (test->assoc[j].size != 0 + && !stylesused[test->assoc[j].style]) { + stylesused[test->assoc[j].style] = true; + if (names != NULL) { + names[cnt] = + BuildName(test->fondname, test->assoc[j].style); + styles[cnt] = test->assoc[j].style; + fonds[cnt] = test; + } + ++cnt; + } + } + } + if (names == NULL) { + names = gcalloc(cnt + 1, sizeof(char *)); + fonds = galloc(cnt * sizeof(FOND *)); + styles = galloc(cnt * sizeof(int)); + } } - if ( find!=NULL ) { - for ( which=cnt-1; which>=0; --which ) - if ( strcmp(names[which],find)==0 ) - break; - if ( which==-1 && strstrmatch(find,test->fondname)!=NULL ) - which = GuessStyle(find,styles,cnt); - if ( which==-1 ) { - char *fn = copy(filename); - fn[lparen-filename] = '\0'; - ff_post_error(_("Not in Collection"),_("%s is not in %.100s"),find,fn); - free(fn); - } - free(find); - } else - which = 0; - - if ( which!=-1 ) { - fond = fonds[which]; - *name = copy(names[which]); - *style = styles[which]; + if (find != NULL) { + for (which = cnt - 1; which >= 0; --which) + if (strcmp(names[which], find) == 0) + break; + if (which == -1 && strstrmatch(find, test->fondname) != NULL) + which = GuessStyle(find, styles, cnt); + if (which == -1) { + char *fn = copy(filename); + fn[lparen - filename] = '\0'; + ff_post_error(_("Not in Collection"), _("%s is not in %.100s"), + find, fn); + free(fn); + } + free(find); + } else + which = 0; + + if (which != -1) { + fond = fonds[which]; + *name = copy(names[which]); + *style = styles[which]; } - for ( i=0; istylekerncnt; ++i ) - if ( fond->stylekerns[i].style==style ) - break; - if ( i==fond->stylekerncnt ) { - LogError(_("No kerning table for %s\n"), name ); - free(name); -return( NULL ); + fond = PickFOND(fondlist, filename, &name, &style); + if (fond == NULL || into == NULL) + return (NULL); + for (i = 0; i < fond->stylekerncnt; ++i) + if (fond->stylekerns[i].style == style) + break; + if (i == fond->stylekerncnt) { + LogError(_("No kerning table for %s\n"), name); + free(name); + return (NULL); } - for ( j=0; jstylekerns[i].kernpairs; ++j ) { - ch1 = fond->stylekerns[i].kerns[j].ch1; - ch2 = fond->stylekerns[i].kerns[j].ch2; - offset = (fond->stylekerns[i].kerns[j].offset*(into->ascent+into->descent)+(1<<11))>>12; - sc1 = SFMakeChar(into,map,ch1); - sc2 = SFMakeChar(into,map,ch2); - for ( kp=sc1->kerns; kp!=NULL; kp=kp->next ) - if ( kp->sc==sc2 ) - break; - if ( kp==NULL ) { - uint32 script; - kp = chunkalloc(sizeof(KernPair)); - kp->sc = sc2; - kp->next = sc1->kerns; - sc1->kerns = kp; - script = SCScriptFromUnicode(sc1); - if ( script==DEFAULT_SCRIPT ) - script = SCScriptFromUnicode(sc2); - kp->subtable = SFSubTableFindOrMake(sc1->parent,CHR('k','e','r','n'), - script, gpos_pair); - } - kp->off = offset; + for (j = 0; j < fond->stylekerns[i].kernpairs; ++j) { + ch1 = fond->stylekerns[i].kerns[j].ch1; + ch2 = fond->stylekerns[i].kerns[j].ch2; + offset = + (fond->stylekerns[i].kerns[j].offset * + (into->ascent + into->descent) + (1 << 11)) >> 12; + sc1 = SFMakeChar(into, map, ch1); + sc2 = SFMakeChar(into, map, ch2); + for (kp = sc1->kerns; kp != NULL; kp = kp->next) + if (kp->sc == sc2) + break; + if (kp == NULL) { + uint32 script; + kp = chunkalloc(sizeof(KernPair)); + kp->sc = sc2; + kp->next = sc1->kerns; + sc1->kerns = kp; + script = SCScriptFromUnicode(sc1); + if (script == DEFAULT_SCRIPT) + script = SCScriptFromUnicode(sc2); + kp->subtable = + SFSubTableFindOrMake(sc1->parent, CHR('k', 'e', 'r', 'n'), + script, gpos_pair); + } + kp->off = offset; } -return( into ); + return (into); } /* Look for a bare truetype font in a binhex/macbinary wrapper */ -static SplineFont *MightBeTrueType(FILE *binary,int32 pos,int32 dlen,int flags, - enum openflags openflags) { +static SplineFont *MightBeTrueType(FILE * binary, int32 pos, int32 dlen, + int flags, enum openflags openflags) +{ FILE *temp = tmpfile(); char *buffer = galloc(8192); int len; SplineFont *sf; - if ( flags&ttf_onlynames ) { - char **ret; - char *temp = TTFGetFontName(binary,pos,pos); - if ( temp==NULL ) -return( NULL ); - ret = galloc(2*sizeof(char *)); - ret[0] = temp; - ret[1] = NULL; -return( (SplineFont *) ret ); + if (flags & ttf_onlynames) { + char **ret; + char *temp = TTFGetFontName(binary, pos, pos); + if (temp == NULL) + return (NULL); + ret = galloc(2 * sizeof(char *)); + ret[0] = temp; + ret[1] = NULL; + return ((SplineFont *) ret); } - fseek(binary,pos,SEEK_SET); - while ( dlen>0 ) { - len = dlen > 8192 ? 8192 : dlen; - len = fread(buffer,1,dlen > 8192 ? 8192 : dlen,binary); - if ( len==0 ) - break; - fwrite(buffer,1,len,temp); - dlen -= len; + fseek(binary, pos, SEEK_SET); + while (dlen > 0) { + len = dlen > 8192 ? 8192 : dlen; + len = fread(buffer, 1, dlen > 8192 ? 8192 : dlen, binary); + if (len == 0) + break; + fwrite(buffer, 1, len, temp); + dlen -= len; } rewind(temp); - sf = _SFReadTTF(temp,flags,openflags,NULL,NULL); + sf = _SFReadTTF(temp, flags, openflags, NULL, NULL); fclose(temp); free(buffer); -return( sf ); + return (sf); } -static SplineFont *IsResourceFork(FILE *f, long offset,char *filename,int flags, - enum openflags openflags, SplineFont *into,EncMap *map) { +static SplineFont *IsResourceFork(FILE * f, long offset, char *filename, + int flags, enum openflags openflags, + SplineFont * into, EncMap * map) +{ /* If it is a good resource fork then the first 16 bytes are repeated */ /* at the location specified in bytes 4-7 */ /* We include an offset because if we are looking at a mac binary file */ @@ -876,326 +927,599 @@ static SplineFont *IsResourceFork(FILE *f, long offset,char *filename,int flags, int32 rdata_len, map_len; uint32 nfnt_pos, font_pos, fond_pos; unsigned long tag; - int i, cnt, subcnt, nfnt_subcnt=0, font_subcnt=0, fond_subcnt=0; + int i, cnt, subcnt, nfnt_subcnt = 0, font_subcnt = 0, fond_subcnt = 0; SplineFont *sf; - FOND *fondlist=NULL; - fond_pos=0; - fseek(f,offset,SEEK_SET); - if ( fread(buffer,1,16,f)!=16 ) -return( NULL ); - rdata_pos = offset + ((buffer[0]<<24)|(buffer[1]<<16)|(buffer[2]<<8)|buffer[3]); - map_pos = offset + ((buffer[4]<<24)|(buffer[5]<<16)|(buffer[6]<<8)|buffer[7]); - rdata_len = ((buffer[8]<<24)|(buffer[9]<<16)|(buffer[10]<<8)|buffer[11]); - map_len = ((buffer[12]<<24)|(buffer[13]<<16)|(buffer[14]<<8)|buffer[15]); - if ( rdata_pos+rdata_len!=map_pos || rdata_len==0 ) -return( NULL ); - fseek(f,map_pos,SEEK_SET); - buffer2[15] = buffer[15]+1; /* make it be different */ - if ( fread(buffer2,1,16,f)!=16 ) -return( NULL ); + FOND *fondlist = NULL; + fond_pos = 0; + fseek(f, offset, SEEK_SET); + if (fread(buffer, 1, 16, f) != 16) + return (NULL); + rdata_pos = + offset + + ((buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]); + map_pos = + offset + + ((buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]); + rdata_len = + ((buffer[8] << 24) | (buffer[9] << 16) | (buffer[10] << 8) | + buffer[11]); + map_len = + ((buffer[12] << 24) | (buffer[13] << 16) | (buffer[14] << 8) | + buffer[15]); + if (rdata_pos + rdata_len != map_pos || rdata_len == 0) + return (NULL); + fseek(f, map_pos, SEEK_SET); + buffer2[15] = buffer[15] + 1; /* make it be different */ + if (fread(buffer2, 1, 16, f) != 16) + return (NULL); /* Apple's data fork resources appear to have a bunch of zeroes here instead */ /* of a copy of the first 16 bytes */ - for ( i=0; i<16; ++i ) - if ( buffer2[i]!=0 ) - break; - if ( i!=16 ) { - for ( i=0; i<16; ++i ) - if ( buffer[i]!=buffer2[i] ) -return( NULL ); + for (i = 0; i < 16; ++i) + if (buffer2[i] != 0) + break; + if (i != 16) { + for (i = 0; i < 16; ++i) + if (buffer[i] != buffer2[i]) + return (NULL); } - getlong(f); /* skip the handle to the next resource map */ - getushort(f); /* skip the file resource number */ - getushort(f); /* skip the attributes */ + getlong(f); /* skip the handle to the next resource map */ + getushort(f); /* skip the file resource number */ + getushort(f); /* skip the attributes */ type_list = map_pos + getushort(f); name_list = map_pos + getushort(f); - fseek(f,type_list,SEEK_SET); - cnt = getushort(f)+1; - for ( i=0; i>24, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff );*/ - subcnt = getushort(f)+1; - rpos = type_list+getushort(f); - sf = NULL; - if ( tag==CHR('P','O','S','T') && !(flags&(ttf_onlystrikes|ttf_onlykerns))) /* No FOND */ - sf = SearchPostscriptResources(f,rpos,subcnt,rdata_pos,name_list,flags); - else if ( tag==CHR('s','f','n','t') && !(flags&ttf_onlykerns)) - sf = SearchTtfResources(f,rpos,subcnt,rdata_pos,name_list,filename,flags,openflags); - else if ( tag==CHR('N','F','N','T') ) { - nfnt_pos = rpos; - nfnt_subcnt = subcnt; - } else if ( tag==CHR('F','O','N','T') ) { - font_pos = rpos; - font_subcnt = subcnt; - } else if ( tag==CHR('F','O','N','D') ) { - fond_pos = rpos; - fond_subcnt = subcnt; - } - if ( sf!=NULL ) -return( sf ); + fseek(f, type_list, SEEK_SET); + cnt = getushort(f) + 1; + for (i = 0; i < cnt; ++i) { + tag = getlong(f); + /* printf( "%c%c%c%c\n", tag>>24, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff ); */ + subcnt = getushort(f) + 1; + rpos = type_list + getushort(f); + sf = NULL; + if (tag == CHR('P', 'O', 'S', 'T') && !(flags & (ttf_onlystrikes | ttf_onlykerns))) /* No FOND */ + sf = SearchPostscriptResources(f, rpos, subcnt, rdata_pos, + name_list, flags); + else if (tag == CHR('s', 'f', 'n', 't') && !(flags & ttf_onlykerns)) + sf = SearchTtfResources(f, rpos, subcnt, rdata_pos, name_list, + filename, flags, openflags); + else if (tag == CHR('N', 'F', 'N', 'T')) { + nfnt_pos = rpos; + nfnt_subcnt = subcnt; + } else if (tag == CHR('F', 'O', 'N', 'T')) { + font_pos = rpos; + font_subcnt = subcnt; + } else if (tag == CHR('F', 'O', 'N', 'D')) { + fond_pos = rpos; + fond_subcnt = subcnt; + } + if (sf != NULL) + return (sf); } - if ( flags&ttf_onlynames ) /* Not interested in bitmap resources here */ -return( NULL ); - - if ( flags&ttf_onlykerns ) { /* For kerns */ - if ( fond_subcnt!=0 ) - fondlist = BuildFondList(f,fond_pos,fond_subcnt,rdata_pos,name_list,flags); - into = FindFamilyStyleKerns(into,map,fondlist,filename); - FondListFree(fondlist); -return( into ); + if (flags & ttf_onlynames) /* Not interested in bitmap resources here */ + return (NULL); + + if (flags & ttf_onlykerns) { /* For kerns */ + if (fond_subcnt != 0) + fondlist = + BuildFondList(f, fond_pos, fond_subcnt, rdata_pos, name_list, + flags); + into = FindFamilyStyleKerns(into, map, fondlist, filename); + FondListFree(fondlist); + return (into); } /* Ok. If no outline font, try for a bitmap */ - if ( nfnt_subcnt==0 ) { - nfnt_pos = font_pos; - nfnt_subcnt = font_subcnt; + if (nfnt_subcnt == 0) { + nfnt_pos = font_pos; + nfnt_subcnt = font_subcnt; } -return( (SplineFont *) -1 ); /* It's a valid resource file, but just has no fonts */ + return ((SplineFont *) - 1); /* It's a valid resource file, but just has no fonts */ } -static SplineFont *IsResourceInBinary(FILE *f,char *filename,int flags, - enum openflags openflags, SplineFont *into,EncMap *map) { +static SplineFont *IsResourceInBinary(FILE * f, char *filename, int flags, + enum openflags openflags, + SplineFont * into, EncMap * map) +{ unsigned char header[128]; unsigned long offset, dlen, rlen; - if ( fread(header,1,128,f)!=128 ) -return( NULL ); - if ( header[0]!=0 || header[74]!=0 || header[82]!=0 || header[1]<=0 || - header[1]>33 || header[63]!=0 || header[2+header[1]]!=0 ) -return( NULL ); - dlen = ((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]); - rlen = ((header[0x57]<<24)|(header[0x58]<<16)|(header[0x59]<<8)|header[0x5a]); - /* 128 bytes for header, then the dlen is padded to a 128 byte boundary */ - offset = 128 + ((dlen+127)&~127); + if (fread(header, 1, 128, f) != 128) + return (NULL); + if (header[0] != 0 || header[74] != 0 || header[82] != 0 || header[1] <= 0 + || header[1] > 33 || header[63] != 0 || header[2 + header[1]] != 0) + return (NULL); + dlen = + ((header[0x53] << 24) | (header[0x54] << 16) | (header[0x55] << 8) | + header[0x56]); + rlen = + ((header[0x57] << 24) | (header[0x58] << 16) | (header[0x59] << 8) | + header[0x5a]); + /* 128 bytes for header, then the dlen is padded to a 128 byte boundary */ + offset = 128 + ((dlen + 127) & ~127); /* Look for a bare truetype font in a binhex/macbinary wrapper */ - if ( dlen!=0 && rlen<=dlen) { - int pos = ftell(f); - fread(header,1,4,f); - header[5] = '\0'; - if ( strcmp((char *) header,"OTTO")==0 || strcmp((char *) header,"true")==0 || - strcmp((char *) header,"ttcf")==0 || - (header[0]==0 && header[1]==1 && header[2]==0 && header[3]==0)) -return( MightBeTrueType(f,pos,dlen,flags,openflags)); + if (dlen != 0 && rlen <= dlen) { + int pos = ftell(f); + fread(header, 1, 4, f); + header[5] = '\0'; + if (strcmp((char *) header, "OTTO") == 0 + || strcmp((char *) header, "true") == 0 + || strcmp((char *) header, "ttcf") == 0 || (header[0] == 0 + && header[1] == 1 + && header[2] == 0 + && header[3] == 0)) + return (MightBeTrueType(f, pos, dlen, flags, openflags)); } -return( IsResourceFork(f,offset,filename,flags,openflags,into,map)); + return (IsResourceFork(f, offset, filename, flags, openflags, into, map)); } -static int lastch=0, repeat = 0; -static void outchr(FILE *binary, int ch) { +static int lastch = 0, repeat = 0; +static void outchr(FILE * binary, int ch) +{ int i; - if ( repeat ) { - if ( ch==0 ) { - /* no repeat, output a literal 0x90 (the repeat flag) */ - lastch=0x90; - putc(lastch,binary); - } else { - for ( i=1; i>16)&0xff); - outchr(binary,(val>>8)&0xff); - outchr(binary,val&0xff); - val = cnt = 0; - } + while ((ch = getc(f)) != ':') { + if (isspace(ch)) + continue; + for (pt = sixbit; *pt != ch && *pt != '\0'; ++pt); + if (*pt == '\0') { + fclose(binary); + return (NULL); + } + val = (val << 6) | (pt - sixbit); + if (++cnt == 4) { + outchr(binary, (val >> 16) & 0xff); + outchr(binary, (val >> 8) & 0xff); + outchr(binary, val & 0xff); + val = cnt = 0; + } } - if ( cnt!=0 ) { - if ( cnt==1 ) - outchr(binary,val<<2); - else if ( cnt==2 ) { - val<<=4; - outchr(binary,(val>>8)&0xff); - outchr(binary,val&0xff); - } else if ( cnt==3 ) { - val<<=6; - outchr(binary,(val>>16)&0xff); - outchr(binary,(val>>8)&0xff); - outchr(binary,val&0xff); - } + if (cnt != 0) { + if (cnt == 1) + outchr(binary, val << 2); + else if (cnt == 2) { + val <<= 4; + outchr(binary, (val >> 8) & 0xff); + outchr(binary, val & 0xff); + } else if (cnt == 3) { + val <<= 6; + outchr(binary, (val >> 16) & 0xff); + outchr(binary, (val >> 8) & 0xff); + outchr(binary, val & 0xff); + } } rewind(binary); - ch = getc(binary); /* Name length */ + ch = getc(binary); /* Name length */ /* skip name */ - for ( i=0; i8 || strlen(dpt)>4 ) { - char exten[8]; - strncpy(exten,dpt,7); - exten[4] = '\0'; /* it includes the dot */ - if ( dpt-spt>6 ) - dpt = spt+6; - *dpt++ = '~'; - *dpt++ = '1'; - strcpy(dpt,exten); + spt = strrchr(buffer, '/') + 1; + for (pt = spt; *pt; ++pt) + if (isupper(*pt)) + *pt = tolower(*pt); + dpt = strchr(spt, '.'); + if (dpt == NULL) + dpt = spt + strlen(spt); + if (dpt - spt > 8 || strlen(dpt) > 4) { + char exten[8]; + strncpy(exten, dpt, 7); + exten[4] = '\0'; /* it includes the dot */ + if (dpt - spt > 6) + dpt = spt + 6; + *dpt++ = '~'; + *dpt++ = '1'; + strcpy(dpt, exten); + } + return (IsResourceInFile(buffer, flags, openflags, into, map)); +} + + +static char *createtmpfile(char *filename) +{ + char *p, *tempname; + p = strrchr(filename,'/'); + if (p != NULL) { + filename = p+1; + } + assert(strlen(filename)>=5); + tempname = malloc(strlen(filename)+2); + if (tempname == NULL) { + LogError(_("Out of memory\n")); + exit(1); + } + strcpy(tempname,filename); + strcpy(tempname+strlen(tempname)-5,"XXXXXX"); /* dfont -> XXXXXX */ + +#ifdef HAVE_MKSTEMP + int i = mkstemp(tempname); + if (i) { + close(i); } -return( IsResourceInFile(buffer,flags,openflags,into,map)); +#else + mktemp(tempname); +#endif + return tempname; } -SplineFont *SFReadMacBinary(char *filename,int flags,enum openflags openflags) { - SplineFont *sf = FindResourceFile(filename,flags,openflags,NULL,NULL); +static char *SearchTtfResourcesFile(FILE * f, long rlistpos, int subcnt, + long rdata_pos, long name_list, + char *filename, char *fontname) +{ + long here; + long roff; + int rname = -1; + int ch1, ch2; + int len, i, rlen, ilen; + /* The sfnt resource is just a copy of the ttf file */ + char *buffer = NULL; + int max = 0; + FILE *ttf; + char *sf = NULL; + int which = 0; + char **names; + (void)name_list; + fseek(f, rlistpos, SEEK_SET); + if (subcnt > 1) { + names = gcalloc(subcnt + 1, sizeof(char *)); + for (i = 0; i < subcnt; ++i) { + /* resource id = */ getushort(f); + /* rname = (short) */ getushort(f); + /* flags = */ getc(f); + ch1 = getc(f); + ch2 = getc(f); + roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f)); + /* mbz = */ getlong(f); + here = ftell(f); + names[i] = TTFGetPSFontName(f, roff + 4, roff + 4); + if (names[i] == NULL) { + char buffer[32]; + sprintf(buffer, "Nameless%d", i); + names[i] = copy(buffer); + } + fseek(f, here, SEEK_SET); + } + if (1) { + char *find = fontname; + for (which = subcnt - 1; which >= 0; --which) + if (strcmp(names[which], find) == 0) + break; + if (which == -1) { + char *end; + which = strtol(find, &end, 10); + if (*end != '\0') + which = -1; + } + if (which == -1) { + ff_post_error(_("Not in Collection"), _("%s is not in %.100s"), + find, filename); + } + } else { + which = 0; + } + for (i = 0; i < subcnt; ++i) + free(names[i]); + free(names); + fseek(f, rlistpos, SEEK_SET); + } + + for (i = 0; i < subcnt; ++i) { + /* resource id = */ getushort(f); + rname = (short) getushort(f); + /* flags = */ getc(f); + ch1 = getc(f); + ch2 = getc(f); + roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f)); + /* mbz = */ getlong(f); + if (i != which) + continue; + here = ftell(f); + + sf = createtmpfile(filename); + ttf = fopen(sf, "wb"); + if (ttf == NULL) { + LogError(_("Can't open temporary file for truetype output.\n")); + continue; + } + + fseek(f, roff, SEEK_SET); + ilen = rlen = getlong(f); + if (rlen > 16 * 1024) + ilen = 16 * 1024; + if (ilen > max) { + free(buffer); + max = ilen; + if (max < 0x800) + max = 0x800; + buffer = malloc(max); + } + for (len = 0; len < rlen;) { + int temp = ilen; + if (rlen - len < ilen) + temp = rlen - len; + temp = fread(buffer, 1, temp, f); + if (temp == EOF) + break; + fwrite(buffer, 1, temp, ttf); + len += temp; + } + fclose(ttf); + } + free(buffer); + return sf; +} + +static char *IsResourceForkFile(FILE * f, char *filename, char *fontname) +{ + /* If it is a good resource fork then the first 16 bytes are repeated */ + /* at the location specified in bytes 4-7 */ + /* We include an offset because if we are looking at a mac binary file */ + /* the resource fork will actually start somewhere in the middle of the */ + /* file, not at the beginning */ + unsigned char buffer[16], buffer2[16]; + long rdata_pos, map_pos, type_list, name_list, rpos; + int32 rdata_len, map_len; + uint32 fond_pos; + unsigned long tag; + int i, cnt, subcnt; + char *sf = NULL; + fond_pos = 0; + fseek(f, 0, SEEK_SET); + if (fread(buffer, 1, 16, f) != 16) + return (NULL); + rdata_pos = + ((buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]); + map_pos = + ((buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]); + rdata_len = + ((buffer[8] << 24) | (buffer[9] << 16) | (buffer[10] << 8) | + buffer[11]); + map_len = + ((buffer[12] << 24) | (buffer[13] << 16) | (buffer[14] << 8) | + buffer[15]); + if (rdata_pos + rdata_len != map_pos || rdata_len == 0) + return (NULL); + fseek(f, map_pos, SEEK_SET); + buffer2[15] = buffer[15] + 1; /* make it be different */ + if (fread(buffer2, 1, 16, f) != 16) + return (NULL); + for (i = 0; i < 16; ++i) + if (buffer2[i] != 0) + break; + if (i != 16) { + for (i = 0; i < 16; ++i) + if (buffer[i] != buffer2[i]) + return (NULL); + } + getlong(f); /* skip the handle to the next resource map */ + getushort(f); /* skip the file resource number */ + getushort(f); /* skip the attributes */ + type_list = map_pos + getushort(f); + name_list = map_pos + getushort(f); + fseek(f, type_list, SEEK_SET); + cnt = getushort(f) + 1; + for (i = 0; i < cnt; ++i) { + tag = getlong(f); + subcnt = getushort(f) + 1; + rpos = type_list + getushort(f); + sf = NULL; + if (tag == CHR('s', 'f', 'n', 't')) { + sf = SearchTtfResourcesFile(f, rpos, subcnt, rdata_pos, name_list, + filename, fontname); + } + if (sf != NULL) + return (sf); + } + return NULL; +} + + +/* filename "/opt/tex/texmf-fonts/fonts/data/LucidaGrande.dfont", + fontname "Lucida Grande Bold" + */ +char *FindResourceTtfFont(char *filename, char *fontname) +{ + char *sf = NULL; + FILE *f = fopen(filename, "rb"); + if (f == NULL) + return (NULL); + sf = IsResourceForkFile(f, filename, fontname); + fclose(f); + return sf; +} - if ( sf==NULL ) - LogError( _("Couldn't find a font file named %s\n"), filename ); - else if ( sf==(SplineFont *) (-1) ) { - LogError( _("%s is a mac resource file but contains no postscript or truetype fonts\n"), filename ); - sf = NULL; +SplineFont *SFReadMacBinary(char *filename, int flags, enum openflags openflags) +{ + SplineFont *sf = FindResourceFile(filename, flags, openflags, NULL, NULL); + + if (sf == NULL) + LogError(_("Couldn't find a font file named %s\n"), filename); + else if (sf == (SplineFont *) (-1)) { + LogError(_ + ("%s is a mac resource file but contains no postscript or truetype fonts\n"), + filename); + sf = NULL; } -return( sf ); + return (sf); } -char **NamesReadMacBinary(char *filename) { -return( (char **) FindResourceFile(filename,ttf_onlynames,0,NULL,NULL)); +char **NamesReadMacBinary(char *filename) +{ + return ((char **) FindResourceFile(filename, ttf_onlynames, 0, NULL, NULL)); } /* should try to optimize this */ -SplineFont *SFReadMacBinaryInfo(char *filename,int flags,enum openflags openflags) { - SplineFont *sf = FindResourceFile(filename,flags,openflags,NULL,NULL); - - if ( sf==NULL ) - LogError( _("Couldn't find a font file named %s\n"), filename ); - else if ( sf==(SplineFont *) (-1) ) { - LogError( _("%s is a mac resource file but contains no postscript or truetype fonts\n"), filename ); - sf = NULL; +SplineFont *SFReadMacBinaryInfo(char *filename, int flags, + enum openflags openflags) +{ + SplineFont *sf = FindResourceFile(filename, flags, openflags, NULL, NULL); + + if (sf == NULL) + LogError(_("Couldn't find a font file named %s\n"), filename); + else if (sf == (SplineFont *) (-1)) { + LogError(_ + ("%s is a mac resource file but contains no postscript or truetype fonts\n"), + filename); + sf = NULL; } -return( sf ); + return (sf); } diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c index d3199f05ee7..3eb886c352f 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c @@ -42,7 +42,7 @@ static void NOUI_IError(const char *format,...) { static void NOUI__LogError(const char *format,va_list ap) { char buffer[400], *str; vsnprintf(buffer,sizeof(buffer),format,ap); - str = utf82def_copy(buffer); + str = (char *)buffer; fprintf(stderr,"%s",str); if ( str[strlen(str)-1]!='\n' ) putc('\n',stderr); diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c index 1f75c22cddc..9ccd1d393dd 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c @@ -33,11 +33,19 @@ #include #include "ttf.h" +extern char *AdobeStandardEncoding[], *AdobeExpertEncoding[]; +extern const char *ttfstandardnames[]; +extern int ask_user_for_cmap; +extern char *SaveTablesPref; + #ifdef LUA_FF_LIB SplineFont *_SFReadTTFInfo(FILE *ttf, int flags,enum openflags openflags, char *filename,struct fontdict *fd); void THPatchSplineChar(SplineChar *sc); #endif +int THtest_duplicate_glyph_names = 0; +int THread_ttf_glyph_data = 0; + char *SaveTablesPref; int ask_user_for_cmap = false; @@ -579,6 +587,57 @@ return( NULL ); return( _readencstring(ttf,stringoffset+fullstr,fulllen,fullplat,fullspec,fulllang)); } + +char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) { + int i,num; + int32 tag, length, stringoffset; + int name, len, off; + int32 nameoffset = 0; + + fseek(ttf,offset,SEEK_SET); + /* version = */ getlong(ttf); + num = getushort(ttf); + /* srange = */ getushort(ttf); + /* esel = */ getushort(ttf); + /* rshift = */ getushort(ttf); + for ( i=0; ixmax = getushort(ttf); sc->ymax = getushort(ttf); sc->lsidebearing = sc->xmin; -#else - /* xmin = */ sc->lsidebearing = getushort(ttf); - /* ymin = */ getushort(ttf); - /* xmax = */ getushort(ttf); - /* ymax = */ /* sc->lsidebearing = */ getushort(ttf); /* what was this for? */ #endif - if ( path_cnt>=0 ) + if (THread_ttf_glyph_data) { + if ( path_cnt>=0 ) readttfsimpleglyph(ttf,info,sc,path_cnt); - else + else readttfcompositglyph(ttf,info,sc,info->glyph_start+end); - if ( start>end ) { + if ( start>end ) { LogError(_("Bad glyph (%d), disordered 'loca' table (start comes after end)\n"), gid ); info->bad_glyph_data = true; - } else if ( ftell(ttf)>info->glyph_start+end ) { + } else if ( ftell(ttf)>(long)(info->glyph_start+end) ) { LogError(_("Bad glyph (%d), its definition extends beyond the space allowed for it\n"), gid ); info->bad_glyph_data = true; + } + + /* find the bb */ + THPatchSplineChar(sc); } - - /* find the bb */ - THPatchSplineChar(sc); return( sc ); } @@ -3284,7 +3339,6 @@ return( strings[sid-nStdStrings]); static void readcffenc(FILE *ttf,struct topdicts *dict,struct ttfinfo *info, char **strings, int scnt) { int format, cnt, i, j, pos, first, last, dupenc, sid; - extern char *AdobeStandardEncoding[], *AdobeExpertEncoding[]; const char *name; EncMap *map; @@ -3722,7 +3776,7 @@ static void cfffigure(struct ttfinfo *info, struct topdicts *dict, info->chars = gcalloc(info->glyph_cnt,sizeof(SplineChar *)); for ( i=0; iglyph_cnt; ++i ) { - info->chars[i] = PSCharStringToSplines( + info->chars[i] = PSCharStringToBB( dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext, subrs,gsubrs,FFgetsid(dict->charset[i],strings,scnt,info)); info->chars[i]->vwidth = info->emsize; @@ -3805,7 +3859,7 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict, cid = dict->charset[i]; /*encmap->map[cid] = cid;*/ uni = CID2NameUni(map,cid,buffer,sizeof(buffer)); - info->chars[i] = PSCharStringToSplines( + info->chars[i] = PSCharStringToBB( dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext, subrs,gsubrs,buffer); info->chars[i]->vwidth = sf->ascent+sf->descent; @@ -4129,6 +4183,7 @@ static int umodenc(int enc,int modtype, struct ttfinfo *info) { return( -1 ); if ( modtype<=1 /* Unicode */ ) { /* No conversion needed, already unicode */; +#ifdef FROM_CJK_ICONV } else if ( modtype==2 /* SJIS */ ) { if ( enc<=127 ) { /* Latin */ @@ -4186,6 +4241,10 @@ return( -1 ); enc = unicode_from_johab[enc-0x8400]; else if ( enc>0x100 ) enc = badencoding(info); +#else + } else { + enc = badencoding(info); +#endif } if ( enc==0 ) enc = -1; @@ -4464,7 +4523,6 @@ static void readttfencodings(FILE *ttf,struct ttfinfo *info, int justinuse) { Encoding *temp; EncMap *map; struct cmap_encs *cmap_encs, desired_cmaps[2], *dcmap; - extern int ask_user_for_cmap; fseek(ttf,info->encoding_start,SEEK_SET); version = getushort(ttf); @@ -5093,7 +5151,6 @@ static void readttfpostnames(FILE *ttf,struct ttfinfo *info) { const char *name; char buffer[30]; uint16 *indexes; - extern const char *ttfstandardnames[]; int notdefwarned = false; int anynames = false; @@ -5211,7 +5268,7 @@ static void readttfpostnames(FILE *ttf,struct ttfinfo *info) { name = NULL; } else { name = StdGlyphName(buffer,info->chars[i]->unicodeenc,info->uni_interp,NULL); - if ( anynames ) { + if (THtest_duplicate_glyph_names && anynames ) { for ( j=0; jglyph_cnt; ++j ) { if ( info->chars[j]!=NULL && j!=i && info->chars[j]->name!=NULL ) { if ( strcmp(info->chars[j]->name,name)==0 ) { @@ -5942,56 +5999,6 @@ return; map->backmap[map->map[i]] = i; } -void TTF_PSDupsDefault(SplineFont *sf) { - struct ttflangname *english; - char versionbuf[40]; - - /* Ok, if we've just loaded a ttf file then we've got a bunch of langnames*/ - /* we copied some of them (copyright, family, fullname, etc) into equiv */ - /* postscript entries in the sf. If we then use FontInfo and change the */ - /* obvious postscript entries we are left with the old ttf entries. If */ - /* we generate a ttf file and then load it the old values pop up. */ - /* Solution: Anything we can generate by default should be set to NULL */ - for ( english=sf->names; english!=NULL && english->lang!=0x409; english=english->next ); - if ( english==NULL ) -return; - if ( english->names[ttf_family]!=NULL && - strcmp(english->names[ttf_family],sf->familyname)==0 ) { - free(english->names[ttf_family]); - english->names[ttf_family]=NULL; - } - if ( english->names[ttf_copyright]!=NULL && - strcmp(english->names[ttf_copyright],sf->copyright)==0 ) { - free(english->names[ttf_copyright]); - english->names[ttf_copyright]=NULL; - } - if ( english->names[ttf_fullname]!=NULL && - strcmp(english->names[ttf_fullname],sf->fullname)==0 ) { - free(english->names[ttf_fullname]); - english->names[ttf_fullname]=NULL; - } - if ( sf->subfontcnt!=0 || sf->version!=NULL ) { - if ( sf->subfontcnt!=0 ) - sprintf( versionbuf, "Version %f", sf->cidversion ); - else - sprintf(versionbuf,"Version %.20s ", sf->version); - if ( english->names[ttf_version]!=NULL && - strcmp(english->names[ttf_version],versionbuf)==0 ) { - free(english->names[ttf_version]); - english->names[ttf_version]=NULL; - } - } - if ( english->names[ttf_subfamily]!=NULL && - strcmp(english->names[ttf_subfamily],SFGetModifiers(sf))==0 ) { - free(english->names[ttf_subfamily]); - english->names[ttf_subfamily]=NULL; - } - - /* User should not be allowed any access to this one, not ever */ - free(english->names[ttf_postscriptname]); - english->names[ttf_postscriptname]=NULL; -} - static SplineFont *SFFillFromTTF(struct ttfinfo *info) { SplineFont *sf, *_sf; int i,k; @@ -6175,21 +6182,6 @@ static SplineFont *SFFillFromTTF(struct ttfinfo *info) { sf->subfonts[i]->hasvmetrics = sf->hasvmetrics; } } - TTF_PSDupsDefault(sf); -#if 0 - if ( info->gsub_start==0 && info->mort_start==0 && info->morx_start==0 ) { - /* Get default ligature values, etc. */ - k=0; - do { - _sf = ksubfontcnt?sf->subfonts[k]:sf; - for ( i=0; iglyphcnt; ++i ) { - if ( _sf->glyphs[i]!=NULL ) /* Might be null in ttc files */ - SCLigDefault(_sf->glyphs[i]); - } - ++k; - } while ( ksubfontcnt ); - } -#endif /* I thought the languages were supposed to be ordered, but it seems */ /* that is not always the case. Order everything, just in case */ @@ -6382,11 +6374,13 @@ return( SFFillFromTTFInfo(&info)); SplineFont *SFReadTTFInfo(char *filename, int flags, enum openflags openflags) { FILE *ttf; SplineFont *sf; - char *temp=filename, *pt, *lparen; + char *temp=filename, *pt, *lparen, *rparen; pt = strrchr(filename,'/'); if ( pt==NULL ) pt = filename; - if ( (lparen=strchr(pt,'('))!=NULL && strchr(lparen,')')!=NULL ) { + if ( (lparen = strrchr(pt,'('))!=NULL && + (rparen = strrchr(lparen,')'))!=NULL && + rparen[1]=='\0' ) { temp = copy(filename); pt = temp + (lparen-filename); *pt = '\0'; diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c index 8b86752fc20..fa466564027 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c @@ -316,7 +316,10 @@ static uint16 *getClassDefTable(FILE *ttf, int classdef_offset, struct ttfinfo * } else if ( ftell(ttf)+2*glyphcnt > g_bounds ) { LogError( _("Class definition sub-table extends beyond end of table\n") ); info->bad_ot = true; - glyphcnt = (g_bounds-ftell(ttf))/2; + if (g_bounds /* Solaris defines isnan in ieeefp rather than math.h */ #endif +int THdo_hint_guessing = 0; +int THdo_set_reversing = 0; +int THdo_catagorize = 0; + typedef struct _io { char *macro, *start; FILE *ps, *fog; @@ -2673,7 +2677,7 @@ static void EntityDefaultStrokeFill(Entity *ent) { static SplinePointList *SplinesFromEntityChar(EntityChar *ec,int *flags,int is_stroked) { Entity *ent, *next; - SplinePointList *head=NULL, *last, *new, *nlast, *temp, *each, *transed; + SplinePointList *head=NULL, *last=NULL, *new, *nlast=NULL, *temp, *each, *transed; StrokeInfo si; real inversetrans[6]; /*SplineSet *spl;*/ @@ -4072,7 +4076,8 @@ SplineChar *PSCharStringToSplines(uint8 *type1, int len, struct pscontext *conte done: if ( pcsp!=0 ) LogError( _("end of subroutine reached with no return in %s\n"), name ); - SCCatagorizePoints(ret); + if (THdo_catagorize) + SCCatagorizePoints(ret); ret->hstem = HintsAppend(ret->hstem,activeh); activeh=NULL; ret->vstem = HintsAppend(ret->vstem,activev); activev=NULL; @@ -4097,27 +4102,699 @@ SplineChar *PSCharStringToSplines(uint8 *type1, int len, struct pscontext *conte SplineMake3(cur->last,cur->first); cur->last = cur->first; } - /* Oh, I see. PS and TT disagree on which direction to use, so Fontographer*/ /* chose the TT direction and we must reverse postscript */ - for ( cur = ret->layers[ly_fore].splines; cur!=NULL; cur = cur->next ) + if (THdo_set_reversing) { + for ( cur = ret->layers[ly_fore].splines; cur!=NULL; cur = cur->next ) SplineSetReverse(cur); + } if ( ret->hstem==NULL && ret->vstem==NULL ) ret->manualhints = false; if ( !is_type2 && context->instance_count!=0 ) { UnblendFree(ret->hstem); UnblendFree(ret->vstem); } - ret->hstem = HintCleanup(ret->hstem,true,context->instance_count); - ret->vstem = HintCleanup(ret->vstem,true,context->instance_count); - SCGuessHHintInstancesList(ret,ly_fore); - SCGuessVHintInstancesList(ret,ly_fore); - ret->hconflicts = StemListAnyConflicts(ret->hstem); - ret->vconflicts = StemListAnyConflicts(ret->vstem); - if ( context->instance_count==1 && !ret->hconflicts && !ret->vconflicts ) + if (THdo_hint_guessing) { + ret->hstem = HintCleanup(ret->hstem,true,context->instance_count); + ret->vstem = HintCleanup(ret->vstem,true,context->instance_count); + SCGuessHHintInstancesList(ret,ly_fore); + SCGuessVHintInstancesList(ret,ly_fore); + ret->hconflicts = StemListAnyConflicts(ret->hstem); + ret->vconflicts = StemListAnyConflicts(ret->vstem); + if ( context->instance_count==1 && !ret->hconflicts && !ret->vconflicts ) SCClearHintMasks(ret,ly_fore,false); - HintsRenumber(ret); + HintsRenumber(ret); + } if ( name!=NULL && strcmp(name,".notdef")!=0 ) ret->widthset = true; return( ret ); } + + +/* This finds the 'connect-the-dots' boundingbox of a Type2 charstring */ +/* It is a simplified version of PSCharStringToSplines, above */ + +SplineChar *PSCharStringToBB(uint8 *type1, int len, struct pscontext *context, + struct pschars *subrs, struct pschars *gsubrs, const char *name) { + real stack[50]; int sp=0, v; /* Type1 stack is about 25 long, Type2 stack is 48 */ + real transient[32]; + SplineChar *ret = SplineCharCreate(2); + + DBasePoint current, ll, ur; + real dx, dy, dx2, dy2, dx3, dy3, dx4, dy4, dx5, dy5, dx6=0, dy6; + + int first = 1; /* to flag extra set width */ + /* subroutines may be nested to a depth of 10 */ + struct substate { unsigned char *type1; int len; int subnum; } pcstack[11]; + int pcsp=0; + + real pops[30]; + int popsp=0; + int base, polarity; + + struct pschars *s; + int hint_cnt = 0; + + int last_was_b1=false, old_last_was_b1; + + ret->name = copy( name ); + ret->unicodeenc = -1; + ret->width = (int16) 0x8000; + if ( name==NULL ) name = "unnamed"; + ret->manualhints = true; + if ( !context->is_type2 ) { + LogError( _("Quick boundingbox mode only does CFF charstrings, not Type1 (font %s)\n"), name ); + return (ret); + } + + current.x = current.y = 0; + ll.x = ll.y = (int16) 0x7FFF; + ur.x = ur.y = (int16) -0x7FFF; + + while ( len>0 ) { + if ( sp>48 ) { + LogError( _("Stack got too big in %s\n"), name ); + sp = 48; + } + base = 0; + --len; + if ( (v = *type1++)>=32 ) { + if ( v<=246) { + stack[sp++] = v - 139; + } else if ( v<=250 ) { + stack[sp++] = (v-247)*256 + *type1++ + 108; + --len; + } else if ( v<=254 ) { + stack[sp++] = -(v-251)*256 - *type1++ - 108; + --len; + } else { + int val = (*type1<<24) | (type1[1]<<16) | (type1[2]<<8) | type1[3]; + stack[sp++] = val; + type1 += 4; + len -= 4; + stack[sp-1] /= 65536.; + } + } else if ( v==28 ) { + stack[sp++] = (short) ((type1[0]<<8) | type1[1]); + type1 += 2; + len -= 2; + /* In the Dict tables of CFF, a 5byte fixed value is prefixed by a */ + /* 29 code. In Type2 strings the prefix is 255. */ + } else if ( v==12 ) { + old_last_was_b1 = last_was_b1; last_was_b1 = false; + v = *type1++; + --len; + switch ( v ) { + case 0: /* dotsection */ + sp = 0; + break; + case 1: /* vstem3 */ /* specifies three v hints zones at once */ + if ( sp<6 ) LogError( _("Stack underflow on vstem3 in %s\n"), name ); + /* according to the standard, if there is a vstem3 there can't */ + /* be any vstems, so there can't be any confusion about hint order */ + /* so we don't need to worry about unblended stuff */ + hint_cnt+=3; + sp = 0; + break; + case 2: /* hstem3 */ /* specifies three h hints zones at once */ + if ( sp<6 ) LogError( _("Stack underflow on hstem3 in %s\n"), name ); + hint_cnt+=3; + sp = 0; + break; + case 6: /* seac */ /* build accented characters */ + seac: + if ( sp<5 ) LogError( _("Stack underflow on seac in %s\n"), name ); + /* stack[0] must be the lsidebearing of the accent. I'm not sure why */ + sp = 0; + break; + case 7: /* sbw */ /* generalized width/sidebearing command */ + if ( sp<4 ) LogError( _("Stack underflow on sbw in %s\n"), name ); + ret->lsidebearing = stack[0]; + /* stack[1] is lsidebearing y (only for vertical writing styles, CJK) */ + ret->width = stack[2]; + /* stack[3] is height (for vertical writing styles, CJK) */ + sp = 0; + break; + case 5: case 9: case 14: case 26: + if ( sp<1 ) LogError( _("Stack underflow on unary operator in %s\n"), name ); + switch ( v ) { + case 5: stack[sp-1] = (stack[sp-1]==0); break; /* not */ + case 9: if ( stack[sp-1]<0 ) stack[sp-1]= -stack[sp-1]; break; /* abs */ + case 14: stack[sp-1] = -stack[sp-1]; break; /* neg */ + case 26: stack[sp-1] = sqrt(stack[sp-1]); break; /* sqrt */ + } + break; + case 3: case 4: case 10: case 11: case 12: case 15: case 24: + if ( sp<2 ) LogError( _("Stack underflow on binary operator in %s\n"), name ); + else switch ( v ) { + case 3: /* and */ + stack[sp-2] = (stack[sp-1]!=0 && stack[sp-2]!=0); + break; + case 4: /* and */ + stack[sp-2] = (stack[sp-1]!=0 || stack[sp-2]!=0); + break; + case 10: /* add */ + stack[sp-2] += stack[sp-1]; + break; + case 11: /* sub */ + stack[sp-2] -= stack[sp-1]; + break; + case 12: /* div */ + stack[sp-2] /= stack[sp-1]; + break; + case 24: /* mul */ + stack[sp-2] *= stack[sp-1]; + break; + case 15: /* eq */ + stack[sp-2] = (stack[sp-1]==stack[sp-2]); + break; + } + --sp; + break; + case 22: /* ifelse */ + if ( sp<4 ) LogError( _("Stack underflow on ifelse in %s\n"), name ); + else { + if ( stack[sp-2]>stack[sp-1] ) + stack[sp-4] = stack[sp-3]; + sp -= 3; + } + break; + case 23: /* random */ + /* This function returns something (0,1]. It's not clear to me*/ + /* if rand includes 0 and RAND_MAX or not, but this approach */ + /* should work no matter what */ + do { + stack[sp] = (rand()/(RAND_MAX-1)); + } while ( stack[sp]==0 || stack[sp]>1 ); + ++sp; + break; + case 20: /* put */ + if ( sp<2 ) LogError( _("Too few items on stack for put in %s\n"), name ); + else if ( stack[sp-1]<0 || stack[sp-1]>=32 ) LogError( _("Reference to transient memory out of bounds in put in %s\n"), name ); + else { + transient[(int)stack[sp-1]] = stack[sp-2]; + sp -= 2; + } + break; + case 21: /* get */ + if ( sp<1 ) LogError( _("Too few items on stack for get in %s\n"), name ); + else if ( stack[sp-1]<0 || stack[sp-1]>=32 ) LogError( _("Reference to transient memory out of bounds in put in %s\n"), name ); + else + stack[sp-1] = transient[(int)stack[sp-1]]; + break; + case 17: /* pop */ + /* pops something from the postscript stack and pushes it on ours */ + /* used to get a return value from an othersubr call */ + /* Bleah. Adobe wants the pops to return the arguments if we */ + /* don't understand the call. What use is the subroutine then?*/ + if ( popsp<=0 ) + LogError( _("Pop stack underflow on pop in %s\n"), name ); + else + stack[sp++] = pops[--popsp]; + break; + case 18: /* drop */ + if ( sp>0 ) --sp; + break; + case 27: /* dup */ + if ( sp>=1 ) { + stack[sp] = stack[sp-1]; + ++sp; + } + break; + case 28: /* exch */ + if ( sp>=2 ) { + real temp = stack[sp-1]; + stack[sp-1] = stack[sp-2]; stack[sp-2] = temp; + } + break; + case 29: /* index */ + if ( sp>=1 ) { + int index = stack[--sp]; + if ( index<0 || sp=2 ) { + int j = stack[sp-1], N=stack[sp-2]; + if ( N>sp || j>=N || j<0 || N<0 ) + LogError( _("roll out of range in %s\n"), name ); + else if ( j==0 || N==0 ) + /* No op */; + else { + real *temp = galloc(N*sizeof(real)); + int i; + for ( i=0; icurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xyt ) { + dx6 = stack[base++]; + dy6 = -dy-dy2-dy3-dy4-dy5; + } else { + dy6 = stack[base++]; + dx6 = -dx-dx2-dx3-dx4-dx5; + } + break; + } + current.x = current.x+dx; current.y = current.y+dy; + if (ll.y>current.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xwidth == (int16) 0x8000 ) + ret->width = stack[0]; + if ( sp&1 ) + base=1; + if ( sp-base<2 ) + LogError( _("Stack underflow on hstem in %s\n"), name ); + /* stack[0] is absolute y for start of horizontal hint */ + /* (actually relative to the y specified as lsidebearing y in sbw*/ + /* stack[1] is relative y for height of hint zone */ + + + while ( sp-base>=2 ) { + hint_cnt++; + base+=2; + } + sp = 0; + break; + case 19: /* hintmask */ + case 20: /* cntrmask */ + /* If there's anything on the stack treat it as a vstem hint */ + case 3: /* vstem */ + case 23: /* vstemhm */ + base = 0; + if ( first || v==3 || v==23 ) { + if ( (sp&1) && ret->width == (int16) 0x8000 ) { + ret->width = stack[0]; + } + if ( sp&1 ) + base=1; + if ( sp-base<2 && v!=19 && v!=20 ) + LogError( _("Stack underflow on vstem in %s\n"), name ); + /* stack[0] is absolute x for start of vertical hint */ + /* (actually relative to the x specified as lsidebearing in h/sbw*/ + /* stack[1] is relative x for height of hint zone */ + + + while ( sp-base>=2 ) { + hint_cnt++; + base+=2; + } + sp = 0; + } + if ( v==19 || v==20 ) { /* hintmask, cntrmask */ + unsigned bytes = (hint_cnt+7)/8; + if ( bytes>sizeof(HintMask) ) bytes = sizeof(HintMask); + if ( bytes!=(unsigned)hint_cnt/8 ) { + int mask = 0xff>>(hint_cnt&7); + if ( type1[bytes-1]&mask ) + LogError( _("Hint mask (or counter mask) with too many hints in %s\n"), name ); + } + type1 += bytes; + len -= bytes; + } + break; + case 14: /* endchar */ + /* endchar is allowed to terminate processing even within a subroutine */ + if ( (sp&1) && ret->width == (int16) 0x8000 ) + ret->width = stack[0]; + pcsp = 0; + if ( sp==4 ) { + /* In Type2 strings endchar has a depreciated function of doing */ + /* a seac (which doesn't exist at all). Except enchar takes */ + /* 4 args and seac takes 5. Bleah */ + stack[4] = stack[3]; stack[3] = stack[2]; stack[2] = stack[1]; stack[1] = stack[0]; + stack[0] = 0; + sp = 5; + goto seac; + } else if ( sp==5 ) { + /* same as above except also specified a width */ + stack[0] = 0; + goto seac; + } + /* the docs say that endchar must be the last command in a char */ + goto done; + break; + case 13: /* hsbw (set left sidebearing and width) */ + if ( sp<2 ) LogError( _("Stack underflow on hsbw in %s\n"), name ); + ret->lsidebearing = stack[0]; + current.x = stack[0]; /* sets the current point too */ + if (ll.x>current.x) ll.x = current.x; + if (ur.xwidth = stack[1]; + sp = 0; + break; + case 9: /* closepath */ + sp = 0; + break; + case 21: /* rmoveto */ + case 22: /* hmoveto */ + case 4: /* vmoveto */ + if (( (v==21 && sp==3) || (v!=21 && sp==2)) && ret->width == (int16) 0x8000 ) + /* Character's width may be specified on the first moveto */ + ret->width = stack[0]; + if ( v==21 && sp>2 ) { + stack[0] = stack[sp-2]; stack[1] = stack[sp-1]; + sp = 2; + } else if ( v!=21 && sp>1 ) { + stack[0] = stack[sp-1]; + sp = 1; + } + /* fall through */ + case 5: /* rlineto */ + case 6: /* hlineto */ + case 7: /* vlineto */ + polarity = 0; + base = 0; + while ( basecurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xbase+6 ) { + current.x = current.x+stack[base++]; current.y = current.y+stack[base++]; + if (ll.y>current.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xbase+2 ) { + dx = dy = dx2 = dy2 = dx3 = dy3 = 0; + if ( v==8 || v==25 || v==24 ) { + if ( sp<6+base ) { + LogError( _("Stack underflow on rrcurveto in %s\n"), name ); + base = sp; + } else { + dx = stack[base++]; + dy = stack[base++]; + dx2 = stack[base++]; + dy2 = stack[base++]; + dx3 = stack[base++]; + dy3 = stack[base++]; + } + } else if ( v==27 ) { /* hhcurveto */ + if ( sp<4+base ) { + LogError( _("Stack underflow on hhcurveto in %s\n"), name ); + base = sp; + } else { + if ( (sp-base)&1 ) dy = stack[base++]; + dx = stack[base++]; + dx2 = stack[base++]; + dy2 = stack[base++]; + dx3 = stack[base++]; + } + } else if ( v==26 ) { /* vvcurveto */ + if ( sp<4+base ) { + LogError( _("Stack underflow on hhcurveto in %s\n"), name ); + base = sp; + } else { + if ( (sp-base)&1 ) dx = stack[base++]; + dy = stack[base++]; + dx2 = stack[base++]; + dy2 = stack[base++]; + dy3 = stack[base++]; + } + } else if ( (v==31 && !(polarity&1)) || (v==30 && (polarity&1)) ) { + if ( sp<4+base ) { + LogError( _("Stack underflow on hvcurveto in %s\n"), name ); + base = sp; + } else { + dx = stack[base++]; + dx2 = stack[base++]; + dy2 = stack[base++]; + dy3 = stack[base++]; + if ( sp==base+1 ) + dx3 = stack[base++]; + } + } else /*if ( (v==30 && !(polarity&1)) || (v==31 && (polarity&1)) )*/ { + if ( sp<4+base ) { + LogError( _("Stack underflow on vhcurveto in %s\n"), name ); + base = sp; + } else { + dy = stack[base++]; + dx2 = stack[base++]; + dy2 = stack[base++]; + dx3 = stack[base++]; + if ( sp==base+1 ) + dy3 = stack[base++]; + } + } + ++polarity; + current.x = current.x+dx; current.y = current.y+dy; + if (ll.y>current.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.xcurrent.y) ll.y = current.y; + if (ur.ycurrent.x) ll.x = current.x; + if (ur.x10 ) { + LogError( _("Too many subroutine calls in %s\n"), name ); + break; + } + s=subrs; if ( v==29 ) s = gsubrs; + if ( s!=NULL ) stack[sp-1] += s->bias; + /* Type2 subrs have a bias that must be added to the subr-number */ + /* Type1 subrs do not. We set the bias on them to 0 */ + if ( s==NULL || stack[sp-1]>=s->cnt || stack[sp-1]<0 || + s->values[(int) stack[sp-1]]==NULL ) + LogError( _("Subroutine number out of bounds in %s\n"), name ); + else { + pcstack[pcsp].type1 = type1; + pcstack[pcsp].len = len; + pcstack[pcsp].subnum = stack[sp-1]; + ++pcsp; + type1 = s->values[(int) stack[sp-1]]; + len = s->lens[(int) stack[sp-1]]; + } + if ( --sp<0 ) sp = 0; + break; + case 11: /* return */ + /* return from a subr outine */ + if ( pcsp<1 ) LogError( _("return when not in subroutine in %s\n"), name ); + else { + --pcsp; + type1 = pcstack[pcsp].type1; + len = pcstack[pcsp].len; + } + break; + case 16: { /* blend -- obsolete type 2 multiple master operator */ + int cnt,i,j; + if ( context->instance_count==0 ) + LogError( _("Attempt to use a multiple master subroutine in a non-mm font.\n") ); + else if ( sp<1 || spinstance_count*stack[sp-1]+1 ) + LogError( _("Too few items on stack for blend in %s\n"), name ); + else { + if ( !context->blend_warn ) { + LogError( _("Use of obsolete blend operator.\n") ); + context->blend_warn = true; + } + cnt = stack[sp-1]; + sp -= context->instance_count*stack[sp-1]+1; + for ( i=0; iinstance_count; ++j ) + stack[sp+i] += context->blend_values[j]*stack[sp+ + cnt+ i*(context->instance_count-1)+ j-1]; + } + /* there will always be fewer pushes than there were pops */ + /* so I don't bother to check the stack */ + sp += cnt; + } + } + break; + default: + LogError( _("Uninterpreted opcode %d in %s\n"), v, name ); + break; + }} + } +done: + if ( pcsp!=0 ) + LogError( _("end of subroutine reached with no return in %s\n"), name ); + + if ( name!=NULL && strcmp(name,".notdef")!=0 ) + ret->widthset = true; + if (ur.x == -0x7FFF) ur.x = 0; + if (ur.y == -0x7FFF) ur.y = 0; + if (ll.x == 0x7FFF) ll.x = 0; + if (ll.y == 0x7FFF) ll.y = 0; + if (ll.x>ur.x) ll.x = ur.x; + if (ll.y>ur.y) ll.y = ur.y; + + + ret->xmin = rint(ll.x); + ret->ymin = rint(ll.y); + ret->xmax = rint(ur.x); + ret->ymax = rint(ur.y); + /* free the curves */ + if (ret->layers!=NULL && ret->layers[ly_fore].splines != NULL) { + SplinePointListsFree(ret->layers[ly_fore].splines); + ret->layers[ly_fore].splines=NULL; + } + if (ret->layers[ly_fore].refs!=NULL) { + RefCharsFree(ret->layers[ly_fore].refs); + ret->layers[ly_fore].refs = NULL; + } + return( ret ); +} diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c index 1fa40c46072..9f0ed92305f 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c @@ -498,7 +498,7 @@ return( _ReadSplineFont(NULL,filename,openflags)); SplineFont *ReadSplineFontInfo(char *filename,enum openflags openflags) { SplineFont *sf, *sf_ptr; char **fontlist; - char *pt =NULL, *strippedname=filename, *paren=NULL, *fullname=filename; + char *pt =NULL, *strippedname=filename, *paren=NULL, *rparen=NULL, *fullname=filename; FILE *foo = NULL; int checked = 0; char s[512] = {0}; @@ -508,9 +508,14 @@ return( NULL ); pt = strrchr(filename,'/'); if ( pt==NULL ) pt = filename; - if ( (paren=strchr(pt,'('))!=NULL && strchr(paren,')')!=NULL ) { - strippedname = copy(filename); - strippedname[paren-filename] = '\0'; + /* Someone gave me a font "Nafees Nastaleeq(Updated).ttf" and complained */ + /* that ff wouldn't open it */ + /* Now someone will complain about "Nafees(Updated).ttc(fo(ob)ar)" */ + if ( (paren = strrchr(pt,'('))!=NULL && + (rparen = strrchr(paren,')'))!=NULL && + rparen[1]=='\0' ) { + strippedname = copy(filename); + strippedname[paren-filename] = '\0'; } sf = NULL; diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h index fa989d61543..a15b6b75325 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h @@ -1866,8 +1866,11 @@ struct findsel; struct charprocs; struct enc; -extern void *chunkalloc(int size); -extern void chunkfree(void *, int size); +/* extern void *chunkalloc(int size); */ +/* extern void chunkfree(void *, int size); */ + +#define chunkalloc(size) gcalloc(1,size) +#define chunkfree(item,size) free(item) extern char *strconcat(const char *str, const char *str2); extern char *strconcat3(const char *str, const char *str2, const char *str3); @@ -1946,7 +1949,6 @@ extern long mactime(void); extern int WriteSVGFont(char *fontname,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,int layer); extern int WriteUFOFont(char *fontname,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,int layer); extern void SfListFree(struct sflist *sfs); -extern void TTF_PSDupsDefault(SplineFont *sf); extern void DefaultTTFEnglishNames(struct ttflangname *dummy, SplineFont *sf); extern void TeXDefaultParams(SplineFont *sf); extern int AlreadyMSSymbolArea(SplineFont *sf,EncMap *map); @@ -2506,6 +2508,7 @@ extern SplineFont *_SFDRead(char *filename,FILE *sfd); extern SplineFont *SFDirRead(char *filename); extern SplineChar *SFDReadOneChar(SplineFont *sf,const char *name); extern char *TTFGetFontName(FILE *ttf,int32 offset,int32 off2); +extern char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2); extern void TTFLoadBitmaps(FILE *ttf,struct ttfinfo *info, int onlyone); enum ttfflags { ttf_onlystrikes=1, ttf_onlyonestrike=2, ttf_onlykerns=4, ttf_onlynames=8 }; extern SplineFont *_SFReadTTF(FILE *ttf,int flags,enum openflags openflags, @@ -2601,6 +2604,8 @@ struct pscontext { extern int UnblendedCompare(real u1[MmMax], real u2[MmMax], int cnt); extern SplineChar *PSCharStringToSplines(uint8 *type1, int len, struct pscontext *context, struct pschars *subrs, struct pschars *gsubrs, const char *name); +extern SplineChar *PSCharStringToBB(uint8 *type1, int len, struct pscontext *context, + struct pschars *subrs, struct pschars *gsubrs, const char *name); extern void MatMultiply(real m1[6], real m2[6], real to[6]); extern int NameToEncoding(SplineFont *sf,EncMap *map,const char *uname); diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c index 43626aec6dc..ce80d837f87 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c @@ -1377,7 +1377,7 @@ Spline *SplineAddExtrema(Spline *s,int always,real lenbound, real offsetbound, uint8 rmfrom[4], rmto[4]; int p, i,j, p_s, mini; SplinePoint *sp; - real len; + real len = 0; /* Init variable to silence compiler warnings */ if ( !always ) { real xlen, ylen; diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c index e5722cfc27d..559867543f2 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c @@ -95,6 +95,8 @@ return( false ); if ( features->ismac || OTTagToMacFeature(features->featuretag,&ft,&fs)) return( true ); } + default: /* handle this to silence compiler warnings */ + break; } return( false ); } diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h index fd2247f7e1b..cfeaf7a24d5 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h @@ -72,7 +72,3 @@ extern struct charmap2 johab_from_unicode; extern const unichar_t unicode_from_gb2312[]; extern struct charmap2 gb2312_from_unicode; -/* a mask for each character saying what charset(s) it may be found in */ -extern const unsigned long * const unicode_backtrans[]; - -extern const unichar_t *const * const unicode_alternates[]; diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h index a5e21e87dc9..22e0a55a189 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h @@ -105,7 +105,6 @@ extern char *utf8_2_latin1_copy(const char *utf8buf); extern int utf8_strlen(const char *utf8_str); /* how many characters in the string */ extern int utf82u_strlen(const char *utf8_str); /* how many long would this be in shorts (UCS2) */ extern char *def2utf8_copy(const char *from); -extern char *utf82def_copy(const char *ufrom); extern char *utf8_strchr(const char *utf8_str, int search_char); extern unichar_t *utf82u_strncpy(unichar_t *ubuf,const char *utf8buf,int len); @@ -117,11 +116,8 @@ extern char *u2utf8_strcpy(char *utf8buf,const unichar_t *ubuf); extern char *u2utf8_copy(const unichar_t *ubuf); extern char *u2utf8_copyn(const unichar_t *ubuf,int len); extern unichar_t *encoding2u_strncpy(unichar_t *uto, const char *from, int n, enum encoding cs); -extern char *u2encoding_strncpy(char *to, const unichar_t *ufrom, int n, enum encoding cs); extern unichar_t *def2u_strncpy(unichar_t *uto, const char *from, int n); -extern char *u2def_strncpy(char *to, const unichar_t *ufrom, int n); extern unichar_t *def2u_copy(const char *from); -extern char *u2def_copy(const unichar_t *ufrom); extern int u_sprintf(unichar_t *str, const unichar_t *format, ... ); extern int u_snprintf(unichar_t *str, int len, const unichar_t *format, ... ); diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c index 88757af288c..731eafe7430 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c @@ -1,3 +1,21 @@ +/* ffdummies.c + + Copyright 2006-2009 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ /* some dummy functions and variables so that a few ff source files can be ignored */ @@ -9,154 +27,195 @@ #include #include +static const char _svn_version[] = + "$Id: ffdummies.c 3360 2010-01-12 21:12:15Z hhenkel $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c $"; + char **gww_errors = NULL; int gww_error_count = 0; -void gwwv_errors_free (void) { - int i; - if (gww_error_count>0) { - for (i=0;i 0) { + for (i = 0; i < gww_error_count; i++) { + free(gww_errors[i]); + } + free(gww_errors); + gww_error_count = 0; + gww_errors = NULL; + } } - -static void LUAUI_IError(const char *format,...) { +__attribute__ ((format(printf, 1, 0))) +static void LUAUI_IError(const char *format, ...) +{ va_list ap; - va_start(ap,format); - fprintf(stderr, "Internal Error: " ); - vfprintf(stderr,format,ap); + size_t l; + char buffer[400], *str; + l = strlen("Internal Error: "); + snprintf(buffer, sizeof(buffer), "Internal Error: "); + va_start(ap, format); + vsnprintf(buffer+l, sizeof(buffer)-l, format, ap); va_end(ap); + str = xstrdup((char *) buffer); + gww_errors = realloc(gww_errors, (gww_error_count + 2) * sizeof(char *)); + if (gww_errors == NULL) { + perror("memory allocation failed"); + exit(EXIT_FAILURE); + } + gww_errors[gww_error_count] = str; + gww_error_count++; + gww_errors[gww_error_count] = NULL; } -static void LUAUI__LogError(const char *format,va_list ap) { +__attribute__ ((format(printf, 1, 0))) +static void LUAUI__LogError(const char *format, va_list ap) +{ char buffer[400], *str; - vsnprintf(buffer,sizeof(buffer),format,ap); - str = utf82def_copy(buffer); - gww_errors = realloc(gww_errors, (gww_error_count+2)*sizeof(char *)); - if (gww_errors==NULL) { - perror("memory allocation failed"); - exit(EXIT_FAILURE); + vsnprintf(buffer, sizeof(buffer), format, ap); + str = xstrdup((char *) buffer); + gww_errors = realloc(gww_errors, (gww_error_count + 2) * sizeof(char *)); + if (gww_errors == NULL) { + perror("memory allocation failed"); + exit(EXIT_FAILURE); } - gww_errors[gww_error_count ] = str ; - gww_error_count ++; - gww_errors[gww_error_count ] = NULL; + gww_errors[gww_error_count] = str; + gww_error_count++; + gww_errors[gww_error_count] = NULL; } /* this is not static because it is used by gwwiconv.c */ -void LUAUI_LogError(const char *format,...) { +__attribute__ ((format(printf, 1, 2))) +void LUAUI_LogError(const char *format, ...) +{ va_list ap; - va_start(ap,format); - LUAUI__LogError(format,ap); + va_start(ap, format); + LUAUI__LogError(format, ap); va_end(ap); } -static void LUAUI_post_notice(const char *title,const char *statement,...) { +__attribute__ ((format(printf, 2, 3))) +static void LUAUI_post_notice(const char *title, const char *statement, ...) +{ va_list ap; - (void)title; - va_start(ap,statement); - LUAUI__LogError(statement,ap); + (void) title; + va_start(ap, statement); + LUAUI__LogError(statement, ap); va_end(ap); } -static void LUAUI_post_error(const char *title,const char *statement,...) { +__attribute__ ((format(printf, 2, 3))) +static void LUAUI_post_error(const char *title, const char *statement, ...) +{ va_list ap; - (void)title; - va_start(ap,statement); - LUAUI__LogError(statement,ap); + (void) title; + va_start(ap, statement); + LUAUI__LogError(statement, ap); va_end(ap); } static int LUAUI_ask(const char *title, const char **answers, - int def, int cancel,const char *question,...) { - (void)title; - (void)answers; - (void)cancel; - (void)question; -return( def ); + int def, int cancel, const char *question, ...) +{ + (void) title; + (void) answers; + (void) cancel; + (void) question; + return (def); } -static int LUAUI_choose(const char *title, const char **choices,int cnt, int def, - const char *question,...) { - (void)title; - (void)choices; - (void)cnt; - (void)question; -return( def ); +static int LUAUI_choose(const char *title, const char **choices, int cnt, + int def, const char *question, ...) +{ + (void) title; + (void) choices; + (void) cnt; + (void) question; + return (def); } -static int LUAUI_choose_multiple(char *title, const char **choices,char *sel, - int cnt, char *buts[2], const char *question,...) { - (void)title; - (void)choices; - (void)sel; - (void)cnt; - (void)buts; - (void)question; -return( -1 ); +static int LUAUI_choose_multiple(char *title, const char **choices, char *sel, + int cnt, char *buts[2], const char *question, + ...) +{ + (void) title; + (void) choices; + (void) sel; + (void) cnt; + (void) buts; + (void) question; + return (-1); } static char *LUAUI_ask_string(const char *title, const char *def, - const char *question,...) { - (void)title; - (void)def; - (void)question; -return( (char *) def ); + const char *question, ...) +{ + (void) title; + (void) def; + (void) question; + return ((char *) def); } static char *LUAUI_open_file(const char *title, const char *defaultfile, - const char *initial_filter) { - (void)title; - (void)initial_filter; - (void)defaultfile; -return( NULL ); + const char *initial_filter) +{ + (void) title; + (void) initial_filter; + (void) defaultfile; + return (NULL); } static char *LUAUI_saveas_file(const char *title, const char *defaultfile, - const char *initial_filter) { - (void)title; - (void)initial_filter; -return( copy(defaultfile) ); + const char *initial_filter) +{ + (void) title; + (void) initial_filter; + return (copy(defaultfile)); } -static void LUAUI_progress_start(int delay, const char *title, const char *line1, - const char *line2, int tot, int stages) { - (void)delay; - (void)title; - (void)line1; - (void)line2; - (void)tot; - (void)stages; +static void LUAUI_progress_start(int delay, const char *title, + const char *line1, const char *line2, int tot, + int stages) +{ + (void) delay; + (void) title; + (void) line1; + (void) line2; + (void) tot; + (void) stages; } -static void LUAUI_void_void_noop(void) { +static void LUAUI_void_void_noop(void) +{ } -static void LUAUI_void_int_noop(int useless) { - (void)useless; +static void LUAUI_void_int_noop(int useless) +{ + (void) useless; } -static int LUAUI_int_int_noop(int useless) { - (void)useless; -return( true ); +static int LUAUI_int_int_noop(int useless) +{ + (void) useless; + return (true); } -static void LUAUI_void_str_noop(const char * useless) { - (void)useless; +static void LUAUI_void_str_noop(const char *useless) +{ + (void) useless; } -static int LUAUI_alwaystrue(void) { -return( true ); +static int LUAUI_alwaystrue(void) +{ + return (true); } -static int LUAUI_DefaultStrokeFlags(void) { -return( sf_correctdir ); +static int LUAUI_DefaultStrokeFlags(void) +{ + return (sf_correctdir); } struct ui_interface luaui_interface = { @@ -168,7 +227,7 @@ struct ui_interface luaui_interface = { LUAUI_choose, LUAUI_choose_multiple, LUAUI_ask_string, - LUAUI_ask_string, /* password */ + LUAUI_ask_string, /* password */ LUAUI_open_file, LUAUI_saveas_file, @@ -197,60 +256,71 @@ struct ui_interface luaui_interface = { /* some bits and pieces */ -int URLFromFile(char *url,FILE *from) { - (void)url; - (void)from; - return false; +int URLFromFile(char *url, FILE * from) +{ + (void) url; + (void) from; + return false; } /* print.c */ -int pagewidth = 0, pageheight=0; /* In points */ -char *printlazyprinter=NULL; -char *printcommand=NULL; +int pagewidth = 0, pageheight = 0; /* In points */ +char *printlazyprinter = NULL; +char *printcommand = NULL; int printtype = 0; -void ScriptPrint(FontViewBase *fv,int type,int32 *pointsizes,char *samplefile, - unichar_t *sample, char *outputfile) { - (void)fv; - (void)type; - (void)pointsizes; - (void)samplefile; - (void)sample; - (void)outputfile; +void ScriptPrint(FontViewBase * fv, int type, int32 * pointsizes, + char *samplefile, unichar_t * sample, char *outputfile) +{ + (void) fv; + (void) type; + (void) pointsizes; + (void) samplefile; + (void) sample; + (void) outputfile; } -int PdfDumpGlyphResources(void *pi, SplineChar *sc) { - (void)pi; - (void)sc; - return 0; +int PdfDumpGlyphResources(void *pi, SplineChar * sc) +{ + (void) pi; + (void) sc; + return 0; } /* autotrace.c */ -int autotrace_ask=0, mf_ask=0, mf_clearbackgrounds=0, mf_showerrors=0; +int autotrace_ask = 0, mf_ask = 0, mf_clearbackgrounds = 0, mf_showerrors = 0; char *mf_args = NULL; -int preferpotrace=0; +int preferpotrace = 0; -void *GetAutoTraceArgs(void) { -return NULL; +void *GetAutoTraceArgs(void) +{ + return NULL; } -void SetAutoTraceArgs(void *a) { - (void)a; +void SetAutoTraceArgs(void *a) +{ + (void) a; } -void FVAutoTrace(FontViewBase *fv,int ask) { - (void)fv; (void)ask; +void FVAutoTrace(FontViewBase * fv, int ask) +{ + (void) fv; + (void) ask; } -SplineFont *SFFromMF(char *filename) { - (void)filename; -return NULL; +SplineFont *SFFromMF(char *filename) +{ + (void) filename; + return NULL; } /* http.c */ -FILE *URLToTempFile(char *url,void *_lock) { - (void)_lock; (void)url; - ff_post_error(_("Could not parse URL"),_("FontForge only handles ftp and http URLs at the moment")); -return( NULL ); +FILE *URLToTempFile(char *url, void *_lock) +{ + (void) _lock; + (void) url; + ff_post_error(_("Could not parse URL"), + _("FontForge only handles ftp and http URLs at the moment")); + return (NULL); } diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c index 8462ae9b2e5..8b7d2bd9415 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c @@ -1,5 +1,23 @@ +/* luafflib.c + + Copyright 2007-2009 Taco Hoekwater + + This file is part of LuaTeX. + + LuaTeX is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + LuaTeX is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see . */ + /** -* $Id $ * @desc Support interface for fontforge 20070607 * @version 1.0 * @author Taco Hoekwater @@ -13,340 +31,362 @@ #include "pfaedit.h" #include "ustring.h" +static const char _svn_version[] = + "$Id: luafflib.c 3456 2010-03-07 09:12:36Z taco $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c $"; + extern char **gww_errors; extern int gww_error_count; -extern void gwwv_errors_free (void); +extern void gwwv_errors_free(void); extern struct ui_interface luaui_interface; -extern int readbinfile(FILE *f, unsigned char **b, int *s); +extern int readbinfile(FILE * f, unsigned char **b, int *s); #define FONT_METATABLE "fontloader.splinefont" #define LUA_OTF_VERSION "0.3" -static char *possub_type_enum[] = { - "null", "position", "pair", "substitution", - "alternate", "multiple", "ligature", "lcaret", - "kerning", "vkerning", "anchors", "contextpos", - "contextsub", "chainpos", "chainsub","reversesub", - "max", "kernback", "vkernback", NULL }; +static char *possub_type_enum[] = { + "null", "position", "pair", "substitution", + "alternate", "multiple", "ligature", "lcaret", + "kerning", "vkerning", "anchors", "contextpos", + "contextsub", "chainpos", "chainsub", "reversesub", + "max", "kernback", "vkernback", NULL +}; #define LAST_POSSUB_TYPE_ENUM 18 #define eight_nulls() NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL -static char *asm_type_enum[] = { - "indic", "context", "lig", NULL, "simple", "insert", NULL, NULL, - eight_nulls(), - NULL, "kern" }; - -static char *otf_lookup_type_enum[] = { - "gsub_start", "gsub_single", "gsub_multiple", "gsub_alternate", - "gsub_ligature", "gsub_context", "gsub_contextchain", NULL, - "gsub_reversecontextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*0x00F */ - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(), NULL, NULL, NULL, NULL, NULL, "morx_indic", "morx_context", "morx_insert", /* 0x0FF*/ - "gpos_start", "gpos_single", "gpos_pair", "gpos_cursive", - "gpos_mark2base", "gpos_mark2ligature", "gpos_mark2mark", "gpos_context", - "gpos_contextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 0x10F */ - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(),eight_nulls(), - eight_nulls(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, "kern_statemachine", /* 0x1FF*/ +static char *asm_type_enum[] = { + "indic", "context", "lig", NULL, "simple", "insert", NULL, NULL, + eight_nulls(), + NULL, "kern" +}; + +static char *otf_lookup_type_enum[] = { + "gsub_start", "gsub_single", "gsub_multiple", "gsub_alternate", + "gsub_ligature", "gsub_context", "gsub_contextchain", NULL, + "gsub_reversecontextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*0x00F */ + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), NULL, NULL, NULL, NULL, NULL, "morx_indic", "morx_context", "morx_insert", /* 0x0FF */ + "gpos_start", "gpos_single", "gpos_pair", "gpos_cursive", + "gpos_mark2base", "gpos_mark2ligature", "gpos_mark2mark", "gpos_context", + "gpos_contextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 0x10F */ + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), eight_nulls(), + eight_nulls(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, "kern_statemachine", /* 0x1FF */ }; -static char *anchor_type_enum[] = { - "mark", "basechar", "baselig", "basemark", "centry", "cexit", "max", NULL }; +static char *anchor_type_enum[] = { + "mark", "basechar", "baselig", "basemark", "centry", "cexit", "max", NULL +}; #define MAX_ANCHOR_TYPE 7 -static char *anchorclass_type_enum[] = { - "mark", "mkmk", "curs", "mklg", NULL }; +static char *anchorclass_type_enum[] = { + "mark", "mkmk", "curs", "mklg", NULL +}; -static char *glyph_class_enum[] = { - "automatic", "none" ,"base", "ligature","mark", "component", NULL }; +static char *glyph_class_enum[] = { + "automatic", "none", "base", "ligature", "mark", "component", NULL +}; -static char *ttfnames_enum[ttf_namemax] = { +static char *ttfnames_enum[ttf_namemax] = { "copyright", "family", "subfamily", "uniqueid", "fullname", "version", "postscriptname", "trademark", "manufacturer", "designer", "descriptor", "venderurl", "designerurl", "license", "licenseurl", "idontknow", "preffamilyname", "prefmodifiers", "compatfull", "sampletext", - "cidfindfontname", "wwsfamily", "wwssubfamily" }; + "cidfindfontname", "wwsfamily", "wwssubfamily" +}; -static char *fpossub_format_enum [] = { - "glyphs", "class","coverage","reversecoverage" , NULL}; +static char *fpossub_format_enum[] = { + "glyphs", "class", "coverage", "reversecoverage", NULL +}; -static char *tex_type_enum[4] = { "unset", "text", "math", "mathext"}; +static char *tex_type_enum[4] = { "unset", "text", "math", "mathext" }; /* has an offset of 1, ui_none = 0. */ static char *uni_interp_enum[9] = { - "unset", "none", "adobe", "greek", "japanese", - "trad_chinese", "simp_chinese", "korean", "ams" }; - + "unset", "none", "adobe", "greek", "japanese", + "trad_chinese", "simp_chinese", "korean", "ams" +}; + #define check_isfont(L,b) (SplineFont **)luaL_checkudata(L,b,FONT_METATABLE) -void handle_generic_pst (lua_State *L, struct generic_pst *pst); /* forward */ -void handle_generic_fpst (lua_State *L, struct generic_fpst *fpst); /* forward */ -void handle_generic_asm (lua_State *L, struct generic_asm *sm) ; -void handle_kernclass (lua_State *L, struct kernclass *kerns); -void handle_anchorclass (lua_State *L, struct anchorclass *anchor); -void handle_splinefont(lua_State *L, struct splinefont *sf) ; +void handle_generic_pst(lua_State * L, struct generic_pst *pst); /* forward */ +void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst); /* forward */ +void handle_generic_asm(lua_State * L, struct generic_asm *sm); +void handle_kernclass(lua_State * L, struct kernclass *kerns); +void handle_anchorclass(lua_State * L, struct anchorclass *anchor); +void handle_splinefont(lua_State * L, struct splinefont *sf); + + +void lua_ff_pushfont(lua_State * L, SplineFont * sf) +{ + SplineFont **a; + if (sf == NULL) { + lua_pushnil(L); + } else { + a = lua_newuserdata(L, sizeof(SplineFont *)); + *a = sf; + luaL_getmetatable(L, FONT_METATABLE); + lua_setmetatable(L, -2); + } + return; +} -void -lua_ff_pushfont(lua_State *L, SplineFont *sf) { - SplineFont **a; - if (sf==NULL) { - lua_pushnil(L); - } else { - a = lua_newuserdata(L,sizeof(SplineFont *)); - *a = sf; - luaL_getmetatable(L,FONT_METATABLE); - lua_setmetatable(L,-2); - } - return; -} - - -static int -ff_open (lua_State *L) { - SplineFont *sf; - const char *fontname; - FILE *l; - char s[511]; - size_t len; - int args,i ; - int openflags = 1; - fontname = luaL_checkstring(L,1); - /* test fontname for existance */ - if ((l = fopen(fontname,"r"))) { - fclose(l); - } else { - lua_pushfstring(L,"font loading failed for %s (read error)\n", fontname); - lua_error(L); - } - args = lua_gettop(L); - if (args>=2 && lua_isstring(L,2)) { - if (*(fontname+strlen(fontname))!=')') { - /* possibly fails for embedded parens in the font name */ - snprintf(s,511,"%s(%s)", fontname, lua_tolstring(L,2,&len)); - if (len==0) { - snprintf(s,511,"%s", fontname); - } - } - } else { - snprintf(s,511,"%s", fontname); - } - if (strlen(s)>0) { - gww_error_count=0; - sf = ReadSplineFont((char *)s,openflags); - if (sf==NULL) { - lua_pushfstring(L,"font loading failed for %s\n", s); - if (gww_error_count>0) { - for (i=0;i0) { - lua_newtable(L); - for (i=0;imap); - - return 0; -} - - - -static void -dump_intfield (lua_State *L, char *name, long int field) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushnumber(L,field); - lua_rawset(L,-3); -} - -static void -dump_realfield (lua_State *L, char *name, real field) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushnumber(L,field); - lua_rawset(L,-3); +static int ff_open(lua_State * L) +{ + SplineFont *sf; + const char *fontname; + FILE *l; + char s[511]; + size_t len; + int args, i; + int openflags = 1; + fontname = luaL_checkstring(L, 1); + /* test fontname for existance */ + if ((l = fopen(fontname, "r"))) { + fclose(l); + } else { + lua_pushnil(L); + lua_pushfstring(L, "font loading failed for %s (read error)\n", + fontname); + return 2; + } + args = lua_gettop(L); + if (args >= 2 && lua_isstring(L, 2)) { + if (*(fontname + strlen(fontname)) != ')') { + /* possibly fails for embedded parens in the font name */ + snprintf(s, 511, "%s(%s)", fontname, lua_tolstring(L, 2, &len)); + if (len == 0) { + snprintf(s, 511, "%s", fontname); + } + } + } else { + snprintf(s, 511, "%s", fontname); + } + if (strlen(s) > 0) { + gww_error_count = 0; + sf = ReadSplineFont((char *) s, openflags); + if (sf == NULL) { + lua_pushnil(L); + lua_pushfstring(L, "font loading failed for %s\n", s); + if (gww_error_count > 0) { + for (i = 0; i < gww_error_count; i++) { + lua_pushstring(L, gww_errors[i]); + lua_concat(L, 2); + } + gwwv_errors_free(); + } + } else { + FVAppend(_FontViewCreate(sf)); + lua_ff_pushfont(L, sf); + if (gww_error_count > 0) { + lua_newtable(L); + for (i = 0; i < gww_error_count; i++) { + lua_pushstring(L, gww_errors[i]); + lua_rawseti(L, -2, (i + 1)); + } + gwwv_errors_free(); + } else { + lua_pushnil(L); + } + } + } else { + lua_pushnil(L); + lua_pushfstring(L, "font loading failed: empty string given\n", + fontname); + } + return 2; +} + + +static int ff_close(lua_State * L) +{ + SplineFont **sf; + /*fputs("ff_close called",stderr); */ + sf = check_isfont(L, 1); + if (*sf != NULL) { + if ((*sf)->fv) { // condition might be improved + FontViewClose((*sf)->fv); + } else { + EncMapFree((*sf)->map); + SplineFontFree(*sf); + } + *sf = NULL; + } + return 0; +} + +static int ff_apply_featurefile(lua_State * L) +{ + SplineFont **sf; + char *fname; + sf = check_isfont(L, 1); + fname = (char *) luaL_checkstring(L, 2); + SFApplyFeatureFilename(*sf, fname); + return 0; +} + +static int ff_apply_afmfile(lua_State * L) +{ + SplineFont **sf; + char *fname; + sf = check_isfont(L, 1); + fname = (char *) luaL_checkstring(L, 2); + CheckAfmOfPostscript(*sf, fname, (*sf)->map); + + return 0; +} + + + +static void dump_intfield(lua_State * L, char *name, long int field) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushnumber(L, field); + lua_rawset(L, -3); +} + +static void dump_realfield(lua_State * L, char *name, real field) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushnumber(L, field); + lua_rawset(L, -3); } #define dump_cond_intfield(a,b,c) if ((c)!=0) { dump_intfield ((a),(b),(c)); } -static void -dump_stringfield (lua_State *L, char *name, char *field) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushstring(L,field); - lua_rawset(L,-3); +static void dump_stringfield(lua_State * L, char *name, char *field) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushstring(L, field); + lua_rawset(L, -3); } -static void -dump_char_ref (lua_State *L, struct splinechar *spchar) { - lua_checkstack(L,2); - lua_pushstring(L,"char"); - lua_pushstring(L,spchar->name); - lua_rawset(L,-3); +static void dump_char_ref(lua_State * L, struct splinechar *spchar) +{ + lua_checkstack(L, 2); + lua_pushstring(L, "char"); + lua_pushstring(L, spchar->name); + lua_rawset(L, -3); } -static void -dump_lstringfield (lua_State *L, char *name, char *field, int len) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushlstring(L,field,len); - lua_rawset(L,-3); +static void dump_lstringfield(lua_State * L, char *name, char *field, int len) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushlstring(L, field, len); + lua_rawset(L, -3); } -static void -dump_enumfield (lua_State *L, char *name, int fid, char **fields) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushstring(L,fields[fid]); - lua_rawset(L,-3); +static void dump_enumfield(lua_State * L, char *name, int fid, char **fields) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushstring(L, fields[fid]); + lua_rawset(L, -3); } -static void -dump_floatfield (lua_State *L, char *name, double field) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushnumber(L,field); - lua_rawset(L,-3); +static void dump_floatfield(lua_State * L, char *name, double field) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushnumber(L, field); + lua_rawset(L, -3); } -static char tag_string [5] = {0}; +static char tag_string[5] = { 0 }; -static char *make_tag_string (unsigned int field) { - tag_string[0] = (field&0xFF000000) >> 24; - tag_string[1] = (field&0x00FF0000) >> 16; - tag_string[2] = (field&0x0000FF00) >> 8; - tag_string[3] = (field&0x000000FF); - return (char *)tag_string; +static char *make_tag_string(unsigned int field) +{ + tag_string[0] = (field & 0xFF000000) >> 24; + tag_string[1] = (field & 0x00FF0000) >> 16; + tag_string[2] = (field & 0x0000FF00) >> 8; + tag_string[3] = (field & 0x000000FF); + return (char *) tag_string; } -static char featbuf[32] = {0}; +static char featbuf[32] = { 0 }; -static char *make_mactag_string (unsigned int field) { - sprintf( featbuf, "<%d,%d>", field>>16, field&0xffff ); - return (char *)featbuf; +static char *make_mactag_string(unsigned int field) +{ + sprintf(featbuf, "<%d,%d>", field >> 16, field & 0xffff); + return (char *) featbuf; } -static void -dump_tag (lua_State *L, char *name, unsigned int field) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushlstring(L,make_tag_string(field),4); - lua_rawset(L,-3); +static void dump_tag(lua_State * L, char *name, unsigned int field) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushlstring(L, make_tag_string(field), 4); + lua_rawset(L, -3); } -static void -dump_mactag (lua_State *L, char *name, unsigned int field) { - lua_checkstack(L,2); - lua_pushstring(L,name); - lua_pushstring(L,make_mactag_string(field)); - lua_rawset(L,-3); +static void dump_mactag(lua_State * L, char *name, unsigned int field) +{ + lua_checkstack(L, 2); + lua_pushstring(L, name); + lua_pushstring(L, make_mactag_string(field)); + lua_rawset(L, -3); } -void -dump_subtable_name (lua_State *L, char *name, struct lookup_subtable *s) { - /* this is likely a backref */ - if (s==NULL) - return; - lua_checkstack(L,2); - if (s->next == NULL) { - dump_stringfield(L,name,s->subtable_name); - } else { - /* can this really happen ? */ - int i = 0; - lua_newtable(L); - while (s!=NULL) { - lua_pushstring(L, s->subtable_name); - lua_rawseti(L, -2, ++i); - s = s->next; +void dump_subtable_name(lua_State * L, char *name, struct lookup_subtable *s) +{ + /* this is likely a backref */ + if (s == NULL) + return; + lua_checkstack(L, 2); + if (s->next == NULL) { + dump_stringfield(L, name, s->subtable_name); + } else { + /* can this really happen ? */ + int i = 0; + lua_newtable(L); + while (s != NULL) { + lua_pushstring(L, s->subtable_name); + lua_rawseti(L, -2, ++i); + s = s->next; + } + lua_setfield(L, -2, name); } - lua_setfield(L, -2, name); - } } @@ -363,188 +403,221 @@ dump_subtable_name (lua_State *L, char *name, struct lookup_subtable *s) { next = next->next; \ } } -void -do_handle_scriptlanglist (lua_State *L, struct scriptlanglist *sl) { - int k; - dump_tag(L,"script", sl->script); - - lua_checkstack(L,3); - lua_newtable(L); - for (k=0;klangs[k] != 0) { - lua_pushnumber(L,(k+1)); - lua_pushstring(L,make_tag_string(sl->langs[k])); - lua_rawset(L,-3); - } - } - - if (sl->lang_cnt>=MAX_LANG) { - for (k=MAX_LANG;klang_cnt;k++) { - lua_pushnumber(L,(k+1)); - lua_pushstring(L,make_tag_string(sl->morelangs[k-MAX_LANG])); - lua_rawset(L,-3); - } - } - lua_setfield(L,-2,"langs"); -} +#define NESTED_TABLE_SF(a,b,c,d) { \ + int k = 1; \ + next = b; \ + while (next != NULL) { \ + lua_checkstack(L,2); \ + lua_pushnumber(L,k); k++; \ + lua_createtable(L,0,d); \ + a(L, next, c); \ + lua_rawset(L,-3); \ + next = next->next; \ + } } -void -handle_scriptlanglist (lua_State *L, struct scriptlanglist *sll) { - struct scriptlanglist *next; - NESTED_TABLE(do_handle_scriptlanglist,sll,4); + +void do_handle_scriptlanglist(lua_State * L, struct scriptlanglist *sl) +{ + int k; + dump_tag(L, "script", sl->script); + + lua_checkstack(L, 3); + lua_newtable(L); + for (k = 0; k < MAX_LANG; k++) { + if (sl->langs[k] != 0) { + lua_pushnumber(L, (k + 1)); + lua_pushstring(L, make_tag_string(sl->langs[k])); + lua_rawset(L, -3); + } + } + + if (sl->lang_cnt >= MAX_LANG) { + for (k = MAX_LANG; k < sl->lang_cnt; k++) { + lua_pushnumber(L, (k + 1)); + lua_pushstring(L, make_tag_string(sl->morelangs[k - MAX_LANG])); + lua_rawset(L, -3); + } + } + lua_setfield(L, -2, "langs"); } -void -do_handle_featurescriptlanglist (lua_State *L, struct featurescriptlanglist *features) { - if (features->ismac) { - dump_mactag (L,"tag",features->featuretag); - } else { - dump_tag (L,"tag",features->featuretag); - } - lua_newtable(L); - handle_scriptlanglist(L, features->scripts); - lua_setfield(L,-2,"scripts"); - dump_cond_intfield (L,"ismac",features->ismac); -} +void handle_scriptlanglist(lua_State * L, struct scriptlanglist *sll) +{ + struct scriptlanglist *next; + NESTED_TABLE(do_handle_scriptlanglist, sll, 4); +} void -handle_featurescriptlanglist (lua_State *L, struct featurescriptlanglist *features) { - struct featurescriptlanglist *next; - NESTED_TABLE(do_handle_featurescriptlanglist,features,3); +do_handle_featurescriptlanglist(lua_State * L, + struct featurescriptlanglist *features) +{ + if (features->ismac) { + dump_mactag(L, "tag", features->featuretag); + } else { + dump_tag(L, "tag", features->featuretag); + } + lua_newtable(L); + handle_scriptlanglist(L, features->scripts); + lua_setfield(L, -2, "scripts"); + dump_cond_intfield(L, "ismac", features->ismac); } -void -do_handle_lookup_subtable (lua_State *L, struct lookup_subtable *subtable) { +void +handle_featurescriptlanglist(lua_State * L, + struct featurescriptlanglist *features) +{ + struct featurescriptlanglist *next; + NESTED_TABLE(do_handle_featurescriptlanglist, features, 3); +} - dump_stringfield(L,"name", subtable->subtable_name); - dump_stringfield(L,"suffix", subtable->suffix); +void do_handle_lookup_subtable(lua_State * L, struct lookup_subtable *subtable) +{ - /* struct otlookup *lookup; */ /* this is the parent */ + dump_stringfield(L, "name", subtable->subtable_name); + dump_stringfield(L, "suffix", subtable->suffix); - /* dump_intfield (L,"unused", subtable->unused); */ - /* The next one is true if there is no fpst, false otherwise */ - /* - dump_intfield (L,"per_glyph_pst_or_kern",subtable->per_glyph_pst_or_kern); - */ - dump_cond_intfield (L,"anchor_classes", subtable->anchor_classes); - dump_cond_intfield (L,"vertical_kerning", subtable->vertical_kerning); + /* struct otlookup *lookup; *//* this is the parent */ - if (subtable->kc != NULL) { - lua_newtable(L); - handle_kernclass(L, subtable->kc); - lua_setfield(L,-2, "kernclass"); - } + /* dump_intfield (L,"unused", subtable->unused); */ + /* The next one is true if there is no fpst, false otherwise */ + /* + dump_intfield (L,"per_glyph_pst_or_kern",subtable->per_glyph_pst_or_kern); + */ + dump_cond_intfield(L, "anchor_classes", subtable->anchor_classes); + dump_cond_intfield(L, "vertical_kerning", subtable->vertical_kerning); + if (subtable->kc != NULL) { + lua_newtable(L); + handle_kernclass(L, subtable->kc); + lua_setfield(L, -2, "kernclass"); + } #if 0 - if (subtable->fpst != NULL) { - /* lua_newtable(L); */ - handle_generic_fpst(L, subtable->fpst); - /* lua_setfield(L,-2, "fpst"); */ - } + if (subtable->fpst != NULL) { + /* lua_newtable(L); */ + handle_generic_fpst(L, subtable->fpst); + /* lua_setfield(L,-2, "fpst"); */ + } #endif - if (subtable->sm != NULL) { - lua_newtable(L); - handle_generic_asm(L, subtable->sm); - lua_setfield(L,-2, "sm"); - } - /* int subtable_offset; */ /* used by OTF file generation */ - /* int32 *extra_subtables; */ /* used by OTF file generation */ + if (subtable->sm != NULL) { + lua_newtable(L); + handle_generic_asm(L, subtable->sm); + lua_setfield(L, -2, "sm"); + } + /* int subtable_offset; *//* used by OTF file generation */ + /* int32 *extra_subtables; *//* used by OTF file generation */ } -void -handle_lookup_subtable (lua_State *L, struct lookup_subtable *subtable) { - struct lookup_subtable *next; - NESTED_TABLE(do_handle_lookup_subtable,subtable,2); +void handle_lookup_subtable(lua_State * L, struct lookup_subtable *subtable) +{ + struct lookup_subtable *next; + NESTED_TABLE(do_handle_lookup_subtable, subtable, 2); } -void -do_handle_lookup (lua_State *L, struct otlookup *lookup ) { +void do_handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont * sf) +{ + int mc; + + dump_enumfield(L, "type", lookup->lookup_type, otf_lookup_type_enum); + + lua_newtable(L); + if (lookup->lookup_flags & pst_r2l) { + lua_pushstring(L, "r2l"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + if (lookup->lookup_flags & pst_ignorebaseglyphs) { + lua_pushstring(L, "ignorebaseglyphs"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + if (lookup->lookup_flags & pst_ignoreligatures) { + lua_pushstring(L, "ignoreligatures"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + if (lookup->lookup_flags & pst_ignorecombiningmarks) { + lua_pushstring(L, "ignorecombiningmarks"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + mc = (lookup->lookup_flags >> 8); + if (mc > 0 && mc < sf->mark_class_cnt && sf->mark_class_names[mc] != NULL) { + lua_pushstring(L, "mark_class"); + lua_pushstring(L, sf->mark_class_names[mc]); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "flags"); - dump_enumfield (L,"type", lookup->lookup_type, otf_lookup_type_enum); - lua_newtable(L); - if (lookup->lookup_flags & pst_r2l) { - lua_pushstring(L,"r2l"); lua_pushboolean(L,1); lua_rawset(L,-3); - } - if (lookup->lookup_flags & pst_ignorebaseglyphs) { - lua_pushstring(L,"ignorebaseglyphs"); lua_pushboolean(L,1); lua_rawset(L,-3); - } - if (lookup->lookup_flags & pst_ignoreligatures) { - lua_pushstring(L,"ignoreligatures"); lua_pushboolean(L,1); lua_rawset(L,-3); - } - if (lookup->lookup_flags & pst_ignorecombiningmarks) { - lua_pushstring(L,"ignorecombiningmarks"); lua_pushboolean(L,1); lua_rawset(L,-3); - } - lua_setfield(L,-2,"flags"); + dump_stringfield(L, "name", lookup->lookup_name); - dump_stringfield (L,"name", lookup->lookup_name); + if (lookup->features != NULL) { + lua_newtable(L); + handle_featurescriptlanglist(L, lookup->features); + lua_setfield(L, -2, "features"); + } - if (lookup->features != NULL) { - lua_newtable(L); - handle_featurescriptlanglist(L,lookup->features); - lua_setfield(L,-2,"features"); - } + if (lookup->subtables != NULL) { + lua_newtable(L); + handle_lookup_subtable(L, lookup->subtables); + lua_setfield(L, -2, "subtables"); + } - if (lookup->subtables != NULL) { - lua_newtable(L); - handle_lookup_subtable(L,lookup->subtables); - lua_setfield(L,-2,"subtables"); - } - - /* dump_intfield (L,"unused", lookup->unused); */ - /* dump_intfield (L,"empty", lookup->empty); */ - /* dump_intfield (L,"store_in_afm", lookup->store_in_afm); */ - /* dump_intfield (L,"needs_extension", lookup->needs_extension); */ - /* dump_intfield (L,"temporary_kern", lookup->temporary_kern); */ - /* dump_intfield (L,"def_lang_checked", lookup->def_lang_checked); */ - /* dump_intfield (L,"def_lang_found", lookup->def_lang_found); */ - /* dump_intfield (L,"ticked", lookup->ticked); */ - /* dump_intfield (L,"subcnt", lookup->subcnt); */ - /* dump_intfield (L,"lookup_index", lookup->lookup_index); */ /* identical to array index */ - /* dump_intfield (L,"lookup_offset", lookup->lookup_offset); */ - /* dump_intfield (L,"lookup_length", lookup->lookup_length); */ - /* dump_stringfield(L,"tempname", lookup->tempname); */ + /* dump_intfield (L,"unused", lookup->unused); */ + /* dump_intfield (L,"empty", lookup->empty); */ + /* dump_intfield (L,"store_in_afm", lookup->store_in_afm); */ + /* dump_intfield (L,"needs_extension", lookup->needs_extension); */ + /* dump_intfield (L,"temporary_kern", lookup->temporary_kern); */ + /* dump_intfield (L,"def_lang_checked", lookup->def_lang_checked); */ + /* dump_intfield (L,"def_lang_found", lookup->def_lang_found); */ + /* dump_intfield (L,"ticked", lookup->ticked); */ + /* dump_intfield (L,"subcnt", lookup->subcnt); */ + /* dump_intfield (L,"lookup_index", lookup->lookup_index); *//* identical to array index */ + /* dump_intfield (L,"lookup_offset", lookup->lookup_offset); */ + /* dump_intfield (L,"lookup_length", lookup->lookup_length); */ + /* dump_stringfield(L,"tempname", lookup->tempname); */ } -void -handle_lookup (lua_State *L, struct otlookup *lookup ) { - struct otlookup *next; - NESTED_TABLE(do_handle_lookup,lookup,18); /* 18 is a guess */ +void handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont * sf) +{ + struct otlookup *next; + NESTED_TABLE_SF(do_handle_lookup, lookup, sf, 18); /* 18 is a guess */ } -void -do_handle_kernpair (lua_State *L, struct kernpair *kp) { +void do_handle_kernpair(lua_State * L, struct kernpair *kp) +{ - if (kp->sc != NULL) - dump_char_ref(L, kp->sc); - dump_intfield(L,"off", kp->off); - /* uint16 kcid; */ /* temporary value */ - dump_subtable_name(L, "lookup", kp->subtable); + if (kp->sc != NULL) + dump_char_ref(L, kp->sc); + dump_intfield(L, "off", kp->off); + /* uint16 kcid; *//* temporary value */ + dump_subtable_name(L, "lookup", kp->subtable); } -void -handle_kernpair (lua_State *L, struct kernpair *kp) { - struct kernpair *next; - NESTED_TABLE(do_handle_kernpair,kp,4); +void handle_kernpair(lua_State * L, struct kernpair *kp) +{ + struct kernpair *next; + NESTED_TABLE(do_handle_kernpair, kp, 4); } -void -handle_splinecharlist (lua_State *L, struct splinecharlist *scl) { +void handle_splinecharlist(lua_State * L, struct splinecharlist *scl) +{ - struct splinecharlist *next = scl; - int k = 1; - lua_checkstack(L,10); - while( next != NULL) { - if (next->sc != NULL) { - lua_pushnumber(L,k); k++; - lua_pushstring(L,next->sc->name); - lua_rawset(L,-3); + struct splinecharlist *next = scl; + int k = 1; + lua_checkstack(L, 10); + while (next != NULL) { + if (next->sc != NULL) { + lua_pushnumber(L, k); + k++; + lua_pushstring(L, next->sc->name); + lua_rawset(L, -3); + } + next = next->next; } - next = next->next; - } } @@ -556,750 +629,801 @@ handle_splinecharlist (lua_State *L, struct splinecharlist *scl) { /* variant shape. The specifics depend on the selector and script */ /* fid is currently unused, but may, someday, be used to do ttcs */ /* NOTE: GlyphInfo displays vs==-1 as vs==0, and fixes things up */ -void -handle_altuni (lua_State *L, struct altuni *au) { - struct altuni *next = au; - int k = 1; - lua_checkstack(L,3); - while( next != NULL) { - lua_newtable(L); - dump_intfield(L, "unicode", next->unienc); - if (next->vs != -1) - dump_intfield(L, "variant", next->vs); - /* dump_intfield(L, "fid", next->fid); */ - lua_rawseti(L, -2, k++); - next = next->next; - } +void handle_altuni(lua_State * L, struct altuni *au) +{ + struct altuni *next = au; + int k = 1; + lua_checkstack(L, 3); + while (next != NULL) { + lua_newtable(L); + dump_intfield(L, "unicode", next->unienc); + if (next->vs != -1) + dump_intfield(L, "variant", next->vs); + /* dump_intfield(L, "fid", next->fid); */ + lua_rawseti(L, -2, k++); + next = next->next; + } } #define interesting_vr(a) (((a)->xoff!=0) || ((a)->yoff!=0) || ((a)->h_adv_off!=0) || ((a)->v_adv_off!=0)) -void handle_vr (lua_State *L, struct vr *pos) { +void handle_vr(lua_State * L, struct vr *pos) +{ - dump_cond_intfield(L,"x", pos->xoff); - dump_cond_intfield(L,"y", pos->yoff); - dump_cond_intfield(L,"h", pos->h_adv_off); - dump_cond_intfield(L,"v", pos->v_adv_off); + dump_cond_intfield(L, "x", pos->xoff); + dump_cond_intfield(L, "y", pos->yoff); + dump_cond_intfield(L, "h", pos->h_adv_off); + dump_cond_intfield(L, "v", pos->v_adv_off); } -void -do_handle_generic_pst (lua_State *L, struct generic_pst *pst) { - int k; - if (pst->type>LAST_POSSUB_TYPE_ENUM) { - dump_tag(L,"type", pst->type); - } else { - dump_enumfield(L,"type", pst->type, possub_type_enum); - } - /* unsigned int ticked: 1;*/ - /* unsigned int temporary: 1;*/ /* Used in afm ligature closure */ - /* struct lookup_subtable *subtable; */ /* handled by caller */ - - lua_checkstack(L,4); - lua_pushstring(L,"specification"); - lua_createtable(L,0,4); - if (pst->type == pst_position) { - handle_vr (L, &pst->u.pos); - } else if (pst->type == pst_pair) { - dump_stringfield(L,"paired",pst->u.pair.paired); - if (pst->u.pair.vr != NULL) { - lua_pushstring(L,"offsets"); - lua_createtable(L,2,0); - if (interesting_vr(pst->u.pair.vr)) { - lua_createtable(L,0,4); - handle_vr (L, pst->u.pair.vr); - lua_rawseti(L,-2,1); - } - if (interesting_vr(pst->u.pair.vr+1)) { - lua_createtable(L,0,4); - handle_vr (L, pst->u.pair.vr+1); - lua_rawseti(L,-2,2); - } - lua_rawset(L,-3); - } - } else if (pst->type == pst_substitution) { - dump_stringfield(L,"variant",pst->u.subs.variant); - } else if (pst->type == pst_alternate) { - dump_stringfield(L,"components",pst->u.mult.components); - } else if (pst->type == pst_multiple) { - dump_stringfield(L,"components",pst->u.alt.components); - } else if (pst->type == pst_ligature) { - dump_stringfield(L,"components",pst->u.lig.components); - if (pst->u.lig.lig != NULL) { - dump_char_ref(L,pst->u.lig.lig); - } - } else if (pst->type == pst_lcaret) { - for (k=0;ku.lcaret.cnt;k++) { - lua_pushnumber(L,(k+1)); - lua_pushnumber(L,pst->u.lcaret.carets[k]); - lua_rawset(L,-3); - } - } - lua_rawset(L,-3); +void do_handle_generic_pst(lua_State * L, struct generic_pst *pst) +{ + int k; + if (pst->type > LAST_POSSUB_TYPE_ENUM) { + dump_tag(L, "type", pst->type); + } else { + dump_enumfield(L, "type", pst->type, possub_type_enum); + } + /* unsigned int ticked: 1; */ + /* unsigned int temporary: 1; *//* Used in afm ligature closure */ + /* struct lookup_subtable *subtable; *//* handled by caller */ + + lua_checkstack(L, 4); + lua_pushstring(L, "specification"); + lua_createtable(L, 0, 4); + if (pst->type == pst_position) { + handle_vr(L, &pst->u.pos); + } else if (pst->type == pst_pair) { + dump_stringfield(L, "paired", pst->u.pair.paired); + if (pst->u.pair.vr != NULL) { + lua_pushstring(L, "offsets"); + lua_createtable(L, 2, 0); + if (interesting_vr(pst->u.pair.vr)) { + lua_createtable(L, 0, 4); + handle_vr(L, pst->u.pair.vr); + lua_rawseti(L, -2, 1); + } + if (interesting_vr(pst->u.pair.vr + 1)) { + lua_createtable(L, 0, 4); + handle_vr(L, pst->u.pair.vr + 1); + lua_rawseti(L, -2, 2); + } + lua_rawset(L, -3); + } + } else if (pst->type == pst_substitution) { + dump_stringfield(L, "variant", pst->u.subs.variant); + } else if (pst->type == pst_alternate) { + dump_stringfield(L, "components", pst->u.mult.components); + } else if (pst->type == pst_multiple) { + dump_stringfield(L, "components", pst->u.alt.components); + } else if (pst->type == pst_ligature) { + dump_stringfield(L, "components", pst->u.lig.components); + if (pst->u.lig.lig != NULL) { + dump_char_ref(L, pst->u.lig.lig); + } + } else if (pst->type == pst_lcaret) { + for (k = 0; k < pst->u.lcaret.cnt; k++) { + lua_pushnumber(L, (k + 1)); + lua_pushnumber(L, pst->u.lcaret.carets[k]); + lua_rawset(L, -3); + } + } + lua_rawset(L, -3); } -void -handle_generic_pst (lua_State *L, struct generic_pst *pst) { - struct generic_pst *next; - int k; - int l = 1; - next = pst; - /* most likely everything arrives in proper order. But to prevent - * surprises, better do this is the proper way - */ - while (next != NULL) { - if (next->subtable !=NULL && - next->subtable->subtable_name !=NULL) { - lua_checkstack(L,3); /* just in case */ - lua_getfield(L,-1,next->subtable->subtable_name); - if (!lua_istable(L,-1)) { - lua_pop(L,1); - lua_newtable(L); - lua_setfield(L,-2,next->subtable->subtable_name); - lua_getfield(L,-1,next->subtable->subtable_name); - } - k = lua_objlen(L,-1) + 1; - lua_pushnumber(L,k); - lua_createtable(L,0,4); - do_handle_generic_pst(L, next); - lua_rawset(L,-3); - next = next->next; - lua_pop(L,1); /* pop the subtable */ - } else { - /* Found a pst without subtable, or without subtable name */ - lua_pushnumber(L,l); l++; - lua_createtable(L,0,4); - do_handle_generic_pst(L, next); - lua_rawset(L,-3); - next = next->next; - } - } +void handle_generic_pst(lua_State * L, struct generic_pst *pst) +{ + struct generic_pst *next; + int k; + int l = 1; + next = pst; + /* most likely everything arrives in proper order. But to prevent + * surprises, better do this is the proper way + */ + while (next != NULL) { + if (next->subtable != NULL && next->subtable->subtable_name != NULL) { + lua_checkstack(L, 3); /* just in case */ + lua_getfield(L, -1, next->subtable->subtable_name); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_newtable(L); + lua_setfield(L, -2, next->subtable->subtable_name); + lua_getfield(L, -1, next->subtable->subtable_name); + } + k = lua_objlen(L, -1) + 1; + lua_pushnumber(L, k); + lua_createtable(L, 0, 4); + do_handle_generic_pst(L, next); + lua_rawset(L, -3); + next = next->next; + lua_pop(L, 1); /* pop the subtable */ + } else { + /* Found a pst without subtable, or without subtable name */ + lua_pushnumber(L, l); + l++; + lua_createtable(L, 0, 4); + do_handle_generic_pst(L, next); + lua_rawset(L, -3); + next = next->next; + } + } } -void -do_handle_liglist (lua_State *L, struct liglist *ligofme) { - lua_checkstack(L,2); - if(ligofme->lig != NULL) { - lua_createtable(L,0,6); - handle_generic_pst (L,ligofme->lig); - lua_setfield(L,-2,"lig"); - } - dump_char_ref(L,ligofme->first); - if (ligofme->components != NULL) { - lua_newtable(L); - handle_splinecharlist (L,ligofme->components); - lua_setfield(L,-2,"components"); - } - dump_intfield(L,"ccnt",ligofme->ccnt); +void do_handle_liglist(lua_State * L, struct liglist *ligofme) +{ + lua_checkstack(L, 2); + if (ligofme->lig != NULL) { + lua_createtable(L, 0, 6); + handle_generic_pst(L, ligofme->lig); + lua_setfield(L, -2, "lig"); + } + dump_char_ref(L, ligofme->first); + if (ligofme->components != NULL) { + lua_newtable(L); + handle_splinecharlist(L, ligofme->components); + lua_setfield(L, -2, "components"); + } + dump_intfield(L, "ccnt", ligofme->ccnt); } -void -handle_liglist (lua_State *L, struct liglist *ligofme) { - struct liglist *next; - NESTED_TABLE(do_handle_liglist,ligofme,3); +void handle_liglist(lua_State * L, struct liglist *ligofme) +{ + struct liglist *next; + NESTED_TABLE(do_handle_liglist, ligofme, 3); } -void -do_handle_anchorpoint (lua_State *L, struct anchorpoint *anchor) { +void do_handle_anchorpoint(lua_State * L, struct anchorpoint *anchor) +{ - if (anchor->anchor==NULL) { - return; - } - if (anchor->type>=0 && anchor->type <= MAX_ANCHOR_TYPE ) { - lua_pushstring(L,anchor_type_enum[anchor->type]); - } else { - lua_pushstring(L,"Anchorpoint has an unknown type!"); - lua_error(L); - } - /* unsigned int selected: 1; */ - /* unsigned int ticked: 1; */ - - lua_rawget(L,-2); - if (!lua_istable(L,-1)) { - /* create the table first */ - lua_pop(L,1); - lua_pushstring(L,anchor_type_enum[anchor->type]); - lua_pushvalue(L,-1); - lua_newtable(L); - lua_rawset(L,-4); - lua_rawget(L,-2); - } - /* now the 'type' table is top of stack */ - if (anchor->type==at_baselig) { - lua_pushstring(L,anchor->anchor->name); - lua_rawget(L,-2); - if (!lua_istable(L,-1)) { - /* create the table first */ - lua_pop(L,1); - lua_pushstring(L,anchor->anchor->name); - lua_pushvalue(L,-1); - lua_newtable(L); - lua_rawset(L,-4); - lua_rawget(L,-2); + if (anchor->anchor == NULL) { + return; } - lua_newtable(L); - dump_intfield(L,"x", anchor->me.x); - dump_intfield(L,"y", anchor->me.y); - if (anchor->has_ttf_pt) - dump_intfield(L,"ttf_pt_index", anchor->ttf_pt_index); - dump_intfield(L,"lig_index", anchor->lig_index); - lua_rawseti(L,-2,(anchor->lig_index+1)); - lua_pop(L,1); - } else { - lua_pushstring(L,anchor->anchor->name); - lua_newtable(L); - dump_intfield(L,"x", anchor->me.x); - dump_intfield(L,"y", anchor->me.y); - if (anchor->has_ttf_pt) - dump_intfield(L,"ttf_pt_index", anchor->ttf_pt_index); - dump_intfield(L,"lig_index", anchor->lig_index); - lua_rawset(L,-3); - } - lua_pop(L,1); + if (anchor->type >= 0 && anchor->type <= MAX_ANCHOR_TYPE) { + lua_pushstring(L, anchor_type_enum[anchor->type]); + } else { + lua_pushstring(L, "Anchorpoint has an unknown type!"); + lua_error(L); + } + /* unsigned int selected: 1; */ + /* unsigned int ticked: 1; */ + + lua_rawget(L, -2); + if (!lua_istable(L, -1)) { + /* create the table first */ + lua_pop(L, 1); + lua_pushstring(L, anchor_type_enum[anchor->type]); + lua_pushvalue(L, -1); + lua_newtable(L); + lua_rawset(L, -4); + lua_rawget(L, -2); + } + /* now the 'type' table is top of stack */ + if (anchor->type == at_baselig) { + lua_pushstring(L, anchor->anchor->name); + lua_rawget(L, -2); + if (!lua_istable(L, -1)) { + /* create the table first */ + lua_pop(L, 1); + lua_pushstring(L, anchor->anchor->name); + lua_pushvalue(L, -1); + lua_newtable(L); + lua_rawset(L, -4); + lua_rawget(L, -2); + } + lua_newtable(L); + dump_intfield(L, "x", anchor->me.x); + dump_intfield(L, "y", anchor->me.y); + if (anchor->has_ttf_pt) + dump_intfield(L, "ttf_pt_index", anchor->ttf_pt_index); + dump_intfield(L, "lig_index", anchor->lig_index); + lua_rawseti(L, -2, (anchor->lig_index + 1)); + lua_pop(L, 1); + } else { + lua_pushstring(L, anchor->anchor->name); + lua_newtable(L); + dump_intfield(L, "x", anchor->me.x); + dump_intfield(L, "y", anchor->me.y); + if (anchor->has_ttf_pt) + dump_intfield(L, "ttf_pt_index", anchor->ttf_pt_index); + dump_intfield(L, "lig_index", anchor->lig_index); + lua_rawset(L, -3); + } + lua_pop(L, 1); } -void -handle_anchorpoint (lua_State *L, struct anchorpoint *anchor) { - struct anchorpoint *next; - next = anchor; - while (next != NULL) { - do_handle_anchorpoint(L, next); - next = next->next; - } +void handle_anchorpoint(lua_State * L, struct anchorpoint *anchor) +{ + struct anchorpoint *next; + next = anchor; + while (next != NULL) { + do_handle_anchorpoint(L, next); + next = next->next; + } } -void -handle_glyphvariants (lua_State *L, struct glyphvariants *vars) { - int i ; - dump_stringfield(L, "variants", vars->variants); - dump_intfield (L, "italic_correction", vars->italic_correction); - lua_newtable(L); - for (i=0; i< vars->part_cnt; i++) { - lua_newtable(L); - dump_stringfield(L, "component", vars->parts[i].component); - dump_intfield(L, "extender", vars->parts[i].is_extender); - dump_intfield(L, "start", vars->parts[i].startConnectorLength); - dump_intfield(L, "end", vars->parts[i].endConnectorLength); - dump_intfield(L, "advance", vars->parts[i].fullAdvance); - lua_rawseti(L,-2,(i+1)); - } - lua_setfield(L, -2, "parts"); -} - -void handle_mathkernvertex (lua_State *L, struct mathkernvertex *mkv) { - int i; - for (i=0; icnt;i++) { - lua_newtable(L); - dump_intfield(L, "height", mkv->mkd[i].height ); - dump_intfield(L, "kern", mkv->mkd[i].kern ); - lua_rawseti(L,-2, (i+1)); - } -} - -void handle_mathkern (lua_State *L, struct mathkern *mk) { - lua_newtable(L); - handle_mathkernvertex(L, &(mk->top_right)); - lua_setfield(L, -2, "top_right"); - lua_newtable(L); - handle_mathkernvertex(L, &(mk->top_left)); - lua_setfield(L, -2, "top_left"); - lua_newtable(L); - handle_mathkernvertex(L, &(mk->bottom_right)); - lua_setfield(L, -2, "bottom_right"); - lua_newtable(L); - handle_mathkernvertex(L, &(mk->bottom_left)); - lua_setfield(L, -2, "bottom_left"); -} - - - -void -handle_splinechar (lua_State *L,struct splinechar *glyph, int hasvmetrics) { - DBounds bb; - if (glyph->xmax==0 && glyph->ymax==0 && glyph->xmin==0 && glyph->ymin==0) { - SplineCharFindBounds(glyph,&bb); - glyph->xmin = bb.minx; - glyph->ymin = bb.miny; - glyph->xmax = bb.maxx; - glyph->ymax = bb.maxy; - } - dump_stringfield(L,"name", glyph->name); - dump_intfield(L,"unicode", glyph->unicodeenc); - lua_createtable(L,4,0); - lua_pushnumber(L,1); lua_pushnumber(L,glyph->xmin); lua_rawset(L,-3); - lua_pushnumber(L,2); lua_pushnumber(L,glyph->ymin); lua_rawset(L,-3); - lua_pushnumber(L,3); lua_pushnumber(L,glyph->xmax); lua_rawset(L,-3); - lua_pushnumber(L,4); lua_pushnumber(L,glyph->ymax); lua_rawset(L,-3); - lua_setfield(L,-2,"boundingbox"); - /*dump_intfield(L,"orig_pos", glyph->orig_pos);*/ - if (hasvmetrics) - dump_intfield(L,"vwidth", glyph->vwidth); - dump_intfield(L,"width", glyph->width); - - if (glyph->lsidebearing != glyph->xmin) { - dump_cond_intfield(L,"lsidebearing", glyph->lsidebearing); - } - /* dump_intfield(L,"ttf_glyph", glyph->ttf_glyph); */ - - /* Layer layers[2]; */ /* TH Not used */ - /* int layer_cnt; */ /* TH Not used */ - /* StemInfo *hstem; */ /* TH Not used */ - /* StemInfo *vstem; */ /* TH Not used */ - /* DStemInfo *dstem; */ /* TH Not used */ - - /* MinimumDistance *md; */ /* TH Not used */ - /* struct charviewbase *views; */ /* TH Not used */ - /* struct charinfo *charinfo; */ /* TH ? (charinfo.c) */ - /* struct splinefont *parent; */ /* TH Not used */ - - if (glyph->glyph_class>0) { - dump_enumfield(L,"class", glyph->glyph_class, glyph_class_enum); - } - /* TH: internal fontforge stuff - dump_intfield(L,"changed", glyph->changed); - dump_intfield(L,"changedsincelasthinted", glyph->changedsincelasthinted); - dump_intfield(L,"manualhints", glyph->manualhints); - dump_intfield(L,"ticked", glyph->ticked); - dump_intfield(L,"changed_since_autosave", glyph->changed_since_autosave); - dump_intfield(L,"widthset", glyph->widthset); - dump_intfield(L,"vconflicts", glyph->vconflicts); - dump_intfield(L,"hconflicts", glyph->hconflicts); - dump_intfield(L,"searcherdummy", glyph->searcherdummy); - dump_intfield(L,"changed_since_search", glyph->changed_since_search); - dump_intfield(L,"wasopen", glyph->wasopen); - dump_intfield(L,"namechanged", glyph->namechanged); - dump_intfield(L,"blended", glyph->blended); - dump_intfield(L,"ticked2", glyph->ticked2); - dump_intfield(L,"unused_so_far", glyph->unused_so_far); - dump_intfield(L,"numberpointsbackards", glyph->numberpointsbackards); - dump_intfield(L,"instructions_out_of_date", glyph->instructions_out_of_date); - dump_intfield(L,"complained_about_ptnums", glyph->complained_about_ptnums); - unsigned int vs_open: 1; - unsigned int unlink_rm_ovrlp_save_undo: 1; - unsigned int inspiro: 1; - unsigned int lig_caret_cnt_fixed: 1; - - - uint8 *ttf_instrs; - int16 ttf_instrs_len; - int16 countermask_cnt; - HintMask *countermasks; - */ - - if (glyph->kerns != NULL) { - lua_newtable(L); - handle_kernpair(L,glyph->kerns); - lua_setfield(L,-2,"kerns"); - } - if (glyph->vkerns != NULL) { - lua_newtable(L); - handle_kernpair(L,glyph->vkerns); - lua_setfield(L,-2,"vkerns"); - } - - if (glyph->dependents != NULL) { - lua_newtable(L); - handle_splinecharlist(L,glyph->dependents); - lua_setfield(L,-2,"dependents"); - - } - if (glyph->possub != NULL) { - lua_newtable(L); - handle_generic_pst(L,glyph->possub); - lua_setfield(L,-2,"lookups"); - } - - if (glyph->ligofme != NULL) { - lua_newtable(L); - handle_liglist(L,glyph->ligofme); - lua_setfield(L,-2,"ligatures"); - } - - if (glyph->comment != NULL) - dump_stringfield(L,"comment", glyph->comment); - - /* Color color; */ /* dont care */ - - if (glyph->anchor != NULL) { - lua_newtable(L); - handle_anchorpoint(L,glyph->anchor); - lua_setfield(L,-2,"anchors"); - } - - if (glyph->altuni != NULL) { - lua_newtable(L); - handle_altuni(L, glyph->altuni); - lua_setfield(L,-2,"altuni"); - } - - if (glyph->tex_height != TEX_UNDEF) - dump_intfield(L,"tex_height", glyph->tex_height); - if (glyph->tex_depth != TEX_UNDEF) - dump_intfield(L,"tex_depth", glyph->tex_depth); - - dump_cond_intfield(L, "is_extended_shape", glyph->is_extended_shape); - if (glyph->italic_correction != TEX_UNDEF) - dump_intfield(L, "italic_correction", glyph->italic_correction); - if (glyph->top_accent_horiz != TEX_UNDEF) - dump_intfield(L, "top_accent", glyph->top_accent_horiz); - - if (glyph->vert_variants != NULL) { - lua_newtable(L); - handle_glyphvariants(L, glyph->vert_variants); - lua_setfield(L,-2,"vert_variants"); - } - if (glyph->horiz_variants != NULL) { - lua_newtable(L); - handle_glyphvariants(L, glyph->horiz_variants); - lua_setfield(L,-2,"horiz_variants"); - } - if (glyph->mathkern != NULL) { +void handle_glyphvariants(lua_State * L, struct glyphvariants *vars) +{ + int i; + dump_stringfield(L, "variants", vars->variants); + dump_intfield(L, "italic_correction", vars->italic_correction); lua_newtable(L); - handle_mathkern(L, glyph->mathkern); - lua_setfield(L,-2,"mathkern"); - } -} - -char *panose_values_0[] = { "Any", "No Fit", "Text and Display", "Script", "Decorative", "Pictorial" }; - -char *panose_values_1[] = { "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove", "Obtuse Square Cove", - "Square", "Thin", "Bone", "Exaggerated", "Triangle", "Normal Sans", - "Obtuse Sans", "Perp Sans", "Flared", "Rounded" } ; - -char *panose_values_2[] = { "Any", "No Fit", "Very Light", "Light", "Thin", "Book", - "Medium", "Demi", "Bold", "Heavy", "Black", "Nord" } ; - -char *panose_values_3[] = { "Any", "No Fit", "Old Style", "Modern", "Even Width", - "Expanded", "Condensed", "Very Expanded", "Very Condensed", "Monospaced" }; - -char *panose_values_4[] = { "Any", "No Fit", "None", "Very Low", "Low", "Medium Low", - "Medium", "Medium High", "High", "Very High" }; - -char *panose_values_5[] = { "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional","Gradual/Vertical", - "Gradual/Horizontal", "Rapid/Vertical", "Rapid/Horizontal", "Instant/Vertical" }; - -char *panose_values_6[] = {"Any","No Fit","Straight Arms/Horizontal","Straight Arms/Wedge","Straight Arms/Vertical", - "Straight Arms/Single Serif","Straight Arms/Double Serif","Non-Straight Arms/Horizontal", - "Non-Straight Arms/Wedge","Non-Straight Arms/Vertical","Non-Straight Arms/Single Serif", - "Non-Straight Arms/Double Serif" }; - -char *panose_values_7[] = { "Any", "No Fit","Normal/Contact","Normal/Weighted","Normal/Boxed","Normal/Flattened", - "Normal/Rounded","Normal/Off Center","Normal/Square","Oblique/Contact","Oblique/Weighted", - "Oblique/Boxed","Oblique/Flattened","Oblique/Rounded","Oblique/Off Center","Oblique/Square" }; - -char *panose_values_8[] = { "Any","No Fit","Standard/Trimmed","Standard/Pointed","Standard/Serifed","High/Trimmed", - "High/Pointed","High/Serifed","Constant/Trimmed","Constant/Pointed","Constant/Serifed", - "Low/Trimmed","Low/Pointed","Low/Serifed"}; - -char *panose_values_9[] = { "Any","No Fit", "Constant/Small", "Constant/Standard", - "Constant/Large", "Ducking/Small", "Ducking/Standard", "Ducking/Large" }; - - -void -handle_pfminfo (lua_State *L, struct pfminfo pfm) { - - dump_intfield (L, "pfmset", pfm.pfmset); - dump_intfield (L, "winascent_add", pfm.winascent_add); - dump_intfield (L, "windescent_add", pfm.windescent_add); - dump_intfield (L, "hheadascent_add", pfm.hheadascent_add); - dump_intfield (L, "hheaddescent_add", pfm.hheaddescent_add); - dump_intfield (L, "typoascent_add", pfm.typoascent_add); - dump_intfield (L, "typodescent_add", pfm.typodescent_add); - dump_intfield (L, "subsuper_set", pfm.subsuper_set); - dump_intfield (L, "panose_set", pfm.panose_set); - dump_intfield (L, "hheadset", pfm.hheadset); - dump_intfield (L, "vheadset", pfm.vheadset); - dump_intfield (L, "pfmfamily", pfm.pfmfamily); - dump_intfield (L, "weight", pfm.weight); - dump_intfield (L, "width", pfm.width); - dump_intfield (L, "avgwidth", pfm.avgwidth); - dump_intfield (L, "firstchar", pfm.firstchar); - dump_intfield (L, "lastchar", pfm.lastchar); - lua_createtable(L,0,10); - dump_enumfield(L,"familytype", pfm.panose[0], panose_values_0); - dump_enumfield(L,"serifstyle", pfm.panose[1], panose_values_1); - dump_enumfield(L,"weight", pfm.panose[2], panose_values_2); - dump_enumfield(L,"proportion", pfm.panose[3], panose_values_3); - dump_enumfield(L,"contrast", pfm.panose[4], panose_values_4); - dump_enumfield(L,"strokevariation", pfm.panose[5], panose_values_5); - dump_enumfield(L,"armstyle", pfm.panose[6], panose_values_6); - dump_enumfield(L,"letterform", pfm.panose[7], panose_values_7); - dump_enumfield(L,"midline", pfm.panose[8], panose_values_8); - dump_enumfield(L,"xheight", pfm.panose[9], panose_values_9); - lua_setfield (L,-2,"panose"); - - dump_intfield (L, "fstype", pfm.fstype); - dump_intfield (L, "linegap", pfm.linegap); - dump_intfield (L, "vlinegap", pfm.vlinegap); - dump_intfield (L, "hhead_ascent", pfm.hhead_ascent); - dump_intfield (L, "hhead_descent", pfm.hhead_descent); - dump_intfield (L, "hhead_descent", pfm.hhead_descent); - dump_intfield (L, "os2_typoascent", pfm.os2_typoascent ); - dump_intfield (L, "os2_typodescent", pfm.os2_typodescent ); - dump_intfield (L, "os2_typolinegap", pfm.os2_typolinegap ); - dump_intfield (L, "os2_winascent", pfm.os2_winascent ); - dump_intfield (L, "os2_windescent", pfm.os2_windescent ); - dump_intfield (L, "os2_subxsize", pfm.os2_subxsize ); - dump_intfield (L, "os2_subysize", pfm.os2_subysize ); - dump_intfield (L, "os2_subxoff", pfm.os2_subxoff ); - dump_intfield (L, "os2_subyoff", pfm.os2_subyoff ); - dump_intfield (L, "os2_supxsize", pfm.os2_supxsize ); - dump_intfield (L, "os2_supysize", pfm.os2_supysize ); - dump_intfield (L, "os2_supxoff", pfm.os2_supxoff ); - dump_intfield (L, "os2_supyoff", pfm.os2_supyoff ); - dump_intfield (L, "os2_strikeysize", pfm.os2_strikeysize ); - dump_intfield (L, "os2_strikeypos", pfm.os2_strikeypos ); - dump_lstringfield (L, "os2_vendor", pfm.os2_vendor, 4); - dump_intfield (L, "os2_family_class", pfm.os2_family_class); - dump_intfield (L, "os2_xheight", pfm.os2_xheight); - dump_intfield (L, "os2_capheight", pfm.os2_capheight); - dump_intfield (L, "os2_defaultchar", pfm.os2_defaultchar); - dump_intfield (L, "os2_breakchar", pfm.os2_breakchar); - if (pfm.hascodepages) { - lua_newtable(L); - lua_pushnumber(L, pfm.codepages[0]); lua_rawseti(L,-2,1); - lua_pushnumber(L, pfm.codepages[1]); lua_rawseti(L,-2,2); - lua_setfield(L,-2,"codepages"); - } - if (pfm.hasunicoderanges) { + for (i = 0; i < vars->part_cnt; i++) { + lua_newtable(L); + dump_stringfield(L, "component", vars->parts[i].component); + dump_intfield(L, "extender", vars->parts[i].is_extender); + dump_intfield(L, "start", vars->parts[i].startConnectorLength); + dump_intfield(L, "end", vars->parts[i].endConnectorLength); + dump_intfield(L, "advance", vars->parts[i].fullAdvance); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "parts"); +} + +void handle_mathkernvertex(lua_State * L, struct mathkernvertex *mkv) +{ + int i; + for (i = 0; i < mkv->cnt; i++) { + lua_newtable(L); + dump_intfield(L, "height", mkv->mkd[i].height); + dump_intfield(L, "kern", mkv->mkd[i].kern); + lua_rawseti(L, -2, (i + 1)); + } +} + +void handle_mathkern(lua_State * L, struct mathkern *mk) +{ lua_newtable(L); - lua_pushnumber(L, pfm.unicoderanges[0]); lua_rawseti(L,-2,1); - lua_pushnumber(L, pfm.unicoderanges[1]); lua_rawseti(L,-2,2); - lua_pushnumber(L, pfm.unicoderanges[2]); lua_rawseti(L,-2,3); - lua_pushnumber(L, pfm.unicoderanges[3]); lua_rawseti(L,-2,4); - lua_setfield(L,-2,"unicoderanges"); - } -} - - -void -do_handle_enc (lua_State *L, struct enc *enc) { - int i; - - dump_stringfield(L,"enc_name", enc->enc_name); - dump_intfield (L,"char_cnt", enc->char_cnt); - - lua_checkstack(L,4); - if (enc->char_cnt && enc->unicode != NULL) { - lua_createtable(L,enc->char_cnt,1); - for (i=0;ichar_cnt;i++) { - lua_pushnumber(L,i); - lua_pushnumber(L,enc->unicode[i]); - lua_rawset(L,-3); - } - lua_setfield(L,-2,"unicode"); - } - - if (enc->char_cnt && enc->psnames != NULL) { - lua_createtable(L,enc->char_cnt,1); - for (i=0;ichar_cnt;i++) { - lua_pushnumber(L,i); - lua_pushstring(L,enc->psnames[i]); - lua_rawset(L,-3); - } - lua_setfield(L,-2,"psnames"); - } - dump_intfield (L,"builtin", enc->builtin ); - dump_intfield (L,"hidden", enc->hidden ); - dump_intfield (L,"only_1byte", enc->only_1byte ); - dump_intfield (L,"has_1byte", enc->has_1byte ); - dump_intfield (L,"has_2byte", enc->has_2byte ); - dump_cond_intfield (L,"is_unicodebmp", enc->is_unicodebmp ); - dump_cond_intfield (L,"is_unicodefull", enc->is_unicodefull ); - dump_cond_intfield (L,"is_custom", enc->is_custom ); - dump_cond_intfield (L,"is_original", enc->is_original ); - dump_cond_intfield (L,"is_compact", enc->is_compact ); - dump_cond_intfield (L,"is_japanese", enc->is_japanese ); - dump_cond_intfield (L,"is_korean", enc->is_korean ); - dump_cond_intfield (L,"is_tradchinese", enc->is_tradchinese ); - dump_cond_intfield (L,"is_simplechinese", enc->is_simplechinese); - - if (enc->iso_2022_escape_len > 0) { - dump_lstringfield (L,"iso_2022_escape", enc->iso_2022_escape, enc->iso_2022_escape_len); - } - dump_intfield (L,"low_page", enc->low_page); - dump_intfield(L,"high_page", enc->high_page); - - dump_stringfield(L,"iconv_name", enc->iconv_name); - - dump_intfield (L,"char_max", enc->char_max); -} - -void -handle_enc (lua_State *L, struct enc *enc) { - struct enc *next; - NESTED_TABLE(do_handle_enc,enc,24); -} - -void -handle_encmap (lua_State *L, struct encmap *map, int notdef_loc) { - int i; - dump_intfield(L,"enccount", map->enccount) ; - dump_intfield(L,"encmax", map->encmax) ; - dump_intfield(L,"backmax", map->backmax) ; - /*dump_intfield(L,"ticked", map->ticked) ;*/ - if (map->remap != NULL) { + handle_mathkernvertex(L, &(mk->top_right)); + lua_setfield(L, -2, "top_right"); lua_newtable(L); - dump_intfield(L,"firstenc", map->remap->firstenc) ; - dump_intfield(L,"lastenc", map->remap->lastenc) ; - dump_intfield(L,"infont", map->remap->infont) ; - lua_setfield(L,-2,"remap"); - } - lua_checkstack(L,4); - if (map->encmax > 0 && map->map != NULL) { - lua_createtable(L,map->encmax,1); - for (i=0;iencmax;i++) { - if (map->map[i]!=-1) { - int l = map->map[i]; - lua_pushnumber(L,i); - if (lbackmax > 0 && map->backmap != NULL) { + handle_mathkernvertex(L, &(mk->top_left)); + lua_setfield(L, -2, "top_left"); lua_newtable(L); - for (i=0;ibackmax;i++) { - if (map->backmap[i]!=-1) { /* TODO: check this, because valgrind sometimes says - "Conditional jump or move depends on uninitialised value(s)" - needs a test file. - */ - if (ibackmap[i]); - lua_rawset(L,-3); - } - } - lua_setfield(L,-2,"backmap"); - } - - if (map->enc != NULL) { + handle_mathkernvertex(L, &(mk->bottom_right)); + lua_setfield(L, -2, "bottom_right"); lua_newtable(L); - handle_enc(L,map->enc); - lua_setfield(L,-2,"enc"); - } + handle_mathkernvertex(L, &(mk->bottom_left)); + lua_setfield(L, -2, "bottom_left"); } -static void -handle_psdict (lua_State *L, struct psdict *private) { - int k; - if (private->keys != NULL && private->values != NULL) { - for (k=0;knext;k++) { - lua_pushstring(L,private->keys[k]); - lua_pushstring(L,private->values[k]); - lua_rawset(L,-3); - } - } + + +void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvmetrics) +{ + DBounds bb; + if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0 + && glyph->ymin == 0) { + SplineCharFindBounds(glyph, &bb); + glyph->xmin = bb.minx; + glyph->ymin = bb.miny; + glyph->xmax = bb.maxx; + glyph->ymax = bb.maxy; + } + dump_stringfield(L, "name", glyph->name); + dump_intfield(L, "unicode", glyph->unicodeenc); + lua_createtable(L, 4, 0); + lua_pushnumber(L, 1); + lua_pushnumber(L, glyph->xmin); + lua_rawset(L, -3); + lua_pushnumber(L, 2); + lua_pushnumber(L, glyph->ymin); + lua_rawset(L, -3); + lua_pushnumber(L, 3); + lua_pushnumber(L, glyph->xmax); + lua_rawset(L, -3); + lua_pushnumber(L, 4); + lua_pushnumber(L, glyph->ymax); + lua_rawset(L, -3); + lua_setfield(L, -2, "boundingbox"); + /*dump_intfield(L,"orig_pos", glyph->orig_pos); */ + if (hasvmetrics) + dump_intfield(L, "vwidth", glyph->vwidth); + dump_intfield(L, "width", glyph->width); + + if (glyph->lsidebearing != glyph->xmin) { + dump_cond_intfield(L, "lsidebearing", glyph->lsidebearing); + } + /* dump_intfield(L,"ttf_glyph", glyph->ttf_glyph); */ + + /* Layer layers[2]; *//* TH Not used */ + /* int layer_cnt; *//* TH Not used */ + /* StemInfo *hstem; *//* TH Not used */ + /* StemInfo *vstem; *//* TH Not used */ + /* DStemInfo *dstem; *//* TH Not used */ + + /* MinimumDistance *md; *//* TH Not used */ + /* struct charviewbase *views; *//* TH Not used */ + /* struct charinfo *charinfo; *//* TH ? (charinfo.c) */ + /* struct splinefont *parent; *//* TH Not used */ + + if (glyph->glyph_class > 0) { + dump_enumfield(L, "class", glyph->glyph_class, glyph_class_enum); + } + /* TH: internal fontforge stuff + dump_intfield(L,"changed", glyph->changed); + dump_intfield(L,"changedsincelasthinted", glyph->changedsincelasthinted); + dump_intfield(L,"manualhints", glyph->manualhints); + dump_intfield(L,"ticked", glyph->ticked); + dump_intfield(L,"changed_since_autosave", glyph->changed_since_autosave); + dump_intfield(L,"widthset", glyph->widthset); + dump_intfield(L,"vconflicts", glyph->vconflicts); + dump_intfield(L,"hconflicts", glyph->hconflicts); + dump_intfield(L,"searcherdummy", glyph->searcherdummy); + dump_intfield(L,"changed_since_search", glyph->changed_since_search); + dump_intfield(L,"wasopen", glyph->wasopen); + dump_intfield(L,"namechanged", glyph->namechanged); + dump_intfield(L,"blended", glyph->blended); + dump_intfield(L,"ticked2", glyph->ticked2); + dump_intfield(L,"unused_so_far", glyph->unused_so_far); + dump_intfield(L,"numberpointsbackards", glyph->numberpointsbackards); + dump_intfield(L,"instructions_out_of_date", glyph->instructions_out_of_date); + dump_intfield(L,"complained_about_ptnums", glyph->complained_about_ptnums); + unsigned int vs_open: 1; + unsigned int unlink_rm_ovrlp_save_undo: 1; + unsigned int inspiro: 1; + unsigned int lig_caret_cnt_fixed: 1; + + + uint8 *ttf_instrs; + int16 ttf_instrs_len; + int16 countermask_cnt; + HintMask *countermasks; + */ + + if (glyph->kerns != NULL) { + lua_newtable(L); + handle_kernpair(L, glyph->kerns); + lua_setfield(L, -2, "kerns"); + } + if (glyph->vkerns != NULL) { + lua_newtable(L); + handle_kernpair(L, glyph->vkerns); + lua_setfield(L, -2, "vkerns"); + } + + if (glyph->dependents != NULL) { + lua_newtable(L); + handle_splinecharlist(L, glyph->dependents); + lua_setfield(L, -2, "dependents"); + + } + if (glyph->possub != NULL) { + lua_newtable(L); + handle_generic_pst(L, glyph->possub); + lua_setfield(L, -2, "lookups"); + } + + if (glyph->ligofme != NULL) { + lua_newtable(L); + handle_liglist(L, glyph->ligofme); + lua_setfield(L, -2, "ligatures"); + } + + if (glyph->comment != NULL) + dump_stringfield(L, "comment", glyph->comment); + + /* Color color; *//* dont care */ + + if (glyph->anchor != NULL) { + lua_newtable(L); + handle_anchorpoint(L, glyph->anchor); + lua_setfield(L, -2, "anchors"); + } + + if (glyph->altuni != NULL) { + lua_newtable(L); + handle_altuni(L, glyph->altuni); + lua_setfield(L, -2, "altuni"); + } + + if (glyph->tex_height != TEX_UNDEF) + dump_intfield(L, "tex_height", glyph->tex_height); + if (glyph->tex_depth != TEX_UNDEF) + dump_intfield(L, "tex_depth", glyph->tex_depth); + + dump_cond_intfield(L, "is_extended_shape", glyph->is_extended_shape); + if (glyph->italic_correction != TEX_UNDEF) + dump_intfield(L, "italic_correction", glyph->italic_correction); + if (glyph->top_accent_horiz != TEX_UNDEF) + dump_intfield(L, "top_accent", glyph->top_accent_horiz); + + if (glyph->vert_variants != NULL) { + lua_newtable(L); + handle_glyphvariants(L, glyph->vert_variants); + lua_setfield(L, -2, "vert_variants"); + } + if (glyph->horiz_variants != NULL) { + lua_newtable(L); + handle_glyphvariants(L, glyph->horiz_variants); + lua_setfield(L, -2, "horiz_variants"); + } + if (glyph->mathkern != NULL) { + lua_newtable(L); + handle_mathkern(L, glyph->mathkern); + lua_setfield(L, -2, "mathkern"); + } } -void -do_handle_ttflangname (lua_State *L, struct ttflangname *names) { - int k; - dump_stringfield(L,"lang", (char *)MSLangString(names->lang)) ; - lua_checkstack(L,4); - lua_createtable(L,0,ttf_namemax); - for (k=0;knames[k]); - lua_rawset(L,-3); - } - lua_setfield(L, -2 , "names"); +char *panose_values_0[] = + { "Any", "No Fit", "Text and Display", "Script", "Decorative", + "Pictorial" +}; + +char *panose_values_1[] = + { "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove", + "Obtuse Square Cove", + "Square", "Thin", "Bone", "Exaggerated", "Triangle", "Normal Sans", + "Obtuse Sans", "Perp Sans", "Flared", "Rounded" +}; + +char *panose_values_2[] = + { "Any", "No Fit", "Very Light", "Light", "Thin", "Book", + "Medium", "Demi", "Bold", "Heavy", "Black", "Nord" +}; + +char *panose_values_3[] = + { "Any", "No Fit", "Old Style", "Modern", "Even Width", + "Expanded", "Condensed", "Very Expanded", "Very Condensed", "Monospaced" +}; + +char *panose_values_4[] = + { "Any", "No Fit", "None", "Very Low", "Low", "Medium Low", + "Medium", "Medium High", "High", "Very High" +}; + +char *panose_values_5[] = + { "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional", + "Gradual/Vertical", + "Gradual/Horizontal", "Rapid/Vertical", "Rapid/Horizontal", + "Instant/Vertical" +}; + +char *panose_values_6[] = + { "Any", "No Fit", "Straight Arms/Horizontal", "Straight Arms/Wedge", + "Straight Arms/Vertical", + "Straight Arms/Single Serif", "Straight Arms/Double Serif", + "Non-Straight Arms/Horizontal", + "Non-Straight Arms/Wedge", "Non-Straight Arms/Vertical", + "Non-Straight Arms/Single Serif", + "Non-Straight Arms/Double Serif" +}; + +char *panose_values_7[] = + { "Any", "No Fit", "Normal/Contact", "Normal/Weighted", "Normal/Boxed", + "Normal/Flattened", + "Normal/Rounded", "Normal/Off Center", "Normal/Square", "Oblique/Contact", + "Oblique/Weighted", + "Oblique/Boxed", "Oblique/Flattened", "Oblique/Rounded", + "Oblique/Off Center", "Oblique/Square" +}; + +char *panose_values_8[] = + { "Any", "No Fit", "Standard/Trimmed", "Standard/Pointed", + "Standard/Serifed", "High/Trimmed", + "High/Pointed", "High/Serifed", "Constant/Trimmed", "Constant/Pointed", + "Constant/Serifed", + "Low/Trimmed", "Low/Pointed", "Low/Serifed" +}; + +char *panose_values_9[] = + { "Any", "No Fit", "Constant/Small", "Constant/Standard", + "Constant/Large", "Ducking/Small", "Ducking/Standard", "Ducking/Large" +}; + + +void handle_pfminfo(lua_State * L, struct pfminfo pfm) +{ + + dump_intfield(L, "pfmset", pfm.pfmset); + dump_intfield(L, "winascent_add", pfm.winascent_add); + dump_intfield(L, "windescent_add", pfm.windescent_add); + dump_intfield(L, "hheadascent_add", pfm.hheadascent_add); + dump_intfield(L, "hheaddescent_add", pfm.hheaddescent_add); + dump_intfield(L, "typoascent_add", pfm.typoascent_add); + dump_intfield(L, "typodescent_add", pfm.typodescent_add); + dump_intfield(L, "subsuper_set", pfm.subsuper_set); + dump_intfield(L, "panose_set", pfm.panose_set); + dump_intfield(L, "hheadset", pfm.hheadset); + dump_intfield(L, "vheadset", pfm.vheadset); + dump_intfield(L, "pfmfamily", pfm.pfmfamily); + dump_intfield(L, "weight", pfm.weight); + dump_intfield(L, "width", pfm.width); + dump_intfield(L, "avgwidth", pfm.avgwidth); + dump_intfield(L, "firstchar", pfm.firstchar); + dump_intfield(L, "lastchar", pfm.lastchar); + lua_createtable(L, 0, 10); + dump_enumfield(L, "familytype", pfm.panose[0], panose_values_0); + dump_enumfield(L, "serifstyle", pfm.panose[1], panose_values_1); + dump_enumfield(L, "weight", pfm.panose[2], panose_values_2); + dump_enumfield(L, "proportion", pfm.panose[3], panose_values_3); + dump_enumfield(L, "contrast", pfm.panose[4], panose_values_4); + dump_enumfield(L, "strokevariation", pfm.panose[5], panose_values_5); + dump_enumfield(L, "armstyle", pfm.panose[6], panose_values_6); + dump_enumfield(L, "letterform", pfm.panose[7], panose_values_7); + dump_enumfield(L, "midline", pfm.panose[8], panose_values_8); + dump_enumfield(L, "xheight", pfm.panose[9], panose_values_9); + lua_setfield(L, -2, "panose"); + + dump_intfield(L, "fstype", pfm.fstype); + dump_intfield(L, "linegap", pfm.linegap); + dump_intfield(L, "vlinegap", pfm.vlinegap); + dump_intfield(L, "hhead_ascent", pfm.hhead_ascent); + dump_intfield(L, "hhead_descent", pfm.hhead_descent); + dump_intfield(L, "hhead_descent", pfm.hhead_descent); + dump_intfield(L, "os2_typoascent", pfm.os2_typoascent); + dump_intfield(L, "os2_typodescent", pfm.os2_typodescent); + dump_intfield(L, "os2_typolinegap", pfm.os2_typolinegap); + dump_intfield(L, "os2_winascent", pfm.os2_winascent); + dump_intfield(L, "os2_windescent", pfm.os2_windescent); + dump_intfield(L, "os2_subxsize", pfm.os2_subxsize); + dump_intfield(L, "os2_subysize", pfm.os2_subysize); + dump_intfield(L, "os2_subxoff", pfm.os2_subxoff); + dump_intfield(L, "os2_subyoff", pfm.os2_subyoff); + dump_intfield(L, "os2_supxsize", pfm.os2_supxsize); + dump_intfield(L, "os2_supysize", pfm.os2_supysize); + dump_intfield(L, "os2_supxoff", pfm.os2_supxoff); + dump_intfield(L, "os2_supyoff", pfm.os2_supyoff); + dump_intfield(L, "os2_strikeysize", pfm.os2_strikeysize); + dump_intfield(L, "os2_strikeypos", pfm.os2_strikeypos); + dump_lstringfield(L, "os2_vendor", pfm.os2_vendor, 4); + dump_intfield(L, "os2_family_class", pfm.os2_family_class); + dump_intfield(L, "os2_xheight", pfm.os2_xheight); + dump_intfield(L, "os2_capheight", pfm.os2_capheight); + dump_intfield(L, "os2_defaultchar", pfm.os2_defaultchar); + dump_intfield(L, "os2_breakchar", pfm.os2_breakchar); + if (pfm.hascodepages) { + lua_newtable(L); + lua_pushnumber(L, pfm.codepages[0]); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, pfm.codepages[1]); + lua_rawseti(L, -2, 2); + lua_setfield(L, -2, "codepages"); + } + if (pfm.hasunicoderanges) { + lua_newtable(L); + lua_pushnumber(L, pfm.unicoderanges[0]); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, pfm.unicoderanges[1]); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, pfm.unicoderanges[2]); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, pfm.unicoderanges[3]); + lua_rawseti(L, -2, 4); + lua_setfield(L, -2, "unicoderanges"); + } } -void -handle_ttflangname (lua_State *L, struct ttflangname *names) { - struct ttflangname *next; - NESTED_TABLE(do_handle_ttflangname,names,2); +void do_handle_enc(lua_State * L, struct enc *enc) +{ + int i; + + dump_stringfield(L, "enc_name", enc->enc_name); + dump_intfield(L, "char_cnt", enc->char_cnt); + + lua_checkstack(L, 4); + if (enc->char_cnt && enc->unicode != NULL) { + lua_createtable(L, enc->char_cnt, 1); + for (i = 0; i < enc->char_cnt; i++) { + lua_pushnumber(L, i); + lua_pushnumber(L, enc->unicode[i]); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "unicode"); + } + + if (enc->char_cnt && enc->psnames != NULL) { + lua_createtable(L, enc->char_cnt, 1); + for (i = 0; i < enc->char_cnt; i++) { + lua_pushnumber(L, i); + lua_pushstring(L, enc->psnames[i]); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "psnames"); + } + dump_intfield(L, "builtin", enc->builtin); + dump_intfield(L, "hidden", enc->hidden); + dump_intfield(L, "only_1byte", enc->only_1byte); + dump_intfield(L, "has_1byte", enc->has_1byte); + dump_intfield(L, "has_2byte", enc->has_2byte); + dump_cond_intfield(L, "is_unicodebmp", enc->is_unicodebmp); + dump_cond_intfield(L, "is_unicodefull", enc->is_unicodefull); + dump_cond_intfield(L, "is_custom", enc->is_custom); + dump_cond_intfield(L, "is_original", enc->is_original); + dump_cond_intfield(L, "is_compact", enc->is_compact); + dump_cond_intfield(L, "is_japanese", enc->is_japanese); + dump_cond_intfield(L, "is_korean", enc->is_korean); + dump_cond_intfield(L, "is_tradchinese", enc->is_tradchinese); + dump_cond_intfield(L, "is_simplechinese", enc->is_simplechinese); + + if (enc->iso_2022_escape_len > 0) { + dump_lstringfield(L, "iso_2022_escape", enc->iso_2022_escape, + enc->iso_2022_escape_len); + } + dump_intfield(L, "low_page", enc->low_page); + dump_intfield(L, "high_page", enc->high_page); + + dump_stringfield(L, "iconv_name", enc->iconv_name); + + dump_intfield(L, "char_max", enc->char_max); } +void handle_enc(lua_State * L, struct enc *enc) +{ + struct enc *next; + NESTED_TABLE(do_handle_enc, enc, 24); +} -void -do_handle_anchorclass (lua_State *L, struct anchorclass *anchor) { +void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc) +{ + int i; + dump_intfield(L, "enccount", map->enccount); + dump_intfield(L, "encmax", map->encmax); + dump_intfield(L, "backmax", map->backmax); + /*dump_intfield(L,"ticked", map->ticked) ; */ + if (map->remap != NULL) { + lua_newtable(L); + dump_intfield(L, "firstenc", map->remap->firstenc); + dump_intfield(L, "lastenc", map->remap->lastenc); + dump_intfield(L, "infont", map->remap->infont); + lua_setfield(L, -2, "remap"); + } + lua_checkstack(L, 4); + if (map->encmax > 0 && map->map != NULL) { + lua_createtable(L, map->encmax, 1); + for (i = 0; i < map->encmax; i++) { + if (map->map[i] != -1) { + int l = map->map[i]; + lua_pushnumber(L, i); + if (l < notdef_loc) + lua_pushnumber(L, (l + 1)); + else + lua_pushnumber(L, l); + lua_rawset(L, -3); + } + } + lua_setfield(L, -2, "map"); + } + + if (map->backmax > 0 && map->backmap != NULL) { + lua_newtable(L); + for (i = 0; i < map->backmax; i++) { + if (map->backmap[i] != -1) { /* TODO: check this, because valgrind sometimes says + "Conditional jump or move depends on uninitialised value(s)" + needs a test file. + */ + if (i < notdef_loc) + lua_pushnumber(L, (i + 1)); + else + lua_pushnumber(L, i); + lua_pushnumber(L, map->backmap[i]); + lua_rawset(L, -3); + } + } + lua_setfield(L, -2, "backmap"); + } - dump_stringfield(L,"name", anchor->name); - dump_subtable_name (L, "lookup", anchor->subtable); - dump_enumfield(L,"type", anchor->type, anchorclass_type_enum); - /* uint8 has_base; */ - /* uint8 processed, has_mark, matches, ac_num; */ - /* uint8 ticked; */ + if (map->enc != NULL) { + lua_newtable(L); + handle_enc(L, map->enc); + lua_setfield(L, -2, "enc"); + } } -void -handle_anchorclass (lua_State *L, struct anchorclass *anchor) { - struct anchorclass *next; - NESTED_TABLE(do_handle_anchorclass,anchor,10); +static void handle_psdict(lua_State * L, struct psdict *private) +{ + int k; + if (private->keys != NULL && private->values != NULL) { + for (k = 0; k < private->next; k++) { + lua_pushstring(L, private->keys[k]); + lua_pushstring(L, private->values[k]); + lua_rawset(L, -3); + } + } +} + +void do_handle_ttflangname(lua_State * L, struct ttflangname *names) +{ + int k; + dump_stringfield(L, "lang", (char *) MSLangString(names->lang)); + lua_checkstack(L, 4); + lua_createtable(L, 0, ttf_namemax); + for (k = 0; k < ttf_namemax; k++) { + lua_pushstring(L, ttfnames_enum[k]); + lua_pushstring(L, names->names[k]); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "names"); } -void -do_handle_ttf_table (lua_State *L, struct ttf_table *ttf_tab) { - dump_tag(L,"tag", ttf_tab->tag); - dump_intfield(L,"len", ttf_tab->len); - dump_intfield(L,"maxlen", ttf_tab->maxlen); - dump_lstringfield(L,"data", (char *)ttf_tab->data, ttf_tab->len); +void handle_ttflangname(lua_State * L, struct ttflangname *names) +{ + struct ttflangname *next; + NESTED_TABLE(do_handle_ttflangname, names, 2); } -void -handle_ttf_table (lua_State *L, struct ttf_table *ttf_tab) { - struct ttf_table *next; - NESTED_TABLE(do_handle_ttf_table,ttf_tab,4); + +void do_handle_anchorclass(lua_State * L, struct anchorclass *anchor) +{ + + dump_stringfield(L, "name", anchor->name); + dump_subtable_name(L, "lookup", anchor->subtable); + dump_enumfield(L, "type", anchor->type, anchorclass_type_enum); + /* uint8 has_base; */ + /* uint8 processed, has_mark, matches, ac_num; */ + /* uint8 ticked; */ } -void -do_handle_kernclass (lua_State *L, struct kernclass *kerns) { - int k; - - /* - * dump_intfield(L,"first_cnt", kerns->first_cnt); - * dump_intfield(L,"second_cnt", kerns->second_cnt); - */ - lua_checkstack(L,4); - lua_createtable(L,kerns->first_cnt,1); - for (k=0;kfirst_cnt;k++) { - lua_pushnumber(L,(k+1)); - lua_pushstring(L,kerns->firsts[k]); - lua_rawset(L,-3); - } - lua_setfield(L,-2,"firsts"); - - lua_createtable(L,kerns->second_cnt,1); - for (k=0;ksecond_cnt;k++) { - lua_pushnumber(L,(k+1)); - lua_pushstring(L,kerns->seconds[k]); - lua_rawset(L,-3); - } - lua_setfield(L,-2,"seconds"); - - dump_subtable_name(L, "lookup", kerns->subtable); - /*dump_intfield(L,"kcid", kerns->kcid); *//* probably not needed */ - - lua_createtable(L,kerns->second_cnt*kerns->first_cnt,1); - for (k=0;k<(kerns->second_cnt*kerns->first_cnt);k++) { - if (kerns->offsets[k]!=0) { - lua_pushnumber(L,(k+1)); - lua_pushnumber(L,kerns->offsets[k]); - lua_rawset(L,-3); - } - } - lua_setfield(L,-2,"offsets"); +void handle_anchorclass(lua_State * L, struct anchorclass *anchor) +{ + struct anchorclass *next; + NESTED_TABLE(do_handle_anchorclass, anchor, 10); +} +void do_handle_ttf_table(lua_State * L, struct ttf_table *ttf_tab) +{ + + dump_tag(L, "tag", ttf_tab->tag); + dump_intfield(L, "len", ttf_tab->len); + dump_intfield(L, "maxlen", ttf_tab->maxlen); + dump_lstringfield(L, "data", (char *) ttf_tab->data, ttf_tab->len); } -void -handle_kernclass (lua_State *L, struct kernclass *kerns) { - struct kernclass *next; - NESTED_TABLE(do_handle_kernclass,kerns,8); +void handle_ttf_table(lua_State * L, struct ttf_table *ttf_tab) +{ + struct ttf_table *next; + NESTED_TABLE(do_handle_ttf_table, ttf_tab, 4); +} + +void do_handle_kernclass(lua_State * L, struct kernclass *kerns) +{ + int k; + + /* + * dump_intfield(L,"first_cnt", kerns->first_cnt); + * dump_intfield(L,"second_cnt", kerns->second_cnt); + */ + lua_checkstack(L, 4); + lua_createtable(L, kerns->first_cnt, 1); + for (k = 0; k < kerns->first_cnt; k++) { + lua_pushnumber(L, (k + 1)); + lua_pushstring(L, kerns->firsts[k]); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "firsts"); + + lua_createtable(L, kerns->second_cnt, 1); + for (k = 0; k < kerns->second_cnt; k++) { + lua_pushnumber(L, (k + 1)); + lua_pushstring(L, kerns->seconds[k]); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "seconds"); + + dump_subtable_name(L, "lookup", kerns->subtable); + /*dump_intfield(L,"kcid", kerns->kcid); *//* probably not needed */ + + lua_createtable(L, kerns->second_cnt * kerns->first_cnt, 1); + for (k = 0; k < (kerns->second_cnt * kerns->first_cnt); k++) { + if (kerns->offsets[k] != 0) { + lua_pushnumber(L, (k + 1)); + lua_pushnumber(L, kerns->offsets[k]); + lua_rawset(L, -3); + } + } + lua_setfield(L, -2, "offsets"); + +} + +void handle_kernclass(lua_State * L, struct kernclass *kerns) +{ + struct kernclass *next; + NESTED_TABLE(do_handle_kernclass, kerns, 8); } @@ -1335,200 +1459,209 @@ handle_kernclass (lua_State *L, struct kernclass *kerns) { lua_setfield(L,-2,s); } } -void handle_fpst_rule (lua_State *L, struct fpst_rule *rule, int format) { - int k; +void handle_fpst_rule(lua_State * L, struct fpst_rule *rule, int format) +{ + int k; - if (format == pst_glyphs) { + if (format == pst_glyphs) { - lua_newtable(L); - dump_stringfield(L,"names",rule->u.glyph.names); - dump_stringfield(L,"back",rule->u.glyph.back); - dump_stringfield(L,"fore",rule->u.glyph.fore); - lua_setfield(L,-2,fpossub_format_enum[format]); + lua_newtable(L); + dump_stringfield(L, "names", rule->u.glyph.names); + dump_stringfield(L, "back", rule->u.glyph.back); + dump_stringfield(L, "fore", rule->u.glyph.fore); + lua_setfield(L, -2, fpossub_format_enum[format]); - } else if (format == pst_class) { - - lua_newtable(L); - DUMP_NUMBER_ARRAY("current", rule->u.class.ncnt,rule->u.class.nclasses); - DUMP_NUMBER_ARRAY("before", rule->u.class.bcnt,rule->u.class.bclasses); - DUMP_NUMBER_ARRAY("after", rule->u.class.fcnt,rule->u.class.fclasses); + } else if (format == pst_class) { + + lua_newtable(L); + DUMP_NUMBER_ARRAY("current", rule->u.class.ncnt, + rule->u.class.nclasses); + DUMP_NUMBER_ARRAY("before", rule->u.class.bcnt, rule->u.class.bclasses); + DUMP_NUMBER_ARRAY("after", rule->u.class.fcnt, rule->u.class.fclasses); #if 0 - DUMP_NUMBER_ARRAY("allclasses", 0,rule->u.class.allclasses); + DUMP_NUMBER_ARRAY("allclasses", 0, rule->u.class.allclasses); #endif - lua_setfield(L,-2,fpossub_format_enum[format]); + lua_setfield(L, -2, fpossub_format_enum[format]); - } else if (format == pst_coverage) { + } else if (format == pst_coverage) { - lua_newtable(L); - DUMP_STRING_ARRAY("current", rule->u.coverage.ncnt,rule->u.coverage.ncovers); - DUMP_STRING_ARRAY("before", rule->u.coverage.bcnt,rule->u.coverage.bcovers); - DUMP_STRING_ARRAY("after", rule->u.coverage.fcnt,rule->u.coverage.fcovers); - lua_setfield(L,-2,fpossub_format_enum[format]); + lua_newtable(L); + DUMP_STRING_ARRAY("current", rule->u.coverage.ncnt, + rule->u.coverage.ncovers); + DUMP_STRING_ARRAY("before", rule->u.coverage.bcnt, + rule->u.coverage.bcovers); + DUMP_STRING_ARRAY("after", rule->u.coverage.fcnt, + rule->u.coverage.fcovers); + lua_setfield(L, -2, fpossub_format_enum[format]); - } else if (format == pst_reversecoverage) { + } else if (format == pst_reversecoverage) { - lua_newtable(L); - DUMP_STRING_ARRAY("current", rule->u.rcoverage.always1,rule->u.rcoverage.ncovers); - DUMP_STRING_ARRAY("before", rule->u.rcoverage.bcnt,rule->u.rcoverage.bcovers); - DUMP_STRING_ARRAY("after", rule->u.rcoverage.fcnt,rule->u.rcoverage.fcovers); - dump_stringfield(L,"replacements", rule->u.rcoverage.replacements); - lua_setfield(L,-2,fpossub_format_enum[format]); - } else { - fprintf(stderr,"handle_fpst_rule(): Unknown rule format: %d\n",format); - } - - if (rule->lookup_cnt>0) { - lua_newtable(L); - for (k=0;klookup_cnt;k++) { - lua_pushnumber(L,(rule->lookups[k].seq+1)); - if (rule->lookups[k].lookup!=NULL) { - lua_pushstring(L,rule->lookups[k].lookup->lookup_name); - } else { - lua_pushnil(L); - } - lua_rawset(L,-3); - } - lua_setfield(L,-2,"lookups"); - } else { - /*fprintf(stderr,"handle_fpst_rule(): No lookups?\n");*/ - } -} - -void -do_handle_generic_fpst(lua_State *L, struct generic_fpst *fpst) { - int k; - - if (fpst->type>LAST_POSSUB_TYPE_ENUM) { - dump_intfield(L,"type", fpst->type); - } else { - dump_enumfield(L,"type", fpst->type, possub_type_enum); - } - dump_enumfield(L,"format", fpst->format, fpossub_format_enum); - - if (fpst->format==pst_class) { - DUMP_EXACT_STRING_ARRAY("current_class",fpst->nccnt,fpst->nclass); - DUMP_EXACT_STRING_ARRAY("before_class",fpst->bccnt,fpst->bclass); - DUMP_EXACT_STRING_ARRAY("after_class",fpst->fccnt,fpst->fclass); - } else { - DUMP_STRING_ARRAY("current_class",fpst->nccnt,fpst->nclass); - DUMP_STRING_ARRAY("before_class",fpst->bccnt,fpst->bclass); - DUMP_STRING_ARRAY("after_class",fpst->fccnt,fpst->fclass); - } - - lua_checkstack(L,4); - if (fpst->rule_cnt>0) { - lua_createtable(L,fpst->rule_cnt,1); - for (k=0;krule_cnt;k++) { - lua_pushnumber(L,(k+1)); - lua_newtable(L); - handle_fpst_rule(L,&(fpst->rules[k]),fpst->format); - lua_rawset(L,-3); - } - lua_setfield(L,-2,"rules"); - } - /*dump_intfield (L,"ticked", fpst->ticked);*/ -} - -void -handle_generic_fpst(lua_State *L, struct generic_fpst *fpst) { - struct generic_fpst *next; - int k = 1; - lua_checkstack(L,3); - if (fpst->subtable != NULL && - fpst->subtable->subtable_name != NULL) { - lua_pushstring(L,fpst->subtable->subtable_name); - } else { - lua_pushnumber(L,k); k++; - } - lua_createtable(L,0,10); - do_handle_generic_fpst(L,fpst); - lua_rawset(L,-3); - next = fpst->next; - while (next != NULL) { - lua_checkstack(L,3); - if (next->subtable != NULL && - next->subtable->subtable_name != NULL) { - lua_pushstring(L,next->subtable->subtable_name); - } else { - lua_pushnumber(L,k); k++; - } - lua_createtable(L,0,10); - do_handle_generic_fpst(L, next); - lua_rawset(L,-3); - next = next->next; - } + lua_newtable(L); + DUMP_STRING_ARRAY("current", rule->u.rcoverage.always1, + rule->u.rcoverage.ncovers); + DUMP_STRING_ARRAY("before", rule->u.rcoverage.bcnt, + rule->u.rcoverage.bcovers); + DUMP_STRING_ARRAY("after", rule->u.rcoverage.fcnt, + rule->u.rcoverage.fcovers); + dump_stringfield(L, "replacements", rule->u.rcoverage.replacements); + lua_setfield(L, -2, fpossub_format_enum[format]); + } else { + fprintf(stderr, "handle_fpst_rule(): Unknown rule format: %d\n", + format); + } + + if (rule->lookup_cnt > 0) { + lua_newtable(L); + for (k = 0; k < rule->lookup_cnt; k++) { + lua_pushnumber(L, (rule->lookups[k].seq + 1)); + if (rule->lookups[k].lookup != NULL) { + lua_pushstring(L, rule->lookups[k].lookup->lookup_name); + } else { + lua_pushnil(L); + } + lua_rawset(L, -3); + } + lua_setfield(L, -2, "lookups"); + } else { + /*fprintf(stderr,"handle_fpst_rule(): No lookups?\n"); */ + } } -void -do_handle_otfname (lua_State *L, struct otfname *oname) { - dump_intfield(L,"lang", oname->lang); - dump_stringfield(L,"name", oname->name); +void do_handle_generic_fpst(lua_State * L, struct generic_fpst *fpst) +{ + int k; + + if (fpst->type > LAST_POSSUB_TYPE_ENUM) { + dump_intfield(L, "type", fpst->type); + } else { + dump_enumfield(L, "type", fpst->type, possub_type_enum); + } + dump_enumfield(L, "format", fpst->format, fpossub_format_enum); + + if (fpst->format == pst_class) { + DUMP_EXACT_STRING_ARRAY("current_class", fpst->nccnt, fpst->nclass); + DUMP_EXACT_STRING_ARRAY("before_class", fpst->bccnt, fpst->bclass); + DUMP_EXACT_STRING_ARRAY("after_class", fpst->fccnt, fpst->fclass); + } else { + DUMP_STRING_ARRAY("current_class", fpst->nccnt, fpst->nclass); + DUMP_STRING_ARRAY("before_class", fpst->bccnt, fpst->bclass); + DUMP_STRING_ARRAY("after_class", fpst->fccnt, fpst->fclass); + } + + lua_checkstack(L, 4); + if (fpst->rule_cnt > 0) { + lua_createtable(L, fpst->rule_cnt, 1); + for (k = 0; k < fpst->rule_cnt; k++) { + lua_pushnumber(L, (k + 1)); + lua_newtable(L); + handle_fpst_rule(L, &(fpst->rules[k]), fpst->format); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "rules"); + } + /*dump_intfield (L,"ticked", fpst->ticked); */ +} + +void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst) +{ + struct generic_fpst *next; + int k = 1; + lua_checkstack(L, 3); + if (fpst->subtable != NULL && fpst->subtable->subtable_name != NULL) { + lua_pushstring(L, fpst->subtable->subtable_name); + } else { + lua_pushnumber(L, k); + k++; + } + lua_createtable(L, 0, 10); + do_handle_generic_fpst(L, fpst); + lua_rawset(L, -3); + next = fpst->next; + while (next != NULL) { + lua_checkstack(L, 3); + if (next->subtable != NULL && next->subtable->subtable_name != NULL) { + lua_pushstring(L, next->subtable->subtable_name); + } else { + lua_pushnumber(L, k); + k++; + } + lua_createtable(L, 0, 10); + do_handle_generic_fpst(L, next); + lua_rawset(L, -3); + next = next->next; + } } -void -handle_otfname (lua_State *L, struct otfname *oname) { - struct otfname *next; - NESTED_TABLE(do_handle_otfname,oname,2); +void do_handle_otfname(lua_State * L, struct otfname *oname) +{ + dump_intfield(L, "lang", oname->lang); + dump_stringfield(L, "name", oname->name); } -void -do_handle_macname (lua_State *L, struct macname *featname) { - dump_intfield(L,"enc", featname->enc); - dump_intfield(L,"lang", featname->lang); - dump_stringfield(L,"name", featname->name); +void handle_otfname(lua_State * L, struct otfname *oname) +{ + struct otfname *next; + NESTED_TABLE(do_handle_otfname, oname, 2); } -void -handle_macname (lua_State *L, struct macname *featname) { - struct macname *next; - NESTED_TABLE(do_handle_macname,featname,3); +void do_handle_macname(lua_State * L, struct macname *featname) +{ + dump_intfield(L, "enc", featname->enc); + dump_intfield(L, "lang", featname->lang); + dump_stringfield(L, "name", featname->name); } -void -do_handle_macsetting (lua_State *L, struct macsetting *settings) { - dump_intfield(L,"setting", settings->setting); - dump_intfield(L,"strid", settings->strid); - dump_intfield(L,"initially_enabled", settings->initially_enabled); - if (settings->setname != NULL) { - lua_newtable(L); - handle_macname(L,settings->setname); - lua_setfield(L,-2,"setname"); - } +void handle_macname(lua_State * L, struct macname *featname) +{ + struct macname *next; + NESTED_TABLE(do_handle_macname, featname, 3); } -void -handle_macsetting (lua_State *L, struct macsetting *settings) { - struct macsetting *next; - NESTED_TABLE(do_handle_macsetting,settings,4); +void do_handle_macsetting(lua_State * L, struct macsetting *settings) +{ + dump_intfield(L, "setting", settings->setting); + dump_intfield(L, "strid", settings->strid); + dump_intfield(L, "initially_enabled", settings->initially_enabled); + if (settings->setname != NULL) { + lua_newtable(L); + handle_macname(L, settings->setname); + lua_setfield(L, -2, "setname"); + } } +void handle_macsetting(lua_State * L, struct macsetting *settings) +{ + struct macsetting *next; + NESTED_TABLE(do_handle_macsetting, settings, 4); +} -void -do_handle_macfeat (lua_State *L, struct macfeat *features) { - dump_intfield(L,"feature", features->feature); - dump_intfield(L,"ismutex", features->ismutex); - dump_intfield(L,"default_setting", features->default_setting); - dump_intfield(L,"strid", features->strid); +void do_handle_macfeat(lua_State * L, struct macfeat *features) +{ - if (features->featname != NULL) { - lua_newtable(L); - handle_macname(L,features->featname); - lua_setfield(L,-2,"featname"); - } + dump_intfield(L, "feature", features->feature); + dump_intfield(L, "ismutex", features->ismutex); + dump_intfield(L, "default_setting", features->default_setting); + dump_intfield(L, "strid", features->strid); - if (features->settings != NULL) { - lua_newtable(L); - handle_macsetting(L,features->settings); - lua_setfield(L,-2,"settings"); - } + if (features->featname != NULL) { + lua_newtable(L); + handle_macname(L, features->featname); + lua_setfield(L, -2, "featname"); + } + + if (features->settings != NULL) { + lua_newtable(L); + handle_macsetting(L, features->settings); + lua_setfield(L, -2, "settings"); + } } -void -handle_macfeat (lua_State *L, struct macfeat *features) { - struct macfeat *next; - NESTED_TABLE(do_handle_macfeat,features,6); +void handle_macfeat(lua_State * L, struct macfeat *features) +{ + struct macfeat *next; + NESTED_TABLE(do_handle_macfeat, features, 6); } @@ -1564,818 +1697,875 @@ handle_macfeat (lua_State *L, struct macfeat *features) { 0x3fff value offset */ /* to be tested */ -void -do_handle_generic_asm (lua_State *L, struct generic_asm *sm) { - int i, k; - - dump_enumfield (L,"type", sm->type, asm_type_enum); - /* backref */ - dump_subtable_name(L, "lookup", sm->subtable); - /* uint8 ticked; */ - lua_newtable(L); - if (sm->flags & asm_vert) { - lua_pushstring(L,"vert"); lua_pushboolean(L,1); lua_rawset(L,-3); - } - if (sm->flags & asm_descending) { - lua_pushstring(L,"descending"); lua_pushboolean(L,1); lua_rawset(L,-3); - } - if (sm->flags & asm_always) { - lua_pushstring(L,"always"); lua_pushboolean(L,1); lua_rawset(L,-3); - } - lua_setfield(L,-2,"flags"); - - if (sm->class_cnt >0) { +void do_handle_generic_asm(lua_State * L, struct generic_asm *sm) +{ + int i, k; + + dump_enumfield(L, "type", sm->type, asm_type_enum); + /* backref */ + dump_subtable_name(L, "lookup", sm->subtable); + /* uint8 ticked; */ lua_newtable(L); - for (i=0; iclass_cnt; i++) { - if (sm->classes[i]!=NULL) { - lua_pushstring(L,sm->classes[i]); - lua_rawseti(L,-2,(i+1)); - } - } - lua_setfield(L,-2,"classes"); - } - if (sm->state_cnt >0) { - lua_newtable(L); - for (i=0; i<(sm->class_cnt * sm->state_cnt); i++) { - struct asm_state as = sm->state[i]; - dump_intfield(L,"next", as.next_state); - dump_intfield(L,"flags", as.flags); - if (sm->type==asm_context) { - lua_newtable(L); - if (as.u.context.mark_lookup!=NULL) - dump_stringfield(L,"mark", as.u.context.mark_lookup->lookup_name); /* backref */ - if (as.u.context.cur_lookup!=NULL) - dump_stringfield(L,"cur", as.u.context.cur_lookup->lookup_name); /* backref */ - lua_setfield(L,-2,"context"); - } else if (sm->type==asm_insert) { - lua_newtable(L); - lua_pushstring(L, as.u.insert.mark_ins); - lua_setfield(L, -2, "mark"); - lua_pushstring(L, as.u.insert.cur_ins); - lua_setfield(L, -2, "cur"); - lua_setfield(L,-2,"insert"); - } else if (sm->type==asm_kern) { - lua_newtable(L); - for (k=0;kScriptPercentScaleDown); - dump_intfield(L,"ScriptScriptPercentScaleDown",MATH->ScriptScriptPercentScaleDown); - dump_intfield(L,"DelimitedSubFormulaMinHeight",MATH->DelimitedSubFormulaMinHeight); - dump_intfield(L,"DisplayOperatorMinHeight",MATH->DisplayOperatorMinHeight); - dump_intfield(L,"MathLeading",MATH->MathLeading); - dump_intfield(L,"AxisHeight",MATH->AxisHeight); - dump_intfield(L,"AccentBaseHeight",MATH->AccentBaseHeight); - dump_intfield(L,"FlattenedAccentBaseHeight",MATH->FlattenedAccentBaseHeight); - dump_intfield(L,"SubscriptShiftDown",MATH->SubscriptShiftDown); - dump_intfield(L,"SubscriptTopMax",MATH->SubscriptTopMax); - dump_intfield(L,"SubscriptBaselineDropMin",MATH->SubscriptBaselineDropMin); - dump_intfield(L,"SuperscriptShiftUp",MATH->SuperscriptShiftUp); - dump_intfield(L,"SuperscriptShiftUpCramped",MATH->SuperscriptShiftUpCramped); - dump_intfield(L,"SuperscriptBottomMin",MATH->SuperscriptBottomMin); - dump_intfield(L,"SuperscriptBaselineDropMax",MATH->SuperscriptBaselineDropMax); - dump_intfield(L,"SubSuperscriptGapMin",MATH->SubSuperscriptGapMin); - dump_intfield(L,"SuperscriptBottomMaxWithSubscript",MATH->SuperscriptBottomMaxWithSubscript); - dump_intfield(L,"SpaceAfterScript",MATH->SpaceAfterScript); - dump_intfield(L,"UpperLimitGapMin",MATH->UpperLimitGapMin); - dump_intfield(L,"UpperLimitBaselineRiseMin",MATH->UpperLimitBaselineRiseMin); - dump_intfield(L,"LowerLimitGapMin",MATH->LowerLimitGapMin); - dump_intfield(L,"LowerLimitBaselineDropMin",MATH->LowerLimitBaselineDropMin); - dump_intfield(L,"StackTopShiftUp",MATH->StackTopShiftUp); - dump_intfield(L,"StackTopDisplayStyleShiftUp",MATH->StackTopDisplayStyleShiftUp); - dump_intfield(L,"StackBottomShiftDown",MATH->StackBottomShiftDown); - dump_intfield(L,"StackBottomDisplayStyleShiftDown",MATH->StackBottomDisplayStyleShiftDown); - dump_intfield(L,"StackGapMin",MATH->StackGapMin); - dump_intfield(L,"StackDisplayStyleGapMin",MATH->StackDisplayStyleGapMin); - dump_intfield(L,"StretchStackTopShiftUp",MATH->StretchStackTopShiftUp); - dump_intfield(L,"StretchStackBottomShiftDown",MATH->StretchStackBottomShiftDown); - dump_intfield(L,"StretchStackGapAboveMin",MATH->StretchStackGapAboveMin); - dump_intfield(L,"StretchStackGapBelowMin",MATH->StretchStackGapBelowMin); - dump_intfield(L,"FractionNumeratorShiftUp",MATH->FractionNumeratorShiftUp); - dump_intfield(L,"FractionNumeratorDisplayStyleShiftUp",MATH->FractionNumeratorDisplayStyleShiftUp); - dump_intfield(L,"FractionDenominatorShiftDown",MATH->FractionDenominatorShiftDown); - dump_intfield(L,"FractionDenominatorDisplayStyleShiftDown",MATH->FractionDenominatorDisplayStyleShiftDown); - dump_intfield(L,"FractionNumeratorGapMin",MATH->FractionNumeratorGapMin); - dump_intfield(L,"FractionNumeratorDisplayStyleGapMin",MATH->FractionNumeratorDisplayStyleGapMin); - dump_intfield(L,"FractionRuleThickness",MATH->FractionRuleThickness); - dump_intfield(L,"FractionDenominatorGapMin",MATH->FractionDenominatorGapMin); - dump_intfield(L,"FractionDenominatorDisplayStyleGapMin",MATH->FractionDenominatorDisplayStyleGapMin); - dump_intfield(L,"SkewedFractionHorizontalGap",MATH->SkewedFractionHorizontalGap); - dump_intfield(L,"SkewedFractionVerticalGap",MATH->SkewedFractionVerticalGap); - dump_intfield(L,"OverbarVerticalGap",MATH->OverbarVerticalGap); - dump_intfield(L,"OverbarRuleThickness",MATH->OverbarRuleThickness); - dump_intfield(L,"OverbarExtraAscender",MATH->OverbarExtraAscender); - dump_intfield(L,"UnderbarVerticalGap",MATH->UnderbarVerticalGap); - dump_intfield(L,"UnderbarRuleThickness",MATH->UnderbarRuleThickness); - dump_intfield(L,"UnderbarExtraDescender",MATH->UnderbarExtraDescender); - dump_intfield(L,"RadicalVerticalGap",MATH->RadicalVerticalGap); - dump_intfield(L,"RadicalDisplayStyleVerticalGap",MATH->RadicalDisplayStyleVerticalGap); - dump_intfield(L,"RadicalRuleThickness",MATH->RadicalRuleThickness); - dump_intfield(L,"RadicalExtraAscender",MATH->RadicalExtraAscender); - dump_intfield(L,"RadicalKernBeforeDegree",MATH->RadicalKernBeforeDegree); - dump_intfield(L,"RadicalKernAfterDegree",MATH->RadicalKernAfterDegree); - dump_intfield(L,"RadicalDegreeBottomRaisePercent",MATH->RadicalDegreeBottomRaisePercent); - dump_intfield(L,"MinConnectorOverlap",MATH->MinConnectorOverlap); + if (sm->flags & asm_vert) { + lua_pushstring(L, "vert"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + if (sm->flags & asm_descending) { + lua_pushstring(L, "descending"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + if (sm->flags & asm_always) { + lua_pushstring(L, "always"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "flags"); + + if (sm->class_cnt > 0) { + lua_newtable(L); + for (i = 0; i < sm->class_cnt; i++) { + if (sm->classes[i] != NULL) { + lua_pushstring(L, sm->classes[i]); + lua_rawseti(L, -2, (i + 1)); + } + } + lua_setfield(L, -2, "classes"); + } + if (sm->state_cnt > 0) { + lua_newtable(L); + for (i = 0; i < (sm->class_cnt * sm->state_cnt); i++) { + struct asm_state as = sm->state[i]; + dump_intfield(L, "next", as.next_state); + dump_intfield(L, "flags", as.flags); + if (sm->type == asm_context) { + lua_newtable(L); + if (as.u.context.mark_lookup != NULL) + dump_stringfield(L, "mark", as.u.context.mark_lookup->lookup_name); /* backref */ + if (as.u.context.cur_lookup != NULL) + dump_stringfield(L, "cur", as.u.context.cur_lookup->lookup_name); /* backref */ + lua_setfield(L, -2, "context"); + } else if (sm->type == asm_insert) { + lua_newtable(L); + lua_pushstring(L, as.u.insert.mark_ins); + lua_setfield(L, -2, "mark"); + lua_pushstring(L, as.u.insert.cur_ins); + lua_setfield(L, -2, "cur"); + lua_setfield(L, -2, "insert"); + } else if (sm->type == asm_kern) { + lua_newtable(L); + for (k = 0; k < as.u.kern.kcnt; k++) { + lua_pushnumber(L, as.u.kern.kerns[k]); + lua_rawseti(L, -2, (k + 1)); + } + lua_setfield(L, -2, "kerns"); + } + } + lua_setfield(L, -2, "states"); + } +} + +void handle_generic_asm(lua_State * L, struct generic_asm *sm) +{ + struct generic_asm *next; + NESTED_TABLE(do_handle_generic_asm, sm, 6); +} + + + + +void handle_MATH(lua_State * L, struct MATH *MATH) +{ + dump_intfield(L, "ScriptPercentScaleDown", MATH->ScriptPercentScaleDown); + dump_intfield(L, "ScriptScriptPercentScaleDown", + MATH->ScriptScriptPercentScaleDown); + dump_intfield(L, "DelimitedSubFormulaMinHeight", + MATH->DelimitedSubFormulaMinHeight); + dump_intfield(L, "DisplayOperatorMinHeight", + MATH->DisplayOperatorMinHeight); + dump_intfield(L, "MathLeading", MATH->MathLeading); + dump_intfield(L, "AxisHeight", MATH->AxisHeight); + dump_intfield(L, "AccentBaseHeight", MATH->AccentBaseHeight); + dump_intfield(L, "FlattenedAccentBaseHeight", + MATH->FlattenedAccentBaseHeight); + dump_intfield(L, "SubscriptShiftDown", MATH->SubscriptShiftDown); + dump_intfield(L, "SubscriptTopMax", MATH->SubscriptTopMax); + dump_intfield(L, "SubscriptBaselineDropMin", + MATH->SubscriptBaselineDropMin); + dump_intfield(L, "SuperscriptShiftUp", MATH->SuperscriptShiftUp); + dump_intfield(L, "SuperscriptShiftUpCramped", + MATH->SuperscriptShiftUpCramped); + dump_intfield(L, "SuperscriptBottomMin", MATH->SuperscriptBottomMin); + dump_intfield(L, "SuperscriptBaselineDropMax", + MATH->SuperscriptBaselineDropMax); + dump_intfield(L, "SubSuperscriptGapMin", MATH->SubSuperscriptGapMin); + dump_intfield(L, "SuperscriptBottomMaxWithSubscript", + MATH->SuperscriptBottomMaxWithSubscript); + dump_intfield(L, "SpaceAfterScript", MATH->SpaceAfterScript); + dump_intfield(L, "UpperLimitGapMin", MATH->UpperLimitGapMin); + dump_intfield(L, "UpperLimitBaselineRiseMin", + MATH->UpperLimitBaselineRiseMin); + dump_intfield(L, "LowerLimitGapMin", MATH->LowerLimitGapMin); + dump_intfield(L, "LowerLimitBaselineDropMin", + MATH->LowerLimitBaselineDropMin); + dump_intfield(L, "StackTopShiftUp", MATH->StackTopShiftUp); + dump_intfield(L, "StackTopDisplayStyleShiftUp", + MATH->StackTopDisplayStyleShiftUp); + dump_intfield(L, "StackBottomShiftDown", MATH->StackBottomShiftDown); + dump_intfield(L, "StackBottomDisplayStyleShiftDown", + MATH->StackBottomDisplayStyleShiftDown); + dump_intfield(L, "StackGapMin", MATH->StackGapMin); + dump_intfield(L, "StackDisplayStyleGapMin", MATH->StackDisplayStyleGapMin); + dump_intfield(L, "StretchStackTopShiftUp", MATH->StretchStackTopShiftUp); + dump_intfield(L, "StretchStackBottomShiftDown", + MATH->StretchStackBottomShiftDown); + dump_intfield(L, "StretchStackGapAboveMin", MATH->StretchStackGapAboveMin); + dump_intfield(L, "StretchStackGapBelowMin", MATH->StretchStackGapBelowMin); + dump_intfield(L, "FractionNumeratorShiftUp", + MATH->FractionNumeratorShiftUp); + dump_intfield(L, "FractionNumeratorDisplayStyleShiftUp", + MATH->FractionNumeratorDisplayStyleShiftUp); + dump_intfield(L, "FractionDenominatorShiftDown", + MATH->FractionDenominatorShiftDown); + dump_intfield(L, "FractionDenominatorDisplayStyleShiftDown", + MATH->FractionDenominatorDisplayStyleShiftDown); + dump_intfield(L, "FractionNumeratorGapMin", MATH->FractionNumeratorGapMin); + dump_intfield(L, "FractionNumeratorDisplayStyleGapMin", + MATH->FractionNumeratorDisplayStyleGapMin); + dump_intfield(L, "FractionRuleThickness", MATH->FractionRuleThickness); + dump_intfield(L, "FractionDenominatorGapMin", + MATH->FractionDenominatorGapMin); + dump_intfield(L, "FractionDenominatorDisplayStyleGapMin", + MATH->FractionDenominatorDisplayStyleGapMin); + dump_intfield(L, "SkewedFractionHorizontalGap", + MATH->SkewedFractionHorizontalGap); + dump_intfield(L, "SkewedFractionVerticalGap", + MATH->SkewedFractionVerticalGap); + dump_intfield(L, "OverbarVerticalGap", MATH->OverbarVerticalGap); + dump_intfield(L, "OverbarRuleThickness", MATH->OverbarRuleThickness); + dump_intfield(L, "OverbarExtraAscender", MATH->OverbarExtraAscender); + dump_intfield(L, "UnderbarVerticalGap", MATH->UnderbarVerticalGap); + dump_intfield(L, "UnderbarRuleThickness", MATH->UnderbarRuleThickness); + dump_intfield(L, "UnderbarExtraDescender", MATH->UnderbarExtraDescender); + dump_intfield(L, "RadicalVerticalGap", MATH->RadicalVerticalGap); + dump_intfield(L, "RadicalDisplayStyleVerticalGap", + MATH->RadicalDisplayStyleVerticalGap); + dump_intfield(L, "RadicalRuleThickness", MATH->RadicalRuleThickness); + dump_intfield(L, "RadicalExtraAscender", MATH->RadicalExtraAscender); + dump_intfield(L, "RadicalKernBeforeDegree", MATH->RadicalKernBeforeDegree); + dump_intfield(L, "RadicalKernAfterDegree", MATH->RadicalKernAfterDegree); + dump_intfield(L, "RadicalDegreeBottomRaisePercent", + MATH->RadicalDegreeBottomRaisePercent); + dump_intfield(L, "MinConnectorOverlap", MATH->MinConnectorOverlap); } /* the handling of BASE is untested, no font */ -void handle_baselangextent (lua_State *L, struct baselangextent *ble); +void handle_baselangextent(lua_State * L, struct baselangextent *ble); -void -do_handle_baselangextent (lua_State *L, struct baselangextent *ble) { - dump_tag(L,"tag",ble->lang); - dump_intfield(L,"ascent",ble->ascent); - dump_intfield(L,"descent",ble->descent); - lua_newtable(L); - handle_baselangextent(L, ble->features); - lua_setfield(L,-2,"features"); +void do_handle_baselangextent(lua_State * L, struct baselangextent *ble) +{ + dump_tag(L, "tag", ble->lang); + dump_intfield(L, "ascent", ble->ascent); + dump_intfield(L, "descent", ble->descent); + lua_newtable(L); + handle_baselangextent(L, ble->features); + lua_setfield(L, -2, "features"); } -void handle_baselangextent (lua_State *L, struct baselangextent *ble) { - struct baselangextent *next; - NESTED_TABLE(do_handle_baselangextent,ble,4); +void handle_baselangextent(lua_State * L, struct baselangextent *ble) +{ + struct baselangextent *next; + NESTED_TABLE(do_handle_baselangextent, ble, 4); } -void handle_base (lua_State *L, struct Base *Base) { - int i; - struct basescript *next = Base->scripts; - lua_newtable(L); - for ( i=0; ibaseline_cnt; i++ ) { - lua_pushstring(L,make_tag_string(Base->baseline_tags[i])); - lua_rawseti(L,-2,(i+1)); - } - lua_setfield(L,-2,"tags"); - if (next != NULL) { +void handle_base(lua_State * L, struct Base *Base) +{ + int i; + struct basescript *next = Base->scripts; lua_newtable(L); - while (next != NULL) { - lua_pushstring(L,make_tag_string(next->script)); - lua_newtable(L); - dump_intfield(L, "default_baseline", (next->def_baseline+1)) ; - lua_newtable(L); - for ( i=0; ibaseline_cnt; i++ ) { - lua_pushnumber(L, next->baseline_pos[i]) ; - lua_rawseti(L,-2, (i+1)); - } - lua_setfield(L, -2, "baseline"); - lua_newtable(L); - handle_baselangextent(L, next->langs); - lua_setfield(L, -2, "lang"); - lua_rawset(L,-3); - next = next->next; - } - lua_setfield(L,-2,"scripts"); - } + for (i = 0; i < Base->baseline_cnt; i++) { + lua_pushstring(L, make_tag_string(Base->baseline_tags[i])); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "tags"); + if (next != NULL) { + lua_newtable(L); + while (next != NULL) { + lua_pushstring(L, make_tag_string(next->script)); + lua_newtable(L); + dump_intfield(L, "default_baseline", (next->def_baseline + 1)); + lua_newtable(L); + for (i = 0; i < Base->baseline_cnt; i++) { + if (next->baseline_pos != NULL) /* default omitted */ + lua_pushnumber(L, next->baseline_pos[i]); + else + lua_pushnumber(L, 0); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "baseline"); + lua_newtable(L); + handle_baselangextent(L, next->langs); + lua_setfield(L, -2, "lang"); + lua_rawset(L, -3); + next = next->next; + } + lua_setfield(L, -2, "scripts"); + } } -void -handle_axismap (lua_State *L, struct axismap *am) { - int i; - lua_checkstack(L,3); - lua_newtable(L); - for (i=0;ipoints;i++) { - lua_pushnumber(L, am->blends[i] ) ; - lua_rawseti(L,-2, (i+1)); - } - lua_setfield(L,-2,"blends"); - lua_newtable(L); - for (i=0;ipoints;i++) { - lua_pushnumber(L, am->designs[i] ) ; - lua_rawseti(L,-2, (i+1)); - } - lua_setfield(L,-2,"designs"); - dump_realfield(L, "min", am->min) ; - dump_realfield(L, "def", am->def) ; - dump_realfield(L, "max", am->max) ; - if (am->axisnames != NULL ){ +void handle_axismap(lua_State * L, struct axismap *am) +{ + int i; + lua_checkstack(L, 3); lua_newtable(L); - handle_macname(L, am->axisnames); - lua_setfield(L,-2,"axisnames"); - } -} + for (i = 0; i < am->points; i++) { + lua_pushnumber(L, am->blends[i]); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "blends"); + lua_newtable(L); + for (i = 0; i < am->points; i++) { + lua_pushnumber(L, am->designs[i]); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "designs"); + dump_realfield(L, "min", am->min); + dump_realfield(L, "def", am->def); + dump_realfield(L, "max", am->max); + if (am->axisnames != NULL) { + lua_newtable(L); + handle_macname(L, am->axisnames); + lua_setfield(L, -2, "axisnames"); + } +} -void -handle_mmset (lua_State *L, struct mmset *mm) { - int i, k; - lua_newtable(L); - for (i=0;iaxis_count;i++) { - lua_pushstring(L, mm->axes[i]) ; - lua_rawseti(L,-2, (i+1)); - } - lua_setfield(L,-2,"axes"); - - dump_intfield(L,"instance_count",mm->instance_count); - /* SplineFont *normal; */ /* this is the parent */ - if (mm->instance_count>0) { +void handle_mmset(lua_State * L, struct mmset *mm) +{ + int i, k; lua_newtable(L); - for (i=0;iinstance_count*mm->axis_count;i++) { - lua_pushnumber(L, mm->positions[i]) ; - lua_rawseti(L,-2, (i+1)); + for (i = 0; i < mm->axis_count; i++) { + lua_pushstring(L, mm->axes[i]); + lua_rawseti(L, -2, (i + 1)); } - lua_setfield(L,-2,"positions"); + lua_setfield(L, -2, "axes"); + + dump_intfield(L, "instance_count", mm->instance_count); + /* SplineFont *normal; *//* this is the parent */ + if (mm->instance_count > 0) { + lua_newtable(L); + for (i = 0; i < mm->instance_count * mm->axis_count; i++) { + lua_pushnumber(L, mm->positions[i]); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "positions"); - /* better not to do this */ + /* better not to do this */ #if 0 - { - struct mmset *mmsave ; - lua_newtable(L); - for (i=0;iinstance_count;i++) { - lua_checkstack(L,20); - lua_createtable(L,0,60); - mmsave = mm->instances[i]->mm; - mm->instances[i]->mm = NULL; - handle_splinefont(L, mm->instances[i]); - mm->instances[i]->mm = mmsave; - lua_rawseti(L,-2, (i+1)); - } - lua_setfield(L,-2,"instances"); - } + { + struct mmset *mmsave; + lua_newtable(L); + for (i = 0; i < mm->instance_count; i++) { + lua_checkstack(L, 20); + lua_createtable(L, 0, 60); + mmsave = mm->instances[i]->mm; + mm->instances[i]->mm = NULL; + handle_splinefont(L, mm->instances[i]); + mm->instances[i]->mm = mmsave; + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "instances"); + } #endif - lua_newtable(L); - for (i=0;iinstance_count;i++) { - lua_pushnumber(L, mm->defweights[i]) ; - lua_rawseti(L,-2, (i+1)); - } - lua_setfield(L,-2,"defweights"); - } - - if (mm->axismaps != NULL) { - lua_newtable(L); - for (i=0;iaxis_count;i++) { - lua_newtable(L); - handle_axismap(L, &(mm->axismaps[i])); - lua_rawseti(L, -2, (i+1)); + lua_newtable(L); + for (i = 0; i < mm->instance_count; i++) { + lua_pushnumber(L, mm->defweights[i]); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "defweights"); } - lua_setfield(L,-2,"axismaps"); - } - dump_stringfield(L,"cdv",mm->cdv); - dump_stringfield(L,"ndv",mm->ndv); - dump_intfield(L,"named_instance_count",mm->named_instance_count); - if (mm->named_instance_count>0) { - lua_newtable(L); - for (i=0; inamed_instance_count;i++) { - struct named_instance *ni = &(mm->named_instances[i]); + if (mm->axismaps != NULL) { lua_newtable(L); + for (i = 0; i < mm->axis_count; i++) { + lua_newtable(L); + handle_axismap(L, &(mm->axismaps[i])); + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "axismaps"); + } + dump_stringfield(L, "cdv", mm->cdv); + dump_stringfield(L, "ndv", mm->ndv); + dump_intfield(L, "named_instance_count", mm->named_instance_count); + if (mm->named_instance_count > 0) { + lua_newtable(L); + for (i = 0; i < mm->named_instance_count; i++) { + struct named_instance *ni = &(mm->named_instances[i]); + lua_newtable(L); + + lua_newtable(L); + for (k = 0; k <= mm->axis_count; k++) { + lua_pushnumber(L, ni->coords[k]); + lua_rawseti(L, -2, (k + 1)); + } + lua_setfield(L, -2, "coords"); + + lua_newtable(L); + handle_macname(L, ni->names); + lua_setfield(L, -2, "names"); + + lua_rawseti(L, -2, (i + 1)); + } + lua_setfield(L, -2, "named_instances"); + } + /* unsigned int changed: 1; */ + dump_intfield(L, "apple", mm->apple); +} + + + +void handle_splinefont(lua_State * L, struct splinefont *sf) +{ + int k; + int fix_notdef = 0; + int l = -1; + + dump_stringfield(L, "table_version", LUA_OTF_VERSION); + dump_stringfield(L, "fontname", sf->fontname); + dump_stringfield(L, "fullname", sf->fullname); + dump_stringfield(L, "familyname", sf->familyname); + dump_stringfield(L, "weight", sf->weight); + dump_stringfield(L, "copyright", sf->copyright); + dump_stringfield(L, "filename", sf->filename); + /* dump_stringfield(L,"defbasefilename", sf->defbasefilename); */ + dump_stringfield(L, "version", sf->version); + dump_floatfield(L, "italicangle", sf->italicangle); + dump_floatfield(L, "upos", sf->upos); + dump_floatfield(L, "uwidth", sf->uwidth); + dump_intfield(L, "ascent", sf->ascent); + dump_intfield(L, "descent", sf->descent); + dump_intfield(L, "uniqueid", sf->uniqueid); + dump_intfield(L, "glyphcnt", sf->glyphcnt); + dump_intfield(L, "glyphmax", sf->glyphmax); + dump_intfield(L, "units_per_em", sf->units_per_em); + + if (sf->possub != NULL) { lua_newtable(L); - for (k=0;k<=mm->axis_count;k++) { - lua_pushnumber(L,ni->coords[k]); - lua_rawseti(L,-2,(k+1)); + handle_generic_fpst(L, sf->possub); + lua_setfield(L, -2, "lookups"); + } + + lua_checkstack(L, 4); + lua_createtable(L, sf->glyphcnt, 0); + + /* This after-the-fact type discovery is not brilliant, + I should really add a 'format' key in the structure */ + if ((sf->origname != NULL) && + (strmatch(sf->origname + strlen(sf->origname) - 4, ".pfa") == 0 || + strmatch(sf->origname + strlen(sf->origname) - 4, ".pfb") == 0)) { + fix_notdef = 1; + } + + if (fix_notdef) { + /* some code to ensure that the .notdef ends up in slot 0 + (this will actually be enforced by the CFF writer) */ + for (k = 0; k < sf->glyphcnt; k++) { + if (sf->glyphs[k]) { + if (strcmp(sf->glyphs[k]->name, ".notdef") == 0) { + l = k; + } + } + } + if (l == -1) { /* fake a .notdef at the end */ + l = sf->glyphcnt; + } + for (k = 0; k < l; k++) { + if (sf->glyphs[k]) { + lua_pushnumber(L, (k + 1)); + lua_createtable(L, 0, 12); + handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics); + lua_rawset(L, -3); + } + } + if (sf->glyphs != NULL && l < sf->glyphcnt) { + lua_pushnumber(L, 0); + if (sf->glyphs[l]) { + lua_createtable(L, 0, 12); + handle_splinechar(L, sf->glyphs[l], sf->hasvmetrics); + } else { + lua_createtable(L, 0, 0); + } + lua_rawset(L, -3); + } + } + if ((l + 1) < sf->glyphcnt) { + for (k = (l + 1); k < sf->glyphcnt; k++) { + if (sf->glyphs[k]) { + lua_pushnumber(L, k); + lua_createtable(L, 0, 12); + handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics); + lua_rawset(L, -3); + } } - lua_setfield(L,-2,"coords"); + } + lua_setfield(L, -2, "glyphs"); + + /* dump_intfield(L,"changed", sf->changed); */ + dump_intfield(L, "hasvmetrics", sf->hasvmetrics); + dump_intfield(L, "onlybitmaps", sf->onlybitmaps); + dump_intfield(L, "serifcheck", sf->serifcheck); + dump_intfield(L, "isserif", sf->isserif); + dump_intfield(L, "issans", sf->issans); + dump_intfield(L, "encodingchanged", sf->encodingchanged); + dump_intfield(L, "strokedfont", sf->strokedfont); + dump_intfield(L, "use_typo_metrics", sf->use_typo_metrics); + dump_intfield(L, "weight_width_slope_only", sf->weight_width_slope_only); + dump_intfield(L, "head_optimized_for_cleartype", + sf->head_optimized_for_cleartype); + + dump_enumfield(L, "uni_interp", (sf->uni_interp + 1), uni_interp_enum); + + if (sf->map != NULL) { + lua_newtable(L); + handle_encmap(L, sf->map, l); + lua_setfield(L, -2, "map"); + } + + dump_stringfield(L, "origname", sf->origname); /* new */ + if (sf->private != NULL) { lua_newtable(L); - handle_macname(L, ni->names); - lua_setfield(L,-2,"names"); + handle_psdict(L, sf->private); + lua_setfield(L, -2, "private"); + } - lua_rawseti(L,-2,(i+1)); - } - lua_setfield(L,-2,"named_instances"); - } - /* unsigned int changed: 1; */ - dump_intfield(L,"apple",mm->apple); -} + dump_stringfield(L, "xuid", sf->xuid); + lua_createtable(L, 0, 40); + handle_pfminfo(L, sf->pfminfo); + lua_setfield(L, -2, "pfminfo"); + if (sf->names != NULL) { + lua_newtable(L); + handle_ttflangname(L, sf->names); + lua_setfield(L, -2, "names"); + } -void -handle_splinefont(lua_State *L, struct splinefont *sf) { - int k; - int fix_notdef = 0; - int l = -1; - - dump_stringfield(L,"table_version", LUA_OTF_VERSION); - dump_stringfield(L,"fontname", sf->fontname); - dump_stringfield(L,"fullname", sf->fullname); - dump_stringfield(L,"familyname", sf->familyname); - dump_stringfield(L,"weight", sf->weight); - dump_stringfield(L,"copyright", sf->copyright); - dump_stringfield(L,"filename", sf->filename); - /* dump_stringfield(L,"defbasefilename", sf->defbasefilename); */ - dump_stringfield(L,"version", sf->version); - dump_floatfield (L,"italicangle", sf->italicangle); - dump_floatfield (L,"upos", sf->upos); - dump_floatfield (L,"uwidth", sf->uwidth); - dump_intfield (L,"ascent", sf->ascent); - dump_intfield (L,"descent", sf->descent); - dump_intfield (L,"uniqueid", sf->uniqueid); - dump_intfield (L,"glyphcnt", sf->glyphcnt); - dump_intfield (L,"glyphmax", sf->glyphmax); - dump_intfield (L,"units_per_em", sf->units_per_em); - - if (sf->possub != NULL) { - lua_newtable(L); - handle_generic_fpst(L,sf->possub); - lua_setfield(L,-2,"lookups"); - } - - lua_checkstack(L,4); - lua_createtable(L,sf->glyphcnt,0); - - /* This after-the-fact type discovery is not brilliant, - I should really add a 'format' key in the structure */ - if ((sf->origname != NULL) && - (strmatch(sf->origname+strlen(sf->origname)-4, ".pfa")==0 || - strmatch(sf->origname+strlen(sf->origname)-4, ".pfb")==0)) { - fix_notdef = 1; - } - - if (fix_notdef) { - /* some code to ensure that the .notdef ends up in slot 0 - (this will actually be enforced by the CFF writer) */ - for (k=0;kglyphcnt;k++) { - if (sf->glyphs[k]) { - if (strcmp(sf->glyphs[k]->name,".notdef") == 0) { - l = k; + lua_createtable(L, 0, 4); + dump_stringfield(L, "registry", sf->cidregistry); + dump_stringfield(L, "ordering", sf->ordering); + dump_intfield(L, "version", sf->cidversion); + dump_intfield(L, "supplement", sf->supplement); + lua_setfield(L, -2, "cidinfo"); + + /* SplineFont *cidmaster *//* parent in a subfont */ + if (sf->subfontcnt > 0) { + lua_createtable(L, sf->subfontcnt, 0); + for (k = 0; k < sf->subfontcnt; k++) { + lua_checkstack(L, 10); + lua_newtable(L); + handle_splinefont(L, sf->subfonts[k]); + lua_rawseti(L, -2, (k + 1)); } - } - } - if (l==-1) { /* fake a .notdef at the end */ - l = sf->glyphcnt; - } - for (k=0;kglyphs[k]) { - handle_splinechar(L,sf->glyphs[k], sf->hasvmetrics); - } - lua_rawset(L,-3); - } - if (sf->glyphs != NULL && lglyphcnt) { - lua_pushnumber(L,0); - lua_createtable(L,0,12); - if (sf->glyphs[l]) { - handle_splinechar(L,sf->glyphs[l], sf->hasvmetrics); - } - lua_rawset(L,-3); - } - } - if ((l+1)glyphcnt) { - for (k=(l+1);kglyphcnt;k++) { - lua_pushnumber(L,k); - lua_createtable(L,0,12); - if (sf->glyphs[k]) { - handle_splinechar(L,sf->glyphs[k], sf->hasvmetrics); - } - lua_rawset(L,-3); - } - } - lua_setfield(L,-2,"glyphs"); - - /* dump_intfield(L,"changed", sf->changed); */ - dump_intfield(L,"hasvmetrics", sf->hasvmetrics); - dump_intfield(L,"onlybitmaps", sf->onlybitmaps); - dump_intfield(L,"serifcheck", sf->serifcheck); - dump_intfield(L,"isserif", sf->isserif); - dump_intfield(L,"issans", sf->issans); - dump_intfield(L,"encodingchanged", sf->encodingchanged); - dump_intfield(L,"strokedfont", sf->strokedfont); - dump_intfield(L,"use_typo_metrics", sf->use_typo_metrics); - dump_intfield(L,"weight_width_slope_only", sf->weight_width_slope_only); - dump_intfield(L,"head_optimized_for_cleartype",sf->head_optimized_for_cleartype); - - dump_enumfield(L,"uni_interp", (sf->uni_interp+1), uni_interp_enum); - - if (sf->map != NULL ) { - lua_newtable(L); - handle_encmap(L,sf->map, l); - lua_setfield(L,-2,"map"); - } + lua_setfield(L, -2, "subfonts"); + } - dump_stringfield(L,"origname", sf->origname); /* new */ + dump_stringfield(L, "comments", sf->comments); + dump_stringfield(L, "fontlog", sf->fontlog); - if (sf->private != NULL) { - lua_newtable(L); - handle_psdict(L, sf->private); - lua_setfield(L,-2,"private"); - } - - dump_stringfield(L,"xuid", sf->xuid); - - lua_createtable(L,0,40); - handle_pfminfo(L,sf->pfminfo); - lua_setfield(L,-2,"pfminfo"); - - if (sf->names != NULL) { - lua_newtable(L); - handle_ttflangname(L,sf->names); - lua_setfield(L,-2,"names"); - } - - lua_createtable(L,0,4); - dump_stringfield(L,"registry", sf->cidregistry); - dump_stringfield(L,"ordering", sf->ordering); - dump_intfield (L,"version", sf->cidversion); - dump_intfield (L,"supplement", sf->supplement); - lua_setfield(L,-2,"cidinfo"); - - /* SplineFont *cidmaster */ /* parent in a subfont */ - if (sf->subfontcnt>0) { - lua_createtable(L,sf->subfontcnt,0); - for (k=0;ksubfontcnt;k++) { - lua_checkstack(L,10); - lua_newtable(L); - handle_splinefont(L,sf->subfonts[k]); - lua_rawseti(L,-2,(k+1)); - } - lua_setfield(L,-2,"subfonts"); - } - - dump_stringfield(L,"comments", sf->comments); - dump_stringfield(L,"fontlog", sf->fontlog); - - if (sf->cvt_names != NULL) { - lua_newtable(L); - for (k=0; sf->cvt_names[k]!=END_CVT_NAMES; ++k) { - lua_pushstring(L, sf->cvt_names[k]); - lua_rawseti(L,-2,(k+1)); + if (sf->cvt_names != NULL) { + lua_newtable(L); + for (k = 0; sf->cvt_names[k] != END_CVT_NAMES; ++k) { + lua_pushstring(L, sf->cvt_names[k]); + lua_rawseti(L, -2, (k + 1)); + } + lua_setfield(L, -2, "cvt_names"); } - lua_setfield(L,-2,"cvt_names"); - } - if (sf->ttf_tables != NULL) { - lua_newtable(L); - handle_ttf_table(L,sf->ttf_tables); - lua_setfield(L,-2,"ttf_tables"); - } + if (sf->ttf_tables != NULL) { + lua_newtable(L); + handle_ttf_table(L, sf->ttf_tables); + lua_setfield(L, -2, "ttf_tables"); + } - if (sf->ttf_tab_saved != NULL) { - lua_newtable(L); - handle_ttf_table(L,sf->ttf_tab_saved); - lua_setfield(L,-2,"ttf_tab_saved"); - } + if (sf->ttf_tab_saved != NULL) { + lua_newtable(L); + handle_ttf_table(L, sf->ttf_tab_saved); + lua_setfield(L, -2, "ttf_tab_saved"); + } - if (sf->texdata.type != tex_unset) { - lua_newtable(L); - dump_enumfield(L,"type", sf->texdata.type, tex_type_enum); - lua_newtable(L); - for (k=0;k<22;k++) { - lua_pushnumber(L,k); - lua_pushnumber(L,sf->texdata.params[k]); - lua_rawset(L,-3); - } - lua_setfield(L,-2,"params"); - lua_setfield(L,-2,"texdata"); - } - if (sf->anchor != NULL) { - lua_newtable(L); - handle_anchorclass(L,sf->anchor); - lua_setfield(L,-2,"anchor_classes"); - } - if (sf->kerns != NULL) { - lua_newtable(L); - handle_kernclass(L,sf->kerns); - lua_setfield(L,-2,"kerns"); - } - if (sf->vkerns != NULL) { - lua_newtable(L); - handle_kernclass(L,sf->vkerns); - lua_setfield(L,-2,"vkerns"); - } - if (sf->gsub_lookups != NULL) { - lua_newtable(L); - handle_lookup(L,sf->gsub_lookups); - lua_setfield(L,-2,"gsub"); - } - if (sf->gpos_lookups != NULL) { - lua_newtable(L); - handle_lookup(L,sf->gpos_lookups); - lua_setfield(L,-2,"gpos"); - } + if (sf->texdata.type != tex_unset) { + lua_newtable(L); + dump_enumfield(L, "type", sf->texdata.type, tex_type_enum); + lua_newtable(L); + for (k = 0; k < 22; k++) { + lua_pushnumber(L, k); + lua_pushnumber(L, sf->texdata.params[k]); + lua_rawset(L, -3); + } + lua_setfield(L, -2, "params"); + lua_setfield(L, -2, "texdata"); + } + if (sf->anchor != NULL) { + lua_newtable(L); + handle_anchorclass(L, sf->anchor); + lua_setfield(L, -2, "anchor_classes"); + } + if (sf->kerns != NULL) { + lua_newtable(L); + handle_kernclass(L, sf->kerns); + lua_setfield(L, -2, "kerns"); + } + if (sf->vkerns != NULL) { + lua_newtable(L); + handle_kernclass(L, sf->vkerns); + lua_setfield(L, -2, "vkerns"); + } + if (sf->gsub_lookups != NULL) { + lua_newtable(L); + handle_lookup(L, sf->gsub_lookups, sf); + lua_setfield(L, -2, "gsub"); + } + if (sf->gpos_lookups != NULL) { + lua_newtable(L); + handle_lookup(L, sf->gpos_lookups, sf); + lua_setfield(L, -2, "gpos"); + } - if (sf->sm != NULL) { - lua_newtable(L); - handle_generic_asm(L,sf->sm); - lua_setfield(L,-2,"sm"); - } - if (sf->features != NULL) { - lua_newtable(L); - handle_macfeat(L,sf->features); - lua_setfield(L,-2,"features"); - } - if (sf->mm != NULL) { - lua_newtable(L); - handle_mmset (L,sf->mm); - lua_setfield(L,-2,"mm"); - } - dump_stringfield(L,"chosenname", sf->chosenname); - - dump_intfield(L,"macstyle", sf->macstyle); - dump_stringfield(L,"fondname", sf->fondname); - - dump_intfield(L,"design_size", sf->design_size); - dump_intfield(L,"fontstyle_id", sf->fontstyle_id); - - if (sf->fontstyle_name != NULL) { - lua_newtable(L); - handle_otfname(L,sf->fontstyle_name); - lua_setfield(L,-2,"fontstyle_name"); - } - - dump_intfield(L,"design_range_bottom",sf->design_range_bottom); - dump_intfield(L,"design_range_top", sf->design_range_top); - dump_floatfield(L,"strokewidth", sf->strokewidth); - - if (sf->mark_class_cnt>0) { - lua_newtable(L); - for ( k=0; kmark_class_cnt; ++k ) { - lua_pushnumber(L,(k+1)); - lua_pushstring(L,sf->mark_classes[k]); - lua_rawset(L,-3); + if (sf->sm != NULL) { + lua_newtable(L); + handle_generic_asm(L, sf->sm); + lua_setfield(L, -2, "sm"); + } + if (sf->features != NULL) { + lua_newtable(L); + handle_macfeat(L, sf->features); + lua_setfield(L, -2, "features"); } - lua_setfield(L,-1,"mark_classes"); + if (sf->mm != NULL) { + lua_newtable(L); + handle_mmset(L, sf->mm); + lua_setfield(L, -2, "mm"); + } + dump_stringfield(L, "chosenname", sf->chosenname); - lua_newtable(L); - for ( k=0; kmark_class_cnt; ++k ) { - lua_pushnumber(L,(k+1)); - lua_pushstring(L,sf->mark_class_names[k]); - lua_rawset(L,-3); + dump_intfield(L, "macstyle", sf->macstyle); + dump_stringfield(L, "fondname", sf->fondname); + + dump_intfield(L, "design_size", sf->design_size); + dump_intfield(L, "fontstyle_id", sf->fontstyle_id); + + if (sf->fontstyle_name != NULL) { + lua_newtable(L); + handle_otfname(L, sf->fontstyle_name); + lua_setfield(L, -2, "fontstyle_name"); } - lua_setfield(L,-1,"mark_class_names"); - } - - dump_intfield(L,"creationtime", sf->creationtime); - dump_intfield(L,"modificationtime", sf->modificationtime); - dump_intfield(L,"os2_version", sf->os2_version); - dump_intfield(L,"sfd_version", sf->sfd_version); + dump_intfield(L, "design_range_bottom", sf->design_range_bottom); + dump_intfield(L, "design_range_top", sf->design_range_top); + dump_floatfield(L, "strokewidth", sf->strokewidth); - if (sf->MATH != NULL) { - lua_newtable(L); - handle_MATH(L, sf->MATH); - lua_setfield(L,-2,"math"); - } - - if (sf->loadvalidation_state != 0) { - int val, st; - lua_newtable(L); - val = 1; - st = sf->loadvalidation_state; - if (st & lvs_bad_ps_fontname) { - lua_pushliteral(L, "bad_ps_fontname"); lua_rawseti(L,-2,val++); + if (sf->mark_class_cnt > 0) { + lua_newtable(L); + for (k = 0; k < sf->mark_class_cnt; k++) { + if (sf->mark_class_names[k] != NULL) { + lua_pushstring(L, sf->mark_class_names[k]); + lua_pushstring(L, sf->mark_classes[k]); + lua_rawset(L, -3); + } + } + lua_setfield(L, -2, "mark_classes"); } - if (st & lvs_bad_glyph_table) { - lua_pushliteral(L, "bad_glyph_table"); lua_rawseti(L,-2,val++); + + dump_intfield(L, "creationtime", sf->creationtime); + dump_intfield(L, "modificationtime", sf->modificationtime); + + dump_intfield(L, "os2_version", sf->os2_version); + dump_intfield(L, "sfd_version", sf->sfd_version); + + if (sf->MATH != NULL) { + lua_newtable(L); + handle_MATH(L, sf->MATH); + lua_setfield(L, -2, "math"); + } + + if (sf->loadvalidation_state != 0) { + int val, st; + lua_newtable(L); + val = 1; + st = sf->loadvalidation_state; + if (st & lvs_bad_ps_fontname) { + lua_pushliteral(L, "bad_ps_fontname"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_glyph_table) { + lua_pushliteral(L, "bad_glyph_table"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_cff_table) { + lua_pushliteral(L, "bad_cff_table"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_metrics_table) { + lua_pushliteral(L, "bad_metrics_table"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_cmap_table) { + lua_pushliteral(L, "bad_cmap_table"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_bitmaps_table) { + lua_pushliteral(L, "bad_bitmaps_table"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_gx_table) { + lua_pushliteral(L, "bad_gx_table"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_ot_table) { + lua_pushliteral(L, "bad_ot_table"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_os2_version) { + lua_pushliteral(L, "bad_os2_version"); + lua_rawseti(L, -2, val++); + } + if (st & lvs_bad_sfnt_header) { + lua_pushliteral(L, "bad_sfnt_header"); + lua_rawseti(L, -2, val++); + } + lua_setfield(L, -2, "validation_state"); } - if (st & lvs_bad_cff_table) { - lua_pushliteral(L, "bad_cff_table"); lua_rawseti(L,-2,val++); + + if (sf->horiz_base != NULL) { + lua_newtable(L); + handle_base(L, sf->horiz_base); + lua_setfield(L, -2, "horiz_base"); } - if (st & lvs_bad_metrics_table) { - lua_pushliteral(L, "bad_metrics_table"); lua_rawseti(L,-2,val++); + if (sf->vert_base != NULL) { + lua_newtable(L); + handle_base(L, sf->vert_base); + lua_setfield(L, -2, "vert_base"); } - if (st & lvs_bad_cmap_table) { - lua_pushliteral(L, "bad_cmap_table"); lua_rawseti(L,-2,val++); + dump_intfield(L, "extrema_bound", sf->extrema_bound); +} + +int ff_make_table(lua_State * L) +{ + SplineFont *sf; + sf = *(check_isfont(L, 1)); + if (sf == NULL) { + lua_pushboolean(L, 0); + } else { + lua_createtable(L, 0, 60); + handle_splinefont(L, sf); } - if (st & lvs_bad_bitmaps_table) { - lua_pushliteral(L, "bad_bitmaps_table"); lua_rawseti(L,-2,val++); + return 1; +} + +void do_ff_info(lua_State * L, SplineFont * sf) +{ + lua_newtable(L); + dump_stringfield(L, "familyname", sf->familyname); + dump_stringfield(L, "fontname", sf->fontname); + dump_stringfield(L, "fullname", sf->fullname); + dump_intfield(L, "italicangle", sf->italicangle); + dump_stringfield(L, "version", sf->version); + dump_stringfield(L, "weight", sf->weight); + +} + +static int ff_info(lua_State * L) +{ + SplineFont *sf; + FILE *l; + int i; + const char *fontname; + int openflags = 1; + fontname = luaL_checkstring(L, 1); + if (!strlen(fontname)) { + lua_pushnil(L); + lua_pushfstring(L, "font loading failed: empty string given\n", + fontname); + return 2; } - if (st & lvs_bad_gx_table) { - lua_pushliteral(L, "bad_gx_table"); lua_rawseti(L,-2,val++); + /* test fontname for existance */ + if ((l = fopen(fontname, "r"))) { + fclose(l); + } else { + lua_pushnil(L); + lua_pushfstring(L, "font loading failed for %s (read error)\n", + fontname); + return 2; } - if (st & lvs_bad_ot_table) { - lua_pushliteral(L, "bad_ot_table"); lua_rawseti(L,-2,val++); + sf = ReadSplineFontInfo((char *) fontname, openflags); + if (sf == NULL) { + lua_pushnil(L); + lua_pushfstring(L, "font loading failed for %s\n", fontname); + return 2; + } else { + if (sf->next != NULL) { + SplineFont *sf_next; + i = 1; + lua_newtable(L); + while (sf) { + do_ff_info(L, sf); + lua_rawseti(L, -2, i); + i++; + sf_next = sf->next; + EncMapFree(sf->map); + SplineFontFree(sf); + sf = sf_next; + } + } else { + do_ff_info(L, sf); + EncMapFree(sf->map); + SplineFontFree(sf); + } } - if (st & lvs_bad_os2_version) { - lua_pushliteral(L, "bad_os2_version"); lua_rawseti(L,-2,val++); + return 1; +} + +static void ff_do_cff(SplineFont * sf, char *filename, unsigned char **buf, + int *bufsiz) +{ + FILE *f; + int32 *bsizes = NULL; + int flags = ps_flag_nocffsugar + ps_flag_nohints; + EncMap *map; + + map = EncMap1to1(sf->glyphcnt); + + if (WriteTTFFont + (filename, sf, ff_cff, bsizes, bf_none, flags, map, ly_fore)) { + /* success */ + f = fopen(filename, "rb"); + readbinfile(f, buf, bufsiz); + /*fprintf(stdout,"\n%s => CFF, size: %d\n", sf->filename, *bufsiz); */ + fclose(f); + return; } - if (st & lvs_bad_sfnt_header) { - lua_pushliteral(L, "bad_sfnt_header"); lua_rawseti(L,-2,val++); + /* errors */ + fprintf(stdout, "\n%s => CFF, failed\n", sf->filename); + +} + +/* exported for writecff.c */ + +int ff_createcff(char *file, unsigned char **buf, int *bufsiz) +{ + SplineFont *sf; + int k; + char s[] = "tempfile.cff"; + int openflags = 1; + int notdefpos = 0; + sf = ReadSplineFont(file, openflags); + if (sf) { + /* this is not the best way. nicer to have no temp file at all */ + ff_do_cff(sf, s, buf, bufsiz); + for (k = 0; k < sf->glyphcnt; k++) { + if (sf->glyphs[k] && strcmp(sf->glyphs[k]->name, ".notdef") == 0) { + notdefpos = k; + break; + } + } + remove(s); + EncMapFree(sf->map); + SplineFontFree(sf); } - lua_setfield(L,-2,"validation_state"); - } + return notdefpos; +} - if (sf->horiz_base != NULL) { - lua_newtable(L); - handle_base(L, sf->horiz_base); - lua_setfield(L,-2,"horiz_base"); - } - if (sf->vert_base != NULL) { - lua_newtable(L); - handle_base(L, sf->vert_base); - lua_setfield(L,-2,"vert_base"); - } - dump_intfield(L,"extrema_bound", sf->extrema_bound); -} - -int -ff_make_table (lua_State *L) { - SplineFont *sf; - sf = *(check_isfont(L,1)); - if (sf == NULL) { - lua_pushboolean(L,0); - } else { - lua_createtable(L,0,60); - handle_splinefont(L,sf); - } - return 1; -} - -void do_ff_info (lua_State *L, SplineFont *sf) { - lua_newtable(L); - dump_stringfield(L,"familyname", sf->familyname); - dump_stringfield(L,"fontname", sf->fontname); - dump_stringfield(L,"fullname", sf->fullname); - dump_intfield (L,"italicangle", sf->italicangle); - dump_stringfield(L,"version", sf->version); - dump_stringfield(L,"weight", sf->weight); - -} - -static int -ff_info (lua_State *L) { - SplineFont *sf; - FILE *l; - int i; - const char *fontname; - int openflags = 1; - fontname = luaL_checkstring(L,1); - if (!strlen(fontname)) { - lua_pushfstring(L,"font loading failed: empty string given\n", fontname); - lua_error(L); - return 1; - } - /* test fontname for existance */ - if ((l = fopen(fontname,"r"))) { - fclose(l); - } else { - lua_pushfstring(L,"font loading failed for %s (read error)\n", fontname); - lua_error(L); - } - sf = ReadSplineFontInfo((char *)fontname,openflags); - if (sf==NULL) { - lua_pushfstring(L,"font loading failed for %s\n", fontname); - lua_error(L); - } else { - if (sf->next != NULL) { - SplineFont *sf_next; - i = 1; - lua_newtable(L); - while (sf) { - do_ff_info(L, sf); - lua_rawseti(L,-2,i); - i++; - sf_next = sf->next; - SplineFontFree(sf); - sf = sf_next; - } - } else { - do_ff_info(L, sf); - SplineFontFree(sf); - } - } - return 1; -} - -static void ff_do_cff (SplineFont *sf, char *filename, unsigned char **buf, int *bufsiz) { - FILE *f; - int32 *bsizes = NULL; - int flags = ps_flag_nocffsugar + ps_flag_nohints; - EncMap *map; - - map = EncMap1to1(sf->glyphcnt); - - if(WriteTTFFont(filename, sf, ff_cff, bsizes, bf_none, flags, map, ly_fore)) { - /* success */ - f = fopen(filename,"rb"); - readbinfile(f , buf, bufsiz); - /*fprintf(stdout,"\n%s => CFF, size: %d\n", sf->filename, *bufsiz);*/ - fclose(f); - return; - } - /* errors */ - fprintf(stdout,"\n%s => CFF, failed\n", sf->filename); - -} - - -#include "luafflib.h" - -int ff_createcff (char *file, unsigned char **buf, int *bufsiz) { - SplineFont *sf; - int k ; - char s[] = "tempfile.cff"; - int openflags = 1; - int notdefpos = 0; - sf = ReadSplineFont(file,openflags); - if (sf) { - /* this is not the best way. nicer to have no temp file at all */ - ff_do_cff(sf, s, buf,bufsiz); - for (k=0;kglyphcnt;k++) { - if (sf->glyphs[k] && strcmp(sf->glyphs[k]->name,".notdef")==0) { - notdefpos=k; - break; - } - } - remove(s); - SplineFontFree(sf); - } - return notdefpos; -} - -int ff_get_ttc_index(char *ffname, char*psname) { - SplineFont *sf; - int i = 0; - int openflags = 1; - int index = 0; - - sf = ReadSplineFontInfo(ffname,openflags); - if (sf==NULL) { - perror("font loading failed unexpectedly\n"); - exit(EXIT_FAILURE); - } - while (sf != NULL) { - if (strcmp(sf->fontname,psname)==0) { - index = i; - break; - } - i++; - sf = sf->next; - } - return index; +int ff_get_ttc_index(char *ffname, char *psname) +{ + SplineFont *sf; + int i = 0; + int openflags = 1; + int index = -1; + + sf = ReadSplineFontInfo((char *) ffname, openflags); + if (sf == NULL) { + perror("font loading failed unexpectedly\n"); + exit(EXIT_FAILURE); + } + while (sf != NULL) { + if (strcmp(sf->fontname, psname) == 0) { + index = i; + break; + } + i++; + sf = sf->next; + } + return index; } static int warning_given = 0; -static int -ffold_info (lua_State *L) { - if (warning_given<5) { - fprintf (stderr, "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n"); - fprintf (stderr, " Please update your source file(s) accordingly.\n"); - warning_given ++; +static int ffold_info(lua_State * L) +{ + if (warning_given < 5) { + fprintf(stderr, + "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n"); + fprintf(stderr, " Please update your source file(s) accordingly.\n"); + warning_given++; } return ff_info(L); } -static int -ffold_open (lua_State *L) { - fprintf (stderr, "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n"); - fprintf (stderr, " Please update your source file(s) accordingly.\n"); +static int ffold_open(lua_State * L) +{ + fprintf(stderr, + "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n"); + fprintf(stderr, " Please update your source file(s) accordingly.\n"); return ff_open(L); } static struct luaL_reg fflib[] = { - {"open", ffold_open}, - {"info", ffold_info}, - {"close", ff_close}, - {"apply_afmfile", ff_apply_afmfile}, - {"apply_featurefile", ff_apply_featurefile}, - {"to_table", ff_make_table}, - {NULL, NULL} + {"open", ffold_open}, + {"info", ffold_info}, + {"close", ff_close}, + {"apply_afmfile", ff_apply_afmfile}, + {"apply_featurefile", ff_apply_featurefile}, + {"to_table", ff_make_table}, + {NULL, NULL} }; static struct luaL_reg fllib[] = { - {"open", ff_open}, - {"info", ff_info}, - {"close", ff_close}, - {"apply_afmfile", ff_apply_afmfile}, - {"apply_featurefile", ff_apply_featurefile}, - {"to_table", ff_make_table}, - {NULL, NULL} + {"open", ff_open}, + {"info", ff_info}, + {"close", ff_close}, + {"apply_afmfile", ff_apply_afmfile}, + {"apply_featurefile", ff_apply_featurefile}, + {"to_table", ff_make_table}, + {NULL, NULL} }; -static const struct luaL_reg fflib_m [] = { - {"__gc", ff_close }, /* doesnt work yet! */ - {NULL, NULL} /* sentinel */ +static const struct luaL_reg fflib_m[] = { + {"__gc", ff_close}, /* doesnt work yet! */ + {NULL, NULL} /* sentinel */ }; extern char *SaveTablesPref; -extern char *coord_sep ; - -int luaopen_ff (lua_State *L) { - InitSimpleStuff(); - setlocale(LC_ALL,"C"); /* undo whatever InitSimpleStuff has caused */ - coord_sep = ","; - FF_SetUiInterface(&luaui_interface); - default_encoding = FindOrMakeEncoding("ISO8859-1"); - SaveTablesPref = "VORG,JSTF,acnt,bsln,fdsc,fmtx,hsty,just,trak,Zapf,LINO"; - luaL_newmetatable(L,FONT_METATABLE); - luaL_register(L, NULL, fflib_m); - luaL_openlib(L, "fontforge", fflib, 0); - luaL_openlib(L, "fontloader", fllib, 0); - return 1; +extern char *coord_sep; + +int luaopen_ff(lua_State * L) +{ + InitSimpleStuff(); + setlocale(LC_ALL, "C"); /* undo whatever InitSimpleStuff has caused */ + coord_sep = ","; + FF_SetUiInterface(&luaui_interface); + default_encoding = FindOrMakeEncoding("ISO8859-1"); + SaveTablesPref = "VORG,JSTF,acnt,bsln,fdsc,fmtx,hsty,just,trak,Zapf,LINO"; + luaL_newmetatable(L, FONT_METATABLE); + luaL_register(L, NULL, fflib_m); + luaL_openlib(L, "fontforge", fflib, 0); + luaL_openlib(L, "fontloader", fllib, 0); + return 1; } - diff --git a/Build/source/texk/web2c/luatexdir/luamd5/luamd5.h b/Build/source/texk/web2c/luatexdir/luamd5/luamd5.h new file mode 100644 index 00000000000..c0470c6439d --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/luamd5/luamd5.h @@ -0,0 +1,20 @@ +/** +* $Id: md5.h,v 1.2 2003/04/28 16:25:44 roberto Exp $ +* Cryptographic module for Lua. +* @author Roberto Ierusalimschy +*/ + + +#ifndef luamd5_h +#define luamd5_h + +#include + + +#define HASHSIZE 16 + +void md5 (const char *message, long len, char *output); +int luaopen_md5 (lua_State *L); + + +#endif diff --git a/Build/source/texk/web2c/luatexdir/luamd5/md5.c b/Build/source/texk/web2c/luatexdir/luamd5/md5.c index 7e630bfc46b..685880bedf5 100644 --- a/Build/source/texk/web2c/luatexdir/luamd5/md5.c +++ b/Build/source/texk/web2c/luatexdir/luamd5/md5.c @@ -6,13 +6,14 @@ #include +#include -#include "md5.h" +#include "luamd5.h" #define WORD 32 #define MASK 0xFFFFFFFF -typedef unsigned long WORD32; +typedef uint32_t WORD32; /** diff --git a/Build/source/texk/web2c/luatexdir/luamd5/md5.h b/Build/source/texk/web2c/luatexdir/luamd5/md5.h deleted file mode 100644 index 80d43f72687..00000000000 --- a/Build/source/texk/web2c/luatexdir/luamd5/md5.h +++ /dev/null @@ -1,20 +0,0 @@ -/** -* $Id: md5.h,v 1.2 2003/04/28 16:25:44 roberto Exp $ -* Cryptographic module for Lua. -* @author Roberto Ierusalimschy -*/ - - -#ifndef md5_h -#define md5_h - -#include - - -#define HASHSIZE 16 - -void md5 (const char *message, long len, char *output); -int luaopen_md5 (lua_State *L); - - -#endif diff --git a/Build/source/texk/web2c/luatexdir/luamd5/md5_lua.c b/Build/source/texk/web2c/luatexdir/luamd5/md5_lua.c new file mode 100644 index 00000000000..5caebaececd --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/luamd5/md5_lua.c @@ -0,0 +1,38 @@ +/* + * This file is auto-generated by "lua2c md5.lua md5_lua" + */ + +#include "lua.h" +#include "lauxlib.h" + +int luatex_md5_lua_open (lua_State *L) { + static unsigned char B[] = { + 45, 45, 32,109,100, 53, 46,108,117, 97, 10, 45, 45, 32, 40,121,111,117, 32,115, +104,111,117,108,100, 32,112,117,116, 32,116,104,105,115, 32,102,105,108,101, 32, +105,110, 32, 97,110,121, 32,100,105,114,101, 99,116,111,114,121, 32,111,102, 32, +121,111,117,114, 32, 76, 85, 65, 95, 80, 65, 84, 72, 41, 10, 10, 10, 45, 45, 32, + 99,104, 97,110,103,101, 32,116,104,101, 32,110,101,120,116, 32,108,105,110,101, + 32,116,111, 32,112,111,105,110,116, 32,116,111, 32,116,104,101, 32,109,100, 53, + 32,100,121,110, 97,109,105, 99, 32,108,105, 98,114, 97,114,121, 10, 10, 45, 45, + 32,108,111, 99, 97,108, 32,112, 97,116,104, 32, 61, 32, 34, 47,117,115,114, 47, +108,111, 99, 97,108, 47,108,117, 97, 47,108,105, 98, 47,108,105, 98,109,100, 53, + 46,115,111, 34, 10, 45, 45,108,111, 99, 97,108, 32,112, 97,116,104, 32, 61, 32, + 34, 46, 47,108,105, 98,109,100, 53, 46,115,111, 34, 10, 10, 45, 45, 97,115,115, +101,114,116, 40,108,111, 97,100,108,105, 98, 40,112, 97,116,104, 44, 32, 34,108, +117, 97,111,112,101,110, 95,109,100, 53, 34, 41, 41, 40, 41, 10, 10, 10, 45, 45, + 32, 82,101,116,117,114,110,115, 32,116,104,101, 32,109,100, 53, 32,104, 97,115, +104, 32,118, 97,108,117,101, 32, 97,115, 32, 97, 32,115,116,114,105,110,103, 32, +111,102, 32,104,101,120, 97,100,101, 99,105,109, 97,108, 32,100,105,103,105,116, +115, 10, 10,102,117,110, 99,116,105,111,110, 32,109,100, 53, 46,115,117,109,104, +101,120, 97, 32, 40,107, 41, 10, 32, 32,107, 32, 61, 32,109,100, 53, 46,115,117, +109, 40,107, 41, 10, 32, 32,114,101,116,117,114,110, 32, 40,115,116,114,105,110, +103, 46,103,115,117, 98, 40,107, 44, 32, 34, 46, 34, 44, 32,102,117,110, 99,116, +105,111,110, 32, 40, 99, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114, +101,116,117,114,110, 32,115,116,114,105,110,103, 46,102,111,114,109, 97,116, 40, + 34, 37, 48, 50,120, 34, 44, 32,115,116,114,105,110,103, 46, 98,121,116,101, 40, + 99, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 41, 41, 10,101, +110,100, 10, 10,114,101,116,117,114,110, 32,109,100, 53, 10, + 0 }; + return luaL_dostring(L, (const char*)B); +} /* end of embedded lua code */ + diff --git a/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c b/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c index 7c72a16fcb6..de213d878a2 100644 --- a/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c +++ b/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c @@ -13,7 +13,7 @@ #include #include -#include "md5.h" +#include "luamd5.h" /** diff --git a/Build/source/texk/web2c/luatexdir/luatangle.ch b/Build/source/texk/web2c/luatexdir/luatangle.ch deleted file mode 100644 index 9c5af9db75a..00000000000 --- a/Build/source/texk/web2c/luatexdir/luatangle.ch +++ /dev/null @@ -1,508 +0,0 @@ -% luatangle.ch: web2c changes to file tangle.ch -% $Id$ -% -% This file is part of LuaTeX. -% -% Copyright (c) 1994--1998 John Plaice and Yannis Haralambous -% Copyright 2006-2008 Taco Hoekwater -% applies only to the changes to the original tangle.ch. -% -% luatangle.ch for C compilation with web2c. -% -% 10/9/82 (HT) Original version -% 11/29 (HT) New version, with conversion to lowercase handled properly -% Also, new control sequence: -% @=...text...@> Put ...text... verbatim on a line -% by itself in the Pascal output. -% (argument must fit on one line) -% This control sequence facilitates putting #include "gcons.h" -% (for example) in files meant for the pc compiler. -% Also, changed command line usage, so that the absence of a -% change file implies no change file, rather than one with the -% same name as the web file, with .ch at the end. -% 1/15/83 (HT) Changed to work with version 1.2, which incorporates the -% above change (though unbundling the output line breaking), -% so mainly had to remove stuff. -% 2/17 (HT) Fixed bug that caused 0-9 in identifiers to be converted to -% Q-Y on output. -% 3/18 (HT) Brought up to work with Version 1.5. Added -r command line -% flag to cause a .rpl file to be written with all the lines -% of the .web file that were replaced because of the .ch file -% (useful for comparing with previous .rpl files, to see if a -% change file will still work with a new version of a .web file) -% Also, made it write a newline just before exit. -% 4/12 (PC) Merged with Pavel's version, including adding a call to exit() -% at the end depending upon the value of history. -% 4/16 (PC) Brought up to date with version 1.5 released April, 1983. -% 6/28 (HWT) Brought up to date with version 1.7 released June, 1983. -% With new change file format, the -r option is now unnecessary. -% 7/17 (HWT) Brought up to date with version 2.0 released July, 1983. -% 12/18/83 (ETM) Brought up to date with version 2.5 released November, 1983. -% 11/07/84 (ETM) Brought up to date with version 2.6. -% 12/15/85 (ETM) Brought up to date with version 2.8. -% 03/07/88 (ETM) Converted for use with WEB2C -% 01/02/89 (PAM) Cosmetic upgrade to version 2.9 -% 11/30/89 (KB) Version 4. -% (more recent changes in the ChangeLog) - -@x [0] Print only changes. -\pageno=\contentspagenumber \advance\pageno by 1 -@y -\pageno=\contentspagenumber \advance\pageno by 1 -\let\maybe=\iffalse -\def\title{TANGLE changes for C} -@z - -@x [2] Eliminate the |end_of_TANGLE| label. -@d end_of_TANGLE = 9999 {go here to wrap it up} - -@y -@z -@x -label end_of_TANGLE; {go here to finish} -@y -@z - -@x [?] Define and call parse_arguments. -procedure initialize; - var @@/ - begin @@/ -@y -@ -procedure initialize; - var @@/ - begin - kpse_set_program_name (argv[0], nil); - parse_arguments; - @@/ -@z - -@x [8] Constants: increase id lengths, for TeX--XeT and tex2pdf. -@!buf_size=100; {maximum length of input line} -@y -@!buf_size=3000; {maximum length of input line} -@z -@x -@!max_names=10239; {number of identifiers, strings, module names; - must be less than 10240} -@!max_texts=10239; {number of replacement texts, must be less than 10240} -@y -@!max_names=10239; {number of identifiers, strings, module names; - must be less than 10240} -@!max_texts=10239; {number of replacement texts, must be less than 10240} -@z - -@x -@!stack_size=50; {number of simultaneous levels of macro expansion} -@!max_id_length=12; {long identifiers are chopped to this length, which must - not exceed |line_length|} -@!unambig_length=7; {identifiers must be unique if chopped to this length} - {note that 7 is more strict than \PASCAL's 8, but this can be varied} -@y -@!stack_size=100; {number of simultaneous levels of macro expansion} -@!max_id_length=64; {long identifiers are chopped to this length, which must - not exceed |line_length|} -@!unambig_length=64; {identifiers must be unique if chopped to this length} -@z - -% [??] The text_char type is used as an array index into xord. The -% default type `char' produces signed integers, which are bad array -% indices in C. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -@x -@d text_char == char {the data type of characters in text files} -@y -@d text_char == ASCII_code {the data type of characters in text files} -@z - -@x [17] enable maximum character set -for i:=1 to @'37 do xchr[i]:=' '; -for i:=@'200 to @'377 do xchr[i]:=' '; -@y -for i:=1 to @'37 do xchr[i]:=chr(i); -for i:=@'200 to @'377 do xchr[i]:=chr(i); -@z - -@x [20] terminal output: use standard i/o -@d print(#)==write(term_out,#) {`|print|' means write on the terminal} -@y -@d term_out==stdout -@d print(#)==write(term_out,#) {`|print|' means write on the terminal} -@z - -@x -@= -@!term_out:text_file; {the terminal as an output file} -@y -@z - -@x [21] init terminal -@ Different systems have different ways of specifying that the output on a -certain file will appear on the user's terminal. Here is one way to do this -on the \PASCAL\ system that was used in \.{TANGLE}'s initial development: -@^system dependencies@> - -@= -rewrite(term_out,'TTY:'); {send |term_out| output to the terminal} -@y -@ Different systems have different ways of specifying that the output on a -certain file will appear on the user's terminal. -@^system dependencies@> - -@= - {Nothing need be done for C.} -@z - -@x [22] flush terminal buffer -@d update_terminal == break(term_out) {empty the terminal output buffer} -@y -@d update_terminal == fflush(term_out) {empty the terminal output buffer} -@z - -@x [24] open input files -begin reset(web_file); reset(change_file); -@y -begin web_file := kpse_open_file(web_name, kpse_web_format); -if chg_name then change_file := kpse_open_file(chg_name, kpse_web_format); -@z - -@x [26] Open output files (except for the pool file). -rewrite(Pascal_file); rewrite(pool); -@y -rewrite (Pascal_file, pascal_name); -@z - -@x [28] Fix f^. - begin buffer[limit]:=xord[f^]; get(f); - incr(limit); - if buffer[limit-1]<>" " then final_limit:=limit; - if limit=buf_size then - begin while not eoln(f) do get(f); -@y - begin buffer[limit]:=xord[getc(f)]; - incr(limit); - if buffer[limit-1]<>" " then final_limit:=limit; - if limit=buf_size then - begin while not eoln(f) do vgetc(f); -@z - -@x [??] Fix `jump_out'. -@d fatal_error(#)==begin new_line; print(#); error; mark_fatal; jump_out; - end - -@= -procedure jump_out; -begin goto end_of_TANGLE; -end; -@y -@d jump_out==uexit(1) -@d fatal_error(#)==begin new_line; write(stderr, #); - error; mark_fatal; uexit(1); - end -@z - -@x [38] Provide for a larger `byte_mem' and `tok_mem'. Extra capacity: -@d ww=2 {we multiply the byte capacity by approximately this amount} -@d zz=3 {we multiply the token capacity by approximately this amount} -@y -@d ww=3 {we multiply the byte capacity by approximately this amount} -@d zz=5 {we multiply the token capacity by approximately this amount} -@z - -@x [58] Case smashing options/strict checking. - begin if buffer[i]<>"_" then - begin if buffer[i]>="a" then chopped_id[s]:=buffer[i]-@'40 - else chopped_id[s]:=buffer[i]; -@y - begin if (buffer[i]<>"_") or (allow_underlines) then - begin chopped_id[s]:=buffer[i]; -@z - -@x [63] Case smashing options/strict checking. - if c<>"_" then - begin if c>="a" then c:=c-@'40; {merge lowercase with uppercase} -@y - if c<>"_" or (allow_underlines) then - begin -@z - -@x [64] Delayed pool file opening. -@= -begin ilk[p]:=numeric; {strings are like numeric macros} -if l-double_chars=2 then {this string is for a single character} - equiv[p]:=buffer[id_first+1]+1073741824 -else begin equiv[p]:=string_ptr+1073741824; - l:=l-double_chars-1; -@y -@= -begin ilk[p]:=numeric; {strings are like numeric macros} -if l-double_chars=2 then {this string is for a single character} - equiv[p]:=buffer[id_first+1]+1073741824 -else begin - {Avoid creating empty pool files.} - if string_ptr = 2097152 then begin - {Change |".web"| to |".pool"| and use the current directory.} - pool_name := basename_change_suffix (web_name, '.web', '.pool'); - rewrite (pool, pool_name); - end; - equiv[p]:=string_ptr+1073741824; - l:=l-double_chars-1; -@z - -@x [105] Accept DIV, div, MOD, and mod - (((out_contrib[1]="D")and(out_contrib[2]="I")and(out_contrib[3]="V")) or@| - ((out_contrib[1]="M")and(out_contrib[2]="O")and(out_contrib[3]="D")) ))or@| -@^uppercase@> -@y - (((out_contrib[1]="D")and(out_contrib[2]="I")and(out_contrib[3]="V")) or@| - ((out_contrib[1]="d")and(out_contrib[2]="i")and(out_contrib[3]="v")) or@| - ((out_contrib[1]="M")and(out_contrib[2]="O")and(out_contrib[3]="D")) or@| - ((out_contrib[1]="m")and(out_contrib[2]="o")and(out_contrib[3]="d")) ))or@| -@z - -@x [110] lowercase ids -@^uppercase@> - if ((out_buf[out_ptr-3]="D")and(out_buf[out_ptr-2]="I")and - (out_buf[out_ptr-1]="V"))or @/ - ((out_buf[out_ptr-3]="M")and(out_buf[out_ptr-2]="O")and - (out_buf[out_ptr-1]="D")) then@/ goto bad_case -@y - if ((out_buf[out_ptr-3]="D")and(out_buf[out_ptr-2]="I")and - (out_buf[out_ptr-1]="V"))or @/ - ((out_buf[out_ptr-3]="d")and(out_buf[out_ptr-2]="i")and - (out_buf[out_ptr-1]="v"))or @/ - ((out_buf[out_ptr-3]="M")and(out_buf[out_ptr-2]="O")and - (out_buf[out_ptr-1]="D"))or @/ - ((out_buf[out_ptr-3]="m")and(out_buf[out_ptr-2]="o")and - (out_buf[out_ptr-1]="d")) then@/ goto bad_case -@z - -@x [114] lowercase operators (`and', `or', etc.) -and_sign: begin out_contrib[1]:="A"; out_contrib[2]:="N"; out_contrib[3]:="D"; -@^uppercase@> - send_out(ident,3); - end; -not_sign: begin out_contrib[1]:="N"; out_contrib[2]:="O"; out_contrib[3]:="T"; - send_out(ident,3); - end; -set_element_sign: begin out_contrib[1]:="I"; out_contrib[2]:="N"; - send_out(ident,2); - end; -or_sign: begin out_contrib[1]:="O"; out_contrib[2]:="R"; send_out(ident,2); -@y -and_sign: begin out_contrib[1]:="a"; out_contrib[2]:="n"; out_contrib[3]:="d"; - send_out(ident,3); - end; -not_sign: begin out_contrib[1]:="n"; out_contrib[2]:="o"; out_contrib[3]:="t"; - send_out(ident,3); - end; -set_element_sign: begin out_contrib[1]:="i"; out_contrib[2]:="n"; - send_out(ident,2); - end; -or_sign: begin out_contrib[1]:="o"; out_contrib[2]:="r"; send_out(ident,2); -@z - -@x [116] Remove conversion to uppercase -@ Single-character identifiers represent themselves, while longer ones -appear in |byte_mem|. All must be converted to uppercase, -with underlines removed. Extremely long identifiers must be chopped. - -(Some \PASCAL\ compilers work with lowercase letters instead of -uppercase. If this module of \.{TANGLE} is changed, it's also necessary -to change from uppercase to lowercase in the modules that are -listed in the index under ``uppercase''.) -@^system dependencies@> -@^uppercase@> - -@d up_to(#)==#-24,#-23,#-22,#-21,#-20,#-19,#-18,#-17,#-16,#-15,#-14, - #-13,#-12,#-11,#-10,#-9,#-8,#-7,#-6,#-5,#-4,#-3,#-2,#-1,# - -@= -"A",up_to("Z"): begin out_contrib[1]:=cur_char; send_out(ident,1); - end; -"a",up_to("z"): begin out_contrib[1]:=cur_char-@'40; send_out(ident,1); - end; -identifier: begin k:=0; j:=byte_start[cur_val]; w:=cur_val mod ww; - while (k="a" then out_contrib[k]:=out_contrib[k]-@'40 - else if out_contrib[k]="_" then decr(k); - end; - send_out(ident,k); - end; -@y -@ Single-character identifiers represent themselves, while longer ones -appear in |byte_mem|. All must be converted to lowercase, -with underlines removed. Extremely long identifiers must be chopped. -@^system dependencies@> - -@d up_to(#)==#-24,#-23,#-22,#-21,#-20,#-19,#-18,#-17,#-16,#-15,#-14, - #-13,#-12,#-11,#-10,#-9,#-8,#-7,#-6,#-5,#-4,#-3,#-2,#-1,# - -@= -"A",up_to("Z"), -"a",up_to("z"): begin out_contrib[1]:=cur_char; send_out(ident,1); - end; -identifier: begin k:=0; j:=byte_start[cur_val]; w:=cur_val mod ww; - while (k; -@y -@; -new_line; -if (history <> spotless) and (history <> harmless_message) -then uexit (1) -else uexit (0); -@z - -@x [188] System-dependent changes. -This module should be replaced, if necessary, by changes to the program -that are necessary to make \.{TANGLE} work at a particular installation. -It is usually best to design your change file so that all changes to -previous modules preserve the module numbering; then everybody's version -will be consistent with the printed program. More extensive changes, -which introduce new modules, can be inserted here; then only the index -itself will get a new module number. -@^system dependencies@> -@y -Parse a Unix-style command line. - -@d argument_is (#) == (strcmp (long_options[option_index].name, #) = 0) - -@ = -procedure parse_arguments; -const n_options = 4; {Pascal won't count array lengths for us.} -var @!long_options: array[0..n_options] of getopt_struct; - @!getopt_return_val: integer; - @!option_index: c_int_type; - @!current_option: 0..n_options; -begin - @; - repeat - getopt_return_val := getopt_long_only (argc, argv, '', long_options, - address_of (option_index)); - if getopt_return_val = -1 then begin - {End of arguments; we exit the loop below.} ; - - end else if getopt_return_val = "?" then begin - usage ('luatangle'); - - end else if argument_is ('underlines') then begin - allow_underlines := true; - - end else if argument_is ('help') then begin - usage_help (LUATANGLE_HELP, nil); - - end else if argument_is ('version') then begin - print_version_and_exit - (banner, nil, 'J. Plaice, Y. Haralambous, D.E. Knuth', nil); - - end; {Else it was a flag; |getopt| has already done the assignment.} - until getopt_return_val = -1; - - {Now |optind| is the index of first non-option on the command line.} - if (optind + 1 <> argc) and (optind + 2 <> argc) then begin - write_ln (stderr, 'otangle: Need one or two file arguments.'); - usage ('otangle'); - end; - - {Supply |".web"| and |".ch"| extensions if necessary.} - web_name := extend_filename (cmdline (optind), 'web'); - if optind + 2 = argc then begin - chg_name := extend_filename (cmdline (optind + 1), 'ch'); - end; - - {Change |".web"| to |".p"| and use the current directory.} - pascal_name := basename_change_suffix (web_name, '.web', '.p'); -end; - -@ Here are the options we allow. The first is one of the standard GNU options. -@.-help@> - -@ = -current_option := 0; -long_options[current_option].name := 'help'; -long_options[current_option].has_arg := 0; -long_options[current_option].flag := 0; -long_options[current_option].val := 0; -incr (current_option); - -@ Another of the standard options. -@.-version@> - -@ = -long_options[current_option].name := 'version'; -long_options[current_option].has_arg := 0; -long_options[current_option].flag := 0; -long_options[current_option].val := 0; -incr (current_option); - -@ Allow underlines. -@.-underlines@> - -@ = -long_options[current_option].name := 'underlines'; -long_options[current_option].has_arg := 0; -long_options[current_option].flag := 0; -long_options[current_option].val := 0; -incr (current_option); - -@ An element with all zeros always ends the list. - -@ = -long_options[current_option].name := 0; -long_options[current_option].has_arg := 0; -long_options[current_option].flag := 0; -long_options[current_option].val := 0; - -@ Global filenames. - -@= -@!web_name,@!chg_name,@!pascal_name,@!pool_name:const_c_string; -@!@!allow_underlines:boolean; -@z diff --git a/Build/source/texk/web2c/luatexdir/luatangle.test b/Build/source/texk/web2c/luatexdir/luatangle.test deleted file mode 100755 index f519174e8b6..00000000000 --- a/Build/source/texk/web2c/luatexdir/luatangle.test +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh - -# Copyright (C) 2009 Peter Breitenlohner -# You may freely use, modify and/or distribute this file. - -TEXMFCNF=$srcdir/../kpathsea WEBINPUTS=$srcdir/cftests \ - ./luatangle cftest cftest || exit 1 - -diff cftest.p $srcdir/cftests/lcftest.p || exit 1 - diff --git a/Build/source/texk/web2c/luatexdir/luatangle.web b/Build/source/texk/web2c/luatexdir/luatangle.web deleted file mode 100644 index 46ca98e1e14..00000000000 --- a/Build/source/texk/web2c/luatexdir/luatangle.web +++ /dev/null @@ -1,3329 +0,0 @@ -% luatangle.web: LuaTeX version of file tangle.web -% $Id$ -% -% This file is part of LuaTeX. -% -% Copyright (c) 1994--1998 John Plaice and Yannis Haralambous -% Copyright 2006-2008 Taco Hoekwater -% applies only to the changes to the original tangle.web. -% -% This program by D. E. Knuth is not copyrighted and can be used freely. -% Version 0 was released in December, 1981. -% Version 1 was released in September, 1982, with version 0 of TeX. -% Slight changes were made in October, 1982, for version 0.6 of TeX. -% Version 1.2 introduced {:nnn} comments, added @@= and @@\ (December, 1982). -% Version 1.4 added "history" (February, 1983). -% Version 1.5 conformed to TeX version 0.96 and fixed @@\ (March, 1983). -% Version 1.7 introduced the new change file format (June, 1983). -% Version 2.0 was released in July, 1983, with version 0.999 of TeX. -% Version 2.5 was released in November, 1983, with version 1.0 of TeX. -% Version 2.6 fixed a bug: force-line-break after a constant (August, 1984). -% Version 2.7 fixed the definition of check_sum_prime (May, 1985). -% Version 2.8 fixed a bug in change_buffer movement (August, 1985). -% Version 2.9 allows nonnumeric macros before their def (December, 1988). -% Version 3, for Sewell's book, fixed long-line bug in input_ln (March, 1989). -% Version 4 was major change to allow 8-bit input (September, 1989). -% Version 4.1 conforms to ANSI standard for-loop rules (September, 1990). -% Version 4.2 fixes stat report if phase one dies (March, 1991). -% Version 4.3 fixes @@ bug in verbatim, catches extra } (September, 1991). -% Version 4.4 activates debug_help on errors as advertised (February, 1993). - -% Here is TeX material that gets inserted after \input webmac -\def\hang{\hangindent 3em\indent\ignorespaces} -\font\ninerm=cmr9 -\let\mc=\ninerm % medium caps for names like SAIL -\def\PASCAL{Pascal} -\def\pb{$\.|\ldots\.|$} % Pascal brackets (|...|) -\def\v{\.{\char'174}} % vertical (|) in typewriter font -\mathchardef\BA="3224 % double arrow -\def\({} % kludge for alphabetizing certain module names - -\def\title{LUATANGLE} -\def\contentspagenumber{123} % should be odd -\def\topofcontents{\null\vfill - \titlefalse % include headline on the contents page - \def\rheader{\mainfont Appendix E\hfil \contentspagenumber} - \centerline{\titlefont The {\ttitlefont LUATANGLE} processor} - \vskip 15pt - \centerline{(Version 4.4)} - \vfill} -\pageno=\contentspagenumber \advance\pageno by 1 - -@* Introduction. -This program converts a \.{WEB} file to a \PASCAL\ file. It was written -by D. E. Knuth in September, 1981; a somewhat similar {\mc SAIL} program had -been developed in March, 1979. Since this program describes itself, a -bootstrapping process involving hand-translation had to be used to get started. - -For large \.{WEB} files one should have a large memory, since \.{TANGLE} keeps -all the \PASCAL\ text in memory (in an abbreviated form). The program uses -a few features of the local \PASCAL\ compiler that may need to be changed in -other installations: - -\yskip\item{1)} Case statements have a default. -\item{2)} Input-output routines may need to be adapted for use with a particular -character set and/or for printing messages on the user's terminal. - -\yskip\noindent -These features are also present in the \PASCAL\ version of \TeX, where they -are used in a similar (but more complex) way. System-dependent portions -of \.{TANGLE} can be identified by looking at the entries for `system -dependencies' in the index below. -@!@^system dependencies@> - -The ``banner line'' defined here should be changed whenever \.{TANGLE} -is modified. - -@d banner=='This is LUATANGLE, Version 4.4' - -@ The program begins with a fairly normal header, made up of pieces that -@^system dependencies@> -will mostly be filled in later. The \.{WEB} input comes from files |web_file| -and |change_file|, the \PASCAL\ output goes to file |Pascal_file|, -and the string pool output goes to file |pool|. - -If it is necessary to abort the job because of a fatal error, the program -calls the `|jump_out|' procedure, which goes to the label |end_of_TANGLE|. - -@d end_of_TANGLE = 9999 {go here to wrap it up} - -@p @t\4@>@@/ -program LUATANGLE(@!web_file,@!change_file,@!Pascal_file,@!pool); -label end_of_TANGLE; {go here to finish} -const @@/ -type @@/ -var @@/ -@@/ -procedure initialize; - var @@/ - begin @@/ - end; - -@ Some of this code is optional for use when debugging only; -such material is enclosed between the delimiters |debug| and $|gubed|$. -Other parts, delimited by |stat| and $|tats|$, are optionally included if -statistics about \.{TANGLE}'s memory usage are desired. - -@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} -@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} -@f debug==begin -@f gubed==end -@# -@d stat==@{ {change this to `$\\{stat}\equiv\null$' - when gathering usage statistics} -@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' - when gathering usage statistics} -@f stat==begin -@f tats==end - -@ The \PASCAL\ compiler used to develop this system has ``compiler -directives'' that can appear in comments whose first character is a dollar sign. -In production versions of \.{TANGLE} these directives tell the compiler that -@^system dependencies@> -it is safe to avoid range checks and to leave out the extra code it inserts -for the \PASCAL\ debugger's benefit, although interrupts will occur if -there is arithmetic overflow. - -@= -@{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead} -@!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging} - -@ Labels are given symbolic names by the following definitions. We insert -the label `|exit|:' just before the `\ignorespaces|end|\unskip' of a -procedure in which we have used the `|return|' statement defined below; -the label `|restart|' is occasionally used at the very beginning of a -procedure; and the label `|reswitch|' is occasionally used just prior to -a \&{case} statement in which some cases change the conditions and we wish to -branch to the newly applicable case. -Loops that are set up with the \&{loop} construction defined below are -commonly exited by going to `|done|' or to `|found|' or to `|not_found|', -and they are sometimes repeated by going to `|continue|'. - -@d exit=10 {go here to leave a procedure} -@d restart=20 {go here to start a procedure again} -@d reswitch=21 {go here to start a case statement again} -@d continue=22 {go here to resume a loop} -@d done=30 {go here to exit a loop} -@d found=31 {go here when you've found it} -@d not_found=32 {go here when you've found something else} - -@ Here are some macros for common programming idioms. - -@d incr(#) == #:=#+1 {increase a variable by unity} -@d decr(#) == #:=#-1 {decrease a variable by unity} -@d loop == @+ while true do@+ {repeat over and over until a |goto| happens} -@d do_nothing == {empty statement} -@d return == goto exit {terminate a procedure call} -@f return == nil -@f loop == xclause - -@ We assume that |case| statements may include a default case that applies -if no matching label is found. Thus, we shall use constructions like -@^system dependencies@> -$$\vbox{\halign{#\hfil\cr -|case x of|\cr -1: $\langle\,$code for $x=1\,\rangle$;\cr -3: $\langle\,$code for $x=3\,\rangle$;\cr -|othercases| $\langle\,$code for |x<>1| and |x<>3|$\,\rangle$\cr -|endcases|\cr}}$$ -since most \PASCAL\ compilers have plugged this hole in the language by -incorporating some sort of default mechanism. For example, the compiler -used to develop \.{WEB} and \TeX\ allows `|others|:' as a default label, -and other \PASCAL s allow syntaxes like `\ignorespaces|else|\unskip' or -`\&{otherwise}' or `\\{otherwise}:', etc. The definitions of |othercases| -and |endcases| should be changed to agree with local conventions. (Of -course, if no default mechanism is available, the |case| statements of -this program must be extended by listing all remaining cases. The author -would have taken the trouble to modify \.{TANGLE} so that such extensions -were done automatically, if he had not wanted to encourage \PASCAL\ -compiler writers to make this important change in \PASCAL, where it belongs.) - -@d othercases == others: {default for cases not listed explicitly} -@d endcases == @+end {follows the default case in an extended |case| statement} -@f othercases == else -@f endcases == end - -@ The following parameters are set big enough to handle \TeX, so they -should be sufficient for most applications of \.{TANGLE}. - -@= -@!buf_size=100; {maximum length of input line} -@!max_bytes=65535; {|1/ww| times the number of bytes in identifiers, - strings, and module names; must be less than 65536} -@!max_toks=65535; {|1/zz| times the number of bytes in compressed \PASCAL\ code; - must be less than 65536} -@!max_names=10239; {number of identifiers, strings, module names; - must be less than 10240} -@!max_texts=10239; {number of replacement texts, must be less than 10240} -@!hash_size=353; {should be prime} -@!longest_name=400; {module names shouldn't be longer than this} -@!line_length=72; {lines of \PASCAL\ output have at most this many characters} -@!out_buf_size=144; {length of output buffer, should be twice |line_length|} -@!stack_size=50; {number of simultaneous levels of macro expansion} -@!max_id_length=12; {long identifiers are chopped to this length, which must - not exceed |line_length|} -@!unambig_length=7; {identifiers must be unique if chopped to this length} - {note that 7 is more strict than \PASCAL's 8, but this can be varied} - -@ A global variable called |history| will contain one of four values -at the end of every run: |spotless| means that no unusual messages were -printed; |harmless_message| means that a message of possible interest -was printed but no serious errors were detected; |error_message| means that -at least one error was found; |fatal_message| means that the program -terminated abnormally. The value of |history| does not influence the -behavior of the program; it is simply computed for the convenience -of systems that might want to use such information. - -@d spotless=0 {|history| value for normal jobs} -@d harmless_message=1 {|history| value when non-serious info was printed} -@d error_message=2 {|history| value when an error was noted} -@d fatal_message=3 {|history| value when we had to stop prematurely} -@# -@d mark_harmless==@t@>@+if history=spotless then history:=harmless_message -@d mark_error==history:=error_message -@d mark_fatal==history:=fatal_message -@d biggest_char=2097151 -@d number_chars=2097152 - -@=@!history:spotless..fatal_message; {how bad was this run?} - -@ @=history:=spotless; - -@* The character set. -One of the main goals in the design of \.{WEB} has been to make it readily -portable between a wide variety of computers. Yet \.{WEB} by its very -nature must use a greater variety of characters than most computer -programs deal with, and character encoding is one of the areas in which -existing machines differ most widely from each other. - -To resolve this problem, all input to \.{WEAVE} and \.{TANGLE} is converted -to an internal eight-bit code that is essentially standard ASCII, the ``American -Standard Code for Information Interchange.'' The conversion is done -immediately when each character is read in. Conversely, characters are -converted from ASCII to the user's external representation just before -they are output. (The original ASCII code was seven bits only; \.{WEB} now -allows eight bits in an attempt to keep up with modern times.) - -Such an internal code is relevant to users of \.{WEB} only because it is -the code used for preprocessed constants like \.{"A"}. If you are writing -a program in \.{WEB} that makes use of such one-character constants, you -should convert your input to ASCII form, like \.{WEAVE} and \.{TANGLE} do. -Otherwise \.{WEB}'s internal coding scheme does not affect you. -@^ASCII code@> - -Here is a table of the standard visible ASCII codes: -$$\def\:{\char\count255\global\advance\count255 by 1} -\count255='40 -\vbox{ -\hbox{\hbox to 40pt{\it\hfill0\/\hfill}% -\hbox to 40pt{\it\hfill1\/\hfill}% -\hbox to 40pt{\it\hfill2\/\hfill}% -\hbox to 40pt{\it\hfill3\/\hfill}% -\hbox to 40pt{\it\hfill4\/\hfill}% -\hbox to 40pt{\it\hfill5\/\hfill}% -\hbox to 40pt{\it\hfill6\/\hfill}% -\hbox to 40pt{\it\hfill7\/\hfill}} -\vskip 4pt -\hrule -\def\^{\vrule height 10.5pt depth 4.5pt} -\halign{\hbox to 0pt{\hskip -24pt\O{#0}\hfill}&\^ -\hbox to 40pt{\tt\hfill#\hfill\^}& -&\hbox to 40pt{\tt\hfill#\hfill\^}\cr -04&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -05&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -06&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -07&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -10&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -11&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -12&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -13&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -14&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -15&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -16&\:&\:&\:&\:&\:&\:&\:&\:\cr\noalign{\hrule} -17&\:&\:&\:&\:&\:&\:&\:\cr} -\hrule width 280pt}$$ -(Actually, of course, code @'040 is an invisible blank space.) Code @'136 -was once an upward arrow (\.{\char'13}), and code @'137 was -once a left arrow (\.^^X), in olden times when the first draft -of ASCII code was prepared; but \.{WEB} works with today's standard -ASCII in which those codes represent circumflex and underline as shown. - -@= -@!ASCII_code=0..255; {eight-bit numbers, a subrange of the integers} - -@ The original \PASCAL\ compiler was designed in the late 60s, when six-bit -character sets were common, so it did not make provision for lowercase -letters. Nowadays, of course, we need to deal with both capital and small -letters in a convenient way, so \.{WEB} assumes that it is being used -with a \PASCAL\ whose character set contains at least the characters of -standard ASCII as listed above. Some \PASCAL\ compilers use the original -name |char| for the data type associated with the characters in text files, -while other \PASCAL s consider |char| to be a 64-element subrange of a larger -data type that has some other name. - -In order to accommodate this difference, we shall use the name |text_char| -to stand for the data type of the characters in the input and output -files. We shall also assume that |text_char| consists of the elements -|chr(first_text_char)| through |chr(last_text_char)|, inclusive. The -following definitions should be adjusted if necessary. -@^system dependencies@> - -@d text_char == char {the data type of characters in text files} -@d first_text_char=0 {ordinal number of the smallest element of |text_char|} -@d last_text_char=255 {ordinal number of the largest element of |text_char|} - -@= -@!text_file=packed file of text_char; - -@ The \.{WEAVE} and \.{TANGLE} processors convert between ASCII code and -the user's external character set by means of arrays |xord| and |xchr| -that are analogous to \PASCAL's |ord| and |chr| functions. - -@= -@!xord: array [text_char] of ASCII_code; - {specifies conversion of input characters} -@!xchr: array [ASCII_code] of text_char; - {specifies conversion of output characters} - -@ If we assume that every system using \.{WEB} is able to read and write the -visible characters of standard ASCII (although not necessarily using the -ASCII codes to represent them), the following assignment statements initialize -most of the |xchr| array properly, without needing any system-dependent -changes. For example, the statement \.{xchr[@@\'101]:=\'A\'} that appears -in the present \.{WEB} file might be encoded in, say, {\mc EBCDIC} code -on the external medium on which it resides, but \.{TANGLE} will convert from -this external code to ASCII and back again. Therefore the assignment -statement \.{XCHR[65]:=\'A\'} will appear in the corresponding \PASCAL\ file, -and \PASCAL\ will compile this statement so that |xchr[65]| receives the -character \.A in the external (|char|) code. Note that it would be quite -incorrect to say \.{xchr[@@\'101]:="A"}, because |"A"| is a constant of -type |integer|, not |char|, and because we have $|"A"|=65$ regardless of -the external character set. - -@= -xchr[@'40]:=' '; -xchr[@'41]:='!'; -xchr[@'42]:='"'; -xchr[@'43]:='#'; -xchr[@'44]:='$'; -xchr[@'45]:='%'; -xchr[@'46]:='&'; -xchr[@'47]:='''';@/ -xchr[@'50]:='('; -xchr[@'51]:=')'; -xchr[@'52]:='*'; -xchr[@'53]:='+'; -xchr[@'54]:=','; -xchr[@'55]:='-'; -xchr[@'56]:='.'; -xchr[@'57]:='/';@/ -xchr[@'60]:='0'; -xchr[@'61]:='1'; -xchr[@'62]:='2'; -xchr[@'63]:='3'; -xchr[@'64]:='4'; -xchr[@'65]:='5'; -xchr[@'66]:='6'; -xchr[@'67]:='7';@/ -xchr[@'70]:='8'; -xchr[@'71]:='9'; -xchr[@'72]:=':'; -xchr[@'73]:=';'; -xchr[@'74]:='<'; -xchr[@'75]:='='; -xchr[@'76]:='>'; -xchr[@'77]:='?';@/ -xchr[@'100]:='@@'; -xchr[@'101]:='A'; -xchr[@'102]:='B'; -xchr[@'103]:='C'; -xchr[@'104]:='D'; -xchr[@'105]:='E'; -xchr[@'106]:='F'; -xchr[@'107]:='G';@/ -xchr[@'110]:='H'; -xchr[@'111]:='I'; -xchr[@'112]:='J'; -xchr[@'113]:='K'; -xchr[@'114]:='L'; -xchr[@'115]:='M'; -xchr[@'116]:='N'; -xchr[@'117]:='O';@/ -xchr[@'120]:='P'; -xchr[@'121]:='Q'; -xchr[@'122]:='R'; -xchr[@'123]:='S'; -xchr[@'124]:='T'; -xchr[@'125]:='U'; -xchr[@'126]:='V'; -xchr[@'127]:='W';@/ -xchr[@'130]:='X'; -xchr[@'131]:='Y'; -xchr[@'132]:='Z'; -xchr[@'133]:='['; -xchr[@'134]:='\'; -xchr[@'135]:=']'; -xchr[@'136]:='^'; -xchr[@'137]:='_';@/ -xchr[@'140]:='`'; -xchr[@'141]:='a'; -xchr[@'142]:='b'; -xchr[@'143]:='c'; -xchr[@'144]:='d'; -xchr[@'145]:='e'; -xchr[@'146]:='f'; -xchr[@'147]:='g';@/ -xchr[@'150]:='h'; -xchr[@'151]:='i'; -xchr[@'152]:='j'; -xchr[@'153]:='k'; -xchr[@'154]:='l'; -xchr[@'155]:='m'; -xchr[@'156]:='n'; -xchr[@'157]:='o';@/ -xchr[@'160]:='p'; -xchr[@'161]:='q'; -xchr[@'162]:='r'; -xchr[@'163]:='s'; -xchr[@'164]:='t'; -xchr[@'165]:='u'; -xchr[@'166]:='v'; -xchr[@'167]:='w';@/ -xchr[@'170]:='x'; -xchr[@'171]:='y'; -xchr[@'172]:='z'; -xchr[@'173]:='{'; -xchr[@'174]:='|'; -xchr[@'175]:='}'; -xchr[@'176]:='~';@/ -xchr[0]:=' '; xchr[@'177]:=' '; {these ASCII codes are not used} - -@ Some of the ASCII codes below @'40 have been given symbolic names in -\.{WEAVE} and \.{TANGLE} because they are used with a special meaning. - -@d and_sign=@'4 {equivalent to `\.{and}'} -@d not_sign=@'5 {equivalent to `\.{not}'} -@d set_element_sign=@'6 {equivalent to `\.{in}'} -@d tab_mark=@'11 {ASCII code used as tab-skip} -@d line_feed=@'12 {ASCII code thrown away at end of line} -@d form_feed=@'14 {ASCII code used at end of page} -@d carriage_return=@'15 {ASCII code used at end of line} -@d left_arrow=@'30 {equivalent to `\.{:=}'} -@d not_equal=@'32 {equivalent to `\.{<>}'} -@d less_or_equal=@'34 {equivalent to `\.{<=}'} -@d greater_or_equal=@'35 {equivalent to `\.{>=}'} -@d equivalence_sign=@'36 {equivalent to `\.{==}'} -@d or_sign=@'37 {equivalent to `\.{or}'} - -@ When we initialize the |xord| array and the remaining parts of |xchr|, -it will be convenient to make use of an index variable, |i|. - -@= -@!i:0..255; - -@ Here now is the system-dependent part of the character set. -If \.{WEB} is being implemented on a garden-variety \PASCAL\ for which -only standard ASCII codes will appear in the input and output files, you -don't need to make any changes here. But if you have, for example, an extended -character set like the one in Appendix~C of {\sl The \TeX book}, the first -line of code in this module should be changed to -$$\hbox{|for i:=1 to @'37 do xchr[i]:=chr(i);|}$$ -\.{WEB}'s character set is essentially identical to \TeX's, even with respect to -characters less than @'40. -@^system dependencies@> - -Changes to the present module will make \.{WEB} more friendly on computers -that have an extended character set, so that one can type things like -\.^^Z\ instead of \.{<>}. If you have an extended set of characters that -are easily incorporated into text files, you can assign codes arbitrarily -here, giving an |xchr| equivalent to whatever characters the users of -\.{WEB} are allowed to have in their input files, provided that unsuitable -characters do not correspond to special codes like |carriage_return| -that are listed above. - -(The present file \.{TANGLE.WEB} does not contain any of the non-ASCII -characters, because it is intended to be used with all implementations of -\.{WEB}. It was originally created on a Stanford system that has a -convenient extended character set, then ``sanitized'' by applying another -program that transliterated all of the non-standard characters into -standard equivalents.) - -@= -for i:=1 to @'37 do xchr[i]:=' '; -for i:=@'200 to @'377 do xchr[i]:=' '; - -@ The following system-independent code makes the |xord| array contain a -suitable inverse to the information in |xchr|. - -@= -for i:=first_text_char to last_text_char do xord[chr(i)]:=" "; -for i:=1 to @'377 do xord[xchr[i]]:=i; -xord[' ']:=" "; - -@* Input and output. -The input conventions of this program are intended to be very much like those -of \TeX\ (except, of course, that they are much simpler, because much less -needs to be done). Furthermore they are identical to those of \.{WEAVE}. -Therefore people who need to make modifications to all three systems -should be able to do so without too many headaches. - -We use the standard \PASCAL\ input/output procedures in several places that -\TeX\ cannot, since \.{TANGLE} does not have to deal with files that are named -dynamically by the user, and since there is no input from the terminal. - -@ Terminal output is done by writing on file |term_out|, which is assumed to -consist of characters of type |text_char|: -@^system dependencies@> - -@d print(#)==write(term_out,#) {`|print|' means write on the terminal} -@d print_ln(#)==write_ln(term_out,#) {`|print|' and then start new line} -@d new_line==write_ln(term_out) {start new line} -@d print_nl(#)== {print information starting on a new line} - begin new_line; print(#); - end - -@= -@!term_out:text_file; {the terminal as an output file} - -@ Different systems have different ways of specifying that the output on a -certain file will appear on the user's terminal. Here is one way to do this -on the \PASCAL\ system that was used in \.{TANGLE}'s initial development: -@^system dependencies@> - -@= -rewrite(term_out,'TTY:'); {send |term_out| output to the terminal} - -@ The |update_terminal| procedure is called when we want -to make sure that everything we have output to the terminal so far has -actually left the computer's internal buffers and been sent. -@^system dependencies@> - -@d update_terminal == break(term_out) {empty the terminal output buffer} - -@ The main input comes from |web_file|; this input may be overridden -by changes in |change_file|. (If |change_file| is empty, there are no changes.) - -@= -@!web_file:text_file; {primary input} -@!change_file:text_file; {updates} - -@ The following code opens the input files. Since these files were listed -in the program header, we assume that the \PASCAL\ runtime system has -already checked that suitable file names have been given; therefore no -additional error checking needs to be done. -@^system dependencies@> - -@p procedure open_input; {prepare to read |web_file| and |change_file|} -begin reset(web_file); reset(change_file); -end; - -@ The main output goes to |Pascal_file|, and string pool constants are -written to the |pool| file. - -@= -@!Pascal_file: text_file; -@!pool: text_file; - -@ The following code opens |Pascal_file| and |pool|. -Since these files were listed in the program header, we assume that the -\PASCAL\ runtime system has checked that suitable external file names have -been given. -@^system dependencies@> - -@= -rewrite(Pascal_file); rewrite(pool); - -@ Input goes into an array called |buffer|. - -@=@!buffer: array[0..buf_size] of ASCII_code; - -@ The |input_ln| procedure brings the next line of input from the specified -file into the |buffer| array and returns the value |true|, unless the file has -already been entirely read, in which case it returns |false|. The conventions -of \TeX\ are followed; i.e., |ASCII_code| numbers representing the next line -of the file are input into |buffer[0]|, |buffer[1]|, \dots, -|buffer[limit-1]|; trailing blanks are ignored; -and the global variable |limit| is set to the length of the -@^system dependencies@> -line. The value of |limit| must be strictly less than |buf_size|. - -We assume that none of the |ASCII_code| values -of |buffer[j]| for |0<=j" " then final_limit:=limit; - if limit=buf_size then - begin while not eoln(f) do get(f); - decr(limit); {keep |buffer[buf_size]| empty} - if final_limit>limit then final_limit:=limit; - print_nl('! Input line too long'); loc:=0; error; -@.Input line too long@> - end; - end; - read_ln(f); limit:=final_limit; input_ln:=true; - end; -end; - -@* Reporting errors to the user. -The \.{TANGLE} processor operates in two phases: first it inputs the source -file and stores a compressed representation of the program, then it produces -the \PASCAL\ output from the compressed representation. - -The global variable |phase_one| tells whether we are in Phase I or not. - -@= -@!phase_one: boolean; {|true| in Phase I, |false| in Phase II} - -@ If an error is detected while we are debugging, -we usually want to look at the contents of memory. -A special procedure will be declared later for this purpose. - -@= -@!debug @+ procedure debug_help; forward;@+ gubed - -@ During the first phase, syntax errors are reported to the user by saying -$$\hbox{`|err_print('! Error message')|'},$$ -followed by `|jump_out|' if no recovery from the error is provided. -This will print the error message followed by an indication of where the error -was spotted in the source file. Note that no period follows the error message, -since the error routine will automatically supply a period. - -Errors that are noticed during the second phase are reported to the user -in the same fashion, but the error message will be -followed by an indication of where the error was spotted in the output file. - -The actual error indications are provided by a procedure called |error|. - -@d err_print(#)==begin new_line; print(#); error; - end - -@= -procedure error; {prints '\..' and location of error message} -var j: 0..out_buf_size; {index into |out_buf|} -@!k,@!l: 0..buf_size; {indices into |buffer|} -begin if phase_one then @ -else @; -update_terminal; mark_error; -@!debug debug_skipped:=debug_cycle; debug_help;@+gubed -end; - -@ The error locations during Phase I can be indicated by using the global -variables |loc|, |line|, and |changing|, which tell respectively the first -unlooked-at position in |buffer|, the current line number, and whether or not -the current line is from |change_file| or |web_file|. -This routine should be modified on systems whose standard text editor -has special line-numbering conventions. -@^system dependencies@> - -@= -begin if changing then print('. (change file ')@+else print('. ('); -print_ln('l.', line:1, ')'); -if loc>=limit then l:=limit else l:=loc; -for k:=1 to l do - if buffer[k-1]=tab_mark then print(' ') - else print(xchr[buffer[k-1]]); {print the characters already read} -new_line; -for k:=1 to l do print(' '); {space out the next line} -for k:=l+1 to limit do print(xchr[buffer[k-1]]); {print the part not yet read} -print(' '); {this space separates the message from future asterisks} -end - -@ The position of errors detected during the second phase can be indicated -by outputting the partially-filled output buffer, which contains |out_ptr| -entries. - -@= -begin print_ln('. (l.',line:1,')'); -for j:=1 to out_ptr do print(xchr[out_buf[j-1]]); {print current partial line} -print('... '); {indicate that this information is partial} -end - -@ The |jump_out| procedure just cuts across all active procedure levels -and jumps out of the program. This is the only non-local |goto| statement -in \.{TANGLE}. It is used when no recovery from a particular error has -been provided. - -Some \PASCAL\ compilers do not implement non-local |goto| statements. -@^system dependencies@> -In such cases the code that appears at label |end_of_TANGLE| should be -copied into the |jump_out| procedure, followed by a call to a system procedure -that terminates the program. - -@d fatal_error(#)==begin new_line; print(#); error; mark_fatal; jump_out; - end - -@= -procedure jump_out; -begin goto end_of_TANGLE; -end; - -@ Sometimes the program's behavior is far different from what it should be, -and \.{TANGLE} prints an error message that is really for the \.{TANGLE} -maintenance person, not the user. In such cases the program says -|confusion('indication of where we are')|. - -@d confusion(#)==fatal_error('! This can''t happen (',#,')') -@.This can't happen@> - -@ An overflow stop occurs if \.{TANGLE}'s tables aren't large enough. - -@d overflow(#)==fatal_error('! Sorry, ',#,' capacity exceeded') -@.Sorry, x capacity exceeded@> - - -@* Data structures. -Most of the user's \PASCAL\ code is packed into eight-bit integers -in two large arrays called |byte_mem| and |tok_mem|. -The |byte_mem| array holds the names of identifiers, strings, and modules; -the |tok_mem| array holds the replacement texts -for macros and modules. Allocation is sequential, since things are deleted only -during Phase II, and only in a last-in-first-out manner. - -Auxiliary arrays |byte_start| and |tok_start| are used as directories to -|byte_mem| and |tok_mem|, and the |link|, |ilk|, |equiv|, and |text_link| -arrays give further information about names. These auxiliary arrays -consist of sixteen-bit items. - -@= -@!eight_bits=0..255; {unsigned one-byte quantity} -@!sixteen_bits=integer; {not quite a two-byte quantity} - -@ \.{TANGLE} has been designed to avoid the need for indices that are more -than sixteen bits wide, so that it can be used on most computers. But -there are programs that need more than 65536 tokens, and some programs -even need more than 65536 bytes; \TeX\ is one of these. To get around -this problem, a slight complication has been added to the data structures: -|byte_mem| and |tok_mem| are two-dimensional arrays, whose first index is -either 0 or 1. (For generality, the first index is actually allowed to run -between 0 and |ww-1| in |byte_mem|, or between 0 and |zz-1| in |tok_mem|, -where |ww| and |zz| are set to 2 and~3; the program will work for any -positive values of |ww| and |zz|, and it can be simplified in obvious ways -if |ww=1| or |zz=1|.) - -@d ww=2 {we multiply the byte capacity by approximately this amount} -@d zz=3 {we multiply the token capacity by approximately this amount} - -@= -@!byte_mem: packed array [0..ww-1,0..max_bytes] of ASCII_code; - {characters of names} -@!tok_mem: packed array [0..zz-1,0..max_toks] of eight_bits; {tokens} -@!byte_start: array [0..max_names] of sixteen_bits; {directory into |byte_mem|} -@!tok_start: array [0..max_texts] of sixteen_bits; {directory into |tok_mem|} -@!link: array [0..max_names] of sixteen_bits; {hash table or tree links} -@!ilk: array [0..max_names] of sixteen_bits; {type codes or tree links} -@!equiv: array [0..max_names] of sixteen_bits; {info corresponding to names} -@!text_link: array [0..max_texts] of sixteen_bits; {relates replacement texts} - -@ The names of identifiers are found by computing a hash address |h| and -then looking at strings of bytes signified by |hash[h]|, |link[hash[h]]|, -|link[link[hash[h]]]|, \dots, until either finding the desired name -or encountering a zero. - -A `|name_pointer|' variable, which signifies a name, is an index into -|byte_start|. The actual sequence of characters in the name pointed to by -|p| appears in positions |byte_start[p]| to |byte_start[p+ww]-1|, inclusive, -in the segment of |byte_mem| whose first index is |p mod ww|. Thus, when -|ww=2| the even-numbered name bytes appear in |byte_mem[0,@t$*$@>]| -and the odd-numbered ones appear in |byte_mem[1,@t$*$@>]|. -The pointer 0 is used for undefined module names; we don't -want to use it for the names of identifiers, since 0 stands for a null -pointer in a linked list. - -Strings are treated like identifiers; the first character (a double-quote) -distinguishes a string from an alphabetic name, but for \.{TANGLE}'s purposes -strings behave like numeric macros. (A `string' here refers to the -strings delimited by double-quotes that \.{TANGLE} processes. \PASCAL\ -string constants delimited by single-quote marks are not given such special -treatment; they simply appear as sequences of characters in the \PASCAL\ -texts.) The total number of strings in the string -pool is called |string_ptr|, and the total number of names in |byte_mem| -is called |name_ptr|. The total number of bytes occupied in -|byte_mem[w,@t$*$@>]| is called |byte_ptr[w]|. - -We usually have |byte_start[name_ptr+w]=byte_ptr[(name_ptr+w) mod ww]| -for |0<=w= -@!name_pointer=0..max_names; {identifies a name} - -@ @= -@!name_ptr:name_pointer; {first unused position in |byte_start|} -@!string_ptr:name_pointer; {next number to be given to a string of length |<>1|} -@!byte_ptr:array [0..ww-1] of 0..max_bytes; - {first unused position in |byte_mem|} -@!pool_check_sum:integer; {sort of a hash for the whole string pool} - -@ @= -@!wi: 0..ww-1; {to initialize the |byte_mem| indices} - -@ @= -for wi:=0 to ww-1 do - begin byte_start[wi]:=0; byte_ptr[wi]:=0; - end; -byte_start[ww]:=0; {this makes name 0 of length zero} -name_ptr:=1; string_ptr:=number_chars; pool_check_sum:=271828; - -@ Replacement texts are stored in |tok_mem|, using similar conventions. -A `|text_pointer|' variable is an index into |tok_start|, and the -replacement text that corresponds to |p| runs from positions -|tok_start[p]| to |tok_start[p+zz]-1|, inclusive, in the segment of -|tok_mem| whose first index is |p mod zz|. Thus, when |zz=2| the -even-numbered replacement texts appear in |tok_mem[0,@t$*$@>]| and the -odd-numbered ones appear in |tok_mem[1,@t$*$@>]|. Furthermore, -|text_link[p]| is used to connect pieces of text that have the same name, -as we shall see later. The pointer 0 is used for undefined replacement -texts. - -The first position of |tok_mem[z,@t$*$@>]| that is unoccupied by -replacement text is called |tok_ptr[z]|, and the first unused location of -|tok_start| is called |text_ptr|. We usually have the identity -|tok_start[text_ptr+z]=tok_ptr[(text_ptr+z) mod zz]|, for |0<=z= -@!text_pointer=0..max_texts; {identifies a replacement text} - -@ It is convenient to maintain a variable |z| that is equal to |text_ptr -mod zz|, so that we always insert tokens into segment |z| of |tok_mem|. - -@= -@t\hskip1em@>@!text_ptr:text_pointer; {first unused position in |tok_start|} -@t\hskip1em@>@!tok_ptr:array[0..zz-1] of 0..max_toks; - {first unused position in a given segment of |tok_mem|} -@t\hskip1em@>@!z:0..zz-1; {current segment of |tok_mem|} -stat @!max_tok_ptr:array[0..zz-1] of 0..max_toks; - {largest values assumed by |tok_ptr|} -tats - -@ @= -@!zi:0..zz-1; {to initialize the |tok_mem| indices} - -@ @= -for zi:=0 to zz-1 do - begin tok_start[zi]:=0; tok_ptr[zi]:=0; - end; -tok_start[zz]:=0; {this makes replacement text 0 of length zero} -text_ptr:=1; z:=1 mod zz; - -@ Four types of identifiers are distinguished by their |ilk|: - -\yskip\hang |normal| identifiers will appear in the \PASCAL\ program as -ordinary identifiers since they have not been defined to be macros; the -corresponding value in the |equiv| array -for such identifiers is a link in a secondary hash table that -is used to check whether any two of them agree in their first |unambig_length| -characters after underline symbols are removed and lowercase letters are -changed to uppercase. - -\yskip\hang |numeric| identifiers have been defined to be numeric macros; -their |equiv| value contains the corresponding numeric value plus $2^{15}$. -Strings are treated as numeric macros. - -\yskip\hang |simple| identifiers have been defined to be simple macros; -their |equiv| value points to the corresponding replacement text. - -\yskip\hang |parametric| identifiers have been defined to be parametric macros; -like simple identifiers, their |equiv| value points to the replacement text. - -@d normal=0 {ordinary identifiers have |normal| ilk} -@d numeric=1 {numeric macros and strings have |numeric| ilk} -@d simple=2 {simple macros have |simple| ilk} -@d parametric=3 {parametric macros have |parametric| ilk} - -@ The names of modules are stored in |byte_mem| together -with the identifier names, but a hash table is not used for them because -\.{TANGLE} needs to be able to recognize a module name when given a prefix of -that name. A conventional binary seach tree is used to retrieve module names, -with fields called |llink| and |rlink| in place of |link| and |ilk|. The -root of this tree is |rlink[0]|. If |p| is a pointer to a module name, -|equiv[p]| points to its replacement text, just as in simple and parametric -macros, unless this replacement text has not yet been defined (in which case -|equiv[p]=0|). - -@d llink==link {left link in binary search tree for module names} -@d rlink==ilk {right link in binary search tree for module names} - -@= -rlink[0]:=0; {the binary search tree starts out with nothing in it} -equiv[0]:=0; {the undefined module has no replacement text} - -@ Here is a little procedure that prints the text of a given name. - -@p procedure print_id(@!p:name_pointer); {print identifier or module name} -var k:0..max_bytes; {index into |byte_mem|} -@!w:0..ww-1; {segment of |byte_mem|} -begin if p>=name_ptr then print('IMPOSSIBLE') -else begin w:=p mod ww; - for k:=byte_start[p] to byte_start[p+ww]-1 do print(xchr[byte_mem[w,k]]); - end; -end; - -@* Searching for identifiers. -The hash table described above is updated by the |id_lookup| procedure, -which finds a given identifier and returns a pointer to its index in -|byte_start|. If the identifier was not already present, it is inserted with -a given |ilk| code; and an error message is printed if the identifier is being -doubly defined. - -Because of the way \.{TANGLE}'s scanning mechanism works, it is most convenient -to let |id_lookup| search for an identifier that is present in the |buffer| -array. Two other global variables specify its position in the buffer: the -first character is |buffer[id_first]|, and the last is |buffer[id_loc-1]|. -Furthermore, if the identifier is really a string, the global variable -|double_chars| tells how many of the characters in the buffer appear -twice (namely \.{@@@@} and \.{""}), since this additional information makes -it easy to calculate the true length of the string. The final double-quote -of the string is not included in its ``identifier,'' but the first one is, -so the string length is |id_loc-id_first-double_chars-1|. - -We have mentioned that |normal| identifiers belong to two hash tables, -one for their true names as they appear in the \.{WEB} file and the other -when they have been reduced to their first |unambig_length| characters. -The hash tables are kept by the method of simple chaining, where the -heads of the individual lists appear in the |hash| and |chop_hash| arrays. -If |h| is a hash code, the primary hash table list starts at |hash[h]| and -proceeds through |link| pointers; the secondary hash table list starts at -|chop_hash[h]| and proceeds through |equiv| pointers. Of course, the same -identifier will probably have two different values of |h|. - -The |id_lookup| procedure uses an auxiliary array called |chopped_id| to -contain up to |unambig_length| characters of the current identifier, if -it is necessary to compute the secondary hash code. (This array could be -declared local to |id_lookup|, but in general we are making all array -declarations global in this program, because some compilers and some machine -architectures make dynamic array allocation inefficient.) - -@= -@!id_first:0..buf_size; {where the current identifier begins in the buffer} -@!id_loc:0..buf_size; {just after the current identifier in the buffer} -@!double_chars:0..buf_size; {correction to length in case of strings} -@# -@!hash,@!chop_hash:array [0..hash_size] of sixteen_bits; {heads of hash lists} -@!chopped_id:array [0..unambig_length] of ASCII_code; {chopped identifier} - -@ Initially all the hash lists are empty. - -@= -@!h:0..hash_size; {index into hash-head arrays} - -@ @= -for h:=0 to hash_size-1 do - begin hash[h]:=0; chop_hash[h]:=0; - end; - -@ Here now is the main procedure for finding identifiers (and strings). -The parameter |t| is set to |normal| except when the identifier is -a macro name that is just being defined; in the latter case, |t| will be -|numeric|, |simple|, or |parametric|. - -@p function id_lookup(@!t:eight_bits):name_pointer; {finds current identifier} -label found, not_found; -var c:eight_bits; {byte being chopped} -@!i:0..buf_size; {index into |buffer|} -@!h:0..hash_size; {hash code} -@!k:0..max_bytes; {index into |byte_mem|} -@!w:0..ww-1; {segment of |byte_mem|} -@!l:0..buf_size; {length of the given identifier} -@!p,@!q:name_pointer; {where the identifier is being sought} -@!s:0..unambig_length; {index into |chopped_id|} -begin l:=id_loc-id_first; {compute the length} -@; -@; -if (p=name_ptr)or(t<>normal) then - @; -id_lookup:=p; -end; - -@ A simple hash code is used: If the sequence of -ASCII codes is $c_1c_2\ldots c_m$, its hash value will be -$$(2^{n-1}c_1+2^{n-2}c_2+\cdots+c_n)\,\bmod\,|hash_size|.$$ - -@= -h:=buffer[id_first]; i:=id_first+1; -while i= -p:=hash[h]; -while p<>0 do - begin if length(p)=l then - @; - p:=link[p]; - end; -p:=name_ptr; {the current identifier is new} -link[p]:=hash[h]; hash[h]:=p; {insert |p| at beginning of hash list} -found: - -@ @= -begin i:=id_first; k:=byte_start[p]; w:=p mod ww; -while (i= -begin if ((p<>name_ptr)and(t<>normal)and(ilk[p]=normal)) or - ((p=name_ptr)and(t=normal)and(buffer[id_first]<>"""")) then - @; -if p<>name_ptr then - @ -else @; -end - -@ The following routine, which is called into play when it is necessary to -look at the secondary hash table, computes the same hash function as before -(but on the chopped data), and places a zero after the chopped identifier -in |chopped_id| to serve as a convenient sentinel. - -@= -begin i:=id_first; s:=0; h:=0; -while (i"_" then - begin if buffer[i]>="a" then chopped_id[s]:=buffer[i]-@'40 - else chopped_id[s]:=buffer[i]; - h:=(h+h+chopped_id[s]) mod hash_size; incr(s); - end; - incr(i); - end; -chopped_id[s]:=0; -end - -@ If a nonnumeric macro has appeared before it was defined, \.{TANGLE} -will still work all right; after all, such behavior is typical of the -replacement texts for modules, which act very much like macros. -However, an undefined numeric macro may not be used on the right-hand -side of another numeric macro definition, so \.{TANGLE} finds it -simplest to make a blanket rule that numeric macros should be defined -before they are used. The following routine gives an error message and -also fixes up any damage that may have been caused. - -@= {now |p<>name_ptr| and |t<>normal|} -begin if ilk[p]=normal then - begin if t=numeric then err_print('! This identifier has already appeared'); -@.This identifier has already...@> - @; - end -else err_print('! This identifier was defined before'); -@.This identifier was defined...@> -ilk[p]:=t; -end - -@ When we have to remove a secondary hash entry, because a |normal| identifier -is changing to another |ilk|, the hash code |h| and chopped identifier have -already been computed. - -@= -q:=chop_hash[h]; -if q=p then chop_hash[h]:=equiv[p] -else begin while equiv[q]<>p do q:=equiv[q]; - equiv[q]:=equiv[p]; - end - -@ The following routine could make good use of a generalized |pack| procedure -that puts items into just part of a packed array instead of the whole thing. - -@= -begin if (t=normal)and(buffer[id_first]<>"""") then - @; -w:=name_ptr mod ww; k:=byte_ptr[w]; -if k+l>max_bytes then overflow('byte memory'); -if name_ptr>max_names-ww then overflow('name'); -i:=id_first; {get ready to move the identifier into |byte_mem|} -while i"""" then ilk[p]:=t -else @; -end - -@ @= -begin q:=chop_hash[h]; -while q<>0 do - begin @; - q:=equiv[q]; - end; -equiv[p]:=chop_hash[h]; chop_hash[h]:=p; {put |p| at front of secondary list} -end - -@ @= -begin k:=byte_start[q]; s:=0; w:=q mod ww; -while (k"_" then - begin if c>="a" then c:=c-@'40; {merge lowercase with uppercase} - if chopped_id[s]<>c then goto not_found; - incr(s); - end; - incr(k); - end; -if (k=byte_start[q+ww])and(chopped_id[s]<>0) then goto not_found; -print_nl('! Identifier conflict with '); -@.Identifier conflict...@> -for k:=byte_start[q] to byte_start[q+ww]-1 do print(xchr[byte_mem[w,k]]); -error; q:=0; {only one conflict will be printed, since |equiv[0]=0|} -not_found: -end - -@ We compute the string pool check sum by working modulo a prime number -that is large but not so large that overflow might occur. - -@d check_sum_prime==@'3777777667 {$2^{29}-73$} -@^preprocessed strings@> - -@= -begin ilk[p]:=numeric; {strings are like numeric macros} -if l-double_chars=2 then {this string is for a single character} - equiv[p]:=buffer[id_first+1]+1073741824 -else begin equiv[p]:=string_ptr+1073741824; - l:=l-double_chars-1; - if l>99 then err_print('! Preprocessed string is too long'); -@.Preprocessed string is too long@> - incr(string_ptr); - write(pool,xchr["0"+l div 10],xchr["0"+l mod 10]); {output the length} - pool_check_sum:=pool_check_sum+pool_check_sum+l; - while pool_check_sum>check_sum_prime do - pool_check_sum:=pool_check_sum-check_sum_prime; - i:=id_first+1; - while icheck_sum_prime do - pool_check_sum:=pool_check_sum-check_sum_prime; - if (buffer[i]="""") or (buffer[i]="@@") then - i:=i+2 {omit second appearance of doubled character} - else incr(i); - end; - write_ln(pool); - end; -end - -@* Searching for module names. -The |mod_lookup| procedure finds the module name |mod_text[1..l]| in the -search tree, after inserting it if necessary, and returns a pointer to -where it was found. - -@= -@!mod_text:array [0..longest_name] of ASCII_code; {name being sought for} - -@ According to the rules of \.{WEB}, no module name -should be a proper prefix of another, so a ``clean'' comparison should -occur between any two names. The result of |mod_lookup| is 0 if this -prefix condition is violated. An error message is printed when such violations -are detected during phase two of \.{WEAVE}. - -@d less=0 {the first name is lexicographically less than the second} -@d equal=1 {the first name is equal to the second} -@d greater=2 {the first name is lexicographically greater than the second} -@d prefix=3 {the first name is a proper prefix of the second} -@d extension=4 {the first name is a proper extension of the second} - -@p function mod_lookup(@!l:sixteen_bits):name_pointer; {finds module name} -label found; -var c:less..extension; {comparison between two names} -@!j:0..longest_name; {index into |mod_text|} -@!k:0..max_bytes; {index into |byte_mem|} -@!w:0..ww-1; {segment of |byte_mem|} -@!p:name_pointer; {current node of the search tree} -@!q:name_pointer; {father of node |p|} -begin c:=greater; q:=0; p:=rlink[0]; {|rlink[0]| is the root of the tree} -while p<>0 do - begin @; - q:=p; - if c=less then p:=llink[q] - else if c=greater then p:=rlink[q] - else goto found; - end; -@; -found: if c<>equal then - begin err_print('! Incompatible section names'); p:=0; -@.Incompatible module names@> - end; -mod_lookup:=p; -end; - -@ @= -w:=name_ptr mod ww; k:=byte_ptr[w]; -if k+l>max_bytes then overflow('byte memory'); -if name_ptr>max_names-ww then overflow('name'); -p:=name_ptr; -if c=less then llink[q]:=p else rlink[q]:=p; -llink[p]:=0; rlink[p]:=0; c:=equal; equiv[p]:=0; -for j:=1 to l do byte_mem[w,k+j-1]:=mod_text[j]; -byte_ptr[w]:=k+l; byte_start[name_ptr+ww]:=k+l; incr(name_ptr); - -@ @= -begin k:=byte_start[p]; w:=p mod ww; c:=equal; j:=1; -while (kl then c:=equal - else c:=extension -else if j>l then c:=prefix -else if mod_text[j]0 do - begin @; - if c=less then p:=llink[p] - else if c=greater then p:=rlink[p] - else begin r:=p; incr(count); q:=rlink[p]; p:=llink[p]; - end; - if p=0 then - begin p:=q; q:=0; - end; - end; -if count<>1 then - if count=0 then err_print('! Name does not match') -@.Name does not match@> - else err_print('! Ambiguous prefix'); -@.Ambiguous prefix@> -prefix_lookup:=r; {the result will be 0 if there was no match} -end; - -@* Tokens. -Replacement texts, which represent \PASCAL\ code in a compressed format, -appear in |tok_mem| as mentioned above. The codes in -these texts are called `tokens'; some tokens occupy two consecutive -eight-bit byte positions, and the others take just one byte. - -If $p>0$ points to a replacement text, |tok_start[p]| is the |tok_mem| position -of the first eight-bit code of that text. If |text_link[p]=0|, -this is the replacement text for a macro, otherwise it is the replacement -text for a module. In the latter case |text_link[p]| is either equal to -|module_flag|, which means that there is no further text for this module, or -|text_link[p]| points to a -continuation of this replacement text; such links are created when -several modules have \PASCAL\ texts with the same name, and they also -tie together all the \PASCAL\ texts of unnamed modules. -The replacement text pointer for the first unnamed module -appears in |text_link[0]|, and the most recent such pointer is |last_unnamed|. - -@d module_flag==max_texts {final |text_link| in module replacement texts} - -@= -@!last_unnamed:text_pointer; {most recent replacement text of unnamed module} - -@ @= last_unnamed:=0; text_link[0]:=0; - -@ If the first byte of a token is less than @'200, the token occupies a -single byte. Otherwise we make a sixteen-bit token by combining two consecutive -bytes |a| and |b|. If |@'200<=a<@'250|, then $(a-@'200)\times2^8+b$ points -to an identifier; if |@'250<=a<@'320|, then -$(a-@'250)\times2^8+b$ points to a module name; otherwise, i.e., if -|@'320<=a<@'400|, then $(a-@'320)\times2^8+b$ is the number of the module -in which the current replacement text appears. - -Codes less than @'200 are 7-bit ASCII codes that represent themselves. -In particular, a single-character identifier like `|x|' will be a one-byte -token, while all longer identifiers will occupy two bytes. - -Some of the 7-bit ASCII codes will not be present, however, so we can -use them for special purposes. The following symbolic names are used: - -\yskip\hang |param| denotes insertion of a parameter. This occurs only in -the replacement texts of parametric macros, outside of single-quoted strings -in those texts. - -\hang |begin_comment| denotes \.{@@\{}, which will become either -\.{\{} or \.{[}. - -\hang |end_comment| denotes \.{@@\}}, which will become either -\.{\}} or \.{]}. - -\hang |octal| denotes the \.{@@\'} that precedes an octal constant. - -\hang |hex| denotes the \.{@@"} that precedes a hexadecimal constant. - -\hang |check_sum| denotes the \.{@@\char'44} that denotes the string pool -check sum. - -\hang |join| denotes the concatenation of adjacent items with no -space or line breaks allowed between them (the \.{@@\&} operation of \.{WEB}). - -\hang |double_dot| denotes `\.{..}' in \PASCAL. - -\hang |verbatim| denotes the \.{@@=} that begins a verbatim \PASCAL\ string. -It is also used for the end of the string. - -\hang |force_line| denotes the \.{@@\\} that forces a new line in the -\PASCAL\ output. -@^ASCII code@> - -@d param=0 {ASCII null code will not appear} -@d verbatim=@'2 {extended ASCII alpha should not appear} -@d force_line=@'3 {extended ASCII beta should not appear} -@d begin_comment=@'11 {ASCII tab mark will not appear} -@d end_comment=@'12 {ASCII line feed will not appear} -@d octal=@'14 {ASCII form feed will not appear} -@d hex=@'15 {ASCII carriage return will not appear} -@d double_dot=@'40 {ASCII space will not appear except in strings} -@d check_sum=@'175 {will not be confused with right brace} -@d join=@'177 {ASCII delete will not appear} - -@ The following procedure is used to enter a two-byte value into -|tok_mem| when a replacement text is being generated. - -@p procedure store_two_bytes(@!x:sixteen_bits); - {stores high byte, then low byte} -begin if tok_ptr[z]+2>max_toks then overflow('token'); -tok_mem[z,tok_ptr[z]]:=x div@'400; {this could be done by a shift command} -tok_mem[z,tok_ptr[z]+1]:=x mod@'400; {this could be done by a logical and} -tok_ptr[z]:=tok_ptr[z]+2; -end; - -@ When \.{TANGLE} is being operated in debug mode, it has a procedure to display -a replacement text in symbolic form. This procedure has not been spruced up to -generate a real great format, but at least the results are not as bad as -a memory dump. - -@p @!debug procedure print_repl(@!p:text_pointer); -var k:0..max_toks; {index into |tok_mem|} -@!a: sixteen_bits; {current byte(s)} -@!zp: 0..zz-1; {segment of |tok_mem| being accessed} -begin if p>=text_ptr then print('BAD') -else begin k:=tok_start[p]; zp:=p mod zz; - while k=@'200 then @ - else @; - incr(k); - end; - end; -end; -gubed - -@ @= -begin incr(k); -if a<@'250 then {identifier or string} - begin a:=(a-@'200)*@'400+tok_mem[zp,k]; print_id(a); - if byte_mem[a mod ww,byte_start[a]]="""" then print('"') - else print(' '); - end -else if a<@'320 then {module name} - begin print('@@<'); print_id((a-@'250)*@'400+tok_mem[zp,k]); - print('@@>'); - end -else begin a:=(a-@'320)*@'400+tok_mem[zp,k]; {module number} - print('@@',xchr["{"],a:1,'@@',xchr["}"]); {can't use right brace - between \&{debug} and \&{gubed}} - end; -end - -@ @= -case a of -begin_comment: print('@@',xchr["{"]); -end_comment: print('@@',xchr["}"]); {can't use right brace - between \&{debug} and \&{gubed}} -octal: print('@@'''); -hex: print('@@"'); -check_sum: print('@@$'); -param: print('#'); -"@@": print('@@@@'); -verbatim: print('@@='); -force_line: print('@@\'); -othercases print(xchr[a]) -endcases - -@* Stacks for output. -Let's make sure that our data structures contain enough information to -produce the entire \PASCAL\ program as desired, by working next on the -algorithms that actually do produce that program. - -@ The output process uses a stack to keep track of what is going on at -different ``levels'' as the macros are being expanded. -Entries on this stack have five parts: - -\yskip\hang |end_field| is the |tok_mem| location where the replacement -text of a particular level will end; - -\hang |byte_field| is the |tok_mem| location from which the next token -on a particular level will be read; - -\hang |name_field| points to the name corresponding to a particular level; - -\hang |repl_field| points to the replacement text currently being read -at a particular level; - -\hang |mod_field| is the module number, or zero if this is a macro. - -\yskip\noindent The current values of these five quantities are referred to -quite frequently, so they are stored in a separate place instead of in -the |stack| array. We call the current values |cur_end|, |cur_byte|, -|cur_name|, |cur_repl|, and |cur_mod|. - -The global variable |stack_ptr| tells how many levels of output are -currently in progress. The end of all output occurs when the stack is -empty, i.e., when |stack_ptr=0|. - -@= -@t\4@>@!output_state=record - @!end_field: sixteen_bits; {ending location of replacement text} - @!byte_field: sixteen_bits; {present location within replacement text} - @!name_field: name_pointer; {|byte_start| index for text being output} - @!repl_field: text_pointer; {|tok_start| index for text being output} - @!mod_field: 0..@'27777; {module number or zero if not a module} - end; - -@ @d cur_end==cur_state.end_field {current ending location in |tok_mem|} -@d cur_byte==cur_state.byte_field {location of next output byte in |tok_mem|} -@d cur_name==cur_state.name_field {pointer to current name being expanded} -@d cur_repl==cur_state.repl_field {pointer to current replacement text} -@d cur_mod==cur_state.mod_field {current module number being expanded} - -@= -@!cur_state : output_state; {|cur_end|, |cur_byte|, |cur_name|, - |cur_repl|, |cur_mod|} -@!stack : array [1..stack_size] of output_state; {info for non-current levels} -@!stack_ptr: 0..stack_size; {first unused location in the output state stack} - -@ It is convenient to keep a global variable |zo| equal to |cur_repl mod zz|. - -@= -@!zo:0..zz-1; {the segment of |tok_mem| from which output is coming} - -@ Parameters must also be stacked. They are placed in -|tok_mem| just above the other replacement texts, and dummy parameter -`names' are placed in |byte_start| just after the other names. -The variables |text_ptr| and |tok_ptr[z]| essentially serve as parameter -stack pointers during the output phase, so there is no need for a separate -data structure to handle this problem. - -@ There is an implicit stack corresponding to meta-comments that are output -via \.{@@\{} and \.{@@\}}. But this stack need not be represented in detail, -because we only need to know whether it is empty or not. A global variable -|brace_level| tells how many items would be on this stack if it were present. - -@= -@!brace_level: eight_bits; {current depth of $\.{@@\{}\ldots\.{@@\}}$ nesting} - -@ To get the output process started, we will perform the following -initialization steps. We may assume that |text_link[0]| is nonzero, since it -points to the \PASCAL\ text in the first unnamed module that generates -code; if there are no such modules, there is nothing to output, and an -error message will have been generated before we do any of the initialization. - -@= -stack_ptr:=1; brace_level:=0; cur_name:=0; cur_repl:=text_link[0]; -zo:=cur_repl mod zz; cur_byte:=tok_start[cur_repl]; -cur_end:=tok_start[cur_repl+zz]; cur_mod:=0; - -@ When the replacement text for name |p| is to be inserted into the output, -the following subroutine is called to save the old level of output and get -the new one going. - -@p procedure push_level(@!p:name_pointer); {suspends the current level} -begin if stack_ptr=stack_size then overflow('stack') -else begin stack[stack_ptr]:=cur_state; {save |cur_end|, |cur_byte|, etc.} - incr(stack_ptr); - cur_name:=p; cur_repl:=equiv[p]; zo:=cur_repl mod zz; - cur_byte:=tok_start[cur_repl]; cur_end:=tok_start[cur_repl+zz]; - cur_mod:=0; - end; -end; - -@ When we come to the end of a replacement text, the |pop_level| subroutine -does the right thing: It either moves to the continuation of this replacement -text or returns the state to the most recently stacked level. Part of this -subroutine, which updates the parameter stack, will be given later when we -study the parameter stack in more detail. - -@p procedure pop_level; {do this when |cur_byte| reaches |cur_end|} -label exit; -begin if text_link[cur_repl]=0 then {end of macro expansion} - begin if ilk[cur_name]=parametric then - @; - end -else if text_link[cur_repl]0 then - begin cur_state:=stack[stack_ptr]; zo:=cur_repl mod zz; - end; -exit: end; - -@ The heart of the output procedure is the |get_output| routine, which produces -the next token of output that is not a reference to a macro. This procedure -handles all the stacking and unstacking that is necessary. It returns the -value |number| if the next output has a numeric value (the value of a -numeric macro or string), in which case |cur_val| has been set to the -number in question. The procedure also returns the value |module_number| -if the next output begins or ends the replacement text of some module, -in which case |cur_val| is that module's number (if beginning) or the -negative of that value (if ending). And it returns the value |identifier| -if the next output is an identifier of length two or more, in which case -|cur_val| points to that identifier name. - -@d number=@'200 {code returned by |get_output| when next output is numeric} -@d module_number=@'201 {code returned by |get_output| for module numbers} -@d identifier=@'202 {code returned by |get_output| for identifiers} - -@= -@!cur_val:integer; {additional information corresponding to output token} - -@ If |get_output| finds that no more output remains, it returns the value zero. - -@p function get_output:sixteen_bits; {returns next token after macro expansion} -label restart, done, found; -var a:sixteen_bits; {value of current byte} -@!b:eight_bits; {byte being copied} -@!bal:sixteen_bits; {excess of \.( versus \.) while copying a parameter} -@!k:0..max_bytes; {index into |byte_mem|} -@!w:0..ww-1; {segment of |byte_mem|} -begin restart: if stack_ptr=0 then - begin a:=0; goto found; - end; -if cur_byte=cur_end then - begin cur_val:=-cur_mod; pop_level; - if cur_val=0 then goto restart; - a:=module_number; goto found; - end; -a:=tok_mem[zo,cur_byte]; incr(cur_byte); -if a<@'200 then {one-byte token} - if a=param then - @ - else goto found; -a:=(a-@'200)*@'400+tok_mem[zo,cur_byte]; incr(cur_byte); -if a<@'24000 then {|@'24000=(@'250-@'200)*@'400|} - @; -if a<@'50000 then {|@'50000=(@'320-@'200)*@'400|} - @; -cur_val:=a-@'50000; a:=module_number; cur_mod:=cur_val; -found: -@!debug if trouble_shooting then debug_help;@;@+gubed@/ -get_output:=a; -end; - -@ The user may have forgotten to give any \PASCAL\ text for a module name, -or the \PASCAL\ text may have been associated with a different name by mistake. - -@= -begin a:=a-@'24000; -if equiv[a]<>0 then push_level(a) -else if a<>0 then - begin print_nl('! Not present: <'); print_id(a); print('>'); error; -@.Not present:
@> - end; -goto restart; -end - -@ @= -begin case ilk[a] of -normal: begin cur_val:=a; a:=identifier; - end; -numeric: begin cur_val:=equiv[a]-1073741824; a:=number; - end; -simple: begin push_level(a); goto restart; - end; -parametric: begin @; - push_level(a); goto restart; - end; -othercases confusion('output') -endcases;@/ -goto found; -end - -@ We come now to the interesting part, the job of putting a parameter on -the parameter stack. First we pop the stack if necessary until getting to -a level that hasn't ended. Then the next character must be a `\.('; -and since parentheses are balanced on each level, the entire parameter must -be present, so we can copy it without difficulty. - -@= -while (cur_byte=cur_end)and(stack_ptr>0) do pop_level; -if (stack_ptr=0)or(tok_mem[zo,cur_byte]<>"(") then - begin print_nl('! No parameter given for '); print_id(a); error; -@.No parameter given for macro@> - goto restart; - end; -@; -equiv[name_ptr]:=text_ptr; ilk[name_ptr]:=simple; w:=name_ptr mod ww; -k:=byte_ptr[w]; -@!debug if k=max_bytes then overflow('byte memory'); -byte_mem[w,k]:="#"; incr(k); byte_ptr[w]:=k; -gubed {this code has set the parameter identifier for debugging printouts} -if name_ptr>max_names-ww then overflow('name'); -byte_start[name_ptr+ww]:=k; incr(name_ptr); -if text_ptr>max_texts-zz then overflow('text'); -text_link[text_ptr]:=0; tok_start[text_ptr+zz]:=tok_ptr[z]; -incr(text_ptr); -z:=text_ptr mod zz - -@ The |pop_level| routine undoes the effect of parameter-pushing when -a parameter macro is finished: - -@= -begin decr(name_ptr); decr(text_ptr); -z:=text_ptr mod zz; -stat if tok_ptr[z]>max_tok_ptr[z] then max_tok_ptr[z]:=tok_ptr[z]; -tats {the maximum value of |tok_ptr| occurs just before parameter popping} -tok_ptr[z]:=tok_start[text_ptr]; -@!debug decr(byte_ptr[name_ptr mod ww]);@+gubed -end - -@ When a parameter occurs in a replacement text, we treat it as a simple -macro in position (|name_ptr-1|): - -@= -begin push_level(name_ptr-1); goto restart; -end - -@ Similarly, a |param| token encountered as we copy a parameter is converted -into a simple macro call for |name_ptr-1|. -Some care is needed to handle cases like \\{macro}|(#; print('#)'))|; the -\.{\#} token will have been changed to |param| outside of strings, but we -still must distinguish `real' parentheses from those in strings. - -@d app_repl(#)==begin if tok_ptr[z]=max_toks then overflow('token'); - tok_mem[z,tok_ptr[z]]:=#; incr(tok_ptr[z]); end - -@= -bal:=1; incr(cur_byte); {skip the opening `\.('} -loop@+ begin b:=tok_mem[zo,cur_byte]; incr(cur_byte); - if b=param then store_two_bytes(name_ptr+@'77777) - else begin if b>=@'200 then - begin app_repl(b); - b:=tok_mem[zo,cur_byte]; incr(cur_byte); - end - else case b of - "(": incr(bal); - ")": begin decr(bal); - if bal=0 then goto done; - end; - "'": repeat app_repl(b); - b:=tok_mem[zo,cur_byte]; incr(cur_byte); - until b="'"; {copy string, don't change |bal|} - othercases do_nothing - endcases; - app_repl(b); - end; - end; -done: - -@* Producing the output. -The |get_output| routine above handles most of the complexity of output -generation, but there are two further considerations that have a nontrivial -effect on \.{TANGLE}'s algorithms. - -First, we want to make sure that the output is broken into lines not -exceeding |line_length| characters per line, where these breaks occur at -valid places (e.g., not in the middle of a string or a constant or an -identifier, not between `\.<' and `\.>', not at a `\.{@@\&}' position -where quantities are being joined together). Therefore we assemble the -output into a buffer before deciding where the line breaks will appear. -However, we make very little attempt to make ``logical'' line breaks that -would enhance the readability of the output; people are supposed to read -the input of \.{TANGLE} or the \TeX ed output of \.{WEAVE}, but not the -tangled-up output. The only concession to readability is that a break after -a semicolon will be made if possible, since commonly used ``pretty -printing'' routines give better results in such cases. - -Second, we want to decimalize non-decimal constants, and to combine integer -quantities that are added or subtracted, because \PASCAL\ doesn't allow -constant expressions in subrange types or in case labels. This means we -want to have a procedure that treats a construction like \.{(E-15+17)} -as equivalent to `\.{(E+2)}', while also leaving `\.{(1E-15+17)}' and -`\.{(E-15+17*y)}' untouched. Consider also `\.{-15+17.5}' versus -`\.{-15+17..5}'. We shall not combine integers preceding or following -\.*, \./, \.{div}, \.{mod}, or \.{@@\&}. Note that if |y| has been defined -to equal $-2$, we must expand `\.{x*y}' into `\.{x*(-2)}'; but `\.{x-y}' -can expand into `\.{x+2}' and we can even change `\.{x - y mod z}' to -@^mod@> -`\.{x + 2 mod z}' because \PASCAL\ has a nonstandard \&{mod} operation! - -The following solution to these problems has been adopted: An array -|out_buf| contains characters that have been generated but not yet output, -and there are three pointers into this array. One of these, |out_ptr|, is -the number of characters currently in the buffer, and we will have -|1<=out_ptr<=line_length| most of the time. The second is |break_ptr|, -which is the largest value |<=out_ptr| such that we are definitely entitled -to end a line by outputting the characters |out_buf[1..(break_ptr-1)]|; -we will always have |break_ptr<=line_length|. Finally, |semi_ptr| is either -zero or the largest known value of a legal break after a semicolon or comment -on the current line; we will always have |semi_ptr<=break_ptr|. - -@= -@!out_buf: array [0..out_buf_size] of ASCII_code; {assembled characters} -@!out_ptr: 0..out_buf_size; {first available place in |out_buf|} -@!break_ptr: 0..out_buf_size; {last breaking place in |out_buf|} -@!semi_ptr: 0..out_buf_size; {last semicolon breaking place in |out_buf|} - -@ Besides having those three pointers, -the output process is in one of several states: - -\yskip\hang |num_or_id| means that the last item in the buffer is a number or -identifier, hence a blank space or line break must be inserted if the next -item is also a number or identifier. - -\yskip\hang |unbreakable| means that the last item in the buffer was followed -by the \.{@@\&} operation that inhibits spaces between it and the next item. - -\yskip\hang |sign| means that the last item in the buffer is to be followed -by \.+ or \.-, depending on whether |out_app| is positive or negative. - -\yskip\hang |sign_val| means that the decimal equivalent of -$\vert|out_val|\vert$ should be appended to the buffer. If |out_val<0|, -or if |out_val=0| and |last_sign<0|, the number should be preceded by a minus -sign. Otherwise it should be preceded by the character |out_sign| unless -|out_sign=0|; the |out_sign| variable is either 0 or \.{"\ "} or \.{"+"}. - -\yskip\hang |sign_val_sign| is like |sign_val|, but also append \.+ or \.- -afterwards, depending on whether |out_app| is positive or negative. - -\yskip\hang |sign_val_val| is like |sign_val|, but also append the decimal -equivalent of |out_app| including its sign, using |last_sign| in case -|out_app=0|. - -\yskip\hang |misc| means none of the above. - -\yskip\noindent -For example, the output buffer and output state run through the following -sequence as we generate characters from `\.{(x-15+19-2)}': -$$\vbox{\halign{$\hfil#\hfil$\quad&#\hfil&\quad\hfil#\hfil&\quad -\hfil#\hfil&\quad\hfil#\hfil&\quad\hfil#\hfil\quad&\hfil#\hfil\cr -output&|out_buf|&|out_state|&|out_sign|&|out_val|&|out_app|&|last_sign|\cr -\noalign{\vskip 3pt} -(&\.(&|misc|\cr -x&\.{(x}&|num_or_id|\cr --&\.{(x}&|sign|&&&$-1$&$-1$\cr -15&\.{(x}&|sign_val|&\.{"+"}&$-15$&&$-15$\cr -+&\.{(x}&|sign_val_sign|&\.{"+"}&$-15$&$+1$&$+1$\cr -19&\.{(x}&|sign_val_val|&\.{"+"}&$-15$&$+19$&$+1$\cr --&\.{(x}&|sign_val_sign|&\.{"+"}&$+4$&$-1$&$-1$\cr -2&\.{(x}&|sign_val_val|&\.{"+"}&$+4$&$-2$&$-2$\cr -)&\.{(x+2)}&|misc|\cr}}$$ -At each stage we have put as much into the buffer as possible without -knowing what is coming next. Examples like `\.{x-0.1}' indicate why -|last_sign| is needed to associate the proper sign with an output of zero. - -In states |num_or_id|, |unbreakable|, and |misc| the last item in the buffer -lies between |break_ptr| and |out_ptr-1|, inclusive; in the other states we -have |break_ptr=out_ptr|. - -The numeric values assigned to |num_or_id|, etc., have been chosen to -shorten some of the program logic; for example, the program makes use of -the fact that |sign+2=sign_val_sign|. - -@d misc=0 {state associated with special characters} -@d num_or_id=1 {state associated with numbers and identifiers} -@d sign=2 {state associated with pending \.+ or \.-} -@d sign_val=num_or_id+2 {state associated with pending sign and value} -@d sign_val_sign=sign+2 {|sign_val| followed by another pending sign} -@d sign_val_val=sign_val+2 {|sign_val| followed by another pending value} -@d unbreakable=sign_val_val+1 {state associated with \.{@@\&}} - -@= -@!out_state:eight_bits; {current status of partial output} -@!out_val,@!out_app:integer; {pending values} -@!out_sign:ASCII_code; {sign to use if appending |out_val>=0|} -@!last_sign:-1..+1; {sign to use if appending a zero} - -@ During the output process, |line| will equal the number of the next line -to be output. - -@= -out_state:=misc; out_ptr:=0; break_ptr:=0; semi_ptr:=0; out_buf[0]:=0; line:=1; - -@ Here is a routine that is invoked when |out_ptr>line_length| -or when it is time to flush out the final line. The |flush_buffer| procedure -often writes out the line up to the current |break_ptr| position, then moves the -remaining information to the front of |out_buf|. However, it prefers to -write only up to |semi_ptr|, if the residual line won't be too long. - -@d check_break==if out_ptr>line_length then flush_buffer - -@p procedure flush_buffer; {writes one line to output file} -var k:0..out_buf_size; {index into |out_buf|} -@!b:0..out_buf_size; {value of |break_ptr| upon entry} -begin b:=break_ptr; -if (semi_ptr<>0)and(out_ptr-semi_ptr<=line_length) then break_ptr:=semi_ptr; -for k:=1 to break_ptr do write(Pascal_file,xchr[out_buf[k-1]]); -write_ln(Pascal_file); incr(line); -if line mod 100 = 0 then - begin print('.'); - if line mod 500 = 0 then print(line:1); - update_terminal; {progress report} - end; -if break_ptrb then b:=break_ptr; - end; - for k:=break_ptr to out_ptr-1 do out_buf[k-break_ptr]:=out_buf[k]; - end; -out_ptr:=out_ptr-break_ptr; break_ptr:=b-break_ptr; semi_ptr:=0; -if out_ptr>line_length then - begin err_print('! Long line must be truncated'); out_ptr:=line_length; -@.Long line must be truncated@> - end; -end; - -@ @= -break_ptr:=out_ptr; semi_ptr:=0; flush_buffer; -if brace_level<>0 then - err_print('! Program ended at brace level ',brace_level:1); -@.Program ended at brace level n@> - -@ Another simple and useful routine appends the decimal equivalent of -a nonnegative integer to the output buffer. - -@d app(#)==begin out_buf[out_ptr]:=#; incr(out_ptr); {append a single character} - end - -@p procedure app_val(@!v:integer); {puts |v| into buffer, assumes |v>=0|} -var k:0..out_buf_size; {index into |out_buf|} -begin k:=out_buf_size; {first we put the digits at the very end of |out_buf|} -repeat out_buf[k]:=v mod 10; v:=v div 10; decr(k); -until v=0; -repeat incr(k); app(out_buf[k]+"0"); -until k=out_buf_size; {then we append them, most significant first} -end; - -@ The output states are kept up to date by the output routines, which are -called |send_out|, |send_val|, and |send_sign|. The |send_out| procedure -has two parameters: |t| tells the type of information being sent and -|v| contains the information proper. Some information may also be passed -in the array |out_contrib|. - -\yskip\hang If |t=misc| then |v| is a character to be output. - -\hang If |t=str| then |v| is the length of a string or something like `\.{<>}' -in |out_contrib|. - -\hang If |t=ident| then |v| is the length of an identifier in |out_contrib|. - -\hang If |t=frac| then |v| is the length of a fraction and/or exponent in -|out_contrib|. - -@d str=1 {|send_out| code for a string} -@d ident=2 {|send_out| code for an identifier} -@d frac=3 {|send_out| code for a fraction} - -@= -@!out_contrib:array[1..line_length] of ASCII_code; {a contribution to |out_buf|} - -@ A slightly subtle point in the following code is that the user may ask -for a |join| operation (i.e., \.{@@\&}) following whatever is being sent -out. We will see later that |join| is implemented in part by calling -|send_out(frac,0)|. - -@p procedure send_out(@!t:eight_bits; @!v:sixteen_bits); - {outputs |v| of type |t|} -label restart; -var k: 0..line_length; {index into |out_contrib|} -begin @; -if t<>misc then for k:=1 to v do app(out_contrib[k]) -else app(v); -check_break; -if (t=misc)and((v=";")or(v="}")) then - begin semi_ptr:=out_ptr; break_ptr:=out_ptr; - end; -if t>=ident then out_state:=num_or_id {|t=ident| or |frac|} -else out_state:=misc {|t=str| or |misc|} -end; - -@ Here is where the buffer states for signs and values collapse into simpler -states, because we are about to append something that doesn't combine with -the previous integer constants. - -We use an ASCII-code trick: Since |","-1="+"| and |","+1="-"|, we have -|","-c=@t sign of $c$@>|, when $\vert c\vert=1$. - -@= -restart: case out_state of -num_or_id: if t<>frac then - begin break_ptr:=out_ptr; - if t=ident then app(" "); - end; -sign: begin app(","-out_app); check_break; break_ptr:=out_ptr; - end; -sign_val,sign_val_sign: begin @; - out_state:=out_state-2; goto restart; - end; -sign_val_val: @; -misc: if t<>frac then break_ptr:=out_ptr;@/ -othercases do_nothing {this is for |unbreakable| state} -endcases - -@ @= -if (out_val<0)or((out_val=0)and(last_sign<0)) then app("-") -else if out_sign>0 then app(out_sign); -app_val(abs(out_val)); check_break; - -@ @= -begin if (t=frac)or(@) then - begin @; - out_sign:="+"; out_val:=out_app; - end -else out_val:=out_val+out_app; -out_state:=sign_val; goto restart; -end - -@ @= -((t=ident)and(v=3)and@| - (((out_contrib[1]="D")and(out_contrib[2]="I")and(out_contrib[3]="V")) or@| - ((out_contrib[1]="M")and(out_contrib[2]="O")and(out_contrib[3]="D")) ))or@| -@^uppercase@> - ((t=misc)and((v="*")or(v="/"))) - -@ The following routine is called with $v=\pm1$ when a plus or minus sign is -appended to the output. It extends \PASCAL\ to allow repeated signs -(e.g., `\.{--}' is equivalent to `\.+'), rather than to give an error message. -The signs following `\.E' in real constants are treated as part of a fraction, -so they are not seen by this routine. - -@p procedure send_sign(@!v:integer); -begin case out_state of -sign, sign_val_sign: out_app:=out_app*v; -sign_val:begin out_app:=v; out_state:=sign_val_sign; - end; -sign_val_val: begin out_val:=out_val+out_app; out_app:=v; - out_state:=sign_val_sign; - end; -othercases begin break_ptr:=out_ptr; out_app:=v; out_state:=sign; - end -endcases;@/ -last_sign:=out_app; -end; - -@ When a (signed) integer value is to be output, we call |send_val|. - -@d bad_case=666 {this is a label used below} - -@p procedure send_val(@!v:integer); {output the (signed) value |v|} -label bad_case, {go here if we can't keep |v| in the output state} - exit; -begin case out_state of -num_or_id: begin @; - out_sign:=" "; out_state:=sign_val; out_val:=v; break_ptr:=out_ptr; - last_sign:=+1; - end; -misc: begin @; - out_sign:=0; out_state:=sign_val; out_val:=v; break_ptr:=out_ptr; - last_sign:=+1; - end; -@t\4@>@@; -othercases goto bad_case -endcases;@/ -return; -bad_case: @; -exit: end; - -@ @= -sign: begin out_sign:="+"; out_state:=sign_val; out_val:=out_app*v; - end; -sign_val: begin out_state:=sign_val_val; out_app:=v; - err_print('! Two numbers occurred without a sign between them'); - end; -sign_val_sign: begin out_state:=sign_val_val; out_app:=out_app*v; - end; -sign_val_val: begin out_val:=out_val+out_app; out_app:=v; - err_print('! Two numbers occurred without a sign between them'); -@.Two numbers occurred...@> - end; - -@ @= -if (out_ptr=break_ptr+1)and((out_buf[break_ptr]="*")or(out_buf[break_ptr]="/")) - then goto bad_case - -@ @= -if (out_ptr=break_ptr+3)or - ((out_ptr=break_ptr+4)and(out_buf[break_ptr]=" ")) then -@^uppercase@> - if ((out_buf[out_ptr-3]="D")and(out_buf[out_ptr-2]="I")and - (out_buf[out_ptr-1]="V"))or @/ - ((out_buf[out_ptr-3]="M")and(out_buf[out_ptr-2]="O")and - (out_buf[out_ptr-1]="D")) then@/ goto bad_case - -@ @= -if v>=0 then - begin if out_state=num_or_id then - begin break_ptr:=out_ptr; app(" "); - end; - app_val(v); check_break; out_state:=num_or_id; - end -else begin app("("); app("-"); app_val(-v); app(")"); check_break; - out_state:=misc; - end - -@* The big output switch. -To complete the output process, we need a routine that takes the results -of |get_output| and feeds them to |send_out|, |send_val|, or |send_sign|. -This procedure `|send_the_output|' will be invoked just once, as follows: - -@= -if text_link[0]=0 then - begin print_nl('! No output was specified.'); mark_harmless; -@.No output was specified@> - end -else begin print_nl('Writing the output file'); update_terminal;@/ - @; - @; - send_the_output;@/ - @; - print_nl('Done.'); - end - -@ A many-way switch is used to send the output: - -@d get_fraction=2 {this label is used below} - -@p procedure send_the_output; -label get_fraction, {go here to finish scanning a real constant} - reswitch, continue; -var cur_char:eight_bits; {the latest character received} - @!k:0..line_length; {index into |out_contrib|} - @!j:0..max_bytes; {index into |byte_mem|} - @!w:0..ww-1; {segment of |byte_mem|} - @!n:integer; {number being scanned} -begin while stack_ptr>0 do - begin cur_char:=get_output; - reswitch: case cur_char of - 0: do_nothing; {this case might arise if output ends unexpectedly} - @t\4@>@@; - @t\4@>@@; - "+","-": send_sign(","-cur_char); - @t\4@>@} and \.{:=}@>@; - "'": @; - @: send_out(misc,cur_char); - @t\4@>@@; - join: begin send_out(frac,0); out_state:=unbreakable; - end; - verbatim: @; - force_line: @; - othercases err_print('! Can''t output ASCII code ',cur_char:1) -@.Can't output ASCII code n@> - endcases;@/ - goto continue; - get_fraction: @; - continue: end; -end; - -@ @}...@>= -and_sign: begin out_contrib[1]:="A"; out_contrib[2]:="N"; out_contrib[3]:="D"; -@^uppercase@> - send_out(ident,3); - end; -not_sign: begin out_contrib[1]:="N"; out_contrib[2]:="O"; out_contrib[3]:="T"; - send_out(ident,3); - end; -set_element_sign: begin out_contrib[1]:="I"; out_contrib[2]:="N"; - send_out(ident,2); - end; -or_sign: begin out_contrib[1]:="O"; out_contrib[2]:="R"; send_out(ident,2); - end; -left_arrow: begin out_contrib[1]:=":"; out_contrib[2]:="="; send_out(str,2); - end; -not_equal: begin out_contrib[1]:="<"; out_contrib[2]:=">"; send_out(str,2); - end; -less_or_equal: begin out_contrib[1]:="<"; out_contrib[2]:="="; send_out(str,2); - end; -greater_or_equal: begin out_contrib[1]:=">"; out_contrib[2]:="="; - send_out(str,2); - end; -equivalence_sign: begin out_contrib[1]:="="; out_contrib[2]:="="; - send_out(str,2); - end; -double_dot: begin out_contrib[1]:="."; out_contrib[2]:="."; send_out(str,2); - end; - -@ Please don't ask how all of the following characters can actually get -through \.{TANGLE} outside of strings. It seems that |""""| and |"{"| -cannot actually occur at this point of the program, but they have -been included just in case \.{TANGLE} changes. - -If \.{TANGLE} is producing code for a \PASCAL\ compiler that uses `\.{(.}' -and `\.{.)}' instead of square brackets (e.g., on machines with {\mc EBCDIC} -code), one should remove |"["| and |"]"| from this list and put them into -the preceding module in the appropriate way. Similarly, some compilers -want `\.\^' to be converted to `\.{@@}'. -@^system dependencies@>@^EBCDIC@> - -@= -"!","""","#","$","%","&","(",")","*",",","/",":",";","<","=",">","?", -"@@","[","\","]","^","_","`","{","|" - -@ Single-character identifiers represent themselves, while longer ones -appear in |byte_mem|. All must be converted to uppercase, -with underlines removed. Extremely long identifiers must be chopped. - -(Some \PASCAL\ compilers work with lowercase letters instead of -uppercase. If this module of \.{TANGLE} is changed, it's also necessary -to change from uppercase to lowercase in the modules that are -listed in the index under ``uppercase''.) -@^system dependencies@> -@^uppercase@> - -@d up_to(#)==#-24,#-23,#-22,#-21,#-20,#-19,#-18,#-17,#-16,#-15,#-14, - #-13,#-12,#-11,#-10,#-9,#-8,#-7,#-6,#-5,#-4,#-3,#-2,#-1,# - -@= -"A",up_to("Z"): begin out_contrib[1]:=cur_char; send_out(ident,1); - end; -"a",up_to("z"): begin out_contrib[1]:=cur_char-@'40; send_out(ident,1); - end; -identifier: begin k:=0; j:=byte_start[cur_val]; w:=cur_val mod ww; - while (k="a" then out_contrib[k]:=out_contrib[k]-@'40 - else if out_contrib[k]="_" then decr(k); - end; - send_out(ident,k); - end; - -@ After sending a string, we need to look ahead at the next character, in order -to see if there were two consecutive single-quote marks. Afterwards we go to -|reswitch| to process the next character. - -@= -begin k:=1; out_contrib[1]:="'"; -repeat if k -send_out(str,k); cur_char:=get_output; -if cur_char="'" then out_state:=unbreakable; -goto reswitch; -end - -@ Sending a verbatim string is similar, but we don't have to look ahead. - -@= -begin k:=0; -repeat if k -send_out(str,k-1); -end - -@ In order to encourage portable software, \.{TANGLE} complains -if the constants get dangerously close to the largest value representable -on a 32-bit computer ($2^{31}-1$). - -@d digits=="0","1","2","3","4","5","6","7","8","9" - -@= -digits: begin n:=0; - repeat cur_char:=cur_char-"0"; - if n>=@'1463146314 then err_print('! Constant too big') -@.Constant too big@> - else n:=10*n+cur_char; - cur_char:=get_output; - until (cur_char>"9")or(cur_char<"0"); - send_val(n); k:=0; - if cur_char="e" then cur_char:="E"; -@^uppercase@> - if cur_char="E" then goto get_fraction - else goto reswitch; - end; -check_sum: send_val(pool_check_sum); -octal: begin n:=0; cur_char:="0"; - repeat cur_char:=cur_char-"0"; - if n>=@'2000000000 then err_print('! Constant too big') - else n:=8*n+cur_char; - cur_char:=get_output; - until (cur_char>"7")or(cur_char<"0"); - send_val(n); goto reswitch; - end; -hex: begin n:=0; cur_char:="0"; - repeat if cur_char>="A" then cur_char:=cur_char+10-"A" - else cur_char:=cur_char-"0"; - if n>=@"8000000 then err_print('! Constant too big') - else n:=16*n+cur_char; - cur_char:=get_output; - until (cur_char>"F")or(cur_char<"0")or@| - ((cur_char>"9")and(cur_char<"A")); - send_val(n); goto reswitch; - end; -number: send_val(cur_val); -".": begin k:=1; out_contrib[1]:="."; cur_char:=get_output; - if cur_char="." then - begin out_contrib[2]:="."; send_out(str,2); - end - else if (cur_char>="0")and(cur_char<="9") then goto get_fraction - else begin send_out(misc,"."); goto reswitch; - end; - end; - -@ The following code appears at label `|get_fraction|', when we want to -scan to the end of a real constant. The first |k| characters of a fraction -have already been placed in |out_contrib|, and |cur_char| is the next character. - -@= -repeat if k - begin if k"E")and((cur_char<"0")or(cur_char>"9")); -if k=line_length then err_print('! Fraction too long'); -@.Fraction too long@> -send_out(frac,k); goto reswitch - -@ Some \PASCAL\ compilers do not recognize comments in braces, so the -comments must be delimited by `\.{(*}' and `\.{*)}'. -@^system dependencies@> -In such cases the statement `|send_out(misc,"{")|' that appears here should -be replaced by `\ignorespaces|begin out_contrib[1]:="("; out_contrib[2]:="*"; -send_out(str,2); end|', and a similar change should be made to -`|send_out(misc,"}")|'. - -@= -begin_comment: begin if brace_level=0 then send_out(misc,"{") - else send_out(misc,"["); - incr(brace_level); - end; -end_comment: if brace_level>0 then - begin decr(brace_level); - if brace_level=0 then send_out(misc,"}") - else send_out(misc,"]"); - end - else err_print('! Extra @@}'); -@.Extra \AT!\}@> -module_number: begin if brace_level=0 then send_out(misc,"{") - else send_out(misc,"["); - if cur_val<0 then - begin send_out(misc,":"); send_val(-cur_val); - end - else begin send_val(cur_val); send_out(misc,":"); - end; - if brace_level=0 then send_out(misc,"}") - else send_out(misc,"]"); - end; - -@ @= -begin send_out(str,0); {normalize the buffer} -while out_ptr>0 do - begin if out_ptr<=line_length then break_ptr:=out_ptr; - flush_buffer; - end; -out_state:=misc; -end - -@* Introduction to the input phase. -We have now seen that \.{TANGLE} will be able to output the full -\PASCAL\ program, if we can only get that program into the byte memory in -the proper format. The input process is something like the output process -in reverse, since we compress the text as we read it in and we expand it -as we write it out. - -There are three main input routines. The most interesting is the one that gets -the next token of a \PASCAL\ text; the other two are used to scan rapidly past -\TeX\ text in the \.{WEB} source code. One of the latter routines will jump to -the next token that starts with `\.{@@}', and the other skips to the end -of a \PASCAL\ comment. - -@ But first we need to consider the low-level routine |get_line| -that takes care of merging |change_file| into |web_file|. The |get_line| -procedure also updates the line numbers for error messages. - -@= -@!ii:integer; {general purpose |for| loop variable in the outer block} -@!line:integer; {the number of the current line in the current file} -@!other_line:integer; {the number of the current line in the input file that - is not currently being read} -@!temp_line:integer; {used when interchanging |line| with |other_line|} -@!limit:0..buf_size; {the last character position occupied in the buffer} -@!loc:0..buf_size; {the next character position to be read from the buffer} -@!input_has_ended: boolean; {if |true|, there is no more input} -@!changing: boolean; {if |true|, the current line is from |change_file|} - -@ As we change |changing| from |true| to |false| and back again, we must -remember to swap the values of |line| and |other_line| so that the |err_print| -routine will be sure to report the correct line number. - -@d change_changing== - changing := not changing; - temp_line:=other_line; other_line:=line; line:=temp_line - {|line @t$\null\BA\null$@> other_line|} - -@ When |changing| is |false|, the next line of |change_file| is kept in -|change_buffer[0..change_limit]|, for purposes of comparison with the next -line of |web_file|. After the change file has been completely input, we -set |change_limit:=0|, so that no further matches will be made. - -@= -@!change_buffer:array[0..buf_size] of ASCII_code; -@!change_limit:0..buf_size; {the last position occupied in |change_buffer|} - -@ Here's a simple function that checks if the two buffers are different. - -@p function lines_dont_match:boolean; -label exit; -var k:0..buf_size; {index into the buffers} -begin lines_dont_match:=true; -if change_limit<>limit then return; -if limit>0 then - for k:=0 to limit-1 do if change_buffer[k]<>buffer[k] then return; -lines_dont_match:=false; -exit: end; - -@ Procedure |prime_the_change_buffer| sets |change_buffer| in preparation -for the next matching operation. Since blank lines in the change file are -not used for matching, we have |(change_limit=0)and not changing| if and -only if the change file is exhausted. This procedure is called only -when |changing| is true; hence error messages will be reported correctly. - -@p procedure prime_the_change_buffer; -label continue, done, exit; -var k:0..buf_size; {index into the buffers} -begin change_limit:=0; {this value will be used if the change file ends} -@; -@; -@; -exit: end; - -@ While looking for a line that begins with \.{@@x} in the change file, -we allow lines that begin with \.{@@}, as long as they don't begin with -\.{@@y} or \.{@@z} (which would probably indicate that the change file is -fouled up). - -@= -loop@+ begin incr(line); - if not input_ln(change_file) then return; - if limit<2 then goto continue; - if buffer[0]<>"@@" then goto continue; - if (buffer[1]>="X")and(buffer[1]<="Z") then - buffer[1]:=buffer[1]+"z"-"Z"; {lowercasify} - if buffer[1]="x" then goto done; - if (buffer[1]="y")or(buffer[1]="z") then - begin loc:=2; err_print('! Where is the matching @@x?'); -@.Where is the match...@> - end; -continue: end; -done: - -@ Here we are looking at lines following the \.{@@x}. - -@= -repeat incr(line); - if not input_ln(change_file) then - begin err_print('! Change file ended after @@x'); -@.Change file ended...@> - return; - end; -until limit>0; - -@ @= -begin change_limit:=limit; -if limit>0 then for k:=0 to limit-1 do change_buffer[k]:=buffer[k]; -end - -@ The following procedure is used to see if the next change entry should -go into effect; it is called only when |changing| is false. -The idea is to test whether or not the current -contents of |buffer| matches the current contents of |change_buffer|. -If not, there's nothing more to do; but if so, a change is called for: -All of the text down to the \.{@@y} is supposed to match. An error -message is issued if any discrepancy is found. Then the procedure -prepares to read the next line from |change_file|. - -@p procedure check_change; {switches to |change_file| if the buffers match} -label exit; -var n:integer; {the number of discrepancies found} -@!k:0..buf_size; {index into the buffers} -begin if lines_dont_match then return; -n:=0; -loop@+ begin change_changing; {now it's |true|} - incr(line); - if not input_ln(change_file) then - begin err_print('! Change file ended before @@y'); -@.Change file ended...@> - change_limit:=0; change_changing; {|false| again} - return; - end; - @; - @; - change_changing; {now it's |false|} - incr(line); - if not input_ln(web_file) then - begin err_print('! WEB file ended during a change'); -@.WEB file ended...@> - input_has_ended:=true; return; - end; - if lines_dont_match then incr(n); - end; -exit: end; - -@ @= -if limit>1 then if buffer[0]="@@" then - begin if (buffer[1]>="X")and(buffer[1]<="Z") then - buffer[1]:=buffer[1]+"z"-"Z"; {lowercasify} - if (buffer[1]="x")or(buffer[1]="z") then - begin loc:=2; err_print('! Where is the matching @@y?'); -@.Where is the match...@> - end - else if buffer[1]="y" then - begin if n>0 then - begin loc:=2; err_print('! Hmm... ',n:1, - ' of the preceding lines failed to match'); -@.Hmm... n of the preceding...@> - end; - return; - end; - end - -@ @= -open_input; line:=0; other_line:=0;@/ -changing:=true; prime_the_change_buffer; change_changing;@/ -limit:=0; loc:=1; buffer[0]:=" "; input_has_ended:=false; - -@ The |get_line| procedure is called when |loc>limit|; it puts the next -line of merged input into the buffer and updates the other variables -appropriately. A space is placed at the right end of the line. - -@p procedure get_line; {inputs the next line} -label restart; -begin restart: if changing then - @; -if not changing then - begin @; - if changing then goto restart; - end; -loc:=0; buffer[limit]:=" "; -end; - -@ @= -begin incr(line); -if not input_ln(web_file) then input_has_ended:=true -else if limit=change_limit then - if buffer[0]=change_buffer[0] then - if change_limit>0 then check_change; -end - -@ @= -begin incr(line); -if not input_ln(change_file) then - begin err_print('! Change file ended without @@z'); -@.Change file ended...@> - buffer[0]:="@@"; buffer[1]:="z"; limit:=2; - end; -if limit>1 then {check if the change has ended} - if buffer[0]="@@" then - begin if (buffer[1]>="X")and(buffer[1]<="Z") then - buffer[1]:=buffer[1]+"z"-"Z"; {lowercasify} - if (buffer[1]="x")or(buffer[1]="y") then - begin loc:=2; err_print('! Where is the matching @@z?'); -@.Where is the match...@> - end - else if buffer[1]="z" then - begin prime_the_change_buffer; change_changing; - end; - end; -end - -@ At the end of the program, we will tell the user if the change file -had a line that didn't match any relevant line in |web_file|. - -@= -if change_limit<>0 then {|changing| is false} - begin for ii:=0 to change_limit do buffer[ii]:=change_buffer[ii]; - limit:=change_limit; changing:=true; line:=other_line; loc:=change_limit; - err_print('! Change file entry did not match'); -@.Change file entry did not match@> - end - -@ Important milestones are reached during the input phase when certain -control codes are sensed. - -Control codes in \.{WEB} begin with `\.{@@}', and the next character -identifies the code. Some of these are of interest only to \.{WEAVE}, -so \.{TANGLE} ignores them; the others are converted by \.{TANGLE} into -internal code numbers by the |control_code| function below. The ordering -of these internal code numbers has been chosen to simplify the program logic; -larger numbers are given to the control codes that denote more significant -milestones. - -@d ignore=0 {control code of no interest to \.{TANGLE}} -@d control_text=@'203 {control code for `\.{@@t}', `\.{@@\^}', etc.} -@d format=@'204 {control code for `\.{@@f}'} -@d definition=@'205 {control code for `\.{@@d}'} -@d begin_Pascal=@'206 {control code for `\.{@@p}'} -@d module_name=@'207 {control code for `\.{@@<}'} -@d new_module=@'210 {control code for `\.{@@\ }' and `\.{@@*}'} - -@p function control_code(@!c:ASCII_code):eight_bits; {convert |c| after \.{@@}} -begin case c of -"@@": control_code:="@@"; {`quoted' at sign} -"'": control_code:=octal; {precedes octal constant} -"""": control_code:=hex; {precedes hexadecimal constant} -"$": control_code:=check_sum; {string pool check sum} -" ",tab_mark: control_code:=new_module; {beginning of a new module} -"*": begin print('*',module_count+1:1); - update_terminal; {print a progress report} - control_code:=new_module; {beginning of a new module} - end; -"D","d": control_code:=definition; {macro definition} -"F","f": control_code:=format; {format definition} -"{": control_code:=begin_comment; {begin-comment delimiter} -"}": control_code:=end_comment; {end-comment delimiter} -"P","p": control_code:=begin_Pascal; {\PASCAL\ text in unnamed module} -"T","t","^",".",":": control_code:=control_text; {control text to be ignored} -"&": control_code:=join; {concatenate two tokens} -"<": control_code:=module_name; {beginning of a module name} -"=": control_code:=verbatim; {beginning of \PASCAL\ verbatim mode} -"\": control_code:=force_line; {force a new line in \PASCAL\ output} -othercases control_code:=ignore {ignore all other cases} -endcases; -end; - -@ The |skip_ahead| procedure reads through the input at fairly high speed -until finding the next non-ignorable control code, which it returns. - -@p function skip_ahead:eight_bits; {skip to next control code} -label done; -var c:eight_bits; {control code found} -begin loop begin if loc>limit then - begin get_line; - if input_has_ended then - begin c:=new_module; goto done; - end; - end; - buffer[limit+1]:="@@"; - while buffer[loc]<>"@@" do incr(loc); - if loc<=limit then - begin loc:=loc+2; c:=control_code(buffer[loc-1]); - if (c<>ignore)or(buffer[loc-1]=">") then goto done; - end; - end; -done: skip_ahead:=c; -end; - -@ The |skip_comment| procedure reads through the input at somewhat high speed -until finding the first unmatched right brace or until coming to the end -of the file. It ignores characters following `\.\\' characters, since all -braces that aren't nested are supposed to be hidden in that way. For -example, consider the process of skipping the first comment below, -where the string containing the right brace has been typed as \.{\`\\.\\\}\'} -in the \.{WEB} file. - -@p procedure skip_comment; {skips to next unmatched `\.\}'} -label exit; -var bal:eight_bits; {excess of left braces} -@!c:ASCII_code; {current character} -begin bal:=0; -loop@+ begin if loc>limit then - begin get_line; - if input_has_ended then - begin err_print('! Input ended in mid-comment'); -@.Input ended in mid-comment@> - return; - end; - end; - c:=buffer[loc]; incr(loc); - @; - end; -exit:end; - -@ @= -if c="@@" then - begin c:=buffer[loc]; - if (c<>" ")and(c<>tab_mark)and(c<>"*")and(c<>"z")and(c<>"Z") then incr(loc) - else begin err_print('! Section ended in mid-comment'); -@.Section ended in mid-comment@> - decr(loc); return; - end - end -else if (c="\")and(buffer[loc]<>"@@") then incr(loc) -else if c="{" then incr(bal) -else if c="}" then - begin if bal=0 then return; - decr(bal); - end - -@* Inputting the next token. -As stated above, \.{TANGLE}'s most interesting input procedure is the -|get_next| routine that inputs the next token. However, the procedure -isn't especially difficult. - -In most cases the tokens output by |get_next| have the form used in -replacement texts, except that two-byte tokens are not produced. -An identifier that isn't one letter long is represented by the -output `|identifier|', and in such a case the global variables -|id_first| and |id_loc| will have been set to the appropriate values -needed by the |id_lookup| procedure. A string that begins with a -double-quote is also considered an |identifier|, and in such a case -the global variable |double_chars| will also have been set appropriately. -Control codes produce the corresponding output of the |control_code| -function above; and if that code is |module_name|, the value of |cur_module| -will point to the |byte_start| entry for that module name. - -Another global variable, |scanning_hex|, is |true| during the time that -the letters \.A through \.F should be treated as if they were digits. - -@= -@!cur_module: name_pointer; {name of module just scanned} -@!scanning_hex: boolean; {are we scanning a hexadecimal constant?} - -@ @= -scanning_hex:=false; - -@ At the top level, |get_next| is a multi-way switch based on the next -character in the input buffer. A |new_module| code is inserted at the -very end of the input file. - -@p function get_next:eight_bits; {produces the next input token} -label restart,done,found; -var c:eight_bits; {the current character} -@!d:eight_bits; {the next character} -@!j,@!k:0..longest_name; {indices into |mod_text|} -begin restart: if loc>limit then - begin get_line; - if input_has_ended then - begin c:=new_module; goto found; - end; - end; -c:=buffer[loc]; incr(loc); -if scanning_hex then @; -case c of -"A",up_to("Z"),"a",up_to("z"): @; -"""": @; -"@@": @; -@t\4@>@@; -" ",tab_mark: goto restart; {ignore spaces and tabs} -"{": begin skip_comment; goto restart; - end; -"}": begin err_print('! Extra }'); goto restart; -@.Extra \}@> - end; -othercases if c>=128 then goto restart {ignore nonstandard characters} - else do_nothing -endcases; -found:@!debug if trouble_shooting then debug_help;@;@+gubed@/ -get_next:=c; -end; - -@ @= -if ((c>="0")and(c<="9"))or((c>="A")and(c<="F")) then goto found -else scanning_hex:=false - -@ Note that the following code substitutes \.{@@\{} and \.{@@\}} for the -respective combinations `\.{(*}' and `\.{*)}'. Explicit braces should be used -for \TeX\ comments in \PASCAL\ text. - -@d compress(#)==begin if loc<=limit then begin c:=#; incr(loc); end; end - -@= -".": if buffer[loc]="." then compress(double_dot) - else if buffer[loc]=")" then compress("]"); -":": if buffer[loc]="=" then compress(left_arrow); -"=": if buffer[loc]="=" then compress(equivalence_sign); -">": if buffer[loc]="=" then compress(greater_or_equal); -"<": if buffer[loc]="=" then compress(less_or_equal) - else if buffer[loc]=">" then compress(not_equal); -"(": if buffer[loc]="*" then compress(begin_comment) - else if buffer[loc]="." then compress("["); -"*": if buffer[loc]=")" then compress(end_comment); - -@ We have to look at the preceding character to make sure this isn't part -of a real constant, before trying to find an identifier starting with -`\.e' or `\.E'. - -@= -begin if ((c="e")or(c="E"))and(loc>1) then - if (buffer[loc-2]<="9")and(buffer[loc-2]>="0") then c:=0; -if c<>0 then - begin decr(loc); id_first:=loc; - repeat incr(loc); d:=buffer[loc]; - until ((d<"0")or((d>"9")and(d<"A"))or((d>"Z")and(d<"a"))or(d>"z")) and - (d<>"_"); - if loc>id_first+1 then - begin c:=identifier; id_loc:=loc; - end; - end -else c:="E"; {exponent of a real constant} -end - -@ A string that starts and ends with double-quote marks is converted into -an identifier that behaves like a numeric macro by means of the following -piece of the program. -@^preprocessed strings@> - -@= -begin double_chars:=0; id_first:=loc-1; -repeat d:=buffer[loc]; incr(loc); - if (d="""")or(d="@@") then - if buffer[loc]=d then - begin incr(loc); d:=0; incr(double_chars); - end - else begin if d="@@" then err_print('! Double @@ sign missing') -@.Double \AT! sign missing@> - end - else if loc>limit then - begin err_print('! String constant didn''t end'); d:=""""; -@.String constant didn't end@> - end; -until d=""""; -id_loc:=loc-1; c:=identifier; -end - -@ After an \.{@@} sign has been scanned, the next character tells us -whether there is more work to do. - -@= -begin c:=control_code(buffer[loc]); incr(loc); -if c=ignore then goto restart -else if c=hex then scanning_hex:=true -else if c=module_name then - @ -else if c=control_text then - begin repeat c:=skip_ahead; - until c<>"@@"; - if buffer[loc-1]<>">" then - err_print('! Improper @@ within control text'); -@.Improper \AT! within control text@> - goto restart; - end; -end - -@ @= -begin @; -if k>3 then - begin if (mod_text[k]=".")and(mod_text[k-1]=".")and(mod_text[k-2]=".") then - cur_module:=prefix_lookup(k-3) - else cur_module:=mod_lookup(k); - end -else cur_module:=mod_lookup(k); -end - -@ Module names are placed into the |mod_text| array with consecutive spaces, -tabs, and carriage-returns replaced by single spaces. There will be no -spaces at the beginning or the end. (We set |mod_text[0]:=" "| to facilitate -this, since the |mod_lookup| routine uses |mod_text[1]| as the first -character of the name.) - -@=mod_text[0]:=" "; - -@ @= -k:=0; -loop@+ begin if loc>limit then - begin get_line; - if input_has_ended then - begin err_print('! Input ended in section name'); -@.Input ended in section name@> - goto done; - end; - end; - d:=buffer[loc]; - @; - incr(loc); if k; -if (mod_text[k]=" ")and(k>0) then decr(k); - -@ @= -if d="@@" then - begin d:=buffer[loc+1]; - if d=">" then - begin loc:=loc+2; goto done; - end; - if (d=" ")or(d=tab_mark)or(d="*") then - begin err_print('! Section name didn''t end'); goto done; -@.Section name didn't end@> - end; - incr(k); mod_text[k]:="@@"; incr(loc); {now |d=buffer[loc]| again} - end - -@ @= -if k>=longest_name-2 then - begin print_nl('! Section name too long: '); -@.Section name too long@> - for j:=1 to 25 do print(xchr[mod_text[j]]); - print('...'); mark_harmless; - end - -@* Scanning a numeric definition. -When \.{TANGLE} looks at the \PASCAL\ text following the `\.=' of a numeric -macro definition, it calls on the precedure |scan_numeric(p)|, where |p| -points to the name that is to be defined. This procedure evaluates the -right-hand side, which must consist entirely of integer constants and -defined numeric macros connected with \.+ and \.- signs (no parentheses). -It also sets the global variable |next_control| to the control code that -terminated this definition. - -A definition ends with the control codes |definition|, |format|, |module_name|, -|begin_Pascal|, and |new_module|, all of which can be recognized -by the fact that they are the largest values |get_next| can return. - -@d end_of_definition(#)==(#>=format) - {is |#| a control code ending a definition?} - -@= -@!next_control:eight_bits; {control code waiting to be acted upon} - -@ The evaluation of a numeric expression makes use of two variables called the -|accumulator| and the |next_sign|. At the beginning, |accumulator| is zero and -|next_sign| is $+1$. When a \.+ or \.- is scanned, |next_sign| is multiplied -by the value of that sign. When a numeric value is scanned, it is multiplied by -|next_sign| and added to the |accumulator|, then |next_sign| is reset to $+1$. - -@d add_in(#)==begin accumulator:=accumulator+next_sign*(#); next_sign:=+1; - end - -@p procedure scan_numeric(@!p:name_pointer); {defines numeric macros} -label reswitch, done; -var accumulator:integer; {accumulates sums} -@!next_sign:-1..+1; {sign to attach to next value} -@!q:name_pointer; {points to identifiers being evaluated} -@!val:integer; {constants being evaluated} -begin @; -if abs(accumulator)>=1073741824 then - begin err_print('! Value too big: ',accumulator:1); accumulator:=0; -@.Value too big@> - end; -equiv[p]:=accumulator+1073741824; - {name |p| now is defined to equal |accumulator|} -end; - -@ @= -accumulator:=0; next_sign:=+1; -loop@+ begin next_control:=get_next; - reswitch: case next_control of - digits: begin @; - add_in(val); goto reswitch; - end; - octal: begin @; - add_in(val); goto reswitch; - end; - hex: begin @; - add_in(val); goto reswitch; - end; - identifier: begin q:=id_lookup(normal); - if ilk[q]<>numeric then - begin next_control:="*"; goto reswitch; {leads to error} - end; - add_in(equiv[q]-1073741824); - end; - "+": do_nothing; - "-": next_sign:=-next_sign; - format, definition, module_name, begin_Pascal, new_module: goto done; - ";": err_print('! Omit semicolon in numeric definition'); -@.Omit semicolon in numeric def...@> - othercases @ - endcases; - end; -done: - -@ @= -begin err_print('! Improper numeric definition will be flushed'); -@.Improper numeric definition...@> -repeat next_control:=skip_ahead -until end_of_definition(next_control); -if next_control=module_name then - begin {we want to scan the module name too} - loc:=loc-2; next_control:=get_next; - end; -accumulator:=0; goto done; -end - -@ @= -val:=0; -repeat val:=10*val+next_control-"0"; next_control:=get_next; -until (next_control>"9")or(next_control<"0") - -@ @= -val:=0; next_control:="0"; -repeat val:=8*val+next_control-"0"; next_control:=get_next; -until (next_control>"7")or(next_control<"0") - -@ @= -val:=0; next_control:="0"; -repeat if next_control>="A" then next_control:=next_control+"0"+10-"A"; -val:=16*val+next_control-"0"; next_control:=get_next; -until (next_control>"F")or(next_control<"0")or@| - ((next_control>"9")and(next_control<"A")) - -@* Scanning a macro definition. -The rules for generating the replacement texts corresponding to simple -macros, parametric macros, and \PASCAL\ texts of a module are almost -identical, so a single procedure is used for all three cases. The -differences are that - -\yskip\item{a)} The sign |#| denotes a parameter only when it appears -outside of strings in a parametric macro; otherwise it stands for the -ASCII character |#|. (This is not used in standard \PASCAL, but some -\PASCAL s allow, for example, `\.{/\#}' after a certain kind of file name.) - -\item{b)}Module names are not allowed in simple macros or parametric macros; -in fact, the appearance of a module name terminates such macros and denotes -the name of the current module. - -\item{c)}The symbols \.{@@d} and \.{@@f} and \.{@@p} are not allowed after -module names, while they terminate macro definitions. - -@ Therefore there is a procedure |scan_repl| whose parameter |t| specifies -either |simple| or |parametric| or |module_name|. After |scan_repl| has -acted, |cur_repl_text| will point to the replacement text just generated, and -|next_control| will contain the control code that terminated the activity. - -@= -@!cur_repl_text:text_pointer; {replacement text formed by |scan_repl|} - -@ @p procedure scan_repl(@!t:eight_bits); {creates a replacement text} -label continue, done, found, reswitch; -var a:sixteen_bits; {the current token} -@!b:ASCII_code; {a character from the buffer} -@!bal:eight_bits; {left parentheses minus right parentheses} -begin bal:=0; -loop@+ begin continue: a:=get_next; - case a of - "(": incr(bal); - ")": if bal=0 then err_print('! Extra )') -@.Extra )@> - else decr(bal); - "'": @; - "#": if t=parametric then a:=param; - @t\4@>@@; - othercases do_nothing - endcases;@/ - app_repl(a); {store |a| in |tok_mem|} - end; -done: next_control:=a; -@; -if text_ptr>max_texts-zz then overflow('text'); -cur_repl_text:=text_ptr; tok_start[text_ptr+zz]:=tok_ptr[z]; -incr(text_ptr); -if z=zz-1 then z:=0@+else incr(z); -end; - -@ @= -if bal>0 then - begin if bal=1 then err_print('! Missing )') - else err_print('! Missing ',bal:1,' )''s'); -@.Missing n )@> - while bal>0 do - begin app_repl(")"); decr(bal); - end; - end - -@ @= -identifier: begin a:=id_lookup(normal); app_repl((a div @'400)+@'200); - a:=a mod @'400; - end; -module_name: if t<>module_name then goto done - else begin app_repl((cur_module div @'400)+@'250); - a:=cur_module mod @'400; - end; -verbatim: @; -definition, format, begin_Pascal: if t<>module_name then goto done - else begin err_print('! @@',xchr[buffer[loc-1]], -@.\AT!p is ignored in Pascal text@> -@.\AT!d is ignored in Pascal text@> -@.\AT!f is ignored in Pascal text@> - ' is ignored in Pascal text'); goto continue; - end; -new_module: goto done; - -@ @= -begin b:="'"; -loop@+ begin app_repl(b); - if b="@@" then - if buffer[loc]="@@" then incr(loc) {store only one \.{@@}} - else err_print('! You should double @@ signs in strings'); -@.You should double \AT! signs@> - if loc=limit then - begin err_print('! String didn''t end'); -@.String didn't end@> - buffer[loc]:="'"; buffer[loc+1]:=0; - end; - b:=buffer[loc]; incr(loc); - if b="'" then - begin if buffer[loc]<>"'" then goto found - else begin incr(loc); app_repl("'"); - end; - end; - end; -found: end {now |a| holds the final |"'"| that will be stored} - -@ @= -begin app_repl(verbatim); -buffer[limit+1]:="@@"; -reswitch: if buffer[loc]="@@" then - begin if loc=limit then err_print('! Verbatim string didn''t end') -@.Verbatim string didn't end@> -else if buffer[loc+1]<>">" then - err_print('! You should double @@ signs in verbatim strings'); -@.You should double \AT! signs@> -loc:=loc+2; -end {another |verbatim| byte will be stored, since |a=verbatim|} - -@ The following procedure is used to define a simple or parametric macro, -just after the `\.{==}' of its definition has been scanned. - -@p procedure define_macro(@!t:eight_bits); -var p:name_pointer; {the identifier being defined} -begin p:=id_lookup(t); scan_repl(t);@/ -equiv[p]:=cur_repl_text; text_link[cur_repl_text]:=0; -end; - -@* Scanning a module. -The |scan_module| procedure starts when `\.{@@\ }' or `\.{@@*}' has been -sensed in the input, and it proceeds until the end of that module. It -uses |module_count| to keep track of the current module number; with luck, -\.{WEAVE} and \.{TANGLE} will both assign the same numbers to modules. - -@= -@!module_count:0..@'27777; {the current module number} - -@ The top level of |scan_module| is trivial. -@p procedure scan_module; -label continue, done, exit; -var p:name_pointer; {module name for the current module} -begin incr(module_count); -@; -@; -exit: end; - -@ @= -next_control:=0; -loop@+ begin continue: while next_control<=format do - begin next_control:=skip_ahead; - if next_control=module_name then - begin {we want to scan the module name too} - loc:=loc-2; next_control:=get_next; - end; - end; - if next_control<>definition then goto done; - next_control:=get_next; {get identifier name} - if next_control<>identifier then - begin err_print('! Definition flushed, must start with ', -@.Definition flushed...@> - 'identifier of length > 1'); goto continue; - end; - next_control:=get_next; {get token after the identifier} - if next_control="=" then - begin scan_numeric(id_lookup(numeric)); goto continue; - end - else if next_control=equivalence_sign then - begin define_macro(simple); goto continue; - end - else @; - err_print('! Definition flushed since it starts badly'); -@.Definition flushed...@> - end; -done: - -@ @= -if next_control="(" then - begin next_control:=get_next; - if next_control="#" then - begin next_control:=get_next; - if next_control=")" then - begin next_control:=get_next; - if next_control="=" then - begin err_print('! Use == for macros'); -@.Use == for macros@> - next_control:=equivalence_sign; - end; - if next_control=equivalence_sign then - begin define_macro(parametric); goto continue; - end; - end; - end; - end; - -@ @= -case next_control of -begin_Pascal:p:=0; -module_name: begin p:=cur_module; - @; - end; -othercases return -endcases;@/ -@; -scan_repl(module_name); {now |cur_repl_text| points to the replacement text} -@; - -@ @= -repeat next_control:=get_next; -until next_control<>"+"; {allow optional `\.{+=}'} -if (next_control<>"=")and(next_control<>equivalence_sign) then - begin err_print('! Pascal text flushed, = sign is missing'); -@.Pascal text flushed...@> - repeat next_control:=skip_ahead; - until next_control=new_module; - return; - end - -@ @= -store_two_bytes(@'150000+module_count); {|@'150000=@'320*@'400|} - -@ @= -if p=0 then {unnamed module} - begin text_link[last_unnamed]:=cur_repl_text; last_unnamed:=cur_repl_text; - end -else if equiv[p]=0 then equiv[p]:=cur_repl_text {first module of this name} -else begin p:=equiv[p]; - while text_link[p]1|, the program stops -only every |debug_cycle| times |debug_help| is called; however, -any error stop will set |debug_cycle| to zero. - -@= -@!debug@!trouble_shooting:boolean; {is |debug_help| wanted?} -@!ddt:integer; {operation code for the |debug_help| routine} -@!dd:integer; {operand in procedures performed by |debug_help|} -@!debug_cycle:integer; {threshold for |debug_help| stopping} -@!debug_skipped:integer; {we have skipped this many |debug_help| calls} -@!term_in:text_file; {the user's terminal as an input file} -gubed - -@ The debugging routine needs to read from the user's terminal. -@^system dependencies@> -@= -@!debug trouble_shooting:=true; debug_cycle:=1; debug_skipped:=0;@/ -trouble_shooting:=false; debug_cycle:=99999; {use these when it almost works} -reset(term_in,'TTY:','/I'); {open |term_in| as the terminal, don't do a |get|} -gubed - -@ @d breakpoint=888 {place where a breakpoint is desirable} -@^system dependencies@> - -@p @!debug procedure debug_help; {routine to display various things} -label breakpoint,exit; -var k:integer; {index into various arrays} -begin incr(debug_skipped); -if debug_skipped - -@p begin initialize; -@; -print_ln(banner); {print a ``banner line''} -@; -stat for ii:=0 to zz-1 do max_tok_ptr[ii]:=tok_ptr[ii];@+tats@;@/ -@; -end_of_TANGLE: -if string_ptr>number_chars then @; -stat @;@+tats@;@/ -@t\4\4@>{here files should be closed if the operating system requires it} -@; -end. - -@ @= -phase_one:=true; -module_count:=0; -repeat next_control:=skip_ahead; -until next_control=new_module; -while not input_has_ended do scan_module; -@; -phase_one:=false; - -@ @= -begin print_nl(string_ptr-number_chars:1, - ' strings written to string pool file.'); -write(pool,'*'); -for ii:=1 to 9 do - begin out_buf[ii]:=pool_check_sum mod 10; - pool_check_sum:=pool_check_sum div 10; - end; -for ii:=9 downto 1 do write(pool,xchr["0"+out_buf[ii]]); -write_ln(pool); -end - -@ @= -stat @!wo:0..ww-1; {segment of memory for which statistics are being printed} -tats - -@ @= -print_nl('Memory usage statistics:'); -print_nl(name_ptr:1, ' names, ', text_ptr:1, ' replacement texts;'); -print_nl(byte_ptr[0]:1); -for wo:=1 to ww-1 do print('+',byte_ptr[wo]:1); -if phase_one then - for ii:=0 to zz-1 do max_tok_ptr[ii]:=tok_ptr[ii]; -print(' bytes, ', max_tok_ptr[0]:1); -for ii:=1 to zz-1 do print('+',max_tok_ptr[ii]:1); -print(' tokens.'); - -@ Some implementations may wish to pass the |history| value to the -operating system so that it can be used to govern whether or not other -programs are started. Here we simply report the history to the user. -@^system dependencies@> - -@= -case history of -spotless: print_nl('(No errors were found.)'); -harmless_message: print_nl('(Did you see the warning message above?)'); -error_message: print_nl('(Pardon me, but I think I spotted something wrong.)'); -fatal_message: print_nl('(That was a fatal error, my friend.)'); -end {there are no other cases} - -@* System-dependent changes. -This module should be replaced, if necessary, by changes to the program -that are necessary to make \.{TANGLE} work at a particular installation. -It is usually best to design your change file so that all changes to -previous modules preserve the module numbering; then everybody's version -will be consistent with the printed program. More extensive changes, -which introduce new modules, can be inserted here; then only the index -itself will get a new module number. -@^system dependencies@> - -@* Index. -Here is a cross-reference table for the \.{TANGLE} processor. -All modules in which an identifier is -used are listed with that identifier, except that reserved words are -indexed only when they appear in format definitions, and the appearances -of identifiers in module names are not indexed. Underlined entries -correspond to where the identifier was declared. Error messages and -a few other things like ``ASCII code'' are indexed here too. diff --git a/Build/source/texk/web2c/luatexdir/luatex-api.h b/Build/source/texk/web2c/luatexdir/luatex-api.h deleted file mode 100644 index 89bbf1230c1..00000000000 --- a/Build/source/texk/web2c/luatexdir/luatex-api.h +++ /dev/null @@ -1,143 +0,0 @@ -/* luatex-api.h - - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . */ - -/* $Id$ */ - -#include -#include -#include -#include <../lua51/lua.h> -#include <../lua51/lauxlib.h> -#include <../lua51/lualib.h> - - -typedef struct LoadS { - const char *s; - size_t size; -} LoadS; - -extern lua_State *Luas; - -extern void make_table(lua_State * L, const char *tab, const char *getfunc, const char *setfunc); - -extern int luac_main(int argc, char *argv[]); - -extern int luaopen_tex(lua_State * L); - -extern int luaopen_pdf(lua_State * L); - -#define LUA_TEXFILEHANDLE "TEXFILE*" - -extern int luaopen_texio(lua_State * L); - -extern int luaopen_lang(lua_State * L); - -extern void luatex_load_init(int s, LoadS * ls); - -extern lua_State *luatex_error(lua_State * L, int fatal); - -extern int luaopen_unicode(lua_State * L); -extern int luaopen_zip(lua_State * L); -extern int luaopen_lfs(lua_State * L); -extern int luaopen_lpeg(lua_State * L); -extern int luaopen_md5(lua_State * L); -extern int luaopen_zlib(lua_State * L); -extern int luaopen_gzip(lua_State * L); -extern int luaopen_ff(lua_State * L); -extern int luaopen_profiler(lua_State * L); - -extern int luaopen_socket_core(lua_State * L); -extern int luaopen_mime_core(lua_State * L); -extern void luatex_socketlua_open(lua_State * L); - -extern int luaopen_img(lua_State * L); -extern int l_new_image(lua_State * L); -extern int luaopen_mplib(lua_State * L); - -extern void open_oslibext(lua_State * L, int safer_option); - -extern void initfilecallbackids(int max); -extern void setinputfilecallbackid(int n, int i); -extern void setreadfilecallbackid(int n, int i); -extern int getinputfilecallbackid(int n); -extern int getreadfilecallbackid(int n); - -extern void lua_initialize(int ac, char **av); - -extern int luaopen_kpse(lua_State * L); - -extern int luaopen_callback(lua_State * L); - -extern int luaopen_lua(lua_State * L, const char *fname); - -extern int luaopen_stats(lua_State * L); - -extern int luaopen_font(lua_State * L); -extern int font_to_lua(lua_State * L, int f); -extern int font_from_lua(lua_State * L, int f); /* return is boolean */ - -extern int luaopen_token(lua_State * L); -extern char *tokenlist_to_cstring(int p, int inhibit_par, int *siz); -extern void tokenlist_to_lua(lua_State * L, int p); -extern void tokenlist_to_luastring(lua_State * L, int p); -extern int tokenlist_from_lua(lua_State * L); - -extern void lua_nodelib_push(lua_State * L); -extern int luaopen_node(lua_State * L); -extern void nodelist_to_lua(lua_State * L, int n); -extern int nodelist_from_lua(lua_State * L); - -extern int dimen_to_number(lua_State * L, const char *s); - -extern void dump_luac_registers(void); - -extern void undump_luac_registers(void); - - -extern void unhide_lua_table(lua_State * lua, const char *name, int r); -extern int hide_lua_table(lua_State * lua, const char *name); - -extern void unhide_lua_value(lua_State * lua, const char *name, const char *item, int r); -extern int hide_lua_value(lua_State * lua, const char *name, const char *item); - -typedef struct command_item_ { - const char *cmd_name; - int command_offset; - char **commands; -} command_item; - -extern command_item command_names[]; -extern int callback_callbacks_id; - -extern void luainterpreter(void); - -extern int program_name_set; - -extern const char *startup_filename; -extern int safer_option; -extern int nosocket_option; - -extern int luabytecode_max; -extern unsigned int luabytecode_bytes; -extern int luastate_bytes; -extern int callback_count; -extern int saved_callback_count; - -#define utf8_idpb lua_utf8_idpb /* avoid name conflict with fontforge library */ -extern char *utf8_idpb(char *utf8_text, unsigned int ch); diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c new file mode 100644 index 00000000000..1183b7d9de4 --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -0,0 +1,1063 @@ +/* texmf.c: Hand-coded routines for TeX or Metafont in C. Originally + written by Tim Morgan, drawing from other Unix ports of TeX. This is + a collection of miscellany, everything that's easier (or only + possible) to do in C. + + This file is public domain. */ + +/* This file is used to create texextra.c etc., with this line + changed to include texd.h or mfd.h. The ?d.h file is what + #defines TeX or MF, which avoids the need for a special + Makefile rule. */ +#include "luatex.h" + +#include "luatex_svnversion.h" + +static const char _svn_version[] = + "$Id: luatex.c 3588 2010-04-04 06:41:44Z taco $ " + "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/luatex.c $"; + +#define TeX + +int luatex_svn = luatex_svn_revision; +int luatex_version = 60; /* \.{\\luatexversion} */ +int luatex_revision = '0'; /* \.{\\luatexrevision} */ +int luatex_date_info = -extra_version_info; /* the compile date is negated */ +const char *luatex_version_string = "beta-0.60.0"; +const char *engine_name = "luatex"; /* the name of this engine */ + + + +#include +#include +#include +#include +#include +#include + +#include /* For `struct tm'. */ +#if defined (HAVE_SYS_TIME_H) +# include +#elif defined (HAVE_SYS_TIMEB_H) +# include +#endif + +#if defined(__STDC__) +# include +#endif + +#include /* Catch interrupts. */ + +#include + +/* {tex,mf}d.h defines TeX, MF, INI, and other such symbols. + Unfortunately there's no way to get the banner into this code, so + just repeat the text. */ +#define edit_var "TEXEDIT" + +/* Shell escape. + + If shellenabledp == 0, all shell escapes are forbidden. + If (shellenabledp == 1 && restrictedshell == 0), any command + is allowed for a shell escape. + If (shellenabledp == 1 && restrictedshell == 1), only commands + given in the configuration file as + shell_escape_commands = kpsewhich,ebb,extractbb,mpost,metafun,... + (no spaces between commands) in texmf.cnf are allowed for a shell + escape in a restricted form: command name and arguments should be + separated by a white space. The first word should be a command + name. The quotation character for an argument with spaces, + including a pathname, should be ". ' should not be used. + + Internally, all arguments are quoted by ' (Unix) or " (Windows) + before calling the system() function in order to forbid execution + of any embedded command. In addition, on Windows, special + characters of cmd.exe are escaped by using (^). + + If the --shell-escape option is given, we set + shellenabledp = 1 and restrictedshell = 0, i.e., any command is allowed. + If the --shell-restricted option is given, we set + shellenabledp = 1 and restrictedshell = 1, i.e., only given cmds allowed. + If the --no-shell-escape option is given, we set + shellenabledp = -1 (and restrictedshell is irrelevant). + If none of these option are given, there are three cases: + (1) In the case where + shell_escape = y or + shell_escape = t or + shell_escape = 1 + it becomes shellenabledp = 1 and restrictedshell = 0, + that is, any command is allowed. + (2) In the case where + shell_escape = p + it becomes shellenabledp = 1 and restrictedshell = 1, + that is, restricted shell escape is allowed. + (3) In all other cases, shellenabledp = 0, that is, shell + escape is forbidden. The value of restrictedshell is + irrelevant if shellenabledp == 0. +*/ + +#ifdef TeX + +/* cmdlist is a list of allowed commands which are given like this: + shell_escape_commands = kpsewhich,ebb,extractbb,mpost,metafun + in texmf.cnf. */ + +static char **cmdlist = NULL; + +void mk_shellcmdlist(char *v) +{ + char **p; + char *q, *r; + unsigned int n; + + q = v; + n = 0; + +/* analyze the variable shell_escape_commands = foo,bar,... + spaces before and after (,) are not allowed. */ + + while ((r = strchr(q, ',')) != 0) { + n++; + r++; + q = r; + } + if (*q) + n++; + cmdlist = (char **) xmalloc((unsigned) ((n + 1) * sizeof(char *))); + p = cmdlist; + q = v; + while ((r = strchr(q, ',')) != 0) { + *r = '\0'; + *p = (char *) xmalloc((unsigned) strlen(q) + 1); + strcpy(*p, q); + *r = ','; + r++; + q = r; + p++; + } + if (*q) { + *p = (char *) xmalloc((unsigned) strlen(q) + 1); + strcpy(*p, q); + p++; + *p = NULL; + } else + *p = NULL; +} + +/* Called from maininit. Not static because also called from + luatexdir/lua/luainit.c. */ + +void init_shell_escape(void) +{ + if (shellenabledp < 0) { /* --no-shell-escape on cmd line */ + shellenabledp = 0; + + } else { + if (shellenabledp == 0) { /* no shell options on cmd line, check cnf */ + char *v1 = kpse_var_value("shell_escape"); + if (v1) { + if (*v1 == 't' || *v1 == 'y' || *v1 == '1') { + shellenabledp = 1; + } else if (*v1 == 'p') { + shellenabledp = 1; + restrictedshell = 1; + } + free(v1); + } + } + + /* If shell escapes are restricted, get allowed cmds from cnf. */ + if (shellenabledp && restrictedshell == 1) { + char *v2 = kpse_var_value("shell_escape_commands"); + if (v2) { + mk_shellcmdlist(v2); + free(v2); + } + } + } +} + +# ifdef WIN32 +# define QUOTE '"' +# else +# define QUOTE '\'' +# endif + +# ifdef WIN32 +static int char_needs_quote(int c) +{ +/* special characters of cmd.exe */ + + return (c == '&' || c == '|' || c == '%' || c == '<' || + c == '>' || c == ';' || c == ',' || c == '(' || c == ')'); +} +# endif + +static int Isspace(char c) +{ + return (c == ' ' || c == '\t'); +} + +/* return values: + -1 : invalid quotation of an argument + 0 : command is not allowed + 2 : restricted shell escape, CMD is allowed. + + We set *SAFECMD to a safely-quoted version of *CMD; this is what + should get executed. And we set CMDNAME to its first word; this is + what is checked against the shell_escape_commands list. */ + +int shell_cmd_is_allowed(const char **cmd, char **safecmd, char **cmdname) +{ + char **p; + char *buf; + char *s, *d; + const char *ss; + int pre; + unsigned spaces; + int allow = 0; + + /* pre == 1 means that the previous character is a white space + pre == 0 means that the previous character is not a white space */ + buf = (char *) xmalloc((unsigned) strlen(*cmd) + 1); + strcpy(buf, *cmd); + s = buf; + while (Isspace(*s)) + s++; + d = s; + while (!Isspace(*d) && *d) + d++; + *d = '\0'; + + /* *cmdname is the first word of the command line. For example, + *cmdname == "kpsewhich" for + \write18{kpsewhich --progname=dvipdfm --format="other text files" config} + */ + *cmdname = xstrdup(s); + free(buf); + + /* Is *cmdname listed in a texmf.cnf vriable as + shell_escape_commands = foo,bar,... ? */ + p = cmdlist; + if (p) { + while (*p) { + if (strcmp(*p, *cmdname) == 0) { + /* *cmdname is found in the list, so restricted shell escape + is allowed */ + allow = 2; + break; + } + p++; + } + } + if (allow == 2) { + spaces = 0; + for (ss = *cmd; *ss; ss++) { + if (Isspace(*ss)) + spaces++; + } + + /* allocate enough memory (too much?) */ +# ifdef WIN32 + *safecmd = + (char *) xmalloc(2 * (unsigned) strlen(*cmd) + 3 + 2 * spaces); +# else + *safecmd = (char *) xmalloc((unsigned) strlen(*cmd) + 3 + 2 * spaces); +# endif + + /* make a safe command line *safecmd */ + ss = *cmd; + while (Isspace(*ss)) + ss++; + d = *safecmd; + while (!Isspace(*ss) && *ss) + *d++ = *ss++; + + pre = 1; + while (*ss) { + /* Quotation given by a user. " should always be used; we + transform it below. On Unix, if ' is used, simply immediately + return a quotation error. */ + if (*ss == '\'') { + return -1; + } + + if (*ss == '"') { + /* All arguments are quoted as 'foo' (Unix) or "foo" (Windows) + before calling system(). Therefore closing QUOTE is necessary + if the previous character is not a white space. + example: + --format="other text files" becomes + '--format=''other text files' (Unix) + "--format=""other test files" (Windows) */ + + if (pre == 0) + *d++ = QUOTE; + + pre = 0; + /* output the quotation mark for the quoted argument */ + *d++ = QUOTE; + ss++; + + while (*ss != '"') { + /* Illegal use of ', or closing quotation mark is missing */ + if (*ss == '\'' || *ss == '\0') + return -1; +# ifdef WIN32 + if (char_needs_quote(*ss)) + *d++ = '^'; +# endif + *d++ = *ss++; + } + + /* Closing quotation mark will be output afterwards, so + we do nothing here */ + ss++; + + /* The character after the closing quotation mark + should be a white space or NULL */ + if (!Isspace(*ss) && *ss) + return -1; + + /* Beginning of a usual argument */ + } else if (pre == 1 && !Isspace(*ss)) { + pre = 0; + *d++ = QUOTE; +# ifdef WIN32 + if (char_needs_quote(*ss)) + *d++ = '^'; +# endif + *d++ = *ss++; + /* Ending of a usual argument */ + + } else if (pre == 0 && Isspace(*ss)) { + pre = 1; + /* Closing quotation mark */ + *d++ = QUOTE; + *d++ = *ss++; + } else { + /* Copy a character from *cmd to *safecmd. */ +# ifdef WIN32 + if (char_needs_quote(*ss)) + *d++ = '^'; +# endif + *d++ = *ss++; + } + } + /* End of the command line */ + if (pre == 0) { + *d++ = QUOTE; + } + *d = '\0'; + } + + return allow; +} + +/* We should only be called with shellenabledp == 1. + Return value: + -1 if a quotation syntax error. + 0 if CMD is not allowed; given shellenabledp==1, this is because + shell escapes are restricted and CMD is not allowed. + 1 if shell escapes are not restricted, hence any command is allowed. + 2 if shell escapes are restricted and CMD is allowed. */ + +int runsystem(char *cmd) +{ + int allow = 0; + char *safecmd = NULL; + char *cmdname = NULL; + + if (shellenabledp <= 0) { + return 0; + } + + /* If restrictedshell == 0, any command is allowed. */ + if (restrictedshell == 0) { + allow = 1; + } else { + const char *thecmd = cmd; + allow = shell_cmd_is_allowed(&thecmd, &safecmd, &cmdname); + } + + if (allow == 1) + (void) system(cmd); + else if (allow == 2) + (void) system(safecmd); + + if (safecmd) + free(safecmd); + if (cmdname) + free(cmdname); + + return allow; +} + +#endif + +/* The main program, etc. */ + +extern void lua_initialize(int ac, char **av); + +/* What we were invoked as and with. */ +char **argv; +int argc; + +/* The C version of what might wind up in |TEX_format_default|. */ +string dump_name; + +/* The C version of the jobname, if given. */ +const_string c_job_name; + +/* Full source file name. */ +extern string fullnameoffile; + +/* The main body of the WEB is transformed into this procedure. */ +extern TEXDLL void mainbody(void); + +char *ptexbanner; + +#if !defined(WIN32) || defined(__MINGW32__) +/* The entry point: set up for reading the command line, which will + happen in `topenin', then call the main body. */ + +int main(int ac, string * av) +{ +# ifdef __EMX__ + _wildcard(&ac, &av); + _response(&ac, &av); +# endif + +# ifdef WIN32 + _setmaxstdio(2048); +# endif + + lua_initialize(ac, av); + + /* Call the real main program. */ + mainbody(); + + return EXIT_SUCCESS; +} +#endif /* !(WIN32 || __MINGW32__) */ + + +/* This is supposed to ``open the terminal for input'', but what we + really do is copy command line arguments into TeX's or Metafont's + buffer, so they can handle them. If nothing is available, or we've + been called already (and hence, argc==0), we return with + `last=first'. */ + +void topenin(void) +{ + int i; + + + buffer[first] = 0; /* In case there are no arguments. */ + + if (optind < argc) { /* We have command line arguments. */ + int k = first; + for (i = optind; i < argc; i++) { + char *ptr = &(argv[i][0]); + /* Don't use strcat, since in Aleph the buffer elements aren't + single bytes. */ + while (*ptr) { + buffer[k++] = (packed_ASCII_code) * (ptr++); + } + buffer[k++] = ' '; + } + argc = 0; /* Don't do this again. */ + buffer[k] = 0; + } + + /* Find the end of the buffer. */ + for (last = first; buffer[last]; ++last); + + /* Make `last' be one past the last non-blank character in `buffer'. */ + /* ??? The test for '\r' should not be necessary. */ + for (--last; last >= first + && ISBLANK(buffer[last]) && buffer[last] != '\r'; --last); + last++; + + /* One more time, this time converting to TeX's internal character + representation. */ +} + +/* IPC for TeX. By Tom Rokicki for the NeXT; it makes TeX ship out the + DVI file in a pipe to TeXView so that the output can be displayed + incrementally. Shamim Mohamed adapted it for Web2c. */ +#if defined (TeX) && defined (IPC) + +# include +# include +# ifndef O_NONBLOCK /* POSIX */ +# ifdef O_NDELAY /* BSD */ +# define O_NONBLOCK O_NDELAY +# else +# ifdef FNDELAY /* NeXT */ +# define O_NONBLOCK O_FNDELAY +# else +what the fcntl ? cannot implement IPC without equivalent for O_NONBLOCK. +# endif /* no FNDELAY */ +# endif /* no O_NDELAY */ +# endif /* no O_NONBLOCK */ +# ifndef IPC_PIPE_NAME /* $HOME is prepended to this. */ +# define IPC_PIPE_NAME "/.TeXview_Pipe" +# endif +# ifndef IPC_SERVER_CMD /* Command to run to start the server. */ +# define IPC_SERVER_CMD "open `which TeXview`" +# endif + struct msg { + short namelength; /* length of auxiliary data */ + int eof; /* new eof for dvi file */ +# if 0 /* see usage of struct msg below */ + char more_data[0]; /* where the rest of the stuff goes */ +# endif +}; + +static char *ipc_name; +static struct sockaddr *ipc_addr; +static int ipc_addr_len; + +static int ipc_make_name(void) +{ + if (ipc_addr_len == 0) { + string s = getenv("HOME"); + if (s) { + ipc_addr = (struct sockaddr *) xmalloc(strlen(s) + 40); + ipc_addr->sa_family = 0; + ipc_name = ipc_addr->sa_data; + strcpy(ipc_name, s); + strcat(ipc_name, IPC_PIPE_NAME); + ipc_addr_len = strlen(ipc_name) + 3; + } + } + return ipc_addr_len; +} + + +static int sock = -1; + +static int ipc_is_open(void) +{ + return sock >= 0; +} + + +static void ipc_open_out(void) +{ +# ifdef IPC_DEBUG + fputs("tex: Opening socket for IPC output ...\n", stderr); +# endif + if (sock >= 0) { + return; + } + + if (ipc_make_name() < 0) { + sock = -1; + return; + } + + sock = socket(PF_UNIX, SOCK_STREAM, 0); + if (sock >= 0) { + if (connect(sock, ipc_addr, ipc_addr_len) != 0 + || fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { + close(sock); + sock = -1; + return; + } +# ifdef IPC_DEBUG + fputs("tex: Successfully opened IPC socket.\n", stderr); +# endif + } +} + + +static void ipc_close_out(void) +{ +# ifdef IPC_DEBUG + fputs("tex: Closing output socket ...\n", stderr); +# endif + if (ipc_is_open()) { + close(sock); + sock = -1; + } +} + + +static void ipc_snd(int n, int is_eof, char *data) +{ + struct { + struct msg msg; + char more_data[1024]; + } ourmsg; + +# ifdef IPC_DEBUG + fputs("tex: Sending message to socket ...\n", stderr); +# endif + if (!ipc_is_open()) { + return; + } + + ourmsg.msg.namelength = n; + ourmsg.msg.eof = is_eof; + if (n) { + strcpy(ourmsg.more_data, data); + } + n += sizeof(struct msg); +# ifdef IPC_DEBUG + fputs("tex: Writing to socket...\n", stderr); +# endif + if (write(sock, &ourmsg, n) != n) { + ipc_close_out(); + } +# ifdef IPC_DEBUG + fputs("tex: IPC message sent.\n", stderr); +# endif +} + + +/* This routine notifies the server if there is an eof, or the filename + if a new DVI file is starting. This is the routine called by TeX. + Aleph defines str_start(#) as str_start_ar[# - too_big_char], with + too_big_char = biggest_char + 1 = 65536 (omstr.ch).*/ + +void ipcpage(int is_eof) +{ + static boolean begun = false; + unsigned len = 0; + string p = (string) ""; + + if (!begun) { + const_string name; /* Just the filename. */ + string cwd = xgetcwd(); + + ipc_open_out(); + + /* Have to pass whole filename to the other end, since it may have + been started up and running as a daemon, e.g., as with the NeXT + preview program. */ + name = (const_string) static_pdf->file_name; + p = concat3(cwd, DIR_SEP_STRING, name); + /* free(name); */ + len = strlen(p); + begun = true; + } + ipc_snd(len, is_eof, p); + + if (len > 0) { + free(p); + } +} +#endif /* TeX && IPC */ + +/* Normalize quoting of filename -- that is, only quote if there is a space, + and always use the quote-name-quote style. */ +string normalize_quotes(const_string name, const_string mesg) +{ + boolean quoted = false; + boolean must_quote = (strchr(name, ' ') != NULL); + /* Leave room for quotes and NUL. */ + string ret = (string) xmalloc((unsigned) strlen(name) + 3); + string p; + const_string q; + p = ret; + if (must_quote) + *p++ = '"'; + for (q = name; *q; q++) { + if (*q == '"') + quoted = !quoted; + else + *p++ = *q; + } + if (must_quote) + *p++ = '"'; + *p = '\0'; + if (quoted) { + fprintf(stderr, "! Unbalanced quotes in %s %s\n", mesg, name); + uexit(1); + } + return ret; +} + + +/* All our interrupt handler has to do is set TeX's or Metafont's global + variable `interrupt'; then they will do everything needed. */ +#ifdef WIN32 +/* Win32 doesn't set SIGINT ... */ +BOOL WINAPI catch_interrupt(DWORD arg) +{ + switch (arg) { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: + interrupt = 1; + return TRUE; + default: + /* No need to set interrupt as we are exiting anyway */ + return FALSE; + } +} +#else /* not WIN32 */ +static RETSIGTYPE catch_interrupt(int arg) +{ + (void) arg; + interrupt = 1; +# ifdef OS2 + (void) signal(SIGINT, SIG_ACK); +# else + (void) signal(SIGINT, catch_interrupt); +# endif /* not OS2 */ +} +#endif /* not WIN32 */ + +/* Besides getting the date and time here, we also set up the interrupt + handler, for no particularly good reason. It's just that since the + `fix_date_and_time' routine is called early on (section 1337 in TeX, + ``Get the first line of input and prepare to start''), this is as + good a place as any. */ + +void get_date_and_time(int *minutes, int *day, int *month, int *year) +{ + time_t myclock = time((time_t *) 0); + struct tm *tmptr = localtime(&myclock); + + *minutes = tmptr->tm_hour * 60 + tmptr->tm_min; + *day = tmptr->tm_mday; + *month = tmptr->tm_mon + 1; + *year = tmptr->tm_year + 1900; + + { +#ifdef SA_INTERRUPT + /* Under SunOS 4.1.x, the default action after return from the + signal handler is to restart the I/O if nothing has been + transferred. The effect on TeX is that interrupts are ignored if + we are waiting for input. The following tells the system to + return EINTR from read() in this case. From ken@cs.toronto.edu. */ + + struct sigaction a, oa; + + a.sa_handler = catch_interrupt; + sigemptyset(&a.sa_mask); + sigaddset(&a.sa_mask, SIGINT); + a.sa_flags = SA_INTERRUPT; + sigaction(SIGINT, &a, &oa); + if (oa.sa_handler != SIG_DFL) + sigaction(SIGINT, &oa, (struct sigaction *) 0); +#else /* no SA_INTERRUPT */ +# ifdef WIN32 + SetConsoleCtrlHandler(catch_interrupt, TRUE); +# else /* not WIN32 */ + RETSIGTYPE(*old_handler) (int); + + old_handler = signal(SIGINT, catch_interrupt); + if (old_handler != SIG_DFL) + signal(SIGINT, old_handler); +# endif /* not WIN32 */ +#endif /* no SA_INTERRUPT */ + } +} + +/* + Getting a high resolution time. + */ +void get_seconds_and_micros(int *seconds, int *micros) +{ +#if defined (HAVE_GETTIMEOFDAY) + struct timeval tv; + gettimeofday(&tv, NULL); + *seconds = (int)tv.tv_sec; + *micros = (int)tv.tv_usec; +#elif defined (HAVE_FTIME) + struct timeb tb; + ftime(&tb); + *seconds = tb.time; + *micros = tb.millitm * 1000; +#else + time_t myclock = time((time_t *) NULL); + *seconds = (int) myclock; + *micros = 0; +#endif +} + +/* + Generating a better seed numbers + */ +int getrandomseed() +{ +#if defined (HAVE_GETTIMEOFDAY) + struct timeval tv; + gettimeofday(&tv, NULL); + return (int)(tv.tv_usec + 1000000 * tv.tv_usec); +#elif defined (HAVE_FTIME) + struct timeb tb; + ftime(&tb); + return (tb.millitm + 1000 * tb.time); +#else + time_t myclock = time((time_t *) NULL); + struct tm *tmptr = localtime(&myclock); + return (tmptr->tm_sec + 60 * (tmptr->tm_min + 60 * tmptr->tm_hour)); +#endif +} + +/* Read a line of input as efficiently as possible while still looking + like Pascal. We set `last' to `first' and return `false' if we get + to eof. Otherwise, we return `true' and set last = first + + length(line except trailing whitespace). */ + +boolean input_line(FILE * f) +{ + int i = EOF; + + /* Recognize either LF or CR as a line terminator. */ + last = first; + while (last < buf_size && (i = getc(f)) != EOF && i != '\n' && i != '\r') + buffer[last++] = (packed_ASCII_code) i; + + if (i == EOF && errno != EINTR && last == first) + return false; + + /* We didn't get the whole line because our buffer was too small. */ + if (i != EOF && i != '\n' && i != '\r') { + fprintf(stderr, "! Unable to read an entire line---bufsize=%u.\n", + (unsigned) buf_size); + fputs("Please increase buf_size in texmf.cnf.\n", stderr); + uexit(1); + } + + buffer[last] = ' '; + if (last >= max_buf_stack) + max_buf_stack = last; + + /* If next char is LF of a CRLF, read it. */ + if (i == '\r') { + while ((i = getc(f)) == EOF && errno == EINTR); + if (i != '\n') + ungetc(i, f); + } + + /* Trim trailing whitespace. */ + while (last > first && ISBLANK(buffer[last - 1])) + --last; + + /* Don't bother using xord if we don't need to. */ + + return true; +} + + +/* This string specifies what the `e' option does in response to an + error message. */ +static const_string edit_value = EDITOR; + +/* This procedure originally due to sjc@s1-c. TeX & Metafont call it when + the user types `e' in response to an error, invoking a text editor on + the erroneous source file. FNSTART is how far into FILENAME the + actual filename starts; FNLENGTH is how long the filename is. */ + +void +calledit(packedASCIIcode * filename, + poolpointer fnstart, int fnlength, int linenumber) +{ + char *temp, *command; + char c; + int sdone, ddone, i; + + sdone = ddone = 0; + filename += fnstart; + + /* Close any open input files, since we're going to kill the job. */ + for (i = 1; i <= in_open; i++) + xfclose(input_file[i], "inputfile"); + + /* Replace the default with the value of the appropriate environment + variable or config file value, if it's set. */ + temp = kpse_var_value(edit_var); + if (temp != NULL) + edit_value = temp; + + /* Construct the command string. The `11' is the maximum length an + integer might be. */ + command = + (string) xmalloc((unsigned) strlen(edit_value) + (unsigned) fnlength + + 11); + + /* So we can construct it as we go. */ + temp = command; + + while ((c = *edit_value++) != 0) { + if (c == '%') { + switch (c = *edit_value++) { + case 'd': + if (ddone) + FATAL("call_edit: `%%d' appears twice in editor command"); + sprintf(temp, "%ld", (long int) linenumber); + while (*temp != '\0') + temp++; + ddone = 1; + break; + + case 's': + if (sdone) + FATAL("call_edit: `%%s' appears twice in editor command"); + for (i = 0; i < fnlength; i++) + *temp++ = (char) Xchr(filename[i]); + sdone = 1; + break; + + case '\0': + *temp++ = '%'; + /* Back up to the null to force termination. */ + edit_value--; + break; + + default: + *temp++ = '%'; + *temp++ = c; + break; + } + } else + *temp++ = c; + } + + *temp = 0; + + /* Execute the command. */ +#ifdef WIN32 + /* Win32 reimplementation of the system() command + provides opportunity to call it asynchronously */ + if (win32_system(command, true) != 0) +#else + if (system(command) != 0) +#endif + fprintf(stderr, "! Trouble executing `%s'.\n", command); + + /* Quit, since we found an error. */ + uexit(1); +} + +/* Read and write dump files. As distributed, these files are + architecture dependent; specifically, BigEndian and LittleEndian + architectures produce different files. These routines always output + BigEndian files. This still does not guarantee them to be + architecture-independent, because it is possible to make a format + that dumps a glue ratio, i.e., a floating-point number. Fortunately, + none of the standard formats do that. */ + +#if !defined (WORDS_BIGENDIAN) && !defined (NO_DUMP_SHARE) /* this fn */ + +/* This macro is always invoked as a statement. It assumes a variable + `temp'. */ + +# define SWAP(x, y) temp = (x); (x) = (y); (y) = temp + + +/* Make the NITEMS items pointed at by P, each of size SIZE, be the + opposite-endianness of whatever they are now. */ + +static void swap_items(char *p, int nitems, int size) +{ + char temp; + + /* Since `size' does not change, we can write a while loop for each + case, and avoid testing `size' for each time. */ + switch (size) { + /* 16-byte items happen on the DEC Alpha machine when we are not + doing sharable memory dumps. */ + case 16: + while (nitems--) { + SWAP(p[0], p[15]); + SWAP(p[1], p[14]); + SWAP(p[2], p[13]); + SWAP(p[3], p[12]); + SWAP(p[4], p[11]); + SWAP(p[5], p[10]); + SWAP(p[6], p[9]); + SWAP(p[7], p[8]); + p += size; + } + break; + + case 8: + while (nitems--) { + SWAP(p[0], p[7]); + SWAP(p[1], p[6]); + SWAP(p[2], p[5]); + SWAP(p[3], p[4]); + p += size; + } + break; + + case 4: + while (nitems--) { + SWAP(p[0], p[3]); + SWAP(p[1], p[2]); + p += size; + } + break; + + case 2: + while (nitems--) { + SWAP(p[0], p[1]); + p += size; + } + break; + + case 1: + /* Nothing to do. */ + break; + + default: + FATAL1("Can't swap a %d-byte item for (un)dumping", size); + } +} +#endif /* not WORDS_BIGENDIAN and not NO_DUMP_SHARE */ + + +/* Here we write NITEMS items, each item being ITEM_SIZE bytes long. + The pointer to the stuff to write is P, and we write to the file + OUT_FILE. */ + +void do_dump(char *p, int item_size, int nitems, FILE * out_file) +{ +#if !defined (WORDS_BIGENDIAN) && !defined (NO_DUMP_SHARE) + swap_items(p, nitems, item_size); +#endif + + if (fwrite(p, (size_t) item_size, (size_t) nitems, out_file) != + (unsigned) nitems) { + fprintf(stderr, "! Could not write %d %d-byte item(s).\n", nitems, + item_size); + uexit(1); + } + + /* Have to restore the old contents of memory, since some of it might + get used again. */ +#if !defined (WORDS_BIGENDIAN) && !defined (NO_DUMP_SHARE) + swap_items(p, nitems, item_size); +#endif +} + + +/* Here is the dual of the writing routine. */ + +void do_undump(char *p, int item_size, int nitems, FILE * in_file) +{ + if (fread(p, (size_t) item_size, (size_t) nitems, in_file) != + (size_t) nitems) + FATAL2("Could not undump %d %d-byte item(s)", nitems, item_size); + +#if !defined (WORDS_BIGENDIAN) && !defined (NO_DUMP_SHARE) + swap_items(p, nitems, item_size); +#endif +} + + +/* Get the job name to be used, which may have been set from the + command line. */ +str_number getjobname(str_number name) +{ + str_number ret = name; + if (c_job_name != NULL) + ret = maketexstring(c_job_name); + return ret; +} diff --git a/Build/source/texk/web2c/luatexdir/luatex.ch b/Build/source/texk/web2c/luatexdir/luatex.ch deleted file mode 100644 index 7dd56dcb85f..00000000000 --- a/Build/source/texk/web2c/luatexdir/luatex.ch +++ /dev/null @@ -1,2176 +0,0 @@ -% luatex.ch -% -% Copyright 2006-2008 Taco Hoekwater -% -% This file is part of LuaTeX. -% -% LuaTeX is free software; you can redistribute it and/or modify it under -% the terms of the GNU General Public License as published by the Free -% Software Foundation; either version 2 of the License, or (at your -% option) any later version. -% -% LuaTeX is distributed in the hope that it will be useful, but WITHOUT -% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -% License for more details. -% -% You should have received a copy of the GNU General Public License along -% with LuaTeX; if not, see . -% -% $Id$ -% -@x - \def\?##1]{\hbox to 1in{\hfil##1.\ }} - } -@y - \def\?##1]{\hbox{Changes to \hbox to 1em{\hfil##1}.\ }} - } -\let\maybe=\iftrue -@z - -@x -Actually the heading shown here is not quite normal: The |program| line -does not mention any |output| file, because \ph\ would ask the \TeX\ user -to specify a file name if |output| were specified here. -@:PASCAL H}{\ph@> -@^system dependencies@> -@y -@z - -@x -program TEX; {all file names are defined dynamically} -label @@/ -@y -program TEX; {all file names are defined dynamically} -@z - -@x -@ Three labels must be declared in the main program, so we give them -symbolic names. - -@d start_of_TEX=1 {go here when \TeX's variables are initialized} -@d end_of_TEX=9998 {go here to close files and terminate gracefully} -@d final_end=9999 {this label marks the ending of the program} - -@= -start_of_TEX@t\hskip-2pt@>, end_of_TEX@t\hskip-2pt@>,@,final_end; - {key control points} -@y -@ For Web2c, labels are not declared in the main program, but -we still have to declare the symbolic names. - -@d start_of_TEX=1 {go here when \TeX's variables are initialized} -@d final_end=9999 {this label marks the ending of the program} -@z - -@x -@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} -@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} -@y -@d debug== ifdef('TEXMF_DEBUG') -@d gubed== endif('TEXMF_DEBUG') -@z - -@x -@d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering - usage statistics} -@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering - usage statistics} -@y -@d stat==ifdef('STAT') -@d tats==endif('STAT') -@z - -@x -the codewords `$|init|\ldots|tini|$'. - -@d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version} -@d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version} -@y -the codewords `$|init|\ldots|tini|$' for declarations and by the codewords -`$|Init|\ldots|Tini|$' for executable code. This distinction is helpful for -implementations where a run-time switch differentiates between the two -versions of the program. - -@d init==ifdef('INITEX') -@d tini==endif('INITEX') -@d Init==init if ini_version then begin -@d Tini==end;@+tini -@f Init==begin -@f Tini==end -@z - -@x -@!init @@;@+tini -@y -@!Init @@;@+Tini -@z - -@x -@= -@!buf_size=500; {maximum number of characters simultaneously present in - current lines of open files and in control sequences between - \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|} -@!error_line=72; {width of context lines on terminal error messages} -@!half_error_line=42; {width of first lines of contexts in terminal - error messages; should be between 30 and |error_line-15|} -@!max_print_line=79; {width of longest text lines output; should be at least 60} -@!stack_size=200; {maximum number of simultaneous input sources} -@!max_in_open=6; {maximum number of input files and error insertions that - can be going on simultaneously} -@!param_size=60; {maximum number of simultaneous macro parameters} -@!nest_size=40; {maximum number of semantic levels simultaneously active} -@!max_strings=3000; {maximum number of strings; must not exceed |max_halfword|} -@!string_vacancies=8000; {the minimum number of characters that should be - available for the user's control sequences and font names, - after \TeX's own error messages are stored} -@!pool_size=32000; {maximum number of characters in strings, including all - error messages and help texts, and the names of all fonts and - control sequences; must exceed |string_vacancies| by the total - length of \TeX's own strings, which is currently about 23000} -@!save_size=600; {space for saving values outside of current group; must be - at most |max_halfword|} -@!dvi_buf_size=800; {size of the output buffer; must be a multiple of 8} -@!expand_depth=10000; {limits recursive calls of the |expand| procedure} -@!file_name_size=40; {file names shouldn't be longer than this} -@!pool_name='TeXformats:TEX.POOL '; - {string of length |file_name_size|; tells where the string pool appears} -@y -@d file_name_size == max_halfword-1 { has to be big enough to force namelength into integer } -@d ssup_error_line = 255 -@d ssup_max_strings == 262143 -{Larger values than 65536 cause the arrays consume much more memory.} - -@= -@!hash_offset=0; {smallest index in hash array, i.e., |hash_base| } - {Use |hash_offset=0| for compilers which cannot decrement pointers.} -@!engine_name='luatex'; {the name of this engine} -@# - -@!inf_main_memory = 2000000; -@!sup_main_memory = 32000000; - -@!inf_max_strings = 100000; -@!sup_max_strings = ssup_max_strings; -@!inf_strings_free = 100; -@!sup_strings_free = sup_max_strings; - -@!inf_buf_size = 500; -@!sup_buf_size = 100000000; - -@!inf_nest_size = 40; -@!sup_nest_size = 4000; - -@!inf_max_in_open = 6; -@!sup_max_in_open = 127; - -@!inf_param_size = 60; -@!sup_param_size = 6000; - -@!inf_save_size = 600; -@!sup_save_size = 80000; - -@!inf_stack_size = 200; -@!sup_stack_size = 30000; - -@!inf_dvi_buf_size = 800; -@!sup_dvi_buf_size = 65536; - -@!inf_pool_size = 128000; -@!sup_pool_size = 40000000; -@!inf_pool_free = 1000; -@!sup_pool_free = sup_pool_size; -@!inf_string_vacancies = 8000; -@!sup_string_vacancies = sup_pool_size - 23000; - -@!sup_hash_extra = sup_max_strings; -@!inf_hash_extra = 0; - -@!sup_ocp_list_size = 1000000; -@!inf_ocp_list_size = 1000; -@!sup_ocp_buf_size = 100000000; -@!inf_ocp_buf_size = 1000; -@!sup_ocp_stack_size = 1000000; -@!inf_ocp_stack_size = 1000; - -@!inf_expand_depth = 100; -@!sup_expand_depth = 1000000; -@z - -@x -@d incr(#) == #:=#+1 {increase a variable by unity} -@d decr(#) == #:=#-1 {decrease a variable by unity} -@y -@z - -@x -@d text_char == char {the data type of characters in text files} -@y -@d text_char == ASCII_code {the data type of characters in text files} -@z - -@x -@!nameoffile:packed array[1..file_name_size] of char;@;@/ - {on some systems this may be a \&{record} variable} -@y -@!nameoffile:^packed_ASCII_code; -@z - -@x -@ The \ph\ compiler with which the present version of \TeX\ was prepared has -extended the rules of \PASCAL\ in a very convenient way. To open file~|f|, -we can write -$$\vbox{\halign{#\hfil\qquad&#\hfil\cr -|reset(f,@t\\{name}@>,'/O')|&for input;\cr -|rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$ -The `\\{name}' parameter, which is of type `{\bf packed array -$[\langle\\{any}\rangle]$ of \\{char}}', stands for the name of -the external file that is being opened for input or output. -Blank spaces that might appear in \\{name} are ignored. - -The `\.{/O}' parameter tells the operating system not to issue its own -error messages if something goes wrong. If a file of the specified name -cannot be found, or if such a file cannot be opened for some other reason -(e.g., someone may already be trying to write the same file), we will have -|@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|. This allows -\TeX\ to undertake appropriate corrective action. -@:PASCAL H}{\ph@> -@^system dependencies@> - -\TeX's file-opening procedures return |false| if no file identified by -|nameoffile| could be opened. - -@d reset_OK(#)==erstat(#)=0 -@d rewrite_OK(#)==erstat(#)=0 - -@p function a_open_in(var f:alpha_file):boolean; - {open a text file for input} -begin reset(f,nameoffile,'/O'); a_open_in:=reset_OK(f); -end; -@# -function a_open_out(var f:alpha_file):boolean; - {open a text file for output} -begin rewrite(f,nameoffile,'/O'); a_open_out:=rewrite_OK(f); -end; -@# -function b_open_in(var f:byte_file):boolean; - {open a binary file for input} -begin reset(f,nameoffile,'/O'); b_open_in:=reset_OK(f); -end; -@# -function b_open_out(var f:byte_file):boolean; - {open a binary file for output} -begin rewrite(f,nameoffile,'/O'); b_open_out:=rewrite_OK(f); -end; -@# -function w_open_in(var f:word_file):boolean; - {open a word file for input} -begin reset(f,nameoffile,'/O'); w_open_in:=reset_OK(f); -end; -@# -function w_open_out(var f:word_file):boolean; - {open a word file for output} -begin rewrite(f,nameoffile,'/O'); w_open_out:=rewrite_OK(f); -end; -@y -@ All of the file opening functions are defined in C. -@z - -@x -@ Files can be closed with the \ph\ routine `|close(f)|', which -@:PASCAL H}{\ph@> -@^system dependencies@> -should be used when all input or output with respect to |f| has been completed. -This makes |f| available to be opened again, if desired; and if |f| was used for -output, the |close| operation makes the corresponding external file appear -on the user's area, ready to be read. - -These procedures should not generate error messages if a file is -being closed before it has been successfully opened. - -@p procedure a_close(var f:alpha_file); {close a text file} -begin close(f); -end; -@# -procedure b_close(var f:byte_file); {close a binary file} -begin close(f); -end; -@# -procedure w_close(var f:word_file); {close a word file} -begin close(f); -end; -@y -@ And all the file closing routines as well. -@z - -@x -@!buffer:array[0..buf_size] of packed_ASCII_code; {lines of characters being read} -@y -@!buffer:^packed_ASCII_code; {lines of characters being read} -@z - -@x -@p function input_ln(var f:alpha_file;@!bypass_eoln:boolean):boolean; - {inputs the next line or returns |false|} -var last_nonblank:0..buf_size; {|last| with trailing blanks removed} -begin if bypass_eoln then if not eof(f) then get(f); - {input the first character of the line into |f^|} -last:=first; {cf.\ Matthew 19\thinspace:\thinspace30} -if eof(f) then input_ln:=false -else begin last_nonblank:=first; - while not eoln(f) do - begin if last>=max_buf_stack then - begin max_buf_stack:=last+1; - if max_buf_stack=buf_size then - @; - end; - buffer[last]:=f^; get(f); incr(last); - if buffer[last-1]<>" " then last_nonblank:=last; - end; - last:=last_nonblank; input_ln:=true; - end; -end; -@y -We define |input_ln| in C, for efficiency. Nevertheless we quote the module -`Report overflow of the input buffer, and abort' here in order to make -\.{WEAVE} happy, since part of that module is needed by e-TeX. - -@p @{ @ @} -@z - -@x -@= -@!term_in:alpha_file; {the terminal as an input file} -@!term_out:alpha_file; {the terminal as an output file} -@y -@d term_in==stdin {the terminal as an input file} -@d term_out==stdout {the terminal as an output file} - -@= -@!init -@!ini_version:boolean; {are we \.{INITEX}?} -@!dump_option:boolean; {was the dump name option used?} -@!dump_line:boolean; {was a \.{\%\AM format} line seen?} -tini@/ -@# -@!bound_default:integer; {temporary for setup} -@!bound_name:constcstring; {temporary for setup} -@# -@!error_line:integer; {width of context lines on terminal error messages} -@!half_error_line:integer; {width of first lines of contexts in terminal - error messages; should be between 30 and |error_line-15|} -@!max_print_line:integer; - {width of longest text lines output; should be at least 60} -@!ocp_list_size:integer; -@!ocp_buf_size:integer; -@!ocp_stack_size:integer; -@!max_strings:integer; {maximum number of strings; must not exceed |max_halfword|} -@!strings_free:integer; {strings available after format loaded} -@!string_vacancies:integer; {the minimum number of characters that should be - available for the user's control sequences and font names, - after \TeX's own error messages are stored} -@!pool_size:integer; {maximum number of characters in strings, including all - error messages and help texts, and the names of all fonts and - control sequences; must exceed |string_vacancies| by the total - length of \TeX's own strings, which is currently about 23000} -@!pool_free:integer;{pool space free after format loaded} -@!font_k:integer; {loop variable for initialization} -@!buf_size:integer; {maximum number of characters simultaneously present in - current lines of open files and in control sequences between - \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|} -@!stack_size:integer; {maximum number of simultaneous input sources} -@!max_in_open:integer; {maximum number of input files and error insertions that - can be going on simultaneously} -@!param_size:integer; {maximum number of simultaneous macro parameters} -@!nest_size:integer; {maximum number of semantic levels simultaneously active} -@!save_size:integer; {space for saving values outside of current group; must be - at most |max_halfword|} -@!dvi_buf_size:integer; {size of the output buffer; must be a multiple of 8} -@!expand_depth:integer; {limits recursive calls of the |expand| procedure} -@!parsefirstlinep:cinttype; {parse the first line for options} -@!filelineerrorstylep:cinttype; {format messages as file:line:error} -@!haltonerrorp:cinttype; {stop at first error} -@!quoted_filename:boolean; {current filename is quoted} -@z - -@x -@ Here is how to open the terminal files -in \ph. The `\.{/I}' switch suppresses the first |get|. -@:PASCAL H}{\ph@> -@^system dependencies@> - -@d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input} -@d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output} -@y -@ Here is how to open the terminal files. |t_open_out| does nothing. -|t_open_in|, on the other hand, does the work of ``rescanning,'' or getting -any command line arguments the user has provided. It's defined in C. - -@d t_open_out == {output already open for text output} -@z - -@x -these operations can be specified in \ph: -@:PASCAL H}{\ph@> -@^system dependencies@> - -@d update_terminal == break(term_out) {empty the terminal output buffer} -@d clear_terminal == break_in(term_in,true) {clear the terminal input buffer} -@y -these operations can be specified with {\mc UNIX}. |update_terminal| -does an |fflush|. |clear_terminal| is redefined -to do nothing, since the user should control the terminal. -@^system dependencies@> - -@d update_terminal == fflush (term_out) -@d clear_terminal == do_nothing -@z - -@x -@= -if format_ident=0 then - begin writeln(term_out,'Buffer size exceeded!'); goto final_end; -@.Buffer size exceeded@> - end -else - check_buffer_overflow(buf_size+10) { need a little bit more} -@y -@= - check_buffer_overflow(buf_size+10) { need a little bit more} -@z - -@x -@ The following program does the required initialization -without retrieving a possible command line. -It should be clear how to modify this routine to deal with command lines, -if the system permits them. -@^system dependencies@> - -@p function init_terminal:boolean; {gets the terminal input started} -label exit; -begin t_open_in; -@y -@ The following program does the required initialization. -Iff anything has been specified on the command line, then |t_open_in| -will return with |last > first|. -@^system dependencies@> - -@p function init_terminal:boolean; {gets the terminal input started} -label exit; -begin t_open_in; -if last > first then - begin loc := first; - while (loc < last) and (buffer[loc]=' ') do incr(loc); - if loc < last then - begin init_terminal := true; goto exit; - end; - end; -@z - -@x - write(term_out,'! End of file on the terminal... why?'); -@y - writeln(term_out,'! End of file on the terminal... why?'); -@z - -@x -@!str_pool:packed array[pool_pointer] of packed_ASCII_code; {the characters} -@!str_start : array[str_number] of pool_pointer; {the starting pointers} -@y -@!str_pool: ^packed_ASCII_code; {the characters} -@!str_start : ^pool_pointer; {the starting pointers} -@z - -@x -@p @!init function get_strings_started:boolean; {initializes the string pool, -@y -@p @t\4@>@@/ - -@!init function get_strings_started:boolean; {initializes the string pool, -@z - -@x -would like string @'32 to be the single character @'32 instead of the -@y -would like string @'32 to be printed as the single character @'32 -instead of the -@z - -@x -@!trick_buf:array[0..error_line] of packed_ASCII_code; {circular buffer for -@y -@!trick_buf:array[0..ssup_error_line] of packed_ASCII_code; {circular buffer for -@z - -@x -@d error_stop_mode=3 {stops at every opportunity to interact} -@y -@d error_stop_mode=3 {stops at every opportunity to interact} -@d unspecified_mode=4 {extra value for command-line switch} -@z - -@x - print_nl("! "); print(#); -@y - if filelineerrorstylep then print_file_line - else print_nl("! "); - print(#); -@z - -@x -@!interaction:batch_mode..error_stop_mode; {current level of interaction} -@y -@!interaction:batch_mode..error_stop_mode; {current level of interaction} -@!interactionoption:batch_mode..unspecified_mode; {set from command line} -@z - -@x -@ @=interaction:=error_stop_mode; -@y -@ @=if interactionoption=unspecified_mode then - interaction:=error_stop_mode -else - interaction:=interactionoption; -@z - -@x -@= -procedure jump_out; -begin goto end_of_TEX; -end; -@y -@d do_final_end==begin - update_terminal; - ready_already:=0; - if (history <> spotless) and (history <> warning_issued) then - uexit(1) - else - uexit(0); - end - -@= -procedure jump_out; -begin -close_files_and_terminate; -do_final_end; -end; -@z - -@x -show_context; -@y -show_context; -if (haltonerrorp) then begin - history:=fatal_error_stop; jump_out; -end; -@z - -@x -|remainder|, holds the remainder after a division. - -@= -@y -|remainder|, holds the remainder after a division. - -@d remainder==tex_remainder - -@= -@z - -@x -@!glue_ratio=real; {one-word representation of a glue expansion factor} -@y -@z - -@x -macros are simplified in the obvious way when |min_quarterword=0|. -@^inner loop@>@^system dependencies@> - -@d qi(#)==#+min_quarterword - {to put an |eight_bits| item into a quarterword} -@d qo(#)==#-min_quarterword - {to take an |eight_bits| item out of a quarterword} -@d hi(#)==#+min_halfword - {to put a sixteen-bit item into a halfword} -@d ho(#)==#-min_halfword - {to take a sixteen-bit item from a halfword} -@y -macros are simplified in the obvious way when |min_quarterword=0|. -So they have been simplified here in the obvious way. -@^inner loop@>@^system dependencies@> - -@d qi(#)==# {to put an |eight_bits| item into a quarterword} -@d qo(#)==# {to take an |eight_bits| item from a quarterword} -@d hi(#)==# {to put a sixteen-bit item into a halfword} -@d ho(#)==# {to take a sixteen-bit item from a halfword} -@z - -@x -@!quarterword = min_quarterword..max_quarterword; {1/4 of a word} -@!halfword=min_halfword..max_halfword; {1/2 of a word} -@!two_choices = 1..2; {used when there are two variants in a record} -@!four_choices = 1..4; {used when there are four variants in a record} -@!two_halves = packed record@;@/ - @!rh:halfword; - case two_choices of - 1: (@!lh:halfword); - 2: (@!b0:quarterword; @!b1:quarterword); - end; -@!four_quarters = packed record@;@/ - @!b0:quarterword; - @!b1:quarterword; - @!b2:quarterword; - @!b3:quarterword; - end; -@!memory_word = record@;@/ - case four_choices of - 1: (@!int:integer); - 2: (@!gr:glue_ratio); - 3: (@!hh:two_halves); - 4: (@!qqqq:four_quarters); - end; -@y -@!quarterword = min_quarterword..max_quarterword; -@!halfword = min_halfword..max_halfword; -@!two_choices = 1..2; {used when there are two variants in a record} -@!four_choices = 1..4; {used when there are four variants in a record} -@=#include "texmfmem.h";@> -@z - -@x -begin if m>0 then - case m div (max_command+1) of - 0:print("vertical"); - 1:print("horizontal"); - 2:print("display math"); - end -else if m=0 then print("no") -else case (-m) div (max_command+1) of - 0:print("internal vertical"); - 1:print("restricted horizontal"); - 2:print("math"); - end; -print(" mode"); -end; -@y -begin if m>0 then - case m div (max_command+1) of - 0:print("vertical mode"); - 1:print("horizontal mode"); - 2:print("display math mode"); - end -else if m=0 then print("no mode") -else case (-m) div (max_command+1) of - 0:print("internal vertical mode"); - 1:print("restricted horizontal mode"); - 2:print("math mode"); - end; -end; - -procedure print_in_mode(@!m:integer); {prints the mode represented by |m|} -begin if m>0 then - case m div (max_command+1) of - 0:print("' in vertical mode"); - 1:print("' in horizontal mode"); - 2:print("' in display math mode"); - end -else if m=0 then print("' in no mode") -else case (-m) div (max_command+1) of - 0:print("' in internal vertical mode"); - 1:print("' in restricted horizontal mode"); - 2:print("' in math mode"); - end; -end; -@z - -@x -@!nest:array[0..nest_size] of list_state_record; -@y -@!nest:^list_state_record; -@z - -@x -@; -@y -@/{The following piece of code is a copy of module 991:} -page_contents:=empty; page_tail:=page_head; {|link(page_head):=null;|}@/ -last_glue:=max_halfword; last_penalty:=0; last_kern:=0; -page_depth:=0; page_max_depth:=0; -@z - -@x - print_int(nest[p].pg_field); print(" line"); - if nest[p].pg_field<>1 then print_char("s"); -@y - print_int(nest[p].pg_field); - if nest[p].pg_field<>1 then print(" lines") - else print(" line"); -@z - -@x -for k:=null_cs to undefined_control_sequence-1 do - eqtb[k]:=eqtb[undefined_control_sequence]; -@y -for k:=null_cs to eqtb_top do - eqtb[k]:=eqtb[undefined_control_sequence]; -@z - -@x -@ The following procedure, which is called just before \TeX\ initializes its -input and output, establishes the initial values of the date and time. -@^system dependencies@> -Since standard \PASCAL\ cannot provide such information, something special -is needed. The program here simply specifies July 4, 1776, at noon; but -users probably want a better approximation to the truth. - -@p procedure fix_date_and_time; -begin time:=12*60; {minutes since midnight} -day:=4; {fourth day of the month} -month:=7; {seventh month of the year} -year:=1776; {Anno Domini} -end; -@y -@ The following procedure, which is called just before \TeX\ initializes its -input and output, establishes the initial values of the date and time. -It calls a macro-defined |date_and_time| routine. |date_and_time| -in turn is a C macro, which calls |get_date_and_time|, passing -it the addresses of the day, month, etc., so they can be set by the -routine. |get_date_and_time| also sets up interrupt catching if that -is conditionally compiled in the C code. -@^system dependencies@> - -@d fix_date_and_time==dateandtime(time,day,month,year) -@z - -@x -else if n -@y -else if (neqtb_size)and(n<=eqtb_top)) then - @ -@z - -@x -@!eqtb:array[null_cs..eqtb_size] of memory_word; -@y -@!zeqtb:^memory_word; -@z - -@x -@!hash: array[hash_base..undefined_control_sequence-1] of two_halves; - {the hash table} -@!hash_used:pointer; {allocation pointer for |hash|} -@y -@!hash: ^two_halves; {the hash table} -@!yhash: ^two_halves; {auxiliary pointer for freeing hash} -@!hash_used:pointer; {allocation pointer for |hash|} -@!hash_extra:pointer; {|hash_extra=hash| above |eqtb_size|} -@!hash_top:pointer; {maximum of the hash array} -@!eqtb_top:pointer; {maximum of the |eqtb|} -@!hash_high:pointer; {pointer to next high hash location} -@z - -@x -next(hash_base):=0; text(hash_base):=0; -for k:=hash_base+1 to undefined_control_sequence-1 do hash[k]:=hash[hash_base]; -@y -@z - -@x -hash_used:=frozen_control_sequence; {nothing is used} -@y -hash_used:=frozen_control_sequence; {nothing is used} -hash_high:=0; -@z - -@x -else if p>=undefined_control_sequence then print_esc("IMPOSSIBLE.") -@y -else if ((p>=undefined_control_sequence)and(p<=eqtb_size))or(p>eqtb_top) then - print_esc("IMPOSSIBLE.") -@z - -@x -else if (text(p)<0)or(text(p)>=str_ptr) then print_esc("NONEXISTENT.") -@y -else if (text(p)>=str_ptr) then print_esc("NONEXISTENT.") -@z - -@x -@!save_stack : array[0..save_size] of memory_word; -@y -@!save_stack : ^memory_word; -@z - -@x -if peqtb_size) then -@z - -@x -if cs_token_flag+undefined_control_sequence>max_halfword then bad:=21; -@y -if cs_token_flag+eqtb_size+hash_extra>max_halfword then bad:=21; -if (hash_offset<0)or(hash_offset>hash_base) then bad:=42; -@z - -@x -@!input_stack : array[0..stack_size] of in_state_record; -@y -@!input_stack : ^in_state_record; -@z - -@x -@!input_file : array[1..max_in_open] of alpha_file; -@!line : integer; {current line number in the current source file} -@!line_stack : array[1..max_in_open] of integer; -@y -@!input_file : ^alpha_file; -@!line : integer; {current line number in the current source file} -@!line_stack : ^integer; -@!source_filename_stack : ^str_number; -@!full_source_filename_stack : ^str_number; -@z - -@x - begin print_nl("Runaway "); -@.Runaway...@> - case scanner_status of - defining: begin print("definition"); p:=def_ref; - end; - matching: begin print("argument"); p:=temp_token_head; - end; - aligning: begin print("preamble"); p:=hold_token_head; - end; - absorbing: begin print("text"); p:=def_ref; - end; - end; {there are no other cases} -@y - begin -@.Runaway...@> - case scanner_status of - defining: begin print_nl("Runaway definition"); p:=def_ref; - end; - matching: begin print_nl("Runaway argument"); p:=temp_token_head; - end; - aligning: begin print_nl("Runaway preamble"); p:=hold_token_head; - end; - absorbing: begin print_nl("Runaway text"); p:=def_ref; - end; - end; {there are no other cases} -@z - -@x -@!param_stack:array [0..param_size] of pointer; - {token list pointers for parameters} -@y -@!param_stack: ^pointer; - {token list pointers for parameters} -@z - -@x -incr(in_open); push_input; index:=in_open; -@y -incr(in_open); push_input; index:=in_open; -source_filename_stack[index]:=0;full_source_filename_stack[index]:=0; -@z - -@x -begin input_ptr:=0; max_in_stack:=0; -@y -begin input_ptr:=0; max_in_stack:=0; -source_filename_stack[0]:=0;full_source_filename_stack[0]:=0; -@z - -@x -if_eof_code: begin scan_four_bit_int; b:=(read_open[cur_val]=closed); - end; -@y -if_eof_code: begin scan_four_bit_int_or_18; - if cur_val=18 then b:=not shellenabledp - else b:=(read_open[cur_val]=closed); - end; -@z - -@x -@ The file names we shall deal with for illustrative purposes have the -following structure: If the name contains `\.>' or `\.:', the file area -consists of all characters up to and including the final such character; -otherwise the file area is null. If the remaining file name contains -`\..', the file extension consists of all such characters from the first -remaining `\..' to the end, otherwise the file extension is null. -@y -@ The file names we shall deal with have the -following structure: If the name contains `\./' or `\.:' -(for Amiga only), the file area -consists of all characters up to and including the final such character; -otherwise the file area is null. If the remaining file name contains -`\..', the file extension consists of all such characters from the last -`\..' to the end, otherwise the file extension is null. -@z - -@x -@!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any} -@!ext_delimiter:pool_pointer; {the relevant `\..', if any} -@y -@!area_delimiter:pool_pointer; {the most recent `\./', if any} -@!ext_delimiter:pool_pointer; {the most recent `\..', if any} -@z - -@x -@d TEX_area=="TeXinputs:" -@.TeXinputs@> -@d TEX_font_area=="TeXfonts:" -@.TeXfonts@> -@y -In C, the default paths are specified separately. -@z - -@x -@d append_to_name(#)==begin c:=#; incr(k); - if k<=file_name_size then nameoffile[k]:=xchr[c]; - end -@y -@d append_to_name(#)==begin c:=#; if not (c="""") then begin incr(k); - if k<=file_name_size then nameoffile[k]:=xchr[c]; - end end -@z - -@x -for j:=str_start_macro(a) to str_start_macro(a+1)-1 do append_to_name(so(str_pool[j])); -@y -if nameoffile then libcfree (nameoffile); -nameoffile:= xmallocarray (packed_ASCII_code, length(a)+length(n)+length(e)+1); -for j:=str_start_macro(a) to str_start_macro(a+1)-1 do append_to_name(so(str_pool[j])); -@z - -@x -for k:=namelength+1 to file_name_size do nameoffile[k]:=' '; -@y -nameoffile[namelength+1]:=0; -@z - -@x -@d format_default_length=20 {length of the |TEX_format_default| string} -@d format_area_length=11 {length of its area part} -@d format_ext_length=4 {length of its `\.{.fmt}' part} -@y -Under {\mc UNIX} we don't give the area part, instead depending -on the path searching that will happen during file opening. Also, the -length will be set in the main program. - -@d format_area_length=0 {length of its area part} -@d format_ext_length=4 {length of its `\.{.fmt}' part} -@z - -@x -@!TEX_format_default:packed array[1..format_default_length] of char; - -@ @= -TEX_format_default:='TeXformats:plain.fmt'; -@y -@!format_default_length: integer; -@!TEX_format_default: ^char; - -@ We set the name of the default format file and the length of that name -in C, instead of Pascal, since we want them to depend on the name of the -program. -@z - -@x -for j:=1 to n do append_to_name(TEX_format_default[j]); -@y -if nameoffile then libcfree (nameoffile); -nameoffile := xmallocarray (packed_ASCII_code, n+(b-a+1)+format_ext_length+1); -for j:=1 to n do append_to_name(TEX_format_default[j]); -@z - -@x -for k:=namelength+1 to file_name_size do nameoffile[k]:=' '; -@y -nameoffile[namelength+1]:=0; -@z - -@x - pack_buffered_name(0,loc,j-1); {try first without the system file area} - if w_open_in(fmt_file) then goto found; - pack_buffered_name(format_area_length,loc,j-1); - {now try the system format file area} - if w_open_in(fmt_file) then goto found; -@y - pack_buffered_name(0,loc,j-1); {Kpathsea does everything} - if w_open_in(fmt_file) then goto found; -@z - -@x - wterm_ln('Sorry, I can''t find that format;',' will try PLAIN.'); -@y - wterm ('Sorry, I can''t find the format `'); - fputs (stringcast(nameoffile + 1), stdout); - wterm ('''; will try `'); - fputs (TEX_format_default + 1, stdout); - wterm_ln ('''.'); -@z - -@x - wterm_ln('I can''t find the PLAIN format file!'); -@.I can't find PLAIN...@> -@y - wterm ('I can''t find the format file `'); - fputs (TEX_format_default + 1, stdout); - wterm_ln ('''!'); -@.I can't find the format...@> -@z - -@x -@d ensure_dvi_open==if output_file_name=0 then -@y -@d log_name == texmf_log_name -@d ensure_dvi_open==if output_file_name=0 then -@z - -@x -@!months:packed array [1..36] of char; {abbreviations of month names} -@y -@!months:constcstring; -@z - -@x -if job_name=0 then job_name:="texput"; -@.texput@> -@y -if job_name=0 then job_name:=getjobname("texput"); -@.texput@> -pack_job_name('.fls'); -recorder_change_filename(stringcast(nameoffile+1)); -@z - -@x -slow_print(format_ident); print(" "); -@y -wlog(versionstring); -slow_print(format_ident); print(" "); -@z - -@x -months:='JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'; -@y -months := ' JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'; -@z - -@x -end -@y -if shellenabledp then begin - wlog_cr; - wlog(' '); - if restrictedshell then begin - wlog('restricted '); - end; - wlog('\write18 enabled.') - end; -if filelineerrorstylep then begin - wlog_cr; - wlog(' file:line:error style messages enabled.') - end; -if parsefirstlinep then begin - wlog_cr; - wlog(' %&-line parsing enabled.'); - end; -end -@z - -@x - prompt_file_name('input file name','.tex'); -@y - prompt_file_name('input file name',''); -@z - -@x -name:=a_make_name_string(cur_file); -@y -name:=a_make_name_string(cur_file); -source_filename_stack[in_open]:=name; -full_source_filename_stack[in_open]:=makefullnamestring; -if name=str_ptr-1 then {we can try to conserve string pool space now} - begin temp_str:=search_string(name); - if temp_str>0 then - begin name:=temp_str; flush_string; - end; - end; -@z - -@x - begin job_name:=cur_name; open_log_file; -@y - begin job_name:=getjobname(cur_name); open_log_file; -@z - -@x -if name=str_ptr-1 then {we can conserve string pool space now} - begin flush_string; name:=cur_name; - end; -@y -@z - -@x -@!ocp_list_info:array[ocp_list_index] of memory_word; - {the big collection of ocp list data} -@!ocp_listmem_ptr:ocp_list_index; {first unused word of |ocp_list_info|} -@!ocp_listmem_run_ptr:ocp_list_index; {temp unused word of |ocp_list_info|} -@!ocp_lstack_info:array[ocp_lstack_index] of memory_word; - {the big collection of ocp lstack data} -@!ocp_lstackmem_ptr:ocp_lstack_index; {first unused word of |ocp_lstack_info|} -@!ocp_lstackmem_run_ptr:ocp_lstack_index; {temp unused word of |ocp_lstack_info|} -@!ocp_list_ptr:internal_ocp_list_number; {largest internal ocp list number in use} -@!ocp_list_list:array[internal_ocp_list_number] of ocp_list_index; -@y -@!ocp_list_info:^memory_word; - {the big collection of ocp list data} -@!ocp_listmem_ptr:ocp_list_index; {first unused word of |ocp_list_info|} -@!ocp_listmem_run_ptr:ocp_list_index; {temp unused word of |ocp_list_info|} -@!ocp_lstack_info:^memory_word; - {the big collection of ocp lstack data} -@!ocp_lstackmem_ptr:ocp_lstack_index; {first unused word of |ocp_lstack_info|} -@!ocp_lstackmem_run_ptr:ocp_lstack_index; {temp unused word of |ocp_lstack_info|} -@!ocp_list_ptr:internal_ocp_list_number; {largest internal ocp list number in use} -@!ocp_list_list:^ocp_list_index; -@z - -@x -@!dvi_buf:array[dvi_index] of real_eight_bits; {buffer for \.{DVI} output} -@!half_buf:dvi_index; {half of |dvi_buf_size|} -@!dvi_limit:dvi_index; {end of the current half buffer} -@!dvi_ptr:dvi_index; {the next available buffer address} -@y -@!dvi_buf:^real_eight_bits; {buffer for \.{DVI} output} -@!half_buf:integer; {half of |dvi_buf_size|} -@!dvi_limit:integer; {end of the current half buffer} -@!dvi_ptr:integer; {the next available buffer address} -@z - -@x -@p procedure write_dvi(@!a,@!b:dvi_index); -var k:dvi_index; -begin for k:=a to b do write(dvi_file,dvi_buf[k]); -end; -@y -In C, we use a macro to call |fwrite| or |write| directly, writing all -the bytes in one shot. Much better even than writing four -bytes at a time. -@z - -@x - old_setting:=selector; selector:=new_string; -@y -if output_comment then - begin l:=strlen(output_comment); dvi_out(l); - for s:=0 to l-1 do dvi_out(output_comment[s]); - end -else begin {the default code is unchanged} - old_setting:=selector; selector:=new_string; -@z - -@x - pool_ptr:=str_start_macro(str_ptr); {flush the current string} -@y - pool_ptr:=str_start_macro(str_ptr); {flush the current string} -end; -@z - -@x -dvi_out(eop); incr(total_pages); cur_s:=-1; -@y -dvi_out(eop); incr(total_pages); cur_s:=-1; -ifdef ('IPC') -if ipcon>0 then - begin if dvi_limit=half_buf then - begin write_dvi(half_buf, dvi_buf_size-1); - flush_dvi; - dvi_gone:=dvi_gone+half_buf; - end; - if dvi_ptr>0 then - begin write_dvi(0, dvi_ptr-1); - flush_dvi; - dvi_offset:=dvi_offset+dvi_ptr; dvi_gone:=dvi_gone+dvi_ptr; - end; - dvi_ptr:=0; dvi_limit:=dvi_buf_size; - ipcpage(dvi_gone); - end; -endif ('IPC'); -@z - -@x - k:=4+((dvi_buf_size-dvi_ptr) mod 4); {the number of 223's} -@y -ifdef ('IPC') - k:=7-((3+dvi_offset+dvi_ptr) mod 4); {the number of 223's} -endif ('IPC') -ifndef ('IPC') - k:=4+((dvi_buf_size-dvi_ptr) mod 4); {the number of 223's} -endifn ('IPC') -@z - -@x - print_nl("Output written on "); slow_print(output_file_name); -@y - print_nl("Output written on "); print_file_name(0, output_file_name, 0); -@z - -@x - print(" ("); print_int(total_pages); print(" page"); - if total_pages<>1 then print_char("s"); -@y - print(" ("); print_int(total_pages); - if total_pages<>1 then print(" pages") - else print(" page"); -@z - -@x -@= -continue: adjust_space_factor;@/ -@y -@= -continue: adjust_space_factor;@/ -@z - -@x -print("' in "); print_mode(mode); -@y -print_in_mode(mode); -@z - -@x -if indented then begin - p:=new_null_box; box_dir(p):=par_direction; - width(p):=par_indent;@+ - tail_append(p); -@y -if indented then begin - p:=new_null_box; box_dir(p):=par_direction; - width(p):=par_indent;@+ - tail_append(p); -@z - -@x -begin print_err("Extra "); print_esc("endcsname"); -@.Extra \\endcsname@> -help1("I'm ignoring this, since I wasn't doing a \csname."); -@y -begin -if cur_chr = 10 then -begin - print_err("Extra "); print_esc("endmubyte"); -@.Extra \\endmubyte@> - help1("I'm ignoring this, since I wasn't doing a \mubyte."); -end else begin - print_err("Extra "); print_esc("endcsname"); -@.Extra \\endcsname@> - help1("I'm ignoring this, since I wasn't doing a \csname."); -end; -@z - -@x -if (cur_cs=0)or(cur_cs>frozen_control_sequence) then -@y -if (cur_cs=0)or(cur_cs>eqtb_top)or - ((cur_cs>frozen_control_sequence)and(cur_cs<=eqtb_size)) then -@z - -@x -interaction:=cur_chr; -@y -interaction:=cur_chr; -if interaction = batch_mode -then kpsemaketexdiscarderrors := 1 -else kpsemaketexdiscarderrors := 0; -@z - -@x -slow_print(s); update_terminal; -@y -print(s); update_terminal; -@z - -@x -begin print_err(""); slow_print(s); -@y -begin print_err(""); print(s); -@z - -@x -format_ident:=" (INITEX)"; -@y -if ini_version then format_ident:=" (INITEX)"; -@z - -@x -@!w: four_quarters; {four ASCII codes} -@y -@!format_engine: ^packed_ASCII_code; -@z - -@x -@!w: four_quarters; {four ASCII codes} -@y -@!format_engine: ^packed_ASCII_code; -@z - -@x -@d dump_wd(#)==begin fmt_file^:=#; put(fmt_file);@+end -@d dump_int(#)==begin fmt_file^.int:=#; put(fmt_file);@+end -@d dump_hh(#)==begin fmt_file^.hh:=#; put(fmt_file);@+end -@d dump_qqqq(#)==begin fmt_file^.qqqq:=#; put(fmt_file);@+end -@y -@z - -@x -@d undump_wd(#)==begin get(fmt_file); #:=fmt_file^;@+end -@d undump_int(#)==begin get(fmt_file); #:=fmt_file^.int;@+end -@d undump_hh(#)==begin get(fmt_file); #:=fmt_file^.hh;@+end -@d undump_qqqq(#)==begin get(fmt_file); #:=fmt_file^.qqqq;@+end -@y -@z - -@x -@d undump_size_end_end(#)==too_small(#)@+else undump_end_end -@y -@d format_debug_end(#)== - writeln (stderr, ' = ', #); - end; -@d format_debug(#)== - if debug_format_file then begin - write (stderr, 'fmtdebug:', #); - format_debug_end -@d undump_size_end_end(#)== - too_small(#)@+else format_debug (#)(x); undump_end_end -@z - -@x -dump_int(@$);@/ -@y -dump_int(@"57325458); {Web2C \TeX's magic constant: "W2TX"} -{Align engine to 4 bytes with one or more trailing NUL} -x:=strlen(engine_name); -format_engine:=xmallocarray(packed_ASCII_code,x+4); -strcpy(stringcast(format_engine), conststringcast(engine_name)); -for k:=x to x+3 do format_engine[k]:=0; -x:=x+4-(x mod 4); -dump_int(x);dump_things(format_engine[0], x); -libcfree(format_engine);@/ -dump_int(@$);@/ -dump_int(max_halfword);@/ -dump_int(hash_high); -@z - -@x -x:=fmt_file^.int; -if x<>@$ then goto bad_fmt; {check that strings are the same} -@y -@+Init -libcfree(str_pool); libcfree(str_start); -libcfree(yhash); libcfree(zeqtb); libcfree(fixmem); libcfree(varmemcast(varmem)); -@+Tini -undump_int(x); -format_debug('format magic number')(x); -if x<>@"57325458 then goto bad_fmt; {not a format file} -undump_int(x); -format_debug('engine name size')(x); -if (x<0) or (x>256) then goto bad_fmt; {corrupted format file} -format_engine:=xmallocarray(packed_ASCII_code, x); -undump_things(format_engine[0], x); -format_engine[x-1]:=0; {force string termination, just in case} -if strcmp(conststringcast(engine_name), stringcast(format_engine)) then - begin wake_up_terminal; - wterm_ln('---! ', stringcast(nameoffile+1), ' was written by ', format_engine); - libcfree(format_engine); - goto bad_fmt; -end; -libcfree(format_engine); -undump_int(x); -format_debug('string pool checksum')(x); -if x<>@$ then begin {check that strings are the same} - wake_up_terminal; - wterm_ln('---! ', stringcast(nameoffile+1), ' was written by an older version'); - goto bad_fmt; -end; -undump_int(x); -if x<>max_halfword then goto bad_fmt; {check |max_halfword|} -undump_int(hash_high); - if (hash_high<0)or(hash_high>sup_hash_extra) then goto bad_fmt; - if hash_extraeqtb_size -@y -k:=j+1; dump_int(k-l); -until k>eqtb_size; -if hash_high>0 then dump_things(eqtb[eqtb_size+1],hash_high); - {dump |hash_extra| part} -@z - -@x -for j:=k to k+x-1 do undump_wd(eqtb[j]); -@y -undump_things(eqtb[k], x); -@z - -@x -until k>eqtb_size -@y -until k>eqtb_size; -if hash_high>0 then undump_things(eqtb[eqtb_size+1],hash_high); - {undump |hash_extra| part} -@z - -@x -dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used; -@y -dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used+hash_high; -@z - -@x -for p:=hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]); -@y -dump_things(hash[hash_used+1], undefined_control_sequence-1-hash_used); -if hash_high>0 then dump_things(hash[eqtb_size+1], hash_high); -@z - -@x -for p:=hash_used+1 to undefined_control_sequence-1 do undump_hh(hash[p]); -@y -undump_things (hash[hash_used+1], undefined_control_sequence-1-hash_used); -if debug_format_file then begin - print_csnames (hash_base, undefined_control_sequence - 1); -end; -if hash_high > 0 then begin - undump_things (hash[eqtb_size+1], hash_high); - if debug_format_file then begin - print_csnames (eqtb_size + 1, hash_high - (eqtb_size + 1)); - end; -end; -@z - -@x -@ @= -begin undump_font(k);@/ -end -@y -@ @= -begin undump_font(k);@/ -end; -make_pdftex_banner -@z - -@x -for k:=0 to active_max_ptr-1 do dump_wd(active_info[k]); -if active_max_ptr>0 then begin - print_ln; print_int(active_max_ptr); print(" words of active ocps"); - end; - -@ @= -undump_size(0)(active_mem_size)('active start point')(active_min_ptr); -undump_size(0)(active_mem_size)('active mem size')(active_max_ptr); -for k:=0 to active_max_ptr-1 do undump_wd(active_info[k]); -@y -if active_max_ptr>0 then - dump_things(active_info[0], active_max_ptr); -if active_max_ptr>0 then begin - print_ln; print_int(active_max_ptr); print(" words of active ocps"); - end; - -@ @= -undump_size(0)(active_mem_size)('active start point')(active_min_ptr); -undump_size(0)(active_mem_size)('active mem size')(active_max_ptr); -if active_max_ptr>0 then - undump_things(active_info[0], active_max_ptr); -@z - -@x -@ @= -dump_int(ocp_listmem_ptr); -for k:=0 to ocp_listmem_ptr-1 do dump_wd(ocp_list_info[k]); -dump_int(ocp_list_ptr); -for k:=null_ocp_list to ocp_list_ptr do begin - dump_int(ocp_list_list[k]); - if null_ocp_list<>ocp_list_ptr then begin - print_nl("\ocplist"); - print_esc(ocp_list_id_text(k)); - print_char("="); - print_ocp_list(ocp_list_list[k]); - end; - end; -dump_int(ocp_lstackmem_ptr); -for k:=0 to ocp_lstackmem_ptr-1 do dump_wd(ocp_lstack_info[k]) -@y -@ @= -dump_int(ocp_listmem_ptr); -dump_things(ocp_list_info[0], ocp_listmem_ptr); -dump_int(ocp_list_ptr); -dump_things(ocp_list_list[null_ocp_list], ocp_list_ptr+1-null_ocp_list); -for k:=null_ocp_list to ocp_list_ptr do begin - if null_ocp_list<>ocp_list_ptr then begin - print_nl("\ocplist"); - print_esc(ocp_list_id_text(k)); - print_char("="); - print_ocp_list(ocp_list_list[k]); - end; - end; -dump_int(ocp_lstackmem_ptr); -dump_things(ocp_lstack_info[0], ocp_lstackmem_ptr) -@z - -@x -@ @= -undump_size(1)(1000000)('ocp list mem size')(ocp_listmem_ptr); -for k:=0 to ocp_listmem_ptr-1 do undump_wd(ocp_list_info[k]); -undump_size(ocp_list_base)(ocp_list_biggest)('ocp list max')(ocp_list_ptr); -for k:=null_ocp_list to ocp_list_ptr do - undump_int(ocp_list_list[k]); -undump_size(1)(1000000)('ocp lstack mem size')(ocp_lstackmem_ptr); -for k:=0 to ocp_lstackmem_ptr-1 do undump_wd(ocp_lstack_info[k]) -@y -@ @= -undump_size(1)(1000000)('ocp list mem size')(ocp_listmem_ptr); -undump_things(ocp_list_info[0], ocp_listmem_ptr); -undump_size(0)(1000000)('ocp list max')(ocp_list_ptr); -undump_things(ocp_list_list[null_ocp_list], ocp_list_ptr+1-null_ocp_list); -undump_size(0)(1000000)('ocp lstack mem size')(ocp_lstackmem_ptr); -undump_things(ocp_lstack_info[0], ocp_lstackmem_ptr) -@z - -@x -undump(batch_mode)(error_stop_mode)(interaction); -@y -undump(batch_mode)(error_stop_mode)(interaction); -if interactionoption<>unspecified_mode then interaction:=interactionoption; -@z - -@x -if (x<>69069)or eof(fmt_file) then goto bad_fmt -@y -if x<>69069 then goto bad_fmt -@z - -@x -print(" (preloaded format="); print(job_name); print_char(" "); -@y -print(" (format="); print(job_name); print_char(" "); -@z - -@x -@p begin @!{|start_here|} -@y -@d const_chk(#)==begin if # < inf_@&# then # := inf_@&# else - if # > sup_@&# then # := sup_@&# end - -{|setup_bound_var| stuff duplicated in \.{mf.ch}.} -@d setup_bound_var(#)==bound_default:=#; setup_bound_var_end -@d setup_bound_var_end(#)==bound_name:=#; setup_bound_var_end_end -@d setup_bound_var_end_end(#)==if luainit>0 then begin - get_lua_number('texconfig',bound_name,addressof(#)); - if #=0 then #:=bound_default; - end - else - setupboundvariable(addressof(#), bound_name, bound_default); - -@p procedure main_body; -begin @!{|start_here|} - -{Bounds that may be set from the configuration file. We want the user to - be able to specify the names with underscores, but \.{TANGLE} removes - underscores, so we're stuck giving the names twice, once as a string, - once as the identifier. How ugly.} - - setup_bound_var (100000)('pool_size')(pool_size); - setup_bound_var (75000)('string_vacancies')(string_vacancies); - setup_bound_var (5000)('pool_free')(pool_free); {min pool avail after fmt} - setup_bound_var (15000)('max_strings')(max_strings); - setup_bound_var (100)('strings_free')(strings_free); - setup_bound_var (3000)('buf_size')(buf_size); - setup_bound_var (50)('nest_size')(nest_size); - setup_bound_var (15)('max_in_open')(max_in_open); - setup_bound_var (60)('param_size')(param_size); - setup_bound_var (4000)('save_size')(save_size); - setup_bound_var (300)('stack_size')(stack_size); - setup_bound_var (16384)('dvi_buf_size')(dvi_buf_size); - setup_bound_var (79)('error_line')(error_line); - setup_bound_var (50)('half_error_line')(half_error_line); - setup_bound_var (79)('max_print_line')(max_print_line); - setup_bound_var(1000)('ocp_list_size')(ocp_list_size); - setup_bound_var(1000)('ocp_buf_size')(ocp_buf_size); - setup_bound_var(1000)('ocp_stack_size')(ocp_stack_size); - setup_bound_var (0)('hash_extra')(hash_extra); - setup_bound_var (72)('pk_dpi')(pk_dpi); - setup_bound_var (10000)('expand_depth')(expand_depth); - - {Check other constants against their sup and inf.} - const_chk (buf_size); - const_chk (nest_size); - const_chk (max_in_open); - const_chk (param_size); - const_chk (save_size); - const_chk (stack_size); - const_chk (dvi_buf_size); - const_chk (pool_size); - const_chk (string_vacancies); - const_chk (pool_free); - const_chk (max_strings); - const_chk (strings_free); - const_chk (hash_extra); - const_chk (obj_tab_size); - const_chk (pdf_mem_size); - const_chk (dest_names_size); - const_chk (pk_dpi); - if error_line > ssup_error_line then error_line := ssup_error_line; - - {array memory allocation} - buffer:=xmallocarray (packed_ASCII_code, buf_size); - nest:=xmallocarray (list_state_record, nest_size); - save_stack:=xmallocarray (memory_word, save_size); - input_stack:=xmallocarray (in_state_record, stack_size); - input_file:=xmallocarray (alpha_file, max_in_open); - input_file_callback_id:=xmallocarray (integer, max_in_open); - line_stack:=xmallocarray (integer, max_in_open); - eof_seen:=xmallocarray (boolean, max_in_open); - grp_stack:=xmallocarray (save_pointer, max_in_open); - if_stack:=xmallocarray (pointer, max_in_open); - source_filename_stack:=xmallocarray (str_number, max_in_open); - full_source_filename_stack:=xmallocarray (str_number, max_in_open); - param_stack:=xmallocarray (halfword, param_size); - dvi_buf:=xmallocarray (real_eight_bits, dvi_buf_size); - ocp_list_info:=xmallocarray (memory_word, ocp_list_size); - memset(ocp_list_info,0,sizeof(memory_word)* ocp_list_size); - ocp_lstack_info:=xmallocarray (memory_word, ocp_list_size); - memset(ocp_lstack_info,0,sizeof(memory_word)* ocp_list_size); - ocp_list_list:=xmallocarray (ocp_list_index, ocp_list_size); - otp_init_input_buf:=xmallocarray (quarterword, ocp_buf_size); - otp_input_buf:=xmallocarray (quarterword, ocp_buf_size); - otp_output_buf:=xmallocarray (quarterword, ocp_buf_size); - otp_stack_buf:=xmallocarray (quarterword, ocp_stack_size); - otp_calcs:=xmallocarray (halfword, ocp_stack_size); - otp_states:=xmallocarray (halfword, ocp_stack_size); - obj_tab:=xmallocarray (obj_entry, inf_obj_tab_size); {will grow dynamically} - obj_offset(0):=0; - pdf_mem:=xmallocarray (integer, inf_pdf_mem_size); {will grow dynamically} - dest_names:=xmallocarray (dest_name_entry, inf_dest_names_size); {will grow dynamically} - pdf_op_buf:=xmallocarray (real_eight_bits, pdf_op_buf_size); - pdf_os_buf:=xmallocarray (real_eight_bits, inf_pdf_os_buf_size); {will grow dynamically} - pdf_os_objnum:=xmallocarray (integer, pdf_os_max_objs); - pdf_os_objoff:=xmallocarray (integer, pdf_os_max_objs); -@+Init - fixmem:=xmallocarray (smemory_word, fix_mem_init+1); - memset (voidcast(fixmem), 0, (fix_mem_init+1)*sizeof(smemory_word)); - fix_mem_min:=0; - fix_mem_max:=fix_mem_init; - - eqtb_top := eqtb_size+hash_extra; - if hash_extra=0 then hash_top:=undefined_control_sequence else - hash_top:=eqtb_top; - yhash:=xmallocarray (two_halves,1+hash_top-hash_offset); - hash:=yhash - hash_offset; {Some compilers require |hash_offset=0|} - next(hash_base):=0; text(hash_base):=0; - for hash_used:=hash_base+1 to hash_top do hash[hash_used]:=hash[hash_base]; - zeqtb:=xmallocarray (memory_word, eqtb_top); - eqtb:=zeqtb; - - str_start:=xmallocarray (pool_pointer, max_strings); - str_pool:=xmallocarray (packed_ASCII_code, pool_size); -@+Tini -@z - -@x -@!init if not get_strings_started then goto final_end; -init_prim; {call |primitive| for each primitive} -init_str_ptr:=str_ptr; init_pool_ptr:=pool_ptr; fix_date_and_time; -tini@/ -@y -@!Init if not get_strings_started then goto final_end; -init_prim; {call |primitive| for each primitive} -init_str_ptr:=str_ptr; init_pool_ptr:=pool_ptr; fix_date_and_time; -Tini@/ -@z - -@x -end_of_TEX: close_files_and_terminate; -final_end: ready_already:=0; -end. -@y -close_files_and_terminate; -final_end: do_final_end; -end {|main_body|}; -@z - -@x - if format_ident=0 then wterm_ln(' (no format preloaded)') - else begin slow_print(format_ident); print_ln; - end; -@y - wterm(versionstring); - if format_ident>0 then slow_print(format_ident); - print_ln; - if shellenabledp then begin - wterm(' '); - if restrictedshell then begin - wterm('restricted '); - end; - wterm_ln('\write18 enabled.'); - end; -@z - -@x -write_svnversion(luatex_svnversion); -@y -wterm(versionstring); -write_svnversion(luatex_svnversion); -@z - -@x - slow_print(log_name); print_char("."); -@y - print_file_name(0, log_name, 0); print_char("."); -@z - -@x - end; -@y - end; -print_ln; -if (edit_name_start<>0) and (interaction>batch_mode) then - calledit(str_pool,edit_name_start,edit_name_length,edit_line); -@z - -@x - wlog_ln(' ',cs_count:1,' multiletter control sequences out of ', - hash_size:1);@/ -@y - wlog_ln(' ',cs_count:1,' multiletter control sequences out of ', - hash_size:1, '+', hash_extra:1);@/ -@z - -@x - begin @!init for i:=0 to biggest_used_mark do begin -@y - begin @!Init for i:=0 to biggest_used_mark do begin -@z - -@x - store_fmt_file; return;@+tini@/ -@y - store_fmt_file; return;@+Tini@/ -@z - -@x -if (format_ident=0)or(buffer[loc]="&") then -@y -if (format_ident=0)or(buffer[loc]="&")or dump_line then -@z - -@x - w_close(fmt_file); -@y - w_close(fmt_file); - eqtb:=zeqtb; -@z - -@x -fix_date_and_time;@/ -@y -fix_date_and_time;@/ -@!init -make_pdftex_banner; -tini@/ -@z - -@x - begin goto breakpoint;@\ {go to every label at least once} - breakpoint: m:=0; @{'BREAKPOINT'@}@\ - end -@y - abort {do something to cause a core dump} -@z - -@x - else if cur_val>15 then cur_val:=16; -@y - else if (cur_val>15) and (cur_val <> 18) then cur_val:=16; -@z - -@x -begin @ - -@= -@!edit_name_start: pool_pointer; {where the filename to switch to starts} -@!edit_name_length,@!edit_line: integer; {what line to start editing at} -@!ipcon: cinttype; {level of IPC action, 0 for none [default]} -@!stop_at_space: boolean; {whether |more_name| returns false for space} - -@ The |edit_name_start| will be set to point into |str_pool| somewhere after -its beginning if \TeX\ is supposed to switch to an editor on exit. - -@= -edit_name_start:=0; -stop_at_space:=true; - -@ These are used when we regenerate the representation of the first 256 -strings. - -@ = -@!save_str_ptr: str_number; -@!save_pool_ptr: pool_pointer; -@!shellenabledp: cinttype; -@!restrictedshell: cinttype; -@!output_comment: ^char; -@!k,l: 0..255; {used by `Make the first 256 strings', etc.} - -@ When debugging a macro package, it can be useful to see the exact -control sequence names in the format file. For example, if ten new -csnames appear, it's nice to know what they are, to help pinpoint where -they came from. (This isn't a truly ``basic'' printing procedure, but -that's a convenient module in which to put it.) - -@ = -procedure print_csnames (hstart:integer; hfinish:integer); -var c,h:integer; -begin - writeln(stderr, 'fmtdebug:csnames from ', hstart, ' to ', hfinish, ':'); - for h := hstart to hfinish do begin - if text(h) > 0 then begin {if have anything at this position} - for c := str_start_macro(text(h)) to str_start_macro(text(h) + 1) - 1 - do begin - putbyte(str_pool[c], stderr); {print the characters} - end; - writeln(stderr, '|'); - end; - end; -end; - -@ Are we printing extra info as we read the format file? - -@ = -@!debug_format_file: boolean; - - -@ A helper for printing file:line:error style messages. Look for a -filename in |full_source_filename_stack|, and if we fail to find -one fall back on the non-file:line:error style. - -@= -procedure print_file_line; -var level: 0..max_in_open; -begin - level:=in_open; - while (level>0) and (full_source_filename_stack[level]=0) do - decr(level); - if level=0 then - print_nl("! ") - else begin - print_nl (""); print (full_source_filename_stack[level]); print (":"); - if level=in_open then print_int (line) - else print_int (line_stack[index+1-(in_open-level)]); - print (": "); - end; -end; - -@ To be able to determine whether \.{\\write18} is enabled from within -\TeX\ we also implement \.{\\eof18}. We sort of cheat by having an -additional route |scan_four_bit_int_or_18| which is the same as -|scan_four_bit_int| except it also accepts the value 18. - -@= -procedure scan_four_bit_int_or_18; -begin scan_int; -if (cur_val<0)or((cur_val>15)and(cur_val<>18)) then - begin print_err("Bad number"); -@.Bad number@> - help2("Since I expected to read a number between 0 and 15,")@/ - ("I changed this one to zero."); int_error(cur_val); cur_val:=0; - end; -end; - -@* \[54/web2c-string] The string recycling routines. \TeX{} uses 2 -upto 4 {\it new\/} strings when scanning a filename in an \.{\\input}, -\.{\\openin}, or \.{\\openout} operation. These strings are normally -lost because the reference to them are not saved after finishing the -operation. |search_string| searches through the string pool for the -given string and returns either 0 or the found string number. - -@= -function search_string(@!search:str_number):str_number; -label found; -var result: str_number; -@!s: str_number; {running index} -@!len: integer; {length of searched string} -begin result:=0; len:=length(search); -if len=0 then {trivial case} - begin result:=""; goto found; - end -else begin s:=search-1; {start search with newest string below |s|; |search>1|!} - while s>=string_offset do {first |string_offset| strings depend on implementation!!} - begin if length(s)=len then - if str_eq_str(s,search) then - begin result:=s; goto found; - end; - decr(s); - end; - end; -found:search_string:=result; -end; - -@ The following routine is a variant of |make_string|. It searches -the whole string pool for a string equal to the string currently built -and returns a found string. Otherwise a new string is created and -returned. Be cautious, you can not apply |flush_string| to a replaced -string! - -@= -function slow_make_string : str_number; -label exit; -var s: str_number; {result of |search_string|} -@!t: str_number; {new string} -begin t:=make_string; s:=search_string(t); -if s>0 then - begin flush_string; slow_make_string:=s; return; - end; -slow_make_string:=t; -exit:end; - - -@* \[54] System-dependent changes. -@z - - -@x -@* \[55] Index. -@y - -@ This function used to be in pdftex, but is useful in tex too. - -@p function get_nullstr: str_number; -begin - get_nullstr := ""; -end; - -@* \[55] Index. -@z - diff --git a/Build/source/texk/web2c/luatexdir/luatex.defines b/Build/source/texk/web2c/luatexdir/luatex.defines deleted file mode 100644 index a36e3847b0f..00000000000 --- a/Build/source/texk/web2c/luatexdir/luatex.defines +++ /dev/null @@ -1,900 +0,0 @@ -{ luatex.defines - - Copyright 1996-2006 Han The Thanh - Copyright 2006-2008 Taco Hoekwater - - This file is part of LuaTeX. - - LuaTeX is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - LuaTeX is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see . } - -{ $Id$ } - -{ luatex.defines: additions for LuaTeX } - -@define function simple_advance_width(); - -@define function new_node(); -@define function new_glyph_node; -@define procedure flush_node(); -@define function copy_node(); -@define procedure couple_nodes(); -@define function copy_node_list(); -@define procedure flush_node_list(); -@define function string_to_pseudo(); -@define function do_set_attribute(); -@define function copy_attribute_list(); -@define procedure add_node_attr_ref(); -@define procedure replace_attribute_list(); -@define procedure update_attribute_cache; -@define const UNUSED_ATTRIBUTE; - -@define function new_span_node(); - -@define function sizeof(); -@define procedure memset(); -@define function realloc(); -@define function malloc(); -@define function voidcast(); -@define function fixmemcast(); -@define function varmemcast(); -@define type void; -@define procedure init_node_mem(); -@define procedure print_node_mem_stats; -@define procedure dump_node_mem; -@define procedure undump_node_mem; -@define function visible_last_node_type(); -@define var NULL; -@define var varmem; -@define var var_mem_max; -@define procedure check_buffer_overflow(); -@define procedure check_pool_overflow(); - -@define function new_ligkern(); -@define function make_lang_data(); -@define procedure ext_do_line_break(); -@define procedure initialize_active; -@define var prev_char_p; -@define function cur_break(); -@define function break_node(); - -@define function divide_scaled(); -@define function divide_scaled_n(); - -@define procedure new_hyphenation(); -@define procedure load_tex_hyphenation(); -@define procedure load_tex_patterns(); -@define procedure dump_language_data; -@define procedure undump_language_data; -@define function insert_discretionary(); -@define const select_disc; -@define function compound_word_break(); -@define procedure set_pre_hyphen_char(); -@define procedure set_post_hyphen_char(); -@define procedure set_pre_exhyphen_char(); -@define procedure set_post_exhyphen_char(); -@define function get_pre_hyphen_char(); -@define function get_post_hyphen_char(); -@define function get_pre_exhyphen_char(); -@define function get_post_exhyphen_char(); - - -{ macros from luatex.h } -@define function pdf_char_marked(); -@define function tex_b_open_in(); -@define function vf_b_open_in (); -@define procedure pdf_mark_char(); -@define procedure writepdf(); -@define procedure pdfassert(); - -@define procedure luacall(); -@define procedure luatokencall(); -@define procedure closelua(); -@define function get_lua_name(); - -{ for virtual file input } - -@define procedure luacstring_close(); -@define procedure luacstring_start(); -@define var DEFAULT_CAT_TABLE; - -{ for callbacks } - -@define function run_callback(); -@define function run_and_save_callback(); -@define function run_saved_callback(); -@define procedure destroy_saved_callback(); -@define function callback_defined(); -@define function callbackluaid(); -@define var find_write_file_callback; -@define var find_output_file_callback; -@define var find_image_file_callback; -@define var find_format_file_callback; -@define var find_read_file_callback; -@define var open_read_file_callback; -@define var find_ocp_file_callback; -@define var read_ocp_file_callback; -@define var find_vf_file_callback; -@define var read_vf_file_callback; -@define var find_data_file_callback; -@define var read_data_file_callback; -@define var find_font_file_callback; -@define var read_font_file_callback; -@define var find_map_file_callback; -@define var read_map_file_callback; -@define var find_enc_file_callback; -@define var read_enc_file_callback; -@define var find_type1_file_callback; -@define var read_type1_file_callback; -@define var find_truetype_file_callback; -@define var read_truetype_file_callback; -@define var find_opentype_file_callback; -@define var read_opentype_file_callback; -@define var find_sfd_file_callback; -@define var read_sfd_file_callback; -@define var find_pk_file_callback; -@define var read_pk_file_callback; -@define var show_error_hook_callback; -@define var process_input_buffer_callback; -@define var start_page_number_callback; -@define var stop_page_number_callback; -@define var start_run_callback; -@define var stop_run_callback; -@define var define_font_callback; -@define var token_filter_callback; -@define var pre_linebreak_filter_callback; -@define var linebreak_filter_callback; -@define var post_linebreak_filter_callback; -@define var buildpage_filter_callback; -@define var hyphenate_callback; - -@define function lua_hyphenate_callback(); -@define function lua_linebreak_callback(); - -@define procedure get_saved_lua_boolean(); -@define procedure get_saved_lua_number(); -@define procedure get_saved_lua_string(); -@define procedure get_lua_boolean(); -@define procedure get_lua_number(); -@define procedure get_lua_string(); - -@define procedure get_token_lua; -@define procedure lua_node_filter(); -@define procedure lua_node_filter_s(); -@define function lua_hpack_filter(); -@define function lua_vpack_filter(); - -@define procedure check_texconfig_init; - -@define procedure lua_pdf_literal(); - -{ bits for extended char code access } - -@define const tex_mathcode ; -@define const aleph_mathcode ; -@define const xetex_mathcode ; -@define const xetexnum_mathcode; - -@define type mathcodeval; -@define @field origin_value; -@define @field class_value; -@define @field family_value; -@define @field character_value; - -@define type delcodeval; -@define @field small_family_value; -@define @field small_character_value; -@define @field large_family_value; -@define @field large_character_value; - -@define function get_math_code(); -@define function get_math_code_num(); -@define procedure set_math_code(); -@define function get_del_code(); -@define procedure set_del_code(); -@define procedure show_mathcode_value(); - -@define function scan_mathchar(); -@define function scan_delimiter_as_mathchar(); -@define function mathchar_from_integer(); - -@define procedure init_math_fields; -@define procedure setup_math_style; -@define procedure print_math_style; - -@define procedure unsave_math_codes (); -@define procedure initialize_math_codes; -@define procedure dump_math_codes; -@define procedure undump_math_codes; -@define procedure free_math_codes; - -@define function get_lc_code(); -@define procedure set_lc_code(); - -@define function get_uc_code(); -@define procedure set_uc_code(); - -@define function get_sf_code(); -@define procedure set_sf_code(); - -@define function get_cat_code(); -@define procedure set_cat_code(); - -@define function valid_catcode_table (); -@define procedure clear_catcode_stack (); -@define procedure copy_cat_codes (); -@define procedure initex_cat_codes (); -@define procedure unsave_cat_codes (); -@define procedure unsave_text_codes (); -@define procedure initializetextcodes; -@define procedure free_text_codes; -@define procedure dumptextcodes; -@define procedure undumptextcodes; - -@define procedure dumpluacregisters; -@define procedure undumpluacregisters; - -@define function do_a_open_out(); -@define function do_b_open_out(); - -@define procedure flush_loggable_info; - -@define var extra_version_info; -@define procedure write_svnversion(); - -{ bits and pieces from aleph } - -@define procedure btestin ; - -@define function readtfmfile(); -@define function next_vf_byte; -@define function read_vf_file(); -@define function read_ocp_file(); -@define function read_data_file(); - -@define var ocp_tables; - -@define procedure allocate_ocp_table (); -@define procedure dump_ocp_table (); -@define procedure undump_ocp_table (); -@define procedure run_external_ocp (); - -@define function copy_font_info(); - -{ 'texfont' library definitions } - -@define procedure dump_font (); -@define procedure undump_font (); -@define function is_valid_font(); -@define function copy_font(); -@define function scale_font(); -@define function max_font_id; -@define procedure set_max_font_id(); - -@define function font_name(); -@define function font_area(); -@define function get_font_name(); -@define function get_font_area(); -@define function font_bc(); -@define function font_ec(); - -@define function tex_font_name(); -@define function tex_font_area(); -@define procedure set_tex_font_name(); - -@define procedure set_pdf_font_size(); -@define procedure set_pdf_font_num(); -@define procedure set_pdf_font_blink(); -@define procedure set_pdf_font_elink(); -@define procedure set_pdf_font_expand_ratio(); -@define procedure set_pdf_font_shrink(); -@define procedure set_pdf_font_stretch(); -@define procedure set_pdf_font_step(); -@define procedure set_pdf_font_auto_expand(); -@define procedure set_pdf_font_attr(); - -@define function pdf_font_size(); -@define function pdf_font_num(); -@define function pdf_font_blink(); -@define function pdf_font_elink(); -@define function pdf_font_expand_ratio(); -@define function pdf_font_shrink(); -@define function pdf_font_stretch(); -@define function pdf_font_step(); -@define function pdf_font_auto_expand(); -@define function pdf_font_attr(); - -@define function cmp_font_area(); -@define function cmp_font_name(); -@define function font_shareable(); - -@define function fontglue(); -@define procedure setfontglue(); - -@define function font_check_0(); -@define function font_check_1(); -@define function font_check_2(); -@define function font_check_3(); - -@define function font_size(); -@define function font_slant(); -@define function font_extend(); -@define function font_used(); -@define procedure set_font_used(); -@define function font_touched(); -@define procedure set_font_touched(); - -@define function font_dsize(); -@define function font_natural_dir(); - -@define function font_params(); -@define function font_param(); -@define procedure set_font_params(); -@define procedure set_font_param(); -@define function slant(); -@define function quad(); -@define function x_height(); -@define function space(); -@define function extra_space(); -@define function space_stretch(); -@define function space_shrink(); - -@define function font_kerns(); -@define function font_kern_sc(); -@define procedure adjust_font_kern(); - -@define function font_italics(); -@define function font_italic(); -@define procedure set_font_italic(); - -@define function has_lig(); -@define function has_kern(); - -@define type liginfo; - -@define function get_ligature(); -@define function is_valid_ligature(); -@define function lig_type(); -@define function lig_replacement(); - -@define function is_ligature(); -@define function is_leftboundary(); -@define function is_rightboundary(); - -@define procedure set_to_character(); -@define procedure set_to_glyph(); -@define procedure set_is_leftghost(); -@define procedure set_is_rightghost(); - -@define var non_boundarychar; - -@define function ext_top(); -@define function ext_mid(); -@define function ext_bot(); -@define function ext_rep(); - -@define var ext_tag; -@define var list_tag; - -@define var virtual_font_type; -@define function font_type(); - -@define function font_format(); -@define function char_index(); -@define function font_cidregistry(); -@define function font_encodingbytes(); - -@define function font_map(); -@define procedure set_font_map(); - - -@define function hyphen_char(); -@define function skew_char(); -@define procedure set_hyphen_char(); -@define procedure set_skew_char(); -@define function char_exists(); - -@define function char_used(); -@define function char_name(); -@define function char_width(); -@define function char_height(); -@define function char_depth(); -@define function char_italic(); -@define function char_tag(); -@define procedure set_char_tag(); -@define function char_remainder(); - -@define function char_info_short(); - -@define function has_packet(); -@define procedure do_vf_packet(); -@define function expand_font_name(); -@define function auto_expand_font(); -@define procedure vf_expand_local_fonts(); -@define function letter_space_font(); -@define function read_font_info(); - -@define function get_tag_code(); -@define function get_lp_code(); -@define function get_rp_code(); -@define function get_ef_code(); -@define procedure set_tag_code(); -@define procedure set_lp_code(); -@define procedure set_rp_code(); -@define procedure set_ef_code(); - -@define function test_no_ligatures(); -@define procedure set_no_ligatures(); - -@define function get_kern(); -@define function charkern(); - -{ functions from mapfile.c } -@define function hasfmentry(); -@define procedure checkextfm(); -@define procedure pdfmapfile(); -@define procedure pdfmapline(); -@define procedure pdf_init_map_file(); - -@define procedure writefontstuff; - -{functions from filename.c } -@define procedure pack_job_name(); -@define procedure prompt_file_name(); -@define procedure scan_file_name; -@define function make_name_string; -@define procedure print_file_name(); - -{ functions from utils/utils.c } -@define procedure escapehex(); -@define procedure escapename(); -@define procedure escapestring(); -@define function ext_xn_over_d(); -@define procedure getcreationdate; -@define function get_resname_prefix; -@define function makecstring(); - -@define procedure append_string(); -@define procedure matchstrings(); -@define procedure libpdffinish; -@define procedure makepdftexbanner; -@define procedure printcreationdate; -@define procedure printmoddate; -@define procedure print_ID(); -@define procedure set_job_id(); -@define procedure unescapehex(); -@define procedure write_stream_length(); -@define procedure removepdffile; -@define procedure garbagewarning; -@define function newcolorstack(); -@define function colorstackset(); -@define function colorstackpush(); -@define function colorstackpop(); -@define function colorstackcurrent(); -@define function colorstackused; -@define function colorstackskippagestart(); -@define procedure checkpdfsave(); -@define procedure checkpdfrestore(); -@define procedure pdfshipoutbegin(); -@define procedure pdfshipoutend(); -@define procedure pdfsetmatrix(); -@define procedure matrixtransformpoint(); -@define procedure matrixtransformrect(); -@define function matrixused; -@define procedure matrixrecalculate(); -@define function getllx; -@define function getlly; -@define function geturx; -@define function getury; - -{functions from pdf/pagetree.c } -@define function pdf_do_page_divert(); -@define procedure pdf_do_page_undivert(); -@define function output_pages_tree; - -{ functions from pdf/pdfpage.c } -@define procedure pdf_place_rule(); -@define procedure pdf_place_glyph(); -@define procedure pdf_place_form(); -@define procedure pdf_goto_pagemode; -@define procedure pdf_page_init; -@define procedure pdf_set_pos(); -@define procedure pdf_end_string_nl; -@define procedure pdf_print_charwidth(); - -{functions from texpdf.c } - -@define procedure pdf_print_char(); -@define procedure pdf_print(); -@define procedure pdf_print_int(); -@define procedure pdf_print_real(); -@define procedure pdf_print_str(); - -{functions from textoken.c } - -@define function get_next; -@define function scan_keyword(); -@define procedure scan_direction; -@define function active_to_cs(); - -{ functions from vfpacket.c } -@define function new_vf_packet(); -@define function packet_byte; -@define procedure start_packet(); -@define procedure store_packet(); - -{ functions from writefont.c } -@define procedure do_pdf_font(); - -{ functions from image/writeimg.c } -@define function check_image_b(); -@define function check_image_c(); -@define function check_image_i(); -@define function epdf_xsize(); -@define function epdf_ysize(); -@define function epdf_orig_x(); -@define function epdf_orig_y(); -@define function image_pages(); -@define function image_colordepth(); -@define function image_index(); -@define function image_width(); -@define function image_height(); -@define function image_depth(); -@define function image_objnum(); -@define function is_pdf_image(); -@define function is_png_image(); -@define function read_image(); -@define procedure update_image_procset(); -@define procedure write_image(); -@define procedure scale_image(); -@define procedure set_image_dimensions(); -@define procedure out_image(); - -@define procedure dumpimagemeta; -@define procedure undumpimagemeta(); - -{ functions from lua/limglib.c } - -{ functions from writet3.c } -@define function get_pk_char_width(); - -{ functions from writezip.c } -@define procedure write_zip(); - -{ functions from avlstuff.c } -@define procedure avl_put_obj(); -@define function avl_find_obj(); - -{ functions from tounicode.c } -@define procedure def_tounicode(); - -{ functions from luatex.web } -@define function auto_expand_vf(); - -{ end of luatex.defines } - -{texmf.defines} - -@define type two_halves; -@define type four_quarters; - -@define function input_ln (); -@define function is_new_source (); -@define function get_job_name (); -@define function make_full_name_string; - -@define procedure seconds_and_micros (); -@define function ocp_open_in (); -@define function kpse_in_name_ok (); -@define function kpse_out_name_ok (); - -@define function w_open_in (); -@define function w_open_out (); - -@define procedure dump_hh (); -@define procedure dump_int (); -@define procedure dump_things (); -@define procedure dump_wd (); - -@define procedure undump_hh (); -@define procedure undump_int (); -@define procedure undump_qqqq (); -@define procedure undump_things (); -@define procedure undump_checked_things (); -@define procedure undump_upper_check_things (); -@define procedure undump_wd (); -@define procedure w_close (); - -{common.defines} - -@define type memory_word; {for gftodvi, TeX, and Metafont} - -@define function a_open_in (); -@define procedure a_close (); -@define procedure b_close (); -@define function a_open_out (); -@define function b_open_out (); - -@define procedure write_dvi (); -@define procedure write_pdf (); -@define procedure write_ln (); - -@define procedure recorder_change_filename (); - -{ functions from the synctex controller in synctex.c } - -@define procedure synctex_init_command; -@define procedure synctex_start_input; -@define procedure synctex_terminate(); -@define procedure synctex_sheet(); -@define procedure synctex_teehs; -@define procedure synctex_vlist(); -@define procedure synctex_tsilv(); -@define procedure synctex_void_vlist(); -@define procedure synctex_hlist(); -@define procedure synctex_tsilh(); -@define procedure synctex_void_hlist(); -@define procedure synctex_math(); -@define procedure synctex_kern(); -@define procedure synctex_char(); -@define procedure synctex_node(); -@define procedure synctex_current; -@define procedure synctex_horizontal_rule_or_glue(); - -{math stuff} - -@define procedure initialize_math; -@define procedure show_math_node(); - -@define procedure scan_extdef_math_code(); -@define procedure scan_extdef_del_code(); - -@define function fam_fnt(); -@define procedure def_fam_fnt(); -@define procedure dump_math_data; -@define procedure undump_math_data; -@define procedure unsave_math_data(); - -@define const ord_noad_type; -@define const op_noad_type_normal; -@define const op_noad_type_limits; -@define const op_noad_type_no_limits; -@define const bin_noad_type; -@define const rel_noad_type; -@define const open_noad_type; -@define const close_noad_type; -@define const punct_noad_type; -@define const inner_noad_type; -@define const under_noad_type; -@define const over_noad_type; -@define const accent_noad; -@define const vcenter_noad; - -@define const left_noad_side ; -@define const middle_noad_side ; -@define const right_noad_side ; - -@define procedure finish_display_alignment(); -@define function new_sub_box(); -@define function math_vcenter_group(); -@define procedure close_math_group(); -@define procedure set_math_char(); -@define function new_style(); -@define const display_style; -@define const text_style; -@define const script_style; -@define const script_script_style; -@define const cramped_display_style; -@define const cramped_text_style; -@define const cramped_script_style; -@define const cramped_script_script_style; - -@define procedure def_math_param(); -@define procedure print_math_param(); -@define function get_math_param(); -@define procedure math_char_in_text(); - - -@define const math_param_quad; -@define const math_param_axis; -@define const math_param_operator_size; -@define const math_param_overbar_kern; -@define const math_param_overbar_rule; -@define const math_param_overbar_vgap; -@define const math_param_underbar_kern; -@define const math_param_underbar_rule; -@define const math_param_underbar_vgap; -@define const math_param_radical_kern; -@define const math_param_radical_rule; -@define const math_param_radical_vgap; -@define const math_param_radical_degree_before; -@define const math_param_radical_degree_after; -@define const math_param_radical_degree_raise; -@define const math_param_stack_vgap; -@define const math_param_stack_num_up; -@define const math_param_stack_denom_down; -@define const math_param_fraction_rule; -@define const math_param_fraction_num_vgap; -@define const math_param_fraction_num_up; -@define const math_param_fraction_denom_vgap; -@define const math_param_fraction_denom_down; -@define const math_param_fraction_del_size; -@define const math_param_limit_above_vgap; -@define const math_param_limit_above_bgap; -@define const math_param_limit_above_kern; -@define const math_param_limit_below_vgap; -@define const math_param_limit_below_bgap; -@define const math_param_limit_below_kern; -@define const math_param_under_delimiter_vgap; -@define const math_param_under_delimiter_bgap; -@define const math_param_over_delimiter_vgap; -@define const math_param_over_delimiter_bgap; -@define const math_param_sub_shift_drop; -@define const math_param_sup_shift_drop; -@define const math_param_sub_shift_down; -@define const math_param_sub_sup_shift_down; -@define const math_param_sub_top_max; -@define const math_param_sup_shift_up; -@define const math_param_sup_bottom_min; -@define const math_param_sup_sub_bottom_max; -@define const math_param_subsup_vgap; -@define const math_param_space_after_script; -@define const math_param_connector_overlap_min; -@define const math_param_first_mu_glue; -@define const math_param_ord_ord_spacing; -@define const math_param_ord_op_spacing; -@define const math_param_ord_bin_spacing; -@define const math_param_ord_rel_spacing; -@define const math_param_ord_open_spacing; -@define const math_param_ord_close_spacing; -@define const math_param_ord_punct_spacing; -@define const math_param_ord_inner_spacing; -@define const math_param_op_ord_spacing; -@define const math_param_op_op_spacing; -@define const math_param_op_bin_spacing; -@define const math_param_op_rel_spacing; -@define const math_param_op_open_spacing; -@define const math_param_op_close_spacing; -@define const math_param_op_punct_spacing; -@define const math_param_op_inner_spacing; -@define const math_param_bin_ord_spacing; -@define const math_param_bin_op_spacing; -@define const math_param_bin_bin_spacing; -@define const math_param_bin_rel_spacing; -@define const math_param_bin_open_spacing; -@define const math_param_bin_close_spacing; -@define const math_param_bin_punct_spacing; -@define const math_param_bin_inner_spacing; -@define const math_param_rel_ord_spacing; -@define const math_param_rel_op_spacing; -@define const math_param_rel_bin_spacing; -@define const math_param_rel_rel_spacing; -@define const math_param_rel_open_spacing; -@define const math_param_rel_close_spacing; -@define const math_param_rel_punct_spacing; -@define const math_param_rel_inner_spacing; -@define const math_param_open_ord_spacing; -@define const math_param_open_op_spacing; -@define const math_param_open_bin_spacing; -@define const math_param_open_rel_spacing; -@define const math_param_open_open_spacing; -@define const math_param_open_close_spacing; -@define const math_param_open_punct_spacing; -@define const math_param_open_inner_spacing; -@define const math_param_close_ord_spacing; -@define const math_param_close_op_spacing; -@define const math_param_close_bin_spacing; -@define const math_param_close_rel_spacing; -@define const math_param_close_open_spacing; -@define const math_param_close_close_spacing; -@define const math_param_close_punct_spacing; -@define const math_param_close_inner_spacing; -@define const math_param_punct_ord_spacing; -@define const math_param_punct_op_spacing; -@define const math_param_punct_bin_spacing; -@define const math_param_punct_rel_spacing; -@define const math_param_punct_open_spacing; -@define const math_param_punct_close_spacing; -@define const math_param_punct_punct_spacing; -@define const math_param_punct_inner_spacing; -@define const math_param_inner_ord_spacing; -@define const math_param_inner_op_spacing; -@define const math_param_inner_bin_spacing; -@define const math_param_inner_rel_spacing; -@define const math_param_inner_open_spacing; -@define const math_param_inner_close_spacing; -@define const math_param_inner_punct_spacing; -@define const math_param_inner_inner_spacing; - - -@define const hlist_node; -@define const vlist_node; -@define const rule_node; -@define const ins_node; -@define const mark_node; -@define const adjust_node; -@define const disc_node; -@define const whatsit_node; -@define const math_node; -@define const glue_node; -@define const kern_node; -@define const penalty_node; -@define const unset_node; -@define const margin_kern_node; -@define const glyph_node; -@define const align_record_node; -@define const inserting_node; -@define const split_up_node; -@define const expr_node; -@define const span_node; -@define const action_node; -@define const glue_spec_node; -@define const temp_node; -@define const align_stack_node; -@define const movement_node; -@define const if_node; -@define const shape_node; - -@define const write_node_size; -@define const open_node_size; - -@define procedure print_short_node_contents(); -@define procedure show_node_list(); - -@define const zero_glue ; -@define const sfi_glue ; -@define const fil_glue ; -@define const fill_glue ; -@define const ss_glue ; -@define const fil_neg_glue ; -@define const page_ins_head ; -@define const contrib_head ; -@define const page_head ; -@define const temp_head ; -@define const hold_head ; -@define const adjust_head ; -@define const pre_adjust_head ; -@define const align_head ; -@define const end_span ; - - -@define const tex_command; -@define const etex_command; -@define const aleph_command; -@define const pdftex_command; -@define const luatex_command; - -@define procedure primitive_tex(); -@define procedure primitive_etex(); -@define procedure primitive_aleph(); -@define procedure primitive_omega(); -@define procedure primitive_pdftex(); -@define procedure primitive_luatex(); -@define procedure primitive_core(); -@define procedure print_cmd_chr(); - -@define procedure init_primitives; -@define procedure ini_init_primitives; -@define procedure dump_primitives; -@define procedure undump_primitives; -@define function compute_pool_hash(); - -@define const undefined_primitive; -@define const hash_prime; - -@define function get_prim_eq_type(); -@define function get_prim_equiv(); -@define function prim_lookup(); -@define function id_lookup(); - -@define procedure tex_def_font(); diff --git a/Build/source/texk/web2c/luatexdir/luatex.h b/Build/source/texk/web2c/luatexdir/luatex.h index 0d2d84eb8da..69ed3fe157c 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.h +++ b/Build/source/texk/web2c/luatexdir/luatex.h @@ -20,61 +20,106 @@ /* $Id$ */ - -extern void do_vf(internal_font_number tmp_f); - -extern int readbinfile(FILE * f, unsigned char **b, integer * s); - -#define read_tfm_file readbinfile -#define read_vf_file readbinfile -#define read_ocp_file readbinfile -#define read_data_file readbinfile - -extern int **ocp_tables; - -extern void allocate_ocp_table(int ocp_number, int ocp_size); -extern void dump_ocp_table(int ocp_number); -extern void undump_ocp_table(int ocp_number); - -extern void run_external_ocp(string external_ocp_name); -extern void b_test_in(void); - -/* Additions to texmfmp.h for pdfTeX */ - -/* mark a char in font */ -#define pdf_mark_char(f,c) set_char_used(f,c,true) - -/* test whether a char in font is marked */ -#define pdf_char_marked char_used - -/* writepdf() always writes by fwrite() */ -#define write_pdf(a, b) \ - (void) fwrite ((char *) &pdf_buf[a], sizeof (pdf_buf[a]), \ - (int) ((b) - (a) + 1), pdf_file) - -#define tex_b_open_in(f) \ - open_input (&(f), kpse_tex_format, FOPEN_RBIN_MODE) -#define ovf_b_open_in(f) \ - open_input (&(f), kpse_ovf_format, FOPEN_RBIN_MODE) -#define vf_b_open_in(f) \ - open_input (&(f), kpse_vf_format, FOPEN_RBIN_MODE) - -extern int open_outfile(FILE ** f, const char *name, const char *mode); - -#define do_a_open_out(f) open_outfile(&(f),(const char *)(nameoffile+1),FOPEN_W_MODE) -#define do_b_open_out(f) open_outfile(&(f),(const char *)(nameoffile+1),FOPEN_WBIN_MODE) - -#define pdfassert assert -#define voidcast(a) (void *)(a) -#define varmemcast(a) (memory_word *)(a) -#define fixmemcast(a) (smemory_word *)(a) -extern volatile memory_word *varmem; -extern halfword var_mem_min; -extern halfword var_mem_max; -extern halfword get_node(integer s); -extern void free_node(halfword p, integer s); -extern void init_node_mem(integer s); -extern void dump_node_mem(void); -extern void undump_node_mem(void); - -#include +#ifndef LUATEX_H +# define LUATEX_H + +/* texmf.h: Main include file for TeX and Metafont in C. This file is + included by {tex,mf}d.h, which is the first include in the C files + output by web2c. */ + +# include "cpascal.h" + +# include /* for IS_DIR_SEP, used in the change files */ +# include /* for kpse_make_tex_discard_errors */ + +/* If we have these macros, use them, as they provide a better guide to + the endianess when cross-compiling. */ +# if defined (BYTE_ORDER) && defined (BIG_ENDIAN) && defined (LITTLE_ENDIAN) +# ifdef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +# if BYTE_ORDER == BIG_ENDIAN +# define WORDS_BIGENDIAN +# endif +# endif +/* More of the same, but now NeXT-specific. */ +# ifdef NeXT +# ifdef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +# ifdef __BIG_ENDIAN__ +# define WORDS_BIGENDIAN +# endif +# endif + + +/* Some things are the same except for the name. */ + +# define TEXMFPOOLNAME "luatex.pool" +# define TEXMFENGINENAME "luatex" + +# define DUMP_FILE fmt_file +# define DUMP_FORMAT kpse_fmt_format +# define write_dvi WRITE_OUT +# define flush_dvi flush_out +# define OUT_FILE dvi_file +# define OUT_BUF dvi_buf + +/* Restore underscores. */ +# define kpsetexformat kpse_tex_format +# define mainbody main_body +# define t_open_in topenin + +/* Executing shell commands. */ +extern void mk_shellcmdlist(char *); +extern void init_shell_escape(void); +extern int shell_cmd_is_allowed(const char **cmd, char **safecmd, + char **cmdname); +extern int runsystem(char *cmd); + +# ifndef GLUERATIO_TYPE +# define GLUERATIO_TYPE double +# endif +typedef GLUERATIO_TYPE glueratio; + +# if defined(__DJGPP__) && defined (IPC) +# undef IPC +# endif + +# ifdef IPC +extern void ipcpage(int); +# endif /* IPC */ + + +/* How to output to the GF or DVI file. */ +# define WRITE_OUT(a, b) \ + if (fwrite ((char *) &OUT_BUF[a], sizeof (OUT_BUF[a]), \ + (int) ((b) - (a) + 1), OUT_FILE) \ + != (int) ((b) - (a) + 1)) \ + FATAL_PERROR ("fwrite"); + +# define flush_out() fflush (OUT_FILE) + +/* Read a line of input as quickly as possible. */ +# define input_ln(stream, flag) input_line (stream) + +extern boolean input_line(FILE *); + +# include + +# define COPYRIGHT_HOLDER "Taco Hoekwater" +# define AUTHOR NULL +# define PROGRAM_HELP LUATEXHELP +# define BUG_ADDRESS "dev-luatex@ntg.nl" +# define DUMP_OPTION "fmt" +# define DUMP_EXT ".fmt" +# define INPUT_FORMAT kpse_tex_format +# define INI_PROGRAM "luainitex" +# define VIR_PROGRAM "luavirtex" +# define TEXMFENGINENAME "luatex" + +/* this counteracts the macro definition in cpascal.h */ +# undef Xchr +# define Xchr(a) a + +#endif diff --git a/Build/source/texk/web2c/luatexdir/luatex.mk b/Build/source/texk/web2c/luatexdir/luatex.mk deleted file mode 100644 index 6a0a5d6386d..00000000000 --- a/Build/source/texk/web2c/luatexdir/luatex.mk +++ /dev/null @@ -1,158 +0,0 @@ -# Makefile fragment for pdfeTeX and web2c. --infovore@xs4all.nl. Public domain. -# This fragment contains the parts of the makefile that are most likely to -# differ between releases of luatex -# $Id$ - -# We build luatex -luatex = @LTEX@ luatex -luatexdir = luatexdir - -# libz -ZLIBDIR=../../libs/zlib -ZLIBSRCDIR=$(srcdir)/$(ZLIBDIR) -# libpng -LIBPNGDIR=../../libs/libpng -LIBPNGSRCDIR=$(srcdir)/$(LIBPNGDIR) -# libxpdf -LIBXPDFDIR=../../libs/xpdf -LIBXPDFSRCDIR=$(srcdir)/$(LIBXPDFDIR) -# libobsdcompa -LIBOBSDCOMPATDIR=../../libs/obsdcompat -LIBOBSDCOMPATFSRCDIR=$(srcdir)/$(LIBOBSDCOMPATDIR) - -SVN_REV := $(shell $(srcdir)/$(luatexdir)/get_svnversion.sh $(srcdir)) - -XCPPFLAGS=-I$(LIBOBSDCOMPATDIR) -I$(LIBOBSDCOMPATDIR)/.. -I$(LIBOBSDCOMPATFSRCDIR) -I$(LIBOBSDCOMPATFSRCDIR)/.. -I$(ZLIBSRCDIR) -I$(LIBPNGSRCDIR) -I$(LIBXPDFSRCDIR) -Dextra_version_info=`date +-%Y%m%d%H` -DSVN_REV=\"$(SVN_REV)\" - -Makefile: $(srcdir)/$(luatexdir)/luatex.mk - -luatex_bin = luatex -linux_build_dir = $(HOME)/luatex/build/linux/texk/web2c - - -# Extract luatex version -$(luatexdir)/luatex.version: $(srcdir)/$(luatexdir)/luatex.web - test -d $(luatexdir) || mkdir $(luatexdir) - grep '^@d luatex_version_string==' $(srcdir)/$(luatexdir)/luatex.web \ - | sed "s/^.*=='//;s/' .*$$//" \ - >$(luatexdir)/luatex.version - -# The C sources. -luatex_c = luatexini.c luatex0.c -luatex_o = luatexini.o luatex0.o luatexextra.o luatex-pool.o $(luatex_o-with_synctex) - -# Making luatex -luatex: luatexd.h $(luatex_o) $(luatexextra_o) $(luatexlibsdep) - @CXXHACKLINK@ $(luatex_o) $(luatexextra_o) $(luatexlibs) $(socketlibs) @SOCKETHACK@ @CXXHACKLDLIBS@ @CXXLDEXTRA@ - -# C file dependencies. -$(luatex_c) luatexcoerce.h luatexd.h: luatex.p $(web2c_texmf) $(srcdir)/$(luatexdir)/luatex.defines $(srcdir)/$(luatexdir)/luatex.h - $(web2c) luatex -# $(luatexd.h-with_synctex) -luatexextra.c: luatexd.h $(luatexdir)/luatexextra.h lib/texmfmp.c - test -d $(luatexdir) || mkdir $(luatexdir) - sed s/TEX-OR-MF-OR-MP/luatex/ $(srcdir)/lib/texmfmp.c >$@ -$(luatexdir)/luatexextra.h: $(luatexdir)/luatexextra.in $(luatexdir)/luatex.version - test -d $(luatexdir) || mkdir $(luatexdir) - sed -e s/LUATEX-VERSION/`cat $(luatexdir)/luatex.version`/ \ - $(srcdir)/$(luatexdir)/luatexextra.in >$@ -luatex-pool.c: luatex.pool - $(makecpool) luatex.pool luatexdir/ptexlib.h >$@ || rm -f $@ - -# luatangle we need a private version of tangle - -luatangle: luatangle.o - $(kpathsea_link) luatangle.o $(LOADLIBES) - -luatangle.c luatangle.h: luatangle.p - $(web2c) luatangle - -luatangle.p: tangle $(srcdir)/$(luatexdir)/luatangle.web $(srcdir)/$(luatexdir)/luatangle.ch - $(TANGLE) $(srcdir)/$(luatexdir)/luatangle.web $(srcdir)/$(luatexdir)/luatangle.ch - -# Tangling -luatex.p luatex.pool: luatangle $(srcdir)/$(luatexdir)/luatex.web $(srcdir)/$(luatexdir)/luatex.ch - $(native)/luatangle --underlines $(srcdir)/$(luatexdir)/luatex.web $(srcdir)/$(luatexdir)/luatex.ch - -# Sources for luatex.ch: -#luatex_ch_srcs = $(srcdir)/$(luatexdir)/luatex.web \ -# $(srcdir)/$(luatexdir)/lua.ch \ -# $(srcdir)/$(luatexdir)/lua.ch0 - -# Rules: -#luatex.ch: $(TIE) $(luatex_ch_srcs) -# $(TIE) -c luatex.ch $(luatex_ch_srcs) - -# for developing only -#luatex-org.web: $(TIE) $(luatex_ch_srcs_org) -# $(TIE) -m $@ $(luatex_ch_srcs_org) -luatex-all.web: $(TIE) $(srcdir)/$(luatexdir)/luatex.web $(srcdir)/$(luatexdir)/luatex.ch - $(TIE) -m $@ $(srcdir)/$(luatexdir)/luatex.web $(srcdir)/$(luatexdir)/luatex.ch -#luatex-all.tex: luatex-all.web -# $(WEAVE) luatex-all.web -# echo -e '1s/ webmac/ pdfwebmac/\nw\nq' | ed $@ >/dev/null 2>&1 -#luatex-all.pdf: luatex-all.tex -# $(luatex) luatex-all.tex - -check: @LTEX@ luatex-check -luatex-check: luatex luatex.fmt - -clean:: luatex-clean -luatex-clean: - $(LIBTOOL) --mode=clean $(RM) luatex - rm -f $(luatex_o) $(luatex_c) luatexextra.c luatexcoerce.h - rm -f $(luatexdir)/luatexextra.h - rm -f luatexd.h luatex.p luatex.pool luatex.ch strpool.c - rm -f luatex.fmt luatex.log - -# Dumps -all_luafmts = @FMU@ luatex.fmt $(luafmts) - -dumps: @LTEX@ luafmts -luafmts: $(all_luafmts) - -luafmtdir = $(web2cdir)/luatex -$(luafmtdir):: - $(SHELL) $(top_srcdir)/../mkinstalldirs $(luafmtdir) - -luatex.fmt: luatex - $(dumpenv) $(MAKE) progname=luatex files="etex.src plain.tex cmr10.tfm" prereq-check - $(dumpenv) ./luatex --progname=luatex --jobname=luatex --ini \*\\pdfoutput=1\\input etex.src \\dump -% Copyright 2006-2009 Hartmut Henkel -% -% This file is part of LuaTeX. -% -% LuaTeX is free software; you can redistribute it and/or modify it under -% the terms of the GNU General Public License as published by the Free -% Software Foundation; either version 2 of the License, or (at your -% option) any later version. -% -% LuaTeX is distributed in the hope that it will be useful, but WITHOUT -% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -% License for more details. -% -% You should have received a copy of the GNU General Public License along -% with LuaTeX; if not, see . -% -% $Id$ - -% pdfTeX is copyright (C) 1996-2006 Han The Thanh, . -% e-TeX is copyright (C) 1994,98 by Peter Breitenlohner. - -% This program is directly derived from Donald E. Knuth's TeX; -% the change history which follows and the reward offered for finders of -% bugs refer specifically to TeX; they should not be taken as referring -% to e-TeX, although the change history is relevant in that it -% demonstrates the evolutionary path followed. This program is not TeX; -% that name is reserved strictly for the program which is the creation -% and sole responsibility of Professor Knuth. - -% Version 0 was released in September 1982 after it passed a variety of tests. -% Version 1 was released in November 1983 after thorough testing. -% Version 1.1 fixed ``disappearing font identifiers'' et alia (July 1984). -% Version 1.2 allowed `0' in response to an error, et alia (October 1984). -% Version 1.3 made memory allocation more flexible and local (November 1984). -% Version 1.4 fixed accents right after line breaks, et alia (April 1985). -% Version 1.5 fixed \the\toks after other expansion in \edefs (August 1985). -% Version 2.0 (almost identical to 1.5) corresponds to "Volume B" (April 1986). -% Version 2.1 corrected anomalies in discretionary breaks (January 1987). -% Version 2.2 corrected "(Please type...)" with null \endlinechar (April 1987). -% Version 2.3 avoided incomplete page in premature termination (August 1987). -% Version 2.4 fixed \noaligned rules in indented displays (August 1987). -% Version 2.5 saved cur_order when expanding tokens (September 1987). -% Version 2.6 added 10sp slop when shipping leaders (November 1987). -% Version 2.7 improved rounding of negative-width characters (November 1987). -% Version 2.8 fixed weird bug if no \patterns are used (December 1987). -% Version 2.9 made \csname\endcsname's "relax" local (December 1987). -% Version 2.91 fixed \outer\def\a0{}\a\a bug (April 1988). -% Version 2.92 fixed \patterns, also file names with complex macros (May 1988). -% Version 2.93 fixed negative halving in allocator when mem_min<0 (June 1988). -% Version 2.94 kept open_log_file from calling fatal_error (November 1988). -% Version 2.95 solved that problem a better way (December 1988). -% Version 2.96 corrected bug in "Infinite shrinkage" recovery (January 1989). -% Version 2.97 corrected blunder in creating 2.95 (February 1989). -% Version 2.98 omitted save_for_after at outer level (March 1989). -% Version 2.99 caught $$\begingroup\halign..$$ (June 1989). -% Version 2.991 caught .5\ifdim.6... (June 1989). -% Version 2.992 introduced major changes for 8-bit extensions (September 1989). -% Version 2.993 fixed a save_stack synchronization bug et alia (December 1989). -% Version 3.0 fixed unusual displays; was more \output robust (March 1990). -% Version 3.1 fixed nullfont, disabled \write{\the\prevgraf} (September 1990). -% Version 3.14 fixed unprintable font names and corrected typos (March 1991). -% Version 3.141 more of same; reconstituted ligatures better (March 1992). -% Version 3.1415 preserved nonexplicit kerns, tidied up (February 1993). -% Version 3.14159 allowed fontmemsize to change; bulletproofing (March 1995). -% Version 3.141592 fixed \xleaders, glueset, weird alignments (December 2002). -% Version 3.1415926 was a general cleanup with minor fixes (February 2008). - - -% Although considerable effort has been expended to make the LuaTeX program -% correct and reliable, no warranty is implied; the authors disclaim any -% obligation or liability for damages, including but not limited to -% special, indirect, or consequential damages arising out of or in -% connection with the use or performance of this software. This work has -% been a ``labor of love'' and the authors hope that users enjoy it. - -% Here is TeX material that gets inserted after \input webmac -\def\hang{\hangindent 3em\noindent\ignorespaces} -\def\hangg#1 {\hang\hbox{#1 }} -\def\textindent#1{\hangindent2.5em\noindent\hbox to2.5em{\hss#1 }\ignorespaces} -\font\ninerm=cmr9 -\let\mc=\ninerm % medium caps for names like SAIL -\def\PASCAL{Pascal} -\def\pdfTeX{pdf\TeX} -\def\pdfeTeX{pdf\eTeX} -\def\PDF{PDF} -\def\Aleph{Aleph} -\def\eTeX{e\TeX} -\def\LuaTeX{Lua\TeX} -\def\THANH{H\`an Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh} -\def\ph{\hbox{Pascal-H}} -\def\pct!{{\char`\%}} % percent sign in ordinary text -\def\grp{\.{\char'173...\char'175}} -\font\logo=logo10 % font used for the METAFONT logo -\def\MF{{\logo META}\-{\logo FONT}} -\def\<#1>{$\langle#1\rangle$} -\def\section{\mathhexbox278} - -\def\(#1){} % this is used to make section names sort themselves better -\def\9#1{} % this is used for sort keys in the index via @@:sort key}{entry@@> - -\outer\def\N#1. \[#2]#3.{\MN#1.\vfil\eject % begin starred section - \def\rhead{PART #2:\uppercase{#3}} % define running headline - \message{*\modno} % progress report - \edef\next{\write\cont{\Z{\?#2]#3}{\modno}{\the\pageno}}}\next - \ifon\startsection{\bf\ignorespaces#3.\quad}\ignorespaces} -\let\?=\relax % we want to be able to \write a \? - -\def\title{LuaTeX} -\let\maybe=\iffalse % print only changed modules -\def\topofcontents{\hsize 5.5in - \vglue 0pt plus 1fil minus 1.5in - \def\?##1]{\hbox to 1in{\hfil##1.\ }} - } -\def\botofcontents{\vskip 0pt plus 1fil minus 1.5in} -\pageno=3 -\def\glob{13} % this should be the section number of "" -\def\gglob{20, 26} % this should be the next two sections of "" - -@* \[1] Introduction. - -This is LuaTeX, a continuation of $\pdfTeX$ and $\Aleph$. LuaTeX is a -document compiler intended to simplify high-quality typesetting for -many of the world's languages. It is an extension of D. E. Knuth's -\TeX, which was designed essentially for the typesetting of languages -using the Latin alphabet. - -The $\Aleph$ subsystem loosens many of the restrictions imposed by~\TeX: -register numbers are no longer limited to 8~bits; fonts may have more -than 256~characters; more than 256~fonts may be used; etc. - -The \PASCAL\ program that follows is the definition of \TeX82, a standard -@:PASCAL}{\PASCAL@> -@!@:TeX82}{\TeX82@> -version of \TeX\ that is designed to be highly portable so that -identical output will be obtainable on a great variety of computers. - -The main purpose of the following program is to explain the algorithms of \TeX\ -as clearly as possible. As a result, the program will not necessarily be very -efficient when a particular \PASCAL\ compiler has translated it into a -particular machine language. However, the program has been written so that it -can be tuned to run efficiently in a wide variety of operating environments -by making comparatively few changes. Such flexibility is possible because -the documentation that follows is written in the \.{WEB} language, which is -at a higher level than \PASCAL; the preprocessing step that converts \.{WEB} -to \PASCAL\ is able to introduce most of the necessary refinements. -Semi-automatic translation to other languages is also feasible, because the -program below does not make extensive use of features that are peculiar to -\PASCAL. - -A large piece of software like \TeX\ has inherent complexity that cannot -be reduced below a certain level of difficulty, although each individual -part is fairly simple by itself. The \.{WEB} language is intended to make -the algorithms as readable as possible, by reflecting the way the -individual program pieces fit together and by providing the -cross-references that connect different parts. Detailed comments about -what is going on, and about why things were done in certain ways, have -been liberally sprinkled throughout the program. These comments explain -features of the implementation, but they rarely attempt to explain the -\TeX\ language itself, since the reader is supposed to be familiar with -{\sl The \TeX book}. -@.WEB@> -@:TeXbook}{\sl The \TeX book@> - -@ The present implementation has a long ancestry, beginning in the summer -of~1977, when Michael~F. Plass and Frank~M. Liang designed and coded -a prototype -@^Plass, Michael Frederick@> -@^Liang, Franklin Mark@> -@^Knuth, Donald Ervin@> -based on some specifications that the author had made in May of that year. -This original proto\TeX\ included macro definitions and elementary -manipulations on boxes and glue, but it did not have line-breaking, -page-breaking, mathematical formulas, alignment routines, error recovery, -or the present semantic nest; furthermore, -it used character lists instead of token lists, so that a control sequence -like \.{\\halign} was represented by a list of seven characters. A -complete version of \TeX\ was designed and coded by the author in late -1977 and early 1978; that program, like its prototype, was written in the -{\mc SAIL} language, for which an excellent debugging system was -available. Preliminary plans to convert the {\mc SAIL} code into a form -somewhat like the present ``web'' were developed by Luis Trabb~Pardo and -@^Trabb Pardo, Luis Isidoro@> -the author at the beginning of 1979, and a complete implementation was -created by Ignacio~A. Zabala in 1979 and 1980. The \TeX82 program, which -@^Zabala Salelles, Ignacio Andr\'es@> -was written by the author during the latter part of 1981 and the early -part of 1982, also incorporates ideas from the 1979 implementation of -@^Guibas, Leonidas Ioannis@> -@^Sedgewick, Robert@> -@^Wyatt, Douglas Kirk@> -\TeX\ in {\mc MESA} that was written by Leonidas Guibas, Robert Sedgewick, -and Douglas Wyatt at the Xerox Palo Alto Research Center. Several hundred -refinements were introduced into \TeX82 based on the experiences gained with -the original implementations, so that essentially every part of the system -has been substantially improved. After the appearance of ``Version 0'' in -September 1982, this program benefited greatly from the comments of -many other people, notably David~R. Fuchs and Howard~W. Trickey. -A final revision in September 1989 extended the input character set to -eight-bit codes and introduced the ability to hyphenate words from -different languages, based on some ideas of Michael~J. Ferguson. -@^Fuchs, David Raymond@> -@^Trickey, Howard Wellington@> -@^Ferguson, Michael John@> - -No doubt there still is plenty of room for improvement, but the author -is firmly committed to keeping \TeX82 ``frozen'' from now on; stability -and reliability are to be its main virtues. - -On the other hand, the \.{WEB} description can be extended without changing -the core of \TeX82 itself, and the program has been designed so that such -extensions are not extremely difficult to make. -The |banner| string defined here should be changed whenever \TeX\ -undergoes any modifications, so that it will be clear which version of -\TeX\ might be the guilty party when a problem arises. -@^extensions to \TeX@> -@^system dependencies@> - -This program contains code for various features extending \TeX, -therefore this program is called `\eTeX' and not -`\TeX'; the official name `\TeX' by itself is reserved -for software systems that are fully compatible with each other. -A special test suite called the ``\.{TRIP} test'' is available for -helping to determine whether a particular implementation deserves to be -known as `\TeX' [cf.~Stanford Computer Science report CS1027, -November 1984]. - -A similar test suite called the ``\.{e-TRIP} test'' is available for -helping to determine whether a particular implementation deserves to be -known as `\eTeX'. - -@d eTeX_version_string=="2.2" {current \eTeX\ version} -@d Omega_version_string=="1.15" { \.{\\OmegaVersion} } -@d Aleph_version_string=="0.0" { \.{\\AlephVersion} } -@d eTeX_version=2 { \.{\\eTeXversion} } -@d Omega_version=1 { \.{\\Omegaversion} } -@d Aleph_version=0 { \.{\\Alephversion} } -@d eTeX_minor_version=1 { \.{\\eTeXminorversion} } -@d Omega_minor_version=15 { \.{\\Omegaminorversion} } -@d Aleph_minor_version=0 { \.{\\Alephminorversion} } -@d eTeX_revision==".2" { \.{\\eTeXrevision} } -@d Omega_revision==".15" { \.{\\Omegarevision} } -@d Aleph_revision==".0" { \.{\\Alephrevision} } -@# -@d pdftex_version==200 { \.{\\pdftexversion} } -@d pdftex_revision=="0" { \.{\\pdftexrevision} } -@d pdftex_version_string=='-2.00.0' {current \pdfTeX\ version} -@# -@d luatex_version==40 { \.{\\luatexversion} } -@d luatex_revision=="6" { \.{\\luatexrevision} } -@d luatex_version_string=='beta-0.40.6' {current \LuaTeX\ version} -@d luatex_date_info==-extra_version_info { the compile date is negated } -@d luatex_svnversion=='$Id$' - {for long --version information, as proposed by Peter M\"unster} -@# -@d LuaTeX_banner=='This is LuaTeX, Version ',luatex_version_string,extra_version_info - {printed when \LuaTeX\ starts} -@# -@d banner==LuaTeX_banner -@# -@d TEX==ETEX {change program name into |ETEX|} - -@ Different \PASCAL s have slightly different conventions, and the present -@!@:PASCAL H}{\ph@> -program expresses \TeX\ in terms of the \PASCAL\ that was -available to the author in 1982. Constructions that apply to -this particular compiler, which we shall call \ph, should help the -reader see how to make an appropriate interface for other systems -if necessary. (\ph\ is Charles Hedrick's modification of a compiler -@^Hedrick, Charles Locke@> -for the DECsystem-10 that was originally developed at the University of -Hamburg; cf.\ {\sl SOFTWARE---Practice \AM\ Experience \bf6} (1976), -29--42. The \TeX\ program below is intended to be adaptable, without -extensive changes, to most other versions of \PASCAL, so it does not fully -use the admirable features of \ph. Indeed, a conscious effort has been -made here to avoid using several idiosyncratic features of standard -\PASCAL\ itself, so that most of the code can be translated mechanically -into other high-level languages. For example, the `\&{with}' and `\\{new}' -features are not used, nor are pointer types, set types, or enumerated -scalar types; there are no `\&{var}' parameters, except in the case of files ---- \eTeX, however, does use `\&{var}' parameters for the |reverse| function; -there are no tag fields on variant records; there are no assignments -|real:=integer|; no procedures are declared local to other procedures.) - -The portions of this program that involve system-dependent code, where -changes might be necessary because of differences between \PASCAL\ compilers -and/or differences between -operating systems, can be identified by looking at the sections whose -numbers are listed under `system dependencies' in the index. Furthermore, -the index entries for `dirty \PASCAL' list all places where the restrictions -of \PASCAL\ have not been followed perfectly, for one reason or another. -@!@^system dependencies@> -@!@^dirty \PASCAL@> - -Incidentally, \PASCAL's standard |round| function can be problematical, -because it disagrees with the IEEE floating-point standard. -Many implementors have -therefore chosen to substitute their own home-grown rounding procedure. - -@ The program begins with a normal \PASCAL\ program heading, whose -components will be filled in later, using the conventions of \.{WEB}. -@.WEB@> -For example, the portion of the program called `\X\glob:Global -variables\X' below will be replaced by a sequence of variable declarations -that starts in $\section\glob$ of this documentation. In this way, we are able -to define each individual global variable when we are prepared to -understand what it means; we do not have to define all of the globals at -once. Cross references in $\section\glob$, where it says ``See also -sections \gglob, \dots,'' also make it possible to look at the set of -all global variables, if desired. Similar remarks apply to the other -portions of the program heading. - -Actually the heading shown here is not quite normal: The |program| line -does not mention any |output| file, because \ph\ would ask the \TeX\ user -to specify a file name if |output| were specified here. -@:PASCAL H}{\ph@> -@^system dependencies@> - -@d mtype==t@&y@&p@&e {this is a \.{WEB} coding trick:} -@f mtype==type {`\&{mtype}' will be equivalent to `\&{type}'} -@f type==true {but `|type|' will not be treated as a reserved word} - -@p @t\4@>@@/ -program TEX; {all file names are defined dynamically} -label @@/ -const @@/ -mtype @@/ -var @@/ -@# -procedure initialize; {this procedure gets things started properly} - var @@/ - begin @@; - end;@# -@t\4@>@@/ -@t\4@>@@/ - -@ Here is a workaround for the unfortunate limitation of WEB2C that -doesn't know how to deal with symbolic case labels. - -@d hlist_node_case==0 -@d vlist_node_case==1 -@d rule_node_case==2 -@d ins_node_case==3 -@d mark_node_case==4 -@d adjust_node_case==5 -@d disc_node_case==7 -@d whatsit_node_case==8 -@d math_node_case==9 -@d glue_node_case==10 -@d kern_node_case==11 -@d penalty_node_case==12 -@d unset_node_case==13 -@d margin_kern_node_case==36 - -@= -pdfassert(hlist_node_case=hlist_node); -pdfassert(vlist_node_case=vlist_node); -pdfassert(rule_node_case=rule_node); -pdfassert(ins_node_case=ins_node); -pdfassert(mark_node_case=mark_node); -pdfassert(adjust_node_case=adjust_node); -pdfassert(disc_node_case=disc_node); -pdfassert(whatsit_node_case=whatsit_node); -pdfassert(math_node_case=math_node); -pdfassert(glue_node_case=glue_node); -pdfassert(kern_node_case=kern_node); -pdfassert(penalty_node_case=penalty_node); -pdfassert(unset_node_case=unset_node); -pdfassert(margin_kern_node_case=margin_kern_node); - - - - - -@ The overall \TeX\ program begins with the heading just shown, after which -comes a bunch of procedure declarations and function declarations. -Finally we will get to the main program, which begins with the -comment `|start_here|'. If you want to skip down to the -main program now, you can look up `|start_here|' in the index. -But the author suggests that the best way to understand this program -is to follow pretty much the order of \TeX's components as they appear in the -\.{WEB} description you are now reading, since the present ordering is -intended to combine the advantages of the ``bottom up'' and ``top down'' -approaches to the problem of understanding a somewhat complicated system. - -@ Three labels must be declared in the main program, so we give them -symbolic names. - -@d start_of_TEX=1 {go here when \TeX's variables are initialized} -@d end_of_TEX=9998 {go here to close files and terminate gracefully} -@d final_end=9999 {this label marks the ending of the program} - -@= -start_of_TEX@t\hskip-2pt@>, end_of_TEX@t\hskip-2pt@>,@,final_end; - {key control points} - -@ Some of the code below is intended to be used only when diagnosing the -strange behavior that sometimes occurs when \TeX\ is being installed or -when system wizards are fooling around with \TeX\ without quite knowing -what they are doing. Such code will not normally be compiled; it is -delimited by the codewords `$|debug|\ldots|gubed|$', with apologies -to people who wish to preserve the purity of English. - -Similarly, there is some conditional code delimited by -`$|stat|\ldots|tats|$' that is intended for use when statistics are to be -kept about \TeX's memory usage. The |stat| $\ldots$ |tats| code also -implements diagnostic information for \.{\\tracingparagraphs} and -\.{\\tracingpages}. -@^debugging@> - -@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} -@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} -@f debug==begin -@f gubed==end -@# -@d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering - usage statistics} -@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering - usage statistics} -@f stat==begin -@f tats==end - -@ This program has two important variations: (1) There is a long and slow -version called \.{INITEX}, which does the extra calculations needed to -@.INITEX@> -initialize \TeX's internal tables; and (2)~there is a shorter and faster -production version, which cuts the initialization to a bare minimum. -Parts of the program that are needed in (1) but not in (2) are delimited by -the codewords `$|init|\ldots|tini|$'. - -@d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version} -@d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version} -@f init==begin -@f tini==end - -@= -@@/ -@!init @@;@+tini - -@ If the first character of a \PASCAL\ comment is a dollar sign, -\ph\ treats the comment as a list of ``compiler directives'' that will -affect the translation of this program into machine language. The -directives shown below specify full checking and inclusion of the \PASCAL\ -debugger when \TeX\ is being debugged, but they cause range checking and other -redundant code to be eliminated when the production system is being generated. -Arithmetic overflow will be detected in all cases. -@:PASCAL H}{\ph@> -@^system dependencies@> -@^overflow in arithmetic@> - -@= -@{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead} -@!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging} - -@ This \TeX\ implementation conforms to the rules of the {\sl Pascal User -@:PASCAL}{\PASCAL@> -@^system dependencies@> -Manual} published by Jensen and Wirth in 1975, except where system-dependent -@^Wirth, Niklaus@> -@^Jensen, Kathleen@> -code is necessary to make a useful system program, and except in another -respect where such conformity would unnecessarily obscure the meaning -and clutter up the code: We assume that |case| statements may include a -default case that applies if no matching label is found. Thus, we shall use -constructions like -$$\vbox{\halign{\ignorespaces#\hfil\cr -|case x of|\cr -1: $\langle\,$code for $x=1\,\rangle$;\cr -3: $\langle\,$code for $x=3\,\rangle$;\cr -|othercases| $\langle\,$code for |x<>1| and |x<>3|$\,\rangle$\cr -|endcases|\cr}}$$ -since most \PASCAL\ compilers have plugged this hole in the language by -incorporating some sort of default mechanism. For example, the \ph\ -compiler allows `|others|:' as a default label, and other \PASCAL s allow -syntaxes like `\&{else}' or `\&{otherwise}' or `\\{otherwise}:', etc. The -definitions of |othercases| and |endcases| should be changed to agree with -local conventions. Note that no semicolon appears before |endcases| in -this program, so the definition of |endcases| should include a semicolon -if the compiler wants one. (Of course, if no default mechanism is -available, the |case| statements of \TeX\ will have to be laboriously -extended by listing all remaining cases. People who are stuck with such -\PASCAL s have, in fact, done this, successfully but not happily!) -@:PASCAL H}{\ph@> - -@d othercases == others: {default for cases not listed explicitly} -@d endcases == @+end {follows the default case in an extended |case| statement} -@f othercases == else -@f endcases == end - -@ The following parameters can be changed at compile time to extend or -reduce \TeX's capacity. They may have different values in \.{INITEX} and -in production versions of \TeX. -@.INITEX@> -@^system dependencies@> - -@= -@!buf_size=500; {maximum number of characters simultaneously present in - current lines of open files and in control sequences between - \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|} -@!error_line=72; {width of context lines on terminal error messages} -@!half_error_line=42; {width of first lines of contexts in terminal - error messages; should be between 30 and |error_line-15|} -@!max_print_line=79; {width of longest text lines output; should be at least 60} -@!stack_size=200; {maximum number of simultaneous input sources} -@!max_in_open=6; {maximum number of input files and error insertions that - can be going on simultaneously} -@!param_size=60; {maximum number of simultaneous macro parameters} -@!nest_size=40; {maximum number of semantic levels simultaneously active} -@!max_strings=3000; {maximum number of strings; must not exceed |max_halfword|} -@!string_vacancies=8000; {the minimum number of characters that should be - available for the user's control sequences and font names, - after \TeX's own error messages are stored} -@!pool_size=32000; {maximum number of characters in strings, including all - error messages and help texts, and the names of all fonts and - control sequences; must exceed |string_vacancies| by the total - length of \TeX's own strings, which is currently about 23000} -@!save_size=600; {space for saving values outside of current group; must be - at most |max_halfword|} -@!dvi_buf_size=800; {size of the output buffer; must be a multiple of 8} -@!expand_depth=10000; {limits recursive calls of the |expand| procedure} -@!file_name_size=40; {file names shouldn't be longer than this} -@!pool_name='TeXformats:TEX.POOL '; - {string of length |file_name_size|; tells where the string pool appears} -@.TeXformats@> -@!active_mem_size=50000; {number of words of |active_info| for active ocps} -@!ocp_maxint=@"10000000; - - -@ Like the preceding parameters, the following quantities can be changed -at compile time to extend or reduce \TeX's capacity. But if they are changed, -it is necessary to rerun the initialization program \.{INITEX} -@.INITEX@> -to generate new tables for the production \TeX\ program. -One can't simply make helter-skelter changes to the following constants, -since certain rather complex initialization -numbers are computed from them. They are defined here using -\.{WEB} macros, instead of being put into \PASCAL's |const| list, in order to -emphasize this distinction. - -@d font_base=0 {smallest internal font number; must not be less - than |min_quarterword|} -@d hash_size=65536 {maximum number of control sequences; it should be at most - about |(fix_mem_max-fix_mem_min)/10|} -@d ocp_base=0 {smallest internal ocp number; must not be less - than |min_quarterword|} -@d ocp_biggest=32767 {the real biggest ocp} -@d number_ocps=ocp_biggest-ocp_base+1 -@d ocp_list_base=0 {smallest internal ocp list number; must not be less - than |min_quarterword|} -@d ocp_list_biggest=32727 {the real biggest ocp list} -@d number_ocp_lists=ocp_list_biggest-ocp_list_base+1 -@d max_active_ocp_lists=32768 -@d biggest_reg=65535 {the largest allowed register number; must be |<=max_quarterword|} -@d number_regs=65536 {|biggest_reg+1|} -@d number_attrs=65536 {total numbeer of attributes} -@d biggest_mark=65535 {the largest allowed marks class; must be |<=max_quarterword|} -@d number_marks=65536 {|biggest_mark+1|} -{using |2^20+2^16| characters instead of |2^21| saves 286MB on the virtual memory size - of the running executable} -@d biggest_char=1114111 {2097151} {the largest allowed character number; must be |<=max_halfword|} -@d too_big_char=1114112 {2097152} {|biggest_char+1|} -@d special_char=1114113 {2097153} {|biggest_char+2|} -@d number_chars=1114112 {2097152} {|biggest_char+1|} -@d string_offset=2097152 -@d font_biggest=5535 {the real biggest font} -@d number_fonts=font_biggest-font_base+1 -@d biggest_lang=32767 -@d too_big_lang=32768 -@d text_size=0 {size code for the largest size in a family} -@d script_size=1 {size code for the medium size in a family} -@d script_script_size=2 {size code for the smallest size in a family} - - -@ In case somebody has inadvertently made bad settings of the ``constants,'' -\TeX\ checks them using a global variable called |bad|. - -This is the first of many sections of \TeX\ where global variables are -defined. - -@= -@!bad:integer; {is some ``constant'' wrong?} -@!luainit:boolean; {are we using lua for initializations } -@!tracefilenames:boolean; { print file open-close info? } - -@ Later on we will say `\ignorespaces|if X>=max_halfword then bad:=14|', -or something similar. (We can't do that until |max_halfword| has been defined.) - -@= -bad:=0; -if not luainit then tracefilenames:=true; -if (half_error_line<30)or(half_error_line>error_line-15) then bad:=1; -if max_print_line<60 then bad:=2; -if dvi_buf_size mod 8<>0 then bad:=3; -if hash_prime>hash_size then bad:=5; -if max_in_open>=128 then bad:=6; -{ |if null_list<256 then bad:=7;| } {we will want |null_list>255|} - -@ Labels are given symbolic names by the following definitions, so that -occasional |goto| statements will be meaningful. We insert the label -`|exit|' just before the `\ignorespaces|end|\unskip' of a procedure in -which we have used the `|return|' statement defined below; the label -`|restart|' is occasionally used at the very beginning of a procedure; and -the label `|reswitch|' is occasionally used just prior to a |case| -statement in which some cases change the conditions and we wish to branch -to the newly applicable case. Loops that are set up with the |loop| -construction defined below are commonly exited by going to `|done|' or to -`|found|' or to `|not_found|', and they are sometimes repeated by going to -`|continue|'. If two or more parts of a subroutine start differently but -end up the same, the shared code may be gathered together at -`|common_ending|'. - -Incidentally, this program never declares a label that isn't actually used, -because some fussy \PASCAL\ compilers will complain about redundant labels. - -@d exit=10 {go here to leave a procedure} -@d restart=20 {go here to start a procedure again} -@d reswitch=21 {go here to start a case statement again} -@d continue=22 {go here to resume a loop} -@d done=30 {go here to exit a loop} -@d done1=31 {like |done|, when there is more than one loop} -@d done2=32 {for exiting the second loop in a long block} -@d done3=33 {for exiting the third loop in a very long block} -@d done4=34 {for exiting the fourth loop in an extremely long block} -@d done5=35 {for exiting the fifth loop in an immense block} -@d done6=36 {for exiting the sixth loop in a block} -@d found=40 {go here when you've found it} -@d found1=41 {like |found|, when there's more than one per routine} -@d found2=42 {like |found|, when there's more than two per routine} -@d not_found=45 {go here when you've found nothing} -@d not_found1=46 {like |not_found|, when there's more than one} -@d not_found2=47 {like |not_found|, when there's more than two} -@d not_found3=48 {like |not_found|, when there's more than three} -@d not_found4=49 {like |not_found|, when there's more than four} -@d common_ending=50 {go here when you want to merge with another branch} - -@ Here are some macros for common programming idioms. - -@d incr(#) == #:=#+1 {increase a variable by unity} -@d decr(#) == #:=#-1 {decrease a variable by unity} -@d negate(#) == #:=-# {change the sign of a variable} -@d loop == @+ while true do@+ {repeat over and over until a |goto| happens} -@f loop == xclause - {\.{WEB}'s |xclause| acts like `\ignorespaces|while true do|\unskip'} -@d do_nothing == pdfassert(1) {empty statement} -@d return == goto exit {terminate a procedure call} -@f return == nil -@d empty=0 {symbolic name for a null constant} - -@* \[2] The character set. -In order to make \TeX\ readily portable to a wide variety of -computers, all of its input text is converted to an internal -twenty-one-bit code that covers all of unicode, including ASCII, the -``American Standard Code for Information Interchange.'' This -conversion is done immediately when each character is read -in. Conversely, characters are converted from ASCII to the user's -external representation just before they are output to a text file. - -Such an internal code is relevant to users of \TeX\ primarily because it -governs the positions of characters in the fonts. For example, the -character `\.A' has ASCII code $65=@'101$, and when \TeX\ typesets -this letter it specifies character number 65 in the current font. -If that font actually has `\.A' in a different position, \TeX\ doesn't -know what the real position is; the program that does the actual printing from -\TeX's device-independent files is responsible for converting from ASCII to -a particular font encoding. -@^ASCII code@> - -\TeX's internal code also defines the value of constants -that begin with a reverse apostrophe; and it provides an index to the -\.{\\catcode}, \.{\\mathcode}, \.{\\uccode}, \.{\\lccode}, and \.{\\delcode} -tables. - -@ Characters of text that have been converted to \TeX's internal form -are said to be of type |ASCII_code|, which is a subrange of the integers. - -@= -@!ASCII_code=0..biggest_char; {eight-bit numbers} -@!BMP_code=0..65535; {sixteen-bit numbers} - -@ The original \PASCAL\ compiler was designed in the late 60s, when six-bit -character sets were common, so it did not make provision for lowercase -letters. Nowadays, of course, we need to deal with both capital and small -letters in a convenient way, especially in a program for typesetting; -so the present specification of \TeX\ has been written under the assumption -that the \PASCAL\ compiler and run-time system permit the use of text files -with more than 64 distinguishable characters. More precisely, we assume that -the character set contains at least the letters and symbols associated -with ASCII codes @'40 through @'176; all of these characters are now -available on most computer terminals. - -Since we are dealing with more characters than were present in the first -\PASCAL\ compilers, we have to decide what to call the associated data -type. Some \PASCAL s use the original name |char| for the -characters in text files, even though there now are more than 64 such -characters, while other \PASCAL s consider |char| to be a 64-element -subrange of a larger data type that has some other name. - -In order to accommodate this difference, we shall use the name |text_char| -to stand for the data type of the characters that are converted to and -from |ASCII_code| when they are input and output. We shall also assume -that |text_char| consists of the elements |chr(first_text_char)| through -|chr(last_text_char)|, inclusive. The following definitions should be -adjusted if necessary. -@^system dependencies@> - -@d text_char == char {the data type of characters in text files} -@d first_text_char=0 {ordinal number of the smallest element of |text_char|} -@d last_text_char=255 {ordinal number of the largest element of |text_char|} - -@= -@!i:integer; - -@ The \TeX\ processor converts between ASCII code and -the user's external character set by means of arrays |xord| and |xchr| -that are analogous to \PASCAL's |ord| and |chr| functions. - -@= -@!xchr: array [ASCII_code] of text_char; - {specifies conversion of output characters} - -@ Since we are assuming that our \PASCAL\ system is able to read and -write the visible characters of standard ASCII (although not -necessarily using the ASCII codes to represent them), the following -assignment statements initialize the standard part of the |xchr| array -properly, without needing any system-dependent changes. On the other -hand, it is possible to implement \TeX\ with less complete character -sets, and in such cases it will be necessary to change something here. -@^system dependencies@> - -@= -xchr[@'40]:=' '; -xchr[@'41]:='!'; -xchr[@'42]:='"'; -xchr[@'43]:='#'; -xchr[@'44]:='$'; -xchr[@'45]:='%'; -xchr[@'46]:='&'; -xchr[@'47]:='''';@/ -xchr[@'50]:='('; -xchr[@'51]:=')'; -xchr[@'52]:='*'; -xchr[@'53]:='+'; -xchr[@'54]:=','; -xchr[@'55]:='-'; -xchr[@'56]:='.'; -xchr[@'57]:='/';@/ -xchr[@'60]:='0'; -xchr[@'61]:='1'; -xchr[@'62]:='2'; -xchr[@'63]:='3'; -xchr[@'64]:='4'; -xchr[@'65]:='5'; -xchr[@'66]:='6'; -xchr[@'67]:='7';@/ -xchr[@'70]:='8'; -xchr[@'71]:='9'; -xchr[@'72]:=':'; -xchr[@'73]:=';'; -xchr[@'74]:='<'; -xchr[@'75]:='='; -xchr[@'76]:='>'; -xchr[@'77]:='?';@/ -xchr[@'100]:='@@'; -xchr[@'101]:='A'; -xchr[@'102]:='B'; -xchr[@'103]:='C'; -xchr[@'104]:='D'; -xchr[@'105]:='E'; -xchr[@'106]:='F'; -xchr[@'107]:='G';@/ -xchr[@'110]:='H'; -xchr[@'111]:='I'; -xchr[@'112]:='J'; -xchr[@'113]:='K'; -xchr[@'114]:='L'; -xchr[@'115]:='M'; -xchr[@'116]:='N'; -xchr[@'117]:='O';@/ -xchr[@'120]:='P'; -xchr[@'121]:='Q'; -xchr[@'122]:='R'; -xchr[@'123]:='S'; -xchr[@'124]:='T'; -xchr[@'125]:='U'; -xchr[@'126]:='V'; -xchr[@'127]:='W';@/ -xchr[@'130]:='X'; -xchr[@'131]:='Y'; -xchr[@'132]:='Z'; -xchr[@'133]:='['; -xchr[@'134]:='\'; -xchr[@'135]:=']'; -xchr[@'136]:='^'; -xchr[@'137]:='_';@/ -xchr[@'140]:='`'; -xchr[@'141]:='a'; -xchr[@'142]:='b'; -xchr[@'143]:='c'; -xchr[@'144]:='d'; -xchr[@'145]:='e'; -xchr[@'146]:='f'; -xchr[@'147]:='g';@/ -xchr[@'150]:='h'; -xchr[@'151]:='i'; -xchr[@'152]:='j'; -xchr[@'153]:='k'; -xchr[@'154]:='l'; -xchr[@'155]:='m'; -xchr[@'156]:='n'; -xchr[@'157]:='o';@/ -xchr[@'160]:='p'; -xchr[@'161]:='q'; -xchr[@'162]:='r'; -xchr[@'163]:='s'; -xchr[@'164]:='t'; -xchr[@'165]:='u'; -xchr[@'166]:='v'; -xchr[@'167]:='w';@/ -xchr[@'170]:='x'; -xchr[@'171]:='y'; -xchr[@'172]:='z'; -xchr[@'173]:='{'; -xchr[@'174]:='|'; -xchr[@'175]:='}'; -xchr[@'176]:='~';@/ - -@ Some of the ASCII codes without visible characters have been given symbolic -names in this program because they are used with a special meaning. - -@d null_code=@'0 {ASCII code that might disappear} -@d carriage_return=@'15 {ASCII code used at end of line} -@d invalid_code=@'177 {ASCII code that many systems prohibit in text files} - -@ The ASCII code is ``standard'' only to a certain extent, since many -computer installations have found it advantageous to have ready access -to more than 94 printing characters. Appendix~C of {\sl The \TeX book\/} -gives a complete specification of the intended correspondence between -characters and \TeX's internal representation. -@:TeXbook}{\sl The \TeX book@> - -If \TeX\ is being used -on a garden-variety \PASCAL\ for which only standard ASCII -codes will appear in the input and output files, it doesn't really matter -what codes are specified in |xchr[0..@'37]|, but the safest policy is to -blank everything out by using the code shown below. - -However, other settings of |xchr| will make \TeX\ more friendly on -computers that have an extended character set, so that users can type things -like `\.^^Z' instead of `\.{\\ne}'. People with extended character sets can -assign codes arbitrarily, giving an |xchr| equivalent to whatever -characters the users of \TeX\ are allowed to have in their input files. -It is best to make the codes correspond to the intended interpretations as -shown in Appendix~C whenever possible; but this is not necessary. For -example, in countries with an alphabet of more than 26 letters, it is -usually best to map the additional letters into codes less than~@'40. -To get the most ``permissive'' character set, change |' '| on the -right of these assignment statements to |chr(i)|. -@^character set dependencies@> -@^system dependencies@> - -@= -for i:=0 to biggest_char do xchr[i]:=i; - -@ The following system-independent code makes the |xord| array contain a -suitable inverse to the information in |xchr|. Note that if |xchr[i]=xchr[j]| -where |i= - -@* \[3] Input and output. -The bane of portability is the fact that different operating systems treat -input and output quite differently, perhaps because computer scientists -have not given sufficient attention to this problem. People have felt somehow -that input and output are not part of ``real'' programming. Well, it is true -that some kinds of programming are more fun than others. With existing -input/output conventions being so diverse and so messy, the only sources of -joy in such parts of the code are the rare occasions when one can find a -way to make the program a little less bad than it might have been. We have -two choices, either to attack I/O now and get it over with, or to postpone -I/O until near the end. Neither prospect is very attractive, so let's -get it over with. - -The basic operations we need to do are (1)~inputting and outputting of -text, to or from a file or the user's terminal; (2)~inputting and -outputting of eight-bit bytes, to or from a file; (3)~instructing the -operating system to initiate (``open'') or to terminate (``close'') input or -output from a specified file; (4)~testing whether the end of an input -file has been reached. - -\TeX\ needs to deal with two kinds of files. -We shall use the term |alpha_file| for a file that contains textual data, -and the term |byte_file| for a file that contains eight-bit binary information. -These two types turn out to be the same on many computers, but -sometimes there is a significant distinction, so we shall be careful to -distinguish between them. Standard protocols for transferring -such files from computer to computer, via high-speed networks, are -now becoming available to more and more communities of users. - -The program actually makes use also of a third kind of file, called a -|word_file|, when dumping and reloading base information for its own -initialization. We shall define a word file later; but it will be possible -for us to specify simple operations on word files before they are defined. - -@= -@!eight_bits=0..65535; {unsigned one-byte quantity} -@!real_eight_bits=0..255; {unsigned one-byte quantity} -@!alpha_file=packed file of text_char; {files that contain textual data} -@!byte_file=packed file of real_eight_bits; {files that contain binary data} - -@ Most of what we need to do with respect to input and output can be handled -by the I/O facilities that are standard in \PASCAL, i.e., the routines -called |get|, |put|, |eof|, and so on. But -standard \PASCAL\ does not allow file variables to be associated with file -names that are determined at run time, so it cannot be used to implement -\TeX; some sort of extension to \PASCAL's ordinary |reset| and |rewrite| -is crucial for our purposes. We shall assume that |nameoffile| is a variable -of an appropriate type such that the \PASCAL\ run-time system being used to -implement \TeX\ can open a file whose external name is specified by -|nameoffile|. -@^system dependencies@> - -@= -@!nameoffile:packed array[1..file_name_size] of char;@;@/ - {on some systems this may be a \&{record} variable} -@!namelength:0..file_name_size;@/{this many characters are actually - relevant in |nameoffile| (the rest are blank)} -@!name_file_pointer:alpha_file; - -@ The \ph\ compiler with which the present version of \TeX\ was prepared has -extended the rules of \PASCAL\ in a very convenient way. To open file~|f|, -we can write -$$\vbox{\halign{#\hfil\qquad&#\hfil\cr -|reset(f,@t\\{name}@>,'/O')|&for input;\cr -|rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$ -The `\\{name}' parameter, which is of type `{\bf packed array -$[\langle\\{any}\rangle]$ of \\{char}}', stands for the name of -the external file that is being opened for input or output. -Blank spaces that might appear in \\{name} are ignored. - -The `\.{/O}' parameter tells the operating system not to issue its own -error messages if something goes wrong. If a file of the specified name -cannot be found, or if such a file cannot be opened for some other reason -(e.g., someone may already be trying to write the same file), we will have -|@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|. This allows -\TeX\ to undertake appropriate corrective action. -@:PASCAL H}{\ph@> -@^system dependencies@> - -\TeX's file-opening procedures return |false| if no file identified by -|nameoffile| could be opened. - -@d reset_OK(#)==erstat(#)=0 -@d rewrite_OK(#)==erstat(#)=0 - -@p function a_open_in(var f:alpha_file):boolean; - {open a text file for input} -begin reset(f,nameoffile,'/O'); a_open_in:=reset_OK(f); -end; -@# -function a_open_out(var f:alpha_file):boolean; - {open a text file for output} -begin rewrite(f,nameoffile,'/O'); a_open_out:=rewrite_OK(f); -end; -@# -function b_open_in(var f:byte_file):boolean; - {open a binary file for input} -begin reset(f,nameoffile,'/O'); b_open_in:=reset_OK(f); -end; -@# -function b_open_out(var f:byte_file):boolean; - {open a binary file for output} -begin rewrite(f,nameoffile,'/O'); b_open_out:=rewrite_OK(f); -end; -@# -function w_open_in(var f:word_file):boolean; - {open a word file for input} -begin reset(f,nameoffile,'/O'); w_open_in:=reset_OK(f); -end; -@# -function w_open_out(var f:word_file):boolean; - {open a word file for output} -begin rewrite(f,nameoffile,'/O'); w_open_out:=rewrite_OK(f); -end; - -@ When input files are opened via a callback, they will also be read using -callbacks. for that purpose, the |open_read_file_callback| returns an -integer to uniquely identify a callback table. This id replaces the file -point |f| in this case, because the input does not have to be a file -in the traditional sense. - -Signalling this fact is achieved by having two arrays of integers. - -@= -@!input_file_callback_id : ^integer; -@!read_file_callback_id : array[0..16] of integer; - -@ -@p function lua_a_open_in(var f:alpha_file; n:quarterword):boolean; -var k:integer; { a temporary value } - fnam:str_number; { string returned by find callback } - callback_id:integer; - file_ok:boolean; { the status so far } -begin - file_ok:=true; - if n=0 then begin - texinputtype := 1; {Tell |open_input| we are \.{\\input}.} - input_file_callback_id[index] := 0; - end - else begin - texinputtype:=0; - read_file_callback_id[n] := 0; - end; - callback_id:=callback_defined(find_read_file_callback); - if callback_id>0 then begin - fnam:=0; - file_ok:=run_callback(callback_id,'dS->s',n,stringcast(nameoffile+1),addressof(fnam)); - if (file_ok)and(fnam<>0)and(length(fnam)>0) then begin - @; - end - else - file_ok:=false; {file not found} - end; - if file_ok then begin - callback_id:=callback_defined(open_read_file_callback); - if callback_id>0 then begin - k := run_and_save_callback(callback_id,'S->',stringcast(nameoffile+1)); - if k>0 then begin - lua_a_open_in := true; - if n=0 then - input_file_callback_id[index] := k - else - read_file_callback_id[n] := k; - end - else - file_ok:=false; {read failed} - end - else begin {no read callback} - if kpse_in_name_ok(stringcast(nameoffile+1)) then begin - lua_a_open_in := a_open_in(f,kpsetexformat); - name_file_pointer := f; - end - else - file_ok:=false; {open failed} - end; - end; - if not file_ok then begin - lua_a_open_in := false; - name_file_pointer := 0; - end; -end; -@# -function lua_a_open_out(var f:alpha_file; n:quarterword):boolean; -var test:boolean; - k:integer; - fnam:str_number; - callback_id:integer; -begin - name_file_pointer := 0; - callback_id:=callback_defined(find_write_file_callback); - if callback_id>0 then begin - fnam:=0; - test:=run_callback(callback_id,'dS->s',n,stringcast(nameoffile+1),addressof(fnam)); - if (test)and(fnam<>0)and(length(fnam)>0) then begin - @; - lua_a_open_out := do_a_open_out(f); - name_file_pointer := f; - end - else - lua_a_open_out := false; - end - else begin - if kpse_out_name_ok(stringcast(nameoffile+1)) then begin - lua_a_open_out := a_open_out(f); - name_file_pointer := f; - end - else - lua_a_open_out := false; - end; -end; -function lua_b_open_out(var f:alpha_file):boolean; -var test:boolean; - k:integer; - fnam:str_number; - callback_id:integer; -begin - name_file_pointer := 0; - callback_id:=callback_defined(find_output_file_callback); - if callback_id>0 then begin - fnam:=0; - test:=run_callback(callback_id,'S->s',stringcast(nameoffile+1),addressof(fnam)); - if (test)and(fnam<>0)and(length(fnam)>0) then begin - @; - lua_b_open_out := do_b_open_out(f); - name_file_pointer := f; - end - else - lua_b_open_out := false; - end - else begin - if kpse_out_name_ok(stringcast(nameoffile+1)) then begin - lua_b_open_out := b_open_out(f); - name_file_pointer := f; - end - else - lua_b_open_out := false; - end; -end; - -@ -@= -libcfree (nameoffile); -nameoffile := xmallocarray (packed_ASCII_code, length(fnam)+2); -for k:=str_start_macro(fnam) to str_start_macro(fnam+1)-1 do - nameoffile[k-str_start_macro(fnam)+1] := str_pool[k]; -nameoffile[length(fnam)+1]:=0; -namelength := length(fnam); -flush_string - -@ Files can be closed with the \ph\ routine `|close(f)|', which -@:PASCAL H}{\ph@> -@^system dependencies@> -should be used when all input or output with respect to |f| has been completed. -This makes |f| available to be opened again, if desired; and if |f| was used for -output, the |close| operation makes the corresponding external file appear -on the user's area, ready to be read. - -These procedures should not generate error messages if a file is -being closed before it has been successfully opened. - -@p procedure a_close(var f:alpha_file); {close a text file} -begin close(f); -end; -@# -procedure b_close(var f:byte_file); {close a binary file} -begin close(f); -end; -@# -procedure w_close(var f:word_file); {close a word file} -begin close(f); -end; - - -@ - -@p procedure lua_a_close_in(var f:alpha_file; n:quarterword); {close a text file} -var ret:boolean; - callback_id:integer; -begin -if n=0 then - callback_id:=input_file_callback_id[index] -else - callback_id:=read_file_callback_id[n]; -if callback_id>0 then begin - ret:=run_saved_callback(callback_id,'close','->'); - destroy_saved_callback(callback_id); - if n=0 then - input_file_callback_id[index] := 0 - else - read_file_callback_id[n] := 0; - end -else - a_close(f); -end; -@# -procedure lua_a_close_out(var f:alpha_file); {close a text file} -begin - a_close(f); -end; - - -@ Binary input and output are done with \PASCAL's ordinary |get| and |put| -procedures, so we don't have to make any other special arrangements for -binary~I/O. Text output is also easy to do with standard \PASCAL\ routines. -The treatment of text input is more difficult, however, because -of the necessary translation to |ASCII_code| values. -\TeX's conventions should be efficient, and they should -blend nicely with the user's operating environment. - -@ Input from text files is read one line at a time, using a routine called -|lua_input_ln|. This function is defined in terms of global variables called -|buffer|, |first|, and |last| that will be described in detail later; for -now, it suffices for us to know that |buffer| is an array of |ASCII_code| -values, and that |first| and |last| are indices into this array -representing the beginning and ending of a line of text. - -@= -@!buffer:array[0..buf_size] of packed_ASCII_code; {lines of characters being read} -@!first:0..buf_size; {the first unused position in |buffer|} -@!last:0..buf_size; {end of the line just input to |buffer|} -@!max_buf_stack:0..buf_size; {largest index used in |buffer|} - -@ The |lua_input_ln| function brings the next line of input from the specified -file into available positions of the buffer array and returns the value -|true|, unless the file has already been entirely read, in which case it -returns |false| and sets |last:=first|. In general, the |ASCII_code| -numbers that represent the next line of the file are input into -|buffer[first]|, |buffer[first+1]|, \dots, |buffer[last-1]|; and the -global variable |last| is set equal to |first| plus the length of the -line. Trailing blanks are removed from the line; thus, either |last=first| -(in which case the line was entirely blank) or |buffer[last-1]<>" "|. - -An overflow error is given, however, if the normal actions of |lua_input_ln| -would make |last>=buf_size|; this is done so that other parts of \TeX\ -can safely look at the contents of |buffer[last+1]| without overstepping -the bounds of the |buffer| array. Upon entry to |lua_input_ln|, the condition -|first - -@p function input_ln(var f:alpha_file;@!bypass_eoln:boolean):boolean; - {inputs the next line or returns |false|} -var last_nonblank:0..buf_size; {|last| with trailing blanks removed} -begin if bypass_eoln then if not eof(f) then get(f); - {input the first character of the line into |f^|} -last:=first; {cf.\ Matthew 19\thinspace:\thinspace30} -if eof(f) then input_ln:=false -else begin last_nonblank:=first; - while not eoln(f) do - begin if last>=max_buf_stack then - begin max_buf_stack:=last+1; - if max_buf_stack=buf_size then - @; - end; - buffer[last]:=f^; get(f); incr(last); - if buffer[last-1]<>" " then last_nonblank:=last; - end; - last:=last_nonblank; input_ln:=true; - end; -end; - -function lua_input_ln(var f:alpha_file;n:quarterword;@!bypass_eoln:boolean):boolean; -var lua_result:boolean; - last_ptr:integer; - callback_id:integer; - bypass_p:boolean; -begin -if n=0 then - callback_id:=input_file_callback_id[index] -else - callback_id:=read_file_callback_id[n]; -if callback_id>0 then begin - last:=first; - last_ptr := first; - lua_result := run_saved_callback(callback_id,'reader','->l', addressof(last_ptr)); - if (lua_result=true)and(last_ptr<>0) then begin - last := last_ptr; - if last>max_buf_stack then max_buf_stack:=last; - lua_input_ln := true; - @; - end - else - lua_input_ln := false; - end - else begin - bypass_p := bypass_eoln; {this is for -Wextra} - lua_result := input_ln(f,bypass_p); - if lua_result=true then begin - lua_input_ln := true; - @; - end - else - lua_input_ln := false; - end -end; - -@ -@= -if last>=first then begin - callback_id := callback_defined(process_input_buffer_callback); - if callback_id>0 then begin - last_ptr := first; - lua_result := run_callback(callback_id, 'l->l', (last-first), addressof(last_ptr)); - if (lua_result=true)and(last_ptr<>0) then begin - last := last_ptr; - if last>max_buf_stack then max_buf_stack:=last; - end; - end; - end - - - -@ The user's terminal acts essentially like other files of text, except -that it is used both for input and for output. When the terminal is -considered an input file, the file variable is called |term_in|, and when it -is considered an output file the file variable is |term_out|. -@^system dependencies@> - -@= -@!term_in:alpha_file; {the terminal as an input file} -@!term_out:alpha_file; {the terminal as an output file} - -@ Here is how to open the terminal files -in \ph. The `\.{/I}' switch suppresses the first |get|. -@:PASCAL H}{\ph@> -@^system dependencies@> - -@d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input} -@d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output} - -@ Sometimes it is necessary to synchronize the input/output mixture that -happens on the user's terminal, and three system-dependent -procedures are used for this -purpose. The first of these, |update_terminal|, is called when we want -to make sure that everything we have output to the terminal so far has -actually left the computer's internal buffers and been sent. -The second, |clear_terminal|, is called when we wish to cancel any -input that the user may have typed ahead (since we are about to -issue an unexpected error message). The third, |wake_up_terminal|, -is supposed to revive the terminal if the user has disabled it by -some instruction to the operating system. The following macros show how -these operations can be specified in \ph: -@:PASCAL H}{\ph@> -@^system dependencies@> - -@d update_terminal == break(term_out) {empty the terminal output buffer} -@d clear_terminal == break_in(term_in,true) {clear the terminal input buffer} -@d wake_up_terminal == do_nothing {cancel the user's cancellation of output} - -@ We need a special routine to read the first line of \TeX\ input from -the user's terminal. This line is different because it is read before we -have opened the transcript file; there is sort of a ``chicken and -egg'' problem here. If the user types `\.{\\input paper}' on the first -line, or if some macro invoked by that line does such an \.{\\input}, -the transcript file will be named `\.{paper.log}'; but if no \.{\\input} -commands are performed during the first line of terminal input, the transcript -file will acquire its default name `\.{texput.log}'. (The transcript file -will not contain error messages generated by the first line before the -first \.{\\input} command.) -@.texput@> - -The first line is even more special if we are lucky enough to have an operating -system that treats \TeX\ differently from a run-of-the-mill \PASCAL\ object -program. It's nice to let the user start running a \TeX\ job by typing -a command line like `\.{tex paper}'; in such a case, \TeX\ will operate -as if the first line of input were `\.{paper}', i.e., the first line will -consist of the remainder of the command line, after the part that invoked -\TeX. - -The first line is special also because it may be read before \TeX\ has -input a format file. In such cases, normal error messages cannot yet -be given. The following code uses concepts that will be explained later. -(If the \PASCAL\ compiler does not support non-local |@!goto|\unskip, the -@^system dependencies@> -statement `|goto final_end|' should be replaced by something that -quietly terminates the program.) - -@= -if format_ident=0 then - begin writeln(term_out,'Buffer size exceeded!'); goto final_end; -@.Buffer size exceeded@> - end -else - check_buffer_overflow(buf_size+10) { need a little bit more} - -@ Different systems have different ways to get started. But regardless of -what conventions are adopted, the routine that initializes the terminal -should satisfy the following specifications: - -\yskip\textindent{1)}It should open file |term_in| for input from the - terminal. (The file |term_out| will already be open for output to the - terminal.) - -\textindent{2)}If the user has given a command line, this line should be - considered the first line of terminal input. Otherwise the - user should be prompted with `\.{**}', and the first line of input - should be whatever is typed in response. - -\textindent{3)}The first line of input, which might or might not be a - command line, should appear in locations |first| to |last-1| of the - |buffer| array. - -\textindent{4)}The global variable |loc| should be set so that the - character to be read next by \TeX\ is in |buffer[loc]|. This - character should not be blank, and we should have |loc - -@p function init_terminal:boolean; {gets the terminal input started} -label exit; -begin t_open_in; -loop@+begin wake_up_terminal; write(term_out,'**'); update_terminal; -@.**@> - if not input_ln(term_in,true) -then {this shouldn't happen} - begin writeln(term_out); - write(term_out,'! End of file on the terminal... why?'); -@.End of file on the terminal@> - init_terminal:=false; return; - end; - loc:=first; - while (loc -which converts single-character strings into the ASCII code number of the -single character involved, while it converts other strings into integers -and builds a string pool file. Thus, when the string constant \.{"."} appears -in the program below, \.{WEB} converts it into the integer 46, which is the -ASCII code for a period, while \.{WEB} will convert a string like \.{"hello"} -into some integer greater than~|biggest_char|. - -Some \PASCAL\ compilers won't pack integers into a single byte unless the -integers lie in the range |-128..127|. To accommodate such systems -we access the string pool only via macros that can easily be redefined. -@^system dependencies@> - -@d si(#) == # {convert from |ASCII_code| to |packed_ASCII_code|} -@d so(#) == # {convert from |packed_ASCII_code| to |ASCII_code|} -@d str_start_macro(#) == str_start[(#) - string_offset] - -@= -@!pool_pointer = integer; {for variables that point into |str_pool|} -@!str_number = integer; {for variables that point into |str_start|} -@!packed_ASCII_code = 0..255; {elements of |str_pool| array} - -@ @= -@!str_pool:packed array[pool_pointer] of packed_ASCII_code; {the characters} -@!str_start : array[str_number] of pool_pointer; {the starting pointers} -@!pool_ptr : pool_pointer; {first unused position in |str_pool|} -@!str_ptr : str_number; {number of the current string being created} -@!init_pool_ptr : pool_pointer; {the starting value of |pool_ptr|} -@!init_str_ptr : str_number; {the starting value of |str_ptr|} - -@ Several of the elementary string operations are performed using \.{WEB} -macros instead of \PASCAL\ procedures, because many of the -operations are done quite frequently and we want to avoid the -overhead of procedure calls. For example, here is -a simple macro that computes the length of a string. -@.WEB@> - -@d length(#)==(str_start_macro(#+1)-str_start_macro(#)) {the number of characters - in string number \#} - -@ The length of the current string is called |cur_length|: - -@d cur_length == (pool_ptr - str_start_macro(str_ptr)) - -@ Strings are created by appending character codes to |str_pool|. -The |append_char| macro, defined here, does not check to see if the -value of |pool_ptr| has gotten too high; this test is supposed to be -made before |append_char| is used. There is also a |flush_char| -macro, which erases the last character appended. - -To test if there is room to append |l| more characters to |str_pool|, -we shall write |str_room(l)|, which aborts \TeX\ and gives an -apologetic error message if there isn't enough room. - -@d append_char(#) == {put |ASCII_code| \# at the end of |str_pool|} -begin str_pool[pool_ptr]:=si(#); incr(pool_ptr); -end -@d flush_char == decr(pool_ptr) {forget the last character in the pool} -@d str_room(#) == check_pool_overflow((pool_ptr+#)) {test or grow the pool} - -@p procedure string_room(t:integer); -begin - str_room(t); -end; -@# -procedure append_pool_char(c:ASCII_code); -begin - append_char(c); -end; - - -@ Once a sequence of characters has been appended to |str_pool|, it -officially becomes a string when the function |make_string| is called. -This function returns the identification number of the new string as its -value. - -@p function make_string : str_number; {current string enters the pool} -begin if str_ptr=(max_strings+string_offset) then - overflow("number of strings",max_strings-init_str_ptr); -@:TeX capacity exceeded number of strings}{\quad number of strings@> -incr(str_ptr); str_start_macro(str_ptr):=pool_ptr; -make_string:=str_ptr-1; -end; - -@ To destroy the most recently made string, we say |flush_string|. - -The helper routines reads one utf sequence from the pool resp. the -buffer, and returns its character value. - -@d flush_string==begin decr(str_ptr); pool_ptr:=str_start_macro(str_ptr); - end -@d test_sequence_byte(#)==if (#<@"80) or (#>=@"C0) then begin - print_err("Text line contains an invalid utf-8 sequence"); -@.Text line contains...@> - help2("A funny symbol that I can't read has just been input.")@/ - ("Just continue, I'll change it to 0xFFFD.");@/ - deletions_allowed:=false; error; deletions_allowed:=true; -{the assigment before return is needed because web2c generates incorrect code} - a:=@"FFFD; buffer_to_unichar:=a; return; end - - -@p function buffer_to_unichar(@!k:integer):integer; -label exit; -var a:@!integer; {a utf char} -b:@!integer; { a utf nibble} -begin - b := buffer[k]; - if b<@"80 then - a := b - else if b>=@"F0 then begin - a := (b-@"F0) * 64; - b := buffer[k+1]; - test_sequence_byte(b); - a := (a + (b-128)) * 64; - b := buffer[k+2]; - test_sequence_byte(b); - a := (a + (b-128)) * 64; - b := buffer[k+3]; - test_sequence_byte(b); - a := a + (b-128); - end - else if b>=@"E0 then begin - a := (b-@"E0) * 64; - b := buffer[k+1]; - test_sequence_byte(b); - a := (a + (b-128)) * 64; - b := buffer[k+2]; - test_sequence_byte(b); - a := a + (b-128); - end - else if b>=@"C0 then begin - a := (b-@"C0) * 64; - b := buffer[k+1]; - test_sequence_byte(b); - a := a + (b-128); - end - else begin { NI: this is an encoding error } - print_err("Buffer contains an invalid utf-8 sequence"); -@.Text line contains...@> - help2("A funny symbol somehow ended up in the input buffer.")@/ - ("Just continue, I'll change it to 0xFFFD.");@/ - deletions_allowed:=false; error; deletions_allowed:=true; - a:=@"FFFD; - end; -exit: - buffer_to_unichar := a; -end ; - - - -@ The following subroutine compares string |s| with another string of the -same length that appears in |buffer| starting at position |k|; -the result is |true| if and only if the strings are equal. -Empirical tests indicate that |str_eq_buf| is used in such a way that -it tends to return |true| about 80 percent of the time. - -@p function str_eq_buf(@!s:str_number;@!k:integer):boolean; - {test equality of strings} -label not_found; {loop exit} -var j: pool_pointer; {running index} -a: ASCII_code; {a unicode character } -@!result: boolean; {result of comparison} -begin result:=false; -if ss then goto not_found; - end -else begin -j:=str_start_macro(s); -while jbuffer[k] then - begin goto not_found; - end; - incr(j); incr(k); - end; -end; -result:=true; -not_found: str_eq_buf:=result; -end; - -@ Here is a similar routine, but it compares two strings in the string pool, -and it does not assume that they have the same length. - -@p function str_eq_str(@!s,@!t:str_number):boolean; - {test equality of strings} -label found,not_found; {loop exit} -var j,@!k: pool_pointer; {running indices} -a: ASCII_code; {a utf char} -@!result: boolean; {result of comparison} -begin result:=false; -a:= 0; -if s=string_offset then begin - if s<=@"7F then - if length(t)=1 then - if str_pool[str_start_macro(t)]=s then - goto found; - a := pool_to_unichar(str_start_macro(t)); - if a<>s then goto not_found; - end - else - if t<>s then goto not_found; - end -else if tt then goto not_found; - end -else begin - if length(s)<>length(t) then goto not_found; - j:=str_start_macro(s); k:=str_start_macro(t); - while jstr_pool[k] then goto not_found; - incr(j); incr(k); - end; - end; -found: result:=true; -not_found: str_eq_str:=result; -end; - -@ The initial values of |str_pool|, |str_start|, |pool_ptr|, -and |str_ptr| are computed by the \.{INITEX} program, based in part -on the information that \.{WEB} has output while processing \TeX. -@.INITEX@> -@^string pool@> - -The first |string_offset| strings are single-characters strings matching -Unicode. There is no point in generating all of these. But |str_ptr| has -initialized properly, otherwise |print_char| cannot see the difference -between characters and strings. - -@p @!init function get_strings_started:boolean; {initializes the string pool, - but returns |false| if something goes wrong} -label done,exit; -var @!g:str_number; {garbage} -begin pool_ptr:=0; str_ptr:=string_offset; str_start[0]:=0; -@; -exit:end; -tini - -@ @d app_lc_hex(#)==l:=#; - if l<10 then append_char(l+"0")@+else append_char(l-10+"a") - -@ The first 128 strings will contain 95 standard ASCII characters, and the -other 33 characters will be printed in three-symbol form like `\.{\^\^A}' -unless a system-dependent change is made here. Installations that have -an extended character set, where for example |xchr[@'32]=@t\.{\'^^Z\'}@>|, -would like string @'32 to be the single character @'32 instead of the -three characters @'136, @'136, @'132 (\.{\^\^Z}). On the other hand, -even people with an extended character set will want to represent string -@'15 by \.{\^\^M}, since @'15 is |carriage_return|; the idea is to -produce visible strings instead of tabs or line-feeds or carriage-returns -or bell-rings or characters that are treated anomalously in text files. - -Unprintable characters of codes 128--255 are, similarly, rendered -\.{\^\^80}--\.{\^\^ff}. - -Unprintable characters of codes 256--|65535| are, similarly, rendered -\.{\^\^\^\^0100}--\.{\^\^\^\^ffff}. - -The boolean expression defined here should be |true| unless \TeX\ -internal code number~|k| corresponds to a non-troublesome visible -symbol in the local character set. An appropriate formula for the -extended character set recommended in {\sl The \TeX book\/} would, for -example, be `|k in [0,@'10..@'12,@'14,@'15,@'33,@'177..@'377]|'. -If character |k| cannot be printed, and |k<@'200|, then character |k+@'100| or -|k-@'100| must be printable; moreover, ASCII codes |[@'41..@'46, -@'60..@'71, @'136, @'141..@'146, @'160..@'171]| must be printable. -Thus, at least 81 printable characters are needed. -@:TeXbook}{\sl The \TeX book@> -@^character set dependencies@> -@^system dependencies@> - -@ @= - g := loadpoolstrings((pool_size-string_vacancies)); - if g=0 then begin - wake_up_terminal; writeln(term_out,'! You have to increase POOLSIZE.'); - get_strings_started:=false; - return; - end; - get_strings_started:=true; - -@* \[5] On-line and off-line printing. -Messages that are sent to a user's terminal and to the transcript-log file -are produced by several `|print|' procedures. These procedures will -direct their output to a variety of places, based on the setting of -the global variable |selector|, which has the following possible -values: - -\yskip -\hang |term_and_log|, the normal setting, prints on the terminal and on the - transcript file. - -\hang |log_only|, prints only on the transcript file. - -\hang |term_only|, prints only on the terminal. - -\hang |no_print|, doesn't print at all. This is used only in rare cases - before the transcript file is open. - -\hang |pseudo|, puts output into a cyclic buffer that is used - by the |show_context| routine; when we get to that routine we shall discuss - the reasoning behind this curious mode. - -\hang |new_string|, appends the output to the current string in the - string pool. - -\hang 0 to 15, prints on one of the sixteen files for \.{\\write} output. - -\yskip -\noindent The symbolic names `|term_and_log|', etc., have been assigned -numeric codes that satisfy the convenient relations |no_print+1=term_only|, -|no_print+2=log_only|, |term_only+2=log_only+1=term_and_log|. - -Three additional global variables, |tally| and |term_offset| and -|file_offset|, record the number of characters that have been printed -since they were most recently cleared to zero. We use |tally| to record -the length of (possibly very long) stretches of printing; |term_offset| -and |file_offset|, on the other hand, keep track of how many characters -have appeared so far on the current line that has been output to the -terminal or to the transcript file, respectively. - -@d no_print=16 {|selector| setting that makes data disappear} -@d term_only=17 {printing is destined for the terminal only} -@d log_only=18 {printing is destined for the transcript file only} -@d term_and_log=19 {normal |selector| setting} -@d pseudo=20 {special |selector| setting for |show_context|} -@d new_string=21 {printing is deflected to the string pool} -@d max_selector=21 {highest selector setting} - -@= -@!log_file : alpha_file; {transcript of \TeX\ session} -@!term_out_mode:halfword; -@!term_out_translation:halfword; -@!selector : 0..max_selector; {where to print a message} -@!dig : array[0..22] of 0..15; {digits in a number being output} -@!tally : integer; {the number of characters recently printed} -@!term_offset : 0..max_print_line; - {the number of characters on the current terminal line} -@!file_offset : 0..max_print_line; - {the number of characters on the current file line} -@!trick_buf:array[0..error_line] of packed_ASCII_code; {circular buffer for - pseudoprinting} -@!trick_count: integer; {threshold for pseudoprinting, explained later} -@!first_count: integer; {another variable for pseudoprinting} -@!inhibit_par_tokens:boolean; { for minor adjustments to |show_token_list| } - -@ @= -selector:=term_only; tally:=0; term_offset:=0; file_offset:=0; -inhibit_par_tokens:=false; - -@ Macro abbreviations for output to the terminal and to the log file are -defined here for convenience. Some systems need special conventions -for terminal output, and it is possible to adhere to those conventions -by changing |wterm|, |wterm_ln|, and |wterm_cr| in this section. -@^system dependencies@> - -@d wterm(#)==write(term_out,#) -@d wterm_ln(#)==writeln(term_out,#) -@d wterm_cr==writeln(term_out) -@d wlog(#)==write(log_file,#) -@d wlog_ln(#)==writeln(log_file,#) -@d wlog_cr==writeln(log_file) - -@ To end a line of text output, we call |print_ln|. - -@= -procedure print_ln; {prints an end-of-line} -begin case selector of -term_and_log: begin wterm_cr; wlog_cr; - term_offset:=0; file_offset:=0; - end; -log_only: begin wlog_cr; file_offset:=0; - end; -term_only: begin wterm_cr; term_offset:=0; - end; -no_print,pseudo,new_string: do_nothing; -othercases writeln(write_file[selector]) -endcases;@/ -end; {|tally| is not affected} - -@ The |print_char| procedure sends one character to the desired destination, -using the |xchr| array to map it into an external character compatible with -|lua_input_ln|. All printing comes through |print_ln| or |print_char|. - -@d wterm_char(#)==begin if (#>=@"20)or(#=@"0A)or(#=@"0D)or(#=@"09) then wterm(xchr[#]) - else begin if term_offset+2>=max_print_line then begin - wterm_cr; term_offset:=0; - end; - incr(term_offset); wterm('^'); incr(term_offset); wterm('^'); - wterm(xchr[#+64]); - end; end -@d fix_term_offset(#)== - if ((#>=@"C0) and (#<=@"DF) and (term_offset+2>=max_print_line)) or - ((#>=@"E0) and (#<=@"EF) and (term_offset+3>=max_print_line)) or - ((#>=@"F0) and (term_offset+4>=max_print_line)) then begin - wterm_cr; term_offset:=0; - end -@d fix_log_offset(#)== - if ((#>=@"C0) and (#<=@"DF) and (file_offset+2>=max_print_line)) or - ((#>=@"E0) and (#<=@"EF) and (file_offset+3>=max_print_line)) or - ((#>=@"F0) and (file_offset+4>=max_print_line)) then begin - wlog_cr; file_offset:=0; - end - -@= -procedure print_char(@!s:ASCII_code); {prints a single character} -label exit; -begin if @ then - if selector - -The first 256 entries above the 17th unicode plane are used for a -special trick: when \TeX\ has to print items in that range, it will -instead print the character that results from substracting @"110000 -from that value. This allows byte-oriented output to things like -\.{\\specials} and \.{\\pdfliterals}. Todo: Perhaps it would be useful -to do the same substraction while typesetting. - -@d print_lc_hex(#)==l:=#; - if l<10 then print_char(l+"0") else print_char(l-10+"a"); - -@= -function pool_to_unichar(@!t:pool_pointer):ASCII_code; -var a,result:@!ASCII_code; {a utf char} -b:@!quarterword; { a utf nibble} -begin - b := str_pool[t]; - if b<=@"7F then - a := b - else if b>=@"F0 then begin - a := (b-@"F0) * 64; - b := str_pool[t+1]; - a := (a + (b-128)) * 64; - b := str_pool[t+2]; - a := (a + (b-128)) * 64; - b := str_pool[t+3]; - a := a + (b-128); - end - else if b>=@"E0 then begin - a := (b-@"E0) * 64; - b := str_pool[t+1]; - a := (a + (b-128)) * 64; - b := str_pool[t+2]; - a := a + (b-128); - end - else if b>=@"C0 then begin - a := (b-@"C0) * 64; - b := str_pool[t+1]; - a := a + (b-128); - end - else begin { NI: this is an encoding error } - wlog_ln('! Pool contains an invalid utf-8 sequence'); - wterm_ln('! Pool contains an invalid utf-8 sequence'); -@.Text line contains...@> - help2("A funny symbol somehow ended up in the string pool.")@/ - ("Just continue, I'll change it to 0xFFFD.");@/ - deletions_allowed:=false; error; deletions_allowed:=true; - a:=@"FFFD; - end; -result := a; -pool_to_unichar := result; -end ; - -procedure print(@!s:integer); {prints string |s|} -label exit; -var j:pool_pointer; {current character code position} -@!v:integer; { a unicode char } -begin if s>=str_ptr then s:="???" {this can't happen} -@.???@> -else if spseudo) then - begin print_char(s); return; {internal strings are not expanded} - end; - if (@) then - if selector=@"110000 then - print_char(s-@"110000) - else begin - print_char(@"F0 + (s div @"40000)); - print_char(@"80 + ((s mod @"40000) div @"1000)); - print_char(@"80 + (((s mod @"40000) mod @"1000) div @"40)); - print_char(@"80 + (((s mod @"40000) mod @"1000) mod @"40)); - end; - end; - return; - end; - end; -j:=str_start_macro(s); -while j0)and(odd(selector)))or@| - ((file_offset>0)and(selector>=log_only)) then print_ln; -print(s); -end; - -procedure print_nlp; {move to beginning of a line} -begin if ((term_offset>0)and(odd(selector)))or@| - ((file_offset>0)and(selector>=log_only)) then print_ln; -end; - -@ |slow_print| is the same as |print| nowadays, but the name is kept for now. - -@= -procedure slow_print(@!s:integer); {prints string |s|} -begin print(s); -end; - -@ Here is the very first thing that \TeX\ prints: a headline that identifies -the version number and format package. The |term_offset| variable is temporarily -incorrect, but the discrepancy is not serious since we assume that the banner -and format identifier together will occupy at most |max_print_line| -character positions. - -@= -print_banner; - -@ The procedure |print_nl| is like |print|, but it makes sure that the -string appears at the beginning of a new line. (moved) - -@= - -@ The procedure |print_esc| prints a string that is preceded by -the user's escape character (which is usually a backslash). - -@= -procedure print_esc(@!s:str_number); {prints escape character, then |s|} -var c:integer; {the escape character code} -begin @; -if c>=0 then if c= -procedure print_the_digs(@!k:eight_bits); - {prints |dig[k-1]|$\,\ldots\,$|dig[0]|} -begin while k>0 do - begin decr(k); - if dig[k]<10 then print_char("0"+dig[k]) - else print_char("A"-10+dig[k]); - end; -end; - -@ The following procedure, which prints out the decimal representation of a -given integer |n|, has been written carefully so that it works properly -if |n=0| or if |(-n)| would cause overflow. It does not apply |mod| or |div| -to negative arguments, since such operations are not implemented consistently -by all \PASCAL\ compilers. - -@= -procedure print_int(@!n:longinteger); {prints an integer in decimal form} -var k:0..23; {index to current digit; we assume that $|n|<10^{23}$} -@!m:longinteger; {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; - -@ Here is a trivial procedure to print two digits; it is usually called with -a parameter in the range |0<=n<=99|. - -@p procedure print_two(@!n:integer); {prints two least significant digits} -begin n:=abs(n) mod 100; print_char("0"+(n div 10)); -print_char("0"+(n mod 10)); -end; - -@ Hexadecimal printing of nonnegative integers is accomplished by |print_hex|. - -@p procedure print_hex(@!n:integer); - {prints a positive integer in hexadecimal form} -var k:0..22; {index to current digit; we assume that $0\L n<16^{22}$} -begin k:=0; print_char(""""); -repeat dig[k]:=n mod 16; n:=n div 16; incr(k); -until n=0; -print_the_digs(k); -end; - -@ Old versions of \TeX\ needed a procedure called |print_ASCII| whose function -is now subsumed by |print|. We retain the old name here as a possible aid to -future software arch\ae ologists. - -@d print_ASCII == print -@d print_font_name(#)==begin print(tex_font_name(#)); flush_string; end - -@ Roman numerals are produced by the |print_roman_int| routine. Readers -who like puzzles might enjoy trying to figure out how this tricky code -works; therefore no explanation will be given. Notice that 1990 yields -\.{mcmxc}, not \.{mxm}. - -@p procedure print_roman_int(@!n:integer); -label exit; -var j,@!k: pool_pointer; {mysterious indices into |str_pool|} -@!u,@!v: nonnegative_integer; {mysterious numbers} -begin j:=str_start_macro("m2d5c2l5x2v5i"); v:=1000; -loop@+ begin while n>=v do - begin print_char(so(str_pool[j])); n:=n-v; - end; - if n<=0 then return; {nonpositive input produces no output} - k:=j+2; u:=v div (so(str_pool[k-1])-"0"); - if str_pool[k-1]=si("2") then - begin k:=k+2; u:=u div (so(str_pool[k-1])-"0"); - end; - if n+u>=v then - begin print_char(so(str_pool[k])); n:=n+u; - end - else begin j:=j+2; v:=v div (so(str_pool[j-1])-"0"); - end; - end; -exit:end; - -@ The |print| subroutine will not print a string that is still being -created. The following procedure will. - -@p procedure print_current_string; {prints a yet-unmade string} -var j:pool_pointer; {points to current character code} -begin j:=str_start_macro(str_ptr); -while j= -procedure prompt_input(s:str_number); -begin wake_up_terminal; print(s); term_input; -end; - -@ -@p procedure term_input; {gets a line from the terminal} -var k:0..buf_size; {index into |buffer|} -begin update_terminal; {now the user sees the prompt for sure} -if not input_ln(term_in,true) -then fatal_error("End of file on the terminal!"); -@.End of file on the terminal@> -term_offset:=0; {the user's line ended with \<\rm return>} -decr(selector); {prepare to echo the input} -if last<>first then for k:=first to last-1 do print(buffer[k]); -print_ln; incr(selector); {restore previous status} -end; - -@* \[6] Reporting errors. -When something anomalous is detected, \TeX\ typically does something like this: -$$\vbox{\halign{#\hfil\cr -|print_err("Something anomalous has been detected");|\cr -|help3("This is the first line of my offer to help.")|\cr -|("This is the second line. I'm trying to")|\cr -|("explain the best way for you to proceed.");|\cr -|error;|\cr}}$$ -A two-line help message would be given using |help2|, etc.; these informal -helps should use simple vocabulary that complements the words used in the -official error message that was printed. (Outside the U.S.A., the help -messages should preferably be translated into the local vernacular. Each -line of help is at most 60 characters long, in the present implementation, -so that |max_print_line| will not be exceeded.) - -The |print_err| procedure supplies a `\.!' before the official message, -and makes sure that the terminal is awake if a stop is going to occur. -The |error| procedure supplies a `\..' after the official message, then it -shows the location of the error; and if |interaction=error_stop_mode|, -it also enters into a dialog with the user, during which time the help -message may be printed. -@^system dependencies@> - -@ The global variable |interaction| has four settings, representing increasing -amounts of user interaction: - -@d batch_mode=0 {omits all stops and omits terminal output} -@d nonstop_mode=1 {omits all stops} -@d scroll_mode=2 {omits error stops} -@d error_stop_mode=3 {stops at every opportunity to interact} -@d print_err(#)==begin if interaction=error_stop_mode then wake_up_terminal; - print_nl("! "); print(#); - last_error:=#; end -@d print_warn(#)==begin if interaction=error_stop_mode then wake_up_terminal; - if prepend_nl then begin print_nl(""); print_ln end; - print_nl(#); - end - -@= -@!interaction:batch_mode..error_stop_mode; {current level of interaction} -@!last_error:str_number; - -@ @=interaction:=error_stop_mode; - -@ \TeX\ is careful not to call |error| when the print |selector| setting -might be unusual. The only possible values of |selector| at the time of -error messages are - -\yskip\hang|no_print| (when |interaction=batch_mode| - and |log_file| not yet open); - -\hang|term_only| (when |interaction>batch_mode| and |log_file| not yet open); - -\hang|log_only| (when |interaction=batch_mode| and |log_file| is open); - -\hang|term_and_log| (when |interaction>batch_mode| and |log_file| is open). - -@= -if interaction=batch_mode then selector:=no_print@+else selector:=term_only - -@ A global variable |deletions_allowed| is set |false| if the |get_next| -routine is active when |error| is called; this ensures that |get_next| -and related routines like |get_token| will never be called recursively. -A similar interlock is provided by |set_box_allowed|. -@^recursion@> - -The global variable |history| records the worst level of error that -has been detected. It has four possible values: |spotless|, |warning_issued|, -|error_message_issued|, and |fatal_error_stop|. - -Another global variable, |error_count|, is increased by one when an -|error| occurs without an interactive dialog, and it is reset to zero at -the end of every paragraph. If |error_count| reaches 100, \TeX\ decides -that there is no point in continuing further. - -@d spotless=0 {|history| value when nothing has been amiss yet} -@d warning_issued=1 {|history| value when |begin_diagnostic| has been called} -@d error_message_issued=2 {|history| value when |error| has been called} -@d fatal_error_stop=3 {|history| value when termination was premature} - -@= -@!deletions_allowed:boolean; {is it safe for |error| to call |get_token|?} -@!set_box_allowed:boolean; {is it safe to do a \.{\\setbox} assignment?} -@!history:spotless..fatal_error_stop; {has the source input been clean so far?} -@!error_count:-1..100; {the number of scrolled errors since the - last paragraph ended} - -@ The value of |history| is initially |fatal_error_stop|, but it will -be changed to |spotless| if \TeX\ survives the initialization process. - -@= -deletions_allowed:=true; set_box_allowed:=true; -error_count:=0; {|history| is initialized elsewhere} - -@ Since errors can be detected almost anywhere in \TeX, we want to declare the -error procedures near the beginning of the program. But the error procedures -in turn use some other procedures, which need to be declared |forward| -before we get to |error| itself. - -It is possible for |error| to be called recursively if some error arises -when |get_token| is being used to delete a token, and/or if some fatal error -occurs while \TeX\ is trying to fix a non-fatal one. But such recursion -@^recursion@> -is never more than two levels deep. - -@= -procedure@?normalize_selector; forward;@t\2@>@/ -procedure@?get_token; forward;@t\2@>@/ -procedure@?term_input; forward;@t\2@>@/ -procedure@?show_context; forward;@t\2@>@/ -procedure@?begin_file_reading; forward;@t\2@>@/ -procedure@?open_log_file; forward;@t\2@>@/ -procedure@?close_files_and_terminate; forward;@t\2@>@/ -procedure@?clear_for_error_prompt; forward;@t\2@>@/ -procedure@?give_err_help; forward;@t\2@>@/ -@t\4\hskip-\fontdimen2\font@>@;@+@!debug@+procedure@?debug_help; - forward;@;@+gubed - -@ Individual lines of help are recorded in the array |help_line|, which -contains entries in positions |0..(help_ptr-1)|. They should be printed -in reverse order, i.e., with |help_line[0]| appearing last. - -@d hlp1(#)==help_line[0]:=#;@+end -@d hlp2(#)==help_line[1]:=#; hlp1 -@d hlp3(#)==help_line[2]:=#; hlp2 -@d hlp4(#)==help_line[3]:=#; hlp3 -@d hlp5(#)==help_line[4]:=#; hlp4 -@d hlp6(#)==help_line[5]:=#; hlp5 -@d help0==help_ptr:=0 {sometimes there might be no help} -@d help1==@+begin help_ptr:=1; hlp1 {use this with one help line} -@d help2==@+begin help_ptr:=2; hlp2 {use this with two help lines} -@d help3==@+begin help_ptr:=3; hlp3 {use this with three help lines} -@d help4==@+begin help_ptr:=4; hlp4 {use this with four help lines} -@d help5==@+begin help_ptr:=5; hlp5 {use this with five help lines} -@d help6==@+begin help_ptr:=6; hlp6 {use this with six help lines} - -@p -procedure dohelp5 (@!a,b,c,d,e:str_number); -begin - help5(a)(b)(c)(d)(e); -end; -@# -procedure dohelp4 (@!a,b,c,d:str_number); -begin - help4(a)(b)(c)(d); -end; -@# -procedure dohelp3 (@!a,b,c:str_number); -begin - help3(a)(b)(c); -end; -@# -procedure dohelp2 (@!a,b:str_number); -begin - help2(a)(b); -end; -@# -procedure dohelp1 (@!a:str_number); -begin - help1(a); -end; -@# -procedure dohelp0; -begin - help0; -end; -@# -procedure do_print_err (s:str_number); -begin - print_err(s); -end; - -@ @= -@!help_line:array[0..5] of str_number; {helps for the next |error|} -@!help_ptr:0..6; {the number of help lines present} -@!use_err_help:boolean; {should the |err_help| list be shown?} - -@ @= -help_ptr:=0; use_err_help:=false; - -@ The |jump_out| procedure just cuts across all active procedure levels and -goes to |end_of_TEX|. This is the only nontrivial |@!goto| statement in the -whole program. It is used when there is no recovery from a particular error. - -Some \PASCAL\ compilers do not implement non-local |goto| statements. -@^system dependencies@> -In such cases the body of |jump_out| should simply be -`|close_files_and_terminate|;\thinspace' followed by a call on some system -procedure that quietly terminates the program. - -@= -procedure jump_out; -begin goto end_of_TEX; -end; - -@ Here now is the general |error| routine. - -@= -procedure error; {completes the job of error reporting} -label continue,exit; -var c:ASCII_code; {what the user types} -callback_id:integer; -@!s1,@!s2,@!s3,@!s4:integer; - {used to save global variables when deleting tokens} -@!t:boolean; -begin if history0 then t := run_callback(callback_id,'->'); -show_context; -if interaction=error_stop_mode then @; -incr(error_count); -if error_count=100 then - begin print_nl("(That makes 100 errors; please try again.)"); -@.That makes 100 errors...@> - history:=fatal_error_stop; jump_out; - end; -@; -exit:end; - -@ @= -loop@+begin continue: clear_for_error_prompt; prompt_input("? "); -@.?\relax@> - if last=first then return; - c:=buffer[first]; - if c>="a" then c:=c+"A"-"a"; {convert to uppercase} - @; - end - -@ It is desirable to provide an `\.E' option here that gives the user -an easy way to return from \TeX\ to the system editor, with the offending -line ready to be edited. But such an extension requires some system -wizardry, so the present implementation simply types out the name of the -file that should be -edited and the relevant line number. -@^system dependencies@> - -There is a secret `\.D' option available when the debugging routines haven't -been commented~out. -@^debugging@> - -@= -case c of -"0","1","2","3","4","5","6","7","8","9": if deletions_allowed then - @; -@t\4\4@>@;@+@!debug "D": begin debug_help; goto continue;@+end;@+gubed@/ -"E": if base_ptr>0 then - begin print_nl("You want to edit file "); -@.You want to edit file x@> - slow_print(input_stack[base_ptr].name_field); - print(" at line "); print_int(line); - interaction:=scroll_mode; jump_out; - end; -"H": @; -"I":@; -"Q","R","S":@; -"X":begin interaction:=scroll_mode; jump_out; - end; -othercases do_nothing -endcases;@/ -@ - -@ @= -begin print("Type to proceed, S to scroll future error messages,");@/ -@.Type to proceed...@> -print_nl("R to run without stopping, Q to run quietly,");@/ -print_nl("I to insert something, "); -if base_ptr>0 then print("E to edit your file,"); -if deletions_allowed then - print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,"); -print_nl("H for help, X to quit."); -end - -@ Here the author of \TeX\ apologizes for making use of the numerical -relation between |"Q"|, |"R"|, |"S"|, and the desired interaction settings -|batch_mode|, |nonstop_mode|, |scroll_mode|. -@^Knuth, Donald Ervin@> - -@= -begin error_count:=0; interaction:=batch_mode+c-"Q"; -print("OK, entering "); -case c of -"Q":begin print_esc("batchmode"); decr(selector); - end; -"R":print_esc("nonstopmode"); -"S":print_esc("scrollmode"); -end; {there are no other cases} -print("..."); print_ln; update_terminal; return; -end - -@ When the following code is executed, |buffer[(first+1)..(last-1)]| may -contain the material inserted by the user; otherwise another prompt will -be given. In order to understand this part of the program fully, you need -to be familiar with \TeX's input stacks. - -@= -begin begin_file_reading; {enter a new syntactic level for terminal input} -{now |state=mid_line|, so an initial blank space will count as a blank} -if last>first+1 then - begin loc:=first+1; buffer[first]:=" "; - end -else begin prompt_input("insert>"); loc:=first; -@.insert>@> - end; -first:=last; -cur_input.limit_field:=last-1; {no |end_line_char| ends this line} -return; -end - -@ We allow deletion of up to 99 tokens at a time. - -@= -begin s1:=cur_tok; s2:=cur_cmd; s3:=cur_chr; s4:=align_state; -align_state:=1000000; OK_to_interrupt:=false; -if (last>first+1) and (buffer[first+1]>="0")and(buffer[first+1]<="9") then - c:=c*10+buffer[first+1]-"0"*11 -else c:=c-"0"; -while c>0 do - begin get_token; {one-level recursive call of |error| is possible} - decr(c); - end; -cur_tok:=s1; cur_cmd:=s2; cur_chr:=s3; align_state:=s4; OK_to_interrupt:=true; -help2("I have just deleted some text, as you asked.")@/ -("You can now delete more, or insert, or whatever."); -show_context; goto continue; -end - -@ @= -begin if use_err_help then - begin give_err_help; use_err_help:=false; - end -else begin if help_ptr=0 then - help2("Sorry, I don't know how to help in this situation.")@/ - @t\kern1em@>("Maybe you should try asking a human?"); - repeat decr(help_ptr); print(help_line[help_ptr]); print_ln; - until help_ptr=0; - end; -help4("Sorry, I already gave what help I could...")@/ - ("Maybe you should try asking a human?")@/ - ("An error might have occurred before I noticed any problems.")@/ - ("``If all else fails, read the instructions.''");@/ -goto continue; -end - -@ @= -if interaction>batch_mode then decr(selector); {avoid terminal output} -if use_err_help then - begin print_ln; give_err_help; - end -else while help_ptr>0 do - begin decr(help_ptr); print_nl(help_line[help_ptr]); - end; -print_ln; -if interaction>batch_mode then incr(selector); {re-enable terminal output} -print_ln - -@ A dozen or so error messages end with a parenthesized integer, so we -save a teeny bit of program space by declaring the following procedure: - -@p procedure int_error(@!n:integer); -begin print(" ("); print_int(n); print_char(")"); error; -end; - -@ In anomalous cases, the print selector might be in an unknown state; -the following subroutine is called to fix things just enough to keep -running a bit longer. - -@p procedure normalize_selector; -begin if log_opened then selector:=term_and_log -else selector:=term_only; -if job_name=0 then open_log_file; -if interaction=batch_mode then decr(selector); -end; - -@ The following procedure prints \TeX's last words before dying. - -@d succumb==begin if interaction=error_stop_mode then - interaction:=scroll_mode; {no more interaction} - if log_opened then error; - @!debug if interaction>batch_mode then debug_help;@+gubed@;@/ - history:=fatal_error_stop; jump_out; {irrecoverable error} - end - -@= -procedure fatal_error(@!s:str_number); {prints |s|, and that's it} -begin normalize_selector;@/ -print_err("Emergency stop"); help1(s); succumb; -@.Emergency stop@> -end; - -@ Here is the most dreaded error message. - -@= -procedure lua_norm_error(@!s:str_number); {lua found a problem} -var saved_new_line_char: integer; -begin -saved_new_line_char:=new_line_char; -new_line_char:=10; -print_err("LuaTeX error "); print(s); -help2("The lua interpreter ran into a problem, so the")@/ - ("remainder of this lua chunk will be ignored."); -error; -new_line_char:=saved_new_line_char; -end; - -procedure lua_fatal_error(@!s:str_number); {lua found a problem} -begin new_line_char:=10; normalize_selector; -print_err("LuaTeX fatal error "); print(s); -succumb; -end; - -procedure overflow(@!s:str_number;@!n:integer); {stop due to finiteness} -begin normalize_selector; -print_err("TeX capacity exceeded, sorry ["); -@.TeX capacity exceeded ...@> -print(s); print_char("="); print_int(n); print_char("]"); -help2("If you really absolutely need more capacity,")@/ - ("you can ask a wizard to enlarge me."); -succumb; -end; - -procedure overflow_ocp_buf_size; -begin -overflow("ocp_buf_size",ocp_buf_size); -end; - -procedure overflow_ocp_stack_size; -begin -overflow("ocp_stack_size",ocp_stack_size); -end; - - -@ The program might sometime run completely amok, at which point there is -no choice but to stop. If no previous error has been detected, that's bad -news; a message is printed that is really intended for the \TeX\ -maintenance person instead of the user (unless the user has been -particularly diabolical). The index entries for `this can't happen' may -help to pinpoint the problem. -@^dry rot@> - -@= -procedure confusion(@!s:str_number); - {consistency check violated; |s| tells where} -begin normalize_selector; -if history - help1("I'm broken. Please show this to someone who can fix can fix"); - end -else begin print_err("I can't go on meeting you like this"); -@.I can't go on...@> - help2("One of your faux pas seems to have wounded me deeply...")@/ - ("in fact, I'm barely conscious. Please fix it and try again."); - end; -succumb; -end; - -@ Users occasionally want to interrupt \TeX\ while it's running. -If the \PASCAL\ runtime system allows this, one can implement -a routine that sets the global variable |interrupt| to some nonzero value -when such an interrupt is signalled. Otherwise there is probably at least -a way to make |interrupt| nonzero using the \PASCAL\ debugger. -@^system dependencies@> -@^debugging@> - -@= -@!interrupt:integer; {should \TeX\ pause for instructions?} -@!OK_to_interrupt:boolean; {should interrupts be observed?} -@!static_int_base:integer; {C version of |int_base|} -@!static_glue_base:integer; {C version of |glue_base|} -@!static_dimen_base:integer; {C version of |dimen_base|} -@!static_local_base:integer; {C version of |local_base|} - -@ @p procedure check_interrupt; -begin -if interrupt<>0 then pause_for_instructions; -end; - - -@ @= -interrupt:=0; OK_to_interrupt:=true; - -@ When an interrupt has been detected, the program goes into its -highest interaction level and lets the user have nearly the full flexibility of -the |error| routine. \TeX\ checks for interrupts only at times when it is -safe to do this. - -@p procedure pause_for_instructions; -begin if OK_to_interrupt then - begin interaction:=error_stop_mode; - if (selector=log_only)or(selector=no_print) then - incr(selector); - print_err("Interruption"); -@.Interruption@> - help3("You rang?")@/ - ("Try to insert some instructions for me (e.g.,`I\showlists'),")@/ - ("unless you just want to quit by typing `X'."); - deletions_allowed:=false; error; deletions_allowed:=true; - interrupt:=0; - end; -end; - -@* \[7] Arithmetic with scaled dimensions. -The principal computations performed by \TeX\ are done entirely in terms of -integers less than $2^{31}$ in magnitude; and divisions are done only when both -dividend and divisor are nonnegative. Thus, the arithmetic specified in this -program can be carried out in exactly the same way on a wide variety of -computers, including some small ones. Why? Because the arithmetic -calculations need to be spelled out precisely in order to guarantee that -\TeX\ will produce identical output on different machines. If some -quantities were rounded differently in different implementations, we would -find that line breaks and even page breaks might occur in different places. -Hence the arithmetic of \TeX\ has been designed with care, and systems that -claim to be implementations of \TeX82 should follow precisely the -@:TeX82}{\TeX82@> -calculations as they appear in the present program. - -(Actually there are three places where \TeX\ uses |div| with a possibly negative -numerator. These are harmless; see |div| in the index. Also if the user -sets the \.{\\time} or the \.{\\year} to a negative value, some diagnostic -information will involve negative-numerator division. The same remarks -apply for |mod| as well as for |div|.) - -@ Here is a routine that calculates half of an integer, using an -unambiguous convention with respect to signed odd numbers. - -@p function half(@!x:integer):integer; -begin if odd(x) then half:=(x+1) div 2 -else half:=x @!div 2; -end; - -@ Fixed-point arithmetic is done on {\sl scaled integers\/} that are multiples -of $2^{-16}$. In other words, a binary point is assumed to be sixteen bit -positions from the right end of a binary computer word. - -@d unity == @'200000 {$2^{16}$, represents 1.00000} -@d two == @'400000 {$2^{17}$, represents 2.00000} - -@= -@!scaled = integer; {this type is used for scaled integers} -@!nonnegative_integer=0..@'17777777777; {$0\L x<2^{31}$} -@!small_number=0..63; {this type is self-explanatory} - -@ The following function is used to create a scaled integer from a given decimal -fraction $(.d_0d_1\ldots d_{k-1})$, where |0<=k<=17|. The digit $d_i$ is -given in |dig[i]|, and the calculation produces a correctly rounded result. - -@p function round_decimals(@!k:small_number) : scaled; - {converts a decimal fraction} -var a:integer; {the accumulator} -begin a:=0; -while k>0 do - begin decr(k); a:=(a+dig[k]*two) div 10; - end; -round_decimals:=(a+1) div 2; -end; - -@ Conversely, here is a procedure analogous to |print_int|. If the output -of this procedure is subsequently read by \TeX\ and converted by the -|round_decimals| routine above, it turns out that the original value will -be reproduced exactly; the ``simplest'' such decimal number is output, -but there is always at least one digit following the decimal point. - -The invariant relation in the \&{repeat} loop is that a sequence of -decimal digits yet to be printed will yield the original number if and only if -they form a fraction~$f$ in the range $s-\delta\L10\cdot2^{16}funity then s:=s+@'100000-50000; {round the last digit} -print_char("0"+(s div unity)); s:=10*(s mod unity); delta:=delta*10; -until s<=delta; -end; - -@ Physical sizes that a \TeX\ user specifies for portions of documents are -represented internally as scaled points. Thus, if we define an `sp' (scaled -@^sp@> -point) as a unit equal to $2^{-16}$ printer's points, every dimension -inside of \TeX\ is an integer number of sp. There are exactly -4,736,286.72 sp per inch. Users are not allowed to specify dimensions -larger than $2^{30}-1$ sp, which is a distance of about 18.892 feet (5.7583 -meters); two such quantities can be added without overflow on a 32-bit -computer. - -The present implementation of \TeX\ does not check for overflow when -@^overflow in arithmetic@> -dimensions are added or subtracted. This could be done by inserting a -few dozen tests of the form `\ignorespaces|if x>=@'10000000000 then -@t\\{report\_overflow}@>|', but the chance of overflow is so remote that -such tests do not seem worthwhile. - -\TeX\ needs to do only a few arithmetic operations on scaled quantities, -other than addition and subtraction, and the following subroutines do most of -the work. A single computation might use several subroutine calls, and it is -desirable to avoid producing multiple error messages in case of arithmetic -overflow; so the routines set the global variable |arith_error| to |true| -instead of reporting errors directly to the user. Another global variable, -|remainder|, holds the remainder after a division. - -@= -@!arith_error:boolean; {has arithmetic overflow occurred recently?} -@!remainder:scaled; {amount subtracted to get an exact division} - -@ The first arithmetical subroutine we need computes $nx+y$, where |x| -and~|y| are |scaled| and |n| is an integer. We will also use it to -multiply integers. - -@d nx_plus_y(#)==mult_and_add(#,@'7777777777) -@d mult_integers(#)==mult_and_add(#,0,@'17777777777) - -@p function mult_and_add(@!n:integer;@!x,@!y,@!max_answer:scaled):scaled; -begin if n<0 then - begin negate(x); negate(n); - end; -if n=0 then mult_and_add:=y -else if ((x<=(max_answer-y) div n)and(-x<=(max_answer+y) div n)) then - mult_and_add:=n*x+y -else begin arith_error:=true; mult_and_add:=0; - end; -end; - -@ We also need to divide scaled dimensions by integers. - -@p function x_over_n(@!x:scaled;@!n:integer):scaled; -var negative:boolean; {should |remainder| be negated?} -begin negative:=false; -if n=0 then - begin arith_error:=true; x_over_n:=0; remainder:=x; - end -else begin if n<0 then - begin negate(x); negate(n); negative:=true; - end; - if x>=0 then - begin x_over_n:=x div n; remainder:=x mod n; - end - else begin x_over_n:=-((-x) div n); remainder:=-((-x) mod n); - end; - end; -if negative then negate(remainder); -end; - -@ Then comes the multiplication of a scaled number by a fraction |n/d|, -where |n| and |d| are nonnegative integers |<=@t$2^{16}$@>| and |d| is -positive. It would be too dangerous to multiply by~|n| and then divide -by~|d|, in separate operations, since overflow might well occur; and it -would be too inaccurate to divide by |d| and then multiply by |n|. Hence -this subroutine simulates 1.5-precision arithmetic. - -@p function xn_over_d(@!x:scaled; @!n,@!d:integer):scaled; -var positive:boolean; {was |x>=0|?} -@!t,@!u,@!v:nonnegative_integer; {intermediate quantities} -begin if x>=0 then positive:=true -else begin negate(x); positive:=false; - end; -t:=(x mod @'100000)*n; -u:=(x div @'100000)*n+(t div @'100000); -v:=(u mod d)*@'100000 + (t mod @'100000); -if u div d>=@'100000 then arith_error:=true -else u:=@'100000*(u div d) + (v div d); -if positive then - begin xn_over_d:=u; remainder:=v mod d; - end -else begin xn_over_d:=-u; remainder:=-(v mod d); - end; -end; - -@ The next subroutine is used to compute the ``badness'' of glue, when a -total~|t| is supposed to be made from amounts that sum to~|s|. According -to {\sl The \TeX book}, the badness of this situation is $100(t/s)^3$; -however, badness is simply a heuristic, so we need not squeeze out the -last drop of accuracy when computing it. All we really want is an -approximation that has similar properties. -@:TeXbook}{\sl The \TeX book@> - -The actual method used to compute the badness is easier to read from the -program than to describe in words. It produces an integer value that is a -reasonably close approximation to $100(t/s)^3$, and all implementations -of \TeX\ should use precisely this method. Any badness of $2^{13}$ or more is -treated as infinitely bad, and represented by 10000. - -It is not difficult to prove that $$\hbox{|badness(t+1,s)>=badness(t,s) ->=badness(t,s+1)|}.$$ The badness function defined here is capable of -computing at most 1095 distinct values, but that is plenty. - -@d inf_bad = 10000 {infinitely bad value} - -@p function badness(@!t,@!s:scaled):halfword; {compute badness, given |t>=0|} -var r:integer; {approximation to $\alpha t/s$, where $\alpha^3\approx - 100\cdot2^{18}$} -begin if t=0 then badness:=0 -else if s<=0 then badness:=inf_bad -else begin if t<=7230584 then r:=(t*297) div s {$297^3=99.94\times2^{18}$} - else if s>=1663497 then r:=t div (s div 297) - else r:=t; - if r>1290 then badness:=inf_bad {$1290^3<2^{31}<1291^3$} - else badness:=(r*r*r+@'400000) div @'1000000; - end; {that was $r^3/2^{18}$, rounded to the nearest integer} -end; - -@ When \TeX\ ``packages'' a list into a box, it needs to calculate the -proportionality ratio by which the glue inside the box should stretch -or shrink. This calculation does not affect \TeX's decision making, -so the precise details of rounding, etc., in the glue calculation are not -of critical importance for the consistency of results on different computers. - -We shall use the type |glue_ratio| for such proportionality ratios. -A glue ratio should take the same amount of memory as an -|integer| (usually 32 bits) if it is to blend smoothly with \TeX's -other data structures. Thus |glue_ratio| should be equivalent to -|short_real| in some implementations of \PASCAL. Alternatively, -it is possible to deal with glue ratios using nothing but fixed-point -arithmetic; see {\sl TUGboat \bf3},1 (March 1982), 10--27. (But the -routines cited there must be modified to allow negative glue ratios.) -@^system dependencies@> - -@d set_glue_ratio_zero(#) == #:=0.0 {store the representation of zero ratio} -@d set_glue_ratio_one(#) == #:=1.0 {store the representation of unit ratio} -@d float(#) == # {convert from |glue_ratio| to type |real|} -@d unfloat(#) == # {convert from |real| to type |glue_ratio|} -@d float_constant(#) == #.0 {convert |integer| constant to |real|} - -@= -@!glue_ratio=real; {one-word representation of a glue expansion factor} - -@* \[7b] Random numbers. - -\font\tenlogo=logo10 % font used for the METAFONT logo -\def\MP{{\tenlogo META}\-{\tenlogo POST}} - -This section is (almost) straight from MetaPost. I had to change -the types (use |integer| instead of |fraction|), but that should -not have any influence on the actual calculations (the original -comments refer to quantities like |fraction_four| ($2^{30}$), and -that is the same as the numeric representation of |max_dimen|). - -I've copied the low-level variables and routines that are needed, but -only those (e.g. |m_log|), not the accompanying ones like |m_exp|. Most -of the following low-level numeric routines are only needed within the -calculation of |norm_rand|. I've been forced to rename |make_fraction| -to |make_frac| because TeX already has a routine by that name with -a wholly different function (it creates a |fraction_noad| for math -typesetting) -- Taco - -And now let's complete our collection of numeric utility routines -by considering random number generation. -\MP\ generates pseudo-random numbers with the additive scheme recommended -in Section 3.6 of {\sl The Art of Computer Programming}; however, the -results are random fractions between 0 and |fraction_one-1|, inclusive. - -There's an auxiliary array |randoms| that contains 55 pseudo-random -fractions. Using the recurrence $x_n=(x_{n-55}-x_{n-31})\bmod 2^{28}$, -we generate batches of 55 new $x_n$'s at a time by calling |new_randoms|. -The global variable |j_random| tells which element has most recently -been consumed. - -@= -@!randoms:array[0..54] of integer; {the last 55 random values generated} -@!j_random:0..54; {the number of unused |randoms|} -@!random_seed:scaled; {the default random seed} - -@ A small bit of metafont is needed. - -@d fraction_half==@'1000000000 {$2^{27}$, represents 0.50000000} -@d fraction_one==@'2000000000 {$2^{28}$, represents 1.00000000} -@d fraction_four==@'10000000000 {$2^{30}$, represents 4.00000000} -@d el_gordo == @'17777777777 {$2^{31}-1$, the largest value that \MP\ likes} -@d halfp(#)==(#) div 2 -@d double(#) == #:=#+# {multiply a variable by two} - -@ The |make_frac| routine produces the |fraction| equivalent of -|p/q|, given integers |p| and~|q|; it computes the integer -$f=\lfloor2^{28}p/q+{1\over2}\rfloor$, when $p$ and $q$ are -positive. If |p| and |q| are both of the same scaled type |t|, -the ``type relation'' |make_frac(t,t)=fraction| is valid; -and it's also possible to use the subroutine ``backwards,'' using -the relation |make_frac(t,fraction)=t| between scaled types. - -If the result would have magnitude $2^{31}$ or more, |make_frac| -sets |arith_error:=true|. Most of \MP's internal computations have -been designed to avoid this sort of error. - -If this subroutine were programmed in assembly language on a typical -machine, we could simply compute |(@t$2^{28}$@>*p)div q|, since a -double-precision product can often be input to a fixed-point division -instruction. But when we are restricted to \PASCAL\ arithmetic it -is necessary either to resort to multiple-precision maneuvering -or to use a simple but slow iteration. The multiple-precision technique -would be about three times faster than the code adopted here, but it -would be comparatively long and tricky, involving about sixteen -additional multiplications and divisions. - -This operation is part of \MP's ``inner loop''; indeed, it will -consume nearly 10\pct! of the running time (exclusive of input and output) -if the code below is left unchanged. A machine-dependent recoding -will therefore make \MP\ run faster. The present implementation -is highly portable, but slow; it avoids multiplication and division -except in the initial stage. System wizards should be careful to -replace it with a routine that is guaranteed to produce identical -results in all cases. -@^system dependencies@> - -As noted below, a few more routines should also be replaced by machine-dependent -code, for efficiency. But when a procedure is not part of the ``inner loop,'' -such changes aren't advisable; simplicity and robustness are -preferable to trickery, unless the cost is too high. -@^inner loop@> - -@p function make_frac(@!p,@!q:integer):integer; -var @!f:integer; {the fraction bits, with a leading 1 bit} -@!n:integer; {the integer part of $\vert p/q\vert$} -@!negative:boolean; {should the result be negated?} -@!be_careful:integer; {disables certain compiler optimizations} -begin if p>=0 then negative:=false -else begin negate(p); negative:=true; - end; -if q<=0 then - begin debug if q=0 then confusion("/");@;@+gubed@;@/ -@:this can't happen /}{\quad \./@> - negate(q); negative:=not negative; - end; -n:=p div q; p:=p mod q; -if n>=8 then - begin arith_error:=true; - if negative then make_frac:=-el_gordo@+else make_frac:=el_gordo; - end -else begin n:=(n-1)*fraction_one; - @; - if negative then make_frac:=-(f+n)@+else make_frac:=f+n; - end; -end; - -@ The |repeat| loop here preserves the following invariant relations -between |f|, |p|, and~|q|: -(i)~|0<=p - -@= -f:=1; -repeat be_careful:=p-q; p:=be_careful+p; -if p>=0 then f:=f+f+1 -else begin double(f); p:=p+q; - end; -until f>=fraction_one; -be_careful:=p-q; -if be_careful+p>=0 then incr(f) - -@ - -@p function take_frac(@!q:integer;@!f:integer):integer; -var @!p:integer; {the fraction so far} -@!negative:boolean; {should the result be negated?} -@!n:integer; {additional multiple of $q$} -@!be_careful:integer; {disables certain compiler optimizations} -begin @=0| and |q>0|@>; -if f; -be_careful:=n-el_gordo; -if be_careful+p>0 then - begin arith_error:=true; n:=el_gordo-p; - end; -if negative then take_frac:=-(n+p) -else take_frac:=n+p; -end; - -@ @=0| and |q>0|@>= -if f>=0 then negative:=false -else begin negate(f); negative:=true; - end; -if q<0 then - begin negate(q); negative:=not negative; - end; - -@ The invariant relations in this case are (i)~$\lfloor(qf+p)/2^k\rfloor -=\lfloor qf_0/2^{28}+{1\over2}\rfloor$, where $k$ is an integer and -$f_0$ is the original value of~$f$; (ii)~$2^k\L f<2^{k+1}$. -@^inner loop@> - -@= -p:=fraction_half; {that's $2^{27}$; the invariants hold now with $k=28$} -if q= -@!two_to_the:array[0..30] of integer; {powers of two} -@!spec_log:array[1..28] of integer; {special logarithms} - - -@ @= -two_to_the[0]:=1; -for k:=1 to 30 do two_to_the[k]:=2*two_to_the[k-1]; -spec_log[1]:=93032640; -spec_log[2]:=38612034; -spec_log[3]:=17922280; -spec_log[4]:=8662214; -spec_log[5]:=4261238; -spec_log[6]:=2113709; -spec_log[7]:=1052693; -spec_log[8]:=525315; -spec_log[9]:=262400; -spec_log[10]:=131136; -spec_log[11]:=65552; -spec_log[12]:=32772; -spec_log[13]:=16385; -for k:=14 to 27 do spec_log[k]:=two_to_the[27-k]; -spec_log[28]:=1; - -@ - -@p function m_log(@!x:integer):integer; -var @!y,@!z:integer; {auxiliary registers} -@!k:integer; {iteration counter} -begin if x<=0 then @ -else begin y:=1302456956+4-100; {$14\times2^{27}\ln2\approx1302456956.421063$} - z:=27595+6553600; {and $2^{16}\times .421063\approx 27595$} - while xfraction_four+4 do - @; - m_log:=y div 8; - end; -end; - -@ @= -begin z:=((x-1) div two_to_the[k])+1; {$z=\lceil x/2^k\rceil$} -while x= -begin print_err("Logarithm of "); -@.Logarithm...replaced by 0@> -print_scaled(x); print(" has been replaced by 0"); -help2("Since I don't take logs of non-positive numbers,")@/ - ("I'm zeroing this one. Proceed, with fingers crossed."); -error; m_log:=0; -end - -@ The following somewhat different subroutine tests rigorously if $ab$ is -greater than, equal to, or less than~$cd$, -given integers $(a,b,c,d)$. In most cases a quick decision is reached. -The result is $+1$, 0, or~$-1$ in the three respective cases. - -@d return_sign(#)==begin ab_vs_cd:=#; return; - end - -@p function ab_vs_cd(@!a,b,c,d:integer):integer; -label exit; -var @!q,@!r:integer; {temporary registers} -begin @=0|, |b,d>0|@>; -loop@+ begin q := a div d; r := c div b; - if q<>r then begin - if q>r then return_sign(1)@+else return_sign(-1); - end; - q := a mod d; r := c mod b; - if r=0 then begin - if q=0 then return_sign(0)@+else return_sign(1); - end; - if q=0 then return_sign(-1); - a:=b; b:=q; c:=d; d:=r; - end; {now |a>d>0| and |c>b>0|} -exit:end; - -@ @= -if a<0 then - begin negate(a); negate(b); - end; -if c<0 then - begin negate(c); negate(d); - end; -if d<=0 then - begin if b>=0 then begin - if ((a=0)or(b=0))and((c=0)or(d=0)) then return_sign(0) - else return_sign(1); - end; - if d=0 then begin - if a=0 then return_sign(0)@+else return_sign(-1); - end; - q:=a; a:=c; c:=q; q:=-b; b:=-d; d:=q; - end -else if b<=0 then - begin if b<0 then if a>0 then return_sign(-1); - if c=0 then return_sign(0) else return_sign(-1); - end - -@ To consume a random integer, the program below will say `|next_random|' -and then it will fetch |randoms[j_random]|. - -@d next_random==if j_random=0 then new_randoms - else decr(j_random) - -@p procedure new_randoms; -var @!k:0..54; {index into |randoms|} -@!x:integer; {accumulator} -begin for k:=0 to 23 do - begin x:=randoms[k]-randoms[k+31]; - if x<0 then x:=x+fraction_one; - randoms[k]:=x; - end; -for k:=24 to 54 do - begin x:=randoms[k]-randoms[k-24]; - if x<0 then x:=x+fraction_one; - randoms[k]:=x; - end; -j_random:=54; -end; - -@ To initialize the |randoms| table, we call the following routine. - -@p procedure init_randoms(@!seed:integer); -var @!j,@!jj,@!k:integer; {more or less random integers} -@!i:0..54; {index into |randoms|} -begin j:=abs(seed); -while j>=fraction_one do j:=halfp(j); -k:=1; -for i:=0 to 54 do - begin jj:=k; k:=j-k; j:=jj; - if k<0 then k:=k+fraction_one; - randoms[(i*21)mod 55]:=j; - end; -new_randoms; new_randoms; new_randoms; {``warm up'' the array} -end; - -@ To produce a uniform random number in the range |0<=u=u>x| -or |0=u=x|, given a |scaled| value~|x|, we proceed as shown here. - -Note that the call of |take_frac| will produce the values 0 and~|x| -with about half the probability that it will produce any other particular -values between 0 and~|x|, because it rounds its answers. - -@p function unif_rand(@!x:integer):integer; -var @!y:integer; {trial value} -begin next_random; y:=take_frac(abs(x),randoms[j_random]); -if y=abs(x) then unif_rand:=0 -else if x>0 then unif_rand:=y -else unif_rand:=-y; -end; - -@ Finally, a normal deviate with mean zero and unit standard deviation -can readily be obtained with the ratio method (Algorithm 3.4.1R in -{\sl The Art of Computer Programming\/}). - -@p function norm_rand:integer; -var @!x,@!u,@!l:integer; {what the book would call $2^{16}X$, $2^{28}U$, - and $-2^{24}\ln U$} -begin repeat - repeat next_random; - x:=take_frac(112429,randoms[j_random]-fraction_half); - {$2^{16}\sqrt{8/e}\approx 112428.82793$} - next_random; u:=randoms[j_random]; - until abs(x)=0; -norm_rand:=x; -end; - -@* \[8] Packed data. -In order to make efficient use of storage space, \TeX\ bases its major data -structures on a |memory_word|, which contains either a (signed) integer, -possibly scaled, or a (signed) |glue_ratio|, or a small number of -fields that are one half or one quarter of the size used for storing -integers. - -If |x| is a variable of type |memory_word|, it contains up to four -fields that can be referred to as follows: -$$\vbox{\halign{\hfil#&#\hfil&#\hfil\cr -|x|&.|int|&(an |integer|)\cr -|x|&.|sc|\qquad&(a |scaled| integer)\cr -|x|&.|gr|&(a |glue_ratio|)\cr -|x.hh.lh|, |x.hh|&.|rh|&(two halfword fields)\cr -|x.hh.b0|, |x.hh.b1|, |x.hh|&.|rh|&(two quarterword fields, one halfword - field)\cr -|x.qqqq.b0|, |x.qqqq.b1|, |x.qqqq|&.|b2|, |x.qqqq.b3|\hskip-100pt - &\qquad\qquad\qquad(four quarterword fields)\cr}}$$ -This is somewhat cumbersome to write, and not very readable either, but -macros will be used to make the notation shorter and more transparent. -The \PASCAL\ code below gives a formal definition of |memory_word| and -its subsidiary types, using packed variant records. \TeX\ makes no -assumptions about the relative positions of the fields within a word. - -We are assuming 32-bit integers, a halfword must contain at least -32 bits, and a quarterword must contain at least 16 bits. -@^system dependencies@> - -N.B.: Valuable memory space will be dreadfully wasted unless \TeX\ is compiled -by a \PASCAL\ that packs all of the |memory_word| variants into -the space of a single integer. This means, for example, that |glue_ratio| -words should be |short_real| instead of |real| on some computers. Some -\PASCAL\ compilers will pack an integer whose subrange is `|0..255|' into -an eight-bit field, but others insist on allocating space for an additional -sign bit; on such systems you can get 256 values into a quarterword only -if the subrange is `|-128..127|'. - -The present implementation tries to accommodate as many variations as possible, -so it makes few assumptions. If integers having the subrange -`|min_quarterword..max_quarterword|' can be packed into a quarterword, -and if integers having the subrange `|min_halfword..max_halfword|' -can be packed into a halfword, everything should work satisfactorily. - -It is usually most efficient to have |min_quarterword=min_halfword=0|, -so one should try to achieve this unless it causes a severe problem. -The values defined here are recommended for most 32-bit computers. - -We cannot use the full range of 32 bits in a halfword, because we have -to allow negative values for potential backend tricks like web2c's -dynamic allocation, and parshapes pointers have to be able to store at -least twice the value |max_halfword| (see below). Therefore, -|max_halfword| is $2^{30}-1$ - -@d min_quarterword=0 {smallest allowable value in a |quarterword|} -@d max_quarterword=65535 {largest allowable value in a |quarterword|} -@d min_halfword==-@"3FFFFFFF {smallest allowable value in a |halfword|} -@d max_halfword==@"3FFFFFFF {largest allowable value in a |halfword|} - -@ Here are the inequalities that the quarterword and halfword values -must satisfy (or rather, the inequalities that they mustn't satisfy): - -@= -if (min_quarterword>0)or(max_quarterword<@"7FFF) then bad:=11; -if (min_halfword>0)or(max_halfword<@"3FFFFFFF) then bad:=12; -if (min_quarterwordmax_halfword) then bad:=13; -if font_basemax_halfword)or(max_strings>max_halfword) then bad:=17; -if buf_size>max_halfword then bad:=18; -if max_quarterword-min_quarterword<@"FFFF then bad:=19; - -@ The operation of adding or subtracting |min_quarterword| occurs quite -frequently in \TeX, so it is convenient to abbreviate this operation -by using the macros |qi| and |qo| for input and output to and from -quarterword format. - -The inner loop of \TeX\ will run faster with respect to compilers -that don't optimize expressions like `|x+0|' and `|x-0|', if these -macros are simplified in the obvious way when |min_quarterword=0|. -@^inner loop@>@^system dependencies@> - -@d qi(#)==#+min_quarterword - {to put an |eight_bits| item into a quarterword} -@d qo(#)==#-min_quarterword - {to take an |eight_bits| item out of a quarterword} -@d hi(#)==#+min_halfword - {to put a sixteen-bit item into a halfword} -@d ho(#)==#-min_halfword - {to take a sixteen-bit item from a halfword} - -@ The reader should study the following definitions closely: -@^system dependencies@> - -@d sc==int {|scaled| data is equivalent to |integer|} - -@= -@!quarterword = min_quarterword..max_quarterword; {1/4 of a word} -@!halfword=min_halfword..max_halfword; {1/2 of a word} -@!two_choices = 1..2; {used when there are two variants in a record} -@!four_choices = 1..4; {used when there are four variants in a record} -@!two_halves = packed record@;@/ - @!rh:halfword; - case two_choices of - 1: (@!lh:halfword); - 2: (@!b0:quarterword; @!b1:quarterword); - end; -@!four_quarters = packed record@;@/ - @!b0:quarterword; - @!b1:quarterword; - @!b2:quarterword; - @!b3:quarterword; - end; -@!memory_word = record@;@/ - case four_choices of - 1: (@!int:integer); - 2: (@!gr:glue_ratio); - 3: (@!hh:two_halves); - 4: (@!qqqq:four_quarters); - end; -@!word_file = file of memory_word; - -@ When debugging, we may want to print a |memory_word| without knowing -what type it is; so we print it in all modes. -@^dirty \PASCAL@>@^debugging@> - -@p @!debug procedure print_word(@!w:memory_word); - {prints |w| in all ways} -begin print_int(w.int); print_char(" ");@/ -print_scaled(w.sc); print_char(" ");@/ -print_scaled(round(unity*float(w.gr))); print_ln;@/ -@^real multiplication@> -print_int(w.hh.lh); print_char("="); print_int(w.hh.b0); print_char(":"); -print_int(w.hh.b1); print_char(";"); print_int(w.hh.rh); print_char(" ");@/ -print_int(w.qqqq.b0); print_char(":"); print_int(w.qqqq.b1); print_char(":"); -print_int(w.qqqq.b2); print_char(":"); print_int(w.qqqq.b3); -end; -gubed - -@* \[9] Dynamic memory allocation. -The \TeX\ system does nearly all of its own memory allocation, so that it -can readily be transported into environments that do not have automatic -facilities for strings, garbage collection, etc., and so that it can be in -control of what error messages the user receives. The dynamic storage -requirements of \TeX\ are handled by providing two large arrays called -|fixmem| and |varmem| in which consecutive blocks of words are used as -nodes by the \TeX\ routines. - -Pointer variables are indices into this array, or into another array -called |eqtb| that will be explained later. A pointer variable might -also be a special flag that lies outside the bounds of |mem|, so we -allow pointers to assume any |halfword| value. The minimum halfword -value represents a null pointer. \TeX\ does not assume that |mem[null]| exists. - -@d pointer==halfword {a flag or a location in |mem| or |eqtb|} -@d null==0 {the null pointer} - -@= -@!temp_ptr:pointer; {a pointer variable for occasional emergency use} - -@ @= -@!smemory_word = packed record@;@/ - @!hhrh:halfword; - @!hhlh:halfword; - end; - - -@ The |mem| array is divided into two items that are allocated separately; -they grow until finding their ``natural'' size in a particular job. -Locations in |varmem| are used for storing variable-length records -consisting of two or more words each. This region -is maintained using an algorithm similar to the one described in exercise -2.5--19 of {\sl The Art of Computer Programming}. However, no size field -appears in the allocated nodes; the program is responsible for knowing the -relevant size when a node is freed. Locations in |fixmem| are used for storing -one-word records; a conventional \.{AVAIL} stack is used for allocation -in this array. - -Empirical tests show that the present implementation of \TeX\ tends to -spend about 9\pct! of its running time allocating nodes, and about 6\pct! -deallocating them after their use. - -@d fix_mem_init==10000 - -@= -@!fixmem : ^smemory_word; {the big dynamic storage area} -@!fix_mem_min : pointer; {the smallest location of one-word memory in use} -@!fix_mem_max : pointer; {the largest location of one-word memory in use} - -@ In order to study the memory requirements of particular applications, it -is possible to prepare a version of \TeX\ that keeps track of current and -maximum memory usage. When code between the delimiters |@!stat| $\ldots$ -|tats| is not ``commented out,'' \TeX\ will run a bit slower but it will -report these statistics when |tracing_stats| is sufficiently large. - -@= -@!var_used, @!dyn_used : integer; {how much memory is in use} - -@ Let's consider the one-word memory region first, since it's the -simplest. The pointer variable |fix_mem_end| holds the highest-numbered location -of |mem| that has ever been used. The free locations of |mem| that -occur between |hi_mem_min| and |fix_mem_end|, inclusive, are of type -|two_halves|, and we write |info(p)| and |link(p)| for the |lh| -and |rh| fields of |mem[p]| when it is of this type. The single-word -free locations form a linked list -$$|avail|,\;\hbox{|link(avail)|},\;\hbox{|link(link(avail))|},\;\ldots$$ -terminated by |null|. - -@d mem(#) == fixmem[#] -@d link(#) == mem(#).hhrh {the |link| field of a memory word} -@d info(#) == mem(#).hhlh {the |info| field of a memory word} - -@= -@!avail : pointer; {head of the list of available one-word nodes} -@!fix_mem_end : pointer; {the last one-word node used in |mem|} - -@ If memory is exhausted, it might mean that the user has forgotten -a right brace. We will define some procedures later that try to help -pinpoint the trouble. - -@p @@/ -@ - -@ The function |get_avail| returns a pointer to a new one-word node whose -|link| field is null. However, \TeX\ will halt if there is no more room left. -@^inner loop@> - -If the available-space list is empty, i.e., if |avail=null|, -we try first to increase |fix_mem_end|. If that cannot be done, i.e., if -|fix_mem_end=fix_mem_max|, we try to reallocate array |fixmem|. -If, that doesn't work, we have to quit. - -@p function get_avail : pointer; {single-word node allocation} -var p:pointer; {the new node being got} -t:integer; -begin p:=avail; {get top location in the |avail| stack} -if p<>null then avail:=link(avail) {and pop it off} -else if fix_mem_end - end; - memset (voidcast(fixmem+fix_mem_max+1),0,t*sizeof(smemory_word)); - fix_mem_max:=fix_mem_max+t; incr(fix_mem_end); p:=fix_mem_end; - end; -link(p):=null; {provide an oft-desired initialization of the new node} -@!stat incr(dyn_used);@+tats@;{maintain statistics} -get_avail:=p; -end; - -@ Conversely, a one-word node is recycled by calling |free_avail|. -This routine is part of \TeX's ``inner loop,'' so we want it to be fast. -@^inner loop@> - -@d free_avail(#)== {single-word node liberation} - begin link(#):=avail; avail:=#; - @!stat decr(dyn_used);@+tats@/ - end - -@ There's also a |fast_get_avail| routine, which saves the procedure-call -overhead at the expense of extra programming. This routine is used in -the places that would otherwise account for the most calls of |get_avail|. -@^inner loop@> - -@d fast_get_avail(#)==@t@>@;@/ - begin #:=avail; {avoid |get_avail| if possible, to save time} - if #=null then #:=get_avail - else begin avail:=link(#); link(#):=null; - @!stat incr(dyn_used);@+tats@/ - end; - end - -@ The procedure |flush_list(p)| frees an entire linked list of -one-word nodes that starts at position |p|. -@^inner loop@> - -@p procedure flush_list(@!p:pointer); {makes list of single-word nodes available} -var @!q,@!r:pointer; {list traversers} -begin if p<>null then - begin r:=p; - repeat q:=r; r:=link(r); @!stat decr(dyn_used);@+tats@/ - until r=null; {now |q| is the last node on the list} - link(q):=avail; avail:=p; - end; -end; - -@ The available-space list that keeps track of the variable-size portion -of |mem| is a nonempty, doubly-linked circular list of empty nodes, -pointed to by the roving pointer |rover|. - -@d vmem(#) == varmem[#] -@d vlink(#) == vmem(#).hh.rh {the |link| field of a memory word} -@d vinfo(#) == vmem(#).hh.lh {the |info| field of a memory word} -@d alink(#) == vlink(#+1) {backlink in doubly-linked list of empty nodes} - -@* \[10] Data structures for boxes and their friends. -From the computer's standpoint, \TeX's chief mission is to create -horizontal and vertical lists. We shall now investigate how the elements -of these lists are represented internally as nodes in the dynamic memory. - -A horizontal or vertical list is linked together by |link| fields in -the first word of each node. Individual nodes represent boxes, glue, -penalties, or special things like discretionary hyphens; because of this -variety, some nodes are longer than others, and we must distinguish different -kinds of nodes. We do this by putting a `|type|' field in the first word, -together with the link and an optional `|subtype|'. - -@d type(#) == vmem(#).hh.b0 {identifies what kind of node this is} -@d subtype(#) == vmem(#).hh.b1 {secondary identification in some cases} - -@ TH: This module section is superceded. - -A |@!char_node|, which represents a single character, is the most important -kind of node because it accounts for the vast majority of all boxes. -Special precautions are therefore taken to ensure that a |char_node| does -not take up much memory space. Every such node is one word long, and in fact -it is identifiable by this property, since other kinds of nodes have at least -two words, and they appear in |mem| locations less than |hi_mem_min|. -This makes it possible to omit the |type| field in a |char_node|, leaving -us room for two bytes that identify a |font| and a |character| within -that font. - -Note that the format of a |char_node| allows for up to 256 different -fonts and up to 256 characters per font; but most implementations will -probably limit the total number of fonts to fewer than 75 per job, -and most fonts will stick to characters whose codes are -less than 128 (since higher codes -are more difficult to access on most keyboards). - -Extensions of \TeX\ intended for oriental languages will need even more -than $256\times256$ possible characters, when we consider different sizes -@^oriental characters@>@^Chinese characters@>@^Japanese characters@> -and styles of type. It is suggested that Chinese and Japanese fonts be -handled by representing such characters in two consecutive |char_node| -entries: The first of these has |font=font_base|, and its |link| points -to the second; -the second identifies the font and the character dimensions. -The saving feature about oriental characters is that most of them have -the same box dimensions. The |character| field of the first |char_node| -is a ``\\{charext}'' that distinguishes between graphic symbols whose -dimensions are identical for typesetting purposes. (See the \MF\ manual.) -Such an extension of \TeX\ would not be difficult; further details are -left to the reader. - -In order to make sure that the |character| code fits in a quarterword, -\TeX\ adds the quantity |min_quarterword| to the actual code. - -Character nodes appear only in horizontal lists, never in vertical lists. - -@ Attribute lists need two extra globals to increase processing efficiency. -|max_used_attr| limits the test loop that checks for set attributes, and -|attr_list_cache| contains a pointer to an already created attribute list. It is -set to the special value |cache_disabled| when the current value can no longer be -trusted: after an assignment to an attribute register, and after a group has -ended. - -@d cache_disabled==max_halfword - -@= -max_used_attr:integer; { maximum assigned attribute id } -attr_list_cache:pointer; - -@ @= -max_used_attr:=-1; attr_list_cache:=cache_disabled; - -@ Attribute lists are maintained in C, but they need access to the current -attributes in eqtb. - -@p function get_attribute(i:halfword):halfword; -begin - get_attribute := attribute(i); -end; - - -@ An |hlist_node| stands for a box that was made from a horizontal list. -Each |hlist_node| is seven words long, and contains the following fields -(in addition to the mandatory |type| and |link|, which we shall not -mention explicitly when discussing the other node types): The |height| and -|width| and |depth| are scaled integers denoting the dimensions of the -box. There is also a |shift_amount| field, a scaled integer indicating -how much this box should be lowered (if it appears in a horizontal list), -or how much it should be moved to the right (if it appears in a vertical -list). There is a |list_ptr| field, which points to the beginning of the -list from which this box was fabricated; if |list_ptr| is |null|, the box -is empty. Finally, there are three fields that represent the setting of -the glue: |glue_set(p)| is a word of type |glue_ratio| that represents -the proportionality constant for glue setting; |glue_sign(p)| is -|stretching| or |shrinking| or |normal| depending on whether or not the -glue should stretch or shrink or remain rigid; and |glue_order(p)| -specifies the order of infinity to which glue setting applies (|normal|, -|sfi|, |fil|, |fill|, or |filll|). The |subtype| field is not used. - -@d width_offset=2 {position of |width| field in a box node} -@d depth_offset=3 {position of |depth| field in a box node} -@d height_offset=4 {position of |height| field in a box node} -@d width(#) == vmem(#+width_offset).sc {width of the box, in sp} -@d depth(#) == vmem(#+depth_offset).sc {depth of the box, in sp} -@d height(#) == vmem(#+height_offset).sc {height of the box, in sp} -@d shift_amount(#) == vlink(#+5) {repositioning distance, in sp} -@d box_dir(#) == vinfo(#+5) {position of |box_dir| in a box node} -@d list_offset=6 {position of |list_ptr| field in a box node} -@d list_ptr(#) == vlink(#+list_offset) {beginning of the list inside the box} -@d glue_order(#) == subtype(#+list_offset) {applicable order of infinity} -@d glue_sign(#) == type(#+list_offset) {stretching or shrinking} -@d normal=0 {the most common case when several cases are named} -@d stretching = 1 {glue setting applies to the stretch components} -@d shrinking = 2 {glue setting applies to the shrink components} -@d glue_set(#) == vmem(#+7).gr {a word of type |glue_ratio| for glue setting} - -@ The |new_null_box| function returns a pointer to an |hlist_node| in -which all subfields have the values corresponding to `\.{\\hbox\{\}}'. -The |subtype| field is set to |min_quarterword|, since that's the desired -|span_count| value if this |hlist_node| is changed to an |unset_node|. - -@p function new_null_box:pointer; {creates a new box node} -var p:pointer; {the new node} -begin p:=new_node(hlist_node,min_quarterword); -box_dir(p):=text_direction; -new_null_box:=p; -end; - -@ A |vlist_node| is like an |hlist_node| in all respects except that it -contains a vertical list. - -@ A |rule_node| stands for a solid black rectangle; it has |width|, -|depth|, and |height| fields just as in an |hlist_node|. However, if -any of these dimensions is $-2^{30}$, the actual value will be determined -by running the rule up to the boundary of the innermost enclosing box. -This is called a ``running dimension.'' The |width| is never running in -an hlist; the |height| and |depth| are never running in a~vlist. - -@d null_flag==-@'10000000000 {$-2^{30}$, signifies a missing item} -@d is_running(#) == (#=null_flag) {tests for a running dimension} -@d rule_dir(#)==vlink(#+5) - -@ A new rule node is delivered by the |new_rule| function. It -makes all the dimensions ``running,'' so you have to change the -ones that are not allowed to run. - -@p -function new_rule:pointer; -var p:pointer; {the new node} -begin p:=new_node(rule_node,0); {the |subtype| is not used} -new_rule:=p; -end; - - -@ Insertions are represented by |ins_node| records, where the |subtype| -indicates the corresponding box number. For example, `\.{\\insert 250}' -leads to an |ins_node| whose |subtype| is |250+min_quarterword|. -The |height| field of an |ins_node| is slightly misnamed; it actually holds -the natural height plus depth of the vertical list being inserted. -The |depth| field holds the |split_max_depth| to be used in case this -insertion is split, and the |split_top_ptr| points to the corresponding -|split_top_skip|. The |float_cost| field holds the |floating_penalty| that -will be used if this insertion floats to a subsequent page after a -split insertion of the same class. There is one more field, the -|ins_ptr|, which points to the beginning of the vlist for the insertion. - -@d float_cost(#)==vmem(#+2).int {the |floating_penalty| to be used} -@d ins_ptr(#)==vinfo(#+5) {the vertical list to be inserted} -@d split_top_ptr(#)==vlink(#+5) {the |split_top_skip| to be used} - -@ A |mark_node| has a |mark_ptr| field that points to the reference count -of a token list that contains the user's \.{\\mark} text. -In addition there is a |mark_class| field that contains the mark class. - -@d mark_ptr(#)==vlink(#+2) {head of the token list for a mark} -@d mark_class(#)==vinfo(#+2) {the mark class} - -@ An |adjust_node|, which occurs only in horizontal lists, -specifies material that will be moved out into the surrounding -vertical list; i.e., it is used to implement \TeX's `\.{\\vadjust}' -operation. The |adjust_ptr| field points to the vlist containing this -material. - -@d adjust_pre == subtype {pre-adjustment?} -@d adjust_ptr(#)==vlink(#+2) {vertical list to be moved out of horizontal list} -@#{|append_list| is used to append a list to |tail|} -@d append_list(#) == begin vlink(tail) := vlink(#); append_list_end -@d append_list_end(#) == tail := #; end - -@ A |glyph_node|, which occurs only in horizontal lists, specifies a -glyph in a particular font, along with its attribute list. Older -versions of \TeX\ could use token memory for characters, because the -font,char combination would fit in a single word (both values were -required to be strictly less than $2^{16}$). In \LuaTeX, room is -needed for characters that are larger than that, as well as a pointer -to a potential attribute list, and the two displacement values. - -In turn, that made the node so large that it made sense to merge -ligature glyphs as well, as that requires only one extra pointer. A -few extra classes of glyph nodes will be introduced later. The -unification of all those types makes it easier to manipulate lists of -glyphs. The subtype differentiates various glyph kinds. - -First, here is a function that returns a pointer to a glyph node for a given -glyph in a given font. If that glyph doesn't exist, |null| is returned -instead. Nodes of this subtype are directly created only for accents -and their base (through |make_accent|), and math nucleus items (in the -conversion from |mlist| to |hlist|). - - -@d is_char_node(#) == ((#<>null)and(type(#)=glyph_node)) -@d font(#)==vlink(#+2) {the font code in a |glyph_node|} -@d character(#)==vinfo(#+2) {the character code in a |glyph_node|} -@d lig_ptr(#)==vlink(#+3) {the list of characters for ligature replacements } -@d lang_data(#)==vinfo(#+3) {language information } -@d x_displace(#)==vinfo(#+4) { horizontal displacement } -@d y_displace(#)==vlink(#+4) { vertical displacement } - -@p function new_glyph(@!f,@!c:integer):pointer; -var p:pointer; {the new node} -begin p:=null; -if (f=0) or (char_exists(f,c)) then begin - p:=new_glyph_node; - set_to_glyph(p); font(p):=f; character(p):=c; - end; -new_glyph:=p; -end; - - -@ A subset of the glyphs nodes represent ligatures: characters -fabricated from the interaction of two or more actual characters. The -characters that generated the ligature have not been forgotten, since -they are needed for diagnostic messages; the |lig_ptr| field points to -a linked list of character nodes for all original characters that have -been deleted. (This list might be empty if the characters that -generated the ligature were retained in other nodes.) - -The |subtype| field of these |glyph_node|s is 1, plus 2 and/or 1 if -the original source of the ligature included implicit left and/or -right boundaries. These nodes are created by the C function |new_ligkern|. - -@ A third general type of glyphs could be called a character, as it -only appears in lists that are not yet processed by the ligaturing and -kerning steps of the program. - -|main_control| inserts these, and they are later converted to -|subtype_normal| by |new_ligkern|. - -@p function norm_min(@!h:integer):quarterword; -begin if h<=0 then norm_min:=1@+else if h>=255 then norm_min:=255@+ -else norm_min:=h; -end; -@# -function new_char(@!f,@!c:integer):pointer; -var p:pointer; {the new node} -begin p:=new_glyph_node; -set_to_character(p); font(p):=f; character(p):=c; -lang_data(p):=make_lang_data(uc_hyph,cur_lang,left_hyphen_min,right_hyphen_min); -new_char:=p; -end; - -@ Left and right ghost glyph nodes are the result of \.{\\leftghost} -and \.{\\rightghost}, respectively. They are going to be removed by -|new_ligkern|, at the end of which they are no longer needed. - -@ Here are a few handy helpers used by the list output routines. - -@p -function glyph_width(@!p:halfword):pointer; -var w:integer; -begin - w := char_width(font(p),character(p)); { |+ x_displace(p);| } - glyph_width := w; -end; -@# -function glyph_height(@!p:halfword):pointer; -var w:integer; -begin - w := char_height(font(p),character(p)) + y_displace(p); - if w<0 then w:=0; - glyph_height := w; -end; -@# -function glyph_depth(@!p:halfword):pointer; -var w:integer; -begin - w := char_depth(font(p),character(p)); - if y_displace(p)>0 then w := w - y_displace(p); - if w<0 then w:=0; - glyph_depth := w; -end; - - -@ A |disc_node|, which occurs only in horizontal lists, specifies a -``dis\-cretion\-ary'' line break. If such a break occurs at node |p|, the text -that starts at |pre_break(p)| will precede the break, the text that starts at -|post_break(p)| will follow the break, and text that appears in -|no_break(p)| nodes will be ignored. For example, an ordinary -discretionary hyphen, indicated by `\.{\\-}', yields a |disc_node| with -|pre_break| pointing to a |char_node| containing a hyphen, |post_break=null|, -and |no_break=null|. - -{TODO: Knuth said: All three of the discretionary texts must be lists -that consist entirely of character, kern, box and rule nodes.} - -If |subtype(p)=automatic_disc|, the |ex_hyphen_penalty| will be charged for this -break. Otherwise the |hyphen_penalty| will be charged. The texts will -actually be substituted into the list by the line-breaking algorithm if it -decides to make the break, and the discretionary node will disappear at -that time; thus, the output routine sees only discretionaries that were -not chosen. - -@d automatic_disc=2 -@d syllable_disc=3 -@d disc_type==subtype {the kind of discretionary} -@d pre_break(#)==vinfo(#+2) {text that precedes a discretionary break} -@d post_break(#)==vlink(#+2) {text that follows a discretionary break} -@d no_break(#)==vlink(#+3) {text this discretionary break replaces} -@d pre_break_head(#)==(#+4) -@d post_break_head(#)==(#+6) -@d no_break_head(#)==(#+8) -@d tlink(#)==vinfo(#+1) - -@p function new_disc:pointer; {creates an empty |disc_node|} -var p:pointer; {the new node} -begin p:=new_node(disc_node,0); -new_disc:=p; -end; - -@ A |whatsit_node| is a wild card reserved for extensions to \TeX. The -|subtype| field in its first word says what `\\{whatsit}' it is, and -implicitly determines the node size (which must be 2 or more) and the -format of the remaining words. When a |whatsit_node| is encountered -in a list, special actions are invoked; knowledgeable people who are -careful not to mess up the rest of \TeX\ are able to make \TeX\ do new -things by adding code at the end of the program. For example, there -might be a `\TeX nicolor' extension to specify different colors of ink, -@^extensions to \TeX@> -and the whatsit node might contain the desired parameters. - -The present implementation of \TeX\ treats the features associated with -`\.{\\write}' and `\.{\\special}' as if they were extensions, in order to -illustrate how such routines might be coded. We shall defer further -discussion of extensions until the end of this program. - -@ A |math_node|, which occurs only in horizontal lists, appears before and -after mathematical formulas. The |subtype| field is |before| before the -formula and |after| after it. There is a |surround| field, which represents -the amount of surrounding space inserted by \.{\\mathsurround}. - -@d surround(#)==vlink(#+2) -@d before=0 {|subtype| for math node that introduces a formula} -@d after=1 {|subtype| for math node that winds up a formula} - -@p function new_math(@!w:scaled;@!s:small_number):pointer; -var p:pointer; {the new node} -begin p:=new_node(math_node,s); -surround(p):=w; new_math:=p; -end; - -@ \TeX\ makes use of the fact that |hlist_node|, |vlist_node|, -|rule_node|, |ins_node|, |mark_node|, |adjust_node|, -|disc_node|, |whatsit_node|, and |math_node| are at the low end of the -type codes, by permitting a break at glue in a list if and only if the -|type| of the previous node is less than |math_node|. Furthermore, a -node is discarded after a break if its type is |math_node| or~more. - -@d precedes_break(#)==(type(#) -representing |null| plus the number of glue nodes that point to it (less one). -Note that the reference count appears in the same position as -the |link| field in list nodes; this is the field that is initialized -to |null| when a node is allocated, and it is also the field that is flagged -by |empty_flag| in empty nodes. - -Glue specifications also contain three |scaled| fields, for the |width|, -|stretch|, and |shrink| dimensions. Finally, there are two one-byte -fields called |stretch_order| and |shrink_order|; these contain the -orders of infinity (|normal|, |sfi|, |fil|, |fill|, or |filll|) -corresponding to the stretch and shrink values. - -@d glue_ref_count(#) == vlink(#+3) {reference count of a glue specification} -@d stretch(#) == vlink(#+1) {the stretchability of this glob of glue} -@d shrink(#) == vinfo(#+1) {the shrinkability of this glob of glue} -@d stretch_order(#) == type(#+3) {order of infinity for stretching} -@d shrink_order(#) == subtype(#+3) {order of infinity for shrinking} -@d sfi=1 {first-order infinity} -@d fil=2 {second-order infinity} -@d fill=3 {third-order infinity} -@d filll=4 {fourth-order infinity} - -@= -@!glue_ord=normal..filll; {infinity to the 0, 1, 2, 3, or 4 power} - -@ Here is a function that returns a pointer to a copy of a glue spec. -The reference count in the copy is |null|, because there is assumed -to be exactly one reference to the new specification. - -@p function new_spec(@!p:pointer):pointer; {duplicates a glue specification} -var q:pointer; {the new spec} -begin q:=copy_node(p); -glue_ref_count(q):=null; -new_spec:=q; -end; - -@ And here's a function that creates a glue node for a given parameter -identified by its code number; for example, -|new_param_glue(line_skip_code)| returns a pointer to a glue node for the -current \.{\\lineskip}. - -@p function new_param_glue(@!n:small_number):pointer; -var p:pointer; {the new node} -@!q:pointer; {the glue specification} -begin p:=new_node(glue_node,n+1); -q:=@@t@>; -glue_ptr(p):=q; incr(glue_ref_count(q)); -new_param_glue:=p; -end; - -@ Glue nodes that are more or less anonymous are created by |new_glue|, -whose argument points to a glue specification. - -@p function new_glue(@!q:pointer):pointer; -var p:pointer; {the new node} -begin p:=new_node(glue_node,normal); -glue_ptr(p):=q; incr(glue_ref_count(q)); -new_glue:=p; -end; - -@ Still another subroutine is needed: This one is sort of a combination -of |new_param_glue| and |new_glue|. It creates a glue node for one of -the current glue parameters, but it makes a fresh copy of the glue -specification, since that specification will probably be subject to change, -while the parameter will stay put. The global variable |temp_ptr| is -set to the address of the new spec. - -@p function new_skip_param(@!n:small_number):pointer; -var p:pointer; {the new node} -begin temp_ptr:=new_spec(@); -p:=new_glue(temp_ptr); glue_ref_count(temp_ptr):=null; subtype(p):=n+1; -new_skip_param:=p; -end; - -@ A |kern_node| has a |width| field to specify a (normally negative) -amount of spacing. This spacing correction appears in horizontal lists -between letters like A and V when the font designer said that it looks -better to move them closer together or further apart. A kern node can -also appear in a vertical list, when its `|width|' denotes additional -spacing in the vertical direction. The |subtype| is either |normal| (for -kerns inserted from font information or math mode calculations) or |explicit| -(for kerns inserted from \.{\\kern} and \.{\\/} commands) or |acc_kern| -(for kerns inserted from non-math accents) or |mu_glue| (for kerns -inserted from \.{\\mkern} specifications in math formulas). - -@d explicit=1 {|subtype| of kern nodes from \.{\\kern} and \.{\\/}} -@d acc_kern=2 {|subtype| of kern nodes from accents} - -@# {memory structure for marginal kerns} -@d margin_char(#) == vlink(#+3) - -@# {|subtype| of marginal kerns} -@d left_side == 0 -@d right_side == 1 - -@# {base for lp/rp/ef codes starts from 2: - 0 for |hyphen_char|, - 1 for |skew_char|} -@d lp_code_base == 2 -@d rp_code_base == 3 -@d ef_code_base == 4 -@d tag_code == 5 - -@d auto_kern == explicit -@d no_lig_code == 6 - -@ The |new_kern| function creates a kern node having a given width. - -@p function new_kern(@!w:scaled):pointer; -var p:pointer; {the new node} -begin p:=new_node(kern_node,normal); -width(p):=w; -new_kern:=p; -end; - -@ A |penalty_node| specifies the penalty associated with line or page -breaking, in its |penalty| field. This field is a fullword integer, but -the full range of integer values is not used: Any penalty |>=10000| is -treated as infinity, and no break will be allowed for such high values. -Similarly, any penalty |<=-10000| is treated as negative infinity, and a -break will be forced. - -@d inf_penalty=inf_bad {``infinite'' penalty value} -@d eject_penalty=-inf_penalty {``negatively infinite'' penalty value} -@d penalty(#) == vlink(#+2) {the added cost of breaking a list here} - -@ Anyone who has been reading the last few sections of the program will -be able to guess what comes next. - -@p function new_penalty(@!m:integer):pointer; -var p:pointer; {the new node} -begin p:=new_node(penalty_node,0); {the |subtype| is not used} -penalty(p):=m; new_penalty:=p; -end; - -@ You might think that we have introduced enough node types by now. Well, -almost, but there is one more: An |unset_node| has nearly the same format -as an |hlist_node| or |vlist_node|; it is used for entries in \.{\\halign} -or \.{\\valign} that are not yet in their final form, since the box -dimensions are their ``natural'' sizes before any glue adjustment has been -made. The |glue_set| word is not present; instead, we have a |glue_stretch| -field, which contains the total stretch of order |glue_order| that is -present in the hlist or vlist being boxed. -Similarly, the |shift_amount| field is replaced by a |glue_shrink| field, -containing the total shrink of order |glue_sign| that is present. -The |subtype| field is called |span_count|; an unset box typically -contains the data for |qo(span_count)+1| columns. -Unset nodes will be changed to box nodes when alignment is completed. - -@d glue_stretch(#)==vmem(#+7).sc {total stretch in an unset node} -@d glue_shrink==shift_amount {total shrink in an unset node} -@d span_count==subtype {indicates the number of spanned columns} - -@ In fact, there are still more types coming. When we get to math formula -processing we will see that a |style_node| has |type=14|; and a number -of larger type codes will also be defined, for use in math mode only. - -@ Warning: If any changes are made to these data structure layouts, such as -changing any of the node sizes or even reordering the words of nodes, -the |copy_node_list| procedure and the memory initialization code -below may have to be changed. Such potentially dangerous parts of the -program are listed in the index under `data structure assumptions'. -@!@^data structure assumptions@> -However, other references to the nodes are made symbolically in terms of -the \.{WEB} macro definitions above, so that format changes will leave -\TeX's other algorithms intact. -@^system dependencies@> - -@* \[11] Memory layout. - -Some areas of |mem| are dedicated to fixed usage, since static -allocation is more efficient than dynamic allocation when we can get -away with it. For example, |zero_glue| used for glue that is `\.{0pt -plus 0pt minus 0pt}'. A few C macro definitions accomplish the static -allocation of node memory locations by giving symbolic names to fixed -positions. The list of imported constant identifiers is: |zero_glue|, -|sfi_glue|, |fil_glue|, |fill_glue|, |ss_glue|, |fil_neg_glue| (all -glue specs), |page_ins_head| (list of insertion data for current -page), |contrib_head| (list of insertion data for current page), -|page_head| (list for current page), |temp_head| and |hold_head| -(temporary lists), |adjust_head| (head of adjustment list returned by -|hpack|), |pre_adjust_head| (head of pre-adjustment list returned by -|hpack|), |align_head| (head of alignment preamble), and -|end_span| (tail of spanned-width lists). - - -@= -garbage:pointer; {head of a junk list, write only} -temp_token_head:pointer; {head of a temporary list of some kind} -hold_token_head:pointer; {head of a temporary list of another kind} -omit_template:pointer; {a constant token list} -null_list:pointer; {permanently empty list} -backup_head:pointer; {head of token list built by |scan_keyword|} - -@ The following code gets |mem| off to a good start, when \TeX\ is -initializing itself the slow~way. - -@= -@!k:integer; {index into |mem|, |eqtb|, etc.} - -@ @= -procedure init_link_heads;forward; -init_node_mem(500); -avail:=null; fix_mem_end:=0; -init_list_heads; -@; -initialize_active; -dyn_used:=0; {initialize statistics} - -@ @p procedure init_list_heads; {initialize token list heads} -var p:halfword; -begin -p:=get_avail; temp_token_head:=p; info(temp_token_head):=0; -p:=get_avail; hold_token_head:=p; info(hold_token_head):=0; -p:=get_avail; omit_template:=p; info(omit_template):=0; -p:=get_avail; null_list:=p; info(null_list):=0; -p:=get_avail; backup_head:=p; info(backup_head):=0; -p:=get_avail; garbage:=p; info(garbage):=0; -end; - -@ @p -@ - -@* \[12] Displaying boxes. -We can reinforce our knowledge of the data structures just introduced -by considering two procedures that display a list in symbolic form. -The first of these, called |short_display|, is used in ``overfull box'' -messages to give the top-level description of a list. The other one, -called |show_node_list|, prints a detailed description of exactly what -is in the data structure. - -The philosophy of |short_display| is to ignore the fine points about exactly -what is inside boxes, except that ligatures and discretionary breaks are -expanded. As a result, |short_display| is a recursive procedure, but the -recursion is never more than one level deep. -@^recursion@> - -A global variable |font_in_short_display| keeps track of the font code that -is assumed to be present when |short_display| begins; deviations from this -font will be printed. - -@= -@!font_in_short_display:integer; {an internal font number} - -@ Boxes, rules, inserts, whatsits, marks, and things in general that are -sort of ``complicated'' are indicated only by printing `\.{[]}'. - -@p -procedure print_font_identifier(f: internal_font_number); -var fonttext:str_number; -begin - if pdf_font_blink(f) = null_font then - fonttext := font_id_text(f) - else - fonttext := font_id_text(pdf_font_blink(f)); - if fonttext>0 then - print_esc(fonttext) - else begin - print_esc("FONT"); - if pdf_font_blink(f) = null_font then - print_int(f) - else - print_int(pdf_font_blink(f)); - end; - if pdf_tracing_fonts > 0 then begin - print(" ("); - print_font_name(f); - if font_size(f) <> font_dsize(f) then begin - print("@@"); - print_scaled(font_size(f)); - print("pt"); - end; - print(")"); - end else - if pdf_font_expand_ratio(f) <> 0 then begin - print(" ("); - if pdf_font_expand_ratio(f) > 0 then - print("+"); - print_int(pdf_font_expand_ratio(f)); - print(")"); - end; -end; - -procedure short_display(@!p:integer); {prints highlights of list |p|} -begin while p<>null do - begin if is_char_node(p) then - begin if lig_ptr(p)<>null then - short_display(lig_ptr(p)) - else begin - if font(p)<>font_in_short_display then - begin if not is_valid_font(font(p)) then - print_char("*") -@.*\relax@> - else print_font_identifier(font(p)); - print_char(" "); font_in_short_display:=font(p); - end; - print(qo(character(p))); - end; - end - else @; - p:=vlink(p); - end; -end; - -@ @= -print_short_node_contents(p) - -@ The |show_node_list| routine requires some auxiliary subroutines: one to -print a font-and-character combination, one to print a token list without -its reference count, and one to print a rule dimension. - -@p procedure print_font_and_char(@!p:integer); {prints |char_node| data} -begin if not is_valid_font(font(p)) then print_char("*") -@.*\relax@> - else print_font_identifier(font(p)); - print_char(" "); print(character(p)); -end; -@# -procedure print_mark(@!p:integer); {prints token list data in braces} -begin print_char("{"); -if (pfix_mem_end) then print_esc("CLOBBERED.") -else show_token_list(link(p),null,max_print_line-10); -print_char("}"); -end; -@# -procedure print_rule_dimen(@!d:scaled); {prints dimension in rule node} -begin if is_running(d) then print_char("*") else print_scaled(d); -@.*\relax@> -end; -@# -procedure print_dir(d:integer); -begin -print(dir_names[dir_primary[d]]); -print(dir_names[dir_secondary[d]]); -print(dir_names[dir_tertiary[d]]); -end; - - -@ Then there is a subroutine that prints glue stretch and shrink, possibly -followed by the name of finite units: - -@p procedure print_glue(@!d:scaled;@!order:integer;@!s:str_number); - {prints a glue component} -begin print_scaled(d); -if (orderfilll) then print("foul") -else if order>normal then - begin print("fi"); - while order>sfi do - begin print_char("l"); decr(order); - end; - end -else if s<>0 then print(s); -end; - -@ The next subroutine prints a whole glue specification. - -@p procedure print_spec(@!p:integer;@!s:str_number); - {prints a glue specification} -begin if p<0 then print_char("*") -@.*\relax@> -else begin print_scaled(width(p)); - if s<>0 then print(s); - if stretch(p)<>0 then - begin print(" plus "); print_glue(stretch(p),stretch_order(p),s); - end; - if shrink(p)<>0 then - begin print(" minus "); print_glue(shrink(p),shrink_order(p),s); - end; - end; -end; - -@ We also need to declare some procedures that appear later in this -documentation. - -@p @ - -@ Since boxes can be inside of boxes, |show_node_list| is inherently recursive, -@^recursion@> -up to a given maximum number of levels. The history of nesting is indicated -by the current string, which will be printed at the beginning of each line; -the length of this string, namely |cur_length|, is the depth of nesting. - -@ A global variable called |depth_threshold| is used to record the maximum -depth of nesting for which |show_node_list| will show information. If we -have |depth_threshold=0|, for example, only the top level information will -be given and no sublists will be traversed. Another global variable, called -|breadth_max|, tells the maximum number of items to show at each level; -|breadth_max| had better be positive, or you won't see anything. - -@= -@!depth_threshold : integer; {maximum nesting depth in box displays} -@!breadth_max : integer; {maximum number of items shown at the same list level} - - -@ The recursive machinery is started by calling |show_box|. -@^recursion@> - -@p procedure show_box(@!p:pointer); -begin @; -if breadth_max<=0 then breadth_max:=5; -if pool_ptr+depth_threshold>=pool_size then - depth_threshold:=pool_size-pool_ptr-1; - {now there's enough room for prefix string} -show_node_list(p); {the show starts at |p|} -print_ln; -end; - -@* \[13] Destroying boxes. -When we are done with a node list, we are obliged to return it to free -storage, including all of its sublists. The recursive procedure -|flush_node_list| does this for us. - -@ First, however, we shall consider two non-recursive procedures that do -simpler tasks. The first of these, |delete_token_ref|, is called when -a pointer to a token list's reference count is being removed. This means -that the token list should disappear if the reference count was |null|, -otherwise the count should be decreased by one. -@^reference counts@> - -@d token_ref_count(#) == info(#) {reference count preceding a token list} - -@p procedure delete_token_ref(@!p:pointer); {|p| points to the reference count - of a token list that is losing one reference} -begin pdfassert(token_ref_count(p)>=0); -if token_ref_count(p)=0 then flush_list(p) -else decr(token_ref_count(p)); -end; - -@ Similarly, |delete_glue_ref| is called when a pointer to a glue -specification is being withdrawn. -@^reference counts@> -@d fast_delete_glue_ref(#)==@t@>@;@/ - begin if glue_ref_count(#)=null then begin - flush_node(#); - end - else decr(glue_ref_count(#)); - end - -@p procedure delete_glue_ref(@!p:pointer); {|p| points to a glue specification} -begin - pdfassert(type(p)=glue_spec_node); - fast_delete_glue_ref(p); -end; - -@ Now we are ready to delete any node list, recursively. -In practice, the nodes deleted are usually charnodes (about 2/3 of the time), -and they are glue nodes in about half of the remaining cases. -@^recursion@> - - -@* \[14] Copying boxes. -Another recursive operation that acts on boxes is sometimes needed: The -procedure |copy_node_list| returns a pointer to another node list that has -the same structure and meaning as the original. Note that since glue -specifications and token lists have reference counts, we need not make -copies of them. Reference counts can never get too large to fit in a -halfword, since each pointer to a node is in a different memory address, -and the total number of memory addresses fits in a halfword. -@^recursion@> -@^reference counts@> - -(Well, there actually are also references from outside |mem|; if the -|save_stack| is made arbitrarily large, it would theoretically be possible -to break \TeX\ by overflowing a reference count. But who would want to do that?) - -@d add_token_ref(#)==incr(token_ref_count(#)) {new reference to a token list} -@d add_glue_ref(#)==incr(glue_ref_count(#)) {new reference to a glue spec} - -@p function tail_of_list (@!p:pointer):pointer; -var q:pointer; -begin - q:=p; - while vlink(q)<>null do q:=vlink(q); - tail_of_list:=q; -end; - -@* \[15] The command codes. -Before we can go any further, we need to define symbolic names for the internal -code numbers that represent the various commands obeyed by \TeX. These codes -are somewhat arbitrary, but not completely so. For example, the command -codes for character types are fixed by the language, since a user says, -e.g., `\.{\\catcode \`\\\${} = 3}' to make \.{\char'44} a math delimiter, -and the command code |math_shift| is equal to~3. Some other codes have -been made adjacent so that |case| statements in the program need not consider -cases that are widely spaced, or so that |case| statements can be replaced -by |if| statements. - -At any rate, here is the list, for future reference. First come the -``catcode'' commands, several of which share their numeric codes with -ordinary commands when the catcode cannot emerge from \TeX's scanning routine. - -@d escape=0 {escape delimiter (called \.\\ in {\sl The \TeX book\/})} -@:TeXbook}{\sl The \TeX book@> -@d relax=0 {do nothing ( \.{\\relax} )} -@d left_brace=1 {beginning of a group ( \.\{ )} -@d right_brace=2 {ending of a group ( \.\} )} -@d math_shift=3 {mathematics shift character ( \.\$ )} -@d tab_mark=4 {alignment delimiter ( \.\&, \.{\\span} )} -@d car_ret=5 {end of line ( |carriage_return|, \.{\\cr}, \.{\\crcr} )} -@d out_param=5 {output a macro parameter} -@d mac_param=6 {macro parameter symbol ( \.\# )} -@d sup_mark=7 {superscript ( \.{\char'136} )} -@d sub_mark=8 {subscript ( \.{\char'137} )} -@d ignore=9 {characters to ignore ( \.{\^\^@@} )} -@d endv=9 {end of \ list in alignment template} -@d spacer=10 {characters equivalent to blank space ( \.{\ } )} -@d letter=11 {characters regarded as letters ( \.{A..Z}, \.{a..z} )} -@d other_char=12 {none of the special character types} -@d active_char=13 {characters that invoke macros ( \.{\char`\~} )} -@d par_end=13 {end of paragraph ( \.{\\par} )} -@d match=13 {match a macro parameter} -@d comment=14 {characters that introduce comments ( \.\% )} -@d end_match=14 {end of parameters to macro} -@d stop=14 {end of job ( \.{\\end}, \.{\\dump} )} -@d invalid_char=15 {characters that shouldn't appear ( \.{\^\^?} )} -@d delim_num=15 {specify delimiter numerically ( \.{\\delimiter} )} -@d max_char_code=15 {largest catcode for individual characters} - -@ Next are the ordinary run-of-the-mill command codes. Codes that are -|min_internal| or more represent internal quantities that might be -expanded by `\.{\\the}'. - -@d char_num=16 {character specified numerically ( \.{\\char} )} -@d math_char_num=17 {explicit math code ( \.{\\mathchar} )} -@d mark=18 {mark definition ( \.{\\mark} )} -@d xray=19 {peek inside of \TeX\ ( \.{\\show}, \.{\\showbox}, etc.~)} -@d make_box=20 {make a box ( \.{\\box}, \.{\\copy}, \.{\\hbox}, etc.~)} -@d hmove=21 {horizontal motion ( \.{\\moveleft}, \.{\\moveright} )} -@d vmove=22 {vertical motion ( \.{\\raise}, \.{\\lower} )} -@d un_hbox=23 {unglue a box ( \.{\\unhbox}, \.{\\unhcopy} )} -@d un_vbox=24 {unglue a box ( \.{\\unvbox}, \.{\\unvcopy} )} - {( or \.{\\pagediscards}, \.{\\splitdiscards} )} -@d remove_item=25 {nullify last item ( \.{\\unpenalty}, - \.{\\unkern}, \.{\\unskip} )} -@d hskip=26 {horizontal glue ( \.{\\hskip}, \.{\\hfil}, etc.~)} -@d vskip=27 {vertical glue ( \.{\\vskip}, \.{\\vfil}, etc.~)} -@d mskip=28 {math glue ( \.{\\mskip} )} -@d kern=29 {fixed space ( \.{\\kern})} -@d mkern=30 {math kern ( \.{\\mkern} )} -@d leader_ship=31 {use a box ( \.{\\shipout}, \.{\\leaders}, etc.~)} -@d halign=32 {horizontal table alignment ( \.{\\halign} )} -@d valign=33 {vertical table alignment ( \.{\\valign} )} -@d no_align=34 {temporary escape from alignment ( \.{\\noalign} )} -@d vrule=35 {vertical rule ( \.{\\vrule} )} -@d hrule=36 {horizontal rule ( \.{\\hrule} )} -@d insert=37 {vlist inserted in box ( \.{\\insert} )} -@d vadjust=38 {vlist inserted in enclosing paragraph ( \.{\\vadjust} )} -@d ignore_spaces=39 {gobble |spacer| tokens ( \.{\\ignorespaces} )} -@d after_assignment=40 {save till assignment is done ( \.{\\afterassignment} )} -@d after_group=41 {save till group is done ( \.{\\aftergroup} )} -@d break_penalty=42 {additional badness ( \.{\\penalty} )} -@d start_par=43 {begin paragraph ( \.{\\indent}, \.{\\noindent} )} -@d ital_corr=44 {italic correction ( \.{\\/} )} -@d accent=45 {attach accent in text ( \.{\\accent} )} -@d math_accent=46 {attach accent in math ( \.{\\mathaccent} )} -@d discretionary=47 {discretionary texts ( \.{\\-}, \.{\\discretionary} )} -@d eq_no=48 {equation number ( \.{\\eqno}, \.{\\leqno} )} -@d left_right=49 {variable delimiter ( \.{\\left}, \.{\\right} )} - {( or \.{\\middle} )} -@d math_comp=50 {component of formula ( \.{\\mathbin}, etc.~)} -@d limit_switch=51 {diddle limit conventions ( \.{\\displaylimits}, etc.~)} -@d above=52 {generalized fraction ( \.{\\above}, \.{\\atop}, etc.~)} -@d math_style=53 {style specification ( \.{\\displaystyle}, etc.~)} -@d math_choice=54 {choice specification ( \.{\\mathchoice}, \.{\\Ustack} )} -@d non_script=55 {conditional math glue ( \.{\\nonscript} )} -@d vcenter=56 {vertically center a vbox ( \.{\\vcenter} )} -@d case_shift=57 {force specific case ( \.{\\lowercase}, \.{\\uppercase}~)} -@d message=58 {send to user ( \.{\\message}, \.{\\errmessage} )} -@d extension=59 {extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~)} -@d in_stream=60 {files for reading ( \.{\\openin}, \.{\\closein} )} -@d begin_group=61 {begin local grouping ( \.{\\begingroup} )} -@d end_group=62 {end local grouping ( \.{\\endgroup} )} -@d omit=63 {omit alignment template ( \.{\\omit} )} -@d ex_space=64 {explicit space ( \.{\\\ } )} -@d no_boundary=65 {suppress boundary ligatures ( \.{\\noboundary} )} -@d radical=66 {square root and similar signs ( \.{\\radical} )} -@d super_sub_script=67 {explicit super ( \.{\\Usuperscript} ) or subscript ( \.{\\Usubscript} )} -@d math_shift_cs=68 {explicit math switch ( \.{\\Ustartmath}, etc.~)} -@d end_cs_name=69 {end control sequence ( \.{\\endcsname} )} -@d char_ghost=end_cs_name+1 - {\.{\\ghostleft}, \.{\\ghostright} character for kerning} -@d assign_local_box=char_ghost+1 - {box for guillemets \.{\\localleftbox} or \.{\\localrightbox}} -@d min_internal=assign_local_box+1 {the smallest code that can follow \.{\\the}} -@d char_given=min_internal {character code defined by \.{\\chardef}} -@d math_given=char_given+1 {math code defined by \.{\\mathchardef}} -@d omath_given=math_given+1 {math code defined by \.{\\omathchardef}} -@d xmath_given=omath_given+1 {math code defined by \.{\\Umathchardef}} -@d last_item=xmath_given+1 {most recent item ( \.{\\lastpenalty}, - \.{\\lastkern}, \.{\\lastskip} )} -@d max_non_prefixed_command=last_item - {largest command code that can't be \.{\\global}} - -@ The next codes are special; they all relate to mode-independent -assignment of values to \TeX's internal registers or tables. -Codes that are |max_internal| or less represent internal quantities -that might be expanded by `\.{\\the}'. - -There is no matching primitive to go with |assign_attr|, but even if -there was no \.{\\attributedef}, a reserved number would still be -needed because there is an implied correspondence between the -|assign_xxx| commands and |xxx_val| expression values. That would -break down otherwise. - -@d toks_register=max_non_prefixed_command+1 - {token list register ( \.{\\toks} )} -@d assign_toks=toks_register+1 - {special token list ( \.{\\output}, \.{\\everypar}, etc.~)} -@d assign_int=assign_toks+1 - {user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~)} -@d assign_attr=assign_int+1 { user-defined attributes } -@d assign_dimen=assign_attr+1 - {user-defined length ( \.{\\hsize}, etc.~)} -@d assign_glue=assign_dimen+1 - {user-defined glue ( \.{\\baselineskip}, etc.~)} -@d assign_mu_glue=assign_glue+1 - {user-defined muglue ( \.{\\thinmuskip}, etc.~)} -@d assign_font_dimen=assign_mu_glue+1 - {user-defined font dimension ( \.{\\fontdimen} )} -@d assign_font_int=assign_font_dimen+1 - {user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} )} -@d set_aux=assign_font_int+1 - {specify state info ( \.{\\spacefactor}, \.{\\prevdepth} )} -@d set_prev_graf=set_aux+1 - {specify state info ( \.{\\prevgraf} )} -@d set_page_dimen=set_prev_graf+1 - {specify state info ( \.{\\pagegoal}, etc.~)} -@d set_page_int=set_page_dimen+1 - {specify state info ( \.{\\deadcycles}, - \.{\\insertpenalties} )} -@d set_box_dimen=set_page_int+1 - {change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} )} -@d set_tex_shape=set_box_dimen+1 - {specify fancy paragraph shape ( \.{\\parshape} )} -@d set_etex_shape=set_tex_shape+1 - {specify etex specials ( \.{\\interlinepenalties}, etc.~)} -@d def_char_code=set_etex_shape+1 - {define a character code ( \.{\\catcode}, etc.~)} -@d def_del_code=def_char_code+1 - {define a delimiter code ( \.{\\delcode})} -@d extdef_math_code=def_del_code+1 - {define an extended character code ( \.{\\omathcode}, etc.~)} -@d extdef_del_code=extdef_math_code+1 - {define an extended delimiter code ( \.{\\odelcode}, etc.~)} -@d def_family=extdef_del_code+1 - {declare math fonts ( \.{\\textfont}, etc.~)} -@d set_math_param=def_family+1 - {declare math parameters ( \.{\\Umathquad}, etc.~)} -@d set_font=set_math_param+1 - {set current font ( font identifiers )} -@d def_font=set_font+1 - {define a font file ( \.{\\font} )} -@d register=def_font+1 - {internal register ( \.{\\count}, \.{\\dimen}, etc.~)} -@d assign_box_dir=register+1 {(\.{\\boxdir})} -@d assign_dir=register+2 {(\.{\\pagedir}, \.{\\bodydir}, \.{\\pardir}, \.{\\textdir}), \.{\\mathdir}} -@d max_internal=assign_dir - {the largest code that can follow \.{\\the}} -@d advance=max_internal+1 - {advance a register or parameter ( \.{\\advance} )} -@d multiply=advance+1 - {multiply a register or parameter ( \.{\\multiply} )} -@d divide=multiply+1 - {divide a register or parameter ( \.{\\divide} )} -@d prefix=divide+1 - {qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} )} -@d let=prefix+1 - {assign a command code ( \.{\\let}, \.{\\futurelet} )} -@d shorthand_def=let+1 - {code definition ( \.{\\chardef}, \.{\\countdef}, etc.~)} -@d read_to_cs=shorthand_def+1 - {read into a control sequence ( \.{\\read} )} -@d def=read_to_cs+1 - {macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} )} -@d set_box=def+1 - {set a box ( \.{\\setbox} )} -@d hyph_data=set_box+1 - {hyphenation data ( \.{\\hyphenation}, \.{\\patterns} )} -@d set_interaction=hyph_data+1 - {define level of interaction ( \.{\\batchmode}, etc.~)} -@d letterspace_font=set_interaction+1 - {letterspace a font ( \.{\\letterspacefont} )} -@d pdf_copy_font=letterspace_font+1 - {create a new font instance ( \.{\\pdfcopyfont} )} -@d set_ocp=pdf_copy_font+1 - {Place a translation process in the stream} -@d def_ocp=set_ocp+1 - {Define and load a translation process} -@d set_ocp_list=def_ocp+1 - {Place a list of OCPs in the stream} -@d def_ocp_list=set_ocp_list+1 - {Define a list of OCPs} -@d clear_ocp_lists=def_ocp_list+1 - {Remove all active OCP lists} -@d push_ocp_list=clear_ocp_lists+1 - {Add to the sequence of active OCP lists} -@d pop_ocp_list=push_ocp_list+1 - {Remove from the sequence of active OCP lists} -@d ocp_list_op=pop_ocp_list+1 - {Operations for building a list of OCPs} -@d ocp_trace_level=ocp_list_op+1 - {Tracing of active OCPs, either 0 or 1} -@d max_command=ocp_trace_level - {the largest command code seen at |big_switch|} - -@ The remaining command codes are extra special, since they cannot get through -\TeX's scanner to the main control routine. They have been given values higher -than |max_command| so that their special nature is easily discernible. -The ``expandable'' commands come first. - -@d undefined_cs=max_command+1 {initial state of most |eq_type| fields} -@d expand_after=max_command+2 {special expansion ( \.{\\expandafter} )} -@d no_expand=max_command+3 {special nonexpansion ( \.{\\noexpand} )} -@d input=max_command+4 {input a source file ( \.{\\input}, \.{\\endinput} )} - {( or \.{\\scantokens} or \.{\\scantextokens} )} -@d if_test=max_command+5 {conditional text ( \.{\\if}, \.{\\ifcase}, etc.~)} -@d fi_or_else=max_command+6 {delimiters for conditionals ( \.{\\else}, etc.~)} -@d cs_name=max_command+7 {make a control sequence from tokens ( \.{\\csname} )} -@d convert=max_command+8 {convert to text ( \.{\\number}, \.{\\string}, etc.~)} -@d the=max_command+9 {expand an internal quantity ( \.{\\the} )} - {( or \.{\\unexpanded}, \.{\\detokenize} )} -@d top_bot_mark=max_command+10 {inserted mark ( \.{\\topmark}, etc.~)} -@d call=max_command+11 {non-long, non-outer control sequence} -@d long_call=max_command+12 {long, non-outer control sequence} -@d outer_call=max_command+13 {non-long, outer control sequence} -@d long_outer_call=max_command+14 {long, outer control sequence} -@d end_template=max_command+15 {end of an alignment template} -@d dont_expand=max_command+16 {the following token was marked by \.{\\noexpand}} -@d glue_ref=max_command+17 {the equivalent points to a glue specification} -@d shape_ref=max_command+18 {the equivalent points to a parshape specification} -@d box_ref=max_command+19 {the equivalent points to a box node, or is |null|} -@d data=max_command+20 {the equivalent is simply a halfword number} - -@* \[16] The semantic nest. -\TeX\ is typically in the midst of building many lists at once. For example, -when a math formula is being processed, \TeX\ is in math mode and -working on an mlist; this formula has temporarily interrupted \TeX\ from -being in horizontal mode and building the hlist of a paragraph; and this -paragraph has temporarily interrupted \TeX\ from being in vertical mode -and building the vlist for the next page of a document. Similarly, when a -\.{\\vbox} occurs inside of an \.{\\hbox}, \TeX\ is temporarily -interrupted from working in restricted horizontal mode, and it enters -internal vertical mode. The ``semantic nest'' is a stack that -keeps track of what lists and modes are currently suspended. - -At each level of processing we are in one of six modes: - -\yskip\hang|vmode| stands for vertical mode (the page builder); - -\hang|hmode| stands for horizontal mode (the paragraph builder); - -\hang|mmode| stands for displayed formula mode; - -\hang|-vmode| stands for internal vertical mode (e.g., in a \.{\\vbox}); - -\hang|-hmode| stands for restricted horizontal mode (e.g., in an \.{\\hbox}); - -\hang|-mmode| stands for math formula mode (not displayed). - -\yskip\noindent The mode is temporarily set to zero while processing \.{\\write} -texts in the |ship_out| routine. - -Numeric values are assigned to |vmode|, |hmode|, and |mmode| so that -\TeX's ``big semantic switch'' can select the appropriate thing to -do by computing the value |abs(mode)+cur_cmd|, where |mode| is the current -mode and |cur_cmd| is the current command code. - -@d vmode=1 {vertical mode} -@d hmode=vmode+max_command+1 {horizontal mode} -@d mmode=hmode+max_command+1 {math mode} - -@p procedure print_mode(@!m:integer); {prints the mode represented by |m|} -begin if m>0 then - case m div (max_command+1) of - 0:print("vertical"); - 1:print("horizontal"); - 2:print("display math"); - end -else if m=0 then print("no") -else case (-m) div (max_command+1) of - 0:print("internal vertical"); - 1:print("restricted horizontal"); - 2:print("math"); - end; -print(" mode"); -end; -function get_mode_id:integer; {returns the mode represented by |m|} -var m:integer ; -begin - m := mode; - if m>0 then - case m div (max_command+1) of - 0:get_mode_id := "v"; - 1:get_mode_id := "h"; - 2:get_mode_id := "m"; - othercases get_mode_id := ""; - end -else if m=0 then get_mode_id := "n" -else case (-m) div (max_command+1) of - 0:get_mode_id := "V"; - 1:get_mode_id := "H"; - 2:get_mode_id := "M"; - othercases get_mode_id := ""; - end; -end; - -@ The state of affairs at any semantic level can be represented by -five values: - -\yskip\hang|mode| is the number representing the semantic mode, as -just explained. - -\yskip\hang|head| is a |pointer| to a list head for the list being built; -|link(head)| therefore points to the first element of the list, or -to |null| if the list is empty. - -\yskip\hang|tail| is a |pointer| to the final node of the list being -built; thus, |tail=head| if and only if the list is empty. - -\yskip\hang|prev_graf| is the number of lines of the current paragraph that -have already been put into the present vertical list. - -\yskip\hang|aux| is an auxiliary |memory_word| that gives further information -that is needed to characterize the situation. - -\yskip\noindent -In vertical mode, |aux| is also known as |prev_depth|; it is the scaled -value representing the depth of the previous box, for use in baseline -calculations, or it is |<=-1000|pt if the next box on the vertical list is to -be exempt from baseline calculations. In horizontal mode, |aux| is also -known as |space_factor|; it holds the current space factor used in -spacing calculations. In math mode, |aux| is also known as |incompleat_noad|; -if not |null|, it points to a record that represents the numerator of a -generalized fraction for which the denominator is currently being formed -in the current list. - -There is also a sixth quantity, |mode_line|, which correlates -the semantic nest with the user's input; |mode_line| contains the source -line number at which the current level of nesting was entered. The negative -of this line number is the |mode_line| at the level of the -user's output routine. - -A seventh quantity, |eTeX_aux|, is used by the extended features \eTeX. -In math mode it is known as |delim_ptr| and points to the most -recent |fence_noad| of a |math_left_group|. - -In horizontal mode, the |prev_graf| field is used for initial language data. - -The semantic nest is an array called |nest| that holds the |mode|, |head|, -|tail|, |prev_graf|, |aux|, and |mode_line| values for all semantic levels -below the currently active one. Information about the currently active -level is kept in the global quantities |mode|, |head|, |tail|, |prev_graf|, -|aux|, and |mode_line|, which live in a \PASCAL\ record that is ready to -be pushed onto |nest| if necessary. - -The math field is used by various bits and pieces in |math.c| - -@d ignore_depth==-65536000 {magic dimension value to mean `ignore me'} - -@= -@!list_state_record=record@!mode_field:-mmode..mmode;@+ - @!head_field,@!tail_field: pointer; - @!eTeX_aux_field: pointer; - @!pg_field,@!ml_field: integer;@+ - @!aux_field: memory_word; - @!dirs_field: halfword; - @!math_field: integer; - @!math_style_field: integer; - end; - -@ @d mode==cur_list.mode_field {current mode} -@d head==cur_list.head_field {header node of current list} -@d tail==cur_list.tail_field {final node on current list} -@d eTeX_aux==cur_list.eTeX_aux_field {auxiliary data for \eTeX} -@d prev_graf==cur_list.pg_field {number of paragraph lines accumulated} -@d aux==cur_list.aux_field {auxiliary data about the current list} -@d prev_depth==aux.sc {the name of |aux| in vertical mode} -@d space_factor==aux.hh.lh {part of |aux| in horizontal mode} -@d incompleat_noad==aux.int {the name of |aux| in math mode} -@d mode_line==cur_list.ml_field {source file line number at beginning of list} -@d dir_save==cur_list.dirs_field {dir stack when a paragraph is interrupted} - -@= -@!nest:array[0..nest_size] of list_state_record; -@!nest_ptr:0..nest_size; {first unused location of |nest|} -@!max_nest_stack:0..nest_size; {maximum of |nest_ptr| when pushing} -@!cur_list:list_state_record; {the ``top'' semantic state} -@!shown_mode:-mmode..mmode; {most recent mode shown by \.{\\tracingcommands}} -@!save_tail: pointer; {save |tail| so we can examine whether we have an auto - kern before a glue} - -@ Here is a common way to make the current list grow: - -@p -procedure tail_append(p:pointer); -begin -vlink(tail):=p; tail:=vlink(tail); -end; -@# -procedure new_tail_append(p:pointer); -begin -couple_nodes(tail,p); tail:=vlink(tail); -end; -@# -function pop_tail:pointer; -label exit; -var n,r:pointer; -begin - if tail<>head then begin - r:=tail; - if vlink(alink(tail))=tail then - n:=alink(tail) - else begin - n:=head; - while vlink(n)<>tail do n:=vlink(n); - end; - flush_node(tail); - tail:=n; - vlink(n):=null; - pop_tail:=r; - end - else - pop_tail:=null; -exit:end; - - -@ We will see later that the vertical list at the bottom semantic level is split -into two parts; the ``current page'' runs from |page_head| to |page_tail|, -and the ``contribution list'' runs from |contrib_head| to |tail| of -semantic level zero. The idea is that contributions are first formed in -vertical mode, then ``contributed'' to the current page (during which time -the page-breaking decisions are made). For now, we don't need to know -any more details about the page-building process. - -@= -nest_ptr:=0; max_nest_stack:=0; -mode:=vmode; head:=contrib_head; tail:=contrib_head; -eTeX_aux:=null; -prev_depth:=ignore_depth; mode_line:=0; -prev_graf:=0; shown_mode:=0; -dir_save:=null; init_math_fields; -@; - -@ @p @; - -@ @p @; - -@ When \TeX's work on one level is interrupted, the state is saved by -calling |push_nest|. This routine changes |head| and |tail| so that -a new (empty) list is begun; it does not change |mode| or |aux|. - -@p procedure push_nest; {enter a new semantic level, save the old} -begin if nest_ptr>max_nest_stack then - begin max_nest_stack:=nest_ptr; - if nest_ptr=nest_size then overflow("semantic nest size",nest_size); -@:TeX capacity exceeded semantic nest size}{\quad semantic nest size@> - end; -nest[nest_ptr]:=cur_list; {stack the record} -incr(nest_ptr); head:=new_node(temp_node,0); tail:=head; prev_graf:=0; mode_line:=line; -dir_save:=null; init_math_fields; -eTeX_aux:=null; -end; - -@ Conversely, when \TeX\ is finished on the current level, the former -state is restored by calling |pop_nest|. This routine will never be -called at the lowest semantic level, nor will it be called unless |head| -is a node that should be returned to free memory. - -@p procedure pop_nest; {leave a semantic level, re-enter the old} -begin -flush_node(head); decr(nest_ptr); cur_list:=nest[nest_ptr]; -end; - -@ Here is a procedure that displays what \TeX\ is working on, at all levels. - -@p procedure@?print_totals; forward;@t\2@> -procedure show_activities; -var p:0..nest_size; {index into |nest|} -@!m:-mmode..mmode; {mode} -@!a:memory_word; {auxiliary} -@!q,@!r:pointer; {for showing the current page} -@!t:integer; {ditto} -begin nest[nest_ptr]:=cur_list; {put the top level into the array} -print_nl(""); print_ln; -for p:=nest_ptr downto 0 do - begin m:=nest[p].mode_field; a:=nest[p].aux_field; - print_nl("### "); print_mode(m); - print(" entered at line "); print_int(abs(nest[p].ml_field)); - if m=hmode then if nest[p].pg_field <> @'40600000 then - begin print(" (language"); print_int(nest[p].pg_field mod @'200000); - print(":hyphenmin"); print_int(nest[p].pg_field div @'20000000); - print_char(","); print_int((nest[p].pg_field div @'200000) mod @'100); - print_char(")"); - end; - if nest[p].ml_field<0 then print(" (\output routine)"); - if p=0 then - begin @; - if vlink(contrib_head)<>null then - print_nl("### recent contributions:"); - end; - show_box(vlink(nest[p].head_field)); - @; - end; -end; - -@ @= -case abs(m) div (max_command+1) of -0: begin print_nl("prevdepth "); - if a.sc<=pdf_ignored_dimen then print("ignored") - else print_scaled(a.sc); - if nest[p].pg_field<>0 then - begin print(", prevgraf "); - print_int(nest[p].pg_field); print(" line"); - if nest[p].pg_field<>1 then print_char("s"); - end; - end; -1: begin print_nl("spacefactor "); print_int(a.hh.lh); - if m>0 then@+ if a.hh.rh>0 then - begin print(", current language "); print_int(a.hh.rh);@+ - end; - end; -2: if a.int<>null then - begin print("this will be denominator of:"); show_box(a.int);@+ - end; -end {there are no other cases} - -@* \[17] The table of equivalents. -Now that we have studied the data structures for \TeX's semantic routines, -we ought to consider the data structures used by its syntactic routines. In -other words, our next concern will be -the tables that \TeX\ looks at when it is scanning -what the user has written. - -The biggest and most important such table is called |eqtb|. It holds the -current ``equivalents'' of things; i.e., it explains what things mean -or what their current values are, for all quantities that are subject to -the nesting structure provided by \TeX's grouping mechanism. There are six -parts to |eqtb|: - -\yskip\hangg 1) |eqtb[null_cs]| holds the current equivalent of the -zero-length control sequence. - -\yskip\hangg 2) |eqtb[hash_base..(glue_base-1)]| holds the current -equivalents of single- and multiletter control sequences. - -\yskip\hangg 3) |eqtb[glue_base..(local_base-1)]| holds the current -equivalents of glue parameters like the current baselineskip. - -\yskip\hangg 4) |eqtb[local_base..(int_base-1)]| holds the current -equivalents of local halfword quantities like the current box registers, -the current ``catcodes,'' the current font, and a pointer to the current -paragraph shape. - -\yskip\hangg 5) |eqtb[int_base..(dimen_base-1)]| holds the current -equivalents of fullword integer parameters like the current hyphenation -penalty. - -\yskip\hangg 6) |eqtb[dimen_base..eqtb_size]| holds the current equivalents -of fullword dimension parameters like the current hsize or amount of -hanging indentation. - -\yskip\noindent Note that, for example, the current amount of -baselineskip glue is determined by the setting of a particular location -in region~3 of |eqtb|, while the current meaning of the control sequence -`\.{\\baselineskip}' (which might have been changed by \.{\\def} or -\.{\\let}) appears in region~2. - -@ Each entry in |eqtb| is a |memory_word|. Most of these words are of type -|two_halves|, and subdivided into three fields: - -\yskip\hangg 1) The |eq_level| (a quarterword) is the level of grouping at -which this equivalent was defined. If the level is |level_zero|, the -equivalent has never been defined; |level_one| refers to the outer level -(outside of all groups), and this level is also used for global -definitions that never go away. Higher levels are for equivalents that -will disappear at the end of their group. @^global definitions@> - -\yskip\hangg 2) The |eq_type| (another quarterword) specifies what kind of -entry this is. There are many types, since each \TeX\ primitive like -\.{\\hbox}, \.{\\def}, etc., has its own special code. The list of -command codes above includes all possible settings of the |eq_type| field. - -\yskip\hangg 3) The |equiv| (a halfword) is the current equivalent value. -This may be a font number, a pointer into |mem|, or a variety of other -things. - -@d eq_level_field(#)==#.hh.b1 -@d eq_type_field(#)==#.hh.b0 -@d equiv_field(#)==#.hh.rh -@d eq_level(#)==eq_level_field(eqtb[#]) {level of definition} -@d eq_type(#)==eq_type_field(eqtb[#]) {command code for equivalent} -@d equiv(#)==equiv_field(eqtb[#]) {equivalent value} -@d level_zero=min_quarterword {level for undefined quantities} -@d level_one=level_zero+1 {outermost level for defined quantities} - -@ Many locations in |eqtb| have symbolic names. The purpose of the next -paragraphs is to define these names, and to set up the initial values of the -equivalents. - -In the first region we have a single entry for the `null csname' of -length zero. In luatex, the active characters and and single-letter -control sequence names are part of the next region. - -Then comes region~2, which corresponds to the hash table that we will -define later. The maximum address in this region is used for a dummy -control sequence that is perpetually undefined. There also are several -locations for control sequences that are perpetually defined -(since they are used in error recovery). - -@d null_cs=1 {equivalent of \.{\\csname\\endcsname}} -@d hash_base=null_cs+1 {beginning of region 2, for the hash table} -@d frozen_control_sequence=hash_base+hash_size {for error recovery} -@d frozen_protection=frozen_control_sequence {inaccessible but definable} -@d frozen_cr=frozen_control_sequence+1 {permanent `\.{\\cr}'} -@d frozen_end_group=frozen_control_sequence+2 {permanent `\.{\\endgroup}'} -@d frozen_right=frozen_control_sequence+3 {permanent `\.{\\right}'} -@d frozen_fi=frozen_control_sequence+4 {permanent `\.{\\fi}'} -@d frozen_end_template=frozen_control_sequence+5 {permanent `\.{\\endtemplate}'} -@d frozen_endv=frozen_control_sequence+6 {second permanent `\.{\\endtemplate}'} -@d frozen_relax=frozen_control_sequence+7 {permanent `\.{\\relax}'} -@d end_write=frozen_control_sequence+8 {permanent `\.{\\endwrite}'} -@d frozen_dont_expand=frozen_control_sequence+9 - {permanent `\.{\\notexpanded:}'} -@d frozen_primitive=frozen_control_sequence+11 - {permanent `\.{\\pdfprimitive}'} -@d frozen_special=frozen_control_sequence+12 - {permanent `\.{\\special}'} -@d frozen_null_font=frozen_control_sequence+13 - {permanent `\.{\\nullfont}'} -@d font_id_base=frozen_null_font-font_base - {begins table of |number_fonts| permanent font identifiers} -@d frozen_null_ocp=frozen_null_font+number_fonts - {permanent `\.{\\nullocp}'} -@d ocp_id_base=frozen_null_ocp-ocp_base - {begins table of |number_ocps| permanent ocp identifiers} -@d frozen_null_ocp_list=frozen_null_ocp+number_ocps - {permanent `\.{\\nullocplist}'} -@d ocp_list_id_base=frozen_null_ocp_list-ocp_list_base - {begins table of |number_ocp_lists| permanent ocp list identifiers} -@d undefined_control_sequence=frozen_null_ocp_list+number_ocp_lists -@d glue_base=undefined_control_sequence+1 {beginning of region 3} - -@= -eq_type(undefined_control_sequence):=undefined_cs; -equiv(undefined_control_sequence):=null; -eq_level(undefined_control_sequence):=level_zero; -for k:=null_cs to undefined_control_sequence-1 do - eqtb[k]:=eqtb[undefined_control_sequence]; - -@ Create a C version of |undefined_control_sequence|. - -@= -@!static_undefined_control_sequence:integer; - -@ @= -static_undefined_control_sequence:=undefined_control_sequence; - -@ Here is a routine that displays the current meaning of an |eqtb| entry -in region 1 or~2. (Similar routines for the other regions will appear -below.) - -@= -begin sprint_cs(n); print_char("="); print_cmd_chr(eq_type(n),equiv(n)); -if eq_type(n)>=call then - begin print_char(":"); show_token_list(link(equiv(n)),null,32); - end; -end - -@ Region 3 of |eqtb| contains the |number_regs| \.{\\skip} registers, as well as the -glue parameters defined here. It is important that the ``muskip'' -parameters have larger numbers than the others. - -@d line_skip_code=0 {interline glue if |baseline_skip| is infeasible} -@d baseline_skip_code=1 {desired glue between baselines} -@d par_skip_code=2 {extra glue just above a paragraph} -@d above_display_skip_code=3 {extra glue just above displayed math} -@d below_display_skip_code=4 {extra glue just below displayed math} -@d above_display_short_skip_code=5 - {glue above displayed math following short lines} -@d below_display_short_skip_code=6 - {glue below displayed math following short lines} -@d left_skip_code=7 {glue at left of justified lines} -@d right_skip_code=8 {glue at right of justified lines} -@d top_skip_code=9 {glue at top of main pages} -@d split_top_skip_code=10 {glue at top of split pages} -@d tab_skip_code=11 {glue between aligned entries} -@d space_skip_code=12 {glue between words (if not |zero_glue|)} -@d xspace_skip_code=13 {glue after sentences (if not |zero_glue|)} -@d par_fill_skip_code=14 {glue on last line of paragraph} -@d thin_mu_skip_code=15 {thin space in math formula} -@d med_mu_skip_code=16 {medium space in math formula} -@d thick_mu_skip_code=17 {thick space in math formula} -@d glue_pars=18 {total number of glue parameters} -@d skip_base=glue_base+glue_pars {table of |number_regs| ``skip'' registers} -@d mu_skip_base=skip_base+number_regs {table of |number_regs| ``muskip'' registers} -@d local_base=mu_skip_base+number_regs {beginning of region 4} -@# -@d skip(#)==equiv(skip_base+#) {|mem| location of glue specification} -@d mu_skip(#)==equiv(mu_skip_base+#) {|mem| location of math glue spec} -@d glue_par(#)==equiv(glue_base+#) {|mem| location of glue specification} -@d line_skip==glue_par(line_skip_code) -@d baseline_skip==glue_par(baseline_skip_code) -@d par_skip==glue_par(par_skip_code) -@d above_display_skip==glue_par(above_display_skip_code) -@d below_display_skip==glue_par(below_display_skip_code) -@d above_display_short_skip==glue_par(above_display_short_skip_code) -@d below_display_short_skip==glue_par(below_display_short_skip_code) -@d left_skip==glue_par(left_skip_code) -@d right_skip==glue_par(right_skip_code) -@d top_skip==glue_par(top_skip_code) -@d split_top_skip==glue_par(split_top_skip_code) -@d tab_skip==glue_par(tab_skip_code) -@d space_skip==glue_par(space_skip_code) -@d xspace_skip==glue_par(xspace_skip_code) -@d par_fill_skip==glue_par(par_fill_skip_code) -@d thin_mu_skip==glue_par(thin_mu_skip_code) -@d med_mu_skip==glue_par(med_mu_skip_code) -@d thick_mu_skip==glue_par(thick_mu_skip_code) - -@=glue_par(n) - -@ @= -static_local_base:=local_base; -static_glue_base:=glue_base; - -@ Sometimes we need to convert \TeX's internal code numbers into symbolic -form. The |print_skip_param| routine gives the symbolic name of a glue -parameter. - -@= -procedure print_skip_param(@!n:integer); -begin case n of -line_skip_code: print_esc("lineskip"); -baseline_skip_code: print_esc("baselineskip"); -par_skip_code: print_esc("parskip"); -above_display_skip_code: print_esc("abovedisplayskip"); -below_display_skip_code: print_esc("belowdisplayskip"); -above_display_short_skip_code: print_esc("abovedisplayshortskip"); -below_display_short_skip_code: print_esc("belowdisplayshortskip"); -left_skip_code: print_esc("leftskip"); -right_skip_code: print_esc("rightskip"); -top_skip_code: print_esc("topskip"); -split_top_skip_code: print_esc("splittopskip"); -tab_skip_code: print_esc("tabskip"); -space_skip_code: print_esc("spaceskip"); -xspace_skip_code: print_esc("xspaceskip"); -par_fill_skip_code: print_esc("parfillskip"); -thin_mu_skip_code: print_esc("thinmuskip"); -med_mu_skip_code: print_esc("medmuskip"); -thick_mu_skip_code: print_esc("thickmuskip"); -othercases print("[unknown glue parameter!]") -endcases; -end; - -@ The symbolic names for glue parameters are put into \TeX's hash table -by using the routine called |primitive|, defined below. Let us enter them -now, so that we don't have to list all those parameter names anywhere else. - -@= -primitive_tex("lineskip",assign_glue,glue_base+line_skip_code,glue_base);@/ -@!@:line_skip_}{\.{\\lineskip} primitive@> -primitive_tex("baselineskip",assign_glue,glue_base+baseline_skip_code,glue_base);@/ -@!@:baseline_skip_}{\.{\\baselineskip} primitive@> -primitive_tex("parskip",assign_glue,glue_base+par_skip_code,glue_base);@/ -@!@:par_skip_}{\.{\\parskip} primitive@> -primitive_tex("abovedisplayskip",assign_glue,glue_base+above_display_skip_code,glue_base);@/ -@!@:above_display_skip_}{\.{\\abovedisplayskip} primitive@> -primitive_tex("belowdisplayskip",assign_glue,glue_base+below_display_skip_code,glue_base);@/ -@!@:below_display_skip_}{\.{\\belowdisplayskip} primitive@> -primitive_tex("abovedisplayshortskip",assign_glue,glue_base+above_display_short_skip_code,glue_base);@/ -@!@:above_display_short_skip_}{\.{\\abovedisplayshortskip} primitive@> -primitive_tex("belowdisplayshortskip",assign_glue,glue_base+below_display_short_skip_code,glue_base);@/ -@!@:below_display_short_skip_}{\.{\\belowdisplayshortskip} primitive@> -primitive_tex("leftskip",assign_glue,glue_base+left_skip_code,glue_base);@/ -@!@:left_skip_}{\.{\\leftskip} primitive@> -primitive_tex("rightskip",assign_glue,glue_base+right_skip_code,glue_base);@/ -@!@:right_skip_}{\.{\\rightskip} primitive@> -primitive_tex("topskip",assign_glue,glue_base+top_skip_code,glue_base);@/ -@!@:top_skip_}{\.{\\topskip} primitive@> -primitive_tex("splittopskip",assign_glue,glue_base+split_top_skip_code,glue_base);@/ -@!@:split_top_skip_}{\.{\\splittopskip} primitive@> -primitive_tex("tabskip",assign_glue,glue_base+tab_skip_code,glue_base);@/ -@!@:tab_skip_}{\.{\\tabskip} primitive@> -primitive_tex("spaceskip",assign_glue,glue_base+space_skip_code,glue_base);@/ -@!@:space_skip_}{\.{\\spaceskip} primitive@> -primitive_tex("xspaceskip",assign_glue,glue_base+xspace_skip_code,glue_base);@/ -@!@:xspace_skip_}{\.{\\xspaceskip} primitive@> -primitive_tex("parfillskip",assign_glue,glue_base+par_fill_skip_code,glue_base);@/ -@!@:par_fill_skip_}{\.{\\parfillskip} primitive@> -primitive_tex("thinmuskip",assign_mu_glue,glue_base+thin_mu_skip_code,glue_base+thin_mu_skip_code);@/ -@!@:thin_mu_skip_}{\.{\\thinmuskip} primitive@> -primitive_tex("medmuskip",assign_mu_glue,glue_base+med_mu_skip_code,glue_base+thin_mu_skip_code);@/ -@!@:med_mu_skip_}{\.{\\medmuskip} primitive@> -primitive_tex("thickmuskip",assign_mu_glue,glue_base+thick_mu_skip_code,glue_base+thin_mu_skip_code);@/ -@!@:thick_mu_skip_}{\.{\\thickmuskip} primitive@> - -@ All glue parameters and registers are initially `\.{0pt plus0pt minus0pt}'. - -@= -equiv(glue_base):=zero_glue; eq_level(glue_base):=level_one; -eq_type(glue_base):=glue_ref; -for k:=glue_base+1 to local_base-1 do eqtb[k]:=eqtb[glue_base]; -glue_ref_count(zero_glue):=glue_ref_count(zero_glue)+local_base-glue_base; - -@ @= -begin -if n= -primitive_tex("output",assign_toks,output_routine_loc,local_base); -@!@:output_}{\.{\\output} primitive@> -primitive_tex("everypar",assign_toks,every_par_loc,local_base); -@!@:every_par_}{\.{\\everypar} primitive@> -primitive_tex("everymath",assign_toks,every_math_loc,local_base); -@!@:every_math_}{\.{\\everymath} primitive@> -primitive_tex("everydisplay",assign_toks,every_display_loc,local_base); -@!@:every_display_}{\.{\\everydisplay} primitive@> -primitive_tex("everyhbox",assign_toks,every_hbox_loc,local_base); -@!@:every_hbox_}{\.{\\everyhbox} primitive@> -primitive_tex("everyvbox",assign_toks,every_vbox_loc,local_base); -@!@:every_vbox_}{\.{\\everyvbox} primitive@> -primitive_tex("everyjob",assign_toks,every_job_loc,local_base); -@!@:every_job_}{\.{\\everyjob} primitive@> -primitive_tex("everycr",assign_toks,every_cr_loc,local_base); -@!@:every_cr_}{\.{\\everycr} primitive@> -primitive_tex("errhelp",assign_toks,err_help_loc,local_base); -@!@:err_help_}{\.{\\errhelp} primitive@> -primitive_pdftex("pdfpagesattr",assign_toks,pdf_pages_attr_loc,local_base); -@!@:pdf_pages_attr_}{\.{\\pdfpagesattr} primitive@> -primitive_pdftex("pdfpageattr",assign_toks,pdf_page_attr_loc,local_base); -@!@:pdf_page_attr_}{\.{\\pdfpageattr} primitive@> -primitive_pdftex("pdfpageresources",assign_toks,pdf_page_resources_loc,local_base); -@!@:pdf_page_resources_}{\.{\\pdfpageresources} primitive@> -primitive_pdftex("pdfpkmode",assign_toks,pdf_pk_mode_loc,local_base); -@!@:pdf_pk_mode_}{\.{\\pdfpkmode} primitive@> - - -@ We initialize most things to null or undefined values. An undefined font -is represented by the internal code |font_base|. - -However, the character code tables are given initial values based on the -conventional interpretation of ASCII code. These initial values should -not be changed when \TeX\ is adapted for use with non-English languages; -all changes to the initialization conventions should be made in format -packages, not in \TeX\ itself, so that global interchange of formats is -possible. - -@d null_font==font_base -@d null_ocp==ocp_base -@d null_ocp_list==ocp_list_base -@d var_code==7 {math code meaning ``use the current family''} - -@= -par_shape_ptr:=null; eq_type(par_shape_loc):=shape_ref; -eq_level(par_shape_loc):=level_one;@/ -for k:=etex_pen_base to etex_pens-1 do - eqtb[k]:=eqtb[par_shape_loc]; -for k:=output_routine_loc to toks_base+biggest_reg do - eqtb[k]:=eqtb[undefined_control_sequence]; -box(0):=null; eq_type(box_base):=box_ref; eq_level(box_base):=level_one; -for k:=box_base+1 to box_base+biggest_reg do eqtb[k]:=eqtb[box_base]; -cur_font:=null_font; eq_type(cur_font_loc):=data; -eq_level(cur_font_loc):=level_one;@/ -equiv(cat_code_base):=0; eq_type(cat_code_base):=data; -eq_level(cat_code_base):=level_one;@/ -eqtb[math_param_base]:=eqtb[cat_code_base]; -eqtb[lc_code_base] :=eqtb[cat_code_base]; -eqtb[uc_code_base] :=eqtb[cat_code_base]; -eqtb[sf_code_base] :=eqtb[cat_code_base]; -eqtb[math_code_base]:=eqtb[cat_code_base];@/ -cat_code_table:=0; -initialize_math_codes; -initialize_text_codes; -initex_cat_codes(0); -for k:="0" to "9" do set_math_code(k,tex_mathcode,var_code,0,k,level_one);@/ -for k:="A" to "Z" do begin - set_math_code(k,tex_mathcode,var_code,1,k,level_one); - set_math_code((k+32),tex_mathcode,var_code,1,(k+32),level_one);@/ - set_lc_code(k,k+32,level_one); set_lc_code(k+32,k+32,level_one);@/ - set_uc_code(k,k,level_one); set_uc_code(k+32,k,level_one);@/ - set_sf_code(k,999,level_one); - end; - -@ @= -static_int_base:=int_base; - -@ @= -begin -if (n=par_shape_loc) or ((n>=etex_pen_base) and (npar_shape_loc then - begin print_int(penalty(equiv(n))); print_char(" "); - print_int(penalty(equiv(n)+1)); - if penalty(equiv(n))>1 then print_esc("ETC."); - end - else print_int(vinfo(par_shape_ptr+1)); - end -else if n; -end - -@ @= -begin print("current font"); print_char("=");@/ -print_esc(hash[font_id_base+equiv(n)].rh); - {that's |font_id_text(equiv(n))|} -end - -@ Region 5 of |eqtb| contains the integer parameters and registers defined -here, as well as the |del_code| table. The latter table differs from the -|cat_code..math_code| tables that precede it, since delimiter codes are -fullword integers while the other kinds of codes occupy at most a -halfword. This is what makes region~5 different from region~4. We will -store the |eq_level| information in an auxiliary array of quarterwords -that will be defined later. - -@d pretolerance_code=0 {badness tolerance before hyphenation} -@d tolerance_code=1 {badness tolerance after hyphenation} -@d line_penalty_code=2 {added to the badness of every line} -@d hyphen_penalty_code=3 {penalty for break after discretionary hyphen} -@d ex_hyphen_penalty_code=4 {penalty for break after explicit hyphen} -@d club_penalty_code=5 {penalty for creating a club line} -@d widow_penalty_code=6 {penalty for creating a widow line} -@d display_widow_penalty_code=7 {ditto, just before a display} -@d broken_penalty_code=8 {penalty for breaking a page at a broken line} -@d bin_op_penalty_code=9 {penalty for breaking after a binary operation} -@d rel_penalty_code=10 {penalty for breaking after a relation} -@d pre_display_penalty_code=11 {penalty for breaking just before a displayed formula} -@d post_display_penalty_code=12 {penalty for breaking just after a displayed formula} -@d inter_line_penalty_code=13 {additional penalty between lines} -@d double_hyphen_demerits_code=14 {demerits for double hyphen break} -@d final_hyphen_demerits_code=15 {demerits for final hyphen break} -@d adj_demerits_code=16 {demerits for adjacent incompatible lines} -@d mag_code=17 {magnification ratio} -@d delimiter_factor_code=18 {ratio for variable-size delimiters} -@d looseness_code=19 {change in number of lines for a paragraph} -@d time_code=20 {current time of day} -@d day_code=21 {current day of the month} -@d month_code=22 {current month of the year} -@d year_code=23 {current year of our Lord} -@d show_box_breadth_code=24 {nodes per level in |show_box|} -@d show_box_depth_code=25 {maximum level in |show_box|} -@d hbadness_code=26 {hboxes exceeding this badness will be shown by |hpack|} -@d vbadness_code=27 {vboxes exceeding this badness will be shown by |vpack|} -@d pausing_code=28 {pause after each line is read from a file} -@d tracing_online_code=29 {show diagnostic output on terminal} -@d tracing_macros_code=30 {show macros as they are being expanded} -@d tracing_stats_code=31 {show memory usage if \TeX\ knows it} -@d tracing_paragraphs_code=32 {show line-break calculations} -@d tracing_pages_code=33 {show page-break calculations} -@d tracing_output_code=34 {show boxes when they are shipped out} -@d tracing_lost_chars_code=35 {show characters that aren't in the font} -@d tracing_commands_code=36 {show command codes at |big_switch|} -@d tracing_restores_code=37 {show equivalents when they are restored} -@d uc_hyph_code=38 {hyphenate words beginning with a capital letter} -@d output_penalty_code=39 {penalty found at current page break} -@d max_dead_cycles_code=40 {bound on consecutive dead cycles of output} -@d hang_after_code=41 {hanging indentation changes after this many lines} -@d floating_penalty_code=42 {penalty for insertions heldover after a split} -@d global_defs_code=43 {override \.{\\global} specifications} -@d cur_fam_code=44 {current family} -@d escape_char_code=45 {escape character for token output} -@d default_hyphen_char_code=46 {value of \.{\\hyphenchar} when a font is loaded} -@d default_skew_char_code=47 {value of \.{\\skewchar} when a font is loaded} -@d end_line_char_code=48 {character placed at the right end of the buffer} -@d new_line_char_code=49 {character that prints as |print_ln|} -@d language_code=50 {current hyphenation table} -@d left_hyphen_min_code=51 {minimum left hyphenation fragment size} -@d right_hyphen_min_code=52 {minimum right hyphenation fragment size} -@d holding_inserts_code=53 {do not remove insertion nodes from \.{\\box255}} -@d error_context_lines_code=54 {maximum intermediate line pairs shown} -@d local_inter_line_penalty_code=55 {local \.{\\interlinepenalty}} -@d local_broken_penalty_code=56 {local \.{\\brokenpenalty}} -@d no_local_whatsits_code=57 {counts local whatsits} -@d no_local_dirs_code=58 -@d level_local_dir_code=59 -@d luastartup_id_code=60 -@d disable_lig_code=61 -@d disable_kern_code=62 -@d cat_code_table_code=63 -@d output_box_code=64 -@d cur_lang_code=65 {current language id} -@d ex_hyphen_char_code=66 -@d tex_int_pars=67 {total number of \.{\\TeX} + Aleph integer parameters} -@# -@d dir_base=int_base+tex_int_pars -@d page_direction_code=0 -@d body_direction_code=1 -@d par_direction_code=2 -@d text_direction_code=3 -@d math_direction_code=4 -@d dir_pars=5 -@# -@d pdftex_first_integer_code = tex_int_pars+dir_pars {base for \pdfTeX's integer parameters} -@d pdf_output_code = pdftex_first_integer_code + 0 {switch on PDF output if positive} -@d pdf_compress_level_code = pdftex_first_integer_code + 1 {compress level of streams} -@d pdf_decimal_digits_code = pdftex_first_integer_code + 2 {digits after the decimal point of numbers} -@d pdf_move_chars_code = pdftex_first_integer_code + 3 {move chars 0..31 to higher area if possible} -@d pdf_image_resolution_code = pdftex_first_integer_code + 4 {default image resolution} -@d pdf_pk_resolution_code = pdftex_first_integer_code + 5 {default resolution of PK font} -@d pdf_unique_resname_code = pdftex_first_integer_code + 6 {generate unique names for resouces} -@d pdf_option_always_use_pdfpagebox_code = pdftex_first_integer_code + 7 {if the PDF inclusion should always use a specific PDF page box} -@d pdf_option_pdf_inclusion_errorlevel_code = pdftex_first_integer_code + 8 {if the PDF inclusion should treat pdfs newer than |pdf_minor_version| as an error} -@d pdf_minor_version_code = pdftex_first_integer_code + 9 {fractional part of the PDF version produced} -@d pdf_force_pagebox_code = pdftex_first_integer_code + 10 {if the PDF inclusion should always use a specific PDF page box} -@d pdf_pagebox_code = pdftex_first_integer_code + 11 {default pagebox to use for PDF inclusion} -@d pdf_inclusion_errorlevel_code = pdftex_first_integer_code + 12 {if the PDF inclusion should treat pdfs newer than |pdf_minor_version| as an error} -@d pdf_gamma_code = pdftex_first_integer_code + 13 -@d pdf_image_gamma_code = pdftex_first_integer_code + 14 -@d pdf_image_hicolor_code = pdftex_first_integer_code + 15 -@d pdf_image_apply_gamma_code = pdftex_first_integer_code + 16 -@d pdf_adjust_spacing_code = pdftex_first_integer_code + 17 {level of spacing adjusting} -@d pdf_protrude_chars_code = pdftex_first_integer_code + 18 {protrude chars at left/right edge of paragraphs} -@d pdf_tracing_fonts_code = pdftex_first_integer_code + 19 {level of font detail in log} -@d pdf_objcompresslevel_code = pdftex_first_integer_code + 20 {activate object streams} -@d pdf_gen_tounicode_code = pdftex_first_integer_code + 24 {generate ToUnicode for fonts?} -@d pdf_draftmode_code = pdftex_first_integer_code + 25 {switch on draftmode if positive} -@d pdf_replace_font_code = pdftex_first_integer_code + 26 {generate ToUnicode for fonts?} -@d pdf_inclusion_copy_font_code = pdftex_first_integer_code + 27 {generate ToUnicode for fonts?} -@d pdf_int_pars=pdftex_first_integer_code + 28 {total number of \pdfTeX's integer parameters} -@# -@d etex_int_base=pdf_int_pars {base for \eTeX's integer parameters} -@d tracing_assigns_code=etex_int_base {show assignments} -@d tracing_groups_code=etex_int_base+1 {show save/restore groups} -@d tracing_ifs_code=etex_int_base+2 {show conditionals} -@d tracing_scan_tokens_code=etex_int_base+3 {show pseudo file open and close} -@d tracing_nesting_code=etex_int_base+4 {show incomplete groups and ifs within files} -@d pre_display_direction_code=etex_int_base+5 {text direction preceding a display} -@d last_line_fit_code=etex_int_base+6 {adjustment for last line of paragraph} -@d saving_vdiscards_code=etex_int_base+7 {save items discarded from vlists} -@d saving_hyph_codes_code=etex_int_base+8 {save hyphenation codes for languages} -@d suppress_fontnotfound_error_code=etex_int_base+9 {surpress errors for missing fonts} -@d suppress_long_error_code=etex_int_base+10 {surpress errors for missing fonts} -@d suppress_ifcsname_error_code=etex_int_base+11 {surpress errors for failed \.{\\ifcsname}} -@d suppress_outer_error_code=etex_int_base+12 {surpress errors for \.{\\outer}} -@d etex_int_pars=etex_int_base+13 {total number of \eTeX's integer parameters} -@# -@d synctex_code=etex_int_pars { is synctex file generation enabled ? } -@d int_pars=synctex_code+1 {total number of integer parameters} -@d count_base=int_base+int_pars {|number_regs| user \.{\\count} registers} -@d attribute_base=count_base+number_regs {|number_attrs| user \.{\\attribute} registers} -@d del_code_base=attribute_base+number_attrs {|number_chars| delimiter code mappings} -@d dimen_base=del_code_base+1 {beginning of region 6} -@# -@d count(#)==eqtb[count_base+#].int -@d attribute(#)==eqtb[attribute_base+#].int -@d int_par(#)==eqtb[int_base+#].int {an integer parameter} -@d pretolerance==int_par(pretolerance_code) -@d tolerance==int_par(tolerance_code) -@d line_penalty==int_par(line_penalty_code) -@d hyphen_penalty==int_par(hyphen_penalty_code) -@d ex_hyphen_penalty==int_par(ex_hyphen_penalty_code) -@d club_penalty==int_par(club_penalty_code) -@d widow_penalty==int_par(widow_penalty_code) -@d display_widow_penalty==int_par(display_widow_penalty_code) -@d broken_penalty==int_par(broken_penalty_code) -@d bin_op_penalty==int_par(bin_op_penalty_code) -@d rel_penalty==int_par(rel_penalty_code) -@d pre_display_penalty==int_par(pre_display_penalty_code) -@d post_display_penalty==int_par(post_display_penalty_code) -@d inter_line_penalty==int_par(inter_line_penalty_code) -@d double_hyphen_demerits==int_par(double_hyphen_demerits_code) -@d final_hyphen_demerits==int_par(final_hyphen_demerits_code) -@d adj_demerits==int_par(adj_demerits_code) -@d mag==int_par(mag_code) -@d delimiter_factor==int_par(delimiter_factor_code) -@d looseness==int_par(looseness_code) -@d time==int_par(time_code) -@d day==int_par(day_code) -@d month==int_par(month_code) -@d year==int_par(year_code) -@d show_box_breadth==int_par(show_box_breadth_code) -@d show_box_depth==int_par(show_box_depth_code) -@d hbadness==int_par(hbadness_code) -@d vbadness==int_par(vbadness_code) -@d pausing==int_par(pausing_code) -@d tracing_online==int_par(tracing_online_code) -@d tracing_macros==int_par(tracing_macros_code) -@d tracing_stats==int_par(tracing_stats_code) -@d tracing_paragraphs==int_par(tracing_paragraphs_code) -@d tracing_pages==int_par(tracing_pages_code) -@d tracing_output==int_par(tracing_output_code) -@d tracing_lost_chars==int_par(tracing_lost_chars_code) -@d tracing_commands==int_par(tracing_commands_code) -@d tracing_restores==int_par(tracing_restores_code) -@d uc_hyph==int_par(uc_hyph_code) -@d output_penalty==int_par(output_penalty_code) -@d max_dead_cycles==int_par(max_dead_cycles_code) -@d hang_after==int_par(hang_after_code) -@d floating_penalty==int_par(floating_penalty_code) -@d global_defs==int_par(global_defs_code) -@d cur_fam==int_par(cur_fam_code) -@d escape_char==int_par(escape_char_code) -@d default_hyphen_char==int_par(default_hyphen_char_code) -@d default_skew_char==int_par(default_skew_char_code) -@d end_line_char==int_par(end_line_char_code) -@d new_line_char==int_par(new_line_char_code) -@d local_inter_line_penalty==int_par(local_inter_line_penalty_code) -@d local_broken_penalty==int_par(local_broken_penalty_code) -@d no_local_whatsits==int_par(no_local_whatsits_code) -@d no_local_dirs==int_par(no_local_dirs_code) -@d level_local_dir==int_par(level_local_dir_code) -@d dir_par(#)==eqtb[dir_base+#].int {a direction parameter} -@d page_direction==dir_par(page_direction_code) -@d body_direction==dir_par(body_direction_code) -@d par_direction==dir_par(par_direction_code) -@d text_direction==dir_par(text_direction_code) -@d math_direction==dir_par(math_direction_code) -@d language==int_par(language_code) -@d cur_lang==int_par(cur_lang_code) -@d ex_hyphen_char==int_par(ex_hyphen_char_code) -@d left_hyphen_min==int_par(left_hyphen_min_code) -@d right_hyphen_min==int_par(right_hyphen_min_code) -@d holding_inserts==int_par(holding_inserts_code) -@d error_context_lines==int_par(error_context_lines_code) -@d luastartup_id==int_par(luastartup_id_code) -@d disable_lig==int_par(disable_lig_code) -@d disable_kern==int_par(disable_kern_code) -@d cat_code_table==int_par(cat_code_table_code) -@d output_box==int_par(output_box_code) -@# -@d pdf_adjust_spacing == int_par(pdf_adjust_spacing_code) -@d pdf_protrude_chars == int_par(pdf_protrude_chars_code) -@d pdf_tracing_fonts == int_par(pdf_tracing_fonts_code) -@d pdf_gen_tounicode == int_par(pdf_gen_tounicode_code) -@d pdf_output == int_par(pdf_output_code) -@d pdf_compress_level == int_par(pdf_compress_level_code) -@d pdf_objcompresslevel == int_par(pdf_objcompresslevel_code) -@d pdf_decimal_digits == int_par(pdf_decimal_digits_code) -@d pdf_move_chars == int_par(pdf_move_chars_code) -@d pdf_image_resolution == int_par(pdf_image_resolution_code) -@d pdf_pk_resolution == int_par(pdf_pk_resolution_code) -@d pdf_unique_resname == int_par(pdf_unique_resname_code) -@d pdf_option_always_use_pdfpagebox == int_par(pdf_option_always_use_pdfpagebox_code) -@d pdf_option_pdf_inclusion_errorlevel == int_par(pdf_option_pdf_inclusion_errorlevel_code) -@d pdf_minor_version == int_par(pdf_minor_version_code) -@d pdf_force_pagebox == int_par(pdf_force_pagebox_code) -@d pdf_pagebox == int_par(pdf_pagebox_code) -@d pdf_inclusion_errorlevel == int_par(pdf_inclusion_errorlevel_code) -@d pdf_gamma == int_par(pdf_gamma_code) -@d pdf_image_gamma == int_par(pdf_image_gamma_code) -@d pdf_image_hicolor == int_par(pdf_image_hicolor_code) -@d pdf_image_apply_gamma == int_par(pdf_image_apply_gamma_code) -@d pdf_draftmode == int_par(pdf_draftmode_code) -@d pdf_inclusion_copy_font == int_par(pdf_inclusion_copy_font_code) -@d pdf_replace_font == int_par(pdf_replace_font_code) -@# -@d tracing_assigns==int_par(tracing_assigns_code) -@d tracing_groups==int_par(tracing_groups_code) -@d tracing_ifs==int_par(tracing_ifs_code) -@d tracing_scan_tokens==int_par(tracing_scan_tokens_code) -@d tracing_nesting==int_par(tracing_nesting_code) -@d pre_display_direction==int_par(pre_display_direction_code) -@d last_line_fit==int_par(last_line_fit_code) -@d saving_vdiscards==int_par(saving_vdiscards_code) -@d saving_hyph_codes==int_par(saving_hyph_codes_code) -@d suppress_fontnotfound_error==int_par(suppress_fontnotfound_error_code) -@d suppress_long_error==int_par(suppress_long_error_code) -@d suppress_ifcsname_error==int_par(suppress_ifcsname_error_code) -@d synctex==int_par(synctex_code) - -@= -depth_threshold:=show_box_depth; -breadth_max:=show_box_breadth - - -@ @= -static_dimen_base:=dimen_base; - -@ We can print the symbolic name of an integer parameter as follows. - -@p procedure print_param(@!n:integer); -begin case n of -pretolerance_code:print_esc("pretolerance"); -tolerance_code:print_esc("tolerance"); -line_penalty_code:print_esc("linepenalty"); -hyphen_penalty_code:print_esc("hyphenpenalty"); -ex_hyphen_penalty_code:print_esc("exhyphenpenalty"); -club_penalty_code:print_esc("clubpenalty"); -widow_penalty_code:print_esc("widowpenalty"); -display_widow_penalty_code:print_esc("displaywidowpenalty"); -broken_penalty_code:print_esc("brokenpenalty"); -bin_op_penalty_code:print_esc("binoppenalty"); -rel_penalty_code:print_esc("relpenalty"); -pre_display_penalty_code:print_esc("predisplaypenalty"); -post_display_penalty_code:print_esc("postdisplaypenalty"); -inter_line_penalty_code:print_esc("interlinepenalty"); -double_hyphen_demerits_code:print_esc("doublehyphendemerits"); -final_hyphen_demerits_code:print_esc("finalhyphendemerits"); -adj_demerits_code:print_esc("adjdemerits"); -mag_code:print_esc("mag"); -delimiter_factor_code:print_esc("delimiterfactor"); -looseness_code:print_esc("looseness"); -time_code:print_esc("time"); -day_code:print_esc("day"); -month_code:print_esc("month"); -year_code:print_esc("year"); -show_box_breadth_code:print_esc("showboxbreadth"); -show_box_depth_code:print_esc("showboxdepth"); -hbadness_code:print_esc("hbadness"); -vbadness_code:print_esc("vbadness"); -pausing_code:print_esc("pausing"); -tracing_online_code:print_esc("tracingonline"); -tracing_macros_code:print_esc("tracingmacros"); -tracing_stats_code:print_esc("tracingstats"); -tracing_paragraphs_code:print_esc("tracingparagraphs"); -tracing_pages_code:print_esc("tracingpages"); -tracing_output_code:print_esc("tracingoutput"); -tracing_lost_chars_code:print_esc("tracinglostchars"); -tracing_commands_code:print_esc("tracingcommands"); -tracing_restores_code:print_esc("tracingrestores"); -uc_hyph_code:print_esc("uchyph"); -output_penalty_code:print_esc("outputpenalty"); -max_dead_cycles_code:print_esc("maxdeadcycles"); -hang_after_code:print_esc("hangafter"); -floating_penalty_code:print_esc("floatingpenalty"); -global_defs_code:print_esc("globaldefs"); -cur_fam_code:print_esc("fam"); -escape_char_code:print_esc("escapechar"); -default_hyphen_char_code:print_esc("defaulthyphenchar"); -default_skew_char_code:print_esc("defaultskewchar"); -end_line_char_code:print_esc("endlinechar"); -new_line_char_code:print_esc("newlinechar"); -language_code:print_esc("language"); -cur_lang_code:print_esc("setlanguage"); -ex_hyphen_char_code:print_esc("exhyphenchar"); -left_hyphen_min_code:print_esc("lefthyphenmin"); -right_hyphen_min_code:print_esc("righthyphenmin"); -holding_inserts_code:print_esc("holdinginserts"); -error_context_lines_code:print_esc("errorcontextlines"); -luastartup_id_code:print_esc("luastartup"); -disable_lig_code:print_esc("noligs"); -disable_kern_code:print_esc("nokerns"); -cat_code_table_code:print_esc("catcodetable"); -output_box_code:print_esc("outputbox"); -@# -local_inter_line_penalty_code: print_esc("localinterlinepenalty"); -local_broken_penalty_code: print_esc("localbrokenpenalty"); -{the next three do not have a matching primitive} -no_local_whatsits_code: print("[no_local_whatsits]"); -no_local_dirs_code: print("[no_local_dirs]"); -level_local_dir_code: print("[level_local_dir]"); -@# -pdf_output_code: print_esc("pdfoutput"); -pdf_compress_level_code: print_esc("pdfcompresslevel"); -pdf_objcompresslevel_code: print_esc("pdfobjcompresslevel"); -pdf_decimal_digits_code: print_esc("pdfdecimaldigits"); -pdf_move_chars_code: print_esc("pdfmovechars"); -pdf_image_resolution_code: print_esc("pdfimageresolution"); -pdf_pk_resolution_code: print_esc("pdfpkresolution"); -pdf_unique_resname_code: print_esc("pdfuniqueresname"); -pdf_option_always_use_pdfpagebox_code: print_esc("pdfoptionalwaysusepdfpagebox"); -pdf_option_pdf_inclusion_errorlevel_code: print_esc("pdfoptionpdfinclusionerrorlevel"); -pdf_minor_version_code: print_esc("pdfminorversion"); -pdf_force_pagebox_code: print_esc("pdfforcepagebox"); -pdf_pagebox_code: print_esc("pdfpagebox"); -pdf_inclusion_errorlevel_code: print_esc("pdfinclusionerrorlevel"); -pdf_gamma_code: print_esc("pdfgamma"); -pdf_image_gamma_code: print_esc("pdfimagegamma"); -pdf_image_hicolor_code: print_esc("pdfimagehicolor"); -pdf_image_apply_gamma_code: print_esc("pdfimageapplygamma"); -pdf_adjust_spacing_code: print_esc("pdfadjustspacing"); -pdf_protrude_chars_code: print_esc("pdfprotrudechars"); -pdf_tracing_fonts_code: print_esc("pdftracingfonts"); -pdf_gen_tounicode_code: print_esc("pdfgentounicode"); -pdf_draftmode_code: print_esc("pdfdraftmode"); -pdf_inclusion_copy_font_code: print_esc("pdfinclusioncopyfonts"); -pdf_replace_font_code: print_esc("pdfreplacefont"); -@/@@/ -othercases begin print("[unknown integer parameter!]"); end -endcases; -end; - -@ The integer parameter names must be entered into the hash table. - -@= -primitive_tex("pretolerance",assign_int,int_base+pretolerance_code,int_base);@/ -@!@:pretolerance_}{\.{\\pretolerance} primitive@> -primitive_tex("tolerance",assign_int,int_base+tolerance_code,int_base);@/ -@!@:tolerance_}{\.{\\tolerance} primitive@> -primitive_tex("linepenalty",assign_int,int_base+line_penalty_code,int_base);@/ -@!@:line_penalty_}{\.{\\linepenalty} primitive@> -primitive_tex("hyphenpenalty",assign_int,int_base+hyphen_penalty_code,int_base);@/ -@!@:hyphen_penalty_}{\.{\\hyphenpenalty} primitive@> -primitive_tex("exhyphenpenalty",assign_int,int_base+ex_hyphen_penalty_code,int_base);@/ -@!@:ex_hyphen_penalty_}{\.{\\exhyphenpenalty} primitive@> -primitive_tex("clubpenalty",assign_int,int_base+club_penalty_code,int_base);@/ -@!@:club_penalty_}{\.{\\clubpenalty} primitive@> -primitive_tex("widowpenalty",assign_int,int_base+widow_penalty_code,int_base);@/ -@!@:widow_penalty_}{\.{\\widowpenalty} primitive@> -primitive_tex("displaywidowpenalty", assign_int,int_base+display_widow_penalty_code,int_base);@/ -@!@:display_widow_penalty_}{\.{\\displaywidowpenalty} primitive@> -primitive_tex("brokenpenalty",assign_int,int_base+broken_penalty_code,int_base);@/ -@!@:broken_penalty_}{\.{\\brokenpenalty} primitive@> -primitive_tex("binoppenalty",assign_int,int_base+bin_op_penalty_code,int_base);@/ -@!@:bin_op_penalty_}{\.{\\binoppenalty} primitive@> -primitive_tex("relpenalty",assign_int,int_base+rel_penalty_code,int_base);@/ -@!@:rel_penalty_}{\.{\\relpenalty} primitive@> -primitive_tex("predisplaypenalty",assign_int,int_base+pre_display_penalty_code,int_base);@/ -@!@:pre_display_penalty_}{\.{\\predisplaypenalty} primitive@> -primitive_tex("postdisplaypenalty",assign_int,int_base+post_display_penalty_code,int_base);@/ -@!@:post_display_penalty_}{\.{\\postdisplaypenalty} primitive@> -primitive_tex("interlinepenalty",assign_int,int_base+inter_line_penalty_code,int_base);@/ -@!@:inter_line_penalty_}{\.{\\interlinepenalty} primitive@> -primitive_tex("doublehyphendemerits", assign_int,int_base+double_hyphen_demerits_code,int_base);@/ -@!@:double_hyphen_demerits_}{\.{\\doublehyphendemerits} primitive@> -primitive_tex("finalhyphendemerits", assign_int,int_base+final_hyphen_demerits_code,int_base);@/ -@!@:final_hyphen_demerits_}{\.{\\finalhyphendemerits} primitive@> -primitive_tex("adjdemerits",assign_int,int_base+adj_demerits_code,int_base);@/ -@!@:adj_demerits_}{\.{\\adjdemerits} primitive@> -primitive_tex("mag",assign_int,int_base+mag_code,int_base);@/ -@!@:mag_}{\.{\\mag} primitive@> -primitive_tex("delimiterfactor",assign_int,int_base+delimiter_factor_code,int_base);@/ -@!@:delimiter_factor_}{\.{\\delimiterfactor} primitive@> -primitive_tex("looseness",assign_int,int_base+looseness_code,int_base);@/ -@!@:looseness_}{\.{\\looseness} primitive@> -primitive_tex("time",assign_int,int_base+time_code,int_base);@/ -@!@:time_}{\.{\\time} primitive@> -primitive_tex("day",assign_int,int_base+day_code,int_base);@/ -@!@:day_}{\.{\\day} primitive@> -primitive_tex("month",assign_int,int_base+month_code,int_base);@/ -@!@:month_}{\.{\\month} primitive@> -primitive_tex("year",assign_int,int_base+year_code,int_base);@/ -@!@:year_}{\.{\\year} primitive@> -primitive_tex("showboxbreadth",assign_int,int_base+show_box_breadth_code,int_base);@/ -@!@:show_box_breadth_}{\.{\\showboxbreadth} primitive@> -primitive_tex("showboxdepth",assign_int,int_base+show_box_depth_code,int_base);@/ -@!@:show_box_depth_}{\.{\\showboxdepth} primitive@> -primitive_tex("hbadness",assign_int,int_base+hbadness_code,int_base);@/ -@!@:hbadness_}{\.{\\hbadness} primitive@> -primitive_tex("vbadness",assign_int,int_base+vbadness_code,int_base);@/ -@!@:vbadness_}{\.{\\vbadness} primitive@> -primitive_tex("pausing",assign_int,int_base+pausing_code,int_base);@/ -@!@:pausing_}{\.{\\pausing} primitive@> -primitive_tex("tracingonline",assign_int,int_base+tracing_online_code,int_base);@/ -@!@:tracing_online_}{\.{\\tracingonline} primitive@> -primitive_tex("tracingmacros",assign_int,int_base+tracing_macros_code,int_base);@/ -@!@:tracing_macros_}{\.{\\tracingmacros} primitive@> -primitive_tex("tracingstats",assign_int,int_base+tracing_stats_code,int_base);@/ -@!@:tracing_stats_}{\.{\\tracingstats} primitive@> -primitive_tex("tracingparagraphs",assign_int,int_base+tracing_paragraphs_code,int_base);@/ -@!@:tracing_paragraphs_}{\.{\\tracingparagraphs} primitive@> -primitive_tex("tracingpages",assign_int,int_base+tracing_pages_code,int_base);@/ -@!@:tracing_pages_}{\.{\\tracingpages} primitive@> -primitive_tex("tracingoutput",assign_int,int_base+tracing_output_code,int_base);@/ -@!@:tracing_output_}{\.{\\tracingoutput} primitive@> -primitive_tex("tracinglostchars",assign_int,int_base+tracing_lost_chars_code,int_base);@/ -@!@:tracing_lost_chars_}{\.{\\tracinglostchars} primitive@> -primitive_tex("tracingcommands",assign_int,int_base+tracing_commands_code,int_base);@/ -@!@:tracing_commands_}{\.{\\tracingcommands} primitive@> -primitive_tex("tracingrestores",assign_int,int_base+tracing_restores_code,int_base);@/ -@!@:tracing_restores_}{\.{\\tracingrestores} primitive@> -primitive_tex("uchyph",assign_int,int_base+uc_hyph_code,int_base);@/ -@!@:uc_hyph_}{\.{\\uchyph} primitive@> -primitive_tex("outputpenalty",assign_int,int_base+output_penalty_code,int_base);@/ -@!@:output_penalty_}{\.{\\outputpenalty} primitive@> -primitive_tex("maxdeadcycles",assign_int,int_base+max_dead_cycles_code,int_base);@/ -@!@:max_dead_cycles_}{\.{\\maxdeadcycles} primitive@> -primitive_tex("hangafter",assign_int,int_base+hang_after_code,int_base);@/ -@!@:hang_after_}{\.{\\hangafter} primitive@> -primitive_tex("floatingpenalty",assign_int,int_base+floating_penalty_code,int_base);@/ -@!@:floating_penalty_}{\.{\\floatingpenalty} primitive@> -primitive_tex("globaldefs",assign_int,int_base+global_defs_code,int_base);@/ -@!@:global_defs_}{\.{\\globaldefs} primitive@> -primitive_tex("fam",assign_int,int_base+cur_fam_code,int_base);@/ -@!@:fam_}{\.{\\fam} primitive@> -primitive_tex("escapechar",assign_int,int_base+escape_char_code,int_base);@/ -@!@:escape_char_}{\.{\\escapechar} primitive@> -primitive_tex("defaulthyphenchar",assign_int,int_base+default_hyphen_char_code,int_base);@/ -@!@:default_hyphen_char_}{\.{\\defaulthyphenchar} primitive@> -primitive_tex("defaultskewchar",assign_int,int_base+default_skew_char_code,int_base);@/ -@!@:default_skew_char_}{\.{\\defaultskewchar} primitive@> -primitive_tex("endlinechar",assign_int,int_base+end_line_char_code,int_base);@/ -@!@:end_line_char_}{\.{\\endlinechar} primitive@> -primitive_tex("newlinechar",assign_int,int_base+new_line_char_code,int_base);@/ -@!@:new_line_char_}{\.{\\newlinechar} primitive@> -primitive_tex("language",assign_int,int_base+language_code,int_base);@/ -@!@:language_}{\.{\\language} primitive@> -primitive_tex("setlanguage",assign_int,int_base+cur_lang_code,int_base);@/ -@!@:cur_lang_}{\.{\\setlanguage} primitive@> -primitive_tex("exhyphenchar",assign_int,int_base+ex_hyphen_char_code,int_base);@/ -@!@:ex_hyphen_char_}{\.{\\exhyphenchar} primitive@> -primitive_tex("lefthyphenmin",assign_int,int_base+left_hyphen_min_code,int_base);@/ -@!@:left_hyphen_min_}{\.{\\lefthyphenmin} primitive@> -primitive_tex("righthyphenmin",assign_int,int_base+right_hyphen_min_code,int_base);@/ -@!@:right_hyphen_min_}{\.{\\righthyphenmin} primitive@> -primitive_tex("holdinginserts",assign_int,int_base+holding_inserts_code,int_base);@/ -@!@:holding_inserts_}{\.{\\holdinginserts} primitive@> -primitive_tex("errorcontextlines",assign_int,int_base+error_context_lines_code,int_base);@/ -@!@:error_context_lines_}{\.{\\errorcontextlines} primitive@> -primitive_luatex("luastartup",assign_int,int_base+luastartup_id_code,int_base);@/ -@!@:luastartup_id_}{\.{\\luastartup} primitive@> -primitive_luatex("nokerns",assign_int,int_base+disable_kern_code,int_base);@/ -@!@:disable_kern_}{\.{\\noligkerns} primitive@> -primitive_luatex("noligs",assign_int,int_base+disable_lig_code,int_base);@/ -@!@:disable_lig_}{\.{\\noligs} primitive@> -primitive_luatex("catcodetable",assign_int,int_base+cat_code_table_code,int_base);@/ -@!@:cat_code_table_}{\.{\\catcodetable} primitive@> -primitive_luatex("outputbox",assign_int,int_base+output_box_code,int_base);@/ -@!@:output_box_}{\.{\\outputbox} primitive@> -primitive_pdftex("pdfoutput",assign_int,int_base+pdf_output_code,int_base);@/ -@!@:pdf_output_}{\.{\\pdfoutput} primitive@> -primitive_pdftex("pdfcompresslevel",assign_int,int_base+pdf_compress_level_code,int_base);@/ -@!@:pdf_compress_level_}{\.{\\pdfcompresslevel} primitive@> -primitive_pdftex("pdfobjcompresslevel",assign_int,int_base+pdf_objcompresslevel_code,int_base);@/ -@!@:pdf_objcompresslevel_}{\.{\\pdfobjcompresslevel} primitive@> -primitive_pdftex("pdfdecimaldigits",assign_int,int_base+pdf_decimal_digits_code,int_base);@/ -@!@:pdf_decimal_digits_}{\.{\\pdfdecimaldigits} primitive@> -primitive_pdftex("pdfmovechars",assign_int,int_base+pdf_move_chars_code,int_base);@/ -@!@:pdf_move_chars_}{\.{\\pdfmovechars} primitive@> -primitive_pdftex("pdfimageresolution",assign_int,int_base+pdf_image_resolution_code,int_base);@/ -@!@:pdf_image_resolution_}{\.{\\pdfimageresolution} primitive@> -primitive_pdftex("pdfpkresolution",assign_int,int_base+pdf_pk_resolution_code,int_base);@/ -@!@:pdf_pk_resolution_}{\.{\\pdfpkresolution} primitive@> -primitive_pdftex("pdfuniqueresname",assign_int,int_base+pdf_unique_resname_code,int_base);@/ -@!@:pdf_unique_resname_}{\.{\\pdfuniqueresname} primitive@> -primitive_pdftex("pdfoptionpdfminorversion",assign_int,int_base+pdf_minor_version_code,int_base);@/ -@!@:pdf_minor_version_}{\.{\\pdfoptionpdfminorversion} primitive@> -primitive_pdftex("pdfoptionalwaysusepdfpagebox",assign_int,int_base+pdf_option_always_use_pdfpagebox_code,int_base);@/ -@!@:pdf_option_always_use_pdfpagebox_}{\.{\\pdfoptionalwaysusepdfpagebox} primitive@> -primitive_pdftex("pdfoptionpdfinclusionerrorlevel",assign_int,int_base+pdf_option_pdf_inclusion_errorlevel_code,int_base);@/ -@!@:pdf_option_pdf_inclusion_errorlevel_}{\.{\\pdfoptionpdfinclusionerrorlevel} primitive@> -primitive_pdftex("pdfminorversion",assign_int,int_base+pdf_minor_version_code,int_base);@/ -@!@:pdf_minor_version_}{\.{\\pdfminorversion} primitive@> -primitive_pdftex("pdfforcepagebox",assign_int,int_base+pdf_force_pagebox_code,int_base);@/ -@!@:pdf_force_pagebox_}{\.{\\pdfforcepagebox} primitive@> -primitive_pdftex("pdfpagebox",assign_int,int_base+pdf_pagebox_code,int_base);@/ -@!@:pdf_pagebox_}{\.{\\pdfpagebox} primitive@> -primitive_pdftex("pdfinclusionerrorlevel",assign_int,int_base+pdf_inclusion_errorlevel_code,int_base);@/ -@!@:pdf_inclusion_errorlevel_}{\.{\\pdfinclusionerrorlevel} primitive@> -primitive_pdftex("pdfgamma",assign_int,int_base+pdf_gamma_code,int_base);@/ -@!@:pdf_gamma_}{\.{\\pdfgamma} primitive@> -primitive_pdftex("pdfimagegamma",assign_int,int_base+pdf_image_gamma_code,int_base);@/ -@!@:pdf_image_gamma_}{\.{\\pdfimagegamma} primitive@> -primitive_pdftex("pdfimagehicolor",assign_int,int_base+pdf_image_hicolor_code,int_base);@/ -@!@:pdf_image_hicolor_}{\.{\\pdfimagehicolor} primitive@> -primitive_pdftex("pdfimageapplygamma",assign_int,int_base+pdf_image_apply_gamma_code,int_base);@/ -@!@:pdf_image_apply_gamma_}{\.{\\pdfimageapplygamma} primitive@> -primitive_pdftex("pdfadjustspacing",assign_int,int_base+pdf_adjust_spacing_code,int_base);@/ -@!@:pdf_adjust_spacing_}{\.{\\pdfadjustspacing} primitive@> -primitive_pdftex("pdfprotrudechars",assign_int,int_base+pdf_protrude_chars_code,int_base);@/ -@!@:pdf_protrude_chars_}{\.{\\pdfprotrudechars} primitive@> -primitive_pdftex("pdftracingfonts",assign_int,int_base+pdf_tracing_fonts_code,int_base);@/ -@!@:pdf_tracing_fonts_}{\.{\\pdftracingfonts} primitive@> -primitive_pdftex("pdfgentounicode",assign_int,int_base+pdf_gen_tounicode_code,int_base);@/ -@!@:pdf_gen_tounicode_}{\.{\\pdfgentounicode} primitive@> -primitive_pdftex("pdfdraftmode",assign_int,int_base+pdf_draftmode_code,int_base);@/ -@!@:pdf_draftmode_}{\.{\\pdfdraftmode} primitive@> -primitive_pdftex("pdfinclusioncopyfonts",assign_int,int_base+pdf_inclusion_copy_font_code,int_base);@/ -@!@:pdf_inclusion_copy_font_}{\.{\\pdfinclusioncopyfonts} primitive@> -primitive_pdftex("pdfreplacefont",assign_int,int_base+pdf_replace_font_code,int_base);@/ -@!@:pdf_replace_font_}{\.{\\pdfreplacefont} primitive@> - -@ The integer parameters should really be initialized by a macro package; -the following initialization does the minimum to keep \TeX\ from -complete failure. -@^null delimiter@> - -@= -for k:=int_base to attribute_base-1 do eqtb[k].int:=0; -for k:=attribute_base to del_code_base-1 do eqtb[k].int:=UNUSED_ATTRIBUTE; -mag:=1000; tolerance:=10000; hang_after:=1; max_dead_cycles:=25; -escape_char:="\"; end_line_char:=carriage_return; -eqtb[int_base+level_local_dir_code].int:=level_one; -set_del_code(".",tex_mathcode,0,0,0,0,level_one); {this null delimiter is used in error recovery} -ex_hyphen_char:="-"; -output_box:=255; - -@ The following procedure, which is called just before \TeX\ initializes its -input and output, establishes the initial values of the date and time. -@^system dependencies@> -Since standard \PASCAL\ cannot provide such information, something special -is needed. The program here simply specifies July 4, 1776, at noon; but -users probably want a better approximation to the truth. - -@p procedure fix_date_and_time; -begin time:=12*60; {minutes since midnight} -day:=4; {fourth day of the month} -month:=7; {seventh month of the year} -year:=1776; {Anno Domini} -end; - -@ @= -begin if n= -@!global_old_setting:0..max_selector; - -@ The final region of |eqtb| contains the dimension parameters defined -here, and the |number_regs| \.{\\dimen} registers. - -@d par_indent_code=0 {indentation of paragraphs} -@d math_surround_code=1 {space around math in text} -@d line_skip_limit_code=2 {threshold for |line_skip| instead of |baseline_skip|} -@d hsize_code=3 {line width in horizontal mode} -@d vsize_code=4 {page height in vertical mode} -@d max_depth_code=5 {maximum depth of boxes on main pages} -@d split_max_depth_code=6 {maximum depth of boxes on split pages} -@d box_max_depth_code=7 {maximum depth of explicit vboxes} -@d hfuzz_code=8 {tolerance for overfull hbox messages} -@d vfuzz_code=9 {tolerance for overfull vbox messages} -@d delimiter_shortfall_code=10 {maximum amount uncovered by variable delimiters} -@d null_delimiter_space_code=11 {blank space in null delimiters} -@d script_space_code=12 {extra space after subscript or superscript} -@d pre_display_size_code=13 {length of text preceding a display} -@d display_width_code=14 {length of line for displayed equation} -@d display_indent_code=15 {indentation of line for displayed equation} -@d overfull_rule_code=16 {width of rule that identifies overfull hboxes} -@d hang_indent_code=17 {amount of hanging indentation} -@d h_offset_code=18 {amount of horizontal offset when shipping pages out} -@d v_offset_code=19 {amount of vertical offset when shipping pages out} -@d emergency_stretch_code=20 {reduces badnesses on final pass of line-breaking} -@d page_left_offset_code=21 -@d page_top_offset_code=22 -@d page_right_offset_code=23 -@d page_bottom_offset_code=24 -@d pdftex_first_dimen_code = 25 {first number defined in this section} -@d pdf_h_origin_code = pdftex_first_dimen_code + 0 {horigin of the PDF output} -@d pdf_v_origin_code = pdftex_first_dimen_code + 1 {vorigin of the PDF output} -@d page_width_code = pdftex_first_dimen_code + 2 {page width of the PDF output} -@d page_height_code = pdftex_first_dimen_code + 3 {page height of the PDF output} -@d pdf_link_margin_code = pdftex_first_dimen_code + 4 {link margin in the PDF output} -@d pdf_dest_margin_code = pdftex_first_dimen_code + 5 {dest margin in the PDF output} -@d pdf_thread_margin_code = pdftex_first_dimen_code + 6 {thread margin in the PDF output} -@d pdf_first_line_height_code = pdftex_first_dimen_code + 7 -@d pdf_last_line_depth_code = pdftex_first_dimen_code + 8 -@d pdf_each_line_height_code = pdftex_first_dimen_code + 9 -@d pdf_each_line_depth_code = pdftex_first_dimen_code + 10 -@d pdf_ignored_dimen_code = pdftex_first_dimen_code + 11 -@d pdf_px_dimen_code = pdftex_first_dimen_code + 12 -@d pdftex_last_dimen_code = pdftex_first_dimen_code + 12 {last number defined in this section} -@d dimen_pars = pdftex_last_dimen_code + 1 {total number of dimension parameters} -@d scaled_base=dimen_base+dimen_pars - {table of |number_regs| user-defined \.{\\dimen} registers} -@d eqtb_size=scaled_base+biggest_reg {largest subscript of |eqtb|} -@# -@d dimen(#)==eqtb[scaled_base+#].sc -@d dimen_par(#)==eqtb[dimen_base+#].sc {a scaled quantity} -@d par_indent==dimen_par(par_indent_code) -@d math_surround==dimen_par(math_surround_code) -@d line_skip_limit==dimen_par(line_skip_limit_code) -@d hsize==dimen_par(hsize_code) -@d vsize==dimen_par(vsize_code) -@d max_depth==dimen_par(max_depth_code) -@d split_max_depth==dimen_par(split_max_depth_code) -@d box_max_depth==dimen_par(box_max_depth_code) -@d hfuzz==dimen_par(hfuzz_code) -@d vfuzz==dimen_par(vfuzz_code) -@d delimiter_shortfall==dimen_par(delimiter_shortfall_code) -@d null_delimiter_space==dimen_par(null_delimiter_space_code) -@d script_space==dimen_par(script_space_code) -@d pre_display_size==dimen_par(pre_display_size_code) -@d display_width==dimen_par(display_width_code) -@d display_indent==dimen_par(display_indent_code) -@d overfull_rule==dimen_par(overfull_rule_code) -@d hang_indent==dimen_par(hang_indent_code) -@d h_offset==dimen_par(h_offset_code) -@d v_offset==dimen_par(v_offset_code) -@d emergency_stretch==dimen_par(emergency_stretch_code) -@d page_left_offset==dimen_par(page_left_offset_code) -@d page_top_offset==dimen_par(page_top_offset_code) -@d page_right_offset==dimen_par(page_right_offset_code) -@d page_bottom_offset==dimen_par(page_bottom_offset_code) -@d pdf_h_origin == dimen_par(pdf_h_origin_code) -@d pdf_v_origin == dimen_par(pdf_v_origin_code) -@d page_width == dimen_par(page_width_code) -@d page_height == dimen_par(page_height_code) -@d pdf_link_margin == dimen_par(pdf_link_margin_code) -@d pdf_dest_margin == dimen_par(pdf_dest_margin_code) -@d pdf_thread_margin == dimen_par(pdf_thread_margin_code) -@d pdf_first_line_height == dimen_par(pdf_first_line_height_code) -@d pdf_last_line_depth == dimen_par(pdf_last_line_depth_code) -@d pdf_each_line_height == dimen_par(pdf_each_line_height_code) -@d pdf_each_line_depth == dimen_par(pdf_each_line_depth_code) -@d pdf_ignored_dimen == dimen_par(pdf_ignored_dimen_code) -@d pdf_px_dimen == dimen_par(pdf_px_dimen_code) - -@p procedure print_length_param(@!n:integer); -begin case n of -par_indent_code:print_esc("parindent"); -math_surround_code:print_esc("mathsurround"); -line_skip_limit_code:print_esc("lineskiplimit"); -hsize_code:print_esc("hsize"); -vsize_code:print_esc("vsize"); -max_depth_code:print_esc("maxdepth"); -split_max_depth_code:print_esc("splitmaxdepth"); -box_max_depth_code:print_esc("boxmaxdepth"); -hfuzz_code:print_esc("hfuzz"); -vfuzz_code:print_esc("vfuzz"); -delimiter_shortfall_code:print_esc("delimitershortfall"); -null_delimiter_space_code:print_esc("nulldelimiterspace"); -script_space_code:print_esc("scriptspace"); -pre_display_size_code:print_esc("predisplaysize"); -display_width_code:print_esc("displaywidth"); -display_indent_code:print_esc("displayindent"); -overfull_rule_code:print_esc("overfullrule"); -hang_indent_code:print_esc("hangindent"); -h_offset_code:print_esc("hoffset"); -v_offset_code:print_esc("voffset"); -emergency_stretch_code:print_esc("emergencystretch"); -page_left_offset_code: print_esc("pageleftoffset"); -page_top_offset_code: print_esc("pagetopoffset"); -page_right_offset_code: print_esc("pagerightoffset"); -page_bottom_offset_code:print_esc("pagebottomoffset"); -pdf_h_origin_code: print_esc("pdfhorigin"); -pdf_v_origin_code: print_esc("pdfvorigin"); -page_width_code: print_esc("pagewidth"); -page_height_code: print_esc("pageheight"); -pdf_link_margin_code: print_esc("pdflinkmargin"); -pdf_dest_margin_code: print_esc("pdfdestmargin"); -pdf_thread_margin_code: print_esc("pdfthreadmargin"); -pdf_first_line_height_code: print_esc("pdffirstlineheight"); -pdf_last_line_depth_code: print_esc("pdflastlinedepth"); -pdf_each_line_height_code: print_esc("pdfeachlineheight"); -pdf_each_line_depth_code: print_esc("pdfeachlinedepth"); -pdf_ignored_dimen_code: print_esc("pdfignoreddimen"); -pdf_px_dimen_code: print_esc("pdfpxdimen"); -othercases print("[unknown dimen parameter!]") -endcases; -end; - -@ @= -primitive_tex("parindent",assign_dimen,dimen_base+par_indent_code,dimen_base);@/ -@!@:par_indent_}{\.{\\parindent} primitive@> -primitive_tex("mathsurround",assign_dimen,dimen_base+math_surround_code,dimen_base);@/ -@!@:math_surround_}{\.{\\mathsurround} primitive@> -primitive_tex("lineskiplimit",assign_dimen,dimen_base+line_skip_limit_code,dimen_base);@/ -@!@:line_skip_limit_}{\.{\\lineskiplimit} primitive@> -primitive_tex("hsize",assign_dimen,dimen_base+hsize_code,dimen_base);@/ -@!@:hsize_}{\.{\\hsize} primitive@> -primitive_tex("vsize",assign_dimen,dimen_base+vsize_code,dimen_base);@/ -@!@:vsize_}{\.{\\vsize} primitive@> -primitive_tex("maxdepth",assign_dimen,dimen_base+max_depth_code,dimen_base);@/ -@!@:max_depth_}{\.{\\maxdepth} primitive@> -primitive_tex("splitmaxdepth",assign_dimen,dimen_base+split_max_depth_code,dimen_base);@/ -@!@:split_max_depth_}{\.{\\splitmaxdepth} primitive@> -primitive_tex("boxmaxdepth",assign_dimen,dimen_base+box_max_depth_code,dimen_base);@/ -@!@:box_max_depth_}{\.{\\boxmaxdepth} primitive@> -primitive_tex("hfuzz",assign_dimen,dimen_base+hfuzz_code,dimen_base);@/ -@!@:hfuzz_}{\.{\\hfuzz} primitive@> -primitive_tex("vfuzz",assign_dimen,dimen_base+vfuzz_code,dimen_base);@/ -@!@:vfuzz_}{\.{\\vfuzz} primitive@> -primitive_tex("delimitershortfall", assign_dimen,dimen_base+delimiter_shortfall_code,dimen_base);@/ -@!@:delimiter_shortfall_}{\.{\\delimitershortfall} primitive@> -primitive_tex("nulldelimiterspace", assign_dimen,dimen_base+null_delimiter_space_code,dimen_base);@/ -@!@:null_delimiter_space_}{\.{\\nulldelimiterspace} primitive@> -primitive_tex("scriptspace",assign_dimen,dimen_base+script_space_code,dimen_base);@/ -@!@:script_space_}{\.{\\scriptspace} primitive@> -primitive_tex("predisplaysize",assign_dimen,dimen_base+pre_display_size_code,dimen_base);@/ -@!@:pre_display_size_}{\.{\\predisplaysize} primitive@> -primitive_tex("displaywidth",assign_dimen,dimen_base+display_width_code,dimen_base);@/ -@!@:display_width_}{\.{\\displaywidth} primitive@> -primitive_tex("displayindent",assign_dimen,dimen_base+display_indent_code,dimen_base);@/ -@!@:display_indent_}{\.{\\displayindent} primitive@> -primitive_tex("overfullrule",assign_dimen,dimen_base+overfull_rule_code,dimen_base);@/ -@!@:overfull_rule_}{\.{\\overfullrule} primitive@> -primitive_tex("hangindent",assign_dimen,dimen_base+hang_indent_code,dimen_base);@/ -@!@:hang_indent_}{\.{\\hangindent} primitive@> -primitive_tex("hoffset",assign_dimen,dimen_base+h_offset_code,dimen_base);@/ -@!@:h_offset_}{\.{\\hoffset} primitive@> -primitive_tex("voffset",assign_dimen,dimen_base+v_offset_code,dimen_base);@/ -@!@:v_offset_}{\.{\\voffset} primitive@> -primitive_tex("emergencystretch",assign_dimen,dimen_base+emergency_stretch_code,dimen_base);@/ -@!@:emergency_stretch_}{\.{\\emergencystretch} primitive@> -primitive_pdftex("pdfhorigin",assign_dimen,dimen_base+pdf_h_origin_code,dimen_base);@/ -@!@:pdf_h_origin_}{\.{\\pdfhorigin} primitive@> -primitive_pdftex("pdfvorigin",assign_dimen,dimen_base+pdf_v_origin_code,dimen_base);@/ -@!@:pdf_v_origin_}{\.{\\pdfvorigin} primitive@> -@# -primitive_omega("pagewidth",assign_dimen,dimen_base+page_width_code,dimen_base);@/ -primitive_pdftex("pdfpagewidth",assign_dimen,dimen_base+page_width_code,dimen_base);@/ -@!@:page_width_}{\.{\\pdfpagewidth} primitive@> -primitive_omega("pageheight",assign_dimen,dimen_base+page_height_code,dimen_base);@/ -primitive_pdftex("pdfpageheight",assign_dimen,dimen_base+page_height_code,dimen_base);@/ -@!@:page_height_}{\.{\\pdfpageheight} primitive@> -@# -primitive_pdftex("pdflinkmargin",assign_dimen,dimen_base+pdf_link_margin_code,dimen_base);@/ -@!@:pdf_link_margin_}{\.{\\pdflinkmargin} primitive@> -primitive_pdftex("pdfdestmargin",assign_dimen,dimen_base+pdf_dest_margin_code,dimen_base);@/ -@!@:pdf_dest_margin_}{\.{\\pdfdestmargin} primitive@> -primitive_pdftex("pdfthreadmargin",assign_dimen,dimen_base+pdf_thread_margin_code,dimen_base);@/ -@!@:pdf_thread_margin_}{\.{\\pdfthreadmargin} primitive@> -primitive_pdftex("pdffirstlineheight",assign_dimen,dimen_base+pdf_first_line_height_code,dimen_base);@/ -@!@:pdf_first_line_height_}{\.{\\pdffirstlineheight} primitive@> -primitive_pdftex("pdflastlinedepth",assign_dimen,dimen_base+pdf_last_line_depth_code,dimen_base);@/ -@!@:pdf_last_line_depth_}{\.{\\pdflastlinedepth} primitive@> -primitive_pdftex("pdfeachlineheight",assign_dimen,dimen_base+pdf_each_line_height_code,dimen_base);@/ -@!@:pdf_each_line_height_}{\.{\\pdfeachlineheight} primitive@> -primitive_pdftex("pdfeachlinedepth",assign_dimen,dimen_base+pdf_each_line_depth_code,dimen_base);@/ -@!@:pdf_each_line_depth_}{\.{\\pdfeachlinedepth} primitive@> -primitive_pdftex("pdfignoreddimen",assign_dimen,dimen_base+pdf_ignored_dimen_code,dimen_base);@/ -@!@:pdf_ignored_dimen_}{\.{\\pdfignoreddimen} primitive@> -primitive_pdftex("pdfpxdimen",assign_dimen,dimen_base+pdf_px_dimen_code,dimen_base);@/ -@!@:pdf_px_dimen_}{\.{\\pdfpxdimen} primitive@> - -@ @= -for k:=dimen_base to eqtb_size do eqtb[k].sc:=0; -page_left_offset := one_inch; -page_top_offset := one_inch; -page_right_offset := one_inch; -page_bottom_offset := one_inch; - -@ @= -pdf_ignored_dimen := ignore_depth; -pdf_each_line_height := pdf_ignored_dimen; -pdf_each_line_depth := pdf_ignored_dimen; -pdf_first_line_height := pdf_ignored_dimen; -pdf_last_line_depth := pdf_ignored_dimen; - - -@ @= -begin if n -else if n -else if n -else if n -else if n<=eqtb_size then @ -else print_char("?"); {this can't happen either} -end; -tats - -@ The last two regions of |eqtb| have fullword values instead of the -three fields |eq_level|, |eq_type|, and |equiv|. An |eq_type| is unnecessary, -but \TeX\ needs to store the |eq_level| information in another array -called |xeq_level|. - -@= -@!eqtb:array[null_cs..eqtb_size] of memory_word; -@!xeq_level:array[null_cs..eqtb_size] of quarterword; - -@ @= -for k:=int_base to eqtb_size do xeq_level[k]:=level_one; - -@* \[18] The hash table. -Control sequences are stored and retrieved by means of a fairly standard hash -table algorithm called the method of ``coalescing lists'' (cf.\ Algorithm 6.4C -in {\sl The Art of Computer Programming\/}). Once a control sequence enters the -table, it is never removed, because there are complicated situations -involving \.{\\gdef} where the removal of a control sequence at the end of -a group would be a mistake preventable only by the introduction of a -complicated reference-count mechanism. - -The actual sequence of letters forming a control sequence identifier is -stored in the |str_pool| array together with all the other strings. An -auxiliary array |hash| consists of items with two halfword fields per -word. The first of these, called |next(p)|, points to the next identifier -belonging to the same coalesced list as the identifier corresponding to~|p|; -and the other, called |text(p)|, points to the |str_start| entry for -|p|'s identifier. If position~|p| of the hash table is empty, we have -|text(p)=0|; if position |p| is either empty or the end of a coalesced -hash list, we have |next(p)=0|. An auxiliary pointer variable called -|hash_used| is maintained in such a way that all locations |p>=hash_used| -are nonempty. The global variable |cs_count| tells how many multiletter -control sequences have been defined, if statistics are being kept. - -A global boolean variable called |no_new_control_sequence| is set to -|true| during the time that new hash table entries are forbidden. - -@d next(#) == hash[#].lh {link for coalesced lists} -@d text(#) == hash[#].rh {string number for control sequence name} -@d hash_is_full == (hash_used=hash_base) {test if all positions are occupied} -@d font_id_text(#) == text(font_id_base+#) {a frozen font identifier's name} -@d ocp_id_text(#) == text(ocp_id_base+#) {a frozen ocp identifier's name} -@d ocp_list_id_text(#) == text(ocp_list_id_base+#) - {a frozen ocp list identifier's name} - -@= -@!hash: array[hash_base..undefined_control_sequence-1] of two_halves; - {the hash table} -@!hash_used:pointer; {allocation pointer for |hash|} -@!no_new_control_sequence:boolean; {are new identifiers legal?} -@!cs_count:integer; {total number of known identifiers} - -@ The extra set of functions make sure we can query the -primitive meanings of thing s from C code - -@p -function get_eq_type(p:integer):quarterword; -begin - get_eq_type := eq_type(p); -end; -function get_eq_level(p:integer):quarterword; -begin - get_eq_level := eq_level(p); -end; -function is_undefined_cs(cs:integer):boolean; -begin - is_undefined_cs := (cs=undefined_cs); -end; -function get_equiv(p:integer):halfword; -begin - get_equiv := equiv(p); -end; -function get_cs_text(cs:integer):str_number; -begin if cs=null_cs then get_cs_text := "\csname\endcsname" - else if (text(cs)<0)or(text(cs)>=str_ptr) then get_cs_text := "" - else get_cs_text := text(cs); -end; -function get_max_command:integer; -begin - get_max_command := max_command; -end; -function get_count_base:halfword; -begin - get_count_base := count_base; -end; -function get_skip_base:halfword; -begin - get_skip_base := skip_base; -end; -function get_mu_skip_base:halfword; -begin - get_mu_skip_base := mu_skip_base; -end; -function get_attribute_base:halfword; -begin - get_attribute_base := attribute_base; -end; -function get_scaled_base:halfword; -begin - get_scaled_base := scaled_base; -end; -function get_int_base:halfword; -begin - get_int_base := int_base; -end; -function get_dimen_base:halfword; -begin - get_dimen_base := dimen_base; -end; -function get_toks_base:halfword; -begin - get_toks_base := toks_base; -end; -function get_del_code_base:halfword; -begin - get_del_code_base := del_code_base; -end; -function get_every_eof:halfword; -begin - get_every_eof := every_eof; -end; -function get_suppress_fontnotfound_error:boolean; -begin - get_suppress_fontnotfound_error := suppress_fontnotfound_error; -end; -function get_pdf_image_resolution:integer; -begin - get_pdf_image_resolution := pdf_image_resolution; -end; -function get_pdf_minor_version:integer; -begin - get_pdf_minor_version := pdf_minor_version; -end; -function get_pdf_inclusion_errorlevel:integer; -begin - get_pdf_inclusion_errorlevel := pdf_inclusion_errorlevel; -end; - -@ @= -no_new_control_sequence:=true; {new identifiers are usually forbidden} -init_primitives; -next(hash_base):=0; text(hash_base):=0; -for k:=hash_base+1 to undefined_control_sequence-1 do hash[k]:=hash[hash_base]; - -@ @= -ini_init_primitives; -hash_used:=frozen_control_sequence; {nothing is used} -cs_count:=0; -eq_type(frozen_dont_expand):=dont_expand; -text(frozen_dont_expand):="notexpanded:"; -@.notexpanded:@> - -eq_type(frozen_primitive):=ignore_spaces; -equiv(frozen_primitive):=1; -eq_level(frozen_primitive):=level_one; -text(frozen_primitive):="primitive"; - - -@ The procedure |print_cs| prints the name of a control sequence, given -a pointer to its address in |eqtb|. A space is printed after the name -unless it is a single nonletter or an active character. This procedure -might be invoked with invalid data, so it is ``extra robust.'' The -individual characters must be printed one at a time using |print|, since -they may be unprintable. - -@d single_letter(#)==(length(#)=1)or - ((length(#)=4)and(str_pool[str_start_macro(#)]>=@"F0))or - ((length(#)=3)and(str_pool[str_start_macro(#)]>=@"E0))or - ((length(#)=2)and(str_pool[str_start_macro(#)]>=@"C0)) - -@d is_active_csname(#)==((length(text(#))>3)and - (str_pool[str_start_macro(text(#))]=@"EF)and - (str_pool[str_start_macro(text(#))+1]=@"BF)and - (str_pool[str_start_macro(text(#))+2]=@"BF)) - -@d active_csname_value(#)==pool_to_unichar(str_start_macro(text(#))+3) - -@= -procedure print_cs(@!p:integer); {prints a purported control sequence} -begin if p -else if p>=undefined_control_sequence then print_esc("IMPOSSIBLE.") -else if (text(p)<0)or(text(p)>=str_ptr) then print_esc("NONEXISTENT.") -@.NONEXISTENT@> -else begin - if is_active_csname(p) then - print(active_csname_value(p)) - else begin - print_esc(text(p)); - if single_letter(text(p)) then begin - if get_cat_code(cat_code_table,pool_to_unichar(str_start_macro(text(p))))=letter then - print_char(" ") - else - do_nothing; - end - else - print_char(" "); - end - end; -end; - -@ Here is a similar procedure; it avoids the error checks, and it never -prints a space after the control sequence. - -@= -procedure sprint_cs(@!p:pointer); {prints a control sequence} -begin if p=null_cs then begin - print_esc("csname"); print_esc("endcsname"); - end -else begin - if is_active_csname(p) then - print(active_csname_value(p)) - else - print_esc(text(p)); - end; -end; - - -@ Many of \TeX's primitives need no |equiv|, since they are identifiable -by their |eq_type| alone. These primitives are loaded into the hash table -as follows: - -@= -primitive_tex(" ",ex_space,0,0);@/ -@!@:Single-character primitives /}{\quad\.{\\\ }@> -primitive_tex("/",ital_corr,0,0);@/ -@!@:Single-character primitives /}{\quad\.{\\/}@> -primitive_tex("accent",accent,0,0);@/ -@!@:accent_}{\.{\\accent} primitive@> -primitive_tex("advance",advance,0,0);@/ -@!@:advance_}{\.{\\advance} primitive@> -primitive_tex("afterassignment",after_assignment,0,0);@/ -@!@:after_assignment_}{\.{\\afterassignment} primitive@> -primitive_tex("aftergroup",after_group,0,0);@/ -@!@:after_group_}{\.{\\aftergroup} primitive@> -primitive_tex("begingroup",begin_group,0,0);@/ -@!@:begin_group_}{\.{\\begingroup} primitive@> -primitive_tex("char",char_num,0,0);@/ -@!@:char_}{\.{\\char} primitive@> -primitive_tex("csname",cs_name,0,0);@/ -@!@:cs_name_}{\.{\\csname} primitive@> -primitive_tex("delimiter",delim_num,0,0);@/ -@!@:delimiter_}{\.{\\delimiter} primitive@> -primitive_omega("odelimiter",delim_num,1,0);@/ -@!@:odelimiter_}{\.{\\odelimiter} primitive@> -primitive_luatex("Udelimiter",delim_num,2,0);@/ -@!@:odelimiter_}{\.{\\Udelimiter} primitive@> -primitive_tex("divide",divide,0,0);@/ -@!@:divide_}{\.{\\divide} primitive@> -primitive_tex("endcsname",end_cs_name,0,0);@/ -@!@:end_cs_name_}{\.{\\endcsname} primitive@> -primitive_tex("endgroup",end_group,0,0); -@!@:end_group_}{\.{\\endgroup} primitive@> -text(frozen_end_group):="endgroup"; eqtb[frozen_end_group]:=eqtb[cur_val];@/ -primitive_tex("expandafter",expand_after,0,0);@/ -@!@:expand_after_}{\.{\\expandafter} primitive@> -primitive_tex("font",def_font,0,0);@/ -@!@:font_}{\.{\\font} primitive@> -primitive_pdftex("letterspacefont",letterspace_font,0,0);@/ -@!@:letterspace_font_}{\.{\\letterspacefont} primitive@> -primitive_pdftex("pdfcopyfont",pdf_copy_font,0,0);@/ -@!@:pdf_copy_font_}{\.{\\pdfcopyfont} primitive@> -primitive_tex("fontdimen",assign_font_dimen,0,0);@/ -@!@:font_dimen_}{\.{\\fontdimen} primitive@> -primitive_tex("halign",halign,0,0);@/ -@!@:halign_}{\.{\\halign} primitive@> -primitive_tex("hrule",hrule,0,0);@/ -@!@:hrule_}{\.{\\hrule} primitive@> -primitive_tex("ignorespaces",ignore_spaces,0,0);@/ -@!@:ignore_spaces_}{\.{\\ignorespaces} primitive@> -primitive_tex("insert",insert,0,0);@/ -@!@:insert_}{\.{\\insert} primitive@> -primitive_omega("leftghost",char_ghost,0,0);@/ -@!@:leftghost_}{\.{\\leftghost} primitive@> -primitive_tex("mark",mark,0,0);@/ -@!@:mark_}{\.{\\mark} primitive@> -primitive_tex("mathaccent",math_accent,0,0);@/ -@!@:math_accent_}{\.{\\mathaccent} primitive@> -primitive_omega("omathaccent",math_accent,1,0);@/ -@!@:math_accent_}{\.{\\omathaccent} primitive@> -primitive_luatex("Umathaccent",math_accent,2,0);@/ -@!@:math_accent_}{\.{\\Umathaccent} primitive@> -primitive_luatex("Umathbotaccent",math_accent,3,0);@/ -@!@:math_accent_}{\.{\\Umathbotaccent} primitive@> -primitive_luatex("Umathaccents",math_accent,4,0);@/ -@!@:math_accent_}{\.{\\Umathaccents} primitive@> -primitive_tex("mathchar",math_char_num,0,0);@/ -@!@:math_char_}{\.{\\mathchar} primitive@> -primitive_omega("omathchar",math_char_num,1,0);@/ -@!@:math_char_}{\.{\\omathchar} primitive@> -primitive_luatex("Umathchar",math_char_num,2,0);@/ -@!@:math_char_}{\.{\\Umathchar} primitive@> -primitive_luatex("Umathcharnum",math_char_num,3,0);@/ -@!@:math_char_}{\.{\\Umathcharnum} primitive@> -primitive_tex("mathchoice",math_choice,0,0);@/ -@!@:math_choice_}{\.{\\mathchoice} primitive@> -primitive_luatex("Ustack",math_choice,1,0);@/ -@!@:math_choice_}{\.{\\Ustack} primitive@> -primitive_tex("multiply",multiply,0,0);@/ -@!@:multiply_}{\.{\\multiply} primitive@> -primitive_tex("noalign",no_align,0,0);@/ -@!@:no_align_}{\.{\\noalign} primitive@> -primitive_tex("noboundary",no_boundary,0,0);@/ -@!@:no_boundary_}{\.{\\noboundary} primitive@> -primitive_tex("noexpand",no_expand,0,0);@/ -@!@:no_expand_}{\.{\\noexpand} primitive@> -primitive_luatex("primitive",no_expand,1,0);@/ -@!@:primitive_}{\.{\\primitive} primitive@> -primitive_pdftex("pdfprimitive",no_expand,1,0);@/ -@!@:pdfprimitive_}{\.{\\pdfprimitive} primitive@> -primitive_tex("nonscript",non_script,0,0);@/ -@!@:non_script_}{\.{\\nonscript} primitive@> -primitive_tex("omit",omit,0,0);@/ -@!@:omit_}{\.{\\omit} primitive@> -primitive_tex("parshape",set_tex_shape,par_shape_loc,par_shape_loc);@/ -@!@:par_shape_}{\.{\\parshape} primitive@> -primitive_tex("penalty",break_penalty,0,0);@/ -@!@:penalty_}{\.{\\penalty} primitive@> -primitive_tex("prevgraf",set_prev_graf,0,0);@/ -@!@:prev_graf_}{\.{\\prevgraf} primitive@> -primitive_tex("radical",radical,0,0);@/ -@!@:radical_}{\.{\\radical} primitive@> -primitive_omega("oradical",radical,1,0);@/ -@!@:radical_}{\.{\\oradical} primitive@> -primitive_luatex("Uradical",radical,2,0);@/ -@!@:radical_}{\.{\\Uradical} primitive@> -primitive_luatex("Uroot",radical,3,0);@/ -@!@:radical_}{\.{\\Uroot} primitive@> -primitive_luatex("Uunderdelimiter",radical,4,0);@/ -@!@:radical_}{\.{\\Uunderdelimiter} primitive@> -primitive_luatex("Uoverdelimiter",radical,5,0);@/ -@!@:radical_}{\.{\\Uoverdelimiter} primitive@> -primitive_luatex("Udelimiterunder",radical,6,0);@/ -@!@:radical_}{\.{\\Udelimiterunder} primitive@> -primitive_luatex("Udelimiterover",radical,7,0);@/ -@!@:radical_}{\.{\\Udelimiterover} primitive@> -primitive_tex("read",read_to_cs,0,0);@/ -@!@:read_}{\.{\\read} primitive@> -primitive_tex("relax",relax,too_big_char,too_big_char); -@!@:relax_}{\.{\\relax} primitive@> -text(frozen_relax):="relax"; eqtb[frozen_relax]:=eqtb[cur_val];@/ -primitive_omega("rightghost",char_ghost,1,0);@/ -@!@:rightghost_}{\.{\\rightghost} primitive@> -primitive_tex("setbox",set_box,0,0);@/ -@!@:set_box_}{\.{\\setbox} primitive@> -primitive_tex("the",the,0,0);@/ -@!@:the_}{\.{\\the} primitive@> -primitive_tex("toks",toks_register,0,0);@/ -@!@:toks_}{\.{\\toks} primitive@> -primitive_tex("vadjust",vadjust,0,0);@/ -@!@:vadjust_}{\.{\\vadjust} primitive@> -primitive_tex("valign",valign,0,0);@/ -@!@:valign_}{\.{\\valign} primitive@> -primitive_tex("vcenter",vcenter,0,0);@/ -@!@:vcenter_}{\.{\\vcenter} primitive@> -primitive_tex("vrule",vrule,0,0);@/ -@!@:vrule_}{\.{\\vrule} primitive@> - -@ Each primitive has a corresponding inverse, so that it is possible to -display the cryptic numeric contents of |eqtb| in symbolic form. -Every call of |primitive| in this program is therefore accompanied by some -straightforward code that forms part of the |print_cmd_chr| routine -below. - -@ We will deal with the other primitives later, at some point in the program -where their |eq_type| and |equiv| values are more meaningful. For example, -the primitives for math mode will be loaded when we consider the routines -that deal with formulas. It is easy to find where each particular -primitive was treated by looking in the index at the end; for example, the -section where |"radical"| entered |eqtb| is listed under `\.{\\radical} -primitive'. (Primitives consisting of a single nonalphabetic character, -@!like `\.{\\/}', are listed under `Single-character primitives'.) -@!@^Single-character primitives@> - - -@* \[19] Saving and restoring equivalents. -The nested structure provided by `$\.{\char'173}\ldots\.{\char'175}$' groups -in \TeX\ means that |eqtb| entries valid in outer groups should be saved -and restored later if they are overridden inside the braces. When a new |eqtb| -value is being assigned, the program therefore checks to see if the previous -entry belongs to an outer level. In such a case, the old value is placed -on the |save_stack| just before the new value enters |eqtb|. At the -end of a grouping level, i.e., when the right brace is sensed, the -|save_stack| is used to restore the outer values, and the inner ones are -destroyed. - -Entries on the |save_stack| are of type |memory_word|. The top item on -this stack is |save_stack[p]|, where |p=save_ptr-1|; it contains three -fields called |save_type|, |save_level|, and |save_index|, and it is -interpreted in one of four ways: - -\yskip\hangg 1) If |save_type(p)=restore_old_value|, then -|save_index(p)| is a location in |eqtb| whose current value should -be destroyed at the end of the current group and replaced by |save_stack[p-1]|. -Furthermore if |save_index(p)>=int_base|, then |save_level(p)| -should replace the corresponding entry in |xeq_level|. - -\yskip\hangg 2) If |save_type(p)=restore_zero|, then |save_index(p)| -is a location in |eqtb| whose current value should be destroyed at the end -of the current group, when it should be -replaced by the current value of |eqtb[undefined_control_sequence]|. - -\yskip\hangg 3) If |save_type(p)=insert_token|, then |save_index(p)| -is a token that should be inserted into \TeX's input when the current -group ends. - -\yskip\hangg 4) If |save_type(p)=level_boundary|, then |save_level(p)| -is a code explaining what kind of group we were previously in, and -|save_index(p)| points to the level boundary word at the bottom of -the entries for that group. -Furthermore, in extended \eTeX\ mode, |save_stack[p-1]| contains the -source line number at which the current level of grouping was entered. - -@d save_type(#)==save_stack[#].hh.b0 {classifies a |save_stack| entry} -@d save_level(#)==save_stack[#].hh.b1 - {saved level for regions 5 and 6, or group code} -@d save_index(#)==save_stack[#].hh.rh - {|eqtb| location or token or |save_stack| location} -@d restore_old_value=0 {|save_type| when a value should be restored later} -@d restore_zero=1 {|save_type| when an undefined entry should be restored} -@d insert_token=2 {|save_type| when a token is being saved for later use} -@d level_boundary=3 {|save_type| corresponding to beginning of group} - -@p@t\4@>@ - -@ Here are the group codes that are used to discriminate between different -kinds of groups. They allow \TeX\ to decide what special actions, if any, -should be performed when a group ends. -\def\grp{\.{\char'173...\char'175}} - -Some groups are not supposed to be ended by right braces. For example, -the `\.\$' that begins a math formula causes a |math_shift_group| to -be started, and this should be terminated by a matching `\.\$'. Similarly, -a group that starts with \.{\\left} should end with \.{\\right}, and -one that starts with \.{\\begingroup} should end with \.{\\endgroup}. - -@d bottom_level=0 {group code for the outside world} -@d simple_group=1 {group code for local structure only} -@d hbox_group=2 {code for `\.{\\hbox}\grp'} -@d adjusted_hbox_group=3 {code for `\.{\\hbox}\grp' in vertical mode} -@d vbox_group=4 {code for `\.{\\vbox}\grp'} -@d vtop_group=5 {code for `\.{\\vtop}\grp'} -@d align_group=6 {code for `\.{\\halign}\grp', `\.{\\valign}\grp'} -@d no_align_group=7 {code for `\.{\\noalign}\grp'} -@d output_group=8 {code for output routine} -@d math_group=9 {code for, e.g., `\.{\char'136}\grp'} -@d disc_group=10 {code for `\.{\\discretionary}\grp\grp\grp'} -@d insert_group=11 {code for `\.{\\insert}\grp', `\.{\\vadjust}\grp'} -@d vcenter_group=12 {code for `\.{\\vcenter}\grp'} -@d math_choice_group=13 {code for `\.{\\mathchoice}\grp\grp\grp\grp'} -@d semi_simple_group=14 {code for `\.{\\begingroup...\\endgroup}'} -@d math_shift_group=15 {code for `\.{\$...\$}'} -@d math_left_group=16 {code for `\.{\\left...\\right}'} -@d local_box_group=17 {code for `\.{\\localleftbox...\\localrightbox}'} -@d max_group_code=17 -@d split_off_group=18 {box code for the top part of a \.{\\vsplit}} -@d split_keep_group=19 {box code for the bottom part of a \.{\\vsplit}} -@d preamble_group=20 {box code for the preamble processing in an alignment} -@d align_set_group=21 {box code for the final item pass in an alignment} -@d fin_row_group=22 {box code for a provisory line in an alignment} - -@= -@!group_code=0..max_group_code; {|save_level| for a level boundary} - -@ The global variable |cur_group| keeps track of what sort of group we are -currently in. Another global variable, |cur_boundary|, points to the -topmost |level_boundary| word. And |cur_level| is the current depth of -nesting. The routines are designed to preserve the condition that no entry -in the |save_stack| or in |eqtb| ever has a level greater than |cur_level|. - -@ @= -@!save_stack : array[0..save_size] of memory_word; -@!save_ptr : 0..save_size; {first unused entry on |save_stack|} -@!max_save_stack:0..save_size; {maximum usage of save stack} -@!cur_level: quarterword; {current nesting level for groups} -@!cur_group: group_code; {current group type} -@!cur_boundary: 0..save_size; {where the current level begins} - -@ At this time it might be a good idea for the reader to review the introduction -to |eqtb| that was given above just before the long lists of parameter names. -Recall that the ``outer level'' of the program is |level_one|, since -undefined control sequences are assumed to be ``defined'' at |level_zero|. - -@= -save_ptr:=0; cur_level:=level_one; cur_group:=bottom_level; cur_boundary:=0; -max_save_stack:=0; - -@ The following macro is used to test if there is room for up to eight more -entries on |save_stack|. By making a conservative test like this, we can -get by with testing for overflow in only a few places. - -@d check_full_save_stack==if save_ptr>max_save_stack then - begin max_save_stack:=save_ptr; - if max_save_stack>save_size-8 then overflow("save size",save_size); -@:TeX capacity exceeded save size}{\quad save size@> - end - -@ Procedure |new_save_level| is called when a group begins. The -argument is a group identification code like `|hbox_group|'. After -calling this routine, it is safe to put six more entries on |save_stack|. - -In some cases integer-valued items are placed onto the -|save_stack| just below a |level_boundary| word, because this is a -convenient place to keep information that is supposed to ``pop up'' just -when the group has finished. -For example, when `\.{\\hbox to 100pt}\grp' is being treated, the 100pt -dimension is stored on |save_stack| just before |new_save_level| is -called. - -We use the notation |saved(k)| to stand for an integer item that -appears in location |save_ptr+k| of the save stack. - -@d saved(#)==save_stack[save_ptr+#].int - -@p procedure new_save_level(@!c:group_code); {begin a new level of grouping} -begin check_full_save_stack; -saved(0):=line; incr(save_ptr); -save_type(save_ptr):=level_boundary; save_level(save_ptr):=cur_group; -save_index(save_ptr):=cur_boundary; -if cur_level=max_quarterword then overflow("grouping levels", -@:TeX capacity exceeded grouping levels}{\quad grouping levels@> - max_quarterword-min_quarterword); - {quit if |(cur_level+1)| is too big to be stored in |eqtb|} -cur_boundary:=save_ptr; cur_group:=c; -@!stat if tracing_groups>0 then group_trace(false);@+tats@;@/ -incr(cur_level); incr(save_ptr); -end; - -@ Just before an entry of |eqtb| is changed, the following procedure should -be called to update the other data structures properly. It is important -to keep in mind that reference counts in |mem| include references from -within |save_stack|, so these counts must be handled carefully. -@^reference counts@> - -@p procedure eq_destroy(@!w:memory_word); {gets ready to forget |w|} -var q:pointer; {|equiv| field of |w|} -begin case eq_type_field(w) of -call,long_call,outer_call,long_outer_call: delete_token_ref(equiv_field(w)); -glue_ref: delete_glue_ref(equiv_field(w)); -shape_ref: begin q:=equiv_field(w); {we need to free a \.{\\parshape} block} - if q<>null then flush_node(q); - end; {such a block is |2n+1| words long, where |n=vinfo(q)|} -box_ref: flush_node_list(equiv_field(w)); -othercases do_nothing -endcases; -end; - -@ To save a value of |eqtb[p]| that was established at level |l|, we -can use the following subroutine. - -@p procedure eq_save(@!p:pointer;@!l:quarterword); {saves |eqtb[p]|} -begin check_full_save_stack; -if l=level_zero then save_type(save_ptr):=restore_zero -else begin save_stack[save_ptr]:=eqtb[p]; incr(save_ptr); - save_type(save_ptr):=restore_old_value; - end; -save_level(save_ptr):=l; save_index(save_ptr):=p; incr(save_ptr); -end; - -@ The procedure |eq_define| defines an |eqtb| entry having specified -|eq_type| and |equiv| fields, and saves the former value if appropriate. -This procedure is used only for entries in the first four regions of |eqtb|, -i.e., only for entries that have |eq_type| and |equiv| fields. -After calling this routine, it is safe to put four more entries on -|save_stack|, provided that there was room for four more entries before -the call, since |eq_save| makes the necessary test. - -@d assign_trace(#)==@!stat if tracing_assigns>0 then restore_trace(#); - tats - -@p procedure eq_define(@!p:pointer;@!t:quarterword;@!e:halfword); - {new data for |eqtb|} -label exit; -begin if (eq_type(p)=t)and(equiv(p)=e) then - begin assign_trace(p,"reassigning")@;@/ - eq_destroy(eqtb[p]); return; - end; -assign_trace(p,"changing")@;@/ -if eq_level(p)=cur_level then eq_destroy(eqtb[p]) -else if cur_level>level_one then eq_save(p,eq_level(p)); -eq_level(p):=cur_level; eq_type(p):=t; equiv(p):=e; -assign_trace(p,"into")@;@/ -exit:end; - -@ The counterpart of |eq_define| for the remaining (fullword) positions in -|eqtb| is called |eq_word_define|. Since |xeq_level[p]>=level_one| for all -|p|, a `|restore_zero|' will never be used in this case. - -@p procedure eq_word_define(@!p:pointer;@!w:integer); -label exit; -begin if eqtb[p].int=w then - begin assign_trace(p,"reassigning")@;@/ - return; - end; -assign_trace(p,"changing")@;@/ -if xeq_level[p]<>cur_level then - begin eq_save(p,xeq_level[p]); xeq_level[p]:=cur_level; - end; -eqtb[p].int:=w; -assign_trace(p,"into")@;@/ -exit:end; - -@ The |eq_define| and |eq_word_define| routines take care of local definitions. -@^global definitions@> -Global definitions are done in almost the same way, but there is no need -to save old values, and the new value is associated with |level_one|. - -@p procedure geq_define(@!p:pointer;@!t:quarterword;@!e:halfword); - {global |eq_define|} -begin assign_trace(p,"globally changing")@;@/ -begin eq_destroy(eqtb[p]); -eq_level(p):=level_one; eq_type(p):=t; equiv(p):=e; -end; -assign_trace(p,"into")@;@/ -end; -@# -procedure geq_word_define(@!p:pointer;@!w:integer); {global |eq_word_define|} -begin assign_trace(p,"globally changing")@;@/ -begin eqtb[p].int:=w; xeq_level[p]:=level_one; -end; -assign_trace(p,"into")@;@/ -end; - -@ Subroutine |save_for_after| puts a token on the stack for save-keeping. - -@p procedure save_for_after(@!t:halfword); -begin if cur_level>level_one then - begin check_full_save_stack; - save_type(save_ptr):=insert_token; save_level(save_ptr):=level_zero; - save_index(save_ptr):=t; incr(save_ptr); - end; -end; - -@ The |unsave| routine goes the other way, taking items off of |save_stack|. -This routine takes care of restoration when a level ends; everything -belonging to the topmost group is cleared off of the save stack. - -@p -procedure@?back_input; forward; @t\2@> -procedure unsave; {pops the top level off the save stack} -label done; -var p:pointer; {position to be restored} -@!l:quarterword; {saved level, if in fullword regions of |eqtb|} -@!t:halfword; {saved value of |cur_tok|} -@!a:boolean; {have we already processed an \.{\\aftergroup} ?} -begin a:=false; l:=level_one; {just in case} -unsave_math_codes(cur_level); -unsave_cat_codes (cat_code_table,cur_level); -unsave_text_codes(cur_level); -unsave_math_data(cur_level); -if cur_level>level_one then - begin decr(cur_level); - @; - end -else confusion("curlevel"); {|unsave| is not used when |cur_group=bottom_level|} -@:this can't happen curlevel}{\quad curlevel@> -attr_list_cache:=cache_disabled; -end; - -@ @= -loop@+begin decr(save_ptr); - if save_type(save_ptr)=level_boundary then goto done; - p:=save_index(save_ptr); - if save_type(save_ptr)=insert_token then - @ - else begin if save_type(save_ptr)=restore_old_value then - begin l:=save_level(save_ptr); decr(save_ptr); - end - else save_stack[save_ptr]:=eqtb[undefined_control_sequence]; - @; - end; - end; -done: @!stat if tracing_groups>0 then group_trace(true);@+tats@;@/ -if grp_stack[in_open]=cur_boundary then group_warning; - {groups possibly not properly nested with files} -cur_group:=save_level(save_ptr); cur_boundary:=save_index(save_ptr); -decr(save_ptr) - -@ A global definition, which sets the level to |level_one|, -@^global definitions@> -will not be undone by |unsave|. If at least one global definition of -|eqtb[p]| has been carried out within the group that just ended, the -last such definition will therefore survive. - -@= -if p0 then restore_trace(p,"retaining");@+tats@;@/ - end - else begin eq_destroy(eqtb[p]); {destroy the current value} - eqtb[p]:=save_stack[save_ptr]; {restore the saved value} - @!stat if tracing_restores>0 then restore_trace(p,"restoring");@+tats@;@/ - end -else if xeq_level[p]<>level_one then - begin eqtb[p]:=save_stack[save_ptr]; xeq_level[p]:=l; - @!stat if tracing_restores>0 then restore_trace(p,"restoring");@+tats@;@/ - end -else begin - @!stat if tracing_restores>0 then restore_trace(p,"retaining");@+tats@;@/ - end - -@ @= -@!stat procedure restore_trace(@!p:pointer;@!s:str_number); - {|eqtb[p]| has just been restored or retained} -begin begin_diagnostic; print_char("{"); print(s); print_char(" "); -show_eqtb(p); print_char("}"); -end_diagnostic(false); -end; -tats - -@ Most of the parameters kept in |eqtb| can be changed freely, but there's -an exception: The magnification should not be used with two different -values during any \TeX\ job, since a single magnification is applied to an -entire run. The global variable |mag_set| is set to the current magnification -whenever it becomes necessary to ``freeze'' it at a particular value. - -@= -@!mag_set:integer; {if nonzero, this magnification should be used henceforth} - -@ @= -mag_set:=0; - -@ The |prepare_mag| subroutine is called whenever \TeX\ wants to use |mag| -for magnification. - -@p procedure prepare_mag; -begin if (mag_set>0)and(mag<>mag_set) then - begin print_err("Incompatible magnification ("); print_int(mag); -@.Incompatible magnification@> - print(");"); print_nl(" the previous value will be retained"); - help2("I can handle only one magnification ratio per job. So I've")@/ - ("reverted to the magnification you used earlier on this run.");@/ - int_error(mag_set); - geq_word_define(int_base+mag_code,mag_set); {|mag:=mag_set|} - end; -if (mag<=0)or(mag>32768) then - begin print_err("Illegal magnification has been changed to 1000");@/ -@.Illegal magnification...@> - help1("The magnification ratio must be between 1 and 32768."); - int_error(mag); geq_word_define(int_base+mag_code,1000); - end; -if (mag_set=0) and (mag<>mag_set) then begin - if mag<>1000 then - one_true_inch:=xn_over_d(one_hundred_inch,10,mag) - else - one_true_inch:=one_inch; -end; -mag_set:=mag; -end; - -@* \[20] Token lists. -A \TeX\ token is either a character or a control sequence, and it is -@^token@> -represented internally in one of two ways: (1)~A character whose ASCII -code number is |c| and whose command code is |m| is represented as the -number $2^{21}m+c$; the command code is in the range |1<=m<=14|. (2)~A control -sequence whose |eqtb| address is |p| is represented as the number -|cs_token_flag+p|. Here |cs_token_flag=@t$2^{25}-1$@>| is larger than -$2^{21}m+c$, yet it is small enough that |cs_token_flag+p< max_halfword|; -thus, a token fits comfortably in a halfword. - -A token |t| represents a |left_brace| command if and only if -|t= -if cs_token_flag+undefined_control_sequence>max_halfword then bad:=21; - -@ A token list is a singly linked list of one-word nodes in |mem|, where -each word contains a token and a link. Macro definitions, output-routine -definitions, marks, \.{\\write} texts, and a few other things -are remembered by \TeX\ in the form -of token lists, usually preceded by a node with a reference count in its -|token_ref_count| field. The token stored in location |p| is called -|info(p)|. - -Three special commands appear in the token lists of macro definitions. -When |m=match|, it means that \TeX\ should scan a parameter -for the current macro; when |m=end_match|, it means that parameter -matching should end and \TeX\ should start reading the macro text; and -when |m=out_param|, it means that \TeX\ should insert parameter -number |c| into the text at this point. - -The enclosing \.{\char'173} and \.{\char'175} characters of a macro -definition are omitted, but the final right brace of an output routine -is included at the end of its token list. - -Here is an example macro definition that illustrates these conventions. -After \TeX\ processes the text -$$\.{\\def\\mac a\#1\#2 \\b \{\#1\\-a \#\#1\#2 \#2\}}$$ -the definition of \.{\\mac} is represented as a token list containing -$$\def\,{\hskip2pt} -\vbox{\halign{\hfil#\hfil\cr -(reference count), |letter|\,\.a, |match|\,\#, |match|\,\#, |spacer|\,\.\ , -\.{\\b}, |end_match|,\cr -|out_param|\,1, \.{\\-}, |letter|\,\.a, |spacer|\,\.\ , |mac_param|\,\#, -|other_char|\,\.1,\cr -|out_param|\,2, |spacer|\,\.\ , |out_param|\,2.\cr}}$$ -The procedure |scan_toks| builds such token lists, and |macro_call| -does the parameter matching. -@^reference counts@> - -Examples such as -$$\.{\\def\\m\{\\def\\m\{a\}\ b\}}$$ -explain why reference counts would be needed even if \TeX\ had no \.{\\let} -operation: When the token list for \.{\\m} is being read, the redefinition of -\.{\\m} changes the |eqtb| entry before the token list has been fully -consumed, so we dare not simply destroy a token list when its -control sequence is being redefined. - -If the parameter-matching part of a definition ends with `\.{\#\{}', -the corresponding token list will have `\.\{' just before the `|end_match|' -and also at the very end. The first `\.\{' is used to delimit the parameter; the -second one keeps the first from disappearing. - -@ The procedure |show_token_list|, which prints a symbolic form of -the token list that starts at a given node |p|, illustrates these -conventions. The token list being displayed should not begin with a reference -count. However, the procedure is intended to be robust, so that if the -memory links are awry or if |p| is not really a pointer to a token list, -nothing catastrophic will happen. - -An additional parameter |q| is also given; this parameter is either null -or it points to a node in the token list where a certain magic computation -takes place that will be explained later. (Basically, |q| is non-null when -we are printing the two-line context information at the time of an error -message; |q| marks the place corresponding to where the second line -should begin.) - -For example, if |p| points to the node containing the first \.a in the -token list above, then |show_token_list| will print the string -$$\hbox{`\.{a\#1\#2\ \\b\ ->\#1\\-a\ \#\#1\#2\ \#2}';}$$ -and if |q| points to the node containing the second \.a, -the magic computation will be performed just before the second \.a is printed. - -The generation will stop, and `\.{\\ETC.}' will be printed, if the length -of printing exceeds a given limit~|l|. Anomalous entries are printed in the -form of control sequences that are not followed by a blank space, e.g., -`\.{\\BAD.}'; this cannot be confused with actual control sequences because -a real control sequence named \.{BAD} would come out `\.{\\BAD\ }'. - -@= -procedure show_token_list(@!p,@!q:integer;@!l:integer); -label exit; -var m,@!c:integer; {pieces of a token} -@!match_chr:ASCII_code; {character used in a `|match|'} -@!n:ASCII_code; {the highest parameter number, as an ASCII digit} -begin match_chr:="#"; n:="0"; tally:=0; -while (p<>null) and (tally; - @; - p:=link(p); - end; -if p<>null then print_esc("ETC."); -@.ETC@> -exit: -end; - -@ @= -if (pfix_mem_end) then - begin print_esc("CLOBBERED."); return; -@.CLOBBERED@> - end; -if info(p)>=cs_token_flag then begin - if not ((inhibit_par_tokens) and (info(p)=par_token)) then - print_cs(info(p)-cs_token_flag); - end -else begin m:=info(p) div string_offset; c:=info(p) mod string_offset; - if info(p)<0 then print_esc("BAD.") -@.BAD@> - else @; - end - -@ The procedure usually ``learns'' the character code used for macro -parameters by seeing one in a |match| command before it runs into any -|out_param| commands. - -@= -case m of -left_brace,right_brace,math_shift,tab_mark,sup_mark,sub_mark,spacer, - letter,other_char: print(c); -mac_param: begin if not in_lua_escape then print(c); print(c); - end; -out_param: begin print(match_chr); - if c<=9 then print_char(c+"0") - else begin print_char("!"); return; - end; - end; -match: begin match_chr:=c; print(c); incr(n); print_char(n); - if n>"9" then return; - end; -end_match: if c=0 then print("->"); -@.->@> -othercases print_esc("BAD.") -@.BAD@> -endcases - -@ Here's the way we sometimes want to display a token list, given a pointer -to its reference count; the pointer may be null. - -@p procedure token_show(@!p:pointer); -begin if p<>null then show_token_list(link(p),null,10000000); -end; - -@ The |print_meaning| subroutine displays |cur_cmd| and |cur_chr| in -symbolic form, including the expansion of a macro or mark. - -@p procedure print_meaning; -begin print_cmd_chr(cur_cmd,cur_chr); -if cur_cmd>=call then - begin print_char(":"); print_ln; token_show(cur_chr); - end -else @; -end; - -@* \[21] Introduction to the syntactic routines. -Let's pause a moment now and try to look at the Big Picture. -The \TeX\ program consists of three main parts: syntactic routines, -semantic routines, and output routines. The chief purpose of the -syntactic routines is to deliver the user's input to the semantic routines, -one token at a time. The semantic routines act as an interpreter -responding to these tokens, which may be regarded as commands. And the -output routines are periodically called on to convert box-and-glue -lists into a compact set of instructions that will be sent -to a typesetter. We have discussed the basic data structures and utility -routines of \TeX, so we are good and ready to plunge into the real activity by -considering the syntactic routines. - -Our current goal is to come to grips with the |get_next| procedure, -which is the keystone of \TeX's input mechanism. Each call of |get_next| -sets the value of three variables |cur_cmd|, |cur_chr|, and |cur_cs|, -representing the next input token. -$$\vbox{\halign{#\hfil\cr - \hbox{|cur_cmd| denotes a command code from the long list of codes - given above;}\cr - \hbox{|cur_chr| denotes a character code or other modifier of the command - code;}\cr - \hbox{|cur_cs| is the |eqtb| location of the current control sequence,}\cr - \hbox{\qquad if the current token was a control sequence, - otherwise it's zero.}\cr}}$$ -Underlying this external behavior of |get_next| is all the machinery -necessary to convert from character files to tokens. At a given time we -may be only partially finished with the reading of several files (for -which \.{\\input} was specified), and partially finished with the expansion -of some user-defined macros and/or some macro parameters, and partially -finished with the generation of some text in a template for \.{\\halign}, -and so on. When reading a character file, special characters must be -classified as math delimiters, etc.; comments and extra blank spaces must -be removed, paragraphs must be recognized, and control sequences must be -found in the hash table. Furthermore there are occasions in which the -scanning routines have looked ahead for a word like `\.{plus}' but only -part of that word was found, hence a few characters must be put back -into the input and scanned again. - -To handle these situations, which might all be present simultaneously, -\TeX\ uses various stacks that hold information about the incomplete -activities, and there is a finite state control for each level of the -input mechanism. These stacks record the current state of an implicitly -recursive process, but the |get_next| procedure is not recursive. -Therefore it will not be difficult to translate these algorithms into -low-level languages that do not support recursion. - -@= -@!cur_cmd: eight_bits; {current command set by |get_next|} -@!cur_chr: halfword; {operand of current command} -@!cur_cs: pointer; {control sequence found here, zero if none found} -@!cur_tok: halfword; {packed representative of |cur_cmd| and |cur_chr|} - -@ Here is a procedure that displays the current command. - -@p procedure show_cur_cmd_chr; -var n:integer; {level of \.{\\if...\\fi} nesting} -@!l:integer; {line where \.{\\if} started} -@!p:pointer; -begin begin_diagnostic; print_nl("{"); -if mode<>shown_mode then - begin print_mode(mode); print(": "); shown_mode:=mode; - end; -print_cmd_chr(cur_cmd,cur_chr); -if tracing_ifs>0 then - if cur_cmd>=if_test then if cur_cmd<=fi_or_else then - begin print(": "); - if cur_cmd=fi_or_else then - begin print_cmd_chr(if_test,cur_if); print_char(" "); - n:=0; l:=if_line; - end - else begin n:=1; l:=line; - end; - p:=cond_ptr; - while p<>null do - begin incr(n); p:=vlink(p); - end; - print("(level "); print_int(n); print_char(")"); print_if_line(l); - end; -print_char("}"); -end_diagnostic(false); -end; - -@* \[22] Input stacks and states. -This implementation of -\TeX\ uses two different conventions for representing sequential stacks. -@^stack conventions@>@^conventions for representing stacks@> - -\yskip\hangg 1) If there is frequent access to the top entry, and if the -stack is essentially never empty, then the top entry is kept in a global -variable (even better would be a machine register), and the other entries -appear in the array $\\{stack}[0\to(\\{ptr}-1)]$. For example, the -semantic stack described above is handled this way, and so is the input -stack that we are about to study. - -\yskip\hangg 2) If there is infrequent top access, the entire stack contents -are in the array $\\{stack}[0\to(\\{ptr}-1)]$. For example, the |save_stack| -is treated this way, as we have seen. - -\yskip\noindent -The state of \TeX's input mechanism appears in the input stack, whose -entries are records with six fields, called |state|, |index|, |start|, |loc|, -|limit|, and |name|. This stack is maintained with -convention~(1), so it is declared in the following way: - -@= -@!in_state_record = record - @!state_field, @!index_field: quarterword; - @!start_field,@!loc_field, @!limit_field, @!name_field, - @!ocp_lstack_field: halfword; {used for omega translation processes} - @!ocp_no_field: halfword; {used for omega translation processes} - @!synctex_tag_field: integer; {stack the tag of the current file} - @!cattable_field: integer; {category table used by the current line (see textoken.c)} - @!partial_field: boolean; {is the current line partial? (see textoken.c)} - @!nofilter_field: boolean; {used by token filtering} - end; - -@ @= -@!input_stack : array[0..stack_size] of in_state_record; -@!input_ptr : 0..stack_size; {first unused location of |input_stack|} -@!max_in_stack: 0..stack_size; {largest value of |input_ptr| when pushing} -@!cur_input : in_state_record; - {the ``top'' input state, according to convention (1)} - -@ We've already defined the special variable |loc==cur_input.loc_field| -in our discussion of basic input-output routines. The other components of -|cur_input| are defined in the same way: - -@d state==cur_input.state_field {current scanner state} -@d index==cur_input.index_field {reference for buffer information} -@d start==cur_input.start_field {starting position in |buffer|} -@d limit==cur_input.limit_field {end of current line in |buffer|} -@d nofilter==cur_input.nofilter_field {is token filtering explicitly disallowed?} -@d name==cur_input.name_field {name of the current file} -@d synctex_tag==cur_input.synctex_tag_field {{\sl Sync\TeX} tag of the current file} -@d current_ocp_lstack==cur_input.ocp_lstack_field {name of the current ocp} -@d current_ocp_no==cur_input.ocp_no_field {name of the current ocp} -@d line_catcode_table==cur_input.cattable_field -@d line_partial==cur_input.partial_field - -@ Let's look more closely now at the control variables -(|state|,~|index|,~|start|,~|loc|,~|limit|,~|name|), -assuming that \TeX\ is reading a line of characters that have been input -from some file or from the user's terminal. There is an array called -|buffer| that acts as a stack of all lines of characters that are -currently being read from files, including all lines on subsidiary -levels of the input stack that are not yet completed. \TeX\ will return to -the other lines when it is finished with the present input file. - -(Incidentally, on a machine with byte-oriented addressing, it might be -appropriate to combine |buffer| with the |str_pool| array, -letting the buffer entries grow downward from the top of the string pool -and checking that these two tables don't bump into each other.) - -The line we are currently working on begins in position |start| of the -buffer; the next character we are about to read is |buffer[loc]|; and -|limit| is the location of the last character present. If |loc>limit|, -the line has been completely read. Usually |buffer[limit]| is the -|end_line_char|, denoting the end of a line, but this is not -true if the current line is an insertion that was entered on the user's -terminal in response to an error message. - -The |name| variable is a string number that designates the name of -the current file, if we are reading a text file. It is zero if we -are reading from the terminal; it is |n+1| if we are reading from -input stream |n|, where |0<=n<=16|. (Input stream 16 stands for -an invalid stream number; in such cases the input is actually from -the terminal, under control of the procedure |read_toks|.) -Finally |18<=name<=20| indicates that we are reading a pseudo file -created by the \.{\\scantokens} or \.{\\scantextokens} command. - -The |state| variable has one of three values, when we are scanning such -files: -$$\baselineskip 15pt\vbox{\halign{#\hfil\cr -1) |state=mid_line| is the normal state.\cr -2) |state=skip_blanks| is like |mid_line|, but blanks are ignored.\cr -3) |state=new_line| is the state at the beginning of a line.\cr}}$$ -These state values are assigned numeric codes so that if we add the state -code to the next character's command code, we get distinct values. For -example, `|mid_line+spacer|' stands for the case that a blank -space character occurs in the middle of a line when it is not being -ignored; after this case is processed, the next value of |state| will -be |skip_blanks|. - -@d mid_line=1 {|state| code when scanning a line of characters} -@d skip_blanks=2+max_char_code {|state| code when ignoring blanks} -@d new_line=3+max_char_code+max_char_code {|state| code at start of line} - -@ Additional information about the current line is available via the -|index| variable, which counts how many lines of characters are present -in the buffer below the current level. We have |index=0| when reading -from the terminal and prompting the user for each line; then if the user types, -e.g., `\.{\\input paper}', we will have |index=1| while reading -the file \.{paper.tex}. However, it does not follow that |index| is the -same as the input stack pointer, since many of the levels on the input -stack may come from token lists. For example, the instruction `\.{\\input -paper}' might occur in a token list. - -The global variable |in_open| is equal to the |index| -value of the highest non-token-list level. Thus, the number of partially read -lines in the buffer is |in_open+1|, and we have |in_open=index| -when we are not reading a token list. - -If we are not currently reading from the terminal, or from an input -stream, we are reading from the file variable |input_file[index]|. We use -the notation |terminal_input| as a convenient abbreviation for |name=0|, -and |cur_file| as an abbreviation for |input_file[index]|. - -The global variable |line| contains the line number in the topmost -open file, for use in error messages. If we are not reading from -the terminal, |line_stack[index]| holds the line number for the -enclosing level, so that |line| can be restored when the current -file has been read. Line numbers should never be negative, since the -negative of the current line number is used to identify the user's output -routine in the |mode_line| field of the semantic nest entries. - -If more information about the input state is needed, it can be -included in small arrays like those shown here. For example, -the current page or segment number in the input file might be -put into a variable |@!page|, maintained for enclosing levels in -`\ignorespaces|@!page_stack:array[1..max_in_open] of integer|\unskip' -by analogy with |line_stack|. -@^system dependencies@> - -@d terminal_input==(name=0) {are we reading from the terminal?} -@d cur_file==input_file[index] {the current |alpha_file| variable} - -@= -@!in_open : 0..max_in_open; {the number of lines in the buffer, less one} -@!open_parens : 0..max_in_open; {the number of open text files} -@!input_file : array[1..max_in_open] of alpha_file; -@!line : integer; {current line number in the current source file} -@!line_stack : array[1..max_in_open] of integer; - -@ Users of \TeX\ sometimes forget to balance left and right braces properly, -and one of the ways \TeX\ tries to spot such errors is by considering an -input file as broken into subfiles by control sequences that -are declared to be \.{\\outer}. - -A variable called |scanner_status| tells \TeX\ whether or not to complain -when a subfile ends. This variable has six possible values: - -\yskip\hang|normal|, means that a subfile can safely end here without incident. - -\yskip\hang|skipping|, means that a subfile can safely end here, but not a file, -because we're reading past some conditional text that was not selected. - -\yskip\hang|defining|, means that a subfile shouldn't end now because a -macro is being defined. - -\yskip\hang|matching|, means that a subfile shouldn't end now because a -macro is being used and we are searching for the end of its arguments. - -\yskip\hang|aligning|, means that a subfile shouldn't end now because we are -not finished with the preamble of an \.{\\halign} or \.{\\valign}. - -\yskip\hang|absorbing|, means that a subfile shouldn't end now because we are -reading a balanced token list for \.{\\message}, \.{\\write}, etc. - -\yskip\noindent -If the |scanner_status| is not |normal|, the variable |warning_index| points -to the |eqtb| location for the relevant control sequence name to print -in an error message. - -@d skipping=1 {|scanner_status| when passing conditional text} -@d defining=2 {|scanner_status| when reading a macro definition} -@d matching=3 {|scanner_status| when reading macro arguments} -@d aligning=4 {|scanner_status| when reading an alignment preamble} -@d absorbing=5 {|scanner_status| when reading a balanced text} - -@= -@!scanner_status : normal..absorbing; {can a subfile end now?} -@!warning_index : pointer; {identifier relevant to non-|normal| scanner status} -@!def_ref : pointer; {reference count of token list being defined} - -@ Here is a procedure that uses |scanner_status| to print a warning message -when a subfile has ended, and at certain other crucial times: - -@= -procedure runaway; -var p:pointer; {head of runaway list} -begin p:=null; - if scanner_status>skipping then - begin print_nl("Runaway "); -@.Runaway...@> - case scanner_status of - defining: begin print("definition"); p:=def_ref; - end; - matching: begin print("argument"); p:=temp_token_head; - end; - aligning: begin print("preamble"); p:=hold_token_head; - end; - absorbing: begin print("text"); p:=def_ref; - end; - end; {there are no other cases} - print_char("?");print_ln; show_token_list(link(p),null,error_line-10); - end; -end; - -@ However, all this discussion about input state really applies only to the -case that we are inputting from a file. There is another important case, -namely when we are currently getting input from a token list. In this case -|state=token_list|, and the conventions about the other state variables -are different: - -\yskip\hang|loc| is a pointer to the current node in the token list, i.e., -the node that will be read next. If |loc=null|, the token list has been -fully read. - -\yskip\hang|start| points to the first node of the token list; this node -may or may not contain a reference count, depending on the type of token -list involved. - -\yskip\hang|token_type|, which takes the place of |index| in the -discussion above, is a code number that explains what kind of token list -is being scanned. - -\yskip\hang|name| points to the |eqtb| address of the control sequence -being expanded, if the current token list is a macro. - -\yskip\hang|param_start|, which takes the place of |limit|, tells where -the parameters of the current macro begin in the |param_stack|, if the -current token list is a macro. - -\yskip\noindent The |token_type| can take several values, depending on -where the current token list came from: - -\yskip\hang|parameter|, if a parameter is being scanned; - -\hang|u_template|, if the \ part of an alignment -template is being scanned; - -\hang|v_template|, if the \ part of an alignment -template is being scanned; - -\hang|backed_up|, if the token list being scanned has been inserted as -`to be read again'. - -\hang|inserted|, if the token list being scanned has been inserted as -the text expansion of a \.{\\count} or similar variable; - -\hang|macro|, if a user-defined control sequence is being scanned; - -\hang|output_text|, if an \.{\\output} routine is being scanned; - -\hang|every_par_text|, if the text of \.{\\everypar} is being scanned; - -\hang|every_math_text|, if the text of \.{\\everymath} is being scanned; - -\hang|every_display_text|, if the text of \.{\\everydisplay} is being scanned; - -\hang|every_hbox_text|, if the text of \.{\\everyhbox} is being scanned; - -\hang|every_vbox_text|, if the text of \.{\\everyvbox} is being scanned; - -\hang|every_job_text|, if the text of \.{\\everyjob} is being scanned; - -\hang|every_cr_text|, if the text of \.{\\everycr} is being scanned; - -\hang|mark_text|, if the text of a \.{\\mark} is being scanned; - -\hang|write_text|, if the text of a \.{\\write} is being scanned. - -\yskip\noindent -The codes for |output_text|, |every_par_text|, etc., are equal to a constant -plus the corresponding codes for token list parameters |output_routine_loc|, -|every_par_loc|, etc. The token list begins with a reference count if and -only if |token_type>=macro|. -@^reference counts@> - -Since \eTeX's additional token list parameters precede |toks_base|, the -corresponding token types must precede |write_text|. - -@d token_list=0 {|state| code when scanning a token list} -@d token_type==index {type of current token list} -@d param_start==limit {base of macro parameters in |param_stack|} -@d parameter=0 {|token_type| code for parameter} -@d u_template=1 {|token_type| code for \ template} -@d v_template=2 {|token_type| code for \ template} -@d backed_up=3 {|token_type| code for text to be reread} -@d inserted=4 {|token_type| code for inserted texts} -@d macro=5 {|token_type| code for defined control sequences} -@d output_text=6 {|token_type| code for output routines} -@d every_par_text=7 {|token_type| code for \.{\\everypar}} -@d every_math_text=8 {|token_type| code for \.{\\everymath}} -@d every_display_text=9 {|token_type| code for \.{\\everydisplay}} -@d every_hbox_text=10 {|token_type| code for \.{\\everyhbox}} -@d every_vbox_text=11 {|token_type| code for \.{\\everyvbox}} -@d every_job_text=12 {|token_type| code for \.{\\everyjob}} -@d every_cr_text=13 {|token_type| code for \.{\\everycr}} -@d mark_text=14 {|token_type| code for \.{\\topmark}, etc.} -@# -@d eTeX_text_offset=output_routine_loc-output_text -@d every_eof_text=every_eof_loc-eTeX_text_offset - {|token_type| code for \.{\\everyeof}} -@# -@d write_text=etex_toks-eTeX_text_offset {|token_type| code for \.{\\write}} - -@ The |param_stack| is an auxiliary array used to hold pointers to the token -lists for parameters at the current level and subsidiary levels of input. -This stack is maintained with convention (2), and it grows at a different -rate from the others. - -@= -@!param_stack:array [0..param_size] of pointer; - {token list pointers for parameters} -@!param_ptr:0..param_size; {first unused entry in |param_stack|} -@!max_param_stack:integer; - {largest value of |param_ptr|, will be |<=param_size+9|} - -@ The input routines must also interact with the processing of -\.{\\halign} and \.{\\valign}, since the appearance of tab marks and -\.{\\cr} in certain places is supposed to trigger the beginning of special -\ template text in the scanner. This magic is accomplished by an -|align_state| variable that is increased by~1 when a `\.{\char'173}' is -scanned and decreased by~1 when a `\.{\char'175}' is scanned. The |align_state| -is nonzero during the \ template, after which it is set to zero; the -\ template begins when a tab mark or \.{\\cr} occurs at a time that -|align_state=0|. - -@= -@!align_state:integer; {group level with respect to current alignment} - -@ Thus, the ``current input state'' can be very complicated indeed; there -can be many levels and each level can arise in a variety of ways. The -|show_context| procedure, which is used by \TeX's error-reporting routine to -print out the current input state on all levels down to the most recent -line of characters from an input file, illustrates most of these conventions. -The global variable |base_ptr| contains the lowest level that was -displayed by this procedure. - -@= -@!base_ptr:0..stack_size; {shallowest level shown by |show_context|} - -@ The status at each level is indicated by printing two lines, where the first -line indicates what was read so far and the second line shows what remains -to be read. The context is cropped, if necessary, so that the first line -contains at most |half_error_line| characters, and the second contains -at most |error_line|. Non-current input levels whose |token_type| is -`|backed_up|' are shown only if they have not been fully read. - -@p procedure show_context; {prints where the scanner is} -label done; -var old_setting:0..max_selector; {saved |selector| setting} -@!nn:integer; {number of contexts shown so far, less one} -@!bottom_line:boolean; {have we reached the final context to be shown?} -@@/ -begin base_ptr:=input_ptr; input_stack[base_ptr]:=cur_input; - {store current state} -nn:=-1; bottom_line:=false; -loop@+begin cur_input:=input_stack[base_ptr]; {enter into the context} - if (state<>token_list) then - if (name>21) or (base_ptr=0) then bottom_line:=true; - if (base_ptr=input_ptr)or bottom_line or(nn - else if nn=error_context_lines then - begin print_nl("..."); incr(nn); {omitted if |error_context_lines<0|} - end; - if bottom_line then goto done; - decr(base_ptr); - end; -done: cur_input:=input_stack[input_ptr]; {restore original state} -end; - -@ @= -begin if (base_ptr=input_ptr) or (state<>token_list) or - (token_type<>backed_up) or (loc<>null) then - {we omit backed-up token lists that have already been read} - begin tally:=0; {get ready to count characters} - old_setting:=selector; - if current_ocp_lstack>0 then - begin print_nl("OCP stack "); print_scaled(current_ocp_lstack); - print(" entry "); print_int(current_ocp_no); print(":"); - @; - end - else if state<>token_list then - begin @; - @; - end - else begin @; - @; - end; - selector:=old_setting; {stop pseudoprinting} - @; - incr(nn); - end; -end - -@ This routine should be changed, if necessary, to give the best possible -indication of where the current line resides in the input file. -For example, on some systems it is best to print both a page and line number. -@^system dependencies@> - -@= -if name<=17 then - if terminal_input then - if base_ptr=0 then print_nl("<*>") else print_nl(" ") - else begin print_nl(" - print_char(">"); - end -else if index<>in_open then {input from a pseudo file} - begin print_nl("l."); print_int(line_stack[index+1]); - end -else begin print_nl("l."); print_int(line); - end; -print_char(" ") - -@ @= -case token_type of -parameter: print_nl(" "); -u_template,v_template: print_nl("