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

Method GetTextWidth

core/graphics/shape/Text.cpp:99–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99float xg::shape::Text::GetTextWidth(canvas::CanvasContext &context) const {
100 if(!std::isnan(width_)) {
101 return width_;
102 }
103
104 context.SetFont(font_);
105 if(textArr_.size()) {
106 float maxWidth = 0;
107 for_each(textArr_.begin(), textArr_.end(),
108 [&maxWidth, &context](const std::string &t) { maxWidth = std::max(maxWidth, context.MeasureTextWidth(t)); });
109 return maxWidth;
110 } else {
111 return context.MeasureTextWidth(text_);
112 }
113}
114
115float xg::shape::Text::GetTextHeightWithContext(canvas::CanvasContext &context) const {
116 if(!std::isnan(height_)) {

Callers 3

SetXTipContentMethod · 0.80
SetYTipContentMethod · 0.80
CalLegendWidthMethod · 0.80

Calls 5

beginMethod · 0.80
endMethod · 0.80
SetFontMethod · 0.45
sizeMethod · 0.45
MeasureTextWidthMethod · 0.45

Tested by

no test coverage detected