Skip to content

Commit

Permalink
Switch to using PNG fonts, add support for more font pages (#138)
Browse files Browse the repository at this point in the history
* add libspng 0.7.3

* working PNG support

* cleanup

* split font code into own file

* add font converter

* swap to PNG fonts

* swap ipk to contain png

* builds

* Fix comparison error

* bump version for testing

* Rework font loading:

- No longer require whitelist of fonts; take FC identifier and use that directly. Avoids needing to release a version to support a new FC; users could put fonts on an SD and away they go.
- Also, to support the above - fall back to default font variant if no FC specific variant found (previously impossible as we bundled a font for all supported FCs)
- Support fallback to bf as a font name; betaflight uses BTFL as it's identifier; we used bf in it's font filenames previously

* debugs

* convert quicksilver font

* Switch to sneaky europa and switch to preferred font names (fc identifier for bf/ultra - btfl/ultr)

* Add fallback for ultra

* Fix comparisons

* reorder font loading - /blackbox before the bundled fonts; means you can put fonts (via adb push) into /blackbox and then not need to worry about putting them on SD

* font convert debugging + load order amend so BTFL/ULTR fallback works

* Fix infinite reloading of fonts caused by lowercasing the FC variant

* Fix debug

* latest ver of sneakyfpv fonts

* update ardu and generic font

* revert accidental gtar

* revise fonts section in readme

* Remove -dev from version ahead of release

---------

Co-authored-by: bri3d <[email protected]>
  • Loading branch information
benlumley and bri3d authored May 10, 2024
1 parent acbfec9 commit f23bb25
Show file tree
Hide file tree
Showing 47 changed files with 7,954 additions and 246 deletions.
10 changes: 5 additions & 5 deletions Makefile.dji
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ LIB_SHIMS = libshims/libduml_hal.so

#this doesn't work by default
#an extra duss_result_t(frame_pop_handler)
#is generated that the compiler doesn't like
#is generated that the compiler doesn't like
libshims/%.c: %.h
stubgen -g -e .c -l -N -t libshims -p "../" -n $<

libshims/lib%.so: libshims/%.c
$(CC) -Wno-c2x-extensions -O2 -shared -Wl,-soname,libduml_hal.so -o $@ $< $(CFLAGS)

libshims: $(LIB_SHIMS)

all: jni/*
ndk-build
ndk-build

install: all
install -d ipk/goggle/build/data/opt/fonts/
install fonts/*.bin ipk/goggle/build/data/opt/fonts/
install fonts/*.png ipk/goggle/build/data/opt/fonts/
install -d ipk/goggle/build/data/opt/mspdictionaries/
install dictionaries/*.bin ipk/goggle/build/data/opt/mspdictionaries/
install -d ipk/goggle/build/data/opt/etc/preload.d/
Expand Down Expand Up @@ -69,7 +69,7 @@ repo: ipk
cp ipk/*.ipk repo/
../opkg-utils-0.5.0/opkg-make-index ./repo/ > repo/Packages
http-server -p 8042 ./repo/

clean:
rm -rf **/*.o
rm -rf *.o
Expand Down
45 changes: 14 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ A diagram to help...

Visit https://fpv.wtf/package/fpv-wtf/msp-osd with your goggles connected, and check "Fake HD"

Optionally, place custom fonts in the root of your sd card, using the names `font_bf_hd.bin` / `font_bf_hd_2.bin` (NB: FakeHD no longer uses font_hd.bin / font_hd_2.bin)
Optionally, place custom fonts in the root of your sd card, using the names `font_bf_hd.png`

Configuration of the grid is also possible; see below.

Expand Down Expand Up @@ -220,53 +220,36 @@ Configure the UART under Digital VTX - see https://docs.bosshobby.com/Configurin

## Fonts

We bundle in default fonts for the flight controller variants we support. [Preview images are available here](docs/fonts). Or you can use a custom one...
We bundle in default fonts for Betaflight, Ardupilot, INAV, Quicksilver, and KISS ULTRA (font is SNEAKYFPV's Europa - thanks to SNEAKYFPV for allowing us to use these - https://sites.google.com/view/sneaky-fpv/home). Since 0.12 we use a PNG font format, the same as Walksnail. [Default fonts can be viewed here](fonts). You may also upload your own fonts to the SD card.

* Download a font package. See below for known community fonts.
* Rename the files for your desired font to `font_<fc variant>` - see table below for examples or take a look at the `fonts` directory for a template for how the file names should look. (If your FC firmware is not listed below, use the generic filenames)
* Place these four files on the root of your Goggles SD card.
* Rename the files for your desired font to `font_<fc variant>.png` - see table below for examples or take a look at the `fonts` directory for a template for how the file names should look. (If your FC firmware is not listed below, use the generic filenames)
* Place these two PNG files on the root of your Goggles SD card.
* Reboot.

### FC Specific Font File Names

| Flight controller | SD | HD |
| ----------------- | -- | -- |
| Betaflight | `font_bf.bin`, `font_bf_2.bin` | `font_bf_hd.bin`, `font_bf_hd_2.bin` |
| INAV | `font_inav.bin`, `font_inav_2.bin` | `font_inav_hd.bin`, `font_inav_hd_2.bin`|
| Ardupilot | `font_ardu.bin`, `font_ardu_2.bin` | `font_ardu_hd.bin`, `font_ardu_hd_2.bin`|
| KISS Ultra | `font_ultra.bin`, `font_ultra_2.bin` | `font_ultra_hd.bin`, `font_ultra_hd_2.bin`|
| QUICKSILVER | `font_quic.bin`, `font_quic_2.bin` | `font_quic_hd.bin`, `font_quic_hd_2.bin`|
| Generic/Fallback | `font.bin`, `font_2.bin` | `font_hd.bin`, `font_hd_2.bin`|
| Betaflight | `font_btfl.png` | `font_btfl_hd.png` |
| INAV | `font_inav.png` | `font_inav_hd.png`|
| Ardupilot | `font_ardu.png` | `font_ardu_hd.png`|
| KISS Ultra | `font_ultr.png` | `font_ulta_hd.png`|
| QUICKSILVER | `font_quic.png` | `font_quic_hd.png`|
| Generic/Fallback | `font.png` | `font_hd.png`|

VTx (AU/Vista) which have not had their msp-osd upgraded, as well as flight controllers which do not respond to the Variant request, like old Ardupilot versions, will fall back to the Generic/Fallback font.
Airside VTx (AU/Vista) which have a very old version of msp-osd on, as well as flight controllers which do not respond to the Variant request, like old Ardupilot versions, will fall back to the Generic/Fallback font.

You can also add fonts for firmwares not in this list; using the generic filename, or put the MSP identifier in (lower case it) the filename - ```font_<fc_variant>.png / font_<fc_variant>_hd.png```

### Suggested Third Party Fonts

- [KNIFA's Material](https://github.com/Knifa/material-osd/releases)
- [KNIFA's Material](https://github.com/Knifa/material-osd/releases) - use the Walksnail version for MSP-OSD >= 0.12
- [SNEAKY_FPV's colour fonts for INAV, ARDU and BF](https://sites.google.com/view/sneaky-fpv/home)
- [VICEWIZE Italic](https://github.com/vicewize/vicewizeosdfontset)
- [Kw0ngk4n's Neue OSD](https://github.com/Kw0ngk4n/WTF-Neue-OSD)
- [EVilm1's OSD Font](https://github.com/EVilm1/EVilm1-OSD-Font)

### Generate your own Font from an analog font (advanced)

* Download [mcm2img](https://github.com/bri3d/mcm2img) and set up a working Python environment to run it.

* Locate the font you'd like to install - it will be a `.mcm` file, in the source code repository or configurator for your Flight Controller.

* For Betaflight: https://github.com/betaflight/betaflight-configurator/tree/master/resources/osd/2
* For INAV: https://github.com/iNavFlight/inav-configurator/blob/master/resources/osd/
* For Ardupilot: https://github.com/ArduPilot/ardupilot/tree/master/libraries/AP_OSD/fonts

* Run `python3 mcm2img.py mcmfile.mcm font RGBA 255 255 255`

* Place the 4 files this makes (font.bin, font_2.bin, font_hd.bin, font_hd_2.bin) on the root of the SD card in the goggles.

* Reboot

You can customize the font color by changing the 255 255 255 RGB values.

Useful tool for working with fonts: https://github.com/shellixyz/hd_fpv_osd_font_tool

## Modify / Move original DJI OSD elements

Expand Down
Binary file removed fonts/font.bin
Binary file not shown.
Binary file added fonts/font.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 removed fonts/font_ardu.bin
Binary file not shown.
Binary file added fonts/font_ardu.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 removed fonts/font_ardu_2.bin
Binary file not shown.
Binary file removed fonts/font_ardu_hd.bin
Binary file not shown.
Binary file added fonts/font_ardu_hd.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 removed fonts/font_ardu_hd_2.bin
Binary file not shown.
Binary file removed fonts/font_bf_hd.bin
Binary file not shown.
Binary file added fonts/font_btfl.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 added fonts/font_btfl_hd.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 removed fonts/font_hd.bin
Binary file not shown.
Binary file added fonts/font_hd.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 removed fonts/font_inav.bin
Binary file not shown.
Binary file added fonts/font_inav.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 removed fonts/font_inav_2.bin
Binary file not shown.
Binary file removed fonts/font_inav_hd.bin
Binary file not shown.
Binary file added fonts/font_inav_hd.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 removed fonts/font_inav_hd_2.bin
Binary file not shown.
Binary file removed fonts/font_quic.bin
Binary file not shown.
Binary file added fonts/font_quic.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 removed fonts/font_quic_2.bin
Binary file not shown.
Binary file removed fonts/font_quic_hd.bin
Binary file not shown.
Binary file added fonts/font_quic_hd.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 removed fonts/font_quic_hd_2.bin
Binary file not shown.
Binary file added fonts/font_ultr.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 added fonts/font_ultr_hd.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 removed fonts/font_ultra.bin
Binary file not shown.
Binary file removed fonts/font_ultra_2.bin
Binary file not shown.
Binary file removed fonts/font_ultra_hd.bin
Binary file not shown.
Binary file removed fonts/font_ultra_hd_2.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion ipk/goggle/control/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: msp-osd
Version: 0.11.1
Version: 0.12.0
Maintainer: bri3d
Description: MSP OSD service for the DJI HD FPV goggles.
Architecture: pigeon-glasses
Expand Down
6 changes: 4 additions & 2 deletions jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ include $(CLEAR_VARS)

LOCAL_CFLAGS += -fPIC -std=c99 -O3
LOCAL_LDFLAGS += -fPIC
LOCAL_LDLIBS := -llog
LOCAL_LDLIBS := -llog -lz
LOCAL_ARM_NEON := true
LOCAL_MODULE := displayport_osd_shim
LOCAL_SHARED_LIBRARIES := duml_hal
LOCAL_SRC_FILES := \
displayport_osd_shim.c \
fakehd/fakehd.c \
font/font.c \
hw/dji_display.c \
hw/dji_radio_shm.c \
hw/dji_services.c \
Expand All @@ -31,7 +32,8 @@ LOCAL_SRC_FILES := \
rec/rec_util.c \
rec/rec.c \
toast/toast.c \
util/fs_util.c
util/fs_util.c \
libspng/spng.c
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
Expand Down
Loading

0 comments on commit f23bb25

Please sign in to comment.