Skip to content

Commit 99a91e0

Browse files
committed
Refactor crate structure and clean up
1 parent 597997d commit 99a91e0

66 files changed

Lines changed: 2050 additions & 2125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
- Added support for text embedding.
10+
- The `convert_str` method has been removed. You should now always convert your SVG string into a `usvg`
11+
tree yourself.
12+
- The `convert_tree` method has been renamed into `to_pdf`, and now requires you to provide the fontdb
13+
used for the `usvg` tree.
14+
- `convert_tree_into` has been renamed into `to_chunk` and now returns an independent chunk as well
15+
as the object ID of the SVG.
16+
17+
- TODO: The CLI options have been (temporarily) removed. They will be readded before the next release.
18+
- TODO: Add tests for CLI and svg options
19+
- TODO: Add CLI option to convert text to paths.
920

1021
### Changed
1122
- Bumped resvg to v0.40.

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ oxipng = { version = "9", default-features = false, features = ["filetime", "par
2525
pdf-writer = "0.9"
2626
pdfium-render = "0.8.6"
2727
termcolor = "1.2"
28-
usvg = { path = "../resvg/crates/usvg", default-features = false, features = ["text"] }
28+
usvg = { git = "https://github.com/RazrFalcon/resvg", default-features = false, features = ["text"] }
2929
tiny-skia = "0.11.4"
30-
owned_ttf_parser = "0.20.0"
3130
unicode-properties = "0.1.1"
32-
resvg = {path = "../resvg/crates/resvg"}
31+
resvg = {git = "https://github.com/RazrFalcon/resvg"}
3332
subsetter = "0.1.1"
33+
ttf-parser = { version = "0.20.0" }
34+
siphasher = { version = "1.0.1"}
3435

3536
[package]
3637
name = "svg2pdf"
@@ -57,9 +58,11 @@ miniz_oxide = { workspace = true }
5758
once_cell = { workspace = true }
5859
pdf-writer = { workspace = true }
5960
usvg = { workspace = true }
60-
owned_ttf_parser = { workspace = true }
6161
log = { workspace = true }
6262
image = { workspace = true, optional = true }
6363
tiny-skia = {workspace = true, optional = true }
6464
resvg = {workspace = true, optional = true }
6565
subsetter = { workspace = true }
66+
ttf-parser = { workspace = true }
67+
siphasher = { workspace = true }
68+

cli/src/convert.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ use svg2pdf::Options;
44

55
/// Execute a font listing command.
66
pub fn _convert(command: ConvertCommand) -> Result<(), String> {
7-
convert_(&command.input, command.output, command.dpi)
7+
convert_(&command.input, command.output)
88
}
99

10-
pub fn convert_(
11-
input: &PathBuf,
12-
output: Option<PathBuf>,
13-
dpi: f32,
14-
) -> Result<(), String> {
10+
pub fn convert_(input: &PathBuf, output: Option<PathBuf>) -> Result<(), String> {
1511
if let Ok(()) = log::set_logger(&LOGGER) {
1612
log::set_max_level(log::LevelFilter::Warn);
1713
}
@@ -37,7 +33,7 @@ pub fn convert_(
3733
let tree =
3834
usvg::Tree::from_str(&svg, &options, &fontdb).map_err(|err| err.to_string())?;
3935

40-
let pdf = svg2pdf::convert_tree(&tree, Options { dpi, ..Options::default() }, fontdb);
36+
let pdf = svg2pdf::to_pdf(&tree, Options::default(), fontdb);
4137

4238
std::fs::write(output, pdf).map_err(|_| "Failed to write PDF file")?;
4339

cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn run() -> Result<(), String> {
2222

2323
// If an input argument was provided, convert the svg file to pdf.
2424
if let Some(input) = args.input {
25-
return convert::convert_(&input, args.output, args.dpi);
25+
return convert::convert_(&input, args.output);
2626
};
2727

2828
// Otherwise execute the command provided if any.

0 commit comments

Comments
 (0)