+@@ -72,13 +72,14 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ ---------------------------------
+-The below license applies to the following files:
++The below applies to the following file(s):
+ libharfbuzz/hb-unicode-emoji-table.hh
+
+-© 2023 Unicode®, Inc.
++© 2024 Unicode®, Inc.
+
-+#ifndef MPI_AMD64_ADD
-+ MP_SUB_BORROW(r0, b0, r0, 0, borrow);
-+ MP_SUB_BORROW(r1, b1, r1, borrow, borrow);
-+ MP_SUB_BORROW(r2, b2, r2, borrow, borrow);
-+#else
-+ __asm__ (
-+ "xorq %3,%3 \n\t"
-+ "subq %4,%0 \n\t"
-+ "sbbq %5,%1 \n\t"
-+ "sbbq %6,%2 \n\t"
-+ "adcq $0,%3 \n\t"
-+ : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(borrow)
-+ : "r" (b0), "r" (b1), "r" (b2), "0" (r0),
-+ "1" (r1), "2" (r2)
-+ : "%cc" );
-+#endif
-+
-+ /* Do quick 'add' if we've gone under 0
-+ * (subtract the 2's complement of the curve field) */
-+ if (borrow) {
-+#ifndef MPI_AMD64_ADD
-+ MP_SUB_BORROW(r0, 1, r0, 0, borrow);
-+ MP_SUB_BORROW(r1, 1, r1, borrow, borrow);
-+ MP_SUB_BORROW(r2, 0, r2, borrow, borrow);
-+#else
-+ __asm__ (
-+ "subq $1,%0 \n\t"
-+ "sbbq $1,%1 \n\t"
-+ "sbbq $0,%2 \n\t"
-+ : "=r"(r0), "=r"(r1), "=r"(r2)
-+ : "0" (r0), "1" (r1), "2" (r2)
-+ : "%cc" );
-+#endif
-+ }
+ Unicode and the Unicode Logo are registered trademarks of Unicode, Inc.
+ in the U.S. and other countries.
+-For terms of use, see https://www.unicode.org/terms_of_use.html
++For terms of use and license, see https://www.unicode.org/terms_of_use.html
+
+
+
+diff --git a/src/java.desktop/share/legal/lcms.md b/src/java.desktop/share/legal/lcms.md
+index 02af4fff0..83c47d3ac 100644
+--- a/src/java.desktop/share/legal/lcms.md
++++ b/src/java.desktop/share/legal/lcms.md
+@@ -1,11 +1,11 @@
+-## Little Color Management System (LCMS) v2.16
++## Little Color Management System (LCMS) v2.17
+
+ ### LCMS License
+
+
+ MIT License
+
+-Copyright (C) 1998-2023 Marti Maria Saguer
++Copyright (C) 1998-2025 Marti Maria Saguer
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the "Software"),
+@@ -26,10 +26,10 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ ---------------------------------
+-The below license applies to the following files:
++The below applies to the following file(s):
+ liblcms/cmssm.c
+
+-Copyright 2001, softSurfer (www.softsurfer.com)
++Copyright (C) 2001, softSurfer (www.softsurfer.com)
+
+ This code may be freely used and modified for any purpose
+ providing that this copyright notice is included with it.
+@@ -99,5 +99,5 @@ Christian Albrecht
+ Dimitrios Anastassakis
+ Lemke Software
+ Tim Zaman
+-
+-```
++Amir Montazery and Open Source Technology Improvement Fund (ostif.org), Google, for fuzzer fundings.
++```
+\ No newline at end of file
+diff --git a/src/java.desktop/share/legal/libpng.md b/src/java.desktop/share/legal/libpng.md
+index cbffed813..d43ccf2e8 100644
+--- a/src/java.desktop/share/legal/libpng.md
++++ b/src/java.desktop/share/legal/libpng.md
+@@ -1,4 +1,4 @@
+-## libpng v1.6.43
++## libpng v1.6.47
+
+ ### libpng License
+
+@@ -9,8 +9,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
+ PNG Reference Library License version 2
+ ---------------------------------------
+
+-Copyright (C) 1995-2024 The PNG Reference Library Authors.
+-Copyright (C) 2018-2024 Cosmin Truta
++Copyright (c) 1995-2025 The PNG Reference Library Authors.
++Copyright (C) 2018-2025 Cosmin Truta
+ Copyright (C) 1998-2018 Glenn Randers-Pehrson
+ Copyright (C) 1996-1997 Andreas Dilger
+ Copyright (C) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+@@ -170,6 +170,7 @@ Authors, for copyright and licensing purposes.
+ * James Yu
+ * John Bowler
+ * Kevin Bracey
++ * Lucas Chollet
+ * Magnus Holmgren
+ * Mandar Sahastrabuddhe
+ * Mans Rullgard
+diff --git a/src/java.desktop/share/native/libawt/java2d/SurfaceData.h b/src/java.desktop/share/native/libawt/java2d/SurfaceData.h
+index f8fd8e62a..ca2e985fa 100644
+--- a/src/java.desktop/share/native/libawt/java2d/SurfaceData.h
++++ b/src/java.desktop/share/native/libawt/java2d/SurfaceData.h
+@@ -60,7 +60,7 @@ typedef struct {
+
+ #define UNSAFE_TO_SUB(a, b) \
+ (((b >= 0) && (a < 0) && (a < (INT_MIN + b))) || \
+- ((b < 0) && (a >= 0) && (-b > (INT_MAX - a)))) \
++ ((b < 0) && (a >= 0) && (a > (INT_MAX + b)))) \
+
+ /*
+ * The SurfaceDataRasInfo structure is used to pass in and return various
+diff --git a/src/java.desktop/share/native/libawt/java2d/loops/Blit.c b/src/java.desktop/share/native/libawt/java2d/loops/Blit.c
+index fee108b83..8a41584de 100644
+--- a/src/java.desktop/share/native/libawt/java2d/loops/Blit.c
++++ b/src/java.desktop/share/native/libawt/java2d/loops/Blit.c
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+@@ -68,14 +68,30 @@ Java_sun_java2d_loops_Blit_Blit
+ return;
+ }
+
++ if (width <= 0 || height <= 0) {
++ return;
++ }
+
-+ MP_CHECKOK(s_mp_pad(r, 3));
-+ MP_DIGIT(r, 2) = r2;
-+ MP_DIGIT(r, 1) = r1;
-+ MP_DIGIT(r, 0) = r0;
-+ MP_SIGN(r) = MP_ZPOS;
-+ MP_USED(r) = 3;
-+ s_mp_clamp(r);
+ srcInfo.bounds.x1 = srcx;
+ srcInfo.bounds.y1 = srcy;
++ if (UNSAFE_TO_ADD(srcx, width) ||
++ UNSAFE_TO_ADD(srcy, height) ||
++ UNSAFE_TO_ADD(dstx, width) ||
++ UNSAFE_TO_ADD(dsty, height)) {
++ return;
++ }
+
-+ CLEANUP:
-+ return res;
-+}
+ srcInfo.bounds.x2 = srcx + width;
+ srcInfo.bounds.y2 = srcy + height;
+ dstInfo.bounds.x1 = dstx;
+ dstInfo.bounds.y1 = dsty;
+ dstInfo.bounds.x2 = dstx + width;
+ dstInfo.bounds.y2 = dsty + height;
++ if (UNSAFE_TO_SUB(srcx, dstx) ||
++ UNSAFE_TO_SUB(srcy, dsty)) {
++ return;
++ }
+
-+#endif
-+
-+/* Compute the square of polynomial a, reduce modulo p192. Store the
-+ * result in r. r could be a. Uses optimized modular reduction for p192.
-+ */
-+mp_err
-+ec_GFp_nistp192_sqr(const mp_int *a, mp_int *r, const GFMethod *meth)
-+{
-+ mp_err res = MP_OKAY;
-+
-+ MP_CHECKOK(mp_sqr(a, r));
-+ MP_CHECKOK(ec_GFp_nistp192_mod(r, r, meth));
-+ CLEANUP:
-+ return res;
-+}
-+
-+/* Compute the product of two polynomials a and b, reduce modulo p192.
-+ * Store the result in r. r could be a or b; a could be b. Uses
-+ * optimized modular reduction for p192. */
-+mp_err
-+ec_GFp_nistp192_mul(const mp_int *a, const mp_int *b, mp_int *r,
-+ const GFMethod *meth)
-+{
-+ mp_err res = MP_OKAY;
-+
-+ MP_CHECKOK(mp_mul(a, b, r));
-+ MP_CHECKOK(ec_GFp_nistp192_mod(r, r, meth));
-+ CLEANUP:
-+ return res;
-+}
-+
-+/* Divides two field elements. If a is NULL, then returns the inverse of
-+ * b. */
-+mp_err
-+ec_GFp_nistp192_div(const mp_int *a, const mp_int *b, mp_int *r,
-+ const GFMethod *meth)
-+{
-+ mp_err res = MP_OKAY;
-+ mp_int t;
-+
-+ /* If a is NULL, then return the inverse of b, otherwise return a/b. */
-+ if (a == NULL) {
-+ return mp_invmod(b, &meth->irr, r);
-+ } else {
-+ /* MPI doesn't support divmod, so we implement it using invmod and
-+ * mulmod. */
-+ MP_CHECKOK(mp_init(&t, FLAG(b)));
-+ MP_CHECKOK(mp_invmod(b, &meth->irr, &t));
-+ MP_CHECKOK(mp_mul(a, &t, r));
-+ MP_CHECKOK(ec_GFp_nistp192_mod(r, r, meth));
-+ CLEANUP:
-+ mp_clear(&t);
-+ return res;
-+ }
-+}
-+
-+/* Wire in fast field arithmetic and precomputation of base point for
-+ * named curves. */
-+mp_err
-+ec_group_set_gfp192(ECGroup *group, ECCurveName name)
-+{
-+ if (name == ECCurve_NIST_P192) {
-+ group->meth->field_mod = &ec_GFp_nistp192_mod;
-+ group->meth->field_mul = &ec_GFp_nistp192_mul;
-+ group->meth->field_sqr = &ec_GFp_nistp192_sqr;
-+ group->meth->field_div = &ec_GFp_nistp192_div;
-+#ifndef ECL_THIRTY_TWO_BIT
-+ group->meth->field_add = &ec_GFp_nistp192_add;
-+ group->meth->field_sub = &ec_GFp_nistp192_sub;
-+#endif
-+ }
-+ return MP_OKAY;
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.crypto.ec/share/native/libsunec/impl/ecp_224.c jdk11u-ls/src/jdk.crypto.ec/share/native/libsunec/impl/ecp_224.c
---- openjdk/src/jdk.crypto.ec/share/native/libsunec/impl/ecp_224.c 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.crypto.ec/share/native/libsunec/impl/ecp_224.c 2023-09-12 13:54:26.293575685 +0800
-@@ -0,0 +1,373 @@
-+/*
-+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
-+ * Use is subject to license terms.
-+ *
-+ * This library is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU Lesser General Public
-+ * License as published by the Free Software Foundation; either
-+ * version 2.1 of the License, or (at your option) any later version.
-+ *
-+ * This library is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ * Lesser General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU Lesser General Public License
-+ * along with this library; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ */
-+
-+/* *********************************************************************
-+ *
-+ * The Original Code is the elliptic curve math library for prime field curves.
-+ *
-+ * The Initial Developer of the Original Code is
-+ * Sun Microsystems, Inc.
-+ * Portions created by the Initial Developer are Copyright (C) 2003
-+ * the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ * Douglas Stebila , Sun Microsystems Laboratories
-+ *
-+ *********************************************************************** */
-+
-+#include "ecp.h"
-+#include "mpi.h"
-+#include "mplogic.h"
-+#include "mpi-priv.h"
-+#ifndef _KERNEL
-+#include
-+#endif
-+
-+#define ECP224_DIGITS ECL_CURVE_DIGITS(224)
-+
-+/* Fast modular reduction for p224 = 2^224 - 2^96 + 1. a can be r. Uses
-+ * algorithm 7 from Brown, Hankerson, Lopez, Menezes. Software
-+ * Implementation of the NIST Elliptic Curves over Prime Fields. */
-+mp_err
-+ec_GFp_nistp224_mod(const mp_int *a, mp_int *r, const GFMethod *meth)
-+{
-+ mp_err res = MP_OKAY;
-+ mp_size a_used = MP_USED(a);
-+
-+ int r3b;
-+ mp_digit carry;
-+#ifdef ECL_THIRTY_TWO_BIT
-+ mp_digit a6a = 0, a6b = 0,
-+ a5a = 0, a5b = 0, a4a = 0, a4b = 0, a3a = 0, a3b = 0;
-+ mp_digit r0a, r0b, r1a, r1b, r2a, r2b, r3a;
-+#else
-+ mp_digit a6 = 0, a5 = 0, a4 = 0, a3b = 0, a5a = 0;
-+ mp_digit a6b = 0, a6a_a5b = 0, a5b = 0, a5a_a4b = 0, a4a_a3b = 0;
-+ mp_digit r0, r1, r2, r3;
-+#endif
-+
-+ /* reduction not needed if a is not larger than field size */
-+ if (a_used < ECP224_DIGITS) {
-+ if (a == r) return MP_OKAY;
-+ return mp_copy(a, r);
-+ }
-+ /* for polynomials larger than twice the field size, use regular
-+ * reduction */
-+ if (a_used > ECL_CURVE_DIGITS(224*2)) {
-+ MP_CHECKOK(mp_mod(a, &meth->irr, r));
-+ } else {
-+#ifdef ECL_THIRTY_TWO_BIT
-+ /* copy out upper words of a */
-+ switch (a_used) {
-+ case 14:
-+ a6b = MP_DIGIT(a, 13);
-+ case 13:
-+ a6a = MP_DIGIT(a, 12);
-+ case 12:
-+ a5b = MP_DIGIT(a, 11);
-+ case 11:
-+ a5a = MP_DIGIT(a, 10);
-+ case 10:
-+ a4b = MP_DIGIT(a, 9);
-+ case 9:
-+ a4a = MP_DIGIT(a, 8);
-+ case 8:
-+ a3b = MP_DIGIT(a, 7);
-+ }
-+ r3a = MP_DIGIT(a, 6);
-+ r2b= MP_DIGIT(a, 5);
-+ r2a= MP_DIGIT(a, 4);
-+ r1b = MP_DIGIT(a, 3);
-+ r1a = MP_DIGIT(a, 2);
-+ r0b = MP_DIGIT(a, 1);
-+ r0a = MP_DIGIT(a, 0);
-+
-+
-+ /* implement r = (a3a,a2,a1,a0)
-+ +(a5a, a4,a3b, 0)
-+ +( 0, a6,a5b, 0)
-+ -( 0 0, 0|a6b, a6a|a5b )
-+ -( a6b, a6a|a5b, a5a|a4b, a4a|a3b ) */
-+ MP_ADD_CARRY (r1b, a3b, r1b, 0, carry);
-+ MP_ADD_CARRY (r2a, a4a, r2a, carry, carry);
-+ MP_ADD_CARRY (r2b, a4b, r2b, carry, carry);
-+ MP_ADD_CARRY (r3a, a5a, r3a, carry, carry);
-+ r3b = carry;
-+ MP_ADD_CARRY (r1b, a5b, r1b, 0, carry);
-+ MP_ADD_CARRY (r2a, a6a, r2a, carry, carry);
-+ MP_ADD_CARRY (r2b, a6b, r2b, carry, carry);
-+ MP_ADD_CARRY (r3a, 0, r3a, carry, carry);
-+ r3b += carry;
-+ MP_SUB_BORROW(r0a, a3b, r0a, 0, carry);
-+ MP_SUB_BORROW(r0b, a4a, r0b, carry, carry);
-+ MP_SUB_BORROW(r1a, a4b, r1a, carry, carry);
-+ MP_SUB_BORROW(r1b, a5a, r1b, carry, carry);
-+ MP_SUB_BORROW(r2a, a5b, r2a, carry, carry);
-+ MP_SUB_BORROW(r2b, a6a, r2b, carry, carry);
-+ MP_SUB_BORROW(r3a, a6b, r3a, carry, carry);
-+ r3b -= carry;
-+ MP_SUB_BORROW(r0a, a5b, r0a, 0, carry);
-+ MP_SUB_BORROW(r0b, a6a, r0b, carry, carry);
-+ MP_SUB_BORROW(r1a, a6b, r1a, carry, carry);
-+ if (carry) {
-+ MP_SUB_BORROW(r1b, 0, r1b, carry, carry);
-+ MP_SUB_BORROW(r2a, 0, r2a, carry, carry);
-+ MP_SUB_BORROW(r2b, 0, r2b, carry, carry);
-+ MP_SUB_BORROW(r3a, 0, r3a, carry, carry);
-+ r3b -= carry;
-+ }
-+
-+ while (r3b > 0) {
-+ int tmp;
-+ MP_ADD_CARRY(r1b, r3b, r1b, 0, carry);
-+ if (carry) {
-+ MP_ADD_CARRY(r2a, 0, r2a, carry, carry);
-+ MP_ADD_CARRY(r2b, 0, r2b, carry, carry);
-+ MP_ADD_CARRY(r3a, 0, r3a, carry, carry);
-+ }
-+ tmp = carry;
-+ MP_SUB_BORROW(r0a, r3b, r0a, 0, carry);
-+ if (carry) {
-+ MP_SUB_BORROW(r0b, 0, r0b, carry, carry);
-+ MP_SUB_BORROW(r1a, 0, r1a, carry, carry);
-+ MP_SUB_BORROW(r1b, 0, r1b, carry, carry);
-+ MP_SUB_BORROW(r2a, 0, r2a, carry, carry);
-+ MP_SUB_BORROW(r2b, 0, r2b, carry, carry);
-+ MP_SUB_BORROW(r3a, 0, r3a, carry, carry);
-+ tmp -= carry;
-+ }
-+ r3b = tmp;
-+ }
-+
-+ while (r3b < 0) {
-+ mp_digit maxInt = MP_DIGIT_MAX;
-+ MP_ADD_CARRY (r0a, 1, r0a, 0, carry);
-+ MP_ADD_CARRY (r0b, 0, r0b, carry, carry);
-+ MP_ADD_CARRY (r1a, 0, r1a, carry, carry);
-+ MP_ADD_CARRY (r1b, maxInt, r1b, carry, carry);
-+ MP_ADD_CARRY (r2a, maxInt, r2a, carry, carry);
-+ MP_ADD_CARRY (r2b, maxInt, r2b, carry, carry);
-+ MP_ADD_CARRY (r3a, maxInt, r3a, carry, carry);
-+ r3b += carry;
-+ }
-+ /* check for final reduction */
-+ /* now the only way we are over is if the top 4 words are all ones */
-+ if ((r3a == MP_DIGIT_MAX) && (r2b == MP_DIGIT_MAX)
-+ && (r2a == MP_DIGIT_MAX) && (r1b == MP_DIGIT_MAX) &&
-+ ((r1a != 0) || (r0b != 0) || (r0a != 0)) ) {
-+ /* one last subraction */
-+ MP_SUB_BORROW(r0a, 1, r0a, 0, carry);
-+ MP_SUB_BORROW(r0b, 0, r0b, carry, carry);
-+ MP_SUB_BORROW(r1a, 0, r1a, carry, carry);
-+ r1b = r2a = r2b = r3a = 0;
-+ }
-+
-+
-+ if (a != r) {
-+ MP_CHECKOK(s_mp_pad(r, 7));
-+ }
-+ /* set the lower words of r */
-+ MP_SIGN(r) = MP_ZPOS;
-+ MP_USED(r) = 7;
-+ MP_DIGIT(r, 6) = r3a;
-+ MP_DIGIT(r, 5) = r2b;
-+ MP_DIGIT(r, 4) = r2a;
-+ MP_DIGIT(r, 3) = r1b;
-+ MP_DIGIT(r, 2) = r1a;
-+ MP_DIGIT(r, 1) = r0b;
-+ MP_DIGIT(r, 0) = r0a;
-+#else
-+ /* copy out upper words of a */
-+ switch (a_used) {
-+ case 7:
-+ a6 = MP_DIGIT(a, 6);
-+ a6b = a6 >> 32;
-+ a6a_a5b = a6 << 32;
-+ case 6:
-+ a5 = MP_DIGIT(a, 5);
-+ a5b = a5 >> 32;
-+ a6a_a5b |= a5b;
-+ a5b = a5b << 32;
-+ a5a_a4b = a5 << 32;
-+ a5a = a5 & 0xffffffff;
-+ case 5:
-+ a4 = MP_DIGIT(a, 4);
-+ a5a_a4b |= a4 >> 32;
-+ a4a_a3b = a4 << 32;
-+ case 4:
-+ a3b = MP_DIGIT(a, 3) >> 32;
-+ a4a_a3b |= a3b;
-+ a3b = a3b << 32;
-+ }
-+
-+ r3 = MP_DIGIT(a, 3) & 0xffffffff;
-+ r2 = MP_DIGIT(a, 2);
-+ r1 = MP_DIGIT(a, 1);
-+ r0 = MP_DIGIT(a, 0);
-+
-+ /* implement r = (a3a,a2,a1,a0)
-+ +(a5a, a4,a3b, 0)
-+ +( 0, a6,a5b, 0)
-+ -( 0 0, 0|a6b, a6a|a5b )
-+ -( a6b, a6a|a5b, a5a|a4b, a4a|a3b ) */
-+ MP_ADD_CARRY_ZERO (r1, a3b, r1, carry);
-+ MP_ADD_CARRY (r2, a4 , r2, carry, carry);
-+ MP_ADD_CARRY (r3, a5a, r3, carry, carry);
-+ MP_ADD_CARRY_ZERO (r1, a5b, r1, carry);
-+ MP_ADD_CARRY (r2, a6 , r2, carry, carry);
-+ MP_ADD_CARRY (r3, 0, r3, carry, carry);
-+
-+ MP_SUB_BORROW(r0, a4a_a3b, r0, 0, carry);
-+ MP_SUB_BORROW(r1, a5a_a4b, r1, carry, carry);
-+ MP_SUB_BORROW(r2, a6a_a5b, r2, carry, carry);
-+ MP_SUB_BORROW(r3, a6b , r3, carry, carry);
-+ MP_SUB_BORROW(r0, a6a_a5b, r0, 0, carry);
-+ MP_SUB_BORROW(r1, a6b , r1, carry, carry);
-+ if (carry) {
-+ MP_SUB_BORROW(r2, 0, r2, carry, carry);
-+ MP_SUB_BORROW(r3, 0, r3, carry, carry);
-+ }
-+
-+
-+ /* if the value is negative, r3 has a 2's complement
-+ * high value */
-+ r3b = (int)(r3 >>32);
-+ while (r3b > 0) {
-+ r3 &= 0xffffffff;
-+ MP_ADD_CARRY_ZERO(r1,((mp_digit)r3b) << 32, r1, carry);
-+ if (carry) {
-+ MP_ADD_CARRY(r2, 0, r2, carry, carry);
-+ MP_ADD_CARRY(r3, 0, r3, carry, carry);
-+ }
-+ MP_SUB_BORROW(r0, r3b, r0, 0, carry);
-+ if (carry) {
-+ MP_SUB_BORROW(r1, 0, r1, carry, carry);
-+ MP_SUB_BORROW(r2, 0, r2, carry, carry);
-+ MP_SUB_BORROW(r3, 0, r3, carry, carry);
-+ }
-+ r3b = (int)(r3 >>32);
-+ }
-+
-+ while (r3b < 0) {
-+ MP_ADD_CARRY_ZERO (r0, 1, r0, carry);
-+ MP_ADD_CARRY (r1, MP_DIGIT_MAX <<32, r1, carry, carry);
-+ MP_ADD_CARRY (r2, MP_DIGIT_MAX, r2, carry, carry);
-+ MP_ADD_CARRY (r3, MP_DIGIT_MAX >> 32, r3, carry, carry);
-+ r3b = (int)(r3 >>32);
-+ }
-+ /* check for final reduction */
-+ /* now the only way we are over is if the top 4 words are all ones */
-+ if ((r3 == (MP_DIGIT_MAX >> 32)) && (r2 == MP_DIGIT_MAX)
-+ && ((r1 & MP_DIGIT_MAX << 32)== MP_DIGIT_MAX << 32) &&
-+ ((r1 != MP_DIGIT_MAX << 32 ) || (r0 != 0)) ) {
-+ /* one last subraction */
-+ MP_SUB_BORROW(r0, 1, r0, 0, carry);
-+ MP_SUB_BORROW(r1, 0, r1, carry, carry);
-+ r2 = r3 = 0;
-+ }
-+
-+
-+ if (a != r) {
-+ MP_CHECKOK(s_mp_pad(r, 4));
-+ }
-+ /* set the lower words of r */
-+ MP_SIGN(r) = MP_ZPOS;
-+ MP_USED(r) = 4;
-+ MP_DIGIT(r, 3) = r3;
-+ MP_DIGIT(r, 2) = r2;
-+ MP_DIGIT(r, 1) = r1;
-+ MP_DIGIT(r, 0) = r0;
-+#endif
-+ }
-+
-+ CLEANUP:
-+ return res;
-+}
-+
-+/* Compute the square of polynomial a, reduce modulo p224. Store the
-+ * result in r. r could be a. Uses optimized modular reduction for p224.
-+ */
-+mp_err
-+ec_GFp_nistp224_sqr(const mp_int *a, mp_int *r, const GFMethod *meth)
-+{
-+ mp_err res = MP_OKAY;
-+
-+ MP_CHECKOK(mp_sqr(a, r));
-+ MP_CHECKOK(ec_GFp_nistp224_mod(r, r, meth));
-+ CLEANUP:
-+ return res;
-+}
-+
-+/* Compute the product of two polynomials a and b, reduce modulo p224.
-+ * Store the result in r. r could be a or b; a could be b. Uses
-+ * optimized modular reduction for p224. */
-+mp_err
-+ec_GFp_nistp224_mul(const mp_int *a, const mp_int *b, mp_int *r,
-+ const GFMethod *meth)
-+{
-+ mp_err res = MP_OKAY;
-+
-+ MP_CHECKOK(mp_mul(a, b, r));
-+ MP_CHECKOK(ec_GFp_nistp224_mod(r, r, meth));
-+ CLEANUP:
-+ return res;
-+}
-+
-+/* Divides two field elements. If a is NULL, then returns the inverse of
-+ * b. */
-+mp_err
-+ec_GFp_nistp224_div(const mp_int *a, const mp_int *b, mp_int *r,
-+ const GFMethod *meth)
-+{
-+ mp_err res = MP_OKAY;
-+ mp_int t;
-+
-+ /* If a is NULL, then return the inverse of b, otherwise return a/b. */
-+ if (a == NULL) {
-+ return mp_invmod(b, &meth->irr, r);
-+ } else {
-+ /* MPI doesn't support divmod, so we implement it using invmod and
-+ * mulmod. */
-+ MP_CHECKOK(mp_init(&t, FLAG(b)));
-+ MP_CHECKOK(mp_invmod(b, &meth->irr, &t));
-+ MP_CHECKOK(mp_mul(a, &t, r));
-+ MP_CHECKOK(ec_GFp_nistp224_mod(r, r, meth));
-+ CLEANUP:
-+ mp_clear(&t);
-+ return res;
-+ }
-+}
-+
-+/* Wire in fast field arithmetic and precomputation of base point for
-+ * named curves. */
-+mp_err
-+ec_group_set_gfp224(ECGroup *group, ECCurveName name)
-+{
-+ if (name == ECCurve_NIST_P224) {
-+ group->meth->field_mod = &ec_GFp_nistp224_mod;
-+ group->meth->field_mul = &ec_GFp_nistp224_mul;
-+ group->meth->field_sqr = &ec_GFp_nistp224_sqr;
-+ group->meth->field_div = &ec_GFp_nistp224_div;
-+ }
-+ return MP_OKAY;
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.crypto.ec/share/native/libsunec/impl/oid.c jdk11u-ls/src/jdk.crypto.ec/share/native/libsunec/impl/oid.c
---- openjdk/src/jdk.crypto.ec/share/native/libsunec/impl/oid.c 2022-10-12 23:00:07.000000000 +0800
-+++ jdk11u-ls/src/jdk.crypto.ec/share/native/libsunec/impl/oid.c 2023-09-12 13:54:26.297575690 +0800
-@@ -73,13 +73,87 @@
- /* NOTE: prime192v1 is the same as secp192r1, prime256v1 is the
- * same as secp256r1
- */
-+CONST_OID ansiX962prime192v1[] = { ANSI_X962_GFp_OID, 0x01 };
-+CONST_OID ansiX962prime192v2[] = { ANSI_X962_GFp_OID, 0x02 };
-+CONST_OID ansiX962prime192v3[] = { ANSI_X962_GFp_OID, 0x03 };
-+CONST_OID ansiX962prime239v1[] = { ANSI_X962_GFp_OID, 0x04 };
-+CONST_OID ansiX962prime239v2[] = { ANSI_X962_GFp_OID, 0x05 };
-+CONST_OID ansiX962prime239v3[] = { ANSI_X962_GFp_OID, 0x06 };
- CONST_OID ansiX962prime256v1[] = { ANSI_X962_GFp_OID, 0x07 };
-
- /* SECG prime curve OIDs */
-+CONST_OID secgECsecp112r1[] = { SECG_OID, 0x06 };
-+CONST_OID secgECsecp112r2[] = { SECG_OID, 0x07 };
-+CONST_OID secgECsecp128r1[] = { SECG_OID, 0x1c };
-+CONST_OID secgECsecp128r2[] = { SECG_OID, 0x1d };
-+CONST_OID secgECsecp160k1[] = { SECG_OID, 0x09 };
-+CONST_OID secgECsecp160r1[] = { SECG_OID, 0x08 };
-+CONST_OID secgECsecp160r2[] = { SECG_OID, 0x1e };
-+CONST_OID secgECsecp192k1[] = { SECG_OID, 0x1f };
-+CONST_OID secgECsecp224k1[] = { SECG_OID, 0x20 };
-+CONST_OID secgECsecp224r1[] = { SECG_OID, 0x21 };
- CONST_OID secgECsecp256k1[] = { SECG_OID, 0x0a };
- CONST_OID secgECsecp384r1[] = { SECG_OID, 0x22 };
- CONST_OID secgECsecp521r1[] = { SECG_OID, 0x23 };
-
-+/* SECG characterisitic two curve OIDs */
-+CONST_OID secgECsect113r1[] = {SECG_OID, 0x04 };
-+CONST_OID secgECsect113r2[] = {SECG_OID, 0x05 };
-+CONST_OID secgECsect131r1[] = {SECG_OID, 0x16 };
-+CONST_OID secgECsect131r2[] = {SECG_OID, 0x17 };
-+CONST_OID secgECsect163k1[] = {SECG_OID, 0x01 };
-+CONST_OID secgECsect163r1[] = {SECG_OID, 0x02 };
-+CONST_OID secgECsect163r2[] = {SECG_OID, 0x0f };
-+CONST_OID secgECsect193r1[] = {SECG_OID, 0x18 };
-+CONST_OID secgECsect193r2[] = {SECG_OID, 0x19 };
-+CONST_OID secgECsect233k1[] = {SECG_OID, 0x1a };
-+CONST_OID secgECsect233r1[] = {SECG_OID, 0x1b };
-+CONST_OID secgECsect239k1[] = {SECG_OID, 0x03 };
-+CONST_OID secgECsect283k1[] = {SECG_OID, 0x10 };
-+CONST_OID secgECsect283r1[] = {SECG_OID, 0x11 };
-+CONST_OID secgECsect409k1[] = {SECG_OID, 0x24 };
-+CONST_OID secgECsect409r1[] = {SECG_OID, 0x25 };
-+CONST_OID secgECsect571k1[] = {SECG_OID, 0x26 };
-+CONST_OID secgECsect571r1[] = {SECG_OID, 0x27 };
-+
-+/* ANSI X9.62 characteristic two curve OIDs */
-+CONST_OID ansiX962c2pnb163v1[] = { ANSI_X962_GF2m_OID, 0x01 };
-+CONST_OID ansiX962c2pnb163v2[] = { ANSI_X962_GF2m_OID, 0x02 };
-+CONST_OID ansiX962c2pnb163v3[] = { ANSI_X962_GF2m_OID, 0x03 };
-+CONST_OID ansiX962c2pnb176v1[] = { ANSI_X962_GF2m_OID, 0x04 };
-+CONST_OID ansiX962c2tnb191v1[] = { ANSI_X962_GF2m_OID, 0x05 };
-+CONST_OID ansiX962c2tnb191v2[] = { ANSI_X962_GF2m_OID, 0x06 };
-+CONST_OID ansiX962c2tnb191v3[] = { ANSI_X962_GF2m_OID, 0x07 };
-+CONST_OID ansiX962c2onb191v4[] = { ANSI_X962_GF2m_OID, 0x08 };
-+CONST_OID ansiX962c2onb191v5[] = { ANSI_X962_GF2m_OID, 0x09 };
-+CONST_OID ansiX962c2pnb208w1[] = { ANSI_X962_GF2m_OID, 0x0a };
-+CONST_OID ansiX962c2tnb239v1[] = { ANSI_X962_GF2m_OID, 0x0b };
-+CONST_OID ansiX962c2tnb239v2[] = { ANSI_X962_GF2m_OID, 0x0c };
-+CONST_OID ansiX962c2tnb239v3[] = { ANSI_X962_GF2m_OID, 0x0d };
-+CONST_OID ansiX962c2onb239v4[] = { ANSI_X962_GF2m_OID, 0x0e };
-+CONST_OID ansiX962c2onb239v5[] = { ANSI_X962_GF2m_OID, 0x0f };
-+CONST_OID ansiX962c2pnb272w1[] = { ANSI_X962_GF2m_OID, 0x10 };
-+CONST_OID ansiX962c2pnb304w1[] = { ANSI_X962_GF2m_OID, 0x11 };
-+CONST_OID ansiX962c2tnb359v1[] = { ANSI_X962_GF2m_OID, 0x12 };
-+CONST_OID ansiX962c2pnb368w1[] = { ANSI_X962_GF2m_OID, 0x13 };
-+CONST_OID ansiX962c2tnb431r1[] = { ANSI_X962_GF2m_OID, 0x14 };
-+
-+/* TeleTrusT ECC Brainpool prime curve OIDs */
-+CONST_OID brainpoolP160r1[] = { ECC_BRAINPOOL_EC_V1, 0x01 };
-+CONST_OID brainpoolP160t1[] = { ECC_BRAINPOOL_EC_V1, 0x02 };
-+CONST_OID brainpoolP192r1[] = { ECC_BRAINPOOL_EC_V1, 0x03 };
-+CONST_OID brainpoolP192t1[] = { ECC_BRAINPOOL_EC_V1, 0x04 };
-+CONST_OID brainpoolP224r1[] = { ECC_BRAINPOOL_EC_V1, 0x05 };
-+CONST_OID brainpoolP224t1[] = { ECC_BRAINPOOL_EC_V1, 0x06 };
-+CONST_OID brainpoolP256r1[] = { ECC_BRAINPOOL_EC_V1, 0x07 };
-+CONST_OID brainpoolP256t1[] = { ECC_BRAINPOOL_EC_V1, 0x08 };
-+CONST_OID brainpoolP320r1[] = { ECC_BRAINPOOL_EC_V1, 0x09 };
-+CONST_OID brainpoolP320t1[] = { ECC_BRAINPOOL_EC_V1, 0x0a };
-+CONST_OID brainpoolP384r1[] = { ECC_BRAINPOOL_EC_V1, 0x0b };
-+CONST_OID brainpoolP384t1[] = { ECC_BRAINPOOL_EC_V1, 0x0c };
-+CONST_OID brainpoolP512r1[] = { ECC_BRAINPOOL_EC_V1, 0x0d };
-+CONST_OID brainpoolP512t1[] = { ECC_BRAINPOOL_EC_V1, 0x0e };
-+
- #define OI(x) { siDEROID, (unsigned char *)x, sizeof x }
- #ifndef SECOID_NO_STRINGS
- #define OD(oid,tag,desc,mech,ext) { OI(oid), tag, desc, mech, ext }
-@@ -100,18 +174,30 @@
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( ansiX962prime192v1, ECCurve_NIST_P192,
-+ "ANSI X9.62 elliptic curve prime192v1 (aka secp192r1, NIST P-192)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962prime192v2, ECCurve_X9_62_PRIME_192V2,
-+ "ANSI X9.62 elliptic curve prime192v2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962prime192v3, ECCurve_X9_62_PRIME_192V3,
-+ "ANSI X9.62 elliptic curve prime192v3",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962prime239v1, ECCurve_X9_62_PRIME_239V1,
-+ "ANSI X9.62 elliptic curve prime239v1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962prime239v2, ECCurve_X9_62_PRIME_239V2,
-+ "ANSI X9.62 elliptic curve prime239v2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962prime239v3, ECCurve_X9_62_PRIME_239V3,
-+ "ANSI X9.62 elliptic curve prime239v3",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- OD( ansiX962prime256v1, ECCurve_NIST_P256,
- "ANSI X9.62 elliptic curve prime256v1 (aka secp256r1, NIST P-256)",
- CKM_INVALID_MECHANISM,
-@@ -122,24 +208,42 @@
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( secgECsect163k1, ECCurve_NIST_K163,
-+ "SECG elliptic curve sect163k1 (aka NIST K-163)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect163r1, ECCurve_SECG_CHAR2_163R1,
-+ "SECG elliptic curve sect163r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect239k1, ECCurve_SECG_CHAR2_239K1,
-+ "SECG elliptic curve sect239k1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect113r1, ECCurve_SECG_CHAR2_113R1,
-+ "SECG elliptic curve sect113r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect113r2, ECCurve_SECG_CHAR2_113R2,
-+ "SECG elliptic curve sect113r2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp112r1, ECCurve_SECG_PRIME_112R1,
-+ "SECG elliptic curve secp112r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp112r2, ECCurve_SECG_PRIME_112R2,
-+ "SECG elliptic curve secp112r2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp160r1, ECCurve_SECG_PRIME_160R1,
-+ "SECG elliptic curve secp160r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp160k1, ECCurve_SECG_PRIME_160K1,
-+ "SECG elliptic curve secp160k1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- OD( secgECsecp256k1, ECCurve_SECG_PRIME_256K1,
- "SECG elliptic curve secp256k1",
- CKM_INVALID_MECHANISM,
-@@ -152,6 +256,18 @@
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( secgECsect163r2, ECCurve_NIST_B163,
-+ "SECG elliptic curve sect163r2 (aka NIST B-163)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect283k1, ECCurve_NIST_K283,
-+ "SECG elliptic curve sect283k1 (aka NIST K-283)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect283r1, ECCurve_NIST_B283,
-+ "SECG elliptic curve sect283r1 (aka NIST B-283)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
- { { siDEROID, NULL, 0 }, ECCurve_noName,
-@@ -160,36 +276,54 @@
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( secgECsect131r1, ECCurve_SECG_CHAR2_131R1,
-+ "SECG elliptic curve sect131r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect131r2, ECCurve_SECG_CHAR2_131R2,
-+ "SECG elliptic curve sect131r2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect193r1, ECCurve_SECG_CHAR2_193R1,
-+ "SECG elliptic curve sect193r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect193r2, ECCurve_SECG_CHAR2_193R2,
-+ "SECG elliptic curve sect193r2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect233k1, ECCurve_NIST_K233,
-+ "SECG elliptic curve sect233k1 (aka NIST K-233)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect233r1, ECCurve_NIST_B233,
-+ "SECG elliptic curve sect233r1 (aka NIST B-233)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp128r1, ECCurve_SECG_PRIME_128R1,
-+ "SECG elliptic curve secp128r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp128r2, ECCurve_SECG_PRIME_128R2,
-+ "SECG elliptic curve secp128r2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp160r2, ECCurve_SECG_PRIME_160R2,
-+ "SECG elliptic curve secp160r2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp192k1, ECCurve_SECG_PRIME_192K1,
-+ "SECG elliptic curve secp192k1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp224k1, ECCurve_SECG_PRIME_224K1,
-+ "SECG elliptic curve secp224k1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsecp224r1, ECCurve_NIST_P224,
-+ "SECG elliptic curve secp224r1 (aka NIST P-224)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- OD( secgECsecp384r1, ECCurve_NIST_P384,
- "SECG elliptic curve secp384r1 (aka NIST P-384)",
- CKM_INVALID_MECHANISM,
-@@ -198,14 +332,22 @@
- "SECG elliptic curve secp521r1 (aka NIST P-521)",
- CKM_INVALID_MECHANISM,
- INVALID_CERT_EXTENSION ),
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION }
-+ OD( secgECsect409k1, ECCurve_NIST_K409,
-+ "SECG elliptic curve sect409k1 (aka NIST K-409)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect409r1, ECCurve_NIST_B409,
-+ "SECG elliptic curve sect409r1 (aka NIST B-409)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect571k1, ECCurve_NIST_K571,
-+ "SECG elliptic curve sect571k1 (aka NIST K-571)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( secgECsect571r1, ECCurve_NIST_B571,
-+ "SECG elliptic curve sect571r1 (aka NIST B-571)",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION )
- };
+ srcx -= dstx;
+ srcy -= dsty;
+ SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h
+index a85151699..0667493fe 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h
+@@ -4,7 +4,7 @@
+ *
+ * ANSI-specific configuration file (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h
+index e607bce15..f6ef2618d 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h
+@@ -4,7 +4,7 @@
+ *
+ * Build macros of the FreeType 2 library.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h
+index 4375c7a6f..d29a0a7ce 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h
+@@ -4,7 +4,7 @@
+ *
+ * User-selectable configuration macros (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -757,6 +757,22 @@ FT_BEGIN_HEADER
+ #endif
- static SECOidData ANSI_oids[] = {
-@@ -213,46 +355,78 @@
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-
- /* ANSI X9.62 named elliptic curves (characteristic two field) */
-+ OD( ansiX962c2pnb163v1, ECCurve_X9_62_CHAR2_PNB163V1,
-+ "ANSI X9.62 elliptic curve c2pnb163v1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2pnb163v2, ECCurve_X9_62_CHAR2_PNB163V2,
-+ "ANSI X9.62 elliptic curve c2pnb163v2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2pnb163v3, ECCurve_X9_62_CHAR2_PNB163V3,
-+ "ANSI X9.62 elliptic curve c2pnb163v3",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2pnb176v1, ECCurve_X9_62_CHAR2_PNB176V1,
-+ "ANSI X9.62 elliptic curve c2pnb176v1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb191v1, ECCurve_X9_62_CHAR2_TNB191V1,
-+ "ANSI X9.62 elliptic curve c2tnb191v1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb191v2, ECCurve_X9_62_CHAR2_TNB191V2,
-+ "ANSI X9.62 elliptic curve c2tnb191v2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb191v3, ECCurve_X9_62_CHAR2_TNB191V3,
-+ "ANSI X9.62 elliptic curve c2tnb191v3",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( ansiX962c2pnb208w1, ECCurve_X9_62_CHAR2_PNB208W1,
-+ "ANSI X9.62 elliptic curve c2pnb208w1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb239v1, ECCurve_X9_62_CHAR2_TNB239V1,
-+ "ANSI X9.62 elliptic curve c2tnb239v1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb239v2, ECCurve_X9_62_CHAR2_TNB239V2,
-+ "ANSI X9.62 elliptic curve c2tnb239v2",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb239v3, ECCurve_X9_62_CHAR2_TNB239V3,
-+ "ANSI X9.62 elliptic curve c2tnb239v3",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION }
-+ OD( ansiX962c2pnb272w1, ECCurve_X9_62_CHAR2_PNB272W1,
-+ "ANSI X9.62 elliptic curve c2pnb272w1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2pnb304w1, ECCurve_X9_62_CHAR2_PNB304W1,
-+ "ANSI X9.62 elliptic curve c2pnb304w1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb359v1, ECCurve_X9_62_CHAR2_TNB359V1,
-+ "ANSI X9.62 elliptic curve c2tnb359v1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2pnb368w1, ECCurve_X9_62_CHAR2_PNB368W1,
-+ "ANSI X9.62 elliptic curve c2pnb368w1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
-+ OD( ansiX962c2tnb431r1, ECCurve_X9_62_CHAR2_TNB431R1,
-+ "ANSI X9.62 elliptic curve c2tnb431r1",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION )
- };
- static SECOidData BRAINPOOL_oids[] = {
-@@ -272,14 +446,31 @@
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( brainpoolP256r1, ECCurve_BrainpoolP256r1,
-+ "brainpoolP256r1 domain parameter set",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( brainpoolP320r1, ECCurve_BrainpoolP320r1,
-+ "brainpoolP320r1 domain parameter set",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( brainpoolP384r1, ECCurve_BrainpoolP384r1,
-+ "brainpoolP384r1 domain parameter set",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- { { siDEROID, NULL, 0 }, ECCurve_noName,
- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
-+ OD( brainpoolP512r1, ECCurve_BrainpoolP512r1,
-+ "brainpoolP512r1 domain parameter set",
-+ CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION ),
- { { siDEROID, NULL, 0 }, ECCurve_noName,
-- "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION }
-+ "Unknown OID", CKM_INVALID_MECHANISM,
-+ INVALID_CERT_EXTENSION }
- };
++ /**************************************************************************
++ *
++ * Option `TT_CONFIG_OPTION_GPOS_KERNING` enables a basic GPOS kerning
++ * implementation (for TrueType fonts only). With this defined, FreeType
++ * is able to get kerning pair data from the GPOS 'kern' feature as well as
++ * legacy 'kern' tables; without this defined, FreeType will only be able
++ * to use legacy 'kern' tables.
++ *
++ * Note that FreeType does not support more advanced GPOS layout features;
++ * even the 'kern' feature implemented here doesn't handle more
++ * sophisticated kerning variants. Use a higher-level library like
++ * HarfBuzz instead for that.
++ */
++/* #define TT_CONFIG_OPTION_GPOS_KERNING */
++
++
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h
+index f65148a90..e17aa7b89 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h
+@@ -5,7 +5,7 @@
+ * ANSI-specific library and header configuration file (specification
+ * only).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h
+index 7258b5085..c27505ffc 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType integer types definitions.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h
+index b77b96d5d..07b6f915b 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h
+@@ -4,7 +4,7 @@
+ *
+ * Mac/OS X support configuration header.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h
+index 23d0fa6a3..f56581a6e 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h
+@@ -4,7 +4,7 @@
+ *
+ * Define a set of compiler macros used in public FreeType headers.
+ *
+- * Copyright (C) 2020-2023 by
++ * Copyright (C) 2020-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h b/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h
+index 92acf3794..58fc33dfe 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType high-level API and common types (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -1322,9 +1322,13 @@ FT_BEGIN_HEADER
+ * FT_FACE_FLAG_KERNING ::
+ * The face contains kerning information. If set, the kerning distance
+ * can be retrieved using the function @FT_Get_Kerning. Otherwise the
+- * function always returns the vector (0,0). Note that FreeType
+- * doesn't handle kerning data from the SFNT 'GPOS' table (as present
+- * in many OpenType fonts).
++ * function always returns the vector (0,0).
++ *
++ * Note that for TrueType fonts only, FreeType supports both the 'kern'
++ * table and the basic, pair-wise kerning feature from the 'GPOS' table
++ * (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled), though FreeType does
++ * not support the more advanced GPOS layout features; use a library
++ * like HarfBuzz for those instead.
+ *
+ * FT_FACE_FLAG_FAST_GLYPHS ::
+ * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT.
+@@ -3767,87 +3771,18 @@ FT_BEGIN_HEADER
+ * pixels and use the @FT_PIXEL_MODE_LCD_V mode.
+ *
+ * FT_RENDER_MODE_SDF ::
+- * This mode corresponds to 8-bit, single-channel signed distance field
+- * (SDF) bitmaps. Each pixel in the SDF grid is the value from the
+- * pixel's position to the nearest glyph's outline. The distances are
+- * calculated from the center of the pixel and are positive if they are
+- * filled by the outline (i.e., inside the outline) and negative
+- * otherwise. Check the note below on how to convert the output values
+- * to usable data.
++ * The positive (unsigned) 8-bit bitmap values can be converted to the
++ * single-channel signed distance field (SDF) by subtracting 128, with
++ * the positive and negative results corresponding to the inside and
++ * the outside of a glyph contour, respectively. The distance units are
++ * arbitrarily determined by an adjustable @spread property.
+ *
+ * @note:
+- * The selected render mode only affects vector glyphs of a font.
++ * The selected render mode only affects scalable vector glyphs of a font.
+ * Embedded bitmaps often have a different pixel mode like
+ * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them
+ * into 8-bit pixmaps.
+ *
+- * For @FT_RENDER_MODE_SDF the output bitmap buffer contains normalized
+- * distances that are packed into unsigned 8-bit values. To get pixel
+- * values in floating point representation use the following pseudo-C
+- * code for the conversion.
+- *
+- * ```
+- * // Load glyph and render using FT_RENDER_MODE_SDF,
+- * // then use the output buffer as follows.
+- *
+- * ...
+- * FT_Byte buffer = glyph->bitmap->buffer;
+- *
+- *
+- * for pixel in buffer
+- * {
+- * // `sd` is the signed distance and `spread` is the current spread;
+- * // the default spread is 2 and can be changed.
+- *
+- * float sd = (float)pixel - 128.0f;
+- *
+- *
+- * // Convert to pixel values.
+- * sd = ( sd / 128.0f ) * spread;
+- *
+- * // Store `sd` in a buffer or use as required.
+- * }
+- *
+- * ```
+- *
+- * FreeType has two rasterizers for generating SDF, namely:
+- *
+- * 1. `sdf` for generating SDF directly from glyph's outline, and
+- *
+- * 2. `bsdf` for generating SDF from rasterized bitmaps.
+- *
+- * Depending on the glyph type (i.e., outline or bitmap), one of the two
+- * rasterizers is chosen at runtime and used for generating SDFs. To
+- * force the use of `bsdf` you should render the glyph with any of the
+- * FreeType's other rendering modes (e.g., `FT_RENDER_MODE_NORMAL`) and
+- * then re-render with `FT_RENDER_MODE_SDF`.
+- *
+- * There are some issues with stability and possible failures of the SDF
+- * renderers (specifically `sdf`).
+- *
+- * 1. The `sdf` rasterizer is sensitive to really small features (e.g.,
+- * sharp turns that are less than 1~pixel) and imperfections in the
+- * glyph's outline, causing artifacts in the final output.
+- *
+- * 2. The `sdf` rasterizer has limited support for handling intersecting
+- * contours and *cannot* handle self-intersecting contours whatsoever.
+- * Self-intersection happens when a single connected contour
+- * intersects itself at some point; having these in your font
+- * definitely poses a problem to the rasterizer and cause artifacts,
+- * too.
+- *
+- * 3. Generating SDF for really small glyphs may result in undesirable
+- * output; the pixel grid (which stores distance information) becomes
+- * too coarse.
+- *
+- * 4. Since the output buffer is normalized, precision at smaller spreads
+- * is greater than precision at larger spread values because the
+- * output range of [0..255] gets mapped to a smaller SDF range. A
+- * spread of~2 should be sufficient in most cases.
+- *
+- * Points (1) and (2) can be avoided by using the `bsdf` rasterizer,
+- * which is more stable than the `sdf` rasterizer in general.
+- *
+ */
+ typedef enum FT_Render_Mode_
+ {
+@@ -4058,9 +3993,26 @@ FT_BEGIN_HEADER
+ * out of the scope of this API function -- they can be implemented
+ * through format-specific interfaces.
+ *
+- * Kerning for OpenType fonts implemented in a 'GPOS' table is not
+- * supported; use @FT_HAS_KERNING to find out whether a font has data
+- * that can be extracted with `FT_Get_Kerning`.
++ * Note that, for TrueType fonts only, this can extract data from both
++ * the 'kern' table and the basic, pair-wise kerning feature from the
++ * GPOS table (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled), though
++ * FreeType does not support the more advanced GPOS layout features; use
++ * a library like HarfBuzz for those instead. If a font has both a
++ * 'kern' table and kern features of a GPOS table, the 'kern' table will
++ * be used.
++ *
++ * Also note for right-to-left scripts, the functionality may differ for
++ * fonts with GPOS tables vs. 'kern' tables. For GPOS, right-to-left
++ * fonts typically use both a placement offset and an advance for pair
++ * positioning, which this API does not support, so it would output
++ * kerning values of zero; though if the right-to-left font used only
++ * advances in GPOS pair positioning, then this API could output kerning
++ * values for it, but it would use `left_glyph` to mean the first glyph
++ * for that case. Whereas 'kern' tables are always advance-only and
++ * always store the left glyph first.
++ *
++ * Use @FT_HAS_KERNING to find out whether a font has data that can be
++ * extracted with `FT_Get_Kerning`.
+ */
+ FT_EXPORT( FT_Error )
+ FT_Get_Kerning( FT_Face face,
+@@ -5222,7 +5174,7 @@ FT_BEGIN_HEADER
+ */
+ #define FREETYPE_MAJOR 2
+ #define FREETYPE_MINOR 13
+-#define FREETYPE_PATCH 2
++#define FREETYPE_PATCH 3
- int
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h jdk11u-ls/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h
---- openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h 2022-10-12 23:00:03.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h 2023-09-12 13:54:26.313575711 +0800
-@@ -22,6 +22,13 @@
+
+ /**************************************************************************
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h
+index 4560ded6d..85b8ba255 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h
+@@ -4,7 +4,7 @@
*
- */
+ * Quick computation of advance widths (specification only).
+ *
+- * Copyright (C) 2008-2023 by
++ * Copyright (C) 2008-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h
+index fc21740fc..12bbfa63a 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType exact bbox computation (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h
+index e8ce64312..6f63b0b1e 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType API for accessing BDF-specific strings (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h
+index eb6b4b1ee..df9d46265 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType utility functions for bitmaps (specification).
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h
+index ef2293902..96b2a90fc 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType API for accessing CID font information (specification).
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * Dereg Clegg and Michael Toftdal.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h
+index eae200fdf..420720ddf 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType's glyph color management (specification).
+ *
+- * Copyright (C) 2018-2023 by
++ * Copyright (C) 2018-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h
+index 7af7465bc..1b7f539f5 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType API for controlling driver modules (specification only).
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -817,6 +817,80 @@ FT_BEGIN_HEADER
+ * 2.5
+ */
-+/*
-+ * This file has been modified by Loongson Technology in 2022. These
-+ * modifications are Copyright (c) 2022, Loongson Technology, and are made
-+ * available on the same license terms set forth above.
-+ *
-+ */
+
- #ifndef _LIBPROC_H_
- #define _LIBPROC_H_
++ /**************************************************************************
++ *
++ * @property:
++ * spread
++ *
++ * @description:
++ * This property of the 'sdf' and 'bsdf' renderers defines how the signed
++ * distance field (SDF) is represented in the output bitmap. The output
++ * values are calculated as follows, '128 * ( SDF / spread + 1 )', with
++ * the result clamped to the 8-bit range [0..255]. Therefore, 'spread'
++ * is also the maximum euclidean distance from the edge after which the
++ * values are clamped. The spread is specified in pixels with the
++ * default value of 8. For accurate SDF texture mapping (interpolation),
++ * the spread should be large enough to accommodate the target grid unit.
++ *
++ * @example:
++ * The following example code demonstrates how to set the SDF spread
++ * (omitting the error handling).
++ *
++ * ```
++ * FT_Library library;
++ * FT_Int spread = 2;
++ *
++ *
++ * FT_Init_FreeType( &library );
++ *
++ * FT_Property_Set( library, "sdf", "spread", &spread );
++ * ```
++ *
++ * @note:
++ * FreeType has two rasterizers for generating SDF, namely:
++ *
++ * 1. `sdf` for generating SDF directly from glyph's outline, and
++ *
++ * 2. `bsdf` for generating SDF from rasterized bitmaps.
++ *
++ * Depending on the glyph type (i.e., outline or bitmap), one of the two
++ * rasterizers is chosen at runtime and used for generating SDFs. To
++ * force the use of `bsdf` you should render the glyph with any of the
++ * FreeType's other rendering modes (e.g., `FT_RENDER_MODE_NORMAL`) and
++ * then re-render with `FT_RENDER_MODE_SDF`.
++ *
++ * There are some issues with stability and possible failures of the SDF
++ * renderers (specifically `sdf`).
++ *
++ * 1. The `sdf` rasterizer is sensitive to really small features (e.g.,
++ * sharp turns that are less than 1~pixel) and imperfections in the
++ * glyph's outline, causing artifacts in the final output.
++ *
++ * 2. The `sdf` rasterizer has limited support for handling intersecting
++ * contours and *cannot* handle self-intersecting contours whatsoever.
++ * Self-intersection happens when a single connected contour
++ * intersects itself at some point; having these in your font
++ * definitely poses a problem to the rasterizer and cause artifacts,
++ * too.
++ *
++ * 3. Generating SDF for really small glyphs may result in undesirable
++ * output; the pixel grid (which stores distance information) becomes
++ * too coarse.
++ *
++ * 4. Since the output buffer is normalized, precision at smaller spreads
++ * is greater than precision at larger spread values because the
++ * output range of [0..255] gets mapped to a smaller SDF range. A
++ * spread of~2 should be sufficient in most cases.
++ *
++ * Points (1) and (2) can be avoided by using the `bsdf` rasterizer,
++ * which is more stable than the `sdf` rasterizer in general.
++ *
++ * @since:
++ * 2.11
++ */
++
++
+ /**************************************************************************
+ *
+ * @property:
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h b/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h
+index d59b3cc2d..710ca91bb 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType error codes (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h b/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h
+index 15ef3f76b..27c0ece5c 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType error code handling (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h
+index c0018fc83..7c8b0874a 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h
+@@ -4,7 +4,7 @@
+ *
+ * Support functions for font formats.
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h
+index d5f19add8..30e5a9bf8 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h
+@@ -4,7 +4,7 @@
+ *
+ * Access of TrueType's 'gasp' table (specification).
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h
+index 4658895f7..dc1eb8873 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType convenience functions to handle glyphs (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h
+index 443ec29db..9516dc030 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h
+@@ -4,7 +4,7 @@
+ *
+ * Gzip-compressed stream support.
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h
+index 6baa81256..2b4b4ac60 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h
+@@ -5,7 +5,7 @@
+ * FreeType glyph image formats and default raster interface
+ * (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -21,6 +21,11 @@
+ * Note: A 'raster' is simply a scan-line converter, used to render
+ * `FT_Outline`s into `FT_Bitmap`s.
+ *
++ * Note: This file can be used for `STANDALONE_` compilation of raster
++ * (B/W) and smooth (anti-aliased) renderers. Therefore, it must
++ * rely on standard variable types only instead of aliases in
++ * `fttypes.h`.
++ *
+ */
-@@ -37,13 +44,17 @@
- #include
- #define user_regs_struct pt_regs
- #endif
--#if defined(aarch64) || defined(arm64)
-+#if defined(aarch64) || defined(arm64) || defined(loongarch64)
- #include
- #define user_regs_struct user_pt_regs
- #elif defined(arm)
- #include
- #define user_regs_struct pt_regs
- #endif
-+#if defined(mips) || defined(mipsel) || defined(mips64) || defined(mips64el)
-+#include
-+#define user_regs_struct pt_regs
-+#endif
- // This C bool type must be int for compatibility with Linux calls and
- // it would be a mistake to equivalence it to C++ bool on many platforms
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c jdk11u-ls/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c
---- openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c 2022-10-12 23:00:03.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c 2023-09-12 13:54:26.313575711 +0800
-@@ -22,6 +22,13 @@
+@@ -318,7 +323,7 @@ FT_BEGIN_HEADER
+ *
+ * If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in
+ * the OpenType specification; the value is the same as the argument to
+- * the 'SCANMODE' instruction).
++ * the 'SCANTYPE' instruction).
+ *
+ * Bits 3 and~4 are reserved for internal purposes.
+ *
+@@ -341,14 +346,14 @@ FT_BEGIN_HEADER
+ */
+ typedef struct FT_Outline_
+ {
+- short n_contours; /* number of contours in glyph */
+- short n_points; /* number of points in the glyph */
++ unsigned short n_contours; /* number of contours in glyph */
++ unsigned short n_points; /* number of points in the glyph */
+
+- FT_Vector* points; /* the outline's points */
+- char* tags; /* the points flags */
+- short* contours; /* the contour end points */
++ FT_Vector* points; /* the outline's points */
++ unsigned char* tags; /* the points flags */
++ unsigned short* contours; /* the contour end points */
+
+- int flags; /* outline masks */
++ int flags; /* outline masks */
+
+ } FT_Outline;
+
+@@ -356,8 +361,8 @@ FT_BEGIN_HEADER
+
+ /* Following limits must be consistent with */
+ /* FT_Outline.{n_contours,n_points} */
+-#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX
+-#define FT_OUTLINE_POINTS_MAX SHRT_MAX
++#define FT_OUTLINE_CONTOURS_MAX USHRT_MAX
++#define FT_OUTLINE_POINTS_MAX USHRT_MAX
+
+
+ /**************************************************************************
+@@ -434,8 +439,8 @@ FT_BEGIN_HEADER
+ * rasterizer; see the `tags` field in @FT_Outline.
+ *
+ * Please refer to the description of the 'SCANTYPE' instruction in the
+- * OpenType specification (in file `ttinst1.doc`) how simple drop-outs,
+- * smart drop-outs, and stubs are defined.
++ * [OpenType specification](https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#scantype)
++ * how simple drop-outs, smart drop-outs, and stubs are defined.
+ */
+ #define FT_OUTLINE_NONE 0x0
+ #define FT_OUTLINE_OWNER 0x1
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h
+index 2d4f5def2..816581b78 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h
+@@ -4,7 +4,7 @@
*
- */
+ * FreeType incremental loading (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h
+index d3723e16f..25274dc4a 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h
+@@ -5,7 +5,7 @@
+ * FreeType API for color filtering of subpixel bitmap glyphs
+ * (specification).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h
+index b55313133..972fbfa2f 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h
+@@ -4,7 +4,7 @@
+ *
+ * Generic list support for FreeType (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h
+index 53b8b8964..1813cfc2c 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h
+@@ -4,7 +4,7 @@
+ *
+ * Additional debugging APIs.
+ *
+- * Copyright (C) 2020-2023 by
++ * Copyright (C) 2020-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h
+index a91e38f9e..e4efde33d 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h
+@@ -4,7 +4,7 @@
+ *
+ * Additional Mac-specific API.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h
+index d145128a9..35ed039c8 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType Multiple Master font interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -19,8 +19,13 @@
+ #ifndef FTMM_H_
+ #define FTMM_H_
-+/*
-+ * This file has been modified by Loongson Technology in 2022. These
-+ * modifications are Copyright (c) 2021, 2022, Loongson Technology, and are made
-+ * available on the same license terms set forth above.
-+ *
-+ */
-+
- #include
- #include "libproc.h"
- #include "proc_service.h"
-@@ -54,10 +61,18 @@
- #include "sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext.h"
- #endif
++#include
-+#if defined(mips64) || defined(mips64el)
-+#include "sun_jvm_hotspot_debugger_mips64_MIPS64ThreadContext.h"
+-#include
++#ifdef FREETYPE_H
++#error "freetype.h of FreeType 1 has been loaded!"
++#error "Please fix the directory search order for header files"
++#error "so that freetype.h of FreeType 2 is found first."
+#endif
-+
- #ifdef aarch64
- #include "sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext.h"
- #endif
-+#ifdef loongarch64
-+#include "sun_jvm_hotspot_debugger_loongarch64_LOONGARCH64ThreadContext.h"
-+#endif
-+
- static jfieldID p_ps_prochandle_ID = 0;
- static jfieldID threadList_ID = 0;
- static jfieldID loadObjectList_ID = 0;
-@@ -397,7 +412,7 @@
- return (err == PS_OK)? array : 0;
- }
--#if defined(i386) || defined(amd64) || defined(sparc) || defined(sparcv9) | defined(ppc64) || defined(ppc64le) || defined(aarch64)
-+#if defined(i386) || defined(amd64) || defined(sparc) || defined(sparcv9) | defined(ppc64) || defined(ppc64le) || defined(aarch64) || defined(loongarch64)
- JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getThreadIntegerRegisterSet0
- (JNIEnv *env, jobject this_obj, jint lwp_id) {
+ FT_BEGIN_HEADER
+@@ -53,6 +58,30 @@ FT_BEGIN_HEADER
+ */
-@@ -425,9 +440,15 @@
- #if defined(sparc) || defined(sparcv9)
- #define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG
- #endif
-+#ifdef loongarch64
-+#define NPRGREG sun_jvm_hotspot_debugger_loongarch64_LOONGARCH64ThreadContext_NPRGREG
-+#endif
- #if defined(ppc64) || defined(ppc64le)
- #define NPRGREG sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_NPRGREG
- #endif
-+#if defined(mips64) || defined(mips64el)
-+#define NPRGREG sun_jvm_hotspot_debugger_mips64_MIPS64ThreadContext_NPRGREG
-+#endif
++ /**************************************************************************
++ *
++ * @enum:
++ * T1_MAX_MM_XXX
++ *
++ * @description:
++ * Multiple Masters limits as defined in their specifications.
++ *
++ * @values:
++ * T1_MAX_MM_AXIS ::
++ * The maximum number of Multiple Masters axes.
++ *
++ * T1_MAX_MM_DESIGNS ::
++ * The maximum number of Multiple Masters designs.
++ *
++ * T1_MAX_MM_MAP_POINTS ::
++ * The maximum number of elements in a design map.
++ *
++ */
++#define T1_MAX_MM_AXIS 4
++#define T1_MAX_MM_DESIGNS 16
++#define T1_MAX_MM_MAP_POINTS 20
++
++
+ /**************************************************************************
+ *
+ * @struct:
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h
+index c8f0c2c2a..0ee715898 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType modules public interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h
+index c8c892dcc..6722fbf8b 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType module error offsets (specification).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h
+index f9329ca40..44e94b4f5 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h
+@@ -5,7 +5,7 @@
+ * Support for the FT_Outline type used to store glyph shapes of
+ * most scalable font formats (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -112,7 +112,7 @@ FT_BEGIN_HEADER
+ * Degenerate contours, segments, and Bezier arcs may be reported. In
+ * most cases, it is best to filter these out before using the outline
+ * for stroking or other path modification purposes (which may cause
+- * degenerate segments to become non-degenrate and visible, like when
++ * degenerate segments to become non-degenerate and visible, like when
+ * stroke caps are used or the path is otherwise outset). Some glyph
+ * outlines may contain deliberate degenerate single points for mark
+ * attachement.
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h
+index 6a9f243bc..43bf69c20 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType API for possible FT_Parameter tags (specification only).
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h
+index 0b6fad32e..dc5018a1b 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType renderer modules public interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h
+index 7bfb1aed4..4ef5c7955 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType size objects management (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h
+index 9d5d22bb2..d5d5cd931 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h
+@@ -7,7 +7,7 @@
+ *
+ * This is _not_ used to retrieve glyph names!
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h
+index b3d90802a..41626dc9d 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType path stroker (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h
+index af90967dd..43081b6c3 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h
+@@ -5,7 +5,7 @@
+ * FreeType synthesizing code for emboldening and slanting
+ * (specification).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h
+index 3a08f4912..1eacb3af3 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType low-level system interface definition (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h b/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h
+index 294981a6f..a5299e938 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType trigonometric functions (specification).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h
+index 5b109f0c7..27815143a 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType simple types definitions (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h
+index bf9c8b7cf..8865d53b3 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level 'autohint' module-specific interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h
+index 50d535384..36b0390a5 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h
+@@ -4,7 +4,7 @@
+ *
+ * Basic OpenType/CFF object type definitions (specification).
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h
+index c2521764c..ef2e8e756 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h
+@@ -5,7 +5,7 @@
+ * Basic OpenType/CFF type definitions and interface (specification
+ * only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -248,10 +248,10 @@ FT_BEGIN_HEADER
+ FT_Byte num_family_blues;
+ FT_Byte num_family_other_blues;
- array = (*env)->NewLongArray(env, NPRGREG);
-@@ -534,6 +555,18 @@
- }
- #endif /* aarch64 */
+- FT_Pos blue_values[14];
+- FT_Pos other_blues[10];
+- FT_Pos family_blues[14];
+- FT_Pos family_other_blues[10];
++ FT_Fixed blue_values[14];
++ FT_Fixed other_blues[10];
++ FT_Fixed family_blues[14];
++ FT_Fixed family_other_blues[10];
-+#if defined(loongarch64)
-+
-+#define REG_INDEX(reg) sun_jvm_hotspot_debugger_loongarch64_LOONGARCH64ThreadContext_##reg
-+
-+ {
-+ int i;
-+ for (i = 0; i < 31; i++)
-+ regs[i] = gregs.regs[i];
-+ regs[REG_INDEX(PC)] = gregs.csr_era;
-+ }
-+#endif /* loongarch64 */
-+
- #if defined(ppc64) || defined(ppc64le)
- #define REG_INDEX(reg) sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_##reg
+ FT_Fixed blue_scale;
+ FT_Pos blue_shift;
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h
+index 6f6765097..876f66e25 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h
+@@ -4,7 +4,7 @@
+ *
+ * Compiler-specific macro definitions used internally by FreeType.
+ *
+- * Copyright (C) 2020-2023 by
++ * Copyright (C) 2020-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h
+index d9aea2360..71128a2df 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h
+@@ -4,7 +4,7 @@
+ *
+ * Arithmetic computations (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -415,7 +415,7 @@ FT_BEGIN_HEADER
-@@ -574,6 +607,45 @@
+ #define FT_MSB( x ) ( 31 - _CountLeadingZeros( x ) )
- #endif
+-#elif defined( _M_ARM64 ) || defined( _M_ARM )
++#elif defined( _M_ARM64 ) || defined( _M_ARM ) || defined( _M_ARM64EC )
-+#if defined(mips64) || defined(mips64el)
+ #include
+ #pragma intrinsic( _CountLeadingZeros )
+@@ -455,6 +455,12 @@ FT_BEGIN_HEADER
+
+ #define FT_MSB( x ) FT_MSB_i386( x )
+
++#elif defined( __SunOS_5_11 )
+
-+#define REG_INDEX(reg) sun_jvm_hotspot_debugger_mips64_MIPS64ThreadContext_##reg
++#include
+
-+ regs[REG_INDEX(ZERO)] = gregs.regs[0];
-+ regs[REG_INDEX(AT)] = gregs.regs[1];
-+ regs[REG_INDEX(V0)] = gregs.regs[2];
-+ regs[REG_INDEX(V1)] = gregs.regs[3];
-+ regs[REG_INDEX(A0)] = gregs.regs[4];
-+ regs[REG_INDEX(A1)] = gregs.regs[5];
-+ regs[REG_INDEX(A2)] = gregs.regs[6];
-+ regs[REG_INDEX(A3)] = gregs.regs[7];
-+ regs[REG_INDEX(T0)] = gregs.regs[8];
-+ regs[REG_INDEX(T1)] = gregs.regs[9];
-+ regs[REG_INDEX(T2)] = gregs.regs[10];
-+ regs[REG_INDEX(T3)] = gregs.regs[11];
-+ regs[REG_INDEX(T4)] = gregs.regs[12];
-+ regs[REG_INDEX(T5)] = gregs.regs[13];
-+ regs[REG_INDEX(T6)] = gregs.regs[14];
-+ regs[REG_INDEX(T7)] = gregs.regs[15];
-+ regs[REG_INDEX(S0)] = gregs.regs[16];
-+ regs[REG_INDEX(S1)] = gregs.regs[17];
-+ regs[REG_INDEX(S2)] = gregs.regs[18];
-+ regs[REG_INDEX(S3)] = gregs.regs[19];
-+ regs[REG_INDEX(S4)] = gregs.regs[20];
-+ regs[REG_INDEX(S5)] = gregs.regs[21];
-+ regs[REG_INDEX(S6)] = gregs.regs[22];
-+ regs[REG_INDEX(S7)] = gregs.regs[23];
-+ regs[REG_INDEX(T8)] = gregs.regs[24];
-+ regs[REG_INDEX(T9)] = gregs.regs[25];
-+ regs[REG_INDEX(K0)] = gregs.regs[26];
-+ regs[REG_INDEX(K1)] = gregs.regs[27];
-+ regs[REG_INDEX(GP)] = gregs.regs[28];
-+ regs[REG_INDEX(SP)] = gregs.regs[29];
-+ regs[REG_INDEX(FP)] = gregs.regs[30];
-+ regs[REG_INDEX(S8)] = gregs.regs[30];
-+ regs[REG_INDEX(RA)] = gregs.regs[31];
-+#endif /* mips */
++#define FT_MSB( x ) ( fls( x ) - 1 )
+
- (*env)->ReleaseLongArrayElements(env, array, regs, JNI_COMMIT);
- return array;
- }
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c jdk11u-ls/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c
---- openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c 2022-10-12 23:00:03.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c 2023-09-12 13:54:26.313575711 +0800
-@@ -22,6 +22,12 @@
- *
- */
+ #elif defined( __DECC ) || defined( __DECCXX )
-+/*
-+ * This file has been modified by Loongson Technology in 2022, These
-+ * modifications are Copyright (c) 2022, Loongson Technology, and are made
-+ * available on the same license terms set forth above.
-+ */
-+
- #include
- #include
- #include
-@@ -142,7 +148,7 @@
- #define PTRACE_GETREGS_REQ PT_GETREGS
- #endif
+ #include
+@@ -489,8 +495,6 @@ FT_BEGIN_HEADER
+ FT_Fixed y );
--#ifdef PTRACE_GETREGS_REQ
-+#if defined(PTRACE_GETREGS_REQ) && !defined(loongarch64)
- if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) {
- print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid);
- return false;
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java 2022-10-12 23:00:03.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java 2023-09-12 13:54:26.373575786 +0800
-@@ -23,6 +23,12 @@
+
+-#if 0
+-
+ /**************************************************************************
+ *
+ * @function:
+@@ -507,12 +511,11 @@ FT_BEGIN_HEADER
+ * The result of 'sqrt(x)'.
+ *
+ * @note:
+- * This function is not very fast.
++ * This function is slow and should be avoided. Consider @FT_Hypot or
++ * @FT_Vector_NormLen instead.
+ */
+- FT_BASE( FT_Int32 )
+- FT_SqrtFixed( FT_Int32 x );
+-
+-#endif /* 0 */
++ FT_BASE( FT_UInt32 )
++ FT_SqrtFixed( FT_UInt32 x );
+
+
+ #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) * 64 ) /* << 6 */
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h
+index 4e013ba1e..d7fa8dc93 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h
+@@ -4,7 +4,7 @@
*
- */
+ * Debugging and logging component (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h
+index 9001c07ad..5609b3ef1 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType internal font driver interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h
+index 36e5509f9..f1c155b16 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType glyph loader (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h
+index 5eb1d21ff..4e05a29f1 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType memory management macros (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -371,8 +371,11 @@ extern "C++"
+ #define FT_STRDUP( dst, str ) \
+ FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) )
-+/*
-+ * This file has been modified by Loongson Technology in 2022, These
-+ * modifications are Copyright (c) 2019, 2022, Loongson Technology, and are made
-+ * available on the same license terms set forth above.
-+ */
-+
- package sun.jvm.hotspot.debugger.linux;
+-#define FT_MEM_DUP( dst, address, size ) \
+- (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error )
++#define FT_MEM_DUP( dst, address, size ) \
++ FT_ASSIGNP_INNER( dst, ft_mem_dup( memory, \
++ (address), \
++ (FT_ULong)(size), \
++ &error ) )
- import java.io.*;
-@@ -34,12 +40,16 @@
- import sun.jvm.hotspot.debugger.amd64.*;
- import sun.jvm.hotspot.debugger.aarch64.*;
- import sun.jvm.hotspot.debugger.sparc.*;
-+import sun.jvm.hotspot.debugger.mips64.*;
-+import sun.jvm.hotspot.debugger.loongarch64.*;
- import sun.jvm.hotspot.debugger.ppc64.*;
- import sun.jvm.hotspot.debugger.linux.x86.*;
- import sun.jvm.hotspot.debugger.linux.amd64.*;
- import sun.jvm.hotspot.debugger.linux.sparc.*;
- import sun.jvm.hotspot.debugger.linux.ppc64.*;
- import sun.jvm.hotspot.debugger.linux.aarch64.*;
-+import sun.jvm.hotspot.debugger.linux.mips64.*;
-+import sun.jvm.hotspot.debugger.linux.loongarch64.*;
- import sun.jvm.hotspot.utilities.*;
+ #define FT_DUP( dst, address, size ) \
+ FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) )
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h
+index c4b21d614..8449e7a01 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h
+@@ -5,7 +5,7 @@
+ * OpenType Variations type definitions for internal use
+ * with the multi-masters service (specification).
+ *
+- * Copyright (C) 2022-2023 by
++ * Copyright (C) 2022-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and
+ * Dominik Röttsches.
+ *
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h
+index 28bc9b65f..a1e93298f 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType private base classes (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -604,12 +604,6 @@ FT_BEGIN_HEADER
+ #define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
+ #define FT_FACE_STREAM( x ) FT_FACE( x )->stream
- class LinuxCDebugger implements CDebugger {
-@@ -102,7 +112,21 @@
- Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7);
- if (pc == null) return null;
- return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
-- } else if (cpu.equals("ppc64")) {
-+ } else if (cpu.equals("mips64")) {
-+ MIPS64ThreadContext context = (MIPS64ThreadContext) thread.getContext();
-+ Address sp = context.getRegisterAsAddress(MIPS64ThreadContext.SP);
-+ if (sp == null) return null;
-+ Address pc = context.getRegisterAsAddress(MIPS64ThreadContext.PC);
-+ if (pc == null) return null;
-+ return new LinuxMIPS64CFrame(dbg, sp, pc);
-+ } else if (cpu.equals("loongarch64")) {
-+ LOONGARCH64ThreadContext context = (LOONGARCH64ThreadContext) thread.getContext();
-+ Address fp = context.getRegisterAsAddress(LOONGARCH64ThreadContext.FP);
-+ if (fp == null) return null;
-+ Address pc = context.getRegisterAsAddress(LOONGARCH64ThreadContext.PC);
-+ if (pc == null) return null;
-+ return new LinuxLOONGARCH64CFrame(dbg, fp, pc);
-+ } else if (cpu.equals("ppc64")) {
- PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext();
- Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP);
- if (sp == null) return null;
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java 2022-10-12 23:00:03.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java 2023-09-12 13:54:26.373575786 +0800
-@@ -22,6 +22,12 @@
+-#define FT_SIZE_FACE( x ) FT_SIZE( x )->face
+-#define FT_SLOT_FACE( x ) FT_SLOT( x )->face
+-
+-#define FT_FACE_SLOT( x ) FT_FACE( x )->glyph
+-#define FT_FACE_SIZE( x ) FT_FACE( x )->size
+-
+
+ /**************************************************************************
+ *
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h
+index 1d5b287ad..4f11aa16b 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h
+@@ -4,7 +4,7 @@
*
- */
+ * Get and set properties of PostScript drivers (specification).
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h
+index e96459921..05c1d6c48 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h
+@@ -4,7 +4,7 @@
+ *
+ * Embedded resource forks accessor (specification).
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * Masatake YAMATO and Redhat K.K.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h
+index 1e85d6d38..8c35dbd71 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType services (specification only).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h
+index 88e19287c..fd52f767e 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h
+@@ -4,7 +4,7 @@
+ *
+ * Stream handling (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h
+index 319fe56fd..42595a29f 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h
+@@ -4,7 +4,7 @@
+ *
+ * Tracing handling (specification only).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -64,6 +64,7 @@ FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */
+ FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */
+ FT_TRACE_DEF( ttcolr ) /* glyph layer table (ttcolr.c) */
+ FT_TRACE_DEF( ttcpal ) /* color palette table (ttcpal.c) */
++FT_TRACE_DEF( ttgpos ) /* GPOS handler (ttgpos.c) */
+ FT_TRACE_DEF( ttsvg ) /* OpenType SVG table (ttsvg.c) */
+ FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */
+ FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h
+index e98ee4e47..a1312f2ab 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType validation support (specification).
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h
+index dfb1987f8..745d2cb56 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h
+@@ -5,7 +5,7 @@
+ * Auxiliary functions and data structures related to PostScript fonts
+ * (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -225,6 +225,7 @@ FT_BEGIN_HEADER
-+/*
-+ * This file has been modified by Loongson Technology in 2021, These
-+ * modifications are Copyright (c) 2019, 2021, Loongson Technology, and are made
-+ * available on the same license terms set forth above.
-+ */
-+
- package sun.jvm.hotspot.debugger.linux;
+ typedef enum T1_FieldLocation_
+ {
++ T1_FIELD_LOCATION_NONE = 0,
+ T1_FIELD_LOCATION_CID_INFO,
+ T1_FIELD_LOCATION_FONT_DICT,
+ T1_FIELD_LOCATION_FONT_EXTRA,
+@@ -249,6 +250,7 @@ FT_BEGIN_HEADER
+ /* structure type used to model object fields */
+ typedef struct T1_FieldRec_
+ {
++ FT_UInt len; /* field identifier length */
+ const char* ident; /* field identifier */
+ T1_FieldLocation location;
+ T1_FieldType type; /* type of field */
+@@ -273,8 +275,9 @@ FT_BEGIN_HEADER
- import java.lang.reflect.*;
-@@ -30,6 +36,8 @@
- import sun.jvm.hotspot.debugger.linux.x86.*;
- import sun.jvm.hotspot.debugger.linux.ppc64.*;
- import sun.jvm.hotspot.debugger.linux.sparc.*;
-+import sun.jvm.hotspot.debugger.linux.mips64.*;
-+import sun.jvm.hotspot.debugger.linux.loongarch64.*;
+ #define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \
+ { \
++ sizeof ( _ident ) - 1, \
+ _ident, T1CODE, _type, \
+- 0, \
++ NULL, \
+ FT_FIELD_OFFSET( _fname ), \
+ FT_FIELD_SIZE( _fname ), \
+ 0, 0, \
+@@ -283,6 +286,7 @@ FT_BEGIN_HEADER
- class LinuxThreadContextFactory {
- static ThreadContext createThreadContext(LinuxDebugger dbg) {
-@@ -40,7 +48,11 @@
- return new LinuxAMD64ThreadContext(dbg);
- } else if (cpu.equals("sparc")) {
- return new LinuxSPARCThreadContext(dbg);
-- } else if (cpu.equals("ppc64")) {
-+ } else if (cpu.equals("mips64")) {
-+ return new LinuxMIPS64ThreadContext(dbg);
-+ } else if (cpu.equals("loongarch64")) {
-+ return new LinuxLOONGARCH64ThreadContext(dbg);
-+ } else if (cpu.equals("ppc64")) {
- return new LinuxPPC64ThreadContext(dbg);
- } else {
- try {
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64CFrame.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64CFrame.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64CFrame.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64CFrame.java 2023-09-12 13:54:26.373575786 +0800
-@@ -0,0 +1,92 @@
-+/*
-+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2015, 2022, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
-+
-+package sun.jvm.hotspot.debugger.linux.loongarch64;
-+
-+import sun.jvm.hotspot.debugger.*;
-+import sun.jvm.hotspot.debugger.linux.*;
-+import sun.jvm.hotspot.debugger.cdbg.*;
-+import sun.jvm.hotspot.debugger.cdbg.basic.*;
-+import sun.jvm.hotspot.debugger.loongarch64.*;
-+
-+final public class LinuxLOONGARCH64CFrame extends BasicCFrame {
-+ // package/class internals only
-+ public LinuxLOONGARCH64CFrame(LinuxDebugger dbg, Address fp, Address pc) {
-+ super(dbg.getCDebugger());
-+ this.fp = fp;
-+ this.pc = pc;
-+ this.dbg = dbg;
-+ }
+ #define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \
+ { \
++ sizeof ( _ident ) - 1, \
+ _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \
+ (T1_Field_ParseFunc)_reader, \
+ 0, 0, \
+@@ -292,8 +296,9 @@ FT_BEGIN_HEADER
+
+ #define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \
+ { \
++ sizeof ( _ident ) - 1, \
+ _ident, T1CODE, _type, \
+- 0, \
++ NULL, \
+ FT_FIELD_OFFSET( _fname ), \
+ FT_FIELD_SIZE_DELTA( _fname ), \
+ _max, \
+@@ -303,8 +308,9 @@ FT_BEGIN_HEADER
+
+ #define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \
+ { \
++ sizeof ( _ident ) - 1, \
+ _ident, T1CODE, _type, \
+- 0, \
++ NULL, \
+ FT_FIELD_OFFSET( _fname ), \
+ FT_FIELD_SIZE_DELTA( _fname ), \
+ _max, 0, \
+@@ -354,6 +360,13 @@ FT_BEGIN_HEADER
+ #define T1_FIELD_CALLBACK( _ident, _name, _dict ) \
+ T1_NEW_CALLBACK_FIELD( _ident, _name, _dict )
+
++#define T1_FIELD_ZERO \
++ { \
++ 0, \
++ NULL, T1_FIELD_LOCATION_NONE, T1_FIELD_TYPE_NONE, \
++ NULL, 0, 0, 0, 0, 0 \
++ }
+
-+ // override base class impl to avoid ELF parsing
-+ public ClosestSymbol closestSymbolToPC() {
-+ // try native lookup in debugger.
-+ return dbg.lookup(dbg.getAddressValue(pc()));
-+ }
+
+ /*************************************************************************/
+ /*************************************************************************/
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h
+index ededc4c72..dba6c7303 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h
+@@ -6,7 +6,7 @@
+ * recorders (specification only). These are used to support native
+ * T1/T2 hints in the 'type1', 'cid', and 'cff' font drivers.
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h
+index bf0c1dcc7..89e9c2e5d 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType BDF services (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h
+index 4a20498ee..3cb483c34 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType CFF tables loader service (specification).
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h
+index 06d0cb8fd..8362cb872 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType CID font services (specification).
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * Derek Clegg and Michael Toftdal.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h
+index bc45e8056..6b837e79f 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType font format service (specification only).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h
+index 6437abfbf..6126ec9ad 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType glyph dictionary services (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h
+index 31016afe0..29cf55281 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType API for validating TrueTypeGX/AAT tables (specification).
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * Masatake YAMATO, Red Hat K.K.,
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h
+index bcabbc3e6..ac1bc30c4 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType Kerning service (specification).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h
+index 167617ebb..8b3563b25 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType services for metrics variations (specification).
+ *
+- * Copyright (C) 2016-2023 by
++ * Copyright (C) 2016-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h
+index 7e76ab832..5288fadf3 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType Multiple Masters and GX var services (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h
+index a4683cd5f..7aea7ec11 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType OpenType validation service (specification).
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h
+index fd189c7de..b2fac6d08 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h
+@@ -4,7 +4,7 @@
+ *
+ * Internal PFR service functions (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h
+index 2b8f6dfec..d19f3adc6 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType PostScript name services (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h
+index 932ce32e0..ba39c0dd4 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType property service (specification).
+ *
+- * Copyright (C) 2012-2023 by
++ * Copyright (C) 2012-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h
+index 6e599f3aa..d4908ee41 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType PostScript charmap service (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h
+index 09c4cdccc..2aadcdd02 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType PostScript info service (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h
+index f98df2ef5..9e0f4ff20 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType SFNT table loading service (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h
+index 5f9eb02d6..250886bcc 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType TrueType/sfnt cmap extra information service.
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * Masatake YAMATO, Redhat K.K.,
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h
+index ad577cb29..14967529a 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType TrueType engine query service (specification).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h
+index ca6fff744..f190b3985 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType TrueType glyph service.
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * David Turner.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h
+index 002923f8c..49f3fb7f7 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType Windows FNT/FONT service (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h
+index a2d4e15ba..35e4e73af 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level 'sfnt' driver interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -924,6 +924,7 @@ FT_BEGIN_HEADER
+ /* this field was called `load_kerning' up to version 2.1.10 */
+ TT_Load_Table_Func load_kern;
+
++ TT_Load_Table_Func load_gpos;
+ TT_Load_Table_Func load_gasp;
+ TT_Load_Table_Func load_pclt;
+
+@@ -944,6 +945,8 @@ FT_BEGIN_HEADER
+
+ /* new elements introduced after version 2.1.10 */
+
++ TT_Face_GetKerningFunc get_gpos_kerning;
++
+ /* load the font directory, i.e., the offset table and */
+ /* the table directory */
+ TT_Load_Table_Func load_font_dir;
+@@ -1002,6 +1005,7 @@ FT_BEGIN_HEADER
+ load_name_, \
+ free_name_, \
+ load_kern_, \
++ load_gpos_, \
+ load_gasp_, \
+ load_pclt_, \
+ load_bhed_, \
+@@ -1009,6 +1013,7 @@ FT_BEGIN_HEADER
+ get_psname_, \
+ free_psnames_, \
+ get_kerning_, \
++ get_gpos_kerning_, \
+ load_font_dir_, \
+ load_hmtx_, \
+ load_eblc_, \
+@@ -1050,6 +1055,7 @@ FT_BEGIN_HEADER
+ load_name_, \
+ free_name_, \
+ load_kern_, \
++ load_gpos_, \
+ load_gasp_, \
+ load_pclt_, \
+ load_bhed_, \
+@@ -1057,6 +1063,7 @@ FT_BEGIN_HEADER
+ get_psname_, \
+ free_psnames_, \
+ get_kerning_, \
++ get_gpos_kerning_, \
+ load_font_dir_, \
+ load_hmtx_, \
+ load_eblc_, \
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h
+index f464b2c05..68c99efb1 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h
+@@ -4,7 +4,7 @@
+ *
+ * Interface of ot-svg module (specification only).
+ *
+- * Copyright (C) 2022-2023 by
++ * Copyright (C) 2022-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h
+index b9c94398f..1821ae5cc 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h
+@@ -5,7 +5,7 @@
+ * Basic Type1/Type2 type definitions and interface (specification
+ * only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -21,7 +21,7 @@
+ #define T1TYPES_H_
+
+
+-#include
++#include
+ #include
+ #include
+ #include
+@@ -137,6 +137,54 @@ FT_BEGIN_HEADER
+ } CID_SubrsRec, *CID_Subrs;
+
+
++ /* this structure is used to store the BlendDesignMap entry for an axis */
++ typedef struct PS_DesignMap_
++ {
++ FT_Byte num_points;
++ FT_Long* design_points;
++ FT_Fixed* blend_points;
+
-+ public Address pc() {
-+ return pc;
-+ }
++ } PS_DesignMapRec, *PS_DesignMap;
+
-+ public Address localVariableBase() {
-+ return fp;
-+ }
++ /* backward compatible definition */
++ typedef PS_DesignMapRec T1_DesignMap;
+
-+ public CFrame sender(ThreadProxy thread) {
-+ LOONGARCH64ThreadContext context = (LOONGARCH64ThreadContext) thread.getContext();
-+ Address sp = context.getRegisterAsAddress(LOONGARCH64ThreadContext.SP);
-+ Address nextFP;
-+ Address nextPC;
+
-+ if ((fp == null) || fp.lessThan(sp)) {
-+ return null;
-+ }
++ typedef struct PS_BlendRec_
++ {
++ FT_UInt num_designs;
++ FT_UInt num_axis;
+
-+ try {
-+ nextFP = fp.getAddressAt(-2 * ADDRESS_SIZE);
-+ } catch (Exception e) {
-+ return null;
-+ }
-+ if (nextFP == null) {
-+ return null;
-+ }
++ FT_String* axis_names[T1_MAX_MM_AXIS];
++ FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
++ PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
+
-+ try {
-+ nextPC = fp.getAddressAt(-1 * ADDRESS_SIZE);
-+ } catch (Exception e) {
-+ return null;
-+ }
-+ if (nextPC == null) {
-+ return null;
-+ }
++ FT_Fixed* weight_vector;
++ FT_Fixed* default_weight_vector;
+
-+ return new LinuxLOONGARCH64CFrame(dbg, nextFP, nextPC);
-+ }
++ PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
++ PS_Private privates [T1_MAX_MM_DESIGNS + 1];
+
-+ private static final int ADDRESS_SIZE = 8;
-+ private Address pc;
-+ private Address fp;
-+ private LinuxDebugger dbg;
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64ThreadContext.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64ThreadContext.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64ThreadContext.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/loongarch64/LinuxLOONGARCH64ThreadContext.java 2023-09-12 13:54:26.373575786 +0800
-@@ -0,0 +1,47 @@
-+/*
-+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2015, 2021, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
++ FT_ULong blend_bitflags;
+
-+package sun.jvm.hotspot.debugger.linux.loongarch64;
++ FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
+
-+import sun.jvm.hotspot.debugger.*;
-+import sun.jvm.hotspot.debugger.loongarch64.*;
-+import sun.jvm.hotspot.debugger.linux.*;
++ /* since 2.3.0 */
+
-+public class LinuxLOONGARCH64ThreadContext extends LOONGARCH64ThreadContext {
-+ private LinuxDebugger debugger;
++ /* undocumented, optional: the default design instance; */
++ /* corresponds to default_weight_vector -- */
++ /* num_default_design_vector == 0 means it is not present */
++ /* in the font and associated metrics files */
++ FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
++ FT_UInt num_default_design_vector;
+
-+ public LinuxLOONGARCH64ThreadContext(LinuxDebugger debugger) {
-+ super();
-+ this.debugger = debugger;
-+ }
++ } PS_BlendRec, *PS_Blend;
+
-+ public void setRegisterAsAddress(int index, Address value) {
-+ setRegister(index, debugger.getAddressValue(value));
-+ }
+
-+ public Address getRegisterAsAddress(int index) {
-+ return debugger.newAddress(getRegister(index));
-+ }
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64CFrame.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64CFrame.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64CFrame.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64CFrame.java 2023-09-12 13:54:26.373575786 +0800
-@@ -0,0 +1,80 @@
-+/*
-+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2015, 2018, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
++ /* backward compatible definition */
++ typedef PS_BlendRec T1_Blend;
+
-+package sun.jvm.hotspot.debugger.linux.mips64;
+
-+import sun.jvm.hotspot.debugger.*;
-+import sun.jvm.hotspot.debugger.linux.*;
-+import sun.jvm.hotspot.debugger.cdbg.*;
-+import sun.jvm.hotspot.debugger.cdbg.basic.*;
-+import sun.jvm.hotspot.debugger.mips64.*;
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h
+index b9788c783..7053e656a 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h
+@@ -5,7 +5,7 @@
+ * Basic SFNT/TrueType type definitions and interface (specification
+ * only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -24,6 +24,7 @@
+ #include
+ #include
+ #include
++#include "freetype/fttypes.h"
+
+ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ #include
+@@ -1581,6 +1582,11 @@ FT_BEGIN_HEADER
+ FT_UInt32 kern_avail_bits;
+ FT_UInt32 kern_order_bits;
+
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++ FT_Byte* gpos_table;
++ FT_Bool gpos_kerning_available;
++#endif
++
+ #ifdef TT_CONFIG_OPTION_BDF
+ TT_BDFRec bdf;
+ #endif /* TT_CONFIG_OPTION_BDF */
+@@ -1649,9 +1655,9 @@ FT_BEGIN_HEADER
+ {
+ FT_Memory memory;
+ FT_UShort max_points;
+- FT_Short max_contours;
++ FT_UShort max_contours;
+ FT_UShort n_points; /* number of points in zone */
+- FT_Short n_contours; /* number of contours */
++ FT_UShort n_contours; /* number of contours */
+
+ FT_Vector* org; /* original point coordinates */
+ FT_Vector* cur; /* current point coordinates */
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h
+index 0c1d8eeaf..4a169d12f 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h
+@@ -5,7 +5,7 @@
+ * Basic WOFF/WOFF2 type definitions and interface (specification
+ * only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h b/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h
+index bfe9a6ab7..9d356938c 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h
+@@ -4,7 +4,7 @@
+ *
+ * Interface for OT-SVG support related things (specification).
+ *
+- * Copyright (C) 2022-2023 by
++ * Copyright (C) 2022-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h b/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h
+index 1aecfbbd9..fbd558aa3 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h
+@@ -5,7 +5,7 @@
+ * Basic Type 1/Type 2 tables definitions and interface (specification
+ * only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -269,64 +269,6 @@ FT_BEGIN_HEADER
+ /* */
+
+
+- /* maximum number of Multiple Masters designs, as defined in the spec */
+-#define T1_MAX_MM_DESIGNS 16
+-
+- /* maximum number of Multiple Masters axes, as defined in the spec */
+-#define T1_MAX_MM_AXIS 4
+-
+- /* maximum number of elements in a design map */
+-#define T1_MAX_MM_MAP_POINTS 20
+-
+-
+- /* this structure is used to store the BlendDesignMap entry for an axis */
+- typedef struct PS_DesignMap_
+- {
+- FT_Byte num_points;
+- FT_Long* design_points;
+- FT_Fixed* blend_points;
+-
+- } PS_DesignMapRec, *PS_DesignMap;
+-
+- /* backward compatible definition */
+- typedef PS_DesignMapRec T1_DesignMap;
+-
+-
+- typedef struct PS_BlendRec_
+- {
+- FT_UInt num_designs;
+- FT_UInt num_axis;
+-
+- FT_String* axis_names[T1_MAX_MM_AXIS];
+- FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
+- PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
+-
+- FT_Fixed* weight_vector;
+- FT_Fixed* default_weight_vector;
+-
+- PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
+- PS_Private privates [T1_MAX_MM_DESIGNS + 1];
+-
+- FT_ULong blend_bitflags;
+-
+- FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
+-
+- /* since 2.3.0 */
+-
+- /* undocumented, optional: the default design instance; */
+- /* corresponds to default_weight_vector -- */
+- /* num_default_design_vector == 0 means it is not present */
+- /* in the font and associated metrics files */
+- FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
+- FT_UInt num_default_design_vector;
+-
+- } PS_BlendRec, *PS_Blend;
+-
+-
+- /* backward compatible definition */
+- typedef PS_BlendRec T1_Blend;
+-
+-
+ /**************************************************************************
+ *
+ * @struct:
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h b/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h
+index e31c68b9b..d5d470e38 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType name ID definitions (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h b/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h
+index a9f60e762..2cf0ff1bc 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h
+@@ -5,7 +5,7 @@
+ * Basic SFNT/TrueType tables definitions and interface
+ * (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -838,8 +838,9 @@ FT_BEGIN_HEADER
+ * The target charmap.
+ *
+ * @return:
+- * The format of `charmap`. If `charmap` doesn't belong to an SFNT face,
+- * return -1.
++ * The format of `charmap`. If `charmap` doesn't belong to an SFNT face
++ * (including the synthetic Unicode charmap sometimes created by
++ * FreeType), return -1.
+ */
+ FT_EXPORT( FT_Long )
+ FT_Get_CMap_Format( FT_CharMap charmap );
+diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h b/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h
+index 9bf4fca23..da0af5d3f 100644
+--- a/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h
++++ b/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h
+@@ -4,7 +4,7 @@
+ *
+ * Tags for TrueType and OpenType tables (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/include/ft2build.h b/src/java.desktop/share/native/libfreetype/include/ft2build.h
+index 58491ceea..d3d768503 100644
+--- a/src/java.desktop/share/native/libfreetype/include/ft2build.h
++++ b/src/java.desktop/share/native/libfreetype/include/ft2build.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType 2 build and setup macros.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c
+index d7655b9b9..ea83969cd 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c
+@@ -7,7 +7,7 @@
+ *
+ * Auto-fitter data for blue strings (body).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin
+index d561c5093..d2270fac7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter data for blue strings (body).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat
+index 8299baa25..88bab2632 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat
+@@ -2,7 +2,7 @@
+ //
+ // Auto-fitter data for blue strings.
+ //
+-// Copyright (C) 2013-2023 by
++// Copyright (C) 2013-2024 by
+ // David Turner, Robert Wilhelm, and Werner Lemberg.
+ //
+ // This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h
+index 76f2f47cb..2aa9d0984 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h
+@@ -7,7 +7,7 @@
+ *
+ * Auto-fitter data for blue strings (specification).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin
+index 6a31298e6..38031505a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter data for blue strings (specification).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c
+index f414289ad..869b60487 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter hinting routines for CJK writing system (body).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h
+index f380ef6e0..bc5aaf12e 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter hinting routines for CJK writing system (specification).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -84,7 +84,7 @@ FT_BEGIN_HEADER
+ /* used for horizontal metrics too for CJK */
+ FT_Bool control_overshoot;
+ FT_UInt blue_count;
+- AF_CJKBlueRec blues[AF_BLUE_STRINGSET_MAX];
++ AF_CJKBlueRec blues[AF_BLUE_STRINGSET_MAX_LEN];
+
+ FT_Fixed org_scale;
+ FT_Pos org_delta;
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h b/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h
+index 102ed4278..7980cf2e9 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter coverages (specification only).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c
+index a4629b528..ad667d2ed 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c
+@@ -5,7 +5,7 @@
+ * Auto-fitter dummy routines to be used if no hinting should be
+ * performed (body).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h
+index a7af3f62c..613c2f88a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h
+@@ -5,7 +5,7 @@
+ * Auto-fitter dummy routines to be used if no hinting should be
+ * performed (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h b/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h
+index 88faf05c9..ae584ff06 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h
+@@ -4,7 +4,7 @@
+ *
+ * Autofitter error codes (specification only).
+ *
+- * Copyright (C) 2005-2023 by
++ * Copyright (C) 2005-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c
+index b1957570f..b7403fa65 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter routines to compute global hinting values (body).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h
+index 66170e419..ddb54c89b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h
+@@ -5,7 +5,7 @@
+ * Auto-fitter routines to compute global hinting values
+ * (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c
+index e4a378fbf..96ffe343a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter hinting routines (body).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -979,8 +979,8 @@
+ /* compute coordinates & Bezier flags, next and prev */
+ {
+ FT_Vector* vec = outline->points;
+- char* tag = outline->tags;
+- FT_Short endpoint = outline->contours[0];
++ FT_Byte* tag = outline->tags;
++ FT_UShort endpoint = outline->contours[0];
+ AF_Point end = points + endpoint;
+ AF_Point prev = end;
+ FT_Int contour_index = 0;
+@@ -1046,16 +1046,16 @@
+
+ /* set up the contours array */
+ {
+- AF_Point* contour = hints->contours;
+- AF_Point* contour_limit = contour + hints->num_contours;
+- short* end = outline->contours;
+- short idx = 0;
++ AF_Point* contour = hints->contours;
++ AF_Point* contour_limit = contour + hints->num_contours;
++ FT_UShort* end = outline->contours;
++ FT_Int idx = 0;
+
+
+ for ( ; contour < contour_limit; contour++, end++ )
+ {
+ contour[0] = points + idx;
+- idx = (short)( end[0] + 1 );
++ idx = *end + 1;
+ }
+ }
+
+@@ -1292,7 +1292,7 @@
+ AF_Point point = hints->points;
+ AF_Point limit = point + hints->num_points;
+ FT_Vector* vec = outline->points;
+- char* tag = outline->tags;
++ FT_Byte* tag = outline->tags;
+
+
+ for ( ; point < limit; point++, vec++, tag++ )
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h
+index d1cf9529b..76fe83006 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter hinting routines (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c
+index 7fb12c63d..c6d23efd8 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter hinting routines for Indic writing system (body).
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * Rahul Bhalerao , .
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h
+index 3eb67f63b..a7f73f251 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h
+@@ -5,7 +5,7 @@
+ * Auto-fitter hinting routines for Indic writing system
+ * (specification).
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * Rahul Bhalerao , .
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c
+index b86367aa9..89287f7ea 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter hinting routines for latin writing system (body).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -981,7 +981,7 @@
+ /* `ref' and `shoot' values of two blue zones must not overlap */
+
+ FT_UInt i;
+- AF_LatinBlue blue_sorted[AF_BLUE_STRINGSET_MAX_LEN + 2];
++ AF_LatinBlue blue_sorted[AF_BLUE_STRINGSET_MAX_LEN];
+
+
+ for ( i = 0; i < axis->blue_count; i++ )
+@@ -1263,10 +1263,9 @@
+ max_height = FT_MAX( max_height, -Axis->blues[nn].descender );
+ }
+
+- dist = FT_ABS( FT_MulFix( max_height, new_scale - scale ) );
+- dist &= ~127;
++ dist = FT_MulFix( max_height, new_scale - scale );
+
+- if ( dist == 0 )
++ if ( -128 < dist && dist < 128 )
+ {
+ FT_TRACE5(( "af_latin_metrics_scale_dim:"
+ " x height alignment (style `%s'):\n",
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h
+index 31aa91d3b..54e506150 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h
+@@ -5,7 +5,7 @@
+ * Auto-fitter hinting routines for latin writing system
+ * (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -98,7 +98,7 @@ FT_BEGIN_HEADER
+
+ /* ignored for horizontal metrics */
+ FT_UInt blue_count;
+- AF_LatinBlueRec blues[AF_BLUE_STRINGSET_MAX];
++ AF_LatinBlueRec blues[AF_BLUE_STRINGSET_MAX_LEN];
+
+ FT_Fixed org_scale;
+ FT_Pos org_delta;
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c
+index 7c47d562a..af1d59a68 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter glyph loading routines (body).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h
+index e4e197e37..99f0e15f9 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter glyph loading routines (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c
+index 20a6b96bc..726f6ca2b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter module implementation (body).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -438,7 +438,7 @@
+ AF_Module module = (AF_Module)module_;
+
+ FT_Error error = FT_Err_Ok;
+- FT_Memory memory = module->root.library->memory;
++ FT_Memory memory = module->root.memory;
+
+ #ifdef FT_DEBUG_AUTOFIT
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h
+index 4b8b4562c..91a1abfef 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter module implementation (specification).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c
+index cfcaf340a..007b43281 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter Unicode script ranges (body).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h
+index 5775738bc..813b3ee78 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter Unicode script ranges (specification).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h b/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h
+index 3a101937d..0a83d7715 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter scripts (specification only).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c
+index abc6f1d29..df0f46ada 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c
+@@ -4,7 +4,7 @@
+ *
+ * HarfBuzz interface for accessing OpenType features (body).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h
+index 054a18ffb..2eb03bb5d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h
+@@ -4,7 +4,7 @@
+ *
+ * HarfBuzz interface for accessing OpenType features (specification).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h b/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h
+index 73ebef017..7a33f37a8 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter styles (specification only).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h b/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h
+index 661519449..27e4185e9 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter types (specification only).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h b/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h
+index 48c888afe..b78745af7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter writing system declarations (specification only).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h b/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h
+index a0a686f8c..c86d609a3 100644
+--- a/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h
++++ b/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h
+@@ -4,7 +4,7 @@
+ *
+ * Auto-fitter writing systems iterator (specification only).
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c b/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c
+index de25476fe..717f7d08b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c
+@@ -4,7 +4,7 @@
+ *
+ * Quick computation of advance widths (body).
+ *
+- * Copyright (C) 2008-2023 by
++ * Copyright (C) 2008-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftbase.h b/src/java.desktop/share/native/libfreetype/src/base/ftbase.h
+index 00790d3b2..1d98b26dd 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftbase.h
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftbase.h
+@@ -4,7 +4,7 @@
+ *
+ * Private functions used in the `base' module (specification).
+ *
+- * Copyright (C) 2008-2023 by
++ * Copyright (C) 2008-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c b/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c
+index 385fea404..d6aa5d56d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType bbox computation (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used
+@@ -489,7 +489,7 @@
+ return FT_THROW( Invalid_Outline );
+
+ /* if outline is empty, return (0,0,0,0) */
+- if ( outline->n_points == 0 || outline->n_contours <= 0 )
++ if ( outline->n_points == 0 || outline->n_contours == 0 )
+ {
+ abbox->xMin = abbox->xMax = 0;
+ abbox->yMin = abbox->yMax = 0;
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c b/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c
+index 1c93648dc..4be145679 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType utility functions for bitmaps (body).
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c b/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c
+index c5bc7e3b1..92de09ed8 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c
+@@ -4,7 +4,7 @@
+ *
+ * Arithmetic computations (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -69,13 +69,15 @@
+
+ /* transfer sign, leaving a positive number; */
+ /* we need an unsigned value to safely negate INT_MIN (or LONG_MIN) */
+-#define FT_MOVE_SIGN( x, x_unsigned, s ) \
+- FT_BEGIN_STMNT \
+- if ( x < 0 ) \
+- { \
+- x_unsigned = 0U - (x_unsigned); \
+- s = -s; \
+- } \
++#define FT_MOVE_SIGN( utype, x, x_unsigned, s ) \
++ FT_BEGIN_STMNT \
++ if ( x < 0 ) \
++ { \
++ x_unsigned = 0U - (utype)x; \
++ s = -s; \
++ } \
++ else \
++ x_unsigned = (utype)x; \
+ FT_END_STMNT
+
+ /* The following three functions are available regardless of whether */
+@@ -179,13 +181,9 @@
+ FT_Long d_;
+
+
+- a = (FT_UInt64)a_;
+- b = (FT_UInt64)b_;
+- c = (FT_UInt64)c_;
+-
+- FT_MOVE_SIGN( a_, a, s );
+- FT_MOVE_SIGN( b_, b, s );
+- FT_MOVE_SIGN( c_, c, s );
++ FT_MOVE_SIGN( FT_UInt64, a_, a, s );
++ FT_MOVE_SIGN( FT_UInt64, b_, b, s );
++ FT_MOVE_SIGN( FT_UInt64, c_, c, s );
+
+ d = c > 0 ? ( a * b + ( c >> 1 ) ) / c
+ : 0x7FFFFFFFUL;
+@@ -208,13 +206,9 @@
+ FT_Long d_;
+
+
+- a = (FT_UInt64)a_;
+- b = (FT_UInt64)b_;
+- c = (FT_UInt64)c_;
+-
+- FT_MOVE_SIGN( a_, a, s );
+- FT_MOVE_SIGN( b_, b, s );
+- FT_MOVE_SIGN( c_, c, s );
++ FT_MOVE_SIGN( FT_UInt64, a_, a, s );
++ FT_MOVE_SIGN( FT_UInt64, b_, b, s );
++ FT_MOVE_SIGN( FT_UInt64, c_, c, s );
+
+ d = c > 0 ? a * b / c
+ : 0x7FFFFFFFUL;
+@@ -257,11 +251,8 @@
+ FT_Long q_;
+
+
+- a = (FT_UInt64)a_;
+- b = (FT_UInt64)b_;
+-
+- FT_MOVE_SIGN( a_, a, s );
+- FT_MOVE_SIGN( b_, b, s );
++ FT_MOVE_SIGN( FT_UInt64, a_, a, s );
++ FT_MOVE_SIGN( FT_UInt64, b_, b, s );
+
+ q = b > 0 ? ( ( a << 16 ) + ( b >> 1 ) ) / b
+ : 0x7FFFFFFFUL;
+@@ -422,13 +413,9 @@
+
+ /* XXX: this function does not allow 64-bit arguments */
+
+- a = (FT_UInt32)a_;
+- b = (FT_UInt32)b_;
+- c = (FT_UInt32)c_;
+-
+- FT_MOVE_SIGN( a_, a, s );
+- FT_MOVE_SIGN( b_, b, s );
+- FT_MOVE_SIGN( c_, c, s );
++ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
++ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
++ FT_MOVE_SIGN( FT_UInt32, c_, c, s );
+
+ if ( c == 0 )
+ a = 0x7FFFFFFFUL;
+@@ -470,13 +457,9 @@
+
+ /* XXX: this function does not allow 64-bit arguments */
+
+- a = (FT_UInt32)a_;
+- b = (FT_UInt32)b_;
+- c = (FT_UInt32)c_;
+-
+- FT_MOVE_SIGN( a_, a, s );
+- FT_MOVE_SIGN( b_, b, s );
+- FT_MOVE_SIGN( c_, c, s );
++ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
++ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
++ FT_MOVE_SIGN( FT_UInt32, c_, c, s );
+
+ if ( c == 0 )
+ a = 0x7FFFFFFFUL;
+@@ -575,11 +558,8 @@
+
+ /* XXX: this function does not allow 64-bit arguments */
+
+- a = (FT_UInt32)a_;
+- b = (FT_UInt32)b_;
+-
+- FT_MOVE_SIGN( a_, a, s );
+- FT_MOVE_SIGN( b_, b, s );
++ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
++ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
+
+ if ( a + ( b >> 8 ) <= 8190UL )
+ a = ( a * b + 0x8000UL ) >> 16;
+@@ -614,11 +594,8 @@
+
+ /* XXX: this function does not allow 64-bit arguments */
+
+- a = (FT_UInt32)a_;
+- b = (FT_UInt32)b_;
+-
+- FT_MOVE_SIGN( a_, a, s );
+- FT_MOVE_SIGN( b_, b, s );
++ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
++ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
+
+ if ( b == 0 )
+ {
+@@ -829,11 +806,8 @@
+ FT_Int sx = 1, sy = 1, shift;
+
+
+- x = (FT_UInt32)x_;
+- y = (FT_UInt32)y_;
+-
+- FT_MOVE_SIGN( x_, x, sx );
+- FT_MOVE_SIGN( y_, y, sy );
++ FT_MOVE_SIGN( FT_UInt32, x_, x, sx );
++ FT_MOVE_SIGN( FT_UInt32, y_, y, sy );
+
+ /* trivial cases */
+ if ( x == 0 )
+@@ -913,43 +887,71 @@
+ }
+
+
+-#if 0
+-
+ /* documentation is in ftcalc.h */
+
+- FT_BASE_DEF( FT_Int32 )
+- FT_SqrtFixed( FT_Int32 x )
++ FT_BASE_DEF( FT_UInt32 )
++ FT_SqrtFixed( FT_UInt32 v )
+ {
+- FT_UInt32 root, rem_hi, rem_lo, test_div;
+- FT_Int count;
+-
++ if ( v == 0 )
++ return 0;
+
+- root = 0;
++#ifndef FT_INT64
+
+- if ( x > 0 )
++ /* Algorithm by Christophe Meessen (1993) with overflow fixed and */
++ /* rounding added. Any unsigned fixed 16.16 argument is acceptable. */
++ /* However, this algorithm is slower than the Babylonian method with */
++ /* a good initial guess. We only use it for large 32-bit values when */
++ /* 64-bit computations are not desirable. */
++ else if ( v > 0x10000U )
+ {
+- rem_hi = 0;
+- rem_lo = (FT_UInt32)x;
+- count = 24;
++ FT_UInt32 r = v >> 1;
++ FT_UInt32 q = ( v & 1 ) << 15;
++ FT_UInt32 b = 0x20000000;
++ FT_UInt32 t;
++
++
+ do
+ {
+- rem_hi = ( rem_hi << 2 ) | ( rem_lo >> 30 );
+- rem_lo <<= 2;
+- root <<= 1;
+- test_div = ( root << 1 ) + 1;
+-
+- if ( rem_hi >= test_div )
++ t = q + b;
++ if ( r >= t )
+ {
+- rem_hi -= test_div;
+- root += 1;
++ r -= t;
++ q = t + b; /* equivalent to q += 2*b */
+ }
+- } while ( --count );
++ r <<= 1;
++ b >>= 1;
+
-+final public class LinuxMIPS64CFrame extends BasicCFrame {
-+ // package/class internals only
-+ public LinuxMIPS64CFrame(LinuxDebugger dbg, Address ebp, Address pc) {
-+ super(dbg.getCDebugger());
-+ this.ebp = ebp;
-+ this.pc = pc;
-+ this.dbg = dbg;
-+ }
++ } while ( b > 0x10 ); /* exactly 25 cycles */
+
-+ // override base class impl to avoid ELF parsing
-+ public ClosestSymbol closestSymbolToPC() {
-+ // try native lookup in debugger.
-+ return dbg.lookup(dbg.getAddressValue(pc()));
-+ }
++ return ( q + 0x40 ) >> 7;
+ }
++ else
++ {
++ FT_UInt32 r = ( v << 16 ) - 1;
+
+- return (FT_Int32)root;
+- }
++#else /* FT_INT64 */
+
+-#endif /* 0 */
++ else
++ {
++ FT_UInt64 r = ( (FT_UInt64)v << 16 ) - 1;
+
-+ public Address pc() {
-+ return pc;
-+ }
++#endif /* FT_INT64 */
+
-+ public Address localVariableBase() {
-+ return ebp;
-+ }
++ FT_UInt32 q = 1 << ( ( 17 + FT_MSB( v ) ) >> 1 );
++ FT_UInt32 t;
+
-+ public CFrame sender(ThreadProxy thread) {
-+ MIPS64ThreadContext context = (MIPS64ThreadContext) thread.getContext();
-+ Address esp = context.getRegisterAsAddress(MIPS64ThreadContext.SP);
+
-+ if ( (ebp == null) || ebp.lessThan(esp) ) {
-+ return null;
-+ }
++ /* Babylonian method with rounded-up division */
++ do
++ {
++ t = q;
++ q = ( t + (FT_UInt32)( r / t ) + 1 ) >> 1;
+
-+ Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE);
-+ if (nextEBP == null) {
-+ return null;
-+ }
-+ Address nextPC = ebp.getAddressAt( 1 * ADDRESS_SIZE);
-+ if (nextPC == null) {
-+ return null;
-+ }
-+ return new LinuxMIPS64CFrame(dbg, nextEBP, nextPC);
-+ }
++ } while ( q != t ); /* less than 6 cycles */
+
-+ private static final int ADDRESS_SIZE = 4;
-+ private Address pc;
-+ private Address ebp;
-+ private LinuxDebugger dbg;
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64ThreadContext.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64ThreadContext.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64ThreadContext.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/mips64/LinuxMIPS64ThreadContext.java 2023-09-12 13:54:26.373575786 +0800
-@@ -0,0 +1,47 @@
-+/*
-+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2015, 2018, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
-+
-+package sun.jvm.hotspot.debugger.linux.mips64;
-+
-+import sun.jvm.hotspot.debugger.*;
-+import sun.jvm.hotspot.debugger.mips64.*;
-+import sun.jvm.hotspot.debugger.linux.*;
-+
-+public class LinuxMIPS64ThreadContext extends MIPS64ThreadContext {
-+ private LinuxDebugger debugger;
-+
-+ public LinuxMIPS64ThreadContext(LinuxDebugger debugger) {
-+ super();
-+ this.debugger = debugger;
-+ }
-+
-+ public void setRegisterAsAddress(int index, Address value) {
-+ setRegister(index, debugger.getAddressValue(value));
-+ }
-+
-+ public Address getRegisterAsAddress(int index) {
-+ return debugger.newAddress(getRegister(index));
++ return q;
++ }
+ }
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/loongarch64/LOONGARCH64ThreadContext.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/loongarch64/LOONGARCH64ThreadContext.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/loongarch64/LOONGARCH64ThreadContext.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/loongarch64/LOONGARCH64ThreadContext.java 2023-09-12 13:54:26.373575786 +0800
-@@ -0,0 +1,128 @@
-+/*
-+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2015, 2021, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
-+
-+package sun.jvm.hotspot.debugger.loongarch64;
-+
-+import java.lang.annotation.Native;
-+
-+import sun.jvm.hotspot.debugger.*;
-+import sun.jvm.hotspot.debugger.cdbg.*;
-+
-+/** Specifies the thread context on loongarch64 platforms; only a sub-portion
-+ of the context is guaranteed to be present on all operating
-+ systems. */
-+
-+public abstract class LOONGARCH64ThreadContext implements ThreadContext {
-+
-+ // NOTE: the indices for the various registers must be maintained as
-+ // listed across various operating systems. However, only a small
-+ // subset of the registers' values are guaranteed to be present (and
-+ // must be present for the SA's stack walking to work): EAX, EBX,
-+ // ECX, EDX, ESI, EDI, EBP, ESP, and EIP.
-+
-+ // One instance of the Native annotation is enough to trigger header generation
-+ // for this file.
-+ @Native
-+ public static final int ZERO = 0;
-+ public static final int RA = 1;
-+ public static final int TP = 2;
-+ public static final int SP = 3;
-+ public static final int A0 = 4;
-+ public static final int A1 = 5;
-+ public static final int A2 = 6;
-+ public static final int A3 = 7;
-+ public static final int A4 = 8;
-+ public static final int A5 = 9;
-+ public static final int A6 = 10;
-+ public static final int A7 = 11;
-+ public static final int T0 = 12;
-+ public static final int T1 = 13;
-+ public static final int T2 = 14;
-+ public static final int T3 = 15;
-+ public static final int T4 = 16;
-+ public static final int T5 = 17;
-+ public static final int T6 = 18;
-+ public static final int T7 = 19;
-+ public static final int T8 = 20;
-+ public static final int RX = 21;
-+ public static final int FP = 22;
-+ public static final int S0 = 23;
-+ public static final int S1 = 24;
-+ public static final int S2 = 25;
-+ public static final int S3 = 26;
-+ public static final int S4 = 27;
-+ public static final int S5 = 28;
-+ public static final int S6 = 29;
-+ public static final int S7 = 30;
-+ public static final int S8 = 31;
-+ public static final int PC = 32;
-+ public static final int NPRGREG = 33;
-+
-+ private static final String[] regNames = {
-+ "ZERO", "RA", "TP", "SP",
-+ "A0", "A1", "A2", "A3",
-+ "A4", "A5", "A6", "A7",
-+ "T0", "T1", "T2", "T3",
-+ "T4", "T5", "T6", "T7",
-+ "T8", "RX", "FP", "S0",
-+ "S1", "S2", "S3", "S4",
-+ "S5", "S6", "S7", "S8",
-+ "PC"
-+ };
+
+
+ /* documentation is in ftcalc.h */
+@@ -1094,11 +1096,8 @@
+ FT_UInt32 factor;
+
+
+- scalar = (FT_UInt32)s[i];
+- factor = (FT_UInt32)f[i];
+-
+- FT_MOVE_SIGN( s[i], scalar, sign );
+- FT_MOVE_SIGN( f[i], factor, sign );
++ FT_MOVE_SIGN( FT_UInt32, s[i], scalar, sign );
++ FT_MOVE_SIGN( FT_UInt32, f[i], factor, sign );
+
+ ft_multo64( scalar, factor, &multResult );
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftcid.c b/src/java.desktop/share/native/libfreetype/src/base/ftcid.c
+index 866cd23e9..4f2deb19a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftcid.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftcid.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType API for accessing CID font information.
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * Derek Clegg and Michael Toftdal.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c b/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c
+index bcd6e893d..c6bf2a3cd 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType's glyph color management (body).
+ *
+- * Copyright (C) 2018-2023 by
++ * Copyright (C) 2018-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c b/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c
+index 8fab50dd0..902a5dc8b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c
+@@ -4,7 +4,7 @@
+ *
+ * Memory debugger (body).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c b/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c
+index 61c4563b0..11307eaac 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c
+@@ -4,7 +4,7 @@
+ *
+ * Debugging and logging component (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c b/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c
+index 0b41f7cc8..77b4089e7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType utility file for font formats (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c b/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c
+index ea24e64c6..1565c3b7e 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType utility file to access FSType data (body).
+ *
+- * Copyright (C) 2008-2023 by
++ * Copyright (C) 2008-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c b/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c
+index 29b7b08b7..c63d30e97 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c
+@@ -4,7 +4,7 @@
+ *
+ * Access of TrueType's `gasp' table (body).
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c b/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c
+index 9823d09e4..484d98f17 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType glyph loader (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -355,34 +355,25 @@
+ FT_BASE_DEF( void )
+ FT_GlyphLoader_Add( FT_GlyphLoader loader )
+ {
+- FT_GlyphLoad base;
+- FT_GlyphLoad current;
+-
+- FT_Int n_curr_contours;
+- FT_Int n_base_points;
+- FT_Int n;
++ FT_Outline* base;
++ FT_Outline* current;
++ FT_Int n;
+
+
+ if ( !loader )
+ return;
+
+- base = &loader->base;
+- current = &loader->current;
+-
+- n_curr_contours = current->outline.n_contours;
+- n_base_points = base->outline.n_points;
++ base = &loader->base.outline;
++ current = &loader->current.outline;
+
+- base->outline.n_points =
+- (short)( base->outline.n_points + current->outline.n_points );
+- base->outline.n_contours =
+- (short)( base->outline.n_contours + current->outline.n_contours );
++ /* adjust contours count in newest outline */
++ for ( n = 0; n < current->n_contours; n++ )
++ current->contours[n] += base->n_points;
+
+- base->num_subglyphs += current->num_subglyphs;
++ base->n_points += current->n_points;
++ base->n_contours += current->n_contours;
+
+- /* adjust contours count in newest outline */
+- for ( n = 0; n < n_curr_contours; n++ )
+- current->outline.contours[n] =
+- (short)( current->outline.contours[n] + n_base_points );
++ loader->base.num_subglyphs += loader->current.num_subglyphs;
+
+ /* prepare for another new glyph image */
+ FT_GlyphLoader_Prepare( loader );
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c b/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c
+index 393d4949f..1b5849f99 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType convenience functions to handle glyphs (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftinit.c b/src/java.desktop/share/native/libfreetype/src/base/ftinit.c
+index c9c71d24b..9a6c00e13 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftinit.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftinit.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType initialization layer (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c b/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c
+index 6c3fd66e0..1e69d4da7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType API for color filtering of subpixel bitmap glyphs (body).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftmac.c b/src/java.desktop/share/native/libfreetype/src/base/ftmac.c
+index 492d05538..e8e35627b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftmac.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftmac.c
+@@ -8,7 +8,7 @@
+ * This file is for Mac OS X only; see builds/mac/ftoldmac.c for
+ * classic platforms built by MPW.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -812,6 +812,7 @@
+ ResourceIndex res_index;
+ Handle fond;
+ short num_faces_in_res;
++ FT_Long count;
+
+
+ if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
+@@ -821,8 +822,10 @@
+ if ( ResError() )
+ return FT_THROW( Cannot_Open_Resource );
+
++ res_index = 1;
+ num_faces_in_res = 0;
+- for ( res_index = 1; ; res_index++ )
++ count = face_index;
++ while ( count >= 0 )
+ {
+ short num_faces_in_fond;
+
+@@ -834,15 +837,21 @@
+ num_faces_in_fond = count_faces( fond, pathname );
+ num_faces_in_res += num_faces_in_fond;
+
+- if ( 0 <= face_index && face_index < num_faces_in_fond && error )
+- error = FT_New_Face_From_FOND( library, fond, face_index, aface );
++ if ( count < num_faces_in_fond )
++ error = FT_New_Face_From_FOND( library, fond, count, aface );
+
+- face_index -= num_faces_in_fond;
++ res_index++;
++ count -= num_faces_in_fond;
+ }
+
+ CloseResFile( res_ref );
+
-+ private long[] data;
+ if ( !error && aface && *aface )
+- (*aface)->num_faces = num_faces_in_res;
++ {
++ (*aface)->num_faces = num_faces_in_res;
++ (*aface)->face_index = face_index;
++ }
+
-+ public LOONGARCH64ThreadContext() {
-+ data = new long[NPRGREG];
-+ }
+ return error;
+ }
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftmm.c b/src/java.desktop/share/native/libfreetype/src/base/ftmm.c
+index 9e2dd7ee7..cc4ca22fb 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftmm.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftmm.c
+@@ -4,7 +4,7 @@
+ *
+ * Multiple Master font support (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c b/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c
+index 89a25bc73..9b97820c3 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType private base classes (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -2302,7 +2302,10 @@
+ face_index_internal, aface );
+ FT_FREE( data_offsets );
+ if ( !error )
+- (*aface)->num_faces = count;
++ {
++ (*aface)->num_faces = count;
++ (*aface)->face_index = face_index_internal;
++ }
+ }
+
+ return error;
+@@ -5791,7 +5794,7 @@
+ ttface = (TT_Face)face;
+ sfnt = (SFNT_Service)ttface->sfnt;
+
+- if ( sfnt->get_colr_layer )
++ if ( sfnt->get_colr_glyph_paint )
+ return sfnt->get_colr_glyph_paint( ttface,
+ base_glyph,
+ root_transform,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c b/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c
+index 134f39d2b..ef699b3c7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType outline management (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -53,7 +53,7 @@
+
+ FT_Vector* point;
+ FT_Vector* limit;
+- char* tags;
++ FT_Byte* tags;
+
+ FT_Error error;
+
+@@ -332,8 +332,8 @@
+ FT_NEW_ARRAY( anoutline->contours, numContours ) )
+ goto Fail;
+
+- anoutline->n_points = (FT_Short)numPoints;
+- anoutline->n_contours = (FT_Short)numContours;
++ anoutline->n_points = (FT_UShort)numPoints;
++ anoutline->n_contours = (FT_UShort)numContours;
+ anoutline->flags |= FT_OUTLINE_OWNER;
+
+ return FT_Err_Ok;
+@@ -359,12 +359,14 @@
+ FT_Int n;
+
+
++ FT_TRACE5(( "FT_Outline_Check: contours = %d, points = %d\n",
++ n_contours, n_points ));
+ /* empty glyph? */
+ if ( n_points == 0 && n_contours == 0 )
+ return FT_Err_Ok;
+
+ /* check point and contour counts */
+- if ( n_points <= 0 || n_contours <= 0 )
++ if ( n_points == 0 || n_contours == 0 )
+ goto Bad;
+
+ end0 = -1;
+@@ -576,13 +578,13 @@
+
+ /* reverse tags table */
+ {
+- char* p = outline->tags + first;
+- char* q = outline->tags + last;
++ FT_Byte* p = outline->tags + first;
++ FT_Byte* q = outline->tags + last;
+
+
+ while ( p < q )
+ {
+- char swap;
++ FT_Byte swap;
+
+
+ swap = *p;
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c b/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c
+index cb5efadff..2055757e0 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c
+@@ -5,7 +5,7 @@
+ * FreeType API for checking patented TrueType bytecode instructions
+ * (body). Obsolete, retained for backward compatibility.
+ *
+- * Copyright (C) 2007-2023 by
++ * Copyright (C) 2007-2024 by
+ * David Turner.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c b/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c
+index cefdf489d..37a6cee6c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c
+@@ -5,7 +5,7 @@
+ * Get and set properties of PostScript drivers (body).
+ * See `ftdriver.h' for available properties.
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c b/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c
+index 2ab430195..dc9b043d8 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c
+@@ -4,7 +4,7 @@
+ *
+ * Embedded resource forks accessor (body).
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * Masatake YAMATO and Redhat K.K.
+ *
+ * FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c b/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c
+index 1917a3f1d..f7231fd61 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c
+@@ -7,7 +7,7 @@
+ *
+ * This is _not_ used to retrieve glyph names!
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftstream.c b/src/java.desktop/share/native/libfreetype/src/base/ftstream.c
+index 64826aceb..667222461 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftstream.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftstream.c
+@@ -4,7 +4,7 @@
+ *
+ * I/O stream support (body).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -763,10 +763,10 @@
+ case ft_frame_bytes: /* read a byte sequence */
+ case ft_frame_skip: /* skip some bytes */
+ {
+- FT_UInt len = fields->size;
++ FT_Offset len = fields->size;
+
+
+- if ( cursor + len > stream->limit )
++ if ( len > (FT_Offset)( stream->limit - cursor ) )
+ {
+ error = FT_THROW( Invalid_Stream_Operation );
+ goto Exit;
+@@ -830,7 +830,7 @@
+ goto Exit;
+ }
+
+- /* now, compute the signed value is necessary */
++ /* now, compute the signed value if necessary */
+ if ( fields->value & FT_FRAME_OP_SIGNED )
+ value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift );
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c b/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c
+index 92f1e4308..64f46ce43 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType path stroker (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -711,7 +711,7 @@
+ {
+ FT_UInt count = border->num_points;
+ FT_Byte* read = border->tags;
+- FT_Byte* write = (FT_Byte*)outline->tags + outline->n_points;
++ FT_Byte* write = outline->tags + outline->n_points;
+
+
+ for ( ; count > 0; count--, read++, write++ )
+@@ -727,10 +727,10 @@
+
+ /* copy contours */
+ {
+- FT_UInt count = border->num_points;
+- FT_Byte* tags = border->tags;
+- FT_Short* write = outline->contours + outline->n_contours;
+- FT_Short idx = (FT_Short)outline->n_points;
++ FT_UInt count = border->num_points;
++ FT_Byte* tags = border->tags;
++ FT_UShort* write = outline->contours + outline->n_contours;
++ FT_UShort idx = outline->n_points;
+
+
+ for ( ; count > 0; count--, tags++, idx++ )
+@@ -743,7 +743,7 @@
+ }
+ }
+
+- outline->n_points += (short)border->num_points;
++ outline->n_points += (FT_UShort)border->num_points;
+
+ FT_ASSERT( FT_Outline_Check( outline ) == 0 );
+ }
+@@ -2050,7 +2050,7 @@
+
+ FT_Vector* point;
+ FT_Vector* limit;
+- char* tags;
++ FT_Byte* tags;
+
+ FT_Error error;
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c b/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c
+index f32edd338..ec05bce33 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType synthesizing code for emboldening and slanting (body).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c b/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c
+index 61c99e363..eee364233 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c
+@@ -4,7 +4,7 @@
+ *
+ * ANSI-specific FreeType low-level system interface (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c b/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c
+index 2dd2c3459..4b1aced1c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType trigonometric functions (body).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/fttype1.c b/src/java.desktop/share/native/libfreetype/src/base/fttype1.c
+index 637c5cf77..cedf7c405 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/fttype1.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/fttype1.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType utility file for PS names support (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftutil.c b/src/java.desktop/share/native/libfreetype/src/base/ftutil.c
+index 6120846d2..b13512f87 100644
+--- a/src/java.desktop/share/native/libfreetype/src/base/ftutil.c
++++ b/src/java.desktop/share/native/libfreetype/src/base/ftutil.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType utility file for memory and list management (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c
+index 10d287bc8..ea5f8ed28 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c
+@@ -4,7 +4,7 @@
+ *
+ * CFF character mapping table (cmap) support (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h
+index b2afc2fab..1dd8700cd 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h
+@@ -4,7 +4,7 @@
+ *
+ * CFF character mapping table (cmap) support (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c
+index 9898d625c..f6ebdb381 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c
+@@ -4,7 +4,7 @@
+ *
+ * OpenType font driver implementation (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h
+index ab1f147bb..fd5bc37ec 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level OpenType driver interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h b/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h
+index bc9a3043f..128adc3b7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h
+@@ -4,7 +4,7 @@
+ *
+ * CFF error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c
+index c483d1d1a..cbb071abd 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c
+@@ -4,7 +4,7 @@
+ *
+ * OpenType Glyph Loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h
+index 3b8cf236d..346d4b11c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h
+@@ -4,7 +4,7 @@
+ *
+ * OpenType Glyph Loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffload.c b/src/java.desktop/share/native/libfreetype/src/cff/cffload.c
+index af79082e9..979fd45f6 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffload.c
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffload.c
+@@ -4,7 +4,7 @@
+ *
+ * OpenType and CFF data/program tables loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -1202,17 +1202,21 @@
+ {
+ CFF_AxisCoords* axis = ®ion->axisList[j];
+
+- FT_Int16 start14, peak14, end14;
++ FT_Int start, peak, end;
+
+
+- if ( FT_READ_SHORT( start14 ) ||
+- FT_READ_SHORT( peak14 ) ||
+- FT_READ_SHORT( end14 ) )
++ if ( FT_READ_SHORT( start ) ||
++ FT_READ_SHORT( peak ) ||
++ FT_READ_SHORT( end ) )
+ goto Exit;
+
+- axis->startCoord = FT_fdot14ToFixed( start14 );
+- axis->peakCoord = FT_fdot14ToFixed( peak14 );
+- axis->endCoord = FT_fdot14ToFixed( end14 );
++ /* immediately tag invalid ranges with special peak = 0 */
++ if ( ( start < 0 && end > 0 ) || start > peak || peak > end )
++ peak = 0;
++
++ axis->startCoord = FT_fdot14ToFixed( start );
++ axis->peakCoord = FT_fdot14ToFixed( peak );
++ axis->endCoord = FT_fdot14ToFixed( end );
+ }
+ }
+
+@@ -1379,10 +1383,10 @@
+ /* opcode in both CFF and CFF2 DICTs. See `cff_parse_num' for */
+ /* decode of this, which rounds to an integer. */
+ *subFont->blend_top++ = 255;
+- *subFont->blend_top++ = (FT_Byte)( sum >> 24 );
+- *subFont->blend_top++ = (FT_Byte)( sum >> 16 );
+- *subFont->blend_top++ = (FT_Byte)( sum >> 8 );
+- *subFont->blend_top++ = (FT_Byte)sum;
++ *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 24 );
++ *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 16 );
++ *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 8 );
++ *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum );
+ }
+
+ /* leave only numBlends results on parser stack */
+@@ -1495,44 +1499,31 @@
+ for ( j = 0; j < lenNDV; j++ )
+ {
+ CFF_AxisCoords* axis = &varRegion->axisList[j];
+- FT_Fixed axisScalar;
+-
+-
+- /* compute the scalar contribution of this axis; */
+- /* ignore invalid ranges */
+- if ( axis->startCoord > axis->peakCoord ||
+- axis->peakCoord > axis->endCoord )
+- axisScalar = FT_FIXED_ONE;
+
+- else if ( axis->startCoord < 0 &&
+- axis->endCoord > 0 &&
+- axis->peakCoord != 0 )
+- axisScalar = FT_FIXED_ONE;
+
+- /* peak of 0 means ignore this axis */
+- else if ( axis->peakCoord == 0 )
+- axisScalar = FT_FIXED_ONE;
++ /* compute the scalar contribution of this axis */
++ /* with peak of 0 used for invalid axes */
++ if ( axis->peakCoord == NDV[j] ||
++ axis->peakCoord == 0 )
++ continue;
+
+ /* ignore this region if coords are out of range */
+- else if ( NDV[j] < axis->startCoord ||
+- NDV[j] > axis->endCoord )
+- axisScalar = 0;
+-
+- /* calculate a proportional factor */
+- else
++ else if ( NDV[j] <= axis->startCoord ||
++ NDV[j] >= axis->endCoord )
+ {
+- if ( NDV[j] == axis->peakCoord )
+- axisScalar = FT_FIXED_ONE;
+- else if ( NDV[j] < axis->peakCoord )
+- axisScalar = FT_DivFix( NDV[j] - axis->startCoord,
+- axis->peakCoord - axis->startCoord );
+- else
+- axisScalar = FT_DivFix( axis->endCoord - NDV[j],
+- axis->endCoord - axis->peakCoord );
++ blend->BV[master] = 0;
++ break;
+ }
+
+- /* take product of all the axis scalars */
+- blend->BV[master] = FT_MulFix( blend->BV[master], axisScalar );
++ /* adjust proportionally */
++ else if ( NDV[j] < axis->peakCoord )
++ blend->BV[master] = FT_MulDiv( blend->BV[master],
++ NDV[j] - axis->startCoord,
++ axis->peakCoord - axis->startCoord );
++ else /* NDV[j] > axis->peakCoord ) */
++ blend->BV[master] = FT_MulDiv( blend->BV[master],
++ axis->endCoord - NDV[j],
++ axis->endCoord - axis->peakCoord );
+ }
+
+ FT_TRACE4(( ", %f ",
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffload.h b/src/java.desktop/share/native/libfreetype/src/cff/cffload.h
+index b5286b0c8..022092454 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffload.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffload.h
+@@ -4,7 +4,7 @@
+ *
+ * OpenType & CFF data/program tables loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c
+index 6d08620c4..7c6713739 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c
+@@ -4,7 +4,7 @@
+ *
+ * OpenType objects manager (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -42,6 +42,8 @@
+ #include
+ #include
+
++#define CFF_fixedToInt( x ) \
++ ( (FT_Short)( ( (x) + 0x8000U ) >> 16 ) )
+
+ /**************************************************************************
+ *
+@@ -124,19 +126,20 @@
+
+ count = priv->num_blue_values = cpriv->num_blue_values;
+ for ( n = 0; n < count; n++ )
+- priv->blue_values[n] = (FT_Short)cpriv->blue_values[n];
++ priv->blue_values[n] = CFF_fixedToInt( cpriv->blue_values[n] );
+
+ count = priv->num_other_blues = cpriv->num_other_blues;
+ for ( n = 0; n < count; n++ )
+- priv->other_blues[n] = (FT_Short)cpriv->other_blues[n];
++ priv->other_blues[n] = CFF_fixedToInt( cpriv->other_blues[n] );
+
+ count = priv->num_family_blues = cpriv->num_family_blues;
+ for ( n = 0; n < count; n++ )
+- priv->family_blues[n] = (FT_Short)cpriv->family_blues[n];
++ priv->family_blues[n] = CFF_fixedToInt( cpriv->family_blues[n] );
+
+ count = priv->num_family_other_blues = cpriv->num_family_other_blues;
+ for ( n = 0; n < count; n++ )
+- priv->family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
++ priv->family_other_blues[n] =
++ CFF_fixedToInt( cpriv->family_other_blues[n] );
+
+ priv->blue_scale = cpriv->blue_scale;
+ priv->blue_shift = (FT_Int)cpriv->blue_shift;
+@@ -421,32 +424,23 @@
+ static void
+ remove_subset_prefix( FT_String* name )
+ {
+- FT_Int32 idx = 0;
+- FT_Int32 length = (FT_Int32)ft_strlen( name ) + 1;
+- FT_Bool continue_search = 1;
++ FT_UInt32 i = 0, idx = 0;
+
+
+- while ( continue_search )
++ /* six ASCII uppercase letters followed by a plus sign */
++ while ( 'A' <= name[i] && name[i++] <= 'Z' &&
++ 'A' <= name[i] && name[i++] <= 'Z' &&
++ 'A' <= name[i] && name[i++] <= 'Z' &&
++ 'A' <= name[i] && name[i++] <= 'Z' &&
++ 'A' <= name[i] && name[i++] <= 'Z' &&
++ 'A' <= name[i] && name[i++] <= 'Z' &&
++ name[i++] == '+' )
+ {
+- if ( length >= 7 && name[6] == '+' )
+- {
+- for ( idx = 0; idx < 6; idx++ )
+- {
+- /* ASCII uppercase letters */
+- if ( !( 'A' <= name[idx] && name[idx] <= 'Z' ) )
+- continue_search = 0;
+- }
+-
+- if ( continue_search )
+- {
+- for ( idx = 7; idx < length; idx++ )
+- name[idx - 7] = name[idx];
+- length -= 7;
+- }
+- }
+- else
+- continue_search = 0;
++ idx = i;
+ }
+
-+ public int getNumRegisters() {
-+ return NPRGREG;
-+ }
++ if ( idx )
++ FT_MEM_MOVE( name, name + idx, ft_strlen( name + idx ) + 1 );
+ }
+
+
+@@ -456,42 +450,20 @@
+ remove_style( FT_String* family_name,
+ const FT_String* style_name )
+ {
+- FT_Int32 family_name_length, style_name_length;
++ FT_String* f = family_name + ft_strlen( family_name );
++ const FT_String* s = style_name + ft_strlen( style_name );
+
+
+- family_name_length = (FT_Int32)ft_strlen( family_name );
+- style_name_length = (FT_Int32)ft_strlen( style_name );
++ /* compare strings moving backwards */
++ while ( s > style_name )
++ if ( f == family_name || *--s != *--f )
++ return;
+
+- if ( family_name_length > style_name_length )
+- {
+- FT_Int idx;
+-
+-
+- for ( idx = 1; idx <= style_name_length; idx++ )
+- {
+- if ( family_name[family_name_length - idx] !=
+- style_name[style_name_length - idx] )
+- break;
+- }
+-
+- if ( idx > style_name_length )
+- {
+- /* family_name ends with style_name; remove it */
+- idx = family_name_length - style_name_length - 1;
+-
+- /* also remove special characters */
+- /* between real family name and style */
+- while ( idx > 0 &&
+- ( family_name[idx] == '-' ||
+- family_name[idx] == ' ' ||
+- family_name[idx] == '_' ||
+- family_name[idx] == '+' ) )
+- idx--;
+-
+- if ( idx > 0 )
+- family_name[idx + 1] = '\0';
+- }
+- }
++ /* terminate and remove special characters */
++ do
++ *f = '\0';
++ while ( f-- > family_name &&
++ ( *f == '-' || *f == ' ' || *f == '_' || *f == '+' ) );
+ }
+
+
+@@ -722,8 +694,7 @@
+ FT_UInt instance_index = (FT_UInt)face_index >> 16;
+
+
+- if ( FT_HAS_MULTIPLE_MASTERS( cffface ) &&
+- instance_index > 0 )
++ if ( FT_HAS_MULTIPLE_MASTERS( cffface ) )
+ {
+ error = FT_Set_Named_Instance( cffface, instance_index );
+ if ( error )
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h
+index 8f05f6132..91ad83b1c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h
+@@ -4,7 +4,7 @@
+ *
+ * OpenType objects manager (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c
+index 3b076704c..92a69c3b5 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c
+@@ -4,7 +4,7 @@
+ *
+ * CFF token stream parser (body)
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -501,10 +501,10 @@
+ return cff_parse_real( *d, parser->limit, scaling, NULL );
+ else if ( **d == 255 )
+ {
+- FT_Fixed val = ( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) |
+- ( (FT_UInt32)*( d[0] + 2 ) << 16 ) |
+- ( (FT_UInt32)*( d[0] + 3 ) << 8 ) |
+- (FT_UInt32)*( d[0] + 4 ) ) );
++ FT_Fixed val = (FT_Int32)( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) |
++ ( (FT_UInt32)*( d[0] + 2 ) << 16 ) |
++ ( (FT_UInt32)*( d[0] + 3 ) << 8 ) |
++ (FT_UInt32)*( d[0] + 4 ) ) );
+
+ if ( scaling )
+ {
+@@ -1031,10 +1031,14 @@
+ CFF_FIELD( code, name, id, cff_kind_string )
+ #define CFF_FIELD_BOOL( code, name, id ) \
+ CFF_FIELD( code, name, id, cff_kind_bool )
++#define CFF_FIELD_DELTA( code, name, max, id ) \
++ CFF_FIELD_DELTA_KIND( code, name, max, id, cff_kind_delta )
++#define CFF_FIELD_DELTA_FIXED( code, name, max, id ) \
++ CFF_FIELD_DELTA_KIND( code, name, max, id, cff_kind_delta_fixed )
+
+
+ #undef CFF_FIELD
+-#undef CFF_FIELD_DELTA
++#undef CFF_FIELD_DELTA_KIND
+
+
+ #ifndef FT_DEBUG_LEVEL_TRACE
+@@ -1064,18 +1068,18 @@
+ code | CFFCODE, \
+ FT_FIELD_OFFSET( name ), \
+ FT_FIELD_SIZE( name ), \
+- 0, 0, 0 \
++ NULL, 0, 0 \
+ },
+
+-#define CFF_FIELD_DELTA( code, name, max, id ) \
+- { \
+- cff_kind_delta, \
+- code | CFFCODE, \
+- FT_FIELD_OFFSET( name ), \
+- FT_FIELD_SIZE_DELTA( name ), \
+- 0, \
+- max, \
+- FT_FIELD_OFFSET( num_ ## name ) \
++#define CFF_FIELD_DELTA_KIND( code, name, max, id, kind ) \
++ { \
++ kind, \
++ code | CFFCODE, \
++ FT_FIELD_OFFSET( name ), \
++ FT_FIELD_SIZE_DELTA( name ), \
++ NULL, \
++ max, \
++ FT_FIELD_OFFSET( num_ ## name ) \
+ },
+
+ static const CFF_Field_Handler cff_field_handlers[] =
+@@ -1083,7 +1087,7 @@
+
+ #include "cfftoken.h"
+
+- { 0, 0, 0, 0, 0, 0, 0 }
++ { 0, 0, 0, 0, NULL, 0, 0 }
+ };
+
+
+@@ -1117,20 +1121,20 @@
+ code | CFFCODE, \
+ FT_FIELD_OFFSET( name ), \
+ FT_FIELD_SIZE( name ), \
+- 0, 0, 0, \
++ NULL, 0, 0, \
+ id \
+ },
+
+-#define CFF_FIELD_DELTA( code, name, max, id ) \
+- { \
+- cff_kind_delta, \
+- code | CFFCODE, \
+- FT_FIELD_OFFSET( name ), \
+- FT_FIELD_SIZE_DELTA( name ), \
+- 0, \
+- max, \
+- FT_FIELD_OFFSET( num_ ## name ), \
+- id \
++#define CFF_FIELD_DELTA_KIND( code, name, max, id, kind ) \
++ { \
++ kind, \
++ code | CFFCODE, \
++ FT_FIELD_OFFSET( name ), \
++ FT_FIELD_SIZE_DELTA( name ), \
++ NULL, \
++ max, \
++ FT_FIELD_OFFSET( num_ ## name ), \
++ id \
+ },
+
+ static const CFF_Field_Handler cff_field_handlers[] =
+@@ -1138,7 +1142,7 @@
+
+ #include "cfftoken.h"
+
+- { 0, 0, 0, 0, 0, 0, 0, 0 }
++ { 0, 0, 0, 0, NULL, 0, 0, NULL }
+ };
+
+
+@@ -1356,7 +1360,8 @@
+
+ /* check that we have enough arguments -- except for */
+ /* delta encoded arrays, which can be empty */
+- if ( field->kind != cff_kind_delta && num_args < 1 )
++ if ( field->kind != cff_kind_delta &&
++ field->kind != cff_kind_delta_fixed && num_args < 1 )
+ goto Stack_Underflow;
+
+ switch ( field->kind )
+@@ -1471,6 +1476,38 @@
+ }
+ break;
+
++ case cff_kind_delta_fixed:
++ {
++ FT_Byte* qcount = (FT_Byte*)parser->object +
++ field->count_offset;
+
-+ public String getRegisterName(int index) {
-+ return regNames[index];
-+ }
++ FT_Byte** data = parser->stack;
+
-+ public void setRegister(int index, long value) {
-+ data[index] = value;
-+ }
+
-+ public long getRegister(int index) {
-+ return data[index];
-+ }
++ if ( num_args > field->array_max )
++ num_args = field->array_max;
+
-+ public CFrame getTopFrame(Debugger dbg) {
-+ return null;
-+ }
++ FT_TRACE4(( " [" ));
+
-+ /** This can't be implemented in this class since we would have to
-+ tie the implementation to, for example, the debugging system */
-+ public abstract void setRegisterAsAddress(int index, Address value);
++ /* store count */
++ *qcount = (FT_Byte)num_args;
+
-+ /** This can't be implemented in this class since we would have to
-+ tie the implementation to, for example, the debugging system */
-+ public abstract Address getRegisterAsAddress(int index);
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionLOONGARCH64.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionLOONGARCH64.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionLOONGARCH64.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionLOONGARCH64.java 2023-09-12 13:54:26.361575771 +0800
-@@ -0,0 +1,41 @@
-+/*
-+ * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2018, 2021, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
++ val = 0;
++ while ( num_args > 0 )
++ {
++ val = ADD_LONG( val, cff_parse_fixed( parser, data++ ) );
++ *(FT_Long*)q = val;
+
-+package sun.jvm.hotspot.debugger;
++ FT_TRACE4(( " %f\n", (double)val / 65536 ));
+
-+public class MachineDescriptionLOONGARCH64 extends MachineDescriptionTwosComplement implements MachineDescription {
-+ public long getAddressSize() {
-+ return 8;
-+ }
++ q += field->size;
++ num_args--;
++ }
+
++ FT_TRACE4(( "]\n" ));
++ }
++ break;
+
-+ public boolean isBigEndian() {
-+ return false;
-+ }
+ default: /* callback or blend */
+ error = field->reader( parser );
+ if ( error )
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h
+index 418caacc6..ca6b18af6 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h
+@@ -4,7 +4,7 @@
+ *
+ * CFF token stream parser (specification)
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -107,6 +107,7 @@ FT_BEGIN_HEADER
+ cff_kind_string,
+ cff_kind_bool,
+ cff_kind_delta,
++ cff_kind_delta_fixed,
+ cff_kind_callback,
+ cff_kind_blend,
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h b/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h
+index b61cb0e66..da45faa7f 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h
++++ b/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h
+@@ -4,7 +4,7 @@
+ *
+ * CFF token definitions (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -80,26 +80,26 @@
+ #undef CFFCODE
+ #define CFFCODE CFF_CODE_PRIVATE
+
+- CFF_FIELD_DELTA ( 6, blue_values, 14, "BlueValues" )
+- CFF_FIELD_DELTA ( 7, other_blues, 10, "OtherBlues" )
+- CFF_FIELD_DELTA ( 8, family_blues, 14, "FamilyBlues" )
+- CFF_FIELD_DELTA ( 9, family_other_blues, 10, "FamilyOtherBlues" )
+- CFF_FIELD_FIXED_1000( 0x109, blue_scale, "BlueScale" )
+- CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" )
+- CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" )
+- CFF_FIELD_NUM ( 10, standard_width, "StdHW" )
+- CFF_FIELD_NUM ( 11, standard_height, "StdVW" )
+- CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" )
+- CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" )
+- CFF_FIELD_BOOL ( 0x10E, force_bold, "ForceBold" )
+- CFF_FIELD_FIXED ( 0x10F, force_bold_threshold, "ForceBoldThreshold" )
+- CFF_FIELD_NUM ( 0x110, lenIV, "lenIV" )
+- CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
+- CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
+- CFF_FIELD_NUM ( 0x113, initial_random_seed, "initialRandomSeed" )
+- CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
+- CFF_FIELD_NUM ( 20, default_width, "defaultWidthX" )
+- CFF_FIELD_NUM ( 21, nominal_width, "nominalWidthX" )
++ CFF_FIELD_DELTA_FIXED( 6, blue_values, 14, "BlueValues" )
++ CFF_FIELD_DELTA_FIXED( 7, other_blues, 10, "OtherBlues" )
++ CFF_FIELD_DELTA_FIXED( 8, family_blues, 14, "FamilyBlues" )
++ CFF_FIELD_DELTA_FIXED( 9, family_other_blues, 10, "FamilyOtherBlues" )
++ CFF_FIELD_FIXED_1000 ( 0x109, blue_scale, "BlueScale" )
++ CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" )
++ CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" )
++ CFF_FIELD_NUM ( 10, standard_width, "StdHW" )
++ CFF_FIELD_NUM ( 11, standard_height, "StdVW" )
++ CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" )
++ CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" )
++ CFF_FIELD_BOOL ( 0x10E, force_bold, "ForceBold" )
++ CFF_FIELD_FIXED ( 0x10F, force_bold_threshold, "ForceBoldThreshold" )
++ CFF_FIELD_NUM ( 0x110, lenIV, "lenIV" )
++ CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
++ CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
++ CFF_FIELD_NUM ( 0x113, initial_random_seed, "initialRandomSeed" )
++ CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
++ CFF_FIELD_NUM ( 20, default_width, "defaultWidthX" )
++ CFF_FIELD_NUM ( 21, nominal_width, "nominalWidthX" )
+
+
+ #undef FT_STRUCTURE
+@@ -129,22 +129,22 @@
+ #undef CFFCODE
+ #define CFFCODE CFF2_CODE_PRIVATE
+
+- CFF_FIELD_DELTA ( 6, blue_values, 14, "BlueValues" )
+- CFF_FIELD_DELTA ( 7, other_blues, 10, "OtherBlues" )
+- CFF_FIELD_DELTA ( 8, family_blues, 14, "FamilyBlues" )
+- CFF_FIELD_DELTA ( 9, family_other_blues, 10, "FamilyOtherBlues" )
+- CFF_FIELD_FIXED_1000( 0x109, blue_scale, "BlueScale" )
+- CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" )
+- CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" )
+- CFF_FIELD_NUM ( 10, standard_width, "StdHW" )
+- CFF_FIELD_NUM ( 11, standard_height, "StdVW" )
+- CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" )
+- CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" )
+- CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
+- CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
+- CFF_FIELD_CALLBACK ( 22, vsindex, "vsindex" )
+- CFF_FIELD_BLEND ( 23, "blend" )
+- CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
++ CFF_FIELD_DELTA_FIXED( 6, blue_values, 14, "BlueValues" )
++ CFF_FIELD_DELTA_FIXED( 7, other_blues, 10, "OtherBlues" )
++ CFF_FIELD_DELTA_FIXED( 8, family_blues, 14, "FamilyBlues" )
++ CFF_FIELD_DELTA_FIXED( 9, family_other_blues, 10, "FamilyOtherBlues" )
++ CFF_FIELD_FIXED_1000 ( 0x109, blue_scale, "BlueScale" )
++ CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" )
++ CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" )
++ CFF_FIELD_NUM ( 10, standard_width, "StdHW" )
++ CFF_FIELD_NUM ( 11, standard_height, "StdVW" )
++ CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" )
++ CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" )
++ CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
++ CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
++ CFF_FIELD_CALLBACK ( 22, vsindex, "vsindex" )
++ CFF_FIELD_BLEND ( 23, "blend" )
++ CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
+
+
+ /* END */
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h b/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h
+index 40a1097d0..c439a8c4a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h
++++ b/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h
+@@ -4,7 +4,7 @@
+ *
+ * CID error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c
+index eaca765ad..7b571322d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c
+@@ -4,7 +4,7 @@
+ *
+ * CID-keyed Type1 Glyph Loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h
+index edd622923..9fdc9db58 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h
+@@ -4,7 +4,7 @@
+ *
+ * OpenType Glyph Loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidload.c b/src/java.desktop/share/native/libfreetype/src/cid/cidload.c
+index a7da8ea39..722f5a34d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidload.c
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidload.c
+@@ -4,7 +4,7 @@
+ *
+ * CID-keyed Type1 font loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -388,7 +388,7 @@
+ T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 )
+ T1_FIELD_CALLBACK( "FontName", parse_font_name, 0 )
+
+- { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 }
++ T1_FIELD_ZERO
+ };
+
+
+@@ -469,36 +469,23 @@
+ T1_Field keyword = (T1_Field)cid_field_records;
+
+
+- for (;;)
++ while ( keyword->len )
+ {
+- FT_Byte* name;
++ FT_Byte* name = (FT_Byte*)keyword->ident;
+
+
+- name = (FT_Byte*)keyword->ident;
+- if ( !name )
+- break;
+-
+- if ( cur[0] == name[0] &&
+- len == ft_strlen( (const char*)name ) )
++ if ( keyword->len == len &&
++ ft_memcmp( cur, name, len ) == 0 )
+ {
+- FT_UInt n;
+-
+-
+- for ( n = 1; n < len; n++ )
+- if ( cur[n] != name[n] )
+- break;
+-
+- if ( n >= len )
+- {
+- /* we found it - run the parsing callback */
+- parser->root.error = cid_load_keyword( face,
+- loader,
+- keyword );
+- if ( parser->root.error )
+- return parser->root.error;
+- break;
+- }
++ /* we found it - run the parsing callback */
++ parser->root.error = cid_load_keyword( face,
++ loader,
++ keyword );
++ if ( parser->root.error )
++ return parser->root.error;
++ break;
+ }
+
-+ public boolean isLP64() {
-+ return true;
-+ }
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionMIPS64.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionMIPS64.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionMIPS64.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionMIPS64.java 2023-09-12 13:54:26.365575776 +0800
-@@ -0,0 +1,41 @@
-+/*
-+ * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2018, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
-+
-+package sun.jvm.hotspot.debugger;
-+
-+public class MachineDescriptionMIPS64 extends MachineDescriptionTwosComplement implements MachineDescription {
-+ public long getAddressSize() {
-+ return 8;
-+ }
-+
-+
-+ public boolean isBigEndian() {
-+ return "big".equals(System.getProperty("sun.cpu.endian"));
-+ }
-+
-+ public boolean isLP64() {
-+ return true;
-+ }
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/mips64/MIPS64ThreadContext.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/mips64/MIPS64ThreadContext.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/mips64/MIPS64ThreadContext.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/mips64/MIPS64ThreadContext.java 2023-09-12 13:54:26.373575786 +0800
-@@ -0,0 +1,128 @@
-+/*
-+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2015, 2018, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
+ keyword++;
+ }
+ }
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidload.h b/src/java.desktop/share/native/libfreetype/src/cid/cidload.h
+index d12d2962a..7f030b32d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidload.h
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidload.h
+@@ -4,7 +4,7 @@
+ *
+ * CID-keyed Type1 font loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c
+index f698a4192..8d337c411 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c
+@@ -4,7 +4,7 @@
+ *
+ * CID objects manager (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h
+index 83c0c61c3..d371cbe99 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h
+@@ -4,7 +4,7 @@
+ *
+ * CID objects manager (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c
+index 171a88621..73a3ade89 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c
+@@ -4,7 +4,7 @@
+ *
+ * CID-keyed Type1 parser (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -90,10 +90,15 @@
+ if ( error )
+ goto Exit;
+
+- Again:
+- /* now, read the rest of the file until we find */
+- /* `StartData' or `/sfnts' */
++ if ( !stream->read ) {
++ /* just parse memory-based streams */
++ offset = stream->size;
++ }
++ else
+ {
++ /* Find the last `StartData` or `/sfnts`. The parser requires */
++ /* contiguous memory; attempt to pin as little as necessary. */
++
+ /*
+ * The algorithm is as follows (omitting the case with less than 256
+ * bytes to fill for simplicity).
+@@ -119,7 +124,8 @@
+ FT_Byte* p = buffer;
+
+
+- for ( offset = FT_STREAM_POS(); ; offset += 256 )
++ offset = 0;
++ while ( 1 )
+ {
+ FT_ULong stream_len;
+
+@@ -127,7 +133,7 @@
+ stream_len = stream->size - FT_STREAM_POS();
+
+ read_len = FT_MIN( read_len, stream_len );
+- if ( FT_STREAM_READ( p, read_len ) )
++ if ( read_len && FT_STREAM_READ( p, read_len ) )
+ goto Exit;
+
+ /* ensure that we do not compare with data beyond the buffer */
+@@ -141,20 +147,23 @@
+ ft_strncmp( (char*)p, STARTDATA, STARTDATA_LEN ) == 0 )
+ {
+ /* save offset of binary data after `StartData' */
+- offset += (FT_ULong)( p - buffer ) + STARTDATA_LEN + 1;
+- goto Found;
++ offset = FT_STREAM_POS() - read_len - read_offset
++ + (FT_ULong)( p - buffer ) + STARTDATA_LEN + 1;
+ }
+ else if ( p[1] == 's' &&
+ ft_strncmp( (char*)p, SFNTS, SFNTS_LEN ) == 0 )
+ {
+- offset += (FT_ULong)( p - buffer ) + SFNTS_LEN + 1;
+- goto Found;
++ offset = FT_STREAM_POS() - read_len - read_offset
++ + (FT_ULong)( p - buffer ) + SFNTS_LEN + 1;
+ }
+ }
+
+- if ( read_offset + read_len < STARTDATA_LEN )
++ if ( read_offset + read_len <= STARTDATA_LEN )
+ {
+- FT_TRACE2(( "cid_parser_new: no `StartData' keyword found\n" ));
++ if ( offset )
++ goto Found;
++
++ FT_TRACE2(( "cid_parser_new: no `StartData` keyword found\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+@@ -171,9 +180,9 @@
+ }
+
+ Found:
+- /* We have found the start of the binary data or the `/sfnts' token. */
+- /* Now rewind and extract the frame corresponding to this PostScript */
+- /* section. */
++ /* We have found an efficient range to look for the binary data or */
++ /* `/sfnts' token. Now rewind and extract the frame corresponding to */
++ /* this PostScript section. */
+
+ ps_len = offset - base_offset;
+ if ( FT_STREAM_SEEK( base_offset ) ||
+@@ -187,8 +196,8 @@
+ parser->root.limit = parser->root.cursor + ps_len;
+ parser->num_dict = FT_UINT_MAX;
+
+- /* Finally, we check whether `StartData' or `/sfnts' was real -- */
+- /* it could be in a comment or string. We also get the arguments */
++ /* Find the first real `StartData' or `/sfnts' -- the last one */
++ /* could be in a comment or string. We also get the arguments */
+ /* of `StartData' to find out whether the data is represented in */
+ /* binary or hex format. */
+
+@@ -216,6 +225,7 @@
+ {
+ T1_TokenRec type_token;
+ FT_Long binary_length;
++ FT_ULong found_offset;
+
+
+ parser->root.cursor = arg1;
+@@ -234,6 +244,24 @@
+ parser->binary_length = (FT_ULong)binary_length;
+ }
+
++ /* set the real values for the parser, if different */
++ found_offset = (FT_ULong)( cur - parser->postscript )
++ + STARTDATA_LEN + 1;
++ if ( found_offset != offset )
++ {
++ FT_FRAME_RELEASE( parser->postscript );
++
++ ps_len = found_offset - base_offset;
++ if ( FT_STREAM_SEEK( base_offset ) ||
++ FT_FRAME_EXTRACT( ps_len, parser->postscript ) )
++ goto Exit;
++
++ parser->data_offset = found_offset;
++ parser->postscript_len = ps_len;
++ parser->root.base = parser->postscript;
++ parser->root.cursor = parser->postscript;
++ parser->root.limit = parser->root.cursor + ps_len;
++ }
+ goto Exit;
+ }
+ else if ( cur[1] == 's' &&
+@@ -251,11 +279,8 @@
+ cur = parser->root.cursor;
+ }
+
+- /* we haven't found the correct `StartData'; go back and continue */
+- /* searching */
+- FT_FRAME_RELEASE( parser->postscript );
+- if ( !FT_STREAM_SEEK( offset ) )
+- goto Again;
++ FT_TRACE2(( "cid_parser_new: no `StartData` token found\n" ));
++ error = FT_THROW( Invalid_File_Format );
+
+ Exit:
+ return error;
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h
+index 2fd4e7a93..0f5baddcb 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h
+@@ -4,7 +4,7 @@
+ *
+ * CID-keyed Type1 parser (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c
+index 99e7b1183..4be8a5c00 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c
+@@ -4,7 +4,7 @@
+ *
+ * CID driver interface (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h
+index a6249385c..7ddce431c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level CID driver interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h b/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h
+index 925951acd..160897d14 100644
+--- a/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h
++++ b/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h
+@@ -4,7 +4,7 @@
+ *
+ * CID token definitions (specification only).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c
+index db08941de..e2f6a8e5a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c
+@@ -4,7 +4,7 @@
+ *
+ * AFM parser (body).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h
+index 2d3b6e6e1..b77663728 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h
+@@ -4,7 +4,7 @@
+ *
+ * AFM parser (specification).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c
+index 562d17d22..9556e11a5 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c
+@@ -4,7 +4,7 @@
+ *
+ * PostScript CFF (Type 2) decoding routines (body).
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -17,6 +17,7 @@
+
+
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -1752,22 +1753,9 @@
+
+ /* without upper limit the loop below might not finish */
+ if ( args[0] > 0x7FFFFFFFL )
+- args[0] = 46341;
++ args[0] = 0xB504F4L; /* sqrt( 32768.0044 ) */
+ else if ( args[0] > 0 )
+- {
+- FT_Fixed root = args[0];
+- FT_Fixed new_root;
+-
+-
+- for (;;)
+- {
+- new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;
+- if ( new_root == root )
+- break;
+- root = new_root;
+- }
+- args[0] = new_root;
+- }
++ args[0] = (FT_Fixed)FT_SqrtFixed( args[0] );
+ else
+ args[0] = 0;
+ args++;
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h
+index e8bb4001c..038f7235c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h
+@@ -4,7 +4,7 @@
+ *
+ * PostScript CFF (Type 2) decoding routines (specification).
+ *
+- * Copyright (C) 2017-2023 by
++ * Copyright (C) 2017-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h b/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h
+index 895ffa48c..18428c40d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h
+@@ -4,7 +4,7 @@
+ *
+ * PS auxiliary module error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c
+index 45e35aa53..6826f9d8d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType auxiliary PostScript module implementation (body).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h
+index 94dbf4881..82d7e348a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType auxiliary PostScript module implementation (specification).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c b/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c
+index f9c864fea..213b943b4 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c
+@@ -54,14 +54,6 @@
+ #define FT_COMPONENT cf2blues
+
+
+- /*
+- * For blue values, the FreeType parser produces an array of integers,
+- * while the Adobe CFF engine produces an array of fixed.
+- * Define a macro to convert FreeType to fixed.
+- */
+-#define cf2_blueToFixed( x ) cf2_intToFixed( x )
+-
+-
+ FT_LOCAL_DEF( void )
+ cf2_blues_init( CF2_Blues blues,
+ CF2_Font font )
+@@ -78,10 +70,10 @@
+ size_t numFamilyBlues;
+ size_t numFamilyOtherBlues;
+
+- FT_Pos* blueValues;
+- FT_Pos* otherBlues;
+- FT_Pos* familyBlues;
+- FT_Pos* familyOtherBlues;
++ FT_Fixed* blueValues;
++ FT_Fixed* otherBlues;
++ FT_Fixed* familyBlues;
++ FT_Fixed* familyOtherBlues;
+
+ size_t i;
+ CF2_Fixed emBoxBottom, emBoxTop;
+@@ -138,13 +130,13 @@
+ emBoxTop = CF2_ICF_Top;
+ }
+
+- if ( cf2_getLanguageGroup( decoder ) == 1 &&
+- ( numBlueValues == 0 ||
+- ( numBlueValues == 4 &&
+- cf2_blueToFixed( blueValues[0] ) < emBoxBottom &&
+- cf2_blueToFixed( blueValues[1] ) < emBoxBottom &&
+- cf2_blueToFixed( blueValues[2] ) > emBoxTop &&
+- cf2_blueToFixed( blueValues[3] ) > emBoxTop ) ) )
++ if ( cf2_getLanguageGroup( decoder ) == 1 &&
++ ( numBlueValues == 0 ||
++ ( numBlueValues == 4 &&
++ blueValues[0] < emBoxBottom &&
++ blueValues[1] < emBoxBottom &&
++ blueValues[2] > emBoxTop &&
++ blueValues[3] > emBoxTop ) ) )
+ {
+ /*
+ * Construct hint edges suitable for synthetic ghost hints at top
+@@ -189,10 +181,8 @@
+ /* bottom zones */
+ for ( i = 0; i < numBlueValues; i += 2 )
+ {
+- blues->zone[blues->count].csBottomEdge =
+- cf2_blueToFixed( blueValues[i] );
+- blues->zone[blues->count].csTopEdge =
+- cf2_blueToFixed( blueValues[i + 1] );
++ blues->zone[blues->count].csBottomEdge = blueValues[i];
++ blues->zone[blues->count].csTopEdge = blueValues[i + 1];
+
+ zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
+ blues->zone[blues->count].csBottomEdge );
+@@ -238,10 +228,8 @@
+
+ for ( i = 0; i < numOtherBlues; i += 2 )
+ {
+- blues->zone[blues->count].csBottomEdge =
+- cf2_blueToFixed( otherBlues[i] );
+- blues->zone[blues->count].csTopEdge =
+- cf2_blueToFixed( otherBlues[i + 1] );
++ blues->zone[blues->count].csBottomEdge = otherBlues[i];
++ blues->zone[blues->count].csTopEdge = otherBlues[i + 1];
+
+ zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
+ blues->zone[blues->count].csBottomEdge );
+@@ -299,7 +287,7 @@
+ for ( j = 0; j < numFamilyOtherBlues; j += 2 )
+ {
+ /* top edge */
+- flatFamilyEdge = cf2_blueToFixed( familyOtherBlues[j + 1] );
++ flatFamilyEdge = familyOtherBlues[j + 1];
+
+ diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
+
+@@ -317,7 +305,7 @@
+ if ( numFamilyBlues >= 2 )
+ {
+ /* top edge */
+- flatFamilyEdge = cf2_blueToFixed( familyBlues[1] );
++ flatFamilyEdge = familyBlues[1];
+
+ diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
+
+@@ -337,7 +325,7 @@
+ for ( j = 2; j < numFamilyBlues; j += 2 )
+ {
+ /* bottom edge */
+- flatFamilyEdge = cf2_blueToFixed( familyBlues[j] );
++ flatFamilyEdge = familyBlues[j];
+
+ /* adjust edges of top zone upward by twice darkening amount */
+ flatFamilyEdge += 2 * font->darkenY; /* bottom edge */
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c
+index b9c7138d8..56c0ecd1d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c
+@@ -4,7 +4,7 @@
+ *
+ * Some convenience conversions (body).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h
+index b7c3ee00b..91fcd15a1 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h
+@@ -4,7 +4,7 @@
+ *
+ * Some convenience conversions (specification).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psft.c b/src/java.desktop/share/native/libfreetype/src/psaux/psft.c
+index 618864e6e..fd0abe171 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psft.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psft.c
+@@ -566,12 +566,12 @@
+ FT_LOCAL_DEF( void )
+ cf2_getBlueValues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data )
++ FT_Fixed* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_blue_values;
+- *data = (FT_Pos*)
++ *data = (FT_Fixed*)
+ &decoder->current_subfont->private_dict.blue_values;
+ }
+
+@@ -579,12 +579,12 @@
+ FT_LOCAL_DEF( void )
+ cf2_getOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data )
++ FT_Fixed* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_other_blues;
+- *data = (FT_Pos*)
++ *data = (FT_Fixed*)
+ &decoder->current_subfont->private_dict.other_blues;
+ }
+
+@@ -592,12 +592,12 @@
+ FT_LOCAL_DEF( void )
+ cf2_getFamilyBlues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data )
++ FT_Fixed* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_family_blues;
+- *data = (FT_Pos*)
++ *data = (FT_Fixed*)
+ &decoder->current_subfont->private_dict.family_blues;
+ }
+
+@@ -605,12 +605,12 @@
+ FT_LOCAL_DEF( void )
+ cf2_getFamilyOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data )
++ FT_Fixed* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_family_other_blues;
+- *data = (FT_Pos*)
++ *data = (FT_Fixed*)
+ &decoder->current_subfont->private_dict.family_other_blues;
+ }
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psft.h b/src/java.desktop/share/native/libfreetype/src/psaux/psft.h
+index 3da454e60..d9082f3a2 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psft.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psft.h
+@@ -92,19 +92,19 @@ FT_BEGIN_HEADER
+ FT_LOCAL( void )
+ cf2_getBlueValues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data );
++ FT_Fixed* *data );
+ FT_LOCAL( void )
+ cf2_getOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data );
++ FT_Fixed* *data );
+ FT_LOCAL( void )
+ cf2_getFamilyBlues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data );
++ FT_Fixed* *data );
+ FT_LOCAL( void )
+ cf2_getFamilyOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+- FT_Pos* *data );
++ FT_Fixed* *data );
+
+ FT_LOCAL( CF2_Int )
+ cf2_getLanguageGroup( PS_Decoder* decoder );
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c b/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c
+index 6c640eebd..7572e225e 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c
+@@ -37,6 +37,7 @@
+
+
+ #include "psft.h"
++#include
+ #include
+ #include
+
+@@ -428,6 +429,8 @@
+ base = cf2_stack_count( opStack ) - numOperands;
+ delta = base + numBlends;
+
++ FT_TRACE6(( " (" ));
+
-+package sun.jvm.hotspot.debugger.mips64;
+ for ( i = 0; i < numBlends; i++ )
+ {
+ const CF2_Fixed* weight = &blend->BV[1];
+@@ -442,10 +445,14 @@
+ cf2_stack_getReal( opStack,
+ delta++ ) ) );
+
++ FT_TRACE6(( "%f ", (double)sum / 65536 ));
+
-+import java.lang.annotation.Native;
+ /* store blended result */
+ cf2_stack_setReal( opStack, i + base, sum );
+ }
+
++ FT_TRACE6(( "blended)\n" ));
+
-+import sun.jvm.hotspot.debugger.*;
-+import sun.jvm.hotspot.debugger.cdbg.*;
+ /* leave only `numBlends' results on stack */
+ cf2_stack_pop( opStack, numOperands - numBlends );
+ }
+@@ -734,7 +741,7 @@
+ FT_UInt numBlends;
+
+
+- FT_TRACE4(( " blend\n" ));
++ FT_TRACE4(( " blend" ));
+
+ if ( !font->isCFF2 )
+ break; /* clear stack & ignore */
+@@ -2275,23 +2282,7 @@
+
+ arg = cf2_stack_popFixed( opStack );
+ if ( arg > 0 )
+- {
+- /* use a start value that doesn't make */
+- /* the algorithm's addition overflow */
+- FT_Fixed root = arg < 10 ? arg : arg >> 1;
+- FT_Fixed new_root;
+-
+-
+- /* Babylonian method */
+- for (;;)
+- {
+- new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1;
+- if ( new_root == root )
+- break;
+- root = new_root;
+- }
+- arg = new_root;
+- }
++ arg = (CF2_F16Dot16)FT_SqrtFixed( (FT_UInt32)arg );
+ else
+ arg = 0;
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c
+index 8da755d0e..eca465f00 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c
+@@ -4,7 +4,7 @@
+ *
+ * Auxiliary functions for PostScript fonts (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -23,6 +23,7 @@
+
+ #include "psobjs.h"
+ #include "psconv.h"
++#include "psft.h"
+
+ #include "psauxerr.h"
+ #include "psauxmod.h"
+@@ -200,7 +201,9 @@
+ /* add the object to the base block and adjust offset */
+ table->elements[idx] = FT_OFFSET( table->block, table->cursor );
+ table->lengths [idx] = length;
+- FT_MEM_COPY( table->block + table->cursor, object, length );
++ /* length == 0 also implies a NULL destination, so skip the copy call */
++ if ( length > 0 )
++ FT_MEM_COPY( table->block + table->cursor, object, length );
+
+ table->cursor += length;
+ return FT_Err_Ok;
+@@ -1624,7 +1627,7 @@
+ if ( builder->load_points )
+ {
+ FT_Vector* point = outline->points + outline->n_points;
+- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
++ FT_Byte* control = outline->tags + outline->n_points;
+
+
+ point->x = FIXED_TO_INT( x );
+@@ -1677,8 +1680,7 @@
+ if ( !error )
+ {
+ if ( outline->n_contours > 0 )
+- outline->contours[outline->n_contours - 1] =
+- (short)( outline->n_points - 1 );
++ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+
+ outline->n_contours++;
+ }
+@@ -1740,7 +1742,7 @@
+ {
+ FT_Vector* p1 = outline->points + first;
+ FT_Vector* p2 = outline->points + outline->n_points - 1;
+- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
++ FT_Byte* control = outline->tags + outline->n_points - 1;
+
+
+ /* `delete' last point only if it coincides with the first */
+@@ -1760,8 +1762,7 @@
+ outline->n_points--;
+ }
+ else
+- outline->contours[outline->n_contours - 1] =
+- (short)( outline->n_points - 1 );
++ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+ }
+ }
+
+@@ -1899,7 +1900,7 @@
+ if ( builder->load_points )
+ {
+ FT_Vector* point = outline->points + outline->n_points;
+- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
++ FT_Byte* control = outline->tags + outline->n_points;
+
+ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
+@@ -1959,8 +1960,7 @@
+ if ( !error )
+ {
+ if ( outline->n_contours > 0 )
+- outline->contours[outline->n_contours - 1] =
+- (short)( outline->n_points - 1 );
++ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+
+ outline->n_contours++;
+ }
+@@ -2019,7 +2019,7 @@
+ {
+ FT_Vector* p1 = outline->points + first;
+ FT_Vector* p2 = outline->points + outline->n_points - 1;
+- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
++ FT_Byte* control = outline->tags + outline->n_points - 1;
+
+
+ /* `delete' last point only if it coincides with the first */
+@@ -2039,8 +2039,7 @@
+ outline->n_points--;
+ }
+ else
+- outline->contours[outline->n_contours - 1] =
+- (short)( outline->n_points - 1 );
++ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+ }
+ }
+
+@@ -2188,7 +2187,7 @@
+ if ( builder->load_points )
+ {
+ FT_Vector* point = outline->points + outline->n_points;
+- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
++ FT_Byte* control = outline->tags + outline->n_points;
+
+ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
+@@ -2267,8 +2266,7 @@
+ if ( !error )
+ {
+ if ( outline->n_contours > 0 )
+- outline->contours[outline->n_contours - 1] =
+- (short)( outline->n_points - 1 );
++ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+
+ outline->n_contours++;
+ }
+@@ -2327,7 +2325,7 @@
+ {
+ FT_Vector* p1 = outline->points + first;
+ FT_Vector* p2 = outline->points + outline->n_points - 1;
+- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
++ FT_Byte* control = outline->tags + outline->n_points - 1;
+
+
+ /* `delete' last point only if it coincides with the first */
+@@ -2347,8 +2345,7 @@
+ outline->n_points--;
+ }
+ else
+- outline->contours[outline->n_contours - 1] =
+- (short)( outline->n_points - 1 );
++ outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+ }
+ }
+
+@@ -2463,19 +2460,20 @@
+
+ count = cpriv->num_blue_values = priv->num_blue_values;
+ for ( n = 0; n < count; n++ )
+- cpriv->blue_values[n] = (FT_Pos)priv->blue_values[n];
++ cpriv->blue_values[n] = cf2_intToFixed( priv->blue_values[n] );
+
+ count = cpriv->num_other_blues = priv->num_other_blues;
+ for ( n = 0; n < count; n++ )
+- cpriv->other_blues[n] = (FT_Pos)priv->other_blues[n];
++ cpriv->other_blues[n] = cf2_intToFixed( priv->other_blues[n] );
+
+ count = cpriv->num_family_blues = priv->num_family_blues;
+ for ( n = 0; n < count; n++ )
+- cpriv->family_blues[n] = (FT_Pos)priv->family_blues[n];
++ cpriv->family_blues[n] = cf2_intToFixed( priv->family_blues[n] );
+
+ count = cpriv->num_family_other_blues = priv->num_family_other_blues;
+ for ( n = 0; n < count; n++ )
+- cpriv->family_other_blues[n] = (FT_Pos)priv->family_other_blues[n];
++ cpriv->family_other_blues[n] =
++ cf2_intToFixed( priv->family_other_blues[n] );
+
+ cpriv->blue_scale = priv->blue_scale;
+ cpriv->blue_shift = (FT_Pos)priv->blue_shift;
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h
+index d5bce5410..345fc8a73 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h
+@@ -4,7 +4,7 @@
+ *
+ * Auxiliary functions for PostScript fonts (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c
+index c4bcf599e..5681c3bd0 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 character map support (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h
+index b3702498a..445e6a278 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 character map support (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c
+index 4b6b969bc..c74baa803 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c
+@@ -4,7 +4,7 @@
+ *
+ * PostScript Type 1 decoding routines (body).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h
+index 0970def96..16203b8f7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h
++++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h
+@@ -4,7 +4,7 @@
+ *
+ * PostScript Type 1 decoding routines (specification).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c
+index 4f622e1e4..967767b34 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c
+@@ -4,7 +4,7 @@
+ *
+ * PostScript hinting algorithm (body).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used
+@@ -1118,7 +1118,7 @@
+ FT_UInt n;
+ PSH_Point point = glyph->points;
+ FT_Vector* vec = glyph->outline->points;
+- char* tags = glyph->outline->tags;
++ FT_Byte* tags = glyph->outline->tags;
+
+
+ for ( n = 0; n < glyph->num_points; n++ )
+@@ -1171,8 +1171,8 @@
+ FT_QNEW_ARRAY( glyph->contours, outline->n_contours ) )
+ goto Exit;
+
+- glyph->num_points = (FT_UInt)outline->n_points;
+- glyph->num_contours = (FT_UInt)outline->n_contours;
++ glyph->num_points = outline->n_points;
++ glyph->num_contours = outline->n_contours;
+
+ {
+ FT_UInt first = 0, next, n;
+@@ -1186,7 +1186,7 @@
+ PSH_Point point;
+
+
+- next = (FT_UInt)outline->contours[n] + 1;
++ next = outline->contours[n] + 1;
+ count = next - first;
+
+ contour->start = points + first;
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h
+index 3f0ba28a6..fb362f061 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h
+@@ -4,7 +4,7 @@
+ *
+ * PostScript hinting algorithm (specification).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c
+index d4c5eb32b..435f45838 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c
+@@ -5,7 +5,7 @@
+ * PostScript hinter global hinting management (body).
+ * Inspired by the new auto-hinter module.
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h
+index 579eb2148..c5a5c9131 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h
+@@ -4,7 +4,7 @@
+ *
+ * PostScript hinter global hinting management.
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c
+index 974a99e01..9965d5b16 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType PostScript hinter module implementation (body).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h
+index 4bd781a35..62ac0a60f 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h
+@@ -4,7 +4,7 @@
+ *
+ * PostScript hinter module interface (specification).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h
+index 97624952d..e9641340e 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h
+@@ -4,7 +4,7 @@
+ *
+ * PS Hinter error codes (specification only).
+ *
+- * Copyright (C) 2003-2023 by
++ * Copyright (C) 2003-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c
+index 680e6d013..0b2b549fc 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c
+@@ -4,7 +4,7 @@
+ *
+ * FreeType PostScript hints recorder (body).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -806,7 +806,7 @@
+ ps_hints_stem( PS_Hints hints,
+ FT_UInt dimension,
+ FT_Int count,
+- FT_Long* stems )
++ FT_Pos* stems )
+ {
+ PS_Dimension dim;
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h
+index 0b2484af1..7e375af7b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h
++++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h
+@@ -4,7 +4,7 @@
+ *
+ * Postscript (Type1/Type2) hints recorder (specification).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c
+index 8203a0465..35d054d1c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c
++++ b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c
+@@ -4,7 +4,7 @@
+ *
+ * psnames module implementation (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h
+index 0904700bf..770458316 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h
++++ b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level psnames module interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h b/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h
+index 0073f8228..e123eb65e 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h
++++ b/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h
+@@ -4,7 +4,7 @@
+ *
+ * PS names module error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h b/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h
+index 7f92cce60..2a941b046 100644
+--- a/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h
++++ b/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h
+@@ -4,7 +4,7 @@
+ *
+ * PostScript glyph names.
+ *
+- * Copyright (C) 2005-2023 by
++ * Copyright (C) 2005-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h b/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h
+index 33dbfd631..943f2aa0a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h
++++ b/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h
+@@ -5,7 +5,7 @@
+ * Miscellaneous macros for stand-alone rasterizer (specification
+ * only).
+ *
+- * Copyright (C) 2005-2023 by
++ * Copyright (C) 2005-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used
+@@ -92,27 +92,6 @@
+ #endif
+
+
+- static FT_Long
+- FT_MulDiv( FT_Long a,
+- FT_Long b,
+- FT_Long c )
+- {
+- FT_Int s;
+- FT_Long d;
+-
+-
+- s = 1;
+- if ( a < 0 ) { a = -a; s = -1; }
+- if ( b < 0 ) { b = -b; s = -s; }
+- if ( c < 0 ) { c = -c; s = -s; }
+-
+- d = (FT_Long)( c > 0 ? ( (FT_Int64)a * b + ( c >> 1 ) ) / c
+- : 0x7FFFFFFFL );
+-
+- return ( s > 0 ) ? d : -d;
+- }
+-
+-
+ static FT_Long
+ FT_MulDiv_No_Round( FT_Long a,
+ FT_Long b,
+diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c
+index 192ca0701..e4b7b937d 100644
+--- a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c
++++ b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType glyph rasterizer (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -63,8 +63,7 @@
+ #else /* !STANDALONE_ */
+
+ #include "ftraster.h"
+-#include /* for FT_MulDiv and FT_MulDiv_No_Round */
+-#include /* for FT_Outline_Get_CBox */
++#include /* for FT_MulDiv_No_Round */
+
+ #endif /* !STANDALONE_ */
+
+@@ -115,12 +114,12 @@
+ * a change of direction is detected in the outline, a new profile is
+ * generated until the end of the outline.
+ *
+- * Note that when all profiles have been generated, the function
+- * Finalize_Profile_Table() is used to record, for each profile, its
+- * bottom-most scanline as well as the scanline above its upmost
+- * boundary. These positions are called `y-turns' because they (sort
+- * of) correspond to local extrema. They are stored in a sorted list
+- * built from the top of the render pool as a downwards stack:
++ * Note that, for all generated profiles, the function End_Profile()
++ * is used to record all their bottom-most scanlines as well as the
++ * scanline above their upmost boundary. These positions are called
++ * `y-turns' because they (sort of) correspond to local extrema.
++ * They are stored in a sorted list built from the top of the render
++ * pool as a downwards stack:
+ *
+ * _ _ _______________________________________
+ * | |
+@@ -136,7 +135,7 @@
+ * optimize performance (see technical note on the sweep below).
+ *
+ * Of course, the raster detects whether the two stacks collide and
+- * handles the situation properly.
++ * handles the situation by bisecting the job and restarting.
+ *
+ */
+
+@@ -252,7 +251,6 @@
+ /* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
+ /* for clipping computations. It simply uses the FT_MulDiv() function */
+ /* defined in `ftcalc.h'. */
+-#define SMulDiv FT_MulDiv
+ #define SMulDiv_No_Round FT_MulDiv_No_Round
+
+ /* The rasterizer is a very general purpose component; please leave */
+@@ -305,16 +303,6 @@
+ typedef unsigned char Byte, *PByte;
+ typedef char Bool;
+
+-
+- typedef union Alignment_
+- {
+- Long l;
+- void* p;
+- void (*f)(void);
+-
+- } Alignment, *PAlignment;
+-
+-
+ typedef struct TPoint_
+ {
+ Long x;
+@@ -327,6 +315,7 @@
+ #define Flow_Up 0x08U
+ #define Overshoot_Top 0x10U
+ #define Overshoot_Bottom 0x20U
++#define Dropout 0x40U
+
+
+ /* States of each line, arc, and profile */
+@@ -345,31 +334,28 @@
+
+ struct TProfile_
+ {
+- FT_F26Dot6 X; /* current coordinate during sweep */
+ PProfile link; /* link to next profile (various purposes) */
+- PLong offset; /* start of profile's data in render pool */
++ PProfile next; /* next profile in same contour, used */
++ /* during drop-out control */
++ Int offset; /* bottom or currently scanned array index */
++ Int height; /* profile's height in scanlines */
++ Int start; /* profile's starting scanline, also use */
++ /* as activation counter */
+ UShort flags; /* Bit 0-2: drop-out mode */
+ /* Bit 3: profile orientation (up/down) */
+ /* Bit 4: is top profile? */
+ /* Bit 5: is bottom profile? */
+- Long height; /* profile's height in scanlines */
+- Long start; /* profile's starting scanline */
++ /* Bit 6: dropout detected */
+
+- Int countL; /* number of lines to step before this */
+- /* profile becomes drawable */
+-
+- PProfile next; /* next profile in same contour, used */
+- /* during drop-out control */
++ FT_F26Dot6 X; /* current coordinate during sweep */
++ Long x[1]; /* actually variable array of scanline */
++ /* intersections with `height` elements */
+ };
+
+ typedef PProfile TProfileList;
+ typedef PProfile* PProfileList;
+
+
+-#define AlignProfileSize \
+- ( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( Long ) )
+-
+-
+ #undef RAS_ARG
+ #undef RAS_ARGS
+ #undef RAS_VAR
+@@ -407,15 +393,13 @@
+
+ /* prototypes used for sweep function dispatch */
+ typedef void
+- Function_Sweep_Init( RAS_ARGS Short min,
+- Short max );
++ Function_Sweep_Init( RAS_ARGS Int min,
++ Int max );
+
+ typedef void
+- Function_Sweep_Span( RAS_ARGS Short y,
++ Function_Sweep_Span( RAS_ARGS Int y,
+ FT_F26Dot6 x1,
+- FT_F26Dot6 x2,
+- PProfile left,
+- PProfile right );
++ FT_F26Dot6 x2 );
+
+ typedef void
+ Function_Sweep_Step( RAS_ARG );
+@@ -441,8 +425,7 @@
+ (Bool)( x - FLOOR( x ) >= ras.precision_half )
+
+ /* Smart dropout rounding to find which pixel is closer to span ends. */
+- /* To mimick Windows, symmetric cases break down indepenently of the */
+- /* precision. */
++ /* To mimic Windows, symmetric cases do not depend on the precision. */
+ #define SMART( p, q ) FLOOR( ( (p) + (q) + ras.precision * 63 / 64 ) >> 1 )
+
+ #if FT_RENDER_POOL_SIZE > 2048
+@@ -462,7 +445,6 @@
+ Int precision_half;
+ Int precision_scale;
+ Int precision_step;
+- Int precision_jitter;
+
+ PLong buff; /* The profiles buffer */
+ PLong sizeBuff; /* Render pool size */
+@@ -471,24 +453,14 @@
+
+ FT_Error error;
+
+- Int numTurns; /* number of Y-turns in outline */
+-
+ Byte dropOutControl; /* current drop_out control method */
+
+- UShort bWidth; /* target bitmap width */
+- PByte bOrigin; /* target bitmap bottom-left origin */
+- PByte bLine; /* target bitmap current line */
+-
+ Long lastX, lastY;
+ Long minY, maxY;
+
+ UShort num_Profs; /* current number of profiles */
++ Int numTurns; /* number of Y-turns in outline */
+
+- Bool fresh; /* signals a fresh new profile which */
+- /* `start' field must be completed */
+- Bool joint; /* signals that the last arc ended */
+- /* exactly on a scanline. Allows */
+- /* removal of doublets */
+ PProfile cProfile; /* current profile */
+ PProfile fProfile; /* head of linked list of profiles */
+ PProfile gProfile; /* contour's first profile in case */
+@@ -496,9 +468,14 @@
+
+ TStates state; /* rendering state */
+
+- FT_Bitmap target; /* description of target bit/pixmap */
+ FT_Outline outline;
+
++ Int bTop; /* target bitmap max line index */
++ Int bRight; /* target bitmap rightmost index */
++ Int bPitch; /* target bitmap pitch */
++ PByte bOrigin; /* target bitmap bottom-left origin */
++ PByte bLine; /* target bitmap current line */
+
-+/** Specifies the thread context on mips64 platforms; only a sub-portion
-+ of the context is guaranteed to be present on all operating
-+ systems. */
+ /* dispatch variables */
+
+ Function_Sweep_Init* Proc_Sweep_Init;
+@@ -563,37 +540,82 @@
+ *
+ * 256 / (1 << 12) = 0.0625 pixels.
+ *
+- * `precision_jitter' is an epsilon threshold used in
+- * `Vertical_Sweep_Span' to deal with small imperfections in the Bezier
+- * decomposition (after all, we are working with approximations only);
+- * it avoids switching on additional pixels which would cause artifacts
+- * otherwise.
+- *
+- * The value of `precision_jitter' has been determined heuristically.
+- *
+ */
+
+ if ( High )
+ {
+ ras.precision_bits = 12;
+ ras.precision_step = 256;
+- ras.precision_jitter = 30;
+ }
+ else
+ {
+ ras.precision_bits = 6;
+ ras.precision_step = 32;
+- ras.precision_jitter = 2;
+ }
+
+- FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" ));
+-
+ ras.precision = 1 << ras.precision_bits;
+ ras.precision_half = ras.precision >> 1;
+ ras.precision_scale = ras.precision >> Pixel_Bits;
+ }
+
+
++ /**************************************************************************
++ *
++ * @Function:
++ * Insert_Y_Turn
++ *
++ * @Description:
++ * Insert a salient into the sorted list placed on top of the render
++ * pool.
++ *
++ * @Input:
++ * New y scanline position.
++ *
++ * @Return:
++ * SUCCESS on success. FAILURE in case of overflow.
++ */
++ static Bool
++ Insert_Y_Turns( RAS_ARGS Int y,
++ Int top )
++ {
++ Int n = ras.numTurns;
++ PLong y_turns = ras.maxBuff;
+
-+public abstract class MIPS64ThreadContext implements ThreadContext {
+
-+ // NOTE: the indices for the various registers must be maintained as
-+ // listed across various operating systems. However, only a small
-+ // subset of the registers' values are guaranteed to be present (and
-+ // must be present for the SA's stack walking to work): EAX, EBX,
-+ // ECX, EDX, ESI, EDI, EBP, ESP, and EIP.
++ /* update top value */
++ if ( n == 0 || top > y_turns[n] )
++ y_turns[n] = top;
+
-+ // One instance of the Native annotation is enough to trigger header generation
-+ // for this file.
-+ @Native
-+ public static final int ZERO = 0;
-+ public static final int AT = 1;
-+ public static final int V0 = 2;
-+ public static final int V1 = 3;
-+ public static final int A0 = 4;
-+ public static final int A1 = 5;
-+ public static final int A2 = 6;
-+ public static final int A3 = 7;
-+ public static final int T0 = 8;
-+ public static final int T1 = 9;
-+ public static final int T2 = 10;
-+ public static final int T3 = 11;
-+ public static final int T4 = 12;
-+ public static final int T5 = 13;
-+ public static final int T6 = 14;
-+ public static final int T7 = 15;
-+ public static final int S0 = 16;
-+ public static final int S1 = 17;
-+ public static final int S2 = 18;
-+ public static final int S3 = 19;
-+ public static final int S4 = 20;
-+ public static final int S5 = 21;
-+ public static final int S6 = 22;
-+ public static final int S7 = 23;
-+ public static final int T8 = 24;
-+ public static final int T9 = 25;
-+ public static final int K0 = 26;
-+ public static final int K1 = 27;
-+ public static final int GP = 28;
-+ public static final int SP = 29;
-+ public static final int FP = 30;
-+ public static final int RA = 31;
-+ public static final int PC = 32;
-+ public static final int NPRGREG = 33;
++ /* look for first y value that is <= */
++ while ( n-- && y < y_turns[n] )
++ ;
+
-+ private static final String[] regNames = {
-+ "ZERO", "AT", "V0", "V1",
-+ "A0", "A1", "A2", "A3",
-+ "T0", "T1", "T2", "T3",
-+ "T4", "T5", "T6", "T7",
-+ "S0", "S1", "S2", "S3",
-+ "S4", "S5", "S6", "S7",
-+ "T8", "T9", "K0", "K1",
-+ "GP", "SP", "FP", "RA",
-+ "PC"
-+ };
++ /* if it is <, simply insert it, ignore if == */
++ if ( n < 0 || y > y_turns[n] )
++ {
++ ras.maxBuff--;
++ if ( ras.maxBuff <= ras.top )
++ {
++ ras.error = FT_THROW( Raster_Overflow );
++ return FAILURE;
++ }
+
-+ private long[] data;
++ do
++ {
++ Int y2 = (Int)y_turns[n];
+
-+ public MIPS64ThreadContext() {
-+ data = new long[NPRGREG];
-+ }
+
-+ public int getNumRegisters() {
-+ return NPRGREG;
-+ }
++ y_turns[n] = y;
++ y = y2;
++ } while ( n-- >= 0 );
+
-+ public String getRegisterName(int index) {
-+ return regNames[index];
-+ }
++ ras.numTurns++;
++ }
+
-+ public void setRegister(int index, long value) {
-+ data[index] = value;
++ return SUCCESS;
+ }
+
-+ public long getRegister(int index) {
-+ return data[index];
-+ }
+
-+ public CFrame getTopFrame(Debugger dbg) {
-+ return null;
-+ }
+ /**************************************************************************
+ *
+ * @Function:
+@@ -606,52 +628,48 @@
+ * aState ::
+ * The state/orientation of the new profile.
+ *
+- * overshoot ::
+- * Whether the profile's unrounded start position
+- * differs by at least a half pixel.
+- *
+ * @Return:
+ * SUCCESS on success. FAILURE in case of overflow or of incoherent
+ * profile.
+ */
+ static Bool
+- New_Profile( RAS_ARGS TStates aState,
+- Bool overshoot )
++ New_Profile( RAS_ARGS TStates aState )
+ {
+- if ( !ras.fProfile )
++ Long e;
+
-+ /** This can't be implemented in this class since we would have to
-+ tie the implementation to, for example, the debugging system */
-+ public abstract void setRegisterAsAddress(int index, Address value);
+
-+ /** This can't be implemented in this class since we would have to
-+ tie the implementation to, for example, the debugging system */
-+ public abstract Address getRegisterAsAddress(int index);
-+}
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/posix/elf/ELFHeader.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/posix/elf/ELFHeader.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/posix/elf/ELFHeader.java 2022-10-12 23:00:03.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/posix/elf/ELFHeader.java 2023-09-12 13:54:26.373575786 +0800
-@@ -22,6 +22,12 @@
- *
- */
++ if ( !ras.cProfile || ras.cProfile->height )
+ {
+ ras.cProfile = (PProfile)ras.top;
+- ras.fProfile = ras.cProfile;
+- ras.top += AlignProfileSize;
+- }
++ ras.top = ras.cProfile->x;
-+/*
-+ * This file has been modified by Loongson Technology in 2021, These
-+ * modifications are Copyright (c) 2019, 2021, Loongson Technology, and are made
-+ * available on the same license terms set forth above.
-+ */
+- if ( ras.top >= ras.maxBuff )
+- {
+- ras.error = FT_THROW( Raster_Overflow );
+- return FAILURE;
++ if ( ras.top >= ras.maxBuff )
++ {
++ FT_TRACE1(( "overflow in New_Profile\n" ));
++ ras.error = FT_THROW( Raster_Overflow );
++ return FAILURE;
++ }
+
- package sun.jvm.hotspot.debugger.posix.elf;
++ ras.cProfile->height = 0;
+ }
- import java.io.FileInputStream;
-@@ -63,6 +69,8 @@
- public static final int ARCH_i860 = 7;
- /** MIPS architecture type. */
- public static final int ARCH_MIPS = 8;
-+ /** LOONGARCH architecture type. */
-+ public static final int ARCH_LOONGARCH = 9;
+- ras.cProfile->start = 0;
+- ras.cProfile->height = 0;
+- ras.cProfile->offset = ras.top;
+- ras.cProfile->link = (PProfile)0;
+- ras.cProfile->next = (PProfile)0;
+ ras.cProfile->flags = ras.dropOutControl;
- /** Returns a file type which is defined by the file type constants. */
- public short getFileType();
-diff -x '.git*' -x .jcheck -x .workflow -Naur openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/loongarch64/ProcLOONGARCH64ThreadContext.java jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/loongarch64/ProcLOONGARCH64ThreadContext.java
---- openjdk/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/loongarch64/ProcLOONGARCH64ThreadContext.java 1970-01-01 08:00:00.000000000 +0800
-+++ jdk11u-ls/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/loongarch64/ProcLOONGARCH64ThreadContext.java 2023-09-12 13:54:26.377575791 +0800
-@@ -0,0 +1,47 @@
-+/*
-+ * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
-+ * Copyright (c) 2015, 2021, Loongson Technology. All rights reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-+ * or visit www.oracle.com if you need additional information or have any
-+ * questions.
-+ *
-+ */
-+
-+package sun.jvm.hotspot.debugger.proc.loongarch64;
-+
-+import sun.jvm.hotspot.debugger.*;
-+import sun.jvm.hotspot.debugger.loongarch64.*;
-+import sun.jvm.hotspot.debugger.proc.*;
-+
-+public class ProcLOONGARCH64ThreadContext extends LOONGARCH64ThreadContext {
-+ private ProcDebugger debugger;
+ switch ( aState )
+ {
+ case Ascending_State:
+ ras.cProfile->flags |= Flow_Up;
+- if ( overshoot )
++ if ( IS_BOTTOM_OVERSHOOT( ras.lastY ) )
+ ras.cProfile->flags |= Overshoot_Bottom;
+
+- FT_TRACE6(( " new ascending profile = %p\n", (void *)ras.cProfile ));
++ e = CEILING( ras.lastY );
+ break;
+
+ case Descending_State:
+- if ( overshoot )
++ if ( IS_TOP_OVERSHOOT( ras.lastY ) )
+ ras.cProfile->flags |= Overshoot_Top;
+- FT_TRACE6(( " new descending profile = %p\n", (void *)ras.cProfile ));
+
-+ public ProcLOONGARCH64ThreadContext(ProcDebugger debugger) {
-+ super();
-+ this.debugger = debugger;
++ e = FLOOR( ras.lastY );
+ break;
+
+ default:
+@@ -660,12 +678,20 @@
+ return FAILURE;
+ }
+
+- if ( !ras.gProfile )
+- ras.gProfile = ras.cProfile;
++ if ( e > ras.maxY )
++ e = ras.maxY;
++ if ( e < ras.minY )
++ e = ras.minY;
++ ras.cProfile->start = (Int)TRUNC( e );
++
++ FT_TRACE7(( " new %s profile = %p, start = %d\n",
++ aState == Ascending_State ? "ascending" : "descending",
++ (void *)ras.cProfile, ras.cProfile->start ));
++
++ if ( ras.lastY == e )
++ *ras.top++ = ras.lastX;
+
+ ras.state = aState;
+- ras.fresh = TRUE;
+- ras.joint = FALSE;
+
+ return SUCCESS;
+ }
+@@ -677,24 +703,19 @@
+ * End_Profile
+ *
+ * @Description:
+- * Finalize the current profile.
+- *
+- * @Input:
+- * overshoot ::
+- * Whether the profile's unrounded end position differs
+- * by at least a half pixel.
++ * Finalize the current profile and record y-turns.
+ *
+ * @Return:
+ * SUCCESS on success. FAILURE in case of overflow or incoherency.
+ */
+ static Bool
+- End_Profile( RAS_ARGS Bool overshoot )
++ End_Profile( RAS_ARG )
+ {
+- Long h;
++ PProfile p = ras.cProfile;
++ Int h = (Int)( ras.top - p->x );
++ Int bottom, top;
+
+
+- h = (Long)( ras.top - ras.cProfile->offset );
+-
+ if ( h < 0 )
+ {
+ FT_ERROR(( "End_Profile: negative height encountered\n" ));
+@@ -704,98 +725,46 @@
+
+ if ( h > 0 )
+ {
+- PProfile oldProfile;
++ FT_TRACE7(( " ending profile %p, start = %2d, height = %+3d\n",
++ (void *)p, p->start, p->flags & Flow_Up ? h : -h ));
+
++ p->height = h;
+
+- FT_TRACE6(( " ending profile %p, start = %ld, height = %ld\n",
+- (void *)ras.cProfile, ras.cProfile->start, h ));
++ if ( p->flags & Flow_Up )
++ {
++ if ( IS_TOP_OVERSHOOT( ras.lastY ) )
++ p->flags |= Overshoot_Top;
+
+- ras.cProfile->height = h;
+- if ( overshoot )
++ bottom = p->start;
++ top = bottom + h;
++ p->offset = 0;
++ p->X = p->x[0];
++ }
++ else
+ {
+- if ( ras.cProfile->flags & Flow_Up )
+- ras.cProfile->flags |= Overshoot_Top;
+- else
+- ras.cProfile->flags |= Overshoot_Bottom;
++ if ( IS_BOTTOM_OVERSHOOT( ras.lastY ) )
++ p->flags |= Overshoot_Bottom;
++
++ top = p->start + 1;
++ bottom = top - h;
++ p->start = bottom;
++ p->offset = h - 1;
++ p->X = p->x[h - 1];
+ }
+
+- oldProfile = ras.cProfile;
+- ras.cProfile = (PProfile)ras.top;
++ if ( Insert_Y_Turns( RAS_VARS bottom, top ) )
++ return FAILURE;
+
+- ras.top += AlignProfileSize;
++ if ( !ras.gProfile )
++ ras.gProfile = p;
+
+- ras.cProfile->height = 0;
+- ras.cProfile->offset = ras.top;
++ /* preliminary values to be finalized */
++ p->next = ras.gProfile;
++ p->link = (PProfile)ras.top;
+
+- oldProfile->next = ras.cProfile;
+ ras.num_Profs++;
+ }
+
+- if ( ras.top >= ras.maxBuff )
+- {
+- FT_TRACE1(( "overflow in End_Profile\n" ));
+- ras.error = FT_THROW( Raster_Overflow );
+- return FAILURE;
+- }
+-
+- ras.joint = FALSE;
+-
+- return SUCCESS;
+- }
+-
+-
+- /**************************************************************************
+- *
+- * @Function:
+- * Insert_Y_Turn
+- *
+- * @Description:
+- * Insert a salient into the sorted list placed on top of the render
+- * pool.
+- *
+- * @Input:
+- * New y scanline position.
+- *
+- * @Return:
+- * SUCCESS on success. FAILURE in case of overflow.
+- */
+- static Bool
+- Insert_Y_Turn( RAS_ARGS Int y )
+- {
+- PLong y_turns;
+- Int n;
+-
+-
+- n = ras.numTurns - 1;
+- y_turns = ras.sizeBuff - ras.numTurns;
+-
+- /* look for first y value that is <= */
+- while ( n >= 0 && y < y_turns[n] )
+- n--;
+-
+- /* if it is <, simply insert it, ignore if == */
+- if ( n >= 0 && y > y_turns[n] )
+- do
+- {
+- Int y2 = (Int)y_turns[n];
+-
+-
+- y_turns[n] = y;
+- y = y2;
+- } while ( --n >= 0 );
+-
+- if ( n < 0 )
+- {
+- ras.maxBuff--;
+- if ( ras.maxBuff <= ras.top )
+- {
+- ras.error = FT_THROW( Raster_Overflow );
+- return FAILURE;
+- }
+- ras.numTurns++;
+- ras.sizeBuff[-ras.numTurns] = y;
+- }
+-
+ return SUCCESS;
+ }
+
+@@ -807,56 +776,29 @@
+ *
+ * @Description:
+ * Adjust all links in the profiles list.
+- *
+- * @Return:
+- * SUCCESS on success. FAILURE in case of overflow.
+ */
+- static Bool
++ static void
+ Finalize_Profile_Table( RAS_ARG )
+ {
+- UShort n;
+- PProfile p;
+-
++ UShort n = ras.num_Profs;
++ PProfile p = ras.fProfile;
++ PProfile q;
+
+- n = ras.num_Profs;
+- p = ras.fProfile;
+
+- if ( n > 1 && p )
++ /* there should be at least two profiles, up and down */
++ while ( --n )
+ {
+- do
+- {
+- Int bottom, top;
++ q = p->link;
+
++ /* fix the contour loop */
++ if ( q->next == p->next )
++ p->next = q;
+
+- if ( n > 1 )
+- p->link = (PProfile)( p->offset + p->height );
+- else
+- p->link = NULL;
+-
+- if ( p->flags & Flow_Up )
+- {
+- bottom = (Int)p->start;
+- top = (Int)( p->start + p->height - 1 );
+- }
+- else
+- {
+- bottom = (Int)( p->start - p->height + 1 );
+- top = (Int)p->start;
+- p->start = bottom;
+- p->offset += p->height - 1;
+- }
+-
+- if ( Insert_Y_Turn( RAS_VARS bottom ) ||
+- Insert_Y_Turn( RAS_VARS top + 1 ) )
+- return FAILURE;
+-
+- p = p->link;
+- } while ( --n );
++ p = q;
+ }
+- else
+- ras.fProfile = NULL;
+
+- return SUCCESS;
++ /* null-terminate */
++ p->link = NULL;
+ }
+
+
+@@ -986,107 +928,78 @@
+ Long miny,
+ Long maxy )
+ {
+- Long Dx, Dy;
+- Int e1, e2, f1, f2, size; /* XXX: is `Short' sufficient? */
+- Long Ix, Rx, Ax;
++ Long e, e2, Dx, Dy;
++ Long Ix, Rx, Ax;
++ Int size;
+
+ PLong top;
+
+
+- Dx = x2 - x1;
+- Dy = y2 - y1;
+-
+- if ( Dy <= 0 || y2 < miny || y1 > maxy )
++ if ( y2 < miny || y1 > maxy )
+ return SUCCESS;
+
+- if ( y1 < miny )
+- {
+- /* Take care: miny-y1 can be a very large value; we use */
+- /* a slow MulDiv function to avoid clipping bugs */
+- x1 += SMulDiv( Dx, miny - y1, Dy );
+- e1 = (Int)TRUNC( miny );
+- f1 = 0;
+- }
+- else
+- {
+- e1 = (Int)TRUNC( y1 );
+- f1 = (Int)FRAC( y1 );
+- }
++ e2 = y2 > maxy ? maxy : FLOOR( y2 );
++ e = y1 < miny ? miny : CEILING( y1 );
+
+- if ( y2 > maxy )
+- {
+- /* x2 += FMulDiv( Dx, maxy - y2, Dy ); UNNECESSARY */
+- e2 = (Int)TRUNC( maxy );
+- f2 = 0;
+- }
+- else
+- {
+- e2 = (Int)TRUNC( y2 );
+- f2 = (Int)FRAC( y2 );
+- }
++ if ( y1 == e )
++ e += ras.precision;
+
+- if ( f1 > 0 )
+- {
+- if ( e1 == e2 )
+- return SUCCESS;
+- else
+- {
+- x1 += SMulDiv( Dx, ras.precision - f1, Dy );
+- e1 += 1;
+- }
+- }
+- else
+- if ( ras.joint )
+- {
+- ras.top--;
+- ras.joint = FALSE;
+- }
+-
+- ras.joint = (char)( f2 == 0 );
++ if ( e2 < e ) /* nothing to do */
++ return SUCCESS;
+
+- if ( ras.fresh )
+- {
+- ras.cProfile->start = e1;
+- ras.fresh = FALSE;
+- }
++ size = (Int)TRUNC( e2 - e ) + 1;
++ top = ras.top;
+
+- size = e2 - e1 + 1;
+- if ( ras.top + size >= ras.maxBuff )
++ if ( top + size >= ras.maxBuff )
+ {
+ ras.error = FT_THROW( Raster_Overflow );
+ return FAILURE;
+ }
+
+- if ( Dx > 0 )
+- {
+- Ix = SMulDiv_No_Round( ras.precision, Dx, Dy );
+- Rx = ( ras.precision * Dx ) % Dy;
+- Dx = 1;
+- }
+- else
++ Dx = x2 - x1;
++ Dy = y2 - y1;
++
++ if ( Dx == 0 ) /* very easy */
+ {
+- Ix = -SMulDiv_No_Round( ras.precision, -Dx, Dy );
+- Rx = ( ras.precision * -Dx ) % Dy;
+- Dx = -1;
++ do
++ *top++ = x1;
++ while ( --size );
++ goto Fin;
+ }
+
+- Ax = -Dy;
+- top = ras.top;
++ Ix = SMulDiv_No_Round( e - y1, Dx, Dy );
++ x1 += Ix;
++ *top++ = x1;
+
+- while ( size > 0 )
++ if ( --size )
+ {
+- *top++ = x1;
++ Ax = Dx * ( e - y1 ) - Dy * Ix; /* remainder */
++ Ix = FMulDiv( ras.precision, Dx, Dy );
++ Rx = Dx * ras.precision - Dy * Ix; /* remainder */
++ Dx = 1;
+
+- x1 += Ix;
+- Ax += Rx;
+- if ( Ax >= 0 )
++ if ( x2 < x1 )
++ {
++ Ax = -Ax;
++ Rx = -Rx;
++ Dx = -Dx;
++ }
++
++ do
+ {
+- Ax -= Dy;
+- x1 += Dx;
++ x1 += Ix;
++ Ax += Rx;
++ if ( Ax >= Dy )
++ {
++ Ax -= Dy;
++ x1 += Dx;
++ }
++ *top++ = x1;
+ }
+- size--;
++ while ( --size );
+ }
+
++ Fin:
+ ras.top = top;
+ return SUCCESS;
+ }
+@@ -1131,17 +1044,7 @@
+ Long miny,
+ Long maxy )
+ {
+- Bool result, fresh;
+-
+-
+- fresh = ras.fresh;
+-
+- result = Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny );
+-
+- if ( fresh && !ras.fresh )
+- ras.cProfile->start = -ras.cProfile->start;
+-
+- return result;
++ return Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny );
+ }
+
+
+@@ -1181,105 +1084,73 @@
+ Long miny,
+ Long maxy )
+ {
+- Long y1, y2, e, e2, e0;
+- Short f1;
++ Long y1, y2, e, e2, dy;
++ Long dx, x2;
+
+- TPoint* start_arc;
+-
+- PLong top;
++ PLong top;
+
+
+ y1 = arc[degree].y;
+ y2 = arc[0].y;
+- top = ras.top;
+
+ if ( y2 < miny || y1 > maxy )
+- goto Fin;
+-
+- e2 = FLOOR( y2 );
+-
+- if ( e2 > maxy )
+- e2 = maxy;
+-
+- e0 = miny;
+-
+- if ( y1 < miny )
+- e = miny;
+- else
+- {
+- e = CEILING( y1 );
+- f1 = (Short)( FRAC( y1 ) );
+- e0 = e;
+-
+- if ( f1 == 0 )
+- {
+- if ( ras.joint )
+- {
+- top--;
+- ras.joint = FALSE;
+- }
++ return SUCCESS;
+
+- *top++ = arc[degree].x;
++ e2 = y2 > maxy ? maxy : FLOOR( y2 );
++ e = y1 < miny ? miny : CEILING( y1 );
+
+- e += ras.precision;
+- }
+- }
++ if ( y1 == e )
++ e += ras.precision;
+
+- if ( ras.fresh )
+- {
+- ras.cProfile->start = TRUNC( e0 );
+- ras.fresh = FALSE;
+- }
++ if ( e2 < e ) /* nothing to do */
++ return SUCCESS;
+
+- if ( e2 < e )
+- goto Fin;
++ top = ras.top;
+
+ if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )
+ {
+- ras.top = top;
+ ras.error = FT_THROW( Raster_Overflow );
+ return FAILURE;
+ }
+
+- start_arc = arc;
+-
+ do
+ {
+- ras.joint = FALSE;
+-
+ y2 = arc[0].y;
++ x2 = arc[0].x;
+
+ if ( y2 > e )
+ {
+- y1 = arc[degree].y;
+- if ( y2 - y1 >= ras.precision_step )
++ dy = y2 - arc[degree].y;
++ dx = x2 - arc[degree].x;
++
++ /* split condition should be invariant of direction */
++ if ( dy > ras.precision_step ||
++ dx > ras.precision_step ||
++ -dx > ras.precision_step )
+ {
+ splitter( arc );
+ arc += degree;
+ }
+ else
+ {
+- *top++ = arc[degree].x + FMulDiv( arc[0].x - arc[degree].x,
+- e - y1, y2 - y1 );
++ *top++ = x2 - FMulDiv( y2 - e, dx, dy );
++ e += ras.precision;
+ arc -= degree;
+- e += ras.precision;
+ }
+ }
+ else
+ {
+ if ( y2 == e )
+ {
+- ras.joint = TRUE;
+- *top++ = arc[0].x;
+-
+- e += ras.precision;
++ *top++ = x2;
++ e += ras.precision;
+ }
+- arc -= degree;
++ arc -= degree;
+ }
+- } while ( arc >= start_arc && e <= e2 );
++ }
++ while ( e <= e2 );
+
+- Fin:
+- ras.top = top;
++ ras.top = top;
+ return SUCCESS;
+ }
+
+@@ -1316,7 +1187,7 @@
+ Long miny,
+ Long maxy )
+ {
+- Bool result, fresh;
++ Bool result;
+
+
+ arc[0].y = -arc[0].y;
+@@ -1325,13 +1196,8 @@
+ if ( degree > 2 )
+ arc[3].y = -arc[3].y;
+
+- fresh = ras.fresh;
+-
+ result = Bezier_Up( RAS_VARS degree, arc, splitter, -maxy, -miny );
+
+- if ( fresh && !ras.fresh )
+- ras.cProfile->start = -ras.cProfile->start;
+-
+ arc[0].y = -arc[0].y;
+ return result;
+ }
+@@ -1362,74 +1228,50 @@
+ Line_To( RAS_ARGS Long x,
+ Long y )
+ {
+- /* First, detect a change of direction */
++ TStates state;
+
+- switch ( ras.state )
+- {
+- case Unknown_State:
+- if ( y > ras.lastY )
+- {
+- if ( New_Profile( RAS_VARS Ascending_State,
+- IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
+- return FAILURE;
+- }
+- else
+- {
+- if ( y < ras.lastY )
+- if ( New_Profile( RAS_VARS Descending_State,
+- IS_TOP_OVERSHOOT( ras.lastY ) ) )
+- return FAILURE;
+- }
+- break;
+
+- case Ascending_State:
+- if ( y < ras.lastY )
+- {
+- if ( End_Profile( RAS_VARS IS_TOP_OVERSHOOT( ras.lastY ) ) ||
+- New_Profile( RAS_VARS Descending_State,
+- IS_TOP_OVERSHOOT( ras.lastY ) ) )
+- return FAILURE;
+- }
+- break;
++ if ( y == ras.lastY )
++ goto Fin;
+
+- case Descending_State:
+- if ( y > ras.lastY )
+- {
+- if ( End_Profile( RAS_VARS IS_BOTTOM_OVERSHOOT( ras.lastY ) ) ||
+- New_Profile( RAS_VARS Ascending_State,
+- IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
+- return FAILURE;
+- }
+- break;
++ /* First, detect a change of direction */
+
+- default:
+- ;
++ state = ras.lastY < y ? Ascending_State : Descending_State;
++
++ if ( ras.state != state )
++ {
++ /* finalize current profile if any */
++ if ( ras.state != Unknown_State &&
++ End_Profile( RAS_VAR ) )
++ goto Fail;
++
++ /* create a new profile */
++ if ( New_Profile( RAS_VARS state ) )
++ goto Fail;
+ }
+
+ /* Then compute the lines */
+
+- switch ( ras.state )
++ if ( state == Ascending_State )
+ {
+- case Ascending_State:
+ if ( Line_Up( RAS_VARS ras.lastX, ras.lastY,
+ x, y, ras.minY, ras.maxY ) )
+- return FAILURE;
+- break;
+-
+- case Descending_State:
++ goto Fail;
++ }
++ else
++ {
+ if ( Line_Down( RAS_VARS ras.lastX, ras.lastY,
+ x, y, ras.minY, ras.maxY ) )
+- return FAILURE;
+- break;
+-
+- default:
+- ;
++ goto Fail;
+ }
+
++ Fin:
+ ras.lastX = x;
+ ras.lastY = y;
+-
+ return SUCCESS;
++
++ Fail:
++ return FAILURE;
+ }
+
+
+@@ -1500,7 +1342,7 @@
+ ymax = y1;
+ }
+
+- if ( y2 < ymin || y2 > ymax )
++ if ( y2 < FLOOR( ymin ) || y2 > CEILING( ymax ) )
+ {
+ /* this arc has no given direction, split it! */
+ Split_Conic( arc );
+@@ -1508,8 +1350,12 @@
+ }
+ else if ( y1 == y3 )
+ {
+- /* this arc is flat, ignore it and pop it from the Bezier stack */
++ /* this arc is flat, advance position */
++ /* and pop it from the Bezier stack */
+ arc -= 2;
++
++ ras.lastX = x3;
++ ras.lastY = y3;
+ }
+ else
+ {
+@@ -1518,18 +1364,13 @@
+ state_bez = y1 < y3 ? Ascending_State : Descending_State;
+ if ( ras.state != state_bez )
+ {
+- Bool o = ( state_bez == Ascending_State )
+- ? IS_BOTTOM_OVERSHOOT( y1 )
+- : IS_TOP_OVERSHOOT( y1 );
+-
+-
+ /* finalize current profile if any */
+ if ( ras.state != Unknown_State &&
+- End_Profile( RAS_VARS o ) )
++ End_Profile( RAS_VAR ) )
+ goto Fail;
+
+ /* create a new profile */
+- if ( New_Profile( RAS_VARS state_bez, o ) )
++ if ( New_Profile( RAS_VARS state_bez ) )
+ goto Fail;
+ }
+
+@@ -1545,13 +1386,13 @@
+ ras.minY, ras.maxY ) )
+ goto Fail;
+ arc -= 2;
++
++ ras.lastX = x3;
++ ras.lastY = y3;
+ }
+
+ } while ( arc >= arcs );
+
+- ras.lastX = x3;
+- ras.lastY = y3;
+-
+ return SUCCESS;
+
+ Fail:
+@@ -1648,7 +1489,7 @@
+ ymax2 = y2;
+ }
+
+- if ( ymin2 < ymin1 || ymax2 > ymax1 )
++ if ( ymin2 < FLOOR( ymin1 ) || ymax2 > CEILING( ymax1 ) )
+ {
+ /* this arc has no given direction, split it! */
+ Split_Cubic( arc );
+@@ -1656,27 +1497,26 @@
+ }
+ else if ( y1 == y4 )
+ {
+- /* this arc is flat, ignore it and pop it from the Bezier stack */
++ /* this arc is flat, advance position */
++ /* and pop it from the Bezier stack */
+ arc -= 3;
++
++ ras.lastX = x4;
++ ras.lastY = y4;
+ }
+ else
+ {
+- state_bez = ( y1 <= y4 ) ? Ascending_State : Descending_State;
++ state_bez = y1 < y4 ? Ascending_State : Descending_State;
+
+ /* detect a change of direction */
+ if ( ras.state != state_bez )
+ {
+- Bool o = ( state_bez == Ascending_State )
+- ? IS_BOTTOM_OVERSHOOT( y1 )
+- : IS_TOP_OVERSHOOT( y1 );
+-
+-
+ /* finalize current profile if any */
+ if ( ras.state != Unknown_State &&
+- End_Profile( RAS_VARS o ) )
++ End_Profile( RAS_VAR ) )
+ goto Fail;
+
+- if ( New_Profile( RAS_VARS state_bez, o ) )
++ if ( New_Profile( RAS_VARS state_bez ) )
+ goto Fail;
+ }
+
+@@ -1692,13 +1532,13 @@
+ ras.minY, ras.maxY ) )
+ goto Fail;
+ arc -= 3;
++
++ ras.lastX = x4;
++ ras.lastY = y4;
+ }
+
+ } while ( arc >= arcs );
+
+- ras.lastX = x4;
+- ras.lastY = y4;
+-
+ return SUCCESS;
+
+ Fail:
+@@ -1740,6 +1580,11 @@
+ *
+ * @Return:
+ * SUCCESS on success, FAILURE on error.
++ *
++ * @Note:
++ * Unlike FT_Outline_Decompose(), this function handles the scanmode
++ * dropout tags in the individual contours. Therefore, it cannot be
++ * replaced.
+ */
+ static Bool
+ Decompose_Curve( RAS_ARGS Int first,
+@@ -1753,7 +1598,7 @@
+ FT_Vector* points;
+ FT_Vector* point;
+ FT_Vector* limit;
+- char* tags;
++ FT_Byte* tags;
+
+ UInt tag; /* current point's state */
+
+@@ -1974,24 +1819,17 @@
+
+
+ ras.fProfile = NULL;
+- ras.joint = FALSE;
+- ras.fresh = FALSE;
+-
+- ras.maxBuff = ras.sizeBuff - AlignProfileSize;
++ ras.cProfile = NULL;
+
+- ras.numTurns = 0;
++ ras.top = ras.buff;
++ ras.maxBuff = ras.sizeBuff - 1; /* top reserve */
+
+- ras.cProfile = (PProfile)ras.top;
+- ras.cProfile->offset = ras.top;
+- ras.num_Profs = 0;
++ ras.numTurns = 0;
++ ras.num_Profs = 0;
+
+ last = -1;
+ for ( i = 0; i < ras.outline.n_contours; i++ )
+ {
+- PProfile lastProfile;
+- Bool o;
+-
+-
+ ras.state = Unknown_State;
+ ras.gProfile = NULL;
+
+@@ -2001,35 +1839,30 @@
+ if ( Decompose_Curve( RAS_VARS first, last, flipped ) )
+ return FAILURE;
+
++ /* Note that ras.gProfile can stay nil if the contour was */
++ /* too small to be drawn or degenerate. */
++ if ( !ras.gProfile )
++ continue;
++
+ /* we must now check whether the extreme arcs join or not */
+ if ( FRAC( ras.lastY ) == 0 &&
+ ras.lastY >= ras.minY &&
+ ras.lastY <= ras.maxY )
+- if ( ras.gProfile &&
+- ( ras.gProfile->flags & Flow_Up ) ==
++ if ( ( ras.gProfile->flags & Flow_Up ) ==
+ ( ras.cProfile->flags & Flow_Up ) )
+ ras.top--;
+- /* Note that ras.gProfile can be nil if the contour was too small */
+- /* to be drawn. */
+
+- lastProfile = ras.cProfile;
+- if ( ras.top != ras.cProfile->offset &&
+- ( ras.cProfile->flags & Flow_Up ) )
+- o = IS_TOP_OVERSHOOT( ras.lastY );
+- else
+- o = IS_BOTTOM_OVERSHOOT( ras.lastY );
+- if ( End_Profile( RAS_VARS o ) )
++ if ( End_Profile( RAS_VAR ) )
+ return FAILURE;
+
+- /* close the `next profile in contour' linked list */
+- if ( ras.gProfile )
+- lastProfile->next = ras.gProfile;
++ if ( !ras.fProfile )
++ ras.fProfile = ras.gProfile;
+ }
+
+- if ( Finalize_Profile_Table( RAS_VAR ) )
+- return FAILURE;
++ if ( ras.fProfile )
++ Finalize_Profile_Table( RAS_VAR );
+
+- return (Bool)( ras.top < ras.maxBuff ? SUCCESS : FAILURE );
++ return SUCCESS;
+ }
+
+
+@@ -2042,24 +1875,11 @@
+ /*************************************************************************/
+
+
+- /**************************************************************************
+- *
+- * Init_Linked
+- *
+- * Initializes an empty linked list.
+- */
+- static void
+- Init_Linked( TProfileList* l )
+- {
+- *l = NULL;
+- }
+-
+-
+ /**************************************************************************
+ *
+ * InsNew
+ *
+- * Inserts a new profile in a linked list.
++ * Inserts a new profile in a linked list, sorted by coordinate.
+ */
+ static void
+ InsNew( PProfileList list,
+@@ -2073,10 +1893,8 @@
+ current = *old;
+ x = profile->X;
+
+- while ( current )
++ while ( current && current->X < x )
+ {
+- if ( x < current->X )
+- break;
+ old = ¤t->link;
+ current = *old;
+ }
+@@ -2088,79 +1906,51 @@
+
+ /**************************************************************************
+ *
+- * DelOld
++ * Increment
+ *
+- * Removes an old profile from a linked list.
++ * Advances all profile in the list to the next scanline. It also
++ * sorts the trace list in the unlikely case of profile crossing.
++ * The profiles are inserted in sorted order. We might need a single
++ * swap to fix it when profiles (contours) cross.
++ * Bubble sort with immediate restart is good enough and simple.
+ */
+ static void
+- DelOld( PProfileList list,
+- const PProfile profile )
++ Increment( PProfileList list,
++ Int flow )
+ {
+- PProfile *old, current;
+-
++ PProfile *old, current, next;
+
+- old = list;
+- current = *old;
+
+- while ( current )
++ /* First, set the new X coordinates and remove exhausted profiles */
++ old = list;
++ while ( *old )
+ {
+- if ( current == profile )
++ current = *old;
++ if ( --current->height )
+ {
+- *old = current->link;
+- return;
++ current->offset += flow;
++ current->X = current->x[current->offset];
++ old = ¤t->link;
+ }
+-
+- old = ¤t->link;
+- current = *old;
+- }
+-
+- /* we should never get there, unless the profile was not part of */
+- /* the list. */
+- }
+-
+-
+- /**************************************************************************
+- *
+- * Sort
+- *
+- * Sorts a trace list. In 95%, the list is already sorted. We need
+- * an algorithm which is fast in this case. Bubble sort is enough
+- * and simple.
+- */
+- static void
+- Sort( PProfileList list )
+- {
+- PProfile *old, current, next;
+-
+-
+- /* First, set the new X coordinate of each profile */
+- current = *list;
+- while ( current )
+- {
+- current->X = *current->offset;
+- current->offset += ( current->flags & Flow_Up ) ? 1 : -1;
+- current->height--;
+- current = current->link;
++ else
++ *old = current->link; /* remove */
+ }
+
+- /* Then sort them */
++ /* Then make sure the list remains sorted */
+ old = list;
+ current = *old;
+
+ if ( !current )
+ return;
+
+- next = current->link;
+-
+- while ( next )
++ while ( current->link )
+ {
++ next = current->link;
++
+ if ( current->X <= next->X )
+ {
+ old = ¤t->link;
+- current = *old;
+-
+- if ( !current )
+- return;
++ current = next;
+ }
+ else
+ {
+@@ -2168,11 +1958,10 @@
+ current->link = next->link;
+ next->link = current;
+
++ /* this is likely the only necessary swap -- restart */
+ old = list;
+ current = *old;
+ }
+-
+- next = current->link;
+ }
+ }
+
+@@ -2187,74 +1976,51 @@
+ */
+
+ static void
+- Vertical_Sweep_Init( RAS_ARGS Short min,
+- Short max )
++ Vertical_Sweep_Init( RAS_ARGS Int min,
++ Int max )
+ {
+ FT_UNUSED( max );
+
+
+- ras.bLine = ras.bOrigin - min * ras.target.pitch;
++ ras.bLine = ras.bOrigin - min * ras.bPitch;
+ }
+
+
+ static void
+- Vertical_Sweep_Span( RAS_ARGS Short y,
++ Vertical_Sweep_Span( RAS_ARGS Int y,
+ FT_F26Dot6 x1,
+- FT_F26Dot6 x2,
+- PProfile left,
+- PProfile right )
++ FT_F26Dot6 x2 )
+ {
+- Long e1, e2;
+-
+- Int dropOutControl = left->flags & 7;
++ Int e1 = (Int)TRUNC( CEILING( x1 ) );
++ Int e2 = (Int)TRUNC( FLOOR( x2 ) );
+
+ FT_UNUSED( y );
+- FT_UNUSED( left );
+- FT_UNUSED( right );
+
+
+- /* in high-precision mode, we need 12 digits after the comma to */
+- /* represent multiples of 1/(1<<12) = 1/4096 */
+- FT_TRACE7(( " y=%d x=[% .12f;% .12f]",
++ FT_TRACE7(( " y=%d x=[% .*f;% .*f]",
+ y,
+- (double)x1 / (double)ras.precision,
+- (double)x2 / (double)ras.precision ));
+-
+- /* Drop-out control */
+-
+- e1 = CEILING( x1 );
+- e2 = FLOOR( x2 );
+-
+- /* take care of the special case where both the left */
+- /* and right contour lie exactly on pixel centers */
+- if ( dropOutControl != 2 &&
+- x2 - x1 - ras.precision <= ras.precision_jitter &&
+- e1 != x1 && e2 != x2 )
+- e2 = e1;
++ ras.precision_bits, (double)x1 / (double)ras.precision,
++ ras.precision_bits, (double)x2 / (double)ras.precision ));
+
+- e1 = TRUNC( e1 );
+- e2 = TRUNC( e2 );
+-
+- if ( e2 >= 0 && e1 < ras.bWidth )
++ if ( e2 >= 0 && e1 <= ras.bRight )
+ {
+- Byte* target;
++ PByte target;
+
+- Int c1, c2;
+- Byte f1, f2;
++ Int c1, f1, c2, f2;
+
+
+ if ( e1 < 0 )
+ e1 = 0;
+- if ( e2 >= ras.bWidth )
+- e2 = ras.bWidth - 1;
++ if ( e2 > ras.bRight )
++ e2 = ras.bRight;
+
+- FT_TRACE7(( " -> x=[%ld;%ld]", e1, e2 ));
++ FT_TRACE7(( " -> x=[%d;%d]", e1, e2 ));
+
+- c1 = (Short)( e1 >> 3 );
+- c2 = (Short)( e2 >> 3 );
++ c1 = e1 >> 3;
++ c2 = e2 >> 3;
+
+- f1 = (Byte) ( 0xFF >> ( e1 & 7 ) );
+- f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) );
++ f1 = 0xFF >> ( e1 & 7 );
++ f2 = ~0x7F >> ( e2 & 7 );
+
+ target = ras.bLine + c1;
+ c2 -= c1;
+@@ -2280,163 +2046,50 @@
+
+
+ static void
+- Vertical_Sweep_Drop( RAS_ARGS Short y,
++ Vertical_Sweep_Drop( RAS_ARGS Int y,
+ FT_F26Dot6 x1,
+- FT_F26Dot6 x2,
+- PProfile left,
+- PProfile right )
++ FT_F26Dot6 x2 )
+ {
+- Long e1, e2, pxl;
+- Short c1, f1;
+-
+-
+- FT_TRACE7(( " y=%d x=[% .12f;% .12f]",
+- y,
+- (double)x1 / (double)ras.precision,
+- (double)x2 / (double)ras.precision ));
+-
+- /* Drop-out control */
+-
+- /* e2 x2 x1 e1 */
+- /* */
+- /* ^ | */
+- /* | | */
+- /* +-------------+---------------------+------------+ */
+- /* | | */
+- /* | v */
+- /* */
+- /* pixel contour contour pixel */
+- /* center center */
+-
+- /* drop-out mode scan conversion rules (as defined in OpenType) */
+- /* --------------------------------------------------------------- */
+- /* 0 1, 2, 3 */
+- /* 1 1, 2, 4 */
+- /* 2 1, 2 */
+- /* 3 same as mode 2 */
+- /* 4 1, 2, 5 */
+- /* 5 1, 2, 6 */
+- /* 6, 7 same as mode 2 */
+-
+- e1 = CEILING( x1 );
+- e2 = FLOOR ( x2 );
+- pxl = e1;
+-
+- if ( e1 > e2 )
+- {
+- Int dropOutControl = left->flags & 7;
+-
+-
+- if ( e1 == e2 + ras.precision )
+- {
+- switch ( dropOutControl )
+- {
+- case 0: /* simple drop-outs including stubs */
+- pxl = e2;
+- break;
+-
+- case 4: /* smart drop-outs including stubs */
+- pxl = SMART( x1, x2 );
+- break;
+-
+- case 1: /* simple drop-outs excluding stubs */
+- case 5: /* smart drop-outs excluding stubs */
+-
+- /* Drop-out Control Rules #4 and #6 */
+-
+- /* The specification neither provides an exact definition */
+- /* of a `stub' nor gives exact rules to exclude them. */
+- /* */
+- /* Here the constraints we use to recognize a stub. */
+- /* */
+- /* upper stub: */
+- /* */
+- /* - P_Left and P_Right are in the same contour */
+- /* - P_Right is the successor of P_Left in that contour */
+- /* - y is the top of P_Left and P_Right */
+- /* */
+- /* lower stub: */
+- /* */
+- /* - P_Left and P_Right are in the same contour */
+- /* - P_Left is the successor of P_Right in that contour */
+- /* - y is the bottom of P_Left */
+- /* */
+- /* We draw a stub if the following constraints are met. */
+- /* */
+- /* - for an upper or lower stub, there is top or bottom */
+- /* overshoot, respectively */
+- /* - the covered interval is greater or equal to a half */
+- /* pixel */
+-
+- /* upper stub test */
+- if ( left->next == right &&
+- left->height <= 0 &&
+- !( left->flags & Overshoot_Top &&
+- x2 - x1 >= ras.precision_half ) )
+- goto Exit;
+-
+- /* lower stub test */
+- if ( right->next == left &&
+- left->start == y &&
+- !( left->flags & Overshoot_Bottom &&
+- x2 - x1 >= ras.precision_half ) )
+- goto Exit;
+-
+- if ( dropOutControl == 1 )
+- pxl = e2;
+- else
+- pxl = SMART( x1, x2 );
+- break;
+-
+- default: /* modes 2, 3, 6, 7 */
+- goto Exit; /* no drop-out control */
+- }
++ Int e1 = (Int)TRUNC( x1 );
++ Int e2 = (Int)TRUNC( x2 );
++ Int c1, f1;
+
+- /* undocumented but confirmed: If the drop-out would result in a */
+- /* pixel outside of the bounding box, use the pixel inside of the */
+- /* bounding box instead */
+- if ( pxl < 0 )
+- pxl = e1;
+- else if ( TRUNC( pxl ) >= ras.bWidth )
+- pxl = e2;
++ FT_UNUSED( y );
+
+- /* check that the other pixel isn't set */
+- e1 = ( pxl == e1 ) ? e2 : e1;
+
+- e1 = TRUNC( e1 );
++ /* undocumented but confirmed: If the drop-out would result in a */
++ /* pixel outside of the bounding box, use the pixel inside of the */
++ /* bounding box instead */
++ if ( e1 < 0 || e1 > ras.bRight )
++ e1 = e2;
+
+- c1 = (Short)( e1 >> 3 );
+- f1 = (Short)( e1 & 7 );
++ /* otherwise check that the other pixel isn't set */
++ else if ( e2 >=0 && e2 <= ras.bRight )
++ {
++ c1 = e2 >> 3;
++ f1 = 0x80 >> ( e2 & 7 );
+
+- if ( e1 >= 0 && e1 < ras.bWidth &&
+- ras.bLine[c1] & ( 0x80 >> f1 ) )
+- goto Exit;
+- }
+- else
+- goto Exit;
++ if ( ras.bLine[c1] & f1 )
++ return;
+ }
+
+- e1 = TRUNC( pxl );
+-
+- if ( e1 >= 0 && e1 < ras.bWidth )
++ if ( e1 >= 0 && e1 <= ras.bRight )
+ {
+- FT_TRACE7(( " -> x=%ld", e1 ));
++ c1 = e1 >> 3;
++ f1 = 0x80 >> ( e1 & 7 );
+
+- c1 = (Short)( e1 >> 3 );
+- f1 = (Short)( e1 & 7 );
++ FT_TRACE7(( " y=%d x=%d%s\n", y, e1,
++ ras.bLine[c1] & f1 ? " redundant" : "" ));
+
+- ras.bLine[c1] |= (char)( 0x80 >> f1 );
++ ras.bLine[c1] |= f1;
+ }
+-
+- Exit:
+- FT_TRACE7(( " dropout=%d\n", left->flags & 7 ));
+ }
+
+
+ static void
+ Vertical_Sweep_Step( RAS_ARG )
+ {
+- ras.bLine -= ras.target.pitch;
++ ras.bLine -= ras.bPitch;
+ }
+
+
+@@ -2450,8 +2103,8 @@
+ */
+
+ static void
+- Horizontal_Sweep_Init( RAS_ARGS Short min,
+- Short max )
++ Horizontal_Sweep_Init( RAS_ARGS Int min,
++ Int max )
+ {
+ /* nothing, really */
+ FT_UNUSED_RASTER;
+@@ -2461,22 +2114,18 @@
+
+
+ static void
+- Horizontal_Sweep_Span( RAS_ARGS Short y,
++ Horizontal_Sweep_Span( RAS_ARGS Int y,
+ FT_F26Dot6 x1,
+- FT_F26Dot6 x2,
+- PProfile left,
+- PProfile right )
++ FT_F26Dot6 x2 )
+ {
+- Long e1, e2;
++ Long e1 = CEILING( x1 );
++ Long e2 = FLOOR( x2 );
+
+- FT_UNUSED( left );
+- FT_UNUSED( right );
+
+-
+- FT_TRACE7(( " x=%d y=[% .12f;% .12f]",
++ FT_TRACE7(( " x=%d y=[% .*f;% .*f]",
+ y,
+- (double)x1 / (double)ras.precision,
+- (double)x2 / (double)ras.precision ));
++ ras.precision_bits, (double)x1 / (double)ras.precision,
++ ras.precision_bits, (double)x2 / (double)ras.precision ));
+
+ /* We should not need this procedure but the vertical sweep */
+ /* mishandles horizontal lines through pixel centers. So we */
+@@ -2484,20 +2133,18 @@
+ /* */
+ /* XXX: Can we handle horizontal lines better and drop this? */
+
+- e1 = CEILING( x1 );
+-
+ if ( x1 == e1 )
+ {
+ e1 = TRUNC( e1 );
+
+- if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
++ if ( e1 >= 0 && e1 <= ras.bTop )
+ {
+- Byte f1;
++ Int f1;
+ PByte bits;
+
+
+- bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch;
+- f1 = (Byte)( 0x80 >> ( y & 7 ) );
++ bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.bPitch;
++ f1 = 0x80 >> ( y & 7 );
+
+ FT_TRACE7(( bits[0] & f1 ? " redundant"
+ : " -> y=%ld edge", e1 ));
+@@ -2506,20 +2153,18 @@
+ }
+ }
+
+- e2 = FLOOR ( x2 );
+-
+ if ( x2 == e2 )
+ {
+ e2 = TRUNC( e2 );
+
+- if ( e2 >= 0 && (ULong)e2 < ras.target.rows )
++ if ( e2 >= 0 && e2 <= ras.bTop )
+ {
+- Byte f1;
++ Int f1;
+ PByte bits;
+
+
+- bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.target.pitch;
+- f1 = (Byte)( 0x80 >> ( y & 7 ) );
++ bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.bPitch;
++ f1 = 0x80 >> ( y & 7 );
+
+ FT_TRACE7(( bits[0] & f1 ? " redundant"
+ : " -> y=%ld edge", e2 ));
+@@ -2533,122 +2178,42 @@
+
+
+ static void
+- Horizontal_Sweep_Drop( RAS_ARGS Short y,
++ Horizontal_Sweep_Drop( RAS_ARGS Int y,
+ FT_F26Dot6 x1,
+- FT_F26Dot6 x2,
+- PProfile left,
+- PProfile right )
++ FT_F26Dot6 x2 )
+ {
+- Long e1, e2, pxl;
++ Int e1 = (Int)TRUNC( x1 );
++ Int e2 = (Int)TRUNC( x2 );
+ PByte bits;
+- Byte f1;
+-
+-
+- FT_TRACE7(( " x=%d y=[% .12f;% .12f]",
+- y,
+- (double)x1 / (double)ras.precision,
+- (double)x2 / (double)ras.precision ));
+-
+- /* During the horizontal sweep, we only take care of drop-outs */
+-
+- /* e1 + <-- pixel center */
+- /* | */
+- /* x1 ---+--> <-- contour */
+- /* | */
+- /* | */
+- /* x2 <--+--- <-- contour */
+- /* | */
+- /* | */
+- /* e2 + <-- pixel center */
+-
+- e1 = CEILING( x1 );
+- e2 = FLOOR ( x2 );
+- pxl = e1;
+-
+- if ( e1 > e2 )
+- {
+- Int dropOutControl = left->flags & 7;
+-
++ Int f1;
+
+- if ( e1 == e2 + ras.precision )
+- {
+- switch ( dropOutControl )
+- {
+- case 0: /* simple drop-outs including stubs */
+- pxl = e2;
+- break;
+-
+- case 4: /* smart drop-outs including stubs */
+- pxl = SMART( x1, x2 );
+- break;
+-
+- case 1: /* simple drop-outs excluding stubs */
+- case 5: /* smart drop-outs excluding stubs */
+- /* see Vertical_Sweep_Drop for details */
+-
+- /* rightmost stub test */
+- if ( left->next == right &&
+- left->height <= 0 &&
+- !( left->flags & Overshoot_Top &&
+- x2 - x1 >= ras.precision_half ) )
+- goto Exit;
+-
+- /* leftmost stub test */
+- if ( right->next == left &&
+- left->start == y &&
+- !( left->flags & Overshoot_Bottom &&
+- x2 - x1 >= ras.precision_half ) )
+- goto Exit;
+-
+- if ( dropOutControl == 1 )
+- pxl = e2;
+- else
+- pxl = SMART( x1, x2 );
+- break;
+
+- default: /* modes 2, 3, 6, 7 */
+- goto Exit; /* no drop-out control */
+- }
+-
+- /* undocumented but confirmed: If the drop-out would result in a */
+- /* pixel outside of the bounding box, use the pixel inside of the */
+- /* bounding box instead */
+- if ( pxl < 0 )
+- pxl = e1;
+- else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
+- pxl = e2;
+-
+- /* check that the other pixel isn't set */
+- e1 = ( pxl == e1 ) ? e2 : e1;
+-
+- e1 = TRUNC( e1 );
++ /* undocumented but confirmed: If the drop-out would result in a */
++ /* pixel outside of the bounding box, use the pixel inside of the */
++ /* bounding box instead */
++ if ( e1 < 0 || e1 > ras.bTop )
++ e1 = e2;
+
+- bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch;
+- f1 = (Byte)( 0x80 >> ( y & 7 ) );
++ /* otherwise check that the other pixel isn't set */
++ else if ( e2 >=0 && e2 <= ras.bTop )
++ {
++ bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.bPitch;
++ f1 = 0x80 >> ( y & 7 );
+
+- if ( e1 >= 0 &&
+- (ULong)e1 < ras.target.rows &&
+- *bits & f1 )
+- goto Exit;
+- }
+- else
+- goto Exit;
++ if ( *bits & f1 )
++ return;
+ }
+
+- e1 = TRUNC( pxl );
+-
+- if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
++ if ( e1 >= 0 && e1 <= ras.bTop )
+ {
+- FT_TRACE7(( " -> y=%ld", e1 ));
++ bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.bPitch;
++ f1 = 0x80 >> ( y & 7 );
+
+- bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch;
+- f1 = (Byte)( 0x80 >> ( y & 7 ) );
++ FT_TRACE7(( " x=%d y=%d%s\n", y, e1,
++ *bits & f1 ? " redundant" : "" ));
+
+- bits[0] |= f1;
++ *bits |= f1;
+ }
+-
+- Exit:
+- FT_TRACE7(( " dropout=%d\n", left->flags & 7 ));
+ }
+
+
+@@ -2664,116 +2229,61 @@
+ *
+ * Generic Sweep Drawing routine
+ *
++ * Note that this routine is executed with the pool containing at least
++ * two valid profiles (up and down) and two y-turns (top and bottom).
++ *
+ */
+
+- static Bool
++ static void
+ Draw_Sweep( RAS_ARG )
+ {
+- Short y, y_change, y_height;
+-
+- PProfile P, Q, P_Left, P_Right;
+-
+- Short min_Y, max_Y, top, bottom, dropouts;
+-
+- Long x1, x2, xs, e1, e2;
+-
+- TProfileList waiting;
+- TProfileList draw_left, draw_right;
+-
+-
+- /* initialize empty linked lists */
+-
+- Init_Linked( &waiting );
+-
+- Init_Linked( &draw_left );
+- Init_Linked( &draw_right );
+-
+- /* first, compute min and max Y */
+-
+- P = ras.fProfile;
+- max_Y = (Short)TRUNC( ras.minY );
+- min_Y = (Short)TRUNC( ras.maxY );
+-
+- while ( P )
+- {
+- Q = P->link;
++ Int min_Y, max_Y, dropouts;
++ Int y, y_turn;
+
+- bottom = (Short)P->start;
+- top = (Short)( P->start + P->height - 1 );
++ PProfile *Q, P, P_Left, P_Right;
+
+- if ( min_Y > bottom )
+- min_Y = bottom;
+- if ( max_Y < top )
+- max_Y = top;
++ TProfileList waiting = ras.fProfile;
++ TProfileList draw_left = NULL;
++ TProfileList draw_right = NULL;
+
+- P->X = 0;
+- InsNew( &waiting, P );
+
+- P = Q;
+- }
++ /* use y_turns to set the drawing range */
+
+- /* check the Y-turns */
+- if ( ras.numTurns == 0 )
+- {
+- ras.error = FT_THROW( Invalid_Outline );
+- return FAILURE;
+- }
++ min_Y = (Int)ras.maxBuff[0];
++ max_Y = (Int)ras.maxBuff[ras.numTurns] - 1;
+
+ /* now initialize the sweep */
+
+ ras.Proc_Sweep_Init( RAS_VARS min_Y, max_Y );
+
+- /* then compute the distance of each profile from min_Y */
+-
+- P = waiting;
+-
+- while ( P )
+- {
+- P->countL = P->start - min_Y;
+- P = P->link;
+- }
+-
+ /* let's go */
+
+- y = min_Y;
+- y_height = 0;
+-
+- if ( ras.numTurns > 0 &&
+- ras.sizeBuff[-ras.numTurns] == min_Y )
+- ras.numTurns--;
+-
+- while ( ras.numTurns > 0 )
++ for ( y = min_Y; y <= max_Y; )
+ {
+- /* check waiting list for new activations */
+-
+- P = waiting;
++ /* check waiting list for new profile activations */
+
+- while ( P )
++ Q = &waiting;
++ while ( *Q )
+ {
+- Q = P->link;
+- P->countL -= y_height;
+- if ( P->countL == 0 )
++ P = *Q;
++ if ( P->start == y )
+ {
+- DelOld( &waiting, P );
++ *Q = P->link; /* remove */
+
++ /* each active list contains profiles with the same flow */
++ /* left and right are arbitrary, correspond to TrueType */
+ if ( P->flags & Flow_Up )
+ InsNew( &draw_left, P );
+ else
+ InsNew( &draw_right, P );
+ }
+-
+- P = Q;
++ else
++ Q = &P->link;
+ }
+
+- /* sort the drawing lists */
++ y_turn = (Int)*++ras.maxBuff;
+
+- Sort( &draw_left );
+- Sort( &draw_right );
+-
+- y_change = (Short)ras.sizeBuff[-ras.numTurns--];
+- y_height = (Short)( y_change - y );
+-
+- while ( y < y_change )
++ do
+ {
+ /* let's trace */
+
+@@ -2784,9 +2294,13 @@
+
+ while ( P_Left && P_Right )
+ {
+- x1 = P_Left ->X;
+- x2 = P_Right->X;
++ Long x1 = P_Left ->X;
++ Long x2 = P_Right->X;
++ Long xs;
++
+
++ /* TrueType should have x2 > x1, but can be opposite */
++ /* by mistake or in CFF/Type1, fix it then */
+ if ( x1 > x2 )
+ {
+ xs = x1;
+@@ -2794,205 +2308,130 @@
+ x2 = xs;
+ }
+
+- e1 = FLOOR( x1 );
+- e2 = CEILING( x2 );
++ if ( CEILING( x1 ) <= FLOOR( x2 ) )
++ ras.Proc_Sweep_Span( RAS_VARS y, x1, x2 );
+
+- if ( x2 - x1 <= ras.precision &&
+- e1 != x1 && e2 != x2 )
++ /* otherwise, bottom ceiling > top floor, it is a drop-out */
++ else
+ {
+- if ( e1 > e2 || e2 == e1 + ras.precision )
++ Int dropOutControl = P_Left->flags & 7;
++
++
++ /* Drop-out control */
++
++ /* e2 x2 x1 e1 */
++ /* */
++ /* ^ | */
++ /* | | */
++ /* +-------------+---------------------+------------+ */
++ /* | | */
++ /* | v */
++ /* */
++ /* pixel contour contour pixel */
++ /* center center */
++
++ /* drop-out mode scan conversion rules (OpenType specs) */
++ /* ------------------------------------------------------- */
++ /* bit 0 exclude stubs if set */
++ /* bit 1 ignore drop-outs if set */
++ /* bit 2 smart rounding if set */
++
++ if ( dropOutControl & 2 )
++ goto Next_Pair;
++
++ /* The specification neither provides an exact definition */
++ /* of a `stub' nor gives exact rules to exclude them. */
++ /* */
++ /* Here the constraints we use to recognize a stub. */
++ /* */
++ /* upper stub: */
++ /* */
++ /* - P_Left and P_Right are in the same contour */
++ /* - P_Right is the successor of P_Left in that contour */
++ /* - y is the top of P_Left and P_Right */
++ /* */
++ /* lower stub: */
++ /* */
++ /* - P_Left and P_Right are in the same contour */
++ /* - P_Left is the successor of P_Right in that contour */
++ /* - y is the bottom of P_Left */
++ /* */
++ /* We draw a stub if the following constraints are met. */
++ /* */
++ /* - for an upper or lower stub, there is top or bottom */
++ /* overshoot, respectively */
++ /* - the covered interval is greater or equal to a half */
++ /* pixel */
++
++ if ( dropOutControl & 1 )
+ {
+- Int dropOutControl = P_Left->flags & 7;
+-
+-
+- if ( dropOutControl != 2 )
+- {
+- /* a drop-out was detected */
+-
+- P_Left ->X = x1;
+- P_Right->X = x2;
+-
+- /* mark profile for drop-out processing */
+- P_Left->countL = 1;
+- dropouts++;
+- }
++ /* upper stub test */
++ if ( P_Left->height == 1 &&
++ P_Left->next == P_Right &&
++ !( P_Left->flags & Overshoot_Top &&
++ x2 - x1 >= ras.precision_half ) )
++ goto Next_Pair;
++
++ /* lower stub test */
++ if ( P_Left->offset == 0 &&
++ P_Right->next == P_Left &&
++ !( P_Left->flags & Overshoot_Bottom &&
++ x2 - x1 >= ras.precision_half ) )
++ goto Next_Pair;
++ }
+
+- goto Skip_To_Next;
++ /* select the pixel to set and the other pixel */
++ if ( dropOutControl & 4 )
++ {
++ x2 = SMART( x1, x2 );
++ x1 = x1 > x2 ? x2 + ras.precision : x2 - ras.precision;
++ }
++ else
++ {
++ x2 = FLOOR ( x2 );
++ x1 = CEILING( x1 );
+ }
+- }
+
+- ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right );
++ P_Left ->X = x2;
++ P_Right->X = x1;
+
+- Skip_To_Next:
++ /* mark profile for drop-out processing */
++ P_Left->flags |= Dropout;
++ dropouts++;
++ }
+
++ Next_Pair:
+ P_Left = P_Left->link;
+ P_Right = P_Right->link;
+ }
+
+- /* handle drop-outs _after_ the span drawing -- */
+- /* drop-out processing has been moved out of the loop */
+- /* for performance tuning */
+- if ( dropouts > 0 )
+- goto Scan_DropOuts;
+-
+- Next_Line:
+-
+- ras.Proc_Sweep_Step( RAS_VAR );
+-
+- y++;
++ /* handle drop-outs _after_ the span drawing */
++ P_Left = draw_left;
++ P_Right = draw_right;
+
+- if ( y < y_change )
++ while ( dropouts )
+ {
+- Sort( &draw_left );
+- Sort( &draw_right );
+- }
+- }
+-
+- /* now finalize the profiles that need it */
+-
+- P = draw_left;
+- while ( P )
+- {
+- Q = P->link;
+- if ( P->height == 0 )
+- DelOld( &draw_left, P );
+- P = Q;
+- }
+-
+- P = draw_right;
+- while ( P )
+- {
+- Q = P->link;
+- if ( P->height == 0 )
+- DelOld( &draw_right, P );
+- P = Q;
+- }
+- }
+-
+- /* for gray-scaling, flush the bitmap scanline cache */
+- while ( y <= max_Y )
+- {
+- ras.Proc_Sweep_Step( RAS_VAR );
+- y++;
+- }
+-
+- return SUCCESS;
+-
+- Scan_DropOuts:
+-
+- P_Left = draw_left;
+- P_Right = draw_right;
+-
+- while ( P_Left && P_Right )
+- {
+- if ( P_Left->countL )
+- {
+- P_Left->countL = 0;
+-#if 0
+- dropouts--; /* -- this is useful when debugging only */
+-#endif
+- ras.Proc_Sweep_Drop( RAS_VARS y,
+- P_Left->X,
+- P_Right->X,
+- P_Left,
+- P_Right );
+- }
+-
+- P_Left = P_Left->link;
+- P_Right = P_Right->link;
+- }
+-
+- goto Next_Line;
+- }
+-
+-
+-#ifdef STANDALONE_
+-
+- /**************************************************************************
+- *
+- * The following functions should only compile in stand-alone mode,
+- * i.e., when building this component without the rest of FreeType.
+- *
+- */
+-
+- /**************************************************************************
+- *
+- * @Function:
+- * FT_Outline_Get_CBox
+- *
+- * @Description:
+- * Return an outline's `control box'. The control box encloses all
+- * the outline's points, including Bézier control points. Though it
+- * coincides with the exact bounding box for most glyphs, it can be
+- * slightly larger in some situations (like when rotating an outline
+- * that contains Bézier outside arcs).
+- *
+- * Computing the control box is very fast, while getting the bounding
+- * box can take much more time as it needs to walk over all segments
+- * and arcs in the outline. To get the latter, you can use the
+- * `ftbbox' component, which is dedicated to this single task.
+- *
+- * @Input:
+- * outline ::
+- * A pointer to the source outline descriptor.
+- *
+- * @Output:
+- * acbox ::
+- * The outline's control box.
+- *
+- * @Note:
+- * See @FT_Glyph_Get_CBox for a discussion of tricky fonts.
+- */
+-
+- static void
+- FT_Outline_Get_CBox( const FT_Outline* outline,
+- FT_BBox *acbox )
+- {
+- if ( outline && acbox )
+- {
+- Long xMin, yMin, xMax, yMax;
+-
+-
+- if ( outline->n_points == 0 )
+- {
+- xMin = 0;
+- yMin = 0;
+- xMax = 0;
+- yMax = 0;
+- }
+- else
+- {
+- FT_Vector* vec = outline->points;
+- FT_Vector* limit = vec + outline->n_points;
+-
+-
+- xMin = xMax = vec->x;
+- yMin = yMax = vec->y;
+- vec++;
++ if ( P_Left->flags & Dropout )
++ {
++ ras.Proc_Sweep_Drop( RAS_VARS y, P_Left->X, P_Right->X );
+
+- for ( ; vec < limit; vec++ )
+- {
+- Long x, y;
++ P_Left->flags &= ~Dropout;
++ dropouts--;
++ }
+
++ P_Left = P_Left->link;
++ P_Right = P_Right->link;
++ }
+
+- x = vec->x;
+- if ( x < xMin ) xMin = x;
+- if ( x > xMax ) xMax = x;
++ ras.Proc_Sweep_Step( RAS_VAR );
+
+- y = vec->y;
+- if ( y < yMin ) yMin = y;
+- if ( y > yMax ) yMax = y;
+- }
++ Increment( &draw_left, 1 );
++ Increment( &draw_right, -1 );
+ }
+- acbox->xMin = xMin;
+- acbox->xMax = xMax;
+- acbox->yMin = yMin;
+- acbox->yMax = yMax;
++ while ( ++y < y_turn );
+ }
+ }
+
+-#endif /* STANDALONE_ */
+-
+
+ /**************************************************************************
+ *
+@@ -3019,13 +2458,15 @@
+ Int band_stack[32]; /* enough to bisect 32-bit int bands */
+
+
++ FT_TRACE6(( "%s pass [%d..%d]\n",
++ flipped ? "Horizontal" : "Vertical",
++ y_min, y_max ));
++
+ while ( 1 )
+ {
+ ras.minY = (Long)y_min * ras.precision;
+ ras.maxY = (Long)y_max * ras.precision;
+
+- ras.top = ras.buff;
+-
+ ras.error = Raster_Err_Ok;
+
+ if ( Convert_Glyph( RAS_VARS flipped ) )
+@@ -3038,6 +2479,9 @@
+ if ( y_min == y_max )
+ return ras.error; /* still Raster_Overflow */
+
++ FT_TRACE6(( "band [%d..%d]: to be bisected\n",
++ y_min, y_max ));
++
+ y_mid = ( y_min + y_max ) >> 1;
+
+ band_stack[band_top++] = y_min;
+@@ -3045,9 +2489,12 @@
+ }
+ else
+ {
++ FT_TRACE6(( "band [%d..%d]: %hd profiles; %td bytes remaining\n",
++ y_min, y_max, ras.num_Profs,
++ (char*)ras.maxBuff - (char*)ras.top ));
++
+ if ( ras.fProfile )
+- if ( Draw_Sweep( RAS_VAR ) )
+- return ras.error;
++ Draw_Sweep( RAS_VAR );
+
+ if ( --band_top < 0 )
+ break;
+@@ -3076,53 +2523,48 @@
+ Render_Glyph( RAS_ARG )
+ {
+ FT_Error error;
++ Long buffer[FT_MAX_BLACK_POOL];
+
+
++ ras.buff = buffer;
++ ras.sizeBuff = (&buffer)[1]; /* Points to right after buffer. */
++
+ Set_High_Precision( RAS_VARS ras.outline.flags &
+ FT_OUTLINE_HIGH_PRECISION );
+
++ ras.dropOutControl = 0;
++
+ if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
+- ras.dropOutControl = 2;
+- else
+- {
+- if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
+- ras.dropOutControl = 4;
+- else
+- ras.dropOutControl = 0;
++ ras.dropOutControl |= 2;
+
+- if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
+- ras.dropOutControl += 1;
+- }
++ if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
++ ras.dropOutControl |= 4;
+
+- /* Vertical Sweep */
+- FT_TRACE7(( "Vertical pass (ftraster)\n" ));
++ if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
++ ras.dropOutControl |= 1;
++
++ FT_TRACE6(( "BW Raster: precision 1/%d, dropout mode %d\n",
++ ras.precision, ras.dropOutControl ));
+
++ /* Vertical Sweep */
+ ras.Proc_Sweep_Init = Vertical_Sweep_Init;
+ ras.Proc_Sweep_Span = Vertical_Sweep_Span;
+ ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
+ ras.Proc_Sweep_Step = Vertical_Sweep_Step;
+
+- ras.bWidth = (UShort)ras.target.width;
+- ras.bOrigin = (Byte*)ras.target.buffer;
+-
+- if ( ras.target.pitch > 0 )
+- ras.bOrigin += (Long)( ras.target.rows - 1 ) * ras.target.pitch;
+-
+- error = Render_Single_Pass( RAS_VARS 0, 0, (Int)ras.target.rows - 1 );
++ error = Render_Single_Pass( RAS_VARS 0, 0, ras.bTop );
+ if ( error )
+ return error;
+
+ /* Horizontal Sweep */
+ if ( !( ras.outline.flags & FT_OUTLINE_SINGLE_PASS ) )
+ {
+- FT_TRACE7(( "Horizontal pass (ftraster)\n" ));
+-
+ ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
+ ras.Proc_Sweep_Span = Horizontal_Sweep_Span;
+ ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop;
+ ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
+
+- error = Render_Single_Pass( RAS_VARS 1, 0, (Int)ras.target.width - 1 );
++ error = Render_Single_Pass( RAS_VARS 1, 0, ras.bRight );
+ if ( error )
+ return error;
+ }
+@@ -3233,8 +2675,6 @@
+ black_TWorker worker[1];
+ #endif
+
+- Long buffer[FT_MAX_BLACK_POOL];
+-
+
+ if ( !raster )
+ return FT_THROW( Raster_Uninitialized );
+@@ -3243,7 +2683,7 @@
+ return FT_THROW( Invalid_Outline );
+
+ /* return immediately if the outline is empty */
+- if ( outline->n_points == 0 || outline->n_contours <= 0 )
++ if ( outline->n_points == 0 || outline->n_contours == 0 )
+ return Raster_Err_Ok;
+
+ if ( !outline->contours || !outline->points )
+@@ -3269,10 +2709,14 @@
+ return FT_THROW( Invalid_Argument );
+
+ ras.outline = *outline;
+- ras.target = *target_map;
+
+- ras.buff = buffer;
+- ras.sizeBuff = (&buffer)[1]; /* Points to right after buffer. */
++ ras.bTop = (Int)target_map->rows - 1;
++ ras.bRight = (Int)target_map->width - 1;
++ ras.bPitch = (Int)target_map->pitch;
++ ras.bOrigin = (PByte)target_map->buffer;
++
++ if ( ras.bPitch > 0 )
++ ras.bOrigin += ras.bTop * ras.bPitch;
+
+ return Render_Glyph( RAS_VAR );
+ }
+diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h
+index b511b3a99..ad9cb1b9f 100644
+--- a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h
++++ b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType glyph rasterizer (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used
+diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c
+index 6d442b1ff..fd9f174f2 100644
+--- a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c
++++ b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType glyph rasterizer interface (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h
+index cec35c852..cf3e73c0a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h
++++ b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h
+@@ -4,7 +4,7 @@
+ *
+ * The FreeType glyph rasterizer interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h b/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h
+index 989d8b44b..326d42e04 100644
+--- a/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h
++++ b/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h
+@@ -4,7 +4,7 @@
+ *
+ * monochrome renderer error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c
+index 33712162e..76181568a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c
+@@ -4,7 +4,7 @@
+ *
+ * PNG Bitmap glyph support.
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * Google, Inc.
+ * Written by Stuart Gill and Behdad Esfahbod.
+ *
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h
+index 903bd2bc3..6e7a5c08e 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h
+@@ -4,7 +4,7 @@
+ *
+ * PNG Bitmap glyph support.
+ *
+- * Copyright (C) 2013-2023 by
++ * Copyright (C) 2013-2024 by
+ * Google, Inc.
+ * Written by Stuart Gill and Behdad Esfahbod.
+ *
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c
+index 0925940b0..81072207b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c
+@@ -4,7 +4,7 @@
+ *
+ * High-level SFNT driver interface (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -49,6 +49,10 @@
+ #include
+ #endif
+
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++#include "ttgpos.h"
++#endif
++
+ #include "ttcmap.h"
+ #include "ttkern.h"
+ #include "ttmtx.h"
+@@ -1249,6 +1253,12 @@
+ #define PUT_PS_NAMES( a ) a
+ #else
+ #define PUT_PS_NAMES( a ) NULL
++#endif
++
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++#define PUT_GPOS_KERNING( a ) a
++#else
++#define PUT_GPOS_KERNING( a ) NULL
+ #endif
+
+ FT_DEFINE_SFNT_INTERFACE(
+@@ -1274,6 +1284,8 @@
+ tt_face_free_name, /* TT_Free_Table_Func free_name */
+
+ tt_face_load_kern, /* TT_Load_Table_Func load_kern */
++ PUT_GPOS_KERNING( tt_face_load_gpos ),
++ /* TT_Load_Table_Func load_gpos */
+ tt_face_load_gasp, /* TT_Load_Table_Func load_gasp */
+ tt_face_load_pclt, /* TT_Load_Table_Func load_init */
+
+@@ -1292,6 +1304,9 @@
+ /* since version 2.1.8 */
+ tt_face_get_kerning, /* TT_Face_GetKerningFunc get_kerning */
+
++ PUT_GPOS_KERNING( tt_face_get_gpos_kerning ),
++ /* TT_Face_GetKerningFunc get_gpos_kerning */
++
+ /* since version 2.2 */
+ tt_face_load_font_dir, /* TT_Load_Table_Func load_font_dir */
+ tt_face_load_hmtx, /* TT_Load_Metrics_Func load_hmtx */
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h
+index 2445958b6..6f71489fd 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level SFNT driver interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h
+index e7a8eb04b..d3ca1d9aa 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h
+@@ -4,7 +4,7 @@
+ *
+ * SFNT error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c
+index f5d66ef84..6ee4e5e93 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c
+@@ -4,7 +4,7 @@
+ *
+ * SFNT object management (base).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -40,6 +40,10 @@
+ #include "ttbdf.h"
+ #endif
+
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++#include "ttgpos.h"
++#endif
++
+
+ /**************************************************************************
+ *
+@@ -1026,6 +1030,10 @@
+ LOAD_( gasp );
+ LOAD_( kern );
+
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++ LOAD_( gpos );
++#endif
++
+ face->root.num_glyphs = face->max_profile.numGlyphs;
+
+ /* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
+@@ -1119,7 +1127,11 @@
+ flags |= FT_FACE_FLAG_VERTICAL;
+
+ /* kerning available ? */
+- if ( TT_FACE_HAS_KERNING( face ) )
++ if ( TT_FACE_HAS_KERNING( face )
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++ || face->gpos_kerning_available
++#endif
++ )
+ flags |= FT_FACE_FLAG_KERNING;
+
+ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+@@ -1470,6 +1482,11 @@
+ /* freeing the kerning table */
+ tt_face_done_kern( face );
+
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++ /* freeing the GPOS table */
++ tt_face_done_gpos( face );
++#endif
++
+ /* freeing the collection table */
+ FT_FREE( face->ttc_header.offsets );
+ face->ttc_header.count = 0;
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h
+index 906aebbf9..90847d957 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h
+@@ -4,7 +4,7 @@
+ *
+ * SFNT object management (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c
+index 7c0ce2205..14514bf95 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c
+@@ -4,7 +4,7 @@
+ *
+ * WOFF format management (base).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -18,6 +18,7 @@
+
+ #include "sfwoff.h"
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -149,6 +150,7 @@
+ /* Miscellaneous checks. */
+ if ( woff.length != stream->size ||
+ woff.num_tables == 0 ||
++ woff.num_tables > 0xFFFU ||
+ 44 + woff.num_tables * 20UL >= woff.length ||
+ 12 + woff.num_tables * 16UL >= woff.totalSfntSize ||
+ ( woff.totalSfntSize & 3 ) != 0 ||
+@@ -169,21 +171,11 @@
+
+ /* Write sfnt header. */
+ {
+- FT_UInt searchRange, entrySelector, rangeShift, x;
++ FT_Int entrySelector = FT_MSB( woff.num_tables );
++ FT_Int searchRange = ( 1 << entrySelector ) * 16;
++ FT_Int rangeShift = woff.num_tables * 16 - searchRange;
+
+
+- x = woff.num_tables;
+- entrySelector = 0;
+- while ( x )
+- {
+- x >>= 1;
+- entrySelector += 1;
+- }
+- entrySelector--;
+-
+- searchRange = ( 1 << entrySelector ) * 16;
+- rangeShift = woff.num_tables * 16 - searchRange;
+-
+ WRITE_ULONG ( sfnt_header, woff.flavor );
+ WRITE_USHORT( sfnt_header, woff.num_tables );
+ WRITE_USHORT( sfnt_header, searchRange );
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h
+index d43842273..a04735ffe 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h
+@@ -4,7 +4,7 @@
+ *
+ * WOFFF format management (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c
+index 2be44a347..589b3e0c6 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c
+@@ -4,7 +4,7 @@
+ *
+ * WOFF2 format management (base).
+ *
+- * Copyright (C) 2019-2023 by
++ * Copyright (C) 2019-2024 by
+ * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -18,6 +18,7 @@
+ #include "sfwoff2.h"
+ #include "woff2tags.h"
+ #include
++#include
+ #include
+ #include
+
+@@ -289,23 +290,15 @@
+ FT_ULong checksum = 0;
+ FT_ULong aligned_size = size & ~3UL;
+ FT_ULong i;
+- FT_ULong v;
++ FT_Int shift;
+
+
+ for ( i = 0; i < aligned_size; i += 4 )
+- checksum += ( (FT_ULong)buf[i ] << 24 ) |
+- ( (FT_ULong)buf[i + 1] << 16 ) |
+- ( (FT_ULong)buf[i + 2] << 8 ) |
+- ( (FT_ULong)buf[i + 3] << 0 );
++ checksum += FT_NEXT_ULONG( buf );
+
+- /* If size is not aligned to 4, treat as if it is padded with 0s. */
+- if ( size != aligned_size )
+- {
+- v = 0;
+- for ( i = aligned_size ; i < size; ++i )
+- v |= (FT_ULong)buf[i] << ( 24 - 8 * ( i & 3 ) );
+- checksum += v;
+- }
++ /* remaining bytes can be shifted and added one at a time */
++ for ( shift = 24; i < size; i++, shift -= 8 )
++ checksum += (FT_UInt32)FT_NEXT_BYTE( buf ) << shift;
+
+ return checksum;
+ }
+@@ -1799,7 +1792,6 @@
+
+ FT_Byte* sfnt = NULL;
+ FT_Stream sfnt_stream = NULL;
+- FT_Byte* sfnt_header;
+ FT_ULong sfnt_size;
+
+ FT_Byte* uncompressed_buf = NULL;
+@@ -1853,6 +1845,7 @@
+ /* Miscellaneous checks. */
+ if ( woff2.length != stream->size ||
+ woff2.num_tables == 0 ||
++ woff2.num_tables > 0xFFFU ||
+ 48 + woff2.num_tables * 20UL >= woff2.length ||
+ ( woff2.metaOffset == 0 && ( woff2.metaLength != 0 ||
+ woff2.metaOrigLength != 0 ) ) ||
+@@ -2143,6 +2136,13 @@
+ WOFF2_TtcFont ttc_font = woff2.ttc_fonts + face_index;
+
+
++ if ( ttc_font->num_tables == 0 || ttc_font->num_tables > 0xFFFU )
++ {
++ FT_ERROR(( "woff2_open_font: invalid WOFF2 CollectionFontEntry\n" ));
++ error = FT_THROW( Invalid_Table );
++ goto Exit;
++ }
++
+ /* Create a temporary array. */
+ if ( FT_QNEW_ARRAY( temp_indices,
+ ttc_font->num_tables ) )
+@@ -2198,27 +2198,15 @@
+ FT_NEW( sfnt_stream ) )
+ goto Exit;
+
+- sfnt_header = sfnt;
+-
+- WRITE_ULONG( sfnt_header, woff2.flavor );
+-
+- if ( woff2.num_tables )
+ {
+- FT_UInt searchRange, entrySelector, rangeShift, x;
++ FT_Byte* sfnt_header = sfnt;
+
++ FT_Int entrySelector = FT_MSB( woff2.num_tables );
++ FT_Int searchRange = ( 1 << entrySelector ) * 16;
++ FT_Int rangeShift = woff2.num_tables * 16 - searchRange;
+
+- x = woff2.num_tables;
+- entrySelector = 0;
+- while ( x )
+- {
+- x >>= 1;
+- entrySelector += 1;
+- }
+- entrySelector--;
+-
+- searchRange = ( 1 << entrySelector ) * 16;
+- rangeShift = ( woff2.num_tables * 16 ) - searchRange;
+
++ WRITE_ULONG ( sfnt_header, woff2.flavor );
+ WRITE_USHORT( sfnt_header, woff2.num_tables );
+ WRITE_USHORT( sfnt_header, searchRange );
+ WRITE_USHORT( sfnt_header, entrySelector );
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h
+index 4901286ee..f41140648 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h
+@@ -4,7 +4,7 @@
+ *
+ * WOFFF2 format management (specification).
+ *
+- * Copyright (C) 2019-2023 by
++ * Copyright (C) 2019-2024 by
+ * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c
+index 9ba25dcbc..28f4d1173 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType character mapping table (cmap) support (body).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h
+index ff52917ed..e2c5e72bf 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType character mapping table (cmap) support (specification).
+ *
+- * Copyright (C) 2002-2023 by
++ * Copyright (C) 2002-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h
+index 0af48c247..370898363 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h
+@@ -4,7 +4,7 @@
+ *
+ * TT CMAP classes definitions (specification only).
+ *
+- * Copyright (C) 2009-2023 by
++ * Copyright (C) 2009-2024 by
+ * Oran Agra and Mickey Gabel.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c
+index 281e7135e..b37658dde 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType and OpenType colored glyph layer support (body).
+ *
+- * Copyright (C) 2018-2023 by
++ * Copyright (C) 2018-2024 by
+ * David Turner, Robert Wilhelm, Dominik Röttsches, and Werner Lemberg.
+ *
+ * Originally written by Shao Yu Zhang .
+@@ -208,18 +208,19 @@
+ colr->num_base_glyphs = FT_NEXT_USHORT( p );
+ base_glyph_offset = FT_NEXT_ULONG( p );
+
+- if ( base_glyph_offset >= table_size )
++ if ( table_size <= base_glyph_offset )
+ goto InvalidTable;
+- if ( colr->num_base_glyphs * BASE_GLYPH_SIZE >
+- table_size - base_glyph_offset )
++ if ( ( table_size - base_glyph_offset ) / BASE_GLYPH_SIZE
++ < colr->num_base_glyphs )
+ goto InvalidTable;
+
+ layer_offset = FT_NEXT_ULONG( p );
+ colr->num_layers = FT_NEXT_USHORT( p );
+
+- if ( layer_offset >= table_size )
++ if ( table_size <= layer_offset )
+ goto InvalidTable;
+- if ( colr->num_layers * LAYER_SIZE > table_size - layer_offset )
++ if ( ( table_size - layer_offset ) / LAYER_SIZE
++ < colr->num_layers )
+ goto InvalidTable;
+
+ if ( colr->version == 1 )
+@@ -229,14 +230,14 @@
+
+ base_glyphs_offset_v1 = FT_NEXT_ULONG( p );
+
+- if ( base_glyphs_offset_v1 >= table_size - 4 )
++ if ( table_size - 4 <= base_glyphs_offset_v1 )
+ goto InvalidTable;
+
+ p1 = (FT_Byte*)( table + base_glyphs_offset_v1 );
+ num_base_glyphs_v1 = FT_PEEK_ULONG( p1 );
+
+- if ( num_base_glyphs_v1 * BASE_GLYPH_PAINT_RECORD_SIZE >
+- table_size - base_glyphs_offset_v1 )
++ if ( ( table_size - base_glyphs_offset_v1 ) / BASE_GLYPH_PAINT_RECORD_SIZE
++ < num_base_glyphs_v1 )
+ goto InvalidTable;
+
+ colr->num_base_glyphs_v1 = num_base_glyphs_v1;
+@@ -244,19 +245,19 @@
+
+ layer_offset_v1 = FT_NEXT_ULONG( p );
+
+- if ( layer_offset_v1 >= table_size )
++ if ( table_size <= layer_offset_v1 )
+ goto InvalidTable;
+
+ if ( layer_offset_v1 )
+ {
+- if ( layer_offset_v1 >= table_size - 4 )
++ if ( table_size - 4 <= layer_offset_v1 )
+ goto InvalidTable;
+
+ p1 = (FT_Byte*)( table + layer_offset_v1 );
+ num_layers_v1 = FT_PEEK_ULONG( p1 );
+
+- if ( num_layers_v1 * LAYER_V1_LIST_PAINT_OFFSET_SIZE >
+- table_size - layer_offset_v1 )
++ if ( ( table_size - layer_offset_v1 ) / LAYER_V1_LIST_PAINT_OFFSET_SIZE
++ < num_layers_v1 )
+ goto InvalidTable;
+
+ colr->num_layers_v1 = num_layers_v1;
+@@ -279,7 +280,7 @@
+
+ clip_list_offset = FT_NEXT_ULONG( p );
+
+- if ( clip_list_offset >= table_size )
++ if ( table_size <= clip_list_offset )
+ goto InvalidTable;
+
+ if ( clip_list_offset )
+@@ -311,7 +312,7 @@
+ goto InvalidTable;
+
+ var_store_offset = FT_NEXT_ULONG( p );
+- if ( var_store_offset >= table_size )
++ if ( table_size <= var_store_offset )
+ goto InvalidTable;
+
+ if ( var_store_offset )
+@@ -661,6 +662,7 @@
+ FT_UInt32 first_layer_index;
+
+
++ ENSURE_READ_BYTES( 5 );
+ num_layers = FT_NEXT_BYTE( p );
+ if ( num_layers > colr->num_layers_v1 )
+ return 0;
+@@ -1278,7 +1280,8 @@
+
+ while ( min < max )
+ {
+- FT_UInt mid = min + ( max - min ) / 2;
++ FT_UInt mid = min + ( max - min ) / 2;
++ FT_UShort gid;
+
+ /*
+ * `base_glyph_begin` is the beginning of `BaseGlyphV1List`;
+@@ -1287,8 +1290,7 @@
+ */
+ FT_Byte *p = base_glyph_begin + 4 + mid * BASE_GLYPH_PAINT_RECORD_SIZE;
+
+- FT_UShort gid = FT_NEXT_USHORT( p );
+-
++ gid = FT_NEXT_USHORT( p );
+
+ if ( gid < glyph_id )
+ min = mid + 1;
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h
+index 20c85f035..30031464c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType and OpenType colored glyph layer support (specification).
+ *
+- * Copyright (C) 2018-2023 by
++ * Copyright (C) 2018-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * Originally written by Shao Yu Zhang .
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c
+index 46ae08596..997eb869f 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType and OpenType color palette support (body).
+ *
+- * Copyright (C) 2018-2023 by
++ * Copyright (C) 2018-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * Originally written by Shao Yu Zhang .
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h
+index 8e9913f0c..bb301ae88 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType and OpenType color palette support (specification).
+ *
+- * Copyright (C) 2018-2023 by
++ * Copyright (C) 2018-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * Originally written by Shao Yu Zhang .
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c
+index a47d08bd6..f0411366a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c
+@@ -5,7 +5,7 @@
+ * Load the basic TrueType kerning table. This doesn't handle
+ * kerning data within the GPOS table at the moment.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h
+index 960c7da49..a54e51df1 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h
+@@ -5,7 +5,7 @@
+ * Load the basic TrueType kerning table. This doesn't handle
+ * kerning data within the GPOS table at the moment.
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c
+index 7b44e9cd2..c3a5fae2c 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c
+@@ -5,7 +5,7 @@
+ * Load the basic TrueType tables, i.e., tables that can be either in
+ * TTF or OTF fonts (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -1046,7 +1046,7 @@
+ FT_LOCAL_DEF( void )
+ tt_face_free_name( TT_Face face )
+ {
+- FT_Memory memory = face->root.driver->root.memory;
++ FT_Memory memory = face->root.memory;
+ TT_NameTable table = &face->name_table;
+
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h
+index 1499dd573..2b1d62d9b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h
+@@ -5,7 +5,7 @@
+ * Load the basic TrueType tables, i.e., tables that can be either in
+ * TTF or OTF fonts (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c
+index 38ee9ae72..278841185 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c
+@@ -4,7 +4,7 @@
+ *
+ * Load the metrics tables common to TTF and OTF fonts (body).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h
+index 56d2b6276..34b3c0e18 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h
+@@ -4,7 +4,7 @@
+ *
+ * Load the metrics tables common to TTF and OTF fonts (specification).
+ *
+- * Copyright (C) 2006-2023 by
++ * Copyright (C) 2006-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c
+index 1dfad4298..5698a62c8 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c
+@@ -5,7 +5,7 @@
+ * PostScript name table processing for TrueType and OpenType fonts
+ * (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -204,8 +204,8 @@
+ /* now load the name strings */
+ if ( num_names )
+ {
+- FT_ULong p;
+- FT_Byte* strings;
++ FT_Byte* p;
++ FT_Byte* p_end;
+
+
+ post_len -= (FT_ULong)num_glyphs * 2;
+@@ -214,36 +214,36 @@
+ post_len + 1 ) )
+ goto Fail;
+
+- strings = (FT_Byte*)( name_strings + num_names );
+- if ( FT_STREAM_READ( strings, post_len ) )
++ p = (FT_Byte*)( name_strings + num_names );
++ if ( FT_STREAM_READ( p, post_len ) )
+ goto Fail;
+
++ p_end = p + post_len;
++
+ /* convert from Pascal- to C-strings and set pointers */
+- for ( p = 0, n = 0; p < post_len && n < num_names; n++ )
++ for ( n = 0; p < p_end && n < num_names; n++ )
+ {
+- FT_UInt len = strings[p];
++ FT_UInt len = *p;
+
+
+- if ( len > 63U )
+- {
+- error = FT_THROW( Invalid_File_Format );
+- goto Fail;
+- }
++ /* names in the Adobe Glyph List are shorter than 40 characters */
++ if ( len >= 40U )
++ FT_TRACE4(( "load_format_20: unusual %u-char name found\n", len ));
+
+- strings[p] = 0;
+- name_strings[n] = strings + p + 1;
+- p += len + 1;
++ *p++ = 0;
++ name_strings[n] = p;
++ p += len;
+ }
+- strings[post_len] = 0;
++ *p_end = 0;
+
+ /* deal with missing or insufficient string data */
+ if ( n < num_names )
+ {
+ FT_TRACE4(( "load_format_20: %hu PostScript names are truncated\n",
+- num_names - n ));
++ (FT_UShort)( num_names - n ) ));
+
+ for ( ; n < num_names; n++ )
+- name_strings[n] = strings + post_len;
++ name_strings[n] = p_end;
+ }
+ }
+
+@@ -436,13 +436,8 @@
+
+ format = face->postscript.FormatType;
+
+- if ( format == 0x00010000L )
+- {
+- if ( idx < 258 ) /* paranoid checking */
+- *PSname = MAC_NAME( idx );
+- }
+- else if ( format == 0x00020000L ||
+- format == 0x00025000L )
++ if ( format == 0x00020000L ||
++ format == 0x00025000L )
+ {
+ TT_Post_Names names = &face->postscript_names;
+
+@@ -466,6 +461,11 @@
+ }
+ }
+
++ /* version 1.0 is only valid with 258 glyphs */
++ else if ( format == 0x00010000L &&
++ face->max_profile.numGlyphs == 258 )
++ *PSname = MAC_NAME( idx );
++
+ /* nothing to do for format == 0x00030000L */
+
+ End:
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h
+index 528f1c5f2..150db6c39 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h
+@@ -5,7 +5,7 @@
+ * PostScript name table processing for TrueType and OpenType fonts
+ * (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c
+index 03f90a628..cb3a8abf1 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType and OpenType embedded bitmap support (body).
+ *
+- * Copyright (C) 2005-2023 by
++ * Copyright (C) 2005-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * Copyright 2013 by Google, Inc.
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h
+index 07e2db461..96f80a584 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType and OpenType embedded bitmap support (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c
+index eeedd9906..532ccfa17 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c
+@@ -4,7 +4,7 @@
+ *
+ * WOFF2 Font table tags (base).
+ *
+- * Copyright (C) 2019-2023 by
++ * Copyright (C) 2019-2024 by
+ * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h
+index 1201848e5..d03b4b41b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h
++++ b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h
+@@ -4,7 +4,7 @@
+ *
+ * WOFF2 Font table tags (specification).
+ *
+- * Copyright (C) 2019-2023 by
++ * Copyright (C) 2019-2024 by
+ * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c
+index 0918272f8..b7c0632a6 100644
+--- a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c
++++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c
+@@ -4,7 +4,7 @@
+ *
+ * A new `perfect' anti-aliasing renderer (body).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -489,7 +489,7 @@ typedef ptrdiff_t FT_PtrDist;
+
+ typedef struct gray_TWorker_
+ {
+- ft_jmp_buf jump_buffer;
++ FT_BBox cbox;
+
+ TCoord min_ex, max_ex; /* min and max integer pixel coordinates */
+ TCoord min_ey, max_ey;
+@@ -510,6 +510,8 @@ typedef ptrdiff_t FT_PtrDist;
+ FT_Raster_Span_Func render_span;
+ void* render_span_data;
+
++ ft_jmp_buf jump_buffer;
++
+ } gray_TWorker, *gray_PWorker;
+
+ #if defined( _MSC_VER )
+@@ -997,49 +999,12 @@ typedef ptrdiff_t FT_PtrDist;
+ #endif
+
+ /*
+- * Benchmarking shows that using DDA to flatten the quadratic Bézier arcs
+- * is slightly faster in the following cases:
+- *
+- * - When the host CPU is 64-bit.
+- * - When SSE2 SIMD registers and instructions are available (even on
+- * x86).
+- *
+- * For other cases, using binary splits is actually slightly faster.
+- */
+-#if ( defined( __SSE2__ ) || \
+- defined( __x86_64__ ) || \
+- defined( _M_AMD64 ) || \
+- ( defined( _M_IX86_FP ) && _M_IX86_FP >= 2 ) ) && \
+- !defined( __VMS )
+-# define FT_SSE2 1
+-#else
+-# define FT_SSE2 0
+-#endif
+-
+-#if FT_SSE2 || \
+- defined( __aarch64__ ) || \
+- defined( _M_ARM64 )
+-# define BEZIER_USE_DDA 1
+-#else
+-# define BEZIER_USE_DDA 0
+-#endif
+-
+- /*
+- * For now, the code that depends on `BEZIER_USE_DDA` requires `FT_Int64`
+- * to be defined. If `FT_INT64` is not defined, meaning there is no
+- * 64-bit type available, disable it to avoid compilation errors. See for
+- * example https://gitlab.freedesktop.org/freetype/freetype/-/issues/1071.
++ * For now, the code that uses DDA to render conic curves requires
++ * `FT_Int64` to be defined. See for example
++ * https://gitlab.freedesktop.org/freetype/freetype/-/issues/1071.
+ */
+-#if !defined( FT_INT64 )
+-# undef BEZIER_USE_DDA
+-# define BEZIER_USE_DDA 0
+-#endif
+-
+-#if BEZIER_USE_DDA
+
+-#if FT_SSE2
+-# include
+-#endif
++#ifdef FT_INT64
+
+ #define LEFT_SHIFT( a, b ) (FT_Int64)( (FT_UInt64)(a) << (b) )
+
+@@ -1095,16 +1060,17 @@ typedef ptrdiff_t FT_PtrDist;
+ return;
+ }
+
+- /* We can calculate the number of necessary bisections because */
++ /* We can calculate the number of necessary segments because */
+ /* each bisection predictably reduces deviation exactly 4-fold. */
+ /* Even 32-bit deviation would vanish after 16 bisections. */
+- shift = 0;
++ shift = 16;
+ do
+ {
+- dx >>= 2;
+- shift += 1;
++ dx >>= 2;
++ shift--;
+
+ } while ( dx > ONE_PIXEL / 4 );
++ count = 0x10000U >> shift;
+
+ /*
+ * The (P0,P1,P2) arc equation, for t in [0,1] range:
+@@ -1150,75 +1116,19 @@ typedef ptrdiff_t FT_PtrDist;
+ * = (B << (33 - N)) + (A << (32 - 2*N))
+ */
+
+-#if FT_SSE2
+- /* Experience shows that for small shift values, */
+- /* SSE2 is actually slower. */
+- if ( shift > 2 )
+- {
+- union
+- {
+- struct { FT_Int64 ax, ay, bx, by; } i;
+- struct { __m128i a, b; } vec;
+-
+- } u;
+-
+- union
+- {
+- struct { FT_Int32 px_lo, px_hi, py_lo, py_hi; } i;
+- __m128i vec;
+-
+- } v;
+-
+- __m128i a, b;
+- __m128i r, q, q2;
+- __m128i p;
+-
+-
+- u.i.ax = ax;
+- u.i.ay = ay;
+- u.i.bx = bx;
+- u.i.by = by;
+-
+- a = _mm_load_si128( &u.vec.a );
+- b = _mm_load_si128( &u.vec.b );
+-
+- r = _mm_slli_epi64( a, 33 - 2 * shift );
+- q = _mm_slli_epi64( b, 33 - shift );
+- q2 = _mm_slli_epi64( a, 32 - 2 * shift );
+-
+- q = _mm_add_epi64( q2, q );
+-
+- v.i.px_lo = 0;
+- v.i.px_hi = p0.x;
+- v.i.py_lo = 0;
+- v.i.py_hi = p0.y;
+-
+- p = _mm_load_si128( &v.vec );
+-
+- for ( count = 1U << shift; count > 0; count-- )
+- {
+- p = _mm_add_epi64( p, q );
+- q = _mm_add_epi64( q, r );
+-
+- _mm_store_si128( &v.vec, p );
+-
+- gray_render_line( RAS_VAR_ v.i.px_hi, v.i.py_hi );
+- }
+-
+- return;
+- }
+-#endif /* FT_SSE2 */
++ rx = LEFT_SHIFT( ax, shift + shift );
++ ry = LEFT_SHIFT( ay, shift + shift );
+
+- rx = LEFT_SHIFT( ax, 33 - 2 * shift );
+- ry = LEFT_SHIFT( ay, 33 - 2 * shift );
++ qx = LEFT_SHIFT( bx, shift + 17 ) + rx;
++ qy = LEFT_SHIFT( by, shift + 17 ) + ry;
+
+- qx = LEFT_SHIFT( bx, 33 - shift ) + LEFT_SHIFT( ax, 32 - 2 * shift );
+- qy = LEFT_SHIFT( by, 33 - shift ) + LEFT_SHIFT( ay, 32 - 2 * shift );
++ rx *= 2;
++ ry *= 2;
+
+ px = LEFT_SHIFT( p0.x, 32 );
+ py = LEFT_SHIFT( p0.y, 32 );
+
+- for ( count = 1U << shift; count > 0; count-- )
++ do
+ {
+ px += qx;
+ py += qy;
+@@ -1227,10 +1137,10 @@ typedef ptrdiff_t FT_PtrDist;
+
+ gray_render_line( RAS_VAR_ (FT_Pos)( px >> 32 ),
+ (FT_Pos)( py >> 32 ) );
+- }
++ } while ( --count );
+ }
+
+-#else /* !BEZIER_USE_DDA */
++#else /* !FT_INT64 */
+
+ /*
+ * Note that multiple attempts to speed up the function below
+@@ -1324,7 +1234,7 @@ typedef ptrdiff_t FT_PtrDist;
+ } while ( --draw );
+ }
+
+-#endif /* !BEZIER_USE_DDA */
++#endif /* !FT_INT64 */
+
+
+ /*
+@@ -1486,139 +1396,6 @@ typedef ptrdiff_t FT_PtrDist;
+ }
+
+
+- static void
+- gray_sweep( RAS_ARG )
+- {
+- int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
+- : INT_MIN;
+- int coverage;
+- int y;
+-
+-
+- for ( y = ras.min_ey; y < ras.max_ey; y++ )
+- {
+- PCell cell = ras.ycells[y - ras.min_ey];
+- TCoord x = ras.min_ex;
+- TArea cover = 0;
+-
+- unsigned char* line = ras.target.origin - ras.target.pitch * y;
+-
+-
+- for ( ; cell != ras.cell_null; cell = cell->next )
+- {
+- TArea area;
+-
+-
+- if ( cover != 0 && cell->x > x )
+- {
+- FT_FILL_RULE( coverage, cover, fill );
+- FT_GRAY_SET( line + x, coverage, cell->x - x );
+- }
+-
+- cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
+- area = cover - cell->area;
+-
+- if ( area != 0 && cell->x >= ras.min_ex )
+- {
+- FT_FILL_RULE( coverage, area, fill );
+- line[cell->x] = (unsigned char)coverage;
+- }
+-
+- x = cell->x + 1;
+- }
+-
+- if ( cover != 0 ) /* only if cropped */
+- {
+- FT_FILL_RULE( coverage, cover, fill );
+- FT_GRAY_SET( line + x, coverage, ras.max_ex - x );
+- }
+- }
+- }
+-
+-
+- static void
+- gray_sweep_direct( RAS_ARG )
+- {
+- int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
+- : INT_MIN;
+- int coverage;
+- int y;
+-
+- FT_Span span[FT_MAX_GRAY_SPANS];
+- int n = 0;
+-
+-
+- for ( y = ras.min_ey; y < ras.max_ey; y++ )
+- {
+- PCell cell = ras.ycells[y - ras.min_ey];
+- TCoord x = ras.min_ex;
+- TArea cover = 0;
+-
+-
+- for ( ; cell != ras.cell_null; cell = cell->next )
+- {
+- TArea area;
+-
+-
+- if ( cover != 0 && cell->x > x )
+- {
+- FT_FILL_RULE( coverage, cover, fill );
+-
+- span[n].coverage = (unsigned char)coverage;
+- span[n].x = (short)x;
+- span[n].len = (unsigned short)( cell->x - x );
+-
+- if ( ++n == FT_MAX_GRAY_SPANS )
+- {
+- /* flush the span buffer and reset the count */
+- ras.render_span( y, n, span, ras.render_span_data );
+- n = 0;
+- }
+- }
+-
+- cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
+- area = cover - cell->area;
+-
+- if ( area != 0 && cell->x >= ras.min_ex )
+- {
+- FT_FILL_RULE( coverage, area, fill );
+-
+- span[n].coverage = (unsigned char)coverage;
+- span[n].x = (short)cell->x;
+- span[n].len = 1;
+-
+- if ( ++n == FT_MAX_GRAY_SPANS )
+- {
+- /* flush the span buffer and reset the count */
+- ras.render_span( y, n, span, ras.render_span_data );
+- n = 0;
+- }
+- }
+-
+- x = cell->x + 1;
+- }
+-
+- if ( cover != 0 ) /* only if cropped */
+- {
+- FT_FILL_RULE( coverage, cover, fill );
+-
+- span[n].coverage = (unsigned char)coverage;
+- span[n].x = (short)x;
+- span[n].len = (unsigned short)( ras.max_ex - x );
+-
+- ++n;
+- }
+-
+- if ( n )
+- {
+- /* flush the span buffer and reset the count */
+- ras.render_span( y, n, span, ras.render_span_data );
+- n = 0;
+- }
+- }
+- }
+-
+-
+ #ifdef STANDALONE_
+
+ /**************************************************************************
+@@ -1934,7 +1711,7 @@ typedef ptrdiff_t FT_PtrDist;
+ if ( continued )
+ FT_Trace_Enable();
+
+- FT_TRACE7(( "band [%d..%d]: %td cell%s remaining/\n",
++ FT_TRACE7(( "band [%d..%d]: %td cell%s remaining\n",
+ ras.min_ey,
+ ras.max_ey,
+ ras.cell_null - ras.cell_free,
+@@ -1952,14 +1729,144 @@ typedef ptrdiff_t FT_PtrDist;
+ }
+
+
++ static void
++ gray_sweep( RAS_ARG )
++ {
++ int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
++ : INT_MIN;
++ int coverage;
++ int y;
++
++
++ for ( y = ras.min_ey; y < ras.max_ey; y++ )
++ {
++ PCell cell = ras.ycells[y - ras.min_ey];
++ TCoord x = ras.min_ex;
++ TArea cover = 0;
++
++ unsigned char* line = ras.target.origin - ras.target.pitch * y;
++
++
++ for ( ; cell != ras.cell_null; cell = cell->next )
++ {
++ TArea area;
++
++
++ if ( cover != 0 && cell->x > x )
++ {
++ FT_FILL_RULE( coverage, cover, fill );
++ FT_GRAY_SET( line + x, coverage, cell->x - x );
++ }
++
++ cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
++ area = cover - cell->area;
++
++ if ( area != 0 && cell->x >= ras.min_ex )
++ {
++ FT_FILL_RULE( coverage, area, fill );
++ line[cell->x] = (unsigned char)coverage;
++ }
++
++ x = cell->x + 1;
++ }
++
++ if ( cover != 0 ) /* only if cropped */
++ {
++ FT_FILL_RULE( coverage, cover, fill );
++ FT_GRAY_SET( line + x, coverage, ras.max_ex - x );
++ }
++ }
++ }
++
++
++ static void
++ gray_sweep_direct( RAS_ARG )
++ {
++ int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
++ : INT_MIN;
++ int coverage;
++ int y;
++
++ FT_Span span[FT_MAX_GRAY_SPANS];
++ int n = 0;
++
++
++ for ( y = ras.min_ey; y < ras.max_ey; y++ )
++ {
++ PCell cell = ras.ycells[y - ras.min_ey];
++ TCoord x = ras.min_ex;
++ TArea cover = 0;
++
++
++ for ( ; cell != ras.cell_null; cell = cell->next )
++ {
++ TArea area;
++
++
++ if ( cover != 0 && cell->x > x )
++ {
++ FT_FILL_RULE( coverage, cover, fill );
++
++ span[n].coverage = (unsigned char)coverage;
++ span[n].x = (short)x;
++ span[n].len = (unsigned short)( cell->x - x );
++
++ if ( ++n == FT_MAX_GRAY_SPANS )
++ {
++ /* flush the span buffer and reset the count */
++ ras.render_span( y, n, span, ras.render_span_data );
++ n = 0;
++ }
++ }
++
++ cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
++ area = cover - cell->area;
++
++ if ( area != 0 && cell->x >= ras.min_ex )
++ {
++ FT_FILL_RULE( coverage, area, fill );
++
++ span[n].coverage = (unsigned char)coverage;
++ span[n].x = (short)cell->x;
++ span[n].len = 1;
++
++ if ( ++n == FT_MAX_GRAY_SPANS )
++ {
++ /* flush the span buffer and reset the count */
++ ras.render_span( y, n, span, ras.render_span_data );
++ n = 0;
++ }
++ }
++
++ x = cell->x + 1;
++ }
++
++ if ( cover != 0 ) /* only if cropped */
++ {
++ FT_FILL_RULE( coverage, cover, fill );
++
++ span[n].coverage = (unsigned char)coverage;
++ span[n].x = (short)x;
++ span[n].len = (unsigned short)( ras.max_ex - x );
++
++ ++n;
++ }
++
++ if ( n )
++ {
++ /* flush the span buffer and reset the count */
++ ras.render_span( y, n, span, ras.render_span_data );
++ n = 0;
++ }
++ }
++ }
++
++
+ static int
+ gray_convert_glyph( RAS_ARG )
+ {
+- const TCoord yMin = ras.min_ey;
+- const TCoord yMax = ras.max_ey;
+-
+ TCell buffer[FT_MAX_GRAY_POOL];
+- size_t height = (size_t)( yMax - yMin );
++ size_t height = (size_t)( ras.cbox.yMax - ras.cbox.yMin );
+ size_t n = FT_MAX_GRAY_POOL / 8;
+ TCoord y;
+ TCoord bands[32]; /* enough to accommodate bisections */
+@@ -1985,35 +1892,36 @@ typedef ptrdiff_t FT_PtrDist;
+ height = ( height + n - 1 ) / n;
+ }
+
+- for ( y = yMin; y < yMax; )
++ for ( y = ras.cbox.yMin; y < ras.cbox.yMax; )
+ {
+ ras.min_ey = y;
+ y += height;
+- ras.max_ey = FT_MIN( y, yMax );
++ ras.max_ey = FT_MIN( y, ras.cbox.yMax );
++
++ ras.count_ey = ras.max_ey - ras.min_ey;
+
+ band = bands;
+- band[1] = ras.min_ey;
+- band[0] = ras.max_ey;
++ band[1] = ras.cbox.xMin;
++ band[0] = ras.cbox.xMax;
+
+ do
+ {
+- TCoord width = band[0] - band[1];
+- TCoord w;
++ TCoord i;
+ int error;
+
+
+- for ( w = 0; w < width; ++w )
+- ras.ycells[w] = ras.cell_null;
++ ras.min_ex = band[1];
++ ras.max_ex = band[0];
++
++ /* memory management: zero out and skip ycells */
++ for ( i = 0; i < ras.count_ey; ++i )
++ ras.ycells[i] = ras.cell_null;
+
+- /* memory management: skip ycells */
+- n = ( (size_t)width * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) /
+- sizeof ( TCell );
++ n = ( (size_t)ras.count_ey * sizeof ( PCell ) + sizeof ( TCell ) - 1 )
++ / sizeof ( TCell );
+
+ ras.cell_free = buffer + n;
+ ras.cell = ras.cell_null;
+- ras.min_ey = band[1];
+- ras.max_ey = band[0];
+- ras.count_ey = width;
+
+ error = gray_convert_glyph_inner( RAS_VAR_ continued );
+ continued = 1;
+@@ -2031,10 +1939,10 @@ typedef ptrdiff_t FT_PtrDist;
+ return error;
+
+ /* render pool overflow; we will reduce the render band by half */
+- width >>= 1;
++ i = ( band[0] - band[1] ) >> 1;
+
+ /* this should never happen even with tiny rendering pool */
+- if ( width == 0 )
++ if ( i == 0 )
+ {
+ FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
+ return FT_THROW( Raster_Overflow );
+@@ -2042,7 +1950,7 @@ typedef ptrdiff_t FT_PtrDist;
+
+ band++;
+ band[1] = band[0];
+- band[0] += width;
++ band[0] += i;
+ } while ( band >= bands );
+ }
+
+@@ -2073,7 +1981,7 @@ typedef ptrdiff_t FT_PtrDist;
+ return FT_THROW( Invalid_Outline );
+
+ /* return immediately if the outline is empty */
+- if ( outline->n_points == 0 || outline->n_contours <= 0 )
++ if ( outline->n_points == 0 || outline->n_contours == 0 )
+ return Smooth_Err_Ok;
+
+ if ( !outline->contours || !outline->points )
+@@ -2093,10 +2001,7 @@ typedef ptrdiff_t FT_PtrDist;
+ ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
+ ras.render_span_data = params->user;
+
+- ras.min_ex = params->clip_box.xMin;
+- ras.min_ey = params->clip_box.yMin;
+- ras.max_ex = params->clip_box.xMax;
+- ras.max_ey = params->clip_box.yMax;
++ ras.cbox = params->clip_box;
+ }
+ else
+ {
+@@ -2122,14 +2027,14 @@ typedef ptrdiff_t FT_PtrDist;
+ ras.render_span = (FT_Raster_Span_Func)NULL;
+ ras.render_span_data = NULL;
+
+- ras.min_ex = 0;
+- ras.min_ey = 0;
+- ras.max_ex = (FT_Pos)target_map->width;
+- ras.max_ey = (FT_Pos)target_map->rows;
++ ras.cbox.xMin = 0;
++ ras.cbox.yMin = 0;
++ ras.cbox.xMax = (FT_Pos)target_map->width;
++ ras.cbox.yMax = (FT_Pos)target_map->rows;
+ }
+
+ /* exit if nothing to do */
+- if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
++ if ( ras.cbox.xMin >= ras.cbox.xMax || ras.cbox.yMin >= ras.cbox.yMax )
+ return Smooth_Err_Ok;
+
+ return gray_convert_glyph( RAS_VAR );
+diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h
+index a5001bf40..940fbe8c7 100644
+--- a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h
++++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h
+@@ -4,7 +4,7 @@
+ *
+ * FreeType smooth renderer declaration
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h
+index f4ac93dc4..6d41fb8e0 100644
+--- a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h
++++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h
+@@ -4,7 +4,7 @@
+ *
+ * smooth renderer error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c
+index 9b0e8886c..f0acc1ea4 100644
+--- a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c
++++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c
+@@ -4,7 +4,7 @@
+ *
+ * Anti-aliasing renderer interface (body).
+ *
+- * Copyright (C) 2000-2023 by
++ * Copyright (C) 2000-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h
+index f8bdc9938..d7b61a9e6 100644
+--- a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h
++++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h
+@@ -4,7 +4,7 @@
+ *
+ * Anti-aliasing renderer interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c
+index d1496fec7..4ab68eb9a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType font driver implementation (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -217,7 +217,20 @@
+ kerning->y = 0;
+
+ if ( sfnt )
+- kerning->x = sfnt->get_kerning( ttface, left_glyph, right_glyph );
++ {
++ /* Use 'kern' table if available since that can be faster; otherwise */
++ /* use GPOS kerning pairs if available. */
++ if ( ttface->kern_avail_bits != 0 )
++ kerning->x = sfnt->get_kerning( ttface,
++ left_glyph,
++ right_glyph );
++#ifdef TT_CONFIG_OPTION_GPOS_KERNING
++ else if ( ttface->gpos_kerning_available )
++ kerning->x = sfnt->get_gpos_kerning( ttface,
++ left_glyph,
++ right_glyph );
++#endif
++ }
+
+ return 0;
+ }
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h
+index 757a66f42..3e1cf234f 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level TrueType driver interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h b/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h
+index 008ee9985..7ad937bd0 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c
+index dc427e8a1..b656ccf04 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType Glyph Loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -353,7 +353,8 @@
+ FT_Byte c, count;
+ FT_Vector *vec, *vec_limit;
+ FT_Pos x, y;
+- FT_Short *cont, *cont_limit, last;
++ FT_UShort *cont, *cont_limit;
++ FT_Int last;
+
+
+ /* check that we can add the contours to the glyph */
+@@ -372,7 +373,7 @@
+ last = -1;
+ for ( ; cont < cont_limit; cont++ )
+ {
+- *cont = FT_NEXT_SHORT( p );
++ *cont = FT_NEXT_USHORT( p );
+
+ if ( *cont <= last )
+ goto Invalid_Outline;
+@@ -418,11 +419,9 @@
+ /* and thus allocate the bytecode array size by ourselves */
+ if ( n_ins )
+ {
+- if ( FT_QNEW_ARRAY( exec->glyphIns, n_ins ) )
++ if ( FT_DUP( exec->glyphIns, p, n_ins ) )
+ return error;
+
+- FT_MEM_COPY( exec->glyphIns, p, (FT_Long)n_ins );
+-
+ exec->glyphSize = n_ins;
+ }
+ }
+@@ -432,7 +431,7 @@
+ p += n_ins;
+
+ /* reading the point tags */
+- flag = (FT_Byte*)outline->tags;
++ flag = outline->tags;
+ flag_limit = flag + n_points;
+
+ FT_ASSERT( flag );
+@@ -465,7 +464,7 @@
+
+ vec = outline->points;
+ vec_limit = vec + n_points;
+- flag = (FT_Byte*)outline->tags;
++ flag = outline->tags;
+ x = 0;
+
+ for ( ; vec < vec_limit; vec++, flag++ )
+@@ -499,7 +498,7 @@
+
+ vec = outline->points;
+ vec_limit = vec + n_points;
+- flag = (FT_Byte*)outline->tags;
++ flag = outline->tags;
+ y = 0;
+
+ for ( ; vec < vec_limit; vec++, flag++ )
+@@ -532,8 +531,8 @@
+ *flag = (FT_Byte)( f & ON_CURVE_POINT );
+ }
+
+- outline->n_points = (FT_Short)n_points;
+- outline->n_contours = (FT_Short)n_contours;
++ outline->n_points = (FT_UShort)n_points;
++ outline->n_contours = (FT_UShort)n_contours;
+
+ load->cursor = p;
+
+@@ -754,15 +753,13 @@
+ FT_UInt start_point,
+ FT_UInt start_contour )
+ {
+- zone->n_points = (FT_UShort)load->outline.n_points + 4 -
+- (FT_UShort)start_point;
+- zone->n_contours = load->outline.n_contours -
+- (FT_Short)start_contour;
++ zone->n_points = load->outline.n_points + 4 - (FT_UShort)start_point;
++ zone->n_contours = load->outline.n_contours - (FT_UShort)start_contour;
+ zone->org = load->extra_points + start_point;
+ zone->cur = load->outline.points + start_point;
+ zone->orus = load->extra_points2 + start_point;
+- zone->tags = (FT_Byte*)load->outline.tags + start_point;
+- zone->contours = (FT_UShort*)load->outline.contours + start_contour;
++ zone->tags = load->outline.tags + start_point;
++ zone->contours = load->outline.contours + start_contour;
+ zone->first_point = (FT_UShort)start_point;
+ }
+
+@@ -1046,7 +1043,7 @@
+ current.points = gloader->base.outline.points +
+ num_base_points;
+ current.n_points = gloader->base.outline.n_points -
+- (short)num_base_points;
++ (FT_UShort)num_base_points;
+
+ have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE |
+ WE_HAVE_AN_XY_SCALE |
+@@ -1059,7 +1056,7 @@
+ /* get offset */
+ if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
+ {
+- FT_UInt num_points = (FT_UInt)gloader->base.outline.n_points;
++ FT_UInt num_points = gloader->base.outline.n_points;
+ FT_UInt k = (FT_UInt)subglyph->arg1;
+ FT_UInt l = (FT_UInt)subglyph->arg2;
+ FT_Vector* p1;
+@@ -1721,8 +1718,8 @@
+ FT_List_Add( &loader->composites, node );
+ }
+
+- start_point = (FT_UInt)gloader->base.outline.n_points;
+- start_contour = (FT_UInt)gloader->base.outline.n_contours;
++ start_point = gloader->base.outline.n_points;
++ start_contour = gloader->base.outline.n_contours;
+
+ /* for each subglyph, read composite header */
+ error = face->read_composite_glyph( loader );
+@@ -1741,14 +1738,14 @@
+ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
+ FT_IS_VARIATION( FT_FACE( face ) ) )
+ {
+- short i, limit;
++ FT_UShort i, limit;
+ FT_SubGlyph subglyph;
+
+ FT_Outline outline = { 0, 0, NULL, NULL, NULL, 0 };
+ FT_Vector* unrounded = NULL;
+
+
+- limit = (short)gloader->current.num_subglyphs;
++ limit = (FT_UShort)gloader->current.num_subglyphs;
+
+ /* construct an outline structure for */
+ /* communication with `TT_Vary_Apply_Glyph_Deltas' */
+@@ -1874,7 +1871,7 @@
+ linear_hadvance = loader->linear;
+ linear_vadvance = loader->vadvance;
+
+- num_base_points = (FT_UInt)gloader->base.outline.n_points;
++ num_base_points = gloader->base.outline.n_points;
+
+ error = load_truetype_glyph( loader,
+ (FT_UInt)subglyph->index,
+@@ -1898,7 +1895,7 @@
+ loader->vadvance = linear_vadvance;
+ }
+
+- num_points = (FT_UInt)gloader->base.outline.n_points;
++ num_points = gloader->base.outline.n_points;
+
+ if ( num_points == num_base_points )
+ continue;
+@@ -2313,7 +2310,7 @@
+ *
+ * 1) we have a `tricky' font that heavily relies on the interpreter to
+ * render glyphs correctly, for example DFKai-SB, or
+- * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested.
++ * 2) FT_RENDER_MODE_MONO (i.e, monochrome rendering) is requested.
+ *
+ * In those cases, backward compatibility needs to be turned off to get
+ * correct rendering. The rendering is then completely up to the
+@@ -2719,7 +2716,7 @@
+ size->metrics->y_ppem < 24 )
+ glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
+
+- FT_TRACE1(( " subglyphs = %u, contours = %hd, points = %hd,"
++ FT_TRACE1(( " subglyphs = %u, contours = %hu, points = %hu,"
+ " flags = 0x%.3x\n",
+ loader.gloader->base.num_subglyphs,
+ glyph->outline.n_contours,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h
+index f18637dce..22ea967f3 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType Glyph Loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c
+index 9d149ea36..4f0083c96 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType GX Font Variation loader
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -129,9 +129,6 @@
+ * stream ::
+ * The data stream.
+ *
+- * size ::
+- * The size of the table holding the data.
+- *
+ * @Output:
+ * point_cnt ::
+ * The number of points read. A zero value means that
+@@ -144,14 +141,14 @@
+ */
+ static FT_UShort*
+ ft_var_readpackedpoints( FT_Stream stream,
+- FT_ULong size,
+ FT_UInt *point_cnt )
+ {
+ FT_UShort *points = NULL;
+ FT_UInt n;
+- FT_UInt runcnt;
++ FT_UInt runcnt, cnt;
+ FT_UInt i, j;
+ FT_UShort first;
++ FT_Byte* p;
+ FT_Memory memory = stream->memory;
+ FT_Error error;
+
+@@ -169,56 +166,60 @@
+ n |= FT_GET_BYTE();
+ }
+
+- if ( n > size )
+- {
+- FT_TRACE1(( "ft_var_readpackedpoints: number of points too large\n" ));
++ if ( FT_QNEW_ARRAY( points, n ) )
+ return NULL;
+- }
+-
+- /* in the nested loops below we increase `i' twice; */
+- /* it is faster to simply allocate one more slot */
+- /* than to add another test within the loop */
+- if ( FT_QNEW_ARRAY( points, n + 1 ) )
+- return NULL;
+-
+- *point_cnt = n;
+
++ p = stream->cursor;
+ first = 0;
+ i = 0;
+ while ( i < n )
+ {
+- runcnt = FT_GET_BYTE();
++ if ( p >= stream->limit )
++ goto Fail;
++
++ runcnt = FT_NEXT_BYTE( p );
++ cnt = runcnt & GX_PT_POINT_RUN_COUNT_MASK;
++
++ /* first point not included in run count */
++ cnt++;
++ if ( cnt > n - i )
++ cnt = n - i;
++
+ if ( runcnt & GX_PT_POINTS_ARE_WORDS )
+ {
+- runcnt &= GX_PT_POINT_RUN_COUNT_MASK;
+- first += FT_GET_USHORT();
+- points[i++] = first;
++ if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
++ goto Fail;
+
+- /* first point not included in run count */
+- for ( j = 0; j < runcnt; j++ )
++ for ( j = 0; j < cnt; j++ )
+ {
+- first += FT_GET_USHORT();
++ first += FT_NEXT_USHORT( p );
+ points[i++] = first;
+- if ( i >= n )
+- break;
+ }
+ }
+ else
+ {
+- first += FT_GET_BYTE();
+- points[i++] = first;
++ if ( cnt > (FT_UInt)( stream->limit - p ) )
++ goto Fail;
+
+- for ( j = 0; j < runcnt; j++ )
++ for ( j = 0; j < cnt; j++ )
+ {
+- first += FT_GET_BYTE();
++ first += FT_NEXT_BYTE( p );
+ points[i++] = first;
+- if ( i >= n )
+- break;
+ }
+ }
+ }
+
++ stream->cursor = p;
++
++ *point_cnt = n;
++
+ return points;
++
++ Fail:
++ FT_TRACE1(( "ft_var_readpackedpoints: invalid table\n" ));
++
++ FT_FREE( points );
++ return NULL;
+ }
+
+
+@@ -240,9 +241,6 @@
+ * stream ::
+ * The data stream.
+ *
+- * size ::
+- * The size of the table holding the data.
+- *
+ * delta_cnt ::
+ * The number of deltas to be read.
+ *
+@@ -258,13 +256,12 @@
+ */
+ static FT_Fixed*
+ ft_var_readpackeddeltas( FT_Stream stream,
+- FT_ULong size,
+ FT_UInt delta_cnt )
+ {
+ FT_Fixed *deltas = NULL;
+ FT_UInt runcnt, cnt;
+ FT_UInt i, j;
+- FT_UInt bytes_used;
++ FT_Byte* p;
+ FT_Memory memory = stream->memory;
+ FT_Error error;
+
+@@ -272,68 +269,51 @@
+ if ( FT_QNEW_ARRAY( deltas, delta_cnt ) )
+ return NULL;
+
+- i = 0;
+- bytes_used = 0;
+-
+- while ( i < delta_cnt && bytes_used < size )
++ p = stream->cursor;
++ i = 0;
++ while ( i < delta_cnt )
+ {
+- runcnt = FT_GET_BYTE();
++ if ( p >= stream->limit )
++ goto Fail;
++
++ runcnt = FT_NEXT_BYTE( p );
+ cnt = runcnt & GX_DT_DELTA_RUN_COUNT_MASK;
+
+- bytes_used++;
++ /* first point not included in run count */
++ cnt++;
++ if ( cnt > delta_cnt - i )
++ cnt = delta_cnt - i;
+
+ if ( runcnt & GX_DT_DELTAS_ARE_ZERO )
+ {
+- /* `cnt` + 1 zeroes get added */
+- for ( j = 0; j <= cnt && i < delta_cnt; j++ )
++ for ( j = 0; j < cnt; j++ )
+ deltas[i++] = 0;
+ }
+ else if ( runcnt & GX_DT_DELTAS_ARE_WORDS )
+ {
+- /* `cnt` + 1 shorts from the stack */
+- bytes_used += 2 * ( cnt + 1 );
+- if ( bytes_used > size )
+- {
+- FT_TRACE1(( "ft_var_readpackeddeltas:"
+- " number of short deltas too large\n" ));
++ if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
+ goto Fail;
+- }
+
+- for ( j = 0; j <= cnt && i < delta_cnt; j++ )
+- deltas[i++] = FT_intToFixed( FT_GET_SHORT() );
++ for ( j = 0; j < cnt; j++ )
++ deltas[i++] = FT_intToFixed( FT_NEXT_SHORT( p ) );
+ }
+ else
+ {
+- /* `cnt` + 1 signed bytes from the stack */
+- bytes_used += cnt + 1;
+- if ( bytes_used > size )
+- {
+- FT_TRACE1(( "ft_var_readpackeddeltas:"
+- " number of byte deltas too large\n" ));
++ if ( cnt > (FT_UInt)( stream->limit - p ) )
+ goto Fail;
+- }
+
+- for ( j = 0; j <= cnt && i < delta_cnt; j++ )
+- deltas[i++] = FT_intToFixed( FT_GET_CHAR() );
+- }
+-
+- if ( j <= cnt )
+- {
+- FT_TRACE1(( "ft_var_readpackeddeltas:"
+- " number of deltas too large\n" ));
+- goto Fail;
++ for ( j = 0; j < cnt; j++ )
++ deltas[i++] = FT_intToFixed( FT_NEXT_CHAR( p ) );
+ }
+ }
+
+- if ( i < delta_cnt )
+- {
+- FT_TRACE1(( "ft_var_readpackeddeltas: not enough deltas\n" ));
+- goto Fail;
+- }
++ stream->cursor = p;
+
+ return deltas;
+
+ Fail:
++ FT_TRACE1(( "ft_var_readpackeddeltas: invalid table\n" ));
++
+ FT_FREE( deltas );
+ return NULL;
+ }
+@@ -596,7 +576,7 @@
+
+ for ( j = 0; j < itemStore->axisCount; j++ )
+ {
+- FT_Short start, peak, end;
++ FT_Int start, peak, end;
+
+
+ if ( FT_READ_SHORT( start ) ||
+@@ -604,6 +584,10 @@
+ FT_READ_SHORT( end ) )
+ goto Exit;
+
++ /* immediately tag invalid ranges with special peak = 0 */
++ if ( ( start < 0 && end > 0 ) || start > peak || peak > end )
++ peak = 0;
++
+ axisCoords[j].startCoord = FT_fdot14ToFixed( start );
+ axisCoords[j].peakCoord = FT_fdot14ToFixed( peak );
+ axisCoords[j].endCoord = FT_fdot14ToFixed( end );
+@@ -1024,6 +1008,9 @@
+ if ( innerIndex >= varData->itemCount )
+ return 0; /* Out of range. */
+
++ if ( varData->regionIdxCount == 0 )
++ return 0; /* Avoid "applying zero offset to null pointer". */
++
+ if ( varData->regionIdxCount < 16 )
+ {
+ deltaSet = deltaSetStack;
+@@ -1074,43 +1061,32 @@
+ /* inner loop steps through axes in this region */
+ for ( j = 0; j < itemStore->axisCount; j++, axis++ )
+ {
+- /* compute the scalar contribution of this axis; */
+- /* ignore invalid ranges */
+- if ( axis->startCoord > axis->peakCoord ||
+- axis->peakCoord > axis->endCoord )
+- continue;
++ FT_Fixed ncv = ttface->blend->normalizedcoords[j];
+
+- else if ( axis->startCoord < 0 &&
+- axis->endCoord > 0 &&
+- axis->peakCoord != 0 )
+- continue;
+
+- /* peak of 0 means ignore this axis */
+- else if ( axis->peakCoord == 0 )
+- continue;
+-
+- else if ( ttface->blend->normalizedcoords[j] == axis->peakCoord )
++ /* compute the scalar contribution of this axis */
++ /* with peak of 0 used for invalid axes */
++ if ( axis->peakCoord == ncv ||
++ axis->peakCoord == 0 )
+ continue;
+
+ /* ignore this region if coords are out of range */
+- else if ( ttface->blend->normalizedcoords[j] <= axis->startCoord ||
+- ttface->blend->normalizedcoords[j] >= axis->endCoord )
++ else if ( ncv <= axis->startCoord ||
++ ncv >= axis->endCoord )
+ {
+ scalar = 0;
+ break;
+ }
+
+ /* cumulative product of all the axis scalars */
+- else if ( ttface->blend->normalizedcoords[j] < axis->peakCoord )
+- scalar =
+- FT_MulDiv( scalar,
+- ttface->blend->normalizedcoords[j] - axis->startCoord,
+- axis->peakCoord - axis->startCoord );
+- else
+- scalar =
+- FT_MulDiv( scalar,
+- axis->endCoord - ttface->blend->normalizedcoords[j],
+- axis->endCoord - axis->peakCoord );
++ else if ( ncv < axis->peakCoord )
++ scalar = FT_MulDiv( scalar,
++ ncv - axis->startCoord,
++ axis->peakCoord - axis->startCoord );
++ else /* ncv > axis->peakCoord */
++ scalar = FT_MulDiv( scalar,
++ axis->endCoord - ncv,
++ axis->endCoord - axis->peakCoord );
+
+ } /* per-axis loop */
+
+@@ -1920,32 +1896,27 @@
+
+ for ( i = 0; i < blend->num_axis; i++ )
+ {
+- FT_TRACE6(( " axis %d coordinate %.5f:\n",
+- i, (double)blend->normalizedcoords[i] / 65536 ));
++ FT_Fixed ncv = blend->normalizedcoords[i];
++
++
++ FT_TRACE6(( " axis %d coordinate %.5f:\n", i, (double)ncv / 65536 ));
+
+ /* It's not clear why (for intermediate tuples) we don't need */
+ /* to check against start/end -- the documentation says we don't. */
+ /* Similarly, it's unclear why we don't need to scale along the */
+ /* axis. */
+
+- if ( tuple_coords[i] == 0 )
++ if ( tuple_coords[i] == ncv )
+ {
+- FT_TRACE6(( " tuple coordinate is zero, ignore\n" ));
++ FT_TRACE6(( " tuple coordinate %.5f fits perfectly\n",
++ (double)tuple_coords[i] / 65536 ));
++ /* `apply' does not change */
+ continue;
+ }
+
+- if ( blend->normalizedcoords[i] == 0 )
+- {
+- FT_TRACE6(( " axis coordinate is zero, stop\n" ));
+- apply = 0;
+- break;
+- }
+-
+- if ( blend->normalizedcoords[i] == tuple_coords[i] )
++ if ( tuple_coords[i] == 0 )
+ {
+- FT_TRACE6(( " tuple coordinate %.5f fits perfectly\n",
+- (double)tuple_coords[i] / 65536 ));
+- /* `apply' does not change */
++ FT_TRACE6(( " tuple coordinate is zero, ignore\n" ));
+ continue;
+ }
+
+@@ -1953,27 +1924,27 @@
+ {
+ /* not an intermediate tuple */
+
+- if ( blend->normalizedcoords[i] < FT_MIN( 0, tuple_coords[i] ) ||
+- blend->normalizedcoords[i] > FT_MAX( 0, tuple_coords[i] ) )
++ if ( ( tuple_coords[i] > ncv && ncv > 0 ) ||
++ ( tuple_coords[i] < ncv && ncv < 0 ) )
++ {
++ FT_TRACE6(( " tuple coordinate %.5f fits\n",
++ (double)tuple_coords[i] / 65536 ));
++ apply = FT_MulDiv( apply, ncv, tuple_coords[i] );
++ }
++ else
+ {
+ FT_TRACE6(( " tuple coordinate %.5f is exceeded, stop\n",
+ (double)tuple_coords[i] / 65536 ));
+ apply = 0;
+ break;
+ }
+-
+- FT_TRACE6(( " tuple coordinate %.5f fits\n",
+- (double)tuple_coords[i] / 65536 ));
+- apply = FT_MulDiv( apply,
+- blend->normalizedcoords[i],
+- tuple_coords[i] );
+ }
+ else
+ {
+ /* intermediate tuple */
+
+- if ( blend->normalizedcoords[i] <= im_start_coords[i] ||
+- blend->normalizedcoords[i] >= im_end_coords[i] )
++ if ( ncv <= im_start_coords[i] ||
++ ncv >= im_end_coords[i] )
+ {
+ FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ is exceeded,"
+ " stop\n",
+@@ -1986,13 +1957,13 @@
+ FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ fits\n",
+ (double)im_start_coords[i] / 65536,
+ (double)im_end_coords[i] / 65536 ));
+- if ( blend->normalizedcoords[i] < tuple_coords[i] )
++ if ( ncv < tuple_coords[i] )
+ apply = FT_MulDiv( apply,
+- blend->normalizedcoords[i] - im_start_coords[i],
++ ncv - im_start_coords[i],
+ tuple_coords[i] - im_start_coords[i] );
+- else
++ else /* ncv > tuple_coords[i] */
+ apply = FT_MulDiv( apply,
+- im_end_coords[i] - blend->normalizedcoords[i],
++ im_end_coords[i] - ncv,
+ im_end_coords[i] - tuple_coords[i] );
+ }
+ }
+@@ -2141,11 +2112,12 @@
+ outerIndex,
+ innerIndex );
+
+- v += delta << 2;
++ /* Convert delta in F2DOT14 to 16.16 before adding. */
++ v += MUL_INT( delta, 4 );
+
+- /* Clamp value range. */
+- v = v >= 0x10000L ? 0x10000 : v;
+- v = v <= -0x10000L ? -0x10000 : v;
++ /* Clamp value to range [-1, 1]. */
++ v = v >= 0x10000L ? 0x10000 : v;
++ v = v <= -0x10000L ? -0x10000 : v;
+
+ new_normalized[i] = v;
+ }
+@@ -2721,9 +2693,8 @@
+ FT_UInt n;
+
+
+- if ( FT_ALLOC( mmvar, ttface->blend->mmvar_len ) )
++ if ( FT_DUP( mmvar, ttface->blend->mmvar, ttface->blend->mmvar_len ) )
+ goto Exit;
+- FT_MEM_COPY( mmvar, ttface->blend->mmvar, ttface->blend->mmvar_len );
+
+ axis_flags =
+ (FT_UShort*)( (char*)mmvar + mmvar_size );
+@@ -3533,9 +3504,10 @@
+ FT_ULong here;
+ FT_UInt i, j;
+
+- FT_Fixed* tuple_coords = NULL;
+- FT_Fixed* im_start_coords = NULL;
+- FT_Fixed* im_end_coords = NULL;
++ FT_Fixed* peak_coords = NULL;
++ FT_Fixed* tuple_coords;
++ FT_Fixed* im_start_coords;
++ FT_Fixed* im_end_coords;
+
+ GX_Blend blend = face->blend;
+
+@@ -3556,16 +3528,16 @@
+ {
+ FT_TRACE2(( "\n" ));
+ FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" ));
+- error = FT_Err_Ok;
+- goto Exit;
++
++ return FT_Err_Ok;
+ }
+
+ if ( !face->cvt )
+ {
+ FT_TRACE2(( "\n" ));
+ FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" ));
+- error = FT_Err_Ok;
+- goto Exit;
++
++ return FT_Err_Ok;
+ }
+
+ error = face->goto_table( face, TTAG_cvar, stream, &table_len );
+@@ -3573,15 +3545,11 @@
+ {
+ FT_TRACE2(( "is missing\n" ));
+
+- error = FT_Err_Ok;
+- goto Exit;
++ return FT_Err_Ok;
+ }
+
+ if ( FT_FRAME_ENTER( table_len ) )
+- {
+- error = FT_Err_Ok;
+- goto Exit;
+- }
++ return FT_Err_Ok;
+
+ table_start = FT_Stream_FTell( stream );
+ if ( FT_GET_LONG() != 0x00010000L )
+@@ -3594,11 +3562,6 @@
+
+ FT_TRACE2(( "loaded\n" ));
+
+- if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) ||
+- FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
+- FT_NEW_ARRAY( im_end_coords, blend->num_axis ) )
+- goto FExit;
+-
+ tupleCount = FT_GET_USHORT();
+ offsetToData = FT_GET_USHORT();
+
+@@ -3621,9 +3584,8 @@
+
+ FT_Stream_SeekSet( stream, offsetToData );
+
+- sharedpoints = ft_var_readpackedpoints( stream,
+- table_len,
+- &spoint_count );
++ sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
++
+ offsetToData = FT_Stream_FTell( stream );
+
+ FT_Stream_SeekSet( stream, here );
+@@ -3634,8 +3596,12 @@
+ tupleCount & GX_TC_TUPLE_COUNT_MASK,
+ ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
+
+- if ( FT_NEW_ARRAY( cvt_deltas, face->cvt_size ) )
+- goto FExit;
++ if ( FT_QNEW_ARRAY( peak_coords, 3 * blend->num_axis ) ||
++ FT_NEW_ARRAY( cvt_deltas, face->cvt_size ) )
++ goto Exit;
++
++ im_start_coords = peak_coords + blend->num_axis;
++ im_end_coords = im_start_coords + blend->num_axis;
+
+ for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
+ {
+@@ -3652,32 +3618,19 @@
+ if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
+ {
+ for ( j = 0; j < blend->num_axis; j++ )
+- tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
++ peak_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
++ tuple_coords = peak_coords;
+ }
+- else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
++ else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) < blend->tuplecount )
++ tuple_coords = blend->tuplecoords +
++ ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis;
++ else
+ {
+ FT_TRACE2(( "tt_face_vary_cvt:"
+ " invalid tuple index\n" ));
+
+ error = FT_THROW( Invalid_Table );
+- goto FExit;
+- }
+- else
+- {
+- if ( !blend->tuplecoords )
+- {
+- FT_TRACE2(( "tt_face_vary_cvt:"
+- " no valid tuple coordinates available\n" ));
+-
+- error = FT_THROW( Invalid_Table );
+- goto FExit;
+- }
+-
+- FT_MEM_COPY(
+- tuple_coords,
+- blend->tuplecoords +
+- ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis,
+- blend->num_axis * sizeof ( FT_Fixed ) );
++ goto Exit;
+ }
+
+ if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
+@@ -3706,9 +3659,7 @@
+
+ if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
+ {
+- localpoints = ft_var_readpackedpoints( stream,
+- table_len,
+- &point_count );
++ localpoints = ft_var_readpackedpoints( stream, &point_count );
+ points = localpoints;
+ }
+ else
+@@ -3719,7 +3670,6 @@
+ }
+
+ deltas = ft_var_readpackeddeltas( stream,
+- table_len,
+ point_count == 0 ? face->cvt_size
+ : point_count );
+
+@@ -3820,22 +3770,20 @@
+ for ( i = 0; i < face->cvt_size; i++ )
+ face->cvt[i] += FT_fixedToFdot6( cvt_deltas[i] );
+
+- FExit:
+- FT_FRAME_EXIT();
++ /* Iterate over all `FT_Size` objects and set `cvt_ready` to -1 */
++ /* to trigger rescaling of all CVT values. */
++ FT_List_Iterate( &root->sizes_list,
++ tt_cvt_ready_iterator,
++ NULL );
+
+ Exit:
+ if ( sharedpoints != ALL_POINTS )
+ FT_FREE( sharedpoints );
+- FT_FREE( tuple_coords );
+- FT_FREE( im_start_coords );
+- FT_FREE( im_end_coords );
+ FT_FREE( cvt_deltas );
++ FT_FREE( peak_coords );
+
+- /* iterate over all FT_Size objects and set `cvt_ready' to -1 */
+- /* to trigger rescaling of all CVT values */
+- FT_List_Iterate( &root->sizes_list,
+- tt_cvt_ready_iterator,
+- NULL );
++ FExit:
++ FT_FRAME_EXIT();
+
+ return error;
+
+@@ -4099,9 +4047,10 @@
+ FT_ULong here;
+ FT_UInt i, j;
+
+- FT_Fixed* tuple_coords = NULL;
+- FT_Fixed* im_start_coords = NULL;
+- FT_Fixed* im_end_coords = NULL;
++ FT_Fixed* peak_coords = NULL;
++ FT_Fixed* tuple_coords;
++ FT_Fixed* im_start_coords;
++ FT_Fixed* im_end_coords;
+
+ GX_Blend blend = face->blend;
+
+@@ -4136,27 +4085,17 @@
+ return FT_Err_Ok;
+ }
+
+- if ( FT_NEW_ARRAY( points_org, n_points ) ||
+- FT_NEW_ARRAY( points_out, n_points ) ||
+- FT_NEW_ARRAY( has_delta, n_points ) )
+- goto Fail1;
+-
+ dataSize = blend->glyphoffsets[glyph_index + 1] -
+ blend->glyphoffsets[glyph_index];
+
+ if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
+ FT_FRAME_ENTER( dataSize ) )
+- goto Fail1;
++ return error;
+
+ glyph_start = FT_Stream_FTell( stream );
+
+ /* each set of glyph variation data is formatted similarly to `cvar' */
+
+- if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) ||
+- FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
+- FT_NEW_ARRAY( im_end_coords, blend->num_axis ) )
+- goto Fail2;
+-
+ tupleCount = FT_GET_USHORT();
+ offsetToData = FT_GET_USHORT();
+
+@@ -4168,7 +4107,7 @@
+ " invalid glyph variation array header\n" ));
+
+ error = FT_THROW( Invalid_Table );
+- goto Fail2;
++ goto FExit;
+ }
+
+ offsetToData += glyph_start;
+@@ -4179,9 +4118,8 @@
+
+ FT_Stream_SeekSet( stream, offsetToData );
+
+- sharedpoints = ft_var_readpackedpoints( stream,
+- blend->gvar_size,
+- &spoint_count );
++ sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
++
+ offsetToData = FT_Stream_FTell( stream );
+
+ FT_Stream_SeekSet( stream, here );
+@@ -4192,9 +4130,16 @@
+ tupleCount & GX_TC_TUPLE_COUNT_MASK,
+ ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
+
+- if ( FT_NEW_ARRAY( point_deltas_x, n_points ) ||
+- FT_NEW_ARRAY( point_deltas_y, n_points ) )
+- goto Fail3;
++ if ( FT_QNEW_ARRAY( peak_coords, 3 * blend->num_axis ) ||
++ FT_NEW_ARRAY( point_deltas_x, 2 * n_points ) ||
++ FT_QNEW_ARRAY( points_org, n_points ) ||
++ FT_QNEW_ARRAY( points_out, n_points ) ||
++ FT_QNEW_ARRAY( has_delta, n_points ) )
++ goto Exit;
++
++ im_start_coords = peak_coords + blend->num_axis;
++ im_end_coords = im_start_coords + blend->num_axis;
++ point_deltas_y = point_deltas_x + n_points;
+
+ for ( j = 0; j < n_points; j++ )
+ {
+@@ -4217,22 +4162,20 @@
+ if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
+ {
+ for ( j = 0; j < blend->num_axis; j++ )
+- tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
++ peak_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
++ tuple_coords = peak_coords;
+ }
+- else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
++ else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) < blend->tuplecount )
++ tuple_coords = blend->tuplecoords +
++ ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis;
++ else
+ {
+ FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
+ " invalid tuple index\n" ));
+
+ error = FT_THROW( Invalid_Table );
+- goto Fail3;
++ goto Exit;
+ }
+- else
+- FT_MEM_COPY(
+- tuple_coords,
+- blend->tuplecoords +
+- ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis,
+- blend->num_axis * sizeof ( FT_Fixed ) );
+
+ if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
+ {
+@@ -4260,9 +4203,7 @@
+
+ if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
+ {
+- localpoints = ft_var_readpackedpoints( stream,
+- blend->gvar_size,
+- &point_count );
++ localpoints = ft_var_readpackedpoints( stream, &point_count );
+ points = localpoints;
+ }
+ else
+@@ -4272,11 +4213,9 @@
+ }
+
+ deltas_x = ft_var_readpackeddeltas( stream,
+- blend->gvar_size,
+ point_count == 0 ? n_points
+ : point_count );
+ deltas_y = ft_var_readpackeddeltas( stream,
+- blend->gvar_size,
+ point_count == 0 ? n_points
+ : point_count );
+
+@@ -4460,23 +4399,17 @@
+ unrounded[n_points - 2].y ) / 64;
+ }
+
+- Fail3:
+- FT_FREE( point_deltas_x );
+- FT_FREE( point_deltas_y );
+-
+- Fail2:
++ Exit:
+ if ( sharedpoints != ALL_POINTS )
+ FT_FREE( sharedpoints );
+- FT_FREE( tuple_coords );
+- FT_FREE( im_start_coords );
+- FT_FREE( im_end_coords );
+-
+- FT_FRAME_EXIT();
+-
+- Fail1:
+ FT_FREE( points_org );
+ FT_FREE( points_out );
+ FT_FREE( has_delta );
++ FT_FREE( peak_coords );
++ FT_FREE( point_deltas_x );
++
++ FExit:
++ FT_FRAME_EXIT();
+
+ return error;
+ }
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h
+index e3da6d170..9326011e3 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType GX Font Variation loader (specification)
+ *
+- * Copyright (C) 2004-2023 by
++ * Copyright (C) 2004-2024 by
+ * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c
+index 79df4555d..951891dbf 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType bytecode interpreter (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -5270,11 +5270,11 @@
+ FT_UShort refp;
+ FT_F26Dot6 dx, dy;
+
+- FT_Short contour, bounds;
++ FT_UShort contour, bounds;
+ FT_UShort start, limit, i;
+
+
+- contour = (FT_Short)args[0];
++ contour = (FT_UShort)args[0];
+ bounds = ( exc->GS.gep2 == 0 ) ? 1 : exc->zp2.n_contours;
+
+ if ( BOUNDS( contour, bounds ) )
+@@ -5290,15 +5290,13 @@
+ if ( contour == 0 )
+ start = 0;
+ else
+- start = (FT_UShort)( exc->zp2.contours[contour - 1] + 1 -
+- exc->zp2.first_point );
++ start = exc->zp2.contours[contour - 1] + 1 - exc->zp2.first_point;
+
+ /* we use the number of points if in the twilight zone */
+ if ( exc->GS.gep2 == 0 )
+ limit = exc->zp2.n_points;
+ else
+- limit = (FT_UShort)( exc->zp2.contours[contour] -
+- exc->zp2.first_point + 1 );
++ limit = exc->zp2.contours[contour] + 1 - exc->zp2.first_point;
+
+ for ( i = start; i < limit; i++ )
+ {
+@@ -5341,9 +5339,9 @@
+ /* Normal zone's `n_points' includes phantoms, so must */
+ /* use end of last contour. */
+ if ( exc->GS.gep2 == 0 )
+- limit = (FT_UShort)exc->zp2.n_points;
++ limit = exc->zp2.n_points;
+ else if ( exc->GS.gep2 == 1 && exc->zp2.n_contours > 0 )
+- limit = (FT_UShort)( exc->zp2.contours[exc->zp2.n_contours - 1] + 1 );
++ limit = exc->zp2.contours[exc->zp2.n_contours - 1] + 1;
+ else
+ limit = 0;
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h
+index e98e258fe..4f1a9bbc6 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType bytecode interpreter (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c
+index 5b56af711..d0ac31812 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c
+@@ -4,7 +4,7 @@
+ *
+ * Objects manager (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -115,7 +115,7 @@
+ FT_LOCAL_DEF( FT_Error )
+ tt_glyphzone_new( FT_Memory memory,
+ FT_UShort maxPoints,
+- FT_Short maxContours,
++ FT_UShort maxContours,
+ TT_GlyphZone zone )
+ {
+ FT_Error error;
+@@ -152,18 +152,20 @@
+ static const FT_String*
+ tt_skip_pdffont_random_tag( const FT_String* name )
+ {
+- unsigned int i;
+-
+-
+- if ( ft_strlen( name ) < 8 || name[6] != '+' )
+- return name;
+-
+- for ( i = 0; i < 6; i++ )
+- if ( !ft_isupper( name[i] ) )
+- return name;
++ if ( ft_isupper( name[0] ) &&
++ ft_isupper( name[1] ) &&
++ ft_isupper( name[2] ) &&
++ ft_isupper( name[3] ) &&
++ ft_isupper( name[4] ) &&
++ ft_isupper( name[5] ) &&
++ '+' == name[6] &&
++ name[7] )
++ {
++ FT_TRACE7(( "name without randomization tag: %s\n", name + 7 ));
++ return name + 7;
++ }
+
+- FT_TRACE7(( "name without randomization tag: %s\n", name + 7 ));
+- return name + 7;
++ return name;
+ }
+
+
+@@ -254,17 +256,20 @@
+ {
+ FT_Error error;
+ FT_UInt32 checksum = 0;
+- FT_UInt i;
++ FT_Byte* p;
++ FT_Int shift;
+
+
+ if ( FT_FRAME_ENTER( length ) )
+ return 0;
+
++ p = (FT_Byte*)stream->cursor;
++
+ for ( ; length > 3; length -= 4 )
+- checksum += (FT_UInt32)FT_GET_ULONG();
++ checksum += FT_NEXT_ULONG( p );
+
+- for ( i = 3; length > 0; length--, i-- )
+- checksum += (FT_UInt32)FT_GET_BYTE() << ( i * 8 );
++ for ( shift = 24; length > 0; length--, shift -=8 )
++ checksum += (FT_UInt32)FT_NEXT_BYTE( p ) << shift;
+
+ FT_FRAME_EXIT();
+
+@@ -782,8 +787,7 @@
+ FT_UInt instance_index = (FT_UInt)face_index >> 16;
+
+
+- if ( FT_HAS_MULTIPLE_MASTERS( ttface ) &&
+- instance_index > 0 )
++ if ( FT_HAS_MULTIPLE_MASTERS( ttface ) )
+ {
+ error = FT_Set_Named_Instance( ttface, instance_index );
+ if ( error )
+@@ -990,16 +994,16 @@
+ FT_Error error;
+ FT_UInt i;
+
+- /* unscaled CVT values are already stored in 26.6 format */
+- FT_Fixed scale = size->ttmetrics.scale >> 6;
+-
+
+ /* Scale the cvt values to the new ppem. */
+ /* By default, we use the y ppem value for scaling. */
+ FT_TRACE6(( "CVT values:\n" ));
+ for ( i = 0; i < size->cvt_size; i++ )
+ {
+- size->cvt[i] = FT_MulFix( face->cvt[i], scale );
++ /* Unscaled CVT values are already stored in 26.6 format. */
++ /* Note that this scaling operation is very sensitive to rounding; */
++ /* the integer division by 64 must be applied to the first argument. */
++ size->cvt[i] = FT_MulFix( face->cvt[i] / 64, size->ttmetrics.scale );
+ FT_TRACE6(( " %3d: %f (%f)\n",
+ i, (double)face->cvt[i] / 64, (double)size->cvt[i] / 64 ));
+ }
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h
+index 40eb37b4c..9c36ca783 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h
+@@ -4,7 +4,7 @@
+ *
+ * Objects manager (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -105,7 +105,7 @@ FT_BEGIN_HEADER
+ FT_LOCAL( FT_Error )
+ tt_glyphzone_new( FT_Memory memory,
+ FT_UShort maxPoints,
+- FT_Short maxContours,
++ FT_UShort maxContours,
+ TT_GlyphZone zone );
+
+ #endif /* TT_USE_BYTECODE_INTERPRETER */
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c
+index 54a64c7b4..9505b5f17 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c
+@@ -4,7 +4,7 @@
+ *
+ * TrueType-specific tables loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h
+index ed229fa46..bc32b5802 100644
+--- a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h
++++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h
+@@ -4,7 +4,7 @@
+ *
+ * TrueType-specific tables loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c
+index d9b9398b0..a63cd4dc4 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c
+@@ -4,7 +4,7 @@
+ *
+ * AFM support for Type 1 fonts (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h
+index e0d5aa5a8..7f5cdda19 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h
+@@ -4,7 +4,7 @@
+ *
+ * AFM support for Type 1 fonts (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c
+index a4cdf372a..8ed01914a 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 driver interface (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -312,10 +312,7 @@
+ {
+ retval = ft_strlen( type1->glyph_names[idx] ) + 1;
+ if ( value && value_len >= retval )
+- {
+ ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval );
+- ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+- }
+ }
+ break;
+
+@@ -344,11 +341,8 @@
+ {
+ retval = ft_strlen( type1->encoding.char_name[idx] ) + 1;
+ if ( value && value_len >= retval )
+- {
+ ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ),
+- retval - 1 );
+- ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+- }
++ retval );
+ }
+ break;
+
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h
+index ee7fcf43e..5ff52b55b 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h
+@@ -4,7 +4,7 @@
+ *
+ * High-level Type 1 driver interface (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h b/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h
+index 2fbd1e513..8aeb24ae1 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 error codes (specification only).
+ *
+- * Copyright (C) 2001-2023 by
++ * Copyright (C) 2001-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c
+index a32a4649d..c29e68251 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 Glyph Loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h
+index c06484758..17a6a5941 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 Glyph Loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1load.c b/src/java.desktop/share/native/libfreetype/src/type1/t1load.c
+index be7cd0fd5..ee7fb42a5 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1load.c
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1load.c
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 font loader (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+@@ -751,6 +751,7 @@
+ PS_DesignMap dmap = blend->design_map + n;
+
+
++ FT_FREE( dmap->blend_points );
+ FT_FREE( dmap->design_points );
+ dmap->num_points = 0;
+ }
+@@ -1043,9 +1044,9 @@
+ }
+
+ /* allocate design map data */
+- if ( FT_QNEW_ARRAY( map->design_points, num_points * 2 ) )
++ if ( FT_QNEW_ARRAY( map->design_points, num_points ) ||
++ FT_QNEW_ARRAY( map->blend_points, num_points ) )
+ goto Exit;
+- map->blend_points = map->design_points + num_points;
+ map->num_points = (FT_Byte)num_points;
+
+ for ( p = 0; p < num_points; p++ )
+@@ -1876,9 +1877,8 @@
+ }
+
+ /* t1_decrypt() shouldn't write to base -- make temporary copy */
+- if ( FT_QALLOC( temp, size ) )
++ if ( FT_DUP( temp, base, size ) )
+ goto Fail;
+- FT_MEM_COPY( temp, base, size );
+ psaux->t1_decrypt( temp, size, 4330 );
+ size -= (FT_ULong)t1face->type1.private_dict.lenIV;
+ error = T1_Add_Table( table,
+@@ -2090,9 +2090,8 @@
+ }
+
+ /* t1_decrypt() shouldn't write to base -- make temporary copy */
+- if ( FT_QALLOC( temp, size ) )
++ if ( FT_DUP( temp, base, size ) )
+ goto Fail;
+- FT_MEM_COPY( temp, base, size );
+ psaux->t1_decrypt( temp, size, 4330 );
+ size -= (FT_ULong)t1face->type1.private_dict.lenIV;
+ error = T1_Add_Table( code_table,
+@@ -2284,7 +2283,7 @@
+ T1_FIELD_DICT_PRIVATE )
+ #endif
+
+- { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 }
++ T1_FIELD_ZERO
+ };
+
+
+@@ -2392,18 +2391,13 @@
+ T1_Field keyword = (T1_Field)t1_keywords;
+
+
+- for (;;)
++ while ( keyword->len )
+ {
+- FT_Byte* name;
++ FT_Byte* name = (FT_Byte*)keyword->ident;
+
+
+- name = (FT_Byte*)keyword->ident;
+- if ( !name )
+- break;
+-
+- if ( cur[0] == name[0] &&
+- len == ft_strlen( (const char *)name ) &&
+- ft_memcmp( cur, name, len ) == 0 )
++ if ( keyword->len == len &&
++ ft_memcmp( cur, name, len ) == 0 )
+ {
+ /* We found it -- run the parsing callback! */
+ /* We record every instance of every field */
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1load.h b/src/java.desktop/share/native/libfreetype/src/type1/t1load.h
+index d8c9d2d8a..a45efa7cb 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1load.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1load.h
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 font loader (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c
+index 69e4fd506..b1b27c31f 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 objects manager (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h
+index 03847b27e..3809370c1 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 objects manager (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c
+index 6dec6c16c..3717ea7c5 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 parser (body).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h
+index 0d9a2865d..a0a2134d4 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 parser (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h b/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h
+index 40f360926..5a3d2f1ef 100644
+--- a/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h
++++ b/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h
+@@ -4,7 +4,7 @@
+ *
+ * Type 1 tokenizer (specification).
+ *
+- * Copyright (C) 1996-2023 by
++ * Copyright (C) 1996-2024 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Color/CBDT/CBDT.hh b/src/java.desktop/share/native/libharfbuzz/OT/Color/CBDT/CBDT.hh
+index d7b2b13e4..43a611a00 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Color/CBDT/CBDT.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Color/CBDT/CBDT.hh
+@@ -204,6 +204,7 @@ struct IndexSubtable
+ {
+ TRACE_SANITIZE (this);
+ if (!u.header.sanitize (c)) return_trace (false);
++ hb_barrier ();
+ switch (u.header.indexFormat)
+ {
+ case 1: return_trace (u.format1.sanitize (c, glyph_count));
+@@ -378,6 +379,7 @@ struct IndexSubtableRecord
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
++ hb_barrier () &&
+ firstGlyphIndex <= lastGlyphIndex &&
+ offsetToSubtable.sanitize (c, base, lastGlyphIndex - firstGlyphIndex + 1));
+ }
+@@ -635,6 +637,7 @@ struct BitmapSizeTable
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
++ hb_barrier () &&
+ indexSubtableArrayOffset.sanitize (c, base, numberOfIndexSubtables) &&
+ horizontal.sanitize (c) &&
+ vertical.sanitize (c));
+@@ -738,7 +741,9 @@ struct CBLC
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
++ hb_barrier () &&
+ likely (version.major == 2 || version.major == 3) &&
++ hb_barrier () &&
+ sizeTables.sanitize (c, this));
+ }
+
+@@ -936,10 +941,12 @@ struct CBDT
+ }
+ }
+
+- bool has_data () const { return cbdt.get_length (); }
++ bool has_data () const { return cbdt->version.major; }
+
+ bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const
+ {
++ if (!has_data ()) return false;
++
+ hb_glyph_extents_t extents;
+ hb_glyph_extents_t pixel_extents;
+ hb_blob_t *blob = reference_png (font, glyph);
+@@ -975,6 +982,7 @@ struct CBDT
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
++ hb_barrier () &&
+ likely (version.major == 2 || version.major == 3));
+ }
+
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/COLR.hh b/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/COLR.hh
+index fb2c42a88..4d6272d05 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/COLR.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/COLR.hh
+@@ -29,11 +29,14 @@
+ #define OT_COLOR_COLR_COLR_HH
+
+ #include "../../../hb.hh"
++#include "../../../hb-decycler.hh"
+ #include "../../../hb-open-type.hh"
+ #include "../../../hb-ot-var-common.hh"
+ #include "../../../hb-paint.hh"
+ #include "../../../hb-paint-extents.hh"
+
++#include "../CPAL/CPAL.hh"
++
+ /*
+ * COLR -- Color
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/colr
+@@ -66,13 +69,13 @@ public:
+ hb_paint_funcs_t *funcs;
+ void *data;
+ hb_font_t *font;
+- unsigned int palette_index;
++ hb_array_t palette;
+ hb_color_t foreground;
+- VarStoreInstancer &instancer;
+- hb_map_t current_glyphs;
+- hb_map_t current_layers;
++ ItemVarStoreInstancer &instancer;
++ hb_decycler_t glyphs_decycler;
++ hb_decycler_t layers_decycler;
+ int depth_left = HB_MAX_NESTING_LEVEL;
+- int edge_count = HB_COLRV1_MAX_EDGE_COUNT;
++ int edge_count = HB_MAX_GRAPH_EDGE_COUNT;
+
+ hb_paint_context_t (const void *base_,
+ hb_paint_funcs_t *funcs_,
+@@ -80,12 +83,16 @@ public:
+ hb_font_t *font_,
+ unsigned int palette_,
+ hb_color_t foreground_,
+- VarStoreInstancer &instancer_) :
++ ItemVarStoreInstancer &instancer_) :
+ base (base_),
+ funcs (funcs_),
+ data (data_),
+ font (font_),
+- palette_index (palette_),
++ palette (
++#ifndef HB_NO_COLOR
++ font->face->table.CPAL->get_palette_colors (palette_)
++#endif
++ ),
+ foreground (foreground_),
+ instancer (instancer_)
+ { }
+@@ -99,12 +106,7 @@ public:
+ if (color_index != 0xffff)
+ {
+ if (!funcs->custom_palette_color (data, color_index, &color))
+- {
+- unsigned int clen = 1;
+- hb_face_t *face = hb_font_get_face (font);
+-
+- hb_ot_color_palette_get_colors (face, palette_index, color_index, &clen, &color);
+- }
++ color = palette[color_index];
+
+ *is_foreground = false;
+ }
+@@ -159,23 +161,35 @@ struct hb_colrv1_closure_context_t :
+ void add_palette_index (unsigned palette_index)
+ { palette_indices->add (palette_index); }
+
++ void add_var_idxes (unsigned first_var_idx, unsigned num_idxes)
++ {
++ if (!num_idxes || first_var_idx == VarIdx::NO_VARIATION) return;
++ variation_indices->add_range (first_var_idx, first_var_idx + num_idxes - 1);
++ }
++
+ public:
+ const void *base;
+ hb_set_t visited_paint;
+ hb_set_t *glyphs;
+ hb_set_t *layer_indices;
+ hb_set_t *palette_indices;
++ hb_set_t *variation_indices;
++ unsigned num_var_idxes;
+ unsigned nesting_level_left;
+
+ hb_colrv1_closure_context_t (const void *base_,
+ hb_set_t *glyphs_,
+ hb_set_t *layer_indices_,
+ hb_set_t *palette_indices_,
++ hb_set_t *variation_indices_,
++ unsigned num_var_idxes_ = 1,
+ unsigned nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
+ base (base_),
+ glyphs (glyphs_),
+ layer_indices (layer_indices_),
+ palette_indices (palette_indices_),
++ variation_indices (variation_indices_),
++ num_var_idxes (num_var_idxes_),
+ nesting_level_left (nesting_level_left_)
+ {}
+ };
+@@ -242,18 +256,33 @@ struct Variable
+ }
+
+ void closurev1 (hb_colrv1_closure_context_t* c) const
+- { value.closurev1 (c); }
++ {
++ c->num_var_idxes = 0;
++ // update c->num_var_idxes during value closure
++ value.closurev1 (c);
++ c->add_var_idxes (varIdxBase, c->num_var_idxes);
++ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ if (!value.subset (c, instancer, varIdxBase)) return_trace (false);
+ if (c->plan->all_axes_pinned)
+ return_trace (true);
+
+- //TODO: update varIdxBase for partial-instancing
+- return_trace (c->serializer->embed (varIdxBase));
++ VarIdx new_varidx;
++ new_varidx = varIdxBase;
++ if (varIdxBase != VarIdx::NO_VARIATION)
++ {
++ hb_pair_t *new_varidx_delta;
++ if (!c->plan->colrv1_variation_idx_delta_map.has (varIdxBase, &new_varidx_delta))
++ return_trace (false);
++
++ new_varidx = hb_first (*new_varidx_delta);
++ }
++
++ return_trace (c->serializer->embed (new_varidx));
+ }
+
+ bool sanitize (hb_sanitize_context_t *c) const
+@@ -270,7 +299,7 @@ struct Variable
+
+ void get_color_stop (hb_paint_context_t *c,
+ hb_color_stop_t *stop,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ value.get_color_stop (c, stop, varIdxBase, instancer);
+ }
+@@ -305,7 +334,7 @@ struct NoVariable
+ { value.closurev1 (c); }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ return_trace (value.subset (c, instancer, varIdxBase));
+@@ -325,7 +354,7 @@ struct NoVariable
+
+ void get_color_stop (hb_paint_context_t *c,
+ hb_color_stop_t *stop,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ value.get_color_stop (c, stop, VarIdx::NO_VARIATION, instancer);
+ }
+@@ -345,10 +374,13 @@ struct NoVariable
+ struct ColorStop
+ {
+ void closurev1 (hb_colrv1_closure_context_t* c) const
+- { c->add_palette_index (paletteIndex); }
++ {
++ c->add_palette_index (paletteIndex);
++ c->num_var_idxes = 2;
++ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -374,7 +406,7 @@ struct ColorStop
+ void get_color_stop (hb_paint_context_t *c,
+ hb_color_stop_t *out,
+ uint32_t varIdx,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ out->offset = stopOffset.to_float(instancer (varIdx, 0));
+ out->color = c->get_color (paletteIndex,
+@@ -410,7 +442,7 @@ struct ColorLine
+ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->start_embed (this);
+@@ -439,7 +471,7 @@ struct ColorLine
+ unsigned int start,
+ unsigned int *count,
+ hb_color_stop_t *color_stops,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ unsigned int len = stops.len;
+
+@@ -542,8 +574,11 @@ struct Affine2x3
+ return_trace (c->check_struct (this));
+ }
+
++ void closurev1 (hb_colrv1_closure_context_t* c) const
++ { c->num_var_idxes = 6; }
++
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -588,7 +623,7 @@ struct PaintColrLayers
+ void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer HB_UNUSED) const
++ const ItemVarStoreInstancer &instancer HB_UNUSED) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->embed (this);
+@@ -617,10 +652,13 @@ struct PaintColrLayers
+ struct PaintSolid
+ {
+ void closurev1 (hb_colrv1_closure_context_t* c) const
+- { c->add_palette_index (paletteIndex); }
++ {
++ c->add_palette_index (paletteIndex);
++ c->num_var_idxes = 1;
++ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -666,10 +704,13 @@ template class Var>
+ struct PaintLinearGradient
+ {
+ void closurev1 (hb_colrv1_closure_context_t* c) const
+- { (this+colorLine).closurev1 (c); }
++ {
++ (this+colorLine).closurev1 (c);
++ c->num_var_idxes = 6;
++ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -733,10 +774,13 @@ template class Var>
+ struct PaintRadialGradient
+ {
+ void closurev1 (hb_colrv1_closure_context_t* c) const
+- { (this+colorLine).closurev1 (c); }
++ {
++ (this+colorLine).closurev1 (c);
++ c->num_var_idxes = 6;
++ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -800,10 +844,13 @@ template class Var>
+ struct PaintSweepGradient
+ {
+ void closurev1 (hb_colrv1_closure_context_t* c) const
+- { (this+colorLine).closurev1 (c); }
++ {
++ (this+colorLine).closurev1 (c);
++ c->num_var_idxes = 4;
++ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -863,7 +910,7 @@ struct PaintGlyph
+ void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->embed (this);
+@@ -906,7 +953,7 @@ struct PaintColrGlyph
+ void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer HB_UNUSED) const
++ const ItemVarStoreInstancer &instancer HB_UNUSED) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->embed (this);
+@@ -936,7 +983,7 @@ struct PaintTransform
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->embed (this);
+@@ -958,7 +1005,7 @@ struct PaintTransform
+ void paint_glyph (hb_paint_context_t *c) const
+ {
+ TRACE_PAINT (this);
+- (this+transform).paint_glyph (c);
++ (this+transform).paint_glyph (c); // This does a push_transform()
+ c->recurse (this+src);
+ c->funcs->pop_transform (c->data);
+ }
+@@ -975,7 +1022,7 @@ struct PaintTranslate
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1024,7 +1071,7 @@ struct PaintScale
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1073,7 +1120,7 @@ struct PaintScaleAroundCenter
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1132,7 +1179,7 @@ struct PaintScaleUniform
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1176,7 +1223,7 @@ struct PaintScaleUniformAroundCenter
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1232,7 +1279,7 @@ struct PaintRotate
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1276,7 +1323,7 @@ struct PaintRotateAroundCenter
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1332,7 +1379,7 @@ struct PaintSkew
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1381,7 +1428,7 @@ struct PaintSkewAroundCenter
+ HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1440,7 +1487,7 @@ struct PaintComposite
+ void closurev1 (hb_colrv1_closure_context_t* c) const;
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->embed (this);
+@@ -1491,7 +1538,7 @@ struct ClipBoxFormat1
+ return_trace (c->check_struct (this));
+ }
+
+- void get_clip_box (ClipBoxData &clip_box, const VarStoreInstancer &instancer HB_UNUSED) const
++ void get_clip_box (ClipBoxData &clip_box, const ItemVarStoreInstancer &instancer HB_UNUSED) const
+ {
+ clip_box.xMin = xMin;
+ clip_box.yMin = yMin;
+@@ -1500,7 +1547,7 @@ struct ClipBoxFormat1
+ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ uint32_t varIdxBase) const
+ {
+ TRACE_SUBSET (this);
+@@ -1533,7 +1580,7 @@ struct ClipBoxFormat1
+
+ struct ClipBoxFormat2 : Variable
+ {
+- void get_clip_box (ClipBoxData &clip_box, const VarStoreInstancer &instancer) const
++ void get_clip_box (ClipBoxData &clip_box, const ItemVarStoreInstancer &instancer) const
+ {
+ value.get_clip_box(clip_box, instancer);
+ if (instancer)
+@@ -1544,12 +1591,15 @@ struct ClipBoxFormat2 : Variable
+ clip_box.yMax += roundf (instancer (varIdxBase, 3));
+ }
+ }
++
++ void closurev1 (hb_colrv1_closure_context_t* c) const
++ { c->variation_indices->add_range (varIdxBase, varIdxBase + 3); }
+ };
+
+ struct ClipBox
+ {
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ switch (u.format) {
+@@ -1559,6 +1609,14 @@ struct ClipBox
+ }
+ }
+
++ void closurev1 (hb_colrv1_closure_context_t* c) const
++ {
++ switch (u.format) {
++ case 2: u.format2.closurev1 (c);
++ default:return;
++ }
++ }
++
+ template
+ typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
+ {
+@@ -1572,7 +1630,7 @@ struct ClipBox
+ }
+
+ bool get_extents (hb_glyph_extents_t *extents,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ ClipBoxData clip_box;
+ switch (u.format) {
+@@ -1606,9 +1664,15 @@ struct ClipRecord
+ int cmp (hb_codepoint_t g) const
+ { return g < startGlyphID ? -1 : g <= endGlyphID ? 0 : +1; }
+
++ void closurev1 (hb_colrv1_closure_context_t* c, const void *base) const
++ {
++ if (!c->glyphs->intersects (startGlyphID, endGlyphID)) return;
++ (base+clipBox).closurev1 (c);
++ }
++
+ bool subset (hb_subset_context_t *c,
+ const void *base,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->embed (*this);
+@@ -1625,7 +1689,7 @@ struct ClipRecord
+
+ bool get_extents (hb_glyph_extents_t *extents,
+ const void *base,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ return (base+clipBox).get_extents (extents, instancer);
+ }
+@@ -1642,7 +1706,7 @@ DECLARE_NULL_NAMESPACE_BYTES (OT, ClipRecord);
+ struct ClipList
+ {
+ unsigned serialize_clip_records (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer,
++ const ItemVarStoreInstancer &instancer,
+ const hb_set_t& gids,
+ const hb_map_t& gid_offset_map) const
+ {
+@@ -1695,7 +1759,7 @@ struct ClipList
+ }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->start_embed (*this);
+@@ -1735,7 +1799,7 @@ struct ClipList
+ bool
+ get_extents (hb_codepoint_t gid,
+ hb_glyph_extents_t *extents,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ auto *rec = clips.as_array ().bsearch (gid);
+ if (rec)
+@@ -1855,7 +1919,7 @@ struct BaseGlyphPaintRecord
+
+ bool serialize (hb_serialize_context_t *s, const hb_map_t* glyph_map,
+ const void* src_base, hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SERIALIZE (this);
+ auto *out = s->embed (this);
+@@ -1884,7 +1948,7 @@ struct BaseGlyphPaintRecord
+ struct BaseGlyphList : SortedArray32Of
+ {
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->start_embed (this);
+@@ -1916,7 +1980,7 @@ struct LayerList : Array32OfOffset32To
+ { return this+(*this)[i]; }
+
+ bool subset (hb_subset_context_t *c,
+- const VarStoreInstancer &instancer) const
++ const ItemVarStoreInstancer &instancer) const
+ {
+ TRACE_SUBSET (this);
+ auto *out = c->serializer->start_embed (this);
+@@ -1941,6 +2005,76 @@ struct LayerList : Array32OfOffset32To
+ }
+ };
+
++struct delta_set_index_map_subset_plan_t
++{
++ unsigned get_inner_bit_count () const { return inner_bit_count; }
++ unsigned get_width () const { return ((outer_bit_count + inner_bit_count + 7) / 8); }
++ hb_array_t get_output_map () const { return output_map.as_array (); }
++
++ delta_set_index_map_subset_plan_t (const hb_map_t &new_deltaset_idx_varidx_map)
++ {
++ map_count = 0;
++ outer_bit_count = 0;
++ inner_bit_count = 1;
++ output_map.init ();
++
++ /* search backwards */
++ unsigned count = new_deltaset_idx_varidx_map.get_population ();
++ if (!count) return;
++
++ unsigned last_idx = (unsigned)-1;
++ unsigned last_varidx = (unsigned)-1;
++
++ for (unsigned i = count; i; i--)
++ {
++ unsigned delta_set_idx = i - 1;
++ unsigned var_idx = new_deltaset_idx_varidx_map.get (delta_set_idx);
++ if (i == count)
++ {
++ last_idx = delta_set_idx;
++ last_varidx = var_idx;
++ continue;
++ }
++ if (var_idx != last_varidx)
++ break;
++ last_idx = delta_set_idx;
++ }
++
++ map_count = last_idx + 1;
++ }
++
++ bool remap (const hb_map_t &new_deltaset_idx_varidx_map)
++ {
++ /* recalculate bit_count */
++ outer_bit_count = 1;
++ inner_bit_count = 1;
++
++ if (unlikely (!output_map.resize (map_count, false))) return false;
++
++ for (unsigned idx = 0; idx < map_count; idx++)
++ {
++ uint32_t *var_idx;
++ if (!new_deltaset_idx_varidx_map.has (idx, &var_idx)) return false;
++ output_map.arrayZ[idx] = *var_idx;
++
++ unsigned outer = (*var_idx) >> 16;
++ unsigned bit_count = (outer == 0) ? 1 : hb_bit_storage (outer);
++ outer_bit_count = hb_max (bit_count, outer_bit_count);
++
++ unsigned inner = (*var_idx) & 0xFFFF;
++ bit_count = (inner == 0) ? 1 : hb_bit_storage (inner);
++ inner_bit_count = hb_max (bit_count, inner_bit_count);
++ }
++ return true;
++ }
++
++ private:
++ unsigned map_count;
++ unsigned outer_bit_count;
++ unsigned inner_bit_count;
++ hb_vector_t output_map;
++};
++
+ struct COLR
+ {
+ static constexpr hb_tag_t tableTag = HB_OT_TAG_COLR;
+@@ -1948,10 +2082,11 @@ struct COLR
+ bool has_v0_data () const { return numBaseGlyphs; }
+ bool has_v1_data () const
+ {
+- if (version == 1)
+- return (this+baseGlyphList).len > 0;
++ if (version < 1)
++ return false;
++ hb_barrier ();
+
+- return false;
++ return (this+baseGlyphList).len > 0;
+ }
+
+ unsigned int get_glyph_layers (hb_codepoint_t glyph,
+@@ -1991,8 +2126,26 @@ struct COLR
+
+ void closure_forV1 (hb_set_t *glyphset,
+ hb_set_t *layer_indices,
+- hb_set_t *palette_indices) const
+- { colr->closure_forV1 (glyphset, layer_indices, palette_indices); }
++ hb_set_t *palette_indices,
++ hb_set_t *variation_indices,
++ hb_set_t *delta_set_indices) const
++ { colr->closure_forV1 (glyphset, layer_indices, palette_indices, variation_indices, delta_set_indices); }
++
++ bool has_var_store () const
++ { return colr->has_var_store (); }
++
++ const ItemVariationStore &get_var_store () const
++ { return colr->get_var_store (); }
++ const ItemVariationStore *get_var_store_ptr () const
++ { return colr->get_var_store_ptr (); }
++
++ bool has_delta_set_index_map () const
++ { return colr->has_delta_set_index_map (); }
++
++ const DeltaSetIndexMap &get_delta_set_index_map () const
++ { return colr->get_delta_set_index_map (); }
++ const DeltaSetIndexMap *get_delta_set_index_map_ptr () const
++ { return colr->get_delta_set_index_map_ptr (); }
+
+ private:
+ hb_blob_ptr_t colr;
+@@ -2029,12 +2182,16 @@ struct COLR
+
+ void closure_forV1 (hb_set_t *glyphset,
+ hb_set_t *layer_indices,
+- hb_set_t *palette_indices) const
++ hb_set_t *palette_indices,
++ hb_set_t *variation_indices,
++ hb_set_t *delta_set_indices) const
+ {
+- if (version != 1) return;
++ if (version < 1) return;
++ hb_barrier ();
++
+ hb_set_t visited_glyphs;
+
+- hb_colrv1_closure_context_t c (this, &visited_glyphs, layer_indices, palette_indices);
++ hb_colrv1_closure_context_t c (this, &visited_glyphs, layer_indices, palette_indices, variation_indices);
+ const BaseGlyphList &baseglyph_paintrecords = this+baseGlyphList;
+
+ for (const BaseGlyphPaintRecord &baseglyph_paintrecord: baseglyph_paintrecords.iter ())
+@@ -2046,6 +2203,22 @@ struct COLR
+ paint.dispatch (&c);
+ }
+ hb_set_union (glyphset, &visited_glyphs);
++
++ const ClipList &cliplist = this+clipList;
++ c.glyphs = glyphset;
++ for (const ClipRecord &clip_record : cliplist.clips.iter())
++ clip_record.closurev1 (&c, &cliplist);
++
++ // if a DeltaSetIndexMap is included, collected variation indices are
++ // actually delta set indices, we need to map them into variation indices
++ if (has_delta_set_index_map ())
++ {
++ const DeltaSetIndexMap &var_idx_map = this+varIdxMap;
++ delta_set_indices->set (*variation_indices);
++ variation_indices->clear ();
++ for (unsigned delta_set_idx : *delta_set_indices)
++ variation_indices->add (var_idx_map.map (delta_set_idx));
++ }
+ }
+
+ const LayerList& get_layerList () const
+@@ -2054,14 +2227,37 @@ struct COLR
+ const BaseGlyphList& get_baseglyphList () const
+ { return (this+baseGlyphList); }
+
++ bool has_var_store () const
++ { return version >= 1 && hb_barrier () && varStore != 0; }
++
++ bool has_delta_set_index_map () const
++ { return version >= 1 && hb_barrier () && varIdxMap != 0; }
++
++ bool has_clip_list () const
++ { return version >= 1 && hb_barrier () && clipList != 0; }
++
++ const DeltaSetIndexMap &get_delta_set_index_map () const
++ { return has_delta_set_index_map () && hb_barrier () ? this+varIdxMap : Null (DeltaSetIndexMap); }
++ const DeltaSetIndexMap *get_delta_set_index_map_ptr () const
++ { return has_delta_set_index_map () && hb_barrier () ? &(this+varIdxMap) : nullptr; }
++
++ const ItemVariationStore &get_var_store () const
++ { return has_var_store () && hb_barrier () ? this+varStore : Null (ItemVariationStore); }
++ const ItemVariationStore *get_var_store_ptr () const
++ { return has_var_store () && hb_barrier () ? &(this+varStore) : nullptr; }
++
++ const ClipList &get_clip_list () const
++ { return has_clip_list () && hb_barrier () ? this+clipList : Null (ClipList); }
++
+ bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
++ hb_barrier () &&
+ (this+baseGlyphsZ).sanitize (c, numBaseGlyphs) &&
+ (this+layersZ).sanitize (c, numLayers) &&
+ (version == 0 ||
+- (version == 1 &&
++ (hb_barrier () &&
+ baseGlyphList.sanitize (c, this) &&
+ layerList.sanitize (c, this) &&
+ clipList.sanitize (c, this) &&
+@@ -2127,6 +2323,94 @@ struct COLR
+ return record;
+ }
+
++ bool downgrade_to_V0 (const hb_set_t &glyphset) const
++ {
++ //no more COLRv1 glyphs, downgrade to version 0
++ for (const BaseGlyphPaintRecord& _ : get_baseglyphList ())
++ if (glyphset.has (_.glyphId))
++ return false;
++
++ return true;
++ }
++
++ bool subset_varstore (hb_subset_context_t *c,
++ COLR* out /* OUT */) const
++ {
++ TRACE_SUBSET (this);
++ if (!varStore || c->plan->all_axes_pinned ||
++ !c->plan->colrv1_variation_idx_delta_map)
++ return_trace (true);
++
++ const ItemVariationStore& var_store = this+varStore;
++ if (c->plan->normalized_coords)
++ {
++ item_variations_t item_vars;
++ /* turn off varstore optimization when varIdxMap is null, so we maintain
++ * original var_idx sequence */
++ bool optimize = (varIdxMap != 0) ? true : false;
++ if (!item_vars.instantiate (var_store, c->plan,
++ optimize, /* optimization */
++ optimize, /* use_no_variation_idx = false */
++ c->plan->colrv1_varstore_inner_maps.as_array ()))
++ return_trace (false);
++
++ /* do not serialize varStore if there's no variation data after
++ * instancing: region_list or var_data is empty */
++ if (item_vars.get_region_list () &&
++ item_vars.get_vardata_encodings () &&
++ !out->varStore.serialize_serialize (c->serializer,
++ item_vars.has_long_word (),
++ c->plan->axis_tags,
++ item_vars.get_region_list (),
++ item_vars.get_vardata_encodings ()))
++ return_trace (false);
++
++ /* if varstore is optimized, update colrv1_new_deltaset_idx_varidx_map in
++ * subset plan.
++ * If varstore is empty after instancing, varidx_map would be empty and
++ * all var_idxes will be updated to VarIdx::NO_VARIATION */
++ if (optimize)
++ {
++ const hb_map_t &varidx_map = item_vars.get_varidx_map ();
++ for (auto _ : c->plan->colrv1_new_deltaset_idx_varidx_map.iter_ref ())
++ {
++ uint32_t varidx = _.second;
++ uint32_t *new_varidx;
++ if (varidx_map.has (varidx, &new_varidx))
++ _.second = *new_varidx;
++ else
++ _.second = VarIdx::NO_VARIATION;
++ }
++ }
++ }
++ else
++ {
++ if (unlikely (!out->varStore.serialize_serialize (c->serializer,
++ &var_store,
++ c->plan->colrv1_varstore_inner_maps.as_array ())))
++ return_trace (false);
++ }
++
++ return_trace (true);
++ }
++
++ bool subset_delta_set_index_map (hb_subset_context_t *c,
++ COLR* out /* OUT */) const
++ {
++ TRACE_SUBSET (this);
++ if (!varIdxMap || c->plan->all_axes_pinned ||
++ !c->plan->colrv1_new_deltaset_idx_varidx_map)
++ return_trace (true);
++
++ const hb_map_t &deltaset_idx_varidx_map = c->plan->colrv1_new_deltaset_idx_varidx_map;
++ delta_set_index_map_subset_plan_t index_map_plan (deltaset_idx_varidx_map);
++
++ if (unlikely (!index_map_plan.remap (deltaset_idx_varidx_map)))
++ return_trace (false);
++
++ return_trace (out->varIdxMap.serialize_serialize (c->serializer, index_map_plan));
++ }
++
+ bool subset (hb_subset_context_t *c) const
+ {
+ TRACE_SUBSET (this);
+@@ -2195,34 +2479,30 @@ struct COLR
+ auto *colr_prime = c->serializer->start_embed ();
+ if (unlikely (!c->serializer->extend_min (colr_prime))) return_trace (false);
+
+- if (version == 0)
+- return_trace (colr_prime->serialize_V0 (c->serializer, version, base_it, layer_it));
++ if (version == 0 || downgrade_to_V0 (glyphset))
++ return_trace (colr_prime->serialize_V0 (c->serializer, 0, base_it, layer_it));
++
++ hb_barrier ();
+
+- auto snap = c->serializer->snapshot ();
++ //start version 1
+ if (!c->serializer->allocate_size (5 * HBUINT32::static_size)) return_trace (false);
++ if (!colr_prime->serialize_V0 (c->serializer, version, base_it, layer_it)) return_trace (false);
+
+- VarStoreInstancer instancer (varStore ? &(this+varStore) : nullptr,
+- varIdxMap ? &(this+varIdxMap) : nullptr,
+- c->plan->normalized_coords.as_array ());
++ /* subset ItemVariationStore first, cause varidx_map needs to be updated
++ * after instancing */
++ if (!subset_varstore (c, colr_prime)) return_trace (false);
+
+- if (!colr_prime->baseGlyphList.serialize_subset (c, baseGlyphList, this, instancer))
+- {
+- if (c->serializer->in_error ()) return_trace (false);
+- //no more COLRv1 glyphs: downgrade to version 0
+- c->serializer->revert (snap);
+- return_trace (colr_prime->serialize_V0 (c->serializer, 0, base_it, layer_it));
+- }
++ ItemVarStoreInstancer instancer (get_var_store_ptr (),
++ get_delta_set_index_map_ptr (),
++ c->plan->normalized_coords.as_array ());
+
+- if (!colr_prime->serialize_V0 (c->serializer, version, base_it, layer_it)) return_trace (false);
++ if (!colr_prime->baseGlyphList.serialize_subset (c, baseGlyphList, this, instancer))
++ return_trace (false);
+
+ colr_prime->layerList.serialize_subset (c, layerList, this, instancer);
+ colr_prime->clipList.serialize_subset (c, clipList, this, instancer);
+- if (!varStore || c->plan->all_axes_pinned)
+- return_trace (true);
+
+- colr_prime->varIdxMap.serialize_copy (c->serializer, varIdxMap, this);
+- colr_prime->varStore.serialize_copy (c->serializer, varStore, this);
+- return_trace (true);
++ return_trace (subset_delta_set_index_map (c, colr_prime));
+ }
+
+ const Paint *get_base_glyph_paint (hb_codepoint_t glyph) const
+@@ -2242,12 +2522,10 @@ struct COLR
+ bool
+ get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
+ {
+- if (version != 1)
+- return false;
+
+- VarStoreInstancer instancer (&(this+varStore),
+- &(this+varIdxMap),
+- hb_array (font->coords, font->num_coords));
++ ItemVarStoreInstancer instancer (get_var_store_ptr (),
++ get_delta_set_index_map_ptr (),
++ hb_array (font->coords, font->num_coords));
+
+ if (get_clip (glyph, extents, instancer))
+ {
+@@ -2282,8 +2560,10 @@ struct COLR
+ bool
+ has_paint_for_glyph (hb_codepoint_t glyph) const
+ {
+- if (version == 1)
++ if (version >= 1)
+ {
++ hb_barrier ();
++
+ const Paint *paint = get_base_glyph_paint (glyph);
+
+ return paint != nullptr;
+@@ -2294,9 +2574,9 @@ struct COLR
+
+ bool get_clip (hb_codepoint_t glyph,
+ hb_glyph_extents_t *extents,
+- const VarStoreInstancer instancer) const
++ const ItemVarStoreInstancer instancer) const
+ {
+- return (this+clipList).get_extents (glyph,
++ return get_clip_list ().get_extents (glyph,
+ extents,
+ instancer);
+ }
+@@ -2305,23 +2585,23 @@ struct COLR
+ bool
+ paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, unsigned int palette_index, hb_color_t foreground, bool clip = true) const
+ {
+- VarStoreInstancer instancer (&(this+varStore),
+- &(this+varIdxMap),
+- hb_array (font->coords, font->num_coords));
++ ItemVarStoreInstancer instancer (get_var_store_ptr (),
++ get_delta_set_index_map_ptr (),
++ hb_array (font->coords, font->num_coords));
+ hb_paint_context_t c (this, funcs, data, font, palette_index, foreground, instancer);
+- c.current_glyphs.add (glyph);
+
+- if (version == 1)
++ hb_decycler_node_t node (c.glyphs_decycler);
++ node.visit (glyph);
++
++ if (version >= 1)
+ {
++ hb_barrier ();
++
+ const Paint *paint = get_base_glyph_paint (glyph);
+ if (paint)
+ {
+ // COLRv1 glyph
+
+- VarStoreInstancer instancer (&(this+varStore),
+- &(this+varIdxMap),
+- hb_array (font->coords, font->num_coords));
+-
+ bool is_bounded = true;
+ if (clip)
+ {
+@@ -2404,7 +2684,7 @@ struct COLR
+ Offset32To layerList;
+ Offset32To clipList; // Offset to ClipList table (may be NULL)
+ Offset32To varIdxMap; // Offset to DeltaSetIndexMap table (may be NULL)
+- Offset32To varStore;
++ Offset32To varStore;
+ public:
+ DEFINE_SIZE_MIN (14);
+ };
+@@ -2427,19 +2707,16 @@ void PaintColrLayers::paint_glyph (hb_paint_context_t *c) const
+ {
+ TRACE_PAINT (this);
+ const LayerList &paint_offset_lists = c->get_colr_table ()->get_layerList ();
++ hb_decycler_node_t node (c->layers_decycler);
+ for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++)
+ {
+- if (unlikely (c->current_layers.has (i)))
+- continue;
+-
+- c->current_layers.add (i);
++ if (unlikely (!node.visit (i)))
++ return;
+
+ const Paint &paint = paint_offset_lists.get_paint (i);
+ c->funcs->push_group (c->data);
+ c->recurse (paint);
+ c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER);
+-
+- c->current_layers.del (i);
+ }
+ }
+
+@@ -2447,16 +2724,14 @@ void PaintColrGlyph::paint_glyph (hb_paint_context_t *c) const
+ {
+ TRACE_PAINT (this);
+
+- if (unlikely (c->current_glyphs.has (gid)))
++ hb_decycler_node_t node (c->glyphs_decycler);
++ if (unlikely (!node.visit (gid)))
+ return;
+
+- c->current_glyphs.add (gid);
+-
+ c->funcs->push_inverse_root_transform (c->data, c->font);
+ if (c->funcs->color_glyph (c->data, gid, c->font))
+ {
+ c->funcs->pop_transform (c->data);
+- c->current_glyphs.del (gid);
+ return;
+ }
+ c->funcs->pop_transform (c->data);
+@@ -2479,8 +2754,6 @@ void PaintColrGlyph::paint_glyph (hb_paint_context_t *c) const
+
+ if (has_clip_box)
+ c->funcs->pop_clip (c->data);
+-
+- c->current_glyphs.del (gid);
+ }
+
+ } /* namespace OT */
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/colrv1-closure.hh b/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/colrv1-closure.hh
+index 705863d4a..9ed0aa563 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/colrv1-closure.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Color/COLR/colrv1-closure.hh
+@@ -66,34 +66,64 @@ HB_INTERNAL void PaintColrGlyph::closurev1 (hb_colrv1_closure_context_t* c) cons
+
+ template class Var>
+ HB_INTERNAL void PaintTransform::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ (this+transform).closurev1 (c);
++}
+
+ HB_INTERNAL void PaintTranslate::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 2;
++}
+
+ HB_INTERNAL void PaintScale::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 2;
++}
+
+ HB_INTERNAL void PaintScaleAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 4;
++}
+
+ HB_INTERNAL void PaintScaleUniform::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 1;
++}
+
+ HB_INTERNAL void PaintScaleUniformAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 3;
++}
+
+ HB_INTERNAL void PaintRotate::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 1;
++}
+
+ HB_INTERNAL void PaintRotateAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 3;
++}
+
+ HB_INTERNAL void PaintSkew::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 2;
++}
+
+ HB_INTERNAL void PaintSkewAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
+-{ (this+src).dispatch (c); }
++{
++ (this+src).dispatch (c);
++ c->num_var_idxes = 4;
++}
+
+ HB_INTERNAL void PaintComposite::closurev1 (hb_colrv1_closure_context_t* c) const
+ {
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Color/CPAL/CPAL.hh b/src/java.desktop/share/native/libharfbuzz/OT/Color/CPAL/CPAL.hh
+index ed8f5957e..51fc1b52a 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Color/CPAL/CPAL.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Color/CPAL/CPAL.hh
+@@ -187,6 +187,14 @@ struct CPAL
+ hb_ot_name_id_t get_color_name_id (unsigned int color_index) const
+ { return v1 ().get_color_name_id (this, color_index, numColors); }
+
++ hb_array_t get_palette_colors (unsigned int palette_index) const
++ {
++ if (unlikely (palette_index >= numPalettes))
++ return hb_array_t ();
++ unsigned int start_index = colorRecordIndicesZ[palette_index];
++ hb_array_t all_colors ((this+colorRecordsZ).arrayZ, numColorRecords);
++ return all_colors.sub_array (start_index, numColors);
++ }
+ unsigned int get_palette_colors (unsigned int palette_index,
+ unsigned int start_offset,
+ unsigned int *color_count, /* IN/OUT. May be NULL. */
+@@ -214,13 +222,17 @@ struct CPAL
+ hb_set_t *nameids_to_retain /* OUT */) const
+ {
+ if (version == 1)
++ {
++ hb_barrier ();
+ v1 ().collect_name_ids (this, numPalettes, numColors, color_index_map, nameids_to_retain);
++ }
+ }
+
+ private:
+ const CPALV1Tail& v1 () const
+ {
+ if (version == 0) return Null (CPALV1Tail);
++ hb_barrier ();
+ return StructAfter (*this);
+ }
+
+@@ -312,7 +324,10 @@ struct CPAL
+ return_trace (false);
+
+ if (version == 1)
++ {
++ hb_barrier ();
+ return_trace (v1 ().serialize (c->serializer, numPalettes, numColors, this, color_index_map));
++ }
+
+ return_trace (true);
+ }
+@@ -321,6 +336,7 @@ struct CPAL
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
++ hb_barrier () &&
+ (this+colorRecordsZ).sanitize (c, numColorRecords) &&
+ colorRecordIndicesZ.sanitize (c, numPalettes) &&
+ (version == 0 || v1 ().sanitize (c, this, numPalettes, numColors)));
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Color/sbix/sbix.hh b/src/java.desktop/share/native/libharfbuzz/OT/Color/sbix/sbix.hh
+index 20b06ab13..e95d8c13a 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Color/sbix/sbix.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Color/sbix/sbix.hh
+@@ -368,6 +368,7 @@ struct sbix
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
++ hb_barrier () &&
+ version >= 1 &&
+ strikes.sanitize (c, this)));
+ }
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Color/svg/svg.hh b/src/java.desktop/share/native/libharfbuzz/OT/Color/svg/svg.hh
+index c8ff6ab74..9f676f968 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Color/svg/svg.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Color/svg/svg.hh
+@@ -56,6 +56,7 @@ struct SVGDocumentIndexEntry
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
++ hb_barrier () &&
+ svgDoc.sanitize (c, base, svgDocLength));
+ }
+
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/Coverage.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/Coverage.hh
+index 257b2a336..35d73c7b8 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/Coverage.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/Coverage.hh
+@@ -64,6 +64,7 @@ struct Coverage
+ {
+ TRACE_SANITIZE (this);
+ if (!u.format.sanitize (c)) return_trace (false);
++ hb_barrier ();
+ switch (u.format)
+ {
+ case 1: return_trace (u.format1.sanitize (c));
+@@ -95,6 +96,15 @@ struct Coverage
+ default:return NOT_COVERED;
+ }
+ }
++ unsigned int get_coverage (hb_codepoint_t glyph_id,
++ hb_ot_lookup_cache_t *cache) const
++ {
++ unsigned coverage;
++ if (cache && cache->get (glyph_id, &coverage)) return coverage;
++ coverage = get_coverage (glyph_id);
++ if (cache) cache->set (glyph_id, coverage);
++ return coverage;
++ }
+
+ unsigned get_population () const
+ {
+@@ -200,6 +210,19 @@ struct Coverage
+ }
+ }
+
++ unsigned cost () const
++ {
++ switch (u.format) {
++ case 1: hb_barrier (); return u.format1.cost ();
++ case 2: hb_barrier (); return u.format2.cost ();
++#ifndef HB_NO_BEYOND_64K
++ case 3: hb_barrier (); return u.format3.cost ();
++ case 4: hb_barrier (); return u.format4.cost ();
++#endif
++ default:return 0u;
++ }
++ }
++
+ /* Might return false if array looks unsorted.
+ * Used for faster rejection of corrupt data. */
+ template
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat1.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat1.hh
+index 995f1ebdb..4a925763b 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat1.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat1.hh
+@@ -103,6 +103,8 @@ struct CoverageFormat1_3
+ intersect_glyphs << glyphArray[i];
+ }
+
++ unsigned cost () const { return hb_bit_storage ((unsigned) glyphArray.len); /* bsearch cost */ }
++
+ template
+ bool collect_coverage (set_t *glyphs) const
+ { return glyphs->add_sorted_array (glyphArray.as_array ()); }
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat2.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat2.hh
+index d47c7eea9..247b7274b 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat2.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/Common/CoverageFormat2.hh
+@@ -157,6 +157,8 @@ struct CoverageFormat2_4
+ }
+ }
+
++ unsigned cost () const { return hb_bit_storage ((unsigned) rangeRecord.len); /* bsearch cost */ }
++
+ template
+ bool collect_coverage (set_t *glyphs) const
+ {
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GDEF/GDEF.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GDEF/GDEF.hh
+index 98543f56c..542480d2d 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GDEF/GDEF.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GDEF/GDEF.hh
+@@ -189,7 +189,7 @@ struct CaretValueFormat3
+ friend struct CaretValue;
+
+ hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction,
+- const VariationStore &var_store) const
++ const ItemVariationStore &var_store) const
+ {
+ return HB_DIRECTION_IS_HORIZONTAL (direction) ?
+ font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font, var_store) :
+@@ -251,7 +251,7 @@ struct CaretValue
+ hb_position_t get_caret_value (hb_font_t *font,
+ hb_direction_t direction,
+ hb_codepoint_t glyph_id,
+- const VariationStore &var_store) const
++ const ItemVariationStore &var_store) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_caret_value (font, direction);
+@@ -291,6 +291,7 @@ struct CaretValue
+ {
+ TRACE_SANITIZE (this);
+ if (!u.format.sanitize (c)) return_trace (false);
++ hb_barrier ();
+ switch (u.format) {
+ case 1: return_trace (u.format1.sanitize (c));
+ case 2: return_trace (u.format2.sanitize (c));
+@@ -315,7 +316,7 @@ struct LigGlyph
+ unsigned get_lig_carets (hb_font_t *font,
+ hb_direction_t direction,
+ hb_codepoint_t glyph_id,
+- const VariationStore &var_store,
++ const ItemVariationStore &var_store,
+ unsigned start_offset,
+ unsigned *caret_count /* IN/OUT */,
+ hb_position_t *caret_array /* OUT */) const
+@@ -371,7 +372,7 @@ struct LigCaretList
+ unsigned int get_lig_carets (hb_font_t *font,
+ hb_direction_t direction,
+ hb_codepoint_t glyph_id,
+- const VariationStore &var_store,
++ const ItemVariationStore &var_store,
+ unsigned int start_offset,
+ unsigned int *caret_count /* IN/OUT */,
+ hb_position_t *caret_array /* OUT */) const
+@@ -441,6 +442,20 @@ struct MarkGlyphSetsFormat1
+ bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
+ { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
+
++ void collect_used_mark_sets (const hb_set_t& glyph_set,
++ hb_set_t& used_mark_sets /* OUT */) const
++ {
++ unsigned i = 0;
++ for (const auto &offset : coverage)
++ {
++ const auto &cov = this+offset;
++ if (cov.intersects (&glyph_set))
++ used_mark_sets.add (i);
++
++ i++;
++ }
++ }
++
+ template
+ void collect_coverage (hb_vector_t &sets) const
+ {
+@@ -461,6 +476,7 @@ struct MarkGlyphSetsFormat1
+ bool ret = true;
+ for (const Offset32To& offset : coverage.iter ())
+ {
++ auto snap = c->serializer->snapshot ();
+ auto *o = out->coverage.serialize_append (c->serializer);
+ if (unlikely (!o))
+ {
+@@ -468,11 +484,17 @@ struct MarkGlyphSetsFormat1
+ break;
+ }
+
+- //not using o->serialize_subset (c, offset, this, out) here because
+- //OTS doesn't allow null offset.
+- //See issue: https://github.com/khaledhosny/ots/issues/172
++ //skip empty coverage
+ c->serializer->push ();
+- c->dispatch (this+offset);
++ bool res = false;
++ if (offset) res = c->dispatch (this+offset);
++ if (!res)
++ {
++ c->serializer->pop_discard ();
++ c->serializer->revert (snap);
++ (out->coverage.len)--;
++ continue;
++ }
+ c->serializer->add_link (*o, c->serializer->pop_pack ());
+ }
+
+@@ -513,6 +535,15 @@ struct MarkGlyphSets
+ }
+ }
+
++ void collect_used_mark_sets (const hb_set_t& glyph_set,
++ hb_set_t& used_mark_sets /* OUT */) const
++ {
++ switch (u.format) {
++ case 1: u.format1.collect_used_mark_sets (glyph_set, used_mark_sets); return;
++ default:return;
++ }
++ }
++
+ bool subset (hb_subset_context_t *c) const
+ {
+ TRACE_SUBSET (this);
+@@ -526,6 +557,7 @@ struct MarkGlyphSets
+ {
+ TRACE_SANITIZE (this);
+ if (!u.format.sanitize (c)) return_trace (false);
++ hb_barrier ();
+ switch (u.format) {
+ case 1: return_trace (u.format1.sanitize (c));
+ default:return_trace (true);
+@@ -577,7 +609,7 @@ struct GDEFVersion1_2
+ * definitions--from beginning of GDEF
+ * header (may be NULL). Introduced
+ * in version 0x00010002. */
+- Offset32To
++ Offset32To
+ varStore; /* Offset to the table of Item Variation
+ * Store--from beginning of GDEF
+ * header (may be NULL). Introduced
+@@ -600,8 +632,9 @@ struct GDEFVersion1_2
+ attachList.sanitize (c, this) &&
+ ligCaretList.sanitize (c, this) &&
+ markAttachClassDef.sanitize (c, this) &&
+- (version.to_int () < 0x00010002u || markGlyphSetsDef.sanitize (c, this)) &&
+- (version.to_int () < 0x00010003u || varStore.sanitize (c, this)));
++ hb_barrier () &&
++ ((version.to_int () < 0x00010002u && hb_barrier ()) || markGlyphSetsDef.sanitize (c, this)) &&
++ ((version.to_int () < 0x00010003u && hb_barrier ()) || varStore.sanitize (c, this)));
+ }
+
+ static void remap_varidx_after_instantiation (const hb_map_t& varidx_map,
+@@ -627,23 +660,23 @@ struct GDEFVersion1_2
+ bool subset (hb_subset_context_t *c) const
+ {
+ TRACE_SUBSET (this);
+- auto *out = c->serializer->embed (*this);
+- if (unlikely (!out)) return_trace (false);
+-
+- bool subset_glyphclassdef = out->glyphClassDef.serialize_subset (c, glyphClassDef, this, nullptr, false, true);
+- bool subset_attachlist = out->attachList.serialize_subset (c, attachList, this);
+- bool subset_ligcaretlist = out->ligCaretList.serialize_subset (c, ligCaretList, this);
+- bool subset_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, nullptr, false, true);
++ auto *out = c->serializer->start_embed (*this);
++ if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
+
+- bool subset_markglyphsetsdef = false;
+- if (version.to_int () >= 0x00010002u)
+- {
+- subset_markglyphsetsdef = out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this);
+- }
++ // Push var store first (if it's needed) so that it's last in the
++ // serialization order. Some font consumers assume that varstore runs to
++ // the end of the GDEF table.
++ // See: https://github.com/harfbuzz/harfbuzz/issues/4636
++ auto snapshot_version0 = c->serializer->snapshot ();
++ if (unlikely (version.to_int () >= 0x00010002u && hb_barrier () && !c->serializer->embed (markGlyphSetsDef)))
++ return_trace (false);
+
+ bool subset_varstore = false;
+- if (version.to_int () >= 0x00010003u)
++ unsigned varstore_index = (unsigned) -1;
++ auto snapshot_version2 = c->serializer->snapshot ();
++ if (version.to_int () >= 0x00010003u && hb_barrier ())
+ {
++ if (unlikely (!c->serializer->embed (varStore))) return_trace (false);
+ if (c->plan->all_axes_pinned)
+ out->varStore = 0;
+ else if (c->plan->normalized_coords)
+@@ -652,27 +685,56 @@ struct GDEFVersion1_2
+ {
+ item_variations_t item_vars;
+ if (item_vars.instantiate (this+varStore, c->plan, true, true,
+- c->plan->gdef_varstore_inner_maps.as_array ()))
++ c->plan->gdef_varstore_inner_maps.as_array ())) {
+ subset_varstore = out->varStore.serialize_serialize (c->serializer,
+ item_vars.has_long_word (),
+ c->plan->axis_tags,
+ item_vars.get_region_list (),
+ item_vars.get_vardata_encodings ());
++ varstore_index = c->serializer->last_added_child_index();
++ }
+ remap_varidx_after_instantiation (item_vars.get_varidx_map (),
+ c->plan->layout_variation_idx_delta_map);
+ }
+ }
+ else
++ {
+ subset_varstore = out->varStore.serialize_subset (c, varStore, this, c->plan->gdef_varstore_inner_maps.as_array ());
++ varstore_index = c->serializer->last_added_child_index();
++ }
++ }
++
++ out->version.major = version.major;
++ out->version.minor = version.minor;
++
++ if (!subset_varstore && version.to_int () >= 0x00010002u) {
++ c->serializer->revert (snapshot_version2);
++ }
++
++ bool subset_markglyphsetsdef = false;
++ if (version.to_int () >= 0x00010002u && hb_barrier ())
++ {
++ subset_markglyphsetsdef = out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this);
+ }
+
+ if (subset_varstore)
+ {
+ out->version.minor = 3;
++ c->plan->has_gdef_varstore = true;
+ } else if (subset_markglyphsetsdef) {
+ out->version.minor = 2;
+ } else {
+ out->version.minor = 0;
++ c->serializer->revert (snapshot_version0);
++ }
++
++ bool subset_glyphclassdef = out->glyphClassDef.serialize_subset (c, glyphClassDef, this, nullptr, false, true);
++ bool subset_attachlist = out->attachList.serialize_subset (c, attachList, this);
++ bool subset_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, nullptr, false, true);
++ bool subset_ligcaretlist = out->ligCaretList.serialize_subset (c, ligCaretList, this);
++
++ if (subset_varstore && varstore_index != (unsigned) -1) {
++ c->serializer->repack_last(varstore_index);
+ }
+
+ return_trace (subset_glyphclassdef || subset_attachlist ||
+@@ -709,6 +771,7 @@ struct GDEF
+ {
+ TRACE_SANITIZE (this);
+ if (unlikely (!u.version.sanitize (c))) return_trace (false);
++ hb_barrier ();
+ switch (u.version.major) {
+ case 1: return_trace (u.version1.sanitize (c));
+ #ifndef HB_NO_BEYOND_64K
+@@ -812,7 +875,7 @@ struct GDEF
+ bool has_mark_glyph_sets () const
+ {
+ switch (u.version.major) {
+- case 1: return u.version.to_int () >= 0x00010002u && u.version1.markGlyphSetsDef != 0;
++ case 1: return u.version.to_int () >= 0x00010002u && hb_barrier () && u.version1.markGlyphSetsDef != 0;
+ #ifndef HB_NO_BEYOND_64K
+ case 2: return u.version2.markGlyphSetsDef != 0;
+ #endif
+@@ -822,7 +885,7 @@ struct GDEF
+ const MarkGlyphSets &get_mark_glyph_sets () const
+ {
+ switch (u.version.major) {
+- case 1: return u.version.to_int () >= 0x00010002u ? this+u.version1.markGlyphSetsDef : Null(MarkGlyphSets);
++ case 1: return u.version.to_int () >= 0x00010002u && hb_barrier () ? this+u.version1.markGlyphSetsDef : Null(MarkGlyphSets);
+ #ifndef HB_NO_BEYOND_64K
+ case 2: return this+u.version2.markGlyphSetsDef;
+ #endif
+@@ -832,21 +895,21 @@ struct GDEF
+ bool has_var_store () const
+ {
+ switch (u.version.major) {
+- case 1: return u.version.to_int () >= 0x00010003u && u.version1.varStore != 0;
++ case 1: return u.version.to_int () >= 0x00010003u && hb_barrier () && u.version1.varStore != 0;
+ #ifndef HB_NO_BEYOND_64K
+ case 2: return u.version2.varStore != 0;
+ #endif
+ default: return false;
+ }
+ }
+- const VariationStore &get_var_store () const
++ const ItemVariationStore &get_var_store () const
+ {
+ switch (u.version.major) {
+- case 1: return u.version.to_int () >= 0x00010003u ? this+u.version1.varStore : Null(VariationStore);
++ case 1: return u.version.to_int () >= 0x00010003u && hb_barrier () ? this+u.version1.varStore : Null(ItemVariationStore);
+ #ifndef HB_NO_BEYOND_64K
+ case 2: return this+u.version2.varStore;
+ #endif
+- default: return Null(VariationStore);
++ default: return Null(ItemVariationStore);
+ }
+ }
+
+@@ -959,47 +1022,6 @@ struct GDEF
+ void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
+ { get_lig_caret_list ().collect_variation_indices (c); }
+
+- void remap_layout_variation_indices (const hb_set_t *layout_variation_indices,
+- const hb_vector_t& normalized_coords,
+- bool calculate_delta, /* not pinned at default */
+- bool no_variations, /* all axes pinned */
+- hb_hashmap_t> *layout_variation_idx_delta_map /* OUT */) const
+- {
+- if (!has_var_store ()) return;
+- const VariationStore &var_store = get_var_store ();
+- float *store_cache = var_store.create_cache ();
+-
+- unsigned new_major = 0, new_minor = 0;
+- unsigned last_major = (layout_variation_indices->get_min ()) >> 16;
+- for (unsigned idx : layout_variation_indices->iter ())
+- {
+- int delta = 0;
+- if (calculate_delta)
+- delta = roundf (var_store.get_delta (idx, normalized_coords.arrayZ,
+- normalized_coords.length, store_cache));
+-
+- if (no_variations)
+- {
+- layout_variation_idx_delta_map->set (idx, hb_pair_t (HB_OT_LAYOUT_NO_VARIATIONS_INDEX, delta));
+- continue;
+- }
+-
+- uint16_t major = idx >> 16;
+- if (major >= var_store.get_sub_table_count ()) break;
+- if (major != last_major)
+- {
+- new_minor = 0;
+- ++new_major;
+- }
+-
+- unsigned new_idx = (new_major << 16) + new_minor;
+- layout_variation_idx_delta_map->set (idx, hb_pair_t (new_idx, delta));
+- ++new_minor;
+- last_major = major;
+- }
+- var_store.destroy_cache (store_cache);
+- }
+-
+ protected:
+ union {
+ FixedVersion<> version; /* Version identifier */
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Anchor.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Anchor.hh
+index 49e76e775..7802e397f 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Anchor.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Anchor.hh
+@@ -25,6 +25,7 @@ struct Anchor
+ {
+ TRACE_SANITIZE (this);
+ if (!u.format.sanitize (c)) return_trace (false);
++ hb_barrier ();
+ switch (u.format) {
+ case 1: return_trace (u.format1.sanitize (c));
+ case 2: return_trace (u.format2.sanitize (c));
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorFormat3.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorFormat3.hh
+index 23821a49c..61bd90310 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorFormat3.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorFormat3.hh
+@@ -38,9 +38,15 @@ struct AnchorFormat3
+ *y = font->em_fscale_y (yCoordinate);
+
+ if ((font->x_ppem || font->num_coords) && xDeviceTable.sanitize (&c->sanitizer, this))
++ {
++ hb_barrier ();
+ *x += (this+xDeviceTable).get_x_delta (font, c->var_store, c->var_store_cache);
++ }
+ if ((font->y_ppem || font->num_coords) && yDeviceTable.sanitize (&c->sanitizer, this))
++ {
++ hb_barrier ();
+ *y += (this+yDeviceTable).get_y_delta (font, c->var_store, c->var_store_cache);
++ }
+ }
+
+ bool subset (hb_subset_context_t *c) const
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorMatrix.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorMatrix.hh
+index b61f1413e..9da9fff50 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorMatrix.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/AnchorMatrix.hh
+@@ -8,7 +8,7 @@ namespace GPOS_impl {
+ struct AnchorMatrix
+ {
+ HBUINT16 rows; /* Number of rows */
+- UnsizedArrayOf>
++ UnsizedArrayOf>
+ matrixZ; /* Matrix of offsets to Anchor tables--
+ * from beginning of AnchorMatrix table */
+ public:
+@@ -18,6 +18,7 @@ struct AnchorMatrix
+ {
+ TRACE_SANITIZE (this);
+ if (!c->check_struct (this)) return_trace (false);
++ hb_barrier ();
+ if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false);
+ unsigned int count = rows * cols;
+ if (!c->check_array (matrixZ.arrayZ, count)) return_trace (false);
+@@ -25,6 +26,7 @@ struct AnchorMatrix
+ if (c->lazy_some_gpos)
+ return_trace (true);
+
++ hb_barrier ();
+ for (unsigned int i = 0; i < count; i++)
+ if (!matrixZ[i].sanitize (c, this)) return_trace (false);
+ return_trace (true);
+@@ -38,6 +40,7 @@ struct AnchorMatrix
+ if (unlikely (row >= rows || col >= cols)) return Null (Anchor);
+ auto &offset = matrixZ[row * cols + col];
+ if (unlikely (!offset.sanitize (&c->sanitizer, this))) return Null (Anchor);
++ hb_barrier ();
+ *found = !offset.is_null ();
+ return this+offset;
+ }
+@@ -65,15 +68,14 @@ struct AnchorMatrix
+ if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
+
+ out->rows = num_rows;
+- bool ret = false;
+ for (const unsigned i : index_iter)
+ {
+ auto *offset = c->serializer->embed (matrixZ[i]);
+ if (!offset) return_trace (false);
+- ret |= offset->serialize_subset (c, matrixZ[i], this);
++ offset->serialize_subset (c, matrixZ[i], this);
+ }
+
+- return_trace (ret);
++ return_trace (true);
+ }
+ };
+
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Common.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Common.hh
+index 408197454..696d25d75 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Common.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/Common.hh
+@@ -23,7 +23,7 @@ static void SinglePos_serialize (hb_serialize_context_t *c,
+ const SrcLookup *src,
+ Iterator it,
+ const hb_hashmap_t> *layout_variation_idx_delta_map,
+- bool all_axes_pinned);
++ unsigned new_format);
+
+
+ }
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/CursivePosFormat1.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/CursivePosFormat1.hh
+index 3a2957af1..361aaed65 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/CursivePosFormat1.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/CursivePosFormat1.hh
+@@ -11,21 +11,21 @@ struct EntryExitRecord
+ {
+ friend struct CursivePosFormat1;
+
+- bool sanitize (hb_sanitize_context_t *c, const void *base) const
++ bool sanitize (hb_sanitize_context_t *c, const struct CursivePosFormat1 *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base));
+ }
+
+ void collect_variation_indices (hb_collect_variation_indices_context_t *c,
+- const void *src_base) const
++ const struct CursivePosFormat1 *src_base) const
+ {
+ (src_base+entryAnchor).collect_variation_indices (c);
+ (src_base+exitAnchor).collect_variation_indices (c);
+ }
+
+ bool subset (hb_subset_context_t *c,
+- const void *src_base) const
++ const struct CursivePosFormat1 *src_base) const
+ {
+ TRACE_SERIALIZE (this);
+ auto *out = c->serializer->embed (this);
+@@ -38,11 +38,11 @@ struct EntryExitRecord
+ }
+
+ protected:
+- Offset16To
++ Offset16To
+ entryAnchor; /* Offset to EntryAnchor table--from
+ * beginning of CursivePos
+ * subtable--may be NULL */
+- Offset16To
++ Offset16To
+ exitAnchor; /* Offset to ExitAnchor table--from
+ * beginning of CursivePos
+ * subtable--may be NULL */
+@@ -128,6 +128,7 @@ struct CursivePosFormat1
+ const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
+ if (!this_record.entryAnchor ||
+ unlikely (!this_record.entryAnchor.sanitize (&c->sanitizer, this))) return_trace (false);
++ hb_barrier ();
+
+ hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
+ skippy_iter.reset_fast (buffer->idx);
+@@ -145,6 +146,7 @@ struct CursivePosFormat1
+ buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1);
+ return_trace (false);
+ }
++ hb_barrier ();
+
+ unsigned int i = skippy_iter.idx;
+ unsigned int j = buffer->idx;
+@@ -262,7 +264,7 @@ struct CursivePosFormat1
+ hb_requires (hb_is_iterator (Iterator))>
+ void serialize (hb_subset_context_t *c,
+ Iterator it,
+- const void *src_base)
++ const struct CursivePosFormat1 *src_base)
+ {
+ if (unlikely (!c->serializer->extend_min ((*this)))) return;
+ this->format = 1;
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/MarkMarkPosFormat1.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/MarkMarkPosFormat1.hh
+index ea196581a..6519e79b4 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/MarkMarkPosFormat1.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/MarkMarkPosFormat1.hh
+@@ -42,6 +42,7 @@ struct MarkMarkPosFormat1_2
+ mark1Coverage.sanitize (c, this) &&
+ mark2Coverage.sanitize (c, this) &&
+ mark1Array.sanitize (c, this) &&
++ hb_barrier () &&
+ mark2Array.sanitize (c, this, (unsigned int) classCount));
+ }
+
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat1.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat1.hh
+index 478c72df7..597ff4c08 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat1.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat1.hh
+@@ -36,6 +36,7 @@ struct PairPosFormat1_3
+ TRACE_SANITIZE (this);
+
+ if (!c->check_struct (this)) return_trace (false);
++ hb_barrier ();
+
+ unsigned int len1 = valueFormat[0].get_len ();
+ unsigned int len2 = valueFormat[1].get_len ();
+@@ -102,12 +103,50 @@ struct PairPosFormat1_3
+
+ const Coverage &get_coverage () const { return this+coverage; }
+
+- bool apply (hb_ot_apply_context_t *c) const
++ unsigned cache_cost () const
++ {
++ return (this+coverage).cost ();
++ }
++ static void * cache_func (void *p, hb_ot_lookup_cache_op_t op)
++ {
++ switch (op)
++ {
++ case hb_ot_lookup_cache_op_t::CREATE:
++ {
++ hb_ot_lookup_cache_t *cache = (hb_ot_lookup_cache_t *) hb_malloc (sizeof (hb_ot_lookup_cache_t));
++ if (likely (cache))
++ cache->clear ();
++ return cache;
++ }
++ case hb_ot_lookup_cache_op_t::ENTER:
++ return (void *) true;
++ case hb_ot_lookup_cache_op_t::LEAVE:
++ return nullptr;
++ case hb_ot_lookup_cache_op_t::DESTROY:
++ {
++ hb_ot_lookup_cache_t *cache = (hb_ot_lookup_cache_t *) p;
++ hb_free (cache);
++ return nullptr;
++ }
++ }
++ return nullptr;
++ }
++
++ bool apply_cached (hb_ot_apply_context_t *c) const { return _apply (c, true); }
++ bool apply (hb_ot_apply_context_t *c) const { return _apply (c, false); }
++ bool _apply (hb_ot_apply_context_t *c, bool cached) const
+ {
+ TRACE_APPLY (this);
++
+ hb_buffer_t *buffer = c->buffer;
++
++#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
++ hb_ot_lookup_cache_t *cache = cached ? (hb_ot_lookup_cache_t *) c->lookup_accel->cache : nullptr;
++ unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint, cache);
++#else
+ unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
+- if (likely (index == NOT_COVERED)) return_trace (false);
++#endif
++ if (index == NOT_COVERED) return_trace (false);
+
+ hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
+ skippy_iter.reset_fast (buffer->idx);
+@@ -131,21 +170,34 @@ struct PairPosFormat1_3
+ auto *out = c->serializer->start_embed (*this);
+ if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
+ out->format = format;
+- out->valueFormat[0] = valueFormat[0];
+- out->valueFormat[1] = valueFormat[1];
+- if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
++
++ hb_pair_t newFormats = hb_pair (valueFormat[0], valueFormat[1]);
++
++ if (c->plan->normalized_coords)
+ {
+- hb_pair_t newFormats = compute_effective_value_formats (glyphset);
+- out->valueFormat[0] = newFormats.first;
+- out->valueFormat[1] = newFormats.second;
++ /* all device flags will be dropped when full instancing, no need to strip
++ * hints, also do not strip emtpy cause we don't compute the new default
++ * value during stripping */
++ newFormats = compute_effective_value_formats (glyphset, false, false, &c->plan->layout_variation_idx_delta_map);
+ }
+-
+- if (c->plan->all_axes_pinned)
++ /* do not strip hints for VF */
++ else if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
+ {
+- out->valueFormat[0] = out->valueFormat[0].drop_device_table_flags ();
+- out->valueFormat[1] = out->valueFormat[1].drop_device_table_flags ();
++ hb_blob_t* blob = hb_face_reference_table (c->plan->source, HB_TAG ('f','v','a','r'));
++ bool has_fvar = (blob != hb_blob_get_empty ());
++ hb_blob_destroy (blob);
++
++ bool strip = !has_fvar;
++ /* special case: strip hints when a VF has no GDEF varstore after
++ * subsetting*/
++ if (has_fvar && !c->plan->has_gdef_varstore)
++ strip = true;
++ newFormats = compute_effective_value_formats (glyphset, strip, true);
+ }
+
++ out->valueFormat[0] = newFormats.first;
++ out->valueFormat[1] = newFormats.second;
++
+ hb_sorted_vector_t new_coverage;
+
+ + hb_zip (this+coverage, pairSet)
+@@ -175,7 +227,9 @@ struct PairPosFormat1_3
+ }
+
+
+- hb_pair_t compute_effective_value_formats (const hb_set_t& glyphset) const
++ hb_pair_t compute_effective_value_formats (const hb_set_t& glyphset,
++ bool strip_hints, bool strip_empty,
++ const hb_hashmap_t> *varidx_delta_map = nullptr) const
+ {
+ unsigned record_size = PairSet::get_size (valueFormat);
+
+@@ -195,8 +249,8 @@ struct PairPosFormat1_3
+ {
+ if (record->intersects (glyphset))
+ {
+- format1 = format1 | valueFormat[0].get_effective_format (record->get_values_1 ());
+- format2 = format2 | valueFormat[1].get_effective_format (record->get_values_2 (valueFormat[0]));
++ format1 = format1 | valueFormat[0].get_effective_format (record->get_values_1 (), strip_hints, strip_empty, &set, varidx_delta_map);
++ format2 = format2 | valueFormat[1].get_effective_format (record->get_values_2 (valueFormat[0]), strip_hints, strip_empty, &set, varidx_delta_map);
+ }
+ record = &StructAtOffset (record, record_size);
+ }
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat2.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat2.hh
+index ce6eec4f2..d85b1ac2c 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat2.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairPosFormat2.hh
+@@ -8,7 +8,7 @@ namespace Layout {
+ namespace GPOS_impl {
+
+ template
+-struct PairPosFormat2_4
++struct PairPosFormat2_4 : ValueBase
+ {
+ protected:
+ HBUINT16 format; /* Format identifier--format = 2 */
+@@ -123,12 +123,61 @@ struct PairPosFormat2_4
+
+ const Coverage &get_coverage () const { return this+coverage; }
+
+- bool apply (hb_ot_apply_context_t *c) const
++ struct pair_pos_cache_t
++ {
++ hb_ot_lookup_cache_t coverage;
++ hb_ot_lookup_cache_t first;
++ hb_ot_lookup_cache_t second;
++ };
++
++ unsigned cache_cost () const
++ {
++ return (this+coverage).cost () + (this+classDef1).cost () + (this+classDef2).cost ();
++ }
++ static void * cache_func (void *p, hb_ot_lookup_cache_op_t op)
++ {
++ switch (op)
++ {
++ case hb_ot_lookup_cache_op_t::CREATE:
++ {
++ pair_pos_cache_t *cache = (pair_pos_cache_t *) hb_malloc (sizeof (pair_pos_cache_t));
++ if (likely (cache))
++ {
++ cache->coverage.clear ();
++ cache->first.clear ();
++ cache->second.clear ();
++ }
++ return cache;
++ }
++ case hb_ot_lookup_cache_op_t::ENTER:
++ return (void *) true;
++ case hb_ot_lookup_cache_op_t::LEAVE:
++ return nullptr;
++ case hb_ot_lookup_cache_op_t::DESTROY:
++ {
++ pair_pos_cache_t *cache = (pair_pos_cache_t *) p;
++ hb_free (cache);
++ return nullptr;
++ }
++ }
++ return nullptr;
++ }
++
++ bool apply_cached (hb_ot_apply_context_t *c) const { return _apply (c, true); }
++ bool apply (hb_ot_apply_context_t *c) const { return _apply (c, false); }
++ bool _apply (hb_ot_apply_context_t *c, bool cached) const
+ {
+ TRACE_APPLY (this);
++
+ hb_buffer_t *buffer = c->buffer;
++
++#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
++ pair_pos_cache_t *cache = cached ? (pair_pos_cache_t *) c->lookup_accel->cache : nullptr;
++ unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint, cache ? &cache->coverage : nullptr);
++#else
+ unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
+- if (likely (index == NOT_COVERED)) return_trace (false);
++#endif
++ if (index == NOT_COVERED) return_trace (false);
+
+ hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
+ skippy_iter.reset_fast (buffer->idx);
+@@ -139,14 +188,13 @@ struct PairPosFormat2_4
+ return_trace (false);
+ }
+
+- unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint);
+- if (!klass2)
+- {
+- buffer->unsafe_to_concat (buffer->idx, skippy_iter.idx + 1);
+- return_trace (false);
+- }
+-
++#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
++ unsigned int klass1 = (this+classDef1).get_class (buffer->cur().codepoint, cache ? &cache->first : nullptr);
++ unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint, cache ? &cache->second : nullptr);
++#else
+ unsigned int klass1 = (this+classDef1).get_class (buffer->cur().codepoint);
++ unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint);
++#endif
+ if (unlikely (klass1 >= class1Count || klass2 >= class2Count))
+ {
+ buffer->unsafe_to_concat (buffer->idx, skippy_iter.idx + 1);
+@@ -287,18 +335,31 @@ struct PairPosFormat2_4
+ unsigned len2 = valueFormat2.get_len ();
+
+ hb_pair_t newFormats = hb_pair (valueFormat1, valueFormat2);
+- if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
+- newFormats = compute_effective_value_formats (klass1_map, klass2_map);
+-
+- out->valueFormat1 = newFormats.first;
+- out->valueFormat2 = newFormats.second;
+
+- if (c->plan->all_axes_pinned)
++ if (c->plan->normalized_coords)
+ {
+- out->valueFormat1 = out->valueFormat1.drop_device_table_flags ();
+- out->valueFormat2 = out->valueFormat2.drop_device_table_flags ();
++ /* in case of full instancing, all var device flags will be dropped so no
++ * need to strip hints here */
++ newFormats = compute_effective_value_formats (klass1_map, klass2_map, false, false, &c->plan->layout_variation_idx_delta_map);
++ }
++ /* do not strip hints for VF */
++ else if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
++ {
++ hb_blob_t* blob = hb_face_reference_table (c->plan->source, HB_TAG ('f','v','a','r'));
++ bool has_fvar = (blob != hb_blob_get_empty ());
++ hb_blob_destroy (blob);
++
++ bool strip = !has_fvar;
++ /* special case: strip hints when a VF has no GDEF varstore after
++ * subsetting*/
++ if (has_fvar && !c->plan->has_gdef_varstore)
++ strip = true;
++ newFormats = compute_effective_value_formats (klass1_map, klass2_map, strip, true);
+ }
+
++ out->valueFormat1 = newFormats.first;
++ out->valueFormat2 = newFormats.second;
++
+ unsigned total_len = len1 + len2;
+ hb_vector_t class2_idxs (+ hb_range ((unsigned) class2Count) | hb_filter (klass2_map));
+ for (unsigned class1_idx : + hb_range ((unsigned) class1Count) | hb_filter (klass1_map))
+@@ -311,22 +372,15 @@ struct PairPosFormat2_4
+ }
+ }
+
+- const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
+- const hb_map_t &glyph_map = *c->plan->glyph_map;
+-
+- auto it =
+- + hb_iter (this+coverage)
+- | hb_filter (glyphset)
+- | hb_map_retains_sorting (glyph_map)
+- ;
+-
+- out->coverage.serialize_serialize (c->serializer, it);
+- return_trace (out->class1Count && out->class2Count && bool (it));
++ bool ret = out->coverage.serialize_subset(c, coverage, this);
++ return_trace (out->class1Count && out->class2Count && ret);
+ }
+
+
+ hb_pair_t compute_effective_value_formats (const hb_map_t& klass1_map,
+- const hb_map_t& klass2_map) const
++ const hb_map_t& klass2_map,
++ bool strip_hints, bool strip_empty,
++ const hb_hashmap_t> *varidx_delta_map = nullptr) const
+ {
+ unsigned len1 = valueFormat1.get_len ();
+ unsigned len2 = valueFormat2.get_len ();
+@@ -340,8 +394,8 @@ struct PairPosFormat2_4
+ for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map))
+ {
+ unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * record_size;
+- format1 = format1 | valueFormat1.get_effective_format (&values[idx]);
+- format2 = format2 | valueFormat2.get_effective_format (&values[idx + len1]);
++ format1 = format1 | valueFormat1.get_effective_format (&values[idx], strip_hints, strip_empty, this, varidx_delta_map);
++ format2 = format2 | valueFormat2.get_effective_format (&values[idx + len1], strip_hints, strip_empty, this, varidx_delta_map);
+ }
+
+ if (format1 == valueFormat1 && format2 == valueFormat2)
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairSet.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairSet.hh
+index 7ccec1df8..e610fcd75 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairSet.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairSet.hh
+@@ -9,7 +9,7 @@ namespace GPOS_impl {
+
+
+ template
+-struct PairSet
++struct PairSet : ValueBase
+ {
+ template
+ friend struct PairPosFormat1_3;
+@@ -45,10 +45,12 @@ struct PairSet
+ bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) const
+ {
+ TRACE_SANITIZE (this);
+- if (!(c->check_struct (this)
+- && c->check_range (&firstPairValueRecord,
++ if (!(c->check_struct (this) &&
++ hb_barrier () &&
++ c->check_range (&firstPairValueRecord,
+ len,
+ closure->stride))) return_trace (false);
++ hb_barrier ();
+
+ unsigned int count = len;
+ const PairValueRecord *record = &firstPairValueRecord;
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairValueRecord.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairValueRecord.hh
+index b32abe46d..fe9595f12 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairValueRecord.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/PairValueRecord.hh
+@@ -29,7 +29,7 @@ struct PairValueRecord
+
+ struct context_t
+ {
+- const void *base;
++ const ValueBase *base;
+ const ValueFormat *valueFormats;
+ const ValueFormat *newFormats;
+ unsigned len1; /* valueFormats[0].get_len() */
+@@ -62,7 +62,7 @@ struct PairValueRecord
+
+ void collect_variation_indices (hb_collect_variation_indices_context_t *c,
+ const ValueFormat *valueFormats,
+- const void *base) const
++ const ValueBase *base) const
+ {
+ unsigned record1_len = valueFormats[0].get_len ();
+ unsigned record2_len = valueFormats[1].get_len ();
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePos.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePos.hh
+index 3af6c4996..a0243a218 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePos.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePos.hh
+@@ -39,14 +39,12 @@ struct SinglePos
+ const SrcLookup* src,
+ Iterator glyph_val_iter_pairs,
+ const hb_hashmap_t> *layout_variation_idx_delta_map,
+- bool all_axes_pinned)
++ unsigned newFormat)
+ {
+ if (unlikely (!c->extend_min (u.format))) return;
+ unsigned format = 2;
+- ValueFormat new_format = src->get_value_format ();
+-
+- if (all_axes_pinned)
+- new_format = new_format.drop_device_table_flags ();
++ ValueFormat new_format;
++ new_format = newFormat;
+
+ if (glyph_val_iter_pairs)
+ format = get_format (glyph_val_iter_pairs);
+@@ -89,8 +87,8 @@ SinglePos_serialize (hb_serialize_context_t *c,
+ const SrcLookup *src,
+ Iterator it,
+ const hb_hashmap_t> *layout_variation_idx_delta_map,
+- bool all_axes_pinned)
+-{ c->start_embed ()->serialize (c, src, it, layout_variation_idx_delta_map, all_axes_pinned); }
++ unsigned new_format)
++{ c->start_embed ()->serialize (c, src, it, layout_variation_idx_delta_map, new_format); }
+
+
+ }
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat1.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat1.hh
+index 8e21c5f8e..1a14be020 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat1.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat1.hh
+@@ -8,7 +8,7 @@ namespace OT {
+ namespace Layout {
+ namespace GPOS_impl {
+
+-struct SinglePosFormat1
++struct SinglePosFormat1 : ValueBase
+ {
+ protected:
+ HBUINT16 format; /* Format identifier--format = 1 */
+@@ -28,6 +28,7 @@ struct SinglePosFormat1
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ coverage.sanitize (c, this) &&
++ hb_barrier () &&
+ /* The coverage table may use a range to represent a set
+ * of glyphs, which means a small number of bytes can
+ * generate a large glyph set. Manually modify the
+@@ -66,7 +67,7 @@ struct SinglePosFormat1
+ TRACE_APPLY (this);
+ hb_buffer_t *buffer = c->buffer;
+ unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
+- if (likely (index == NOT_COVERED)) return_trace (false);
++ if (index == NOT_COVERED) return_trace (false);
+
+ if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ())
+ {
+@@ -146,6 +147,30 @@ struct SinglePosFormat1
+ hb_set_t intersection;
+ (this+coverage).intersect_set (glyphset, intersection);
+
++ unsigned new_format = valueFormat;
++
++ if (c->plan->normalized_coords)
++ {
++ new_format = valueFormat.get_effective_format (values.arrayZ, false, false, this, &c->plan->layout_variation_idx_delta_map);
++ }
++ /* do not strip hints for VF */
++ else if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
++ {
++ hb_blob_t* blob = hb_face_reference_table (c->plan->source, HB_TAG ('f','v','a','r'));
++ bool has_fvar = (blob != hb_blob_get_empty ());
++ hb_blob_destroy (blob);
++
++ bool strip = !has_fvar;
++ /* special case: strip hints when a VF has no GDEF varstore after
++ * subsetting*/
++ if (has_fvar && !c->plan->has_gdef_varstore)
++ strip = true;
++ new_format = valueFormat.get_effective_format (values.arrayZ,
++ strip, /* strip hints */
++ true, /* strip empty */
++ this, nullptr);
++ }
++
+ auto it =
+ + hb_iter (intersection)
+ | hb_map_retains_sorting (glyph_map)
+@@ -153,7 +178,7 @@ struct SinglePosFormat1
+ ;
+
+ bool ret = bool (it);
+- SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned);
++ SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, new_format);
+ return_trace (ret);
+ }
+ };
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat2.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat2.hh
+index ddc4c18ec..455796b4b 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat2.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/SinglePosFormat2.hh
+@@ -7,7 +7,7 @@ namespace OT {
+ namespace Layout {
+ namespace GPOS_impl {
+
+-struct SinglePosFormat2
++struct SinglePosFormat2 : ValueBase
+ {
+ protected:
+ HBUINT16 format; /* Format identifier--format = 2 */
+@@ -66,7 +66,7 @@ struct SinglePosFormat2
+ TRACE_APPLY (this);
+ hb_buffer_t *buffer = c->buffer;
+ unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
+- if (likely (index == NOT_COVERED)) return_trace (false);
++ if (index == NOT_COVERED) return_trace (false);
+
+ if (unlikely (index >= valueCount)) return_trace (false);
+
+@@ -143,6 +143,37 @@ struct SinglePosFormat2
+ coverage.serialize_serialize (c, glyphs);
+ }
+
++ template
++ unsigned compute_effective_format (const hb_face_t *face,
++ Iterator it,
++ bool is_instancing, bool strip_hints,
++ bool has_gdef_varstore,
++ const hb_hashmap_t> *varidx_delta_map) const
++ {
++ hb_blob_t* blob = hb_face_reference_table (face, HB_TAG ('f','v','a','r'));
++ bool has_fvar = (blob != hb_blob_get_empty ());
++ hb_blob_destroy (blob);
++
++ unsigned new_format = 0;
++ if (is_instancing)
++ {
++ new_format = new_format | valueFormat.get_effective_format (+ it | hb_map (hb_second), false, false, this, varidx_delta_map);
++ }
++ /* do not strip hints for VF */
++ else if (strip_hints)
++ {
++ bool strip = !has_fvar;
++ if (has_fvar && !has_gdef_varstore)
++ strip = true;
++ new_format = new_format | valueFormat.get_effective_format (+ it | hb_map (hb_second), strip, true, this, nullptr);
++ }
++ else
++ new_format = valueFormat;
++
++ return new_format;
++ }
++
+ bool subset (hb_subset_context_t *c) const
+ {
+ TRACE_SUBSET (this);
+@@ -163,8 +194,13 @@ struct SinglePosFormat2
+ })
+ ;
+
++ unsigned new_format = compute_effective_format (c->plan->source, it,
++ bool (c->plan->normalized_coords),
++ bool (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING),
++ c->plan->has_gdef_varstore,
++ &c->plan->layout_variation_idx_delta_map);
+ bool ret = bool (it);
+- SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned);
++ SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, new_format);
+ return_trace (ret);
+ }
+ };
+diff --git a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/ValueFormat.hh b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/ValueFormat.hh
+index 8618cddad..731d1ffca 100644
+--- a/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/ValueFormat.hh
++++ b/src/java.desktop/share/native/libharfbuzz/OT/Layout/GPOS/ValueFormat.hh
+@@ -9,6 +9,8 @@ namespace GPOS_impl {
+
+ typedef HBUINT16 Value;
+
++struct ValueBase {}; // Dummy base class tag for OffsetTo bases.
++
+ typedef UnsizedArrayOf ValueRecord;
+
+ struct ValueFormat : HBUINT16
+@@ -78,7 +80,7 @@ struct ValueFormat : HBUINT16
+ }
+
+ bool apply_value (hb_ot_apply_context_t *c,
+- const void *base,
++ const ValueBase *base,
+ const Value *values,
+ hb_glyph_position_t &glyph_pos) const
+ {
+@@ -114,7 +116,7 @@ struct ValueFormat : HBUINT16
+
+ if (!use_x_device && !use_y_device) return ret;
+
+- const VariationStore &store = c->var_store;
++ const ItemVariationStore &store = c->var_store;
+ auto *cache = c->var_store_cache;
+
+ /* pixel -> fractional pixel */
+@@ -142,11 +144,29 @@ struct ValueFormat : HBUINT16
+ return ret;
+ }
+
+- unsigned int get_effective_format (const Value *values) const
++ unsigned int get_effective_format (const Value *values, bool strip_hints, bool strip_empty, const ValueBase *base,
++ const hb_hashmap_t> *varidx_delta_map) const
+ {
+ unsigned int format = *this;
+ for (unsigned flag = xPlacement; flag <= yAdvDevice; flag = flag << 1) {
+- if (format & flag) should_drop (*values++, (Flags) flag, &format);
++ if (format & flag)
++ {
++ if (strip_hints && flag >= xPlaDevice)
++ {
++ format = format & ~flag;
++ values++;
++ continue;
++ }
++ if (varidx_delta_map && flag >= xPlaDevice)
++ {
++ update_var_flag (values++, (Flags) flag, &format, base, varidx_delta_map);
++ continue;
++ }
++ /* do not strip empty when instancing, cause we don't know whether the new
++ * default value is 0 or not */
++ if (strip_empty) should_drop (*values, (Flags) flag, &format);
++ values++;
++ }
+ }
+
+ return format;
+@@ -154,18 +174,19 @@ struct ValueFormat : HBUINT16
+
+ template
+- unsigned int get_effective_format (Iterator it) const {
++ unsigned int get_effective_format (Iterator it, bool strip_hints, bool strip_empty, const ValueBase *base,
++ const hb_hashmap_t> *varidx_delta_map) const {
+ unsigned int new_format = 0;
+
+ for (const hb_array_t& values : it)
+- new_format = new_format | get_effective_format (&values);
++ new_format = new_format | get_effective_format (&values, strip_hints, strip_empty, base, varidx_delta_map);
+
+ return new_format;
+ }
+
+ void copy_values (hb_serialize_context_t *c,
+ unsigned int new_format,
+- const void *base,
++ const ValueBase *base,
+ const Value *values,
+ const hb_hashmap_t> *layout_variation_idx_delta_map) const
+ {
+@@ -217,7 +238,7 @@ struct ValueFormat : HBUINT16
+ }
+
+ void collect_variation_indices (hb_collect_variation_indices_context_t *c,
+- const void *base,
++ const ValueBase *base,
+ const hb_array_t& values) const
+ {
+ unsigned format = *this;
+@@ -251,17 +272,8 @@ struct ValueFormat : HBUINT16
+ }
+ }
+
+- unsigned drop_device_table_flags () const
+- {
+- unsigned format = *this;
+- for (unsigned flag = xPlaDevice; flag <= yAdvDevice; flag = flag << 1)
+- format = format & ~flag;
+-
+- return format;
+- }
+-
+ private:
+- bool sanitize_value_devices (hb_sanitize_context_t *c, const void *base, const Value *values) const
++ bool sanitize_value_devices (hb_sanitize_context_t *c, const ValueBase *base, const Value *values) const
+ {
+ unsigned int format = *this;
+
+@@ -278,17 +290,17 @@ struct ValueFormat : HBUINT16
+ return true;
+ }
+
+- static inline Offset16To& get_device (Value* value)
++ static inline Offset16To& get_device (Value* value)
+ {
+- return *static_cast