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

Underline position and thickness metrics are not correct #395

Closed
simast opened this issue Dec 31, 2020 · 5 comments · Fixed by #402
Closed

Underline position and thickness metrics are not correct #395

simast opened this issue Dec 31, 2020 · 5 comments · Fixed by #402

Comments

@simast
Copy link

simast commented Dec 31, 2020

Environment

Cascadia Code version number: 2009.22
Application (with version) used to display text: Windows Terminal 1.4.3243.0
OS platform and version: Windows 10
Screen resolution (i.e. 220dpi):  -

Steps to reproduce

Inspect underline thickness and position with larger font sizes.

Expected behavior

I expect underline to be more thick with larger font sizes (if you compare to other fonts).

Actual behavior

Seems like underline thickness is always reported around 1px. I suspect that underline position metric is also off (should probably be offset by more pixels with larger font sizes, as right now this seem to be constant value no matter the size).

Screenshot showing the issue in Windows Terminal (with font size set to 40px):

underline-metrics-issue

@kenmcd
Copy link

kenmcd commented Jan 1, 2021

Text editors or DTP apps which support font styles etc. will typically override the underline settings in a font and instead replace it with a horizontal rule under the baseline.
This avoids issues with all the wacko underline settings in some fonts and provides more control. Found one recently which had an underline thickness setting of 0 (zero), so no underline appeared at all. This is why editors simply use their own settings.
Cascadia Code has the same underline settings in all fonts.
So if the editor actually uses them an underline will be even across all the weights.
Some fonts have different underline settings in different weights.
In less advanced editors this results in broken underlines with different weights on one line.
So more advanced editor apps override the settings for a better one-size rule.
In LibreOffice it sets a weight on the rule based on the starting font weight.
No control other than that.
In advanced DTP apps like InDesign you have control over both the thickness and the vertical placement of the underline rule.

Back to your issue ...
Most likely Windows Terminal is setting the thickness and the placement of the underline rule.
You can check this by trying a different font.
My guess is you will end up with the same underline with any font selected.
Most code editors are not going to be used set at a 40 pixels font size.
So they selected an underline thickness of 1 pixel which is more appropriate for an expected font size setting of say 10-13 pixels, and they work around any odd hinting issues.

So not likely a Cascadia Code font issue. Just the way smarter editor apps work with underlines.

@simast
Copy link
Author

simast commented Jan 1, 2021

I did try other fonts with Windows Terminal, just for comparison:

Courier New:

courier-new

Consolas:

consolas

Cascadia Mono:

cascadia-mono

It seems Windows Terminal now strictly relies on those metrics to draw underlines. I was not aware some fonts don't fill this properly or leave values at 0 as you mentioned. If that's the case then it makes sense for renderers to somehow ignore those metrics or try to figure them in other ways. But it is probably not a hard fix to fill this in Cascadia Code for better compatibility.

@kenmcd
Copy link

kenmcd commented Jan 1, 2021

Yes, you are right.
I compared the underline metrics on those three fonts and the settings directly correspond to your image.
So the underline settings in Cascadia Code would need to be changed to affect your issue.

@kenmcd
Copy link

kenmcd commented Jan 2, 2021

Compared the underline settings in Cascadia Code, Fira Code, Courier New, Source Code Pro, JetBrains Mono, and Consolas.
Cascadia Code underlines are less than half the thickness of Source Code Pro and JetBrains Mono.
But close to Fira Code.

Undeline-Comparison-trimmed

DHowett pushed a commit that referenced this issue Feb 9, 2021
This is a significant update to Cascadia Code including a large number
of bug fixes as well as updating the font to offer support for Fira
Code v5 ligature support. 

This update supersedes PR #373.

Closes #262 - ⏎ added
Closes #264 - additional codepoints for control characters added
Closes #281 - `!:` and `!.` added
Closes #290 - `/\` and `\/` added
Closes #301 - `??=` added
Closes #324 - ℞ added
Closes #327 - `<:>` and other variants implemented via the `calt`
  refactoring
Closes #359 - house added
Closes #371 - Added x-height instruction into ttfautohint to control the
  height of the lowercase.  
Closes #375 - Completely redesigned quote marks for better recognition
Closes #377 - updated hinting to achieve more consistent results
Closes #381 - increased height of thetamod
Closes #382 - reduced the width of the hooklefts
Closes #383 - updated heights on esh, glottalstop, glottalstopreversed
Closes #384 - tweaked hinting a little bit. Maybe it'll help :)
Closes #386 - added remaining soft-dotting
Closes #392 - changed designs of angled quotes (they are now round)
Closes #394 - changed former `~=` symbol to a simpler component-based
  version. Should be less confusing now for Lua / Matlab users. 
Closes #395 - makes the underline thicker based on font weight
Closes #400 - increased size of degree

Closes #219 
The full control pictures block has been added (u+2400 to u+2426). For
purposes of rendering, the two letter abbreviations have been used
instead of the standard three letter abbreviations:

Additionally, ss20 includes the oft-unused graphical representations of
these codepoints (for fun!):

Closes #276 (infinite arrows)
Full support for Fira Code's current ligature set (with a few
exceptions). Now featuring infinite arrows!!! 

This involved a full refactoring of the `calt` feature—for those
interested, it now uses forward-looking substitutions instead of
backward-looking substitutions and progressive substitution to reduce
code. This also required some redesigning of the greater / lesser
related ligatures. Please note, I have also removed all the obsolete
ligatures now covered by the arrows code.

Closes #329 
There was a mismatch in the font's postscript naming conventions that
was corrected. Should now render all weights in Word. **Note** there is
apparently an additional bug in Mac Word's implementation of variable
fonts which should be available in an update mid-Feb. 

* Not listed – Reworked the hints for the mod and superscript glyphs so
  that they're bottom-up rather than top-down. This allows for better
  bottom alignments. 

Aside from the above changes, this version also includes many other
small updates including spacing, outline quality improvements, and
fixing hinting.
@aaronbell
Copy link
Collaborator

aaronbell commented Feb 24, 2021

Per issue #428, use of the MVAR table (required for the solution to this issue in the Variable font) can cause problems. As such, I will have to roll-back the fix for this issue until the MVAR has better coverage cross-platform.

I will increase the overall weight of the underline so it isn't quite so thin, but it won't be weight-responsive :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants