I have a problem with using custom font on Heroku.
In order to show Russian text correctly on generated pdf pages I use following custom font in my html:
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Boat pdf</title>
<style type="text/css">
@font-face {
font-family: Palatino Linotype;
src: url({% static "fonts/Palatino.ttf" %});
}
body {
font-family: Palatino Linotype, Arial, sans-serif;
color: #333333;
}
</style>
</head>
It works fine locally but after migration to Heroku whenever I am trying to generate pdf file based on the html I get an exception:
File "/app/.heroku/python/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 420, in stored_name
2019-06-26T09:52:03.873127+00:00 app[web.1]: raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
2019-06-26T09:52:03.873128+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'fonts/Palatino.ttf'
This is the only error I get related to staticfiles. All other static works fine. I have tried to manually run collectstatic one more time and even placed this font to staticfiles folder manually – no success.
In production static assets are served by Whitenoize.
Development setting related to static are:
INSTALLED_APPS = [
'whitenoise.runserver_nostatic',
STATIC_ROOT = os.path.join(BASE_DIR, "static") # new
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
production settings are:
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
Question is how to serve this font on Heroku. Where to place it? Or maybe I need to change url in template?
Thank you!
Well, for some reason Whitenoize doesnt serve files being moved from project's "static" folder, which is strange. I moved font to app/static/app folder, then ran collectatic again and deployed it all to Heroku. Now it work