Fix TTF component subsetting
This commit is contained in:
parent
5427ac4ab8
commit
087bbc013d
@ -9,19 +9,19 @@ local function round(x)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function addglyph(glyph, usedcids, cidtogid)
|
local function addglyph(glyph, usedcids, cidtogid)
|
||||||
-- FIXME: Pseudocode
|
|
||||||
if string.unpack(">i2", glyph) < 0 then -- We have a composite glyph.
|
if string.unpack(">i2", glyph) < 0 then -- We have a composite glyph.
|
||||||
-- This is an untested mess. Disaster will follow.
|
-- This is a mess. Disaster will follow.
|
||||||
local offset = 11
|
local offset = 11
|
||||||
while offset do
|
while offset do
|
||||||
local flags, component = string.unpack(">I2I2", glyph, offset)
|
local flags, component = string.unpack(">I2I2", glyph, offset)
|
||||||
local gid = cidtogid[component]
|
local gid = cidtogid[component]
|
||||||
|
print(glyph, component, gid)
|
||||||
if not gid then
|
if not gid then
|
||||||
gid = #usedcids+1
|
gid = #usedcids
|
||||||
usedcids[gid] = {component}
|
usedcids[gid+1] = {component}
|
||||||
cidtogid[component] = gid
|
cidtogid[component] = gid
|
||||||
end
|
end
|
||||||
glyph = glyph:sub(1, offset-1) .. string.pack(">I2", gid).. glyph:sub(offset+2)
|
glyph = glyph:sub(1, offset+1) .. string.pack(">I2", gid).. glyph:sub(offset+4)
|
||||||
offset = flags&32==32 and offset + 4 + (flags&1==1 and 4 or 2) + (flags&8==8 and 2 or (flags&64==64 and 4 or (flags&128==128 and 8 or 0)))
|
offset = flags&32==32 and offset + 4 + (flags&1==1 and 4 or 2) + (flags&8==8 and 2 or (flags&64==64 and 4 or (flags&128==128 and 8 or 0)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user