Repository navigation
refactor(docx): split DocxFontTable in four - #1085
Merged
Merged
Conversation
DocxFontTable had grown to 868 lines, against the project's 500. It keeps the font table itself: which faces a document asks for, which family keeps a declared name and the refusal of the one that does not, and the parts and XML it writes (478 lines). Three package-private classes take the rest, moved line for line: - DocxShippedLines: the former DocxFontTable.ShippedLines; - DocxFontFaces: the Face class and Slot enum, reading a family's faces and their licence terms, and the note on a face of another typeface than the family's regular one; - DocxTypeface: the typeface a program states. Face gains fontKey() and relationshipId() accessors, which the XML read as fields while Face was nested in the table. DocxFontFaces logs under the DocxFontTable category, as the code did before the move. DocxFontTableTest's eleven shared-name cases move to DocxSharedFontNameTest, and the helpers both classes use to DocxFontTableFixtures; the eighteen others stay. 29 tests before and after. No behaviour change: the 105 documents of the DOCX fidelity corpus are identical in every part, with the same 1,718 report notes.
The CHANGELOG heading said DocxFontTable no longer carried the whole of the backend's font embedding; it never did, since DocxFontEmbedding already held the licence bits and the obfuscation. It now says the class is split in four. The move was line for line apart from visibility, names, two Face accessors and javadoc that now crosses a class; this rewraps one javadoc paragraph in refuseForASharedName that a reference change had left with a stranded line, and reflows the CHANGELOG entry.
DemchaAV
marked this pull request as ready for review
November 25, 2026 11:46
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
DocxFontTablewrites the DOCX font table, and the rest of font embedding grew inside it until it was 868 lines, against the project's 500. The class did four things:ShippedLines), whichDocxGrownLinesreads;DocxFontTableTestgrew with it, to 1,020 lines and 29 tests, eleven of them about two families asking for one name.What changed
Three package-private classes in
com.demcha.compose.document.backend.semantic.docxtake the code that is not the table:DocxShippedLines(131 lines) — the formerDocxFontTable.ShippedLines.DocxFontFaces(278 lines, static) — theFaceclass and theSlotenum,facesOf,addFaceand the note on a face of another typeface than the family's regular one.DocxTypeface(51 lines) —typefaceOf, which readsnameid 16, else id 1, from the Windows en-US record.DocxFontTable(477 lines) keepswrite,familiesByName, theEmbeddedrecord,resolvewith the shared-name refusal, the walk over the faces a document names, and the XML.writeandfamiliesByNamekeep their parameters;writereturns the renamedDocxShippedLines. Public API is unchanged and the knowledge pack is untouched.The moved code is the original lines, sliced from the file rather than retyped. Every non-blank line of the original is accounted for in the four files. What differs:
private→ package-private where another class now uses a member (Embedded,Face,Slot,facesOf, theShippedLinesconstructor);ShippedLines→DocxShippedLines, and calls qualified withDocxFontFaces.andDocxTypeface.;Face,fontKey()andrelationshipId(), which the XML read as fields whileFacewas nested in the table;DocxFontTablepointing atDocxFontFacesfor the licence terms, and the javadoc lines rewrapped around them;LinkedHashSetimport, dropped.DocxFontFaceslogs under theDocxFontTablecategory, so the export's lines about its fonts keep the logger name they had.Tests, the same 29, moved and not rewritten:
DocxSharedFontNameTest— the eleven cases of one declared name: which family keeps it, the refusal and its note, the line each family's paragraphs read, a family reached by two names writing one element.DocxFontTableFixtures— the font constants,exportSetIn, and the readers of the font table and its parts that both classes use.DocxFontTableTestkeeps the other eighteen, in 537 lines: still over the guide, by its four cases of a family holding two typefaces, which are not moved here. Its one-paragraphexportSetInoverload is renamedexportOneFace, because a method of its own with that name would shadow the fixtures' statically imported one.Documentation:
CHANGELOG.md(2.5.2, Internal) anddocs/architecture/backend-capability-details.md, which now namesDocxFontFacesbesideDocxFontTableandDocxFontEmbedding.Verification
developatb3e774d19) and after, are identical in every part, with the same 1,718 report notes (corpus-diff: unchanged)../mvnw -B -ntp test -pl :graph-compose-render-docx -am: 2,787 tests, 0 failures, 1 skipped;DocxFontTableTestran 18 andDocxSharedFontNameTest11, whereDocxFontTableTestran 29 before../mvnw -B -ntp test -f qa/pom.xml: 1,926 tests, 0 failures, 1 skipped.DocxSharedFontNameTest.twoFamiliesUnderOneNameShipOneFaceSet;DocxSharedFontNameTest.theFamilyThatKeepsTheNameKeepsTheLineItsParagraphsMayGrowTo;DocxFontTableTest.aBundledFamilyWhoseItalicStatesAnotherFamilyRecordIsNotNamed;Face.fontKey()returning another key →DocxFontTableTest.theShippedFaceIsTheRealFontBehindItsScrambledHeader;DocxFontTableTest.aFaceThatMayNotTravelLeavesNoRequestToSaveFacesEither;DocxFontTableTest.aFaceOfAnotherTypefaceThanTheFamilysRegularOneIsNamedAsUndrawn.2d8dc8158: the reactorclean verifyas CI runs it, the four knowledge checks, core javadoc, then install and the examples tests (93,CommittedAssetDriftTestincluded) — all passed.Lane: render-docx internals, no public surface.