summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-12-26 15:14:31 +0000
committerKhaled Hosny <khaledhosny@eglug.org>2018-05-08 00:55:27 +0200
commitbdccb7e9991d83029eb2f2f11327b54534a00db8 (patch)
treec32e95c49849647dc72c1071f375f3d2b67d8d7a /vcl/qt5
parent9615e45d2e2bac79c252a018846e4f20012cfa34 (diff)
Refactor CommonSalLayout font handling
Moves all platform specific code from CommonSalLayout into the platform specific plugins. This way the vcl library won't depend on the Qt5 libraries and the Qt5Font header can be moved into the qt5 VCL plugin. While at it, switch the CommonSalLayouts font reference from the FontSelectPattern to the LogicalFontInstance and also add the harfbuzz font handling to the instance. Change-Id: Ida910b8d88837ea949a2f84394ccc0cfae153060 Reviewed-on: https://gerrit.libreoffice.org/47408 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/Qt5Font.cxx31
-rw-r--r--vcl/qt5/Qt5Font.hxx40
-rw-r--r--vcl/qt5/Qt5FontFace.cxx2
-rw-r--r--vcl/qt5/Qt5Graphics.cxx3
-rw-r--r--vcl/qt5/Qt5Graphics.hxx1
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx11
6 files changed, 78 insertions, 10 deletions
diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx
index 01a45d359600..0164c3b13cd4 100644
--- a/vcl/qt5/Qt5Font.cxx
+++ b/vcl/qt5/Qt5Font.cxx
@@ -17,8 +17,37 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <qt5/Qt5Font.hxx>
+#include "Qt5Font.hxx"
+
+#include <QtGui/QFont>
+#include <QtGui/QRawFont>
+
+Qt5Font::Qt5Font(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP)
+ : LogicalFontInstance(rPFF, rFSP)
+{
+}
Qt5Font::~Qt5Font() {}
+static hb_blob_t* getFontTable(hb_face_t*, hb_tag_t nTableTag, void* pUserData)
+{
+ char pTagName[5];
+ LogicalFontInstance::DecodeOpenTypeTag(nTableTag, pTagName);
+
+ Qt5Font* pFont = static_cast<Qt5Font*>(pUserData);
+ QRawFont aRawFont(QRawFont::fromFont(*pFont));
+ QByteArray aTable = aRawFont.fontTable(pTagName);
+ const sal_uInt32 nLength = aTable.size();
+
+ hb_blob_t* pBlob = nullptr;
+ if (nLength > 0)
+ pBlob = hb_blob_create(aTable.data(), nLength, HB_MEMORY_MODE_DUPLICATE, nullptr, nullptr);
+ return pBlob;
+}
+
+hb_font_t* Qt5Font::ImplInitHbFont()
+{
+ return InitHbFont(hb_face_create_for_tables(getFontTable, this, nullptr));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Font.hxx b/vcl/qt5/Qt5Font.hxx
new file mode 100644
index 000000000000..fd496348c9b6
--- /dev/null
+++ b/vcl/qt5/Qt5Font.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <fontinstance.hxx>
+
+#include <QtGui/QFont>
+
+#include "Qt5FontFace.hxx"
+
+class Qt5Font final : public QFont, public LogicalFontInstance
+{
+ friend LogicalFontInstance* Qt5FontFace::CreateFontInstance(const FontSelectPattern&) const;
+
+ virtual hb_font_t* ImplInitHbFont() override;
+
+ explicit Qt5Font(const PhysicalFontFace&, const FontSelectPattern&);
+
+public:
+ virtual ~Qt5Font() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index dd80292922aa..0cd071385aaa 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -18,7 +18,7 @@
*/
#include "Qt5FontFace.hxx"
-#include <qt5/Qt5Font.hxx>
+#include "Qt5Font.hxx"
#include "Qt5Tools.hxx"
#include <sft.hxx>
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx
index cf39b916ab42..8bf37adddff8 100644
--- a/vcl/qt5/Qt5Graphics.cxx
+++ b/vcl/qt5/Qt5Graphics.cxx
@@ -19,7 +19,7 @@
#include "Qt5Graphics.hxx"
-#include <qt5/Qt5Font.hxx>
+#include "Qt5Font.hxx"
#include "Qt5Frame.hxx"
#include "Qt5Painter.hxx"
@@ -34,7 +34,6 @@ Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
, m_aFillColor( 0xFF, 0xFF, 0XFF )
, m_eCompositionMode( QPainter::CompositionMode_SourceOver )
, m_pFontCollection( nullptr )
- , m_pFontData{ nullptr, }
, m_pTextStyle{ nullptr, }
, m_aTextColor( 0x00, 0x00, 0x00 )
{
diff --git a/vcl/qt5/Qt5Graphics.hxx b/vcl/qt5/Qt5Graphics.hxx
index 9feff684ec93..8b37232f7e5c 100644
--- a/vcl/qt5/Qt5Graphics.hxx
+++ b/vcl/qt5/Qt5Graphics.hxx
@@ -48,7 +48,6 @@ class Qt5Graphics : public SalGraphics
QPainter::CompositionMode m_eCompositionMode;
PhysicalFontCollection* m_pFontCollection;
- const Qt5FontFace* m_pFontData[MAX_FALLBACK];
Qt5Font* m_pTextStyle[MAX_FALLBACK];
Color m_aTextColor;
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 4314e6333fe3..ed3d849aa3f4 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -19,7 +19,7 @@
#include "Qt5Graphics.hxx"
#include "Qt5FontFace.hxx"
-#include <qt5/Qt5Font.hxx>
+#include "Qt5Font.hxx"
#include <vcl/fontcharmap.hxx>
@@ -78,16 +78,17 @@ void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel)
const FontCharMapRef Qt5Graphics::GetFontCharMap() const
{
- if (!m_pFontData[0])
+ if (!m_pTextStyle[0])
return FontCharMapRef(new FontCharMap());
- return m_pFontData[0]->GetFontCharMap();
+ return static_cast<const Qt5FontFace*>(m_pTextStyle[0]->GetFontFace())->GetFontCharMap();
}
bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const
{
- if (!m_pFontData[0])
+ if (!m_pTextStyle[0])
return false;
- return m_pFontData[0]->GetFontCapabilities(rFontCapabilities);
+ return static_cast<const Qt5FontFace*>(m_pTextStyle[0]->GetFontFace())
+ ->GetFontCapabilities(rFontCapabilities);
}
void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)