| 24 | } |
| 25 | |
| 26 | void xg::shape::Text::DrawInner(canvas::CanvasContext &context) const { |
| 27 | if(std::isnan(point_.x) || std::isnan(point_.y)) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | if(HasFill()) { |
| 32 | if(!std::isnan(fillOpacity_)) { |
| 33 | context.SetGlobalAlpha(fillOpacity_); |
| 34 | } |
| 35 | if(textArr_.size()) { |
| 36 | float spaceingY = GetSpacingY(); |
| 37 | float height = GetTextHeight(); |
| 38 | for(std::size_t i = 0; i < textArr_.size(); ++i) { |
| 39 | float subY = point_.y + i * (spaceingY + fontSize_) - height + fontSize_; |
| 40 | if(textBaseline_ == "middle") { |
| 41 | subY += height - fontSize_ - (height - fontSize_) / 2; |
| 42 | } else if(textBaseline_ == "top") { |
| 43 | subY += height - fontSize_; |
| 44 | } |
| 45 | context.FillText(textArr_[i], point_.x, subY); |
| 46 | } |
| 47 | } else { |
| 48 | context.FillText(text_, point_.x, point_.y); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | BBox xg::shape::Text::CalculateBox(canvas::CanvasContext &context) const { |
| 54 | if(text_.empty()) { |
no test coverage detected