Chaos Project

RPG Maker => General Discussion => Topic started by: godsrighthand on June 26, 2009, 10:08:01 am

Title: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 26, 2009, 10:08:01 am
RMXP
--------------------------------------------------
How do i get <subject of post> to work in a game
It must work in messages. ( all other areas like menu etc are optional )
Does the user have to install it??
Is there any message script that can do this??
--------------------------------------------------
the font is " Abaddon "
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Arkaea Halfdemon on June 26, 2009, 10:40:02 am
Blizzard's Ultimate Font Override in Tons of Addons should do the trick. Make sure you include the font in the download folder when you export your project, though.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 26, 2009, 11:21:46 am
so the user still has to install it??
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Aqua on June 26, 2009, 12:15:18 pm
You can get an auto-font installer script.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 26, 2009, 12:43:37 pm
Quote from: Aqua on June 26, 2009, 12:15:18 pm
You can get an auto-font installer script.


i did find one though i did not understand how to use it
http://www.rmxp.org/forums/viewtopic.php?t=2622

it says place it in script directory but scripts are stored in an encrypted format ( RPGXP data )
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 26, 2009, 12:58:50 pm
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
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 26, 2009, 01:18:34 pm
Thanks
If its your script i should have no problem with it :)
Ill try it out first thing in the morning
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 26, 2009, 01:26:55 pm
Lol, no, it's not my first script. It's just a script that I never released. This actually isn't even the exact version I use in my game. In my game the words "the game", etc. in the messages are replaces by "Chaos Project" and there are also German messages. And I'm not running it in Scene_Title, but in Scene_StormTronics. xD
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Hellfire Dragon on June 26, 2009, 03:53:47 pm
QuoteLol, no, it's not my first script.

he never said it was your first script, he said he'll try it first thing in the morning :P
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 26, 2009, 04:16:38 pm
O_o I have no idea how I read "first script".
Title: Re: custom font which is NOT pre-installed in a computer
Post by: fugibo on June 26, 2009, 09:48:49 pm
Quote from: Blizzard on June 26, 2009, 04:16:38 pm
O_o I have no idea how I read "first script".


I do :naughty:

/stops spam
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 26, 2009, 10:50:02 pm
Its not working
in the game no text appears at all

what i did::
I put in abaddon.ttf in "Fontfiles" folder within the main game folder
I inserted your scripts above main (first the fileutils )
I defined the font as abaddon.ttf and the fontname as Abaddon
Then i used ultimate font override and configured it like so
Font.default_name = 'Abaddon' # default font name
Font.default_size = 24      # default font size

PS: what was your first script??
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 27, 2009, 03:02:57 am
Quote from: Blizzard on June 26, 2009, 12:58:50 pm
All your fontfiles should be located in a folder called "Fontfiles" in the game's main folder.


My first script was a credits script. It's been turned into the Picture Scene from Tons later.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Ryex on June 27, 2009, 03:23:05 am
Quote from: godsrighthand on June 26, 2009, 10:50:02 pm
I put in abaddon.ttf in "Fontfiles" folder within the main game folder

did you not see that line
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 27, 2009, 06:17:36 am
>.<

@godsrighthand: Did you use an old save game or did you start a new game? Is the font installed at all? If it's installed, try first deinstalling it manually (just delete it from the WINDOWS\Fonts folder). Try to let the installer install the font. Then try it vice versa. Uninstall the font and install it manually. Maybe something isn't right. i.e. the font might not be called Abbadon. You can check the real font name by opening Paint and trying to use the text tool.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 27, 2009, 08:52:04 am
method 1-manual install, using ultimate font override
method 2-using your script, using ultimate font override
neither work
I get an error message

Script 'TOA 2' line 1208: RGSSError Occured
Failed to create bitmap



Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 27, 2009, 01:19:25 pm
Remove Tons temporarily, another script is messing up something.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 27, 2009, 11:23:02 pm
If i remove tons ( ultimate font override) how do i use the fonts ingame??
Title: Re: custom font which is NOT pre-installed in a computer
Post by: G_G on June 27, 2009, 11:29:21 pm
Quote from: Blizzard on June 26, 2009, 04:16:38 pm
O_o I have no idea how I read "first script".


I read it as that too blizz ;__;
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 28, 2009, 08:25:53 am
Quote from: Blizzard on June 27, 2009, 01:19:25 pm
Remove Tons temporarily, another script is messing up something.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 28, 2009, 09:21:07 am
Quote from: Blizzard on June 28, 2009, 08:25:53 am
Quote from: Blizzard on June 27, 2009, 01:19:25 pm
Remove Tons temporarily, another script is messing up something.



i understand that but if i do that how do i use the font?? I mean if i remove TOA how can i tell RMXP to use a new font?? I dont understand you, please elaborate 
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 28, 2009, 09:24:19 am
Quote from: godsrighthand on June 27, 2009, 08:52:04 am
method 1-manual install, using ultimate font override
method 2-using your script, using ultimate font override
neither work
I get an error message

Script 'TOA 2' line 1208: RGSSError Occured
Failed to create bitmap


This error isn't caused by Tons of Add-ons. Don't you think it would have been faster to simply do it instead of repeatedly questioning? :P
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 28, 2009, 10:59:05 pm
Tried it

RESULT- No error came
            The default font was used

I think the error is with tons
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Blizzard on June 29, 2009, 04:28:44 am
That error came up because a script tried to create a bitmap with 0 width and/or height. As far as I know that has pretty much nothing to do with fonts.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 30, 2009, 02:10:11 am
your right another script is messing up something. i tried other methods to get custom fonts they dont work either. Ill try to find out which script it is
Thanks for your help
Title: Re: custom font which is NOT pre-installed in a computer
Post by: GAX on June 30, 2009, 05:16:38 am
By any chance are you using Vista?

Put simple, Vista's bullshit oversecurity will NOT allow an RMXP script to install fonts.  It's bullshit, I know, but sadly Micro$haft isn't nice to ANYONE.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Aqua on June 30, 2009, 12:10:17 pm
Just run as admin, and everything works fine :P
Title: Re: custom font which is NOT pre-installed in a computer
Post by: Subsonic_Noise on June 30, 2009, 12:21:39 pm
Quote from: Badou Nails on June 30, 2009, 05:16:38 am
By any chance are you using Vista?

Put simple, Vista's bullshit oversecurity will NOT allow an RMXP script to install fonts.  It's bullshit, I know, but sadly Micro$haft isn't nice to ANYONE.

WOW This means I must have some special edition because it worked nice on my PC >.>
Please people, stop dissing Vista, it isn't that bad. In fact, I've been using Vista x64 for some time now
and I never had a virus or a crash or any compatibility problem execept for some freeware programs.
But that also could be because of my special edition. -_-

Sorry for Offtopic but I had to say this.

EDIT: I did not want to insult you, I hope that's clear.
Title: Re: custom font which is NOT pre-installed in a computer
Post by: godsrighthand on June 30, 2009, 11:26:57 pm
If i break any rules I apologize in advance

No i am not using vista
I only use xp and ubuntu
Vista sucks Donkey balls