tsoding / olive.c

Simple 2D Graphics Library for C
https://tsoding.github.io/olive.c/
MIT License
1.86k stars 105 forks source link

Add a mostly complete 5x5 font. #20

Closed eloj closed 1 year ago

eloj commented 1 year ago

Added as a separate file in the 'fonts' directory, should be able to include it directly into the C source where appropriate.

I know he never merges any of these anyway -- but maybe someone else can find a use for it.

olive5x5_font_test

diff --git a/demos/dots3d.c b/demos/dots3d.c
index a240fac..7da0b9d 100644
--- a/demos/dots3d.c
+++ b/demos/dots3d.c
@@ -20,6 +20,8 @@ float cosf(float x);
 static uint32_t pixels[WIDTH*HEIGHT];
 static float angle = 0;

+#include "fonts/olivec_5x5_font.c"
+
 Olivec_Canvas vc_render(float dt)
 {
     angle += 0.25*PI*dt;
@@ -61,8 +63,9 @@ Olivec_Canvas vc_render(float dt)
         }
     }

-    size_t size = 8;
-    olivec_text(oc, "aboba", ABOBA_PADDING, HEIGHT - ABOBA_PADDING - olivec_default_font.height*size, olivec_default_font, size, 0xFFFFFFFF);
+    size_t size = 2;
+    olivec_text(oc, "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG, 0123456789", ABOBA_PADDING, HEIGHT - ABOBA_PADDING - olivec_5x5_font.height*size, olivec_5x5_font, size, 0xFFFFFFFF);
+    olivec_text(oc, "the quick brown fox jumps over the lazy dog, !\"#$%&/()[]\\", ABOBA_PADDING, HEIGHT - ABOBA_PADDING + (olivec_5x5_font.height*size) * 2, olivec_5x5_font, size, 0xFFFFFFFF);

     return oc;
 }