Re: Unix font warning -- CJK-related...


Subject: Re: Unix font warning -- CJK-related...
From: Anthony Fok (anthony@thizlinux.com)
Date: Tue Dec 11 2001 - 20:28:20 CST


On Tue, Dec 11, 2001 at 10:22:54AM -0000, Tomas Frydrych wrote:
> The problem with the patch is that it merely bypasses the warning,
> which is there for a reason -- it is to alert the user to the fact that
> some manual ajustment of the system might be required before
> AW is usable.

That sounds reasonable from the point of view of developers and experienced
users, but not for new Linux users, especially when the CJK TrueType fonts
are already in X fontpaths (pre-configured by Linux distribution vendors/
developers), and AbiWord works perfectly, and yet it keeps popping up that
warning message on startup.

AbiWord 0.9.4.1 didn't such warning message. This warning message has
puzzled me ever since 0.9.5 came out. It wasn't apparent from the
warning message why exact AbiWord is complaining -- it just says it
couldn't add its fontpaths to X... didn't explain why or which paths --
until I recompiled AbiWord with --enable-debug when it showed it tries
to add /usr/share/AbiSuite/fonts/zh-TW to the X fontpath... (I should
have thought of it earlier... AbiWord's debug messages are awesome!)

> Even under CJK locale AW still needs the fonts to
> be in the X font path, since it uses Gtk to do the rendering.

Yes: the situation on Thiz Linux and just about all other Linux
distributions are as follows:

  * The actual TrueType font files (e.g. bsmi00lp.ttf) are placed in:
        /usr/share/fonts/ttf/ (or other directories under /usr/share/fonts)

  * These *.ttf files are symlinked in /usr/X11R6/lib/X11/fonts/TrueType
    (or /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType on Debian)
    with a fonts.dir that is read by XFree86.

  * /usr/share/AbiSuite/fonts/zh-TW contains only the file "fonts.dir"
    which is used by AbiWord exclusively to obtain CJK PostScript and XLFD
    names.

> So if the non-standard format of the fonts.dir file means that we are
> never able to add the CJK directories to the font path automatically,
> then that warning needs to be always displayed when CJK locale is
> detected in the process of setting the path, not to be always
> disabled. When the user has the fonts in the font path, then they can
> turn off the font-path modification in the Preferences.

Again, Linux end-users (especially newbies), their immediate response
would be: "Hey, something is wrong with my system or with AbiWord!"
especially if they have used pre-0.9.5 which never had this warning.

I realize my patch is more of a kludge and not a "correct" solution,
it solves an immediate problem for Thiz Linux users, most of whom are
not developers. Nevertheless, I agree that a more "correct" fix is
needed.

Instead of adding locale subdir fontpaths to X indiscriminately, I
propose the following, in pseudocode:
(e.g. locale = zh_TW.Big5, hence subdirs = zh, zh-TW.Big5, zh-TW, Big5)

  foreach subdir in (subdirs) {
     if ( is_dir(subdir) && is_readable(subdir/fonts.dir) ) {
        read fonts.dir;

        if (second_line_contains_comma) {

            // CJK-specific fonts.dir, not suitable for X
            add this path to AbiWord;

            // Optional detailed testing: test whether each XLFD in
            // fonts.dir is valid. Alternatively, just check
            // the first entry instead of the whole file.
            for each line in fonts.dir {
                if (firstline) { skip; /* or keep the fontcount */ }
                grep the XLFD;
                check if X knows this XLFD or not;
                // I don't know the exact X function, but akin to
                // xlsfonts -fn 'xlfd_name'
                if X knows no such XLFD {
                    Warn user this XLFD (and maybe others) is unavailable,
                        and ask user to fix font settings;
                    break;
                }
            }
        } else {
            add this fontpath to X, and warn if unsuccessful;
            // i.e. the current behaviour
        }
     }
  }
            
What do you think? :-)

Cheers,

Anthony

-- 
Anthony Fok Tung-Ling
ThizLinux Laboratory   <anthony@thizlinux.com> http://www.thizlinux.com/
Debian Chinese Project <foka@debian.org>       http://www.debian.org/intl/zh/
Come visit Our Lady of Victory Camp!           http://www.olvc.ab.ca/



This archive was generated by hypermail 2b25 : Tue Dec 11 2001 - 20:23:01 CST