Skip to content

Commit 2d22cd0

Browse files
author
zhaokai
committed
字体翻转
1 parent a069720 commit 2d22cd0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/service/PlotBase/SvgLoader/element/TSpanElement.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* @Author: your name
44
* @Date: 2021-09-14 18:57:30
5-
* @LastEditTime: 2022-05-23 13:40:03
5+
* @LastEditTime: 2022-06-08 17:13:57
66
* @LastEditors: zk
77
* @Description: In User Settings Edit
88
* @FilePath: \MapGISPlotBase\src\svg-loader\element\TSapnElement.js
@@ -161,10 +161,24 @@ class TSpanElement extends TextElement {
161161
const bounds = new Bounds();
162162
const fontSize = this.getStyle('font-size').getNumber();
163163
const width = this._getMeasureTextWidth();
164+
164165
const pos = this.getPos(width);
166+
167+
let del=-width/2
168+
const textAnchorProps = this.getStyle('text-anchor');
169+
if (textAnchorProps.hasValue()) {
170+
const s = textAnchorProps.getString();
171+
if (s === 'middle') {
172+
del =0;
173+
} else if (s === 'end') {
174+
del = width/2;
175+
}
176+
}
177+
165178
const matrix = this._getMatrix();
179+
166180
bounds.addPnt(pos.x, pos.y - fontSize);
167-
bounds.addPnt(pos.x + width, pos.y);
181+
bounds.addPnt(pos.x + width-del, pos.y);
168182
bounds.applyMatrix3(matrix);
169183
return bounds;
170184
}

0 commit comments

Comments
 (0)