18# include FT_FREETYPE_H
28# define STREAM_FILE(stream) static_cast<FILE *>(stream->descriptor.pointer)
29# define FT_THROW(e) -1
33static void ft_ansi_stream_close(FT_Stream stream)
35 fclose(STREAM_FILE(stream));
37 stream->descriptor.pointer =
nullptr;
49 if (!count && offset > stream->size) {
53 FILE *file = STREAM_FILE(stream);
55 if (stream->pos != offset) {
59 return fread(buffer, 1, count, file);
62static FT_Error FT_Stream_Open__win32_compat(FT_Stream stream,
const char *filepathname)
66 stream->descriptor.pointer =
nullptr;
67 stream->pathname.pointer = (
char *)filepathname;
70 stream->read =
nullptr;
71 stream->close =
nullptr;
73 FILE *file =
BLI_fopen(filepathname,
"rb");
77 "could not open '%s'\n",
79 return FT_THROW(Cannot_Open_Resource);
83 stream->size = ftell(file);
87 "opened '%s' but zero-sized\n",
90 return FT_THROW(Cannot_Open_Stream);
95 stream->descriptor.pointer = file;
96 stream->read = ft_ansi_stream_io;
97 stream->close = ft_ansi_stream_close;
102FT_Error FT_New_Face__win32_compat(FT_Library
library,
103 const char *pathname,
109 FT_Stream stream =
static_cast<FT_Stream
>(
MEM_new_zeroed(
sizeof(*stream), __func__));
111 open.flags = FT_OPEN_STREAM;
112 open.stream = stream;
114 stream->pathname.pointer = (
void *)pathname;
116 err = FT_Stream_Open__win32_compat(stream, pathname);
122 err = FT_Open_Face(
library, &open, face_index, aface);
File and directory operations.
Read Blender memory allocation and freeing.
void * MEM_new_zeroed(size_t len, const char *str)
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_fseek(FILE *stream, int64_t offset, int whence)