diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-03-12 09:56:18 +0100 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-06-01 10:06:22 +0200 |
commit | bf495a371d82ba8953718829fdbd277067f5f653 (patch) | |
tree | 3220457362f2a8f232134bab2c3473800b061dc0 /vcl | |
parent | 564150f62d70466b50a887efb472562d169ee9d0 (diff) |
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
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/Qt5Font.cxx | 3 | ||||
-rw-r--r-- | vcl/qt5/Qt5FontFace.cxx | 1 | ||||
-rw-r--r-- | vcl/qt5/Qt5Graphics_Text.cxx | 15 | ||||
-rw-r--r-- | vcl/qt5/Qt5Tools.hxx | 5 |
4 files changed, 22 insertions, 2 deletions
diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx index 0164c3b13cd4..46e7b9ec01c3 100644 --- a/vcl/qt5/Qt5Font.cxx +++ b/vcl/qt5/Qt5Font.cxx @@ -41,7 +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(aTable.data(), nLength, HB_MEMORY_MODE_DUPLICATE, 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 8967a8c1e1db..a719bef57085 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -131,7 +131,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()); } |