Skip to content

Commit

Permalink
fix(cli): icon should render explicit svg text node fonts (fix: #10022)…
Browse files Browse the repository at this point in the history
… (#10039)

* fix(cli): icon should render explicit svg text node fonts (fix: #10022)

* fix(cli): icon should render explicit svg text node fonts (fix: #10022)

added a .change file for the fix
  • Loading branch information
roylaurie authored Jun 12, 2024
1 parent f56cdc9 commit 79542f4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 52 deletions.
7 changes: 7 additions & 0 deletions .changes/fix-cli-icon-svg-render-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri-cli": "patch:bug"
"@tauri-apps/cli": "patch:bug"
---

Fixed an issue that prevented `tauri icon` from rendering `<text>` nodes in SVG files.

92 changes: 42 additions & 50 deletions tooling/cli/Cargo.lock

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

2 changes: 1 addition & 1 deletion tooling/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ serde-value = "0.7.0"
itertools = "0.12"
local-ip-address = "0.6"
css-color = "0.2"
resvg = "0.40.0"
resvg = "0.42.0"
dunce = "1"
glob = "0.3"

Expand Down
7 changes: 6 additions & 1 deletion tooling/cli/src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::{
io::{BufWriter, Write},
path::{Path, PathBuf},
str::FromStr,
sync::Arc,
};

use anyhow::Context;
Expand Down Expand Up @@ -117,16 +118,20 @@ pub fn command(options: Options) -> Result<()> {
let source = if let Some(extension) = input.extension() {
if extension == "svg" {
let rtree = {
let mut fontdb = usvg::fontdb::Database::new();
fontdb.load_system_fonts();

let opt = usvg::Options {
// Get file's absolute directory.
resources_dir: std::fs::canonicalize(&input)
.ok()
.and_then(|p| p.parent().map(|p| p.to_path_buf())),
fontdb: Arc::new(fontdb),
..Default::default()
};

let svg_data = std::fs::read(&input).unwrap();
usvg::Tree::from_data(&svg_data, &opt, &Default::default()).unwrap()
usvg::Tree::from_data(&svg_data, &opt).unwrap()
};

Source::Svg(rtree)
Expand Down

0 comments on commit 79542f4

Please sign in to comment.