Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf_font_win32_compat.c
| Show All 34 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_fileops.h" | #include "BLI_fileops.h" | ||||
| #include "blf_internal.h" | #include "blf_internal.h" | ||||
| #include "CLG_log.h" | |||||
| static CLG_LogRef LOG = {"blf.i18n"}; | |||||
| /* internal freetype defines */ | /* internal freetype defines */ | ||||
| #define STREAM_FILE(stream) ((FILE *)stream->descriptor.pointer) | #define STREAM_FILE(stream) ((FILE *)stream->descriptor.pointer) | ||||
| #define FT_THROW(e) -1 | #define FT_THROW(e) -1 | ||||
| static void ft_ansi_stream_close( | static void ft_ansi_stream_close( | ||||
| FT_Stream stream) | FT_Stream stream) | ||||
| { | { | ||||
| fclose(STREAM_FILE(stream)); | fclose(STREAM_FILE(stream)); | ||||
| Show All 34 Lines | static FT_Error FT_Stream_Open__win32_compat(FT_Stream stream, const char *filepathname) | ||||
| stream->pathname.pointer = (char *)filepathname; | stream->pathname.pointer = (char *)filepathname; | ||||
| stream->base = 0; | stream->base = 0; | ||||
| stream->pos = 0; | stream->pos = 0; | ||||
| stream->read = NULL; | stream->read = NULL; | ||||
| stream->close = NULL; | stream->close = NULL; | ||||
| file = BLI_fopen(filepathname, "rb"); | file = BLI_fopen(filepathname, "rb"); | ||||
| if (!file) { | if (!file) { | ||||
| fprintf(stderr, | CLOG_ERROR(&LOG, "could not open `%s'", filepathname); | ||||
| "FT_Stream_Open: " | |||||
| "could not open `%s'\n", filepathname); | |||||
| return FT_THROW(Cannot_Open_Resource); | return FT_THROW(Cannot_Open_Resource); | ||||
| } | } | ||||
| fseek(file, 0, SEEK_END); | fseek(file, 0, SEEK_END); | ||||
| stream->size = ftell(file); | stream->size = ftell(file); | ||||
| if (!stream->size) { | if (!stream->size) { | ||||
| fprintf(stderr, | CLOG_ERROR(&LOG, "opened `%s' but zero-sized", filepathname); | ||||
| "FT_Stream_Open: " | |||||
| "opened `%s' but zero-sized\n", filepathname); | |||||
| fclose(file); | fclose(file); | ||||
| return FT_THROW(Cannot_Open_Stream); | return FT_THROW(Cannot_Open_Stream); | ||||
| } | } | ||||
| fseek(file, 0, SEEK_SET); | fseek(file, 0, SEEK_SET); | ||||
| stream->descriptor.pointer = file; | stream->descriptor.pointer = file; | ||||
| stream->read = ft_ansi_stream_io; | stream->read = ft_ansi_stream_io; | ||||
| Show All 33 Lines | |||||