• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Resource icon

How to change fonts in your scripts 2018-12-06

Hi there! Have you ever wanted to change your font for a specific thing in your game, like the summary screen? It's actually pretty easy, so here's how to do it:

First, go to your SpriteWindow script and copy the code referring to def pbDrawTextPositions(bitmap,textpos) and paste it two lines under.
Ruby:
Expand Collapse Copy
def pbDrawTextPositions(bitmap,textpos)
  for i in textpos
    textsize=bitmap.text_size(i[0])
    x=i[1]
    y=i[2]
    if i[3]==true || i[3]==1 # right align
      x-=textsize.width
    elsif i[3]==2 # centered
      x-=(textsize.width/2)
    end
    if i[6]==true || i[6]==1 # outline text
      pbDrawOutlineText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    else
      pbDrawShadowText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    end
  end
end

def pbDrawTextPositions(bitmap,textpos)
  for i in textpos
    textsize=bitmap.text_size(i[0])
    x=i[1]
    y=i[2]
    if i[3]==true || i[3]==1 # right align
      x-=textsize.width
    elsif i[3]==2 # centered
      x-=(textsize.width/2)
    end
    if i[6]==true || i[6]==1 # outline text
      pbDrawOutlineText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    else
      pbDrawShadowText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    end
  end
end

Now change the name of def pbDrawTextPositions(bitmap,textpos) to something you'll remember like def pbDrawSummaryText(bitmap,textpos)

If you want to change the font make sure you have the .ttf in your fonts folder and add bitmap.font.name = "Font name here" under textsize=bitmap.text_size(i[0]) and if you'd like to change the size you can add bitmap.font.size = # under that.

Then you'll need to go to PScreen_Load
Ruby:
Expand Collapse Copy
module FontInstaller
  # filenames of fonts to be installed
  Filenames = [
     'pkmnem.ttf',
     'pkmnemn.ttf',
     'pkmnems.ttf',
     'pkmnrs.ttf',
     'pkmndp.ttf',
     'pkmnfl.ttf'
  ]   
  # names (not filenames) of fonts to be installed
  Names = [
    'Power Green',
    'Power Green Narrow',
    'Power Green Small',
    'Power Red and Blue',
    'Power Clear',
    'Power Red and Green'
  ]
and make it look more like this
Ruby:
Expand Collapse Copy
module FontInstaller
  # filenames of fonts to be installed
  Filenames = [
     'pkmnem.ttf',
     'pkmnemn.ttf',
     'pkmnems.ttf',
     'pkmnrs.ttf',
     'pkmndp.ttf',
     'pkmnfl.ttf',
     '(File name).ttf'
  ]   
  # names (not filenames) of fonts to be installed
  Names = [
    'Power Green',
    'Power Green Narrow',
    'Power Green Small',
    'Power Red and Blue',
    'Power Clear',
    'Power Red and Green',
    '(Font name)'

Lastly go to your PScreen_Summary script and change pbDrawTextPositions(bitmap,textpos) to def pbDrawSummaryText(bitmap,textpos) (or whatever you named it) and it should show the font and/or font size that you changed it to!

First, go to your DrawText script and copy the code referring to def pbDrawTextPositions(bitmap,textpos) and paste it two lines under.
Ruby:
Expand Collapse Copy
def pbDrawTextPositions(bitmap,textpos)
  for i in textpos
    textsize = bitmap.text_size(i[0])
    x = i[1]
    y = i[2]
    if i[3]==true || i[3]==1 # right align
      x -= textsize.width
    elsif i[3]==2 # centered
      x -= (textsize.width/2)
    end
    if i[6]==true || i[6]==1 # outline text
      pbDrawOutlineText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    else
      pbDrawShadowText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    end
  end
end

def pbDrawTextPositions(bitmap,textpos)
  for i in textpos
    textsize = bitmap.text_size(i[0])
    x = i[1]
    y = i[2]
    if i[3]==true || i[3]==1 # right align
      x -= textsize.width
    elsif i[3]==2 # centered
      x -= (textsize.width/2)
    end
    if i[6]==true || i[6]==1 # outline text
      pbDrawOutlineText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    else
      pbDrawShadowText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5])
    end
  end
end

Now change the name of def pbDrawTextPositions(bitmap,textpos) to something you'll remember like def pbDrawSummaryText(bitmap,textpos)

If you want to change the font make sure you have the .ttf in your fonts folder and add bitmap.font.name = "Font name here" under textsize=bitmap.text_size(i[0]) and if you'd like to change the size you can add bitmap.font.size = # under that.

Then, for both 16.2 and 17.2, you'll need to go to PScreen_Load
Ruby:
Expand Collapse Copy
module FontInstaller
  # filenames of fonts to be installed
  Filenames = [
     'pkmnem.ttf',
     'pkmnemn.ttf',
     'pkmnems.ttf',
     'pkmnrs.ttf',
     'pkmndp.ttf',
     'pkmnfl.ttf'
  ]   
  # names (not filenames) of fonts to be installed
  Names = [
    'Power Green',
    'Power Green Narrow',
    'Power Green Small',
    'Power Red and Blue',
    'Power Clear',
    'Power Red and Green'
  ]
and make it look more like this
Ruby:
Expand Collapse Copy
module FontInstaller
  # filenames of fonts to be installed
  Filenames = [
     'pkmnem.ttf',
     'pkmnemn.ttf',
     'pkmnems.ttf',
     'pkmnrs.ttf',
     'pkmndp.ttf',
     'pkmnfl.ttf',
     '(File name).ttf'
  ]   
  # names (not filenames) of fonts to be installed
  Names = [
    'Power Green',
    'Power Green Narrow',
    'Power Green Small',
    'Power Red and Blue',
    'Power Clear',
    'Power Red and Green',
    '(Font name)'


Lastly go to your PScreen_Summary script and change pbDrawTextPositions(bitmap,textpos) to def pbDrawSummaryText(bitmap,textpos) (or whatever you named it) and it should show the font and/or font size that you changed it to!


2018-12-05_12-53-40.gif

You shouldn't have any issues if you follow the instructions, it's pretty easy to do. Would love to see some more custom summary screens now ^^
Credits
@Michael helped me with this one, no credits necessary but if you want to you can credit us.
Author
Invatorzen
Views
1,358
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from Invatorzen

Back
Top