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 
28 #include "PhysicalFontFamily.hxx"
29 
30 #include <array>
31 #include <string_view>
32 
33 #define MAX_GLYPHFALLBACK 16
34 
35 namespace vcl::font
36 {
37 class GlyphFallbackFontSubstitution;
38 class PreMatchFontSubstitution;
39 }
40 
41 // TODO: merge with ImplFontCache
42 // TODO: rename to LogicalFontManager
43 
44 namespace vcl::font
45 {
46 
48 {
49 public:
50  explicit PhysicalFontCollection();
52 
53  // fill the list with device font faces
55  void Clear();
56  int Count() const { return maPhysicalFontFamilies.size(); }
57 
58  // find the device font family
59  vcl::font::PhysicalFontFamily* FindFontFamily( std::u16string_view rFontName ) const;
60  vcl::font::PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName );
62  vcl::font::PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const;
63  vcl::font::PhysicalFontFamily* FindFontFamilyByAttributes(ImplFontAttrs nSearchType, FontWeight, FontWidth,
64  FontItalic, const OUString& rSearchFamily) const;
65 
66  // suggest fonts for glyph fallback
68  LogicalFontInstance* pLogicalFont,
69  OUString& rMissingCodes, int nFallbackLevel ) const;
70 
71  // prepare platform specific font substitutions
72  void SetPreMatchHook( vcl::font::PreMatchFontSubstitution* );
73  void SetFallbackHook( vcl::font::GlyphFallbackFontSubstitution* );
74 
75  // misc utilities
76  std::shared_ptr<PhysicalFontCollection> Clone() const;
77  std::unique_ptr<vcl::font::PhysicalFontFaceCollection> GetFontFaceCollection() const;
78 
79 private:
80  mutable bool mbMatchData; // true if matching attributes are initialized
81 
82  typedef std::unordered_map<OUString, std::unique_ptr<vcl::font::PhysicalFontFamily>> PhysicalFontFamilies;
83  PhysicalFontFamilies maPhysicalFontFamilies;
84 
85  vcl::font::PreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution
86  vcl::font::GlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution
87 
88  mutable std::unique_ptr<std::array<vcl::font::PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList;
89  mutable int mnFallbackCount;
90 
91  void ImplInitMatchData() const;
92  void ImplInitGenericGlyphFallback() const;
93 
94  vcl::font::PhysicalFontFamily* ImplFindFontFamilyBySearchName( const OUString& ) const;
95  vcl::font::PhysicalFontFamily* ImplFindFontFamilyBySubstFontAttr( const utl::FontNameAttr& ) const;
96 
97  vcl::font::PhysicalFontFamily* ImplFindFontFamilyOfDefaultFont() const;
98 
99 };
100 
101 }
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
std::unique_ptr< std::array< vcl::font::PhysicalFontFamily *, MAX_GLYPHFALLBACK > > mpFallbackList
FontWidth
vcl::font::GlyphFallbackFontSubstitution * mpFallbackHook
vcl::font::PreMatchFontSubstitution * mpPreMatchHook
Abstracts the concept of a configured font substitution before the availability of the originally sel...
Abstracts the concept of finding the best font to support an incomplete font.
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
ImplFontAttrs
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
void Clear(EHistoryType eHistory)
abstract base class for physical font faces
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
FontWeight
std::unordered_map< OUString, std::unique_ptr< vcl::font::PhysicalFontFamily > > PhysicalFontFamilies
FontItalic