legend chinese word

91 views
Skip to first unread message

Sin

unread,
May 17, 2012, 7:52:21 PM5/17/12
to dislin-users
Hi,all
I want to add legends (chinese word) with dislin(dl_10_vc.rar) in VC
++2008

I have tried
chacod("UTF8");
winfnt("Arial Unicode MS");
name("中文","x");

but i got nothing in legend box. !
Any suggestions will be appreciated!

Armin Rauthe-Schöch

unread,
May 18, 2012, 7:37:29 AM5/18/12
to dislin...@googlegroups.com
Hi,

have a look at the DISLIN manual:
http://www.mps.mpg.de/dislin/kap5.html#section_2

You need at least

disini();

// Initialize legend
legini(buf, ...);

// Create axis system
graf();

// Plot a curve/symbol/..
curve/rlsym/...

// Define corresponding legend line
leglin(buf, "Text for legend", 1);


// Plot legend
legend();

endgrf();


Good luck !
Armin
--
Dr. Armin Rauthe-Schöch
Max Planck Institute for Chemistry
Department of Atmospheric Chemistry
Johann-J.-Becher-Weg 27
D-55128 Mainz / GERMANY
Tel. +49-6131-305-427
Email: armin.raut...@mpic.de

Sin

unread,
May 18, 2012, 10:37:24 AM5/18/12
to dislin-users
thanks, how ahout add a axis title including chinese word(like"中文")?



On 5月18日, 下午7时37分, Armin Rauthe-Schöch <armin.rauthe-scho...@mpic.de>
wrote:
> Email: armin.rauthe-scho...@mpic.de

Sin

unread,
May 18, 2012, 11:16:54 AM5/18/12
to dislin-users
Can you give me an example about legend and axis title (both including
chinese characters) ?
thanks a lot!

On 5月18日, 下午7时37分, Armin Rauthe-Schöch <armin.rauthe-scho...@mpic.de>
wrote:
> Hi,
>
> have a look at the DISLIN manual:http://www.mps.mpg.de/dislin/kap5.html#section_2
>
> You need at least
>
> disini();
>
> // Initialize legend
> legini(buf, ...);
>
> // Create axis system
> graf();
>
> // Plot a curve/symbol/..
> curve/rlsym/...
>
> // Define corresponding legend line
> leglin(buf, "Text for legend", 1);
>
> // Plot legend
> legend();
>
> endgrf();
>
> Good luck !
> Armin
>
> On 18.05.2012 01:52, Sin wrote:
>
> > Hi,all
> >    I want to add legends (chineseword)  with dislin(dl_10_vc.rar) in VC
> > ++2008
>
> > I have tried
> >                chacod("UTF8");
> >                winfnt("Arial Unicode MS");
> >                name("中文","x");
>
> > but i got nothing in legend box. !
> > Any suggestions will be appreciated!
>
> --
> Dr. Armin Rauthe-Schöch
> Max Planck Institute for Chemistry
> Department of Atmospheric Chemistry
> Johann-J.-Becher-Weg 27
> D-55128 Mainz / GERMANY
> Tel. +49-6131-305-427
> Email: armin.rauthe-scho...@mpic.de

Rauthe-Schöch, Armin

unread,
May 19, 2012, 7:55:50 AM5/19/12
to dislin...@googlegroups.com
Hi,

sorry, I am no expert on chinese characters. What I would do first is to make sure that I can plot axis titles and legends correctly with english characters. Once this works, you can play around with "winfnt" and "chacod". Are english characters displaying correctly when using chacod("UTF8") ?

Maybe you need a different winfnt ?

Which font is displaying chinese characters correctly on your computer in a word processor like "wordpad" or "notepad" ?


Good luck!
Armin

________________________________________
From: dislin...@googlegroups.com [dislin...@googlegroups.com] on behalf of Sin [liaoxin...@gmail.com]
Sent: Friday, May 18, 2012 17:16
To: dislin-users
Subject: Re: legend chinese word

"Armin Rauthe-Schöch"

unread,
May 21, 2012, 6:14:00 AM5/21/12
to dislin...@googlegroups.com
Hi,

just a thought:

Did you follow the ideas offered in a thread in August 2011 on this mailing list ?

https://groups.google.com/forum/#!msg/dislin-users/luy7pEbDItw/wEQaWEXo5IAJ

Helmut, maybe your bugfixes from August 2011 got lost in one of the recent DISLIN updates ?


Sorry for not having better ideas to solve your problem,

