-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fonts with different font-weights #2920
Comments
Hi, I would like to help with this issue, could you please assign it to me? |
Sure, thanks :) Make sure to make the new API backwards compatible. |
I can take this, if no one is proceeding with it. @HackbrettXXX Can you provide me some direction on this one. |
@vbinithyanandamv font style and font weight are currently stored in the In an optimal solution, we would probably completely separate font style and font weight. This would add another parameter to methods like The second approach would be to extend the current encoding in a single string by the numeric values, e.g. |
@HackbrettXXX So should i just provide an API like below
since we already have two more param in between, will make the last one as optional. and when adding will combine it out
will that be a good way to go about it? It will also be backwards compatible too. |
The public API method currently has only 4 parameters:
Since the encoding parameter is optional and has only 4 valid values ("StandardEncoding", "MacRomanEncoding", "Identity-H", "WinAnsiEncoding"), I think we can put the new
Make sure that passing an encoding without Regarding the "normal" value:
|
@HackbrettXXX Makes sense. How do u think we should handle the invalid case? Throwing error or any standard we already follow on invalid cases? |
I think throwing an error is good :) |
Resolved in #3036. |
Cross-Link to original issue #199.
Request to extend the 'addFont' with an additional parameter for font-weights. (or even better, replace the 'font-style' definition):
Why:
As of now, there's a missmatch between the possibility to define font-weights and font-styles in css and what's possible in jsPDF. Several popular font-families consist out of several individual fonts, which define their style primarly on the font-weight, not the font-style.
For example, the popular Roboto font defines for 'bold' either the Roboto-Medium (with 500 weight) and Roboto-Bold (with 700 weight). With the current implementation and the font-matching done purely on font-style, it is not possible to have both of those fonts defined in the same pdf-report. (since font weight maps to ['normal', 'italic', 'bold', ... ])
font-face declaration of roboto medium:
currently possible to be render it in jspdf with:
desired call with font-weight:
doc.addFont('Roboto-Medium.ttf', 'Roboto', 'normal', '500');
The text was updated successfully, but these errors were encountered: