diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2010-06-05 23:15:57 +0300 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2010-06-05 23:15:57 +0300 |
commit | 18340b7b6238d2c9362bd6920c9b7031f7dd794a (patch) | |
tree | 56de5bb0a6e751429aac62f5908c778ae40cb6e8 /luaotfload.dtx | |
parent | f4a1b50c01c511bb4deb382f81d3b8f633bce4d0 (diff) | |
download | luaotfload-18340b7b6238d2c9362bd6920c9b7031f7dd794a.tar.gz |
Improve capheight guessing a bit
We first check if the font have a non-zero os2_capheight and use it,
else we use the height of "X" glyph, else we set capheight to the font's
ascender. The later can be improved by checking certain glyphs in other
scripts (Greek, Cyrillic etc.)
Diffstat (limited to 'luaotfload.dtx')
-rw-r--r-- | luaotfload.dtx | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx index 2be5db8..a593b4e 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -570,19 +570,21 @@ luaotfload.loadmodule('font-clr.lua') local function def_font(...) local fontdata = fonts.define.read(...) if fontdata then + local capheight local units = fontdata.units local size = fontdata.size local otfdata = fontdata.shared.otfdata - local capheight = otfdata.pfminfo.os2_capheight - - local dimen8 = capheight/units*size - - if capheight <= 0 then - dimen8 = fontdata.characters[string.byte("X")].height + 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] = dimen8 + fontdata.parameters[8] = capheight end return fontdata end |