| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 0 |  
| 积分 | 1 |  
| 经验 | 1811 |  
| 最后登录 | 2014-2-3 |  
| 在线时间 | 15 小时 |  
 Lv1.梦旅人 
	梦石0 星屑50 在线时间15 小时注册时间2010-6-17帖子19 | 
| 本帖最后由 天帝·隳 于 2010-6-22 09:19 编辑 
 LZ的意思是使用Fonts文件里面的字体,只要打开游戏就能够使用,不需要玩家手动安装字体么?
 
 建议先在最开始定义一个模块,内容如下(假设有三个字体,分别为"迷你简黑体", "华文琥珀", "方正卡通简体",而三个字体文件分别对应Fonts中的字体文件名:"mljht.ttf", "hwhp.ttf","fzktjt.ttf"):
 然后把最后的Main脚本段变成:复制代码module System_Fonts 
  Font_Type = {"迷你简黑体" => "mljht.ttf",
             "华文琥珀" => "hwhp.ttf",
             "方正卡通简体" => "fzktjt.ttf"}
  def self.font_use(font_name, font_chn_name)
    $font_input = 0
    font = Win32API.new('gdi32','AddFontResourceA','p','L')
    sendmsg = Win32API.new('user32','SendMessageA','l,l,l,l','L')
    unless Font.exist?("#{font_chn_name}")
      $font_input += 1
      font.call("Fonts/#{font_name}")
      sendmsg.call(65535,29,0,0)
    end
  end
end
不过这里有一个小小的问题,就是第一次点开游戏的时候,只会黑一下就消失了(因为刚初始化了字体),第二次就正常了。复制代码begin
   for font in System_Fonts::Font_Type.keys
     System_Fonts.font_use(System_Fonts::Font_Type[font] ,font)
   end
   exit if $font_input != 0
   Font.default_name = (["迷你简黑体"])
   Graphics.freeze
   $scene = Scene_Title.new
   while $scene != nil
     $scene.main
   end
   Graphics.transition(20)
rescue Errno::ENOENT
   filename = $!.message.sub("No such file or directory - ", "")
   print("找不到文件 #{filename}。 ")
end
 | 
 |