[cairo] A (LONG) Pango/Cairo Question

Behdad Esfahbod behdad at behdad.org
Thu Aug 28 08:16:22 PDT 2008


Jeremy Moles wrote:
> I'm attaching a file test.c (and accompanying Makefile) that I believe
> demonstrates a bug in either Cairo or my own code.
> 
> The goal of this application is to use Pangocairo to create an OpenGL
> texture that caches glyphs with one pixel of space both horizontally and
> vertically between each rendered item. When there are no transforms
> present on the current Cairo context, everything appears to work exactly
> as expected. However, when the origin is "flipped" to the bottom left
> (via cairo_scale(), cairo_translate()), the glyphs are rendered subtly
> different and overlap by one pixel or so, depending on font size.
> 
> In the second (failed) case, you will need to rotate the image in a
> program like gimp and compare it to the original. I have also attached a
> PNG image demonstrating this for convenience. Notice that in the first
> "row" of text, each glyph has one pixel of space between it. In the
> second "row" you'll notice that some glyphs are rendered different
> (you'll need a keen eye for this :)) and that a few of them bleed
> together, despite being subject to the same translations that work in
> the normal mode.

Basically you are assuming that the mirrored font has the same extents as of
the original one.  As your test case shows, this does not hold currently.
This is FreeType's fault.  Most probably bugs.  At some point I'm going to fix
this by moving rasterization to cairo.

Back to your problem, I added a simple scale to the font matrix and am getting
the effect you were trying to achieve quite easily.  Modified code attached.


behdad


-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 5541 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080828/e19dd01a/attachment.c 


More information about the cairo mailing list