mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Makes caret height adapt to context in mathed.
Set current cursor font in MathData::metrics() Also make sure that caret dimension in mathed is not larger than inset height.
This commit is contained in:
parent
37404df686
commit
c5ca503d92
@ -2965,8 +2965,16 @@ void BufferView::caretPosAndHeight(Point & p, int & h) const
|
|||||||
Cursor const & cur = cursor();
|
Cursor const & cur = cursor();
|
||||||
Font const font = cur.real_current_font;
|
Font const font = cur.real_current_font;
|
||||||
frontend::FontMetrics const & fm = theFontMetrics(font);
|
frontend::FontMetrics const & fm = theFontMetrics(font);
|
||||||
int const asc = fm.maxAscent();
|
int asc = fm.maxAscent();
|
||||||
int const des = fm.maxDescent();
|
int des = fm.maxDescent();
|
||||||
|
// If the cursor is in mathed and it has cached metrics, reduce
|
||||||
|
// the height to fit the inner cell (mathed cells are tight
|
||||||
|
// vertically).
|
||||||
|
if (cur.inMathed() && coordCache().getArrays().hasDim(&cur.cell())) {
|
||||||
|
Dimension const dim = cur.cell().dimension(*this);
|
||||||
|
asc = min(asc, dim.asc);
|
||||||
|
des = min(des, dim.des);
|
||||||
|
}
|
||||||
h = asc + des;
|
h = asc + des;
|
||||||
p = getPos(cur);
|
p = getPos(cur);
|
||||||
p.y_ -= asc;
|
p.y_ -= asc;
|
||||||
|
@ -261,6 +261,15 @@ bool isInside(DocIterator const & it, MathData const & ar,
|
|||||||
|
|
||||||
void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
|
void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
|
// This is the only point where the drawing font is known.
|
||||||
|
// We set cursor current font so that the blinking caret height
|
||||||
|
// adapts to math font.
|
||||||
|
Cursor & cur = mi.base.bv->cursor();
|
||||||
|
if (cur.inMathed() && &cur.cell() == this) {
|
||||||
|
cur.current_font.fontInfo() = mi.base.font;
|
||||||
|
cur.real_current_font.fontInfo() = mi.base.font;
|
||||||
|
}
|
||||||
|
|
||||||
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
|
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
|
||||||
dim = fm.dimension('I');
|
dim = fm.dimension('I');
|
||||||
int xascent = fm.dimension('x').ascent();
|
int xascent = fm.dimension('x').ascent();
|
||||||
|
Loading…
Reference in New Issue
Block a user