Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with embedding a TTF font #2710

Closed
tschero opened this issue Mar 26, 2020 · 10 comments
Closed

Problems with embedding a TTF font #2710

tschero opened this issue Mar 26, 2020 · 10 comments

Comments

@tschero
Copy link

tschero commented Mar 26, 2020

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.
#2708

Best Regards

@HackbrettXXX
Copy link
Collaborator

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?

@tschero
Copy link
Author

tschero commented Mar 26, 2020

TTF File
wingdings-cufonfonts.zip

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

@tschero
Copy link
Author

tschero commented Mar 26, 2020

Converted Fontfile:

wingdings-cufonfonts.zip

@tschero
Copy link
Author

tschero commented Mar 30, 2020

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

@HackbrettXXX
Copy link
Collaborator

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.

@tschero
Copy link
Author

tschero commented Mar 30, 2020

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

@tschero
Copy link
Author

tschero commented Apr 2, 2020

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

@HackbrettXXX
Copy link
Collaborator

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 ;)

@moneyeyedan
Copy link

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

@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants