Skip to content

Add more details to the stretchy algorithm #238

@NSoiffer

Description

@NSoiffer

This comes from a side discussion about #103... It incorporates two related questions about the algorithm for stretchy characters.

Some stretchy characters have a few fixed sizes before moving to essentially assembling glyph pieces. For these fixed sizes, there is the question of which glyph variant to choose when the size is between two sizes. I see three options when moving from smaller sizes to larger sizes:

  1. when the size exceeds the target size, choose the smaller size (i.e., the previous entry)
  2. when the size exceeds the target size, choose the larger size (i.e., the current entry)
  3. when the size exceeds the target size, choose the size that is closest to the target size

Note that the target size is affected by the symmetric property.

@davidcarlisle: what does TeX do?

My gut reaction is that choosing the closest size is best. However, I'm not entirely sure that is right or maybe the target size should have already been shrunk (TeX uses parens/brackets/braces that are ~90% the size of the contents for \left( ... \right) -- see below).

5.3 Size variants for operators (MathVariants) says:

Browse the list of MathGlyphVariantRecord in MathGlyphConstruction.mathGlyphVariantRecord. If one MathGlyphVariantRecord.advanceMeasurement is at least T then use normal shaping and bounding box for MathGlyphVariantRecord.variantGlyph, the MathItalicsCorrectionInfo for that glyph as italic correction and exit with success.

So the spec seems to be saying use '2'. I didn't see an issue where there a discussion of what is the right thing to do (hence this issue).

The determination of the target size is in 3.3.1.1 Algorithm for stretching operators along the block axis.

TeX has:

  • \delimitershortfall: specifies the maximum space not covered by a delimiter (default 5pt)
  • \delimiterfactor: the ratio for variable delimiters, times 1000 (default 901).

I suspect that sizing will be better if we follow the TeX model. This would mean a change to 3.3.1.1. I don't know how common it is to change these values. Maybe @dginev can tell from arXiv? Assuming changing them is not common (and they aren't in the OpenType table), then I suggest hard coding them into the algorithm in the spec for computing the size to use.

@davidcarlisle: are these variables used for other stretchy chars like \sum and horizontal stretching, or just when \left and \right are used (which would slightly complicate the algorithm by having to check the first/last element in an mrow for being a prefix/postfix mo.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions