parallax / jsPDF

Client-side JavaScript PDF generation for everyone.
https://parall.ax/products/jspdf
MIT License
29.32k stars 4.68k forks source link

Contextual alternates and ligatures in hand-written fonts #3242

Open utilmind opened 3 years ago

utilmind commented 3 years ago

Hello! I have prepared https://jsfiddle.net/utilmind/o1gbyL9j/, that demonstrates issue with contextual alternates for glyphs in "hand-written" fonts.

Please pay attention on the last characters in each word: "Hello world hey". You see that original HTML text have doesn't have tails in the final character of each word.

However if you create PDF with exactly the same text and exactly the same font (it's "Pacifico" from Google fonts), clicking the "Make PDF" button, you will see, that the words in produced PDF all have tails at the end.

Does jsPDF have a feature similar to "font-variant-ligatures" CSS property? Thanks!

utilmind commented 3 years ago

I researched more and found that Adobe Illustrator is also able to "alternate" the look of some characters, although not automatically (in HTML contextual alternates controlled with "font-variant-ligatures" CSS property). Manually I can switch to "Appearance / OpenType" tab and apply "Contextual Alternates" setting to some single character or group of characters...

Is there way to apply "Contextual Alternates" for the text drawn with text() method of jsPDF?

(Of course I still researching, but maybe this is known issue.)

utilmind commented 3 years ago

Ok, now I see that jsPDF is just missing OpenType features, described on https://helpx.adobe.com/fonts/using/open-type-syntax.html All I need is Contextual alternates (calt), which supposed to be enabled by default, but missing in jsPDF...

Still researching, but thinking about implementing these features in jsPDF... I know that it's possible, since they are implemented in the mPDF for PHP (https://github.com/mpdf/mpdf/blob/development/src/Otl.php)

HackbrettXXX commented 3 years ago

Thanks for reporting this. A pull request would be welcome ;)