laymur 0.3.25 → 0.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/miscellaneous/UITextStyle.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6244,6 +6244,9 @@ function isUITextStyle(obj) {
|
|
|
6244
6244
|
}
|
|
6245
6245
|
const candidate = obj;
|
|
6246
6246
|
return (typeof candidate.color === "string" &&
|
|
6247
|
+
(candidate.align === "left" ||
|
|
6248
|
+
candidate.align === "center" ||
|
|
6249
|
+
candidate.align === "right") &&
|
|
6247
6250
|
typeof candidate.fontFamily === "string" &&
|
|
6248
6251
|
typeof candidate.fontSize === "number" &&
|
|
6249
6252
|
(candidate.fontStyle === "normal" ||
|
|
@@ -6266,6 +6269,7 @@ function isUITextStyle(obj) {
|
|
|
6266
6269
|
}
|
|
6267
6270
|
const DEFAULT_TEXT_STYLE = {
|
|
6268
6271
|
color: "#000000",
|
|
6272
|
+
align: "left",
|
|
6269
6273
|
fontFamily: "Arial",
|
|
6270
6274
|
fontSize: 16,
|
|
6271
6275
|
fontStyle: "normal",
|
|
@@ -6308,6 +6312,7 @@ function resolveTextStyle(style, commonStyle) {
|
|
|
6308
6312
|
assertValidNonNegativeNumber(strokeWidth, "Stroke width");
|
|
6309
6313
|
return {
|
|
6310
6314
|
color: style?.color ?? commonStyle?.color ?? DEFAULT_TEXT_STYLE.color,
|
|
6315
|
+
align: style?.align ?? commonStyle?.align ?? DEFAULT_TEXT_STYLE.align,
|
|
6311
6316
|
fontFamily: style?.fontFamily ??
|
|
6312
6317
|
commonStyle?.fontFamily ??
|
|
6313
6318
|
DEFAULT_TEXT_STYLE.fontFamily,
|
|
@@ -6444,6 +6449,7 @@ function renderText(x, y, text, style, context) {
|
|
|
6444
6449
|
context.strokeText(text, x, y);
|
|
6445
6450
|
}
|
|
6446
6451
|
context.fillStyle = style.color;
|
|
6452
|
+
context.textAlign = style.align;
|
|
6447
6453
|
context.fillText(text, x, y);
|
|
6448
6454
|
}
|
|
6449
6455
|
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|