zrender icon indicating copy to clipboard operation
zrender copied to clipboard

[PENDING] fix(svg): use `textBaseline` specified in text style instead of fixed default value.

Open plainheart opened this issue 3 years ago • 2 comments

THIS IS A PENDING CHANGE

I noticed the text node's position rendered by the SVG renderer currently differs from the canvas renderer.

Here are some cases,

Before After this change

I'm not sure about the reason for setting the dominant-baseline attribute of the text node as a fixed middle(previously) or central(currently) in SVG renderer, but if we use textBaseline specified in text style, it will render the text as the same as the canvas renderer. At least, it will look quite obviously better than now.

plainheart avatar May 22 '21 07:05 plainheart

@plainheart Sorry about the late reply. Text is centered by adjusting y in https://github.com/ecomfe/zrender/blob/b3ead0b2ce7755b30b337fae6c983d7d4bcc8042/src/svg/graphic.ts#L419 manually. I can't remember the reason exactly. Seems it's because other baseline configuration may have unexpected result in some font-family like Microsoft Yahei. @100pah Do you still remember the detail?

pissang avatar Jun 01 '21 10:06 pissang

I can't remember the reason exactly. Seems it's because other baseline configuration may have unexpected result in some font-family like Microsoft Yahei.

Yes, I remember for Canvas renderer, it seems not easy to control make the same effect when font family changed if using different value of textBaseline.

100pah avatar Jun 01 '21 11:06 100pah