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

UIWrappedText: Fix single-character strings not being rendered #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ open class UIWrappedText @JvmOverloads constructor(
return super.draw(matrixStack)
}

if (width / textScale <= charWidth) {
// If we are smaller than a char, we can't physically split this string into
// "width" strings, so we'll prefer a no-op to an error.
return super.draw(matrixStack)
}

UGraphics.enableBlend()

val lines = if (trimText) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/gg/essential/elementa/utils/text.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fun getStringSplitToWidth(
pushLine()

for (char in word.toCharArray()) {
if ((currLine.toString() + char).width(textScale, fontProvider) > maxLineWidthSpace)
if (currLine.isNotEmpty() && (currLine.toString() + char).width(textScale, fontProvider) > maxLineWidthSpace)
pushLine()
currLine.append(char)
}
Expand Down
Loading