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
This commit is contained in:
Solomon Peachy 2025-10-27 07:31:19 -04:00
parent b47d0ef3cf
commit 3f43fe3cd8
4 changed files with 39 additions and 9 deletions

View file

@ -67,13 +67,6 @@ lngdump: lngdump.c
ipod_fw: ipod_fw.c
$(SILENT)$(CC) $(CFLAGS) $+ -o $@
checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c \
../firmware/common/ctype.c ../apps/misc.c ../apps/recorder/bmp.c
$(SILENT)$(CC) $(CFLAGS) -I ../apps/gui -I../firmware/export \
-D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR \
-D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" -I../apps \
-I../firmware/target/arm/ipod -I../firmware/include $+ -o $@
convbdf: convbdf.c
$(SILENT)$(CC) $(CFLAGS) $+ -o $@
@ -106,4 +99,3 @@ clean:
echo $$f.exe $$f.o $$f.obj ; done) *.ajf *~
$(SILENT)$(MAKE) -C ucl clean
$(SILENT)$(MAKE) -C rbspeex clean

View file

@ -226,10 +226,41 @@ bool radio_hardware_present(void)
}
#endif
#include "fontbundle.h"
static int loaded_fonts = 0;
static struct font _font;
int font_load(const char *path)
{
/* First see if it exists in the theme */
int fd = open(path, O_RDONLY);
if (fd < 0) {
char buf[1024];
sprintf(buf, ".rockbox/%s", path);
fd = open(buf, O_RDONLY);
if (fd < 0) {
char *first = strrchr(buf, '/');
char *final = strrchr(buf, '.');
*final = 0;
int missing = 1;
/* Check if font is included in the bundle */
for (int i = 0 ; bundledfonts[i] != NULL ; i++) {
if (!strcmp(first+1, bundledfonts[i])) {
missing = 0;
break;
}
}
if (missing) {
//printf("Font missing >%s<\n", first+1);
return -1;
} else {
printf("INFO: Theme requires rockbox font bundle\n");
}
}
}
if (fd >= 0)
close(fd);
int id = 2 + loaded_fonts;
loaded_fonts++;
return id;

View file

@ -40,6 +40,13 @@ $(BUILDDIR)/$(BINARY): $$(CHECKWPS_OBJ) $$(CORE_LIBS)
$(SILENT)$(HOSTCC) -o $@ $+ $(INCLUDE) $(GCCOPTS) \
-L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS))
$(BUILDDIR)/fontbundle.h: $(ROOTDIR)/fonts/*bdf
@echo FONTBUNDLE
$(SILENT)echo "static unsigned char* bundledfonts[] = {" > $@
$(SILENT)ls $(ROOTDIR)/fonts/*bdf | perl -pne 's|.*/(\d+-.*)\.bdf| "$$1",|;' >> $@
$(SILENT)echo " NULL, " >> $@
$(SILENT)echo "};" >> $@
#### Everything below is hacked in from apps.make and lang.make
$(BUILDDIR)/apps/features: $(ROOTDIR)/apps/features.txt

View file

@ -226,7 +226,7 @@ clean::
$(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
make.dep rombox.elf rombox.map rombox.bin romstart.txt \
$(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \
rockbox.apk lang_enum.h rbversion.h
rockbox.apk lang_enum.h rbversion.h fontbundle.h
#### linking the binaries: ####