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_IMPFONTCACHE_HXX
21 #define INCLUDED_VCL_INC_IMPFONTCACHE_HXX
23 #include <unordered_map>
25 #include "fontselect.hxx"
28 namespace vcl
{ class Font
; }
29 class PhysicalFontCollection
;
32 // TODO: closely couple with PhysicalFontCollection
37 LogicalFontInstance
* mpFirstEntry
;
38 int mnRef0Count
; // number of unreferenced LogicalFontInstances
40 // cache of recently used font instances
41 struct IFSD_Equal
{ bool operator()( const FontSelectPattern
&, const FontSelectPattern
& ) const; };
42 struct IFSD_Hash
{ size_t operator()( const FontSelectPattern
& ) const; };
43 typedef std::unordered_map
<FontSelectPattern
,LogicalFontInstance
*,IFSD_Hash
,IFSD_Equal
> FontInstanceList
;
44 FontInstanceList maFontInstanceList
;
46 int CountUnreferencedEntries() const;
52 LogicalFontInstance
* GetFontInstance( PhysicalFontCollection
*,
53 const vcl::Font
&, const Size
& rPixelSize
, float fExactHeight
);
54 LogicalFontInstance
* GetFontInstance( PhysicalFontCollection
*, FontSelectPattern
& );
55 LogicalFontInstance
* GetGlyphFallbackFont( PhysicalFontCollection
*, FontSelectPattern
&,
56 int nFallbackLevel
, OUString
& rMissingCodes
);
58 /// Increase the refcount of the given LogicalFontInstance.
59 void Acquire(LogicalFontInstance
*);
60 /// Decrease the refcount and potentially cleanup the entries with zero refcount from the cache.
61 void Release(LogicalFontInstance
*);
66 #endif // INCLUDED_VCL_INC_IMPFONTCACHE_HXX
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */