Author Topic: [XP] Memory Font Loader  (Read 18739 times)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
[XP] Memory Font Loader
« on: January 08, 2014, 03:46:25 PM »
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

  • 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
  • Plug & play

Screenshots

None.

Demo

None.

Script

(click to show/hide)

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

  • ForeverZer0, for the script
  • Duds, for pointing out the "AddFontResource" fix

Author's Notes

Please feel free to ask for support, post bugs, or anything else. Enjoy!
« Last Edit: December 17, 2014, 02:35:32 PM by ForeverZer0 »
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19931
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Memory Font Loader
« Reply #1 on: January 08, 2014, 04:25:01 PM »
I love you.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline PhoenixFire

  • Moderator
  • Astral Trancist
  • ***
  • Posts: 918
  • LV: 6
  • Gender: Female
  • ~That's an interesting notion, in it's own way~
    • View Profile
Re: [XP] Memory Font Loader
« Reply #2 on: January 08, 2014, 04:30:56 PM »
   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  :^_^':
Next off, how to create a first person shooter using microsoft excel.

<Remember when computers had turbo buttons?

Offline Zexion

  • Addicted to LoL
  • Chaos User
  • ******
  • Posts: 1511
  • LV: 69
  • Gender: Male
  • My anaconda don't...jk it does
    • View Profile
Re: [XP] Memory Font Loader
« Reply #3 on: January 08, 2014, 10: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!

Offline Jamal XVI

  • Trained Member
  • *
  • Posts: 13
  • LV: 0
  • Gender: Male
    • View Profile
Re: [XP] Memory Font Loader
« Reply #4 on: January 21, 2014, 06:08:05 PM »
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

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Memory Font Loader
« Reply #5 on: January 21, 2014, 06:39:10 PM »
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, I have confirmed that this name is the same. Simply use the name "Slant".
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Jamal XVI

  • Trained Member
  • *
  • Posts: 13
  • LV: 0
  • Gender: Male
    • View Profile
Re: [XP] Memory Font Loader
« Reply #6 on: January 21, 2014, 07:41:38 PM »
The same problem.Something must be wrong.
Look at this code:
Code: [Select]
module GTBS
  #=============================================================#
  #                       ENGINE SETTINGS                       #
  #=============================================================#
  def self.font
    return "slant"#Fonts::Names[0]
  end
end
and the main
Code: [Select]
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

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Memory Font Loader
« Reply #7 on: January 21, 2014, 07:58:34 PM »
Does it work in a new project, as in a blank new project, without any added scripts?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Online KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3047
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP] Memory Font Loader
« Reply #8 on: January 21, 2014, 08:07:56 PM »
Shouldn't that be GTBS.font?



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline Jamal XVI

  • Trained Member
  • *
  • Posts: 13
  • LV: 0
  • Gender: Male
    • View Profile
Re: [XP] Memory Font Loader
« Reply #9 on: January 21, 2014, 08:08:38 PM »
Does it work in a new project, as in a blank new project, without any added scripts?
A new project main
Code: [Select]
#==============================================================================
# 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
(click to show/hide)
I can't imagine what problem making this, but it wont work.
Thanks,
Jamal XVI

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Memory Font Loader
« Reply #10 on: January 21, 2014, 09:54:24 PM »
Strange.
I will have to see if maybe there is some issue with WinXP, or perhaps something else I am missing.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Jamal XVI

  • Trained Member
  • *
  • Posts: 13
  • LV: 0
  • Gender: Male
    • View Profile
Re: [XP] Memory Font Loader
« Reply #11 on: January 24, 2014, 03:16:01 PM »
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

Offline Zexion

  • Addicted to LoL
  • Chaos User
  • ******
  • Posts: 1511
  • LV: 69
  • Gender: Male
  • My anaconda don't...jk it does
    • View Profile
Re: [XP] Memory Font Loader
« Reply #12 on: January 24, 2014, 10: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.

Offline PrinceEndymion88

  • Awakened Visionist
  • **
  • Posts: 74
  • LV: 1
  • Gender: Male
    • View Profile
Re: [XP] Memory Font Loader
« Reply #13 on: April 15, 2014, 03:54:38 AM »
I've added the Joystix Monospace.ttf font into Fonts folder and into UMS script I've edited
Code: [Select]
@font = "Arial" into
Code: [Select]
@font = "Joystix Monospace" but I can't see the font when I play the game... where I'm wrong?

Offline Zexion

  • Addicted to LoL
  • Chaos User
  • ******
  • Posts: 1511
  • LV: 69
  • Gender: Male
  • My anaconda don't...jk it does
    • View Profile
Re: [XP] Memory Font Loader
« Reply #14 on: April 15, 2014, 07: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:

Offline PrinceEndymion88

  • Awakened Visionist
  • **
  • Posts: 74
  • LV: 1
  • Gender: Male
    • View Profile
Re: [XP] Memory Font Loader
« Reply #15 on: April 15, 2014, 10:07:40 AM »
I had already checked out, the real name is Joystix Monospace.

Nome tipo carattere = Font Name (in italian  :haha:)

Dust

  • Guest
Re: [XP] Memory Font Loader
« Reply #16 on: May 24, 2014, 09: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.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Memory Font Loader
« Reply #17 on: May 24, 2014, 12:39:32 PM »
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.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline orochii

  • Transcended Spirit
  • ***
  • Posts: 143
  • LV: 14
  • Rhapsody of the Warrior of Ice
    • View Profile
Re: [XP] Memory Font Loader
« Reply #18 on: May 25, 2014, 12:23:23 AM »
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!

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19931
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Memory Font Loader
« Reply #19 on: May 25, 2014, 10:12:29 AM »
(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.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.