refactor(font): remove the PDFBox-typed API and FontShowcase from the core font package#296
Merged
Merged
Conversation
… core font package Ahead of the 2.0 module split, take the core font package a step closer to backend-neutral. - DefaultFonts no longer declares library(PDDocument) or library(PDDocument, Collection<FontFamilyDefinition>). They were thin delegators to document.backend.fixed.pdf.PdfFontLibraryFactory, which already exposes the identical methods; the (test-scope) callers now call the factory directly. compose.font is now free of org.apache.pdfbox. - FontShowcase moves from compose.font to document.backend.fixed.pdf: it composes a preview through the document DSL and renders it, so it belongs with the PDF backend it rides. Its two tests move alongside, and its public methods gain javadoc (the pdf package is javadoc-gated with doclint=all; the font package was not). GraphCompose.renderAvailableFontsPreview() imports it from the new home. DefaultFonts.standardLibrary() and its EntityManager caller are intentionally left untouched; that remaining font-to-backend delegation is cut when the render/measurement seam lands. Behaviour is unchanged: the FontShowcase render/snapshot tests and every layout snapshot pass with zero baseline updates.
Extend PdfBackendIsolationGuardTest to scan com.demcha.compose.font. The font package is the logical font catalog — it names fonts and never loads them, so a file under it that imports org.apache.pdfbox now fails the guard. FontShowcase, which renders a preview PDF, already lives under backend/fixed/pdf and is exempted along with the rest of the pdf backend.
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
Ahead of the 2.0 Maven module split, the core
com.demcha.compose.fontpackage must stop reaching into the PDF backend so it can live in a lean, backend-neutral core. Today it does so in two places:DefaultFontsexposesPDDocument-typed methods, andFontShowcasecomposes a preview through the document DSL. This PR removes both. (It is a partial cycle break by design — see Scope below.)What changed
DefaultFontsdrops the PDFBox leak.library(PDDocument)andlibrary(PDDocument, Collection<FontFamilyDefinition>)were thin delegators todocument.backend.fixed.pdf.PdfFontLibraryFactory, which already exposes the identical methods. They're removed and the (all test-scope) callers now call the factory directly.compose.fontno longer importsorg.apache.pdfboxanywhere.FontShowcasemoves todocument.backend.fixed.pdf. It builds a font-preview document via the DSL and renders it, so it belongs with the PDF backend it rides. Its two tests move alongside, and its public methods gain javadoc — the pdf package is javadoc-gated (doclint=all); the font package was not.GraphCompose.renderAvailableFontsPreview()imports it from the new home.PdfBackendIsolationGuardTestnow also scanscom.demcha.compose.font, so any future file that re-importsorg.apache.pdfboxunder the font catalog fails the build. The font package is the logical catalog — it names fonts, it never loads them.CONTRIBUTING.mdpackage map updated to reflect FontShowcase's new home.Scope (deliberately partial)
DefaultFonts.standardLibrary()— reached byengine.core.EntityManager's defaulting constructors — still delegates toPdfFontLibraryFactory, socompose.fontretains that one non-PDFBoxdocumentimport. Cutting it would force the engine to name the pdf backend directly (a forbiddenengine → documentedge) unless a backend seam supplies the default library; that belongs with the render/measurement seam, not here. Production never hits that default (nosrc/mainconstructsEntityManagerwithout an injected library) — it is a test-only convenience.Verification
./mvnw clean verify -pl .— green. Zero layout-snapshot updates and the FontShowcase render/snapshot tests pass, proving the rendered output is byte-identical../mvnw javadoc:javadoc -pl .— clean; FontShowcase's new method javadoc satisfiesdoclint=allin the (now-gated) pdf package.org.apache.pdfboximport intoDefaultFontsturnsPdfBackendIsolationGuardTestred on exactly that file.DefaultFonts.library(...)callers; zeroorg.apache.pdfboximports undercompose.font; no dangling references to the oldcom.demcha.compose.font.FontShowcaseFQN.