Metadata-Version: 2.4
Name: ttf2json
Version: 0.0.1
Summary: A Python library for converting .ttf files to JSON for use with Three.js, supporting both CLI and programmatic usage
Author-email: maslke <maslke@outlook.com>
License: MIT License
        
        Copyright (c) 2025 maslke
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# ttf2json
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PyPI version](https://badge.fury.io/py/ttf2json.svg)](https://badge.fury.io/py/ttf2json)
[![Tests](https://github.com/maslke/ttf2json/actions/workflows/tests.yml/badge.svg)](https://github.com/maslke/ttf2json/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/maslke/ttf2json/graph/badge.svg?token=Q3X8GM5ZWX)](https://codecov.io/gh/maslke/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:

```shell
pip install ttf2json
```

## How to use

### use via command line

1. Provide the font file path "ttf_file" and the output json file path "json_file". 

   ```shell
   python3 -m ttf2json --ttf_file ./msyh.ttf --json_file ./msyh.json
   ```

2. The "words" parameter can be optionally provided to convert only the necessary text and simplify the output json file. 

   ```shell
   python3 -m ttf2json --ttf_file ./msyh.ttf --json_file ./msyh.json --words abcdefg
   ```

3. 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.

   ```shell
   python3 -m ttf2json --ttf_file ./msyh.ttf --json_file ./msyh.json --words_from_file ./words.txt
   ```

### imported as moudle


```python
from ttf2json import TTF2JSON

ttf2json = TTF2JSON("/path/to/ttf/file")
ttf2json.convert2json("words")
ttf2json.dump2json("/path/to/json/file")

```
   

