适用于微型屏幕的5x5像素字体
5x5 Pixel font for tiny screens

原始链接: https://maurycyz.com/projects/mcufont/

## 5x5像素字体概要 该项目详细介绍了为资源受限的微控制器(如AVR128DA28)创建的高度紧凑的5x5像素字体。该字体灵感来自ZX Spectrum的风格,优先考虑在最小的350字节空间内实现可读性——这对于RAM有限的设备至关重要。 虽然探索了更小的尺寸(3x3、2x2),但它们严重影响了可读性。5x5网格提供了最佳平衡,允许区分大小写字母,并保持一致的字符宽度以简化编程布局。 该字体针对小型OLED显示屏(160x128或128x64)进行了优化,在这些显示屏上,像素效率至关重要。尽管存在像素化图形的限制,该字体受益于某些显示屏的次像素渲染,从而产生伪阴影效果和更高的清晰度。 此外,还测试了替代的3x5和3x4变体,以进一步节省空间,但代价是牺牲了一些字符细节。

## 适用于小屏幕的微型像素字体 一则黑客新闻的讨论集中在极小的像素字体上,特别是 5x5 甚至更小(如 3x2 和 1x1)的字体,以及它们的潜在用途。原始帖子展示了一款专为微型屏幕设计的 5x5 字体,引发了关于可读性和实际应用方面的争论。 用户分享了示例,展示了即使在现代高分辨率显示器上,通过次像素渲染,这些字体也能出人意料地具有可读性。另一些人指出,需要间距,并且在如此小的网格中表示所有字符存在局限性。 许多评论员提到了类似字体在早期计算机、终端和嵌入式系统中的历史用途,例如较旧的卡西欧掌上电脑或现代设备(如电子墨水显示器)。 对话还涉及了替代方法,例如灰度字体以及为密度而非传统字母表而优化的新字符集。 虽然承认这个话题的利基性质,但许多人认为这个项目很有趣,并且证明了在严格的约束条件下巧妙的设计。
相关文章

原文
(Programming) Some example text in this font.
Font data (C header)

All characters fit within a 5 pixel square, and are safe to draw on a 6x6 grid. The design is based off of lcamtuf's 5x6 font-inline.h, which is itself inspired by the ZX Spectrum's 8x8 font.

5x5 is the smallest size that doesn't compromise legibility:

  • 2x2: Impossible.
  • 3x3: Technically possible, but unreadable.
  • 4x4: Not enough to draw "E", "M" or "W" properly.
  • 5x5: This font.

Five by five is actually big enough to draw most lowercase letters one pixel smaller, making them visually distinct from uppercase.

Narrower 4x5 and 3x5 dimensions are possible, but would require sacrificing the M, dotted zero, and reduce U/V/Y distinctiveness.

There's no artistic reason to make all characters five wide just because a few must be... but a using a constant width makes programming a lot easier: The length of a string on screen is always 6 times the number of characters.

It also makes compact layouts much safer: There's no need to worry that a number will overflow because "8978" is longer than "1111".

The whole font takes up just 350 bytes of memory, which makes it ideally suited to 8-bit microcontrollers like the AVR128DA28 (16 kB of RAM) These are cheap, low power and robust... but they fall short on graphics:

Even a low-resolution 384x288 display has 110 thousand pixels: way too big to fit in the AVRs memory.

... except most projects don't need anywhere near that many pixels. A 160x128 or 128x64 OLED is more practical and cheaper — but these need hand-drawn, pixel-efficient fonts to make good use of them.

For reference, here's a vector font rendered at a similar scale:

A screenshot of my computer displaying text at a tiny font size. It's a blurry mess.
Actually 6 tall, but the letters are narrower, so I'll allow it.

Antialiasing, several megabytes of code, a megabyte of font data, and it's still terrible compared 350 hand-crafted bytes.

Pixels aren't perfect squares, so the font won't actually look like the rendering at the top of this post: This is it on an actual screen:

A photograph of the font displayed on real hardware

I actually really like the pseudo-dropshadow effect created by the subpixels. This won't happen on monochrome displays, but the font will still look smoother than you might expect.

The gaps between pixels really help sell the "e" and "g", but this same effect should allow...

While 5x5 is the smallest no-compromise resolution, a 3x5 isn't too bad:

There are 32,768 glyphs at this size. (27,904 are distinct)

The "M", "W" and "Q" suffer, but it's still got a distinct O and zero. Something like this might actually be a good option if you need to cram (50%) more columns into a display.

That's still readable, so what about 3x4?

There are 4,096 glyphs at this size. (3,392 are distinct)

At this size, there's no way to have a distinct upper and lowercase, so I've picked whatever style works the best in the limited space. The numbers have also taken a hit, but still work ok.

How about 3x3?

There are 512 glyphs at this size. (400 are distinct)

The main loss was the numbers, but the letters don't include any duplicates and are somewhat recognizable.

This font is hugely improved by being displayed on real hardware:

That means it's still too big. How about 2x3?

There are 64 glyphs at this size. (44 are distinct)

Ok, this is getting ridiculous. Most letters are unrecognizable, and there are quite a few duplicates. In case you couldn't tell, the bottom line reads "Hello World".

Flipping the aspect ratio to a 3x2 makes it a lot better:

There are 64 glyphs at this size. (44 are distinct)
Simulated pixel grid

More letters have horizontal detail (M, W, N, Q, G, P, etc) then have vertical detail (E, F). The bottom line reads "you can probably read this", although you might have to squint or zoom out.

... and for the sake of completeness, a 2x2:

There are 16 glyphs at this size. (10 are distinct)

On paper, there are 16 possible 2x2 images, but one of them is blank and 5 of them are shifted copies of another one. That leaves 10, just enough to do all the digits... but because they have no resemblance to the originals, it's more of a secret code than a font.

联系我们 contact @ memedata.com