diff options
Diffstat (limited to 'tex/context/base/font-ini.lua')
-rw-r--r-- | tex/context/base/font-ini.lua | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/tex/context/base/font-ini.lua b/tex/context/base/font-ini.lua index 5db2973a1..248a2baca 100644 --- a/tex/context/base/font-ini.lua +++ b/tex/context/base/font-ini.lua @@ -10,34 +10,44 @@ if not modules then modules = { } end modules ['font-ini'] = { <p>Not much is happening here.</p> --ldx]]-- +local utf = unicode.utf8 + +if not fontloader then fontloader = fontforge end + +fontloader.totable = fontloader.to_table + -- vtf comes first -- fix comes last -fonts = fonts or { } +fonts = fonts or { } +fonts.ids = fonts.ids or { } -- aka fontdata +fonts.tfm = fonts.tfm or { } -fonts.trace = false -- true fonts.mode = 'base' -fonts.private = 0xE000 +fonts.private = 0xF0000 -- 0x10FFFF fonts.verbose = false -- more verbose cache tables -fonts.methods = { +fonts.methods = fonts.methods or { base = { tfm = { }, afm = { }, otf = { }, vtf = { }, fix = { } }, node = { tfm = { }, afm = { }, otf = { }, vtf = { }, fix = { } }, } -fonts.initializers = { +fonts.initializers = fonts.initializers or { base = { tfm = { }, afm = { }, otf = { }, vtf = { }, fix = { } }, node = { tfm = { }, afm = { }, otf = { }, vtf = { }, fix = { } } } -fonts.triggers = { +fonts.triggers = fonts.triggers or { 'mode', 'language', 'script', 'strategy', } -fonts.manipulators = { +fonts.processors = fonts.processors or { +} + +fonts.manipulators = fonts.manipulators or { } fonts.define = fonts.define or { } @@ -48,18 +58,35 @@ fonts.define.specify.synonyms = fonts.define.specify.synonyms or { } fonts.color = fonts.color or { } -fonts.color.trace = false - -local attribute = attributes.numbers['color'] or 7 -- we happen to know this -) -local mapping = attributes.list[attribute] +local attribute = attributes.private('color') +local mapping = (attributes and attributes.list[attribute]) or { } local set_attribute = node.set_attribute local unset_attribute = node.unset_attribute function fonts.color.set(n,c) --- local mc = mapping[c] if mc then unset_attribute((n,attribute) else set_attribute(n,attribute,mc) end - set_attribute(n,attribute,mapping[c] or -1) -- also handles -1 now + local mc = mapping[c] + if not mc then + unset_attribute(n,attribute) + else + set_attribute(n,attribute,mc) + end end function fonts.color.reset(n) unset_attribute(n,attribute) end + +-- this will change ... + +function fonts.show_char_data(n) + local tfmdata = fonts.ids[font.current()] + if tfmdata then + if type(n) == "string" then + n = utf.byte(n) + end + local chr = tfmdata.characters[n] + if chr then + texio.write_nl(table.serialize(chr,string.format("U_%04X",n))) + end + end +end |