Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems setting LaTeX image type to SVG #13

Open
ncoghlan opened this issue Oct 21, 2019 · 6 comments
Open

Problems setting LaTeX image type to SVG #13

ncoghlan opened this issue Oct 21, 2019 · 6 comments

Comments

@ncoghlan
Copy link

ncoghlan commented Oct 21, 2019

In an attempt to work around blockdiag/blockdiag#78, I've set the LaTeX image type to SVG instead of PNG.

However, that then runs into sphinx-doc/sphinx#1907, and installing ImageMagick and enabling "sphinx.ext.imgconverter" doesn't appear to be converting the SVGs before LaTeX sees them.

@tk0miya
Copy link
Contributor

tk0miya commented Oct 27, 2019

Yes, this extension generates SVG image after imgconverter worked. But blockdiag is able to generate PDF image directly. It is much better to keep quality of image. Why would you like to generate SVG image and convert it to PDF via imgconverter?

@ncoghlan
Copy link
Author

The specific thing I'm aiming to do is generate a PDF of the whole Sphinx project via "make latexpdf".

Using png as the generated diagram format doesn't work due to the text rotation issue, so I tried SVG, as that's what worked for HTML.

Those are the only image formats I tried, though, so it may be there's a different output option that LaTeX would be able to accept.

@tk0miya
Copy link
Contributor

tk0miya commented Oct 30, 2019

You can use PDF image to embed a diagram-image to LaTeX output with blockdiag_latex_image_format = 'pdf'. I think it goes well. Could you check this please?
http://blockdiag.com/en/blockdiag/sphinxcontrib.html#configuration-file-options

@ncoghlan
Copy link
Author

ncoghlan commented Nov 1, 2019

When I try rendering the images as PDF, there seems to be a problem with actdiag not passing the actdiag_fontpath setting down correctly:

Traceback (most recent call last):
  File "/.../site-packages/sphinxcontrib/actdiag.py", line 303, in on_doctree_resolved
    image.save()
  File "/.../site-packages/blockdiag/drawer.py", line 187, in save
    return self.drawer.save(self.filename, size, self.format)
  File "/.../site-packages/blockdiag/imagedraw/filters/linejump.py", line 181, in save
    self._run()
  File "/.../site-packages/blockdiag/imagedraw/filters/linejump.py", line 108, in _run
    method(self.target, *args, **kwargs)
  File "/.../site-packages/blockdiag/imagedraw/pdf.py", line 159, in textarea
    self.set_font(font)
  File "/.../site-packages/blockdiag/imagedraw/pdf.py", line 46, in set_font
    raise RuntimeError(msg)
RuntimeError: Could not detect fonts, use --font opiton

After hooking get_lazy_method in the linejump filter, I found that the font.path attribute was set to None for all of the textarea calls.

@ncoghlan
Copy link
Author

ncoghlan commented Nov 1, 2019

Ah, I forgot I switched these experiments to a different machine, and the ipafont didn't exist here. Switching to a font that does exist at least allowed the PDF to build, and I suspect the remaining problems are a configuration issue on the Sphinx PDF side (I need to embed the font in the PDF).

So I think that means the request here would be to emit a warning or an error when attempting to set the latex output style to "SVG", since it probably isn't going to work, and folks would be much better off using "PDF".

@tk0miya
Copy link
Contributor

tk0miya commented Nov 1, 2019

Thank you for comment.

+1; Reasonable for a warning when blockdiag_latex_image_format = 'svg'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants