Question regarding fonts

Started by azdesign, August 30, 2012, 03:41:30 am

Previous topic - Next topic

azdesign

August 30, 2012, 03:41:30 am Last Edit: August 30, 2012, 03:50:49 am by azdesign
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
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Blizzard

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 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


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

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

azdesign

Thank you!  :D
Yay I definitely gonna try this out!
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

azdesign

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/ ~

Blizzard

This works just fine if you don't have a bitmap class at hand:

Bitmap.new(1, 1).text_size("TEXT GOES HERE").width


If you do, just use the existing one.

Code: e.g.
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 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


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

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

azdesign

August 30, 2012, 05:22:55 am #5 Last Edit: August 30, 2012, 05:25:48 am by azdesign
Thanks  :haha:, I'll keep that double post in mind
I request bitmap source 'cos I seen something like :

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  :)
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

G_G

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".