# FreeType 2.13.3, trimmed to the modules the platform font adapter needs
# (EterLib/GrpFontTexture: TrueType and CFF/CFF2 faces, hinting, mono + gray rasterizers).
# CFF is needed on Android, whose only CJK fallback is the CFF2 NotoSansCJK-Regular.ttc.
# Source: https://download.savannah.gnu.org/releases/freetype/freetype-2.13.3.tar.xz
#   sha256 0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289
# Kept: include/, src/{base,sfnt,truetype,cff,psaux,pshinter,smooth,raster,psnames,gzip}, LICENSE.TXT, docs/FTL.TXT.
# mt-config/freetype/config/ftmodule.h replaces the stock module list.
set(dir "${CMAKE_CURRENT_SOURCE_DIR}")
add_library(freetype STATIC
    ${dir}/src/base/ftbase.c
    ${dir}/src/base/ftinit.c
    ${dir}/src/base/ftsystem.c
    ${dir}/src/base/ftdebug.c
    ${dir}/src/base/ftbitmap.c
    ${dir}/src/base/ftgasp.c
    ${dir}/src/base/ftsynth.c
    ${dir}/src/base/ftglyph.c
    ${dir}/src/base/ftmm.c
    ${dir}/src/sfnt/sfnt.c
    ${dir}/src/truetype/truetype.c
    ${dir}/src/cff/cff.c
    ${dir}/src/psaux/psaux.c
    ${dir}/src/pshinter/pshinter.c
    ${dir}/src/smooth/smooth.c
    ${dir}/src/raster/raster.c
    ${dir}/src/psnames/psnames.c
    ${dir}/src/gzip/ftgzip.c)
target_include_directories(freetype BEFORE PUBLIC "${dir}/mt-config" "${dir}/include")
target_compile_definitions(freetype PRIVATE FT2_BUILD_LIBRARY)
set_target_properties(freetype PROPERTIES C_STANDARD 99 POSITION_INDEPENDENT_CODE ON)
target_compile_options(freetype PRIVATE -w)
add_library(mt3p::freetype ALIAS freetype)
