summaryrefslogtreecommitdiff
path: root/pango/glyphstring.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-11-13 18:47:29 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-11-13 18:47:29 +0000
commitf6511ca5a76f630f5a8802bb65d417db8ed31cfd (patch)
tree4bd9592fa7adf8a790703e429e2c8fdff59df456 /pango/glyphstring.c
parentd11951be51e06b6377ce0f1c546fde62281929a9 (diff)
downloadpango-f6511ca5a76f630f5a8802bb65d417db8ed31cfd.tar.gz
Add new PangoLayoutIter entry points
2000-11-13 Havoc Pennington <hp@redhat.com> * docs/pango-sections.txt: Add new PangoLayoutIter entry points * pango/glyphstring.c (pango_glyph_string_extents_range): New function * pango/pango-layout.c: Create PangoLayoutIter for iterating over a layout's visual elements * pango/pango-layout.c (pango_layout_check_lines): plug a memleak (attr iterator not freed) * pango/pango-tabs.c (pango_tab_array_free): plug a memleak (array->tabs not freed)
Diffstat (limited to 'pango/glyphstring.c')
-rw-r--r--pango/glyphstring.c64
1 files changed, 48 insertions, 16 deletions
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index b8d9eaa7..9ac489c7 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -86,28 +86,35 @@ pango_glyph_string_free (PangoGlyphString *string)
}
/**
- * pango_glyph_string_extents:
+ * pango_glyph_string_extents_range:
* @glyphs: a #PangoGlyphString
+ * @start: start index
+ * @end: end index
* @font: a #PangoFont
- * @ink_rect: rectangle used to store the extents of the glyph string as drawn
+ * @ink_rect: rectangle used to store the extents of the glyph string range as drawn
* or %NULL to indicate that the result is not needed.
- * @logical_rect: rectangle used to store the logical extents of the glyph string
+ * @logical_rect: rectangle used to store the logical extents of the glyph string range
* or %NULL to indicate that the result is not needed.
- *
- * Compute the logical and ink extents of a glyph string. See the documentation
- * for pango_font_get_glyph_extents() for details about the interpretation
- * of the rectangles.
- */
-void
-pango_glyph_string_extents (PangoGlyphString *glyphs,
- PangoFont *font,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ *
+ * Computes the extents of a sub-portion of a glyph string. The extents are
+ * relative to the start of the glyph string range (the origin of their
+ * coordinate system is at the start of the range, not at the start of the entire
+ * glyph string).
+ **/
+void
+pango_glyph_string_extents_range (PangoGlyphString *glyphs,
+ int start,
+ int end,
+ PangoFont *font,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
int x_pos = 0;
int i;
- if (glyphs->num_glyphs == 0)
+ g_return_if_fail (start <= end);
+
+ if (end - start == 0)
{
if (ink_rect)
{
@@ -128,7 +135,7 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
return;
}
- for (i=0; i<glyphs->num_glyphs; i++)
+ for (i = start; i < end; i++)
{
PangoRectangle glyph_ink;
PangoRectangle glyph_logical;
@@ -137,7 +144,8 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
if (i == 0)
{
- 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, logical_rect);
if (logical_rect)
{
@@ -179,6 +187,30 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
x_pos += geometry->width;
}
+
+}
+
+/**
+ * pango_glyph_string_extents:
+ * @glyphs: a #PangoGlyphString
+ * @font: a #PangoFont
+ * @ink_rect: rectangle used to store the extents of the glyph string as drawn
+ * or %NULL to indicate that the result is not needed.
+ * @logical_rect: rectangle used to store the logical extents of the glyph string
+ * or %NULL to indicate that the result is not needed.
+ *
+ * Compute the logical and ink extents of a glyph string. See the documentation
+ * for pango_font_get_glyph_extents() for details about the interpretation
+ * of the rectangles.
+ */
+void
+pango_glyph_string_extents (PangoGlyphString *glyphs,
+ PangoFont *font,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
+{
+ pango_glyph_string_extents_range (glyphs, 0, glyphs->num_glyphs,
+ font, ink_rect, logical_rect);
}
/**