From 5f95f36cac52c92d34bffbfa22a7da49d0653978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Pe=C3=B1a?= Date: Thu, 28 Sep 2017 13:00:45 +0900 Subject: Change bottom-top order in FontBBox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The FontBBox, for compatiblity reasons, must be specified top to bottom. This CL flips the current implementation which was bottom to top. Bug: pdfium:892 Change-Id: Ieb8d3bb183ed7870e3b3d7f0380f1343adedf87b Reviewed-on: https://pdfium-review.googlesource.com/14851 Commit-Queue: Nicolás Peña Moreno Reviewed-by: dsinclair --- fpdfsdk/fpdfedit_embeddertest.cpp | 10 +++++++++- fpdfsdk/fpdfedittext.cpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp index 0fb736a9d4..9f43054b4c 100644 --- a/fpdfsdk/fpdfedit_embeddertest.cpp +++ b/fpdfsdk/fpdfedit_embeddertest.cpp @@ -58,7 +58,15 @@ class FPDFEditEmbeddertest : public EmbedderTest { EXPECT_FALSE(font_flags & FXFONT_ITALIC); EXPECT_TRUE(font_flags & FXFONT_NONSYMBOLIC); ASSERT_TRUE(font_desc->KeyExist("FontBBox")); - EXPECT_EQ(4U, font_desc->GetArrayFor("FontBBox")->GetCount()); + + CPDF_Array* fontBBox = font_desc->GetArrayFor("FontBBox"); + ASSERT_TRUE(fontBBox); + EXPECT_EQ(4U, fontBBox->GetCount()); + // Check that the coordinates are in the preferred order according to spec + // 1.7 Section 3.8.4 + EXPECT_TRUE(fontBBox->GetIntegerAt(0) < fontBBox->GetIntegerAt(2)); + EXPECT_TRUE(fontBBox->GetIntegerAt(1) < fontBBox->GetIntegerAt(3)); + EXPECT_TRUE(font_desc->KeyExist("ItalicAngle")); EXPECT_TRUE(font_desc->KeyExist("Ascent")); EXPECT_TRUE(font_desc->KeyExist("Descent")); diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp index 2a9ef53273..bac1108243 100644 --- a/fpdfsdk/fpdfedittext.cpp +++ b/fpdfsdk/fpdfedittext.cpp @@ -54,9 +54,9 @@ CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc, pFont->GetBBox(bbox); auto pBBox = pdfium::MakeUnique(); pBBox->AddNew(bbox.left); - pBBox->AddNew(bbox.bottom); - pBBox->AddNew(bbox.right); pBBox->AddNew(bbox.top); + pBBox->AddNew(bbox.right); + pBBox->AddNew(bbox.bottom); fontDesc->SetFor("FontBBox", std::move(pBBox)); // TODO(npm): calculate italic angle correctly -- cgit v1.2.3