1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

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:
    927
    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