17 May 2009

Simple Font Draw

As the title suggests, this is a simple routine for redefining fonts, such as name, size, bold, italic, etc. Although this was written in RMXP, it should also work in RMVX. The default format for manipulating fonts is:

self.contents.font.name = "Font Name"
self.contents.font.size = 22

and so on.

But there is a way to merge the different properties into one procedure by adding the following to Window_Base:
# * Draw font status
#     bold    : Bold on/off
#     italic  : Italic on/off
#     size    : Font size
#     color   : Font color
def draw_font(bold, italic, size, color)
  # Check bold on/off
  case bold
  when 0
    self.contents.font.bold = false
  when 1
    self.contents.font.bold = true
  # Check italic on/off
  case italic
  when 0
    self.contents.font.italic = false
  when 1
    self.contents.font.italic = true
  # Change Color
  case color
  when 0
    self.contents.font.color = system_color
  when 1
    self.contents.font.color = normal_color
  when 2
    self.contents.font.color = Color.new(255, 255, 255, 255)
  # Font size
  self.contents.font.size = size
Whenever fonts need to be "drawn", something like this would be called in RGSS when the font and its properties are called:

draw_font(1, 0, 22, 1)

This would result in bold 22-size font, set at the default "System Color" (also predefined in the Window_Base).

Other properties can easily be added using the same method. Anything predefined in this way is used as a template for all windows, including the Status and menu screens.

0 Comments So Far:

Post a Comment

Related Posts with Thumbnails
Template Design "Perfect World" by SkinCorner