1
votes

We are working on a large print app with thousands of fonts. Historically, these have been displayed using Flash but, obviously, we are now investigating HTML5.

A subset of WOFF fonts display vertically displaced downwards by up to several pixels - this appears to be converter independent. (I have tried over a dozen WOFF conversions and all display the same positioning.)

Clearly there is something in the affected fonts that causes WOFF to display vertically down from the OTF / TTF / SWF position. Can anybody point me to a reference that might explain what?

Thanks, G

ETA: Following comments below, I have edited this to include an MCVE.

The example chosen demonstrates how the ClarendonNo1URW-Lig font displays a small number of pixels below where would be expected using the same font outside of a browser.

Screenshot of HTML page displaying WOFF with a problem font compared to PNG extracted from InDesign using the same font

The blue rectangles in the screenshot linked illustrate the bounds that are expected when interrogating the font to position between baseline of last line and ascent of first line - to match InDesign display positioning.

All positioning values are calculated explicitly from these font ascent / descent values and have been validated against over 1000 fonts - they are pixel perfect in well over 90% of fonts, but some (such as the example) are shifted vertically downwards.

Additionally, this phenomena appears consistent across a range of browsers - similar behaviour is observed in FireFox, Edge, Opera, Chrome...

This doesn't appear to be converter dependent - I have tried almost a dozen converters from the online ttf to woff services to purchased software including TransType etc. Swapping the WOFF with the original TTF or OTF (as applicable) does not eliminate the issue, so it is probably something in the original font file itself that is hinting to the browser to display lower down. But I have no idea what or how to query it to make allowance for same.

Sample HTML page displaying issue is below. The use of lineheight 0 and absolute positioning of spans is to eliminate the effects of browser-renderer specific rounding effects that otherwise make a mockery of any attempt for pixel-perfect font layout.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
@font-face {
font-family: 'ClarendonNo1URW-Lig';
src: url('/assets/compiled_fonts/ClarendonNo1URW_Lig.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
img {
width:3000px;
transform-origin:0 0;
}
p {
width:3000px;
background-color:#00AEEF; 
margin:0;
position:relative;
}
span {
line-height:0px;  
color: #000000;  
position: absolute;
}
</style>
</head>
<body>
<h1>As displayed by HTML</h1>
<div id="paraToStyle" style="text-align:left; ">
<p style="height: 226.8px;" id="bobParent">
<span id="bobToStyle" style="font-family: ClarendonNo1URW-Lig; font-size: 72px; top: 36px;">Net netted nets nest nests stents N e t n s l y L</span>
<br>
<span id="bobToStyle2" style="font-family: ClarendonNo1URW-Lig; font-size: 72px; top: 122.4px;">hairdressing Sillily Lloyds of Lyana LYANG</span>
<br>
<span id="bobToStyle3" style="font-family: ClarendonNo1URW-Lig; font-size: 72px; top: 208.8px;">Better BETTER fet Fetter Gest Fest</span>
</p>
</div>
<br>
<h1>As exported from InDesign</h1>
<img style="transform: scale(1, 1);" src="/fontImages/ClarendonNo1URW_Lig.png" id="paraImageFromInDesign">
</body>
1
This.... question makes no sense. WOFF is literally a byte-for-byte lossless-compressed OpenType font. Care to add more details, an mcve, specific fonts, browser console debug information, anything that lets people dealing with OpenType and the web understand what you're running into?Mike 'Pomax' Kamermans
Sorry that it makes no sense, however, it is supported by verifiable observation; out of 1000 fonts 900+ display vertically aligned with where I would expect when compared to desktop publishing using the non-web font. But the remainder are visibly displaced (usually downwards) by up to several pixels. This is for identical code with lineheight in html set to 0 to eliminate other effects. I will look at providing an MCVE, but this is obviously complicated by the proprietary nature of the fonts.Gaius Coffey
start simple: pick a font, write a single paragraph webpage that uses that font in its opentype form with a @font-face, and again with the same font but run through "professional" WOFF conversion tools (google's woff converter, FontForge, etc). If you can't distribute the font, say which one you used (because people might own it), show the code you used (html + css), screenshoot and show the result for several different browsers, say which tools you used for the conversion, and then you have a question with a good amount of information and detail.Mike 'Pomax' Kamermans
MCVE added - it looks like the issue is browser handling of the specific fonts rather than the WOFF conversion per se - eg: both WOFF and OTF / TTF display the same positional problem in the browser when compared to desktop.Gaius Coffey

1 Answers

0
votes

You probably need to reconvert this via a tool that fixes vertical metrics for Mac/PC. (eg. Fontsquirrel)

As this happens across browsers this seems like the problem described in this thread: Mac vs. Windows Browser Font Height Rendering Issue.

Another option via the commandline seems to be fiddling with the TTX configuration via FontTools