summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_font/include
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-08-24 11:23:49 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-24 11:23:49 -0700
commitb107193e9780b4a50e85d54c1ffbd2303263e193 (patch)
treefb81a07ad10477d16af26667aa4e4629328b6084 /core/fpdfapi/fpdf_font/include
parentcedaa557316a3f5c436814e69d67f19795f471d7 (diff)
downloadpdfium-b107193e9780b4a50e85d54c1ffbd2303263e193.tar.xz
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 Review-Url: https://codereview.chromium.org/2276653002
Diffstat (limited to 'core/fpdfapi/fpdf_font/include')
-rw-r--r--core/fpdfapi/fpdf_font/include/cpdf_font.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/fpdfapi/fpdf_font/include/cpdf_font.h b/core/fpdfapi/fpdf_font/include/cpdf_font.h
index a76a6a2573..a47d8655c2 100644
--- a/core/fpdfapi/fpdf_font/include/cpdf_font.h
+++ b/core/fpdfapi/fpdf_font/include/cpdf_font.h
@@ -88,12 +88,15 @@ class CPDF_Font {
int GetItalicAngle() const { return m_ItalicAngle; }
int GetStemV() const { return m_StemV; }
int GetStringWidth(const FX_CHAR* pString, int size);
+ uint32_t FallbackFontFromCharcode(uint32_t charcode);
+ int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode);
virtual int GetCharWidthF(uint32_t charcode, int level = 0) = 0;
virtual FX_RECT GetCharBBox(uint32_t charcode, int level = 0) = 0;
CPDF_Document* m_pDocument;
CFX_Font m_Font;
+ std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks;
protected:
CPDF_Font();