fonts: Use fontations to read the OS/2 table of DirectWrite fonts (#38851)

Instead of copying the font table data in memory and parsing it with the
`truetype` crate, use a non-copying API from DirectWrite to implement a
`fontations` `TableProvider`. This has two benefits:

- We remove the dependency on the `truetype` crate finally.
- We do not have to make an in-memory copy of the table data when
  parsing the table.

The hope is that the `TableProvider` will be more generally useful in
the future.

Testing: There are no automated tests for Windows, but I manually
verified
that the data retrived via `fontations` matched that retrived by
`truetype`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-22 09:23:35 -07:00 committed by GitHub
parent 176e42d36d
commit 777373054f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 107 additions and 116 deletions

17
Cargo.lock generated
View file

@ -2708,11 +2708,11 @@ dependencies = [
"stylo",
"stylo_atoms",
"tracing",
"truetype",
"unicode-properties",
"unicode-script",
"url",
"webrender_api",
"winapi",
"xml-rs",
"yeslogic-fontconfig-sys",
]
@ -8988,15 +8988,6 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce607aae8ab0ab3abf3a2723a9ab6f09bb8639ed83fdd888d857b8e556c868d8"
[[package]]
name = "truetype"
version = "0.47.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ce9543b570c6e8a392274b67e1001816bce953aa89724e52a4639db02a10e0"
dependencies = [
"typeface",
]
[[package]]
name = "try-lock"
version = "0.2.5"
@ -9037,12 +9028,6 @@ version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "typeface"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "191ea6762cbcd705fbed8f58573fd6c654453ff3da60adb293d9f255bc92af8e"
[[package]]
name = "typeid"
version = "1.0.3"