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 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <vcl/dllapi.h>
25 
26 #include "fontinstance.hxx"
27 #include "PhysicalFontFamily.hxx"
28 #include <array>
29 
30 #define MAX_GLYPHFALLBACK 16
31 
35 
36 
37 // TODO: merge with ImplFontCache
38 // TODO: rename to LogicalFontManager
39 
41 {
42 public:
43  explicit PhysicalFontCollection();
45 
46  // fill the list with device font faces
47  void Add( PhysicalFontFace* );
48  void Clear();
49  int Count() const { return maPhysicalFontFamilies.size(); }
50 
51  // find the device font family
52  PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const;
53  PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName );
54  PhysicalFontFamily* FindFontFamily( FontSelectPattern& ) const;
55  PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const;
56  PhysicalFontFamily* FindFontFamilyByAttributes(ImplFontAttrs nSearchType, FontWeight, FontWidth,
57  FontItalic, const OUString& rSearchFamily) const;
58 
59  // suggest fonts for glyph fallback
60  PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&,
61  LogicalFontInstance* pLogicalFont,
62  OUString& rMissingCodes, int nFallbackLevel ) const;
63 
64  // prepare platform specific font substitutions
65  void SetPreMatchHook( ImplPreMatchFontSubstitution* );
66  void SetFallbackHook( ImplGlyphFallbackFontSubstitution* );
67 
68  // misc utilities
69  std::shared_ptr<PhysicalFontCollection> Clone() const;
70  std::unique_ptr<vcl::font::PhysicalFontFaceCollection> GetFontFaceCollection() const;
71  std::unique_ptr<ImplDeviceFontSizeList> GetDeviceFontSizeList( const OUString& rFontName ) const;
72 
73 private:
74  mutable bool mbMatchData; // true if matching attributes are initialized
75 
76  typedef std::unordered_map<OUString, std::unique_ptr<PhysicalFontFamily>> PhysicalFontFamilies;
77  PhysicalFontFamilies maPhysicalFontFamilies;
78 
79  ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution
80  ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution
81 
82  mutable std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList;
83  mutable int mnFallbackCount;
84 
85  void ImplInitMatchData() const;
86  void ImplInitGenericGlyphFallback() const;
87 
88  PhysicalFontFamily* ImplFindFontFamilyBySearchName( const OUString& ) const;
89  PhysicalFontFamily* ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& ) const;
90 
91  PhysicalFontFamily* ImplFindFontFamilyOfDefaultFont() const;
92 
93 };
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
FontWidth
ImplPreMatchFontSubstitution * mpPreMatchHook
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)
ImplFontAttrs
std::unordered_map< OUString, std::unique_ptr< PhysicalFontFamily > > PhysicalFontFamilies
void Clear(EHistoryType eHistory)
ImplGlyphFallbackFontSubstitution * mpFallbackHook
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
FontWeight
PhysicalFontFamilies maPhysicalFontFamilies
FontItalic