Add text fit safety margin
This commit is contained in:
@@ -8,6 +8,7 @@ const PRINTABLE_TAPE_PX = {
|
||||
24: 128,
|
||||
};
|
||||
const STORAGE_KEY = "ptouch-web-layout";
|
||||
const TEXT_FIT_EXTRA_MM = 6;
|
||||
|
||||
const state = {
|
||||
zoom: 1.5,
|
||||
@@ -113,7 +114,7 @@ function textNaturalWidthMm(obj) {
|
||||
const lines = String(obj.text || " ").split("\n");
|
||||
const maxTextWidthPx = Math.max(...lines.map((line) => ctx.measureText(line || " ").width), 0);
|
||||
ctx.restore();
|
||||
return Math.max(2, pxToMm(maxTextWidthPx) + 1);
|
||||
return Math.max(2, pxToMm(maxTextWidthPx) + TEXT_FIT_EXTRA_MM);
|
||||
}
|
||||
|
||||
function autoFitTextObject(obj) {
|
||||
|
||||
Reference in New Issue
Block a user