PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.5
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.5
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
pdf-print / mpdf / utils / font_dump.php

font_dump.php in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 1.5, at mpdf/utils/font_dump.php

220 lines 7.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 This script prints out all characters in a TrueType font file
5 to a PDF document. Point your browser to
6 http://your.domain/your_path_to _mpdf/utils/font_dump.php
7 The font file must be located in /ttfonts/ (or the default font
8 directory defined by _MPDF_TTFONTPATH.
9 By default this will examine the font dejavusanscondensed.
10 You can optionally define an alternative font file to examine by setting
11 the variable below (must be a relative path, or filesystem path):
12 */
13
14
15 $font = 'dejavusanscondensed'; // Use internal mPDF font-name
16
17 $showmissing = true; // Show all missing unicode blocks / characters
18
19
20 //////////////////////////////////
21 //////////////////////////////////
22 //////////////////////////////////
23
24 set_time_limit(600);
25 ini_set("memory_limit","256M");
26
27 //==============================================================
28 //==============================================================
29 define('_MPDF_URI', '../');
30 include("../mpdf.php");
31
32 $mpdf=new mPDF('');
33 $mpdf->StartProgressBarOutput(2);
34
35 $mpdf->SetDisplayMode('fullpage');
36
37 $mpdf->useSubstitutions = false;
38 $mpdf->debug = true;
39 $mpdf->simpleTables = true;
40
41 //==============================================================
42 //==============================================================
43 //==============================================================
44 //==============================================================
45
46 // This generates a .mtx.php file if not already generated
47 $mpdf->WriteHTML('<style>td { border: 0.1mm solid #555555; } body { font-weight: normal; }</style>');
48 $mpdf->WriteHTML('<h3 style="font-family:'.$font.'">'.strtoupper($font).'</h3>'); // Separate Paragraphs defined by font
49 $html = '';
50 //==============================================================
51 //==============================================================
52 //==============================================================
53 //==============================================================
54 $unifile = file('UnicodeData.txt');
55 $unichars = array();
56
57 foreach($unifile AS $line) {
58 if ($smp && preg_match('/^(1[0-9A-Za-z]{4});/',$line,$m)) {
59 $unichars[hexdec($m[1])] = hexdec($m[1]);
60 }
61 else if (preg_match('/^([0-9A-Za-z]{4});/',$line,$m)) {
62 $unichars[hexdec($m[1])] = hexdec($m[1]);
63 }
64 }
65
66 // loads array $unicode_ranges
67 include('UnicodeRanges.php');
68 //==============================================================
69 //==============================================================
70
71
72
73 $cw = file_get_contents(_MPDF_TTFONTDATAPATH.$font.'.cw.dat');
74 if (!$cw) { die("Error - Must be able to read font metrics file: "._MPDF_TTFONTDATAPATH.$font.'.cw.dat'); }
75 $counter=0;
76
77
78 include(_MPDF_TTFONTDATAPATH.$font.'.mtx.php');
79
80 if ($smp) {
81 $max = 131071;
82 }
83 else {
84 $max = 65535;
85 }
86
87
88 $justfinishedblank = false;
89 $justfinishedblankinvalid = false;
90
91 foreach($unicode_ranges AS $urk => $ur) {
92 if (0 >= $ur['startdec'] && 0 <= $ur['enddec']) {
93 $rangekey = $urk;
94 $range = $ur['range'];
95 $rangestart = $ur['starthex'];
96 $rangeend = $ur['endhex'];
97 break;
98 }
99 }
100 $lastrange = $range ;
101 // create HTML content
102 $html .= '<table cellpadding="2" cellspacing="0" style="font-family:'.$font.';text-align:center; border-collapse: collapse; ">';
103 $html .= '<tr><td colspan="18" style="font-family:helvetica;font-weight:bold">'.strtoupper($font).'</td></tr>';
104 $html .= '<tr><td colspan="18" style="font-family:helvetica;font-size:8pt;font-weight:bold">'.strtoupper($range).' (U+'.$rangestart .'-U+'.$rangeend.')</td></tr>';
105 $html .= '<tr><td></td>';
106
107 $html .= '<td></td>';
108 for ($i = 0; $i < 16; $i++) {
109 $html .= '<td><b>-'.sprintf('%X', $i).'</b></td>';
110 }
111
112
113 // print each character
114 for ($i = 32; $i < $max; ++$i) {
115 if (($i > 0) AND (($i % 16) == 0)) {
116 $notthisline = true;
117 while($notthisline) {
118 for ($j = 0; $j < 16; $j++) {
119 if ($mpdf->_charDefined($cw, ($i + $j))) {
120 //if (isset($cw[($i+$j)])) {
121 $notthisline = false;
122 }
123 }
124 if ($notthisline) {
125 if ($showmissing) {
126 $range = '';
127 foreach($unicode_ranges AS $urk => $ur) {
128 if ($i >= $ur['startdec'] && $i <= $ur['enddec']) {
129 $rangekey = $urk;
130 $range = $ur['range'];
131 $rangestart = $ur['starthex'];
132 $rangeend = $ur['endhex'];
133 break;
134 }
135 }
136 $anyvalid = false;
137 for ($j = 0; $j < 16; $j++) {
138 if (isset($unichars[$i+$j])) { $anyvalid = true; break; }
139 }
140 if ($range && $range == $lastrange) {
141 if (!$anyvalid) {
142 if (!$justfinishedblankinvalid) {
143 $html .= '<tr><td colspan="18" style="background-color:#555555; font-size: 4pt;">&nbsp;</td></tr>';
144 }
145 $justfinishedblankinvalid = true;
146 }
147 else if (!$justfinishedblank ) {
148 $html .= '<tr><td colspan="18" style="background-color:#FFAAAA; font-size: 4pt;">&nbsp;</td></tr>';
149 $justfinishedblank = true;
150 }
151 }
152 else if($range) {
153 $html .= '</tr></table><br />';
154 $mpdf->WriteHTML($html); $html = '';
155 $html .= '<table cellpadding="2" cellspacing="0" style="font-family:'.$font.';text-align:center; border-collapse: collapse; ">';
156 $html .= '<tr><td colspan="18" style="font-family:helvetica;font-size:8pt;font-weight:bold">'.strtoupper($range).' (U+'.$rangestart.'-U+'.$rangeend.')</td></tr>';
157 $html .= '<tr><td></td>';
158 $html .= '<td></td>';
159 for ($k = 0; $k < 16; $k++) {
160 $html .= '<td><b>-'.sprintf('%X', $k).'</b></td>';
161 }
162 $justfinishedblank = false;
163 $justfinishedblankinvalid = false;
164 }
165 $lastrange = $range ;
166 }
167 $i +=16;
168 if ($i > $max) { break 2; }
169 }
170 }
171 foreach($unicode_ranges AS $urk => $ur) {
172 if ($i >= $ur['startdec'] && $i <= $ur['enddec']) {
173 $rangekey = $urk;
174 $range = $ur['range'];
175 $rangestart = $ur['starthex'];
176 $rangeend = $ur['endhex'];
177 break;
178 }
179 }
180
181 if ($i > 0 && ($i % 16) == 0 && ($range != $lastrange)) {
182 $html .= '</tr></table><br />';
183 $mpdf->WriteHTML($html); $html = '';
184 $html .= '<table cellpadding="2" cellspacing="0" style="font-family:'.$font.';text-align:center; border-collapse: collapse; ">';
185 $html .= '<tr><td colspan="18" style="font-family:helvetica;font-size:8pt;font-weight:bold">'.strtoupper($range).' (U+'.$rangestart.'-U+'.$rangeend.')</td></tr>';
186 $html .= '<tr><td></td>';
187 $html .= '<td></td>';
188 for ($k = 0; $k < 16; $k++) {
189 $html .= '<td><b>-'.sprintf('%X', $k).'</b></td>';
190 }
191 }
192 $lastrange = $range ;
193 $justfinishedblank = false;
194 $justfinishedblankinvalid = false;
195 $html .= '</tr><tr><td><i>'.(floor($i / 16)*16).'</i></td>';
196 $html .= '<td><b>'.sprintf('%03X', floor($i / 16)).'-</b></td>';
197 }
198 if ($mpdf->_charDefined($cw, $i)) { $html .= '<td>&#'.$i.';</td>'; $counter++; }
199 else if (isset($unichars[$i])) { $html .= '<td style="background-color: #FFAAAA;"></td>'; }
200 else { $html .= '<td style="background-color: #555555;"></td>'; }
201 }
202
203 if (($i % 16) > 0) {
204 for ($j = ($i % 16); $j < 16; ++$j) { $html .= '<td style="background-color: #555555;"></td>'; }
205 }
206 $html .= '</tr></table><br />';
207 //==============================================================
208 //==============================================================
209 $mpdf->WriteHTML($html); // Separate Paragraphs defined by font
210
211 $mpdf->Output();
212 exit;
213
214 //==============================================================
215 //==============================================================
216 //==============================================================
217 //==============================================================
218
219
220 ?>