Skip to content

Commit

Permalink
Use scale to adapt text field resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed May 14, 2024
1 parent 0499436 commit 05a93ff
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@leosac/cardrendering",
"version": "1.7.2",
"version": "1.7.3",
"description": "Card Rendering engine for CR-80 cards and more",
"main": "dist/cardrendering.node.js",
"browser": "dist/cardrendering.js",
Expand Down
3 changes: 2 additions & 1 deletion src/lib/cardrenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ class CardRenderer {
this.data.grid.ruler = false;
this.data.grid.scale = 1 - ((width - parentRectoContainer.offsetWidth) / width);
} else {
if (resize)
if (resize) {
this.data.grid.scale = 1;
}
}
if (this.data.grid.ruler) {
width += rulerwidth + rulerspacing * 2;
Expand Down
7 changes: 4 additions & 3 deletions src/lib/fieldFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function setFieldBorder(box, border) {
}
}

function createTextField(options)
function createTextField(options, scale = 1)
{
options.type = 'label';
const text = new PIXI.Text(options.value);
Expand All @@ -39,6 +39,7 @@ function createTextField(options)
options.fontStyle = "Normal";
}
text.style = style;
text.resolution = scale;
if (options.wordBreak) {
text.wordWrap = true;
text.wordWrapWidth = options.width;
Expand Down Expand Up @@ -153,8 +154,8 @@ async function createBwipSprint(options, bwopts, dpi = 300) {
sprite.y = options.y;
sprite.height = height;
sprite.width = width;
options.height = sprite.height;
options.width = sprite.width;
options.height = height;
options.width = width;
if (options.rotation > 0) {
sprite.angle = options.rotation;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Fields {
color: 0x000000
},
...options
});
}, this.cardside.data.grid.scale);
} else if (options.type === 'picture') {
field = await createPictureField({
useMacros: false,
Expand Down

0 comments on commit 05a93ff

Please sign in to comment.