Fix: Wrong size measurement for WrapTextSegment#1057
Open
Denrage wants to merge 2 commits intoblish-hud:devfrom
Open
Fix: Wrong size measurement for WrapTextSegment#1057Denrage wants to merge 2 commits intoblish-hud:devfrom
Denrage wants to merge 2 commits intoblish-hud:devfrom
Conversation
Collaborator
Author
|
I talked with @greaka about the added MeasureString operations and it is sadly something we need to do. |
Member
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.

In specific edge cases
DrawUtil.WrapTextproduces a string that is greater than themaxLineWidthyou give him.This happens because the previous implementation of
WrapTextSegmentdidn't properly measured the string after appending a word.The size of the space changes depending on which letter the space precedes so we can't use a fixed SpaceWidth for the whole wrapping and we need to measure the actual size of the string to not exceeed the
maxLineWidth.I don't know all the implications this change could occure, but i can't think of any problem with it, but that is limited to the knowledge i have regarding this function and usage all around Blish.
Also i don't know if
MeasureString("some string") + MeasureString("some other string")will be the same asMeasureString("some string" + "some other string"). This could create another even more edgy case where we need to measure the resulting string before we create it to not exceed themaxLineWidthThis is intended to not break any existing implementation and should only fix an edge case.
Also unrelated to the current issue:
DrawUtil.WrapTextadds an unnecessary space at every line at the end.Minimal reproduction that produces a wrong LineWidth string: