Skip to content

Commit

Permalink
Add \n support for image.print(). This fixes jimp-dev#865 - more cond…
Browse files Browse the repository at this point in the history
…ensed code.
  • Loading branch information
juurr00 committed Nov 1, 2023
1 parent 9dd782a commit 96a4324
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/plugin-print/src/measure-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ export function splitLines(font, text, maxWidth) {
const lines = [];
let currentLine = [];
let longestLine = 0;

words.forEach((word) => {
const line = [...currentLine, word].join(" ");
const length = measureText(font, line);

const withinMaxWidth = length <= maxWidth;
const containsNewline = word.includes("\n");

if (withinMaxWidth && !containsNewline) {
if (length <= maxWidth && !word.includes("\n")) {
if (length > longestLine) {
longestLine = length;
}
Expand Down

0 comments on commit 96a4324

Please sign in to comment.