Skip to content

How to use custom fonts in a craft setup #138

@JulieVelghe

Description

@JulieVelghe

Question

Hello,
for a clients website, we would like to be be able to style the generated pdf's with a custom font. For our pdf settings (in wishlist.php), we have the following settings:
// PDF
'pdfFilenameFormat' => 'karakters-{id}',
'pdfPath' => '_pdf/template',
'pdfAllowRemoteImages' => true,
'pdfPaperSize' => 'A4',
'pdfPaperOrientation' => 'portrait',

in our template twig file we have for example this code: @font-face {
font-family: 'Mona Sans Wide';
font-style: italic;
font-weight: 800;
src: url({{ "#{currentSite.baseUrl}assets/dist/fonts/Mona-Sans/Mona-Sans-ExtraBoldWideItalic.ttf" }}) format('truetype');
}

and we use a css file like this:

<style>{{ source('_pdf/assets/css/layout.css') }}</style>

screenshot of our folder structure:
image

Unfortunately the fonts get ignored. Is there any way to get to use those ttf files?

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions