Fix freetype dependencies

This commit is contained in:
fvanroie 2022-09-03 17:40:43 +02:00
parent 4852b6f4c4
commit 7a8abec978
4 changed files with 21 additions and 19 deletions

6
.gitmodules vendored
View File

@ -1,4 +1,4 @@
#[submodule "lib/freetype"]
# path = lib/freetype
# url = https://github.com/fvanroie/freetype
[submodule "lib/freetype"]
path = lib/freetype
url = https://github.com/fvanroie/freetype

View File

@ -7,13 +7,14 @@
* INCLUDES
*********************/
#include <stdlib.h>
#include "ftstdlib.h"
#include "lv_fs_freetype.h"
/*********************
* DEFINES
*********************/
#if LV_USE_FS_IF
#include "lv_fs_if.h"
#include "lvgl.h"
/**********************
* TYPEDEFS
@ -36,7 +37,7 @@
**********************/
// FILE * fopen ( const char * filename, const char * mode );
lv_ft_stream_t* lv_ft_fopen(const char* filename, const char* mode)
hasp_FILE* lv_ft_fopen(const char* filename, const char* mode)
{
lv_fs_file_t* file_p = malloc(sizeof(lv_fs_file_t)); // reserve memory
@ -45,7 +46,7 @@ lv_ft_stream_t* lv_ft_fopen(const char* filename, const char* mode)
lv_fs_res_t res = lv_fs_open(file_p, filename, rw);
if(res == LV_FS_RES_OK) { // success
return (lv_ft_stream_t*)file_p;
return (hasp_FILE*)file_p;
} else { // error
free(file_p); // release memory
}
@ -55,7 +56,7 @@ lv_ft_stream_t* lv_ft_fopen(const char* filename, const char* mode)
}
// int fclose ( FILE * stream );
int lv_ft_fclose(lv_ft_stream_t* stream)
int lv_ft_fclose(hasp_FILE* stream)
{
lv_fs_file_t* f_ptr = (lv_fs_file_t*)stream;
@ -66,7 +67,7 @@ int lv_ft_fclose(lv_ft_stream_t* stream)
}
// size_t fread ( void * ptr, size_t size, size_t count, FILE * stream );
size_t lv_ft_fread(void* ptr, size_t size, size_t count, lv_ft_stream_t* stream)
size_t lv_ft_fread(void* ptr, size_t size, size_t count, hasp_FILE* stream)
{
lv_fs_file_t* f_ptr = (lv_fs_file_t*)stream;
uint32_t bytes_read;
@ -80,7 +81,7 @@ size_t lv_ft_fread(void* ptr, size_t size, size_t count, lv_ft_stream_t* stream)
}
// long int ftell ( FILE * stream );
int lv_ft_ftell(lv_ft_stream_t* stream)
int lv_ft_ftell(hasp_FILE* stream)
{
lv_fs_file_t* f_ptr = (lv_fs_file_t*)stream;
uint32_t pos;
@ -92,7 +93,7 @@ int lv_ft_ftell(lv_ft_stream_t* stream)
}
// int fseek ( FILE * stream, long int offset, int origin );
int lv_ft_fseek(lv_ft_stream_t* stream, long int offset, int origin)
int lv_ft_fseek(hasp_FILE* stream, long int offset, int origin)
{
lv_fs_file_t* f_ptr = (lv_fs_file_t*)stream;
uint32_t start = 0;

View File

@ -12,7 +12,7 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include "lv_fs_if.h"
#include "lvgl.h"
/*********************
* DEFINES
@ -22,7 +22,8 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
typedef void lv_ft_stream_t;
// typedef lv_fs_file_t lv_ft_stream_t;
typedef void hasp_FILE;
/**********************
* GLOBAL PROTOTYPES
@ -33,14 +34,14 @@ typedef void lv_ft_stream_t;
* @param mode "r" for read, "w" fro write.
* @return A file stream pointer on success, NULL on error.
*/
lv_ft_stream_t* lv_ft_fopen(const char* filename, const char* mode);
hasp_FILE* lv_ft_fopen(const char* filename, const char* mode);
/**
* fclose glue for freetype library to access lv_fs api
* @param stream The file stream to close.
* @return Always 0.
*/
int lv_ft_fclose(lv_ft_stream_t* stream);
int lv_ft_fclose(hasp_FILE* stream);
/**
* fread glue for freetype library to access lv_fs api
@ -50,7 +51,7 @@ int lv_ft_fclose(lv_ft_stream_t* stream);
* @param stream The file stream to read.
* @return The number of bytes read on success, otherwise 0.
*/
size_t lv_ft_fread(void* ptr, size_t size, size_t count, lv_ft_stream_t* stream);
size_t lv_ft_fread(void* ptr, size_t size, size_t count, hasp_FILE* stream);
/**
* fseek glue for freetype library to access lv_fs api
@ -59,14 +60,14 @@ size_t lv_ft_fread(void* ptr, size_t size, size_t count, lv_ft_stream_t* stream)
* @param origin The start position within the file, either SEEK_SET, SEEK_CUR or SEEK_END.
* @return 1 on success, otherwise 0.
*/
int lv_ft_fseek(lv_ft_stream_t* stream, long int offset, int origin);
int lv_ft_fseek(hasp_FILE* stream, long int offset, int origin);
/**
* ftell glue for freetype library to access lv_fs api
* @param stream The file stream to tell.
* @return The current file cursor position on success, otherwise -1.
*/
int lv_ft_ftell(lv_ft_stream_t* stream);
int lv_ft_ftell(hasp_FILE* stream);
#endif // LV_USE_FILESYSTEM

View File

@ -61,7 +61,7 @@ void filesystemUnzip(const char*, const char* filename, uint8_t source)
continue;
}
if(fh.filename_length >= 31) {
if(fh.filename_length >= 255) {
LOG_WARNING(TAG_FILE, F("filename length too long %d"), fh.filename_length);
zipfile.seek(fh.filename_length + fh.extra_length, SeekCur); // skip extra field
continue;
@ -69,7 +69,7 @@ void filesystemUnzip(const char*, const char* filename, uint8_t source)
// LOG_WARNING(TAG_FILE, F("min %d - flag %d - len %d - xtra %d"), fh.min_version, fh.flags,
// fh.filename_length, fh.extra_length);
}
char name[32] = {0};
char name[257] = {0};
name[0] = '/';
len = zipfile.read((uint8_t*)&name[1], fh.filename_length);