diff options
author | Armin Le Grand (Allotropia) <Armin.Le.Grand@me.com> | 2021-11-18 18:06:39 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-11-18 22:02:18 +0100 |
commit | 7bcc18ac67181d10d3479b3100647aceddd86750 (patch) | |
tree | ff630483b4419d542c3923d7b2974abfa39c0818 /vcl | |
parent | b8ef63c9fb3a1d4fb4a5549d28067cde07a8ab13 (diff) |
Qt implement QtFont::GetGlyphOutline
Fixes FontWork with QFont based rendering.
Change-Id: I294fe89d2753b6e82a559ff847b44126f9ea3bfc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125500
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/QtFont.cxx | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/vcl/qt5/QtFont.cxx b/vcl/qt5/QtFont.cxx index a9d84e897c1b..07bf9f541f0b 100644 --- a/vcl/qt5/QtFont.cxx +++ b/vcl/qt5/QtFont.cxx @@ -24,6 +24,7 @@ #include <QtGui/QFont> #include <QtGui/QRawFont> +#include <QtGui/QPainterPath> static inline void applyWeight(QtFont& rFont, FontWeight eWeight) { @@ -151,7 +152,61 @@ hb_font_t* QtFont::ImplInitHbFont() return InitHbFont(hb_face_create_for_tables(getFontTable, this, nullptr)); } -bool QtFont::GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const { return false; } +bool QtFont::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rB2DPolyPoly, bool) const +{ + rB2DPolyPoly.clear(); + basegfx::B2DPolygon aPart; + QRawFont aRawFont(QRawFont::fromFont(*this)); + QPainterPath aQPath = aRawFont.pathForGlyph(nId); + + for (int a(0); a < aQPath.elementCount(); a++) + { + const QPainterPath::Element aQElement = aQPath.elementAt(a); + + switch (aQElement.type) + { + case QPainterPath::MoveToElement: + { + if (aPart.count()) + { + aPart.setClosed(true); + rB2DPolyPoly.append(aPart); + aPart.clear(); + } + + aPart.append(basegfx::B2DPoint(aQElement.x, aQElement.y)); + break; + } + case QPainterPath::LineToElement: + { + aPart.append(basegfx::B2DPoint(aQElement.x, aQElement.y)); + break; + } + case QPainterPath::CurveToElement: + { + const QPainterPath::Element aQ2 = aQPath.elementAt(++a); + const QPainterPath::Element aQ3 = aQPath.elementAt(++a); + aPart.appendBezierSegment(basegfx::B2DPoint(aQElement.x, aQElement.y), + basegfx::B2DPoint(aQ2.x, aQ2.y), + basegfx::B2DPoint(aQ3.x, aQ3.y)); + break; + } + case QPainterPath::CurveToDataElement: + { + break; + } + } + } + + if (aPart.count()) + { + aPart.setClosed(true); + rB2DPolyPoly.append(aPart); + aPart.clear(); + } + + return true; +} bool QtFont::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool) const { |