Issues (661)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

fpdf/korean.php (27 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
if (!defined('XOOPS_ROOT_PATH')) {
3
  die('XOOPS root path not defined');
4
}
5
6
require('fpdf.php');
7
8
$UHC_widths=array(' '=>333,'!'=>416,'"'=>416,'#'=>833,'$'=>625,'%'=>916,'&'=>833,'\''=>250,
9
  '('=>500,')'=>500,'*'=>500,'+'=>833,','=>291,'-'=>833,'.'=>291,'/'=>375,'0'=>625,'1'=>625,
10
  '2'=>625,'3'=>625,'4'=>625,'5'=>625,'6'=>625,'7'=>625,'8'=>625,'9'=>625,':'=>333,';'=>333,
11
  '<'=>833,'='=>833,'>'=>916,'?'=>500,'@'=>1000,'A'=>791,'B'=>708,'C'=>708,'D'=>750,'E'=>708,
12
  'F'=>666,'G'=>750,'H'=>791,'I'=>375,'J'=>500,'K'=>791,'L'=>666,'M'=>916,'N'=>791,'O'=>750,
13
  'P'=>666,'Q'=>750,'R'=>708,'S'=>666,'T'=>791,'U'=>791,'V'=>750,'W'=>1000,'X'=>708,'Y'=>708,
14
  'Z'=>666,'['=>500,'\\'=>375,']'=>500,'^'=>500,'_'=>500,'`'=>333,'a'=>541,'b'=>583,'c'=>541,
15
  'd'=>583,'e'=>583,'f'=>375,'g'=>583,'h'=>583,'i'=>291,'j'=>333,'k'=>583,'l'=>291,'m'=>875,
16
  'n'=>583,'o'=>583,'p'=>583,'q'=>583,'r'=>458,'s'=>541,'t'=>375,'u'=>583,'v'=>583,'w'=>833,
17
  'x'=>625,'y'=>625,'z'=>500,'{'=>583,'|'=>583,'}'=>583,'~'=>750);
18
19
class PDF_Korean extends FPDF
20
{
21 View Code Duplication
function AddCIDFont($family,$style,$name,$cw,$CMap,$registry)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
  $fontkey=strtolower($family).strtoupper($style);
24
  if(isset($this->fonts[$fontkey]))
25
    $this->Error("Font already added: $family $style");
26
  $i=count($this->fonts)+1;
27
  $name=str_replace(' ','',$name);
28
  $this->fonts[$fontkey]=array('i'=>$i,'type'=>'Type0','name'=>$name,'up'=>-130,'ut'=>40,'cw'=>$cw,'CMap'=>$CMap,'registry'=>$registry);
29
}
30
31 View Code Duplication
function AddCIDFonts($family,$name,$cw,$CMap,$registry)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
{
33
  $this->AddCIDFont($family,'',$name,$cw,$CMap,$registry);
34
  $this->AddCIDFont($family,'B',$name.',Bold',$cw,$CMap,$registry);
35
  $this->AddCIDFont($family,'I',$name.',Italic',$cw,$CMap,$registry);
36
  $this->AddCIDFont($family,'BI',$name.',BoldItalic',$cw,$CMap,$registry);
37
}
38
39
function AddUHCFont($family='UHC',$name='HYSMyeongJoStd-Medium-Acro')
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
{
41
  //Add UHC font with proportional Latin
42
  $cw=$GLOBALS['UHC_widths'];
43
  $CMap='KSCms-UHC-H';
44
  $registry=array('ordering'=>'Korea1','supplement'=>1);
45
  $this->AddCIDFonts($family,$name,$cw,$CMap,$registry);
46
}
47
48 View Code Duplication
function AddUHChwFont($family='UHC-hw',$name='HYSMyeongJoStd-Medium-Acro')
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
{
50
  //Add UHC font with half-witdh Latin
51
  for($i=32;$i<=126;$i++)
52
    $cw[chr($i)]=500;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$cw was never initialized. Although not strictly required by PHP, it is generally a good practice to add $cw = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
53
  $CMap='KSCms-UHC-HW-H';
54
  $registry=array('ordering'=>'Korea1','supplement'=>1);
55
  $this->AddCIDFonts($family,$name,$cw,$CMap,$registry);
0 ignored issues
show
The variable $cw does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
56
}
57
58 View Code Duplication
function GetStringWidth($s)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
{
60
  if($this->CurrentFont['type']=='Type0')
61
    return $this->GetMBStringWidth($s);
62
  else
63
    return parent::GetStringWidth($s);
64
}
65
66 View Code Duplication
function GetMBStringWidth($s)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
{
68
  //Multi-byte version of GetStringWidth()
69
  $l=0;
70
  $cw=&$this->CurrentFont['cw'];
71
  $nb=strlen($s);
72
  $i=0;
73
  while($i<$nb)
74
  {
75
    $c=$s[$i];
76
    if(ord($c)<128)
77
    {
78
      $l+=$cw[$c];
79
      $i++;
80
    }
81
    else
82
    {
83
      $l+=1000;
84
      $i+=2;
85
    }
86
  }
87
88
  return $l*$this->FontSize/1000;
89
}
90
91 View Code Duplication
function MultiCell($w,$h,$txt,$border=0,$align='L',$fill=0)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
{
93
  if($this->CurrentFont['type']=='Type0')
94
    $this->MBMultiCell($w,$h,$txt,$border,$align,$fill);
95
  else
96
    parent::MultiCell($w,$h,$txt,$border,$align,$fill);
97
}
98
99 View Code Duplication
function MBMultiCell($w,$h,$txt,$border=0,$align='L',$fill=0)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
100
{
101
  //Multi-byte version of MultiCell()
102
  $cw=&$this->CurrentFont['cw'];
103
  if($w==0)
104
    $w=$this->w-$this->rMargin-$this->x;
105
  $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
106
  $s=str_replace("\r",'',$txt);
107
  $nb=strlen($s);
108
  if($nb>0 and $s[$nb-1]=="\n")
109
    $nb--;
110
  $b=0;
111
  if($border)
112
  {
113
    if($border==1)
114
    {
115
      $border='LTRB';
116
      $b='LRT';
117
      $b2='LR';
118
    }
119
    else
120
    {
121
      $b2='';
122
      if(is_int(strpos($border,'L')))
123
        $b2.='L';
124
      if(is_int(strpos($border,'R')))
125
        $b2.='R';
126
      $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2;
127
    }
128
  }
129
  $sep=-1;
130
  $i=0;
131
  $j=0;
132
  $l=0;
133
  $nl=1;
134
  while($i<$nb)
135
  {
136
    //Get next character
137
    $c=$s[$i];
138
    //Check if ASCII or MB
139
    $ascii=(ord($c)<128);
140
    if($c=="\n")
141
    {
142
      //Explicit line break
143
      $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
144
      $i++;
145
      $sep=-1;
146
      $j=$i;
147
      $l=0;
148
      $nl++;
149
      if($border and $nl==2)
150
        $b=$b2;
0 ignored issues
show
The variable $b2 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
151
      continue;
152
    }
153
    if(!$ascii)
154
    {
155
      $sep=$i;
156
      $ls=$l;
0 ignored issues
show
$ls is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
157
    }
158
    elseif($c==' ')
159
    {
160
      $sep=$i;
161
      $ls=$l;
0 ignored issues
show
$ls is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
162
    }
163
    $l+=$ascii ? $cw[$c] : 1000;
164
    if($l>$wmax)
165
    {
166
      //Automatic line break
167
      if($sep==-1 or $i==$j)
168
      {
169
        if($i==$j)
170
          $i+=$ascii ? 1 : 2;
171
        $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
172
      }
173
      else
174
      {
175
        $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
176
        $i=($s[$sep]==' ') ? $sep+1 : $sep;
177
      }
178
      $sep=-1;
179
      $j=$i;
180
      $l=0;
181
      $nl++;
182
      if($border and $nl==2)
183
        $b=$b2;
184
    }
185
    else
186
      $i+=$ascii ? 1 : 2;
187
  }
188
  //Last chunk
189
  if($border and is_int(strpos($border,'B')))
190
    $b.='B';
191
  $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
192
  $this->x=$this->lMargin;
193
}
194
195 View Code Duplication
function Write($h,$txt,$link='')
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
196
{
197
  if($this->CurrentFont['type']=='Type0')
198
    $this->MBWrite($h,$txt,$link);
199
  else
200
    parent::Write($h,$txt,$link);
201
}
202
203 View Code Duplication
function MBWrite($h,$txt,$link)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
204
{
205
  //Multi-byte version of Write()
206
  $cw=&$this->CurrentFont['cw'];
207
  $w=$this->w-$this->rMargin-$this->x;
208
  $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
209
  $s=str_replace("\r",'',$txt);
210
  $nb=strlen($s);
211
  $sep=-1;
212
  $i=0;
213
  $j=0;
214
  $l=0;
215
  $nl=1;
216
  while($i<$nb)
217
  {
218
    //Get next character
219
    $c=$s[$i];
220
    //Check if ASCII or MB
221
    $ascii=(ord($c)<128);
222
    if($c=="\n")
223
    {
224
      //Explicit line break
225
      $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
226
      $i++;
227
      $sep=-1;
228
      $j=$i;
229
      $l=0;
230
      if($nl==1)
231
      {
232
        $this->x=$this->lMargin;
233
        $w=$this->w-$this->rMargin-$this->x;
234
        $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
235
      }
236
      $nl++;
237
      continue;
238
    }
239
    if(!$ascii or $c==' ')
240
      $sep=$i;
241
    $l+=$ascii ? $cw[$c] : 1000;
242
    if($l>$wmax)
243
    {
244
      //Automatic line break
245
      if($sep==-1 or $i==$j)
246
      {
247
        if($this->x>$this->lMargin)
248
        {
249
          //Move to next line
250
          $this->x=$this->lMargin;
251
          $this->y+=$h;
252
          $w=$this->w-$this->rMargin-$this->x;
253
          $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
254
          $i++;
255
          $nl++;
256
          continue;
257
        }
258
        if($i==$j)
259
          $i+=$ascii ? 1 : 2;
260
        $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
261
      }
262
      else
263
      {
264
        $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
265
        $i=($s[$sep]==' ') ? $sep+1 : $sep;
266
      }
267
      $sep=-1;
268
      $j=$i;
269
      $l=0;
270
      if($nl==1)
271
      {
272
        $this->x=$this->lMargin;
273
        $w=$this->w-$this->rMargin-$this->x;
274
        $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
275
      }
276
      $nl++;
277
    }
278
    else
279
      $i+=$ascii ? 1 : 2;
280
  }
281
  //Last chunk
282
  if($i!=$j)
283
    $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j,$i-$j),0,0,'',0,$link);
