Using fonts on Windows

This topic includes the following sections:

 

Because the fonts installed on each system may differ, we use the concept of a font palette to define the fonts that are actually used. A font palette consists of font palette entries, each of which associates a font name with a typeface, point size, and sizing character. (A sizing character determines cell width for an object using that font.)

A font palette is created in memory when the Synergy runtime starts up, and it exists for the duration of that runtime (dbr.exe). The runtime creates the initial font palette by reading font palette entries specified in the [fonts] section of the Synergy initialization file, synergy.ini, and then overrides or adds to the palette by reading synuser.ini. You can add new font palette entries and modify existing entries at runtime by calling the %U_WNDFONT function.

The runtime identifies font palette entries by palette entry name or font handle, either of which can be used when assigning fonts to objects at runtime. When assigning fonts to objects at script time, or through Composer or Repository, you must use palette entry names.

The font (typeface) specified in a font palette entry is either fixed (every character has the same width, such as Courier) or proportional (different characters have different widths, such as Arial). See Using fixed fonts and Using proportional fonts for more information.

Defining font palette entries

There are two ways to define the font palette entries used by the runtime to create the initial font palette: in the [fonts] section of synergy.ini or synuser.ini or by using Composer to add a [fonts] section to synuser.ini. (Composer can’t add a [font] section or font entries to synergy.ini.)

Defining font palette entries in synergy.ini or synuser.ini

To define font palette entries in synergy.ini or synuser.ini, manually add them to the [fonts] section. (You can also use the D_SAVEFONT subfunction for %U_WNDFONT to add them to these files at runtime.)

Each font palette entry has the form

font_name=typeface;point_size[;sizing_char]

where font_name is the case-insensitive name of the font you’re defining, typeface is a case-sensitive string that indicates the font’s typeface (for example, Times New Roman), point_size is a numeric point size, and sizing_char is an optional single character used to determine the cell size for purposes of positioning. If sizing_char isn’t specified, it defaults to “A”.

Here are some example font palette entries:

Default=Fixedsys;9;A
Alternate=MS Sans Serif;10;W
My_input_font=Times New Roman;12

Four font names are reserved. If these names are not defined in synergy.ini or synuser.ini, they will be defined for you by the runtime:

For more information, see Setting the font for an application.

Defining font palette entries in Composer (synuser.ini)

When a window or input field is selected in Composer’s Application window, you can add or modify font palette entries in the [fonts] section of synuser.ini. To do so,

1. Select a window or input field in the Application window.
2. If you selected an input field, double-click the “Font selected” attribute and change the property to Yes. (You can also do this from the “Font selected” attribute below the “Prompt attribute”.)
3. Click the drilldown button for the Font attribute to display the Font Palette dialog box.
4. Click the Add button to display the Add Font dialog box.
5. Enter a new name in the Font name field and click OK. The Font dialog box is displayed. See figure 1

1. Defining a font.

Defining a font

6. Specify a typeface, point size, and sizing character, then click the OK button to exit the Font dialog and click OK again to exit the Font Palette dialog box. Composer updates the synuser.ini file to reflect your changes.
Tip

You can also modify the typeface, point size, or sizing character for existing fonts by highlighting the font you want to change in the Font Palette dialog box and clicking the Modify button.

Defining font palette entries at runtime

You can define or modify font palette entries at runtime using the %U_WNDFONT(D_SETFONT) function. D_SETFONT enables you to define the characteristics of a font. Use the following syntax:

%U_WNDFONT(D_SETFONT, font_id, face_name, point_size[, sizing_char])

The font_id argument specifies the font palette entry name or handle of the existing font you are defining. If successful, this call to %U_WNDFONT returns the font’s handle. From this point on, you can refer to this palette entry by either palette entry name or font handle.

The D_SETFONT subfunction adds a font palette entry to memory or updates a font palette entry in memory. To save a font palette entry to synergy.ini or synuser.ini, use the D_SAVEFONT subfunction.

Setting the font for an application

The Synergy runtime supports two global fonts. An application window defined as less than 132 columns uses the “global font.” If automatic font switching is enabled, an application window of 132 columns or more uses the “alternate font”. If you choose the alternate font carefully, it may enable the window to fit on the screen.

To determine the initial global font when an application starts up,

The logic described above is also used when determining the font palette entry name to use for the initial alternate font. The initialization settings involved are FONT_ALTERNATE, ALTERNATE, ALT_TYPE_FACE, ALT_FONT_HEIGHT, and ALT_FONT_WIDTH.

Tip

We recommend using the DEFAULT and ALTERNATE settings in the [fonts] section of synergy.ini or synuser.ini rather than the pre–version 6.3 TYPE_FACE, FONT_HEIGHT, FONT_WIDTH, ALT_TYPE_FACE, ALT_FONT_HEIGHT, and ALT_FONT_WIDTH settings.

Setting application fonts in synergy.ini or synuser.ini

Use the FONT_GLOBAL and FONT_ALTERNATE initialization settings to specify the initial global and alternate fonts that will be used in your application. They should be specified in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini, where myprog is any .dbr file.

FONT_GLOBAL and FONT_ALTERNATE have the syntax

FONT_GLOBAL=palette_name

and

FONT_ALTERNATE=palette_name

Use the DEFAULT and ALTERNATE reserved palette entry names to define the characteristics of fonts that will be used if FONT_GLOBAL and FONT_ALTERNATE are undefined. See Defining font palette entries in synergy.ini or synuser.ini for the syntax.

Setting application fonts at runtime

To modify the global or alternate fonts used by your application after it has started up, use the %U_WNDFONT(D_SETFONT) function to modify the characteristics of the font IDs DF_DEFAULT and DF_ALTERNATE. Use the following syntax:

%U_WNDFONT(D_SETFONT, font_id, face_name, point_size[, sizing_char])

where font_id specifies which font ID to modify.

See Utility Routines for more information on using %U_WNDFONT and its subfunctions, including D_CHOOSEFONT, which displays the Font dialog box and enables your users to define font characteristics graphically.

Setting fonts for the header, footer, and information line

The Synergy header, footer, and information line of the application window use their own fonts. The initial fonts are one of the following, in order of precedence.

Note

For settings in synergy.ini and synuser.ini, definitions in the [myprog] section override definitions in [dbr], and definitions in [dbr] override definitions in [synergy]. In addition, a definition in synuser.ini overrides the same definition in the same section of synergy.ini.

Setting fonts for the Synergy debugger

The Synergy debugger window uses its own font. The initial “debugger font” is one of the following, in order of precedence.

Note

For settings in synergy.ini and synuser.ini, definitions in the [myprog] section override definitions in [dbr], and definitions in [dbr] override definitions in [synergy]. In addition, a definition in synuser.ini overrides the same definition in the same section of synergy.ini.

Setting the font for an object

By default, the font used for an application is the font used for all objects within that application. You can override the default font for an object by doing any of the following:

In all of these cases, the font that you specify should already be defined in your font palette. See How fonts are applied for information about the defaulting hierarchy used if a referenced font is undefined.

If a font is specified for a window, it becomes the default for all objects in that window unless otherwise specified. The window is sized according to the metrics of that font, and objects are positioned according to rows and columns based upon the sizing character for that font. Likewise, if a font is specified for any other object or component, the object is sized according to the metrics for that font.

Note

If a proportional font is specified for a window, objects in the window that do not support proportional fonts may not display as expected. See Using proportional fonts for a list of objects that support proportional fonts.

Setting fonts for a class of objects

You can define a font for a particular class of objects. This enables you to more easily migrate your application to proportional fonts.

Use one or more of the following initialization settings in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini to define the default font for the specified classes:

Setting

What it specifies

FONT_NUMFLD

Default font for numeric input fields (including dates and times).

FONT_ALPHAFLD

Default font for alphanumeric input fields (including user-defined).

FONT_PROMPT

Default font for input field prompts.

FONT_TEXT

Default font for text in windows.

FONT_LIST

Default font for lists.

Setting fonts for an object in Repository

Repository enables you to assign a font to a field or template. If you assign a font to a template, the font is used by all fields that use that template. You can also specify a font for a template or field prompt.

To specify fonts in Repository, enter a font palette entry name in the Font field and one in the Prompt font field on the Display tab of the Field Definition or Template Definition window. See Display information for more information.

You can also specify fonts using the Synergy Data Language. The FIELD, GROUP, and TEMPLATE statements all have FONT, NOFONT, PROMPTFONT, and NOPROMPTFONT keywords. Refer to Synergy Data Language for more information about these keywords.

Setting fonts for an object in a script file

You can set fonts in your script file using the .FONT command and certain qualifiers of the .FIELD command. You can also specify fonts in Composer by setting the Font and Font selected properties for an object. Composer will then generate the script file for you.

To set a window font in a script file, use the .FONT command, which has the following syntax:

.FONT palette_name

To set a field or prompt font in a script file, use the FONT and PROMPTFONT qualifiers of the .FIELD command. These qualifiers have the syntax

[, FONT(palette_name)]

and

[, PROMPTFONT(palette_name)]

To override a font specified for a repository field, use the NOFONT and NOPROMPTFONT qualifiers. If NOFONT or NOPROMPTFONT is specified, your application will use the input window’s font for the affected field or prompt.

Setting fonts for an object at runtime

You can set window fonts using the %U_WNDFONT function and input field fonts using the I_FLDMOD or IB_FIELD subroutine.

To set a window font at runtime, use the following syntax:

%U_WNDFONT(D_SETWNDFONT, window_id, font_id)

To set the font for a field or prompt at runtime, use I_FLDMOD or IB_FIELD. For either routine, use the following argument qualifiers:

D_FLD_FONT, font_id

and

D_FLD_PROMPTFONT, font_id

To tell your application to use the input window’s font for fields and prompts, turn D_FLD_FONT and D_FLD_PROMPTFONT off with the D_OFF qualifier, as follows:

D_OFF, D_FLD_FONT

and

D_OFF, D_FLD_PROMPTFONT

How fonts are applied

For the application window and the objects within it, Synergy/DE determines the font to use according to the following order of precedence (from highest to lowest).

Note

For settings in synergy.ini and synuser.ini, definitions in the [myprog] section override definitions in [dbr], and definitions in [dbr] override definitions in [synergy]. In addition, a definition in synuser.ini overrides the same definition in the same section of synergy.ini.

For the header, footer, and information line sections within the application window, Synergy/DE determines the font to use according to the following hierarchy:

For the debugger window, Synergy/DE determines the font to use according to the following hierarchy:

Using fixed fonts

If you are using a fixed font on Windows, the foreground color (which is the text color) will change according to the following rules: If the foreground color for the palette is in the range 0-7 and the rendition for the object includes a bold attribute, 8 is added to the number for the foreground color. If reverse is applied, the background color and the foreground color are swapped and the above rules are applied to the new foreground color. For instance, the default rendition for fields that aren’t in the current input set is palette 3 and includes the bold attribute. So, if you haven’t changed this setting and the foreground color is in the range 0-7, it will be increased by 8 (3 will become 11, and so forth).

Using proportional fonts

The following UI Toolkit objects support proportional fonts:

This is \hbold\-h text.

there may be extra space between the words “is” and “bold” and “text.”