Skip to content

Scale font line and tab advance by the font scale factor - #7760

Open
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/fred_label_line_spacing
Open

Scale font line and tab advance by the font scale factor#7760
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/fred_label_line_spacing

Conversation

@Goober5000

@Goober5000 Goober5000 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Multi-line and tabbed strings drawn with a scaleMultiplier != 1 overlapped or misaligned because the font code advanced newlines and tabs by the unscaled font height/tab width -- most visible in FRED's viewport labels now that they honor an adjustable font scale.

Scale the newline and tab advance in both the rendering and measurement paths of each backend: the NVG path (gr_string and NVGFont::getStringSize) and the VFNT path (gr_string_old and VFNTFont::getStringSize), which also gains tab handling. The tab width is hoisted onto the shared FSFont base so both backends share it.

While here, pass the FSFont wrapper to gr_string_old instead of a bag of scalars, make its font pointer const, and consolidate the get_char_width_old externs into a single declaration in font_internal.h.

Fixes an engine bug that #7745 uncovered. Tested in FRED and QtFRED with both VFNT and NVG fonts at different scaling settings.

@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. graphics A feature or issue related to graphics (2d and 3d) labels Sep 3, 2026
@Goober5000 Goober5000 added this to the Release 26.2 milestone Sep 3, 2026
@Goober5000
Goober5000 force-pushed the fix/fred_label_line_spacing branch 2 times, most recently from d6b7928 to f855a88 Compare September 3, 2026 05:40
Multi-line and tabbed strings drawn with a scaleMultiplier != 1 overlapped
or misaligned because the font code advanced newlines and tabs by the
unscaled font height/tab width -- most visible in FRED's viewport labels
now that they honor an adjustable font scale.

Scale the newline and tab advance in both the rendering and measurement
paths of each backend: the NVG path (gr_string and NVGFont::getStringSize)
and the VFNT path (gr_string_old and VFNTFont::getStringSize), which also
gains tab handling.  The tab width is hoisted onto the shared FSFont base
so both backends share it.

While here, pass the FSFont wrapper to gr_string_old instead of a bag of
scalars, make its font pointer const, and consolidate the
get_char_width_old externs into a single declaration in font_internal.h.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Goober5000
Goober5000 force-pushed the fix/fred_label_line_spacing branch from f855a88 to f3817c8 Compare September 3, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. graphics A feature or issue related to graphics (2d and 3d)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants