我有一个关于Django和自定义字体的问题。。哪种方式我尝试使用这种类型的自定义字体
@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;
}
}
或者这种类型的
@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的内置服务器("python manage.py runserver")正在打印
Traceback (most recent call last):
File "C:Python34libwsgirefhandlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "c:usersmyNamedocumentsgithubdjango-trunkdjangocontribstaticfiles
handlers.py", line 65, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "c:usersmyNamedocumentsgithubdjango-trunkdjangocorehandlerswsgi.p
y", line 191, in __call__
response = self.get_response(request)
File "c:usersmyNamedocumentsgithubdjango-trunkdjangocontribstaticfiles
handlers.py", line 55, in get_response
return self.serve(request)
File "c:usersmyNamedocumentsgithubdjango-trunkdjangocontribstaticfiles
handlers.py", line 48, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "c:usersmyNamedocumentsgithubdjango-trunkdjangocontribstaticfiles
views.py", line 41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "c:usersmyNamedocumentsgithubdjango-trunkdjangoviewsstatic.py", li
ne 68, in serve
response["Last-Modified"] = http_date(statobj.st_mtime)
File "c:usersmyNamedocumentsgithubdjango-trunkdjangoutilshttp.py", line
119, in http_date
return formatdate(epoch_seconds, usegmt=True)
File "C:Python34libemailutils.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
如果我通过<link>
、复制&将内容粘贴到我的base.css(已正确加载)中,或使用<script>@font-face..</script>
将其嵌入到.html文件中。我也试过不同的字体。
摘录自我的设置.py:
DEBUG = True
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'CEST'
USE_I18N = True
USE_L10N = True
USE_TZ = True
尽管我现在没有使用除CCD_ 3之外的任何东西。如果重要的话,我的机器运行的是Windows 8 64位。
有什么想法吗?Ty
问题似乎出在文件本身的"上次修改"值上。该文件可能是在带有偏移时钟的计算机上创建的,或者类似的。
参考:
- https://code.djangoproject.com/ticket/15120
- 为什么在CSS中提供web字体文件时会出现500个错误
尝试使用以下命令更新文件:
copy /b customfont.ttf +,,
(这相当于Windows中的*nix"touch"命令,参考:https://superuser.com/a/764721/66285)