Le 20/03/2018 à 16:57, Pavel Sanda a écrit :
This is already huge improvement to the current situation.
It might still make sense to decrease little bit, I can try
different patch if you have another variant at hand.

This, for example. I am not sure how robust it is, but it seems to work.

JMarc


From 22841811d75df5aee35691c7709eebfd0b7ea8e7 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Tue, 20 Mar 2018 16:41:59 +0100
Subject: [PATCH] Set current cursor font in MathData::metrics()

Also make sure that caret dimension in mathed is not larger than inset
height.

This makes size of the cursor closer to current font in mathed.
---
 src/BufferView.cpp      | 9 +++++++--
 src/mathed/MathData.cpp | 6 ++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 0e30cc7..375ac90 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2965,8 +2965,13 @@ void BufferView::caretPosAndHeight(Point & p, int & h) const
 	Cursor const & cur = cursor();
 	Font const font = cur.real_current_font;
 	frontend::FontMetrics const & fm = theFontMetrics(font);
-	int const asc = fm.maxAscent();
-	int const des = fm.maxDescent();
+	int asc = fm.maxAscent();
+	int des = fm.maxDescent();
+	if (d->cursor_.inMathed()) {
+		Dimension const dim = d->cursor_.cell().dimension(*this);
+		asc = min(asc, dim.asc);
+		des = min(des, dim.des);
+	}
 	h = asc + des;
 	p = getPos(cur);
 	p.y_ -= asc;
diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index d242a86..b7a106e 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -261,6 +261,12 @@ bool isInside(DocIterator const & it, MathData const & ar,
 
 void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
 {
+	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);
 	dim = fm.dimension('I');
 	int xascent = fm.dimension('x').ascent();
-- 
2.7.4

Reply via email to