1<?php
2
3namespace Mpdf\Fonts;
4
5class FontFileFinder
6{
7
8	private $directories;
9
10	public function __construct($directories)
11	{
12		$this->setDirectories($directories);
13	}
14
15	public function setDirectories($directories)
16	{
17		if (!is_array($directories)) {
18			$directories = [$directories];
19		}
20
21		$this->directories = $directories;
22	}
23
24	public function findFontFile($name)
25	{
26		foreach ($this->directories as $directory) {
27			$filename = $directory . '/' . $name;
28			if (file_exists($filename)) {
29				return $filename;
30			}
31		}
32
33		throw new \Mpdf\MpdfException(sprintf('Cannot find TTF TrueType font file "%s" in configured font directories.', $name));
34	}
35}
36