All Projects → LingDong- → ttf2hershey

LingDong- / ttf2hershey

Licence: MIT license
Convert True Type Fonts (.ttf) to Hershey vector fonts

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to ttf2hershey

Chinese Hershey Font
Convert Chinese Characters to Single-Line Fonts using Computer Vision
Stars: ✭ 70 (+141.38%)
Mutual labels:  font, convert, typography
Php Font Lib
A library to read, parse, export and make subsets of different types of font files.
Stars: ✭ 1,530 (+5175.86%)
Mutual labels:  font, truetype
Bellota-Font
An ornamented Sans Serif font family
Stars: ✭ 21 (-27.59%)
Mutual labels:  font, typography
Scsscale
Typographic modular scale starter based on body's font-size built on SCSS.
Stars: ✭ 206 (+610.34%)
Mutual labels:  font, typography
Linearicons
Linearicons is the highest quality set of line icons, matching with minimalist UI designs in iOS.
Stars: ✭ 64 (+120.69%)
Mutual labels:  font, typography
3270font
A 3270 font in a modern format
Stars: ✭ 1,197 (+4027.59%)
Mutual labels:  font, typography
Typesetter
Android tool to help display changes to text positioning.
Stars: ✭ 149 (+413.79%)
Mutual labels:  font, typography
Juliamono
repository for JuliaMono, a monospaced font with reasonable Unicode support.
Stars: ✭ 625 (+2055.17%)
Mutual labels:  font, typography
Typography
C# Font Reader (TrueType / OpenType / OpenFont / CFF / woff / woff2) , Glyphs Layout and Rendering
Stars: ✭ 246 (+748.28%)
Mutual labels:  font, typography
ansi-to-svg
😹 convert ANSI Escaped CLI strings to SVGs
Stars: ✭ 18 (-37.93%)
Mutual labels:  font, convert
Urbanist
Urbanist is a low-contrast, geometric sans-serif inspired by Modernist design and typography.
Stars: ✭ 374 (+1189.66%)
Mutual labels:  font, typography
Google Type
Collaborative typography project using select passages from Aesop's Fables set to Google Fonts
Stars: ✭ 971 (+3248.28%)
Mutual labels:  font, typography
P5 Hershey Js
p5.js Hershey Vector Font Library
Stars: ✭ 23 (-20.69%)
Mutual labels:  font, typography
Rrpl
Describing Chinese Characters with Recursive Radical Packing Language (RRPL)
Stars: ✭ 649 (+2137.93%)
Mutual labels:  font, typography
InupiaqNumbers
Font for displaying Inupiaq Numerals
Stars: ✭ 27 (-6.9%)
Mutual labels:  font, truetype
Plusjakartasans
+Jakarta Sans is a open-source fonts. Designed for Jakarta "City of collaboration" program in 2020.
Stars: ✭ 136 (+368.97%)
Mutual labels:  font, typography
Prototypo
Create your own font in a few clicks
Stars: ✭ 388 (+1237.93%)
Mutual labels:  font, typography
Qiji Font
齊伋體 - typeface from Ming Dynasty woodblock printed books
Stars: ✭ 536 (+1748.28%)
Mutual labels:  font, typography
Typefaces
NPM packages for Open Source typefaces
Stars: ✭ 2,581 (+8800%)
Mutual labels:  font, typography
fdiff
An OpenType table diff tool for fonts. Based on the fontTools TTX format.
Stars: ✭ 33 (+13.79%)
Mutual labels:  font, typography

ttf2hershey

Convert True Type Fonts (.ttf) to Hershey vector fonts (Live Demo)

The Hershey fonts are a collection of vector fonts developed c. 1967 by Dr. Allen Vincent Hershey at the Naval Weapons Laboratory, originally designed to be rendered using vectors on early cathode ray tube displays. The fonts are publicly available and have few usage restrictions. Vector fonts are easily scaled and rotated in two or three dimensions; consequently the Hershey fonts have been widely used in computer graphics, computer-aided design programs, and more recently also in computer-aided manufacturing applications like laser engraving. (Wikipedia)

This tool converts the common True Type Font (.ttf) files to Hershey font format. A few pre-converted samples can be found in the ./hershey folder.

Dependencies

  • Python 2

Usage

Quick Start

First cd into the directory, then

python ttf2hershey.py path/to/font.ttf > path/to/output.hf.txt

Done! you can find the generated hershey font at path/to/output.hf.txt.

Use as Module

from ttf2hershey import *
output_str = tohershey("ABCDEFG0123",font_path="font.ttf",kern=2)
print output_str
  • First argument: the set of characters to be encoded. This can be the 95 printable ASCII characters, or other unicode characters as you like, as long as the font has them.
  • font_path: this is the path to your ttf file to be converted
  • kern: this is the amount of extra spacing to the left and right of a character. At kern=0, all characters are squeezed together. However the more kern you put, the less accurate the vertices are, since there're only 95 possible values for a coordinate in a Hershey font.

Character Mapping

The original Hershey fonts are indexed differently from unicode, so there're tables for mapping characters to Hershey font's special index. In this implementation however, the index is exactly the same as unicode entry point, so no mapping is required.

Parsing & Rendering

An example Hershey font parser & renderer in javascript and p5.js can be found at LingDong-/p5-hershey-js, which is used to drive this Live Demo.

Known Issues

  • There're multiple ways to encode cmap (which maps unicode characters to glyph indices) in a TTF file. Only parsing of the most common is implemented (PlatformID = 0, Format = 4).

Resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].