Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: core/src/fxge/ge/fx_ge_font.cpp

Issue 1412733011: Make CFX_FontMgr member variables private. (try 2) (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: no unique_ptr Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #include "../../../include/fxge/fx_freetype.h" 8 #include "../../../include/fxge/fx_freetype.h"
9 #include "text_int.h" 9 #include "text_int.h"
10
10 #define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em) 11 #define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
12
13 namespace {
14
15 FXFT_Face FT_LoadFont(const uint8_t* pData, int size) {
16 return CFX_GEModule::Get()->GetFontMgr()->GetFixedFace(pData, size, 0);
17 }
18
19 } // namespace
20
11 CFX_Font::CFX_Font() { 21 CFX_Font::CFX_Font() {
12 m_pSubstFont = NULL; 22 m_pSubstFont = NULL;
13 m_Face = NULL; 23 m_Face = NULL;
14 m_bEmbedded = FALSE; 24 m_bEmbedded = FALSE;
15 m_bVertical = FALSE; 25 m_bVertical = FALSE;
16 m_pFontData = NULL; 26 m_pFontData = NULL;
17 m_pFontDataAllocation = NULL; 27 m_pFontDataAllocation = NULL;
18 m_dwSize = 0; 28 m_dwSize = 0;
19 m_pGsubData = NULL; 29 m_pGsubData = NULL;
20 m_pPlatformFont = NULL; 30 m_pPlatformFont = NULL;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 int err = FXFT_Load_Glyph( 93 int err = FXFT_Load_Glyph(
84 m_Face, glyph_index, 94 m_Face, glyph_index,
85 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); 95 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
86 if (err) { 96 if (err) {
87 return 0; 97 return 0;
88 } 98 }
89 int width = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 99 int width = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
90 FXFT_Get_Glyph_HoriAdvance(m_Face)); 100 FXFT_Get_Glyph_HoriAdvance(m_Face));
91 return width; 101 return width;
92 } 102 }
93 static FXFT_Face FT_LoadFont(uint8_t* pData, int size) { 103
94 FXFT_Library library;
95 if (CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary == NULL) {
96 FXFT_Init_FreeType(&CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary);
97 }
98 library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary;
99 FXFT_Face face = NULL;
100 int error = FXFT_New_Memory_Face(library, pData, size, 0, &face);
101 if (error) {
102 return NULL;
103 }
104 error = FXFT_Set_Pixel_Sizes(face, 64, 64);
105 if (error) {
106 return NULL;
107 }
108 return face;
109 }
110 FX_BOOL CFX_Font::LoadEmbedded(const uint8_t* data, FX_DWORD size) { 104 FX_BOOL CFX_Font::LoadEmbedded(const uint8_t* data, FX_DWORD size) {
111 m_pFontDataAllocation = FX_Alloc(uint8_t, size); 105 m_pFontDataAllocation = FX_Alloc(uint8_t, size);
112 FXSYS_memcpy(m_pFontDataAllocation, data, size); 106 FXSYS_memcpy(m_pFontDataAllocation, data, size);
113 m_Face = FT_LoadFont((uint8_t*)m_pFontDataAllocation, size); 107 m_Face = FT_LoadFont(m_pFontDataAllocation, size);
114 m_pFontData = (uint8_t*)m_pFontDataAllocation; 108 m_pFontData = m_pFontDataAllocation;
115 m_bEmbedded = TRUE; 109 m_bEmbedded = TRUE;
116 m_dwSize = size; 110 m_dwSize = size;
117 return m_Face != NULL; 111 return m_Face != NULL;
118 } 112 }
119 113
120 FX_BOOL CFX_Font::IsTTFont() const { 114 FX_BOOL CFX_Font::IsTTFont() const {
121 if (!m_Face) 115 if (!m_Face)
122 return FALSE; 116 return FALSE;
123 return FXFT_Is_Face_TT_OT(m_Face) == FXFT_FACE_FLAG_SFNT; 117 return FXFT_Is_Face_TT_OT(m_Face) == FXFT_FACE_FLAG_SFNT;
124 } 118 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 330
337 if (m_pFont->GetSubstFont() && m_pFont->GetSubstFont()->m_Charset == 2) { 331 if (m_pFont->GetSubstFont() && m_pFont->GetSubstFont()->m_Charset == 2) {
338 FX_DWORD index = 0; 332 FX_DWORD index = 0;
339 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) 333 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0)
340 index = FXFT_Get_Char_Index(face, charcode); 334 index = FXFT_Get_Char_Index(face, charcode);
341 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) 335 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN))
342 return FXFT_Get_Char_Index(face, charcode); 336 return FXFT_Get_Char_Index(face, charcode);
343 } 337 }
344 return charcode; 338 return charcode;
345 } 339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698