我在django有一个项目,我想将一些文本呈现给pdf。它已经工作但现在我需要更改我的字体。我在电脑上安装了Gotham
字体,我用于我的所有文件,但是现在我想用Gotham
字体渲染我的pdf。
我下载字体并放入我的templates
文件夹:
myproject/
|-- myproject
|-- templates/
|-- admin/
|-- font/
|-- GothamBookItalic.ttf
|-- GothamBookLight.ttf
|-- GothamBookLIghtItalic.ttf
|-- GothamBookMedium.ttf
这是我的html
的css
@font-face {
font-family: GothamMedium;
src: url('/font/GothamMedium.ttf') format('truetype');
}
但是没有用,我不知道我需要做什么。
你需要Gotham webfont。哪个应该是.woff
文件。
您尝试使用.ttf
TrueTypeFont。这不适合现代Web应用程序。
这是一个如何看起来像这样的例子:
@font-face {
font-family: 'GothamMedium';
src: url('fonts/GothamMedium-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
也可以看起来像这样更广泛的浏览器兼容性:
@font-face {
font-family: 'GothamMedium';
src: url('fonts/GothamMedium-webfont.eot?') format('eot'),
url('fonts/GothamMedium-webfont.woff') format('woff'),
url('fonts/GothamMedium-webfont.ttf') format('truetype'),
url('fonts/GothamMedium-webfont.svg#webfontdSscXrwb') format('svg');
font-weight: normal;
font-style: normal;
}
也许这就是你要寻找的:https://gist.github.com/mfd/f3d96ec7f0e8f034cc22ea73b3797b59