OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "pdf/pdfium/pdfium_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 0, | 313 0, |
314 DeleteFont | 314 DeleteFont |
315 }; | 315 }; |
316 #else | 316 #else |
317 struct FPDF_SYSFONTINFO_WITHMETRICS : public FPDF_SYSFONTINFO { | 317 struct FPDF_SYSFONTINFO_WITHMETRICS : public FPDF_SYSFONTINFO { |
318 explicit FPDF_SYSFONTINFO_WITHMETRICS(FPDF_SYSFONTINFO* sysfontinfo) { | 318 explicit FPDF_SYSFONTINFO_WITHMETRICS(FPDF_SYSFONTINFO* sysfontinfo) { |
319 version = sysfontinfo->version; | 319 version = sysfontinfo->version; |
320 default_sysfontinfo = sysfontinfo; | 320 default_sysfontinfo = sysfontinfo; |
321 } | 321 } |
322 | 322 |
323 ~FPDF_SYSFONTINFO_WITHMETRICS() { delete default_sysfontinfo; } | 323 ~FPDF_SYSFONTINFO_WITHMETRICS() { |
| 324 FPDF_FreeDefaultSystemFontInfo(default_sysfontinfo); |
| 325 } |
324 | 326 |
325 FPDF_SYSFONTINFO* default_sysfontinfo; | 327 FPDF_SYSFONTINFO* default_sysfontinfo; |
326 }; | 328 }; |
327 | 329 |
328 FPDF_SYSFONTINFO_WITHMETRICS* g_font_info = nullptr; | 330 FPDF_SYSFONTINFO_WITHMETRICS* g_font_info = nullptr; |
329 | 331 |
330 void* MapFontWithMetrics(FPDF_SYSFONTINFO* sysfontinfo, | 332 void* MapFontWithMetrics(FPDF_SYSFONTINFO* sysfontinfo, |
331 int weight, | 333 int weight, |
332 int italic, | 334 int italic, |
333 int charset, | 335 int charset, |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 g_font_info->DeleteFont = DeleteFont; | 646 g_font_info->DeleteFont = DeleteFont; |
645 FPDF_SetSystemFontInfo(g_font_info); | 647 FPDF_SetSystemFontInfo(g_font_info); |
646 #endif | 648 #endif |
647 | 649 |
648 FSDK_SetUnSpObjProcessHandler(&g_unsupported_info); | 650 FSDK_SetUnSpObjProcessHandler(&g_unsupported_info); |
649 | 651 |
650 return true; | 652 return true; |
651 } | 653 } |
652 | 654 |
653 void ShutdownSDK() { | 655 void ShutdownSDK() { |
| 656 FPDF_DestroyLibrary(); |
654 #if !defined(OS_LINUX) | 657 #if !defined(OS_LINUX) |
655 FPDF_FreeDefaultSystemFontInfo(g_font_info->default_sysfontinfo); | |
656 delete g_font_info; | 658 delete g_font_info; |
657 #endif | 659 #endif |
658 FPDF_DestroyLibrary(); | |
659 TearDownV8(); | 660 TearDownV8(); |
660 } | 661 } |
661 | 662 |
662 PDFEngine* PDFEngine::Create(PDFEngine::Client* client) { | 663 PDFEngine* PDFEngine::Create(PDFEngine::Client* client) { |
663 return new PDFiumEngine(client); | 664 return new PDFiumEngine(client); |
664 } | 665 } |
665 | 666 |
666 PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) | 667 PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) |
667 : client_(client), | 668 : client_(client), |
668 current_zoom_(1.0), | 669 current_zoom_(1.0), |
(...skipping 3484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4153 FPDF_DOCUMENT doc = | 4154 FPDF_DOCUMENT doc = |
4154 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); | 4155 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); |
4155 if (!doc) | 4156 if (!doc) |
4156 return false; | 4157 return false; |
4157 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4158 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
4158 FPDF_CloseDocument(doc); | 4159 FPDF_CloseDocument(doc); |
4159 return success; | 4160 return success; |
4160 } | 4161 } |
4161 | 4162 |
4162 } // namespace chrome_pdf | 4163 } // namespace chrome_pdf |
OLD | NEW |