Font Problem

BlitzPlus Forums/BlitzPlus Programming/Font Problem

xlsior(Posted 2004) [#1]
This is a rehash of the problem I posted in the BlitzPlus Bugs group a couple of days ago, but unfortunately so far nothing I tried has made the issue go away.

Anyway: I downloaded a truetype font online ( ), which works just fine in BlitzPlus when I actually install the font. That is nice, but inconvenient since I would prefer to keep my game 'self-contained' in a single directory without dumping anything in the windows fonts/system directories.

I use the following code:

Graphics 640,480,0,2
FreeFont fnt1
fnt1=LoadFont("Plasma Drip BRK",60,False,False,False)

SetFont fnt1
Text 100,100,"This is a test!"

The internal font name is "Plasma Drip BRK", and when the font is actually 'installed' it renders just fine when called by that name... When it is in the game directory instead, however, it reverts to Arial instead.

Since supposedly the font filename and the fonts internal name are supposed to match, I tried renaming the font file to the following:

- 'Plasma Drip BRK.ttf'
- 'Plasma Drip BRK.fon'
- 'Plasma Drip BRK'
- 'PlasmaDripBRK.ttf'

as well as trying LoadFont("PlasDrip.ttf"60,False,False,False)

Unfortunately none of these tries work. When the font is 'installed' it works fine, but when it merely resides in the game folder all I get is Arial.

This is just one of many fonts I tried recently, and all appear to have the same problem.

I'm starting to pull my hair out now. :-)
Does anyone here have any suggestions?

Mr Brine(Posted 2004) [#2]
I have a suggestion, but I dont know wether it'll work or not... could you use either the systemproperty or the getenv command to retreive the font's directory location??

Mr Brine

xlsior(Posted 2004) [#3]
What do you mean?

The font is stored in the same directory as the example program, plus in addition to that I've also tried a changedir("d:\myfolder") to absolutely force it to that folder, where the font resides as well.

I see the exact same issue whether I'm running it in the IDE or in compiled form, from the command line. Just really weird. :-/

Beaker(Posted 2004) [#4]
I just tried something that worked.
Put the font in the game folder, do NOT change the name, then use:
fnt1=LoadFont("Plasma Drip BRK.ttf",60,False,False,False)

...worked here on Windows 98.

xlsior(Posted 2004) [#5]

That did the trick, thank you SO much!
(Can't believe I missed that iteration)

GfK(Posted 2004) [#6]
This doesn't work on WinXP....

Beaker(Posted 2004) [#7]
And the XP solution doesn't work on Windows98. :/

xlsior(Posted 2004) [#8]
So... What -is- the Fix for XP?

The example mentioned above works without problems on windows 2000, but I currently don't have access to either Win98 or XP.

However, if there is a definite way to make it work under Win98 as well as XP, at least it won't be the end of the world: I don't remember who wrote it, but I ran across the following code a while ago:

; Userlib declaration 
;.lib "Kernel32.dll" 

; Blitz code for querying platform
Version = CreateBank(148)
PokeInt(Version, 0, BankSize(Version))

If GetVersionEx(Version) Then
	Select PeekInt(Version, 16)
		Case 0 : Notify "You are running Windows 3.1"
		Case 1 : Notify "You are running on the Windows 9x kernel"
		Case 2 : Notify "You are running on the Windows NT kernel"
		Default : Notify "Unexpected value for Platform ID.", True
	End Select
	Notify "There was an error querying version info.", True


Or more detailed, without userlibs:

If OS$="Windows_NT" then print "You are running the Windows NT kernel"

If OS$="Windows_NT" And (Instr(root$,"WINNT")<>0) And AppData$<>"" Then Print "Probably Windows 2000"
If OS$="Windows_NT" And (Instr(root$,"WINDOWS")<>0) And AppData<>"" Then Print "Probably Windows XP or Windows 2003"
If OS$="Windows_NT" And AppData$="" Then Print "Probably Windows NT"
If OS$="" Then Print "Windows 9x" 2004) [#9]
Is this a simpler way:

FreeFont fnt1
fnt1=LoadFont("Plasma Drip BRK",60,False,False,False)
if fnt1=0 then 
    fnt1=LoadFont("Plasma Drip BRK.ttf",60,False,False,False)
SetFont fnt1

PS: I just posted this related code that deals with TTF fontnames...

xlsior(Posted 2004) [#10]

That other code looks like it may come in handy too...

Tracer(Posted 2004) [#11]
Well, this STILL doesn't work for me under B+.

I have a font file (font1.fon), it's in the directory with the Blitz+ exe .. and no matter WHAT i do.. it doesn't load it.

Hmm.. i think i see the problem.. There's like 8 fonts called Terminal in the XP fonts directory! Blitz don't LIKE that at ALL...


Gets odder..

There's also a bunch of "FixedSys" fonts in the XP fonts dir.. if i LoadFont that.. it works.. if i load "Terminal" it doesn't .. 8514OEM.FON doesn't work either... There's something REAL screwed with Blitz' font system.


xlsior(Posted 2004) [#12]
Isn't blitz supposed to just handle True Type fonts (TTF?)

If not: Tracer, did you make sure to match the internal font name to the filename, including any spaces and such?

Tracer(Posted 2004) [#13]
everything matches.. i have tried over 90 .FON files .. 4% works, the rest doesn't ..

Tracer 2004) [#14]
After I wrote the code to look up TTF fontnames from the file (
) I tried to do the same for .FON files. I couldn't find any file layout info or even a DLL that BB can use. (let me know if you can find something)

In the end I decided to forget about .FON fonts because TTFs often render much nicer than raster/vector fonts anyway.

I was still frustrated that I couldn't determine if a TTF file was a Symbol font or not since BB doesn't support them (like wingdings etc).

NB: There's a lot more font info available via the GDI32 api but it's not available to BB because it requires callbacks. :-(

Tracer(Posted 2004) [#15]
It's kinda odd tho .. i'd expect Mark to use the API commands for fonts.. which supports a whole host of font formats.

Oh, and i don't want to use TTF in this case.