改变PDF FONT'S(DJANGO)

问题描述 投票:0回答:1

我在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'); 
            }    

但是没有用,我不知道我需要做什么。

css django pdf fonts
1个回答
0
投票

你需要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

© www.soinside.com 2019 - 2024. All rights reserved.