Skip to content

Commit

Permalink
Merge pull request #631 from keithc-ca/freetype
Browse files Browse the repository at this point in the history
Include freetype source from openjdk
  • Loading branch information
pshipton authored Nov 10, 2022
2 parents 2ac69d4 + 956df0d commit b0d50c4
Show file tree
Hide file tree
Showing 309 changed files with 172,229 additions and 7,777 deletions.
4,098 changes: 437 additions & 3,661 deletions common/autoconf/generated-configure.sh

Large diffs are not rendered by default.

454 changes: 137 additions & 317 deletions common/autoconf/libraries.m4

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ SJAVAC_SERVER_DIR:=@SJAVAC_SERVER_DIR@
# Number of parallel jobs to use for compilation
JOBS?=@JOBS@

FREETYPE_TO_USE:=@FREETYPE_TO_USE@
FREETYPE_LIBS:=@FREETYPE_LIBS@
FREETYPE_CFLAGS:=@FREETYPE_CFLAGS@
FREETYPE_BUNDLE_LIB_PATH=@FREETYPE_BUNDLE_LIB_PATH@
FONTCONFIG_CFLAGS:=@FONTCONFIG_CFLAGS@
CUPS_CFLAGS:=@CUPS_CFLAGS@
ALSA_LIBS:=@ALSA_LIBS@
Expand Down
11 changes: 0 additions & 11 deletions common/autoconf/toolchain_windows.m4
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
if test "x$VS_ENV_CMD" = x; then
AC_MSG_NOTICE([Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring])
else
# PLATFORM_TOOLSET is used during the compilation of the freetype sources
# (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100',
# 'v110' or 'v120' for VS 2010, 2012 or VS2013
eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
fi
fi
fi
Expand Down Expand Up @@ -170,10 +164,6 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
else
VS_ENV_ARGS="/x64"
fi
# PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
# 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
# TODO: improve detection for other versions of SDK
eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
else
AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
Expand Down Expand Up @@ -281,7 +271,6 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO],
eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
eval USE_UCRT="\${VS_USE_UCRT_${VS_VERSION}}"
eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
VS_PATH="$TOOLCHAIN_PATH:$PATH"
# Convert DEVKIT_VS_INCLUDE into windows style VS_INCLUDE so that it
Expand Down
632 changes: 632 additions & 0 deletions jdk/THIRD_PARTY_README

Large diffs are not rendered by default.

35 changes: 0 additions & 35 deletions jdk/make/CopyFiles.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -214,41 +214,6 @@ $(ICCPROFILE_DEST_DIR)%.pf: $(ICCPROFILE_SRC_DIR)%.pf

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

##########################################################################################
# Optionally copy OpenSSL Crypto Library
# To bundle first search for openssl 1.1.x library, if not found, search for 1.0.x
Expand Down
4,217 changes: 465 additions & 3,752 deletions jdk/make/closed/autoconf/generated-configure.sh

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions jdk/make/lib/Awt2dLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,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
Expand Down Expand Up @@ -897,6 +942,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
Expand Down
34 changes: 34 additions & 0 deletions jdk/src/share/native/sun/awt/libfreetype/UPDATING.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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/share/native/sun/awt/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/share/native/sun/awt/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 jdk/THIRD_PARTY_README.

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/****************************************************************************
*
* ftconfig.h
*
* ANSI-specific configuration file (specification only).
*
* Copyright (C) 1996-2022 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/<system>`, 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 <ft2build.h>
#include FT_CONFIG_OPTIONS_H
#include FT_CONFIG_STANDARD_LIBRARY_H

#include <freetype/config/integer-types.h>
#include <freetype/config/public-macros.h>
#include <freetype/config/mac-support.h>

#endif /* FTCONFIG_H_ */


/* END */
Loading

0 comments on commit b0d50c4

Please sign in to comment.