Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

feat: package fonts for more invoice PDF languages (Hebrew, Thai, Lao, Khmer, Myanmar, Sinhala, Kannada, Telugu, Sindhi)

已关闭
#2,039 6 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@superdav42 已经在做这个了。

开始于 2026年10月27日。

  • #2040 来自 @superdav42 —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

auto-dispatch enhancement status:in-review tier:standard

Summary

Package fonts so invoice PDFs render Hebrew, Thai, Lao, Khmer, Myanmar, Sinhala, Kannada, Telugu and Sindhi. Fonts stay packaged in the plugin. There are no on-demand downloads in this issue.

Follow-up to #1925, #2030 (PR #2035) and #2037 (PR #2038). #2038 added a pre-render check, Invoice::get_unsupported_scripts(). It uses mPDF's own script database and font mapping, and fails early with a clear, admin-visible error when the font mPDF would select for a script is not on disk. Once a font file is retained, that script passes the check with no code change. So this issue is mainly about which mPDF font files to stop stripping.

Background (verified against mPDF 8.3.1)

scripts/remove-mpdf-fonts.php deletes mPDF's non-Latin fonts. It runs from the composer post-install-cmd and post-update-cmd hooks. Every build path goes through it: package.json prebuild (composer install -o --no-dev), release.yml, CI and bin/deploy.sh. Editing its $fonts list is the single control point.

The original mPDF package, as cached by composer, gives exact sizes. Today the plugin ships about 2.9 MB of fonts (DejaVu Sans/Serif Condensed regular and bold, FreeMono, Eeyek).

Scope: fonts to retain (from mPDF's own bundle, about 1.76 MB uncompressed in total)

Script mPDF font name Files to keep Size
Hebrew taameydavidclm TaameyDavidCLM-Medium.ttf, TaameyDavidCLM-LICENSE.txt 96 KB
Thai garuda Garuda.ttf, Garuda-Bold.ttf 113 KB
Lao dhyana Dhyana-Regular.ttf, Dhyana-Bold.ttf, DhyanaOFL.txt 134 KB
Khmer khmeros KhmerOS.ttf, KhmerOFL.txt 266 KB
Myanmar (and Tai Le) tharlon Tharlon-Regular.ttf, TharlonOFL.txt 353 KB
Sinhala kaputaunicode kaputaunicode.ttf 160 KB
Kannada lohitkannada Lohit-Kannada.ttf, LohitKannadaOFL.txt 198 KB
Telugu pothana2000 Pothana2000.ttf 194 KB
Sindhi lateef LateefRegOT.ttf, Lateef font OFL.txt 246 KB

Notes:

  • mPDF's fontdata for most of these defines only the regular style. Garuda has regular, bold, oblique and bold-oblique, and Dhyana has regular and bold. The invoice template uses <strong> (company name, headings), so bold and italic markup must not throw Font "..." is not supported. For each retained family, check which of R/B/I/BI mPDF's fontdata defines. Where a style is missing, or its file is not retained, add a remap in Invoice::get_missing_fontdata() to a retained file. Use the existing dejavusansmono, dejavusans and dejavuserif entries as the pattern. Do not retain Garuda's two oblique files (57 KB each); remap I and BI to R and B.
  • Keep the licence texts listed above next to the fonts they cover. Before retaining each font, confirm it may be redistributed. mPDF already distributes these files, but Garuda, kaputaunicode and Pothana2000 ship without a licence text in ttfonts/. If redistribution terms are unclear for any font, leave it stripped and say so in the PR.

Files

  • scripts/remove-mpdf-fonts.php: remove the listed font and licence file names from $fonts. Add a comment pointing to this issue. Keep a note that retained fonts must keep all four fontdata styles resolvable.
  • inc/invoices/class-invoice.php: remaps in get_missing_fontdata() for missing styles only.
  • tests/WP_Ultimo/Invoices/Invoice_Test.php: extend the existing tests. #2038 added test_get_unsupported_scripts and test_pdf_with_unsupported_script_throws_clear_error. Hebrew and Thai are in those tests as examples of unsupported scripts, so move them to a "supported" assertion and pick a still-unsupported script (for example Devanagari) for the failure case.

Reference patterns: Invoice::get_missing_fontdata() and Invoice::get_unsupported_scripts().

Out of scope (separate decisions, not part of this issue)

  • Devanagari, Bengali, Gujarati, Gurmukhi, Tamil, Malayalam, Oriya, Thaana: mPDF selects freeserif, which is 3.3 MB regular plus 1.3 MB bold (about 4.6 MB for regular and bold). This needs a size decision, or a spike on smaller per-script fonts. Noto per-script fonts are a candidate but have not been tested with mPDF's OpenType shaper.
  • CJK: with +aCJK, mPDF uses non-embedded Adobe CJK fonts, so most viewers and phones show blanks. Embedded fonts are large (Sun-ExtA is 23 MB, UnBatang is 6.9 MB). This is its own decision.
  • Tibetan (jomolhari, 2.3 MB), Syriac (OTF file), Ethiopic (619 KB) and historical scripts.
  • On-demand or downloadable font packs.

Verification

  • For each script in the table, generate a PDF through the real WP_Ultimo\Invoices\Invoice class with sample text in the company name (bold via <strong>) and in a line item title. Render it with pdftoppm and inspect the image for correct glyph shaping, joining and ordering. A PDF header alone is not evidence. Suggested samples are in the #2037 PR body and Invoice_Test.
  • Invoice::get_unsupported_scripts() returns [] for each of these scripts.
  • Bold and italic markup does not throw for any retained family.
  • vendor/bin/phpunit --filter 'Invoice_Test|Email_Manager_Test|Payment_Manager_Test', vendor/bin/phpcs on the changed files, vendor/bin/phpstan analyse, and git diff --check.
  • Measure the packaged size change (du of vendor/mpdf/mpdf/ttfonts/ before and after, and the built ZIP if practical) and record it in the PR. The expected increase is about 1.8 MB uncompressed.
  • composer install --no-dev still ends with only the intended fonts present.
主要语言
PHP
星标
218
派生
87
平均合并
1 天 2 小时
30 天内合并 PR
109

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Ultimate-Multisite/ultimate-multisite 的其他 Issue

查看 Ultimate-Multisite/ultimate-multisite 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。