diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-09-04 15:05:39 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-09-04 15:05:39 +0000 |
commit | 93861b3494f85f749a1d3bcc2225720989ca61a5 (patch) | |
tree | b3b6bc6c83c9767f4f94b3236b39d9abfe94e3aa /test/test-nautilus-font.c | |
parent | 31cb07f67aeff1c10fb4ebce4fb80b24f566b06c (diff) | |
download | nautilus-93861b3494f85f749a1d3bcc2225720989ca61a5.tar.gz |
Work on task 1588.
* libnautilus-extensions/nautilus-scalable-font.c:
(nautilus_scalable_font_measure_text),
(nautilus_scalable_font_draw_text),
(nautilus_scalable_font_measure_text_lines),
(nautilus_scalable_font_draw_text_lines),
(nautilus_scalable_font_measure_text_lines),
(nautilus_scalable_font_draw_text_lines),
(nautilus_scalable_font_largest_fitting_font_size):
* libnautilus-extensions/nautilus-scalable-font.h:
Change api to accept a string with embedded new lines instead of
an array of strings. This simplifies many things.
* libnautilus-extensions/nautilus-label.c:
(nautilus_label_initialize), (nautilus_label_destroy),
(render_buffer_pixbuf), (label_recompute_line_geometries):
Update for NautilusScalalbleFont api changes. No longer need to
tokenize the text string. we can feed the string to the rendering
api as is.
* librsvg/rsvg-ft.c: (rsvg_ft_render_string):
* librsvg/rsvg-ft.h:
Change the string to glyph rendering api to accept the string
length rather than computing it. This makes it possible to feed
it arbitrary lengths.
* librsvg/rsvg.c: (rsvg_text_handler_characters):
* librsvg/test-ft-gtk.c: (draw_line):
* librsvg/test-ft.c: (main):
Update for api changes.
* src/nautilus-about.c: (draw_aa_string):
* src/nautilus-sidebar-tabs.c: (draw_one_tab_plain),
(draw_one_tab_themed), (get_tab_width):
* test/test-nautilus-font.c: (main):
Update test to use text lines drawing api.
* test/test-nautilus-label.c:
(alpha_background_color_value_changed_callback), (main):
Update test for 2 new lines in a row.
Diffstat (limited to 'test/test-nautilus-font.c')
-rw-r--r-- | test/test-nautilus-font.c | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/test/test-nautilus-font.c b/test/test-nautilus-font.c index 5a212b084..8e72eb99f 100644 --- a/test/test-nautilus-font.c +++ b/test/test-nautilus-font.c @@ -18,55 +18,76 @@ #include <libnautilus-extensions/nautilus-scalable-font.h> #include <libnautilus-extensions/nautilus-label.h> #include <libnautilus-extensions/nautilus-image.h> +#include <libnautilus-extensions/nautilus-string.h> int main (int argc, char* argv[]) { GdkPixbuf *pixbuf; - guint text_width; - guint text_height; ArtIRect area; NautilusScalableFont *font; + guint num_text_lines; + char **text_lines; + guint *text_line_widths; + guint *text_line_heights; + guint max_width_out; + guint total_height_out; - const char *text = "Something"; - const guint font_width = 64; - const guint font_height = 64; + const char *text = "\nLine Two\n\nLine Four\n\n\nLine Seven\n"; + const guint font_width = 48; + const guint font_height = 48; + + const guint pixbuf_width = 500; + const guint pixbuf_height = 700; gtk_init (&argc, &argv); gdk_rgb_init (); font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new ("Nimbus Sans L", NULL, NULL, NULL)); g_assert (font != NULL); - - nautilus_scalable_font_measure_text (font, - font_width, - font_height, - text, - &text_width, - &text_height); - - g_print ("size of '%s' = (%d,%d)\n", text, text_width, text_height); - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 512, 256); + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf_width, pixbuf_height); g_assert (pixbuf != NULL); area.x0 = 0; area.y0 = 0; - area.x1 = 512; - area.y1 = 256; - - nautilus_scalable_font_draw_text (font, - pixbuf, - &area, - font_width, - font_height, - text, - NAUTILUS_RGB_COLOR_RED, - 255); + area.x1 = pixbuf_width; + area.y1 = pixbuf_height; - g_assert (pixbuf != NULL); + num_text_lines = nautilus_str_count_characters (text, '\n') + 1; + + text_lines = g_strsplit (text, "\n", -1); + text_line_widths = g_new (guint, num_text_lines); + text_line_heights = g_new (guint, num_text_lines); + + nautilus_scalable_font_measure_text_lines (font, + font_width, + font_height, + text, + num_text_lines, + text_line_widths, + text_line_heights, + &max_width_out, + &total_height_out); + + g_print ("max_width = %d, total_height = %d\n", max_width_out, total_height_out); + + nautilus_scalable_font_draw_text_lines (font, + pixbuf, + &area, + font_width, + font_height, + text, + num_text_lines, + text_line_widths, + text_line_heights, + GTK_JUSTIFY_LEFT, + 2, + NAUTILUS_RGB_COLOR_RED, + 255); + nautilus_gdk_pixbuf_save_to_file (pixbuf, "font_test.png"); g_print ("saving test png file to font_test.png\n"); |