Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > e5936adde9b1ea7ed6dc23c107bda8ab > files > 233

python3-pillow-doc-5.4.1-1.1.mga7.noarch.rpm



<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>ImageFont Module &mdash; Pillow (PIL Fork) 5.4.1 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></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>
        <script type="text/javascript" src="../_static/language_data.js"></script>
        <script type="text/javascript" src="../_static/js/script.js"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="ImageGrab Module (macOS and Windows only)" href="ImageGrab.html" />
    <link rel="prev" title="ImageFilter Module" href="ImageFilter.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html" class="icon icon-home"> Pillow (PIL Fork)
          

          
          </a>

          
            
            
              <div class="version">
                5.4.1
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../handbook/index.html">Handbook</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="Image.html"><code class="docutils literal notranslate"><span class="pre">Image</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageChops.html"><code class="docutils literal notranslate"><span class="pre">ImageChops</span></code> (“Channel Operations”) Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageColor.html"><code class="docutils literal notranslate"><span class="pre">ImageColor</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageCms.html"><code class="docutils literal notranslate"><span class="pre">ImageCms</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageDraw.html"><code class="docutils literal notranslate"><span class="pre">ImageDraw</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageEnhance.html"><code class="docutils literal notranslate"><span class="pre">ImageEnhance</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageFile.html"><code class="docutils literal notranslate"><span class="pre">ImageFile</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageFilter.html"><code class="docutils literal notranslate"><span class="pre">ImageFilter</span></code> Module</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">ImageFont</span></code> Module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#example">Example</a></li>
<li class="toctree-l3"><a class="reference internal" href="#functions">Functions</a></li>
<li class="toctree-l3"><a class="reference internal" href="#methods">Methods</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="ImageGrab.html"><code class="docutils literal notranslate"><span class="pre">ImageGrab</span></code> Module (macOS and Windows only)</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageMath.html"><code class="docutils literal notranslate"><span class="pre">ImageMath</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageMorph.html"><code class="docutils literal notranslate"><span class="pre">ImageMorph</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageOps.html"><code class="docutils literal notranslate"><span class="pre">ImageOps</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImagePalette.html"><code class="docutils literal notranslate"><span class="pre">ImagePalette</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImagePath.html"><code class="docutils literal notranslate"><span class="pre">ImagePath</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageQt.html"><code class="docutils literal notranslate"><span class="pre">ImageQt</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageSequence.html"><code class="docutils literal notranslate"><span class="pre">ImageSequence</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageStat.html"><code class="docutils literal notranslate"><span class="pre">ImageStat</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageTk.html"><code class="docutils literal notranslate"><span class="pre">ImageTk</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="ImageWin.html"><code class="docutils literal notranslate"><span class="pre">ImageWin</span></code> Module (Windows-only)</a></li>
<li class="toctree-l2"><a class="reference internal" href="ExifTags.html"><code class="docutils literal notranslate"><span class="pre">ExifTags</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="TiffTags.html"><code class="docutils literal notranslate"><span class="pre">TiffTags</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="PSDraw.html"><code class="docutils literal notranslate"><span class="pre">PSDraw</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="PixelAccess.html"><code class="docutils literal notranslate"><span class="pre">PixelAccess</span></code> Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="PyAccess.html"><code class="docutils literal notranslate"><span class="pre">PyAccess</span></code> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../PIL.html">PIL Package (autodoc of remaining modules)</a></li>
<li class="toctree-l2"><a class="reference internal" href="plugins.html">Plugin reference</a></li>
<li class="toctree-l2"><a class="reference internal" href="internal_design.html">Internal Reference Docs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../porting.html">Porting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../about.html">About</a></li>
<li class="toctree-l1"><a class="reference internal" href="../releasenotes/index.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../deprecations.html">Deprecations and removals</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">Pillow (PIL Fork)</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="index.html">Reference</a> &raquo;</li>
        
      <li><code class="docutils literal notranslate"><span class="pre">ImageFont</span></code> Module</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/reference/ImageFont.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <span class="target" id="module-PIL.ImageFont"></span><div class="section" id="imagefont-module">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">ImageFont</span></code> Module<a class="headerlink" href="#imagefont-module" title="Permalink to this headline">¶</a></h1>
