diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..fbd04c11c --- /dev/null +++ b/.clang-format @@ -0,0 +1,16 @@ +BasedOnStyle: Chromium +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignConsecutiveMacros: true +AlignEscapedNewlines: true +# AlignOperands: Align +AlignTrailingComments: true +AlwaysBreakAfterReturnType: AllDefinitions +BreakBeforeBraces: Allman +ColumnLimit: 80 +DerivePointerAlignment: false +IndentCaseLabels: false +PointerAlignment: Left +SpaceBeforeParens: ControlStatements +SpacesInParentheses: true diff --git a/.gitignore b/.gitignore deleted file mode 100644 index b5db9d874..000000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -config.mk -objs/vc2010/ diff --git a/.mailmap b/.mailmap deleted file mode 100644 index a3c5f9451..000000000 --- a/.mailmap +++ /dev/null @@ -1,7 +0,0 @@ -Alexei Podtelezhnikov (Алексей Подтележников) -Behdad Esfahbod -Bram Tassyns bram tassyns -Bram Tassyns -Suzuki, Toshiya (鈴木俊哉) -Suzuki, Toshiya (鈴木俊哉) sssa -Suzuki, Toshiya (鈴木俊哉) suzuki toshiya diff --git a/CMakeLists.txt b/CMakeLists.txt index edcb64e87..3ed55aad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # CMakeLists.txt # -# Copyright 2013-2015 by +# Copyright (C) 2013-2020 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # Written originally by John Cary @@ -12,35 +12,44 @@ # fully. # # -# As a preliminary, create a compilation directory and change into it, for -# example +# The following will 1. create a build directory and 2. change into it and +# call cmake to configure the build with default parameters as a static +# library. See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html +# for information about Debug, Release, etc. builds. # -# mkdir ~/freetype2.compiled -# cd ~/freetype2.compiled -# -# Now you can say -# -# cmake -# -# to create a Makefile that builds a static version of the library. +# cmake -B build -D CMAKE_BUILD_TYPE=Release # # For a dynamic library, use # -# cmake -D BUILD_SHARED_LIBS:BOOL=true +# cmake -B build -D BUILD_SHARED_LIBS=true -D CMAKE_BUILD_TYPE=Release # # For a framework on OS X, use # -# cmake -D BUILD_FRAMEWORK:BOOL=true -G Xcode -# -# instead. +# cmake -E chdir build cmake -G Xcode -D BUILD_FRAMEWORK:BOOL=true .. # # For an iOS static library, use # -# cmake -D IOS_PLATFORM=OS -G Xcode +# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=OS .. +# +# or +# +# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR .. # # or # -# cmake -D IOS_PLATFORM=SIMULATOR -G Xcode +# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR64 .. +# +# Finally, build the project with: +# +# cmake --build build +# +# Install it with +# +# (sudo) cmake --build build --target install +# +# A binary distribution can be made with +# +# cmake --build build --config Release --target package # # Please refer to the cmake manual for further options, in particular, how # to modify compilation and linking parameters. @@ -58,22 +67,55 @@ # # . `CMakeLists.txt' is provided as-is since it is normally not used by the # developer team. - - -cmake_minimum_required(VERSION 2.6) - +# +# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG', +# `FT_WITH_HARFBUZZ', and `FT_WITH_BROTLI' CMake variables to `ON' to +# force using a dependency. Leave a variable undefined (which is the +# default) to use the dependency only if it is available. Example: +# +# cmake -B build -D FT_WITH_ZLIB=ON \ +# -D FT_WITH_BZIP2=ON \ +# -D FT_WITH_PNG=ON \ +# -D FT_WITH_HARFBUZZ=ON \ +# -D FT_WITH_BROTLI=ON [...] +# +# Set `CMAKE_DISABLE_FIND_PACKAGE_XXX=TRUE' to disable a dependency completely +# (where `XXX' is a CMake package name like `BZip2'). Example for disabling all +# dependencies: +# +# cmake -B build -D CMAKE_DISABLE_FIND_PACKAGE_ZLIB=TRUE \ +# -D CMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE \ +# -D CMAKE_DISABLE_FIND_PACKAGE_PNG=TRUE \ +# -D CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE \ +# -D CMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE [...] +# +# . Installation of FreeType can be controlled with the CMake variables +# `SKIP_INSTALL_HEADERS', `SKIP_INSTALL_LIBRARIES', and `SKIP_INSTALL_ALL' +# (this is compatible with the same CMake variables in zlib's CMake +# support). + +# FreeType explicitly marks the API to be exported and relies on the compiler +# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property +# starting with 2.8.12. +cmake_minimum_required(VERSION 2.8.12) + +if (NOT CMAKE_VERSION VERSION_LESS 3.3) + # Allow symbol visibility settings also on static libraries. CMake < 3.3 + # only sets the property on a shared library build. + cmake_policy(SET CMP0063 NEW) +endif () include(CheckIncludeFile) - # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which # configures the base build environment and references the toolchain file if (APPLE) if (DEFINED IOS_PLATFORM) if (NOT "${IOS_PLATFORM}" STREQUAL "OS" - AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR") + AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR" + AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR64") message(FATAL_ERROR - "IOS_PLATFORM must be set to either OS or SIMULATOR") + "IOS_PLATFORM must be set to either OS, SIMULATOR, or SIMULATOR64") endif () if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") message(AUTHOR_WARNING @@ -92,7 +134,7 @@ if (APPLE) set(BUILD_SHARED_LIBS OFF) set(CMAKE_TOOLCHAIN_FILE - ${PROJECT_SOURCE_DIR}/builds/cmake/iOS.cmake) + ${CMAKE_SOURCE_DIR}/builds/cmake/iOS.cmake) endif () else () if (DEFINED IOS_PLATFORM) @@ -100,31 +142,56 @@ else () endif () endif () -if (WIN32 AND BUILD_SHARED_LIBS) - message(FATAL_ERROR "Shared libraries not supported on Windows.") -endif () +project(freetype C) -project(freetype) +set(VERSION_MAJOR "2") +set(VERSION_MINOR "10") +set(VERSION_PATCH "4") + +# Generate LIBRARY_VERSION and LIBRARY_SOVERSION. +set(LIBTOOL_REGEX "version_info='([0-9]+):([0-9]+):([0-9]+)'") +file(STRINGS "${PROJECT_SOURCE_DIR}/builds/unix/configure.raw" + VERSION_INFO + REGEX ${LIBTOOL_REGEX}) +string(REGEX REPLACE + ${LIBTOOL_REGEX} "\\1" + LIBTOOL_CURRENT "${VERSION_INFO}") +string(REGEX REPLACE + ${LIBTOOL_REGEX} "\\2" + LIBTOOL_REVISION "${VERSION_INFO}") +string(REGEX REPLACE + ${LIBTOOL_REGEX} "\\3" + LIBTOOL_AGE "${VERSION_INFO}") + +# This is what libtool does internally on Unix platforms. +math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}") +set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}") + +# External dependency library detection is automatic. See the notes at the top +# of this file, for how to force or disable dependencies completely. +option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF) +option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF) +option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." OFF) +option(FT_WITH_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF) +option(FT_WITH_BROTLI "Support compressed WOFF2 fonts." OFF) # Disallow in-source builds -if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") +if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") message(FATAL_ERROR - " -In-source builds are not permitted! Make a separate folder for" - " building, e.g.," - " - mkdir build; cd build; cmake .." - " -Before that, remove the files created by this failed run with" - " - rm -rf CMakeCache.txt CMakeFiles") + "In-source builds are not permitted! Make a separate folder for" + " building, e.g.,\n" + " cmake -E make_directory build\n" + " cmake -E chdir build cmake ..\n" + "Before that, remove the files created by this failed run with\n" + " cmake -E remove CMakeCache.txt\n" + " cmake -E remove_directory CMakeFiles") endif () # Add local cmake modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/builds) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake) if (BUILD_FRAMEWORK) @@ -137,72 +204,72 @@ if (BUILD_FRAMEWORK) endif () -set(VERSION_MAJOR "2") -set(VERSION_MINOR "6") -set(VERSION_PATCH "0") - -set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) -set(SHARED_LIBRARY_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) - - -# Compiler definitions for building the library -add_definitions(-DFT2_BUILD_LIBRARY) - - # Find dependencies -find_package(ZLIB) -find_package(BZip2) -find_package(PNG) -find_package(HarfBuzz) +set(HARFBUZZ_MIN_VERSION "1.8.0") +if (FT_WITH_HARFBUZZ) + find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED) +else () + find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION}) +endif () +if (FT_WITH_PNG) + find_package(PNG REQUIRED) +else () + find_package(PNG) +endif () -message(STATUS - "Creating directory ${PROJECT_BINARY_DIR}/include/freetype/config") -file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include/freetype/config") +if (FT_WITH_ZLIB) + find_package(ZLIB REQUIRED) +else () + find_package(ZLIB) +endif () +if (FT_WITH_BZIP2) + find_package(BZip2 REQUIRED) +else () + find_package(BZip2) +endif () -# Create the configuration file -message(STATUS - "Creating file ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h") +if (FT_WITH_BROTLI) + find_package(BrotliDec REQUIRED) +else () + find_package(BrotliDec) +endif () +# Create the configuration file if (UNIX) check_include_file("unistd.h" HAVE_UNISTD_H) check_include_file("fcntl.h" HAVE_FCNTL_H) - check_include_file("stdint.h" HAVE_STDINT_H) - file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.in" + file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.h.in" FTCONFIG_H) if (HAVE_UNISTD_H) string(REGEX REPLACE - "#undef +(HAVE_UNISTD_H)" "#define \\1" + "#undef +(HAVE_UNISTD_H)" "#define \\1 1" FTCONFIG_H "${FTCONFIG_H}") endif () if (HAVE_FCNTL_H) string(REGEX REPLACE - "#undef +(HAVE_FCNTL_H)" "#define \\1" - FTCONFIG_H "${FTCONFIG_H}") - endif () - if (HAVE_STDINT_H) - string(REGEX REPLACE - "#undef +(HAVE_STDINT_H)" "#define \\1" + "#undef +(HAVE_FCNTL_H)" "#define \\1 1" FTCONFIG_H "${FTCONFIG_H}") endif () - string(REPLACE "/undef " "#undef " - FTCONFIG_H "${FTCONFIG_H}") - file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h" - "${FTCONFIG_H}") else () file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h" FTCONFIG_H) - file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h" - "${FTCONFIG_H}") endif () +set(FTCONFIG_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h") +if (EXISTS "${FTCONFIG_H_NAME}") + file(READ "${FTCONFIG_H_NAME}" ORIGINAL_FTCONFIG_H) +else () + set(ORIGINAL_FTCONFIG_H "") +endif () +if (NOT (ORIGINAL_FTCONFIG_H STREQUAL FTCONFIG_H)) + file(WRITE "${FTCONFIG_H_NAME}" "${FTCONFIG_H}") +endif () -# Create the options file -message(STATUS - "Creating file ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h") +# Create the options file file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h" FTOPTION_H) if (ZLIB_FOUND) @@ -225,13 +292,21 @@ if (HARFBUZZ_FOUND) "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1" FTOPTION_H "${FTOPTION_H}") endif () -file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h" - "${FTOPTION_H}") - +if (BROTLIDEC_FOUND) + string(REGEX REPLACE + "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1" + FTOPTION_H "${FTOPTION_H}") +endif () -# Specify library include directories -include_directories("${PROJECT_SOURCE_DIR}/include") -include_directories(BEFORE "${PROJECT_BINARY_DIR}/include") +set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h") +if (EXISTS "${FTOPTION_H_NAME}") + file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H) +else () + set(ORIGINAL_FTOPTION_H "") +endif () +if (NOT (ORIGINAL_FTOPTION_H STREQUAL FTOPTION_H)) + file(WRITE "${FTOPTION_H_NAME}" "${FTOPTION_H}") +endif () file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h") @@ -246,20 +321,17 @@ set(BASE_SRCS src/base/ftbdf.c src/base/ftbitmap.c src/base/ftcid.c - src/base/ftfntfmt.c src/base/ftfstype.c src/base/ftgasp.c src/base/ftglyph.c src/base/ftgxval.c src/base/ftinit.c - src/base/ftlcdfil.c src/base/ftmm.c src/base/ftotval.c src/base/ftpatent.c src/base/ftpfr.c src/base/ftstroke.c src/base/ftsynth.c - src/base/ftsystem.c src/base/fttype1.c src/base/ftwinfnt.c src/bdf/bdf.c @@ -283,20 +355,29 @@ set(BASE_SRCS src/winfonts/winfnt.c ) +if (UNIX) + list(APPEND BASE_SRCS "builds/unix/ftsystem.c") +else () + list(APPEND BASE_SRCS "src/base/ftsystem.c") +endif () + if (WIN32) - set(BASE_SRCS ${BASE_SRCS} builds/windows/ftdebug.c) + enable_language(RC) + list(APPEND BASE_SRCS builds/windows/ftdebug.c + src/base/ftver.rc) elseif (WINCE) - set(BASE_SRCS ${BASE_SRCS} builds/wince/ftdebug.c) + list(APPEND BASE_SRCS builds/wince/ftdebug.c) else () - set(BASE_SRCS ${BASE_SRCS} src/base/ftdebug.c) + list(APPEND BASE_SRCS src/base/ftdebug.c) endif () - if (BUILD_FRAMEWORK) - set(BASE_SRCS - ${BASE_SRCS} - builds/mac/freetype-Info.plist - ) + list(APPEND BASE_SRCS builds/mac/freetype-Info.plist) +endif () + + +if (NOT DISABLE_FORCE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX d) endif () @@ -307,15 +388,43 @@ add_library(freetype ${BASE_SRCS} ) +set_target_properties( + freetype PROPERTIES + C_VISIBILITY_PRESET hidden) + +target_compile_definitions( + freetype PRIVATE FT2_BUILD_LIBRARY) + +if (WIN32) + target_compile_definitions( + freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS) + if (BUILD_SHARED_LIBS) + target_compile_definitions( + freetype PRIVATE DLL_EXPORT) + endif () +endif () if (BUILD_SHARED_LIBS) set_target_properties(freetype PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${SHARED_LIBRARY_VERSION} - COMPILE_DEFINITIONS freetype_EXPORTS - ) + VERSION ${LIBRARY_VERSION} + SOVERSION ${LIBRARY_SOVERSION}) endif () +# Pick up ftconfig.h and ftoption.h generated above, first. +target_include_directories( + freetype + PUBLIC + $ + $ + $ + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/include + + # Make available for builds/unix/ftsystem.c. + ${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config +) + if (BUILD_FRAMEWORK) set_property(SOURCE ${PUBLIC_CONFIG_HEADERS} @@ -330,75 +439,145 @@ if (BUILD_FRAMEWORK) endif () -if (MSVC) - set_target_properties(freetype PROPERTIES - COMPILE_FLAGS /Fd"$(IntDir)$(TargetName).pdb") -endif () - +set(PKG_CONFIG_REQUIRED_PRIVATE "") if (ZLIB_FOUND) - target_link_libraries(freetype ${ZLIB_LIBRARIES}) - include_directories(${ZLIB_INCLUDE_DIRS}) + target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES}) + target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS}) + list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "zlib") endif () if (BZIP2_FOUND) - target_link_libraries(freetype ${BZIP2_LIBRARIES}) - include_directories(${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS + target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES}) + target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS + list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "bzip2") endif () if (PNG_FOUND) - add_definitions(${PNG_DEFINITIONS}) - target_link_libraries(freetype ${PNG_LIBRARIES}) - include_directories(${PNG_INCLUDE_DIRS}) + target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES}) + target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS}) + target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS}) + list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libpng") endif () if (HARFBUZZ_FOUND) - target_link_libraries(freetype ${HARFBUZZ_LIBRARIES}) - include_directories(${HARFBUZZ_INCLUDE_DIRS}) + target_link_libraries(freetype PRIVATE ${HARFBUZZ_LIBRARIES}) + target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS}) + list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}") +endif () +if (BROTLIDEC_FOUND) + target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES}) + target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS}) + target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS}) + list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libbrotlidec") endif () -# Installations -# Note the trailing slash in the argument to the `DIRECTORY' directive -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION include/freetype2 - PATTERN "internal" EXCLUDE - PATTERN "ftconfig.h" EXCLUDE - PATTERN "ftoption.h" EXCLUDE -) -install(FILES - ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h - ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h - DESTINATION include/freetype2/freetype/config -) -install(TARGETS freetype - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - FRAMEWORK DESTINATION Library/Frameworks -) +# Installation +include(GNUInstallDirs) + +if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) + install( + # Note the trailing slash in the argument to `DIRECTORY'! + DIRECTORY ${PROJECT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2 + COMPONENT headers + PATTERN "internal" EXCLUDE + PATTERN "ftconfig.h" EXCLUDE + PATTERN "ftoption.h" EXCLUDE) + install( + FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h + ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config + COMPONENT headers) +endif () + +if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) + # Generate the pkg-config file + if (UNIX) + file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN) + + string(REPLACE ";" ", " PKG_CONFIG_REQUIRED_PRIVATE "${PKG_CONFIG_REQUIRED_PRIVATE}") + + string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX} + FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) + string(REPLACE "%exec_prefix%" "\${prefix}" + FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) + string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}" + FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) + string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}" + FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) + string(REPLACE "%ft_version%" "${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}" + FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) + string(REPLACE "%REQUIRES_PRIVATE%" "${PKG_CONFIG_REQUIRED_PRIVATE}" + FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) + string(REPLACE "%LIBS_PRIVATE%" "" # All libs support pkg-config + FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) + + set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc") + if (EXISTS "${FREETYPE2_PC_IN_NAME}") + file(READ "${FREETYPE2_PC_IN_NAME}" ORIGINAL_FREETYPE2_PC_IN) + else () + set(ORIGINAL_FREETYPE2_PC_IN "") + endif () + if (NOT (ORIGINAL_FREETYPE2_PC_IN STREQUAL FREETYPE2_PC_IN)) + file(WRITE "${FREETYPE2_PC_IN_NAME}" ${FREETYPE2_PC_IN}) + endif () + + install( + FILES ${PROJECT_BINARY_DIR}/freetype2.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + COMPONENT pkgconfig) + endif () + + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + ${PROJECT_BINARY_DIR}/freetype-config-version.cmake + VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + COMPATIBILITY SameMajorVersion) + + install( + TARGETS freetype + EXPORT freetype-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + FRAMEWORK DESTINATION Library/Frameworks + COMPONENT libraries) + install( + EXPORT freetype-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype + FILE freetype-config.cmake + COMPONENT headers) + install( + FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype + COMPONENT headers) +endif () # Packaging -# CPack version numbers for release tarball name. +set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/docs/LICENSE.TXT") + set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}}) -if (NOT DEFINED CPACK_PACKAGE_DESCRIPTION_SUMMARY) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_NAME}") -endif () -if (NOT DEFINED CPACK_SOURCE_PACKAGE_FILE_NAME) - set(CPACK_SOURCE_PACKAGE_FILE_NAME - "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}-r${PROJECT_REV}" - CACHE INTERNAL "tarball basename" - ) -endif () -set(CPACK_SOURCE_GENERATOR TGZ) -set(CPACK_SOURCE_IGNORE_FILES - "/CVS/;/.svn/;.swp$;.#;/#;/build/;/serial/;/ser/;/parallel/;/par/;~;/preconfig.out;/autom4te.cache/;/.config") -set(CPACK_GENERATOR TGZ) -include(CPack) - +set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") -# add make dist target -add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) +if (WIN32) + set(CPACK_GENERATOR ZIP) +else () + set(CPACK_GENERATOR TGZ) +endif () +set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") +set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers") +set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION + "Library used to build programs which use FreeType") +set(CPACK_COMPONENT_HEADERS_DESCRIPTION + "C/C++ header files for use with FreeType") +set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) +set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") +set(CPACK_COMPONENT_HEADERS_GROUP "Development") -# eof +include(CPack) diff --git a/ChangeLog b/ChangeLog index 42216762d..42f7c34ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,2093 +1,1960 @@ -2015-08-11 Werner Lemberg +2020-10-20 Werner Lemberg - [builds/unix] Minor. + * Version 2.10.4 released. + ========================== - * builds/unix/configure.raw: - s/lib{priv,staticconf}/libs{priv,staticconf}/ for orthogonality with - similarly named uppercase variables. -2015-08-10 Alexei Podtelezhnikov + Tag sources with `VER-2-10-4'. - [type1,cid,type42] Minor improvements. - - * src/type1/t1load.c (t1_parse_font_matrix): Scale units per EM only - when necessary. Refresh comments. - * src/cid/cidload.c (cid_parse_font_matrix): Ditto. - * src/type42/t42parse.c (t42_parse_font_matrix): Refresh comments. - -2015-08-08 Werner Lemberg - - [type42] Fix glyph access. - - This is a severe bug: We've missed one level of indirection, as - described in the Type 42 specification. As a result, ftview - sometimes showed incorrect glyphs for given glyph names, and even - displayed `error 0x0006' (invalid argument!) in case the number of - glyph indices differed between the Type 42 font and the embedded - TTF. - - Apparently, noone ever noticed it; this shows how much Type 42 fonts - are in use... - - * src/type42/t42objs.c (T42_GlyphSlot_Load): Map Type 42 glyph index - to embedded TTF's glyph index. - -2015-08-08 Werner Lemberg - - [type42] Minor clean-up. - - * src/type42/t42parse.c (t42_parse_font_matrix): Remove unused - variable. - -2015-08-06 Alexei Podtelezhnikov - - [type42] Parse FontMatrix according to specifications. - - * src/type42/t42parse.c (t42_parse_font_matrix): Type 42 FontMatrix - does not need scaling by 1000. Units_per_EM are taken from the - embedded TrueType. - -2015-08-06 Werner Lemberg - - [autofit] Improve Arabic hinting. - - Problem reported by Titus Nemeth (by using - ttfautohint). - - * src/autofit/afblue.dat: Add neutral blue zone for the tatweel - character. - - * src/autofit/afblue.c, src/autofit/afblue.h: Regenerated. + * docs/VERSION.TXT: Add entry for version 2.10.4. + * docs/CHANGES: Updated. -2015-08-05 Alexei Podtelezhnikov + * README, src/base/ftver.rc, builds/windows/vc2010/index.html, + builds/windows/visualc/index.html, + builds/windows/visualce/index.html, + builds/wince/vc2005-ce/index.html, + builds/wince/vc2008-ce/index.html, docs/freetype-config.1: + s/2.10.3/2.10.4/, s/2103/2104/. - [truetype] Clean up types. + * include/freetype/freetype.h (FREETYPE_PATCH): Set to 4. - * src/truetype/ttobjs.c (TT_Size): Move declaration from here. - * include/freetype/internal/tttypes.h (TT_Size): ... to here. - (TT_LoaderRec): Switch to appropriate types for `face' and `size'. - * src/truetype/ttgload.c: Remove corresponding type casts. - * src/truetype/ttsubpix.c: Ditto. + * builds/unix/configure.raw (version_info): Set to 23:4:17. + * CMakeLists.txt (VERSION_PATCH): Set to 4. -2015-08-05 Werner Lemberg +2020-10-19 Werner Lemberg - [autofit] Improve recognition of flat vs. rounded segments. + [sfnt] Fix heap buffer overflow (#59308). - Lower the flatness threshold from upem/8 to upem/14, making the - auto-hinter accept shorter elements. + This is CVE-2020-15999. - Synchronize flat/round stem selection algorithm with blue zone code. + * src/sfnt/pngshim.c (Load_SBit_Png): Test bitmap size earlier. - * src/autofit/aflatin.c (FLAT_THRESHOLD): New macro. - (af_latin_metrics_init_blues): Use it. - (af_latin_hints_compute_segments): Collect information on maximum - and minimum coordinates of `on' points; use this to add a constraint - for the flat/round decision similar to - `af_latin_metrics_init_blues'. +2020-10-17 Alexei Podtelezhnikov -2015-08-04 Werner Lemberg + * src/sfnt/tt{colr,cpal}.c: Fix signedness warnings from VC++. - Another left-shift bug (#45681). +2020-10-17 Alexei Podtelezhnikov - * src/base/ftobjs.c (IsMacBinary): Only accept positive values for - `dlen'. + * src/sfnt/sfwoff2.c (Read255UShort): Tweak types to please VC++. -2015-08-03 Alexei Podtelezhnikov +2020-10-10 Werner Lemberg - [base] Fix `ft_corner_orientation'. + * Version 2.10.3 released. + ========================== - Remove casting from `FT_Long' to `FT_Int' that might change the sign - of the return value and make it faster too. - * src/base/ftcalc.c (ft_corner_orientation): On 32-bit systems, stay - with 32-bit arithmetic when safe. Use plain math on 64-bit systems. - * src/pshinter/pshalgo.c: Remove old unused code. + Tag sources with `VER-2-10-3'. -2015-08-03 Werner Lemberg + * docs/VERSION.TXT: Add entry for version 2.10.3. - * src/truetype/ttgload.c (load_truetype_glyph) - [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Fix crash for composite glyphs - having a depth greater than 1. + * README, src/base/ftver.rc, builds/windows/vc2010/index.html, + builds/windows/visualc/index.html, + builds/windows/visualce/index.html, + builds/wince/vc2005-ce/index.html, + builds/wince/vc2008-ce/index.html, docs/freetype-config.1: + s/2.10.2/2.10.3/, s/2102/2103/. -2015-08-03 Werner Lemberg + * include/freetype/freetype.h (FREETYPE_PATCH): Set to 3. - Fix typo in clang bug from 2015-07-31 (#45678). + * builds/unix/configure.raw (version_info): Set to 23:3:17. + * CMakeLists.txt (VERSION_PATCH): Set to 3. - * src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Fix inequality. +2020-09-25 Werner Lemberg -2015-08-02 Werner Lemberg + [autofit] Synchronize with ttfautohint. - * CMakeLists.txt: Improve shared library support. + This corresponds to the following commits in the ttfautohint git + repository: - Based on a patch from John Cary . + bb6842bd3bd437b7b4a7921b0376c860f5e73d18 Typo, formatting. + d5c91ddb1cb310257a3dfe9a8e20e1fc51335faa Add Medefaidrin script. -2015-08-02 Werner Lemberg + * src/autofit/afblue.dat: Add blue zone data for Medefaidrin. + * src/autofit/afblue.c, src/autofit/afblue.h: Regenerated. - * builds/unix/freetype-config.in (enable_shared): Remove. Unused. + * src/autofit/afscript.h: Add Medefaidrin standard characters. -2015-08-02 Werner Lemberg + * src/autofit/afranges.c, src/autofit/afstyles.h: Add Medefaidrin + data. - Fix more invalid left-shifts. +2020-09-25 Werner Lemberg - * src/pfr/pfrgload.c (pfr_glyph_load_compound): Use multiplication, - not left-shift. + Move `scripts/make_distribution_archives.py` to `src/tools`. - * src/truetype/ttgxvar.c (ft_var_load_avar, ft_var_load_gvar, - tt_face_vary_cvt, TT_Vary_Apply_Glyph_Deltas): Use multiplication, - not left-shift. + * scr/tools/scripts/make_distribution_archives.py: (_TOP_DIR, + _SCRIPT_DIR): Updated to new location. + (main): s/shutils.copyfile/shutils.copy/ to preserve file + permissions. + (main): Prefix source file paths with `git_dir` while copying files + to allow calls of the script from other places than the top-level + directory. -2015-07-31 Werner Lemberg +2020-09-24 Werner Lemberg - Fix some bugs found by clang's `-fsanitize=undefined' (#45661). + * src/cff/cffgload.c (cff_slot_load): Scale `vertBearingY`. - * src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Only accept - positive values from header. - Check overflow. + Towards the end of the the function there is a call to + `FT_Outline_Get_CBox` that retrieves the glyph bbox in scaled units. + That sets `horiBearing{X,Y}` and `vertBearingX` but `vertBearingY` + is left alone, and is not scaled. - * src/base/ftoutln.c (SCALED): Correctly handle left-shift of - negative values. + Patch from Eric Muller . - * src/bdf/bdf.h (_bdf_glyph_modified, _bdf_set_glyph_modified, - _bdf_clear_glyph_modified): Use unsigned long constant. +2020-09-24 Werner Lemberg - * src/bdf/bdfdrivr.c (BDF_Size_Select, BDF_Glyph_Load): Don't - left-shift values that can be negative. + * src/base/ftobjs.c (FT_Load_Glyph): Trace glyph metrics. - * src/pcf/pcfdrivr.c (PCF_Size_Select, PCF_Glyph_Load): Don't - left-shift values that can be negative. +2020-09-22 Werner Lemberg - * src/raster/ftraster.c (SCALED): Correctly handle left-shift of - negative values. + [meson] Move auxiliary scripts to `builds/meson`. - * src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Don't left-shift - values that can be negative. + Suggested by Alexei. - * src/truetype/ttgload.c (TT_Load_Composite_Glyph, - compute_glyph_metrics, load_sbit_image): Don't left-shift values - that can be negative. + * scripts/*.py: Move meson scripts to... + * builds/meson/*.py: ... this new location. -2015-07-31 Werner Lemberg + * meson.build: Updated. - Define FT_LONG_MAX. +2020-09-21 David Turner - * include/freetype/config/ftstdlib.h (FT_LONG_MAX): New macro. - * src/cff/cf2arrst.c (cf2_arrstack_setNumElements): Use it. + Add python script for building tarballs. -2015-07-28 Alexei Podtelezhnikov + * scripts/make_distribution_archives.py: New file. - * src/base/ftcalc.c (FT_Vector_NormLen): Clarify. + This standalone Python script should be equivalent to running `make + dist` with the Make-based build system, with the following minor + differences: -2015-07-27 Alexei Podtelezhnikov + - Since `make distclean` doesn't always clean up `objs/` properly, + `make dist` archives may contain some stale binaries like + `objs/.libs/libfreetype.so.6` or others. - * src/base/ftcalc.c (FT_Vector_NormLen): Explicate type conversions. + - `config.guess` and `config.sub` are not updated unless option + `--gnu-config-dir=DIR` is used to specify the location of these + files. -2015-07-26 Matthias Clasen + - Some bits of the auto-generated reference documentation may + appear in slightly different order, probably due to issues related + to mkdocs and docwriter. - [cff] Don't use `hmtx' table for LSB (#45520). + As an example, the call - * src/cff/cffgload.c (cff_slot_load): Use `htmx' table for advance - width only. Bug introduced 2015-04-10. + scripts/make_distribution_archives.py /tmp/freetype2-dist -2015-07-09 Werner Lemberg + creates the following files under `/tmp/freetype2-dist`: - Better support of user-supplied C++ namespaces. + freetype-.tar.gz + freetype-.tar.xz + ft.zip - See +2020-09-21 Werner Lemberg - http://lists.nongnu.org/archive/html/freetype-devel/2015-07/msg00008.html + * scripts/extract_freetype_version.py: Fix regex typos. - for a rationale. +2020-09-21 David Turner - * src/autofit/afpic.h, src/base/basepic.h, src/cff/cffpic.h, - src/pshinter/pshpic.h, src/psnames/pspic.h, src/raster/rastpic.h, - src/sfnt/sfntpic.h, src/smooth/ftspic.h, src/truetype/ttpic.h - (FT_BEGIN_HEADER, FT_END_HEADER): Move macro calls to not enclose - header files that contain FT_{BEGIN,END}_HEADER macros by - themselves. + Add Meson build project file. - * src/autofit/aftypes.h [FT_DEBUG_AUTOFIT]: Include - FT_CONFIG_STANDARD_LIBRARY_H earlier. + Example usage: - * src/truetype/ttpic.h: Include FT_INTERNL_PIC_H. + # Configure Meson build in directory `build-meson` to generate + # release binaries comparable to to the ones from the + # autotools/make build system. + meson setup build-meson \ + --prefix=/usr/local \ + --buildtype=debugoptimized \ + --strip \ + -Db_ndebug=true -2015-07-07 Werner Lemberg + # After configuring the Meson build with the above command, + # compile and install to `/usr/local/`; this includes a pkg-config + # file. + ninja -C build-meson install - [sfnt] Make `tt_face_get_name' member of the SFNT interface. + # Alternatively, compile and install to `/tmp/aa/usr/local/...` + # for packaging. + DESTDIR=/tmp/aa ninja -C build-meson install - * include/freetype/internal/sfnt.h (TT_Get_Name_Func): New - prototype. - (SFNT_Interface, FT_DEFINE_SFNT_INTERFACE): New member `get_name'. + # Generate documentation under `build-meson/docs`. + ninja -C build-meson docs - * src/sfnt/sfdriver.c (sfnt_interface): Updated. + Library size comparison for stripped `libfreetype.so` generated by + all three build systems: - * src/sfnt/sfobjs.c (tt_face_get_name): Tag it with `LOCAL_DEF'. - * src/sfnt/sfobjs.h: Add prototype for it. + - Default build (autotools + libtool): 712 KiB + - CMake build (RelWithDebInfo): 712 KiB + - Meson build: 712 KiB -2015-06-30 Werner Lemberg - Fix some clang compiler warnings. + * meson.build: New top-level Meson build file for the library. - * src/base/ftoutln.c (FT_Outline_EmboldenXY), src/cff/cf2intrp.c - (cf2_interpT2CharString), src/truetype/ttgload.c - (load_truetype_glyph), src/truetype/ttgxvar.c (tt_handle_deltas), - src/truetype/ttinterp.c (Ins_INSTCTRL): Fix signedness issues. + * meson_options.txt: New file. It holds user-selectable options for + the build, which can be printed with `meson configure`, and selected + at `meson setup` or `meson --reconfigure` time with + `-D