diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2009-08-23 11:11:32 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2009-08-23 11:11:32 +0000 |
commit | 8fc3039c82d48605b5ca8b2eda3f4fdd755681e1 (patch) | |
tree | 3cd9bbdd599bc4d1ac0409e167fee2136e4c0ec9 /Master/texmf-dist/tex/context/base/font-chk.lua | |
parent | 850fc99b7cd3ae7a20065531fe866ff7bae642ec (diff) |
this is context 2009.08.19 17:10
git-svn-id: svn://tug.org/texlive/trunk@14827 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/font-chk.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/font-chk.lua | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/font-chk.lua b/Master/texmf-dist/tex/context/base/font-chk.lua new file mode 100644 index 00000000000..382f671d8a8 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/font-chk.lua @@ -0,0 +1,76 @@ +if not modules then modules = { } end modules ['font-chk'] = { + version = 1.001, + comment = "companion to font-ini.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- possible optimization: delayed initialization of vectors + +fonts = fonts or { } +fonts.checkers = fonts.checkers or { } + +local checkers = fonts.checkers +local fontdata = fonts.ids +local is_character = characters.is_character +local chardata = characters.data + +local glyph = node.id('glyph') +local traverse_id = node.traverse_id +local remove_node = nodes.remove + +-- maybe in fonts namespace +-- deletion can be option + +checkers.enabled = false +checkers.delete = false + +function fonts.register_message(font,char,message) + local tfmdata = fontdata[font] + local shared = tfmdata.shared + local messages = shared.messages + if not messages then + messages = { } + shared.messages = messages + end + local category = messages[message] + if not category then + category = { } + messages[message] = category + end + if not category[char] then + logs.report("fonts","char U+%04X in font '%s' with id %s: %s",char,tfmdata.fullname,font,message) + category[char] = true + end +end + +function checkers.missing(head) + if checkers.enabled then + local lastfont, characters, found = nil, nil, nil + for n in traverse_id(glyph,head) do + local font, char = n.font, n.char + if font ~= lastfont then + characters = fontdata[font].characters + end + if not characters[char] and is_character[chardata[char].category] then + if checkers.delete then + fonts.register_message(font,char,"missing (will be deleted)") + else + fonts.register_message(font,char,"missing") + end + if not found then + found = { n } + else + found[#found+1] = n + end + end + end + if found and checkers.delete then + for i=1,#found do + head = remove_node(head,found[i],true) + end + end + end + return head, false +end |