From 48ae177f1d3b198c6e67bc4314f9360e79e7b044 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Mon, 9 Apr 2018 18:41:56 +0800 Subject: [PATCH] bug fixed --- core/Node/Text.cpp | 13 ++++++++++--- core/etool.h | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/Node/Text.cpp b/core/Node/Text.cpp index 668e95b5..c376fb2b 100644 --- a/core/Node/Text.cpp +++ b/core/Node/Text.cpp @@ -101,9 +101,16 @@ UINT32 e2d::Text::getColor() const int e2d::Text::getLineCount() const { - DWRITE_TEXT_METRICS metrics; - m_pDWriteTextLayout->GetMetrics(&metrics); - return static_cast(metrics.lineCount); + if (m_pDWriteTextLayout) + { + DWRITE_TEXT_METRICS metrics; + m_pDWriteTextLayout->GetMetrics(&metrics); + return static_cast(metrics.lineCount); + } + else + { + return 0; + } } bool e2d::Text::isItalic() const diff --git a/core/etool.h b/core/etool.h index ab342cd8..6b45cece 100644 --- a/core/etool.h +++ b/core/etool.h @@ -18,6 +18,9 @@ public: template static inline T range(T min, T max) { return e2d::Random::randomInt(min, max); } + // 取得浮点数范围内的一个随机数 + static inline double range(float min, float max) { return e2d::Random::randomReal(min, max); } + // 取得浮点数范围内的一个随机数 static inline double range(double min, double max) { return e2d::Random::randomReal(min, max); }