1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-21 15:25:12 +03:00

fix: Danish special characters on B&W radios (#2271)

* Dannish special characters

* Danish special characters

* Danish special characters

* Danish special characters

* Danish special characters

* Danish special characters

* chore: Reset header to `copyright-header` template
`tools/copyright-header.txt` template is what should be used.
Also added line at EoF to make git happy

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
HThuren 2022-09-07 12:15:08 +02:00 committed by GitHub
parent 435e4c86f5
commit 3b2f07ae85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 120 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

View file

@ -27,7 +27,7 @@ const unsigned char font_5x7[] = {
#if defined(TRANSLATIONS_DE) #if defined(TRANSLATIONS_DE)
#include "font_de_05x07.lbm" #include "font_de_05x07.lbm"
#elif defined(TRANSLATIONS_DA) #elif defined(TRANSLATIONS_DA)
#include "font_se_05x07.lbm" #include "font_da_05x07.lbm"
#elif defined(TRANSLATIONS_CZ) #elif defined(TRANSLATIONS_CZ)
#include "font_cz_05x07.lbm" #include "font_cz_05x07.lbm"
#elif defined(TRANSLATIONS_ES) #elif defined(TRANSLATIONS_ES)
@ -57,7 +57,7 @@ const unsigned char font_10x14[] = {
#if defined(TRANSLATIONS_DE) #if defined(TRANSLATIONS_DE)
#include "font_de_10x14.lbm" #include "font_de_10x14.lbm"
#elif defined(TRANSLATIONS_DA) #elif defined(TRANSLATIONS_DA)
#include "font_se_10x14.lbm" #include "font_da_10x14.lbm"
#elif defined(TRANSLATIONS_CZ) #elif defined(TRANSLATIONS_CZ)
#include "font_cz_10x14.lbm" #include "font_cz_10x14.lbm"
#elif defined(TRANSLATIONS_ES) #elif defined(TRANSLATIONS_ES)
@ -86,7 +86,7 @@ const unsigned char font_4x6[] = {
#if defined(TRANSLATIONS_DE) #if defined(TRANSLATIONS_DE)
#include "font_de_04x06.lbm" #include "font_de_04x06.lbm"
#elif defined(TRANSLATIONS_DA) #elif defined(TRANSLATIONS_DA)
#include "font_se_04x06.lbm" #include "font_da_04x06.lbm"
#elif defined(TRANSLATIONS_CZ) #elif defined(TRANSLATIONS_CZ)
#include "font_cz_04x06.lbm" #include "font_cz_04x06.lbm"
#elif defined(TRANSLATIONS_ES) #elif defined(TRANSLATIONS_ES)
@ -111,7 +111,7 @@ const unsigned char font_8x10[] = {
#if defined(TRANSLATIONS_DE) #if defined(TRANSLATIONS_DE)
#include "font_de_08x10.lbm" #include "font_de_08x10.lbm"
#elif defined(TRANSLATIONS_DA) #elif defined(TRANSLATIONS_DA)
#include "font_cz_08x10.lbm" #include "font_da_08x10.lbm"
#elif defined(TRANSLATIONS_CZ) #elif defined(TRANSLATIONS_CZ)
#include "font_cz_08x10.lbm" #include "font_cz_08x10.lbm"
#elif defined(TRANSLATIONS_ES) #elif defined(TRANSLATIONS_ES)

View file

@ -2,9 +2,9 @@
* Copyright (C) EdgeTX * Copyright (C) EdgeTX
* *
* Based on code named * Based on code named
* opentx - https://github.com/opentx/opentx * opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x * th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x * er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x * gruvin9x - http://code.google.com/p/gruvin9x
* *
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
@ -27,6 +27,10 @@
static wchar_t _utf8_lut[] = { static wchar_t _utf8_lut[] = {
L'é', L'è', L'à', L'î', L'ç', L'é', L'è', L'à', L'î', L'ç',
}; };
#elif defined(TRANSLATIONS_DA)
static wchar_t _utf8_lut[] = {
L'å', L'æ', L'ø', L'Å', L'Æ', L'Ø',
};
#elif defined(TRANSLATIONS_DE) #elif defined(TRANSLATIONS_DE)
static wchar_t _utf8_lut[] = { static wchar_t _utf8_lut[] = {
L'Ä', L'ä', L'Ö', L'ö', L'Ü', L'ü', L'ß', L'Ä', L'ä', L'Ö', L'ö', L'Ü', L'ü', L'ß',

View file

@ -2,9 +2,9 @@
* Copyright (C) EdgeTX * Copyright (C) EdgeTX
* *
* Based on code named * Based on code named
* opentx - https://github.com/opentx/opentx * opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x * th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x * er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x * gruvin9x - http://code.google.com/p/gruvin9x
* *
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
@ -17,7 +17,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*
*/ */
// DK translations author: Henrik Thuren <thuren.henrik@gmail.com> // DK translations author: Henrik Thuren <thuren.henrik@gmail.com>
@ -373,7 +372,7 @@
#define TR_ELEDIRECTION "HØJ retning" #define TR_ELEDIRECTION "HØJ retning"
#define TR_AILDIRECTION "KRÆ retning" #define TR_AILDIRECTION "KRÆ retning"
#define TR_COLDIRECTION "PIT retning" #define TR_COLDIRECTION "PIT retning"
#define TR_MODE "Tilstand" #define TR_MODE "Tilst."
#define TR_SUBTYPE INDENT "Subtype" #define TR_SUBTYPE INDENT "Subtype"
#define TR_NOFREEEXPO "Ingen fri expo!" #define TR_NOFREEEXPO "Ingen fri expo!"
#define TR_NOFREEMIXER "Ingen fri mix!" #define TR_NOFREEMIXER "Ingen fri mix!"

103
radio/util/font2png.py Normal file
View file

@ -0,0 +1,103 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os
import glob
from PIL import Image, ImageDraw, ImageFont
chars_en = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~|≥"""
chars_fr = u"""éèàîç"""
chars_da = u"""åæøÅÆØ"""
chars_de = u"""ÄäÖöÜüß"""
chars_cz = u"""ěščřžýáíéňóůúďťĚŠČŘŽÝÁÍÉŇÓÚŮĎŤ"""
chars_es = u"""ÑñÁáÉéÍíÓóÚú"""
chars_fi = u"""åäöÅÄÖ"""
chars_it = u"""àù"""
chars_pl = u"""ąćęłńóśżźĄĆĘŁŃÓŚŻŹ"""
chars_pt = u"""ÁáÂâÃãÀàÇçÉéÊêÍíÓóÔôÕõÚú"""
COUNT_EXTRA_CHARS = 21
chars_extra = u"".join([chr(1+i) for i in range(COUNT_EXTRA_CHARS)])
chars = chars_en + chars_extra + chars_fr + chars_da + chars_de + chars_cz + chars_es + chars_fi + chars_it + chars_pl + chars_pt
def createFontBitmap(filename, fontname, fontsize, fontoffset, foreground, background, coordsfile=True):
coords = []
font_filename = 'fonts/' + fontname + '.ttf'
print("Font filename: %s" % font_filename)
font = ImageFont.truetype(font_filename, fontsize)
extraImage = None
extraFilename = 'fonts/extra_%dpx.png' % fontsize
try:
extraImage = Image.open(extraFilename)
extraImage = extraImage.convert('RGB');
except IOError:
print("Missing extra symbol filename %s" % extraFilename)
def getCharWidth(c):
if c in chars_extra:
if extraImage:
# Extra characters 16px
#if fontsize == 16:
if ord(c) <= 9:
return 13
else:
return 15
else:
return 0
elif c == " ":
return 4
else:
w, h = font.getsize(c)
return w + 1
def getFontWidth():
width = 0
for c in chars:
width += getCharWidth(c)
return width
width = getFontWidth()
image = Image.new('RGB', (width, fontsize + 4), background)
draw = ImageDraw.Draw(image)
width = 0
for c in chars:
coords.append(width)
if c in chars_extra:
if extraImage and c == chars_extra[0]:
image.paste(extraImage.copy(),(width,1))
elif c == " ":
pass
elif c == "j" and fontsize == 32:
w, h = font.getsize(c)
draw.text((width + 2, fontoffset), c, fill=foreground, font=font)
elif c == "j" and fontsize == 64:
aw, h = font.getsize(c)
draw.text((width + 3, fontoffset), c, fill=foreground, font=font)
else:
w, h = font.getsize(c)
draw.text((width + 1, fontoffset), c, fill=foreground, font=font)
width += getCharWidth(c)
coords.append(width)
image.save(filename + ".png")
if coordsfile:
with open(filename + ".specs", "w") as f:
f.write(",".join(str(tmp) for tmp in coords))
# Main
if __name__ == "__main__":
createFontBitmap(sys.argv[4], sys.argv[1], int(sys.argv[2]), int(sys.argv[3]), (0,0,0), (255,255,255))

View file

@ -14,7 +14,7 @@ def is_special_char(c):
def get_special_chars(): def get_special_chars():
result = {} result = {}
for lang in["en", "fr", "de", "cz", "nl", "es", "fi", "it", "pl", "pt", "se", "cn", "tw"]: for lang in["en", "fr", "da", "de", "cz", "nl", "es", "fi", "it", "pl", "pt", "se", "cn", "tw"]:
charset = set() charset = set()
tools_path = os.path.dirname(os.path.realpath(__file__)) tools_path = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(tools_path, "../radio/src/translations/%s.h" % lang), encoding='utf-8') as f: with open(os.path.join(tools_path, "../radio/src/translations/%s.h" % lang), encoding='utf-8') as f:
@ -58,6 +58,7 @@ def get_chars_encoding(subset):
special_chars_BW = { special_chars_BW = {
"en": "", "en": "",
"fr": "éèàîç", "fr": "éèàîç",
"da": "åæøÅÆØ",
"de": "ÄäÖöÜüß", "de": "ÄäÖöÜüß",
"cz": "áčéěíóřšúůýÁÍŘÝžÉ", "cz": "áčéěíóřšúůýÁÍŘÝžÉ",
"nl": "", "nl": "",