Fix ligatures and font plugin stuff
This commit is contained in:
parent
6f7e300510
commit
0de810ea6e
3 changed files with 17 additions and 6 deletions
|
|
@ -425,7 +425,7 @@
|
|||
"set",
|
||||
"テキストピクチャの設定",
|
||||
{
|
||||
"text": "Attack \\V[32] Mag.Atk \\V[34] Agility \\V[36]"
|
||||
"text": "Attack \\V[32]\nMag.Atk \\V[34]\nAgility \\V[36]"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -460,7 +460,7 @@
|
|||
"set",
|
||||
"テキストピクチャの設定",
|
||||
{
|
||||
"text": "Defense \\V[33] Mag.Def \\V[35] Luck \\V[37]"
|
||||
"text": "Defense \\V[33]\nMag.Def \\V[35]\nLuck \\V[37]"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@
|
|||
const align = this.itemTextAlign();
|
||||
this.resetTextColor();
|
||||
this.changePaintOpacity(this.isCommandEnabled(index));
|
||||
this.drawText(this.convertEscapeCharacters(this.commandName(index)), rect.x, rect.y, rect.width, align);
|
||||
this.drawText(this.breakLigatures(this.convertEscapeCharacters(this.commandName(index))), rect.x, rect.y, rect.width, align);
|
||||
};
|
||||
|
||||
Window_GalgeChoiceList.prototype.isCancelEnabled = function() {
|
||||
|
|
|
|||
|
|
@ -56,8 +56,13 @@
|
|||
const pluginName = "TextPicture";
|
||||
let textPictureText = "";
|
||||
|
||||
function breakLigatures(text) {
|
||||
// Insert zero-width non-joiner (U+200C) to prevent missing ligature glyphs (fi, fl, ff, etc.)
|
||||
return text.replace(/f([filt])/g, "f\u200C$1");
|
||||
}
|
||||
|
||||
PluginManager.registerCommand(pluginName, "set", args => {
|
||||
textPictureText = String(args.text);
|
||||
textPictureText = breakLigatures(String(args.text));
|
||||
});
|
||||
|
||||
const _Game_Picture_show = Game_Picture.prototype.show;
|
||||
|
|
@ -96,11 +101,17 @@
|
|||
|
||||
function createTextPictureBitmap(text) {
|
||||
const tempWindow = new Window_Base(new Rectangle());
|
||||
tempWindow.resetFontSettings = function() {
|
||||
this.contents.fontFace = $gameSystem.mainFontFace();
|
||||
this.contents.fontSize = 20;
|
||||
this.resetTextColor();
|
||||
};
|
||||
const size = tempWindow.textSizeEx(text);
|
||||
const pad = 4; // extra pixels on each side to prevent outline clipping
|
||||
tempWindow.padding = 0;
|
||||
tempWindow.move(0, 0, size.width, size.height);
|
||||
tempWindow.move(0, 0, size.width + pad * 2, size.height + pad * 2);
|
||||
tempWindow.createContents();
|
||||
tempWindow.drawTextEx(text, 0, 0, 0);
|
||||
tempWindow.drawTextEx(text, pad, pad, 0);
|
||||
const bitmap = tempWindow.contents;
|
||||
tempWindow.contents = null;
|
||||
tempWindow.destroy();
|
||||
|
|
|
|||
Loading…
Reference in a new issue