summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Robertson <wspr81@gmail.com>2010-06-05 16:37:07 +0930
committerWill Robertson <wspr81@gmail.com>2010-06-05 16:37:07 +0930
commitba9845b7c34e114ddd122adaf9264bbd8da41fe0 (patch)
tree3d2eabe80df132eba30b8f2c74beb030a39f81b5
parent44dcbbcef3d06f80747407f0c70c57e1ab1fe76c (diff)
downloadluaotfload-ba9845b7c34e114ddd122adaf9264bbd8da41fe0.tar.gz
add \fontdimen8 support from Khaled
closes #7
-rw-r--r--luaotfload.dtx37
1 files changed, 37 insertions, 0 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx
index f4d39f6..1e4e338 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -597,6 +597,43 @@ function luaotfload.unregister_callbacks()
'luaotfload.find_vf_file')
end
% \end{macrocode}
+%
+% \subsection{Emulating font dimensions}
+%
+% And here add some code to emulate \XeTeX's \cs{fontdimen8},
+% which stores the caps-height of the font. (Cf.\ \cs{fontdimen5} which
+% stores the x-height.)
+%
+% Falls back to measuring the glyph if the font doesn't contain the
+% necessary information.
+% This needs to be extended for fonts that don't contain an `X'.
+%
+% \begin{macrocode}
+local function def_font(...)
+ local fontdata = fonts.define.read(...)
+ if fontdata then
+ 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
+ end
+
+ fontdata.parameters[8] = dimen8
+ end
+ return fontdata
+end
+luatexbase.reset_callback('define_font')
+luatexbase.add_to_callback('define_font',
+ def_font,
+ 'luaotfload.define_font', 1)
+% \end{macrocode}
+%
% \iffalse
%</lua>
% \fi