bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / PhysicalFontCollection.hxx
blob87b94fe2ce3bc1c1157f8a66e1e0d33d64a77b65
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_PHYSICALFONTCOLLECTION_HXX
21 #define INCLUDED_VCL_INC_PHYSICALFONTCOLLECTION_HXX
23 #include <vcl/dllapi.h>
25 #include "fontinstance.hxx"
26 #include "PhysicalFontFamily.hxx"
27 #include <array>
29 #define MAX_GLYPHFALLBACK 16
31 class ImplDeviceFontSizeList;
32 class ImplGlyphFallbackFontSubstitution;
33 class ImplPreMatchFontSubstitution;
36 // TODO: merge with ImplFontCache
37 // TODO: rename to LogicalFontManager
39 class VCL_PLUGIN_PUBLIC PhysicalFontCollection final
41 public:
42 explicit PhysicalFontCollection();
43 ~PhysicalFontCollection();
45 // fill the list with device font faces
46 void Add( PhysicalFontFace* );
47 void Clear();
48 int Count() const { return maPhysicalFontFamilies.size(); }
50 // find the device font family
51 PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const;
52 PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName );
53 PhysicalFontFamily* FindFontFamily( FontSelectPattern& ) const;
54 PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const;
55 PhysicalFontFamily* FindFontFamilyByAttributes(ImplFontAttrs nSearchType, FontWeight, FontWidth,
56 FontItalic, const OUString& rSearchFamily) const;
58 // suggest fonts for glyph fallback
59 PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&,
60 LogicalFontInstance* pLogicalFont,
61 OUString& rMissingCodes, int nFallbackLevel ) const;
63 // prepare platform specific font substitutions
64 void SetPreMatchHook( ImplPreMatchFontSubstitution* );
65 void SetFallbackHook( ImplGlyphFallbackFontSubstitution* );
67 // misc utilities
68 std::shared_ptr<PhysicalFontCollection> Clone() const;
69 std::unique_ptr<ImplDeviceFontList> GetDeviceFontList() const;
70 std::unique_ptr<ImplDeviceFontSizeList> GetDeviceFontSizeList( const OUString& rFontName ) const;
72 private:
73 mutable bool mbMatchData; // true if matching attributes are initialized
75 typedef std::unordered_map<OUString, std::unique_ptr<PhysicalFontFamily>> PhysicalFontFamilies;
76 PhysicalFontFamilies maPhysicalFontFamilies;
78 ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution
79 ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution
81 mutable std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList;
82 mutable int mnFallbackCount;
84 void ImplInitMatchData() const;
85 void ImplInitGenericGlyphFallback() const;
87 PhysicalFontFamily* ImplFindFontFamilyBySearchName( const OUString& ) const;
88 PhysicalFontFamily* ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& ) const;
90 PhysicalFontFamily* ImplFindFontFamilyOfDefaultFont() const;
94 #endif // INCLUDED_VCL_INC_PHYSICALFONTCOLLECTION_HXX
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */