mittwald / typo3-web2pdf

A TYPO3 extension for rendering content as PDF
GNU General Public License v2.0
18 stars 20 forks source link

Custom font definition not respected #116

Open cdaecke opened 3 years ago

cdaecke commented 3 years ago

Thanks a lot for sharing your extension!

I am trying to use some custom font in generated PDF files. This is my CSS definition:

.teaser {
    font-family: DINWeb;
    font-size: 15px;
    line-height: 20px;
    margin-top: 0;
    font-weight: normal;
}

The font file is located in EXT:web2pdf/Resources/Public/Fonts/. The file is named DINWeb.ttf.

Unfortunately the font is not used for <div class="teaser">Test</div>.

Am I missing something?

TYPO3: v10.4.8 ext:web2pdf: v 2.0.1

lilu82 commented 3 years ago

Same problem here. Pls help , how can I add my own font? It's not working this way.

kriemhildt commented 3 years ago

Found a (temporary) solution: Because web2pdf is using mpdf, a possible way to change the font-family is by copying a mpdf-font and putting it into the EXT:web2pdf/Resources/Public/Fonts/ folder with all available options (italic, bold, bolditalic etc.). Then set the font-family in your Print.css (I tested with FreeSans):

h2 {
    margin-top: 10mm;
    font-family: FreeSans;
}

Available fonts can be found in vendor/mpdf/mpdf/ttfonts/. Unfortunately and afaik any other fonts won't work (e.g. icomoon).

This works with TYPO3 v10.4.18 and web2pdf v2.0.3 (composer and latest)

rei-we commented 3 years ago

I had an earlier version running and struggled with the actual. Solved by adding in the web2pdf\Resources\Private\Libraries\vendor\mpdf\mpdf\src\Config\FontVariables.php under 'fontdata' possibly at the end about line 153 after "freemono" for example "futura-pt" => [ 'R' => "TT0138xxx.TTF", 'I' => "TT0139xxx.TTF", 'B' => "TT0144xxx.TTF", 'BI' => "TT0145xxx.TTF", ], The above named fonts must be in the already mentioned folder EXT:web2pdf/Resources/Public/Fonts/. Good luck!

kriemhildt commented 2 years ago

I'm having trouble again with this issue and my workaround from 5th Aug 2021 doesn't seem to work for me anymore.

p-view commented 3 weeks ago

Any chance to use custom fonts right now?