Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Issue 2276653002: Add fallback fonts in pdfium (Closed)

Created:
4 years, 4 months ago by npm
Modified:
4 years, 4 months ago
CC:
pdfium-reviews_googlegroups.com
Base URL:
https://pdfium.googlesource.com/pdfium.git@master
Target Ref:
refs/heads/master
Project:
pdfium
Visibility:
Public.

Description

Allow CPDF_Font to use fallback fonts Added a vector of pointers to CFX_Fonts in the class CPDF_Font, so that fallback fonts may be used. In CPDF_CharPosList::Load, the glyphs for each character are calculated. When m_Font does not support a character, a fallback font is selected and the character is rendered using that font. This meant adding an attribute to FXTEXT_CHARPOS so it knows which font renders it. Also, methods in fpdf_render_text.cpp now may need to call device drawing methods multiple times because these only support one font at a time. In CPDF_TextRenderer::DrawNormalText and in CPDF_TextRenderer::DrawTextPath, the device drawing method is called as few times as possible by grouping contiguous characters rendered by the same font. In CPDF_RenderStatus::DrawTextPathWithPattern, drawing was already done one character at a time, but precalculating CFX_FaceCache. Now, the face cache is precalculated for all of the fallback fonts. The list of fallback fonts does not include tha main font. Otherwise the list would be of raw pointers to avoid double free problems. For now, the font Arial is used as fallback. This should fix the issue of not seeing Latin characters displayed when bad fonts are used. However, this should be improved. Tested manually using the file in the bug, plus a font directory containing a font that supports Hangul but not Latin. This font is chosen as the substitute font, but Latin characters are now being rendered. Design proposal: go/pdfium_fallbackfonts BUG=pdfium:358 Committed: https://pdfium.googlesource.com/pdfium/+/b107193e9780b4a50e85d54c1ffbd2303263e193

Patch Set 1 #

Patch Set 2 : Nits #

Total comments: 12

Patch Set 3 : Only fallbacks in vector #

Total comments: 28

Patch Set 4 : Address comments #

Total comments: 10

