[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: character by name on the gnome canvas, custom fontencoding

From: Christopher Blizzard
Subject: Re: character by name on the gnome canvas, custom fontencoding
Date: Wed, 16 Jun 2004 10:55:47 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510

Owen Taylor wrote:
On Mon, 2004-06-14 at 16:24, Jan Nieuwenhuizen wrote:

Owen Taylor writes:

Chris Blizzard is working on some API enhancements to Pango to
allow the application to control how this mapping works

I've just noticed that Chris has already checked in quite a hack and
I'm wondering if you could point me to an example or documentation
about how to use this.

"Quite a hack". Why?

API docs are with the check-in. Perhaps Chris has a pointer to an example usage.


I've attached the small test stub that I used to test the code before checking it in. It should shed a little light on how the code paths are supposed to work. At a high level, here's how you would add a custom decoder:

Create an object that derives from the PangoFcDecoder that implements the two class methods: get_charset and get_glyph. More on these callbacks later.

When your application starts up, call pango_fc_font_map_add_decoder_find_func with a callback function you've created. What pango creates new fonts, it will call back into your function and allow you to register one of your custom decoders for that particular font.

So this means the code looks like this:

somewhere during startup:

pango_fc_font_map_add_decoder_find_func (fontmap, mycallback, NULL, NULL);

and the callback:

PangoFcDecoder *
mycallback (FcPattern *pattern, gpointer user_data)
    /* check to see if the pattern matches a font that we want to decode
     * by hand */
    if (is_custom_font(pattern))
        return custom_decoder_new();

and your decoder:

struct _CustomDecoder
    PangoFcDecoder parent_instance;

get_glyph should return a single glyph for a specific code point. Note that there is no support here for doing more than one glyph for a code point. As Owen put it, I think correctly, "write a shaper" if you want to do that.

get_charset should return an FcCharSet * that includes complete coverage information for your font. That might include coverage in the usual unicode ranges, or in the PUA. It doesn't really matter all that much, as long as the code points in the text you want to render matches up to those characters in the coverage information and the font description font name will resolve to the font for which you have the decoder registered.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]