-
Notifications
You must be signed in to change notification settings - Fork 214
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
The baseline position is a bit high #37
Comments
I would guess that is the result of the line gap. You can correct that with If you do a Nerd Font patch it will (has to) distribute the gap for you: |
Thanks @Finii that's great insight. Looking at the way my terminal (and many others) calculate cell heights and baselines, I think I was handling the leading metric incorrectly. In CoreText, that's
The issue is this doesn't properly distribute the leading value equally across top and bottom for terminal cell grids. This doesn't cause an issue in many fonts because at least of the few I tested (Monaco, JetBrains Mono, Berkeley, Fira) they have a zero leading value. But Monaspace has a non-zero leading value. I'm not 100% sure this is correct, but I changed the formula to the following instead, and the results look much better:
This distributes the leading equally across the top/bottom by adjusting the baseline. |
Hi If you are using Kitty |
@mitchellh Additionally the problem is of course how to handle the three different sets of metrics in fonts that contradict themselves ;-) In principle the whole concept of a line gap does not really resonate with terminal cells. Most terminal fonts have a zero gap, and NerdFonts removes any gap of sourcefonts. Why have a gap? Haralambous has not much to say in Fonts & Encodings: Here code done long ago, it even takes use-typo-metric into account 🙄 # Step 1
# There are three ways to discribe the baseline to baseline distance
# (a.k.a. line spacing) of a font. That is all a kuddelmuddel
# and we try to sort this out here
# See also https://glyphsapp.com/learn/vertical-metrics
# See also https://github.com/source-foundry/font-line
(hhea_btb, typo_btb, win_btb, win_gap) = get_btb_metrics(self.sourceFont)
use_typo = self.sourceFont.os2_use_typo_metrics != 0 [1] https://glyphsapp.com/learn/vertical-metrics |
Thanks for the reply! I managed to fix this by patching with nerd font.
This should also work. |
@ryankask, it's terminal dependent. Basically Monaspace uses some font properties not typically used by monospace fonts and many terminals are not handling it quite right. There was a fix for the Kitty terminal named above which worked great for me, see if you can find something similar for your terminal or open an issue with it. |
Thanks! This is for emacs rather than a terminal but looking at Mitchell's comment and searching for I'm curious if any emacs users on Windows or Linux see the same baseline positioning issue. |
Don't you run Emacs from within a terminal? Or is this some kind of weird graphical Emacs? I'm not very familiar with how you run it, I always assumed it was like Vim. |
Hey guys, I am seeing a similar issue in Sublime Text (and Sublime Merge): I can tweak it in the editor to achieve equal spacing (but the caret not aligning with the line highlight is killing me): It looks a bit worse in Sublime Merge: But it can be helped by adding these two properties when editing the settings file (you may need to adjust the padding values for the font size you are using):
And it ends up looking better: I know this is not perfect but it might help if someone else wants to try out the new fonts. :) |
Maybe just push the font through Which's report looks more or less ok:
I guess the problem is your client that Nerd Fonts removes the gap and puts it half on top and half on bottom of the ordinary 'cell', which looks ok-ish I guess: $ fontforge font-patcher src/unpatched-fonts/Monaspace/Neon/MonaspaceNeon-Regular.otf --debug 2 2>/dev/null
Nerd Fonts Patcher v3.2.1-3 (4.13.1) (ff 20230101)
DEBUG: Naming mode 1
DEBUG: Monospace check: Panose is invalid ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); glyph-width-mono True
INFO: Setting Panose 'Family Kind' to 'Latin Text and Display' (was 'Any')
INFO: Setting Panose 'Proportion' to 'Monospaced' (was 'Any')
INFO: Redistributing line gap of 400 (200 top and 200 bottom)
DEBUG: Final font cell dimensions 1240 w x 2400 h
Adding 188 Glyphs from Seti-UI + Custom Set
╢████████████████████████████████████████╟ 100%
... ..... Oh just notices I wrote the same already some time ago. Seemed to not help people. In principle I would recommend the font designers to remove the gap from Monaspace as different clients unfortunately have different ideas how to handle it. |
- githubnext#21 githubnext#37 "Hanging Font": Miss configure `typo` and `hhea` value. Adjust this value will "centering" glyphs across the vertical bounding box. - githubnext#169 Probably same as above, tweaking `typo` and `hhea` does resolve the `line-height` or `leading` default to `1.2` or `120%` from the upm value. UPM = 2000 (typo/hhea)Ascenders = 1930 (typo/hhea)Descenders = -470 (typo/hhea)LineGap = 0 Total: ascender + abs(descenders) + linegap = 2400 Note that "Gcommaaccent" may be truncated in environments that have `overflow: hidden` Please see these documentation: - https://googlefonts.github.io/gf-guide/metrics.html#6-winascent-and-windescent-values-must-be-the-same-as-the-familys-tallestdeepest-ymin-and-ymax-bounding-box-values - https://googlefonts.github.io/gf-guide/metrics.html#11-the-sum-of-the-fonts-vertical-metric-values-absolute-should-be-20-30-greater-than-the-fonts-upm
Not sure if I am misconfigured on something, the font characters go a bit high in a line, both in Kitty and VSCode:
The text was updated successfully, but these errors were encountered: