| 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 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ | 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ |
| 9 #include "../../../include/fxge/fx_ge_win32.h" | 9 #include "../../../include/fxge/fx_ge_win32.h" |
| 10 #include <crtdbg.h> | 10 #include <crtdbg.h> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 delete this; | 57 delete this; |
| 58 } | 58 } |
| 59 #define TT_MAKE_TAG(x1, x2, x3, x4) (((FX_DWORD)x1<<24)|((FX_DWORD)x2<<16)|((FX_
DWORD)x3<<8)|(FX_DWORD)x4) | 59 #define TT_MAKE_TAG(x1, x2, x3, x4) (((FX_DWORD)x1<<24)|((FX_DWORD)x2<<16)|((FX_
DWORD)x3<<8)|(FX_DWORD)x4) |
| 60 FX_BOOL CWin32FontInfo::IsOpenTypeFromDiv(const LOGFONTA *plf) | 60 FX_BOOL CWin32FontInfo::IsOpenTypeFromDiv(const LOGFONTA *plf) |
| 61 { | 61 { |
| 62 HFONT hFont = CreateFontIndirectA(plf); | 62 HFONT hFont = CreateFontIndirectA(plf); |
| 63 FX_BOOL ret = FALSE; | 63 FX_BOOL ret = FALSE; |
| 64 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); | 64 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); |
| 65 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { | 65 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { |
| 66 FX_DWORD lVersion = 0; | 66 FX_DWORD lVersion = 0; |
| 67 GetFontData(hFont, 0, (FX_BYTE*)(&lVersion), sizeof(FX_DWORD)); | 67 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD)); |
| 68 lVersion = (((FX_DWORD)(FX_BYTE)(lVersion)) << 24) | ((FX_DWORD)((FX_BYT
E)(lVersion >> 8))) << 16 | | 68 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_
t)(lVersion >> 8))) << 16 | |
| 69 ((FX_DWORD)((FX_BYTE)(lVersion >> 16))) << 8 | ((FX_BYTE)(lVe
rsion >> 24)); | 69 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe
rsion >> 24)); |
| 70 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || | 70 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || |
| 71 lVersion == 0x00010000 || | 71 lVersion == 0x00010000 || |
| 72 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || | 72 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || |
| 73 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || | 73 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || |
| 74 lVersion == 0x00020000) { | 74 lVersion == 0x00020000) { |
| 75 ret = TRUE; | 75 ret = TRUE; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 DeleteFont(hFont); | 78 DeleteFont(hFont); |
| 79 return ret; | 79 return ret; |
| 80 } | 80 } |
| 81 FX_BOOL CWin32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) | 81 FX_BOOL CWin32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) |
| 82 { | 82 { |
| 83 HFONT hFont = CreateFontIndirectA(plf); | 83 HFONT hFont = CreateFontIndirectA(plf); |
| 84 FX_BOOL ret = FALSE; | 84 FX_BOOL ret = FALSE; |
| 85 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); | 85 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); |
| 86 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { | 86 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { |
| 87 FX_DWORD lVersion = 0; | 87 FX_DWORD lVersion = 0; |
| 88 GetFontData(hFont, 0, (FX_BYTE*)(&lVersion), sizeof(FX_DWORD)); | 88 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD)); |
| 89 lVersion = (((FX_DWORD)(FX_BYTE)(lVersion)) << 24) | ((FX_DWORD)((FX_BYT
E)(lVersion >> 8))) << 16 | | 89 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_
t)(lVersion >> 8))) << 16 | |
| 90 ((FX_DWORD)((FX_BYTE)(lVersion >> 16))) << 8 | ((FX_BYTE)(lVe
rsion >> 24)); | 90 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe
rsion >> 24)); |
| 91 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || | 91 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || |
| 92 lVersion == 0x00010000 || | 92 lVersion == 0x00010000 || |
| 93 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || | 93 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || |
| 94 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || | 94 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || |
| 95 lVersion == 0x00020000) { | 95 lVersion == 0x00020000) { |
| 96 ret = TRUE; | 96 ret = TRUE; |
| 97 } else if ((lVersion & 0xFFFF0000) == TT_MAKE_TAG(0x80, 0x01, 0x00, 0x00
) || | 97 } else if ((lVersion & 0xFFFF0000) == TT_MAKE_TAG(0x80, 0x01, 0x00, 0x00
) || |
| 98 (lVersion & 0xFFFF0000) == TT_MAKE_TAG('%', '!', 0, 0)) { | 98 (lVersion & 0xFFFF0000) == TT_MAKE_TAG('%', '!', 0, 0)) { |
| 99 ret = TRUE; | 99 ret = TRUE; |
| 100 } | 100 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return 1; | 138 return 1; |
| 139 } | 139 } |
| 140 FX_BOOL CWin32FontInfo::EnumFontList(CFX_FontMapper* pMapper) | 140 FX_BOOL CWin32FontInfo::EnumFontList(CFX_FontMapper* pMapper) |
| 141 { | 141 { |
| 142 m_pMapper = pMapper; | 142 m_pMapper = pMapper; |
| 143 LOGFONTA lf; | 143 LOGFONTA lf; |
| 144 FXSYS_memset32(&lf, 0, sizeof(LOGFONTA)); | 144 FXSYS_memset32(&lf, 0, sizeof(LOGFONTA)); |
| 145 lf.lfCharSet = DEFAULT_CHARSET; | 145 lf.lfCharSet = DEFAULT_CHARSET; |
| 146 lf.lfFaceName[0] = 0; | 146 lf.lfFaceName[0] = 0; |
| 147 lf.lfPitchAndFamily = 0; | 147 lf.lfPitchAndFamily = 0; |
| 148 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (FX_UINTPTR)thi
s, 0); | 148 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t)this
, 0); |
| 149 if (pMapper->GetFontEnumerator()) { | 149 if (pMapper->GetFontEnumerator()) { |
| 150 pMapper->GetFontEnumerator()->Finish(); | 150 pMapper->GetFontEnumerator()->Finish(); |
| 151 } | 151 } |
| 152 return TRUE; | 152 return TRUE; |
| 153 } | 153 } |
| 154 static const struct { | 154 static const struct { |
| 155 FX_LPCSTR m_pFaceName; | 155 FX_LPCSTR m_pFaceName; |
| 156 FX_LPCSTR m_pVariantName; | 156 FX_LPCSTR m_pVariantName; |
| 157 } | 157 } |
| 158 VariantNames[] = { | 158 VariantNames[] = { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 { | 511 { |
| 512 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; | 512 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; |
| 513 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { | 513 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { |
| 514 return FALSE; | 514 return FALSE; |
| 515 } | 515 } |
| 516 if ((pBitmap->IsCmykImage() || pIccTransform) && | 516 if ((pBitmap->IsCmykImage() || pIccTransform) && |
| 517 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { | 517 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { |
| 518 return FALSE; | 518 return FALSE; |
| 519 } | 519 } |
| 520 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 520 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
| 521 if ((FX_INT64)abs(dest_width) * abs(dest_height) < (FX_INT64)pBitmap1->GetWi
dth() * pBitmap1->GetHeight() * 4 || | 521 if ((int64_t)abs(dest_width) * abs(dest_height) < (int64_t)pBitmap1->GetWidt
h() * pBitmap1->GetHeight() * 4 || |
| 522 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { | 522 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { |
| 523 SetStretchBltMode(m_hDC, HALFTONE); | 523 SetStretchBltMode(m_hDC, HALFTONE); |
| 524 } else { | 524 } else { |
| 525 SetStretchBltMode(m_hDC, COLORONCOLOR); | 525 SetStretchBltMode(m_hDC, COLORONCOLOR); |
| 526 } | 526 } |
| 527 CFX_DIBitmap* pToStrechBitmap = pBitmap; | 527 CFX_DIBitmap* pToStrechBitmap = pBitmap; |
| 528 bool del = false; | 528 bool del = false; |
| 529 if (m_DeviceClass == FXDC_PRINTER && ((FX_INT64)pBitmap->GetWidth() * pBitma
p->GetHeight() > (FX_INT64)abs(dest_width) * abs(dest_height))) { | 529 if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap
->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { |
| 530 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); | 530 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); |
| 531 del = true; | 531 del = true; |
| 532 } | 532 } |
| 533 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB
itmap); | 533 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB
itmap); |
| 534 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, | 534 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, |
| 535 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh
t(), pToStrechBitmap->GetBuffer(), | 535 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh
t(), pToStrechBitmap->GetBuffer(), |
| 536 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC
COPY); | 536 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC
COPY); |
| 537 if (del) { | 537 if (del) { |
| 538 delete pToStrechBitmap; | 538 delete pToStrechBitmap; |
| 539 } | 539 } |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 if (m_hDC) { | 1194 if (m_hDC) { |
| 1195 SelectObject(m_hDC, m_hOldBitmap); | 1195 SelectObject(m_hDC, m_hOldBitmap); |
| 1196 DeleteDC(m_hDC); | 1196 DeleteDC(m_hDC); |
| 1197 } | 1197 } |
| 1198 if (m_hBitmap) { | 1198 if (m_hBitmap) { |
| 1199 DeleteObject(m_hBitmap); | 1199 DeleteObject(m_hBitmap); |
| 1200 } | 1200 } |
| 1201 delete GetBitmap(); | 1201 delete GetBitmap(); |
| 1202 } | 1202 } |
| 1203 #endif | 1203 #endif |
| OLD | NEW |