Skip to content

Commit e7372cd

Browse files
committed
Add text to path test
1 parent 654779a commit e7372cd

6 files changed

Lines changed: 1790 additions & 1750 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct Options {
9191
/// Higher values will lead to better quality, but will increase the size of
9292
/// the pdf.
9393
///
94-
/// _Default:_ 1
94+
/// _Default:_ 1.5
9595
pub raster_scale: f32,
9696

9797
/// Whether text should be embedded as actual selectable text inside
@@ -106,7 +106,7 @@ impl Default for Options {
106106
fn default() -> Self {
107107
Self {
108108
compress: false,
109-
raster_scale: 1.0,
109+
raster_scale: 1.5,
110110
embed_text: true,
111111
}
112112
}

tests/ref/api/text_to_paths.png

2.33 KB
Loading

tests/scripts/gen-tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
def main():
8787
test_string = f"// This file was auto-generated by `{Path(__file__).name}`, do not edit manually.\n\n"
8888
test_string += "#![allow(non_snake_case)]\n\n"
89-
test_string += "#[allow(unused_imports)]\nuse crate::run_test;\n\n"
89+
test_string += "#[allow(unused_imports)]\nuse crate::run_test;\nuse svg2pdf::Options;\n"
9090

9191
for p in SVG_DIR.rglob("*"):
9292
if p.is_file() and p.suffix == ".svg":
@@ -107,7 +107,7 @@ def main():
107107

108108
test_string += "#[test] "
109109

110-
test_string += f'fn {function_name}() {{assert_eq!(run_test("{test_file.test_name()}"), 0)}}\n'
110+
test_string += f'fn {function_name}() {{assert_eq!(run_test("{test_file.test_name()}", Options::default()), 0)}}\n'
111111

112112
with open(Path(OUT_PATH), "w") as file:
113113
file.write(test_string)

tests/src/api.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::run_test_impl;
2+
use std::path::Path;
3+
use svg2pdf::Options;
4+
5+
fn run_api_test(svg_path: &Path, test_name: &str, options: Options) {
6+
assert_eq!(
7+
run_test_impl(
8+
Path::new(svg_path),
9+
Path::new(&format!("ref/api/{}.png", test_name)),
10+
Path::new(&format!("diff/api/{}.png", test_name)),
11+
Path::new(&format!("pdf/api/{}.pdf", test_name)),
12+
options
13+
),
14+
0
15+
);
16+
}
17+
18+
#[test]
19+
fn text_to_paths() {
20+
let options = Options { embed_text: false, ..Options::default() };
21+
22+
run_api_test(
23+
Path::new("svg/resvg/text/text/simple-case.svg"),
24+
"text_to_paths",
25+
options,
26+
);
27+
}

0 commit comments

Comments
 (0)