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

Method GetTextSizeProp

olcPixelGameEngine.h:4159–4174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4157 }
4158
4159 olc::vi2d PixelGameEngine::GetTextSizeProp(const std::string& s)
4160 {
4161 olc::vi2d size = { 0,1 };
4162 olc::vi2d pos = { 0,1 };
4163 for (auto c : s)
4164 {
4165 if (c == '\n') { pos.y += 1; pos.x = 0; }
4166 else if (c == '\t') { pos.x += nTabSizeInSpaces * 8; }
4167 else pos.x += vFontSpacing[c - 32].y;
4168 size.x = std::max(size.x, pos.x);
4169 size.y = std::max(size.y, pos.y);
4170 }
4171
4172 size.y *= 8;
4173 return size;
4174 }
4175
4176 void PixelGameEngine::DrawStringProp(const olc::vi2d& pos, const std::string& sText, Pixel col, uint32_t scale)
4177 {

Callers 3

OnBeforeUserUpdateMethod · 0.80
DrawMethod · 0.80
DrawDecalMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected