Index: docs/pango-sections.txt
===================================================================
RCS file: /cvs/gnome/pango/docs/pango-sections.txt,v
retrieving revision 1.72
diff -u -p -d -r1.72 pango-sections.txt
--- docs/pango-sections.txt 6 Jun 2006 20:19:56 -0000 1.72
+++ docs/pango-sections.txt 8 Jul 2006 17:11:15 -0000
@@ -98,6 +98,7 @@ pango_glyph_string_set_size
pango_glyph_string_free
pango_glyph_string_extents
pango_glyph_string_extents_range
+pango_glyph_string_get_width
pango_glyph_string_index_to_x
pango_glyph_string_x_to_index
pango_glyph_string_get_logical_widths
Index: docs/tmpl/glyphs.sgml
===================================================================
RCS file: /cvs/gnome/pango/docs/tmpl/glyphs.sgml,v
retrieving revision 1.35
diff -u -p -d -r1.35 glyphs.sgml
--- docs/tmpl/glyphs.sgml 29 Apr 2006 19:41:22 -0000 1.35
+++ docs/tmpl/glyphs.sgml 8 Jul 2006 17:11:15 -0000
@@ -382,6 +382,16 @@ The #GObject type for #PangoGlyphString.
@logical_rect:
+
+
+
+
+
+@glyphs:
+@font:
+@Returns:
+
+
Index: pango/glyphstring.c
===================================================================
RCS file: /cvs/gnome/pango/pango/glyphstring.c,v
retrieving revision 1.26
diff -u -p -d -r1.26 glyphstring.c
--- pango/glyphstring.c 29 Apr 2006 08:10:58 -0000 1.26
+++ pango/glyphstring.c 8 Jul 2006 17:11:15 -0000
@@ -264,6 +264,33 @@ pango_glyph_string_extents (PangoGlyphSt
}
/**
+ * pango_glyph_string_get_width:
+ * @glyphs: a #PangoGlyphString
+ * @font: a #PangoFont
+ *
+ * Computes the logical width of the glyph string as can also be computed
+ * using pango_glyph_string_extents(). However, since this only computes the
+ * width, it's much faster. This is in fact only a convenience function that
+ * computes the sum of geometry.width for each glyph in the @glyphs.
+ *
+ * Return value: the logical width of the glyph string.
+ *
+ * Since: 1.14
+ */
+int
+pango_glyph_string_get_width (PangoGlyphString *glyphs,
+ PangoFont *font)
+{
+ int i;
+ int width = 0;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ width += &glyphs->glyphs[i].geometry.width;
+
+ return width;
+}
+
+/**
* pango_glyph_string_get_logical_widths:
* @glyphs: a #PangoGlyphString
* @text: the text corresponding to the glyphs
Index: pango/pango-glyph.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-glyph.h,v
retrieving revision 1.12
diff -u -p -d -r1.12 pango-glyph.h
--- pango/pango-glyph.h 9 Feb 2006 17:14:08 -0000 1.12
+++ pango/pango-glyph.h 8 Jul 2006 17:11:15 -0000
@@ -91,6 +91,8 @@ void pango_glyph_string_ext
PangoFont *font,
PangoRectangle *ink_rect,
PangoRectangle *logical_rect);
+int pango_glyph_string_get_width(PangoGlyphString *glyphs,
+ PangoFont *font);
void pango_glyph_string_extents_range (PangoGlyphString *glyphs,
int start,
Index: pango/pango-renderer.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-renderer.c,v
retrieving revision 1.16
diff -u -p -d -r1.16 pango-renderer.c
--- pango/pango-renderer.c 6 Jun 2006 21:41:24 -0000 1.16
+++ pango/pango-renderer.c 8 Jul 2006 17:11:15 -0000
@@ -289,8 +289,7 @@ add_underline (PangoRenderer *rendere
PangoFontMetrics *metrics,
int base_x,
int base_y,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ PangoRectangle *ink_rect)
{
PangoRectangle *current_rect = &state->underline_rect;
PangoRectangle new_rect;
@@ -341,8 +340,7 @@ add_strikethrough (PangoRenderer *ren
PangoFontMetrics *metrics,
int base_x,
int base_y,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ PangoRectangle *ink_rect)
{
PangoRectangle *current_rect = &state->strikethrough_rect;
PangoRectangle new_rect;
@@ -450,6 +448,7 @@ pango_renderer_draw_layout_line (PangoRe
int y)
{
int x_off = 0;
+ int glyph_string_width;
LineState state;
GSList *l;
gboolean got_overall = FALSE;
@@ -480,7 +479,6 @@ pango_renderer_draw_layout_line (PangoRe
gint rise;
PangoLayoutRun *run = l->data;
PangoAttrShape *shape_attr;
- PangoRectangle logical_rect;
PangoRectangle ink_rect;
pango_renderer_prepare_run (renderer, run);
@@ -490,20 +488,18 @@ pango_renderer_draw_layout_line (PangoRe
if (shape_attr)
{
ink_rect = shape_attr->ink_rect;
- logical_rect = shape_attr->logical_rect;
+ glyph_string_width = shape_attr->logical_rect.width;
}
else
{
if (renderer->underline != PANGO_UNDERLINE_NONE ||
renderer->strikethrough)
- pango_glyph_string_extents (run->glyphs, run->item->analysis.font,
- &ink_rect, &logical_rect);
- else
- pango_glyph_string_extents (run->glyphs, run->item->analysis.font,
- NULL, &logical_rect);
+ pango_glyph_string_extents (run->glyphs, run->item->analysis.font,
+ &ink_rect, NULL);
+ glyph_string_width = pango_glyph_string_get_width (run->glyphs, run->item->analysis.font);
}
- state.logical_rect_end = x + x_off + logical_rect.x + logical_rect.width;
+ state.logical_rect_end = x + x_off + glyph_string_width;
if (renderer->priv->color_set[PANGO_RENDER_PART_BACKGROUND])
{
@@ -515,9 +511,9 @@ pango_renderer_draw_layout_line (PangoRe
pango_renderer_draw_rectangle (renderer,
PANGO_RENDER_PART_BACKGROUND,
- x + x_off + logical_rect.x,
+ x + x_off,
y - rise + overall_rect.y,
- logical_rect.width,
+ glyph_string_width,
overall_rect.height);
}
@@ -541,12 +537,12 @@ pango_renderer_draw_layout_line (PangoRe
if (renderer->underline != PANGO_UNDERLINE_NONE)
add_underline (renderer, &state,metrics,
x + x_off, y - rise,
- &ink_rect, &logical_rect);
+ &ink_rect);
if (renderer->strikethrough)
add_strikethrough (renderer, &state, metrics,
x + x_off, y - rise,
- &ink_rect, &logical_rect);
+ &ink_rect);
pango_font_metrics_unref (metrics);
}
@@ -558,7 +554,7 @@ pango_renderer_draw_layout_line (PangoRe
if (!renderer->strikethrough && state.strikethrough)
draw_strikethrough (renderer, &state);
- x_off += logical_rect.width;
+ x_off += glyph_string_width;
}
/* Finish off any remaining underlines
Index: pango/pango.def
===================================================================
RCS file: /cvs/gnome/pango/pango/pango.def,v
retrieving revision 1.42
diff -u -p -d -r1.42 pango.def
--- pango/pango.def 22 May 2006 20:10:08 -0000 1.42
+++ pango/pango.def 8 Jul 2006 17:11:15 -0000
@@ -172,6 +172,7 @@ EXPORTS
pango_glyph_string_free
pango_glyph_string_get_logical_widths
pango_glyph_string_get_type
+ pango_glyph_string_get_width
pango_glyph_string_index_to_x
pango_glyph_string_new
pango_glyph_string_set_size