class Bitmap
#--------------------------------------------------------------------------
# * Bitmap Font
# x : the x of the starting letter
# y : the y of the starting letter
# text : the text to display
# font : the font to render (optional)
#--------------------------------------------------------------------------
def bitmap_font(x, y, text, font = 'FE7_Text', color = 'White', dash = false)
text = text.to_s
if font == 'Verdana'
# Create the font
font_image = RPG::Cache.picture(font)
# Determine sizing.
char_width = font_image.width / 26
char_height = font_image.height / 3
# Loop through each letter.
text.length.times do |index|
# Get the Byte.
byte = text[index]
# Get Letter
letter = byte.chr
# If it is a letter
if letter =~ /[A-Z]/
iX = (byte - 65) * char_width
iY = char_height
elsif letter =~ /[a-z]/
iX =(byte - 97) * char_width
iY = 0
# If it is a number
elsif letter =~ /[0-9]/
iX = letter.to_i * char_width
iY = 2 * char_height
# Otherwise it's a symbol
else
unless letter == ' ' or letter == ''
# Define the order
order = ['.', ',', '$', '!', '(', ')', '-', '/', '\\', '?', ';',
':', '#', '&', '"', "'"]
iX = (order.index(letter) + 10) * char_width
iY = 2 * char_height
end
end
# If it's not a space, draw it
if letter != ' ' and letter != ""
rect = Rect.new(iX, iY, char_width, char_height)
# Blit it to the screen
self.blt((index * char_width) + x, y, font_image, rect)
end
end
end
if font == 'AWOS'
# Create the font
font_image = RPG::Cache.picture(font)
$placement = 0
# Loop through each letter.
text.length.times do |index|
# Determine sizing.
char_width = 8 #font_image.width / 26
char_height = 12 #font_image.height / 3
# Get the Byte.
byte = text[index]
# Get Letter
letter = byte.chr
# If it is a letter
if letter =~ /[A-Z]/
iX = (byte - 65) * char_width
iY = char_height
if letter == 'W' or letter == 'M'
char_width = 8
elsif letter == 'I'
char_width = 2
else
char_width = 6
end
elsif letter =~ /[a-z]/
iX =(byte - 97) * char_width
iY = 0
if letter == 'a' or letter == 'd' or letter == 'm' or letter == 'v'
char_width = 6
elsif letter == 'w' or letter == 'x' or letter == 'z'
char_width = 6
elsif letter == 'j' or letter == 't'
char_width = 4
elsif letter == 'i' or letter == 'l'
char_width = 2
else
char_width = 5
end
# If it is a number
elsif letter =~ /[0-9]/
iX = letter.to_i * char_width
iY = 2 * char_height
if letter == '1'
char_width = 4
else
char_width = 7
end
# Otherwise it's a symbol
else
unless letter == ' ' or letter == ''
# Define the order
order = ['.', ',', '$', '!', '(', ')', '-', '/', '\\', '?', ';',
':', '#', '&', '"', "'", '+']
iX = (order.index(letter) + 10) * char_width
iY = 2 * char_height
end
if letter == '.' or letter == ':' or letter == "'"
char_width = 2
elsif letter == ',' or letter == '!' or letter == ';'
char_width = 3
elsif letter == '(' or letter == ')' or letter == '-' or letter == '"'
char_width = 4
elsif letter == '#'
char_width = 7
elsif letter == '&'
char_width = 8
else
char_width = 6
end
end
letter == ' ' or letter == "" ? char_width = 3 : nil
# If it's not a space, draw it
if letter != ' ' and letter != ""
rect = Rect.new(iX, iY, char_width, char_height)
# Blit it to the screen
self.blt($placement + x, y, font_image, rect)
end
$placement += char_width
end
end
if font == 'FE7_Text' or font == 'FE7_TextL'
large_text = (font == 'FE7_TextL')
# Create the font
font = 'FE7_Text' + '_' + (color == 'Info2' ? 'Info' : color)
font_image = RPG::Cache.picture(font)
$placement = 0
# Loop through each letter.
text.length.times do |index|
# Determine sizing.
char_width = 8 #font_image.width / 26
char_height = 14 #font_image.height / 3
# Get the Byte.
byte = text[index]
# Get Letter
letter = byte.chr
# If it is a letter
if letter =~ /[A-Z]/
iX = (byte - 65) * char_width
iY = char_height * (large_text ? 3 : 1)
if large_text
char_width = 8
else
if letter == 'W' or letter == 'M' or letter == 'V' or
letter == 'Q' or letter == 'X' or letter == 'Y' or letter == 'T'
char_width = 7
elsif letter == 'I' or letter == 'L'
char_width = 5
else
char_width = 6
end
end
elsif letter =~ /[a-z]/
iX =(byte - 97) * char_width
iY = 0
if letter == 'a' or letter == 'm' or letter == 'v' or
letter == 'w' or letter == 'x'
char_width = 7
elsif letter == 'f' or letter == 'j' or letter == 'r' or letter == 't'
char_width = 5
elsif letter == 'i' or letter == 'l'
char_width = 3
else
char_width = 6
end
# If it is a number
elsif letter =~ /[0-9]/
iX = letter.to_i * char_width
iY = 2 * char_height
if color == 'Info'
char_width = 7
else
char_width = 8
end
# Otherwise it's a symbol
else
unless letter == ' ' or letter == ''
# Define the order
order = ['.', ',', '$', '!', '(', ')', '-', '/', '\\', '?', ';',
':', '#', '&', '"', "'", '+']
iX = (order.index(letter) + 10) * char_width
iY = 2 * char_height
end
if letter == '.' or letter == ':' or letter == "'" or
letter == ',' or letter == ';'
char_width = 3
elsif letter == '(' or letter == ')'
char_width = 5
elsif letter == '"' or letter == '!'
char_width = 5
elsif letter == '#'
char_width = 6
elsif letter == '-'
if color == 'Combat'
char_width = 8
else
char_width = 7
end
#$placement += 1
elsif letter == '$' # Equipped/Experience 'E'
char_width = 8
else
char_width = 7
end
end
(letter == ' ' or letter == "") ? (char_width = 4) : nil
# If it's not a space, draw it
if letter != ' ' and letter != ""
rect = Rect.new(iX, iY, char_width, char_height)
# Blit it to the screen
self.blt($placement + x, y, font_image, rect)
end
$placement += char_width - 1
$placement += 1 if (letter =~ /[A-Z]/ and large_text)
$placement += 1 if (letter =~ /[0-9]/)
$placement += 1 if (letter == '-' and (dash or color == 'Combat'))
$placement += 2 if (letter == '-' and !(dash or (color == 'Combat')))
end
end
if font == 'FE7_Convo'
# Create the font
font = 'FE7_Convo' + '_' + color
font_image = RPG::Cache.picture(font)
$placement = 0
# Loop through each letter.
text.length.times do |index|
# Determine sizing.
char_width = 8 #font_image.width / 26
char_height = 16 #font_image.height / 3
# Get the Byte.
byte = text[index]
# Get Letter
letter = byte.chr
# If it is a letter
if letter =~ /[A-Z]/
iX = (byte - 65) * char_width
iY = char_height
if ['M', 'W', 'X'].include?(letter)
char_width = 8
elsif ['Q', 'S'].include?(letter)
char_width = 7
elsif letter == 'I'
char_width = 4
else
char_width = 6
end
elsif letter =~ /[a-z]/
iX =(byte - 97) * char_width
iY = 0
if letter == 'g'
char_width = 7
elsif ['a', 'm', 'v', 'w', 'x'].include?(letter)
char_width = 6
elsif letter == 'r' or letter == 't'
char_width = 4
elsif letter == 'j'
char_width = 3
elsif letter == 'i' or letter == 'l'
char_width = 2
else
char_width = 5
end
# If it is a number
elsif letter =~ /[0-9]/
iX = letter.to_i * char_width
iY = 2 * char_height
if letter == '1'
char_width = 4
elsif letter == '4'
char_width = 7
else
char_width = 6
end
# Otherwise it's a symbol
else
unless letter == ' ' or letter == ''
# Define the order
order = ['.', ',', '$', '!', '(', ')', '-', '/', '\\', '?', ';',
':', '#', '&', '"', "'", '+', '%']
if !order.include?(letter)
next
end
iX = (order.index(letter) + 10) * char_width
iY = 2 * char_height
end
if ['.', ',', ';', ':', "'"].include?(letter)
char_width = 2
elsif ['!', '(', ')'].include?(letter)
char_width = 3
elsif letter == '-'
char_width = 4
elsif letter == '"' or letter == '+'
char_width = 5
elsif letter == '#'
char_width = 6
elsif letter == '%' or letter == '$' # Equipped/Experience 'E'
char_width = 8
else
char_width = 7
end
end
(letter == ' ' or letter == "") ? (char_width = 4) : nil
# If it's not a space, draw it
if letter != ' ' and letter != ""
rect = Rect.new(iX, iY, char_width, char_height)
# Blit it to the screen
self.blt($placement + x, y, font_image, rect)
end
$placement += char_width
#$placement += 1 if (letter =~ /[A-Z]/ and large_text)
#$placement += 1 if (letter =~ /[0-9]/)
#$placement += 1 if (letter == '-' and (dash or color == 'Combat'))
#$placement += 2 if (letter == '-' and !(dash or (color == 'Combat')))
end
end
end
end