commit 29bc6a77c4520520d0151e9891ab521273dec5c1
Author: Koji Yokota <[email protected]>
Date: Sat Nov 8 10:16:41 2025 +0900
Fix wrong preedit font size in text mode of mathed
---
src/MetricsInfo.cpp | 4 ++--
src/MetricsInfo.h | 2 +-
src/frontends/NullPainter.h | 8 ++++----
src/frontends/Painter.h | 6 +++---
src/frontends/qt/GuiPainter.cpp | 19 +++++++++++++------
src/frontends/qt/GuiPainter.h | 4 ++--
src/mathed/InsetMathChar.cpp | 2 +-
7 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp
index 90e74e9733..3b4dd70f82 100644
--- a/src/MetricsInfo.cpp
+++ b/src/MetricsInfo.cpp
@@ -219,9 +219,9 @@ void PainterInfo::draw(int x, int y, docstring const & str)
void PainterInfo::draw(int x, int y, char_type c,
frontend::InputMethod const * im,
- pos_type const char_format_index)
+ pos_type const char_format_index, FontInfo const * f)
{
- pain.text(x, y, c, im, char_format_index);
+ pain.text(x, y, c, im, char_format_index, f);
}
diff --git a/src/MetricsInfo.h b/src/MetricsInfo.h
index cd9096e993..5efa72a8ca 100644
--- a/src/MetricsInfo.h
+++ b/src/MetricsInfo.h
@@ -128,7 +128,7 @@ public:
void draw(int x, int y, docstring const & str);
///
void draw(int x, int y, char_type c, frontend::InputMethod const * im,
- pos_type const char_format_index);
+ pos_type const char_format_index, FontInfo const * f =
nullptr);
/// Determines the background color based on the
/// selection state, the background color inherited from the parent
inset
diff --git a/src/frontends/NullPainter.h b/src/frontends/NullPainter.h
index 28a1982d11..208c83417a 100644
--- a/src/frontends/NullPainter.h
+++ b/src/frontends/NullPainter.h
@@ -78,12 +78,12 @@ public:
Color, size_type, size_type, double, double) override {}
/// draw a char with input method
- void text(int, int, char_type, InputMethod const *,
- pos_type const, Direction const = Auto) override {}
+ void text(int, int, char_type, InputMethod const *, pos_type const,
+ FontInfo const * = nullptr, Direction const = Auto) override
{}
/// draw a string with input method
- void text(int, int, docstring const &, InputMethod const *,
- pos_type const, Direction const = Auto) override {}
+ void text(int, int, docstring const &, InputMethod const *, pos_type
const,
+ FontInfo const * = nullptr,Direction const = Auto) override {}
/// This painter does not paint
bool isNull() const override { return true; }
diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h
index d1a9b95f4d..5c32b5da1d 100644
--- a/src/frontends/Painter.h
+++ b/src/frontends/Painter.h
@@ -161,13 +161,13 @@ public:
double wordspacing, double textwidth) = 0;
/// draw a char at position x, y (y is the baseline) using input method
- virtual void text(int, int, char_type, InputMethod const *,
- pos_type const, Direction const = Auto) = 0;
+ virtual void text(int, int, char_type, InputMethod const *, pos_type
const,
+ FontInfo const * = nullptr, Direction const = Auto) =
0;
/// draw a string at position x, y (y is the baseline) using input
method.
virtual void text(int x, int y, docstring const & str,
InputMethod const * im, pos_type const
char_format_index,
- Direction const dir = Auto) = 0;
+ FontInfo const * f = nullptr, Direction const dir =
Auto) = 0;
// Returns true if the painter does not actually paint.
virtual bool isNull() const = 0;
diff --git a/src/frontends/qt/GuiPainter.cpp b/src/frontends/qt/GuiPainter.cpp
index 3d23b1ce97..8920e95425 100644
--- a/src/frontends/qt/GuiPainter.cpp
+++ b/src/frontends/qt/GuiPainter.cpp
@@ -345,16 +345,16 @@ void GuiPainter::text(int x, int y, docstring const & s,
void GuiPainter::text(int x, int y, char_type c, InputMethod const * im,
- pos_type const char_format_index, Direction const dir)
+ pos_type const char_format_index, FontInfo const * f,
+ Direction const dir)
{
- text(x, y, docstring(1, c), im, char_format_index, dir);
+ text(x, y, docstring(1, c), im, char_format_index, f, dir);
}
void GuiPainter::text(int x, int y, docstring const & s,
- InputMethod const * im,
- pos_type const char_format_index,
- Direction const dir)
+ InputMethod const * im, pos_type const char_format_index,
+ FontInfo const * f, Direction const dir)
{
if (s.empty())
return;
@@ -370,7 +370,14 @@ void GuiPainter::text(int x, int y, docstring const & s,
setPen(gim->charFormat(char_format_index).foreground().color());
setBackgroundMode(Qt::OpaqueMode);
setBackground(gim->charFormat(char_format_index).background());
- setFont(gim->charFormat(char_format_index).font());
+
+ QFont qfont = gim->charFormat(char_format_index).font();
+ if (f != nullptr) {
+ int fsize = getFont(*f).pointSize();
+ LASSERT(fsize > 0, fsize = 12);
+ qfont.setPointSize(fsize);
+ }
+ setFont(qfont);
LYXERR(Debug::GUI, "Drawing preedit segment " << char_format_index <<
": fg = " <<
diff --git a/src/frontends/qt/GuiPainter.h b/src/frontends/qt/GuiPainter.h
index 9e499e3c0d..ff7c53fe10 100644
--- a/src/frontends/qt/GuiPainter.h
+++ b/src/frontends/qt/GuiPainter.h
@@ -138,11 +138,11 @@ public:
/// draw a char at position x, y (y is the baseline) using input method
void text(int x, int y, char_type c, InputMethod const * im,
- pos_type const char_format_index,
+ pos_type const char_format_index, FontInfo const * f =
nullptr,
Direction const dir = Auto) override;
/// draw a string at position x, y (y is the baseline) using input
method.
void text(int x, int y, docstring const & str, InputMethod const * im,
- pos_type const char_format_index,
+ pos_type const char_format_index, FontInfo const * f =
nullptr,
Direction const dir = Auto) override;
///
diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index d6f93c558e..e32c2249ab 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -195,7 +195,7 @@ void InsetMathChar::draw(PainterInfo & pi, int x, int y,
frontend::InputMethod const * im,
pos_type const char_format_index) const
{
- pi.draw(x, y, char_, im, char_format_index);
+ pi.draw(x, y, char_, im, char_format_index, &pi.base.font);
}
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs