简体   繁体   中英

Heroku can't connect fonts

I have downloaded fonts for html template that is converted with xhtml2pdf to pdf. I didn't manage to google for answer that works for me. I thought that path was changed but in heroku bash path isn't changed. Here is my code:

fonts are in invoices/static/invoices/fonts

settings.py

STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'main/static'),
    #os.path.join(BASE_DIR, 'invoices/static'),
    #BASE_DIR / "static",
]

STATIC_ROOT os.path.join(BASE_DIR, 'staticfiles')

STATICFILES_STORAGE = 'whitenoise.storage. CompressedManifestStaticFilesStorage'

html font connect

<html lang="ru">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Инвойс #{{invoice_id}}</title>

<style>
@font-face {
    font-family: 'Roboto-Medium';
    src: url(../invoices/static/invoices/fonts/Roboto-Medium.ttf);
}
</style>

So it figured out that when deployed on heroku you have to use ./path_to_fonts instead of ../path_to_fonts. Hope that this will help somebody.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM