JsPdf 有没有办法支持自定义孟加拉字体?

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

我在我的一个项目中集成了 JsPDF,但它没有正确显示孟加拉字体。

我尝试了各种方法,例如字体编码和addToVFS在样式表中使用@font-face
支持自定义字体的示例代码。

var doc = new jsPDF();

doc.addFont('SiyamRupali.ttf', 'custom', 'normal');

doc.setFont('custom');
doc.text(15, 15, 'মাইক্রোসফট আফিস ট্রেনিং গাইড');

我得到了这个结果 “þÿ ® ¸ ‡ • Í ° Ë ¸ « Ÿ † « ¿ ¸ Ÿ Í ° Ç ¡ ¿ — ¸ ‡ ¡”而不是 "মাইক্রোসফট আফ࿸ ট ্রেনিংগাইড”

javascript jspdf
2个回答
0
投票

首先您需要从在此处输入链接描述

转换字体

那么, 更改 SolaimanLipi-normal.js 文件-> 来自,

import { jsPDF } from "jspdf"

import jsPDF from "jspdf"

那么,

import 'assets/fonts/SolaimanLipi-normal.js';
import jsPDF from 'jspdf';

const doc = new jsPDF();

doc.setFont('SolaimanLipi'); // set custom font (SolaimanLipi)
doc.setFontSize(10); // set font size 10
doc.text('মাইক্রোসফট আফিস ট্রেনিং গাইড', x, y) // and you can write your text with starting co-ordinator

you can check your font is added or not
console.log('fonts', doc.getFontList());

0
投票

不幸的是没有!我也去过图书馆。该库支持通用孟加拉语。但是 jsPdf 不支持或无法读取我们日常使用的常用格式和编码。

var doc = new jsPDF()
doc.text(10, 10, 'This is a test')
doc.setLanguage("Bengali")
doc.save('bangla.pdf')
© www.soinside.com 2019 - 2024. All rights reserved.