Skip to content

Commit 79542f4

Browse files
authored
fix(cli): icon should render explicit svg text node fonts (fix: #10022) (#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
1 parent f56cdc9 commit 79542f4

File tree

4 files changed

+56
-52
lines changed

4 files changed

+56
-52
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-cli": "patch:bug"
3+
"@tauri-apps/cli": "patch:bug"
4+
---
5+
6+
Fixed an issue that prevented `tauri icon` from rendering `<text>` nodes in SVG files.
7+

tooling/cli/Cargo.lock

Lines changed: 42 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ serde-value = "0.7.0"
8989
itertools = "0.12"
9090
local-ip-address = "0.6"
9191
css-color = "0.2"
92-
resvg = "0.40.0"
92+
resvg = "0.42.0"
9393
dunce = "1"
9494
glob = "0.3"
9595

tooling/cli/src/icon.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::{
1010
io::{BufWriter, Write},
1111
path::{Path, PathBuf},
1212
str::FromStr,
13+
sync::Arc,
1314
};
1415

1516
use anyhow::Context;
@@ -117,16 +118,20 @@ pub fn command(options: Options) -> Result<()> {
117118
let source = if let Some(extension) = input.extension() {
118119
if extension == "svg" {
119120
let rtree = {
121+
let mut fontdb = usvg::fontdb::Database::new();
122+
fontdb.load_system_fonts();
123+
120124
let opt = usvg::Options {
121125
// Get file's absolute directory.
122126
resources_dir: std::fs::canonicalize(&input)
123127
.ok()
124128
.and_then(|p| p.parent().map(|p| p.to_path_buf())),
129+
fontdb: Arc::new(fontdb),
125130
..Default::default()
126131
};
127132

128133
let svg_data = std::fs::read(&input).unwrap();
129-
usvg::Tree::from_data(&svg_data, &opt, &Default::default()).unwrap()
134+
usvg::Tree::from_data(&svg_data, &opt).unwrap()
130135
};
131136

132137
Source::Svg(rtree)

0 commit comments

Comments
 (0)