Horde_Pdf_Writer::addFont PHP Method

addFont() public method

The location of the definition file (and the font file itself when embedding) must be found at the full path name included. Example: $pdf->addFont('Comic', 'I'); is equivalent to: $pdf->addFont('Comic', 'I', 'comici.php');
See also: setFont()
public addFont ( string $family, string $style = '', string $file = '' )
$family string Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
$style string Font style. Possible values are (case insensitive): - empty string: regular (default) - B: bold - I: italic - BI or IB: bold italic
$file string The font definition file. By default, the name is built from the family and style, in lower case with no space.
    public function addFont($family, $style = '', $file = '')
    {
        $family = Horde_String::lower($family);
        if ($family == 'arial') {
            $family = 'helvetica';
        }
        $style = Horde_String::upper($style);
        if ($style == 'IB') {
            $style = 'BI';
        }
        if (isset($this->_fonts[$family . $style])) {
            throw new Horde_Pdf_Exception(sprintf('Font already added: %s %s', $family, $style));
        }
        if ($file == '') {
            $file = str_replace(' ', '', $family) . Horde_String::lower($style) . '.php';
        }
        include $file;
        if (!isset($name)) {
            throw new Horde_Pdf_Exception('Could not include font definition file');
        }
        $i = count($this->_fonts) + 1;
        $this->_fonts[$family . $style] = array('i' => $i, 'type' => $type, 'name' => $name, 'desc' => $desc, 'up' => $up, 'ut' => $ut, 'cw' => $cw, 'enc' => $enc, 'file' => $file);
        if ($diff) {
            /* Search existing encodings. */
            $d = 0;
            $nb = count($this->_diffs);
            for ($i = 1; $i <= $nb; $i++) {
                if ($this->_diffs[$i] == $diff) {
                    $d = $i;
                    break;
                }
            }
            if ($d == 0) {
                $d = $nb + 1;
                $this->_diffs[$d] = $diff;
            }
            $this->_fonts[$family . $style]['diff'] = $d;
        }
        if ($file) {
            if ($type == 'TrueType') {
                $this->_font_files[$file] = array('length1' => $originalsize);
            } else {
                $this->_font_files[$file] = array('length1' => $size1, 'length2' => $size2);
            }
        }
    }