DmitryBaranovskiy / raphael

JavaScript Vector Library
https://dmitrybaranovskiy.github.io/raphael/
MIT License
11.27k stars 1.67k forks source link

How to position multiple lines of text with different styles/size? #1062

Open cocomo opened 8 years ago

cocomo commented 8 years ago

Please: I'm trying to position 2 lines of text above each other at the center of a pie chart. Each text has dynamic content, font-size and style therefore i create 2 elements using the text() function. Now i run into weirdness trying to determine positions:

Since the getBBox() function is only available after adding the text element to the paper it seems there is no way to calculate size and according position before text shows up?

Should i create text in an offscreen position first and shift it to the calculated coordinates after getting its Bounds? I could also create transparent text and make it opaque later but both solutions sound overly complicated. Is getBBox() the way to go or are there probably easier solutions i've missed?