yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
649 stars 98 forks source link

Add fonts with different font-weights #181

Closed EugeneBalabai closed 2 years ago

EugeneBalabai commented 3 years ago

Based on: https://github.com/MrRio/jsPDF/pull/3036

Now users can use any combination of font-weight and font-style

EugeneBalabai commented 3 years ago

Hey @HackbrettXXX

Thanks for review yep, we can pass font-weight as separate arguments to setFont and I will do it (a bit later). But what about findFirstAvailableFontFamily? We still need to combine font style and font-weight with the same algorithm as jsPDF to get the correct fontFamily. Or do you have any ideas on how we can solve this?

HackbrettXXX commented 3 years ago

Ah, good catch! Unfortunately, I don't have a better idea for findFirstAvailableFontFamily. I guess, If we're forced to combine font style/weight manually anyway, we can just take your initial implementation.

Could you have a look at the failing tests? Seems like some test cases produce different results now. The new results are probably correct, though. Please update the reference files in that case.

HackbrettXXX commented 3 years ago

I've added some changes: the function for combining fonts was actually not correct in jsPDF. I've fixed it there (https://github.com/MrRio/jsPDF/pull/3217). The fix will be released with jsPDF@2.4.0. I've added a version switch to svg2pdf, so it will work with both jsPDF versions. The tests will fail until we update to jsPDF@2.4.0. We can do so, once it's released.

EugeneBalabai commented 3 years ago

@HackbrettXXX great job! Do you know when it will release?

HackbrettXXX commented 3 years ago

Hopefully soon ;)