From 58b7dfe85b124eaccc2d2f1018d9e4bc881acbbd Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 5 Dec 2019 19:41:53 +0100 Subject: 2019-12-05 18:54:00 --- doc/context/documents/general/manuals/evenmore.pdf | Bin 0 -> 222820 bytes doc/context/documents/general/qrcs/setup-cs.pdf | Bin 888111 -> 888089 bytes doc/context/documents/general/qrcs/setup-de.pdf | Bin 889597 -> 889424 bytes doc/context/documents/general/qrcs/setup-en.pdf | Bin 894230 -> 893995 bytes doc/context/documents/general/qrcs/setup-fr.pdf | Bin 886059 -> 885882 bytes doc/context/documents/general/qrcs/setup-it.pdf | Bin 891796 -> 891894 bytes .../documents/general/qrcs/setup-mapping-cs.pdf | Bin 383544 -> 383649 bytes .../documents/general/qrcs/setup-mapping-de.pdf | Bin 383899 -> 383776 bytes .../documents/general/qrcs/setup-mapping-en.pdf | Bin 380640 -> 380305 bytes .../documents/general/qrcs/setup-mapping-fr.pdf | Bin 384021 -> 383852 bytes .../documents/general/qrcs/setup-mapping-it.pdf | Bin 383363 -> 383523 bytes .../documents/general/qrcs/setup-mapping-nl.pdf | Bin 382101 -> 381891 bytes .../documents/general/qrcs/setup-mapping-ro.pdf | Bin 620204 -> 620337 bytes doc/context/documents/general/qrcs/setup-nl.pdf | Bin 881326 -> 881163 bytes doc/context/documents/general/qrcs/setup-ro.pdf | Bin 886170 -> 886075 bytes doc/context/scripts/mkiv/mtx-fonts.html | 81 ------- doc/context/scripts/mkiv/mtx-fonts.man | 69 ------ doc/context/scripts/mkiv/mtx-fonts.xml | 65 ------ doc/context/scripts/mkiv/mtx-unzip.html | 3 +- doc/context/scripts/mkiv/mtx-unzip.man | 5 +- doc/context/scripts/mkiv/mtx-unzip.xml | 3 +- .../general/manuals/evenmore/evenmore-contents.tex | 11 + .../manuals/evenmore/evenmore-expansion.tex | 148 +++++++++++++ .../manuals/evenmore/evenmore-introduction.tex | 38 ++++ .../manuals/evenmore/evenmore-normalization.tex | 239 +++++++++++++++++++++ .../general/manuals/evenmore/evenmore-style.tex | 67 ++++++ .../manuals/evenmore/evenmore-titlepage.tex | 45 ++++ .../sources/general/manuals/evenmore/evenmore.tex | 37 ++++ .../manuals/luametatex/luametatex-introduction.tex | 12 +- .../general/manuals/luametatex/luametatex.tex | 2 +- .../manuals/luatex/luatex-modifications.tex | 5 +- scripts/context/lua/mtx-unzip.lua | 132 ++++++------ scripts/context/lua/mtxrun.lua | 158 +++++--------- scripts/context/stubs/mswin/mtxrun.lua | 158 +++++--------- scripts/context/stubs/unix/mtxrun | 158 +++++--------- scripts/context/stubs/win64/mtxrun.lua | 158 +++++--------- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkii/mult-pe.mkii | 3 + tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/context.mkxl | 2 +- tex/context/base/mkiv/font-ctx.lua | 8 +- tex/context/base/mkiv/font-imp-properties.lua | 1 - tex/context/base/mkiv/font-ini.lua | 4 + tex/context/base/mkiv/hand-ini.mkiv | 2 +- tex/context/base/mkiv/hand-ini.mkxl | 2 +- tex/context/base/mkiv/l-gzip.lua | 191 ++++++++++------ tex/context/base/mkiv/lpdf-img.lua | 4 +- tex/context/base/mkiv/lpdf-lmt.lua | 2 +- tex/context/base/mkiv/math-act.lua | 7 +- tex/context/base/mkiv/math-noa.lua | 17 +- tex/context/base/mkiv/math-tag.lua | 2 +- tex/context/base/mkiv/mlib-svg.lua | 6 +- tex/context/base/mkiv/node-aux.lua | 234 +++++++++++++++++++- tex/context/base/mkiv/node-cmp.lua | 232 ++++++++++++++++++++ tex/context/base/mkiv/node-ini.mkiv | 4 + tex/context/base/mkiv/node-met.lua | 230 ++++++++++++++++++++ tex/context/base/mkiv/status-files.pdf | Bin 26597 -> 26578 bytes tex/context/base/mkiv/status-lua.pdf | Bin 268220 -> 269165 bytes tex/context/base/mkiv/strc-def.mkiv | 146 +++++++------ tex/context/base/mkiv/strc-sec.mkiv | 3 + tex/context/base/mkiv/typo-chr.lua | 1 - tex/context/base/mkiv/util-zip.lua | 126 ++++++----- tex/context/interface/mkii/keys-pe.xml | 3 + tex/context/interface/mkiv/i-context.pdf | Bin 894230 -> 893995 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 61165 -> 61165 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 5 +- 68 files changed, 1898 insertions(+), 939 deletions(-) create mode 100644 doc/context/documents/general/manuals/evenmore.pdf delete mode 100644 doc/context/scripts/mkiv/mtx-fonts.html delete mode 100644 doc/context/scripts/mkiv/mtx-fonts.man delete mode 100644 doc/context/scripts/mkiv/mtx-fonts.xml create mode 100644 doc/context/sources/general/manuals/evenmore/evenmore-contents.tex create mode 100644 doc/context/sources/general/manuals/evenmore/evenmore-expansion.tex create mode 100644 doc/context/sources/general/manuals/evenmore/evenmore-introduction.tex create mode 100644 doc/context/sources/general/manuals/evenmore/evenmore-normalization.tex create mode 100644 doc/context/sources/general/manuals/evenmore/evenmore-style.tex create mode 100644 doc/context/sources/general/manuals/evenmore/evenmore-titlepage.tex create mode 100644 doc/context/sources/general/manuals/evenmore/evenmore.tex create mode 100644 tex/context/base/mkiv/node-cmp.lua diff --git a/doc/context/documents/general/manuals/evenmore.pdf b/doc/context/documents/general/manuals/evenmore.pdf new file mode 100644 index 000000000..e8f7e737c Binary files /dev/null and b/doc/context/documents/general/manuals/evenmore.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf index f43b60427..31bb06864 100644 Binary files a/doc/context/documents/general/qrcs/setup-cs.pdf and b/doc/context/documents/general/qrcs/setup-cs.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf index ff28cf5a0..e3ace250f 100644 Binary files a/doc/context/documents/general/qrcs/setup-de.pdf and b/doc/context/documents/general/qrcs/setup-de.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf index 078c2dd7a..12d7ad595 100644 Binary files a/doc/context/documents/general/qrcs/setup-en.pdf and b/doc/context/documents/general/qrcs/setup-en.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf index 2f3f96b7d..b9d18b6e1 100644 Binary files a/doc/context/documents/general/qrcs/setup-fr.pdf and b/doc/context/documents/general/qrcs/setup-fr.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf index 1d9054018..c78a1f578 100644 Binary files a/doc/context/documents/general/qrcs/setup-it.pdf and b/doc/context/documents/general/qrcs/setup-it.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf index 7a04cccd3..9708078cd 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf and b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-de.pdf b/doc/context/documents/general/qrcs/setup-mapping-de.pdf index 35ff02d7f..546aa5f31 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-de.pdf and b/doc/context/documents/general/qrcs/setup-mapping-de.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-en.pdf b/doc/context/documents/general/qrcs/setup-mapping-en.pdf index 52cd92931..bfc546f37 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-en.pdf and b/doc/context/documents/general/qrcs/setup-mapping-en.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf index 9f4321f5d..506d92d93 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf and b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-it.pdf b/doc/context/documents/general/qrcs/setup-mapping-it.pdf index 96373f848..f9d44c4ae 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-it.pdf and b/doc/context/documents/general/qrcs/setup-mapping-it.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf index 5a7d5f114..94cf16b02 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf and b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf index 33d2719cc..6f19eb84c 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf and b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf index d254b787b..b0b530e51 100644 Binary files a/doc/context/documents/general/qrcs/setup-nl.pdf and b/doc/context/documents/general/qrcs/setup-nl.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf index 91bfdc213..b9a54628e 100644 Binary files a/doc/context/documents/general/qrcs/setup-ro.pdf and b/doc/context/documents/general/qrcs/setup-ro.pdf differ diff --git a/doc/context/scripts/mkiv/mtx-fonts.html b/doc/context/scripts/mkiv/mtx-fonts.html deleted file mode 100644 index b175139c8..000000000 --- a/doc/context/scripts/mkiv/mtx-fonts.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - ConTeXt Font Database Management 0.21 - - - - - -
-
ConTeXt Font Database Management 0.21
-
-
-
-
wiki: http://contextgarden.net | mail: ntg-context@ntg.nl | website: http://www.pragma-ade.nl
-
-
-
- -
-
-

Command line options

- - - - - - - - - - - - - - - - - - - - - -
flagvaluedescription
--convertsave open type font in raw table
--unpacksave a tma file in a more readable format
--reloadgenerate new font database (use --force when in doubt)
--reload--simple:generate luatex-fonts-names.lua (not for context!)
--list--name: list installed fonts, filter by name [--pattern]
--list--spec: list installed fonts, filter by spec [--filter]
--list--file: list installed fonts, filter by file [--pattern]
--patternstrfilter files using pattern
--filterlistkey-value pairs
--allshow all found instances (combined with other flags)
--infogive more details
--trackerslistenable trackers
--statisticssome info about the database
--namesuse name instead of unicodes
--cachestruse specific cache (otl or otf)
-
-

Examples

-mtxrun --script font --list somename (== --pattern=*somename*) -

mtxrun --script font --list --name somename -
mtxrun --script font --list --name --pattern=*somename* -

mtxrun --script font --list --spec somename -
mtxrun --script font --list --spec somename-bold-italic -
mtxrun --script font --list --spec --pattern=*somename* -
mtxrun --script font --list --spec --filter="fontname=somename" -
mtxrun --script font --list --spec --filter="familyname=somename,weight=bold,style=italic,width=condensed" -
mtxrun --script font --list --spec --filter="familyname=crap*,weight=bold,style=italic" -

mtxrun --script font --list --all -
mtxrun --script font --list --file somename -
mtxrun --script font --list --file --all somename -
mtxrun --script font --list --file --pattern=*somename* -

mtxrun --script font --convert texgyrepagella-regular.otf -
mtxrun --script font --convert --names texgyrepagella-regular.otf -

