Skip to content

Commit

Permalink
fix(svg): use textBaseline specified in text style instead of fixed d…
Browse files Browse the repository at this point in the history
…efault value.
  • Loading branch information
plainheart committed May 22, 2021
1 parent 2e33c31 commit b3ead0b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/svg/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,13 @@ const svgText: SVGProxy<TSpan> = {
setTransform(textSvgEl, el.transform);

// Consider different font display differently in vertial align, we always
// set vertialAlign as 'middle', and use 'y' to locate text vertically.
// set verticalAlign as 'middle', and use 'y' to locate text vertically.
const x = style.x || 0;
const y = adjustTextY(style.y || 0, getLineHeight(font), style.textBaseline);
const textAlign = TEXT_ALIGN_TO_ANCHOR[style.textAlign as keyof typeof TEXT_ALIGN_TO_ANCHOR]
|| style.textAlign;

attr(textSvgEl, 'dominant-baseline', 'central');
attr(textSvgEl, 'dominant-baseline', style.textBaseline || 'central');
attr(textSvgEl, 'text-anchor', textAlign);
attr(textSvgEl, 'x', x + '');
attr(textSvgEl, 'y', y + '');
Expand Down

0 comments on commit b3ead0b

Please sign in to comment.