Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent conditions for Type 3 font resources #128

Closed
t-merz opened this issue Nov 1, 2021 · 36 comments
Closed

Inconsistent conditions for Type 3 font resources #128

t-merz opened this issue Nov 1, 2021 · 36 comments
Assignees
Labels
ISO approved Resolved issue approved by ISO

Comments

@t-merz
Copy link

t-merz commented Nov 1, 2021

Table 110 "Entries in a Type 3 font dictionary" states about the /Resources entry: "Optional but should be used".

On the other hand, 7.8.3 "Resource dictionaries" states in the second bulleted item

"Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary specifying all the resources used by all the content streams in the CharProcs dictionary of a Type 3 font."

Here "shall" contradicts "should" in Table 110.

Possible solutions (given inconsistent conditions it's hard to decide compatibility issues):

  • Might be considered incompatible: change "Optional but should be used" to "Required" for Resources in Table 110.
  • Weaker, but compatible: change "shall" to "should" in 7.8.3.

A better approach would be to require the Resources dictionary only if there actually are resources (i.e. don't require empty /Resources), but this would further complicate the compatibility issue.

A minor wording problem in 7.8.3 is that a content stream shall specify something in another location, which is weird phrasing for "if dictionary A is present, dictionary B shall contain X" (the content stream doesn't contain the resources, but actually the font does). Actually, since a Type 3 font without "Content streams that define the glyph descriptions" doesn't make sense this boils down to "/Resources is required in a Type 3 font dict", a statement which is redundant with the (corrected) entry in Table 110. The relevant information is that the Resources dictionary collects the resources in all CharProcs.

@t-merz t-merz added the bug Something isn't correct label Nov 1, 2021
@petervwyatt
Copy link
Member

What did you mean by "... further complicate the compatibility issue"?

From my memory of past ISO discussions, I think your first bullet option is what is now generally preferred.

And maybe a half-solution to the minor wording problem is that a cross-reference to Table 110 be added to the 2nd bullet in 7.8.3:

Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary (see Table 110) specifying all the resources used by all the content streams in the CharProcs dictionary of a Type 3 font.

The second half of this sentence is a factual statement related to requirements in 9.6.4 so I don't see any issue.

@t-merz
Copy link
Author

t-merz commented Nov 2, 2021

What did you mean by "... further complicate the compatibility issue"?

It will be impossible to maintain full compatibility since the previous text was inconsistent. Changing to "Required" is technically sub-optimal since it forces you to also emit an empty resource dictionary. What I meant is that an improved condition "required if non-empty" would deviate from the previous text even more.

Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary (see Table 110) specifying all the resources used by all the content streams in the CharProcs dictionary of a Type 3 font.

The second half of this sentence is a factual statement related to requirements in 9.6.4 so I don't see any issue.

I find it strange wording that "content streams shall include in a font dictionary", but that's not a technical issue.

@petervwyatt
Copy link
Member

OK - thanks. I understand what you mean and I agree it is very unclear the "resource inheritance" locations used by Type3 CharProcs.

Table 110 also states "If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used." so there is a lot of contradiction between Table 110 and 7.8.3!

We first need to decide what the desired behaviour is:

  • can individual Type3 CharProc content streams have Resources? Do they get used? I cannot see anywhere else that excludes this and they are otherwise just content streams...
  • are Type3 CharProc resources limited to Type 3 Font dictionary Resources only - and any resources on each CharProc content stream is ignored (implied by current 7.8.3 wording)?
  • are Type3 CharProc resources are limited to CharProc content stream Resources, then the Type 3 Font dictionary Resources then the page but only if Type 3 Font dictionary Resources is not present? These last 2 steps are implied by Table 110 and the last bullet in 7.8.3 for legacy PDFs.

The third option needs to avoid accidental implications that an empty Type 3 Font dictionary Resources is always needed (but this would be valid syntax if an author wanted to stop the page Resources lookup).

Comments? Opinions? Other options?

@lrosenthol
Copy link
Contributor

can individual Type3 CharProc content streams have Resources? Do they get used? I cannot see anywhere else that excludes this and they are otherwise just content streams...

Yes they can and yes they are used.

are Type3 CharProc resources limited to Type 3 Font dictionary Resources only - and any resources on each CharProc content stream is ignored (implied by current 7.8.3 wording)?

Not according to a well known implementation. It supports the model described next.

are Type3 CharProc resources are limited to CharProc content stream Resources, then the Type 3 Font dictionary Resources then the page but only if Type 3 Font dictionary Resources is not present? These last 2 steps are implied by Table 110 and the last bullet in 7.8.3 for legacy PDFs.

Yes, this is what a well known implementation does. (content stream then either font or page, depending)

@petervwyatt
Copy link
Member

Based on feedback and discussion at PDF TWG, the current "shall" wording of the 2nd bullet of 7.8.3 "Resource dictionaries" is far too strict. But just replacing with "should" is also not correct, since the CharProcs content streams can have their own local Resource dictionary.

So to solve this issue, proposal is to:

  1. completely replace this 2nd bullet in clause 7.8.3 with a full description of how resources can be associated with Type3 CharProcs content streams and the order in which various resources are examined.
  2. Table 110, Resource - strike "but should be used" from the parenthetical. Resources here are just "(Optional; PDF 1.2)"
  3. Clause 9.6.4, bullet (d) (below Table 110) also needs a complete rewrite. Rather than duplicate wording make this an explicit back-reference to the newly reworded bullet in clause 7.8.3:

If any glyph descriptions refer to named resources they shall be looked up according to requirements described in clause 7.8.3 "Resource dictionaries".

New wording for 7.8.3 2nd bullet is T.B.D.

@petervwyatt
Copy link
Member

Actually the sentence "A list of the named resources, such as fonts and images, required by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries")." in Table 110 also needs to be clarified, as the word "required" can easily be misinterpreted - it is not necessarily all Resources.

@petervwyatt
Copy link
Member

I'm also now struggling to find where it is explicitly stated that content streams (in general) can all have a Resources entry...

It seems to be that this is normally done in the Table that defines the type of dictionary, such as Form XObjects, Annotations, Shadings, etc. or by reference by stating that something is a Form XObject (for example). But AFAICT there is no equivalent for Type3 CharProcs.

Table 110 CharProcs just says "A dictionary in which each key shall be a glyph name and the value associated with that key shall be a content stream that constructs and paints the glyph for that character." but there is no table of permitted keys for "general" content streams - you would expect that to be in clause 7.8.2. If Table 110 was altered to say "Form XObject" instead then it might resolve things... but does a Form XObject provide too much extra that is then even more confusing??? (e.g. StructParent, OC, etc).

So if we only want to permit Resources entries on CharProc content streams what should we do???
Can CharProcs have other Form XObject features (e.g. OC)??

Help requested!

@petervwyatt petervwyatt added help wanted Extra attention is needed question Further information is requested labels Nov 13, 2021
@MPBailey
Copy link

@petervwyatt: The bit you’re looking for is the 3rd bullet under 7.8.3:

“For other content streams, a PDF writer shall include a Resources entry in the stream's dictionary specifying the resource dictionary which contains all the resources used by that content stream. This shall apply to content streams that define form XObjects, patterns, and annotation appearances.”

Although that is a bit of a mixed message as to whether it applies to anything other than those three cases. Since pages and CharProcs are covered by the two previous bullets, I’m coming up short on other places it might be relevant.

Oh dear; whenever you poke around in this stuff you find more loose ends.

The discussion of needing to use the first Resources dictionary found in walking up the object tree, and not inheriting individual elements within a Resources dictionary separately, is specifically applied only to page objects (7.7.3.4). We’ll have to state that the same monolithic inheritance rules apply to CharProcs etc. I’d suggest adjusting the heading for 7.7.3.4 so it’s no longer page-specific and extending the text to cover all Resources inheritance, through Forms, fonts etc.

While we’re on the subject, the statement of Resources inheritance through a chain of Form XObjects in the Resources row of Table 93 is a bit weak. If it’s PDF 1.1 or earlier then the requirements are clear. But if it’s PDF 1.2 or later, the form may be independent, and if so there is no inheritance of Resources ("the Resources dict shall contain …"). The implication is that the Form is not independent if it does not contain a Resources entry, but the text says nothing about what should happen then. I’ve always assumed that it should inherit from any containing Forms, and eventually up to the Page, but I can’t see that stated anywhere. Cover this in 7.7.3.4.

If I’m being picky, the Resources row of Table 93 (Form XObjects) also says “In an independent form XObject, the resource dictionary of the form XObject […] shall contain all named resources used by the form XObject.” That pretty much implies that any resources used by child XObjects and T3 fonts also need to be in that Form Resources dictionary, which I’m pretty sure was not the intent. Perhaps “In an independent form XObject, the resource dictionary of the form XObject […] shall contain all named resources used directly by the form Xobject and its content stream.”? That may not be worth the effort, though.

And why on earth would the Resources inheritance for a CharProc in a T3 font used inside a Form XObject nested inside a 2nd Form go: CharProc, font dictionary, page? Surely it should search through the chain of forms?

I note that Resources in patterns explicitly do not inherit. Makes things much simpler 😊

@petervwyatt
Copy link
Member

PDF TWG would like to progress this during the next meeting...

@MPBailey
Copy link

MPBailey commented Feb 15, 2022

Putting this out as a straw man to argue over. I’m aware that some of this may change more wording than people are comfortable with, but it seemed a good starting point.

These proposals are pretty much in order through the document rather than grouping by subject matter; I hope it’s still understandable.

After discussion on this thread it seems that the consensus is converging on requiring a Resources dictionary in a Type 3 font. To do that, and to respond to Thomas’ comments on strange constructions, I propose replacing the 2nd bullet in 7.8.3 with the following, adopting wording based on the previous bullet (for resources on Page objects):

  • For a content stream that defines a glyph description of a Type 3 font the resource dictionary shall be designated by a Resources entry in the Type 3 font dictionary that shall specify all the resources used by all the content streams in the CharProcs dictionary of the font.

There’s also been a discussion around whether Resources is allowed in each CharProcs stream. I haven’t found anywhere in the current text that says what you’d do with it if it were present (as Peter says, any generic statements about Resources in arbitrary streams are pretty vague, especially if the list at the end of the 3rd bullet in 7.8.3 is taken as an exclusive list). Leonard says that a well-known implementation would use one, but that’s not sufficient reason to encourage people to add one. And the current state is a bit unclear, so I suggest adding this on the end of that 2nd bullet:

Individual CharProcs streams shall not include a Resources entry.

Inheritance of Resources dictionaries in Form XObjects in Table 93 is a bit unclear, so break it into two pieces:

The 2nd para (starting “In a PDF whose version is 1.1”) is telling people how to make files against a 25-year old specification and does not seem appropriate in this standard. I suggest removing it, and replacing with a note along the lines of:

NOTE: PDF files whose version is 1.1 or earlier followed different rules. A software developer wishing their PDF processor to offer maximum compatibility might need to review appropriate specifications.

The 3rd para of the Resources Value cell in Table 93 is also confusing; it’s defining post PDF 1.1 behaviour by comparison with the obsolete v1.1 structures. I suggest deleting the entire paragraph. Bullet 3 in 7.8.3 states clearly that a Resources dictionary is required in a Form XObject (at least if the Form needs any resources). So I’d replace the current “Optional but strongly recommended” at the start of the cell, which contradicts 7.8.3, with Required. I could suggest "Required if the Form requires any resources" instead, but the overhead of needing to add an empty Resources dictionary is pretty low.

Coming back to Type 3 fonts, this time in the Resources row of Table 110, replace “Optional but should be used” with “Usually required”. And then replace the last sentence of that cell with

If any glyph descriptions refer to named resources then this Resources entry is required, otherwise it is optional.

NOTE Before PDF 2.0 202X the Resources dictionary was optional in a Type 3 font dictionary. Software developers might wish to make their PDF processors compatible with older PDF versions by looking up names in the resource dictionary of the page on which the font is used if no Resources entry is present in the Type 3 font dictionary.

Finally in that table cell, replace “required by the glyph descriptions” with “referenced by the glyph descriptions”.

Delete the last sentence of bullet d in the list immediately below table 110.

And finally, just to rock the boat on everything above:

The fourth bullet in 7.8.3 is a bit problematic because it implicitly endorses converting a pre PDF 2.0 file to a PDF 2.0 file without bothering to enforce all of the PDF 2.0 rules. It basically says “I know we said Resources is required in a Form XObject or a Type 3 font, but you can break that rule if you prefer”. If we want to allow that because we believe that doing anything else would be too great a drag on PDF 2.0 adoption, then so be it, but we would need to go back to optional Resources in at least those two places.

If we want to stay with making them clearly required then I suggest making the last bullet into a note, with appropriate tweaks to the wording.

-end-

@petervwyatt petervwyatt added this to the Font and text related milestone Mar 7, 2022
@petervwyatt petervwyatt removed help wanted Extra attention is needed question Further information is requested labels Jun 30, 2022
@MPBailey
Copy link

MPBailey commented Jul 7, 2022

We discussed this in the call on 30 June 2022 and I was asked to come up with a concrete proposal. That discussion concluded that:

  • a T3 font shall have a Resources entry if any CharStrings use resources directly (but that resources used by resources that are referenced by the CharString stream should not be included)
  • There shall be no Resources entry in each CharStrings stream

Those decisions contradict some of the earlier comments in this thread.

So here goes:

7.8.3 Resource dictionaries
Amend the 2nd bullet to add the word ‘directly’, and a cross-reference:

Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary specifying all the resources used directly by all the content streams in the CharProcs dictionary of a Type 3 font (see Table 110 — Entries in a Type 3 font dictionary).

This is a clarification not a change because a resource referenced by an XObject that is itself referenced in a CharProcs stream is arguably not “used by a content stream in the CharProcs dictionary”.

Probably best to leave the last bullet in that series as-is, or convert to a note. Worth discussing.

Table 110
Replace the description of Resources as follows:
2020:

(Optional but should be used; PDF 1.2) A list of the named resources, such as fonts and images, required by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries"). If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Replace with:

(Required if any CharStrings streams reference resources directly; Optional otherwise) A list of the named resources, such as fonts and images, directly referenced by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries"). Resources required within other resources such as fonts or XObjects referenced by glyph descriptions shall be included in the Resources dictionary for each referenced resource and shall not be included in the Resources dictionary within the Type 3 font.

Note: PDF specifications prior to PDF 2.0 stated that, if any glyph descriptions refer to named resources but this dictionary is absent, the names could be looked up in the resource dictionary of the page on which the font is used.

The required/optional statement is adapted from similar table entries elsewhere in the current text. Equivalent usage seems to consistently omit any sentence in the body of the description to repeat the conditions.

This is arguably not a change as 7.8.4 already stated that “Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary specifying all the resources used by all the content streams in the CharProcs dictionary of a Type 3 font”.

9.6.4 Type 3 fonts
In the lettered list below Table 110, amend item d) as follows:
Delete (the note in the table as described above should be enough):

If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Add a new second sentence:

No Resources entry shall be present in the stream object for a CharProcs entry.

This is also a clarification, not a change because there has never been anything in the spec that describes a Resources entry in a CharProcs stream, while there are statements that resources required by a CharProcs stream shall be present in the Type 3 font or, in earlier versions, inherited from the page.

@MPBailey MPBailey added the proposed solution Proposed solution is ready for review label Jul 7, 2022
@lrosenthol
Copy link
Contributor

Add a new second sentence:
No Resources entry shall be present in the stream object for a CharProcs entry.

I don't support this change - it will break some existing implementations that may indeed look for a Resources dictionary associated with this content stream. It would also make a CharProc stream different than every other content stream in a PDF. I see no benefit to that.

@petervwyatt petervwyatt removed the proposed solution Proposed solution is ready for review label Jul 21, 2022
@petervwyatt
Copy link
Member

PDF TWG discussed and proposed wording is not correct. Will try again...

@MPBailey
Copy link

Capturing the discussion in the call on 21st July.

In clause 7.8.3 (Resource dictionaries), amend the 2nd bullet as follows:

Current:

• Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary specifying all the resources used by all the content streams in the CharProcs dictionary of a Type 3 font.

Proposed:

• Content streams in the CharProcs dictionary of a Type 3 font may include a Resources entry in the stream dictionary specifying all the named resources used directly by that content stream. If a CharProcs content stream references named resources and there is no Resources dictionary in the CharProcs stream then there shall be a Resources dictionary in the parent Type 3 font dictionary, in the page dictionary or inherited from some ancestor node of the page object (see 7.7.3.4), that specifies all the named resources used by all the content streams in the CharProcs dictionary of the font.

NOTE: Named resources referenced by a resource such as an XObject that is itself referenced from a CharProcs stream would be included in the Resources dictionary of that resource rather than in the Resources dictionary for the CharProcs content stream or the Type 3 font.

In Table 110, amend the Value cell for Resources as follows:

Current:

(Optional but should be used; PDF 1.2) A list of the named resources, such as fonts and images, required by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries"). If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Proposed:

(Optional; PDF 1.2) Named resources, such as fonts and images, required by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries").

9.6.4 Type 3 fonts: In the lettered list below Table 110, amend item d) as follows:

