jsPDF-CustomFonts-support
jsPDF-CustomFonts-support copied to clipboard
Incorrect characters pulled from custom font
Using: https://sphilee.github.io/jsPDF-CustomFonts-support/# with this font baloo-tamma-v3-latin.zip Downloaded from here: https://google-webfonts-helper.herokuapp.com/fonts/baloo-tammudu?subsets=latin With the following code: ` doc.addFont('baloo-tamma-v3-latin-regular.ttf', 'custom', 'normal');
doc.setFont('custom'); doc.text(15, 15, 'ABCDEFabcdefgAAAAAAAAAAAAAAAAAAAB'); `
Gnerates a pdf with the following text:
!"#$%&'()*+,-!!!!!!!!!!!!!!!!!!!"
Base64 decoding the file using https://www.base64decode.org/ generates a ttf file which looks correct so it can't be the font data.
Exactly the same problem here: When using certain TTF fonts in the test editor I get the mentioned output while others work with no problems. Cannot seem to find a reason or pattern when or why this happens. The TTF is not damaged or corrupt, can be normally used. Any ideas..?
I've attached 2 TTFs: Academy-F2W ist not working, Autour-One is.
Obviously the char map/glyph order, or however you call it, seems to get shifted or offset for fonts like the Academy-F2W I have attached above.
This code:
doc.text(15, 15, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ '\nabcdefghijklmnopqrstuvwxyz'
+ '\n1234567890'
+ '\näöüß ÄÖÜ'
+ '\n!"§$%&/()=?'
);
Outputs the following:
!"#$%&'()*+,-./0123456789:
;<=>?@ABCDEFGHIJKLMNOPQRST
UVWXYZ[\]^
_`abcdef
ghijklmnonpqr
Strange …
I experience the same problem.
It also happens when using the Base64 encoder on https://www.giftofspeed.com/base64-encoder/
or when uploading the files to the authors' demo page: https://sphilee.github.io/jsPDF-CustomFonts-support/
This last thing is kind of a good thing, because you first check a font in this demo. If it works there, it will work in your project.
BTW, I triend quite a lot of fonts. 75% of them did not work. Among them, "Source Sans" and "Fira Sans",... which really are quite common.
@ideogram @tomgloeckler @devops-at-alinea Do you guys solved this problem?
Having same problem here with other font...