| @@ -4,6 +4,23 @@ |
| 4 |
#include <libgen.h> |
4 |
#include <libgen.h> |
| 5 |
#include "raylib.h" |
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 |
int |
24 |
int |
| 8 |
main (int argc, char **argv) |
25 |
main (int argc, char **argv) |
| 9 |
{ |
26 |
{ |
| @@ -11,12 +28,20 @@ main (int argc, char **argv) |
| 11 |
const int width = 1280; |
28 |
const int width = 1280; |
| 12 |
const int height = 720; |
29 |
const int height = 720; |
| 13 |
|
30 |
|
|
|
31 |
+ |
| 14 |
InitWindow (width, height, "moosic palyer"); |
32 |
InitWindow (width, height, "moosic palyer"); |
| 15 |
SetTargetFPS (60); |
33 |
SetTargetFPS (60); |
| 16 |
InitAudioDevice (); |
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 |
Music song; |
45 |
Music song; |
| 21 |
char song_path[1024]; |
46 |
char song_path[1024]; |
| 22 |
if (argc > 1) |
47 |
if (argc > 1) |
| @@ -93,7 +118,7 @@ main (int argc, char **argv) |
| 93 |
char *filename = basename (path_copy); |
118 |
char *filename = basename (path_copy); |
| 94 |
|
119 |
|
| 95 |
const char *line1 = !IsMusicStreamPlaying (song) |
120 |
const char *line1 = !IsMusicStreamPlaying (song) |
| 96 |
- ? "paused :<" : TextFormat ("currently playing %s :D", filename); |
121 |
+ ? "paused :<" : TextFormat ("currently palying: %s :] ", filename); |
| 97 |
|
122 |
|
| 98 |
const char *line2 = TextFormat ("Volume: %.2f", vol); |
123 |
const char *line2 = TextFormat ("Volume: %.2f", vol); |
| 99 |
int tp = (int) time_played; |
124 |
int tp = (int) time_played; |
| @@ -102,7 +127,7 @@ main (int argc, char **argv) |
| 102 |
TextFormat ("%d:%02d / %d:%02d", tp / 60, tp % 60, tt / 60, tt % 60); |
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 |
float spacing = 1.0f; |
131 |
float spacing = 1.0f; |
| 107 |
float line_spacing = 35.0f; |
132 |
float line_spacing = 35.0f; |
| 108 |
|
133 |
|