Skip to content

Commit

Permalink
fix text
Browse files Browse the repository at this point in the history
  • Loading branch information
Nivaturimika committed Jul 9, 2024
1 parent 46588f6 commit 6460ebd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/gui/gui_element_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,30 +757,11 @@ void simple_text_element_base::format_text(sys::state& state) {
void simple_text_element_base::on_reset_text(sys::state& state) noexcept {
if(base_data.get_element_type() == element_type::button) {
black_text = text::is_black_from_font_id(base_data.data.button.font_handle);
cached_text = text::produce_simple_string(state, base_data.data.button.txt);
internal_layout.contents.clear();
internal_layout.number_of_lines = 0;

auto al = text::to_text_alignment(base_data.data.button.get_alignment());
text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y),
base_data.data.button.font_handle, 0, al, black_text ? text::text_color::black : text::text_color::white, true, true },
state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };

sl.add_text(state, cached_text);
set_text(state, text::produce_simple_string(state, base_data.data.button.txt));
} else if(base_data.get_element_type() == element_type::text) {
black_text = text::is_black_from_font_id(base_data.data.text.font_handle);
cached_text = text::produce_simple_string(state, base_data.data.text.txt);
internal_layout.contents.clear();
internal_layout.number_of_lines = 0;

auto al = text::to_text_alignment(base_data.data.text.get_alignment());
text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x - base_data.data.text.border_size.x * 2), static_cast<int16_t>(base_data.size.y),
base_data.data.text.font_handle, 0, al, black_text ? text::text_color::black : text::text_color::white, true, true },
state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };

sl.add_text(state, cached_text);
set_text(state, text::produce_simple_string(state, base_data.data.text.txt));
}
format_text(state);
}
void simple_text_element_base::on_create(sys::state& state) noexcept {
on_reset_text(state);
Expand Down
16 changes: 16 additions & 0 deletions src/text/bmfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ bm_font const& get_bm_font(sys::state& state, uint16_t font_handle) {
return std::string("garamond_14");
if(sv == "Main_14_plain")
return std::string("garamond_14");
if(sv == "Main_14_grey")
return std::string("garamond_14_bold");
if(sv == "Main_14_black")
return std::string("garamond_14_bold");
if(sv == "Main_14_red")
return std::string("garamond_14_bold");
if(sv == "Main_14_bold")
return std::string("garamond_14_bold");
if(sv == "Main_14_orange")
return std::string("garamond_14_bold");
if(sv == "Main_14_eu")
return std::string("garamond_14");
if(sv == "tahoma_60")
return std::string("mapfont_56");
if(sv == "mapfont_56_small")
return std::string("vic_22_bl");
if(sv == "ToolTip_Font")
return std::string("garamond_16");
if(sv == "FPS_Font")
Expand Down

0 comments on commit 6460ebd

Please sign in to comment.