8349859: Support static JDK in libfontmanager/freetypeScaler.c

Reviewed-by: prr
This commit is contained in:
Jiangli Zhou 2025-02-12 16:29:08 +00:00
parent 73e1780ad0
commit 332d87cc7e
2 changed files with 15 additions and 0 deletions

View File

@ -407,6 +407,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
LDFLAGS_aix := -Wl$(COMMA)-berok, \
JDK_LIBS := libawt java.base:libjava $(LIBFONTMANAGER_JDK_LIBS), \
JDK_LIBS_macosx := libawt_lwawt, \
JDK_LIBS_unix := java.base:libjvm, \
LIBS := $(LIBFONTMANAGER_LIBS), \
LIBS_unix := $(LIBM), \
LIBS_macosx := \

View File

@ -32,6 +32,7 @@
#include <stdlib.h>
#if !defined(_WIN32) && !defined(__APPLE_)
#include <dlfcn.h>
#include "jvm.h"
#endif
#include <math.h>
#include "ft2build.h"
@ -298,6 +299,19 @@ static void setInterpreterVersion(FT_Library library) {
#if defined(_WIN32) || defined(__APPLE__)
FT_Property_Set(library, module, property, (void*)(&version));
#else
if (JVM_IsStaticallyLinked()) {
// The bundled libfreetype may be statically linked with
// the launcher.
if (dlsym(RTLD_DEFAULT, "FT_Property_Set") != NULL) {
FT_Property_Set(library, module, property, (void*)(&version));
return;
}
// libfreetype is not statically linked with the executable,
// fall through to find the system provided library dynamically.
}
void *lib = dlopen("libfreetype.so", RTLD_LOCAL|RTLD_LAZY);
if (lib == NULL) {
lib = dlopen("libfreetype.so.6", RTLD_LOCAL|RTLD_LAZY);