Skip to content

Commit 948c590

Browse files
authored
Merge pull request #64 from LaurenzV/text-new
Add support for text embedding and refactor crate structure a bit.
2 parents 97274ce + 3a0e597 commit 948c590

438 files changed

Lines changed: 4324 additions & 3798 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ 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.
20+
- TODO: Add CI test to test builds with different feature
21+
- TODO: Add text feature?
922

1023
### Changed
1124
- Bumped resvg to v0.40.

Cargo.lock

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

Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +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 = { version = "0.40", 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-
resvg = "0.40"
30+
unicode-properties = "0.1.1"
31+
resvg = {git = "https://github.com/RazrFalcon/resvg"}
32+
subsetter = "0.1.1"
33+
ttf-parser = { version = "0.20.0" }
34+
siphasher = { version = "1.0.1"}
3135

3236
[package]
3337
name = "svg2pdf"
@@ -49,6 +53,7 @@ image = ["dep:image"]
4953
filters = ["image", "dep:tiny-skia", "dep:resvg"]
5054

5155
[dependencies]
56+
unicode-properties = { workspace = true }
5257
miniz_oxide = { workspace = true }
5358
once_cell = { workspace = true }
5459
pdf-writer = { workspace = true }
@@ -57,3 +62,7 @@ log = { workspace = true }
5762
image = { workspace = true, optional = true }
5863
tiny-skia = {workspace = true, optional = true }
5964
resvg = {workspace = true, optional = true }
65+
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() });
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)