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

Unified Diff: core/fpdfapi/fpdf_font/cpdf_font.cpp

Issue 2276653002: Add fallback fonts in pdfium (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_font/include/cpdf_font.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4747093ac4f307228d9ef62ff0f9e72f59c0426e 100644
--- a/core/fpdfapi/fpdf_font/cpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp
@@ -22,7 +22,9 @@
#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"
+#include "third_party/base/stl_util.h"
namespace {
@@ -451,3 +453,25 @@ 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) {
+ 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) {
+ if (fallbackFont < 0 ||
+ fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) {
+ return -1;
+ }
+ int glyph =
+ FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode);
+ if (glyph == 0 || glyph == 0xffff)
+ return -1;
+ return glyph;
+}
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_font/include/cpdf_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698