| 34 | } |
| 35 | |
| 36 | void* FontReadFile(const char* path, uint32_t* file_size) |
| 37 | { |
| 38 | FILE* file = fopen(path, "rb"); |
| 39 | if (!file) |
| 40 | { |
| 41 | printf("Failed to load %s\n", path); |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | fseek(file, 0, SEEK_END); |
| 46 | size_t size = (size_t)ftell(file); |
| 47 | fseek(file, 0, SEEK_SET); |
| 48 | |
| 49 | void* mem = malloc(size); |
| 50 | |
| 51 | size_t nread = fread(mem, 1, size, file); |
| 52 | fclose(file); |
| 53 | |
| 54 | if (nread != size) |
| 55 | { |
| 56 | printf("Failed to read %u bytes from %s\n", (uint32_t)size, path); |
| 57 | free(mem); |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | if (file_size) |
| 62 | *file_size = size; |
| 63 | |
| 64 | return mem; |
| 65 | } |
no test coverage detected