diff --git a/desktop/Cargo.lock b/desktop/Cargo.lock index 4eb5d1e..dad90fe 100644 --- a/desktop/Cargo.lock +++ b/desktop/Cargo.lock @@ -24,6 +24,21 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "allocator-api2" version = "0.2.21" @@ -54,6 +69,18 @@ version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "boa_ast" version = "0.20.0" @@ -110,7 +137,7 @@ dependencies = [ "static_assertions", "tap", "thin-vec", - "thiserror", + "thiserror 2.0.21", "time", ] @@ -193,6 +220,27 @@ dependencies = [ "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]] name = "bumpalo" version = "3.20.3" @@ -225,6 +273,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + [[package]] name = "cc" version = "1.11.1" @@ -324,6 +378,7 @@ dependencies = [ "rustybuzz", "serde_json", "webpki-roots 0.26.11", + "woff2-patched", ] [[package]] @@ -376,6 +431,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "futures" version = "0.3.34" @@ -1100,6 +1167,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.8" @@ -1249,6 +1322,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "scopeguard" version = "1.2.0" @@ -1431,13 +1515,33 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "thiserror" version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" 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]] @@ -1809,6 +1913,20 @@ dependencies = [ "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]] name = "write16" version = "1.0.0" @@ -1821,6 +1939,15 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "x11-dl" version = "2.21.0" diff --git a/docs/10-roadmap.md b/docs/10-roadmap.md index 041d872..4e3daa6 100644 --- a/docs/10-roadmap.md +++ b/docs/10-roadmap.md @@ -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 | | `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 `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 | Il TLS è l'unica parte del motore con **codice C** (l'assembly di `ring`): il resto diff --git a/engine/Cargo.lock b/engine/Cargo.lock index 8b1170b..bb5f531 100644 --- a/engine/Cargo.lock +++ b/engine/Cargo.lock @@ -24,6 +24,21 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "allocator-api2" version = "0.2.21" @@ -54,6 +69,18 @@ version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "boa_ast" version = "0.20.0" @@ -110,7 +137,7 @@ dependencies = [ "static_assertions", "tap", "thin-vec", - "thiserror", + "thiserror 2.0.21", "time", ] @@ -193,6 +220,27 @@ dependencies = [ "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]] name = "bumpalo" version = "3.20.3" @@ -225,6 +273,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + [[package]] name = "cc" version = "1.11.1" @@ -314,6 +368,7 @@ dependencies = [ "rustybuzz", "serde_json", "webpki-roots 0.26.11", + "woff2-patched", ] [[package]] @@ -366,6 +421,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "futures-core" version = "0.3.34" @@ -942,6 +1009,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.8" @@ -1076,6 +1149,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "scopeguard" version = "1.2.0" @@ -1235,13 +1319,33 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "thiserror" version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" 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]] @@ -1553,6 +1657,20 @@ dependencies = [ "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]] name = "write16" version = "1.0.0" @@ -1565,6 +1683,15 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "yoke" version = "0.7.5" diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 0894a83..4b97ee3 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -41,6 +41,7 @@ png = "0.17" # shaping (kerning, legature): port Rust di HarfBuzz, nessuna dipendenza C rustybuzz = { version = "0.20.1", default-features = false, features = ["std"] } serde_json = "1" +woff2-patched = "0.4.0" [profile.release] opt-level = 3 diff --git a/engine/README.md b/engine/README.md index f665a90..70b29fa 100644 --- a/engine/README.md +++ b/engine/README.md @@ -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` | | 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` | -| 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`): diff --git a/engine/cases/prova.woff2 b/engine/cases/prova.woff2 new file mode 100644 index 0000000..9e5a00f Binary files /dev/null and b/engine/cases/prova.woff2 differ diff --git a/engine/src/font.rs b/engine/src/font.rs index 3e6827a..5b97877 100644 --- a/engine/src/font.rs +++ b/engine/src/font.rs @@ -78,8 +78,15 @@ impl FontHolder { // WOFF e WOFF2 sono contenitori compressi: servirebbe un decompressore // (brotli per WOFF2). Meglio dirlo che riportare «font illeggibile», che // 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") { - 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") { return Err("WOFF non supportato: usare TTF o OTF".to_string()); diff --git a/engine/tests/woff2.rs b/engine/tests/woff2.rs new file mode 100644 index 0000000..f2a4445 --- /dev/null +++ b/engine/tests/woff2.rs @@ -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 { + 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 + ); +} diff --git a/harbour-mosaic/rpm/harbour-mosaic.spec b/harbour-mosaic/rpm/harbour-mosaic.spec index 389a258..99199dd 100644 --- a/harbour-mosaic/rpm/harbour-mosaic.spec +++ b/harbour-mosaic/rpm/harbour-mosaic.spec @@ -1,6 +1,6 @@ Name: harbour-mosaic Summary: Mosaic browser with an independent rendering engine -Version: 0.8.17 +Version: 0.8.18 Release: 1 Group: Qt/Qt 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. %changelog +* Thu Nov 12 2026 Carlo Baratto - 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 - 0.8.17-1 - Conformita' del tokenizer misurata sul corpus html5lib: 93,88% (era il 48,42% al primo giro). Soglia 93% in CI