summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-12-10 21:39:50 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-12-10 21:40:42 +0000
commit79c4f0a2facfb25f5a532a32fdcc40d3027d96b5 (patch)
tree12764eb05d5c3e811c51f62c2009e63feb2b894b /vcl
parentcc02097495f95967f8f06c364dfa6a8949132868 (diff)
oss-fuzz: build fonts.conf replacement on the fly based on runtime location
Change-Id: Ic5a1dbd098d251588ff528cf2a63f2189cb783af
Diffstat (limited to 'vcl')
-rw-r--r--vcl/workben/wmffuzzer.cxx34
1 files changed, 23 insertions, 11 deletions
diff --git a/vcl/workben/wmffuzzer.cxx b/vcl/workben/wmffuzzer.cxx
index e84ab5dca5d5..b9b44b639d33 100644
--- a/vcl/workben/wmffuzzer.cxx
+++ b/vcl/workben/wmffuzzer.cxx
@@ -16,6 +16,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <unotools/configmgr.hxx>
+#include <rtl/strbuf.hxx>
#include <osl/file.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wmf.hxx>
@@ -30,18 +31,29 @@ namespace
{
void setFontConfigConf()
{
- OUString uri;
- if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) {
- abort();
- }
- sal_Int32 lastDirSeperatorPos = uri.lastIndexOf('/');
- if (lastDirSeperatorPos >= 0) {
- uri = uri.copy(0, lastDirSeperatorPos + 1);
+ osl::File aFontConfig("file::///tmp/wmffuzzerfonts.conf");
+ if (aFontConfig.open(osl_File_OpenFlag_Create | osl_File_OpenFlag_Write) == osl::File::E_None)
+ {
+ OUString uri;
+ if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) {
+ abort();
+ }
+ sal_Int32 lastDirSeperatorPos = uri.lastIndexOf('/');
+ if (lastDirSeperatorPos >= 0) {
+ uri = uri.copy(0, lastDirSeperatorPos + 1);
+ }
+ OUString path;
+ osl::FileBase::getSystemPathFromFileURL(uri, path);
+ OString sFontDir = OUStringToOString(path, osl_getThreadTextEncoding()) + "../share/fonts/truetype";
+
+ rtl::OStringBuffer aBuffer("<?xml version=\"1.0\"?>\n<fontconfig><dir>");
+ aBuffer.append(sFontDir);
+ aBuffer.append("</dir><cachedir>/tmp/cache/fontconfig</cachedir></fontconfig>");
+ rtl::OString aConf = aBuffer.makeStringAndClear();
+ sal_uInt64 aBytesWritten;
+ aFontConfig.write(aConf.getStr(), aConf.getLength(), aBytesWritten);
}
- OUString path;
- osl::FileBase::getSystemPathFromFileURL(uri, path);
- OString sFontConf = OUStringToOString(path, osl_getThreadTextEncoding()) + "fonts.conf";
- setenv("FONTCONFIG_FILE", sFontConf.getStr(), 0);
+ setenv("FONTCONFIG_FILE", "/tmp/wmffuzzerfonts.conf", 0);
}
}