summaryrefslogtreecommitdiff
path: root/core/src/fxge/ge/fx_ge_font.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-20 10:43:15 -0700
committerLei Zhang <thestig@chromium.org>2015-10-20 10:43:15 -0700
commit444ed783c014bbbde2eda7a25cf42bfc2234d7a8 (patch)
tree8acd0842faeed065ef12e1a528293c87222e82d4 /core/src/fxge/ge/fx_ge_font.cpp
parent937840e1722d1f2b77d80575d6e710d760662c9c (diff)
downloadpdfium-444ed783c014bbbde2eda7a25cf42bfc2234d7a8.tar.xz
Revert "Make CFX_FontMgr member variables private."
This reverts commit c29bee029cd5fe3f8a4ceb580235ac2d0e5ce8fd. because it broke corpus tests. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1410733005 .
Diffstat (limited to 'core/src/fxge/ge/fx_ge_font.cpp')
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index fed80e6165..a6ababf572 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -7,17 +7,7 @@
#include "../../../include/fxge/fx_ge.h"
#include "../../../include/fxge/fx_freetype.h"
#include "text_int.h"
-
#define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
-
-namespace {
-
-FXFT_Face FT_LoadFont(const uint8_t* pData, int size) {
- return CFX_GEModule::Get()->GetFontMgr()->GetFixedFace(pData, size, 0);
-}
-
-} // namespace
-
CFX_Font::CFX_Font() {
m_pSubstFont = NULL;
m_Face = NULL;
@@ -100,12 +90,28 @@ 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(m_pFontDataAllocation, size);
- m_pFontData = m_pFontDataAllocation;
+ m_Face = FT_LoadFont((uint8_t*)m_pFontDataAllocation, size);
+ m_pFontData = (uint8_t*)m_pFontDataAllocation;
m_bEmbedded = TRUE;
m_dwSize = size;
return m_Face != NULL;