diff options
author | Nicolas Pena <npm@chromium.org> | 2017-06-19 17:07:40 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-19 21:35:03 +0000 |
commit | 4db9046e56c884a350fa2c5087f8d5b8110463c4 (patch) | |
tree | a423eb6dfe89dd9e7aa5ffc8c728c9bfec938f1b /core/fpdfapi/font/cpdf_simplefont.h | |
parent | b73ce7bcd72a97c780176d9f63681a5415c06422 (diff) | |
download | pdfium-4db9046e56c884a350fa2c5087f8d5b8110463c4.tar.xz |
Add heuristic for improving text rendering in CPDF_CharPosList::Load
This CL uses the following algorithm for improving substitute font spacing (we
are assuming the text layout is horizontal):
* Calculate PDFWidth, the width that the PDF says the glyph should have.
* Calculate FTWidth, the width calculated by freetype for the glyph, using the
substitute font that we'll use to render it. Note that some embedded fonts have
PDFWidth == FTWidth + 1, so we consider that to be matching widths.
* If PDFWidth > FTWidth + 1 , move the x coordinate by the difference / 2 so
that the glyph is rendered in a more centered spot and the text looks better.
* If PDFWidth < FTWidth, transform the glyph horizontally by PDFWidth / FTWidth
so that the glyph gets compressed and does not overlap with surrounding glyphs.
Bug: chromium:431507
Change-Id: Ia378344253fabe44d93af4daab98bb3b7bca22de
Reviewed-on: https://pdfium-review.googlesource.com/6630
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/font/cpdf_simplefont.h')
-rw-r--r-- | core/fpdfapi/font/cpdf_simplefont.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h index 3e414fa788..6a22f46966 100644 --- a/core/fpdfapi/font/cpdf_simplefont.h +++ b/core/fpdfapi/font/cpdf_simplefont.h @@ -29,6 +29,8 @@ class CPDF_SimpleFont : public CPDF_Font { CPDF_FontEncoding* GetEncoding() { return &m_Encoding; } + bool HasFontWidths() const override; + protected: virtual void LoadGlyphMap() = 0; |