Author Topic: Question regarding fonts  (Read 1257 times)

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Question regarding fonts
« on: August 30, 2012, 09:41:30 AM »
I got couple questions regarding fonts :

1. Who provide them ? Windows or RTP ?
2A. If provided by windows, I just want to confirm : to use it, just type the name of the font registered in windows font right ?
2B. If not provided by windows, how to embed custom font ?
3. Is there any fixed-width font I could use ? fixed width just like in notepad, where 'i' and 'X' occupy same pixel in width
4. Regarding question no.3, the point I'm asking that is how to find text length in a line ? not length number of characters in digit instead, length in pixel
5. What is the text that guaranteed available on any windows version supported in RMXP

Number 4 is the most important. Currently, my script using the maximum characters algorithm to determine line length limit, but it could easily messed by combination of different kinds of fonts and size. These are to complete my work on custom message script. Thanks in advance  :D
« Last Edit: August 30, 2012, 09:50:49 AM by azdesign »
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20016
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Question regarding fonts
« Reply #1 on: August 30, 2012, 09:51:17 AM »
1. Windows.
2A. Technically yes.
2B. You can include the font file in your game (make sure to check the font license if you are actually allowed to!), but you have to make sure the user installs the font somehow before running the game.
3. Those are called "monospace" fonts. There are plenty of them. One of the most popular (often used in programming) is "Courier New".
4. You can do that in RMXP. Call Bitmap#text_size and you will get a Rect instance with the dimensions which the text will occupy if rendered. It does not include bold/italic modifiers.
5. I'm not sure if I understand the question, but every Windows has the font Arial installed.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Re: Question regarding fonts
« Reply #2 on: August 30, 2012, 10:01:50 AM »
Thank you!  :D
Yay I definitely gonna try this out!
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Re: Question regarding fonts
« Reply #3 on: August 30, 2012, 10:57:34 AM »
It seems that I have to modify bitmap class methods to include validation about text width. Where can I find Bitmap source (and other built-in classes source for future reference) ? RGSS manual only mention its methods and usage.  :???:
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20016
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Question regarding fonts
« Reply #4 on: August 30, 2012, 11:12:24 AM »
This works just fine if you don't have a bitmap class at hand:

Code: [Select]
Bitmap.new(1, 1).text_size("TEXT GOES HERE").width
If you do, just use the existing one.

Code: (e.g.) [Select]
self.contents.text_size("TEXT GOES HERE").width
The Bitmap source is not available (as it was written in C/C++) and you can't really modify the existing methods either.

Also, please don't double post within 24 hours. There is a "Modify" button in the top right corner of every post.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Re: Question regarding fonts
« Reply #5 on: August 30, 2012, 11:22:55 AM »
Thanks  :haha:, I'll keep that double post in mind
I request bitmap source 'cos I seen something like :

Code: [Select]
class Bitmap
  alias old_draw_text draw_text
  def draw_text(*args)
    args.each_index {|i|
      args[i] = Localization.scan(args[i]) if args[i].is_a?(String) }
    old_draw_text(*args)
  end
end

I just want to know what are the actual codes to draw_text, blt, etc so I can learn how they actually works. Manual doesn't provide them  :)
« Last Edit: August 30, 2012, 11:25:48 AM by azdesign »
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: Question regarding fonts
« Reply #6 on: August 30, 2012, 10:08:48 PM »
That method is part of the underlying engine. The actual Bitmap#draw_text method is coded in C++, not Ruby. Ruby just allows you to alias the method and overwrite it. Tons of Add-Ons has examples on how to do this. Look at the Add-On "Simple Shaded Text".