summaryrefslogtreecommitdiff
path: root/pango/glyphstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'pango/glyphstring.c')
-rw-r--r--pango/glyphstring.c104
1 files changed, 55 insertions, 49 deletions
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index f4766191..6fad2a35 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -149,27 +149,30 @@ pango_glyph_string_extents_range (PangoGlyphString *glyphs,
int x_pos = 0;
int i;
+ /* Note that the handling of empty rectangles for ink
+ * and logical rectangles is different. A zero-height ink
+ * rectangle makes no contribution to the overall ink rect,
+ * while a zero-height logical rect still reserves horizontal
+ * width. Also, we may return zero-width, positive height
+ * logical rectangles, while we'll never do that for the
+ * ink rect.
+ */
g_return_if_fail (start <= end);
- if (end - start == 0)
+ if (ink_rect)
{
- 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;
- }
-
- return;
+ 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;
}
for (i = start; i < end; i++)
@@ -179,52 +182,55 @@ pango_glyph_string_extents_range (PangoGlyphString *glyphs,
PangoGlyphGeometry *geometry = &glyphs->glyphs[i].geometry;
- if (i == start)
- {
- pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph,
- ink_rect, logical_rect);
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph,
+ ink_rect ? &glyph_ink : NULL,
+ logical_rect ? &glyph_logical : NULL);
- if (logical_rect)
+ if (ink_rect && glyph_ink.width != 0 && glyph_ink.height != 0)
+ {
+ if (ink_rect->width == 0 || ink_rect->height == 0)
{
- logical_rect->x = 0;
- logical_rect->width = geometry->width;
+ ink_rect->x = x_pos + glyph_ink.x;
+ ink_rect->width = glyph_ink.width;
+ ink_rect->y = glyph_ink.y;
+ ink_rect->height = glyph_ink.height;
}
- }
- else
- {
- int new_pos;
-
- pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph,
- ink_rect ? &glyph_ink : NULL,
- logical_rect ? &glyph_logical : NULL);
-
- if (ink_rect)
+ else
{
- new_pos = MIN (ink_rect->x, x_pos + glyph_ink.x + geometry->x_offset);
+ int new_x, new_y;
+
+ new_x = MIN (ink_rect->x, x_pos + glyph_ink.x + geometry->x_offset);
ink_rect->width = MAX (ink_rect->x + ink_rect->width,
- x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - new_pos;
- ink_rect->x = new_pos;
-
- new_pos = MIN (ink_rect->y, glyph_ink.y + geometry->y_offset);
+ x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - new_x;
+ ink_rect->x = new_x;
+
+ new_y = MIN (ink_rect->y, glyph_ink.y + geometry->y_offset);
ink_rect->height = MAX (ink_rect->y + ink_rect->height,
- glyph_ink.y + glyph_ink.height + geometry->y_offset) - new_pos;
- ink_rect->y = new_pos;
+ glyph_ink.y + glyph_ink.height + geometry->y_offset) - new_y;
+ ink_rect->y = new_y;
}
+ }
- if (logical_rect)
- {
- logical_rect->width += geometry->width;
+ if (logical_rect)
+ {
+ logical_rect->width += geometry->width;
- new_pos = MIN (logical_rect->y, glyph_logical.y);
+ if (i == start)
+ {
+ logical_rect->y = glyph_logical.y;
+ logical_rect->height = glyph_logical.height;
+ }
+ else
+ {
+ int new_y = MIN (logical_rect->y, glyph_logical.y);
logical_rect->height = MAX (logical_rect->y + logical_rect->height,
- glyph_logical.y + glyph_logical.height) - new_pos;
- logical_rect->y = new_pos;
+ glyph_logical.y + glyph_logical.height) - new_y;
+ logical_rect->y = new_y;
}
}
x_pos += geometry->width;
}
-
}
/**