Skip to content

Commit

Permalink
Fixed text split issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jiakuan committed Nov 9, 2023
1 parent addee41 commit 4aa059e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public static List<String> splitText(
splitPoint = Math.max(1, splitPoint - 1);
splitPointWidth = measureText(ctx, textMap,
tempLine.substring(0, splitPoint));
if (splitPoint == 0 || splitPoint == 1) {
if (splitPoint == 1) {
break;
}
}
}

averageSplitPoint = Math.round(
averageSplitPoint + (splitPoint - averageSplitPoint) / index);
averageSplitPoint = (int) Math.round(averageSplitPoint * 1.0
+ (splitPoint * 1.0 - averageSplitPoint) / index);

// Remove last character that was out of the box
splitPoint--;
Expand All @@ -100,9 +100,8 @@ public static List<String> splitText(
int tempSplitPoint = splitPoint;
if (!" ".equals(
tempLine.substring(tempSplitPoint, tempSplitPoint + 1))) {
while (!" ".equals(
tempLine.substring(tempSplitPoint, tempSplitPoint + 1)) &&
tempSplitPoint >= 0) {
while (tempSplitPoint >= 0 && !" ".equals(
tempLine.substring(tempSplitPoint, tempSplitPoint + 1))) {
tempSplitPoint--;
}
if (tempSplitPoint > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public MainView() {
updateInputValues(config);
updateCanvas();
});
textarea.addEventListener("input", evt -> updateCanvas());
inputRangeX.addEventListener("input", evt -> {
inputNumberX.value = inputRangeX.value;
config.x = Double.parseDouble(inputRangeX.value);
Expand Down

0 comments on commit 4aa059e

Please sign in to comment.