summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luaotfload/fontloader-font-onr.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/fontloader-font-onr.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luaotfload/fontloader-font-onr.lua62
1 files changed, 35 insertions, 27 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-font-onr.lua b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-font-onr.lua
index 6c33b24c644..7c806c69206 100644
--- a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-font-onr.lua
+++ b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-font-onr.lua
@@ -41,7 +41,7 @@ handlers.afm = afm
local readers = afm.readers or { }
afm.readers = readers
-afm.version = 1.512 -- incrementing this number one up will force a re-cache
+afm.version = 1.513 -- incrementing this number one up will force a re-cache
--[[ldx--
<p>We start with the basic reader which we give a name similar to the built in <l n='tfm'/>
@@ -89,7 +89,7 @@ do
local dup = P("dup")
local put = P("put")
local array = P("array")
- local name = P("/") * C((R("az")+R("AZ")+R("09")+S("-_."))^1)
+ local name = P("/") * C((R("az","AZ","09")+S("-_."))^1)
local digits = R("09")^1
local cardinal = digits / tonumber
local spaces = P(" ")^1
@@ -103,32 +103,40 @@ do
return position + 1
end
- local setroutine = function(str,position,index,size)
+ local setroutine = function(str,position,index,size,filename)
local forward = position + tonumber(size)
- local stream = sub(str,position+1,forward)
- routines[index] = decrypt(stream,4330,4)
+ local stream = decrypt(sub(str,position+1,forward),4330,4)
+ routines[index] = { byte(stream,1,#stream) }
return forward
end
- local setvector = function(str,position,name,size)
+ local setvector = function(str,position,name,size,filename)
local forward = position + tonumber(size)
if n >= m then
return #str
elseif forward < #str then
+ if n == 0 and name ~= ".notdef" then
+ report_pfb("reserving .notdef at index 0 in %a",filename) -- luatex needs that
+ n = n + 1
+ end
vector[n] = name
- n = n + 1 -- we compensate for notdef at the cff loader end
+ n = n + 1
return forward
else
return #str
end
end
- local setshapes = function(str,position,name,size)
+ local setshapes = function(str,position,name,size,filename)
local forward = position + tonumber(size)
local stream = sub(str,position+1,forward)
if n > m then
return #str
elseif forward < #str then
+ if n == 0 and name ~= ".notdef" then
+ report_pfb("reserving .notdef at index 0 in %a",filename) -- luatex needs that
+ n = n + 1
+ end
vector[n] = name
n = n + 1
chars [n] = decrypt(stream,4330,4)
@@ -144,15 +152,15 @@ do
local p_filterroutines = -- dup <i> <n> RD or -| <n encrypted bytes> NP or |
(1-subroutines)^0 * subroutines * spaces * Cmt(cardinal,initialize)
- * (Cmt(cardinal * spaces * cardinal * p_rd, setroutine) * p_np + P(1))^1
+ * (Cmt(cardinal * spaces * cardinal * p_rd * Carg(1), setroutine) * p_np + P(1))^1
local p_filtershapes = -- /foo <n> RD <n encrypted bytes> ND
(1-charstrings)^0 * charstrings * spaces * Cmt(cardinal,initialize)
- * (Cmt(name * spaces * cardinal * p_rd, setshapes) * p_nd + P(1))^1
+ * (Cmt(name * spaces * cardinal * p_rd * Carg(1) , setshapes) * p_nd + P(1))^1
local p_filternames = Ct (
(1-charstrings)^0 * charstrings * spaces * Cmt(cardinal,initialize)
- * (Cmt(name * spaces * cardinal, setvector) + P(1))^1
+ * (Cmt(name * spaces * cardinal * Carg(1), setvector) + P(1))^1
)
-- /Encoding 256 array
@@ -177,7 +185,7 @@ do
return
end
- if not (find(data,"!PS%-AdobeFont%-") or find(data,"%%!FontType1")) then
+ if not (find(data,"!PS-AdobeFont-",1,true) or find(data,"%!FontType1",1,true)) then
report_pfb("no font in %a",filename)
return
end
@@ -192,14 +200,14 @@ do
binary = decrypt(binary,55665,4)
local names = { }
+
local encoding = lpegmatch(p_filterencoding,ascii)
local glyphs = { }
routines, vector, chars = { }, { }, { }
-
if shapestoo then
- lpegmatch(p_filterroutines,binary)
- lpegmatch(p_filtershapes,binary)
+ lpegmatch(p_filterroutines,binary,1,filename)
+ lpegmatch(p_filtershapes,binary,1,filename)
local data = {
dictionaries = {
{
@@ -209,9 +217,9 @@ do
}
},
}
- fonts.handlers.otf.readers.parsecharstrings(data,glyphs,true,true)
+ fonts.handlers.otf.readers.parsecharstrings(false,data,glyphs,true,true)
else
- lpegmatch(p_filternames,binary)
+ lpegmatch(p_filternames,binary,1,filename)
end
names = vector
@@ -233,7 +241,7 @@ do
if trace_loading then
report_afm("getting index data from %a",pfbname)
end
- for index=1,#vector do
+ for index=0,#vector do -- hm, zero, often space or notdef
local name = vector[index]
local char = characters[name]
if char then
@@ -241,6 +249,10 @@ do
report_afm("glyph %a has index %a",name,index)
end
char.index = index
+ else
+ if trace_indexing then
+ report_afm("glyph %a has index %a but no data",name,index)
+ end
end
end
end
@@ -410,10 +422,6 @@ local fullparser = ( P("StartFontMetrics") * fontdata * name / start )
* ( p_charmetrics + p_kernpairs + p_parameters + (1-P("EndFontMetrics")) )^0
* ( P("EndFontMetrics") / stop )
-local fullparser = ( P("StartFontMetrics") * fontdata * name / start )
- * ( p_charmetrics + p_kernpairs + p_parameters + (1-P("EndFontMetrics")) )^0
- * ( P("EndFontMetrics") / stop )
-
local infoparser = ( P("StartFontMetrics") * fontdata * name / start )
* ( p_parameters + (1-P("EndFontMetrics")) )^0
* ( P("EndFontMetrics") / stop )
@@ -463,17 +471,17 @@ function readers.loadfont(afmname,pfbname)
local data = read(resolvers.findfile(afmname),fullparser)
if data then
if not pfbname or pfbname == "" then
- pfbname = file.replacesuffix(file.nameonly(afmname),"pfb")
- pfbname = resolvers.findfile(pfbname)
+ pfbname = resolvers.findfile(file.replacesuffix(file.nameonly(afmname),"pfb"))
end
if pfbname and pfbname ~= "" then
data.resources.filename = resolvers.unresolve(pfbname)
get_indexes(data,pfbname)
- elseif trace_loading then
+ return data
+ else -- if trace_loading then
report_afm("no pfb file for %a",afmname)
- -- data.resources.filename = "unset" -- better than loading the afm file
+ -- better than loading the afm file: data.resources.filename = rawname
+ -- but that will still crash the backend so we just return nothing now
end
- return data
end
end