t775: fix DejaVuSansMono.ttf missing exception when viewing invoices#778
t775: fix DejaVuSansMono.ttf missing exception when viewing invoices#778superdav42 merged 2 commits intomainfrom
Conversation
DejaVuSansMono.ttf and its variants are removed from the vendor ttfonts directory by the composer post-install script to reduce plugin size. mPDF's default font configuration still references these files as the primary monospace font family, so any invoice content that triggers a monospace font lookup throws: MpdfException: Cannot find TTF TrueType font file "DejaVuSansMono.ttf" Fix: after creating the mPDF instance in pdf_setup(), override the dejavusansmono fontdata entry to point to FreeMono.ttf and FreeMonoBold.ttf, which are retained in the ttfonts directory. Oblique/BoldOblique variants are mapped to their upright counterparts since only the regular and bold FreeMono files are available. This follows the same post-construction fontdata override pattern already used for the Amiri RTL font registration. Fixes #775
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 59 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge SummaryIssue: #775 — DejaVuSansMono.ttf Missing - Causing Exception When Viewing Invoice Root cause: The composer post-install script removes Fix: Added Verification: PHP syntax clean ( aidevops.sh v3.6.235 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 4m and 218 tokens on this as a headless worker. Overall, 16s since this issue was created. |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for 6f8f7e5 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
The Upload Cypress screenshots and Upload Cypress videos steps had inconsistent indentation in their 'with:' blocks, causing a YAML parse error that prevented the E2E Tests workflow from running. This blocked the required 'cypress (8.2, chrome)' check from appearing on PR #778, preventing merge.
Merge SummaryIssue: #775 — DejaVuSansMono.ttf Missing - Causing Exception When Viewing Invoice Root cause: The composer post-install script removes Fix: Added Verification: PHP syntax clean ( aidevops.sh v3.6.235 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 4m and 218 tokens on this as a headless worker. Overall, 16s since this issue was created. Merged via PR #778 to main. |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
Fixes the
MpdfException: Cannot find TTF TrueType font file "DejaVuSansMono.ttf"error thrown when viewing invoices that contain monospace-font content (e.g. product descriptions with<code>tags, or any CSSfont-family: monospace).Root Cause
The composer post-install script (
scripts/remove-mpdf-fonts.php) stripsDejaVuSansMono.ttfand its variants fromvendor/mpdf/mpdf/ttfonts/to reduce plugin distribution size. However, mPDF's defaultFontVariablesconfiguration still listsdejavusansmonoas the first entry inmono_fonts, so any monospace font lookup throws a fatal exception.Fix
In
pdf_setup()ininc/invoices/class-invoice.php, after creating the mPDF instance, override thedejavusansmonofontdata entry to point toFreeMono.ttf/FreeMonoBold.ttf, which are retained in the ttfonts directory. Oblique/BoldOblique variants are mapped to their upright counterparts since only the regular and bold FreeMono files are available.This follows the same post-construction fontdata override pattern already used for the Amiri RTL font registration.
Files Changed
inc/invoices/class-invoice.php— addedget_missing_fontdata()method and called it inpdf_setup()after RTL font registrationRuntime Testing
Risk level: Medium (PDF generation path, no dev environment available for runtime test).
Self-assessed: the fix is a direct fontdata key override on the mPDF instance, identical in mechanism to the existing Amiri RTL font override. PHP syntax verified (
php -l). TheFreeMono.ttfandFreeMonoBold.ttffiles confirmed present invendor/mpdf/mpdf/ttfonts/.Resolves #775
aidevops.sh v3.6.235 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 3m and 10,445 tokens on this as a headless worker.