SETFONT

Updated December 2009

//SETFONT, height, face, pitch-family, {charset, weight, style, rotation, width}

SETFONT is used to select the printer font. If not used, the font will be determined by the FONT parameter within the printer initialization file. The last four parameters are optional, or may be specified as zero for defaults. Note that the color of the font will be black characters on a white transparent background, unless overridden by a SETTEXTCOLOR directive. See the topic Parameters: Symbols vs. Values if you have questions about which to use.

Also see the "Update Note" section at the bottom of this page.

TIP: To change font in the middle of a line of text, use the backslash (\) line terminator on the line prior to the font change in order to suppress the automatic line feed. For this and other tips, pointers and relevant information about writing GDI printing directives, please see Writing GDI Print Directives.

Parameters

height

Height of the font in tenths of points. For example, use 120 to select a 12 point font.

face

Face name of the font. These are the names that appear in the typical Windows font selection dialogs. Typical face names are Courier New, Helvetica, Fixed Sys, Times Roman, etc.

pitch-and-family

Formed as the sum of the following:

Symbol

Value

Description

DEFAULT_PITCH

0

Default pitch, don't care about family.

FIXED_PITCH

1

Fixed pitch (monospace).

VARIABLE_PITCH 

2

Variable pitch (proportional space).

 

Symbol

Value

Description

FF_DONTCARE

&h000

Don't care.

FF_ROMAN

&h010

Roman family (serifs, variable pitch.) Example: Times Roman.

FF_SWISS

&h020

Swiss family (sans serifs, variable pitch.) Example: MS Sans Serif.

FF_MODERN

&h030

Modern family (fixed pitch, serif or sans serif.) Examples: Courier, Pica, Elite.

FF_SCRIPT

&h040

Script family (fonts that look like handwriting.) Examples: Script, Cursive

FF_DECORATIVE

&h050

Decorative family (novelty fonts.) Example: Old English.

 

charset

Specifies the desired character set, from the following values:

Symbol

Value

Description

ANSI_CHARSET

0

ANSI

DEFAULT_CHARSET

1

Don't care

SYMBOL_CHARSET

2

Symbols

OEM_CHARSET

255

OEM (system dependent)

 

weight

Specifies the desired boldness of stroke, from the following choices. Note that most of these are not supported but are mapped to the nearest supported choice.

Symbol

Value

Description

FW_DONTCARE

0

Don't care

FW_THIN

100

Thin

FW_EXTRALIGHT

200

Extra Light

FW_LIGHT

300

Light

FW_NORMAL

400

Normal

FW_MEDIUM

500

Medium

FW_SEMIBOLD

600

Semibold, demibold

FW_BOLD

700

Bold

FW_EXTRABOLD

800

Extrabold, ultrabold

FW_HEAVY

900

Heavy

 

style

Specifies font style options.

Symbol

Value

Description

FS_UPRIGHT

&h00

Normal upright

FS_ITALIC

&h01

Italic

FS_UNDERLINE

&h02

Underline

FS_STRIKEOUT

&h04

Strikeout

 

rotation

The default is zero. Rotation is specified in degrees, with positive numbers being rotated clockwise.

width

This option allows you to stretch or squeeze the width of the font independent of the height. The units of width are equivalent to that of height (tenths of points). Beginning in A-Shell build 1168 of 11 December 2009, you may also use width to specify the character width in terms of the number of characters that would fit on a line, by setting it to the negative of that value. For example, to select a font that would fit 90 characters across the page, set width to -90.

 

Examples

//SETFONT,120,Arial

This is 12 point Arial, standard options

 

//SETFONT,100,Times Roman,0,0,200,1

This is 10 point Times Roman, extra light weight, italic

 

//SETFONT,120,Courier,FIXED_PITCH,ANSI_CHARSET,FW_EXTRABOLD,FS_UPRIGHT

This is 12 point Courier (or something similar in fixed pitch), extra bold, upright

 

Comments

In the context of fixed-pitch (mono-spaced) fonts, the terms "pitch" and "point" are sometimes confused or at least conflated by the traditional typewriter-era rule-of-thumb that a 12 point font (e.g. Courier, Pica) was equivalent to 10 pitch (10 CPI or characters per inch horizontal), while a 10 point font (e.g. Elite) was equivalent to 12 pitch. In the digital era, that rule-of-thumb falls apart, especially with proportional fonts, where the relationship between height in points and number of characters per inch is completely unpredictable, but even with fixed-pitch fonts, due to the fact that the characters can be made wider or thinner without changing the height. If it is important to select a font with a certain pitch (CPI), use the width parameter to specify it explicitly.

Also note that while there is a natural relationship between the vertical line spacing (LPI or lines per inch vertical) and the font height (i.e. point size), changing the font does not automatically change the line spacing. See the GDI printing directive RESETFONT.

Update Note: A-Shell build 1149 of 16 May 09

GDI printing bug fix/refinement: The width parameter in the SETFONT statement now works more precisely and reliably with fixed pitch fonts, across all font families, printers and resolutions. Previously, certain fonts (most notoriously Courier) didn't "behave" very well. And in addition, since the individual cell width was being rounded to the nearest integer number of pixels, small adjustments to the width were often not having the desired effect with lower printer device resolutions. Now, the cell width is interpolated to 1/8 of a pixel, resulting in fine control even with 100 DPI (e.g. fax) devices.

COMPATIBILITY WARNING: This "fix" could possibly result in a small change in the horizontal character spacing of existing printouts. The change will probably be small, and will always represent a correction, but it is possible that having worked out precise spacing by trial-and-error, you may need to make adjustments after this fix. (After considerable soul-searching and public comment, we decided that since width is a relatively new parameter, rarely used, that the likelihood of this fix actually improving the spacing of existing reports was many times greater than the chance of it making a report worse. But if you use the width parameter to fine tune the fixed pitch spacing of a very precise form, and especially if you used trial-and-error rather than math to figure out the ideal width, you may need to take another look. (The upside is, anyone affected by this would have been at risk of their reports looking different on different printers; so even if you have to make an adjustment, the report will now print consistently across devices.)

A more detailed discussion is available on the A-Shell forum topic "Fixed Pitch Precision."