Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
class FontFactory {
3
  var $fonts;
4
  var $error_message;
5
 
6
  var $_trueType;
7
 
8
  function error_message() {
9
    return $this->error_message;
10
  }
11
 
12
  function FontFactory() {
13
    $this->fonts = array();
14
  }
15
 
16
  /**
17
   * Note that typeface  is not a font file  name; example of typeface
18
   * name  could  be  'Times-Roman'  or  'ArialUnicodeMS'.  Note  that
19
   * typeface  names  are  for  internal  use only,  as  they  do  not
20
   * correspond  to  any system  font  names/parameters; all  typeface
21
   * names and their relateions to system fonts are defined in html2ps
22
   * config
23
   *
24
   * @param $typeface String name of the font typeface
25
   * @param $encoding String
26
   *
27
   */
28
  function &getTrueType($typeface, $encoding) {
29
    if (!isset($this->fonts[$typeface][$encoding])) {
30
      global $g_font_resolver_pdf;
31
      $fontfile = $g_font_resolver_pdf->ttf_mappings[$typeface];
32
 
33
      $font = FontTrueType::create($fontfile, $encoding);
34
      if (is_null($font)) {
35
        $dummy = null;
36
        return $dummy;
37
      };
38
 
39
      $this->fonts[$typeface][$encoding] = $font;
40
    };
41
 
42
    return $this->fonts[$typeface][$encoding];
43
  }
44
 
45
  function &get_type1($name, $encoding) {
46
    if (!isset($this->fonts[$name][$encoding])) {
47
      global $g_font_resolver;
48
 
49
      $font =& FontType1::create($name, $encoding, $g_font_resolver, $this->error_message);
50
      if (is_null($font)) {
51
        $dummy = null;
52
        return $dummy;
53
      };
54
 
55
      $this->fonts[$name][$encoding] = $font;
56
    };
57
 
58
    return $this->fonts[$name][$encoding];
59
  }
60
}
61
 
62
?>