Skip to content

Commit c4a5787

Browse files
authored
Merge pull request #279 from SumolX/fonts
New Fonts for Live View
2 parents bd4396f + 859d484 commit c4a5787

File tree

5 files changed

+1875
-1
lines changed

5 files changed

+1875
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ endif()
6363
# main application
6464
file(GLOB SRC_FILES_CORE "src/core/*.c" "src/core/*.h")
6565
file(GLOB SRC_FILES_DRIVER "src/driver/*.c" "src/driver/*.h")
66+
file(GLOB SRC_FILES_FONTS "src/fonts/*.c" "src/fonts/*.h")
6667
file(GLOB SRC_FILES_IMAGE "src/image/*.c" "src/image/*.h")
6768
file(GLOB SRC_FILES_UI "src/ui/*.c" "src/ui/*.h")
6869
file(GLOB SRC_FILES_BMI "src/bmi270/*.c" "src/bmi270/*.h")
@@ -73,6 +74,7 @@ file(GLOB SRC_FILES_EMULATOR "src/emulator/*.c" "src/emulator/*.h")
7374
set(SRC_FILES
7475
${SRC_FILES_CORE}
7576
${SRC_FILES_DRIVER}
77+
${SRC_FILES_FONTS}
7678
${SRC_FILES_IMAGE}
7779
${SRC_FILES_UI}
7880
${SRC_FILES_BMI}

src/core/osd.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include "ui/ui_image_setting.h"
3434
#include "ui/ui_porting.h"
3535

36+
extern const lv_font_t conthrax_26;
37+
extern const lv_font_t robotomono_26;
38+
3639
//////////////////////////////////////////////////////////////////
3740
// local
3841
static sem_t osd_semaphore;
@@ -284,7 +287,16 @@ static void osd_object_create_label(uint8_t fhd, lv_obj_t **obj, char *text, set
284287
osd_object_set_pos(fhd, *obj, pos);
285288

286289
lv_obj_set_style_text_color(*obj, lv_color_make(255, 255, 255), 0);
287-
lv_obj_set_style_text_font(*obj, &lv_font_montserrat_26, 0);
290+
291+
if (0 == strncmp(fc_variant, "ARDU", sizeof(fc_variant)) ||
292+
0 == strncmp(fc_variant, "BTFL", sizeof(fc_variant)) ||
293+
0 == strncmp(fc_variant, "INAV", sizeof(fc_variant))) {
294+
lv_obj_set_style_text_font(*obj, &conthrax_26, 0);
295+
} else if (0 == strncmp(fc_variant, "QUIC", sizeof(fc_variant))) {
296+
lv_obj_set_style_text_font(*obj, &robotomono_26, 0);
297+
} else {
298+
lv_obj_set_style_text_font(*obj, &lv_font_montserrat_26, 0);
299+
}
288300
}
289301

290302
void osd_show(bool show) {

src/fonts/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# LVGL's online converter
2+
Location: https://lvgl.io/tools/fontconverter
3+
4+
Requires a True Type Font in order to convert to source code
5+
6+
# Example
7+
QuickSilver OSD is based on Roboto Mono font family:
8+
9+
Symbols are included below, copy and paste them into the convertor.
10+
```
11+
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`-=[]\;',./~!@#$%^&*()_+{}|:"<> ?
12+
```
13+
![image](https://github.com/SumolX/hdzero-goggle/assets/1988793/3231174e-97b9-4a92-9948-f1d4d1ea3f84)
14+
15+
# Compiling
16+
17+
Simply click convert then add the newly downloaded source file to the font directory and regenerate cmake via setup.sh
18+
19+
In order to include the font in the HDZero Goggle Source code, you must forward declare the font source.
20+
```
21+
extern const lv_font_t conthrax_26;
22+
extern const lv_font_t robotomono_26;
23+
```

0 commit comments

Comments
 (0)