Skip to content

Commit

Permalink
Rework the font loading in the GL backend
Browse files Browse the repository at this point in the history
The basic idea is to use fontdb's load_system_fonts() mechanism, in
conjunction with its built-in mmap support, to get an overview over all
installed fonts on macOS, Windows and Linux.

This isn't quite perfect in terms of discovering systems defaults, but
it's much faster than font-kit's approach of querying the system (good)
but reading the matched files into memory (not using mmap). And we have
the option of perfecting it by using fontconfig directly on Linux (where
the backend is most important).

This also paves the way for better fallback handling, as now we have a
list of all available families and we can use system APIs to query for
fallbacks.
  • Loading branch information
tronical committed Sep 17, 2021
1 parent a79ee93 commit 6130e04
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 199 deletions.
7 changes: 4 additions & 3 deletions sixtyfps_runtime/rendering_backends/gl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ ttf-parser = "0.12.0"
winit = { version = "0.25", default-features = false }
glutin = { version = "0.27", default-features = false }
glow = { version = "0.11.0", default-features = false }
font-kit = { version = "0.10", features = [] }
fontdb = { version = "0.6.2", features = ["memmap"] }

[target.'cfg(target_family = "windows")'.dependencies]
font-kit = { version = "0.10", features = [] }

[target.'cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios", target_arch = "wasm32")))'.dependencies]
# Require font-config from the system on Linux. Issue #88 indicates that the copy provided by servo-fontconfig may be incompatible
# with distros at times.
servo-fontconfig = { version = "0.5", features = [ "force_system_lib" ] }
# On Windows and macOS we don't need freetype (font-kit has coretext/directwrite backends)
font-kit = { version = "0.10", features = ["loader-freetype"] }
libc = { version = "0.2" }

[target.'cfg(target_os = "macos")'.dependencies]
cocoa = { version = "0.24.0" }
Expand Down
Loading

0 comments on commit 6130e04

Please sign in to comment.