1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#include "test.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;
EelScalableFont *font;
EelScalableFont *bold_font;
EelSmoothTextLayout *smooth_text_layout;
ArtIRect dest;
test_init (&argc, &argv);
font = eel_scalable_font_get_default_font ();
g_assert (font != NULL);
bold_font = eel_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,
EEL_OPACITY_FULLY_OPAQUE);
{
const int border = 50;
dest = eel_gdk_pixbuf_intersect (pixbuf, 0, 0, eel_gdk_pixbuf_whole_pixbuf);
dest.x0 += border;
dest.y0 += border;
dest.x1 = 340;
dest.y1 -= border;
}
eel_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 = eel_smooth_text_layout_new (text,
strlen (text),
font,
font_size,
FALSE);
eel_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 = eel_gdk_pixbuf_intersect (pixbuf, 0, 0, eel_gdk_pixbuf_whole_pixbuf);
dest.x0 += 350;
dest.y0 += border;
dest.x1 -= border;
dest.y1 -= border;
}
eel_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 = eel_smooth_text_layout_new (text,
strlen (text),
font,
font_size,
TRUE);
eel_smooth_text_layout_set_line_wrap_width (smooth_text_layout,
eel_art_irect_get_width (dest));
eel_smooth_text_layout_draw_to_pixbuf (smooth_text_layout,
pixbuf,
0,
0,
dest,
GTK_JUSTIFY_CENTER,
FALSE,
0x00FF00,
0xff);
dest.y0 += eel_smooth_text_layout_get_height (smooth_text_layout) + 10;
dest.y1 += eel_smooth_text_layout_get_height (smooth_text_layout) + 10;
gtk_object_unref (GTK_OBJECT (smooth_text_layout));
smooth_text_layout = eel_smooth_text_layout_new (text,
strlen (text),
bold_font,
font_size * 1.5,
TRUE);
eel_smooth_text_layout_set_line_wrap_width (smooth_text_layout,
eel_art_irect_get_width (dest) + 2);
if (1) eel_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));
eel_debug_show_pixbuf_in_external_viewer (pixbuf, "ee");
gdk_pixbuf_unref (pixbuf);
gtk_object_unref (GTK_OBJECT (font));
gtk_object_unref (GTK_OBJECT (bold_font));
return test_quit (EXIT_SUCCESS);
}
|