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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 0, | 312 0, |
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 |
Tom Sepez
2016/11/10 17:47:08
Probably cleaner to call FPDF_FreeDefaultSystemFon
| |
323 ~FPDF_SYSFONTINFO_WITHMETRICS() { delete default_sysfontinfo; } | 323 ~FPDF_SYSFONTINFO_WITHMETRICS() {} |
324 | 324 |
325 // Not owned. | |
Tom Sepez
2016/11/10 17:47:08
nit: in which case this comment goes away.
| |
325 FPDF_SYSFONTINFO* default_sysfontinfo; | 326 FPDF_SYSFONTINFO* default_sysfontinfo; |
326 }; | 327 }; |
327 | 328 |
328 FPDF_SYSFONTINFO_WITHMETRICS* g_font_info = nullptr; | 329 FPDF_SYSFONTINFO_WITHMETRICS* g_font_info = nullptr; |
329 | 330 |
330 void* MapFontWithMetrics(FPDF_SYSFONTINFO* sysfontinfo, | 331 void* MapFontWithMetrics(FPDF_SYSFONTINFO* sysfontinfo, |
331 int weight, | 332 int weight, |
332 int italic, | 333 int italic, |
333 int charset, | 334 int charset, |
334 int pitch_family, | 335 int pitch_family, |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 g_font_info->DeleteFont = DeleteFont; | 645 g_font_info->DeleteFont = DeleteFont; |
645 FPDF_SetSystemFontInfo(g_font_info); | 646 FPDF_SetSystemFontInfo(g_font_info); |
646 #endif | 647 #endif |
647 | 648 |
648 FSDK_SetUnSpObjProcessHandler(&g_unsupported_info); | 649 FSDK_SetUnSpObjProcessHandler(&g_unsupported_info); |
649 | 650 |
650 return true; | 651 return true; |
651 } | 652 } |
652 | 653 |
653 void ShutdownSDK() { | 654 void ShutdownSDK() { |
655 FPDF_DestroyLibrary(); | |
654 #if !defined(OS_LINUX) | 656 #if !defined(OS_LINUX) |
655 FPDF_FreeDefaultSystemFontInfo(g_font_info->default_sysfontinfo); | 657 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 |