aboutsummaryrefslogtreecommitdiff
path: root/graphics/fonts
diff options
context:
space:
mode:
authorEugene Sandulenko2016-10-11 18:22:51 +0200
committerEugene Sandulenko2016-10-11 18:27:06 +0200
commit719bc03487ca27e98378f7f48f05ba9312cbd432 (patch)
tree6ebc8ad200812cadb09cfc7a58107ef6a9c505a7 /graphics/fonts
parentc118e2fe12b4ad50e77badd812ccc6d0e3cbd92a (diff)
downloadscummvm-rg350-719bc03487ca27e98378f7f48f05ba9312cbd432.tar.gz
scummvm-rg350-719bc03487ca27e98378f7f48f05ba9312cbd432.tar.bz2
scummvm-rg350-719bc03487ca27e98378f7f48f05ba9312cbd432.zip
GRAPHICS: Added stub for BDF font scaler
Diffstat (limited to 'graphics/fonts')
-rw-r--r--graphics/fonts/bdf.cpp57
-rw-r--r--graphics/fonts/bdf.h1
2 files changed, 58 insertions, 0 deletions
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index 9c5105d8b5..a783a22f5e 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -700,4 +700,61 @@ BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
return new BdfFont(data, DisposeAfterUse::YES);
}
+BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) {
+ if (src->getFontSize()) {
+ warning("Requested to scale 0 size font");
+ return NULL;
+ }
+
+ float scale = newSize / src->getFontSize();
+
+ BdfFontData data;
+
+ data.maxAdvance = src->_data.maxAdvance;
+ data.height = src->_data.height;
+ data.defaultBox.width = src->_data.defaultBox.width;
+ data.defaultBox.height = src->_data.defaultBox.height;
+ data.defaultBox.xOffset = src->_data.defaultBox.xOffset;
+ data.defaultBox.yOffset = src->_data.defaultBox.yOffset;
+ data.ascent = src->_data.ascent;
+ data.firstCharacter = src->_data.firstCharacter;
+ data.defaultCharacter = src->_data.defaultCharacter;
+ data.numCharacters = src->_data.numCharacters;
+
+ BdfBoundingBox *boxes = new BdfBoundingBox[data.numCharacters];
+ for (int i = 0; i < data.numCharacters; ++i) {
+ boxes[i].width = src->_data.boxes[i].width;
+ boxes[i].height = src->_data.boxes[i].height;
+ boxes[i].xOffset = src->_data.boxes[i].xOffset;
+ boxes[i].yOffset = src->_data.boxes[i].yOffset;
+ }
+
+ byte *advances = new byte[data.numCharacters];
+ for (int i = 0; i < data.numCharacters; ++i) {
+ advances[i] = src->_data.advances[i];
+ }
+
+ byte **bitmaps = new byte *[data.numCharacters];
+
+ for (int i = 0; i < data.numCharacters; ++i) {
+ const BdfBoundingBox &box = data.boxes ? data.boxes[i] : data.defaultBox;
+ if (src->_data.bitmaps[i]) {
+ const int bytes = ((box.width + 7) / 8) * box.height;
+ bitmaps[i] = new byte[bytes];
+
+ for (int j = 0; j < bytes; j++)
+ bitmaps[i][j] = src->_data.bitmaps[i][j];
+
+ } else {
+ bitmaps[i] = 0;
+ }
+ }
+
+ data.bitmaps = bitmaps;
+ data.advances = advances;
+ data.boxes = boxes;
+
+ return new BdfFont(data, DisposeAfterUse::YES);
+}
+
} // End of namespace Graphics
diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h
index 9a3b20e14c..d99b5fd401 100644
--- a/graphics/fonts/bdf.h
+++ b/graphics/fonts/bdf.h
@@ -76,6 +76,7 @@ public:
static BdfFont *loadFont(Common::SeekableReadStream &stream);
static bool cacheFontData(const BdfFont &font, const Common::String &filename);
static BdfFont *loadFromCache(Common::SeekableReadStream &stream);
+ static BdfFont *scaleFont(BdfFont *src, int newSize);
private:
int mapToIndex(uint32 ch) const;