[Scummvm-git-logs] scummvm master -> 9730e42fac5b7d0fd70939cddb6888a508f8056e
sev-
sev at scummvm.org
Thu Oct 6 11:19:11 CEST 2016
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0d4d5459f2 GRAPHICS: Use Family name instead of font name when reading from BDF fonts
9730e42fac GRAPHICS: Parse font size from BDF fonts
Commit: 0d4d5459f27abaac7d41288583acc80b2a5ad9fb
https://github.com/scummvm/scummvm/commit/0d4d5459f27abaac7d41288583acc80b2a5ad9fb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-10-06T07:33:46+02:00
Commit Message:
GRAPHICS: Use Family name instead of font name when reading from BDF fonts
Changed paths:
devtools/convbdf.cpp
graphics/fonts/bdf.cpp
graphics/fonts/bdf.h
graphics/macgui/macwindowmanager.cpp
diff --git a/devtools/convbdf.cpp b/devtools/convbdf.cpp
index c849076..b9ce5c7 100644
--- a/devtools/convbdf.cpp
+++ b/devtools/convbdf.cpp
@@ -38,7 +38,7 @@ struct BdfBoundingBox {
};
struct BdfFont {
- char *faceName;
+ char *familyName;
int maxAdvance;
int height;
BdfBoundingBox defaultBox;
@@ -63,7 +63,7 @@ struct BdfFont {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
}
};
@@ -162,12 +162,12 @@ int main(int argc, char *argv[]) {
font.advances = new unsigned char[font.numCharacters];
font.boxes = new BdfBoundingBox[font.numCharacters];
} else if (hasPrefix(line, "FACE_NAME \"")) {
- font.faceName = new char[line.size()]; // We will definitely fit here
- strncpy(font.faceName, &line.c_str()[11], line.size() - 1);
- char *p = &font.faceName[strlen(font.faceName)];
- while (p != font.faceName && *p != '"')
+ font.familyName = new char[line.size()]; // We will definitely fit here
+ strncpy(font.familyName, &line.c_str()[11], line.size() - 1);
+ char *p = &font.familyName[strlen(font.familyName)];
+ while (p != font.familyName && *p != '"')
p--;
- if (p == font.faceName)
+ if (p == font.familyName)
error("Invalid FACE_NAME");
*p = '\0'; // Remove last quote
} else if (hasPrefix(line, "FONT_ASCENT ")) {
@@ -503,7 +503,7 @@ int main(int argc, char *argv[]) {
"\t%d, // Characters\n"
"\n"
"\tbitmapTable, // Bitmaps\n",
- font.faceName, font.maxAdvance, font.height, font.defaultBox.width,
+ font.familyName, font.maxAdvance, font.height, font.defaultBox.width,
font.defaultBox.height, font.defaultBox.xOffset, font.defaultBox.yOffset,
font.ascent, font.firstCharacter, font.defaultCharacter, font.numCharacters);
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index 59a4ddb..c0a7b05 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -41,12 +41,12 @@ BdfFont::~BdfFont() {
delete[] _data.bitmaps;
delete[] _data.advances;
delete[] _data.boxes;
- delete[] _data.faceName;
+ delete[] _data.familyName;
}
}
-const char *BdfFont::getFaceName() const {
- return _data.faceName;
+const char *BdfFont::getFamilyName() const {
+ return _data.familyName;
}
int BdfFont::getFontHeight() const {
@@ -290,7 +290,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
memset(bitmaps, 0, sizeof(byte *) * font.numCharacters);
byte *advances = new byte[font.numCharacters];
BdfBoundingBox *boxes = new BdfBoundingBox[font.numCharacters];
- char *faceName;
+ char *familyName;
int descent = -1;
@@ -316,7 +316,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
@@ -331,7 +331,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
} else if (line.hasPrefix("FONT_DESCENT ")) {
@@ -341,7 +341,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
} else if (line.hasPrefix("DEFAULT_CHAR ")) {
@@ -351,7 +351,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
} else if (line.hasPrefix("STARTCHAR ")) {
@@ -376,7 +376,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
@@ -385,19 +385,19 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
advances[encoding] = advance;
boxes[encoding] = box;
}
- } else if (line.hasPrefix("FACE_NAME \"")) {
- faceName = new char[line.size()]; // We will definitely fit here
- Common::strlcpy(faceName, &line.c_str()[11], line.size());
- char *p = &faceName[strlen(faceName)];
- while (p != faceName && *p != '"')
+ } else if (line.hasPrefix("FAMILY_NAME \"")) {
+ familyName = new char[line.size()]; // We will definitely fit here
+ Common::strlcpy(familyName, &line.c_str()[11], line.size());
+ char *p = &familyName[strlen(familyName)];
+ while (p != familyName && *p != '"')
p--;
- if (p == faceName) {
- warning("BdfFont::loadFont: Invalid FACE_NAME");
+ if (p == familyName) {
+ warning("BdfFont::loadFont: Invalid FAMILY_NAME");
freeBitmaps(bitmaps, font.numCharacters);
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
*p = '\0'; // Remove last quote
@@ -412,7 +412,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
@@ -421,7 +421,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
font.bitmaps = bitmaps;
font.advances = advances;
font.boxes = boxes;
- font.faceName = faceName;
+ font.familyName = familyName;
int firstCharacter = font.numCharacters;
int lastCharacter = -1;
@@ -454,7 +454,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
delete[] font.bitmaps;
delete[] font.advances;
delete[] font.boxes;
- delete[] faceName;
+ delete[] familyName;
return 0;
}
diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h
index 4e3295c..140b1f7 100644
--- a/graphics/fonts/bdf.h
+++ b/graphics/fonts/bdf.h
@@ -40,7 +40,7 @@ struct BdfBoundingBox {
};
struct BdfFontData {
- const char *faceName;
+ const char *familyName;
int maxAdvance;
int height;
@@ -67,7 +67,7 @@ public:
virtual int getCharWidth(uint32 chr) const;
virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
- const char *getFaceName() const;
+ const char *getFamilyName() const;
static BdfFont *loadFont(Common::SeekableReadStream &stream);
static bool cacheFontData(const BdfFont &font, const Common::String &filename);
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index f0f821d..a685466 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -348,8 +348,8 @@ void MacWindowManager::loadFonts() {
delete stream;
Common::String fontName;
- if (font->getFaceName() && *font->getFaceName()) {
- fontName = font->getFaceName();
+ if (font->getFamilyName() && *font->getFamilyName()) {
+ fontName = font->getFamilyName();
} else { // Get it from the file name
fontName = (*it)->getName();
Commit: 9730e42fac5b7d0fd70939cddb6888a508f8056e
https://github.com/scummvm/scummvm/commit/9730e42fac5b7d0fd70939cddb6888a508f8056e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-10-06T07:44:18+02:00
Commit Message:
GRAPHICS: Parse font size from BDF fonts
Changed paths:
devtools/convbdf.cpp
graphics/fonts/bdf.cpp
graphics/fonts/bdf.h
graphics/fonts/consolefont.cpp
graphics/fonts/newfont.cpp
graphics/fonts/newfont_big.cpp
diff --git a/devtools/convbdf.cpp b/devtools/convbdf.cpp
index b9ce5c7..4a75458 100644
--- a/devtools/convbdf.cpp
+++ b/devtools/convbdf.cpp
@@ -40,6 +40,7 @@ struct BdfBoundingBox {
struct BdfFont {
char *familyName;
int maxAdvance;
+ int size;
int height;
BdfBoundingBox defaultBox;
int ascent;
@@ -140,7 +141,9 @@ int main(int argc, char *argv[]) {
error("Premature end of file");
if (hasPrefix(line, "SIZE ")) {
- // Ignore
+ int hDpi, vDpi;
+ if (sscanf(line.c_str(), "SIZE %d %d %d", &font.size, &hDpi, &vDpi) != 3)
+ error("Invalid SIZE");
} else if (hasPrefix(line, "FONT ")) {
fontName = line.substr(5);
} else if (hasPrefix(line, "COPYRIGHT ")) {
@@ -492,8 +495,9 @@ int main(int argc, char *argv[]) {
printf("// Font structure\n"
"static const BdfFontData desc = {\n"
- "\"%s\", // Face name\n"
+ "\t\"%s\", // Family name\n"
"\t%d, // Max advance\n"
+ "\t%d, // Size\n"
"\t%d, // Height\n"
"\t{ %d, %d, %d, %d }, // Bounding box\n"
"\t%d, // Ascent\n"
@@ -503,7 +507,7 @@ int main(int argc, char *argv[]) {
"\t%d, // Characters\n"
"\n"
"\tbitmapTable, // Bitmaps\n",
- font.familyName, font.maxAdvance, font.height, font.defaultBox.width,
+ font.familyName, font.maxAdvance, font.size, font.height, font.defaultBox.width,
font.defaultBox.height, font.defaultBox.xOffset, font.defaultBox.yOffset,
font.ascent, font.firstCharacter, font.defaultCharacter, font.numCharacters);
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index c0a7b05..79d31e5 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -53,6 +53,10 @@ int BdfFont::getFontHeight() const {
return _data.height;
}
+int BdfFont::getFontSize() const {
+ return _data.size;
+}
+
int BdfFont::getMaxCharWidth() const {
return _data.maxAdvance;
}
@@ -324,6 +328,17 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
font.defaultBox.height = height;
font.defaultBox.xOffset = xOffset;
font.defaultBox.yOffset = yOffset;
+ } else if (line.hasPrefix("SIZE ")) {
+ int hDpi, vDpi;
+ if (sscanf(line.c_str(), "SIZE %d %d %d", &font.size, &hDpi, &vDpi) != 3) {
+ warning("BdfFont::loadFont: Invalid SIZE");
+ freeBitmaps(bitmaps, font.numCharacters);
+ delete[] bitmaps;
+ delete[] advances;
+ delete[] boxes;
+ delete[] familyName;
+ return 0;
+ }
} else if (line.hasPrefix("FONT_ASCENT ")) {
if (sscanf(line.c_str(), "FONT_ASCENT %d", &font.ascent) != 1) {
warning("BdfFont::loadFont: Invalid FONT_ASCENT");
diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h
index 140b1f7..bc1ced9 100644
--- a/graphics/fonts/bdf.h
+++ b/graphics/fonts/bdf.h
@@ -44,6 +44,7 @@ struct BdfFontData {
int maxAdvance;
int height;
+ int size;
BdfBoundingBox defaultBox;
int ascent;
@@ -68,6 +69,7 @@ public:
virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
const char *getFamilyName() const;
+ int getFontSize() const;
static BdfFont *loadFont(Common::SeekableReadStream &stream);
static bool cacheFontData(const BdfFont &font, const Common::String &filename);
diff --git a/graphics/fonts/consolefont.cpp b/graphics/fonts/consolefont.cpp
index 4d66b09..9b1f545 100644
--- a/graphics/fonts/consolefont.cpp
+++ b/graphics/fonts/consolefont.cpp
@@ -5850,8 +5850,9 @@ const byte *const bitmapTable[] = {
// Font structure
static const BdfFontData desc = {
- "Fixed", // Face name
+ "Fixed", // Family name
5, // Max advance
+ 8, // Size
8, // Height
{ 5, 8, 0, -1 }, // Bounding box
7, // Ascent
diff --git a/graphics/fonts/newfont.cpp b/graphics/fonts/newfont.cpp
index af68ca0..1ee3df4 100644
--- a/graphics/fonts/newfont.cpp
+++ b/graphics/fonts/newfont.cpp
@@ -7634,8 +7634,9 @@ const byte *const bitmapTable[] = {
// Font structure
static const BdfFontData desc = {
- "Schumacher", // Face name
+ "Schumacher", // Family name
6, // Max advance
+ 12, // Size
12, // Height
{ 6, 12, 0, -3 }, // Bounding box
9, // Ascent
diff --git a/graphics/fonts/newfont_big.cpp b/graphics/fonts/newfont_big.cpp
index 3f6866a..4c30141 100644
--- a/graphics/fonts/newfont_big.cpp
+++ b/graphics/fonts/newfont_big.cpp
@@ -5829,8 +5829,9 @@ static const BdfBoundingBox boxes[] = {
// Font structure
static const BdfFontData desc = {
- "Helvetica", // Face name
+ "Helvetica", // Family name
13, // Max advance
+ 12, // Size
14, // Height
{ 13, 15, -1, -3 }, // Bounding box
11, // Ascent
More information about the Scummvm-git-logs
mailing list