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

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

Issue 2364643003: Make CPDF_Font::Create() return a std::unique_ptr. (Closed)
Patch Set: Stray file Created 4 years, 3 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_font/font_int.h » ('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 d3f8664cd36d1154a8aeadbf0b235900a23ec576..64511c8025d96a739f64f78dcfd8f85df98428c4 100644
--- a/core/fpdfapi/fpdf_font/cpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp
@@ -299,27 +299,25 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc,
const CFX_ByteStringC& name) {
CFX_ByteString fontname(name);
int font_id = PDF_GetStandardFontName(&fontname);
- if (font_id < 0) {
+ if (font_id < 0)
return nullptr;
- }
+
CPDF_FontGlobals* pFontGlobals =
CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id);
- if (pFont) {
+ if (pFont)
return pFont;
- }
+
CPDF_Dictionary* pDict = new CPDF_Dictionary;
pDict->SetNameFor("Type", "Font");
pDict->SetNameFor("Subtype", "Type1");
pDict->SetNameFor("BaseFont", fontname);
pDict->SetNameFor("Encoding", "WinAnsiEncoding");
- pFont = CPDF_Font::CreateFontF(nullptr, pDict);
- pFontGlobals->Set(pDoc, font_id, pFont);
- return pFont;
+ return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict));
}
-CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
- CPDF_Dictionary* pFontDict) {
+std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
+ CPDF_Dictionary* pFontDict) {
CFX_ByteString type = pFontDict->GetStringFor("Subtype");
std::unique_ptr<CPDF_Font> pFont;
if (type == "TrueType") {
@@ -344,7 +342,7 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
pFont->m_BaseFont = pFontDict->GetStringFor("BaseFont");
- return pFont->Load() ? pFont.release() : nullptr;
+ return pFont->Load() ? std::move(pFont) : std::unique_ptr<CPDF_Font>();
}
uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString,
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_font/font_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698