6
#define DEG2RAD(x) ((x)*PI/180.)
8
#define MAX(x,y) ((x) > (y) ? (x) : (y))
9
#define MIN(x,y) ((x) < (y) ? (x) : (y))
11
#define MAX4(x,y,z,w) \
12
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
13
#define MIN4(x,y,z,w) \
14
((MIN((x),(y))) < (MIN((z),(w))) ? (MIN((x),(y))) : (MIN((z),(w))))
16
#define MAXX(x) MAX4(x[0],x[2],x[4],x[6])
17
#define MINX(x) MIN4(x[0],x[2],x[4],x[6])
18
#define MAXY(x) MAX4(x[1],x[3],x[5],x[7])
19
#define MINY(x) MIN4(x[1],x[3],x[5],x[7])
22
main (int argc, char *argv[])
24
#ifndef HAVE_LIBFREETYPE
25
fprintf (stderr, "gd was not compiled with HAVE_LIBFREETYPE defined.\n");
26
fprintf (stderr, "Install the FreeType library, including the\n");
27
fprintf (stderr, "header files. Then edit the gd Makefile, type\n");
28
fprintf (stderr, "make clean, and type make again.\n");
39
char *s = "Hello. ����ɂ��� Qyjpqg,"; /* String to draw. */
41
char *s = "Hello. Qyjpqg,"; /* String to draw. */
49
double angle = DEG2RAD (-90);
53
char *f = "/usr/openwin/lib/locale/ja/X11/fonts/TT/HG-MinchoL.ttf"; /* UNICODE */
54
/* char *f = "/usr/local/lib/fonts/truetype/DynaFont/dfpop1.ttf"; *//* SJIS */
56
char *f = "arial"; /* TrueType font */
59
/* obtain brect so that we can size the image */
60
err = gdImageStringFT ((gdImagePtr) NULL, brect, 0, f, sz, angle, 0, 0, s);
63
fprintf (stderr, err);
67
/* create an image just big enough for the string */
68
x = MAXX (brect) - MINX (brect) + 6;
69
y = MAXY (brect) - MINY (brect) + 6;
71
im = gdImageCreate (x, y);
73
/* gd 2.0: true color images can use freetype too */
74
im = gdImageCreateTrueColor (x, y);
77
/* Background color. gd 2.0: fill the image with it; truecolor
78
images have a black background otherwise. */
80
bg = gdImageColorResolve (im, 255, 255, 255);
81
gdImageFilledRectangle (im, 0, 0, x, y, bg);
82
fg = gdImageColorResolve (im, 0, 0, 0);
84
bg = gdImageColorResolve (im, 0, 0, 0);
85
fg = gdImageColorResolve (im, 255, 255, 255);
88
/* render the string, offset origin to center string */
89
x = 0 - MINX (brect) + 3;
90
y = 0 - MINY (brect) + 3;
92
err = gdImageStringFT (im, NULL, fg, f, sz, angle, x, y, s);
95
fprintf (stderr, err);
98
/* TBB: Write img to test/fttest.png */
99
out = fopen ("test/fttest.png", "wb");
102
fprintf (stderr, "Can't create test/fttest.png\n");
105
gdImagePng (im, out);
107
fprintf (stderr, "Test image written to test/fttest.png\n");
112
#endif /* HAVE_FREETYPE */