Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bw): add missing UA characters, mapping #4823

Merged
merged 4 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified radio/src/fonts/std/font_ua_04x06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified radio/src/fonts/std/font_ua_05x07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified radio/src/fonts/std/font_ua_08x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified radio/src/fonts/std/font_ua_10x14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 54 additions & 25 deletions radio/src/gui/common/stdlcd/utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include "translations/untranslated.h"

#if defined(TRANSLATIONS_FR)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'é', L'è', L'à', L'î', L'ç',
};

#if !defined(COLORLCD)
#define UTF8_SUBS_LUT
static wchar_t _utf8_substitution_lut[] = {
static uint16_t _utf8_substitution_lut[] = {
L'Â', L'A',
L'À', L'A',
L'Ê', L'E',
Expand All @@ -50,23 +50,23 @@ static wchar_t _utf8_substitution_lut[] = {
};
#endif
#elif defined(TRANSLATIONS_DA)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'å', L'æ', L'ø', L'Å', L'Æ', L'Ø',
};
#elif defined(TRANSLATIONS_DE)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'Ä', L'ä', L'Ö', L'ö', L'Ü', L'ü', L'ß',
};
#elif defined(TRANSLATIONS_CZ)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'á', L'č', L'é', L'ě', L'í', L'ó', L'ř',
L'š', L'ú', L'ů', L'ý', L'Á', L'Í', L'Ř',
L'Ý', L'ž', L'É', L'ň',
};

