[Lazarus] Controlling DPI

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Mar 29 15:51:55 CEST 2009


David W Noon schrieb:

> Specifically, the font engine uses the DPI provided by the video (or
> printer) driver.

In general: of the given Device Context (Windows: DC).


>>  Pixel based sizes, as 
>> used in the LCL for the origin and extent of the forms and controls, are 
>> not affected by the DPI settings.
> 
> I am not sure about this. I think they could well be affected by DPI,
> but the Lazarus developers could say for sure.

Most Microsoft languages (VB, VC...) scale all visual elements in 
"twips" (1/20 point), but the Delphi VCL uses pixels for everything but 
fonts. As long as the LCL is Delphi compatible, it must behave in the 
same way.

>> If you want to change that DPI factor, your application can scale the 
>> size of every used font accordingly.
> 
> No, this is wrong. The fonts do not need to be rescaled.
> 
> The point size required for a font to render to a particular size on
> screen or paper is independent of the DPI of the device.

For pixel based output devices, the graphic system converts all units 
into pixels, based on the DPI value of the given device context. Then it 
depends on the actual device, how big the output will appear. At least 
on Windows a logical inch on the screen is larger than a physical inch, 
and the user can change that ratio by adjusting the DPI factor 
(accessibility option).

> Point sizes are
> based on 1/72nd of an inch, regardless of how many device dots are in
> that inch. It is the American inch (slightly larger than the traditional
> Imperial inch, which it has largely supplanted) that is the defining
> factor, and this is fixed.

The established font sizes are essential for print media. Computer 
monitors have such a poor resolution, that in most cases the font size 
has to be increased for readable output. When you measure the font 
height on a monitor, it typically will be larger than the given (point) 
size of the font. On my Linux system 10cm really are 11cm on screen, 
independent of the screen size and geometry.

DoDi




More information about the Lazarus mailing list