Re: pango_layout_get_pixel_extents crash on Win32



On 9/6/07, David Nečas (Yeti) <yeti physics muni cz> wrote:
> On Thu, Sep 06, 2007 at 05:12:05PM -0400, Owen Taylor wrote:
> >
> >  - Your code assumes that the fonts for the Pango backend used on GTK+
> > are the same as those for the FT2 backend ... true on X11, where both
> > are using fontconfig. False on windows, where GTK+ uses the native
> > font catalog and font system. Now, of course, using a font description
> > that doesn't point to a known font shouldn't *crash*,
>
> Should't I get either the requested font or a replacement
> (possibly being awarded with a Pango warning)?

If there are any fonts at all, yes, you'll get a replacement. The
replacement will have no apparent relationship to what was requested,
other than size, and maybe bold/italic.

Dealing with no fonts at all is hard; Behdad did a bunch of work to
avoid crashing in that case a year or two ago, but it's possible that
those fixes haven't reached your users yet if you are trying to work
with old versions of GTK+. Or they may not be complete in the case of
the FT2 backend, which isn't a primary target for testing.

> > but it's quite
> > possible that your users have *no fonts at all* configured for the FT2
> > backend, and at that point, it's more likely that there might be a
> > crash.
> >
> >  - Using FT2 on Windows is generally a poor idea.
>
> Hm, I thought Gimp had been using FT2 so it could not be so
> bad -- but maybe I was mistaken.  Anyway, if it's possible
> that there are no fonts at all configured for FT2 then
> obviously I cannot use it, at least not on Win32.

*IF* the user has a working install of the GIMP using FT2 *AND* your
application is using the same install of GTK+ as the GIMP, then it's
likely that the user will have a working configuration for fontconfig.
Neither of those is at all a given. Once you drag fontconfig into the
system, you have a second font system involved, and unlike the native
font system, there is no guarantee at all that it has been configured
correctly. (It's also badly inefficient to have two copies of the font
database in memory.)

> >  To render to an
> > offscreen in-memory image, use cairo. With pango/cairo, you can render
> > to offscreen images using the exact same font catalog that GTK+ is
> > using, rather than dragging in an nonnative, innappropriate
> > dependencies (FreeType/fontconfig).
>
> I see.  The trouble is my application has still Gtk+ 2.6 as
> the lowest supported version (and changing requirements in
> a minor stable version is a bit unfortunate).
>
> Does any safe off-screen text rendering method exist that
> does not require Cairo?  I do not need much features, simple
> strings with some default font would be sufficient.
>
> Since I need off-screen text rendering only in a few places
> I could also branch the code according to the platform, but
> I'd rather avoid this too if there is another way...

The only other the way I can think of doing offscreen rendering that
uses the native font system would be to use Win32 GDI calls and
pango_win32_* calls to render the layout to a Device Context (DC) that
targets an offscreen image (a DIB).

Basically, if you want to work on old versions of GTK+, you'll get old
APIs and old bugs.

- Owen


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