Current:

d) If any glyph descriptions refer to named resources they shall be looked up in the Resources entry of the Type 3 font dictionary. If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Proposed:

d) If any glyph descriptions refer to named resources they shall be looked up in the Resources entry of that CharStrings content stream. If any glyph descriptions refer to named resources but that dictionary is absent, the names shall be looked up in the resource dictionary of the Type 3 font dictionary. If the Type 3 font dictionary does not contain a Resources dictionary, the names shall be looked up in the resource dictionary of the page on which the font is used.

Note that the text in 7.8.3 is a file format requirement, and that in 9.6.4 is a processor requirement.

@petervwyatt
Copy link
Member

PDF TWG agree with the changes as proposed.

However it was noted that PDF/A (in clause 6.2.2) and PDF/X (in clause 6.7.1) both use the phrase "explicitly associated" w.r.t. to resources which needs improving regardless of the specific solution here. PDF/A and PDF/X wording applies more generally to all use of resources.

A content stream that references other objects, such as images and fonts that are necessary to fully render or process the stream, shall have an explicitly associated resources dictionary as described in ISO 32000-2:2020, 7.8.3.

@lrosenthol - just tagging because you were away

@lrosenthol
Copy link
Contributor

So I would actually want changes to the proposed text - I think the current proposals are too wordy and duplicative of material elsewhere in the spec that we should instead be referring to...

