Description
I need consistent positioning of large and medium-sized text across operating systems.
The large text on the page
https://tobireif.com/non_site_stuff/test_case_for_font_position_report/
gets positioned differently eg in Chrome on Mac vs in Chrome on Windows:
The space above the large text is 102px in Chrome on Mac
vs 125px in Chrome on Windows.
The space below the large text is 75px in Chrome on Mac
vs 52px in Chrome on Windows.
Another test-page:
https://tobireif.com/non_site_stuff/test_case_for_font_position_report_yet_another_font/
From the above test-page:
Chrome on MacOS:
Chrome on Windows:
The large-text positioning / the space above and below the large text should be the same across operating platforms, for this font and for all fonts where the effective position currently is different across operating systems.
In order to not break existing content there needs to be a new CSS property,
eg
position-of-glyphs: consistent-across-platforms;
or eg
text-layout: glyph-bounding-box;
(The latter would set the same text positioning that browsers use for SVG.)
There are many other pages/sites/layouts where medium/large text and its position is important.
I need a way to ensure the same vertical text position across platforms.
The alternatives are not great:
a) Applying spacing:
eg
if (navigator.platform.startsWith("Win")) {
var h1 = document.querySelector("h1");
h1.style.marginTop = "-0.25em";
h1.style.marginBottom = "0.15em";
}
This is a hack.
b) Fixing each problematic font:
This is not always feasible: There might be no time to do this, many web devs use fonts hosted by external services, and thirdly the font license might not allow any modifications.
c) Using SVG text instead of HTML text:
Replacing each respective text with SVG has major drawbacks: Some might fear that it might impact eg search engine visibility. Imagine a newspaper considering to use SVG for its headlines while search engines handle h1/h2/etc well - they probably wouldn't take that risk. And it might also impact accessibility, see https://www.google.com/search?q=svg+text+screen+readers . It's a potential issue as far as I can see (eg in a given specific screen reader), while HTML text can be expected to just work. Also, SVG is meant for graphics (which might contain text or not) - a pure text page (eg an article) coded in HTML shouldn't have to use SVG just to get consistent cross-OS text-layout (for its large text instances).
Thus it would be great if consistent cross-OS text-layout would be available in HTML as well (not just in SVG as is currently the case).
I hope that CSS will support opting into the glyph-bounding-box-based layout (which browsers already have implemented for SVG) as option for (typically large) HTML text.
eg h1 {text-layout: glyph-bounding-box}
or h1 {glyph-positioning: glyph-bounding-box}
(The exact names for the property and value could be different.)
That would solve the issue completely.