MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / get_string_size

Method get_string_size

modules/gui/gui/src/backend/text_server/font.cpp:257–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257Size2 Font::get_string_size(const String& p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const
258{
259 bool fill = (p_alignment == HORIZONTAL_ALIGNMENT_FILL);
260 ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.0f, fill ? p_jst_flags : TextServer::JUSTIFICATION_NONE, TextServer::BREAK_NONE, p_direction, p_orientation);
261
262 Ref<TextLine> buffer;
263 auto&& iter = cache.find(key);
264 if (cache.contains(key))
265 {
266 buffer = cache.lookup(key);
267 }
268 else
269 {
270 buffer.instantiate();
271 buffer->set_direction(p_direction);
272 buffer->set_orientation(p_orientation);
273 buffer->add_string(p_text, Ref<Font>(const_cast<Font*>(this)), p_font_size);
274 cache.insert(key, buffer);
275 }
276
277 buffer->set_width(p_width);
278 buffer->set_horizontal_alignment(p_alignment);
279 if (p_alignment == HORIZONTAL_ALIGNMENT_FILL)
280 {
281 buffer->set_flags(p_jst_flags);
282 }
283
284 return buffer->get_size();
285}
286
287Size2 Font::get_multiline_string_size(const String& p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, BitField<TextServer::LineBreakFlag> p_brk_flags, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const
288{

Callers

nothing calls this directly

Calls 13

ShapedTextKeyClass · 0.85
findMethod · 0.45
containsMethod · 0.45
lookupMethod · 0.45
instantiateMethod · 0.45
set_directionMethod · 0.45
set_orientationMethod · 0.45
add_stringMethod · 0.45
insertMethod · 0.45
set_widthMethod · 0.45
set_flagsMethod · 0.45

Tested by

no test coverage detected