diff options
author | Eugene Sandulenko | 2016-10-05 23:24:53 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-10-05 23:24:53 +0200 |
commit | 15e499772032ae050627e1558904f119815ec51f (patch) | |
tree | 64c0a244ea14ec94a2f4789d8a4d85006d617167 /graphics/fonts | |
parent | 3f30e2dd06dbdf0d12849a9850a21e84b60f2b6c (diff) | |
download | scummvm-rg350-15e499772032ae050627e1558904f119815ec51f.tar.gz scummvm-rg350-15e499772032ae050627e1558904f119815ec51f.tar.bz2 scummvm-rg350-15e499772032ae050627e1558904f119815ec51f.zip |
GRAPHICS: Load Face Name from BDF files
Also adjust the devtools and built-in fonts accordingly.
Diffstat (limited to 'graphics/fonts')
-rw-r--r-- | graphics/fonts/bdf.cpp | 30 | ||||
-rw-r--r-- | graphics/fonts/bdf.h | 4 | ||||
-rw-r--r-- | graphics/fonts/consolefont.cpp | 1 | ||||
-rw-r--r-- | graphics/fonts/newfont.cpp | 1 | ||||
-rw-r--r-- | graphics/fonts/newfont_big.cpp | 1 |
5 files changed, 37 insertions, 0 deletions
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp index 3476838911..59a4ddb24f 100644 --- a/graphics/fonts/bdf.cpp +++ b/graphics/fonts/bdf.cpp @@ -41,9 +41,14 @@ BdfFont::~BdfFont() { delete[] _data.bitmaps; delete[] _data.advances; delete[] _data.boxes; + delete[] _data.faceName; } } +const char *BdfFont::getFaceName() const { + return _data.faceName; +} + int BdfFont::getFontHeight() const { return _data.height; } @@ -285,6 +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; int descent = -1; @@ -310,6 +316,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { delete[] bitmaps; delete[] advances; delete[] boxes; + delete[] faceName; return 0; } @@ -324,6 +331,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { delete[] bitmaps; delete[] advances; delete[] boxes; + delete[] faceName; return 0; } } else if (line.hasPrefix("FONT_DESCENT ")) { @@ -333,6 +341,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { delete[] bitmaps; delete[] advances; delete[] boxes; + delete[] faceName; return 0; } } else if (line.hasPrefix("DEFAULT_CHAR ")) { @@ -342,6 +351,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { delete[] bitmaps; delete[] advances; delete[] boxes; + delete[] faceName; return 0; } } else if (line.hasPrefix("STARTCHAR ")) { @@ -366,6 +376,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { delete[] bitmaps; delete[] advances; delete[] boxes; + delete[] faceName; return 0; } @@ -374,6 +385,22 @@ 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 != '"') + p--; + if (p == faceName) { + warning("BdfFont::loadFont: Invalid FACE_NAME"); + freeBitmaps(bitmaps, font.numCharacters); + delete[] bitmaps; + delete[] advances; + delete[] boxes; + delete[] faceName; + return 0; + } + *p = '\0'; // Remove last quote } else if (line == "ENDFONT") { break; } @@ -385,6 +412,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { delete[] bitmaps; delete[] advances; delete[] boxes; + delete[] faceName; return 0; } @@ -393,6 +421,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { font.bitmaps = bitmaps; font.advances = advances; font.boxes = boxes; + font.faceName = faceName; int firstCharacter = font.numCharacters; int lastCharacter = -1; @@ -425,6 +454,7 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) { delete[] font.bitmaps; delete[] font.advances; delete[] font.boxes; + delete[] faceName; return 0; } diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h index b91834785f..4e3295ca5f 100644 --- a/graphics/fonts/bdf.h +++ b/graphics/fonts/bdf.h @@ -40,6 +40,8 @@ struct BdfBoundingBox { }; struct BdfFontData { + const char *faceName; + int maxAdvance; int height; BdfBoundingBox defaultBox; @@ -65,6 +67,8 @@ 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; + static BdfFont *loadFont(Common::SeekableReadStream &stream); static bool cacheFontData(const BdfFont &font, const Common::String &filename); static BdfFont *loadFromCache(Common::SeekableReadStream &stream); diff --git a/graphics/fonts/consolefont.cpp b/graphics/fonts/consolefont.cpp index 748aa08a5c..4d66b09e80 100644 --- a/graphics/fonts/consolefont.cpp +++ b/graphics/fonts/consolefont.cpp @@ -5850,6 +5850,7 @@ const byte *const bitmapTable[] = { // Font structure static const BdfFontData desc = { + "Fixed", // Face name 5, // Max advance 8, // Height { 5, 8, 0, -1 }, // Bounding box diff --git a/graphics/fonts/newfont.cpp b/graphics/fonts/newfont.cpp index 4922e24676..af68ca03b5 100644 --- a/graphics/fonts/newfont.cpp +++ b/graphics/fonts/newfont.cpp @@ -7634,6 +7634,7 @@ const byte *const bitmapTable[] = { // Font structure static const BdfFontData desc = { + "Schumacher", // Face name 6, // Max advance 12, // Height { 6, 12, 0, -3 }, // Bounding box diff --git a/graphics/fonts/newfont_big.cpp b/graphics/fonts/newfont_big.cpp index 550d6dbfa9..3f6866ac00 100644 --- a/graphics/fonts/newfont_big.cpp +++ b/graphics/fonts/newfont_big.cpp @@ -5829,6 +5829,7 @@ static const BdfBoundingBox boxes[] = { // Font structure static const BdfFontData desc = { + "Helvetica", // Face name 13, // Max advance 14, // Height { 13, 15, -1, -3 }, // Bounding box |