altair icon indicating copy to clipboard operation
altair copied to clipboard

Emojis in PDF/PNG Renders

Open EntilZha opened this issue 3 years ago • 4 comments

I'm trying to get emojis to render in PDF output of altair, but it seems like this breaks somewhere in the rendering pipeline (not sure where). As an example, I am using the sample chart here https://github.com/altair-viz/altair/issues/1949 and appending a pedroai.altair.save_chart(chart, '/tmp/test', ['pdf', 'svg', 'png']) from https://github.com/EntilZha/pedroai/blob/master/pedroai/altair.py (just a wrapper around altair_saver). I tried debugging this in the vega-lite demo online to render to PDF, but it looks like maybe that server is offline now?

So things I've tried:

  1. With altair_saver render pdf/png, which don't have the emoji. Render SVG locally which is fine
  2. With vega-lite demo, render PDF (crashes), png (no emoji), SVG (fine)

My suspicion is that somewhere there is a font issue so the emoji is not getting rendered, since I can still see ghost whitespace where the emoji should appear. As for 1/2 differing on PNG, I suspect that the vega-lite demo is using the chromium driver while I'm using the local nodejs driver to also render PDF. Any thoughts on what to try next?

EntilZha avatar Jun 07 '22 05:06 EntilZha

The example you linked to works well for me for both svg and pdf. For png, I see the flags but they are rendered in black and white. Clicking the three dots actions menu saves the charts with flags in color for both png and svg. The Vega editor should be online, but not sure you can try there since this seems to be something specific to altai_saver, possibly a local font issue as you mentioned.

These are the package versions I tested with

❯ conda list altair                                                                                                
# Name                    Version                   Build  Channel
altair                    4.2.0                    pypi_0    pypi
altair_saver              0.5.0                      py_0    conda-forge

joelostblom avatar Jun 07 '22 15:06 joelostblom

Interesting, the PDF output in color is what I'm most interested in since I'm embedding the graphic in a LaTeX document. The vega editor is online, but it seem like the output to PDF feature is broken (even trying to save one of the examples on the site to PDF doesn't work).

I fiddled around with the vega lite cli as well, can post a few tests with that later today. Hopefully that sheds some more light on what might be the root issue to test.

EntilZha avatar Jun 09 '22 14:06 EntilZha

For LaTeX, you could also use svg, that is what I do the commonly myself. If something is broken in the VegaEditor please report it as an issue to the VegaLite or Vega tracker and they might be able to help.

joelostblom avatar Jun 09 '22 14:06 joelostblom

@EntilZha Were you able to resolve the issue in the meantime? If yes, I'd close the issue :)

binste avatar May 27 '23 06:05 binste