[cairo] Equivalence of text_path(); fill(); and show_text()
cworth at cworth.org
Thu Sep 27 08:23:52 PDT 2007
On Thu, 27 Sep 2007 15:54:25 +0100, Chris Wilson wrote:
> It is my understanding that
> cairo_show_text (cr, "cairo");
> cairo_text_path (cr, "cairo");
> cairo_fill (cr);
> should generate identical output.
Not precisely identical, no---just roughly the same.
What happens in the text_path;fill case should be pretty
straightforward, (cairo fills the path). But in the show_text case
there are the following differences (at least):
* Freetype is used for rendering the glyphs, (this is something that
we could easily imagine changing in the future---particularly if
we get a new software polygon rasterizer that's as fast or faster
than what freetype has).
* Glyph images are cached and reused
So, just the fact that there's a different rasterizer being used
(cairo+pixman vs. freetype) will contribute some minor
differences. But the cache actually introduces bigger
differences. With the path, we've currently got a ridiculous amount of
sub-pixel positioning, (16 bits now---looking to move to 8 bits
But with the cached glyphs, we're currently rounding things to integer
positions. This gives less than ideal behavior, (a rotated baseline
will really show the problem, for example). I'd definitely like to
improve this, but one thing to be weighed in the balance is the impact
on the glyph caches. (Independently, I'd like to improve our glyph
cache to have a total global size across all fonts rather than a fixed
maximum of glyphs per scaled font.)
> So I wrote a little test case to demonstrate that they do not.
I wrote the text-rotate test for that exact same reason, (see the
GENERATE_REFERENCE_IMAGE thing inside that uses text_path;fill to
generate the reference image). And I had that as an XFAIL test from
the beginning. I think at some point someone decided that the worst
bugs were fixed and adopted the show_text-generated result as the
reference image and removed the XFAIL designation.
> Whilst constructing the test I stumbled
> across another oddity; namely that show_text() ignores
That definitely sounds like a bug, yes. All drawing operations should
respect the operator.
> So before adding the test case, I'd like some confirmation that the code
> is actually correct and should generate a clear surface.
No. I don't think we ever expect it to be exactly identical as
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20070927/4a7e41b3/attachment.pgp
More information about the cairo