]> git.pld-linux.org Git - packages/webalizer.git/blob - 18_ttf_support_throught_libgd.diff
- rel 2; add gettext back (from debian); someone could merge it to master
[packages/webalizer.git] / 18_ttf_support_throught_libgd.diff
1 From: Tatsuki Sugiura <sugi@nemui.org>
2 Subject: make possible to use TrueTypeFont throught libgd
3
4 Origin: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=201723
5
6 ####################
7 # graph label characters will be broken under non-C locale
8 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=201723
9 # From: Tatsuki Sugiura <sugi@nemui.org>
10 #
11 # GD's built-in font has no Japanese Kanji and any other multi-byte
12 # characters. Graph labels can't be displayed correctly under some
13 # locales which has these characters.
14 # This patch make possible to use TrueTypeFont throught libgd
15 # function.
16
17 Index: webalizer/README.FIRST
18 ===================================================================
19 --- webalizer.orig/README.FIRST 2011-01-08 20:59:30.000000000 +0100
20 +++ webalizer/README.FIRST      2011-01-08 20:59:49.000000000 +0100
21 @@ -28,3 +28,18 @@
22  # with the options you prefer, build it, install it and use it.
23  ##################
24  
25 +###################  SUMMARY 18_ttf_support_throught_libgd  ##########################
26 +
27 +##################
28 +# TrueTypeFont makes possible to replace GD built-in font by
29 +# specified TrueTypeFont.
30 +# The value can be '/path/to/your/true_type_font.file' or empty.
31 +# If value is empty(or commented out), GD built-in font will be used.
32 +# The default is empty.
33 +# (Supplement for Japanese:
34 +#  Under EUC-JP locale, TTF file must be specified which has *Windows
35 +#  Shift-JIS encoding*. This limitation is derived from libgd.
36 +#  e.g. you can use "/usr/share/fonts/truetype/X-TT/wadalab-gothic.ttf"
37 +#  provided by ttf-xtt-wadalab-gothic package)
38 +#TrueTypeFont
39 +##################
40 Index: webalizer/configure.in
41 ===================================================================
42 --- webalizer.orig/configure.in 2011-01-08 20:36:44.000000000 +0100
43 +++ webalizer/configure.in      2011-01-08 20:59:49.000000000 +0100
44 @@ -140,6 +140,7 @@
45  AC_CHECK_LIB(gd, main, LIBGD="yes"; LIBS="-lgd ${LIBS}")
46  if test "${LIBGD}" = "yes"; then
47    AC_CHECK_LIB(gd, gdImagePng, LIBGD="yes", LIBGD="no")
48 +  AC_CHECK_LIB(gd, gdImageStringFT, LIBS="-lgd ${LIBS}"; HAVE_LIBGD_TTF="yes", HAVE_LIBGD_TTF="")
49    if test "${LIBGD}" = "no"; then
50      AC_MSG_ERROR(Old version of libgd found.. please upgrade!)
51    fi
52 @@ -147,6 +148,10 @@
53    AC_MSG_ERROR(gd library not found.. please install libgd)
54  fi
55  
56 +if test "$HAVE_LIBGD_TTF" = "yes" ;then
57 + AC_DEFINE(HAVE_LIBGD_TTF)
58 +fi
59 +
60  AC_CHECK_HEADER(gd.h, HDR="yes", HDR="no")
61  if test "${HDR}" = "no"; then
62    AC_MSG_ERROR(gd.h header not found.. please install)
63 Index: webalizer/graphs.c
64 ===================================================================
65 --- webalizer.orig/graphs.c     2011-01-08 20:59:42.000000000 +0100
66 +++ webalizer/graphs.c  2011-01-08 20:59:49.000000000 +0100
67 @@ -1025,6 +1025,48 @@
68     return;
69  }
70  
71 +#ifdef HAVE_LIBGD_TTF
72 +/*
73 + * Simple wrapper of gdImageString() for TrueType fonts
74 + *
75 + * To support Japanese (and other multi-byte characters), GD 1.7
76 + * or later that supports kanji(JISX208) TTF has been required.
77 + * So, we must use TrueType fonts instead of gd built-in
78 + * bitmap fonts.
79 + * 
80 + * Original of function written by <yasu@on.cs.keio.ac.jp>.
81 + * And modified by Tatsuki Sugiura <sugi@nemui.org>
82 + * 
83 + */
84 +static void gdImageStringWrapper(gdImagePtr im,  gdFontPtr f,
85 +                                int x, int y,
86 +                                unsigned char *s, int color, double rad)
87 +{
88 +   double ptsize = 11.0;
89 +   int    brect[8];
90 +   extern char *ttf_file;
91 +
92 +   if (ttf_file == NULL || strcmp(ttf_file, "") == 0) {
93 +      if (fabs(rad) < PI/4.0)
94 +        gdImageString(im, f, x, y, s, color);
95 +      else
96 +        gdImageStringUp(im, f, x, y, s, color);
97 +   } else {
98 +      if (f == gdFontSmall)
99 +         ptsize = 9.0;
100 +
101 +      gdImageStringFT(im, brect, color, ttf_file, ptsize, rad, 
102 +                     x + (int)(ptsize*sin(rad)),
103 +                     y + (int)(ptsize*cos(rad)), s);
104 +   }
105 +}
106 +
107 +#define gdImageString(im, f, x, y, s, color) \
108 +        gdImageStringWrapper(im, f, x, y, s, color, 0.0)
109 +#define gdImageStringUp(im, f, x, y, s, color) \
110 +       gdImageStringWrapper(im, f, x, y, s, color, PI/2.0)
111 +#endif /* HAVE_LIBGD_TTF */
112 +
113  /****************************************************************/
114  /*                                                              */
115  /* ASHEX2INT - ASCII HEX TO INT CONVERTER                       */
116 Index: webalizer/sample.conf
117 ===================================================================
118 --- webalizer.orig/sample.conf  2011-01-08 20:59:48.000000000 +0100
119 +++ webalizer/sample.conf       2011-01-08 20:59:49.000000000 +0100
120 @@ -792,4 +792,17 @@
121  #PieColor3     ff00ff
122  #PieColor4     ffc080
123  
124 +# TrueTypeFont makes possible to replace GD built-in font by
125 +# specified TrueTypeFont.
126 +# The value can be '/path/to/your/true_type_font.file' or empty.
127 +# If value is empty(or commented out), GD built-in font will be used.
128 +# The default is empty.
129 +# (Supplement for Japanese:
130 +#  Under EUC-JP locale, TTF file must be specified which has *Windows
131 +#  Shift-JIS encoding*. This limitation is derived from libgd.
132 +#  e.g. you can use "/usr/share/fonts/truetype/X-TT/wadalab-gothic.ttf"
133 +#  provided by ttf-xtt-wadalab-gothic package)
134 +
135 +#TrueTypeFont
136 +
137  # End of configuration file...  Have a nice day!
138 Index: webalizer/webalizer.c
139 ===================================================================
140 --- webalizer.orig/webalizer.c  2011-01-08 20:59:42.000000000 +0100
141 +++ webalizer/webalizer.c       2011-01-08 20:59:49.000000000 +0100
142 @@ -175,6 +175,10 @@
143  GeoIP   *geo_fp      = NULL;                  /* GeoIP database handle    */
144  #endif
145  
146 +#ifdef HAVE_LIBGD_TTF
147 +char    *ttf_file    = "";                    /* truetype font file       */
148 +#endif
149 +
150  int     ntop_sites   = 30;                    /* top n sites to display   */
151  int     ntop_sitesK  = 10;                    /* top n sites (by kbytes)  */
152  int     ntop_urls    = 30;                    /* top n url's to display   */
153 @@ -1668,7 +1672,10 @@
154                       "SearchCaseI",       /* srch str case insensitive  120 */
155                      "InOutkB",           /* logio (0=no,1=yes,2=auto)  121 */
156                       "ColorIKbyte",       /* IKbyte Color (def=0080ff)  122 */
157 -                     "ColorOKbyte"        /* OKbyte Color (def=00e000)  123 */
158 +                     "ColorOKbyte",       /* OKbyte Color (def=00e000)  123 */
159 +#ifdef HAVE_LIBGD_TTF
160 +                     "TrueTypeFont"       /* TrueType Font file         124 */
161 +#endif
162                     };
163  
164     FILE *fp;
165 @@ -1908,6 +1915,9 @@
166                      (tolower(value[0])=='y')?1:2;  break; /* InOutkB        */
167          case 122: strncpy(ikbyte_color+1,value,6); break; /* ColorIKbyte    */
168          case 123: strncpy(okbyte_color+1,value,6); break; /* ColorOKbyte    */
169 +#ifdef HAVE_LIBGD_TTF
170 +        case 124: ttf_file=save_opt(value);        break; /* TrueType font  */
171 +#endif
172        }
173     }
174     fclose(fp);
This page took 0.139277 seconds and 3 git commands to generate.