diff options
author | Owen Taylor <otaylor@redhat.com> | 1998-12-15 20:31:26 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-12-15 20:31:26 +0000 |
commit | a3c1e86ffa9b75d4e027843d6c3d23249247cad5 (patch) | |
tree | 2bf8312bde174405ce5ba3937a389a2ec4856927 /gdk/gdkfont.c | |
parent | 7eec796cbdddddb2b1213dbf90c0609ef65a99a6 (diff) | |
download | gdk-pixbuf-a3c1e86ffa9b75d4e027843d6c3d23249247cad5.tar.gz |
Added gdk_text_extents_wc()
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Diffstat (limited to 'gdk/gdkfont.c')
-rw-r--r-- | gdk/gdkfont.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/gdk/gdkfont.c b/gdk/gdkfont.c index 094be0c41..e36fde170 100644 --- a/gdk/gdkfont.c +++ b/gdk/gdkfont.c @@ -504,6 +504,80 @@ gdk_text_extents (GdkFont *font, } void +gdk_text_extents_wc (GdkFont *font, + const GdkWChar *text, + gint text_length, + gint *lbearing, + gint *rbearing, + gint *width, + gint *ascent, + gint *descent) +{ + GdkFontPrivate *private; + XCharStruct overall; + XFontStruct *xfont; + XFontSet fontset; + XRectangle ink, logical; + int direction; + int font_ascent; + int font_descent; + gint i; + + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + + private = (GdkFontPrivate*) font; + + switch (font->type) + { + case GDK_FONT_FONT: + { + gchar *text_8bit; + gint i; + + xfont = (XFontStruct *) private->xfont; + g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)); + + text_8bit = g_new (gchar, text_length); + for (i=0; i<text_length; i++) + text_8bit[i] = text[i]; + + XTextExtents (xfont, text_8bit, text_length, + &direction, &font_ascent, &font_descent, + &overall); + g_free (text_8bit); + + if (lbearing) + *lbearing = overall.lbearing; + if (rbearing) + *rbearing = overall.rbearing; + if (width) + *width = overall.width; + if (ascent) + *ascent = overall.ascent; + if (descent) + *descent = overall.descent; + break; + } + case GDK_FONT_FONTSET: + fontset = (XFontSet) private->xfont; + XwcTextExtents (fontset, text, text_length, &ink, &logical); + if (lbearing) + *lbearing = ink.x; + if (rbearing) + *rbearing = ink.x + ink.width; + if (width) + *width = logical.width; + if (ascent) + *ascent = -ink.y; + if (descent) + *descent = ink.y + ink.height; + break; + } + +} + +void gdk_string_extents (GdkFont *font, const gchar *string, gint *lbearing, |