stipub / stixfonts

OpenType Unicode fonts for Scientific, Technical, and Mathematical texts
SIL Open Font License 1.1
686 stars 41 forks source link

missing glyphs to write ordinals #229

Open mdeff opened 2 years ago

mdeff commented 2 years ago

The text and math fonts miss the following superscript letters to write ordinals:

Unlike the superscript s, r, n, and h that are included, those are in the phonetic extension. I guess the rest of it should be considered for inclusion as well.

Code to reproduce:

\documentclass{article}
\usepackage{fontspec}
\usepackage[math-style=ISO]{unicode-math}
\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}
\begin{document}
1ˢᵗ, 2ⁿᵈ, 3ʳᵈ, 4ᵗʰ, $i$ᵗʰ, $n$ᵗʰ
\end{document}

Result: 20220112_013925

An alternative is to have the engine superscript the standard letters:

\documentclass{article}
\usepackage{fontspec}
\usepackage[math-style=ISO]{unicode-math}
\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}
\begin{document}
$1^\text{st}, 2^\text{nd}, 3^\text{rd}, 4^\text{th}, i^\text{th}, n^\text{th}$
\end{document}

Though that doesn't look as good (positioning and weight): 20220112_015550

tiroj commented 2 years ago

English ordinals are not normally expected to be written using modifier letter superscripts, which are encoded in Unicode as elements of various phonetic transcription systems and alphabets. The STIX Two Text fonts contain a full set of a–zlowercase superscript variant glyphs mapped to their regular lowercase characters via the OpenType Layout sups feature, and that is the recommended method to display them for ordinals.

Since the full set of a–z lowercase superscript glyphs are available, it would be relatively easy to duplicate those of them that are not yet encoded in the font as modifier letters, and to assign them the codepoints from the Phonetic Extension block. Filling out the remainder of that block would be considerably more work, and is something that STI Pub would need to consider.

tiroj commented 2 years ago

PS. Ideally, the layout engine would apply the sups feature automatically when superscripting the letters, rather than scaling and positioning according to its own algorithm or font fallback data.

firai commented 2 years ago

PS. Ideally, the layout engine would apply the sups feature automatically when superscripting the letters, rather than scaling and positioning according to its own algorithm or font fallback data.

@mdeff There's a LaTeX package that accesses the sups feature that @tiroj is referring to: realscripts (either accessed directly or through the package xltxtra). After you load the package, use the \textsuperscript{} and \textsubscript{} commands (or the \realsuperscript{} and \realsubscript{} commands) to access the OpenType features.

By the way, the manual for fontspec actually documents how it implements OpenType features fairly well. I found out about realscripts from the fontspec manual.

firai commented 2 years ago

PS. Ideally, the layout engine would apply the sups feature automatically when superscripting the letters, rather than scaling and positioning according to its own algorithm or font fallback data.

P.S. @mdeff's second piece of code is putting regular text inside a math superscript in an inline math equation (the $s) to force the superscript effect, so not only are the correct glyphs not being used, the spacing is determined using math cut-in kerning rules rather than text font kerning rules.

firai commented 2 years ago

P.P.S. As it turns out, MS Word does not seem to support the sups and subs features at all (i.e. Word emulates the superscripts and subscripts even if the font actually has the right glyphs). It seems that the only way for MS Word users to access the right glyphs is if the glyphs are replicated in the various Unicode blocks.

tiroj commented 2 years ago

Sigh. We never managed to persuade the Office text layout folk to implement OpenType Layout sups (and subs). Their argument was always that users might apply superscript styling to characters that are not supported by the font layout features, and then there would be an ugly mix of superscript characters at different heights and weights, so it was better to synthesise all superscripts. So users don’t get the actual useful things like superscript letters and numbers that they might reasonably use in conventional typography, in case other users might style random characters as superscript.