Skip to content

Commit

Permalink
Merge pull request #89414 from bruvzg/update_icu_msdfgen
Browse files Browse the repository at this point in the history
Update ICU and msdfgen.
  • Loading branch information
akien-mga committed Mar 13, 2024
2 parents 1030f1f + 0d02568 commit 0478998
Show file tree
Hide file tree
Showing 53 changed files with 421 additions and 396 deletions.
3 changes: 1 addition & 2 deletions modules/msdfgen/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ if env["builtin_msdfgen"]:
"core/Projection.cpp",
"core/Scanline.cpp",
"core/Shape.cpp",
"core/SignedDistance.cpp",
"core/Vector2.cpp",
"core/contour-combiners.cpp",
"core/edge-coloring.cpp",
"core/edge-segments.cpp",
Expand All @@ -36,6 +34,7 @@ if env["builtin_msdfgen"]:
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
env_msdfgen.Prepend(CPPPATH=["#thirdparty/freetype/include", "#thirdparty/msdfgen", "#thirdparty/nanosvg"])

lib = env_msdfgen.add_library("msdfgen_builtin", thirdparty_sources)
Expand Down
1 change: 1 addition & 0 deletions modules/text_server_adv/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ module_obj = []

if env["builtin_msdfgen"] and msdfgen_enabled:
# Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC.
env_text_server_adv.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
if not env.msvc:
env_text_server_adv.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path])
else:
Expand Down
4 changes: 2 additions & 2 deletions modules/text_server_adv/gdextension_build/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
"core/Projection.cpp",
"core/Scanline.cpp",
"core/Shape.cpp",
"core/SignedDistance.cpp",
"core/Vector2.cpp",
"core/contour-combiners.cpp",
"core/edge-coloring.cpp",
"core/edge-segments.cpp",
Expand All @@ -149,8 +147,10 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
]
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]

env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
env.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])

lib = env_msdfgen.Library(
Expand Down
6 changes: 6 additions & 0 deletions modules/text_server_adv/text_server_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ using namespace godot;
// Thirdparty headers.

#ifdef MODULE_MSDFGEN_ENABLED
#ifdef _MSC_VER
#pragma warning(disable : 4458)
#endif
#include <core/ShapeDistanceFinder.h>
#include <core/contour-combiners.h>
#include <core/edge-selectors.h>
#include <msdfgen.h>
#ifdef _MSC_VER
#pragma warning(default : 4458)
#endif
#endif

#ifdef MODULE_SVG_ENABLED
Expand Down
1 change: 1 addition & 0 deletions modules/text_server_fb/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if "svg" in env.module_list:

if env["builtin_msdfgen"] and msdfgen_enabled:
# Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC.
env_text_server_fb.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
if not env.msvc:
env_text_server_fb.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path])
else:
Expand Down
2 changes: 2 additions & 0 deletions modules/text_server_fb/gdextension_build/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
]
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]

env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
env.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])

