MZ OpenType Pixel Font Renderer (MV & MZ)

Spoiler: Screenshots
1737211428402.png

1737211530000.png
Download link: https://utstudio.itch.io/otpfmvz

Introduction​

This plugin uses opentype.js - an OpenType/TTF font parser - to achieve precise text rendering in both browser and Node.js environments. The plugin is designed specifically for pixel-perfect font display, it modifies the core CanvasRenderingContext2D methods (fillText, measureText, and strokeText) while maintaining engine compatibility.

Features​

  • Automatic pixel grid alignment for crisp text rendering
  • Customizable font configurations through parameters
  • Size configurations for various display resolutions
  • Unicode character range specification

Usage​

tl;dr

There's a passive mode version called UT_OpenTypePixelFont.js, which doesn't require any parameter to work. But if you need to fine-tune the settings, you can read the following section about parameters.


Plugin Parameters​

Configure your fonts through an array of structured objects with these properties:
  1. Font File
    (String) Path to your font file (e.g., pixeloperator.ttf)
  2. Font Family Name
    (String) Target font family to replace:
    • MV: Typically GameFont
    • MZ: Defaults are rmmz-mainfont (primary) & rmmz-numberfont (gauges)Note: Actual font replacement must be handled through RPG Maker's native systems
  3. Snap to Pixel
    (Boolean) Enable pixel grid alignment (crucial for pixel font rendering)
    Default: ON(true)
  4. Base Size
    (Number|Object) Optimal font size configuration:
    • Single value: e.g., 16 for PixelOperator
    • Size map: Custom scaling rules (e.g., {28:24, 72:80} scales 28→24, 72→80)Automatically calculates nearest whole-number scaling while preserving game variables
  5. Unicode Range
    (String) Character subset coverage using CSS unicode-range syntax
    Default: U+0-10FFFF (all characters) Use when employing multiple font files for a single family

Terms of Use​

  • Free Usage: Compatible with commercial/non-commercial projects
  • Attribution: Optional (not required)
  • Modifications: Permitted for personal use
  • Redistribution: Prohibited without explicit authorization

Disclaimer:​

The demonstration font files included in this download are provided solely for testing purposes and are NOT part of the plugin. If you wish to use these fonts in actual projects, you MUST consult their respective license terms. Links to the fonts:

https://www.dafont.com/5x5-pixel.font
https://notabug.org/HarvettFox96/ttf-pixeloperator
https://files.ax86.net/terminus-ttf/ (Some glyphs are used by arrows32.ttf in the demo)
Incredible, I've been trying to tinker with workarounds using what PixiJS offers to no avail, and this one works so nicely! I genuinely tried searching for solutions for oh so many hours and it was in this thread this whole time.

However, I can only get it to work for message windows, whereas I want it working for menus, battle UI, etc. Is there something I'm missing?
Incredible, I've been trying to tinker with workarounds using what PixiJS offers to no avail, and this one works so nicely! I genuinely tried searching for solutions for oh so many hours and it was in this thread this whole time.

However, I can only get it to work for message windows, whereas I want it working for menus, battle UI, etc. Is there something I'm missing?
Are you use plugins that changes fonts of the other UI?
Are you use plugins that changes fonts of the other UI?
Well, looks like setting the default font list in Yanfly's Core Engine to just GameFont fixes it. Funny how it works out that way.
This plugin works like magic!
You are my lifesaver. Thank you very much.
Finally, pixel perfect fonts! Thank you.
I tried, and didn't do pixel, and I am using MZ
I tried, and didn't do pixel, and I am using MZ
MZ uses different font names instead of GameFont in MV.
You need to change the plugin parameters as well as font settings in the database.
Then MZ’s font family name what should I name it? For example let’s say I used “Raster.ttf” font name, font family what should I name it?

Edit: I found a solution for those who use MZ
1) Open "rmmz_core.js"
2) in line 1203 you will find this.fontFace
1730352363645.png

3) Open plugin manager, and then font family name should "sans-serif"
And that's it it will work a perfect pixel font

Since I found solution that MV is working on gamefonts, and MZ is working on rmmz_core.js but MZ does it have gamefont, so I asked chatgpt, and here's the answer:

"In RPG Maker MZ, the engine no longer uses the GameFont file that was present in RPG Maker MV. Instead, MZ manages fonts directly through JavaScript in its core file, rmmz_core.js, which includes a property called fontFace. This change serves multiple purposes and reflects a shift in how MZ handles fonts for efficiency, flexibility, and better performance."
I think it is called rmmz-mainfont, you can change gamefont to rmmz-mainfont to see if it works.
I don't have MZ right now to test, I'll check it when I have my own pc to see if I can make a small demo for MZ.
Then MZ’s font family name what should I name it? For example let’s say I used “Raster.ttf” font name, font family what should I name it?

Edit: I found a solution for those who use MZ
1) Open "rmmz_core.js"
2) in line 1203 you will find this.fontFace View attachment 321720
3) Open plugin manager, and then font family name should "sans-serif"
And that's it it will work a perfect pixel font

Since I found solution that MV is working on gamefonts, and MZ is working on rmmz_core.js but MZ does it have gamefont, so I asked chatgpt, and here's the answer:

"In RPG Maker MZ, the engine no longer uses the GameFont file that was present in RPG Maker MV. Instead, MZ manages fonts directly through JavaScript in its core file, rmmz_core.js, which includes a property called fontFace. This change serves multiple purposes and reflects a shift in how MZ handles fonts for efficiency, flexibility, and better performance."
That's the answer, I found it
1730384442279.png
1730384411822.png


Here's an example for mz.
Since mz uses a different font for gauge numbers (hp and mp values), you can choose a smaller font if you like.
Then MZ’s font family name what should I name it? For example let’s say I used “Raster.ttf” font name, font family what should I name it?

Edit: I found a solution for those who use MZ
1) Open "rmmz_core.js"
2) in line 1203 you will find this.fontFace View attachment 321720
3) Open plugin manager, and then font family name should "sans-serif"
And that's it it will work a perfect pixel font

Since I found solution that MV is working on gamefonts, and MZ is working on rmmz_core.js but MZ does it have gamefont, so I asked chatgpt, and here's the answer:

"In RPG Maker MZ, the engine no longer uses the GameFont file that was present in RPG Maker MV. Instead, MZ manages fonts directly through JavaScript in its core file, rmmz_core.js, which includes a property called fontFace. This change serves multiple purposes and reflects a shift in how MZ handles fonts for efficiency, flexibility, and better performance."
This can be work

View attachment 321748View attachment 321747

Here's an example for mz.
Since mz uses a different font for gauge numbers (hp and mp values), you can choose a smaller font if you like.
And this one.

I just found another solution which there like english + latin alphabet
You could use this unicode range: U+0000-024F

I will try to find like Japanese and Korean

1730402187113.png
Unless you have a working Japanese pixel font, I don't have one to test.

Edit*
For example, this one, but it is not free for commercial use:
I already have one and it's Japanese font, the problem is Japanese unicode range are more than I expected; because they have like 5 things that I searched google:

- Hiragana
- Katakana
- CJK unifed ideographs
- Japanese-style punctuation

This is how did I work in Japanese unicode range:

1730437973485.png


1730439008628.png


Edit: I forgot for Katakana and Punctuation (Half Width)
1730439887126.png
Actually, you can use comma.
U+100-200, U+500-600
And you don't have to be so accurate. U+100-10FFFF should cover all of them.
Wow! It works! I can finally use pixel fonts for whatever I need, also good news is I can use dk translation to translate the game and use your plugin. It's working 100% pixel font for real.

See the video!
I updated the first post.
1. Renamed plugin so it makes more sense.
2. Fixed a bug: when loading a big ttf file, the title screen appears before the font is fully loaded.
3. Fixed vertical position when the actual font size is different. For example, if the actual size is 24 and font size is set to 28, move the base line 2 pixels upward. Let me know if you have different thought about this fix or experiencing bugs.
4. Merge the lib file and the plugin file, so you don't need to put opentype.js in js/libs folder.
I updated the first post, removed the outdated attachment.
Fixed some bugs and added a demo on itch.io

1. The fonts are loaded in correct order now.
2. Unicode range works correctly now, if it didn't before.

TODO: make a demo for MZ
Hello! I first just want to say how grateful for and hopeful because of this plugin I am, but I have a question regarding on how exactly to discern what values to input...

See I am using a font called AbaddonLight which is a free downloadable one off itch.io, and using the default "16" setting on "30" called by the game through Yanfly's Core Engine plugin it looks almost exactly as it should, except when you look closely at the "default" sized words you can see inconsistencies as with the little circles on the percentage marks here:
1738107911712.png



and also, much more sadly, in my game I decided to make the HP/MP/TP name text tiny using the \} code to create more space in order for my Battle UI to be as compact as possible... and... it suffers severely i'm afraid :
1738108067324.png


The "LiFE" looks absolutely perfect, but as you can see the letter S gets all but obliterated here.
Any slight adjustments I'm testing out to the ratio yields wildly unexpected results none of which too good...


Do you think it would be possible to display the font at the size I was using before:
1738108554534.png

(this is at Font Size 27, where the words fit neatly into the menu without the plugin turned on, as you can see from the monstrous blurriness <'; )

1738108684762.png


I am very willing to try and work around any limitations as much as required, but I'm hoping I can possibly minimize any compromise if I understand the rules a bit better... It's the #font base size I am very stumped about I cannot understand how to relate these numbers or how to gauge what number would be appropriate..

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