no output of chinese font

Dear GraphViz-Community,

I tried the following steps regarding the subject, but the chinese glyphs are not rendered.

1) Installed font by fontconfig, i.e. among the results of "fc-list :lang=zh" is:

/usr/share/fonts/adobe/AdobeSongStd_Light.otf: Adobe Song Std,Adobe 宋体 Std,Adobe Song Std L,Adobe 宋体 Std L:style=L,Regular

2) written my dot file: (_grph.dot)

digraph {
rankdir=LR ;
node [shape = record] ;

struct0[label = "Johann | liebt | Marie"] ;
struct0:n0:e -> struct1:n0:w ;
struct0:n1:e -> struct1:n1:w ;
struct0:n2:e -> struct1:n2:w ;
struct1[label = "约翰 | 爱 | 玛丽"] ;
}

3) executed dot on the file:

dot -Nfontname="Adobe Song Std" -v -Tpng _grph.dot -O

4) verified that my font is chosen looking at the verbose output:

fontname: "Adobe Song Std" resolved to: (PangoCairoFcFont) "Adobe Song Std, L" /usr/share/fonts/adobe/AdobeSongStd_Light.otf

- also I can see that the font is used by seeing the latin letters (of the german words) change in between multiple calls to DOT using different chinese fonts

I was wondering if this could have anything to do with my locales, so here is output of this command:
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE=C
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

I really have no clue why this isn't working and would be glad for any input. Thanks alot!

angle-bracket-nX forgotten gv-code :: solution by adding blank

Dear Stephen,

first of all I have to apologize for not taking too much care when posting my GraphViz-Code: angle-brackets have been vanished, so the correct code I try to get working is:

digraph {
rankdir=LR ;
node [shape = record] ;

// struct1[label = "<n0>约翰 | <n1>爱 | <n2>玛丽"] ; -- this will not render
struct0[label = "<n0>Johann | <n1>liebt | <n2>Marie"] ;
struct0:n0:e -> struct1:n0:w ;
struct0:n1:e -> struct1:n1:w ;
struct0:n2:e -> struct1:n2:w ;
struct1[label = "<n0>&#x7ea6;约翰 | <n1> 爱 | <n2> 玛丽"] ;
}

Notice the n0, n1, n2 modifiers in the label which have been omitted from previously posted code.

Also you should be able to run it and reproduce the following behaviour:

1) chinese glyph is not rendered when _no_ blank is in between angle-bracket-nX and the chinese glyph

2) a chinese glyph in entity representation directly adjacent to angle-bracket-nX renders fine

So it seems the tokenizer/parser is just troubled when there's no blank?

René Tobner

Re: no output of chinese font

Sorry to hear about the problems. This seems really difficult to figure out.

I wonder if there is some incompatibility or inconsistency in the font encoding.

Can you try specifying raw UTF-8 in HTML labels?  e.g.
http://htmlpurifier.org/docs/enduser-utf8.html gives an example in Chinese.

Can you try exercising the cairo layer independently from graphviz? For
example in pycairo. I found this: https://heuristically.wordpress.com/2011/01/31/pycairo-hello-world/
and this http://zetcode.com/gfx/pycairo/text/  though you may know a better way.

Stephen North

 

Recent comments