summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/font-chk.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/font-chk.lua94
1 files changed, 34 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua b/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua
index ab145ce4d8f..3613432c1e0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua
@@ -66,12 +66,14 @@ local hpack_node = node.hpack
local nuts = nodes.nuts
local tonut = nuts.tonut
+local tonode = nuts.tonode
-local isglyph = nuts.isglyph
-local setchar = nuts.setchar
+local getfont = nuts.getfont
+local getchar = nuts.getchar
-local nextglyph = nuts.traversers.glyph
+local setchar = nuts.setchar
+local traverse_id = nuts.traverse_id
local remove_node = nuts.remove
local insert_node_after = nuts.insert_after
@@ -140,7 +142,7 @@ local mapping = allocate { -- this is just an experiment to illustrate some prin
table.setmetatableindex(mapping,
function(t,k)
- local v = "placeholder unknown gray"
+ v = "placeholder unknown gray"
t[k] = v
return v
end
@@ -194,10 +196,7 @@ local variants = allocate {
{ tag = "yellow", r = .6, g = .6, b = 0 },
}
--- bah .. low level pdf ... should be a rule or plugged in
-
------ pdf_blob = "pdf: q %.6F 0 0 %.6F 0 0 cm %s %s %s rg %s %s %s RG 10 M 1 j 1 J 0.05 w %s Q"
-local pdf_blob = "q %.6F 0 0 %.6F 0 0 cm %s %s %s rg %s %s %s RG 10 M 1 j 1 J 0.05 w %s Q"
+local pdf_blob = "pdf: q %.6F 0 0 %.6F 0 0 cm %s %s %s rg %s %s %s RG 10 M 1 j 1 J 0.05 w %s Q"
local cache = { } -- saves some tables but not that impressive
@@ -236,8 +235,8 @@ local function addmissingsymbols(tfmdata) -- we can have an alternative with rul
width = size*fake.width,
height = size*fake.height,
depth = size*fake.depth,
- -- commands = { { "special", formatters[pdf_blob](scale,scale,r,g,b,r,g,b,fake.code) } }
- commands = { { "pdf", formatters[pdf_blob](scale,scale,r,g,b,r,g,b,fake.code) } }
+ -- bah .. low level pdf ... should be a rule or plugged in
+ commands = { { "special", formatters[pdf_blob](scale,scale,r,g,b,r,g,b,fake.code) } }
}
cache[hash] = char
end
@@ -279,7 +278,7 @@ end
local function placeholder(font,char)
local tfmdata = fontdata[font]
- local category = chardata[char].category or "unknown"
+ local category = chardata[char].category
local fakechar = mapping[category]
local slot = getprivateslot(font,fakechar)
if not slot then
@@ -293,12 +292,15 @@ checkers.placeholder = placeholder
function checkers.missing(head)
local lastfont, characters, found = nil, nil, nil
- for n, char, font in nextglyph, head do -- faster than while loop so we delay removal
+ head = tonut(head)
+ for n in traverse_id(glyph_code,head) do -- faster than while loop so we delay removal
+ local font = getfont(n)
+ local char = getchar(n)
if font ~= lastfont then
characters = fontcharacters[font]
lastfont = font
end
- if font > 0 and not characters[char] and is_character[chardata[char].category or "unknown"] then
+ if font > 0 and not characters[char] and is_character[chardata[char].category] then
if action == "remove" then
onetimemessage(font,char,"missing (will be deleted)")
elseif action == "replace" then
@@ -322,8 +324,7 @@ function checkers.missing(head)
elseif action == "replace" then
for i=1,#found do
local node = found[i]
- local char, font = isglyph(node)
- local kind, char = placeholder(font,char)
+ local kind, char = placeholder(getfont(node),getchar(node))
if kind == "node" then
insert_node_after(head,node,tonut(char))
head = remove_node(head,node,true)
@@ -336,7 +337,7 @@ function checkers.missing(head)
else
-- maye write a report to the log
end
- return head
+ return tonode(head), false
end
local relevant = {
@@ -361,9 +362,6 @@ local function getmissing(id)
local messages = shared and shared.messages
if messages then
local filename = d.properties.filename
- if not filename then
- filename = tostring(d)
- end
local tf = t[filename] or { }
for i=1,#relevant do
local tm = messages[relevant[i]]
@@ -392,6 +390,7 @@ checkers.getmissing = getmissing
do
local reported = true
+ local tracked = false
callback.register("glyph_not_found",function(font,char)
if font > 0 then
@@ -409,6 +408,7 @@ do
trackers.register("fonts.missing", function(v)
if v then
enableaction("processors","fonts.checkers.missing")
+ tracked = true
else
disableaction("processors","fonts.checkers.missing")
end
@@ -419,25 +419,27 @@ do
end)
logs.registerfinalactions(function()
- local collected, details = getmissing()
- if next(collected) then
- for filename, list in sortedhash(details) do
- logs.startfilelogging(report,"missing characters",filename)
- for u, v in sortedhash(list) do
- report("%4i %U %c %s",v,u,u,chardata[u].description)
- end
- logs.stopfilelogging()
- end
- if logs.loggingerrors() then
+-- if tracked then
+ local collected, details = getmissing()
+ if next(collected) then
for filename, list in sortedhash(details) do
- logs.starterrorlogging(report,"missing characters",filename)
+ logs.startfilelogging(report,"missing characters",filename)
for u, v in sortedhash(list) do
report("%4i %U %c %s",v,u,u,chardata[u].description)
end
- logs.stoperrorlogging()
+ logs.stopfilelogging()
+ end
+ if logs.loggingerrors() then
+ for filename, list in sortedhash(details) do
+ logs.starterrorlogging(report,"missing characters",filename)
+ for u, v in sortedhash(list) do
+ report("%4i %U %c %s",v,u,u,chardata[u].description)
+ end
+ logs.stoperrorlogging()
+ end
end
end
- end
+-- end
end)
end
@@ -505,31 +507,3 @@ local dummies_specification = {
registerotffeature(dummies_specification)
registerafmfeature(dummies_specification)
-
---
-
-local function addvisualspace(tfmdata)
- local spacechar = tfmdata.characters[32]
- if spacechar and not spacechar.commands then
- local w = spacechar.width
- local h = tfmdata.parameters.xheight
- local c = {
- width = w,
- commands = { { "rule", h, w } }
- }
- local u = addprivate(tfmdata, "visualspace", c)
- end
-end
-
-local visualspace_specification = {
- name = "visualspace",
- description = "visual space",
- default = true,
- manipulators = {
- base = addvisualspace,
- node = addvisualspace,
- }
-}
-
-registerotffeature(visualspace_specification)
-registerafmfeature(visualspace_specification)