1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Read scaling filter for fonts from config

This commit is contained in:
Ivan Savenko 2024-09-02 22:08:19 +00:00
parent 35467039a7
commit 0acc22214b
2 changed files with 17 additions and 4 deletions

View File

@ -16,13 +16,14 @@
#include "../render/Colors.h"
#include "../render/IScreenHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/Rect.h"
#include "../../lib/VCMI_Lib.h"
#include "../../lib/filesystem/Filesystem.h"
#include "../../lib/modding/CModHandler.h"
#include "../../lib/texts/Languages.h"
#include "../../lib/texts/TextOperations.h"
#include "../../lib/vcmi_endian.h"
#include "../../lib/VCMI_Lib.h"
#include <SDL_surface.h>
#include <SDL_image.h>
@ -200,9 +201,15 @@ CBitmapFont::CBitmapFont(const std::string & filename):
if (GH.screenHandler().getScalingFactor() != 1)
{
// scale using nearest neighbour - looks way better with H3 fonts than more high-quality xBRZ
// TODO: make configurable?
auto scaledSurface = CSDL_Ext::scaleSurfaceIntegerFactor(atlasImage, GH.screenHandler().getScalingFactor(), EScalingAlgorithm::NEAREST);
static const std::map<std::string, EScalingAlgorithm> filterNameToEnum = {
{ "nearest", EScalingAlgorithm::NEAREST},
{ "bilinear", EScalingAlgorithm::BILINEAR},
{ "xbrz", EScalingAlgorithm::XBRZ}
};
auto filterName = settings["video"]["fontUpscalingFilter"].String();
EScalingAlgorithm algorithm = filterNameToEnum.at(filterName);
auto scaledSurface = CSDL_Ext::scaleSurfaceIntegerFactor(atlasImage, GH.screenHandler().getScalingFactor(), algorithm);
SDL_FreeSurface(atlasImage);
atlasImage = scaledSurface;
}

View File

@ -167,6 +167,7 @@
"targetfps",
"vsync",
"upscalingFilter",
"fontUpscalingFilter",
"downscalingFilter"
],
"properties" : {
@ -231,6 +232,11 @@
"type" : "boolean",
"default" : true
},
"fontUpscalingFilter" : {
"type" : "string",
"enum" : [ "nearest", "bilinear", "xbrz" ],
"default" : "nearest"
},
"upscalingFilter" : {
"type" : "string",
"enum" : [ "auto", "none", "xbrz2", "xbrz3", "xbrz4" ],