diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index c7d7140ce00..c05d9626124 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -517,7 +517,7 @@ License: BSD-2-clause Files: thirdparty/msdfgen/* Comment: Multi-channel signed distance field generator -Copyright: 2014-2024, Viktor Chlumsky +Copyright: 2014-2025, Viktor Chlumsky License: Expat Files: thirdparty/openxr/* diff --git a/thirdparty/README.md b/thirdparty/README.md index f5730f30bde..29a33e64880 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -833,7 +833,7 @@ Collection of single-file libraries used in Godot components. ## msdfgen - Upstream: https://github.com/Chlumsky/msdfgen -- Version: 1.12 (85e8b3d47b3d1a42e4a5ebda0a24fb1cc2e669e0, 2024) +- Version: 1.12.1 (6574da1310df433c97ca0fddcab7e463c31e58f8, 2025) - License: MIT Files extracted from the upstream source: diff --git a/thirdparty/msdfgen/LICENSE.txt b/thirdparty/msdfgen/LICENSE.txt index d5b31742500..fbea359b250 100644 --- a/thirdparty/msdfgen/LICENSE.txt +++ b/thirdparty/msdfgen/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2014 - 2024 Viktor Chlumsky +Copyright (c) 2014 - 2025 Viktor Chlumsky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/thirdparty/msdfgen/core/MSDFErrorCorrection.cpp b/thirdparty/msdfgen/core/MSDFErrorCorrection.cpp index 7639dc68773..d1b10ef10fa 100644 --- a/thirdparty/msdfgen/core/MSDFErrorCorrection.cpp +++ b/thirdparty/msdfgen/core/MSDFErrorCorrection.cpp @@ -89,6 +89,8 @@ public: bool protectedFlag; inline ShapeDistanceChecker(const BitmapConstRef &sdf, const Shape &shape, const Projection &projection, DistanceMapping distanceMapping, double minImproveRatio) : distanceFinder(shape), sdf(sdf), distanceMapping(distanceMapping), minImproveRatio(minImproveRatio) { texelSize = projection.unprojectVector(Vector2(1)); + if (shape.inverseYAxis) + texelSize.y = -texelSize.y; } inline ArtifactClassifier classifier(const Vector2 &direction, double span) { return ArtifactClassifier(this, direction, span); @@ -127,10 +129,10 @@ void MSDFErrorCorrection::protectCorners(const Shape &shape) { if (!(commonColor&(commonColor-1))) { // Find the four texels that envelop the corner and mark them as protected. Point2 p = transformation.project((*edge)->point(0)); - if (shape.inverseYAxis) - p.y = stencil.height-p.y; int l = (int) floor(p.x-.5); int b = (int) floor(p.y-.5); + if (shape.inverseYAxis) + b = stencil.height-b-2; int r = l+1; int t = b+1; // Check that the positions are within bounds. diff --git a/thirdparty/msdfgen/core/msdf-error-correction.cpp b/thirdparty/msdfgen/core/msdf-error-correction.cpp index 0b53572de5e..e9094deb408 100644 --- a/thirdparty/msdfgen/core/msdf-error-correction.cpp +++ b/thirdparty/msdfgen/core/msdf-error-correction.cpp @@ -84,6 +84,12 @@ void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, const Proje void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, const Projection &projection, Range range, double minDeviationRatio) { msdfErrorCorrectionShapeless(sdf, SDFTransformation(projection, range), minDeviationRatio, false); } +void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio) { + msdfErrorCorrectionShapeless(sdf, SDFTransformation(Projection(), pxRange), minDeviationRatio, false); +} +void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio) { + msdfErrorCorrectionShapeless(sdf, SDFTransformation(Projection(), pxRange), minDeviationRatio, false); +} void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, const SDFTransformation &transformation, double minDeviationRatio) { msdfErrorCorrectionShapeless(sdf, transformation, minDeviationRatio, true); @@ -97,6 +103,12 @@ void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, const Projectio void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, const Projection &projection, Range range, double minDeviationRatio) { msdfErrorCorrectionShapeless(sdf, SDFTransformation(projection, range), minDeviationRatio, true); } +void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio) { + msdfErrorCorrectionShapeless(sdf, SDFTransformation(Projection(), pxRange), minDeviationRatio, true); +} +void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio) { + msdfErrorCorrectionShapeless(sdf, SDFTransformation(Projection(), pxRange), minDeviationRatio, true); +} // Legacy version diff --git a/thirdparty/msdfgen/core/msdf-error-correction.h b/thirdparty/msdfgen/core/msdf-error-correction.h index fd9b0026d1c..c92cbe17a3b 100644 --- a/thirdparty/msdfgen/core/msdf-error-correction.h +++ b/thirdparty/msdfgen/core/msdf-error-correction.h @@ -22,12 +22,16 @@ void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, const SDFTr void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, const SDFTransformation &transformation, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, const Projection &projection, Range range, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, const Projection &projection, Range range, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); +void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); +void msdfFastDistanceErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); /// Applies the simplified error correction to edges only (EDGE_ONLY mode). Does not need shape or translation. void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, const SDFTransformation &transformation, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, const SDFTransformation &transformation, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, const Projection &projection, Range range, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, const Projection &projection, Range range, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); +void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); +void msdfFastEdgeErrorCorrection(const BitmapRef &sdf, Range pxRange, double minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio); /// The original version of the error correction algorithm. void msdfErrorCorrection_legacy(const BitmapRef &output, const Vector2 &threshold); diff --git a/thirdparty/msdfgen/core/rasterization.cpp b/thirdparty/msdfgen/core/rasterization.cpp index 9aa695a8c1d..8ceec77b4a2 100644 --- a/thirdparty/msdfgen/core/rasterization.cpp +++ b/thirdparty/msdfgen/core/rasterization.cpp @@ -33,7 +33,7 @@ void distanceSignCorrection(const BitmapRef &sdf, const Shape &shape, template static void multiDistanceSignCorrection(const BitmapRef &sdf, const Shape &shape, const Projection &projection, FillRule fillRule) { int w = sdf.width, h = sdf.height; - if (!(w*h)) + if (!(w && h)) return; Scanline scanline; bool ambiguous = false; diff --git a/thirdparty/msdfgen/core/save-bmp.cpp b/thirdparty/msdfgen/core/save-bmp.cpp index bf8e8e478d8..d71a2a6f8e1 100644 --- a/thirdparty/msdfgen/core/save-bmp.cpp +++ b/thirdparty/msdfgen/core/save-bmp.cpp @@ -1,5 +1,7 @@ +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include "save-bmp.h" diff --git a/thirdparty/msdfgen/core/save-tiff.cpp b/thirdparty/msdfgen/core/save-tiff.cpp index 62c379c6f5a..2c400d5d2f1 100644 --- a/thirdparty/msdfgen/core/save-tiff.cpp +++ b/thirdparty/msdfgen/core/save-tiff.cpp @@ -1,5 +1,7 @@ +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include "save-tiff.h" diff --git a/thirdparty/msdfgen/core/shape-description.cpp b/thirdparty/msdfgen/core/shape-description.cpp index c2664d544d8..639ffa1883e 100644 --- a/thirdparty/msdfgen/core/shape-description.cpp +++ b/thirdparty/msdfgen/core/shape-description.cpp @@ -1,5 +1,8 @@ +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif + #include "shape-description.h" #include diff --git a/thirdparty/msdfgen/msdfgen.h b/thirdparty/msdfgen/msdfgen.h index ae909effdc4..e5dd67260ed 100644 --- a/thirdparty/msdfgen/msdfgen.h +++ b/thirdparty/msdfgen/msdfgen.h @@ -4,7 +4,7 @@ /* * MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR * --------------------------------------------- - * A utility by Viktor Chlumsky, (c) 2014 - 2024 + * A utility by Viktor Chlumsky, (c) 2014 - 2025 * * The technique used to generate multi-channel distance fields in this code * has been developed by Viktor Chlumsky in 2014 for his master's thesis,