All Projects → LingDong- → P5 Hershey Js

LingDong- / P5 Hershey Js

Licence: mit
p5.js Hershey Vector Font Library

Programming Languages

javascript
184084 projects - #8 most used programming language
p5js
31 projects

Projects that are alternatives of or similar to P5 Hershey Js

Bellota-Font
An ornamented Sans Serif font family
Stars: ✭ 21 (-8.7%)
Mutual labels:  font, typography
Commissioner
Commissioner is a variable and static sans typeface.
Stars: ✭ 147 (+539.13%)
Mutual labels:  font, typography
ttf2hershey
Convert True Type Fonts (.ttf) to Hershey vector fonts
Stars: ✭ 29 (+26.09%)
Mutual labels:  font, typography
Urbanist
Urbanist is a low-contrast, geometric sans-serif inspired by Modernist design and typography.
Stars: ✭ 374 (+1526.09%)
Mutual labels:  font, typography
Prototypo
Create your own font in a few clicks
Stars: ✭ 388 (+1586.96%)
Mutual labels:  font, typography
fdiff
An OpenType table diff tool for fonts. Based on the fontTools TTX format.
Stars: ✭ 33 (+43.48%)
Mutual labels:  font, typography
Epilogue
2 axes/Variable/18 styles/Sans
Stars: ✭ 104 (+352.17%)
Mutual labels:  font, typography
Typesetter
Android tool to help display changes to text positioning.
Stars: ✭ 149 (+547.83%)
Mutual labels:  font, typography
Otfcc
Optimized OpenType builder and inspector.
Stars: ✭ 348 (+1413.04%)
Mutual labels:  font, typography
Web Typography Glossary
Webタイポグラフィの基礎知識と実践
Stars: ✭ 279 (+1113.04%)
Mutual labels:  font, typography
Typography
C# Font Reader (TrueType / OpenType / OpenFont / CFF / woff / woff2) , Glyphs Layout and Rendering
Stars: ✭ 246 (+969.57%)
Mutual labels:  font, typography
Juliamono
repository for JuliaMono, a monospaced font with reasonable Unicode support.
Stars: ✭ 625 (+2617.39%)
Mutual labels:  font, typography
Typefaces
NPM packages for Open Source typefaces
Stars: ✭ 2,581 (+11121.74%)
Mutual labels:  font, typography
Gluten
2 Axes/Variable/Super Soft/Display
Stars: ✭ 28 (+21.74%)
Mutual labels:  font, typography
Scsscale
Typographic modular scale starter based on body's font-size built on SCSS.
Stars: ✭ 206 (+795.65%)
Mutual labels:  font, typography
typeface-minecraft
Minecraft typeface and colors
Stars: ✭ 20 (-13.04%)
Mutual labels:  font, typography
3270font
A 3270 font in a modern format
Stars: ✭ 1,197 (+5104.35%)
Mutual labels:  font, typography
Plusjakartasans
+Jakarta Sans is a open-source fonts. Designed for Jakarta "City of collaboration" program in 2020.
Stars: ✭ 136 (+491.3%)
Mutual labels:  font, typography
baseline
New method for creating leading on the web
Stars: ✭ 31 (+34.78%)
Mutual labels:  font, typography
Qiji Font
齊伋體 - typeface from Ming Dynasty woodblock printed books
Stars: ✭ 536 (+2230.43%)
Mutual labels:  font, typography

p5.js Hershey Vector Font Library. (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 p5.js library renders the Hershey fonts in the browser. It can parse user-provided Hershey fonts along with custom character mapping.

Supported Character Sets

Roman Gothic Greek Other
COMPLEX GOTHIC_ENGLISH_TRIPLEX GREEK_COMPLEX ITALIC_COMPLEX
COMPLEX_SMALL GOTHIC_GERMAN_TRIPLEX GREEK_COMPLEX_SMALL ITALIC_COMPLEX_SMALL
DUPLEX GOTHIC_ITALIAN_TRIPLEX GREEK_PLAIN ITALIC_TRIPLEX
PLAIN GREEK_SIMPLEX SCRIPT_COMPLEX
SIMPLEX SCRIPT_SIMPLEX
TRIPLEX CYRILLIC_COMPLEX

Usage

Minimal Example

In HTML, include the library as well as the data file.

<script src="p5.hershey.js"></script>  
<script src="p5.hershey.data.js"></script>  

And in the p5 sketch javascript, call P5.hershey.putText

push();
translate(100,100);
noFill();
stroke(0);
strokeWeight(1);
P5.hershey.putText("Hello World!");
pop();

Advanced

P5.hershey.putText("Hello World!",{
	cmap:  FONT_HERSHEY.GOTHIC_GERMAN_TRIPLEX,
	align: "center",
	noise: 0.5,
});
  • cmap specifies the character mapping to use, see Supported Character Sets for details.
  • align can be one of left, center or right.
  • noise can be used to add special effects to the vertices. noise can be either of the following datatypes:
    • if noise is a number, a default randomGaussian filter is applied to give a jiggly/nervous effect using noise as the standard deviation.
    • if noise is an object of the form {x: (x,y)=>(x_offset), y: (x,y)=>(y_offset)}, noise.x and noise.y will be called on each vertex, and the return value is used as the offset for the respective axis.

Custom Fonts

Users can also provide their own Hershey fonts and mappings. To parse a correctly formatted Hershey font as a string, use:

var font_data = P5.hershey.parseFontString("   49 12LXRMRV RNOOPOSQTSTUSUPVO");

A mapping from unicode entry point to the index used by the hershey font is also required. If the indices are identical, this can be as simple as:

var cmap = (x)=>(x);

Say you have a more complicated mapping, where characters A,B,C,D will be mapped to indices 2,4,6,8 in the Hershey font:

var cmap = (x)=>([2,4,6,8][x-65]);

Finally feed the font and the mapping to P5.hershey.putText:

P5.hershey.putText("Hello World!",{
	font:  font_data,
	cmap:  cmap,
});

Other Tools

  • P5.hershey.estimateTextWidth(text, args) returns the width in pixels of the text if it is to be drawn with arguments args.
  • P5.hershey.validateFont(font_data) returns an Array containing indices of all the invalid glyphs in a font object.

Examples

  • Live Demo, see index.html for details.
  • ttf2hershey, a tool for converting True Type Fonts to Hershey fonts.

Preview

References

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