Progress on vf fonts
This commit is contained in:
parent
23d93b55ac
commit
bb955cb1c3
@ -53,14 +53,33 @@ function font.define(f)
|
||||
font.fonts[i] = f
|
||||
return i
|
||||
end
|
||||
callback_register('define_font', function(name, size)
|
||||
local function base_define_font_cb(name, size)
|
||||
local f = read_tfm(name, size)
|
||||
if not f then return end
|
||||
local vf = read_vf(name, size)
|
||||
if vf then
|
||||
local fonts = {}
|
||||
f.fonts = fonts
|
||||
for i, f in next, vf.fonts do
|
||||
if vf.id then
|
||||
fonts[i] = f
|
||||
else
|
||||
fonts[i] = {id = assert(base_define_font_cb(f.name, f.size))}
|
||||
end
|
||||
end
|
||||
f.type = 'virtual'
|
||||
local realchars = f.characters
|
||||
for cp, char in next, vf.characters do
|
||||
assert(realchars[cp]).commands = char.commands
|
||||
end
|
||||
end
|
||||
local id = font.define(f)
|
||||
if status.ini_version then
|
||||
lua.prepared_code[#lua.prepared_code+1] = string.format("assert(%i == font.define(font.read_tfm(%q, %i)))", id, name, size)
|
||||
end
|
||||
return id
|
||||
end)
|
||||
end
|
||||
callback_register('define_font', base_define_font_cb)
|
||||
callback_register('find_log_file', function(name) return name end)
|
||||
do
|
||||
local function normal_find_data_file(name)
|
||||
|
@ -354,14 +354,14 @@ local function do_commands(p, c, f, fid, x, y, outer, ...)
|
||||
nodehandler[getid(cmd)](p, cmd, x, y, nil, ...)
|
||||
x = x + getwidth(cmd)
|
||||
elseif cmd[1] == "font" then
|
||||
current_font = fonts[cmd[2]]
|
||||
current_font = assert(fonts[cmd[2]], "invalid font requested")
|
||||
elseif cmd[1] == "char" then
|
||||
local n = direct.new'glyph'
|
||||
setsubtype(n, 256)
|
||||
setfont(n, current_font.id, cmd[2])
|
||||
nodehandler.glyph(p, n, x, y, outer, ...)
|
||||
direct.free(n)
|
||||
x = x + getwidth(n)
|
||||
direct.free(n)
|
||||
elseif cmd[1] == "slot" then
|
||||
local n = direct.new'glyph'
|
||||
setsubtype(n, 256)
|
||||
@ -401,10 +401,6 @@ local function do_commands(p, c, f, fid, x, y, outer, ...)
|
||||
-- else
|
||||
-- NOP, comment and invalid commands ignored
|
||||
end
|
||||
if #commands ~= 1 then error[[Unsupported command number]] end
|
||||
if commands[1][1] ~= "node" then error[[Unsupported command name]] end
|
||||
commands = commands[1][2]
|
||||
nodehandler[getid(commands)](p, commands, x, y, nil, ...)
|
||||
end
|
||||
end
|
||||
function nodehandler.glyph(p, n, x, y, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user