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

[css-inline-3][css-writing-modes] Baseline Alignment of Mixed Vertical Orientations #5424

Open
fantasai opened this issue Aug 13, 2020 · 2 comments
Labels
css-inline-3 Current Work css-writing-modes-4 Current Work

Comments

@fantasai
Copy link
Collaborator

fantasai commented Aug 13, 2020

In CSS Writing Modes, text and inline boxes are aligned using the central baseline. This gives the correct behavior across font changes and also across orientation changes.

However, dominant-baseline and alignment-baseline properties introduced by SVG / CSS Inline Layout Level 3 allow changing the baseline away from central. When orientations are mixed, this can result in some nonsensical things. For example, vertical baseline tables often set their alphabetic baseline to coincide with the central baseline. If you try to align an upright run (where the alphabetic baseline is central) with a sideways run (where the alphabetic baseline is to one side of the run) the result will not make any sense. They are trying to align using two different, incompatible baseline tables, essentially.

I think we need to make some special rules for when sideways and upright text are aligned to each other.

Note: This issue is derived from @kojiishi’s #5381, but it's about baseline metrics instead of ascent/descent.

@fantasai fantasai added css-inline-3 Current Work css-writing-modes-4 Current Work labels Aug 13, 2020
@fantasai
Copy link
Collaborator Author

Proposal:

  • When aligning a sideways run inside an upright context, create a hypothetical vertical baseline table for the sideways run that is the same table for an upright run of the same font, pinned to the sideways run at the central baseline. Then align using the vertical metrics of the context and the run.
  • When aligning an upright run inside a sideways context, similarly create a hypothetical rotated-horizontal baseline table for the upright run pinned at the central baseline, and align using the horizontal metrics of the context and the run.

@fantasai
Copy link
Collaborator Author

fantasai commented Aug 13, 2020

To make a concrete example, let's say the vertical baseline table of the font places alphabetic and central baselines at 50/100, and the horizontal baseline table places alphabetic at 10/100 and central at 40/100.

It's clear, I think, that in typical vertical typesetting, the upright runs and the sideways runs should be aligned to each other by the central baseline. But it's less clear what should happen if alignment by alphabetic baseline is requested. If we follow the proposal above:

  • Suppose we have an inline box with sideways text inside an inline box with upright text. We are aligning sideways inside upright, so the context is sideways. Because the orientations mismatch, we create a hypothetical vertical baseline table for the sideways text: overlay the vertical baselines on the rotated horizontal baseline table, matching the central baselines. Since alphabetic and central coincide in the vertical table, this means alphabetic and central baseline will both be positioned at the rotated horizontal central coordinate, 40/100, and this point of the sideways will coincide with the central (50/100) point of the upright context.

  • Next, consider the opposite situation: upright text in a sideways context. In this case we create a hypothetical rotated-horizontal baseline table for the upright text, matching at the central baseline. Since the alphabetic baseline in the horizontal baseline table is offset 30/100 from the central baseline, this means that the central baseline will be at 50/100 (to match the vertical baseline table) and the alphabetic baseline will be at 20/100. Then we align the matching baselines of the context and the intruder using their rotated-horizontal baseline tables.

I think this will work reasonably when aligning child text with an orientation mismatched to its parent. However, it is not a symmetrical operation: the result of aligning two runs depends on which orientation is considered the context and which is considered the intruder, because that determines whether we use the horizontal or vertical baseline table. For aligning a box within another box, there is a natural answer to this question. But for mixed orientation boxes: is the context sideways or upright?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-inline-3 Current Work css-writing-modes-4 Current Work
Projects
None yet
Development

No branches or pull requests

1 participant