diff options
Diffstat (limited to 'pdf/fpdf/tutorial')
-rwxr-xr-x | pdf/fpdf/tutorial/calligra.php | 4 | ||||
-rwxr-xr-x | pdf/fpdf/tutorial/calligra.z | bin | 25604 -> 22477 bytes | |||
-rwxr-xr-x | pdf/fpdf/tutorial/index.htm | 4 | ||||
-rwxr-xr-x | pdf/fpdf/tutorial/tuto1.htm | 8 | ||||
-rwxr-xr-x | pdf/fpdf/tutorial/tuto4.htm | 8 | ||||
-rwxr-xr-x | pdf/fpdf/tutorial/tuto4.php | 6 | ||||
-rwxr-xr-x | pdf/fpdf/tutorial/tuto6.htm | 19 | ||||
-rwxr-xr-x | pdf/fpdf/tutorial/tuto6.php | 19 | ||||
-rwxr-xr-x | pdf/fpdf/tutorial/tuto7.htm | 104 |
9 files changed, 47 insertions, 125 deletions
diff --git a/pdf/fpdf/tutorial/calligra.php b/pdf/fpdf/tutorial/calligra.php index baf8a3a..e262f4c 100755 --- a/pdf/fpdf/tutorial/calligra.php +++ b/pdf/fpdf/tutorial/calligra.php @@ -18,6 +18,8 @@ $cw = array( chr(220)=>805,chr(221)=>0,chr(222)=>0,chr(223)=>688,chr(224)=>581,chr(225)=>581,chr(226)=>581,chr(227)=>581,chr(228)=>581,chr(229)=>581,chr(230)=>792,chr(231)=>440,chr(232)=>450,chr(233)=>450,chr(234)=>450,chr(235)=>450,chr(236)=>283,chr(237)=>283,chr(238)=>283,chr(239)=>283,chr(240)=>0,chr(241)=>595,
chr(242)=>508,chr(243)=>508,chr(244)=>508,chr(245)=>508,chr(246)=>508,chr(247)=>0,chr(248)=>508,chr(249)=>614,chr(250)=>614,chr(251)=>614,chr(252)=>614,chr(253)=>0,chr(254)=>0,chr(255)=>597);
$enc = 'cp1252';
+$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
$file = 'calligra.z';
-$originalsize = 40120;
+$originalsize = 33948;
+$subsetted = true;
?>
diff --git a/pdf/fpdf/tutorial/calligra.z b/pdf/fpdf/tutorial/calligra.z Binary files differindex 1c0bebd..8a14e9c 100755 --- a/pdf/fpdf/tutorial/calligra.z +++ b/pdf/fpdf/tutorial/calligra.z diff --git a/pdf/fpdf/tutorial/index.htm b/pdf/fpdf/tutorial/index.htm index 44dba25..87cc484 100755 --- a/pdf/fpdf/tutorial/index.htm +++ b/pdf/fpdf/tutorial/index.htm @@ -14,7 +14,7 @@ <li><a href="tuto4.htm">Tutorial 4</a>: Multi-columns</li>
<li><a href="tuto5.htm">Tutorial 5</a>: Tables</li>
<li><a href="tuto6.htm">Tutorial 6</a>: Links and flowing text</li>
-<li><a href="tuto7.htm">Tutorial 7</a>: Adding new fonts and encoding support</li>
-</UL>
+<li><a href="tuto7.htm">Tutorial 7</a>: Adding new fonts and encodings</li>
+</ul>
</body>
</html>
diff --git a/pdf/fpdf/tutorial/tuto1.htm b/pdf/fpdf/tutorial/tuto1.htm index a26e29a..36fabad 100755 --- a/pdf/fpdf/tutorial/tuto1.htm +++ b/pdf/fpdf/tutorial/tuto1.htm @@ -21,7 +21,7 @@ Let's start with the classic example: </div>
<p class='demo'><a href='tuto1.php' target='_blank' class='demo'>[Demo]</a></p>
After including the library file, we create an FPDF object.
-The <a href='../doc/fpdf.htm'>FPDF()</a> constructor is used here with the default values: pages are in A4 portrait and
+The <a href='../doc/__construct.htm'>constructor</a> is used here with the default values: pages are in A4 portrait and
the unit of measure is millimeter. It could have been specified explicitly with:
<div class="source">
<pre><code>$pdf <span class="kw">= new </span>FPDF<span class="kw">(</span><span class="str">'P'</span><span class="kw">,</span><span class="str">'mm'</span><span class="kw">,</span><span class="str">'A4'</span><span class="kw">);
@@ -36,8 +36,8 @@ is at the upper-left corner and the current position is by default set at 1 cm f borders; the margins can be changed with <a href='../doc/setmargins.htm'>SetMargins()</a>.
<br>
<br>
-Before we can print text, it's mandatory to select a font with <a href='../doc/setfont.htm'>SetFont()</a>, otherwise the
-document would be invalid. We choose Arial bold 16:
+Before we can print text, it's mandatory to select a font with <a href='../doc/setfont.htm'>SetFont()</a>.
+We choose Arial bold 16:
<div class="source">
<pre><code>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">,</span>16<span class="kw">);
</span></code></pre>
@@ -65,7 +65,7 @@ the height of the break. <br>
<br>
Finally, the document is closed and sent to the browser with <a href='../doc/output.htm'>Output()</a>. We could have saved
-it to a file by passing the desired file name.
+it to a file by passing the appropriate parameters.
<br>
<br>
<strong>Caution:</strong> in case when the PDF is sent to the browser, nothing else must be output by the
diff --git a/pdf/fpdf/tutorial/tuto4.htm b/pdf/fpdf/tutorial/tuto4.htm index c4a4eb8..7af730f 100755 --- a/pdf/fpdf/tutorial/tuto4.htm +++ b/pdf/fpdf/tutorial/tuto4.htm @@ -15,12 +15,10 @@ columns. class </span>PDF <span class="kw">extends </span>FPDF
<span class="kw">{
-</span><span class="cmt">// Current column
-</span><span class="kw">var </span>$col <span class="kw">= </span>0<span class="kw">;
-</span><span class="cmt">// Ordinate of column start
-</span><span class="kw">var </span>$y0<span class="kw">;
+protected </span>$col <span class="kw">= </span>0<span class="kw">; </span><span class="cmt">// Current column
+</span><span class="kw">protected </span>$y0<span class="kw">; </span><span class="cmt">// Ordinate of column start
-function </span>Header<span class="kw">()
+</span><span class="kw">function </span>Header<span class="kw">()
{
</span><span class="cmt">// Page header
</span><span class="kw">global </span>$title<span class="kw">;
diff --git a/pdf/fpdf/tutorial/tuto4.php b/pdf/fpdf/tutorial/tuto4.php index 360d237..f5f4fa8 100755 --- a/pdf/fpdf/tutorial/tuto4.php +++ b/pdf/fpdf/tutorial/tuto4.php @@ -3,10 +3,8 @@ require('../fpdf.php'); class PDF extends FPDF
{
-// Current column
-var $col = 0;
-// Ordinate of column start
-var $y0;
+protected $col = 0; // Current column
+protected $y0; // Ordinate of column start
function Header()
{
diff --git a/pdf/fpdf/tutorial/tuto6.htm b/pdf/fpdf/tutorial/tuto6.htm index 2b98d20..24516e6 100755 --- a/pdf/fpdf/tutorial/tuto6.htm +++ b/pdf/fpdf/tutorial/tuto6.htm @@ -15,21 +15,10 @@ mode. It also contains a basic HTML parser. class </span>PDF <span class="kw">extends </span>FPDF
<span class="kw">{
-var </span>$B<span class="kw">;
-var </span>$I<span class="kw">;
-var </span>$U<span class="kw">;
-var </span>$HREF<span class="kw">;
-
-function </span>PDF<span class="kw">(</span>$orientation<span class="kw">=</span><span class="str">'P'</span><span class="kw">, </span>$unit<span class="kw">=</span><span class="str">'mm'</span><span class="kw">, </span>$size<span class="kw">=</span><span class="str">'A4'</span><span class="kw">)
-{
- </span><span class="cmt">// Call parent constructor
- </span>$<span class="kw">this-></span>FPDF<span class="kw">(</span>$orientation<span class="kw">,</span>$unit<span class="kw">,</span>$size<span class="kw">);
- </span><span class="cmt">// Initialization
- </span>$<span class="kw">this-></span>B <span class="kw">= </span>0<span class="kw">;
- </span>$<span class="kw">this-></span>I <span class="kw">= </span>0<span class="kw">;
- </span>$<span class="kw">this-></span>U <span class="kw">= </span>0<span class="kw">;
- </span>$<span class="kw">this-></span>HREF <span class="kw">= </span><span class="str">''</span><span class="kw">;
-}
+protected </span>$B <span class="kw">= </span>0<span class="kw">;
+protected </span>$I <span class="kw">= </span>0<span class="kw">;
+protected </span>$U <span class="kw">= </span>0<span class="kw">;
+protected </span>$HREF <span class="kw">= </span><span class="str">''</span><span class="kw">;
function </span>WriteHTML<span class="kw">(</span>$html<span class="kw">)
{
diff --git a/pdf/fpdf/tutorial/tuto6.php b/pdf/fpdf/tutorial/tuto6.php index 88fdd51..66580e9 100755 --- a/pdf/fpdf/tutorial/tuto6.php +++ b/pdf/fpdf/tutorial/tuto6.php @@ -3,21 +3,10 @@ require('../fpdf.php'); class PDF extends FPDF
{
-var $B;
-var $I;
-var $U;
-var $HREF;
-
-function PDF($orientation='P', $unit='mm', $size='A4')
-{
- // Call parent constructor
- $this->FPDF($orientation,$unit,$size);
- // Initialization
- $this->B = 0;
- $this->I = 0;
- $this->U = 0;
- $this->HREF = '';
-}
+protected $B = 0;
+protected $I = 0;
+protected $U = 0;
+protected $HREF = '';
function WriteHTML($html)
{
diff --git a/pdf/fpdf/tutorial/tuto7.htm b/pdf/fpdf/tutorial/tuto7.htm index 21a3f6e..b42e552 100755 --- a/pdf/fpdf/tutorial/tuto7.htm +++ b/pdf/fpdf/tutorial/tuto7.htm @@ -2,32 +2,18 @@ <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Adding new fonts and encoding support</title>
+<title>Adding new fonts and encodings</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
-<style type="text/css">
-table {border-collapse:collapse; border-style:solid; border-width:2px; border-color:#A0A0A0 #000000 #000000 #A0A0A0}
-table {margin:1.4em 0 1.4em 1em}
-th {background-color:#E0EBFF; color:#900000; text-align:left}
-th, td {border:1px solid #808080; padding:2px 10px}
-tr.alt0 {background-color:#FFFFEE}
-tr.alt1 {background-color:#FFFFE0}
-</style>
</head>
<body>
-<h1>Adding new fonts and encoding support</h1>
-This tutorial explains how to use TrueType, OpenType and Type1 fonts so that you are not limited to
-the standard fonts any more. The other benefit is that you can choose the font encoding, which allows
-you to use other languages than the Western ones (the standard fonts having too few available characters).
+<h1>Adding new fonts and encodings</h1>
+This tutorial explains how to use TrueType, OpenType and Type1 fonts so that you are not limited to the
+standard fonts anymore. The other benefit is that you can choose the text encoding, which allows you to
+use other languages than the Western ones (the standard fonts support only cp1252 aka windows-1252).
<br>
<br>
-Remark: for OpenType, only the format based on TrueType is supported (not the one based on Type1).
-<br>
-<br>
-There are two ways to use a new font: embedding it in the PDF or not. When a font is not
-embedded, it is searched in the system. The advantage is that the PDF file is lighter; on the other
-hand, if it's not available, a substitution font is used. So it's preferable to ensure that the
-needed font is installed on the client systems. If the file is to be viewed by a large audience,
-it's highly recommended to embed.
+For OpenType, only the format based on TrueType is supported (not the one based on Type1).<br>
+For Type1, you will need the corresponding AFM file (it is usually provided with the font).
<br>
<br>
Adding a new font requires two steps:
@@ -35,7 +21,6 @@ Adding a new font requires two steps: <li>Generation of the font definition file</li>
<li>Declaration of the font in the script</li>
</ul>
-For Type1, you need the corresponding AFM file. It's usually provided with the font.
<h2>Generation of the font definition file</h2>
The first step consists in generating a PHP file containing all the information needed by FPDF;
@@ -43,7 +28,7 @@ in addition, the font file is compressed. To do this, a helper script is provide directory of the package: makefont.php. It contains the following function:
<br>
<br>
-<code>MakeFont(<b>string</b> fontfile, [, <b>string</b> enc [, <b>boolean</b> embed]])</code>
+<code>MakeFont(<b>string</b> fontfile [, <b>string</b> enc [, <b>boolean</b> embed [, <b>boolean</b> subset]]])</code>
<dl class="param" style="margin-bottom:2em">
<dt><code>fontfile</code></dt>
<dd>
@@ -57,6 +42,10 @@ directory of the package: makefont.php. It contains the following function: <dd>
<p>Whether to embed the font or not. Default value: <code>true</code>.</p>
</dd>
+<dt><code>subset</code></dt>
+<dd>
+<p>Whether to subset the font or not. Default value: <code>true</code>.</p>
+</dd>
</dl>
The first parameter is the name of the font file. The extension must be either .ttf, .otf or .pfb and
determines the font type. If your Type1 font is in ASCII format (.pfa), you can convert it to binary
@@ -91,10 +80,19 @@ files. The available ones are: <li>KOI8-R (Russian)</li>
<li>KOI8-U (Ukrainian)</li>
</ul>
-Of course, the font must contain the characters corresponding to the chosen encoding.
+Of course, the font must contain the characters corresponding to the selected encoding.
<br>
<br>
-Remark: the standard fonts use cp1252.
+The third parameter indicates whether the font should be embedded in the PDF or not. When a font is
+not embedded, it is searched in the system. The advantage is that the PDF file is smaller; on the
+other hand, if it is not available, then a substitution font is used. So you should ensure that the
+needed font is installed on the client systems. Embedding is the recommended option to guarantee a
+correct rendering.
+<br>
+<br>
+The last parameter indicates whether subsetting should be used, that is to say, whether only
+the characters from the selected encoding should be kept in the embedded font. As a result,
+the size of the PDF file can be greatly reduced, especially if the original font was big.
<br>
<br>
After you have called the function (create a new file for this and include makefont.php), a .php file
@@ -109,7 +107,7 @@ Example: <pre><code><?php
<span class="kw">require(</span><span class="str">'makefont/makefont.php'</span><span class="kw">);
-</span>MakeFont<span class="kw">(</span><span class="str">'c:\\Windows\\Fonts\\comic.ttf'</span><span class="kw">,</span><span class="str">'cp1252'</span><span class="kw">);
+</span>MakeFont<span class="kw">(</span><span class="str">'C:\\Windows\\Fonts\\comic.ttf'</span><span class="kw">,</span><span class="str">'cp1252'</span><span class="kw">);
</span>?></code></pre>
</div>
which gives the files comic.php and comic.z.
@@ -122,7 +120,7 @@ it directly instead of the .z version. Another way to call MakeFont() is through the command line:
<br>
<br>
-<kbd>php makefont\makefont.php c:\Windows\Fonts\comic.ttf cp1252</kbd>
+<kbd>php makefont\makefont.php C:\Windows\Fonts\comic.ttf cp1252</kbd>
<br>
<br>
Finally, for TrueType and OpenType fonts, you can also generate the files
@@ -185,57 +183,5 @@ We can now copy the two generated files to the font directory and write the scri </span>?></code></pre>
</div>
<p class='demo'><a href='tuto7.php' target='_blank' class='demo'>[Demo]</a></p>
-
-<h2>About the euro symbol</h2>
-The euro character is not present in all encodings, and is not always placed at the same position:
-<table>
-<tr><th>Encoding</th><th>Position</th></tr>
-<tr class="alt0"><td>cp1250</td><td>128</td></tr>
-<tr class="alt1"><td>cp1251</td><td>136</td></tr>
-<tr class="alt0"><td>cp1252</td><td>128</td></tr>
-<tr class="alt1"><td>cp1253</td><td>128</td></tr>
-<tr class="alt0"><td>cp1254</td><td>128</td></tr>
-<tr class="alt1"><td>cp1255</td><td>128</td></tr>
-<tr class="alt0"><td>cp1257</td><td>128</td></tr>
-<tr class="alt1"><td>cp1258</td><td>128</td></tr>
-<tr class="alt0"><td>cp874</td><td>128</td></tr>
-<tr class="alt1"><td>ISO-8859-1</td><td>N/A</td></tr>
-<tr class="alt0"><td>ISO-8859-2</td><td>N/A</td></tr>
-<tr class="alt1"><td>ISO-8859-4</td><td>N/A</td></tr>
-<tr class="alt0"><td>ISO-8859-5</td><td>N/A</td></tr>
-<tr class="alt1"><td>ISO-8859-7</td><td>N/A</td></tr>
-<tr class="alt0"><td>ISO-8859-9</td><td>N/A</td></tr>
-<tr class="alt1"><td>ISO-8859-11</td><td>N/A</td></tr>
-<tr class="alt0"><td>ISO-8859-15</td><td>164</td></tr>
-<tr class="alt1"><td>ISO-8859-16</td><td>164</td></tr>
-<tr class="alt0"><td>KOI8-R</td><td>N/A</td></tr>
-<tr class="alt1"><td>KOI8-U</td><td>N/A</td></tr>
-</table>
-ISO-8859-1 is widespread but does not include the euro sign. If you need it, the simplest thing
-to do is to use cp1252 or ISO-8859-15 instead, which are nearly identical but contain the precious
-symbol.
-
-<h2>Reducing the size of TrueType fonts</h2>
-Font files are often quite voluminous; this is due to the fact that they contain the characters
-corresponding to many encodings. Zlib compression reduces them but they remain fairly big. A
-technique exists to reduce them further. It consists in converting the font to the Type1 format
-with <a href="http://ttf2pt1.sourceforge.net" target="_blank">ttf2pt1</a> (the Windows binary is
-available <a href="http://www.fpdf.org/fr/dl.php?id=22">here</a>) while specifying the encoding
-you are interested in; all other characters will be discarded.
-<br>
-For example, the arial.ttf font that ships with Windows Vista weights 748 KB (it contains 3381 characters).
-After compression it drops to 411. Let's convert it to Type1 by keeping only cp1250 characters:
-<br>
-<br>
-<kbd>ttf2pt1 -b -L cp1250.map c:\Windows\Fonts\arial.ttf arial</kbd>
-<br>
-<br>
-The .map files are located in the makefont directory of the package. The command produces
-arial.pfb and arial.afm. The arial.pfb file weights only 57 KB, and 53 after compression.
-<br>
-<br>
-It's possible to go even further. If you are interested only by a subset of the encoding (you
-probably don't need all 217 characters), you can open the .map file and remove the lines you are
-not interested in. This will reduce the file size accordingly.
</body>
</html>
|