True-Type Fonts and "internal font name"?

Blitz3D Forums/Blitz3D Programming/True-Type Fonts and "internal font name"?

martonic(Posted 2004) [#1]
Hi! I would like to use LoadFont() with a ttf font.

From scanning forum posts, this apparently can be accomplished in Blitz3d if:

(a) The font is in the same directory as the program, and

(b) The filename of the font is the same as the "internal font name".

However, to test this theory I have to know the "internal font name" - and how can I find that out?

Some posts recommend to "double-click the font" to get the internal font name, but when I double-click a font file, I just get Windows - as expected - asking me which program I would like to have open the file.

I tried right-click, "Properties" but got no help there either.

What is this mysterious "internal font name" and where is it hidden?

Thanks!


Gabriel(Posted 2004) [#2]
Windows Fonts Viewer opens up when I double click on a ttf font. It may be an XP only thing. Google has a ton of free font viewers. I'm sure one of them will do the trick.


martonic(Posted 2004) [#3]
Thanks! With some help from a "fonts viewer" I tested a couple of ttf fonts and they do seem to load correctly. Hurrah!


_PJ_(Posted 2004) [#4]

It may be an XP only thing.



Standard Windows Font-Viewer works fine for .TTF fonts for me on WinXP...


RGR(Posted 2004) [#5]
;-


John Blackledge(Posted 2004) [#6]
I downloaded a load of Star Trek ttf fonts, then found that Blitz would only show about half of them, (even though there was no error on load), and defaulted back to Arial. Can't explain this - it seems that Blitz just does not like some fonts. Had to painstakingly work through them all to find out what Blitz would or would not display.


Serpent(Posted 2009) [#7]
I'm annoyed - Blitz3D does not seem to be compatible with fonts I'm trying to use for a program.
My fonts default to Arial as well even though there is no problem in loading them.

It would be great if this issue could be fixed in both BlitzMax and Blitz3D.


beanage(Posted 2009) [#8]
Yea.. its annoying, strange and unexplained (at least from what I heard, which may not be much), why some fonts get loaded and some not. I once got the harsh reply on the same q "Dont use ttf's. Use Image Fonts.". So I do use image fonts since then, which work. FonTEXT does a great job on this imo. However, the actual problem remains.


Kryzon(Posted 2009) [#9]
As far as I know, you can specify directories.

Example: LoadFont("fonts\menu.ttf")

If Blitz3D can't find the font in the path you specified, it'll search the "internal fonts" (EDIT: or not! check Bill's post)


Zethrax(Posted 2009) [#10]
I think LoadFont only takes the internal name of the font as a parameter, rather than its filename or filepath.

The main problem I've had in the past with loading fonts correctly, is in finding the correct name to specify in the LoadFont command. The font's filename may not be the same as its internal name - and it's the internal name you need to use with LoadFont.

If you set the TTF font to be opened with Irfanview ( http://www.irfanview.net/ ) then Irfanview should display the font preview with the internal name of the font up the top. The preview seems to be displayed as an image, though, so you'll need to manually copy the font name.


_PJ_(Posted 2009) [#11]
It's a very murky area from experience.

Certain things do yied better results, though:

* ) Changing the filename to match the internal name (+".ttf")
* ) If the font is not installed on the machine (i.e. present in "C:\Windows\Fonts\"), it should be present in the root drive of the application that loads it.

Although some fonts (especially symbolic or more artistic styles of fonts) still present problems with the above, when working with the Blitzsys.dll to grab fonts using the Windows API Font-chooser itself, all installed fonts seemed to load okay and work in Blitz.

Due to the uncertainty of Blitz' font handling, I agree that bitmap fonts are a good way to go. At least, you also have some extra control over the appearance of the character set.

Not to pimp myself/own code too much, but if it's any help, I built these little routines to help with making bitmap fonts from any fonts installed on your machine. They can then be used in 3D or 2D as images and sprites as required:

http://www.blitzbasic.com/codearcs/codearcs.php?code=2533


jfk EO-11110(Posted 2009) [#12]
BTW. I also couldn't load a Font using a path like "..\myfont.ttf".


Kryzon(Posted 2009) [#13]
I took that LoadFont(path$) reference from the Blitz Boulders sample that came with the old free BlitzBasic version years ago.

See this unaltered excerpt from the source:
Global font_one=LoadFont("Fonts\Blitz.fon",24)
If font_one=0 
  err1$="Can't Find Fonts Make Sure The Fonts Directory,"
  err2$="Is In The Same Directory Has BlitzBoulders.exe?"
  error(err1$,err2$)
  End
EndIf

The game has a "Fonts" folder where that "Blitz.fon" file is placed.
Source: Blitz Boulders - by Geoff Storey.

As it is one of the Samples that came along with it (including Hole in One by GFK and Aristoids by Aristides Mytaras), we can be sure that it has some voice to it.


EDIT: This freeware software appears to convert .TTF to .FON, for those interested.