PHPPdf icon indicating copy to clipboard operation
PHPPdf copied to clipboard

Fonts - Easy Path

Open verschoof opened this issue 11 years ago • 1 comments

I'm not sure if I'm right or if its the right solution, but see it as a discussion.

In my case I work with the PdfBundle, there I can point to my fonts.xml In the fonts.xlm I have to add fonts with name and path, now, I don't want to put a full path in the XML file, so my idea is: If you use the "./arial/normal.ttf" it will take the file path as base path.

prototype:

vendor/psliwa/php-pdf/lib/PHPPdf/Core/Configuration/LoaderImpl.php

        if (preg_match('/font/', $file)) {
            $dirname = dirname($file);
            if (is_array($result)) {
                foreach ($result as $fontName => $files) {
                    foreach ($files as $key => $file) {
                        if (substr($file, 0, 2) == './') {
                            $result[$fontName][$key] = str_replace('./', $dirname . '/', $file);
                        }
                    }
                }
            }
        }

Please some feedback.. :)

verschoof avatar Sep 22 '14 15:09 verschoof

Good idea. I think that path conversion should be on LoaderImpl::loadFonts method level.

psliwa avatar Sep 28 '14 14:09 psliwa