Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fgas / src / font / fx_gdifont.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FX_GDIOBJECT_IMP\r
8 #define _FX_GDIOBJECT_IMP\r
9 #ifdef _FXPLUS\r
10 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_\r
11 typedef struct _FX_GDIGOCACHE {\r
12     GLYPHMETRICS        gm;\r
13     FX_LPBYTE           pOutline;\r
14 } FX_GDIGOCACHE, * FX_LPGDIGOCACHE;\r
15 typedef FX_GDIGOCACHE const * FX_LPCGDIGOCACHE;\r
16 class CFX_GdiFontCache : public CFX_Object\r
17 {\r
18 public:\r
19     CFX_GdiFontCache();\r
20     ~CFX_GdiFontCache();\r
21     void                                SetCachedGlyphOutline(FX_DWORD dwGlyph, const GLYPHMETRICS &gm, FX_LPBYTE pOutline);\r
22     FX_LPCGDIGOCACHE    GetCachedGlyphOutline(FX_DWORD dwGlyph) const;\r
23 protected:\r
24     CFX_MapPtrToPtr             m_GlyphMap;\r
25 };\r
26 class CFX_GdiFont : public IFX_Font, public CFX_ThreadLock, public CFX_Object\r
27 {\r
28 public:\r
29     CFX_GdiFont(IFX_FontMgr *pFontMgr);\r
30     ~CFX_GdiFont();\r
31     virtual void                        Release();\r
32     virtual IFX_Font*           Retain();\r
33     FX_BOOL                     LoadFont(FX_LPCWSTR pszFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage);\r
34     FX_BOOL                     LoadFont(FX_LPCBYTE pBuffer, FX_INT32 iLength);\r
35     FX_BOOL                     LoadFont(FX_LPCWSTR pszFileName);\r
36     FX_BOOL                     LoadFont(IFX_Stream *pFontStream);\r
37     FX_BOOL                     LoadFont(const LOGFONTW &lf);\r
38     virtual IFX_Font*           Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0)\r
39     {\r
40         return NULL;\r
41     }\r
42     virtual void                        GetFamilyName(CFX_WideString &wsFamily) const;\r
43     virtual FX_DWORD            GetFontStyles() const\r
44     {\r
45         return m_dwStyles;\r
46     }\r
47     virtual FX_BYTE                     GetCharSet() const\r
48     {\r
49         return m_LogFont.lfCharSet;\r
50     }\r
51     virtual FX_BOOL                     GetCharWidth(FX_WCHAR wUnicode, FX_INT32 &iWidth, FX_BOOL bCharCode = FALSE);\r
52     virtual FX_INT32            GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE);\r
53     virtual FX_INT32            GetAscent() const;\r
54     virtual FX_INT32            GetDescent() const;\r
55     virtual FX_BOOL                     GetCharBBox(FX_WCHAR wUnicode, CFX_Rect &bbox, FX_BOOL bCharCode = FALSE);\r
56     virtual FX_BOOL                     GetBBox(CFX_Rect &bbox);\r
57     virtual FX_INT32            GetItalicAngle() const;\r
58     virtual void                        Reset();\r
59     FX_DWORD            GetGlyphDIBits(FX_INT32 iGlyphIndex, FX_ARGB argb, const MAT2 *pMatrix, GLYPHMETRICS &gm, FX_LPVOID pBuffer, FX_DWORD bufSize);\r
60     FX_DWORD            GetHashCode() const;\r
61 protected:\r
62     IFX_FontMgr                         *m_pFontMgr;\r
63     FX_INT32                            m_iRefCount;\r
64     CFX_WordDiscreteArray       m_WidthCache;\r
65     OUTLINETEXTMETRICW          m_OutlineTM;\r
66     HGDIOBJ                                     m_hOldFont;\r
67     HFONT                                       m_hFont;\r
68     HDC                                         m_hDC;\r
69     LOGFONTW                            m_LogFont;\r
70     CFX_WideString                      m_wsFontFileName;\r
71     CFX_WideStringArray         m_FontFamilies;\r
72     HANDLE                                      m_hRes;\r
73     FX_DWORD                            m_dwStyles;\r
74     CFX_PtrArray                        m_SubstFonts;\r
75     CFX_MapPtrToPtr                     m_FontMapper;\r
76     CFX_MapPtrToPtr                     m_FontCache;\r
77     void                        ClearCache();\r
78     FX_INT32            GetFontFamilies(Gdiplus::FontCollection &fc);\r
79     void                        RetrieveFontStyles();\r
80     IFX_Font*           GetSubstFont(FX_INT32 iGlyphIndex) const;\r
81     FX_BOOL                     GetCharWidth(FX_WCHAR wUnicode, FX_INT32 &iWidth, FX_BOOL bRecursive, FX_BOOL bCharCode = FALSE);\r
82     FX_INT32            GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bRecursive, IFX_Font **ppFont, FX_BOOL bCharCode = FALSE);\r
83     FX_DWORD            GetMAT2HashCode(const FIXED *pFixed);\r
84     void                        CreateGlyphBitmap(FX_INT32 iWidth, FX_INT32 iHeight, FX_LPBYTE pOutline, FX_LPDWORD pDIB, FX_ARGB argb);\r
85     friend class CFX_GdiFontMgr;\r
86 };\r
87 #endif\r
88 #endif\r
89 #endif\r