aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-10-06 07:44:18 +0200
committerEugene Sandulenko2016-10-06 07:44:18 +0200
commit9730e42fac5b7d0fd70939cddb6888a508f8056e (patch)
tree66e886e5549436666b88e7f2d8d2dde228a7444b
parent0d4d5459f27abaac7d41288583acc80b2a5ad9fb (diff)
downloadscummvm-rg350-9730e42fac5b7d0fd70939cddb6888a508f8056e.tar.gz
scummvm-rg350-9730e42fac5b7d0fd70939cddb6888a508f8056e.tar.bz2
scummvm-rg350-9730e42fac5b7d0fd70939cddb6888a508f8056e.zip
GRAPHICS: Parse font size from BDF fonts
-rw-r--r--devtools/convbdf.cpp10
-rw-r--r--graphics/fonts/bdf.cpp15
-rw-r--r--graphics/fonts/bdf.h2
-rw-r--r--graphics/fonts/consolefont.cpp3
-rw-r--r--graphics/fonts/newfont.cpp3
-rw-r--r--graphics/fonts/newfont_big.cpp3
6 files changed, 30 insertions, 6 deletions
diff --git a/devtools/convbdf.cpp b/devtools/convbdf.cpp
index b9ce5c7f5f..4a7545834a 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 c0a7b05d8b..79d31e5b9a 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 140b1f7f4e..bc1ced9599 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 4d66b09e80..9b1f5458fc 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 af68ca03b5..1ee3df4941 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 3f6866ac00..4c30141bcc 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