diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-22 14:10:51 -0700 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-22 14:10:51 -0700 |
commit | 00a2e2b6f095ba547dda795e263de9a5eb3f8f8f (patch) | |
tree | c08247d89db9980d05192f41d0843ea60843d75c | |
parent | 1b1890c3b306e42a451465e64c5dbd8f0f094303 (diff) | |
parent | 6c1bb8b5c6de06598e28af43dd16e21b1741e56b (diff) | |
download | luaotfload-00a2e2b6f095ba547dda795e263de9a5eb3f8f8f.tar.gz |
Merge pull request #89 from phi-gamma/master
cygwin patch; import aux functions removed from fontspec into legacy codebase
-rw-r--r-- | luaotfload-database.lua | 27 | ||||
-rw-r--r-- | luaotfload-legacy-database.lua | 4 | ||||
-rw-r--r-- | luaotfload-legacy.lua | 136 |
3 files changed, 144 insertions, 23 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua index ee7701d..60e321f 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -990,29 +990,14 @@ do path_normalize = function (path) path = stringgsub(path, '\\', '/') path = stringlower(path) - path = stringgsub(path, '^/cygdrive/(%a)/', '%1:/') - path = filecollapsepath(path) - return path - end - - elseif os_name == "cygwin" then -- union of ms + unix - path_normalize = function (path) - path = stringgsub(path, '\\', '/') - path = stringlower(path) - path = stringgsub(path, '^/cygdrive/(%a)/', '%1:/') - local dest = lfsreadlink(path) - if dest then - if kpsereadable_file(dest) then - path = dest - elseif kpsereadable_file(filejoin(filedirname(path), dest)) then - path = filejoin(file.dirname(path), dest) - else - -- broken symlink? - end - end path = filecollapsepath(path) return path end +--[[doc-- + Cygwin used to be treated different from windows and dos. This + special treatment was removed with a patch submitted by Ken Brown. + Reference: http://cygwin.com/ml/cygwin/2013-05/msg00006.html +--doc]]-- else -- posix path_normalize = function (path) @@ -1379,7 +1364,7 @@ local function get_os_dirs() "/System/Library/Fonts", "/Network/Library/Fonts", } - elseif os.type == "windows" or os.type == "msdos" or os.name == "cygwin" then + elseif os.type == "windows" or os.type == "msdos" then local windir = os.getenv("WINDIR") return { filejoin(windir, 'Fonts') } else diff --git a/luaotfload-legacy-database.lua b/luaotfload-legacy-database.lua index 4af05f5..b31fe88 100644 --- a/luaotfload-legacy-database.lua +++ b/luaotfload-legacy-database.lua @@ -425,7 +425,7 @@ local function path_normalize(path) - reading symlinks under non-Win32 - using kpse.readable_file on Win32 ]] - if os.type == "windows" or os.type == "msdos" or os.name == "cygwin" then + if os.type == "windows" or os.type == "msdos" then path = path:gsub('\\', '/') path = path:lower() path = path:gsub('^/cygdrive/(%a)/', '%1:/') @@ -635,7 +635,7 @@ local function get_os_dirs() "/System/Library/Fonts", "/Network/Library/Fonts", } - elseif os.type == "windows" or os.type == "msdos" or os.name == "cygwin" then + elseif os.type == "windows" or os.type == "msdos" then local windir = os.getenv("WINDIR") return { file.join(windir, 'Fonts') } else diff --git a/luaotfload-legacy.lua b/luaotfload-legacy.lua index e0c2230..8bb1790 100644 --- a/luaotfload-legacy.lua +++ b/luaotfload-legacy.lua @@ -263,4 +263,140 @@ end luatexbase.add_to_callback("luaotfload.patch_font", set_sscale_diments, "unicodemath.set_sscale_diments") +--[[doc-- + Version 2.3c of fontspec dropped a couple features that are now + provided in the luaotfload auxiliary libraries. To avoid breaking + Mik\TEX (again), which is sorta the entire point of distributing the + legacy codebase, we temporarily restore those functions here. + + Note that apart from cosmetic changes these are still the same as in + pre-TL2013 fontspec, relying on pairs() and other inefficient methods. +--doc]]-- + +luaotfload.aux = luaotfload.aux or { } +local aux = luaotfload.aux + +local stringlower = string.lower +local fontid = font.id + +local identifiers = fonts.identifiers + +local check_script = function (id, script) + local s = stringlower(script) + if id and id > 0 then + local tfmdata = identifiers[id] + local otfdata = tfmdata.shared and tfmdata.shared.otfdata + if otfdata then + local features = otfdata.luatex.features + for i, _ in pairs(features) do + for j, _ in pairs(features[i]) do + if features[i][j][s] then + fontspec.log("script '%s' exists in font '%s'", + script, tfmdata.fullname) + return true + end + end + end + end + end +end + +local check_language = function (id, script, language) + local s = stringlower(script) + local l = stringlower(language) + if id and id > 0 then + local tfmdata = identifiers[id] + local otfdata = tfmdata.shared and tfmdata.shared.otfdata + if otfdata then + local features = otfdata.luatex.features + for i, _ in pairs(features) do + for j, _ in pairs(features[i]) do + if features[i][j][s] and features[i][j][s][l] then + fontspec.log("language '%s' for script '%s' exists in font '%s'", + language, script, tfmdata.fullname) + return true + end + end + end + end + end +end + +local check_feature = function (id, script, language, feature) + local s = stringlower(script) + local l = stringlower(language) + local f = stringlower(feature:gsub("^[+-]", ""):gsub("=.*$", "")) + if id and id > 0 then + local tfmdata = identifiers[id] + local otfdata = tfmdata.shared and tfmdata.shared.otfdata + if otfdata then + local features = otfdata.luatex.features + for i, _ in pairs(features) do + if features[i][f] and features[i][f][s] then + if features[i][f][s][l] == true then + fontspec.log("feature '%s' for language '%s' and script '%s' exists in font '%s'", + feature, language, script, tfmdata.fullname) + return true + end + end + end + end + end +end + +local get_math_dimension = function(fnt, str) + if type(fnt) == "string" then + fnt = fontid(fnt) + end + local tfmdata = identifiers[fnt] + if tfmdata then + local mathdata = tfmdata.MathConstants + if mathdata then + return mathdata[str] + end + end +end + +aux.provides_script = check_script +aux.provides_language = check_language +aux.provides_feature = check_feature +aux.get_math_dimension = get_math_dimension + +local set_capheight = function (tfmdata) + local capheight + local shared = tfmdata.shared + if shared then + local metadata = shared.otfdata.metadata + local units_per_em = metadata.units_per_em or tfmdata.units + local os2_capheight = shared.otfdata.pfminfo.os2_capheight + local size = tfmdata.size + + if os2_capheight > 0 then + capheight = os2_capheight / units_per_em * size + else + local X8 = string.byte"X" + if tfmdata.characters[X8] then + capheight = tfmdata.characters[X8].height + else + capheight = metadata.ascent / units_per_em * size + end + end + else + local X8 = string.byte"X" + if tfmdata.characters[X8] then + capheight = tfmdata.characters[X8].height + end + end + if capheight then + tfmdata.parameters[8] = capheight + end +end +luatexbase.add_to_callback("luaotfload.patch_font", + set_capheight, + "luaotfload.set_capheight") + +--[[doc-- +End of auxiliary functionality that was moved from fontspec.lua. +--doc]]-- + -- vim:ts=2:sw=2:expandtab:ft=lua |