@MPBailey
Copy link

Hi Leonard

The last proposal could be replaced with this:

9.6.4 Type 3 fonts: In the lettered list below Table 110, amend item d) as follows:

Current:

d) If any glyph descriptions refer to named resources they shall be looked up in the Resources entry of the Type 3 font dictionary. If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Proposed:

d) If any glyph descriptions refer to named resources they shall be looked up as described in 7.8.3.

But note that the text in 7.8.3 is a file format requirement, and this in 9.6.4 is a processor requirement. So 7.8.3 explains where the Resources dictionary must be located. How that could be treated that as an instruction for a processor will be obvious to most developers, but is not strictly correct.

If you meant something else, could you be more specific?

In particular the proposal for 7.8.3 is much longer than the current text because our conclusion on the last couple of calls means that it needs to walk through a more complex sequence of potential locations for Resources.

@MPBailey
Copy link

OK, one more attempt, with slightly fewer words.

In clause 7.8.3 (Resource dictionaries), amend the 2nd bullet as follows:

Current:

• Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary specifying all the resources used by all the content streams in the CharProcs dictionary of a Type 3 font.

Proposed:

• If a content stream in the CharProcs dictionary of a Type 3 font uses named resources directly then those resources shall be present in the resource dictionary designated by the first Resources entry found in the following search order: the stream dictionary of that content stream; the parent Type 3 font dictionary; the parent page dictionary (potentially inherited from ancestor nodes, see 7.7.3.4).

NOTE: Named resources referenced by a resource such as an XObject that is itself referenced from a CharProcs content stream would be included in the Resources dictionary of that resource rather than in the designated resource dictionary for the content stream.

In Table 110, amend the Value cell for Resources as follows:

Current:

(Optional but should be used; PDF 1.2) A list of the named resources, such as fonts and images, required by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries"). If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Proposed:

(Optional; PDF 1.2) Named resources, such as fonts and images, required by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries").

9.6.4 Type 3 fonts: In the lettered list below Table 110, amend item d) as follows:

Current:

d) If any glyph descriptions refer to named resources they shall be looked up in the Resources entry of the Type 3 font dictionary. If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Proposed:

d) If a glyph description refers to named resources they shall be looked up in the designated resource dictionary as described in 7.8.3.

Note that the text in 7.8.3 is a file format requirement, and that in 9.6.4 is a processor requirement.

@MPBailey MPBailey added the proposed solution Proposed solution is ready for review label Nov 29, 2022
@petervwyatt
Copy link
Member

PDF TWG agree with the direction but some concerns over words. Will resolve through more discussion and approval via PDF TWG email.

@MPBailey
Copy link

MPBailey commented Jan 3, 2023

@petervwyatt , @lrosenthol : either of you care to fill in some more detail about your concerns here so we can move it forward on Thursday?

