5.11 The Default GC Versus Default Values of a GC
The server creates one GC, called the default GC, when it starts
up. This GC is returned by the XDefaultGC() and the
DefaultGC() macro. It contains foreground and
background colors that are guaranteed contrasting (but not necessarily
black and white), and it contains a default font that is guaranteed to
be loaded, but is not necessarily the same font on all servers. The
values in the default GC must not be changed.
The default GC can be used in simple applications. But it is not very useful since all applications should provide user customization of fonts and colors, and few can avoid the need to modify other GC components as well.
When you create a GC of your own, its default values are slightly different from the values of the default GC. Its foreground and background values are 0 and 1, respectively, so they are not necessarily black and white or contrasting. That’s why you must always set foreground and background when you create a GC. Also, the default font is implementation dependent, and it may not be loaded. Therefore, you must always load the font before attempting to draw with it.
Table 5-3 shows the default values for all members of a graphics context you create.
Table 5-3. The Default Values of a Graphics Context
Component | Value |
|---|---|
|
|
| all
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Pixmap filled with ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access