Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / vcl / inc / PhysicalFontCollection.hxx
blobfd944a211631cf5c29920d8b6eaeee7b45f130ea
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 ImplGlyphFallbackFontSubstitution;
32 class ImplPreMatchFontSubstitution;
35 // TODO: merge with ImplFontCache
36 // TODO: rename to LogicalFontManager
38 class VCL_PLUGIN_PUBLIC PhysicalFontCollection final
40 public:
41 explicit PhysicalFontCollection();
42 ~PhysicalFontCollection();
44 // fill the list with device font faces
45 void Add( PhysicalFontFace* );
46 void Clear();
47 int Count() const { return maPhysicalFontFamilies.size(); }
49 // find the device font family
50 PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const;
51 PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName );
52 PhysicalFontFamily* FindFontFamily( FontSelectPattern& ) const;
53 PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const;
54 PhysicalFontFamily* FindFontFamilyByAttributes(ImplFontAttrs nSearchType, FontWeight, FontWidth,
55 FontItalic, const OUString& rSearchFamily) const;
57 // suggest fonts for glyph fallback
58 PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&,
59 OUString& rMissingCodes, int nFallbackLevel ) const;
61 // prepare platform specific font substitutions
62 void SetPreMatchHook( ImplPreMatchFontSubstitution* );
63 void SetFallbackHook( ImplGlyphFallbackFontSubstitution* );
65 // misc utilities
66 PhysicalFontCollection* Clone() const;
67 std::unique_ptr<ImplDeviceFontList> GetDeviceFontList() const;
68 std::unique_ptr<ImplDeviceFontSizeList> GetDeviceFontSizeList( const OUString& rFontName ) const;
70 private:
71 mutable bool mbMatchData; // true if matching attributes are initialized
73 typedef std::unordered_map<OUString, PhysicalFontFamily*> PhysicalFontFamilies;
74 PhysicalFontFamilies maPhysicalFontFamilies;
76 ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution
77 ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution
79 mutable std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList;
80 mutable int mnFallbackCount;
82 void ImplInitMatchData() const;
83 void ImplInitGenericGlyphFallback() const;
85 PhysicalFontFamily* ImplFindFontFamilyBySearchName( const OUString& ) const;
86 PhysicalFontFamily* ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& ) const;
88 PhysicalFontFamily* ImplFindFontFamilyOfDefaultFont() const;
92 #endif // INCLUDED_VCL_INC_PHYSICALFONTCOLLECTION_HXX
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */