Debug 64bit Build:
diff --git a/doc/building.md b/doc/building.md
index 460e4d12668..6de7df5e396 100644
--- a/doc/building.md
+++ b/doc/building.md
@@ -405,8 +405,8 @@ happens, read more below in [the `configure` options](#configureoptions).
Some examples:
-> **Windows 32bit build with freetype specified:** \
-> `bash ./configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32`
+> **Windows 32bit build with msvcr-dll specified:** \
+> `bash ./configure --with-msvcr-dll=/cygdrive/c/msvcr100.dll --with-target-bits=32`
> **Debug 64bit Build:** \
> `bash ./configure --enable-debug --with-target-bits=64`
diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make
index 65b31149756..0e2ca9b3b80 100644
--- a/hotspot/make/bsd/makefiles/gcc.make
+++ b/hotspot/make/bsd/makefiles/gcc.make
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2025, 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
@@ -343,7 +343,7 @@ ifeq ($(OS_VENDOR), Darwin)
# if built on a newer version of the OS.
# The expected format is X.Y.Z
ifeq ($(MACOSX_VERSION_MIN),)
- MACOSX_VERSION_MIN=10.7.0
+ MACOSX_VERSION_MIN=11.00.00
endif
# The macro takes the version with no dots, ex: 1070
CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
diff --git a/hotspot/make/windows/makefiles/compile.make b/hotspot/make/windows/makefiles/compile.make
index 26c215f8d06..797fef435fa 100644
--- a/hotspot/make/windows/makefiles/compile.make
+++ b/hotspot/make/windows/makefiles/compile.make
@@ -172,7 +172,7 @@ COMPILER_NAME=VS2017
!if "$(MSC_VER)" >= "1920" && "$(MSC_VER)" <= "1929"
COMPILER_NAME=VS2019
!endif
-!if "$(MSC_VER)" >= "1930" && "$(MSC_VER)" <= "1938"
+!if "$(MSC_VER)" >= "1930" && "$(MSC_VER)" <= "1944"
COMPILER_NAME=VS2022
!endif
!endif
diff --git a/hotspot/make/windows/makefiles/sanity.make b/hotspot/make/windows/makefiles/sanity.make
index 4e75bf7ce44..59c4fa98fe7 100644
--- a/hotspot/make/windows/makefiles/sanity.make
+++ b/hotspot/make/windows/makefiles/sanity.make
@@ -34,7 +34,8 @@ checkCL:
if "$(MSC_VER)" NEQ "1920" if "$(MSC_VER)" NEQ "1921" if "$(MSC_VER)" NEQ "1922" if "$(MSC_VER)" NEQ "1923" if "$(MSC_VER)" NEQ "1924" \
if "$(MSC_VER)" NEQ "1925" if "$(MSC_VER)" NEQ "1926" if "$(MSC_VER)" NEQ "1927" if "$(MSC_VER)" NEQ "1928" if "$(MSC_VER)" NEQ "1929" \
if "$(MSC_VER)" NEQ "1930" if "$(MSC_VER)" NEQ "1931" if "$(MSC_VER)" NEQ "1932" if "$(MSC_VER)" NEQ "1933" if "$(MSC_VER)" NEQ "1934" \
- if "$(MSC_VER)" NEQ "1935" if "$(MSC_VER)" NEQ "1936" if "$(MSC_VER)" NEQ "1937" if "$(MSC_VER)" NEQ "1938" \
+ if "$(MSC_VER)" NEQ "1935" if "$(MSC_VER)" NEQ "1936" if "$(MSC_VER)" NEQ "1937" if "$(MSC_VER)" NEQ "1938" if "$(MSC_VER)" NEQ "1939" \
+ if "$(MSC_VER)" NEQ "1940" if "$(MSC_VER)" NEQ "1941" if "$(MSC_VER)" NEQ "1942" if "$(MSC_VER)" NEQ "1943" if "$(MSC_VER)" NEQ "1944" \
echo *** WARNING *** unrecognized cl.exe version $(MSC_VER) ($(RAW_MSC_VER)). Use FORCE_MSC_VER to override automatic detection.
checkLink:
@@ -46,5 +47,6 @@ checkLink:
if "$(LD_VER)" NEQ "1420" if "$(LD_VER)" NEQ "1421" if "$(LD_VER)" NEQ "1422" if "$(LD_VER)" NEQ "1423" if "$(LD_VER)" NEQ "1424" \
if "$(LD_VER)" NEQ "1425" if "$(LD_VER)" NEQ "1426" if "$(LD_VER)" NEQ "1427" if "$(LD_VER)" NEQ "1428" if "$(LD_VER)" NEQ "1429" \
if "$(LD_VER)" NEQ "1430" if "$(LD_VER)" NEQ "1431" if "$(LD_VER)" NEQ "1432" if "$(LD_VER)" NEQ "1433" if "$(LD_VER)" NEQ "1434" \
- if "$(LD_VER)" NEQ "1435" if "$(LD_VER)" NEQ "1436" if "$(LD_VER)" NEQ "1437" if "$(LD_VER)" NEQ "1438" \
+ if "$(LD_VER)" NEQ "1435" if "$(LD_VER)" NEQ "1436" if "$(LD_VER)" NEQ "1437" if "$(LD_VER)" NEQ "1438" if "$(LD_VER)" NEQ "1439" \
+ if "$(LD_VER)" NEQ "1440" if "$(LD_VER)" NEQ "1441" if "$(LD_VER)" NEQ "1442" if "$(LD_VER)" NEQ "1443" if "$(LD_VER)" NEQ "1444" \
echo *** WARNING *** unrecognized link.exe version $(LD_VER) ($(RAW_LD_VER)). Use FORCE_LD_VER to override automatic detection.
diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
index d775a61b5d3..0cfc5d5e410 100644
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
@@ -1707,7 +1707,7 @@ class StubGenerator: public StubCodeGenerator {
// Helper for generating a dynamic type check.
- // Smashes rscratch1.
+ // Smashes rscratch1, rscratch2.
void generate_type_check(Register sub_klass,
Register super_check_offset,
Register super_klass,
@@ -2137,6 +2137,10 @@ class StubGenerator: public StubCodeGenerator {
const Register dst_pos = c_rarg3; // destination position
const Register length = c_rarg4;
+
+ // Registers used as temps
+ const Register dst_klass = c_rarg5;
+
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", name);
@@ -2342,8 +2346,7 @@ class StubGenerator: public StubCodeGenerator {
arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length,
r18, L_failed);
- const Register rscratch2_dst_klass = rscratch2;
- __ load_klass(rscratch2_dst_klass, dst); // reload
+ __ load_klass(dst_klass, dst); // reload
// Marshal the base address arguments now, freeing registers.
__ lea(from, Address(src, src_pos, Address::lsl(LogBytesPerHeapOop)));
@@ -2353,24 +2356,25 @@ class StubGenerator: public StubCodeGenerator {
__ movw(count, length); // length (reloaded)
Register sco_temp = c_rarg3; // this register is free now
assert_different_registers(from, to, count, sco_temp,
- rscratch2_dst_klass, scratch_src_klass);
+ dst_klass, scratch_src_klass);
// assert_clean_int(count, sco_temp);
// Generate the type check.
const int sco_offset = in_bytes(Klass::super_check_offset_offset());
- __ ldrw(sco_temp, Address(rscratch2_dst_klass, sco_offset));
- // assert_clean_int(sco_temp, r18);
- generate_type_check(scratch_src_klass, sco_temp, rscratch2_dst_klass, L_plain_copy);
+ __ ldrw(sco_temp, Address(dst_klass, sco_offset));
+
+ // Smashes rscratch1, rscratch2
+ generate_type_check(scratch_src_klass, sco_temp, dst_klass, L_plain_copy);
// Fetch destination element klass from the ObjArrayKlass header.
int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
- __ ldr(rscratch2_dst_klass, Address(rscratch2_dst_klass, ek_offset));
- __ ldrw(sco_temp, Address(rscratch2_dst_klass, sco_offset));
+ __ ldr(dst_klass, Address(dst_klass, ek_offset));
+ __ ldrw(sco_temp, Address(dst_klass, sco_offset));
// the checkcast_copy loop needs two extra arguments:
assert(c_rarg3 == sco_temp, "#3 already in place");
// Set up arguments for checkcast_copy_entry.
- __ mov(c_rarg4, rscratch2_dst_klass); // dst.klass.element_klass
+ __ mov(c_rarg4, dst_klass); // dst.klass.element_klass
__ b(RuntimeAddress(checkcast_copy_entry));
}
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index bc6f41771dc..04b6bb755fd 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -359,16 +359,23 @@ void os::init_system_properties_values() {
// Important note: if the location of libjvm.so changes this
// code needs to be changed accordingly.
-// See ld(1):
-// The linker uses the following search paths to locate required
-// shared libraries:
-// 1: ...
-// ...
-// 7: The default directories, normally /lib and /usr/lib.
+ // See ld(1):
+ // The linker uses the following search paths to locate required
+ // shared libraries:
+ // 1: ...
+ // ...
+ // 7: The default directories, normally /lib and /usr/lib.
#if defined(AMD64) || defined(_LP64) && (defined(SPARC) || defined(PPC) || defined(S390))
-#define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
+ #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
#else
-#define DEFAULT_LIBPATH "/lib:/usr/lib"
+#if defined(AARCH64)
+ // Use 32-bit locations first for AARCH64 (a 64-bit architecture), since some systems
+ // might not adhere to the FHS and it would be a change in behaviour if we used
+ // DEFAULT_LIBPATH of other 64-bit architectures which prefer the 64-bit paths.
+ #define DEFAULT_LIBPATH "/lib:/usr/lib:/usr/lib64:/lib64"
+#else
+ #define DEFAULT_LIBPATH "/lib:/usr/lib"
+#endif // AARCH64
#endif
// Base path of extensions installed on the system.
diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp
index 4662bf02a5d..2611138ace1 100644
--- a/hotspot/src/share/vm/classfile/verifier.cpp
+++ b/hotspot/src/share/vm/classfile/verifier.cpp
@@ -2265,216 +2265,6 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
}
}
-// Look at the method's handlers. If the bci is in the handler's try block
-// then check if the handler_pc is already on the stack. If not, push it
-// unless the handler has already been scanned.
-void ClassVerifier::push_handlers(ExceptionTable* exhandlers,
- GrowableArray* handler_list,
- GrowableArray* handler_stack,
- u4 bci) {
- int exlength = exhandlers->length();
- for(int x = 0; x < exlength; x++) {
- if (bci >= exhandlers->start_pc(x) && bci < exhandlers->end_pc(x)) {
- u4 exhandler_pc = exhandlers->handler_pc(x);
- if (!handler_list->contains(exhandler_pc)) {
- handler_stack->append_if_missing(exhandler_pc);
- handler_list->append(exhandler_pc);
- }
- }
- }
-}
-
-// Return TRUE if all code paths starting with start_bc_offset end in
-// bytecode athrow or loop.
-bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) {
- ResourceMark rm;
- // Create bytecode stream.
- RawBytecodeStream bcs(method());
- u4 code_length = method()->code_size();
- bcs.set_start(start_bc_offset);
- u4 target;
- // Create stack for storing bytecode start offsets for if* and *switch.
- GrowableArray* bci_stack = new GrowableArray(30);
- // Create stack for handlers for try blocks containing this handler.
- GrowableArray* handler_stack = new GrowableArray(30);
- // Create list of handlers that have been pushed onto the handler_stack
- // so that handlers embedded inside of their own TRY blocks only get
- // scanned once.
- GrowableArray* handler_list = new GrowableArray(30);
- // Create list of visited branch opcodes (goto* and if*).
- GrowableArray* visited_branches = new GrowableArray(30);
- ExceptionTable exhandlers(_method());
-
- while (true) {
- if (bcs.is_last_bytecode()) {
- // if no more starting offsets to parse or if at the end of the
- // method then return false.
- if ((bci_stack->is_empty()) || ((u4)bcs.end_bci() == code_length))
- return false;
- // Pop a bytecode starting offset and scan from there.
- bcs.set_start(bci_stack->pop());
- }
- Bytecodes::Code opcode = bcs.raw_next();
- u4 bci = bcs.bci();
-
- // If the bytecode is in a TRY block, push its handlers so they
- // will get parsed.
- push_handlers(&exhandlers, handler_list, handler_stack, bci);
-
- switch (opcode) {
- case Bytecodes::_if_icmpeq:
- case Bytecodes::_if_icmpne:
- case Bytecodes::_if_icmplt:
- case Bytecodes::_if_icmpge:
- case Bytecodes::_if_icmpgt:
- case Bytecodes::_if_icmple:
- case Bytecodes::_ifeq:
- case Bytecodes::_ifne:
- case Bytecodes::_iflt:
- case Bytecodes::_ifge:
- case Bytecodes::_ifgt:
- case Bytecodes::_ifle:
- case Bytecodes::_if_acmpeq:
- case Bytecodes::_if_acmpne:
- case Bytecodes::_ifnull:
- case Bytecodes::_ifnonnull:
- target = bcs.dest();
- if (visited_branches->contains(bci)) {
- if (bci_stack->is_empty()) {
- if (handler_stack->is_empty()) {
- return true;
- } else {
- // Parse the catch handlers for try blocks containing athrow.
- bcs.set_start(handler_stack->pop());
- }
- } else {
- // Pop a bytecode starting offset and scan from there.
- bcs.set_start(bci_stack->pop());
- }
- } else {
- if (target > bci) { // forward branch
- if (target >= code_length) return false;
- // Push the branch target onto the stack.
- bci_stack->push(target);
- // then, scan bytecodes starting with next.
- bcs.set_start(bcs.next_bci());
- } else { // backward branch
- // Push bytecode offset following backward branch onto the stack.
- bci_stack->push(bcs.next_bci());
- // Check bytecodes starting with branch target.
- bcs.set_start(target);
- }
- // Record target so we don't branch here again.
- visited_branches->append(bci);
- }
- break;
-
- case Bytecodes::_goto:
- case Bytecodes::_goto_w: {
- int offset = (opcode == Bytecodes::_goto ? bcs.get_offset_s2() : bcs.get_offset_s4());
- int min_offset = -1 * max_method_code_size;
- // Check offset for overflow
- if (offset < min_offset || offset > max_method_code_size) return false;
-
- target = bci + offset;
- if (visited_branches->contains(bci)) {
- if (bci_stack->is_empty()) {
- if (handler_stack->is_empty()) {
- return true;
- } else {
- // Parse the catch handlers for try blocks containing athrow.
- bcs.set_start(handler_stack->pop());
- }
- } else {
- // Been here before, pop new starting offset from stack.
- bcs.set_start(bci_stack->pop());
- }
- } else {
- if (target >= code_length) return false;
- // Continue scanning from the target onward.
- bcs.set_start(target);
- // Record target so we don't branch here again.
- visited_branches->append(bci);
- }
- break;
- }
-
- // Check that all switch alternatives end in 'athrow' bytecodes. Since it
- // is difficult to determine where each switch alternative ends, parse
- // each switch alternative until either hit a 'return', 'athrow', or reach
- // the end of the method's bytecodes. This is gross but should be okay
- // because:
- // 1. tableswitch and lookupswitch byte codes in handlers for ctor explicit
- // constructor invocations should be rare.
- // 2. if each switch alternative ends in an athrow then the parsing should be
- // short. If there is no athrow then it is bogus code, anyway.
- case Bytecodes::_lookupswitch:
- case Bytecodes::_tableswitch:
- {
- address aligned_bcp = (address) round_to((intptr_t)(bcs.bcp() + 1), jintSize);
- u4 default_offset = Bytes::get_Java_u4(aligned_bcp) + bci;
- int keys, delta;
- if (opcode == Bytecodes::_tableswitch) {
- jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
- jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
- // This is invalid, but let the regular bytecode verifier
- // report this because the user will get a better error message.
- if (low > high) return true;
- keys = high - low + 1;
- delta = 1;
- } else {
- keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize);
- delta = 2;
- }
- // Invalid, let the regular bytecode verifier deal with it.
- if (keys < 0) return true;
-
- // Push the offset of the next bytecode onto the stack.
- bci_stack->push(bcs.next_bci());
-
- // Push the switch alternatives onto the stack.
- for (int i = 0; i < keys; i++) {
- int min_offset = -1 * max_method_code_size;
- int offset = (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
- if (offset < min_offset || offset > max_method_code_size) return false;
- u4 target = bci + offset;
- if (target > code_length) return false;
- bci_stack->push(target);
- }
-
- // Start bytecode parsing for the switch at the default alternative.
- if (default_offset > code_length) return false;
- bcs.set_start(default_offset);
- break;
- }
-
- case Bytecodes::_return:
- return false;
-
- case Bytecodes::_athrow:
- {
- if (bci_stack->is_empty()) {
- if (handler_stack->is_empty()) {
- return true;
- } else {
- // Parse the catch handlers for try blocks containing athrow.
- bcs.set_start(handler_stack->pop());
- }
- } else {
- // Pop a bytecode offset and starting scanning from there.
- bcs.set_start(bci_stack->pop());
- }
- }
- break;
-
- default:
- ;
- } // end switch
- } // end while loop
-
- return false;
-}
-
void ClassVerifier::verify_invoke_init(
RawBytecodeStream* bcs, u2 ref_class_index, VerificationType ref_class_type,
StackMapFrame* current_frame, u4 code_length, bool in_try_block,
@@ -2499,26 +2289,6 @@ void ClassVerifier::verify_invoke_init(
// sure that all catch clause paths end in a throw. Otherwise, this can
// result in returning an incomplete object.
if (in_try_block) {
- ExceptionTable exhandlers(_method());
- int exlength = exhandlers.length();
- for(int i = 0; i < exlength; i++) {
- u2 start_pc = exhandlers.start_pc(i);
- u2 end_pc = exhandlers.end_pc(i);
-
- if (bci >= start_pc && bci < end_pc) {
- if (!ends_in_athrow(exhandlers.handler_pc(i))) {
- verify_error(ErrorContext::bad_code(bci),
- "Bad method call from after the start of a try block");
- return;
- } else if (VerboseVerification) {
- ResourceMark rm;
- tty->print_cr(
- "Survived call to ends_in_athrow(): %s",
- current_class()->name()->as_C_string());
- }
- }
- }
-
// Check the exception handler target stackmaps with the locals from the
// incoming stackmap (before initialize_object() changes them to outgoing
// state).
diff --git a/hotspot/src/share/vm/classfile/verifier.hpp b/hotspot/src/share/vm/classfile/verifier.hpp
index ff41232fa78..e44d9ca1c50 100644
--- a/hotspot/src/share/vm/classfile/verifier.hpp
+++ b/hotspot/src/share/vm/classfile/verifier.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2025, 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
@@ -305,17 +305,6 @@ class ClassVerifier : public StackObj {
bool* this_uninit, constantPoolHandle cp, StackMapTable* stackmap_table,
TRAPS);
- // Used by ends_in_athrow() to push all handlers that contain bci onto the
- // handler_stack, if the handler has not already been pushed on the stack.
- void push_handlers(ExceptionTable* exhandlers,
- GrowableArray* handler_list,
- GrowableArray* handler_stack,
- u4 bci);
-
- // Returns true if all paths starting with start_bc_offset end in athrow
- // bytecode or loop.
- bool ends_in_athrow(u4 start_bc_offset);
-
void verify_invoke_instructions(
RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame,
bool in_try_block, bool* this_uninit, VerificationType return_type,
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
index 75a9a5f9529..af2026e1672 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2025, 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
@@ -34,13 +34,17 @@
class LineBuffer: public StackObj {
private:
- static const int BUFFER_LEN = 1024;
+ static const int BUFFER_LEN = 1024*3;
static const int INDENT_CHARS = 3;
char _buffer[BUFFER_LEN];
int _indent_level;
int _cur;
void vappend(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0) {
+ if (_cur >= BUFFER_LEN) {
+ DEBUG_ONLY(warning("previous LineBuffer overflow, request ignored");)
+ return;
+ }
int res = os::vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
if (res > BUFFER_LEN) {
DEBUG_ONLY(warning("buffer too small in LineBuffer");)
diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp
index 3f644102d32..2947c1082d3 100644
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp
@@ -1890,13 +1890,17 @@ void JvmtiExport::post_dynamic_code_generated_while_holding_locks(const char* na
address code_begin, address code_end)
{
// register the stub with the current dynamic code event collector
- JvmtiThreadState* state = JvmtiThreadState::state_for(JavaThread::current());
- // state can only be NULL if the current thread is exiting which
- // should not happen since we're trying to post an event
- guarantee(state != NULL, "attempt to register stub via an exiting thread");
- JvmtiDynamicCodeEventCollector* collector = state->get_dynamic_code_event_collector();
- guarantee(collector != NULL, "attempt to register stub without event collector");
- collector->register_stub(name, code_begin, code_end);
+ // Cannot take safepoint here so do not use state_for to get
+ // jvmti thread state.
+ // The collector and/or state might be NULL if JvmtiDynamicCodeEventCollector
+ // has been initialized while JVMTI_EVENT_DYNAMIC_CODE_GENERATED was disabled.
+ JvmtiThreadState* state = JavaThread::current()->jvmti_thread_state();
+ if (state != NULL) {
+ JvmtiDynamicCodeEventCollector *collector = state->get_dynamic_code_event_collector();
+ if (collector != NULL) {
+ collector->register_stub(name, code_begin, code_end);
+ }
+ }
}
// Collect all the vm internally allocated objects which are visible to java world
diff --git a/hotspot/test/compiler/unsafe/TestMisalignedUnsafeAccess.java b/hotspot/test/compiler/unsafe/TestMisalignedUnsafeAccess.java
index f04da65193a..a867a6a4048 100644
--- a/hotspot/test/compiler/unsafe/TestMisalignedUnsafeAccess.java
+++ b/hotspot/test/compiler/unsafe/TestMisalignedUnsafeAccess.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
+ * Copyright (C) 2020, Tencent. 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
diff --git a/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGenerated.java b/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGenerated.java
new file mode 100644
index 00000000000..a5a970ea121
--- /dev/null
+++ b/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGenerated.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2021, 2025, 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
+ * 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.
+ */
+
+public class DynamicCodeGenerated {
+ static {
+ System.loadLibrary("DynamicCodeGenerated");
+ }
+ public static native void changeEventNotificationMode();
+
+ public static void main(String[] args) {
+ // Try to enable DynamicCodeGenerated event while it is posted
+ // using JvmtiDynamicCodeEventCollector from VtableStubs::find_stub
+ Thread t = new Thread(() -> {
+ changeEventNotificationMode();
+ });
+ t.setDaemon(true);
+ t.start();
+
+ for (int i = 0; i < 2000; i++) {
+ new Thread(() -> {
+ String result = "string" + System.currentTimeMillis();
+
+ // Keep a reference to result
+ if (result.hashCode() == System.currentTimeMillis()) {
+ // Shouldn't happen
+ return;
+ }
+ }).start();
+ }
+ }
+}
diff --git a/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.sh b/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.sh
new file mode 100644
index 00000000000..4017d3e7044
--- /dev/null
+++ b/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+# Copyright (c) 2012, 2025, 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
+# 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.
+
+# @test DynamicCodeGeneratedTest.sh
+# @bug 8212155
+# @summary Test concurrent enabling and posting of DynamicCodeGenerated events.
+# @run shell DynamicCodeGeneratedTest.sh
+
+if [ "$TESTSRC" = "" ]
+then TESTSRC=.
+fi
+
+if [ "$TESTJAVA" = "" ]
+then
+ PARENT=$(dirname $(which java))
+ TESTJAVA=$(dirname $PARENT)
+ echo "TESTJAVA not set, selecting " $TESTJAVA
+ echo "If this is incorrect, try setting the variable manually."
+fi
+
+# set platform-dependent variables
+OS=$(uname -s)
+case "$OS" in
+ Linux )
+ ARCHFLAG=
+ $TESTJAVA/bin/java -version 2>&1 | grep '64-Bit' > /dev/null
+ if [ $? -eq '0' ]
+ then
+ ARCH="amd64"
+ else
+ ARCH="i386"
+ ARCHFLAG="-m32 -march=i386"
+ fi
+ ;;
+ * )
+ echo "Test passed, unrecognized system."
+ exit 0;
+ ;;
+esac
+
+echo "OS-ARCH is" linux-$ARCH
+$TESTJAVA/jre/bin/java -fullversion 2>&1
+
+which gcc >/dev/null 2>&1
+if [ "$?" -ne '0' ]
+then
+ echo "No C compiler found. Test passed."
+ exit 0
+fi
+
+JAVA=$TESTJAVA/jre/bin/java
+JAVAC=$TESTJAVA/bin/javac
+JAVAH=$TESTJAVA/bin/javah
+
+$JAVAC -d . $TESTSRC/DynamicCodeGenerated.java
+$JAVAH -jni -classpath . -d . DynamicCodeGenerated
+
+gcc --shared $ARCHFLAG -fPIC -O -I$TESTJAVA/include -I$TESTJAVA/include/linux -I. -o libDynamicCodeGenerated.so $TESTSRC/libDynamicCodeGenerated.cpp
+
+LD_LIBRARY_PATH=. $JAVA -classpath . -agentlib:DynamicCodeGenerated DynamicCodeGenerated
+
+exit $?
diff --git a/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp b/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp
new file mode 100644
index 00000000000..7cef753c02c
--- /dev/null
+++ b/hotspot/test/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2021, 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
+ * 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.
+ */
+
+#include
+#include
+
+static jvmtiEnv* jvmti = NULL;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT
+void JNICALL Java_DynamicCodeGenerated_changeEventNotificationMode(JNIEnv* jni, jclass cls) {
+ while (true) {
+ jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL);
+ jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL);
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+void JNICALL DynamicCodeGenerated(jvmtiEnv* jvmti, const char* name, const void* address, jint length) {
+
+}
+
+jint Agent_OnLoad(JavaVM* vm, char* options, void* reserved) {
+ vm->GetEnv((void**)&jvmti, JVMTI_VERSION_1_0);
+ jvmtiEventCallbacks callbacks;
+ memset(&callbacks, 0, sizeof(callbacks));
+ callbacks.DynamicCodeGenerated = DynamicCodeGenerated;
+ jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
+
+ return 0;
+}
diff --git a/jdk/make/CopyFiles.gmk b/jdk/make/CopyFiles.gmk
index b6dfeb646f6..ba637fd2155 100644
--- a/jdk/make/CopyFiles.gmk
+++ b/jdk/make/CopyFiles.gmk
@@ -212,41 +212,6 @@ COPY_FILES += $(ICCPROFILE_TARGET_FILES)
##########################################################################################
-ifneq ($(FREETYPE_BUNDLE_LIB_PATH), )
- # We need to bundle the freetype library, so it will be available at runtime as well as link time.
- #
- # NB: Default freetype build system uses -h linker option and
- # result .so contains hardcoded library name that is later
- # used for adding dependencies to other objects
- # (e.g. libfontmanager.so).
- #
- # It is not obvious how to extract that hardcoded name (libfreetype.so.6)
- # without overcomplicating logic here.
- # To workaround this we hardcode .6 suffix for now.
- #
- # Note that .so.6 library will not be found by System.loadLibrary()
- # but fortunately we need to load FreeType library explicitly
- # on windows only
- #
- #TODO: rework this to avoid hardcoding library name in the makefile
- #
- ifeq ($(OPENJDK_TARGET_OS), windows)
- FREETYPE_TARGET_LIB = $(JDK_OUTPUTDIR)/bin/$(call SHARED_LIBRARY,freetype)
- else
- FREETYPE_TARGET_LIB = $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/$(call SHARED_LIBRARY,freetype).6
- endif
-
- $(FREETYPE_TARGET_LIB): $(FREETYPE_BUNDLE_LIB_PATH)/$(call SHARED_LIBRARY,freetype)
- $(CP) $(FREETYPE_BUNDLE_LIB_PATH)/$(call SHARED_LIBRARY,freetype) $@
- ifeq ($(OPENJDK_BUILD_OS), windows)
- $(CHMOD) +rx $@
- endif
-
- COPY_FILES += $(FREETYPE_TARGET_LIB)
-endif
-
-##########################################################################################
-
# Copy the microsoft runtime libraries on windows
ifeq ($(OPENJDK_TARGET_OS), windows)
diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk
index 3658faab4da..4e56db3514b 100644
--- a/jdk/make/lib/Awt2dLibraries.gmk
+++ b/jdk/make/lib/Awt2dLibraries.gmk
@@ -890,6 +890,51 @@ endif
##########################################################################################
+ifeq ($(FREETYPE_TO_USE), system)
+ # For use by libfontmanager:
+ LIBFREETYPE_CFLAGS := $(FREETYPE_CFLAGS)
+ LIBFREETYPE_LIBS := $(FREETYPE_LIBS)
+else
+ LIBFREETYPE_SRC := $(TOPDIR)/jdk/src/share/native/sun/awt/libfreetype
+ BUILD_LIBFREETYPE_HEADER_DIRS := $(LIBFREETYPE_SRC)/include
+
+# BUILD_LIBFREETYPE_HEADERS := $(addprefix -I, $(BUILD_LIBFREETYPE_HEADER_DIRS))
+
+ # For use by libfontmanager:
+ LIBFREETYPE_CFLAGS := -I$(LIBFREETYPE_SRC)/include
+ ifeq ($(OPENJDK_TARGET_OS), windows)
+ LIBFREETYPE_LIBS := $(JDK_OUTPUTDIR)/objs/libfreetype/freetype.lib
+ # freetype now requires you to manually define this (see ftconfig.h)
+ BUILD_LIBFREETYPE_CFLAGS += -DDLL_EXPORT
+ else
+ LIBFREETYPE_LIBS := -lfreetype
+ endif
+
+ $(eval $(call SetupNativeCompilation,BUILD_LIBFREETYPE, \
+ LIBRARY := freetype, \
+ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+ SRC := $(LIBFREETYPE_SRC)/src, \
+ LANG := C, \
+ OPTIMIZATION := HIGHEST, \
+ CFLAGS := $(CFLAGS_JDKLIB) $(LIBFREETYPE_CFLAGS) \
+ $(BUILD_LIBFREETYPE_CFLAGS) \
+ -DFT2_BUILD_LIBRARY, \
+ LDFLAGS := $(LDFLAGS_JDKLIB) \
+ $(call SET_SHARED_LIBRARY_ORIGIN), \
+ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
+ RC_FLAGS := $(RC_FLAGS) \
+ -D "JDK_FNAME=freetype.dll" \
+ -D "JDK_INTERNAL_NAME=freetype" \
+ -D "JDK_FTYPE=0x2L", \
+ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libfreetype, \
+ DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES) \
+ ))
+
+ BUILD_LIBRARIES += $(BUILD_LIBFREETYPE)
+endif
+
+##########################################################################################
+
ifndef OPENJDK
FONT_HEADERS := -I$(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k
BUILD_LIBFONTMANAGER_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libfontmanager/mapfile-vers
@@ -935,6 +980,9 @@ BUILD_LIBFONTMANAGER_CFLAGS_COMMON := \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
-I$(JDK_TOPDIR)/src/share/native/sun/java2d
+BUILD_LIBFONTMANAGER_CFLAGS_COMMON += $(LIBFREETYPE_CFLAGS)
+BUILD_LIBFONTMANAGER_FONTLIB += $(LIBFREETYPE_LIBS)
+
# Turn off aliasing with GCC for ExtensionSubtables.cpp
ifeq ($(OPENJDK_TARGET_OS), linux)
BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing
diff --git a/jdk/make/lib/SecurityLibraries.gmk b/jdk/make/lib/SecurityLibraries.gmk
index 1a7bccf8075..39f7e46c552 100644
--- a/jdk/make/lib/SecurityLibraries.gmk
+++ b/jdk/make/lib/SecurityLibraries.gmk
@@ -114,6 +114,11 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2GSS, \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX := $(LIBDL), \
LDFLAGS_SUFFIX_solaris := -lc, \
+ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
+ RC_FLAGS := $(RC_FLAGS) \
+ -D "JDK_FNAME=j2gss.dll" \
+ -D "JDK_INTERNAL_NAME=j2gss" \
+ -D "JDK_FTYPE=0x2L", \
OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libj2gss, \
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
@@ -131,6 +136,11 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX := $(LIBDL), \
+ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
+ RC_FLAGS := $(RC_FLAGS) \
+ -D "JDK_FNAME=sspi_bridge.dll" \
+ -D "JDK_INTERNAL_NAME=sspi_bridge" \
+ -D "JDK_FTYPE=0x2L", \
OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libsspi_bridge, \
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
diff --git a/jdk/src/bsd/doc/man/jarsigner.1 b/jdk/src/bsd/doc/man/jarsigner.1
index 803101ed533..5009bb164b3 100644
--- a/jdk/src/bsd/doc/man/jarsigner.1
+++ b/jdk/src/bsd/doc/man/jarsigner.1
@@ -624,6 +624,11 @@ Informational warnings include those that are not errors but regarded as bad pra
hasExpiringCert
This jar contains entries whose signer certificate will expire within six months\&.
.TP
+internalInconsistenciesDetected
+This jar contains internal inconsistencies detected during verification
+that may result in different contents when reading via JarFile
+and JarInputStream\&.
+.TP
noTimestamp
This jar contains signatures that does not include a timestamp\&. Without a timestamp, users may not be able to validate this JAR file after the signer certificate\&'s expiration date (\f3YYYY-MM-DD\fR) or after any future revocation date\&.
.SH EXAMPLES
diff --git a/jdk/src/linux/doc/man/jarsigner.1 b/jdk/src/linux/doc/man/jarsigner.1
index 803101ed533..5009bb164b3 100644
--- a/jdk/src/linux/doc/man/jarsigner.1
+++ b/jdk/src/linux/doc/man/jarsigner.1
@@ -624,6 +624,11 @@ Informational warnings include those that are not errors but regarded as bad pra
hasExpiringCert
This jar contains entries whose signer certificate will expire within six months\&.
.TP
+internalInconsistenciesDetected
+This jar contains internal inconsistencies detected during verification
+that may result in different contents when reading via JarFile
+and JarInputStream\&.
+.TP
noTimestamp
This jar contains signatures that does not include a timestamp\&. Without a timestamp, users may not be able to validate this JAR file after the signer certificate\&'s expiration date (\f3YYYY-MM-DD\fR) or after any future revocation date\&.
.SH EXAMPLES
diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java
index 39e5afe9f81..6f476c1a2e6 100644
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2025, 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
@@ -29,7 +29,10 @@
import java.awt.peer.DesktopPeer;
import java.io.File;
import java.io.IOException;
+import java.lang.annotation.Native;
import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
/**
@@ -39,6 +42,12 @@
*/
public class CDesktopPeer implements DesktopPeer {
+ @Native private static final int OPEN = 0;
+ @Native private static final int BROWSE = 1;
+ @Native private static final int EDIT = 2;
+ @Native private static final int PRINT = 3;
+ @Native private static final int MAIL = 4;
+
public boolean isSupported(Action action) {
// OPEN, EDIT, PRINT, MAIL, BROWSE all supported.
// Though we don't really differentiate between OPEN / EDIT
@@ -46,43 +55,63 @@ public boolean isSupported(Action action) {
}
public void open(File file) throws IOException {
- this.lsOpenFile(file, false);
+ this.lsOpenFile(file, OPEN);
}
public void edit(File file) throws IOException {
- this.lsOpenFile(file, false);
+ this.lsOpenFile(file, EDIT);
}
public void print(File file) throws IOException {
- this.lsOpenFile(file, true);
+ this.lsOpenFile(file, PRINT);
}
public void mail(URI uri) throws IOException {
- this.lsOpen(uri);
+ this.lsOpen(uri, MAIL);
}
public void browse(URI uri) throws IOException {
- this.lsOpen(uri);
+ this.lsOpen(uri, BROWSE);
}
- private void lsOpen(URI uri) throws IOException {
- int status = _lsOpenURI(uri.toString());
+ private void lsOpen(URI uri, int action) throws IOException {
+ int status = _lsOpenURI(uri.toString(), action);
if (status != 0 /* noErr */) {
- throw new IOException("Failed to mail or browse " + uri + ". Error code: " + status);
+ String actionString = (action == MAIL) ? "mail" : "browse";
+ throw new IOException("Failed to " + actionString + " " + uri
+ + ". Error code: " + status);
}
}
- private void lsOpenFile(File file, boolean print) throws IOException {
- int status = _lsOpenFile(file.getCanonicalPath(), print);
-
+ private void lsOpenFile(File file, int action) throws IOException {
+ int status = -1;
+ Path tmpFile = null;
+ String tmpTxtPath = null;
+
+ try {
+ if (action == EDIT) {
+ tmpFile = Files.createTempFile("TmpFile", ".txt");
+ tmpTxtPath = tmpFile.toAbsolutePath().toString();
+ }
+ status = _lsOpenFile(file.getCanonicalPath(), action, tmpTxtPath);
+ } catch (Exception e) {
+ throw new IOException("Failed to create tmp file: ", e);
+ } finally {
+ if (tmpFile != null) {
+ Files.deleteIfExists(tmpFile);
+ }
+ }
if (status != 0 /* noErr */) {
- throw new IOException("Failed to open, edit or print " + file + ". Error code: " + status);
+ String actionString = (action == OPEN) ? "open"
+ : (action == EDIT) ? "edit" : "print";
+ throw new IOException("Failed to " + actionString + " " + file
+ + ". Error code: " + status);
}
}
- private static native int _lsOpenURI(String uri);
+ private static native int _lsOpenURI(String uri, int action);
- private static native int _lsOpenFile(String path, boolean print);
+ private static native int _lsOpenFile(String path, int action, String tmpTxtPath);
}
diff --git a/jdk/src/macosx/native/sun/awt/CDesktopPeer.m b/jdk/src/macosx/native/sun/awt/CDesktopPeer.m
index ae440848af6..98088f942c8 100644
--- a/jdk/src/macosx/native/sun/awt/CDesktopPeer.m
+++ b/jdk/src/macosx/native/sun/awt/CDesktopPeer.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2025, 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
@@ -27,27 +27,61 @@
#import
#import
#import
+#import
+#import "sun_lwawt_macosx_CDesktopPeer.h"
/*
* Class: sun_lwawt_macosx_CDesktopPeer
* Method: _lsOpenURI
- * Signature: (Ljava/lang/String;)I;
+ * Signature: (Ljava/lang/String;I)I
*/
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenURI
-(JNIEnv *env, jclass clz, jstring uri)
+(JNIEnv *env, jclass clz, jstring uri, jint action)
{
- OSStatus status = noErr;
+ __block OSStatus status = noErr;
JNF_COCOA_ENTER(env);
- // I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know.
- // So we use LaunchServices directly.
-
- NSURL *url = [NSURL URLWithString:JNFJavaToNSString(env, uri)];
-
- LSLaunchFlags flags = kLSLaunchDefaults;
-
- LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL};
- status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0);
+ NSURL *urlToOpen = [NSURL URLWithString:JNFJavaToNSString(env, uri)];
+ NSURL *appURI = nil;
+
+ if (action == sun_lwawt_macosx_CDesktopPeer_BROWSE) {
+ // To get the defaultBrowser
+ NSURL *httpsURL = [NSURL URLWithString:@"https://"];
+ NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
+ appURI = [workspace URLForApplicationToOpenURL:httpsURL];
+ } else if (action == sun_lwawt_macosx_CDesktopPeer_MAIL) {
+ // To get the default mailer
+ NSURL *mailtoURL = [NSURL URLWithString:@"mailto://"];
+ NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
+ appURI = [workspace URLForApplicationToOpenURL:mailtoURL];
+ }
+
+ if (appURI == nil) {
+ return -1;
+ }
+
+ // Prepare NSOpenConfig object
+ NSArray *urls = @[urlToOpen];
+ NSWorkspaceOpenConfiguration *configuration = [NSWorkspaceOpenConfiguration configuration];
+ configuration.activates = YES; // To bring app to foreground
+ configuration.promptsUserIfNeeded = YES; // To allow macOS desktop prompts
+
+ // dispatch semaphores used to wait for the completion handler to update and return status
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)); // 1 second timeout
+
+ // Asynchronous call to openURL
+ [[NSWorkspace sharedWorkspace] openURLs:urls
+ withApplicationAtURL:appURI
+ configuration:configuration
+ completionHandler:^(NSRunningApplication *app, NSError *error) {
+ if (error) {
+ status = (OSStatus) error.code;
+ }
+ dispatch_semaphore_signal(semaphore);
+ }];
+
+ dispatch_semaphore_wait(semaphore, timeout);
JNF_COCOA_EXIT(env);
return status;
@@ -56,30 +90,72 @@
/*
* Class: sun_lwawt_macosx_CDesktopPeer
* Method: _lsOpenFile
- * Signature: (Ljava/lang/String;Z)I;
+ * Signature: (Ljava/lang/String;I;Ljava/lang/String;)I;
*/
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenFile
-(JNIEnv *env, jclass clz, jstring jpath, jboolean print)
+(JNIEnv *env, jclass clz, jstring jpath, jint action, jstring jtmpTxtPath)
{
- OSStatus status = noErr;
+ __block OSStatus status = noErr;
JNF_COCOA_ENTER(env);
- // I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know.
- // So we use LaunchServices directly.
-
NSString *path = JNFNormalizedNSStringForPath(env, jpath);
-
- NSURL *url = [NSURL fileURLWithPath:(NSString *)path];
+ NSURL *urlToOpen = [NSURL fileURLWithPath:(NSString *)path];
// This byzantine workaround is necesary, or else directories won't open in Finder
- url = (NSURL *)CFURLCreateWithFileSystemPath(NULL, (CFStringRef)[url path], kCFURLPOSIXPathStyle, false);
-
- LSLaunchFlags flags = kLSLaunchDefaults;
- if (print) flags |= kLSLaunchAndPrint;
-
- LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL};
- status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0);
- [url release];
+ urlToOpen = (NSURL *)CFURLCreateWithFileSystemPath(NULL, (CFStringRef)[urlToOpen path],
+ kCFURLPOSIXPathStyle, false);
+
+ NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
+ NSURL *appURI = [workspace URLForApplicationToOpenURL:urlToOpen];
+ NSURL *defaultTerminalApp = [workspace URLForApplicationToOpenURL:[NSURL URLWithString:@"file:///bin/sh"]];
+
+ // Prepare NSOpenConfig object
+ NSArray *urls = @[urlToOpen];
+ NSWorkspaceOpenConfiguration *configuration = [NSWorkspaceOpenConfiguration configuration];
+ configuration.activates = YES; // To bring app to foreground
+ configuration.promptsUserIfNeeded = YES; // To allow macOS desktop prompts
+
+ // pre-checks for open/print/edit before calling openURLs API
+ if (action == sun_lwawt_macosx_CDesktopPeer_OPEN
+ || action == sun_lwawt_macosx_CDesktopPeer_PRINT) {
+ if (appURI == nil
+ || [[urlToOpen absoluteString] containsString:[appURI absoluteString]]
+ || [[defaultTerminalApp absoluteString] containsString:[appURI absoluteString]]) {
+ return -1;
+ }
+ // Additionally set forPrinting=TRUE for print
+ if (action == sun_lwawt_macosx_CDesktopPeer_PRINT) {
+ configuration.forPrinting = YES;
+ }
+ } else if (action == sun_lwawt_macosx_CDesktopPeer_EDIT) {
+ if (appURI == nil
+ || [[urlToOpen absoluteString] containsString:[appURI absoluteString]]) {
+ return -1;
+ }
+ // for EDIT: if (defaultApp = TerminalApp) then set appURI = DefaultTextEditor
+ if ([[defaultTerminalApp absoluteString] containsString:[appURI absoluteString]]) {
+ NSString *path = JNFNormalizedNSStringForPath(env, jtmpTxtPath);
+ NSURL *tempFilePath = [NSURL fileURLWithPath:(NSString *)path];
+ appURI = [workspace URLForApplicationToOpenURL:tempFilePath];
+ }
+ }
+
+ // dispatch semaphores used to wait for the completion handler to update and return status
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)); // 1 second timeout
+
+ // Asynchronous call - openURLs:withApplicationAtURL
+ [[NSWorkspace sharedWorkspace] openURLs:urls
+ withApplicationAtURL:appURI
+ configuration:configuration
+ completionHandler:^(NSRunningApplication *app, NSError *error) {
+ if (error) {
+ status = (OSStatus) error.code;
+ }
+ dispatch_semaphore_signal(semaphore);
+ }];
+
+ dispatch_semaphore_wait(semaphore, timeout);
JNF_COCOA_EXIT(env);
return status;
diff --git a/jdk/src/share/classes/com/sun/net/httpserver/Headers.java b/jdk/src/share/classes/com/sun/net/httpserver/Headers.java
index 8d1a356e05f..5d3fc2c0205 100644
--- a/jdk/src/share/classes/com/sun/net/httpserver/Headers.java
+++ b/jdk/src/share/classes/com/sun/net/httpserver/Headers.java
@@ -26,6 +26,7 @@
package com.sun.net.httpserver;
import java.util.*;
+import sun.net.httpserver.Utils;
/**
* HTTP request and response headers are represented by this class which implements
@@ -129,8 +130,14 @@ public String getFirst (String key) {
}
public List put(String key, List value) {
+ // checkHeader is called in this class to fail fast
+ // It also must be called in sendResponseHeaders because
+ // Headers instances internal state can be modified
+ // external to these methods.
+ Utils.checkHeader(key, false);
+
for (String v : value)
- checkValue(v);
+ Utils.checkHeader(v, true);
return map.put (normalize(key), value);
}
@@ -142,7 +149,8 @@ public List put(String key, List value) {
* @param value the header value to add to the header
*/
public void add (String key, String value) {
- checkValue(value);
+ Utils.checkHeader(key, false);
+ Utils.checkHeader(value, true);
String k = normalize(key);
List l = map.get(k);
if (l == null) {
@@ -152,30 +160,6 @@ public void add (String key, String value) {
l.add (value);
}
- private static void checkValue(String value) {
- int len = value.length();
- for (int i=0; i= len - 2) {
- throw new IllegalArgumentException("Illegal CR found in header");
- }
- char c1 = value.charAt(i+1);
- char c2 = value.charAt(i+2);
- if (c1 != '\n') {
- throw new IllegalArgumentException("Illegal char found after CR in header");
- }
- if (c2 != ' ' && c2 != '\t') {
- throw new IllegalArgumentException("No whitespace found after CRLF in header");
- }
- i+=2;
- } else if (c == '\n') {
- throw new IllegalArgumentException("Illegal LF found in header");
- }
- }
- }
-
/**
* sets the given value as the sole header value
* for the given key. If the mapping does not
diff --git a/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java b/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java
index 059cceb103a..ecfc994576a 100644
--- a/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java
+++ b/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java
@@ -34,6 +34,12 @@
*/
package java.util.concurrent;
+import sun.misc.Unsafe;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamException;
+import java.io.StreamCorruptedException;
import java.util.Collection;
import java.util.Set;
import java.util.AbstractSet;
@@ -430,4 +436,40 @@ public Spliterator spliterator() {
private static boolean eq(Object o1, Object o2) {
return (o1 == null) ? o2 == null : o1.equals(o2);
}
+
+ /**
+ * De-serialization without data not supported for this class.
+ */
+ private void readObjectNoData() throws ObjectStreamException {
+ throw new StreamCorruptedException("Deserialized CopyOnWriteArraySet requires data");
+ }
+
+ /**
+ * Reconstitutes the {@code CopyOnWriteArraySet} instance from a stream
+ * (that is, deserializes it).
+ * @throws StreamCorruptedException if the object read from the stream is invalid.
+ */
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ CopyOnWriteArrayList newAl; // Set during the duplicate check
+
+ @SuppressWarnings("unchecked")
+ CopyOnWriteArrayList inAl = (CopyOnWriteArrayList) in.readFields().get("al", null);
+
+ if (inAl == null
+ || inAl.getClass() != CopyOnWriteArrayList.class
+ || (newAl = new CopyOnWriteArrayList<>()).addAllAbsent(inAl) != inAl.size()) {
+ throw new StreamCorruptedException("Content is invalid");
+ }
+
+ final Unsafe U = Unsafe.getUnsafe();
+ try {
+ U.putObject(
+ this,
+ U.objectFieldOffset(CopyOnWriteArraySet.class.getDeclaredField("al")),
+ newAl
+ );
+ } catch (NoSuchFieldException nsfe) {
+ throw new InternalError(nsfe);
+ }
+ }
}
diff --git a/jdk/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java b/jdk/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java
index ffbc699b150..7e2e576dbdd 100644
--- a/jdk/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java
+++ b/jdk/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, 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
@@ -31,6 +31,7 @@
import java.rmi.server.RMIClientSocketFactory;
import java.util.StringTokenizer;
import javax.net.SocketFactory;
+import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
@@ -119,6 +120,16 @@ public Socket createSocket(String host, int port) throws IOException {
//
final SSLSocket sslSocket = (SSLSocket)
sslSocketFactory.createSocket(host, port);
+
+ if (Boolean.parseBoolean(
+ System.getProperty("jdk.rmi.ssl.client.enableEndpointIdentification", "true"))) {
+ SSLParameters params = sslSocket.getSSLParameters();
+ if (params == null) {
+ params = new SSLParameters();
+ }
+ params.setEndpointIdentificationAlgorithm("HTTPS");
+ sslSocket.setSSLParameters(params);
+ }
// Set the SSLSocket Enabled Cipher Suites
//
final String enabledCipherSuites =
diff --git a/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java b/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java
index e3bcf02ed5c..bc95da7367c 100644
--- a/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java
+++ b/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -26,9 +26,9 @@
import java.awt.Component;
import java.awt.Container;
-import java.awt.ComponentOrientation;
import java.util.Comparator;
import java.io.*;
+import java.util.Enumeration;
import sun.awt.SunToolkit;
@@ -235,6 +235,30 @@ protected boolean accept(Component aComponent) {
JComboBox box = (JComboBox)aComponent;
return box.getUI().isFocusTraversable(box);
} else if (aComponent instanceof JComponent) {
+ if (SunToolkit.isInstanceOf(aComponent,
+ "javax.swing.JToggleButton")) {
+ ButtonModel buttonModel = ((JToggleButton) aComponent).getModel();
+ if (buttonModel != null && buttonModel instanceof DefaultButtonModel) {
+ DefaultButtonModel model = (DefaultButtonModel) buttonModel;
+ ButtonGroup group = model.getGroup();
+ if (group != null) {
+ Enumeration elements =
+ group.getElements();
+ int idx = 0;
+ while (elements.hasMoreElements()) {
+ AbstractButton member = elements.nextElement();
+ if (member.isVisible() && member.isDisplayable() &&
+ member.isEnabled() && member.isFocusable()) {
+ if (member == aComponent) {
+ return idx == 0;
+ }
+ idx++;
+ }
+ }
+ }
+ }
+ }
+
JComponent jComponent = (JComponent)aComponent;
InputMap inputMap = jComponent.getInputMap(JComponent.WHEN_FOCUSED,
false);
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java
index f251369494b..b94bc4f98ea 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -421,13 +421,13 @@ public Dimension getPreferredSize() {
addMessageComponents(container, cons, c, maxll, true );
} else {
- JLabel label;
- label = new JLabel( s, JLabel.LEADING );
+ JLabel label = new JLabel();
if (Boolean.TRUE.equals(
this.optionPane.getClientProperty("html.disable"))) {
label.putClientProperty("html.disable", true);
BasicHTML.updateRenderer(label, label.getText());
}
+ label.setText(s);
label.setName("OptionPane.label");
configureMessageLabel(label);
addMessageComponents(container, cons, label, maxll, true);
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java
index 420e30e936f..265acfd734f 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -437,21 +437,7 @@ boolean containsInGroup(Object obj){
// Check if the next object to gain focus belongs
// to the button group or not
Component getFocusTransferBaseComponent(boolean next){
- Component focusBaseComp = activeBtn;
- Container container = focusBaseComp.getFocusCycleRootAncestor();
- if (container != null) {
- FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
- Component comp = next ? policy.getComponentAfter(container, activeBtn)
- : policy.getComponentBefore(container, activeBtn);
-
- // If next component in the button group, use last/first button as base focus
- // otherwise, use the activeBtn as the base focus
- if (containsInGroup(comp)) {
- focusBaseComp = next ? lastBtn : firstBtn;
- }
- }
-
- return focusBaseComp;
+ return firstBtn;
}
boolean getButtonGroupInfo() {
diff --git a/jdk/src/share/classes/sun/java2d/pipe/SpanClipRenderer.java b/jdk/src/share/classes/sun/java2d/pipe/SpanClipRenderer.java
index bba66f65907..791bec0c7f9 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/SpanClipRenderer.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/SpanClipRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2025, 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
@@ -28,6 +28,8 @@
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.PathIterator;
+
+import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
/**
@@ -68,7 +70,9 @@ public SCRcontext(RegionIterator ri, Object outctx) {
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
int[] abox) {
RegionIterator ri = sg.clipRegion.getIterator();
-
+ if (ri.region.isRectangular()) {
+ throw new InvalidPipeException("Invalid clip data");
+ }
return new SCRcontext(ri, outpipe.startSequence(sg, s, devR, abox));
}
diff --git a/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java b/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java
index eac2bc3ddf7..1e2c7d496a7 100644
--- a/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java
+++ b/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java
@@ -197,6 +197,8 @@ PlaceholderOutputStream getPlaceholderResponseBody () {
return uos_orig;
}
+ private static final byte[] CRLF = new byte[] {0x0D, 0x0A};
+
public void sendResponseHeaders (int rCode, long contentLen)
throws IOException
{
@@ -204,10 +206,11 @@ public void sendResponseHeaders (int rCode, long contentLen)
throw new IOException ("headers already sent");
}
this.rcode = rCode;
- String statusLine = "HTTP/1.1 "+rCode+Code.msg(rCode)+"\r\n";
+ String statusLine = "HTTP/1.1 "+rCode+Code.msg(rCode);
OutputStream tmpout = new BufferedOutputStream (ros);
PlaceholderOutputStream o = getPlaceholderResponseBody();
- tmpout.write (bytes(statusLine, 0), 0, statusLine.length());
+ tmpout.write (bytes(statusLine, false, 0), 0, statusLine.length());
+ tmpout.write (CRLF);
boolean noContentToSend = false; // assume there is content
rspHdrs.set ("Date", dateFormat.get().format (new Date()));
@@ -277,11 +280,11 @@ void write (Headers map, OutputStream os) throws IOException {
List values = entry.getValue();
for (String val : values) {
int i = key.length();
- buf = bytes (key, 2);
+ buf = bytes (key, true, 2);
buf[i++] = ':';
buf[i++] = ' ';
os.write (buf, 0, i);
- buf = bytes (val, 2);
+ buf = bytes (val, false, 2);
i = val.length();
buf[i++] = '\r';
buf[i++] = '\n';
@@ -299,8 +302,14 @@ void write (Headers map, OutputStream os) throws IOException {
* Make sure that at least "extra" bytes are free at end
* of rspbuf. Reallocate rspbuf if not big enough.
* caller must check return value to see if rspbuf moved
+ *
+ * Header values are supposed to be limited to 7-bit ASCII
+ * but 8-bit has to be allowed (for ISO_8859_1). For efficiency
+ * we just down cast 16 bit Java chars to byte. We don't allow
+ * any character that can't be encoded in 8 bits.
*/
- private byte[] bytes (String s, int extra) {
+ private byte[] bytes (String s, boolean isKey, int extra) throws IOException {
+ Utils.checkHeader(s, !isKey);
int slen = s.length();
if (slen+extra > rspbuf.length) {
int diff = slen + extra - rspbuf.length;
diff --git a/jdk/src/share/classes/sun/net/httpserver/Utils.java b/jdk/src/share/classes/sun/net/httpserver/Utils.java
new file mode 100644
index 00000000000..561c02f7cda
--- /dev/null
+++ b/jdk/src/share/classes/sun/net/httpserver/Utils.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2025, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.net.httpserver;
+
+/**
+ * Provides utility methods for checking header field names and quoted strings.
+ */
+public class Utils {
+
+ /* Throw IAE if illegal character found. isValue is true if String is
+ * a value. Otherwise it is header name
+ */
+ public static void checkHeader(String str, boolean isValue) {
+ int len = str.length();
+ for (int i=0; i= len - 2) {
+ throw new IllegalArgumentException("Illegal CR found in header");
+ }
+ char c1 = str.charAt(i+1);
+ char c2 = str.charAt(i+2);
+ if (c1 != '\n') {
+ throw new IllegalArgumentException("Illegal char found after CR in header");
+ }
+ if (c2 != ' ' && c2 != '\t') {
+ throw new IllegalArgumentException("No whitespace found after CRLF in header");
+ }
+ i+=2;
+ } else if (c == '\n') {
+ throw new IllegalArgumentException("Illegal LF found in header");
+ } else if (c > 255) {
+ throw new IllegalArgumentException("Illegal character found in header");
+ }
+ }
+ }
+
+}
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java b/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java
index a5ec5d36e8d..4eaaa5f54a7 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2025, 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
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URLConnection;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
@@ -49,14 +50,20 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Optional;
+import java.util.Set;
import sun.security.action.GetIntegerAction;
import sun.security.x509.AccessDescription;
import sun.security.x509.GeneralNameInterface;
import sun.security.x509.URIName;
import sun.security.util.Cache;
import sun.security.util.Debug;
+import sun.security.util.SecurityProperties;
+
+import javax.security.auth.x500.X500Principal;
/**
* A CertStore that retrieves Certificates or
@@ -149,6 +156,165 @@ private static int initializeTimeout() {
return tmp * 1000;
}
+ /**
+ * Enumeration for the allowed schemes we support when following a
+ * URI from an authorityInfoAccess extension on a certificate.
+ */
+ private enum AllowedScheme {
+ HTTP(HttpFtpRuleMatcher.HTTP),
+ HTTPS(HttpFtpRuleMatcher.HTTPS),
+ LDAP(LdapRuleMatcher.LDAP),
+ LDAPS(LdapRuleMatcher.LDAPS),
+ FTP(HttpFtpRuleMatcher.FTP);
+
+ final URIRuleMatcher ruleMatcher;
+
+ AllowedScheme(URIRuleMatcher matcher) {
+ ruleMatcher = matcher;
+ }
+
+ /**
+ * Return an {@code AllowedScheme} based on a case-insensitive match
+ * @param name the scheme name to be matched
+ * @return the {@code AllowedScheme} that corresponds to the
+ * {@code name} provided, or null if there is no match.
+ */
+ static AllowedScheme nameOf(String name) {
+ if (name == null) {
+ return null;
+ }
+
+ try {
+ return AllowedScheme.valueOf(name.toUpperCase(Locale.ROOT));
+ } catch (IllegalArgumentException iaEx) {
+ return null;
+ }
+ }
+ }
+
+ private static Set CA_ISS_URI_FILTERS = null;
+ private static final boolean CA_ISS_ALLOW_ANY;
+
+ static {
+ boolean allowAny = false;
+ try {
+ if (Builder.USE_AIA) {
+ CA_ISS_URI_FILTERS = new LinkedHashSet<>();
+ String aiaPropVal = SecurityProperties.privilegedGetOverridable(
+ "com.sun.security.allowedAIALocations");
+ aiaPropVal = (aiaPropVal != null)?aiaPropVal.trim():"";
+ if (aiaPropVal.equalsIgnoreCase("any")) {
+ allowAny = true;
+ if (debug != null) {
+ debug.println("allowedAIALocations: Warning: " +
+ "Allow-All URI filtering enabled!");
+ }
+ } else {
+ // Load all the valid rules from the Security property
+ if (!aiaPropVal.isEmpty()) {
+ String[] aiaUriStrs = aiaPropVal.trim().split("\\s+");
+ addCaIssUriFilters(aiaUriStrs);
+ }
+
+ if (CA_ISS_URI_FILTERS.isEmpty()) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Warning: " +
+ "No valid filters found. Deny-all URI " +
+ "filtering is active.");
+ }
+ }
+ }
+ }
+ } finally {
+ CA_ISS_ALLOW_ANY = allowAny;
+ }
+ }
+
+ /**
+ * Populate the filter collection from the list of AIA CA issuer URIs
+ * found in the {@code com.sun.security.allowedAIALocations} security
+ * or system property.
+ *
+ * @param aiaUriStrs array containing String URI filters
+ */
+ private static void addCaIssUriFilters(String[] aiaUriStrs) {
+ for (String aiaStr : aiaUriStrs) {
+ if (aiaStr != null && !aiaStr.isEmpty()) {
+ try {
+ AllowedScheme scheme;
+ URI aiaUri = new URI(aiaStr).normalize();
+ // It must be absolute and non-opaque
+ if (!aiaUri.isAbsolute() || aiaUri.isOpaque()) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Skipping " +
+ "non-absolute or opaque URI " + aiaUri);
+ }
+ } else if (aiaUri.getHost() == null) {
+ // We do not allow rules with URIs that omit a hostname
+ // or address.
+ if (debug != null) {
+ debug.println("allowedAIALocations: Skipping " +
+ "URI rule with no hostname or address: " +
+ aiaUri);
+ }
+ } else if ((scheme = AllowedScheme.nameOf(
+ aiaUri.getScheme())) != null) {
+ // When it is an LDAP type, we can check the path
+ // portion (the DN) for proper structure and reject
+ // the rule early if it isn't correct.
+ if (scheme == AllowedScheme.LDAP ||
+ scheme == AllowedScheme.LDAPS) {
+ try {
+ new X500Principal(aiaUri.getPath().
+ replaceFirst("^/+", ""));
+ } catch (IllegalArgumentException iae) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: " +
+ "Skipping LDAP rule: " + iae);
+ }
+ continue;
+ }
+ }
+
+ // When a URI has a non-null query or fragment
+ // warn the user upon adding the rule that those
+ // components will be ignored
+ if (aiaUri.getQuery() != null) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: " +
+ "Rule will ignore non-null query");
+ }
+ }
+ if (aiaUri.getFragment() != null) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: " +
+ "Rule will ignore non-null fragment");
+ }
+ }
+
+ CA_ISS_URI_FILTERS.add(aiaUri);
+ if (debug != null) {
+ debug.println("allowedAIALocations: Added " +
+ aiaUri + " to URI filters");
+ }
+ } else {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Disallowed " +
+ "filter URI scheme: " +
+ aiaUri.getScheme());
+ }
+ }
+ } catch (URISyntaxException urise) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Skipping " +
+ "filter URI entry " + aiaStr +
+ ": parse failure at index " + urise.getIndex());
+ }
+ }
+ }
+ }
+ }
+
/**
* Creates a URICertStore.
*
@@ -217,6 +383,39 @@ static CertStore getInstance(AccessDescription ad) {
return null;
}
URI uri = ((URIName) gn).getURI();
+
+ // Before performing any instantiation make sure that
+ // the URI passes any filtering rules. This processing should
+ // only occur if the com.sun.security.enableAIAcaIssuers is true
+ // and the "any" rule has not been specified.
+ if (Builder.USE_AIA && !CA_ISS_ALLOW_ANY) {
+ URI normAIAUri = uri.normalize();
+ AllowedScheme scheme = AllowedScheme.nameOf(normAIAUri.getScheme());
+
+ if (scheme == null) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: No matching ruleset " +
+ "for scheme " + normAIAUri.getScheme());
+ }
+ return null;
+ }
+
+ // Go through each of the filter rules and see if any will
+ // make a positive match against the caIssuer URI. If nothing
+ // matches then we won't instantiate a URICertStore.
+ if (CA_ISS_URI_FILTERS.stream().noneMatch(rule ->
+ scheme.ruleMatcher.matchRule(rule, normAIAUri))) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Warning - " +
+ "The caIssuer URI " + normAIAUri +
+ " in the AuthorityInfoAccess extension is denied " +
+ "access. Use the com.sun.security.allowedAIALocations" +
+ " security/system property to allow access.");
+ }
+ return null;
+ }
+ }
+
try {
return URICertStore.getInstance
(new URICertStore.URICertStoreParameters(uri));
@@ -244,7 +443,7 @@ static CertStore getInstance(AccessDescription ad) {
@Override
@SuppressWarnings("unchecked")
public synchronized Collection engineGetCertificates
- (CertSelector selector) throws CertStoreException {
+ (CertSelector selector) throws CertStoreException {
// if ldap URI we wrap the CertSelector in an LDAPCertSelector to
// avoid LDAP DN matching issues (see LDAPCertSelector for more info)
@@ -488,4 +687,159 @@ protected UCS(CertStoreSpi spi, Provider p, String type,
super(spi, p, type, params);
}
}
+
+ /**
+ * URIRuleMatcher - abstract base class for the rule sets used for
+ * various URI schemes.
+ */
+ static abstract class URIRuleMatcher {
+ protected final int wellKnownPort;
+
+ protected URIRuleMatcher(int port) {
+ wellKnownPort = port;
+ }
+
+ /**
+ * Attempt to match the scheme, host and port between a filter
+ * rule URI and a URI coming from an AIA extension.
+ *
+ * @param filterRule the filter rule to match against
+ * @param caIssuer the AIA URI being compared
+ * @return true if the scheme, host and port numbers match, false if
+ * any of the components do not match. If a port number is omitted in
+ * either the filter rule or AIA URI, the well-known port for that
+ * scheme is used in the comparison.
+ */
+ boolean schemeHostPortCheck(URI filterRule, URI caIssuer) {
+ if (!filterRule.getScheme().equalsIgnoreCase(
+ caIssuer.getScheme())) {
+ return false;
+ } else if (!filterRule.getHost().equalsIgnoreCase(
+ caIssuer.getHost())) {
+ return false;
+ } else {
+ try {
+ // Check for port matching, taking into consideration
+ // default ports
+ int fPort = (filterRule.getPort() == -1) ? wellKnownPort :
+ filterRule.getPort();
+ int caiPort = (caIssuer.getPort() == -1) ? wellKnownPort :
+ caIssuer.getPort();
+ if (fPort != caiPort) {
+ return false;
+ }
+ } catch (IllegalArgumentException iae) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Attempt to match an AIA URI against a specific filter rule. The
+ * specific rules to apply are implementation dependent.
+ *
+ * @param filterRule the filter rule to match against
+ * @param caIssuer the AIA URI being compared
+ * @return true if all matching rules pass, false if any fail.
+ */
+ abstract boolean matchRule(URI filterRule, URI caIssuer);
+ }
+
+ static class HttpFtpRuleMatcher extends URIRuleMatcher {
+ static final HttpFtpRuleMatcher HTTP = new HttpFtpRuleMatcher(80);
+ static final HttpFtpRuleMatcher HTTPS = new HttpFtpRuleMatcher(443);
+ static final HttpFtpRuleMatcher FTP = new HttpFtpRuleMatcher(21);
+
+ private HttpFtpRuleMatcher(int port) {
+ super(port);
+ }
+
+ @Override
+ boolean matchRule(URI filterRule, URI caIssuer) {
+ // Check for scheme/host/port matching
+ if (!schemeHostPortCheck(filterRule, caIssuer)) {
+ return false;
+ }
+
+ // Check the path component to make sure the filter is at
+ // least a root of the AIA caIssuer URI's path. It must be
+ // a case-sensitive match for all platforms.
+ if (!isRootOf(filterRule, caIssuer)) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Match failed: " +
+ "AIA URI is not within the rule's path hierarchy.");
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Performs a hierarchical containment check, ensuring that the
+ * base URI's path is a root component of the candidate path. The
+ * path comparison is case-sensitive. If the base path ends in a
+ * slash (/) then all candidate paths that begin with the base
+ * path are allowed. If it does not end in a slash, then it is
+ * assumed that the leaf node in the base path is a file component
+ * and both paths must match exactly.
+ *
+ * @param base the URI that contains the root path
+ * @param candidate the URI that contains the path being evaluated
+ * @return true if {@code candidate} is a child path of {@code base},
+ * false otherwise.
+ */
+ private static boolean isRootOf(URI base, URI candidate) {
+ // Note: The URIs have already been normalized at this point and
+ // HTTP URIs cannot have null paths. If it's an empty path
+ // then consider the path to be "/".
+ String basePath = Optional.of(base.getPath()).
+ filter(p -> !p.isEmpty()).orElse("/");
+ String candPath = Optional.of(candidate.getPath()).
+ filter(p -> !p.isEmpty()).orElse("/");
+ return (basePath.endsWith("/")) ? candPath.startsWith(basePath) :
+ candPath.equals(basePath);
+ }
+ }
+
+ static class LdapRuleMatcher extends URIRuleMatcher {
+ static final LdapRuleMatcher LDAP = new LdapRuleMatcher(389);
+ static final LdapRuleMatcher LDAPS = new LdapRuleMatcher(636);
+
+ private LdapRuleMatcher(int port) {
+ super(port);
+ }
+
+ @Override
+ boolean matchRule(URI filterRule, URI caIssuer) {
+ // Check for scheme/host/port matching
+ if (!schemeHostPortCheck(filterRule, caIssuer)) {
+ return false;
+ }
+
+ // Obtain the base DN component and compare
+ try {
+ X500Principal filterBaseDn = new X500Principal(
+ filterRule.getPath().replaceFirst("^/+", ""));
+ X500Principal caIssBaseDn = new X500Principal(
+ caIssuer.getPath().replaceFirst("^/+", ""));
+ if (!filterBaseDn.equals(caIssBaseDn)) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Match failed: " +
+ "Base DN mismatch (" + filterBaseDn + " vs " +
+ caIssBaseDn + ")");
+ }
+ return false;
+ }
+ } catch (IllegalArgumentException iae) {
+ if (debug != null) {
+ debug.println("allowedAIALocations: Match failed on DN: " +
+ iae);
+ }
+ return false;
+ }
+
+ return true;
+ }
+ }
}
diff --git a/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java b/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java
index 0cfa2c38ea6..c4e3d9d4d2b 100644
--- a/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java
+++ b/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java
@@ -26,6 +26,8 @@
package sun.security.tools.jarsigner;
import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.security.cert.CertPathValidatorException;
import java.security.cert.PKIXBuilderParameters;
import java.util.*;
@@ -223,6 +225,8 @@ public static void main(String args[]) throws Exception {
private Throwable chainNotValidatedReason = null;
private Throwable tsaChainNotValidatedReason = null;
+ private List crossChkWarnings = new ArrayList<>();
+
PKIXBuilderParameters pkixParameters;
Set trustedCerts = new HashSet<>();
@@ -976,6 +980,7 @@ void verifyJar(String jarName)
}
}
System.out.println();
+ crossCheckEntries(jarName);
// If signer is a trusted cert or private entry in user's own
// keystore, it can be self-signed. Please note aliasNotInStore
@@ -1017,6 +1022,144 @@ void verifyJar(String jarName)
System.exit(1);
}
+ private void crossCheckEntries(String jarName) throws Exception {
+ Set locEntries = new HashSet<>();
+
+ try (JarFile jarFile = new JarFile(jarName);
+ JarInputStream jis = new JarInputStream(
+ Files.newInputStream(Paths.get(jarName)))) {
+
+ Manifest cenManifest = jarFile.getManifest();
+ Manifest locManifest = jis.getManifest();
+ compareManifest(cenManifest, locManifest);
+
+ JarEntry locEntry;
+ while ((locEntry = jis.getNextJarEntry()) != null) {
+ String entryName = locEntry.getName();
+ locEntries.add(entryName);
+
+ JarEntry cenEntry = jarFile.getJarEntry(entryName);
+ if (cenEntry == null) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "entry.1.present.when.reading.jarinputstream.but.missing.via.jarfile"),
+ entryName));
+ continue;
+ }
+
+ try {
+ readEntry(jis);
+ } catch (SecurityException e) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "signature.verification.failed.on.entry.1.when.reading.via.jarinputstream"),
+ entryName));
+ continue;
+ }
+
+ try (InputStream cenInputStream = jarFile.getInputStream(cenEntry)) {
+ if (cenInputStream == null) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "entry.1.present.in.jarfile.but.unreadable"),
+ entryName));
+ continue;
+ } else {
+ try {
+ readEntry(cenInputStream);
+ } catch (SecurityException e) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "signature.verification.failed.on.entry.1.when.reading.via.jarfile"),
+ entryName));
+ continue;
+ }
+ }
+ }
+
+ compareSigners(cenEntry, locEntry);
+ }
+
+ jarFile.stream()
+ .map(JarEntry::getName)
+ .filter(n -> !locEntries.contains(n) && !n.equals(JarFile.MANIFEST_NAME))
+ .forEach(n -> crossChkWarnings.add(String.format(rb.getString(
+ "entry.1.present.when.reading.jarfile.but.missing.via.jarinputstream"), n)));
+ }
+ }
+
+ private void readEntry(InputStream is) throws IOException {
+ byte[] buffer = new byte[8192];
+ while (is.read(buffer) != -1) { }
+ }
+
+ private void compareManifest(Manifest cenManifest, Manifest locManifest) {
+ if (cenManifest == null) {
+ crossChkWarnings.add(rb.getString(
+ "manifest.missing.when.reading.jarfile"));
+ return;
+ }
+ if (locManifest == null) {
+ crossChkWarnings.add(rb.getString(
+ "manifest.missing.when.reading.jarinputstream"));
+ return;
+ }
+
+ Attributes cenMainAttrs = cenManifest.getMainAttributes();
+ Attributes locMainAttrs = locManifest.getMainAttributes();
+
+ for (Object key : cenMainAttrs.keySet()) {
+ Object cenValue = cenMainAttrs.get(key);
+ Object locValue = locMainAttrs.get(key);
+
+ if (locValue == null) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "manifest.attribute.1.present.when.reading.jarfile.but.missing.via.jarinputstream"),
+ key));
+ } else if (!cenValue.equals(locValue)) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "manifest.attribute.1.differs.jarfile.value.2.jarinputstream.value.3"),
+ key, cenValue, locValue));
+ }
+ }
+
+ for (Object key : locMainAttrs.keySet()) {
+ if (!cenMainAttrs.containsKey(key)) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "manifest.attribute.1.present.when.reading.jarinputstream.but.missing.via.jarfile"),
+ key));
+ }
+ }
+ }
+
+ private void compareSigners(JarEntry cenEntry, JarEntry locEntry) {
+ CodeSigner[] cenSigners = cenEntry.getCodeSigners();
+ CodeSigner[] locSigners = locEntry.getCodeSigners();
+
+ boolean cenHasSigners = cenSigners != null;
+ boolean locHasSigners = locSigners != null;
+
+ if (cenHasSigners && locHasSigners) {
+ if (!Arrays.equals(cenSigners, locSigners)) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "codesigners.different.for.entry.1.when.reading.jarfile.and.jarinputstream"),
+ cenEntry.getName()));
+ }
+ } else if (cenHasSigners) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "entry.1.is.signed.in.jarfile.but.is.not.signed.in.jarinputstream"),
+ cenEntry.getName()));
+ } else if (locHasSigners) {
+ crossChkWarnings.add(String.format(rb.getString(
+ "entry.1.is.signed.in.jarinputstream.but.is.not.signed.in.jarfile"),
+ locEntry.getName()));
+ }
+ }
+
+ private void displayCrossChkWarnings() {
+ System.out.println();
+ // First is a summary warning
+ System.out.println(rb.getString("jar.contains.internal.inconsistencies.result.in.different.contents.via.jarfile.and.jarinputstream"));
+ // each warning message with prefix "- "
+ crossChkWarnings.forEach(warning -> System.out.println("- " + warning));
+ }
+
private void displayMessagesAndResult(boolean isSigning) {
String result;
List errors = new ArrayList<>();
@@ -1248,6 +1391,9 @@ private void displayMessagesAndResult(boolean isSigning) {
System.out.println(rb.getString("Warning."));
warnings.forEach(System.out::println);
}
+ if (!crossChkWarnings.isEmpty()) {
+ displayCrossChkWarnings();
+ }
} else {
if (!errors.isEmpty() || !warnings.isEmpty()) {
System.out.println();
@@ -1255,6 +1401,9 @@ private void displayMessagesAndResult(boolean isSigning) {
errors.forEach(System.out::println);
warnings.forEach(System.out::println);
}
+ if (!crossChkWarnings.isEmpty()) {
+ displayCrossChkWarnings();
+ }
}
if (!isSigning && (!errors.isEmpty() || !warnings.isEmpty())) {
if (! (verbose != null && showcerts)) {
diff --git a/jdk/src/share/classes/sun/security/tools/jarsigner/Resources.java b/jdk/src/share/classes/sun/security/tools/jarsigner/Resources.java
index 923897089a9..6bc92b09ef0 100644
--- a/jdk/src/share/classes/sun/security/tools/jarsigner/Resources.java
+++ b/jdk/src/share/classes/sun/security/tools/jarsigner/Resources.java
@@ -312,6 +312,34 @@ public class Resources extends java.util.ListResourceBundle {
{"Cannot.find.environment.variable.",
"Cannot find environment variable: "},
{"Cannot.find.file.", "Cannot find file: "},
+ {"manifest.missing.when.reading.jarfile",
+ "Manifest is missing when reading via JarFile"},
+ {"manifest.missing.when.reading.jarinputstream",
+ "Manifest is missing when reading via JarInputStream"},
+ {"manifest.attribute.1.present.when.reading.jarfile.but.missing.via.jarinputstream",
+ "Manifest main attribute %s is present when reading via JarFile but missing when reading via JarInputStream"},
+ {"manifest.attribute.1.present.when.reading.jarinputstream.but.missing.via.jarfile",
+ "Manifest main attribute %s is present when reading via JarInputStream but missing when reading via JarFile"},
+ {"manifest.attribute.1.differs.jarfile.value.2.jarinputstream.value.3",
+ "Manifest main attribute %1$s differs: JarFile value = %2$s, JarInputStream value = %3$s"},
+ {"entry.1.present.when.reading.jarinputstream.but.missing.via.jarfile",
+ "Entry %s is present when reading via JarInputStream but missing when reading via JarFile"},
+ {"entry.1.present.when.reading.jarfile.but.missing.via.jarinputstream",
+ "Entry %s is present when reading via JarFile but missing when reading via JarInputStream"},
+ {"entry.1.present.in.jarfile.but.unreadable",
+ "Entry %s is present in JarFile but unreadable"},
+ {"codesigners.different.for.entry.1.when.reading.jarfile.and.jarinputstream",
+ "Code signers are different for entry %s when reading from JarFile and JarInputStream"},
+ {"entry.1.is.signed.in.jarfile.but.is.not.signed.in.jarinputstream",
+ "Entry %s is signed in JarFile but is not signed in JarInputStream"},
+ {"entry.1.is.signed.in.jarinputstream.but.is.not.signed.in.jarfile",
+ "Entry %s is signed in JarInputStream but is not signed in JarFile"},
+ {"jar.contains.internal.inconsistencies.result.in.different.contents.via.jarfile.and.jarinputstream",
+ "This JAR file contains internal inconsistencies that may result in different contents when reading via JarFile and JarInputStream:"},
+ {"signature.verification.failed.on.entry.1.when.reading.via.jarinputstream",
+ "Signature verification failed on entry %s when reading via JarInputStream"},
+ {"signature.verification.failed.on.entry.1.when.reading.via.jarfile",
+ "Signature verification failed on entry %s when reading via JarFile"},
};
/**
diff --git a/jdk/src/share/lib/security/java.security-aix b/jdk/src/share/lib/security/java.security-aix
index 9318e518d84..e0dd107bb11 100644
--- a/jdk/src/share/lib/security/java.security-aix
+++ b/jdk/src/share/lib/security/java.security-aix
@@ -1311,4 +1311,49 @@ jdk.tls.alpnCharset=ISO_8859_1
#
# The default pattern value allows any object factory class specified by the reference
# instance to recreate the referenced object.
-#jdk.jndi.object.factoriesFilter=*
\ No newline at end of file
+#jdk.jndi.object.factoriesFilter=*
+
+#
+# X.509 AuthorityInfoAccess caIssuer URI Filtering
+#
+# This property defines a whitespace-separated list of filters that
+# are applied to URIs found in the authorityInfoAccess extension in
+# X.509 certificates. Any caIssuers URIs in X.509 certificates are only
+# followed when the com.sun.security.enableAIAcaIssuers System property is
+# enabled and the filter allows the URI. By default this property imposes a
+# deny-all ruleset. This property may be overridden by a System property
+# of the same name.
+#
+# The filters must take the form of absolute, hierarchical URIs as defined by
+# the java.net.URI class. Additionally, only the following protocols are
+# allowed as filters: http, https, ldap and ftp.
+# See RFC 5280, section 4.2.2.1 for details about the types of URIs allowed for
+# the extension and their specific requirements.
+# The filter matching rules are applied to each CA issuer URI as follows:
+# 1. The scheme must match (case-insensitive).
+# 2. A hostname or address must be specified in the filter URI. It must match
+# the host or address in the caIssuers URI (case-insensitive). No name
+# resolution is performed on hostnames to match IP addresses.
+# 3. The port number must match. For filter and caIssuer URIs, when a port
+# number is omitted, the well-known port for that scheme will be used in the
+# comparison.
+# 4. For hierarchical filesystem schemes (e.g. http[s], ftp):
+# a. The normalized path portion of the filter URI is matched in a
+# case-sensitive manner. If the final component of the path does not end
+# in a slash (/), it is considered to be a file path component and must
+# be an exact match of the caIssuer's URI file path component. If the
+# final filter component ends in a slash, then it must either match or be
+# a prefix of the caIssuer's URI path component (e.g. a filter path of
+# /ab/cd/ will match a caIssuer path of /ab/cd/, /ab/cd/ef and
+# /ab/cd/ef/ghi).
+# b. Query strings will be ignored in filter rules and caIssuer URIs.
+# c. Fragments will be ignored in filter rules and caIssuer URIs.
+# 5. For ldap URIs:
+# a. The base DN must be an exact match (case-insensitive).
+# b. Any query string in the rule, if specified, is ignored.
+# 6. A single value "any" (case-insensitive) will create an allow-all rule.
+#
+# As an example, here is a valid filter policy consisting of two rules:
+# com.sun.security.allowedAIALocations=http://some.company.com/cacert \
+# ldap://ldap.company.com/dc=company,dc=com?caCertificate;binary
+com.sun.security.allowedAIALocations=
diff --git a/jdk/src/share/lib/security/java.security-linux b/jdk/src/share/lib/security/java.security-linux
index 5a718042d5a..2dcc5770ba5 100644
--- a/jdk/src/share/lib/security/java.security-linux
+++ b/jdk/src/share/lib/security/java.security-linux
@@ -1317,4 +1317,49 @@ jdk.tls.alpnCharset=ISO_8859_1
#
# The default pattern value allows any object factory class specified by the reference
# instance to recreate the referenced object.
-#jdk.jndi.object.factoriesFilter=*
\ No newline at end of file
+#jdk.jndi.object.factoriesFilter=*
+
+#
+# X.509 AuthorityInfoAccess caIssuer URI Filtering
+#
+# This property defines a whitespace-separated list of filters that
+# are applied to URIs found in the authorityInfoAccess extension in
+# X.509 certificates. Any caIssuers URIs in X.509 certificates are only
+# followed when the com.sun.security.enableAIAcaIssuers System property is
+# enabled and the filter allows the URI. By default this property imposes a
+# deny-all ruleset. This property may be overridden by a System property
+# of the same name.
+#
+# The filters must take the form of absolute, hierarchical URIs as defined by
+# the java.net.URI class. Additionally, only the following protocols are
+# allowed as filters: http, https, ldap and ftp.
+# See RFC 5280, section 4.2.2.1 for details about the types of URIs allowed for
+# the extension and their specific requirements.
+# The filter matching rules are applied to each CA issuer URI as follows:
+# 1. The scheme must match (case-insensitive).
+# 2. A hostname or address must be specified in the filter URI. It must match
+# the host or address in the caIssuers URI (case-insensitive). No name
+# resolution is performed on hostnames to match IP addresses.
+# 3. The port number must match. For filter and caIssuer URIs, when a port
+# number is omitted, the well-known port for that scheme will be used in the
+# comparison.
+# 4. For hierarchical filesystem schemes (e.g. http[s], ftp):
+# a. The normalized path portion of the filter URI is matched in a
+# case-sensitive manner. If the final component of the path does not end
+# in a slash (/), it is considered to be a file path component and must
+# be an exact match of the caIssuer's URI file path component. If the
+# final filter component ends in a slash, then it must either match or be
+# a prefix of the caIssuer's URI path component (e.g. a filter path of
+# /ab/cd/ will match a caIssuer path of /ab/cd/, /ab/cd/ef and
+# /ab/cd/ef/ghi).
+# b. Query strings will be ignored in filter rules and caIssuer URIs.
+# c. Fragments will be ignored in filter rules and caIssuer URIs.
+# 5. For ldap URIs:
+# a. The base DN must be an exact match (case-insensitive).
+# b. Any query string in the rule, if specified, is ignored.
+# 6. A single value "any" (case-insensitive) will create an allow-all rule.
+#
+# As an example, here is a valid filter policy consisting of two rules:
+# com.sun.security.allowedAIALocations=http://some.company.com/cacert \
+# ldap://ldap.company.com/dc=company,dc=com?caCertificate;binary
+com.sun.security.allowedAIALocations=
diff --git a/jdk/src/share/lib/security/java.security-macosx b/jdk/src/share/lib/security/java.security-macosx
index f571ab39abd..a772f3d1d21 100644
--- a/jdk/src/share/lib/security/java.security-macosx
+++ b/jdk/src/share/lib/security/java.security-macosx
@@ -1315,4 +1315,49 @@ jdk.tls.alpnCharset=ISO_8859_1
#
# The default pattern value allows any object factory class specified by the reference
# instance to recreate the referenced object.
-#jdk.jndi.object.factoriesFilter=*
\ No newline at end of file
+#jdk.jndi.object.factoriesFilter=*
+
+#
+# X.509 AuthorityInfoAccess caIssuer URI Filtering
+#
+# This property defines a whitespace-separated list of filters that
+# are applied to URIs found in the authorityInfoAccess extension in
+# X.509 certificates. Any caIssuers URIs in X.509 certificates are only
+# followed when the com.sun.security.enableAIAcaIssuers System property is
+# enabled and the filter allows the URI. By default this property imposes a
+# deny-all ruleset. This property may be overridden by a System property
+# of the same name.
+#
+# The filters must take the form of absolute, hierarchical URIs as defined by
+# the java.net.URI class. Additionally, only the following protocols are
+# allowed as filters: http, https, ldap and ftp.
+# See RFC 5280, section 4.2.2.1 for details about the types of URIs allowed for
+# the extension and their specific requirements.
+# The filter matching rules are applied to each CA issuer URI as follows:
+# 1. The scheme must match (case-insensitive).
+# 2. A hostname or address must be specified in the filter URI. It must match
+# the host or address in the caIssuers URI (case-insensitive). No name
+# resolution is performed on hostnames to match IP addresses.
+# 3. The port number must match. For filter and caIssuer URIs, when a port
+# number is omitted, the well-known port for that scheme will be used in the
+# comparison.
+# 4. For hierarchical filesystem schemes (e.g. http[s], ftp):
+# a. The normalized path portion of the filter URI is matched in a
+# case-sensitive manner. If the final component of the path does not end
+# in a slash (/), it is considered to be a file path component and must
+# be an exact match of the caIssuer's URI file path component. If the
+# final filter component ends in a slash, then it must either match or be
+# a prefix of the caIssuer's URI path component (e.g. a filter path of
+# /ab/cd/ will match a caIssuer path of /ab/cd/, /ab/cd/ef and
+# /ab/cd/ef/ghi).
+# b. Query strings will be ignored in filter rules and caIssuer URIs.
+# c. Fragments will be ignored in filter rules and caIssuer URIs.
+# 5. For ldap URIs:
+# a. The base DN must be an exact match (case-insensitive).
+# b. Any query string in the rule, if specified, is ignored.
+# 6. A single value "any" (case-insensitive) will create an allow-all rule.
+#
+# As an example, here is a valid filter policy consisting of two rules:
+# com.sun.security.allowedAIALocations=http://some.company.com/cacert \
+# ldap://ldap.company.com/dc=company,dc=com?caCertificate;binary
+com.sun.security.allowedAIALocations=
diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris
index 06ffe9ef5ac..997fac3f2ee 100644
--- a/jdk/src/share/lib/security/java.security-solaris
+++ b/jdk/src/share/lib/security/java.security-solaris
@@ -1313,4 +1313,49 @@ jdk.tls.alpnCharset=ISO_8859_1
#
# The default pattern value allows any object factory class specified by the reference
# instance to recreate the referenced object.
-#jdk.jndi.object.factoriesFilter=*
\ No newline at end of file
+#jdk.jndi.object.factoriesFilter=*
+
+#
+# X.509 AuthorityInfoAccess caIssuer URI Filtering
+#
+# This property defines a whitespace-separated list of filters that
+# are applied to URIs found in the authorityInfoAccess extension in
+# X.509 certificates. Any caIssuers URIs in X.509 certificates are only
+# followed when the com.sun.security.enableAIAcaIssuers System property is
+# enabled and the filter allows the URI. By default this property imposes a
+# deny-all ruleset. This property may be overridden by a System property
+# of the same name.
+#
+# The filters must take the form of absolute, hierarchical URIs as defined by
+# the java.net.URI class. Additionally, only the following protocols are
+# allowed as filters: http, https, ldap and ftp.
+# See RFC 5280, section 4.2.2.1 for details about the types of URIs allowed for
+# the extension and their specific requirements.
+# The filter matching rules are applied to each CA issuer URI as follows:
+# 1. The scheme must match (case-insensitive).
+# 2. A hostname or address must be specified in the filter URI. It must match
+# the host or address in the caIssuers URI (case-insensitive). No name
+# resolution is performed on hostnames to match IP addresses.
+# 3. The port number must match. For filter and caIssuer URIs, when a port
+# number is omitted, the well-known port for that scheme will be used in the
+# comparison.
+# 4. For hierarchical filesystem schemes (e.g. http[s], ftp):
+# a. The normalized path portion of the filter URI is matched in a
+# case-sensitive manner. If the final component of the path does not end
+# in a slash (/), it is considered to be a file path component and must
+# be an exact match of the caIssuer's URI file path component. If the
+# final filter component ends in a slash, then it must either match or be
+# a prefix of the caIssuer's URI path component (e.g. a filter path of
+# /ab/cd/ will match a caIssuer path of /ab/cd/, /ab/cd/ef and
+# /ab/cd/ef/ghi).
+# b. Query strings will be ignored in filter rules and caIssuer URIs.
+# c. Fragments will be ignored in filter rules and caIssuer URIs.
+# 5. For ldap URIs:
+# a. The base DN must be an exact match (case-insensitive).
+# b. Any query string in the rule, if specified, is ignored.
+# 6. A single value "any" (case-insensitive) will create an allow-all rule.
+#
+# As an example, here is a valid filter policy consisting of two rules:
+# com.sun.security.allowedAIALocations=http://some.company.com/cacert \
+# ldap://ldap.company.com/dc=company,dc=com?caCertificate;binary
+com.sun.security.allowedAIALocations=
diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows
index 19e474eecfd..02fa1c8b02c 100644
--- a/jdk/src/share/lib/security/java.security-windows
+++ b/jdk/src/share/lib/security/java.security-windows
@@ -1315,4 +1315,49 @@ jdk.tls.alpnCharset=ISO_8859_1
#
# The default pattern value allows any object factory class specified by the reference
# instance to recreate the referenced object.
-#jdk.jndi.object.factoriesFilter=*
\ No newline at end of file
+#jdk.jndi.object.factoriesFilter=*
+
+#
+# X.509 AuthorityInfoAccess caIssuer URI Filtering
+#
+# This property defines a whitespace-separated list of filters that
+# are applied to URIs found in the authorityInfoAccess extension in
+# X.509 certificates. Any caIssuers URIs in X.509 certificates are only
+# followed when the com.sun.security.enableAIAcaIssuers System property is
+# enabled and the filter allows the URI. By default this property imposes a
+# deny-all ruleset. This property may be overridden by a System property
+# of the same name.
+#
+# The filters must take the form of absolute, hierarchical URIs as defined by
+# the java.net.URI class. Additionally, only the following protocols are
+# allowed as filters: http, https, ldap and ftp.
+# See RFC 5280, section 4.2.2.1 for details about the types of URIs allowed for
+# the extension and their specific requirements.
+# The filter matching rules are applied to each CA issuer URI as follows:
+# 1. The scheme must match (case-insensitive).
+# 2. A hostname or address must be specified in the filter URI. It must match
+# the host or address in the caIssuers URI (case-insensitive). No name
+# resolution is performed on hostnames to match IP addresses.
+# 3. The port number must match. For filter and caIssuer URIs, when a port
+# number is omitted, the well-known port for that scheme will be used in the
+# comparison.
+# 4. For hierarchical filesystem schemes (e.g. http[s], ftp):
+# a. The normalized path portion of the filter URI is matched in a
+# case-sensitive manner. If the final component of the path does not end
+# in a slash (/), it is considered to be a file path component and must
+# be an exact match of the caIssuer's URI file path component. If the
+# final filter component ends in a slash, then it must either match or be
+# a prefix of the caIssuer's URI path component (e.g. a filter path of
+# /ab/cd/ will match a caIssuer path of /ab/cd/, /ab/cd/ef and
+# /ab/cd/ef/ghi).
+# b. Query strings will be ignored in filter rules and caIssuer URIs.
+# c. Fragments will be ignored in filter rules and caIssuer URIs.
+# 5. For ldap URIs:
+# a. The base DN must be an exact match (case-insensitive).
+# b. Any query string in the rule, if specified, is ignored.
+# 6. A single value "any" (case-insensitive) will create an allow-all rule.
+#
+# As an example, here is a valid filter policy consisting of two rules:
+# com.sun.security.allowedAIALocations=http://some.company.com/cacert \
+# ldap://ldap.company.com/dc=company,dc=com?caCertificate;binary
+com.sun.security.allowedAIALocations=
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/constants.h b/jdk/src/share/native/com/sun/java/util/jar/pack/constants.h
index f1a1f73edff..536003b53cd 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/constants.h
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/constants.h
@@ -223,7 +223,7 @@ enum {
AO_HAVE_FIELD_FLAGS_HI = 1<<10,
AO_HAVE_METHOD_FLAGS_HI = 1<<11,
AO_HAVE_CODE_FLAGS_HI = 1<<12,
- AO_UNUSED_MBZ = (-1)<<13, // options bits reserved for future use.
+ AO_UNUSED_MBZ = (int)((~0U)<<13), // options bits reserved for future use.
#define ARCHIVE_BIT_DO(F) \
F(AO_HAVE_SPECIAL_FORMATS) \
diff --git a/jdk/src/share/native/common/check_code.c b/jdk/src/share/native/common/check_code.c
index 0889c57f49d..2b43b3e46a3 100644
--- a/jdk/src/share/native/common/check_code.c
+++ b/jdk/src/share/native/common/check_code.c
@@ -1161,10 +1161,11 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
case JVM_OPC_if_acmpeq: case JVM_OPC_if_acmpne:
case JVM_OPC_goto: {
/* Set the ->operand to be the instruction number of the target. */
- int jump = (((signed char)(code[offset+1])) << 8) + code[offset+2];
+ int jump, target;
+ jump = (((signed char)(code[offset+1])) << 8) + code[offset+2];
if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal target of jump or branch");
- int target = offset + jump;
+ target = offset + jump;
this_idata->operand.i = code_data[target];
break;
}
@@ -1175,12 +1176,13 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
/* FALLTHROUGH */
case JVM_OPC_goto_w: {
/* Set the ->operand to be the instruction number of the target. */
- int jump = (((signed char)(code[offset+1])) << 24) +
+ int jump, target;
+ jump = (((signed char)(code[offset+1])) << 24) +
(code[offset+2] << 16) + (code[offset+3] << 8) +
(code[offset + 4]);
if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal target of jump or branch");
- int target = offset + jump;
+ target = offset + jump;
this_idata->operand.i = code_data[target];
break;
}
@@ -1193,6 +1195,7 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
int *saved_operand;
int keys;
int k, delta;
+ int jump, target;
if (context->major_version < NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION) {
/* 4639449, 4647081: Padding bytes must be zero. */
@@ -1219,10 +1222,10 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
}
}
saved_operand = NEW(int, keys + 2);
- int jump = _ck_ntohl(lpc[0]);
+ jump = _ck_ntohl(lpc[0]);
if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal default target in switch");
- int target = offset + jump;
+ target = offset + jump;
saved_operand[keys + 1] = code_data[target];
for (k = keys, lptr = &lpc[3]; --k >= 0; lptr += delta) {
jump = _ck_ntohl(lptr[0]);
@@ -1765,8 +1768,9 @@ isLegalOffset(context_type *context, int bci, int offset)
int *code_data = context->code_data;
int max_offset = 65535; // JVMS 4.11
int min_offset = -65535;
+ int target;
if (offset < min_offset || offset > max_offset) return JNI_FALSE;
- int target = bci + offset;
+ target = bci + offset;
return (target >= 0 && target < code_length && code_data[target] >= 0);
}
diff --git a/jdk/src/share/native/sun/awt/libfreetype/UPDATING.txt b/jdk/src/share/native/sun/awt/libfreetype/UPDATING.txt
new file mode 100644
index 00000000000..e7b9a3843d2
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/UPDATING.txt
@@ -0,0 +1,35 @@
+Tips and tasks when updating freetype sources to a newer version.
+-----------------------------------------------------------------
+
+The freetype sources here are just the subset needed by JDK. This is deliberate.
+When updating be sure to import only the same files.
+If a file is no longer present in freetype, or renamed this will be noticed
+during the copy.
+Occasionally there may be a new missing dependency if freetype introduces
+a new file or imports a file into these files that was not previously used.
+Import just what is needed.
+
+Before attempting compilation be sure to diff the JDK copy and the freetype copy
+of src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h
+and re-apply the same edits made for the JDK option file.
+Also modules the JDK does not include must be commented out in
+src/java.desktop/share/native/libfreetype/include/freetype/config/ftmodule.h.
+Notably JDK is not using GZIP or LZW or BDF support which are on by default
+for the freetype distribution.
+If you don't make the edits the build will fail due to not copying the relevant
+sources.
+
+Use "expand" and "sed" to remove tabs and trailing white space from the imported
+sources. The current version of freetype is quite clean in this respect.
+None of files we import have tabs, and ./include/freetype/freetype.h,
+and ./include/freetype/ftlcdfil.h have the only trailing white space.
+If you forget this step, or aren't thorough, jcheck will remind you.
+
+Remember to update the freetype version identified in
+src/java.desktop/share/legal/freetype.md
+
+When updating specify --with-freetype=bundled to test builds to
+expose build issues.
+This is important because presently on Linux the build
+defaults to linking against the system library and does not attempt
+to compile the sources.
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftconfig.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftconfig.h
new file mode 100644
index 00000000000..0667493fec6
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftconfig.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+ *
+ * ftconfig.h
+ *
+ * ANSI-specific configuration file (specification only).
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * This header file contains a number of macro definitions that are used by
+ * the rest of the engine. Most of the macros here are automatically
+ * determined at compile time, and you should not need to change it to port
+ * FreeType, except to compile the library with a non-ANSI compiler.
+ *
+ * Note however that if some specific modifications are needed, we advise
+ * you to place a modified copy in your build directory.
+ *
+ * The build directory is usually `builds/`, and contains
+ * system-specific files that are always included first when building the
+ * library.
+ *
+ * This ANSI version should stay in `include/config/`.
+ *
+ */
+
+#ifndef FTCONFIG_H_
+#define FTCONFIG_H_
+
+#include
+#include FT_CONFIG_OPTIONS_H
+#include FT_CONFIG_STANDARD_LIBRARY_H
+
+#include
+#include
+#include
+
+#endif /* FTCONFIG_H_ */
+
+
+/* END */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftheader.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftheader.h
new file mode 100644
index 00000000000..f6ef2618ded
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftheader.h
@@ -0,0 +1,836 @@
+/****************************************************************************
+ *
+ * ftheader.h
+ *
+ * Build macros of the FreeType 2 library.
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+#ifndef FTHEADER_H_
+#define FTHEADER_H_
+
+
+ /*@***********************************************************************/
+ /* */
+ /* */
+ /* FT_BEGIN_HEADER */
+ /* */
+ /* */
+ /* This macro is used in association with @FT_END_HEADER in header */
+ /* files to ensure that the declarations within are properly */
+ /* encapsulated in an `extern "C" { .. }` block when included from a */
+ /* C++ compiler. */
+ /* */
+#ifndef FT_BEGIN_HEADER
+# ifdef __cplusplus
+# define FT_BEGIN_HEADER extern "C" {
+# else
+# define FT_BEGIN_HEADER /* nothing */
+# endif
+#endif
+
+
+ /*@***********************************************************************/
+ /* */
+ /* */
+ /* FT_END_HEADER */
+ /* */
+ /* */
+ /* This macro is used in association with @FT_BEGIN_HEADER in header */
+ /* files to ensure that the declarations within are properly */
+ /* encapsulated in an `extern "C" { .. }` block when included from a */
+ /* C++ compiler. */
+ /* */
+#ifndef FT_END_HEADER
+# ifdef __cplusplus
+# define FT_END_HEADER }
+# else
+# define FT_END_HEADER /* nothing */
+# endif
+#endif
+
+
+ /**************************************************************************
+ *
+ * Aliases for the FreeType 2 public and configuration files.
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @section:
+ * header_file_macros
+ *
+ * @title:
+ * Header File Macros
+ *
+ * @abstract:
+ * Macro definitions used to `#include` specific header files.
+ *
+ * @description:
+ * In addition to the normal scheme of including header files like
+ *
+ * ```
+ * #include
+ * #include
+ * #include
+ * ```
+ *
+ * it is possible to used named macros instead. They can be used
+ * directly in `#include` statements as in
+ *
+ * ```
+ * #include FT_FREETYPE_H
+ * #include FT_MULTIPLE_MASTERS_H
+ * #include FT_GLYPH_H
+ * ```
+ *
+ * These macros were introduced to overcome the infamous 8.3~naming rule
+ * required by DOS (and `FT_MULTIPLE_MASTERS_H` is a lot more meaningful
+ * than `ftmm.h`).
+ *
+ */
+
+
+ /* configuration files */
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_CONFIG_CONFIG_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * FreeType~2 configuration data.
+ *
+ */
+#ifndef FT_CONFIG_CONFIG_H
+#define FT_CONFIG_CONFIG_H
+#endif
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_CONFIG_STANDARD_LIBRARY_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * FreeType~2 interface to the standard C library functions.
+ *
+ */
+#ifndef FT_CONFIG_STANDARD_LIBRARY_H
+#define FT_CONFIG_STANDARD_LIBRARY_H
+#endif
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_CONFIG_OPTIONS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * FreeType~2 project-specific configuration options.
+ *
+ */
+#ifndef FT_CONFIG_OPTIONS_H
+#define FT_CONFIG_OPTIONS_H
+#endif
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_CONFIG_MODULES_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * list of FreeType~2 modules that are statically linked to new library
+ * instances in @FT_Init_FreeType.
+ *
+ */
+#ifndef FT_CONFIG_MODULES_H
+#define FT_CONFIG_MODULES_H
+#endif
+
+ /* */
+
+ /* public headers */
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_FREETYPE_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * base FreeType~2 API.
+ *
+ */
+#define FT_FREETYPE_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_ERRORS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * list of FreeType~2 error codes (and messages).
+ *
+ * It is included by @FT_FREETYPE_H.
+ *
+ */
+#define FT_ERRORS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_MODULE_ERRORS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * list of FreeType~2 module error offsets (and messages).
+ *
+ */
+#define FT_MODULE_ERRORS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_SYSTEM_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 interface to low-level operations (i.e., memory management
+ * and stream i/o).
+ *
+ * It is included by @FT_FREETYPE_H.
+ *
+ */
+#define FT_SYSTEM_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IMAGE_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing type
+ * definitions related to glyph images (i.e., bitmaps, outlines,
+ * scan-converter parameters).
+ *
+ * It is included by @FT_FREETYPE_H.
+ *
+ */
+#define FT_IMAGE_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_TYPES_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * basic data types defined by FreeType~2.
+ *
+ * It is included by @FT_FREETYPE_H.
+ *
+ */
+#define FT_TYPES_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_LIST_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * list management API of FreeType~2.
+ *
+ * (Most applications will never need to include this file.)
+ *
+ */
+#define FT_LIST_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_OUTLINE_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * scalable outline management API of FreeType~2.
+ *
+ */
+#define FT_OUTLINE_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_SIZES_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * API which manages multiple @FT_Size objects per face.
+ *
+ */
+#define FT_SIZES_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_MODULE_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * module management API of FreeType~2.
+ *
+ */
+#define FT_MODULE_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_RENDER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * renderer module management API of FreeType~2.
+ *
+ */
+#define FT_RENDER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_DRIVER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * structures and macros related to the driver modules.
+ *
+ */
+#define FT_DRIVER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_AUTOHINTER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * structures and macros related to the auto-hinting module.
+ *
+ * Deprecated since version~2.9; use @FT_DRIVER_H instead.
+ *
+ */
+#define FT_AUTOHINTER_H FT_DRIVER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_CFF_DRIVER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * structures and macros related to the CFF driver module.
+ *
+ * Deprecated since version~2.9; use @FT_DRIVER_H instead.
+ *
+ */
+#define FT_CFF_DRIVER_H FT_DRIVER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_TRUETYPE_DRIVER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * structures and macros related to the TrueType driver module.
+ *
+ * Deprecated since version~2.9; use @FT_DRIVER_H instead.
+ *
+ */
+#define FT_TRUETYPE_DRIVER_H FT_DRIVER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_PCF_DRIVER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing
+ * structures and macros related to the PCF driver module.
+ *
+ * Deprecated since version~2.9; use @FT_DRIVER_H instead.
+ *
+ */
+#define FT_PCF_DRIVER_H FT_DRIVER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_TYPE1_TABLES_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * types and API specific to the Type~1 format.
+ *
+ */
+#define FT_TYPE1_TABLES_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_TRUETYPE_IDS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * enumeration values which identify name strings, languages, encodings,
+ * etc. This file really contains a _large_ set of constant macro
+ * definitions, taken from the TrueType and OpenType specifications.
+ *
+ */
+#define FT_TRUETYPE_IDS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_TRUETYPE_TABLES_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * types and API specific to the TrueType (as well as OpenType) format.
+ *
+ */
+#define FT_TRUETYPE_TABLES_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_TRUETYPE_TAGS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * definitions of TrueType four-byte 'tags' which identify blocks in
+ * SFNT-based font formats (i.e., TrueType and OpenType).
+ *
+ */
+#define FT_TRUETYPE_TAGS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_BDF_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * definitions of an API which accesses BDF-specific strings from a face.
+ *
+ */
+#define FT_BDF_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_CID_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * definitions of an API which access CID font information from a face.
+ *
+ */
+#define FT_CID_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_GZIP_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * definitions of an API which supports gzip-compressed files.
+ *
+ */
+#define FT_GZIP_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_LZW_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * definitions of an API which supports LZW-compressed files.
+ *
+ */
+#define FT_LZW_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_BZIP2_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * definitions of an API which supports bzip2-compressed files.
+ *
+ */
+#define FT_BZIP2_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_WINFONTS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * definitions of an API which supports Windows FNT files.
+ *
+ */
+#define FT_WINFONTS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_GLYPH_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * API of the optional glyph management component.
+ *
+ */
+#define FT_GLYPH_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_BITMAP_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * API of the optional bitmap conversion component.
+ *
+ */
+#define FT_BITMAP_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_BBOX_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * API of the optional exact bounding box computation routines.
+ *
+ */
+#define FT_BBOX_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_CACHE_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * API of the optional FreeType~2 cache sub-system.
+ *
+ */
+#define FT_CACHE_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_MAC_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * Macintosh-specific FreeType~2 API. The latter is used to access fonts
+ * embedded in resource forks.
+ *
+ * This header file must be explicitly included by client applications
+ * compiled on the Mac (note that the base API still works though).
+ *
+ */
+#define FT_MAC_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_MULTIPLE_MASTERS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * optional multiple-masters management API of FreeType~2.
+ *
+ */
+#define FT_MULTIPLE_MASTERS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_SFNT_NAMES_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * optional FreeType~2 API which accesses embedded 'name' strings in
+ * SFNT-based font formats (i.e., TrueType and OpenType).
+ *
+ */
+#define FT_SFNT_NAMES_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_OPENTYPE_VALIDATE_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * optional FreeType~2 API which validates OpenType tables ('BASE',
+ * 'GDEF', 'GPOS', 'GSUB', 'JSTF').
+ *
+ */
+#define FT_OPENTYPE_VALIDATE_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_GX_VALIDATE_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * optional FreeType~2 API which validates TrueTypeGX/AAT tables ('feat',
+ * 'mort', 'morx', 'bsln', 'just', 'kern', 'opbd', 'trak', 'prop').
+ *
+ */
+#define FT_GX_VALIDATE_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_PFR_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which accesses PFR-specific data.
+ *
+ */
+#define FT_PFR_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_STROKER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which provides functions to stroke outline paths.
+ */
+#define FT_STROKER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_SYNTHESIS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which performs artificial obliquing and emboldening.
+ */
+#define FT_SYNTHESIS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_FONT_FORMATS_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which provides functions specific to font formats.
+ */
+#define FT_FONT_FORMATS_H
+
+ /* deprecated */
+#define FT_XFREE86_H FT_FONT_FORMATS_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_TRIGONOMETRY_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which performs trigonometric computations (e.g.,
+ * cosines and arc tangents).
+ */
+#define FT_TRIGONOMETRY_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_LCD_FILTER_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which performs color filtering for subpixel rendering.
+ */
+#define FT_LCD_FILTER_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_INCREMENTAL_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which performs incremental glyph loading.
+ */
+#define FT_INCREMENTAL_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_GASP_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which returns entries from the TrueType GASP table.
+ */
+#define FT_GASP_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_ADVANCES_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which returns individual and ranged glyph advances.
+ */
+#define FT_ADVANCES_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_COLOR_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which handles the OpenType 'CPAL' table.
+ */
+#define FT_COLOR_H
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_OTSVG_H
+ *
+ * @description:
+ * A macro used in `#include` statements to name the file containing the
+ * FreeType~2 API which handles the OpenType 'SVG~' glyphs.
+ */
+#define FT_OTSVG_H
+
+
+ /* */
+
+ /* These header files don't need to be included by the user. */
+#define FT_ERROR_DEFINITIONS_H
+#define FT_PARAMETER_TAGS_H
+
+ /* Deprecated macros. */
+#define FT_UNPATENTED_HINTING_H
+#define FT_TRUETYPE_UNPATENTED_H
+
+ /* `FT_CACHE_H` is the only header file needed for the cache subsystem. */
+#define FT_CACHE_IMAGE_H FT_CACHE_H
+#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H
+#define FT_CACHE_CHARMAP_H FT_CACHE_H
+
+ /* The internals of the cache sub-system are no longer exposed. We */
+ /* default to `FT_CACHE_H` at the moment just in case, but we know */
+ /* of no rogue client that uses them. */
+ /* */
+#define FT_CACHE_MANAGER_H FT_CACHE_H
+#define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H
+#define FT_CACHE_INTERNAL_MANAGER_H FT_CACHE_H
+#define FT_CACHE_INTERNAL_CACHE_H FT_CACHE_H
+#define FT_CACHE_INTERNAL_GLYPH_H FT_CACHE_H
+#define FT_CACHE_INTERNAL_IMAGE_H FT_CACHE_H
+#define FT_CACHE_INTERNAL_SBITS_H FT_CACHE_H
+
+/* TODO(david): Move this section below to a different header */
+#ifdef FT2_BUILD_LIBRARY
+#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
+
+ /* We disable the warning `conditional expression is constant' here */
+ /* in order to compile cleanly with the maximum level of warnings. */
+ /* In particular, the warning complains about stuff like `while(0)' */
+ /* which is very useful in macro definitions. There is no benefit */
+ /* in having it enabled. */
+#pragma warning( disable : 4127 )
+
+#endif /* _MSC_VER */
+#endif /* FT2_BUILD_LIBRARY */
+
+#endif /* FTHEADER_H_ */
+
+
+/* END */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftmodule.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftmodule.h
new file mode 100644
index 00000000000..d908ce76bd1
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftmodule.h
@@ -0,0 +1,33 @@
+/*
+ * This file registers the FreeType modules compiled into the library.
+ *
+ * If you use GNU make, this file IS NOT USED! Instead, it is created in
+ * the objects directory (normally `/objs/`) based on information
+ * from `/modules.cfg`.
+ *
+ * Please read `docs/INSTALL.ANY` and `docs/CUSTOMIZE` how to compile
+ * FreeType without GNU make.
+ *
+ */
+
+FT_USE_MODULE( FT_Module_Class, autofit_module_class )
+FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
+FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
+FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
+FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
+// FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
+// FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
+// FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
+// FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
+// FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
+FT_USE_MODULE( FT_Module_Class, psaux_module_class )
+FT_USE_MODULE( FT_Module_Class, psnames_module_class )
+FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
+FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
+FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
+FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
+// FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
+// FT_USE_MODULE( FT_Renderer_Class, ft_bitmap_sdf_renderer_class )
+// FT_USE_MODULE( FT_Renderer_Class, ft_svg_renderer_class )
+
+/* EOF */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftoption.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftoption.h
new file mode 100644
index 00000000000..d29a0a7cefb
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftoption.h
@@ -0,0 +1,1030 @@
+/****************************************************************************
+ *
+ * ftoption.h
+ *
+ * User-selectable configuration macros (specification only).
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+#ifndef FTOPTION_H_
+#define FTOPTION_H_
+
+
+#include
+
+
+FT_BEGIN_HEADER
+
+ /**************************************************************************
+ *
+ * USER-SELECTABLE CONFIGURATION MACROS
+ *
+ * This file contains the default configuration macro definitions for a
+ * standard build of the FreeType library. There are three ways to use
+ * this file to build project-specific versions of the library:
+ *
+ * - You can modify this file by hand, but this is not recommended in
+ * cases where you would like to build several versions of the library
+ * from a single source directory.
+ *
+ * - You can put a copy of this file in your build directory, more
+ * precisely in `$BUILD/freetype/config/ftoption.h`, where `$BUILD` is
+ * the name of a directory that is included _before_ the FreeType include
+ * path during compilation.
+ *
+ * The default FreeType Makefiles use the build directory
+ * `builds/` by default, but you can easily change that for your
+ * own projects.
+ *
+ * - Copy the file to `$BUILD/ft2build.h` and modify it
+ * slightly to pre-define the macro `FT_CONFIG_OPTIONS_H` used to locate
+ * this file during the build. For example,
+ *
+ * ```
+ * #define FT_CONFIG_OPTIONS_H
+ * #include
+ * ```
+ *
+ * will use `$BUILD/myftoptions.h` instead of this file for macro
+ * definitions.
+ *
+ * Note also that you can similarly pre-define the macro
+ * `FT_CONFIG_MODULES_H` used to locate the file listing of the modules
+ * that are statically linked to the library at compile time. By
+ * default, this file is ``.
+ *
+ * We highly recommend using the third method whenever possible.
+ *
+ */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*#************************************************************************
+ *
+ * If you enable this configuration option, FreeType recognizes an
+ * environment variable called `FREETYPE_PROPERTIES`, which can be used to
+ * control the various font drivers and modules. The controllable
+ * properties are listed in the section @properties.
+ *
+ * You have to undefine this configuration option on platforms that lack
+ * the concept of environment variables (and thus don't have the `getenv`
+ * function), for example Windows CE.
+ *
+ * `FREETYPE_PROPERTIES` has the following syntax form (broken here into
+ * multiple lines for better readability).
+ *
+ * ```
+ *
+ * ':'
+ * '='
+ *
+ * ':'
+ * '='
+ * ...
+ * ```
+ *
+ * Example:
+ *
+ * ```
+ * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
+ * cff:no-stem-darkening=1
+ * ```
+ *
+ */
+#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+
+
+ /**************************************************************************
+ *
+ * Uncomment the line below if you want to activate LCD rendering
+ * technology similar to ClearType in this build of the library. This
+ * technology triples the resolution in the direction color subpixels. To
+ * mitigate color fringes inherent to this technology, you also need to
+ * explicitly set up LCD filtering.
+ *
+ * When this macro is not defined, FreeType offers alternative LCD
+ * rendering technology that produces excellent output.
+ */
+/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+
+
+ /**************************************************************************
+ *
+ * Many compilers provide a non-ANSI 64-bit data type that can be used by
+ * FreeType to speed up some computations. However, this will create some
+ * problems when compiling the library in strict ANSI mode.
+ *
+ * For this reason, the use of 64-bit integers is normally disabled when
+ * the `__STDC__` macro is defined. You can however disable this by
+ * defining the macro `FT_CONFIG_OPTION_FORCE_INT64` here.
+ *
+ * For most compilers, this will only create compilation warnings when
+ * building the library.
+ *
+ * ObNote: The compiler-specific 64-bit integers are detected in the
+ * file `ftconfig.h` either statically or through the `configure`
+ * script on supported platforms.
+ */
+#undef FT_CONFIG_OPTION_FORCE_INT64
+
+
+ /**************************************************************************
+ *
+ * If this macro is defined, do not try to use an assembler version of
+ * performance-critical functions (e.g., @FT_MulFix). You should only do
+ * that to verify that the assembler function works properly, or to execute
+ * benchmark tests of the various implementations.
+ */
+/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */
+
+
+ /**************************************************************************
+ *
+ * If this macro is defined, try to use an inlined assembler version of the
+ * @FT_MulFix function, which is a 'hotspot' when loading and hinting
+ * glyphs, and which should be executed as fast as possible.
+ *
+ * Note that if your compiler or CPU is not supported, this will default to
+ * the standard and portable implementation found in `ftcalc.c`.
+ */
+#define FT_CONFIG_OPTION_INLINE_MULFIX
+
+
+ /**************************************************************************
+ *
+ * LZW-compressed file support.
+ *
+ * FreeType now handles font files that have been compressed with the
+ * `compress` program. This is mostly used to parse many of the PCF
+ * files that come with various X11 distributions. The implementation
+ * uses NetBSD's `zopen` to partially uncompress the file on the fly (see
+ * `src/lzw/ftgzip.c`).
+ *
+ * Define this macro if you want to enable this 'feature'.
+ */
+/* #define FT_CONFIG_OPTION_USE_LZW */
+
+
+ /**************************************************************************
+ *
+ * Gzip-compressed file support.
+ *
+ * FreeType now handles font files that have been compressed with the
+ * `gzip` program. This is mostly used to parse many of the PCF files
+ * that come with XFree86. The implementation uses 'zlib' to partially
+ * uncompress the file on the fly (see `src/gzip/ftgzip.c`).
+ *
+ * Define this macro if you want to enable this 'feature'. See also the
+ * macro `FT_CONFIG_OPTION_SYSTEM_ZLIB` below.
+ */
+/* #define FT_CONFIG_OPTION_USE_ZLIB */
+
+
+ /**************************************************************************
+ *
+ * ZLib library selection
+ *
+ * This macro is only used when `FT_CONFIG_OPTION_USE_ZLIB` is defined.
+ * It allows FreeType's 'ftgzip' component to link to the system's
+ * installation of the ZLib library. This is useful on systems like
+ * Unix or VMS where it generally is already available.
+ *
+ * If you let it undefined, the component will use its own copy of the
+ * zlib sources instead. These have been modified to be included
+ * directly within the component and **not** export external function
+ * names. This allows you to link any program with FreeType _and_ ZLib
+ * without linking conflicts.
+ *
+ * Do not `#undef` this macro here since the build system might define
+ * it for certain configurations only.
+ *
+ * If you use a build system like cmake or the `configure` script,
+ * options set by those programs have precedence, overwriting the value
+ * here with the configured one.
+ *
+ * If you use the GNU make build system directly (that is, without the
+ * `configure` script) and you define this macro, you also have to pass
+ * `SYSTEM_ZLIB=yes` as an argument to make.
+ */
+/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */
+
+
+ /**************************************************************************
+ *
+ * Bzip2-compressed file support.
+ *
+ * FreeType now handles font files that have been compressed with the
+ * `bzip2` program. This is mostly used to parse many of the PCF files
+ * that come with XFree86. The implementation uses `libbz2` to partially
+ * uncompress the file on the fly (see `src/bzip2/ftbzip2.c`). Contrary
+ * to gzip, bzip2 currently is not included and need to use the system
+ * available bzip2 implementation.
+ *
+ * Define this macro if you want to enable this 'feature'.
+ *
+ * If you use a build system like cmake or the `configure` script,
+ * options set by those programs have precedence, overwriting the value
+ * here with the configured one.
+ */
+/* #define FT_CONFIG_OPTION_USE_BZIP2 */
+
+
+ /**************************************************************************
+ *
+ * Define to disable the use of file stream functions and types, `FILE`,
+ * `fopen`, etc. Enables the use of smaller system libraries on embedded
+ * systems that have multiple system libraries, some with or without file
+ * stream support, in the cases where file stream support is not necessary
+ * such as memory loading of font files.
+ */
+/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
+
+
+ /**************************************************************************
+ *
+ * PNG bitmap support.
+ *
+ * FreeType now handles loading color bitmap glyphs in the PNG format.
+ * This requires help from the external libpng library. Uncompressed
+ * color bitmaps do not need any external libraries and will be supported
+ * regardless of this configuration.
+ *
+ * Define this macro if you want to enable this 'feature'.
+ *
+ * If you use a build system like cmake or the `configure` script,
+ * options set by those programs have precedence, overwriting the value
+ * here with the configured one.
+ */
+/* #define FT_CONFIG_OPTION_USE_PNG */
+
+
+ /**************************************************************************
+ *
+ * HarfBuzz support.
+ *
+ * FreeType uses the HarfBuzz library to improve auto-hinting of OpenType
+ * fonts. If available, many glyphs not directly addressable by a font's
+ * character map will be hinted also.
+ *
+ * Define this macro if you want to enable this 'feature'.
+ *
+ * If you use a build system like cmake or the `configure` script,
+ * options set by those programs have precedence, overwriting the value
+ * here with the configured one.
+ */
+/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */
+
+
+ /**************************************************************************
+ *
+ * Brotli support.
+ *
+ * FreeType uses the Brotli library to provide support for decompressing
+ * WOFF2 streams.
+ *
+ * Define this macro if you want to enable this 'feature'.
+ *
+ * If you use a build system like cmake or the `configure` script,
+ * options set by those programs have precedence, overwriting the value
+ * here with the configured one.
+ */
+/* #define FT_CONFIG_OPTION_USE_BROTLI */
+
+
+ /**************************************************************************
+ *
+ * Glyph Postscript Names handling
+ *
+ * By default, FreeType 2 is compiled with the 'psnames' module. This
+ * module is in charge of converting a glyph name string into a Unicode
+ * value, or return a Macintosh standard glyph name for the use with the
+ * TrueType 'post' table.
+ *
+ * Undefine this macro if you do not want 'psnames' compiled in your
+ * build of FreeType. This has the following effects:
+ *
+ * - The TrueType driver will provide its own set of glyph names, if you
+ * build it to support postscript names in the TrueType 'post' table,
+ * but will not synthesize a missing Unicode charmap.
+ *
+ * - The Type~1 driver will not be able to synthesize a Unicode charmap
+ * out of the glyphs found in the fonts.
+ *
+ * You would normally undefine this configuration macro when building a
+ * version of FreeType that doesn't contain a Type~1 or CFF driver.
+ */
+#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
+
+ /**************************************************************************
+ *
+ * Postscript Names to Unicode Values support
+ *
+ * By default, FreeType~2 is built with the 'psnames' module compiled in.
+ * Among other things, the module is used to convert a glyph name into a
+ * Unicode value. This is especially useful in order to synthesize on
+ * the fly a Unicode charmap from the CFF/Type~1 driver through a big
+ * table named the 'Adobe Glyph List' (AGL).
+ *
+ * Undefine this macro if you do not want the Adobe Glyph List compiled
+ * in your 'psnames' module. The Type~1 driver will not be able to
+ * synthesize a Unicode charmap out of the glyphs found in the fonts.
+ */
+#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
+
+
+ /**************************************************************************
+ *
+ * Support for Mac fonts
+ *
+ * Define this macro if you want support for outline fonts in Mac format
+ * (mac dfont, mac resource, macbinary containing a mac resource) on
+ * non-Mac platforms.
+ *
+ * Note that the 'FOND' resource isn't checked.
+ */
+#define FT_CONFIG_OPTION_MAC_FONTS
+
+
+ /**************************************************************************
+ *
+ * Guessing methods to access embedded resource forks
+ *
+ * Enable extra Mac fonts support on non-Mac platforms (e.g., GNU/Linux).
+ *
+ * Resource forks which include fonts data are stored sometimes in
+ * locations which users or developers don't expected. In some cases,
+ * resource forks start with some offset from the head of a file. In
+ * other cases, the actual resource fork is stored in file different from
+ * what the user specifies. If this option is activated, FreeType tries
+ * to guess whether such offsets or different file names must be used.
+ *
+ * Note that normal, direct access of resource forks is controlled via
+ * the `FT_CONFIG_OPTION_MAC_FONTS` option.
+ */
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
+#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#endif
+
+
+ /**************************************************************************
+ *
+ * Allow the use of `FT_Incremental_Interface` to load typefaces that
+ * contain no glyph data, but supply it via a callback function. This is
+ * required by clients supporting document formats which supply font data
+ * incrementally as the document is parsed, such as the Ghostscript
+ * interpreter for the PostScript language.
+ */
+#define FT_CONFIG_OPTION_INCREMENTAL
+
+
+ /**************************************************************************
+ *
+ * The size in bytes of the render pool used by the scan-line converter to
+ * do all of its work.
+ */
+#define FT_RENDER_POOL_SIZE 16384L
+
+
+ /**************************************************************************
+ *
+ * FT_MAX_MODULES
+ *
+ * The maximum number of modules that can be registered in a single
+ * FreeType library object. 32~is the default.
+ */
+#define FT_MAX_MODULES 32
+
+
+ /**************************************************************************
+ *
+ * Debug level
+ *
+ * FreeType can be compiled in debug or trace mode. In debug mode,
+ * errors are reported through the 'ftdebug' component. In trace mode,
+ * additional messages are sent to the standard output during execution.
+ *
+ * Define `FT_DEBUG_LEVEL_ERROR` to build the library in debug mode.
+ * Define `FT_DEBUG_LEVEL_TRACE` to build it in trace mode.
+ *
+ * Don't define any of these macros to compile in 'release' mode!
+ *
+ * Do not `#undef` these macros here since the build system might define
+ * them for certain configurations only.
+ */
+/* #define FT_DEBUG_LEVEL_ERROR */
+/* #define FT_DEBUG_LEVEL_TRACE */
+
+
+ /**************************************************************************
+ *
+ * Logging
+ *
+ * Compiling FreeType in debug or trace mode makes FreeType write error
+ * and trace log messages to `stderr`. Enabling this macro
+ * automatically forces the `FT_DEBUG_LEVEL_ERROR` and
+ * `FT_DEBUG_LEVEL_TRACE` macros and allows FreeType to write error and
+ * trace log messages to a file instead of `stderr`. For writing logs
+ * to a file, FreeType uses an the external `dlg` library (the source
+ * code is in `src/dlg`).
+ *
+ * This option needs a C99 compiler.
+ */
+/* #define FT_DEBUG_LOGGING */
+
+
+ /**************************************************************************
+ *
+ * Autofitter debugging
+ *
+ * If `FT_DEBUG_AUTOFIT` is defined, FreeType provides some means to
+ * control the autofitter behaviour for debugging purposes with global
+ * boolean variables (consequently, you should **never** enable this
+ * while compiling in 'release' mode):
+ *
+ * ```
+ * af_debug_disable_horz_hints_
+ * af_debug_disable_vert_hints_
+ * af_debug_disable_blue_hints_
+ * ```
+ *
+ * Additionally, the following functions provide dumps of various
+ * internal autofit structures to stdout (using `printf`):
+ *
+ * ```
+ * af_glyph_hints_dump_points
+ * af_glyph_hints_dump_segments
+ * af_glyph_hints_dump_edges
+ * af_glyph_hints_get_num_segments
+ * af_glyph_hints_get_segment_offset
+ * ```
+ *
+ * As an argument, they use another global variable:
+ *
+ * ```
+ * af_debug_hints_
+ * ```
+ *
+ * Please have a look at the `ftgrid` demo program to see how those
+ * variables and macros should be used.
+ *
+ * Do not `#undef` these macros here since the build system might define
+ * them for certain configurations only.
+ */
+/* #define FT_DEBUG_AUTOFIT */
+
+
+ /**************************************************************************
+ *
+ * Memory Debugging
+ *
+ * FreeType now comes with an integrated memory debugger that is capable
+ * of detecting simple errors like memory leaks or double deletes. To
+ * compile it within your build of the library, you should define
+ * `FT_DEBUG_MEMORY` here.
+ *
+ * Note that the memory debugger is only activated at runtime when when
+ * the _environment_ variable `FT2_DEBUG_MEMORY` is defined also!
+ *
+ * Do not `#undef` this macro here since the build system might define it
+ * for certain configurations only.
+ */
+/* #define FT_DEBUG_MEMORY */
+
+
+ /**************************************************************************
+ *
+ * Module errors
+ *
+ * If this macro is set (which is _not_ the default), the higher byte of
+ * an error code gives the module in which the error has occurred, while
+ * the lower byte is the real error code.
+ *
+ * Setting this macro makes sense for debugging purposes only, since it
+ * would break source compatibility of certain programs that use
+ * FreeType~2.
+ *
+ * More details can be found in the files `ftmoderr.h` and `fterrors.h`.
+ */
+#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
+
+
+ /**************************************************************************
+ *
+ * OpenType SVG Glyph Support
+ *
+ * Setting this macro enables support for OpenType SVG glyphs. By
+ * default, FreeType can only fetch SVG documents. However, it can also
+ * render them if external rendering hook functions are plugged in at
+ * runtime.
+ *
+ * More details on the hooks can be found in file `otsvg.h`.
+ */
+/* #define FT_CONFIG_OPTION_SVG */
+
+
+ /**************************************************************************
+ *
+ * Error Strings
+ *
+ * If this macro is set, `FT_Error_String` will return meaningful
+ * descriptions. This is not enabled by default to reduce the overall
+ * size of FreeType.
+ *
+ * More details can be found in the file `fterrors.h`.
+ */
+/* #define FT_CONFIG_OPTION_ERROR_STRINGS */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** S F N T D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_EMBEDDED_BITMAPS` if you want to support
+ * embedded bitmaps in all formats using the 'sfnt' module (namely
+ * TrueType~& OpenType).
+ */
+#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_COLOR_LAYERS` if you want to support colored
+ * outlines (from the 'COLR'/'CPAL' tables) in all formats using the 'sfnt'
+ * module (namely TrueType~& OpenType).
+ */
+#define TT_CONFIG_OPTION_COLOR_LAYERS
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_POSTSCRIPT_NAMES` if you want to be able to
+ * load and enumerate Postscript names of glyphs in a TrueType or OpenType
+ * file.
+ *
+ * Note that if you do not compile the 'psnames' module by undefining the
+ * above `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` macro, the 'sfnt' module will
+ * contain additional code to read the PostScript name table from a font.
+ *
+ * (By default, the module uses 'psnames' to extract glyph names.)
+ */
+#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_SFNT_NAMES` if your applications need to access
+ * the internal name table in a SFNT-based format like TrueType or
+ * OpenType. The name table contains various strings used to describe the
+ * font, like family name, copyright, version, etc. It does not contain
+ * any glyph name though.
+ *
+ * Accessing SFNT names is done through the functions declared in
+ * `ftsnames.h`.
+ */
+#define TT_CONFIG_OPTION_SFNT_NAMES
+
+
+ /**************************************************************************
+ *
+ * TrueType CMap support
+ *
+ * Here you can fine-tune which TrueType CMap table format shall be
+ * supported.
+ */
+#define TT_CONFIG_CMAP_FORMAT_0
+#define TT_CONFIG_CMAP_FORMAT_2
+#define TT_CONFIG_CMAP_FORMAT_4
+#define TT_CONFIG_CMAP_FORMAT_6
+#define TT_CONFIG_CMAP_FORMAT_8
+#define TT_CONFIG_CMAP_FORMAT_10
+#define TT_CONFIG_CMAP_FORMAT_12
+#define TT_CONFIG_CMAP_FORMAT_13
+#define TT_CONFIG_CMAP_FORMAT_14
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` if you want to compile a
+ * bytecode interpreter in the TrueType driver.
+ *
+ * By undefining this, you will only compile the code necessary to load
+ * TrueType glyphs without hinting.
+ *
+ * Do not `#undef` this macro here, since the build system might define it
+ * for certain configurations only.
+ */
+#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_SUBPIXEL_HINTING` if you want to compile
+ * subpixel hinting support into the TrueType driver. This modifies the
+ * TrueType hinting mechanism when anything but `FT_RENDER_MODE_MONO` is
+ * requested.
+ *
+ * In particular, it modifies the bytecode interpreter to interpret (or
+ * not) instructions in a certain way so that all TrueType fonts look like
+ * they do in a Windows ClearType (DirectWrite) environment. See [1] for a
+ * technical overview on what this means. See `ttinterp.h` for more
+ * details on this option.
+ *
+ * The new default mode focuses on applying a minimal set of rules to all
+ * fonts indiscriminately so that modern and web fonts render well while
+ * legacy fonts render okay. The corresponding interpreter version is v40.
+ * The so-called Infinality mode (v38) is no longer available in FreeType.
+ *
+ * By undefining these, you get rendering behavior like on Windows without
+ * ClearType, i.e., Windows XP without ClearType enabled and Win9x
+ * (interpreter version v35). Or not, depending on how much hinting blood
+ * and testing tears the font designer put into a given font. If you
+ * define one or both subpixel hinting options, you can switch between
+ * between v35 and the ones you define (using `FT_Property_Set`).
+ *
+ * This option requires `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` to be
+ * defined.
+ *
+ * [1]
+ * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
+ */
+#define TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED` to compile the
+ * TrueType glyph loader to use Apple's definition of how to handle
+ * component offsets in composite glyphs.
+ *
+ * Apple and MS disagree on the default behavior of component offsets in
+ * composites. Apple says that they should be scaled by the scaling
+ * factors in the transformation matrix (roughly, it's more complex) while
+ * MS says they should not. OpenType defines two bits in the composite
+ * flags array which can be used to disambiguate, but old fonts will not
+ * have them.
+ *
+ * https://www.microsoft.com/typography/otspec/glyf.htm
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html
+ */
+#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_GX_VAR_SUPPORT` if you want to include support
+ * for Apple's distortable font technology ('fvar', 'gvar', 'cvar', and
+ * 'avar' tables). Tagged 'Font Variations', this is now part of OpenType
+ * also. This has many similarities to Type~1 Multiple Masters support.
+ */
+#define TT_CONFIG_OPTION_GX_VAR_SUPPORT
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_NO_BORING_EXPANSION` if you want to exclude
+ * support for 'boring' OpenType specification expansions.
+ *
+ * https://github.com/harfbuzz/boring-expansion-spec
+ *
+ * Right now, the following features are covered:
+ *
+ * - 'avar' version 2.0
+ *
+ * Most likely, this is a temporary configuration option to be removed in
+ * the near future, since it is assumed that eventually those features are
+ * added to the OpenType standard.
+ */
+/* #define TT_CONFIG_OPTION_NO_BORING_EXPANSION */
+
+
+ /**************************************************************************
+ *
+ * Define `TT_CONFIG_OPTION_BDF` if you want to include support for an
+ * embedded 'BDF~' table within SFNT-based bitmap formats.
+ */
+/* #define TT_CONFIG_OPTION_BDF */
+
+
+ /**************************************************************************
+ *
+ * Option `TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES` controls the maximum
+ * number of bytecode instructions executed for a single run of the
+ * bytecode interpreter, needed to prevent infinite loops. You don't want
+ * to change this except for very special situations (e.g., making a
+ * library fuzzer spend less time to handle broken fonts).
+ *
+ * It is not expected that this value is ever modified by a configuring
+ * script; instead, it gets surrounded with `#ifndef ... #endif` so that
+ * the value can be set as a preprocessor option on the compiler's command
+ * line.
+ */
+#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES
+#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L
+#endif
+
+
+ /**************************************************************************
+ *
+ * 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 */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /**************************************************************************
+ *
+ * `T1_MAX_DICT_DEPTH` is the maximum depth of nest dictionaries and arrays
+ * in the Type~1 stream (see `t1load.c`). A minimum of~4 is required.
+ */
+#define T1_MAX_DICT_DEPTH 5
+
+
+ /**************************************************************************
+ *
+ * `T1_MAX_SUBRS_CALLS` details the maximum number of nested sub-routine
+ * calls during glyph loading.
+ */
+#define T1_MAX_SUBRS_CALLS 16
+
+
+ /**************************************************************************
+ *
+ * `T1_MAX_CHARSTRING_OPERANDS` is the charstring stack's capacity. A
+ * minimum of~16 is required.
+ *
+ * The Chinese font 'MingTiEG-Medium' (covering the CNS 11643 character
+ * set) needs 256.
+ */
+#define T1_MAX_CHARSTRINGS_OPERANDS 256
+
+
+ /**************************************************************************
+ *
+ * Define this configuration macro if you want to prevent the compilation
+ * of the 't1afm' module, which is in charge of reading Type~1 AFM files
+ * into an existing face. Note that if set, the Type~1 driver will be
+ * unable to produce kerning distances.
+ */
+#undef T1_CONFIG_OPTION_NO_AFM
+
+
+ /**************************************************************************
+ *
+ * Define this configuration macro if you want to prevent the compilation
+ * of the Multiple Masters font support in the Type~1 driver.
+ */
+#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
+
+
+ /**************************************************************************
+ *
+ * `T1_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe Type~1
+ * engine gets compiled into FreeType. If defined, it is possible to
+ * switch between the two engines using the `hinting-engine` property of
+ * the 'type1' driver module.
+ */
+/* #define T1_CONFIG_OPTION_OLD_ENGINE */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** C F F D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /**************************************************************************
+ *
+ * Using `CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4}` it is
+ * possible to set up the default values of the four control points that
+ * define the stem darkening behaviour of the (new) CFF engine. For more
+ * details please read the documentation of the `darkening-parameters`
+ * property (file `ftdriver.h`), which allows the control at run-time.
+ *
+ * Do **not** undefine these macros!
+ */
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0
+
+
+ /**************************************************************************
+ *
+ * `CFF_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe CFF engine
+ * gets compiled into FreeType. If defined, it is possible to switch
+ * between the two engines using the `hinting-engine` property of the 'cff'
+ * driver module.
+ */
+/* #define CFF_CONFIG_OPTION_OLD_ENGINE */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** P C F D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /**************************************************************************
+ *
+ * There are many PCF fonts just called 'Fixed' which look completely
+ * different, and which have nothing to do with each other. When selecting
+ * 'Fixed' in KDE or Gnome one gets results that appear rather random, the
+ * style changes often if one changes the size and one cannot select some
+ * fonts at all. This option makes the 'pcf' module prepend the foundry
+ * name (plus a space) to the family name.
+ *
+ * We also check whether we have 'wide' characters; all put together, we
+ * get family names like 'Sony Fixed' or 'Misc Fixed Wide'.
+ *
+ * If this option is activated, it can be controlled with the
+ * `no-long-family-names` property of the 'pcf' driver module.
+ */
+/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /**************************************************************************
+ *
+ * Compile 'autofit' module with CJK (Chinese, Japanese, Korean) script
+ * support.
+ */
+#define AF_CONFIG_OPTION_CJK
+
+
+ /**************************************************************************
+ *
+ * Compile 'autofit' module with fallback Indic script support, covering
+ * some scripts that the 'latin' submodule of the 'autofit' module doesn't
+ * (yet) handle. Currently, this needs option `AF_CONFIG_OPTION_CJK`.
+ */
+#ifdef AF_CONFIG_OPTION_CJK
+#define AF_CONFIG_OPTION_INDIC
+#endif
+
+
+ /**************************************************************************
+ *
+ * Use TrueType-like size metrics for 'light' auto-hinting.
+ *
+ * It is strongly recommended to avoid this option, which exists only to
+ * help some legacy applications retain its appearance and behaviour with
+ * respect to auto-hinted TrueType fonts.
+ *
+ * The very reason this option exists at all are GNU/Linux distributions
+ * like Fedora that did not un-patch the following change (which was
+ * present in FreeType between versions 2.4.6 and 2.7.1, inclusive).
+ *
+ * ```
+ * 2011-07-16 Steven Chu
+ *
+ * [truetype] Fix metrics on size request for scalable fonts.
+ * ```
+ *
+ * This problematic commit is now reverted (more or less).
+ */
+/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */
+
+ /* */
+
+
+ /*
+ * This macro is obsolete. Support has been removed in FreeType version
+ * 2.5.
+ */
+/* #define FT_CONFIG_OPTION_OLD_INTERNALS */
+
+
+ /*
+ * The next two macros are defined if native TrueType hinting is
+ * requested by the definitions above. Don't change this.
+ */
+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#define TT_USE_BYTECODE_INTERPRETER
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#define TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+#endif
+#endif
+
+
+ /*
+ * The TT_SUPPORT_COLRV1 macro is defined to indicate to clients that this
+ * version of FreeType has support for 'COLR' v1 API. This definition is
+ * useful to FreeType clients that want to build in support for 'COLR' v1
+ * depending on a tip-of-tree checkout before it is officially released in
+ * FreeType, and while the feature cannot yet be tested against using
+ * version macros. Don't change this macro. This may be removed once the
+ * feature is in a FreeType release version and version macros can be used
+ * to test for availability.
+ */
+#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
+#define TT_SUPPORT_COLRV1
+#endif
+
+
+ /*
+ * Check CFF darkening parameters. The checks are the same as in function
+ * `cff_property_set` in file `cffdrivr.c`.
+ */
+#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \
+ \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \
+ \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \
+ \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \
+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500
+#error "Invalid CFF darkening parameters!"
+#endif
+
+
+FT_END_HEADER
+
+#endif /* FTOPTION_H_ */
+
+
+/* END */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftstdlib.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftstdlib.h
new file mode 100644
index 00000000000..e17aa7b89d5
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/ftstdlib.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+ *
+ * ftstdlib.h
+ *
+ * ANSI-specific library and header configuration file (specification
+ * only).
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * This file is used to group all `#includes` to the ANSI~C library that
+ * FreeType normally requires. It also defines macros to rename the
+ * standard functions within the FreeType source code.
+ *
+ * Load a file which defines `FTSTDLIB_H_` before this one to override it.
+ *
+ */
+
+
+#ifndef FTSTDLIB_H_
+#define FTSTDLIB_H_
+
+
+#include
+
+#define ft_ptrdiff_t ptrdiff_t
+
+
+ /**************************************************************************
+ *
+ * integer limits
+ *
+ * `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of
+ * `int` and `long` in bytes at compile-time. So far, this works for all
+ * platforms the library has been tested on. We also check `ULLONG_MAX`
+ * to see whether we can use 64-bit `long long` later on.
+ *
+ * Note that on the extremely rare platforms that do not provide integer
+ * types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where
+ * `int` is 36~bits), we do not make any guarantee about the correct
+ * behaviour of FreeType~2 with all fonts.
+ *
+ * In these cases, `ftconfig.h` will refuse to compile anyway with a
+ * message like 'couldn't find 32-bit type' or something similar.
+ *
+ */
+
+
+#include
+
+#define FT_CHAR_BIT CHAR_BIT
+#define FT_USHORT_MAX USHRT_MAX
+#define FT_INT_MAX INT_MAX
+#define FT_INT_MIN INT_MIN
+#define FT_UINT_MAX UINT_MAX
+#define FT_LONG_MIN LONG_MIN
+#define FT_LONG_MAX LONG_MAX
+#define FT_ULONG_MAX ULONG_MAX
+#ifdef LLONG_MAX
+#define FT_LLONG_MAX LLONG_MAX
+#endif
+#ifdef LLONG_MIN
+#define FT_LLONG_MIN LLONG_MIN
+#endif
+#ifdef ULLONG_MAX
+#define FT_ULLONG_MAX ULLONG_MAX
+#endif
+
+
+ /**************************************************************************
+ *
+ * character and string processing
+ *
+ */
+
+
+#include
+
+#define ft_memchr memchr
+#define ft_memcmp memcmp
+#define ft_memcpy memcpy
+#define ft_memmove memmove
+#define ft_memset memset
+#define ft_strcat strcat
+#define ft_strcmp strcmp
+#define ft_strcpy strcpy
+#define ft_strlen strlen
+#define ft_strncmp strncmp
+#define ft_strncpy strncpy
+#define ft_strrchr strrchr
+#define ft_strstr strstr
+
+
+ /**************************************************************************
+ *
+ * file handling
+ *
+ */
+
+
+#include
+
+#define FT_FILE FILE
+#define ft_fclose fclose
+#define ft_fopen fopen
+#define ft_fread fread
+#define ft_fseek fseek
+#define ft_ftell ftell
+#define ft_snprintf snprintf
+
+
+ /**************************************************************************
+ *
+ * sorting
+ *
+ */
+
+
+#include
+
+#define ft_qsort qsort
+
+
+ /**************************************************************************
+ *
+ * memory allocation
+ *
+ */
+
+
+#define ft_scalloc calloc
+#define ft_sfree free
+#define ft_smalloc malloc
+#define ft_srealloc realloc
+
+
+ /**************************************************************************
+ *
+ * miscellaneous
+ *
+ */
+
+
+#define ft_strtol strtol
+#define ft_getenv getenv
+
+
+ /**************************************************************************
+ *
+ * execution control
+ *
+ */
+
+
+#include
+
+#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
+ /* `jmp_buf` is defined as a macro */
+ /* on certain platforms */
+
+#define ft_longjmp longjmp
+#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
+
+
+ /* The following is only used for debugging purposes, i.e., if */
+ /* `FT_DEBUG_LEVEL_ERROR` or `FT_DEBUG_LEVEL_TRACE` are defined. */
+
+#include
+
+
+#endif /* FTSTDLIB_H_ */
+
+
+/* END */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/integer-types.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/integer-types.h
new file mode 100644
index 00000000000..c27505ffc4b
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/integer-types.h
@@ -0,0 +1,250 @@
+/****************************************************************************
+ *
+ * config/integer-types.h
+ *
+ * FreeType integer types definitions.
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+#ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_
+#define FREETYPE_CONFIG_INTEGER_TYPES_H_
+
+ /* There are systems (like the Texas Instruments 'C54x) where a `char` */
+ /* has 16~bits. ANSI~C says that `sizeof(char)` is always~1. Since an */
+ /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which */
+ /* is probably unexpected. */
+ /* */
+ /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */
+ /* `char` type. */
+
+#ifndef FT_CHAR_BIT
+#define FT_CHAR_BIT CHAR_BIT
+#endif
+
+#ifndef FT_SIZEOF_INT
+
+ /* The size of an `int` type. */
+#if FT_UINT_MAX == 0xFFFFUL
+#define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT )
+#elif FT_UINT_MAX == 0xFFFFFFFFUL
+#define FT_SIZEOF_INT ( 32 / FT_CHAR_BIT )
+#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
+#define FT_SIZEOF_INT ( 64 / FT_CHAR_BIT )
+#else
+#error "Unsupported size of `int' type!"
+#endif
+
+#endif /* !defined(FT_SIZEOF_INT) */
+
+#ifndef FT_SIZEOF_LONG
+
+ /* The size of a `long` type. A five-byte `long` (as used e.g. on the */
+ /* DM642) is recognized but avoided. */
+#if FT_ULONG_MAX == 0xFFFFFFFFUL
+#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
+#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
+#define FT_SIZEOF_LONG ( 64 / FT_CHAR_BIT )
+#else
+#error "Unsupported size of `long' type!"
+#endif
+
+#endif /* !defined(FT_SIZEOF_LONG) */
+
+#ifndef FT_SIZEOF_LONG_LONG
+
+ /* The size of a `long long` type if available */
+#if defined( FT_ULLONG_MAX ) && FT_ULLONG_MAX >= 0xFFFFFFFFFFFFFFFFULL
+#define FT_SIZEOF_LONG_LONG ( 64 / FT_CHAR_BIT )
+#else
+#define FT_SIZEOF_LONG_LONG 0
+#endif
+
+#endif /* !defined(FT_SIZEOF_LONG_LONG) */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * basic_types
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Int16
+ *
+ * @description:
+ * A typedef for a 16bit signed integer type.
+ */
+ typedef signed short FT_Int16;
+
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_UInt16
+ *
+ * @description:
+ * A typedef for a 16bit unsigned integer type.
+ */
+ typedef unsigned short FT_UInt16;
+
+ /* */
+
+
+ /* this #if 0 ... #endif clause is for documentation purposes */
+#if 0
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Int32
+ *
+ * @description:
+ * A typedef for a 32bit signed integer type. The size depends on the
+ * configuration.
+ */
+ typedef signed XXX FT_Int32;
+
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_UInt32
+ *
+ * A typedef for a 32bit unsigned integer type. The size depends on the
+ * configuration.
+ */
+ typedef unsigned XXX FT_UInt32;
+
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Int64
+ *
+ * A typedef for a 64bit signed integer type. The size depends on the
+ * configuration. Only defined if there is real 64bit support;
+ * otherwise, it gets emulated with a structure (if necessary).
+ */
+ typedef signed XXX FT_Int64;
+
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_UInt64
+ *
+ * A typedef for a 64bit unsigned integer type. The size depends on the
+ * configuration. Only defined if there is real 64bit support;
+ * otherwise, it gets emulated with a structure (if necessary).
+ */
+ typedef unsigned XXX FT_UInt64;
+
+ /* */
+
+#endif
+
+#if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT )
+
+ typedef signed int FT_Int32;
+ typedef unsigned int FT_UInt32;
+
+#elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
+
+ typedef signed long FT_Int32;
+ typedef unsigned long FT_UInt32;
+
+#else
+#error "no 32bit type found -- please check your configuration files"
+#endif
+
+
+ /* look up an integer type that is at least 32~bits */
+#if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT )
+
+ typedef int FT_Fast;
+ typedef unsigned int FT_UFast;
+
+#elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT )
+
+ typedef long FT_Fast;
+ typedef unsigned long FT_UFast;
+
+#endif
+
+
+ /* determine whether we have a 64-bit integer type */
+#if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
+
+#define FT_INT64 long
+#define FT_UINT64 unsigned long
+
+#elif FT_SIZEOF_LONG_LONG >= ( 64 / FT_CHAR_BIT )
+
+#define FT_INT64 long long int
+#define FT_UINT64 unsigned long long int
+
+ /**************************************************************************
+ *
+ * A 64-bit data type may create compilation problems if you compile in
+ * strict ANSI mode. To avoid them, we disable other 64-bit data types if
+ * `__STDC__` is defined. You can however ignore this rule by defining the
+ * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro.
+ */
+#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
+
+#if defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
+
+ /* this compiler provides the `__int64` type */
+#define FT_INT64 __int64
+#define FT_UINT64 unsigned __int64
+
+#elif defined( __BORLANDC__ ) /* Borland C++ */
+
+ /* XXXX: We should probably check the value of `__BORLANDC__` in order */
+ /* to test the compiler version. */
+
+ /* this compiler provides the `__int64` type */
+#define FT_INT64 __int64
+#define FT_UINT64 unsigned __int64
+
+#elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1100 /* Watcom C++ */
+
+#define FT_INT64 long long int
+#define FT_UINT64 unsigned long long int
+
+#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
+
+#define FT_INT64 long long int
+#define FT_UINT64 unsigned long long int
+
+#elif defined( __GNUC__ )
+
+ /* GCC provides the `long long` type */
+#define FT_INT64 long long int
+#define FT_UINT64 unsigned long long int
+
+#endif /* !__STDC__ */
+
+#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
+
+#ifdef FT_INT64
+ typedef FT_INT64 FT_Int64;
+ typedef FT_UINT64 FT_UInt64;
+#endif
+
+
+#endif /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/mac-support.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/mac-support.h
new file mode 100644
index 00000000000..07b6f915bd8
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/mac-support.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+ *
+ * config/mac-support.h
+ *
+ * Mac/OS X support configuration header.
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+#ifndef FREETYPE_CONFIG_MAC_SUPPORT_H_
+#define FREETYPE_CONFIG_MAC_SUPPORT_H_
+
+ /**************************************************************************
+ *
+ * Mac support
+ *
+ * This is the only necessary change, so it is defined here instead
+ * providing a new configuration file.
+ */
+#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
+ /* No Carbon frameworks for 64bit 10.4.x. */
+ /* `AvailabilityMacros.h` is available since Mac OS X 10.2, */
+ /* so guess the system version by maximum errno before inclusion. */
+#include
+#ifdef ECANCELED /* defined since 10.2 */
+#include "AvailabilityMacros.h"
+#endif
+#if defined( __LP64__ ) && \
+ ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
+#undef FT_MACINTOSH
+#endif
+
+#elif defined( __SC__ ) || defined( __MRC__ )
+ /* Classic MacOS compilers */
+#include "ConditionalMacros.h"
+#if TARGET_OS_MAC
+#define FT_MACINTOSH 1
+#endif
+
+#endif /* Mac support */
+
+#endif /* FREETYPE_CONFIG_MAC_SUPPORT_H_ */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/public-macros.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/public-macros.h
new file mode 100644
index 00000000000..f56581a6ee7
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/config/public-macros.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+ *
+ * config/public-macros.h
+ *
+ * Define a set of compiler macros used in public FreeType headers.
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+ /*
+ * The definitions in this file are used by the public FreeType headers
+ * and thus should be considered part of the public API.
+ *
+ * Other compiler-specific macro definitions that are not exposed by the
+ * FreeType API should go into
+ * `include/freetype/internal/compiler-macros.h` instead.
+ */
+#ifndef FREETYPE_CONFIG_PUBLIC_MACROS_H_
+#define FREETYPE_CONFIG_PUBLIC_MACROS_H_
+
+ /*
+ * `FT_BEGIN_HEADER` and `FT_END_HEADER` might have already been defined
+ * by `freetype/config/ftheader.h`, but we don't want to include this
+ * header here, so redefine the macros here only when needed. Their
+ * definition is very stable, so keeping them in sync with the ones in the
+ * header should not be a maintenance issue.
+ */
+#ifndef FT_BEGIN_HEADER
+#ifdef __cplusplus
+#define FT_BEGIN_HEADER extern "C" {
+#else
+#define FT_BEGIN_HEADER /* empty */
+#endif
+#endif /* FT_BEGIN_HEADER */
+
+#ifndef FT_END_HEADER
+#ifdef __cplusplus
+#define FT_END_HEADER }
+#else
+#define FT_END_HEADER /* empty */
+#endif
+#endif /* FT_END_HEADER */
+
+
+FT_BEGIN_HEADER
+
+ /*
+ * Mark a function declaration as public. This ensures it will be
+ * properly exported to client code. Place this before a function
+ * declaration.
+ *
+ * NOTE: This macro should be considered an internal implementation
+ * detail, and not part of the FreeType API. It is only defined here
+ * because it is needed by `FT_EXPORT`.
+ */
+
+ /* Visual C, mingw */
+#if defined( _WIN32 )
+
+#if defined( FT2_BUILD_LIBRARY ) && defined( DLL_EXPORT )
+#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllexport )
+#elif defined( DLL_IMPORT )
+#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllimport )
+#endif
+
+ /* gcc, clang */
+#elif ( defined( __GNUC__ ) && __GNUC__ >= 4 ) || defined( __clang__ )
+#define FT_PUBLIC_FUNCTION_ATTRIBUTE \
+ __attribute__(( visibility( "default" ) ))
+
+ /* Sun */
+#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550
+#define FT_PUBLIC_FUNCTION_ATTRIBUTE __global
+#endif
+
+
+#ifndef FT_PUBLIC_FUNCTION_ATTRIBUTE
+#define FT_PUBLIC_FUNCTION_ATTRIBUTE /* empty */
+#endif
+
+
+ /*
+ * Define a public FreeType API function. This ensures it is properly
+ * exported or imported at build time. The macro parameter is the
+ * function's return type as in:
+ *
+ * FT_EXPORT( FT_Bool )
+ * FT_Object_Method( FT_Object obj,
+ * ... );
+ *
+ * NOTE: This requires that all `FT_EXPORT` uses are inside
+ * `FT_BEGIN_HEADER ... FT_END_HEADER` blocks. This guarantees that the
+ * functions are exported with C linkage, even when the header is included
+ * by a C++ source file.
+ */
+#define FT_EXPORT( x ) FT_PUBLIC_FUNCTION_ATTRIBUTE extern x
+
+
+ /*
+ * `FT_UNUSED` indicates that a given parameter is not used -- this is
+ * only used to get rid of unpleasant compiler warnings.
+ *
+ * Technically, this was not meant to be part of the public API, but some
+ * third-party code depends on it.
+ */
+#ifndef FT_UNUSED
+#define FT_UNUSED( arg ) ( (arg) = (arg) )
+#endif
+
+
+ /*
+ * Support for casts in both C and C++.
+ */
+#ifdef __cplusplus
+#define FT_STATIC_CAST( type, var ) static_cast(var)
+#define FT_REINTERPRET_CAST( type, var ) reinterpret_cast(var)
+
+#define FT_STATIC_BYTE_CAST( type, var ) \
+ static_cast( static_cast( var ) )
+#else
+#define FT_STATIC_CAST( type, var ) (type)(var)
+#define FT_REINTERPRET_CAST( type, var ) (type)(var)
+
+#define FT_STATIC_BYTE_CAST( type, var ) (type)(unsigned char)(var)
+#endif
+
+
+FT_END_HEADER
+
+#endif /* FREETYPE_CONFIG_PUBLIC_MACROS_H_ */
diff --git a/jdk/src/share/native/sun/awt/libfreetype/include/freetype/freetype.h b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/freetype.h
new file mode 100644
index 00000000000..58fc33dfe60
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/libfreetype/include/freetype/freetype.h
@@ -0,0 +1,5289 @@
+/****************************************************************************
+ *
+ * freetype.h
+ *
+ * FreeType high-level API and common types (specification only).
+ *
+ * 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,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+#ifndef FREETYPE_H_
+#define FREETYPE_H_
+
+
+#include
+#include FT_CONFIG_CONFIG_H
+#include
+#include
+
+
+FT_BEGIN_HEADER
+
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * preamble
+ *
+ * @title:
+ * Preamble
+ *
+ * @abstract:
+ * What FreeType is and isn't
+ *
+ * @description:
+ * FreeType is a library that provides access to glyphs in font files. It
+ * scales the glyph images and their metrics to a requested size, and it
+ * rasterizes the glyph images to produce pixel or subpixel alpha coverage
+ * bitmaps.
+ *
+ * Note that FreeType is _not_ a text layout engine. You have to use
+ * higher-level libraries like HarfBuzz, Pango, or ICU for that.
+ *
+ * Note also that FreeType does _not_ perform alpha blending or
+ * compositing the resulting bitmaps or pixmaps by itself. Use your
+ * favourite graphics library (for example, Cairo or Skia) to further
+ * process FreeType's output.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * header_inclusion
+ *
+ * @title:
+ * FreeType's header inclusion scheme
+ *
+ * @abstract:
+ * How client applications should include FreeType header files.
+ *
+ * @description:
+ * To be as flexible as possible (and for historical reasons), you must
+ * load file `ft2build.h` first before other header files, for example
+ *
+ * ```
+ * #include
+ *
+ * #include
+ * #include
+ * ```
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * user_allocation
+ *
+ * @title:
+ * User allocation
+ *
+ * @abstract:
+ * How client applications should allocate FreeType data structures.
+ *
+ * @description:
+ * FreeType assumes that structures allocated by the user and passed as
+ * arguments are zeroed out except for the actual data. In other words,
+ * it is recommended to use `calloc` (or variants of it) instead of
+ * `malloc` for allocation.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * font_testing_macros
+ *
+ * @title:
+ * Font Testing Macros
+ *
+ * @abstract:
+ * Macros to test various properties of fonts.
+ *
+ * @description:
+ * Macros to test the most important font properties.
+ *
+ * It is recommended to use these high-level macros instead of directly
+ * testing the corresponding flags, which are scattered over various
+ * structures.
+ *
+ * @order:
+ * FT_HAS_HORIZONTAL
+ * FT_HAS_VERTICAL
+ * FT_HAS_KERNING
+ * FT_HAS_FIXED_SIZES
+ * FT_HAS_GLYPH_NAMES
+ * FT_HAS_COLOR
+ * FT_HAS_MULTIPLE_MASTERS
+ * FT_HAS_SVG
+ * FT_HAS_SBIX
+ * FT_HAS_SBIX_OVERLAY
+ *
+ * FT_IS_SFNT
+ * FT_IS_SCALABLE
+ * FT_IS_FIXED_WIDTH
+ * FT_IS_CID_KEYED
+ * FT_IS_TRICKY
+ * FT_IS_NAMED_INSTANCE
+ * FT_IS_VARIATION
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * library_setup
+ *
+ * @title:
+ * Library Setup
+ *
+ * @abstract:
+ * Functions to start and end the usage of the FreeType library.
+ *
+ * @description:
+ * Functions to start and end the usage of the FreeType library.
+ *
+ * Note that @FT_Library_Version and @FREETYPE_XXX are of limited use
+ * because even a new release of FreeType with only documentation
+ * changes increases the version number.
+ *
+ * @order:
+ * FT_Library
+ * FT_Init_FreeType
+ * FT_Done_FreeType
+ *
+ * FT_Library_Version
+ * FREETYPE_XXX
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * face_creation
+ *
+ * @title:
+ * Face Creation
+ *
+ * @abstract:
+ * Functions to manage fonts.
+ *
+ * @description:
+ * The functions and structures collected in this section operate on
+ * fonts globally.
+ *
+ * @order:
+ * FT_Face
+ * FT_FaceRec
+ * FT_FACE_FLAG_XXX
+ * FT_STYLE_FLAG_XXX
+ *
+ * FT_New_Face
+ * FT_Done_Face
+ * FT_Reference_Face
+ * FT_New_Memory_Face
+ * FT_Face_Properties
+ * FT_Open_Face
+ * FT_Open_Args
+ * FT_OPEN_XXX
+ * FT_Parameter
+ * FT_Attach_File
+ * FT_Attach_Stream
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * sizing_and_scaling
+ *
+ * @title:
+ * Sizing and Scaling
+ *
+ * @abstract:
+ * Functions to manage font sizes.
+ *
+ * @description:
+ * The functions and structures collected in this section are related to
+ * selecting and manipulating the size of a font globally.
+ *
+ * @order:
+ * FT_Size
+ * FT_SizeRec
+ * FT_Size_Metrics
+ *
+ * FT_Bitmap_Size
+ *
+ * FT_Set_Char_Size
+ * FT_Set_Pixel_Sizes
+ * FT_Request_Size
+ * FT_Select_Size
+ * FT_Size_Request_Type
+ * FT_Size_RequestRec
+ * FT_Size_Request
+ *
+ * FT_Set_Transform
+ * FT_Get_Transform
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * glyph_retrieval
+ *
+ * @title:
+ * Glyph Retrieval
+ *
+ * @abstract:
+ * Functions to manage glyphs.
+ *
+ * @description:
+ * The functions and structures collected in this section operate on
+ * single glyphs, of which @FT_Load_Glyph is most important.
+ *
+ * @order:
+ * FT_GlyphSlot
+ * FT_GlyphSlotRec
+ * FT_Glyph_Metrics
+ *
+ * FT_Load_Glyph
+ * FT_LOAD_XXX
+ * FT_LOAD_TARGET_MODE
+ * FT_LOAD_TARGET_XXX
+ *
+ * FT_Render_Glyph
+ * FT_Render_Mode
+ * FT_Get_Kerning
+ * FT_Kerning_Mode
+ * FT_Get_Track_Kerning
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * character_mapping
+ *
+ * @title:
+ * Character Mapping
+ *
+ * @abstract:
+ * Functions to manage character-to-glyph maps.
+ *
+ * @description:
+ * This section holds functions and structures that are related to
+ * mapping character input codes to glyph indices.
+ *
+ * Note that for many scripts the simplistic approach used by FreeType
+ * of mapping a single character to a single glyph is not valid or
+ * possible! In general, a higher-level library like HarfBuzz or ICU
+ * should be used for handling text strings.
+ *
+ * @order:
+ * FT_CharMap
+ * FT_CharMapRec
+ * FT_Encoding
+ * FT_ENC_TAG
+ *
+ * FT_Select_Charmap
+ * FT_Set_Charmap
+ * FT_Get_Charmap_Index
+ *
+ * FT_Get_Char_Index
+ * FT_Get_First_Char
+ * FT_Get_Next_Char
+ * FT_Load_Char
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * information_retrieval
+ *
+ * @title:
+ * Information Retrieval
+ *
+ * @abstract:
+ * Functions to retrieve font and glyph information.
+ *
+ * @description:
+ * Functions to retrieve font and glyph information. Only some very
+ * basic data is covered; see also the chapter on the format-specific
+ * API for more.
+ *
+ *
+ * @order:
+ * FT_Get_Name_Index
+ * FT_Get_Glyph_Name
+ * FT_Get_Postscript_Name
+ * FT_Get_FSType_Flags
+ * FT_FSTYPE_XXX
+ * FT_Get_SubGlyph_Info
+ * FT_SUBGLYPH_FLAG_XXX
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * other_api_data
+ *
+ * @title:
+ * Other API Data
+ *
+ * @abstract:
+ * Other structures, enumerations, and macros.
+ *
+ * @description:
+ * Other structures, enumerations, and macros. Deprecated functions are
+ * also listed here.
+ *
+ * @order:
+ * FT_Face_Internal
+ * FT_Size_Internal
+ * FT_Slot_Internal
+ *
+ * FT_SubGlyph
+ *
+ * FT_HAS_FAST_GLYPHS
+ * FT_Face_CheckTrueTypePatents
+ * FT_Face_SetUnpatentedHinting
+ *
+ */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* B A S I C T Y P E S */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * glyph_retrieval
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @struct:
+ * FT_Glyph_Metrics
+ *
+ * @description:
+ * A structure to model the metrics of a single glyph. The values are
+ * expressed in 26.6 fractional pixel format; if the flag
+ * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are
+ * expressed in font units instead.
+ *
+ * @fields:
+ * width ::
+ * The glyph's width.
+ *
+ * height ::
+ * The glyph's height.
+ *
+ * horiBearingX ::
+ * Left side bearing for horizontal layout.
+ *
+ * horiBearingY ::
+ * Top side bearing for horizontal layout.
+ *
+ * horiAdvance ::
+ * Advance width for horizontal layout.
+ *
+ * vertBearingX ::
+ * Left side bearing for vertical layout.
+ *
+ * vertBearingY ::
+ * Top side bearing for vertical layout. Larger positive values mean
+ * further below the vertical glyph origin.
+ *
+ * vertAdvance ::
+ * Advance height for vertical layout. Positive values mean the glyph
+ * has a positive advance downward.
+ *
+ * @note:
+ * If not disabled with @FT_LOAD_NO_HINTING, the values represent
+ * dimensions of the hinted glyph (in case hinting is applicable).
+ *
+ * Stroking a glyph with an outside border does not increase
+ * `horiAdvance` or `vertAdvance`; you have to manually adjust these
+ * values to account for the added width and height.
+ *
+ * FreeType doesn't use the 'VORG' table data for CFF fonts because it
+ * doesn't have an interface to quickly retrieve the glyph height. The
+ * y~coordinate of the vertical origin can be simply computed as
+ * `vertBearingY + height` after loading a glyph.
+ */
+ typedef struct FT_Glyph_Metrics_
+ {
+ FT_Pos width;
+ FT_Pos height;
+
+ FT_Pos horiBearingX;
+ FT_Pos horiBearingY;
+ FT_Pos horiAdvance;
+
+ FT_Pos vertBearingX;
+ FT_Pos vertBearingY;
+ FT_Pos vertAdvance;
+
+ } FT_Glyph_Metrics;
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * sizing_and_scaling
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @struct:
+ * FT_Bitmap_Size
+ *
+ * @description:
+ * This structure models the metrics of a bitmap strike (i.e., a set of
+ * glyphs for a given point size and resolution) in a bitmap font. It is
+ * used for the `available_sizes` field of @FT_Face.
+ *
+ * @fields:
+ * height ::
+ * The vertical distance, in pixels, between two consecutive baselines.
+ * It is always positive.
+ *
+ * width ::
+ * The average width, in pixels, of all glyphs in the strike.
+ *
+ * size ::
+ * The nominal size of the strike in 26.6 fractional points. This
+ * field is not very useful.
+ *
+ * x_ppem ::
+ * The horizontal ppem (nominal width) in 26.6 fractional pixels.
+ *
+ * y_ppem ::
+ * The vertical ppem (nominal height) in 26.6 fractional pixels.
+ *
+ * @note:
+ * Windows FNT:
+ * The nominal size given in a FNT font is not reliable. If the driver
+ * finds it incorrect, it sets `size` to some calculated values, and
+ * `x_ppem` and `y_ppem` to the pixel width and height given in the
+ * font, respectively.
+ *
+ * TrueType embedded bitmaps:
+ * `size`, `width`, and `height` values are not contained in the bitmap
+ * strike itself. They are computed from the global font parameters.
+ */
+ typedef struct FT_Bitmap_Size_
+ {
+ FT_Short height;
+ FT_Short width;
+
+ FT_Pos size;
+
+ FT_Pos x_ppem;
+ FT_Pos y_ppem;
+
+ } FT_Bitmap_Size;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* O B J E C T C L A S S E S */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /**************************************************************************
+ *
+ * @section:
+ * library_setup
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Library
+ *
+ * @description:
+ * A handle to a FreeType library instance. Each 'library' is completely
+ * independent from the others; it is the 'root' of a set of objects like
+ * fonts, faces, sizes, etc.
+ *
+ * It also embeds a memory manager (see @FT_Memory), as well as a
+ * scan-line converter object (see @FT_Raster).
+ *
+ * [Since 2.5.6] In multi-threaded applications it is easiest to use one
+ * `FT_Library` object per thread. In case this is too cumbersome, a
+ * single `FT_Library` object across threads is possible also, as long as
+ * a mutex lock is used around @FT_New_Face and @FT_Done_Face.
+ *
+ * @note:
+ * Library objects are normally created by @FT_Init_FreeType, and
+ * destroyed with @FT_Done_FreeType. If you need reference-counting
+ * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library.
+ */
+ typedef struct FT_LibraryRec_ *FT_Library;
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * module_management
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Module
+ *
+ * @description:
+ * A handle to a given FreeType module object. A module can be a font
+ * driver, a renderer, or anything else that provides services to the
+ * former.
+ */
+ typedef struct FT_ModuleRec_* FT_Module;
+
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Driver
+ *
+ * @description:
+ * A handle to a given FreeType font driver object. A font driver is a
+ * module capable of creating faces from font files.
+ */
+ typedef struct FT_DriverRec_* FT_Driver;
+
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Renderer
+ *
+ * @description:
+ * A handle to a given FreeType renderer. A renderer is a module in
+ * charge of converting a glyph's outline image to a bitmap. It supports
+ * a single glyph image format, and one or more target surface depths.
+ */
+ typedef struct FT_RendererRec_* FT_Renderer;
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * face_creation
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Face
+ *
+ * @description:
+ * A handle to a typographic face object. A face object models a given
+ * typeface, in a given style.
+ *
+ * @note:
+ * A face object also owns a single @FT_GlyphSlot object, as well as one
+ * or more @FT_Size objects.
+ *
+ * Use @FT_New_Face or @FT_Open_Face to create a new face object from a
+ * given filepath or a custom input stream.
+ *
+ * Use @FT_Done_Face to destroy it (along with its slot and sizes).
+ *
+ * An `FT_Face` object can only be safely used from one thread at a time.
+ * Similarly, creation and destruction of `FT_Face` with the same
+ * @FT_Library object can only be done from one thread at a time. On the
+ * other hand, functions like @FT_Load_Glyph and its siblings are
+ * thread-safe and do not need the lock to be held as long as the same
+ * `FT_Face` object is not used from multiple threads at the same time.
+ *
+ * @also:
+ * See @FT_FaceRec for the publicly accessible fields of a given face
+ * object.
+ */
+ typedef struct FT_FaceRec_* FT_Face;
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * sizing_and_scaling
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Size
+ *
+ * @description:
+ * A handle to an object that models a face scaled to a given character
+ * size.
+ *
+ * @note:
+ * An @FT_Face has one _active_ `FT_Size` object that is used by
+ * functions like @FT_Load_Glyph to determine the scaling transformation
+ * that in turn is used to load and hint glyphs and metrics.
+ *
+ * A newly created `FT_Size` object contains only meaningless zero values.
+ * You must use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size
+ * or even @FT_Select_Size to change the content (i.e., the scaling
+ * values) of the active `FT_Size`. Otherwise, the scaling and hinting
+ * will not be performed.
+ *
+ * You can use @FT_New_Size to create additional size objects for a given
+ * @FT_Face, but they won't be used by other functions until you activate
+ * it through @FT_Activate_Size. Only one size can be activated at any
+ * given time per face.
+ *
+ * @also:
+ * See @FT_SizeRec for the publicly accessible fields of a given size
+ * object.
+ */
+ typedef struct FT_SizeRec_* FT_Size;
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * glyph_retrieval
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_GlyphSlot
+ *
+ * @description:
+ * A handle to a given 'glyph slot'. A slot is a container that can hold
+ * any of the glyphs contained in its parent face.
+ *
+ * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char,
+ * the slot's content is erased by the new glyph data, i.e., the glyph's
+ * metrics, its image (bitmap or outline), and other control information.
+ *
+ * @also:
+ * See @FT_GlyphSlotRec for the publicly accessible glyph fields.
+ */
+ typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * character_mapping
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_CharMap
+ *
+ * @description:
+ * A handle to a character map (usually abbreviated to 'charmap'). A
+ * charmap is used to translate character codes in a given encoding into
+ * glyph indexes for its parent's face. Some font formats may provide
+ * several charmaps per font.
+ *
+ * Each face object owns zero or more charmaps, but only one of them can
+ * be 'active', providing the data used by @FT_Get_Char_Index or
+ * @FT_Load_Char.
+ *
+ * The list of available charmaps in a face is available through the
+ * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec.
+ *
+ * The currently active charmap is available as `face->charmap`. You
+ * should call @FT_Set_Charmap to change it.
+ *
+ * @note:
+ * When a new face is created (either through @FT_New_Face or
+ * @FT_Open_Face), the library looks for a Unicode charmap within the
+ * list and automatically activates it. If there is no Unicode charmap,
+ * FreeType doesn't set an 'active' charmap.
+ *
+ * @also:
+ * See @FT_CharMapRec for the publicly accessible fields of a given
+ * character map.
+ */
+ typedef struct FT_CharMapRec_* FT_CharMap;
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_ENC_TAG
+ *
+ * @description:
+ * This macro converts four-letter tags into an unsigned long. It is
+ * used to define 'encoding' identifiers (see @FT_Encoding).
+ *
+ * @note:
+ * Since many 16-bit compilers don't like 32-bit enumerations, you should
+ * redefine this macro in case of problems to something like this:
+ *
+ * ```
+ * #define FT_ENC_TAG( value, a, b, c, d ) value
+ * ```
+ *
+ * to get a simple enumeration without assigning special numbers.
+ */
+
+#ifndef FT_ENC_TAG
+
+#define FT_ENC_TAG( value, a, b, c, d ) \
+ value = ( ( FT_STATIC_BYTE_CAST( FT_UInt32, a ) << 24 ) | \
+ ( FT_STATIC_BYTE_CAST( FT_UInt32, b ) << 16 ) | \
+ ( FT_STATIC_BYTE_CAST( FT_UInt32, c ) << 8 ) | \
+ FT_STATIC_BYTE_CAST( FT_UInt32, d ) )
+
+#endif /* FT_ENC_TAG */
+
+
+ /**************************************************************************
+ *
+ * @enum:
+ * FT_Encoding
+ *
+ * @description:
+ * An enumeration to specify character sets supported by charmaps. Used
+ * in the @FT_Select_Charmap API function.
+ *
+ * @note:
+ * Despite the name, this enumeration lists specific character
+ * repertoires (i.e., charsets), and not text encoding methods (e.g.,
+ * UTF-8, UTF-16, etc.).
+ *
+ * Other encodings might be defined in the future.
+ *
+ * @values:
+ * FT_ENCODING_NONE ::
+ * The encoding value~0 is reserved for all formats except BDF, PCF,
+ * and Windows FNT; see below for more information.
+ *
+ * FT_ENCODING_UNICODE ::
+ * The Unicode character set. This value covers all versions of the
+ * Unicode repertoire, including ASCII and Latin-1. Most fonts include
+ * a Unicode charmap, but not all of them.
+ *
+ * For example, if you want to access Unicode value U+1F028 (and the
+ * font contains it), use value 0x1F028 as the input value for
+ * @FT_Get_Char_Index.
+ *
+ * FT_ENCODING_MS_SYMBOL ::
+ * Microsoft Symbol encoding, used to encode mathematical symbols and
+ * wingdings. For more information, see
+ * 'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts',
+ * 'http://www.kostis.net/charsets/symbol.htm', and
+ * 'http://www.kostis.net/charsets/wingding.htm'.
+ *
+ * This encoding uses character codes from the PUA (Private Unicode
+ * Area) in the range U+F020-U+F0FF.
+ *
+ * FT_ENCODING_SJIS ::
+ * Shift JIS encoding for Japanese. More info at
+ * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte
+ * encodings below.
+ *
+ * FT_ENCODING_PRC ::
+ * Corresponds to encoding systems mainly for Simplified Chinese as
+ * used in People's Republic of China (PRC). The encoding layout is
+ * based on GB~2312 and its supersets GBK and GB~18030.
+ *
+ * FT_ENCODING_BIG5 ::
+ * Corresponds to an encoding system for Traditional Chinese as used in
+ * Taiwan and Hong Kong.
+ *
+ * FT_ENCODING_WANSUNG ::
+ * Corresponds to the Korean encoding system known as Extended Wansung
+ * (MS Windows code page 949). For more information see
+ * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'.
+ *
+ * FT_ENCODING_JOHAB ::
+ * The Korean standard character set (KS~C 5601-1992), which
+ * corresponds to MS Windows code page 1361. This character set
+ * includes all possible Hangul character combinations.
+ *
+ * FT_ENCODING_ADOBE_LATIN_1 ::
+ * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript
+ * font. It is limited to 256 character codes.
+ *
+ * FT_ENCODING_ADOBE_STANDARD ::
+ * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF
+ * fonts. It is limited to 256 character codes.
+ *
+ * FT_ENCODING_ADOBE_EXPERT ::
+ * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF
+ * fonts. It is limited to 256 character codes.
+ *
+ * FT_ENCODING_ADOBE_CUSTOM ::
+ * Corresponds to a custom encoding, as found in Type~1, CFF, and
+ * OpenType/CFF fonts. It is limited to 256 character codes.
+ *
+ * FT_ENCODING_APPLE_ROMAN ::
+ * Apple roman encoding. Many TrueType and OpenType fonts contain a
+ * charmap for this 8-bit encoding, since older versions of Mac OS are
+ * able to use it.
+ *
+ * FT_ENCODING_OLD_LATIN_2 ::
+ * This value is deprecated and was neither used nor reported by
+ * FreeType. Don't use or test for it.
+ *
+ * FT_ENCODING_MS_SJIS ::
+ * Same as FT_ENCODING_SJIS. Deprecated.
+ *
+ * FT_ENCODING_MS_GB2312 ::
+ * Same as FT_ENCODING_PRC. Deprecated.
+ *
+ * FT_ENCODING_MS_BIG5 ::
+ * Same as FT_ENCODING_BIG5. Deprecated.
+ *
+ * FT_ENCODING_MS_WANSUNG ::
+ * Same as FT_ENCODING_WANSUNG. Deprecated.
+ *
+ * FT_ENCODING_MS_JOHAB ::
+ * Same as FT_ENCODING_JOHAB. Deprecated.
+ *
+ * @note:
+ * When loading a font, FreeType makes a Unicode charmap active if
+ * possible (either if the font provides such a charmap, or if FreeType
+ * can synthesize one from PostScript glyph name dictionaries; in either
+ * case, the charmap is tagged with `FT_ENCODING_UNICODE`). If such a
+ * charmap is synthesized, it is placed at the first position of the
+ * charmap array.
+ *
+ * All other encodings are considered legacy and tagged only if
+ * explicitly defined in the font file. Otherwise, `FT_ENCODING_NONE` is
+ * used.
+ *
+ * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is
+ * neither Unicode nor ISO-8859-1 (otherwise it is set to
+ * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which
+ * encoding is really present. If, for example, the `cs_registry` field
+ * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in
+ * KOI8-R.
+ *
+ * `FT_ENCODING_NONE` is always set (with a single exception) by the
+ * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset`
+ * field of the @FT_WinFNT_HeaderRec structure to find out which encoding
+ * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means
+ * Windows code page 1251 (for Russian).
+ *
+ * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH
+ * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to
+ * `FT_ENCODING_APPLE_ROMAN`).
+ *
+ * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function
+ * @FT_Get_CMap_Language_ID to query the Mac language ID that may be
+ * needed to be able to distinguish Apple encoding variants. See
+ *
+ * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt
+ *
+ * to get an idea how to do that. Basically, if the language ID is~0,
+ * don't use it, otherwise subtract 1 from the language ID. Then examine
+ * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN`
+ * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the
+ * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with
+ * `TT_MAC_LANGID_FARSI` means the Farsi variant of the Arabic encoding.
+ */
+ typedef enum FT_Encoding_
+ {
+ FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
+
+ FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
+ FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
+
+ FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
+ FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
+ FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
+ FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
+ FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
+
+ /* for backward compatibility */
+ FT_ENCODING_GB2312 = FT_ENCODING_PRC,
+ FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
+ FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
+ FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
+ FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
+ FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
+
+ FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
+ FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
+ FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
+ FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
+
+ FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
+
+ FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
+
+ } FT_Encoding;
+
+
+ /* these constants are deprecated; use the corresponding `FT_Encoding` */
+ /* values instead */
+#define ft_encoding_none FT_ENCODING_NONE
+#define ft_encoding_unicode FT_ENCODING_UNICODE
+#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
+#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
+#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
+#define ft_encoding_sjis FT_ENCODING_SJIS
+#define ft_encoding_gb2312 FT_ENCODING_PRC
+#define ft_encoding_big5 FT_ENCODING_BIG5
+#define ft_encoding_wansung FT_ENCODING_WANSUNG
+#define ft_encoding_johab FT_ENCODING_JOHAB
+
+#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
+#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
+#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
+#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
+
+
+ /**************************************************************************
+ *
+ * @struct:
+ * FT_CharMapRec
+ *
+ * @description:
+ * The base charmap structure.
+ *
+ * @fields:
+ * face ::
+ * A handle to the parent face object.
+ *
+ * encoding ::
+ * An @FT_Encoding tag identifying the charmap. Use this with
+ * @FT_Select_Charmap.
+ *
+ * platform_id ::
+ * An ID number describing the platform for the following encoding ID.
+ * This comes directly from the TrueType specification and gets
+ * emulated for other formats.
+ *
+ * encoding_id ::
+ * A platform-specific encoding number. This also comes from the
+ * TrueType specification and gets emulated similarly.
+ */
+ typedef struct FT_CharMapRec_
+ {
+ FT_Face face;
+ FT_Encoding encoding;
+ FT_UShort platform_id;
+ FT_UShort encoding_id;
+
+ } FT_CharMapRec;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* B A S E O B J E C T C L A S S E S */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * other_api_data
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @type:
+ * FT_Face_Internal
+ *
+ * @description:
+ * An opaque handle to an `FT_Face_InternalRec` structure that models the
+ * private data of a given @FT_Face object.
+ *
+ * This structure might change between releases of FreeType~2 and is not
+ * generally available to client applications.
+ */
+ typedef struct FT_Face_InternalRec_* FT_Face_Internal;
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * face_creation
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @struct:
+ * FT_FaceRec
+ *
+ * @description:
+ * FreeType root face class structure. A face object models a typeface
+ * in a font file.
+ *
+ * @fields:
+ * num_faces ::
+ * The number of faces in the font file. Some font formats can have
+ * multiple faces in a single font file.
+ *
+ * face_index ::
+ * This field holds two different values. Bits 0-15 are the index of
+ * the face in the font file (starting with value~0). They are set
+ * to~0 if there is only one face in the font file.
+ *
+ * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
+ * fonts only, holding the named instance index for the current face
+ * index (starting with value~1; value~0 indicates font access without
+ * a named instance). For non-variation fonts, bits 16-30 are ignored.
+ * If we have the third named instance of face~4, say, `face_index` is
+ * set to 0x00030004.
+ *
+ * Bit 31 is always zero (that is, `face_index` is always a positive
+ * value).
+ *
+ * [Since 2.9] Changing the design coordinates with
+ * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
+ * not influence the named instance index value (only
+ * @FT_Set_Named_Instance does that).
+ *
+ * face_flags ::
+ * A set of bit flags that give important information about the face;
+ * see @FT_FACE_FLAG_XXX for the details.
+ *
+ * style_flags ::
+ * The lower 16~bits contain a set of bit flags indicating the style of
+ * the face; see @FT_STYLE_FLAG_XXX for the details.
+ *
+ * [Since 2.6.1] Bits 16-30 hold the number of named instances
+ * available for the current face if we have a GX or OpenType variation
+ * (sub)font. Bit 31 is always zero (that is, `style_flags` is always
+ * a positive value). Note that a variation font has always at least
+ * one named instance, namely the default instance.
+ *
+ * num_glyphs ::
+ * The number of glyphs in the face. If the face is scalable and has
+ * sbits (see `num_fixed_sizes`), it is set to the number of outline
+ * glyphs.
+ *
+ * For CID-keyed fonts (not in an SFNT wrapper) this value gives the
+ * highest CID used in the font.
+ *
+ * family_name ::
+ * The face's family name. This is an ASCII string, usually in
+ * English, that describes the typeface's family (like 'Times New
+ * Roman', 'Bodoni', 'Garamond', etc). This is a least common
+ * denominator used to list fonts. Some formats (TrueType & OpenType)
+ * provide localized and Unicode versions of this string. Applications
+ * should use the format-specific interface to access them. Can be
+ * `NULL` (e.g., in fonts embedded in a PDF file).
+ *
+ * In case the font doesn't provide a specific family name entry,
+ * FreeType tries to synthesize one, deriving it from other name
+ * entries.
+ *
+ * style_name ::
+ * The face's style name. This is an ASCII string, usually in English,
+ * that describes the typeface's style (like 'Italic', 'Bold',
+ * 'Condensed', etc). Not all font formats provide a style name, so
+ * this field is optional, and can be set to `NULL`. As for
+ * `family_name`, some formats provide localized and Unicode versions
+ * of this string. Applications should use the format-specific
+ * interface to access them.
+ *
+ * num_fixed_sizes ::
+ * The number of bitmap strikes in the face. Even if the face is
+ * scalable, there might still be bitmap strikes, which are called
+ * 'sbits' in that case.
+ *
+ * available_sizes ::
+ * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It
+ * is set to `NULL` if there is no bitmap strike.
+ *
+ * Note that FreeType tries to sanitize the strike data since they are
+ * sometimes sloppy or incorrect, but this can easily fail.
+ *
+ * num_charmaps ::
+ * The number of charmaps in the face.
+ *
+ * charmaps ::
+ * An array of the charmaps of the face.
+ *
+ * generic ::
+ * A field reserved for client uses. See the @FT_Generic type
+ * description.
+ *
+ * bbox ::
+ * The font bounding box. Coordinates are expressed in font units (see
+ * `units_per_EM`). The box is large enough to contain any glyph from
+ * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender',
+ * and `bbox.yMin` as the 'minimum descender'. Only relevant for
+ * scalable formats.
+ *
+ * Note that the bounding box might be off by (at least) one pixel for
+ * hinted fonts. See @FT_Size_Metrics for further discussion.
+ *
+ * Note that the bounding box does not vary in OpenType variation fonts
+ * and should only be used in relation to the default instance.
+ *
+ * units_per_EM ::
+ * The number of font units per EM square for this face. This is
+ * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only
+ * relevant for scalable formats.
+ *
+ * ascender ::
+ * The typographic ascender of the face, expressed in font units. For
+ * font formats not having this information, it is set to `bbox.yMax`.
+ * Only relevant for scalable formats.
+ *
+ * descender ::
+ * The typographic descender of the face, expressed in font units. For
+ * font formats not having this information, it is set to `bbox.yMin`.
+ * Note that this field is negative for values below the baseline.
+ * Only relevant for scalable formats.
+ *
+ * height ::
+ * This value is the vertical distance between two consecutive
+ * baselines, expressed in font units. It is always positive. Only
+ * relevant for scalable formats.
+ *
+ * If you want the global glyph height, use `ascender - descender`.
+ *
+ * max_advance_width ::
+ * The maximum advance width, in font units, for all glyphs in this
+ * face. This can be used to make word wrapping computations faster.
+ * Only relevant for scalable formats.
+ *
+ * max_advance_height ::
+ * The maximum advance height, in font units, for all glyphs in this
+ * face. This is only relevant for vertical layouts, and is set to
+ * `height` for fonts that do not provide vertical metrics. Only
+ * relevant for scalable formats.
+ *
+ * underline_position ::
+ * The position, in font units, of the underline line for this face.
+ * It is the center of the underlining stem. Only relevant for
+ * scalable formats.
+ *
+ * underline_thickness ::
+ * The thickness, in font units, of the underline for this face. Only
+ * relevant for scalable formats.
+ *
+ * glyph ::
+ * The face's associated glyph slot(s).
+ *
+ * size ::
+ * The current active size for this face.
+ *
+ * charmap ::
+ * The current active charmap for this face.
+ *
+ * @note:
+ * Fields may be changed after a call to @FT_Attach_File or
+ * @FT_Attach_Stream.
+ *
+ * For an OpenType variation font, the values of the following fields can
+ * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
+ * the font contains an 'MVAR' table: `ascender`, `descender`, `height`,
+ * `underline_position`, and `underline_thickness`.
+ *
+ * Especially for TrueType fonts see also the documentation for
+ * @FT_Size_Metrics.
+ */
+ typedef struct FT_FaceRec_
+ {
+ FT_Long num_faces;
+ FT_Long face_index;
+
+ FT_Long face_flags;
+ FT_Long style_flags;
+
+ FT_Long num_glyphs;
+
+ FT_String* family_name;
+ FT_String* style_name;
+
+ FT_Int num_fixed_sizes;
+ FT_Bitmap_Size* available_sizes;
+
+ FT_Int num_charmaps;
+ FT_CharMap* charmaps;
+
+ FT_Generic generic;
+
+ /* The following member variables (down to `underline_thickness`) */
+ /* are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
+ /* for bitmap fonts. */
+ FT_BBox bbox;
+
+ FT_UShort units_per_EM;
+ FT_Short ascender;
+ FT_Short descender;
+ FT_Short height;
+
+ FT_Short max_advance_width;
+ FT_Short max_advance_height;
+
+ FT_Short underline_position;
+ FT_Short underline_thickness;
+
+ FT_GlyphSlot glyph;
+ FT_Size size;
+ FT_CharMap charmap;
+
+ /* private fields, internal to FreeType */
+
+ FT_Driver driver;
+ FT_Memory memory;
+ FT_Stream stream;
+
+ FT_ListRec sizes_list;
+
+ FT_Generic autohint; /* face-specific auto-hinter data */
+ void* extensions; /* unused */
+
+ FT_Face_Internal internal;
+
+ } FT_FaceRec;
+
+
+ /**************************************************************************
+ *
+ * @enum:
+ * FT_FACE_FLAG_XXX
+ *
+ * @description:
+ * A list of bit flags used in the `face_flags` field of the @FT_FaceRec
+ * structure. They inform client applications of properties of the
+ * corresponding face.
+ *
+ * @values:
+ * FT_FACE_FLAG_SCALABLE ::
+ * The face contains outline glyphs. Note that a face can contain
+ * bitmap strikes also, i.e., a face can have both this flag and
+ * @FT_FACE_FLAG_FIXED_SIZES set.
+ *
+ * FT_FACE_FLAG_FIXED_SIZES ::
+ * The face contains bitmap strikes. See also the `num_fixed_sizes`
+ * and `available_sizes` fields of @FT_FaceRec.
+ *
+ * FT_FACE_FLAG_FIXED_WIDTH ::
+ * The face contains fixed-width characters (like Courier, Lucida,
+ * MonoType, etc.).
+ *
+ * FT_FACE_FLAG_SFNT ::
+ * The face uses the SFNT storage scheme. For now, this means TrueType
+ * and OpenType.
+ *
+ * FT_FACE_FLAG_HORIZONTAL ::
+ * The face contains horizontal glyph metrics. This should be set for
+ * all common formats.
+ *
+ * FT_FACE_FLAG_VERTICAL ::
+ * The face contains vertical glyph metrics. This is only available in
+ * some formats, not all of them.
+ *
+ * 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 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.
+ *
+ * FT_FACE_FLAG_MULTIPLE_MASTERS ::
+ * The face contains multiple masters and is capable of interpolating
+ * between them. Supported formats are Adobe MM, TrueType GX, and
+ * OpenType variation fonts.
+ *
+ * See section @multiple_masters for API details.
+ *
+ * FT_FACE_FLAG_GLYPH_NAMES ::
+ * The face contains glyph names, which can be retrieved using
+ * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken
+ * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when
+ * needed.
+ *
+ * FT_FACE_FLAG_EXTERNAL_STREAM ::
+ * Used internally by FreeType to indicate that a face's stream was
+ * provided by the client application and should not be destroyed when
+ * @FT_Done_Face is called. Don't read or test this flag.
+ *
+ * FT_FACE_FLAG_HINTER ::
+ * The font driver has a hinting machine of its own. For example, with
+ * TrueType fonts, it makes sense to use data from the SFNT 'gasp'
+ * table only if the native TrueType hinting engine (with the bytecode
+ * interpreter) is available and active.
+ *
+ * FT_FACE_FLAG_CID_KEYED ::
+ * The face is CID-keyed. In that case, the face is not accessed by
+ * glyph indices but by CID values. For subsetted CID-keyed fonts this
+ * has the consequence that not all index values are a valid argument
+ * to @FT_Load_Glyph. Only the CID values for which corresponding
+ * glyphs in the subsetted font exist make `FT_Load_Glyph` return
+ * successfully; in all other cases you get an
+ * `FT_Err_Invalid_Argument` error.
+ *
+ * Note that CID-keyed fonts that are in an SFNT wrapper (that is, all
+ * OpenType/CFF fonts) don't have this flag set since the glyphs are
+ * accessed in the normal way (using contiguous indices); the
+ * 'CID-ness' isn't visible to the application.
+ *
+ * FT_FACE_FLAG_TRICKY ::
+ * The face is 'tricky', that is, it always needs the font format's
+ * native hinting engine to get a reasonable result. A typical example
+ * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that
+ * uses TrueType bytecode instructions to move and scale all of its
+ * subglyphs.
+ *
+ * It is not possible to auto-hint such fonts using
+ * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING.
+ * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to
+ * really disable hinting; however, you probably never want this except
+ * for demonstration purposes.
+ *
+ * Currently, there are about a dozen TrueType fonts in the list of
+ * tricky fonts; they are hard-coded in file `ttobjs.c`.
+ *
+ * FT_FACE_FLAG_COLOR ::
+ * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR
+ * for more information.
+ *
+ * FT_FACE_FLAG_VARIATION ::
+ * [Since 2.9] Set if the current face (or named instance) has been
+ * altered with @FT_Set_MM_Design_Coordinates,
+ * @FT_Set_Var_Design_Coordinates, @FT_Set_Var_Blend_Coordinates, or
+ * @FT_Set_MM_WeightVector to select a non-default instance.
+ *
+ * FT_FACE_FLAG_SVG ::
+ * [Since 2.12] The face has an 'SVG~' OpenType table.
+ *
+ * FT_FACE_FLAG_SBIX ::
+ * [Since 2.12] The face has an 'sbix' OpenType table *and* outlines.
+ * For such fonts, @FT_FACE_FLAG_SCALABLE is not set by default to
+ * retain backward compatibility.
+ *
+ * FT_FACE_FLAG_SBIX_OVERLAY ::
+ * [Since 2.12] The face has an 'sbix' OpenType table where outlines
+ * should be drawn on top of bitmap strikes.
+ *
+ */
+#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
+#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
+#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
+#define FT_FACE_FLAG_SFNT ( 1L << 3 )
+#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
+#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
+#define FT_FACE_FLAG_KERNING ( 1L << 6 )
+#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
+#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
+#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
+#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
+#define FT_FACE_FLAG_HINTER ( 1L << 11 )
+#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
+#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
+#define FT_FACE_FLAG_COLOR ( 1L << 14 )
+#define FT_FACE_FLAG_VARIATION ( 1L << 15 )
+#define FT_FACE_FLAG_SVG ( 1L << 16 )
+#define FT_FACE_FLAG_SBIX ( 1L << 17 )
+#define FT_FACE_FLAG_SBIX_OVERLAY ( 1L << 18 )
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * font_testing_macros
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_HORIZONTAL
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains horizontal
+ * metrics (this is true for all font formats though).
+ *
+ * @also:
+ * @FT_HAS_VERTICAL can be used to check for vertical metrics.
+ *
+ */
+#define FT_HAS_HORIZONTAL( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_VERTICAL
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains real
+ * vertical metrics (and not only synthesized ones).
+ *
+ */
+#define FT_HAS_VERTICAL( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_KERNING
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains kerning data
+ * that can be accessed with @FT_Get_Kerning.
+ *
+ */
+#define FT_HAS_KERNING( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_KERNING ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IS_SCALABLE
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a scalable
+ * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and
+ * PFR font formats).
+ *
+ */
+#define FT_IS_SCALABLE( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IS_SFNT
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a font whose
+ * format is based on the SFNT storage scheme. This usually means:
+ * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap
+ * fonts.
+ *
+ * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
+ * @FT_TRUETYPE_TABLES_H are available.
+ *
+ */
+#define FT_IS_SFNT( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_SFNT ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IS_FIXED_WIDTH
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a font face
+ * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.)
+ * glyphs.
+ *
+ */
+#define FT_IS_FIXED_WIDTH( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_FIXED_SIZES
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains some
+ * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec
+ * structure.
+ *
+ */
+#define FT_HAS_FIXED_SIZES( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) )
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * other_api_data
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_FAST_GLYPHS
+ *
+ * @description:
+ * Deprecated.
+ *
+ */
+#define FT_HAS_FAST_GLYPHS( face ) 0
+
+
+ /**************************************************************************
+ *
+ * @section:
+ * font_testing_macros
+ *
+ */
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_GLYPH_NAMES
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains some glyph
+ * names that can be accessed through @FT_Get_Glyph_Name.
+ *
+ */
+#define FT_HAS_GLYPH_NAMES( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_MULTIPLE_MASTERS
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains some
+ * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
+ * are then available to choose the exact design you want.
+ *
+ */
+#define FT_HAS_MULTIPLE_MASTERS( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IS_NAMED_INSTANCE
+ *
+ * @description:
+ * A macro that returns true whenever a face object is a named instance
+ * of a GX or OpenType variation font.
+ *
+ * [Since 2.9] Changing the design coordinates with
+ * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
+ * not influence the return value of this macro (only
+ * @FT_Set_Named_Instance does that).
+ *
+ * @since:
+ * 2.7
+ *
+ */
+#define FT_IS_NAMED_INSTANCE( face ) \
+ ( !!( (face)->face_index & 0x7FFF0000L ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IS_VARIATION
+ *
+ * @description:
+ * A macro that returns true whenever a face object has been altered by
+ * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates,
+ * @FT_Set_Var_Blend_Coordinates, or @FT_Set_MM_WeightVector.
+ *
+ * @since:
+ * 2.9
+ *
+ */
+#define FT_IS_VARIATION( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_VARIATION ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IS_CID_KEYED
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a CID-keyed
+ * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details.
+ *
+ * If this macro is true, all functions defined in @FT_CID_H are
+ * available.
+ *
+ */
+#define FT_IS_CID_KEYED( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_IS_TRICKY
+ *
+ * @description:
+ * A macro that returns true whenever a face represents a 'tricky' font.
+ * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
+ *
+ */
+#define FT_IS_TRICKY( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_TRICKY ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_COLOR
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains tables for
+ * color glyphs.
+ *
+ * @since:
+ * 2.5.1
+ *
+ */
+#define FT_HAS_COLOR( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_COLOR ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_SVG
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains an 'SVG~'
+ * OpenType table.
+ *
+ * @since:
+ * 2.12
+ */
+#define FT_HAS_SVG( face ) \
+ ( !!( (face)->face_flags & FT_FACE_FLAG_SVG ) )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_HAS_SBIX
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains an 'sbix'
+ * OpenType table *and* outline glyphs.
+ *
+ * Currently, FreeType only supports bitmap glyphs in PNG format for this
+ * table (i.e., JPEG and TIFF formats are unsupported, as are
+ * Apple-specific formats not part of the OpenType specification).
+ *
+ * @note:
+ * For backward compatibility, a font with an 'sbix' table is treated as
+ * a bitmap-only face. Using @FT_Open_Face with
+ * @FT_PARAM_TAG_IGNORE_SBIX, an application can switch off 'sbix'
+ * handling so that the face is treated as an ordinary outline font with
+ * scalable outlines.
+ *
+ * Here is some pseudo code that roughly illustrates how to implement
+ * 'sbix' handling according to the OpenType specification.
+ *
+ * ```
+ * if ( FT_HAS_SBIX( face ) )
+ * {
+ * // open font as a scalable one without sbix handling
+ * FT_Face face2;
+ * FT_Parameter param = { FT_PARAM_TAG_IGNORE_SBIX, NULL };
+ * FT_Open_Args args = { FT_OPEN_PARAMS | ...,
+ * ...,
+ * 1, ¶m };
+ *
+ *
+ * FT_Open_Face( library, &args, 0, &face2 );
+ *
+ * available_size` as necessary into
+ * `preferred_sizes`[*]>
+ *
+ * for ( i = 0; i < face->num_fixed_sizes; i++ )
+ * {
+ * size = preferred_sizes[i].size;
+ *
+ * error = FT_Set_Pixel_Sizes( face, size, size );
+ *
+ *
+ * // check whether we have a glyph in a bitmap strike
+ * error = FT_Load_Glyph( face,
+ * glyph_index,
+ * FT_LOAD_SBITS_ONLY |
+ * FT_LOAD_BITMAP_METRICS_ONLY );
+ * if ( error == FT_Err_Invalid_Argument )
+ * continue;
+ * else if ( error )
+ *
+ * else
+ * break;
+ * }
+ *
+ * if ( i != face->num_fixed_sizes )
+ *
+ *
+ * if ( i == face->num_fixed_sizes ||
+ * FT_HAS_SBIX_OVERLAY( face ) )
+ *