8000 GitHub - bO-05/handwritten · GitHub
[go: up one dir, main page]

Skip to content

About

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handwritten — Custom Handwriting Font

A font created from a scanned handwriting sample, built with a fully automated Python pipeline.

90 glyphs · 3 formats (TTF, WOFF, WOFF2) · 61 kerning pairs · Auto-hinted

Original Handwriting

Source handwriting sample


Preview

Uppercase (A–Z) & Lowercase (a–z)

Uppercase characters and title rendering

Numerals (0–9) & Punctuation

Numerals and punctuation symbols

Size Scale — 72px down to 16px

Size scale with pangrams

Kerning & Paragraph

Kerning and paragraph rendering

Font Testing 1

Font testing 1

Font Testing 2

Font testing 2

Font Testing 3

Font testing 3


Output

File Size Format
Handwritten.ttf 29.0 KB TrueType (desktop install)
Handwritten.woff 13.9 KB Web Open Font Format
Handwritten.woff2 11.5 KB WOFF2 (best web compression)

Font files are in the output/ directory.

Glyph Coverage

  • Uppercase: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  • Lowercase: a b c d e f g h i j k l m n o p q r s t u v w x y z
  • Numerals: 0 1 2 3 4 5 6 7 8 9
  • Symbols: ! @ # $ % ^ & * ? / \ < > + =
  • Punctuation: . , ' " - — ( ) [ ] : ; _

How It Works

The pipeline (create_font.py) converts a scanned handwriting sheet into production font files in 6 phases:

  1. Image Preprocessing — Adaptive thresholding, border line removal, morphological noise cleanup
  2. Character Segmentation — Projection-profile row detection, contour-based character isolation with smart edge-artifact trimming
  3. Vectorization — OpenCV contour detection with polygon approximation (approxPolyDP) for smooth outlines
  4. Metrics Engineering — Cap height and x-height measured from actual glyph data; UPM-normalized spacing
  5. Font Assembly — fontTools FontBuilder with 61 kerning pairs, auto-hinting via ttfautohint, multi-format export
  6. Specimen Page — Dark-themed HTML page with character grids, size scale, kerning demo, and live editable text

Typographic Heuristics

Several custom fixes apply intelligent typographic rendering during vectorization:

  • Dot Retention Algorithm: A localized X-overlap bounds intersection isolates small dots (for i, j, ?, !) matching directly to their parent character logic, filtering out any background grid-paper noise.
  • Robust Local Baseline Anchoring: Hard-an 819B chors each individual alphanumeric character's lowest Y-bound exactly to Y=0 (unless detected as descending sequences). This inherently corrects varying upward or downward baseline slants across the handwritten row, completely preventing accidental cross-screen descender mappings and "floaters".
  • Precision Symbol Mapping: Encodes custom horizontal sequence matching designed carefully for handwriting layouts, fixing index offsets of ( ) [ ] : ; —.

Usage

Web (CSS)

@font-face {
    font-family: 'Handwritten';
    src: url('Handwritten.woff2') format('woff2'),
         url('Handwritten.woff') format('woff'),
         url('Handwritten.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body {
    font-family: 'Handwritten', cursive;
}

Desktop

Install Handwritten.ttf by double-clicking it on Windows or Mac.

Specimen Preview

python -m http.server 8080 --directory output
# Then open http://localhost:8080

Running the Pipeline

Prerequisites

pip install opencv-python-headless Pillow numpy fonttools brotli ttfautohint-py

Generate the Font

python create_font.py

This reads docs/6151945549901401701.jpg and outputs the font files + specimen page to output/.


Tech Stack

Tool Purpose
OpenCV Image preprocessing, contour detection, vectorization
fontTools Font assembly (TTF/WOFF/WOFF2), metrics, kerning tables
ttfautohint Auto-hinting for crisp rendering at small sizes
brotli WOFF2 compression
Pillow / NumPy Image manipulation utilities

License

Free for personal and commercial use.

About

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0