Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ async-std = "1.0"
bitflags = "2.5"
bytemuck = { version = "1.0", features = ["derive"] }
bytes = "1.6"
cosmic-text = "0.19"
cryoglyph = { git = "https://github.com/iced-rs/cryoglyph.git", rev = "e429a025df36ab8145708acb309080ae3deec17a" }
cosmic-text = { git = "https://github.com/pop-os/cosmic-text.git", rev = "4fe1195e6451d6aaa3dc383895d6fd366ea9fc7b" }
cryoglyph = { git = "https://github.com/pop-os/glyphon.git", rev = "273130949ef4ffc652e3d5e5255219f1f079868e" }
dark-light = "1.0"
resvg = "0.45"
web-sys = "0.3.69"
Expand Down
2 changes: 1 addition & 1 deletion graphics/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn font_system() -> &'static RwLock<FontSystem> {

FONT_SYSTEM.get_or_init(|| {
RwLock::new(FontSystem {
raw: cosmic_text::FontSystem::new_with_fonts([
raw: cosmic_text::FontSystem::new_with_fonts_and_cache([
cosmic_text::fontdb::Source::Binary(Arc::new(
include_bytes!("../fonts/Iced-Icons.ttf").as_slice(),
)),
Expand Down
12 changes: 7 additions & 5 deletions wgpu/src/image/vector.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::core::svg;
use crate::core::{Color, Size};
use crate::graphics::text;
use crate::image::atlas::{self, Atlas};

use resvg::tiny_skia;
Expand Down Expand Up @@ -40,6 +41,7 @@ pub struct Cache {
rasterized_hits: FxHashSet<(u64, u32, u32, ColorFilter)>,
should_trim: bool,
fontdb: Option<Arc<usvg::fontdb::Database>>,
fontdb_version: Option<text::Version>,
}

type ColorFilter = Option<[u8; 4]>;
Expand All @@ -51,12 +53,12 @@ impl Cache {
return self.svgs.get(&handle.id()).unwrap();
}

// TODO: Reuse `cosmic-text` font database
if self.fontdb.is_none() {
let mut fontdb = usvg::fontdb::Database::new();
fontdb.load_system_fonts();
let font_system = text::font_system().read().expect("Read font system");
let version = font_system.version();

self.fontdb = Some(Arc::new(fontdb));
if self.fontdb_version != Some(version) {
self.fontdb = Some(Arc::new(font_system.db().clone()));
self.fontdb_version = Some(version);
}

let options = usvg::Options {
Expand Down