Skip to content

Update the vendored FreeType version to 2.13.3#1543

Merged
ruevs merged 1 commit intosolvespace:masterfrom
iscgar:iscgar/update-freetype
Mar 7, 2025
Merged

Update the vendored FreeType version to 2.13.3#1543
ruevs merged 1 commit intosolvespace:masterfrom
iscgar:iscgar/update-freetype

Conversation

@iscgar
Copy link
Contributor

@iscgar iscgar commented Mar 6, 2025

The existing version (2.7.1) is using an ancient zlib version, which fails to build with modern Xcode tools on macOS.

Fixes #1539

The existing version (2.7.1) is using an ancient zlib version, which
fails to build with modern Xcode tools on macOS.

Fixes solvespace#1539
@iscgar iscgar force-pushed the iscgar/update-freetype branch from e4b6b12 to c3926d0 Compare March 6, 2025 21:30
@iscgar
Copy link
Contributor Author

iscgar commented Mar 6, 2025

Had to force push because I didn't have a way to test this before pushing, and apparently the name of the configuration variables to disable dependencies changed between the versions (and Brotli was added as well). What's weird though, is that we were already using WITH_ZLIB=OFF with the older version, but for some reason FreeType code was including its vendored header file of zlib regardless.

Because we build our vendored zlib and libpng anyway, there's no point in disabling their build, so I didn't include them in the list of dependencies to disable. Since they're included and found earlier, CMake picks our versions and statically links them.

WITH_HarfBuzz OFF
FT_DISABLE_BZIP2 ON
FT_DISABLE_HARFBUZZ ON
FT_DISABLE_BROTLI ON
Copy link
Member

@ruevs ruevs Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FT_DISABLE_BROTLI ON
FT_DISABLE_BROTLI ON
FT_DISABLE_PNG ON
FT_DISABLE_ZLIB ON

We should disable PNG - as it was before.
And I do not see why not to FT_DISABLE_ZLIB=ON - it disables the system ZLIB and uses the internal one anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with disabling libpng (which disables support of PNG compressed OpenType embedded bitmaps), although we build it anyway as a direct dependency of SolveSpace, so I'm not sure why we would want to prevent FreeType from using it.

As for zlib, "system" is a bit confusing here. When disabling zlib it does not use the zlib that we build as a direct dependency of SolveSpace, but rather the copy of zlib vendored in FreeType, so we just end up with two copies of zlib in the binary, each from a different version. Without disabling it, CMake ends up using the SolveSpace zlib that we introduce into the build before adding FreeType, so we have only a single version of zlib in the binary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I'm not sure why we would want to prevent FreeType from using it.

I'm not sure what "PNG compressed OpenType embedded bitmaps." are but I presume that since they are bitmaps they would be useless for the text feature of SolveSpace, which uses only the curves from the fonts.

However enabling the option causes the EXE (Windows 32 bit build with MSVC 2019 with LTO) size to decrease for me:

FT_DISABLE_PNG ON:
5.93 MB (6,218,752 bytes)

FT_DISABLE_PNG OFF:
5.92 MB (6,208,512 bytes)

WTF?!

The FT_DISABLE_ZLIB option does not influence the EXE size. So let us leave them as you configured them.

Copy link
Contributor Author

@iscgar iscgar Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird. On Linux I see the reverse (when forcing building with vendored zlib, libpng, and freetype, and with cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LTO=1 -DENABLE_SANITIZERS=0):

$ ls -ln --time-style=+"" bin/solvespace
-rwxr-xr-x 1 1000 1000 52871080  bin/solvespace
$ ls -ln --time-style=+"" ../solvespace-png
-rwxr-xr-x 1 1000 1000 52884800  ../solvespace-png

I'll try to boot into Windows and check what's happening there when I have some time.

Copy link
Contributor Author

@iscgar iscgar Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same result, though to a bit lesser extent, with -DCMAKE_BUILD_TYPE=Release:

$ ls -ln --time-style=+"" bin/solvespace
-rwxr-xr-x 1 1000 1000 5290248  bin/solvespace
$ ls -ln --time-style=+"" ../solvespace-png
-rwxr-xr-x 1 1000 1000 5294640  ../solvespace-png

And after strip -g:

$ ls -ln --time-style=+"" bin/solvespace
-rwxr-xr-x 1 1000 1000 5287192  bin/solvespace
$ ls -ln --time-style=+"" ../solvespace-png
-rwxr-xr-x 1 1000 1000 5291592  ../solvespace-png

Copy link
Contributor Author

@iscgar iscgar Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruevs I'm having trouble reproducing your results on Windows (Visual Studio 2022, with -DCMAKE_BUILD_TYPE=Release -DENABLE_LTO=1):

>dir /c bin\solvespace.exe ..\solvespace-png.exe
8,433,152 solvespace.exe
               1 File(s)      8,433,152 bytes

8,436,224 solvespace-png.exe
               1 File(s)      8,436,224 bytes

Given the fact that as you noted embedded bitmaps support is unneeded, and that on both Windows and Linux I see an increase in file size of 3-4KB, it's probably best if we disable libpng support in FreeType. Should I submit a PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ruevs
Copy link
Member

ruevs commented Mar 7, 2025

What's weird though, is that we were already using WITH_ZLIB=OFF with the older version, but for some reason FreeType code was including its vendored header file of zlib regardless.

I think it is not weird because regardless of its description:

# . Set the `WITH_ZLIB', `WITH_BZip2', `WITH_PNG', and `WITH_HarfBuzz'
#   CMake variables to `ON' or `OFF' to force or skip using a dependency.
#   Leave a variable undefined (which is the default) to use the dependency
#   only if it is available.  Example:
#
#     cmake ... -DWITH_ZLIB=ON -DWITH_HarfBuzz=OFF ...
#
# . 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).

it seems that the WITH_ZLIB define is not used anywhere in version 069083ccc ("* Version 2.7.1 released.") (or am I not finding it?).

The new option disables looking for a system ZLIB and uses the internal one instead:
image

if (NOT FT_DISABLE_ZLIB)
  if (FT_REQUIRE_ZLIB)
    find_package(ZLIB REQUIRED)
  else ()
    find_package(ZLIB)
  endif ()
endif ()

@iscgar
Copy link
Contributor Author

iscgar commented Mar 7, 2025

What's weird though, is that we were already using WITH_ZLIB=OFF with the older version, but for some reason FreeType code was including its vendored header file of zlib regardless.

I think it is not weird because regardless of its description:

[snip]

it seems that the WITH_ZLIB define is not used anywhere in version 069083ccc ("* Version 2.7.1 released.") (or am I not finding it?).

It is a bit obscure, but it is used in the CMake loop here to find the package.

@iscgar iscgar closed this Mar 7, 2025
@iscgar iscgar reopened this Mar 7, 2025
@iscgar
Copy link
Contributor Author

iscgar commented Mar 7, 2025

Accidentally closed this. Sorry for the noise.

@ruevs ruevs merged commit bd7b627 into solvespace:master Mar 7, 2025
8 checks passed
@iscgar iscgar deleted the iscgar/update-freetype branch March 7, 2025 14:48
ruevs added a commit that referenced this pull request Mar 14, 2025
devin-ai-integration bot pushed a commit to erkinalp/solvespace that referenced this pull request Apr 3, 2025
dennisyangji pushed a commit to Orthogonalpub/ode_solvespace that referenced this pull request Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS build instructions in README don't work

3 participants