[cairo] Re: cairo-win32 falls over when asked for the path of
a glyph from a bitmap font
Owen Taylor
otaylor at redhat.com
Mon Apr 9 05:42:47 PDT 2007
On Thu, 2007-04-05 at 15:00 -0400, Behdad Esfahbod wrote:
> On Thu, 2007-04-05 at 13:29 -0400, Carl Worth wrote:
> >
> > I'm baffled. How has cairo-win32 font stuff ever appeared to work in
> > the past?
>
> That's the question I asked before too. The current show_glyphs in
> cairo-win32-font.c seems to just work with win32 surfaces. I have no
> idea how it can draw to an image surface.
Because the relevant code _cairo_win32_scaled_font_show_glyphs() has:
if (_cairo_surface_is_win32 (generic_surface) &&
surface->format == CAIRO_FORMAT_RGB24 &&
op == CAIRO_OPERATOR_OVER &&
_cairo_pattern_is_opaque_solid (pattern)) {
[...]
} else {
} else {
/* Otherwise, we need to draw using software fallbacks. We create a mask
* surface by drawing the the glyphs onto a DIB, black-on-white then
* inverting. GDI outputs gamma-corrected images so inverted black-on-white
* is very different from white-on-black. We favor the more common
* case where the final output is dark-on-light.
*/
cairo_win32_surface_t *t
[...]
}
? Rendering by creating individual glyphs from surfaces and caching them
would not smart thing to do for win32; the operating system already has code
to cache glyphs. So, at that point when glyph_init() was added to cairo,
the contract was that if backend implemented show_glyphs() then it didn't need
to implement that part of glyph_init(). Apparently that's changed...
Obviously that part of glyph_init() could be implemented, but I don't think
it's the right way to go for normal rendering to a surface.
> I still think clearing
> cairo-win32-font.c of cairo-win32-surface stuff is the way to go. A
> font backend's show_glyphs should work for any surface. If it's
> win32-surface-specific, it should go into cairo-win32-surface.c, and
> there is one there already...
And I still want to see _cairo_win32_surface_show_glyphs() deleted. It
makes the code more confusing and causes code duplication. There are no
optimizations there that couldn't have been done in the existing
code path as well...
(See the messages around
http://lists.freedesktop.org/archives/cairo/2006-October/008112.html
for discussion of the change that was made and I dislike.)
The reason that there is "win32 surface stuff" in cairo-win32-font.c is
that win32 fonts can *ONLY* be rendered using ExtTextOutW() to a win32
device context. This is true whether we are:
- Rendering directly to a win32 surface that already exists
- Rendering using a temporary DIB to an image surface
- Create a glyph image for a bitmap font for tracing to an outline
And the abstraction we have for a win32 device context, is a
win32 surface.
- Owen
More information about the cairo
mailing list