After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 508002 - change pango_layout_pixel_extents() to round logical rect to be inclusive
change pango_layout_pixel_extents() to round logical rect to be inclusive
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks: 438752 508242
 
 
Reported: 2008-01-08 08:32 UTC by Behdad Esfahbod
Modified: 2008-01-22 02:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Behdad Esfahbod 2008-01-08 08:32:08 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.
Comment 1 Behdad Esfahbod 2008-01-08 08:38:13 UTC
Oops, wrong bugs.
Comment 2 Mathias Hasselmann (IRC: tbf) 2008-01-08 10:17:50 UTC
Also have this problem when on extended layout.
Comment 3 Behdad Esfahbod 2008-01-22 02:08:47 UTC
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.