-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text bbox
is empty when using font-size with units
#86
Comments
Units are rarely used in svg. whats your usecase? |
I'm importing and manipulating preexisting SVGs that happen to use units for their font-sizes. A small step in the right direction might be to at least warn or document somewhere that measurements with units aren't supported or something. It took me a while to figure out why my text fields just weren't measuring at all. |
Or we could just skip the unit alltogether. Feel free to implement a PR. You should find the corresponding code somewhere in https://github.com/svgdotjs/svgdom/blob/master/src/utils/textUtils.js |
I think ignoring the unit would work for the case of |
This library has no notion of real-world measurements. How much is a cm in px if you don't have a screen? There is no way to know. The only other unit that would make sense is percentage but in the end, this is a custom library that supports as much as it can. What works works and when somebody needs more, they can create a PR :) |
It seems that when
<text>
or<tspan>
elements have a font-size which includes a unit, this library renders their.bbox()
as an empty rect (all 0's). The following example illustrates my point.Which outputs the following when run in node:
The text was updated successfully, but these errors were encountered: