Re-factor the idFactory
functionality, used in the core/
-code, and move the fontID
generation into it
#12070
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note how the
getFontID
-method insrc/core/fonts.js
is completely global, rather than properly tied to the current document. This means that if you repeatedly open and parse/render, and then close, even the same PDF document thefontID
s will still be incremented continuously.For comparison the
createObjId
method, onidFactory
, will always create a consistent id, assuming of course that the document and its pages are parsed/rendered in the same order.In order to address this inconsistency, it thus seems reasonable to add a new
createFontId
method on theidFactory
and use that when obtainingfontID
s. (When the currentgetFontID
method was added theidFactory
didn't actually exist yet, which explains why the code looks the way it does.)Please note: Since the document id is (still) part of the
loadedName
, it's thus not possible for different documents to have identical font names.Implements the idea from #11610 (comment)