Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UiFlags::KerningFitSpacing #7705

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Source/engine/render/text_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,13 @@ uint32_t DoDrawString(const Surface &out, std::string_view text, Rectangle rect,
TextRenderOptions &opts)
{
CurrentFont currentFont;
int curSpacing = HasAnyOf(opts.flags, UiFlags::KerningFitSpacing)
? AdjustSpacingToFitHorizontally(lineWidth, opts.spacing, charactersInLine, rect.size.width)
: opts.spacing;
int curSpacing = opts.spacing;
if (HasAnyOf(opts.flags, UiFlags::KerningFitSpacing)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is very similar code in DrawStringWithColors that also needs to be adjusted in the same way (search the file for int curSpacing = HasAnyOf)

Copy link
Collaborator

@glebm glebm Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here (see bottom of the screenshot):
image

curSpacing = AdjustSpacingToFitHorizontally(lineWidth, opts.spacing, charactersInLine, rect.size.width);
int adjustedLineWidth = GetLineWidth(text, size, curSpacing, &charactersInLine);
characterPosition.x = GetLineStartX(opts.flags, rect, adjustedLineWidth);
opts.spacing = curSpacing;
}

char32_t next;
std::string_view remaining = text;
Expand Down
Loading