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

ClearType rendering issue with transformed components (was "Braces are asymmetric for some font sizes") #251

Closed
ForNeVeR opened this issue Mar 27, 2020 · 33 comments
Assignees
Labels
bug Something that is now the way it's supposed to be Microsoft/Windows Microsoft Windows is a constant source of font issues :–)

Comments

@ForNeVeR
Copy link

For some font sizes (e.g. 16px) braces ([](){}) look asymmetric, the right one may be drawn lower or higher than the left one.

For example, visit this link: https://rsms.me/inter/lab/?size=16&antialias=default and enter braces into the first text line:

Expected behavior
Braces should be symmetric and have the same height/position for all font sizes.

Screenshots
image

Environment

  • OS: Windows 10 1909
  • App that renders the font: Chrome
  • Display size/scale: 3840 × 2160, 150%
  • Version of font: sorry, I don't know; wasn't able to find this information on the font test site
@rsms
Copy link
Owner

rsms commented Apr 4, 2020

Interesting. This seems to be a Windows-specific issue as I an unable to reproduce in Chrome, Safari or Firefox on mac. I will check on my Windows computer as well, but in the meantime, would you mind trying the following things?

  • Check in a different browser like Edge (stable, non-chromium; the one that ships with Windows) and/or Firefox? Do you see the same issue there?
  • Turn on variable font (use this link for a shortcut)

@rsms rsms added the Microsoft/Windows Microsoft Windows is a constant source of font issues :–) label Apr 4, 2020
@g-cqd
Copy link

g-cqd commented Apr 4, 2020

I get the same issue on :


  • Safari : Version 13.1 (15609.1.20.111.8)

Screenshot 2020-04-04 at 23 00 40


  • Safari Technology Preview : Release 103 (Safari 13.2, WebKit 15610.1.7.3.2)

Screenshot 2020-04-04 at 23 00 05


  • Firefox Developer Edition : 75.0b11 & 75.0b12

Screenshot 2020-04-04 at 23 05 14

@be5invis
Copy link

be5invis commented Apr 5, 2020

@rsms Should be another issue related with transformed component references. This is how GID 1331 shown in VTT:
image
Note that, this component is also set rounded, so Macintosh may also have problems.

@schriftgestalt is it possible to tell Glyphs not to use transformed components? Font tools really really dislike that. Glyphs could unlink a component if it is trasnformed.

@Felix-MFU
Copy link

Felix-MFU commented Jul 3, 2020

