This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/jpgraph/docs/chunkhtml/ch08s07.html
2011-05-28 19:51:52 +10:00

102 lines
14 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Inserting Unicode entities</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch08.html" title="Chapter 8. Text and font handling"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Inserting Unicode entities</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 8. Text and font handling</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Inserting Unicode entities"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.inserting-unicode"></a>Inserting Unicode entities</h2></div></div></div>
<p>One reason for using TTF fonts is the possibility to inserting unicode
character/entities. With this we mean characters from the extended range that are
not normally available on West european keyboards. This could for example be
classical Greek characters often used in mathematics, for example the symbol for
"pi". In order to make these and other commonly used "special" characters more
accessible the library provides a utility class that makes it easy to use these
characters without having to look up the corresponding unicode entities every
time.</p>
<p>In order to specify characters not available on the keyboard the normal way is to
specify there unicode code and included it in the text string with the prefix
"&amp;#". For example the unicode for the character "pi" is "03C0" in hex so to
include this character in a text string you would have to write "This is pi
&amp;#0960;" note that the code should be given in decimal encoding in the string
and always use 4 digits (pre-padded with 0:s as necessary). Since it is very tedious
to lookup and encode special characters the library offers a simpler way. The
<code class="code">SymChar</code> class. </p>
<p>
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
<p>This section can be skipped at first reading without loss of
continuity.</p>
</div><p>
</p>
<div class="sect2" title='The utility class "SymChar"'><div class="titlepage"><div><div><h3 class="title"><a name="id2499171"></a>The utility class "SymChar"</h3></div></div></div>
<p>As described above it is tedious to have to lookup all the character codes. To
simplify this the SymChar class allows you to find these characters with the
english common name of these symbols instead. For example to create a string
with the Greek character "pi" one would have to write the code as shown
in.</p>
<div class="example"><a name="ex.sym-char-ex1"></a><p class="title"><b>Example 8.2. Using the SymChar class to display the Greek letter "pi"</b></p><div class="example-contents">
<div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$pi</span><span class="hl-code"> = </span><span class="hl-identifier">SymChar</span><span class="hl-code">::</span><span class="hl-identifier">Get</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">pi</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Test is pi</span><span class="hl-quotes">'</span><span class="hl-code">.</span><span class="hl-var">$pi</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div>
</div></div><br class="example-break">
<p>All supported entities with there symbolic names are listed in <a class="xref" href="ch08s07.html#tab.sym-char-list" title="Table 8.3. Supported character entities in class SymChar">Table 8.3. Supported character entities in class SymChar</a>. The first argument to the static method
<code class="code">SymChar::Get()</code> should be the name of the entity and if the
second optional argument is true then the capital version (if it exists) of the
symbol should be returned.</p>
<p>
</p><div class="table"><a name="tab.sym-char-list"></a><p class="title"><b>Table 8.3. Supported character entities in class SymChar</b></p><div class="table-contents">
<table summary="Supported character entities in class SymChar" border="1"><colgroup><col class="c1"><col class="c2"><col class="c3"><col class="c4"></colgroup><thead><tr><th>Name</th><th>Unicode </th><th>Unicode capital</th><th>Comment</th></tr></thead><tbody><tr><td>"alpha"</td><td>03B1</td><td>0391</td><td>Greek character</td></tr><tr><td>"beta"</td><td>03B2</td><td>0392</td><td>Greek character</td></tr><tr><td>"gamma"</td><td>03B3</td><td>0393</td><td>Greek character</td></tr><tr><td>"delta"</td><td>03B4</td><td>0394</td><td>Greek character</td></tr><tr><td>"epsilon"</td><td>03B5</td><td>0395</td><td>Greek character</td></tr><tr><td>"zeta"</td><td>03B6</td><td>0396</td><td>Greek character</td></tr><tr><td>"ny"</td><td>03B7</td><td>0397</td><td>Greek character</td></tr><tr><td>"eta"</td><td>03B8</td><td>0398</td><td>Greek character</td></tr><tr><td>"theta"</td><td>03B8</td><td>0398</td><td>Greek character</td></tr><tr><td>"iota"</td><td>03B9</td><td>0399</td><td>Greek character</td></tr><tr><td>"kappa"</td><td>03BA</td><td>039A</td><td>Greek character</td></tr><tr><td>"lambda"</td><td>03BB</td><td>039B</td><td>Greek character</td></tr><tr><td>"mu"</td><td>03BC</td><td>039C</td><td>Greek character</td></tr><tr><td>"nu"</td><td>03BD</td><td>039D</td><td>Greek character</td></tr><tr><td>"xi"</td><td>03BE</td><td>039E</td><td>Greek character</td></tr><tr><td>"omicron"</td><td>03BF</td><td>039F</td><td>Greek character</td></tr><tr><td>"pi"</td><td>03C0</td><td>03A0</td><td>Greek character</td></tr><tr><td>"rho"</td><td>03C1</td><td>03A1</td><td>Greek character</td></tr><tr><td>"sigma"</td><td>03C3</td><td>03A3</td><td>Greek character</td></tr><tr><td>"tau"</td><td>03C4</td><td>03A4</td><td>Greek character</td></tr><tr><td>"upsilon"</td><td>03C5</td><td>03A5</td><td>Greek character</td></tr><tr><td>"phi"</td><td>03C6</td><td>03A6</td><td>Greek character</td></tr><tr><td>"chi"</td><td>03C7</td><td>03A7</td><td>Greek character</td></tr><tr><td>"psi"</td><td>03C8</td><td>03A8</td><td>Greek character</td></tr><tr><td>"omega"</td><td>03C9</td><td>03A9</td><td>Greek character</td></tr><tr><td>"euro"</td><td>20AC</td><td> </td><td>Monetary symbol</td></tr><tr><td>"yen"</td><td>00A5</td><td> </td><td>Monetary symbol</td></tr><tr><td>"pound"</td><td>20A4</td><td> </td><td>Monetary symbol</td></tr><tr><td>"approx"</td><td>2248</td><td> </td><td>Mathematical</td></tr><tr><td>"neq"</td><td>2260</td><td> </td><td>Mathematical</td></tr><tr><td>"not"</td><td>2310</td><td> </td><td>Mathematical</td></tr><tr><td>"def"</td><td>2261</td><td> </td><td>Mathematical</td></tr><tr><td>"inf"</td><td>221E</td><td> </td><td>Mathematical</td></tr><tr><td>"sqrt"</td><td>221A</td><td> </td><td>Mathematical</td></tr><tr><td>"int"</td><td>222B</td><td> </td><td>Mathematical</td></tr><tr><td>"copy"</td><td>00A9</td><td> </td><td>Misc symbols</td></tr><tr><td>"para"</td><td>00A7</td><td> </td><td>Misc symbols</td></tr><tr><td>"tm"</td><td>2122</td><td> </td><td>Misc symbols</td></tr><tr><td>"rtm"</td><td>00AE</td><td> </td><td>Misc symbols</td></tr></tbody></table>
</div></div><p><br class="table-break">
</p>
<p><a class="xref" href="ch08s07.html#fig.sym-char-list" title="Figure 8.6. Rendered symbol characters corresponding to">Figure 8.6. Rendered symbol characters corresponding to
</a> and <a class="xref" href="ch08s07.html#fig.sym-char-capital-list" title="Figure 8.7. Rendered capital symbol characters corresponding to Table 8.3. Supported character entities in class SymChar.">Figure 8.7. Rendered capital symbol characters corresponding to Table 8.3. Supported character entities in class SymChar. </a> shows how these symbol look when
they are rendered with the TTF font <span class="italic">Times Roman 14pt</span>. The symbols are in the same order
as in the table above and are visually grouped by there category as specified in
the column "Comment" in the table above.</p>
<p>
</p><div class="figure"><a name="fig.sym-char-list"></a><p class="title"><b>Figure 8.6. Rendered symbol characters corresponding to
</b></p><div class="figure-contents">
<div class="mediaobject"><img src="images/sym-char-list.png" alt="Rendered symbol characters corresponding to"></div>
</div></div><p><br class="figure-break">
</p>
<p>
</p><div class="figure"><a name="fig.sym-char-capital-list"></a><p class="title"><b>Figure 8.7. Rendered capital symbol characters corresponding to <a class="xref" href="ch08s07.html#tab.sym-char-list" title="Table 8.3. Supported character entities in class SymChar">Table 8.3. Supported character entities in class SymChar</a>. </b></p><div class="figure-contents">
<div class="mediaobject"><img src="images/sym-char-list-capital.png" alt="Rendered capital symbol characters corresponding to ."></div>
</div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Graph example with Greek labels"><div class="titlepage"><div><div><h3 class="title"><a name="id2500148"></a>Graph example with Greek labels</h3></div></div></div>
<p>In <a class="xref" href="ch08s07.html#fig.manualtickex2" title="Figure 8.8. Specifying manual ticks as fraction of Pi. (manualtickex2.php)">Figure 8.8. Specifying manual ticks as fraction of Pi. <code class="uri"><a class="uri" href="example_src/manualtickex2.html" target="_top">(<code class="filename">manualtickex2.php</code>)</a></code> </a> we have used the previous discussed
<code class="code">SymChar</code> class to more readily insert "π" characters in the
X-axis label. We highlight some functionality that we haven't yet discussed in
detail</p>
<p>
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<p>We use a utility class (<code class="code">FuncGenerator</code> available in
"<code class="filename">jpgraph_utils.inc.php</code>") to help create
plot values from a mathematical expression. This will help create a
set of (x,y) points that can later on be used as the base for a data
series.</p>
</li><li class="listitem">
<p>The x-axis labels and the position of the tick marks on the x-axis
are manually positioned and specified to be positioned at "even"
fractions of π.</p>
</li></ol></div><p>
</p>
<p>
</p><div class="figure"><a name="fig.manualtickex2"></a><p class="title"><b>Figure 8.8. Specifying manual ticks as fraction of Pi. <code class="uri"><a class="uri" href="example_src/manualtickex2.html" target="_top">(<code class="filename">manualtickex2.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/manualtickex2.png" alt="Specifying manual ticks as fraction of Pi. (manualtickex2.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch08.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>