Skip to content

Ink ascent/descent #78

Open
Open
@fred-wang

Description

@fred-wang

This one is a bit tricky... It was mentioned in #139 and https://github.com/mathml-refresh/mathml/issues/52#issuecomment-514016715 at least. But it needs clear explanation.

When drawing a box, one can distinguish its normal size (the space it occupies) from its "ink" size (smallest enclosing rect for the painted content). For example, a white space has nonzero width/height but an empty ink box.

First the ink size is involved in the OpenType MATH spec when computing vertical gaps [1]. If I'm correct, it is not involved for horizontal placement during layout of math box, so I think we can don't need "ink left/right bearings" and can focus on ink ascent/descent below.

Using CSS baseline concepts, the MathML Core specification defines two new baselines "ink-over baseline" and "ink-under baseline" which delimitate the ink ascent/descent of a box [2]. All the boxes/baselines in the SVG schemas of the spec are drawn with dashes but the ink boxes are suggested with a background.

The status in browser is the following:

  • All MathML boxes in Gecko have ink metrics, both vertical and horizontal.
  • WebKit does not use ink metrics. For token elements, it calculate box metrics of the text specially [3] which means that it will somewhat work with basic constructions.
  • For Blink, @rwlbuis started to implement the concept of the core spec but it's still very experimental and incomplete. It at least somewhat works for text and fractions.

In order to understand this properly, we need a non-trial test case. I uploaded a test case [4] with basic text/fraction/square root examples and the interesting one which is AAA/√CCC (square root as a denominator).

The font is built like this [5]:

  • all font ascents/descents are 1em and the "use typo metrics" bit is set.
  • Glyphs for A, B, C are 1em squares (respectively 1em ink ascent, 1em ink descent and .5em ink ascent/descent). They are respectively drawn in red, green and blue.
  • Glyph for U+221a (radical symbol) is 1em width, 1em ink ascent, 1em ink descent. It can be repeated with 1em overlap to build a glyph assembly.
  • fraction and radical rulethickness are 1em
  • num/denom min gaps are 1em
  • num/denom shifts are 2em
  • radical vertical gap is 1em
  • radical extra ascender is 2em

Exercise: Deduce the vertical positions of AAA, fraction bar, radical overbar and CCC.

Gecko, WebKit, Blink, XeLaTeX and LuaLaTeX render this last example inconsistently. Analysis is complicated by the fact that there are some unrelated bugs and that I was not able to make XeLaTeX/LuaLaTeX use my custom glyphs for the text.

Two questions for the CG:

(1) Is it important to have this concept of ink ascent/descent for all boxes? Or only male ascent/descent of token elements match the text ink ascent/descent? As I understand the MATH spec, it is important to have it for all boxes...

(2) If it is important, is the MathML Core description correct? For example, is the "radical vertical gap" included in its ink box or not? I guess we should ask Microsoft people about this.

[1] https://docs.microsoft.com/en-us/typography/opentype/spec/math
[2] https://mathml-refresh.github.io/mathml-core/#box-model
[3] https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/css/mathml.css#L19
[4] https://github.com/mathml-refresh/ink-metrics
[5] https://github.com/mathml-refresh/ink-metrics/blob/master/create-font.py

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions