Open adunning opened 5 years ago
Are OpenType fractions actually reliable? It’s been years since I did any testing but I remember poor results.
Perhaps more reliable would be for xfrac to have an OpenType mode added that looks for numerator and denominator glyphs and uses them. (Kind of like the realscripts package does for footnote symbols and so on.)
Some fonts attempt to add extra context detection to allow the option to be used globally, and that can get messy, though that's not really a problem here. I think the font is also responsible for converting a slash into a solidus, and things could theoretically go wrong there. But with a good font, you get a perfectly kerned fraction without additional work.
Ah, evidently many fonts have trouble with more complex fractions.
BTW, with XeTeX <numbers><fraction slash><numbers>
should automatically activate numr
, dnom
, and frac
OpenType features for this range of characters (a feature of HarfBuzz, so any HarfBuzz-using engine should have it).
Very cool – though, alas, that does not seem to work with LuaLaTeX. It does seem as if @wspr's approach would be the most reliable way of having fractions that just work.
@khaledhosny Thanks for this insight into HarfBuzz, and of course the anticipated luahbtex! One question: is harfbuzz itself configurable? For, example could a luahbtex user turn off features such as this one for fractions, or extend it to be used with single letters as well as numbers? Or must all configuration be done via the fonts in use?
This particular behavior of HarfBuzz is not configurable; it follows the Unicode recommendation for handling fraction slash (U+2044). You can avoid the automatic fractions by not using fraction slash (regular slash does not activate this), and you can manually activate frac
, numr
and dnom
as needed.
The
xfrac
package does not provide any means of using OpenType fractions where these are available. Would it be possible to add an option that turns on\addfontfeature{Fractions=On}
through fontspec?Here's an example based on a StackExchange discussion: