In this assignment, you learn some basics about X's font service, including two standard X clients (xfontsel and xfd) that can save work as you develop new X applications. You will also try out different methods for passing arguments to an X application.
Experienced X programmer periodically re-visit their application defaults file. Settings added later in development often override earlier settings, making them redundant or useless. For the sake of both maintenance and ease-of-use, your final application should not include any extra, non-functional resources or widgets. Re-check each resource setting to be sure that it does something useful (commenting them out, or overriding them through command-line options is a good way of doing this); if not, be sure to remove it.
You should have read Chapter 2.5 in Nye and O'Reilly, Vol. 4, before starting this exercise.
If the application name is now fonts, what should the resource defaults file be called, according to X naming conventions? Which file(s) will this name appear in?
Make all necessary changes so that the program works properly with the new name.
Use the minimum number of resources necessary to alter the sizes of the button and box3, so that they are the same length as the label.
Should these be hardcoded, or in a resource file? Why?
Note that the label on the button now appears centered. Add the resource(s) necessary to left-justify the text.
Use xfontsel to choose a new font for all text. Note that you can use the select option of xfontsel to copy-and- paste the name directly into your copy of .Xdefaults.
How could you set the quit button to use a different font than the Label does?
xfd -fn "-adobe-times-*-*-*-*-*-*-*-*-*-*-*-*"
Try out a couple of aliases, like 9x15, heb6x13 and variable. Take a look at them using xfd, then use one or more in your program by specifying them as font resources.
How do you think X's alias names work?
Show how you would change the font to a font alias, using the command-line option.
Will the same mechanism work if you want to use a full font specifier (such as -adobe-times-*-*-*-*-*-*-*-*-*-*-*-*)? Prove your answer.
From your knowledge of strings in C, how else could you have embedded the dollar signs?
static String fallback_resources[] =
{"Fonts*font: variable",
NULL,};
(Make sure you choose a font that is distinct from the default used
when nothing is specified at all.)
What is the purpose of the "extra" NULL as the last element in array fallback_resources?
To inform the X Toolkit manager that you are providing a fallback resource setting, you must refer to it as the next-to-last argument in XtVaAppInitialize.
Add the code necessary to do this. Test your application by invoking it with and without additional font settings. When no font is specified in either the application defaults file or on the command-line, your fallback resource setting should be used. When the user specifies a font, it should take precedence over the fallback resource.
Where does the error message appear?
Fixing this problem requires quite sophisticated use of the Xlib routines. For the time being, you should be aware that not all fonts are supported, and you should test out your application on more than one type of machine display, noting whether or not the fonts change.