Files
fs2open.github.com/code/graphics/software/FSFont.cpp
T
Mike Nelson 06b0966580 Ttf font scaling option (#6330)
* Add option to set a font size multiplier for ttf fonts

* remove the option if we have no scaling fonts

* Clang the conquerer strikes again

* Update XSTRs

* clang

* Clarify comments
2024-11-27 18:50:35 +09:00

84 lines
1.4 KiB
C++

#include "graphics/software/FSFont.h"
namespace font
{
void FSFont::setScaleBehavior(bool scale)
{
this->canScale = scale;
}
void FSFont::setBottomOffset(float offset)
{
this->offsetBottom = offset;
}
void FSFont::setTopOffset(float offset)
{
this->offsetTop = offset;
}
void FSFont::setName(const SCP_string &newName)
{
this->name = newName;
}
void FSFont::setFilename(const SCP_string& newName)
{
this->filename = newName;
}
[[nodiscard]] bool FSFont::getScaleBehavior() const
{
return this->canScale;
}
float FSFont::getBottomOffset() const
{
return this->offsetBottom;
}
float FSFont::getTopOffset() const
{
return this->offsetTop;
}
float FSFont::getHeight() const
{
return _height;
}
const SCP_string &FSFont::getName() const
{
return this->name;
}
const SCP_string &FSFont::getFilename() const
{
return this->filename;
}
void FSFont::computeFontMetrics() {
_height = this->getTextHeight() + this->offsetTop + this->offsetBottom;
// By default the base line of the font is also the lowest point of the font
_ascender = _height;
_descender = 0.0f;
checkFontMetrics();
}
void FSFont::checkFontMetrics() {
if (_height <= 1.0f)
{
Warning(LOCATION, "The height of font %s has an invalid height of %f, must be greater than one!",
getName().c_str(), _height);
}
}
float FSFont::getAscender() {
return _ascender;
}
float FSFont::getDescender() {
return _descender;
}
}