summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-fonts-overlay.mkiv
blob: fccc977d472a1aa9070bfc795e98cbb109914500 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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