You can use mine.
#==============================================================================
# Scene_Title
#==============================================================================
Fontfiles = [
'Impressed.ttf',
'Future.ttf',
'Papyrus.ttf',
'CopperPlate-Normal.ttf',
'Brush.ttf',
'Geometrix.ttf',
'LED_REAL.ttf',
'EurostileExtended-Roman-DTC.ttf'
]
Fontnames = [
'Impressed',
'Future',
'Papyrus',
'CopperPlate-Normal',
'Brush Script',
'Geometrix',
'LED Real',
'EurostileExtended-Roman-DTC'
]
class Scene_Title
alias main_ifa_later main
def main
font = CP.fonts_load
CP.data_save(font)
unless font
str = ENV['SystemRoot'].sub('WINNT', '')
win = ENV['SystemRoot'].dup.sub(str, '')
if win == 'WINNT'
p 'The game found a possible problem while initializing the ' +
'font installer. Please install these fonts manually if problems occur.'
end
install = Win32API.new('gdi32', 'AddFontResource', ['P'], 'L')
acknowledge_WINDOZE = Win32API.new('kernel32', 'WriteProfileString', ['P'] * 3, 'L')
acknowledge_user = Win32API.new('user32', 'SendMessage', ['L'] * 4, 'L')
_SourceF = 'Fontfiles\\'
_WINFonts = ENV['SystemRoot'] + '\\Fonts\\'
succeeded, failed, missing = [], [], []
Fontfiles.each_index {|i|
font = Fontfiles[i]
if FileTest.exists?(_SourceF + font)
if FileTest.exists?(_WINFonts + font) &&
FileTest.size(_WINFonts + font) == FileTest.size(_SourceF + font)
next
end
FileUtils.copy(_SourceF + font, _WINFonts + font)
install.call(_SourceF + font)
acknowledge_WINDOZE.call('Fonts', Fontnames[i], font)
acknowledge_user.call(0xFFFF, 0x001D,0,0)
if FileTest.exists?(_WINFonts + font)
succeeded.push(Fontnames[i])
else
failed.push(font)
end
else
missing.push(font)
end}
succeeded_fonts = succeeded[0]
(1...succeeded.size).each {|i| succeeded_fonts += ', ' + succeeded[i]}
unless succeeded_fonts == nil
p "Installed following fonts: #{succeeded_fonts}"
end
failed_fonts = failed[0]
(1...failed.size).each {|i| failed_fonts += ', ' + failed[i]}
unless failed_fonts == nil
p "Could not install following fontfiles: #{failed_fonts}" +
'. Please install these fonts manually.'
end
missing_fonts = missing[0]
(1...missing.size).each {|i| missing_fonts += ', ' + missing[i]}
unless missing_fonts == nil
p "Could not find following fontfiles: #{missing_fonts}"
end
unless succeeded_fonts == nil
p 'New fonts were installed. Restarting the game now. If you ' +
'experience any problems, please manually install the fonts by ' +
"copying the font files located in #{_SourceF}" +
" folder into your #{_WINFonts} folder and/or restaring your PC."
Thread.new {system('Game')}
exit
end
end
main_ifa_later
end
end
Just define font filenames and font names on top. All your fontfiles should be located in a folder called "Fontfiles" in the game's main folder. Keep in mind that I don't officially support this script as I made it for my own game only.
You need Fileutils as well.
I did not make Fileutils. (But I think that I did remove the stuff I don't need because I don't remember it being that short. o.o; )
#
# = fileutils.rb
#
# Copyright (c) 2000-2005 Minero Aoki <aamine@loveruby.net>
#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
#
# == module FileUtils
#
module FileUtils
def self.private_module_function(name) #:nodoc:
module_function name
private_class_method name
end
OPT_TABLE = {} #:nodoc: internal use only
def copy(src, dest, options = {})
fu_check_options options, :preserve, :noop, :verbose
fu_output_message "cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
return if options[:noop]
fu_each_src_dest(src, dest) do |s, d|
copy_file s, d, options[:preserve]
end
end
module_function :copy
OPT_TABLE['copy'] = %w( noop verbose preserve )
def fu_check_options(options, *optdecl) #:nodoc:
h = options.dup
optdecl.each do |name|
h.delete name
end
raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
end
private_module_function :fu_check_options
def fu_each_src_dest(src, dest) #:nodoc:
fu_each_src_dest0(src, dest) do |s, d|
raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
yield s, d
end
end
private_module_function :fu_each_src_dest
def fu_each_src_dest0(src, dest) #:nodoc:
if src.is_a?(Array)
src.each do |s|
s = s.to_str
yield s, File.join(dest, File.basename(s))
end
else
src = src.to_str
if File.directory?(dest)
yield src, File.join(dest, File.basename(src))
else
yield src, dest.to_str
end
end
end
private_module_function :fu_each_src_dest0
def fu_same?(a, b) #:nodoc:
if fu_have_st_ino?
st1 = File.stat(a)
st2 = File.stat(b)
st1.dev == st2.dev && st1.ino == st2.ino
else
File.expand_path(a) == File.expand_path(b)
end
rescue Errno::ENOENT
return false
end
private_module_function :fu_same?
def fu_have_st_ino? #:nodoc:
!fu_windows?
end
private_module_function :fu_have_st_ino?
def copy_file(src, dest, preserve = false, dereference = true)
ent = Entry_.new(src, nil, dereference)
ent.copy_file dest
ent.copy_metadata dest if preserve
end
module_function :copy_file
module StreamUtils_
private
def fu_windows?
/mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
end
def fu_copy_stream0(src, dest, blksize) #:nodoc:
# FIXME: readpartial?
while s = src.read(blksize)
dest.write s
end
end
def fu_blksize(st)
s = st.blksize
return nil unless s
return nil if s == 0
s
end
def fu_default_blksize
1024
end
end
include StreamUtils_
extend StreamUtils_
class Entry_ #:nodoc: internal use only
include StreamUtils_
def initialize(a, b = nil, deref = false)
@prefix = @rel = @path = nil
if b
@prefix = a
@rel = b
else
@path = a
end
@deref = deref
@stat = nil
@lstat = nil
end
def copy_file(dest)
st = stat()
File.open(path(), 'rb') {|r|
File.open(dest, 'wb', st.mode) {|w|
fu_copy_stream0 r, w, (fu_blksize(st) || fu_default_blksize())
}
}
end
def copy_metadata(path)
st = lstat()
File.utime st.atime, st.mtime, path
begin
File.chown st.uid, st.gid, path
rescue Errno::EPERM
# clear setuid/setgid
File.chmod st.mode & 01777, path
else
File.chmod st.mode, path
end
end
def stat
return @stat if @stat
if lstat() && lstat().symlink?
@stat = File.stat(path())
else
@stat = lstat()
end
@stat
end
def lstat
if dereference?
@lstat ||= File.stat(path())
else
@lstat ||= File.lstat(path())
end
end
def dereference?
@deref
end
def path
if @path
@path.to_str
else
join(@prefix, @rel)
end
end
end
end