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)
Metadata
Release files for getbestfontsize 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| getbestfontsize-0.10.tar.gz | 22.8 kB | Without provenance | Details for getbestfontsize-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| getbestfontsize-0.10-py3-none-any.whl | Python 3 | none | any | Details for getbestfontsize-0.10-py3-none-any.whl |
Total release size: 46.3 kB
Release files / getbestfontsize-0.10.tar.gz
| Download URL | getbestfontsize-0.10.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7866a0ef3c2c5bc18e78b8a9f9b996cd168a6051152dff0670139c0cd2124cb
|
|
BLAKE2b-256 checksum How to use checksums |
c01b268c2016ecb0d4237f35b087450d0ac0fcb86fbda22c14c7c9201b301be2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / getbestfontsize-0.10-py3-none-any.whl
| Download URL | getbestfontsize-0.10-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7dc10066457b3ad1df09bc562825176831645e6328cfa35b5faf6ed43ad75e43
|
|
BLAKE2b-256 checksum How to use checksums |
2342df00d542d06d3f51fc343326ffa4a587f275cdc880a9727ed5bcee2fad0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for getbestfontsize 0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.