1

I have some text paragraphs in Unicode. What I want to do is to convert these paragraphs into images. The process flow I chose was to convert the text into SVG first and then to png.

I am using python for this and do not use any third-party library at the moment as it's just simple text processing. (tspan element for each line)

The issue I face is some sentences are lengthy and go out of the view box. Is there a way to figure out a consistent font size that would work for all paragraphs/images.?

Or in other words, is there a way to figure out the height and width in pixels of a given string?

Thanks

This question is related but uses javascript instead.

XYZ
  • 310
  • 2
  • 12

0 Answers0