Code Duplication    Length = 100-100 lines in 2 locations

lib/FPDF/src/font/makefont/makefont.php 1 location

@@ 36-135 (lines=100) @@
33
	return $cc2gn;
34
}
35
36
function ReadAFM($file, &$map)
37
{
38
	//Read a font metric file
39
	$a=file($file);
40
	if(empty($a))
41
		die('File not found');
42
	$widths=array();
43
	$fm=array();
44
	$fix=array('Edot'=>'Edotaccent','edot'=>'edotaccent','Idot'=>'Idotaccent','Zdot'=>'Zdotaccent','zdot'=>'zdotaccent',
45
		'Odblacute'=>'Ohungarumlaut','odblacute'=>'ohungarumlaut','Udblacute'=>'Uhungarumlaut','udblacute'=>'uhungarumlaut',
46
		'Gcedilla'=>'Gcommaaccent','gcedilla'=>'gcommaaccent','Kcedilla'=>'Kcommaaccent','kcedilla'=>'kcommaaccent',
47
		'Lcedilla'=>'Lcommaaccent','lcedilla'=>'lcommaaccent','Ncedilla'=>'Ncommaaccent','ncedilla'=>'ncommaaccent',
48
		'Rcedilla'=>'Rcommaaccent','rcedilla'=>'rcommaaccent','Scedilla'=>'Scommaaccent','scedilla'=>'scommaaccent',
49
		'Tcedilla'=>'Tcommaaccent','tcedilla'=>'tcommaaccent','Dslash'=>'Dcroat','dslash'=>'dcroat','Dmacron'=>'Dcroat','dmacron'=>'dcroat',
50
		'combininggraveaccent'=>'gravecomb','combininghookabove'=>'hookabovecomb','combiningtildeaccent'=>'tildecomb',
51
		'combiningacuteaccent'=>'acutecomb','combiningdotbelow'=>'dotbelowcomb','dongsign'=>'dong');
52
	foreach($a as $l)
53
	{
54
		$e=explode(' ',rtrim($l));
55
		if(count($e)<2)
56
			continue;
57
		$code=$e[0];
58
		$param=$e[1];
59
		if($code=='C')
60
		{
61
			//Character metrics
62
			$cc=(int)$e[1];
63
			$w=$e[4];
64
			$gn=$e[7];
65
			if(substr($gn,-4)=='20AC')
66
				$gn='Euro';
67
			if(isset($fix[$gn]))
68
			{
69
				//Fix incorrect glyph name
70
				foreach($map as $c=>$n)
71
				{
72
					if($n==$fix[$gn])
73
						$map[$c]=$gn;
74
				}
75
			}
76
			if(empty($map))
77
			{
78
				//Symbolic font: use built-in encoding
79
				$widths[$cc]=$w;
80
			}
81
			else
82
			{
83
				$widths[$gn]=$w;
84
				if($gn=='X')
85
					$fm['CapXHeight']=$e[13];
86
			}
87
			if($gn=='.notdef')
88
				$fm['MissingWidth']=$w;
89
		}
90
		elseif($code=='FontName')
91
			$fm['FontName']=$param;
92
		elseif($code=='Weight')
93
			$fm['Weight']=$param;
94
		elseif($code=='ItalicAngle')
95
			$fm['ItalicAngle']=(double)$param;
96
		elseif($code=='Ascender')
97
			$fm['Ascender']=(int)$param;
98
		elseif($code=='Descender')
99
			$fm['Descender']=(int)$param;
100
		elseif($code=='UnderlineThickness')
101
			$fm['UnderlineThickness']=(int)$param;
102
		elseif($code=='UnderlinePosition')
103
			$fm['UnderlinePosition']=(int)$param;
104
		elseif($code=='IsFixedPitch')
105
			$fm['IsFixedPitch']=($param=='true');
106
		elseif($code=='FontBBox')
107
			$fm['FontBBox']=array($e[1],$e[2],$e[3],$e[4]);
108
		elseif($code=='CapHeight')
109
			$fm['CapHeight']=(int)$param;
110
		elseif($code=='StdVW')
111
			$fm['StdVW']=(int)$param;
112
	}
113
	if(!isset($fm['FontName']))
114
		die('FontName not found');
115
	if(!empty($map))
116
	{
117
		if(!isset($widths['.notdef']))
118
			$widths['.notdef']=600;
119
		if(!isset($widths['Delta']) && isset($widths['increment']))
120
			$widths['Delta']=$widths['increment'];
121
		//Order widths according to map
122
		for($i=0;$i<=255;$i++)
123
		{
124
			if(!isset($widths[$map[$i]]))
125
			{
126
				echo '<b>Warning:</b> character '.$map[$i].' is missing<br>';
127
				$widths[$i]=$widths['.notdef'];
128
			}
129
			else
130
				$widths[$i]=$widths[$map[$i]];
131
		}
132
	}
133
	$fm['Widths']=$widths;
134
	return $fm;
135
}
136
137
function MakeFontDescriptor($fm, $symbolic)
138
{

ufpdf/font/makefont/makefont.php 1 location

@@ 36-135 (lines=100) @@
33
	return $cc2gn;
34
}
35
36
function ReadAFM($file, &$map)
37
{
38
	//Read a font metric file
39
	$a=file($file);
40
	if(empty($a))
41
		die('File not found');
42
	$widths=array();
43
	$fm=array();
44
	$fix=array('Edot'=>'Edotaccent','edot'=>'edotaccent','Idot'=>'Idotaccent','Zdot'=>'Zdotaccent','zdot'=>'zdotaccent',
45
		'Odblacute'=>'Ohungarumlaut','odblacute'=>'ohungarumlaut','Udblacute'=>'Uhungarumlaut','udblacute'=>'uhungarumlaut',
46
		'Gcedilla'=>'Gcommaaccent','gcedilla'=>'gcommaaccent','Kcedilla'=>'Kcommaaccent','kcedilla'=>'kcommaaccent',
47
		'Lcedilla'=>'Lcommaaccent','lcedilla'=>'lcommaaccent','Ncedilla'=>'Ncommaaccent','ncedilla'=>'ncommaaccent',
48
		'Rcedilla'=>'Rcommaaccent','rcedilla'=>'rcommaaccent','Scedilla'=>'Scommaaccent','scedilla'=>'scommaaccent',
49
		'Tcedilla'=>'Tcommaaccent','tcedilla'=>'tcommaaccent','Dslash'=>'Dcroat','dslash'=>'dcroat','Dmacron'=>'Dcroat','dmacron'=>'dcroat',
50
		'combininggraveaccent'=>'gravecomb','combininghookabove'=>'hookabovecomb','combiningtildeaccent'=>'tildecomb',
51
		'combiningacuteaccent'=>'acutecomb','combiningdotbelow'=>'dotbelowcomb','dongsign'=>'dong');
52
	foreach($a as $l)
53
	{
54
		$e=explode(' ',rtrim($l));
55
		if(count($e)<2)
56
			continue;
57
		$code=$e[0];
58
		$param=$e[1];
59
		if($code=='C')
60
		{
61
			//Character metrics
62
			$cc=(int)$e[1];
63
			$w=$e[4];
64
			$gn=$e[7];
65
			if(substr($gn,-4)=='20AC')
66
				$gn='Euro';
67
			if(isset($fix[$gn]))
68
			{
69
				//Fix incorrect glyph name
70
				foreach($map as $c=>$n)
71
				{
72
					if($n==$fix[$gn])
73
						$map[$c]=$gn;
74
				}
75
			}
76
			if(empty($map))
77
			{
78
				//Symbolic font: use built-in encoding
79
				$widths[$cc]=$w;
80
			}
81
			else
82
			{
83
				$widths[$gn]=$w;
84
				if($gn=='X')
85
					$fm['CapXHeight']=$e[13];
86
			}
87
			if($gn=='.notdef')
88
				$fm['MissingWidth']=$w;
89
		}
90
		elseif($code=='FontName')
91
			$fm['FontName']=$param;
92
		elseif($code=='Weight')
93
			$fm['Weight']=$param;
94
		elseif($code=='ItalicAngle')
95
			$fm['ItalicAngle']=(double)$param;
96
		elseif($code=='Ascender')
97
			$fm['Ascender']=(int)$param;
98
		elseif($code=='Descender')
99
			$fm['Descender']=(int)$param;
100
		elseif($code=='UnderlineThickness')
101
			$fm['UnderlineThickness']=(int)$param;
102
		elseif($code=='UnderlinePosition')
103
			$fm['UnderlinePosition']=(int)$param;
104
		elseif($code=='IsFixedPitch')
105
			$fm['IsFixedPitch']=($param=='true');
106
		elseif($code=='FontBBox')
107
			$fm['FontBBox']=array($e[1],$e[2],$e[3],$e[4]);
108
		elseif($code=='CapHeight')
109
			$fm['CapHeight']=(int)$param;
110
		elseif($code=='StdVW')
111
			$fm['StdVW']=(int)$param;
112
	}
113
	if(!isset($fm['FontName']))
114
		die('FontName not found');
115
	if(!empty($map))
116
	{
117
		if(!isset($widths['.notdef']))
118
			$widths['.notdef']=600;
119
		if(!isset($widths['Delta']) && isset($widths['increment']))
120
			$widths['Delta']=$widths['increment'];
121
		//Order widths according to map
122
		for($i=0;$i<=255;$i++)
123
		{
124
			if(!isset($widths[$map[$i]]))
125
			{
126
				echo '<b>Warning:</b> character '.$map[$i].' is missing<br>';
127
				$widths[$i]=$widths['.notdef'];
128
			}
129
			else
130
				$widths[$i]=$widths[$map[$i]];
131
		}
132
	}
133
	$fm['Widths']=$widths;
134
	return $fm;
135
}
136
137
function MakeFontDescriptor($fm, $symbolic)
138
{