Skip to content

Commit

Permalink
Update fontdb since resvg depends on the newer one
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart committed Mar 28, 2023
1 parent 977b1cc commit 538dddf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions internal/compiler/passes/embed_glyphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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 }

Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions internal/core/software_renderer/fonts/systemfonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion internal/core/textlayout/shaping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ fn with_dejavu_font<R>(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");
Expand Down

0 comments on commit 538dddf

Please sign in to comment.