title = newlabel(...);
settextfont(title, newfont("Times", Bold, 18));
The example given above illustrates how to set a label's text font
to be a bold Times 18-pixel tall font. Note that settextfont
may not work properly in MS-Windows for anything but labels,
due to limitations within that operating system. It should work
for most widgets under X-Windows.
Another thing that can happen is the label might be oscured by another control. Try moving nearby controls away and see if that improves things.
There are many reasons for this. Which fonts and font sizes are installed on your machine may not be the same as on someone else's machine, so writing portable code which relies on font sizes can be a problem.
Solution? Some guidelines:
Currently the only solution to this problem is to fiddle with the background colours of your windows until it looks nice.
If you use a 'redraw function', the window calls the specified function every time the window needs to be drawn. Hence, the window will always look good. You can use gprintf inside your call-back:
void draw_window_1(window w, rect r)
{
gprintf("First window!\n");
}
void draw_window_2(window w, rect r)
{
gprintf("Second window!\n");
}
void main(void)
{
window w1, w2;
w1 = newwindow("First", rect(10,10,100,100), StandardWindow);
setredraw(w1, draw_window_1);
show(w1);
w2 = newwindow("Second", rect(10,10,200,100), StandardWindow);
setredraw(w2, draw_window_2);
show(w2);
}
Whenever either window is drawn, the appropriate function is called.
Alternately, you can use the drawto function to choose
which window to draw to:
window w1, w2;
void main(void)
{
w1 = newwindow("First", rect(10,10,100,100), StandardWindow);
show(w1);
w2 = newwindow("Second", rect(10,10,200,100), StandardWindow);
show(w2);
drawto(w1);
gprintf("First window!\n");
drawto(w2);
gprintf("Second window!\n");
}
Each call to drawto can be followed by many calls to
gprintf or any of the other drawing functions.
The drawto function is not necessary when using
redraw functions (first example).
After creating a window, the library adds any new controls you create to that window. If you create a second window, the new controls will be added to this second window, because it was created more recently.
To add more controls to the first window you need to call the addto function, and supply as its parameter the first window. Then create the new controls.
Similarly, Motif will strip the newlines out of a text string used in buttons. Only the Athena version will properly allow multiple lines of text, and only because I wrote the code for the buttons myself.
The short answer is: don't do it. Your code won't be portable.