flat assembler
Message board for the users of flat assembler.

Index > Windows > font sizes

Author
Thread Post new topic Reply to topic
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 27 Jul 2004, 14:17
hi,
I'm trying to read Notepad's settings from registry (HKEY_CURRENT_USER\Software\Microsoft\Notepad). Notepad stores font size in a value named "iPointSize". But how can I convert this value, to create font with this size (I mean to calculate LOGFONT.lfHeight variable, to pass it to CreateFontIndirect). Question

thanks
Post 27 Jul 2004, 14:17
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 28 Jul 2004, 12:30
I'd guess it's an ingeter (thus 32-bit, unless it's like wchar_t (the it's 16-bit), PointSize sounds like '"pt" size' of the font - if that's of any help to you.
(/me don't have windows to check that regkey)
Post 28 Jul 2004, 12:30
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 28 Jul 2004, 12:46
iPointSize is 10 times the current size of the font (example: iPointSize=100, the font=10 points). Something like the following code should be all you need to convert from iPointSize to actual points:

Code:
mov eax, [iPointSize]
mov ebx, 10
div eax
    
Post 28 Jul 2004, 12:46
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 28 Jul 2004, 14:23
thanks, but how can I convert this value to LOGFONT.lfHeight? That's what win32.hlp says:
Quote:
lfHeight

Specifies the height, in logical units, of the font's character cell or character. The character height value (also known as the em height) is the character cell height value minus the internal-leading value. The font mapper interprets the value specified in lfHeight in the following manner:

Value Meaning
> 0 The font mapper transforms this value into device units and matches it against the cell height of the available fonts.
0 The font mapper uses a default height value when it searches for a match.
< 0 The font mapper transforms this value into device units and matches its absolute value against the character height of the available fonts.


actually I just don't understand it Confused
Post 28 Jul 2004, 14:23
View user's profile Send private message Visit poster's website Reply with quote
Frank



Joined: 17 Jun 2003
Posts: 100
Frank 28 Jul 2004, 15:26
Hi decard,

in the section that you already quoted, WIN32 help further says:
Code:
For the MM_TEXT mapping mode, you can use the following formula to specify a height for a font with a given point size:

lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
    


LOGPIXELSY is the number of pixels per logical inch along the screen height. Your program should determine LOGPIXELSY, multiply it with the point size that you already have, and divide the product by 72. Then multiply with -1.

Here is a table of hardcoded values that I use on a set of computers where I know LOGPIXELSY to be 96:

Code:
hFonts  dd      -11, -13, -16, -19, -21, -24, -32, -64
;               ( 8,  10,  12,  14,  16,  18,  24,  48 point font size)
                sizeof.hFonts = $ - hFonts
    


Regards

Frank
Post 28 Jul 2004, 15:26
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 29 Jul 2004, 15:23
well, it's a bit more complicated than I thought, but this simple lookup table should be a good solution for me Wink.

Thanks.
Post 29 Jul 2004, 15:23
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.