Skip to content

Commit

Permalink
ftgl: Fix builds with freetype 2.13.3
Browse files Browse the repository at this point in the history
Based on research into this issue, freetype 2.13.3 changed some return
types that caused current (modern?) builds to fail as seen in the linked
ticket.

A patch was applied with frankheckenbach/ftgl#20 that appears to fix
this, but the repo owner has not indicated a plan to cut a new release
with this and other fixes since v2.4.0.

In addition to the patch files that were previously present, I have
applied all other patches from v2.4.0 to current HEAD. This involved
removing the existing patch files, but those changes have been fully
incorporated.

Builds with +doc and +universal variants worked fine and I have tested
a downstream port (gource) with this on an affected system.

macOS 15.2 24C101 arm64
Xcode 16.2 16C5032a

Closes: https://trac.macports.org/ticket/71434
  • Loading branch information
halostatue committed Jan 23, 2025
1 parent 3935297 commit 1e4e02f
Show file tree
Hide file tree
Showing 7 changed files with 429 additions and 25 deletions.
30 changes: 24 additions & 6 deletions graphics/ftgl/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ PortSystem 1.0
PortGroup github 1.0

github.setup frankheckenbach ftgl 2.4.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision 1
github.tarball_from archive
revision 2

categories graphics
license MIT
maintainers nomaintainer
Expand All @@ -25,7 +25,7 @@ autoreconf.cmd ./autogen.sh
autoreconf.args

depends_lib-append \
port:freetype
port:freetype

depends_build-append \
port:autoconf \
Expand All @@ -34,8 +34,26 @@ depends_build-append \
port:libtool \
port:pkgconfig

patchfiles AC_ARG_WITH.patch \
dylib_file.patch
patch.pre_args-replace -p0 -p1

# These patch files are generated from `git format-patch v2.40.0..HEAD` and originally
# comprised 14 different patches. All patches have been modified to remove email address
# metadata.
#
# - Patches 2, 3, 4, 5, and 7 do not relate to MacPorts and were omitted.
# - Patch 6 was modified to work after the removal of patch 3.
# - Patch 11 was folded into patch 10.
# - Patch 13 was folded into patch 12.
#
# Future revisions tracking this repository should only need to add new patch files using
# the same procedure.
patchfiles 0001-fix-duplicated-entry-in-doc.patch \
0006-use-GL_TEXTURE_BIT.patch \
0008-Use-AC_ARG_WITH-correctly.patch \
0009-Use-dylib_file-flag-correctly.patch \
0010-demo-support-latin1-keystrokes.patch \
0012-add-layout-height-width-and-depth-functions.patch \
0014-fix-type-error.patch

# Don't use MacPorts X11 since there doesn't seem to be a need to do so.
# Don't use MacPorts OpenGL (mesa) since that would bring in X11 deps.
Expand Down
51 changes: 51 additions & 0 deletions graphics/ftgl/files/0006-use-GL_TEXTURE_BIT.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
From 778b8f21ba0b71289aef37e3422d008456445971 Mon Sep 17 00:00:00 2001
From: Frank Heckenbach
Date: Fri, 24 May 2019 23:58:47 +0200
Subject: [PATCH 06/14] src/FTFont/FTBufferFont.cpp,
src/FTFont/FTTextureFont.cpp: GL_TEXTURE_ENV_MODE is not valid mask for
glPushAttrib. Use GL_TEXTURE_BIT instead to avoid leaking texture env mode.
(reported by Eddie-cz, https://github.com/frankheckenbach/ftgl/issues/3)

---
src/FTFont/FTBufferFont.cpp | 2 +-
src/FTFont/FTTextureFont.cpp | 2 +-
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/FTFont/FTBufferFont.cpp b/src/FTFont/FTBufferFont.cpp
index ce04cf56ae0f..b330a3b119f7 100644
--- a/src/FTFont/FTBufferFont.cpp
+++ b/src/FTFont/FTBufferFont.cpp
@@ -230,11 +230,11 @@ inline FTPoint FTBufferFontImpl::RenderI(const T* string, const int len,
int width, height, texWidth, texHeight;
int cacheIndex = -1;
bool inCache = false;

// Protect blending functions, GL_TEXTURE_2D and optionally GL_BLEND
- glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_TEXTURE_ENV_MODE);
+ glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT);

// Protect glPixelStorei() calls
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);

if(FTLibrary::Instance().GetLegacyOpenGLStateSet())
diff --git a/src/FTFont/FTTextureFont.cpp b/src/FTFont/FTTextureFont.cpp
index 97e876876e12..a5145cf05f53 100644
--- a/src/FTFont/FTTextureFont.cpp
+++ b/src/FTFont/FTTextureFont.cpp
@@ -239,11 +239,11 @@ template <typename T>
inline FTPoint FTTextureFontImpl::RenderI(const T* string, const int len,
FTPoint position, FTPoint spacing,
int renderMode)
{
// Protect GL_TEXTURE_2D and optionally GL_BLEND
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TEXTURE_ENV_MODE);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT);

