GNOME Bugzilla – Bug 508002
change pango_layout_pixel_extents() to round logical rect to be inclusive
Last modified: 2008-01-22 02:08:47 UTC
Some time ago I cleaned up how we round logical and ink rects in various functions. The idea was that "logical" coordinates should be rounded irrespective of which side of a rectangle they represent, such that the rounded logical rect for consecutive runs always touch. For ink rect, one wants the rounded rect to fully include the unrounded one. That means flooring the start x/y and ceil'ing end x/y. I added pango_extents_to_pixels() to make both conversions public to avoid having to add more _pixel variants in the future. All sounds good and nice and logical, except that people rightfully use pango_layout_get_pixel_size() and pass the returned size back to pango_layout_set_width()... Since get_pixel_size() returns pixel logical extents, the rounded-down-then-up value may be less than the original layout width, causing layout change, etc... So I guess we should make pango_layout_pixel_extents() round logical rect inclusive, like it does for ink rect. That means the API docs for that function would change slightly... Probably the same about pango_layout_line_get_pixel_extents(). The most recent incarnation of this bug is bug 469313, but I've seen a cell-renderer one before, where I made Kris not use pixel_extents() and round inclusive by making two calls.
Oops, wrong bugs.
Also have this problem when on extended layout.
2008-01-21 Behdad Esfahbod <behdad@gnome.org> Bug 508002 – change pango_layout_pixel_extents() to round logical rect to be inclusive * pango/pango-layout.c (pango_layout_get_pixel_extents), (pango_layout_line_get_pixel_extents): Round extents to pixels inclusively. That is, pass both ink_rect and logical_rect as first argument to pango_extents_to_pixels(). * pango/pango-matrix.c (pango_matrix_transform_pixel_rectangle): Fix rounding. * pango/pango-types.h: * docs/tmpl/glyphs.sgml: * pango/pango-utils.c (pango_extents_to_pixels): Rename pango_extents_to_pixels() function arguments from @ink_rect and @logical_rect to @inclusive and @nearest. Given that this API is a fairly new addition and not commonly used, language bindings are encouraged to update their argument names accordingly. Moreover, they are encouraged to wrap this function as two different calls: extents_to_pixels_inclusive() and extents_to_pixels_nearest(), or similar conventions that best reflect their native language.