From 095446b06393c9bf2f2635a102d998974562f4b1 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Tue, 22 May 2018 22:00:47 +0800 Subject: [PATCH] =?UTF-8?q?Font=E7=B1=BB=E7=A7=BB=E5=8A=A8=E5=88=B0Common?= =?UTF-8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Common/Font.cpp | 17 ++++++++++++ core/Node/Text.cpp | 24 +---------------- core/e2dcommon.h | 38 +++++++++++++++++++++++++++ core/e2dnode.h | 37 -------------------------- project/vs2017/Easy2D.vcxproj | 1 + project/vs2017/Easy2D.vcxproj.filters | 3 +++ 6 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 core/Common/Font.cpp diff --git a/core/Common/Font.cpp b/core/Common/Font.cpp new file mode 100644 index 00000000..4ed9e879 --- /dev/null +++ b/core/Common/Font.cpp @@ -0,0 +1,17 @@ +#include "..\e2dcommon.h" + +e2d::Font::Font() + : family("") + , size(22) + , weight(Font::Weight::NORMAL) + , italic(false) +{ +} + +e2d::Font::Font(const String & family, double size, UINT weight, bool italic) + : family(family) + , size(size) + , weight(weight) + , italic(italic) +{ +} \ No newline at end of file diff --git a/core/Node/Text.cpp b/core/Node/Text.cpp index d8f38bab..9ad86d95 100644 --- a/core/Node/Text.cpp +++ b/core/Node/Text.cpp @@ -1,27 +1,5 @@ #include "..\e2dnode.h" - -//------------------------------------------------------- -// Font -//------------------------------------------------------- - -e2d::Text::Font::Font() - : family("") - , size(22) - , weight(Font::Weight::NORMAL) - , italic(false) -{ -} - -e2d::Text::Font::Font(const String & family, double size, UINT weight, bool italic) - : family(family) - , size(size) - , weight(weight) - , italic(italic) -{ -} - - //------------------------------------------------------- // Style //------------------------------------------------------- @@ -101,7 +79,7 @@ e2d::String e2d::Text::getText() const return _text; } -e2d::Text::Font e2d::Text::getFont() const +e2d::Font e2d::Text::getFont() const { return _font; } diff --git a/core/e2dcommon.h b/core/e2dcommon.h index 46ddf8e9..15942404 100644 --- a/core/e2dcommon.h +++ b/core/e2dcommon.h @@ -347,6 +347,44 @@ protected: }; +// 字体 +class Font +{ +public: + String family; // 字体族 + double size; // 字号 + UINT weight; // 粗细值 + bool italic; // 斜体 + +public: + // 字体粗细值 + enum Weight : UINT + { + THIN = 100, + EXTRA_LIGHT = 200, + LIGHT = 300, + SEMI_LIGHT = 350, + NORMAL = 400, + MEDIUM = 500, + DEMI_BOLD = 600, + BOLD = 700, + EXTRA_BOLD = 800, + BLACK = 900, + EXTRA_BLACK = 950 + }; + +public: + Font(); + + Font( + const String& family, + double size = 22, + UINT weight = Font::Weight::NORMAL, + bool italic = false + ); +}; + + // 基础对象 class Object { diff --git a/core/e2dnode.h b/core/e2dnode.h index 9ee825a8..c39af2a7 100644 --- a/core/e2dnode.h +++ b/core/e2dnode.h @@ -543,43 +543,6 @@ class Text : public Node { public: - // 字体 - class Font - { - public: - String family; // 字体族 - double size; // 字号 - UINT weight; // 粗细值 - bool italic; // 斜体 - - public: - // 字体粗细值 - enum Weight : UINT - { - THIN = 100, - EXTRA_LIGHT = 200, - LIGHT = 300, - SEMI_LIGHT = 350, - NORMAL = 400, - MEDIUM = 500, - DEMI_BOLD = 600, - BOLD = 700, - EXTRA_BOLD = 800, - BLACK = 900, - EXTRA_BLACK = 950 - }; - - public: - Font(); - - Font( - const String& family, - double size = 22, - UINT weight = Font::Weight::NORMAL, - bool italic = false - ); - }; - // 文本对齐方式 enum class Align : int { diff --git a/project/vs2017/Easy2D.vcxproj b/project/vs2017/Easy2D.vcxproj index be85718d..b91da693 100644 --- a/project/vs2017/Easy2D.vcxproj +++ b/project/vs2017/Easy2D.vcxproj @@ -227,6 +227,7 @@ + diff --git a/project/vs2017/Easy2D.vcxproj.filters b/project/vs2017/Easy2D.vcxproj.filters index 184a2b93..95310d73 100644 --- a/project/vs2017/Easy2D.vcxproj.filters +++ b/project/vs2017/Easy2D.vcxproj.filters @@ -231,6 +231,9 @@ Tool + + Common +