Popular recipes tagged "fixed"http://code.activestate.com/recipes/tags/fixed/2011-11-11T21:29:21-08:00ActiveState Code RecipesWord 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>