diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua | 154 |
1 files changed, 90 insertions, 64 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua index 89bf51b4d83..c50e0cdb647 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua @@ -2,10 +2,8 @@ ----------------------------------------------------------------------- -- FILE: luaotfload-auxiliary.lua -- DESCRIPTION: part of luaotfload --- REQUIREMENTS: luaotfload 2.5 +-- REQUIREMENTS: luaotfload 2.6 -- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang --- VERSION: 2.5 --- MODIFIED: 2014-01-02 21:24:25+0100 ----------------------------------------------------------------------- -- @@ -19,6 +17,7 @@ local aux = luaotfload.aux local log = luaotfload.log local report = log.report local fonthashes = fonts.hashes +local encodings = fonts.encodings local identifiers = fonthashes.identifiers local fontnames = fonts.names @@ -64,7 +63,7 @@ aux.start_rewrite_fontname = start_rewrite_fontname local stop_rewrite_fontname = function () if rewriting == true then - luatexbase.remove_fromt_callback + luatexbase.remove_from_callback ("luaotfload.patch_font", "luaotfload.rewrite_fontname") rewriting = false report ("log", 1, "aux", @@ -129,6 +128,35 @@ luatexbase.add_to_callback( "luaotfload.patch_font", patch_cambria_domh, "luaotfload.aux.patch_cambria_domh") + + +--[[doc-- + + Add missing field to fonts that lack it. Addresses issue + https://github.com/lualatex/luaotfload/issues/253 + + This is considered a hack, especially since importing the + unicode-math package fixes the problem quite nicely. + +--doc]]-- + +--- fontobj -> unit +local fixup_fontdata = function (data) + + local t = type (data) + --- Some OT fonts like Libertine R lack the resources table, causing + --- the fontloader to nil-index. + if t == "table" then + if data and not data.resources then data.resources = { } end + end + +end + +luatexbase.add_to_callback( + "luaotfload.patch_font_unsafe", + fixup_fontdata, + "luaotfload.aux.fixup_fontdata") + --[[doc-- @@ -185,8 +213,6 @@ luatexbase.add_to_callback( --- glyphs and characters ----------------------------------------------------------------------- -local agl = fonts.encodings.agl - --- int -> int -> bool local font_has_glyph = function (font_id, codepoint) local fontdata = fonts.hashes.identifiers[font_id] @@ -203,7 +229,7 @@ aux.font_has_glyph = font_has_glyph local raw_slot_of_name = function (font_id, glyphname) local fontdata = font.fonts[font_id] if fontdata.type == "virtual" then --- get base font for glyph idx - local codepoint = agl.unicodes[glyphname] + local codepoint = encodings.agl.unicodes[glyphname] local glyph = fontdata.characters[codepoint] if fontdata.characters[codepoint] then return codepoint @@ -264,7 +290,7 @@ local indices --- int -> (string | false) local name_of_slot = function (codepoint) if not indices then --- this will load the glyph list - local unicodes = agl.unicodes + local unicodes = encodings.agl.unicodes indices = table.swapped(unicodes) end local glyphname = indices[codepoint] @@ -417,25 +443,25 @@ least one feature. local provides_script = function (font_id, asked_script) asked_script = stringlower(asked_script) if font_id and font_id > 0 then - local fontdata = identifiers[font_id].shared.rawdata - if fontdata then - local fontname = fontdata.metadata.fontname - local features = fontdata.resources.features - for method, featuredata in next, features do - --- where method: "gpos" | "gsub" - for feature, data in next, featuredata do - if data[asked_script] then - report ("log", 1, "aux", - "font no %d (%s) defines feature %s for script %s", - font_id, fontname, feature, asked_script) - return true - end + local tfmdata = identifiers[font_id] if not tfmdata then return false end + local shared = tfmdata.shared if not shared then return false end + local fontdata = shared.rawdata if not fontdata then return false end + local fontname = fontdata.metadata.fontname + local features = fontdata.resources.features + for method, featuredata in next, features do + --- where method: "gpos" | "gsub" + for feature, data in next, featuredata do + if data[asked_script] then + report ("log", 1, "aux", + "font no %d (%s) defines feature %s for script %s", + font_id, fontname, feature, asked_script) + return true end end - report ("log", 0, "aux", - "font no %d (%s) defines no feature for script %s", - font_id, fontname, asked_script) end + report ("log", 0, "aux", + "font no %d (%s) defines no feature for script %s", + font_id, fontname, asked_script) end report ("log", 0, "aux", "no font with id %d", font_id) return false @@ -455,29 +481,29 @@ local provides_language = function (font_id, asked_script, asked_language) asked_script = stringlower(asked_script) asked_language = stringlower(asked_language) if font_id and font_id > 0 then - local fontdata = identifiers[font_id].shared.rawdata - if fontdata then - local fontname = fontdata.metadata.fontname - local features = fontdata.resources.features - for method, featuredata in next, features do - --- where method: "gpos" | "gsub" - for feature, data in next, featuredata do - local scriptdata = data[asked_script] - if scriptdata and scriptdata[asked_language] then - report ("log", 1, "aux", - "font no %d (%s) defines feature %s " - .. "for script %s with language %s", - font_id, fontname, feature, - asked_script, asked_language) - return true - end + local tfmdata = identifiers[font_id] if not tfmdata then return false end + local shared = tfmdata.shared if not shared then return false end + local fontdata = shared.rawdata if not fontdata then return false end + local fontname = fontdata.metadata.fontname + local features = fontdata.resources.features + for method, featuredata in next, features do + --- where method: "gpos" | "gsub" + for feature, data in next, featuredata do + local scriptdata = data[asked_script] + if scriptdata and scriptdata[asked_language] then + report ("log", 1, "aux", + "font no %d (%s) defines feature %s " + .. "for script %s with language %s", + font_id, fontname, feature, + asked_script, asked_language) + return true end end - report ("log", 0, "aux", - "font no %d (%s) defines no feature " - .. "for script %s with language %s", - font_id, fontname, asked_script, asked_language) end + report ("log", 0, "aux", + "font no %d (%s) defines no feature " + .. "for script %s with language %s", + font_id, fontname, asked_script, asked_language) end report ("log", 0, "aux", "no font with id %d", font_id) return false @@ -527,29 +553,29 @@ local provides_feature = function (font_id, asked_script, asked_feature = lpegmatch(strip_garbage, asked_feature) if font_id and font_id > 0 then - local fontdata = identifiers[font_id].shared.rawdata - if fontdata then - local features = fontdata.resources.features - local fontname = fontdata.metadata.fontname - for method, featuredata in next, features do - --- where method: "gpos" | "gsub" - local feature = featuredata[asked_feature] - if feature then - local scriptdata = feature[asked_script] - if scriptdata and scriptdata[asked_language] then - report ("log", 1, "aux", - "font no %d (%s) defines feature %s " - .. "for script %s with language %s", - font_id, fontname, asked_feature, - asked_script, asked_language) - return true - end + local tfmdata = identifiers[font_id] if not tfmdata then return false end + local shared = tfmdata.shared if not shared then return false end + local fontdata = shared.rawdata if not fontdata then return false end + local features = fontdata.resources.features + local fontname = fontdata.metadata.fontname + for method, featuredata in next, features do + --- where method: "gpos" | "gsub" + local feature = featuredata[asked_feature] + if feature then + local scriptdata = feature[asked_script] + if scriptdata and scriptdata[asked_language] then + report ("log", 1, "aux", + "font no %d (%s) defines feature %s " + .. "for script %s with language %s", + font_id, fontname, asked_feature, + asked_script, asked_language) + return true end end - report ("log", 0, "aux", - "font no %d (%s) does not define feature %s for script %s with language %s", - font_id, fontname, asked_feature, asked_script, asked_language) end + report ("log", 0, "aux", + "font no %d (%s) does not define feature %s for script %s with language %s", + font_id, fontname, asked_feature, asked_script, asked_language) end report ("log", 0, "aux", "no font with id %d", font_id) return false |