diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-23 08:35:08 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-23 08:35:08 +0000 |
commit | 2db06b9173c5a9cb255bb8236bfc01a844331ef1 (patch) | |
tree | 8118f74d9db121f34d470d1d45eddc449d63f6b0 /test | |
parent | f8b7ec465c6edafe50f3e0d0b920e51d3a5587ec (diff) | |
download | nautilus-2db06b9173c5a9cb255bb8236bfc01a844331ef1.tar.gz |
reviewed by: Gene Z. Ragan <gzr@eazel.com>
Fix bugs:
2784 - NautilusScalableFont text clipping is broken.
2831 - Icon container redraw performance is poor in smooth mode.
Optimized this case some. Its still not as good as we
would like it to be. Thanks to the following changes, it
is possible to optimize it even more - by caching the
layouts of icons for example. We need to profile with the
new changes.
* libnautilus-extensions/Makefile.am:
* libnautilus-extensions/nautilus-icon-canvas-item.c:
(measure_label_text), (draw_or_measure_label_text_aa),
(draw_label_text_aa):
* libnautilus-extensions/nautilus-icon-factory.c: (embed_text):
Use NautilusSmoothTextLayout instead of NautilusTextLayout.
* libnautilus-extensions/nautilus-label.h:
* libnautilus-extensions/nautilus-label.c:
(nautilus_label_initialize_class), (nautilus_label_initialize),
(nautilus_label_destroy), (nautilus_label_set_arg),
(nautilus_label_get_arg), (nautilus_label_size_allocate),
(label_composite_pixbuf_callback), (label_get_text_dimensions),
(label_smooth_text_ensure), (label_smooth_text_clear),
(nautilus_label_set_smooth_font),
(nautilus_label_set_smooth_font_size),
(nautilus_label_set_is_smooth),
(nautilus_label_set_smooth_line_wrap_width),
(nautilus_label_set_smooth_drop_shadow_offset),
(nautilus_label_set_text), (nautilus_label_set_wrap),
(nautilus_label_new_solid), (nautilus_label_make_bold),
(nautilus_label_make_larger), (nautilus_label_make_smaller),
(nautilus_label_set_never_smooth):
Simplified. Use NautilusSmoothTextLayout to handle laying
out the text.
* libnautilus-extensions/nautilus-scalable-font.h:
* libnautilus-extensions/nautilus-scalable-font.c:
(nautilus_scalable_font_new),
(nautilus_scalable_font_measure_text),
(nautilus_scalable_font_draw_text),
(initialize_global_stuff_if_needed),
(nautilus_scalable_font_get_underline_height),
(nautilus_scalable_font_get_baseline):
Simplified. Use NautilusSmoothTextLayout. Remove no longer
needed functions.
* libnautilus-extensions/nautilus-smooth-text-layout.h:
* libnautilus-extensions/nautilus-smooth-text-layout.c:
New class to handle smooth text layout needs. Layout details are
private to make it easirt to fix bugs in the future.
* libnautilus-extensions/nautilus-text-layout.c:
* libnautilus-extensions/nautilus-text-layout.h:
Retire.
* test/.cvsignore:
* test/Makefile.am:
* test/test-nautilus-font-simple.c: (main):
* test/test-nautilus-font.c: (main):
* test/test-nautilus-glyph-simple.c: (glyph_new), (main):
* test/test-nautilus-label-simple.c: (main):
* test/test-nautilus-label-wrapped.c: (create_nautilus_label),
(main):
* test/test-nautilus-smooth-text-layout.c: (main):
New smooth text layout test. Update test for smooth layout changes.
Diffstat (limited to 'test')
-rw-r--r-- | test/.cvsignore | 1 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/test-nautilus-font-simple.c | 4 | ||||
-rw-r--r-- | test/test-nautilus-font.c | 182 | ||||
-rw-r--r-- | test/test-nautilus-glyph-simple.c | 116 | ||||
-rw-r--r-- | test/test-nautilus-label-simple.c | 38 | ||||
-rw-r--r-- | test/test-nautilus-label-wrapped.c | 20 | ||||
-rw-r--r-- | test/test-nautilus-smooth-text-layout.c | 142 |
8 files changed, 260 insertions, 245 deletions
diff --git a/test/.cvsignore b/test/.cvsignore index e0c642411..f5d711bdd 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -37,3 +37,4 @@ test-nautilus-smooth-graphics test-nautilus-widgets test-nautilus-wrap-table test-nautilus-wrapped-label +test-nautilus-smooth-text-layout diff --git a/test/Makefile.am b/test/Makefile.am index a1bb3a508..f6c357977 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -58,6 +58,7 @@ noinst_PROGRAMS =\ test-nautilus-preferences-change \ test-nautilus-preferences-display \ test-nautilus-smooth-graphics \ + test-nautilus-smooth-text-layout \ test-nautilus-widgets \ test-nautilus-wrap-table \ test-nautilus-viewport-constraint \ @@ -92,6 +93,7 @@ test_nautilus_pixbuf_tile_SOURCES = test-nautilus-pixbuf-tile.c test.c test_nautilus_preferences_change_SOURCES = test-nautilus-preferences-change.c test.c test_nautilus_preferences_display_SOURCES = test-nautilus-preferences-display.c test.c test_nautilus_smooth_graphics_SOURCES = test-nautilus-smooth-graphics.c +test_nautilus_smooth_text_layout_SOURCES = test-nautilus-smooth-text-layout.c test.c test_nautilus_widgets_SOURCES = test-nautilus-widgets.c test_nautilus_wrap_table_SOURCES = test-nautilus-wrap-table.c test.c diff --git a/test/test-nautilus-font-simple.c b/test/test-nautilus-font-simple.c index ee0e7a691..87b749d2b 100644 --- a/test/test-nautilus-font-simple.c +++ b/test/test-nautilus-font-simple.c @@ -31,8 +31,8 @@ main (int argc, char* argv[]) 100, NULL, 80, - "Something", - strlen ("Something"), + "Somoet", + strlen ("Somoet"), NAUTILUS_RGBA_COLOR_OPAQUE_BLUE, NAUTILUS_OPACITY_FULLY_OPAQUE); diff --git a/test/test-nautilus-font.c b/test/test-nautilus-font.c index 7ac8647a7..553eed1ab 100644 --- a/test/test-nautilus-font.c +++ b/test/test-nautilus-font.c @@ -4,7 +4,6 @@ #include "test.h" #include <libnautilus-extensions/nautilus-scalable-font.h> -#include <libnautilus-extensions/nautilus-text-layout.h> int main (int argc, char* argv[]) @@ -15,11 +14,9 @@ main (int argc, char* argv[]) ArtIRect whole_area; ArtIRect multi_lines_area; - const char *text = "\nLine Two\n\nLine Four\n\n\nLine Seven"; const guint font_size = 48; const guint pixbuf_width = 500; const guint pixbuf_height = 700; - const guint line_offset = 2; const guint empty_line_height = font_size; const int multi_line_x = 10; const int multi_line_y = 10; @@ -45,37 +42,6 @@ main (int argc, char* argv[]) multi_lines_area.x0 = multi_line_x; multi_lines_area.y0 = multi_line_y; - /* Measure some text lines */ - { - guint num_text_lines; - NautilusDimensions *text_line_dimensions; - guint max_width_out; - guint total_height_out; - - num_text_lines = nautilus_str_count_characters (text, '\n') + 1; - - text_line_dimensions = g_new (NautilusDimensions, num_text_lines); - - nautilus_scalable_font_measure_text_lines (font, - font_size, - text, - num_text_lines, - empty_line_height, - text_line_dimensions, - &max_width_out, - &total_height_out); - - multi_lines_area.x1 = multi_lines_area.x0 + max_width_out; - multi_lines_area.y1 = multi_lines_area.y0 + total_height_out + ((num_text_lines - 1) * line_offset); - - g_print ("num_text_lines = %d, max_width = %d, total_height = %d\n", - num_text_lines, - max_width_out, - total_height_out); - - g_free (text_line_dimensions); - } - clip_area.x0 = 300; clip_area.y0 = 20; clip_area.x1 = clip_area.x0 + 100; @@ -107,22 +73,6 @@ main (int argc, char* argv[]) -1); /* - * Multiple text lines test. - */ - nautilus_scalable_font_draw_text_lines (font, - pixbuf, - multi_line_x, - multi_line_y, - &whole_area, - font_size, - text, - GTK_JUSTIFY_LEFT, - line_offset, - empty_line_height, - NAUTILUS_RGBA_COLOR_OPAQUE_BLUE, - NAUTILUS_OPACITY_FULLY_OPAQUE); - - /* * Clipped text test. The "Something" string should be clipped such * that horizontally you can only see "Som" and a tiny fraction of * the "e". @@ -177,138 +127,6 @@ main (int argc, char* argv[]) gdk_pixbuf_unref (tile_pixbuf); } - /* - * Text layout test. - */ - { - NautilusTextLayout *text_layout; - const guint max_text_width = 100; - const char *separators = " -_,;.?/&"; - const char *text = "This is a long piece of text!-This is the second piece-Now we have the third piece-And finally the fourth piece"; - const guint font_size = 14; - ArtIRect layout_area; - - text_layout = nautilus_text_layout_new (font, - font_size, - text, - separators, - max_text_width, - TRUE); - g_assert (text_layout != NULL); - - layout_area.x0 = 20; - layout_area.y0 = 550; - layout_area.x1 = layout_area.x0 + max_text_width; - layout_area.y1 = layout_area.y0 + 130; - - nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, - FALSE, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE, - -1); - - nautilus_text_layout_paint (text_layout, - pixbuf, - layout_area.x0, - layout_area.y0, - GTK_JUSTIFY_LEFT, - NAUTILUS_RGBA_COLOR_OPAQUE_BLACK, - FALSE); - - layout_area.x0 += (max_text_width + 20); - layout_area.x1 += (max_text_width + 20); - - nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, - FALSE, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE, - -1); - - nautilus_text_layout_paint (text_layout, - pixbuf, - layout_area.x0, - layout_area.y0, - GTK_JUSTIFY_CENTER, - NAUTILUS_RGBA_COLOR_OPAQUE_BLACK, - FALSE); - - layout_area.x0 += (max_text_width + 20); - layout_area.x1 += (max_text_width + 20); - - nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, - FALSE, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE, - -1); - - nautilus_text_layout_paint (text_layout, - pixbuf, - layout_area.x0, - layout_area.y0, - GTK_JUSTIFY_RIGHT, - NAUTILUS_RGBA_COLOR_OPAQUE_BLACK, - FALSE); - - nautilus_text_layout_free (text_layout); - } - - /* - * Underlined text test. - */ - { - NautilusTextLayout *text_layout; - const guint max_text_width = pixbuf_width / 2; - const char *separators = "-"; - const char *text = "This is multi line-text (g) that should-be centered and-(q) underlined"; - const guint font_size = 30; - ArtIRect layout_area; - - text_layout = nautilus_text_layout_new (font, - font_size, - text, - separators, - max_text_width, - TRUE); - g_assert (text_layout != NULL); - - layout_area.x0 = (pixbuf_width - text_layout->width) / 2; - layout_area.y0 = 410; - layout_area.x1 = layout_area.x0 + text_layout->width; - layout_area.y1 = layout_area.y0 + text_layout->height; - - nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, - FALSE, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE, - -1); - - nautilus_text_layout_paint (text_layout, - pixbuf, - layout_area.x0, - layout_area.y0, - GTK_JUSTIFY_CENTER, - NAUTILUS_RGBA_COLOR_OPAQUE_BLACK, - TRUE); - - nautilus_text_layout_free (text_layout); - } - nautilus_debug_show_pixbuf_in_eog (pixbuf); gdk_pixbuf_unref (pixbuf); diff --git a/test/test-nautilus-glyph-simple.c b/test/test-nautilus-glyph-simple.c index e32f2c12a..c69bf15d0 100644 --- a/test/test-nautilus-glyph-simple.c +++ b/test/test-nautilus-glyph-simple.c @@ -6,9 +6,10 @@ #include <libnautilus-extensions/nautilus-glyph.h> static NautilusGlyph * -glyph_new (const char *text, int font_size) +glyph_new (const char *text, int font_size, gboolean bold) { NautilusScalableFont *font; + NautilusScalableFont *bold_font; NautilusGlyph *glyph; g_return_val_if_fail (text != NULL, NULL); @@ -19,6 +20,13 @@ glyph_new (const char *text, int font_size) font = nautilus_scalable_font_get_default_font (); g_return_val_if_fail (font != NULL, NULL); + if (bold) { + bold_font = nautilus_scalable_font_make_bold (font); + g_return_val_if_fail (bold_font != NULL, NULL); + gtk_object_unref (GTK_OBJECT (font)); + font = bold_font; + } + glyph = nautilus_glyph_new (font, font_size, text, strlen (text)); g_return_val_if_fail (glyph != NULL, NULL); @@ -32,17 +40,18 @@ main (int argc, char* argv[]) { GdkPixbuf *pixbuf; NautilusScalableFont *font; - ArtIRect clip_area; - ArtIRect dest_area; NautilusGlyph *glyph; + int x; + int y; const guint font_size = 60; + const guint underlined_font_size = 100; const int opacity = NAUTILUS_OPACITY_FULLY_OPAQUE; const guint pixbuf_width = 640; const guint pixbuf_height = 480; const gboolean has_alpha = FALSE; const guint32 background_color = NAUTILUS_RGB_COLOR_WHITE; - const char text[] = "Something"; + const char text[] = "Somethin"; test_init (&argc, &argv); @@ -58,47 +67,84 @@ main (int argc, char* argv[]) background_color, NAUTILUS_OPACITY_FULLY_OPAQUE); - nautilus_art_irect_assign (&clip_area, - 60, - 20, - 200, - 100); - - if (0) nautilus_debug_pixbuf_draw_rectangle (pixbuf, - FALSE, - clip_area.x0, - clip_area.y0, - clip_area.x1, - clip_area.y1, - NAUTILUS_RGBA_COLOR_OPAQUE_GREEN, - NAUTILUS_OPACITY_FULLY_OPAQUE); - - glyph = glyph_new (text, font_size); + glyph = glyph_new (text, font_size, FALSE); - nautilus_art_irect_assign (&dest_area, - 50, - 200, - 1000, - 1000); + x = 50; + y = 10; nautilus_glyph_draw_to_pixbuf (glyph, pixbuf, - 100, - 0, - &dest_area, + x, + y, + NULL, NAUTILUS_RGBA_COLOR_OPAQUE_BLUE, opacity); - - if (0) nautilus_glyph_draw_to_pixbuf (glyph, + y += nautilus_glyph_get_height (glyph) + 10; + nautilus_glyph_free (glyph); + + glyph = glyph_new (text, font_size, TRUE); + nautilus_glyph_draw_to_pixbuf (glyph, pixbuf, - 30, - 40, - NULL, //&clip_area, - NAUTILUS_RGBA_COLOR_OPAQUE_GREEN, + x, + y, + NULL, + NAUTILUS_RGBA_COLOR_OPAQUE_BLUE, opacity); - + y += nautilus_glyph_get_height (glyph) + 10; nautilus_glyph_free (glyph); + + + glyph = glyph_new (text, underlined_font_size, FALSE); + nautilus_glyph_draw_to_pixbuf (glyph, + pixbuf, + x, + y, + NULL, + NAUTILUS_RGBA_COLOR_OPAQUE_BLUE, + opacity); + + { + NautilusScalableFont *font; + int underline_height; + int baseline; + ArtIRect glyph_rect; + ArtIRect underline_rect; + + font = nautilus_scalable_font_get_default_font (); + underline_height = nautilus_scalable_font_get_underline_height (font, underlined_font_size); + baseline = nautilus_scalable_font_get_baseline (font, underlined_font_size); + gtk_object_unref (GTK_OBJECT (font)); + + glyph_rect = nautilus_glyph_intersect (glyph, x, y, NULL); + + if (0) nautilus_debug_pixbuf_draw_rectangle (pixbuf, + FALSE, + glyph_rect.x0, + glyph_rect.y0, + glyph_rect.x1, + glyph_rect.y1, + 0xFF0000, + NAUTILUS_OPACITY_FULLY_OPAQUE); + underline_rect = glyph_rect; + + underline_rect.y1 -= ABS (baseline); + underline_rect.y0 = underline_rect.y1 - underline_height; + + nautilus_debug_pixbuf_draw_rectangle (pixbuf, + TRUE, + underline_rect.x0, + underline_rect.y0, + underline_rect.x1, + underline_rect.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_BLUE, + NAUTILUS_OPACITY_FULLY_OPAQUE); + + g_print ("underline_height = %d\n", underline_height); + g_print ("baseline = %d\n", baseline); + } + nautilus_glyph_free (glyph); + nautilus_debug_show_pixbuf_in_eog (pixbuf); gdk_pixbuf_unref (pixbuf); diff --git a/test/test-nautilus-label-simple.c b/test/test-nautilus-label-simple.c index 3dbcae70b..cd3d81279 100644 --- a/test/test-nautilus-label-simple.c +++ b/test/test-nautilus-label-simple.c @@ -3,28 +3,34 @@ int main (int argc, char* argv[]) { + //const char *text = "This is a very intersting label\nThat has more\nthan one line."; + const char *text = "Something"; GtkWidget *window; - GtkWidget *label; + GtkWidget *vbox; + GtkWidget *label1; + GtkWidget *label2; test_init (&argc, &argv); window = test_window_new ("Simple Label Test", 20); - if (0) { - GtkWidget *frame; - GtkWidget *main_vbox; - - main_vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), main_vbox); - frame = gtk_frame_new ("Foo"); - label = nautilus_label_new ("This is a very intersting label\nThat has more\nthan one line."); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); - } else { - label = nautilus_label_new ("This is a very intersting label\nThat has more\nthan one line."); - nautilus_label_make_larger (NAUTILUS_LABEL (label), 40); - gtk_container_add (GTK_CONTAINER (window), label); - } + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), vbox); + + label1 = nautilus_label_new (""); + nautilus_label_make_larger (NAUTILUS_LABEL (label1), 40); + nautilus_label_set_wrap (NAUTILUS_LABEL (label1), TRUE); + nautilus_label_set_justify (NAUTILUS_LABEL (label1), GTK_JUSTIFY_CENTER); + nautilus_label_set_text (NAUTILUS_LABEL (label1), text); + gtk_box_pack_start (GTK_BOX (vbox), label1, TRUE, TRUE, 0); + + label2 = nautilus_label_new (""); + nautilus_label_make_larger (NAUTILUS_LABEL (label2), 40); + nautilus_label_make_bold (NAUTILUS_LABEL (label2)); + nautilus_label_set_wrap (NAUTILUS_LABEL (label2), TRUE); + nautilus_label_set_justify (NAUTILUS_LABEL (label2), GTK_JUSTIFY_CENTER); + nautilus_label_set_text (NAUTILUS_LABEL (label2), text); + gtk_box_pack_start (GTK_BOX (vbox), label2, TRUE, TRUE, 0); gtk_widget_show_all (window); diff --git a/test/test-nautilus-label-wrapped.c b/test/test-nautilus-label-wrapped.c index 0e523d5a2..1fc1f1b0b 100644 --- a/test/test-nautilus-label-wrapped.c +++ b/test/test-nautilus-label-wrapped.c @@ -46,7 +46,7 @@ create_nautilus_label (gboolean adjust_wrap_on_resize) nautilus_label_set_wrap (NAUTILUS_LABEL (label), TRUE); nautilus_label_set_justify (NAUTILUS_LABEL (label), GTK_JUSTIFY_LEFT); nautilus_label_set_smooth_drop_shadow_offset (NAUTILUS_LABEL (label), 1); - nautilus_label_set_background_mode (NAUTILUS_LABEL (label), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR); + nautilus_label_set_background_mode (NAUTILUS_LABEL (label), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR); nautilus_label_set_solid_background_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_WHITE); nautilus_label_set_smooth_drop_shadow_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_BLUE); nautilus_label_set_text_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_RED); @@ -100,20 +100,20 @@ create_nautilus_label_window (gboolean adjust_wrap_on_resize) int main (int argc, char* argv[]) { - GtkWidget *nautilus_window; - GtkWidget *nautilus_window_adjust; - GtkWidget *gtk_window; + GtkWidget *nautilus_window = NULL; + GtkWidget *nautilus_window_wrapped = NULL; + GtkWidget *gtk_window = NULL; gtk_init (&argc, &argv); gdk_rgb_init (); - nautilus_window = create_nautilus_label_window (FALSE); - nautilus_window_adjust = create_nautilus_label_window (TRUE); - gtk_window = create_gtk_label_window (); + if (0) nautilus_window = create_nautilus_label_window (FALSE); + if (1) nautilus_window_wrapped = create_nautilus_label_window (TRUE); + if (0) gtk_window = create_gtk_label_window (); - gtk_widget_show_all (nautilus_window); - gtk_widget_show_all (nautilus_window_adjust); - gtk_widget_show_all (gtk_window); + if (nautilus_window) gtk_widget_show_all (nautilus_window); + if (nautilus_window_wrapped) gtk_widget_show_all (nautilus_window_wrapped); + if (gtk_window) gtk_widget_show_all (gtk_window); gtk_main (); diff --git a/test/test-nautilus-smooth-text-layout.c b/test/test-nautilus-smooth-text-layout.c new file mode 100644 index 000000000..8fdde2c6a --- /dev/null +++ b/test/test-nautilus-smooth-text-layout.c @@ -0,0 +1,142 @@ + +#include <config.h> + +#include "test.h" + +#include <libnautilus-extensions/nautilus-glyph.h> +#include <libnautilus-extensions/nautilus-smooth-text-layout.h> + +int +main (int argc, char* argv[]) +{ + const guint pixbuf_width = 640; + const guint pixbuf_height = 480; + const gboolean has_alpha = TRUE; + const char *text = NULL; + const int font_size = 25; + + GdkPixbuf *pixbuf; + NautilusScalableFont *font; + NautilusScalableFont *bold_font; + NautilusSmoothTextLayout *smooth_text_layout; + ArtIRect dest; + + + test_init (&argc, &argv); + + font = nautilus_scalable_font_get_default_font (); + g_assert (font != NULL); + + bold_font = nautilus_scalable_font_make_bold (font); + g_assert (bold_font != NULL); + + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha, 8, pixbuf_width, pixbuf_height); + g_assert (pixbuf != NULL); + + test_pixbuf_draw_rectangle_tiled (pixbuf, + "patterns/brushed_metal.png", + -1, -1, -1, -1, + NAUTILUS_OPACITY_FULLY_OPAQUE); + + { + const int border = 50; + dest = nautilus_gdk_pixbuf_intersect (pixbuf, 0, 0, NULL); + dest.x0 += border; + dest.y0 += border; + dest.x1 = 340; + dest.y1 -= border; + } + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + dest.x0, + dest.y0, + dest.x1, + dest.y1, + 0x00FFFF, + 0xFF, + -1); + + text = "This\nis\nmulti\nline\ntext"; + smooth_text_layout = nautilus_smooth_text_layout_new (text, + strlen (text), + font, + font_size, + FALSE); + nautilus_smooth_text_layout_draw_to_pixbuf (smooth_text_layout, + pixbuf, + 0, + 0, + &dest, + GTK_JUSTIFY_LEFT, + FALSE, + 0xFF0000, + 0xff); + gtk_object_unref (GTK_OBJECT (smooth_text_layout)); + + { + const int border = 50; + dest = nautilus_gdk_pixbuf_intersect (pixbuf, 0, 0, NULL); + dest.x0 += 350; + dest.y0 += border; + dest.x1 -= border; + dest.y1 -= border; + } + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + dest.x0, + dest.y0, + dest.x1, + dest.y1, + 0xFFFF00, + 0xFF, + -1); + + text = "This is text that needs t be wrapped to fit and stuff and foo and bar and more stuff."; + smooth_text_layout = nautilus_smooth_text_layout_new (text, + strlen (text), + font, + font_size, + TRUE); + nautilus_smooth_text_layout_set_line_wrap_width (smooth_text_layout, + nautilus_art_irect_get_width (&dest)); + nautilus_smooth_text_layout_draw_to_pixbuf (smooth_text_layout, + pixbuf, + 0, + 0, + &dest, + GTK_JUSTIFY_CENTER, + FALSE, + 0x00FF00, + 0xff); + dest.y0 += nautilus_smooth_text_layout_get_height (smooth_text_layout) + 10; + dest.y1 += nautilus_smooth_text_layout_get_height (smooth_text_layout) + 10; + gtk_object_unref (GTK_OBJECT (smooth_text_layout)); + + smooth_text_layout = nautilus_smooth_text_layout_new (text, + strlen (text), + bold_font, + font_size * 1.5, + TRUE); + nautilus_smooth_text_layout_set_line_wrap_width (smooth_text_layout, + nautilus_art_irect_get_width (&dest) + 2); + + if (1) nautilus_smooth_text_layout_draw_to_pixbuf (smooth_text_layout, + pixbuf, + 1, + 1, + &dest, + GTK_JUSTIFY_CENTER, + TRUE, + 0x00FF00, + 0xff); + gtk_object_unref (GTK_OBJECT (smooth_text_layout)); + + nautilus_debug_show_pixbuf_in_eog (pixbuf); + + gdk_pixbuf_unref (pixbuf); + gtk_object_unref (GTK_OBJECT (font)); + gtk_object_unref (GTK_OBJECT (bold_font)); + test_quit (0); + + return 0; +} |