[Libreoffice-commits] core.git: Branch 'private/jmux/qt5_fixes' - vcl/qt5 vcl/source
Jan-Marek Glogowski
glogow at fbihome.de
Mon Mar 12 09:00:45 UTC 2018
vcl/qt5/Qt5Font.cxx | 4 ++--
vcl/qt5/Qt5FontFace.cxx | 1 +
vcl/qt5/Qt5Graphics_Text.cxx | 15 ++++++++++++++-
vcl/qt5/Qt5Tools.hxx | 5 +++++
vcl/source/gdi/CommonSalLayout.cxx | 5 ++---
5 files changed, 24 insertions(+), 6 deletions(-)
New commits:
commit 1b4f6cc436b3db63cbd84040b39eb002f36c953c
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Mon Mar 12 09:56:18 2018 +0100
Qt5 fix font drawing
The main problem was the memory management of the harfbuzz memory
blob. Now we copy the font data tables into the blob, as the
QByteArray memory will be freed at the end of the function.
Change-Id: If5a5a4b1a235e66ba472b28a156e16be1b82bf2e
diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx
index 51e87e8a1958..74918a70f008 100644
--- a/vcl/qt5/Qt5Font.cxx
+++ b/vcl/qt5/Qt5Font.cxx
@@ -41,8 +41,8 @@ static hb_blob_t* getFontTable(hb_face_t*, hb_tag_t nTableTag, void* pUserData)
hb_blob_t* pBlob = nullptr;
if (nLength > 0)
- pBlob = hb_blob_create(reinterpret_cast<const char*>(aTable.data()), nLength,
- HB_MEMORY_MODE_READONLY, nullptr, nullptr);
+ pBlob = hb_blob_create(aTable.data(), nLength,
+ HB_MEMORY_MODE_DUPLICATE, nullptr, nullptr);
return pBlob;
}
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index 0cd071385aaa..b7a0f0b12f9e 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -28,6 +28,7 @@
#include <PhysicalFontCollection.hxx>
#include <QtGui/QFont>
+#include <QtGui/QFontInfo>
#include <QtGui/QRawFont>
using namespace vcl;
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index a457759a3c22..b31975e6f527 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -137,7 +137,20 @@ void Qt5Graphics::GetGlyphWidths(const PhysicalFontFace* /*pPFF*/, bool /*bVerti
{
}
-bool Qt5Graphics::GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) { return false; }
+bool Qt5Graphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
+{
+ const int nLevel = rGlyph.mnFallbackLevel;
+ if( nLevel >= MAX_FALLBACK )
+ return false;
+
+ Qt5Font* pFont = m_pTextStyle[ nLevel ];
+ if( !pFont )
+ return false;
+
+ QRawFont aRawFont(QRawFont::fromFont( *pFont ));
+ rRect = toRectangle(aRawFont.boundingRect(rGlyph.maGlyphId).toAlignedRect());
+ return true;
+}
bool Qt5Graphics::GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) { return false; }
diff --git a/vcl/qt5/Qt5Tools.hxx b/vcl/qt5/Qt5Tools.hxx
index bfd604993fd0..c7b47014beb0 100644
--- a/vcl/qt5/Qt5Tools.hxx
+++ b/vcl/qt5/Qt5Tools.hxx
@@ -46,6 +46,11 @@ inline QRect toQRect(const tools::Rectangle& rRect)
return QRect(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight());
}
+inline tools::Rectangle toRectangle(const QRect& rRect)
+{
+ return tools::Rectangle(rRect.left(), rRect.top(), rRect.width(), rRect.height());
+}
+
inline QSize toQSize(const Size& rSize) { return QSize(rSize.Width(), rSize.Height()); }
inline Size toSize(const QSize& rSize) { return Size(rSize.width(), rSize.height()); }
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 3664401237b2..177e2d01064b 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -271,8 +271,6 @@ bool CommonSalLayout::HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aVariationSe
bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
{
- hb_face_t* pHbFace = hb_font_get_face(mpFont->GetHbFont());
-
int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos);
Reserve(nGlyphCapacity);
@@ -312,6 +310,8 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
mpFont->GetScale(&nXScale, &nYScale);
Point aCurrPos(0, 0);
+ hb_font_t *pHbFont = mpFont->GetHbFont();
+ hb_face_t *pHbFace = hb_font_get_face(pHbFont);
while (true)
{
int nBidiMinRunPos, nBidiEndRunPos;
@@ -400,7 +400,6 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
if (bRightToLeft)
std::reverse(aSubRuns.begin(), aSubRuns.end());
- hb_font_t *pHbFont = mpFont->GetHbFont();
for (const auto& aSubRun : aSubRuns)
{
hb_buffer_clear_contents(pHbBuffer);
More information about the Libreoffice-commits
mailing list