Loading fonts
Blitz3D Forums/Blitz3D Programming/Loading fonts
| ||
I'm loading a local font by referencing it by name. File = "Century Gothic.TTF" font1=LoadFont("century gothic.ttf",40*x_ratio,0) "Century Gothic.TTF" is located in the local folder of the executable. When I run the program on another computer (XP) it doesn't load the font. Any ideas why? |
| ||
your TTF is installed with your exe in same folder on that another XP machine? |
| ||
Yes. PZSSS/ ... Images/ ... Sound/ ... Model/ ... PZSSS.exe ... JV-ODE.dll ... Century Gothic.ttf |
| ||
On my PC Century Gothic is the internal name but Gothic.ttf is the actual filename. It may be that Windows looks in its own Fonts folder first, in which case you will probably have to supply the full path to _your_ font. I think I posted a thread about this a while ago. |
| ||
The name you supply to LoadFont is the font's internal name, not the file name. Try changing it to just "century gothic" and see if that helps. |
| ||
I read somewhere on this forum that you can reference fonts by the filename is they're local to the program and the filename is the same as font name. I think here http://www.blitzbasic.com/Community/posts.php?topic=42536&hl=fonts This agrees with my experience. If I use the filename 'Gothic.ttf' then the font doesn't load. Only by having the font name as the filename does it load, but not on this XP machine. I haven't tried the full path though. How can I obtain the applicaiton pathway for the Blitz program? |
| ||
Ah, right - I knew the filename had to match the font's internal name, but I didn't realize you could use the filename to load a local font. TBH, I've no idea why it doesn't work on XP machines. SystemProperty ("appdir") gets an apps path. This only works for standalone exes, though. When run from the IDE, it returns the Blitz3D 'bin' directory. |
| ||
I had a similar problem a while back where the filename was renamed to match the FOnt's internal name, AND it was in the same directory as the executable, but sill didnt work until the Font was subsequently installed into the Fonts folder of the new machine as well. (Again, this was two XP machines) |
| ||
Thanks Malice. So it looks like XP doesn't allow for the local font 'cheat'? How can I install the font if needed then? Perhaps I'll just stick with Arial bolded this time, but that's quite a problem. Did you find a good way to install fonts? I guess in InnoSetup you could copy it over to the font directory, but I don't like the idea of forcing fonts onto people's system. |
| ||
Yeah, I don't think installing the font on peoples' machines is a good idea. Besides, I think there's more to installing a font than simply copying it to the fonts folder. Installing probably involves listing the font somewhere in the registry, too. However, blitz may pick-up the font if it's simply present in the fonts folder - I'm not sure. Anyway, I see you're wanting to load the font at a size relative to the screen res. Maybe you could use bitmap fonts instead by creating one for each screen res needed? You could name the font image files something like "myfont800x600", "myfont1024x768" etc., and then load the correct one using file$ = "myfont" + GraphicsWidth() + "x" + GraphicsHeight(). Just an idea. |
| ||
Yes, that'll probably be the way to go. Now I understand the provision of various bitmap font tools! Plus they'll be antialiased which the TrueType fonts aren't. |
| ||
I've found Cyberseth's BMPFont system. Fits in without hassle to my program and will be being used in all my other programs too no doubt! |
| ||
Bitmap fonts are SO the way to go! hehe. just to note: I think you're right, Big10p. I did some tests using CopyFile to see if I could just copy fonts into the Fonts folder, what happened was very strange indeed. The file that subsequently appeared in the Fonts folder had the icon of a Shortcut although otherwise appeared fine. I even loaded up Word2000 and the font was registered in there..... |