Commit a0427144 authored by RazrFalcon's avatar RazrFalcon

Build fixed.

parent fa54852c
...@@ -9,6 +9,8 @@ This changelog also contains an important changes in dependencies. ...@@ -9,6 +9,8 @@ This changelog also contains an important changes in dependencies.
## [Unreleased] ## [Unreleased]
### Added ### Added
- (c-api) `RESVG_ERROR_PARSING_FAILED`. - (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 ### Changed
- (c-api) Qt wrapper is header-only now. - (c-api) Qt wrapper is header-only now.
...@@ -18,9 +20,10 @@ This changelog also contains an important changes in dependencies. ...@@ -18,9 +20,10 @@ This changelog also contains an important changes in dependencies.
- (resvg) Recursive SVG images via `image` tag. - (resvg) Recursive SVG images via `image` tag.
- (resvg) Bbox calculation of the text with rotate. - (resvg) Bbox calculation of the text with rotate.
- (qt-api) SVG from QByteArray loading when data is invalid. - (qt-api) SVG from QByteArray loading when data is invalid.
- (usvg) `display` attribute processing.
### Removed ### Removed
- (rendersvg) `failure`. - (rendersvg) `failure` dependency.
## [0.3.0] - 2018-05-23 ## [0.3.0] - 2018-05-23
### Added ### Added
......
...@@ -103,6 +103,10 @@ typedef struct resvg_options { ...@@ -103,6 +103,10 @@ typedef struct resvg_options {
const char *path; const char *path;
/** Output DPI. Default: 96. */ /** Output DPI. Default: 96. */
double dpi; 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. * Fits the image using specified options.
* *
......
...@@ -30,10 +30,14 @@ use resvg::usvg; ...@@ -30,10 +30,14 @@ use resvg::usvg;
use usvg::prelude::*; use usvg::prelude::*;
const DEFAULT_FONT_FAMILY: &str = "Times New Roman";
#[repr(C)] #[repr(C)]
pub struct resvg_options { pub struct resvg_options {
pub path: *const c_char, pub path: *const c_char,
pub dpi: f64, pub dpi: f64,
pub font_family: *const c_char,
pub font_size: f64,
pub fit_to: resvg_fit_to, pub fit_to: resvg_fit_to,
pub draw_background: bool, pub draw_background: bool,
pub background: resvg_color, pub background: resvg_color,
...@@ -149,6 +153,8 @@ pub extern fn resvg_init_options(opt: *mut resvg_options) { ...@@ -149,6 +153,8 @@ pub extern fn resvg_init_options(opt: *mut resvg_options) {
unsafe { unsafe {
(*opt).path = ptr::null(); (*opt).path = ptr::null();
(*opt).dpi = 96.0; (*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 { (*opt).fit_to = resvg_fit_to {
kind: resvg_fit_to_type::RESVG_FIT_TO_ORIGINAL, kind: resvg_fit_to_type::RESVG_FIT_TO_ORIGINAL,
value: 0.0, value: 0.0,
...@@ -656,10 +662,28 @@ fn to_native_opt(opt: &resvg_options) -> resvg::Options { ...@@ -656,10 +662,28 @@ fn to_native_opt(opt: &resvg_options) -> resvg::Options {
None 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 { resvg::Options {
usvg: usvg::Options { usvg: usvg::Options {
path, path,
dpi: opt.dpi, dpi: opt.dpi,
font_family: font_family.to_string(),
font_size: opt.font_size,
keep_named_groups: opt.keep_named_groups, keep_named_groups: opt.keep_named_groups,
}, },
fit_to, fit_to,
......
a-display-002.svg
a-display-003.svg
a-display-004.svg
a-display-005.svg
a-display-006.svg
a-display-007.svg
a-display-002.svg
a-display-003.svg
a-display-004.svg
a-display-005.svg
a-display-006.svg
a-display-007.svg
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment