A
A
Anatoly2019-03-17 07:39:35
css
Anatoly, 2019-03-17 07:39:35

How to calculate viewBox for text in SVG?

I want to make the SVG text, and then use it as a background-image.
I will insert from a sprite or inline.
But, I can not understand how the viewBox is calculated.
For example, how to calculate the size of the viewBox for the text "Hello", in the example below, I put them at random.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 35">
 <text x="0" y="50" font-family="Verdana" font-size="35px" fill="gray">Привет</text> 
</svg>

Haven't figured out how to use styles yet:
font-stretch - Compress and stretch text. Possible values: normal (default) | wider | narrower | ultra condensed | extra condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
text-anchor - Alignment of text relative to the beginning of the line. Possible values: start (default), middle, end
but rather the last questions will be closed if you deal with the viewBox.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question