From 7a6ad48495b920797da20fdc685152f3d744c2dd Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sat, 3 Apr 2021 18:37:10 +0200 Subject: [PATCH] Use font metrics for computing the size of math decorations It was an error using an absolute size instead of one relative to the size of the used font. It was requiring using the physical dpi of the screen and caused #12222. Now everything is computed with respect to the metrics of the font and should be automatically correct. Fixes #12222. --- src/frontends/qt/GuiApplication.cpp | 2 +- src/mathed/InsetMathDecoration.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index 7d9bb9433f..b818163f0b 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -1141,7 +1141,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv) // needs to be done before reading lyxrc QWidget w; - lyxrc.dpi = (w.physicalDpiX() + w.physicalDpiY()) / 2; + lyxrc.dpi = (w.logicalDpiX() + w.logicalDpiY()) / 2; guiApp = this; diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp index ae95cdc1d5..cc4ba16279 100644 --- a/src/mathed/InsetMathDecoration.cpp +++ b/src/mathed/InsetMathDecoration.cpp @@ -122,8 +122,8 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const cell(0).metrics(mi, dim); int const l1 = mi.base.bv->zoomedPixels(1); - int const l2 = 4 * l1; - int const l3 = 4 * l1; + int const l2 = mathed_char_width(mi.base.font, 'x') - l1; + int const l3 = l2; dh_ = l2; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_); dw_ = l3; //mathed_char_width(LM_TC_VAR, mi, 'x'); -- 2.39.5