Configurable UI font size: scale look-and-feel fonts, and the constants that clip - #1902
Closed
jcschaff wants to merge 2 commits into
Closed
Configurable UI font size: scale look-and-feel fonts, and the constants that clip#1902jcschaff wants to merge 2 commits into
jcschaff wants to merge 2 commits into
Conversation
Groundwork for a configurable UI font size. Walks the look-and-feel defaults after setLookAndFeel and multiplies every Font, before any window is built, because a Swing component resolves its font once at construction. Fonts are written back as FontUIResource rather than plain Font: a plain Font reads as a user-set override, which would stop the look and feel managing it. This reaches only fonts obtained implicitly from the look and feel. The ~138 sites that construct a Font with a literal point size keep theirs and must be converted separately - that is the next phase, and this commit is what makes the cost of it measurable. The scaling also runs on every platform. The existing 39-key UIManager.put block is inside `if (isMac)`, so Windows and Linux had no font handling at all; scaling is applied before that block so the Mac path derives from it rather than undoing it. Default 1.0 is a no-op. Unparseable or out-of-range values log and fall back to 1.0 rather than preventing the client from starting. Measured at 1.25 against a live client (bridge-captured component trees, 93 components matched): 17 grew wider, 71 kept their width. Damage is confined to fixed-width containers, chiefly the left navigation panel - tree labels clip without an ellipsis, a database tab is pushed out of the tab strip into scroll mode, and a horizontal scrollbar appears. Nothing failed to lay out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
At 1.25 the left navigation panel was where every visible defect was: tree
labels clipped without an ellipsis ("Parameters, Functions, Units, etc." lost
its period), counts truncated mid-digit ("(538)" became "(53"), the database
tab strip pushed "Pathway Comm" out into scroll mode, and a horizontal
scrollbar appeared.
None of that came from a font: it came from splitPane.setDividerLocation(270),
which pins the panel's width in pixels. Measured across two live runs, the
components inside it - LeftBottomTabbedPane, DatabaseWindowPanel and the three
tree panels - kept their exact widths while buttons and checkboxes elsewhere
grew normally, because those sit in GridBag cells that size from preferred
size.
Adds VCellLookAndFeel.scaleTextPixels for constants that bound text, and
applies it to the two divider locations and two minimum sizes here. Icon
sizes, insets and borders are deliberately out of scope - they should not move
with the font.
Verified at 1.25: LeftBottomTabbedPane 264 -> 332, BioModelDbTreePanel1
222 -> 290, both exactly the requested scale, and all four defects above are
gone. Inert at the default 1.0.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for a user-settable UI font size, plus the first round of layout fallout. Inert at the default scale of 1.0 — nothing changes unless
-Dvcell.ui.fontScaleis set.Why this route
-Dsun.java2d.uiScalewas evaluated first, since it would have made most of this unnecessary. It won't:On macOS the JDK derives scale from the display and ignores the property outright. Where it is honored, it multiplies only the device transform — Swing lays out in logical units, which the flag never touches. That is why it can never clip, and equally why it cannot make text more readable at a fixed window size. It magnifies; it does not enlarge. Worth keeping in mind as a separate, zero-code answer to "VCell is tiny on my 4K monitor".
What this does
VCellLookAndFeelwalks the look-and-feel defaults aftersetLookAndFeeland multiplies everyFont, before any window is built — Swing components resolve their font once, at construction. Fonts are written back asFontUIResource, not plainFont: a plain one reads as a user-set override and the L&F would stop managing it.The scaling also now runs on every platform. The existing 39-key
UIManager.putblock sits insideif (isMac), so Windows and Linux had no font handling at all. Scaling is applied before that block, so the Mac path derives from it rather than undoing it.Bad input can't stop the client starting — unparseable or out-of-range values log and fall back to 1.0.
What broke at 1.25x, and why
Measured against a live client via the debug bridge — 93 components matched across two runs, 17 grew wider, 71 kept their width.
Every visible defect was in the left navigation panel: tree labels clipped with no ellipsis (
Parameters, Functions, Units, etc.lost its period), counts truncated mid-digit ((538)→(53), the database tab strip pushedPathway Commout into scroll mode, and a spurious horizontal scrollbar appeared.None of it came from a font. It came from
splitPane.setDividerLocation(270)inDocumentEditor, pinning the panel's width in pixels. The component data is unambiguous: inside that panelLeftBottomTabbedPane,DatabaseWindowPaneland all three tree panels held their exact widths, whileModelDeleteButton(77→88) andShowWarningsCheckBox(113→138) grew normally elsewhere. GridBag cells size from preferred size and adapt; pinned dividers don't.Adds
VCellLookAndFeel.scaleTextPixelsfor constants that bound text, applied to the two divider locations and two minimum sizes here. Icon sizes, insets and borders are deliberately out of scope — they should not move with the font.After the fix at 1.25x:
LeftBottomTabbedPane264 → 332 andBioModelDbTreePanel1222 → 290, both exactly the requested scale, and all four defects resolved.What this deliberately does not do
The ~138 sites that construct a
Fontwith a literal point size keep theirs — a plainFontis immune to the L&F. Converting them is the next phase.Notably, none of those caused a visible defect at 1.25x, because most sit in layouts that adapt. That reorders the work: the pinned pixel constants matter more than the font constants. There are 26 further hard-coded
setDividerLocationcalls across the client that want the same treatment.🤖 Generated with Claude Code