PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.6
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.6
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
← All changes | mpdf/utils/font_coverage.php +255 -250 trunk1.6 View file →
@@ -1,250 +1,255 @@
1 -<?php
2 -
3 -/* This script prints out the Unicode coverage of all TrueType font files
4 - in your font directory.
5 - Point your browser to
6 - http://your.domain/your_path_to _mpdf/utils/font_coverage.php
7 - By default this will examine the folder /ttfonts/ (or the default font
8 - directory defined by _MPDF_TTFONTPATH.
9 - You can optionally define an alternative folder to examine by setting
10 - the variable below (must be a relative path, or filesystem path):
11 -*/
12 -
13 -
14 -$checkdir = '';
15 -
16 -//////////////////////////////////
17 -
18 -
19 -set_time_limit(600);
20 -ini_set("memory_limit","256M");
21 -
22 -//==============================================================
23 -//==============================================================
24 -include("../mpdf.php");
25 -
26 -$mpdf=new mPDF('','A4-L','','',10,10,10,10);
27 -$mpdf->SetDisplayMode('fullpage');
28 -$mpdf->useSubstitutions = true;
29 -$mpdf->debug = true;
30 -$mpdf->simpleTables = true;
31 -if ($checkdir) {
32 - $ttfdir = $checkdir;
33 -} else {
34 - $ttfdir = _MPDF_TTFONTPATH;
35 -}
36 -
37 -
38 -
39 -$mqr=ini_get("magic_quotes_runtime");
40 -if ($mqr) { set_magic_quotes_runtime(0); }
41 -if (!class_exists('TTFontFile_Analysis', false)) { include(_MPDF_PATH .'classes/ttfontsuni_analysis.php'); }
42 -
43 -//==============================================================
44 - $smp = true;
45 - $maxt = 131071;
46 -//==============================================================
47 -//==============================================================
48 -$unifile = file('UnicodeData.txt');
49 -$unichars = array();
50 -foreach($unifile AS $line) {
51 - if (preg_match('/<control>/',$line,$m)) {
52 - $rangename = '';
53 - continue;
54 - }
55 - else if (preg_match('/^([12]{0,1}[0-9A-Za-z]{4});<(.*?), Last>/',$line,$m)) {
56 - if ($rangename && $rangename == $m[2]) {
57 - $endrange = hexdec($m[1]);
58 - for ($i=$startrange;$i<=$endrange; $i++) {
59 - $unichars[$i] = $i;
60 - }
61 - }
62 - $rangename = '';
63 - }
64 - else if (preg_match('/^([12]{0,1}[0-9A-Za-z]{4});<(.*?), First>/',$line,$m)) {
65 - $startrange = hexdec($m[1]);
66 - $rangename = $m[2];
67 - }
68 - else if (preg_match('/^([12]{0,1}[0-9A-Za-z]{4});/',$line,$m)) {
69 - $unichars[hexdec($m[1])] = hexdec($m[1]);
70 - $rangename = '';
71 - }
72 -}
73 -
74 -// loads array $unicode_ranges
75 -include('UnicodeRanges.php');
76 -//==============================================================
77 -$html = '<html><head><style>td { border: 0.1mm solid #555555; }
78 -body { font-weight: normal; font-family: helvetica;font-size:8pt; }
79 -td { font-family: helvetica;font-size:8pt; vertical-align: top;}
80 -</style></head><body>';
81 -
82 -//==============================================================
83 -$ff = scandir($ttfdir);
84 -$tempfontdata = array();
85 -foreach($ff AS $f) {
86 - $ttf = new TTFontFile_Analysis();
87 - $ret = array();
88 - $isTTC = false;
89 - if (strtolower(substr($f,-4,4))=='.ttf' || strtolower(substr($f,-4,4))=='.otf') {
90 - $ret[] = $ttf->extractCoreInfo($ttfdir.$f);
91 - }
92 - for ($i=0; $i<count($ret); $i++) {
93 - if (is_array($ret[$i])) {
94 - $tfname = $ret[$i][0];
95 - $bold = $ret[$i][1];
96 - $italic = $ret[$i][2];
97 - $fname = strtolower($tfname );
98 - $fname = preg_replace('/[ ()]/','',$fname );
99 - //$tempfonttrans[$tfname] = $fname;
100 - $style = '';
101 - if ($bold) { $style .= 'B'; }
102 - if ($italic) { $style .= 'I'; }
103 - if (!$style) {
104 - $tempfontdata[$fname]['file'] = $f;
105 - if ($isTTC) {
106 - $tempfontdata[$fname]['TTCfontID'] = $ret[$i][4];
107 - }
108 - }
109 - }
110 - }
111 - unset($ttf);
112 -
113 -}
114 -
115 -$fullcovers = array();
116 -$nearlycovers = array();
117 -ksort($tempfontdata);
118 -$ningroup = 14;
119 -$nofgroups = ceil(count($unicode_ranges)/$ningroup);
120 -
121 -//==============================================================
122 -
123 -
124 -for ($urgp = 0; $urgp < $nofgroups; $urgp++) {
125 -
126 -
127 - $html .= '<table cellpadding="2" cellspacing="0" style="page-break-inside:avoid; text-align:center; border-collapse: collapse; ">';
128 - $html .= '<thead><tr><td></td>';
129 -
130 - foreach($unicode_ranges AS $urk => $ur) {
131 - if ($urk >= ($urgp*$ningroup) && $urk < (($urgp+1)*$ningroup)) {
132 - $rangekey = $urk;
133 - $range = $ur['range'];
134 - $rangestart = $ur['starthex'];
135 - $rangeend = $ur['endhex'];
136 - $html .= '<td style="font-family:helvetica;font-size:8pt;font-weight:bold;">'.strtoupper($range).' (U+'.$rangestart .'-U+'.$rangeend.')</td>';
137 - }
138 - }
139 - $html .= '</tr></thead>';
140 -
141 -
142 - foreach ($tempfontdata AS $fname => $v) {
143 - $cw = '';
144 - if (file_exists((_MPDF_TTFONTDATAPATH.$fname.'.cw.dat'))) { $cw = file_get_contents(_MPDF_TTFONTDATAPATH.$fname.'.cw.dat'); }
145 - else {
146 - $mpdf->fontdata[$fname]['R'] = $tempfontdata[$fname]['file'];
147 - $mpdf->AddFont($fname);
148 - $cw = file_get_contents(_MPDF_TTFONTDATAPATH.$fname.'.cw.dat');
149 - }
150 - if (!$cw) {
151 - continue;
152 - die("Font data not available for $fname");
153 - }
154 -
155 - $counter=0;
156 - $max = $maxt;
157 -
158 - // create HTML content
159 - $html .= '<tr>';
160 - $html .= '<td>'.$fname.'</td>';
161 -
162 - foreach($unicode_ranges AS $urk => $ur) {
163 - if ($urk >= ($urgp*$ningroup) && $urk < (($urgp+1)*$ningroup)) {
164 - if ($ur['pua'] || $ur['reserved'] || $ur['control']) {
165 - $html .= '<td style="background-color: #000000;"></td>';
166 - }
167 - else {
168 - $rangekey = $urk;
169 - $range = $ur['range'];
170 - $rangestart = $ur['starthex'];
171 - $rangeend = $ur['endhex'];
172 - $rangestartdec = $ur['startdec'];
173 - $rangeenddec = $ur['enddec'];
174 - $uniinrange = 0;
175 - $fontinrange = 0;
176 - for ($i=$rangestartdec; $i<=$rangeenddec; $i++) {
177 - //if (isset($cw[$i])) { $fontinrange++; }
178 - if ($mpdf->_charDefined($cw, $i)) { $fontinrange++; }
179 - if (isset($unichars[$i])) { $uniinrange++; }
180 - }
181 - if ($uniinrange) {
182 - if ($fontinrange) {
183 - $pc = ($fontinrange/$uniinrange);
184 - $str = '('.$fontinrange.'/'.$uniinrange.')';
185 - if ($pc==1) {
186 - $fullcovers[$urk][] = $fname;
187 - $html .= '<td style="background-color: #00FF00;"></td>';
188 - }
189 - else if ($pc>1) {
190 - $fullcovers[$urk][] = $fname;
191 - $html .= '<td style="background-color: #00FF00;">'.$str.'</td>';
192 - }
193 - else if ($pc>=0.9) {
194 - $html .= '<td style="background-color: #AAFFAA;">'.$str.'</td>';
195 - $nearlycovers[$urk][] = $fname;
196 - }
197 - else if ($pc>0.75) { $html .= '<td style="background-color: #00FFAA;">'.$str.'</td>'; }
198 - else if ($pc>0.5) { $html .= '<td style="background-color: #AAAAFF;">'.$str.'</td>'; }
199 - else if ($pc>0.25) { $html .= '<td style="background-color: #FFFFAA;">'.$str.'</td>'; }
200 - else { $html .= '<td style="background-color: #FFAAAA;">'.$str.'</td>'; }
201 - }
202 - else { $html .= '<td style="background-color: #555555;">(0/0)</td>'; }
203 - }
204 - else { $html .= '<td style="background-color: #000000;"></td>'; }
205 - }
206 - }
207 - }
208 -
209 -
210 - $html .= '</tr>';
211 -
212 - }
213 -//==============================================================
214 - $html .= '</table><pagebreak />';
215 -}
216 -
217 -$html .= '<h4>Fonts with full coverage of Unicode Ranges</h4>';
218 -$html .= '<table>';
219 -//$html .= '<tr><td></td><td></td></tr>';
220 -foreach($unicode_ranges AS $urk => $ur) {
221 - if ($ur['pua'] || $ur['reserved'] || $ur['control']) { continue; }
222 - $rangekey = $urk;
223 - $range = $ur['range'];
224 - $rangestart = $ur['starthex'];
225 - $rangeend = $ur['endhex'];
226 - $ext = $ext2 = '';
227 - if ($ur['combining']) { $ext = 'background-color:#DDDDFF;'; $ext2 = '<br /><span style="color:#AA0000">Special positioning required</span>'; }
228 - if ($ur['vertical']) { $ext = 'background-color:#FFDDDD;'; $ext2 = '<br /><span style="color:#AA0000">Vertical positioning required</span>'; }
229 - if ($ur['special']) { $ext = 'background-color:#FFDDDD;'; $ext2 = '<br /><span style="color:#AA0000">Special processing required</span>'; }
230 -
231 -
232 - $html .= '<tr><td style="font-family:helvetica;font-size:8pt;font-weight:bold;'.$ext.'">'.strtoupper($range).' (U+'.$rangestart .'-U+'.$rangeend.')'.$ext2.'</td>';
233 - $arr = $fullcovers[$urk];
234 - $narr = $nearlycovers[$urk];
235 - if (is_array($arr)) { $html .= '<td>'. implode(', ',$arr). '</td></tr>'; }
236 - else if (is_array($narr)) { $html .= '<td style="background-color: #AAAAAA;">'. implode(', ',$narr). ' (>90%)</td></tr>'; }
237 - else { $html .= '<td style="background-color: #555555;"> </td></tr>'; }
238 -}
239 -$html.= '</table>';
240 -
241 -
242 -//==============================================================
243 -echo $html;
244 -
245 -exit;
246 -
247 -//==============================================================
248 -//==============================================================
249 -//==============================================================
250 -//==============================================================
1 +<?php
2 +
3 +/* This script prints out the Unicode coverage of all TrueType font files
4 + in your font directory.
5 + Point your browser to
6 + http://your.domain/your_path_to _mpdf/utils/font_coverage.php
7 + By default this will examine the folder /ttfonts/ (or the default font
8 + directory defined by _MPDF_TTFONTPATH.
9 + You can optionally define an alternative folder to examine by setting
10 + the variable below (must be a relative path, or filesystem path):
11 +*/
12 +
13 +
14 +$checkdir = '';
15 +
16 +
17 +//////////////////////////////////
18 +//////////////////////////////////
19 +//////////////////////////////////
20 +
21 +
22 +set_time_limit(600);
23 +ini_set("memory_limit","256M");
24 +
25 +//==============================================================
26 +//==============================================================
27 +include("../mpdf.php");
28 +
29 +$mpdf=new mPDF('','A4-L','','',10,10,10,10);
30 +$mpdf->SetDisplayMode('fullpage');
31 +$mpdf->useSubstitutions = true;
32 +$mpdf->debug = true;
33 +$mpdf->simpleTables = true;
34 +if ($checkdir) {
35 + $ttfdir = $checkdir;
36 +}
37 +else { $ttfdir = _MPDF_TTFONTPATH; }
38 +
39 +
40 +
41 +$mqr=ini_get("magic_quotes_runtime");
42 +if ($mqr) { set_magic_quotes_runtime(0); }
43 +if (!class_exists('TTFontFile_Analysis', false)) { include(_MPDF_PATH .'classes/ttfontsuni_analysis.php'); }
44 +
45 +//==============================================================
46 + $smp = true;
47 + $maxt = 131071;
48 +//==============================================================
49 +//==============================================================
50 +$unifile = file('UnicodeData.txt');
51 +$unichars = array();
52 +foreach($unifile AS $line) {
53 + if (preg_match('/<control>/',$line,$m)) {
54 + $rangename = '';
55 + continue;
56 + }
57 + else if (preg_match('/^([12]{0,1}[0-9A-Za-z]{4});<(.*?), Last>/',$line,$m)) {
58 + if ($rangename && $rangename == $m[2]) {
59 + $endrange = hexdec($m[1]);
60 + for ($i=$startrange;$i<=$endrange; $i++) {
61 + $unichars[$i] = $i;
62 + }
63 + }
64 + $rangename = '';
65 + }
66 + else if (preg_match('/^([12]{0,1}[0-9A-Za-z]{4});<(.*?), First>/',$line,$m)) {
67 + $startrange = hexdec($m[1]);
68 + $rangename = $m[2];
69 + }
70 + else if (preg_match('/^([12]{0,1}[0-9A-Za-z]{4});/',$line,$m)) {
71 + $unichars[hexdec($m[1])] = hexdec($m[1]);
72 + $rangename = '';
73 + }
74 +}
75 +
76 +// loads array $unicode_ranges
77 +include('UnicodeRanges.php');
78 +//==============================================================
79 +$html = '<html><head><style>td { border: 0.1mm solid #555555; }
80 +body { font-weight: normal; font-family: helvetica;font-size:8pt; }
81 +td { font-family: helvetica;font-size:8pt; vertical-align: top;}
82 +</style></head><body>';
83 +
84 +//==============================================================
85 +$ff = scandir($ttfdir);
86 +$tempfontdata = array();
87 +foreach($ff AS $f) {
88 + $ttf = new TTFontFile_Analysis();
89 + $ret = array();
90 + $isTTC = false;
91 + if (strtolower(substr($f,-4,4))=='.ttf' || strtolower(substr($f,-4,4))=='.otf') {
92 + $ret[] = $ttf->extractCoreInfo($ttfdir.$f);
93 + }
94 + for ($i=0; $i<count($ret); $i++) {
95 + if (is_array($ret[$i])) {
96 + $tfname = $ret[$i][0];
97 + $bold = $ret[$i][1];
98 + $italic = $ret[$i][2];
99 + $fname = strtolower($tfname );
100 + $fname = preg_replace('/[ ()]/','',$fname );
101 + //$tempfonttrans[$tfname] = $fname;
102 + $style = '';
103 + if ($bold) { $style .= 'B'; }
104 + if ($italic) { $style .= 'I'; }
105 + if (!$style) {
106 + $tempfontdata[$fname]['file'] = $f;
107 + if ($isTTC) {
108 + $tempfontdata[$fname]['TTCfontID'] = $ret[$i][4];
109 + }
110 + }
111 + }
112 + }
113 + unset($ttf);
114 +
115 +}
116 +
117 +$fullcovers = array();
118 +$nearlycovers = array();
119 +ksort($tempfontdata);
120 +$ningroup = 14;
121 +$nofgroups = ceil(count($unicode_ranges)/$ningroup);
122 +
123 +//==============================================================
124 +
125 +
126 +for ($urgp = 0; $urgp < $nofgroups; $urgp++) {
127 +
128 +
129 + $html .= '<table cellpadding="2" cellspacing="0" style="page-break-inside:avoid; text-align:center; border-collapse: collapse; ">';
130 + $html .= '<thead><tr><td></td>';
131 +
132 + foreach($unicode_ranges AS $urk => $ur) {
133 + if ($urk >= ($urgp*$ningroup) && $urk < (($urgp+1)*$ningroup)) {
134 + $rangekey = $urk;
135 + $range = $ur['range'];
136 + $rangestart = $ur['starthex'];
137 + $rangeend = $ur['endhex'];
138 + $html .= '<td style="font-family:helvetica;font-size:8pt;font-weight:bold;">'.strtoupper($range).' (U+'.$rangestart .'-U+'.$rangeend.')</td>';
139 + }
140 + }
141 + $html .= '</tr></thead>';
142 +
143 +
144 + foreach ($tempfontdata AS $fname => $v) {
145 + $cw = '';
146 + if (file_exists((_MPDF_TTFONTDATAPATH.$fname.'.cw.dat'))) { $cw = file_get_contents(_MPDF_TTFONTDATAPATH.$fname.'.cw.dat'); }
147 + else {
148 + $mpdf->fontdata[$fname]['R'] = $tempfontdata[$fname]['file'];
149 + $mpdf->AddFont($fname);
150 + $cw = file_get_contents(_MPDF_TTFONTDATAPATH.$fname.'.cw.dat');
151 + }
152 + if (!$cw) {
153 + continue;
154 + die("Font data not available for $fname");
155 + }
156 +
157 + $counter=0;
158 + $max = $maxt;
159 +
160 + // create HTML content
161 + $html .= '<tr>';
162 + $html .= '<td>'.$fname.'</td>';
163 +
164 + foreach($unicode_ranges AS $urk => $ur) {
165 + if ($urk >= ($urgp*$ningroup) && $urk < (($urgp+1)*$ningroup)) {
166 + if ($ur['pua'] || $ur['reserved'] || $ur['control']) {
167 + $html .= '<td style="background-color: #000000;"></td>';
168 + }
169 + else {
170 + $rangekey = $urk;
171 + $range = $ur['range'];
172 + $rangestart = $ur['starthex'];
173 + $rangeend = $ur['endhex'];
174 + $rangestartdec = $ur['startdec'];
175 + $rangeenddec = $ur['enddec'];
176 + $uniinrange = 0;
177 + $fontinrange = 0;
178 + for ($i=$rangestartdec; $i<=$rangeenddec; $i++) {
179 + //if (isset($cw[$i])) { $fontinrange++; }
180 + if ($mpdf->_charDefined($cw, $i)) { $fontinrange++; }
181 + if (isset($unichars[$i])) { $uniinrange++; }
182 + }
183 + if ($uniinrange) {
184 + if ($fontinrange) {
185 + $pc = ($fontinrange/$uniinrange);
186 + $str = '('.$fontinrange.'/'.$uniinrange.')';
187 + if ($pc==1) {
188 + $fullcovers[$urk][] = $fname;
189 + $html .= '<td style="background-color: #00FF00;"></td>';
190 + }
191 + else if ($pc>1) {
192 + $fullcovers[$urk][] = $fname;
193 + $html .= '<td style="background-color: #00FF00;">'.$str.'</td>';
194 + }
195 + else if ($pc>=0.9) {
196 + $html .= '<td style="background-color: #AAFFAA;">'.$str.'</td>';
197 + $nearlycovers[$urk][] = $fname;
198 + }
199 + else if ($pc>0.75) { $html .= '<td style="background-color: #00FFAA;">'.$str.'</td>'; }
200 + else if ($pc>0.5) { $html .= '<td style="background-color: #AAAAFF;">'.$str.'</td>'; }
201 + else if ($pc>0.25) { $html .= '<td style="background-color: #FFFFAA;">'.$str.'</td>'; }
202 + else { $html .= '<td style="background-color: #FFAAAA;">'.$str.'</td>'; }
203 + }
204 + else { $html .= '<td style="background-color: #555555;">(0/0)</td>'; }
205 + }
206 + else { $html .= '<td style="background-color: #000000;"></td>'; }
207 + }
208 + }
209 + }
210 +
211 +
212 + $html .= '</tr>';
213 +
214 + }
215 +//==============================================================
216 + $html .= '</table><pagebreak />';
217 +}
218 +
219 +$html .= '<h4>Fonts with full coverage of Unicode Ranges</h4>';
220 +$html .= '<table>';
221 +//$html .= '<tr><td></td><td></td></tr>';
222 +foreach($unicode_ranges AS $urk => $ur) {
223 + if ($ur['pua'] || $ur['reserved'] || $ur['control']) { continue; }
224 + $rangekey = $urk;
225 + $range = $ur['range'];
226 + $rangestart = $ur['starthex'];
227 + $rangeend = $ur['endhex'];
228 + $ext = $ext2 = '';
229 + if ($ur['combining']) { $ext = 'background-color:#DDDDFF;'; $ext2 = '<br /><span style="color:#AA0000">Special positioning required</span>'; }
230 + if ($ur['vertical']) { $ext = 'background-color:#FFDDDD;'; $ext2 = '<br /><span style="color:#AA0000">Vertical positioning required</span>'; }
231 + if ($ur['special']) { $ext = 'background-color:#FFDDDD;'; $ext2 = '<br /><span style="color:#AA0000">Special processing required</span>'; }
232 +
233 +
234 + $html .= '<tr><td style="font-family:helvetica;font-size:8pt;font-weight:bold;'.$ext.'">'.strtoupper($range).' (U+'.$rangestart .'-U+'.$rangeend.')'.$ext2.'</td>';
235 + $arr = $fullcovers[$urk];
236 + $narr = $nearlycovers[$urk];
237 + if (is_array($arr)) { $html .= '<td>'. implode(', ',$arr). '</td></tr>'; }
238 + else if (is_array($narr)) { $html .= '<td style="background-color: #AAAAAA;">'. implode(', ',$narr). ' (>90%)</td></tr>'; }
239 + else { $html .= '<td style="background-color: #555555;"> </td></tr>'; }
240 +}
241 +$html.= '</table>';
242 +
243 +
244 +//==============================================================
245 +echo $html;
246 +
247 +exit;
248 +
249 +//==============================================================
250 +//==============================================================
251 +//==============================================================
252 +//==============================================================
253 +
254 +
255 +?>