[Scummvm-git-logs] scummvm master -> bc343edb42ffcb6e86b14f9b3057aa51b9d959a4

lephilousophe noreply at scummvm.org
Sun Jan 29 12:19:10 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bc343edb42 GRAPHICS: Fix BDF font loading


Commit: bc343edb42ffcb6e86b14f9b3057aa51b9d959a4
    https://github.com/scummvm/scummvm/commit/bc343edb42ffcb6e86b14f9b3057aa51b9d959a4
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-01-29T13:18:54+01:00

Commit Message:
GRAPHICS: Fix BDF font loading

When the character is out of range, just go to the next character.

Changed paths:
    graphics/fonts/bdf.cpp


diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index 764c11b0c3a..5dec680742b 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -397,16 +397,16 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
 			byte *bitmap = loadCharacter(stream, encoding, advance, box);
 
 			// Ignore all characters above 255.
-			if (encoding < -1 || encoding >= font.numCharacters) {
+			if (encoding < 0 || encoding >= font.numCharacters) {
 				delete[] bitmap;
-				encoding = -1;
+				continue;
 			}
 
 			// Calculate the max advance
-			if (encoding != -1 && advance > font.maxAdvance)
+			if (advance > font.maxAdvance)
 				font.maxAdvance = advance;
 
-			if (!bitmap && encoding != -1) {
+			if (!bitmap) {
 				warning("BdfFont::loadFont: Character %d invalid", encoding);
 				freeBitmaps(bitmaps, font.numCharacters);
 				delete[] bitmaps;
@@ -417,11 +417,9 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
 				return 0;
 			}
 
-			if (encoding != -1) {
-				bitmaps[encoding] = bitmap;
-				advances[encoding] = advance;
-				boxes[encoding] = box;
-			}
+			bitmaps[encoding] = bitmap;
+			advances[encoding] = advance;
+			boxes[encoding] = box;
 		} else if (line.hasPrefix("FAMILY_NAME \"")) {
 			if (familyName != nullptr) {
 				warning("BdfFont::loadFont: Duplicated FAMILY_NAME");




More information about the Scummvm-git-logs mailing list