say user that Text can’t be empty

This commit is contained in:
Filip Sykala 2022-04-07 17:06:26 +02:00
parent 40817f537b
commit 630b1bb956
2 changed files with 13 additions and 1 deletions

View File

@ -750,9 +750,17 @@ std::string Emboss::create_range_text(const std::string &text,
ws.erase(std::remove_if(ws.begin(), ws.end(),
[&prev_unicode, font_info, exist_unknown](wchar_t wc) -> bool {
int unicode = static_cast<int>(wc);
// is duplicit
// skip white spaces
if (unicode == '\n' ||
unicode == '\r' ||
unicode == '\t') return true;
// is duplicit?
if (prev_unicode == unicode) return true;
prev_unicode = unicode;
// can find in font?
bool is_unknown = !stbtt_FindGlyphIndex(font_info, unicode);
if (is_unknown && exist_unknown != nullptr)
*exist_unknown = true;

View File

@ -990,6 +990,10 @@ void GLGizmoEmboss::draw_text_input()
tool_tip += t;
}
};
if (m_text.empty() ||
m_text.find_first_not_of(" \n\t\r") == std::string::npos)
append_warning(_u8L("Empty"),
_u8L("Embossed text can NOT contain only white spaces."));
if (m_text_contain_unknown_glyph)
append_warning(_u8L("Bad symbol"),
_u8L("Text contain character glyph (represented by '?') unknown by font."));