# Administering Application Resources, Fonts, and Colors

You can choose a wide range of colors and fonts for your display either by using Style Manager or by customizing additional font and color resources. This chapter discusses how to customize fonts and color resources.

This chapter also describes how to specify style translations for `DtEditor` widget applications such as the desktop text editor (`dtpad`) and Mailer (`dtmail`), and alternates for `DtEditor` widget application menu accelerators that conflict with these translations.

SAG.FACol.div.2
SAG.FACol.div.6
SAG.FACol.div.10
SAG.FACol.div.18
SAG.FACol.div.30

.

## Setting Application Resources

Resources are used by applications to set certain aspects of appearance and behavior. For example, Style Manager (`dtstyle`) provides resources that enable you to specify where the system looks for files containing information about color palettes:

    dtstyle*paletteDirectories: /usr/dt/palettes/C \ HomeDirectory/.dt/palettes

App-default files for the desktop applications are located in the `/usr/dt/app-defaults/`language directory.

### To Set System-Wide Resources

1. Add the resources to the file `/etc/dt/config/`language`/
   sys.resources`. (You may have to create the file.)

   For example, if in `/etc/dt/config/C/sys.resources` you specify:

       AnApplication*resource: value

   then the resource `AnApplication*resource` will be set in each user's RESOURCE_MANAGER property at the next login.

### To Set Personal Resources

1. Add the resources to the file HomeDirectory`/.Xdefaults`.

2. Double-click Reload Resources in the Desktop_Tools application group.

### How the Desktop Loads Resources

Resources are loaded at session start-up by Session Manager. For information on how Session Manager loads the resources into the RESOURCE_MANAGER, see SAG.SesMg.mkr.7.

## Defining UNIX Bindings

By default UNIX bindings are not enabled.

### To Specify EMACS-Style Translations

The following procedure specifies:

- EMACS-style translations for `DtEditor` widget applications such as the desktop Text Editor (`dtpad`) and Mailer (`dtmail`)

- Alternates for `DtEditor` widget application menu accelerators that conflict with these translations.

1. Add the following line to the HomeDirectory`/.Xdefaults` file:

   `#include “/usr/dt/app-defaults/`language`/UNIXbindings”`

   where language is the value of the LANG environment variable.

2. Restart your session.

### To Modify the EMACS-Style Translations

1. Insert the contents of the file `/usr/dt/app-defaults/`language`/UNIXbindings` into HomeDirectory`/.Xdefaults`.

2. Edit the bindings in the `.Xdefaults` file.

3. Restart your session when you have finished.

### UNIX Bindings Provided by the UNIXbindings File

The `/usr/dt/app-defaults/`language`/UNIXbindings` file provides the following bindings:

The Delete key deletes the previous character when the UNIX bindings are enabled, and Shift-Delete deletes the next character. Note that not all vendors' keyboards supply these keys. Please see your local vendor's documentation for alternate key bindings.

- SAG.FACol.tbl.1 lists the `dtpad` overrides for menu accelerators and accelerator text that conflict with the UNIX bindings.

### `dtpad` Overrides for Menu Accelerators and Accelerator Text

`Menu Accelerators and Accelerator Text` | `Override`
`Dtpad*fileMenu.print.acceleratorText:` |
`Dtpad*fileMenu.print.accelerator:` |
`Dtpad*editMenu.undo.acceleratorText:` | Ctrl+_
`Dtpad*editMenu.undo.accelerator:` | Ctrl<Key>_
`Dtpad*editMenu.paste.acceleratorText:` | Shift+Insert
`Dtpad*editMenu.paste.accelerator:` | Shift<Key>osfInsert
`Dtpad*editMenu.selectAll.acceleratorText:` | Ctrl+/
`Dtpad*editMenu.selectAll.accelerator:` | Ctrl<Key>/

