psliwa / PHPPdf

Pdf and graphic files generator library written in php

Home Page:http://ohey.pl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fonts - Easy Path

verschoof opened this issue · 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.. :)

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