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 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 } | 452 } |
453 | 453 |
454 m_pMapper->AddInstalledFont(name, plf->lfCharSet); | 454 m_pMapper->AddInstalledFont(name, plf->lfCharSet); |
455 m_LastFamily = name; | 455 m_LastFamily = name; |
456 } | 456 } |
457 | 457 |
458 FX_BOOL CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) { | 458 FX_BOOL CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) { |
459 m_pMapper = pMapper; | 459 m_pMapper = pMapper; |
460 LOGFONTA lf; | 460 LOGFONTA lf; |
461 FXSYS_memset(&lf, 0, sizeof(LOGFONTA)); | 461 FXSYS_memset(&lf, 0, sizeof(LOGFONTA)); |
462 lf.lfCharSet = DEFAULT_CHARSET; | 462 lf.lfCharSet = FXFONT_DEFAULT_CHARSET; |
463 lf.lfFaceName[0] = 0; | 463 lf.lfFaceName[0] = 0; |
464 lf.lfPitchAndFamily = 0; | 464 lf.lfPitchAndFamily = 0; |
465 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this, | 465 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this, |
466 0); | 466 0); |
467 return TRUE; | 467 return TRUE; |
468 } | 468 } |
469 | 469 |
470 CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) { | 470 CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) { |
471 if (!m_pMapper) | 471 if (!m_pMapper) |
472 return name; | 472 return name; |
(...skipping 20 matching lines...) Expand all Loading... |
493 void* font = GetSubstFont(cstr_face); | 493 void* font = GetSubstFont(cstr_face); |
494 if (font) { | 494 if (font) { |
495 iExact = 1; | 495 iExact = 1; |
496 return font; | 496 return font; |
497 } | 497 } |
498 FX_BOOL bCJK = TRUE; | 498 FX_BOOL bCJK = TRUE; |
499 switch (charset) { | 499 switch (charset) { |
500 case FXFONT_SHIFTJIS_CHARSET: | 500 case FXFONT_SHIFTJIS_CHARSET: |
501 case FXFONT_GB2312_CHARSET: | 501 case FXFONT_GB2312_CHARSET: |
502 case FXFONT_CHINESEBIG5_CHARSET: | 502 case FXFONT_CHINESEBIG5_CHARSET: |
503 case FXFONT_HANGEUL_CHARSET: | 503 case FXFONT_HANGUL_CHARSET: |
504 default: | 504 default: |
505 bCJK = FALSE; | 505 bCJK = FALSE; |
506 break; | 506 break; |
507 } | 507 } |
508 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); | 508 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); |
509 } | 509 } |
510 | 510 |
511 void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face, | 511 void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face, |
512 int weight, | 512 int weight, |
513 int picth_family) { | 513 int picth_family) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 CFX_ByteString face = cstr_face; | 585 CFX_ByteString face = cstr_face; |
586 int iBaseFont; | 586 int iBaseFont; |
587 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) | 587 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) |
588 if (face == CFX_ByteStringC(g_Base14Substs[iBaseFont].m_pName)) { | 588 if (face == CFX_ByteStringC(g_Base14Substs[iBaseFont].m_pName)) { |
589 face = g_Base14Substs[iBaseFont].m_pWinName; | 589 face = g_Base14Substs[iBaseFont].m_pWinName; |
590 weight = g_Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; | 590 weight = g_Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; |
591 bItalic = g_Base14Substs[iBaseFont].m_bItalic; | 591 bItalic = g_Base14Substs[iBaseFont].m_bItalic; |
592 iExact = TRUE; | 592 iExact = TRUE; |
593 break; | 593 break; |
594 } | 594 } |
595 if (charset == ANSI_CHARSET || charset == SYMBOL_CHARSET) { | 595 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { |
596 charset = DEFAULT_CHARSET; | 596 charset = FXFONT_DEFAULT_CHARSET; |
597 } | 597 } |
598 int subst_pitch_family = pitch_family; | 598 int subst_pitch_family = pitch_family; |
599 switch (charset) { | 599 switch (charset) { |
600 case SHIFTJIS_CHARSET: | 600 case FXFONT_SHIFTJIS_CHARSET: |
601 subst_pitch_family = FF_ROMAN; | 601 subst_pitch_family = FF_ROMAN; |
602 break; | 602 break; |
603 case CHINESEBIG5_CHARSET: | 603 case FXFONT_CHINESEBIG5_CHARSET: |
604 case HANGUL_CHARSET: | 604 case FXFONT_HANGUL_CHARSET: |
605 case GB2312_CHARSET: | 605 case FXFONT_GB2312_CHARSET: |
606 subst_pitch_family = 0; | 606 subst_pitch_family = 0; |
607 break; | 607 break; |
608 } | 608 } |
609 HFONT hFont = | 609 HFONT hFont = |
610 ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset, | 610 ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset, |
611 OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str()); | 611 OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str()); |
612 char facebuf[100]; | 612 char facebuf[100]; |
613 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, hFont); | 613 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, hFont); |
614 ::GetTextFaceA(m_hDC, 100, facebuf); | 614 ::GetTextFaceA(m_hDC, 100, facebuf); |
615 ::SelectObject(m_hDC, hOldFont); | 615 ::SelectObject(m_hDC, hOldFont); |
616 if (face.EqualNoCase(facebuf)) | 616 if (face.EqualNoCase(facebuf)) |
617 return hFont; | 617 return hFont; |
618 | 618 |
619 CFX_WideString wsFace = CFX_WideString::FromLocal(facebuf); | 619 CFX_WideString wsFace = CFX_WideString::FromLocal(facebuf); |
620 for (size_t i = 0; i < FX_ArraySize(g_VariantNames); ++i) { | 620 for (size_t i = 0; i < FX_ArraySize(g_VariantNames); ++i) { |
621 if (face != g_VariantNames[i].m_pFaceName) | 621 if (face != g_VariantNames[i].m_pFaceName) |
622 continue; | 622 continue; |
623 | 623 |
624 const unsigned short* pName = reinterpret_cast<const unsigned short*>( | 624 const unsigned short* pName = reinterpret_cast<const unsigned short*>( |
625 g_VariantNames[i].m_pVariantName); | 625 g_VariantNames[i].m_pVariantName); |
626 FX_STRSIZE len = CFX_WideString::WStringLength(pName); | 626 FX_STRSIZE len = CFX_WideString::WStringLength(pName); |
627 CFX_WideString wsName = CFX_WideString::FromUTF16LE(pName, len); | 627 CFX_WideString wsName = CFX_WideString::FromUTF16LE(pName, len); |
628 if (wsFace == wsName) | 628 if (wsFace == wsName) |
629 return hFont; | 629 return hFont; |
630 } | 630 } |
631 ::DeleteObject(hFont); | 631 ::DeleteObject(hFont); |
632 if (charset == DEFAULT_CHARSET) | 632 if (charset == FXFONT_DEFAULT_CHARSET) |
633 return nullptr; | 633 return nullptr; |
634 | 634 |
635 switch (charset) { | 635 switch (charset) { |
636 case SHIFTJIS_CHARSET: | 636 case FXFONT_SHIFTJIS_CHARSET: |
637 GetJapanesePreference(face, weight, pitch_family); | 637 GetJapanesePreference(face, weight, pitch_family); |
638 break; | 638 break; |
639 case GB2312_CHARSET: | 639 case FXFONT_GB2312_CHARSET: |
640 GetGBPreference(face, weight, pitch_family); | 640 GetGBPreference(face, weight, pitch_family); |
641 break; | 641 break; |
642 case HANGUL_CHARSET: | 642 case FXFONT_HANGUL_CHARSET: |
643 face = "Gulim"; | 643 face = "Gulim"; |
644 break; | 644 break; |
645 case CHINESEBIG5_CHARSET: | 645 case FXFONT_CHINESEBIG5_CHARSET: |
646 if (face.Find("MSung") >= 0) { | 646 if (face.Find("MSung") >= 0) { |
647 face = "MingLiU"; | 647 face = "MingLiU"; |
648 } else { | 648 } else { |
649 face = "PMingLiU"; | 649 face = "PMingLiU"; |
650 } | 650 } |
651 break; | 651 break; |
652 } | 652 } |
653 hFont = | 653 hFont = |
654 ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset, | 654 ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset, |
655 OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str()); | 655 OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str()); |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); | 1387 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); |
1388 int obj_type = ::GetObjectType(hDC); | 1388 int obj_type = ::GetObjectType(hDC); |
1389 bool use_printer = device_type == DT_RASPRINTER || | 1389 bool use_printer = device_type == DT_RASPRINTER || |
1390 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC; | 1390 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC; |
1391 if (use_printer) | 1391 if (use_printer) |
1392 return new CGdiPrinterDriver(hDC); | 1392 return new CGdiPrinterDriver(hDC); |
1393 return new CGdiDisplayDriver(hDC); | 1393 return new CGdiDisplayDriver(hDC); |
1394 } | 1394 } |
1395 | 1395 |
1396 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ | 1396 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
OLD | NEW |