1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 [SOLVED} Font Size - How do I enlarge fonts?

Discussion in 'Programming' started by EricR175, Jan 12, 2017.

Tags:
  1. EricR175

    EricR175 Guest

    Hello,

    This is only my second post so far since starting to use Gamemaker Studio 2, which I love. I'm trying to learn as much as I can without help so that I remember things that I discover. I always find that if you discover things on your own, you will remember better.

    However, I want to draw text, which I already know how to do :), but I also want to manipulate the size of the font. I know all of the font functions like color and draw, however, is there a way to size the font?

    I know it will only draw basic fonts from the computer unless I include a font which needs permission from the font owner.

    Do I have to use number sprites and do more coding? I'm pretty sure that I can code it to use sprites as numbers but I would rather just use arial.
     
  2. ZeDuval

    ZeDuval Member

    Joined:
    Jun 20, 2016
    Posts:
    118
    You need to add the font with the specific size to the resource tree individually for every size you want to use(as far as I know?!).
    Let's say you want Arial 10,12 and 14, add the 3 fonts to your project and name them fn_arial10, fn_arial12,...
    In the beginning of your game, initialize a global var:
    Code:
    global.current_font = "fn_arial"; // string
    Create 2 scripts:
    Code:
    /// draw_set_font_ext(font,size) // string,real
    global.current_font = "fn_"+argument[0];
    if argument_count==2 draw_set_size(argument[1]);
    
    Code:
    /// draw_set_size(size) // real
    var font = asset_get_index(global.current_font+string(argument0));
    if font_exists(font){
      draw_set_font(font);
      return true;
    }
    
    Then you can use it like this in the Draw event:
    Code:
    draw_set_font_ext("arial",10);
    draw_text(32,32,"Small");
    draw_set_size(14);
    draw_text(32,64,"Large");
    
    The idea isn't perfect or finished but it's a start to build on and meant more as an inspiration. ;) I still need to finish and release an extension of mine based on this concept + bold, italic,...
     
    Samwiz1 likes this.
  3. Tornado

    Tornado Member

    Joined:
    Sep 9, 2016
    Posts:
    478
  4. EricR175

    EricR175 Guest

    Thank you I will try them both and see which works.
     
  5. EricR175

    EricR175 Guest

    Tornado, that worked well. Thanks!
     
  6. Samwiz1

    Samwiz1 Guest


    Hi. I found this page because i had a similar problem, and because i'm trying to get textbox text to change fontsize even while it's still printing i thought i'd give it a shot. But this is a GMS2 thread, and there's no draw_set_size string?...
    If you could clarify on that or maybe point me in the direction of how to get that in my gamemaker 2 i'd appreciate it, because i need what you typed to work :p
     
  7. BaBiA Game Studio

    BaBiA Game Studio Member

    Joined:
    Jun 20, 2016
    Posts:
    872
    If you read that post a bit closer you will see that the "draw_set_size" is a script that they have clearly shown in the post you quoted. @ZeDuval even shows exactly what you need to do to get it to work: create 3 fonts at different sizes, then create the scripts and then use them in the Draw Event.
     
  8. Samwiz1

    Samwiz1 Guest

    Ah. That makes sense. Sorry for the misunderstanding.
     

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