summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-04-24 14:06:06 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-04-24 14:06:06 +0200
commit8c3e40f3dc42ec1b5b6cce8f7ee5bbe7b66ddfd0 (patch)
tree42fe1c39e53282c1acb6f54aa73be5f5e0a925f1
parent76a913948ef596f93a548004f70e933523d13baf (diff)
downloadluaotfload-8c3e40f3dc42ec1b5b6cce8f7ee5bbe7b66ddfd0.tar.gz
[aux] make slot_of_name API more robust
-rw-r--r--src/luaotfload-auxiliary.lua37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index c927471..fc2a191 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -263,20 +263,27 @@ end
--- int -> string -> bool -> (int | false)
local slot_of_name = function (font_id, glyphname, unsafe)
- local fontdata = identifiers[font_id]
- if fontdata then
- local unicode = fontdata.resources.unicodes[glyphname]
- if unicode then
- if type(unicode) == "number" then
- return unicode
- else
- return unicode[1] --- for multiple components
- end
--- else
--- --- missing
+ if not font_id or type (font_id) ~= "number"
+ or not glyphname or type (glyphname) ~= "string"
+ then
+ logreport ("both", 0, "aux",
+ "invalid parameters to slot_of_name (%s, %s)",
+ tostring (font_id), tostring (glyphname))
+ return false
+ end
+
+ local tfmdata = identifiers [font_id]
+ if not tfmdata then return raw_slot_of_name (font_id, glyphname) end
+ local resources = tfmdata.resources if not resources then return false end
+ local unicodes = resources.unicodes if not unicodes then return false end
+
+ local unicode = unicodes [glyphname]
+ if unicode then
+ if type (unicode) == "number" then
+ return unicode
+ else
+ return unicode [1] --- for multiple components
end
- elseif unsafe == true then -- for Robert
- return raw_slot_of_name(font_id, glyphname)
end
return false
end
@@ -335,7 +342,7 @@ local provides_script = function (font_id, asked_script)
or not asked_script or type (asked_script) ~= "string"
then
logreport ("both", 0, "aux",
- "invalid parameters to provides_language(%s, %s)",
+ "invalid parameters to provides_script(%s, %s)",
tostring (font_id), tostring (asked_script))
return false
end
@@ -467,7 +474,7 @@ local provides_feature = function (font_id, asked_script,
or not asked_feature or type (asked_feature) ~= "string"
then
logreport ("both", 0, "aux",
- "invalid parameters to provides_language(%s, %s, %s, %s)",
+ "invalid parameters to provides_feature(%s, %s, %s, %s)",
tostring (font_id), tostring (asked_script),
tostring (asked_language), tostring (asked_feature))
return false