Jspdf: Set font weight?

Created on 4 Mar 2014  Â·  5Comments  Â·  Source: MrRio/jsPDF

Ok, we have _setFont(fontName, fontStyle)_ where we can set the font name and style. We have _setFontSize(size)_ that sets the font size. We also have _setFontStyle(style)_ to set the font style.
Ok, how to go about setting the font weight? There is no _setFontWeight()_

Support Request

Most helpful comment

setFontType() isn't documented in the https://mrrio.github.io/jsPDF/doc/symbols/jsPDF.html

But you can see it used in http://mrrio.github.io/jsPDF/examples/basic.html

doc.setFontType("bold");
doc.text(20, 20, "This is a bold paragraph");

doc.setFontType("normal")
doc.text(40, 40, "This is a normal font paragraph");

All 5 comments

Font weight is currently set by just changing the font name used. See the example at jsPDF.com—
Sent on the run. Apologies for brevity.

On Tue, Mar 4, 2014 at 4:38 PM, liftarn [email protected] wrote:

Ok, we have _setFont(fontName, fontStyle)_ where we can set the font name and style. We have _setFontSize(size)_ that sets the font size. We also have _setFontStyle(style)_ to set the font style.

Ok, how to go about setting the font weight? There is no _setFontWeight()_

Reply to this email directly or view it on GitHub:
https://github.com/MrRio/jsPDF/issues/199

OK, that is not an option for me.
Thanks anyway.

Hmm, are you adding your own non-bold font?

Well, closing anyway ;-)

setFontType() isn't documented in the https://mrrio.github.io/jsPDF/doc/symbols/jsPDF.html

But you can see it used in http://mrrio.github.io/jsPDF/examples/basic.html

doc.setFontType("bold");
doc.text(20, 20, "This is a bold paragraph");

doc.setFontType("normal")
doc.text(40, 40, "This is a normal font paragraph");

I'd like to have this ticket re-opened:

Why:
eg. Roboto-Medium corresponds to a font-weight of 500.

Currently it's not possible to correctly define the font in css with the font-face declaration:
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: local('Roboto Medium'), local('Roboto-Medium'), font('Roboto-Medium.woff2') format('woff2'), font('Roboto-Medium.woff') format('woff'); font-display: swap; }

.. and render it in jspdf with:
doc.addFileToVFS('Roboto-Medium.ttf', robotoMedium); doc.addFont('Roboto-Medium.ttf', 'Roboto', 'normal');

since we're missing the font-weight in the function above:
doc.addFont('Roboto-Medium.ttf', 'Roboto', 'normal', '500);

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mellisa0109 picture mellisa0109  Â·  3Comments

glaier picture glaier  Â·  3Comments

centurianii picture centurianii  Â·  4Comments

BarathArivazhagan picture BarathArivazhagan  Â·  4Comments

MaxCodeDE picture MaxCodeDE  Â·  4Comments