soccer-jersey-fork 1.0.109 → 1.0.111
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/lib/types/index.d.ts
CHANGED
|
@@ -150,14 +150,15 @@ export default function drawSoccerJersey({ shirtColor = "plain", shirtStyle, shi
|
|
|
150
150
|
*/
|
|
151
151
|
if (texts && texts.length > 0) {
|
|
152
152
|
for (const textItem of texts) {
|
|
153
|
-
const { text, color, size, outlineColor, backgroundColor, backgroundShape, fontFamily, fontWeight, fontStyle, x, y, } = textItem;
|
|
153
|
+
const { text, color, size, outlineColor, backgroundColor, backgroundShape, fontFamily, fontWeight, fontStyle, textLength, x, y, } = textItem;
|
|
154
154
|
const drawText = (elem) => {
|
|
155
|
-
|
|
155
|
+
const textElement = elem
|
|
156
156
|
.text(text)
|
|
157
157
|
.fill(color || "#eee")
|
|
158
158
|
.font({
|
|
159
159
|
family: fontFamily,
|
|
160
160
|
size,
|
|
161
|
+
// fontWeight and fontStyle as the name do not work. Must be weight, style
|
|
161
162
|
weight: fontWeight,
|
|
162
163
|
style: fontStyle,
|
|
163
164
|
anchor: "middle",
|
|
@@ -165,8 +166,18 @@ export default function drawSoccerJersey({ shirtColor = "plain", shirtStyle, shi
|
|
|
165
166
|
.stroke({
|
|
166
167
|
color: outlineColor || color,
|
|
167
168
|
width: 0.5,
|
|
168
|
-
})
|
|
169
|
-
|
|
169
|
+
});
|
|
170
|
+
if (textLength) {
|
|
171
|
+
// You must apply the attributes directly to the tspan element instead of (or in addition to) the parent text element.
|
|
172
|
+
const tspan = textElement.first();
|
|
173
|
+
const attrs = {
|
|
174
|
+
textLength,
|
|
175
|
+
lengthAdjust: "spacingAndGlyphs",
|
|
176
|
+
};
|
|
177
|
+
if (tspan)
|
|
178
|
+
tspan.attr(attrs);
|
|
179
|
+
}
|
|
180
|
+
return textElement.center(x, y);
|
|
170
181
|
};
|
|
171
182
|
if (backgroundColor) {
|
|
172
183
|
// eslint-disable-next-line new-cap
|