Skip to content

Commit 2eb8938

Browse files
committed
upgrade vendored harfbuzz to 8.5.0,
- fix cmake setup so that the optional freetype symbols can actually be used in our vendored harfbuzz, - support Windows- and Apple-specific harfbuzz backends, - minor update to vendored freetype along the way. Reference issue: #532
1 parent 0a56d53 commit 2eb8938

File tree

8 files changed

+105
-350
lines changed

8 files changed

+105
-350
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
[submodule "external/harfbuzz"]
66
path = external/harfbuzz
77
url = https://github.com/libsdl-org/harfbuzz.git
8-
branch = 8.1.1-SDL
8+
branch = 8.5.0-SDL

CMakeLists.txt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,61 @@ set(PC_REQUIRES)
182182
set(BUILD_SHARED_LIBS OFF)
183183

184184
if(SDL2TTF_HARFBUZZ)
185+
set(harfbuzz_link_libraries)
185186
if(SDL2TTF_HARFBUZZ_VENDORED)
186187
message(STATUS "${PROJECT_NAME}: Using vendored harfbuzz library")
188+
# HB_BUILD_SUBSET variable is used by harfbuzz
189+
set(HB_BUILD_SUBSET OFF CACHE BOOL "build harfbuzz-subset" FORCE)
187190
# HB_BUILD_UTILS variable is used by harfbuzz
188191
set(HB_BUILD_UTILS OFF CACHE BOOL "harfbuzz build utils" FORCE)
189192
# SKIP_INSTALL_LIBRARIES variable is used by harfbuzz
190193
set(SKIP_INSTALL_LIBRARIES ON CACHE BOOL "harfbuzz install option" FORCE)
191194
# HB_HAVE_FREETYPE variable is used by harfbuzz
192195
set(HB_HAVE_FREETYPE ${SDL2TTF_FREETYPE} CACHE BOOL "harfbuzz freetype helpers" FORCE)
196+
# target-specific harfbuzz backends :
197+
if(APPLE)
198+
# Minimum version for $<LINK_LIBRARY:feature,library-list>
199+
cmake_minimum_required(VERSION 3.24)
200+
# HB_HAVE_CORETEXT variable is used by harfbuzz
201+
set(HB_HAVE_CORETEXT ON CACHE BOOL "harfbuzz coretext backend" FORCE)
202+
endif()
203+
if(WIN32)
204+
# HB_HAVE_UNISCRIBE variable is used by harfbuzz
205+
set(HB_HAVE_UNISCRIBE ON CACHE BOOL "harfbuzz uniscribe backend" FORCE)
206+
# HB_HAVE_GDI variable is used by harfbuzz
207+
set(HB_HAVE_GDI ON CACHE BOOL "harfbuzz windows backend" FORCE)
208+
endif()
209+
## HACK: HACK: These fail detection, we rely on our own vendored FreeType having them ##
210+
set(HAVE_FT_GET_VAR_BLEND_COORDINATES 1 CACHE BOOL "FT_Get_Var_Blend_Coordinates" FORCE)
211+
set(HAVE_FT_SET_VAR_BLEND_COORDINATES 1 CACHE BOOL "FT_Set_Var_Blend_Coordinates" FORCE)
212+
set(HAVE_FT_DONE_MM_VAR 1 CACHE BOOL "FT_Done_MM_Var" FORCE)
213+
set(HAVE_FT_GET_TRANSFORM 1 CACHE BOOL "FT_Get_Transform" FORCE)
193214
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/harfbuzz/CMakeLists.txt")
194215
message(FATAL_ERROR "No harfbuzz sources found. Install a harfbuzz development package or run the download script in the external folder.")
195216
endif()
196217
add_subdirectory(external/harfbuzz EXCLUDE_FROM_ALL)
197218
# harfbuzz is a c++ project, enable c++ here to ensure linking to the c++ standard library
198219
enable_language(CXX)
220+
set(harfbuzz_link_libraries harfbuzz::harfbuzz)
199221
if(NOT SDL2TTF_BUILD_SHARED_LIBS)
200222
list(APPEND INSTALL_EXTRA_TARGETS harfbuzz)
201223
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:harfbuzz>)
224+
if(WIN32)
225+
# for uniscribe and gdi backends :
226+
list(APPEND harfbuzz_link_libraries usp10 gdi32 rpcrt4)
227+
list(APPEND PC_LIBS -lusp10 -lgdi32 -lrpcrt4)
228+
elseif(APPLE)
229+
# for coretext backend :
230+
list(APPEND harfbuzz_link_libraries "$<LINK_LIBRARY:FRAMEWORK,CoreText>")
231+
list(APPEND harfbuzz_link_libraries "$<LINK_LIBRARY:FRAMEWORK,CoreGraphics>")
232+
list(APPEND harfbuzz_link_libraries "$<LINK_LIBRARY:FRAMEWORK,CoreFoundation>")
233+
list(APPEND PC_LIBS "-Wl,-framework,CoreText")
234+
list(APPEND PC_LIBS "-Wl,-framework,CoreGraphics")
235+
list(APPEND PC_LIBS "-Wl,-framework,CoreFoundation")
236+
else()
237+
find_package(Threads)
238+
set(harfbuzz_link_libraries Threads::Threads)
239+
endif()
202240
endif()
203241
if(NOT TARGET harfbuzz::harfbuzz)
204242
add_library(harfbuzz::harfbuzz ALIAS harfbuzz)
@@ -207,9 +245,10 @@ if(SDL2TTF_HARFBUZZ)
207245
message(STATUS "${PROJECT_NAME}: Using system harfbuzz library")
208246
find_package(harfbuzz "${HARFBUZZ_REQUIRED_VERSION}" REQUIRED)
209247
list(APPEND PC_REQUIRES harfbuzz)
248+
set(harfbuzz_link_libraries harfbuzz::harfbuzz)
210249
endif()
211250
target_compile_definitions(SDL2_ttf PRIVATE TTF_USE_HARFBUZZ=1)
212-
target_link_libraries(SDL2_ttf PRIVATE harfbuzz::harfbuzz)
251+
target_link_libraries(SDL2_ttf PRIVATE ${harfbuzz_link_libraries} )
213252
endif()
214253

215254
if(SDL2TTF_FREETYPE)

VisualC/SDL_ttf.vcxproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@
8585
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
8686
</PropertyGroup>
8787
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
88-
<IncludePath>..\external\freetype\include;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
88+
<IncludePath>..\external\freetype\include;..\external\harfbuzz;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
8989
<LibraryPath>$(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath)</LibraryPath>
9090
</PropertyGroup>
9191
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
92-
<IncludePath>..\external\freetype\include;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
92+
<IncludePath>..\external\freetype\include;..\external\harfbuzz;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
9393
<LibraryPath>$(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath)</LibraryPath>
9494
</PropertyGroup>
9595
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
96-
<IncludePath>..\external\freetype\include;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
96+
<IncludePath>..\external\freetype\include;..\external\harfbuzz;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
9797
<LibraryPath>$(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath)</LibraryPath>
9898
</PropertyGroup>
9999
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
100-
<IncludePath>..\external\freetype\include;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
100+
<IncludePath>..\external\freetype\include;..\external\harfbuzz;..\external\harfbuzz\src;$(SolutionDir)..\..\SDL\include;$(IncludePath)</IncludePath>
101101
<LibraryPath>$(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath)</LibraryPath>
102102
</PropertyGroup>
103103
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -112,7 +112,7 @@
112112
</Midl>
113113
<ClCompile>
114114
<Optimization>Disabled</Optimization>
115-
<PreprocessorDefinitions>DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115+
<PreprocessorDefinitions>DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;HAVE_CONFIG_H;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
116116
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
117117
<WarningLevel>Level3</WarningLevel>
118118
<DebugInformationFormat>OldStyle</DebugInformationFormat>
@@ -122,7 +122,7 @@
122122
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
123123
</ResourceCompile>
124124
<Link>
125-
<AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
125+
<AdditionalDependencies>usp10.lib;gdi32.lib;rpcrt4.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
126126
<AdditionalLibraryDirectories>external\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
127127
<GenerateDebugInformation>true</GenerateDebugInformation>
128128
<SubSystem>Windows</SubSystem>
@@ -140,7 +140,7 @@
140140
</Midl>
141141
<ClCompile>
142142
<Optimization>Disabled</Optimization>
143-
<PreprocessorDefinitions>DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
143+
<PreprocessorDefinitions>DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;HAVE_CONFIG_H;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
144144
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
145145
<WarningLevel>Level3</WarningLevel>
146146
<DebugInformationFormat>OldStyle</DebugInformationFormat>
@@ -149,7 +149,7 @@
149149
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
150150
</ResourceCompile>
151151
<Link>
152-
<AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
152+
<AdditionalDependencies>usp10.lib;gdi32.lib;rpcrt4.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
153153
<AdditionalLibraryDirectories>external\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
154154
<GenerateDebugInformation>true</GenerateDebugInformation>
155155
<SubSystem>Windows</SubSystem>
@@ -166,7 +166,7 @@
166166
</HeaderFileName>
167167
</Midl>
168168
<ClCompile>
169-
<PreprocessorDefinitions>DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
169+
<PreprocessorDefinitions>DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;HAVE_CONFIG_H;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
170170
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
171171
<WarningLevel>Level3</WarningLevel>
172172
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
@@ -176,7 +176,7 @@
176176
</ResourceCompile>
177177
<Link>
178178
<SubSystem>Windows</SubSystem>
179-
<AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
179+
<AdditionalDependencies>usp10.lib;gdi32.lib;rpcrt4.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
180180
<AdditionalLibraryDirectories>external\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
181181
<EnableCOMDATFolding>true</EnableCOMDATFolding>
182182
<OptimizeReferences>true</OptimizeReferences>
@@ -193,7 +193,7 @@
193193
</HeaderFileName>
194194
</Midl>
195195
<ClCompile>
196-
<PreprocessorDefinitions>DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
196+
<PreprocessorDefinitions>DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;TTF_USE_HARFBUZZ=1;HAVE_CONFIG_H;FT_PUBLIC_FUNCTION_ATTRIBUTE=;FT_CONFIG_OPTION_USE_HARFBUZZ;FT2_BUILD_LIBRARY;HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
197197
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
198198
<WarningLevel>Level3</WarningLevel>
199199
</ClCompile>
@@ -202,7 +202,7 @@
202202
</ResourceCompile>
203203
<Link>
204204
<SubSystem>Windows</SubSystem>
205-
<AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
205+
<AdditionalDependencies>usp10.lib;gdi32.lib;rpcrt4.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
206206
<AdditionalLibraryDirectories>external\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
207207
<EnableCOMDATFolding>true</EnableCOMDATFolding>
208208
<OptimizeReferences>true</OptimizeReferences>

0 commit comments

Comments
 (0)