Patch Set 5 : Comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+112 lines, -11 lines) Patch
M core/fpdfapi/fpdf_font/cpdf_font.cpp View 1 2 3 4 2 chunks +24 lines, -0 lines 0 comments Download
M core/fpdfapi/fpdf_font/include/cpdf_font.h View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
M core/fpdfapi/fpdf_render/fpdf_render_text.cpp View 1 2 3 4 6 chunks +84 lines, -11 lines 0 comments Download
M core/fxge/include/cfx_renderdevice.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 25 (14 generated)
npm
PTAL
4 years, 4 months ago (2016-08-23 19:12:43 UTC) #8
dsinclair
https://codereview.chromium.org/2276653002/diff/20001/core/fpdfapi/fpdf_font/cpdf_font.cpp File core/fpdfapi/fpdf_font/cpdf_font.cpp (right): https://codereview.chromium.org/2276653002/diff/20001/core/fpdfapi/fpdf_font/cpdf_font.cpp#newcode455 core/fpdfapi/fpdf_font/cpdf_font.cpp:455: uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode, This only ever returns 1, can ...
4 years, 4 months ago (2016-08-23 19:41:18 UTC) #9
npm
PTAL https://codereview.chromium.org/2276653002/diff/20001/core/fpdfapi/fpdf_font/cpdf_font.cpp File core/fpdfapi/fpdf_font/cpdf_font.cpp (right): https://codereview.chromium.org/2276653002/diff/20001/core/fpdfapi/fpdf_font/cpdf_font.cpp#newcode455 core/fpdfapi/fpdf_font/cpdf_font.cpp:455: uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode, On 2016/08/23 19:41:18, dsinclair wrote: ...
4 years, 4 months ago (2016-08-23 20:36:57 UTC) #12
dsinclair
https://codereview.chromium.org/2276653002/diff/40001/core/fpdfapi/fpdf_render/fpdf_render_text.cpp File core/fpdfapi/fpdf_render/fpdf_render_text.cpp (right): https://codereview.chromium.org/2276653002/diff/40001/core/fpdfapi/fpdf_render/fpdf_render_text.cpp#newcode645 core/fpdfapi/fpdf_render/fpdf_render_text.cpp:645: int32_t pFontPosition = CharPosList.m_pCharPos[0].m_FallbackFontPosition; can m_pCharPos length be 0? ...
4 years, 4 months ago (2016-08-23 20:58:02 UTC) #15
Lei Zhang
https://codereview.chromium.org/2276653002/diff/40001/core/fpdfapi/fpdf_font/cpdf_font.cpp File core/fpdfapi/fpdf_font/cpdf_font.cpp (right): https://codereview.chromium.org/2276653002/diff/40001/core/fpdfapi/fpdf_font/cpdf_font.cpp#newcode457 core/fpdfapi/fpdf_font/cpdf_font.cpp:457: if (m_FontFallbacks.size() < 1) { m_FontFallbacks.empty() https://codereview.chromium.org/2276653002/diff/40001/core/fpdfapi/fpdf_font/cpdf_font.cpp#newcode458 core/fpdfapi/fpdf_font/cpdf_font.cpp:458: m_FontFallbacks.push_back(std::unique_ptr<CFX_Font>(new ...
4 years, 4 months ago (2016-08-24 04:43:11 UTC) #16
npm
PTAL https://codereview.chromium.org/2276653002/diff/40001/core/fpdfapi/fpdf_font/cpdf_font.cpp File core/fpdfapi/fpdf_font/cpdf_font.cpp (right): https://codereview.chromium.org/2276653002/diff/40001/core/fpdfapi/fpdf_font/cpdf_font.cpp#newcode457 core/fpdfapi/fpdf_font/cpdf_font.cpp:457: if (m_FontFallbacks.size() < 1) { On 2016/08/24 04:43:10, ...
4 years, 4 months ago (2016-08-24 14:39:22 UTC) #17
Tom Sepez
https://codereview.chromium.org/2276653002/diff/60001/core/fpdfapi/fpdf_font/cpdf_font.cpp File core/fpdfapi/fpdf_font/cpdf_font.cpp (right): https://codereview.chromium.org/2276653002/diff/60001/core/fpdfapi/fpdf_font/cpdf_font.cpp#newcode471 core/fpdfapi/fpdf_font/cpdf_font.cpp:471: fallbackFont >= static_cast<int>(m_FontFallbacks.size())) { nit: pdfium::CollectionSize<int>(m_FontFallbacks) is preferred over ...
4 years, 4 months ago (2016-08-24 16:23:49 UTC) #18
npm
PTAL https://codereview.chromium.org/2276653002/diff/60001/core/fpdfapi/fpdf_font/cpdf_font.cpp File core/fpdfapi/fpdf_font/cpdf_font.cpp (right): https://codereview.chromium.org/2276653002/diff/60001/core/fpdfapi/fpdf_font/cpdf_font.cpp#newcode471 core/fpdfapi/fpdf_font/cpdf_font.cpp:471: fallbackFont >= static_cast<int>(m_FontFallbacks.size())) { On 2016/08/24 16:23:49, Tom ...
4 years, 4 months ago (2016-08-24 17:47:15 UTC) #19
Tom Sepez
lgtm
4 years, 4 months ago (2016-08-24 17:51:03 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2276653002/80001
4 years, 4 months ago (2016-08-24 18:08:14 UTC) #23
commit-bot: I haz the power
4 years, 4 months ago (2016-08-24 18:23:53 UTC) #25
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as
https://pdfium.googlesource.com/pdfium/+/b107193e9780b4a50e85d54c1ffbd2303263...

Powered by Google App Engine
This is Rietveld 408576698