summaryrefslogtreecommitdiff
path: root/pango/pango-utils.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-08-15 19:23:54 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-08-15 19:23:54 +0000
commitf90163fecc2f1e10ea1c800c2ac3045b485398bd (patch)
tree4c0f0455ee3eabf4b09de5142a15fa1c194c9838 /pango/pango-utils.c
parentcb816fe9b636b832e8383acc03654f92edb583d3 (diff)
downloadpango-f90163fecc2f1e10ea1c800c2ac3045b485398bd.tar.gz
Bug 467056 – Shape attribute handling is not consistent
2007-08-15 Behdad Esfahbod <behdad@gnome.org> Bug 467056 – Shape attribute handling is not consistent * pango/pango-impl-utils.h: * pango/pango-layout.c (pango_layout_line_index_to_x), (shape_run), (pango_layout_line_x_to_index), (pango_layout_run_get_extents), (update_run): * pango/pango-renderer.c (pango_renderer_draw_layout_line): * pango/pango-utils.c (_pango_shape_shape), (_pango_shape_get_extents): Fix handling of extents for shaped runs. Previsouly a shaped run with more than one character was not correctly positioned. svn path=/trunk/; revision=2401
Diffstat (limited to 'pango/pango-utils.c')
-rw-r--r--pango/pango-utils.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index 39ade732..3f36478c 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -1641,3 +1641,80 @@ pango_extents_to_pixels (PangoRectangle *ink_rect,
logical_rect->height = PANGO_PIXELS (orig_y + logical_rect->height) - logical_rect->y;
}
}
+
+
+
+
+
+/*********************************************************
+ * Some internal functions for handling PANGO_ATTR_SHAPE *
+ ********************************************************/
+
+void
+_pango_shape_shape (const char *text,
+ gint n_chars,
+ PangoRectangle *shape_ink,
+ PangoRectangle *shape_logical,
+ PangoGlyphString *glyphs)
+{
+ int i;
+ const char *p;
+
+ pango_glyph_string_set_size (glyphs, n_chars);
+
+ for (i=0, p = text; i < n_chars; i++, p = g_utf8_next_char (p))
+ {
+ glyphs->glyphs[i].glyph = PANGO_GLYPH_EMPTY;
+ glyphs->glyphs[i].geometry.x_offset = 0;
+ glyphs->glyphs[i].geometry.y_offset = 0;
+ glyphs->glyphs[i].geometry.width = shape_logical->width;
+ glyphs->glyphs[i].attr.is_cluster_start = 1;
+
+ glyphs->log_clusters[i] = p - text;
+ }
+}
+
+void
+_pango_shape_get_extents (gint n_chars,
+ PangoRectangle *shape_ink,
+ PangoRectangle *shape_logical,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
+{
+ if (n_chars > 0)
+ {
+ if (ink_rect)
+ {
+ ink_rect->x = MIN (shape_ink->x, shape_ink->x + shape_logical->width * (n_chars - 1));
+ ink_rect->width = MAX (shape_ink->width, shape_ink->width + shape_logical->width * (n_chars - 1));
+ ink_rect->y = shape_ink->y;
+ ink_rect->height = shape_ink->height;
+ }
+ if (logical_rect)
+ {
+ logical_rect->x = MIN (shape_logical->x, shape_logical->x + shape_logical->width * (n_chars - 1));
+ logical_rect->width = MAX (shape_logical->width, shape_logical->width + shape_logical->width * (n_chars - 1));
+ logical_rect->y = shape_logical->y;
+ logical_rect->height = shape_logical->height;
+ }
+ }
+ else
+ {
+ if (ink_rect)
+ {
+ ink_rect->x = 0;
+ ink_rect->y = 0;
+ ink_rect->width = 0;
+ ink_rect->height = 0;
+ }
+
+ if (logical_rect)
+ {
+ logical_rect->x = 0;
+ logical_rect->y = 0;
+ logical_rect->width = 0;
+ logical_rect->height = 0;
+ }
+ }
+}
+