Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\sfrac does not use OpenType fractions #3

Open
adunning opened this issue Feb 16, 2019 · 7 comments
Open

\sfrac does not use OpenType fractions #3

adunning opened this issue Feb 16, 2019 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@adunning
Copy link

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:

screen shot 2019-02-15 at 23 16 35

\documentclass[12pt,a5paper]{article}
\usepackage{fontspec,xfrac}
\usepackage[osf,p]{libertinus}
\def\frc#1{{\addfontfeature{Fractions=On}#1}}

\begin{document}
\section{xfrac}
In Plato’s \textit{Timaeus,} the demiurge gives the world-soul a
structure based on two geometrical proportions, their arithmetic
means, and their harmonic means: 1, \sfrac{4}{3}, \sfrac{3}{2}, 2,
\sfrac{8}{3}, 3, 4, \sfrac{9}{2}, \sfrac{16}{3}, 6, 8, 9,
\sfrac{27}{3}, 18, and 27. Why do you suppose he did that?

\section{font feature}
In Plato’s \textit{Timaeus,} the demiurge gives the world-soul a
structure based on two geometrical proportions, their arithmetic
means, and their harmonic means: 1, \frc{4/3}, \frc{3/2}, 2,
\frc{8/3}, 3, 4, \frc{9/2}, \frc{16/3}, 6, 8, 9, \frc{27/3}, 18, and
27. Why do you suppose he did that?

\end{document}
@wspr
Copy link

wspr commented Feb 16, 2019 via email

@wspr wspr self-assigned this Feb 16, 2019
@wspr wspr added the enhancement New feature or request label Feb 16, 2019
@adunning
Copy link
Author

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.

@adunning
Copy link
Author

@khaledhosny
Copy link

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).

@adunning
Copy link
Author

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.

@car222222
Copy link

@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?

@khaledhosny
Copy link

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.

@josephwright josephwright transferred this issue from latex3/latex3 Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants