Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How do I make my own installer app for my games/programs?

Author
Message
Yodaman Jer
User Banned
Posted: 21st Apr 2011 08:24
Hey guys,

this is something I've been wondering about for a while now, and I figure I'd better ask it while I'm thinking about it tonight.

I'm currently working on a project that I'm using a very specific font for that I doubt anybody else has pre-installed on their machines, and provided I'm legally allowed to re-distribute it I figure the only way I can use it is if I make my own installer for the program that copies the font to the fonts directory on the users computer. My problem is, I have NO idea how to do this with DBPro or any other programming language! Can anybody help give me some pointers? I know it's basically file copying, but I have no idea where to start...

Pseudo-code would be appreciated too. Like I said, this is something that's interested me for a while, and I'd love to see samples!

Thanks!

-CoffeeCoder

BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Apr 2011 09:17
IanM's Matrix utils has functions for getting the Windows directory, where the Fonts subdirectory is held.

However, you can simply put it in your game folder and LOAD FONT.

Battoad
AGK Developer
19
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 21st Apr 2011 11:35
Instead of writing yr own installer, you could use WarSetup 3 installer and include yr fonts in the installation folder with yr application. There is a lot about it, and a download tutorial in the "sticky" - "AppUp DBP Developers Group". Although the tutorial is based on getting the installer suitable for the Intel Appup Centre, it will work far easier if its just for pc distribution.
I think that there could also be a write up of this in next months newsletter, but can't guarantee.

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 21st Apr 2011 16:37
@BatVink:
I'm not sure your right, I'm just testing this on my plugin-less install of DBPro, and there is no load font command? Is it from a plug in? If it is, I'm not entirely sure which one it's from.

I thought you had to call the AddFontResourceExA function from the gdi32.dll?

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Apr 2011 16:58 Edited at: 21st Apr 2011 17:01
It's SET TEXT FONT. The best way is to just keep it in your games directory like BatVink said and not try to install it onto the persons machine. We get so many programs that fill our computers with junk 99% of the time we don't want. Save the user some grief and don't add that font to their font list.

Yodaman Jer
User Banned
Posted: 21st Apr 2011 21:25 Edited at: 21st Apr 2011 21:32
Thanks guys. I thought that in order to use the font 100% of the time, I'd have to install it on the end-user's computer. I didn't realize I could just keep it in the game directory. This saves me a lot of trouble!

@Juney:

I'll check that out! Sounds very intriguing.

EDIT: Hmm...I just tried putting the font in the same directory as my game's .exe and source file, and it's not working. I've made sure I've typed the font name accurately, and even though I'm sure it's not designed this way I tried set text font "Editor Data\AltamonteNF.ttf", but it didn't work. Anybody have any ideas?

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 21st Apr 2011 23:37 Edited at: 21st Apr 2011 23:42
I'm almost 100% sure that you can only use set text font on fonts which are installed already.

I believe the only way to do it is, as I said earlier, like this...



You can then set the text font in the usual way.

Hope that helps

>Edit<
You should probably remove the font with a call to RemoveFontResourceEx as part of your cleanup stuff when your program has finished.

Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 22nd Apr 2011 00:18
I think you've got the font thing covered. Just a something worth investigating more, but I'm planning to use Smart Packer to create my content libraries and installers.

Just my two cents...

Regards Sph!nx
http://www.mental-image.net
Yodaman Jer
User Banned
Posted: 22nd Apr 2011 00:51
@=PRoF=:

Thanks! That looks pretty dang easy. I'll try that later on tonight and let you know if it works or not. If it does, then I won't have a need to learn how to use bitmap fonts for my game just yet!

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 22nd Apr 2011 04:55 Edited at: 22nd Apr 2011 04:56
Quote: "I'm almost 100% sure that you can only use set text font on fonts which are installed already."


Yup, you're right.

The font file has to be in the windows font directory too.

Yodaman Jer
User Banned
Posted: 22nd Apr 2011 09:50
@Grog:

Quote: "The font file has to be in the windows font directory too."