<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">ImageFont</span></code> module defines a class with the same name. Instances of
this class store bitmap fonts, and are used with the
<code class="xref py py-meth docutils literal notranslate"><span class="pre">PIL.ImageDraw.Draw.text()</span></code> method.</p>
<p>PIL uses its own font file format to store bitmap fonts. You can use the
<strong class="command">pilfont</strong> 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 notranslate"><div class="highlight"><pre><span></span><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="c1"># 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="s2">&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="s2">&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="c1"># 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="s2">&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="s2">&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>
<dl class="function">
<dt id="PIL.ImageFont.load">
<code class="descclassname">PIL.ImageFont.</code><code class="descname">load</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/PIL/ImageFont.html#load"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#PIL.ImageFont.load" title="Permalink to this definition">¶</a></dt>
<dd><p>Load a font file.  This function loads a font object from the given
bitmap font file, and returns the corresponding font object.</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"><strong>filename</strong> – Name of font file.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A font object.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><strong>IOError</strong> – If the file could not be read.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="PIL.ImageFont.load_path">
<code class="descclassname">PIL.ImageFont.</code><code class="descname">load_path</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/PIL/ImageFont.html#load_path"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#PIL.ImageFont.load_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Load font file. Same as <a class="reference internal" href="#PIL.ImageFont.load" title="PIL.ImageFont.load"><code class="xref py py-func docutils literal notranslate"><span class="pre">load()</span></code></a>, but searches for a
bitmap font along the Python path.</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"><strong>filename</strong> – Name of font file.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A font object.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><strong>IOError</strong> – If the file could not be read.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="PIL.ImageFont.truetype">
<code class="descclassname">PIL.ImageFont.</code><code class="descname">truetype</code><span class="sig-paren">(</span><em>font=None</em>, <em>size=10</em>, <em>index=0</em>, <em>encoding=''</em>, <em>layout_engine=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/PIL/ImageFont.html#truetype"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#PIL.ImageFont.truetype" title="Permalink to this definition">¶</a></dt>
<dd><p>Load a TrueType or OpenType font from a file or file-like object,
and create a font object.
This function loads a font object from the given file or file-like
object, and creates a font object for a font of the given size.</p>
<p>This function requires the _imagingft service.</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>font</strong> – A filename or file-like object containing a TrueType font.
Under Windows, if the file is not found in this filename,
the loader also looks in Windows <code class="file docutils literal notranslate"><span class="pre">fonts/</span></code> directory.</li>
<li><strong>size</strong> – The requested size, in points.</li>
<li><strong>index</strong> – Which font face to load (default is first available face).</li>
<li><strong>encoding</strong> – Which font encoding to use (default is Unicode). Common
encodings are “unic” (Unicode), “symb” (Microsoft
Symbol), “ADOB” (Adobe Standard), “ADBE” (Adobe Expert),
and “armn” (Apple Roman). See the FreeType documentation
for more information.</li>
<li><strong>layout_engine</strong> – Which layout engine to use, if available:
<cite>ImageFont.LAYOUT_BASIC</cite> or <cite>ImageFont.LAYOUT_RAQM</cite>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A font object.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><strong>IOError</strong> – If the file could not be read.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="PIL.ImageFont.load_default">
<code class="descclassname">PIL.ImageFont.</code><code class="descname">load_default</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/PIL/ImageFont.html#load_default"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#PIL.ImageFont.load_default" title="Permalink to this definition">¶</a></dt>
<dd><p>Load a “better than nothing” default font.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.1.4.</span></p>
</div>
<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">A font object.</td>
</tr>
</tbody>
</table>
</dd></dl>

</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">
<code class="descclassname">PIL.ImageFont.ImageFont.</code><code class="descname">getsize</code><span class="sig-paren">(</span><em>text</em><span class="sig-paren">)</span><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">
<code class="descclassname">PIL.ImageFont.ImageFont.</code><code class="descname">getmask</code><span class="sig-paren">(</span><em>text</em>, <em>mode=''</em>, <em>direction=None</em>, <em>features=[]</em><span class="sig-paren">)</span><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> – Text to render.</li>
<li><strong>mode</strong> – <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>
<li><strong>direction</strong> – <p>Direction of the text. It can be ‘rtl’ (right to
left), ‘ltr’ (left to right) or ‘ttb’ (top to bottom).
Requires libraqm.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 4.2.0.</span></p>
</div>
</li>
<li><strong>features</strong> – <p>A list of OpenType font features to be used during text
layout. This is usually used to turn on optional
font features that are not enabled by default,
for example ‘dlig’ or ‘ss01’, but can be also
used to turn off default font features for
example ‘-liga’ to disable ligatures or ‘-kern’
to disable kerning.  To get all supported
features, see
<a class="reference external" href="https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist">https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist</a>
Requires libraqm.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 4.2.0.</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
<code class="xref py py-mod docutils literal notranslate"><span class="pre">PIL.Image.core</span></code> interface module.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="ImageGrab.html" class="btn btn-neutral float-right" title="ImageGrab Module (macOS and Windows only)" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="ImageFilter.html" class="btn btn-neutral float-left" title="ImageFilter Module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 1995-2011 Fredrik Lundh, 2010-2018 Alex Clark and Contributors

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>