ws-arch2: font/type1 (PFB / PFA, eexec, Subrs / CharStrings, Type 1 charstrings with flex / hint replacement / seac, AGL code points, rasterize; read) vs fontTools and FreeType; codecs/font/GlyphNames
This commit is contained in:
1 parent
0ee0859298
commit
53b41c7275
5 files changed
+231
-9
No files matched your search
@@ -65,9 +65,7 @@ function Charstring.run(cs: buffer, ctx: Context): (Result?, string?)
|
||||
end
|
||||
end
|
||||
local function lineTo(dx: number, dy: number)
|
||||
local first = not open
|
||||
ensureOpen()
|
||||
local _ = first
|
||||
x += dx
|
||||
y += dy
|
||||
local c: any = { op = "lineTo" }
|
||||
@@ -242,11 +240,12 @@ function Charstring.run(cs: buffer, ctx: Context): (Result?, string?)
|
||||
elseif op == 1206 then -- seac: asb adx ady bchar achar
|
||||
local asb, adx, ady, bchar, achar = arg(1), arg(2), arg(3), arg(4), arg(5)
|
||||
sp = 0
|
||||
if not ctx.seac then
|
||||
local seac = ctx.seac
|
||||
if not seac then
|
||||
return "seac without base glyphs"
|
||||
end
|
||||
local base = ctx.seac(bchar)
|
||||
local accent = ctx.seac(achar)
|
||||
local base = seac(bchar)
|
||||
local accent = seac(achar)
|
||||
if not base or not accent then
|
||||
return "seac of a missing glyph"
|
||||
end
|
||||
|
||||
@@ -224,10 +224,11 @@ function Type1.decode(r: Bytes.Reader, opts: DecodeOptions?): (any, Err.Err?)
|
||||
if sAt and sAt < csAt then
|
||||
local p = sAt
|
||||
while true do
|
||||
local s, e, idx, len = string.find(ptext, "dup%s+(%d+)%s+(%d+)%s+%S+ ", p)
|
||||
local s, e0, idx, len = string.find(ptext, "dup%s+(%d+)%s+(%d+)%s+%S+ ", p)
|
||||
if not s or s > csAt then
|
||||
break
|
||||
end
|
||||
local e = e0 :: number
|
||||
local i, n = tonumber(idx) :: number, tonumber(len) :: number
|
||||
if i > 65535 then
|
||||
return nil, Err.new(Err.LIMIT, "too many subroutines")
|
||||
@@ -246,10 +247,11 @@ function Type1.decode(r: Bytes.Reader, opts: DecodeOptions?): (any, Err.Err?)
|
||||
local byName: { [string]: number } = {}
|
||||
local p = csAt + 12
|
||||
while true do
|
||||
local s, e, name, len = string.find(ptext, "/([^%s/%[%]{}()<>]+)%s+(%d+)%s+%S+ ", p)
|
||||
local s, e0, name, len = string.find(ptext, "/([^%s/%[%]{}()<>]+)%s+(%d+)%s+%S+ ", p)
|
||||
if not s then
|
||||
break
|
||||
end
|
||||
local e = e0 :: number
|
||||
-- stop at the end of the dictionary
|
||||
if string.find(string.sub(ptext, p, s), "%send%s") then
|
||||
break
|
||||
@@ -356,7 +358,8 @@ function Type1.decode(r: Bytes.Reader, opts: DecodeOptions?): (any, Err.Err?)
|
||||
if not g then
|
||||
return nil
|
||||
end
|
||||
return Charstring.run(charstrings[g + 1], { subrs = subrs })
|
||||
local res = Charstring.run(charstrings[g + 1], { subrs = subrs })
|
||||
return res
|
||||
end,
|
||||
}
|
||||
return font, nil
|
||||
|
||||
Reference in new issue
Block a user