Skip to content
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

Custom font definition not respected #116

Open
cdaecke opened this issue Jan 23, 2021 · 5 comments
Open

Custom font definition not respected #116

cdaecke opened this issue Jan 23, 2021 · 5 comments

Comments

@cdaecke
Copy link

cdaecke commented Jan 23, 2021

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
Copy link

lilu82 commented Aug 4, 2021

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

@kriemhildt
Copy link

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
Copy link

rei-we commented Aug 14, 2021

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
Copy link

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
Copy link

p-view commented Oct 14, 2024

Any chance to use custom fonts right now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants