These days, working with a display in software is fairly easy. Thanks to the convenience of the modern OS, we’re blessed with graphical user interfaces, where things such as buttons and windows and text are all taken care of for us. Of course, once you start to wander off the beaten track, particularly in embedded systems with no GUI, things can get a little more difficult. For these situations, [JSBattista] wrote some code to blast text directly to the Linux framebuffer.
It’s a project borne out of necessity. Working with a Raspberry Pi with no X server, it was found that the console text size made it difficult to display data. By writing directly to the framebuffer, it would be possible to display text of a larger size without having to implement a full GUI, and overheads could be kept to a minimum.
Working in this manner comes with some limitations. Glyphs are taken from an array in bitmap format, rather than font files. In this case, a font akin to that of the Alien sentry gun interface was chosen, for an attractive sci-fi look. Lowercase characters are currently unimplemented. Testing thus far has been on Raspberry Pi and Beaglebone non-GUI systems, with performance varying depending on platform.
It’s a project we suspect might prove useful to the developers of lightweight embedded systems. It’s something that may take some tweaking and experimentation to implement, but the hacker set rarely shy away from a challenge. If you’re eager to get down and dirty with some heavy programming, this tutorial on Linux graphics will help.
One can change the console font and size you know. If you’re mostly just displaying text that’s gonna be a way easier way to accomplish this. Did this once to get more readability on an old green phosphor CRT. But then again maybe they want some more specific additional features.
X windows bitmap font files in .bdf format are pretty easy to parse and available with CJK glyphs too.
See also https://en.m.wikipedia.org/wiki/GNU_Unifont
libfreetype2 isn’t that hard to interface, and that gives you font rendering from any font file you want.
There’s nothing new or interesting here..so would be nice to see why justified the hard way over using DirectFB…just sayin.
Reminds me a bit of getting images on a 320×200 VGA display in DOS by, defining a 8-bit palette and then writing 64000 bytes to memory starting at 0xA0000000.
And there was also a neat trick where you could borrow the bit patterns for fonts from the BIOS, using the address pointed to for interrupt vector 0x1F in MSDOS (A pointer to the VGCT (Video Graphics Character Table), which contains the data for ASCII characters 0x80 to 0xFF).
Interrupt vector 0x43 and 0x44 also pointed fonts table inside the BIOS, that could be “borrowed”.
Great project! I’ve been wondering if something like this was possible.
ahhhh i love this.
awesome.
For Arduino dozons of libraries are written to render text on a bitmap display. Perhaps time to get them working for the RPI?
There is a whole bunch of direct framebuffer libraries for linux as well. But sometimes it’s good to just go back to basics to see what’s required to do something.
Well I wrote a whole library that can draw characters, display images, handle keystrokes and mouse etc. and is backend agnostic so that you can develop on normal Linux with X server, then run it on a framebuffer. You can have a look at https://github.com/gfxprim/gfxprim
I’m also working on a widget library for it, but that part is not finished yet https://github.com/metan-ucw/widgets/
Respect for going the long way using the framebuffer directly. If you just need to get it done on the Raspberry Pi the easier way would be https://github.com/paeryn/openvg I guess
If you aim for performance, keep in mind that the frame buffer is uncached. Sometimes it is faster to compose the image in cached ram and use an optimized memcpy equivalent to copy the final picture.
Those letter glyphs look to be very memory inefficient maybe make it a list of x,y points instead?
Then you draw a line between them
[0] = {1,2,1,6,2,7,3,7,4,6,4,2,3,1,2,1,1,2}
[1] = {3,1,3,7}
[2] = {1,1,3,1,4,2,4,3,3,4,1,5,1,7,4,7}
This also makes scaling the x & y trivial — by simple multiplication or even by percentage
Fun fact- the sentry gun scene only actually appears in the Director’s Cut of Aliens, but most of us know it because that’s the version most of us have seen (likely due to the popularity of that VHS/DVD version). It’s my favorite scene in the film, so I’m amazed it was ever cut from any release.