//
// Created by 46944 on 25-3-28.
//

#include "mtext_block.h"

#include "font/font_system.h"

void mtext_block::on_paint(mirage_paint_context& in_context) {
	// 绘制文本
	in_context.drawer().make_text(
		layout_,
		{0, 0},
		in_context.geo().get_local_size(),
		in_context.geo()
	);
}

auto mtext_block::compute_desired_size(float in_layout_scale_multiplier) const -> Eigen::Vector2f {
	return layout_.total_size;
}

void mtext_block::update_layout() {
	layout_ = font_manager::instance().layout_text(text_, font_, font_size_, max_width_, line_spacing_);
}
