WOFF2: i font web si caricano

Il buco visivo più grande su ogni sito reale: `@font-face { src: url(...woff2) }`
finiva in `parse_errors` con «WOFF2 non supportato» e la pagina usava il font di
ripiego. Senza i font giusti un sito sembra sempre rotto, anche se il resto è a
posto.

WOFF2 non è un contenitore da sgonfiare: i dati sono compressi con brotli **e** le
tabelle `glyf`/`loca` sono trasformate, quindi vanno ricostruite. Serve un vero
decodificatore.

- `woff2 0.3.0` non compila: `safer-bytes` ha cambiato API e la crate è rimasta
  indietro (`Base128Error` non converte più `TryGetError`). Il fork
  `woff2-patched 0.4.0` esiste per questo e compila
- è Rust puro (brotli + thiserror + bytes): il cross-build aarch64 resta senza C,
  come il resto del motore
- `FontHolder::load_bytes` riconosce `wOF2`, decodifica a TTF e rientra: sotto
  c'è lo stesso percorso di un file TTF, nessun caso speciale a valle
- WOFF (versione 1, zlib) resta fuori: è raro e l'errore lo dice

Due test (`tests/woff2.rs`) su un WOFF2 vero (DM Sans, 29 KB, in `cases/`):
decodifica con metriche sensate e glifi veri (nessun `.notdef`), e un file
troncato che fallisce con un messaggio che nomina il WOFF2.

Verifiche oltre i test:
- il blog dell'utente passa da **10 errori di parsing a 0** e usa i font del tema
  (DM Sans per il sans, Source Serif per il serif, niente quadratini)
- il renderer compilato **per aarch64**, eseguito sotto qemu, decodifica lo stesso
  WOFF2 e disegna il testo: la decodifica funziona sull'architettura del telefono,
  non solo su x86
- l'AppImage 0.5.20 mostra il blog con i font del tema
This commit is contained in:
Carlo Baratto committed 2026-11-13 16:06:27 +01:00
1 parent e2b238d424
commit 87d763b1da
9 files changed
+333 -8

No files matched your search

+129 -2
View File
@@ -24,6 +24,21 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "alloc-no-stdlib"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
[[package]]
name = "alloc-stdlib"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195"
dependencies = [
"alloc-no-stdlib",
]
[[package]] [[package]]
name = "allocator-api2" name = "allocator-api2"
version = "0.2.21" version = "0.2.21"
@@ -54,6 +69,18 @@ version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "bitvec"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]] [[package]]
name = "boa_ast" name = "boa_ast"
version = "0.20.0" version = "0.20.0"
@@ -110,7 +137,7 @@ dependencies = [
"static_assertions", "static_assertions",
"tap", "tap",
"thin-vec", "thin-vec",
"thiserror", "thiserror 2.0.21",
"time", "time",
] ]
@@ -193,6 +220,27 @@ dependencies = [
"static_assertions", "static_assertions",
] ]
[[package]]
name = "brotli"
version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
"brotli-decompressor",
]
[[package]]
name = "brotli-decompressor"
version = "4.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a334ef7c9e23abf0ce748e8cd309037da93e606ad52eb372e4ce327a0dcfbdfd"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.20.3" version = "3.20.3"
@@ -225,6 +273,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.11.1" version = "1.11.1"
@@ -324,6 +378,7 @@ dependencies = [
"rustybuzz", "rustybuzz",
"serde_json", "serde_json",
"webpki-roots 0.26.11", "webpki-roots 0.26.11",
"woff2-patched",
] ]
[[package]] [[package]]
@@ -376,6 +431,18 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "four-cc"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "795cbfc56d419a7ce47ccbb7504dd9a5b7c484c083c356e797de08bd988d9629"
[[package]]
name = "funty"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.34" version = "0.3.34"
@@ -1100,6 +1167,12 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "radium"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.8" version = "0.8.8"
@@ -1249,6 +1322,17 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04d056b875a9d2e6cb9a61d127afee9ac5999b9f87bcb32079d1318e505be714" checksum = "04d056b875a9d2e6cb9a61d127afee9ac5999b9f87bcb32079d1318e505be714"
[[package]]
name = "safer-bytes"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9814c78d534f27a438fcb57091d6deed0634b60e4e500fee28fe5990adf5ea54"
dependencies = [
"bytes",
"paste",
"thiserror 1.0.69",
]
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.2.0" version = "1.2.0"
@@ -1431,13 +1515,33 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6a4b9ba8738cb4a4f399d37e266becfd475e75eb73425b87a05a2f2039ba63e" checksum = "d6a4b9ba8738cb4a4f399d37e266becfd475e75eb73425b87a05a2f2039ba63e"
[[package]]
name = "thiserror"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl 1.0.69",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.21" version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl 2.0.21",
]
[[package]]
name = "thiserror-impl"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
] ]
[[package]] [[package]]
@@ -1809,6 +1913,20 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "woff2-patched"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb9e0d17aedee2afac15749407e107edce8485f57b7ad9fb929f0bbdf2c28f24"
dependencies = [
"bitvec",
"brotli",
"bytes",
"four-cc",
"safer-bytes",
"thiserror 1.0.69",
]
[[package]] [[package]]
name = "write16" name = "write16"
version = "1.0.0" version = "1.0.0"
@@ -1821,6 +1939,15 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "wyz"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [
"tap",
]
[[package]] [[package]]
name = "x11-dl" name = "x11-dl"
version = "2.21.0" version = "2.21.0"
+1 -1
View File
@@ -96,7 +96,7 @@ locale vero, più una prova manuale su `https://example.com`):
| `@import` (anche annidati, con rilevamento dei cicli e media query) | **fatto** (M2.6c): la base è l'indirizzo del foglio, non della pagina | | `@import` (anche annidati, con rilevamento dei cicli e media query) | **fatto** (M2.6c): la base è l'indirizzo del foglio, non della pagina |
| `srcset` | **fatto** (M2.6c): `Nx` sceglie per densità dello schermo, `Nw` per larghezza dichiarata | | `srcset` | **fatto** (M2.6c): `Nx` sceglie per densità dello schermo, `Nw` per larghezza dichiarata |
| `@font-face` con `url()` remoto o relativo al documento | **fatto** (M2.6c): si scarica come una sotto-risorsa | | `@font-face` con `url()` remoto o relativo al documento | **fatto** (M2.6c): si scarica come una sotto-risorsa |
| Font `WOFF`/`WOFF2` | **mancano**: sono contenitori compressi (WOFF2 con brotli) e vanno ricostruiti, non solo decompressi. L'errore lo dice esplicitamente invece di riportare «font illeggibile» | | Font `WOFF2` | **fatto** (M2.13): decodifica completa con `woff2-patched` (Rust puro, nessuna dipendenza C). Il blog dell'utente passa da 10 errori a **0** e usa i font del tema. `WOFF` (versione 1, zlib) resta fuori: è raro e l'errore lo dice |
| Sotto-risorse ancora mancanti | `image-set()`, `@import` con `layer()`/`supports()`: l'errore è riportato in `resource_errors`, non silenzioso | | Sotto-risorse ancora mancanti | `image-set()`, `@import` con `layer()`/`supports()`: l'errore è riportato in `resource_errors`, non silenzioso |
Il TLS è l'unica parte del motore con **codice C** (l'assembly di `ring`): il resto Il TLS è l'unica parte del motore con **codice C** (l'assembly di `ring`): il resto
+129 -2
View File
@@ -24,6 +24,21 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "alloc-no-stdlib"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
[[package]]
name = "alloc-stdlib"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195"
dependencies = [
"alloc-no-stdlib",
]
[[package]] [[package]]
name = "allocator-api2" name = "allocator-api2"
version = "0.2.21" version = "0.2.21"
@@ -54,6 +69,18 @@ version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "bitvec"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]] [[package]]
name = "boa_ast" name = "boa_ast"
version = "0.20.0" version = "0.20.0"
@@ -110,7 +137,7 @@ dependencies = [
"static_assertions", "static_assertions",
"tap", "tap",
"thin-vec", "thin-vec",
"thiserror", "thiserror 2.0.21",
"time", "time",
] ]
@@ -193,6 +220,27 @@ dependencies = [
"static_assertions", "static_assertions",
] ]
[[package]]
name = "brotli"
version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
"brotli-decompressor",
]
[[package]]
name = "brotli-decompressor"
version = "4.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a334ef7c9e23abf0ce748e8cd309037da93e606ad52eb372e4ce327a0dcfbdfd"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.20.3" version = "3.20.3"
@@ -225,6 +273,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.11.1" version = "1.11.1"
@@ -314,6 +368,7 @@ dependencies = [
"rustybuzz", "rustybuzz",
"serde_json", "serde_json",
"webpki-roots 0.26.11", "webpki-roots 0.26.11",
"woff2-patched",
] ]
[[package]] [[package]]
@@ -366,6 +421,18 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "four-cc"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "795cbfc56d419a7ce47ccbb7504dd9a5b7c484c083c356e797de08bd988d9629"
[[package]]
name = "funty"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.34" version = "0.3.34"
@@ -942,6 +1009,12 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "radium"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.8" version = "0.8.8"
@@ -1076,6 +1149,17 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04d056b875a9d2e6cb9a61d127afee9ac5999b9f87bcb32079d1318e505be714" checksum = "04d056b875a9d2e6cb9a61d127afee9ac5999b9f87bcb32079d1318e505be714"
[[package]]
name = "safer-bytes"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9814c78d534f27a438fcb57091d6deed0634b60e4e500fee28fe5990adf5ea54"
dependencies = [
"bytes",
"paste",
"thiserror 1.0.69",
]
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.2.0" version = "1.2.0"
@@ -1235,13 +1319,33 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6a4b9ba8738cb4a4f399d37e266becfd475e75eb73425b87a05a2f2039ba63e" checksum = "d6a4b9ba8738cb4a4f399d37e266becfd475e75eb73425b87a05a2f2039ba63e"
[[package]]
name = "thiserror"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl 1.0.69",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.21" version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl 2.0.21",
]
[[package]]
name = "thiserror-impl"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
] ]
[[package]] [[package]]
@@ -1553,6 +1657,20 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "woff2-patched"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb9e0d17aedee2afac15749407e107edce8485f57b7ad9fb929f0bbdf2c28f24"
dependencies = [
"bitvec",
"brotli",
"bytes",
"four-cc",
"safer-bytes",
"thiserror 1.0.69",
]
[[package]] [[package]]
name = "write16" name = "write16"
version = "1.0.0" version = "1.0.0"
@@ -1565,6 +1683,15 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "wyz"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [
"tap",
]
[[package]] [[package]]
name = "yoke" name = "yoke"
version = "0.7.5" version = "0.7.5"
+1
View File
@@ -41,6 +41,7 @@ png = "0.17"
# shaping (kerning, legature): port Rust di HarfBuzz, nessuna dipendenza C # shaping (kerning, legature): port Rust di HarfBuzz, nessuna dipendenza C
rustybuzz = { version = "0.20.1", default-features = false, features = ["std"] } rustybuzz = { version = "0.20.1", default-features = false, features = ["std"] }
serde_json = "1" serde_json = "1"
woff2-patched = "0.4.0"
[profile.release] [profile.release]
opt-level = 3 opt-level = 3
+3 -1
View File
@@ -60,7 +60,9 @@ Nessun codice di WebKit, Blink, Gecko o Servo: parser, cascata, layout e raster
| Immagini: `max-width` applicato, `height:auto` segue il rapporto (attributi o intrinseco) | fatto | `Layout::dimensioni_immagine` | | Immagini: `max-width` applicato, `height:auto` segue il rapporto (attributi o intrinseco) | fatto | `Layout::dimensioni_immagine` |
| Rete: `GET` http/https con TLS, chunked, reindirizzamenti, limiti | fatto in parte (M2.6) | `src/net.rs`, `render --url`, `desktop --url` | | Rete: `GET` http/https con TLS, chunked, reindirizzamenti, limiti | fatto in parte (M2.6) | `src/net.rs`, `render --url`, `desktop --url` |
| Sotto-risorse dalla rete: `link[rel=stylesheet]` e `img[src]` | fatto (M2.6) | `src/resource.rs`, `tests/risorse.rs` | | Sotto-risorse dalla rete: `link[rel=stylesheet]` e `img[src]` | fatto (M2.6) | `src/resource.rs`, `tests/risorse.rs` |
| WPT (`html/syntax/parsing` ≥ 90 %) | mancante | — | | WPT (`html/syntax/parsing` ≥ 90 %) | **misurato**: corpus `html5lib-tests` al 93,88%, soglia 93% in CI (M2.12) | `src/bin/wpt.rs`, `cases/html5lib/` |
| Entità HTML nominate: 2231 voci generate dal WHATWG | fatto (M2.12) | `src/entita_tabelle.rs` |
| Font WOFF2 (brotli + ricostruzione `glyf`/`loca`) | fatto (M2.13) | `src/font.rs`, `woff2-patched` |
Esito della build del 2026-11-11 (`harbour-mosaic/scripts/build.sh aarch64`): Esito della build del 2026-11-11 (`harbour-mosaic/scripts/build.sh aarch64`):
Binary file not shown.
+8 -1
View File
@@ -78,8 +78,15 @@ impl FontHolder {
// WOFF e WOFF2 sono contenitori compressi: servirebbe un decompressore // WOFF e WOFF2 sono contenitori compressi: servirebbe un decompressore
// (brotli per WOFF2). Meglio dirlo che riportare «font illeggibile», che // (brotli per WOFF2). Meglio dirlo che riportare «font illeggibile», che
// manda a cercare un difetto dove c'è solo una funzionalità assente. // manda a cercare un difetto dove c'è solo una funzionalità assente.
// WOFF2 è un contenitore: brotli per i dati e tabelle `glyf`/`loca`
// trasformate, da ricostruire. Non è "sgonfiare e via": ci pensa
// `woff2`, port Rust puro (nessuna dipendenza C, quindi il cross-build
// aarch64 resta semplice). Il risultato è un TTF, che si carica sotto.
if data.starts_with(b"wOF2") { if data.starts_with(b"wOF2") {
return Err("WOFF2 non supportato (serve brotli): usare TTF o OTF".to_string()); match woff2_patched::convert_woff2_to_ttf(&mut &data[..]) {
Ok(ttf) => return Self::load_bytes(nome, ttf),
Err(e) => return Err(format!("WOFF2 illeggibile: {}", e)),
}
} }
if data.starts_with(b"wOFF") { if data.starts_with(b"wOFF") {
return Err("WOFF non supportato: usare TTF o OTF".to_string()); return Err("WOFF non supportato: usare TTF o OTF".to_string());
+55
View File
@@ -0,0 +1,55 @@
//! WOFF2: il formato con cui arriva quasi ogni font web.
//!
//! Non è un contenitore da sgonfiare: i dati sono compressi con brotli **e** le
//! tabelle `glyf`/`loca` sono trasformate, quindi vanno ricostruite. Prima di
//! questo, ogni `@font-face` di un sito vero finiva in `parse_errors` con
//! «WOFF2 non supportato» e la pagina usava il font di ripiego.
use std::path::PathBuf;
fn font_di_prova() -> Vec<u8> {
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
p.push("cases/prova.woff2");
std::fs::read(p).expect("font WOFF2 di prova")
}
#[test]
fn un_woff2_vero_si_decodifica_e_compone() {
let dati = font_di_prova();
assert!(
dati.starts_with(b"wOF2"),
"il file di prova deve essere un WOFF2"
);
let font = engine::FontHolder::load_bytes(std::path::Path::new("prova.woff2"), dati)
.expect("il WOFF2 deve decodificarsi");
// metriche sensate: se la decodifica fosse parziale il font sarebbe vuoto
assert!(font.ascent(16.0) > 0.0, "ascendente non valida");
assert!(font.descent(16.0) > 0.0, "discendente non valida");
// e deve produrre glifi veri, non `.notdef`
let shaped = font.shape("Prova", 16.0);
assert!(!shaped.glyphs.is_empty(), "nessun glifo composto");
assert!(
shaped.glyphs.iter().all(|g| g.id != 0),
"ci sono glifi .notdef: la decodifica non è completa"
);
assert!(
shaped.width > 10.0,
"larghezza implausibile: {}",
shaped.width
);
}
#[test]
fn un_woff2_troncato_fallisce_con_un_messaggio() {
let dati = font_di_prova();
let tagliato = dati[..dati.len() / 2].to_vec();
let esito = engine::FontHolder::load_bytes(std::path::Path::new("rotto.woff2"), tagliato);
let errore = esito.err().expect("un WOFF2 troncato non deve passare");
assert!(
errore.contains("WOFF2"),
"il messaggio deve dire che è un problema del WOFF2: {}",
errore
);
}
+7 -1
View File
@@ -1,6 +1,6 @@
Name: harbour-mosaic Name: harbour-mosaic
Summary: Mosaic browser with an independent rendering engine Summary: Mosaic browser with an independent rendering engine
Version: 0.8.17 Version: 0.8.18
Release: 1 Release: 1
Group: Qt/Qt Group: Qt/Qt
License: MIT License: MIT
@@ -21,6 +21,12 @@ engine written from scratch (no WebKit, Blink, Gecko or Servo code).
Milestone M0: HTML parsing, CSS cascade, block layout and CPU raster. Milestone M0: HTML parsing, CSS cascade, block layout and CPU raster.
%changelog %changelog
* Thu Nov 12 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.8.18-1
- WOFF2: i font web si caricano. Decodifica completa (brotli + ricostruzione di
glyf/loca) con woff2-patched, Rust puro: il cross-build aarch64 resta senza C
- Prima ogni @font-face di un sito vero finiva in errore e la pagina usava il
font di ripiego. Il blog di prova passa da 10 errori a 0
* Thu Nov 12 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.8.17-1 * Thu Nov 12 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.8.17-1
- Conformita' del tokenizer misurata sul corpus html5lib: 93,88% (era il 48,42% - Conformita' del tokenizer misurata sul corpus html5lib: 93,88% (era il 48,42%
al primo giro). Soglia 93% in CI al primo giro). Soglia 93% in CI