MZ OpenType Pixel Font Renderer (MV & MZ)

Hello @Anatis , it seems you are sacaling the screen?
If you want to keep the pixels from deform, you need to only scale the screen 2x, 3x, etc, or never if your game's original size is not small enough to do a 2x scale.
It has nothing to do with the font you are using.
Ah well yes my game is on 1104x624 screen size, is that what you mean?
1738117277195.png


Working around that would surely be difficult...

(Edit: changing back and forth between 816 and 1104 actually changes nothing at all when it comes to the font)
No I mean do you play the game fullscreen, or change the size of the window?
It doesn't looks like your screenshots are from a 1104x624 window.
Well yeah I do have it full screen with blur removal etc.. Definitely intend (or hope) for my game to be playable in full screen.
1738119271929.png

Yes indeed I see that without full screen the proportions seem to remain solid...

But regardless the smaller printed characters behave the same even without full screen 🙁
1738119346568.png

Perhaps I'm just being too ambitious for a RM dev lol just need to find a way to compromise
What battle UI are you using? Shifting the PSY text up or down by half a pixel should fix the problem.

As for the fullscreen question, it is impossible in theory. How do you manage, for example, 2.5 pixel? It can only be 3 or 2 if you want it to display clearly. Also changing the screen size is out of the control of the plugin, it is done after the text is displayed.
Well I've used SRD SuperTools to rearrange the battle scene myself, trying to make it as compact as possible. Sadly I realized incredibly late that it wasn't just my monitor making Full Sceen blurry, and so I've spent all day applying plugins to fix it and eventually got stuck on the font...

I can understand the limitation there, I guess the only way to go forward is to try and make it look somewhat good accepting that it can't be perfect. Currently I switched from AbaddonLight to AbaddonBold which seems to yield slightly better results, and sadly resorted to change the PSY/RAGE text from those bars to PP/RP abbreviations which are more manageable, something I'd went through quite some lengths not to have to do before... It is what it is I suppose.

1738120407858.png
For text position, it can be rounded using a small plugin, for example:

Bitmap.prototype.drawText = function(text, x, y, maxWidth, lineHeight, align) {
// Note: Firefox has a bug with textBaseline: Bug 737852
// So we use 'alphabetic' here.
if (text !== undefined) {
var tx = x;
var ty = y + lineHeight - (lineHeight - this.fontSize * 0.7) / 2;
var context = this._context;
var alpha = context.globalAlpha;
maxWidth = maxWidth || 0xffffffff;
if (align === 'center') {
tx += maxWidth / 2;
}
if (align === 'right') {
tx += maxWidth;
}
tx = Math.round(tx);
ty = Math.round(ty);

context.save();
context.font = this._makeFontNameText();
context.textAlign = align;
context.textBaseline = 'alphabetic';
context.globalAlpha = 1;
this._drawTextOutline(text, tx, ty, maxWidth);
context.globalAlpha = alpha;
this._drawTextBody(text, tx, ty, maxWidth);
context.restore();
this._setDirty();
}
};
I don't know if it can fix your previous PSY text problem.
Anyway, UI adjust is very hard to do, you need to tinker things pixel by pixel.

And there're the original \{ and \} control, it increase or decrease font size by 12, so maybe you'll also need to change that to have best result.

Window_Base.prototype.makeFontBigger = function() {
if (this.contents.fontSize <= 96) {
this.contents.fontSize += 12;
}
};
Window_Base.prototype.makeFontSmaller = function() {
if (this.contents.fontSize >= 24) {
this.contents.fontSize -= 12;
}
};
Yes I had already tampered some with the \{ \} influence through Yanfly's Message Core plugin which simply edits that function at the core level, sadly it turns everything into rocket science and there really isn't anything to conclude other than from (mass) trial and error which gets very tedious very quickly. Also every single dialogue in my game starts with \{ so that would be quite the bother as well and would have needed to be counterbalanced...

In the end I decided to make edits at the Font level, resizing and then transplanting the numbers I liked from PixelOperator8 on to my original used font, and I am fairly satisfied with the result and by now think I have actually improved my initial "build" since adding in your awesome plugin!
The (unscaled) result:
1738170791717.png


Currently the only "problem" that remains in Full Screen is that the second actor in the party has their font slightly squished... as you can see here noticeably by the F, E and PP they are missing rows of pixels causing them to appear very thin compared to the rest, which honestly is only a minor issue at this point.
1738170807858.png


Thank you again so much for sharing this awesome plugin!
It wasn't easy to find but it completely revolutionized what I was doing! 🙂
JavaScript:
Bitmap.prototype.drawText = function(text, x, y, maxWidth, lineHeight, align) {
    // Note: Firefox has a bug with textBaseline: Bug 737852
    //       So we use 'alphabetic' here.
    if (text !== undefined) {
        var tx = x;
        var ty = y + lineHeight - (lineHeight - this.fontSize * 0.7) / 2;
        var context = this._context;
        var alpha = context.globalAlpha;
        maxWidth = maxWidth || 0xffffffff;
        if (align === 'center') {
            tx += maxWidth / 2;
        }
        if (align === 'right') {
            tx += maxWidth;
        }
        tx = Math.round(tx);
        ty = Math.round(ty);
        context.save();
        context.font = this._makeFontNameText();
        context.textAlign = align;
        context.textBaseline = 'alphabetic';
        context.globalAlpha = 1;
        this._drawTextOutline(text, tx, ty, maxWidth);
        context.globalAlpha = alpha;
        this._drawTextBody(text, tx, ty, maxWidth);
        context.restore();
        this._setDirty();
    }
};
Have you tried this?
I don't know about the bar/gauge plugins you are using but maybe the text positin is not integer/whole number.
Have you tried this?
I don't know about the bar/gauge plugins you are using but maybe the text positin is not integer/whole number.
I have it in my plugin list but turning it off/on doesn't seem to change much as far as I can tell..

It's only a minor imperfection compared to the massive improvement overall so I'm still incredibly happy ;D
I see. Besides that, it is best to have your actual font size multiplies of 16.
Because the renderer will try to center the text according to line height, for example, if the size is 19, it will be shift upward 1.5 pixels.

When the plugin tries to snap to a pixel, it is possible two values are 10.49999 and 9.500001, both values will be rounded to 10. I haven't tried to improve that yet, so you'll need to make sure the position and size of the text is accurate.:hswt:
I add a passive mode plugin. You can download UT_OpenTypePixelFont.js from the itch page.
Passive mode means you don't need to setup parameters for the plugin, instead, the plugin will read the font files your game has already loaded using css or database settings.

The only thing you need to do is to make sure the font file is good. The plugin will try to detect if it is a pixel font by sampling alpha-beta glyphs (A-Z and a-z). Basically it checks minimal distance between points and calcualte the base size of the font. If the size falls between 5 and 32, it is a valid pixel font.
If it is a not a pixel font, it can still render it but will not snap the points to pixel grids.

I don't know if there are actually pixel fonts that are bigger than 32, that is bigger than Terminus ttf:

Effect of terminus ttf using this plugin:

Spoiler
1742311877757.png

1742312295232.png
looks really good. keep it up.
I love it, but does it support for 640x320?

Edit: it works perfect fine, but when I am using Yep CoreEngine, the fonts decrease the size, it's not good, and I want to use it for real. Is there way to fix it?
Edit: it works perfect fine, but when I am using Yep CoreEngine, the fonts decrease the size, it's not good, and I want to use it for real. Is there way to fix it?
open YEP_CoreEngine and rule out the fontsize section 🙂
I ruled out a lot as error wont pop up so I ruled the entire thing out 🙂

among a lot of other things messing around 🙂
The problem is when I use YEP CoreEngine, the font size I used is 16, and this is how it shows me

1742423859453.png


Without YEP, it shows a perfect pixel art
1742423942765.png
Maybe it is because the font? For example 22 will be rounded down to 16 but 24 will be 32.
Please post a screen shot of the plugin parameters and the front you are using.
1742449427968.png


1742449497354.png


This is how I used https://www.pentacom.jp/pentacom/bitfontmaker2/gallery/?id=102
Without YEP, it works perfectly pixel art, but with YEP, it shows pixel but not perfect

And my size screen is 640x320
Seems fine on my end.
1742450811125.png

Have you tried updating the plugin? I have made some adjustments. It looks like your screenshots have some glitches.
1742450756414.png
Seems fine on my end.
View attachment 335061
Have you tried updating the plugin? I have made some adjustments. It looks like your screenshots have some glitches.
View attachment 335060
No, I didn't update it

Original thread: https://forums.rpgmakerweb.com/threads/opentype-pixel-font-renderer-mv-mz.171027/