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 / Help: I need to use more fonts

Author
Message
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 1st Aug 2003 11:40
Hi,

I´d like who someone explains me how i can use more fonts than it´s not installed on the system. Is there anyway to use fonts which are within the directories´ tree of the program/game?

Also I need help with the charset value(SET TEXT FONT Fontname, Charset Value), im spanish and here we´ve got characters like "ñ", "ó" or "¡" but i cant to use without the charset value. I should be very much obliged if someone to help me.

Thank u in advance.
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 1st Aug 2003 12:19 Edited at: 1st Aug 2003 12:20
The best way is to use bitmap fonts (ie characters created in a bitmap editing package) - then you dont have to worry about making sure the user has the correct font installed etc...

Plus, using sprites for the fonts, you have absolute control over the size, position and things like that.


Its better than a poke in the eye...
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 1st Aug 2003 12:57
Thank u for your response. I was waiting that solution but I hoped a way more easy to include new fonts.

I suppose that´s the only way to make it. Anyway, i need know how to use the charset value.

Thank u for your attention.

MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 1st Aug 2003 17:23
The problem is making sure the font is always present... What might be useful is to find a program that converts TT fonts (at a reasonable reading size) to a bitmap. You could use the bitmap as a font.


Its better than a poke in the eye...
Bangla
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: Sweden
Posted: 1st Aug 2003 17:49
I think I've read it here on the forum somewhere - though I'm not sure and wouldn't change religion over it - that you could simply install the font on the users machine by copying it to the font-folder.
DBP has a command to look for fonts already installer on the machine, use it to look for the font you want to install and if it doesn't exist, install it, else, leave it be.

I haven't tried it myself and don't know if it works, just thought I'd let you know that it might be possible.

2,4 Ghz, 512 Meg, TNT2 - and then some...
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 1st Aug 2003 18:13 Edited at: 2nd Aug 2003 05:24
You can use the Windows API functions AddFontResource and RemoveFontResource to temporarily install fonts on the user's system.

See code example (click on the source button below)



***cough*** just replace the words
AddFontResource with AddFontResourceA and
RemoveFontResource with RemoveFontResourceA

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 2nd Aug 2003 03:27
MrTAToad, can you not just include the font file in with your media? or in a sub dir? or does it have to be preloaded with windows?
Just wondering?
CTP
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 2nd Aug 2003 05:18
erm, did you read my post (and code example)?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 2nd Aug 2003 09:45
yes I did and thats why I was asking, I thought you could just include it with you media. So if I understand, you can put your font in a folder say 'font' and use AddFont("font/font.ttf") and it will then load, right? do you need to do a chesk for the font first before using AddFont, will it crash if the font already exists? Is there a api call for that if it needs done?

CTP
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 2nd Aug 2003 12:14
I dont see why not - the only real problem is installing it :
You may be overwriting a newer font, and it might fail to install, both of which you should check for...


Logo design by Indi
Its better than a poke in the eye...
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 2nd Aug 2003 15:43 Edited at: 2nd Aug 2003 15:44
You don't need to place your font into the windows font folder. You can add it from your app's folder.

The best way to install a new font is to rename it to something unigue like "mygamefont1.ttf" or something so you won't have problems, in case you prog crashes before removing the font.
If the same font already exists the AddFontResource function returns 0, indicating no fonts were added.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 4th Aug 2003 19:53 Edited at: 4th Aug 2003 19:55
Thank u very much Empty, thank u for your help.

Now the only i need is the charset value to use the spanish characters.

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 4th Aug 2003 20:53
Are you sure the special characters are in the font?
What happens if you run this:
print chr$(241)
sync
wait key

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 5th Aug 2003 03:59
try a 1 for the charset value, it's what I did to use wingdings fonts symbols. If not just keep trying different numbers.
CTP
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 5th Aug 2003 20:37
Greetings,

I´ll say u tomorrow empty.

The characters i need, arent special characters like pound, euro, or acid faces. When i install windows i install my lenguage for my keyboard. My keyboard is "qwerty" but it has a few characters more than yours (english and american people i refer).

For example, in spanish, the symbol "?" has a partner. it goes to the start of a question and it looks like the same but rotate 180 degrees.
We have got characters with a little stick on the top and characters with a little wave on the top.

I hope tha charset value help me. i need characters not symbols.

Thank for yours attention.

Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 6th Aug 2003 13:05
i´ve got 2 bad news. The first and more important is that the source code doesnt load the fonts.

I replaced the words like you said me, and i tried delete RemoveFontResourceA to check if the font was installed on fonts directory.

The second: "print chr$(241) : sync : wait key" doesnt show any character on the screen.

I´ve got Windows XP.

Thanks again.

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 7th Aug 2003 00:02 Edited at: 7th Aug 2003 00:03
Quote: "
I replaced the words like you said me, and i tried delete RemoveFontResourceA to check if the font was installed on fonts directory.
"

Check the variable "myfont" it must be greater than 0. Else the path and or filename isn't correct. If it's > 0 then the font is added. Please keep also in mind that the new font might not work with the PRINT command. Use TEXT instead. It works here very well.

Quote: "
The second: "print chr$(241) : sync : wait key" doesnt show any character on the screen.
"

Yeah indeed. DBpro doesn't seem to like international characters (as it should print ñ). It works in DBClassic, though.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 7th Aug 2003 11:00
Thank u very much, it´s very nice to see how the international community helps to its members.

I was making tests with print, sorry.

Tomorrow i comment u my results.

Thank u again.

Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 8th Aug 2003 11:06
I cant use it. The only i get is a sans serif font.

Thank u anyway

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 8th Aug 2003 14:11
Would you mind uploading the font so that I can give a try?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 9th Aug 2003 10:10
It happens with any font who isnt one of default (agatha.ttf,stonehen.ttf,invisbl.tff,harringtn.ttf). Anyway you show me another way to get it, longer but with the same result. I´ll copy the font file in the directory of fonts using the commands of file.

Thank u for your time

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 9th Aug 2003 14:35
That's weird. I've attached a test code for agatha.ttf and it works fine here.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 9th Aug 2003 19:35
Then i cant understand it, because it doesnt work with me.

Could u paste here the code? I check directly from your code.

You´re very patient with me.

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 9th Aug 2003 21:54 Edited at: 9th Aug 2003 21:55
I had already attached it. Just click the "source" button underneath my previous post.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Elthan
20
Years of Service
User Offline
Joined: 29th Jul 2003
Location: Spain
Posted: 10th Aug 2003 14:09
Ups, excuse me twice.
The first for i didnt understand u, i didnt see that u say me; the second for a little error of me, on SET TEXT FONT i specified the font so: SET TEXT FONT "agatha.ttf".

Thank u very much empty, thank u very much.

Login to post a reply

Server time is: 2024-05-07 18:47:17
Your offset time is: 2024-05-07 18:47:17