[issue12485] Improvement of textwrap module
New submission from Tyler Romeo : Python's textwrap module can be helpful at times, but personally I think there are a couple of things that could be added. First, when it comes to text wrapping, usually you're not dealing with a monospace font where each letter is the same size. If you're working with the Python Imaging Library for example, there is a function that you pass the text to in order to determine how wide (or tall) a font is. Therefore, it would be useful to have a parameter where the user can pass a function that gives a custom width for a set of text. The default for this parameter, of course, would be len. Also, this module uses a rough and efficient algorithm for wrapping text, but the results are not always aesthetically pleasing (one word hanging off on a line). Sometimes the user may want something that is wrapped more beautifully, so to say, such as is found in TeX. So there should also be a beautiful option that goes back and redistributes the text so that it is more aesthetically pleasing. This isn't exactly that important (minor improvements to a module that is probably not used much), but I figured I'd get it out there as I run into the problem all the time when trying to wrap text to be put in images of a set size. -- components: Extension Modules files: textwrap.py-improvement.diff keywords: patch messages: 139731 nosy: parent5446 priority: normal severity: normal status: open title: Improvement of textwrap module type: feature request versions: Python 2.7 Added file: http://bugs.python.org/file22561/textwrap.py-improvement.diff ___ Python tracker <http://bugs.python.org/issue12485> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12485] textwrap.wrap: add control for custom length and orphans
Tyler Romeo added the comment: Nah, they're both unrelated. I'll separate the changes and remake the patches. (I'll keep this entry for the beautification part.) -- ___ Python tracker <http://bugs.python.org/issue12485> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12485] textwrap.wrap: add control for custom length and orphans
Tyler Romeo added the comment: OK, so here is the patch for just the new algorithm. -- Added file: http://bugs.python.org/file22573/textwrap.py-new-algorithm-2011-07-04_22-45-53_r71219+.diff ___ Python tracker <http://bugs.python.org/issue12485> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12499] textwrap.wrap: add control for fonts with different character widths
New submission from Tyler Romeo : Originally from http://bugs.python.org/issue12485 but separated. The textwrap modules uses len to determine the length of text, but in many (if not most) fonts, the width of a character differs depending on the letter, so it would be useful to have an option to pass a custom function that returns the width of a given string of text. -- components: Library (Lib) files: textwrap.py-widthfunction-2011-07-04_22-57-49_r71219+.diff keywords: patch messages: 139828 nosy: parent5446 priority: normal severity: normal status: open title: textwrap.wrap: add control for fonts with different character widths type: feature request versions: Python 3.3 Added file: http://bugs.python.org/file22574/textwrap.py-widthfunction-2011-07-04_22-57-49_r71219+.diff ___ Python tracker <http://bugs.python.org/issue12499> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12485] textwrap.wrap: add control for custom length and orphans
Changes by Tyler Romeo : Removed file: http://bugs.python.org/file22561/textwrap.py-improvement.diff ___ Python tracker <http://bugs.python.org/issue12485> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12499] textwrap.wrap: add control for fonts with different character widths
Tyler Romeo added the comment: Normally I would have just added it as a function to be overloaded, but because of the nature of the textwrap.wrap function (all kwargs are passed to the TextWrapper constructor) I thought it made a lot more sense to keep it as an argument to __init__. -- ___ Python tracker <http://bugs.python.org/issue12499> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12485] textwrap.wrap: new argument for more pleasing output
Tyler Romeo added the comment: OK, sorry to get back so late, but here's the updated patch without xrange. I saw the version change but forgot that I used xrange in the function (old habits I guess). -- Added file: http://bugs.python.org/file22626/textwrap.py-beautiful-2011-07-11_22-01-31_r71296+.diff ___ Python tracker <http://bugs.python.org/issue12485> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12485] textwrap.wrap: new argument for more pleasing output
Changes by Tyler Romeo : Removed file: http://bugs.python.org/file22573/textwrap.py-new-algorithm-2011-07-04_22-45-53_r71219+.diff ___ Python tracker <http://bugs.python.org/issue12485> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com