修复文本类型下面总是多一行的问题,同时取消限制item高度加1
This commit is contained in:
@@ -557,6 +557,23 @@ QImage ItemUtils::txtToImage(const QString &txt, const QFont &font, const QColor
|
||||
QFontMetrics fm(font);
|
||||
int width = fm.horizontalAdvance(txt);
|
||||
int height = fm.height();
|
||||
|
||||
// 优先使用字体名中后缀标识的字体高度
|
||||
QString fontname = font.family();
|
||||
QString numStr = "";
|
||||
for(int i = fontname.length() - 1; i >= 0; --i) {
|
||||
if(fontname[i].isDigit()) {
|
||||
numStr.prepend(fontname[i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!numStr.isEmpty()) {
|
||||
height = numStr.toInt();
|
||||
if(height < 5 || height > 32)
|
||||
height = fm.height();
|
||||
}
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
return QImage();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user