Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Fri, 28 Mar 2008 10:12:48 -0400,    group: microsoft.public.win32.programmer.gdi        back       


conversion: Font Point Size <=> LOGFONT::lfHeight   
When converting between font point size and the LOGFONT structure's lfHeight 
variable, I've always used the example code in the MSDN documentation, shown 
below (reversing it to do the opposite conversion).

lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
This seems to work fine, however, the hard-coded 72 has always bothered me. 
I know the docs say that as long as you're using MM_TEXT the above can be 
used.  But they don't specifically address where the 72 is coming from and 
what assumptions are hidden there.

If I open the "Display Settings" control panel and go to the Settings tab 
and click the Advanced button and then go to the General tab in the new 
dialog which opens, I see that you can change the DPI setting.

On my laptop I can pick from the below.

- Normal (96 DPI)
- Large size (120 DPI)
- Custom setting...

So my question is the following.  Is it really correct to hard-code 72 in 
the above code?  Is this number affected in any way by the DPI setting or 
some other setting I'm not familiar with?  Should the third argument be 
instead queried from somewhere instead of just hard-coded?
date: Fri, 28 Mar 2008 10:12:48 -0400   author:   Dave Calkins ail

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
"Dave Calkins" <david.calkins@noemail.noemail> wrote:
>
>lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
>[...]
>
>So my question is the following. Is it really correct to hard-code
>72 in the above code? Is this number affected in any way by the DPI
>setting or some other setting I'm not familiar with? Should the third
>argument be instead queried from somewhere instead of just hard-coded?

It's really correct. The 72 refers to the number of points per inch, a
value not likely to change. I suppose you could use a constant or macro
for the value to make things a little more clear, but there's no need to
query the system for it, just like I wouldn't expect to query the system
for a value to convert from inches to feet.

-- 
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
   Fault always lies in the same place, my fine babies: with him weak 
   enough to lay blame. 
   -- The Drawing of the Three by Stephen King
date: 28 Mar 2008 08:52:22 -0700   author:   Scott Seligman

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
"Scott Seligman"  wrote in message 
news:fsj47m$rnf$1@panix3.panix.com...
> "Dave Calkins" <david.calkins@noemail.noemail> wrote:
>>
>>lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
>>[...]
>>
>>So my question is the following. Is it really correct to hard-code
>>72 in the above code? Is this number affected in any way by the DPI
>>setting or some other setting I'm not familiar with? Should the third
>>argument be instead queried from somewhere instead of just hard-coded?
>
> It's really correct. The 72 refers to the number of points per inch, a
> value not likely to change. I suppose you could use a constant or macro
> for the value to make things a little more clear, but there's no need to
> query the system for it, just like I wouldn't expect to query the system
> for a value to convert from inches to feet.

the conversion from inches to feet would never change of course.

however, why do you say that the number of points per inch won't change?  I 
know I can change the dots-per-inch of my display.  Or is the 72 something 
different?  I guess I'm curious what exactly the 72 is and why it would be 
unlikely to change.  Its not clear from the docs what that 72 number is.
date: Fri, 28 Mar 2008 16:57:01 -0400   author:   Dave Calkins ail

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
"Dave Calkins" <david.calkins@noemail.noemail> wrote:
>the conversion from inches to feet would never change of course.
>
>however, why do you say that the number of points per inch won't
>change?

Because much like an inch is effectively defined as 1/12th of a foot, a
point is defined as 1/72nd of an inch.

-- 
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
   Better to light a candle than to curse the darkness. 
   -- Chinese Proverb
date: 28 Mar 2008 15:00:26 -0700   author:   Scott Seligman

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
"Scott Seligman"  wrote in message 
news:fsjppq$ebl$1@panix3.panix.com...
> "Dave Calkins" <david.calkins@noemail.noemail> wrote:
>>the conversion from inches to feet would never change of course.
>>
>>however, why do you say that the number of points per inch won't
>>change?
>
> Because much like an inch is effectively defined as 1/12th of a foot, a
> point is defined as 1/72nd of an inch.

