• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM 1.4.1772-draw_text_ext BUG

Radio

Member
After update the 1.4.1772.I found the draw_text_ext could not wrap newline correctly with chinese character.How to fix it?Thanks!
2222222.png
44444.png
333333.png
 
Last edited:

Qual

Member
It's looks like draw text ext doesnt split the string if there is no space, as it's a single word.
 

rwkay

GameMaker Staff
GameMaker Dev.
I can confirm that draw_text_ext is expecting spaces at word breaks - please file a bug with the specific strings you are seeing (we had not considered chinese and eastern languages when it was designed). In the meantime add a few spaces into the chinese text where the linebreaks should be on roll your own code to measure the strings and add the spaces at the correct locations.

Russell
 

RangerX

Member
What?
Didn't you guy said you just reverted a change made to that function in the release notes? You said it would be back to old behavior (aka needing a space)
 

Radio

Member
I can confirm that draw_text_ext is expecting spaces at word breaks - please file a bug with the specific strings you are seeing (we had not considered chinese and eastern languages when it was designed). In the meantime add a few spaces into the chinese text where the linebreaks should be on roll your own code to measure the strings and add the spaces at the correct locations.

Russell
Thanks, I already report the bug.In fact the chinese not need space,each character just like the word in English.In GMS2 and GMS1 Previous version.The draw_text_ext works fine.Please fix it soon.

And now I edit a script to warp chinese for now.
Code:
///draw_txt_warp(x,y,txt,sep,w);
var xx,yy,vtxt,vsep,vww,vth,vhh;
vth=0;
xx=argument0;
yy=argument1;
vtxt=argument2;
vsep=argument3;
vww=argument4;
vhh=string_height(vtxt);
vlen=string_length(vtxt);
var i=1;
var j=1;
repeat vlen{
    var vcut = string_copy(vtxt,1,j);
    if i==vlen{
        draw_text(xx,yy+vth,vtxt);
        vth+=vsep;
    }else if string_width(vcut)>vww{
        var vj=max(1,j-1);
        vcut = string_copy(vtxt,1,vj);
        draw_text(xx,yy+vth,vcut);
        vtxt = string_delete(vtxt,1,vj);
        vth+=vsep;
        j=0;
    }
    i+=1;
    j+=1;
}
return vth;
 

Mike

nobody important
GMC Elder
All wrapping is based on spaces as a word break. If you have none or just want to wrap on characters, then you just need to loop and print the number of characters per line that will fit.
 
F

fromjune

Guest
Thanks, I already report the bug.In fact the chinese not need space,each character just like the word in English.In GMS2 and GMS1 Previous version.The draw_text_ext works fine.Please fix it soon.

And now I edit a script to warp chinese for now.
Code:
///draw_txt_warp(x,y,txt,sep,w);
var xx,yy,vtxt,vsep,vww,vth,vhh;
vth=0;
xx=argument0;
yy=argument1;
vtxt=argument2;
vsep=argument3;
vww=argument4;
vhh=string_height(vtxt);
vlen=string_length(vtxt);
var i=1;
var j=1;
repeat vlen{
    var vcut = string_copy(vtxt,1,j);
    if i==vlen{
        draw_text(xx,yy+vth,vtxt);
        vth+=vsep;
    }else if string_width(vcut)>vww{
        var vj=max(1,j-1);
        vcut = string_copy(vtxt,1,vj);
        draw_text(xx,yy+vth,vcut);
        vtxt = string_delete(vtxt,1,vj);
        vth+=vsep;
        j=0;
    }
    i+=1;
    j+=1;
}
return vth;
this bug also cause me a lot of trouble
thank you very much, the script works very well if there are not too many lines
really solve my problem
 
G

Gibibit

Guest
This broke Turmoil pretty badly.


That's quite a lot of code to change and probably some preprocessing for a sudden spec change (in a minor update). Can't you make it into a seperate function?

EDIT: of course I'll just keep building with an older version but this was quite the unpleasant surprise nevertheless. Also I'd hate to miss out on future bugfixes because of this spec change.
 
Last edited by a moderator:

Mike

nobody important
GMC Elder
Wrapping based on simple character length (where there are no spaces) can be done easily by the user. Just get the width of each character and add it on until it gets to the end of the window - print that, then wrap. Word wrap (based on a space separator) is a little more complicated which is why it's built in.

EDIT: Also... just to clarify, we wrap on ASCII space character 32 (0x20). I know there are "other" space characters higher up in the UNICODE range, but we don't check for them.
 
Last edited:

Flaick

Member
Apologize if I resume this dead post. Is there a way to solve the problem without writing a custom script? I'm considering to manually put some white spaces.
 

renex

Member
Apologize if I resume this dead post. Is there a way to solve the problem without writing a custom script? I'm considering to manually put some white spaces.
putting whitepsace in is the easiest approach. you can also programmatically iterate through characters in the string, while checking for the width, and if the width exceeds the maximum, insert whitespace.
 
Top