Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 11, 2025. It is now read-only.
/gridfontPublic archive

grid-based system for designing simple symbols and fonts. including an example font. mainly intended for plotter drawings.

License

NotificationsYou must be signed in to change notification settings

inconvergent/gridfont

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

originaloriginal

smoothsmooth

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|S3DtRqS2eLp

You can use spaces to separate moves, so you can for instance write it like this:

S4,9: DS6| S3 DtRq S2 eLp

The 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,1e

Paths

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

Relative Moves

The following commands are allowed:

 p   N   t   \ | / L - o - R    <-- o is the current position of the cursor   / | \ e   S   q

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

Numbers

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

Absolute Moves

The following absolute moves are allowed

  • Mx,y to move to positionx,y relative to theorigin.
  • Z move to the first position of the drawn path. (defaults toorigin)
  • W to move to move out to the right hand side of the drawing.
  • w to move to the left side of the drawing.
  • H to move to the top of the drawing.
  • h to move to the bottom of the drawing.

Groups

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

Fonts

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 letters
  • smooth: smoother version.

Using the Code

In order to use this library

python3 setup.py install --user

You 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 --help

Parsing your Own Symbol Definitions

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

Writing

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'

Contributing

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.

Todo

  • Improve smooth numerals2 and3?
  • Capital letters, at leastA-Z
  • shift origin (in info section)?
  • simple pair kerning instructions?
  • some ligatures?

References

About

grid-based system for designing simple symbols and fonts. including an example font. mainly intended for plotter drawings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp