Home > Mobile >  What is the scope of a path in a PDF text object?
What is the scope of a path in a PDF text object?

Time:01-12

I am confused by seemingly contradicting information in the PDF Standard (PDF 32000-1:2008). To simplify, I assume no transparency complications at all, as I am confused enough as is, so alphas are all 1, and I have blending mode normal, and text knockout is not a topic. The issue is text state (more precisely Tr, setting the text rendering mode) and text showing (Tj and friends) and how to reconcile these with the scope of what a SINGLE path is.

So these three things, A, B, and C, seem contradictory:

A. On p.247 (in section 9.3.6, under Table 106), it says (emphasis with caps is mine): "At the end of the text object, the accumulated glyph outlines, if any, shall be combined INTO A SINGLE PATH, treating the individual outlines as subpaths of that path and applying the nonzero winding number rule (...)."

B. According to p.113, Figure 9 ("Graphics Objects"), the allowed operators within a text object include: "Color" (e.g. a change of fill color), "Text state" (so e.g. changing Tr, the text rendering mode), and "Text-showing" (e.g. (Hello) Tj). According to B, the following would then be a valid text object:

enter image description here

C. On p. 246, in the middle of the page it says (emphasis in caps is mine): "In [text rendering] modes that perform both filling and stroking, the effect shall be as if each glyph outline where filled and then stroked in separate operations. If any of the glyphs overlap, the result shall be equivalent to filling and stroking them ONE AT A TIME, producing the appearance of stacked opaque glyphs, rather then first filling and stroking them all at once".

So, according to A, all the glyphs (in my example in B) in "Red hello filled" and "Blue hello filled then stroked" must be considered as A SINGLE path, and the individual glyphs are subpaths... My understanding is that ONE path can be filled with ONE color (I do not mean gradients of course, I am talking about solid colors, like the red and the blue in my example in B), is this not so? And I can only apply 1 text rendering mode to it, right? How does it make sense then that I can change color and text rendering mode WITHIN the text object, which B tells me, if according to A, I am dealing with a SINGLE path? And according to C, even each glpyh is to be considered as a SINGLE path as we paint one after, so on top of, the other, which is exactely the concept of PATH. I can not fill ONE PATH "one at a time"...

So, bottomline question, what is the scope of a path in a PDF text object?

Thank you very much for help!

CodePudding user response:

If I understand the spec correctly, you misinterpret the term "the accumulated glyph outlines". It does not refer to all the outline paths of the shown glyphs and their rendering as you assume. Instead it refers only to the outlines that are added to path for clipping if any!

Thus, all the text is filled and/or stroked immediately in the text object according to the state at the time its text showing instruction is evaluated, one glyph at a time. Consequentially, text drawn by different text showing instructions may have different colors and different other characteristics and later glyphs may overlap earlier ones.

Eventually, at the end of a text object all the outlines of the text drawn with text rendering mode 4..7 in the object - if any - are combined in that single path A talks about and used to intersect the previous clipping path.

  • Related