summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-07-05 18:24:28 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2018-07-06 10:47:34 +0200
commit9a5b1d50806706328404060806bf3ee936b4baaf (patch)
tree75dee38b4461a8bb12055a26674a5e01c9be67d9 /vcl
parent670117dd9659910fe2cbde92356b12ef1ceb8399 (diff)
Qt5 use fontconfig for font substitution
This just shoves all known fonts from the PrintFontManager into the QFontDatabase. Can be disabled using SAL_VCL_QT5_NO_FONTCONFIG. It already feels slow - don't know. Running "./bin/run vcldemo --show text" you can see it has some pro and cons, regarding the output. Qts' diacrits look definitly nicer then the "substitutions". This brings the font support kind of on par with the other backends. And since sensible font substitition is not at all implemented in Qt, we have to rely on some platform ssolution anyway. And this needs a sensible, platform agnostic interface, so we can reuse the code easier. Change-Id: I4e9d8ee98fc479a7c4bbe4c968116e0a102ebb7a
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/Qt5Graphics_GDI.cxx26
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx24
-rw-r--r--vcl/qt5/Qt5Instance.cxx2
3 files changed, 49 insertions, 3 deletions
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index a9f9175e6d48..c45b678d88a5 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -248,9 +248,31 @@ void Qt5Graphics::drawPolygon(sal_uInt32 nPoints, const SalPoint* pPtAry)
aPainter.update(aPolygon.boundingRect());
}
-void Qt5Graphics::drawPolyPolygon(sal_uInt32 /*nPoly*/, const sal_uInt32* /*pPoints*/,
- PCONSTSALPOINT* /*pPtAry*/)
+void Qt5Graphics::drawPolyPolygon(sal_uInt32 nPolyCount, const sal_uInt32* pPoints,
+ PCONSTSALPOINT* ppPtAry)
{
+ // ignore invisible polygons
+ if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor)
+ return;
+
+ QPainterPath aPath;
+ for (sal_uInt32 nPoly = 0; nPoly < nPolyCount; nPoly++)
+ {
+ const sal_uInt32 nPoints = pPoints[nPoly];
+ if (nPoints > 1)
+ {
+ const SalPoint* pPtAry = ppPtAry[nPoly];
+ aPath.moveTo(pPtAry->mnX, pPtAry->mnY);
+ pPtAry++;
+ for (sal_uInt32 nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++)
+ aPath.lineTo(pPtAry->mnX, pPtAry->mnY);
+ aPath.closeSubpath();
+ }
+ }
+
+ Qt5Painter aPainter(*this, true);
+ aPainter.drawPath(aPath);
+ aPainter.update(aPath.boundingRect());
}
bool Qt5Graphics::drawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPoly, double fTransparency)
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 282432214589..92e9a416d74a 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -23,6 +23,8 @@
#include <Qt5Painter.hxx>
#include <vcl/fontcharmap.hxx>
+#include <unx/geninst.h>
+#include <unx/fontmanager.hxx>
#include <sallayout.hxx>
#include <PhysicalFontCollection.hxx>
@@ -89,11 +91,33 @@ bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities)
void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)
{
+ static const bool bUseFontconfig = (nullptr == getenv("SAL_VCL_QT5_NO_FONTCONFIG"));
+
m_pFontCollection = pPFC;
if (pPFC->Count())
return;
QFontDatabase aFDB;
+
+ if (bUseFontconfig)
+ {
+ ::std::vector<psp::fontID> aList;
+ psp::FastPrintFontInfo aInfo;
+
+ psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
+ rMgr.getFontList(aList);
+ for (auto const& elem : aList)
+ {
+ if (!rMgr.getFontFastInfo(elem, aInfo))
+ continue;
+ QString aFilename = toQString(
+ OStringToOUString(rMgr.getFontFileSysPath(aInfo.m_nID), RTL_TEXTENCODING_UTF8));
+ aFDB.addApplicationFont(aFilename);
+ }
+
+ SalGenericInstance::RegisterFontSubstitutors(pPFC);
+ }
+
for (auto& family : aFDB.families())
for (auto& style : aFDB.styles(family))
{
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 40c737446c65..6ea2610e03f7 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -283,7 +283,7 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
QApplication::setQuitOnLastWindowClosed(false);
- const bool bUseCairo = (nullptr != getenv("SAL_VCL_QT5_USE_CAIRO"));
+ static const bool bUseCairo = (nullptr != getenv("SAL_VCL_QT5_USE_CAIRO"));
Qt5Instance* pInstance = new Qt5Instance(new SalYieldMutex(), bUseCairo);
// initialize SalData