Font Glitch - Need a way to draw letters fully

So, I've figured out that font glitches seen in the screenshots below are actually due to letters of the main white text not drawn fully--thus displaying the black outline underneath. This makes it seems some junk pixels are on top of the white text. Nonetheless, in removing the white text to leave the black outline below, sometimes the black outline's characters may be not fully drawn as well.
Reference: rpg_core.js

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;
        }
        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();
    }
};

For message boxes, if showfast is set to false or that each letter appears one by one very slowly, the characters would render properly. If showfast is true or that the letters are set to appear rapidly, there's a chance this glitch occurs.
Reference: rpg_windows.js


JavaScript:
Window_Message.prototype.updateMessage = function() {
    if (this._textState) {
        while (!this.isEndOfText(this._textState)) {
            if (this.needsNewPage(this._textState)) {
                this.newPage(this._textState);
            }
            this.updateShowFast();
            this.processCharacter(this._textState);
            if (!this._showFast && !this._lineShowFast) {
                break;
            }
            if (this.pause || this._waitCount > 0) {
                break;
            }
        }
        if (this.isEndOfText(this._textState)) {
            this.onEndOfText();
        }
        return true;
    } else {
        return false;
    }
};

For me, this issue occurs on Win 11 laptop for deployed games. All is fine on the Steam Deck and a Win 10 PC. I've tried turning off plugins (YEP_MessageCore, YEP_CoreEngine, etc.), but none seems to be the culprit. It appears there's something particular about Win 11 laptops.

With this information, does anyone know how to fix this?


1737275055747.png

From: https://forums.rpgmakerweb.com/index.php?threads/glitch-messing-up-with-the-fonts.145758/

1737275180479.png

From: https://forums.rpgmakerweb.com/index.php?threads/font-and-texts-being-weird.166846/

1737275979257.png
From: https://forums.rpgmakerweb.com/index.php?threads/font-displays-strangely.170137/
Someone mentioned upgrading NW.js fixed the problem.
So it looks like a bug of the browser itself.

You can also try my plugin, change base size to 1 and turn off snap to pixel. If it fixes the problem maybe I can update the plugin to draw normal fonts.

Edit*
You are posting on MV board, so doesn't it happens on MV as well? Because all the links seem to talk about MZ.
Someone mentioned upgrading NW.js fixed the problem.
So it looks like a bug of the browser itself.

You can also try my plugin, change base size to 1 and turn off snap to pixel. If it fixes the problem maybe I can update the plugin to draw normal fonts.

Edit*
You are posting on MV board, so doesn't it happens on MV as well? Because all the links seem to talk about MZ.
Hi, tried out your your plugin to fix the font rendering issues and it works wonderfully for non-pixel fonts, fixed the rendering issue completely 😀

Before:
Screenshot 2025-01-19 193512.png

After:
Screenshot 2025-01-19 193530.png
@Percarus: Was that screen from -
a) MV or MZ?
b) a deployed/exported game?
c) a Win 11 laptop?
d) an nw.js - updated rpg maker?

@utunnels: Appreciate the plugin. Unfortunately, I couldn't get my normal font working. The bodytext still have some incompletely renderings. Have tried uninstalling all other plugins. I haven't been able to test with pixel fonts yet.

1737328297551.png



The deployed MV game in question was exported with RMMV with nw.js 49.2.
I'm having troubles on a Win 11 laptop that has RMMV with nw.js 29.4 (no upgrade). However, that shouldn't matter since the deployed game should be standalone.

Nonetheless, a fresh MV project with the exact same text message deployed from that Win 11 laptop with nw.js 29.4 does not have that issue. I'm going to upgrade the Win 11 laptop to nw.js 49.2 and deploy that new project again to see if it's really the issue with nw.js 49.2 or the Win 11 laptop (it's practically new).
From @Percarus 's screenshots it seems to be MV because the icon looks like it.
@MikeMakes that is unfortunate. I suspect it happens when bitmap's texture is updated when the canvas context is changed. Can I see your plugin parameter of OpenTypePixelFont.js?
Yes, it's:
["{\"family\":\"GameFonta\",\"file\":\"OpenSans-Regular.tff\",\"snapToPixel\":\"false\",\"baseSize\":\"1\",\"unicode-range\":\"U+0-10FFFF\"}"]

I'm using YEP LoadCustomFonts before and YEP MessageCore after your plugin to use GameFonta.
Actually you don't need load custom font although I doubt it matters. The message core also doesn't change much of the bitmap class but add a bold option.
If you still has the issue at least we can rule out original fillText function. As I suspect the texture gets bad when it is updated. Can't test it myself because I can't reproduce it.
Since you are using MV, how about you switch to canvas mode using Community_Basic.js to see if it fixes the problem?
Thanks for the suggestion. Though the Canvas mode was no go either. As much as I don't want to tinker with it, looks like I'll have to upgrade nw.js and see if that'll work.
It's fine, I just wanted you to test it in canvas mode to see if it is webgl texture related.
@Percarus: Was that screen from -
a) MV or MZ?
b) a deployed/exported game?
c) a Win 11 laptop?
d) an nw.js - updated rpg maker?

@utunnels: Appreciate the plugin. Unfortunately, I couldn't get my normal font working. The bodytext still have some incompletely renderings. Have tried uninstalling all other plugins. I haven't been able to test with pixel fonts yet.

View attachment 329356


The deployed MV game in question was exported with RMMV with nw.js 49.2.
I'm having troubles on a Win 11 laptop that has RMMV with nw.js 29.4 (no upgrade). However, that shouldn't matter since the deployed game should be standalone.

Nonetheless, a fresh MV project with the exact same text message deployed from that Win 11 laptop with nw.js 29.4 does not have that issue. I'm going to upgrade the Win 11 laptop to nw.js 49.2 and deploy that new project again to see if it's really the issue with nw.js 49.2 or the Win 11 laptop (it's practically new).
a) I'm using MV, as utunnels have observed.
b) not deployed, just through playtest.
c) Windows 11 laptop, exactly.
d) nw.js is updated to 49.2 iirc? Whatever was recommended in the forum post all about updating nw.js

Just to add, I also have Message Core installed, and I have the utunnel's font plugin installed all the way at the bottom of my plugin list.
I'm glad you got your game working.

I updated my NW.js. While that fixed the font issue for Win 11, it broke my Steam Deck version and can't get controls to work. Guess I'll just have to find a NW.js that works for both Win 11 and Steam Deck.
Doesn't steamdeck use steamos? Maybe you can upload a seperate deport for linux+steamos and use another version.
I have no idea about steamos and linux nor the ability for version control management outside of Steam due to workload. I've been using the same windows export files so far on all platforms
Oh well just say it is a possible solution.
You can also pack another nw.js into the app and use steam's lauch option to change executable and dir on specific os.
I don't know if the OP still needs a solution.
Anyway I came by a topic on the Japanese forum today about this issue.

The author post 2 test plugin files in order to collect information of the user's enviroment, as well as test a method to see if it fixes the problem.
(You need to register in order to download the files like here).

I'm curious about the test plugin(the second file), but the author says it only works in test mode. @MikeMakes mentioned he only had issue in a deployed game. So maybe you can save part of the code to test it:

Code:
  const markContext = (() => {
    const marked = new WeakSet();
    return context => {
      if (!marked.has(context)) {
        context.getImageData(0, 0, 1, 1);
        marked.add(context);
      }
    };
  })();
  const Bitmap_drawText = Bitmap.prototype.drawText;
  Bitmap.prototype.drawText = function () {
    Bitmap_drawText.apply(this, arguments);
    markContext(this.context);
  };

Much appreciate the sharing. I eventually upgraded NW.js, which did solve the issue.

But I will keep this in mind in case I need to roll back.
I see.

I heard this problem is quite system specific. Some also reported upgrading nw.js does not solve the issue. Some also reported certain message plugin fixed the problem(siad plugin actually draws on another canvas before transfering to the actual message window), while the some said it didn't. So it looks like the canvas context goes bad randomly.

Original thread: https://forums.rpgmakerweb.com/threads/font-glitch-need-a-way-to-draw-letters-fully.174818/