diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/fontspec/fontspec.lua')
-rw-r--r-- | Master/texmf-dist/tex/latex/fontspec/fontspec.lua | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec.lua b/Master/texmf-dist/tex/latex/fontspec/fontspec.lua index a6b5528391a..869bc5879dd 100644 --- a/Master/texmf-dist/tex/latex/fontspec/fontspec.lua +++ b/Master/texmf-dist/tex/latex/fontspec/fontspec.lua @@ -36,14 +36,14 @@ function fontspec.sprint (...) tex.sprint(luatexbase.catcodetables['latex-packag local function check_script(id, script) local s = string.lower(script) if id and id > 0 then - local otfdata = fonts.ids[id].shared.otfdata + local otfdata = fonts.identifiers[id].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, fonts.ids[id].fullname) + script, fonts.identifiers[id].fullname) return true end end @@ -55,14 +55,14 @@ local function check_language(id, language, script) local s = string.lower(script) local l = string.lower(language) if id and id > 0 then - local otfdata = fonts.ids[id].shared.otfdata + local otfdata = fonts.identifiers[id].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, fonts.ids[id].fullname) + language, script, fonts.identifiers[id].fullname) return true end end @@ -75,14 +75,14 @@ local function check_feature(id, feature, language, script) local l = string.lower(language) local f = string.lower(feature:gsub("^[+-]", "")) if id and id > 0 then - local otfdata = fonts.ids[id].shared.otfdata + local otfdata = fonts.identifiers[id].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, fonts.ids[id].fullname) + feature, language, script, fonts.identifiers[id].fullname) return true end end @@ -120,7 +120,7 @@ function fontspec.check_ot_feat(fnt, feat, lang, script) end end function fontspec.mathfontdimen(fnt, str) - local mathdimens = fonts.ids[font.id(fnt)].MathConstants + local mathdimens = fonts.identifiers[font.id(fnt)].MathConstants if mathdimens then local m = mathdimens[str] if m then @@ -133,6 +133,24 @@ function fontspec.mathfontdimen(fnt, str) fontspec.sprint("0pt") end end +local function set_capheight(fontdata) + local capheight + local units = fontdata.units + local size = fontdata.size + local otfdata = fontdata.shared.otfdata + + if otfdata.pfminfo.os2_capheight > 0 then + capheight = otfdata.pfminfo.os2_capheight / units * size + else + if fontdata.characters[string.byte("X")] then + capheight = fontdata.characters[string.byte("X")].height + else + capheight = otfdata.metadata.ascent / units * size + end + end + fontdata.parameters[8] = capheight +end +luatexbase.add_to_callback("luaotfload.patch_font", set_capheight, "fontspec.set_capheight") -- -- Copyright 2004--2011 Will Robertson <wspr81@gmail.com> -- Copyright 2009--2010 Khaled Hosny <khaledhosny@eglug.org> |