[rrd-developers] Re[2]: Re: Re[2]: national characters in font

Gabriel Borkowski gabrys at gmail.com
Thu Apr 28 14:10:41 MEST 2005


Hello,

On 28th of April 2005 (10:23:18) Vaclav wrote:

> as I wrote to Tobias last year, we have to have on mind used TTFont
> encoding. I think the right algo would be:

> - what is LC_LANG setting?  -> txt_lang
> - what is TTFont encoding?    -> ttf_enc
> - if txt_lang contain encoding information then convert text from txt_lang
> to ttf_enc encoding
> - use TTFont encoding for next work with text (characters counting, text
> width etc.)

> My knowledge of C is not so good to coding this, so I would be happy if
> somone else can do it.

If you have LC_ALL or LC_CTYPE properly set (in environment, system
wide) - you don't have to deal with it "inside" rrdtool.
But I don't have (LC_ALL, LANG, etc. are set to POSIX) so I had
to add setlocale with "non-dynamic"  'pl_PL'... (UGLY!)

I hate all these problems with charmaps, charsets, locales and i'm no
expert how to deal the best with setting locale if it isn't set
globally or if you want to use different locale than system wide.
Maybe - when configuring rrdtool and/or additional parameter for graphing?


PS.
English isn't my native lang, so... hehh

Greetings,
Gabrys



DIFF1: (ugly setlocale "pl_PL", heh)
--- rrd_graph.c.orig     Mon Apr 25 22:56:40 2005
+++ rrd_graph.c          Thu Apr 28 11:03:39 2005
@@ -2749,6 +2749,7 @@
 #endif
 #ifdef HAVE_SETLOCALE
     setlocale(LC_TIME,"");
+    setlocale(LC_CTYPE,"pl_PL");
 #endif
     im->yorigin=0;
     im->xorigin=0;



DIFF2:
--- rrd_gfx.c.orig      Mon Apr 25 22:56:39 2005
+++ rrd_gfx.c           Thu Apr 28 11:24:21 2005
@@ -373,6 +373,8 @@
   int           error;
   int        gottab = 0;

+  wchar_t*      w_text;
+
   ft_pen.x = 0;   /* start at (0,0) !! */
   ft_pen.y = 0;

@@ -387,6 +389,9 @@
   string->transform.yx = (FT_Fixed)( sin(M_PI*(rotation)/180.0)*0x10000);
   string->transform.yy = (FT_Fixed)( cos(M_PI*(rotation)/180.0)*0x10000);

+  w_text = (wchar_t) calloc (string->count,sizeof(wchar_t));
+  mbstowcs(w_text,text,string->count);
+
   use_kerning = FT_HAS_KERNING(face);
   previous    = 0;
   glyph = string->glyphs;
@@ -414,7 +419,7 @@
     glyph->pos.y = 0;
     glyph->image = NULL;

-    glyph->index = FT_Get_Char_Index( face, letter );
+    glyph->index = FT_Get_Char_Index( face, w_text[n] );

     /* compute glyph origin */
     if ( use_kerning && previous && glyph->index ) {
@@ -480,6 +485,8 @@
       string->width = string->bbox.xMax - string->bbox.xMin;
   }
   string->height = string->bbox.yMax - string->bbox.yMin;
+
+  free(w_text);
   return string;
 }


--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-developers
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-developers mailing list