Skip to content

Commit

Permalink
remove the option if we have no scaling fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
MjnMixael committed Aug 28, 2024
1 parent ceed5be commit 0e614ea
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions code/graphics/software/FontManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "bmpman/bmpman.h"
#include "cfile/cfile.h"
#include "localization/localize.h"
#include "options/Option.h"

namespace font
{
Expand Down Expand Up @@ -84,6 +85,18 @@ namespace font
return -1;
}

bool FontManager::hasScalingFonts()
{
for (auto& font : fonts) {
const auto& thisFont = font.get();
if (thisFont->getType() == NVG_FONT && thisFont->getScaleBehavior()) {
return true;
}
}

return false;
}

int FontManager::numberOfFonts()
{
return (int)fonts.size();
Expand Down
5 changes: 5 additions & 0 deletions code/graphics/software/FontManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ namespace font {
*/
static int getFontIndex(FSFont *font);

/**
* @brief Checks if we have any Scaling TTF fonts loaded. If not it disables the font scaling option
*/
static bool hasScalingFonts();

/**
* @brief Returns the number of fonts currently saved in the manager
* @return The number of fonts
Expand Down
4 changes: 4 additions & 0 deletions code/graphics/software/NVGFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ static auto FontScaleFactor __UNUSED = options::OptionBuilder<float>("Game.FontS
.importance(55)
.finish();

void removeFontMultiplierOption() {
options::OptionsManager::instance()->removeOption(FontScaleFactor);
}

namespace
{
const char* const TOKEN_SEPARATORS = "\n\t\r";
Expand Down
2 changes: 2 additions & 0 deletions code/graphics/software/VFNTFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "globalincs/pstypes.h"
#include "graphics/software/FSFont.h"

void removeFontMultiplierOption();

namespace font
{
struct font;
Expand Down
5 changes: 5 additions & 0 deletions code/graphics/software/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ namespace
//Then other ones
parse_modular_table("*-fnt.tbm", parse_font_tbl);


if (!FontManager::hasScalingFonts()) {
removeFontMultiplierOption();
}

// double check
if (FontManager::numberOfFonts() < 3) {
Error(LOCATION, "At least three fonts have to be loaded but only %d valid entries were found!", FontManager::numberOfFonts());
Expand Down

0 comments on commit 0e614ea

Please sign in to comment.