Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > b17ed897c34853a0a39ef25ab5d3af32 > files > 125

python3-pillow-doc-2.6.2-2.mga5.noarch.rpm

<!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>ImageFont Module &mdash; Pillow v2.6.2 (PIL fork)</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:     '2.6.2',
        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="author" title="About these documents" href="../about.html" />
    <link rel="top" title="Pillow v2.6.2 (PIL fork)" href="../index.html" />
    <link rel="up" title="Reference" href="index.html" />
    <link rel="next" title="ImageGrab Module (Windows-only)" href="ImageGrab.html" />
    <link rel="prev" title="ImageFilter Module" href="ImageFilter.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="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="ImageGrab.html" title="ImageGrab Module (Windows-only)"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="ImageFilter.html" title="ImageFilter Module"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Home</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">Reference</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <span class="target" id="module-PIL.ImageFont"></span><div class="section" id="imagefont-module">
<h1><tt class="xref py py-mod docutils literal"><span class="pre">ImageFont</span></tt> Module<a class="headerlink" href="#imagefont-module" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="xref py py-mod docutils literal"><span class="pre">ImageFont</span></tt> module defines a class with the same name. Instances of
this class store bitmap fonts, and are used with the
<tt class="xref py py-meth docutils literal"><span class="pre">PIL.ImageDraw.Draw.text()</span></tt> method.</p>
<p>PIL uses its own font file format to store bitmap fonts. You can use the
:command`pilfont` utility to convert BDF and PCF font descriptors (X window
font formats) to this format.</p>
<p>Starting with version 1.1.4, PIL can be configured to support TrueType and
OpenType fonts (as well as other font formats supported by the FreeType
library). For earlier versions, TrueType support is only available as part of
the imToolkit package</p>
<div class="section" id="example">
<h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">ImageFont</span><span class="p">,</span> <span class="n">ImageDraw</span>

<span class="n">draw</span> <span class="o">=</span> <span class="n">ImageDraw</span><span class="o">.</span><span class="n">Draw</span><span class="p">(</span><span class="n">image</span><span class="p">)</span>

<span class="c"># use a bitmap font</span>
<span class="n">font</span> <span class="o">=</span> <span class="n">ImageFont</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s">&quot;arial.pil&quot;</span><span class="p">)</span>

<span class="n">draw</span><span class="o">.</span><span class="n">text</span><span class="p">((</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">),</span> <span class="s">&quot;hello&quot;</span><span class="p">,</span> <span class="n">font</span><span class="o">=</span><span class="n">font</span><span class="p">)</span>

<span class="c"># use a truetype font</span>
<span class="n">font</span> <span class="o">=</span> <span class="n">ImageFont</span><span class="o">.</span><span class="n">truetype</span><span class="p">(</span><span class="s">&quot;arial.ttf&quot;</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>

<span class="n">draw</span><span class="o">.</span><span class="n">text</span><span class="p">((</span><span class="mi">10</span><span class="p">,</span> <span class="mi">25</span><span class="p">),</span> <span class="s">&quot;world&quot;</span><span class="p">,</span> <span class="n">font</span><span class="o">=</span><span class="n">font</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="functions">
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="methods">
<h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline">¶</a></h2>
<dl class="method">
<dt id="PIL.ImageFont.PIL.ImageFont.ImageFont.getsize">
<tt class="descclassname">PIL.ImageFont.ImageFont.</tt><tt class="descname">getsize</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#PIL.ImageFont.PIL.ImageFont.ImageFont.getsize" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">(width, height)</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="PIL.ImageFont.PIL.ImageFont.ImageFont.getmask">
<tt class="descclassname">PIL.ImageFont.ImageFont.</tt><tt class="descname">getmask</tt><big>(</big><em>text</em>, <em>mode=''</em><big>)</big><a class="headerlink" href="#PIL.ImageFont.PIL.ImageFont.ImageFont.getmask" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a bitmap for the text.</p>
<p>If the font uses antialiasing, the bitmap should have mode “L” and use a
maximum value of 255. Otherwise, it should have mode “1”.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>text</strong> &#8211; Text to render.</li>
<li><strong>mode</strong> &#8211; <p>Used by some graphics drivers to indicate what mode the
driver prefers; if empty, the renderer may return either
mode. Note that the mode is always a string, to simplify
C-level implementations.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.1.5.</span></p>
</div>
</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An internal PIL storage memory instance as defined by the
<tt class="xref py py-mod docutils literal"><span class="pre">PIL.Image.core</span></tt> interface module.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">ImageFont</span></tt> Module</a><ul>
<li><a class="reference internal" href="#example">Example</a></li>
<li><a class="reference internal" href="#functions">Functions</a></li>
<li><a class="reference internal" href="#methods">Methods</a></li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/reference/ImageFont.txt"
           rel="nofollow">Show Source</a></li>
  </ul><h3>Need help?</h3>
<p>
    You can get help via IRC at <a href="irc://irc.freenode.net#pil">irc://irc.freenode.net#pil</a> or Stack Overflow <a href="http://stackoverflow.com/questions/tagged/pillow">here</a> and <a href="http://stackoverflow.com/questions/tagged/pil">here</a>. Please <a href="https://github.com/python-pillow/Pillow/issues/new">report issues on GitHub</a>.
</p>
<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="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="ImageGrab.html" title="ImageGrab Module (Windows-only)"
             >next</a> |</li>
        <li class="right" >
          <a href="ImageFilter.html" title="ImageFilter Module"
             >previous</a> |</li>
        <li><a href="../index.html">Home</a> &raquo;</li>
          <li><a href="index.html" >Reference</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 1997-2011 by Secret Labs AB, 1995-2011 by Fredrik Lundh, 2010-2013 Alex Clark.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>