GMS 2 long Jap text not cut to new line

Discussion in 'Programming' started by saga55555, Aug 7, 2018.

  1. saga55555

    saga55555 Member

    Joined:
    Aug 14, 2016
    Posts:
    38
    Hi, I have problem with Japanese text. My English text work fine but Jp not cut to new line when it longer than length limit. Both texts use the same code.
    JP text use font_add to store .tff to global.variable when start game. I try to use this font to draw Eng, still no problem. Only draw JP.
    Code:
    txt = instance_create(argument2,argument3,obj_text);
    with (txt)
    {
        padding = 20;
        maxlength = __view_get( e__VW.WView, 0 )-580;
        text = argument0;
        spd = argument1;
        font = global.jap_font;
        
        text_length = string_length(text);
        font_size = font_get_size(font);    
        draw_set_font(font);
        
        text_width = string_width_ext(string_hash_to_newline(text),font_size+(font_size/2), maxlength);
        text_height = string_height_ext(string_hash_to_newline(text),font_size+(font_size/2), maxlength);
    }
    
    Here result image of Eng/JP dialogue link : https://imgur.com/a/L6A4b9u
    Anyone know the cause and how to fix? Thank you :D
     
  2. saga55555

    saga55555 Member

    Joined:
    Aug 14, 2016
    Posts:
    38
    No one know the cause? Help me plzzzzzzzz :(
     
  3. Rob

    Rob Member

    Joined:
    Jul 12, 2016
    Posts:
    681
    I wonder if it's because you're using a font you made.

    You could try modifying the code by using string_width for your variable "text_length" to see if that helps.
     
  4. Tsa05

    Tsa05 Member

    Joined:
    Jun 21, 2016
    Posts:
    560
    Having trouble locating the problem because none of the code here performs text wrapping or text drawing.
    (I do notice that you are using string_hash_to_newline, though...if your text has manually inserted line breaks in it then it's behaving as intended...)
     
  5. saga55555

    saga55555 Member

    Joined:
    Aug 14, 2016
    Posts:
    38
    Thank you for your reply. I just have time to test it and nothing change.
    Maybe problem isn't come from code but gms doesn't know with word should break to new line in Japanese.
    I tested and it randomly break some sentence that have (space bar) near max_length. Seem like I have to line break manually D:
     
  6. saga55555

    saga55555 Member

    Joined:
    Aug 14, 2016
    Posts:
    38
    Thank you for your respond and sorry that I forgot to show my draw code. I using draw_text_ext.
    I decided to line break manually now anyway.
     
  7. Adriano_ppaula

    Adriano_ppaula Member

    Joined:
    Jun 22, 2017
    Posts:
    25
    Hello everyone! :)
    I am having the same problem, but in my case there is no way to break the line manually because all the dialogs of my game are linked in a single system, I would have to rewrite all the dialogs :(

    Is there any other way to fix this problem? I using draw_text_ext.
     
    Last edited: Sep 9, 2019
  8. Adriano_ppaula

    Adriano_ppaula Member

    Joined:
    Jun 22, 2017
    Posts:
    25
    Could anyone help me?
     
  9. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,742
    Manually insert linebreaks on the string after reading it, but BEFORE drawing it:
    upload_2019-9-10_22-4-32.png
    (intentionally posting a screenshot so you at least gotta type this thing out for yourself, maybe learning a thing or two in the process)

    Also, please start your own topics instead of hijacking old ones that has been dead for half a year and also has a different issue than you.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice