GNOME Bugzilla – Bug 329524
provide pango_font_get_unknown_glyph
Last modified: 2006-02-05 03:09:51 UTC
This is useful, for example in pango_shape, when the shaper fails we can return an array full of unknown_glyphs...
From: Owen Taylor <otaylor@redhat.com> To: Behdad Esfahbod <behdad> Subject: Re: Adding get_unknown_glyph to PangoFont? On Tue, 2006-01-31 at 18:15 -0500, Behdad Esfahbod wrote: > Do you have any objection with adding get_unknown_glyph to > PangoFontClass? Currently only the PangoFcFontClass has this > method, but pango_win32 also implements such a function. It > would use one of the three expansion slots in PangoFontClass. No real objection; one question might be whether it would be easier and simpler to just standardize using the high bit for that ... that would require changes in all the backends but not complex ones. As I think you realize from what you say below, adding something for one of those slots is only compatible if you have a default implementation ... you can't assume that a subclass will know about and implement a newly added virtual function. (Of course, it's only the PANGO_ENABLE_BACKEND level of compatibility anyways, which I've been pretty free to break between 1.x and 1.x+1. Padding in PangoFontClass is not really very important.) > I would like to add get_unknown_glyph to PangoFontClass and a > global function pango_font_get_unknown_glyph which would return 0 > if the class does not implement this feature. I like to use it > in pango_shape when the shaper fails... glyph 0 has a special meaning in Pango - it means "don't draw anything" for all backends. It's not a horrible choice for a fallback for a unknown glyph .. at least it's guaranteed not to crash. But it isn't a particularly good "unknown glyph" fallback for any backend. (That's what bug 73147 was about, more or less... for TrueType fonts the *actual* glyph 0 is a better choice, though hex box drawing is perhaps better still.) You are probably aware of that ... just wanted to emphasize that special meaning. Regards, Owen
Thanks Owen. "0" is what all backends use when they don't support hexbox drawing. I think I'm going to use the high bit for this, but still need to know if a particular backend does handle that. Another way to do it, and to fix bug 73147 at the same time too is: do not add any method. Use the high-bit for unknown glyphs and "don't draw anything". "don't draw anything" will be (guint32)-1, while unknown glyph would be 0x10000000|glyph. If a backend supports hexbox drawing, it would know what to do, if a backend doesn't handle it, it will simply do nothing on any glyph&0x10000000. Moreover, the zero-part of the "draw nothing" glyph is left to get_glyph_extents, such that one can actually have "draw nothing" glyphs with non-zero width, if they set the width explicitly, instead of using get_glyph_extents. All this is really easy to implement. How's that?
Created attachment 58572 [details] [review] patch. This is the patch I'm going to commit after some more review. The FT2 backend needs some more work... going to fix that before commit. After this patch, we can simply assume that PANGO_GLYPH_NULL is the "don't render anything" glyph, and all backends know how to handle PANGO_GLYPH_UNKNOWN_FLAG|wc nicely.
2006-02-02 Behdad Esfahbod <behdad@gnome.org> * modules/arabic/arabic-fc.c, modules/basic/basic-atsui.c, modules/basic/basic-fc.c, modules/basic/basic-win32.c, modules/basic/basic-x.c, modules/hangul/hangul-fc.c, modules/hebrew/hebrew-fc.c, modules/indic/indic-fc.c, modules/khmer/khmer-fc.c, modules/syriac/syriac-fc.c, modules/thai/thai-fc.c, modules/tibetan/tibetan-fc.c, pango/fonts.c, pango/pango-engine-private.h pango/pango-types.h, pango/pangocairo-fcfont.c, pango/pangocairo-font.c, pango/pangocairo-private.h, pango/pangocairo-render.c, pango/pangofc-decoder.c, pango/pangofc-font.c, pango/pangoft2-render.c, pango/pangoft2.c pango/pangowin32.c, pango/pangox.c, pango/pangoxft-font.c pango/pangoxft-private.h, pango/pangoxft-render.c, pango/shape.c: Use PANGO_GLYPH_NULL for when no glyph should be drawn. Use PANGO_GLYPH_UNKNOWN_FLAG for all backends to mark unknown flags. There's no need for pango_font_get_unknown_glyph() anymore, since all backends know how to handle PANGO_GLYPH_UNKNOWN_FLAG gracefully. We may add that in the future however. (fixes bug #73147, closes bug #329524)
I added the PANGO_GET_UNKNOWN_GLYPH(wc) macro.