Repository navigation
fix(pptx): say no face of a font travels where none did - #1088
Merged
Merged
Conversation
A family the deck could not carry was told `"X" is not carried whole`, worded for a deck holding part of the family, because the embedder answered a boolean (bundled path) or nullable metrics (registered path) and the caller could not tell "nothing travelled" from "the presentation kept part of it". Every refusal a font can provoke arrives before the presentation is handed a face and leaves nothing. PptxFontEmbedder now answers a package-private Carried (WHOLE, NONE, PART) and, on the registered path, an Embedding of it and the viewer metrics. PptxDeckFonts writes `no face of it travels with the deck` for NONE on both paths, and keeps `not carried whole` for PART and for a FontName an earlier registration of which travelled. The saveSubsetFonts clear follows "anything carried", the same on every path a font reaches. A family given up by its viewer metrics in a style slot that the family sharing its viewer name left free is told its text is drawn from the program that travelled, in either order of registration: already true since the line is chosen from the slot ledger after the last registration, now pinned by a test. Only the log changes.
…keeps The embedder's javadoc counted four refusals and called every one of them NONE; the presentation refusing a face it was handed is PART, and a family the page had to measure fails the render. It now says which answer each gives, and why the only refusal left after the hand-over starts is POI's part store: FontHeader.bufferInit reads only the header, which PptxEmbeddedFont has measured. The CHANGELOG's exception is widened to what the code does: a family whose declared name another registered family carries a face under keeps the shared-name line whatever refused it, the ledger being asked first. The bundled-path comment says the subsetting flag may have been set by a refused hand-over, rather than that it was.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
A registered or bundled family the PPTX deck could not carry was told
render.pptx.font.substitution family=X — could not be embedded, so "X" is not carried whole; ….That wording is for a deck holding part of the family, and
PptxDeckFontscould not chooseanother:
PptxFontEmbedder.embedFontFamilyanswered a boolean andembedFontFamilyWithMetricsa nullable metrics object, so "nothing of the family travelled" and "the presentation kept part
of it" arrived as the same answer.
Every refusal a font can provoke arrives before the presentation is handed a face — a face that
cannot be read, licence bits that forbid embedding, a header the presentation could not read back,
two of the family's faces reading back as one style slot, a face arriving into a slot another
family holds, and on the registered path the viewer metrics. In each of them nothing of the family
is in the deck, so the hedge was always the weaker claim. The one refusal left after the hand-over
starts is POI's part store: the presentation's first read of a face,
FontHeader.bufferInit, readsonly the container's header, which
PptxEmbeddedFonthas already measured against it. (A familywhose declared name another registered family carries a face under is told its text is drawn from
that program, whatever refused it, and keeps that line.)
What changed
PptxFontEmbedder.Carried(WHOLE,NONE,PART) andPptxFontEmbedder.Embedding(carried, metrics), both package-private.NONEwhere the family is refused before the hand-over;PARTwhere
handOverProgramsfails after the presentation was handed the family, which only POI's ownpart store can do.
PptxDeckFontswritescould not be embedded, so no face of it travels with the deck; any text drawn with it is referenced as "X" by name, and needs that font installed where the deck is opened for identical glyphsforNONEon the registered path, and the same withits texton thebundled path, where the family is known to be drawn in — in both cases where no other registered
family carries a face under the declared name, which is asked first and keeps the shared-name
line whatever refused the family.
not carried wholestays where somethingof the name is in the deck:
PART, or an earlier registration of the sameFontNamethattravelled while its last registration did not.
again" limit now applies only to a re-registration without sources.
saveSubsetFontsclear follows "anything of a family was carried" on both paths, instead of"some registered family kept its metrics" and "some bundled family travelled whole". The two agree
on every path a font reaches; they differ only for
PART, whereaddFacetmay have set the flagbefore it refused.
No public API changes. On every path a font can reach, only the log changes: what a deck carries is
unchanged.
Tests
PptxUnreadableFontSourceTest(missing classpath resource, one unreadable face of two, metricsrefusal) and
PptxFontStyleSlotTest(two faces in one slot): the substitution line now has to sayno face of it travels with the deckand must not saynot carried whole.PptxFontSubstitutionWarningTest.aNameAnEarlierRegistrationCarriedIsNotToldNoFaceOfItTravels:files("Brand", Lato)thenfiles("Brand", Lato truncated by a byte)— one part in the deck, thelast registration refused on its viewer metrics (asserted), and the line stays
"Brand" is not carried whole.PptxSharedViewerFamilyTest.aFamilyGivenUpInAFreeSlotOfACarriedNameIsToldItsTextIsDrawnFromThatProgram:a family whose only face reads back as
boldunderwordFamily("Brand"), beside a regular-onlycarrier of
Brand, given up by the viewer metrics. In both orders of registration it gets theshared-name line (
draws it from the program that did travel), not the install line. This alreadyheld since the line is chosen from the slot ledger after the last registration; the test pins it.
NONEline has no test, as the bundled line it replaces had none: a bundled familyrefused beside a registration that declares its name gets the shared-name line, and no test draws
a bundled family whose own face is refused.
./mvnw -B -ntp test -pl :graph-compose-render-docx,:graph-compose-render-pptx -am: render-pptx207, core 845, render-pdf 347, render-docx 2,823, testing 5, 0 failures;
./mvnw -B -ntp test -f qa/pom.xml: 1,927, 0 failures.NONEline swapped for thehedged one (4 tests fail), an earlier registration that travelled forgotten (the new re-registration
test fails), a registered family reported as it is read instead of after the last registration (the
new free-slot test fails, with three others).