diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-09-10 22:22:07 +1000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-19 12:11:53 +0200 |
commit | 9e7715dbc4e3c09d9be8a6f3c5ca0e4910651fec (patch) | |
tree | a760fef9057b93ae5fa906e80437c66d0e3e3a53 | |
parent | a6bccaf72f69428bffd6688917491ef921383456 (diff) |
vcl: test PhysicalFontFamily and move to vcl::font namespace
- Adds a series of unit tests for PhysicalFontFamily
- Moves PhysicalFontFamily into vcl::font
- Move PhysicalFontFamily.hxx into vcl/inc/font
This is part of a series of patches where I also move font files into
the relevant font directories, and into the vcl::font namespace.
Change-Id: I9e8d7ceb5ec3494bf3ab6560645e52e88223ee69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121903
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | vcl/CppunitTest_vcl_font.mk | 1 | ||||
-rw-r--r-- | vcl/inc/PhysicalFontCollection.hxx | 25 | ||||
-rw-r--r-- | vcl/inc/PhysicalFontFace.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/PhysicalFontFamily.hxx | 103 | ||||
-rw-r--r-- | vcl/inc/font/PhysicalFontFamily.hxx | 111 | ||||
-rw-r--r-- | vcl/inc/sallayout.hxx | 3 | ||||
-rw-r--r-- | vcl/qa/cppunit/fontmocks.hxx | 64 | ||||
-rw-r--r-- | vcl/qa/cppunit/physicalfontfacecollection.cxx | 49 | ||||
-rw-r--r-- | vcl/qa/cppunit/physicalfontfamily.cxx | 153 | ||||
-rw-r--r-- | vcl/source/font/PhysicalFontCollection.cxx | 96 | ||||
-rw-r--r-- | vcl/source/font/PhysicalFontFamily.cxx | 4 | ||||
-rw-r--r-- | vcl/source/font/fontcache.cxx | 12 | ||||
-rw-r--r-- | vcl/source/gdi/pdffontcache.cxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 4 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 4 |
15 files changed, 411 insertions, 223 deletions
diff --git a/vcl/CppunitTest_vcl_font.mk b/vcl/CppunitTest_vcl_font.mk index 55a850e044a6..456468557056 100644 --- a/vcl/CppunitTest_vcl_font.mk +++ b/vcl/CppunitTest_vcl_font.mk @@ -17,6 +17,7 @@ $(eval $(call gb_CppunitTest_set_include,vcl_font,\ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_font, \ vcl/qa/cppunit/font \ vcl/qa/cppunit/physicalfontfacecollection \ + vcl/qa/cppunit/physicalfontfamily \ )) $(eval $(call gb_CppunitTest_use_externals,vcl_font,\ diff --git a/vcl/inc/PhysicalFontCollection.hxx b/vcl/inc/PhysicalFontCollection.hxx index c3ccdb69d438..e1a819354e8d 100644 --- a/vcl/inc/PhysicalFontCollection.hxx +++ b/vcl/inc/PhysicalFontCollection.hxx @@ -24,7 +24,7 @@ #include <vcl/dllapi.h> #include "fontinstance.hxx" -#include "PhysicalFontFamily.hxx" +#include "font/PhysicalFontFamily.hxx" #include <array> #define MAX_GLYPHFALLBACK 16 @@ -33,7 +33,6 @@ class ImplDeviceFontSizeList; class ImplGlyphFallbackFontSubstitution; class ImplPreMatchFontSubstitution; - // TODO: merge with ImplFontCache // TODO: rename to LogicalFontManager @@ -49,15 +48,15 @@ public: int Count() const { return maPhysicalFontFamilies.size(); } // find the device font family - PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const; - PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName ); - PhysicalFontFamily* FindFontFamily( FontSelectPattern& ) const; - PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const; - PhysicalFontFamily* FindFontFamilyByAttributes(ImplFontAttrs nSearchType, FontWeight, FontWidth, + vcl::font::PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const; + vcl::font::PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName ); + vcl::font::PhysicalFontFamily* FindFontFamily( FontSelectPattern& ) const; + vcl::font::PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const; + vcl::font::PhysicalFontFamily* FindFontFamilyByAttributes(ImplFontAttrs nSearchType, FontWeight, FontWidth, FontItalic, const OUString& rSearchFamily) const; // suggest fonts for glyph fallback - PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&, + vcl::font::PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&, LogicalFontInstance* pLogicalFont, OUString& rMissingCodes, int nFallbackLevel ) const; @@ -73,22 +72,22 @@ public: private: mutable bool mbMatchData; // true if matching attributes are initialized - typedef std::unordered_map<OUString, std::unique_ptr<PhysicalFontFamily>> PhysicalFontFamilies; + 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 - mutable std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList; + mutable std::unique_ptr<std::array<vcl::font::PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList; mutable int mnFallbackCount; void ImplInitMatchData() const; void ImplInitGenericGlyphFallback() const; - PhysicalFontFamily* ImplFindFontFamilyBySearchName( const OUString& ) const; - PhysicalFontFamily* ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& ) const; + vcl::font::PhysicalFontFamily* ImplFindFontFamilyBySearchName( const OUString& ) const; + vcl::font::PhysicalFontFamily* ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& ) const; - PhysicalFontFamily* ImplFindFontFamilyOfDefaultFont() const; + vcl::font::PhysicalFontFamily* ImplFindFontFamilyOfDefaultFont() const; }; diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx index 66bf62c5b90c..a4d032f6160a 100644 --- a/vcl/inc/PhysicalFontFace.hxx +++ b/vcl/inc/PhysicalFontFace.hxx @@ -33,11 +33,12 @@ class LogicalFontInstance; struct FontMatchStatus; class FontSelectPattern; -class PhysicalFontFamily; +class PhysicalFontFace; namespace vcl { struct FontCapabilities; +class PhysicalFontFamily; } struct FontMatchStatus diff --git a/vcl/inc/PhysicalFontFamily.hxx b/vcl/inc/PhysicalFontFamily.hxx deleted file mode 100644 index 77f0938ebead..000000000000 --- a/vcl/inc/PhysicalFontFamily.hxx +++ /dev/null @@ -1,103 +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 <sal/config.h> - -#include <vcl/dllapi.h> -#include <vcl/outdev.hxx> - -#include <o3tl/sorted_vector.hxx> - -#include <unotools/fontcfg.hxx> - -#include "PhysicalFontFace.hxx" - -namespace vcl::font -{ -class PhysicalFontFaceCollection; -} -class PhysicalFontFace; -class PhysicalFontCollection; - -// flags for mnTypeFaces member -enum class FontTypeFaces { - NONE = 0x00, - Scalable = 0x01, - Symbol = 0x02, - NoneSymbol = 0x04, - Light = 0x08, - Bold = 0x10, - Normal = 0x20, - NoneItalic = 0x40, - Italic = 0x80 -}; -namespace o3tl { - template<> struct typed_flags<FontTypeFaces> : is_typed_flags<FontTypeFaces, 0xff> {}; -}; - -class VCL_PLUGIN_PUBLIC PhysicalFontFamily -{ -public: - PhysicalFontFamily( const OUString& rSearchName ); - ~PhysicalFontFamily(); - - const OUString& GetFamilyName() const { return maFamilyName; } - const OUString& GetSearchName() const { return maSearchName; } - const OUString& GetAliasNames() const { return maMapNames; } - int GetMinQuality() const { return mnMinQuality; } - FontTypeFaces GetTypeFaces() const { return mnTypeFaces; } - void GetFontHeights( o3tl::sorted_vector<int>& rHeights ) const; - - const OUString& GetMatchFamilyName() const { return maMatchFamilyName; } - ImplFontAttrs GetMatchType() const { return mnMatchType ; } - FontWeight GetMatchWeight() const { return meMatchWeight ; } - FontWidth GetMatchWidth() const { return meMatchWidth ; } - void InitMatchData( const utl::FontSubstConfiguration&, - const OUString& rSearchName ); - - void AddFontFace( PhysicalFontFace* ); - - PhysicalFontFace* FindBestFontFace( const FontSelectPattern& rFSD ) const; - - void UpdateDevFontList(vcl::font::PhysicalFontFaceCollection&) const; - void UpdateCloneFontList(PhysicalFontCollection&) const; - -static void CalcType( ImplFontAttrs& rType, FontWeight& rWeight, FontWidth& rWidth, - FontFamily eFamily, const utl::FontNameAttr* pFontAttr ); - -private: - std::vector< rtl::Reference<PhysicalFontFace> > maFontFaces; - - OUString maFamilyName; // original font family name - OUString maSearchName; // normalized font family name - OUString maMapNames; // fontname aliases - FontTypeFaces mnTypeFaces; // Typeface Flags - FontFamily meFamily; - FontPitch mePitch; - int mnMinQuality; // quality of the worst font face - - ImplFontAttrs mnMatchType; // MATCH - Type - OUString maMatchFamilyName; // MATCH - FamilyName - FontWeight meMatchWeight; // MATCH - Weight - FontWidth meMatchWidth; // MATCH - Width -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/font/PhysicalFontFamily.hxx b/vcl/inc/font/PhysicalFontFamily.hxx new file mode 100644 index 000000000000..1a8fe0160f8e --- /dev/null +++ b/vcl/inc/font/PhysicalFontFamily.hxx @@ -0,0 +1,111 @@ +/* -*- 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 <sal/config.h> + +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> + +#include <o3tl/sorted_vector.hxx> + +#include <unotools/fontcfg.hxx> + +#include <PhysicalFontFace.hxx> + +class PhysicalFontFace; +class PhysicalFontCollection; + +namespace vcl::font +{ +// flags for mnTypeFaces member +enum class FontTypeFaces +{ + NONE = 0x00, + Scalable = 0x01, + Symbol = 0x02, + NoneSymbol = 0x04, + Light = 0x08, + Bold = 0x10, + Normal = 0x20, + NoneItalic = 0x40, + Italic = 0x80 +}; +} +namespace o3tl +{ +template <> +struct typed_flags<vcl::font::FontTypeFaces> : is_typed_flags<vcl::font::FontTypeFaces, 0xff> +{ +}; +}; + +namespace vcl::font +{ +class PhysicalFontFaceCollection; + +class VCL_PLUGIN_PUBLIC PhysicalFontFamily +{ +public: + PhysicalFontFamily(const OUString& rSearchName); + ~PhysicalFontFamily(); + + const OUString& GetFamilyName() const { return maFamilyName; } + const OUString& GetSearchName() const { return maSearchName; } + const OUString& GetAliasNames() const { return maMapNames; } + int GetMinQuality() const { return mnMinQuality; } + FontTypeFaces GetTypeFaces() const { return mnTypeFaces; } + void GetFontHeights(o3tl::sorted_vector<int>& rHeights) const; + + const OUString& GetMatchFamilyName() const { return maMatchFamilyName; } + ImplFontAttrs GetMatchType() const { return mnMatchType; } + FontWeight GetMatchWeight() const { return meMatchWeight; } + FontWidth GetMatchWidth() const { return meMatchWidth; } + void InitMatchData(const utl::FontSubstConfiguration&, const OUString& rSearchName); + + void AddFontFace(PhysicalFontFace*); + + PhysicalFontFace* FindBestFontFace(const FontSelectPattern& rFSD) const; + + void UpdateDevFontList(PhysicalFontFaceCollection&) const; + void UpdateCloneFontList(PhysicalFontCollection&) const; + + static void CalcType(ImplFontAttrs& rType, FontWeight& rWeight, FontWidth& rWidth, + FontFamily eFamily, const utl::FontNameAttr* pFontAttr); + +private: + std::vector<rtl::Reference<PhysicalFontFace>> maFontFaces; + + OUString maFamilyName; // original font family name + OUString maSearchName; // normalized font family name + OUString maMapNames; // fontname aliases + FontTypeFaces mnTypeFaces; // Typeface Flags + FontFamily meFamily; + FontPitch mePitch; + int mnMinQuality; // quality of the worst font face + + ImplFontAttrs mnMatchType; // MATCH - Type + OUString maMatchFamilyName; // MATCH - FamilyName + FontWeight meMatchWeight; // MATCH - Weight + FontWidth meMatchWidth; // MATCH - Width +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 060fcbb1be77..a3b33b6b3bc1 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -45,10 +45,9 @@ #define MAX_FALLBACK 16 - -class SalGraphics; class PhysicalFontFace; class GenericSalLayout; +class SalGraphics; enum class SalLayoutFlags; namespace vcl::text { class TextLayoutCache; diff --git a/vcl/qa/cppunit/fontmocks.hxx b/vcl/qa/cppunit/fontmocks.hxx new file mode 100644 index 000000000000..703f03957de6 --- /dev/null +++ b/vcl/qa/cppunit/fontmocks.hxx @@ -0,0 +1,64 @@ +/* -*- 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/. + */ + +#include <sal/config.h> + +#include <PhysicalFontFace.hxx> +#include <font/PhysicalFontFaceCollection.hxx> +#include <fontattributes.hxx> +#include <fontinstance.hxx> +#include <fontselect.hxx> + +class TestFontInstance : public LogicalFontInstance +{ +public: + TestFontInstance(PhysicalFontFace const& rFontFace, FontSelectPattern const& rFontSelectPattern) + : LogicalFontInstance(rFontFace, rFontSelectPattern) + { + } + + bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override + { + return true; + } + +protected: + bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override { return true; } +}; + +class TestFontFace : public PhysicalFontFace +{ +public: + TestFontFace(sal_uIntPtr nId) + : PhysicalFontFace(FontAttributes()) + , mnFontId(nId) + { + } + + TestFontFace(FontAttributes const& rFontAttributes, sal_uIntPtr nId) + : PhysicalFontFace(rFontAttributes) + , mnFontId(nId) + { + } + + rtl::Reference<LogicalFontInstance> + CreateFontInstance(FontSelectPattern const& rFontSelectPattern) const override + { + return new TestFontInstance(*this, rFontSelectPattern); + } + + sal_IntPtr GetFontId() const override { return mnFontId; } + FontCharMapRef GetFontCharMap() const override { return FontCharMap::GetDefaultMap(false); } + bool GetFontCapabilities(vcl::FontCapabilities&) const override { return true; } + +private: + sal_IntPtr mnFontId; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qa/cppunit/physicalfontfacecollection.cxx b/vcl/qa/cppunit/physicalfontfacecollection.cxx index 829729c3a185..56f44d2b39b9 100644 --- a/vcl/qa/cppunit/physicalfontfacecollection.cxx +++ b/vcl/qa/cppunit/physicalfontfacecollection.cxx @@ -20,11 +20,7 @@ #include <vcl/glyphitem.hxx> #include <vcl/virdev.hxx> -#include <PhysicalFontFace.hxx> -#include <font/PhysicalFontFaceCollection.hxx> -#include <fontattributes.hxx> -#include <fontinstance.hxx> -#include <fontselect.hxx> +#include "fontmocks.hxx" class VclPhysicalFontFaceCollectionTest : public test::BootstrapFixture { @@ -41,49 +37,6 @@ public: CPPUNIT_TEST_SUITE_END(); }; -namespace -{ -class TestFontInstance : public LogicalFontInstance -{ -public: - TestFontInstance(PhysicalFontFace const& rFontFace, FontSelectPattern const& rFontSelectPattern) - : LogicalFontInstance(rFontFace, rFontSelectPattern) - { - } - - bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override - { - return true; - } - -protected: - bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override { return true; } -}; - -class TestFontFace : public PhysicalFontFace -{ -public: - TestFontFace(sal_uIntPtr nId) - : PhysicalFontFace(FontAttributes()) - , mnFontId(nId) - { - } - - rtl::Reference<LogicalFontInstance> - CreateFontInstance(FontSelectPattern const& rFontSelectPattern) const override - { - return new TestFontInstance(*this, rFontSelectPattern); - } - - sal_IntPtr GetFontId() const override { return mnFontId; } - FontCharMapRef GetFontCharMap() const override { return FontCharMap::GetDefaultMap(false); } - bool GetFontCapabilities(vcl::FontCapabilities&) const override { return true; } - -private: - sal_IntPtr mnFontId; -}; -} - void VclPhysicalFontFaceCollectionTest::testShouldGetFontId() { vcl::font::PhysicalFontFaceCollection aCollection; diff --git a/vcl/qa/cppunit/physicalfontfamily.cxx b/vcl/qa/cppunit/physicalfontfamily.cxx new file mode 100644 index 000000000000..b90ee4ec0e71 --- /dev/null +++ b/vcl/qa/cppunit/physicalfontfamily.cxx @@ -0,0 +1,153 @@ +/* -*- 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/. + */ + +#include <sal/config.h> + +#include <test/bootstrapfixture.hxx> +#include <cppunit/TestAssert.h> + +#include <tools/fontenum.hxx> +#include <unotools/fontcfg.hxx> +#include <o3tl/sorted_vector.hxx> + +#include <vcl/virdev.hxx> + +#include <font/PhysicalFontFamily.hxx> + +#include "fontmocks.hxx" + +using namespace vcl::font; + +class VclPhysicalFontFamilyTest : public test::BootstrapFixture +{ +public: + VclPhysicalFontFamilyTest() + : BootstrapFixture(true, false) + { + } + + void testCreateFontFamily(); + void testAddFontFace_Default(); + void testAddOneFontFace(); + void testAddTwoFontFaces(); + + CPPUNIT_TEST_SUITE(VclPhysicalFontFamilyTest); + CPPUNIT_TEST(testCreateFontFamily); + CPPUNIT_TEST(testAddFontFace_Default); + CPPUNIT_TEST(testAddOneFontFace); + CPPUNIT_TEST(testAddTwoFontFaces); + CPPUNIT_TEST_SUITE_END(); +}; + +void VclPhysicalFontFamilyTest::testCreateFontFamily() +{ + PhysicalFontFamily aFamily("Test font face"); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Family name", OUString(""), aFamily.GetFamilyName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Search name", OUString("Test font face"), + aFamily.GetSearchName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alias names", OUString(""), aFamily.GetAliasNames()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Min quality", -1, aFamily.GetMinQuality()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Type faces", FontTypeFaces::NONE, aFamily.GetTypeFaces()); + + o3tl::sorted_vector<int> aHeights; + aFamily.GetFontHeights(aHeights); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Number font heights", static_cast<size_t>(0), aHeights.size()); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Match family name", OUString(""), aFamily.GetMatchFamilyName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Match type", ImplFontAttrs::None, aFamily.GetMatchType()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Match weight", WEIGHT_DONTKNOW, aFamily.GetMatchWeight()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Match width", WIDTH_DONTKNOW, aFamily.GetMatchWidth()); +} + +void VclPhysicalFontFamilyTest::testAddFontFace_Default() +{ + PhysicalFontFamily aFamily("Test font face"); + + aFamily.AddFontFace(new TestFontFace(1)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Family name", OUString(""), aFamily.GetFamilyName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Search name", OUString("Test font face"), + aFamily.GetSearchName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alias names", OUString(""), aFamily.GetAliasNames()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Min quality", 0, aFamily.GetMinQuality()); + FontTypeFaces eTypeFace + = FontTypeFaces::Scalable | FontTypeFaces::NoneSymbol | FontTypeFaces::NoneItalic; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Type faces", eTypeFace, aFamily.GetTypeFaces()); +} + +void VclPhysicalFontFamilyTest::testAddOneFontFace() +{ + PhysicalFontFamily aFamily("Test font face"); + + FontAttributes aFontAttrs; + aFontAttrs.SetFamilyName("Test font face"); + aFontAttrs.AddMapName("Alias name"); + aFontAttrs.SetFamilyType(FontFamily::FAMILY_ROMAN); + aFontAttrs.SetPitch(FontPitch::PITCH_VARIABLE); + aFontAttrs.SetItalic(FontItalic::ITALIC_NONE); + aFontAttrs.SetQuality(10); + aFontAttrs.SetWeight(FontWeight::WEIGHT_BOLD); + aFontAttrs.SetWidthType(FontWidth::WIDTH_EXPANDED); + + aFamily.AddFontFace(new TestFontFace(aFontAttrs, 1)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Family name", OUString("Test font face"), + aFamily.GetFamilyName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Search name", OUString("Test font face"), + aFamily.GetSearchName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alias names", OUString("Alias name"), aFamily.GetAliasNames()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Min quality", 10, aFamily.GetMinQuality()); + FontTypeFaces eTypeFace = FontTypeFaces::Scalable | FontTypeFaces::NoneSymbol + | FontTypeFaces::Bold | FontTypeFaces::NoneItalic; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Type faces", eTypeFace, aFamily.GetTypeFaces()); +} + +void VclPhysicalFontFamilyTest::testAddTwoFontFaces() +{ + PhysicalFontFamily aFamily("Test font face"); + + FontAttributes aFontAttrs; + aFontAttrs.SetFamilyName("Test font face"); + aFontAttrs.AddMapName("Alias name"); + aFontAttrs.SetFamilyType(FontFamily::FAMILY_ROMAN); + aFontAttrs.SetPitch(FontPitch::PITCH_VARIABLE); + aFontAttrs.SetItalic(FontItalic::ITALIC_NONE); + aFontAttrs.SetQuality(10); + aFontAttrs.SetWeight(FontWeight::WEIGHT_THIN); + aFontAttrs.SetWidthType(FontWidth::WIDTH_EXPANDED); + + aFamily.AddFontFace(new TestFontFace(aFontAttrs, 1)); + + aFontAttrs.SetFamilyName("Test font face"); + aFontAttrs.AddMapName("Alias name 2"); + aFontAttrs.SetFamilyType(FontFamily::FAMILY_ROMAN); + aFontAttrs.SetPitch(FontPitch::PITCH_VARIABLE); + aFontAttrs.SetItalic(FontItalic::ITALIC_NORMAL); + aFontAttrs.SetQuality(5); + aFontAttrs.SetWeight(FontWeight::WEIGHT_BOLD); + aFontAttrs.SetWidthType(FontWidth::WIDTH_CONDENSED); + + aFamily.AddFontFace(new TestFontFace(aFontAttrs, 2)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Family name", OUString("Test font face"), + aFamily.GetFamilyName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Search name", OUString("Test font face"), + aFamily.GetSearchName()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alias names", OUString("Alias name"), aFamily.GetAliasNames()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Min quality", 5, aFamily.GetMinQuality()); + FontTypeFaces eTypeFace = FontTypeFaces::Scalable | FontTypeFaces::NoneSymbol + | FontTypeFaces::Light | FontTypeFaces::Bold + | FontTypeFaces::NoneItalic | FontTypeFaces::Italic; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Type faces", eTypeFace, aFamily.GetTypeFaces()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(VclPhysicalFontFamilyTest); + +/* 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 698e3a91c48e..cd557b8db1eb 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -131,7 +131,7 @@ void PhysicalFontCollection::ImplInitGenericGlyphFallback() const bool bHasEudc = false; int nMaxLevel = 0; int nBestQuality = 0; - std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> pFallbackList; + std::unique_ptr<std::array<vcl::font::PhysicalFontFamily*,MAX_GLYPHFALLBACK>> pFallbackList; for( const char** ppNames = &aGlyphFallbackList[0];; ++ppNames ) { @@ -151,7 +151,7 @@ void PhysicalFontCollection::ImplInitGenericGlyphFallback() const // test if the glyph fallback candidate font is available and scalable OUString aTokenName( *ppNames, strlen(*ppNames), RTL_TEXTENCODING_UTF8 ); - PhysicalFontFamily* pFallbackFont = FindFontFamily( aTokenName ); + vcl::font::PhysicalFontFamily* pFallbackFont = FindFontFamily( aTokenName ); if( !pFallbackFont ) continue; @@ -162,7 +162,7 @@ void PhysicalFontCollection::ImplInitGenericGlyphFallback() const nBestQuality = pFallbackFont->GetMinQuality(); // store available glyph fallback fonts if( !pFallbackList ) - pFallbackList.reset(new std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>); + pFallbackList.reset(new std::array<vcl::font::PhysicalFontFamily*,MAX_GLYPHFALLBACK>); (*pFallbackList)[ nMaxLevel ] = pFallbackFont; if( !bHasEudc && !nMaxLevel ) @@ -174,12 +174,12 @@ void PhysicalFontCollection::ImplInitGenericGlyphFallback() const mpFallbackList = std::move(pFallbackList); } -PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPattern& rFontSelData, +vcl::font::PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPattern& rFontSelData, LogicalFontInstance* pFontInstance, OUString& rMissingCodes, int nFallbackLevel ) const { - PhysicalFontFamily* pFallbackData = nullptr; + vcl::font::PhysicalFontFamily* pFallbackData = nullptr; // find a matching font candidate for platform specific glyph fallback if( mpFallbackHook ) @@ -280,13 +280,13 @@ void PhysicalFontCollection::Add( PhysicalFontFace* pNewData ) { OUString aSearchName = GetEnglishSearchFontName( pNewData->GetFamilyName() ); - PhysicalFontFamily* pFoundData = FindOrCreateFontFamily( aSearchName ); + vcl::font::PhysicalFontFamily* pFoundData = FindOrCreateFontFamily( aSearchName ); pFoundData->AddFontFace( pNewData ); } // find the font from the normalized font family name -PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyBySearchName( const OUString& rSearchName ) const +vcl::font::PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyBySearchName( const OUString& rSearchName ) const { // must be called with a normalized name. assert( GetEnglishSearchFontName( rSearchName ) == rSearchName ); @@ -295,35 +295,35 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyBySearchName( cons if( it == maPhysicalFontFamilies.end() ) return nullptr; - PhysicalFontFamily* pFoundData = (*it).second.get(); + vcl::font::PhysicalFontFamily* pFoundData = (*it).second.get(); return pFoundData; } -PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( const OUString& rFontName ) const +vcl::font::PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( const OUString& rFontName ) const { return ImplFindFontFamilyBySearchName( GetEnglishSearchFontName( rFontName ) ); } -PhysicalFontFamily *PhysicalFontCollection::FindOrCreateFontFamily( const OUString &rFamilyName ) +vcl::font::PhysicalFontFamily *PhysicalFontCollection::FindOrCreateFontFamily( const OUString &rFamilyName ) { PhysicalFontFamilies::const_iterator it = maPhysicalFontFamilies.find( rFamilyName ); - PhysicalFontFamily* pFoundData = nullptr; + vcl::font::PhysicalFontFamily* pFoundData = nullptr; if( it != maPhysicalFontFamilies.end() ) pFoundData = (*it).second.get(); if( !pFoundData ) { - pFoundData = new PhysicalFontFamily( rFamilyName ); + pFoundData = new vcl::font::PhysicalFontFamily( rFamilyName ); maPhysicalFontFamilies[ rFamilyName ].reset(pFoundData); } return pFoundData; } -PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByTokenNames(const OUString& rTokenStr) const +vcl::font::PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByTokenNames(const OUString& rTokenStr) const { - PhysicalFontFamily* pFoundData = nullptr; + vcl::font::PhysicalFontFamily* pFoundData = nullptr; // use normalized font name tokens to find the font for( sal_Int32 nTokenPos = 0; nTokenPos != -1; ) @@ -341,9 +341,9 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByTokenNames(const OUS return pFoundData; } -PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& rFontAttr ) const +vcl::font::PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& rFontAttr ) const { - PhysicalFontFamily* pFoundData = nullptr; + vcl::font::PhysicalFontFamily* pFoundData = nullptr; // use the font substitutions suggested by the FontNameAttr to find the font for (auto const& substitution : rFontAttr.Substitutions) @@ -387,13 +387,13 @@ void PhysicalFontCollection::ImplInitMatchData() const for (auto const& family : maPhysicalFontFamilies) { const OUString& rSearchName = family.first; - PhysicalFontFamily* pEntry = family.second.get(); + vcl::font::PhysicalFontFamily* pEntry = family.second.get(); pEntry->InitMatchData( rFontSubst, rSearchName ); } } -PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFontAttrs nSearchType, +vcl::font::PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFontAttrs nSearchType, FontWeight eSearchWeight, FontWidth eSearchWidth, FontItalic eSearchItalic, @@ -409,14 +409,14 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont return nullptr; ImplInitMatchData(); - PhysicalFontFamily* pFoundData = nullptr; + vcl::font::PhysicalFontFamily* pFoundData = nullptr; tools::Long nBestMatch = 40000; ImplFontAttrs nBestType = ImplFontAttrs::None; for (auto const& family : maPhysicalFontFamilies) { - PhysicalFontFamily* pData = family.second.get(); + vcl::font::PhysicalFontFamily* pData = family.second.get(); // Get all information about the matching font ImplFontAttrs nMatchType = pData->GetMatchType(); @@ -497,7 +497,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont { nTestMatch += 10000000*5; } - else if ( pData->GetTypeFaces() & FontTypeFaces::Symbol ) + else if ( pData->GetTypeFaces() & vcl::font::FontTypeFaces::Symbol ) { nTestMatch += 10000000*4; } @@ -509,7 +509,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont nTestMatch += 10000000; } } - else if ( (pData->GetTypeFaces() & (FontTypeFaces::Symbol | FontTypeFaces::NoneSymbol)) == FontTypeFaces::Symbol ) + else if ( (pData->GetTypeFaces() & (vcl::font::FontTypeFaces::Symbol | vcl::font::FontTypeFaces::NoneSymbol)) == vcl::font::FontTypeFaces::Symbol ) { nTestMatch -= 10000000; } @@ -676,14 +676,14 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont // test ITALIC attribute if( nSearchType & ImplFontAttrs::Italic ) { - if( pData->GetTypeFaces() & FontTypeFaces::Italic ) + if( pData->GetTypeFaces() & vcl::font::FontTypeFaces::Italic ) nTestMatch += 1000000*3; if( nMatchType & ImplFontAttrs::Italic ) nTestMatch += 1000000; } else if( !(nSearchType & ImplFontAttrs::AllScript) && ((nMatchType & ImplFontAttrs::Italic) || - !(pData->GetTypeFaces() & FontTypeFaces::NoneItalic)) ) + !(pData->GetTypeFaces() & vcl::font::FontTypeFaces::NoneItalic)) ) { nTestMatch -= 1000000*2; } @@ -718,14 +718,14 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont { if( eSearchWeight < WEIGHT_NORMAL ) { - if( pData->GetTypeFaces() & FontTypeFaces::Light ) + if( pData->GetTypeFaces() & vcl::font::FontTypeFaces::Light ) nTestMatch += 1000000; if( (eMatchWeight < WEIGHT_NORMAL) && (eMatchWeight != WEIGHT_DONTKNOW) ) nTestMatch += 1000000; } else { - if( pData->GetTypeFaces() & FontTypeFaces::Bold ) + if( pData->GetTypeFaces() & vcl::font::FontTypeFaces::Bold ) nTestMatch += 1000000; if( eMatchWeight > WEIGHT_BOLD ) nTestMatch += 1000000; @@ -734,13 +734,13 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont else if( ((eMatchWeight != WEIGHT_DONTKNOW) && (eMatchWeight != WEIGHT_NORMAL) && (eMatchWeight != WEIGHT_MEDIUM)) || - !(pData->GetTypeFaces() & FontTypeFaces::Normal) ) + !(pData->GetTypeFaces() & vcl::font::FontTypeFaces::Normal) ) { nTestMatch -= 1000000; } // prefer scalable fonts - if( pData->GetTypeFaces() & FontTypeFaces::Scalable ) + if( pData->GetTypeFaces() & vcl::font::FontTypeFaces::Scalable ) nTestMatch += 10000*4; else nTestMatch -= 10000*4; @@ -814,11 +814,11 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont return pFoundData; } -PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyOfDefaultFont() const +vcl::font::PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyOfDefaultFont() const { // try to find one of the default fonts of the // UNICODE, SANSSERIF, SERIF or FIXED default font lists - PhysicalFontFamily* pFoundData = nullptr; + vcl::font::PhysicalFontFamily* pFoundData = nullptr; if (!utl::ConfigManager::IsFuzzing()) { const utl::DefaultFontConfiguration& rDefaults = utl::DefaultFontConfiguration::get(); @@ -851,7 +851,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyOfDefaultFont() co for (auto const& family : maPhysicalFontFamilies) { - PhysicalFontFamily* pData = family.second.get(); + vcl::font::PhysicalFontFamily* pData = family.second.get(); if( pData->GetMatchType() & ImplFontAttrs::Symbol ) continue; @@ -881,7 +881,7 @@ std::shared_ptr<PhysicalFontCollection> PhysicalFontCollection::Clone() const for (auto const& family : maPhysicalFontFamilies) { - const PhysicalFontFamily* pFontFace = family.second.get(); + const vcl::font::PhysicalFontFamily* pFontFace = family.second.get(); pFontFace->UpdateCloneFontList(*xClonedCollection); } @@ -894,7 +894,7 @@ std::unique_ptr<vcl::font::PhysicalFontFaceCollection> PhysicalFontCollection::G for (auto const& family : maPhysicalFontFamilies) { - const PhysicalFontFamily* pFontFamily = family.second.get(); + const vcl::font::PhysicalFontFamily* pFontFamily = family.second.get(); pFontFamily->UpdateDevFontList( *pDeviceFontList ); } @@ -905,7 +905,7 @@ std::unique_ptr<ImplDeviceFontSizeList> PhysicalFontCollection::GetDeviceFontSiz { std::unique_ptr<ImplDeviceFontSizeList> pDeviceFontSizeList(new ImplDeviceFontSizeList); - PhysicalFontFamily* pFontFamily = FindFontFamily( rFontName ); + vcl::font::PhysicalFontFamily* pFontFamily = FindFontFamily( rFontName ); if( pFontFamily != nullptr ) { o3tl::sorted_vector<int> rHeights; @@ -945,7 +945,7 @@ static bool FindMetricCompatibleFont(FontSelectPattern& rFontSelData) return false; } -PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& rFSD ) const +vcl::font::PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& rFSD ) const { // give up if no fonts are available if( !Count() ) @@ -958,7 +958,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r sal_Int32 nIndex = 0; rFSD.maTargetName = GetNextFontToken(rFSD.GetFamilyName(), nIndex); rFSD.maSearchName = "liberationsans"; - PhysicalFontFamily* pFont = ImplFindFontFamilyBySearchName(rFSD.maSearchName); + vcl::font::PhysicalFontFamily* pFont = ImplFindFontFamilyBySearchName(rFSD.maSearchName); assert(pFont); return pFont; } @@ -1017,7 +1017,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r rFSD.maTargetName = aOrigName; // check if the current font name token or its substitute is valid - PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchName ); + vcl::font::PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchName ); if( pFoundData ) return pFoundData; @@ -1082,7 +1082,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r aSearchName = GetEnglishSearchFontName( aSearchName ); } ImplFontSubstitute( aSearchName ); - PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchName ); + vcl::font::PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchName ); if( pFoundData ) return pFoundData; } @@ -1108,7 +1108,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r // use the font's shortened name if needed if ( aSearchShortName != aSearchName ) { - PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchShortName ); + vcl::font::PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchShortName ); if( pFoundData ) { #ifdef UNX @@ -1141,7 +1141,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r // try the font substitutions suggested by the fallback info if( pFontAttr ) { - PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySubstFontAttr( *pFontAttr ); + vcl::font::PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySubstFontAttr( *pFontAttr ); if( pFoundData ) return pFoundData; } @@ -1155,7 +1155,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r aSearchName = "OpenSymbol"; else aSearchName = utl::DefaultFontConfiguration::get().getDefaultFont( aDefaultLanguageTag, DefaultFontType::SYMBOL ); - PhysicalFontFamily* pFoundData = FindFontFamilyByTokenNames( aSearchName ); + vcl::font::PhysicalFontFamily* pFoundData = FindFontFamilyByTokenNames( aSearchName ); if( pFoundData ) return pFoundData; } @@ -1180,7 +1180,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r // use a shortened token name if available if( aTempShortName != aSearchName ) { - PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aTempShortName ); + vcl::font::PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aTempShortName ); if( pFoundData ) return pFoundData; } @@ -1204,7 +1204,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r // try the font substitutions suggested by the fallback info if( pTempFontAttr ) { - PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySubstFontAttr( *pTempFontAttr ); + vcl::font::PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySubstFontAttr( *pTempFontAttr ); if( pFoundData ) return pFoundData; if( !pFontAttr ) @@ -1228,8 +1228,8 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r nSearchType |= ImplFontAttrs::Symbol; } - PhysicalFontFamily::CalcType( nSearchType, eSearchWeight, eSearchWidth, rFSD.GetFamilyType(), pFontAttr ); - PhysicalFontFamily* pFoundData = FindFontFamilyByAttributes( nSearchType, + vcl::font::PhysicalFontFamily::CalcType( nSearchType, eSearchWeight, eSearchWidth, rFSD.GetFamilyType(), pFontAttr ); + vcl::font::PhysicalFontFamily* pFoundData = FindFontFamilyByAttributes( nSearchType, eSearchWeight, eSearchWidth, rFSD.GetItalic(), aSearchFamilyName ); if( pFoundData ) @@ -1237,14 +1237,14 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r // overwrite font selection attributes using info from the typeface flags if( (eSearchWeight >= WEIGHT_BOLD) && (eSearchWeight > rFSD.GetWeight()) && - (pFoundData->GetTypeFaces() & FontTypeFaces::Bold) ) + (pFoundData->GetTypeFaces() & vcl::font::FontTypeFaces::Bold) ) { rFSD.SetWeight( eSearchWeight ); } else if( (eSearchWeight < WEIGHT_NORMAL) && (eSearchWeight < rFSD.GetWeight()) && (eSearchWeight != WEIGHT_DONTKNOW) && - (pFoundData->GetTypeFaces() & FontTypeFaces::Light) ) + (pFoundData->GetTypeFaces() & vcl::font::FontTypeFaces::Light) ) { rFSD.SetWeight( eSearchWeight ); } @@ -1252,7 +1252,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r if( (nSearchType & ImplFontAttrs::Italic) && ((rFSD.GetItalic() == ITALIC_DONTKNOW) || (rFSD.GetItalic() == ITALIC_NONE)) && - (pFoundData->GetTypeFaces() & FontTypeFaces::Italic) ) + (pFoundData->GetTypeFaces() & vcl::font::FontTypeFaces::Italic) ) { rFSD.SetItalic( ITALIC_NORMAL ); } diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx index 31caca8dcd31..cfe93b9d22b7 100644 --- a/vcl/source/font/PhysicalFontFamily.cxx +++ b/vcl/source/font/PhysicalFontFamily.cxx @@ -26,6 +26,9 @@ #include <font/PhysicalFontFaceCollection.hxx> #include <PhysicalFontCollection.hxx> +namespace vcl::font +{ + void PhysicalFontFamily::CalcType( ImplFontAttrs& rType, FontWeight& rWeight, FontWidth& rWidth, FontFamily eFamily, const utl::FontNameAttr* pFontAttr ) { @@ -272,5 +275,6 @@ void PhysicalFontFamily::UpdateCloneFontList(PhysicalFontCollection& rFontCollec pFamily->AddFontFace( pFoundFontFace ); } } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/font/fontcache.cxx b/vcl/source/font/fontcache.cxx index 8b6730a81447..18d191bb0f7b 100644 --- a/vcl/source/font/fontcache.cxx +++ b/vcl/source/font/fontcache.cxx @@ -17,12 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <fontinstance.hxx> -#include <impfontcache.hxx> +#include <sal/config.h> +#include <sal/log.hxx> + #include <PhysicalFontCollection.hxx> #include <PhysicalFontFace.hxx> -#include <PhysicalFontFamily.hxx> -#include <sal/log.hxx> +#include <font/PhysicalFontFamily.hxx> +#include <fontinstance.hxx> +#include <impfontcache.hxx> + +using namespace vcl::font; size_t ImplFontCache::IFSD_Hash::operator()( const FontSelectPattern& rFSD ) const { diff --git a/vcl/source/gdi/pdffontcache.cxx b/vcl/source/gdi/pdffontcache.cxx index e7206701562f..dadcb03048e2 100644 --- a/vcl/source/gdi/pdffontcache.cxx +++ b/vcl/source/gdi/pdffontcache.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + #include <sal/types.h> #include <PhysicalFontFace.hxx> diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index e2d8d4ef471c..c1cf93f1eec8 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -128,7 +128,7 @@ int OutputDevice::GetFontFaceCollectionCount() const bool OutputDevice::IsFontAvailable( const OUString& rFontName ) const { ImplInitFontList(); - PhysicalFontFamily* pFound = mxFontCollection->FindFontFamily( rFontName ); + vcl::font::PhysicalFontFamily* pFound = mxFontCollection->FindFontFamily( rFontName ); return (pFound != nullptr); } @@ -792,7 +792,7 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan sal_Int32 nIndex = 0; do { - PhysicalFontFamily* pFontFamily = pOutDev->mxFontCollection->FindFontFamily( GetNextFontToken( aSearch, nIndex ) ); + vcl::font::PhysicalFontFamily* pFontFamily = pOutDev->mxFontCollection->FindFontFamily( GetNextFontToken( aSearch, nIndex ) ); if( pFontFamily ) { AddTokenFontName( aName, pFontFamily->GetFamilyName() ); diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 6c199de9c18f..0fc289d3d95e 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -244,7 +244,7 @@ bool WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OU namespace { //used by 2-level font fallback - PhysicalFontFamily* findDevFontListByLocale(const PhysicalFontCollection &rFontCollection, + vcl::font::PhysicalFontFamily* findDevFontListByLocale(const PhysicalFontCollection &rFontCollection, const LanguageTag& rLanguageTag ) { // get the default font for a specified locale @@ -302,7 +302,7 @@ bool WinGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& rFont // first level fallback: // try use the locale specific default fonts defined in VCL.xcu const PhysicalFontCollection* pFontCollection = ImplGetSVData()->maGDIData.mxScreenFontList.get(); - PhysicalFontFamily* pFontFamily = findDevFontListByLocale(*pFontCollection, aLanguageTag); + vcl::font::PhysicalFontFamily* pFontFamily = findDevFontListByLocale(*pFontCollection, aLanguageTag); if( pFontFamily ) { PhysicalFontFace* pFace = pFontFamily->FindBestFontFace( rFontSelData ); |