Microsoft MakeCode

Microbit font inconsistencies

I’ve just noticed, whilst working on the text/char and text scrolling functions of my extension for the 17x7 LED matrix, that the internal Microbit font is rather oddly constructed.

Obviously characters which are five pixels wide are five pixels wide. However, some characters which are four pixels wide are left-aligned whilst others are right aligned. Here are two examples, first “t”:

.#...
.#...
.##..
.#...
..###

but “e” is left-aligned:

.##..
#..#.
###..
#....
.###.

Furthermore, characters which are three pixels wide “l” and j" etc are centred in the 5-wide matrix but the letter “i” is not - it is in the second leftmost column.

When scrolling text across a wider LED display attached to a Microbit it would be nice to have only one blank pixel-column between adjacent letters so as to maximise density. This requires a bit of jiggery pokery.

What do people think about this? Obviously when displaying a single letter on the 5x45 Microbit matrix it makes sense to have it centred but for any external display devices it’s a shame the characters are not consistently definted to give ease of manipulation

The original Pimoroni code included a function in a .cpp file which does a logical OR of all five rows to determine the width. I will therefore add an additional check for lack of left-alignment and return a negative value which I can use to indicate both the width (using abs(width)) and to determine that the first pixel-column can be eliminated.

We need to ask the Lancaster folks about that font. @jamesadevine ?

Every font has its own styling. The micro:bit font (Pendolino) is no different and is designed for scrolling text at speed on the constrained display of the micro:bit. I don’t think there was ever any consideration for some sort of spacing consistency between characters—it was determined through user testing and feedback.

We never implemented dynamic “kerning” (what you are describing) in the DAL, but it is possible to load alternate fonts via the appropriate call to setSystemFont in C++. You are also welcome to implement your own kerning as you outlined :slight_smile:.

I’ve managed to construct a routine which, when scrolling text for a larger display, works out the width after left-aligning each character. That was fun. So for “wilt” I get always one column between each letter of a word:

#...#.#.#...#...
#...#...#...#...
#...#.#.#...##..
#.#.#.#.#...#...
##.##.#..##..###

Of course I then have to bodge it with a special check for the case of a space character which has zero width in pixels.