On Fri, 29 Aug 2003, Nick Ing-Simmons wrote: > What I am hoping to do for Tk804 is put some kind of callback to perl > hook in so that when Tk wants a font for a particular character it > can call to perl and perl will give it strong push in a particular direction. > Thus for someone expecting Japanese if asked for a Han character > it will suggest a JIS font. While for someone expecting Chinese it > will suggest a Big5 or gb2312 font as appropriate.
If you want, you can take a look at nsFontMetricsGTK.cpp file of mozilla. You can view that huge file (over 6,000 lines of code) by going to http://lxr.mozilla.org and typing in the file name. Compare that with nsFontMetricsXft.cpp or nsFontMetricsWin.cpp and you'll realize the enormous difficulty of the problem you're trying to tackle. See, for example, <http://bugzilla.mozilla.org/show_bug.cgi?id=152264> Perhaps, your problem is of the limited scope, but still it won't be a very pleasant experience ;-) Can Tk use Xft and fontconfig (http://fontconfig.org) where/when available? Using XLFD-based fonts (15year old) is not such a good idea if you don't have to. > What gets really painful is the Unicode fonts - one has to look at > which characters it has to decide if it > Japanese/Simplified Chinese/Traditional Chinese/Korean or just a grab-bag > of glyphs font designer had to hand. Some Unicode fonts have a signature for 'lang'. For instance, 'misc-fixed-iso10646-1' fonts that come with XFree86 have 'ko' and 'ja' in add-style field. Other fonts have a 'lang signature' in registry-encoding pairs (e.g. ucs2.korean-0) http://bugzilla.mozilla.org/show_bug.cgi?id=215537). As you wrote, most of them don't and it'll make some old system almost to a halt for tens of seconds if you want to open Unicode X11 core fonts and examine which char. is covered. Jungshik