JsPDF无法设置字体系列 [英] jsPDF cannot set font family

查看:0
本文介绍了JsPDF无法设置字体系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法更改字体系列。这是直接从jsPDFwebsite

var doc = new jsPDF();

doc.text(20, 20, 'This is the default font.');

doc.setFont("courier");
doc.setFontType("normal");
doc.text(20, 30, 'This is courier normal.');

doc.setFont("times");
doc.setFontType("italic");
doc.text(20, 40, 'This is times italic.');

doc.setFont("helvetica");
doc.setFontType("bold");
doc.text(20, 50, 'This is helvetica bold.');

doc.setFont("courier");
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');

但以下是打印的目的:

这些都是times字体。为什么字体系列没有更改?

推荐答案

实际上您可以使用

doc.addFont()

例如:

doc.addFont('ArialMS', 'Arial', 'normal');
doc.setFont('Arial');
doc.text(50,150,'Hello World');

这篇关于JsPDF无法设置字体系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