284
}
285
286 View Code Duplication
function _putfonts()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
287
{
288
  $nf=$this->n;
289
  foreach($this->diffs as $diff)
290
  {
291
    //Encodings
292
    $this->_newobj();
293
    $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
294
    $this->_out('endobj');
295
  }
296
  $mqr=get_magic_quotes_runtime();
297
  set_magic_quotes_runtime(0);
298
  foreach($this->FontFiles as $file=>$info)
299
  {
300
    //Font file embedding
301
    $this->_newobj();
302
    $this->FontFiles[$file]['n']=$this->n;
303
    if(defined('FPDF_FONTPATH'))
304
      $file=FPDF_FONTPATH.$file;
305
    $size=filesize($file);
306
    if(!$size)
307
      $this->Error('Font file not found');
308
    $this->_out('<</Length '.$size);
309
    if(substr($file,-2)=='.z')
310
      $this->_out('/Filter /FlateDecode');
311
    $this->_out('/Length1 '.$info['length1']);
312
    if(isset($info['length2']))
313
      $this->_out('/Length2 '.$info['length2'].' /Length3 0');
314
    $this->_out('>>');
315
    $f=fopen($file,'rb');
316
    $this->_putstream(fread($f,$size));
317
    fclose($f);
318
    $this->_out('endobj');
319
  }
320
  set_magic_quotes_runtime($mqr);
321
  foreach($this->fonts as $k=>$font)
322
  {
323
    //Font objects
324
    $this->_newobj();
325
    $this->fonts[$k]['n']=$this->n;
326
    $this->_out('<</Type /Font');
327
    if($font['type']=='Type0')
328
      $this->_putType0($font);
329
    else
330
    {
331
      $name=$font['name'];
332
      $this->_out('/BaseFont /'.$name);
333
      if($font['type']=='core')
334
      {
335
        //Standard font
336
        $this->_out('/Subtype /Type1');
337
        if($name!='Symbol' and $name!='ZapfDingbats')
338
          $this->_out('/Encoding /WinAnsiEncoding');
339
      }
340
      else
341
      {
342
        //Additional font
343
        $this->_out('/Subtype /'.$font['type']);
344
        $this->_out('/FirstChar 32');
345
        $this->_out('/LastChar 255');
346
        $this->_out('/Widths '.($this->n+1).' 0 R');
347
        $this->_out('/FontDescriptor '.($this->n+2).' 0 R');
348
        if($font['enc'])
349
        {
350
          if(isset($font['diff']))
351
            $this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
352
          else
353
            $this->_out('/Encoding /WinAnsiEncoding');
354
        }
355
      }
356
      $this->_out('>>');
357
      $this->_out('endobj');
358
      if($font['type']!='core')
359
      {
360
        //Widths
361
        $this->_newobj();
362
        $cw=&$font['cw'];
363
        $s='[';
364
        for($i=32;$i<=255;$i++)
365
          $s.=$cw[chr($i)].' ';
366
        $this->_out($s.']');
367
        $this->_out('endobj');
368
        //Descriptor
369
        $this->_newobj();
370
        $s='<</Type /FontDescriptor /FontName /'.$name;
371
        foreach($font['desc'] as $k=>$v)
372
          $s.=' /'.$k.' '.$v;
373
        $file=$font['file'];
374
        if($file)
375
          $s.=' /FontFile'.($font['type']=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
376
        $this->_out($s.'>>');
377
        $this->_out('endobj');
378
      }
379
    }
380
  }
381
}
382
383
function _putType0($font)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
384
{
385
  //Type0
386
  $this->_out('/Subtype /Type0');
387
  $this->_out('/BaseFont /'.$font['name'].'-'.$font['CMap']);
388
  $this->_out('/Encoding /'.$font['CMap']);
389
  $this->_out('/DescendantFonts ['.($this->n+1).' 0 R]');
390
  $this->_out('>>');
391
  $this->_out('endobj');
392
  //CIDFont
393
  $this->_newobj();
394
  $this->_out('<</Type /Font');
395
  $this->_out('/Subtype /CIDFontType0');
396
  $this->_out('/BaseFont /'.$font['name']);
397
  $this->_out('/CIDSystemInfo <</Registry (Adobe) /Ordering ('.$font['registry']['ordering'].') /Supplement '.$font['registry']['supplement'].'>>');
398
  $this->_out('/FontDescriptor '.($this->n+1).' 0 R');
399
  if($font['CMap']=='KSCms-UHC-HW-H')
400
    $W='8094 8190 500';
401
  else
402
    $W='1 ['.implode(' ',$font['cw']).']';
403
  $this->_out('/W ['.$W.']>>');
404
  $this->_out('endobj');
405
  //Font descriptor
406
  $this->_newobj();
407
  $this->_out('<</Type /FontDescriptor');
408
  $this->_out('/FontName /'.$font['name']);
409
  $this->_out('/Flags 6');
410
  $this->_out('/FontBBox [0 -200 1000 900]');
411
  $this->_out('/ItalicAngle 0');
412
  $this->_out('/Ascent 800');
413
  $this->_out('/Descent -200');
414
  $this->_out('/CapHeight 800');
415
  $this->_out('/StemV 50');
416
  $this->_out('>>');
417
  $this->_out('endobj');
418
}
419
}
420