Armin
Hahn-Meitner-Weg 1
D-55128 Mainz / GERMANY
Tel. +49-6131-305-4123
Fax. +49-6131-305-4009
Email: armin.raut...@mpic.de

Helmut Michels

unread,
May 21, 2012, 7:39:38 AM5/21/12
to dislin-users
Hi,
you have the know the Unicode numbers of the Chinese characters, which
you
want to plot. You can then convert the Unicode numbers to a UTF8
string with
the Dislin routine intutf and pass the UTF8 string to Dislin routines.
Here is
the Dislin legend example using some Chinese characters in titles,
axis titles
and legends. I have used the Chinese characters beginning at Unicode
number
19968. Just for testing.

#include <stdio.h>
#include <math.h>
#include "dislin.h"

static float xray[100], y1ray[100], y2ray[100];

void main ()
{ int n = 100, i, nx, ny, nl;
double fpi = 3.1415926/180., step, x;
char cbuf[180], cstr[80];
int iray[20];

for (i = 0; i < 20; i++)
iray[i] = 19968 + i;
nl = intutf (iray, 20, cstr, 80);

step = 360. / (n - 1);
for (i = 0; i < n; i++)
{ xray[i] = (float) (i * step);
x=xray[i] * fpi;
y1ray[i] = (float) sin (x);
y2ray[i] = (float) cos (x);
}

metafl ("cons");
disini ();
pagera ();
winfnt ("Arial Unicode MS");
chacod ("utf8");

axspos (450, 1800);
axslen (2200, 1200);

name (cstr, "x");
name (cstr, "y");
labdig (-1, "x");
ticks (10, "xy");

titlin (cstr, 1);

graf (0.f, 360.f, 0.f, 90.f, -1.f, 1.f, -1.f, 0.5f);
title ();
xaxgit ();

chncrv ("both");
curve (xray, y1ray, n);
curve (xray, y2ray, n);

legini (cbuf, 2, 80);
nx = nxposn (150.f);
ny = nyposn (0.75f);
legpos (nx, ny);
leglin (cbuf, cstr, 1);
leglin (cbuf, cstr, 2);
legtit ("Legend");
legend (cbuf, 3);
disfin ();
}
----

Best regards,

Helmut

"Armin Rauthe-Schöch"

unread,
May 21, 2012, 9:34:07 AM5/21/12
to dislin...@googlegroups.com
Hi,

just as a round-up of this thread, here is a documentation of how to do this under Linux, in my case OpenSuSE 11.4:

1) Install a Chinese font; OpenSuSE offered "wqy-bitmapfont". Follow the installation instruction for this package to create the "fonts.dir" file and to tell X11 where to find the font files.

2) Then compile the following code. My compile command is simple:
gcc -o test_chinese test_chinese.c -ldislin

Using the source code file "test_chinese.c":

#include <stdio.h>
#include <string.h>
#include <dislin.h>

int main() {
char cstr[80];
int iray[100];
int ni;
int i;

strcpy(cstr, "中文");
printf("\n%s\n\n", cstr);

printf("strlen = %d\n\n", strlen(cstr));
for(i=0;i<strlen(cstr);i++)
printf(" %x\n", (unsigned char)cstr[i]);
printf("\n");

ni = utfint(cstr, &iray[0], 100);
printf("ni = %d\n", ni);
for(i=0;i<ni;i++)
printf(" %u %x\n", iray[i], iray[i]);
printf("\n");

metafl("CONS");
scrmod("REVERS");
window(100, 200, 500, 300);
disini();

x11fnt("-wenquanyi-wenquanyi bitmap song-medium-*-normal-", "-*-*-*-*-iso10646-1");
chacod("utf8");

hname(60);
height(60);

name(cstr, "X");
name("Y-axis", "Y");
titlin(cstr, 3);
labdig(-1, "XY");

graf(0.0, 10.0, 0.0, 2.0, 100.0, 200.0, 100.0, 20.0);
title();
endgrf();

disfin();

return(0);
}


The code shows you the byte-wise content of the UTF8 string with the chinese characters in hexadecimal and then uses "utfint" to calculate and display the UTF8 character number.

You can use the hexadecimal notation to look up the characters at:
http://www.utf8-chartable.de/unicode-utf8-table.pl
They are in the block "U+4E00 ... U+9FFF: CJK Unified Ideographs"

Since my "xterm" terminal and my "joe" editor support the chinese characters, I could directly copy&paste them into a normal C string without the need for the UTF8 character numbers. They are just displayed for completeness in the above code.


Cheers,
Armin
Reply all
Reply to author
Forward
0 new messages