Skip to content

feat: optionally use typographical width#826

Open
erics118 wants to merge 1 commit into
FelixKratz:masterfrom
erics118:typographical-width
Open

feat: optionally use typographical width#826
erics118 wants to merge 1 commit into
FelixKratz:masterfrom
erics118:typographical-width

Conversation

@erics118

Copy link
Copy Markdown
Contributor

This is a follow-up to #692 that added font features like tnum.

After that PR, tnum would not work properly, because we weren't using the right attribute to decide on character width.

CTLineGetBoundsWithOptions gets us the actual bounds where the character is drawn, but we actually need to use CTLineGetTypographicBounds so that we can properly render the extra spacing for each character.

This PR introduces a typographical_width option to the font field that enables using the slightly larger bounds for each character.

I added this as off by default because this otherwise, it would be a breaking change and makes every (most?) item slightly wider than before.

Now, tnum will actually work properly.

example using the SF Pro font:

Before this patch (without tnum): observe lots of jumping around

CleanShot.2026-06-10.at.11.48.28.mp4

Before the patch (with tnum): exact same as without tnum

CleanShot.2026-06-10.at.11.47.17.mp4

After the patch (with typographical_width and `tnum): no jumping around

CleanShot.2026-06-10.at.11.45.25.mp4

Looking at the actual widths, the issue and fix is a lot more clear:

method 0 1 2 3 4 5 6 7 8 9
pre pr 5.789 3.100 5.801 5.865 5.971 5.777 5.754 5.836 5.766 5.672
pre pr,tnum 5.789 3.100 5.801 5.865 5.971 5.777 5.754 5.836 5.766 5.672
typographic,tnun 6.674 6.674 6.674 6.674 6.674 6.674 6.674 6.674 6.674 6.674

khaneliman added a commit to khaneliman/khanelinix that referenced this pull request Jun 11, 2026
Apply temporary SketchyBar patches for upstream font feature work so local config can exercise OpenType tags and typographical widths.

References upstream PRs:

- FelixKratz/SketchyBar#826

- FelixKratz/SketchyBar#828
khaneliman added a commit to khaneliman/khanelinix that referenced this pull request Jun 11, 2026
Use fixed label, icon, and stack widths so font-feature-enabled SketchyBar metrics stay aligned after typographical width support.

Trim command output before rendering memory and disk percentages to avoid newline artifacts in labels.

Builds on upstream SketchyBar PRs:

- FelixKratz/SketchyBar#826

- FelixKratz/SketchyBar#828
@khaneliman

Copy link
Copy Markdown

Works well in my testing, solves some issues i've had with aligning things that change values constantly in the bar. Thanks for doing this.

@acsandmann

Copy link
Copy Markdown

Great pr fixes a long standing issue

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 this pull request may close these issues.

3 participants