1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 string_height returns wrong value?

Discussion in 'Programming' started by TheBroman90, Feb 13, 2019 at 3:28 PM.

  1. TheBroman90

    TheBroman90 Member

    Joined:
    Jun 20, 2016
    Posts:
    351
    I'm making a colission mask for my menu buttons, based on their string size.

    Code:
    draw_set_font(font);
    var width = string_width(text);
    var height = string_height(text);
    When I'm using Arial the colission mask works, but when I use the pixel font bellow the height is wrong.
    Why is it not working?

    [​IMG]
     
    Last edited: Feb 13, 2019 at 5:08 PM
  2. Guitarmike

    Guitarmike Member

    Joined:
    Jun 30, 2018
    Posts:
    30
    Are you drawing on the GUI layer?
     
  3. TheBroman90

    TheBroman90 Member

    Joined:
    Jun 20, 2016
    Posts:
    351
    Yes I am.
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,046
    Draw in the normal draw event and check the box size.

    But kinda looks like the font's properties were incorrectly set in the font itself.
     
  5. Edwin

    Edwin Member

    Joined:
    Jul 15, 2018
    Posts:
    204
    Code:
    var height = string_height(text)/2;
    
     
  6. Bayesian

    Bayesian Member

    Joined:
    Sep 13, 2016
    Posts:
    363
    I think this is the same issue as this. Try a different font.
     
  7. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    3,610
    What version of GMS are you using?

    If GMS 2 there was a font update in the recent 2.2.2 beta, so it might be worth trying that to see if the issue still occurs. If so report it as a bug.
     
  8. TheBroman90

    TheBroman90 Member

    Joined:
    Jun 20, 2016
    Posts:
    351
    I tried another font and got a more accurate collision mask. Still not perfect though. But I guess there's something wrong with the font itself.

    [​IMG]
     
  9. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,046
    Did you get the font from a website? If so, what font and site?

    There are two lines in a font's data, one near the top and one near the bottom. I think string_get_height() just goes off those two lines for most fonts.
     
  10. Siolfor the Jackal

    Siolfor the Jackal Member

    Joined:
    Jun 21, 2016
    Posts:
    558
  11. TheBroman90

    TheBroman90 Member

    Joined:
    Jun 20, 2016
    Posts:
    351
    Edwin likes this.
  12. Edwin

    Edwin Member

    Joined:
    Jul 15, 2018
    Posts:
    204
  13. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,046
  14. Edwin

    Edwin Member

    Joined:
    Jul 15, 2018
    Posts:
    204
  15. TheBroman90

    TheBroman90 Member

    Joined:
    Jun 20, 2016
    Posts:
    351
    I edited the font range to only include letters and digits, but there's still extra space above.
     
  16. Edwin

    Edwin Member

    Joined:
    Jul 15, 2018
    Posts:
    204
    Font is broken or you need to finish it in font editor.
     
    TheBroman90 likes this.

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