Skip to content

[css-inline-3] Propose N/A value for em-top and em-bottom baselines #5380

@kojiishi

Description

@kojiishi

A follow up for #5312.

I'd like to propose using some N/A value (undefined in JavaScript, 0, or something else) for when the font doesn't have none of top, bottom, nor central of em-box.

Imagine a case:

const ctx = canvas.getContext('2d');
ctx.font = '20px Arial, CJKFont';
const metrics = ctx.measureText('日本語');

I think the expectation is to get em-box from the CJKFont.

Another example:

ctx.font = '20px Arial, CJKFont1, CJKFont2';

and CJKFont1 doesn't have BASE table but CJKFont2 has. Is the expectation to synthesize from Arial, synthesize from CJKFont1, or use BASE table from CJKFont2?

Because this is JavaScript API, if author knows that the first available font doesn't have accurate metrics, they can choose options such as synthesize from ascent/descent of the first available font, fallback to the next font, or something else. If browser returns possibly inaccurate synthesized values, authors doesn't have a good way to determine how much they can trust it.

WDYT?

/cc @jfkthame @litherum @fantasai @annevk @yiyix @macnmm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions