MCPcopy Create free account
hub / github.com/antvis/F2Native / DrawInner

Method DrawInner

core/graphics/shape/Text.cpp:26–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26void 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
53BBox xg::shape::Text::CalculateBox(canvas::CanvasContext &context) const {
54 if(text_.empty()) {

Callers 1

DrawMethod · 0.45

Calls 3

SetGlobalAlphaMethod · 0.45
sizeMethod · 0.45
FillTextMethod · 0.45

Tested by

no test coverage detected