mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 21:05:26 +03:00
fix chars continued
This commit is contained in:
parent
acdc2343dd
commit
7d2178cb5c
11 changed files with 34 additions and 43 deletions
|
@ -9,13 +9,7 @@ set(CJK_FONT_BOLD "Noto/NotoSansCJKsc-Bold")
|
||||||
#set(FONT "Ubuntu/Ubuntu-Regular")
|
#set(FONT "Ubuntu/Ubuntu-Regular")
|
||||||
#set(FONT_BOLD "Ubuntu/Ubuntu-Bold")
|
#set(FONT_BOLD "Ubuntu/Ubuntu-Bold")
|
||||||
|
|
||||||
if(TRANSLATIONS STREQUAL CN)
|
string(TOLOWER ${TRANSLATIONS} subset)
|
||||||
set(subset all)
|
|
||||||
elseif(TRANSLATIONS STREQUAL TW)
|
|
||||||
set(subset all)
|
|
||||||
else()
|
|
||||||
string(TOLOWER ${TRANSLATIONS} subset)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_truetype_font_target(9 9 ${subset} none)
|
add_truetype_font_target(9 9 ${subset} none)
|
||||||
add_truetype_font_target(13 13 ${subset} none)
|
add_truetype_font_target(13 13 ${subset} none)
|
||||||
|
|
|
@ -29,10 +29,7 @@ uint8_t getMappedChar(uint8_t c)
|
||||||
{
|
{
|
||||||
uint8_t result;
|
uint8_t result;
|
||||||
|
|
||||||
if (c < 0x80)
|
|
||||||
result = c - 0x20;
|
result = c - 0x20;
|
||||||
else
|
|
||||||
result = c - 0x80 + 32 + 26 + 6 + 26 + 5; // 96;
|
|
||||||
|
|
||||||
// TRACE("getMappedChar '%c' (0x%x) = %d", c, c, result);
|
// TRACE("getMappedChar '%c' (0x%x) = %d", c, c, result);
|
||||||
|
|
||||||
|
@ -61,7 +58,7 @@ int getTextWidth(const char * s, int len, LcdFlags flags)
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (int i = 0; len == 0 || i < len; ++i) {
|
for (int i = 0; len == 0 || i < len; ++i) {
|
||||||
unsigned int c = uint8_t(*s);
|
unsigned c = uint8_t(*s);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ constexpr LcdFlags MENU_FONT = FONT(STD);
|
||||||
constexpr LcdFlags TABLE_HEADER_FONT = FONT(STD);
|
constexpr LcdFlags TABLE_HEADER_FONT = FONT(STD);
|
||||||
constexpr LcdFlags TABLE_BODY_FONT = FONT(STD);
|
constexpr LcdFlags TABLE_BODY_FONT = FONT(STD);
|
||||||
|
|
||||||
constexpr int CJK_FIRST_LETTER_INDEX = 189;
|
constexpr int CJK_FIRST_LETTER_INDEX = 128 - 32 + 21;
|
||||||
constexpr coord_t CHAR_SPACING = 0;
|
constexpr coord_t CHAR_SPACING = 0;
|
||||||
|
|
||||||
#define ROTARY_ENCODER_SPEED() rotencSpeed
|
#define ROTARY_ENCODER_SPEED() rotencSpeed
|
||||||
|
|
|
@ -173,7 +173,7 @@ constexpr LcdFlags MENU_FONT = FONT(STD);
|
||||||
constexpr LcdFlags TABLE_HEADER_FONT = FONT(STD);
|
constexpr LcdFlags TABLE_HEADER_FONT = FONT(STD);
|
||||||
constexpr LcdFlags TABLE_BODY_FONT = FONT(STD);
|
constexpr LcdFlags TABLE_BODY_FONT = FONT(STD);
|
||||||
|
|
||||||
constexpr int CJK_FIRST_LETTER_INDEX = 168;
|
constexpr int CJK_FIRST_LETTER_INDEX = 128 - 32 + 21;
|
||||||
constexpr coord_t CHAR_SPACING = 0;
|
constexpr coord_t CHAR_SPACING = 0;
|
||||||
|
|
||||||
#endif // _LIBOPENUI_CONFIG_H_
|
#endif // _LIBOPENUI_CONFIG_H_
|
||||||
|
|
|
@ -55,6 +55,8 @@
|
||||||
#define LEN_SPECIAL_CHARS 0
|
#define LEN_SPECIAL_CHARS 0
|
||||||
#elif defined(TRANSLATIONS_CN)
|
#elif defined(TRANSLATIONS_CN)
|
||||||
#include "translations/cn.h"
|
#include "translations/cn.h"
|
||||||
|
#elif defined(TRANSLATIONS_TW)
|
||||||
|
#include "translations/tw.h"
|
||||||
#define LEN_SPECIAL_CHARS 0
|
#define LEN_SPECIAL_CHARS 0
|
||||||
#else
|
#else
|
||||||
#include "translations/en.h"
|
#include "translations/en.h"
|
||||||
|
|
|
@ -4,9 +4,6 @@ foreach(translation ${translations})
|
||||||
get_filename_component(language ${translation} NAME_WE)
|
get_filename_component(language ${translation} NAME_WE)
|
||||||
get_filename_component(path ${translation} DIRECTORY)
|
get_filename_component(path ${translation} DIRECTORY)
|
||||||
set(target ${language}.h)
|
set(target ${language}.h)
|
||||||
if(PCB STREQUAL X12S OR PCB STREQUAL X10 OR PCB STREQUAL NV14)
|
|
||||||
set(language all)
|
|
||||||
endif()
|
|
||||||
if(PYTHONINTERP_FOUND)
|
if(PYTHONINTERP_FOUND)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${target}
|
OUTPUT ${target}
|
||||||
|
|
|
@ -1129,19 +1129,19 @@
|
||||||
#define TR_BAR1_COLOR "主条形图颜色"
|
#define TR_BAR1_COLOR "主条形图颜色"
|
||||||
#define TR_TEXT_COLOR "文本颜色"
|
#define TR_TEXT_COLOR "文本颜色"
|
||||||
#define TR_TEXT_VIEWER "文本视图"
|
#define TR_TEXT_VIEWER "文本视图"
|
||||||
#define TR_MENU_INPUTS "\214输入"
|
#define TR_MENU_INPUTS STR_CHAR_INPUT "输入"
|
||||||
#define TR_MENU_LUA "\222LUA脚本"
|
#define TR_MENU_LUA STR_CHAR_LUA "LUA脚本"
|
||||||
#define TR_MENU_STICKS "\207摇杆"
|
#define TR_MENU_STICKS STR_CHAR_STICK "摇杆"
|
||||||
#define TR_MENU_POTS "\210旋钮"
|
#define TR_MENU_POTS STR_CHAR_POT "旋钮"
|
||||||
#define TR_MENU_MAX "\215固定值MAX"
|
#define TR_MENU_MAX STR_CHAR_FUNCTION "固定值MAX"
|
||||||
#define TR_MENU_HELI "\216斜盘混控CYC"
|
#define TR_MENU_HELI STR_CHAR_CYC "斜盘混控CYC"
|
||||||
#define TR_MENU_TRIMS "\213微调"
|
#define TR_MENU_TRIMS STR_CHAR_TRIM "微调"
|
||||||
#define TR_MENU_SWITCHES "\212开关"
|
#define TR_MENU_SWITCHES STR_CHAR_SWITCH "开关"
|
||||||
#define TR_MENU_LOGICAL_SWITCHES "\212逻辑开关"
|
#define TR_MENU_LOGICAL_SWITCHES STR_CHAR_SWITCH "逻辑开关"
|
||||||
#define TR_MENU_TRAINER "\217教练"
|
#define TR_MENU_TRAINER STR_CHAR_TRAINER "教练"
|
||||||
#define TR_MENU_CHANNELS "\220通道"
|
#define TR_MENU_CHANNELS STR_CHAR_CHANNEL "通道"
|
||||||
#define TR_MENU_GVARS "\211全局变量"
|
#define TR_MENU_GVARS STR_CHAR_SLIDER "全局变量"
|
||||||
#define TR_MENU_TELEMETRY "\221回传"
|
#define TR_MENU_TELEMETRY STR_CHAR_TELEMETRY "回传"
|
||||||
#define TR_MENU_DISPLAY "显示"
|
#define TR_MENU_DISPLAY "显示"
|
||||||
#define TR_MENU_OTHER "其它"
|
#define TR_MENU_OTHER "其它"
|
||||||
#define TR_MENU_INVERT "反向"
|
#define TR_MENU_INVERT "反向"
|
||||||
|
|
|
@ -388,7 +388,7 @@
|
||||||
#define TR_TEXT_SIZE "Standard""Tiny\0 ""Small\0 ""Mid\0 ""Double\0 "
|
#define TR_TEXT_SIZE "Standard""Tiny\0 ""Small\0 ""Mid\0 ""Double\0 "
|
||||||
|
|
||||||
#define LEN_SUBTRIMMODES "\017"
|
#define LEN_SUBTRIMMODES "\017"
|
||||||
#define TR_SUBTRIMMODES STR_CHAR_DELTA" (center only)""= (symetrical) "
|
#define TR_SUBTRIMMODES STR_CHAR_DELTA " (center only)""= (symetrical) "
|
||||||
|
|
||||||
// ZERO TERMINATED STRINGS
|
// ZERO TERMINATED STRINGS
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,9 @@ from charset import get_chars, special_chars, extra_chars, standard_chars
|
||||||
|
|
||||||
|
|
||||||
class FontBitmap:
|
class FontBitmap:
|
||||||
def __init__(self, chars, font_size, font_name, cjk_font_name, foreground, background):
|
def __init__(self, language, font_size, font_name, cjk_font_name, foreground, background):
|
||||||
self.chars = chars
|
self.language = language
|
||||||
|
self.chars = get_chars(language)
|
||||||
self.font_size = font_size
|
self.font_size = font_size
|
||||||
self.foreground = foreground
|
self.foreground = foreground
|
||||||
self.background = background
|
self.background = background
|
||||||
|
@ -95,11 +96,9 @@ class FontBitmap:
|
||||||
for c in self.chars:
|
for c in self.chars:
|
||||||
if c == " ":
|
if c == " ":
|
||||||
w = 4
|
w = 4
|
||||||
elif c in special_chars["cn"]:
|
|
||||||
w = self.draw_char(image, width, c, self.cjk_font, -3)
|
|
||||||
elif c in extra_chars:
|
elif c in extra_chars:
|
||||||
if self.extra_bitmap:
|
if self.extra_bitmap:
|
||||||
for i in range(128 - 32 - len(standard_chars) - 1):
|
for i in range(128 - 32 - len(standard_chars)):
|
||||||
coords.append(width)
|
coords.append(width)
|
||||||
image.paste(self.extra_bitmap.copy(), (width, 0))
|
image.paste(self.extra_bitmap.copy(), (width, 0))
|
||||||
for coord in [14, 14, 12, 12, 13, 13, 13, 13, 13] + [15] * 12:
|
for coord in [14, 14, 12, 12, 13, 13, 13, 13, 13] + [15] * 12:
|
||||||
|
@ -107,6 +106,8 @@ class FontBitmap:
|
||||||
width += coord
|
width += coord
|
||||||
self.extra_bitmap = None
|
self.extra_bitmap = None
|
||||||
continue
|
continue
|
||||||
|
elif c in special_chars[self.language]:
|
||||||
|
w = self.draw_char(image, width, c, self.cjk_font, -3)
|
||||||
else:
|
else:
|
||||||
w = self.draw_char(image, width, c, self.font)
|
w = self.draw_char(image, width, c, self.font)
|
||||||
|
|
||||||
|
@ -135,13 +136,13 @@ def main():
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Builder for OpenTX font files")
|
parser = argparse.ArgumentParser(description="Builder for OpenTX font files")
|
||||||
parser.add_argument('--output', help="Output file name")
|
parser.add_argument('--output', help="Output file name")
|
||||||
parser.add_argument('--subset', help="Subset", default="all")
|
parser.add_argument('--subset', help="Subset")
|
||||||
parser.add_argument('--size', type=int, help="Font size")
|
parser.add_argument('--size', type=int, help="Font size")
|
||||||
parser.add_argument('--font', help="Font name")
|
parser.add_argument('--font', help="Font name")
|
||||||
parser.add_argument('--cjk-font', help="CJK font name")
|
parser.add_argument('--cjk-font', help="CJK font name")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
font = FontBitmap(get_chars(args.subset), args.size, args.font, args.cjk_font, (0, 0, 0), (255, 255, 255))
|
font = FontBitmap(args.subset, args.size, args.font, args.cjk_font, (0, 0, 0), (255, 255, 255))
|
||||||
font.generate(args.output)
|
font.generate(args.output)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ subset_lowercase = {
|
||||||
|
|
||||||
def get_chars(subset):
|
def get_chars(subset):
|
||||||
result = standard_chars + extra_chars
|
result = standard_chars + extra_chars
|
||||||
if subset == "all":
|
if False: # subset == "all":
|
||||||
for key, chars in special_chars.items():
|
for key, chars in special_chars.items():
|
||||||
result += "".join([char for char in chars if char not in result])
|
result += "".join([char for char in chars if char not in result])
|
||||||
else:
|
else:
|
||||||
|
@ -65,11 +65,11 @@ def get_chars(subset):
|
||||||
|
|
||||||
def get_chars_encoding(subset):
|
def get_chars_encoding(subset):
|
||||||
result = {}
|
result = {}
|
||||||
if subset == "all":
|
if subset in ("cn", "tw"):
|
||||||
chars = get_chars(subset)
|
chars = get_chars(subset)
|
||||||
for char in chars:
|
for char in chars:
|
||||||
if char in special_chars["cn"]:
|
if char in special_chars[subset]:
|
||||||
index = special_chars["cn"].index(char) + 1
|
index = special_chars[subset].index(char) + 1
|
||||||
if index >= 0x100:
|
if index >= 0x100:
|
||||||
index += 1
|
index += 1
|
||||||
result[char] = "\\%03o\\%03o" % (0xFE + ((index >> 8) & 0x01), index & 0xFF)
|
result[char] = "\\%03o\\%03o" % (0xFE + ((index >> 8) & 0x01), index & 0xFF)
|
||||||
|
|
|
@ -15,7 +15,7 @@ def main():
|
||||||
parser.add_argument("--reverse", help="Reversed char conversion (from number to char)", action="store_true")
|
parser.add_argument("--reverse", help="Reversed char conversion (from number to char)", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.language != "all" and args.language not in special_chars:
|
if args.language not in special_chars:
|
||||||
parser.error(args.language + ' is not a supported language. Try one of the supported ones: %s' % list(special_chars.keys()))
|
parser.error(args.language + ' is not a supported language. Try one of the supported ones: %s' % list(special_chars.keys()))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue