Get the size in pixels for a string


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 ?



This is undoubtedly overkill, but:

require ‘tk’

f =‘Courier 10’)
width = f.measure(“Hi There!”)
height = f.metrics.assoc(‘linespace’)[1]