GRAPHICS: Expose Font leading and descent values

The leading value in Macintosh fonts is the space between lines,
defined as the space between a descent line and the ascent line
below it. Clients need this to draw text and calculate its height
as classic Macintosh did.
This commit is contained in:
sluicebox 2022-11-04 17:29:36 -07:00
parent 2775987cba
commit b578f5be7b
3 changed files with 28 additions and 0 deletions

View File

@ -31,6 +31,14 @@ int Font::getFontAscent() const {
return -1;
}
int Font::getFontDescent() const {
return -1;
}
int Font::getFontLeading() const {
return -1;
}
int Font::getKerningOffset(uint32 left, uint32 right) const {
return 0;
}

View File

@ -104,6 +104,24 @@ public:
*/
virtual int getFontAscent() const;
/**
* Return the descent of the font.
*
* @return Font descent in pixels. If it is unknown
* a value of -1 is returned.
*/
virtual int getFontDescent() const;
/**
* Return the leading of the font.
* This is the distance between the descent line
* and the ascent line below it.
*
* @return Font leading in pixels. If it is unknown
* a value of -1 is returned.
*/
virtual int getFontLeading() const;
/**
* Return the maximum width of the font.
*

View File

@ -170,6 +170,8 @@ public:
virtual int getFontHeight() const { return _data._fRectHeight; }
virtual int getFontAscent() const { return _data._ascent; }
virtual int getFontDescent() const { return _data._descent; }
virtual int getFontLeading() const { return _data._leading; }
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;