| 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/fx_system.h" | 7 #include "core/fxcrt/fx_system.h" |
| 8 | 8 |
| 9 #if _FX_OS_ == _FX_ANDROID_ | 9 #if _FX_OS_ == _FX_ANDROID_ |
| 10 | 10 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 args.flags = FT_OPEN_MEMORY; | 392 args.flags = FT_OPEN_MEMORY; |
| 393 args.memory_base = pBuffer; | 393 args.memory_base = pBuffer; |
| 394 args.memory_size = szBuffer; | 394 args.memory_size = szBuffer; |
| 395 FXFT_Face face; | 395 FXFT_Face face; |
| 396 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { | 396 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { |
| 397 return FALSE; | 397 return FALSE; |
| 398 } | 398 } |
| 399 FXFT_Set_Pixel_Sizes(face, 0, 64); | 399 FXFT_Set_Pixel_Sizes(face, 0, 64); |
| 400 return face; | 400 return face; |
| 401 } | 401 } |
| 402 |
| 402 void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteString& path) { | 403 void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteString& path) { |
| 403 void* handle = FX_OpenFolder(path.c_str()); | 404 DIR* handle = FX_OpenFolder(path.c_str()); |
| 404 if (!handle) { | 405 if (!handle) { |
| 405 return; | 406 return; |
| 406 } | 407 } |
| 407 CFX_ByteString filename; | 408 CFX_ByteString filename; |
| 408 FX_BOOL bFolder = FALSE; | 409 bool bFolder = false; |
| 409 while (FX_GetNextFile(handle, filename, bFolder)) { | 410 while (FX_GetNextFile(handle, &filename, &bFolder)) { |
| 410 if (bFolder) { | 411 if (bFolder) { |
| 411 if (filename == "." || filename == "..") { | 412 if (filename == "." || filename == "..") |
| 412 continue; | 413 continue; |
| 413 } | |
| 414 } else { | 414 } else { |
| 415 CFX_ByteString ext = filename.Right(4); | 415 CFX_ByteString ext = filename.Right(4); |
| 416 ext.MakeLower(); | 416 ext.MakeLower(); |
| 417 if (ext != ".ttf" && ext != ".ttc" && ext != ".otf") { | 417 if (ext != ".ttf" && ext != ".ttc" && ext != ".otf") |
| 418 continue; | 418 continue; |
| 419 } | |
| 420 } | 419 } |
| 421 CFX_ByteString fullpath(path); | 420 CFX_ByteString fullpath(path); |
| 422 fullpath += "/"; | 421 fullpath += "/"; |
| 423 fullpath += filename; | 422 fullpath += filename; |
| 424 if (bFolder) { | 423 if (bFolder) |
| 425 ScanPath(fullpath); | 424 ScanPath(fullpath); |
| 426 } else { | 425 else |
| 427 ScanFile(fullpath); | 426 ScanFile(fullpath); |
| 428 } | |
| 429 } | 427 } |
| 430 FX_CloseFolder(handle); | 428 FX_CloseFolder(handle); |
| 431 } | 429 } |
| 430 |
| 432 void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteString& file) { | 431 void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteString& file) { |
| 433 FXFT_Face face = GetFontFace(file.AsStringC()); | 432 FXFT_Face face = GetFontFace(file.AsStringC()); |
| 434 if (face) { | 433 if (face) { |
| 435 CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont; | 434 CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont; |
| 436 pFontDesc->SetPath(file.c_str()); | 435 pFontDesc->SetPath(file.c_str()); |
| 437 ReportFace(face, pFontDesc); | 436 ReportFace(face, pFontDesc); |
| 438 m_FontFaces.push_back(pFontDesc); | 437 m_FontFaces.push_back(pFontDesc); |
| 439 FXFT_Done_Face(face); | 438 FXFT_Done_Face(face); |
| 440 } | 439 } |
| 441 } | 440 } |
| 441 |
| 442 static const uint32_t g_FPFSkiaFontCharsets[] = { | 442 static const uint32_t g_FPFSkiaFontCharsets[] = { |
| 443 FPF_SKIACHARSET_Ansi, | 443 FPF_SKIACHARSET_Ansi, |
| 444 FPF_SKIACHARSET_EeasternEuropean, | 444 FPF_SKIACHARSET_EeasternEuropean, |
| 445 FPF_SKIACHARSET_Cyrillic, | 445 FPF_SKIACHARSET_Cyrillic, |
| 446 FPF_SKIACHARSET_Greek, | 446 FPF_SKIACHARSET_Greek, |
| 447 FPF_SKIACHARSET_Turkish, | 447 FPF_SKIACHARSET_Turkish, |
| 448 FPF_SKIACHARSET_Hebrew, | 448 FPF_SKIACHARSET_Hebrew, |
| 449 FPF_SKIACHARSET_Arabic, | 449 FPF_SKIACHARSET_Arabic, |
| 450 FPF_SKIACHARSET_Baltic, | 450 FPF_SKIACHARSET_Baltic, |
| 451 0, | 451 0, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 466 0, | 466 0, |
| 467 0, | 467 0, |
| 468 0, | 468 0, |
| 469 0, | 469 0, |
| 470 0, | 470 0, |
| 471 0, | 471 0, |
| 472 0, | 472 0, |
| 473 FPF_SKIACHARSET_OEM, | 473 FPF_SKIACHARSET_OEM, |
| 474 FPF_SKIACHARSET_Symbol, | 474 FPF_SKIACHARSET_Symbol, |
| 475 }; | 475 }; |
| 476 |
| 476 static uint32_t FPF_SkiaGetFaceCharset(TT_OS2* pOS2) { | 477 static uint32_t FPF_SkiaGetFaceCharset(TT_OS2* pOS2) { |
| 477 uint32_t dwCharset = 0; | 478 uint32_t dwCharset = 0; |
| 478 if (pOS2) { | 479 if (pOS2) { |
| 479 for (int32_t i = 0; i < 32; i++) { | 480 for (int32_t i = 0; i < 32; i++) { |
| 480 if (pOS2->ulCodePageRange1 & (1 << i)) { | 481 if (pOS2->ulCodePageRange1 & (1 << i)) { |
| 481 dwCharset |= g_FPFSkiaFontCharsets[i]; | 482 dwCharset |= g_FPFSkiaFontCharsets[i]; |
| 482 } | 483 } |
| 483 } | 484 } |
| 484 } | 485 } |
| 485 dwCharset |= FPF_SKIACHARSET_Default; | 486 dwCharset |= FPF_SKIACHARSET_Default; |
| 486 return dwCharset; | 487 return dwCharset; |
| 487 } | 488 } |
| 489 |
| 488 void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, | 490 void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, |
| 489 CFPF_SkiaFontDescriptor* pFontDesc) { | 491 CFPF_SkiaFontDescriptor* pFontDesc) { |
| 490 if (!face || !pFontDesc) { | 492 if (!face || !pFontDesc) { |
| 491 return; | 493 return; |
| 492 } | 494 } |
| 493 pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face)); | 495 pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face)); |
| 494 if (FXFT_Is_Face_Bold(face)) { | 496 if (FXFT_Is_Face_Bold(face)) { |
| 495 pFontDesc->m_dwStyle |= FXFONT_BOLD; | 497 pFontDesc->m_dwStyle |= FXFONT_BOLD; |
| 496 } | 498 } |
| 497 if (FXFT_Is_Face_Italic(face)) { | 499 if (FXFT_Is_Face_Italic(face)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 512 } | 514 } |
| 513 } | 515 } |
| 514 } | 516 } |
| 515 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) { | 517 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) { |
| 516 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; | 518 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; |
| 517 } | 519 } |
| 518 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); | 520 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); |
| 519 pFontDesc->m_iFaceIndex = face->face_index; | 521 pFontDesc->m_iFaceIndex = face->face_index; |
| 520 pFontDesc->m_iGlyphNum = face->num_glyphs; | 522 pFontDesc->m_iGlyphNum = face->num_glyphs; |
| 521 } | 523 } |
| 524 |
| 522 void CFPF_SkiaFontMgr::OutputSystemFonts() {} | 525 void CFPF_SkiaFontMgr::OutputSystemFonts() {} |
| 523 #endif | 526 #endif |
| OLD | NEW |