- SAG.FACol.tbl.2 lists the `dtmail` Compose window overrides for menu accelerators and accelerator text that conflict with the UNIX bindings.

### `dtmail` Compose Window Overrides

`Menu Accelerators and Accelerator Text` | `Override`
`Dtmail*ComposeDialog*menubar*Edit.Undo.acceleratorText:` | Ctrl+_
`Dtmail*ComposeDialog*menubar*Edit.Undo.accelerator:` | Ctrl<Key>_
`Dtmail*ComposeDialog*menubar*Edit.Paste.acceleratorText:` | Shift+Insert
`Dtmail*ComposeDialog*menubar*Edit.Paste.accelerator:` | Shift<Key>osfInsert
`Dtmail*ComposeDialog*menubar*Edit.Find/Change.acceleratorText:` | Ctrl+S
`Dtmail*ComposeDialog*menubar*Edit.Find/Change.accelerator:` | Ctrl<Key>s

- The following translations provide (GNU style) EMACS control and meta key bindings plus some additional bindings. When appropriate, they also allow the Shift key to be used in combination with the normal binding to reverse the direction of the operation. For example, Ctrl+Shift+F will move the cursor backward a character since Ctrl+F normally moves it forward a character.

  The additional bindings are:

  Ctrl+comma

- backward-word

Ctrl+Shift+comma

- forward-word

Ctrl+period

- forward-word

Ctrl+Shift+period

- backward-word

Ctrl+Return

- end-of-file

Ctrl+Shift+Return

- beginning-of-file

GNU EMACS binds delete-previous-character() rather than delete-next- character() to the Delete key. Meta+F is normally the mnemonic for the File menu, so the binding to forward-word() will be ignored. Use one of the other bindings for forward-word (for example, Ctrl+period).

- SAG.FACol.tbl.3 lists the `DtEditor.text` Translations

### `DtEditor.text` Translations

