laymur 0.3.26 → 0.3.28
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 +17 -3
- 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
|
@@ -6273,6 +6273,7 @@ const DEFAULT_TEXT_STYLE = {
|
|
|
6273
6273
|
fontFamily: "Arial",
|
|
6274
6274
|
fontSize: 16,
|
|
6275
6275
|
fontStyle: "normal",
|
|
6276
|
+
fontWeight: "normal",
|
|
6276
6277
|
lineHeight: 1.2,
|
|
6277
6278
|
enableShadow: false,
|
|
6278
6279
|
shadowOffsetX: 0,
|
|
@@ -6449,14 +6450,27 @@ function renderText(x, y, text, style, context) {
|
|
|
6449
6450
|
context.strokeText(text, x, y);
|
|
6450
6451
|
}
|
|
6451
6452
|
context.fillStyle = style.color;
|
|
6452
|
-
context.textAlign = style.align;
|
|
6453
6453
|
context.fillText(text, x, y);
|
|
6454
6454
|
}
|
|
6455
6455
|
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
6456
6456
|
let currentY = paddingTop;
|
|
6457
|
+
let textWidth = 0;
|
|
6458
|
+
for (const line of lines) {
|
|
6459
|
+
textWidth = Math.max(line.width, textWidth);
|
|
6460
|
+
}
|
|
6457
6461
|
for (let i = 0; i < lines.length; i++) {
|
|
6458
6462
|
const line = lines[i];
|
|
6459
|
-
|
|
6463
|
+
const firstAlign = line.chunks[0]?.style.align ?? DEFAULT_TEXT_STYLE.align;
|
|
6464
|
+
const isUniformAlign = line.chunks.every((c) => c.style.align === firstAlign);
|
|
6465
|
+
const lineAlign = isUniformAlign ? firstAlign : DEFAULT_TEXT_STYLE.align;
|
|
6466
|
+
let offsetX = 0;
|
|
6467
|
+
if (lineAlign === "center") {
|
|
6468
|
+
offsetX = (textWidth - line.width) / 2;
|
|
6469
|
+
}
|
|
6470
|
+
else if (lineAlign === "right") {
|
|
6471
|
+
offsetX = textWidth - line.width;
|
|
6472
|
+
}
|
|
6473
|
+
let currentX = paddingLeft + offsetX;
|
|
6460
6474
|
currentY += i === 0 ? line.height : line.lineHeight;
|
|
6461
6475
|
for (const chunk of line.chunks) {
|
|
6462
6476
|
renderText(currentX, currentY, chunk.text, chunk.style, context);
|
|
@@ -7365,5 +7379,5 @@ function isUITextSpan(obj) {
|
|
|
7365
7379
|
(!("style" in obj) || isUITextStyle(obj.style)));
|
|
7366
7380
|
}
|
|
7367
7381
|
|
|
7368
|
-
export { UIAnchor, UIAnimatedImage, UIAnimatedImageEvent, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMicroEvent, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIResizePolicy, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyEvent, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
|
|
7382
|
+
export { DEFAULT_TEXT_STYLE, UIAnchor, UIAnimatedImage, UIAnimatedImageEvent, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMicroEvent, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIResizePolicy, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyEvent, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
|
|
7369
7383
|
//# sourceMappingURL=index.js.map
|