diff options
author | npm <npm@chromium.org> | 2016-08-29 09:35:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-29 09:35:12 -0700 |
commit | 81ee14da357bb8bb141930d96e07a46f6d472720 (patch) | |
tree | bb3d188137887b563ea111d090fbd0f05ed7f5a5 /core | |
parent | 5283e674fecf3732d89a8f7f144545af2301ccec (diff) | |
download | pdfium-81ee14da357bb8bb141930d96e07a46f6d472720.tar.xz |
Move CFX_SubstFont and CTTFontDesc into their own files
Review-Url: https://codereview.chromium.org/2292503002
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfdoc/cpdf_interform.cpp | 1 | ||||
-rw-r--r-- | core/fxge/ge/cfx_facecache.cpp | 1 | ||||
-rw-r--r-- | core/fxge/ge/cfx_fontmapper.cpp | 1 | ||||
-rw-r--r-- | core/fxge/ge/cfx_fontmgr.cpp | 4 | ||||
-rw-r--r-- | core/fxge/ge/cfx_substfont.cpp | 18 | ||||
-rw-r--r-- | core/fxge/ge/cttfontdesc.cpp | 42 | ||||
-rw-r--r-- | core/fxge/ge/cttfontdesc.h | 45 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_font.cpp | 1 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_fontmap.cpp | 46 | ||||
-rw-r--r-- | core/fxge/include/cfx_fontmapper.h | 2 | ||||
-rw-r--r-- | core/fxge/include/cfx_fontmgr.h | 2 | ||||
-rw-r--r-- | core/fxge/include/cfx_substfont.h | 34 | ||||
-rw-r--r-- | core/fxge/include/fx_font.h | 61 |
13 files changed, 151 insertions, 107 deletions
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index a6f73c620b..d567e09e82 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -16,6 +16,7 @@ #include "core/fpdfdoc/include/cpdf_filespec.h" #include "core/fpdfdoc/include/cpdf_formcontrol.h" #include "core/fpdfdoc/include/cpdf_interform.h" +#include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/fx_font.h" #include "third_party/base/stl_util.h" diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp index 7c85b06e0c..c35830fbde 100644 --- a/core/fxge/ge/cfx_facecache.cpp +++ b/core/fxge/ge/cfx_facecache.cpp @@ -12,6 +12,7 @@ #include "core/fxge/include/cfx_fontmgr.h" #include "core/fxge/include/cfx_gemodule.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/fx_freetype.h" #ifdef _SKIA_SUPPORT_ diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp index 56bfdcac5e..37c1d03785 100644 --- a/core/fxge/ge/cfx_fontmapper.cpp +++ b/core/fxge/ge/cfx_fontmapper.cpp @@ -10,6 +10,7 @@ #include <utility> #include <vector> +#include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/ifx_systemfontinfo.h" #include "core/fxge/include/fx_font.h" diff --git a/core/fxge/ge/cfx_fontmgr.cpp b/core/fxge/ge/cfx_fontmgr.cpp index 3f03988cb7..ec1d81b237 100644 --- a/core/fxge/ge/cfx_fontmgr.cpp +++ b/core/fxge/ge/cfx_fontmgr.cpp @@ -7,9 +7,11 @@ #include "core/fxge/include/cfx_fontmgr.h" #include "core/fxge/fontdata/chromefontdata/chromefontdata.h" +#include "core/fxge/ge/cttfontdesc.h" #include "core/fxge/include/cfx_fontmapper.h" -#include "core/fxge/include/ifx_systemfontinfo.h" +#include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/fx_font.h" +#include "core/fxge/include/ifx_systemfontinfo.h" namespace { diff --git a/core/fxge/ge/cfx_substfont.cpp b/core/fxge/ge/cfx_substfont.cpp new file mode 100644 index 0000000000..5014af74f2 --- /dev/null +++ b/core/fxge/ge/cfx_substfont.cpp @@ -0,0 +1,18 @@ +// Copyright 2016 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 "core/fxge/include/cfx_substfont.h" + +#include "core/fxge/include/fx_font.h" + +CFX_SubstFont::CFX_SubstFont() + : m_Charset(FXFONT_ANSI_CHARSET), + m_SubstFlags(0), + m_Weight(0), + m_ItalicAngle(0), + m_bSubstCJK(false), + m_WeightCJK(0), + m_bItalicCJK(false) {} diff --git a/core/fxge/ge/cttfontdesc.cpp b/core/fxge/ge/cttfontdesc.cpp new file mode 100644 index 0000000000..31018cb3da --- /dev/null +++ b/core/fxge/ge/cttfontdesc.cpp @@ -0,0 +1,42 @@ +// Copyright 2016 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 "core/fxge/ge/cttfontdesc.h" + +#include "core/fxge/include/fx_freetype.h" + +CTTFontDesc::~CTTFontDesc() { + if (m_Type == 1) { + if (m_SingleFace.m_pFace) + FXFT_Done_Face(m_SingleFace.m_pFace); + } else if (m_Type == 2) { + for (int i = 0; i < 16; i++) { + if (m_TTCFace.m_pFaces[i]) + FXFT_Done_Face(m_TTCFace.m_pFaces[i]); + } + } + FX_Free(m_pFontData); +} + +int CTTFontDesc::ReleaseFace(FXFT_Face face) { + if (m_Type == 1) { + if (m_SingleFace.m_pFace != face) + return -1; + } else if (m_Type == 2) { + int i; + for (i = 0; i < 16; i++) { + if (m_TTCFace.m_pFaces[i] == face) + break; + } + if (i == 16) + return -1; + } + m_RefCount--; + if (m_RefCount) + return m_RefCount; + delete this; + return 0; +} diff --git a/core/fxge/ge/cttfontdesc.h b/core/fxge/ge/cttfontdesc.h new file mode 100644 index 0000000000..05cafde980 --- /dev/null +++ b/core/fxge/ge/cttfontdesc.h @@ -0,0 +1,45 @@ +// Copyright 2016 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 CORE_FXGE_GE_CTTFONTDESC_H_ +#define CORE_FXGE_GE_CTTFONTDESC_H_ + +#include "core/fxcrt/include/fx_system.h" +#include "core/fxge/include/fx_font.h" + +#define FX_FONT_FLAG_SERIF 0x01 +#define FX_FONT_FLAG_FIXEDPITCH 0x02 +#define FX_FONT_FLAG_ITALIC 0x04 +#define FX_FONT_FLAG_BOLD 0x08 +#define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10 +#define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20 +#define FX_FONT_FLAG_MULTIPLEMASTER 0x40 + +class CTTFontDesc { + public: + CTTFontDesc() : m_Type(0), m_pFontData(nullptr), m_RefCount(0) {} + ~CTTFontDesc(); + // ret < 0, releaseface not appropriate for this object. + // ret == 0, object released + // ret > 0, object still alive, other referrers. + int ReleaseFace(FXFT_Face face); + + int m_Type; + union { + struct { + FX_BOOL m_bItalic; + FX_BOOL m_bBold; + FXFT_Face m_pFace; + } m_SingleFace; + struct { + FXFT_Face m_pFaces[16]; + } m_TTCFace; + }; + uint8_t* m_pFontData; + int m_RefCount; +}; + +#endif // CORE_FXGE_GE_CTTFONTDESC_H_ diff --git a/core/fxge/ge/fx_ge_font.cpp b/core/fxge/ge/fx_ge_font.cpp index e459d6b083..cb86429ef6 100644 --- a/core/fxge/ge/fx_ge_font.cpp +++ b/core/fxge/ge/fx_ge_font.cpp @@ -10,6 +10,7 @@ #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/cfx_fontmgr.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/fx_freetype.h" #define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em) diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 6de364788b..2f5410517d 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -7,52 +7,6 @@ #include "core/fxge/include/cfx_fontmapper.h" #include "core/fxge/include/ifx_systemfontinfo.h" -CFX_SubstFont::CFX_SubstFont() { - m_Charset = FXFONT_ANSI_CHARSET; - m_SubstFlags = 0; - m_Weight = 0; - m_ItalicAngle = 0; - m_bSubstCJK = false; - m_WeightCJK = 0; - m_bItalicCJK = false; -} - -CTTFontDesc::~CTTFontDesc() { - if (m_Type == 1) { - if (m_SingleFace.m_pFace) { - FXFT_Done_Face(m_SingleFace.m_pFace); - } - } else if (m_Type == 2) { - for (int i = 0; i < 16; i++) - if (m_TTCFace.m_pFaces[i]) { - FXFT_Done_Face(m_TTCFace.m_pFaces[i]); - } - } - FX_Free(m_pFontData); -} -int CTTFontDesc::ReleaseFace(FXFT_Face face) { - if (m_Type == 1) { - if (m_SingleFace.m_pFace != face) { - return -1; - } - } else if (m_Type == 2) { - int i; - for (i = 0; i < 16; i++) - if (m_TTCFace.m_pFaces[i] == face) { - break; - } - if (i == 16) { - return -1; - } - } - m_RefCount--; - if (m_RefCount) { - return m_RefCount; - } - delete this; - return 0; -} - static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, uint32_t string_ptr_length, uint16_t offset, diff --git a/core/fxge/include/cfx_fontmapper.h b/core/fxge/include/cfx_fontmapper.h index 09d5429044..0d82855c41 100644 --- a/core/fxge/include/cfx_fontmapper.h +++ b/core/fxge/include/cfx_fontmapper.h @@ -13,6 +13,8 @@ #include "core/fxge/include/cfx_fontmgr.h" #include "core/fxge/include/fx_font.h" +class CFX_SubstFont; + class CFX_FontMapper { public: explicit CFX_FontMapper(CFX_FontMgr* mgr); diff --git a/core/fxge/include/cfx_fontmgr.h b/core/fxge/include/cfx_fontmgr.h index dac8c5ac7b..c8e66aee14 100644 --- a/core/fxge/include/cfx_fontmgr.h +++ b/core/fxge/include/cfx_fontmgr.h @@ -14,6 +14,8 @@ class IFX_SystemFontInfo; class CFX_FontMapper; +class CFX_SubstFont; +class CTTFontDesc; class CFX_FontMgr { public: diff --git a/core/fxge/include/cfx_substfont.h b/core/fxge/include/cfx_substfont.h new file mode 100644 index 0000000000..a712a7a7a7 --- /dev/null +++ b/core/fxge/include/cfx_substfont.h @@ -0,0 +1,34 @@ +// Copyright 2016 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 CORE_FXGE_INCLUDE_CFX_SUBSTFONT_H_ +#define CORE_FXGE_INCLUDE_CFX_SUBSTFONT_H_ + +#include "core/fxcrt/include/fx_string.h" + +#define FXFONT_SUBST_MM 0x01 +#define FXFONT_SUBST_GLYPHPATH 0x04 +#define FXFONT_SUBST_CLEARTYPE 0x08 +#define FXFONT_SUBST_TRANSFORM 0x10 +#define FXFONT_SUBST_NONSYMBOL 0x20 +#define FXFONT_SUBST_EXACT 0x40 +#define FXFONT_SUBST_STANDARD 0x80 + +class CFX_SubstFont { + public: + CFX_SubstFont(); + + CFX_ByteString m_Family; + int m_Charset; + uint32_t m_SubstFlags; + int m_Weight; + int m_ItalicAngle; + bool m_bSubstCJK; + int m_WeightCJK; + bool m_bItalicCJK; +}; + +#endif // CORE_FXGE_INCLUDE_CFX_SUBSTFONT_H_ diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h index 28c51b131c..cdde643770 100644 --- a/core/fxge/include/fx_font.h +++ b/core/fxge/include/fx_font.h @@ -7,11 +7,11 @@ #ifndef CORE_FXGE_INCLUDE_FX_FONT_H_ #define CORE_FXGE_INCLUDE_FX_FONT_H_ -#include <map> #include <memory> #include <vector> #include "core/fxcrt/include/fx_system.h" +#include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/fx_dib.h" #include "core/fxge/include/fx_freetype.h" @@ -22,8 +22,6 @@ class CFX_FaceCache; class CFX_FontCache; class CFX_PathData; class CFX_SizeGlyphCache; -class CFX_SubstFont; -class CTTFontDesc; #ifdef _SKIA_SUPPORT_ class SkTypeface; @@ -174,63 +172,6 @@ class CFX_Font { FX_BOOL m_bVertical; }; -#define FXFONT_SUBST_MM 0x01 -#define FXFONT_SUBST_GLYPHPATH 0x04 -#define FXFONT_SUBST_CLEARTYPE 0x08 -#define FXFONT_SUBST_TRANSFORM 0x10 -#define FXFONT_SUBST_NONSYMBOL 0x20 -#define FXFONT_SUBST_EXACT 0x40 -#define FXFONT_SUBST_STANDARD 0x80 - -class CFX_SubstFont { - public: - CFX_SubstFont(); - - CFX_ByteString m_Family; - int m_Charset; - uint32_t m_SubstFlags; - int m_Weight; - int m_ItalicAngle; - bool m_bSubstCJK; - int m_WeightCJK; - bool m_bItalicCJK; -}; - -#define FX_FONT_FLAG_SERIF 0x01 -#define FX_FONT_FLAG_FIXEDPITCH 0x02 -#define FX_FONT_FLAG_ITALIC 0x04 -#define FX_FONT_FLAG_BOLD 0x08 -#define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10 -#define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20 -#define FX_FONT_FLAG_MULTIPLEMASTER 0x40 - -class CTTFontDesc { - public: - CTTFontDesc() { - m_Type = 0; - m_pFontData = nullptr; - m_RefCount = 0; - } - ~CTTFontDesc(); - // ret < 0, releaseface not appropriate for this object. - // ret == 0, object released - // ret > 0, object still alive, other referrers. - int ReleaseFace(FXFT_Face face); - int m_Type; - union { - struct { - FX_BOOL m_bItalic; - FX_BOOL m_bBold; - FXFT_Face m_pFace; - } m_SingleFace; - struct { - FXFT_Face m_pFaces[16]; - } m_TTCFace; - }; - uint8_t* m_pFontData; - int m_RefCount; -}; - class CFX_FontFaceInfo { public: CFX_FontFaceInfo(CFX_ByteString filePath, |