赞 | 0 |
VIP | 11 |
好人卡 | 0 |
积分 | 1 |
经验 | 21393 |
最后登录 | 2016-5-11 |
在线时间 | 476 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 476 小时
- 注册时间
- 2011-3-22
- 帖子
- 46
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 muyumuyulnny 于 2013-1-28 14:52 编辑
有一个英文脚本,它不适用正常的字体而是用以下脚本来定义字体
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
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
能否在其中加入一个可使用中文的字体?因为这是一个系列的脚本,它的窗口里都是用的
@content[index].bitmap.bitmap_font(4,6,@commands[index], 'FE7_Text','White')
@lv_hp.bitmap.bitmap_font(0, 16, 'HP', 'FE7_TextL', 'Yellow')
之类的语句来写的,一旦把'HP'改成'生命'它就完全不能显示了。
其实我以前有问过的,可是一直到过期都没人理我... ...所以本着锲而不舍的精神再问一次。 |
|