jsPDF-CustomFonts-support icon indicating copy to clipboard operation
jsPDF-CustomFonts-support copied to clipboard

Incorrect characters pulled from custom font

Open devops-at-alinea opened this issue 7 years ago • 4 comments

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: !"#$%&'()*+,-!!!!!!!!!!!!!!!!!!!"

demo (2).pdf

Base64 decoding the file using https://www.base64decode.org/ generates a ttf file which looks correct so it can't be the font data.

devops-at-alinea avatar Jun 07 '18 15:06 devops-at-alinea

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.

Academy-F2W.ttf.zip Autour-One.ttf.zip

tomgloeckler avatar Aug 08 '18 07:08 tomgloeckler

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 …

tomgloeckler avatar Aug 08 '18 08:08 tomgloeckler

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 avatar Aug 25 '18 08:08 ideogram

@ideogram @tomgloeckler @devops-at-alinea Do you guys solved this problem?

Having same problem here with other font...

abisewski avatar Feb 23 '19 19:02 abisewski