1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_OUTDEV_H
21 #define INCLUDED_VCL_INC_OUTDEV_H
26 #include <tools/gen.hxx>
27 #include <vcl/vclptr.hxx>
29 #include "fontinstance.hxx"
30 #include "PhysicalFontFace.hxx"
31 #include "impfontcache.hxx"
34 namespace vcl
{ class Font
; }
36 class PhysicalFontCollection
;
37 enum class AddFontSubstituteFlags
;
39 // an ImplDeviceFontList is created by a PhysicalFontCollection
40 // it becomes invalid when original PhysicalFontCollection is modified
41 class ImplDeviceFontList
44 std::vector
<rtl::Reference
<PhysicalFontFace
>> maDevFontVector
;
47 ImplDeviceFontList() { maDevFontVector
.reserve(1024); }
48 void Add( PhysicalFontFace
* pFace
) { maDevFontVector
.push_back( pFace
); }
49 PhysicalFontFace
* Get( int nIndex
) const { return maDevFontVector
[ nIndex
].get(); }
50 int Count() const { return maDevFontVector
.size(); }
53 class ImplDeviceFontSizeList
56 std::vector
<int> maSizeList
;
59 ImplDeviceFontSizeList()
60 { maSizeList
.reserve( 32 ); }
61 void Add( int nHeight
) { maSizeList
.push_back( nHeight
); }
62 int Count() const { return maSizeList
.size(); }
63 int Get( int nIndex
) const { return maSizeList
[ nIndex
]; }
66 // nowadays these substitutions are needed for backward compatibility and tight platform integration:
67 // - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig)
68 // - device specific substitutions (e.g. for PS printer builtin fonts)
69 // - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks)
70 // - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB")
71 // - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks)
72 // - substitutions for missing symbol fonts by translating code points into other symbol fonts
74 class ImplFontSubstitution
76 // TODO: there is more commonality between the different substitutions
78 virtual ~ImplFontSubstitution() {}
81 // ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions
82 // The class is just a simple port of the unmaintainable manual-linked-list based mechanism
83 // TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good
85 struct ImplFontSubstEntry
87 OUString maSearchName
;
88 OUString maSearchReplaceName
;
89 AddFontSubstituteFlags mnFlags
;
91 ImplFontSubstEntry( const OUString
& rFontName
, const OUString
& rSubstFontName
, AddFontSubstituteFlags nSubstFlags
);
94 class ImplDirectFontSubstitution final
95 : public ImplFontSubstitution
98 std::vector
<ImplFontSubstEntry
> maFontSubstList
;
100 void AddFontSubstitute( const OUString
& rFontName
, const OUString
& rSubstName
, AddFontSubstituteFlags nFlags
);
101 void RemoveFontsSubstitute();
103 bool FindFontSubstitute( OUString
& rSubstName
, std::u16string_view rFontName
) const;
106 // PreMatchFontSubstitution
107 // abstracts the concept of a configured font substitution
108 // before the availability of the originally selected font has been checked
109 class ImplPreMatchFontSubstitution
110 : public ImplFontSubstitution
113 virtual bool FindFontSubstitute(FontSelectPattern
&) const = 0;
116 // ImplGlyphFallbackFontSubstitution
117 // abstracts the concept of finding the best font to support an incomplete font
118 class ImplGlyphFallbackFontSubstitution
119 : public ImplFontSubstitution
122 virtual bool FindFontSubstitute(FontSelectPattern
&, LogicalFontInstance
* pLogicalFont
, OUString
& rMissingCodes
) const = 0;
125 namespace vcl
{ struct ControlLayoutData
; }
127 namespace basegfx
{ class B2DHomMatrix
; }
129 struct ImplOutDevData
131 VclPtr
<VirtualDevice
> mpRotateDev
;
132 vcl::ControlLayoutData
* mpRecordLayout
;
133 tools::Rectangle maRecordRect
;
136 basegfx::B2DHomMatrix
* mpViewTransform
;
137 basegfx::B2DHomMatrix
* mpInverseViewTransform
;
140 void ImplFontSubstitute( OUString
& rFontName
);
142 #endif // INCLUDED_VCL_INC_OUTDEV_H
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */