diff options
40 files changed, 383 insertions, 185 deletions
diff --git a/doc/context/scripts/mkiv/context.html b/doc/context/scripts/mkiv/context.html index b409de6e7..9cd106116 100644 --- a/doc/context/scripts/mkiv/context.html +++ b/doc/context/scripts/mkiv/context.html @@ -14,7 +14,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> - <title>ConTeXt Process Management 0.61</title> + <title>ConTeXt Process Management 0.62</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"> body { color: #FFFFFF; background-color: #808080; font-family: optima, verdana, futura, "lucida sans", arial, geneva, helvetica, sans; font-size: 12px; line-height: 18px; } a:link, a:active, a:visited { color: #FFFFFF; } a.dir-view:link, a.dir-view:active, a.dir-view:visited { color: #FFFFFF; text-decoration: underline; } .valid { color: #00FF00; } .invalid { color: #FF0000; } button, .commonlink, .smallbutton { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; border-color: #7F7F7F; border-style: solid; border-width: .125ex; background-color: #FFFFFF; padding: .5ex; } .smallbutton { width: 1em; } a.commonlink:link, a.commonlink:active, a.commonlink:visited, a.smalllink:link, a.smalllink:active, a.smalllink:visited { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; } h1, .title { font-style: normal; font-weight: normal; font-size: 18px; line-height: 18px; margin-bottom: 20px; } h2, .subtitle { font-style: normal; font-weight: normal; font-size: 12px; margin-top: 18px; margin-bottom: 18px; } table { line-height: 18px; font-size: 12px; margin: 0; } th { font-weight: bold; text-align: left; padding-bottom: 6px; } .tc { font-weight: bold; text-align: left; } p, li { max-width: 60em; } .empty-line { margin-top: 4px; } .more-room { margin-right: 1.5em; } .much-more-room { margin-right: 3em; } #main { position: absolute; left: 10%; top: 10%; right: 10%; bottom: 10%; z-index: 2; width: 80%; height: 80%; padding: 0%; margin: 0%; overflow: auto; border-style: none; border-width: 0; background-color: #3F3F3F; } #main-settings { margin: 12px; x_max-width: 60em; line-height: 18px; font-size: 12px; } #left { position: absolute; top : 10%; left: 0%; bottom: 0%; right: 90%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; } #right { position: absolute; top : 0%; left: 90%; bottom: 10%; right: 0%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; _margin-left: -15px; } #bottom { position: absolute; left: 10%; right: 0%; top: 90%; bottom: 0%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top { position: absolute; left: 0%; right: 10%; top: 0%; bottom: 90%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #top-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: right; vertical-align: middle; } #bottom-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #bottom-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: left; vertical-align: middle; } #left-one { position: absolute; width: 100%; buggedheight: 100%; } #left-two { position: relative; margin-top: 12px; line-height: 18px; text-align: center; vertical-align: top; } #right-one { display: table; height: 100%; width: 100%; } #right-two { display: table-row; height: 100%; width: 100%; } #right-three { display: table-cell; width: 100%; vertical-align: bottom; _position: absolute; _top: 100%; } #right-four { text-align: center; margin-bottom: 2ex; _position: relative; _top: -100%; } #more-top { position: absolute; top: 0%; left: 90%; bottom: 90%; right: 0%; z-index: 3; width: 10%; height: 10%; padding: 0%; margin: 0%; border-style: none; border-width: 0; } #more-top-settings { text-align: center; } #more-right-settings { margin-right: 12px; margin-left: 12px; line-height: 18px; font-size: 10px; text-align: center; } #right-safari { _display: table; width: 100%; height: 100%; } @@ -24,7 +24,7 @@ </head> <body> <div id="top"> <div id="top-one"> - <div id="top-two">ConTeXt Process Management 0.61 </div> + <div id="top-two">ConTeXt Process Management 0.62 </div> </div> </div> <div id="bottom"> <div id="bottom-one"> @@ -44,6 +44,7 @@ <tr><th>--make</th><td></td><td>create context formats</td></tr> <tr><th/><td/><td/></tr> <tr><th>--ctx=name</th><td></td><td>use ctx file (process management specification)</td></tr> + <tr><th>--noctx</th><td></td><td>ignore ctx directives and flags</td></tr> <tr><th>--interface</th><td></td><td>use specified user interface (default: en)</td></tr> <tr><th/><td/><td/></tr> <tr><th>--autopdf</th><td></td><td>close pdf file in viewer and start pdf viewer afterwards</td></tr> diff --git a/doc/context/scripts/mkiv/context.man b/doc/context/scripts/mkiv/context.man index 0c2f607f2..e2bfa2f1e 100644 --- a/doc/context/scripts/mkiv/context.man +++ b/doc/context/scripts/mkiv/context.man @@ -1,4 +1,4 @@ -.TH "mtx-context" "1" "01-01-2015" "version 0.60" "ConTeXt Process Management" +.TH "mtx-context" "1" "01-01-2015" "version 0.62" "ConTeXt Process Management" .SH NAME .B mtx-context .SH SYNOPSIS @@ -20,6 +20,9 @@ create context formats .B --ctx=name use ctx file (process management specification) .TP +.B --noctx +ignore ctx directives and flags +.TP .B --interface use specified user interface (default: en) .TP diff --git a/doc/context/scripts/mkiv/context.xml b/doc/context/scripts/mkiv/context.xml index c41093289..46e586153 100644 --- a/doc/context/scripts/mkiv/context.xml +++ b/doc/context/scripts/mkiv/context.xml @@ -4,7 +4,7 @@ <metadata> <entry name="name">mtx-context</entry> <entry name="detail">ConTeXt Process Management</entry> - <entry name="version">0.60</entry> + <entry name="version">0.62</entry> <entry name="comment">external helpinfo file</entry> </metadata> <flags> @@ -21,6 +21,9 @@ <flag name="ctx=name"> <short>use ctx file (process management specification)</short> </flag> + <flag name="noctx"> + <short>ignore ctx directives and flags</short> + </flag> <flag name="interface"> <short>use specified user interface (default: en)</short> </flag> diff --git a/doc/context/scripts/mkiv/mtx-context.html b/doc/context/scripts/mkiv/mtx-context.html index b409de6e7..9cd106116 100644 --- a/doc/context/scripts/mkiv/mtx-context.html +++ b/doc/context/scripts/mkiv/mtx-context.html @@ -14,7 +14,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> - <title>ConTeXt Process Management 0.61</title> + <title>ConTeXt Process Management 0.62</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"> body { color: #FFFFFF; background-color: #808080; font-family: optima, verdana, futura, "lucida sans", arial, geneva, helvetica, sans; font-size: 12px; line-height: 18px; } a:link, a:active, a:visited { color: #FFFFFF; } a.dir-view:link, a.dir-view:active, a.dir-view:visited { color: #FFFFFF; text-decoration: underline; } .valid { color: #00FF00; } .invalid { color: #FF0000; } button, .commonlink, .smallbutton { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; border-color: #7F7F7F; border-style: solid; border-width: .125ex; background-color: #FFFFFF; padding: .5ex; } .smallbutton { width: 1em; } a.commonlink:link, a.commonlink:active, a.commonlink:visited, a.smalllink:link, a.smalllink:active, a.smalllink:visited { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; } h1, .title { font-style: normal; font-weight: normal; font-size: 18px; line-height: 18px; margin-bottom: 20px; } h2, .subtitle { font-style: normal; font-weight: normal; font-size: 12px; margin-top: 18px; margin-bottom: 18px; } table { line-height: 18px; font-size: 12px; margin: 0; } th { font-weight: bold; text-align: left; padding-bottom: 6px; } .tc { font-weight: bold; text-align: left; } p, li { max-width: 60em; } .empty-line { margin-top: 4px; } .more-room { margin-right: 1.5em; } .much-more-room { margin-right: 3em; } #main { position: absolute; left: 10%; top: 10%; right: 10%; bottom: 10%; z-index: 2; width: 80%; height: 80%; padding: 0%; margin: 0%; overflow: auto; border-style: none; border-width: 0; background-color: #3F3F3F; } #main-settings { margin: 12px; x_max-width: 60em; line-height: 18px; font-size: 12px; } #left { position: absolute; top : 10%; left: 0%; bottom: 0%; right: 90%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; } #right { position: absolute; top : 0%; left: 90%; bottom: 10%; right: 0%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; _margin-left: -15px; } #bottom { position: absolute; left: 10%; right: 0%; top: 90%; bottom: 0%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top { position: absolute; left: 0%; right: 10%; top: 0%; bottom: 90%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #top-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: right; vertical-align: middle; } #bottom-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #bottom-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: left; vertical-align: middle; } #left-one { position: absolute; width: 100%; buggedheight: 100%; } #left-two { position: relative; margin-top: 12px; line-height: 18px; text-align: center; vertical-align: top; } #right-one { display: table; height: 100%; width: 100%; } #right-two { display: table-row; height: 100%; width: 100%; } #right-three { display: table-cell; width: 100%; vertical-align: bottom; _position: absolute; _top: 100%; } #right-four { text-align: center; margin-bottom: 2ex; _position: relative; _top: -100%; } #more-top { position: absolute; top: 0%; left: 90%; bottom: 90%; right: 0%; z-index: 3; width: 10%; height: 10%; padding: 0%; margin: 0%; border-style: none; border-width: 0; } #more-top-settings { text-align: center; } #more-right-settings { margin-right: 12px; margin-left: 12px; line-height: 18px; font-size: 10px; text-align: center; } #right-safari { _display: table; width: 100%; height: 100%; } @@ -24,7 +24,7 @@ </head> <body> <div id="top"> <div id="top-one"> - <div id="top-two">ConTeXt Process Management 0.61 </div> + <div id="top-two">ConTeXt Process Management 0.62 </div> </div> </div> <div id="bottom"> <div id="bottom-one"> @@ -44,6 +44,7 @@ <tr><th>--make</th><td></td><td>create context formats</td></tr> <tr><th/><td/><td/></tr> <tr><th>--ctx=name</th><td></td><td>use ctx file (process management specification)</td></tr> + <tr><th>--noctx</th><td></td><td>ignore ctx directives and flags</td></tr> <tr><th>--interface</th><td></td><td>use specified user interface (default: en)</td></tr> <tr><th/><td/><td/></tr> <tr><th>--autopdf</th><td></td><td>close pdf file in viewer and start pdf viewer afterwards</td></tr> diff --git a/doc/context/scripts/mkiv/mtx-context.man b/doc/context/scripts/mkiv/mtx-context.man index 0c2f607f2..e2bfa2f1e 100644 --- a/doc/context/scripts/mkiv/mtx-context.man +++ b/doc/context/scripts/mkiv/mtx-context.man @@ -1,4 +1,4 @@ -.TH "mtx-context" "1" "01-01-2015" "version 0.60" "ConTeXt Process Management" +.TH "mtx-context" "1" "01-01-2015" "version 0.62" "ConTeXt Process Management" .SH NAME .B mtx-context .SH SYNOPSIS @@ -20,6 +20,9 @@ create context formats .B --ctx=name use ctx file (process management specification) .TP +.B --noctx +ignore ctx directives and flags +.TP .B --interface use specified user interface (default: en) .TP diff --git a/doc/context/scripts/mkiv/mtx-context.xml b/doc/context/scripts/mkiv/mtx-context.xml index c41093289..46e586153 100644 --- a/doc/context/scripts/mkiv/mtx-context.xml +++ b/doc/context/scripts/mkiv/mtx-context.xml @@ -4,7 +4,7 @@ <metadata> <entry name="name">mtx-context</entry> <entry name="detail">ConTeXt Process Management</entry> - <entry name="version">0.60</entry> + <entry name="version">0.62</entry> <entry name="comment">external helpinfo file</entry> </metadata> <flags> @@ -21,6 +21,9 @@ <flag name="ctx=name"> <short>use ctx file (process management specification)</short> </flag> + <flag name="noctx"> + <short>ignore ctx directives and flags</short> + </flag> <flag name="interface"> <short>use specified user interface (default: en)</short> </flag> diff --git a/doc/context/scripts/mkiv/mtx-fonts.html b/doc/context/scripts/mkiv/mtx-fonts.html index 97a16c79a..8afba10b3 100644 --- a/doc/context/scripts/mkiv/mtx-fonts.html +++ b/doc/context/scripts/mkiv/mtx-fonts.html @@ -39,7 +39,8 @@ <table> <tr><th style="width: 10em">flag</th><th style="width: 8em">value</th><th>description</th></tr> <tr><th/><td/><td/></tr> - <tr><th>--save</th><td></td><td>save open type font in raw table</td></tr> + <tr><th>--save</th><td></td><td>save open type font in raw table (ff format)</td></tr> + <tr><th>--convert</th><td></td><td>save open type font in raw table (ctx format)</td></tr> <tr><th>--unpack</th><td></td><td>save a tma file in a more readable format</td></tr> <tr><th/><td/><td/></tr> <tr><th>--reload</th><td></td><td>generate new font database (use --force when in doubt)</td></tr> @@ -55,6 +56,7 @@ <tr><th>--info</th><td></td><td>give more details</td></tr> <tr><th>--trackers</th><td>list</td><td>enable trackers</td></tr> <tr><th>--statistics</th><td></td><td>some info about the database</td></tr> + <tr><th>--names</th><td></td><td>uise name instead of unicodes</td></tr> </table> <br/> <h1>Examples</h1> @@ -71,6 +73,9 @@ <br/><tt>mtxrun --script font --list --file somename</tt> <br/><tt>mtxrun --script font --list --file --all somename</tt> <br/><tt>mtxrun --script font --list --file --pattern=*somename*</tt> +<br/><br/><tt>mtxrun --script font --save --texgyrepagella-regular.otf</tt> +<br/><tt>mtxrun --script font --convert --texgyrepagella-regular.otf</tt> +<br/><tt>mtxrun --script font --convert --names --texgyrepagella-regular.otf</tt> <br/><br/> </div> </div> </body> diff --git a/doc/context/scripts/mkiv/mtx-fonts.man b/doc/context/scripts/mkiv/mtx-fonts.man index c0806a32c..26b591c60 100644 --- a/doc/context/scripts/mkiv/mtx-fonts.man +++ b/doc/context/scripts/mkiv/mtx-fonts.man @@ -12,7 +12,10 @@ .SH OPTIONS .TP .B --save -save open type font in raw table +save open type font in raw table (ff format) +.TP +.B --convert +save open type font in raw table (ctx format) .TP .B --unpack save a tma file in a more readable format @@ -49,6 +52,9 @@ enable trackers .TP .B --statistics some info about the database +.TP +.B --names +uise name instead of unicodes .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-fonts.xml b/doc/context/scripts/mkiv/mtx-fonts.xml index c3c571ca8..696f03c55 100644 --- a/doc/context/scripts/mkiv/mtx-fonts.xml +++ b/doc/context/scripts/mkiv/mtx-fonts.xml @@ -8,7 +8,8 @@ <flags> <category name="basic"> <subcategory> - <flag name="save"><short>save open type font in raw table</short></flag> + <flag name="save"><short>save open type font in raw table (ff format)</short></flag> + <flag name="convert"><short>save open type font in raw table (ctx format)</short></flag> <flag name="unpack"><short>save a tma file in a more readable format</short></flag> </subcategory> <subcategory> @@ -27,6 +28,7 @@ <flag name="info"><short>give more details</short></flag> <flag name="trackers" value="list"><short>enable trackers</short></flag> <flag name="statistics"><short>some info about the database</short></flag> + <flag name="names"><short>uise name instead of unicodes</short></flag> </subcategory> </category> </flags> @@ -54,6 +56,11 @@ <example><command>mtxrun --script font --list --file --all somename</command></example> <example><command>mtxrun --script font --list --file --pattern=*somename*</command></example> </subcategory> + <subcategory> + <example><command>mtxrun --script font --save --texgyrepagella-regular.otf</command></example> + <example><command>mtxrun --script font --convert --texgyrepagella-regular.otf</command></example> + <example><command>mtxrun --script font --convert --names --texgyrepagella-regular.otf</command></example> + </subcategory> </category> </examples> </application> diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index d624f6831..0837a1b50 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -34,7 +34,7 @@ local formatters = string.formatters local application = logs.application { name = "mtx-context", - banner = "ConTeXt Process Management 0.61", + banner = "ConTeXt Process Management 0.62", -- helpinfo = helpinfo, -- table with { category_a = text_1, category_b = text_2 } or helpstring or xml_blob helpinfo = "mtx-context.xml", } @@ -173,7 +173,7 @@ end function ctxrunner.checkfile(ctxdata,ctxname,defaultname) - if not ctxdata.jobname or ctxdata.jobname == "" then + if not ctxdata.jobname or ctxdata.jobname == "" or getargument("noctx") then return end @@ -1600,7 +1600,7 @@ elseif getargument("make") then scripts.context.timed(function() scripts.context.make() end) elseif getargument("generate") then scripts.context.timed(function() scripts.context.generate() end) -elseif getargument("ctx") then +elseif getargument("ctx") and not getargument("noctx") then scripts.context.timed(scripts.context.ctx) -- elseif getargument("mp") or getargument("metapost") then -- scripts.context.timed(scripts.context.metapost) diff --git a/scripts/context/lua/mtx-context.xml b/scripts/context/lua/mtx-context.xml index c41093289..46e586153 100644 --- a/scripts/context/lua/mtx-context.xml +++ b/scripts/context/lua/mtx-context.xml @@ -4,7 +4,7 @@ <metadata> <entry name="name">mtx-context</entry> <entry name="detail">ConTeXt Process Management</entry> - <entry name="version">0.60</entry> + <entry name="version">0.62</entry> <entry name="comment">external helpinfo file</entry> </metadata> <flags> @@ -21,6 +21,9 @@ <flag name="ctx=name"> <short>use ctx file (process management specification)</short> </flag> + <flag name="noctx"> + <short>ignore ctx directives and flags</short> + </flag> <flag name="interface"> <short>use specified user interface (default: en)</short> </flag> diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua index dde145e50..db2f06120 100644 --- a/scripts/context/lua/mtx-fonts.lua +++ b/scripts/context/lua/mtx-fonts.lua @@ -23,7 +23,8 @@ local helpinfo = [[ <flags> <category name="basic"> <subcategory> - <flag name="save"><short>save open type font in raw table</short></flag> + <flag name="save"><short>save open type font in raw table (ff format)</short></flag> + <flag name="convert"><short>save open type font in raw table (ctx format)</short></flag> <flag name="unpack"><short>save a tma file in a more readable format</short></flag> </subcategory> <subcategory> @@ -42,6 +43,7 @@ local helpinfo = [[ <flag name="info"><short>give more details</short></flag> <flag name="trackers" value="list"><short>enable trackers</short></flag> <flag name="statistics"><short>some info about the database</short></flag> + <flag name="names"><short>uise name instead of unicodes</short></flag> </subcategory> </category> </flags> @@ -69,6 +71,11 @@ local helpinfo = [[ <example><command>mtxrun --script font --list --file --all somename</command></example> <example><command>mtxrun --script font --list --file --pattern=*somename*</command></example> </subcategory> + <subcategory> + <example><command>mtxrun --script font --save --texgyrepagella-regular.otf</command></example> + <example><command>mtxrun --script font --convert --texgyrepagella-regular.otf</command></example> + <example><command>mtxrun --script font --convert --names --texgyrepagella-regular.otf</command></example> + </subcategory> </category> </examples> </application> @@ -86,17 +93,31 @@ local report = application.report if not fontloader then fontloader = fontforge end -dofile(resolvers.findfile("font-otr.lua","tex")) -dofile(resolvers.findfile("font-cff.lua","tex")) -dofile(resolvers.findfile("font-ttf.lua","tex")) -dofile(resolvers.findfile("font-tmp.lua","tex")) -------(resolvers.findfile("font-dsp.lua","tex")) -------(resolvers.findfile("font-off.lua","tex")) +local function loadmodule(filename) + local fullname = resolvers.findfile(filename,"tex") + if fullname and fullname ~= "" then + dofile(fullname) + end +end + +-- old loader code + +loadmodule("font-otp.lua") -- we need to unpack the font for analysis + +-- new loader code + +loadmodule("font-otr.lua") +loadmodule("font-cff.lua") +loadmodule("font-ttf.lua") +loadmodule("font-tmp.lua") +loadmodule("font-dsp.lua") -- not yet in distribution +loadmodule("font-oup.lua") -- not yet in distribution -dofile(resolvers.findfile("font-otp.lua","tex")) -- we need to unpack the font for analysis -dofile(resolvers.findfile("font-syn.lua","tex")) -dofile(resolvers.findfile("font-trt.lua","tex")) -dofile(resolvers.findfile("font-mis.lua","tex")) +-- extra code + +loadmodule("font-syn.lua") +loadmodule("font-trt.lua") +loadmodule("font-mis.lua") scripts = scripts or { } scripts.fonts = scripts.fonts or { } @@ -403,13 +424,17 @@ end function scripts.fonts.unpack() local name = file.removesuffix(file.basename(givenfiles[1] or "")) if name and name ~= "" then - local cache = containers.define("fonts", "otf", otfversion, true) + local cache = containers.define("fonts", getargument("cache") or "otf", otfversion, true) -- cache is temp local cleanname = containers.cleanname(name) local data = containers.read(cache,cleanname) if data then local savename = file.addsuffix(cleanname .. "-unpacked","tma") report("fontsave, saving data in %s",savename) - fonts.handlers.otf.enhancers.unpack(data) + if data.creator == "context mkiv" then + fonts.handlers.otf.readers.unpack(data) + else + fonts.handlers.otf.enhancers.unpack(data) + end io.savedata(savename,table.serialize(data,true)) else report("unknown file %a",name) @@ -462,6 +487,36 @@ function scripts.fonts.save() end end +function scripts.fonts.convert() -- new save + local name = givenfiles[1] or "" + local sub = givenfiles[2] or "" + if name and name ~= "" then + local filename = resolvers.findfile(name) -- maybe also search for opentype + if filename and filename ~= "" then + local suffix = string.lower(file.suffix(filename)) + if suffix == 'ttf' or suffix == 'otf' or suffix == 'ttc' then + local data = fonts.handlers.otf.readers.loadfont(filename,sub) + if data then + fonts.handlers.otf.readers.compact(data) + fonts.handlers.otf.readers.rehash(data,getargument("names") and "names" or "unicodes") + local savename = file.replacesuffix(string.lower(data.metadata.fullname or filename),"lua") + table.save(savename,data) + report("font: %a saved as %a",filename,savename) + else + report("font: %a not loaded",filename) + end + else + report("font: %a not saved",filename) + end + else + report("font: %a not found",name) + end + else + report("font: no name given") + end +end + + if getargument("names") then setargument("reload",true) setargument("simple",true) @@ -473,6 +528,8 @@ elseif getargument("reload") then scripts.fonts.reload() elseif getargument("save") then scripts.fonts.save() +elseif getargument("convert") then + scripts.fonts.convert() elseif getargument("justload") then scripts.fonts.justload() elseif getargument("unpack") then diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 19a23ceca..753ce8bbf 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -7964,7 +7964,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 29359, stripped down to: 20483 +-- original size: 29394, stripped down to: 20482 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8453,7 +8453,7 @@ function logs.messenger(category,subcategory) end end end -local function setblocked(category,value) +local function setblocked(category,value) if category==true then category,value="*",true elseif category==false then @@ -8468,7 +8468,7 @@ local function setblocked(category,value) end else states=utilities.parsers.settings_to_hash(category,type(states)=="table" and states or nil) - for c,_ in next,states do + for c in next,states do local v=data[c] if v then v.state=value @@ -18336,8 +18336,8 @@ end -- of closure -- used libraries : l-lua.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-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 trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.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 : 757476 --- stripped bytes : 272592 +-- original bytes : 757511 +-- stripped bytes : 272628 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 19a23ceca..753ce8bbf 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -7964,7 +7964,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 29359, stripped down to: 20483 +-- original size: 29394, stripped down to: 20482 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8453,7 +8453,7 @@ function logs.messenger(category,subcategory) end end end -local function setblocked(category,value) +local function setblocked(category,value) if category==true then category,value="*",true elseif category==false then @@ -8468,7 +8468,7 @@ local function setblocked(category,value) end else states=utilities.parsers.settings_to_hash(category,type(states)=="table" and states or nil) - for c,_ in next,states do + for c in next,states do local v=data[c] if v then v.state=value @@ -18336,8 +18336,8 @@ end -- of closure -- used libraries : l-lua.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-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 trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.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 : 757476 --- stripped bytes : 272592 +-- original bytes : 757511 +-- stripped bytes : 272628 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 19a23ceca..753ce8bbf 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -7964,7 +7964,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 29359, stripped down to: 20483 +-- original size: 29394, stripped down to: 20482 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8453,7 +8453,7 @@ function logs.messenger(category,subcategory) end end end -local function setblocked(category,value) +local function setblocked(category,value) if category==true then category,value="*",true elseif category==false then @@ -8468,7 +8468,7 @@ local function setblocked(category,value) end else states=utilities.parsers.settings_to_hash(category,type(states)=="table" and states or nil) - for c,_ in next,states do + for c in next,states do local v=data[c] if v then v.state=value @@ -18336,8 +18336,8 @@ end -- of closure -- used libraries : l-lua.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-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 trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.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 : 757476 --- stripped bytes : 272592 +-- original bytes : 757511 +-- stripped bytes : 272628 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 19a23ceca..753ce8bbf 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -7964,7 +7964,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 29359, stripped down to: 20483 +-- original size: 29394, stripped down to: 20482 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8453,7 +8453,7 @@ function logs.messenger(category,subcategory) end end end -local function setblocked(category,value) +local function setblocked(category,value) if category==true then category,value="*",true elseif category==false then @@ -8468,7 +8468,7 @@ local function setblocked(category,value) end else states=utilities.parsers.settings_to_hash(category,type(states)=="table" and states or nil) - for c,_ in next,states do + for c in next,states do local v=data[c] if v then v.state=value @@ -18336,8 +18336,8 @@ end -- of closure -- used libraries : l-lua.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-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 trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.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 : 757476 --- stripped bytes : 272592 +-- original bytes : 757511 +-- stripped bytes : 272628 -- end library merge diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 8cd739503..910276a43 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2015.07.01 21:40} +\newcontextversion{2015.07.07 21:43} %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/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 9a613cc88..a1918c9bd 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 2c3cc0eb0..6b47c4a98 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.07.01 21:40} +\edef\contextversion{2015.07.07 21:43} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/font-cff.lua b/tex/context/base/font-cff.lua index c6707ff35..2f0198ece 100644 --- a/tex/context/base/font-cff.lua +++ b/tex/context/base/font-cff.lua @@ -50,7 +50,7 @@ local parsecharstrings local resetcharstrings local parseprivates -local defaultstrings = { [0] = -- hijacked from ff +local defaultstrings = { [0] = -- taken from ff ".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", @@ -1449,8 +1449,8 @@ local function readcharsets(f,data,dictionary) end elseif format == 1 or format == 2 then local readcount = format == 1 and readbyte or readushort - local i = 0 - while i<= nofglyphs do + local i = 1 + while i <= nofglyphs do local sid = readushort(f) local n = readcount(f) for s=sid,sid+n do diff --git a/tex/context/base/font-inj.lua b/tex/context/base/font-inj.lua index 783d67425..62e806f8b 100644 --- a/tex/context/base/font-inj.lua +++ b/tex/context/base/font-inj.lua @@ -146,7 +146,8 @@ end function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) -- hm: nuts or nodes local dx = factor*(exit[1]-entry[1]) local dy = -factor*(exit[2]-entry[2]) - local ws, wn = tfmstart.width, tfmnext.width + local ws = tfmstart.width + local wn = tfmnext.width nofregisteredcursives = nofregisteredcursives + 1 if rlmode < 0 then dx = -(dx + wn) diff --git a/tex/context/base/font-otc.lua b/tex/context/base/font-otc.lua index a3afcd9e1..db8587741 100644 --- a/tex/context/base/font-otc.lua +++ b/tex/context/base/font-otc.lua @@ -6,9 +6,10 @@ if not modules then modules = { } end modules ['font-otc'] = { license = "see context related readme files" } -local format, insert = string.format, table.insert +local format, insert, sortedkeys = string.format, table.insert, table.sortedkeys local type, next = type, next local lpegmatch = lpeg.match +local utfbyte = utf.byte -- we assume that the other otf stuff is loaded already @@ -28,8 +29,10 @@ local setmetatableindex = table.setmetatableindex local types = { substitution = "gsub_single", + single = "gsub_single", ligature = "gsub_ligature", alternate = "gsub_alternate", + multiple = "gsub_multiple", } setmetatableindex(types, function(t,k) t[k] = k return k end) -- "key" @@ -46,7 +49,7 @@ local function addfeature(data,feature,specifications) -- already present else local sequences = resources.sequences - local fontfeatures = resources.features + local fontfeatures = resources.features or everywhere local unicodes = resources.unicodes local lookuptypes = resources.lookuptypes local splitter = lpeg.splitter(" ",unicodes) @@ -182,7 +185,13 @@ otf.enhancers.addfeature = addfeature local extrafeatures = { } function otf.addfeature(name,specification) - extrafeatures[name] = specification + if type(name) == "table" then + specification = name + name = specification.name + end + if type(name) == "string" then + extrafeatures[name] = specification + end end local function enhance(data,filename,raw) @@ -211,6 +220,7 @@ local tlig_specification = { type = "ligature", features = everywhere, data = tlig, + name = "ctx_tlig", order = { "tlig" }, flags = noflags, prepend = true, @@ -235,6 +245,7 @@ local trep_specification = { type = "substitution", features = everywhere, data = trep, + name = "ctx_trep", order = { "trep" }, flags = noflags, prepend = true, diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 28a129cc1..edd9ed2de 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -451,6 +451,7 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone end end if reload then + starttiming("fontloader") report_otf("loading %a, hash %a",filename,hash) local fontdata, messages if sub then @@ -522,7 +523,6 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone tounicodetable = Ct(splitter), }, } - starttiming(data) report_otf("file size: %s", size) enhancers.apply(data,filename,fontdata) local packtime = { } @@ -539,10 +539,10 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone if cleanup > 1 then collectgarbage("collect") end - stoptiming(data) + stoptiming("fontloader") if elapsedtime then -- not in generic - report_otf("preprocessing and caching time %s, packtime %s", - elapsedtime(data),packdata and elapsedtime(packtime) or 0) + report_otf("loading, optimizing, packing and caching time %s, pack time %s", + elapsedtime("fontloader"),packdata and elapsedtime(packtime) or 0) end close_font(fontdata) -- free memory if cleanup > 3 then @@ -553,6 +553,7 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone collectgarbage("collect") end else + stoptiming("fontloader") data = nil report_otf("loading failed due to read error") end diff --git a/tex/context/base/font-otr.lua b/tex/context/base/font-otr.lua index 1b53601a9..ddbe6d271 100644 --- a/tex/context/base/font-otr.lua +++ b/tex/context/base/font-otr.lua @@ -32,10 +32,6 @@ if not modules then modules = { } end modules ['font-otr'] = { -- Optimizing the widths wil be done anyway as it save quite some on a cjk font -- and the existing (old) code if okay. --- todo: duplicates --- todo: markclasses : checking needed (see font-otf) --- --- todo: check all unsigned / signed (will be done last) -- todo: more messages (only if really needed) -- -- todo (in old loader and new one) math: @@ -47,19 +43,36 @@ if not modules then modules = { } end modules ['font-otr'] = { -- vert_variants -> vvariants -> next in tex, so better 'sizes' -- horiz_variants -> hvariants -> next in tex, so better 'sizes' -- +-- considered, in math: +-- -- start -> first (so we can skip the first same-size one) -- end -> last -- --- We can optimize kern pairs (i.e. simple h only positioning) later if we want --- which is easier as then we know if we have clashes between features. We can have --- kerns as well as moves (smaller files) --- -- Widths and weights are kind of messy: for instance lmmonolt has a pfmweight of -- 400 while it should be 300. So, for now we mostly stick to the old compromis. -- We don't really need all those language tables so they might be dropped some -- day. +-- The new reader is faster on some aspects and slower on other. The memory footprint +-- is lower. The string reader is a bit faster than the file reader. The new reader +-- gives more efficient tables and has bit more analysis. In practice these times are +-- not that relevant because we cache. The otf files take a it more time because we +-- need to calculate the boundingboxes. In theory the processing of text should be +-- somewhat faster especially for complex fonts with many lookups. +-- +-- old new str reader +-- lmroman12-regular.otf 0.103 0.203 0.195 +-- latinmodern-math.otf 0.454 0.768 0.712 +-- husayni.ttf 1.142 1.526 1.259 +-- +-- If there is demand I will consider making a ff compatible table dumper but it's +-- probably more fun to provide a way to show features applied. + +-- I experimented a bit with f:readbyte(n) and f:readshort() and so and it is indeed +-- faster but it might not be the real bottleneck as we still need to juggle data. It +-- is probably more memory efficient as no intermediate strings are involved. + if not characters then require("char-def") require("char-ini") @@ -90,7 +103,7 @@ handlers.otf = otf local readers = otf.readers or { } otf.readers = readers --- local streamreader = utilities.streams -- faster on big files +----- streamreader = utilities.streams -- faster on big files local streamreader = utilities.files -- faster on identify readers.streamreader = streamreader @@ -130,6 +143,8 @@ end local tableversion = 0.001 local privateoffset = fonts.constructors and fonts.constructors.privateoffset or 0xF0000 -- 0x10FFFF +readers.tableversion = tableversion + local reportedskipped = { } local function reportskippedtable(tag) @@ -585,7 +600,7 @@ local languages = { }, } -local standardromanencoding = { [0] = -- hijacked from wikipedia +local standardromanencoding = { [0] = -- taken from wikipedia "notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", @@ -898,11 +913,10 @@ readers.head = function(f,fontdata) glyphformat = readshort(f), } fontdata.fontheader = fontheader - fontdata.nofglyphs = 0 else fontdata.fontheader = { } - fontdata.nofglyphs = 0 end + fontdata.nofglyphs = 0 end -- This table is a rather simple one. No treatment of values is needed here. Most @@ -940,9 +954,8 @@ readers.hhea = function(f,fontdata,specification) end end --- We probably never need all these variables, but we do need the nofglyphs --- when loading other tables. Again we use the microsoft names but see no reason --- to have "max" in each name. +-- We probably never need all these variables, but we do need the nofglyphs when loading other +-- tables. Again we use the microsoft names but see no reason to have "max" in each name. -- fontdata.maximumprofile can be bad @@ -988,8 +1001,8 @@ readers.maxp = function(f,fontdata,specification) end end --- Here we filter the (advance) widths (that can be different from the boundingbox --- width of course). +-- Here we filter the (advance) widths (that can be different from the boundingbox width of +-- course). readers.hmtx = function(f,fontdata,specification) if specification.glyphs then @@ -1028,10 +1041,9 @@ readers.hmtx = function(f,fontdata,specification) end end --- The post table relates to postscript (printing) but has some relevant --- properties for other usage as well. We just use the names from the microsoft --- specification. The version 2.0 description is somewhat fuzzy but it is a --- hybrid with overloads. +-- The post table relates to postscript (printing) but has some relevant properties for other +-- usage as well. We just use the names from the microsoft specification. The version 2.0 +-- description is somewhat fuzzy but it is a hybrid with overloads. readers.post = function(f,fontdata,specification) local datatable = fontdata.tables.post @@ -1103,9 +1115,10 @@ readers.cff = function(f,fontdata,specification) end end --- Not all cmaps make sense .. e.g. dfont is obsolete and probably more are not --- relevant. Let's see what we run into. There is some weird calculation going --- on here because we offset in a table being a blob of memory or file. +-- Not all cmaps make sense .. e.g. dfont is obsolete and probably more are not relevant. Let's see +-- what we run into. There is some weird calculation going on here because we offset in a table +-- being a blob of memory or file. Anyway, I can't stand lunatic formats like this esp when there +-- is no real gain. local formatreaders = { } @@ -1129,7 +1142,7 @@ formatreaders[4] = function(f,fontdata,offset) for i=1,nofsegments do endchars[i] = readushort(f) end - local reserved = readushort(f) + local reserved = readushort(f) -- 0 for i=1,nofsegments do startchars[i] = readushort(f) end @@ -1153,31 +1166,34 @@ formatreaders[4] = function(f,fontdata,offset) if startchar == 0xFFFF and endchar == 0xFFFF then break elseif offset == 0 then - for char=startchar,endchar do - local unicode = char - local index = mod(char + delta,65536) + for unicode=startchar,endchar do + index = mod(unicode + delta,65536) if index and index > 0 then local glyph = glyphs[index] - if not glyph.unicode then - glyph.unicode = unicode + if glyph then + if not glyph.unicode then + glyph.unicode = unicode + end + mapping[index] = unicode + -- report("case 1: %C %04i %s",unicode,index,glyphs[index].name) end - mapping[index] = unicode - -- report("%C %04i %05i %s",unicode,index,glyphs[index].name) end end else local shift = (segment-nofsegments+offset/2) - startchar - for char=startchar,endchar do - local unicode = mod(char + delta,65536) - local slot = shift + char - local index = indices[slot] + for unicode=startchar,endchar do + local slot = shift + unicode + local index = indices[slot] if index and index > 0 then + index = mod(index + delta,65536) local glyph = glyphs[index] - if not glyph.unicode then - glyph.unicode = unicode + if glyph then + if not glyph.unicode then + glyph.unicode = unicode + end + mapping[index] = unicode + -- report("case 2: %C %04i %s",unicode,index,glyphs[index].name) end - mapping[index] = unicode - -- report("%C %04i %05i %s",unicode,index,glyphs[index].name) end end end @@ -1349,10 +1365,10 @@ function readers.cmap(f,fontdata,specification) -- checkcmap(f,fontdata,records,0, 3, 4) -- checkcmap(f,fontdata,records,1, 0, 6) checkcmap(f,fontdata,records,0, 5,14) --- variantcid = records[0] and records[0][5] --- if variantcid then --- formatreaders[14](f,fontdata,offset,variantcid[14]) --- end + -- variantcid = records[0] and records[0][5] + -- if variantcid then + -- formatreaders[14](f,fontdata,offset,variantcid[14]) + -- end -- fontdata.cidmaps = { version = version, @@ -1365,11 +1381,9 @@ function readers.cmap(f,fontdata,specification) end end --- The glyf table depends on the loca table. We have one entry to much --- in the locations table (the last one is a dummy) because we need to --- calculate the size of a glyph blob from the delta, although we not --- need it in our usage (yet). We can remove the locations table when --- we're done (todo: cleanup finalizer). +-- The glyf table depends on the loca table. We have one entry to much in the locations table (the +-- last one is a dummy) because we need to calculate the size of a glyph blob from the delta, +-- although we not need it in our usage (yet). We can remove the locations table when we're done. function readers.loca(f,fontdata,specification) if specification.glyphs then @@ -1383,9 +1397,8 @@ function readers.glyf(f,fontdata,specification) -- part goes to cff module end end --- Here we have a table that we really need for later processing although a more --- advanced gpos table can also be available. Todo: we need a 'fake' lookup for --- this (analogue to ff). +-- Here we have a table that we really need for later processing although a more advanced gpos table +-- can also be available. Todo: we need a 'fake' lookup for this (analogue to ff). function readers.kern(f,fontdata,specification) if specification.kerns then @@ -1514,7 +1527,7 @@ local function packoutlines(data,makesequence) for i=1,#segments do local segment = segments[i] local h = concat(segment," ") - if hash[h] > 1 then + if hash[h] > 1 then -- minimal one shared in order to hash local idx = reverse[h] if not idx then last = last + 1 @@ -1866,39 +1879,32 @@ function readers.loadfont(filename,n) -- return { tableversion = tableversion, - -- cache_uuid = false, -- only when cached - -- cache_version = false, -- only when cached + creator = "context mkiv", size = fontdata.filesize, time = fontdata.filetime, - -- warnings = { }, glyphs = fontdata.glyphs, descriptions = fontdata.descriptions, format = fontdata.format, goodies = { }, - -- lookups = { }, metadata = getinfo(fontdata,n), properties = { hasitalics = fontdata.hasitalics or false, }, resources = { - -- anchor_to_lookup = fontdata.anchor_to_lookup or { }, - creator = "context mkiv", - duplicates = { }, -- todo - features = fontdata.features, - filename = fontdata.filename, - -- lookup_to_anchor = fontdata.lookup_to_anchor or { }, - sublookups = fontdata.sublookups, - subtables = fontdata.subtables, - -- lookuptags = { }, -- will be metatable using offsets: gsub-1, gpos-1 etc - lookuptypes = fontdata.lookuptypes or { }, - marks = fontdata.marks or { }, - markclasses = fontdata.markclasses or { }, - marksets = fontdata.marksets or { }, - private = privateoffset, - sequences = fontdata.sequences, - variants = fontdata.variants, -- variant -> unicode -> glyph - version = getname(fontdata,"version"), - cidinfo = fontdata.cidinfo, + duplicates = { }, -- todo + features = fontdata.features, + filename = fontdata.filename, + sublookups = fontdata.sublookups, + subtables = fontdata.subtables, + marks = fontdata.marks or { }, + markclasses = fontdata.markclasses or { }, + marksets = fontdata.marksets or { }, + private = privateoffset, + sequences = fontdata.sequences, + variants = fontdata.variants, -- variant -> unicode -> glyph + version = getname(fontdata,"version"), + cidinfo = fontdata.cidinfo, + mathconstants = fontdata.mathconstants, }, } end @@ -1955,6 +1961,10 @@ function readers.expand(fontdata) report("the %a helper is not yet implemented","unpack") end +function readers.compact(fontdata) + report("the %a helper is not yet implemented","compact") +end + -- if fonts.hashes then diff --git a/tex/context/base/lang-hyp.mkiv b/tex/context/base/lang-hyp.mkiv index 927f5a057..329837c76 100644 --- a/tex/context/base/lang-hyp.mkiv +++ b/tex/context/base/lang-hyp.mkiv @@ -129,6 +129,11 @@ \unexpanded\def\sethyphenationfeatures[#1]% {\clf_sethyphenationfeatures{#1}} +\unexpanded\def\resethyphenationfeatures + {\hyphenationattribute\attributeunsetvalue} + +\resethyphenationfeatures + % todo: \start ... \stop too \unexpanded\def\registerhyphenationpattern diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv index 4a6d530db..fc8a4fdbd 100644 --- a/tex/context/base/lxml-ini.mkiv +++ b/tex/context/base/lxml-ini.mkiv @@ -177,6 +177,11 @@ \def\xmlinfo #1{\hbox{\ttxx[\clf_xmlinfo{#1}]}} \def\xmlshow #1{\startpacked\ttx\xmlverbatim{#1}\stoppacked} +% the next one is handy for mode runs because it enforces a consistent +% #1 indexing (needed when using \xmltext{main:123}{...} like calls + +\let\xmladdindex \clf_xmladdindex + % we need to pass the last argument as function, so \def\xmlsetfunction#1#2#3{\ctxcommand{xmlsetfunction("#1",\!!bs#2\!!es,#3)}} diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index 5b4b16184..48e75e9c1 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -354,6 +354,12 @@ end lxml.addindex = addindex +implement { + name = "xmladdindex", + arguments = { "string" }, + actions = addindex, +} + -- another cache local function lxmlapplylpath(id,pattern) -- better inline, saves call @@ -1214,7 +1220,7 @@ local function command(collected,cmd,otherwise) local ix = e.ix local name = e.name if name and not ix then - lxml.addindex(name,false,true) + addindex(name,false,true) ix = e.ix end if not ix or not name then diff --git a/tex/context/base/math-fbk.lua b/tex/context/base/math-fbk.lua index ab3a726d1..564ece8d7 100644 --- a/tex/context/base/math-fbk.lua +++ b/tex/context/base/math-fbk.lua @@ -338,7 +338,7 @@ local function accent_to_extensible(target,newchr,original,oldchr,height,depth,s local addprivate = fonts.helpers.addprivate if swap then swap = characters[swap] - height = swap.depth + height = swap.depth or 0 depth = 0 else height = height or 0 diff --git a/tex/context/base/math-frc.mkiv b/tex/context/base/math-frc.mkiv index cbe342b66..bbee610eb 100644 --- a/tex/context/base/math-frc.mkiv +++ b/tex/context/base/math-frc.mkiv @@ -326,14 +326,13 @@ }% }\endgroup} -\unexpanded\def\xfrac {\begingroup\let\xfrac\xxfrac\math_frac_alternative\scriptstyle} -\unexpanded\def\xxfrac{\begingroup \math_frac_alternative\scriptscriptstyle} -%D The \type {xx} variant looks still ugly, so maybe it's best to say: +\definemathfraction[xfrac] [\c!alternative=\v!inner,\c!mathstyle=\s!script] +\definemathfraction[xxfrac][\c!alternative=\v!inner,\c!mathstyle=\s!scriptscript] -\unexpanded\def\xxfrac#1#2% - {\begingroup - \math_frac_alternative\scriptscriptstyle{#1}{\raise.25\exheight\hbox{$\scriptscriptstyle#2$}}} +\let\normalxfrac\xfrac + +\unexpanded\def\xfrac#1#2{\normalxfrac{\let\xfrac\xxfrac#1}{\let\xfrac\xxfrac#2}} %D Spacing: diff --git a/tex/context/base/meta-imp-outlines.mkiv b/tex/context/base/meta-imp-outlines.mkiv index ceecb9bbe..0f3d1875d 100644 --- a/tex/context/base/meta-imp-outlines.mkiv +++ b/tex/context/base/meta-imp-outlines.mkiv @@ -157,8 +157,11 @@ end \starttext -\setupbodyfont[pagella] -\showshape[character=all,alternative=page] +% \setupbodyfont[pagella] +% \showshape[character=3,alternative=page] + +% \setupbodyfont[pagella] +% \showshape[character=all,alternative=page] % \setupbodyfont[dejavu] % \showshape[character=P,alternative=text] diff --git a/tex/context/base/mtx-context-listing.tex b/tex/context/base/mtx-context-listing.tex index 583aa2b8f..2deffd795 100644 --- a/tex/context/base/mtx-context-listing.tex +++ b/tex/context/base/mtx-context-listing.tex @@ -24,7 +24,8 @@ % --scite : pretty print comform suffix using scite lexer % --bodyfont=list : additional bodyfont settings % --paperformat=spec : paper*print or paperxprint -% --compact : small margins, small font +% --compact : small margins, 8pt font +% --verycompact : small margins, 7pt font % % end help @@ -36,6 +37,12 @@ \setdocumentargument{bodyfont} {8pt} } +\doifdocumentargument {verycompact} { + \setdocumentargument{topspace} {5mm} + \setdocumentargument{backspace}{5mm} + \setdocumentargument{bodyfont} {7pt} +} + \setupbodyfont [dejavu,11pt,tt,\getdocumentargument{bodyfont}] % dejavu is more complete diff --git a/tex/context/base/node-nut.lua b/tex/context/base/node-nut.lua index b133c4e74..fb30ff0dc 100644 --- a/tex/context/base/node-nut.lua +++ b/tex/context/base/node-nut.lua @@ -700,14 +700,21 @@ if propertydata then end nuts.setprop = function(n,k,v) - if v then - local p = propertydata[n] - if p then - p[k] = v - else - propertydata[n] = { [k] = v } - end + local p = propertydata[n] + if p then + p[k] = v + else + propertydata[n] = { [k] = v } + end + end + + nuts.theprop = function(n) + local p = propertydata[n] + if not p then + p = { } + propertydata[n] = p end + return p end nodes.setprop = nodes.setproperty diff --git a/tex/context/base/page-mix.lua b/tex/context/base/page-mix.lua index 61a4f944d..806632881 100644 --- a/tex/context/base/page-mix.lua +++ b/tex/context/base/page-mix.lua @@ -63,6 +63,8 @@ local setbox = nuts.setbox local getskip = nuts.getskip local getattribute = nuts.getattribute +local theprop = nuts.theprop + local nodepool = nuts.pool local new_hlist = nodepool.hlist @@ -272,6 +274,7 @@ local function preparesplit(specification) -- a rather large function if specification.balance ~= v_yes then optimal = maxheight end + local topback = 0 local target = optimal + extra local overflow = target > maxheight - preheight local threshold = specification.threshold or 0 @@ -291,6 +294,7 @@ local function preparesplit(specification) -- a rather large function depth = 0, inserts = { }, delta = 0, + back = 0, } end @@ -611,7 +615,6 @@ end line = line + 1 local inserts, currentskips, nextskips, inserttotal = nil, 0, 0, 0 local advance = getfield(current,"height") --- + getfield(current,"depth") -- when > strutdp if trace_state then report_state("%-7s > column %s, content: %s","line",column,listtoutf(getlist(current),true,true)) end @@ -628,6 +631,23 @@ end if state == "quit" then return true end +-- if state == "next" then -- only when profile +-- local unprofiled = theprop(current).unprofiled +-- if unprofiled then +-- local h = unprofiled.height +-- local s = unprofiled.strutht +-- local t = s/2 +-- print("profiled",h,s) +-- local snapped = theprop(current).snapped +-- if snapped then +-- inspect(snapped) +-- end +-- if h < s + t then +-- result.back = - (h - s) +-- advance = s +-- end +-- end +-- end height = height + depth + skip + advance + inserttotal if state == "next" then height = height + nextskips @@ -742,6 +762,13 @@ local function finalize(result) local h = r.head if h then setfield(h,"prev",nil) +if r.back then + local k = new_glue(r.back) + setfield(h,"prev",k) + setfield(k,"next",h) + h = k + r.head = h +end local t = r.tail if t then setfield(t,"next",nil) diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua index c48c79c42..18b04f3fc 100644 --- a/tex/context/base/spac-ver.lua +++ b/tex/context/base/spac-ver.lua @@ -38,20 +38,20 @@ local formatters = string.formatters local P, C, R, S, Cc = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc -local nodes = nodes -local node = node -local trackers = trackers -local attributes = attributes -local context = context -local tex = tex +local nodes = nodes +local node = node +local trackers = trackers +local attributes = attributes +local context = context +local tex = tex -local texlists = tex.lists -local texgetdimen = tex.getdimen -local texsetdimen = tex.setdimen -local texnest = tex.nest +local texlists = tex.lists +local texgetdimen = tex.getdimen +local texsetdimen = tex.setdimen +local texnest = tex.nest -local variables = interfaces.variables -local implement = interfaces.implement +local variables = interfaces.variables +local implement = interfaces.implement -- vertical space handler @@ -108,6 +108,8 @@ local vpack_node = nuts.vpack local writable_spec = nuts.writable_spec local nodereference = nuts.reference +local theprop = nuts.theprop + local listtoutf = nodes.listtoutf local nodeidstostring = nodes.idstostring @@ -116,7 +118,6 @@ local nodepool = nuts.pool local new_penalty = nodepool.penalty local new_kern = nodepool.kern local new_rule = nodepool.rule -local new_glue = nodepool.glue local new_gluespec = nodepool.gluespec local nodecodes = nodes.nodecodes @@ -308,7 +309,18 @@ end -- check variables.none etc +local function fixedprofile(current) + if builders.profiling then + return builders.profiling.fixedprofile(current) + else + return false + end +end + local function snap_hlist(where,current,method,height,depth) -- method.strut is default + if fixedprofile(current) then + return + end local list = getlist(current) local t = trace_vsnapping and { } if t then @@ -360,6 +372,17 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is local plusdp = snapdp local snaphtdp = snapht + snapdp +-- local properties = theprop(current) +-- local unsnapped = properties.unsnapped +-- if not unsnapped then -- experiment +-- properties.unsnapped = { +-- height = h, +-- depth = d, +-- snapht = snapht, +-- snapdp = snapdp, +-- } +-- end + if method.box then local br = 1 - br if br < 0 then diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 6c0039c43..2c3b549c4 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 4aea7255e..0fee76e32 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua index 029d68a9d..3019c7a66 100644 --- a/tex/context/base/strc-doc.lua +++ b/tex/context/base/strc-doc.lua @@ -115,6 +115,10 @@ end -- -- -- sections -- -- -- +-- This is just a quick way to have access to prefixes and the numbers (section entry in a ref) +-- is not the list entry. An alternative is to use the list index of the last numbered section. In +-- that case we should check a buse of the current structure. + local collected = allocate() local tobesaved = allocate() diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua index d998295c1..224c8de22 100644 --- a/tex/context/base/trac-deb.lua +++ b/tex/context/base/trac-deb.lua @@ -104,13 +104,10 @@ end local savedluaerror = nil local function errorreporter(luaerror) - if luaerror then - logs.enable("lua error") -- - return logs.reporter("lua error") - else - logs.enable("tex error") - return logs.reporter("tex error") - end + local category = luaerror and "lua error" or "tex error" + local report = logs.reporter(category) + logs.enable(category) + return report end function tracers.showlines(filename,linenumber,offset,luaerrorline) @@ -185,7 +182,6 @@ local function processerror(offset) local lasttexerror = status.lasterrorstring or "?" local lastluaerror = status.lastluaerrorstring or lasttexerror local luaerrorline = match(lastluaerror,[[lua%]?:.-(%d+)]]) or (lastluaerror and find(lastluaerror,"?:0:",1,true) and 0) - local report = errorreporter(luaerrorline) tracers.printerror { filename = filename, linenumber = linenumber, @@ -213,10 +209,10 @@ function tracers.printerror(specification) else report_nl() if luaerrorline then - report("error on line %s in file %s:\n\n%s",linenumber,filename,lastluaerror) + report("lua error on line %s in file %s:\n\n%s",linenumber,filename,lastluaerror) -- report("error on line %s in file %s:\n\n%s",linenumber,filename,lasttexerror) else - report("error on line %s in file %s: %s",linenumber,filename,lasttexerror) + report("tex error on line %s in file %s: %s",linenumber,filename,lasttexerror) if tex.show_context then report_nl() tex.show_context() diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua index ce620e6cf..1e91fc404 100644 --- a/tex/context/base/trac-log.lua +++ b/tex/context/base/trac-log.lua @@ -626,7 +626,7 @@ end -- so far -local function setblocked(category,value) +local function setblocked(category,value) -- v.state == value == true : disable if category == true then -- lock all category, value = "*", true @@ -644,7 +644,7 @@ local function setblocked(category,value) end else states = utilities.parsers.settings_to_hash(category,type(states)=="table" and states or nil) - for c, _ in next, states do + for c in next, states do local v = data[c] if v then v.state = value diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 6597ca93c..c0ad6bda9 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 07/01/15 21:40:12 +-- merge date : 07/07/15 21:43:15 do -- begin closure to overcome local limits and interference @@ -7428,6 +7428,7 @@ function otf.load(filename,sub,featurefile) end end if reload then + starttiming("fontloader") report_otf("loading %a, hash %a",filename,hash) local fontdata,messages if sub then @@ -7489,7 +7490,6 @@ function otf.load(filename,sub,featurefile) tounicodetable=Ct(splitter), }, } - starttiming(data) report_otf("file size: %s",size) enhancers.apply(data,filename,fontdata) local packtime={} @@ -7506,10 +7506,10 @@ function otf.load(filename,sub,featurefile) if cleanup>1 then collectgarbage("collect") end - stoptiming(data) + stoptiming("fontloader") if elapsedtime then - report_otf("preprocessing and caching time %s, packtime %s", - elapsedtime(data),packdata and elapsedtime(packtime) or 0) + report_otf("loading, optimizing, packing and caching time %s, pack time %s", + elapsedtime("fontloader"),packdata and elapsedtime(packtime) or 0) end close_font(fontdata) if cleanup>3 then @@ -7520,6 +7520,7 @@ function otf.load(filename,sub,featurefile) collectgarbage("collect") end else + stoptiming("fontloader") data=nil report_otf("loading failed due to read error") end |