mirror of
https://github.com/godotengine/godot.git
synced 2025-01-05 17:50:55 +00:00
Merge pull request #57852 from bruvzg/hb_msdf_update
This commit is contained in:
commit
d368b88f5c
4
thirdparty/README.md
vendored
4
thirdparty/README.md
vendored
@ -206,7 +206,7 @@ Files extracted from upstream source:
|
||||
## harfbuzz
|
||||
|
||||
- Upstream: https://github.com/harfbuzz/harfbuzz
|
||||
- Version: 3.3.1 (45df259538c204540819d74456d30ffb40df488a, 2022)
|
||||
- Version: 3.3.2 (ac46c3248e8b0316235943175c4d4a11c24dd4a9, 2022)
|
||||
- License: MIT
|
||||
|
||||
Files extracted from upstream source:
|
||||
@ -465,7 +465,7 @@ Collection of single-file libraries used in Godot components.
|
||||
## msdfgen
|
||||
|
||||
- Upstream: https://github.com/Chlumsky/msdfgen
|
||||
- Version: 1.9.1 (1b3b6b985094e6f12751177490add3ad11dd91a9, 2010)
|
||||
- Version: 1.9.2 (64a91eec3ca3787e6f78b4c99fcd3052ad3e37c0, 2021)
|
||||
- License: MIT
|
||||
|
||||
Files extracted from the upstream source:
|
||||
|
37
thirdparty/harfbuzz/src/hb-buffer.hh
vendored
37
thirdparty/harfbuzz/src/hb-buffer.hh
vendored
@ -386,11 +386,14 @@ struct hb_buffer_t
|
||||
HB_INTERNAL void delete_glyph ();
|
||||
|
||||
|
||||
void set_glyph_flags (hb_mask_t mask,
|
||||
unsigned start = 0,
|
||||
unsigned end = (unsigned) -1,
|
||||
bool interior = false,
|
||||
bool from_out_buffer = false)
|
||||
/* Adds glyph flags in mask to infos with clusters between start and end.
|
||||
* The start index will be from out-buffer if from_out_buffer is true.
|
||||
* If interior is true, then the cluster having the minimum value is skipped. */
|
||||
void _set_glyph_flags (hb_mask_t mask,
|
||||
unsigned start = 0,
|
||||
unsigned end = (unsigned) -1,
|
||||
bool interior = false,
|
||||
bool from_out_buffer = false)
|
||||
{
|
||||
end = hb_min (end, len);
|
||||
|
||||
@ -437,27 +440,27 @@ struct hb_buffer_t
|
||||
|
||||
void unsafe_to_break (unsigned int start = 0, unsigned int end = -1)
|
||||
{
|
||||
set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_BREAK | HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
true);
|
||||
_set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_BREAK | HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
true);
|
||||
}
|
||||
void unsafe_to_concat (unsigned int start = 0, unsigned int end = -1)
|
||||
{
|
||||
set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
true);
|
||||
_set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
true);
|
||||
}
|
||||
void unsafe_to_break_from_outbuffer (unsigned int start = 0, unsigned int end = -1)
|
||||
{
|
||||
set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_BREAK | HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
true, true);
|
||||
_set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_BREAK | HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
true, true);
|
||||
}
|
||||
void unsafe_to_concat_from_outbuffer (unsigned int start = 0, unsigned int end = -1)
|
||||
{
|
||||
set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
false, true);
|
||||
_set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
start, end,
|
||||
false, true);
|
||||
}
|
||||
|
||||
|
||||
|
4
thirdparty/harfbuzz/src/hb-ot-glyf-table.hh
vendored
4
thirdparty/harfbuzz/src/hb-ot-glyf-table.hh
vendored
@ -917,7 +917,7 @@ struct glyf
|
||||
|
||||
struct accelerator_t
|
||||
{
|
||||
accelerator_t (hb_face_t *face_)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
short_offset = false;
|
||||
num_glyphs = 0;
|
||||
@ -930,7 +930,6 @@ struct glyf
|
||||
#ifndef HB_NO_VERTICAL
|
||||
vmtx = nullptr;
|
||||
#endif
|
||||
face = face_;
|
||||
const OT::head &head = *face->table.head;
|
||||
if (head.indexToLocFormat > 1 || head.glyphDataFormat > 0)
|
||||
/* Unknown format. Leave num_glyphs=0, that takes care of disabling us. */
|
||||
@ -1287,7 +1286,6 @@ struct glyf
|
||||
unsigned int num_glyphs;
|
||||
hb_blob_ptr_t<loca> loca_table;
|
||||
hb_blob_ptr_t<glyf> glyf_table;
|
||||
hb_face_t *face;
|
||||
};
|
||||
|
||||
struct SubsetGlyph
|
||||
|
@ -1586,7 +1586,15 @@ struct PairPosFormat2
|
||||
|
||||
|
||||
/* Isolate simple kerning and apply it half to each side.
|
||||
* Results in better cursor positinoing / underline drawing. */
|
||||
* Results in better cursor positinoing / underline drawing.
|
||||
*
|
||||
* Disabled, because causes issues... :-(
|
||||
* https://github.com/harfbuzz/harfbuzz/issues/3408
|
||||
* https://github.com/harfbuzz/harfbuzz/pull/3235#issuecomment-1029814978
|
||||
*/
|
||||
#ifndef HB_SPLIT_KERN
|
||||
if (0)
|
||||
#endif
|
||||
{
|
||||
if (!len2)
|
||||
{
|
||||
|
4
thirdparty/harfbuzz/src/hb-version.h
vendored
4
thirdparty/harfbuzz/src/hb-version.h
vendored
@ -53,14 +53,14 @@ HB_BEGIN_DECLS
|
||||
*
|
||||
* The micro component of the library version available at compile-time.
|
||||
*/
|
||||
#define HB_VERSION_MICRO 1
|
||||
#define HB_VERSION_MICRO 2
|
||||
|
||||
/**
|
||||
* HB_VERSION_STRING:
|
||||
*
|
||||
* A string literal containing the library version available at compile-time.
|
||||
*/
|
||||
#define HB_VERSION_STRING "3.3.1"
|
||||
#define HB_VERSION_STRING "3.3.2"
|
||||
|
||||
/**
|
||||
* HB_VERSION_ATLEAST:
|
||||
|
2
thirdparty/harfbuzz/src/hb.hh
vendored
2
thirdparty/harfbuzz/src/hb.hh
vendored
@ -447,6 +447,7 @@ static int HB_UNUSED _hb_errno = 0;
|
||||
#ifndef HB_USE_ATEXIT
|
||||
# define HB_USE_ATEXIT 0
|
||||
#endif
|
||||
#ifndef hb_atexit
|
||||
#if !HB_USE_ATEXIT
|
||||
# define hb_atexit(_) HB_STMT_START { if (0) (_) (); } HB_STMT_END
|
||||
#else /* HB_USE_ATEXIT */
|
||||
@ -457,6 +458,7 @@ static int HB_UNUSED _hb_errno = 0;
|
||||
# define hb_atexit(f) static hb_atexit_t<f> _hb_atexit_##__LINE__;
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Lets assert int types. Saves trouble down the road. */
|
||||
static_assert ((sizeof (hb_codepoint_t) == 4), "");
|
||||
|
4
thirdparty/msdfgen/core/edge-coloring.cpp
vendored
4
thirdparty/msdfgen/core/edge-coloring.cpp
vendored
@ -473,7 +473,7 @@ void edgeColoringByDistance(Shape &shape, double angleThreshold, unsigned long l
|
||||
edgeMatrix[i] = &edgeMatrixStorage[i*splineCount];
|
||||
int nextEdge = 0;
|
||||
for (; nextEdge < graphEdgeCount && !*graphEdgeDistances[nextEdge]; ++nextEdge) {
|
||||
int elem = graphEdgeDistances[nextEdge]-distanceMatrixBase;
|
||||
int elem = (int) (graphEdgeDistances[nextEdge]-distanceMatrixBase);
|
||||
int row = elem/splineCount;
|
||||
int col = elem%splineCount;
|
||||
edgeMatrix[row][col] = 1;
|
||||
@ -483,7 +483,7 @@ void edgeColoringByDistance(Shape &shape, double angleThreshold, unsigned long l
|
||||
std::vector<int> coloring(2*splineCount);
|
||||
colorSecondDegreeGraph(&coloring[0], &edgeMatrix[0], splineCount, seed);
|
||||
for (; nextEdge < graphEdgeCount; ++nextEdge) {
|
||||
int elem = graphEdgeDistances[nextEdge]-distanceMatrixBase;
|
||||
int elem = (int) (graphEdgeDistances[nextEdge]-distanceMatrixBase);
|
||||
tryAddEdge(&coloring[0], &edgeMatrix[0], splineCount, elem/splineCount, elem%splineCount, &coloring[splineCount]);
|
||||
}
|
||||
|
||||
|
47
thirdparty/msdfgen/core/equation-solver.cpp
vendored
47
thirdparty/msdfgen/core/equation-solver.cpp
vendored
@ -4,17 +4,15 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
|
||||
#define TOO_LARGE_RATIO 1e12
|
||||
|
||||
namespace msdfgen {
|
||||
|
||||
int solveQuadratic(double x[2], double a, double b, double c) {
|
||||
// a = 0 -> linear equation
|
||||
if (a == 0 || fabs(b)+fabs(c) > TOO_LARGE_RATIO*fabs(a)) {
|
||||
// a, b = 0 -> no solution
|
||||
if (b == 0 || fabs(c) > TOO_LARGE_RATIO*fabs(b)) {
|
||||
// a == 0 -> linear equation
|
||||
if (a == 0 || fabs(b) > 1e12*fabs(a)) {
|
||||
// a == 0, b == 0 -> no solution
|
||||
if (b == 0) {
|
||||
if (c == 0)
|
||||
return -1; // 0 = 0
|
||||
return -1; // 0 == 0
|
||||
return 0;
|
||||
}
|
||||
x[0] = -c/b;
|
||||
@ -35,41 +33,38 @@ int solveQuadratic(double x[2], double a, double b, double c) {
|
||||
|
||||
static int solveCubicNormed(double x[3], double a, double b, double c) {
|
||||
double a2 = a*a;
|
||||
double q = (a2 - 3*b)/9;
|
||||
double r = (a*(2*a2-9*b) + 27*c)/54;
|
||||
double q = 1/9.*(a2-3*b);
|
||||
double r = 1/54.*(a*(2*a2-9*b)+27*c);
|
||||
double r2 = r*r;
|
||||
double q3 = q*q*q;
|
||||
double A, B;
|
||||
a *= 1/3.;
|
||||
if (r2 < q3) {
|
||||
double t = r/sqrt(q3);
|
||||
if (t < -1) t = -1;
|
||||
if (t > 1) t = 1;
|
||||
t = acos(t);
|
||||
a /= 3; q = -2*sqrt(q);
|
||||
x[0] = q*cos(t/3)-a;
|
||||
x[1] = q*cos((t+2*M_PI)/3)-a;
|
||||
x[2] = q*cos((t-2*M_PI)/3)-a;
|
||||
q = -2*sqrt(q);
|
||||
x[0] = q*cos(1/3.*t)-a;
|
||||
x[1] = q*cos(1/3.*(t+2*M_PI))-a;
|
||||
x[2] = q*cos(1/3.*(t-2*M_PI))-a;
|
||||
return 3;
|
||||
} else {
|
||||
A = -pow(fabs(r)+sqrt(r2-q3), 1/3.);
|
||||
if (r < 0) A = -A;
|
||||
B = A == 0 ? 0 : q/A;
|
||||
a /= 3;
|
||||
x[0] = (A+B)-a;
|
||||
x[1] = -0.5*(A+B)-a;
|
||||
x[2] = 0.5*sqrt(3.)*(A-B);
|
||||
if (fabs(x[2]) < 1e-14)
|
||||
double u = (r < 0 ? 1 : -1)*pow(fabs(r)+sqrt(r2-q3), 1/3.);
|
||||
double v = u == 0 ? 0 : q/u;
|
||||
x[0] = (u+v)-a;
|
||||
if (u == v || fabs(u-v) < 1e-12*fabs(u+v)) {
|
||||
x[1] = -.5*(u+v)-a;
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int solveCubic(double x[3], double a, double b, double c, double d) {
|
||||
if (a != 0) {
|
||||
double bn = b/a, cn = c/a, dn = d/a;
|
||||
// Check that a isn't "almost zero"
|
||||
if (fabs(bn) < TOO_LARGE_RATIO && fabs(cn) < TOO_LARGE_RATIO && fabs(dn) < TOO_LARGE_RATIO)
|
||||
return solveCubicNormed(x, bn, cn, dn);
|
||||
double bn = b/a;
|
||||
if (fabs(bn) < 1e6) // Above this ratio, the numerical error gets larger than if we treated a as zero
|
||||
return solveCubicNormed(x, bn, c/a, d/a);
|
||||
}
|
||||
return solveQuadratic(x, b, c, d);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user