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

Unified Diff: core/fpdfapi/fpdf_font/cpdf_font.cpp

Issue 2194853002: Cleanup CPDF_DocPageData release methods and callers. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/cpdf_color.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_font/cpdf_font.cpp
diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp
index 07a79ed60747ab84bee78793d5999bf156b8d412..59a4aeca94b2065215e1550ea075ba3d7b22faf5 100644
--- a/core/fpdfapi/fpdf_font/cpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
+#include <memory>
+
#include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h"
#include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
#include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
@@ -23,13 +25,13 @@
namespace {
-const uint8_t ChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00},
- {0xBF, 0xAC, 0xCC, 0xE5, 0x00},
- {0xBA, 0xDA, 0xCC, 0xE5, 0x00},
- {0xB7, 0xC2, 0xCB, 0xCE, 0x00},
- {0xD0, 0xC2, 0xCB, 0xCE, 0x00}};
+const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00},
+ {0xBF, 0xAC, 0xCC, 0xE5, 0x00},
+ {0xBA, 0xDA, 0xCC, 0xE5, 0x00},
+ {0xB7, 0xC2, 0xCB, 0xCE, 0x00},
+ {0xD0, 0xC2, 0xCB, 0xCE, 0x00}};
-FX_BOOL GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) {
+void GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) {
if (value == "WinAnsiEncoding")
basemap = PDFFONT_ENCODING_WINANSI;
else if (value == "MacRomanEncoding")
@@ -38,9 +40,6 @@ FX_BOOL GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) {
basemap = PDFFONT_ENCODING_MACEXPERT;
else if (value == "PDFDocEncoding")
basemap = PDFFONT_ENCODING_PDFDOC;
- else
- return FALSE;
- return TRUE;
}
} // namespace
@@ -58,7 +57,7 @@ CPDF_Font::CPDF_Font()
CPDF_Font::~CPDF_Font() {
if (m_pFontFile) {
m_pDocument->GetPageData()->ReleaseFontFileStreamAcc(
- const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream()));
+ m_pFontFile->GetStream()->AsStream());
}
}
@@ -222,7 +221,7 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) {
uint32_t dwFontSize = m_pFontFile->GetSize();
if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) {
m_pDocument->GetPageData()->ReleaseFontFileStreamAcc(
- const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream()));
+ m_pFontFile->GetStream()->AsStream());
m_pFontFile = nullptr;
}
}
@@ -322,8 +321,8 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
std::unique_ptr<CPDF_Font> pFont;
if (type == "TrueType") {
CFX_ByteString tag = pFontDict->GetStringBy("BaseFont").Left(4);
- for (size_t i = 0; i < FX_ArraySize(ChineseFontNames); ++i) {
- if (tag == CFX_ByteString(ChineseFontNames[i], 4)) {
+ for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) {
+ if (tag == CFX_ByteString(kChineseFontNames[i], 4)) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDictBy("FontDescriptor");
if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
pFont.reset(new CPDF_CIDFont);
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/cpdf_color.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698