| 2 | #include <utils/StringUtil.h> |
| 3 | |
| 4 | xg::shape::Text::Text(const std::string &text, const Point &pt, const float fontSize, const std::string &strokeColor, const std::string &fillColor) { |
| 5 | type_ = "text"; |
| 6 | lineWidth_ = std::nan("0"); |
| 7 | point_ = pt; |
| 8 | fontSize_ = fontSize; |
| 9 | |
| 10 | if(!fillColor.empty()) { |
| 11 | fillStyle_ = canvas::CanvasFillStrokeStyle(fillColor); |
| 12 | } |
| 13 | if(!strokeColor.empty()) { |
| 14 | strokeStyle_ = canvas::CanvasFillStrokeStyle(strokeColor); |
| 15 | } |
| 16 | |
| 17 | font_ = GetFontStyle(); |
| 18 | text_ = text; |
| 19 | lineCount_ = 1; |
| 20 | if(text.size() && text.find("\n") != string::npos) { |
| 21 | StringUtil::Split(text, textArr_, '\n'); |
| 22 | lineCount_ = (int)textArr_.size(); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | void xg::shape::Text::DrawInner(canvas::CanvasContext &context) const { |
| 27 | if(std::isnan(point_.x) || std::isnan(point_.y)) { |
no test coverage detected