【问题标题】:Changing the PDF FONT'S (DJANGO)更改 PDF 字体 (DJANGO)
【发布时间】:2019-07-29 02:58:37
【问题描述】:

我在 django 有一个项目,我想将一些文本呈现为 pdf。它已经在工作,但现在我需要更改我的字体。我在 pc 上安装了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】:

    您将需要 Gotham 网络字体。应该是.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

    【讨论】:

    • 我尝试了 gothamPro,然后下载文件 .woff,然后放到我的 fonts 文件夹中,什么也没有。并尝试将link of css 放在<head> 内,但仍然没有
    猜你喜欢
    • 2019-09-12
    • 2023-03-11
    • 1970-01-01
    • 2019-07-07
    • 2023-03-02
    • 1970-01-01
    • 2012-10-14
    • 2014-08-16
    • 2013-08-04
    相关资源
    最近更新 更多