diff options
author | Nicolas Pena <npm@chromium.org> | 2018-06-01 21:10:33 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-01 21:10:33 +0000 |
commit | b27de7c64c5e9b949f3a76f962abdc2fa5c524e8 (patch) | |
tree | 5a9f0ec203c4cfeecc5f03c09a3e57a3358d711b | |
parent | d05394341e3a2140923f379cb1547f0600590a62 (diff) | |
download | pdfium-b27de7c64c5e9b949f3a76f962abdc2fa5c524e8.tar.xz |
Fix font regression in AdjustMMParams
Commit 2334660 changed the |dest_width| in CFX_Font::AdjustMMParams to
unsigned, but this means that dest_width - min_width becomes unsigned,
which is wrong because the subtraction could be negative. This CL fixes
this bug.
Bug: chromium:845697
Change-Id: I88fb2f3ee3837d80ff5fa70a08309d9e0fec50e0
Reviewed-on: https://pdfium-review.googlesource.com/33150
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
(cherry picked from commit 8f7ee98e2c622c21f452cd9fd5956fe85bcb2b7c)
Reviewed-on: https://pdfium-review.googlesource.com/33610
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
-rw-r--r-- | core/fxge/cfx_font.cpp | 3 | ||||
-rw-r--r-- | core/fxge/cfx_font.h | 2 | ||||
-rw-r--r-- | testing/resources/pixel/bug_845697.in | 63 | ||||
-rw-r--r-- | testing/resources/pixel/bug_845697_expected.pdf.0.png | bin | 0 -> 2348 bytes |
4 files changed, 66 insertions, 2 deletions
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp index 98322fdf98..dbb9cc7462 100644 --- a/core/fxge/cfx_font.cpp +++ b/core/fxge/cfx_font.cpp @@ -501,8 +501,9 @@ void CFX_Font::ClearFaceCache() { } void CFX_Font::AdjustMMParams(int glyph_index, - uint32_t dest_width, + int dest_width, int weight) const { + ASSERT(dest_width >= 0); FXFT_MM_Var pMasters = nullptr; FXFT_Get_MM_Var(m_Face, &pMasters); if (!pMasters) diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h index 1d17714b46..27d4269629 100644 --- a/core/fxge/cfx_font.h +++ b/core/fxge/cfx_font.h @@ -84,7 +84,7 @@ class CFX_Font { #endif uint8_t* GetFontData() const { return m_pFontData; } uint32_t GetSize() const { return m_dwSize; } - void AdjustMMParams(int glyph_index, uint32_t dest_width, int weight) const; + void AdjustMMParams(int glyph_index, int dest_width, int weight) const; CFX_PathData* LoadGlyphPathImpl(uint32_t glyph_index, uint32_t dest_width) const; diff --git a/testing/resources/pixel/bug_845697.in b/testing/resources/pixel/bug_845697.in new file mode 100644 index 0000000000..92da761d40 --- /dev/null +++ b/testing/resources/pixel/bug_845697.in @@ -0,0 +1,63 @@ +{{header}} +{{object 1 0}} << + /Type /Catalog + /Pages 2 0 R +>> +endobj +{{object 2 0}} << + /Type /Pages + /MediaBox [ 0 0 200 200 ] + /Count 1 + /Kids [ 3 0 R ] +>> +endobj +{{object 3 0}} << + /Type /Page + /Parent 2 0 R + /Resources << + /Font << + /F1 4 0 R + >> + >> + /Contents 6 0 R +>> +endobj +{{object 4 0}} << + /Type /Font + /Subtype /TrueType + /BaseFont /ABCDEE+Calibri + /Encoding /WinAnsiEncoding + /FirstChar 65 + /LastChar 74 + /FontDescriptor 5 0 R + /Name /F1 + /Widths [300 250 250 250 250 250 250 250 250] +>> +endobj +{{object 5 0}} << + /Type /FontDescriptor + /CapHeight 750 + /Descent -250 + /Flags 32 + /FontBBox [ -503 -250 1240 750 ] + /FontName /ABCDEE+Calibri + /FontWeight 400 + /ItalicAngle 0 + /StemV 52 +>> +endobj +{{object 6 0}} << + {{streamlen}} +>> +stream +BT +50 100 Td +/F1 20 Tf +(ABCDEFGHI) Tj +ET +endstream +endobj +{{xref}} +{{trailer}} +{{startxref}} +%%EOF diff --git a/testing/resources/pixel/bug_845697_expected.pdf.0.png b/testing/resources/pixel/bug_845697_expected.pdf.0.png Binary files differnew file mode 100644 index 0000000000..a55063cde5 --- /dev/null +++ b/testing/resources/pixel/bug_845697_expected.pdf.0.png |