if(FTLibrary::Instance().GetLegacyOpenGLStateSet())
{
glEnable(GL_BLEND);
/*
--
2.47.1


Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
Use AC_ARG_WITH correctly so that the advertised configure options
actually exist under their expected names.
From d44133ec49e27ca5c7b6bfcb7f8ec1c6be585d5b Mon Sep 17 00:00:00 2001
From: Ryan Schmidt
Date: Wed, 10 Feb 2021 21:35:59 -0600
Subject: [PATCH 08/14] Use AC_ARG_WITH correctly so that the advertised
configure options actually exist under their expected names.

https://github.com/frankheckenbach/ftgl/pull/13
--- m4/gl.m4.orig 2019-02-07 15:39:58.000000000 -0600
+++ m4/gl.m4 2021-02-10 21:21:30.000000000 -0600
@@ -7,11 +7,11 @@
---
m4/gl.m4 | 6 +++---
m4/glut.m4 | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/m4/gl.m4 b/m4/gl.m4
index 4a1bc4886c35..09c84ca7bdb9 100644
--- a/m4/gl.m4
+++ b/m4/gl.m4
@@ -5,15 +5,15 @@ AC_DEFUN([FTGL_CHECK_GL],
[dnl
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PATH_X])
AC_REQUIRE([AC_PATH_XTRA])

-AC_ARG_WITH([--with-gl-inc],
+AC_ARG_WITH([gl-inc],
AC_HELP_STRING([--with-gl-inc=DIR],[Directory where GL/gl.h is installed]))
Expand All @@ -17,19 +28,30 @@ https://github.com/frankheckenbach/ftgl/pull/13
-AC_ARG_WITH([--with-glu-lib],
+AC_ARG_WITH([glu-lib],
AC_HELP_STRING([--with-glu-lib=DIR],[Directory where OpenGL GLU library is installed]))

AC_LANG_SAVE
--- m4/glut.m4.orig 2019-02-07 15:39:58.000000000 -0600
+++ m4/glut.m4 2021-02-10 21:21:21.000000000 -0600
@@ -8,9 +8,9 @@
AC_LANG_C

diff --git a/m4/glut.m4 b/m4/glut.m4
index 4a2b0b87b020..450824962ce8 100644
--- a/m4/glut.m4
+++ b/m4/glut.m4
@@ -6,13 +6,13 @@ AC_DEFUN([FTGL_CHECK_GLUT],
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PATH_X])dnl
AC_REQUIRE([AC_PATH_XTRA])dnl
AC_REQUIRE([FTGL_CHECK_GL])dnl

-AC_ARG_WITH([--with-glut-inc],
+AC_ARG_WITH([glut-inc],
AC_HELP_STRING([--with-glut-inc=DIR],[Directory where GL/glut.h is installed (optional)]))
-AC_ARG_WITH([--with-glut-lib],
+AC_ARG_WITH([glut-lib],
AC_HELP_STRING([--with-glut-lib=DIR],[Directory where GLUT libraries are installed (optional)]))

AC_LANG_SAVE
AC_LANG_C

--
2.47.1

Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
From 97d2ccfbfdbaa9d19620117fdcc4e278e44a3469 Mon Sep 17 00:00:00 2001
From: Ryan Schmidt
Date: Wed, 10 Feb 2021 23:54:59 -0600
Subject: [PATCH 09/14] Use correct syntax for the -dylib_file flag

Use correct syntax for the -dylib_file flag (no space after colon).
Fixes configure failure on macOS Big Sur and later:
Fixes configure failure on macOS Big Sur and later.

configure: error: GL library could not be found, please specify its location with --with-gl-lib.

config.log contains:

configure:17551: /usr/bin/clang -o conftest -pipe -Os -DGL_SILENCE_DEPRECATION -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -arch x86_64 -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -arch x86_64 conftest.c -Xlinker -framework -Xlinker OpenGL -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib >&5
configure:17551: /usr/bin/clang -o conftest -pipe -Os -DGL_SILENCE_DEPRECATION -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -arch x86_64 -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -a
clang: error: no such file or directory: '/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib'

https://github.com/frankheckenbach/ftgl/pull/14
--- m4/gl.m4.orig 2019-02-07 15:39:58.000000000 -0600
+++ m4/gl.m4 2021-02-10 23:23:19.000000000 -0600
@@ -50,7 +50,7 @@
---
m4/gl.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/m4/gl.m4 b/m4/gl.m4
index 09c84ca7bdb9..a4c789f873b6 100644
--- a/m4/gl.m4
+++ b/m4/gl.m4
@@ -48,11 +48,11 @@ FRAMEWORK_OPENGL=""
PRELIBS="$LIBS"
LIBS="$LIBS -Xlinker -framework -Xlinker OpenGL"
# -Xlinker is used because libtool is busted prior to 1.6 wrt frameworks
AC_TRY_LINK([#include <OpenGL/gl.h>], [glBegin(GL_POINTS)],
[GL_DYLIB="/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
Expand All @@ -20,3 +32,8 @@ https://github.com/frankheckenbach/ftgl/pull/14
ac_cv_search_glBegin="$FRAMEWORK_OPENGL"
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
if test x"$FRAMEWORK_OPENGL" != "x"; then
with_gl_lib="$FRAMEWORK_OPENGL"
--
2.47.1

140 changes: 140 additions & 0 deletions graphics/ftgl/files/0010-demo-support-latin1-keystrokes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
From a867c7a2e02ab8b47b1322f2903cfaa44c756b9b Mon Sep 17 00:00:00 2001
From: Frank Heckenbach
Date: Thu, 17 Nov 2022 00:43:20 +0100
Subject: [PATCH 10/14] demo/FTGLDemo.cpp, demo/FTGLMFontDemo.cpp: support
Latin1 key strokes (fixes #15)

---
demo/FTGLDemo.cpp | 34 +++++++++++++++++++++++++++++-----
demo/FTGLMFontDemo.cpp | 34 +++++++++++++++++++++++++++++-----
2 files changed, 58 insertions(+), 10 deletions(-)

diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index 01f9049530f2..49e550c9cc86 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -526,10 +526,35 @@ void myinit(const char* file)
textures[i]);
}
}


+/*
+ * Simple conversion from Unicode character to UTF-8 string.
+ * (In real code, you may want want to use a library such as ICU or
+ * newer C++ features instead, but this avoids additional dependencies.)
+ * s must contain enough space for up to 4 bytes.
+ * Returns number of bytes written.
+ */
+int ToUTF8 (unsigned int c, char *s)
+{
+ char *t = s;
+ int n = 0;
+ if (c < 0x80)
+ *s++ = c;
+ else if (c < 0x800)
+ *s++ = c >> (n = 6) | 0xc0;
+ else if (c < 0x10000)
+ *s++ = c >> (n = 12) | 0xe0;
+ else
+ *s++ = c >> (n = 18) | 0xf0;
+ while (n)
+ *s++ = (c >> (n -= 6) & 0x3f) | 0x80;
+ return s - t;
+}
+
+
void parsekey(unsigned char key, int, int)
{
switch (key)
{
case 27:
@@ -571,18 +596,17 @@ void parsekey(unsigned char key, int, int)
}
break;
default:
if(mode == INTERACTIVE)
{
- myString[0] = key;
- myString[1] = 0;
+ myString[ToUTF8 (key, myString)] = 0;
}
else
{
- myString[carat] = key;
- myString[carat + 1] = 0;
- carat = carat > 2000 ? 2000 : carat + 1;
+ int r = ToUTF8 (key, myString + carat) + carat;
+ myString[r] = 0;
+ carat = r > 2000 ? 2000 : r;
}
break;
}

glutPostRedisplay();
diff --git a/demo/FTGLMFontDemo.cpp b/demo/FTGLMFontDemo.cpp
index 196b54c7b8a8..f5bdb829d3a5 100644
--- a/demo/FTGLMFontDemo.cpp
+++ b/demo/FTGLMFontDemo.cpp
@@ -482,10 +482,35 @@ void myinit(int numFontFiles)
simpleLayout.SetLineLength(InitialLineLength);
simpleLayout.SetFont(fonts[current_font]);
}


