mirror of
https://github.com/keycastr/keycastr.git
synced 2026-10-23 08:07:30 -06:00
[PR #355] Let visualizers draw keystrokes in a user-chosen font #355
Labels
No labels
bug
compatibility
discussion
documentation
enhancement
help wanted
help wanted
investigation needed
pull-request
release
visualizer
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github-starred/keycastr#355
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/keycastr/keycastr/pull/355
Author: @anandghegde
Created: 9/19/2026
Status: 🔄 Open
Base:
main← Head:feature/selectable-visualizer-font📝 Commits (1)
39df5e7Let visualizers draw keystrokes in a user-chosen font📊 Changes
14 files changed (+444 additions, -28 deletions)
View changed files
📝
keycastr/KCDefaultVisualizer.m(+2 -1)📝
keycastr/KCDefaultVisualizer.nib/designable.nib(+34 -7)📝
keycastr/KCDefaultVisualizer.nib/keyedobjects.nib(+0 -0)➕
keycastr/KCFontPopUpButton.h(+45 -0)➕
keycastr/KCFontPopUpButton.m(+115 -0)➕
keycastr/KCVisualizerTests/KCFontSelectionTests.m(+121 -0)📝
keycastr/KeyCastr.xcodeproj/project.pbxproj(+12 -0)📝
keycastr/Minimal.xib(+39 -12)📝
keycastr/MinimalVisualizer.m(+2 -1)📝
keycastr/NSUserDefaults+Utility.h(+5 -0)📝
keycastr/NSUserDefaults+Utility.m(+24 -0)📝
keycastr/Svelte.nib/designable.nib(+29 -2)📝
keycastr/Svelte.nib/keyedobjects.nib(+0 -0)📝
keycastr/SvelteVisualizer.m(+16 -5)📄 Description
Closes #169.
Every bundled visualizer already lets you pick a font size; the typeface has always been hardcoded to the system font. The request in #169 is for fixed-width —
Ivslare indistinguishable in the system font, which matters a lot when you're recording a tutorial — but it's just as useful for matching a visualizer to a theme.What this adds
A Font pop-up in each of the three bundled preference panes, directly above the existing Font Size control (Svelte has no size control, so it sits under "Display All Keystrokes"). Each pane stores its own choice:
default.fontNameminimal.fontNamesvelte.fontNameThe menu lists every installed family, each drawn in its own typeface, so it reads as a specimen sheet rather than a wall of identical text. The first item is "System Font", which is the default and restores today's behaviour exactly.
How it's put together
KCFontPopUpButtonis a smallNSPopUpButtonsubclass that populates itself fromNSFontManagerand reads/writes whichever defaults key the nib hands it viafontFamilyDefaultsKey(a user-defined runtime attribute). One class covers all three panes, and any future visualizer gets font selection by dropping the control into its nib and setting that one attribute.Font resolution is
-[NSUserDefaults fontForKey:size:bold:], sitting next to the existingcolorForKey:/imageForKey:helpers. It always returns something drawable:Minimal is the only visualizer that asks for bold, matching its current
boldSystemFontOfSize:.Two judgement calls worth flagging
Svelte applies the font to the key label only, not the modifier strip above it. That strip is ⌘⌥⇧-style iconography and reads better kept in the system font; a decorative display face makes it much harder to parse at a glance.
Svelte's shrink-to-fit loop gained a minimum size. It previously ran
while (size.width > frame.size.width - 10) fontSize -= 1.0;with no floor. That was unreachable with the system font, but a user-selectable wide face makes it reachable, so it now stops at 8pt.Tests
New
KCFontSelectionTestscovers the resolution rules (unset, empty, installed, bold fallback, uninstalled family) and an integration test that instantiates the Default and Svelte preference views from their nibs and asserts each one has a font pop-up bound to its own key with a populated menu. That last one is what proves the nib wiring actually survives — the legacywrapper.nibbundles can't be diffed usefully by eye.To make the helper testable,
NSUserDefaults+Utility.his now a public header of theKCVisualizerframework.Minimal isn't in that integration test because only
KCDefaultVisualizer.kcpluginandSvelte.kcpluginare copied into the test bundle's plug-ins. Its pane is a plain xib and gets validated when the project builds; I verified all three panes' computed layouts by hand, including re-seating the separator boxes in Default and Minimal, which use autoresizing rather than autolayout and so don't move with the rest of the pane.Both
wrapper.nibbundles were recompiled withibtooland produce no errors or warnings. The full test suite passes.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.