From Olaf Flebbe, "FlightGear/OSG on Windows did not load the Texture Fonts.

1) TXF Fonts are binary.
2) Do not rely on the result of istream::readsome if buffer _is_ empty
and no data have been read before."
This commit is contained in:
Robert Osfield 2007-05-21 08:01:45 +00:00
parent d2aefbc09a
commit 94b3a63e0c
2 changed files with 2 additions and 2 deletions

View File

@ -39,7 +39,7 @@ class ReaderWriterTXF : public osgDB::ReaderWriter
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream stream; std::ifstream stream;
stream.open(fileName.c_str(), std::ios::in); stream.open(fileName.c_str(), std::ios::in | std::ios::binary);
if (!stream.is_open()) return ReadResult::FILE_NOT_FOUND; if (!stream.is_open()) return ReadResult::FILE_NOT_FOUND;
TXFFont* impl = new TXFFont(fileName); TXFFont* impl = new TXFFont(fileName);

View File

@ -136,7 +136,7 @@ bool
TXFFont::loadFont(std::istream& stream) TXFFont::loadFont(std::istream& stream)
{ {
unsigned char magic[4]; unsigned char magic[4];
stream.readsome(reinterpret_cast<std::istream::char_type*>(&magic), 4); stream.read(reinterpret_cast<std::istream::char_type*>(&magic), 4);
if (magic[0] != 0xFF || magic[1] != 't' || magic[2] != 'x' || magic[3] != 'f' ) if (magic[0] != 0xFF || magic[1] != 't' || magic[2] != 'x' || magic[3] != 'f' )
{ {