Error in drawing numbers

I have a small script by Mithran which I have to post here as there is no thread for it, and it doesn't show up in his posting activity.
Spoiler: Script by Mithran
Code:
# add xparams to equip status window
# example script by Mithran at forums.rpgmakerweb.com
# Terms of Use: use as you see fit (learn, edit, repost, commercial allowed)
module Vocab
  XPARAM = # xparam terms
  ["HIT", # 0 HIT  HIT rate
  "EVA", # 1 EVA  EVAsion rate
  "CRI",# 2 CRI  CRItical rate
  "CEV", # 3 CEV  Critical EVasion rate
  "MEV",  # 4 MEV  Magic EVasion rate
  "MRF",# 5 MRF  Magic ReFlection rate
  "CNT", # 6 CNT  CouNTer attack rate
  "HRG",# 7 HRG  Hp ReGeneration rate
  "MRG", # 8 MRG  Mp ReGeneration rate
  "TRG",# 9 TRG  Tp ReGeneration rate
  ]
  def self.xparam(param_id)
    XPARAM[param_id]
  end
end

class Window_EquipStatus
  XPARAM_DISPLAY_MULT = true # if true, multiply xparam as %
  FONT_SIZE = 21 # font point size of this window
  SKIP_XPARAMS = [7, 8] # skip drawing these xparams
  alias initialize_setfont initialize
  # making a copy of the origina method so it can be used in the redefinition
  def initialize(*args)
    initialize_setfont(*args) # calling original method
    if FONT_SIZE
      contents.font.size = FONT_SIZE # setting custom font size
      refresh # redrawing window
    end
  end
 
  alias refresh_drawxparam refresh
  def refresh
    refresh_drawxparam
    off = 0
    10.times {|i| # 10 times, one for each number of xparams
    if SKIP_XPARAMS.include?(i) # if this xparam is to be omitted
      off += 1 # increase offset variable so there are no gaps in drawing
      next # skip drawing and move onto the next one
    end
    draw_item_ex(0, line_height * (7 + i - off), i) # draw item calls all other draw methods
    }
  end
  
  def draw_item_ex(x, y, param_id)
    # calls all seperate draw methods, see below
    # this method basically passes the origin of where each item should be drawn
    draw_xparam_name(x + 4, y, param_id)
    draw_current_xparam(x + 94, y, param_id) if @actor
    draw_right_arrow(x + 126, y)
    draw_new_xparam(x + 150, y, param_id) if @temp_actor
  end
 
  def draw_xparam_name(x, y, param_id) # draw the parameter name
    change_color(system_color)
    draw_text(x, y, 80, line_height, Vocab.xparam(param_id))
  end
 
  def draw_current_xparam(x, y, param_id) # draw current value of xparam
    change_color(normal_color)
    text = !XPARAM_DISPLAY_MULT ? sprintf("%0.2f", @actor.xparam(param_id)) : "#{(@actor.xparam(param_id) * 100).to_i}%"
    draw_text(x, y, 32, line_height, text, 2)
  end
 
  def draw_new_xparam(x, y, param_id)
    new_value = @temp_actor.xparam(param_id)
    change_color(param_change_color(new_value - @actor.xparam(param_id)))
    text = !XPARAM_DISPLAY_MULT ? sprintf("%0.2f", new_value) : "#{(new_value * 100).to_i}%"
    # above line - get text to be drawn.  if using display mult, multiply value
    # by 100 and add a percent sign instead of displaying the decimal
    # if not, display two decimal values with a leading zero
    draw_text(x, y, 32, line_height, text, 2)
  end
 
  def window_height
    344 # default of Graphics.height minus the help window's height
    # calculating this dynamically would require redefining a few other methods
  end
 
  def line_height
    return FONT_SIZE if FONT_SIZE # if font size is set, use it for line height
    super # if not set, use the default value
  end

end

class Scene_Equip
 
  def create_item_window
    # redefining this and using math to put the item window in the correct place
    wx = @status_window.width
    wy = @slot_window.y + @slot_window.height
    ww = Graphics.width - @status_window.width
    wh = Graphics.height - wy
    @item_window = Window_EquipItemCompact.new(wx, wy, ww, wh)
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.status_window = @status_window
    @item_window.actor = @actor
    @item_window.set_handler(:ok,     method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
    @slot_window.item_window = @item_window
  end
end

class Window_EquipItemCompact < Window_EquipItem
  # compact version of the equip item window with one column
  def col_max
    1
  end
end

What it does is add exparams to the equip screen. It does that without a problem. However, there is something about the way the numbers are drawn that means when there are three characters (in this example "99%") the left side of the first digit is slightly cut off. Changing the size of the font does not alter this.
upload_2018-5-23_13-5-19.png



I think this can be solved by inserting a space before where the digits are actually drawn, but I have no idea whereabouts in the script that is done. (I'm making that assumption because that was the cure for a similar problem with a Yanfly script. The solution can be seen in this post.)

Can anyone tell me where to make the edit and exactly what I should do?

Thanks.
It looks like it is not allocating enough space for the numbers. You may need to tweak the numbers in these lines:

draw_current_xparam(x + 94, y, param_id) if @actor
draw_right_arrow(x + 126, y)
draw_new_xparam(x + 150, y, param_id) if @temp_actor

Try replacing 94 with say 78, 126 with 118 and 150 with 144. See if that helps.
@bgillisp That moves the whole column left, but still leaves the numbers clipped.
Ok, so it is somewhere else that is setting number size. I'll have to look more.

Edit: Ok, it is this code which draws the text, the previous code just states where to draw it. So some kind of edit is needed here:

def draw_current_xparam(x, y, param_id) # draw current value of xparam
change_color(normal_color)
text = !XPARAM_DISPLAY_MULT ? sprintf("%0.2f", @actor.xparam(param_id)) : "#{(@actor.xparam(param_id) * 100).to_i}%"
draw_text(x, y, 32, line_height, text, 2)
end

It looks to me the edit is needed on the 32. Does anything happen if we change the 32 to 40? Does it fix it, or does it just stretch it out with the same error?
@bgillisp I could see no discernable difference, even when I upped the edit to 50, or took it down to 24 (just as an experiment)
Ok, that eliminates that idea, though if it did work it would only fix the first set of numbers, not the second as those are different codes. The last idea I have is to try to edit this line in the same area:

text = !XPARAM_DISPLAY_MULT ? sprintf("%0.2f", @actor.xparam(param_id)) : "#{(@actor.xparam(param_id) * 100).to_i}%"

Try changing the sprintf("%0.2f" part to sprintf(" %0.2f" that should add a space to the front. See if that helps. And see what it does to the first column, as this code only affects that, but if it does work then we can edit the other columns too.
@bgillisp I had high hopes for this suggestion as it is similar to the Yanfly fix, but sadly, nope, does nothing.
Ok, I have to admit I'm stumped now. Sorry. I'll post more if I find another idea that might work.
@bgillisp But your last suggestion did prompt something which is, in fact, the solution.
Further along that same line is the bit:
"#{(@actor.xparam(param_id) * 100).to_i}%"

Working on the same logic, I inserted a space so that it became
" #{ etc
And then did the same on the other instance which draws the comparison column.
Problem solved.

upload_2018-5-23_14-44-8.png


So thank you very much for directing me to that line. I can now look at my Equip Screen with an unjaundiced eye.
Have you tried changing the 32's on these lines? The width of the column itself looks to be about 32px - maybe that will increase it? 😅

draw_text(x, y, 32, line_height, text, 2)

EDIT: Nevermind - you got it!
@IAmJakeSauvage That was bgillisp's first thought as well. But as you've seen, the solution lay elsewhere .

Original thread: https://forums.rpgmakerweb.com/threads/error-in-drawing-numbers.95621/