| 312 | } |
| 313 | |
| 314 | void 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 | |
| 353 | void 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 | { |
nothing calls this directly
no test coverage detected