diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8e751ec937fca9bc5aef31c5d59093a851ab6c..6502562aed2ecfcc93d48ccf35b7bb9831b48675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ This changelog also contains an important changes in dependencies. ## [Unreleased] ### Added - (c-api) `RESVG_ERROR_PARSING_FAILED`. +- (c-api) `resvg_options::font_family` and `resvg_options::font_size`. +- (usvg) Default font family and size is configurable now. ### Changed - (c-api) Qt wrapper is header-only now. @@ -18,9 +20,10 @@ This changelog also contains an important changes in dependencies. - (resvg) Recursive SVG images via `image` tag. - (resvg) Bbox calculation of the text with rotate. - (qt-api) SVG from QByteArray loading when data is invalid. +- (usvg) `display` attribute processing. ### Removed -- (rendersvg) `failure`. +- (rendersvg) `failure` dependency. ## [0.3.0] - 2018-05-23 ### Added diff --git a/capi/include/resvg.h b/capi/include/resvg.h index 422d4110b9f2612e302c559b40c55e3dd045fa09..90c05be942d91d0f1b26c83ebc597904d788bf6e 100644 --- a/capi/include/resvg.h +++ b/capi/include/resvg.h @@ -103,6 +103,10 @@ typedef struct resvg_options { const char *path; /** Output DPI. Default: 96. */ double dpi; + /** Default font family. Default: 'Timer New Roman'. */ + const char *font_family; + /** Default font size. Default: 12. */ + double font_size; /** * Fits the image using specified options. * diff --git a/capi/src/lib.rs b/capi/src/lib.rs index 6b86862e9a80bfaa4bedb0ad82528bbdeab9a8ed..9db8ab0fb4c7d0adfa90fef0405dd8b7ae1fd915 100644 --- a/capi/src/lib.rs +++ b/capi/src/lib.rs @@ -30,10 +30,14 @@ use resvg::usvg; use usvg::prelude::*; +const DEFAULT_FONT_FAMILY: &str = "Times New Roman"; + #[repr(C)] pub struct resvg_options { pub path: *const c_char, pub dpi: f64, + pub font_family: *const c_char, + pub font_size: f64, pub fit_to: resvg_fit_to, pub draw_background: bool, pub background: resvg_color, @@ -149,6 +153,8 @@ pub extern fn resvg_init_options(opt: *mut resvg_options) { unsafe { (*opt).path = ptr::null(); (*opt).dpi = 96.0; + (*opt).font_family = b"Times New Roman\0".as_ptr() as *const _; + (*opt).font_size = 12.0; (*opt).fit_to = resvg_fit_to { kind: resvg_fit_to_type::RESVG_FIT_TO_ORIGINAL, value: 0.0, @@ -656,10 +662,28 @@ fn to_native_opt(opt: &resvg_options) -> resvg::Options { None }; + let ff = DEFAULT_FONT_FAMILY; + let font_family = match cstr_to_str(opt.font_family) { + Some(v) => { + if v.is_empty() { + warn!("Provided 'font_family' is empty. Fallback to '{}'.", ff); + ff + } else { + v + } + } + None => { + warn!("Provided 'font_family' is no an UTF-8 string. Fallback to '{}'.", ff); + ff + } + }; + resvg::Options { usvg: usvg::Options { path, dpi: opt.dpi, + font_family: font_family.to_string(), + font_size: opt.font_size, keep_named_groups: opt.keep_named_groups, }, fit_to, diff --git a/testing_tools/regression/allow-cairo.txt b/testing_tools/regression/allow-cairo.txt index 8b4553eaf40fe48280f0a4dd624181ee35b78a2f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/testing_tools/regression/allow-cairo.txt +++ b/testing_tools/regression/allow-cairo.txt @@ -1,6 +0,0 @@ -a-display-002.svg -a-display-003.svg -a-display-004.svg -a-display-005.svg -a-display-006.svg -a-display-007.svg diff --git a/testing_tools/regression/allow-qt.txt b/testing_tools/regression/allow-qt.txt index 8b4553eaf40fe48280f0a4dd624181ee35b78a2f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/testing_tools/regression/allow-qt.txt +++ b/testing_tools/regression/allow-qt.txt @@ -1,6 +0,0 @@ -a-display-002.svg -a-display-003.svg -a-display-004.svg -a-display-005.svg -a-display-006.svg -a-display-007.svg