Adding KFontUtils to kdeui
Albert Astals Cid
aacid at kde.org
Fri May 1 21:51:56 BST 2009
A Divendres, 1 de maig de 2009, Christoph Feck va escriure:
> Am Friday 01 May 2009 16:25:42 schrieb Albert Astals Cid:
> > The rational of this helper method is that QFontMetrics is a good try but
> > it really fails when you need pixel perfection.
>
> Hm, if your aim is pixel perfection, you really should return a qreal here,
> as with high DPI displays the difference between a 10 pt and an 11 pt font
> can be quite big.
You got me, the code is from Qt3 times when fonts were int sizes only ;-)
Attaching a qrealized patch.
>
> The return value documentation says "biggest", the description says
> "optimal".
Actually it's not the biggest since the
size = qMin(width * size / boundingRect.width(), height * size /
boundingRect.height());
asumes fonts react linearly to font size, and that's not totally true, but
well, it gives you a quite good guess, so i'm still going with "biggest"
unless you suggest a better explanation.
> As for the name, fontSize() sounds like an attribute getter, it should
> reflect the fact that it computes the largest possible font size, maybe
> call it adaptFontSize() to reflect the behaviour that it changes the size
> of the QPainter's font?
Seems a good name, also adapted to KFontMetrics as suggested by Allen.
Albert
>
> Other than that, this function is surely useful, maybe even in KMessageBox.
>
> > Since the code is small and already used in lots of places, Allen agreed
> > i can commit it to kdelibs on Monday if noone objects.
>
> Not sure how the freeze dates apply here...
>
> Christoph Feck (kdepepo)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kfontmetrics.patch
Type: text/x-patch
Size: 7586 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090501/8864b4fb/attachment.bin>
More information about the kde-core-devel
mailing list