summaryrefslogtreecommitdiff
path: root/examples/ui.c
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-08-10 16:56:58 +0200
committerMitya Selivanov <automainint@guattari.tech>2024-08-10 16:56:58 +0200
commitbb0a5b8e004b03c487f4fb9ebba96ab56d968d4e (patch)
treec24e7235b9ce0f6088a0982aad76966d06e7b550 /examples/ui.c
parent495a816647304d5858347b3c030a6ffab0262dc4 (diff)
downloadreduced_system_layer-bb0a5b8e004b03c487f4fb9ebba96ab56d968d4e.zip
Update bit font
Diffstat (limited to 'examples/ui.c')
-rwxr-xr-xexamples/ui.c114
1 files changed, 51 insertions, 63 deletions
diff --git a/examples/ui.c b/examples/ui.c
index b66521c..32d694e 100755
--- a/examples/ui.c
+++ b/examples/ui.c
@@ -172,7 +172,7 @@ Platform platform = {0};
#include <math.h>
#include <assert.h>
-#define CHAR_NUM_BITS_X 4
+#define CHAR_NUM_BITS_X 6
#define CHAR_NUM_BITS_Y 7
u64 bitfont[] = {
@@ -198,6 +198,11 @@ void print_text(u32 color, i32 x, i32 y, f64 width, f64 height, i64 num_chars, c
continue;
}
+ if (text[n] <= ' ') {
+ dx += width;
+ continue;
+ }
+
i64 x0 = (i64) floor(dx + .5);
i64 y0 = (i64) floor(dy + .5);
i64 y1 = (i64) floor(dy + height + .5);
@@ -213,7 +218,7 @@ void print_text(u32 color, i32 x, i32 y, f64 width, f64 height, i64 num_chars, c
for (i64 j = y0; j < y1; ++j) {
i64 char_y = ((j - y0) * CHAR_NUM_BITS_Y) / (y1 - y0);
- i64 bit_index = text[n] * CHAR_NUM_BITS_X * CHAR_NUM_BITS_Y + char_y * CHAR_NUM_BITS_X + char_x;
+ i64 bit_index = (text[n] - 32) * CHAR_NUM_BITS_X * CHAR_NUM_BITS_Y + char_y * CHAR_NUM_BITS_X + char_x;
i64 qword_index = bit_index / 64;
if (qword_index >= (i64) (sizeof bitfont / sizeof *bitfont))
continue;
@@ -229,7 +234,7 @@ void print_text(u32 color, i32 x, i32 y, f64 width, f64 height, i64 num_chars, c
if (empty_col && char_x + 1 < CHAR_NUM_BITS_X)
for (i64 j = y; j < y1; ++j) {
i64 char_y = ((j - y) * CHAR_NUM_BITS_Y) / (y1 - y);
- i64 bit_index = text[n] * CHAR_NUM_BITS_X * CHAR_NUM_BITS_Y + char_y * CHAR_NUM_BITS_X + char_x + 1;
+ i64 bit_index = (text[n] - 32) * CHAR_NUM_BITS_X * CHAR_NUM_BITS_Y + char_y * CHAR_NUM_BITS_X + char_x + 1;
i64 qword_index = bit_index / 64;
if (qword_index >= (i64) (sizeof bitfont / sizeof *bitfont))
continue;
@@ -242,71 +247,54 @@ void print_text(u32 color, i32 x, i32 y, f64 width, f64 height, i64 num_chars, c
break;
}
- if (text[n] == ' ')
- dx += width;
- else
- dx += num_cols + width / CHAR_NUM_BITS_X;
+ dx += num_cols + width / CHAR_NUM_BITS_X;
}
}
i32 main(i32 argc, c8 **argv) {
c8 static data[] =
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " "
- " ! ' ' $$ % && ' ( ) * / "
- " ! ' ' # # $$ $% % & & ' ( ) *** / "
- " ! ####$$ % && ( ) *** + / "
- " ! # # $$ %%%%&& ( ) * +++ --- / "
- " # # $ $ % & & ( ) + / "
- " ! ####$$ $ % %& & ( ) , . / "
- " # # $$ % &&& ( ) , / "
- " ? "
- "000 11 222 333 4 4 555 66 777 888 999 < > ? ? "
- "0 0 1 2 3 4 4 5 6 7 8 8 9 9 : ; < === > ? "
- "0 0 1 2 3 444 555 666 7 888 999 < > ? "
- "0 0 1 2 3 4 5 6 6 7 8 8 9 < === > "
- "000 111 222 333 4 55 666 7 888 99 : ; < > ? "
- " ; "
- " @@ AA BBB CC DDD EEEEFFFF GG H HIII JJJ K KL M MN N OO "
- "@ @A AB BC CD DE F G GH H I J K K L MMMMNN NO O"
- "@ @@A ABBB C D DEEE FFF G HHHH I J KK L MMMMN NNO O"
- "@@ @AAAAB BC D DE F G GGH H I J K K L MMMMN NO O"
- "@ @@A AB BC CD DE F G GH H I J J K KL M MN NO O"
- "@ A ABBB CC DDD EEEEF GG H HIII J K KLLL M MN N OO "
- " @@ "
- "PPP QQ RRR SS TTT U UV V W WX XY YZZZZ[[ x ]] ^ "
- "P PQ QR RS T U UV V W WX XY Y Z[ x ] ^ ^ "
- "P PQ QR R SS T U UV V W W XX YY Z [ x ] "
- "PPP Q QRRR S T U UV V WWWW XX Y Z [ x ] "
- "P Q QR RS S T U UVVV WWWWX X Y Z [ x ] "
- "P QQ R R SS T UU V WW X X Y ZZZZ[ x ] "
- " Q [[ x ]] ____"
- "` l "
- " ` aa b cc d ee ff gg h i j k k l m mnnn oo "
- " abbb c c ddde e f g gh k k l mmmmn no o"
- " aaaab bc d deeeefff g ghhh ii jj kk l mmmmn no o"
- " a ab bc cd de f gggh h i j k k l mmmmn no o"
- " aa bbb cc ddd ee f gh hiii j k k l m mn n oo "
- " gg j "
- " { | } ~ ~ "
- "ppp qqqr r ss ttt u uv v w wx xy yzzzz { | } ~ ~ "
- "p pq qrr s t u uv v w wx xy y z { | } "
- "p pq qr ss t u uv v wwww xx yy zz { | } "
- "ppp qqqr s t u u v wwwwx x y z { | } "
- "p qr ss t uuu v ww x xy zzzz { | } "
- " { | } "
+ " ! ' ' $ % && ' ( ) * * / "
+ " ! ' ' # # $$$ % % & & ' ( ) ** + / "
+ " ! ##### $ $ % && ( ) ****** + / "
+ " ! # # $$$ %%%%% && ( ) ** +++++ ----- / "
+ " # # $ $ % & & ( ) * * + / "
+ " ! ##### $$$ % % & & ( ) + , . / "
+ " # # $ % &&& ( ) , / "
+ " ? "
+ "000 11 222 333 4 4 555 66 777 888 999 < > ? ? "
+ "0 0 1 2 3 4 4 5 6 7 8 8 9 9 : ; < ==== > ? "
+ "0 0 1 2 3 444 555 666 7 888 999 < > ? "
+ "0 0 1 2 3 4 5 6 6 7 8 8 9 < ==== > "
+ "000 111 222 333 4 55 666 7 888 99 : ; < > ? "
+ " ; "
+ " @@@ AA BBB CC DDD EEEE FFFF GG H H III JJJ K K L M M N N OO "
+ "@ @ A A B B C C D D E F G G H H I J K K L MM MM NN N O O "
+ "@ @@ A A BBB C D D EEE FFF G HHHH I J KK L MMMMM N N N O O "
+ "@ @ @ AAAA B B C D D E F G GG H H I J K K L M M M N NN O O "
+ "@ @@ A A B B C C D D E F G G H H I J J K K L M M N N O O "
+ "@ A A BBB CC DDD EEEE F GG H H III J K K LLL M M N N OO "
+ " @@@ "
+ "PPP QQ RRR SS TTTTT U U V V W W X X Y Y ZZZZ [[ x ]] ^ "
+ "P P Q Q R R S T U U V V W W X X Y Y Z [ x ] ^ ^ "
+ "P P Q Q R R SS T U U V V W W W X Y Y Z [ x ] ^ ^ "
+ "PPP Q Q RRR S T U U V V W W W X X Y Z [ x ] "
+ "P Q Q R R S S T U U V V WWWWW X X Y Z [ x ] "
+ "P QQ R R SS T UU V W W X X Y ZZZZ [ x ] "
+ " Q [[ x ]] ____ "
+ "` l "
+ " ` aa b cc d ee ff gg h i j k k l mmmm nnn oo "
+ " a bbb c c ddd e e f g g h k k l m m m n n o o "
+ " aaaa b b c d d eeee fff g g hhh ii jj kk l m m m n n o o "
+ " a a b b c c d d e f ggg h h i j k k l m m m n n o o "
+ " aa bbb cc ddd ee f g h h iii j k k l m m m n n oo "
+ " gg j "
+ " { | } ~~ ~ "
+ "ppp qqq r r ss ttt u u v v w w x x y y zzzz { | } ~ ~~ "
+ "p p q q rr s t u u v v w w x x y y z { | } "
+ "p p q q r ss t u u v v w w w x y zz { | } "
+ "ppp qqq r s t u u v v wwwww x x y z { | } "
+ "p q r ss t uuu v w w x x y zzzz { | } "
+ " { | } "
;
u64 bits[(16 * 8 * CHAR_NUM_BITS_X * CHAR_NUM_BITS_Y) / 64] = {0};