win32lib bug in getFontSize

new topic     » topic index » view thread      » older message » newer message

I posted this once in "Analyze this" but I suspect that no one probably 
noticed.

I've discovered that win32lib getFontSize is wrong..at least in my opinion. 
Look at this link which has a drawing of characters explaining the vars used.

http://msdn2.microsoft.com/en-us/library/ms534015.aspx

Then look at the winlib32 code below. "tmInternalLeading" is actually added
twice. It's first contained in "tmHeight" then getFontSize adds it again.
I think that "tmInternalLeading" should be removed from the char heigth. 
I've rem'd it out on my copy and my list boxes have the correct height since
I'm sizing them by character heights. If I'm wrong please explain.


global function getFontSize( integer id )

    -- get metrics for current font

    integer width, height, maxwidth
    atom tm

    -- text metric structure
    tm  = w32acquire_mem(0, SIZEOF_TEXTMETRIC )

    -- get the metrics of the font (queryFont will prepend the DC)
    if not queryFont( id, xGetTextMetrics, {tm} ) then
        warnErr( Err_GETFONTSIZE )
    end if

    -- assign values
    width   = w32fetch(tm,tmAveCharWidth)
    maxwidth   = w32fetch(tm,tmMaxCharWidth)
    height  = w32fetch(tm,tmHeight) +
                w32fetch(tm,tmInternalLeading) + <----------- remove this 
                w32fetch(tm,tmExternalLeading)

    -- release
    w32release_mem( tm )

    -- return results
    return { width, height, maxwidth }

end function

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu