summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-04-12 15:37:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-12 15:37:39 +0000
commit1c23a6d78c95ff0714cda6f642420e0502edac29 (patch)
tree82d35256f9a214cc26f03d7c5626653a2398f56b
parente6d4559a1b6c2eb0eb433b9db70745e3be3d8465 (diff)
downloadpdfium-1c23a6d78c95ff0714cda6f642420e0502edac29.tar.xz
Make CFX_Font take FX_RECT out params by pointer.
Change-Id: I6643aaf66bf3e9d53d5afab5c99a5cb7deab3661 Reviewed-on: https://pdfium-review.googlesource.com/30054 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp2
-rw-r--r--core/fxge/cfx_font.cpp60
-rw-r--r--core/fxge/cfx_font.h4
-rw-r--r--fpdfsdk/fpdf_edittext.cpp2
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp10
5 files changed, 36 insertions, 42 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 565886a3a5..b8d1ce2094 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -924,7 +924,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) {
int italicangle =
pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0;
FX_RECT bbox;
- pFont->GetBBox(bbox);
+ pFont->GetBBox(&bbox);
auto pBBox = pdfium::MakeUnique<CPDF_Array>();
pBBox->AddNew<CPDF_Number>(bbox.left);
pBBox->AddNew<CPDF_Number>(bbox.bottom);
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index ece3f96bed..98322fdf98 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -349,7 +349,7 @@ int CFX_Font::GetDescent() const {
return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), descender);
}
-bool CFX_Font::GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox) {
+bool CFX_Font::GetGlyphBBox(uint32_t glyph_index, FX_RECT* pBBox) {
if (!m_Face)
return false;
@@ -373,20 +373,20 @@ bool CFX_Font::GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox) {
int pixel_size_x = m_Face->size->metrics.x_ppem,
pixel_size_y = m_Face->size->metrics.y_ppem;
if (pixel_size_x == 0 || pixel_size_y == 0) {
- bbox.left = cbox.xMin;
- bbox.right = cbox.xMax;
- bbox.top = cbox.yMax;
- bbox.bottom = cbox.yMin;
+ pBBox->left = cbox.xMin;
+ pBBox->right = cbox.xMax;
+ pBBox->top = cbox.yMax;
+ pBBox->bottom = cbox.yMin;
} else {
- bbox.left = cbox.xMin * 1000 / pixel_size_x;
- bbox.right = cbox.xMax * 1000 / pixel_size_x;
- bbox.top = cbox.yMax * 1000 / pixel_size_y;
- bbox.bottom = cbox.yMin * 1000 / pixel_size_y;
+ pBBox->left = cbox.xMin * 1000 / pixel_size_x;
+ pBBox->right = cbox.xMax * 1000 / pixel_size_x;
+ pBBox->top = cbox.yMax * 1000 / pixel_size_y;
+ pBBox->bottom = cbox.yMin * 1000 / pixel_size_y;
}
- bbox.top = std::min(bbox.top,
- static_cast<int32_t>(FXFT_Get_Face_Ascender(m_Face)));
- bbox.bottom = std::max(
- bbox.bottom, static_cast<int32_t>(FXFT_Get_Face_Descender(m_Face)));
+ pBBox->top = std::min(pBBox->top,
+ static_cast<int32_t>(FXFT_Get_Face_Ascender(m_Face)));
+ pBBox->bottom = std::max(
+ pBBox->bottom, static_cast<int32_t>(FXFT_Get_Face_Descender(m_Face)));
FT_Done_Glyph(glyph);
return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0;
}
@@ -397,19 +397,19 @@ bool CFX_Font::GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox) {
}
int em = FXFT_Get_Face_UnitsPerEM(m_Face);
if (em == 0) {
- bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face);
- bbox.bottom = FXFT_Get_Glyph_HoriBearingY(m_Face);
- bbox.top = bbox.bottom - FXFT_Get_Glyph_Height(m_Face);
- bbox.right = bbox.left + FXFT_Get_Glyph_Width(m_Face);
+ pBBox->left = FXFT_Get_Glyph_HoriBearingX(m_Face);
+ pBBox->bottom = FXFT_Get_Glyph_HoriBearingY(m_Face);
+ pBBox->top = pBBox->bottom - FXFT_Get_Glyph_Height(m_Face);
+ pBBox->right = pBBox->left + FXFT_Get_Glyph_Width(m_Face);
} else {
- bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face) * 1000 / em;
- bbox.top =
+ pBBox->left = FXFT_Get_Glyph_HoriBearingX(m_Face) * 1000 / em;
+ pBBox->top =
(FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)) *
1000 / em;
- bbox.right =
+ pBBox->right =
(FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)) *
1000 / em;
- bbox.bottom = (FXFT_Get_Glyph_HoriBearingY(m_Face)) * 1000 / em;
+ pBBox->bottom = (FXFT_Get_Glyph_HoriBearingY(m_Face)) * 1000 / em;
}
return true;
}
@@ -467,21 +467,21 @@ ByteString CFX_Font::GetFaceName() const {
return m_pSubstFont->m_Family;
}
-bool CFX_Font::GetBBox(FX_RECT& bbox) {
+bool CFX_Font::GetBBox(FX_RECT* pBBox) {
if (!m_Face)
return false;
int em = FXFT_Get_Face_UnitsPerEM(m_Face);
if (em == 0) {
- bbox.left = FXFT_Get_Face_xMin(m_Face);
- bbox.bottom = FXFT_Get_Face_yMax(m_Face);
- bbox.top = FXFT_Get_Face_yMin(m_Face);
- bbox.right = FXFT_Get_Face_xMax(m_Face);
+ pBBox->left = FXFT_Get_Face_xMin(m_Face);
+ pBBox->bottom = FXFT_Get_Face_yMax(m_Face);
+ pBBox->top = FXFT_Get_Face_yMin(m_Face);
+ pBBox->right = FXFT_Get_Face_xMax(m_Face);
} else {
- bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em;
- bbox.top = FXFT_Get_Face_yMin(m_Face) * 1000 / em;
- bbox.right = FXFT_Get_Face_xMax(m_Face) * 1000 / em;
- bbox.bottom = FXFT_Get_Face_yMax(m_Face) * 1000 / em;
+ pBBox->left = FXFT_Get_Face_xMin(m_Face) * 1000 / em;
+ pBBox->top = FXFT_Get_Face_yMin(m_Face) * 1000 / em;
+ pBBox->right = FXFT_Get_Face_xMax(m_Face) * 1000 / em;
+ pBBox->bottom = FXFT_Get_Face_yMax(m_Face) * 1000 / em;
}
return true;
}
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index c753e7e29d..1d17714b46 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -65,7 +65,7 @@ class CFX_Font {
uint32_t GetGlyphWidth(uint32_t glyph_index);
int GetAscent() const;
int GetDescent() const;
- bool GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox);
+ bool GetGlyphBBox(uint32_t glyph_index, FX_RECT* pBBox);
bool IsItalic() const;
bool IsBold() const;
bool IsFixedWidth() const;
@@ -74,7 +74,7 @@ class CFX_Font {
ByteString GetFamilyName() const;
ByteString GetFaceName() const;
bool IsTTFont() const;
- bool GetBBox(FX_RECT& bbox);
+ bool GetBBox(FX_RECT* pBBox);
bool IsEmbedded() const { return m_bEmbedded; }
uint8_t* GetSubData() const { return m_pGsubData.get(); }
void SetSubData(uint8_t* data) { m_pGsubData.reset(data); }
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 8155003a1f..eba5b554c3 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -53,7 +53,7 @@ CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
pFontDesc->SetNewFor<CPDF_Number>("Flags", flags);
FX_RECT bbox;
- pFont->GetBBox(bbox);
+ pFont->GetBBox(&bbox);
pFontDesc->SetRectFor("FontBBox", CFX_FloatRect(bbox));
// TODO(npm): calculate italic angle correctly
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 6b2cb0f03b..35d3480d03 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -202,7 +202,7 @@ bool CFGAS_GEFont::GetCharBBox(wchar_t wUnicode, FX_RECT* bbox) {
return pFont->GetCharBBox(wUnicode, bbox);
FX_RECT rtBBox;
- if (!m_pFont->GetGlyphBBox(iGlyph, rtBBox))
+ if (!m_pFont->GetGlyphBBox(iGlyph, &rtBBox))
return false;
m_BBoxMap[wUnicode] = rtBBox;
@@ -211,13 +211,7 @@ bool CFGAS_GEFont::GetCharBBox(wchar_t wUnicode, FX_RECT* bbox) {
}
bool CFGAS_GEFont::GetBBox(FX_RECT* bbox) {
- // TODO(thestig): Pass directly into GetBBox().
- FX_RECT rt;
- if (!m_pFont->GetBBox(rt))
- return false;
-
- *bbox = rt;
- return true;
+ return m_pFont->GetBBox(bbox);
}
int32_t CFGAS_GEFont::GetGlyphIndex(wchar_t wUnicode) {