Skip to content

Commit

Permalink
fix: 修复两端对齐的缺陷
Browse files Browse the repository at this point in the history
  • Loading branch information
胡正 authored and Qiu-Jun committed Sep 30, 2024
1 parent 320b7ae commit da841ed
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/core/objects/CustomTextbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,22 @@ fabric.Textbox = fabric.util.createClass(fabric.Textbox, {
accumulatedSpace = 0;
line = this._textLines[i];
currentLineWidth = this.getLineWidth(i);
if (currentLineWidth < this.width && (spaces = this.textLines[i].split(''))) {
if (
currentLineWidth < this.width &&
(spaces = this.textLines[i].split('')) &&
spaces.length > 1
) {
numberOfSpaces = spaces.length;
diffSpace = (this.width - currentLineWidth) / (numberOfSpaces - 1);
for (var j = 0, jlen = line.length; j <= jlen; j++) {
charBound = this.__charBounds[i][j];
// if (this._reSpaceAndTab.test(line[j])) {
charBound.width += diffSpace;
charBound.kernedWidth += diffSpace;
charBound.left += accumulatedSpace;
accumulatedSpace += diffSpace;
if (j < jlen - 1) {
charBound.width += diffSpace;
charBound.kernedWidth += diffSpace;
accumulatedSpace += diffSpace;
}
// } else {
// charBound.left += accumulatedSpace;
// }
Expand Down

0 comments on commit da841ed

Please sign in to comment.