| 143 | } |
| 144 | |
| 145 | function textOpen(o: TextOptions): string { |
| 146 | const parts = [ |
| 147 | `x="${round(o.x)}"`, |
| 148 | `y="${round(o.y)}"`, |
| 149 | `font-family="${o.family ?? SANS_STACK}"`, |
| 150 | `font-size="${o.size}"`, |
| 151 | `fill="${o.fill}"`, |
| 152 | ]; |
| 153 | if (o.weight && o.weight !== 400) parts.push(`font-weight="${o.weight}"`); |
| 154 | if (o.anchor && o.anchor !== 'start') parts.push(`text-anchor="${o.anchor}"`); |
| 155 | if (o.preserve) parts.push('xml:space="preserve"'); |
| 156 | return `<text ${parts.join(' ')}>`; |
| 157 | } |
| 158 | |
| 159 | function textEl(o: TextOptions, content: string): string { |
| 160 | return `${textOpen(o)}${content}</text>`; |