ok, so in other words, the 72 value is "points" per inch which is fixed and 
the "points" are logical points completely distinct from the "dots" 
referenced in the Windows Display DPI setting?

i.e. the "points" referenced via the 72 != the "dots" referenced in the DPI 
setting?
date: Fri, 4 Apr 2008 09:19:29 -0400   author:   Dave Calkins ail

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
Dave,

A point is 1/72".

The number of pixels, or dots, per inch is what DPI is.

So a 36 point font is 300 pixels, or dots, on a printter that has 600 DPI.

Does that answer your question?

Paul

"Dave Calkins" <david.calkins@noemail.noemail> wrote in message 
news:%23lsg8YllIHA.3940@TK2MSFTNGP05.phx.gbl...
> "Scott Seligman"  wrote in message 
> news:fsjppq$ebl$1@panix3.panix.com...
>> "Dave Calkins" <david.calkins@noemail.noemail> wrote:
>>>the conversion from inches to feet would never change of course.
>>>
>>>however, why do you say that the number of points per inch won't
>>>change?
>>
>> Because much like an inch is effectively defined as 1/12th of a foot, a
>> point is defined as 1/72nd of an inch.
>
> ok, so in other words, the 72 value is "points" per inch which is fixed 
> and the "points" are logical points completely distinct from the "dots" 
> referenced in the Windows Display DPI setting?
>
> i.e. the "points" referenced via the 72 != the "dots" referenced in the 
> DPI setting?
>
>
date: Fri, 4 Apr 2008 09:56:42 -0400   author:   Paul Baker [MVP, Windows Desktop Experience] am

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
"Dave Calkins" <david.calkins@noemail.noemail> wrote:
>
>"Scott Seligman"  wrote in message 
>news:fsjppq$ebl$1@panix3.panix.com...
>> "Dave Calkins" <david.calkins@noemail.noemail> wrote:
>>>the conversion from inches to feet would never change of course.
>>>
>>>however, why do you say that the number of points per inch won't
>>>change?
>>
>> Because much like an inch is effectively defined as 1/12th of a foot, a
>> point is defined as 1/72nd of an inch.
>
>ok, so in other words, the 72 value is "points" per inch which is fixed and 
>the "points" are logical points completely distinct from the "dots" 
>referenced in the Windows Display DPI setting?

Yes.


-- 
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
   I'm the one that has to die when it's time for me to die, so let me 
   live my life, the way I want to. 
   -- Jimi Hendrix
date: 4 Apr 2008 11:29:57 -0700   author:   Scott Seligman

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
On Apr 4, 2:19 pm, "Dave Calkins" <david.calk...@noemail.noemail>
wrote:
> ok, so in other words, the 72 value is "points" per inch which is fixed and
> the "points" are logical points completely distinct from the "dots"
> referenced in the Windows Display DPI setting?

A 'point' is a typographical measure:

 http://en.wikipedia.org/wiki/Point_(typography)

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
date: Tue, 8 Apr 2008 15:02:14 -0700 (PDT)   author:   Richard Russell

Re: conversion: Font Point Size <=> LOGFONT::lfHeight   
Thanks for the replies.  I will proceed using the hard-coded value with 
confidence now :)

"Dave Calkins" <david.calkins@noemail.noemail> wrote in message 
news:%23lsg8YllIHA.3940@TK2MSFTNGP05.phx.gbl...
> "Scott Seligman"  wrote in message 
> news:fsjppq$ebl$1@panix3.panix.com...
>> "Dave Calkins" <david.calkins@noemail.noemail> wrote:
>>>the conversion from inches to feet would never change of course.
>>>
>>>however, why do you say that the number of points per inch won't
>>>change?
>>
>> Because much like an inch is effectively defined as 1/12th of a foot, a
>> point is defined as 1/72nd of an inch.
>
> ok, so in other words, the 72 value is "points" per inch which is fixed 
> and the "points" are logical points completely distinct from the "dots" 
> referenced in the Windows Display DPI setting?
>
> i.e. the "points" referenced via the 72 != the "dots" referenced in the 
> DPI setting?
>
>
date: Mon, 14 Apr 2008 08:08:14 -0400   author:   Dave Calkins ail

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us