@petervwyatt
Copy link
Member

petervwyatt commented Jan 4, 2023

Current wording in 9.6.4 uses "glyph description" whereas the proposed text uses slightly different and mixed terminology. For consistency and absolute clarity, I'd go with "glyph description content stream" everywhere and then be crystal clear as to whether a statement means only the glyph description content stream or the glyph description content stream and any referenced content streams.
PS. Note that the any referenced content stream can refer to XObjects, patterns, shadings or other Type3 glyph description content stream.

@petervwyatt
Copy link
Member

So beating up on a few more words:

In clause 7.8.3 (Resource dictionaries), amend the 2nd bullet as follows:

Current:

• Content streams that define the glyph descriptions of a Type 3 font shall include a Resources entry in the Type 3 font dictionary specifying all the resources used by all the content streams in the CharProcs dictionary of a Type 3 font.

Proposed:

• If a glyph description content stream in the CharProcs entry of a Type 3 font uses named resources directly then those resources shall be present in the resource dictionary designated by the first Resources entry found in the following search order:

  1. the stream dictionary of that glyph description content stream;
    NOTE: a glyph description content stream is a Type 1 Form XObject.
  2. the parent Type 3 font dictionary that contained the CharProcs entry with the glyph description content stream;
  3. the parent page dictionary on which the Type 3 font is used;
  4. resource inheritance from ancestor nodes of the parent page dictionary (see 7.7.3.4).

