mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-12 22:11:50 +08:00
add getter on font atlas into style manager
- get imgui font could return nonValid imgui font to recognize font without loaded symbol
This commit is contained in:
parent
5e76d86460
commit
a1914f5f94
@ -53,13 +53,7 @@
|
|||||||
#define ALLOW_REVERT_ALL_STYLES
|
#define ALLOW_REVERT_ALL_STYLES
|
||||||
#endif // ALLOW_DEBUG_MODE
|
#endif // ALLOW_DEBUG_MODE
|
||||||
|
|
||||||
//#define SHOW_WX_FONT_DESCRIPTOR
|
|
||||||
//#define SHOW_FONT_FILE_PROPERTY
|
|
||||||
//#define SHOW_FONT_COUNT
|
|
||||||
#define SHOW_CONTAIN_3MF_FIX
|
#define SHOW_CONTAIN_3MF_FIX
|
||||||
//#define ALLOW_ADD_FONT_BY_FILE
|
|
||||||
//#define ALLOW_ADD_FONT_BY_OS_SELECTOR
|
|
||||||
//#define ALLOW_REVERT_ALL_STYLES
|
|
||||||
|
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
using namespace Slic3r::GUI;
|
using namespace Slic3r::GUI;
|
||||||
@ -129,6 +123,7 @@ GLGizmoEmboss::GLGizmoEmboss(GLCanvas3D &parent)
|
|||||||
m_rotate_gizmo.set_group_id(0);
|
m_rotate_gizmo.set_group_id(0);
|
||||||
// TODO: add suggestion to use https://fontawesome.com/
|
// TODO: add suggestion to use https://fontawesome.com/
|
||||||
// (copy & paste) unicode symbols from web
|
// (copy & paste) unicode symbols from web
|
||||||
|
// paste HEX unicode into notepad move cursor after unicode press [alt] + [x]
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::set_fine_position()
|
void GLGizmoEmboss::set_fine_position()
|
||||||
@ -901,7 +896,7 @@ bool GLGizmoEmboss::process()
|
|||||||
if (m_text.empty()) return false;
|
if (m_text.empty()) return false;
|
||||||
|
|
||||||
// exist loaded font file?
|
// exist loaded font file?
|
||||||
if (!m_style_manager.get_font_file_with_cache().has_value()) return false;
|
if (!m_style_manager.is_activ_font()) return false;
|
||||||
|
|
||||||
// Cancel previous Job, when it is in process
|
// Cancel previous Job, when it is in process
|
||||||
// Can't use cancel, because I want cancel only previous EmbossUpdateJob no other jobs
|
// Can't use cancel, because I want cancel only previous EmbossUpdateJob no other jobs
|
||||||
@ -984,18 +979,14 @@ void GLGizmoEmboss::draw_window()
|
|||||||
}
|
}
|
||||||
#endif // ALLOW_DEBUG_MODE
|
#endif // ALLOW_DEBUG_MODE
|
||||||
|
|
||||||
bool is_selected_style = m_style_manager.is_activ_font();
|
bool is_activ_font = m_style_manager.is_activ_font();
|
||||||
bool exist_font_file = is_selected_style &&
|
if (!is_activ_font)
|
||||||
m_style_manager.get_font_file_with_cache().has_value();
|
|
||||||
if (!is_selected_style) {
|
|
||||||
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Warning: No text style is selected."));
|
|
||||||
}else if (!exist_font_file) {
|
|
||||||
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Warning: No font is selected. Select correct one."));
|
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Warning: No font is selected. Select correct one."));
|
||||||
}
|
|
||||||
draw_text_input();
|
draw_text_input();
|
||||||
draw_model_type();
|
draw_model_type();
|
||||||
draw_style_list();
|
draw_style_list();
|
||||||
m_imgui->disabled_begin(!is_selected_style);
|
m_imgui->disabled_begin(!is_activ_font);
|
||||||
ImGui::TreePush();
|
ImGui::TreePush();
|
||||||
draw_style_edit();
|
draw_style_edit();
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@ -1008,7 +999,7 @@ void GLGizmoEmboss::draw_window()
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
} else if (m_is_advanced_edit_style)
|
} else if (m_is_advanced_edit_style)
|
||||||
set_minimal_window_size(false);
|
set_minimal_window_size(false);
|
||||||
m_imgui->disabled_end(); // !is_selected_style
|
m_imgui->disabled_end(); // !is_activ_font
|
||||||
|
|
||||||
#ifdef SHOW_WX_FONT_DESCRIPTOR
|
#ifdef SHOW_WX_FONT_DESCRIPTOR
|
||||||
if (is_selected_style)
|
if (is_selected_style)
|
||||||
@ -1018,13 +1009,13 @@ void GLGizmoEmboss::draw_window()
|
|||||||
if (ImGui::Button(_u8L("Close").c_str())) close();
|
if (ImGui::Button(_u8L("Close").c_str())) close();
|
||||||
|
|
||||||
// Option to create text volume when reselecting volumes
|
// Option to create text volume when reselecting volumes
|
||||||
m_imgui->disabled_begin(!exist_font_file);
|
m_imgui->disabled_begin(!is_activ_font);
|
||||||
if (m_volume == nullptr) {
|
if (m_volume == nullptr) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(_u8L("Generate object").c_str()))
|
if (ImGui::Button(_u8L("Generate object").c_str()))
|
||||||
create_volume(ModelVolumeType::MODEL_PART);
|
create_volume(ModelVolumeType::MODEL_PART);
|
||||||
}
|
}
|
||||||
m_imgui->disabled_end();
|
m_imgui->disabled_end(); // !is_activ_font
|
||||||
|
|
||||||
#ifdef SHOW_CONTAIN_3MF_FIX
|
#ifdef SHOW_CONTAIN_3MF_FIX
|
||||||
if (m_volume!=nullptr &&
|
if (m_volume!=nullptr &&
|
||||||
@ -1052,7 +1043,7 @@ void GLGizmoEmboss::draw_window()
|
|||||||
ImGui::Image((void *) t.get_id(), ImVec2(t.get_width(), t.get_height()));
|
ImGui::Image((void *) t.get_id(), ImVec2(t.get_width(), t.get_height()));
|
||||||
#endif //SHOW_ICONS_TEXTURE
|
#endif //SHOW_ICONS_TEXTURE
|
||||||
#ifdef SHOW_IMGUI_ATLAS
|
#ifdef SHOW_IMGUI_ATLAS
|
||||||
auto &atlas = m_style_manager.m_imgui_font_atlas;
|
const auto &atlas = m_style_manager.get_atlas();
|
||||||
ImGui::Image(atlas.TexID, ImVec2(atlas.TexWidth, atlas.TexHeight));
|
ImGui::Image(atlas.TexID, ImVec2(atlas.TexWidth, atlas.TexHeight));
|
||||||
#endif // SHOW_IMGUI_ATLAS
|
#endif // SHOW_IMGUI_ATLAS
|
||||||
}
|
}
|
||||||
@ -1070,14 +1061,20 @@ void GLGizmoEmboss::draw_text_input()
|
|||||||
static const ImGuiInputTextFlags flags =
|
static const ImGuiInputTextFlags flags =
|
||||||
ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_AutoSelectAll;
|
ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_AutoSelectAll;
|
||||||
|
|
||||||
|
|
||||||
ImFont *imgui_font = m_style_manager.get_imgui_font();
|
ImFont *imgui_font = m_style_manager.get_imgui_font();
|
||||||
if (imgui_font == nullptr) {
|
if (imgui_font == nullptr) {
|
||||||
// try create new imgui font
|
// try create new imgui font
|
||||||
m_style_manager.create_imgui_font(create_range_text());
|
m_style_manager.create_imgui_font(create_range_text());
|
||||||
imgui_font = m_style_manager.get_imgui_font();
|
imgui_font = m_style_manager.get_imgui_font();
|
||||||
}
|
}
|
||||||
bool exist_font = imgui_font != nullptr;
|
bool exist_font =
|
||||||
assert(!exist_font || imgui_font->IsLoaded());
|
imgui_font != nullptr &&
|
||||||
|
imgui_font->IsLoaded() &&
|
||||||
|
imgui_font->Scale > 0.f &&
|
||||||
|
imgui_font->ContainerAtlas != nullptr;
|
||||||
|
// NOTE: Symbol fonts doesn't have atlas
|
||||||
|
// when their glyph range is out of language character range
|
||||||
if (exist_font) ImGui::PushFont(imgui_font);
|
if (exist_font) ImGui::PushFont(imgui_font);
|
||||||
|
|
||||||
// flag for extend font ranges if neccessary
|
// flag for extend font ranges if neccessary
|
||||||
@ -1155,9 +1152,10 @@ void GLGizmoEmboss::draw_text_input()
|
|||||||
ImGui::SetCursorPos(cursor);
|
ImGui::SetCursorPos(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: must be after ImGui::font_pop()
|
||||||
|
// -> imgui_font has to be unused
|
||||||
// IMPROVE: only extend not clear
|
// IMPROVE: only extend not clear
|
||||||
// Extend font ranges
|
// Extend font ranges
|
||||||
// imgui_font has to be unused
|
|
||||||
if (!range_text.empty() &&
|
if (!range_text.empty() &&
|
||||||
!m_imgui->contain_all_glyphs(imgui_font, range_text) ) {
|
!m_imgui->contain_all_glyphs(imgui_font, range_text) ) {
|
||||||
m_style_manager.clear_imgui_font();
|
m_style_manager.clear_imgui_font();
|
||||||
@ -1649,27 +1647,6 @@ void GLGizmoEmboss::draw_style_add_button()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::draw_style_undo_button() {
|
|
||||||
const EmbossStyle *stored_style = nullptr;
|
|
||||||
bool is_stored = m_style_manager.exist_stored_style();
|
|
||||||
if (is_stored)
|
|
||||||
stored_style = m_style_manager.get_stored_style();
|
|
||||||
const EmbossStyle &style = m_style_manager.get_style();
|
|
||||||
bool is_changed = (stored_style)? !(*stored_style == style) : true;
|
|
||||||
bool can_undo = is_stored && is_changed;
|
|
||||||
if (draw_button(IconType::undo, !can_undo)) {
|
|
||||||
discard_changes_in_style();
|
|
||||||
process();
|
|
||||||
} else if (ImGui::IsItemHovered()) {
|
|
||||||
if (can_undo)
|
|
||||||
ImGui::SetTooltip("%s", _u8L("Discard style changes.").c_str());
|
|
||||||
else if (!is_stored)
|
|
||||||
ImGui::SetTooltip("%s", _u8L("Not stored yet.").c_str());
|
|
||||||
else if (!is_changed)
|
|
||||||
ImGui::SetTooltip("%s", _u8L("No change to discard.").c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoEmboss::draw_delete_style_button() {
|
void GLGizmoEmboss::draw_delete_style_button() {
|
||||||
bool is_stored = m_style_manager.exist_stored_style();
|
bool is_stored = m_style_manager.exist_stored_style();
|
||||||
bool is_last = m_style_manager.get_styles().size() == 1;
|
bool is_last = m_style_manager.get_styles().size() == 1;
|
||||||
@ -1731,51 +1708,51 @@ void GLGizmoEmboss::draw_delete_style_button() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::discard_changes_in_style()
|
//void GLGizmoEmboss::discard_changes_in_style()
|
||||||
{
|
//{
|
||||||
if (!m_style_manager.exist_stored_style()) return;
|
// if (!m_style_manager.exist_stored_style()) return;
|
||||||
|
//
|
||||||
EmbossStyle &emboss_style = m_style_manager.get_style();
|
// EmbossStyle &emboss_style = m_style_manager.get_style();
|
||||||
const EmbossStyle* stored_style = m_style_manager.get_stored_style();
|
// const EmbossStyle* stored_style = m_style_manager.get_stored_style();
|
||||||
assert(stored_style != nullptr);
|
// assert(stored_style != nullptr);
|
||||||
|
//
|
||||||
// is rotation changed
|
// // is rotation changed
|
||||||
auto &angle = emboss_style.prop.angle;
|
// auto &angle = emboss_style.prop.angle;
|
||||||
const auto &angle_ = stored_style->prop.angle;
|
// const auto &angle_ = stored_style->prop.angle;
|
||||||
// TODO: compare with approx
|
// // TODO: compare with approx
|
||||||
if (angle.has_value() != angle_.has_value() ||
|
// if (angle.has_value() != angle_.has_value() ||
|
||||||
(angle.has_value() && !is_approx(*angle, *angle_))) {
|
// (angle.has_value() && !is_approx(*angle, *angle_))) {
|
||||||
auto &tc = m_volume->text_configuration;
|
// auto &tc = m_volume->text_configuration;
|
||||||
if (m_volume != nullptr && tc.has_value()) {
|
// if (m_volume != nullptr && tc.has_value()) {
|
||||||
// change actual text configuration
|
// // change actual text configuration
|
||||||
tc->style.prop.angle = angle_;
|
// tc->style.prop.angle = angle_;
|
||||||
float act_angle = angle_.has_value() ? *angle_ : .0f;
|
// float act_angle = angle_.has_value() ? *angle_ : .0f;
|
||||||
float prev_angle = angle.has_value() ? *angle : .0f;
|
// float prev_angle = angle.has_value() ? *angle : .0f;
|
||||||
do_rotate(act_angle - prev_angle);
|
// do_rotate(act_angle - prev_angle);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// is distance changed
|
// // is distance changed
|
||||||
auto &distance = emboss_style.prop.distance;
|
// auto &distance = emboss_style.prop.distance;
|
||||||
const auto &distance_ = stored_style->prop.distance;
|
// const auto &distance_ = stored_style->prop.distance;
|
||||||
if (distance.has_value() != distance_.has_value() ||
|
// if (distance.has_value() != distance_.has_value() ||
|
||||||
(distance.has_value() && !is_approx(*distance, *distance_))) {
|
// (distance.has_value() && !is_approx(*distance, *distance_))) {
|
||||||
auto &tc = m_volume->text_configuration;
|
// auto &tc = m_volume->text_configuration;
|
||||||
if (m_volume != nullptr && tc.has_value()) {
|
// if (m_volume != nullptr && tc.has_value()) {
|
||||||
tc->style.prop.distance = distance_;
|
// tc->style.prop.distance = distance_;
|
||||||
float act_distance = distance_.has_value() ? *distance_ : .0f;
|
// float act_distance = distance_.has_value() ? *distance_ : .0f;
|
||||||
float prev_distance = distance.has_value() ? *distance : .0f;
|
// float prev_distance = distance.has_value() ? *distance : .0f;
|
||||||
do_translate(Vec3d::UnitZ() * (act_distance - prev_distance));
|
// do_translate(Vec3d::UnitZ() * (act_distance - prev_distance));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (emboss_style.path != stored_style->path) {
|
// if (emboss_style.path != stored_style->path) {
|
||||||
// NOTE: load font file again
|
// // NOTE: load font file again
|
||||||
m_style_manager.load_style(m_style_manager.get_style_index());
|
// m_style_manager.load_style(m_style_manager.get_style_index());
|
||||||
//m_style_manager.get_wx_font() = WxFontUtils::load_wxFont(emboss_style.path);
|
// //m_style_manager.get_wx_font() = WxFontUtils::load_wxFont(emboss_style.path);
|
||||||
//m_style_manager.wx_font_changed();
|
// //m_style_manager.wx_font_changed();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
void GLGizmoEmboss::draw_revert_all_styles_button() {
|
void GLGizmoEmboss::draw_revert_all_styles_button() {
|
||||||
if (draw_button(IconType::revert_all)) {
|
if (draw_button(IconType::revert_all)) {
|
||||||
@ -1821,8 +1798,16 @@ void GLGizmoEmboss::draw_style_list() {
|
|||||||
// allow click delete button
|
// allow click delete button
|
||||||
ImGuiSelectableFlags_ flags = ImGuiSelectableFlags_AllowItemOverlap;
|
ImGuiSelectableFlags_ flags = ImGuiSelectableFlags_AllowItemOverlap;
|
||||||
if (ImGui::Selectable(item.truncated_name.c_str(), is_selected, flags, select_size)) {
|
if (ImGui::Selectable(item.truncated_name.c_str(), is_selected, flags, select_size)) {
|
||||||
if (m_style_manager.load_style(index))
|
if (m_style_manager.load_style(index)) {
|
||||||
|
// TODO:
|
||||||
|
// fix volume transformation after change style -->
|
||||||
|
// rotation or z-move
|
||||||
|
// HELP: discard_changes_in_style()
|
||||||
|
// void style_changed(const FontProp &prev, const FontProp &act);
|
||||||
process();
|
process();
|
||||||
|
} else {
|
||||||
|
// TODO: inform user that can't load and erase style
|
||||||
|
}
|
||||||
} else if (ImGui::IsItemHovered())
|
} else if (ImGui::IsItemHovered())
|
||||||
ImGui::SetTooltip("%s", actual_style_name.c_str());
|
ImGui::SetTooltip("%s", actual_style_name.c_str());
|
||||||
|
|
||||||
@ -1865,10 +1850,6 @@ void GLGizmoEmboss::draw_style_list() {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
draw_style_add_button();
|
draw_style_add_button();
|
||||||
|
|
||||||
// undo button
|
|
||||||
ImGui::SameLine();
|
|
||||||
draw_style_undo_button();
|
|
||||||
|
|
||||||
#ifdef ALLOW_REVERT_ALL_STYLES
|
#ifdef ALLOW_REVERT_ALL_STYLES
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
draw_revert_all_styles_button();
|
draw_revert_all_styles_button();
|
||||||
@ -2644,7 +2625,7 @@ EmbossDataBase GLGizmoEmboss::create_emboss_data_base() {
|
|||||||
std::string default_text_for_emboss = _u8L("Embossed text");
|
std::string default_text_for_emboss = _u8L("Embossed text");
|
||||||
EmbossStyle es = m_style_manager.get_style();
|
EmbossStyle es = m_style_manager.get_style();
|
||||||
TextConfiguration tc{es, default_text_for_emboss};
|
TextConfiguration tc{es, default_text_for_emboss};
|
||||||
// TODO: investigace how to initialize
|
// TODO: investigate how to initialize
|
||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2652,7 +2633,8 @@ EmbossDataBase GLGizmoEmboss::create_emboss_data_base() {
|
|||||||
// actualize font path - during changes in gui it could be corrupted
|
// actualize font path - during changes in gui it could be corrupted
|
||||||
// volume must store valid path
|
// volume must store valid path
|
||||||
assert(m_style_manager.get_wx_font().has_value());
|
assert(m_style_manager.get_wx_font().has_value());
|
||||||
es.path = WxFontUtils::store_wxFont(*m_style_manager.get_wx_font());
|
assert(es.path.compare(WxFontUtils::store_wxFont(*m_style_manager.get_wx_font())) == 0);
|
||||||
|
//es.path = WxFontUtils::store_wxFont(*m_style_manager.get_wx_font());
|
||||||
return TextConfiguration{es, m_text};
|
return TextConfiguration{es, m_text};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,14 +101,12 @@ private:
|
|||||||
void draw_model_type();
|
void draw_model_type();
|
||||||
void draw_style_list();
|
void draw_style_list();
|
||||||
void draw_delete_style_button();
|
void draw_delete_style_button();
|
||||||
void discard_changes_in_style();
|
|
||||||
void draw_revert_all_styles_button();
|
void draw_revert_all_styles_button();
|
||||||
void draw_style_rename_popup();
|
void draw_style_rename_popup();
|
||||||
void draw_style_rename_button();
|
void draw_style_rename_button();
|
||||||
void draw_style_save_button();
|
void draw_style_save_button();
|
||||||
void draw_style_save_as_popup();
|
void draw_style_save_as_popup();
|
||||||
void draw_style_add_button();
|
void draw_style_add_button();
|
||||||
void draw_style_undo_button();
|
|
||||||
void draw_font_list();
|
void draw_font_list();
|
||||||
void draw_style_edit();
|
void draw_style_edit();
|
||||||
bool draw_italic_button();
|
bool draw_italic_button();
|
||||||
|
@ -124,8 +124,14 @@ void EmbossStyleManager::discard_style_changes() {
|
|||||||
if (m_style_cache.style == m_style_items[m_stored_activ_index].style &&
|
if (m_style_cache.style == m_style_items[m_stored_activ_index].style &&
|
||||||
m_style_cache.wx_font == m_style_cache.stored_wx_font)
|
m_style_cache.wx_font == m_style_cache.stored_wx_font)
|
||||||
return; // already loaded
|
return; // already loaded
|
||||||
if (load_style(m_style_cache.style_index)) return;
|
if (load_style(m_style_cache.style_index))
|
||||||
|
return; // correct reload style
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (load_style(m_stored_activ_index))
|
||||||
|
return; // correct reload last activ font
|
||||||
|
|
||||||
|
// try to save situation by load some font
|
||||||
load_first_valid_font();
|
load_first_valid_font();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +232,7 @@ bool EmbossStyleManager::exist_stored_style() const { return m_style_cache.style
|
|||||||
size_t EmbossStyleManager::get_style_index() const { return m_style_cache.style_index; }
|
size_t EmbossStyleManager::get_style_index() const { return m_style_cache.style_index; }
|
||||||
Emboss::FontFileWithCache &EmbossStyleManager::get_font_file_with_cache() { return m_style_cache.font_file; }
|
Emboss::FontFileWithCache &EmbossStyleManager::get_font_file_with_cache() { return m_style_cache.font_file; }
|
||||||
std::string &EmbossStyleManager::get_truncated_name() { return m_style_cache.truncated_name; }
|
std::string &EmbossStyleManager::get_truncated_name() { return m_style_cache.truncated_name; }
|
||||||
|
const ImFontAtlas &EmbossStyleManager::get_atlas() const { return m_style_cache.atlas; }
|
||||||
|
|
||||||
void EmbossStyleManager::clear_glyphs_cache()
|
void EmbossStyleManager::clear_glyphs_cache()
|
||||||
{
|
{
|
||||||
@ -249,10 +256,6 @@ ImFont *EmbossStyleManager::get_imgui_font()
|
|||||||
if (f_size != 1) return nullptr;
|
if (f_size != 1) return nullptr;
|
||||||
ImFont *font = fonts.front();
|
ImFont *font = fonts.front();
|
||||||
if (font == nullptr) return nullptr;
|
if (font == nullptr) return nullptr;
|
||||||
if (!font->IsLoaded()) return nullptr;
|
|
||||||
if (font->Scale <= 0.f) return nullptr;
|
|
||||||
// Symbol fonts doesn't have atlas because their glyph range is out of language range
|
|
||||||
if (font->ContainerAtlas == nullptr) return nullptr;
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +380,7 @@ void EmbossStyleManager::free_style_images() {
|
|||||||
float EmbossStyleManager::min_imgui_font_size = 18.f;
|
float EmbossStyleManager::min_imgui_font_size = 18.f;
|
||||||
float EmbossStyleManager::max_imgui_font_size = 60.f;
|
float EmbossStyleManager::max_imgui_font_size = 60.f;
|
||||||
float EmbossStyleManager::get_imgui_font_size(const FontProp &prop,
|
float EmbossStyleManager::get_imgui_font_size(const FontProp &prop,
|
||||||
const Emboss::FontFile &file)
|
const Emboss::FontFile &file)
|
||||||
{
|
{
|
||||||
const auto &cn = prop.collection_number;
|
const auto &cn = prop.collection_number;
|
||||||
unsigned int font_index = (cn.has_value()) ? *cn : 0;
|
unsigned int font_index = (cn.has_value()) ? *cn : 0;
|
||||||
@ -464,6 +467,7 @@ ImFont *EmbossStyleManager::create_imgui_font(const std::string &text)
|
|||||||
assert(!m_style_cache.atlas.Fonts.empty());
|
assert(!m_style_cache.atlas.Fonts.empty());
|
||||||
if (m_style_cache.atlas.Fonts.empty()) return nullptr;
|
if (m_style_cache.atlas.Fonts.empty()) return nullptr;
|
||||||
assert(font == m_style_cache.atlas.Fonts.back());
|
assert(font == m_style_cache.atlas.Fonts.back());
|
||||||
|
if (!font->IsLoaded()) return nullptr;
|
||||||
assert(font->IsLoaded());
|
assert(font->IsLoaded());
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
@ -118,10 +118,14 @@ public:
|
|||||||
const FontProp &get_font_prop() const;
|
const FontProp &get_font_prop() const;
|
||||||
FontProp &get_font_prop();
|
FontProp &get_font_prop();
|
||||||
|
|
||||||
|
const ImFontAtlas& get_atlas() const;
|
||||||
|
|
||||||
// getter on activ wx font
|
// getter on activ wx font
|
||||||
const std::optional<wxFont> &get_wx_font() const;
|
const std::optional<wxFont> &get_wx_font() const;
|
||||||
|
|
||||||
|
// True when activ style has same name as some of stored style
|
||||||
bool exist_stored_style() const;
|
bool exist_stored_style() const;
|
||||||
|
|
||||||
size_t get_style_index() const;
|
size_t get_style_index() const;
|
||||||
|
|
||||||
// getter on font file with cache
|
// getter on font file with cache
|
||||||
|
Loading…
x
Reference in New Issue
Block a user