E
Edwin
Guest
Hello, everyone.
I'm having a quite silly problem; I'll start from the beginning.
I made a drawing text script that gets the tags from string and then converts these tags into new drawing functions. Having this I can't string warp the string regarding the width of it, because it will check not untagged string, so when I delete the tags, it will show me wrong linebreak positions.
String looks like this after using draw_text_tag().
Now when I use string wordwrapping (which just places "#" string every X width in the string), it will look like this:
This is immediately noticeable if the text is large enough.
Script which I'm using string_wordwrap_width() is just slightly modified script taken from this source.
string_insert_tag() is just string_insert() function that ignores tags [colour=], [/colour], etc.
How should I get rid of this problem?
I'm having a quite silly problem; I'll start from the beginning.
I made a drawing text script that gets the tags from string and then converts these tags into new drawing functions. Having this I can't string warp the string regarding the width of it, because it will check not untagged string, so when I delete the tags, it will show me wrong linebreak positions.
String looks like this after using draw_text_tag().
Now when I use string wordwrapping (which just places "#" string every X width in the string), it will look like this:
This is immediately noticeable if the text is large enough.
Script which I'm using string_wordwrap_width() is just slightly modified script taken from this source.
Code:
/// string_wordwrap_width(string,width)
// Declare variables
var pos_space, pos_current, text_current, text_output;
pos_space = -1;
pos_current = 1;
text_current = argument[0];
text_output = "";
// Word wrap
while (string_length(text_current) >= pos_current) {
if (string_width(string_copy(text_current, 1, pos_current)) > argument[1]) {
if (pos_space != -1) {
text_output += string_copy(text_current, 1, pos_space);
text_output = string_insert_tag("#", text_output, string_length(text_output));
text_current = string_copy(text_current, pos_space + 1, string_length(text_current) - (pos_space));
} else {
text_output += string_copy(text_current, 1, pos_current);
text_output = string_insert("#", text_output, string_length(text_output) + 1);
text_current = string_copy(text_current, pos_current + 1, string_length(text_current) - (pos_space));
};
pos_current = 1;
pos_space = -1;
};
if (string_char_at(text_current,pos_current) == " ") {
pos_space = pos_current;
};
pos_current ++;
};
// Finishing the text
if (string_length(text_current) > 0) {
text_output += text_current;
};
// Replacing unnecessary spaces
text_output = string_replace_all(text_output, "# ", "#");
// Return ouput text
return text_output;
How should I get rid of this problem?