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 .
22 #include <sal/config.h>
24 #include <basegfx/range/b2drectangle.hxx>
25 #include <rtl/ref.hxx>
26 #include <o3tl/lru_map.hxx>
27 #include <o3tl/hash_combine.hxx>
29 #include "font/FontSelectPattern.hxx"
30 #include "glyphid.hxx"
33 namespace vcl
{ class Font
; }
34 namespace vcl::font
{ class PhysicalFontCollection
; }
36 // TODO: closely couple with PhysicalFontCollection
38 struct GlyphBoundRectCacheKey
40 const LogicalFontInstance
* m_pFont
;
41 const sal_GlyphId m_nId
;
43 GlyphBoundRectCacheKey(const LogicalFontInstance
* pFont
, sal_GlyphId nID
)
44 : m_pFont(pFont
), m_nId(nID
)
47 bool operator==(GlyphBoundRectCacheKey
const& aOther
) const
48 { return m_pFont
== aOther
.m_pFont
&& m_nId
== aOther
.m_nId
; }
51 struct GlyphBoundRectCacheHash
53 std::size_t operator()(GlyphBoundRectCacheKey
const& aCache
) const
56 o3tl::hash_combine(seed
, aCache
.m_pFont
);
57 o3tl::hash_combine(seed
, aCache
.m_nId
);
62 typedef o3tl::lru_map
<GlyphBoundRectCacheKey
, basegfx::B2DRectangle
,
63 GlyphBoundRectCacheHash
> GlyphBoundRectCache
;
68 // cache of recently used font instances
69 struct IFSD_Equal
{ bool operator()( const vcl::font::FontSelectPattern
&, const vcl::font::FontSelectPattern
& ) const; };
70 struct IFSD_Hash
{ size_t operator()( const vcl::font::FontSelectPattern
& ) const; };
71 typedef o3tl::lru_map
<vcl::font::FontSelectPattern
, rtl::Reference
<LogicalFontInstance
>, IFSD_Hash
, IFSD_Equal
> FontInstanceList
;
73 LogicalFontInstance
* mpLastHitCacheEntry
; ///< keeps the last hit cache entry
74 FontInstanceList maFontInstanceList
;
75 GlyphBoundRectCache m_aBoundRectCache
;
77 rtl::Reference
<LogicalFontInstance
> GetFontInstance(vcl::font::PhysicalFontCollection
const*, vcl::font::FontSelectPattern
&);
83 rtl::Reference
<LogicalFontInstance
> GetFontInstance(vcl::font::PhysicalFontCollection
const *,
84 const vcl::Font
&, const Size
& rPixelSize
, float fExactHeight
, bool bNonAntialias
= false);
85 rtl::Reference
<LogicalFontInstance
> GetGlyphFallbackFont( vcl::font::PhysicalFontCollection
const *, vcl::font::FontSelectPattern
&,
86 LogicalFontInstance
* pLogicalFont
,
87 int nFallbackLevel
, OUString
& rMissingCodes
);
89 bool GetCachedGlyphBoundRect(const LogicalFontInstance
*, sal_GlyphId
, basegfx::B2DRectangle
&);
90 void CacheGlyphBoundRect(const LogicalFontInstance
*, sal_GlyphId
, basegfx::B2DRectangle
&);
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */