Circumvent odd stmary font metrics (part of #9990).

The stmary font has an unusual large descent that was causing a large
gap between lines in the math delimiter dialog because of the \llbracket
and \rrbracket delimiters. The solution is to force Qt using the same
size for all elements of the QlistWidget widget instead of letting it
compute the size of each element.
This commit is contained in:
Enrico Forestieri 2016-03-13 01:51:15 +01:00
parent 8d088df4df
commit 0430132aa0
2 changed files with 9 additions and 3 deletions

View File

@ -181,6 +181,11 @@ GuiDelimiter::GuiDelimiter(GuiView & lv)
initMathSymbols();
FontInfo lyxfont;
lyxfont.setFamily(CMR_FAMILY);
QFontMetrics fm(frontend::getFont(lyxfont));
QSize item_size(fm.maxWidth(), fm.height() + 8);
typedef map<char_type, QListWidgetItem *> ListItems;
ListItems list_items;
// The last element is the empty one.
@ -191,11 +196,12 @@ GuiDelimiter::GuiDelimiter(GuiView & lv)
QString symbol(ms.fontcode?
QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
QListWidgetItem * lwi = new QListWidgetItem(symbol);
FontInfo lyxfont;
lyxfont.setFamily(ms.fontfamily);
QFont font = frontend::getFont(lyxfont);
lwi->setFont(font);
lwi->setToolTip(toqstr(delim));
lwi->setSizeHint(item_size);
lwi->setTextAlignment(Qt::AlignTop);
list_items[ms.unicode] = lwi;
leftLW->addItem(lwi);
}

View File

@ -84,7 +84,7 @@
<enum>QListView::Adjust</enum>
</property>
<property name="spacing" >
<number>0</number>
<number>2</number>
</property>
<property name="currentRow" >
<number>-1</number>
@ -123,7 +123,7 @@
<enum>QListView::Adjust</enum>
</property>
<property name="spacing" >
<number>0</number>
<number>2</number>
</property>
</widget>
</item>