-
- - diff --git a/doc/context/scripts/mkiv/mtx-fonts.man b/doc/context/scripts/mkiv/mtx-fonts.man deleted file mode 100644 index e781b087c..000000000 --- a/doc/context/scripts/mkiv/mtx-fonts.man +++ /dev/null @@ -1,69 +0,0 @@ -.TH "mtx-fonts" "1" "01-01-2019" "version 1.00" "ConTeXt Font Database Management" -.SH NAME - mtx-fonts - ConTeXt Font Database Management -.SH SYNOPSIS -.B mtxrun --script fonts [ -.I OPTIONS ... -.B ] [ -.I FILENAMES -.B ] -.SH DESCRIPTION -.B ConTeXt Font Database Management -.SH OPTIONS -.TP -.B --convert -save open type font in raw table -.TP -.B --unpack -save a tma file in a more readable format -.TP -.B --reload -generate new font database (use --force when in doubt) -.TP -.B --reload ---simple:generate luatex-fonts-names.lua (not for context!) -.TP -.B --list ---name: list installed fonts, filter by name [--pattern] -.TP -.B --list ---spec: list installed fonts, filter by spec [--filter] -.TP -.B --list ---file: list installed fonts, filter by file [--pattern] -.TP -.B --pattern=str -filter files using pattern -.TP -.B --filter=list -key-value pairs -.TP -.B --all -show all found instances (combined with other flags) -.TP -.B --info -give more details -.TP -.B --trackers=list -enable trackers -.TP -.B --statistics -some info about the database -.TP -.B --names -use name instead of unicodes -.TP -.B --cache=str -use specific cache (otl or otf) -.SH AUTHOR -More information about ConTeXt and the tools that come with it can be found at: - - -.B "maillist:" -ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context - -.B "webpage:" -http://www.pragma-ade.nl / http://tex.aanhet.net - -.B "wiki:" -http://contextgarden.net diff --git a/doc/context/scripts/mkiv/mtx-fonts.xml b/doc/context/scripts/mkiv/mtx-fonts.xml deleted file mode 100644 index d001f4f9a..000000000 --- a/doc/context/scripts/mkiv/mtx-fonts.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - mtx-fonts - ConTeXt Font Database Management - 1.00 - - - - - save open type font in raw table - save a tma file in a more readable format - - - generate new font database (use when in doubt) - :generate luatex-fonts-names.lua (not for context!) - - - : list installed fonts, filter by name [] - : list installed fonts, filter by spec [] - : list installed fonts, filter by file [] - - - filter files using pattern - key-value pairs - show all found instances (combined with other flags) - give more details - enable trackers - some info about the database - use name instead of unicodes - use specific cache (otl or otf) - - - - - - Examples - - mtxrun --script font --list somename (== --pattern=*somename*) - - - mtxrun --script font --list --name somename - mtxrun --script font --list --name --pattern=*somename* - - - mtxrun --script font --list --spec somename - mtxrun --script font --list --spec somename-bold-italic - mtxrun --script font --list --spec --pattern=*somename* - mtxrun --script font --list --spec --filter="fontname=somename" - mtxrun --script font --list --spec --filter="familyname=somename,weight=bold,style=italic,width=condensed" - mtxrun --script font --list --spec --filter="familyname=crap*,weight=bold,style=italic" - - - mtxrun --script font --list --all - mtxrun --script font --list --file somename - mtxrun --script font --list --file --all somename - mtxrun --script font --list --file --pattern=*somename* - - - mtxrun --script font --convert texgyrepagella-regular.otf - mtxrun --script font --convert --names texgyrepagella-regular.otf - - - - diff --git a/doc/context/scripts/mkiv/mtx-unzip.html b/doc/context/scripts/mkiv/mtx-unzip.html index 655c1be8d..60172eaa8 100644 --- a/doc/context/scripts/mkiv/mtx-unzip.html +++ b/doc/context/scripts/mkiv/mtx-unzip.html @@ -40,8 +40,7 @@ flagvaluedescription --listlist files in archive - --junkflatten unzipped directory structure - --extractextract files + --extractextract files [--silent --steps]
diff --git a/doc/context/scripts/mkiv/mtx-unzip.man b/doc/context/scripts/mkiv/mtx-unzip.man index 39db05cd6..b2b954e71 100644 --- a/doc/context/scripts/mkiv/mtx-unzip.man +++ b/doc/context/scripts/mkiv/mtx-unzip.man @@ -14,11 +14,8 @@ .B --list list files in archive .TP -.B --junk -flatten unzipped directory structure -.TP .B --extract -extract files +extract files [--silent --steps] .SH AUTHOR More information about ConTeXt and the tools that come with it can be found at: diff --git a/doc/context/scripts/mkiv/mtx-unzip.xml b/doc/context/scripts/mkiv/mtx-unzip.xml index 9f56ca076..0346957f6 100644 --- a/doc/context/scripts/mkiv/mtx-unzip.xml +++ b/doc/context/scripts/mkiv/mtx-unzip.xml @@ -9,8 +9,7 @@ list files in archive - flatten unzipped directory structure - extract files + extract files [--silent --steps] diff --git a/doc/context/sources/general/manuals/evenmore/evenmore-contents.tex b/doc/context/sources/general/manuals/evenmore/evenmore-contents.tex new file mode 100644 index 000000000..d20b45eee --- /dev/null +++ b/doc/context/sources/general/manuals/evenmore/evenmore-contents.tex @@ -0,0 +1,11 @@ +\startcomponent evenmore-contents + +\environment evenmore-style + +\starttitle[title={Table of contents}] + + \placelist[chapter] + +\stoptitle + +\stopcomponent diff --git a/doc/context/sources/general/manuals/evenmore/evenmore-expansion.tex b/doc/context/sources/general/manuals/evenmore/evenmore-expansion.tex new file mode 100644 index 000000000..6c67f07d6 --- /dev/null +++ b/doc/context/sources/general/manuals/evenmore/evenmore-expansion.tex @@ -0,0 +1,148 @@ +% language=us + +\environment evenmore-style + +\startcomponent evenmore-expansion + +\startchapter[title=Expansion] + +Character expansion was introduced in \PDFTEX\ a couple of decades ago. It is a +mechanism that scales glyphs horizontally in order to reduce excessive whitespace +that is needed to properly justify a paragraph. I must admit that I never use it +myself but there are users who do. Although this mechanism evolved a bit, and in +\LUATEX\ is implemented a bit different, the basics remained the same. If you +have no clue what this is about, you can just quite reading here. + +A font can be set up to expand characters by a certain amount: they can shrink or +stretch. This is driven by three parameters: \type {step}, \type {stretch} and +\type {shrink}. The values are in thousands because \TEX\ has no float quantity. +Originally these values were percentages of the width of a glyph, later they +became related to the em width but in \LUATEX\ we went back to the former +definition. + +In \CONTEXT\ \MKIV\ we have an interface that works as follows: + +\startbuffer +\startluacode + local classes = fonts.expansions.classes + + classes.qualitya = { + vector = "default", + factor = 1, + stretch = 4, + shrink = 2, + step = .5, + } + + classes.qualityb = { + vector = "default", + factor = 1, + stretch = 8, + shrink = 4, + step = .5, + } + +\stopluacode +\stopbuffer + +\typebuffer[option=TEX] \getbuffer + +The default vector looks like this: + +\starttyping[option=LUA] +vectors['default'] = { + [0x0041] = 0.5, -- A + [0x0042] = 0.7, -- B + -- and some more +} +\stoptyping + +The values that we pass to the engine are stretch 40, shrink 20, and step 5 for +\type {qualitya} and stretch 80, shrink 40, and step 5 for \type {qualityb}, so +we multiply by 10. In the engine the step is limited to 100, the stretch to 1000 +and the shrink to 500. But these extremes produce quite bad results. + +The expansion class is set with the \type {expansion} feature, as in: + +\startbuffer +\definefontfeature [basea] [default] [expansion=qualitya] +\definefontfeature [baseb] [default] [expansion=qualityb] + +\definefont [FontA] [Serif*basea] +\definefont [FontB] [Serif*baseb] + +\stopbuffer + +\typebuffer[option=TEX] \getbuffer + +\startbuffer[sample] + \setupalign[verytolerant,stretch,hz] % hz triggers expansion + \dorecurse {30} {% + {\FontB \darkred test me #1,} \FontA \dorecurse{#1}{test ##1, }% + }\par +\stopbuffer + +In \in {figure} [hz:1] we see this in action, using the following code: + +\typebuffer[sample][option=TEX] + +\startplacefigure[reference=hz:1] + \getbuffer[sample] +\stopplacefigure + +There is one drawback with this method, although so far I never heard a user +complain, which can be an indication of how this mechanism is used: you cannot +mix fonts with different step, stretch and|/|or shrink. As we just did this in +the example, this statement is not really true in \LUAMETATEX: there we only need +to keep the step the same. This is compatible in the sense that otherwise we +would quit the run, so at least we carry on: the smallest stretch and shrink is +taken. But, we do issue a warning (once) because there can be side effects! This +is not that pretty a solution anyway because it depends on what font is used +first. + +It is for this reason that we have another option: in \CONTEXT\ \LMTX\ you can +define a specific expansion: + +\startbuffer +\defineexpansion + [myexpansion] + [step=1, % default + stretch=50, + shrink=20] +\stopbuffer + +\typebuffer[option=TEX] \getbuffer + +There is no need to have a different step than~1. In \PDFTEX\ instances are +created per step used, but in \LUATEX\ this is more fluid. There is no gain in +using different steps. We just keep it for compatibility reasons. This specific +expansion is enables with: + +\starttyping[option=TEX] +\setexpansion[myexpansion] +\stoptyping + +and the result is shown in \in {figure} [hz:2]. This time the set expansion wins +over the one set in the font. All fonts that have the expansion feature set are +treated the same. By using this method you can locally have different values. + +\startplacefigure[reference=hz:2] + \setexpansion[myexpansion] + \getbuffer[sample] +\stopplacefigure + +Deep down we use some new primitives: + +\starttyping[option=TEX] +\adjustspacingstep +\adjustspacingstretch +\adjustspacingshrink +\stoptyping + +The step is limited to 100 (10\percent) and the stretch and shrink to 500 +(50\percent) and the stretch to 1000 (100\percent) but these extremes are only +useful for examples. + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/evenmore/evenmore-introduction.tex b/doc/context/sources/general/manuals/evenmore/evenmore-introduction.tex new file mode 100644 index 000000000..d5bfbdad7 --- /dev/null +++ b/doc/context/sources/general/manuals/evenmore/evenmore-introduction.tex @@ -0,0 +1,38 @@ +% language=us + +\startcomponent evenmore-introduction + +\environment evenmore-style + +\startchapter[title={Introduction}] + +After five collections of \quote {articles} about the development of \LUATEX, +\CONTEXT\ \MKIV, \LUAMETATEX\ and \CONTEXT\ \LMTX, there is even more to tell so +here is number six. Wrapping up not only serves to inform the users but for me it is +also a way to get things right: if you cannot write it down it's no good. It forces +me to (re)consider interfaces and also test new code but of course it comes with +no guarantees. + +When writing this introduction I just finished the first chapter, about some new +font stuff, as follow up on the (again) nice \CONTEXT\ meeting in 2019. It's +always inspiring to meet and talk with my \TEX\ friends and see what they're +doing. It keeps me going. + +Some chapters end up in user group journals first so they will be added once they +have been published and are available. The advantage is that these are then +copy|-|edited. Many texts, also in previous development updates, got better +because Karl Berry checked them thoroughly for TUGboat, for which I'm grateful. + +Hopefully, this document serves a purpose. + +\blank[2*big] + +\startlines +Hans Hagen +PRAGMA ADE, Hasselt NL +Started in October 2019 +\stoplines + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/evenmore/evenmore-normalization.tex b/doc/context/sources/general/manuals/evenmore/evenmore-normalization.tex new file mode 100644 index 000000000..36d4390aa --- /dev/null +++ b/doc/context/sources/general/manuals/evenmore/evenmore-normalization.tex @@ -0,0 +1,239 @@ +% language=us + +% \enabletrackers[nodes.directions] + +\environment evenmore-style + +\startcomponent evenmore-normalization + +\startchapter[title=Normalization] + +What I describe here was long due. I delayed it because when enabled it had best +also be used and I need to (check and) adapt some code to it in order to profit +from it. So, if used at all, it will take some time to have an effect on the +\CONTEXT\ code base. But first some background information. + +When \TEX\ builds a paragraph it splits the current text stream (that makes up +the paragraph) into lines where each line becomes an horizontal box. In \LUATEX, +this process is split into distinctive steps, contrary to regular \TEX\ where the +splitting is combined with hyphenation, ligature construction and font kerning. +But what all engines have in common is that after the decision is made about what +a line is, the result gets packages into the horizontal box. + +The decision making is influenced by quite some factors, like: + +\startitemize[packed] +\startitem + The indentation of the first line, driven by the presence of a box of + with a certain width and no height and depth (its always there, also when + the indentation is zero). +\stopitem +\startitem + Hanging indentation, which can happen at each corner of the paragraph, or + alternatively a specific parshape. +\stopitem +\startitem + Left and|/|or right margins, aka left skip and right skip. A right skip is + always present, even when zero. +\stopitem +\startitem + The way the last line gets aligns, aka parfill skip. +\stopitem +\startitem + Directional changes that need to be carries over to the next line. +\stopitem +\startitem + Optional protrusion of characters to the left of right of the line, something + that is sensitive for directional changes. +\stopitem +\startitem + Expansion of characters in order to get better inter|-|word spacing and|/|or + to prevent lines being too bad. There can be stretch as well as shrink but + on a per line basis. Inter|-|character kerns can also get that treatment. +\stopitem +\startitem + The penalties associated to hyphenation: the pre|-|last line, the last two + lines, a list of penalties (\ETEX), specific penalties bound to hyphenation + pints (\LUATEX). +\stopitem +\startitem + The wish to have more or less lines than optimal, aka looseness. I have to + admit that I never use that feature. +\stopitem +\stopitemize + +In traditional \TEX\ it doesn't really matter how the resulting boxes look like, +as long as the following steps can handle them, and those steps don't look into +those boxes. In fact, unless you unpack a box, only the backend deals with the +content. But in \LUATEX\ we have callbacks that hook into several stages and {\em +can} look into the constructed boxes. In \LUATEX\ these boxes also have embedded +directional information (needed by the backend) and (although that is seldom +used) left or right boxed material, a features inherited from \ALEPH|/|\OMEGA. +And when messing around with the content of boxes one has to know what can be +seen there. In principle the code can be reorganized a it but adding additional +functionality is not that trivial because we want to stay close to the original +implementation, even if it has been messed up a bit by successive additions. +Eventually I might give it a try to integrate all these features a bit better, +but on the other hand: it works. + +\starttexdefinition Sample #1#2 + \startluacode + document.normalizestate = nodes.getnormalizeline() + nodes.setnormalizeline(#1) + \stopluacode + \startsubsubject[title={normalization #1, #2}] + \typebuffer[#2] + \startlinecorrection + \forgetall + \start + \setupalign[verytolerant,stretch] + \showmakeup[line,hbox,vbox,glue] + \vbox{\getbuffer[#2]\samplefile{sapolsky}} + \stop + \par + \stoplinecorrection + \stopsubject + \startluacode + nodes.setnormalizeline(document.normalizestate) + \stopluacode +\stoptexdefinition + +\startbuffer[sample-1] + \parindent = 20pt + \leftskip = 40pt + \rightskip = 50pt + \hangindent = 0pt + \hangafter = 0 +\stopbuffer + +\startbuffer[sample-2] + \parindent = 0pt + \leftskip = 0pt + \rightskip = 0pt + \hangindent =-20pt + \hangafter = -3 +\stopbuffer + +\startbuffer[sample-3] + \parindent = 0pt + \leftskip = 0pt + \rightskip = 0pt + \hangindent = 20pt + \hangafter = 3 +\stopbuffer + +\startbuffer[sample-4] + \parindent = 0pt + \leftskip = 10pt + \rightskip = 30pt + \hangindent = 20pt + \hangafter = 3 +\stopbuffer + +In the next examples we show how the result of typesetting a paragraph looks +like. We use the Sapolsky quote from the distribution. The cyan glue nodes are +the left and right skip nodes, and the gray one at the end of the last line +represents the parfill skip. The magenta ones at the edge are baseline skips. An +indentation is shown in gray too. As experiment we have four normalization levels +but in the end only the highest level makes sense, simply because normalization +makes no sense unless one consistently normalizes all. We just keep the +granularity because it makes it possible to explain what gets done. + +\texdefinition{Sample}{0}{sample-1} +\texdefinition{Sample}{0}{sample-2} +\texdefinition{Sample}{0}{sample-3} +\texdefinition{Sample}{0}{sample-4} + +You might have noticed that the right skip is always there but the left skip is +absent when it is zero. As said, as long as the result is okay, it does not +really matter. But \unknown\ in \LUATEX\ (and therefore \CONTEXT) it can have +consequences because there we can kick in a callback that does something with +lines. Such a callback often has to deal with these specific glues and them being +optional makes for more testing. The more predictable the order is, the better. +Although we can easily normalize lines (in a callback) to always have a left skip +too it is also an option in the engine. + +\texdefinition{Sample}{1}{sample-1} +\texdefinition{Sample}{1}{sample-2} +\texdefinition{Sample}{1}{sample-3} +\texdefinition{Sample}{1}{sample-4} + +In the previous examples there are always left skips as well as right skips. It +makes no sense to have an option to omit both zero left and right skips, because +that again is unpredictable. But we can go further. + +\texdefinition{Sample}{2}{sample-1} +\texdefinition{Sample}{2}{sample-2} +\texdefinition{Sample}{2}{sample-3} +\texdefinition{Sample}{2}{sample-4} + +In these examples the indentation has been turned into a glue as well (actually +it is more a kern but using a glue makes more sense). The hanging indentation +however is not seen here: it is not represented by glue but instead sort of +hidden in the width of the box and a shift of its content. + +\texdefinition{Sample}{3}{sample-1} +\texdefinition{Sample}{3}{sample-2} +\texdefinition{Sample}{3}{sample-3} +\texdefinition{Sample}{3}{sample-4} + +In the previous examples the hanging indentation is turned into left and right +hang skips. These cannot be set at the \TEX\ end, but are injected when we +instruct the normalizer to do so. + +\texdefinition{Sample}{4}{sample-1} +\texdefinition{Sample}{4}{sample-2} +\texdefinition{Sample}{4}{sample-3} +\texdefinition{Sample}{4}{sample-4} + +The previous examples differ from the previous set in that they push these hang +related glue nodes before the left and after the right skip. As I couldn't make +up my mind yet, I let \LUAMETATEX\ just provide both variants. + +The option to keep hang related information explicitly in the line has some +consequences. First of all, we now have glue and not some shift|/|width +combination. Second, we have introduced an incompatibility: the lines now always +have the proper width. You might have noticed that but we can show it more +explicitly. We use two parameter sets + +\startbuffer[sample-5] + \hangindent = 20pt + \hangafter = 0 +\stopbuffer + +\startbuffer[sample-6] + \hangindent =-20pt + \hangafter = 0 +\stopbuffer + +\Sample{0}{sample-5} +\Sample{4}{sample-5} + +\Sample{0}{sample-6} +\Sample{4}{sample-6} + +A not yet mention part of the normalization is that, because they are no longer +of relevance, the special local par nodes have been removed. The one that starts +a paragraph is turned into a normal directional node if needed, so that we get +properly balanced pairs of directional nodes. It must been said that the code +that does all this is a bit of a mess. We want to stay close to the original +code, but we also need to deal with all these extensions, like directions, +protrusion, extra boxes, etc. + +Not shown here is that there is a fifth mode of operation. When we enable that +level an overfull box will get a correction skip so that the right skip etc are +properly aligned. How useful this is: we'll see. + +Now, when I decide to keep this feature, which can be set at the \LUA\ end to do +the previously mentioned tasks, depending on a feature level ranging from zero to +four, I also need to check the impact on existing \CONTEXT\ code, which +(currently) is complicated by the fact that most is shared between \MKIV\ and +\LMTX, and only \LUAMETATEX\ has this normalization feature. I will probably +enable it for a while locally in order to see if there are side effects. Then, +when the code base gets adapted, we have to assume that normalization happens, so +there is no way back. + +\stopchapter + +\stopcomponent + diff --git a/doc/context/sources/general/manuals/evenmore/evenmore-style.tex b/doc/context/sources/general/manuals/evenmore/evenmore-style.tex new file mode 100644 index 000000000..07168e57c --- /dev/null +++ b/doc/context/sources/general/manuals/evenmore/evenmore-style.tex @@ -0,0 +1,67 @@ +% \enablelmtx +% \nopdfcompression + +\startenvironment evenmore-style + +\usemodule[abbreviations-smallcaps] +\usemodule[scite] + +\logo [LUAMETATEX] {LuaMeta\TeXsuffix} + +\setupbodyfont[plex,10pt] % not that ok for titling + +\setuplayout + [width=middle, + height=middle, + header=0pt, + footer=1cm, + footerdistance=5mm, + backspace=2cm, + cutspace=15mm, + topspace=2cm, + bottomspace=1cm, + style=bold, + color=maincolor] + +\setuppagenumbering + [alternative=doublesided] + +\setupwhitespace + [big] + +\setupfootertexts + [][{\getmarking[chapter]\quad\pagenumber}] + [{\pagenumber\quad\getmarking[chapter]}][] + +\definecolor + [maincolor] + [darkgray] + +\setuphead + [chapter] + [style=\bfc, + color=maincolor] + +\setuphead + [section] + [style=\bfa, + color=maincolor] + +\setuphead + [subsection] + [style=\bf, + color=maincolor] + +\setupalign + [tolerant,stretch] + +\setuptyping + [color=maincolor] + +\setuptype + [color=maincolor] + +\setupitemize + [color=maincolor] + +\stopenvironment diff --git a/doc/context/sources/general/manuals/evenmore/evenmore-titlepage.tex b/doc/context/sources/general/manuals/evenmore/evenmore-titlepage.tex new file mode 100644 index 000000000..57418800c --- /dev/null +++ b/doc/context/sources/general/manuals/evenmore/evenmore-titlepage.tex @@ -0,0 +1,45 @@ +\startcomponent evenmore-titlepage + +\environment evenmore-style + +% \usetypescriptfile[latinmodern] +% \usetypescript[mono][latin-modern] +% \definefont[MyFontA][LMTypewriter-Dark*none] +% \definefont[MyFontB][LMTypewriterVarWd-Regular*default] + +\definefont[MyFontA][MonoBold*none] +\definefont[MyFontB][Serif*default] + +\startMPpage[pagestate=stop] + +StartPage ; + + fill Page withcolor .1 ; + + numeric d ; d := PaperWidth/4 ; + + numeric w ; w := d ; + numeric h ; h := 2d ; + + draw textext.rt ("\MyFontA E") xsized d shifted (0w,PaperHeight- 36mm) withcolor "darkred" ; + draw textext.rt ("\MyFontA V") xsized d shifted (1w,PaperHeight- 36mm) withcolor "darkgreen" ; + draw textext.rt ("\MyFontA E") xsized d shifted (2w,PaperHeight- 36mm) withcolor "darkblue" ; + draw textext.rt ("\MyFontA N") xsized d shifted (3w,PaperHeight- 36mm) withcolor "darkorange" ; + draw textext.rt ("\MyFontA M") xsized d shifted (0w,PaperHeight-104mm) withcolor "darkcyan" ; + draw textext.rt ("\MyFontA O") xsized d shifted (1w,PaperHeight-104mm) withcolor "darkmagenta" ; + draw textext.rt ("\MyFontA R") xsized d shifted (2w,PaperHeight-104mm) withcolor "darkyellow" ; + draw textext.rt ("\MyFontA E") xsized d shifted (3w,PaperHeight-104mm) withcolor "darkgray" ; + +% draw textext.lft ("\MyFontB\setstrut\strut fun with") ysized 30mm shifted lrcorner Page shifted (-1cm,8cm) withcolor "white" ; +% draw textext.lft ("\MyFontB\setstrut\strut luametatex") ysized 30mm shifted lrcorner Page shifted (-1cm,5cm) withcolor "white" ; +% draw textext.lft ("\MyFontB\setstrut\strut and context") ysized 30mm shifted lrcorner Page shifted (-1cm,2cm) withcolor "white" ; + + draw textext.lft ("\MyFontB\setstrut\strut fun with") ysized 27mm shifted lrcorner Page shifted (-10mm,70mm) withcolor "white" ; + draw textext.lft ("\MyFontB\setstrut\strut luametatex") ysized 27mm shifted lrcorner Page shifted (-10mm,45mm) withcolor "white" ; + draw textext.lft ("\MyFontB\setstrut\strut and context") ysized 27mm shifted lrcorner Page shifted (-10mm,20mm) withcolor "white" ; + +StopPage ; + +\stopMPpage + +\stopcomponent diff --git a/doc/context/sources/general/manuals/evenmore/evenmore.tex b/doc/context/sources/general/manuals/evenmore/evenmore.tex new file mode 100644 index 000000000..9a5052e26 --- /dev/null +++ b/doc/context/sources/general/manuals/evenmore/evenmore.tex @@ -0,0 +1,37 @@ +\environment evenmore-style + +\dontcomplain + +\startdocument + + \component evenmore-titlepage + + \startfrontmatter + \component evenmore-contents + \stopfrontmatter + + \startbodymatter + + \component evenmore-introduction + + % \component evenmore-pi + \startchapter[title={\TEX\ and Pi}] + First in TUGboat. + \stopchapter + + % \component evenmore-fonts + \startchapter[title={Modern Type 3 fonts}] + First in TUGboat. + \stopchapter + + % \component evenmore-threesix + \startchapter[title={ThreeSix, Don Knuths first colorfont?}] + After the his new book comes out. + \stopchapter + + \component evenmore-normalization + \component evenmore-expansion + + \stopbodymatter + +\stopdocument diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex b/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex index 6081be4f3..24dd5c65a 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex @@ -97,9 +97,15 @@ Hans Hagen \NC \LUATEX\ Team \EQ Hans Hagen, Hartmut Henkel, Taco Hoekwater, Luigi Scarso \NC \NR \stoptabulate -\LUAMETATEX\ development is mostly done by Hans Hagen and Alan Braslau, who love -playing with the three languages involved. Testing is done by \CONTEXT\ -developers and users. +\vfilll + +{\bf remark:} \LUAMETATEX\ development is mostly done by Hans Hagen and Alan +Braslau, who love playing with the three languages involved. Testing is done by +\CONTEXT\ developers and users. Many thanks for their patience! + +{\bf remark:} When there are non|-|intrusive features that also make sense in +\LUATEX, these will be applied in the experimental branch first, so that there is +no interference with the stable release. \stopchapter diff --git a/doc/context/sources/general/manuals/luametatex/luametatex.tex b/doc/context/sources/general/manuals/luametatex/luametatex.tex index 71a8bf48b..a0bc823bc 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex.tex @@ -6,7 +6,7 @@ \startdocument [manual=LuaMeta\TeX, status=experimental, - version=2.00] + version=2.02] \component luametatex-titlepage \component luametatex-firstpage diff --git a/doc/context/sources/general/manuals/luatex/luatex-modifications.tex b/doc/context/sources/general/manuals/luatex/luatex-modifications.tex index b7ce6ca2b..747945f55 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-modifications.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-modifications.tex @@ -262,7 +262,10 @@ backend are decoupled as much as possible. \startitem When \lpr {adjustspacing} has value~2, hz optimization will be applied to glyphs and kerns. When the value is~3, only glyphs will be treated. A value - smaller than~2 disables this feature. + smaller than~2 disables this feature. With value of 1, font expansion is + applied after \TEX's normal paragraph breaking routines have broken the + paragraph into lines. In this case, line breaks are identical to standard + \TEX\ behavior (as with \PDFTEX). \stopitem \startitem diff --git a/scripts/context/lua/mtx-unzip.lua b/scripts/context/lua/mtx-unzip.lua index 02d9676bc..0bc219386 100644 --- a/scripts/context/lua/mtx-unzip.lua +++ b/scripts/context/lua/mtx-unzip.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['mtx-unzip'] = { -- maybe --pattern -local format = string.format +local format, find = string.format, string.find local helpinfo = [[ @@ -22,8 +22,7 @@ local helpinfo = [[ list files in archive - flatten unzipped directory structure - extract files + extract files [--silent --steps] @@ -41,92 +40,87 @@ local report = application.report scripts = scripts or { } scripts.unzipper = scripts.unzipper or { } -function scripts.unzipper.opened() +local function validfile() local filename = environment.files[1] if filename and filename ~= "" then filename = file.addsuffix(filename,'zip') - local zipfile = zip.open(filename) - if zipfile then - return zipfile + if lfs.isfile(filename) then + return filename + else + report("invalid zip file: %s",filename) end + else + report("no zip file") end - report("no zip file: %s",filename) return false end function scripts.unzipper.list() - local zipfile = scripts.unzipper.opened() - if zipfile then - local n = 0 - for k in zipfile:files() do - if #k.filename > n then n = #k.filename end - end - local files, paths, compressed, uncompressed = 0, 0, 0, 0 - local template_a = "%-"..n.."s" - local template_b = "%-"..n.."s % 9i % 9i" - local template_c = "\n%-"..n.."s % 9i % 9i" - for k in zipfile:files() do - if k.filename:find("/$") then - paths = paths + 1 - print(format(template_a, k.filename)) - else - files = files + 1 - local cs, us = k.compressed_size, k.uncompressed_size - if cs > compressed then - compressed = cs - end - if us > uncompressed then - uncompressed = us + local filename = validfile() + if filename then + local zipfile = utilities.zipfiles.open(filename) + if zipfile then + local list = utilities.zipfiles.list(zipfile) + if list then + local n = 0 + for i=1,#list do + local l = list[i] + if #l.filename > n then + n = #l.filename + end end - print(format(template_b,k.filename,cs,us)) + local files, paths, compressed, uncompressed = 0, 0, 0, 0 + local template_a = "%-" .. n .."s" + local template_b = "%-" .. n .."s % 9i % 9i" + local template_c = "\n%-" .. n .."s % 9i % 9i" + for i=1,#list do + local l = list[i] + local f = l.filename + if find(f,"/$") then + paths = paths + 1 + print(format(template_a, f)) + else + files = files + 1 + local cs = l.compressed + local us = l.uncompressed + if cs > compressed then + compressed = cs + end + if us > uncompressed then + uncompressed = us + end + print(format(template_b,f,cs,us)) + end + end -- check following pattern, n is not enough + print(format(template_c,files .. " files, " .. paths .. " directories",compressed,uncompressed)) end - end -- check following pattern, n is not enough - print(format(template_c,files .. " files, " .. paths .. " directories",compressed,uncompressed)) - end -end - -function zip.loaddata(zipfile,filename) - local f = zipfile:open(filename) - if f then - local data = f:read("*a") - f:close() - return data + utilities.zipfiles.close(zipfile) + else + report("invalid zip file: %s",filename) + end end - return nil end function scripts.unzipper.extract() - local zipfile = scripts.unzipper.opened() - if zipfile then - local junk = environment.arguments["j"] or environment.arguments["junk"] - for k in zipfile:files() do - local filename = k.filename - if filename:find("/$") then - if not junk then - lfs.mkdir(filename) - end - else - local data = zip.loaddata(zipfile,filename) - if data then - if junk then - filename = file.basename(filename) - end - io.savedata(filename,data) - print(filename) - end - end - end + local filename = validfile() + if validfile then + -- todo --junk + local silent = environment.arguments["silent"] + local steps = environment.arguments["steps"] + utilities.zipfiles.unzipdir { + zipname = filename, + path = ".", + verbose = not silent and (steps and "steps" or true), + } end end -if environment.arguments["h"] or environment.arguments["help"] then - application.help() -elseif environment.arguments["l"] or environment.arguments["list"] then - scripts.unzipper.list(zipfile) +if environment.arguments["list"] then + scripts.unzipper.list() +elseif environment.arguments["extract"] then + scripts.unzipper.extract() elseif environment.arguments["exporthelp"] then application.export(environment.arguments["exporthelp"],environment.files[1]) -elseif environment.files[1] then -- implicit --extract - scripts.unzipper.extract(zipfile) else application.help() end diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 94ca07bb3..2604294db 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -4631,7 +4631,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-gzip"] = package.loaded["l-gzip"] or true --- original size: 2980, stripped down to: 2054 +-- original size: 5115, stripped down to: 1699 if not modules then modules={} end modules ['l-gzip']={ version=1.001, @@ -4639,35 +4639,46 @@ if not modules then modules={} end modules ['l-gzip']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -if gzip then - local suffix,suffixes=file.suffix,file.suffixes +gzip=gzip or {} +if not zlib then + zlib=xzip +elseif not xzip then + xzip=zlib +end +if zlib then + local suffix=file.suffix + local suffixes=file.suffixes + local find=string.find + local openfile=io.open + local gzipwindow=15+16 + local gziplevel=3 + local identifier="^\x1F\x8B\x08" + local compress=zlib.compress + local decompress=zlib.decompress function gzip.load(filename) - local f=io.open(filename,"rb") + local f=openfile(filename,"rb") if not f then - elseif suffix(filename)=="gz" then - f:close() - local g=gzip.open(filename,"rb") - if g then - local str=g:read("*all") - g:close() - return str - end else - local str=f:read("*all") + local data=f:read("*all") f:close() - return str + if data and data~="" then + if suffix(filename)=="gz" then + data=decompress(data,gzipwindow) + end + return data + end end end - function gzip.save(filename,data) + function gzip.save(filename,data,level) if suffix(filename)~="gz" then filename=filename..".gz" end - local f=io.open(filename,"wb") + local f=openfile(filename,"wb") if f then - local s=zlib.compress(data or "",9,nil,15+16) - f:write(s) + data=compress(data or "",level or gziplevel,nil,gzipwindow) + f:write(data) f:close() - return #s + return #data end end function gzip.suffix(filename) @@ -4675,58 +4686,24 @@ if gzip then local gzipped=extra=="gz" return suffix,gzipped end -else -end -if flate then - local type=type - local find=string.find - local compress=flate.gz_compress - local decompress=flate.gz_decompress - local absmax=128*1024*1024 - local initial=64*1024 - local identifier="^\x1F\x8B\x08" function gzip.compressed(s) return s and find(s,identifier) end function gzip.compress(s,level) if s and not find(s,identifier) then if not level then - level=3 + level=gziplevel elseif level<=0 then return s elseif level>9 then level=9 end - return compress(s,level) or s + return compress(s,level or gziplevel,nil,gzipwindow) or s end end - function gzip.decompress(s,size,iterate) + function gzip.decompress(s) if s and find(s,identifier) then - if type(size)~="number" then - size=initial - end - if size>absmax then - size=absmax - end - if type(iterate)=="number" then - max=size*iterate - elseif iterate==nil or iterate==true then - iterate=true - max=absmax - end - if max>absmax then - max=absmax - end - while true do - local d=decompress(s,size) - if d then - return d - end - size=2*size - if not iterate or size>max then - return false - end - end + return decompress(s,gzipwindow) else return s end @@ -15960,7 +15937,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 18645, stripped down to: 11291 +-- original size: 19243, stripped down to: 10700 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15971,7 +15948,7 @@ if not modules then modules={} end modules ['util-zip']={ local type,tostring,tonumber=type,tostring,tonumber local sort=table.sort local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub -local osdate,ostime=os.date,os.time +local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs @@ -15987,10 +15964,6 @@ local band=bit32.band local rshift=bit32.rshift local lshift=bit32.lshift local decompress,calculatecrc -if flate then - decompress=flate.flate_decompress - calculatecrc=flate.update_crc32 -else local zlibdecompress=zlib.decompress local zlibchecksum=zlib.crc32 decompress=function(source,targetsize) @@ -16004,7 +15977,6 @@ else calculatecrc=function(buffer,initial) return zlibchecksum(initial or 0,buffer) end -end local zipfiles={} utilities.zipfiles=zipfiles local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do @@ -16113,6 +16085,7 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do z.handle=nil end end + local expandsize=xzip.expandsize function unzipfile(z,filename,check) local hash=z.hash if not hash then @@ -16129,7 +16102,11 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do setposition(handle,position) local result=readstring(handle,compressed) if data.method==8 then - result=decompress(result,data.uncompressed) + if expandsize then + result=expandsize(result,data.uncompressed) + else + result=decompress(result) + end end if check and data.crc32~=calculatecrc(result) then print("checksum mismatch") @@ -16148,14 +16125,14 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do zipfiles.list=getziplist zipfiles.found=foundzipfile end -if flate then do +if xzip then local writecardinal1=files.writebyte local writecardinal2=files.writecardinal2le local writecardinal4=files.writecardinal4le local logwriter=logs.writer local globpattern=dir.globpattern - local compress=flate.flate_compress - local checksum=flate.update_crc32 + local compress=xzip.compress + local checksum=xzip.crc32 local function fromdostime(dostime,dosdate) return ostime { year=rshift(dosdate,9)+1980, @@ -16352,18 +16329,20 @@ if flate then do local count=#list local step=number.idiv(count,10) local done=0 + local steps=verbose=="steps" + local time=steps and osclock() for i=1,count do local l=list[i] local n=l.filename local d=unzipfile(z,n) local p=filejoin(path,n) if mkdirs(dirname(p)) then - if verbose=="steps" then + if steps then total=total+#d done=done+1 if done>=step then done=0 - logwriter(format("%4i files of %4i done, %10i bytes",i,count,total)) + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time)) end elseif verbose then logwriter(n) @@ -16371,8 +16350,8 @@ if flate then do savedata(p,d) end end - if verbose=="steps" then - logwriter(format("%4i files of %4i done, %10i bytes",count,count,total)) + if steps then + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time)) end closezipfile(z) return true @@ -16383,37 +16362,8 @@ if flate then do end zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir -end end -if flate then - local streams=utilities.streams - local openfile=streams.open - local closestream=streams.close - local setposition=streams.setposition - local getsize=streams.size - local readcardinal4=streams.readcardinal4le - local getstring=streams.getstring - local decompress=flate.gz_decompress - function zipfiles.gunzipfile(filename) - local strm=openfile(filename) - if strm then - setposition(strm,getsize(strm)-4+1) - local size=readcardinal4(strm) - local data=decompress(getstring(strm),size) - closestream(strm) - return data - end - end -elseif gzip then - local openfile=gzip.open - function zipfiles.gunzipfile(filename) - local g=openfile(filename,"rb") - if g then - local d=g:read("*a") - d:close() - return d - end - end end +zipfiles.gunzipfile=gzip.load end -- of closure @@ -26129,8 +26079,8 @@ end -- of closure -- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1040843 --- stripped bytes : 412133 +-- original bytes : 1043576 +-- stripped bytes : 415812 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 94ca07bb3..2604294db 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -4631,7 +4631,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-gzip"] = package.loaded["l-gzip"] or true --- original size: 2980, stripped down to: 2054 +-- original size: 5115, stripped down to: 1699 if not modules then modules={} end modules ['l-gzip']={ version=1.001, @@ -4639,35 +4639,46 @@ if not modules then modules={} end modules ['l-gzip']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -if gzip then - local suffix,suffixes=file.suffix,file.suffixes +gzip=gzip or {} +if not zlib then + zlib=xzip +elseif not xzip then + xzip=zlib +end +if zlib then + local suffix=file.suffix + local suffixes=file.suffixes + local find=string.find + local openfile=io.open + local gzipwindow=15+16 + local gziplevel=3 + local identifier="^\x1F\x8B\x08" + local compress=zlib.compress + local decompress=zlib.decompress function gzip.load(filename) - local f=io.open(filename,"rb") + local f=openfile(filename,"rb") if not f then - elseif suffix(filename)=="gz" then - f:close() - local g=gzip.open(filename,"rb") - if g then - local str=g:read("*all") - g:close() - return str - end else - local str=f:read("*all") + local data=f:read("*all") f:close() - return str + if data and data~="" then + if suffix(filename)=="gz" then + data=decompress(data,gzipwindow) + end + return data + end end end - function gzip.save(filename,data) + function gzip.save(filename,data,level) if suffix(filename)~="gz" then filename=filename..".gz" end - local f=io.open(filename,"wb") + local f=openfile(filename,"wb") if f then - local s=zlib.compress(data or "",9,nil,15+16) - f:write(s) + data=compress(data or "",level or gziplevel,nil,gzipwindow) + f:write(data) f:close() - return #s + return #data end end function gzip.suffix(filename) @@ -4675,58 +4686,24 @@ if gzip then local gzipped=extra=="gz" return suffix,gzipped end -else -end -if flate then - local type=type - local find=string.find - local compress=flate.gz_compress - local decompress=flate.gz_decompress - local absmax=128*1024*1024 - local initial=64*1024 - local identifier="^\x1F\x8B\x08" function gzip.compressed(s) return s and find(s,identifier) end function gzip.compress(s,level) if s and not find(s,identifier) then if not level then - level=3 + level=gziplevel elseif level<=0 then return s elseif level>9 then level=9 end - return compress(s,level) or s + return compress(s,level or gziplevel,nil,gzipwindow) or s end end - function gzip.decompress(s,size,iterate) + function gzip.decompress(s) if s and find(s,identifier) then - if type(size)~="number" then - size=initial - end - if size>absmax then - size=absmax - end - if type(iterate)=="number" then - max=size*iterate - elseif iterate==nil or iterate==true then - iterate=true - max=absmax - end - if max>absmax then - max=absmax - end - while true do - local d=decompress(s,size) - if d then - return d - end - size=2*size - if not iterate or size>max then - return false - end - end + return decompress(s,gzipwindow) else return s end @@ -15960,7 +15937,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 18645, stripped down to: 11291 +-- original size: 19243, stripped down to: 10700 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15971,7 +15948,7 @@ if not modules then modules={} end modules ['util-zip']={ local type,tostring,tonumber=type,tostring,tonumber local sort=table.sort local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub -local osdate,ostime=os.date,os.time +local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs @@ -15987,10 +15964,6 @@ local band=bit32.band local rshift=bit32.rshift local lshift=bit32.lshift local decompress,calculatecrc -if flate then - decompress=flate.flate_decompress - calculatecrc=flate.update_crc32 -else local zlibdecompress=zlib.decompress local zlibchecksum=zlib.crc32 decompress=function(source,targetsize) @@ -16004,7 +15977,6 @@ else calculatecrc=function(buffer,initial) return zlibchecksum(initial or 0,buffer) end -end local zipfiles={} utilities.zipfiles=zipfiles local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do @@ -16113,6 +16085,7 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do z.handle=nil end end + local expandsize=xzip.expandsize function unzipfile(z,filename,check) local hash=z.hash if not hash then @@ -16129,7 +16102,11 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do setposition(handle,position) local result=readstring(handle,compressed) if data.method==8 then - result=decompress(result,data.uncompressed) + if expandsize then + result=expandsize(result,data.uncompressed) + else + result=decompress(result) + end end if check and data.crc32~=calculatecrc(result) then print("checksum mismatch") @@ -16148,14 +16125,14 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do zipfiles.list=getziplist zipfiles.found=foundzipfile end -if flate then do +if xzip then local writecardinal1=files.writebyte local writecardinal2=files.writecardinal2le local writecardinal4=files.writecardinal4le local logwriter=logs.writer local globpattern=dir.globpattern - local compress=flate.flate_compress - local checksum=flate.update_crc32 + local compress=xzip.compress + local checksum=xzip.crc32 local function fromdostime(dostime,dosdate) return ostime { year=rshift(dosdate,9)+1980, @@ -16352,18 +16329,20 @@ if flate then do local count=#list local step=number.idiv(count,10) local done=0 + local steps=verbose=="steps" + local time=steps and osclock() for i=1,count do local l=list[i] local n=l.filename local d=unzipfile(z,n) local p=filejoin(path,n) if mkdirs(dirname(p)) then - if verbose=="steps" then + if steps then total=total+#d done=done+1 if done>=step then done=0 - logwriter(format("%4i files of %4i done, %10i bytes",i,count,total)) + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time)) end elseif verbose then logwriter(n) @@ -16371,8 +16350,8 @@ if flate then do savedata(p,d) end end - if verbose=="steps" then - logwriter(format("%4i files of %4i done, %10i bytes",count,count,total)) + if steps then + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time)) end closezipfile(z) return true @@ -16383,37 +16362,8 @@ if flate then do end zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir -end end -if flate then - local streams=utilities.streams - local openfile=streams.open - local closestream=streams.close - local setposition=streams.setposition - local getsize=streams.size - local readcardinal4=streams.readcardinal4le - local getstring=streams.getstring - local decompress=flate.gz_decompress - function zipfiles.gunzipfile(filename) - local strm=openfile(filename) - if strm then - setposition(strm,getsize(strm)-4+1) - local size=readcardinal4(strm) - local data=decompress(getstring(strm),size) - closestream(strm) - return data - end - end -elseif gzip then - local openfile=gzip.open - function zipfiles.gunzipfile(filename) - local g=openfile(filename,"rb") - if g then - local d=g:read("*a") - d:close() - return d - end - end end +zipfiles.gunzipfile=gzip.load end -- of closure @@ -26129,8 +26079,8 @@ end -- of closure -- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1040843 --- stripped bytes : 412133 +-- original bytes : 1043576 +-- stripped bytes : 415812 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 94ca07bb3..2604294db 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -4631,7 +4631,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-gzip"] = package.loaded["l-gzip"] or true --- original size: 2980, stripped down to: 2054 +-- original size: 5115, stripped down to: 1699 if not modules then modules={} end modules ['l-gzip']={ version=1.001, @@ -4639,35 +4639,46 @@ if not modules then modules={} end modules ['l-gzip']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -if gzip then - local suffix,suffixes=file.suffix,file.suffixes +gzip=gzip or {} +if not zlib then + zlib=xzip +elseif not xzip then + xzip=zlib +end +if zlib then + local suffix=file.suffix + local suffixes=file.suffixes + local find=string.find + local openfile=io.open + local gzipwindow=15+16 + local gziplevel=3 + local identifier="^\x1F\x8B\x08" + local compress=zlib.compress + local decompress=zlib.decompress function gzip.load(filename) - local f=io.open(filename,"rb") + local f=openfile(filename,"rb") if not f then - elseif suffix(filename)=="gz" then - f:close() - local g=gzip.open(filename,"rb") - if g then - local str=g:read("*all") - g:close() - return str - end else - local str=f:read("*all") + local data=f:read("*all") f:close() - return str + if data and data~="" then + if suffix(filename)=="gz" then + data=decompress(data,gzipwindow) + end + return data + end end end - function gzip.save(filename,data) + function gzip.save(filename,data,level) if suffix(filename)~="gz" then filename=filename..".gz" end - local f=io.open(filename,"wb") + local f=openfile(filename,"wb") if f then - local s=zlib.compress(data or "",9,nil,15+16) - f:write(s) + data=compress(data or "",level or gziplevel,nil,gzipwindow) + f:write(data) f:close() - return #s + return #data end end function gzip.suffix(filename) @@ -4675,58 +4686,24 @@ if gzip then local gzipped=extra=="gz" return suffix,gzipped end -else -end -if flate then - local type=type - local find=string.find - local compress=flate.gz_compress - local decompress=flate.gz_decompress - local absmax=128*1024*1024 - local initial=64*1024 - local identifier="^\x1F\x8B\x08" function gzip.compressed(s) return s and find(s,identifier) end function gzip.compress(s,level) if s and not find(s,identifier) then if not level then - level=3 + level=gziplevel elseif level<=0 then return s elseif level>9 then level=9 end - return compress(s,level) or s + return compress(s,level or gziplevel,nil,gzipwindow) or s end end - function gzip.decompress(s,size,iterate) + function gzip.decompress(s) if s and find(s,identifier) then - if type(size)~="number" then - size=initial - end - if size>absmax then - size=absmax - end - if type(iterate)=="number" then - max=size*iterate - elseif iterate==nil or iterate==true then - iterate=true - max=absmax - end - if max>absmax then - max=absmax - end - while true do - local d=decompress(s,size) - if d then - return d - end - size=2*size - if not iterate or size>max then - return false - end - end + return decompress(s,gzipwindow) else return s end @@ -15960,7 +15937,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 18645, stripped down to: 11291 +-- original size: 19243, stripped down to: 10700 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15971,7 +15948,7 @@ if not modules then modules={} end modules ['util-zip']={ local type,tostring,tonumber=type,tostring,tonumber local sort=table.sort local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub -local osdate,ostime=os.date,os.time +local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs @@ -15987,10 +15964,6 @@ local band=bit32.band local rshift=bit32.rshift local lshift=bit32.lshift local decompress,calculatecrc -if flate then - decompress=flate.flate_decompress - calculatecrc=flate.update_crc32 -else local zlibdecompress=zlib.decompress local zlibchecksum=zlib.crc32 decompress=function(source,targetsize) @@ -16004,7 +15977,6 @@ else calculatecrc=function(buffer,initial) return zlibchecksum(initial or 0,buffer) end -end local zipfiles={} utilities.zipfiles=zipfiles local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do @@ -16113,6 +16085,7 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do z.handle=nil end end + local expandsize=xzip.expandsize function unzipfile(z,filename,check) local hash=z.hash if not hash then @@ -16129,7 +16102,11 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do setposition(handle,position) local result=readstring(handle,compressed) if data.method==8 then - result=decompress(result,data.uncompressed) + if expandsize then + result=expandsize(result,data.uncompressed) + else + result=decompress(result) + end end if check and data.crc32~=calculatecrc(result) then print("checksum mismatch") @@ -16148,14 +16125,14 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do zipfiles.list=getziplist zipfiles.found=foundzipfile end -if flate then do +if xzip then local writecardinal1=files.writebyte local writecardinal2=files.writecardinal2le local writecardinal4=files.writecardinal4le local logwriter=logs.writer local globpattern=dir.globpattern - local compress=flate.flate_compress - local checksum=flate.update_crc32 + local compress=xzip.compress + local checksum=xzip.crc32 local function fromdostime(dostime,dosdate) return ostime { year=rshift(dosdate,9)+1980, @@ -16352,18 +16329,20 @@ if flate then do local count=#list local step=number.idiv(count,10) local done=0 + local steps=verbose=="steps" + local time=steps and osclock() for i=1,count do local l=list[i] local n=l.filename local d=unzipfile(z,n) local p=filejoin(path,n) if mkdirs(dirname(p)) then - if verbose=="steps" then + if steps then total=total+#d done=done+1 if done>=step then done=0 - logwriter(format("%4i files of %4i done, %10i bytes",i,count,total)) + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time)) end elseif verbose then logwriter(n) @@ -16371,8 +16350,8 @@ if flate then do savedata(p,d) end end - if verbose=="steps" then - logwriter(format("%4i files of %4i done, %10i bytes",count,count,total)) + if steps then + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time)) end closezipfile(z) return true @@ -16383,37 +16362,8 @@ if flate then do end zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir -end end -if flate then - local streams=utilities.streams - local openfile=streams.open - local closestream=streams.close - local setposition=streams.setposition - local getsize=streams.size - local readcardinal4=streams.readcardinal4le - local getstring=streams.getstring - local decompress=flate.gz_decompress - function zipfiles.gunzipfile(filename) - local strm=openfile(filename) - if strm then - setposition(strm,getsize(strm)-4+1) - local size=readcardinal4(strm) - local data=decompress(getstring(strm),size) - closestream(strm) - return data - end - end -elseif gzip then - local openfile=gzip.open - function zipfiles.gunzipfile(filename) - local g=openfile(filename,"rb") - if g then - local d=g:read("*a") - d:close() - return d - end - end end +zipfiles.gunzipfile=gzip.load end -- of closure @@ -26129,8 +26079,8 @@ end -- of closure -- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1040843 --- stripped bytes : 412133 +-- original bytes : 1043576 +-- stripped bytes : 415812 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 94ca07bb3..2604294db 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -4631,7 +4631,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-gzip"] = package.loaded["l-gzip"] or true --- original size: 2980, stripped down to: 2054 +-- original size: 5115, stripped down to: 1699 if not modules then modules={} end modules ['l-gzip']={ version=1.001, @@ -4639,35 +4639,46 @@ if not modules then modules={} end modules ['l-gzip']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -if gzip then - local suffix,suffixes=file.suffix,file.suffixes +gzip=gzip or {} +if not zlib then + zlib=xzip +elseif not xzip then + xzip=zlib +end +if zlib then + local suffix=file.suffix + local suffixes=file.suffixes + local find=string.find + local openfile=io.open + local gzipwindow=15+16 + local gziplevel=3 + local identifier="^\x1F\x8B\x08" + local compress=zlib.compress + local decompress=zlib.decompress function gzip.load(filename) - local f=io.open(filename,"rb") + local f=openfile(filename,"rb") if not f then - elseif suffix(filename)=="gz" then - f:close() - local g=gzip.open(filename,"rb") - if g then - local str=g:read("*all") - g:close() - return str - end else - local str=f:read("*all") + local data=f:read("*all") f:close() - return str + if data and data~="" then + if suffix(filename)=="gz" then + data=decompress(data,gzipwindow) + end + return data + end end end - function gzip.save(filename,data) + function gzip.save(filename,data,level) if suffix(filename)~="gz" then filename=filename..".gz" end - local f=io.open(filename,"wb") + local f=openfile(filename,"wb") if f then - local s=zlib.compress(data or "",9,nil,15+16) - f:write(s) + data=compress(data or "",level or gziplevel,nil,gzipwindow) + f:write(data) f:close() - return #s + return #data end end function gzip.suffix(filename) @@ -4675,58 +4686,24 @@ if gzip then local gzipped=extra=="gz" return suffix,gzipped end -else -end -if flate then - local type=type - local find=string.find - local compress=flate.gz_compress - local decompress=flate.gz_decompress - local absmax=128*1024*1024 - local initial=64*1024 - local identifier="^\x1F\x8B\x08" function gzip.compressed(s) return s and find(s,identifier) end function gzip.compress(s,level) if s and not find(s,identifier) then if not level then - level=3 + level=gziplevel elseif level<=0 then return s elseif level>9 then level=9 end - return compress(s,level) or s + return compress(s,level or gziplevel,nil,gzipwindow) or s end end - function gzip.decompress(s,size,iterate) + function gzip.decompress(s) if s and find(s,identifier) then - if type(size)~="number" then - size=initial - end - if size>absmax then - size=absmax - end - if type(iterate)=="number" then - max=size*iterate - elseif iterate==nil or iterate==true then - iterate=true - max=absmax - end - if max>absmax then - max=absmax - end - while true do - local d=decompress(s,size) - if d then - return d - end - size=2*size - if not iterate or size>max then - return false - end - end + return decompress(s,gzipwindow) else return s end @@ -15960,7 +15937,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 18645, stripped down to: 11291 +-- original size: 19243, stripped down to: 10700 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15971,7 +15948,7 @@ if not modules then modules={} end modules ['util-zip']={ local type,tostring,tonumber=type,tostring,tonumber local sort=table.sort local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub -local osdate,ostime=os.date,os.time +local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs @@ -15987,10 +15964,6 @@ local band=bit32.band local rshift=bit32.rshift local lshift=bit32.lshift local decompress,calculatecrc -if flate then - decompress=flate.flate_decompress - calculatecrc=flate.update_crc32 -else local zlibdecompress=zlib.decompress local zlibchecksum=zlib.crc32 decompress=function(source,targetsize) @@ -16004,7 +15977,6 @@ else calculatecrc=function(buffer,initial) return zlibchecksum(initial or 0,buffer) end -end local zipfiles={} utilities.zipfiles=zipfiles local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do @@ -16113,6 +16085,7 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do z.handle=nil end end + local expandsize=xzip.expandsize function unzipfile(z,filename,check) local hash=z.hash if not hash then @@ -16129,7 +16102,11 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do setposition(handle,position) local result=readstring(handle,compressed) if data.method==8 then - result=decompress(result,data.uncompressed) + if expandsize then + result=expandsize(result,data.uncompressed) + else + result=decompress(result) + end end if check and data.crc32~=calculatecrc(result) then print("checksum mismatch") @@ -16148,14 +16125,14 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do zipfiles.list=getziplist zipfiles.found=foundzipfile end -if flate then do +if xzip then local writecardinal1=files.writebyte local writecardinal2=files.writecardinal2le local writecardinal4=files.writecardinal4le local logwriter=logs.writer local globpattern=dir.globpattern - local compress=flate.flate_compress - local checksum=flate.update_crc32 + local compress=xzip.compress + local checksum=xzip.crc32 local function fromdostime(dostime,dosdate) return ostime { year=rshift(dosdate,9)+1980, @@ -16352,18 +16329,20 @@ if flate then do local count=#list local step=number.idiv(count,10) local done=0 + local steps=verbose=="steps" + local time=steps and osclock() for i=1,count do local l=list[i] local n=l.filename local d=unzipfile(z,n) local p=filejoin(path,n) if mkdirs(dirname(p)) then - if verbose=="steps" then + if steps then total=total+#d done=done+1 if done>=step then done=0 - logwriter(format("%4i files of %4i done, %10i bytes",i,count,total)) + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time)) end elseif verbose then logwriter(n) @@ -16371,8 +16350,8 @@ if flate then do savedata(p,d) end end - if verbose=="steps" then - logwriter(format("%4i files of %4i done, %10i bytes",count,count,total)) + if steps then + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time)) end closezipfile(z) return true @@ -16383,37 +16362,8 @@ if flate then do end zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir -end end -if flate then - local streams=utilities.streams - local openfile=streams.open - local closestream=streams.close - local setposition=streams.setposition - local getsize=streams.size - local readcardinal4=streams.readcardinal4le - local getstring=streams.getstring - local decompress=flate.gz_decompress - function zipfiles.gunzipfile(filename) - local strm=openfile(filename) - if strm then - setposition(strm,getsize(strm)-4+1) - local size=readcardinal4(strm) - local data=decompress(getstring(strm),size) - closestream(strm) - return data - end - end -elseif gzip then - local openfile=gzip.open - function zipfiles.gunzipfile(filename) - local g=openfile(filename,"rb") - if g then - local d=g:read("*a") - d:close() - return d - end - end end +zipfiles.gunzipfile=gzip.load end -- of closure @@ -26129,8 +26079,8 @@ end -- of closure -- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1040843 --- stripped bytes : 412133 +-- original bytes : 1043576 +-- stripped bytes : 415812 -- end library merge diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index c6965809e..3821ec4a7 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2019.12.02 18:28} +\newcontextversion{2019.12.05 18:44} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 171e1555a..21d3808ea 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2019.12.02 18:28} +\edef\contextversion{2019.12.05 18:44} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index eb5c6d3b8..b9d71fe33 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -232,6 +232,7 @@ \setinterfacevariable{handwritten}{دست‌نوشته} \setinterfacevariable{hang}{بیاویز} \setinterfacevariable{hanging}{آویزان} +\setinterfacevariable{hangingboth}{hangingboth} \setinterfacevariable{head}{سر} \setinterfacevariable{header}{سربرگ} \setinterfacevariable{headintext}{headintext} @@ -1044,6 +1045,7 @@ \setinterfaceconstant{overprint}{overprint} \setinterfaceconstant{ownerpassword}{ownerpassword} \setinterfaceconstant{ownnumber}{شماره‌خود} +\setinterfaceconstant{packcriterium}{packcriterium} \setinterfaceconstant{page}{صفحه} \setinterfaceconstant{pageboundaries}{مرزهای‌صفحه} \setinterfaceconstant{pagecolor}{رنگ‌صفحه} @@ -1053,6 +1055,7 @@ \setinterfaceconstant{pageconversion}{pageconversion} \setinterfaceconstant{pageconversionset}{pageconversionset} \setinterfaceconstant{pageleft}{pageleft} +\setinterfaceconstant{pagemethod}{pagemethod} \setinterfaceconstant{pagenumber}{شماره‌صفحه} \setinterfaceconstant{pageprefix}{pageprefix} \setinterfaceconstant{pageprefixconnector}{pageprefixconnector} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index f0590d199..cfec9c098 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2019.12.02 18:28} +\newcontextversion{2019.12.05 18:44} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 3169d21f8..54f6ecc35 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.12.02 18:28} +\edef\contextversion{2019.12.05 18:44} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index 5cf9188d4..e91fbc285 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.12.02 18:28} +\edef\contextversion{2019.12.05 18:44} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua index a0e695005..f6c81e76d 100644 --- a/tex/context/base/mkiv/font-ctx.lua +++ b/tex/context/base/mkiv/font-ctx.lua @@ -3106,9 +3106,9 @@ end do - local family_font = node.family_font - local new_glyph = nodes.pool.glyph - local fontproperties = fonts.hashes.properties + local getfontoffamily = font.getfontoffamily + local new_glyph = nodes.pool.glyph + local fontproperties = fonts.hashes.properties local function getprivateslot(id,name) if not name then @@ -3177,7 +3177,7 @@ do name = "getprivatemathchar", arguments = "string", actions = function(name) - local p = getprivateslot(family_font(0),name) + local p = getprivateslot(getfontoffamily(0),name) if p then context(utfchar(p)) end diff --git a/tex/context/base/mkiv/font-imp-properties.lua b/tex/context/base/mkiv/font-imp-properties.lua index 5805235b7..21b55aeb2 100644 --- a/tex/context/base/mkiv/font-imp-properties.lua +++ b/tex/context/base/mkiv/font-imp-properties.lua @@ -35,7 +35,6 @@ local constructors = fonts.constructors local getprivate = constructors.getprivate local allocate = utilities.storage.allocate -local family_font = node.family_font local setmetatableindex = table.setmetatableindex diff --git a/tex/context/base/mkiv/font-ini.lua b/tex/context/base/mkiv/font-ini.lua index 462e30bf9..8fdac011d 100644 --- a/tex/context/base/mkiv/font-ini.lua +++ b/tex/context/base/mkiv/font-ini.lua @@ -52,3 +52,7 @@ fonts.privateoffsets = { mathbase = 0xFF000, -- used for hidden (virtual math) keepnames = false, -- when set to true names are always kept (not for context) } + +if not tex.getfontoffamily then + tex.getfontoffamily = node.family_font -- we moved this +end diff --git a/tex/context/base/mkiv/hand-ini.mkiv b/tex/context/base/mkiv/hand-ini.mkiv index a18f86707..dc6d1b198 100644 --- a/tex/context/base/mkiv/hand-ini.mkiv +++ b/tex/context/base/mkiv/hand-ini.mkiv @@ -60,7 +60,7 @@ \def\font_expansion_enable {\normaladjustspacing\plusthree} \def\font_expansion_enable_k{\normaladjustspacing\plustwo} -\def\font_expansion_enable_n{\normaladjustspacing\plusone} +%def\font_expansion_enable_n{\normaladjustspacing\plusone} \def\font_expansion_disable {\normaladjustspacing\zerocount} \def\font_protruding_enable_b{\normalprotrudechars\plusthree} % also deal with r2l (experimental lmtx) diff --git a/tex/context/base/mkiv/hand-ini.mkxl b/tex/context/base/mkiv/hand-ini.mkxl index 66da0585e..ca6922ddd 100644 --- a/tex/context/base/mkiv/hand-ini.mkxl +++ b/tex/context/base/mkiv/hand-ini.mkxl @@ -60,7 +60,7 @@ \def\font_expansion_enable {\normaladjustspacing\plusthree} \def\font_expansion_enable_k{\normaladjustspacing\plustwo} -\def\font_expansion_enable_n{\normaladjustspacing\plusone} +%def\font_expansion_enable_n{\normaladjustspacing\plusone} \def\font_expansion_disable {\normaladjustspacing\zerocount} \def\font_protruding_enable_b{\normalprotrudechars\plusthree} % also deal with r2l (experimental lmtx) diff --git a/tex/context/base/mkiv/l-gzip.lua b/tex/context/base/mkiv/l-gzip.lua index 31466bde8..f141b5ebb 100644 --- a/tex/context/base/mkiv/l-gzip.lua +++ b/tex/context/base/mkiv/l-gzip.lua @@ -5,39 +5,77 @@ if not modules then modules = { } end modules ['l-gzip'] = { license = "see context related readme files" } -if gzip then +-- We only have a few official methods here: +-- +-- local decompressed = gzip.load (filename) +-- local resultsize = gzip.save (filename,compresslevel) +-- local compressed = gzip.compress (str,compresslevel) +-- local decompressed = gzip.decompress (str) +-- local iscompressed = gzip.compressed (str) +-- local suffix, okay = gzip.suffix (filename) +-- +-- In LuaMetaTeX we have only xzip which implements a very few methods: +-- +-- compress (str,level,method,window,memory,strategy) +-- decompress (str,window) +-- adler32 (str,checksum) +-- crc32 (str,checksum) +-- +-- Special window values are: +-- +-- flate : - 15 +-- zlib : 15 +-- gzip : 15 | 16 +-- auto : 15 | 32 + +gzip = gzip or { } -- so in luatex we keep the old ones too + +if not zlib then + zlib = xzip -- in luametatex we shadow the old one +elseif not xzip then + xzip = zlib +end + +if zlib then - local suffix, suffixes = file.suffix, file.suffixes + local suffix = file.suffix + local suffixes = file.suffixes + local find = string.find + local openfile = io.open + + local gzipwindow = 15 + 16 -- +16: gzip, +32: gzip|zlib + local gziplevel = 3 + local identifier = "^\x1F\x8B\x08" + + local compress = zlib.compress + local decompress = zlib.decompress function gzip.load(filename) - local f = io.open(filename,"rb") + local f = openfile(filename,"rb") if not f then -- invalid file - elseif suffix(filename) == "gz" then - f:close() - local g = gzip.open(filename,"rb") - if g then - local str = g:read("*all") - g:close() - return str - end else - local str = f:read("*all") + local data = f:read("*all") f:close() - return str + if data and data ~= "" then + if suffix(filename) == "gz" then + data = decompress(data,gzipwindow) + end + return data + end end end - function gzip.save(filename,data) + function gzip.save(filename,data,level) if suffix(filename) ~= "gz" then filename = filename .. ".gz" end - local f = io.open(filename,"wb") + local f = openfile(filename,"wb") if f then - local s = zlib.compress(data or "",9,nil,15+16) - f:write(s) + data = compress(data or "",level or gziplevel,nil,gzipwindow) + f:write(data) f:close() - return #s + return #data end end @@ -47,24 +85,6 @@ if gzip then return suffix, gzipped end -else - - -- todo: fallback on flate - -end - -if flate then - - local type = type - local find = string.find - - local compress = flate.gz_compress - local decompress = flate.gz_decompress - - local absmax = 128*1024*1024 - local initial = 64*1024 - local identifier = "^\x1F\x8B\x08" - function gzip.compressed(s) return s and find(s,identifier) end @@ -72,46 +92,89 @@ if flate then function gzip.compress(s,level) if s and not find(s,identifier) then -- the find check might go away if not level then - level = 3 + level = gziplevel elseif level <= 0 then return s elseif level > 9 then level = 9 end - return compress(s,level) or s + return compress(s,level or gziplevel,nil,gzipwindow) or s end end - function gzip.decompress(s,size,iterate) + function gzip.decompress(s) if s and find(s,identifier) then - if type(size) ~= "number" then - size = initial - end - if size > absmax then - size = absmax - end - if type(iterate) == "number" then - max = size * iterate - elseif iterate == nil or iterate == true then - iterate = true - max = absmax - end - if max > absmax then - max = absmax - end - while true do - local d = decompress(s,size) - if d then - return d - end - size = 2 * size - if not iterate or size > max then - return false - end - end + return decompress(s,gzipwindow) else return s end end end + +-- In luametatex we can use this one but it doesn't look like there wil be stream +-- support so for now we still use zlib (the performance difference is not that +-- spectacular in our usage. + +-- if flate then +-- +-- local type = type +-- local find = string.find +-- +-- local compress = flate.gz_compress +-- local decompress = flate.gz_decompress +-- +-- local absmax = 128*1024*1024 +-- local initial = 64*1024 +-- local identifier = "^\x1F\x8B\x08" +-- +-- function gzip.compressed(s) +-- return s and find(s,identifier) +-- end +-- +-- function gzip.compress(s,level) +-- if s and not find(s,identifier) then -- the find check might go away +-- if not level then +-- level = 3 +-- elseif level <= 0 then +-- return s +-- elseif level > 9 then +-- level = 9 +-- end +-- return compress(s,level) or s +-- end +-- end +-- +-- function gzip.decompress(s,size,iterate) +-- if s and find(s,identifier) then +-- if type(size) ~= "number" then +-- size = initial +-- end +-- if size > absmax then +-- size = absmax +-- end +-- if type(iterate) == "number" then +-- max = size * iterate +-- elseif iterate == nil or iterate == true then +-- iterate = true +-- max = absmax +-- end +-- if max > absmax then +-- max = absmax +-- end +-- while true do +-- local d = decompress(s,size) +-- if d then +-- return d +-- end +-- size = 2 * size +-- if not iterate or size > max then +-- return false +-- end +-- end +-- else +-- return s +-- end +-- end +-- +-- end diff --git a/tex/context/base/mkiv/lpdf-img.lua b/tex/context/base/mkiv/lpdf-img.lua index 97b596937..17305a1cf 100644 --- a/tex/context/base/mkiv/lpdf-img.lua +++ b/tex/context/base/mkiv/lpdf-img.lua @@ -51,8 +51,8 @@ local pdfminorversion = lpdf.minorversion local createimage = images.create -local zlibcompress = flate and flate.zip_compress or zlib.compress -local zlibdecompress = zlib.decompress -- todo +local zlibcompress = (xzip or zlib).compress +local zlibdecompress = (xzip or zlib).decompress local trace = false diff --git a/tex/context/base/mkiv/lpdf-lmt.lua b/tex/context/base/mkiv/lpdf-lmt.lua index b09f0a4f8..32d743614 100644 --- a/tex/context/base/mkiv/lpdf-lmt.lua +++ b/tex/context/base/mkiv/lpdf-lmt.lua @@ -43,7 +43,7 @@ local bpfactor = number.dimenfactors.bp local md5HEX = md5.HEX local osuuid = os.uuid -local zlibcompress = flate.zip_compress or zlib.compress +local zlibcompress = (xzip or zlib).compress local nuts = nodes.nuts local tonut = nodes.tonut diff --git a/tex/context/base/mkiv/math-act.lua b/tex/context/base/mkiv/math-act.lua index 07ef32746..1f0140960 100644 --- a/tex/context/base/mkiv/math-act.lua +++ b/tex/context/base/mkiv/math-act.lua @@ -441,7 +441,8 @@ mathematics.tweaks = tweaks -- helpers local setmetatableindex = table.setmetatableindex -local family_font = node.family_font + +local getfontoffamily = tex.getfontoffamily local fontcharacters = fonts.hashes.characters local extensibles = utilities.storage.allocate() @@ -512,7 +513,7 @@ setmetatableindex(extensibles,function(extensibles,font) end) local function extensiblecode(family,unicode) - return extensibles[family_font(family or 0)][unicode][1] + return extensibles[getfontoffamily(family or 0)][unicode][1] end -- left : [head] ... @@ -522,7 +523,7 @@ end -- abs(right["start"] - right["end"]) | right.advance | characters[right.glyph].width local function horizontalcode(family,unicode) - local font = family_font(family or 0) + local font = getfontoffamily(family or 0) local data = extensibles[font][unicode] local kind = data[1] local loffset = 0 diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua index 5c078b784..f53410b18 100644 --- a/tex/context/base/mkiv/math-noa.lua +++ b/tex/context/base/mkiv/math-noa.lua @@ -136,8 +136,6 @@ local set_visual = nuts.setvisual local mlist_to_hlist = nuts.mlist_to_hlist -local font_of_family = node.family_font - local new_kern = nodepool.kern local new_submlist = nodepool.submlist local new_noad = nodepool.noad @@ -152,6 +150,7 @@ local fontitalics = fonthashes.italics local variables = interfaces.variables local texsetattribute = tex.setattribute local texgetattribute = tex.getattribute +local getfontoffamily = tex.getfontoffamily local unsetvalue = attributes.unsetvalue local implement = interfaces.implement @@ -512,7 +511,7 @@ do report_families("no bold replacement for %C, family %s with remap %s becomes %s with remap %s",char,a,familymap[a],newa,familymap[newa]) end setfam(pointer,newa) - elseif not fontcharacters[font_of_family(newa)][bold] then + elseif not fontcharacters[getfontoffamily(newa)][bold] then if trace_families then report_families("no bold character for %C, family %s with remap %s becomes %s with remap %s",char,a,familymap[a],newa,familymap[newa]) end @@ -529,7 +528,7 @@ do end else local char = getchar(pointer) - if not fontcharacters[font_of_family(a)][char] then + if not fontcharacters[getfontoffamily(a)][char] then if trace_families then report_families("no bold replacement for %C",char) end @@ -553,14 +552,14 @@ do a = a - 3 end local char = getfield(pointer,"small_char") - local okay = fontcharacters[font_of_family(a)][char] + local okay = fontcharacters[getfontoffamily(a)][char] if okay then setfield(pointer,"small_fam",a) elseif a > 2 then setfield(pointer,"small_fam",a-3) end local char = getfield(pointer,"large_char") - local okay = fontcharacters[font_of_family(a)][char] + local okay = fontcharacters[getfontoffamily(a)][char] if okay then setfield(pointer,"large_fam",a) elseif a > 2 then @@ -585,7 +584,7 @@ do -- a = a - 3 -- end -- local char = getchar(pointer) - -- local okay = fontcharacters[font_of_family(a)][char] + -- local okay = fontcharacters[getfontoffamily(a)][char] -- if okay then -- setfam(pointer,a) -- elseif a > 2 then @@ -792,7 +791,7 @@ do local chr = getchar(delimiter) if chr > 0 then local fam = getfam(delimiter) - local id = font_of_family(fam) + local id = getfontoffamily(fam) if id > 0 then local data = fontdata[id] local char = mathematics.big(data,chr,size,method) @@ -1362,7 +1361,7 @@ do local fontresources = fonts.hashes.resources local function getalternate(fam,tag,current) - local resources = fontresources[font_of_family(fam)] + local resources = fontresources[getfontoffamily(fam)] local attribute = unsetvalue if resources then local mathalternates = resources.mathalternates diff --git a/tex/context/base/mkiv/math-tag.lua b/tex/context/base/mkiv/math-tag.lua index d7aa37a5b..daa757f6a 100644 --- a/tex/context/base/mkiv/math-tag.lua +++ b/tex/context/base/mkiv/math-tag.lua @@ -163,7 +163,7 @@ local fencesstack = { } -- local function getunicode(n) -- instead of getchar -- local char = getchar(n) --- -- local font = font_of_family(getfield(n,"fam")) -- font_of_family +-- -- local font = getfontoffamily(getfield(n,"fam")) -- local font = getfont(n) -- local data = fontcharacters[font][char] -- return data.unicode or char diff --git a/tex/context/base/mkiv/mlib-svg.lua b/tex/context/base/mkiv/mlib-svg.lua index afbf36ecf..fee23acdf 100644 --- a/tex/context/base/mkiv/mlib-svg.lua +++ b/tex/context/base/mkiv/mlib-svg.lua @@ -2924,7 +2924,7 @@ do local entry = svgshapes[i] local data = entry.data if decompress then - data = decompress(data,128*1024) or data + data = decompress(data) or data end local specification = { data = xmlconvert(data), @@ -2971,7 +2971,7 @@ do local entry = svgshapes[i] local data = entry.data if decompress then - data = decompress(data,128*1024) or data + data = decompress(data) or data end local specification = { data = xmlconvert(data), @@ -3024,7 +3024,7 @@ do if index >= entry.first and index <= entry.last then local data = entry.data if data then - local root = xml.convert(gzip.decompress(data,128*1024) or data) + local root = xml.convert(gzip.decompress(data) or data) return metapost.svgtomp ( { data = root, diff --git a/tex/context/base/mkiv/node-aux.lua b/tex/context/base/mkiv/node-aux.lua index e68a672cd..1567868d7 100644 --- a/tex/context/base/mkiv/node-aux.lua +++ b/tex/context/base/mkiv/node-aux.lua @@ -553,8 +553,8 @@ do nuts.find_node = find_node - nuts.getnormalizeline = direct.getnormalizeline or function() return 0 end - nuts.setnormalizeline = direct.setnormalizeline or function() end + nodes.getnormalizeline = nodes.getnormalizeline or function() return 0 end + nodes.setnormalizeline = nodes.setnormalizeline or function() end nuts.getnormalizedline = direct.getnormalizedline or function(h) if getid(h) == hlist_code and getsubtype(h) == line_code then @@ -577,3 +577,233 @@ do end end + +if not nodes.count then + + local type = type + + local direct = node.direct + local todirect = direct.tovaliddirect + local tonode = direct.tonode + + local count = direct.count + local length = direct.length + local slide = direct.slide + + function node.count(id,first,last) + return count(id,first and todirect(first), last and todirect(last) or nil) + end + + function node.length(first,last) + return length(first and todirect(first), last and todirect(last) or nil) + end + + function node.slide(n) + if n then + n = slide(todirect(n)) + if n then + return tonode(n) + end + end + return nil + end + + local hyphenating = direct.hyphenating + local ligaturing = direct.ligaturing + local kerning = direct.kerning + + -- kind of inconsistent + + function node.hyphenating(first,last) + if first then + local h, t = hyphenating(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end + end + + function node.ligaturing(first,last) + if first then + local h, t = ligaturing(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end + end + + function node.kerning(first,last) + if first then + local h, t = kerning(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end + end + + local protect_glyph = direct.protect_glyph + local unprotect_glyph = direct.unprotect_glyph + local protect_glyphs = direct.protect_glyphs + local unprotect_glyphs = direct.unprotect_glyphs + + function node.protect_glyphs(first,last) + protect_glyphs(todirect(first), last and todirect(last) or nil) + end + + function node.unprotect_glyphs(first,last) + unprotect_glyphs(todirect(first), last and todirect(last) or nil) + end + + function node.protect_glyph(first) + protect_glyph(todirect(first)) + end + + function node.unprotect_glyph(first) + unprotect_glyph(todirect(first)) + end + + local flatten_discretionaries = direct.flatten_discretionaries + local check_discretionaries = direct.check_discretionaries + local check_discretionary = direct.check_discretionary + + function node.flatten_discretionaries(first) + local h, count = flatten_discretionaries(todirect(first)) + return tonode(h), count + end + + function node.check_discretionaries(n) + check_discretionaries(todirect(n)) + end + + function node.check_discretionary(n) + check_discretionary(todirect(n)) + end + + local hpack = direct.hpack + local vpack = direct.vpack + local list_to_hlist = direct.mlist_to_hlist + + function node.hpack(head,...) + local h, badness = hpack(head and todirect(head) or nil,...) + return tonode(h), badness + end + + function node.vpack(head,...) + local h, badness = vpack(head and todirect(head) or nil,...) + return tonode(h), badness + end + + function node.mlist_to_hlist(head,...) + return tonode(mlist_to_hlist(head and todirect(head) or nil,...)) + end + + local end_of_math = direct.end_of_math + local find_attribute = direct.find_attribute + local first_glyph = direct.first_glyph + + function node.end_of_math(n) + if n then + n = end_of_math(todirect(n)) + if n then + return tonode(n) + end + end + return nil + end + + function node.find_attribute(n,a) + if n then + local v, n = find_attribute(todirect(n),a) + if n then + return v, tonode(n) + end + end + return nil + end + + function node.first_glyph(first,last) + local n = first_glyph(todirect(first), last and todirect(last) or nil) + return n and tonode(n) or nil + end + + local dimensions = direct.dimensions + local rangedimensions = direct.rangedimensions + local effective_glue = direct.effective_glue + + function node.dimensions(a,b,c,d,e) + if type(a) == "userdata" then + a = todirect(a) + if type(b) == "userdata" then + b = todirect(b) + end + return dimensions(a,b) + else + d = todirect(d) + if type(e) == "userdata" then + e = todirect(e) + end + return dimensions(a,b,c,d,e) + end + return 0, 0, 0 + end + + function node.rangedimensions(parent,first,last) + return rangedimenensions(todirect(parent),todirect(first),last and todirect(last)) + end + + function node.effective_glue(list,parent) + return effective_glue(list and todirect(list) or nil,parent and todirect(parent) or nil) + end + + local uses_font = direct.uses_font + local has_glyph = direct.has_glyph + local protrusion_skippable = direct.protrusion_skippable + local prepend_prevdepth = direct.prepend_prevdepth + local make_extensible = direct.make_extensible + + function node.uses_font(n,f) + return uses_font(todirect(n),f) + end + + function node.has_glyph(n) + return has_glyph(todirect(n)) + end + + function node.protrusion_skippable(n) + return protrusion_skippable(todirect(n)) + end + + function node.prepend_prevdepth(n) + local n, d = prepend_prevdepth(todirect(n)) + return tonode(n), d + end + + function node.make_extensible(...) + local n = make_extensible(...) + return n and tonode(n) or nil + end + + local last_node = direct.last_node + + function node.last_node() + local n = last_node() + return n and tonode(n) or nil + end + + local is_zero_glue = direct.is_zero_glue + local getglue = direct.getglue + local setglue = direct.setglue + + function node.is_zero_glue(n) + return is_zero_glue(todirect(n)) + end + + function node.get_glue(n) + return get_glue(todirect(n)) + end + + function node.set_glue(n) + return set_glue(todirect(n)) + end + +end diff --git a/tex/context/base/mkiv/node-cmp.lua b/tex/context/base/mkiv/node-cmp.lua new file mode 100644 index 000000000..e13e93d1f --- /dev/null +++ b/tex/context/base/mkiv/node-cmp.lua @@ -0,0 +1,232 @@ +if node.count then + return +end + +local type = type + +local node = node +local direct = node.direct +local todirect = direct.tovaliddirect +local tonode = direct.tonode + +local count = direct.count +local length = direct.length +local slide = direct.slide + +function node.count(id,first,last) + return count(id,first and todirect(first), last and todirect(last) or nil) +end + +function node.length(first,last) + return length(first and todirect(first), last and todirect(last) or nil) +end + +function node.slide(n) + if n then + n = slide(todirect(n)) + if n then + return tonode(n) + end + end + return nil +end + +local hyphenating = direct.hyphenating +local ligaturing = direct.ligaturing +local kerning = direct.kerning + +-- kind of inconsistent + +function node.hyphenating(first,last) + if first then + local h, t = hyphenating(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end +end + +function node.ligaturing(first,last) + if first then + local h, t = ligaturing(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end +end + +function node.kerning(first,last) + if first then + local h, t = kerning(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end + end + +local protect_glyph = direct.protect_glyph +local unprotect_glyph = direct.unprotect_glyph +local protect_glyphs = direct.protect_glyphs +local unprotect_glyphs = direct.unprotect_glyphs + +function node.protect_glyphs(first,last) + protect_glyphs(todirect(first), last and todirect(last) or nil) +end + +function node.unprotect_glyphs(first,last) + unprotect_glyphs(todirect(first), last and todirect(last) or nil) +end + +function node.protect_glyph(first) + protect_glyph(todirect(first)) +end + +function node.unprotect_glyph(first) + unprotect_glyph(todirect(first)) +end + +local flatten_discretionaries = direct.flatten_discretionaries +local check_discretionaries = direct.check_discretionaries +local check_discretionary = direct.check_discretionary + +function node.flatten_discretionaries(first) + local h, count = flatten_discretionaries(todirect(first)) + return tonode(h), count +end + +function node.check_discretionaries(n) + check_discretionaries(todirect(n)) +end + +function node.check_discretionary(n) + check_discretionary(todirect(n)) +end + +local hpack = direct.hpack +local vpack = direct.vpack +local list_to_hlist = direct.mlist_to_hlist + +function node.hpack(head,...) + local h, badness = hpack(head and todirect(head) or nil,...) + return tonode(h), badness +end + +function node.vpack(head,...) + local h, badness = vpack(head and todirect(head) or nil,...) + return tonode(h), badness +end + +function node.mlist_to_hlist(head,...) + return tonode(mlist_to_hlist(head and todirect(head) or nil,...)) +end + +local end_of_math = direct.end_of_math +local find_attribute = direct.find_attribute +local first_glyph = direct.first_glyph + +function node.end_of_math(n) + if n then + n = end_of_math(todirect(n)) + if n then + return tonode(n) + end + end + return nil +end + +function node.find_attribute(n,a) + if n then + local v, n = find_attribute(todirect(n),a) + if n then + return v, tonode(n) + end + end + return nil +end + +function node.first_glyph(first,last) + local n = first_glyph(todirect(first), last and todirect(last) or nil) + return n and tonode(n) or nil +end + +local dimensions = direct.dimensions +local rangedimensions = direct.rangedimensions +local effective_glue = direct.effective_glue + +function node.dimensions(a,b,c,d,e) + if type(a) == "userdata" then + a = todirect(a) + if type(b) == "userdata" then + b = todirect(b) + end + return dimensions(a,b) + else + d = todirect(d) + if type(e) == "userdata" then + e = todirect(e) + end + return dimensions(a,b,c,d,e) + end + return 0, 0, 0 +end + +function node.rangedimensions(parent,first,last) + return rangedimenensions(todirect(parent),todirect(first),last and todirect(last)) +end + +function node.effective_glue(list,parent) + return effective_glue(list and todirect(list) or nil,parent and todirect(parent) or nil) +end + +local uses_font = direct.uses_font +local has_glyph = direct.has_glyph +local protrusion_skippable = direct.protrusion_skippable +local prepend_prevdepth = direct.prepend_prevdepth +local make_extensible = direct.make_extensible + +function node.uses_font(n,f) + return uses_font(todirect(n),f) +end + +function node.has_glyph(n) + return has_glyph(todirect(n)) +end + +function node.protrusion_skippable(n) + return protrusion_skippable(todirect(n)) +end + +function node.prepend_prevdepth(n) + local n, d = prepend_prevdepth(todirect(n)) + return tonode(n), d +end + +function node.make_extensible(...) + local n = make_extensible(...) + return n and tonode(n) or nil +end + +local last_node = direct.last_node + +function node.last_node() + local n = last_node() + return n and tonode(n) or nil +end + +local is_zero_glue = direct.is_zero_glue +local getglue = direct.getglue +local setglue = direct.setglue + +function node.is_zero_glue(n) + return is_zero_glue(todirect(n)) +end + +function node.get_glue(n) + return get_glue(todirect(n)) +end + +function node.set_glue(n) + return set_glue(todirect(n)) +end + +node.family_font = tex.getfontoffamily diff --git a/tex/context/base/mkiv/node-ini.mkiv b/tex/context/base/mkiv/node-ini.mkiv index 7a00a8930..5bf53cd2d 100644 --- a/tex/context/base/mkiv/node-ini.mkiv +++ b/tex/context/base/mkiv/node-ini.mkiv @@ -17,6 +17,10 @@ \newcount\filterstate \filterstate\plusone % hm, public +\ifcase\contextlmtxmode \else + \registerctxluafile{node-cmp}{} +\fi + \registerctxluafile{node-ini}{} \registerctxluafile{node-met}{} \registerctxluafile{node-nut}{} diff --git a/tex/context/base/mkiv/node-met.lua b/tex/context/base/mkiv/node-met.lua index f472d31a9..db079c116 100644 --- a/tex/context/base/mkiv/node-met.lua +++ b/tex/context/base/mkiv/node-met.lua @@ -629,3 +629,233 @@ end nodes.keys = keys -- [id][subtype] nodes.fields = nodefields -- (n) + +if not nodes.count then + + local type = type + + local direct = node.direct + local todirect = direct.tovaliddirect + local tonode = direct.tonode + + local count = direct.count + local length = direct.length + local slide = direct.slide + + function node.count(id,first,last) + return count(id,first and todirect(first), last and todirect(last) or nil) + end + + function node.length(first,last) + return length(first and todirect(first), last and todirect(last) or nil) + end + + function node.slide(n) + if n then + n = slide(todirect(n)) + if n then + return tonode(n) + end + end + return nil + end + + local hyphenating = direct.hyphenating + local ligaturing = direct.ligaturing + local kerning = direct.kerning + + -- kind of inconsistent + + function node.hyphenating(first,last) + if first then + local h, t = hyphenating(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end + end + + function node.ligaturing(first,last) + if first then + local h, t = ligaturing(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end + end + + function node.kerning(first,last) + if first then + local h, t = kerning(todirect(first), last and todirect(last) or nil) + return h and tonode(h) or nil, t and tonode(t) or nil, true + else + return nil, false + end + end + + local protect_glyph = direct.protect_glyph + local unprotect_glyph = direct.unprotect_glyph + local protect_glyphs = direct.protect_glyphs + local unprotect_glyphs = direct.unprotect_glyphs + + function node.protect_glyphs(first,last) + protect_glyphs(todirect(first), last and todirect(last) or nil) + end + + function node.unprotect_glyphs(first,last) + unprotect_glyphs(todirect(first), last and todirect(last) or nil) + end + + function node.protect_glyph(first) + protect_glyph(todirect(first)) + end + + function node.unprotect_glyph(first) + unprotect_glyph(todirect(first)) + end + + local flatten_discretionaries = direct.flatten_discretionaries + local check_discretionaries = direct.check_discretionaries + local check_discretionary = direct.check_discretionary + + function node.flatten_discretionaries(first) + local h, count = flatten_discretionaries(todirect(first)) + return tonode(h), count + end + + function node.check_discretionaries(n) + check_discretionaries(todirect(n)) + end + + function node.check_discretionary(n) + check_discretionary(todirect(n)) + end + + local hpack = direct.hpack + local vpack = direct.vpack + local list_to_hlist = direct.mlist_to_hlist + + function node.hpack(head,...) + local h, badness = hpack(head and todirect(head) or nil,...) + return tonode(h), badness + end + + function node.vpack(head,...) + local h, badness = vpack(head and todirect(head) or nil,...) + return tonode(h), badness + end + + function node.mlist_to_hlist(head,...) + return tonode(mlist_to_hlist(head and todirect(head) or nil,...)) + end + + local end_of_math = direct.end_of_math + local find_attribute = direct.find_attribute + local first_glyph = direct.first_glyph + + function node.end_of_math(n) + if n then + n = end_of_math(todirect(n)) + if n then + return tonode(n) + end + end + return nil + end + + function node.find_attribute(n,a) + if n then + local v, n = find_attribute(todirect(n),a) + if n then + return v, tonode(n) + end + end + return nil + end + + function node.first_glyph(first,last) + local n = first_glyph(todirect(first), last and todirect(last) or nil) + return n and tonode(n) or nil + end + + local dimensions = direct.dimensions + local rangedimensions = direct.rangedimensions + local effective_glue = direct.effective_glue + + function node.dimensions(a,b,c,d,e) + if type(a) == "userdata" then + a = todirect(a) + if type(b) == "userdata" then + b = todirect(b) + end + return dimensions(a,b) + else + d = todirect(d) + if type(e) == "userdata" then + e = todirect(e) + end + return dimensions(a,b,c,d,e) + end + return 0, 0, 0 + end + + function node.rangedimensions(parent,first,last) + return rangedimenensions(todirect(parent),todirect(first),last and todirect(last)) + end + + function node.effective_glue(list,parent) + return effective_glue(list and todirect(list) or nil,parent and todirect(parent) or nil) + end + + local uses_font = direct.uses_font + local has_glyph = direct.has_glyph + local protrusion_skippable = direct.protrusion_skippable + local prepend_prevdepth = direct.prepend_prevdepth + local make_extensible = direct.make_extensible + + function node.uses_font(n,f) + return uses_font(todirect(n),f) + end + + function node.has_glyph(n) + return has_glyph(todirect(n)) + end + + function node.protrusion_skippable(n) + return protrusion_skippable(todirect(n)) + end + + function node.prepend_prevdepth(n) + local n, d = prepend_prevdepth(todirect(n)) + return tonode(n), d + end + + function node.make_extensible(...) + local n = make_extensible(...) + return n and tonode(n) or nil + end + + local last_node = direct.last_node + + function node.last_node() + local n = last_node() + return n and tonode(n) or nil + end + + local is_zero_glue = direct.is_zero_glue + local getglue = direct.getglue + local setglue = direct.setglue + + function node.is_zero_glue(n) + return is_zero_glue(todirect(n)) + end + + function node.get_glue(n) + return get_glue(todirect(n)) + end + + function node.set_glue(n) + return set_glue(todirect(n)) + end + +end diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index ebe7a3717..14160c825 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index a9f5e7dbb..1fb3effab 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/strc-def.mkiv b/tex/context/base/mkiv/strc-def.mkiv index 941f561c8..52b3b3ad9 100644 --- a/tex/context/base/mkiv/strc-def.mkiv +++ b/tex/context/base/mkiv/strc-def.mkiv @@ -90,13 +90,18 @@ % \definesection (could become \definehead with one parameter) -\definesection[\s!section-1] % part -\definesection[\s!section-2] % chapter -\definesection[\s!section-3] % section -\definesection[\s!section-4] % subsection -\definesection[\s!section-5] % subsubsection -\definesection[\s!section-6] % subsubsubsection -\definesection[\s!section-7] % subsubsubsubsection +\definesection[\s!section-1] % part +\definesection[\s!section-2] % chapter +\definesection[\s!section-3] % section +\definesection[\s!section-4] % subsection +\definesection[\s!section-5] % subsubsection +\definesection[\s!section-6] % subsubsubsection +\definesection[\s!section-7] % subsubsubsubsection +\definesection[\s!section-8] % subsubsubsubsubsection +\definesection[\s!section-9] % subsubsubsubsubsubsection +\definesection[\s!section-10] % subsubsubsubsubsubsubsection +\definesection[\s!section-11] % subsubsubsubsubsubsubsubsection +\definesection[\s!section-12] % subsubsubsubsubsubsubsubsubsection % \definehead @@ -132,6 +137,31 @@ [\c!section=\s!section-7, \c!default=\v!subsubsubsection] +\definehead + [\v!subsubsubsubsubsection] + [\c!section=\s!section-8, + \c!default=\v!subsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsection] + [\c!section=\s!section-9, + \c!default=\v!subsubsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsubsection] + [\c!section=\s!section-10, + \c!default=\v!subsubsubsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsubsubsection] + [\c!section=\s!section-11, + \c!default=\v!subsubsubsubsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsubsubsubsection] + [\c!section=\s!section-12, + \c!default=\v!subsubsubsubsubsubsubsubsection] + \definehead [\v!title] [\c!coupling=\v!chapter, @@ -168,63 +198,6 @@ \c!default=\v!subsubsubsubsection, \c!incrementnumber=\v!no] -\setuphead - [\v!part] - [\c!placehead=\v!no] - -\setuphead - [\v!chapter] - [\v!appendix\c!label=\v!appendix, - \v!bodypart\c!label=\v!chapter] % bijlageconversie=\Character - -\setuphead - [\v!section] - [\v!appendix\c!label=\v!section, - \v!bodypart\c!label=\v!section] % bijlageconversie=\Character - -\setuphead - [\v!subsection] - [\v!appendix\c!label=\v!subsection, - \v!bodypart\c!label=\v!subsection] % bijlageconversie=\Character - -\setuphead - [\v!subsubsection] - [\v!appendix\c!label=\v!subsubsection, - \v!bodypart\c!label=\v!subsubsection] % bijlageconversie=\Character - -% extras - -\definesection[\s!section-8] % subsubsubsubsubsection -\definesection[\s!section-9] % subsubsubsubsubsubsection -\definesection[\s!section-10] % subsubsubsubsubsubsubsection -\definesection[\s!section-11] % subsubsubsubsubsubsubsubsection -\definesection[\s!section-12] % subsubsubsubsubsubsubsubsubsection - -\definehead - [\v!subsubsubsubsubsection] - [\c!section=\s!section-8, - \c!default=\v!subsubsubsubsection] - -\definehead - [\v!subsubsubsubsubsubsection] - [\c!section=\s!section-9, - \c!default=\v!subsubsubsubsubsection] - -\definehead - [\v!subsubsubsubsubsubsubsection] - [\c!section=\s!section-10, - \c!default=\v!subsubsubsubsubsubsection] - -\definehead - [\v!subsubsubsubsubsubsubsubsection] - [\c!section=\s!section-11, - \c!default=\v!subsubsubsubsubsubsubsection] - -\definehead - [\v!subsubsubsubsubsubsubsubsubsection] - [\c!section=\s!section-12, - \c!default=\v!subsubsubsubsubsubsubsubsection] - \definehead [\v!subsubsubsubsubsubject] [\c!coupling=\v!subsubsubsubsubsection, @@ -255,6 +228,34 @@ \c!default=\v!subsubsubsubsubsubsubsubsubsection, \c!incrementnumber=\v!no] +% setups + +\setuphead + [\v!part] + [\c!placehead=\v!no] + +\setuphead + [\v!chapter] + [\v!appendix\c!label=\v!appendix, + \v!bodypart\c!label=\v!chapter] % bijlageconversie=\Character + +\setuphead + [\v!section] + [\v!appendix\c!label=\v!section, + \v!bodypart\c!label=\v!section] % bijlageconversie=\Character + +\setuphead + [\v!subsection] + [\v!appendix\c!label=\v!subsection, + \v!bodypart\c!label=\v!subsection] % bijlageconversie=\Character + +\setuphead + [\v!subsubsection] + [\v!appendix\c!label=\v!subsubsection, + \v!bodypart\c!label=\v!subsubsection] % bijlageconversie=\Character + +% prefixes + \defineprefixset [\v!all] [section-1,section-2,section-3,section-4,section-5,section-6,section-7,% @@ -321,12 +322,17 @@ [\c!before={\blank[\v!preference,\v!big]}, % sort of mkii compatible, watch columns \c!after=] -\setuplist [\v!part] [\c!width=0\emwidth] -\setuplist [\v!chapter] [\c!width=2\emwidth] -\setuplist [\v!section] [\c!width=3\emwidth] -\setuplist [\v!subsection] [\c!width=4\emwidth] -\setuplist [\v!subsubsection] [\c!width=5\emwidth] -\setuplist [\v!subsubsubsection] [\c!width=6\emwidth] +\setuplist [\v!part] [\c!width=0\emwidth] +\setuplist [\v!chapter] [\c!width=2\emwidth] +\setuplist [\v!section] [\c!width=3\emwidth] +\setuplist [\v!subsection] [\c!width=4\emwidth] +\setuplist [\v!subsubsection] [\c!width=5\emwidth] +\setuplist [\v!subsubsubsection] [\c!width=6\emwidth] \setuplist [\v!subsubsubsubsection] [\c!width=7\emwidth] +\setuplist [\v!subsubsubsubsubsection] [\c!width=8\emwidth] +\setuplist [\v!subsubsubsubsubsubsection] [\c!width=9\emwidth] +\setuplist [\v!subsubsubsubsubsubsubsection] [\c!width=10\emwidth] +\setuplist [\v!subsubsubsubsubsubsubsubsection] [\c!width=11\emwidth] +\setuplist [\v!subsubsubsubsubsubsubsubsubsection] [\c!width=12\emwidth] \protect \endinput diff --git a/tex/context/base/mkiv/strc-sec.mkiv b/tex/context/base/mkiv/strc-sec.mkiv index 21e6adfe3..0e30d92fa 100644 --- a/tex/context/base/mkiv/strc-sec.mkiv +++ b/tex/context/base/mkiv/strc-sec.mkiv @@ -430,6 +430,9 @@ }% \doifelselist\currenthead\donothing {\definelist[\currenthead][\c!prefix=\v!no]}% + % we can't do this now for backward compatibility reasons + % \doifelselist\currenthead\donothing + % {\normalexpanded{\definelist[\currenthead][\currentheadparent][\c!prefix=\v!no]}}% \else \normalexpanded {% \setheadparameter{\c!label}{\currenthead}% diff --git a/tex/context/base/mkiv/typo-chr.lua b/tex/context/base/mkiv/typo-chr.lua index cabfc4ab1..966df6098 100644 --- a/tex/context/base/mkiv/typo-chr.lua +++ b/tex/context/base/mkiv/typo-chr.lua @@ -101,7 +101,6 @@ local texsetcount = tex.setcount local flush_node = nodes.flush_node local flush_list = nodes.flush_list ------ start_of_par = nodes.start_of_par local settexattribute = tex.setattribute local punctuation = characters.is_punctuation diff --git a/tex/context/base/mkiv/util-zip.lua b/tex/context/base/mkiv/util-zip.lua index 7d252a74f..33f8d8a7e 100644 --- a/tex/context/base/mkiv/util-zip.lua +++ b/tex/context/base/mkiv/util-zip.lua @@ -16,7 +16,7 @@ local type, tostring, tonumber = type, tostring, tonumber local sort = table.sort local find, format, sub, gsub = string.find, string.format, string.sub, string.gsub -local osdate, ostime = os.date, os.time +local osdate, ostime, osclock = os.date, os.time, os.clock local ioopen = io.open local loaddata, savedata = io.loaddata, io.savedata local filejoin, isdir, dirname, mkdirs = file.join, lfs.isdir, file.dirname, dir.mkdirs @@ -36,12 +36,12 @@ local lshift = bit32.lshift local decompress, calculatecrc -if flate then - - decompress = flate.flate_decompress - calculatecrc = flate.update_crc32 - -else +-- if flate then +-- +-- decompress = flate.flate_decompress +-- calculatecrc = flate.update_crc32 +-- +-- else local zlibdecompress = zlib.decompress local zlibchecksum = zlib.crc32 @@ -59,7 +59,7 @@ else return zlibchecksum(initial or 0,buffer) end -end +-- end local zipfiles = { } utilities.zipfiles = zipfiles @@ -183,6 +183,8 @@ local openzipfile, closezipfile, unzipfile, foundzipfile, getziphash, getziplist end end + local expandsize = xzip.expandsize + function unzipfile(z,filename,check) local hash = z.hash if not hash then @@ -201,7 +203,11 @@ local openzipfile, closezipfile, unzipfile, foundzipfile, getziphash, getziplist setposition(handle,position) local result = readstring(handle,compressed) if data.method == 8 then - result = decompress(result,data.uncompressed) + if expandsize then + result = expandsize(result,data.uncompressed) + else + result = decompress(result) + end end if check and data.crc32 ~= calculatecrc(result) then print("checksum mismatch") @@ -223,7 +229,7 @@ local openzipfile, closezipfile, unzipfile, foundzipfile, getziphash, getziplist end -if flate then do +if xzip then -- flate then do local writecardinal1 = files.writebyte local writecardinal2 = files.writecardinal2le @@ -232,8 +238,10 @@ if flate then do local logwriter = logs.writer local globpattern = dir.globpattern - local compress = flate.flate_compress - local checksum = flate.update_crc32 +-- local compress = flate.flate_compress +-- local checksum = flate.update_crc32 + local compress = xzip.compress + local checksum = xzip.crc32 -- local function fromdostime(dostime,dosdate) -- return ostime { @@ -469,18 +477,20 @@ if flate then do local count = #list local step = number.idiv(count,10) local done = 0 + local steps = verbose == "steps" + local time = steps and osclock() for i=1,count do local l = list[i] local n = l.filename local d = unzipfile(z,n) -- true for check local p = filejoin(path,n) if mkdirs(dirname(p)) then - if verbose == "steps" then + if steps then total = total + #d done = done + 1 if done >= step then done = 0 - logwriter(format("%4i files of %4i done, %10i bytes",i,count,total)) + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time)) end elseif verbose then logwriter(n) @@ -488,8 +498,8 @@ if flate then do savedata(p,d) end end - if verbose == "steps" then - logwriter(format("%4i files of %4i done, %10i bytes",count,count,total)) + if steps then + logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time)) end closezipfile(z) return true @@ -502,48 +512,50 @@ if flate then do zipfiles.zipdir = zipdir zipfiles.unzipdir = unzipdir -end end - -if flate then - - local streams = utilities.streams - local openfile = streams.open - local closestream = streams.close - local setposition = streams.setposition - local getsize = streams.size - local readcardinal4 = streams.readcardinal4le - local getstring = streams.getstring - local decompress = flate.gz_decompress - - -- id1=1 id2=1 method=1 flags=1 mtime=4(le) extra=1 os=1 - -- flags:8 comment=... flags:4 name=... flags:2 extra=... flags:1 crc=2 - -- data:? - -- crc=4 size=4 - - function zipfiles.gunzipfile(filename) - local strm = openfile(filename) - if strm then - setposition(strm,getsize(strm) - 4 + 1) - local size = readcardinal4(strm) - local data = decompress(getstring(strm),size) - closestream(strm) - return data - end - end - -elseif gzip then - - local openfile = gzip.open +end - function zipfiles.gunzipfile(filename) - local g = openfile(filename,"rb") - if g then - local d = g:read("*a") - d:close() - return d - end - end +zipfiles.gunzipfile = gzip.load -end +-- if flate then +-- +-- local streams = utilities.streams +-- local openfile = streams.open +-- local closestream = streams.close +-- local setposition = streams.setposition +-- local getsize = streams.size +-- local readcardinal4 = streams.readcardinal4le +-- local getstring = streams.getstring +-- local decompress = flate.gz_decompress +-- +-- -- id1=1 id2=1 method=1 flags=1 mtime=4(le) extra=1 os=1 +-- -- flags:8 comment=... flags:4 name=... flags:2 extra=... flags:1 crc=2 +-- -- data:? +-- -- crc=4 size=4 +-- +-- function zipfiles.gunzipfile(filename) +-- local strm = openfile(filename) +-- if strm then +-- setposition(strm,getsize(strm) - 4 + 1) +-- local size = readcardinal4(strm) +-- local data = decompress(getstring(strm),size) +-- closestream(strm) +-- return data +-- end +-- end +-- +-- elseif gzip then +-- +-- local openfile = gzip.open +-- +-- function zipfiles.gunzipfile(filename) +-- local g = openfile(filename,"rb") +-- if g then +-- local d = g:read("*a") +-- d:close() +-- return d +-- end +-- end +-- +-- end return zipfiles diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml index 2fcb76c9f..9f18d633d 100644 --- a/tex/context/interface/mkii/keys-pe.xml +++ b/tex/context/interface/mkii/keys-pe.xml @@ -235,6 +235,7 @@ + @@ -1050,6 +1051,7 @@ + @@ -1059,6 +1061,7 @@ + diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 078c2dd7a..12d7ad595 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index 14396db1c..7695a653b 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 26d79fe47..f81fee7a7 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 12/02/19 18:28:49 +-- merge date : 12/05/19 18:44:50 do -- begin closure to overcome local limits and interference @@ -8690,6 +8690,9 @@ fonts.privateoffsets={ mathbase=0xFF000, keepnames=false, } +if not tex.getfontoffamily then + tex.getfontoffamily=node.family_font +end end -- closure -- cgit v1.2.3