diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-11-06 11:08:14 -0800 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-11-06 11:08:14 -0800 |
commit | adb03528f61cd71d61aa66bb237222c070fd3d3a (patch) | |
tree | 6753700cee1e69851a5ba7eea78f73bdad85e558 | |
parent | 90e060ed1717f6a14cf06bc394cf857782a7c140 (diff) | |
parent | 1eba3465773d90ac51f961bd74f6addb649ec0df (diff) | |
download | luaotfload-2.4-beta.tar.gz |
Merge pull request #146 from phi-gamma/masterv2.4-beta
restore some of the earlier behavior (fallbacks, live db reload)
-rw-r--r-- | luaotfload-database.lua | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua index d8d4a6f..d25b846 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -580,6 +580,17 @@ local italic_synonym = { italic = true, } +local style_category = { + regular = "r", + bold = "b", + bolditalic = "bi", + italic = "i", + r = "regular", + b = "bold", + bi = "bolditalic", + i = "italic", +} + local type1_formats = { "tfm", "ofm", } local dummy_findfile = resolvers.findfile -- from basics-gen @@ -991,17 +1002,43 @@ local resolve_familyname = function (specification, name, style, askedsize) return resolved, subfont end -local resolve_fontname = function (specification, name) - local mappings = name_index.mappings +local resolve_fontname = function (specification, name, style) + local mappings = name_index.mappings + local fallback = nil + local lastresort = nil + style = style_category [style] for i = 1, #mappings do local face = mappings [i] + local prefmodifiers = face.prefmodifiers + local subfamily = face.subfamily if face.fontname == name or face.fullname == name or face.psname == name then return face.basename, face.subfont + elseif face.familyname == name then + if prefmodifiers == style + or subfamily == style + then + fallback = face + elseif regular_synonym [prefmodifiers] + or regular_synonym [subfamily] + then + lastresort = face + end + elseif face.metafamily == name + and (regular_synonym [prefmodifiers] + or regular_synonym [subfamily]) + then + lastresort = face end end + if fallback then + return fallback.basename, fallback.subfont + end + if lastresort then + return lastresort.basename, lastresort.subfont + end return nil, nil end @@ -1072,13 +1109,26 @@ resolve_name = function (specification) end end - resolved, subfont = resolve_familyname (specification, name, style, askedsize) + resolved, subfont = resolve_familyname (specification, + name, + style, + askedsize) if not resolved then - resolved, subfont = resolve_fontname (specification, name) + resolved, subfont = resolve_fontname (specification, + name, + style) end if not resolved then resolved = specification.name, false end + + if not resolved then + if not fonts_reloaded then + return reload_db ("Font not found.", + resolve_name, + specification) + end + end return resolved, subfont end |