aboutsummaryrefslogtreecommitdiff
path: root/graphics/fonts
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/fonts')
-rw-r--r--graphics/fonts/bdf.cpp7
1 files changed, 5 insertions, 2 deletions
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--;