src/Pdf/PdfWriter.php
public function addFontDirectories(array $paths): self
    {
        $projectDir = System::getContainer()->get('huh.utils.container')->getProjectDir();

        $defaultConfig = (new  ConfigVariables())->getDefaults();
        $fontDirs = $defaultConfig['fontDir'];

        foreach ($paths as $path) {
            $fontDir = $projectDir.\DIRECTORY_SEPARATOR.ltrim($path, \DIRECTORY_SEPARATOR);

            if (!file_exists($fontDir) || !file_exists($fontDir.\DIRECTORY_SEPARATOR.'mpdf-config.php')) {
                continue;
            }

            $configPath = $fontDir.\DIRECTORY_SEPARATOR.'mpdf-config.php';
            $fontConfig = require_once $configPath;

            if (!\is_array($fontConfig)) {
                continue;
            }

            if (!isset($fontConfig['fontDir'])) {
                $fontConfig['fontDir'] = array_merge($fontDirs, [
                    $fontDir,
                ]);
            }

            $this->config = array_merge($this->config, $fontConfig);
        }

        return $this;
    }
public function addFontDirectories(array $paths): self
    {
        $projectDir = System::getContainer()->get('huh.utils.container')->getProjectDir();

        $defaultConfig = (new  ConfigVariables())->getDefaults();
        $fontDirs = $defaultConfig['fontDir'];

        foreach ($paths as $path) {
            $fontDir = $projectDir.\DIRECTORY_SEPARATOR.ltrim($path, \DIRECTORY_SEPARATOR);

            if (!file_exists($fontDir) || !file_exists($fontDir.\DIRECTORY_SEPARATOR.'mpdf-config.php')) {
                continue;
            }

            $configPath = $fontDir.\DIRECTORY_SEPARATOR.'mpdf-config.php';
            $fontConfig = require_once $configPath;

            if (!\is_array($fontConfig)) {
                continue;
            }

            if (!isset($fontConfig['fontDir'])) {
                $fontConfig['fontDir'] = array_merge($fontDirs, [
                    $fontDir,
                ]);
            }

            $this->config = array_merge($this->config, $fontConfig);
        }

        return $this;
    }
public function addFontDirectories ( array $ paths ) : self { $ projectDir = System :: getContainer ( ) -> get ( 'huh.utils.container' ) -> getProjectDir ( ) ; $ defaultConfig = ( new ConfigVariables ( ) ) -> getDefaults ( ) ; $ fontDirs = $ defaultConfig [ 'fontDir' ] ; foreach ( $ paths as $ path ) { $ fontDir = $ projectDir . \ DIRECTORY_SEPARATOR . ltrim ( $ path , \ DIRECTORY_SEPARATOR ) ; if ( ! file_exists ( $ fontDir ) || ! file_exists ( $ fontDir . \ DIRECTORY_SEPARATOR . 'mpdf-config.php' ) ) { continue ; } $ configPath = $ fontDir . \ DIRECTORY_SEPARATOR . 'mpdf-config.php' ; $ fontConfig = require_once $ configPath ; if ( ! \ is_array ( $ fontConfig ) ) { continue ; } if ( ! isset ( $ fontConfig [ 'fontDir' ] ) ) { $ fontConfig [ 'fontDir' ] = array_merge ( $ fontDirs , [ $ fontDir , ] ) ; } $ this -> config = array_merge ( $ this -> config , $ fontConfig ) ; } return $ this ; }
Add font directories to the config.

@param array $paths Directory pathseader

@return PdfWriter Current pdf writer instance
Add font directories to the config .