mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Read scaling filter for fonts from config
This commit is contained in:
parent
35467039a7
commit
0acc22214b
@ -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;
|
||||
}
|
||||
|
@ -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" ],
|
||||
|
Loading…
Reference in New Issue
Block a user