| 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 "core/fxcrt/include/fx_system.h" | 7 #include "core/fxcrt/include/fx_system.h" |
| 8 | 8 |
| 9 #if _FX_OS_ == _FX_ANDROID_ | 9 #if _FX_OS_ == _FX_ANDROID_ |
| 10 | 10 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 case FXFONT_THAI_CHARSET: | 169 case FXFONT_THAI_CHARSET: |
| 170 return FPF_SKIACHARSET_Thai; | 170 return FPF_SKIACHARSET_Thai; |
| 171 case FXFONT_EASTEUROPE_CHARSET: | 171 case FXFONT_EASTEUROPE_CHARSET: |
| 172 return FPF_SKIACHARSET_EeasternEuropean; | 172 return FPF_SKIACHARSET_EeasternEuropean; |
| 173 } | 173 } |
| 174 return FPF_SKIACHARSET_Default; | 174 return FPF_SKIACHARSET_Default; |
| 175 } | 175 } |
| 176 static uint32_t FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) { | 176 static uint32_t FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) { |
| 177 uint32_t dwHash = 0; | 177 uint32_t dwHash = 0; |
| 178 int32_t iLength = bsfamily.GetLength(); | 178 int32_t iLength = bsfamily.GetLength(); |
| 179 const FX_CHAR* pBuffer = bsfamily.GetCStr(); | 179 const FX_CHAR* pBuffer = bsfamily.c_str(); |
| 180 for (int32_t i = 0; i < iLength; i++) { | 180 for (int32_t i = 0; i < iLength; i++) { |
| 181 FX_CHAR ch = pBuffer[i]; | 181 FX_CHAR ch = pBuffer[i]; |
| 182 if (ch == ' ' || ch == '-' || ch == ',') { | 182 if (ch == ' ' || ch == '-' || ch == ',') { |
| 183 continue; | 183 continue; |
| 184 } | 184 } |
| 185 dwHash = 31 * dwHash + FXSYS_tolower(ch); | 185 dwHash = 31 * dwHash + FXSYS_tolower(ch); |
| 186 } | 186 } |
| 187 return dwHash; | 187 return dwHash; |
| 188 } | 188 } |
| 189 static uint32_t FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily, | 189 static uint32_t FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile, | 365 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile, |
| 366 int32_t iFaceIndex) { | 366 int32_t iFaceIndex) { |
| 367 if (bsFile.IsEmpty()) { | 367 if (bsFile.IsEmpty()) { |
| 368 return NULL; | 368 return NULL; |
| 369 } | 369 } |
| 370 if (iFaceIndex < 0) { | 370 if (iFaceIndex < 0) { |
| 371 return NULL; | 371 return NULL; |
| 372 } | 372 } |
| 373 FXFT_Open_Args args; | 373 FXFT_Open_Args args; |
| 374 args.flags = FT_OPEN_PATHNAME; | 374 args.flags = FT_OPEN_PATHNAME; |
| 375 args.pathname = (FT_String*)bsFile.GetCStr(); | 375 args.pathname = static_cast<FT_String*>(bsFile.c_str()); |
| 376 FXFT_Face face; | 376 FXFT_Face face; |
| 377 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { | 377 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { |
| 378 return FALSE; | 378 return FALSE; |
| 379 } | 379 } |
| 380 FXFT_Set_Pixel_Sizes(face, 0, 64); | 380 FXFT_Set_Pixel_Sizes(face, 0, 64); |
| 381 return face; | 381 return face; |
| 382 } | 382 } |
| 383 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, | 383 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, |
| 384 size_t szBuffer, | 384 size_t szBuffer, |
| 385 int32_t iFaceIndex) { | 385 int32_t iFaceIndex) { |
| 386 if (!pBuffer || szBuffer < 1) { | 386 if (!pBuffer || szBuffer < 1) { |
| 387 return NULL; | 387 return NULL; |
| 388 } | 388 } |
| 389 if (iFaceIndex < 0) { | 389 if (iFaceIndex < 0) { |
| 390 return NULL; | 390 return NULL; |
| 391 } | 391 } |
| 392 FXFT_Open_Args args; | 392 FXFT_Open_Args args; |
| 393 args.flags = FT_OPEN_MEMORY; | 393 args.flags = FT_OPEN_MEMORY; |
| 394 args.memory_base = pBuffer; | 394 args.memory_base = pBuffer; |
| 395 args.memory_size = szBuffer; | 395 args.memory_size = szBuffer; |
| 396 FXFT_Face face; | 396 FXFT_Face face; |
| 397 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { | 397 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { |
| 398 return FALSE; | 398 return FALSE; |
| 399 } | 399 } |
| 400 FXFT_Set_Pixel_Sizes(face, 0, 64); | 400 FXFT_Set_Pixel_Sizes(face, 0, 64); |
| 401 return face; | 401 return face; |
| 402 } | 402 } |
| 403 void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteStringC& path) { | 403 void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteStringC& path) { |
| 404 void* handle = FX_OpenFolder(path.GetCStr()); | 404 void* handle = FX_OpenFolder(path.c_str()); |
| 405 if (!handle) { | 405 if (!handle) { |
| 406 return; | 406 return; |
| 407 } | 407 } |
| 408 CFX_ByteString filename; | 408 CFX_ByteString filename; |
| 409 FX_BOOL bFolder = FALSE; | 409 FX_BOOL bFolder = FALSE; |
| 410 while (FX_GetNextFile(handle, filename, bFolder)) { | 410 while (FX_GetNextFile(handle, filename, bFolder)) { |
| 411 if (bFolder) { | 411 if (bFolder) { |
| 412 if (filename == "." || filename == "..") { | 412 if (filename == "." || filename == "..") { |
| 413 continue; | 413 continue; |
| 414 } | 414 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 427 } else { | 427 } else { |
| 428 ScanFile(fullpath); | 428 ScanFile(fullpath); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 FX_CloseFolder(handle); | 431 FX_CloseFolder(handle); |
| 432 } | 432 } |
| 433 void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteStringC& file) { | 433 void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteStringC& file) { |
| 434 FXFT_Face face = GetFontFace(file); | 434 FXFT_Face face = GetFontFace(file); |
| 435 if (face) { | 435 if (face) { |
| 436 CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont; | 436 CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont; |
| 437 pFontDesc->SetPath(file.GetCStr()); | 437 pFontDesc->SetPath(file.c_str()); |
| 438 ReportFace(face, pFontDesc); | 438 ReportFace(face, pFontDesc); |
| 439 m_FontFaces.push_back(pFontDesc); | 439 m_FontFaces.push_back(pFontDesc); |
| 440 FXFT_Done_Face(face); | 440 FXFT_Done_Face(face); |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 static const uint32_t g_FPFSkiaFontCharsets[] = { | 443 static const uint32_t g_FPFSkiaFontCharsets[] = { |
| 444 FPF_SKIACHARSET_Ansi, | 444 FPF_SKIACHARSET_Ansi, |
| 445 FPF_SKIACHARSET_EeasternEuropean, | 445 FPF_SKIACHARSET_EeasternEuropean, |
| 446 FPF_SKIACHARSET_Cyrillic, | 446 FPF_SKIACHARSET_Cyrillic, |
| 447 FPF_SKIACHARSET_Greek, | 447 FPF_SKIACHARSET_Greek, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 515 } |
| 516 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) { | 516 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) { |
| 517 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; | 517 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; |
| 518 } | 518 } |
| 519 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); | 519 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); |
| 520 pFontDesc->m_iFaceIndex = face->face_index; | 520 pFontDesc->m_iFaceIndex = face->face_index; |
| 521 pFontDesc->m_iGlyphNum = face->num_glyphs; | 521 pFontDesc->m_iGlyphNum = face->num_glyphs; |
| 522 } | 522 } |
| 523 void CFPF_SkiaFontMgr::OutputSystemFonts() {} | 523 void CFPF_SkiaFontMgr::OutputSystemFonts() {} |
| 524 #endif | 524 #endif |
| OLD | NEW |