summaryrefslogtreecommitdiff
path: root/vcl/qt5/Qt5Graphics_Text.cxx
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/qt5/Qt5Graphics_Text.cxx
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/qt5/Qt5Graphics_Text.cxx')
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx24
1 files changed, 24 insertions, 0 deletions
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))
{