MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetWidth

Method GetWidth

src/gfx_layout_fallback.cpp:155–168  ·  view source on GitHub ↗

* Get the width of this line. * @return The width of the line. */

Source from the content-addressed store, hash-verified

153 * @return The width of the line.
154 */
155int FallbackParagraphLayout::FallbackLine::GetWidth() const
156{
157 if (this->empty()) return 0;
158
159 /*
160 * The last X position of a run contains is the end of that run.
161 * Since there is no left-to-right support, taking this value of
162 * the last run gives us the end of the line and thus the width.
163 */
164 const auto &run = this->GetVisualRun(this->CountRuns() - 1);
165 const auto &positions = run.GetPositions();
166 if (positions.empty()) return 0;
167 return positions.back().right + 1;
168}
169
170/**
171 * Get the number of runs in this line.

Callers 1

NextLineMethod · 0.45

Calls 3

CountRunsMethod · 0.95
emptyMethod · 0.45
GetPositionsMethod · 0.45

Tested by

no test coverage detected