Smalot\PdfParser\Page::getFonts PHP Method

getFonts() public method

public getFonts ( ) : Smalot\PdfParser\Font[]
return Smalot\PdfParser\Font[]
    public function getFonts()
    {
        if (!is_null($this->fonts)) {
            return $this->fonts;
        }
        $resources = $this->get('Resources');
        if (method_exists($resources, 'has') && $resources->has('Font')) {
            if ($resources->get('Font') instanceof Header) {
                $fonts = $resources->get('Font')->getElements();
            } else {
                $fonts = $resources->get('Font')->getHeader()->getElements();
            }
            $table = array();
            foreach ($fonts as $id => $font) {
                if ($font instanceof Font) {
                    $table[$id] = $font;
                    // Store too on cleaned id value (only numeric)
                    $id = preg_replace('/[^0-9\\.\\-_]/', '', $id);
                    if ($id != '') {
                        $table[$id] = $font;
                    }
                }
            }
            return $this->fonts = $table;
        } else {
            return array();
        }
    }