diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index bed55f9ddabf..66db01d295f4 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -247,6 +247,7 @@ public: class SmShowSymbolSet final : public weld::CustomWidgetController { + SmViewShell &m_rViewShell; Size m_aOldSize; SymbolPtrVec_t aSymbolSet; Link aSelectHdlLink; @@ -268,7 +269,7 @@ class SmShowSymbolSet final : public weld::CustomWidgetController DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void); public: - SmShowSymbolSet(std::unique_ptr pScrolledWindow); + SmShowSymbolSet(std::unique_ptr pScrolledWindow, SmViewShell &rViewShell); virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override { @@ -291,6 +292,7 @@ public: class SmShowSymbol final : public weld::CustomWidgetController { private: + SmViewShell &m_rViewShell; vcl::Font m_aFont; OUString m_aText; @@ -302,7 +304,7 @@ private: void setFontSize(vcl::Font &rFont) const; public: - SmShowSymbol(); + SmShowSymbol(SmViewShell &rViewShell); virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override { diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index c87b987660e4..585f5a0df475 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -85,6 +85,24 @@ public: const OUString& GetStyleName(sal_uInt16 nIdx) const; }; +vcl::Font lclGetSymbolFont(const SmViewShell& rViewShell, const SmSym &rSymbol) +{ + const SmDocShell* pDoc = rViewShell.GetDoc(); + if (pDoc) + { + // If we have a document, we want to render the symbol useing the font and style used in + // the documnet, so we do that by creating a node and preparing it, then get the resolved + // font and style from it. + SmToken token(TSPECIAL, '\0', "%" + rSymbol.GetUiName()); + SmSpecialNode aNode(token); + aNode.Prepare(pDoc->GetFormat(), *pDoc, 1); + aNode.PrepareAttributes(); + return aNode.GetFont(); + } + + return rSymbol.GetFace(); +} + } // end anonymous namespace SmFontStyles::SmFontStyles() @@ -985,8 +1003,9 @@ void SmAlignDialog::WriteTo(SmFormat &rFormat) const rFormat.RequestApplyChanges(); } -SmShowSymbolSet::SmShowSymbolSet(std::unique_ptr pScrolledWindow) - : nLen(0) +SmShowSymbolSet::SmShowSymbolSet(std::unique_ptr pScrolledWindow, SmViewShell &rViewShell) + : m_rViewShell(rViewShell) + , nLen(0) , nRows(0) , nColumns(0) , nXOffset(0) @@ -1034,7 +1053,7 @@ void SmShowSymbolSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rec for (size_t i = v; i < nSymbols ; i++) { SmSym aSymbol(*aSymbolSet[i]); - vcl::Font aFont(aSymbol.GetFace()); + vcl::Font aFont(lclGetSymbolFont(m_rViewShell, aSymbol)); aFont.SetAlignment(ALIGN_TOP); // taking a FontSize which is a bit smaller (compared to nLen) in order to have a buffer @@ -1198,7 +1217,8 @@ IMPL_LINK_NOARG(SmShowSymbolSet, ScrollHdl, weld::ScrolledWindow&, void) Invalidate(); } -SmShowSymbol::SmShowSymbol() +SmShowSymbol::SmShowSymbol(SmViewShell& rViewShell) + : m_rViewShell(rViewShell) { } @@ -1239,7 +1259,7 @@ void SmShowSymbol::SetSymbol(const SmSym *pSymbol) { if (pSymbol) { - vcl::Font aFont(pSymbol->GetFace()); + vcl::Font aFont(lclGetSymbolFont(m_rViewShell, *pSymbol)); aFont.SetAlignment(ALIGN_BASELINE); SetFont(aFont); @@ -1348,8 +1368,9 @@ SmSymbolDialog::SmSymbolDialog(weld::Window *pParent, OutputDevice *pFntListDevi , rViewSh(rViewShell) , rSymbolMgr(rMgr) , pFontListDev(pFntListDevice) + , m_aSymbolDisplay(rViewShell) , m_xSymbolSets(m_xBuilder->weld_combo_box("symbolset")) - , m_xSymbolSetDisplay(new SmShowSymbolSet(m_xBuilder->weld_scrolled_window("scrolledwindow", true))) + , m_xSymbolSetDisplay(new SmShowSymbolSet(m_xBuilder->weld_scrolled_window("scrolledwindow", true), rViewShell)) , m_xSymbolSetDisplayArea(new weld::CustomWeld(*m_xBuilder, "symbolsetdisplay", *m_xSymbolSetDisplay)) , m_xSymbolName(m_xBuilder->weld_label("symbolname")) , m_xSymbolDisplay(new weld::CustomWeld(*m_xBuilder, "preview", m_aSymbolDisplay))