Using fonts on Windows
This topic includes the following sections:
- Defining font palette entries
- Setting the font for an application
- Setting the font for an object
- How fonts are applied
- Using fixed fonts
- Using proportional fonts
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:
- DEFAULT
- ALTERNATE
- DEBUGGER
- STATUS
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. |
|
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. |
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 runtime looks at the FONT_GLOBAL initialization setting, which specifies a font palette entry name. This allows the global font to be specified on a per application basis. See Setting application fonts in synergy.ini or synuser.ini below.
- If FONT_GLOBAL is not found or if it references an undefined font palette entry name, the runtime looks at the font specified by the DEFAULT setting in the [fonts] section of synergy.ini and synuser.ini. If it’s defined in both of these files, the synuser.ini setting overrides the setting in synergy.ini.
- If DEFAULT is not found, the runtime looks in the [fonts] section of synergy.ini and synuser.ini for the pre-version 6.3 initialization settings TYPE_FACE, FONT_HEIGHT, and FONT_WIDTH. If any of these are defined in both of these files, the synuser.ini settings override the settings in synergy.ini.
- If the TYPE_FACE, FONT_HEIGHT, and FONT_WIDTH settings are not found, the runtime uses Terminal font at the point size selected by the system as optimal (either the largest point size for which at least 80 columns of the font will fit on the screen or 10 point, whichever is smaller).
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.
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.
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. |
- The font specified by the FONT_HEADER, FONT_FOOTER, and FONT_INFO initialization settings in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini, where myprog is any .dbr file.
- The font specified by the reserved palette entry name STATUS in the [fonts] section of synergy.ini or synuser.ini. If a palette entry named STATUS is not defined, one will be defined using Arial font, point size 10, and sizing character “A”.
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.
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. |
- The font specified by the FONT_DEBUG initialization setting in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini
- The font specified by the reserved palette entry name DEBUGGER in the [fonts] section of synergy.ini or synuser.ini
- The font specified by the reserved palette entry name DEFAULT in the [fonts] section of synergy.ini or synuser.ini
- The font specified by the TYPE_FACE, FONT_HEIGHT, and FONT_WIDTH initialization settings in the [synergy], [dbr], or [myprog] sections of synergy.ini or synuser.ini
- The terminal font
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:
- Specifying the font for that class of object in synergy.ini or synuser.ini. (If this is defined in both files, the synuser.ini setting overrides the setting in synergy.ini.)
- Specifying the font in Repository.
- Specifying the font in your script file (either manually or using Composer).
- Using the Toolkit routines I_FLDMOD, IB_FIELD, or %U_WNDFONT.
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.
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 |
---|---|
Default font for numeric input fields (including dates and times). |
|
Default font for alphanumeric input fields (including user-defined). |
|
Default font for input field prompts. |
|
Default font for text in windows. |
|
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).
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. |
- Font specified for this field by I_FLDMOD
- Font specified for this field in a script file or by IB_FIELD
- Font specified in the repository for this field
- Font specified in the repository for the template that this field is derived from
- Font specified by %U_WNDFONT(D_SETWNDFONT)
- Font specified for the window in a script file
- Font specified for this class of object by FONT_NUMFLD, FONT_ALPHAFLD, FONT_PROMPT, FONT_TEXT, or FONT_LIST in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini
- Font specified by FONT_GLOBAL or FONT_ALTERNATE in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini
- Font specified by the reserved palette entry name DEFAULT or ALTERNATE in the [fonts] section of synergy.ini or synuser.ini
- Font specified by TYPE_FACE, FONT_HEIGHT, and FONT_WIDTH or ALT_TYPE_FACE, ALT_HEIGHT, and ALT_WIDTH in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini
- Terminal font, at the point size selected by the system as optimal (either the largest point size for which at least 80 columns of the font will fit on the screen or 10 point, whichever is smaller)
For the header, footer, and information line sections within the application window, Synergy/DE determines the font to use according to the following hierarchy:
- Font specified by FONT_HEADER, FONT_FOOTER, and FONT_INFO in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini
- Font specified by the reserved palette entry name STATUS in the [fonts] section of synergy.ini or synuser.ini. If a palette entry named STATUS is not defined, one will be defined using Arial font, point size 10, and sizing character “A”
For the debugger window, Synergy/DE determines the font to use according to the following hierarchy:
- Font specified by FONT_DEBUG in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini
- Font specified by the reserved palette entry name DEBUGGER in the [fonts] section of synergy.ini or synuser.ini
- Font specified by the reserved palette entry name DEFAULT in the [fonts] section of synergy.ini or synuser.ini
- Font specified by TYPE_FACE, FONT_HEIGHT, and FONT_WIDTH in the [synergy], [dbr], or [myprog] section of synergy.ini or synuser.ini
- Terminal font, at the point size selected by the system as optimal (either the largest point size for which at least 80 columns of the font will fit on the screen or 10 point, whichever is smaller)
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:
- Input windows
- Text windows
- Selection windows
- Lists
- List headers and footers
- Input window fields
- Prompts
- Application header, footer, and information line
Restrictions and recommendations for using proportional fonts
- Because Synergy/DE maintains support for Unix and OpenVMS applications, although a proportional font may make an input prompt or input field take up less space within the input window, you cannot take advantage of that extra space by placing something there. If you do place something, it will most likely be truncated or covered by another object.
- Static text and text in a window are compressed to the left and cannot be justified.
- A sizing character that is too wide may cause prompts to be clipped. A sizing character that is too narrow may cause extra space to be displayed between the prompt and the field.
- You cannot align prompts with leading spaces. Prompts should be positioned at the location where their text will begin.
- Whenever renditions change, justification is used. For example, if this text is in your script
This is \hbold\-h text.
there may be extra space between the words “is” and “bold” and “text.”
- Horizontal scrolling will occur if text exceeds the width of the edit control. However, a multi-line text field will wrap without scrolling. A multi-line text field will scroll vertically only if exceeds its frame.
- When attributes are set or cleared, the text that follows begins on a cell boundary, so there may be extra space between an attribute change and the text that precedes or follows it.
- Text objects used for field headings or prompts will not be positioned correctly and should not be used. Instead, you can use input fields that are not in the set and display the text to these input fields.
- We recommend that you use a fixed font for the following: the debugger window; when doing non-Toolkit processing; for Toolkit lists, because columns do not line up when a proportional font is used; and for text in a window other than prompts or fields, because the text may wrap in strange places.
- We recommend that you do not use proportional fonts in conjunction with the row and column arguments to %UWNDEVENTS_METHOD, because the column (x-direction) arguments are based on the sizing character for the window and not the actual text.
- Bold proportional fonts use an actual bold font rather than rendering bold as a color change the way fixed fonts do. Consequently, bold characters are more likely to be truncated, because Toolkit determines the width of the field or prompt using a non-bold (normal) font.
- For text fields (multi-line alpha fields), the number of characters displayed on each line is equal to the width of the arrayed field. For example, a 3a10 field will display 10 characters on each line, regardless of the font specified. This means there could be a gap between the last character of a line and the frame of the edit field.