下标/上标字符问题 (TouchGFX) [英] Issues with subsript/superscript characters (TouchGFX)
问题描述
我需要下标/上标字符才能正确显示 O₂、CO₂、m²、m³....
I need subscript/superscript characters for the correct display of O₂,CO₂, m² ,m³....
上标字符有效(m³,.. 没问题),但如果我想有一个下标 2,显示器要么只显示O"而不是 O₂,要么在 O 后面显示一个hyroglyphic"字母.
The superscript characters are working (m³,.. no Problem), but if I want to have a subscript two, either the display shows just the "O" instead of O₂ or a "hyroglyphic" letter behind the O.
我检查了通配符范围,它是 0x02 到 0x2084.下标 2 的 Unicode 是 0x2082.
我还在通配符中添加了 ₂.
I checked the wildcard ranges, it is 0x02 to 0x2084. The Unicode for the subscript 2 is 0x2082.
I added the ₂ also into the wildcard characters.
我的代码:
void Screen1View::button_down_clicked()
{
Unicode::UnicodeChar list[] = {0xB2, 0};
counter--;
Unicode::snprintf(test_textBuffer, TEST_TEXT_SIZE, "%d m%s", counter, list);
test_text.invalidate();
}
请不要对 UnicodeChar 列表感到疑惑.我计划向 sprintf 添加多个 Unicode 字符.
Please don't wonder about the UnicodeChar list. I'm planning to add more than one Unicode-Character to the sprintf.
0xB2 是 ² 的 Unicode.这很好用.但是如果我写 0x2082 或 0x2083 就会失败.
The 0xB2 ist the Unicode for ². This works well. But if I write 0x2082 or 0x2083 it fails.
如果有人有想法,请告诉我:)
If anyone has an idea please let me know :)
推荐答案
您可能希望改用 Unicode::strncpy()
,因为它允许您简单地将一个 UnicodeChar 缓冲区复制到另一个缓冲区.我认为你会有一些未定义的行为,因为 Unicode::snprintf 期望你尊重你指定的格式.
You may want to use Unicode::strncpy()
instead since it allows you to simply copy one UnicodeChar buffer to another. I think you'll have some undefined behavior since Unicode::snprintf expects you to respect the format you specify.
我为我的排版指定了下标 2 (0x2082) 作为通配符,它给了我以下生成的 unicode(在 generated/fonts/src/Font_verdana_20_4bpp.cpp
中).请注意,您使用的字体文件必须支持您指定的 unicode 点.
I specified subscript-2 (0x2082) for my typography as a wildcard character which gave me the following generated unicode (in generated/fonts/src/Font_verdana_20_4bpp.cpp
). Note that the font file you use must support the unicode points you specify.
FONT_LOCATION_FLASH_PRAGMA
KEEP extern const uint8_t unicodes_verdana_20_4bpp[] FONT_LOCATION_FLASH_ATTRIBUTE =
{
...
0xDF, 0xDF, 0x00, 0xE8, 0xDF, 0x07, 0xDF,
// Unicode: [0x2082, ]
0x00, 0x10, 0x00, 0x00, 0xE9, 0xFF, 0x9F, 0x00, 0x9E, 0x55, 0xFA, 0x09, 0x00, 0x00, 0xE0, 0x0D,
0x00, 0x00, 0xF0, 0x0B, 0x00, 0x00, 0xFB, 0x03, 0x00, 0xC2, 0x4E, 0x00, 0x60, 0xBF, 0x01, 0x00,
0xFC, 0x6C, 0x66, 0x26, 0xFF, 0xFF, 0xFF, 0x7F
};
并为屏幕 1 编写了以下代码:
and wrote the following code for Screen 1:
void Screen1View::setupScreen()
{
Screen1ViewBase::setupScreen();
Unicode::UnicodeChar buf[2] = {0x2082, 0};
Unicode::strncpy(textArea1Buffer, buf, 5);
textArea1.invalidate();
}
这在我的模拟器中给了我以下输出:
Which gives me the following output in my simulator:
如果我像您一样添加通配符范围":
If i add a wildcard "range" instead, like you did:
.. 我仍然得到生成的 unicode-point 的代码:
.. i still get code for the unicode-point generated:
...
// Unicode: [0x2080, ]
0x00, 0xE8, 0xDF, 0x07, 0x00, 0x80, 0x7F, 0x83, 0x6F, 0x00, 0xE0, 0x09, 0x00, 0xCC, 0x00, 0xF1,
0x06, 0x00, 0xF9, 0x00, 0xF2, 0x05, 0x00, 0xF8, 0x00, 0xF2, 0x06, 0x00, 0xF9, 0x00, 0xF0, 0x09,
0x00, 0xCC, 0x00, 0x80, 0x6F, 0x83, 0x5F, 0x00, 0x00, 0xE8, 0xDF, 0x06, 0x00,
// Unicode: [0x2081, ]
0x00, 0xD2, 0x0C, 0x00, 0xF2, 0xFF, 0x0C, 0x00, 0x20, 0xD2, 0x0C, 0x00, 0x00, 0xC0, 0x0C, 0x00,
0x00, 0xC0, 0x0C, 0x00, 0x00, 0xC0, 0x0C, 0x00, 0x00, 0xC0, 0x0C, 0x00, 0x20, 0xD2, 0x2C, 0x02,
0xF1, 0xFF, 0xFF, 0x0E,
// Unicode: [0x2082, ]
0x00, 0x10, 0x00, 0x00, 0xE9, 0xFF, 0x9F, 0x00, 0x9E, 0x55, 0xFA, 0x09, 0x00, 0x00, 0xE0, 0x0D,
0x00, 0x00, 0xF0, 0x0B, 0x00, 0x00, 0xFB, 0x03, 0x00, 0xC2, 0x4E, 0x00, 0x60, 0xBF, 0x01, 0x00,
0xFC, 0x6C, 0x66, 0x26, 0xFF, 0xFF, 0xFF, 0x7F,
// Unicode: [0x2083, ]
0x00, 0x00, 0x00, 0x00, 0xD7, 0xFF, 0xBF, 0x02, 0xAC, 0x46, 0xF7, 0x0D, 0x01, 0x00, 0xA0, 0x0F,
0x00, 0x11, 0xE4, 0x09, 0x00, 0xFF, 0xAF, 0x01, 0x00, 0x44, 0xD6, 0x1E, 0x00, 0x00, 0x60, 0x4F,
0x9E, 0x67, 0xE8, 0x1E, 0xD9, 0xFF, 0xAE, 0x02,
// Unicode: [0x2084, ]
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x00, 0x00, 0x10, 0xFE, 0x0C, 0x00, 0x00,
0xC0, 0xBC, 0x0C, 0x00, 0x00, 0xEA, 0xA1, 0x0C, 0x00, 0x70, 0x2F, 0xA0, 0x0C, 0x00, 0xF2, 0x05,
0xA0, 0x0C, 0x00, 0xF4, 0xFF, 0xFF, 0xFF, 0x05, 0x30, 0x33, 0xC3, 0x3C, 0x01, 0x00, 0x00, 0xB0,
0x0C, 0x00
这篇关于下标/上标字符问题 (TouchGFX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!