HP OpenVMS Systems Documentation |
DECwindows Motif Guide to Application Programming
Chapter 10
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 -ADOBE-ITC Avant Garde Gothic-Book-R-Normal--14-100-100-100-P-80-ISO8859-1 |
In the example:
The DECwindows Motif Toolkit first tries to load the specified font. If it is unable to successfully load the font, the DECwindows Motif Toolkit uses the fallbacks listed in Table 10-1 and Table 10-2.
The font fallback implementation uses whatever matching fonts are available on the display including, but not limited to, the DECwindows and X11 R5 server fonts. Asterisks indicate a wildcard.
Field | Fallback | |
---|---|---|
(Foundry) | ||
All families but Terminal | Adobe | |
(Family) | ||
ITC Avant Garde Gothic | Helvetica | |
ITC Lubalin Graph | New Century Schoolbook | |
Menu | Helvetica | |
ITC Souvenir | Times | |
Any other | Fixed | |
(Weight) | ||
Menu family | Bold (overrides any other weight remapping) | |
Book weight | Medium | |
Demi weight | Bold | |
Light weight | Medium | |
(Style) | ||
ITC Lubalin Graph family
and O slant |
Italic | |
(Width) | ||
All AVERAGE_WIDTH values | * | |
(Pixel Size When Not DPI 100) | ||
* | * | |
(Pixel Size When DPI 100) | ||
10 | 11 | |
13 | 14 | |
16 | 17 | |
19 | 20 | |
24 | 25 | |
33 | 34 |
Field | Fallback | |
---|---|---|
(Foundry) | ||
* | * | |
When 75 dpi | DEC | |
When 100 dpi | Bitstream | |
(Pixel Size) | ||
* | * | |
When 75 dpi | 14 | |
When 100 dpi | 18 | |
(Setwidth Name) | ||
All SETWIDTH_NAME values | Normal | |
(Point Size) | ||
All POINT_SIZE values | 140 | |
(Average Width) | ||
All AVERAGE_WIDTH values | * |
Note that the font fallback implementation does not remap all of the font name fields. For example, the x and y resolution fields (in pixels or dots per inch) are not remapped. Because not all screens support both 75 dpi and 100 dpi fonts, you can use wildcards for these fields to avoid interoperability problems. Font name fields that are not remapped while generating the new font name remain unchanged. |
The Fixed font is returned if the family, weight, slant, width,
character set registry, or character set encoding font name fields are
wildcarded or if the font name syntax cannot be parsed (for example, if
hyphens are not positioned correctly or are missing). Note that the
terminal line-drawing characters are not available in the Fixed font.
10.2.3 Using Common Fonts
If your application specifies fonts through the Toolkit routines but does not use the DXmLoadQueryFont or DXmFindFontFallback routines to determine a fallback font, the application should use only fonts common to both the DECwindows and X11 R5 servers.
The font fallback policy implemented through UIL and the DXmLoadQueryFont and DXmFindFontFallback routines provides the best assurance of finding a suitable font. However, if your application uses only fonts common to both the DECwindows and X11 R5 servers, the application will be able to display on other vendors' workstations that support the X11 fonts.
Font families common to both DECwindows and X11 R5 are as follows:
You can use FONT function and the VALUE declaration to create font lists through UIL. For example, the following UIL code segment defines a font by using the FONT function and the VALUE declaration:
VALUE k_button_font : font('-ADOBE-Courier-Bold-R-Normal--14-140-75-75-M-90-ISO8859-1'); |
If this font is not available when the widget associated with it is fetched, the DECwindows Motif Toolkit determines the fallback font as described in Section 10.2.2.
If for some reason the font fallback implementation is not appropriate
for your application, do not specify the font through UIL. Instead, use
the Toolkit routines to select a fallback font.
10.2.5 Implementing Font Fallback Through Toolkit Routines
The program in Example 10-1 creates a font list and uses it to specify the font used in a CSText widget.
Example 10-1 Font Fallback Through Toolkit Routines |
---|
#include <stdio> #include <Mrm/MrmAppl.h> #include <DXm/DXmCSText.h> static void change_cs(); static void ok_text(); XmString cstring; Widget toplevel, text_shell, text_label, text_w, ok_button; int main(argc, argv) unsigned int argc; char **argv; { XtAppContext app_context; Arg arglist[15]; int ac = 0; (1)XFontStruct *font; (2)XmFontList font_list; XtCallbackRec callback_arg[2]; toplevel = XtAppInitialize(&app_context, "example", NULL, 0, &argc, argv, NULL, NULL, 0); ac = 0; cstring = XmStringCreateLtoR("User Defined", XmSTRING_ISO8859_1); XtSetArg( arglist[ac], XmNdialogTitle, cstring);ac++; XtSetArg( arglist[ac], XmNallowOverlap, TRUE);ac++; XtSetArg( arglist[ac], XmNheight, 300);ac++; XtSetArg( arglist[ac], XmNwidth, 300);ac++; XtSetArg( arglist[ac], XmNresizePolicy, XmRESIZE_GROW);ac++; text_shell = XmCreateBulletinBoard(toplevel, "CSText", arglist, ac ); XmStringFree(cstring); ac = 0; cstring = XmStringCreateLtoR("Enter a 10-letter title\nfor this widget", XmSTRING_ISO8859_1); XtSetArg( arglist[ac], XmNlabelString, cstring);ac++; XtSetArg( arglist[ac], XmNx, 90);ac++; XtSetArg( arglist[ac], XmNy, 20);ac++; text_label = XmCreateLabel(text_shell, "textlabel", arglist, ac ); XmStringFree(cstring); (3)font = DXmLoadQueryFont( XtDisplay (toplevel), "-ADOBE-Courier-Bold-R-Normal--14-140-*-*-M-90-ISO8859-1"); (4)if (font == NULL){ printf("Fonts Are Not Available"); exit(0); } (5)font_list = XmStringCreateFontList(font, XmSTRING_ISO8859_1); callback_arg[0].callback = change_cs; callback_arg[0].closure = 0; callback_arg[1].callback = NULL; callback_arg[1].closure = NULL; ac = 0; (6)XtSetArg( arglist[ac], XmNfontList, font_list ); ac++; XtSetArg( arglist[ac], XmNx, 40);ac++; XtSetArg( arglist[ac], XmNy, 100);ac++; XtSetArg( arglist[ac], XmNrows, 2 ); ac++; XtSetArg( arglist[ac], XmNcolumns, 35 ); ac++; XtSetArg( arglist[ac], XmNmaxLength, 10 ); ac++; XtSetArg( arglist[ac], XmNactivateCallback, callback_arg);ac++; text_w = DXmCreateCSText(text_shell, "textwidget", arglist, ac ); (7)XmFontListFree (font_list ); XtManageChild(text_w); XtManageChild(text_label); XtManageChild(text_shell); XtRealizeWidget(toplevel); XtAppMainLoop(app_context); } . . . |
You should not make any assumptions about the screen on which your
application will display. This section discusses several
interoperability issues related to screen independence.
10.3.1 Screen DPI Assumptions
As described in Section 10.2.2, not all screens support both 75 DPI and 100 DPI fonts. To avoid screen interoperability problems, you can use wildcards for the x and y resolution fields. The first example shows specific values for the x and y resolution fields:
VALUE k_button_font : font('-ADOBE-Courier-Bold-R-Normal--14-140-75-75-M-90-ISO8859-1'); |
This example uses wildcards for the x and y resolution fields:
VALUE k_button_font : font('-ADOBE-Courier-Bold-R-Normal--14-140-*-*-M-90-ISO8859-1'); |
DECwindows supports servers with multiple screens. Such systems are called multiheaded displays.
DECwindows servers currently support a maximum of two screens. However, other vendor's server implementations might support additional screens.
When you create a DECwindows application, you should not make any assumptions as to whether the application will run on screen zero (the default), screen one, or any other screen of a display. Rather, you should let the user specify the screen by using command line arguments, the SET DISPLAY command on OpenVMS systems, or the DISPLAY environment variable on UNIX and Windows NT systems.
If you hard code a screen number of zero, the user cannot display the application on any other screen. If you hard code a screen number of one, the user cannot display the application on any other screen.
Hard-coding screen numbers can result in severe limitations. For example, if you hard code a screen number of one and the server has only the default screen (screen zero), your application will not be able to open the display.
Note that there is no way for your application to determine in advance
of opening the display how many screens are attached. All of the Xlib
routines that return screen information require that you first open the
display. For example, your application must first open the display
before it can call Xlib routines such as XScreenCount or
XScreenofDisplay.
10.3.2.1 Using XtAppInitialize to Specify a Screen
DECwindows Motif Toolkit applications generally call the
XtAppInitialize routine to initialize the toolkit and open the display.
XtAppInitialize uses command line arguments or, if command line
arguments are not present, the result of the last command used to set
the DISPLAY environment variable (UNIX and Windows NT) or DISPLAY
logical (OpenVMS) to determine the display and screen to use. In this
way, XtAppInitialize uses the "default" display and screen;
it does not otherwise explicitly set the display or screen to use.
10.3.2.2 Using XtOpenDisplay to Specify a Screen
DECwindows Motif Toolkit applications that want to open a connection to a specific display or screen (without also initializing the toolkit) can call the XtOpenDisplay routine to open a display, initialize it, and add it to an application context.
XtOpenDisplay calls the Xlib routine XOpenDisplay with the specified display name. If the display name argument is null, XtOpenDisplay uses the current value of the display option specified in the command-line argvalue argument. If no display is specified in argvalue, XtOpenDisplay uses the result of the last command that defined DISPLAY.
The format of the display name argument is hostname:number.screen (UNIX and Windows NT) or hostname::number.screen (OpenVMS). The element hostname is the network name of the host, number is the number of the server on the host, and screen is the number of the screen to use. Currently, the screen number can be zero or one for DECwindows servers; additional screens are possible in other vendors' server implementations.
If you specifically wanted your application to use screen one, you could specify screen one in a call to XtOpenDisplay and then test to see if XtOpenDisplay returns NULL to indicate failure.
If your application will be displayed on PC or other small screens, you must make sure that your application windows are not too big to fit on the screen.
This section describes two possible implementations for adjusting window size:
Other implementations are also possible.
Previous | Next | Contents | Index |