summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-07-02 21:31:19 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-07-02 21:31:19 +0000
commit6870ed61201c6c8545c59861a148647e39a3b7ed (patch)
treee4ffb25a9ca54888d625bc423ceb3507ec8c1993
parent5d69786601736595d1b6ac4fe141a8694fab011d (diff)
downloadpango-6870ed61201c6c8545c59861a148647e39a3b7ed.tar.gz
Add a PANGO_PIXELS macro to convert from pango units to device units and
Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-types.h: Add a PANGO_PIXELS macro to convert from pango units to device units and round. * pango/pango-layout.[ch]: Add convenience functions pango_layout_get_pixel_extents, pango_layout_get_size, pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
-rw-r--r--ChangeLog9
-rw-r--r--ChangeLog.pre-1-09
-rw-r--r--ChangeLog.pre-1-109
-rw-r--r--ChangeLog.pre-1-29
-rw-r--r--ChangeLog.pre-1-49
-rw-r--r--ChangeLog.pre-1-69
-rw-r--r--ChangeLog.pre-1-89
-rw-r--r--configure.in2
-rw-r--r--pango/pango-layout.c136
-rw-r--r--pango/pango-layout.h12
-rw-r--r--pango/pango-types.h3
11 files changed, 214 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3aa24c7d..60696a9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h: Add a PANGO_PIXELS macro to convert
+ from pango units to device units and round.
+
+ * pango/pango-layout.[ch]: Add convenience functions
+ pango_layout_get_pixel_extents, pango_layout_get_size,
+ pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
+
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-utils.[ch] Makefile.am: A bunch of simple functions
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index 3aa24c7d..60696a9c 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,12 @@
+Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h: Add a PANGO_PIXELS macro to convert
+ from pango units to device units and round.
+
+ * pango/pango-layout.[ch]: Add convenience functions
+ pango_layout_get_pixel_extents, pango_layout_get_size,
+ pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
+
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-utils.[ch] Makefile.am: A bunch of simple functions
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 3aa24c7d..60696a9c 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,12 @@
+Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h: Add a PANGO_PIXELS macro to convert
+ from pango units to device units and round.
+
+ * pango/pango-layout.[ch]: Add convenience functions
+ pango_layout_get_pixel_extents, pango_layout_get_size,
+ pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
+
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-utils.[ch] Makefile.am: A bunch of simple functions
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 3aa24c7d..60696a9c 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,12 @@
+Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h: Add a PANGO_PIXELS macro to convert
+ from pango units to device units and round.
+
+ * pango/pango-layout.[ch]: Add convenience functions
+ pango_layout_get_pixel_extents, pango_layout_get_size,
+ pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
+
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-utils.[ch] Makefile.am: A bunch of simple functions
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 3aa24c7d..60696a9c 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,12 @@
+Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h: Add a PANGO_PIXELS macro to convert
+ from pango units to device units and round.
+
+ * pango/pango-layout.[ch]: Add convenience functions
+ pango_layout_get_pixel_extents, pango_layout_get_size,
+ pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
+
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-utils.[ch] Makefile.am: A bunch of simple functions
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 3aa24c7d..60696a9c 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,12 @@
+Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h: Add a PANGO_PIXELS macro to convert
+ from pango units to device units and round.
+
+ * pango/pango-layout.[ch]: Add convenience functions
+ pango_layout_get_pixel_extents, pango_layout_get_size,
+ pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
+
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-utils.[ch] Makefile.am: A bunch of simple functions
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 3aa24c7d..60696a9c 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,12 @@
+Sun Jul 2 17:19:11 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h: Add a PANGO_PIXELS macro to convert
+ from pango units to device units and round.
+
+ * pango/pango-layout.[ch]: Add convenience functions
+ pango_layout_get_pixel_extents, pango_layout_get_size,
+ pango_layout_get_pixel_size pango_layout_line_get_pixel_extents.
+
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-utils.[ch] Makefile.am: A bunch of simple functions
diff --git a/configure.in b/configure.in
index 1019c79a..af367cf8 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to create configure.
AC_INIT(ChangeLog)
-AM_INIT_AUTOMAKE(pango, 0.11)
+AM_INIT_AUTOMAKE(pango, 0.12)
AM_CONFIG_HEADER(config.h)
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index a876c069..abcc7f5b 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1274,7 +1274,7 @@ pango_layout_get_cursor_pos (PangoLayout *layout,
* @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 layout line. See the documentation
+ * Compute the logical and ink extents of a layout. See the documentation
* for pango_font_get_glyph_extents() for details about the interpretation
* of the rectangles.
*/
@@ -1370,6 +1370,99 @@ pango_layout_get_extents (PangoLayout *layout,
}
}
+/**
+ * pango_layout_get_pixel_extents:
+ * @layout: a #PangoLayout
+ * @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 layout. See the documentation
+ * for pango_font_get_glyph_extents() for details about the interpretation
+ * of the rectangles. The returned rectangles are in device units, as
+ * opposed to pango_layout_get_extents(), which returns the extents in
+ * units of device unit / PANGO_SCALE.
+ **/
+void
+pango_layout_get_pixel_extents (PangoLayout *layout,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
+{
+ g_return_if_fail (PANGO_IS_LAYOUT (layout));
+
+ pango_layout_get_extents (layout, ink_rect, logical_rect);
+
+ if (ink_rect)
+ {
+ ink_rect->width = (ink_rect->width + PANGO_SCALE / 2) / PANGO_SCALE;
+ ink_rect->height = (ink_rect->height + PANGO_SCALE / 2) / PANGO_SCALE;
+
+ ink_rect->x = PANGO_PIXELS (ink_rect->x);
+ ink_rect->y = PANGO_PIXELS (ink_rect->y);
+ }
+
+ if (logical_rect)
+ {
+ logical_rect->width = (logical_rect->width + PANGO_SCALE / 2) / PANGO_SCALE;
+ logical_rect->height = (logical_rect->height + PANGO_SCALE / 2) / PANGO_SCALE;
+
+ logical_rect->x = PANGO_PIXELS (logical_rect->x);
+ logical_rect->y = PANGO_PIXELS (logical_rect->y);
+ }
+}
+
+/**
+ * pango_layout_get_size:
+ * @layout: a #PangoLayout
+ * @width: location to store the logical width, or %NULL
+ * @height: location to store the logical height, or %NULL
+ *
+ * Determine the logical width and height of a #PangoLayout
+ * in Pango units. (device units divided by PANGO_SCALE). This
+ * is simply a convenience function around pango_layout_get_extents.
+ **/
+void
+pango_layout_get_size (PangoLayout *layout,
+ int *width,
+ int *height)
+{
+ PangoRectangle logical_rect;
+
+ pango_layout_get_extents (layout, NULL, &logical_rect);
+
+ if (width)
+ *width = logical_rect.width;
+ if (height)
+ *height = logical_rect.height;
+}
+
+/**
+ * pango_layout_get_pixel_size:
+ * @layout: a #PangoLayout
+ * @width: location to store the logical width, or %NULL
+ * @height: location to store the logical height, or %NULL
+ *
+ * Determine the logical width and height of a #PangoLayout
+ * in device units. (pango_layout_get_size() returns the width
+ * and height in thousandths of a device unit.) This
+ * is simply a convenience function around pango_layout_get_extents.
+ **/
+void
+pango_layout_get_pixel_size (PangoLayout *layout,
+ int *width,
+ int *height)
+{
+ PangoRectangle logical_rect;
+
+ pango_layout_get_extents (layout, NULL, &logical_rect);
+
+ if (width)
+ *width = (logical_rect.width + PANGO_SCALE / 2) / PANGO_SCALE;
+ if (height)
+ *height = (logical_rect.height + PANGO_SCALE / 2) / PANGO_SCALE;
+}
+
static void
pango_layout_clear_lines (PangoLayout *layout)
{
@@ -2337,6 +2430,47 @@ pango_layout_line_new (PangoLayout *layout)
return (PangoLayoutLine *) private;
}
+/**
+ * pango_layout_line_get_pixel_extents:
+ * @layout: a #PangoLayout
+ * @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 layout line. See the documentation
+ * for pango_font_get_glyph_extents() for details about the interpretation
+ * of the rectangles. The returned rectangles are in device units, as
+ * opposed to pango_layout_line_get_extents(), which returns the extents in
+ * units of device unit / PANGO_SCALE.
+ **/
+void
+pango_layout_line_get_pixel_extents (PangoLayoutLine *layout_line,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
+{
+ g_return_if_fail (LINE_IS_VALID (layout_line));
+
+ pango_layout_line_get_extents (layout_line, ink_rect, logical_rect);
+
+ if (ink_rect)
+ {
+ ink_rect->width = (ink_rect->width + PANGO_SCALE / 2) / PANGO_SCALE;
+ ink_rect->height = (ink_rect->height + PANGO_SCALE / 2) / PANGO_SCALE;
+
+ ink_rect->x = PANGO_PIXELS (ink_rect->x);
+ ink_rect->y = PANGO_PIXELS (ink_rect->y);
+ }
+
+ if (logical_rect)
+ {
+ logical_rect->width = (logical_rect->width + PANGO_SCALE / 2) / PANGO_SCALE;
+ logical_rect->height = (logical_rect->height + PANGO_SCALE / 2) / PANGO_SCALE;
+
+ logical_rect->x = PANGO_PIXELS (logical_rect->x);
+ logical_rect->y = PANGO_PIXELS (logical_rect->y);
+ }
+}
/*
* NB: This implement the exact same algorithm as
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index 034794d9..516b867a 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -120,6 +120,15 @@ gboolean pango_layout_xy_to_index (PangoLayout *layout,
void pango_layout_get_extents (PangoLayout *layout,
PangoRectangle *ink_rect,
PangoRectangle *logical_rect);
+void pango_layout_get_pixel_extents (PangoLayout *layout,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
+void pango_layout_get_size (PangoLayout *layout,
+ int *width,
+ int *height);
+void pango_layout_get_pixel_size (PangoLayout *layout,
+ int *width,
+ int *height);
int pango_layout_get_line_count (PangoLayout *layout);
PangoLayoutLine *pango_layout_get_line (PangoLayout *layout,
@@ -144,6 +153,9 @@ void pango_layout_line_get_x_ranges (PangoLayoutLine *line,
void pango_layout_line_get_extents (PangoLayoutLine *line,
PangoRectangle *ink_rect,
PangoRectangle *logical_rect);
+void pango_layout_line_get_pixel_extents (PangoLayoutLine *layout_line,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
#ifdef __cplusplus
}
diff --git a/pango/pango-types.h b/pango/pango-types.h
index cabdf232..91e21ba8 100644
--- a/pango/pango-types.h
+++ b/pango/pango-types.h
@@ -49,6 +49,9 @@ struct _PangoRectangle
};
#define PANGO_SCALE 1024
+#define PANGO_PIXELS(d) (((d) >= 0) ? \
+ ((d) + PANGO_SCALE / 2) / PANGO_SCALE : \
+ ((d) - PANGO_SCALE / 2) / PANGO_SCALE)
/* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing
*/