• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FXGE_CFX_FONTCACHE_H_
8 #define CORE_FXGE_CFX_FONTCACHE_H_
9 
10 #include <map>
11 #include <memory>
12 
13 #include "core/fxcrt/fx_system.h"
14 #include "core/fxge/cfx_font.h"
15 #include "core/fxge/fx_font.h"
16 #include "core/fxge/fx_freetype.h"
17 
18 class CFX_FaceCache;
19 
20 class CFX_FontCache {
21  public:
22   CFX_FontCache();
23   ~CFX_FontCache();
24   CFX_FaceCache* GetCachedFace(const CFX_Font* pFont);
25   void ReleaseCachedFace(const CFX_Font* pFont);
26 #ifdef _SKIA_SUPPORT_
27   CFX_TypeFace* GetDeviceCache(const CFX_Font* pFont);
28 #endif
29 
30  private:
31   struct CountedFaceCache {
32     CountedFaceCache();
33     ~CountedFaceCache();
34     std::unique_ptr<CFX_FaceCache> m_Obj;
35     uint32_t m_nCount;
36   };
37 
38   using CFX_FTCacheMap = std::map<FXFT_Face, std::unique_ptr<CountedFaceCache>>;
39   CFX_FTCacheMap m_FTFaceMap;
40   CFX_FTCacheMap m_ExtFaceMap;
41 };
42 
43 #endif  // CORE_FXGE_CFX_FONTCACHE_H_
44