summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/s-fnt-31.mkiv
blob: 3cd689d9719a57d68b937c97cc1d2804d9f10df0 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
%D \module
%D   [      file=s-fnt-31,
%D        version=2011.01.02, % about
%D          title=\CONTEXT\ Style File,
%D       subtitle=Comparing Fonts,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%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   : compare glyphs in fonts
%
% comment : show glyphs in several fonts alongside in order to to compare coverage
% status  : experimental, used for luatex testing
%
% end info

\startluacode

local format, upper, find = string.format, string.upper, string.find
local chardata = characters.data

function fonts.tracers.coverage(fontfiles,pattern) -- todo: patterns

    local present, names = { }, { }
    local pattern = pattern and upper(pattern)

    for i=1,#fontfiles do
        local fontname = format("testfont-%s",i)
        local fontfile = fontfiles[i]
        local fontsize = tex.dimen.bodyfontsize
        local id, fontdata = fonts.definers.define {
            name = fontfile,
            size = fontsize,
            cs   = fontname,
        }
        for k, v in next, fontdata.characters do
            present[k] = true
        end
        names[i] = fontname
    end

    context.starttabulate {"|Tr" .. string.rep("|l",#names) .. "|" }
        for i=1,#names do
            context.NC()
            context(i)
            context.NC()
         -- context.getvalue(names[i])
            context.type(fontfiles[i])
            context.NC()
            context.NR()
        end
    context.stoptabulate()

    context.starttabulate {"|Tl" .. string.rep("|c",#names) .. "|Tl|" }
        context.NC()
        context.type("unicode")
        context.NC()
        for i=1,#names do
            context.type(i)
            context.NC()
        end
        context.type("description")
        context.NC()
        context.NR()
        context.HL()
        for k, v in table.sortedpairs(present) do
            local description = chardata[k].description
            if not pattern or (pattern == k) or (description and find(description,pattern)) then
                context.NC()
                context(format("%05X",k))
                context.NC()
                for i=1,#names do
                    context.getvalue(names[i])
                    context.char(k)
                    context.NC()
                end
                context(description)
                context.NC()
                context.NR()
            end
        end
    context.stoptabulate()

end

\stopluacode

\doifnotmode{demo}{\endinput}

\setupbodyfont[10pt]

\setuplayout
  [backspace=1cm,
   topspace=1cm,
   footer=1cm,
   header=0cm,
   height=middle,
   width=middle]

\starttext

% \startluacode
%     fonts.tracers.coverage {
%         "pirat.ttf",
%     }
% \stopluacode

% \startluacode
%     fonts.tracers.coverage {
%      -- "cambria.ttf",
%         "lbr.afm",
%         "LucidaBrightRegular.ttf",
%         "lbi.afm",
%         "LucidaBrightItalic.ttf",
%         "lbd.afm",
%         "LucidaBrightDemiBold.ttf",
%         "lbdi.afm",
%         "LucidaBrightDemiItalic.ttf",
%     }
% \stopluacode

% \startluacode
%     fonts.tracers.coverage ( {
%         "LucidaBrightRegular.ttf",
%         "cambria.ttf",
%         "iwona-regular.otf",
%         "texgyrepagella-regular.otf",
%         "texgyretermes-regular.otf",
%         "texgyrebonum-regular.otf",
%         "antpolt-regular.otf",
%     }, "OGONEK")
% \stopluacode

% \loadfontgoodies[lucida-math]
% \loadfontgoodies[lm-math]

% \startluacode
%     fonts.tracers.coverage {
%         "LucidaBrightRegular.ttf",
%         "LucidaBrightOne@lucida-math",
%         "cambria.ttc(Cambria Math)",
%         "xits-math.otf",
%         "LMMath10-Regular@lmroman10-math",
%     }
% \stopluacode

\loadfontgoodies[px-math]
\loadfontgoodies[lm-math]

\startluacode
    fonts.tracers.coverage {
        "cambria.ttc(Cambria Math)",
        "xits-math.otf",
        "LMMath10-Regular@lmroman10-math",
        "pxmath@px-math",
     -- "LinLibertine_Re-4.7.5.otf",
    }
\stopluacode

\stoptext