Giter Club home page Giter Club logo

octafont's Introduction

Octafont

Example image

Pixelfont designed for flipdot matrices. Each text line has a height of 8 pixels and the characters, in favor of a natural appearance, have variable width (1 to 6 pixels).The bottom most pixel line is kept free by normal letters and only used by letters that go below the baseline, as for instance "g" or "q". A bold and a regular version is available. Octafont's look-and-feel is inspired by the Brose flipdot font that was still shown on my flipdot modules I got directly out of a bus. It is only inspired and not a clone, as the display did not show all characters, so the unknown ones were merely created in the same spirit.

The font for usage in C++ programs (it makes use of object oriented language) is generated by a python script mkfont.py which in turn reads the data from an image file. This way it is easy to adapt the font or to create completely new fonts. Using the generated C++ files, the font can be included in the program in hardcoded form.

Currently, the font generator is configured such that it provides all printable ASCII characters (from decimal 33 to decimal 126) and some german special letters from the upper block (greater than decimal 127). The german characters are encoded according to ISO 8859-15 (also called Latin-9).

The Font

The C++ pixelfont's interface is defined by its parent class PixelFont. The two generated classes OctafontRegular and OctafontBold are its descendants and can be instantiated. The interface offers three basic methods for accessing the pixeldata:

  • has_char(char) determines whether a certain character is included in the font.
  • get_width(char) returns the width in columns of the given character.
  • get_octet(char, uint8_t) provides the pixel data for the given character and the given column index.
  • static get_undercut(PixelFont&, char, PixelFont&, char) determines, whether the two characters can have an undercut when being displayed next to each other. Normally the characters are supposed to have one column distance between each other, however if this function returns 1, the distance can be decreased to no column.

The pixel data is stored and provided as uint8_t where the least significant bit is the topmost in the column. Each column has therefore a height of 8 pixels and that's why it is called octafont.

The Generator

The generator is a python script which only needs PIL/Pillow as extra dependency. Therefore no requirements.txt is provided. Calling reads the image data and writes the C++ source and header file to the folder output in the current working directory. If the output folder does not exist, it is created.

The image pixel data itself is rather self explanatory. It includes two lines of characters, one for the normal variant and one for the bold variant. Each line has a height of 8 pixels and a special line of pixels above, which encodes the beginnings and endings of the characters. A red pixel marks the beginning of the character, a green pixel its end. Thus the image file has a total height of 18 pixels.

octafont's People

Contributors

julianschick avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.