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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 { | 514 { |
515 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; | 515 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; |
516 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { | 516 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { |
517 return FALSE; | 517 return FALSE; |
518 } | 518 } |
519 if ((pBitmap->IsCmykImage() || pIccTransform) && | 519 if ((pBitmap->IsCmykImage() || pIccTransform) && |
520 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { | 520 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { |
521 return FALSE; | 521 return FALSE; |
522 } | 522 } |
523 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 523 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
524 if ((FX_INT64)abs(dest_width) * abs(dest_height) < (FX_INT64)pBitmap1->GetWi
dth() * pBitmap1->GetHeight() * 4 || | 524 if ((int64_t)abs(dest_width) * abs(dest_height) < (int64_t)pBitmap1->GetWidt
h() * pBitmap1->GetHeight() * 4 || |
525 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { | 525 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { |
526 SetStretchBltMode(m_hDC, HALFTONE); | 526 SetStretchBltMode(m_hDC, HALFTONE); |
527 } else { | 527 } else { |
528 SetStretchBltMode(m_hDC, COLORONCOLOR); | 528 SetStretchBltMode(m_hDC, COLORONCOLOR); |
529 } | 529 } |
530 CFX_DIBitmap* pToStrechBitmap = pBitmap; | 530 CFX_DIBitmap* pToStrechBitmap = pBitmap; |
531 bool del = false; | 531 bool del = false; |
532 if (m_DeviceClass == FXDC_PRINTER && ((FX_INT64)pBitmap->GetWidth() * pBitma
p->GetHeight() > (FX_INT64)abs(dest_width) * abs(dest_height))) { | 532 if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap
->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { |
533 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); | 533 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); |
534 del = true; | 534 del = true; |
535 } | 535 } |
536 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB
itmap); | 536 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB
itmap); |
537 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, | 537 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, |
538 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh
t(), pToStrechBitmap->GetBuffer(), | 538 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh
t(), pToStrechBitmap->GetBuffer(), |
539 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC
COPY); | 539 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC
COPY); |
540 if (del) { | 540 if (del) { |
541 delete pToStrechBitmap; | 541 delete pToStrechBitmap; |
542 } | 542 } |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 if (m_hDC) { | 1206 if (m_hDC) { |
1207 SelectObject(m_hDC, m_hOldBitmap); | 1207 SelectObject(m_hDC, m_hOldBitmap); |
1208 DeleteDC(m_hDC); | 1208 DeleteDC(m_hDC); |
1209 } | 1209 } |
1210 if (m_hBitmap) { | 1210 if (m_hBitmap) { |
1211 DeleteObject(m_hBitmap); | 1211 DeleteObject(m_hBitmap); |
1212 } | 1212 } |
1213 delete GetBitmap(); | 1213 delete GetBitmap(); |
1214 } | 1214 } |
1215 #endif | 1215 #endif |
OLD | NEW |