summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font/cpdf_font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/font/cpdf_font.cpp')
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 1a7fb60b0b..1faa4ec4be 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -15,7 +15,6 @@
#include "core/fpdfapi/font/cpdf_truetypefont.h"
#include "core/fpdfapi/font/cpdf_type1font.h"
#include "core/fpdfapi/font/cpdf_type3font.h"
-#include "core/fpdfapi/font/font_int.h"
#include "core/fpdfapi/page/cpdf_docpagedata.h"
#include "core/fpdfapi/page/cpdf_pagemodule.h"
#include "core/fpdfapi/parser/cpdf_array.h"
@@ -477,3 +476,27 @@ CFX_Font* CPDF_Font::GetFontFallback(int position) {
return nullptr;
return m_FontFallbacks[position].get();
}
+
+// static
+int CPDF_Font::TT2PDF(int m, FXFT_Face face) {
+ int upm = FXFT_Get_Face_UnitsPerEM(face);
+ if (upm == 0)
+ return m;
+ return pdfium::base::checked_cast<int>(
+ (static_cast<double>(m) * 1000 + upm / 2) / upm);
+}
+
+// static
+bool CPDF_Font::FT_UseTTCharmap(FXFT_Face face,
+ int platform_id,
+ int encoding_id) {
+ auto** pCharMap = FXFT_Get_Face_Charmaps(face);
+ for (int i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) {
+ if (FXFT_Get_Charmap_PlatformID(pCharMap[i]) == platform_id &&
+ FXFT_Get_Charmap_EncodingID(pCharMap[i]) == encoding_id) {
+ FXFT_Set_Charmap(face, pCharMap[i]);
+ return true;
+ }
+ }
+ return false;
+}