I have a problem concerning Django and custom fonts.. Which way ever I try to use a custom font of this type
@font-face {
@font-face {
font-family: 'abc';
src: url('abc.eot');
src: url('abc.woff');
src: url('abc.ttf');
font-weight: normal;
font-style: normal;
}
}
or this type
@font-face {
@font-face {
font-family: 'abc';
src: url('abc.eot');
src: url('abc.eot?#iefix') format('embedded-opentype'),
url('abc.woff') format('woff'),
url('abc.ttf') format('truetype'),
url('abc.svg#cde') format('svg');
font-weight: normal;
font-style: normal;
}
}
Django's builtin server ("python manage.py runserver") is printing
Traceback (most recent call last):
File "C:\Python34\lib\wsgiref\handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "c:\users\myName\documents\github\django-trunk\django\contrib\staticfiles\
handlers.py", line 65, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "c:\users\myName\documents\github\django-trunk\django\core\handlers\wsgi.p
y", line 191, in __call__
response = self.get_response(request)
File "c:\users\myName\documents\github\django-trunk\django\contrib\staticfiles\
handlers.py", line 55, in get_response
return self.serve(request)
File "c:\users\myName\documents\github\django-trunk\django\contrib\staticfiles\
handlers.py", line 48, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "c:\users\myName\documents\github\django-trunk\django\contrib\staticfiles\
views.py", line 41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "c:\users\myName\documents\github\django-trunk\django\views\static.py", li
ne 68, in serve
response["Last-Modified"] = http_date(statobj.st_mtime)
File "c:\users\myName\documents\github\django-trunk\django\utils\http.py", line
119, in http_date
return formatdate(epoch_seconds, usegmt=True)
File "C:\Python34\lib\email\utils.py", line 175, in formatdate
now = time.gmtime(timeval)
OSError: [Errno 22] Invalid argument
"GET /this/is/the/correct/path/customfont.css HTTP/1.1" 500 59
it does not matter if I link the customfont.css via <link>
, copy&paste the content into my base.css (which is loaded correctly) or embed it into the .html file with <script>@font-face..</script>
. I tried different fonts, too.
Excerpt from my settings.py:
DEBUG = True
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'CEST'
USE_I18N = True
USE_L10N = True
USE_TZ = True
even though I am not using anything besides DEBUG = True
by now.
My machine is running Windows 8 64bit if it matters.
Any ideas anyone? Ty
It looks like the problem is in the "last modified" value on the file itself. Possibly the file was created on a computer with an offset clock, or some such.
Ref:
Try updating the file with the following command:
copy /b customfont.ttf +,,
(That's a Windows equivalent of *nix "touch" command, ref: https://superuser.com/a/764721/66285 )