From 18340b7b6238d2c9362bd6920c9b7031f7dd794a Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sat, 5 Jun 2010 23:15:57 +0300 Subject: 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.) --- luaotfload.dtx | 18 ++++++++++-------- 1 file 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 -- cgit v1.2.3