MacArthur, Ian (SELEX GALILEO, UK) wrote:
>> but instead I will have to type the 
>> fonts as shown here to be able to have them displayed in my 
>> application:
>> http://www.seriss.com/people/erco/fltk/utf8-japanese-songs.cxx
> 
> Yes.

        Or well, you may not have to specify hexidecimal; the reason
        I did that in the example is so that it could be copy/pasted
        from the web browser without the utf8 text getting mangled.

        You can either use the 'actual' utf8 codes in your source
        (but you'd better make sure your text editors never accidentally
        get into ascii mode, or it'll munge all your carefully constructed
        utf8 strings into garbage), or you can do what most apps do, and
        put the utf8 strings into a separate file, and use a message
        library that handles converting the english equivalents (in your
        source code) into the appropriate language files. So in your code
        you might have:

                somewidget.label( lang("This is a test") );

        ..where lang() does a fast lookup in the appropriate language
        file (based on the LOCALE variable, or some such) and prints
        the appropriate utf8 string. gnu has such a lib, but I can't
        remember the name of it at the moment.

>> What I meant is : despite FLuid is not able to display 
>> Chinese fonts, is it possible that the "exe" file can display 
>> the Chinese fonts via the source code, as shown in the 
>> Japanese example ?
> 
> Yes.
> 
>>> What platform are you on?
>> I am working on Linux Debian.
> 
> In that case, you should be able to try out Greg's Japanese example and
> it ought to work for you - the ubuntu and debian distro's use the same
> font packages, I think, and if I recall correctly Greg tested his
> example on ubuntu.
> That should give you confidence that it *can* work and you can proceed
> from there!

        Right, you'll just need to make sure you have the right chinese
        fonts installed, and the trick is figuring out the right Fl::set_font()
        line, which you'll see at the top of main() in that example.
        Assigning FLTK's FL_HELVETICA font to "Kochi Gothic" is appropriate
        for Japanese, but probably not for Chinese.

        I'm not sure how UTF8-aware text editors automatically figure out
        the correct font to use, but AFAIK FLTK does not do this under linux,
        so you kinda have to somehow know and use Fl::set_font() to give FLTK
        a hint in the right direction.

        A possible solution is to include the font name in your language
        file, eg:

myapp-jp.lang
------------------
font:   Kochi Gothic
"This is a test"        "<japanese utf8 equivalent>"
"OK"                    "<japanese utf8 equivalent>"
[etc..]

        ..so you'd have code in your app that would load this on startup
        and on seeing the font: line, would do the Fl::set_font() call with
        that string's value as the argument. This way, if the name of the
        font changes, the end user can tweak the language file as needed.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to