After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 329524 - provide pango_font_get_unknown_glyph
provide pango_font_get_unknown_glyph
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2006-02-01 21:35 UTC by Behdad Esfahbod
Modified: 2006-02-05 03:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch. (31.02 KB, patch)
2006-02-02 09:38 UTC, Behdad Esfahbod
none Details | Review

Description Behdad Esfahbod 2006-02-01 21:35:51 UTC
This is useful, for example in pango_shape, when the shaper fails we can return an array full of unknown_glyphs...
Comment 1 Behdad Esfahbod 2006-02-02 05:27:41 UTC
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
Comment 2 Behdad Esfahbod 2006-02-02 05:40:38 UTC
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?
Comment 3 Behdad Esfahbod 2006-02-02 09:38:26 UTC
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.
Comment 4 Behdad Esfahbod 2006-02-02 10:53:51 UTC
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)
Comment 5 Behdad Esfahbod 2006-02-05 03:09:51 UTC
I added the PANGO_GET_UNKNOWN_GLYPH(wc) macro.