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); }