sphinx-simplepdf icon indicating copy to clipboard operation
sphinx-simplepdf copied to clipboard

Fonts on windows

Open danwos opened this issue 3 years ago • 10 comments

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.

danwos avatar Sep 16 '22 09:09 danwos

For me, it looks like this: grafik

1kastner avatar Sep 16 '22 09:09 1kastner

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

1kastner avatar Sep 16 '22 09:09 1kastner

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:

  • The font is different (looks like a default one, maybe Times New Roman / serif )
  • No colors got set
  • You have section numbers, which is interesting because of a discussion here
  • There is also a sitebox

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

danwos avatar Sep 16 '22 10:09 danwos

Thank you for the effort!

1kastner avatar Sep 16 '22 10:09 1kastner

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 avatar Sep 16 '22 10:09 1kastner

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.

1kastner avatar Sep 16 '22 15:09 1kastner

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 avatar Oct 12 '22 14:10 kreuzberger

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

kreuzberger avatar Oct 12 '22 17:10 kreuzberger

Cool, thank you @kreuzberger!

1kastner avatar Oct 12 '22 19:10 1kastner

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

kreuzberger avatar Oct 13 '22 05:10 kreuzberger