Hi list !
Id like to know the width and height in pixels for a string given a
font family, size and style.
How could I do that ?
Thanks,
Stéphane.
Hi list !
Id like to know the width and height in pixels for a string given a
font family, size and style.
How could I do that ?
Thanks,
Stéphane.
This is undoubtedly overkill, but:
require ‘tk’
f = TkFont.new(‘Courier 10’)
width = f.measure(“Hi There!”)
height = f.metrics.assoc(‘linespace’)[1]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs