Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: ForeverZer0 on January 08, 2014, 08:46:25 am

Title: [XP] Memory Font Loader
Post by: ForeverZer0 on January 08, 2014, 08:46:25 am
Memory Font Loader
Authors: ForeverZer0
Version: 1.1
Type: Game Utility
Key Term: Game Utility



Introduction

Small script that allows for loading and using fonts into memory at run-time without the need for installing them on the operating system. The advantage of this script over others, such as Wachunga's font-install script, is that it does not require a administrator privileges to use the fonts, nor a restart of the game after running.



Features




Screenshots

None.


Demo

None.


Script

Spoiler: ShowHide

#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Memory Font Loader
# Author: ForeverZer0
# Version: 1.1
# Date: 12.17.2014
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#                             VERSION HISTORY
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# v.1.0   1.8.2014
#   - Original Release
# v.1.1   12.17.2014
#   - Improved compatibility on different systems by adding "AddFontResource"
#     as backup call if "AddFontResourceEx" fails
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#
# Introduction:
#
#   Small script that allows for loading and using fonts into memory at run-time
#   without the need for installing them on the operating system. The advantage
#   of this script over others, such as Wachunga's font-install script, is that
#   it does not require a administrator privileges to use the fonts, nor a
#   restart of the game after running.
#
# Features:
#
#   - Automatically load all fonts found in user-defined folder
#   - Supports TrueType (*.ttf) and OpenType(*.otf) fonts
#   - Does not require Administrator privileges
#   - Does not require a game restart
#
# Instructions:
#   
#   - Place script anywhere above main
#   - Some optional configuration below with explanation
#   - Use the script call "Font.add(PATH_TO_FILE)" to add a font.
#   - If using auto-load, create a folder for the fonts ("Fonts" by default),
#     and place all font files within it. Loading will be done automatically.
#
# Compatibility:
#
#   - No known compatibility issues with any other script.
#
# Credits/Thanks:
#
#   - ForeverZer0, for the script
#   - Duds, for pointing out the "AddFontResource" fix
#
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

