J: great to hear! The moar 256x64 OLED users, the better ![]()
Ultra:
very nice! As far as iĆĀ“ve understood, you are currently using the ālineToā methods to draw the font, which makes sense for this linear font.
But to have a more universal font-drawing mechanism, iĆĀ“d recommend to implement a packed bitmap font engine, that can handle characters with front leading (ājā in your example).
What you always have to keep in mind is the uC-limitations, you donĆĀ“t have endless space, so āpackingā data as well as possible is a necessity, or you will run out of memory for your main programā¦
So instead of using a full byte, if a pixel is lit or not, you could use a bit and extract it via bit operations (and/or/not bitwise operators -> wikipedia has some article on it).
To store a character with left offset, and flexible length you could
* put all characters in a 16x12 pixel bitmap (width x height), which will use only 192/8 = 24 bytes of space for each character.
* have a character āleadingā and character āwidthā control parameter associated with each character, which you can also put into your packed font data structure (=26 bytes per character).
* do not output āblank pixelsā, so that the left offset of the ājā does not overwrite the right character pixels of the āaā in your demo.
Quick pseudo-algorithm to draw ājā with positive left-side leading
(Sorry donĆĀ“t have more time to write the inner loop pixel checking and setting)
unsigned char x = 100; // Current x "cursor" coordinate
unsigned char y = 16; // Current y "cursor" coordinate
// Grab output buffer, that has enough room to store the to-be-rendered screen data
...
// Character output loop, example just writing character "j", assuming font with height 12 pixels, j has a left lead of 2 pixels, forces cursor to "go back"
unsigned char leftLead = packedCharacter['j'][24]; // Byte 25 contains the left leading
unsigned char width = packedCharacter['j'][25]; // Byte 26 contains the width
for (unsigned char yChar = y; yChar < y + 12; yChar++)
{
for (unsigned char xChar = x - leftLead; xChar < x - leftLead + width; xChar++)
{
// Code, that checks, if a pixel is lit in character buffer
// Only, if pixel is lit, modify output buffer
}
}
// Write output buffer to screen
...
