Search code examples
gtkpango

Getting text bounds in GTK+


How can I get bounds of a text, provided string with attributes say, font size, font style, and font family in GTK+?


Solution

  • For GTK+, you should probably look at Pango. I believe the required call is pango_layout_line_get_pixel_extents(), although this will of course require you to parse whatever string it is you have with the specs, and set up the corresponding Pango object before getting the extents.