From d337a98321d611749cfcf23b21f49084fe8731ca Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Thu, 21 Jul 2011 20:37:46 +0200 Subject: [PATCH] Fixed a minor bug in Font::LoadFromStream --- src/SFML/Graphics/Font.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 651fa87b..3563091b 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -46,9 +46,15 @@ namespace unsigned long Read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count) { sf::InputStream* stream = static_cast(rec->descriptor.pointer); - if (stream->Seek(offset) != offset) - return count ? 1 : 0; // error code is 0 if we're reading, or nonzero if we're seeking - return static_cast(stream->Read(reinterpret_cast(buffer), count)); + if (stream->Seek(offset) == offset) + { + if (count > 0) + return static_cast(stream->Read(reinterpret_cast(buffer), count)); + else + return 0; + } + else + return count > 0 ? 0 : 1; // error code is 0 if we're reading, or nonzero if we're seeking } void Close(FT_Stream) {