Home | History | Annotate | Download | only in ge
      1 // Copyright 2016 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef CORE_FXGE_GE_CFX_FOLDERFONTINFO_H_
      8 #define CORE_FXGE_GE_CFX_FOLDERFONTINFO_H_
      9 
     10 #include <map>
     11 #include <vector>
     12 
     13 #include "core/fxge/cfx_fontmapper.h"
     14 #include "core/fxge/fx_font.h"
     15 #include "core/fxge/ifx_systemfontinfo.h"
     16 
     17 class CFX_FolderFontInfo : public IFX_SystemFontInfo {
     18  public:
     19   CFX_FolderFontInfo();
     20   ~CFX_FolderFontInfo() override;
     21 
     22   void AddPath(const CFX_ByteStringC& path);
     23 
     24   // IFX_SytemFontInfo:
     25   bool EnumFontList(CFX_FontMapper* pMapper) override;
     26   void* MapFont(int weight,
     27                 bool bItalic,
     28                 int charset,
     29                 int pitch_family,
     30                 const FX_CHAR* face,
     31                 int& bExact) override;
     32 #ifdef PDF_ENABLE_XFA
     33   void* MapFontByUnicode(uint32_t dwUnicode,
     34                          int weight,
     35                          bool bItalic,
     36                          int pitch_family) override;
     37 #endif  // PDF_ENABLE_XFA
     38   void* GetFont(const FX_CHAR* face) override;
     39   uint32_t GetFontData(void* hFont,
     40                        uint32_t table,
     41                        uint8_t* buffer,
     42                        uint32_t size) override;
     43   void DeleteFont(void* hFont) override;
     44   bool GetFaceName(void* hFont, CFX_ByteString& name) override;
     45   bool GetFontCharset(void* hFont, int& charset) override;
     46 
     47  protected:
     48   void ScanPath(const CFX_ByteString& path);
     49   void ScanFile(const CFX_ByteString& path);
     50   void ReportFace(const CFX_ByteString& path,
     51                   FXSYS_FILE* pFile,
     52                   uint32_t filesize,
     53                   uint32_t offset);
     54   void* GetSubstFont(const CFX_ByteString& face);
     55   void* FindFont(int weight,
     56                  bool bItalic,
     57                  int charset,
     58                  int pitch_family,
     59                  const FX_CHAR* family,
     60                  bool bMatchName);
     61 
     62   std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList;
     63   std::vector<CFX_ByteString> m_PathList;
     64   CFX_FontMapper* m_pMapper;
     65 };
     66 
     67 #endif  // CORE_FXGE_GE_CFX_FOLDERFONTINFO_H_
     68