NOTE: Named resources referenced by a resource, such as an XObject referenced from a glyph description content stream, would be included in the Resources dictionary of that resource rather than in the designated resource dictionary of the glyph description content stream.

In Table 110, amend the Value cell for Resources as follows:

Current:

(Optional but should be used; PDF 1.2) A list of the named resources, such as fonts and images, required by the glyph descriptions in this font (see 7.8.3, "Resource dictionaries"). If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Proposed:

(Optional; PDF 1.2) Named resources, such as fonts and images, required by the glyph description content streams of this Type 3 font (see 7.8.3, "Resource dictionaries").

9.6.4 Type 3 fonts: In the lettered list below Table 110, amend item d) as follows:

Current:

d) If any glyph descriptions refer to named resources they shall be looked up in the Resources entry of the Type 3 font dictionary. If any glyph descriptions refer to named resources but this dictionary is absent, the names shall be looked up in the resource dictionary of the page on which the font is used.

Proposed:

d) If a glyph description content stream refers to named resources they shall be looked up in the designated resource dictionary as described in 7.8.3.

Note that the text in 7.8.3 is a file format requirement, and that in 9.6.4 is a processor requirement.

@petervwyatt
Copy link
Member

PDF TWG agree but some members wish to review wording more closely.
PDF/A4 only wants to support resources in glyph description streams and Type 3 font dictionaries (so not page and not inheritance). Can be addressed with dated revision of PDF/A-4.

@DietrichSeggern
Copy link

DietrichSeggern commented Jan 27, 2023

PDF/A4 only wants to support resources in glyph description streams and Type 3 font dictionaries (so not page and not inheritance). Can be addressed with dated revision of PDF/A-4.

PDF/A says "shall have an explicitly associated resources dictionary as described in ISO 32000-2:—, 7.8.3".

"Explicitly associated" may already exclude the cases 3 and 4 where resources are inherited from pages. We could make that more clear if we change the order of lookups:

  • the stream dictionary of that glyph description content stream;
    NOTE: a glyph description content stream is a Type 1 Form XObject.
  • the parent Type 3 font dictionary that contained the CharProcs entry with the glyph description content stream;

