cid-harvard / atlas-economic-complexity

[DEPRECATED] The Atlas online is a powerful interactive tool that enables users to visualize a country’s total trade, track how these dynamics change over time and explore growth opportunities for more than a hundred countries worldwide.
http://atlas.cid.harvard.edu
81 stars 40 forks source link

Static image font is messed up #269

Open makmanalp opened 9 years ago

makmanalp commented 9 years ago

For some reason the static image rendering is using the wrong font. E.g. screen shot 2015-01-30 at 10 36 29 am

when it should look like:

screen shot 2015-01-30 at 10 36 17 am

The font is in /home/vagrant/.fonts/PTN57.ttf and my understanding was that any font here would be used by the SVG renderer (we use cairosvg) automatically. This might be where the bug is happening. Could help to just test the prerendered_html_to_image function by itself on an SVG file generated by the atlas. It used to work okay but stopped working at some point - I'm not sure if this was because I changed some code.

The static image stuff runs in a celery task in the background (http://www.celeryproject.org/) and you can find the code in https://github.com/cid-harvard/atlas-economic-complexity/blob/beta/django_files/atlas/celery_tasks.py You can check if the automatic celery task is running by typing sudo supervisorctl status celery. It might help to kill that process and run your own one manually to see debug information.

Let me know if you need help understanding how the static image code works or if you need help running it.

sibamohanty commented 9 years ago

It looks like cairosvg supports a very few fonts and with no support for svg fonts. Also the font element is ignored completely. Here's the documentation http://cairosvg.org/svg_support/#idid10

In order to support (Helvetica Neue) or (PT Sans Narrow) which I can see is being used in viz_general.js, either we can explore other svg2png rendering engine, or we can change the fonts to CSS2 font face which will be supported by cairosvg natively.