A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

checkwps: Validate all fonts in themes

Makes sure any fonts specified are either:

* Present in the theme itself
* One of the fonts in the Rockbox bundle

Change-Id: I215132835e2ae7faa06662637bc867df9c5dba92

+39 -9
-8
tools/Makefile
··· 67 67 ipod_fw: ipod_fw.c 68 68 $(SILENT)$(CC) $(CFLAGS) $+ -o $@ 69 69 70 - checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c \ 71 - ../firmware/common/ctype.c ../apps/misc.c ../apps/recorder/bmp.c 72 - $(SILENT)$(CC) $(CFLAGS) -I ../apps/gui -I../firmware/export \ 73 - -D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR \ 74 - -D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" -I../apps \ 75 - -I../firmware/target/arm/ipod -I../firmware/include $+ -o $@ 76 - 77 70 convbdf: convbdf.c 78 71 $(SILENT)$(CC) $(CFLAGS) $+ -o $@ 79 72 ··· 106 99 echo $$f.exe $$f.o $$f.obj ; done) *.ajf *~ 107 100 $(SILENT)$(MAKE) -C ucl clean 108 101 $(SILENT)$(MAKE) -C rbspeex clean 109 -
+31
tools/checkwps/checkwps.c
··· 226 226 } 227 227 #endif 228 228 229 + #include "fontbundle.h" 230 + 229 231 static int loaded_fonts = 0; 230 232 static struct font _font; 231 233 int font_load(const char *path) 232 234 { 235 + /* First see if it exists in the theme */ 236 + int fd = open(path, O_RDONLY); 237 + if (fd < 0) { 238 + char buf[1024]; 239 + sprintf(buf, ".rockbox/%s", path); 240 + fd = open(buf, O_RDONLY); 241 + if (fd < 0) { 242 + char *first = strrchr(buf, '/'); 243 + char *final = strrchr(buf, '.'); 244 + *final = 0; 245 + int missing = 1; 246 + /* Check if font is included in the bundle */ 247 + for (int i = 0 ; bundledfonts[i] != NULL ; i++) { 248 + if (!strcmp(first+1, bundledfonts[i])) { 249 + missing = 0; 250 + break; 251 + } 252 + } 253 + if (missing) { 254 + //printf("Font missing >%s<\n", first+1); 255 + return -1; 256 + } else { 257 + printf("INFO: Theme requires rockbox font bundle\n"); 258 + } 259 + } 260 + } 261 + if (fd >= 0) 262 + close(fd); 263 + 233 264 int id = 2 + loaded_fonts; 234 265 loaded_fonts++; 235 266 return id;
+7
tools/checkwps/checkwps.make
··· 40 40 $(SILENT)$(HOSTCC) -o $@ $+ $(INCLUDE) $(GCCOPTS) \ 41 41 -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) 42 42 43 + $(BUILDDIR)/fontbundle.h: $(ROOTDIR)/fonts/*bdf 44 + @echo FONTBUNDLE 45 + $(SILENT)echo "static unsigned char* bundledfonts[] = {" > $@ 46 + $(SILENT)ls $(ROOTDIR)/fonts/*bdf | perl -pne 's|.*/(\d+-.*)\.bdf| "$$1",|;' >> $@ 47 + $(SILENT)echo " NULL, " >> $@ 48 + $(SILENT)echo "};" >> $@ 49 + 43 50 #### Everything below is hacked in from apps.make and lang.make 44 51 45 52 $(BUILDDIR)/apps/features: $(ROOTDIR)/apps/features.txt
+1 -1
tools/root.make
··· 226 226 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \ 227 227 make.dep rombox.elf rombox.map rombox.bin romstart.txt \ 228 228 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \ 229 - rockbox.apk lang_enum.h rbversion.h 229 + rockbox.apk lang_enum.h rbversion.h fontbundle.h 230 230 231 231 #### linking the binaries: #### 232 232