s-fonts-overlay.mkiv /size: 3297 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [      file=s-fonts-overlay,
3%D        version=2018.03.25,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Show Glyph Similarity,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14% begin info
15%
16% title   : overlay glyphs in fonts
17%
18% comment : show glyphs in two fonts
19% status  : experimental, used for font feature development
20%
21% end info
22
23%D This module is for Luigi/Idris as part of the Husayni development where the
24%D gpos pair, single, mark and cursive features are just linear transformations.
25
26\startmodule[fonts-coverage]
27
28\unprotect
29
30\definecolor[ColorOne][r=1,t=.5,a=1]
31\definecolor[ColorTwo][b=1,t=.5,a=1]
32
33\startluacode
34    moduledata.fonts         = moduledata.fonts         or { }
35    moduledata.fonts.overlay = moduledata.fonts.overlay or { }
36
37    function moduledata.fonts.overlay(id)
38        for k, v in table.sortedhash(fonts.hashes.identifiers[id or true].characters) do
39            context.showoverlayedglyphs(k)
40        end
41    end
42\stopluacode
43
44\starttexdefinition unexpanded showoverlayedglyphs#1
45    \startTEXpage[offset=.25\scratchdimentwo,height=10\scratchdimentwo,width=4\scratchdimenone]
46        \ruledhbox to \hsize\bgroup
47            \hss
48            \FontOne\setstrut\strut\showglyphs
49            \startoverlay
50                {\ColorOne\ruledhbox{\FontOne\char#1}}
51                {\ColorTwo\ruledhbox{\FontTwo\char#1}}
52            \stopoverlay
53            \hss
54        \egroup
55        \vfill
56        \dontleavehmode
57        \hbox to \hsize\bgroup
58            \hss
59            \infofont0x\uchexnumbers{#1}
60            \hss
61       \egroup
62   \stopTEXpage
63\stoptexdefinition
64
65\starttexdefinition unexpanded showoverlayedfonts[#1]
66    \start
67        \getdummyparameters[\c!list=,#1]
68        \doifsomething {\dummyparameter\c!list} {
69            \page
70            \getfromcommacommand[\dummyparameter\c!list][1]\let\NameOne\commalistelement
71            \getfromcommacommand[\dummyparameter\c!list][2]\let\NameTwo\commalistelement
72            \definefont[FontOne][\NameOne]
73            \definefont[FontTwo][\NameTwo]
74            \FontOne\expandafter\edef\expandafter\OneID\expandafter{\number\fontid\font}%
75            \FontTwo\expandafter\edef\expandafter\TwoID\expandafter{\number\fontid\font}%
76            \scratchdimenone\emwidth
77            \scratchdimentwo\exheight
78            \ctxlua{moduledata.fonts.overlay(\OneID)}%
79            \page
80          % \startTEXpage[offset=.25\scratchdimentwo,height=10\scratchdimentwo,width=4\scratchdimenone]
81          %     \vfill
82          %     \hbox to \hsize{\ColorOne\infofont\hss\OneN\hss}
83          %     \vfill
84          %     \hbox to \hsize{\ColorTwo\infofont\hss\TwoN\hss}
85          %     \vfill
86          % \stopTEXpage
87          % \page
88        }
89    \stop
90\stoptexdefinition
91
92\protect
93
94\stopmodule
95
96\continueifinputfile{s-fonts-overlay.mkiv}
97
98\starttext
99
100%     \showoverlayedfonts
101%       [list={file:husayni-script-regular.ttf @ 48.0pt,
102%              file:husayni-note-bold.ttf      @ 34.2pt}] % 34.18726pt
103
104    \showoverlayedfonts
105      [list={Serif,SerifBold}]
106
107\stoptext
108