summaryrefslogtreecommitdiff
path: root/core/src/fxge/ge/fx_ge_font.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-21 17:07:24 -0700
committerLei Zhang <thestig@chromium.org>2015-10-21 17:07:24 -0700
commit122ee21e38a15554c8c61edd21fda8c110be6072 (patch)
tree208031600c134d48a8af2488fc337dab2e110bde /core/src/fxge/ge/fx_ge_font.cpp
parentafaa98eeb161d60e76506a16d8b986203a7ec0b3 (diff)
downloadpdfium-122ee21e38a15554c8c61edd21fda8c110be6072.tar.xz
Merge to XFA: Make CFX_FontMgr member variables private. (try 2)
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1412733011 . (cherry picked from commit 5a5b6fb3759daf1201ffc9702f626f4b243922d0) Review URL: https://codereview.chromium.org/1414463006 .
Diffstat (limited to 'core/src/fxge/ge/fx_ge_font.cpp')
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp40
1 files changed, 16 insertions, 24 deletions
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index 468033eb01..7517cf1bed 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -39,6 +39,10 @@ CFX_UnicodeEncodingEx* _FXFM_CreateFontEncoding(CFX_Font* pFont,
return new CFX_UnicodeEncodingEx(pFont, nEncodingID);
}
+FXFT_Face FT_LoadFont(const uint8_t* pData, int size) {
+ return CFX_GEModule::Get()->GetFontMgr()->GetFixedFace(pData, size, 0);
+}
+
} // namespace
CFX_Font::CFX_Font() {
@@ -181,23 +185,27 @@ FX_BOOL _LoadFile(FXFT_Library library,
}
return TRUE;
}
+
FX_BOOL CFX_Font::LoadFile(IFX_FileRead* pFile,
int nFaceIndex,
int* pFaceCount) {
m_bEmbedded = FALSE;
- FXFT_Library library;
- if (CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary == NULL)
- FXFT_Init_FreeType(&CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary);
- library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary;
- FXFT_Stream stream = NULL;
+
+ CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
+ pFontMgr->InitFTLibrary();
+ FXFT_Library library = pFontMgr->GetFTLibrary();
+
+ FXFT_Stream stream = nullptr;
if (!_LoadFile(library, &m_Face, pFile, &stream, nFaceIndex))
return FALSE;
+
if (pFaceCount)
*pFaceCount = (int)m_Face->num_faces;
m_pOwnedStream = stream;
FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
return TRUE;
}
+
int CFX_Font::GetGlyphWidth(FX_DWORD glyph_index) {
if (!m_Face) {
return 0;
@@ -215,28 +223,12 @@ int CFX_Font::GetGlyphWidth(FX_DWORD glyph_index) {
FXFT_Get_Glyph_HoriAdvance(m_Face));
return width;
}
-static FXFT_Face FT_LoadFont(uint8_t* pData, int size) {
- FXFT_Library library;
- if (CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary == NULL) {
- FXFT_Init_FreeType(&CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary);
- }
- library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary;
- FXFT_Face face = NULL;
- int error = FXFT_New_Memory_Face(library, pData, size, 0, &face);
- if (error) {
- return NULL;
- }
- error = FXFT_Set_Pixel_Sizes(face, 64, 64);
- if (error) {
- return NULL;
- }
- return face;
-}
+
FX_BOOL CFX_Font::LoadEmbedded(const uint8_t* data, FX_DWORD size) {
m_pFontDataAllocation = FX_Alloc(uint8_t, size);
FXSYS_memcpy(m_pFontDataAllocation, data, size);
- m_Face = FT_LoadFont((uint8_t*)m_pFontDataAllocation, size);
- m_pFontData = (uint8_t*)m_pFontDataAllocation;
+ m_Face = FT_LoadFont(m_pFontDataAllocation, size);
+ m_pFontData = m_pFontDataAllocation;
m_bEmbedded = TRUE;
m_dwSize = size;
return m_Face != NULL;