Fonts - Easy Path
verschoof opened this issue · comments
Mitchel commented
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.. :)
Piotr Śliwa commented
Good idea. I think that path conversion should be on LoaderImpl::loadFonts method level.