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
|
if not modules then modules = { } end modules ['font-fmp'] = {
version = 1.001,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
-- We only need to pick up the filename and optionally the enc file as we only use
-- them for old school virtual math fonts. We might as well drop this completely.
-- This used to be a backend module but the code is rather generic so for now we
-- just put it here.
--
-- As Type 1 is kind of obsolete I don't expect usage of those fonts in ways that
-- are not yet covered. Actually, we don't need map files at all because we read the
-- afm files. Maybe for math but there at some point we'll ditch the virtual old
-- school variants because afaik ConTeXt users are not using these any longer.
local find, match, splitlines = string.find, string.match, string.splitlines
local implement = interfaces.implement
local mappings = { }
local function setline(n)
if trace_fonts then
report_fonts("mapline: %s",n)
end
local name, fullname, encfile, pfbfile = match(n,"(%S+)%s+(%S+).-<(.-%.enc).-<(.-%.pfb)")
if name then
mappings[name] = { fullname, encfile, pfbfile }
end
end
local function setfile(n)
local okay, data = resolvers.loadbinfile(n,"map")
if okay and data then
data = splitlines(data)
for i=1,#data do
local d = data[i]
if d ~= "" and not find(d,"^[#%%]") then
setline(d)
end
end
end
end
local function getentry(n)
local n = file.nameonly(n)
local m = mappings[n]
if m then
local encfile = m[2]
local encoding = fonts.encodings.load(encfile)
if not encoding then
return
end
local pfbfile = resolvers.findfile(m[3],"pfb")
if not pfbfile or pfbfile == "" then
return
end
return encoding, pfbfile, encfile
end
end
-- soon to be obsolete:
local mappings = fonts.mappings or { }
fonts.mappings = mappings
local loaded = { -- prevent loading (happens in cont-sys files)
-- ["original-base.map" ] = true,
-- ["original-ams-base.map" ] = true,
-- ["original-ams-euler.map"] = true,
-- ["original-public-lm.map"] = true,
}
function mappings.loadfile(name)
name = file.addsuffix(name,"map")
if not loaded[name] then
if trace_mapfiles then
report_mapfiles("loading map file %a",name)
end
setfile(name)
loaded[name] = true
end
end
local loaded = { -- prevent double loading
}
function mappings.loadline(how,line)
if line then
how = how .. " " .. line
elseif how == "" then
how = "= " .. line
end
if not loaded[how] then
if trace_mapfiles then
report_mapfiles("processing map line %a",line)
end
setline(how)
loaded[how] = true
end
end
function mappings.reset()
local setmapfile = lpdf and lpdf.setmapfile
if setmapfile then
setmapfile("") -- tricky ... backend related
end
end
mappings.getentry = getentry
implement {
name = "loadmapfile",
actions = mappings.loadfile,
arguments = "string"
}
implement {
name = "loadmapline",
actions = mappings.loadline,
arguments = "string"
}
implement {
name = "resetmapfiles",
actions = mappings.reset,
arguments = "string"
}
|