Files
adminandClaude Fable 5 f10cb7df2b
Build Windows portable / build (push) Canceled after 0s
DONG GOI bo font Noto theo app: khong thoa hiep font he thong o bat ky tang nao
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>
2026-08-10 12:12:26 +07:00

48 lines
1.9 KiB
PowerShell

# Tai bo font Noto (hinted static TTF, phu tieng Viet) vao fonts/ o goc
# workspace - app DONG GOI bo font nay de moi may khach hien thi/ghi file
# giong het nhau, khong phu thuoc font cai tren he dieu hanh (chuan Foxit:
# khong thoa hiep thay bang font "gan giong").
#
# Dung: powershell -ExecutionPolicy Bypass -File scripts/fetch-fonts.ps1
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
$fontsDir = Join-Path $root "fonts"
New-Item -ItemType Directory -Force -Path $fontsDir | Out-Null
# notofonts.github.io la repo phat hanh chinh thuc cac ban static hinted.
$base = "https://github.com/notofonts/notofonts.github.io/raw/main/fonts"
$files = @(
"NotoSans/hinted/ttf/NotoSans-Regular.ttf",
"NotoSans/hinted/ttf/NotoSans-Bold.ttf",
"NotoSans/hinted/ttf/NotoSans-Italic.ttf",
"NotoSans/hinted/ttf/NotoSans-BoldItalic.ttf",
"NotoSansMono/hinted/ttf/NotoSansMono-Regular.ttf",
"NotoSansMono/hinted/ttf/NotoSansMono-Bold.ttf",
"NotoSerif/hinted/ttf/NotoSerif-Regular.ttf",
"NotoSerif/hinted/ttf/NotoSerif-Bold.ttf",
"NotoSerif/hinted/ttf/NotoSerif-Italic.ttf",
"NotoSerif/hinted/ttf/NotoSerif-BoldItalic.ttf"
)
foreach ($f in $files) {
$name = Split-Path -Leaf $f
$dest = Join-Path $fontsDir $name
if ((Test-Path $dest) -and ((Get-Item $dest).Length -gt 100000)) {
Write-Output "Da co: $name"
continue
}
Write-Output "Tai $name..."
Invoke-WebRequest -Uri "$base/$f" -OutFile $dest -UseBasicParsing
if ((Get-Item $dest).Length -lt 100000) { throw "File $name qua nho - tai hong?" }
}
# Giay phep OFL di kem khi phan phoi font.
$ofl = Join-Path $fontsDir "OFL-LICENSE.txt"
if (-not (Test-Path $ofl)) {
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/google/fonts/main/ofl/notosans/OFL.txt" -OutFile $ofl -UseBasicParsing
}
Get-ChildItem $fontsDir | ForEach-Object { "{0} {1:N0} bytes" -f $_.Name, $_.Length } | Write-Output
Write-Output "Xong. Fonts tai: $fontsDir"