Repository navigation
Add math.accent support for flac and dtls OpenType features - #5202
Conversation
|
The changes made making Could add a test for this if Libertinus Math is added to https://github.com/typst/typst-dev-assets. In the future we should pass single chars in math through the shaper. |
| Re: 'ℜ', | ||
| Im: 'ℑ', | ||
| dotless: [i: '𝚤', j: '𝚥'], | ||
| dotless: [i: 'ı', j: 'ȷ'], |
There was a problem hiding this comment.
This change makes this character act more in line with other Latin characters in math. (Some) Single characters in math are converted to their italic math variants, so the dotless i and j should as well. See the example below.
$ 𝑗 upright(𝑗) italic(𝑗) bb(𝑗) med
𝚤 upright(𝚤) italic(𝚤) bb(𝚤) \
j upright(j) italic(j) bb(j) med
ı upright(ı) italic(ı) bb(ı) $ |
| // Try replace a glyph with its dotless variant. | ||
| if let MathFragment::Glyph(ref mut glyph) = &mut base { | ||
| glyph.make_dotless_form(ctx) |
There was a problem hiding this comment.
(Moving part of the old conversation here.) Are there any situations where you'd want an accent above i or j with the dot still? If this is basically never, it'd be much nicer to automatically replace them with their dotless variants.
There was a problem hiding this comment.
Some orthographies keep the dots of the i and j when accented, but I don’t know if there are equivalent math notations. There is at least one question on tex.stackexchange where this was desired https://tex.stackexchange.com/questions/181384/diacritics-above-dotted-i-i-with-tittle (though since you need to explicitly use \imath and \jmath to drop the dot in LaTeX, it is unlikely to have many questions asking about how to keep the dots).
There was a problem hiding this comment.
I've made the changes so that $bb(dotless.i)$ (along with all the other variants) work as expected, following @khaledhosny comments to switch if the font has the dtls OpenType feature.
See the example below.
$ dotless.i dotless.j med
upright(dotless.i) upright(dotless.j) \
sans(dotless.i) sans(dotless.j) med
bold(dotless.i) bold(dotless.j) \
bb(dotless.i) bb(dotless.j) med
cal(dotless.i) cal(dotless.j) \
frak(dotless.i) frak(dotless.j) med
mono(dotless.i) mono(dotless.j) \
bold(frak(dotless.i)) upright(sans(dotless.j)) med
italic(bb(dotless.i)) frak(sans(dotless.j)) $ |
However, the only "issue" is that if the font does not have a dotless variant of the glyph, it will sometimes fall back to the glyph with the dot (this depends on the order in which variants and styles are applied). This feels in some ways like bad and unexpected behaviour, but at the same time I can see this as being fairly reasonable. I think it'd also increase the code's complexity a fair bit to check whether the glyph exists in the dtls alphabet beforehand.
Because we're not exactly switching the alphabets, and only attempt to replace a glyph if it has a value in the dtls table, we get the glyph with the dot sometimes instead of a 'tofu'. Should we instead forcibly apply the switch, and so end up with a missing glyph in these situations?
67bf88d to
9108e92
Compare
9108e92 to
5e040ee
Compare
|
Thank you!
Let's not do that (at least for now) then. |


Closes #5201.
While implementing this, I also changed the logic for the
ssty_tableto use theGlyphwiseSubsts<'a>struct. This saves some code duplication and is more consistent anyways. Also, from the spec, it could be implemented as a single substitution. So this change also ensuressstyvariants will work in fonts where this is the case.The only font I can find that supports the

flacOpenType feature is Cambria Math. I tested it locally, and it is all working. Though it (my probably dodgy copy) had a bug I needed to manually fix so the horizontal variants of some of theflacvariants would be used. See the example below.EDIT: Also fixes #2860.