Popular recipes tagged "font"http://code.activestate.com/recipes/tags/font/popular/2017-04-10T01:07:11-07:00ActiveState Code Recipestkinter custom fonts (Python)
2017-04-10T01:07:11-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580778-tkinter-custom-fonts/
<p style="color: grey">
Python
recipe 580778
by <a href="/recipes/users/4189907/">Miguel Martínez López</a>
(<a href="/recipes/tags/font/">font</a>, <a href="/recipes/tags/tkinter/">tkinter</a>).
Revision 2.
</p>
<p>One Windows the best solution is to use the trick explained here:</p>
<p><a href="http://stackoverflow.com/a/30631309" rel="nofollow">http://stackoverflow.com/a/30631309</a></p>
<p>Another possibility is to use PIL. creating an image with the text and a specific font.</p>
<p>I provide 2 classes: <em>CustomFont_Label</em> and <em>CustomFont_Message</em>.</p>
<p><em>CustomFont_Message</em> displays multilines but requires the <em>width</em> parameter.</p>
Word Wrap for Proportional Fonts (Python)
2011-11-11T21:29:21-08:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/577946-word-wrap-for-proportional-fonts/
<p style="color: grey">
Python
recipe 577946
by <a href="/recipes/users/4171845/">Michael Fogleman</a>
(<a href="/recipes/tags/fixed/">fixed</a>, <a href="/recipes/tags/font/">font</a>, <a href="/recipes/tags/proportional/">proportional</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/word_wrap/">word_wrap</a>, <a href="/recipes/tags/wrap/">wrap</a>).
</p>
<p>Word wrap function / algorithm for wrapping text using proportional (versus
fixed-width) fonts.</p>
<p><code>text</code>: a string of text to wrap
<code>width</code>: the width in pixels to wrap to
<code>extent_func</code>: a function that returns a (w, h) tuple given any string, to
specify the size (text extent) of the string when rendered.
the algorithm only uses the width.</p>
<p>Returns a list of strings, one for each line after wrapping.</p>