Skip to content

Commit

Permalink
Fix nullptr on calculating of text width
Browse files Browse the repository at this point in the history
  • Loading branch information
d0by1 committed Oct 9, 2023
1 parent 43b9d9e commit f75420b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ public static int getCharWidth(char c) {
* @param text The string.
* @return The width.
*/
public static int getTextWidth(@NotNull String text) {
public static int getTextWidth(String text) {
if (text == null || text.isEmpty()) {
return 0;
}

if (text.contains("\n")) {
throw new IllegalArgumentException("Text cannot contain newline characters.");
}
Expand Down

0 comments on commit f75420b

Please sign in to comment.