blob: 43b5c5876ed46ff949d886468c518d35478004c6 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// Copyright 2014 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 XFA_FGAS_FONT_FGAS_GEFONT_H_
8#define XFA_FGAS_FONT_FGAS_GEFONT_H_
9
10#include "xfa/fgas/crt/fgas_utils.h"
11#include "xfa/fgas/font/fgas_font.h"
12
13#define FXFONT_SUBST_ITALIC 0x02
14
dsinclair303e5252016-04-27 12:47:01 -070015class CXFA_PDFFontMgr;
16
Dan Sinclair1770c022016-03-14 14:14:16 -040017class CFX_GEFont : public IFX_Font {
18 public:
tsepezdeee3d22016-03-25 14:38:58 -070019 CFX_GEFont(const CFX_GEFont& src, uint32_t dwFontStyles);
Dan Sinclair1770c022016-03-14 14:14:16 -040020 CFX_GEFont(IFX_FontMgr* pFontMgr);
21 ~CFX_GEFont();
22 virtual void Release();
23 virtual IFX_Font* Retain();
24 FX_BOOL LoadFont(const FX_WCHAR* pszFontFamily,
tsepezdeee3d22016-03-25 14:38:58 -070025 uint32_t dwFontStyles,
Tom Sepez62a70f92016-03-21 15:00:20 -070026 uint16_t wCodePage);
Dan Sinclair1770c022016-03-14 14:14:16 -040027 FX_BOOL LoadFont(const uint8_t* pBuffer, int32_t length);
28 FX_BOOL LoadFont(const FX_WCHAR* pszFileName);
29 FX_BOOL LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream);
30 FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver = FALSE);
tsepezdeee3d22016-03-25 14:38:58 -070031 virtual IFX_Font* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0);
Dan Sinclair1770c022016-03-14 14:14:16 -040032 virtual void GetFamilyName(CFX_WideString& wsFamily) const;
33 virtual void GetPsName(CFX_WideString& wsName) const;
tsepezdeee3d22016-03-25 14:38:58 -070034 virtual uint32_t GetFontStyles() const;
Dan Sinclair1770c022016-03-14 14:14:16 -040035 virtual uint8_t GetCharSet() const;
36 virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
37 int32_t& iWidth,
38 FX_BOOL bCharCode = FALSE);
39 virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE);
40 virtual int32_t GetAscent() const;
41 virtual int32_t GetDescent() const;
42 virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
43 CFX_Rect& bbox,
44 FX_BOOL bCharCode = FALSE);
45 virtual FX_BOOL GetBBox(CFX_Rect& bbox);
46 virtual int32_t GetItalicAngle() const;
47 virtual void Reset();
48 virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const;
49 virtual void* GetDevFont() const { return (void*)m_pFont; }
dsinclair303e5252016-04-27 12:47:01 -070050 virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) {
Dan Sinclair1770c022016-03-14 14:14:16 -040051 m_pProvider = pProvider;
52 }
53#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
tsepezdeee3d22016-03-25 14:38:58 -070054 virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) {
Dan Sinclair1770c022016-03-14 14:14:16 -040055 m_bUseLogFontStyle = TRUE;
56 m_dwLogFontStyle = dwLogFontStyle;
57 }
58#endif
59
60 protected:
61#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
62 FX_BOOL m_bUseLogFontStyle;
tsepezdeee3d22016-03-25 14:38:58 -070063 uint32_t m_dwLogFontStyle;
Dan Sinclair1770c022016-03-14 14:14:16 -040064#endif
65 CFX_Font* m_pFont;
66 IFX_FontMgr* m_pFontMgr;
67 int32_t m_iRefCount;
68 FX_BOOL m_bExtFont;
69 IFX_Stream* m_pStream;
70 IFX_FileRead* m_pFileRead;
71 CFX_UnicodeEncoding* m_pFontEncoding;
72 CFX_WordDiscreteArray* m_pCharWidthMap;
73 CFX_RectMassArray* m_pRectArray;
74 CFX_MapPtrToPtr* m_pBBoxMap;
dsinclair303e5252016-04-27 12:47:01 -070075 CXFA_PDFFontMgr* m_pProvider;
Tom Sepez62a70f92016-03-21 15:00:20 -070076 uint16_t m_wCharSet;
Dan Sinclair1770c022016-03-14 14:14:16 -040077 CFX_PtrArray m_SubstFonts;
78 CFX_MapPtrToPtr m_FontMapper;
79 FX_BOOL InitFont();
80 FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
81 CFX_Rect& bbox,
82 FX_BOOL bRecursive,
83 FX_BOOL bCharCode = FALSE);
84 FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
85 int32_t& iWidth,
86 FX_BOOL bRecursive,
87 FX_BOOL bCharCode = FALSE);
88 int32_t GetGlyphIndex(FX_WCHAR wUnicode,
89 FX_BOOL bRecursive,
90 IFX_Font** ppFont,
91 FX_BOOL bCharCode = FALSE);
92};
93
94#endif // XFA_FGAS_FONT_FGAS_GEFONT_H_