+/*
+ * Simple conversion from Unicode character to UTF-8 string.
+ * (In real code, you may want want to use a library such as ICU or
+ * newer C++ features instead, but this avoids additional dependencies.)
+ * s must contain enough space for up to 4 bytes.
+ * Returns number of bytes written.
+ */
+int ToUTF8 (unsigned int c, char *s)
+{
+ char *t = s;
+ int n = 0;
+ if (c < 0x80)
+ *s++ = c;
+ else if (c < 0x800)
+ *s++ = c >> (n = 6) | 0xc0;
+ else if (c < 0x10000)
+ *s++ = c >> (n = 12) | 0xe0;
+ else
+ *s++ = c >> (n = 18) | 0xf0;
+ while (n)
+ *s++ = (c >> (n -= 6) & 0x3f) | 0x80;
+ return s - t;
+}
+
+
void parsekey(unsigned char key, int, int)
{
switch (key)
{
case 27:
@@ -527,18 +552,17 @@ void parsekey(unsigned char key, int, int)
}
break;
default:
if(mode == INTERACTIVE)
{
- myString[0] = key;
- myString[1] = 0;
+ myString[ToUTF8 (key, myString)] = 0;
}
else
{
- myString[carat] = key;
- myString[carat + 1] = 0;
- carat = carat > 2000 ? 2000 : carat + 1;
+ int r = ToUTF8 (key, myString + carat) + carat;
+ myString[r] = 0;
+ carat = r > 2000 ? 2000 : r;
}
break;
}

glutPostRedisplay();
--
2.47.1

Loading

0 comments on commit 1e4e02f

Please sign in to comment.