[cairo] PDF text rendering problem

Mindaugas Kavaliauskas dbtopas at dbtopas.lt
Thu May 22 12:11:04 PDT 2008


I have a problem with text rendering to pdf (on WinXP). I use simple
"toy function" cairo_show_text(). IMHO, it is trying to do some
complicated glyph kerning (or position adjustment) in a buggy way.

Below is the sample indicating the problem. Distances between letters
"lis" are to large. Spaces between words are to small. Pairs of letters
"se" are overlapped! "st" is also almost overlapped.

I've uncompressed test1.pdf (using pdftk), and cleared (using simple
text editor) all glyph position adjustments inside pdf's TJ operator.
Now text rendering is much much better! So, I think complicated glyph
position adjustment is buggy. I've tried to hack internals. Glyph
adjustment is done inside function _cairo_pdf_operators_show_glyphs(),
see variable delta. But I've failed to understand idea of font subsets
and fix the problem.

I'm attaching original test1.pdf and uncompressed adjustment-free
test1u.pdf files. If mailing list does not allow attachments, you'll be
able to find these files at http://www.dbtopas.lt/download/cairobug

Thank you for support,

---------- Sample code ----------
cairo_surface_t*      pSurface;
cairo_t*              pCairo;

pSurface = cairo_pdf_surface_create( "test1.pdf", 595, 842 );
pCairo = cairo_create( pSurface );
cairo_set_source_rgb( pCairo, 0, 0, 0 );
cairo_select_font_face( pCairo, "Arial", CAIRO_FONT_SLANT_NORMAL,
                         CAIRO_FONT_WEIGHT_NORMAL );
cairo_set_font_size( pCairo, 10 );
cairo_move_to( pCairo, 20, 100 );
cairo_show_text( pCairo, "seconds is list" );
cairo_destroy( pCairo );
cairo_surface_destroy( pSurface );

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.pdf
Type: application/pdf
Size: 9744 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080522/d9eec996/attachment-0002.pdf 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1u.pdf
Type: application/pdf
Size: 12863 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080522/d9eec996/attachment-0003.pdf 

More information about the cairo mailing list