diff options
author | Marius <mariausol@gmail.com> | 2013-10-15 11:20:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-10-15 11:20:13 +0300 |
commit | 20b9f7641509d3a2ed593c07dd496451eed32347 (patch) | |
tree | 1f42098f0e1cdd2c17e1df4197c8a69ca3552057 /tex | |
parent | 8adfb82865390989ea7a92db77996b6c3c8212b3 (diff) | |
download | context-20b9f7641509d3a2ed593c07dd496451eed32347.tar.gz |
beta 2013.10.15 10:11
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/cldf-ini.lua | 88 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4115 -> 4106 bytes | |||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/font-sel.lua | 57 | ||||
-rw-r--r-- | tex/context/base/font-sel.mkvi | 39 | ||||
-rw-r--r-- | tex/context/base/meta-imp-txt.mkiv | 42 | ||||
-rw-r--r-- | tex/context/base/s-present-tiles.mkiv | 21 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24517 -> 24536 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 224877 -> 224878 bytes | |||
-rw-r--r-- | tex/context/base/util-tpl.lua | 16 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
12 files changed, 235 insertions, 34 deletions
diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua index 0b89053a2..b29db4090 100644 --- a/tex/context/base/cldf-ini.lua +++ b/tex/context/base/cldf-ini.lua @@ -31,7 +31,7 @@ local context = context local format, gsub, validstring, stripstring = string.format, string.gsub, string.valid, string.strip local next, type, tostring, tonumber, setmetatable, unpack, select = next, type, tostring, tonumber, setmetatable, unpack, select local insert, remove, concat = table.insert, table.remove, table.concat -local lpegmatch, lpegC, lpegS, lpegP, lpegCc, patterns = lpeg.match, lpeg.C, lpeg.S, lpeg.P, lpeg.Cc, lpeg.patterns +local lpegmatch, lpegC, lpegS, lpegP, lpegV, lpegCc, lpegCs, patterns = lpeg.match, lpeg.C, lpeg.S, lpeg.P, lpeg.V, lpeg.Cc, lpeg.Cs, lpeg.patterns local formatters = string.formatters -- using formatteds is slower in this case local loaddata = io.loaddata @@ -1078,3 +1078,89 @@ setmetatable(delayed, { __index = indexer, __call = caller } ) function context.concat(...) context(concat(...)) end + +-- templates + +local single = lpegP("%") +local double = lpegP("%%") +local lquoted = lpegP("%[") +local rquoted = lpegP("]%") + +local start = [[ +local texescape = lpeg.patterns.texescape +local lpegmatch = lpeg.match +return function(variables) return +]] + +local stop = [[ +end +]] + +local replacer = lpegP { "parser", + parser = lpegCs(lpegCc(start) * lpegV("step") * (lpegCc("..") * lpegV("step"))^0 * lpegCc(stop)), + unquoted = (lquoted/'') * ((lpegC((1-rquoted)^1)) / "lpegmatch(texescape,variables['%0'] or '')" ) * (rquoted/''), + escape = double/'%%', + key = (single/'') * ((lpegC((1-single)^1)) / "(variables['%0'] or '')" ) * (single/''), + step = lpegV("unquoted") + + lpegV("escape") + + lpegV("key") + + lpegCc("\n[===[") * (1 - lpegV("unquoted") - lpegV("escape") - lpegV("key"))^1 * lpegCc("]===]\n"), +} + +local templates = { } + +local function indexer(parent,k) + local v = lpegmatch(replacer,k) + if not v then + v = "error: no valid template (1)" + else + v = loadstring(v) + if type(v) ~= "function" then + v = "error: no valid template (2)" + else + v = v() + if not v then + v = "error: no valid template (3)" + end + end + end + if type(v) == "function" then + local f = function(first,second) + if second then + pushcatcodes(first) + flushlines(v(second)) + popcatcodes() + else + flushlines(v(first)) + end + end + parent[k] = f + return f + else + return function() + flush(v) + end + end + +end + +local function caller(parent,k,...) + return parent[k](...) +end + +setmetatable(templates, { __index = indexer, __call = caller } ) + +function context.template(template,...) + context(templates[template](...)) +end + +context.templates = templates + +-- The above is a bit over the top as we could also stick to a simple context.replace +-- which is fast enough anyway, but the above fits in nicer, also with the catcodes. +-- +-- local replace = utilities.templates.replace +-- +-- function context.template(template,variables) +-- context(replace(template,variables)) +-- end diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 87d9d256d..d655f011c 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.10.13 23:58} +\newcontextversion{2013.10.15 10: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 Binary files differindex 1221a3d27..c686d4e2f 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 631ca3797..43930574a 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.10.13 23:58} +\edef\contextversion{2013.10.15 10:11} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/font-sel.lua b/tex/context/base/font-sel.lua index 7d535caa8..0c8985f4a 100644 --- a/tex/context/base/font-sel.lua +++ b/tex/context/base/font-sel.lua @@ -10,6 +10,7 @@ local context = context local cleanname = fonts.names.cleanname local gsub, splitup, find = string.gsub, string.splitup, string.find local formatters = string.formatters +local settings_to_array = utilities.parsers.settings_to_array local v_yes = interfaces.variables.yes local v_simplefonts = interfaces.variables.simplefonts @@ -269,6 +270,7 @@ function commands.defineselectfont(settings) local index = #data + 1 data[index] = settings selectfont.searchfiles(index) + selectfont.filterinput(index) context(index) end @@ -281,6 +283,24 @@ local function savefont(data,alternative,entries) f[alternative] = entries end +local function savefeatures(data,alternative,entries) + local f = data.features + if not f then + f = { } + data.features = f + end + f[alternative] = entries +end + +local function savegoodies(data,alternative,entries) + local g = data.goodies + if not f then + g = { } + data.goodies = g + end + g[alternative] = entries +end + methods[v_simplefonts] = function(data,alternative,style) local family = data.metadata.family local names = names["simplefonts"][style] or names["simplefonts"]["regular"] @@ -389,6 +409,14 @@ methods["style"] = function(data,alternative,style) (methods[method] or methods[v_default])(data,alternative,style) end +methods["features"] = function(data,alternative,features) + savefeatures(data,alternative,features) +end + +methods["goodies"] = function(data,alternative,goodies) + savegoodies(data,alternative,goodies) +end + function selectfont.searchfiles(index) local data = data[index] for alternative, _ in next, alternatives do @@ -398,9 +426,8 @@ function selectfont.searchfiles(index) local style = alternatives[alternative] if filename == "" then local pattern = getlookups{ familyname = cleanname(family) } - if #pattern == 1 then -- needs to be improved - savefont(data,"tf",pattern) - break + if #pattern == 1 and alternative == "tf" then -- needs to be improved + savefont(data,alternative,pattern) else (methods[method] or methods[v_default])(data,alternative,style) end @@ -415,25 +442,40 @@ function selectfont.searchfiles(index) end end +function selectfont.filterinput(index) + local data = data[index] + for alternative, _ in next, alternatives do + local list = settings_to_array(data.alternatives[alternative]) + for _, entry in next, list do + method, entries = splitup(entry,":") + if not entries then + entries = method + method = "name" + end + (methods[method] or methods["name"])(data,alternative,entries) + end + end +end + local function definefontsynonym(data,alternative,index,fallback) local fontdata = data.fonts and data.fonts[alternative] local style = data.metadata.style local typeface = data.metadata.typeface local mathsettings = mathsettings[cleanname(data.metadata.family)] - local features = mathsettings and mathsettings["features"] and (mathsettings["features"][alternative] or mathsettings["features"]["tf"]) or data.features[alternative] - local goodies = mathsettings and mathsettings["goodies"] and (mathsettings["goodies"] [alternative] or mathsettings["goodies"] ["tf"]) or "" + local features = mathsettings and mathsettings["features"] and (mathsettings["features"][alternative] or mathsettings["features"]["tf"]) or data.features and data.features[alternative] or "" + local goodies = mathsettings and mathsettings["goodies"] and (mathsettings["goodies"] [alternative] or mathsettings["goodies"] ["tf"]) or data.goodies and data.goodies [alternative] or "" local parent = replacement["style"][alternative] or "" local fontname, fontfile, fontparent if fallback then fontname = formatters["%s-%s-%s-fallback-%s"](typeface, style, alternative, index) fontfile = formatters["%s-%s-%s-%s"] (typeface, style, alternative, index) - fontparent = formatters["%s-%s-%s-%s"] (typeface, style, parent, index) + fontparent = formatters["%s-%s-%s-fallback-%s"](typeface, style, parent, index) else fontname = synonyms[style][alternative] fontfile = formatters["%s-%s-%s"](typeface, style, alternative) fontparent = formatters["%s-%s-%s"](typeface, style, parent) end - if fontdata then + if fontdata and #fontdata > 0 then for _, size in next, sizes["default"] do for _, entry in next, fontdata do if entry["minsize"] and entry["maxsize"] then @@ -530,6 +572,7 @@ local function definetextfallback(entry,index) definetextfontfallback(data,alternative,entry) end context.stopfontclass() + -- inspect(data) end local function definemathfontfallback(data,alternative,index) diff --git a/tex/context/base/font-sel.mkvi b/tex/context/base/font-sel.mkvi index f91baa5d8..718da1fa2 100644 --- a/tex/context/base/font-sel.mkvi +++ b/tex/context/base/font-sel.mkvi @@ -1,6 +1,6 @@ %D \module %D [ file=font-sel, -%D version=2013.09.28, +%D version=2013.10.14, %D title=\CONTEXT\ User Module, %D subtitle=Selectfont, %D author=Wolfgang Schuster, @@ -44,6 +44,15 @@ check = "\selectfontparameter\c!check", % fallback only force = "\selectfontparameter\c!force", % fallback only }, + alternatives = { + ["tf"] = "\selectfontparameter\s!tf", + ["bf"] = "\selectfontparameter\s!bf", + ["it"] = "\selectfontparameter\s!it", + ["sl"] = "\selectfontparameter\s!sl", + ["bi"] = "\selectfontparameter\s!bi", + ["bs"] = "\selectfontparameter\s!bs", + ["sc"] = "\selectfontparameter\s!sc", + }, files = { ["tf"] = "\selectfontparameter\c!regularfont", ["bf"] = "\selectfontparameter\c!boldfont", @@ -91,7 +100,7 @@ \installcorenamespace {selectfontpreset} -\unexpanded\def\defineselectfontpreset +\unexpanded\def\definefontfamilypreset {\dodoubleargument\selectfont_preset_define} \def\selectfont_preset_define[#name][#settings]% @@ -106,11 +115,11 @@ % unknown preset \fi} -\let\definefontfamilypreset\defineselectfontpreset - -\definefontfamilypreset [\s!chinese ] [\c!range={0x00400-0x2FA1F}] -\definefontfamilypreset [\s!japanese] [\c!range={0x00400-0x2FA1F}] -\definefontfamilypreset [\s!korean ] [\c!range={0x00400-0x2FA1F}] +\definefontfamilypreset [r:chinese] [\c!range={cjkcompatibilityforms,cjkcompatibilityideographs,cjkcompatibilityideographssupplement,cjkradicalssupplement,cjkstrokes,cjksymbolsandpunctuation,cjkunifiedideographs,cjkunifiedideographsextensiona,cjkunifiedideographsextensionb,halfwidthandfullwidthforms,verticalforms,bopomofo,bopomofoextended}] +\definefontfamilypreset [r:japanese] [\c!range={cjkcompatibilityforms,cjkcompatibilityideographs,cjkcompatibilityideographssupplement,cjkradicalssupplement,cjkstrokes,cjksymbolsandpunctuation,cjkunifiedideographs,cjkunifiedideographsextensiona,cjkunifiedideographsextensionb,halfwidthandfullwidthforms,verticalforms,hiragana,katakana}] +\definefontfamilypreset [r:korean] [\c!range={cjkcompatibilityforms,cjkcompatibilityideographs,cjkcompatibilityideographssupplement,cjkradicalssupplement,cjkstrokes,cjksymbolsandpunctuation,cjkunifiedideographs,cjkunifiedideographsextensiona,cjkunifiedideographsextensionb,halfwidthandfullwidthforms,verticalforms,hangulcompatibilityjamo,hanguljamo,hanguljamoextendeda,hanguljamoextendedb,hangulsyllables}] +\definefontfamilypreset [r:cyrillic] [\c!range={cyrillic,cyrillicextendeda,cyrillicextendedb,cyrillicsupplement}] +\definefontfamilypreset [r:greek] [\c!range={greekandcoptic,greekextended,ancientgreeknumbers}] %D \macros %D {defineselectfontalternative} @@ -229,7 +238,9 @@ {\doquadrupleempty\selectfont_family_define} \def\selectfont_family_define[#typeface][#style][#family][#settings]% - {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]% + {\doifassignmentelse{#settings} + {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]} + {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},\c!preset={#settings}]}% \ctxcommand{definefontfamily(\selectfont_index)}} \unexpanded\def\definefallbackfamily @@ -271,10 +282,20 @@ \unexpanded\def\setupfontfamily {\dotripleempty\selectfont_family_setup} -\def\selectfont_family_setup[#style][#family][#settings]% +\def\selectfont_family_setup + {\ifsecondargument + \expandafter\selectfont_family_setup_yes + \else + \expandafter\selectfont_family_setup_nop + \fi} + +\def\selectfont_family_setup_yes[#style][#family][#settings]% {\normalexpanded{\t_selectfont_styles{\selectfont_set_font_family[#style][#family][#settings]\the\t_selectfont_styles}}% \selectfont_set_font_indeed} +\def\selectfont_family_setup_nop[#settings][#dummya][#dummyb]% + {\setupselectfont[#settings]} + \unexpanded\def\selectfont_set_default {\selectfont_set_font_family[\v!serif][Latin Modern Roman][\c!opticalsize=\v!yes]% \selectfont_set_font_family[\v!sans] [Latin Modern Sans] [\c!opticalsize=\v!yes]% diff --git a/tex/context/base/meta-imp-txt.mkiv b/tex/context/base/meta-imp-txt.mkiv index 8c35d966f..bcfc5513f 100644 --- a/tex/context/base/meta-imp-txt.mkiv +++ b/tex/context/base/meta-imp-txt.mkiv @@ -170,7 +170,7 @@ % we default to nothing \stopuseMPgraphic -\unexpanded\def\followtokens#1% +\unexpanded\def\dofollowtokens#1#2% {\vbox\bgroup \forgetall \dontcomplain @@ -183,13 +183,13 @@ \includeMPgraphic{followtokens} ; picture pic[] ; numeric len[], n ; n := 0 ; \stopMPdrawing - \handletokens#1\with\processfollowingtoken + \handletokens#2\with\processfollowingtoken \startMPdrawing if unknown RotPath : path RotPath ; RotPath := origin ; fi ; if unknown RotColor : color RotColor ; RotColor := black ; fi ; if unknown TraceRot : boolean TraceRot ; TraceRot := false ; fi ; if unknown ExtraRot : numeric ExtraRot ; ExtraRot := 0 ; fi ; - numeric al, at, pl, wid, pos ; pair ap, ad ; + numeric al, at, pl, pc, wid, pos ; pair ap, ad ; al := arclength RotPath ; if al=0 : al := len[n] + ExtraRot ; @@ -199,13 +199,19 @@ RotPath := RotPath scaled ((len[n]+ExtraRot)/al) ; al := arclength RotPath ; fi ; - pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ; + if \number#1 = 1 : + pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ; + pc := 0 ; + else : % centered / MP + pl := 0 ; + pc := arclength RotPath/2 - len[n]/2 ; + fi ; if TraceRot : draw RotPath withpen pencircle scaled 1pt withcolor blue ; fi ; for i=1 upto n : wid := abs(xpart urcorner pic[i] - xpart llcorner pic[i]) ; - pos := len[i]-wid/2 + (i-1)*pl ; + pos := len[i]-wid/2 + (i-1)*pl + pc ; at := arctime pos of RotPath ; ap := point at of RotPath ; ad := direction at of RotPath ; @@ -225,6 +231,11 @@ \resetMPdrawing \egroup} +\unexpanded\def\followtokens {\dofollowtokens1} +\unexpanded\def\followtokenscentered{\dofollowtokens0} + +% stretched variant: +% % \followtokens % {This is just a dummy text, kerned by T{\kern % -.1667em\lower .5ex\hbox {E}}{\kern -.125emX} and typeset @@ -232,6 +243,27 @@ % E}{\setMFPfont T}{\setMFPfont A}{\setMFPfont % P}{\setMFPfont O}{\setMFPfont S}{\setMFPfont T}.\quad} +% centered variant: +% +% \def\followtokengraphicscale#1{%% +% \startuseMPgraphic {followtokens} +% path RotPath; RotPath := reverse halfcircle scaled #1 ; +% draw RotPath ; +% setbounds currentpicture to boundingbox fullcircle scaled 12cm ; +% \stopuseMPgraphic} +% +% \startoverlay +% {\followtokengraphicscale{12cm}%% +% \followtokenscentered{There was question on the list about this kind of graphics.}} +% {\followtokengraphicscale{10cm}%% +% \followtokenscentered{And Marco patched followingtokens to handle a centered text.}} +% {\followtokengraphicscale{8cm}%% +% \followtokenscentered{That ended up as variant branch in the main macro.}} +% {\followtokengraphicscale{6cm}%% +% \followtokenscentered{So now we have two commands.}} +% \stopoverlay + + \startuseMPgraphic{fuzzycount} begingroup save height, span, drift, d, cp ; diff --git a/tex/context/base/s-present-tiles.mkiv b/tex/context/base/s-present-tiles.mkiv index 79fe48950..b68a34ef4 100644 --- a/tex/context/base/s-present-tiles.mkiv +++ b/tex/context/base/s-present-tiles.mkiv @@ -64,7 +64,17 @@ -\topspace ] -\definemeasure [topiclistfont] [1.2\measured{topiclistwidth}/10] +\definemeasure [topiclistfontsize] [ + \ifcase\numexpr\structurelistsize\relax 2.5 % 0 + \or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4 % 1 - 9 + \or1.3\or1.3\or1.3\or1.3\or1.3\or1.3\or1.3 % 10 - 16 + \or1.2\or1.2\or1.2\or1.2\or1.2 % 17 - 20 + \else1 % 21 - 25 + \fi + \bodyfontsize +] + +\definemeasure [topiclistfont] [\measured{topiclistfontsize}] \definemeasure [topictitlefont] [1.2\measured{layoutunit}] \definemeasure [titlepagefont] [2\measured{layoutunit}] @@ -218,6 +228,15 @@ % end of buttons +\defineframed + [conclusion] + [location=low, + width=max, + align={flushleft,lohi}, + background=color, + backgroundcolor=white, + foregroundcolor=secondarycolor] + \startsetups [document:titlepage] \definebodyfontenvironment diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex deeebb46f..51957e4b7 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 4aac19a9a..07a5a0aaa 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/util-tpl.lua b/tex/context/base/util-tpl.lua index e0c405a42..67d058221 100644 --- a/tex/context/base/util-tpl.lua +++ b/tex/context/base/util-tpl.lua @@ -17,8 +17,8 @@ local trace_template = false trackers.register("templates.trace",function(v) t local report_template = logs.reporter("template") local tostring = tostring -local format, sub = string.format, string.sub -local P, C, Cs, Carg, lpegmatch, lpegpatterns = lpeg.P, lpeg.C, lpeg.Cs, lpeg.Carg, lpeg.match, lpeg.patterns +local format, sub, byte = string.format, string.sub, string.byte +local P, C, R, Cs, Cc, Carg, lpegmatch, lpegpatterns = lpeg.P, lpeg.C, lpeg.R, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.match, lpeg.patterns -- todo: make installable template.new @@ -71,7 +71,7 @@ lpegpatterns.sqlquoted = sqlquoted -- } -- -- slightly faster: --- + -- local luaescape = Cs (( -- P('"' ) / [[\"]] + -- P('\\') / [[\\]] + @@ -81,11 +81,11 @@ lpegpatterns.sqlquoted = sqlquoted -- P(1) -- )^0) --- local xmlescape = lpegpatterns.xmlescape --- local texescape = lpegpatterns.texescape --- local luaescape = lpegpatterns.luaescape --- local sqlquoted = lpegpatterns.sqlquoted --- local luaquoted = lpegpatterns.luaquoted +----- xmlescape = lpegpatterns.xmlescape +----- texescape = lpegpatterns.texescape +local luaescape = lpegpatterns.luaescape +----- sqlquoted = lpegpatterns.sqlquoted +----- luaquoted = lpegpatterns.luaquoted local escapers = { lua = function(s) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index b875f40c9..012878063 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 : 10/13/13 23:58:40 +-- merge date : 10/15/13 10:11:32 do -- begin closure to overcome local limits and interference |