lib = env_msdfgen.Library(
Expand Down
6 changes: 6 additions & 0 deletions modules/text_server_fb/text_server_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ using namespace godot;
// Thirdparty headers.

#ifdef MODULE_MSDFGEN_ENABLED
#ifdef _MSC_VER
#pragma warning(disable : 4458)
#endif
#include <core/ShapeDistanceFinder.h>
#include <core/contour-combiners.h>
#include <core/edge-selectors.h>
#include <msdfgen.h>
#ifdef _MSC_VER
#pragma warning(default : 4458)
#endif
#endif

#ifdef MODULE_SVG_ENABLED
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ Files extracted from upstream source:
## icu4c

- Upstream: https://github.com/unicode-org/icu
- Version: 74.1 (9edac7b78327a1cb58db29e2714b15f9fa14e4d7, 2023)
- Version: 74.2 (2d029329c82c7792b985024b2bdab5fc7278fbc8, 2023)
- License: Unicode

Files extracted from upstream source:
Expand Down Expand Up @@ -690,7 +690,7 @@ Collection of single-file libraries used in Godot components.
## msdfgen

- Upstream: https://github.com/Chlumsky/msdfgen
- Version: 1.10 (64a91eec3ca3787e6f78b4c99fcd3052ad3e37c0, 2021)
- Version: 1.11 (f12d7ca00091a632a289865b85c3f2e0bfc6542d, 2023)
- License: MIT

Files extracted from the upstream source:
Expand Down
6 changes: 3 additions & 3 deletions thirdparty/icu4c/common/unicode/uvernum.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.6
*/
#define U_ICU_VERSION_MINOR_NUM 1
#define U_ICU_VERSION_MINOR_NUM 2

/** The current ICU patchlevel version as an integer.
* This value will change in the subsequent releases of ICU
Expand Down Expand Up @@ -132,7 +132,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.4
*/
#define U_ICU_VERSION "74.1"
#define U_ICU_VERSION "74.2"

/**
* The current ICU library major version number as a string, for library name suffixes.
Expand All @@ -151,7 +151,7 @@
/** Data version in ICU4C.
* @internal ICU 4.4 Internal Use Only
**/
#define U_ICU_DATA_VERSION "74.1"
#define U_ICU_DATA_VERSION "74.2"
#endif /* U_HIDE_INTERNAL_API */

/*===========================================================================
Expand Down
Binary file modified thirdparty/icu4c/icudt74l.dat
Binary file not shown.
2 changes: 1 addition & 1 deletion thirdparty/msdfgen/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 - 2022 Viktor Chlumsky
Copyright (c) 2016 - 2023 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
Expand Down
10 changes: 5 additions & 5 deletions thirdparty/msdfgen/core/Bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class Bitmap {
Bitmap(Bitmap<T, N> &&orig);
#endif
~Bitmap();
Bitmap<T, N> & operator=(const BitmapConstRef<T, N> &orig);
Bitmap<T, N> & operator=(const Bitmap<T, N> &orig);
Bitmap<T, N> &operator=(const BitmapConstRef<T, N> &orig);
Bitmap<T, N> &operator=(const Bitmap<T, N> &orig);
#ifdef MSDFGEN_USE_CPP11
Bitmap<T, N> & operator=(Bitmap<T, N> &&orig);
Bitmap<T, N> &operator=(Bitmap<T, N> &&orig);
#endif
/// Bitmap width in pixels.
int width() const;
/// Bitmap height in pixels.
int height() const;
T * operator()(int x, int y);
const T * operator()(int x, int y) const;
T *operator()(int x, int y);
const T *operator()(int x, int y) const;
#ifdef MSDFGEN_USE_CPP11
explicit operator T *();
explicit operator const T *() const;
Expand Down
10 changes: 5 additions & 5 deletions thirdparty/msdfgen/core/Bitmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Bitmap<T, N>::~Bitmap() {
}

template <typename T, int N>
Bitmap<T, N> & Bitmap<T, N>::operator=(const BitmapConstRef<T, N> &orig) {
Bitmap<T, N> &Bitmap<T, N>::operator=(const BitmapConstRef<T, N> &orig) {
if (pixels != orig.pixels) {
delete [] pixels;
w = orig.width, h = orig.height;
Expand All @@ -51,7 +51,7 @@ Bitmap<T, N> & Bitmap<T, N>::operator=(const BitmapConstRef<T, N> &orig) {
}

template <typename T, int N>
Bitmap<T, N> & Bitmap<T, N>::operator=(const Bitmap<T, N> &orig) {
Bitmap<T, N> &Bitmap<T, N>::operator=(const Bitmap<T, N> &orig) {
if (this != &orig) {
delete [] pixels;
w = orig.w, h = orig.h;
Expand All @@ -63,7 +63,7 @@ Bitmap<T, N> & Bitmap<T, N>::operator=(const Bitmap<T, N> &orig) {

#ifdef MSDFGEN_USE_CPP11
template <typename T, int N>
Bitmap<T, N> & Bitmap<T, N>::operator=(Bitmap<T, N> &&orig) {
Bitmap<T, N> &Bitmap<T, N>::operator=(Bitmap<T, N> &&orig) {
if (this != &orig) {
delete [] pixels;
pixels = orig.pixels;
Expand All @@ -85,12 +85,12 @@ int Bitmap<T, N>::height() const {
}

template <typename T, int N>
T * Bitmap<T, N>::operator()(int x, int y) {
T *Bitmap<T, N>::operator()(int x, int y) {
return pixels+N*(w*y+x);
}

template <typename T, int N>
const T * Bitmap<T, N>::operator()(int x, int y) const {
const T *Bitmap<T, N>::operator()(int x, int y) const {
return pixels+N*(w*y+x);
}

Expand Down
8 changes: 3 additions & 5 deletions thirdparty/msdfgen/core/BitmapRef.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

#pragma once

#include <cstdlib>
#include "base.h"

namespace msdfgen {

typedef unsigned char byte;

/// Reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.
template <typename T, int N = 1>
struct BitmapRef {
Expand All @@ -17,7 +15,7 @@ struct BitmapRef {
inline BitmapRef() : pixels(NULL), width(0), height(0) { }
inline BitmapRef(T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }

inline T * operator()(int x, int y) const {
inline T *operator()(int x, int y) const {
return pixels+N*(width*y+x);
}

Expand All @@ -34,7 +32,7 @@ struct BitmapConstRef {
inline BitmapConstRef(const T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }
inline BitmapConstRef(const BitmapRef<T, N> &orig) : pixels(orig.pixels), width(orig.width), height(orig.height) { }

inline const T * operator()(int x, int y) const {
inline const T *operator()(int x, int y) const {
return pixels+N*(width*y+x);
}

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/msdfgen/core/Contour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void Contour::addEdge(EdgeHolder &&edge) {
}
#endif

EdgeHolder & Contour::addEdge() {
EdgeHolder &Contour::addEdge() {
edges.resize(edges.size()+1);
return edges.back();
}
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/msdfgen/core/Contour.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Contour {
void addEdge(EdgeHolder &&edge);
#endif
/// Creates a new edge in the contour and returns its reference.
EdgeHolder & addEdge();
EdgeHolder &addEdge();
/// Adjusts the bounding box to fit the contour.
void bound(double &l, double &b, double &r, double &t) const;
/// Adjusts the bounding box to fit the contour border's mitered corners.
Expand Down
2 changes: 2 additions & 0 deletions thirdparty/msdfgen/core/EdgeColor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#pragma once

#include "base.h"

namespace msdfgen {

/// Edge color specifies which color channels an edge belongs to.
Expand Down
12 changes: 6 additions & 6 deletions thirdparty/msdfgen/core/EdgeHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ EdgeHolder::~EdgeHolder() {
delete edgeSegment;
}

EdgeHolder & EdgeHolder::operator=(const EdgeHolder &orig) {
EdgeHolder &EdgeHolder::operator=(const EdgeHolder &orig) {
if (this != &orig) {
delete edgeSegment;
edgeSegment = orig.edgeSegment ? orig.edgeSegment->clone() : NULL;
Expand All @@ -40,7 +40,7 @@ EdgeHolder & EdgeHolder::operator=(const EdgeHolder &orig) {
}

#ifdef MSDFGEN_USE_CPP11
EdgeHolder & EdgeHolder::operator=(EdgeHolder &&orig) {
EdgeHolder &EdgeHolder::operator=(EdgeHolder &&orig) {
if (this != &orig) {
delete edgeSegment;
edgeSegment = orig.edgeSegment;
Expand All @@ -50,19 +50,19 @@ EdgeHolder & EdgeHolder::operator=(EdgeHolder &&orig) {
}
#endif

EdgeSegment & EdgeHolder::operator*() {
EdgeSegment &EdgeHolder::operator*() {
return *edgeSegment;
}

const EdgeSegment & EdgeHolder::operator*() const {
const EdgeSegment &EdgeHolder::operator*() const {
return *edgeSegment;
}

EdgeSegment * EdgeHolder::operator->() {
EdgeSegment *EdgeHolder::operator->() {
return edgeSegment;
}

const EdgeSegment * EdgeHolder::operator->() const {
const EdgeSegment *EdgeHolder::operator->() const {
return edgeSegment;
}

Expand Down
12 changes: 6 additions & 6 deletions thirdparty/msdfgen/core/EdgeHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class EdgeHolder {
EdgeHolder(EdgeHolder &&orig);
#endif
~EdgeHolder();
EdgeHolder & operator=(const EdgeHolder &orig);
EdgeHolder &operator=(const EdgeHolder &orig);
#ifdef MSDFGEN_USE_CPP11
EdgeHolder & operator=(EdgeHolder &&orig);
EdgeHolder &operator=(EdgeHolder &&orig);
#endif
EdgeSegment & operator*();
const EdgeSegment & operator*() const;
EdgeSegment * operator->();
const EdgeSegment * operator->() const;
EdgeSegment &operator*();
const EdgeSegment &operator*() const;
EdgeSegment *operator->();
const EdgeSegment *operator->() const;
operator EdgeSegment *();
operator const EdgeSegment *() const;

Expand Down
8 changes: 4 additions & 4 deletions thirdparty/msdfgen/core/MSDFErrorCorrection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace msdfgen {
#define CLASSIFIER_FLAG_CANDIDATE 0x01
#define CLASSIFIER_FLAG_ARTIFACT 0x02

const double ErrorCorrectionConfig::defaultMinDeviationRatio = 1.11111111111111111;
const double ErrorCorrectionConfig::defaultMinImproveRatio = 1.11111111111111111;
MSDFGEN_PUBLIC const double ErrorCorrectionConfig::defaultMinDeviationRatio = 1.11111111111111111;
MSDFGEN_PUBLIC const double ErrorCorrectionConfig::defaultMinImproveRatio = 1.11111111111111111;

/// The base artifact classifier recognizes artifacts based on the contents of the SDF alone.
class BaseArtifactClassifier {
Expand Down Expand Up @@ -317,15 +317,15 @@ static bool hasDiagonalArtifactInner(const ArtifactClassifier &artifactClassifie
em[0] = am, em[1] = dm;
tEnd[tEx0 > t[i]] = tEx0;
em[tEx0 > t[i]] = interpolatedMedian(a, l, q, tEx0);
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], am, dm, xm);
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], em[0], em[1], xm);
}
// tEx1
if (tEx1 > 0 && tEx1 < 1) {
tEnd[0] = 0, tEnd[1] = 1;
em[0] = am, em[1] = dm;
tEnd[tEx1 > t[i]] = tEx1;
em[tEx1 > t[i]] = interpolatedMedian(a, l, q, tEx1);
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], am, dm, xm);
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], em[0], em[1], xm);
}
if (artifactClassifier.evaluate(t[i], xm, rangeFlags))
return true;
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/msdfgen/core/Projection.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#pragma once

#include "Vector2.h"
#include "Vector2.hpp"

namespace msdfgen {

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/msdfgen/core/Scanline.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include "Scanline.h"

#include <algorithm>
#include <cstdlib>
#include "arithmetics.hpp"

namespace msdfgen {
Expand Down
1 change: 1 addition & 0 deletions thirdparty/msdfgen/core/Scanline.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

#include <vector>
#include "base.h"

namespace msdfgen {

Expand Down
Loading

0 comments on commit 0478998

Please sign in to comment.