From e486991f986cb96e6ef5f5b03f83494f16cb2acb Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 23 Mar 2013 15:20:14 +0200 Subject: beta 2013.03.23 14:11 --- tex/context/base/bibl-tra.mkiv | 13 +++-- tex/context/base/cldf-bas.lua | 4 ++ tex/context/base/cldf-ini.lua | 72 +++++++++++++++++------ tex/context/base/colo-ini.mkiv | 2 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4129 -> 4135 bytes tex/context/base/context-version.png | Bin 40393 -> 40244 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 4 +- tex/context/base/lang-frd.mkiv | 2 + tex/context/base/lang-frq-de.lua | 12 ++++ tex/context/base/lang-frq-en.lua | 26 +++++++++ tex/context/base/lang-frq-nl.lua | 12 ++++ tex/context/base/lang-frq.mkiv | 2 + tex/context/base/s-lan-06.mkiv | 53 +++++++++++++++++ tex/context/base/sort-ini.lua | 8 ++- tex/context/base/status-files.pdf | Bin 24805 -> 24759 bytes tex/context/base/status-lua.pdf | Bin 211450 -> 211620 bytes tex/context/base/status-mkiv.lua | 16 ++++++ tex/context/base/trac-log.lua | 107 ++++++++++++++++++----------------- tex/context/base/trac-xml.lua | 14 ++--- tex/context/base/typo-lan.lua | 72 +++++++++++++++++++++++ tex/context/base/typo-lan.mkiv | 63 +++++++++++++++++++++ tex/context/base/typo-spa.lua | 6 +- 25 files changed, 401 insertions(+), 93 deletions(-) create mode 100644 tex/context/base/lang-frq-de.lua create mode 100644 tex/context/base/lang-frq-en.lua create mode 100644 tex/context/base/lang-frq-nl.lua create mode 100644 tex/context/base/s-lan-06.mkiv create mode 100644 tex/context/base/typo-lan.lua create mode 100644 tex/context/base/typo-lan.mkiv (limited to 'tex/context') diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv index 188313165..f454f5185 100644 --- a/tex/context/base/bibl-tra.mkiv +++ b/tex/context/base/bibl-tra.mkiv @@ -1268,12 +1268,15 @@ \expandafter\secondoftwoarguments \fi} +% \unexpanded\def\bibmaybeinteractive#1#2% +% {\ifbibcitecompress +% #2% +% \else +% \doifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}% +% \fi} + \unexpanded\def\bibmaybeinteractive#1#2% - {\ifbibcitecompress - #2% - \else - \doifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}% - \fi} + {\doifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}} \unexpanded\def\bibauthoryearref[#1]% {\ixbibauthoryear{#1}% diff --git a/tex/context/base/cldf-bas.lua b/tex/context/base/cldf-bas.lua index 9cf8dcd4a..298b374f0 100644 --- a/tex/context/base/cldf-bas.lua +++ b/tex/context/base/cldf-bas.lua @@ -71,6 +71,10 @@ function context.egroup() context("}") end +function context.space() + context(" ") +end + function context.hrule(w,h,d,dir) if type(w) == "table" then context(new_rule(w.width,w.height,w.depth,w.dir)) diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua index df203b01e..4a7d9f025 100644 --- a/tex/context/base/cldf-ini.lua +++ b/tex/context/base/cldf-ini.lua @@ -622,24 +622,6 @@ function tex.fprint(fmt,first,...) -- goodie end end --- function context.formatted(catcodes,fmt,first,...) -- no longer to be used ... context(...) now uses formatted --- if type(catcodes) == "number" then -- and this was just a temporary helper that will go away --- if first then --- flush(catcodes,formatters[fmt](first,...)) --- else --- flush(catcodes,fmt) --- end --- else --- if fmt then --- flush(formatters[catcodes](fmt,first,...)) --- else --- flush(catcodes) --- end --- end --- end - -context.formatted = context.fprint - -- logging local trace_stack = { } @@ -944,6 +926,60 @@ end setmetatable(verbatim, { __index = indexer, __call = caller } ) +-- formatted + +local formatted = { } context.formatted = formatted + +-- local function indexer(parent,k) +-- local command = context[k] +-- local f = function(fmt,...) +-- command(formatters[fmt](...)) +-- end +-- parent[k] = f +-- return f +-- end + +local function indexer(parent,k) + if type(k) == "string" then + local c = "\\" .. tostring(generics[k] or k) + local f = function(first,second,...) + if first == nil then + flush(currentcatcodes,c) + elseif second then + return writer(parent,c,formatters[first](second,...)) + else + return writer(parent,c,first) + end + end + parent[k] = f + return f + else + return context -- catch + end +end + +-- local function caller(parent,...) +-- context.fprint(...) +-- end + +local function caller(parent,catcodes,fmt,first,...) + if type(catcodes) == "number" then + if first then + flush(catcodes,formatters[fmt](first,...)) + else + flush(catcodes,fmt) + end + else + if fmt then + flush(formatters[catcodes](fmt,first,...)) + else + flush(catcodes) + end + end +end + +setmetatable(formatted, { __index = indexer, __call = caller } ) + -- metafun (this will move to another file) local metafun = { } context.metafun = metafun diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 6b82f592d..7052bf6c9 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -756,7 +756,7 @@ {\ctxcommand{defineintermediatecolor("#1","#2", \thecolorattribute{#3},\thecolorattribute{#4}, \thetransparencyattribute{#3},\thetransparencyattribute{#4}, - "#5",false,\iffreezecolors true\else false\fi)}% not global + "#5",false,\v_colo_freeze_state)}% not global \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} %D Here is a more efficient helper for pgf: diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 2ad5a63e6..3384373c5 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.03.22 22:21} +\newcontextversion{2013.03.23 14:11} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 818845c7d..4855e0cd8 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{2013.03.22 22:21} +\newcontextversion{2013.03.23 14:11} %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 index cfa0f7218..9f7c0a4be 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index 3e28b44b8..5949427cc 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index c41e6374e..a9072da32 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2013.03.22 22:21} +\edef\contextversion{2013.03.23 14:11} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 5386f68b2..ee83bd0ed 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.03.22 22:21} +\edef\contextversion{2013.03.23 14:11} %D For those who want to use this: @@ -361,6 +361,8 @@ \loadmkvifile{font-gds} \loadmkvifile{font-aux} +\loadmarkfile{typo-lan} + \loadmarkfile{lxml-css} \loadmarkfile{spac-chr} % depends on fonts diff --git a/tex/context/base/lang-frd.mkiv b/tex/context/base/lang-frd.mkiv index 716ff257d..352e5016d 100644 --- a/tex/context/base/lang-frd.mkiv +++ b/tex/context/base/lang-frd.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +\endinput + %D This is experimental work! Old stuff, whenever I need it I might %D do it in \LUA. diff --git a/tex/context/base/lang-frq-de.lua b/tex/context/base/lang-frq-de.lua new file mode 100644 index 000000000..3733f39f9 --- /dev/null +++ b/tex/context/base/lang-frq-de.lua @@ -0,0 +1,12 @@ +return { + language = "de", + source = "http://www.blankenburg.de/gat/pages/fach/info/analyse2.htm", + frequencies = { + [0x0061] = 6.47, [0x0062] = 1.93, [0x0063] = 2.68, [0x0064] = 4.83, [0x0065] = 17.48, + [0x0066] = 1.65, [0x0067] = 3.06, [0x0068] = 4.23, [0x0069] = 7.73, [0x006A] = 0.27, + [0x006B] = 1.46, [0x006C] = 3.49, [0x006D] = 2.58, [0x006E] = 9.84, [0x006F] = 2.98, + [0x0070] = 0.96, [0x0071] = 0.02, [0x0072] = 7.54, [0x0073] = 6.83, [0x0074] = 6.13, + [0x0075] = 4.17, [0x0076] = 0.94, [0x0077] = 1.48, [0x0078] = 0.04, [0x0079] = 0.08, + [0x007A] = 1.14, + } +} diff --git a/tex/context/base/lang-frq-en.lua b/tex/context/base/lang-frq-en.lua new file mode 100644 index 000000000..9e18d7166 --- /dev/null +++ b/tex/context/base/lang-frq-en.lua @@ -0,0 +1,26 @@ +-- return { +-- language = "en", +-- source = "http://caislab.icu.ac.kr/course/2001/spring/ice605/down/010306.pdf", +-- frequencies = { +-- [0x0061] = 8.2, [0x0062] = 1.5, [0x0063] = 2.8, [0x0064] = 4.3, [0x0065] = 12.7, +-- [0x0066] = 2.2, [0x0067] = 2.0, [0x0068] = 6.1, [0x0069] = 7.0, [0x006A] = 0.2, +-- [0x006B] = 0.8, [0x006C] = 4.0, [0x006D] = 2.4, [0x006E] = 6.7, [0x006F] = 7.5, +-- [0x0070] = 1.9, [0x0071] = 0.1, [0x0072] = 6.0, [0x0073] = 6.3, [0x0074] = 9.1, +-- [0x0075] = 2.8, [0x0076] = 1.0, [0x0077] = 2.3, [0x0078] = 0.1, [0x0079] = 2.0, +-- [0x007A] = 0.1, +-- } +-- } + +return { + language = "en", + source = "http://www.blankenburg.de/gat/pages/fach/info/analyse2.htm", + frequencies = { + [0x0061] = 8.04, [0x0062] = 1.54, [0x0063] = 3.06, [0x0064] = 3.99, [0x0065] = 12.51, + [0x0066] = 2.30, [0x0067] = 1.96, [0x0068] = 5.49, [0x0069] = 7.26, [0x006A] = 0.16, + [0x006B] = 0.67, [0x006C] = 4.14, [0x006D] = 2.53, [0x006E] = 7.09, [0x006F] = 7.60, + [0x0070] = 2.00, [0x0071] = 0.11, [0x0072] = 6.12, [0x0073] = 6.54, [0x0074] = 9.25, + [0x0075] = 2.71, [0x0076] = 0.99, [0x0077] = 1.92, [0x0078] = 0.19, [0x0079] = 1.73, + [0x007A] = 0.09, + } +} + diff --git a/tex/context/base/lang-frq-nl.lua b/tex/context/base/lang-frq-nl.lua new file mode 100644 index 000000000..7b640b779 --- /dev/null +++ b/tex/context/base/lang-frq-nl.lua @@ -0,0 +1,12 @@ +return { + language = "nl", + source = "http://www.onzetaal.nl/advies/letterfreq.html", + frequencies = { + [0x0061] = 7.47, [0x0062] = 1.58, [0x0063] = 1.24, [0x0064] = 5.93, [0x0065] = 18.91, + [0x0066] = 0.81, [0x0067] = 3.40, [0x0068] = 2.38, [0x0069] = 6.50, [0x006A] = 1.46, + [0x006B] = 2.25, [0x006C] = 3.57, [0x006D] = 2.21, [0x006E] = 10.03, [0x006F] = 6.06, + [0x0070] = 1.57, [0x0071] = 0.009, [0x0072] = 6.41, [0x0073] = 3.73, [0x0074] = 6.79, + [0x0075] = 1.99, [0x0076] = 2.85, [0x0077] = 1.52, [0x0078] = 0.04, [0x0079] = 0.035, + [0x007A] = 1.39, + } +} diff --git a/tex/context/base/lang-frq.mkiv b/tex/context/base/lang-frq.mkiv index 24f535296..eaa93281a 100644 --- a/tex/context/base/lang-frq.mkiv +++ b/tex/context/base/lang-frq.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +\endinput + \writestatus{loading}{ConTeXt Language Macros / Frequency Tables} %D Some day I might redo this \LUA. But anyway, who uses it. It's rather diff --git a/tex/context/base/s-lan-06.mkiv b/tex/context/base/s-lan-06.mkiv new file mode 100644 index 000000000..43d59a2d1 --- /dev/null +++ b/tex/context/base/s-lan-06.mkiv @@ -0,0 +1,53 @@ +%D \module +%D [ file=s-lan-06, +%D version=2013.03.22, +%D title=\CONTEXT\ Style File, +%D subtitle=Language Environment 6, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\startluacode + +languages.tracers = languages.tracers or { } + +function languages.tracers.showfrequencies(language) + local t = languages.frequencies.getdata(language or "en") + context.starttabulate { "|lT|cw(2em)|r|" } + context.NC() + context.formatted.rlap("%s: %p",t.language,languages.frequencies.averagecharwidth(t.language)) + context.NC() + context.NC() + context.NR() + context.HL() + for k, v in table.sortedhash(t.frequencies) do + context.NC() + context("%U",k) + context.NC() + context("%c",k) + context.NC() + context("%0.3f",v) + context.NC() + context.NR() + end + context.stoptabulate() +end + +\stopluacode + +\unexpanded\def\ShowLanguageFrequencies#1% + {\ctxlua{languages.tracers.showfrequencies("#1")}} + +\continueifinputfile{s-lan-06.mkiv} + +\starttext + + \hsize65\averagecharwidth \input ward \par + + \ShowLanguageFrequencies\currentmainlanguage + +\stoptext diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index 1d8ac630f..479d1c489 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -123,9 +123,9 @@ local data, language, method, digits local replacements, m_mappings, z_mappings, p_mappings, entries, orders, lower, upper, method, sequence local thefirstofsplit -local mte = { +local mte = { -- todo: assign to t __index = function(t,k) - if k ~= "" and utfbyte(k) < digitsoffset then + if k and k ~= "" and utfbyte(k) < digitsoffset then -- k check really needed (see s-lan-02) local el if k then local l = lower[k] or lcchars[k] @@ -147,8 +147,10 @@ local mte = { end el = el or k end - -- rawset(t,k,el) also make a copy? + -- rawset(t,k,el) return el + else + -- rawset(t,k,k) end end } diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 28d37dd34..45884e446 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 109161ab4..9f0f763ae 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index b09e498e8..5f101e7d6 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -1471,6 +1471,12 @@ return { loading = "always", status = "okay", }, + { + category = "mkiv", + filename = "typo-lan", + loading = "always", + status = "okay", + }, { category = "mkiv", comment = "this is work in progress", @@ -4665,6 +4671,11 @@ return { filename = "typo-prc", status = "todo", }, + { + category = "lua", + filename = "typo-lan", + status = "okay", + }, { category = "lua", filename = "typo-rep", @@ -5314,6 +5325,11 @@ return { filename = "s-lan-04", status = "todo", }, + { + category = "mkiv", + filename = "s-lan-06", + status = "okay", + }, { category = "tex", filename = "s-mag-01", diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua index feecdcb3b..1ea257bc3 100644 --- a/tex/context/base/trac-log.lua +++ b/tex/context/base/trac-log.lua @@ -6,59 +6,60 @@ if not modules then modules = { } end modules ['trac-log'] = { license = "see context related readme files" } --- if tex and (tex.jobname or tex.formatname) then --- --- -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2) --- --- local texio_write_nl = texio.write_nl --- local texio_write = texio.write --- local io_write = io.write --- --- local write_nl = function(target,...) --- if not io_write then --- io_write = io.write --- end --- if target == "term and log" then --- texio_write_nl("log",...) --- texio_write_nl("term","") --- io_write(...) --- elseif target == "log" then --- texio_write_nl("log",...) --- elseif target == "term" then --- texio_write_nl("term","") --- io_write(...) --- else --- texio_write_nl("log",...) --- texio_write_nl("term","") --- io_write(...) --- end --- end --- --- local write = function(target,...) --- if not io_write then --- io_write = io.write --- end --- if target == "term and log" then --- texio_write("log",...) --- io_write(...) --- elseif target == "log" then --- texio_write("log",...) --- elseif target == "term" then --- io_write(...) --- else --- texio_write("log",...) --- io_write(...) --- end --- end --- --- texio.write = write --- texio.write_nl = write_nl --- --- else --- --- -- texlua or just lua --- --- end +if tex and (tex.jobname or tex.formatname) then + + -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2) + -- still needed for luajittex + + local texio_write_nl = texio.write_nl + local texio_write = texio.write + local io_write = io.write + + local write_nl = function(target,...) + if not io_write then + io_write = io.write + end + if target == "term and log" then + texio_write_nl("log",...) + texio_write_nl("term","") + io_write(...) + elseif target == "log" then + texio_write_nl("log",...) + elseif target == "term" then + texio_write_nl("term","") + io_write(...) + else + texio_write_nl("log",...) + texio_write_nl("term","") + io_write(...) + end + end + + local write = function(target,...) + if not io_write then + io_write = io.write + end + if target == "term and log" then + texio_write("log",...) + io_write(...) + elseif target == "log" then + texio_write("log",...) + elseif target == "term" then + io_write(...) + else + texio_write("log",...) + io_write(...) + end + end + + texio.write = write + texio.write_nl = write_nl + +else + + -- texlua or just lua + +end -- todo: less categories, more subcategories (e.g. nodes) -- todo: split into basics and ctx specific diff --git a/tex/context/base/trac-xml.lua b/tex/context/base/trac-xml.lua index df213ba2d..7dd3969ef 100644 --- a/tex/context/base/trac-xml.lua +++ b/tex/context/base/trac-xml.lua @@ -138,16 +138,15 @@ function reporters.export(t,method,filename) if not xmlfound(t) then return exporthelp(t) end - dofile(resolvers.findfile("trac-exp.lua","tex")) - if not exporters or not method then - return exporthelp(t) - end if not method or method == "" then - method = environment.argument["exporthelp"] + method = environment.arguments["exporthelp"] end if not filename or filename == "" then filename = environment.files[1] end + if not exporters or not method then + return exporthelp(t) + end if method == "all" then method = table.keys(exporters) else @@ -156,9 +155,10 @@ function reporters.export(t,method,filename) if type(filename) ~= "string" or filename == "" then filename = false elseif file.pathpart(filename) == "" then - t.report("export file %a will not be saved on the current path (safeguard)") - filename = false + t.report("export file %a will not be saved on the current path (safeguard)",filename) + return end + dofile(resolvers.findfile("trac-exp.lua","tex")) for i=1,#method do local m = method[i] local result = exporters[m](t,m) diff --git a/tex/context/base/typo-lan.lua b/tex/context/base/typo-lan.lua new file mode 100644 index 000000000..50927f744 --- /dev/null +++ b/tex/context/base/typo-lan.lua @@ -0,0 +1,72 @@ +if not modules then modules = { } end modules ['typo-lan'] = { + version = 1.001, + comment = "companion to typo-lan.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local type, next = type, next + +local currentfont = font.current +local setmetatableindex = table.setmetatableindex +local utfbyte = utf.byte + +local hashes = fonts.hashes +local fontdata = hashes.characters +local emwidths = hashes.emwidths + +local frequencies = languages.frequencies or { } +languages.frequencies = frequencies + +local frequencydata = { } +local frequencyfile = string.formatters["lang-frq-%s.lua"] +local frequencycache = { } + +setmetatableindex(frequencydata, function(t,language) + local fullname = resolvers.findfile(frequencyfile(language)) + local v = fullname ~= "" and dofile(fullname) + if not v or not v.frequencies then + v = t.en + end + t[language] = v + return v +end) + +setmetatableindex(frequencycache, function(t,language) + local dataset = frequencydata[language] + local frequencies = dataset.frequencies + if not frequencies then + return t.en + end + local v = { } + setmetatableindex(v, function(t,font) + local average = emwidths[font] / 2 + if frequencies then + local characters = fontdata[font] + local sum, tot = 0, 0 + for k, v in next, frequencies do + local character = characters[k] -- characters[type(k) == "number" and k or utfbyte(k)] + tot = tot + v + sum = sum + v * (character and character.width or average) + end + average = sum / tot -- widths + end + t[font] = average + return average + end) + t[language] = v + return v +end) + +function frequencies.getdata(language) + return frequencydata[language] +end + +function frequencies.averagecharwidth(language,font) + return frequencycache[language or "en"][font or currentfont()] +end + +function commands.averagecharwidth(language,font) + context(frequencycache[language or "en"][font or currentfont()]) +end diff --git a/tex/context/base/typo-lan.mkiv b/tex/context/base/typo-lan.mkiv new file mode 100644 index 000000000..bb4ed2042 --- /dev/null +++ b/tex/context/base/typo-lan.mkiv @@ -0,0 +1,63 @@ +%D \module +%D [ file=typo-lan, +%D version=2013.03.22, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Language Goodies, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typography Macros / Languages} + +\unprotect + +\registerctxluafile{typo-lan}{1.001} + +%D \macros +%D {averagecharwidth, charwidthlanguage} +%D +%D This is a more \MKIV-ish variant of lang-frq.mkiv. The methods are +%D gone as one doesn't need the tables for them. The main macro is +%D \type {\averagecharwidth} which behaves like a dimension register. +%D +%D I finally decided to reimplement this as I needed it for a manual +%D (which is often a reason for such a rewrite). With some inspiring +%D Porcupine Tree in the background it's not the worst thing to do. + +\def\charwidthlanguage{\currentmainlanguage} + +\def\averagecharwidth{\dimexpr\ctxcommand{averagecharwidth("\charwidthlanguage")}\scaledpoint\relax} + +\protect + +\continueifinputfile{typo-lan.mkiv} + +\setuplayout[backspace=4cm] + +\showframe + +\starttext + +\startbuffer + +\mainlanguage[en] \hsize65\averagecharwidth \normalexpanded{\inleft{\the\hsize}} \input ward \par +\mainlanguage[de] \hsize65\averagecharwidth \normalexpanded{\inleft{\the\hsize}} \input ward \par +\mainlanguage[nl] \hsize65\averagecharwidth \normalexpanded{\inleft{\the\hsize}} \input ward \par + +\stopbuffer + +\getbuffer \blank + +\switchtobodyfont[pagella] + +\getbuffer \blank + +\switchtobodyfont[tt,8pt] + +\getbuffer + +\stoptext diff --git a/tex/context/base/typo-spa.lua b/tex/context/base/typo-spa.lua index 4810a7163..619b3eddd 100644 --- a/tex/context/base/typo-spa.lua +++ b/tex/context/base/typo-spa.lua @@ -158,9 +158,11 @@ local function process(namespace,attribute,head) end end elseif id == math_code then - start = end_of_math(start) + start = end_of_math(start) -- weird, can return nil .. no math end? + end + if start then + start = start.next end - start = start.next end return head, done end -- cgit v1.2.3