mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-12 20:00:09 +00:00
gtk-demo: Improve ink extents rendering
Show the pixel-aligned ink rectangle, so we can see that it includes all the pixels that are inked.
This commit is contained in:
parent
06db477847
commit
2c8e55605b
@ -37,7 +37,7 @@ update_image (void)
|
|||||||
const char *text;
|
const char *text;
|
||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoRectangle ink, pink, logical;
|
PangoRectangle ink, logical;
|
||||||
int baseline;
|
int baseline;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
@ -94,7 +94,6 @@ update_image (void)
|
|||||||
pango_layout_set_font_description (layout, desc);
|
pango_layout_set_font_description (layout, desc);
|
||||||
pango_layout_set_text (layout, text, -1);
|
pango_layout_set_text (layout, text, -1);
|
||||||
pango_layout_get_extents (layout, &ink, &logical);
|
pango_layout_get_extents (layout, &ink, &logical);
|
||||||
pink = ink;
|
|
||||||
baseline = pango_layout_get_baseline (layout);
|
baseline = pango_layout_get_baseline (layout);
|
||||||
|
|
||||||
pango_extents_to_pixels (&ink, NULL);
|
pango_extents_to_pixels (&ink, NULL);
|
||||||
@ -165,10 +164,10 @@ update_image (void)
|
|||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||||
cairo_rectangle (cr,
|
cairo_rectangle (cr,
|
||||||
scale * (10 + pango_units_to_double (pink.x)) + 0.5,
|
scale * (10 + ink.x) - 0.5,
|
||||||
scale * (10 + pango_units_to_double (pink.y)) + 0.5,
|
scale * (10 + ink.y) - 0.5,
|
||||||
scale * pango_units_to_double (pink.width) - 1,
|
scale * ink.width + 1,
|
||||||
scale * pango_units_to_double (pink.height) - 1);
|
scale * ink.height + 1);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user