OLD | NEW |
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 #define EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em) | 10 #define EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 return 0; | 98 return 0; |
99 } | 99 } |
100 void _FTStreamClose(FXFT_Stream stream) | 100 void _FTStreamClose(FXFT_Stream stream) |
101 { | 101 { |
102 } | 102 } |
103 }; | 103 }; |
104 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FX
FT_Stream* stream) | 104 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FX
FT_Stream* stream) |
105 { | 105 { |
106 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec)
); | 106 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec)
); |
107 if (!stream1) { | |
108 return FALSE; | |
109 } | |
110 stream1->base = NULL; | 107 stream1->base = NULL; |
111 stream1->size = (unsigned long)pFile->GetSize(); | 108 stream1->size = (unsigned long)pFile->GetSize(); |
112 stream1->pos = 0; | 109 stream1->pos = 0; |
113 stream1->descriptor.pointer = pFile; | 110 stream1->descriptor.pointer = pFile; |
114 stream1->close = _FTStreamClose; | 111 stream1->close = _FTStreamClose; |
115 stream1->read = _FTStreamRead; | 112 stream1->read = _FTStreamRead; |
116 FXFT_Open_Args args; | 113 FXFT_Open_Args args; |
117 args.flags = FT_OPEN_STREAM; | 114 args.flags = FT_OPEN_STREAM; |
118 args.stream = stream1; | 115 args.stream = stream1; |
119 if (FXFT_Open_Face(library, &args, 0, Face)) { | 116 if (FXFT_Open_Face(library, &args, 0, Face)) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 167 } |
171 error = FXFT_Set_Pixel_Sizes(face, 64, 64); | 168 error = FXFT_Set_Pixel_Sizes(face, 64, 64); |
172 if (error) { | 169 if (error) { |
173 return NULL; | 170 return NULL; |
174 } | 171 } |
175 return face; | 172 return face; |
176 } | 173 } |
177 FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size) | 174 FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size) |
178 { | 175 { |
179 m_pFontDataAllocation = FX_Alloc(FX_BYTE, size); | 176 m_pFontDataAllocation = FX_Alloc(FX_BYTE, size); |
180 if (!m_pFontDataAllocation) { | |
181 return FALSE; | |
182 } | |
183 FXSYS_memcpy32(m_pFontDataAllocation, data, size); | 177 FXSYS_memcpy32(m_pFontDataAllocation, data, size); |
184 m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size); | 178 m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size); |
185 m_pFontData = (FX_LPBYTE)m_pFontDataAllocation; | 179 m_pFontData = (FX_LPBYTE)m_pFontDataAllocation; |
186 m_bEmbedded = TRUE; | 180 m_bEmbedded = TRUE; |
187 m_dwSize = size; | 181 m_dwSize = size; |
188 return m_Face != NULL; | 182 return m_Face != NULL; |
189 } | 183 } |
190 FX_BOOL CFX_Font::IsTTFont() | 184 FX_BOOL CFX_Font::IsTTFont() |
191 { | 185 { |
192 if (m_Face == NULL) { | 186 if (m_Face == NULL) { |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 break; | 428 break; |
435 } | 429 } |
436 } | 430 } |
437 } | 431 } |
438 return FXFT_Get_Char_Index(face, charcode); | 432 return FXFT_Get_Char_Index(face, charcode); |
439 } | 433 } |
440 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) | 434 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) |
441 { | 435 { |
442 return new CFX_UnicodeEncoding(pFont); | 436 return new CFX_UnicodeEncoding(pFont); |
443 } | 437 } |
OLD | NEW |