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 --- 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 ----------------------------------------- 8 files changed, 111 insertions(+), 47 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 (limited to 'core/fxge/ge') 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, -- cgit v1.2.3