Determines the appropriate font size for given text and constraints
Project description
Determines the appropriate font size for given text and constraints
pip install getbestfontsize
Tested against Windows 10 / Python 3.10 / Anaconda
Automated Font Size Calculation:
The module automates the process of determining the appropriate font size for given text and constraints. This saves users from manually testing different font sizes and ensures a faster and more accurate selection.
Flexibility with Constraints:
Users can specify maximum width and height constraints for the text, allowing them to control how the text fits within the given space.
Optimal Text Rendering:
By providing the best-fitted font size, this module helps ensure that text appears legible and visually appealing, no matter the context or screen size.
Efficient Caching:
The lru_cache decorator helps optimize the loading of fonts by caching previously loaded fonts, reducing the need to reload the same font multiple times during the same execution.
Dynamic and Adaptive:
The module can adapt to different font files and text content, making it suitable for a wide range of fonts and text strings.
HashList
# Example usage:
from getbestfontsize import calculate_text_size
text = "Hello, World!"
fs = calculate_text_size(
text,
font_path=r"C:\Users\hansc\Downloads\CALIBRIB.TTF",
max_width=None,
max_height=100,
startfont=10,
)
print(fs)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for getbestfontsize-0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dc10066457b3ad1df09bc562825176831645e6328cfa35b5faf6ed43ad75e43 |
|
MD5 | a55b7bccb753f2bb9b13ccd2d652bf39 |
|
BLAKE2b-256 | 2342df00d542d06d3f51fc343326ffa4a587f275cdc880a9727ed5bcee2fad0d |