I'm confused. Do you mean for the "set text font" command, the font has to be in the font directory, or do you mean that it also has to be in the directory for using the .dll?

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 22nd Apr 2011 12:09
Using the addFontResourceEx method will work with a font no matter where the ttf file is located, as long as you supply the correct path.

Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 22nd Apr 2011 21:31
Just a point I've noticed hasn't been made as was probably assumed knowledge (but clearly isn't) - SET TEXT FONT loads a font that is already installed on the system and cannot be used to actually load a font from disk. If you are using your own font that you don't think other people will have, the SET TEXT FONT command won't work on its own even if you include the font as a file with the distro.

There's no such command as LOAD FONT in DBPro, so you can't load it in any ordinary way like that. You may be able to find a plugin that adds a command with this functionality, or you can use the DLL that Prof suggested (this DLL exists on all Windows XP and subsequent systems). Using the DLL in this way simulates what you'd think a LOAD FONT command should do. You'll have to include the font file itself with your distro for this to work, but once you've called the DLL from your program you can then use SET TEXT FONT as if you were certain that every machine had the font installed.

Yodaman Jer
User Banned
Posted: 23rd Apr 2011 00:18 Edited at: 23rd Apr 2011 00:22
Thanks guys! That technique worked like a charm.

The font isn't as clean as I hoped it would be, though...guess it's time to check into Cloggy's D3D text commands!

Can anyone point me in the right direction to learn how to use bitmap fonts? I'm not going to use that in my current project just yet, but I want to learn how to use them for future needs. Thanks!

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Apr 2011 09:03
Quote: "I'm confused. "


Na, I'm the one that's confused.

I don't normally use fonts in anything unless it's a quick example (and then I only use Comic Sans). I normally use only bitmap fonts.

Quote: "Can anyone point me in the right direction to learn how to use bitmap fonts?"


You basically load the image of all the letters which are ordered based on the ASCII chart starting at #32 (space). Each letter is exactly the same size to make it easier to grab all the separate images. To write them to the screen you use a FOR/NEXT loop to go though each character of the string you want to show and get the ASCII value of the character to put the right image number on the screen.



baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Apr 2011 09:23
I use this code to load fonts that are not already installed on the users machine:


Works like a charm... the code is written by IanM I believe. Hope that helps.

Yodaman Jer
User Banned
Posted: 26th Apr 2011 05:31
@Grog:

GREAT example! That looks fairly easy, though I don't quite understand all what's going on (probably because I'm new to using bitmap fonts ), so could I please get a little bit of explanation about it? Thanks!

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Apr 2011 10:45 Edited at: 26th Apr 2011 10:59
Quote: "could I please get a little bit of explanation about it?"


Yeah np.

This part loads the image as bitmap 1 so anything that's done to the image is away from the sight of the user. We use bitmaps for image manipulation or just screen setups so the user is oblivious to anything that's happening till it's complete.




This part grabs each character as it's own image starting with image number 32 and ending with image number 90. Each character is 32x25 pixels in size.




This part changes the current working screen back to the main view screen which is bitmap 0. Without this the program would still be on bitmap 1 and the user would never see anything on the screen.




This part just calls the function twice to put that text on the screen using the images grabbed earlier.




This part is the function to write the text. It's called with the starting x and y coordinates where you want the text to appear and the actual string of text to show on the screen.




This part makes t equal the 1 to however long the string is (in both cases it's 1 to 14).




This part makes the variable a equal the ascii value of the current character of Tex$ at t's location in the string. So if t=6 and the string was "GROG WAS HERE." the 6th character of that string is "W". The ascii value of "W" is 87 so in that case a=87 (see attached ASCII Chart).




This part pastes the image number a (defined in the previous line) at the current x and y location. Because we grabbed all the images starting with image number 32 pasting whatever a equals should be exactly the right character we want. If a=87 pasting image number 87 should show the picture of the "W" because we grabbed each image based on the ASCII Chart. Each letter of the chart starting with 32 (which is the spacebar) to 90 which is higher case Z. If you wanted a bitmap font with lower case letters too you'd do 32 to 126 instead to grab every character and symbol that may be required for higher/lower case letter bitmap font. We use the ascii chart to make it easier to convert a character to a number so using image numbers 71, 82, 79, 71 from a bitmap font will always show GROG.




This last part just increases the x coordinate so the next character placed won't be on top of the previous character, the end of the FOR/NEXT loop, and the end of the function.



Yodaman Jer
User Banned
Posted: 26th Apr 2011 23:38
Wow! That's amazingly simple, and so much more efficient than a previous code example I saw (which used at least a hundred lines worth of memblock commands...yeck!). Thank you very much Grog, I am definitely going to use that for my project now.

Yodaman Jer
User Banned
Posted: 29th Apr 2011 10:21 Edited at: 29th Apr 2011 10:21
Hmm...some experimenting of mine has produced some pretty interesting (and slightly annoying) results with my venture into using bitmap fonts.

I tried making my own simple, alphabet-only font, and then I saved it as a .PNG. My goal was to see if if I could paste the images of the letters without having to define a color as transparent, but it didn't work. I tried the following...


...but that didn't work; there was simply a line of black boxes pasted on the screen. Then, I tried loading the .png as a bitmap even though I was pretty sure that command could only be used with .bmps. I found out I was wrong! But still, it gave me the same, black-box result. So I went back into gimp, loaded the font, created a new, 0,0,255 (blue) layer, saved the font out, and tried the following...



...and wah-lah! My font appeared as I wanted it to! However, there are some artifacts in the characters and it's driving me a little bonkers. I don't know what's causing them; the compression settings in GIMP are normal and aren't causing strangely off-color pixels, even when I scale the image, so I'm lost. Is it the way I'm loading the image? It did the same thing with true .bmp files though, so I don't think that's it. Attached is my font image and here's the code...



Yes, 99% of that is Grog's code. I haven't gotten around to making my own yet.

So, what's going on? How do I eliminate the artifacts? Any advice is appreciated, and thanks for the help so far guys!

[Attached Image]

...Oh, and this thread is super off-topic now, so to go back to its original roots, could someone please point me in the direction for making my own installers? I'm still very interested in that procedure.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th Apr 2011 20:09
It has artifacts because of the way the image was made. The font is anti-aliased so there are parts of the image that have semi-transparent areas that have a blue color that's not exactly the same as the background color.
Go back to making it a transparent background and use SET BITMAP FORMAT 21 to grab transparencies with GET IMAGE. And always use ,1 at the end of GET IMAGE to grab it without blurring the image.

Yodaman Jer
User Banned
Posted: 29th Apr 2011 22:42
Thanks Grog! That worked like a charm.

It doesn't seem that I can use white text with a black outline though, as my original font's outline disappeared, but at least with no artifacts!

Login to post a reply

Server time is: 2026-07-11 12:20:49
Your offset time is: 2026-07-11 12:20:49