summaryrefslogtreecommitdiff
path: root/luaotfload.dtx
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-06-05 23:09:05 +0300
committerKhaled Hosny <khaledhosny@eglug.org>2010-06-05 23:09:05 +0300
commitf4a1b50c01c511bb4deb382f81d3b8f633bce4d0 (patch)
tree2229aa1e9c9e0204ac9aef002e07dc14c4893808 /luaotfload.dtx
parentba9845b7c34e114ddd122adaf9264bbd8da41fe0 (diff)
downloadluaotfload-f4a1b50c01c511bb4deb382f81d3b8f633bce4d0.tar.gz
Suffle the code around to actually work
Diffstat (limited to 'luaotfload.dtx')
-rw-r--r--luaotfload.dtx70
1 files changed, 33 insertions, 37 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx
index 1e4e338..2be5db8 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -556,6 +556,38 @@ luaotfload.loadmodule('font-clr.lua')
% \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
+% \end{macrocode}
+%
% \subsection{\ConTeXt\ override}
%
% Here we override some defaults set in \ConTeXt\ code.
@@ -579,7 +611,7 @@ function luaotfload.register_callbacks()
'luaotfload.hpack_filter')
luatexbase.reset_callback('define_font')
luatexbase.add_to_callback('define_font',
- fonts.define.read,
+ def_font,
'luaotfload.define_font', 1)
luatexbase.add_to_callback('find_vf_file',
fonts.vf.find,
@@ -598,42 +630,6 @@ function luaotfload.unregister_callbacks()
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