![]() |
|
Include ttf in exe |
Bingocat
Member #15,424
December 2013
|
Is it possible to include a ttf file inside of the exe? Like how it's possible to include dll's in the exe. It would be nice to not have any files other than the exe. |
RPG Hacker
Member #12,492
January 2011
![]() |
Is it really favorable to include all resources in the EXE? That means that whenever you make an update for the game, people will have to redownload the whole game instead of just the executable. That is something that should be considered. Don't know if this is possible. Probably as a resource file? Even then I don't know how you would load it with Allegro.
|
Niunio
Member #1,975
March 2002
![]() |
Both versions 3 and 4 had utilities to translate data files into ASM and link with exe. I didn't see such stuff in version 5, but it can be reproduced and overload the file_io system to load data from byte arrays (for example). But as RPG Hacker said, I find it useless except if you're doing something like a demo. ----------------- |
SiegeLord
Member #7,827
October 2006
![]() |
With Allegro 5 you can use the xxd tool to convert your file to a C array and then the memfile addon (i.e. al_open_memfile). "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
torhu
Member #2,727
September 2002
![]() |
Cool, xxd is even part of the Git for Windows package. |
Bingocat
Member #15,424
December 2013
|
How to do you use al_open_memfile()? I can find no examples anywhere. |
torhu
Member #2,727
September 2002
![]() |
Bingocat
Member #15,424
December 2013
|
What are the arguments that you put in? Can you give me an example? Like if I have this array then how do I use the command to turn it into an ALLEGRO_FONT? Also, I'm not sure if I converted the .ttf file correctly or not. Should it be this length? 1char font[] = {
20x00,0x01,0x00,0x00,0x00,0x18,0x01,0x00,0x00,0x04,
30x00,0x80,0x44,0x53,0x49,0x47,0xB2,0x75,0xFB,0xD1,
40x00,0x0D,0x7F,0x70,0x00,0x00};
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Obviously, that char array does not hold the ttf file you converted. It would be orders of magnitude larger if it did. The _f functions load from memory locations, using ALLEGRO_FILES's. You want to use al_open_memfile and al_load_ttf_font_f. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Gideon Weems
Member #3,925
October 2003
|
SiegeLord said: With Allegro 5 you can use the xxd tool to convert your file to a C array and then the memfile addon (i.e. al_open_memfile). The xxd utility that comes with vim? I didn't realize that existed outside of Vi Land, though I see now that msys includes it. |
Audric
Member #907
January 2001
|
You don't even need to generate such hefty C file, compilers can link binary files directly. For example with GCC, the utility is objcopy. |
Bingocat
Member #15,424
December 2013
|
Ok this is the code that I tried, but there is still a problem. It says that the arial variable is being used before it's initialized. What am I doing wrong? 1ALLEGRO_FILE *arial = al_open_memfile(arial, 891469, "rw");
2
3 ALLEGRO_FONT *font18 = al_load_ttf_font_f(arial, NULL, 18, NULL);
4 ALLEGRO_FONT *font10 = al_load_ttf_font_f(arial, NULL, 10, NULL);
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
You're passing the wrong argument (or shadowing a variable (using the same name)) to al_open_memfile. Your ALLEGRO_FILE* and your argument to al_open_memfile have the same name ('arial'). I assume that's a typo. What is your memory block called? That is what you pass to al_open_memfile. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|