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
27 #include <tools/gen.hxx>
28 #include <vcl/vclptr.hxx>
30 #include "fontinstance.hxx"
31 #include "PhysicalFontFace.hxx"
32 #include "impfontcache.hxx"
35 namespace vcl
{ class Font
; }
37 class PhysicalFontCollection
;
38 enum class AddFontSubstituteFlags
;
40 // an ImplDeviceFontList is created by an PhysicalFontCollection
41 // it becomes invalid when original PhysicalFontCollection is modified
42 class ImplDeviceFontList
45 std::vector
<PhysicalFontFace
*> maDevFontVector
;
48 ImplDeviceFontList() { maDevFontVector
.reserve(1024); }
49 void Add( PhysicalFontFace
* pFace
) { maDevFontVector
.push_back( pFace
); }
50 PhysicalFontFace
* Get( int nIndex
) const { return maDevFontVector
[ nIndex
]; }
51 int Count() const { return maDevFontVector
.size(); }
54 class ImplDeviceFontSizeList
57 std::vector
<int> maSizeList
;
60 ImplDeviceFontSizeList()
61 { maSizeList
.reserve( 32 ); }
62 void Add( int nHeight
) { maSizeList
.push_back( nHeight
); }
63 int Count() const { return maSizeList
.size(); }
64 int Get( int nIndex
) const { return maSizeList
[ nIndex
]; }
67 // nowadays these substitutions are needed for backward compatibility and tight platform integration:
68 // - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig)
69 // - device specific substitutions (e.g. for PS printer builtin fonts)
70 // - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks)
71 // - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB")
72 // - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks)
73 // - substitutions for missing symbol fonts by translating code points into other symbol fonts
75 class ImplFontSubstitution
77 // TODO: there is more commonality between the different substitutions
79 virtual ~ImplFontSubstitution() {}
82 // ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions
83 // The class is just a simple port of the unmaintainable manual-linked-list based mechanism
84 // TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good
86 struct ImplFontSubstEntry
88 OUString maSearchName
;
89 OUString maSearchReplaceName
;
90 AddFontSubstituteFlags mnFlags
;
92 ImplFontSubstEntry( const OUString
& rFontName
, const OUString
& rSubstFontName
, AddFontSubstituteFlags nSubstFlags
);
95 class ImplDirectFontSubstitution
96 : public ImplFontSubstitution
99 std::list
<ImplFontSubstEntry
> maFontSubstList
;
101 void AddFontSubstitute( const OUString
& rFontName
, const OUString
& rSubstName
, AddFontSubstituteFlags nFlags
);
102 void RemoveFontSubstitute( int nIndex
);
103 int GetFontSubstituteCount() const { return maFontSubstList
.size(); };
105 bool FindFontSubstitute( OUString
& rSubstName
, const OUString
& rFontName
) const;
108 // PreMatchFontSubstitution
109 // abstracts the concept of a configured font substitution
110 // before the availability of the originally selected font has been checked
111 class ImplPreMatchFontSubstitution
112 : public ImplFontSubstitution
115 virtual bool FindFontSubstitute( FontSelectPattern
& ) const = 0;
118 // ImplGlyphFallbackFontSubstitution
119 // abstracts the concept of finding the best font to support an incomplete font
120 class ImplGlyphFallbackFontSubstitution
121 : public ImplFontSubstitution
124 virtual bool FindFontSubstitute( FontSelectPattern
&, OUString
& rMissingCodes
) const = 0;
127 namespace vcl
{ struct ControlLayoutData
; }
129 namespace basegfx
{ class B2DHomMatrix
; }
131 struct ImplOutDevData
133 VclPtr
<VirtualDevice
> mpRotateDev
;
134 vcl::ControlLayoutData
* mpRecordLayout
;
135 tools::Rectangle maRecordRect
;
138 basegfx::B2DHomMatrix
* mpViewTransform
;
139 basegfx::B2DHomMatrix
* mpInverseViewTransform
;
142 void ImplFontSubstitute( OUString
& rFontName
);
144 #endif // INCLUDED_VCL_INC_OUTDEV_H
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */