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

Math more fixes and features #2151

Merged

Conversation

Omikhleia
Copy link
Member

@Omikhleia Omikhleia commented Oct 26, 2024

On An Adventure1 - Part One

Closes #2122

Closes #1799

Closes #1293

Footnotes

  1. "Grandpa, how did you end up on such an adventure in the perilous Land of Math?"
    "Well, it all began with a simple, amusing task involving square roots, nth roots, and the like..."
    "And that went smoothly, didn’t it?"
    "At first, yes. But then I started picking out random formulas, sure I could typeset anything that came my way. Little did I know, I had wandered into the lair of the Hydra."
    "The Hydra? That beast with countless heads that regrows two for every one that's cut off?"
    "Exactly. The great monster, relentless devourer of formulas"
    "And did you manage to defeat it?"
    "I can’t say for sure. But I stopped complaining and making issues. I just drew my sword and kept fighting the beast. Pouring commits into the lair, one after another."

  2. So I'm taking a shortcut here -- one which would likely make math font designers frown, as formerly for the msqrt/mroot support. I'll explain something about it in the booklet I'm also preparing as I progress on this PR... (I haven't counted, but I've assembled over 50 formulas at least, all problematic in an area or another. Frankly, glyph assembly from bits is insane, is the least of the problems, and is far too costly).

  3. Previously unreported... Just a bad confusion between largeop and big operators, a mere coding slip likely... but it's a very funny one, we even show it, unnoticed, on our "demo" examples on the web-site 🤣 - Yes that circled-integral is too high with respect to the baseline, look folks! 🐰
    image

  4. I couldn't make sense of MathML Core §3.4.2.2 so I just made it work for a series of tests. The results seem acceptable for a first try, and one may perhaps understand the implied logic if we ever meet more complex cases:
    image

@Omikhleia
Copy link
Member Author

Failed regression tests assessment so far:

  • tests/bug-1495-inline-math-layout.sil = sizing of paired parentheses = consequence of fix(math): Paired open/close atoms shall be forced in a mrow in TeX-like math
  • tests/feat-math-display-numbered.sil = table spacing = fix(math): Default table row/column spacing must depend on the math font size
  • tests/math-bigops.xml = integral positioning = fix(math): Wrong vertical alignment of integral signs
  • tests/math-macros.sil = paired parentheses (as above) + position of superscripts = fix(math): Correct sub/superscript position for subformulas vs. symbols
  • tests/math-tables-mathml.xml = table spacing, as above
  • tests/math-tables-tex.sil = idem previous
  • tests/math-variants.xml = position of superscripts + size of parenthesis
    • Size of parenthesis: I had a little doubt, esp. for the first space, but my browser shows the same things for this MathML, so it's meeting the expectations.

= All tests failed where expected.

…ont size

I don't really mind us using the (non-Core) rowspacing and columnspacing
attributes, but the default values must be a ratio of the current math font
size, not some hard-coded value in pt.
Legit MathML elements for which a naive implementation is better than
nothing and paves the way to check other more important elements from
the MathML test suite.
@Omikhleia Omikhleia added bug Software bug issue enhancement Software improvement or feature request labels Nov 2, 2024
@Omikhleia Omikhleia added this to the v0.15.6 milestone Nov 2, 2024
@Omikhleia Omikhleia marked this pull request as ready for review November 2, 2024 01:58
@Omikhleia
Copy link
Member Author

I pushed the fixed test expectations.
These 17 commits (+646 −390 changes) conclude Part One of Grandpa's adventures in the Land of Maths 🤣
There are still 4 issues I'd like to address, but it will be for another day in another PR.

…ike math

So that stretching occurs on the relevant spans of content.
One wants `\vec{v}`, `\hat{n}` etc. to result in proper stacking of
the corresponding symbol over the argument, instead of the symbol
alone and the argument being lost :)
We long did without it, but MathML examples may contain lengths in px.
And we'll be happy too with other uses cases such as Markdown etc.
This might break some code as SILE.types.length can ignore the unknown
unit and the raw number value would thus be regarded as being in pt.
But that's rather a parsing bug anyway, and SILE.types.measurement spits
an error, so let's not care.
In particular, in most MathML examples, tests, or results from other
converters, a zero line thickness is used for binomial coefficients
and stacked subscript/superscript on big operators such as sums, etc.
Nothing really complex with mpadded.. Wait some ambiguity if dimensions
are in a font-relative unit (see in-code comment), but let's move
forward anyway -- and on the same occasion, remove the non-standard
approach previously used for (La)TeX's phantom, hphantom and vphantom.
This is not a proper fix, see in-code comment, but one has to move
forward and the workaround does the trick until we can do better.
And also override other explicit attributes from the element over those
from the default operator table.
The current stretchy "reshaping" picks the closest symbols in the math
glyph variants, but when none exist or they are still not close enough
(esp. far too small), OpenTypeand MathML Core say we should rely on
complex glyph assembly rules from glyph parts.
We don't have that yet: Here we fallback on re-scaling the glyph.
It might not look always good, but at least it's stretched as it
should around the content. It's a dirty compromise until something
better can be done.
Presumably a non-general solution here, covering the main use cases
only (e.g. braces and vectors) without too much stacking.
Follow MathML Core layout, except when the base is a symbol, in which
case use the more finicky TeX approach.

Closes sile-typesetter#2122
@alerque alerque force-pushed the math-more-fixes-and-features branch from 488b1d4 to ef249c3 Compare November 2, 2024 13:14
@alerque
Copy link
Member

alerque commented Nov 2, 2024

My force push of rebased commits was only to apply Lua coding style changes created deterministically by running stylua (still using the unreleased dev version, but no longer my fork since the option I wanted got merged upstream), the applying them to the original commits with git absorb. No big deal.

@Omikhleia
Copy link
Member Author

(...) still using the unreleased dev version, but no longer my fork since the option I wanted got merged upstream

Congrats! 🚀
Thanks for applying the styling stuff. I'll have to install it one day, and set it as a pre-commit ^^

@alerque alerque merged commit 21bcc5c into sile-typesetter:master Nov 2, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software bug issue enhancement Software improvement or feature request
Projects
Status: Done
2 participants