GML A baguette problem: special characters and non-breaking spaces (SOLVED)

Discussion in 'Programming' started by Braisque, Mar 16, 2019.

  1. Braisque

    Braisque Member

    Joined:
    Jul 11, 2016
    Posts:
    20
    There seems to be little to no documentation about this subject: in some European languages, there's something called "non breaking space" (dec = 160, uni = U+00A0). At some point in a phrase, there are spaces that shouldn't allow what's after to be on the next line.

    Unfortunatly, GameMaker just ignores these non-breaking spaces. Despite my font including non-breaking spaces, and the font range in gamemaker set to allow the dec 160 (the non-breaking space).

    Is there a way to, somehow, implement a space that doesn't break line?

    Thank your for reading :)
     
  2. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,628
    You'll probably have to do a manual split if draw_text_ext is ignoring nonbreaking spaces. Replace nonbreaking spaces with a special symbol, like "_" then split individual words to an array by looping over the string. Loop through your array, replace the special symbol with space in each word you pick, then use string_width on it to count up towards you maximum line width. When that width is exceeded, go down a line and zero the counter.

    Another way would be to draw your own pixel font. Use some special character for your nonbreaking space again, but in the sprite it would be empty. GM will not split the words because it doesn't see a space in your string, but sprite will assign a subimage to it that is space.
     
    Braisque likes this.
  3. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    301
    I'd be with @NightFrost on that one, make a custom sprite font and use something like % or $ as special character which would refer to an empty sprite frame, and put that character where you want a non-line-breaking space.
    Hope you and your stuff are going well, bro!
     
    Braisque likes this.
  4. Braisque

    Braisque Member

    Joined:
    Jul 11, 2016
    Posts:
    20
    Well, I've solved it. You were right, I had to modify an existing font. Although it might be useful to point out the fact that the "non breaking space" char do exists. It's just that fonts are transformed into textures by gamemaker. And since the non breaking space is a "blank" char, the place it occupies in the texture page is removed by the gamemaker program so there is no empty space on texture page.

    What I did was, for my fellow baguette and my European friends using a language that is not adapted to the Internet, is that: I downloaded fontforge (an open software to edit glyphs). I imported the font I wanted to use and changed the 160th dec from the font (the normal decimal for the non-breaking space font). Since, if you remove everything to let it blank (as it is by default), Gamemaker will remove it on the texture page, I had to draw 2 points with a special tool. That tool draws a line between 2 points. But I didn't connect them. Those two points were left unconnected each on an opposite side of the glyph. AND SOMEHOW, despite that the glyph is still blank, it WORKED, Gamemaker didn't remove the space in the texture page... I don't quite get how it works, but it works.

    Thank you for guiding me on the right path.
     

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