Review Request 114907: Make KFontUtils::adaptFontSize be a bit more exact

David Faure faure at kde.org
Sat Feb 15 22:22:17 GMT 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/114907/#review49878
-----------------------------------------------------------



kdeui/fonts/kfontutils.cpp
<https://git.reviewboard.kde.org/r/114907/#comment35045>

    for portability, better use <qmath.h> and qFloor.



kdeui/fonts/kfontutils.cpp
<https://git.reviewboard.kde.org/r/114907/#comment35044>

    Can be written as qtFlags &= ...



kdeui/fonts/kfontutils.cpp
<https://git.reviewboard.kde.org/r/114907/#comment35046>

    "minimum than"? do you mean "smaller than"?



kdeui/fonts/kfontutils.cpp
<https://git.reviewboard.kde.org/r/114907/#comment35049>

    Can't this loop forever?
    
    fontSizeFits = 9
    fontSizeDoesNotFit = 10
    
    -> next to try 9.5, fits
    -> fontSizeFits = 9.5
    -> next to try 9.75, fits
    -> fontSizeFits = 9.75
    -> ....
    -> and so on, until 9.999999999.
    
    this would loop every time because the while() check always looks and 9 and 10, never equal.
    
    Of course it assumes an underlying fontmetric that is a bit broken, but all that's needed is one that uses floor() on the point size, for instance....
    
    I'm just wondering if it makes sense to keep dividing the interval, e.g. we could stop if the difference between fontSizeFits and nextFontSizeToTry is smaller than 1% of the font size, or something like that.
    


- David Faure


On Jan. 9, 2014, 10:22 p.m., Albert Astals Cid wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/114907/
> -----------------------------------------------------------
> 
> (Updated Jan. 9, 2014, 10:22 p.m.)
> 
> 
> Review request for kdelibs and Jeremy Whiting.
> 
> 
> Repository: kdelibs
> 
> 
> Description
> -------
> 
> Not all fonts are linear in drawn size against their point size, the old code assumes so and simply guesses the next font size taking into account the pointSize we drawn, the geometry we got and the geometry we want. The new code is a bit slower but will make sure that we get better pointSize results in non linear fonts.
> 
> 
> Diffs
> -----
> 
>   kdeui/fonts/kfontutils.cpp 3a80039 
> 
> Diff: https://git.reviewboard.kde.org/r/114907/diff/
> 
> 
> Testing
> -------
> 
> Blinken still works. Font sizes are similar.
> 
> 
> Thanks,
> 
> Albert Astals Cid
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20140215/a827c639/attachment.htm>


More information about the kde-core-devel mailing list