summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Ftkinter.font.html
blob: 6b0f35acc3280b8d8c33ddc1fe838ac46e13aa57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 <span id="tkinter-font-tkinter-font-wrapper"></span><h1>tkinter.font — Tkinter font wrapper</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/tkinter/font.py">Lib/tkinter/font.py</a></p>  <p>The <a class="reference internal" href="#module-tkinter.font" title="tkinter.font: Tkinter font-wrapping class (Tk)"><code>tkinter.font</code></a> module provides the <a class="reference internal" href="#tkinter.font.Font" title="tkinter.font.Font"><code>Font</code></a> class for creating and using named fonts.</p> <p>The different font weights and slants are:</p> <dl class="py data"> <dt class="sig sig-object py" id="tkinter.font.NORMAL">
<code>tkinter.font.NORMAL</code> </dt> <dt class="sig sig-object py" id="tkinter.font.BOLD">
<code>tkinter.font.BOLD</code> </dt> <dt class="sig sig-object py" id="tkinter.font.ITALIC">
<code>tkinter.font.ITALIC</code> </dt> <dt class="sig sig-object py" id="tkinter.font.ROMAN">
<code>tkinter.font.ROMAN</code> </dt> <dd></dd>
</dl> <dl class="py class"> <dt class="sig sig-object py" id="tkinter.font.Font">
<code>class tkinter.font.Font(root=None, font=None, name=None, exists=False, **options)</code> </dt> <dd>
<p>The <a class="reference internal" href="#tkinter.font.Font" title="tkinter.font.Font"><code>Font</code></a> class represents a named font. <em>Font</em> instances are given unique names and can be specified by their family, size, and style configuration. Named fonts are Tk’s method of creating and identifying fonts as a single object, rather than specifying a font by its attributes with each occurrence.</p>  <p>arguments:</p>    <p>additional keyword options (ignored if <em>font</em> is specified):</p>     <dl class="py method"> <dt class="sig sig-object py" id="tkinter.font.Font.actual">
<code>actual(option=None, displayof=None)</code> </dt> <dd>
<p>Return the attributes of the font.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.font.Font.cget">
<code>cget(option)</code> </dt> <dd>
<p>Retrieve an attribute of the font.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.font.Font.config">
<code>config(**options)</code> </dt> <dd>
<p>Modify attributes of the font.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.font.Font.copy">
<code>copy()</code> </dt> <dd>
<p>Return new instance of the current font.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.font.Font.measure">
<code>measure(text, displayof=None)</code> </dt> <dd>
<p>Return amount of space the text would occupy on the specified display when formatted in the current font. If no display is specified then the main application window is assumed.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.font.Font.metrics">
<code>metrics(*options, **kw)</code> </dt> <dd>
<p>Return font-specific data. Options include:</p> <dl class="simple"> <dt>
<em>ascent</em> - distance between baseline and highest point that a</dt>
<dd>
<p>character of the font can occupy</p> </dd> <dt>
<em>descent</em> - distance between baseline and lowest point that a</dt>
<dd>
<p>character of the font can occupy</p> </dd> <dt>
<em>linespace</em> - minimum vertical separation necessary between any two</dt>
<dd>
<p>characters of the font that ensures no vertical overlap between lines.</p> </dd> </dl> <p><em>fixed</em> - 1 if font is fixed-width else 0</p> </dd>
</dl> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="tkinter.font.families">
<code>tkinter.font.families(root=None, displayof=None)</code> </dt> <dd>
<p>Return the different font families.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="tkinter.font.names">
<code>tkinter.font.names(root=None)</code> </dt> <dd>
<p>Return the names of defined fonts.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="tkinter.font.nametofont">
<code>tkinter.font.nametofont(name, root=None)</code> </dt> <dd>
<p>Return a <a class="reference internal" href="#tkinter.font.Font" title="tkinter.font.Font"><code>Font</code></a> representation of a tk named font.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.10: </span>The <em>root</em> parameter was added.</p> </div> </dd>
</dl> <div class="_attribution">
  <p class="_attribution-p">
    &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
    <a href="https://docs.python.org/3.12/library/tkinter.font.html" class="_attribution-link">https://docs.python.org/3.12/library/tkinter.font.html</a>
  </p>
</div>