From c411eb943bb51e16ff4fb5a6ffb06e277ca6a982 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 25 Jul 2017 09:39:30 -0400 Subject: Move fpdfsdk/pdfwindow to fpdfsdk/pwl This makes it clearer what the directory contains. Change-Id: I34fc38dd30b8e0f6e057052ea33c8b5a10f1b9c3 Reviewed-on: https://pdfium-review.googlesource.com/8791 Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima Reviewed-by: Tom Sepez --- fpdfsdk/pwl/cpwl_font_map.h | 95 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 fpdfsdk/pwl/cpwl_font_map.h (limited to 'fpdfsdk/pwl/cpwl_font_map.h') diff --git a/fpdfsdk/pwl/cpwl_font_map.h b/fpdfsdk/pwl/cpwl_font_map.h new file mode 100644 index 0000000000..9872779c95 --- /dev/null +++ b/fpdfsdk/pwl/cpwl_font_map.h @@ -0,0 +1,95 @@ +// 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 + +#ifndef FPDFSDK_PWL_CPWL_FONT_MAP_H_ +#define FPDFSDK_PWL_CPWL_FONT_MAP_H_ + +#include +#include + +#include "core/fpdfdoc/ipvt_fontmap.h" +#include "core/fxcrt/fx_codepage.h" +#include "core/fxge/fx_font.h" +#include "public/fpdf_sysfontinfo.h" + +class CPDF_Document; +class CFX_SystemHandler; + +struct CPWL_FontMap_Data { + CPDF_Font* pFont; + int32_t nCharset; + CFX_ByteString sFontName; +}; + +struct CPWL_FontMap_Native { + int32_t nCharset; + CFX_ByteString sFontName; +}; + +class CPWL_FontMap : public IPVT_FontMap { + public: + explicit CPWL_FontMap(CFX_SystemHandler* pSystemHandler); + ~CPWL_FontMap() override; + + // IPVT_FontMap + CPDF_Font* GetPDFFont(int32_t nFontIndex) override; + CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override; + int32_t GetWordFontIndex(uint16_t word, + int32_t nCharset, + int32_t nFontIndex) override; + int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override; + int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override; + + const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const; + static int32_t GetNativeCharset(); + CFX_ByteString GetNativeFontName(int32_t nCharset); + + static CFX_ByteString GetDefaultFontByCharset(int32_t nCharset); + static const FPDF_CharsetFontMap defaultTTFMap[]; + + protected: + virtual void Initialize(); + virtual CPDF_Document* GetDocument(); + virtual CPDF_Font* FindFontSameCharset(CFX_ByteString* sFontAlias, + int32_t nCharset); + virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); + + bool KnowWord(int32_t nFontIndex, uint16_t word); + + void Empty(); + int32_t GetFontIndex(const CFX_ByteString& sFontName, + int32_t nCharset, + bool bFind); + int32_t AddFontData(CPDF_Font* pFont, + const CFX_ByteString& sFontAlias, + int32_t nCharset = FX_CHARSET_Default); + + CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, + int32_t nCharset); + CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); + + std::vector> m_Data; + std::vector> m_NativeFont; + + private: + int32_t FindFont(const CFX_ByteString& sFontName, + int32_t nCharset = FX_CHARSET_Default); + + CFX_ByteString GetNativeFont(int32_t nCharset); + CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, + CFX_ByteString& sFontName, + uint8_t nCharset); + bool IsStandardFont(const CFX_ByteString& sFontName); + CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); + CPDF_Font* AddSystemFont(CPDF_Document* pDoc, + CFX_ByteString& sFontName, + uint8_t nCharset); + + std::unique_ptr m_pPDFDoc; + CFX_UnownedPtr const m_pSystemHandler; +}; + +#endif // FPDFSDK_PWL_CPWL_FONT_MAP_H_ -- cgit v1.2.3