summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-07-01 00:30:57 +0900
committerNorbert Preining <norbert@preining.info>2019-07-01 00:30:57 +0900
commit51aaddbb2460fc2494ce04f70a10246ea4d733f1 (patch)
tree34f3a4be7c7e1a5965548e49197721d09409a401
parent013aaa686be931c83cccfc67af2ae96f0019876e (diff)
harf 0.3.1
-rw-r--r--texmf-dist/tex/generic/harftex/harf-load.lua55
-rw-r--r--texmf-dist/tex/generic/harftex/harfload.sty2
2 files changed, 38 insertions, 19 deletions
diff --git a/texmf-dist/tex/generic/harftex/harf-load.lua b/texmf-dist/tex/generic/harftex/harf-load.lua
index 06af2706..9ab05783 100644
--- a/texmf-dist/tex/generic/harftex/harf-load.lua
+++ b/texmf-dist/tex/generic/harftex/harf-load.lua
@@ -108,21 +108,6 @@ local function loadfont(spec)
local gid = hbfont:get_nominal_glyph(0x0020)
local space = gid and hbfont:get_glyph_h_advance(gid) or upem / 2
- local xheight, capheight = nil, nil
- if hasos2 then
- local os2 = hbface:get_table(os2tag)
- local length = os2:get_length()
- local data = os2:get_data()
- if length >= 96 and string.unpack(">H", data) > 1 then
- -- We don’t need much of the table, so we read from hard-coded offsets.
- xheight = string.unpack(">H", data, 87)
- capheight = string.unpack(">H", data, 89)
- end
- end
-
- xheight = xheight or ascender / 2
- capheight = capheight or ascender
-
local slant = 0
if haspost then
local post = hbface:get_table(posttag)
@@ -182,6 +167,36 @@ local function loadfont(spec)
characters[uni] = hbfont:get_nominal_glyph(uni)
end
+ local xheight, capheight = 0, 0
+ if hasos2 then
+ local os2 = hbface:get_table(os2tag)
+ local length = os2:get_length()
+ local data = os2:get_data()
+ if length >= 96 and string.unpack(">H", data) > 1 then
+ -- We don’t need much of the table, so we read from hard-coded offsets.
+ xheight = string.unpack(">H", data, 87)
+ capheight = string.unpack(">H", data, 89)
+ end
+ end
+
+ if xheight == 0 then
+ local gid = characters[120] -- x
+ if gid then
+ xheight = glyphs[gid].height
+ else
+ xheight = ascender / 2
+ end
+ end
+
+ if capheight == 0 then
+ local gid = characters[88] -- X
+ if gid then
+ capheight = glyphs[gid].height
+ else
+ capheight = ascender
+ end
+ end
+
data = {
face = hbface,
font = hbfont,
@@ -237,7 +252,6 @@ local function scalefont(data, spec)
local hbfont = data.font
local upem = data.upem
local space = data.space
- local capheight = data.capheight
if size < 0 then
size = -655.36 * size
@@ -271,7 +285,12 @@ local function scalefont(data, spec)
local palettes = data.palettes
local palette = palettes and palettes[tonumber(options.palette) or 1]
- local letterspace = tonumber(options.letterspace or 0) / 100 * upem
+ local letterspace = 0
+ if options.letterspace then
+ letterspace = tonumber(options.letterspace) / 100 * upem
+ elseif options.kernfactor then
+ letterspace = tonumber(options.kernfactor) * upem
+ end
space = space + letterspace
local slantfactor = nil
@@ -340,7 +359,7 @@ local function scalefont(data, spec)
x_height = data.xheight * scale,
quad = size,
extra_space = space * scale / 3,
- [8] = capheight * scale, -- for XeTeX compatibility.
+ [8] = data.capheight * scale, -- for XeTeX compatibility.
},
hb = {
scale = scale,
diff --git a/texmf-dist/tex/generic/harftex/harfload.sty b/texmf-dist/tex/generic/harftex/harfload.sty
index 4f8cf4df..9675b10d 100644
--- a/texmf-dist/tex/generic/harftex/harfload.sty
+++ b/texmf-dist/tex/generic/harftex/harfload.sty
@@ -2,7 +2,7 @@
\let\ifharfloadloaded\endinput
\ifdefined\ProvidesPackage
\RequirePackage{luaotfload}
- \ProvidesPackage{harfload}[2019/06/24 v0.3.0 Unicode text layout system]
+ \ProvidesPackage{harfload}[2019/06/30 v0.3.1 Unicode text layout system]
\else
\input luaotfload.sty
\fi