对于 svg 文本元素,坐标应用于基线的左下角。
我有一个宽度和高度已知的文本,因此我可以设置
row.height = 2 * text.height
然后我想在这一行中放置 2 个文本元素,一个在另一个之上,并将 text.y 坐标设置为coordinate of top left corner of row + text.heigh * 2
. 将文本的底线设置在行边框正上方,但此坐标适用于基线,因此文本很少降低。你可以在图片上看到它。
那么,如何知道基线偏移量,设置文本坐标如
y = top left corner of row + height of text - baseline offset
?