If there is no Resources dictionary explicitly associated with the CharProcs:

  • the parent page dictionary on which the Type 3 font is used;
  • resource inheritance from ancestor nodes of the parent page dictionary (see 7.7.3.4).

@MPBailey
Copy link

"If there is no Resources dictionary explicitly associated with the CharProcs:" would need to be "If there is no Resources dictionary explicitly associated with the CharProcs or the Type 3 font dictionary:"

But isn't that unnecessary given that the first location that has a Resources dictionary should be used?

@DietrichSeggern
Copy link

DietrichSeggern commented Jan 30, 2023

My intention was to make it clear that the third and forth option are not consistent with PDF/A-4, if we want to keep the ISO32000-2 text clear of that it is indeed unnecessary. But I think the proposed way would be better than a note, because that note would tend to be a normative suggestion.

@lrosenthol
Copy link
Contributor

I don't understand why Type 3 font Resources lookup is different than any other resources lookup in a non-page content stream. Shouldn't the same rules/path apply to annot appearances, for example? (module the actual Font dictionary).

So why not just write this one and apply it in all cases?

@petervwyatt
Copy link
Member

PDF TWG agree with the principle and suggestions of the comment of mine from Jan 4.
Also consider use of the phrase "explicitly associated" in PDF/A and PDF/X and how that fits with new wording.
Draft an updated bulleted list which makes the process more applicable to all uses of non-page content streams and then calls out the differences for Type 3. Review and finalize in May ISO meetings in Paris.

@MPBailey
Copy link

Starting with Peter’s proposal from Jan 4th 2023, I suggest making the following changes.

As proposed by Dietrich, adjust Peter’s proposal for the 2nd bullet in 7.8.3 (T3 font resources) to:

• If a glyph description content stream in the CharProcs entry of a Type 3 font uses named resources directly then those resources shall be present in the resource dictionary designated by the first Resources entry found in the following search order:

  1. the stream dictionary of that glyph description content stream;

NOTE 1: a glyph description content stream is a Type 1 Form XObject.

  1. the parent Type 3 font dictionary that contained the CharProcs entry with the glyph description content stream;

If there is no Resources dictionary explicitly associated with the Type 3 CharProcs or font dictionary:

  1. the parent page dictionary on which the Type 3 font is used;

  2. resource inheritance from ancestor nodes of the parent page dictionary (see 7.7.3.4).

NOTE 2: Named resources referenced by a resource, such as an XObject referenced from a glyph description content stream, would be included in the Resources dictionary of that resource rather than in the designated resource dictionary of the glyph description content stream.

That will obviously require some care in getting the indenting right. I've replaced the 2nd level bullets with numbers to try to make it clearer.

One of the primary sources of confusion appears to be the fourth bullet in 7.8.3, describing behaviour according to previous versions of PDF. That bullet does not describe the behaviour of PDF 2.0 writers, but appears to be setting requirements on PDF 2.0 readers for files that do not conform to PDF 2.0 (“resources … shall be inherited …”). I suggest replacing that bullet with a sightly re-phrased note. In rephrasing I’ve removed the reference to Type 3 fonts because the proposal for bullet 2 already describes the same behaviour.

Bullet 3 explicitly lists annotation appearances and patterns. In PDF 2.0 (2020) patterns are required to have explicitly associated resources, and that’s true at least back to PDF 1.4. Appearance streams are explicitly form XObjects, so the requirement for forms to have explicitly associated resources also applies to them in PDF 2.0. In earlier versions the explicit description of annotation streams as form XObjects is still present, but of course forms did not have to have explicitly associated resources. As a result I’ve also added annotation appearance streams into the new note.

NOTE 3 PDF files written obeying earlier versions of PDF could have omitted the Resources entry in form XObjects and annotation appearance streams used on a page. Those earlier versions state that resources that are referenced from those forms and streams are inherited from the resource dictionary of the page on which they are used.

The following note will also need numbering.

All other parts of Peter’s Jan 4th comment remain unchanged.

@petervwyatt
Copy link
Member

Table 93 (Additional entries specific to a Type 1 form dictionary) Resources entry states the following which I think needs some tweaking now to align with @MPBailey's proposal above:

