summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luaotfload.dtx37
-rw-r--r--tests/math.tex20
2 files changed, 50 insertions, 7 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx
index 12aae2a..0918a4b 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -556,9 +556,18 @@ luaotfload.loadmodule('font-clr.lua')
% \end{macrocode}
%
-% \subsection{Emulating font dimensions}
+% \subsection{Post-processing TFM table}
%
-% And here add some code to emulate \XeTeX's \cs{fontdimen8},
+% Here we do some final touches to the loaded TFM table before passing it
+% to the \TeX\ end.
+%
+% \begin{macrocode}
+local function def_font(...)
+ local fontdata = fonts.define.read(...)
+ if type(fontdata) == "table" and fontdata.shared then
+% \end{macrocode}
+%
+% First, we 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.)
%
@@ -567,24 +576,38 @@ luaotfload.loadmodule('font-clr.lua')
% 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 type(fontdata) == "table" and fontdata.shared then
local capheight
local units = fontdata.units
local size = fontdata.size
local otfdata = fontdata.shared.otfdata
if otfdata.pfminfo.os2_capheight > 0 then
- capheight = otfdata.pfminfo.os2_capheight/units*size
+ 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
+ capheight = otfdata.metadata.ascent / units * size
end
end
fontdata.parameters[8] = capheight
+% \end{macrocode}
+%
+% Then we populate \texttt{MathConstants} table, which is required for
+% OpenType math.
+%
+% \begin{macrocode}
+ if otfdata.metadata.math then
+ for k,v in next, otfdata.metadata.math do
+ if k == "RadicalDegreeBottomRaisePercent" then
+ -- this is a percent
+ fontdata.MathConstants[k] = v
+ else
+ fontdata.MathConstants[k] = v / units * size
+ end
+ end
+ end
+
end
return fontdata
end
diff --git a/tests/math.tex b/tests/math.tex
new file mode 100644
index 0000000..6157fd5
--- /dev/null
+++ b/tests/math.tex
@@ -0,0 +1,20 @@
+% start out with plain.tex,
+% having TFM-based CM fonts preloaded in \fam 0...3
+
+% load OT math font in \fam 4
+\input luaotfload.sty
+\font\4={name:XITS Math:mode=base;script=math} at 10pt
+\font\5={name:XITS Math:mode=base;script=math;+ssty=0} at 7pt
+\font\6={name:XITS Math:mode=node;script=math;+ssty=1} at 5pt
+\textfont4=\4 \scriptfont4=\5 \scriptscriptfont4=\6
+
+% set up macros to use math font in \fam 4, just enough for this test
+\def\x{\Umathchar"7 "4 "1D465 }
+\def\y{\Umathchar"7 "4 "1D465 }
+\def\3{\Umathchar"7 "4 "0033 }
+
+%\tracingall
+$$\Uradical "4 "221A {\x}$$
+$$\Uroot "4 "221A {\3}{\x^\3+\y^\3}$$
+\bye
+