jsPDF icon indicating copy to clipboard operation
jsPDF copied to clipboard

Problems with embedding a TTF font

Open tschero opened this issue 6 years ago • 10 comments

Hi there,

I bind several fonts acc. the given description. https://github.com/MrRio/jsPDF#use-of-utf-8--ttf This works e.g. with the ARIAL and ARIALBD font. Certain special characters are also displayed correctly.

However, I need a frame and a fisheye. For this I want to use the Wingdings font. Unfortunately, the integration of this font does not work. The following error occurs: jsPDF PubSub Error No unicode cmap for font Error: "No unicode cmap for font"

jspdf_wingding

The font appears in the font map. What is possibly wrong here.

How can I use a FishEye and other characters in the PDF as shown here? https://www.key-shortcut.com/schriftsysteme/35-symbole/symbole-typographie

Is a different font necessary?

This thread is known to me but does not help. https://github.com/MrRio/jsPDF/issues/2708

Best Regards

tschero avatar Mar 26 '20 11:03 tschero

Either your Wingdings font is faulty or this is a bug of jsPDF. In order to check this, could you attach your converted font file?

HackbrettXXX avatar Mar 26 '20 12:03 HackbrettXXX

TTF File wingdings-cufonfonts.zip

Download Source for TTF File: https://www.cufonfonts.com/font/wingdings

tschero avatar Mar 26 '20 12:03 tschero

Converted Fontfile:

wingdings-cufonfonts.zip

tschero avatar Mar 26 '20 13:03 tschero

Or is there possibly another font or possibility (except images) to create graphics, such as a frame and a fisheye?

tschero avatar Mar 30 '20 05:03 tschero

You can of course use the path drawing commands: moveTo. lineTo, curveTo, rect, ellipse, etc. Or you can use SVG images and convert them with svg2pdf.

I haven't had the time yet to look into the font file, sorry.

HackbrettXXX avatar Mar 30 '20 07:03 HackbrettXXX

It's ok, I would still rather wait a little longer for the result with the font.

tschero avatar Mar 30 '20 08:03 tschero

Hello, is there anything new on this topic? I absolutely need this function. Best Regards.

tschero avatar Apr 02 '20 08:04 tschero

Ok, I just had a look at the font code and read a bit about OpenType fonts. Turns out, jsPDF does not support this kind of font. Your Wingdings font has a platformID of 3 (Windows) and an encodingID of 0 (Symbol). See also here. In order to map JavaScript characters to the glyphs in the font, jsPDF requires a "Unicode to glyph" mapping, i.e. an encodingID of 1.

So, sadly, you need to either use a different font, convert your font so it has a Unicode cmap, or draw the symbols manually.

If you want to and have the time for that you may, of course, also implement support for Symbol (0) cmap encodings. We are always happy about pull requests ;)

HackbrettXXX avatar Apr 02 '20 09:04 HackbrettXXX

hii jspdf code here let pdfbasefont1; await this.pdfImages("Italiana-Regular.ttf",(base64Data)=>{ pdfbasefont1 =base64Data; }); doc.addFileToVFS("MarkaziText-Regular", pdfbasefont1); doc.addFont('MarkaziText-Regular', 'markazi-text', 'normal'); doc.setFont('markazi-text'); this is work on the local machine but i host the aws server custom font not working,please any one resolve this problem

moneyeyedan avatar Apr 30 '20 04:04 moneyeyedan

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

github-actions[bot] avatar Jul 30 '20 01:07 github-actions[bot]