Score:0

Font style isn't applied on PDF (entity print)

kn flag

I'm using Entity print with my webforms. I've followed those steps https://www.drupal.org/node/2706755 to add the css into my PDF.

My classes are applied (color, padding...), but for some reason, the fonts are never applied on the generated PDF, but is applied on the debug : https://.../print/pdf/webform_submission/10/debug

Font are not applied with CDN @import url('https://fonts.cdnfonts.com/css/aphont');

or with local font files

@font-face {
  font-family: "APHont";
  font-style: Italic;
  font-weight: 700;
  //URLs are OK
  src: url("./font/aphont-bold-italic.woff2") format("woff2"), url("./font/aphont-bold-italic.woff") format("woff"); 
}

body {
  font-family: 'APHont', 'Arial', serif; //even Arial is not applied
}

I'm using drupal 9.5.1, entity print 9.11 and DomPDF (i've been digging into others issues on entity print, but could'nt find any matching solution)

Kevin avatar
in flag
Pretty sure asset includes have to be full URLs / paths on the server and not relative.
Kevin avatar
in flag
https://github.com/dompdf/dompdf/issues/1401#issuecomment-589543115
kn flag
It helps. Works with relative, see my answer, thanks a lot
Score:0
kn flag

Works by doing this (thanks to this https://github.com/dompdf/dompdf/issues/1566#issuecomment-591955876) :

  1. Using ttf
  2. not apply font-family to the body
  3. add font-weight to each tag you want to apply the font (h1, p...)

The result in css :

@font-face {
  font-family: "APhont";
  font-style: normal;
  font-weight: bold;
  src: url("./font/aphont-bold.ttf") format("truetype");
}

h1 {
  font-family: APhont, serif;
  font-weight: bold; //very important
}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.