The experienced the same issue on Sketch (MacOS Catalina). It seems to have to do with the calt (Contextual Alternates feature. It works on capital letters only after letter, but not before it. So the left brace gets positioned wrongly (no reposition), and the right one correctly (reposition).

In Chrome on the other hand braces are positioned correctly.

––––

Turns out that the left bracket repositions like follows:
(M) brackets move upwards correctly
(a) brackets stay low as expected
(Ma) brackets stay low –> left bracket should move upwards instead
(Maaa) left bracket moves upwards correctly

–> When at least 4 characters are entered using mixed small and capital letters, the brackets behave as expected.

@schriftgestalt
Copy link

Sorry for taking so long. Flipped or rotated components are decomposed by default.

@be5invis
Copy link

@schriftgestalt It looks like Inter used its own script to generate TTF from Glyphs source 🤦. Time to fix that.

@rsms
Copy link
Owner

rsms commented Aug 17, 2020

Indeed this looks like an issue with intended behavior with unexpected results — i.e. not a bug but also not ideal. Inter uses an OpenType feature called "contextual alternates" which is used to replace certain glyphs in certain contexts with specialized glyphs. For example, Inter provides a left parenthesis specialized for capital letters. When a left parenthesis is adjacent to a capital letter, it is replaced by the special one. However, the rules are more complex that this and includes exceptions, which is what causes the issue you see. Specifically, "x (M" vs "(M" — in the first case the adjacent lower-case letter "x" invokes an exception to not perform the substitution.

@rsms
Copy link
Owner

rsms commented Aug 18, 2020

I made some improvements in ebdfaf2

Here is the result of /lab/?sample=Feature%3A%20calt&size=24&varWeightNum=446 (master, not the website)
Screen Shot 2020-08-17 at 17 15 55

Screen Shot 2020-08-17 at 17 19 00

@rsms
Copy link
Owner

rsms commented Aug 18, 2020

Some improvements to this has been released as part of version 3.14

@ForNeVeR
Copy link
Author

I'm sorry, but I can't see any improvements.

I can see that the braces are rendered differently if there's an adjacent capital letter (they go up a little), but the opening and closing brace still have different lifting, which, on my screen, differs from what I see on your screenshot. Here're the current results from https://rsms.me/inter/lab/?antialias=default&size=16 (which, I believe, has been updated to use 3.14 already? By the way, could we have a font version being printed on the website?)
image

And, for comparison, with space or a non-capital letter before and of the braces:
image

(they're drawn lower, but opening and closing brace are still noticeably different)

@rsms
Copy link
Owner

rsms commented Aug 18, 2020

Interesting! So perhaps this is Windows-specific after all. I’ll test on a Windows machine...

@be5invis
Copy link

be5invis commented Aug 18, 2020

@rsms You can try with Visual TrueType, select the glyphs, select an anti-aliasing mode (TTFA should using "CT(anti-aliased)"), enable grid fitting (Ctrl+G) and zoom in to see the pixel-level difference.

@rsms
Copy link
Owner

rsms commented Aug 18, 2020

Thanks! I'll try that.

@be5invis
Copy link

This issue may also influence certain Linux users (depending their fontconfig settings).

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

I've spend a good deal of time this evening trying to reproduce the issue but I'm falling flat. I've tried all major browser, macOS and Windows 10 as well as following @be5invis's advice with Visual TrueType. The results I'm seeing are the expected ones (i.e. "()" are aligned and not offset.) Is there any details we might be missing here?

How I'm testing:

  1. Open https://rsms.me/inter/lab/ in a web browser
  2. Select all and paste to replace the sample below
  3. Inspect and screenshot

sample:

ABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()
abcdefghijklmnopqrstuvwxyz[]{}()
0123456789!?.

Note that https://rsms.me/inter/lab/ does not use font files with TTF hints.

Some screenshots of what I'm seeing:

Visual TrueType, setup as suggested in #251 (comment)

Screen Shot 2020-08-18 at 18 55 49


macOS:
Screen Shot 2020-08-18 at 18 25 40
Screen Shot 2020-08-18 at 18 25 54
Screen Shot 2020-08-18 at 18 26 19


Windows 10:
Screen Shot 2020-08-18 at 18 41 39

@be5invis
Copy link

@rsms You could try using ↑ or ↓ to increase or decrease PPEM in VTT. This issue only occurs at certain PPEM sizes.

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

Hm. I'm not seeing any changes to positioning of left and right parenthesis across sizes.

Perhaps the component transformation (right parenthesis is a component instance) gets messed up somehow on Windows.

Tomorrow I'll try to decompose everything in the font (which will explore the file size but allow me to test this theory.) If this is the case, with component transformation issues on Windows, then perhaps I could offer a decomposed and larger font for Windows specifically.

@be5invis
Copy link

@rsms It is a feature: you are using rounded component references in ), and this component is flipped, and you have hinting, so the rasterizer correctly interpreted the hinted (, rotated it, and translated but using an rounded offset, so they become asymmetric, since you added a lot of rounding (component offset and hinting).

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

Hm, but there are no hints in these fonts. The hinted TTF fonts are not served from the website (/inter/lab/).

My understanding of the issue, as I read it in the description of this issue, is that things are rendered incorrectly in the web browser when viewing https://rsms.me/inter/lab/, which does not serve font files with hints.

Let me ask a clarifying question: Is it possible that we are discussing two different issues here? I.e. rendering in web browsers AND hinting data of the hinted fonts.

What I'm testing and debugging is the rendering of https://rsms.me/inter/lab/ (as described in the OP.)

This is what I'm seeing walking through rasterization sizes in Visual TrueType, using the most recent release: (v3.14, no hints. two videos stitched together)
dfs8n91iukjs

@be5invis
Copy link

be5invis commented Aug 19, 2020

@rsms Could you press CTRL + 2 and show me the glyph program of )?
I expect there's a line starts with SOFFSET[R], where the uppercase R means rounded. Changing it to r could immediate fix this issue.

@be5invis
Copy link

SOFFSET[r] + transformed components, perfectly symmetric:
image

SOFFSET[R] + transformed components, slightly asymmetric:
image

The best solution to this should be unlinking all the components that is transformed -- which shouldn't have a lot.

@schriftgestalt
Copy link

You can skip all tests on MacOS as it ignores TrueType instructions.

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

@be5invis This is what the CTRL+2 shows me for the glyph program
Screen Shot 2020-08-19 at 09 43 48

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

Now, if I open a font file with TTF hints (from ttfautohint) I do see a program for the glyph as expected, but as I mentioned earlier, the fonts on the website do not have TTF hints.

Screen Shot 2020-08-19 at 09 50 55

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

Repro on Windows with ClearType enabled: (or Linux with ClearType or similar technology enabled in e.g. FreeType)

  1. Install or load Inter Regular with TrueType hints: Inter-Regular-hinted-v3.14.ttf.zip (release v3.14)
  2. Use an app that uses the system font renderer, like Notepad
  3. Type "ABC()[]{}"
  4. Set font to Inter Regular, size 12

This should yield right parenthesis with an unwanted offset on the y axis, as shown in this screenshot:

Screen Shot 2020-08-19 at 12 39 06


Repro on Windows in a web browser (for some reason this is not reliable for me; sometimes it repros sometimes not. Very strange.)

  1. Open https://rsms.me/inter/lab/?antialias=default&sample=ABC()%5B%5D%7B%7D&size=12 in Edge

Screen Shot 2020-08-19 at 12 44 07

@rsms rsms added the bug Something that is now the way it's supposed to be label Aug 19, 2020
@rsms rsms self-assigned this Aug 19, 2020
@rsms rsms changed the title Braces are asymmetric for some font sizes ClearType rendering issue with transformed components (was "Braces are asymmetric for some font sizes") Aug 19, 2020
@rsms rsms closed this as completed in 7d70535 Aug 19, 2020
@rsms
Copy link
Owner

rsms commented Aug 19, 2020

Here's a new build of the fonts, incorporating the changes landed in 7d70535
Inter-3.14-text-ca7d79eb20-issue-251.zip

This is what it looks like on Windows 10 in Notepad:
Screen Shot 2020-08-19 at 13 52 25

This is what is looks like on the website in Windows 10: (left is static font, right is variable)
Screen Shot 2020-08-19 at 14 04 08

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

@ForNeVeR @aemi-dev Would you mind installing the fonts in the zip attached in the previous comment above and let me know if that solves the issue for you?

@g-cqd
Copy link

g-cqd commented Aug 19, 2020

Issue is solved. I'm using macOS.
However :

Firefox
ffox
Google Chrome
gchrome
Safari
safari

We can notice that Google Chrome handles this differently.

@rsms
Copy link
Owner

rsms commented Aug 19, 2020

Excellent news. Thank you @aemi-dev!

@rsms
Copy link
Owner

rsms commented Aug 20, 2020

This has now been released as part of version 3.15 🎉
Try it out here: https://rsms.me/inter/lab/

@rsms
Copy link
Owner

rsms commented Aug 20, 2020

Some ClearType rendering samples from Windows 10 using the v3.15 hinted font files:

cleartype-samples@2x

@ForNeVeR
Copy link
Author

Thanks a lot for your work on figuring our the issue and fixing it! I confirm that it has been resolved completely.

@citizenkade
Copy link

Sorry to dredge up this issue. Just experienced it with Inter in Figma on a mac. Not a big deal. Just thought it was an interesting problem and Googled it. Ended up here.

Screenshot 2024-11-12 at 3 00 57 PM

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 Microsoft/Windows Microsoft Windows is a constant source of font issues :–)
Projects
None yet
Development

No branches or pull requests

7 participants