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>
This commit is contained in:
parent
b8ef63c9fb
commit
7bcc18ac67
1 changed files with 56 additions and 1 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue