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

Method draw_string

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

Source from the content-addressed store, hash-verified

312}
313
314void Font::draw_string(RID p_canvas_item, const Point2& p_pos, const String& p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, const Color& p_modulate, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const
315{
316 bool fill = (p_alignment == HORIZONTAL_ALIGNMENT_FILL);
317 ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.f, fill ? p_jst_flags : TextServer::JUSTIFICATION_NONE, TextServer::BREAK_NONE, p_direction, p_orientation);
318
319 Ref<TextLine> buffer;
320 if (cache.contains(key))
321 {
322 buffer = cache.lookup(key);
323 }
324 else
325 {
326 buffer.instantiate();
327 buffer->set_direction(p_direction);
328 buffer->set_orientation(p_orientation);
329 buffer->add_string(p_text, Ref<Font>(const_cast<Font*>(this)), p_font_size);
330 cache.insert(key, buffer);
331 }
332
333 Vector2 ofs = p_pos;
334 if (p_orientation == TextServer::ORIENTATION_HORIZONTAL)
335 {
336 ofs.y -= buffer->get_line_ascent();
337 }
338 else
339 {
340 ofs.x -= buffer->get_line_ascent();
341 }
342
343 buffer->set_width(p_width);
344 buffer->set_horizontal_alignment(p_alignment);
345 if (p_alignment == HORIZONTAL_ALIGNMENT_FILL)
346 {
347 buffer->set_flags(p_jst_flags);
348 }
349
350 buffer->draw(p_canvas_item, ofs, p_modulate);
351}
352
353void Font::draw_multiline_string(RID p_canvas_item, const Point2& p_pos, const String& p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, const Color& p_modulate, BitField<TextServer::LineBreakFlag> p_brk_flags, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const
354{

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected