diff --git a/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx b/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx index f50081de2..a9cb4b10f 100644 --- a/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx +++ b/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx @@ -398,7 +398,7 @@ export class TextUtil extends TDShapeUtil { const fontSize = getFontSize(shape.style.size, shape.style.font) * (shape.style.scale ?? 1) const fontFamily = getFontFace(shape.style.font).slice(1, -1) - const textAlign = shape.style.textAlign ?? AlignStyle.Start + const textAlign = shape.style.textAlign ?? AlignStyle.Middle const textElm = getTextSvgElement( shape.text, diff --git a/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts b/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts index 38db3d1f3..47416ce32 100644 --- a/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts +++ b/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts @@ -58,19 +58,19 @@ export function getTextSvgElement( case AlignStyle.Middle: { textElm.setAttribute('text-align', 'center') textElm.setAttribute('text-anchor', 'middle') - textLines.forEach((textElm) => textElm.setAttribute('x', 4 + width / 2 + '')) + textLines.forEach((textElm) => textElm.setAttribute('x', width / 2 + '')) break } case AlignStyle.End: { textElm.setAttribute('text-align', 'right') textElm.setAttribute('text-anchor', 'end') - textLines.forEach((textElm) => textElm.setAttribute('x', 4 + width + '')) + textLines.forEach((textElm) => textElm.setAttribute('x', -4 + width + '')) break } default: { textElm.setAttribute('text-align', 'left') textElm.setAttribute('text-anchor', 'start') - textLines.forEach((textElm) => textElm.setAttribute('x', '4')) + textLines.forEach((textElm) => textElm.setAttribute('x', 4 + '')) } }