fordon_greeman / moosicpalyer

default to the system's monospace font Browse files
theidioticdev committed 13d ago parent 2e598c4 commit e6fd8b4dba0ab823d67ad626b749b74f7f1c04b7
Showing 4 changed files with 41 additions and 7 deletions. UnifiedSplit
+7 −4 GNUmakefile
@@ -1,10 +1,10 @@
1 -# CC = cc
2 -CC = tcc
1 +CC = cc
2 +# CC = tcc
3 3 CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -O2
4 4 INCLUDES = -Iraylib/include
5 5 LDFLAGS = -Lraylib -lraylib -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon -lGL -lm -lpthread -ldl -lX11
6 6 TARGET = moosicpalyer
7 -PREFIX ?= /usr/local/bin
7 +PREFIX ?= /usr/local/
8 8
9 9 all: $(TARGET)
10 10
@@ -14,5 +14,8 @@ $(TARGET): main.c
14 14 clean:
15 15 rm -f $(TARGET)
16 16
17 +PREFIX ?= /usr/local
18 +
17 19 install: $(TARGET)
18 - install -Dm755 $(TARGET) $(PREFIX)/$(TARGET)
20 + install -Dm755 $(TARGET) $(PREFIX)/bin/$(TARGET)
21 + install -Dm644 moosicpalyer.desktop $(PREFIX)/share/applications/moosicpalyer.desktop
+28 −3 main.c
@@ -4,6 +4,23 @@
4 4 #include <libgen.h>
5 5 #include "raylib.h"
6 6
7 +static void
8 +get_system_font (char *dest, size_t max_len)
9 +{
10 + snprintf( dest, max_len, "resources/IBMPlexSans-Bold.ttf");
11 +
12 + FILE *f = popen("fc-match -f '%{file}' monospace", "r");
13 + if (f != NULL)
14 + {
15 + if (fgets (dest, max_len, f) != NULL)
16 + {
17 + dest[strcspn (dest, "\r\n")] = 0;
18 + }
19 + pclose (f);
20 + }
21 +}
22 +
23 +
7 24 int
8 25 main (int argc, char **argv)
9 26 {
@@ -11,12 +28,20 @@ main (int argc, char **argv)
11 28 const int width = 1280;
12 29 const int height = 720;
13 30
31 +
14 32 InitWindow (width, height, "moosic palyer");
15 33 SetTargetFPS (60);
16 34 InitAudioDevice ();
35 + char font_path[512];
36 + get_system_font (font_path, sizeof (font_path));
17 37
18 - Font font = LoadFont ("resources/IBMPlexSans-Bold.ttf");
38 + Font font = LoadFont (font_path);
19 39
40 + if (font.texture.id == 0)
41 + {
42 + TraceLog (LOG_WARNING, "Failed to load font");
43 + }
44 +
20 45 Music song;
21 46 char song_path[1024];
22 47 if (argc > 1)
@@ -93,7 +118,7 @@ main (int argc, char **argv)
93 118 char *filename = basename (path_copy);
94 119
95 120 const char *line1 = !IsMusicStreamPlaying (song)
96 - ? "paused :<" : TextFormat ("currently playing %s :D", filename);
121 + ? "paused :<" : TextFormat ("currently palying: %s :] ", filename);
97 122
98 123 const char *line2 = TextFormat ("Volume: %.2f", vol);
99 124 int tp = (int) time_played;
@@ -102,7 +127,7 @@ main (int argc, char **argv)
102 127 TextFormat ("%d:%02d / %d:%02d", tp / 60, tp % 60, tt / 60, tt % 60);
103 128
104 129
105 - int font_size = 32;
130 + int font_size = 24;
106 131 float spacing = 1.0f;
107 132 float line_spacing = 35.0f;
108 133
+0 −0 moosicpalyer deleted file mode 100755, Binary files a/moosicpalyer and /dev/null differ
+6 −0 moosicpalyer.desktop new file mode 100644
@@ -0,0 +1,6 @@
1 +[Desktop Entry]
2 +Name=Moosic Palyer
3 +Comment=Raylib-based music player
4 +Exec=moosicpalyer
5 +Terminal=False
6 +Type=Application