spirali / nelsie

Framework for Creating Slides
MIT License
39 stars 4 forks source link

Text with inline styles disappears from pdf. #19

Closed fgelm01 closed 4 months ago

fgelm01 commented 4 months ago

When using text, certain combinations of inline styles and text contents cause the text to not appear in the generated pdf file.

I can't discern a pattern in what strings cause this, but it doesn't happen when parse_styles=False.

Here's a minimal example:

import nelsie

deck = nelsie.SlideDeck(width=320, height=240)

@deck.slide()
def _(slide: nelsie.Slide) -> None:
    s = "~monospace{s} specifi"
    slide.text(s, parse_styles=False, bg_color="#fa8080")
    slide.text(s, parse_styles=True, bg_color="#80fa80")

deck.render("repro", "svg")

0-0-1

The cut-off is expected due to slide deck dimensions being small. But the second line looks very strange in the .svg and doesn't appear at all in the .pdf.

This is using version 0.6.0

spirali commented 4 months ago

Thank you for your report. I can reproduce it and I will look at it.

fgelm01 commented 4 months ago

Thanks for looking at this. I just ran into the bug again with new strings:

slide.text("~code{start} creates a ~code{From} value.")
slide.text("~code{finish} takes a ~code{To} value.")

Both lines don't appear in the pdf.

spirali commented 4 months ago

My first investigation is that it is a bug in an upstream crate usvg that converts text in to paths. It seems that the bug is already fixed but because of another dependency (svg2pdf) we are still on the buggy version. In next days I will try to investigate how to upgrade without breaking dependencies.

spirali commented 4 months ago

I have tested dev version of svg2pdf and it seems to work. The main problem is now that the new version of usvg made substantial changes in API. I have started to work on port of Nelsie to the current version of usvg but it will take some time.

spirali commented 4 months ago

Btw: It seems that the text disappears when ligature is created, so a temporary workaround is to use a monospace font that usually does not create ligatures. I know, not a great solution ...