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 "fx_fpf.h" | 7 #include "fx_fpf.h" |
8 #if _FX_OS_ == _FX_ANDROID_ | 8 #if _FX_OS_ == _FX_ANDROID_ |
9 #define FPF_SKIAMATCHWEIGHT_NAME1 62 | 9 #define FPF_SKIAMATCHWEIGHT_NAME1 62 |
10 #define FPF_SKIAMATCHWEIGHT_NAME2 60 | 10 #define FPF_SKIAMATCHWEIGHT_NAME2 60 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (dwHash < pItem->dwFamily) { | 96 if (dwHash < pItem->dwFamily) { |
97 iEnd = iMid - 1; | 97 iEnd = iMid - 1; |
98 } else if (dwHash > pItem->dwFamily) { | 98 } else if (dwHash > pItem->dwFamily) { |
99 iStart = iMid + 1; | 99 iStart = iMid + 1; |
100 } else { | 100 } else { |
101 return pItem->dwSubSt; | 101 return pItem->dwSubSt; |
102 } | 102 } |
103 } | 103 } |
104 return 0; | 104 return 0; |
105 } | 105 } |
106 static uint32_t FPF_GetHashCode_StringA(FX_LPCSTR pStr, int32_t iLength, FX_BOOL
bIgnoreCase = FALSE) | 106 static uint32_t FPF_GetHashCode_StringA(const FX_CHAR* pStr, int32_t iLength, FX
_BOOL bIgnoreCase = FALSE) |
107 { | 107 { |
108 if (!pStr) { | 108 if (!pStr) { |
109 return 0; | 109 return 0; |
110 } | 110 } |
111 if (iLength < 0) { | 111 if (iLength < 0) { |
112 iLength = FXSYS_strlen(pStr); | 112 iLength = FXSYS_strlen(pStr); |
113 } | 113 } |
114 FX_LPCSTR pStrEnd = pStr + iLength; | 114 const FX_CHAR* pStrEnd = pStr + iLength; |
115 uint32_t uHashCode = 0; | 115 uint32_t uHashCode = 0; |
116 if (bIgnoreCase) { | 116 if (bIgnoreCase) { |
117 while (pStr < pStrEnd) { | 117 while (pStr < pStrEnd) { |
118 uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++); | 118 uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++); |
119 } | 119 } |
120 } else { | 120 } else { |
121 while (pStr < pStrEnd) { | 121 while (pStr < pStrEnd) { |
122 uHashCode = 31 * uHashCode + *pStr ++; | 122 uHashCode = 31 * uHashCode + *pStr ++; |
123 } | 123 } |
124 } | 124 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return FPF_SKIACHARSET_Thai; | 178 return FPF_SKIACHARSET_Thai; |
179 case FXFONT_EASTEUROPE_CHARSET: | 179 case FXFONT_EASTEUROPE_CHARSET: |
180 return FPF_SKIACHARSET_EeasternEuropean; | 180 return FPF_SKIACHARSET_EeasternEuropean; |
181 } | 181 } |
182 return FPF_SKIACHARSET_Default; | 182 return FPF_SKIACHARSET_Default; |
183 } | 183 } |
184 static FX_DWORD FPF_SKIANormalizeFontName(FX_BSTR bsfamily) | 184 static FX_DWORD FPF_SKIANormalizeFontName(FX_BSTR bsfamily) |
185 { | 185 { |
186 FX_DWORD dwHash = 0; | 186 FX_DWORD dwHash = 0; |
187 int32_t iLength = bsfamily.GetLength(); | 187 int32_t iLength = bsfamily.GetLength(); |
188 FX_LPCSTR pBuffer = bsfamily.GetCStr(); | 188 const FX_CHAR* pBuffer = bsfamily.GetCStr(); |
189 for (int32_t i = 0; i < iLength; i++) { | 189 for (int32_t i = 0; i < iLength; i++) { |
190 FX_CHAR ch = pBuffer[i]; | 190 FX_CHAR ch = pBuffer[i]; |
191 if (ch == ' ' || ch == '-' || ch == ',') { | 191 if (ch == ' ' || ch == '-' || ch == ',') { |
192 continue; | 192 continue; |
193 } | 193 } |
194 dwHash = 31 * dwHash + FXSYS_tolower(ch); | 194 dwHash = 31 * dwHash + FXSYS_tolower(ch); |
195 } | 195 } |
196 return dwHash; | 196 return dwHash; |
197 } | 197 } |
198 static FX_DWORD FPF_SKIAGetFamilyHash(FX_BSTR bsFamily, FX_DWORD dwStyle, uint8_
t uCharset) | 198 static FX_DWORD FPF_SKIAGetFamilyHash(FX_BSTR bsFamily, FX_DWORD dwStyle, uint8_
t uCharset) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 ScanPath(FX_BSTRC("/system/fonts")); | 269 ScanPath(FX_BSTRC("/system/fonts")); |
270 OutputSystemFonts(); | 270 OutputSystemFonts(); |
271 m_bLoaded = TRUE; | 271 m_bLoaded = TRUE; |
272 } | 272 } |
273 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) | 273 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) |
274 { | 274 { |
275 } | 275 } |
276 void CFPF_SkiaFontMgr::LoadPrivateFont(FX_BSTR bsFileName) | 276 void CFPF_SkiaFontMgr::LoadPrivateFont(FX_BSTR bsFileName) |
277 { | 277 { |
278 } | 278 } |
279 void CFPF_SkiaFontMgr::LoadPrivateFont(FX_LPVOID pBuffer, size_t szBuffer) | 279 void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) |
280 { | 280 { |
281 } | 281 } |
282 IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, uint8_t uCharset,
FX_DWORD dwStyle, FX_DWORD dwMatch) | 282 IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, uint8_t uCharset,
FX_DWORD dwStyle, FX_DWORD dwMatch) |
283 { | 283 { |
284 FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); | 284 FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); |
285 IFPF_Font *pFont = NULL; | 285 IFPF_Font *pFont = NULL; |
286 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 286 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
287 if (pFont) { | 287 if (pFont) { |
288 return pFont->Retain(); | 288 return pFont->Retain(); |
289 } | 289 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 FXFT_Open_Args args; | 399 FXFT_Open_Args args; |
400 args.flags = FT_OPEN_PATHNAME; | 400 args.flags = FT_OPEN_PATHNAME; |
401 args.pathname = (FT_String*)bsFile.GetCStr(); | 401 args.pathname = (FT_String*)bsFile.GetCStr(); |
402 FXFT_Face face; | 402 FXFT_Face face; |
403 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { | 403 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { |
404 return FALSE; | 404 return FALSE; |
405 } | 405 } |
406 FXFT_Set_Pixel_Sizes(face, 0, 64); | 406 FXFT_Set_Pixel_Sizes(face, 0, 64); |
407 return face; | 407 return face; |
408 } | 408 } |
409 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, int
32_t iFaceIndex ) | 409 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, size_t szBuffer,
int32_t iFaceIndex ) |
410 { | 410 { |
411 if (!pBuffer || szBuffer < 1) { | 411 if (!pBuffer || szBuffer < 1) { |
412 return NULL; | 412 return NULL; |
413 } | 413 } |
414 if (iFaceIndex < 0) { | 414 if (iFaceIndex < 0) { |
415 return NULL; | 415 return NULL; |
416 } | 416 } |
417 FXFT_Open_Args args; | 417 FXFT_Open_Args args; |
418 args.flags = FT_OPEN_MEMORY; | 418 args.flags = FT_OPEN_MEMORY; |
419 args.memory_base = pBuffer; | 419 args.memory_base = pBuffer; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; | 545 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; |
546 } | 546 } |
547 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); | 547 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); |
548 pFontDesc->m_iFaceIndex = face->face_index; | 548 pFontDesc->m_iFaceIndex = face->face_index; |
549 pFontDesc->m_iGlyphNum = face->num_glyphs; | 549 pFontDesc->m_iGlyphNum = face->num_glyphs; |
550 } | 550 } |
551 void CFPF_SkiaFontMgr::OutputSystemFonts() | 551 void CFPF_SkiaFontMgr::OutputSystemFonts() |
552 { | 552 { |
553 } | 553 } |
554 #endif | 554 #endif |
OLD | NEW |