slight font directives changes

invalid font directives stopped checkerboarding the glyph texture at some point, fixed that too
This commit is contained in:
Kae 2024-04-24 16:29:51 +10:00
parent f58702683f
commit 6f7e2bbb83
5 changed files with 29 additions and 21 deletions

View File

@ -6,9 +6,9 @@
},
"nametag" : {
"showMasterNames" : true,
// border is double here as it otherwise fades out near the end
// outline is double here as it otherwise fades out near the end
// (could just the end to opaque too, but then diagonals are more jaggy)
"textStyle" : { "backDirectives" : "border=1;222;2224?border=1;222;2224" },
"textStyle" : { "backDirectives" : "border=1;fff;fff4?border=1;fff;fff4?multiply=222" },
"inspectOpacityRate" : 0.15,
"movementThreshold" : 0.5,
"offset" : [0, 13]
@ -24,7 +24,7 @@
"paneTextStyle" : {},
"textBoxTextStyle" : {},
"itemSlotTextStyle" : {
"backDirectives" : "border=1;444;4444"
"backDirectives" : "border=1;fff;fff4?multiply=444"
},
"teamBarNameStyle" : {},
"cursorTooltip" : { "textStyle" : {} },
@ -32,7 +32,7 @@
"debugTextStyle" : {
"font" : "iosevka-semibold",
"fontSize" : 7,
"backDirectives" : "border=1;333a;3334"
"backDirectives" : "border=1;fff;fff7?multiply=333a"
},
"debugSpatialClearTime" : 0.0,
"debugOffset" : [80, 130],
@ -40,7 +40,7 @@
// Change planet name to support the new internal string formatting.
"planetNameFormatString" : "- {} -",
"planetTextStyle" : {
"backDirectives" : "border=6;000;000",
"backDirectives" : "border=5;fff;fff?border=1;fff;fff7?multiply=000",
"fontSize" : 24
},

View File

@ -2,8 +2,8 @@
"config" : {
"lineHeight" : 1,
"padding" : [1, 1],
"textStyle" : { "backDirectives" : "border=1;111a;1117" },
"chatFormatString" : "^backdirectives=border=1=333=3337;<^backdirectives=border=1=333=3330?border=1=333=3337,white;{}^reset,backdirectives=border=1=333=3337;>^reset,#eee; {}",
"textStyle" : { "backDirectives" : "border=1;fff;fff7?multiply=111a" },
"chatFormatString" : "^backdirectives=border=1=fff=fff7?multiply=333;<^backdirectives=border=1=fff=fff0?border=1=fff=fff7?multiply=333,white;{}^reset,backdirectives=border=1=fff=fff7?multiply=333;>^reset,#eee; {}",
"colors" : {
"local" : "^white;",
"party" : "^blue;",

View File

@ -1,5 +1,5 @@
{
"movementThreshold" : 0.5,
"bubbleOffset" : [0, 1.875],
"textStyle" : { "backDirectives" : "?border=1;111;1110?border=1;111;1117" }
"textStyle" : { "backDirectives" : "border=1;fff;fff0?border=1;fff;fff7?multiply=111" }
}

View File

@ -140,7 +140,7 @@ void Directives::parse(String&& directives) {
}
catch (StarException const& e) {
prefix = split;
return;
entries.emplace_back(ImageOperation(ErrorImageOperation{std::current_exception()}), beg, end);
}
}
else {

View File

@ -1,6 +1,7 @@
#include "StarFontTextureGroup.hpp"
#include "StarTime.hpp"
#include "StarImageProcessing.hpp"
#include "StarLogging.hpp"
namespace Star {
@ -58,23 +59,30 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha
auto renderResult = font->render(c);
Image& image = get<0>(renderResult);
if (processingDirectives) {
try {
Directives const& directives = *processingDirectives;
Vec2F preSize = Vec2F(image.size());
Directives const& directives = *processingDirectives;
Vec2F preSize = Vec2F(image.size());
for (auto& entry : directives->entries)
for (auto& entry : directives->entries) {
if (auto error = entry.operation.ptr<ErrorImageOperation>()) {
if (error->exception) {
try
{ std::rethrow_exception(error->exception); }
catch (std::exception const& e)
{ Logger::error("Exception parsing font directives: {}", e.what()); }
error->exception = {};
}
image.forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) {
pixel = ((x + y) % 2 == 0) ? Vec4B(255, 0, 255, pixel[3]) : Vec4B(0, 0, 0, pixel[3]);
});
glyphTexture.colored = true;
} else
processImageOperation(entry.operation, image);
}
glyphTexture.offset = (preSize - Vec2F(image.size())) / 2;
}
catch (StarException const&) {
image.forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) {
pixel = ((x + y) % 2 == 0) ? Vec4B(255, 0, 255, pixel[3]) : Vec4B(0, 0, 0, pixel[3]);
});
}
glyphTexture.offset = (preSize - Vec2F(image.size())) / 2;
}
glyphTexture.colored = get<2>(renderResult);
glyphTexture.colored |= get<2>(renderResult);
glyphTexture.offset += Vec2F(get<1>(renderResult));
glyphTexture.texture = m_textureGroup->create(image);
}