From f4b603f02dae8e909a98d572f3ad1ed2d3031bea Mon Sep 17 00:00:00 2001 From: nspackman Date: Mon, 10 Nov 2025 15:39:51 -0800 Subject: [PATCH] Update README.md --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a4524e..c1224a4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ -# ttf_to_binary_font +# Font to Binary Conversion Script +This script uses the following libraries: + +- **Pillow** (a fork of PIL): to load and manipulate the font image +- **numpy**: to convert glyph images to binary arrays + +## Script Functionality + +The script performs the following steps: + +1. Extracts the glyphs from the input TrueType font file using Pillow's `ImageFont` class. +2. Creates a binary representation of each glyph by converting it to an array and packing it into bytes using `struct.pack`. +3. Saves the binary font data to a file named after the input font file but with `_binary.bin` appended (e.g., `arial.ttf_binary.bin`). +4. Generates a `README.md` file describing the parameters used for generating the binary font and the output files produced. + +## Usage + +Run the script from the command line as follows: +```bash + python font_to_binary.py your_font_file.ttf +``` + +Replace `your_font_file.ttf` with the path to your TrueType font file (for example, `arial.ttf`). + +The script will generate both: + +- A binary font data file with `_binary.bin` appended to the input font's filename. +- A `README.md` file in the current working directory explaining the generated output and parameters used. \ No newline at end of file