Phileas' Text Wrap (MZ automatic text break (word wrap) in the message)

Plugin name: Phileas's Text Wrap

Author: Phileas

Version: 1.1.7 for MZ

Release date:
1.0.0 - 2023.July.02
1.1.7 - 2025.July.27

Plugin description:
The plugin adds a line break to the text in such a way that the text does not go beyond the borders of the window.
The plugin works automatically for message windows and the TAA_BookMenu plugin.

The text is carried over by words. That is, it is impossible for one half of a word to be on one line and the other half on the next. The whole word will be moved to a new line. This is how word wrapping works in Windows Notepad and many other places. This way, the text will look neat.
The plugin may not work well if some word is wider than the dialog box. But it is unlikely that anyone in their right mind would use such words in practice.

Plugin Command: getWrappedText
This command will allow you to write the processed text to a variable.

Feature of the plugin: the text color setting (\C[x]) is saved when the line is moved. Even if the new line is displayed in another window (which often happens when transferring text in the message window).
The same applies to the text size setting (\FS[x]).

Code

License

MIT, all responsibility is on the user.

Compatibility:
If there are any problems, write to me.
Updated to version 1.0.1.
Fixed a bug: the plugin did not work if the TAA_BookMenu plugin was not installed.
Now my plugin works both with and without it.

I forgot to write one conditional statement. I bring my sincere regrets, I am very ashamed of this (

See the first message of the topic.

UPD: slightly improved the behavior when using the TAA_BookMenu plugin. Now window standard padding is taken into account.
I noticed that I did not explain the principle of the plugin and its main feature well. Therefore, I added the following to the description above:
The text is carried over by words. That is, it is impossible for one half of a word to be on one line and the other half on the next. The whole word will be moved to a new line. This is how word wrapping works in Windows Notepad and many other places. This way, the text will look neat.
The plugin may not work well if some word is wider than the dialog box. But it is unlikely that anyone in their right mind would use such words in practice.
YOU ARE MY SAVIOR, thanks for saving my life.
I dont know, why rpg maker don't make this one as basic function =_=a
1.1.0
Messages no longer flicker if the text is split into several pages.
1.1.1
  • The number of lines of text that can be displayed in the window is dynamically determined. Fixes a bug with a blinking face if there are not 4 lines.
  • The rest of the text is no longer lost if there are not 4 lines.
  • I added the same feature for the \FS control character as for \C: if a line break occurs, the current text size is saved.
1.1.1
  • The number of lines of text that can be displayed in the window is dynamically determined. Fixes a bug with a blinking face if there are not 4 lines.
  • The rest of the text is no longer lost if there are not 4 lines.
  • I added the same feature for the \FS control character as for \C: if a line break occurs, the current text size is saved.

This seems helpful, but I'm not sure how to adjust the text box size. Changing the text width in System 2 or the text width in the actual getWrapped code doesn't work, and it always seems to wrap just a letter or two too late every time. Not sure if it's an issue with the font or text box size or what but no matter what I change, it won't budge. As you can see below, the top text is supposed to end with "recorded picture shows," but the S and part of the W are cut off. I don't know enough js code rn to edit the plugin directly, so any advice?

1744634271683.png
Hi. Please tell me which font you are using and show me how you have configured the System 2 page in the Database.
It would be ideal if you provide a link to a test project with a bug.

​

Hi. Please tell me which font you are using and show me how you have configured the System 2 page in the Database.
It would be ideal if you provide a link to a test project with a bug.

​

Wow, thank you for the quick response! I'm using a custom font, would it be better to just use the default one for now? And then as for System 2, I tried so many different combinations of numbers with the UI size and text width and font size, but nothing seemed to work. This is what it looks like right now from the screenshot I sent.

1744677934811.png


I can try sending a test version of it too but I'm not sure how to do it with a bug as you say since I'm reletively new to this.
I'm using a custom font
Which one exactly? Can you tell me the name or attach the font file?
I can try sending a test version of it too but I'm not sure how to do it with a bug
You can make a small project with one map and one event on it that shows a problem message. Next, upload the archive with the project to any file sharing site.
Which one exactly? Can you tell me the name or attach the font file?

You can make a small project with one map and one event on it that shows a problem message. Next, upload the archive with the project to any file sharing site.
Sure, here's the font file (website doesn't allow WOFF uploads, it looks like):

Yeah, even on a new project, it still does it, and changing font size, textbox width, or GUI scale doesn't seem to fix it in System 2 or the GetWrapped Code menu. You can see on the third line at the end, the letter "r" is still cut off too early, like the word test below it.
45454545.png



here's the test file I think!
1.1.3

Fixed the formation of the final text:
  • All control characters are processed correctly.
  • The maximum line width is determined correctly. The bug could manifest itself with non-standard fonts.
1.1.4

Fixed behavior when using the control characters "\{" and "\}".
1.1.5

Fixed the handling of the control characters \{ and \}, which modify the text size.
1.1.6

Fixed the calculation of the number of lines in the message window, which I broke with the previous update...
1.1.7

Fixed choices display bug. If the long message before the choices was divided into several small ones, then the choices window was displayed after each small message.
Sometimes this just randomly stops working? Like it will work fine in parts but in other dialogue boxes I just can't get it to work at all -- any ideas?

I think I've discovered the bug. The TextWrap tends to "reset" every time a Shop Window is opened. Upon the reset, I need to talk to a NON-SHOP NPC in order to reactivate the text wrap. After that, the textwrap will work until the next shop window is opened... Rinse and repeat.
I think I've discovered the bug. The TextWrap tends to "reset" every time a Shop Window is opened. Upon the reset, I need to talk to a NON-SHOP NPC in order to reactivate the text wrap. After that, the textwrap will work until the next shop window is opened... Rinse and repeat.
Hi! Thank you for reporting the bug. Unfortunately, I haven't been able to reproduce it myself yet. Can you show screenshots of the events or provide a demo project?
Hi! Thank you for reporting the bug. Unfortunately, I haven't been able to reproduce it myself yet. Can you show screenshots of the events or provide a demo project?

Sure -- AFTER a shop window has been opened, the text begins to look like the FIRST image. If I go to talk to a non-shop opening NPC, then the text will reset and work properly. And a Shop-Opening NPC will then correct itself (second image), give the proper wrap around text for the FIRST interaction after I've spoken to a non-shop opening NPC. But once any shop is opened, the text continues to operate like the first image (does NOT wrap) until I once again speak to a non-shop opening NPC. It is particularly noticeable in places like the "Bazaar" where you speak to multiple merchants in a row.

I thought perhaps it was operating in a strange way with NRP_ShopCustomization, another plugin, but it continues to display this behavior even with that plugin turned off.


I have found a fix, albeit it is very annoying to do so. If I manually call this script after EVERY shop-opening scene, then it will work:

"

// force refresh so the very next box uses it

if (SceneManager._scene._messageWindow) {

SceneManager._scene._messageWindow.updatePlacement();

}"


But that's very tedious to add in after every shop opening...

Sorry if this isn't more useful!

Screenshot 2025-08-20 002710.png
Screenshot 2025-08-20 002808.png
@orgint, can you show me a screenshot of the seller's event commands in the editor or give me a link to the demo project?

Original thread: https://forums.rpgmakerweb.com/threads/phileas-text-wrap-mz-automatic-text-break-word-wrap-in-the-message.158894/