2.5 font

All fonts you want to use have to be declared as a resource. The number of displayable fonts depends on the graphics system you use. The declaration of a font begins with the keyword font, followed by the identifier describing the font within the DM and by the font definition.

Definition

{ export | reexport } font <Identifier> <fontSpec> | <variantDef> ;
fontSpec ::=
  "<fontName>" { , <size> { , <modifier> } } |
  "<Predefined UI-Font>" |
  "<X Logical Font Description (XLFD)>" |                          // Motif, Qt
  "<fontName> [ , <parameter> ]" { , <modifier> } |                // Qt
  "<fontName>" { , <size> { , <modifier> { + <modifier> } } } |
  "<size>.<fontName>" | "<systemFont>"                             // Windows
  { x:= * <xscale> % + <xoffset> | / <xdivider>} { y:= * <yscale> % 
         + <yoffset> | / <ydivider>}
  { propscale }
  { r:= "<RefString >" } ;
variantDef ::=
{
           0 : <fontSpec>
  [ <number> : <fontSpec> ]
}

The name determined by the window system as well as size and attributes of the font are specified in the font definition.

Depending on your graphics system, it may not be possible to define font size and attributes independently of the selected font. In this case only the first font variant can be defined. Other following font sizes and attributes are ignored.

In addition to the system's means of viewing the available fonts, the list of fonts can also be viewed in the IDM Editor. Depending on the system, it is possible to filter the list of fonts by UI Fonts, XFT and XLFD.

Examples

Non-variant

font BIG          "white_shadow-48";
font KilterBold   "-adobe-courier-bold-r-normal*";
font KilterItalic "kilter 12i";
font UI "UI_FONT";

// Defines the font vtsingle of the window system X as font NORMAL in the IDM
font NORMAL "vtsingle";

// Defines the font Courier in size 12 as resource Courier
font Courier "Courier", 12;

// As in the previous definition, with the additional attribute bold
font Bold "Courier", 12, bold;

// Defines the font with the system font usually used for UI objects;
// additionally with the attribute propscale to control the font-raster
font UIpropscale "UI_FONT" propscale;

// Defines an XFT font (e.g. on an Ubuntu system); additionally the size 12 
// and the attribute bold for bold display are defined
font XFT "DejaVu Sans", 12, bold;

Variant

font BIG
{
  0: "white_shadow-48";
  1: "walla_walla-12";
  2: "helvetica", 24, bold;
  3: "harakiri",  48, roman;
}

2.5.1 Calculating the Grid Size from a Reference Font

On calculating the grid size from a reference font, you can specify correction factors at the font definition and thus can arbitrarily change the calculation base for the grid which was determined by the font.

It is also possible to specify a reference string for calculation of grid width. The grid width will then be calculated as width of the entire string, divided by the number of characters (with mathematical rounding). Specifying a reference string makes the calculation of grid width independent of the average and maximum character widths from the font description, which may vary between different systems. A reference string is defined by adding r:="<RefString>" to the font definition.

Based on the above font definition the grid size calculated as follows:

xraster = ((width of font) * xscale) / 100 + xoffset
yraster = ((height of edittext with this font) * yscale) / 100
          + yoffset

The effect of this calculation that the font size will be provided with the indicated factor and will then be enlarged according to the given constant.

 

The <xdivider>/<ydivider> allows the division of a raster without rounding effects. The IDM ensures that a raster in the full divider size is at least as large as the raster without divider. This ensures a complete object representation.

xraster = ((width of font) + (xdivider - 1 )) / xdivider
yraster = ((height of edittext with this font) + (ydivider - 1))) / ydivider

Example

font Font "6x13" x:=*150%+2 y:=*200%+10;

In this case, the grid size resulting from this font is calculated as follows:

xraster = (6 * 150) / 100 + 2
        = 11
yraster = (13 * 200) / 100 + 10
        = 36

Important: improved calculation of the raster width under Windows

With IDM version A.06.03.a, the calculation of the raster width has been substantially changed. If no reference string is set, the raster width is now calculated from an internal reference string (M) to avoid excessive width growth due to excessively wide letters within a font.

For compatibility reasons, however, the opt_fontraster_compat option, the -IDMfontraster_compat startup option, or the IDM_FONTRASTER_COMPAT environment variable can temporarily reactivate the old raster width calculation (with the drawback that excessive width growth may occur again).
When using the opt_fontraster_compat, the size calculation is partly based on the system font, which is not High DPI capable, so High DPI capable applications created with IDM for Windows 11 should not use this option.

2.5.2 Predefined UI-Fonts

The UI font resources are WSI-independent predefined fonts that are available on all systems with similar characteristics or meaning. The default fonts used by the current desktop/window manager or theme are used for this purpose. The uniform FONT resources are defined as follows:

A list of the fonts available on the respective system can be requested via the attribute .fontname[integer] on the setup object.

2.5.3 Font Definition

There are the following definition methods for a font:

Note:

It should be mentioned that it depends on the selected character set whether and to what extent the selected modifiers are applied.

2.5.4 Font Definition for Microsoft Windows

There are the following definition methods for a font:

Remark

If the specified font is not available, the system font will be chosen instead.

Warning

All fonts available in the system can be used, since there is no limitation to the code page when choosing fonts.

This may lead to choosing fonts with a wrong code page so that the wrong characters are displayed. The IDM on Microsoft Windows has no possibility to make a code page conversion since only the WINANSI code page is defined.

See also

Chapter “Note on the use of symbol fonts under Microsoft Windows”

2.5.5 Font Definition for Qt

Fonts can be defined in the following ways:

Qt Style with Comma-separated Parameter List

Family, PointSize, PixelSize, QFont::StyleHint, QFont::Weight, QFont::Style,
Flag underline, Flag strikeout, Flag pixedPitch, Flag rawMode
"Helvetica, 12, -1, 5, 75, 1, 0, 0, 0, 0"

Not all parameters have to be specified, "Helvetica, 12" is sufficient, for example.

Font with Independent Display Attributes (Size and Style)

"Helvetica", 12, bold

The styles bold, italic and oblique are supported.

Qt style specifications can be combined with independent display attributes:

"Helvetica, 12", bold

X Logical Font Description (XLFD)

"-adobe-helvetica-medium-r-normal--12-*-*-*-p-*-iso8859-1"
"*adobe-helvetica-bold-r-normal-*-100-*-iso8859-1"

Notes

Attention

2.5.6 Dynamically changeable attributes

For fonts, the following attributes can be set and queried dynamically at runtime:

Table 20-3: Modifiable attributes of the font resource

Attribute

Data Type

Index Range

Description

.face enum

face_default,
face_italic,

face_oblique,
face_roman,

font face/ slant

.height[enum] integer scale_factor,
scale_offset

y-scaling and offset

.name

string

font name

.refstring

string

reference string for calculating the grid width

.propscale boolean

raster control

.size

integer

font size

.style

enum

face_default,
face_light,
face_normal,
face_medium,
face_demibold,
face_bold,
face_black
face_italic,

face_oblique
face_roman,

font style

.weight enum

face_default,

face_light,
face_normal,
face_medium,
face_demibold,
face_bold,
face_black

font weight

.width[enum]

integer

scale_factor,
scale_offset

x-scaling and offset