Popup Window v1.2d is cut off and I can't figure out why

I've set up 3 different popups with V.M of D.T Popup Window v1.2d. However, it only works for one of them. The others have their popup window being cut off at the side and I spent hours trying to figure out the reason, but I cannot tell what is the problem here.

I have 3 examples that are the same text size and almost the same text lenght but they behave completely differently.

I can't figure out what's wrong here, so please if anyone is able to help me, I highly appreciate.
I also added a Demo below to show the problem.

First Example
Works fine

Code:
pop_up(['1x \i[350]Firestone obtained.',
'Possession  \i[350]\v[25]'],0,268,0)
1.png


Second Example
Window is being cut off at the side

Code:
pop_up(['1x \i[2888]Handle obtained.',
'Possession  \i[2888]\v[30]'],0,268,0)
2.png

Third Example
Window is being cut off at the side

Code:
pop_up(['1x \i[4436]Letter obtained.',
'"The Arrival"'],0,268,0)
3.png


Spoiler: Popup Window v1.2d
Ruby:
#Popup Window v1.2d
#----------#
#Features: Create a popup window for anything you want! How magical!
#
#Usage:    Script calls:
#           (In Events:)
#           pop_up(['text','text', ... ], timer(opt), x(opt), y(opt))
#           (Anywhere else:)
#           Popup.add(['text','text', ... ], timer(opt), x(opt), y(opt))
#
#          Examples:
#           pop_up(['\i[5] Mage class unlocked!!'])
#           pop_up(['\c[16] Class Change:\c[0]',
#                   ' Speak to any mysterious hermit to change class!'],240)
#
#   Escape codes not working? You have two options... switch to '' singe quotes
#    instead of "" double quotes, or double up on \\ slashes.
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email hidden]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
$imported = {} if $imported.nil?
$imported[:Vlue_PopupWindow] = true
 
POPUP_DURATION = 180
 
class Popup_Window < Window_Base
  def initialize(text,timer,x,y)
    super(0,0,25,100)
    text.each do |string|
      temp_string = string.gsub(/\\[^invpgINVPG]\[\d{0,3}\]/) { "" }
      temp_string = temp_string.gsub(/\\i\[\d{0,3}\]/) { icon_width }
      temp_string = convert_escape_characters(temp_string)
      self.width = [text_size(temp_string).width+standard_padding*2+12,self.width].max
    end
    self.height = text.size * line_height + line_height
    if x.nil?
      self.x = Graphics.width / 2 - self.width / 2
    else
      self.x = x
    end
    if y.nil?
      self.y = Graphics.height / 2 - self.height / 2
    else
      self.y = y
    end
    @text = text
    @timer = timer
    create_contents
    refresh
    self.openness = 0
    open
  end
  def icon_width
    size = text_size(' ').width
    ' ' * (24 / size)
  end
  def refresh
    contents.clear
    yy = 0
    @text.each do |string|
      draw_text_ex(0,yy,string)
      yy += line_height
    end
  end
  def update
    super
    @timer -= 1
    close if @timer == 0
  end
end
 
module Popup
  def self.init
    @queue = []
  end
  def self.add(text, timer = POPUP_DURATION, x = nil, y = nil)
    @queue.push([text,timer,x,y])
  end
  def self.queue
    @queue
  end
end
 
Popup.init
 
class Scene_Base
  alias popupwin_preterminate pre_terminate
  alias popupwin_update update
  def update
    popupwin_update
    update_popup_window_text unless $popup.nil?
    return if Popup.queue.empty?
    if $popup.nil? or $popup.close?
      text = Popup.queue.pop
      $popup = Popup_Window.new(text[0], text[1], text[2], text[3])
    end
  end
#~   def update_popup_window_text
#~     $popup.update
#~     $popup.close if Input.trigger?(:C)
#~     if !$popup.disposed? and $popup.close?
#~       $popup.dispose
#~       $popup = nil
#~     end
#~ end
 def update_popup_window_text
    if $popup.disposed?
      $popup = nil
      return
    end
    $popup.update
    $popup.close if Input.trigger?(:C)
    if !$popup.disposed? and $popup.close?
      $popup.dispose
      $popup = nil
    end
  end
 
  def pre_terminate
    popupwin_preterminate
    $popup.visible = false unless $popup.nil?
  end
end
 
class Game_Interpreter
  alias popup_command_355 command_355
  def pop_up(text, timer = POPUP_DURATION, x = nil, y = nil)
    Popup.add(text, timer, x, y)
  end
  def command_355
    popup_command_355
    wait_for_popup #if SceneManager.scene.is_a?(Scene_Map)
  end
  def wait_for_popup
    Fiber.yield while !Popup.queue.empty? || $popup
  end
end
The script accounts for iconsets that has less than 1000 icons.
Line 38 in the script it's looking for a number between 0 and 3 digits long.
Change the 3 to 4 or 5.
4 = icons up to 9999
5 = icons up to 99999

Original thread: https://forums.rpgmakerweb.com/threads/popup-window-v1-2d-is-cut-off-and-i-cant-figure-out-why.169913/