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

Line-height problem with regular compared to black (ATS bug) #124

Closed
hmaesta opened this issue Feb 7, 2019 · 19 comments
Closed

Line-height problem with regular compared to black (ATS bug) #124

hmaesta opened this issue Feb 7, 2019 · 19 comments
Labels
bug Something that is now the way it's supposed to be

Comments

@hmaesta
Copy link

hmaesta commented Feb 7, 2019

screen shot 2019-02-07 at 16 52 30

Since I upgraded to Inter 3.3 there is a difference between line-height of Regular and Bold.

Environment

  • OS: macOS 10.14.2
  • Sketch 53 (72520)
  • Inter 3.3
@vilav
Copy link

vilav commented Feb 8, 2019

+1. Noticed the same.
Added Plex for comparison of bounding box spacing.

• Keynote 8.3
• macOS 10.14.3

screenshot 2019-02-08 at 1 51 24 pm

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

So strange. What font files do you have installed? (Please be as detailed and exact as possible.)

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

Something's definitely not right here.
diffing fontinfo of regular and black otf yields some weird differences:

@fontinfo black vs regular

     "head": {
-      "checkSumAdjustment": 1882288472,
+      "checkSumAdjustment": 1637560464,
...
-      "xMax": 4860,
-      "xMin": -2433,
-      "yMax": 3145,
-      "yMin": -1196
+      "xMax": 4650,
+      "xMin": -2080,
+      "yMax": 3072,
+      "yMin": -1084
...
     "hhea": {
...
-      "xMaxExtent": 4860
+      "xMaxExtent": 4650

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

Here's what I'm seeing for OTF files of v3.2:

@ black vs regular (v3.2 OTF)
     "head": {
...
-      "xMax": 4860,
-      "xMin": -2433,
-      "yMax": 3145,
-      "yMin": -1236
+      "xMax": 4524,
+      "xMin": -2080,
+      "yMax": 3012,
+      "yMin": -1076
     },
     "hhea": {
...
-      "xMaxExtent": 4860
+      "xMaxExtent": 4524

The black, regular and light masters all have identical metrics in the source files, both Glyphs and UFO. The diff also shows that there are no differences between metrics that account for line-height, so this is really strange.

Additionally, it seems to only be an issue with ATS-based type rendering — the only way to reproduce this is with Apple software that directly uses ATS (i.e. no Safari.)

Adobe tools (uses adobe's type setter) as well as tools based on freetype and harfbuzz shows the correct line height.

@hmaesta
Copy link
Author

hmaesta commented Feb 8, 2019

What font files do you have installed?

I downloaded the latest release from inter/releases. (Here my installed fonts.)


Another example comparing all weights and line-heights.

screen shot 2019-02-08 at 07 42 28

Download Sketch file here.

You mentioned that on Adobe software it's correct (and in fact the line-height number is), but when creating a grid line and comparing the weights on Illustrator, Bold and Black have a slight difference between others. Could be a software bug though. (it's impossible to screenshot since Illustrator removes the "outer box" when hitting cmd – but you can download file here).

@thundernixon
Copy link
Contributor

I can help look into this!

Typically, Google Fonts projects need to set custom parameters in GlyphsApp to control vertical metrics in their various flavors. This is one thing that FontBakery helps to catch. I’m on my phone right now, but I’ll be able to post more detail later.

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

This is what I'm seeing:

Apple TextEdit: (uses ATS/CoreText)
screen shot 2019-02-08 at 08 38 33

Sketch 53: (uses ATS/CoreText)
screen shot 2019-02-08 at 08 51 20

Illustrator CC 2019
screen shot 2019-02-08 at 08 35 50

Figma: (uses Freetype & Harfbuzz)
screen shot 2019-02-08 at 08 48 47

InVision Studio 1.8.4:
screen shot 2019-02-08 at 08 56 00

Adobe XD 15:
screen shot 2019-02-08 at 09 54 58

Adobe InDesign CC 14:
screen shot 2019-02-08 at 09 59 17

Google Chrome 72: (uses Freetype & Harfbuzz)
screen shot 2019-02-08 at 08 42 16

Apple Safari 12:
screen shot 2019-02-08 at 08 43 30

Microsoft Edge 42: (probably uses DirectWrite)
edge

Microsoft WordPad: (Win 10; uses DirectWrite)
screen shot 2019-02-08 at 09 10 10

This is the data I'm getting from Freetype for Inter-Black.otf:

ascender: 2708
descender: -660
faceFlags: 537
faceIndex: 0
familyName: Inter
height: 3368
maxAdvanceHeight: 3368
maxAdvanceWidth: 4928
numCharmaps: 3
numFaces: 1
numFixedSizes: 0
numGlyphs: 2345
styleFlags: 0
styleName: Black
underlinePosition: -576
underlineThickness: 320
unitsPerEm: 2816

This is the data I'm getting from Freetype for Inter-Regular.otf:

ascender: 2708
descender: -660
faceFlags: 537
faceIndex: 0
familyName: Inter
height: 3368
maxAdvanceHeight: 3368
maxAdvanceWidth: 4928
numCharmaps: 3
numFaces: 1
numFixedSizes: 0
numGlyphs: 2345
styleFlags: 0
styleName: Regular
underlinePosition: -560
underlineThickness: 192
unitsPerEm: 2816

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

I tried scaling the glyphs source to 2048 UPM, compiled font files and tested with the Apple apps. No difference. So probably not a UPM-related bug (there has been issues with uncommon UPMs in ATS/CoreText.)

@emma-sg
Copy link

emma-sg commented Feb 8, 2019

Seeing the same thing on Apple Pages/Numbers/Keynote, presumably they use ATS/CoreText as well

@m4rc1e
Copy link
Contributor

m4rc1e commented Feb 8, 2019

I've had this issue before on Android. Some applications use the font's yMin and yMax to determine the position for the first line of text.

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

Diffing ttx:

(. init.sh ; ttx build/fonts/const/Inter-Regular.otf & ; ttx build/fonts/const/Inter-Black.otf & ; wait)
diff -u build/fonts/const/Inter-*.ttx

Notable differences: (Black vs Regular)

-    <underlinePosition value="-416"/>
+    <underlinePosition value="-464"/>

This is by design though and shouldn't affect line height.
There really is nothing else sticking out that affects height... What a mystery.

@m4rc1e
Copy link
Contributor

m4rc1e commented Feb 8, 2019

I'm pretty sure Roboto experienced this issue in Android.

To solve it they forced the yMin and yMax using the following script, https://github.com/google/roboto/blob/master/scripts/force_yminmax.py

https://github.com/google/roboto/blob/master/Makefile#L39

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

@m4rc1e I patched the font files' yMin and yMax to match (otf -> ttx, patch values, ttx -> otf) and I get the same results.

@rsms
Copy link
Owner

rsms commented Feb 8, 2019

Here are the highest and lowest glyphs in the regular and black masters: (from a script in Glyphs)

Master: Regular
   Highest: Adieresismacron (top y: 3072.0)
   Lowest: ydotbelow (bottom y: -1084.0)

Master: Black
   Highest: Idieresisacute (top y: 3146.0)
   Lowest: ydotbelow (bottom y: -1196.0)

(looks normal)

@rsms rsms changed the title Different line-height for regular and bold on Inter 3.3 Line-height problem with regular compared to black Feb 8, 2019
@m4rc1e
Copy link
Contributor

m4rc1e commented Feb 8, 2019

Inter UI v3.2 seems to have the same issue.

screenshot 2019-02-08 at 17 56 04

@hmaesta what was the previous release you were using?

@hmaesta
Copy link
Author

hmaesta commented Feb 8, 2019

what was the previous release you were using?

Unfortunately I don't remember, but I don't believe it was 3.2 since I can't remember the last time I updated (so it must be a long time).

@m4rc1e
Copy link
Contributor

m4rc1e commented Feb 8, 2019

@hmaesta thanks. I can confirm 2.2 was ok.

screenshot 2019-02-08 at 18 35 39

@rsms Apologies for the goose chase. I may take a look at this on Monday...the beer is calling. Nice font btw! the progress between different versions is really impressive.

@rsms rsms changed the title Line-height problem with regular compared to black Line-height problem with regular compared to black (ATS bug) Feb 10, 2019
@rsms rsms added the bug Something that is now the way it's supposed to be label Feb 10, 2019
thundernixon added a commit to thundernixon/inter that referenced this issue Mar 21, 2019
@thundernixon
Copy link
Contributor

thundernixon commented Mar 21, 2019

This seems to still be an issue in v3.3, currently the latest release.

image

However, I (tentatively) think I may have resolved the issue (click image to see it bigger if the bounding boxes are too faint):

image

Pull Request with updates: #141


I have followed an earlier system suggested by @m4rc1e, using a script to apply custom parameters across all masters based on min and max heights, then rebuilding:

image

Sketch (Inter 3.4 WIP)

Variable

image

Static

image

TextEdit (Inter 3.4 WIP)

Variable

image

Static

image

@rsms
Copy link
Owner

rsms commented Mar 27, 2019

Confirming build off of master fb79b9e works correctly and fixes the issues. Nice work @thundernixon !

ATS based apps:
Screen Shot 2019-03-27 at 11 53 46
Screen Shot 2019-03-27 at 11 54 48

Freetype/Harfbuzz:
Screen Shot 2019-03-27 at 12 01 26

Here's a build of master fb79b9e if you want to try yourself:
Inter-3.4-fb79b9ee89.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is now the way it's supposed to be
Projects
None yet
Development

No branches or pull requests

6 participants