#if !defined(COLORLCD)
#define UTF8_SUBS_LUT
static wchar_t _utf8_substitution_lut[] = {
static uint16_t _utf8_substitution_lut[] = {
L'Ě', L'ě',
L'Š', L'š',
L'Č', L'č',
Expand All @@ -78,33 +78,33 @@ static wchar_t _utf8_substitution_lut[] = {
};
#endif
#elif defined(TRANSLATIONS_ES)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'Ñ', L'ñ', L'Á', L'á', L'É', L'é', L'Í',
L'í', L'Ó', L'ó', L'ú',
};
#elif defined(TRANSLATIONS_PT)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'Á', L'á', L'Â', L'â', L'Ã', L'ã', L'À',
L'à', L'Ç', L'ç', L'É', L'é', L'Ê', L'ê',
L'Í', L'í', L'Ó', L'ó', L'Ô', L'ô', L'Õ',
L'õ', L'Ú', L'ú',
};
#elif defined(TRANSLATIONS_FI)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'å', L'ä', L'ö', L'Å', L'Ä', L'Ö',
};
#elif defined(TRANSLATIONS_IT)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'à', L'ù',
};
#elif defined(TRANSLATIONS_PL)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'ą', L'ć', L'ę', L'ł', L'ń', L'ó', L'ś',
L'ż', L'ź', L'Ą', L'Ć', L'Ę', L'Ł', L'Ń',
L'Ó', L'Ś', L'Ż', L'Ź',
};
#elif defined(TRANSLATIONS_RU)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'А', L'Б', L'В', L'Г', L'Д', L'Е', L'Ж',
L'З', L'И', L'Й', L'К', L'Л', L'М', L'Н',
L'О', L'П', L'Р', L'С', L'Т', L'У', L'Ф',
Expand All @@ -117,27 +117,56 @@ static wchar_t _utf8_lut[] = {
L'я',
};
#elif defined(TRANSLATIONS_UA)
static wchar_t _utf8_lut[] = {
L'А', L'Б', L'В', L'Г', L'Д', L'Е', L'Ж',
L'З', L'И', L'Й', L'К', L'Л', L'М', L'Н',
L'О', L'П', L'Р', L'С', L'Т', L'У', L'Ф',
L'Х', L'Ц', L'Ч', L'Ш', L'Щ', L'Ъ', L'Ы',
L'Ь', L'Э', L'Ю', L'Я', L'а', L'б', L'в',
L'г', L'д', L'е', L'ж', L'з', L'и', L'й',
L'к', L'л', L'м', L'н', L'о', L'п', L'р',
L'с', L'т', L'у', L'ф', L'х', L'ц', L'ч',
L'ш', L'щ', L'ъ', L'ы', L'ь', L'э', L'ю',
L'я',
#if !defined(COLORLCD)
#define UTF8_SUBS_LUT
// Warning, albeit the following table looks useless
// It does translate Cyrillic to Latin
static uint16_t _utf8_substitution_lut[] = {
L'А', L'A',
L'а', L'a',
L'В', L'B',
L'С', L'C',
L'с', L'c',
L'Е', L'E',
L'е', L'e',
L'Н', L'H',
L'К', L'K',
L'М', L'M',
L'І', L'I',
L'і', L'i',
L'О', L'O',
L'о', L'o',
L'о', L'o',
L'Р', L'P',
L'р', L'p',
L'Т', L'T',
L'Х', L'X',
L'х', L'x',
L'у', L'y'
};
#endif

static uint16_t _utf8_lut[] = {
L'Б', L'Г', L'Ґ', L'Д', L'Є', L'Ж', L'З',
L'И', L'Ї', L'Й', L'Л', L'П', L'У', L'Ф',
L'Ц', L'Ч', L'Ш', L'Щ', L'Ь', L'Ю', L'Я',
L'б', L'в', L'г', L'ґ', L'д', L'є', L'ж',
L'з', L'и', L'ї', L'й', L'к', L'л', L'м',
L'н', L'п', L'т', L'ф', L'ц', L'ч', L'ш',
L'щ', L'ь', L'ю', L'я'
};
#elif defined(TRANSLATIONS_SE)
static wchar_t _utf8_lut[] = {
static uint16_t _utf8_lut[] = {
L'å', L'ä', L'ö', L'Å', L'Ä', L'Ö',
};
#else
#define NO_UTF8_LUT
#endif

#if !defined(NO_UTF8_LUT)
#define MAX_TRANSLATED_CHARS 107
static_assert(sizeof(_utf8_lut) / sizeof(_utf8_lut[0]) <= MAX_TRANSLATED_CHARS, "Number of translated chars exceeds the limit");

static unsigned char lookup_utf8_mapping(wchar_t w)
{
for (uint32_t i=0; i < DIM(_utf8_lut); i++) {
Expand All @@ -149,7 +178,7 @@ static unsigned char lookup_utf8_mapping(wchar_t w)
#endif

#if defined(UTF8_SUBS_LUT)
static wchar_t lookup_utf8_substitution(wchar_t w)
static uint16_t lookup_utf8_substitution(wchar_t w)
{
for (uint32_t i=0; i < DIM(_utf8_substitution_lut); i+=2) {
if (w == _utf8_substitution_lut[i])
Expand Down
4 changes: 4 additions & 0 deletions radio/src/targets/taranis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ else()
message( FATAL_ERROR "Unknown CPU_TYPE_FULL" )
endif()

if(TRANSLATIONS STREQUAL UA AND NOT TARGET_FLASH_SIZE STREQUAL 1M)
pfeerick marked this conversation as resolved.
Show resolved Hide resolved
set(PXX2 OFF)
endif()

if(ENABLE_SERIAL_PASSTHROUGH)
set(CLI ON "Enable CLI")
endif()
Expand Down
2 changes: 1 addition & 1 deletion radio/util/font2png.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
chars_pl = u"""ąćęłńóśżźĄĆĘŁŃÓŚŻŹ"""
chars_pt = u"""ÁáÂâÃãÀàÇçÉéÊêÍíÓóÔôÕõÚú"""
chars_ru = u"""АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя"""
chars_ua = u"""АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгґдеєжзиіїйклмнопрстуфхцчшщьюя"""
chars_ua = u"""БГҐДЄЖЗИЇЙЛПУФЦЧШЩЬЮЯбвгґдєжзиїйклмнптфцчшщьюя"""

COUNT_EXTRA_CHARS = 21

Expand Down