Skip to content

Commit be94566

Browse files
committed
require freetype version at least 2.8.0
1 parent 67eced5 commit be94566

2 files changed

Lines changed: 2 additions & 25 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ cmake_dependent_option(SDLTTF_SAMPLES_INSTALL "Install the SDL3_ttf sample progr
9999
# For style consistency, create a SDLTTF_FREETYPE CMake variable. This variable is NOT configurable.
100100
set(SDLTTF_FREETYPE ON)
101101
set(SDLTTF_FREETYPE_VENDORED "${SDLTTF_VENDORED}")
102+
set(FREETYPE_REQUIRED_VERSION "2.8.0")
102103

103104
set(HARFBUZZ_REQUIRED_VERSION "2.3.1")
104105
option(SDLTTF_HARFBUZZ "Use harfbuzz to improve text shaping" ON)
@@ -356,7 +357,7 @@ if(SDLTTF_FREETYPE)
356357
endif()
357358
else()
358359
message(STATUS "${PROJECT_NAME}: Using system freetype library")
359-
find_package(Freetype REQUIRED)
360+
find_package(Freetype "${FREETYPE_REQUIRED_VERSION}" REQUIRED)
360361
list(APPEND PC_REQUIRES freetype2)
361362
target_link_libraries(${sdl3_ttf_target_name} PRIVATE Freetype::Freetype)
362363
endif()

src/SDL_ttf.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@
3434
#include FT_TRUETYPE_TABLES_H
3535
#include FT_IMAGE_H
3636

37-
/* Enable rendering with color
38-
* Freetype may need to be compiled with FT_CONFIG_OPTION_USE_PNG */
39-
#if defined(FT_HAS_COLOR)
40-
# define TTF_USE_COLOR 1
41-
#else
42-
# define TTF_USE_COLOR 0
43-
#endif
44-
4537
// Enable Signed Distance Field rendering (requires latest FreeType version)
4638
#if defined(FT_RASTER_FLAG_SDF)
4739
# define TTF_USE_SDF 1
@@ -2518,11 +2510,9 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
25182510

25192511
int ft_load = FT_LOAD_DEFAULT | font->ft_load_target;
25202512

2521-
#if TTF_USE_COLOR
25222513
if (want & CACHED_COLOR) {
25232514
ft_load |= FT_LOAD_COLOR;
25242515
}
2525-
#endif
25262516

25272517
if (FT_HAS_SVG(font->face)) {
25282518
// We won't get metrics unless we add FT_LOAD_COLOR
@@ -2724,11 +2714,9 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
27242714

27252715
// Compute pitch: glyph is padded right to be able to read an 'aligned' size expanding on the right
27262716
dst->pitch = dst->width + alignment;
2727-
#if TTF_USE_COLOR
27282717
if (src->pixel_mode == FT_PIXEL_MODE_BGRA && (want & CACHED_COLOR)) {
27292718
dst->pitch += 3 * dst->width;
27302719
}
2731-
#endif
27322720
if (src->pixel_mode == FT_PIXEL_MODE_LCD) {
27332721
dst->pitch += 3 * dst->width;
27342722
}
@@ -2771,11 +2759,9 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
27712759
} else if (src->pixel_mode == FT_PIXEL_MODE_GRAY4) {
27722760
quotient = src->width / 2;
27732761
remainder = src->width & 0x1;
2774-
#if TTF_USE_COLOR
27752762
} else if (src->pixel_mode == FT_PIXEL_MODE_BGRA) {
27762763
quotient = src->width;
27772764
remainder = 0;
2778-
#endif
27792765
} else if (src->pixel_mode == FT_PIXEL_MODE_LCD) {
27802766
quotient = src->width / 3;
27812767
remainder = 0;
@@ -2918,7 +2904,6 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
29182904
NORMAL_GRAY4(2);
29192905
}
29202906
NORMAL_GRAY4(remainder);
2921-
#if TTF_USE_COLOR
29222907
} else if (src->pixel_mode == FT_PIXEL_MODE_BGRA) {
29232908
if (want & CACHED_COLOR) {
29242909
SDL_memcpy(dstp, srcp, 4 * src->width);
@@ -2941,7 +2926,6 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
29412926
}
29422927
}
29432928
}
2944-
#endif
29452929
} else if (src->pixel_mode == FT_PIXEL_MODE_LCD) {
29462930
while (quotient--) {
29472931
Uint8 alpha = 0;
@@ -2994,23 +2978,18 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
29942978
dst->buffer -= alignment;
29952979
}
29962980

2997-
#if TTF_USE_COLOR
29982981
if (src->pixel_mode == FT_PIXEL_MODE_BGRA && (want & CACHED_COLOR)) {
29992982
dst->is_color = 1;
30002983
} else {
30012984
dst->is_color = 0;
30022985
}
3003-
#else
3004-
dst->is_color = 0;
3005-
#endif
30062986

30072987
// Mark that we rendered this format
30082988
if (mono) {
30092989
cached->stored |= CACHED_BITMAP;
30102990
} else if (src->pixel_mode == FT_PIXEL_MODE_LCD) {
30112991
cached->stored |= CACHED_LCD;
30122992
} else {
3013-
#if TTF_USE_COLOR
30142993
if (want & CACHED_COLOR) {
30152994
cached->stored |= CACHED_COLOR;
30162995
/* Most of the time, glyphs loaded with FT_LOAD_COLOR are non colored, so the cache is
@@ -3025,9 +3004,6 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
30253004
cached->stored |= CACHED_COLOR;
30263005
}
30273006
}
3028-
#else
3029-
cached->stored |= CACHED_COLOR | CACHED_PIXMAP;
3030-
#endif
30313007
}
30323008

30333009
// Free outlined glyph

0 commit comments

Comments
 (0)