I'm trying to overlay polygons on top of a grid of mono-spaced characters. In order to calculate the coordinates for the polygons I need to know how wide a single character is. How do you determine the width of a single mono-spaced (Courier 12) character using the Ruby Prawn gem?
According to this there is a width_of
method buried in Prawn:
pdf.width_of(text, :size => 10)
Here is a bit more documentation I was able to dig up. In terms of your question I think you would do:
pdf.width_of('a', :size => 12) #provided a was the single character in question
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With