aboutsummaryrefslogtreecommitdiff
path: root/graphics/fonts
diff options
context:
space:
mode:
authorThanasis Antoniou2019-03-12 00:39:02 +0200
committerThanasis Antoniou2019-03-12 00:42:58 +0200
commit672d216d113abcc11d3be1b0c76d2c251cfd8357 (patch)
tree671657edc596d451e969b5e9ecfb6e69ccb15cfb /graphics/fonts
parent1e6720b8be6c80cfb9177fdcdca7c032be0e869c (diff)
downloadscummvm-rg350-672d216d113abcc11d3be1b0c76d2c251cfd8357.tar.gz
scummvm-rg350-672d216d113abcc11d3be1b0c76d2c251cfd8357.tar.bz2
scummvm-rg350-672d216d113abcc11d3be1b0c76d2c251cfd8357.zip
GUI: Fix loading new (not already cached) localized fonts
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--;