Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load systems fonts for svg by dafault #74

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Support embedding videos into slides
* `.image()` can now take directly image data (e.g. `.image((blob, "png"))`)
* Better progressbar computing
* Introduce `system_fonts_for_svg` in `Resources`.
It is enabled by default and loads system fonts only for SVG.
It is a compromise for slower loading system fonts for non SVG parts and confusions like #72.

# v0.15.0

Expand Down
5 changes: 4 additions & 1 deletion python/nelsie/slidedeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ def __init__(
*,
builtin_fonts: bool = True,
system_fonts: bool = False,
system_fonts_for_svg: bool = True,
default_code_syntaxes: bool = True,
default_code_themes: bool = True,
):
self._resources = nelsie_rs.Resources(system_fonts, default_code_syntaxes, default_code_themes)
self._resources = nelsie_rs.Resources(
system_fonts, system_fonts_for_svg, default_code_syntaxes, default_code_themes
)
if builtin_fonts:
self._resources.load_fonts_dir(BUILTIN_FONTS_DIR)
self._resources.set_generic_family("sans-serif", "DejaVu Sans")
Expand Down
3 changes: 2 additions & 1 deletion src/model/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ pub(crate) struct Resources {
impl Resources {
pub fn new(
system_fonts: bool,
system_fonts_for_svg: bool,
default_code_syntaxes: bool,
default_code_themes: bool,
) -> Resources {
let mut font_db = fontdb::Database::new();
if system_fonts {
if system_fonts || system_fonts_for_svg {
font_db.load_system_fonts();
}
let syntax_set = if default_code_syntaxes {
Expand Down
2 changes: 2 additions & 0 deletions src/pyinterface/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ impl Resources {
#[new]
fn new(
system_fonts: bool,
system_fonts_for_svg: bool,
default_code_syntaxes: bool,
default_code_themes: bool,
) -> PyResult<Self> {
Ok(Resources {
resources: crate::model::Resources::new(
system_fonts,
system_fonts_for_svg,
default_code_syntaxes,
default_code_themes,
),
Expand Down
Loading