Skip to content

Preview how plain text would wrap were it rendered with a given ttf font for a given line width

License

Notifications You must be signed in to change notification settings

Grollicus/pyttfwrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wrapper around ttf_word_wrap and owned_ttf_parser for use in Python.

Usage

# ./.env/bin/ipython
In [1]: import pyttfwrap

In [2]: wrapper = pyttfwrap.TextWrapper('/usr/share/fonts/TTF/iosevka-regular.ttf', '0')

In [3]: wrapper.wrap(42, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi utaliquip ex ea commodo consequat.')

Out[3]:
['Lorem ipsum dolor sit amet, consectetur',
 'adipiscing elit, sed do eiusmod tempor',
 'incididunt ut labore et dolore magna',
 'aliqua. Ut enim ad minim veniam, quis',
 'nostrud exercitation ullamco laboris nisi',
 'ut aliquip ex ea commodo consequat.']

Building

$ python -m venv .venv
$ ./.venv/bin/pip install maturin
$ ./.venv/bin/maturin build --release

About

Preview how plain text would wrap were it rendered with a given ttf font for a given line width

Topics

Resources

License

Stars

Watchers

Forks

Languages