#===============================================================================
# ** Font
#-------------------------------------------------------------------------------
# The font class. Font is a property of the Bitmap class.
#===============================================================================
class Font
 
  #-----------------------------------------------------------------------------
  #                            CONFIGURATION
  #-----------------------------------------------------------------------------
 
  # This value (true/false) indicates if all fonts in the specified fonts folder
  # will be automatically loaded when the game is started.
  AUTO_LOAD = true
   
  # Set this to the name of the folder, relative to the game directory, where
  # the font files are contained. This folder will be searched for font files
  # when using the auto-load feature
  FONT_FOLDER = 'Fonts'
 
  #-----------------------------------------------------------------------------
  #                           END CONFIGURATION
  #-----------------------------------------------------------------------------
 
  #-----------------------------------------------------------------------------
  # * Constants
  #-----------------------------------------------------------------------------
  WM_FONTCHANGE = 0x001D
  HWND_BROADCAST = 0xFFFF
  AddFontResource = Win32API.new('gdi32', 'AddFontResource', ['P'], 'L')
  AddFontResourceEx = Win32API.new('gdi32', 'AddFontResourceEx', 'PLL', 'L')
  SendMessage = Win32API.new('user32', 'SendMessage', 'LLLL', 'L')
  SendNotifyMessage = Win32API.new('user32', 'SendNotifyMessage', 'LLLL', 'L')
  #-----------------------------------------------------------------------------
  # * Class Variables
  #-----------------------------------------------------------------------------
  @@memory_fonts = []
  #-----------------------------------------------------------------------------
  # * Load font(s) into memory
  #     filename  : Full path to font file. Accepts multiple filenames.
  #-----------------------------------------------------------------------------
  def self.add(*filenames)
    filenames.each {|f|
      next if @@memory_fonts.include?(f)
      if AddFontResourceEx.call(f, 16, 0) > 0 || AddFontResource.call(f) > 0
        @@memory_fonts.push(f)
      end
    }
    SendNotifyMessage.call(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
    SendMessage.call(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
  end
  #-----------------------------------------------------------------------------
  # * Automatically seach and load all font files found in the font folder.
  #-----------------------------------------------------------------------------
  def self.auto_load
    dir = FONT_FOLDER == '' ? Dir.pwd : File.join(Dir.pwd, FONT_FOLDER)
    return unless File.directory?(dir)
    files = Dir.glob(File.join(dir, '*.{ttf,otf}'))
    self.add(*files)
  end
end

# Load fonts if using auto-load
if Font::AUTO_LOAD
  Font.auto_load
end



Instructions

Place script anywhere above main. Some optional configuration and instructions within the script.


Compatibility

No known compatibility issues, should have been solved with version 1.1.  


Credits and Thanks




Author's Notes

Please feel free to ask for support, post bugs, or anything else. Enjoy!
Title: Re: [XP] Memory Font Loader
Post by: Blizzard on January 08, 2014, 09:25:01 am
I love you.
Title: Re: [XP] Memory Font Loader
Post by: PhoenixFire on January 08, 2014, 09:30:56 am
   I currently have absolutely no use for this, but now that this exists, I may just change the fonts in my game so that I can use this  :^_^':
Title: Re: [XP] Memory Font Loader
Post by: Zexion on January 08, 2014, 03:21:53 pm
... Words cannot describe how much I love you right now :P
Nice job F0! I'm sure that there will be tons of use of this script!
Title: Re: [XP] Memory Font Loader
Post by: Jamal XVI on January 21, 2014, 11:08:05 am
So i tested and it didn't work.I've just pasted the script and put a code 'Font.default_name = "Font Name"', but it won't work,
What should i do?
Thanks,
Jamal XVI
Title: Re: [XP] Memory Font Loader
Post by: ForeverZer0 on January 21, 2014, 11:39:10 am
Make sure the name of the font is correct. The name of the font and the filename are not always the same.

Try with this (https://dl.dropboxusercontent.com/u/20787370/RMXP/slant.ttf), I have confirmed that this name is the same. Simply use the name "Slant".
Title: Re: [XP] Memory Font Loader
Post by: Jamal XVI on January 21, 2014, 12:41:38 pm
The same problem.Something must be wrong.
Look at this code:
module GTBS
  #=============================================================#
  #                       ENGINE SETTINGS                       #
  #=============================================================#
  def self.font
    return "slant"#Fonts::Names[0]
  end
end

and the main
begin
  #intalar_fonts
  $data_configuracoes = Configuracoes.new
  # Prepare for transition
  GMRK::API.disable_sys_key(1)
  Graphics.freeze
  # Make scene object (title screen)
  $scene = Scene_Perfis.new
  Font.default_name = GTBS::font  #############################################Here#################################
  Font.default_size = 22
  Font.default_bold = true
  # Call main method as long as $scene is effective
  while $scene != nil
    $scene.main
  end
  # Fade out
  Graphics.transition(20)
rescue Errno::ENOENT
  # Supplement Errno::ENOENT exception
  # If unable to open file, display message and end
  filename = $!.message.sub("No such file or directory - ", "")
  print("Unable to find file #{filename}.")
end

i wondering why it didn't work.Hope you can help me   :)
Thanks,
Jamal XVI
Title: Re: [XP] Memory Font Loader
Post by: ForeverZer0 on January 21, 2014, 12:58:34 pm
Does it work in a new project, as in a blank new project, without any added scripts?
Title: Re: [XP] Memory Font Loader
Post by: KK20 on January 21, 2014, 01:07:56 pm
Shouldn't that be GTBS.font?
Title: Re: [XP] Memory Font Loader
Post by: Jamal XVI on January 21, 2014, 01:08:38 pm
Quote from: ForeverZer0 on January 21, 2014, 12:58:34 pm
Does it work in a new project, as in a blank new project, without any added scripts?

A new project main
#==============================================================================
# Main
#------------------------------------------------------------------------------
# Após o final de cada definição de classe o processo principal
# do jogo é iniciado. Esta é a classe principal do jogo.
#==============================================================================

begin
 
 # É definida aqui a fonte usada nas janelas do jogo
 # Você pode usar aqui qualquer fonte disponível em seu computador
 # Porém é recomendável usar fontes padrão do Windows
 # Por exemplo: Arial, Lucida Console, Tahoma, Verdana...
 
 $defaultfonttype = $fontface = $fontname = Font.default_name = "Slant"
 # É definido aqui o tamanho da fonte usada nas janelas de jogo
 # O tamanho padrão é 25. Porém, você pode usar o tamanho que você
 # achar melhor para seu sistema e fonte
 
 $defaultfontsize = $fontsize = Font.default_size = 22
 
 # É preparada uma transição de tela
 
 Graphics.freeze
 
 # Aqui é chamada a tela título do jogo. O script padrão
 # de título é 'Scene_Title'. Você pode mudá-lo, mas isso não é
 # recomendável
 
 $scene = Scene_Title.new
 
 # É definida a limitação efetiva da variável $scene.
 # Se esta é nula, é chamado o método principal
 
 while $scene != nil
   $scene.main
 end
 
 # A transição de tela é executada
 
 Graphics.transition(20)
rescue Errno::ENOENT
 
 # Aqui, definimos a mensagem padrão para Errno::ENOENT
 # Quando não é possível abrir um arquivo, a mensagem é exibida
 
 filename = $!.message.sub("Arquivo não encontrado - ", "")
 print("O Arquivo #{filename} não foi encontrado.")
end

Results: ShowHide
So i put a print in the method self.auto_load and the result was:
(http://imagizer.imageshack.us/v2/800x600q90/713/zelo.png)
so i started the game and...
(http://imagizer.imageshack.us/v2/800x600q90/841/d1nf.png)

I can't imagine what problem making this, but it wont work.
Thanks,
Jamal XVI
Title: Re: [XP] Memory Font Loader
Post by: ForeverZer0 on January 21, 2014, 02:54:24 pm
Strange.
I will have to see if maybe there is some issue with WinXP, or perhaps something else I am missing.
Title: Re: [XP] Memory Font Loader
Post by: Jamal XVI on January 24, 2014, 08:16:01 am
So i got the problem.
The font name "slant.ttf" has to be the name name of the font "Slant" as the same in RGGS,but the font name is case sensitive to.
Then the file name must be "Slant.ttf" and in RGSS the font name must be "Slant"
Thanks,
Jamal XVI
Title: Re: [XP] Memory Font Loader
Post by: Zexion on January 24, 2014, 03:16:44 pm
Here's a tip, doesn't always work but will for the most part. In your system fonts folder, double click the font in question and it should say the fonts real name inside. A lot of font files are named one thing but are actually something else. A file like "sans bold" could actually be called "sanserif bold" and rgss won't pick it up.
Title: Re: [XP] Memory Font Loader
Post by: PrinceEndymion88 on April 14, 2014, 09:54:38 pm
I've added the Joystix Monospace.ttf font into Fonts folder and into UMS script I've edited
@font = "Arial"
into
@font = "Joystix Monospace"
but I can't see the font when I play the game... where I'm wrong?
Title: Re: [XP] Memory Font Loader
Post by: Zexion on April 15, 2014, 01:43:31 am
I think it might be related to the post I made above you. The font is named Joystix Monospace.ttf  but the real font probably has a different name like joystix mono.
Double click it and read where it says Font Name:
Title: Re: [XP] Memory Font Loader
Post by: PrinceEndymion88 on April 15, 2014, 04:07:40 am
I had already checked out, the real name is Joystix Monospace.
(http://i58.tinypic.com/ztvy1u.png)
Nome tipo carattere = Font Name (in italian  :haha:)
Title: Re: [XP] Memory Font Loader
Post by: Dust on May 24, 2014, 03:42:33 am
Doesn't work for me too, sadly :/ I tried it with the Slant-font aswell, even renaming it and trying other fonts, but the font won't be loaded. I'm using Windows 8.1 by the way.
Title: Re: [XP] Memory Font Loader
Post by: ForeverZer0 on May 24, 2014, 06:39:32 am
I think it does have something to do with the new "upgrade" that is Windows 8.
I wrote the script under Windows 7, and now that I have remade a switch back to Windows 8, it is not working for me either.  AddFontResourceEx is executing correctly, but using SendMessage with the broadcast is failing, returning a generic error code of "1", which doesn't explain much other than "I did not work".

I will take a look into it soon when I get a chance. One more reason Windows 8 sucks.
Just out of curiosity, are you running the game in compatibility mode or anything? That shouldn't be a problem, but may help track down the cause of the error.
Title: Re: [XP] Memory Font Loader
Post by: orochii on May 24, 2014, 06:23:23 pm
I don't care if this script works (well, actually I do, but...). I love this kind of scripts where I don't get a shit of how does it works. I can imagine, and I could probably, like, write it later from scratch (it's pretty short anyway). Because the idea is pretty simple (though I still don't understand why the SendMessage command is used, something about a protocol?). But as in "thought that it could be done this way", nope. Not without a lot of research, and there is where the beautifulness of this code is. As in, how the hell did you came up with this solution xD.

This is wizardry!
Title: Re: [XP] Memory Font Loader
Post by: Blizzard on May 25, 2014, 04:12:29 am
Quote from: orochii on May 24, 2014, 06:23:23 pm
(though I still don't understand why the SendMessage command is used, something about a protocol?).


You need to let the running apps in the OS know "hey, dudes, there's a new kid font on the block". SendMessage() does exactly that.
Title: Re: [XP] Memory Font Loader
Post by: Dust on May 25, 2014, 07:22:02 am
Quote from: ForeverZer0 on May 24, 2014, 06:39:32 am
I will take a look into it soon when I get a chance. One more reason Windows 8 sucks.
Just out of curiosity, are you running the game in compatibility mode or anything? That shouldn't be a problem, but may help track down the cause of the error.


It would be reaaally great if you could get this to work c: And no, I'm not running the Game.exe or RPG Maker itself in compatibility mode
Title: Re: [XP] Memory Font Loader
Post by: Cremno on May 25, 2014, 11:22:37 am
I don't know exactly why it doesn't work, but it's neither the fault of the (unnecessary) SendMessage call nor Windows 8. Does it work for you or someone else? It doesn't even work for me under the good old Windows XP SP3.

By the way, it works if you write your own Game.exe.
Title: Re: [XP] Memory Font Loader
Post by: ForeverZer0 on May 25, 2014, 01:27:32 pm
Yes, SendMessage should most definitely be used.

http://msdn.microsoft.com/en-us/library/aa911393.aspx

Quote from: MSDNRemarks

An application that adds or removes fonts from the system (for example, by using the AddFontResource or RemoveFontResource function) should send this message to all top-level windows.
To send the WM_FONTCHANGE message to all top-level windows, an application can call the SendMessage function with the hwnd parameter set to HWND_BROADCAST.


I am hardly going to rewrite Game.exe just to load a font from memory, that is ludicrous.

I only think that it could be the fault of Win 8 due to the fact that it worked perfectly for me before making a switch from Win7 to Win8, though it is obviously unconfirmed at this point.
Title: Re: [XP] Memory Font Loader
Post by: Cremno on May 25, 2014, 01:48:26 pm
AddFontResource != AddFontResourceEx (especially with FR_PRIVATE)

I think RGSS1 has an internal font list which is initialized at start and that's why calling AddFont* functions don't work afterwards.
Title: Re: [XP] Memory Font Loader
Post by: Heretic86 on October 10, 2014, 05:10:24 am
Methinks time for Blizz to step in...

I cant get this to work either.  Renaming fonts, case sensitive, spaces, putting ".ttf" in the name, and this box is XP-SP3.  I monkeyed with the scripts, but even after its there, using Font.exist?(name) I get nada.  AddFontResourceEx.call returns 1 so it says the font is loaded into memory.  Fantastic idea, and already implemented into VXA apparently, just can not get it to work.  Only thing I could find that was relevant was this:

https://github.com/Ancurio/mkxp

Way over my head...
Title: Re: [XP] Memory Font Loader
Post by: Blizzard on October 10, 2014, 06:33:57 am
Try AddFontResourceExA(), that's probably the reason. Using just AddFontResourceExW() will cause problems because of wide-chars.
Title: Re: [XP] Memory Font Loader
Post by: Heretic86 on October 10, 2014, 01:36:31 pm
Still no luck.  Ex, ExA, ExW, no Ex, my brain just keeps coming up short.
Title: Re: [XP] Memory Font Loader
Post by: ForeverZer0 on October 10, 2014, 03:51:50 pm
I have yet to find a pattern to what works definitely and what does not. I do believe it has SOMETHING to do with the OS, but I cannot even say that for sure.

@heretic:
Just for a test, run the game as admin and see if has something to do with permissions or not. I have had success and not being an admin, put it could possibly be a combination of OS and UAC.
Title: Re: [XP] Memory Font Loader
Post by: Heretic86 on October 11, 2014, 04:45:57 am
Still doesnt work as Administrator either.

However, I do use a program for my VPN called PIA (Private Internet Access) and when I set it up and my firewall complained about it, it is also Ruby based, so not sure if that could somehow cause a conflict.  It may not sound like it might, but since RMXP uses system globals (like fonts), I wonder if the two might conflict?  I did exit the VPN program, and still didnt get any results.  Perhaps Adobe Flash?  I messed with some of the geek config settings, namely "DisableDeviceFontEnumeration", and think Flash shouldnt cause a conflict, but perhaps Font Enumeration?  Some sort of other Windows permission?  AVG?  All disabled for testing, and no luck on anything I've tried.  Shortcuts are not set to run in compatability mode, the advanced text services are not turned off.  Just related things, but dont seem to have any impact...
Title: Re: [XP] Memory Font Loader
Post by: Duds on November 30, 2014, 07:13:57 pm
Hi guys, this is my first post here. :haha:
I was very interested in this script so I gave a try on fixing it.
It works with AddFontResource (without Ex).


Spoiler: ShowHide


#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Memory Font Loader
# Author: ForeverZer0
# Version: 1.0
# Date: 1.8.2014
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#                             VERSION HISTORY
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# v.1.0   1.8.2014
#   - Original Release
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#
# Introduction:
#
#   Small script that allows for loading and using fonts into memory at run-time
#   without the need for installing them on the operating system. The advantage
#   of this script over others, such as Wachunga's font-install script, is that
#   it does not require a administrator privileges to use the fonts, nor a
#   restart of the game after running.
#
# Features:
#
#   - Automatically load all fonts found in user-defined folder
#   - Supports TrueType (*.ttf) and OpenType(*.otf) fonts
#   - Does not require Administrator privileges
#   - Does not require a game restart
#
# Instructions:
#  
#   - Place script anywhere above main
#   - Some optional configuration below with explanation
#   - Use the script call "Font.add(PATH_TO_FILE)" to add a font.
#   - If using auto-load, create a folder for the fonts ("Fonts" by default),
#     and place all font files within it. Loading will be done automatically.
#
# Compatibility:
#
#   - No known compatibility issues with any other script.
#
# Credits/Thanks:
#
#   - ForeverZer0, for the script
#
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

#===============================================================================
# ** Font
#-------------------------------------------------------------------------------
# The font class. Font is a property of the Bitmap class.
#===============================================================================
class Font
 
 #-----------------------------------------------------------------------------
 #                            CONFIGURATION
 #-----------------------------------------------------------------------------
 
 # This value (true/false) indicates if all fonts in the specified fonts folder
 # will be automatically loaded when the game is started.
 AUTO_LOAD = true
   
 # Set this to the name of the folder, relative to the game directory, where
 # the font files are contained. This folder will be searched for font files
 # when using the auto-load feature
 FONT_FOLDER = 'Fonts'
 
 #-----------------------------------------------------------------------------
 #                           END CONFIGURATION
 #-----------------------------------------------------------------------------
 
 #-----------------------------------------------------------------------------
 # * Constants
 #-----------------------------------------------------------------------------

 WM_FONTCHANGE = 0x001D
 HWND_BROADCAST = 0xFFFF

 AddFontResourceEx = Win32API.new('gdi32', 'AddFontResource', ['P'], 'L')
 SendMessage = Win32API.new('user32', 'SendMessage', ['L'] * 4, 'L')
 #-----------------------------------------------------------------------------
 # * Class Variables
 #-----------------------------------------------------------------------------
 @@memory_fonts = []
 #-----------------------------------------------------------------------------
 # * Load font(s) into memory
 #     filename  : Full path to font file. Accepts multiple filenames.
 #-----------------------------------------------------------------------------
 def self.add(*filenames)
   filenames.each {|f|
     next if @@memory_fonts.include?(f)
     if AddFontResourceEx.call(f) > 0
       @@memory_fonts.push(f)
     end
   }
   SendMessage.call(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
 end
 #-----------------------------------------------------------------------------
 # * Automatically seach and load all font files found in the font folder.
 #-----------------------------------------------------------------------------
 def self.auto_load
   dir = FONT_FOLDER == '' ? Dir.pwd : File.join(Dir.pwd, FONT_FOLDER)
   return unless File.directory?(dir)
   files = Dir.glob(File.join(dir, '*.{ttf,otf}'))
   self.add(*files)
 end
 # Load fonts if using auto-load
 auto_load if AUTO_LOAD
end

Title: Re: [XP] Memory Font Loader
Post by: Heretic86 on December 02, 2014, 09:19:25 am
+Rep

Changing AddFontResourceEx (ExA or ExW also) to just AddFontResource works perfectly!  At least on XP SP3, so Im not sure how that will affect Windows 7 / 8 / 8.1 but feedback on the proposed fix would be appreciated by many...
Title: Re: [XP] Memory Font Loader
Post by: ForeverZer0 on December 17, 2014, 07:37:43 am
* Updates script to version 1.1 *

I added the fix that Duds pointed out to the script as a backup if the original method fails. If you were having troubles getting the script to work before, it may be worth your while to check again.

Thank you, Duds.  8)
Title: Re: [XP] Memory Font Loader
Post by: Blizzard on August 23, 2015, 08:34:39 am
I think that I can offer some more insight here after experimenting with this a bit.
The problem seems to be indeed that RMXP keeps a list of available fonts that it creates on load. AddFontResourceEx() can't work, because the fonts are uninstalled again right after it closes. AddFontResource() will work, because it temporarily installs the fonts until the next reboot. So yeah, I don't think this problem can be solved.
Title: Re: [XP] Memory Font Loader
Post by: Blizzard on May 12, 2016, 03:13:15 am
*BUMP*

I just had an idea that I shared with Heretic:

Quote from: le meThere MIGHT be one last possible solution. You could reinstall the fonts every time the game runs and copy the file into the fonts directory regardless if it's already there. In that case you would just have to change the code a bit to avoid reporting missing fonts to users.
Title: Re: [XP] Memory Font Loader
Post by: F117Landers on July 10, 2016, 10:48:23 pm
I'm rather new to this, so perhaps someone can help:

what is "PATH_TO_FILE"? Is that to add a script from outside the Fonts folder into the game? or is that to actually set the font once it is loaded?
Title: Re: [XP] Memory Font Loader
Post by: KK20 on July 11, 2016, 12:46:10 am
If you're not using AUTO_LOAD, you'll have to use that script call to add your fonts. Otherwise, just throw all your fonts into whatever Font folder you package your game with; you won't have to worry about making any script calls.
Title: Re: [XP] Memory Font Loader
Post by: F117Landers on July 11, 2016, 07:46:14 am
Thanks KK20. I am using auto load, but the fonts weren't loading (Edit: using Font.default_name = "King's Gambit") and I had checked the font size, name (within the ttf), and capitalization already.
Title: Re: [XP] Memory Font Loader
Post by: ThallionDarkshine on December 20, 2017, 09:54:47 am
So I seem to have found a bug with this on Windows 8.1. After the call to
SendMessage
, the game freezes. Have you tried with just
SendNotifyMessage
? From what I can tell in the docs,
SendMessage
blocks until all windows process the notification, whereas
SendNotifyMessage
returns immediately... I tried removing the
SendMessage
call, and the game appears to run fine. Is there a reason you're making both calls?
Title: Re: [XP] Memory Font Loader
Post by: maathieu on May 03, 2020, 04:16:45 am
Hi,

I have been asked by a friend developing an RPGMaker XP game to look into this script in order to get it to load a user-defined font at runtime. Reading the forum here, I can't really figure out why it seems to work for some people, and not for others.

I am doing the testing on Wine simulating Windows XP. Ruby properly calls AddFontResource, SendMessage, and SendNotifyMessage; but after that, the font is not made available to the game. I have read that RPGMaker XP maintains an internal "list of fonts", could it be possible that said list is loaded before the script for some verions of RPGMaker XP, and after it for others? I use version 1.03 here.

If the "list" hypothesis is right, is there any way to access the internal list and manually add the font name in it?

Cheers,

Maathieu
Title: Re: [XP] Memory Font Loader
Post by: Blizzard on May 03, 2020, 05:37:16 am
I think you're correct about the internal list IIRC. But that's exactly what AddFontResource, SendMessage and SendNotifyMessage are supposed to handle and change. So I'm not sure what's wrong. I assume it's some internal bug in XP. XP's been around since, well, Windows XP and the tighter permission restrictions have only been added in Windows Vista and later and I wouldn't be surprised if permissions are what's causing the issue in the first place. So it's likely that this is an issue that would require an update to XP to reliably fix. But the original developers don't maintain it anymore so there's not much hope that this will be fixed.

You may want to consider using XPA. Ever since I converted my project to XPA, I haven't had any font issues anymore. The VXA engine handles fonts so much better than previous versions of RPG Maker.
Title: Re: [XP] Memory Font Loader
Post by: maathieu on May 14, 2020, 02:34:28 pm
I wish I could do that... Unfortunately we developed a lot of custom scripts for the game and hacked around the existing ones. The code is sloppy, the development heavily plays with the limits of RPG XP, and porting is hazardous.

Well, I guess the best solution is to create a Windows Installer that installs the font along with the game... I'll give a go at NSIS.
Title: Re: [XP] Memory Font Loader
Post by: Blizzard on May 19, 2020, 03:37:49 am
I have over 30000 lines of code compared to the standard 9000 lines. That's how many custom scripts I had when porting. It took me about 3 work days to do the port and most of it was fixing cutscene timing of music and minigames. And that was because I switched to 60 FPS, not so much because of XPA. Except for some very specific bitmap handling issues and some other minor bugs, it was relatively easy to do. Actually the majority of bugs were either in the new windowing system and with the tilemap implementation. So KK20 fixed the tilemap bugs and I fixed the window system bugs directly in XPA.

Of course, I'm a programmer. If you're not one, you'll likely have a harder time with porting to XPA. In either case it was very worth it for me. This is why I'm suggesting to at least give it a go. Make a backup of your project, switch to XPA and maybe do 1-2h of testing to see how it works. If you run into issues you think you can't solve, you can always just delete it and keep using your normal XP backup.

I tried getting NSIS to install the font myself as well, but it didn't work. I'm not saying that you should give up right away (I used v2.46), but be aware that this will likely not be the solution.
Title: Re: [XP] Memory Font Loader
Post by: ctkny on January 19, 2021, 01:48:06 pm
If reverse engineering is permitted for some kind of refinement,this should be way simpler.

Similarily,functionalities such as disabling F12/10s hangup/alt+enter,background running,pausing the movieplay in VA,loading .so that requires native ruby func support,screenshot,... can all be achieved.
Some of these take nothing but one byte's hack.

With no source,the machine code level provides the most freedom.
Sadly though,this violates the EULA.

A lot of what I know about reverse engineering comes from the time when I had fun with RMXP,fixing this or that,digging.I just drifted from scripting ruby.

I'm Chinese so I have never posted here.And I don't really care about EULA for a long time.I don't make /publish games myself and people I helped did not seem that bothered.

I don't know.If it is acceptable,I'll share my way of doing this,detail it.Otherwise,well,thanks for hearing out.
Title: Re: [XP] Memory Font Loader
Post by: KK20 on January 19, 2021, 04:18:06 pm
I don't know why you specifically chose this thread to share it. But feel free to post a new topic under general discussion sharing what you found/know. Just put a disclaimer that it violates EULA and is just for knowledge-sharing purposes.