From 81ee14da357bb8bb141930d96e07a46f6d472720 Mon Sep 17 00:00:00 2001 From: npm Date: Mon, 29 Aug 2016 09:35:12 -0700 Subject: Move CFX_SubstFont and CTTFontDesc into their own files Review-Url: https://codereview.chromium.org/2292503002 --- BUILD.gn | 4 +++ core/fpdfdoc/cpdf_interform.cpp | 1 + core/fxge/ge/cfx_facecache.cpp | 1 + core/fxge/ge/cfx_fontmapper.cpp | 1 + core/fxge/ge/cfx_fontmgr.cpp | 4 ++- core/fxge/ge/cfx_substfont.cpp | 18 +++++++++++ core/fxge/ge/cttfontdesc.cpp | 42 ++++++++++++++++++++++++++ core/fxge/ge/cttfontdesc.h | 45 ++++++++++++++++++++++++++++ core/fxge/ge/fx_ge_font.cpp | 1 + core/fxge/ge/fx_ge_fontmap.cpp | 46 ---------------------------- core/fxge/include/cfx_fontmapper.h | 2 ++ core/fxge/include/cfx_fontmgr.h | 2 ++ core/fxge/include/cfx_substfont.h | 34 +++++++++++++++++++++ core/fxge/include/fx_font.h | 61 +------------------------------------- fpdfsdk/formfiller/cba_fontmap.cpp | 1 + xfa/fde/fde_gedevice.cpp | 1 + xfa/fgas/font/fgas_gefont.cpp | 1 + 17 files changed, 158 insertions(+), 107 deletions(-) create mode 100644 core/fxge/ge/cfx_substfont.cpp create mode 100644 core/fxge/ge/cttfontdesc.cpp create mode 100644 core/fxge/ge/cttfontdesc.h create mode 100644 core/fxge/include/cfx_substfont.h diff --git a/BUILD.gn b/BUILD.gn index c898f4d413..982c57a179 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -769,7 +769,10 @@ static_library("fxge") { "core/fxge/ge/cfx_graphstatedata.cpp", "core/fxge/ge/cfx_pathdata.cpp", "core/fxge/ge/cfx_renderdevice.cpp", + "core/fxge/ge/cfx_substfont.cpp", "core/fxge/ge/cfx_unicodeencoding.cpp", + "core/fxge/ge/cttfontdesc.cpp", + "core/fxge/ge/cttfontdesc.h", "core/fxge/ge/fx_ge_font.cpp", "core/fxge/ge/fx_ge_fontmap.cpp", "core/fxge/ge/fx_ge_linux.cpp", @@ -787,6 +790,7 @@ static_library("fxge") { "core/fxge/include/cfx_graphstatedata.h", "core/fxge/include/cfx_pathdata.h", "core/fxge/include/cfx_renderdevice.h", + "core/fxge/include/cfx_substfont.h", "core/fxge/include/cfx_unicodeencoding.h", "core/fxge/include/cfx_windowsdevice.h", "core/fxge/include/fx_dib.h", 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 #include +#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 #include #include #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, diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 97590d20dd..a816e2ce7f 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -13,6 +13,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfdoc/include/cpdf_formfield.h" +#include "core/fxge/include/cfx_substfont.h" #include "fpdfsdk/include/cpdfsdk_annot.h" CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp index 778eb73879..8279e777b0 100644 --- a/xfa/fde/fde_gedevice.cpp +++ b/xfa/fde/fde_gedevice.cpp @@ -12,6 +12,7 @@ #include "core/fxge/include/cfx_gemodule.h" #include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_renderdevice.h" +#include "core/fxge/include/cfx_substfont.h" #include "xfa/fde/cfde_path.h" #include "xfa/fde/fde_object.h" #include "xfa/fgas/font/fgas_font.h" diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp index 3a5b1cdbca..1507fa4840 100644 --- a/xfa/fgas/font/fgas_gefont.cpp +++ b/xfa/fgas/font/fgas_gefont.cpp @@ -6,6 +6,7 @@ #include "xfa/fgas/font/fgas_gefont.h" +#include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/cfx_unicodeencoding.h" #include "core/fxge/include/cfx_unicodeencodingex.h" #include "xfa/fgas/crt/fgas_codepage.h" -- cgit v1.2.3