summaryrefslogtreecommitdiff
path: root/core/fxge/fx_ge_fontmap.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-10 15:14:26 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-10 19:28:59 +0000
commit92e2276a8be492fd2be8e44a5d62e8a5879644d8 (patch)
tree0945f5edda0fbfb461ca1cae89a20adb583242e4 /core/fxge/fx_ge_fontmap.cpp
parent1437643bfaca635d52f4cb9ec41e3075cf893f79 (diff)
downloadpdfium-92e2276a8be492fd2be8e44a5d62e8a5879644d8.tar.xz
Move core/fxge/ge to core/fxge.
This brings the cpp and h files together and removes the redundant ge/ path. Change-Id: I36594b8ae719d362768ba4c2e4ce173e287363eb Reviewed-on: https://pdfium-review.googlesource.com/7452 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge/fx_ge_fontmap.cpp')
-rw-r--r--core/fxge/fx_ge_fontmap.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/core/fxge/fx_ge_fontmap.cpp b/core/fxge/fx_ge_fontmap.cpp
new file mode 100644
index 0000000000..7ac4fada5c
--- /dev/null
+++ b/core/fxge/fx_ge_fontmap.cpp
@@ -0,0 +1,93 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include <memory>
+
+#include "core/fxge/cfx_fontmapper.h"
+#include "core/fxge/ifx_systemfontinfo.h"
+
+static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr,
+ uint32_t string_ptr_length,
+ uint16_t offset,
+ uint16_t length) {
+ if (string_ptr_length < static_cast<uint32_t>(offset + length)) {
+ return CFX_ByteString();
+ }
+ return CFX_ByteString(string_ptr + offset, length);
+}
+
+CFX_ByteString GetNameFromTT(const uint8_t* name_table,
+ uint32_t name_table_size,
+ uint32_t name_id) {
+ if (!name_table || name_table_size < 6) {
+ return CFX_ByteString();
+ }
+ uint32_t name_count = GET_TT_SHORT(name_table + 2);
+ uint32_t string_offset = GET_TT_SHORT(name_table + 4);
+ // We will ignore the possibility of overlap of structures and
+ // string table as if it's all corrupt there's not a lot we can do.
+ if (name_table_size < string_offset) {
+ return CFX_ByteString();
+ }
+
+ const uint8_t* string_ptr = name_table + string_offset;
+ uint32_t string_ptr_size = name_table_size - string_offset;
+ name_table += 6;
+ name_table_size -= 6;
+ if (name_table_size < name_count * 12) {
+ return CFX_ByteString();
+ }
+
+ for (uint32_t i = 0; i < name_count; i++, name_table += 12) {
+ if (GET_TT_SHORT(name_table + 6) == name_id &&
+ GET_TT_SHORT(name_table) == 1 && GET_TT_SHORT(name_table + 2) == 0) {
+ return GetStringFromTable(string_ptr, string_ptr_size,
+ GET_TT_SHORT(name_table + 10),
+ GET_TT_SHORT(name_table + 8));
+ }
+ }
+ return CFX_ByteString();
+}
+#ifdef PDF_ENABLE_XFA
+void* IFX_SystemFontInfo::MapFontByUnicode(uint32_t dwUnicode,
+ int weight,
+ bool bItalic,
+ int pitch_family) {
+ return nullptr;
+}
+#endif // PDF_ENABLE_XFA
+
+int IFX_SystemFontInfo::GetFaceIndex(void* hFont) {
+ return 0;
+}
+
+extern "C" {
+unsigned long _FTStreamRead(FXFT_Stream stream,
+ unsigned long offset,
+ unsigned char* buffer,
+ unsigned long count);
+void _FTStreamClose(FXFT_Stream stream);
+};
+
+#if _FX_OS_ == _FX_ANDROID_
+std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault(
+ const char** pUnused) {
+ return nullptr;
+}
+#endif
+
+CFX_FontFaceInfo::CFX_FontFaceInfo(CFX_ByteString filePath,
+ CFX_ByteString faceName,
+ CFX_ByteString fontTables,
+ uint32_t fontOffset,
+ uint32_t fileSize)
+ : m_FilePath(filePath),
+ m_FaceName(faceName),
+ m_FontTables(fontTables),
+ m_FontOffset(fontOffset),
+ m_FileSize(fileSize),
+ m_Styles(0),
+ m_Charsets(0) {}