useblocks / sphinx-simplepdf

A simple PDF builder for Sphinx documentations
https://sphinx-simplepdf.readthedocs.io
MIT License
35 stars 17 forks source link

Fonts on windows #25

Open danwos opened 2 years ago

danwos commented 2 years ago

Code-blocks and some other elements are looking strange when build on windows: image Complete DEMO example (WIN build)

On linux it looks like this and the used font is set to monospace for the code-block text (set by browser for pre elements) image

@1kastner: Can you please check the HTML on your side? Would be interesting, what font is set in the HTML. So a similar browser-image like the one above would be good.

1kastner commented 2 years ago

For me, it looks like this: grafik

1kastner commented 2 years ago

One small idea - could we add a WIN build GitHub workflow to this repository?

danwos commented 2 years ago

One small idea - could we add a WIN build GitHub workflow to this repository?

Yes, but CI is overall totally missing. I just use ReadTheDocs to get the Documentation build done.

But we have no test cases or other checks currently. And to be honest, I have no idea how to check the layout of a generated PDF automatically. But it would be awesome to have something for it. :)

Regarding your screenshot, it looks like no CSS from Sphinx-SimplePDF got used. Things I see:

I will try to test it also manually on a windows machine. But fixes here will need some time.

1kastner commented 2 years ago

Thank you for the effort!

1kastner commented 2 years ago

Regarding the CI, I have worked at companies where the PDF was converted to a PNG and then a pixel-wise comparison took place. I guess that is too strict for this case.

1kastner commented 2 years ago

I can confirm that the docs are built good enough on my WSL Ubuntu. The fonts are no issue there. In some edge cases, I guess I would need to customize the CSS file though.

kreuzberger commented 2 years ago

With weasyprint >= 56 i ran into problems in all code examples, inline code elements. Nothing is rendered on windows in these grey boxes. HTML looks still perfect. After some playing around i added a new entry into main.css @font-face { font-family: monospace; font-weight: 400; src: url(fonts/FiraMono-Regular.ttf); } And code examples and other monospace stuff is displayed in pdf again. This seems only to affect windows currently, on Ubuntu it works like expected.

kreuzberger commented 2 years ago

fixed in fork of the project, but also updated requirements for the demo project to handle sphinx-needs dependencies (rename from sphinxcontrib-needs).

1kastner commented 2 years ago

Cool, thank you @kreuzberger!

kreuzberger commented 2 years ago

Forgotten to mention: As in the first screenshots above BOLD monospace content was printed correctly. Only "regular" Monospace was not printed.