vcl/source/font/PhysicalFontCollection.cxx | 35 ++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-)
New commits: commit f16d17df9d33ad96d053abe2d9212b0c2850c19f Author: Khaled Hosny <khaledho...@eglug.org> Date: Wed Dec 21 20:16:14 2016 +0200 Make sure we use bundled metric-compatible fonts We were relying on FontConfig knowing about these replacements, but this does not work on Mac and might not even work on Linux if FontConfig is not configured to know these replacements. Since we bundle these fonts, we better making sure they end up being used. Change-Id: I26e72e8d1e5c902132e1260791e20017a92a5475 Reviewed-on: https://gerrit.libreoffice.org/32299 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Khaled Hosny <khaledho...@eglug.org> diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 3a7da59..f0249c0 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <map> + #include <i18nlangtag/mslangid.hxx> #include <unotools/configmgr.hxx> #include <unotools/fontdefs.hxx> @@ -968,6 +970,33 @@ ImplDeviceFontSizeList* PhysicalFontCollection::GetDeviceFontSizeList( const OUS return pDeviceFontSizeList; } +// These are the metric-compatible replacement fonts that are bundled with +// LibreOffice, we prefer them over generic substitutions that might be +// provided by the system. +static const std::map<OUString, OUString> aMetricCompatibleMap = +{ + { "Times New Roman", "Liberation Serif" }, + { "Arial", "Liberation Sans" }, + { "Arial Narrow", "Liberation Sans Narrow" }, + { "Courier New", "Liberation Mono" }, + { "Cambria", "Caladea" }, + { "Calibri", "Carlito" }, +}; + +static bool FindMetricCompatibleFont(FontSelectPattern& rFontSelData) +{ + for (const auto& aSub : aMetricCompatibleMap) + { + if (rFontSelData.maSearchName == GetEnglishSearchFontName(aSub.first)) + { + rFontSelData.maSearchName = aSub.second; + return true; + } + } + + return false; +} + PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& rFSD ) const { // give up if no fonts are available @@ -1053,10 +1082,10 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r return pFoundData; } - if( mpPreMatchHook ) + if (FindMetricCompatibleFont(rFSD) || + (mpPreMatchHook && mpPreMatchHook->FindFontSubstitute(rFSD))) { - if( mpPreMatchHook->FindFontSubstitute( rFSD ) ) - aSearchName = GetEnglishSearchFontName( aSearchName ); + aSearchName = GetEnglishSearchFontName(aSearchName); } // the prematch hook uses the target name to search, but we now need _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits