charlotte-os / charlotte-core

The Kernel of CharlotteOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add framebuffer text scaling

EthanPlant opened this issue · comments

As the framebuffer font is 8x16 pixels, the text appears very small on high resolution displays. Ideally the text should be scaled to counteract this.

For simplicity's sake we probably only need to support integer scaling at the moment, ideally the scaling factor for text should be automatically computed to be the best possible for the 80x25 console.

We can probably do this using bilinear interpolation. The algorithm is really simple. For each pixel in the upscaled image take the average of the nearest 4 pixels in the original.

Since out font is already relatively small we shouldn't need to downscale.

Alternatively, we can use an AI upscaler on the font as it is now and just store pre-upscaled versions of it at few different sizes, say 2x, 4x, 6x, and 8x and then allow the user to switch between the supported sizes when the OS is running in terminal mode.

Implementing a bitmap scaler using nested for loops is straightforward, but it can impact performance due to increased computation.

Alternatively, statically "burning in" the upscaled bitmaps would offer better performance, however, this approach would consume more memory and result in larger image (.iso) sizes.

We need to prioritize either performance or memory usage.

if you scale and cache the scaled fonts in memory it could be the best of both worlds

We need to prioritize either performance or memory usage.

For desktop and server use cases memory is probably cheaper than CPU cycles especially since the CPU will be working double time to do rendering as well as general computation since we won't have GPU drivers for a very long time. I say we optimize for CPU and use more memory for these platforms. Later on we can revisit the issue for the embedded version of the OS which will not need to support a traditional display possibly at all.

Does anybody know the name of the 8x16 bitmap font we already have?

Currently, the scaling multiplier is set based on the resolution. As @mdpatelcsecon mentioned, later on we should base this number on DPI. The scaling simply enlarges the existing 8x16 font, so only whole numbers are valid scaling values. This method does not require significantly more computation compared to "burnt-in" scaled fonts.