Как отобразить специальные символы (₹,₤,₿..) в окне ImGui?C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Как отобразить специальные символы (₹,₤,₿..) в окне ImGui?

Сообщение Anonymous »

Я работаю над приложением, использующим ImGui в качестве пользовательского интерфейса, и у меня возникли проблемы с отображением специальных символов, таких как символ индийской рупии (₹), в моих окнах ImGui. В настоящее время эти символы отображаются как .? вместо правильных символов. Я специально использую OpenGL в качестве основного средства визуализации.
Вот что я сделал на данный момент:
  • Загрузил шрифт: я обязательно загрузил шрифт, поддерживающий специальные символы.

    Функция замены. У меня есть функция, которая заменяет определенные строки-заполнители специальными символами.
У меня есть функция, которая заменяет определенные строки-заполнители специальными символами, включая символ индийской рупии. Вот функция:
std::string replacedStr = str;
std::map replacements = {
{"1397904493", "®"}, {"1397776754", "¶"}, {"1400073811", "§"},
{"1396991858", "°"}, {"1396929140", "©"}, {"1398041963", "™"},
{"1397059140", "–"}, {"1397058884", "—"}, {"1397969521", "’"},
{"1397967985", "‘"}, {"1396986737", "\""}, {"1397969777", "'"},
{"1397645907", " "}, {"1396984945", "“"}, {"1396986481", "”"},
{"1396862068", "•"}, {"1397518451", "…"}, {"1398320179", "₹"}
// Added mapping for the Indian Rupee symbol }; for (const auto &pair
// : replacements) { size_t pos = replacedStr.find(pair.first); while
// (pos != std::string::npos) { replacedStr.replace(pos,
// pair.first.length(), pair.second); pos =
// replacedStr.find(pair.first, pos + 1); } } return replacedStr; }


Я получаю следующий результат для некоторых специальных символов. Введите здесь описание изображения.
здесь вы можете увидеть код, посвященный методам преобразования и рендеринга.
введите описание изображения здесь
или
for (size_t i = 0; i < contents.size();) {
// Get the Unicode value of the current character and convert it to UTF-8
uint32_t unicode = workose_studio_getUTF8Unicode(contents, i);
std::string charStr = utf8::utf32to8(std::u32string(1, unicode));
std::cout GetGlyphRangesChineseFull();

// Initialize an array to store font names
std::vector font_name;

// Check if layout and element details are available
if (workose_studio_get_layout_and_element_details.size() > 0)
{
// Iterate over layout elements
for (nlohmann::json::iterator it = workose_studio_get_layout_and_element_details[0][0].begin(); it != workose_studio_get_layout_and_element_details[0][0].end(); ++it)
{
nlohmann::json layout_elements = it.value()["layout_elements"];

// Iterate over layout element details
for (nlohmann::json::iterator it = layout_elements.begin(); it != layout_elements.end(); ++it)
{
std::string element_type = it.value()["LAYOUT_ELEMENT_TYPE"];

// Check if the element type is "text"
if (element_type == "text")
{
nlohmann::json paragraphs;
// Extract and decode element JSON style attributes
std::string element_json_style_attributes = it.value()["ELEMENT_JSON_STYLE_ATTRIBUTES"];
std::string decode_data = urldecode(element_json_style_attributes);
nlohmann::json json_data = nlohmann::json::parse(decode_data);

// Check for the presence of specific style attributes
if (json_data.find("frame_style") != json_data.end() && json_data["frame_style"].find("tableDetils") != json_data["frame_style"].end())
{

// Check if the "tableDetils" field is empty
if (json_data["frame_style"]["tableDetils"].empty())
{
nlohmann::json decoded_json = nlohmann::json::parse(decode_data);
// Check for the presence of "paragraphs" in the decoded JSON
if (decoded_json.contains("paragraphs"))
{
paragraphs = decoded_json["paragraphs"];
// Store used fonts from paragraphs
storeusedfonts(paragraphs);
}
}
else
{
// table condition
const nlohmann::json &frame_style = json_data["frame_style"];
// Check for the presence of "tableDetils" in "frame_style"
if (frame_style.contains("tableDetils"))
{
const nlohmann::json &table_details = frame_style["tableDetils"];
// Check for the presence of "tableContentArray" in "tableDetils"
if (table_details.contains("tableContentArray"))
{
const nlohmann::json &table_content_array = table_details["tableContentArray"];
size_t numColumns = table_content_array[std::to_string(0)].size();

// Iterate over table columns and rows
for (size_t x = 0; x < numColumns; ++x)
{
for (size_t j = 0; j < table_content_array.size(); ++j)
{
const nlohmann::json &row_j = table_content_array[std::to_string(j)];

// Check for the presence of the current column in the current row
if (row_j.contains(std::to_string(x)))
{
const nlohmann::json &cell_ij = row_j[std::to_string(x)];

// Check for the presence of "style" in the cell
if (cell_ij.contains("style"))
{
const nlohmann::json &styleObj = cell_ij["style"];

// Check for the presence of "paragraphs" in the style
if (styleObj.contains("paragraphs"))
{
paragraphs = styleObj["paragraphs"];
// Store used fonts from paragraphs
storeusedfonts(paragraphs);
}
}
}
}
}
}
}
}
}
}
}
}
}
}


Подробнее здесь: https://stackoverflow.com/questions/785 ... gui-window
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»