File indexing completed on 2024-04-14 05:44:25
0001 /* 0002 * SPDX-FileCopyrightText: 2002-2003 Jesper K. Pedersen <blackie@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-only 0005 **/ 0006 0007 #include "myfontmetrics.h" 0008 0009 #include <QStringList> 0010 0011 QSize HackCalculateFontSize(const QFontMetrics &fm, const QString &str) 0012 { 0013 QStringList list; 0014 int maxWidth = 0; 0015 int height = 0; 0016 0017 if (str.isEmpty()) { 0018 return QSize(0, 0); 0019 } 0020 list = str.split(QStringLiteral("\n"), Qt::SkipEmptyParts); 0021 0022 const QStringList::const_iterator end(list.constEnd()); 0023 for (QStringList::const_iterator it = list.constBegin(); it != end; ++it) { 0024 QSize size = fm.size(0, *it); 0025 maxWidth = qMax(maxWidth, size.width()); 0026 height += size.height(); 0027 } 0028 return QSize(maxWidth, height); 0029 }