# Cleanup Bundled MiSans Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Remove the unused jar-bundled MiSans font path and keep Docker runtime system MiSans as the single PDF font source. **Architecture:** The Playwright PDF generator will no longer accept or reference bundled font loaders. Runtime PDF rendering continues to rely on the existing CSS font stack and the Docker image installing `MiSans-VF.ttf` into the OS font cache. **Tech Stack:** Java 17, Spring Boot 3.3.5, Maven multi-module project, Playwright Java, Docker runtime image. --- ## File Structure - Delete `abilities/exam-sprint/infrastructure/src/main/resources/fonts/MiSans-VF.ttf`: unused classpath font resource. - Delete `abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/BundledOutlookReportFonts.java`: unused bundled font loader. - Delete `abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/BundledOutlookReportFontsTest.java`: tests for deleted loader. - Modify `abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/PlaywrightExamSprintReportPdfGenerator.java`: simplify constructors and remove `Supplier` dependency. - Modify `abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/PlaywrightExamSprintReportPdfGeneratorTest.java`: update test-only constructor usage. - Modify `docs/superpowers/plans/2026-05-07-playwright-pdf-generator.md`: replace stale bundled-font wording with runtime-system-font wording. ### Task 1: Simplify Playwright Generator Constructors **Files:** - Modify: `abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/PlaywrightExamSprintReportPdfGenerator.java` - Modify: `abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/PlaywrightExamSprintReportPdfGeneratorTest.java` - [ ] **Step 1: Update the test constructor call** In `PlaywrightExamSprintReportPdfGeneratorTest.java`, replace the constructor call in `constructorDoesNotLaunchChromiumBeforeFirstGenerate()` from: ```java try (PlaywrightExamSprintReportPdfGenerator generator = new PlaywrightExamSprintReportPdfGenerator( BundledOutlookReportFonts::load, 1, 1)) { ``` to: ```java try (PlaywrightExamSprintReportPdfGenerator generator = new PlaywrightExamSprintReportPdfGenerator(1, 1)) { ``` - [ ] **Step 2: Run the targeted compile/test to verify the expected failure** Run: ```bash mvn -pl abilities/exam-sprint/infrastructure -am -Dtest=PlaywrightExamSprintReportPdfGeneratorTest test ``` Expected: compilation fails because `PlaywrightExamSprintReportPdfGenerator(double, double)` does not exist yet. - [ ] **Step 3: Simplify the production class constructors** In `PlaywrightExamSprintReportPdfGenerator.java`, remove this import: ```java import java.util.Objects; import java.util.function.Supplier; ``` Add back only this import if `Objects` is still needed by another statement: ```java import java.util.Objects; ``` Then replace the constructors: ```java public PlaywrightExamSprintReportPdfGenerator() { this(BundledOutlookReportFonts::load, DEFAULT_LAUNCH_TIMEOUT_MILLIS, DEFAULT_RENDER_TIMEOUT_MILLIS); } PlaywrightExamSprintReportPdfGenerator( Supplier bundledFontsSupplier, double launchTimeoutMillis, double renderTimeoutMillis) { Objects.requireNonNull(bundledFontsSupplier, "bundledFontsSupplier"); this.launchTimeoutMillis = launchTimeoutMillis; this.renderTimeoutMillis = renderTimeoutMillis; } ``` with: ```java public PlaywrightExamSprintReportPdfGenerator() { this(DEFAULT_LAUNCH_TIMEOUT_MILLIS, DEFAULT_RENDER_TIMEOUT_MILLIS); } PlaywrightExamSprintReportPdfGenerator(double launchTimeoutMillis, double renderTimeoutMillis) { this.launchTimeoutMillis = launchTimeoutMillis; this.renderTimeoutMillis = renderTimeoutMillis; } ``` Keep this line in `generate(String htmlContent)` unchanged, so `java.util.Objects` remains required: ```java Objects.requireNonNull(htmlContent, "htmlContent"); ``` - [ ] **Step 4: Run the targeted generator test** Run: ```bash mvn -pl abilities/exam-sprint/infrastructure -am -Dtest=PlaywrightExamSprintReportPdfGeneratorTest test ``` Expected: the test compiles and passes, assuming local Playwright Chromium is installed and available. ### Task 2: Delete Bundled Font Loader and Resource **Files:** - Delete: `abilities/exam-sprint/infrastructure/src/main/resources/fonts/MiSans-VF.ttf` - Delete: `abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/BundledOutlookReportFonts.java` - Delete: `abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/BundledOutlookReportFontsTest.java` - [ ] **Step 1: Delete the classpath font resource** Delete: ```text abilities/exam-sprint/infrastructure/src/main/resources/fonts/MiSans-VF.ttf ``` - [ ] **Step 2: Delete the unused bundled font loader** Delete: ```text abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/BundledOutlookReportFonts.java ``` - [ ] **Step 3: Delete the loader test** Delete: ```text abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/BundledOutlookReportFontsTest.java ``` - [ ] **Step 4: Verify no production/test references remain** Run: ```bash rg "BundledOutlookReportFonts|/fonts/MiSans-VF.ttf|src/main/resources/fonts/MiSans-VF.ttf" abilities/exam-sprint/infrastructure ``` Expected: no matches. ### Task 3: Update Stale Plan Documentation **Files:** - Modify: `docs/superpowers/plans/2026-05-07-playwright-pdf-generator.md` - [ ] **Step 1: Replace the stale bundled-font bullet** In `docs/superpowers/plans/2026-05-07-playwright-pdf-generator.md`, replace this line: ```markdown - Injects bundled MiSans as `MiSans`, `MiSans VF`, and `ReportFont` through a `file:` URL `@font-face` block when the bundled font is available. ``` with: ```markdown - Relies on the runtime Docker image installing MiSans as a system font so Chromium can resolve the report font stack (`'MiSans VF', MiSans, ReportFont, sans-serif`). ``` - [ ] **Step 2: Verify the docs no longer describe bundled font injection** Run: ```bash rg "bundled MiSans|@font-face|/fonts/MiSans-VF.ttf|BundledOutlookReportFonts" docs/superpowers/plans/2026-05-07-playwright-pdf-generator.md ``` Expected: no matches. ### Task 4: Final Verification **Files:** - No source file changes. - [ ] **Step 1: Run targeted infrastructure tests** Run: ```bash mvn -pl abilities/exam-sprint/infrastructure -am -Dtest=PlaywrightExamSprintReportPdfGeneratorTest test ``` Expected: build exits with code 0 and `PlaywrightExamSprintReportPdfGeneratorTest` passes. - [ ] **Step 2: Run broader PDF/report related tests if time allows** Run: ```bash mvn -pl abilities/exam-sprint/infrastructure -am -Dtest='*Report*Test,*Pdf*Test' test ``` Expected: build exits with code 0. If Playwright Chromium is missing locally, install it with the existing project command before rerunning: ```bash mvn -pl abilities/exam-sprint/infrastructure exec:java -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install chromium" ``` - [ ] **Step 3: Verify the Docker runtime font remains available in source** Run: ```bash rg "MiSans-VF.ttf|fc-match \"MiSans VF\"" deploy/ability-center/runtime ``` Expected: matches remain in `deploy/ability-center/runtime/dockerfile` and the only remaining source font file is `deploy/ability-center/runtime/fonts/MiSans-VF.ttf`. - [ ] **Step 4: Inspect git diff** Run: ```bash git diff --stat && git diff -- abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/PlaywrightExamSprintReportPdfGenerator.java abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/pdf/PlaywrightExamSprintReportPdfGeneratorTest.java docs/superpowers/plans/2026-05-07-playwright-pdf-generator.md ``` Expected: diff only removes bundled font artifacts, simplifies the Playwright generator constructor, updates the related test call, and fixes stale documentation. ## Self-Review - Spec coverage: The plan deletes the jar-bundled font, removes the unused loader and tests, simplifies the only production constructor reference, updates the stale documentation, and preserves Docker runtime system font handling. - Placeholder scan: No `TBD`, `TODO`, or undefined implementation instructions remain. - Type consistency: The new test call uses `PlaywrightExamSprintReportPdfGenerator(double, double)`, which Task 1 defines as a package-private constructor matching the current test package. - Commit policy: No commit step is included because the current session has not received an explicit request to create a git commit.