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

Doesn't support real custom fonts #388

Closed
poletaew opened this issue Jan 21, 2020 · 3 comments
Closed

Doesn't support real custom fonts #388

poletaew opened this issue Jan 21, 2020 · 3 comments

Comments

@poletaew
Copy link

I have custom font on the DokuWiki page. And there is no options to use the same font in PDF. As I see there is hardcoded DejaVu font.

Moreover, after I edited DokuPDF class with following codes, it also didn't help:

... line 50 ...
                $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
		$fontDirs = $defaultConfig['fontDir'];
		
		$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
		$fontData = $defaultFontConfig['fontdata'];

        // we're always UTF-8
        parent::__construct(
            array(
                'mode' => $mode,
                'format' => $format,
                'fontsize' => $fontsize,
                'ImageProcessorClass' => DokuImageProcessorDecorator::class,
                'tempDir' => _MPDF_TEMP_PATH, //$conf['tmpdir'] . '/tmp/dwpdf',
				'fontDir' => array_merge($fontDirs, [
					__DIR__ . '/../../tpl/dnd/fonts',
				]),
				'fontdata' => $fontData + [
					'Nodesto' => [
						'R' => 'Nodesto.otf'
					]
				],
				'default_font' => 'Nodesto'
            )
        );

Is there a way to use custom font in dw2pdf?

@demaddis
Copy link

Not sure this is the best/recommended way, but I got this to work by adding my custom font to vendor/mpdf/mpdf/src/Config/Fontvariables.php:

                        'fontdata' => [
                                "roboto" => [
                                        'R' => "Roboto-Light.ttf",
                                        'B' => "Roboto-Medium.ttf",
                                        'I' => "Roboto-Italic",
                                        'BI' => "Roboto-BoldItalic.ttf",
                                ],

and then setting roboto as font-family in my style.css.

@arjay54
Copy link

arjay54 commented Mar 3, 2021

Perfect!

@Klap-in
Copy link
Collaborator

Klap-in commented Oct 12, 2022

I would expect, that an approach like the startpost should be possible. Maybe some details needs attention there?

Proposals to add other fonts to the configuration of mpdf are welcome.
Please let continue the discussion in similar issue #445.

@Klap-in Klap-in closed this as completed Oct 12, 2022
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

4 participants