Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

font-weight: lighter" style does not seems to be working with lighter fonts in flying-saucer. Any solution?

I've included OpenSans-Light.ttf in source. If I added either font-weight: lighter or font-weight: 200 it is not getting applied on PDF. Always the regular font style is getting applied.

Any solution/workaround would be much appreciated.

like image 829
NkS Avatar asked Dec 09 '25 23:12

NkS


2 Answers

mPDF does not support multiple weights for a font face - just normal and bold

http://www.mpdf1.com/forum/discussion/1369/open-sans-problems-with-bold-font-weight/p1

like image 188
Lyuba Yevdokimova Avatar answered Dec 12 '25 12:12

Lyuba Yevdokimova


One workaround is to use .light {font-family:Open Sans Light}

Here's an example of what you get: enter image description here


Another solution, which gives the same result is to use font-faces like this:

@font-face {
  font-family: 'Open Sans';
  src: url("font/OpenSans-Regular.ttf");
  -fs-pdf-font-embed: embed;
  -fs-pdf-font-encoding: Identity-H;
}
@font-face {
  font-family: 'Open Sans';
  src: url("font/OpenSans-Light.ttf");
  font-weight:200;
  -fs-pdf-font-embed: embed;
  -fs-pdf-font-encoding: Identity-H;
}
.normal{font-family:Open Sans;}
.lighter{font-family:Open Sans;font-weight:200}
like image 23
obourgain Avatar answered Dec 12 '25 13:12

obourgain