-
Font Size
In my vb app, I need to show the user, the list of available font size for
each font.
I have been told to use EnumFontFamily api to retrieve it. Of course, it
allowed me to get
the list of available system fonts, and its LOGFONT structure contains lot
of other elements,
but none for size. Could anybody throw some torch?
Thanks in advance
J Justin
-
Re: Font Size
Size is certainly in there.... what do you think lfHeight (and occasionally
though usually not lfWidth) is there for?
--
MichKa
random junk of dubious value at the multilingual
http://www.trigeminal.com/ and a new book on
i18N in VB at http://www.trigeminal.com/michka.asp
"J Justin" <precious@md3.vsnl.net.in> wrote in message
news:3972c675@news.devx.com...
> In my vb app, I need to show the user, the list of available font size for
> each font.
> I have been told to use EnumFontFamily api to retrieve it. Of course, it
> allowed me to get
> the list of available system fonts, and its LOGFONT structure contains lot
> of other elements,
> but none for size. Could anybody throw some torch?
>
> Thanks in advance
>
>
> J Justin
>
>
>
-
Re: Font Size
Size is certainly in there.... what do you think lfHeight (and occasionally
though usually not lfWidth) is there for?
--
MichKa
random junk of dubious value at the multilingual
http://www.trigeminal.com/ and a new book on
i18N in VB at http://www.trigeminal.com/michka.asp
"J Justin" <precious@md3.vsnl.net.in> wrote in message
news:3972c675@news.devx.com...
> In my vb app, I need to show the user, the list of available font size for
> each font.
> I have been told to use EnumFontFamily api to retrieve it. Of course, it
> allowed me to get
> the list of available system fonts, and its LOGFONT structure contains lot
> of other elements,
> but none for size. Could anybody throw some torch?
>
> Thanks in advance
>
>
> J Justin
>
>
>
-
Re: Font Size
J,
As michka says, you need to use the lfHeight member. However, this number is
expressed in logical units, so, for example, in the most common mapping mode
(MM_TEXT), a font size of 8 corresponds to a font height of -11. The formula
to calculate the height given a size is:
Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal
nNumerator As Long, ByVal nDenominator As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex
As Long) As Long
Public Const LOGPIXELSY = 90
lfHeight = -MulDiv(lFontSize, GetDeviceCaps(pDC, LOGPIXELSY), 72)
To do it the other way around, just reverse the division operation:
lFontSize = -((.lfHeight * 72) \ GetDeviceCaps(pDC, LOGPIXELSY))
This technique is documented in the LOGFONT reference on the PSDK.
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
Please post/reply to the newsgroup(s)
"J Justin" <precious@md3.vsnl.net.in> wrote in message
news:3972c675@news.devx.com...
> In my vb app, I need to show the user, the list of available font size for
> each font.
> I have been told to use EnumFontFamily api to retrieve it. Of course, it
> allowed me to get
> the list of available system fonts, and its LOGFONT structure contains lot
> of other elements,
> but none for size. Could anybody throw some torch?
>
> Thanks in advance
>
>
> J Justin
>
>
>
-
Re: Font Size
J,
As michka says, you need to use the lfHeight member. However, this number is
expressed in logical units, so, for example, in the most common mapping mode
(MM_TEXT), a font size of 8 corresponds to a font height of -11. The formula
to calculate the height given a size is:
Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal
nNumerator As Long, ByVal nDenominator As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex
As Long) As Long
Public Const LOGPIXELSY = 90
lfHeight = -MulDiv(lFontSize, GetDeviceCaps(pDC, LOGPIXELSY), 72)
To do it the other way around, just reverse the division operation:
lFontSize = -((.lfHeight * 72) \ GetDeviceCaps(pDC, LOGPIXELSY))
This technique is documented in the LOGFONT reference on the PSDK.
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
Please post/reply to the newsgroup(s)
"J Justin" <precious@md3.vsnl.net.in> wrote in message
news:3972c675@news.devx.com...
> In my vb app, I need to show the user, the list of available font size for
> each font.
> I have been told to use EnumFontFamily api to retrieve it. Of course, it
> allowed me to get
> the list of available system fonts, and its LOGFONT structure contains lot
> of other elements,
> but none for size. Could anybody throw some torch?
>
> Thanks in advance
>
>
> J Justin
>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks