Skip to content

Commit

Permalink
Keep trying font pokery.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Dec 12, 2024
1 parent d02076f commit 259f825
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
31 changes: 18 additions & 13 deletions src/fileio.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
#include "af-file-io.h"
#include "ff.h"
#include "stdint.h"
#include "string.h"
#include "stdio.h"
#include <stdlib.h>

void* fileio_open(const char* filename) {
FIL *fil = new FIL();
FRESULT fr = f_open((FIL*)fil, filename, FA_READ);
(void)fr;
return (void *)fil;
printf("IMPL: Opening %s\n", filename);
FIL *fil = (FIL*)malloc(sizeof(FIL));
FRESULT fr = f_open(fil, filename, FA_READ);
if(fr == FR_OK) {
return (void *)fil;
} else {
free(fil);
return NULL;
}
}

void fileio_close(void* fhandle) {
f_close((FIL*)fhandle);
free(fhandle);
}

size_t fileio_read(void* fhandle, void *buf, size_t len) {
unsigned int bytes_read;
FRESULT fr = f_read((FIL*)fhandle, buf, len, &bytes_read);
(void)fr;
return bytes_read;
return fr == FR_OK ? bytes_read : 0;
}

int fileio_getc(void* fhandle) {
unsigned int bytes_read;
char c;
FRESULT fr = f_read((FIL*)fhandle, (void*)&c, 1, &bytes_read);
(void)fr;
(void)bytes_read;
return c;
unsigned char buf;
(void *)fileio_read(fhandle, (void*)&buf, (size_t)1);
return (int)buf;
}

size_t fileio_tell(void* fhandle) {
Expand All @@ -35,5 +40,5 @@ size_t fileio_tell(void* fhandle) {

size_t fileio_seek(void* fhandle, size_t pos) {
f_lseek((FIL*)fhandle, pos);
return pos;
return f_tell((FIL*)fhandle);
}
9 changes: 7 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ int main() {
printf("Init: OK\n");

printf("Font: ...");
vector->set_font("/marker-high.af", 30);
printf("Font: OK\n");
if(vector->set_font("/marker-high.af", 30)) {
printf("Font: OK\n");
} else {
printf("Font: Fail!\n");
}

sleep_ms(1000);

pp_mat3_t t = pp_mat3_identity();
pp_mat3_translate(&t, 50, 50);
Expand Down

0 comments on commit 259f825

Please sign in to comment.