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

Method CalculateBox

core/graphics/shape/Text.cpp:53–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53BBox xg::shape::Text::CalculateBox(canvas::CanvasContext &context) const {
54 if(text_.empty()) {
55 return {static_cast<float>(std::nan("0"))};
56 } else {
57 const float height = GetTextHeight();
58 const float width = GetTextWidth(context);
59 Point point(point_.x, point_.y - height);
60 if(textAlign_ == "end" || textAlign_ == "right") {
61 point.x -= width;
62 } else if(textAlign_ == "center") {
63 point.x -= width / 2;
64 }
65
66 if(textBaseline_ == "top") {
67 point.y += height;
68 } else if(textBaseline_ == "middle") {
69 point.y += height / 2;
70 }
71 return {static_cast<float>(point.x),
72 static_cast<float>(point.x + width),
73 static_cast<float>(point.y),
74 static_cast<float>(point.y + height),
75 width,
76 height,
77 static_cast<float>(point_.x),
78 static_cast<float>(point_.y)};
79 }
80}
81
82std::string xg::shape::Text::GetFontStyle() const {
83 return CreateFontStyle(fontSize_, fontStyle_, fontVariant_, fontWeight_, fontFamily_);

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected