You are on page 1of 6

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.

org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>sge.Font &mdash; The Pygame SGE 0.8.0 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '0.8.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="The Pygame SGE 0.8.0 documentation" href="index.html" /> <link rel="up" title="Classes" href="classes.html" /> <link rel="next" title="sge.StellarClass" href="StellarClass.html" /> <link rel="prev" title="sge.Music" href="Music.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="StellarClass.html" title="sge.StellarClass" accesskey="N">next</a> |</li> <li class="right" > <a href="Music.html" title="sge.Music" accesskey="P">previous</a> |</li> <li><a href="index.html">The Pygame SGE 0.8.0 documentation</a> &raquo;< /li> <li><a href="classes.html" accesskey="U">Classes</a> &raquo;</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="sge-font"> <h1>sge.Font<a class="headerlink" href="#sge-font" title="Permalink to this head line"></a></h1>

<dl class="class"> <dt id="sge.Font"> <em class="property">class </em><tt class="descclassname">sge.</tt><tt class="de scname">Font</tt><big>(</big><em>name=None</em>, <em>ID=None</em>, <em>size=12</ em>, <em>underline=False</em>, <em>bold=False</em>, <em>italic=False</em><big>)< /big><a class="headerlink" href="#sge.Font" title="Permalink to this definition" ></a></dt> <dd><p>Font handling class.</p> <p>This class stores a font for use by <a class="reference internal" href="Sprit e.html#sge.Sprite.draw_text" title="sge.Sprite.draw_text"><tt class="xref py pymeth docutils literal"><span class="pre">sge.Sprite.draw_text()</span></tt></a> and <a class="reference internal" href="Room.html#sge.Room.project_text" title="sge. Room.project_text"><tt class="xref py py-meth docutils literal"><span class="pre ">sge.Room.project_text()</span></tt></a>.</p> <p>Note that bold and italic rendering could be ugly. It is better to choose a bold or italic font rather than enabling bold or italic rendering, if possible.</p> <dl class="attribute"> <dt id="Font.size"> <tt class="descname">size</tt><a class="headerlink" href="#Font.size" title="Per malink to this definition"></a></dt> <dd><p>The height of the font in pixels.</p> </dd></dl> <dl class="attribute"> <dt id="Font.underline"> <tt class="descname">underline</tt><a class="headerlink" href="#Font.underline" title="Permalink to this definition"></a></dt> <dd><p>Whether or not underlined rendering is enabled.</p> </dd></dl> <dl class="attribute"> <dt id="Font.bold"> <tt class="descname">bold</tt><a class="headerlink" href="#Font.bold" title="Per malink to this definition"></a></dt> <dd><p>Whether or not bold rendering is enabled.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Using this option can be ugly. It is better to choose a bold font rather than enabling bold rendering, if possible.</p> </div> </dd></dl> <dl class="attribute"> <dt id="Font.italic"> <tt class="descname">italic</tt><a class="headerlink" href="#Font.italic" title= "Permalink to this definition"></a></dt> <dd><p>Whether or not italic rendering is enabled.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Using this option can be ugly. It is better to choose an italic font rather than enabling italic rendering, if possible.</p> </div> </dd></dl> <dl class="attribute"> <dt id="Font.name"> <tt class="descname">name</tt><a class="headerlink" href="#Font.name" title="Per

malink to this definition"></a></dt> <dd><p>The name of the font as specified when it was created. (Read-only)</p> </dd></dl> <dl class="attribute"> <dt id="Font.id"> <tt class="descname">id</tt><a class="headerlink" href="#Font.id" title="Permali nk to this definition"></a></dt> <dd><p>The unique identifier of the font. (Read-only)</p> </dd></dl> </dd></dl> <div class="section" id="sge-font-methods"> <h2>sge.Font Methods<a class="headerlink" href="#sge-font-methods" title="Permal ink to this headline"></a></h2> <dl class="method"> <dt id="sge.Font.__init__"> <tt class="descclassname">Font.</tt><tt class="descname">__init__</tt><big>(</bi g><em>name=None</em>, <em>ID=None</em>, <em>size=12</em>, <em>underline=False</e m>, <em>bold=False</em>, <em>italic=False</em><big>)</big><a class="headerlink" href="#sge.Font.__init__" title="Permalink to this definition"></a></dt> <dd><p>Constructor method.</p> <p>Arguments:</p> <ul> <li><p class="first"><tt class="docutils literal"><span class="pre">name</span>< /tt> &#8211; The name of the font. Can be one of the following:</p> <ul class="simple"> <li>A string indicating the name of a font file located in one of the paths specified in <a class="reference internal" href="globalvars.html#sg e.font_directories" title="sge.font_directories"><tt class="xref py py-data docu tils literal"><span class="pre">sge.font_directories</span></tt></a>, e.g. <tt class="docutils literal"><span class="pre">&quot;MyFont.ttf&quot;</span></tt >.</li> <li>A string indicating the case-insensitive name of a system font, e.g. <tt class="docutils literal"><span class="pre">&quot;Liberation</span > <span class="pre">Serif&quot;</span></tt>.</li> <li>A list or tuple of strings indicating either a font file or a system font to choose from in order of preference.</li> </ul> <p>If none of the above methods return a valid font, the SGE will choose the font.</p> </li> <li><p class="first"><tt class="docutils literal"><span class="pre">ID</span></t t> &#8211; The value to set <a class="reference internal" href="#Font.id" title= "Font.id"><tt class="xref py py-attr docutils literal"><span class="pre">id</spa n></tt></a> to. If set to <tt class="xref py py-const docutils literal"><span class="pre">None</span></tt> , <tt class="docutils literal"><span class="pre">name</span></tt> will be used, modified by the SGE if it is already the unique identifier of another font.</p> </li> </ul> <p>All other arguments set the respective initial attributes of the font. See the documentation for <a class="reference internal" href="#sge.Font" title="sge.Font"><tt class="xref py py-class docutils literal"><span class="pre" >sge.Font</span></tt></a> for more information.</p>

