diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-10-06 16:35:09 +1100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-08 19:19:56 +0200 |
commit | 677434a572b8f07a386937b2f7edf2e9b801bbd0 (patch) | |
tree | 52b10a20cf6956572aaddd1c986b27787c028859 | |
parent | 49e02381a301e4634eb7077fcb08eb4e8a95fb08 (diff) |
vcl: split out outdev.h into seperate headers
outdev.h is a hodge-podge of functions - font substitution and an
internal state struct for OutputDevice. I have split these into:
- font/fontsubstitution: FontSubstitution,
GlyphFallbackFontSubstitution.hxx and PreMatchFontSubstitution.hxx
(all three define pure virtual base classes for later reuse)
- font/DirectFontSubstitution.hxx: incorporates FontSubstEntry and
DirectFontSubstitution
- ImplOutDevData.hxx contains it's own class
Each fo the classes has been moved to the vcl::font namespace.
As outdev.h is now no longer, this has meant that I have had to
regenerate vcl/inc/pch/precompiled_vcl.hxx
Change-Id: Iaa92fa21271faff46f2a8a0f6488e01434c142db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121997
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
25 files changed, 306 insertions, 207 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 5c410de75bb0..7886b5b271b5 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -470,6 +470,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/wmf/wmfwr \ vcl/source/filter/png/PngImageReader \ vcl/source/filter/png/pngwrite \ + vcl/source/font/DirectFontSubstitution \ vcl/source/font/Feature \ vcl/source/font/FeatureCollector \ vcl/source/font/FeatureParser \ diff --git a/vcl/inc/ImplOutDevData.hxx b/vcl/inc/ImplOutDevData.hxx new file mode 100644 index 000000000000..34e9c058c1fa --- /dev/null +++ b/vcl/inc/ImplOutDevData.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <tools/gen.hxx> + +#include <vcl/vclptr.hxx> + +class VirtualDevice; + +namespace vcl +{ +struct ControlLayoutData; +} + +// #i75163# +namespace basegfx +{ +class B2DHomMatrix; +} + +struct ImplOutDevData +{ + VclPtr<VirtualDevice> mpRotateDev; + vcl::ControlLayoutData* mpRecordLayout; + tools::Rectangle maRecordRect; + + // #i75163# + basegfx::B2DHomMatrix* mpViewTransform; + basegfx::B2DHomMatrix* mpInverseViewTransform; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/PhysicalFontCollection.hxx b/vcl/inc/PhysicalFontCollection.hxx index b35d3d1c6f99..e9907b8f5f6c 100644 --- a/vcl/inc/PhysicalFontCollection.hxx +++ b/vcl/inc/PhysicalFontCollection.hxx @@ -29,8 +29,11 @@ #define MAX_GLYPHFALLBACK 16 -class ImplGlyphFallbackFontSubstitution; -class ImplPreMatchFontSubstitution; +namespace vcl::font +{ +class GlyphFallbackFontSubstitution; +class PreMatchFontSubstitution; +} // TODO: merge with ImplFontCache // TODO: rename to LogicalFontManager @@ -60,8 +63,8 @@ public: OUString& rMissingCodes, int nFallbackLevel ) const; // prepare platform specific font substitutions - void SetPreMatchHook( ImplPreMatchFontSubstitution* ); - void SetFallbackHook( ImplGlyphFallbackFontSubstitution* ); + void SetPreMatchHook( vcl::font::PreMatchFontSubstitution* ); + void SetFallbackHook( vcl::font::GlyphFallbackFontSubstitution* ); // misc utilities std::shared_ptr<PhysicalFontCollection> Clone() const; @@ -73,8 +76,8 @@ private: typedef std::unordered_map<OUString, std::unique_ptr<vcl::font::PhysicalFontFamily>> PhysicalFontFamilies; PhysicalFontFamilies maPhysicalFontFamilies; - ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution - ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution + vcl::font::PreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution + vcl::font::GlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution mutable std::unique_ptr<std::array<vcl::font::PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList; mutable int mnFallbackCount; diff --git a/vcl/inc/font/DirectFontSubstitution.hxx b/vcl/inc/font/DirectFontSubstitution.hxx new file mode 100644 index 000000000000..7c2840bb4cad --- /dev/null +++ b/vcl/inc/font/DirectFontSubstitution.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <rtl/ustring.hxx> + +#include <vcl/rendercontext/AddFontSubstituteFlags.hxx> + +#include <font/fontsubstitution.hxx> + +#include <string> +#include <vector> + +namespace vcl::font +{ +struct FontSubstEntry +{ + FontSubstEntry(OUString const& rFontName, OUString const& rSubstFontName, + AddFontSubstituteFlags nSubstFlags) + : maSearchName(GetEnglishSearchFontName(rFontName)) + , maSearchReplaceName(GetEnglishSearchFontName(rSubstFontName)) + , mnFlags(nSubstFlags) + { + } + + OUString maSearchName; + OUString maSearchReplaceName; + AddFontSubstituteFlags mnFlags; +}; + +/** DirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions + The class is just a simple port of the unmaintainable manual-linked-list based mechanism + */ +// TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good +class DirectFontSubstitution final : public FontSubstitution +{ +private: + std::vector<FontSubstEntry> maFontSubstList; + +public: + void AddFontSubstitute(const OUString& rFontName, const OUString& rSubstName, + AddFontSubstituteFlags nFlags); + void RemoveFontsSubstitute(); + bool FindFontSubstitute(OUString& rSubstName, std::u16string_view rFontName) const; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/font/fontsubstitution.hxx b/vcl/inc/font/fontsubstitution.hxx new file mode 100644 index 000000000000..d721c9348e77 --- /dev/null +++ b/vcl/inc/font/fontsubstitution.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +// nowadays these substitutions are needed for backward compatibility and tight platform integration: +// - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig) +// - device specific substitutions (e.g. for PS printer builtin fonts) +// - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks) +// - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB") +// - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks) +// - substitutions for missing symbol fonts by translating code points into other symbol fonts + +#pragma once + +#include <sal/config.h> + +#include <rtl/ustring.hxx> + +#include <vcl/rendercontext/AddFontSubstituteFlags.hxx> + +#include <font/FontSelectPattern.hxx> + +namespace vcl::font +{ +class FontSelectPattern; + +class FontSubstitution +{ + // TODO: there is more commonality between the different substitutions +protected: + virtual ~FontSubstitution() {} +}; + +/// Abstracts the concept of finding the best font to support an incomplete font +class GlyphFallbackFontSubstitution : public FontSubstitution +{ +public: + virtual bool FindFontSubstitute(vcl::font::FontSelectPattern&, + LogicalFontInstance* pLogicalFont, + OUString& rMissingCodes) const = 0; +}; + +/** Abstracts the concept of a configured font substitution before the + availability of the originally selected font has been checked. + */ +class PreMatchFontSubstitution : public FontSubstitution +{ +public: + virtual bool FindFontSubstitute(vcl::font::FontSelectPattern&) const = 0; +}; + +void ImplFontSubstitute(OUString& rFontName); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h deleted file mode 100644 index c6cf81369ee2..000000000000 --- a/vcl/inc/outdev.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <set> -#include <vector> - -#include <tools/gen.hxx> -#include <vcl/vclptr.hxx> - -#include "font/PhysicalFontFace.hxx" -#include "fontinstance.hxx" -#include "impfontcache.hxx" - -class Size; -namespace vcl { class Font; } -namespace vcl::font { class FontSelectPattern; } -class VirtualDevice; -class PhysicalFontCollection; -enum class AddFontSubstituteFlags; - -// nowadays these substitutions are needed for backward compatibility and tight platform integration: -// - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig) -// - device specific substitutions (e.g. for PS printer builtin fonts) -// - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks) -// - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB") -// - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks) -// - substitutions for missing symbol fonts by translating code points into other symbol fonts - -class ImplFontSubstitution -{ - // TODO: there is more commonality between the different substitutions -protected: - virtual ~ImplFontSubstitution() {} -}; - -// ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions -// The class is just a simple port of the unmaintainable manual-linked-list based mechanism -// TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good - -struct ImplFontSubstEntry -{ - OUString maSearchName; - OUString maSearchReplaceName; - AddFontSubstituteFlags mnFlags; - - ImplFontSubstEntry( const OUString& rFontName, const OUString& rSubstFontName, AddFontSubstituteFlags nSubstFlags ); -}; - -class ImplDirectFontSubstitution final -: public ImplFontSubstitution -{ -private: - std::vector<ImplFontSubstEntry> maFontSubstList; -public: - void AddFontSubstitute( const OUString& rFontName, const OUString& rSubstName, AddFontSubstituteFlags nFlags ); - void RemoveFontsSubstitute(); - - bool FindFontSubstitute( OUString& rSubstName, std::u16string_view rFontName ) const; -}; - -// PreMatchFontSubstitution -// abstracts the concept of a configured font substitution -// before the availability of the originally selected font has been checked -class ImplPreMatchFontSubstitution -: public ImplFontSubstitution -{ -public: - virtual bool FindFontSubstitute(vcl::font::FontSelectPattern&) const = 0; -}; - -// ImplGlyphFallbackFontSubstitution -// abstracts the concept of finding the best font to support an incomplete font -class ImplGlyphFallbackFontSubstitution -: public ImplFontSubstitution -{ -public: - virtual bool FindFontSubstitute(vcl::font::FontSelectPattern&, LogicalFontInstance* pLogicalFont, OUString& rMissingCodes) const = 0; -}; - -namespace vcl { struct ControlLayoutData; } -// #i75163# -namespace basegfx { class B2DHomMatrix; } - -struct ImplOutDevData -{ - VclPtr<VirtualDevice> mpRotateDev; - vcl::ControlLayoutData* mpRecordLayout; - tools::Rectangle maRecordRect; - - // #i75163# - basegfx::B2DHomMatrix* mpViewTransform; - basegfx::B2DHomMatrix* mpInverseViewTransform; -}; - -void ImplFontSubstitute( OUString& rFontName ); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx index 9fea18da7661..afa6ea5c6562 100644 --- a/vcl/inc/pch/precompiled_vcl.hxx +++ b/vcl/inc/pch/precompiled_vcl.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2021-09-21 16:33:04 using: + Generated on 2021-10-06 16:34:16 using: ./bin/update_pch vcl vcl --cutoff=6 --exclude:system --include:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -37,7 +37,6 @@ #include <initializer_list> #include <iomanip> #include <limits> -#include <list> #include <map> #include <math.h> #include <memory> @@ -257,6 +256,7 @@ #include <uno/sequence2.h> #include <unotools/calendarwrapper.hxx> #include <unotools/configmgr.hxx> +#include <unotools/fontdefs.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/resmgr.hxx> #include <unotools/syslocale.hxx> @@ -264,14 +264,15 @@ #include <unotools/unotoolsdllapi.h> #endif // PCH_LEVEL >= 3 #if PCH_LEVEL >= 4 +#include <ImplOutDevData.hxx> #include <PhysicalFontCollection.hxx> #include <accel.hxx> #include <brdwin.hxx> #include <configsettings.hxx> #include <drawmode.hxx> #include <fontattributes.hxx> +#include <impfontcache.hxx> #include <impglyphitem.hxx> -#include <outdev.h> #include <salbmp.hxx> #include <salframe.hxx> #include <salgdi.hxx> diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 628f5d098622..1995df30ba95 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -52,7 +52,7 @@ struct ImplPostEventData; struct ImplTimerData; struct ImplIdleData; struct ImplConfigData; -class ImplDirectFontSubstitution; +namespace vcl::font { class DirectFontSubstitution; } struct ImplHotKey; struct ImplEventHook; class Point; @@ -224,7 +224,7 @@ struct ImplSVGDIData std::shared_ptr<PhysicalFontCollection> mxScreenFontList; // Screen-Font-List std::shared_ptr<ImplFontCache> mxScreenFontCache; // Screen-Font-Cache lru_scale_cache maScaleCache = lru_scale_cache(10); // Cache for scaled images - ImplDirectFontSubstitution* mpDirectFontSubst = nullptr; // Font-Substitutions defined in Tools->Options->Fonts + vcl::font::DirectFontSubstitution* mpDirectFontSubst = nullptr; // Font-Substitutions defined in Tools->Options->Fonts std::unique_ptr<GraphicConverter> mxGrfConverter; // Converter for graphics tools::Long mnAppFontX = 0; // AppFont X-Numenator for 40/tel Width tools::Long mnAppFontY = 0; // AppFont Y-Numenator for 80/tel Height diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index ab67e851612a..9fed99165cf9 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -43,7 +43,7 @@ #include <impfont.hxx> #include <impfontcharmap.hxx> #include <impfontmetricdata.hxx> -#include <outdev.h> +#include <font/fontsubstitution.hxx> #include <PhysicalFontCollection.hxx> #ifdef MACOSX @@ -67,7 +67,7 @@ using namespace vcl; namespace { class CoreTextGlyphFallbackSubstititution -: public ImplGlyphFallbackFontSubstitution +: public vcl::font::GlyphFallbackFontSubstitution { public: bool FindFontSubstitute(vcl::font::FontSelectPattern&, LogicalFontInstance* pLogicalFont, OUString&) const override; diff --git a/vcl/source/font/DirectFontSubstitution.cxx b/vcl/source/font/DirectFontSubstitution.cxx new file mode 100644 index 000000000000..e494fb7ce794 --- /dev/null +++ b/vcl/source/font/DirectFontSubstitution.cxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <unotools/fontdefs.hxx> + +#include <font/DirectFontSubstitution.hxx> + +#include <svdata.hxx> + +#include <string> +#include <vector> + +namespace vcl::font +{ +void DirectFontSubstitution::AddFontSubstitute(const OUString& rFontName, + const OUString& rSubstFontName, + AddFontSubstituteFlags nFlags) +{ + maFontSubstList.emplace_back(rFontName, rSubstFontName, nFlags); +} + +void DirectFontSubstitution::RemoveFontsSubstitute() { maFontSubstList.clear(); } + +bool DirectFontSubstitution::FindFontSubstitute(OUString& rSubstName, + std::u16string_view rSearchName) const +{ + // TODO: get rid of O(N) searches + std::vector<FontSubstEntry>::const_iterator it = std::find_if( + maFontSubstList.begin(), maFontSubstList.end(), [&](const FontSubstEntry& s) { + return (s.mnFlags & AddFontSubstituteFlags::ALWAYS) && (s.maSearchName == rSearchName); + }); + if (it != maFontSubstList.end()) + { + rSubstName = it->maSearchReplaceName; + return true; + } + return false; +} + +void ImplFontSubstitute(OUString& rFontName) +{ + // must be canonicalised + assert(GetEnglishSearchFontName(rFontName) == rFontName); + OUString aSubstFontName; + // apply user-configurable font replacement (eg, from the list in Tools->Options) + const DirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; + if (pSubst && pSubst->FindFontSubstitute(aSubstFontName, rFontName)) + { + rFontName = aSubstFontName; + return; + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 42dc11d303e2..c78055075206 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -26,9 +26,10 @@ #include <unotools/configmgr.hxx> #include <unotools/fontdefs.hxx> #include <o3tl/sorted_vector.hxx> -#include <outdev.h> + #include <font/PhysicalFontFaceCollection.hxx> #include <PhysicalFontCollection.hxx> +#include <font/fontsubstitution.hxx> static ImplFontAttrs lcl_IsCJKFont( const OUString& rFontName ) { @@ -76,12 +77,12 @@ PhysicalFontCollection::~PhysicalFontCollection() Clear(); } -void PhysicalFontCollection::SetPreMatchHook( ImplPreMatchFontSubstitution* pHook ) +void PhysicalFontCollection::SetPreMatchHook( vcl::font::PreMatchFontSubstitution* pHook ) { mpPreMatchHook = pHook; } -void PhysicalFontCollection::SetFallbackHook( ImplGlyphFallbackFontSubstitution* pHook ) +void PhysicalFontCollection::SetFallbackHook( vcl::font::GlyphFallbackFontSubstitution* pHook ) { mpFallbackHook = pHook; } @@ -967,7 +968,7 @@ vcl::font::PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( vcl::font } aSearchName = GetEnglishSearchFontName( aSearchName ); - ImplFontSubstitute( aSearchName ); + vcl::font::ImplFontSubstitute(aSearchName); // #114999# special emboldening for Ricoh fonts // TODO: smarter check for special cases by using PreMatch infrastructure? if( (rFSD.GetWeight() > WEIGHT_MEDIUM) && @@ -1064,7 +1065,7 @@ vcl::font::PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( vcl::font { aSearchName = GetEnglishSearchFontName( aSearchName ); } - ImplFontSubstitute( aSearchName ); + vcl::font::ImplFontSubstitute( aSearchName ); vcl::font::PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchName ); if( pFoundData ) return pFoundData; diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx index 798b36b45ebc..31d19e6da55a 100644 --- a/vcl/source/font/PhysicalFontFamily.cxx +++ b/vcl/source/font/PhysicalFontFamily.cxx @@ -22,7 +22,6 @@ #include <rtl/ustring.hxx> #include <unotools/fontdefs.hxx> -#include <outdev.h> #include <font/PhysicalFontFaceCollection.hxx> #include <PhysicalFontCollection.hxx> diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx index 03c80ccb885b..b699a33de11f 100644 --- a/vcl/source/gdi/embeddedfontshelper.cxx +++ b/vcl/source/gdi/embeddedfontshelper.cxx @@ -20,7 +20,6 @@ #include <vcl/embeddedfontshelper.hxx> #include <com/sun/star/io/XInputStream.hpp> -#include <outdev.h> #include <font/PhysicalFontFaceCollection.hxx> #include <PhysicalFontCollection.hxx> #include <salgdi.hxx> diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index f9f25c110917..864755c9ae96 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -32,10 +32,12 @@ #include <vcl/printer/Options.hxx> #include <jobset.h> -#include <outdev.h> #include <print.h> +#include <ImplOutDevData.hxx> #include <PhysicalFontCollection.hxx> #include <font/PhysicalFontFaceCollection.hxx> +#include <font/fontsubstitution.hxx> +#include <impfontcache.hxx> #include <print.hrc> #include <salgdi.hxx> #include <salinst.hxx> diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 9a40f04e2725..ea6e97a73ed1 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -25,9 +25,10 @@ #include <vcl/pdfextoutdevdata.hxx> #include <vcl/virdev.hxx> -#include <outdev.h> +#include <ImplOutDevData.hxx> #include <font/PhysicalFontFaceCollection.hxx> #include <PhysicalFontCollection.hxx> +#include <impfontcache.hxx> #include <salinst.hxx> #include <salgdi.hxx> #include <salvd.hxx> diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 4587974bef76..435b554f411b 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -34,13 +34,14 @@ #include <vcl/sysdata.hxx> #include <vcl/virdev.hxx> -#include <outdev.h> #include <window.h> #include <ImplLayoutArgs.hxx> +#include <drawmode.hxx> +#include <impfontcache.hxx> +#include <font/DirectFontSubstitution.hxx> #include <font/PhysicalFontFaceCollection.hxx> #include <PhysicalFontCollection.hxx> -#include <drawmode.hxx> #include <font/FeatureCollector.hxx> #include <impglyphitem.hxx> #include <sallayout.hxx> @@ -591,71 +592,20 @@ void OutputDevice::AddFontSubstitute( const OUString& rFontName, const OUString& rReplaceFontName, AddFontSubstituteFlags nFlags ) { - ImplDirectFontSubstitution*& rpSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; + vcl::font::DirectFontSubstitution*& rpSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; if( !rpSubst ) - rpSubst = new ImplDirectFontSubstitution; + rpSubst = new vcl::font::DirectFontSubstitution; rpSubst->AddFontSubstitute( rFontName, rReplaceFontName, nFlags ); ImplGetSVData()->maGDIData.mbFontSubChanged = true; } -void ImplDirectFontSubstitution::AddFontSubstitute( const OUString& rFontName, - const OUString& rSubstFontName, AddFontSubstituteFlags nFlags ) -{ - maFontSubstList.emplace_back( rFontName, rSubstFontName, nFlags ); -} - -ImplFontSubstEntry::ImplFontSubstEntry( const OUString& rFontName, - const OUString& rSubstFontName, AddFontSubstituteFlags nSubstFlags ) -: mnFlags( nSubstFlags ) -{ - maSearchName = GetEnglishSearchFontName( rFontName ); - maSearchReplaceName = GetEnglishSearchFontName( rSubstFontName ); -} - void OutputDevice::RemoveFontsSubstitute() { - ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; + vcl::font::DirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; if( pSubst ) pSubst->RemoveFontsSubstitute(); } -void ImplDirectFontSubstitution::RemoveFontsSubstitute() -{ - maFontSubstList.clear(); -} - -bool ImplDirectFontSubstitution::FindFontSubstitute( OUString& rSubstName, - std::u16string_view rSearchName ) const -{ - // TODO: get rid of O(N) searches - std::vector<ImplFontSubstEntry>::const_iterator it = std::find_if ( - maFontSubstList.begin(), maFontSubstList.end(), - [&] (const ImplFontSubstEntry& s) { return (s.mnFlags & AddFontSubstituteFlags::ALWAYS) - && (s.maSearchName == rSearchName); } ); - if (it != maFontSubstList.end()) - { - rSubstName = it->maSearchReplaceName; - return true; - } - return false; -} - -void ImplFontSubstitute( OUString& rFontName ) -{ - // must be canonicalised - assert( GetEnglishSearchFontName( rFontName ) == rFontName ); - - OUString aSubstFontName; - - // apply user-configurable font replacement (eg, from the list in Tools->Options) - const ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; - if( pSubst && pSubst->FindFontSubstitute( aSubstFontName, rFontName ) ) - { - rFontName = aSubstFontName; - return; - } -} - //hidpi TODO: This routine has hard-coded font-sizes that break places such as DialControl vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice* pOutDev ) diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 394a46d726e5..112fd5322557 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -30,9 +30,9 @@ #include <sal/log.hxx> #include <osl/diagnose.h> +#include <ImplOutDevData.hxx> #include <svdata.hxx> #include <window.h> -#include <outdev.h> #include <basegfx/matrix/b2dhommatrix.hxx> #include <tools/UnitConversion.hxx> diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 7cb123bea790..78c4ff97d3bf 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -32,10 +32,10 @@ #include <vcl/lazydelete.hxx> #include <comphelper/processfactory.hxx> +#include <ImplOutDevData.hxx> #include <font/PhysicalFontFaceCollection.hxx> #include <salgdi.hxx> #include <window.h> -#include <outdev.h> #include <com/sun/star/awt/DeviceCapability.hpp> #include <com/sun/star/awt/XWindow.hpp> diff --git a/vcl/source/outdev/stack.cxx b/vcl/source/outdev/stack.cxx index 23c9f92c1c8b..e11947de5b14 100644 --- a/vcl/source/outdev/stack.cxx +++ b/vcl/source/outdev/stack.cxx @@ -27,7 +27,6 @@ #include <vcl/virdev.hxx> #include <vcl/settings.hxx> -#include <outdev.h> #include <drawmode.hxx> #include <salgdi.hxx> diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 50ee3ce917f0..0b37b8fc743f 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -42,8 +42,8 @@ #include <vcl/unohelp.hxx> #include <config_fuzzers.h> -#include <outdev.h> #include <ImplLayoutArgs.hxx> +#include <ImplOutDevData.hxx> #include <drawmode.hxx> #include <salgdi.hxx> #include <svdata.hxx> diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index f5cf9b855103..61eea6837924 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -47,6 +47,8 @@ #include <vcl/uitest/uiobject.hxx> +#include <ImplOutDevData.hxx> +#include <impfontcache.hxx> #include <salframe.hxx> #include <salobj.hxx> #include <salinst.hxx> @@ -54,7 +56,6 @@ #include <svdata.hxx> #include <window.h> #include <toolbox.h> -#include <outdev.h> #include <brdwin.hxx> #include <helpwin.hxx> diff --git a/vcl/unx/generic/fontmanager/fontsubst.cxx b/vcl/unx/generic/fontmanager/fontsubst.cxx index 9559a252b089..7945da6179c4 100644 --- a/vcl/unx/generic/fontmanager/fontsubst.cxx +++ b/vcl/unx/generic/fontmanager/fontsubst.cxx @@ -20,7 +20,7 @@ #include <sal/config.h> #include <unx/geninst.h> -#include <outdev.h> +#include <font/fontsubstitution.hxx> #include <unx/fontmanager.hxx> #include <PhysicalFontCollection.hxx> @@ -29,7 +29,7 @@ namespace { class FcPreMatchSubstitution -: public ImplPreMatchFontSubstitution +: public vcl::font::PreMatchFontSubstitution { public: bool FindFontSubstitute( vcl::font::FontSelectPattern& ) const override; @@ -40,7 +40,7 @@ private: }; class FcGlyphFallbackSubstitution -: public ImplGlyphFallbackFontSubstitution +: public vcl::font::GlyphFallbackFontSubstitution { // TODO: add a cache public: diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index 0940b4005af6..177f1e7c3384 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -21,7 +21,7 @@ #include <win/salgdi.h> #include <win/saldata.hxx> -#include <outdev.h> +#include <ImplOutDevData.hxx> #include <win/DWriteTextRenderer.hxx> diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 842f5ed8830f..522793f68580 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -53,10 +53,10 @@ #include <font/FontSelectPattern.hxx> #include <fontsubset.hxx> -#include <outdev.h> #include <font/PhysicalFontFaceCollection.hxx> #include <PhysicalFontCollection.hxx> #include <font/PhysicalFontFace.hxx> +#include <font/fontsubstitution.hxx> #include <sft.hxx> #include <win/saldata.hxx> #include <win/salgdi.h> @@ -158,14 +158,14 @@ RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) namespace { class WinPreMatchFontSubstititution -: public ImplPreMatchFontSubstitution +: public vcl::font::PreMatchFontSubstitution { public: bool FindFontSubstitute(vcl::font::FontSelectPattern&) const override; }; class WinGlyphFallbackSubstititution -: public ImplGlyphFallbackFontSubstitution +: public vcl::font::GlyphFallbackFontSubstitution { public: explicit WinGlyphFallbackSubstititution() diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 0db736c256c0..68ee4aa45865 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -1,4 +1,3 @@ - /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. @@ -34,7 +33,7 @@ #include <win/salgdi.h> #include <win/saldata.hxx> #include <win/wingdiimpl.hxx> -#include <outdev.h> +#include <ImplOutDevData.hxx> #include <win/DWriteTextRenderer.hxx> #include <win/scoped_gdi.hxx> |