Moghunter's Battle HUD and Victor SFonts issue

So, I have an issue with Moghunter's Battle HUD script and with Victor's SFonts.

I needed to make the character's name uses the SFont too.

I found this thread that managed to solve the solution.
https://forums.rpgmakerweb.com/index.php?threads/victor-sfonts-as-default-font.81420/

However, I'm unsure of what are the arguments used for Victor's SFont script.

This is the method to draw the text using SFont, I assume.
Code:
def draw_sfont_text(*args)
    is_rect = args[0].is_a?(Rect)
    x      = is_rect ? args[0].x      : args[0]
    y      = is_rect ? args[0].y      : args[1]
    width  = is_rect ? args[0].width  : args[2]
    height = is_rect ? args[0].height : args[3]
    text   = is_rect ? args[1].to_s   : args[4].to_s
    align  = is_rect ? args[2]        : args[5]
    bitmap = sfont.draw_text(text)
    x += width - bitmap.width       if align == 2
    x += (width - bitmap.width) / 2 if align == 1
    y += (height - bitmap.height) / 2 - 4
    blt(x, y, bitmap, bitmap.rect)
  end

This is Moghunter's original method to draw the name.
Code:
@name.bitmap.draw_text(0,0,160,32,@actor.name,NAME_ALIGN_TYPE)

And lastly, my failed method so far to draw the name text using SFonts.
Code:
@name.bitmap.draw_sfont_text(0,0,160,32,@actor_name,0)

This is the error that occurs when I started the battle test.
upload_2019-3-11_1-30-44.png


Line 201 gives me this:
Code:
bitmap = sfont.draw_text(text)

Would anyone give me a pointer on what I did wrong?

Since you need help with existing scripts, I've moved this to Script Support.

bump
bump again
It's missing that sfont variable for some reason.
Try to set the VE_ALL_SFONT setting to true, that should make all windows use the sfont drawing method.

If for some reason you don't want all windows to use the sfont drawing method, you will have to manually create that variable for the window you are working in.
You can do so by using this line:
Code:
contents.sfont = $sfont[0]
You have to place this in the window's create_contents method, after the original parts. Something like this:
Spoiler
Code:
  def create_contents
    super
    contents.sfont = $sfont[0] # This will make that missing variable.
  end
If the window got no such method defined yet, just add the above code anywhere into the window class.
If the window already has that method defined, you can either add in the marked line directly there from above, or alias the method and add the line that way.
Ohh, and this all assumes that Moghunter's script draws those names on windows and not on sprites (on their bitmap, more specifically) directly. If they are drawn on sprites, you will have to replace the contents part of that code line with self.bitmap, and you will have to add that line somewhere where the bitmap is already set up.

For the record, your draw_sfont_text method is correct, you don't have to change anything there.
Alright, I followed your advice, and what do you know.
It actually worked!
Thanks so much for the help.
Mods, you can close the thread now.
upload_2019-3-14_17-36-0.png

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/moghunters-battle-hud-and-victor-sfonts-issue.106651/