From 388735924392027eb6a8e722083e6496b92a40fa Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 28 Oct 2020 15:11:36 +0000 Subject: tdf#137643 alternative solution to activate embedded fonts in one batch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib5ffb2b8a31f237d5d2e465bf3f777590e0bfade Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104947 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/source/gdi/embeddedfontshelper.cxx | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'vcl/source/gdi/embeddedfontshelper.cxx') diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx index 03f4092d5ed6..431c140422ce 100644 --- a/vcl/source/gdi/embeddedfontshelper.cxx +++ b/vcl/source/gdi/embeddedfontshelper.cxx @@ -156,10 +156,36 @@ bool EmbeddedFontsHelper::addEmbeddedFont( const uno::Reference< io::XInputStrea osl::File::remove( fileUrl ); return false; } - EmbeddedFontsHelper::activateFont( fontName, fileUrl ); + m_aAccumulatedFonts.emplace_back(std::make_pair(fontName, fileUrl)); return true; } +namespace +{ + struct UpdateFontsGuard + { + UpdateFontsGuard() + { + OutputDevice::ImplClearAllFontData(true); + } + + ~UpdateFontsGuard() + { + OutputDevice::ImplRefreshAllFontData(true); + } + }; +} + +void EmbeddedFontsHelper::activateFonts() +{ + if (m_aAccumulatedFonts.empty()) + return; + UpdateFontsGuard aUpdateFontsGuard; + for (const auto& rEntry : m_aAccumulatedFonts) + EmbeddedFontsHelper::activateFont(rEntry.first, rEntry.second); + m_aAccumulatedFonts.clear(); +} + OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, const char* extra ) { OUString path = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; -- cgit