Skip to content

[css-inline-3] Define em-top and em-bottom baselines #5312

Closed
@fantasai

Description

@fantasai

The Canvas API has several references into the metrics defined in

It also defines emHeightAscent and emHeightDescent but doesn't have a concrete definition for them. Talked with @jfkthame about what they might be defined as and currently thinking maybe we add in definitions for these for HTML to refer into, so all the related metrics are all defined in one place (even if CSS doesn't end up using this particular pair).

Proposed definition from me and @jfkthame is:

  • if the ideographic-top + ideographic-bottom or ideographic-central baselines are defined by the font, emHeightAscent is 0.5em above the ideographic-central and emHeightDescent is 0.5em below. (This will normally make ideographic-top = emHeightAscent and ideographic-bottom = emHeightDescent, but if ideographic-top and ideographic-bottom are not 1em apart it will normalize the distance to 1em)
  • if none of the ideographic baselines are defined, use the ascent and descent normalized proportionally so they add up to 1em

Roughly in code, something like:

if iTop | iBottom | iCentral:
  /* rules of font format considers at least one of these defined */
  if iBottom && !iTop:
    iTop = iBottom + 1em;
  if iTop && !iBottom:
    iBottom = iTop - 1em;
  if !iCentral:
    iCentral = (iTop + iBottom)/2;

  return (iCentral + 0.5em, iCentral - 0.5em);
else:
  p = 1em/(ascent - descent);
  return (ascent*p, descent*p);

CC @annevk @yiyix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions