【问题标题】:puppeteer-sharp unable to use cursive fontpuppeteer-sharp 无法使用草书字体
【发布时间】:2021-08-26 04:22:24
【问题描述】:

我正在尝试在 puppeteer-sharp 中使用草书字体作为签名。 Puppeteer 在分配时似乎忽略了字体系列。例如:

.signature { font-family: 'Brush Script MT', cursive; }

这是我的 PdfOptions:

               var stream = await page.PdfStreamAsync(new PdfOptions
               {
                  Format = PaperFormat.A4,
                  MarginOptions = new MarginOptions
                  {
                     Top = "0px",
                     Right = "0px",
                     Bottom = "0px",
                     Left = "0px"
                  },
                  PrintBackground = true,
               });

我已经确认这不是代码本身,因为如果我在浏览器中运行 html,草书字体会按预期工作。有没有人知道如何或是否有可能让草书工作?我想我错过了什么。

【问题讨论】:

    标签: puppeteer-sharp


    【解决方案1】:

    所以我想通了,有两种方法可以解决我的问题。我在 Debian 中运行一个 Docker 容器,它没有安装这个特定的字体。

    解决方案 1:

    1. 从受信任的站点下载并安装 Brush Script MT。
    2. 将 ttf 文件复制到 DockerFile 中的 /usr/local/share/fonts。 例如:
    COPY ["font.ttf", "./usr/local/share/fonts/font.ttf"]
    RUN fc-cache
    

    欲了解更多信息,请参阅此网址:https://wiki.debian.org/Fonts#Adding_fonts

    解决方案 2:

    这是比较懒的路线,也是我走的路线。查找类似的 Google 字体 用草书代替。

    1. 转到https://fonts.google.com/ 并找到与您匹配的字体 需要。

    2. 参考字体。 例如:

      <link href='https://fonts.googleapis.com/css?family=Cookie' rel='stylesheet'>

    .signature {
        font-family: 'Cookie';
    }     
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多