Files
lan-manager/web/node_modules/@antv/g-base/lib/bbox/text.js
openclaw 0a5f6a8047 Initial commit: Lan-manager project code
- Go backend (server/)
- Frontend (web/, server/static/)
- Database and deployment files
- Scripts and docs

Co-Authored-By: 狸花猫/Claude-Qwen3.6-Plus 🐾
2026-04-20 00:52:58 +08:00

57 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var text_1 = require("../util/text");
function default_1(shape) {
var attrs = shape.attr();
var x = attrs.x, y = attrs.y, text = attrs.text, fontSize = attrs.fontSize, lineHeight = attrs.lineHeight;
var font = attrs.font;
if (!font) {
// 如果未组装 font
font = text_1.assembleFont(attrs);
}
var width = text_1.getTextWidth(text, font);
var bbox;
if (!width) {
// 如果width不存在四点共其实点
bbox = {
x: x,
y: y,
width: 0,
height: 0,
};
}
else {
var textAlign = attrs.textAlign, textBaseline = attrs.textBaseline;
var height = text_1.getTextHeight(text, fontSize, lineHeight); // attrs.height
// 默认左右对齐left, 默认上下对齐 bottom
var point = {
x: x,
y: y - height,
};
if (textAlign) {
if (textAlign === 'end' || textAlign === 'right') {
point.x -= width;
}
else if (textAlign === 'center') {
point.x -= width / 2;
}
}
if (textBaseline) {
if (textBaseline === 'top') {
point.y += height;
}
else if (textBaseline === 'middle') {
point.y += height / 2;
}
}
bbox = {
x: point.x,
y: point.y,
width: width,
height: height,
};
}
return bbox;
}
exports.default = default_1;
//# sourceMappingURL=text.js.map