[cairo] Help / incompatibility with the PDF output?

Tobias Hoffmann lcairo-list at thax.hardliners.org
Thu Nov 30 15:12:36 UTC 2023

Hello Behdad,

from your PDF, e.g.:
% Small pink circle left to the string "Point causing kink..."
1 0 1 RG /a3 gs
10 w
1 J
48 954 m 48 954 l S

% Text "Suggested new contour..."
0 0 0 rg /a0 gs
36 0 0 -36 80 911 Tm
/f-1-0 1 Tf

1 0 1 RG sets the Stroking Color to DeviceRGB pink,
0 0 0 rg sets the Non-Stroking Color to DeviceRGB black.

Evince / XPDF / Chrome PDF Plugin render the text with the non-stroking 
color, other views with the stroking color...

PDF Reference 1.7 Page 391f (5.1.2 Achieving Special Graphical Effects): 
"The color used for painting glyphs is the current color in the graphics 
state: either
the nonstroking color or the stroking color (or both), depending on the 
text rendering mode (see Section 5.2.5, “Text Rendering Mode”) [...] The 
text rendering mode parameter in the graphics state specifies whether 
glyph outlines are to be filled, stroked, used as a clipping boundary, 
or some combination of these effects. (This parameter does not apply to 
Type 3 fonts.)"

But your PDF does use Type 3 Fonts (possibly set up as user fonts on the 
cairo side??), which also use Stroking operations in the glyph 
This seems to catch cairo on the wrong foot, which does not expect text 
to behave differently for Type 3 fonts(?), and thus only sets the fill 
color to black, but not also the stroking color...

The PDF Spec might have changed since 1.7; I might have overseen some 
special concession; there might be a subtle difference in how these Type 
3 fonts are represented in PostScript – but AFAIUI Evince/... seems to 
do it wrong(?).


On 28/11/2023 18:37, Behdad Esfahbod wrote:
> [Resending with an even smaller image to pass the list limit...]
> Hi everyone,
> I'm facing an issue with the PDF output of cairo. Basically, the 
> attached PDF *should* render all text in grayish black. And that's 
> what I see in Evince. But both GitHub's web PDF viewer, and the MacOS 
> PDF viewer, show them *wrong*, like below:
> image2.png
> I've confirmed that HTML and PS output are fine. If I use ps2pdf to 
> convert the PS to PDF, then the PDF also renders fine.
> I *am* using multiple cairo contexts at the same time to draw those 
> things. But trying to use just one context for all didn't seem to 
> change anything.
> Any help / advice is appreciated. PDF attached.
> behdad
> http://behdad.org/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20231130/04bf7eeb/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image2.png
Type: image/png
Size: 35264 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20231130/04bf7eeb/attachment-0001.png>

More information about the cairo mailing list