commit kguiaddons for openSUSE:Factory
Hello community, here is the log from the commit of package kguiaddons for openSUSE:Factory checked in at 2014-10-07 15:58:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kguiaddons (Old) and /work/SRC/openSUSE:Factory/.kguiaddons.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "kguiaddons" Changes: -------- --- /work/SRC/openSUSE:Factory/kguiaddons/kguiaddons.changes 2014-09-12 17:03:20.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.kguiaddons.new/kguiaddons.changes 2014-10-07 15:58:51.000000000 +0200 @@ -1,0 +2,8 @@ +Sat Oct 4 17:59:09 UTC 2014 - hrvoje.senjan@gmail.com + +- Update to 5.3.0 + * Make KFontUtils::adaptFontSize be a bit more exact + * For more details please see: + https://www.kde.org/announcements/kde-frameworks-5.3.0.php + +------------------------------------------------------------------- Old: ---- kguiaddons-5.2.0.tar.xz New: ---- kguiaddons-5.3.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kguiaddons.spec ++++++ --- /var/tmp/diff_new_pack.Mgq9nz/_old 2014-10-07 15:58:52.000000000 +0200 +++ /var/tmp/diff_new_pack.Mgq9nz/_new 2014-10-07 15:58:52.000000000 +0200 @@ -18,10 +18,10 @@ %define lname libKF5GuiAddons5 Name: kguiaddons -Version: 5.2.0 +Version: 5.3.0 Release: 0 BuildRequires: cmake >= 2.8.12 -BuildRequires: extra-cmake-modules >= 1.2.0 +BuildRequires: extra-cmake-modules >= 1.3.0 BuildRequires: fdupes BuildRequires: kf5-filesystem BuildRequires: pkgconfig(Qt5Gui) >= 5.2.0 ++++++ kguiaddons-5.2.0.tar.xz -> kguiaddons-5.3.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kguiaddons-5.2.0/CMakeLists.txt new/kguiaddons-5.3.0/CMakeLists.txt --- old/kguiaddons-5.2.0/CMakeLists.txt 2014-09-08 01:25:16.000000000 +0200 +++ new/kguiaddons-5.3.0/CMakeLists.txt 2014-10-03 19:55:11.000000000 +0200 @@ -2,7 +2,7 @@ project(KGuiAddons) -find_package(ECM 1.2.0 REQUIRED NO_MODULE) +find_package(ECM 1.3.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) @@ -21,7 +21,7 @@ include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) -set(KF5_VERSION "5.2.0") # handled by release scripts +set(KF5_VERSION "5.3.0") # handled by release scripts ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX KGUIADDONS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kguiaddons_version.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kguiaddons-5.2.0/src/fonts/kfontutils.cpp new/kguiaddons-5.3.0/src/fonts/kfontutils.cpp --- old/kguiaddons-5.2.0/src/fonts/kfontutils.cpp 2014-09-08 01:25:16.000000000 +0200 +++ new/kguiaddons-5.3.0/src/fonts/kfontutils.cpp 2014-10-03 19:55:11.000000000 +0200 @@ -1,6 +1,6 @@ /********************************************************************************* * * - * Copyright (C) 2005, 2009 by Albert Astals Cid <aacid@kde.org> * + * Copyright (C) 2005, 2009, 2014 by Albert Astals Cid <aacid@kde.org> * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * @@ -22,33 +22,68 @@ #include "kfontutils.h" +#include <qmath.h> #include <qpainter.h> +static bool checkFits(QPainter &painter, const QString &string, qreal width, qreal height, qreal size, KFontUtils::AdaptFontSizeOptions flags) +{ + QFont f = painter.font(); + f.setPointSizeF(size); + painter.setFont(f); + int qtFlags = Qt::AlignCenter | Qt::TextWordWrap; + if (flags & KFontUtils::DoNotAllowWordWrap) { + qtFlags &= ~Qt::TextWordWrap; + } + const QRectF boundingRect = painter.boundingRect(QRectF(0, 0, width, height), qtFlags, string); + if (boundingRect.width() == 0 || boundingRect.height() == 0) { + return false; + } else if (boundingRect.width() > width || boundingRect.height() > height) { + return false; + } + return true; +} + qreal KFontUtils::adaptFontSize(QPainter &painter, const QString &string, qreal width, qreal height, qreal maxFontSize, qreal minFontSize, AdaptFontSizeOptions flags) { - qreal size = maxFontSize; - QRectF boundingRect; - bool done = false; - - while (!done && size > minFontSize) { - QFont f = painter.font(); - f.setPointSizeF(size); - painter.setFont(f); - int qtFlags = Qt::AlignCenter | Qt::TextWordWrap; - if (flags & DoNotAllowWordWrap) { - qtFlags = qtFlags & ~Qt::TextWordWrap; - } - boundingRect = painter.boundingRect(QRectF(0, 0, width, height), qtFlags, string); - if (boundingRect.width() == 0 || boundingRect.height() == 0) { + // A invalid range is an error (-1) + if (maxFontSize < minFontSize) + return -1; + + // If the max font size already fits, return it + if (checkFits(painter, string, width, height, maxFontSize, flags)) + return maxFontSize; + + qreal fontSizeDoesNotFit = maxFontSize; + + // If the min font size does not fit, try to see if a font size of 1 fits, + // if it does not return error (-1) + // if it does, we'll return a fontsize smaller than the minFontSize as documented + if (!checkFits(painter, string, width, height, minFontSize, flags)) { + fontSizeDoesNotFit = minFontSize; + + minFontSize = 1; + if (!checkFits(painter, string, width, height, minFontSize, flags)) return -1; - } else if (boundingRect.width() > width || boundingRect.height() > height) { - size = qMin(width * size / boundingRect.width(), height * size / boundingRect.height()); + } + + qreal fontSizeFits = minFontSize; + qreal nextFontSizeToTry = (fontSizeDoesNotFit + fontSizeFits) / 2; + + while (qFloor(fontSizeFits) != qFloor(nextFontSizeToTry)) { + if (checkFits(painter, string, width, height, nextFontSizeToTry, flags)) { + fontSizeFits = nextFontSizeToTry; + nextFontSizeToTry = (fontSizeDoesNotFit + fontSizeFits) / 2; } else { - done = true; + fontSizeDoesNotFit = nextFontSizeToTry; + nextFontSizeToTry = (nextFontSizeToTry + fontSizeFits) / 2; } } - return size; + QFont f = painter.font(); + f.setPointSizeF(fontSizeFits); + painter.setFont(f); + + return fontSizeFits; } qreal KFontUtils::adaptFontSize(QPainter &painter, const QString &text, const QSizeF &availableSize, qreal maxFontSize, qreal minFontSize, AdaptFontSizeOptions flags) -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de