dockerfiles
dockerfiles copied to clipboard
SVG conversion broken in pandoc/latex
SVG images in latex based output (e.g. beamer) do not show proper text. The culprit is rsvg-convert which generates bad png/pdf output.
To reproduce the bug:
$ docker run --rm --volume "`pwd`:/data" --entrypoint "/bin/sh" -ti pandoc/latex
/data # rsvg-convert -f png -a -o font-test.png font-test.svg
/data # rsvg-convert -f pdf -a -o font-test.pdf font-test.svg
using the SVG file in font-test.svg.zip.
I suspect that there are some missing fonts in the image, but I don't know enough about Librsvg to trace down the real issue.
This is a rather serious bug which prevents the use of Pandoc to generate both web and PDF contents unless scalable images are converted in advance to a non scalable png.
Thanks for the report. Do you get better results if you use the pandoc/ubuntu-latex image?
Thanks for the report. Do you get better results if you use the
pandoc/ubuntu-lateximage?
yes, results are pretty good.
In some of my original figures there are a few fonts that are substituted with wider ones, so they get misaligned; but it's a minor thing and it might depend on how the SVG has been generated (Graphviz).
That's good to know, thanks. I'll take a look. I'm pretty booked right now, so it may take a little longer.
@stessaris thanks for the report, this isn't very good x0 would you be willing to help us do some research? I think what we should do is determine what fonts Ubuntu comes with and then install them in alpine to be as uniform as we can.
I think on the Ubuntu side you can get what's installed with apt-get list --installed, there's likely an equivalent command with apk on alpine. The name of the game is
- Prune the Ubuntu installed packages to just fonts.
- Search for these font names (may be slightly differently named but probably similar) here https://pkgs.alpinelinux.org/packages and
- See if (2) is installed in the current image.
It would be helpful if somebody could help us get this list, it's gotta be done manually and may take a couple hours. @tarleb and I are both swamped right now, but if somebody can identify the fonts we need then we will be able to get them into the images (there's a little more work on our end than just updating the install stuff, we'll need to verify they're available to the TeX images etc).
Our general policy on fonts is to request that users create derivative images, more fonts means bigger images which for alpine in particular is a priority. Additionally, there are way too many fonts to give any one font special priority. That said, I think as long as the size increase of alpine isn't terrible, it would be better to have uniform font options across the images.
@svenevs, I'm glad to help. I'll have a look at both images to see which fonts are missing in alpine. I'll do it ASAP
--sergio
@svenevs, @tarleb I did a few tests with both the alpine and ubuntu images; the fc-list command can be used to list the installed fonts. Alpine has not fonts installed while ubuntu comes with DejaVu fonts because of the fontconfig-config dependencies:
# apt-cache depends fontconfig-config
fontconfig-config
Depends: ucf
|Depends: fonts-dejavu-core
|Depends: <ttf-bitstream-vera>
|Depends: <fonts-liberation>
Depends: <fonts-freefont>
Breaks: libfontconfig1
Unless there are license problems, one possibility is to install the Microsoft Core fonts for the Web. I installed them on alpine and they just take 5.5MB:
# apk --no-cache add msttcorefonts-installer fontconfig && \
update-ms-fonts && \
fc-cache -f
...
# du -sh /usr/share/fonts/
5.5M /usr/share/fonts/
Something similar could be done for the ubuntu image.
Alternative fonts are listed in the Microsoft Core fonts for the Web wiki page.
@stessaris awesome, thanks for digging all that up! Wanted to send quick response before work picks up, the font unification with Dejavu seems attainable. I'll also look into installing a font after graphviz is installed, it may be that is the bottleneck.
But can you clarify the MS fonts stuff? It appears to be packaged as an installer because of the licensing stuff, so I'm not sure we can do that. It would be one thing if the font was available directly through system package manager, the fact that we install an installer and then run that gives me pause. Are you saying that those fonts are what make your diagrams look the way you want? At the very least we can provide instructions on how to get it setup pending some investigation, but I don't want us to be vulnerable over something gray area like this. I think it's a matter of coordinating font config post installation (?)
I had a look at the MS fonts licensing and apparently they can only be distributed in their original format so they're out of the game.
I tried both dejavu and Liberation fonts with my SVGs and I get better results with the latter, so I suggest to select the package ttf-liberation (the list of Alpine font packages is available on the Alpine wiki):
# apk --no-cache add ttf-liberation && fc-cache -f
...
# du -sh /usr/share/fonts
4.6M /usr/share/fonts
For ubuntu the corresponding package is fonts-liberation.
Wanted to give quick ping, hoping to get this up over the weekend thanks again for the updates / research / feedback!