Skip to content

Commit

Permalink
Don't insert hyphen after existing hyphen during line split.
Browse files Browse the repository at this point in the history
  • Loading branch information
Solpatium committed May 4, 2024
1 parent ee126d6 commit 9d4a161
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/textkit/src/engines/linebreaker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import advanceWidthBetween from '../../attributedString/advanceWidthBetween';
* @typedef {import('../../types.js').Attributes} Attributes
*/

const HYPHEN = 0x002d;
const HYPHEN = '-';
const TOLERANCE_STEPS = 5;
const TOLERANCE_LIMIT = 50;

Expand Down Expand Up @@ -43,7 +43,9 @@ const breakLines = (string, nodes, breaks) => {
end = prevNode.value.end;

line = slice(start, end, string);
line = insertGlyph(line.length, HYPHEN, line);
if (!line.string?.endsWith(HYPHEN)) {
line = insertGlyph(line.length, HYPHEN.charCodeAt(0), line);
}
} else {
end = node.value.end;
line = slice(start, end, string);
Expand Down

0 comments on commit 9d4a161

Please sign in to comment.