LibreOffice Module vcl (master)  1
PhysicalFontCollection.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_PHYSICALFONTCOLLECTION_HXX
21 #define INCLUDED_VCL_INC_PHYSICALFONTCOLLECTION_HXX
22 
23 #include <vcl/dllapi.h>
24 
25 #include "fontinstance.hxx"
26 #include "PhysicalFontFamily.hxx"
27 #include <array>
28 
29 #define MAX_GLYPHFALLBACK 16
30 
34 
35 
36 // TODO: merge with ImplFontCache
37 // TODO: rename to LogicalFontManager
38 
40 {
41 public:
42  explicit PhysicalFontCollection();
44 
45  // fill the list with device font faces
46  void Add( PhysicalFontFace* );
47  void Clear();
48  int Count() const { return maPhysicalFontFamilies.size(); }
49 
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;
57 
58  // suggest fonts for glyph fallback
59  PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&,
60  LogicalFontInstance* pLogicalFont,
61  OUString& rMissingCodes, int nFallbackLevel ) const;
62 
63  // prepare platform specific font substitutions
64  void SetPreMatchHook( ImplPreMatchFontSubstitution* );
65  void SetFallbackHook( ImplGlyphFallbackFontSubstitution* );
66 
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;
71 
72 private:
73  mutable bool mbMatchData; // true if matching attributes are initialized
74 
75  typedef std::unordered_map<OUString, std::unique_ptr<PhysicalFontFamily>> PhysicalFontFamilies;
76  PhysicalFontFamilies maPhysicalFontFamilies;
77 
78  ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution
79  ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution
80 
81  mutable std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList;
82  mutable int mnFallbackCount;
83 
84  void ImplInitMatchData() const;
85  void ImplInitGenericGlyphFallback() const;
86 
87  PhysicalFontFamily* ImplFindFontFamilyBySearchName( const OUString& ) const;
88  PhysicalFontFamily* ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& ) const;
89 
90  PhysicalFontFamily* ImplFindFontFamilyOfDefaultFont() const;
91 
92 };
93 
94 #endif // INCLUDED_VCL_INC_PHYSICALFONTCOLLECTION_HXX
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FontWidth
ImplPreMatchFontSubstitution * mpPreMatchHook
ImplFontAttrs
std::unique_ptr< std::array< PhysicalFontFamily *, MAX_GLYPHFALLBACK > > mpFallbackList
abstract base class for physical font faces
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
std::unordered_map< OUString, std::unique_ptr< PhysicalFontFamily > > PhysicalFontFamilies
ImplGlyphFallbackFontSubstitution * mpFallbackHook
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
FontWeight
PhysicalFontFamilies maPhysicalFontFamilies
FontItalic