Skip to content

How can I use a custom font? #3404

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

Closed
PhilippJR opened this issue Apr 7, 2022 · 5 comments
Closed

How can I use a custom font? #3404

PhilippJR opened this issue Apr 7, 2022 · 5 comments

Comments

@PhilippJR
Copy link

"I have read and understood the contribution guidelines.".

I know, this question has been asked several times, but whatever I try, I do not get my custom font in the generated pdf.
I already created a Stack Overflow question. Any help is greatly appreciated.

Thanks

Philipp

@PhilippJR
Copy link
Author

Does anyone have a suggestion, what I could try? I really need this custom font.

Many many thanks!

@HackbrettXXX
Copy link
Collaborator

Some fonts are just not supported ATM. You might have a look at #3152 and #2276.

@PhilippJR
Copy link
Author

PhilippJR commented Apr 28, 2022

Thanks @HackbrettXXX.

The first link you sent, is about Japanese letters. You commented

Looks like jsPDF does not support this type of font.

Did you mean non-latin letters with "this type of font"? Then, this cannot be my problem, since I want to implement Source Sans Pro.

The second link is a feature request for .otf fonts. This should also not be the problem, since I downloaded Source Sans Pro as .ttf.

I stepped over addFont(). Could it be, that this part is missing in my code? getFontList() does not list Source Sans Pro. Unfortunately, I do not understand how to implement addFont().

Thanks again

Philipp

@PhilippJR
Copy link
Author

Let me give you a real good reason, to have a look at this issue:
I am working on a Blazor WASM application. I need to create a pdf at runtime and since one strength of Blazor WASM is that it can run offline, it could be that there is no internet connection. Therefore, the pdf must be created client side.
Currently, even DevExpress and Syncfusion cannot support this. They have Blazor WASM libraries but for pdf creation they need a server. So, I tried different ways to create a pdf client side. Looks like jsPDF is the only one that can do it client side (and is sophisticated enough).

My problem is, that I cannot code in JavaScript. Probably, it is really simple to fix and I just have to add the font or something...

@PhilippJR
Copy link
Author

Please find the solution on Stack Overflow.

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

No branches or pull requests

2 participants