-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ftgl: Fix builds with freetype 2.13.3
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
1 parent
3935297
commit 1e4e02f
Showing
7 changed files
with
429 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
graphics/ftgl/files/0010-demo-support-latin1-keystrokes.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.