[Answered]Why are pixel fonts so...messed up in MV/MZ

The thought came to my mind several days ago, when I was reading topics on the forums about sharp text.
Then I did my little test to display pixelated text in MV.

I even wrote a piece of code to test if a font can draw pixelated text. I tested it with several fonts but found none.
It appears, beside several east asian fonts pre-installed on windows, every other font displays smooth text.

So I searched the internet for an answer, and this discussion caught my attention:

According to the author of that topic, windows literally ignores bitmap data embeded in ttf fonts unless it contains cjk characters.

Another link confirms that. As it is mentioned on terminus ttf's download page,

Beware: Broken Hiragana characters​

This version of Terminus TTF contains a few additional fake Hiragana characters not present in other versions. Without those characters, native Windows® applications won't correctly display the font as a bitmap font.

If you need working Hiragana characters in native Windows® applications, this version is not for you (however, there is an official Windows® installer for the original Terminus Font available; you could try to use that installer instead).

I would really like to add real Hiragana characters, but that is not easily done because of size constraints (contact me if you have any ideas on how to solve this problem). Therefore, for now, I have instead added dummy glyphs for these Hiragana characters to at least make the font work with native Windows® applications, at the cost of broken Hiragana characters.

tl;dr
So, in order to display those bitmap fonts in a web browser, you need to install them first. Web font also ignores bitmap data, if you add a font using @font-face through gamefont.css, it won't work.

1723293806067.png
1723294075998.png
use a purpose-built pixel font.
I've been doing the same adjustments in Ace.... there's no way to pixelate a TTF unless it's designed like pixels.
and you'll still not have consistency, so consider using several fonts of different sizes, for bold or super thicc text.
(or, write a plugin to BLT pixel types from a bitmap, if there's not one written already)

case in point:

1723308220547.png


you can see pixel operator being the best at readable size, but it'll struggle at lower sizes.
cuword is perfect for tiny text, and it's virtually indistinguishable from operator.
the game Into The Breach uses this asymmetrical approach... look it up.
Yeah I was talking about ttfs which actually have build-in bitmaps, not the ones which simulate pixel looks. That terminal ttf I linked above for example has 9 sizes of bitmaps, range from 12 to 32 px.
The first screenshot I posted has a font size of 28.
TTF was meant to render at any resolution on screen and on print... maybe it defaults to the vector types without any parameters to send them to the pixel map.
....so, to the point of not-having that parameter in any case, it's cheaper to use a font with only the bitmap, working as intended.

I did dig into the same problem on my end, but since I solved it with dedicated fonts, I stopped worrying about it.
although the code I'm running requires some housekeeping: some fonts render better with the smoothing disabled, others with the bold enabled even though they're not bold, etc.

so, yes... it's a windows problem, probably solvable by a system update, which is not worth the effort.

EDIT: on further analysis, I think the pixel map is just to cover the case of a very tiny font on screen, not to be used *as* a pixel font.
and *types on screen* are subject to *resolution*, which may or may not be the same as the physical build of the screen.
pixel fonts will always be X pixels in size, independent of resolution.
Maybe I can use terminus ttf as a template and edit the bitmap glyphs. The run a script to install it so it can be used in game. As for cjk characters I can just use windows system fonts as a fall back.
This stackoverflow post was made 5 years ago, but might explain the absence of raster (as opposed to vector) support for web fonts:
....so, what's preventing people from vectorizing the pixel map and make it a TTF?
I mean, a vector square is still a vector, even at 1px size.
@caethyril Thank you got the link!
Edit* I had tried to find a javascript or node.js solution. It seems the closest thing is opentype.js, but it ignores EBLC and EBDT tables (out of curiosity I wrote some code on top of it to inspect the embeded bitmap data, but gave up halfway because I was too lazy to read documents).
I think I'll just leave it for now.

@gstv87 I guess it is the positions of converted pixels are not always integer. You still need to manual fix them if you want better result.
@gstv87 I saw you mentioned pixelOperator, I downloaded the font and opened it with fontforge. It seems the font has a em size of 1600, so I guess it is meant to display 16 pixels font. Then I converted it to 16 pixels bitmap using fontforge. It turned out the font is so well made and the bitmap glyphs has no glitches at all! Then I installed the newly generated ttf and tested it in a web browser, you can see the result, it looks really good:

1723343943150.png



HTML:
<style type="text/css">
@font-face{
font-family:'terminus';
src:local("Terminus (TTF) for Windows");
}
@font-face{
font-family:'terminusttf';
src:url(term2.ttf);
}
@font-face{
font-family:'pixel';
src:local("Pixel Operator");
}
@font-face{
font-family:'pixelttf';
src:url("PixelOperator.ttf");
}


</style>
<canvas id="canvas" width="400" height="400" onclick="render()" />
<script type="text/javascript">
var c = document.getElementById('canvas');
var ctx= c.getContext('2d');
function render(){
ctx.clearRect(0,0,c.width,c.height);
ctx.font = '18px terminus';
ctx.fillText('18px Terminus ttf, installed',10,50);
ctx.font = '18px terminusttf';
ctx.fillText('18px Terminus ttf, using css @font-face',10,100);
ctx.font = '16px pixel';
ctx.fillText('Installed and converted 16px pixeloperator.ttf',10,150);
ctx.font = '16px pixelttf';
ctx.fillText('The same pixeloperator.ttf load using css @font-face',10,200);
}
</script>
there are a good bunch of them in dafont.com, of various qualities.
my original pick was Minecraftia, which checked all the boxes, except it's copyrighted.
Oh, and about opentype.js I mentioned above. It is very capable of drawing those fonts, without any glithces, as long as the fonts themselves are good.

1723360855466.png

1723361190097.png

Original thread: https://forums.rpgmakerweb.com/threads/answered-why-are-pixel-fonts-so-messed-up-in-mv-mz.170984/