/*: * @target MZ * @plugindesc Automatically scales icons in text (\I[x]) to match the current font size. * @author 1x1x1x1 * * @help * This plugin overrides the default processDrawIcon function. * Instead of drawing icons at 32x32, it detects the current line height * (font size) and scales the icon down to fit perfectly inline. */ (() => { Window_Base.prototype.processDrawIcon = function(iconIndex, textState) { if (textState.drawing) { const iconWidth = ImageManager.iconWidth; const iconHeight = ImageManager.iconHeight; const bitmap = ImageManager.loadSystem("IconSet"); const pw = iconWidth; const ph = iconHeight; const sx = (iconIndex % 16) * pw; const sy = Math.floor(iconIndex / 16) * ph; // Calculate the scale based on the text line height // We subtract 2 pixels for a little breathing room/padding const targetSize = textState.height - 2; // Center the icon vertically in the line const yOffset = (textState.height - targetSize) / 2; this.contents.blt( bitmap, sx, sy, pw, ph, // Source coordinates (32x32) textState.x, // Destination X textState.y + yOffset,// Destination Y (centered) targetSize, targetSize // Destination Size (Scaled) ); } // Advance the text cursor by the width of the scaled icon + padding textState.x += textState.height; }; })();