`Modifier Key` | `Key` | `Action Routine`
c ~s | <Key>a: | beginning-of-line()\n\
c s | <Key>a: | end-of-line()\n\
c ~s | <Key>b: | backward-character()\n\
c s | <Key>b: | forward-character()\n\
c ~s | <Key>b: | backward-character()\n\
c s | <Key>b: | backward-word()\n\
m ~s | <Key>b: | backward-word()\n\
m s | <Key>b: | forward-word()\n\
c ~s | <Key>d: | delete-next-character()\n\
c s | <Key>d: | delete-previous- character()\n\
m ~s | <Key>d: | kill-next-word()\n\
m s | <Key>d: | kill-previous-word()\n\
c ~s | <Key>e: | end-of-line()\n\
c s | <Key>e: | beginning-of-line()\n\
c ~s | <Key>f: | forward-character()\n\
c s | <Key>f: | backward-character()\n\
m ~s | <Key>f: | forward-word()\n\
m s | <Key>f: | backward-word()\n\
c | <Key>j: | newline-and-indent()\n\
c ~s | <Key>k: | kill-to-end-of-line()\n\
c s | <Key>k: | kill-to-start-of-line()\n\
c | <Key>l: | redraw-display()\n\
c | <Key>m: | newline()\n\
c s | <Key>n: | process-up()\n\
c ~s | <Key>n: | process-down()\n\
c | <Key>o: | newline-and-backup()\n\
c ~s | <Key>p: | process-up()\n\
c s | <Key>p: | process-down()\n\
c ~s | <Key>u: | kill-to-start-of-line()\n\
c s | <Key>u: | kill-to-end-of-line()\n\
c ~s | <Key>v: | next-page()\n\
c s | <Key>v: | previous-page()\n\
m ~s | <Key>v: | previous-page()\n\
m s | <Key>v: | next-page()\n\
c | <Key>w: | kill-selection()\n\
c ~s | <Key>y: | unkill()\n\
m | <Key>]: | forward-paragraph()\n\
m | <Key>[: | backward-paragraph()\n\
c ~s | <Key>comma: | backward-word()\n\
c s | <Key>comma: | forward-word()\n\
m | <Key>\\<: | beginning-of-file()\n\
c ~s | <Key>period: | forward-word()\n\
c s | <Key>period: | backward-word()\n\
m | <Key>\\>: | end-of-file()\n\
c ~s | <Key>Return: | end-of-file()\n\
c s | <Key>Return: | beginning-of-file()\n\
~c ~s ~m ~a | <Key>osfDelete: | delete-previous- character()\n\
~c s ~m ~a | <Key>osfDelete: | delete-next-character()

## Administering Fonts

Using the Style Manager Font dialog box, you can select the font size you want for all applications. You can also specify fonts on the command line or use resources to:

- Set font resources for individual applications

- Assign different fonts to be used by the Font dialog box

A font is a type style in which text characters are printed or displayed. The desktop includes a variety of fonts in different styles and sizes.

A bitmap font
is made from a matrix of dots. (By default, Style Manager configures bitmap fonts only.) The font is completely contained in one file. Many files are needed to have a complete range of sizes, slants, and weights.

Fonts are specified as values of resources and as parameters to commands. The X Logical Font Description (XLFD) name is the method by which a desired font is requested. The system finds the font that best matches the description it was given.

### Setting Desktop Font Resources

The Style Manager Font dialog box enables you to set fonts (up to seven sizes) for things such as text entry and labels.

#### Resources Set by the Font Dialog Box

When a font is selected, the following resources are written to the RESOURCE_MANAGER property:

- `SystemFont` is used for system areas, such as menu bars, menu panes, push buttons, toggle buttons, and labels. The following resource is set by `SystemFont`:

  `*FontList` | Displayed in system areas of desktop clients and other clients created using the Motif toolkit.

- `UserFont` is used for text entered into windows. The following resources are set by `UserFont`:

  `*Font` | Supports earlier versions of X applications
  `*FontSet` | The primary setting
  `*XmText*FontList` | Displayed in text entry boxes
  `*XmTextField*FontList` | Displayed in text entry boxes

#### Resources Used by the Font Dialog Box

The fonts used for each selection in the Font dialog box are specified in the `/usr/dt/app-defaults/Dtstyle` resource file. Up to seven sizes can be specified.

`NumFonts` | Number of font sizes in the Font dialog box
`SystemFont[1-7]` | Up to seven resources assigning a specific font to a Font dialog box selection for `SystemFont`
`UserFont[1-7]` | Up to seven resources assigning a specific font to a Font dialog box selection for `UserFont`

The default fonts for these resources have been chosen for readability on various displays. If you want a specific font for an application, set the font with an application font resource rather than changing these desktop fonts.

For more information about application fonts, seethe `DtStdAppFontNames` (`5`) and `DtStdInterfaceFontNames` (`5`) man pages.

### To List Available Fonts

1. Type the following:

       xlsfonts [-options] [-fn pattern]

   A list of XLFD names and font alias names available on your system is displayed. Bitmap fonts show values in all fourteen XLFD fields. Scalable typefaces show zeros in the PixelSize, PointSize, ResolutionX, and ResolutionY positions.

2. To check for specific fonts, use the pattern-matching capability of `xlsfonts`. Use wildcards to replace the part of the pattern you are not trying to match.

3. If `xlsfonts` does not show any font names starting with `dt`, your font path does not include the desktop fonts. Type the following command to include the desktop fonts into your available fonts:

       xset +fp directory name

   where directory name is the directory containing the desktop fonts. The default location set by session startup is `/usr/dt/config/xfonts/`language.

For additional information, see:

- The `xset` and `xlsfonts` man pages list the available options.

- Using the X Window System explains font alias names and the `xset` client.

### To Specify Fonts on the Command Line

1. Use the `-xrm` command-line option to specify a font resource for a specific client. For example:

    application name -xrm “*bitstream-charter-medium-r-normal-8-88-75-75-p-45-iso8859-1”

### X Logical Font Description (XLFD)

A font is specified by listing fourteen different characteristics, separated by dashes (-). This is called the X Logical Font Description (XLFD). In some cases, a property in the list can be replaced by a * wildcard, and a character within a property can be replaced by a ? wildcard. SAG.FACol.tbl.4 lists font property string specifications.

The form of the property string specification is:

“-Foundry-FamilyName-WeightName- Slant-SetwidthName-AddStyleName-PixelSize- PointSize-ResolutionX-ResolutionY-Spacing- AverageWidth-CharSetRegistry-CharSetCoding”

### Font Property String Specification

`Property String` | `Definition`
Foundry | A string identifying the font designer
FamilyName | A string identifying the trademarked name of the font
WeightName | A string giving the relative weight of the font, such as bold
Slant | A code describing the direction of slant R (Roman–no slant) I (Italic–slant right) O (Oblique–slant right) RI (Reverse Italic–slant left) RO (Reverse Oblique–slant left)
SetwidthName | A string describing the width, such as compressed or expanded
AddStyleName | A string providing any additional information needed to uniquely identify the font
PixelSize | An integer giving the size of an em-square in pixels
PointSize | An integer giving the size of an em-square in decipoints
ResolutionX | An integer giving the horizontal resolution in pixels
ResolutionY | An integer giving the vertical resolution in pixels
Spacing | A code specifying the spacing between units `M` (Monospace--fixed pitch) `P` (Proportional space--variable pitch) `C` (Character cell)
AverageWidth | An integer giving the average width in 1/10th pixels
CharSetRegistry | A string identifying the registration authority that has registered the font encoding
CharSetEncoding | A string identifying the character set in the specified registry

#### Example

The following XLFD name describes a font named `charter` made by Bitstream that supports the ISO8859-1 standard encoding:

    -bitstream-charter-medium-r-normal--8-80-75-75-p-45-iso8859-1

It is medium weight, with no special slanting, and normal width. The font is proportional, with an em-square box of 8 pixels or 8.0 points. The horizontal and vertical resolution are both 75 pixels. The average width of a character is 45 1/10ths pixels or 4.5 pixels.

Parts of this string can be replaced by wildcards. The system uses the first font it finds that matches the parts you have specified.

If all you want is an eight-pixel `charter` font, you could use:

    *-charter-*-*-*-*-8-*

## Administering Colors

This section describes:

- How Style Manager sets display colors.

- Resources used by Style Manager to control desktop color usage.

### Color Palettes

A palette consists a group of color sets. The color sets for the current palette are shown in the Style Manager Color dialog box

A file exists for each palette. The `paletteDirectories` resource specifies the directories containing palette files. By default, this resource contains:

- Built-in palettes: `/usr/dt/palettes`

- System-wide palettes: `/etc/dt/palettes`

- Personal palettes: HomeDirectory`/.dt/palettes`

### Color Sets

Each color set in the current palette is represented by a color button in the Style Manager Color dialog box. Each color is identified by a color set ID—a number from 1 to 8.

#### Color set ID values for HIGH_COLOR

Each color set is composed of up to five colors. Each color button displays the background color of the color set. The five colors in each color set represent the following display component resources:

`foreground`
The foreground of an application window or window frame. It is always black or white. This is generally used for text within windows and titles.
`background`
The background of the application or the window frame.
`topShadowColor`
The color of the top and left bevels of application controls (such as push buttons) and window frames.
`bottomShadowColor`
The color of the bottom and right bevels of application controls and window frames.
`selectColor`
The color that indicates the active state of certain controls, such as active toggles and buttons.

The number of color sets used by each palette is determined by the `colorUse` resource, which the user can set using the Style Manager Number of Colors To Use dialog box.

#### Specifying Color Values

Style Manager uses
RGB values when writing color information to its palette files. The syntax for RGB numbers is:

    #RedGreenBlue

Red, Green, and Blue are hexadecimal numbers, each 1 to 4 digits long, that indicate the amount of that color used. There must be the same number of digits for each of the colors. Thus, valid color values consist of 3, 6, 9, or 12 hexadecimal digits.

For example, white can be specified in any of the following ways:

    #fff
    #ffffff
    #fffffffff
    #fffffffffffff

If you set a color resource directly, you can use either the color name or RGB value. The file `/usr/lib/X11/
rgb.txt` lists all the named colors.

#### How Color Sets are Mapped to Resources

The desktop maps color sets to various display elements through resources, and makes the following assignments:

Resource | Display element
`activeColorSetId` | Active window frame color
`inactiveColorSetId` | Inactive window frame color
`textColorSetId` | Text entry areas
`primaryColorSetId` | Application's main background areas
`secondaryColorSetId` | Application's menu bar, menus, and dialog boxes

These resources take a color set ID as their value. Coloring display elements with color set IDs allows the element to dynamically change to the new color scheme when a new palette is selected with Style Manager.

You can use these resources for individual applications. For example, the following line shows how you would visually group all `dtterm` windows by using color set 8 for their primary color.

    dtterm*primaryColorSetId:  8

#### Default Color Set Assignments

The color set IDs used for display elements depends on the Number of Colors setting in Style Manager:

- High color (8 color sets)—Style Manager setting More Colors for Desktop:

  Color set ID | Display element
  1 | Active window frame color
  2 | Inactive window frame color
  3 | Unused (by default)
  4 | Text entry areas
  5 | Application's main background areas
  6 | Application's menu bar, menus, and dialog boxes
  7 | Unused by default
  8 | Front Panel background

- Medium color (4 color sets)—Style Manager setting More Colors for Applications:

  Color set ID | Display element
  `1` | Active window frame color
  `2` | Inactive window frame color
  `3` | Application and Front Panel background color
  `4` | Text entry areas

- Low color (2 color sets)—Style Manager setting Most Colors for Applications.

  Color set ID | Display element
  1 | Active window frame, workspace selection buttons
  2 | All other display elements

### Controlling Color with Style Manager

You can dynamically change color for desktop applications and other cooperating applications through Style Manager. The foreground and background colors set by Style Manager are available to non-cooperating applications.

- For a client to respond to Style Manager color changes, the client must be using the desktop Motif library. Clients written with other toolkits cannot change color dynamically in response to Style Manager changes. Color changes for these clients do not take effect until the client is restarted.

- There must be no other specific color resources applied for the client. This includes user-specified resources, appdefaults, and resources built into the application.

- Clients can specify `
  primaryColorSetId` and `
  secondaryColorSetId` resources to use certain colors within a desktop palette.

### Number of Colors Used by Style Manager

The number of colors used by Style Manager depends on the values for the following resources:

`colorUse` | Configures the number of colors the desktop uses
`shadowPixmaps` | Directs the desktop to replace the two shadow colors with pixmaps
`foregroundColor` | Specifies if the foreground color changes dynamically.
`dynamicColor` | Controls whether applications change color when you switch palettes.

SAG.FACol.tbl.5 lists the maximum number of colors allocated by the desktop.

### Number of Desktop Colors

Display | `Maximum Number of Colors` | `Number Derived From`
B_W | 2 | Black and white
LOW_COLOR | 12 | Two color sets times five colors plus black and white
MEDIUM_COLOR | 22 | Four color sets times five colors plus black and white
HIGH_COLOR | 42 | Eight color sets times five colors plus black and white

To determine the maximum number of colors:

1. Multiply the number of color sets in the palette by the number of colors within each color set.

2. Add 2 (for black and white).

However, with the following configuration you would only have ten colors in your palette: four color sets times two colors in each set (`background` and `selectColor`) plus black and white:

    *colorUse: MEDIUM_COLOR
    *shadowPixmaps:  True
    *foregroundColor: White

Multi-color icons use fourteen additional colors.

#### colorUse Resource

The default value of the `colorUse` resource is MEDIUM_COLOR. The value of this resource affects the number of color sets used in a palette. Other resources affect the number of colors used to make shadows. The value of the `colorUse` resource also affects the use of multi-color icons.

Value | Description
B_W | “Black and White” Style Manager setting Displays with 1 to 3 color planes Number of color sets: 2 Maximum number of colors: 2 Default number of colors: 2 No multicolor icons
LOW_COLOR | “Most Color for Applications” Style Manager setting Displays with 4 to 5 color planes Number of color sets: 2 Maximum number of colors: 12 Default number of colors: 12 No multicolor icons
MEDIUM_COLOR | “More Colors for Application” Style Manager setting Displays with 6 color planes Number of color sets: 4 Maximum number of colors: 22 Default number of colors: 22 Multicolor icons
HIGH_COLOR | “More Colors for Desktop” Style Manager setting Displays with 7 or more color planes Number of color sets: 8 Maximum number of colors: 42 Default number of colors: 42 Multicolor icons\
default | The desktop chooses the correct value for that display. (To reduce the number of colors used by the desktop for high-color displays, the default `colorUse` resource is set to MEDIUM_COLOR.)

#### shadowPixmaps Resource

The `shadowPixmaps` resource directs the desktop to replace the two shadow colors with pixmaps. These pixmaps mix the background color with black or white to simulate top or bottom shadow values. This reduces the number of needed colors by two, since color cells do not need to be allocated for the shadow colors.

Value | Description
True | The desktop creates a `topShadowPixmap` and `bottomShadowPixmap` to use instead of the shadow colors.
False | `topShadowColor` and `bottomShadowColor` from the palette are used.

The default value for `shadowPixmaps` depends on the `colorUse` resource you have and the hardware support for the display.

#### foregroundColor Resource

The `foregroundColor` resource specifies how the foreground is configured in a palette.

Setting | Result
White | Foreground is set to white.
Black | Foreground is set to black.
Dynamic | (Default) Foreground is dynamically set to black or white, depending on the value of `background`. For instance, white letters on a yellow background are difficult to read, so the system chooses black.

If `foregroundColor` is set to either Black or White, the number of colors in the color set is reduced by one, and the foreground will not change in response to changes in the background color.

The default value for `foregroundColor` is Dynamic, except where the value of `colorUse` is B_W.

#### dynamicColor Resource

The `dynamicColor` resource controls whether applications change color dynamically; that is, whether the clients change color when you switch palettes.

Value | Description
True | Clients change color dynamically when a new palette is selected. This is the default value.
False | Clients do not change color dynamically. When a new palette is selected, clients will use the new colors when the session is restarted.

When the value of the `dynamicColor` resource is True, clients that cannot change colors dynamically (non-Motif applications) allocate different cells in the color map than clients that can change colors dynamically, even if you see the same color.

Since all clients can share the same color cells, setting `dynamicColor` to False reduces the number of colors your desktop consumes.

## Setting Shadow Thicknesses for Application Windows

The desktop defines a default shadow thickness of one pixel for the components in application windows, such as button shadows and focus highlight. Motif 1.2 (or later) applications use this resource value; other applications may not obtain this resource value and therefore will appear different on the display.

To set the shadow thickness to one pixel for non-Motif 1.2 (or later) applications:

1. Log in as root.

2. Create the `/etc/dt/config/`language`/sys.resources` file.

3. Specify the application-specific resource in `/etc/dt/config/`language`/sys.resources` as follows:

       application_class_name*XmCascadeButton*shadowThickness: 1

For more information about overriding system default resources and specifying additional resources for all desktop users, see SAG.SesMg.mkr.7