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 item description rendering issues #7683

Merged
merged 3 commits into from
Jan 29, 2025
Merged

Conversation

glebm
Copy link
Collaborator

@glebm glebm commented Jan 28, 2025

Fixes #7651

The initial issue in the unique item info box was caused by GetLineStartX returning a negative value for long strings.
Fixing that made the text fit but the renderer wraps text at arbitrary points, so we further use WordWrapString to break at word boundaries:

image

The info box issue was caused by KerningFitSpacing only taking the first line into account.
This PR fixes that by recalculating the kerning fit on each new line:

image

An alternative fix to would be to add a version of GetLineWidth that calculates the maximum width across all lines. This would make the kerning the same for all lines.

I went with kerning fit per line here but I don't have a strong preference either way.

/cc @Riccila

glebm added 3 commits January 28, 2025 08:17
Previously, `GetLineStartX` assumed that the text fit into
a single line.
Pre-wraps the string at spaces, otherwise `DrawString` would hard wrap in the middle of words.
@Riccila
Copy link

Riccila commented Jan 28, 2025

The solution is excellent if it is suitable for similar situations. I noticed that there are quite a lot of descriptions of such items. I sincerely thank all those who responded. Gleb is a special respect

@glebm glebm enabled auto-merge (rebase) January 28, 2025 19:17
@glebm glebm merged commit f7be00c into diasurgical:master Jan 29, 2025
23 checks passed
@glebm glebm deleted the text-render branch January 29, 2025 03:31
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.

[Russian] text out of bounds in unique item stat window
3 participants