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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 void _FTStreamClose(FXFT_Stream stream) | 136 void _FTStreamClose(FXFT_Stream stream) |
137 { | 137 { |
138 } | 138 } |
139 }; | 139 }; |
140 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FX
FT_Stream* stream, FX_INT32 faceIndex = 0) | 140 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FX
FT_Stream* stream, FX_INT32 faceIndex = 0) |
141 { | 141 { |
142 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec)
); | 142 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec)
); |
143 if (!stream1) { | |
144 return FALSE; | |
145 } | |
146 stream1->base = NULL; | 143 stream1->base = NULL; |
147 stream1->size = (unsigned long)pFile->GetSize(); | 144 stream1->size = (unsigned long)pFile->GetSize(); |
148 stream1->pos = 0; | 145 stream1->pos = 0; |
149 stream1->descriptor.pointer = pFile; | 146 stream1->descriptor.pointer = pFile; |
150 stream1->close = _FTStreamClose; | 147 stream1->close = _FTStreamClose; |
151 stream1->read = _FTStreamRead; | 148 stream1->read = _FTStreamRead; |
152 FXFT_Open_Args args; | 149 FXFT_Open_Args args; |
153 args.flags = FT_OPEN_STREAM; | 150 args.flags = FT_OPEN_STREAM; |
154 args.stream = stream1; | 151 args.stream = stream1; |
155 if (FXFT_Open_Face(library, &args, faceIndex, Face)) { | 152 if (FXFT_Open_Face(library, &args, faceIndex, Face)) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 203 } |
207 error = FXFT_Set_Pixel_Sizes(face, 64, 64); | 204 error = FXFT_Set_Pixel_Sizes(face, 64, 64); |
208 if (error) { | 205 if (error) { |
209 return NULL; | 206 return NULL; |
210 } | 207 } |
211 return face; | 208 return face; |
212 } | 209 } |
213 FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size) | 210 FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size) |
214 { | 211 { |
215 m_pFontDataAllocation = FX_Alloc(FX_BYTE, size); | 212 m_pFontDataAllocation = FX_Alloc(FX_BYTE, size); |
216 if (!m_pFontDataAllocation) { | |
217 return FALSE; | |
218 } | |
219 FXSYS_memcpy32(m_pFontDataAllocation, data, size); | 213 FXSYS_memcpy32(m_pFontDataAllocation, data, size); |
220 m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size); | 214 m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size); |
221 m_pFontData = (FX_LPBYTE)m_pFontDataAllocation; | 215 m_pFontData = (FX_LPBYTE)m_pFontDataAllocation; |
222 m_bEmbedded = TRUE; | 216 m_bEmbedded = TRUE; |
223 m_dwSize = size; | 217 m_dwSize = size; |
224 return m_Face != NULL; | 218 return m_Face != NULL; |
225 } | 219 } |
226 FX_BOOL CFX_Font::IsTTFont() | 220 FX_BOOL CFX_Font::IsTTFont() |
227 { | 221 { |
228 if (m_Face == NULL) { | 222 if (m_Face == NULL) { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 631 } |
638 static int s_count = sizeof(gs_EncodingID) / sizeof(FX_DWORD); | 632 static int s_count = sizeof(gs_EncodingID) / sizeof(FX_DWORD); |
639 for (int i = 0; i < s_count; i++) { | 633 for (int i = 0; i < s_count; i++) { |
640 IFX_FontEncodingEx* pFontEncoding = _FXFM_CreateFontEncoding(pFont, gs_E
ncodingID[i]); | 634 IFX_FontEncodingEx* pFontEncoding = _FXFM_CreateFontEncoding(pFont, gs_E
ncodingID[i]); |
641 if (pFontEncoding) { | 635 if (pFontEncoding) { |
642 return pFontEncoding; | 636 return pFontEncoding; |
643 } | 637 } |
644 } | 638 } |
645 return NULL; | 639 return NULL; |
646 } | 640 } |
OLD | NEW |