summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-05-01 20:18:38 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-05-01 20:18:38 +0200
commitb5e475547fbd9cc6f9f9fe883f6ccd05d277b081 (patch)
treeaf4a926b9034735ba254882a4110c6aeededa4f9
parent3d757d9ac865a0751750b1b358f9fa1781d97883 (diff)
downloadluaotfload-b5e475547fbd9cc6f9f9fe883f6ccd05d277b081.tar.gz
add basic access functions for math dimensions
-rw-r--r--luaotfload-auxiliary.lua25
-rw-r--r--tests/pln-aux-3.tex39
2 files changed, 64 insertions, 0 deletions
diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua
index 01e1bc0..a5f22dd 100644
--- a/luaotfload-auxiliary.lua
+++ b/luaotfload-auxiliary.lua
@@ -22,6 +22,8 @@ local aux = luaotfload.aux
local log = luaotfload.log
local identifiers = fonts.hashes.identifiers
+local fontid = font.id
+local texsprint = tex.sprint
local utf8 = unicode.utf8
local stringlower = string.lower
@@ -324,4 +326,27 @@ end
aux.provides_feature = provides_feature
+-----------------------------------------------------------------------
+--- font dimensions
+-----------------------------------------------------------------------
+
+--- string -> string -> int
+local get_math_dimension = function (csname, dimenname)
+ local fontdata = identifiers[fontid(csname)]
+ local mathdata = fontdata.mathparameters
+ if mathdata then return mathdata[dimenname] or 0 end
+ return 0
+end
+
+aux.get_math_dimension = get_math_dimension
+
+--- string -> string -> unit
+local sprint_math_dimension = function (csname, dimenname)
+ local dim = get_math_dimension(csname, dimenname)
+ texsprint(luatexbase.catcodetables["latex-package"], dim)
+ texsprint(luatexbase.catcodetables["latex-package"], "sp")
+end
+
+aux.sprint_math_dimension = sprint_math_dimension
+
-- vim:tw=71:sw=2:ts=2:expandtab
diff --git a/tests/pln-aux-3.tex b/tests/pln-aux-3.tex
new file mode 100644
index 0000000..12a80cf
--- /dev/null
+++ b/tests/pln-aux-3.tex
@@ -0,0 +1,39 @@
+\input luaotfload.sty
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% math dimension getter
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\font\xitsmath=file:xits-math.otf
+\font\cambriamath=file:cambria.ttc(1)
+
+\font\main=file:Iwona-Regular.otf at 12pt\main
+
+\directlua{
+ local aux = luaotfload.aux
+ local test_a = function (fontname, dimension)
+ tex.sprint(
+ "(", fontname, " (", dimension, " ",
+ aux.get_math_dimension(fontname, dimension),
+ [[))\endgraf ]])
+ end
+
+ local test_b = function (fontname, dimension)
+ aux.sprint_math_dimension(fontname, dimension)
+ tex.print[[\endgraf ]]
+ end
+
+ test_a("xitsmath", "AxisHeight")
+ test_a("xitsmath", "RadicalVerticalGap")
+ test_a("cambriamath", "StackTopShiftUp")
+ test_a("cambriamath", "FractionNumeratorGapMin")
+
+ test_b("xitsmath", "AxisHeight")
+ test_b("xitsmath", "RadicalVerticalGap")
+ test_b("cambriamath", "StackTopShiftUp")
+ test_b("cambriamath", "FractionNumeratorGapMin")
+}
+
+foo bar baz
+
+\bye