Dear all,
 
I would like to create a face by calling FT_OpenFace with std::istream, but error 2 returns. Here are my codes.
 
 
unsigned long stream_load(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count) {
    std::ifstream* is = reinterpret_cast<std::ifstream*>(stream->descriptor.pointer);
    if (count == 0) return 0;
    is->read((char*)buffer, count);
    return is->gcount();
}

void stream_close(FT_Stream stream) {
    // Nothing to do
}

{

// ...

std::ifstream ifs;
ifs.open("C:\\WINDOWS\\Fonts\\arial.ttf", std::ios::in | std::ios::binary);
FT_StreamDesc desc;
desc.pointer = (void*)&ifs;

FT_StreamRec stream;
memset(&stream, 0, sizeof(FT_StreamRec));
stream.base = 0;
stream.size = 367112; // I dun't know how to get size from std::ifstream, i just view it in file properties
stream.pos = 0;
stream.descriptor = desc;
stream.read = stream_load;
stream.close = stream_close;

FT_Open_Args args;
memset(&args, 0, sizeof(FT_Open_Args));
args.flags = FT_OPEN_STREAM;
args.stream = &stream;
 
error = FT_Open_Face(library, &args, 0, &face);

// got error 2 ???

}

What is the error about? Anything I have missed? Sorry for the question if someone has asked this before.

Thank you for your attention.

Regards,

Patrick Cheung

 

_______________________________________________
Freetype mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to