Skip to content

Commit 2adc912

Browse files
OmikhleiaDidier Willis
authored andcommitted
fix(math): Add math.font.script.feature setting, defaulting to ssty
1 parent b8f35ff commit 2adc912

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/math/base-elements.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,17 @@ end
947947

948948
function elements.text:shape ()
949949
self.font.size = self.font.size * self:getScaleDown()
950+
if isScriptMode(self.mode) then
951+
local scriptFeature = SILE.settings:get("math.font.script.feature")
952+
if scriptFeature then
953+
self.font.features = ("+%s=1"):format(scriptFeature)
954+
end
955+
elseif isScriptScriptMode(self.mode) then
956+
local scriptFeature = SILE.settings:get("math.font.script.feature")
957+
if scriptFeature then
958+
self.font.features = ("+%s=2"):format(scriptFeature)
959+
end
960+
end
950961
local face = SILE.font.cache(self.font, SILE.shaper.getFace)
951962
local mathMetrics = self:getMathMetrics()
952963
local glyphs = SILE.shaper:shapeToken(self.text, self.font)

packages/math/init.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ function package.declareSettings (_)
3535
type = "integer",
3636
default = 400,
3737
})
38+
SILE.settings:declare({
39+
parameter = "math.font.script.feature",
40+
type = "string or nil",
41+
default = "ssty",
42+
help = "OpenType feature for the math script-style alternates (esp. primes), theoretically ssty",
43+
})
3844
SILE.settings:declare({
3945
parameter = "math.font.filename",
4046
type = "string",
@@ -138,6 +144,10 @@ By default, this package uses Libertinus Math, so it will fail if Libertinus Mat
138144
Another font may be specified via the setting \autodoc:setting{math.font.family}.
139145
If required, you can set the font style and weight via \autodoc:setting{math.font.style} and \autodoc:setting{math.font.weight}.
140146
The font size can be set via \autodoc:setting{math.font.size}.
147+
The \autodoc:setting{math.font.script.feature} setting can be used to specify OpenType features for the math font, which are applied to the smaller script styles.
148+
It defaults to \code{ssty} (script style alternates), notably to ensure that some symbols such as the prime, double prime, etc. are displayed correctly.
149+
The default setting applies to Libertinus Math and well-designed math fonts, but some fonts may require different features.
150+
(The STIX Two Math font has a stylitic set \code{ss04} from primes only, but also supports, according to its documentation, \code{ssty}, which provides other optical adjustments.)
141151
142152
\paragraph{MathML}
143153
The first way to typeset math formulas is to enter them in the MathML format.

0 commit comments

Comments
 (0)