From 12179037031484c3469fd5128a7028c1f520fba0 Mon Sep 17 00:00:00 2001 From: markmental Date: Sun, 29 Mar 2026 14:58:13 -0400 Subject: [PATCH] Bundle assets into the appimage build --- build-appimage.sh | 8 ++++++++ src/ui.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/build-appimage.sh b/build-appimage.sh index 1d11705..31b7128 100755 --- a/build-appimage.sh +++ b/build-appimage.sh @@ -33,6 +33,14 @@ mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps cp passport-c-media-player AppDir/usr/bin/ chmod +x AppDir/usr/bin/passport-c-media-player +# Copy bundled resources (font and logo for AppImage) +if [ -f "BigBlueTermPlusNerdFontMono-Regular.ttf" ]; then + cp BigBlueTermPlusNerdFontMono-Regular.ttf AppDir/usr/bin/ +fi +if [ -f "logo.png" ]; then + cp logo.png AppDir/usr/bin/ +fi + # Create desktop file directly in script (avoids copy conflicts) cat > AppDir/passport-c-media-player.desktop << 'EOF' [Desktop Entry] diff --git a/src/ui.c b/src/ui.c index b7d5416..a1e14c5 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,6 +1,7 @@ #include "ui.h" #include +#include #include #include @@ -1198,6 +1199,8 @@ void ui_render_theme_picker(SDL_Renderer *renderer, active_theme->panel_text); } +static char *get_exe_dir(void); + int ui_cache_init(UiCache *cache, SDL_Renderer *renderer, const UiFonts *fonts, const ChannelList *channels) { char buffer[256]; @@ -1227,7 +1230,19 @@ int ui_cache_init(UiCache *cache, SDL_Renderer *renderer, const UiFonts *fonts, return -1; } - cache->logo_texture = load_png_texture(renderer, "logo.png", NULL, NULL); + { + char *exe_dir = get_exe_dir(); + if (exe_dir) { + char logo_path[512]; + snprintf(logo_path, sizeof(logo_path), "%slogo.png", exe_dir); + cache->logo_texture = load_png_texture(renderer, logo_path, NULL, NULL); + SDL_free(exe_dir); + } + + if (!cache->logo_texture) { + cache->logo_texture = load_png_texture(renderer, "logo.png", NULL, NULL); + } + } if (channels && channels->count > 0) { cache->channels = calloc((size_t) channels->count, sizeof(UiChannelCache)); @@ -1302,12 +1317,36 @@ void ui_cache_destroy(UiCache *cache) { memset(cache, 0, sizeof(*cache)); } +static char *get_exe_dir(void) { + return SDL_GetBasePath(); +} + int ui_load_fonts(UiFonts *fonts) { + char *exe_dir; + if (!fonts) { return -1; } memset(fonts, 0, sizeof(*fonts)); + + exe_dir = get_exe_dir(); + if (exe_dir) { + char font_path[512]; + snprintf(font_path, sizeof(font_path), "%sBigBlueTermPlusNerdFontMono-Regular.ttf", exe_dir); + + fonts->small = TTF_OpenFont(font_path, 13); + fonts->medium = TTF_OpenFont(font_path, 17); + fonts->large = TTF_OpenFont(font_path, 22); + + SDL_free(exe_dir); + + if (fonts->small && fonts->medium && fonts->large) { + return 0; + } + ui_destroy_fonts(fonts); + } + for (size_t i = 0; i < sizeof(FONT_CANDIDATES) / sizeof(FONT_CANDIDATES[0]); ++i) { fonts->small = TTF_OpenFont(FONT_CANDIDATES[i], 13); fonts->medium = TTF_OpenFont(FONT_CANDIDATES[i], 17);