From 538dddf9538d1ff5837dc3d1d795ee053f917b07 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Mar 2023 13:04:16 +0200 Subject: [PATCH] Update fontdb since resvg depends on the newer one --- Cargo.toml | 1 + internal/compiler/Cargo.toml | 4 ++-- internal/compiler/passes/embed_glyphs.rs | 6 +++--- internal/core/Cargo.toml | 6 +++--- internal/core/software_renderer/fonts/systemfonts.rs | 4 ++-- internal/core/textlayout/shaping.rs | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cbf74b586af..7f988e82cf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,6 +88,7 @@ rust-version = "1.66" [workspace.dependencies] resvg = { version= "0.30.0", default-features = false } +fontdb = { version = "0.13", features = ["fontconfig"] } [profile.release] lto = true diff --git a/internal/compiler/Cargo.toml b/internal/compiler/Cargo.toml index 498199471c1..2aad0cbd817 100644 --- a/internal/compiler/Cargo.toml +++ b/internal/compiler/Cargo.toml @@ -28,7 +28,7 @@ proc_macro_span = ["quote", "proc-macro2"] display-diagnostics = ["codemap", "codemap-diagnostic"] # Enabled the support to render images and font in the binary -software-renderer = ["image", "dep:resvg", "fontdb", "fontdue", "libc", "yeslogic-fontconfig-sys"] +software-renderer = ["image", "dep:resvg", "dep:fontdb", "fontdue", "libc", "yeslogic-fontconfig-sys"] [dependencies] @@ -58,7 +58,7 @@ linked_hash_set = "0.1.4" image = { version = "0.24", optional = true } resvg = { workspace = true, optional = true } # font embedding -fontdb = { version = "0.12", features = ["fontconfig"], optional = true } +fontdb = { workspace = true, optional = true } fontdue = { version = "0.7.1", optional = true } [target.'cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios", target_arch = "wasm32")))'.dependencies] diff --git a/internal/compiler/passes/embed_glyphs.rs b/internal/compiler/passes/embed_glyphs.rs index 4754a84cc82..5cacf637ed1 100644 --- a/internal/compiler/passes/embed_glyphs.rs +++ b/internal/compiler/passes/embed_glyphs.rs @@ -100,7 +100,7 @@ pub fn embed_glyphs<'a>( let face_count = fontdb.len(); match fontdb.load_font_file(path) { Ok(()) => { - fontdb.faces().get(face_count).map(|face_info| face_info.id) + fontdb.faces().nth(face_count).map(|face_info| face_info.id) }, Err(err) => { diag.push_error( @@ -126,11 +126,11 @@ pub fn embed_glyphs<'a>( // add custom fonts for doc in all_docs { for (font_path, import_token) in doc.custom_fonts.iter() { - let face_count = fontdb.faces().len(); + let face_count = fontdb.faces().count(); if let Err(e) = fontdb.load_font_file(&font_path) { diag.push_error(format!("Error loading font: {}", e), import_token); } else { - custom_fonts.extend(fontdb.faces()[face_count..].iter().map(|info| info.id)) + custom_fonts.extend(fontdb.faces().skip(face_count).map(|info| info.id)) } } } diff --git a/internal/core/Cargo.toml b/internal/core/Cargo.toml index 820c90a5432..e87fdb12fc4 100644 --- a/internal/core/Cargo.toml +++ b/internal/core/Cargo.toml @@ -31,7 +31,7 @@ unsafe-single-threaded = [] unicode = ["unicode-script", "unicode-linebreak"] -software-renderer-systemfonts = ["fontdb", "rustybuzz", "fontdue"] +software-renderer-systemfonts = ["dep:fontdb", "rustybuzz", "fontdue"] image-decoders = ["image", "clru"] svg = ["dep:resvg"] @@ -85,7 +85,7 @@ wasm-bindgen = { version = "0.2" } web-sys = { version = "0.3", features = [ "HtmlImageElement" ] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -fontdb = { version = "0.12", optional = true, features = ["memmap", "fontconfig"] } +fontdb = { workspace = true, optional = true, features = ["memmap"] } rustybuzz = { version = "0.7.0", optional = true } fontdue = { version = "0.7.1", optional = true } @@ -94,7 +94,7 @@ slint = { path = "../../api/rs/slint", default-features = false, features = ["st i-slint-backend-testing = { path="../backends/testing" } rustybuzz = "0.7.0" ttf-parser = "0.18.0" -fontdb = { version = "0.12.0" } +fontdb = { workspace = true } image = { version = "0.24.0", default-features = false, features = [ "png" ] } pin-weak = "1" diff --git a/internal/core/software_renderer/fonts/systemfonts.rs b/internal/core/software_renderer/fonts/systemfonts.rs index cffc3b297e2..5baffeeff1c 100644 --- a/internal/core/software_renderer/fonts/systemfonts.rs +++ b/internal/core/software_renderer/fonts/systemfonts.rs @@ -45,11 +45,11 @@ fn init_fontdb() -> FontDatabase { let face_count = db.len(); match db.load_font_file(path) { Ok(()) => { - db.faces().get(face_count).map(|face_info| face_info.id) + db.faces().nth(face_count).map(|face_info| face_info.id) }, Err(err) => { eprintln!( - "Could not load the font set via `SLINT_DEFAULT_FONT`: {}: {}", path.display(), err, + "Could not load the font set via `SLINT_DEFAULT_FONT`: {}: {}", path.display(), err, ); None }, diff --git a/internal/core/textlayout/shaping.rs b/internal/core/textlayout/shaping.rs index 0e965642c7a..406aa87d928 100644 --- a/internal/core/textlayout/shaping.rs +++ b/internal/core/textlayout/shaping.rs @@ -302,7 +302,7 @@ fn with_dejavu_font(mut callback: impl FnMut(&rustybuzz::Face<'_>) -> R) -> O .iter() .collect(); fontdb.load_font_file(dejavu_path).expect("unable to load test dejavu font"); - let font_id = fontdb.faces()[0].id; + let font_id = fontdb.faces().next().unwrap().id; fontdb.with_face_data(font_id, |data, font_index| { let face = rustybuzz::Face::from_slice(data, font_index).expect("unable to parse dejavu font");