- Notifications
You must be signed in to change notification settings - Fork3
grid-based system for designing simple symbols and fonts. including an example font. mainly intended for plotter drawings.
License
inconvergent/gridfont
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
grid-based system for designing simple symbols and fonts. including an examplefont. Mainly intended for plotter drawings.
The symbol descriptions look like this:
S4,9:DS6|S3DtRqS2eLpYou can use spaces to separate moves, so you can for instance write it like this:
S4,9: DS6| S3 DtRq S2 eLpThe first section (left of:) is theinfo section. Which currently containsthe size of the grid (asintegers). Here the width is4 and the height is9. That is, there are4 and9 grid points in the two directions. Thatmeans the width of the symbol will be3 and8.
In time this section might contain other things. Such as a translate command.(this might be useful if you are only drawing within a certain section of thegrid.)
The next section is one or more paths, separated by the pipe symbol|.Specifically, the above example should result in the two paths of the letterb:
| <-- p1||/-\ <-- p2| || ||\-/Here are a few examples of more complex symbol definitions:
asterisk: S3,9:M1,3DS|S3.75Dq1,0.25t1,0.25|M0.25,5Dt0.75,1q0.75,1w: S5,9:S2D q1,4 t1,4 q1,4 t1,4y: S4,9:S2Dq1.5,4|M3,2De1.5,4e0.5,1eWhen drawing a new path the cursor is always reset to theorigin, which is inthe upper left corner. The coordinate system is rotated like this:
- |- --o-- x+ | y+From there you can perform relative and absolute moves. Once the commandD isentered the path will start being drawn. Which means you can move the cursorinto position before starting each path.
The following commands are allowed:
p N t \ | / L - o - R <-- o is the current position of the cursor / | \ e S qAny number (see below) after a direction command is interpreted as the lengthof the step, otherwise the step size is1. You can also use two numbersseparated by a comma. For instanceq2.5,3 will move the cursor two and a halfsteps to the right, and three steps down. Similarlyp2,1/2 will move thecursor two steps left, and half a step up.
Accepted numbers are either integers:1, fractions:1/2 or decimals:3.5.Note that all decimals are converted to fractions. Decimals are a conveniencethat allows you to write4.5 instead of9/2. However, you are better ofusing13/3 instead of4.33.... The latter will most likely not add upinside the limits of the grid. You can also use multiple commands in the samedirection, if you find that easier. For instanceR4 R1/2.
That means that if you get out of bounds errors, it is either because you areusing a decimal that does not "add up" properly inside the grid. Or simplybecause the resulting number is outside the grid.
Numbers are converted to float before being exported tojson orsvg
The following absolute moves are allowed
Mx,yto move to positionx,yrelative to theorigin.Zmove to the first position of the drawn path. (defaults toorigin)Wto move to move out to the right hand side of the drawing.wto move to the left side of the drawing.Hto move to the top of the drawing.hto move to the bottom of the drawing.
You can provide substitution groups in thegroups property of thejsonspecification. Groups names should always start with a( and end with a).Any(group) in a path definition will be replaced verbatim until there are nomore( or) left in the path specification. (Note: this means you can causeinfinite loops as well as memory leaks.)
The font paths are included indat/*/res.json, along with SVGs for eachsymbol. The raw descriptions are indat/*.json.
At the moment the included fonts are:
original: blocky letterssmooth: smoother version.
In order to use this library
python3 setup.py install --userYou can then use the library from your code. seegridfont/__init__.py orgridfont/writer.py to get an idea. More documentationmight be addedlater, if this seems useful to people.
To see other options use:
gridfont --helpTo parse a symbol.json file such asdat/font.json run the following, tooutput the results to the directoryout
gridfont parse font.json out [--svg]If you include the--svg flag, an svg will also be created for each symbol.
When you have a parsed symbol file (suchdat/original/res.json), you canwrite SVGs with it like this:
gridfont write res.json tmp.svg 'my text'This is a project I started because I wanted a simple "font" that would allowme to easily draw line-based glyphs while plotting. I don't know whether I willend up developing this much further, but I'm open to suggestions.
- Improve smooth numerals
2and3? - Capital letters, at least
A-Z - shift origin (in info section)?
- simple pair kerning instructions?
- some ligatures?
This is very similar to the Hershey fonts:https://en.wikipedia.org/wiki/Hershey_fonts. Which you probably should use,as they have been around for some time
This method is also similar to drawing in Logo:https://en.wikipedia.org/wiki/Logo_(programming_language)
The path definitions are also similar to the SVG format (but simpler):https://en.wikipedia.org/wiki/Scalable_Vector_Graphics
If you find this interesting, you might also like Recursive Radical PackingLanguage:https://github.com/LingDong-/rrpl
Metafont (LaTeX):https://en.wikipedia.org/wiki/Metafont
LeonSans:https://github.com/cmiscm/leonsans
About
grid-based system for designing simple symbols and fonts. including an example font. mainly intended for plotter drawings.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.