(Optional but strongly recommended; PDF 1.2) A dictionary specifying any resources (such as fonts and images) required by the form XObject (see 7.8, "Content streams and resources").
In a PDF whose version is 1.1 and earlier, all named resources used in the form XObject shall be included in the resource dictionary of each page object on which the form XObject appears, regardless of whether they also appear in the resource dictionary of the form XObject. These resources should also be specified in the form XObject’s resource dictionary as well, to determine which resources are used inside the form XObject. If a resource is included in both dictionaries, it shall have the same name in both locations.
In PDF 1.2 and later versions, form XObjects may be independent of the content streams in which they appear, and this is strongly recommended although not required. In an independent form XObject, the resource dictionary of the form XObject is required and shall contain all named resources used by the form XObject. These resources shall not be promoted to the outer content stream’s resource dictionary, although that stream’s resource dictionary refers to the form XObject.

  • the 2nd para about 1.1 and earlier, should be changed to also use past tense phrasing and avoid "shall" requirements since it is describing what processors need to do to support old versions - e.g. the 1st sentence would be "_... all named used in the form XObject were included ..."

  • given that this description of Type 1 Form XObjects gets referenced by annot appearance streams, Type3 glyph descriptions, etc., noting those other features use Type1 Form XObjects for less knowledgeable readers will also help.

  • based on the updated wording in 7.8, we also need to review the "strongly recommended" statement in Table 93 as we should be as explicit as possible (e.g. "is required for XXX, is optional for YYY")

@petervwyatt
Copy link
Member

Further: 7.7.3.4 states that Linearized PDFs also don't inherit back up the page tree:

In a document conforming to Linearized PDF (see Annex F, "Linearized PDF" and Annex G, "Linearized PDF access strategies") all page attributes shall be specified explicitly as entries in the page dictionaries to which they apply; they shall not be inherited from an ancestor node.

@MatthiasValvekens
Copy link
Member

Further: 7.7.3.4 states that Linearized PDFs also don't inherit back up the page tree

This is possibly an artifact of the "ISOification" process, but I suspect that that line was intended purely as a file format requirement, and not a processor instruction (@lrosenthol ?). If so, perhaps it should be reworded to make that more obvious. Maybe replacing the "they shall not be inherited..." bit with something like "Such documents shall not rely on inheritance to propagate attributes in the page tree" would work?

@datalogics-pgallot
Copy link

There is a requirement in normative section F.3.10 that all inheritable attributes be pushed down to the leaf page objects precisely so that the Page tree is never required to display any page. So a conformant Linearized PDF will never have inheritable attributes.

F.3.10 Other Objects (Part 9)
[...]
•The page tree. This object can be located in this section because the conforming reader never needs to consult it. Note that all Resources attributes and other inheritable attributes of the page objects shall be pushed down and replicated in each of the leaf page objects (but they may contain indirect references to shared objects).

@MPBailey
Copy link

Peter's comment on the Resources row in Table 93 is picking up on a loose end from a change made in the transition from Adobe PDF 1.7 to 32000-1 rather than directly associated with this issue, but ...

I'd change the value cell along the lines of:

  • Make the requirement "(Sometimes required; PDF 1.2)". That terminology is used elsewhere already. FWIW, we might consider doing the same in the Resources row of Table 110.
  • As Peter says, change para 2 to past tense and remove normative words. In fact I'd go all the way to making it a note, and consider moving it to the end of the cell.
  • Para 3 is now incorrect as form XObjects must now be independent, at least as far as resources go. Replace the first sentence of that para with "In PDF 1.2 and later versions, form XObjects may be independent of the content streams in which they appear; from PDF 2.0 this is required."

@petervwyatt
Copy link
Member

PDF TWG would like to:

  1. create new issues for Table 93 corrections and Linearization
  2. take Martin's improved comments (also from Jan 4) from 2 days ago and apply those changes to share with the PDF TWG (as a full markup of subclause 7.xxx)

@petervwyatt
Copy link
Member

PDF TWG agree to wording distributed via email.

@petervwyatt petervwyatt added ISO approved Resolved issue approved by ISO and removed bug Something isn't correct proposed solution Proposed solution is ready for review labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISO approved Resolved issue approved by ISO
Projects
None yet
Development

No branches or pull requests

7 participants