<div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">It is generally not a good practice to rely on system fonts. A font which you have on your system is probably not on everyone&#8217;s system. For example, most Windows systems have a font called Times New Roman, but this font is not normally found on Debian systems. On the other hand, Debian has the Liberation fonts installed by default, but these fonts are uncommon on Windows systems. Rather than relying on system fonts, choose a font which is under a free license (such as the GNU General Public License or the SIL Open Font License) and distribute it with your game; this will ensure that everyone sees text rendered the same way you do.</p> </div> </dd></dl> <dl class="method"> <dt id="sge.Font.get_size"> <tt class="descclassname">Font.</tt><tt class="descname">get_size</tt><big>(</bi g><em>text</em>, <em>width=None</em>, <em>height=None</em><big>)</big><a class=" headerlink" href="#sge.Font.get_size" title="Permalink to this definition"></a></d t> <dd><p>Return the size of a certain string of text when rendered.</p> <p>See the documentation for <a class="reference internal" href="Sprite.html#sge .Sprite.draw_text" title="sge.Sprite.draw_text"><tt class="xref py py-meth docut ils literal"><span class="pre">sge.Sprite.draw_text()</span></tt></a> for information about the arguments.</p> </dd></dl> <dl class="classmethod"> <dt id="sge.Font.from_sprite"> <em class="property">classmethod </em><tt class="descclassname">Font.</tt><tt cl ass="descname">from_sprite</tt><big>(</big><em>sprite</em>, <em>chars</em>, <em> ID=None</em>, <em>hsep=0</em>, <em>vsep=0</em>, <em>size=12</em>, <em>underline= False</em>, <em>bold=False</em>, <em>italic=False</em><big>)</big><a class="head erlink" href="#sge.Font.from_sprite" title="Permalink to this definition"></a></dt > <dd><p>Return a font derived from a sprite.</p> <p>Arguments:</p> <ul class="simple"> <li><tt class="docutils literal"><span class="pre">sprite</span></tt> &#8211; Th e <a class="reference internal" href="Sprite.html#sge.Sprite" title="sge.Sprite" ><tt class="xref py py-class docutils literal"><span class="pre">sge.Sprite</spa n></tt></a> object to derive the font from.</li> <li><tt class="docutils literal"><span class="pre">chars</span></tt> &#8211; A l ist of characters to set the sprite&#8217;s frames to. For example, <tt class="docutils literal"><span class="pre">['A',</span> <s pan class="pre">'B',</span> <span class="pre">'C']</span></tt> would assign the first frame to the letter &#8220;A&#8221;, the second frame to the letter &#8220;B&#82 21;, and the third frame to the letter &#8220;C&#8221;. Any character not listed here will be rendered as its differently-cased counterpart if possible (e.g. &#8220;A&#8221; as &#8220;a&#8221;) or as a blank space otherwise.</li> <li><tt class="docutils literal"><span class="pre">ID</span></tt> &#8211; The va lue to set <a class="reference internal" href="#Font.id" title="Font.id"><tt cla ss="xref py py-attr docutils literal"><span class="pre">id</span></tt></a> to.

If set to <tt class="xref py py-const docutils literal"><span class="pre">None</span></tt> , the name of the sprite will be used, modified by the SGE if it is already the unique identifier of another font.</li> <li><tt class="docutils literal"><span class="pre">hsep</span></tt> &#8211; The amount of horizontal space to place between characters when text is rendered.</li> <li><tt class="docutils literal"><span class="pre">vsep</span></tt> &#8211; The amount of vertical space to place between lines when text is rendered.</li> </ul> <p>All other arguments set the respective initial attributes of the font. See the documentation for <a class="reference internal" href="#sge.Font" title="sge.Font"><tt class="xref py py-class docutils literal"><span class="pre" >sge.Font</span></tt></a> for more information.</p> <p>The font&#8217;s <a class="reference internal" href="#Font.name" title="Font. name"><tt class="xref py py-attr docutils literal"><span class="pre">name</span> </tt></a> attribute will be set to the name of the sprite the font is derived from.</p> <p>The font&#8217;s <a class="reference internal" href="#Font.size" title="Font. size"><tt class="xref py py-attr docutils literal"><span class="pre">size</span> </tt></a> attribute will indicate the height of the characters in pixels. The width of the characters will be adjusted proportionally.</p> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <p class="logo"><a href="index.html"> <img class="logo" src="_static/sge_logo_alpha_black.png" alt="Logo "/> </a></p> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">sge.Font</a><ul> <li><a class="reference internal" href="#sge-font-methods">sge.Font Methods</a>< /li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="Music.html" title="previous chapter">sge.Music</a></p> <h4>Next topic</h4> <p class="topless"><a href="StellarClass.html" title="next chapter">sge.StellarClass</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/Font.txt" rel="nofollow">Show Source</a></li>

</ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="StellarClass.html" title="sge.StellarClass" >next</a> |</li> <li class="right" > <a href="Music.html" title="sge.Music" >previous</a> |</li> <li><a href="index.html">The Pygame SGE 0.8.0 documentation</a> &raquo;< /li> <li><a href="classes.html" >Classes</a> &raquo;</li> </ul> </div> <div class="footer"> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>

You might also like