diff options
author | Hans Hagen <pragma@wxs.nl> | 2022-10-14 10:56:48 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2022-10-14 10:56:48 +0200 |
commit | 0aa93a6d31a45d8df2d8516567b98967ce04f183 (patch) | |
tree | 7e1942650512f1994ca56c1eba245973240d4b71 /tex/context/modules | |
parent | c161b7d6fe142231346cc1844e6e27c0ab7718c1 (diff) | |
download | context-0aa93a6d31a45d8df2d8516567b98967ce04f183.tar.gz |
2022-10-14 10:15:00
Diffstat (limited to 'tex/context/modules')
-rw-r--r-- | tex/context/modules/mkiv/s-fonts-charts.mkiv | 6 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-fonts-coverage.mkiv | 12 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-fonts-shapes.lua | 139 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-fonts-shapes.mkiv | 16 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-math-characters.lua | 2 |
5 files changed, 100 insertions, 75 deletions
diff --git a/tex/context/modules/mkiv/s-fonts-charts.mkiv b/tex/context/modules/mkiv/s-fonts-charts.mkiv index b7fcc9f9e..6fe58c899 100644 --- a/tex/context/modules/mkiv/s-fonts-charts.mkiv +++ b/tex/context/modules/mkiv/s-fonts-charts.mkiv @@ -172,10 +172,10 @@ \starttext -% \showfontchart[filename=texgyredejavu-math.otf,page=yes,option=all] + \showfontchart[filename=texgyredejavu-math.otf,page=yes,option=all] - \showfontchart[filename=danlan.otf] % ,page=yes,option=all] - \showfontchart[filename=danlan-bold.otf] % ,page=yes,option=all] +% \showfontchart[filename=danlan.otf] % ,page=yes,option=all] +% \showfontchart[filename=danlan-bold.otf] % ,page=yes,option=all] % \showfontchart[filename=aegean,page=yes] % \showfontchart[filename=veramono.ttf,page=yes] diff --git a/tex/context/modules/mkiv/s-fonts-coverage.mkiv b/tex/context/modules/mkiv/s-fonts-coverage.mkiv index 2d1870842..a4ae9d211 100644 --- a/tex/context/modules/mkiv/s-fonts-coverage.mkiv +++ b/tex/context/modules/mkiv/s-fonts-coverage.mkiv @@ -31,16 +31,18 @@ \continueifinputfile{s-fonts-coverage.mkiv} +% \usemodule[fonts-coverage] + \usemodule[art-01] \starttext - \showfontcomparison - [list={texgyrepagella-regular.otf,texgyretermes-regular.otf,texgyrebonum-regular.otf}, - pattern=ogonek] - % \showfontcomparison -% [list={texgyrepagella-regular.otf,texgyretermes-regular.otf,nimbusroman-regular.afm}] +% [list={texgyrepagella-regular.otf,texgyretermes-regular.otf,texgyrebonum-regular.otf}, +% pattern=ogonek] + + \showfontcomparison + [list={texgyrepagella-regular.otf,texgyretermes-regular.otf,nimbusroman-regular.afm}] \page diff --git a/tex/context/modules/mkiv/s-fonts-shapes.lua b/tex/context/modules/mkiv/s-fonts-shapes.lua index 868c22da1..d55b1198e 100644 --- a/tex/context/modules/mkiv/s-fonts-shapes.lua +++ b/tex/context/modules/mkiv/s-fonts-shapes.lua @@ -83,16 +83,21 @@ local function showglyphshape(specification) local characters = tfmdata.characters local descriptions = tfmdata.descriptions local parameters = tfmdata.parameters + local tfmfactor = parameters.scaledpoints/10 +-- inspect(tfmdata.parameters) +-- inspect(tfmdata.properties) local anchors = fonts.helpers.collectanchors(tfmdata) - local function showonecharacter(unicode) + local function showonecharacter(unicode,krn,tight) local c = characters [unicode] local d = descriptions[unicode] if c and d then local factor = (parameters.size/parameters.units)*((7200/7227)/65536) local llx, lly, urx, ury = unpack(d.boundingbox) + local height = ury + local depth = lly llx, lly, urx, ury = llx*factor, lly*factor, urx*factor, ury*factor - local width = (d.width or 0)*factor + local width = (d.width or 0)*factor context.start() context.dontleavehmode() context.obeyMPboxdepth() @@ -110,76 +115,52 @@ local function showglyphshape(specification) context('draw boundingbox p withcolor .2white withpen pencircle scaled .065bp ;') context("defaultscale := 0.05 ; ") -- inefficient but non critical - 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 - 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 (%..t) withcolor .5white ;",l) -- why not "--" - 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]) + function slant(v,dx,dy,txt,xsign,ysign,loc,labloc,shift) + local n = #v + if n > 0 then + local l = { } + local t = { } + for i=1,n do + local c = v[i] + local h = c.height or height or 0 + local d = depth or 0 + local k = c.kern or 0 + if i == 1 then + l[1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,d*factor,dx,dy) + t[1] = formatters['draw textext.%s("\\tttf(%s,%s)") scaled .025 shifted %s shifted (%i/4,%i/3);'](labloc,k,d,l[1],shift,shift); end + l[i+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) + t[i+1] = formatters['draw textext.%s("\\tttf(%s,%s)") scaled .025 shifted %s shifted (%i/4,%i/3);'](labloc,k,h,l[i+1],shift,shift); end - 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 + context("draw laddered (%--t) withcolor .5white ;",l) + for i=1,#l do + context("draw %s withcolor blue withpen pencircle scaled 2lw ;",l[i]) + context(t[i]) end - end, - } + end + end -- local math = d.math if math then local kerns = math.kerns if kerns then - for i=1,#slant do - local s = slant[i] - for k, v in next, kerns do - if k == "topright" then - -- s(v,width+italic,0,k,1,1,"top","ulft") - s(v,width,0,k,1,1,"top","ulft") - elseif k == "bottomright" then - s(v,width,0,k,1,1,"bot","lrt") - elseif k == "topleft" then - s(v,0,0,k,-1,1,"top","ulft") - elseif k == "bottomleft" then - s(v,0,0,k,-1,1,"bot","lrt") - end + for k, v in next, kerns do + if k == "topright" and (krn == "all" or krn == k) then + slant(v,width,0,k,1,1,"top","lrt",1) + elseif k == "bottomright" and (krn == "all" or krn == k) then + slant(v,width,0,k,1,1,"bot","ulft",-1) + elseif k == "topleft" and (krn == "all" or krn == k) then + slant(v,0,0,k,-1,1,"top","lrt",1) + elseif k == "bottomleft" and (krn == "all" or krn == k) then + slant(v,0,0,k,-1,1,"bot","ulft",-1) end end end - local accent = math.accent + local accent = math.topanchor or math.accent if accent and accent ~= 0 then local a = accent * factor - context('draw (%s,%s+1bp)--(%s,%s-1bp) withcolor blue;',a,ury,a,ury) - context('label.bot("\\type{%s}",(%s,%s+1bp));',"accent",a,ury) - context('label.top("%s",(%s,%s-1bp));',math.accent,a,ury) + context('draw (%s,%s+1/4)--(%s,%s-1/4) withcolor blue;',a,ury,a,ury) + context('draw textext.top("\\tttf%s") scaled .025 shifted (%s,%s+2/4);',accent,a,ury) end end -- @@ -215,7 +196,29 @@ local function showglyphshape(specification) context('label.rt("%s",(%s-2bp,%s-1bp));',italic,width+i,ury) end context('draw origin withcolor red withpen pencircle scaled 2lw;') - context("setbounds currentpicture to boundingbox currentpicture enlarged 1bp ;") + local kern = c.topright + if kern and kern ~= 0 then + local k = kern * factor / tfmfactor + context('draw (%s,%s) withcolor "orange" withpen pencircle scaled .2 ;',width+k,ury) + end + local kern = c.bottomright + if kern and kern ~= 0 then + local k = kern * factor / tfmfactor + context('draw (%s,%s) withcolor "orange" withpen pencircle scaled .2 ;',width+k,lly) + end + local kern = c.topleft + if kern and kern ~= 0 then + local k = kern * factor / tfmfactor + context('draw (%s,%s) withcolor "orange" withpen pencircle scaled .2 ;',-k,ury) + end + local kern = c.bottomleft + if kern and kern ~= 0 then + local k = kern * factor / tfmfactor + context('draw (%s,%s) withcolor "orange" withpen pencircle scaled .2 ;',-k,lly) + end + if not tight then + context("setbounds currentpicture to boundingbox currentpicture enlarged 1bp ;") + end context("currentpicture := currentpicture scaled 8 ;") context.stopMPcode() context.stop() @@ -226,16 +229,28 @@ local function showglyphshape(specification) fonts.helpers.nametoslot(specification.character) if unicode then - showonecharacter(unicode) + showonecharacter(unicode,"all",true) else context.modulefontsstartshowglyphshapes() for unicode, description in fonts.iterators.descriptions(tfmdata) do if unicode >= 0x110000 then break end + local kerns = specification.kerns + if kerns then + local k = description and description.math and description.math.kerns + if k then + if not (kerns == "all" or k[kerns]) then + goto DONE + end + else + goto DONE + end + end context.modulefontsstartshowglyphshape(unicode,description.name or "",description.index or 0) - showonecharacter(unicode) + showonecharacter(unicode,kerns,false) context.modulefontsstopshowglyphshape() + ::DONE:: end context.modulefontsstopshowglyphshapes() end diff --git a/tex/context/modules/mkiv/s-fonts-shapes.mkiv b/tex/context/modules/mkiv/s-fonts-shapes.mkiv index 7dd39c07d..97fcbfa6c 100644 --- a/tex/context/modules/mkiv/s-fonts-shapes.mkiv +++ b/tex/context/modules/mkiv/s-fonts-shapes.mkiv @@ -30,7 +30,7 @@ \startsetups module:showallglyphshapes:start \unexpanded\def\modulefontsstartshowglyphshape##1##2##3{ - \startTEXpage[\c!offset=\exheight] % ,\c!frame=\v!on] + \startTEXpage[\c!offset=\exheight]% ,\c!frame=\v!on] \edef\lastshownglyphshapefieldunicode{##1}% \edef\lastshownglyphshapefieldname {##2}% \edef\lastshownglyphshapefieldindex {##3}% @@ -106,8 +106,11 @@ % \startTEXpage \ShowGlyphShape{simplenaskhi}{100bp}{0xF0299} \stopTEXpage % \startTEXpage \ShowGlyphShape{simplenaskhi}{100bp}{NameMe.1190} \stopTEXpage - \startTEXpage[offset=0pt]\ShowGlyphShape{file:stixtwomath-regular.otf}{20bp}{0x1D44A}\stopTEXpage - \startTEXpage[offset=0pt]\ShowGlyphShape{file:stixtwomath-regular.otf}{20bp}{0x1D44C}\stopTEXpage +% \startTEXpage[offset=0pt]\ShowGlyphShape{file:stixtwomath-regular.otf}{20bp}{0x1D44A}\stopTEXpage +% \startTEXpage[offset=0pt]\ShowGlyphShape{file:stixtwomath-regular.otf}{20bp}{0x1D44C}\stopTEXpage + +% \definefontfeature[tg][goodies=pagella-math] +% \startTEXpage[offset=0pt]\ShowGlyphShape{file:texgyrepagella-math.otf*tg}{20bp}{0x002F}\stopTEXpage % \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{20bp}{0x00066}\stopTEXpage % \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{20bp}{0x1D453}\stopTEXpage @@ -126,7 +129,12 @@ % \startTEXpage[offset=0pt]\ShowGlyphShape{file:husayninotebold.ttf}{50bp}{0x006DD}\stopTEXpage % \startTEXpage[offset=0pt]\ShowGlyphShape{file:arabtype.ttf}{50bp}{0x0FCA1}\stopTEXpage -% \showallglyphshapes[name=name:cambria-math,size=100bp] +\showallglyphshapes[name=name:cambria-math,size=100bp,kerns=bottomright] +% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{100bp}{0x1D6FD}\stopTEXpage + +% \showallglyphshapes[name=file:lucidabrightmathot,size=100bp,kerns=all] +% \showallglyphshapes[name=file:garamondmath,size=100bp,kerns=bottomright] + % \showallglyphshapes[name=name:arabtype,size=100bp] % \showallglyphshapes[name=file:husayninotebold.ttf,size=100bp] % \showallglyphshapes[name=name:dejavuserif,size=100bp] diff --git a/tex/context/modules/mkiv/s-math-characters.lua b/tex/context/modules/mkiv/s-math-characters.lua index b634a203f..a967f7934 100644 --- a/tex/context/modules/mkiv/s-math-characters.lua +++ b/tex/context/modules/mkiv/s-math-characters.lua @@ -185,7 +185,7 @@ function moduledata.math.characters.showlist(specification) round(char.height or 0), round(char.depth or 0), round(char.italic or 0), - round(char.topaccent or 0) + round(char.topanchor or char.topaccent or 0) ) end if virtual and commands then |