summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-12-26 15:58:21 +0100
committerKhaled Hosny <khaledhosny@eglug.org>2018-05-07 23:03:37 +0200
commit083b7ca26bbf4b9bad2922520caaf5c0227dac5e (patch)
treeb33576cd90c64cb2ede5ab1a930b11828f110105 /vcl/qt5
parent1ca1886d46f38a0759ab466e6a4a8c3c0866c523 (diff)
Move PhysicalFontFace member of FontSelectPattern
A FontSelectPattern describes a general font request. It can be used to find the best matching LogicalFontInstance. The instance will be created based on a PhysicalFontFace, which is really a factory since commit 8b700794b2746070814e9ff416ecd7bbb1c902e7. Following this workflow, this moves the PhysicalFontFace pointer to the instance and makes it constant. Which leaves some special symbol font handling code in the hash and instance lookup code path. It used to query the font face directly from the instance. I'm not sure of the correct handling. The related commits where made to fix #i89002#, which has an attached test document. 1. commit 849f618270da313f9339dda29a9f35938434c91d 2. commit 8c9823d311fdf8092cc75873e4565325d204a658 The document is as broken as it was before the patch. The symbol substitution still works, but the 'Q's are missing when displaying a symbol font. I also don't understand all the reinterpret_casts for fake font ids. I guess this was used to prevent the crashes I see, where a PhysicalFontFace referenced in a valid LogicalFontInstance is freed and a later FontId check in the GlyphCache crashes. So this now checks for a valid cache instead. Change-Id: If8ee5a6288e66cfa4c419289fbdd5b5da128c6ea Reviewed-on: https://gerrit.libreoffice.org/47279 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/Qt5FontFace.cxx6
-rw-r--r--vcl/qt5/Qt5FontFace.hxx2
-rw-r--r--vcl/qt5/Qt5Graphics.cxx20
-rw-r--r--vcl/qt5/Qt5Graphics.hxx2
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx17
5 files changed, 31 insertions, 16 deletions
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index a73e4528ec05..dd80292922aa 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -18,6 +18,7 @@
*/
#include "Qt5FontFace.hxx"
+#include <qt5/Qt5Font.hxx>
#include "Qt5Tools.hxx"
#include <sft.hxx>
@@ -60,6 +61,11 @@ Qt5FontFace::~Qt5FontFace() {}
sal_IntPtr Qt5FontFace::GetFontId() const { return reinterpret_cast<sal_IntPtr>(&m_aFontId); }
+LogicalFontInstance* Qt5FontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
+{
+ return new Qt5Font(*this, rFSD);
+}
+
const FontCharMapRef Qt5FontFace::GetFontCharMap() const
{
if (m_xCharMap.is())
diff --git a/vcl/qt5/Qt5FontFace.hxx b/vcl/qt5/Qt5FontFace.hxx
index bd33893609d8..9468cf15b4e3 100644
--- a/vcl/qt5/Qt5FontFace.hxx
+++ b/vcl/qt5/Qt5FontFace.hxx
@@ -47,6 +47,8 @@ public:
bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const;
bool HasChar(sal_uInt32 cChar) const;
+ LogicalFontInstance* CreateFontInstance(const FontSelectPattern& rFSD) const override;
+
protected:
Qt5FontFace(const Qt5FontFace&);
Qt5FontFace(const FontAttributes& rFA, const QString& rFontID);
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx
index 6ec6c341913a..cf39b916ab42 100644
--- a/vcl/qt5/Qt5Graphics.cxx
+++ b/vcl/qt5/Qt5Graphics.cxx
@@ -19,16 +19,13 @@
#include "Qt5Graphics.hxx"
+#include <qt5/Qt5Font.hxx>
#include "Qt5Frame.hxx"
#include "Qt5Painter.hxx"
-#include <qt5/Qt5Font.hxx>
-
-#include <QtWidgets/QWidget>
-
-#include <QtGui/QPainter>
-
#include <QtGui/QImage>
+#include <QtGui/QPainter>
+#include <QtWidgets/QWidget>
Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
: m_pFrame( pFrame )
@@ -44,7 +41,16 @@ Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
ResetClipRegion();
}
-Qt5Graphics::~Qt5Graphics() {}
+Qt5Graphics::~Qt5Graphics()
+{
+ // release the text styles
+ for (int i = 0; i < MAX_FALLBACK; ++i)
+ {
+ if (!m_pTextStyle[i])
+ break;
+ m_pTextStyle[i]->Release();
+ }
+}
void Qt5Graphics::ChangeQImage(QImage* pQImage)
{
diff --git a/vcl/qt5/Qt5Graphics.hxx b/vcl/qt5/Qt5Graphics.hxx
index 0ece5ec5f036..9feff684ec93 100644
--- a/vcl/qt5/Qt5Graphics.hxx
+++ b/vcl/qt5/Qt5Graphics.hxx
@@ -49,7 +49,7 @@ class Qt5Graphics : public SalGraphics
PhysicalFontCollection* m_pFontCollection;
const Qt5FontFace* m_pFontData[MAX_FALLBACK];
- std::unique_ptr<Qt5Font> m_pTextStyle[MAX_FALLBACK];
+ Qt5Font* m_pTextStyle[MAX_FALLBACK];
Color m_aTextColor;
Qt5Graphics(Qt5Frame* pFrame, QImage* pQImage);
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 2dbeaecfdf2c..4314e6333fe3 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -39,17 +39,18 @@ void Qt5Graphics::SetFont(const FontSelectPattern* pReqFont, int nFallbackLevel)
{
if (!m_pTextStyle[i])
break;
- m_pTextStyle[i].reset();
+ m_pTextStyle[i]->Release();
+ m_pTextStyle[i] = nullptr;
}
if (!pReqFont)
- // handle release-font-resources request
- m_pFontData[nFallbackLevel] = nullptr;
- else
- {
- m_pFontData[nFallbackLevel] = static_cast<const Qt5FontFace*>(pReqFont->mpFontData);
- m_pTextStyle[nFallbackLevel].reset(new Qt5Font(*pReqFont));
- }
+ return;
+ assert(pReqFont->mpFontInstance);
+ if (!pReqFont->mpFontInstance)
+ return;
+
+ m_pTextStyle[nFallbackLevel] = static_cast<Qt5Font*>(pReqFont->mpFontInstance);
+ m_pTextStyle[nFallbackLevel]->Acquire();
}
void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel)