From 672d216d113abcc11d3be1b0c76d2c251cfd8357 Mon Sep 17 00:00:00 2001 From: Thanasis Antoniou Date: Tue, 12 Mar 2019 00:39:02 +0200 Subject: GUI: Fix loading new (not already cached) localized fonts --- graphics/fonts/bdf.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'graphics/fonts/bdf.cpp') diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp index 8424e00303..4374c36ff4 100644 --- a/graphics/fonts/bdf.cpp +++ b/graphics/fonts/bdf.cpp @@ -203,6 +203,9 @@ byte *loadCharacter(Common::SeekableReadStream &stream, int &encoding, int &adva while (true) { line = stream.readLine(); + line.trim(); // BDF files created from unifont tools (make hex) + // have a rogue space character after the "BITMAP" label + if (stream.err() || stream.eos()) { warning("BdfFont::loadCharacter: Premature end of file"); delete[] bitmap; @@ -412,7 +415,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { } } else if (line.hasPrefix("FAMILY_NAME \"")) { familyName = new char[line.size()]; - Common::strlcpy(familyName, line.c_str() + 13, line.size() - 13); + Common::strlcpy(familyName, line.c_str() + 13, line.size() - 12); // strlcpy() copies at most size-1 characters and then add a '\0' char *p = &familyName[strlen(familyName)]; while (p != familyName && *p != '"') p--; @@ -429,7 +432,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { *p = '\0'; // Remove last quote } else if (line.hasPrefix("SLANT \"")) { slant = new char[line.size()]; - Common::strlcpy(slant, line.c_str() + 7, line.size() - 7); + Common::strlcpy(slant, line.c_str() + 7, line.size() - 6); // strlcpy() copies at most size-1 characters and then add a '\0' char *p = &slant[strlen(slant)]; while (p != slant && *p != '"') p--; -- cgit v1.2.3