PRB: WinSDK: Printing Strings of Mixed Fonts

ID Number: Q19945

2.00 3.00

WINDOWS

SYMPTOMS

When sending strings to a printer DC using TextOut(), a different

font is selected prior to each call to TextOut(). The number of

spaces appended is between each string and is not predictable.

However, each time the document is printed, the same number of

spaces appear at the same positions, regardless of what printer is

being used.

CAUSE

Features such as boldface and underlining do not always have the

same TEXTMETRIC values.

RESOLUTION

Call GetTextMetrics() before sending a string to the TextOut()

function. Using the values returned by GetTextMetrics(), calculate

the (X,Y) positioning of the string and use that (X,Y) pair

in the call to TextOut().