CSharpMath: Incorrect spacing and bounding box

Describe the bug There are incorrect spacing and bounding boxes as indicated by green ellipses. The top is created by LaTeX and the bottom is created by CSharpMath.

  • comparer-05
  • comparer-00
  • comparer-01
  • comparer-02
  • comparer-04
  • comparer-07
  • comparer-08
  • comparer-09

To Reproduce Make sure you have TeX distribution installed. Download the VS solution from my rep: https://github.com/sadqiang/GitHubReport/tree/master/GitHubReport.

Questions

  • 1. What causes the size of LaTeX output to be smaller than that of Skia’s ? I already set 12pt for both actually.
  • 2. Why can’t we use the following?
\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)
y=\cfrac{x}{1+\cfrac{x}{1+\cfrac{x}{1}}}
\mathscr{L}\left\{f(t)\right\} = F(s) 
  • 3. Can we change the math font from the default to, for example, Palatino, Bera, etc?

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 30 (1 by maintainers)

Most upvoted comments

@pstricks-fans I’d say that at least getting the spacing specified in the original post counts as fixing this case.

Some of these are deficiencies from iosMath that this library was ported from. I’ll keep this in mind in the upcoming rewrite.

Math Layout in “In-span” italic correction

from https://github.com/verybadcat/CSharpMath/issues/32 and should be solved by (https://github.com/verybadcat/CSharpMath/issues/32#issuecomment-645134531 and https://github.com/verybadcat/CSharpMath/issues/32#issuecomment-645291053)

math_italic_not_set_scriptLang pic 1: No italic correction if not set ScriptLang property to “math”


Users can layout math manually entire process by their own MathLayout engine.

But the GlyphLayout class also have a help for layouting “in-span” italic glyph.

  1. EnableBuiltinMathItalicCorrection (https://github.com/LayoutFarm/Typography/commit/ccad43bb2130137b71958d8b0aa8b046e3a82a15) is true by default

BUT

  1. GlyphLayout ScriptLang must be set to new ScriptLang(“math”) too.

see detail impl => https://github.com/LayoutFarm/Typography/commit/ccad43bb2130137b71958d8b0aa8b046e3a82a15#diff-b705c14388c05643560a455e65eaf449R468


math_italic_set_scriptLang pic 2: ‘in-span’ math italic correction

f_italic pic 3: latin modern math, 20pt, math italic correction

[A] (𝐹𝐹𝐹), [B] (FFF), [C] (𝐹F𝐹)

I’ve overlooked that info!

The Math Font file (eg Latin Modern Math, Asana Math)

contain that info.

It may be used in this situation.

When a run of slanted characters is followed by a straight character (such as an operator or a delimiter), the italics correction of the last glyph is added to its advance width.

see detail more detail =>

https://docs.microsoft.com/en-us/typography/opentype/spec/math#mathitalicscorrectioninfo-table

@prepare What about storing an italic measure (glyph.MathGlyphInfo?.ItalicCorrection) when positioning each glyph? So if the current character has less italic correction than the previous character, the difference becomes additional spacing?

See the bottom part of #29, basically CSharpMath is in a process of being rewritten.