News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Avg Character width question

Started by Rainstorm, October 05, 2007, 03:27:33 PM

Previous topic - Next topic

Rainstorm

hi.

the question is regarding an example drom the platformSDK (using keyboard input)

Quote// Calculate the maximum width of a line
           
            dwLineLen = dwClientX - dwCharX;

dwClientX  is the width of the client area
dwCharX   is the average text width

so how does that calculation give you the line length ?
line length would be the width of the client area itself right ?
& dwCharX is just like the width of 1 character or something.

ty

~~


Tedd

That line doesn't seem to make much sense :dazzled:

For any font, you can get information including the average character width (usually it's just the width of the character 'x').
Given the average character width you can find out how wide N characters would be (avgCharWidth * numChars), or the number of characters that will fit into a specific width (clientWidth / avgCharWidth) -- with the division truncating (ignore the remainder.)
Monospace fonts have all characters the same width, but for variable width fonts it provides a quick guess which is usually close enough.
No snowflake in an avalanche feels responsible.

Rainstorm

hi Tedd,

yah what yuo said makes sense....
The excerpt is from the last example in   the 'Using Keyboard Input' section
Windows User Interface-->User Input-->Keyboard Input->Keyboard Input Overviews-->Using Keyboard Input

Thanks!