Skip to content

Commit

Permalink
Default font returned to SlideDeck
Browse files Browse the repository at this point in the history
  • Loading branch information
spirali committed Nov 11, 2024
1 parent 33e662a commit 4c12f5d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* By default, Nelsie no longer loads system fonts, but loads the fonts built into Nelsie instead.
You can revert to the original behavior by creating resouces as follows: `Resources(system_fonts=True, builtin_fonts=False)`.
* Removed `TextStyle` features: overline and stroke
* `SlideDeck(default_font=...)` removed. Default font is now set to "sans-serif" so use `resources.set_sans_serif("...")`

## New features

Expand Down
4 changes: 3 additions & 1 deletion python/nelsie/slidedeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def __init__(
bg_color: str = "white",
image_directory: str | None = None,
resources: Resources | None = None,
default_font: str = "sans-serif",
default_monospace_font: str = "monospace",
default_code_theme: str = "InspiredGitHub",
default_code_language: str | None = None,
):
Expand Down Expand Up @@ -156,7 +158,7 @@ def __init__(
self.resources = resources
self.default_code_theme = default_code_theme
self.default_code_language = default_code_language
self._deck = nelsie_rs.Deck()
self._deck = nelsie_rs.Deck(default_font, default_monospace_font)
self._slides: List[Slide] = []

def set_style(self, name: str, style: TextStyle):
Expand Down
6 changes: 3 additions & 3 deletions src/model/slidedeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ pub(crate) struct SlideDeck {
}

impl SlideDeck {
pub fn new() -> crate::Result<Self> {
pub fn new(default_font: &str, default_monospace_font: &str) -> crate::Result<Self> {
let creation_time = std::time::Instant::now();

let default_font = Arc::new(FontData {
family_name: "sans-serif".to_string(),
family_name: default_font.to_string(),
});
let monospace_font = Arc::new(FontData {
family_name: "monospace".to_string(),
family_name: default_monospace_font.to_string(),
});

let default_style = PartialTextStyle {
Expand Down
4 changes: 2 additions & 2 deletions src/pyinterface/deck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ fn resolve_slide_id(deck: &mut SlideDeck, slide_id: SlideId) -> PyResult<&mut Sl
#[pymethods]
impl Deck {
#[new]
fn new() -> PyResult<Self> {
fn new(default_font: &str, default_monospace_font: &str) -> PyResult<Self> {
Ok(Deck {
deck: SlideDeck::new()?,
deck: SlideDeck::new(default_font, default_monospace_font)?,
})
}

Expand Down

0 comments on commit 4c12f5d

Please sign in to comment.