Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/child/pdf_child_init.cc

Issue 906923003: Fix fonts not loading in PDFs that don't embed them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 #include "chrome/child/pdf_child_init.h" 5 #include "chrome/child/pdf_child_init.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 DWORD offset, 43 DWORD offset,
44 LPVOID buffer, 44 LPVOID buffer,
45 DWORD length) { 45 DWORD length) {
46 int rv = g_original_get_font_data(hdc, table, offset, buffer, length); 46 int rv = g_original_get_font_data(hdc, table, offset, buffer, length);
47 if (rv == GDI_ERROR && hdc) { 47 if (rv == GDI_ERROR && hdc) {
48 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); 48 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT));
49 49
50 LOGFONT logfont; 50 LOGFONT logfont;
51 if (GetObject(font, sizeof(LOGFONT), &logfont)) { 51 if (GetObject(font, sizeof(LOGFONT), &logfont)) {
52 std::vector<char> font_data; 52 std::vector<char> font_data;
53 content::ChildThread::Get()->PreCacheFont(logfont); 53 if (content::ChildThread::Get())
54 content::ChildThread::Get()->PreCacheFont(logfont);
54 rv = g_original_get_font_data(hdc, table, offset, buffer, length); 55 rv = g_original_get_font_data(hdc, table, offset, buffer, length);
55 content::ChildThread::Get()->ReleaseCachedFonts(); 56 if (content::ChildThread::Get())
57 content::ChildThread::Get()->ReleaseCachedFonts();
56 } 58 }
57 } 59 }
58 return rv; 60 return rv;
59 } 61 }
60 #endif // OS_WIN 62 #endif // OS_WIN
61 63
62 } // namespace 64 } // namespace
63 65
64 void InitializePDF() { 66 void InitializePDF() {
65 #if defined(OS_WIN) 67 #if defined(OS_WIN)
(...skipping 11 matching lines...) Expand all
77 g_iat_patch_createdca.Patch(current_module_name, "gdi32.dll", "CreateDCA", 79 g_iat_patch_createdca.Patch(current_module_name, "gdi32.dll", "CreateDCA",
78 CreateDCAPatch); 80 CreateDCAPatch);
79 g_iat_patch_get_font_data.Patch(current_module_name, "gdi32.dll", 81 g_iat_patch_get_font_data.Patch(current_module_name, "gdi32.dll",
80 "GetFontData", GetFontDataPatch); 82 "GetFontData", GetFontDataPatch);
81 g_original_get_font_data = reinterpret_cast<GetFontDataPtr>( 83 g_original_get_font_data = reinterpret_cast<GetFontDataPtr>(
82 g_iat_patch_get_font_data.original_function()); 84 g_iat_patch_get_font_data.original_function());
83 #endif // OS_WIN 85 #endif // OS_WIN
84 } 86 }
85 87
86 } // namespace chrome 88 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698