DONG GOI bo font Noto theo app: khong thoa hiep font he thong o bat ky tang nao
Build Windows portable / build (push) Canceled after 0s

User yeu cau: khach hang khong co font chuan san — phan mem phai tu chuan bi
font, khong duoc thay bang font "gan giong". Truoc do font nhung cua PDF da
dung cho o sua (build 35), nhung con 3 khe ho roi ve font he thong: font
khong nhung trong PDF, font CFF khong va duoc, va KY TU MOI GO VAO khong co
trong subset (subset chi chua glyph da dung).

- scripts/fetch-fonts.ps1: tai 10 file Noto hinted static (Sans/Serif/Mono,
  du Regular/Bold/Italic/BoldItalic, phu tieng Viet, ~6.7MB) + OFL license
  vao fonts/ (gitignore; CI cache theo hash script).
- CI: fetch fonts + dong fonts/ vao zip portable (canh exe).
- Tauri: main() dat FOFREEXIT_FONTS_PATH (fonts/ canh exe, dev thi goc
  workspace); command app_font_data(kind) tra base64 (whitelist 10 kind).
- UI: FontFace "ff-app-{sans|serif|mono}" dang ky theo weight/style, dung
  GIUA stack: font nhung cua PDF -> Noto dong goi -> stack he thong (luoi
  cuoi). Phan loai serif/sans/mono tu cssFontStack. Nap truoc cung font
  nhung khi vao trang sua.
- Engine find_font_bytes (duong ghi file/reflow can font coverage): uu tien
  tuyet doi fonts/ dong goi qua env — ket qua LUU ra giong nhau tren moi may
  (truoc: lay Arial/Segoe cua Windows, may khach thieu font la khac ket qua).

E2E ke tiep (build 36): go ky tu ngoai subset trong o sua -> 100% glyph phai
tu font custom (nhung/dong goi), 0 glyph he thong.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-10 12:12:26 +07:00
co-authored by Claude Fable 5
parent f6c1bc2070
commit f10cb7df2b
6 changed files with 174 additions and 6 deletions
+15
View File
@@ -293,6 +293,21 @@ fn pdf_text_string(s: &str) -> LoObj {
/// Thử đúng file biến thể (vd `arialbd.ttf`) trước, rồi mới hạ cấp dần về regular
/// của family khác — để FreeText giữ đúng đậm/nghiêng như Foxit.
pub(crate) fn find_font_bytes(bold: bool, italic: bool) -> Option<Vec<u8>> {
// Bộ font ĐÓNG GÓI theo app (Noto — phủ tiếng Việt): ưu tiên tuyệt đối để
// hiển thị/ghi file GIỐNG NHAU trên mọi máy khách, không phụ thuộc font
// của hệ điều hành (không thoả hiệp thay bằng font "gần giống").
// FOFREEXIT_FONTS_PATH do app đặt lúc khởi động (fonts/ cạnh exe).
if let Ok(dir) = std::env::var("FOFREEXIT_FONTS_PATH") {
let name = match (bold, italic) {
(false, false) => "NotoSans-Regular.ttf",
(true, false) => "NotoSans-Bold.ttf",
(false, true) => "NotoSans-Italic.ttf",
(true, true) => "NotoSans-BoldItalic.ttf",
};
if let Ok(bytes) = std::fs::read(std::path::Path::new(&dir).join(name)) {
return Some(bytes);
}
}
#[cfg(windows)]
{
// [regular, bold, italic, bold-italic] cho từng family phổ biến trên Windows.