diff options
author | Karl Berry <karl@freefriends.org> | 2018-04-03 21:38:18 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-04-03 21:38:18 +0000 |
commit | 3fb0ad9f253c3ebf81ce763d3f6ddb3f9d9f4191 (patch) | |
tree | 41cb948bdec6398d9a899bde276f561b42364f25 /Master/texmf-dist/tex/context/modules/mkiv | |
parent | 10bc59082551160a5434cb4c7fcfdc7816bb647d (diff) |
context (3apr18)
git-svn-id: svn://tug.org/texlive/trunk@47272 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/modules/mkiv')
8 files changed, 391 insertions, 63 deletions
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-punk.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-punk.mkiv index b72abd64d8f..08a0663592e 100644 --- a/Master/texmf-dist/tex/context/modules/mkiv/m-punk.mkiv +++ b/Master/texmf-dist/tex/context/modules/mkiv/m-punk.mkiv @@ -11,6 +11,12 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +%D You can actually turn a punk font into music (wintergatan): +%D +%D \starttyping +%D https://www.youtube.com/watch?v=g5c2Htj8Vtw +%D \stoptyping + \startluacode local concat = table.concat local round = math.round diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-basics.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-basics.mkiv new file mode 100644 index 00000000000..e9d0a21a296 --- /dev/null +++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-basics.mkiv @@ -0,0 +1,175 @@ +%D \module +%D [ file=s-fnt-01, +%D version=2006.10.10, % guess +%D title=\CONTEXT\ Style File, +%D subtitle=Listing Glyphs in Large Fonts, +%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. + +%D This module is just a check for \type {luatex-basics-prepare}. + +\usemodule[article] + +\setupbodyfont[9pt] + +\starttext + +\definefontfeature + [boundingbox] + [boundingbox=yes] + +\definefont + [TestFont] + [file:arialuni.ttf*boundingbox] + +\startluacode + +local data = characters.data + +local indicscripts = table.sorted { + "devanagari", + "kannada", + "malayalam", + "tamil", + "bengali", + "gurmukhi", + "gujarati", + "oriya", + "telugu", +} + +local arabicscripts = table.sorted { + "arabic", + "syriac", + "mandiac", + "nko", +} + +local allindic = true +local allarabic = true +local dotted = utf.char(0x25CC) + +local left = table.setmetatableindex ( + { r = dotted, b = dotted, t = dotted, s = dotted }, + function(t,k) local v = "" if k then t[k] = v end return v end +) + +local right = table.setmetatableindex ( + { l = dotted }, + function(t,k) local v = "" if k then t[k] = v end return v end +) + +for i=1,#indicscripts do + local script = indicscripts[i] + local first, last = characters.blockrange(script) + context.starttitle { title = script } + context.starttabulate { "|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tp|" } + context.FL() + context.BC() context("unicode") + context.BC() context("glyph") + context.BC() context("category") + context.BC() context("indic") + context.BC() context("mark") + context.BC() context("class") + context.BC() context("order") + context.BC() context("description") + context.NC() context.NR() + context.ML() + for i=first,last do + local d = data[i] + if d and d.unicodeslot then + local indic = d.indic + local category = d.category or "?" + local description = d.description + if not indic then + context.NC() context("\\red %U",i) + context.NC() context("\\red\\showstruts\\strut\\TestFont %c",i) + context.NC() context("\\red %s",category) + context.NC() + context.NC() + context.NC() + context.NC() + context.NC() context(description) + context.NC() context.NR() + else + local indicclass = d.indicclass + local indicmark = d.indicmark + local indicorder = d.indicorder + if allindic or indic == "d" or indicmark or indicclass or indicorder then + local l = left [indicmark] + local r = right[indicmark] + context.NC() context("%U",i) + context.NC() context("\\showstruts\\strut\\TestFont %s%c%s",l,i,r) + context.NC() context(category) + context.NC() context(indic or "?") + context.NC() context(indicmark or "") + context.NC() context(indicclass or "") + context.NC() context(indicorder or "") + context.NC() context(description) + context.NC() context.NR() + end + end + end + end + context.LL() + context.stoptabulate() + context.stoptitle() +end + +for i=1,#arabicscripts do + local script = arabicscripts[i] + local first, last = characters.blockrange(script) + context.starttitle { title = script } + context.starttabulate { "|Tc|Tc|Tc|Tc|Tp|" } + context.FL() + context.BC() context("unicode") + context.BC() context("glyph") + context.BC() context("category") + context.BC() context("arabic") + context.BC() context("description") + context.NC() context.NR() + context.ML() + for i=first,last do + local d = data[i] + if d and d.unicodeslot then + local arabic = d.arabic + local category = d.category or "" + local description = d.description or "" + if arabic then + context.NC() context("%U",i) + context.NC() context("\\showstruts\\strut\\TestFont %c",i) + context.NC() context(category) + context.NC() context(arabic) + context.NC() context(description) + context.NC() context.NR() + elseif allarabic then + context.NC() context("\\red %U",i) + context.NC() context("\\red\\showstruts\\strut\\TestFont %c",i) + context.NC() context("\\red %s",category) + context.NC() + context.NC() context("\\red %s",description) + context.NC() context.NR() + end + end + end + context.LL() + context.stoptabulate() + context.stoptitle() +end + +-- local olddata = io.loaddata("char-def.lua") +-- local preamble = string.gsub(olddata,"characters%.data%s*=%s*%{.*","") + +-- local newdata = table.serialize(data,"characters.data", { hexify = true, noquotes = true }) +-- local newdata = string.gsub(newdata,"%{%s+%[0xFE0E%]=\"text style\",%s+%[0xFE0F%]=\"emoji style\",%s+%}","variants_emoji") + +-- io.savedata("char-def-new.lua",newdata) + +\stopluacode + +\stoptext diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-overlay.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-overlay.mkiv new file mode 100644 index 00000000000..fccc977d472 --- /dev/null +++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-overlay.mkiv @@ -0,0 +1,107 @@ +%D \module +%D [ file=s-fonts-overlay, +%D version=2018.03.25, +%D title=\CONTEXT\ Style File, +%D subtitle=Show Glyph Similarity, +%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. + +% begin info +% +% title : overlay glyphs in fonts +% +% comment : show glyphs in two fonts +% status : experimental, used for font feature development +% +% end info + +%D This module is for Luigi/Idris as part of the Husayni development where the +%D gpos pair, single, mark and cursive features are just linear transformations. + +\startmodule[fonts-coverage] + +\unprotect + +\definecolor[ColorOne][r=1,t=.5,a=1] +\definecolor[ColorTwo][b=1,t=.5,a=1] + +\startluacode + moduledata.fonts = moduledata.fonts or { } + moduledata.fonts.overlay = moduledata.fonts.overlay or { } + + function moduledata.fonts.overlay(id) + for k, v in table.sortedhash(fonts.hashes.identifiers[id or true].characters) do + context.showoverlayedglyphs(k) + end + end +\stopluacode + +\starttexdefinition unexpanded showoverlayedglyphs#1 + \startTEXpage[offset=.25\scratchdimentwo,height=10\scratchdimentwo,width=4\scratchdimenone] + \ruledhbox to \hsize\bgroup + \hss + \FontOne\setstrut\strut\showglyphs + \startoverlay + {\ColorOne\ruledhbox{\FontOne\char#1}} + {\ColorTwo\ruledhbox{\FontTwo\char#1}} + \stopoverlay + \hss + \egroup + \vfill + \dontleavehmode + \hbox to \hsize\bgroup + \hss + \infofont0x\uchexnumbers{#1} + \hss + \egroup + \stopTEXpage +\stoptexdefinition + +\starttexdefinition unexpanded showoverlayedfonts[#1] + \start + \getdummyparameters[\c!list=,#1] + \doifsomething {\dummyparameter\c!list} { + \page + \getfromcommacommand[\dummyparameter\c!list][1]\let\NameOne\commalistelement + \getfromcommacommand[\dummyparameter\c!list][2]\let\NameTwo\commalistelement + \definefont[FontOne][\NameOne] + \definefont[FontTwo][\NameTwo] + \FontOne\expandafter\edef\expandafter\OneID\expandafter{\number\fontid\font}% + \FontTwo\expandafter\edef\expandafter\TwoID\expandafter{\number\fontid\font}% + \scratchdimenone\emwidth + \scratchdimentwo\exheight + \ctxlua{moduledata.fonts.overlay(\OneID)}% + \page + % \startTEXpage[offset=.25\scratchdimentwo,height=10\scratchdimentwo,width=4\scratchdimenone] + % \vfill + % \hbox to \hsize{\ColorOne\infofont\hss\OneN\hss} + % \vfill + % \hbox to \hsize{\ColorTwo\infofont\hss\TwoN\hss} + % \vfill + % \stopTEXpage + % \page + } + \stop +\stoptexdefinition + +\protect + +\stopmodule + +\continueifinputfile{s-fonts-overlay.mkiv} + +\starttext + +% \showoverlayedfonts +% [list={file:husayni-script-regular.ttf @ 48.0pt, +% file:husayni-note-bold.ttf @ 34.2pt}] % 34.18726pt + + \showoverlayedfonts + [list={Serif,SerifBold}] + +\stoptext diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.lua index ebdf04c2235..748c5a92a60 100644 --- a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.lua +++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.lua @@ -109,12 +109,9 @@ local characters = nil local function showglyphshape(specification) specification = interfaces.checkedspecification(specification) - local id, cs = fonts.definers.internal(specification,"<module:fonts:shapes:font>") + local id, cs = fonts.definers.internal(specification,"<module:fonts:shapes:font>") local tfmdata = fontdata[id] - local charnum = tonumber(specification.character) - if not charnum then - charnum = fonts.helpers.nametoslot(specification.character) - end + local charnum = tonumber(specification.character) or fonts.helpers.nametoslot(specification.character) local characters = tfmdata.characters local descriptions = tfmdata.descriptions local parameters = tfmdata.parameters @@ -133,64 +130,75 @@ local function showglyphshape(specification) context.startMPcode() context("numeric lw ; lw := .125bp ;") context("pickup pencircle scaled lw ;") - context('picture p ; p := image(draw textext.drt("\\getuvalue{%s}\\gray\\char%s");); draw p ;',cs,charnum) + if width < 0.01 then + -- catches zero width marks + context('picture p ; p := textext.drt("\\hskip5sp\\getuvalue{%s}\\gray\\char%s"); draw p ;',cs,charnum) + else + context('picture p ; p := textext.drt("\\getuvalue{%s}\\gray\\char%s"); draw p ;',cs,charnum) + end context('draw (%s,%s)--(%s,%s)--(%s,%s)--(%s,%s)--cycle withcolor green ;',llx,lly,urx,lly,urx,ury,llx,ury) context('draw (%s,%s)--(%s,%s) withcolor green ;',llx,0,urx,0) context('draw boundingbox p withcolor .2white withpen pencircle scaled .065bp ;') context("defaultscale := 0.05 ; ") -- inefficient but non critical - local function slant_1(v,dx,dy,txt,xsign,ysign,loc,labloc) - if #v > 0 then - local l = { } - for kk, vv in ipairs(v) do - local h, k = vv.height or 0, vv.kern or 0 - if h and k then - l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) + local slant = { + function(v,dx,dy,txt,xsign,ysign,loc,labloc) + local n = #v + if n > 0 then + local l = { } + for i=1,n do + local c = v[i] + local h = c.height or 0 + local k = c.kern or 0 + l[i] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) end - end - context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[1].kern*factor,lly,dx,dy,l[1]) - context("draw laddered (%s) withcolor .5white ;",table.concat(l,"..")) - context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[#v].kern*factor,ury,dx,dy,l[#l]) - for k, v in ipairs(l) do - context("draw %s withcolor blue withpen pencircle scaled 2lw ;",v) - end - end - end - local function slant_2(v,dx,dy,txt,xsign,ysign,loc,labloc) - if #v > 0 then - local l = { } - for kk, vv in ipairs(v) do - local h, k = vv.height or 0, vv.kern or 0 - if h and k then - l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) + context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[1].kern*factor,lly,dx,dy,l[1]) +-- context("draw laddered (%s) withcolor .5white ;",table.concat(l,"..")) + context("draw laddered (%..t) withcolor .5white ;",l) + context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[#v].kern*factor,ury,dx,dy,l[#l]) + for i=1,n do + context("draw %s withcolor blue withpen pencircle scaled 2lw ;",l[i]) end end - if loc == "top" then - context('label.%s("\\type{%s}",%s shifted (0,-1bp)) ;',loc,txt,l[#l]) - else - context('label.%s("\\type{%s}",%s shifted (0,2bp)) ;',loc,txt,l[1]) - end - for kk, vv in ipairs(v) do - local h, k = vv.height or 0, vv.kern or 0 - if h and k then - context('label.top("(%s,%s)",%s shifted (0,-2bp));',k,h,l[kk]) + end, + function(v,dx,dy,txt,xsign,ysign,loc,labloc) + local n = #v + if n > 0 then + local l = { } + for i=1,n do + local c = v[i] + local h = c.height or 0 + local k = c.kern or 0 + l[i] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) + end + if loc == "top" then + context('label.%s("\\type{%s}",%s shifted (0,-1bp)) ;',loc,txt,l[n]) + else + context('label.%s("\\type{%s}",%s shifted (0,2bp)) ;',loc,txt,l[1]) + end + for i=1,n do + local c = v[i] + local h = c.height or 0 + local k = c.kern or 0 + context('label.top("(%s,%s)",%s shifted (0,-2bp));',k,h,l[i]) end end - end - end + end, + } if math then local kerns = math.kerns if kerns then - for _, slant in ipairs { slant_1, slant_2 } do - for k,v in pairs(kerns) do + for i=1,#slant do + local s = slant[i] + for k, v in next, kerns do if k == "topright" then - slant(v,width+italic,0,k,1,1,"top","ulft") + s(v,width+italic,0,k,1,1,"top","ulft") elseif k == "bottomright" then - slant(v,width,0,k,1,1,"bot","lrt") + s(v,width,0,k,1,1,"bot","lrt") elseif k == "topleft" then - slant(v,0,0,k,-1,1,"top","ulft") + s(v,0,0,k,-1,1,"top","ulft") elseif k == "bottomleft" then - slant(v,0,0,k,-1,1,"bot","lrt") + s(v,0,0,k,-1,1,"bot","lrt") end end end @@ -205,33 +213,34 @@ local function showglyphshape(specification) if anchors then local a = anchors.baselig if a then - for k, v in pairs(a) do - for kk, vv in ipairs(v) do - show(vv[1],vv[2],k .. ":" .. kk) + for k, v in next, a do + for i=1,#v do + local p = v[i] + show(p[1],p[2],k .. ":" .. i) end end end local a = anchors.mark if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end local a = anchors.basechar if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end local ba = anchors.centry if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end local a = anchors.cexit if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.mkiv index 4a0377adaee..53ed1b426ef 100644 --- a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.mkiv +++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.mkiv @@ -109,7 +109,11 @@ % \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D45D}\stopTEXpage % \page -\showallglyphshapes[name=name:cambria-math,size=100bp] +\startTEXpage[offset=0pt]\ShowGlyphShape{file:husayninotebold.ttf}{50bp}{0xF034A}\stopTEXpage +\startTEXpage[offset=0pt]\ShowGlyphShape{file:husayninotebold.ttf}{50bp}{0x006DD}\stopTEXpage + +% \showallglyphshapes[name=name:cambria-math,size=100bp] +% \showallglyphshapes[name=file:husayninotebold.ttf,size=100bp] % \showallglyphshapes[name=name:dejavuserif,size=100bp] % \showallglyphshapes[name=file:brill.otf,size=100bp] diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-tugboat.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-tugboat.mkiv index 2b3b07d11f8..d3d15c3e735 100644 --- a/Master/texmf-dist/tex/context/modules/mkiv/s-tugboat.mkiv +++ b/Master/texmf-dist/tex/context/modules/mkiv/s-tugboat.mkiv @@ -23,8 +23,7 @@ [tugboat] [type=article, columns=no, - grid=yes - ] + grid=yes] \setvariables [tugboat] @@ -45,7 +44,7 @@ email={tugboat@tug.org}] %D \section Font Setup %<<<1 -%D +%D %D \TUGBOAT\ uses slightly different interline space than the default. %D So we change the interline space. @@ -121,7 +120,7 @@ \setupdescriptions [indentnext=no] -%D \section Itemize +%D \section Itemize %D %D And these. We typeset itemizations ragged right. @@ -158,7 +157,7 @@ subject, subsubject, subsubsubject] [style=bold, align=right, - before={\blank[8pt]}, + before={\blank[8pt]}, after={\blank[4pt]}] %D \section Spacing <<<1 @@ -173,8 +172,8 @@ \setupitemize[1][before={\blank[tugblank]},after={\blank[tugblank]}, inbetween={\blank[tugblank]}] -\setuplines[before={\blank[tugblank]},after={\blank[tugblank]}, - inbetween={\blank[tugblank]}] +\setuplines[before={\blank[tugblank]},after={\blank[tugblank]}, + inbetween={\blank[tugblank]}] %D \section Typing %<<<1 %D @@ -232,7 +231,7 @@ \definereferenceformat[cite][left={[},right={]}] \defineitemgroup [bibliography] [levels=1] -\setupitemgroup [bibliography] +\setupitemgroup [bibliography] [symbol=n, left={[}, right={]}, diff --git a/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.lua b/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.lua index 7785d5587a9..b0d45659e30 100644 --- a/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.lua +++ b/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.lua @@ -50,9 +50,12 @@ local formatters = string.formatters local entities = characters.entities or { } local xmltext = xml.text +local xmlpure = xml.pure local xmlinclusion = xml.inclusion local xmlcollected = xml.collected +local lxmlgetid = lxml.getid + -- todo: use private unicodes as temporary slots ... easier to compare local s_lparent = "\\left\\lparent" @@ -2089,6 +2092,14 @@ interfaces.implement { arguments = { "string", true }, } +interfaces.implement { + name = "xmlasciimath", + actions = function(id) + convert(xmlpure(lxmlgetid(id))) + end, + arguments = "string" +} + local ctx_typebuffer = context.typebuffer local ctx_mathematics = context.mathematics local ctx_color = context.color @@ -2192,7 +2203,7 @@ end function show.filter(id,element) collected, indexed, ignored = { }, { }, { } - asciimath.filter(lxml.getid(id),element or "am",collected,indexed) + asciimath.filter(lxmlgetid(id),element or "am",collected,indexed) end function show.max() diff --git a/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.mkiv index 1b0567dbd0a..32eaf2af213 100644 --- a/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.mkiv +++ b/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.mkiv @@ -182,6 +182,23 @@ {\the\everyasciimath \clf_justasciimath{\detokenize\expandafter{\normalexpanded{#1}}}}} +% \unexpanded\def\xmlasciimath +% {\clf_xmlasciimath} + +\unexpanded\def\xmlasciimath + {\doifnextoptionalelse\xmlasciimath_yes\xmlasciimath_nop} + +\def\xmlasciimath_yes[#1]#2% + {\mathematics + [#1]% + {\the\everyasciimath% + \clf_xmlasciimath{#2}}} + +\def\xmlasciimath_nop#1% + {\mathematics + {\the\everyasciimath + \clf_xmlasciimath{#1}}} + \unexpanded\def\ctxmoduleasciimath#1% {\ctxlua{moduledata.asciimath.#1}} |