Handwrite
repository·dev·Indexed 19 days ago
https://github.com/yashlamba/handwriteA tool that converts handwriting samples into custom .ttf font files, allowing users to type in their own handwriting style using standard word processors. It includes a CLI for automating the pipeline from sample sheets to fonts via PNG and SVG conversion, and requires fontforge and Potrace as system dependencies.
What's inside handwrite
- Handwrite is a tool that generates a custom font based on a sample of your handwriting. This allows you to type assignments or documents that appear to be handwritten, making them compatible with standard text editors and word processors like Microsoft Word and LibreOffice Writer. It is designed to make handwritten assignments more efficient and is particularly helpful for individuals with dysgraphia.
Generate a font using the Handwrite CLI
devOnce you have your
.jpgsample, you can generate a.ttffont file using thehandwritecommand.Prerequisites You must have the following installed on your system:
handwritepotracefontforge
Basic Usage Run the command with the path to your image and the desired output directory:
handwrite [PATH TO IMAGE] [OUTPUT DIRECTORY]Advanced Usage
- Custom Configuration: Pass a custom JSON configuration file using the
--config [CONFIG FILE]flag. - Argument Precedence: If you provide metadata (such as filename, family, or style) directly as CLI arguments, these will override any values found in the provided config file.
- Default Config: If no
--configargument is provided, the tool uses the default config file.
Output The generated font will be located at:
[OUTPUT DIRECTORY]/[OUTPUT FONT NAME].ttf.handwrite path/to/your_sample.jpg ./output_folder # Using a custom config file handwrite path/to/your_sample.jpg ./output_folder --config my_config.jsonHow to use Handwrite
devTo generate your custom handwriting font, you follow a simple process of filling out a form with your handwriting samples. Once the form is processed, Handwrite produces a font file that can be installed on your system and used in any application that supports custom fonts.Create a handwritten sample for font generation
devTo generate a font from your handwriting, you must first create a physical sample using the provided template:
- Print the sample form.
- Fill out the form manually using a pen.
- Scan the completed form using a scanner or a mobile scanning app (like Adobe Scan).
- Save the resulting scan as a
.jpgimage on your system.
Install Handwrite via pip
devInstall the
handwritepackage usingpip. Note that this package requires external system dependencies to function correctly.pip install handwriteInstall system dependencies for Handwrite
devBefore installing
handwrite, you must install the following system-level dependencies:- fontforge: Required for font manipulation.
- Potrace: Required for tracing bitmap images into vector graphics.
Ensure these are installed and available in your system's PATH before proceeding with the
pip install.Use the Handwrite CLI to generate a font from a sample sheet
devThe Handwrite CLI automates the pipeline of converting a handwriting sample sheet into a usable font file (.ttf). The process follows three stages: converting the sheet to PNGs, converting PNGs to SVGs, and finally converting SVGs to a TTF font.
By default, the CLI uses a temporary directory for intermediate files and a
default.jsonconfiguration file located in the package directory. You can specify a custom directory for intermediate files, a custom configuration file, and metadata for the resulting font (filename, family, and style).python -m handwrite.cli <input_path> <output_directory> [options] # Example: Generate a font named 'MyHand' with family 'MyHandwriting' python -m handwrite.cli sample_sheet.png ./output_font --filename MyHand.ttf --family MyHandwriting --style RegularUse SHEETtoPNG to convert sheets to PNG images
devThe
SHEETtoPNGfunction (located in thehandwrite.sheettopngmodule) is used to convert sheet data into PNG image files. This function is part of thehandwritelibrary's capabilities for generating handwriting-style images from structured input.from handwrite.sheettopng import SHEETtoPNG # Usage of SHEETtoPNG goes hereUse PNGtoSVG to convert PNG images to SVG
devThe
PNGtoSVGclass in thehandwrite.pngtosvgmodule provides functionality to convert PNG images into SVG format. This is likely used as part of a handwriting reconstruction or vectorization pipeline within thehandwritelibrary.from handwrite.pngtosvg import PNGtoSVG # Initialize the converter converter = PNGtoSVG() # Further usage depends on the specific implementation of the classView Handwrite CLI arguments
devTo see all available arguments and options for the
handwritecommand, use the help flag in your terminal.handwrite -hHandwrite CLI arguments and options reference
devThe Handwrite CLI accepts the following positional arguments and optional flags to control the font generation process.
Positional Arguments: input_path Path to sample sheet output_directory Directory Path to save font output Optional Arguments: --directory Generate additional files to this path (Temp by default) --config Use custom configuration file --filename Font File name --family Font Family name --style Font Style name