summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2022-09-20 16:07:14 +0300
committerTor Lillqvist <tml@collabora.com>2022-10-12 14:21:18 +0200
commit2def5485aa57d7c407a84ecc73b22083579e9a98 (patch)
tree42378dc2093ad2fc82001a5b72e9a5e69411ca0c /desktop
parentaaa34c3ee9895bab5fc6f6dc42882464d7078430 (diff)
Enable opening of downloaded fonts only in ForKit in Online
(This is the second attempt at this, I had to revert the first one as it broke desktop Collabora Office.) We want that only the ForKit process needs to have access to new font files added to a Collabora Online instance dynamically by downloading from a server. There are however many locations in the Kit process, in core and in external libraries like harfbuzz, where the code wants to open a font file. Handle this so that the ForKit process opens such a downloaded font file and doesn't close it. The file descriptor is thus inherited by Kit processes. The font file pathname passed on to other code is a fake on in the format "/:FD:/%d" where the %d is the file descriptor of the opened font file. Add checks in all places where font files are opened, look for this special pathname format, and modify the code to just dup() the already open file descriptor in that case. All this is relevant for Linux only, as Collabora Online runs on Linux. Do the above for harfbuzz, cairo, fontconfig, and freetype. In addition make sure that these libraries (except harfbuzz which needs to be a static library) when bundled, on Linux, are built as shared libraries, and won't be confused with the corresponding system libraries by making sure their sonames are different. Change-Id: Ib059cb27e1637d07bb709249abd0d984f948caa9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140714 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 559c8fe9cd1b..8b93b9815a8f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -25,6 +25,10 @@
#include <postmac.h>
#endif
+#ifdef LINUX
+#include <fcntl.h>
+#endif
+
#ifdef ANDROID
#include <osl/detail/android-bootstrap.h>
#endif
@@ -4331,13 +4335,27 @@ static void lo_setOption(LibreOfficeKit* /*pThis*/, const char *pOption, const c
else
sal_detail_set_log_selector(pCurrentSalLogOverride);
}
+#ifdef LINUX
else if (strcmp(pOption, "addfont") == 0)
{
+ if (memcmp(pValue, "file://", 7) == 0)
+ pValue += 7;
+
+ int fd = open(pValue, O_RDONLY);
+ if (fd == -1)
+ {
+ std::cerr << "Could not open font file '" << pValue << "': " << strerror(errno) << std::endl;
+ return;
+ }
+
+ OUString sMagicFileName = "file:///:FD:/" + OUString::number(fd);
+
OutputDevice *pDevice = Application::GetDefaultDevice();
OutputDevice::ImplClearAllFontData(false);
- pDevice->AddTempDevFont(OUString::fromUtf8(pValue), "");
+ pDevice->AddTempDevFont(sMagicFileName, "");
OutputDevice::ImplRefreshAllFontData(false);
}
+#endif
}
static void lo_dumpState (LibreOfficeKit* pThis, const char* /* pOptions */, char** pState)