Skip to content

Commit

Permalink
Added the stylesheet option to the C API
Browse files Browse the repository at this point in the history
  • Loading branch information
michabay05 committed Dec 26, 2024
1 parent bda7db0 commit 502591a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/c-api/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ pub extern "C" fn resvg_options_set_dpi(opt: *mut resvg_options, dpi: f32) {
cast_opt(opt).dpi = dpi as f32;
}

/// @brief Sets a stylesheet path that will be used when resolving CSS attributes.
///
/// Must be UTF-8. Can be set to NULL.
///
/// Default: NULL
#[no_mangle]
pub extern "C" fn resvg_options_set_stylesheet(opt: *mut resvg_options, path: *const c_char) {
if path.is_null() {
cast_opt(opt).style_sheet = None;
} else {
cast_opt(opt).style_sheet = Some(cstr_to_str(path).unwrap().into());
}
}

/// @brief Sets the default font family.
///
/// Will be used when no `font-family` attribute is set in the SVG.
Expand Down
9 changes: 9 additions & 0 deletions crates/c-api/resvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ void resvg_options_set_resources_dir(resvg_options *opt, const char *path);
*/
void resvg_options_set_dpi(resvg_options *opt, float dpi);

/**
* @brief Sets a stylesheet path that will be used when resolving CSS attributes.
*
* Must be UTF-8. Can be set to NULL.
*
* Default: NULL
*/
void resvg_options_set_stylesheet(resvg_options *opt, const char *path);

/**
* @brief Sets the default font family.
*
Expand Down

0 comments on commit 502591a

Please sign in to comment.