My friend told me that the reason why text is blurry in MZ is because the text gets rendered at the base resolution, and that for the text to scale correctly the text needs to render at a higher resolution. He says the the only way to account for this is to render the text at a higher resolution than normal when the game is scaled. I've tried looking at PixiJS threads trying to solve this, but I either keep getting errors or it doesn't change anything. I'm fairly new to JS and come from ruby so i'm not sure what to do exactly.
MZ How to make text render at higher resolution based on screen difference?
JS Plugin RequestsI'm new to RPGM. So, different font plugins for the menu can be a problem based on the engine?
I wanted to do something a little like this, but I keep getting errors
Code:
text.style.fontSize = (FONT_SIZE / app.renderer.resolution) + "px";
EDIT:
I've been looking at older threads and I found this and tried mogwai's solution, but it 20% worked. All messages are broken and game crashes upon dialogue starting due to width being 0 or something. Would anyone be able to fix this?
Code:
Bitmap.prototype._drawTextOutline = function() {
return;
}
Bitmap.prototype._drawTextBody = function(text, tx, ty, maxWidth) {
var context = this._context;
context.imageSmoothingEnabled = false;
context.fillStyle = this.textColor;
context.fillText(text, tx, ty, maxWidth*2);
var imageData = context.getImageData(0, 0, this.width, this.height); //broken <--
var data = imageData.data;
for (var i = 0; i < data.length; i += 4) {
if(data[i + 3] < 200) // if alpha less than
data[i + 3] = 0; // set alpha to 0
data[i] = data[i]; // red
data[i + 1] = data[i + 1]; // green
data[i + 2] = data[i + 2]; // blue
}
context.putImageData(imageData, 0, 0);
};
everything so simple and yet an error? I think I have lot to learn. Thank god text color changing isn't that hard.
My friend helped me fix mogwai's solution, by using try catch and just skipping the error. I assume the error came from dialogue boxes having 0 width and height once they start. Overall this solution works really well, but most likely isn't the best one. It's not 100% accurate but it works compared to the other solutions.
Code:
Bitmap.prototype._drawTextOutline = function() {
return;
}
Bitmap.prototype._drawTextBody = function(text, tx, ty, maxWidth) {
var context = this._context;
context.imageSmoothingEnabled = false;
context.fillStyle = this.textColor;
context.fillText(text, tx, ty, maxWidth*2);
try {
var imageData = context.getImageData(0, 0, this.width, this.height); //broken <--
var data = imageData.data;
console.log(data.length)
for (var i = 0; i < data.length; i += 4) {
if(data[i + 3] < 200) // if alpha less than
data[i + 3] = 0; // set alpha to 0
data[i] = data[i]; // red
data[i + 1] = data[i + 1]; // green
data[i + 2] = data[i + 2]; // blue
}
context.putImageData(imageData, 0, 0);
}
catch (error) {
console.log(error) //<- delete this, this is just for testing
}
};
I guess this post could be marked as solved or done, but this solution isn't the best one.
i tested this using a font i made a while ago.
post where i found the solution if you wanna read on it: https://forums.rpgmakerweb.com/index.php?threads/removing-font-blur.75294/
Amaazing. truly a work of art. glad you figured that out. good on you.
usually the way it's done is you set up a table containing the standard resolutions you're capable of displaying, and the default font for those resolutions.
AND, the interface as a whole is designed in terms of Main Title is size 1, Subtitle is size 2, (tiny tool tip) is size 3. Where size 1 is probably "entry number 10 in the list of available font sizes, whichever it might be", and size 2 is probably "entry number *size 1* minus 2"
so, you only ever specify size 1, and everything is calculated from there.
if you calculate by subtracting or dividing default sizes, or by percentage, you could fall into the same problem of having blurry edges, because the available sizes are fixed numbers which not always refer to pixels or millimeters.
AND, the interface as a whole is designed in terms of Main Title is size 1, Subtitle is size 2, (tiny tool tip) is size 3. Where size 1 is probably "entry number 10 in the list of available font sizes, whichever it might be", and size 2 is probably "entry number *size 1* minus 2"
so, you only ever specify size 1, and everything is calculated from there.
if you calculate by subtracting or dividing default sizes, or by percentage, you could fall into the same problem of having blurry edges, because the available sizes are fixed numbers which not always refer to pixels or millimeters.
Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-text-render-at-higher-resolution-based-on-screen-difference.132766/