summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfedittext.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-09 22:28:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-09 22:28:49 +0000
commit257900b6dae0fe8d82d48ecc91d92e5dbb3a28bf (patch)
treee3b53963f47cb34166baafb5eb17b07d1c66c9fe /fpdfsdk/fpdfedittext.cpp
parentbc5dd9e7901ee56e0db66e76bf2e4903ab3d3fcd (diff)
downloadpdfium-257900b6dae0fe8d82d48ecc91d92e5dbb3a28bf.tar.xz
Use CPDF_Dictionary::SetRectFor() when appropriate.
Change-Id: I4ced221fb5691927485deceb7002dac880c2c210 Reviewed-on: https://pdfium-review.googlesource.com/26110 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfedittext.cpp')
-rw-r--r--fpdfsdk/fpdfedittext.cpp37
1 files changed, 16 insertions, 21 deletions
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp
index 7bbb6a857c..460e852eaa 100644
--- a/fpdfsdk/fpdfedittext.cpp
+++ b/fpdfsdk/fpdfedittext.cpp
@@ -35,9 +35,9 @@ CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
const uint8_t* data,
uint32_t size,
int font_type) {
- CPDF_Dictionary* fontDesc = pDoc->NewIndirect<CPDF_Dictionary>();
- fontDesc->SetNewFor<CPDF_Name>("Type", "FontDescriptor");
- fontDesc->SetNewFor<CPDF_Name>("FontName", font_name);
+ CPDF_Dictionary* pFontDesc = pDoc->NewIndirect<CPDF_Dictionary>();
+ pFontDesc->SetNewFor<CPDF_Name>("Type", "FontDescriptor");
+ pFontDesc->SetNewFor<CPDF_Name>("FontName", font_name);
int flags = 0;
if (FXFT_Is_Face_fixedwidth(pFont->GetFace()))
flags |= FXFONT_FIXED_PITCH;
@@ -51,25 +51,20 @@ CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
// TODO(npm): How do I know if a font is symbolic, script, allcap, smallcap
flags |= FXFONT_NONSYMBOLIC;
- fontDesc->SetNewFor<CPDF_Number>("Flags", flags);
+ pFontDesc->SetNewFor<CPDF_Number>("Flags", flags);
FX_RECT bbox;
pFont->GetBBox(bbox);
- auto pBBox = pdfium::MakeUnique<CPDF_Array>();
- pBBox->AddNew<CPDF_Number>(bbox.left);
- pBBox->AddNew<CPDF_Number>(bbox.top);
- pBBox->AddNew<CPDF_Number>(bbox.right);
- pBBox->AddNew<CPDF_Number>(bbox.bottom);
- fontDesc->SetFor("FontBBox", std::move(pBBox));
+ pFontDesc->SetRectFor("FontBBox", CFX_FloatRect(bbox));
// TODO(npm): calculate italic angle correctly
- fontDesc->SetNewFor<CPDF_Number>("ItalicAngle", pFont->IsItalic() ? -12 : 0);
+ pFontDesc->SetNewFor<CPDF_Number>("ItalicAngle", pFont->IsItalic() ? -12 : 0);
- fontDesc->SetNewFor<CPDF_Number>("Ascent", pFont->GetAscent());
- fontDesc->SetNewFor<CPDF_Number>("Descent", pFont->GetDescent());
+ pFontDesc->SetNewFor<CPDF_Number>("Ascent", pFont->GetAscent());
+ pFontDesc->SetNewFor<CPDF_Number>("Descent", pFont->GetDescent());
// TODO(npm): calculate the capheight, stemV correctly
- fontDesc->SetNewFor<CPDF_Number>("CapHeight", pFont->GetAscent());
- fontDesc->SetNewFor<CPDF_Number>("StemV", pFont->IsBold() ? 120 : 70);
+ pFontDesc->SetNewFor<CPDF_Number>("CapHeight", pFont->GetAscent());
+ pFontDesc->SetNewFor<CPDF_Number>("StemV", pFont->IsBold() ? 120 : 70);
CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>();
pStream->SetData(data, size);
@@ -79,8 +74,8 @@ CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
static_cast<int>(size));
}
ByteString fontFile = font_type == FPDF_FONT_TYPE1 ? "FontFile" : "FontFile2";
- fontDesc->SetNewFor<CPDF_Reference>(fontFile, pDoc, pStream->GetObjNum());
- return fontDesc;
+ pFontDesc->SetNewFor<CPDF_Reference>(fontFile, pDoc, pStream->GetObjNum());
+ return pFontDesc;
}
const char ToUnicodeStart[] =
@@ -276,11 +271,11 @@ void* LoadSimpleFont(CPDF_Document* pDoc,
}
fontDict->SetNewFor<CPDF_Number>("LastChar", static_cast<int>(currentChar));
fontDict->SetNewFor<CPDF_Reference>("Widths", pDoc, widthsArray->GetObjNum());
- CPDF_Dictionary* fontDesc =
+ CPDF_Dictionary* pFontDesc =
LoadFontDesc(pDoc, name, pFont.get(), data, size, font_type);
fontDict->SetNewFor<CPDF_Reference>("FontDescriptor", pDoc,
- fontDesc->GetObjNum());
+ pFontDesc->GetObjNum());
return pDoc->LoadFont(fontDict);
}
@@ -319,10 +314,10 @@ void* LoadCompositeFont(CPDF_Document* pDoc,
pCIDFont->SetNewFor<CPDF_Reference>("CIDSystemInfo", pDoc,
pCIDSystemInfo->GetObjNum());
- CPDF_Dictionary* fontDesc =
+ CPDF_Dictionary* pFontDesc =
LoadFontDesc(pDoc, name, pFont.get(), data, size, font_type);
pCIDFont->SetNewFor<CPDF_Reference>("FontDescriptor", pDoc,
- fontDesc->GetObjNum());
+ pFontDesc->GetObjNum());
uint32_t glyphIndex;
uint32_t currentChar = FXFT_Get_First_Char(pFont->GetFace(), &glyphIndex);