Skip to content

Commit

Permalink
fix: make textBaseline in SVG the same with Canvas #1313
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Jul 21, 2023
1 parent 659b07d commit ee52dc6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/g-plugin-svg-renderer/src/shapes/paths/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ export function updateTextElementAttribute(

// Since `text-after-edge` is not a standard property value, we use `dy` instead.
if (textBaseline === 'bottom' || textBaseline === 'top') {
$el.setAttribute('dominant-baseline', 'middle');
$el.setAttribute('dy', textBaseline === 'bottom' ? `-0.5em` : '0.5em');
$el.setAttribute('dominant-baseline', BASELINE_MAP['middle']);
$el.setAttribute(
'dy',
textBaseline === 'bottom' ? `-${height / 2}px` : `${height / 2}px`,
);
}

// <textPath> only support one line
Expand Down

0 comments on commit ee52dc6

Please sign in to comment.