Skip to content

Commit

Permalink
on create an image once for each character
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Aug 5, 2018
1 parent ea34d22 commit 174f20e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/image-manipulation/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ function xOffsetBasedOnAlignment(font, line, maxWidth, alignment) {

function drawCharacter(image, font, x, y, char) {
if (char.width > 0 && char.height > 0) {
const imageChar = font.pages[char.page]
.cloneQuiet()
.crop(char.x, char.y, char.width, char.height);
let imageChar = char.image;

if (!imageChar) {
imageChar = font.pages[char.page]
.cloneQuiet()
.crop(char.x, char.y, char.width, char.height);
char.image = imageChar;
}

return image.composite(imageChar, x + char.xoffset, y + char.yoffset);
}

Expand Down

0 comments on commit 174f20e

Please sign in to comment.