summaryrefslogtreecommitdiff
path: root/src/font/nerd_font_attributes.zig
AgeCommit message (Collapse)Author
2025-10-11fix(font): Additional scale group tweaks (#9152)HEADtipmainDaniel Wennberg
Of course #9142 would require a minor follow-up! * Scale groups can cut across patch sets, but not across fonts. We had some scale group mixing between Font Awesome and the weather symbols, which is removed by this PR.[^cp_table_full] * There's one case where a scale group includes a glyph that's not part of any patch sets, just for padding out the group bounding box. Previously, an unrelated glyph from a different font would be pulled in. Now we use an appropriate stand-in. (See code comment for details.) * I noticed overlaps weren't being split between each side of the bounding box, they were added to both sides, resulting in twice as much padding as specified. Screenshots showing the extra vertical padding for progress bar elements due to the second bullet point: **Before** <img width="191" height="42" alt="Screenshot 2025-10-11 at 15 33 54" src="https://github.com/user-attachments/assets/cf288cce-86d3-46fd-ae86-18e5c274b0e4" /> **After** <img width="191" height="42" alt="Screenshot 2025-10-11 at 15 33 20" src="https://github.com/user-attachments/assets/7ac799c7-bf50-4e65-a74a-f8a2c42d2441" /> [^cp_table_full]: Forming and using the merged `cp_table_full` table should have been a red flag. Such a table doesn't make sense, it would be a one-to-many map. You need the names of the original fonts to disambiguate.
2025-10-11font(fix): Extract and apply Nerd Font codepoint mapping table (#9142)Daniel Wennberg
Fixes #9076 **Before** <img width="128" height="57" alt="Screenshot 2025-10-11 at 00 07 09" src="https://github.com/user-attachments/assets/a6b416d5-dae1-4cea-a836-00640ceaf39b" /> **After** <img width="128" height="57" alt="Screenshot 2025-10-11 at 00 07 31" src="https://github.com/user-attachments/assets/7d2df7b1-4767-4e2d-84d2-8301da5c6602" /> These screenshots show the chevrons mentioned in https://github.com/ghostty-org/ghostty/discussions/7820#discussioncomment-14617170, which should be scaled as a group but were not until this PR. The added code downloads each individual symbol font file from the Nerd Fonts github repo (making sure to get the version corresponding to the vendored `font-patcher.py`) and iterates over all of them to build the correct and complete codepoint mapping table. The table is saved to `nerd_font_codepoint_tables.py`, which `nerd_font_codegen.py` will reuse if possible instead of downloading the font files again. I'm not going to utter any famous last words or anything, but... after this, I don't think the number of remaining issues with icon scaling/alignment is _large._
2025-10-03Handle font_patcher codepoint range overlapsDaniel Wennberg
2025-10-03Handle font_patcher codepoint offsetsDaniel Wennberg
2025-10-03Skip patchsets and codepoints not in SymbolsNFDaniel Wennberg
2025-10-03Add font_patcher's grouped vs individual alignmentDaniel Wennberg
2025-09-29Rewrite constraint code for improved icon scaling/alignmentDaniel Wennberg
2025-09-03font: constrain dingbatsQwerasd
This was a regression, we were giving dingbats an extra cell of constraint width but not actually applying constraints to them.
2025-07-25font: use non-mono symbols nerd font for embedded symbolsQwerasd
I changed my mind, this is a pretty small change and relevant to the intent of the PR. This brings the appearance of the embedded symbols much closer to patched fonts. With this, the sizes of most symbols are nearly identical to a patched font, the only big difference is positioning (and TBH I think we do a better job positioning than the patcher does, since we have knowledge about the cell size).
2025-07-08font: add scale groups to nerd font constraintsQwerasd
We do this by characterizing the shared bounding boxes in a static copy of the symbols only nerd font when we're doing the codegen. This allows us to get results of our scaling that are just as good as in a patched font, since related glyphs can now be sized and positioned relative to each other.
2025-07-07font: add icon height to nerd font constraintsQwerasd
Icons were often WAY too big before because they were filling the whole cell in height, which isn't great lol. This commit adds an `icon_height` metric which is used to constrain glyphs that shouldn't be the size of the entire cell.
2025-07-06font: fix nerd font patcher ypadding twice what it should beQwerasd
The nerd font patcher uses `ypadding` as a single subtraction from the cell height, which means that half of it should go to the top padding and the other half to the bottom, this was making the heavy brackets way too small lol (0.4 of the cell height instead of 0.7)
2025-07-06font: respect cell width attributes in nerd font constraintsQwerasd
This mostly applies to powerline glyphs, but is also relevant for heavy bracket characters, which need to always be 1 wide otherwise they look silly because they misalign depending on if there's a space after them or not.
2025-07-06font: fix nerd font codegen to handle ypadding properlyQwerasd
Previously `ypadding` was effectively ignored, since it's mutually exclusive with `overlap`. This had a noticeable effect on the heavy bracket characters U+276C...U+2771, which were much taller than they should have been. I also fixed the vertical overlap limit, since negative `overlap` values are used in the nerd font attributes to create padding on all sides of the cell, so we don't want to limit the magnitude of the overlap for vertical padding, we only want to limit it if the value is positive. That change fixed the vertical padding for a handful of ranges, which should give more consistent results.
2025-07-06refactor nerd font codegen scripttrag1c
2025-07-04font: generate glyph constraints based on nerd font patcherQwerasd