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

criezy criezy at scummvm.org
Tue Mar 23 20:25:26 UTC 2021


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:
a3f3d71c57 GRAPHICS: Expose ascent value in font class


Commit: a3f3d71c57d14b2d26613d04b5a879f92d60cfc1
    https://github.com/scummvm/scummvm/commit/a3f3d71c57d14b2d26613d04b5a879f92d60cfc1
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-23T20:25:23Z

Commit Message:
GRAPHICS: Expose ascent value in font class

Changed paths:
    graphics/font.cpp
    graphics/font.h
    graphics/fonts/bdf.cpp
    graphics/fonts/bdf.h
    graphics/fonts/macfont.h
    graphics/fonts/ttf.cpp
    graphics/fonts/winfont.cpp
    graphics/fonts/winfont.h


diff --git a/graphics/font.cpp b/graphics/font.cpp
index 92be7b41a5..dbc6ec4e55 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -28,6 +28,10 @@
 
 namespace Graphics {
 
+int Font::getFontAscent() const {
+	return -1;
+}
+
 int Font::getKerningOffset(uint32 left, uint32 right) const {
 	return 0;
 }
diff --git a/graphics/font.h b/graphics/font.h
index 0b44ed40b4..e8008cac42 100644
--- a/graphics/font.h
+++ b/graphics/font.h
@@ -92,6 +92,14 @@ public:
 	 */
 	virtual int getFontHeight() const = 0;
 
+	/**
+	 * Return the ascent of the font.
+	 *
+	 * @return Font ascent in pixels. If it is unknown
+	 * a value of -1 is returned.
+	 */
+	virtual int getFontAscent() const;
+
 	/**
 	 * Return the maximum width of the font.
 	 *
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index fc91d3f8ab..6e587f63cf 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -58,6 +58,10 @@ int BdfFont::getFontHeight() const {
 	return _data.height;
 }
 
+int BdfFont::getFontAscent() const {
+	return _data.ascent;
+}
+
 int BdfFont::getFontSize() const {
 	return _data.size;
 }
diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h
index c903d52c55..8f2e78fd2e 100644
--- a/graphics/fonts/bdf.h
+++ b/graphics/fonts/bdf.h
@@ -64,6 +64,7 @@ public:
 	~BdfFont();
 
 	virtual int getFontHeight() const;
+	virtual int getFontAscent() const;
 	virtual int getMaxCharWidth() const;
 
 	virtual int getCharWidth(uint32 chr) const;
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index bf8cd318e2..7f9367ec30 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -150,6 +150,7 @@ public:
 	virtual ~MacFONTFont();
 
 	virtual int getFontHeight() const { return _data._fRectHeight; }
+	virtual int getFontAscent() const { return _data._ascent; }
 	virtual int getMaxCharWidth() const { return _data._maxWidth; }
 	virtual int getCharWidth(uint32 chr) const;
 	virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 1066b28338..02a72343a3 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -149,6 +149,8 @@ public:
 
 	virtual int getFontHeight() const;
 
+	virtual int getFontAscent() const;
+
 	virtual int getMaxCharWidth() const;
 
 	virtual int getCharWidth(uint32 chr) const;
@@ -526,6 +528,10 @@ int TTFFont::getFontHeight() const {
 	return _height;
 }
 
+int TTFFont::getFontAscent() const {
+	return _ascent;
+}
+
 int TTFFont::getMaxCharWidth() const {
 	return _width;
 }
diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp
index ad5b36ec23..b02323ec82 100644
--- a/graphics/fonts/winfont.cpp
+++ b/graphics/fonts/winfont.cpp
@@ -183,7 +183,7 @@ bool WinFont::loadFromFNT(Common::SeekableReadStream &stream) {
 	/* uint16 points = */ stream.readUint16LE();
 	/* uint16 vertRes = */ stream.readUint16LE();
 	/* uint16 horizRes = */ stream.readUint16LE();
-	/* uint16 ascent = */ stream.readUint16LE();
+	_ascent = stream.readUint16LE();
 	/* uint16 internalLeading = */ stream.readUint16LE();
 	/* uint16 externalLeading = */ stream.readUint16LE();
 	/* byte italic = */ stream.readByte();
diff --git a/graphics/fonts/winfont.h b/graphics/fonts/winfont.h
index 386a620508..a30c59bbc6 100644
--- a/graphics/fonts/winfont.h
+++ b/graphics/fonts/winfont.h
@@ -63,6 +63,7 @@ public:
 
 	// Font API
 	int getFontHeight() const { return _pixHeight; }
+	int getFontAscent() const { return _ascent; }
 	int getMaxCharWidth() const { return _maxWidth; }
 	int getCharWidth(uint32 chr) const;
 	void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
@@ -77,6 +78,7 @@ private:
 
 	uint16 _pixHeight;
 	uint16 _maxWidth;
+	uint16 _ascent;
 	byte _firstChar;
 	byte _lastChar;
 	byte _defaultChar;




More information about the Scummvm-git-logs mailing list