Greek custom fonts, not supported in new version.
I'm using the latest version of jsPDF and have managed to successfully implement custom fonts for almost any language (Cyrillic, Japanese etc)! But no matter what I have tried, Greek fonts are never correctly reproduced to .pdf. I encode them to Base64 using your converter and use this code:
var doc = new jsPDF();
doc.addFileToVFS("Arialbd.ttf", font);
doc.addFont("Arialbd.ttf", "arialbd", "bold");
doc.setFont('arialbd');
doc.text(50,50,'Καλημέρα');```
But instead of 'Καλημέρα' I see some bizarre characters being produced. And this happens with all the Greek fonts I have tried. Any idea why this happens with Greek characters? Is it a bug?
Can you provide the testcase in a zip-file?
Thanks for the prompt reply. I'm attaching a test case zip file including the original font I used to encode to base64 (I can also send you more fonts to try but it's the same with every font I tried - no Greek characters are displayed) GreekCharacters.zip Any insight on what might be causing this issue would be greatly appreciated.
verified as a bug.
If you do setFont("Arialbd") it would work. there is a problem with case sensitivity
After several more tests with other fonts, I realized that the issue described above occured in certain fonts only. Upon testing it with a font that is free to use (Arial Unicode) -despite its big size (a little more than 20mb)- I can verify that it covers the vast majority of languages (including cyrillic, Greek, Asian etc). So by encoding that font to Base64 I'm now able to display Greek properly through jsPDF.
And yes, you are right about the case sensitivity, cause even the Arial Unicode font does not work if I use different letter capitalization.
i reopen this issue, because it is still a bugreport
Indeed, sorry for rushing to close it.
It is not a bug. I realized, that your code is faulty.
var greek_text = $('#greektext').val();
var doc = new jsPDF();
doc.addFileToVFS("Arialbd.ttf", font);
doc.addFont("Arialbd.ttf", "arialbd", "bold");
doc.setFont('arialbd', 'bold');
you should have selected the font as bold. You did not, so jsPDF couldnt find the font. If you modify your code accordingly your font will work.
No Bug.
Unfortunately, it does not work if I set the font in "bold". If you notice my initial thread post, I had set the font as bold. Even after using correct capitalization and setting it to bold it reproduces the characters incorrectly. I just tried it. I'm reattaching a test case including the original font that was converted to Base64, so that you verify this. So it is still a bug. GreekFontsApp.zip
It works as expected if you use the latest jspdf (1.5.3) and set the font to bold ( doc.setFont('Arialbd', 'bold'); )