Fix read_vf
This commit is contained in:
parent
2c68c0223a
commit
23d93b55ac
@ -9,10 +9,11 @@ local function read_fonts(buf, i, fonts, size)
|
|||||||
if not cmd then return i end
|
if not cmd then return i end
|
||||||
local fid, check, scale, designsize, arealen, namelen, i =
|
local fid, check, scale, designsize, arealen, namelen, i =
|
||||||
string.unpack(cmd, buf, i + 1)
|
string.unpack(cmd, buf, i + 1)
|
||||||
|
fid = fid + 1 -- We prefer 1-based arrays
|
||||||
local fsize = size * scale >> 20
|
local fsize = size * scale >> 20
|
||||||
if fonts[fid] then error[[font number reused in VF file]] end
|
if fonts[fid] then error[[font number reused in VF file]] end
|
||||||
fonts[fid] = {
|
fonts[fid] = {
|
||||||
area = string.sub(buf, i, i+arealen-1),
|
area = arealen > 0 and string.sub(buf, i, i+arealen-1) or nil,
|
||||||
name = string.sub(buf, i+arealen, i+arealen+namelen-1),
|
name = string.sub(buf, i+arealen, i+arealen+namelen-1),
|
||||||
size = fsize,
|
size = fsize,
|
||||||
designsize = designsize >> 4,
|
designsize = designsize >> 4,
|
||||||
@ -134,9 +135,9 @@ local function read_chars(buf, i, characters, size)
|
|||||||
if cmd >= 235 then
|
if cmd >= 235 then
|
||||||
cmd, i = string.unpack(Cmds[cmd-234], buf, i + 1)
|
cmd, i = string.unpack(Cmds[cmd-234], buf, i + 1)
|
||||||
else
|
else
|
||||||
i = i + 1
|
cmd, i = cmd - 171, i + 1
|
||||||
end
|
end
|
||||||
commands[#commands + 1] = { "font", cmd }
|
commands[#commands + 1] = { "font", cmd + 1 } -- 1-based fonts
|
||||||
elseif xxx[cmd] then
|
elseif xxx[cmd] then
|
||||||
cmd, i = string.unpack(xxx[cmd], buf, i + 1)
|
cmd, i = string.unpack(xxx[cmd], buf, i + 1)
|
||||||
commands[#commands + 1] = { "special", cmd }
|
commands[#commands + 1] = { "special", cmd }
|
||||||
@ -161,16 +162,17 @@ local function parse_vf(buf, i, size)
|
|||||||
i = read_fonts(buf, i, fonts, size)
|
i = read_fonts(buf, i, fonts, size)
|
||||||
i = read_chars(buf, i, characters, size)
|
i = read_chars(buf, i, characters, size)
|
||||||
|
|
||||||
print(require'inspect'(font))
|
return font
|
||||||
end
|
end
|
||||||
local basename = ((1-lpeg.S'\\/')^0*lpeg.S'\\/')^0*lpeg.C((1-lpeg.P'.tfm'*-1)^0)
|
local basename = ((1-lpeg.S'\\/')^0*lpeg.S'\\/')^0*lpeg.C((1-lpeg.P'.tfm'*-1)^0)
|
||||||
return function(name, size, must_exist)
|
return function(name, size, must_exist)
|
||||||
local filename = kpse.find_file(name, 'vf', must_exist)
|
local filename = kpse.find_file(name, 'vf', must_exist)
|
||||||
|
if not filename then return end
|
||||||
local f = io.open(filename)
|
local f = io.open(filename)
|
||||||
if not f then return end
|
if not f then return end
|
||||||
local buf = f:read'*a'
|
local buf = f:read'*a'
|
||||||
f:close()
|
f:close()
|
||||||
local result = parse_tfm(buf, 1, size)
|
local result = parse_vf(buf, 1, size)
|
||||||
result.name = basename:match(name)
|
result.name = basename:match(name)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,6 @@ local function doublekeyed(t, id2name, name2id, index)
|
|||||||
end
|
end
|
||||||
local nodehandler = (function()
|
local nodehandler = (function()
|
||||||
local function unknown_handler(_, n, x, y)
|
local function unknown_handler(_, n, x, y)
|
||||||
print(node.type(10))
|
|
||||||
write(format("Sorry, but the PDF backend does not support %q (id = %i) nodes right now. The supplied node will be dropped at coordinates (%i, %i).", node.type(getid(n)), getid(n), x//1, y//1))
|
write(format("Sorry, but the PDF backend does not support %q (id = %i) nodes right now. The supplied node will be dropped at coordinates (%i, %i).", node.type(getid(n)), getid(n), x//1, y//1))
|
||||||
end
|
end
|
||||||
return doublekeyed({}, node.type, node.id, function()
|
return doublekeyed({}, node.type, node.id, function()
|
||||||
|
Loading…
Reference in New Issue
Block a user