Article ID: 194323 - View products that this article applies to.
This article was previously published under Q194323
This article has been archived. It is offered "as is" and will no longer be updated.
When you set a font size by assigning a value directly to Printer.FontSize, or Printer.Font.Size, you get a different value than when using a StdFont object.
The issue here is that the default StdFont object is always based on the display hDC (Device Context handle), not the printer hDC. So when executing a line such as this:
the actual font handle created is using the display Device Context (DC). Because the printer has a slightly different scale than the display, the font size generated is also a little different.
As long as you consistently use a StdFont object (late binding) or consistently set the FontSize directly (early binding) and do not try to use both techniques in your code, this behavior should have no noticeable effect.
A Device Context (DC) is defined as a link between a Windows-based application, a device driver, and an output device, such as a display, printer, or plotter. These DCs are created as needed and are identified by a device context handle, or hDC.
When a StdFont object is instantiated, it has no way of knowing what devices will be using it. Therefore, to be consistent, it is always based on the display Device Context. If it were to try and change its hDC to that of the device to which it was being assigned, undesired behavior would result for shared Font objects that are used across different devices.
Steps to Reproduce Behavior
For more information on Device Contexts, search Help for "hDC property" or "device context handle."
For additional information, please see the following article in the Microsoft Knowledge Base:
(https://support.microsoft.com/kb/190223/EN-US/ ): PRB: StdFont Rescales When Shared with Printer Object
(c) Microsoft Corporation 1998. All Rights Reserved.
Contributions by Chris E. Jolley, Microsoft Corporation.
Article ID: 194323 - Last Review: February 28, 2014 - Revision: 3.0