Chromium Code Reviews| Index: core/fpdfapi/fpdf_font/cpdf_font.cpp |
| diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp |
| index 8101bd49a65eab2364ec6cd611466b9eac8e87bc..a3641fab3a3cd1c47cdc0be4f6fefbfe4bf3a9e0 100644 |
| --- a/core/fpdfapi/fpdf_font/cpdf_font.cpp |
| +++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp |
| @@ -22,6 +22,7 @@ |
| #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
| #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" |
| #include "core/fpdfapi/include/cpdf_modulemgr.h" |
| +#include "core/fxcrt/include/fx_memory.h" |
| #include "core/fxge/include/fx_freetype.h" |
| namespace { |
| @@ -451,3 +452,28 @@ const FX_CHAR* CPDF_Font::GetAdobeCharName( |
| name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); |
| return name && name[0] ? name : nullptr; |
| } |
| + |
| +uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode, |
| + bool* pVertGlyph) { |
| + if (m_FontFallbacks.empty()) { |
| + m_FontFallbacks.push_back(WrapUnique(new CFX_Font())); |
| + m_FontFallbacks[0]->LoadSubst("Arial", IsTrueTypeFont(), m_Flags, |
| + m_StemV * 5, m_ItalicAngle, 0, |
| + IsVertWriting()); |
| + } |
| + return 0; |
| +} |
| + |
| +int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, |
| + uint32_t charcode, |
| + bool* pVertGlyph) { |
| + if (fallbackFont < 0 || |
| + fallbackFont >= static_cast<int>(m_FontFallbacks.size())) { |
|
Tom Sepez
2016/08/24 16:23:49
nit: pdfium::CollectionSize<int>(m_FontFallbacks)
npm
2016/08/24 17:47:15
Done.
|
| + return -1; |
| + } |
| + int glyph = |
| + FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); |
| + if (glyph == 0 || glyph == 0xffff) |
| + return -1; |
| + return glyph; |
| +} |