🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Loading fonts in linux.

Started by
2 comments, last by Null and Void 16 years, 4 months ago
I looked at the source from the NeHe tutorial on loading and displaying system fonts. Here is a code snippet:

Display *dpy;
XFontStruct *fontInfo;

mDisplayList = glGenLists(96);

dpy = XOpenDisplay(NULL);

fontInfo = XLoadQueryFont(dpy, face.c_str());

if (fontInfo == NULL) {
    return false;
}

glXUseXFont(fontInfo->fid, 32, 96, mDisplayList);

XFreeFont(dpy, fontInfo);

XCloseDisplay(dpy);


My question is: How do I load a font in a particular location relative to me excecutable (truetype)? And how do I specify the size? I've googled XLoadQueryFont() but I cannot seem to answer my question. I will continue googling... Thanks
Advertisement
Use freetype library.
But if you want to use Xlib, use something like
xset +fp=path/to/font/directory
The problem is that I want to load the same fonts on both linux and windows build of my game.

I don't really understand the xset. Is it a function? XSet("+fp+..")?

Quote: Original post by c_olin
The problem is that I want to load the same fonts on both linux and windows build of my game.

I would also recommend trying FreeType for your situation.
Quote: Original post by c_olin
I don't really understand the xset. Is it a function? XSet("+fp+..")?

It's a command line program to tweak some X preferences (such as the font path in that example). I wouldn't bother with it.

This topic is closed to new replies.

Advertisement