Index: core/fxge/ge/cfx_font.cpp |
diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp |
index feea8b0aa152c710d79f1cb1e327e357170823eb..6bbec1dcbd7f6130bc1759f0ee24438151ca78d6 100644 |
--- a/core/fxge/ge/cfx_font.cpp |
+++ b/core/fxge/ge/cfx_font.cpp |
@@ -8,6 +8,8 @@ |
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
#include "core/fxge/ge/fx_text_int.h" |
+#include "core/fxge/include/cfx_facecache.h" |
+#include "core/fxge/include/cfx_fontcache.h" |
#include "core/fxge/include/cfx_fontmgr.h" |
#include "core/fxge/include/cfx_gemodule.h" |
#include "core/fxge/include/cfx_pathdata.h" |
@@ -224,6 +226,8 @@ CFX_Font::CFX_Font() |
m_pOwnedStream(nullptr), |
#endif // PDF_ENABLE_XFA |
m_Face(nullptr), |
+ m_FaceCache(nullptr), |
+ m_FontCache(new CFX_FontCacheItem(this)), |
m_pFontData(nullptr), |
m_pGsubData(nullptr), |
m_dwSize(0), |
@@ -262,6 +266,7 @@ FX_BOOL CFX_Font::LoadClone(const CFX_Font* pFont) { |
m_pPlatformFont = pFont->m_pPlatformFont; |
#endif |
m_pOwnedStream = pFont->m_pOwnedStream; |
+ m_FaceCache = pFont->GetFaceCache(); |
dsinclair
2016/09/14 17:51:50
What about m_FontCache?
snake
2016/09/14 19:06:29
m_FontCache it is just wrapper (which will never c
|
return TRUE; |
} |
#endif // PDF_ENABLE_XFA |
@@ -279,10 +284,7 @@ CFX_Font::~CFX_Font() { |
FXFT_Clear_Face_External_Stream(m_Face); |
} |
#endif // PDF_ENABLE_XFA |
- if (m_bEmbedded) |
- DeleteFace(); |
- else |
- CFX_GEModule::Get()->GetFontMgr()->ReleaseFace(m_Face); |
+ DeleteFace(); |
} |
#ifdef PDF_ENABLE_XFA |
delete m_pOwnedStream; |
@@ -294,7 +296,12 @@ CFX_Font::~CFX_Font() { |
} |
void CFX_Font::DeleteFace() { |
- FXFT_Done_Face(m_Face); |
+ ClearFaceCache(); |
+ if (m_bEmbedded) { |
+ FXFT_Done_Face(m_Face); |
+ } else { |
+ CFX_GEModule::Get()->GetFontMgr()->ReleaseFace(m_Face); |
+ } |
m_Face = nullptr; |
} |
@@ -537,6 +544,21 @@ int CFX_Font::GetMaxAdvanceWidth() const { |
FXFT_Get_Face_MaxAdvanceWidth(m_Face)); |
} |
+CFX_FaceCache* CFX_Font::GetFaceCache() const { |
+ if (!m_FaceCache) { |
+ m_FaceCache = CFX_GEModule::Get()->GetFontCache()->GetCachedFace( |
+ const_cast<CFX_Font*>(this)); |
dsinclair
2016/09/14 17:51:50
We should remove the const from the signature inst
snake
2016/09/14 19:06:29
Done
|
+ } |
+ return m_FaceCache; |
+} |
+ |
+void CFX_Font::ClearFaceCache() { |
+ if (!m_FaceCache) |
+ return; |
+ CFX_GEModule::Get()->GetFontCache()->ReleaseCachedFace(this); |
+ m_FaceCache = nullptr; |
+} |
+ |
int CFX_Font::GetULPos() const { |
if (!m_Face) |
return 0; |
@@ -662,3 +684,30 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { |
pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; |
return pPath; |
} |
+ |
+CFX_FontCacheItem::CFX_FontCacheItem(CFX_Font* font) : m_Font(font) {} |
+ |
+CFX_FontCacheItem::~CFX_FontCacheItem() {} |
+ |
+const CFX_GlyphBitmap* CFX_FontCacheItem::LoadGlyphBitmap( |
+ uint32_t glyph_index, |
+ FX_BOOL bFontStyle, |
+ const CFX_Matrix* pMatrix, |
+ int dest_width, |
+ int anti_alias, |
+ int& text_flags) const { |
+ return m_Font->GetFaceCache()->LoadGlyphBitmap( |
+ m_Font, glyph_index, bFontStyle, pMatrix, dest_width, anti_alias, |
+ text_flags); |
+} |
+ |
+const CFX_PathData* CFX_FontCacheItem::LoadGlyphPath(uint32_t glyph_index, |
+ int dest_width) const { |
+ return m_Font->GetFaceCache()->LoadGlyphPath(m_Font, glyph_index, dest_width); |
+} |
+ |
+#ifdef _SKIA_SUPPORT_ |
+CFX_TypeFace* CFX_FontCacheItem::GetDeviceCache() const { |
+ return m_Font->GetFaceCache()->GetDeviceCache(m_Font); |
+} |
+#endif |