Sharp Text [MZ + MV]

This is wonderful, but when using alongside Visustella some scenes lag a lot. As soon as I disable it there's a huge perf increase, specially in large maps.

Perhaps the VS suite spams "DrawText" a lot? Anyway, not really OP's problem, but if anyone has figured a fix for this please share 🙂
Maybe vs tries to draw text every frame?
You can test with a loop showtext command to see how slow the process is.
If I use \> to show all the text at one time, the game runs 2fps on my old pc.
But if the character shows one by one, the game runs solid 60 fps.
Btw, I also do get a Warning on the console:
MechPen_SharpText.js:147 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently

I'm gonna look into how to set said flag.

Giga update! I made a HUGE performance boost by adding:
Code:
if (!text || text == "") {
        return;
}

inside the drawText function. Like right above the
// sharp text must be drawn on pixel borders.

No more lag, at all 😀
I wonder why there are so many empty texts.

Btw, I also do get a Warning ...
I tested with that flag it made almost no difference. The really slow step is context.getImageData, yes. But it is slow regardless of whatever you do, even if the canvas is small.
Giga update! I made a HUGE performance boost by adding:
Code:
if (!text || text == "") {
        return;
}

inside the drawText function. Like right above the


No more lag, at all 😀
Thanks for this, I updated the code to include it.
I tested with that flag it made almost no difference. The really slow step is context.getImageData, yes. But it is slow regardless of whatever you do, even if the canvas is small.
I really don't know, but I discovered it as I was debugging how to do perf improvement. I was trying to implement some sort of cache when I started noticing most of the keys being generated for the cache were empty strings. That's when I connected the dots.

My theory is that VS's Events and Movement Core invokes drawText for every single event you have in a map. Probably because it supports Event Labels, and even if you don't use them then it probably still initializes them as empty strings. This goes in line with how maps with high event populations triggered the lag. This is just a theory though, I can't dig into the obfuscated code.

Menus in general also seem to call a lot of empty draw texts, but for those I have no clue as to why.

I tested with that flag it made almost no difference. The really slow step is context.getImageData, yes. But it is slow regardless of whatever you do, even if the canvas is small.
Ditto. That is why I left it as is.

Thanks for this, I updated the code to include it.
Happy to help, and thank you for such a great plugin! 🙂
You can still try it on your side. The computer I'm using to test is a bit old.
So maybe 2 fps to 3fps is not a big deal. lol
JavaScript:
Bitmap.minFontSize = 64;
Bitmap.drawSmallTextBitmap = new Bitmap(1024, 64);
//small hack to test willReadFrequently
Bitmap.drawSmallTextBitmap.__canvas = document.createElement('canvas');
Bitmap.drawSmallTextBitmap.__canvas.width = Bitmap.drawSmallTextBitmap.width;
Bitmap.drawSmallTextBitmap.__canvas.height = Bitmap.drawSmallTextBitmap.height;
Bitmap.drawSmallTextBitmap.__context = Bitmap.drawSmallTextBitmap.__canvas.getContext('2d',{willReadFrequently:true});
@Tiramisu Likely this is impossible to fix in RPG Maker MV, as it draws each letter individually and will happily draw the next letter at a fractional offset. MZ draws a chunk of text until it reaches a control code so this issue is better hidden. Some fonts will behave better than others. In my own project I used YellowAfterlife's Pixel font converter to avoid many of the spacing issues. Remember that TTF is a vector format descibing lines, so its never going to represent pixel fonts 100% accurately.

@lsjadsl Do you use any other battle plug ins? Likely there is a bug somewhere that is causing a window to be redrawn every frame. It may be worth it to upgrade your nw.js to something newer if you have not yet. This plug in works by editing each individual pixel of the text and erasing parts that are "blurry" so its never going to be particularly fast.

You both may have more luck with Eli's old Eli_BitmapFontPro from his MV archive.
Eli's Bitmap font ended up working, thanks a lot!!
I probably wouldn't have been able to find that plugin by myself haha
@Tiramisu Likely this is impossible to fix in RPG Maker MV, as it draws each letter individually and will happily draw the next letter at a fractional offset. MZ draws a chunk of text until it reaches a control code so this issue is better hidden. Some fonts will behave better than others. In my own project I used YellowAfterlife's Pixel font converter to avoid many of the spacing issues. Remember that TTF is a vector format descibing lines, so its never going to represent pixel fonts 100% accurately.

@lsjadsl Do you use any other battle plug ins? Likely there is a bug somewhere that is causing a window to be redrawn every frame. It may be worth it to upgrade your nw.js to something newer if you have not yet. This plug in works by editing each individual pixel of the text and erasing parts that are "blurry" so its never going to be particularly fast.

You both may have more luck with Eli's old Eli_BitmapFontPro from his MV archive.

I'm sorry for the late response. I have tested only the four plugins YEP_CoreEngine, YEP_BattleEngineCore, YEP_PartySystem, and MechPen_SharpText, but the game still slows down. In more detail, the game slows down when moving the cursor from one skill to anothers. It seems that the cause of the slowdown is [opening the party change window during battle], but I don't know how to fix it ; ;

I checked Eli_BitmapFontPro, but I need Japanese and Korean in the game, so unfortunately it couldn't be the option.
Another small thing, this change should make it a bit faster on MV. Because there maybe multiple drawText within one frame (e.g., menu). As for MZ, maybe it is already done in PIXI.js?

//this._baseTexture.update();
this._setDirty();
I'm sorry for the late response. I have tested only the four plugins YEP_CoreEngine, YEP_BattleEngineCore, YEP_PartySystem, and MechPen_SharpText, but the game still slows down. In more detail, the game slows down when moving the cursor from one skill to anothers. It seems that the cause of the slowdown is [opening the party change window during battle], but I don't know how to fix it ; ;

I checked Eli_BitmapFontPro, but I need Japanese and Korean in the game, so unfortunately it couldn't be the option.
Did you try the above https://forums.rpgmakerweb.com/index.php?threads/sharp-text-mz-mv.132598/post-1464006 ? Or try the latest version? A speedup fix was attempted.
Did you try the above https://forums.rpgmakerweb.com/index.php?threads/sharp-text-mz-mv.132598/post-1464006 ? Or try the latest version? A speedup fix was attempted.
I've used the last version of the plugin, but the issue hasn't been fixed
I might have to look for Korean or Japanese BitmapFont plugin
I've used the last version of the plugin, but the issue hasn't been fixed
I might have to look for Korean or Japanese BitmapFont plugin
Can you try this one to see if it is faster?
I made some changes specifically for your situation.

Edit* You need to disable the original one first before test.
Can you try this one to see if it is faster?
I made some changes specifically for your situation.

Edit* You need to disable the original one first before test.
Wow, no longer slowing down.
But the text disappears in some places like dialog box and skill select window(When I move the cursor to another skill).

By the way, your other plugin work very well for me.

I've been struggling with this font issue for a long time. Thank you so much.
Wow, no longer slowing down.
But the text disappears in some places like dialog box and skill select window(When I move the cursor to another skill).

By the way, your other plugin work very well for me.

I've been struggling with this font issue for a long time. Thank you so much.
Oh, I noticed that. This one should have fixed it.

As for my other plugin, if you want to display Korean and Japanese the ttf you use needs to have their glyphs.
Oh, I noticed that. This one should have fixed it.

As for my other plugin, if you want to display Korean and Japanese the ttf you use needs to have their glyphs.
Now the message is displayed well.
But I found two issues.

1. When I scroll down a window (like a skill list or item list that doesn't fit on one screen and needs to be scrolled), the font flickers.
2. Fonts that should be displayed in gray (like not enough MP) are being displayed in white.
Well it seem it is still a long way to go.
I haven't checked the flickering problem, but the gray text is actually semi-transparent effect which is lost because the optimization. I don't know why they don't just use a gray color, it would make life easier.
Maybe I'll look into them when I have time, need to take a break.

Edit*

@lsjadsl Try this one.
I want to express my gratitude for making this plugin available for everyone. Set my resolution to 800x600, so obviously it blurs everything (bleh!) Yours paired with another one for the rest of sprites/tiles, makes it all look superbly crisp and unblurred. TY!! 😂
this plugin seems to break tsr_textcoloraddon.js plugin, when both are enabled, it seems like this plugin won't show customs text codes for the other, such as \I[Number] to show custom icons on the menus, instead it only shows the text command and not the icon.

Original thread: https://forums.rpgmakerweb.com/threads/sharp-text-mz-mv.132598/