A Python library for converting .ttf files to JSON for use with Three.js, supporting both CLI and programmatic usage
Project description
ttf2json
This Python library allows you to convert .ttf font files into JSON format compatible with Three.js. It can be used via the command line or imported as a module in your Python code.
Installation
You can install the package using pip:
pip install ttf2json
How to use
use via command line
-
Provide the font file path "ttf_file" and the output json file path "json_file".
python3 -m ttf2json --ttf_file ./msyh.ttf --json_file ./msyh.json
-
The "words" parameter can be optionally provided to convert only the necessary text and simplify the output json file.
python3 -m ttf2json --ttf_file ./msyh.ttf --json_file ./msyh.json --words abcdefg
-
The "words_from_file" parameter can be optionally provided to obtain the text to be converted from a file. When both the "words" parameter and the "words_from_file" parameter are provided, the "words_from_file" parameter will be ignored.
python3 -m ttf2json --ttf_file ./msyh.ttf --json_file ./msyh.json --words_from_file ./words.txt
imported as moudle
from ttf2json import TTF2JSON
ttf2json = TTF2JSON("/path/to/ttf/file")
ttf2json.convert2json("words")
ttf2json.dump2json("/path/to/json/file")
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ttf2json-0.0.1.tar.gz.
File metadata
- Download URL: ttf2json-0.0.1.tar.gz
- Upload date:
- Size: 553.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a1c3fe5aecea3683c7639e5487bfffd081c50442fd9e34eabcafbb082492684
|
|
| MD5 |
fd898763af5c2487419c544ff20f2223
|
|
| BLAKE2b-256 |
2077172a07ed1093016501550a4f8e4c94789af7dc3d80a7b00f818a63eb7aa5
|
File details
Details for the file ttf2json-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ttf2json-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7668691280389de4b472c73c3c7025cde749bf009564723f4f003f75a7a79a3
|
|
| MD5 |
f2bc5701ea3df9b338b13e85402f1bec
|
|
| BLAKE2b-256 |
32486b5168b4b2d7a9d2b79371a2327ee5937684f6c81411d6a71ae804c831ab
|