@jimp/plugin-print
Advanced tools
Comparing version 0.22.10 to 0.22.11--canary.c55989b.0
{ | ||
"name": "@jimp/plugin-print", | ||
"version": "0.22.10", | ||
"version": "0.22.11--canary.c55989b.0", | ||
"description": "print an image.", | ||
@@ -24,3 +24,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@jimp/utils": "^0.22.10", | ||
"@jimp/utils": "0.22.11--canary.c55989b.0", | ||
"load-bmfont": "^1.4.1" | ||
@@ -33,5 +33,5 @@ }, | ||
"devDependencies": { | ||
"@jimp/custom": "^0.22.10", | ||
"@jimp/plugin-blit": "^0.22.10", | ||
"@jimp/test-utils": "^0.22.10" | ||
"@jimp/custom": "0.22.11--canary.c55989b.0", | ||
"@jimp/plugin-blit": "0.22.11--canary.c55989b.0", | ||
"@jimp/test-utils": "0.22.11--canary.c55989b.0" | ||
}, | ||
@@ -41,3 +41,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "af334eff862cc8091378cd6b1e194086e36d445e" | ||
"gitHead": "c55989b09f4c40aaf607203a2b7069625f1ca590" | ||
} |
@@ -19,3 +19,4 @@ export function measureText(font, text) { | ||
export function splitLines(font, text, maxWidth) { | ||
const words = text.split(" "); | ||
const words = text.replace(/[\r\n]+/g, " \n").split(" "); | ||
const lines = []; | ||
@@ -29,3 +30,3 @@ let currentLine = []; | ||
if (length <= maxWidth) { | ||
if (length <= maxWidth && !word.includes("\n")) { | ||
if (length > longestLine) { | ||
@@ -38,8 +39,6 @@ longestLine = length; | ||
lines.push(currentLine); | ||
currentLine = [word]; | ||
currentLine = [word.replace("\n", "")]; | ||
} | ||
}); | ||
lines.push(currentLine); | ||
return { | ||
@@ -46,0 +45,0 @@ lines, |
@@ -297,2 +297,16 @@ /* eslint key-spacing: ["error", { "align": "value" }] */ | ||
}); | ||
it("text with newlines, default alignment", async () => { | ||
const expectedImage = await Jimp.read( | ||
getTestDir(__dirname) + "/images/with-newlines.png" | ||
); | ||
const textImage = await createTextImage(100, 240, Jimp.FONT_SANS_16_BLACK, { | ||
text: "This \nis only \na \ntest.", | ||
maxWidth: 300, | ||
}); | ||
expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
1051662
55
649
+ Added@jimp/utils@0.22.11--canary.c55989b.0(transitive)