MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / getString

Method getString

framework/font.cpp:12–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10BitmapFont::~BitmapFont() = default;
11
12sp<PaletteImage> BitmapFont::getString(const UString &Text)
13{
14 if (Text.find('\n') != std::string::npos)
15 {
16 LogWarning(
17 "Multiline text not supported. Newline characters will be ignored. Text : \"%s\"",
18 Text);
19 }
20 int height = this->getFontHeight();
21 int width = this->getFontWidth(Text);
22 int pos = 0;
23
24 auto img = fw().data->getFontStringCacheEntry(this->name, Text);
25 if (img)
26 return img;
27
28 img = mksp<PaletteImage>(Vec2<int>{width, height});
29
30 auto u32Text = to_u32string(Text);
31
32 for (const auto &c : u32Text)
33 {
34 auto glyph = this->getGlyph(c);
35 PaletteImage::blit(glyph, img, {0, 0}, {pos, 0});
36 pos += glyph->size.x;
37 }
38
39 fw().data->putFontStringCacheEntry(this->name, Text, img);
40
41 return img;
42}
43
44int BitmapFont::getFontWidth(const UString &Text)
45{

Callers 15

initMethod · 0.45
renderBaseMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
BattleViewMethod · 0.45
BattleTileViewMethod · 0.45
renderMethod · 0.45
CityViewMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
pushLuaFrameworkFunction · 0.45
onRenderMethod · 0.45

Calls 6

getFontHeightMethod · 0.95
getFontWidthMethod · 0.95
getGlyphMethod · 0.95
to_u32stringFunction · 0.85

Tested by 1

mainFunction · 0.36