What happens between $gameMessage.add() and Window_Base.processNormalCharacter()?

I'm trying to better understand the process for displaying text messages- so, I'm wondering if somebody more knowledgeable would be kind enough to explain what happens from the time text gets added to the $gameMessage._text array to when it is broken down to a single letter as part of the textState object that gets passed to the Window_Message.contents Bitmap drawText() function.

My questions specifically are:
  1. Where / how are the values textState.height, textState.x, textState.y, textState.index defined?
  2. Would it be possible to intercept the $gameMessage._text array (after it goes through the convertEscapeCharacter(), processEscapeCharacter(), processCharacter() functions) and pass the whole string (not just individual letters) to an external function that outputs a Bitmap that can be placed in the Window_Message.contents instead of going through the Bitmap drawText() / blt() method? Where / at what point would be the best place to do this?
Thanks in advance!
1. Most of the answers to this are found on lines 259-~353 of rpg_windows.
textState.height is defined by the calcTextHeight function found on lines 398 and below of rpg_windows
textState.x is generally just the position as defined by the starting position + textWidth of the current character being drawn.
textState.index is incremented as each character is drawn.
textState.y is generally only incremented and changed when a new line needs to be drawn (see line 333) or when a page needs changing.

2. I don't understand your reasoning for this, as it would still need to draw the full message onto a bitmap. I guess you could hijack (alias) the processNormalCharacter, and processsDrawIcon to draw on a second bitmap that you have somewhere. Regardless though you'd need to draw the characters in some way, unless you have another way of drawing text onto a bitmap. In which case, I think just getting the result of convertEscapeCharacters would be fine? The other ones are used to handle how the text is drawn so they really don't mean much in terms of an actual string. Only to the engines way of drawing text.
1. Most of the answers to this are found on lines 259-~353 of rpg_windows.
textState.height is defined by the calcTextHeight function found on lines 398 and below of rpg_windows
textState.x is generally just the position as defined by the starting position + textWidth of the current character being drawn.
textState.index is incremented as each character is drawn.
textState.y is generally only incremented and changed when a new line needs to be drawn (see line 333) or when a page needs changing.

@Kaliya Thanks! I'll take a gander.
Would you know where $gameMessage._text is detected and a command to draw the Window_Message is fired?

2. I don't understand your reasoning for this, as it would still need to draw the full message onto a bitmap. I guess you could hijack (alias) the processNormalCharacter, and processsDrawIcon to draw on a second bitmap that you have somewhere. Regardless though you'd need to draw the characters in some way, unless you have another way of drawing text onto a bitmap. In which case, I think just getting the result of convertEscapeCharacters would be fine? The other ones are used to handle how the text is drawn so they really don't mean much in terms of an actual string. Only to the engines way of drawing text.

Sorry I should have been more specific- the reasoning is, I have a custom BitmapFont.drawSmallText() that handles the layout of the passed string and renders it to a Bitmap (which I have more control over).

Window_Message:
showtext.PNG


Cutom BitmapFont function:
custombitmap_console.PNG

custombitmap.PNG


But anyway I will pour over your tips and see if I can make it work for me. Thanks again!
OK- sort of got it working based on @Kaliya 's advice. I just can't figure out yet why my first line has a large gap between it and the second line and / or how to adjust the height so that the window cursor / border is closer to the bottom text line:

showtext_fix_00.PNG
Bump...

Can anybody speculate why the line space between my first and second line is taller than the rest of the lines in the dialog box?
showtext_fix_01.PNG

showtext_fix_01_00.png


Thank you 🙂

Original thread: https://forums.rpgmakerweb.com/threads/what-happens-between-gamemessage-add-and-window_base-processnormalcharacter.124086/