~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to gd/fontsizetest.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "gd.h"
 
2
 
 
3
void dosizes(gdImagePtr im, int color, char *fontfile,
 
4
             int x, int y, const char *string)
 
5
{
 
6
  int brect[8];
 
7
  double curang = 0.0;
 
8
  char *cp;
 
9
  int cursize;
 
10
  char buf[60];
 
11
 
 
12
  for (cursize = 1; cursize <= 20; cursize++) 
 
13
  {
 
14
      sprintf(buf,"%d: %s", cursize, string);
 
15
 
 
16
  /* The case of newlines is taken care of in the gdImageStringTTF call */
 
17
#if defined(OLDER_GD)
 
18
      cp = gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y, buf);
 
19
#else
 
20
      cp = gdImageStringFT  (im, brect, color, fontfile, cursize, curang, x, y, buf);
 
21
#endif
 
22
    if (cp)
 
23
      fprintf(stderr, "%s\n", cp);
 
24
    y += cursize + 4;
 
25
 
 
26
/* render the same fontsize with antialiasing turned off */
 
27
#if defined(OLDER_GD)
 
28
      cp = gdImageStringTTF (im, brect, 0-color, fontfile, cursize, curang, x, y, buf);
 
29
#else
 
30
      cp = gdImageStringFT  (im, brect, 0-color, fontfile, cursize, curang, x, y, buf);
 
31
#endif
 
32
    if (cp)
 
33
      fprintf(stderr, "%s\n", cp);
 
34
    y += cursize + 4;
 
35
  }
 
36
}
 
37
 
 
38
void dotest(char *font, 
 
39
            int w, int h, char *string,
 
40
            const char *filename)
 
41
{
 
42
  gdImagePtr im;
 
43
  FILE *out;
 
44
  int bg;
 
45
  int fc;
 
46
  int lc;
 
47
 
 
48
  im = gdImageCreate(w, h);
 
49
  bg = gdImageColorAllocate(im, 0, 0, 0);
 
50
 
 
51
  gdImageFilledRectangle(im, 1, 1, w-1, h-1, bg);
 
52
  
 
53
  fc = gdImageColorAllocate(im, 255, 192, 192);
 
54
  lc = gdImageColorAllocate(im, 192, 255, 255);
 
55
 
 
56
  out = fopen(filename, "wb");
 
57
 
 
58
  dosizes(im, fc, font, 20, 20, string);
 
59
 
 
60
  gdImagePng(im, out);
 
61
  fclose(out);
 
62
}
 
63
 
 
64
int main(int argc, char **argv)
 
65
{
 
66
 
 
67
  dotest("times",     400, 600, ".....Hello, there!", "fontsizetest1.png");
 
68
  dotest("cour",      400, 600, ".....Hello, there!", "fontsizetest2.png");
 
69
  dotest("arial",     400, 600, ".....Hello, there!", "fontsizetest3.png");
 
70
  dotest("verdana",   400, 600, ".....Hello, there!", "fontsizetest4.png");
 
71
 
 
72
  return 0;
 
73
}