French special chars added
|
@ -38,6 +38,7 @@ configure_file(stamp.h.in stamp.h @ONLY)
|
|||
|
||||
add_subdirectory(translations)
|
||||
add_subdirectory(bitmaps)
|
||||
add_subdirectory(fonts)
|
||||
add_subdirectory(lua)
|
||||
|
||||
set(EEPROM_VARIANT 0)
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
add_truetype_font_target(horus tinsize "DejaVu Sans" 9 False)
|
||||
add_truetype_font_target(horus smlsize "DejaVu Sans" 13 False)
|
||||
add_truetype_font_target(horus stdsize "DejaVu Sans" 16 False)
|
||||
add_truetype_font_target(horus stdsizebold "DejaVu Sans" 16 True)
|
||||
add_truetype_font_target(horus midsize "DejaVu Sans" 24 False)
|
||||
add_truetype_font_target(horus dblsize "DejaVu Sans" 32 True)
|
||||
add_truetype_font_target(horus xxlsize "DejaVu Sans" 48 False)
|
||||
add_custom_target(ttf_horus_fonts DEPENDS ${ttf_horus_fonts_targets})
|
||||
|
||||
add_bitmaps_target(horus_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/bmp_*.png" 480 5/6/5)
|
||||
add_bitmaps_target(horus_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/calibration/bmp_*.png" 480 5/6/5)
|
||||
add_bitmaps_target(horus_button_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/button/alpha_*.png" 480 4/4/4/4)
|
||||
|
|
1
radio/src/fonts/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
add_subdirectory(horus)
|
10
radio/src/fonts/horus/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
set(FONT "DejaVu Sans")
|
||||
|
||||
add_truetype_font_target(horus tinsize ${FONT} 9 False)
|
||||
add_truetype_font_target(horus smlsize ${FONT} 13 False)
|
||||
add_truetype_font_target(horus stdsize ${FONT} 16 False)
|
||||
add_truetype_font_target(horus stdsizebold ${FONT} 16 True)
|
||||
add_truetype_font_target(horus midsize ${FONT} 24 False)
|
||||
add_truetype_font_target(horus dblsize ${FONT} 32 True)
|
||||
add_truetype_font_target(horus xxlsize ${FONT} 48 False)
|
||||
add_custom_target(ttf_horus_fonts DEPENDS ${ttf_horus_fonts_targets})
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 28 KiB |
|
@ -1 +1 @@
|
|||
0,4,14,28,54,76,110,139,146,160,173,193,217,228,242,251,266,289,310,331,352,375,397,420,441,464,487,497,508,532,556,580,598,613,641,665,689,715,736,757,783,808,818,832,859,880,910,935,963,987,1015,1040,1062,1087,1112,1140,1178,1206,1234,1258,1272,1287,1300,1324,1343,1356,1378,1401,1420,1443,1466,1484,1507,1529,1539,1553,1576,1586,1618,1640,1663,1686,1709,1726,1746,1764,1786,1810,1841,1865,1889,1909,1933,1936,1960,1988,2015,2033,2051,2074,2097,2120,2143,2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171
|
||||
0,4,14,28,54,76,110,139,146,160,173,193,217,228,242,251,266,289,310,331,352,375,397,420,441,464,487,497,508,532,556,580,598,613,641,665,689,715,736,757,783,808,818,832,859,880,910,935,963,987,1015,1040,1062,1087,1112,1140,1178,1206,1234,1258,1272,1287,1300,1324,1343,1356,1378,1401,1420,1443,1466,1484,1507,1529,1539,1553,1576,1586,1618,1640,1663,1686,1709,1726,1746,1764,1786,1810,1841,1865,1889,1909,1933,1937,1961,1989,2016,2034,2052,2075,2098,2121,2144,2172,2172,2172,2172,2172,2172,2172,2172,2172,2172,2172,2172,2172,2195,2218,2240,2255,2274
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 21 KiB |
|
@ -1 +1 @@
|
|||
0,4,10,20,41,56,80,100,106,115,125,140,159,167,177,184,196,212,227,242,258,274,290,306,322,338,354,361,369,388,407,426,440,451,471,487,505,524,539,553,572,589,595,605,623,638,658,675,695,710,730,747,763,782,799,819,845,864,883,901,910,922,931,950,967,976,991,1006,1020,1036,1052,1064,1080,1095,1101,1110,1125,1131,1154,1169,1185,1200,1216,1227,1241,1253,1268,1285,1306,1323,1340,1354,1373,1376,1395,1416,1437,1452,1467,1484,1501,1518,1535,1557, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1557
|
||||
0,4,10,20,41,56,80,100,106,115,125,140,159,167,177,184,196,212,227,242,258,274,290,306,322,338,354,361,369,388,407,426,440,451,471,487,505,524,539,553,572,589,595,605,623,638,658,675,695,710,730,747,763,782,799,819,845,864,883,901,910,922,931,950,967,976,991,1006,1020,1036,1052,1064,1080,1095,1101,1110,1125,1131,1154,1169,1185,1200,1216,1227,1241,1253,1268,1285,1306,1323,1340,1354,1373,1377,1396,1417,1438,1453,1468,1485,1502,1519,1536,1558,1558,1558,1558,1558,1558,1558,1558,1558,1558,1558,1558,1558,1574,1590,1605,1616,1630
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
@ -1 +1 @@
|
|||
0,4,8,13,23,31,44,55,58,63,67,75,85,88,94,97,103,112,120,128,137,146,154,163,171,180,189,192,195,205,215,225,232,238,248,256,266,276,284,291,301,310,313,318,327,335,345,354,365,373,384,393,402,412,421,431,445,455,465,475,479,485,489,499,508,513,521,529,537,546,555,561,570,578,581,586,594,597,609,617,626,634,643,649,657,663,671,680,692,701,710,718,728,729,739,751,763,771,779,789,799,809,819,830, 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, 830
|
||||
0,4,8,13,23,31,44,55,58,63,67,75,85,88,94,97,103,112,120,128,137,146,154,163,171,180,189,192,195,205,215,225,232,238,248,256,266,276,284,291,301,310,313,318,327,335,345,354,365,373,384,393,402,412,421,431,445,455,465,475,479,485,489,499,508,513,521,529,537,546,555,561,570,578,581,586,594,597,609,617,626,634,643,649,657,663,671,680,692,701,710,718,728,732,742,754,766,774,782,792,802,812,822,833,833,833,833,833,833,833,833,833,833,833,833,833,842,851,859,865,873
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
|
@ -1 +1 @@
|
|||
0,4,7,13,26,35,51,63,66,71,76,85,97,101,107,111,118,128,137,146,155,166,175,185,194,204,214,218,222,234,246,258,266,273,285,295,307,319,329,338,351,362,366,372,383,392,405,416,429,439,452,463,473,485,496,508,525,537,549,561,566,573,578,590,601,607,617,627,636,646,656,663,673,682,685,690,700,703,718,727,737,747,757,764,773,780,789,799,813,823,833,842,854,855,867,881,895,904,913,924,935,946,957,971, 986, 1001, 1016, 1031, 1046, 1061, 1076, 1091, 1106, 1121, 1136, 1151, 1166
|
||||
0,4,7,13,26,35,51,63,66,71,76,85,97,101,107,111,118,128,137,146,155,166,175,185,194,204,214,218,222,234,246,258,266,273,285,295,307,319,329,338,351,362,366,372,383,392,405,416,429,439,452,463,473,485,496,508,525,537,549,561,566,573,578,590,601,607,617,627,636,646,656,663,673,682,685,690,700,703,718,727,737,747,757,764,773,780,789,799,813,823,833,842,854,858,870,884,898,907,916,927,938,949,960,974,989,1004,1019,1034,1049,1064,1079,1094,1109,1124,1139,1154,1164,1174,1184,1191,1200
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
@ -1 +1 @@
|
|||
0,4,9,16,29,40,57,72,76,83,89,99,111,117,124,129,136,148,159,169,179,191,202,213,223,235,247,252,257,269,281,293,302,309,323,335,347,360,370,380,393,405,410,417,430,440,455,467,481,493,507,519,530,542,554,568,587,601,615,627,634,641,647,659,668,675,686,697,707,719,731,740,752,763,768,775,786,791,807,818,830,841,853,861,871,880,891,903,919,931,943,953,965,966,978,992,1006,1015,1024,1035,1046,1057,1068,1082, 1097, 1112, 1127, 1142, 1157, 1172, 1187, 1202, 1217, 1232, 1247, 1262, 1277
|
||||
0,4,9,16,29,40,57,72,76,83,89,99,111,117,124,129,136,148,159,169,179,191,202,213,223,235,247,252,257,269,281,293,302,309,323,335,347,360,370,380,393,405,410,417,430,440,455,467,481,493,507,519,530,542,554,568,587,601,615,627,634,641,647,659,668,675,686,697,707,719,731,740,752,763,768,775,786,791,807,818,830,841,853,861,871,880,891,903,919,931,943,953,965,969,981,995,1009,1018,1027,1038,1049,1060,1071,1085,1100,1115,1130,1145,1160,1175,1190,1205,1220,1235,1250,1265,1277,1289,1300,1307,1317
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.5 KiB |
|
@ -1 +1 @@
|
|||
0,4,7,12,20,26,36,44,47,51,55,61,69,72,76,79,84,91,97,103,109,116,122,129,135,142,149,151,154,162,170,178,184,189,197,204,211,219,226,232,240,247,250,254,262,268,276,283,291,298,306,313,320,328,335,343,353,360,368,375,379,384,388,396,403,407,413,420,426,432,439,444,450,456,459,463,470,473,482,488,495,502,508,513,519,524,530,537,545,552,559,565,573,574,582,591,600,606,612,619,626,633,640,648, 648, 648, 648, 648, 648, 648, 648, 648, 648, 648, 648, 648, 648
|
||||
0,4,7,12,20,26,36,44,47,51,55,61,69,72,76,79,84,91,97,103,109,116,122,129,135,142,149,151,154,162,170,178,184,189,197,204,211,219,226,232,240,247,250,254,262,268,276,283,291,298,306,313,320,328,335,343,353,360,368,375,379,384,388,396,403,407,413,420,426,432,439,444,450,456,459,463,470,473,482,488,495,502,508,513,519,524,530,537,545,552,559,565,573,577,585,594,603,609,615,622,629,636,643,651,651,651,651,651,651,651,651,651,651,651,651,651,658,665,671,676,682
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 43 KiB |
|
@ -1 +1 @@
|
|||
0,4,12,29,66,93,137,173,181,195,210,235,269,280,296,305,325,353,378,404,431,460,487,515,542,570,598,607,618,652,686,720,743,762,798,827,859,893,920,944,979,1010,1019,1035,1067,1093,1129,1160,1197,1224,1261,1292,1320,1354,1384,1420,1468,1502,1536,1568,1582,1602,1616,1650,1679,1695,1722,1749,1774,1802,1830,1850,1878,1904,1912,1925,1952,1960,2002,2028,2056,2083,2111,2130,2154,2174,2200,2229,2268,2297,2326,2351,2385,2388,2422,2461,2500,2525,2550,2581,2612,2643,2674,2714, 2714, 2714, 2714, 2714, 2714, 2714, 2714, 2714, 2714, 2714, 2714, 2714, 2714
|
||||
0,4,12,29,66,93,137,173,181,195,210,235,269,280,296,305,325,353,378,404,431,460,487,515,542,570,598,607,618,652,686,720,743,762,798,827,859,893,920,944,979,1010,1019,1035,1067,1093,1129,1160,1197,1224,1261,1292,1320,1354,1384,1420,1468,1502,1536,1568,1582,1602,1616,1650,1679,1695,1722,1749,1774,1802,1830,1850,1878,1904,1912,1925,1952,1960,2002,2028,2056,2083,2111,2130,2154,2174,2200,2229,2268,2297,2326,2351,2385,2389,2423,2462,2501,2526,2551,2582,2613,2644,2675,2715,2715,2715,2715,2715,2715,2715,2715,2715,2715,2715,2715,2715,2743,2771,2798,2817,2842
|
|
@ -326,6 +326,11 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
|
|||
break;
|
||||
}
|
||||
else if (c >= 0x20) {
|
||||
#if defined(TRANSLATIONS_FR)
|
||||
if (c >= 0x80 && c <= 0x85) {
|
||||
c = 0x20 + 115 + c - 0x80;
|
||||
}
|
||||
#endif
|
||||
if (fontcache) {
|
||||
drawCharWithCache(x, y, fontcache, fontspecs, getMappedChar(c), flags);
|
||||
}
|
||||
|
|
|
@ -10,36 +10,15 @@ app = Qt.QApplication(sys.argv)
|
|||
for f in glob.glob("fonts/*.ttf"):
|
||||
QtGui.QFontDatabase.addApplicationFont(f)
|
||||
|
||||
chars = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓↗↘↙↖△"""
|
||||
chars_en = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓↗↘↙↖△"""
|
||||
chars_fr = u"""éèàîç"""
|
||||
|
||||
COUNT_EXTRA_CHARS = 12
|
||||
|
||||
def getCharWidth(fontsize, metrics, index):
|
||||
if index == 0:
|
||||
return 4
|
||||
elif index == 14 and fontsize <= 8:
|
||||
return 1
|
||||
else:
|
||||
rect = metrics.boundingRect(chars[index])
|
||||
if fontsize >= 24:
|
||||
return rect.width() + 3
|
||||
else:
|
||||
return rect.width() + 1
|
||||
chars_extra = u"".join([chr(1+i) for i in range(COUNT_EXTRA_CHARS)])
|
||||
chars = chars_en + chars_extra + chars_fr
|
||||
|
||||
|
||||
def getFontTopBottom(fontsize, metrics):
|
||||
top, bottom = 0, 0
|
||||
for i, c in enumerate(chars):
|
||||
rect = metrics.boundingRect(chars[i])
|
||||
top = min(top, rect.top())
|
||||
bottom = max(bottom, rect.bottom())
|
||||
return top, bottom
|
||||
|
||||
|
||||
def getFontWidth(fontsize, metrics):
|
||||
width = 0
|
||||
for i, c in enumerate(chars):
|
||||
width += getCharWidth(fontsize, metrics, i)
|
||||
return width
|
||||
print len(chars_en + chars_extra)
|
||||
|
||||
|
||||
def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, background, coordsfile=True):
|
||||
|
@ -51,16 +30,46 @@ def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, backgro
|
|||
font.setStyleStrategy(QtGui.QFont.PreferAntialias)
|
||||
metrics = QtGui.QFontMetrics(font)
|
||||
|
||||
width = getFontWidth(fontsize, metrics)
|
||||
top, bottom = getFontTopBottom(fontsize, metrics)
|
||||
extraFilename = "fonts/extra_%dpx.png" % fontsize
|
||||
extraImage = QtGui.QImage(extraFilename)
|
||||
if extraImage.isNull():
|
||||
print("No extra font file", extraFilename)
|
||||
extraImage = None
|
||||
extraWidth = 0
|
||||
else:
|
||||
extraWidth = extraImage.size().width()
|
||||
image = QtGui.QImage(width + extraWidth, fontsize + 2, QtGui.QImage.Format_RGB32)
|
||||
extraWidth = extraImage.size().width() / COUNT_EXTRA_CHARS
|
||||
|
||||
def getCharWidth(c):
|
||||
if c in chars_extra:
|
||||
return extraWidth
|
||||
elif c == " ":
|
||||
return 4
|
||||
elif c == "." and fontsize <= 8:
|
||||
return 1
|
||||
else:
|
||||
r = metrics.boundingRect(c)
|
||||
if fontsize >= 24:
|
||||
return r.width() + 3
|
||||
else:
|
||||
return r.width() + 1
|
||||
|
||||
def getFontWidth():
|
||||
width = 0
|
||||
for c in chars:
|
||||
width += getCharWidth(c)
|
||||
return width
|
||||
|
||||
def getFontTopBottom():
|
||||
top, bottom = 0, 0
|
||||
for i, c in enumerate(chars):
|
||||
r = metrics.boundingRect(chars[i])
|
||||
top = min(top, r.top())
|
||||
bottom = max(bottom, r.bottom())
|
||||
return top, bottom
|
||||
|
||||
width = getFontWidth()
|
||||
top, bottom = getFontTopBottom()
|
||||
image = QtGui.QImage(width, fontsize + 2, QtGui.QImage.Format_RGB32)
|
||||
image.fill(background)
|
||||
painter = QtGui.QPainter()
|
||||
painter.begin(image)
|
||||
|
@ -68,11 +77,14 @@ def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, backgro
|
|||
pen = QtGui.QPen(foreground)
|
||||
painter.setPen(pen)
|
||||
width = 0
|
||||
for i, c in enumerate(chars):
|
||||
for c in chars:
|
||||
coords.append(width)
|
||||
if i == 0:
|
||||
if c in chars_extra:
|
||||
if extraImage and c == chars_extra[0]:
|
||||
painter.drawImage(QtCore.QPoint(width, 0), extraImage)
|
||||
elif c == " ":
|
||||
pass
|
||||
elif i == 14 and fontsize <= 8:
|
||||
elif c == "." and fontsize <= 8:
|
||||
painter.drawPoint(width, fontsize)
|
||||
else:
|
||||
rect = metrics.boundingRect(c)
|
||||
|
@ -80,9 +92,7 @@ def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, backgro
|
|||
painter.drawText(width - rect.left() + 1, fontsize - 2, c) # fontsize-bottom+1 -17 / 7
|
||||
else:
|
||||
painter.drawText(width - rect.left(), fontsize - 1, c) # fontsize-bottom+1 -17 / 7
|
||||
width += getCharWidth(fontsize, metrics, i)
|
||||
if extraWidth:
|
||||
painter.drawImage(QtCore.QPoint(width, 0), extraImage)
|
||||
width += getCharWidth(c)
|
||||
|
||||
coords.append(width)
|
||||
painter.end()
|
||||
|
@ -90,8 +100,7 @@ def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, backgro
|
|||
if coordsfile:
|
||||
with open(filename + ".specs", "w") as f:
|
||||
f.write(",".join(str(tmp) for tmp in coords))
|
||||
for i in range(1, 14):
|
||||
f.write(", %d" % (int(coords[-1]) + i * (extraWidth / 12)))
|
||||
|
||||
return coords
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|