MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / GetTextSize

Method GetTextSize

olcPixelGameEngine.h:4091–4104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4089 }
4090
4091 olc::vi2d PixelGameEngine::GetTextSize(const std::string& s)
4092 {
4093 olc::vi2d size = { 0,1 };
4094 olc::vi2d pos = { 0,1 };
4095 for (auto c : s)
4096 {
4097 if (c == '\n') { pos.y++; pos.x = 0; }
4098 else if (c == '\t') { pos.x += nTabSizeInSpaces; }
4099 else pos.x++;
4100 size.x = std::max(size.x, pos.x);
4101 size.y = std::max(size.y, pos.y);
4102 }
4103 return size * 8;
4104 }
4105
4106 void PixelGameEngine::DrawString(const olc::vi2d& pos, const std::string& sText, Pixel col, uint32_t scale)
4107 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected