Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated DED crashed on Ubuntu 22 #67

Open
hexaredecimal opened this issue Feb 13, 2023 · 5 comments
Open

Updated DED crashed on Ubuntu 22 #67

hexaredecimal opened this issue Feb 13, 2023 · 5 comments

Comments

@hexaredecimal
Copy link

I recently built DED with the new changes (clipboard and runtime shader updates) but it crashes when I try to open a file or even the text editor itself.

./ded src/main.c 
Loading src/main.c
GL version 3.3
ERROR: could not load glyph of a character with code 32

The previous version worked like a charm. If anyone can help I would really appreciate it. Thanks to Tsoding for this wonderful project.

@eloj
Copy link

eloj commented Feb 14, 2023

Same here. My guess it's that libfreetype-dev is too old for the new SDF font rendering stuff.

My Mint install comes with v2.11, and the new documented minimum is 2.13.

For me it works again if I git revert 99e9318086623 and rebuild. Not optimal, but a simple workaround.

@jayhawker6
Copy link
Contributor

funny enough I am now having issues building it at all.

@jayhawker6
Copy link
Contributor

Try running sed 's/\r$//' build.sh > out.sh and then running ./out.sh to build. IDK the new version is working for me, after being able to build it. Old versions did not have these issues though. @eloj try updating your packages and then building the new version. Out of date stuff probably has an update on your package manager. If not you could build that from source as well, though good luck with that.

@eloj
Copy link

eloj commented Feb 14, 2023

No, there are no updated packages. My dist is built on Ubuntu 22.04 LTS (Jammy), which comes with freetype 2.11, and will only see security updates.

Obviously I can build from freetype from source. I was just giving OP the easiest way forward.

Anyway, I went back to investigate, and it's indeed a bug with the space character (32) specifically, so you can do the following and get nicely scaled and rendered SDF fonts even on the older libfreetype:

diff --git a/src/free_glyph.c b/src/free_glyph.c
index 041a2a3..1df8f36 100644
--- a/src/free_glyph.c
+++ b/src/free_glyph.c
@@ -4,7 +4,7 @@
 
 void free_glyph_atlas_init(Free_Glyph_Atlas *atlas, FT_Face face)
 {
-    FT_Int32 load_flags = FT_LOAD_RENDER | FT_LOAD_TARGET_(FT_RENDER_MODE_SDF);
+    #define load_flags (i > 32 ? FT_LOAD_RENDER | FT_LOAD_TARGET_(FT_RENDER_MODE_SDF) : FT_LOAD_RENDER)
     for (int i = 32; i < 128; ++i) {
         if (FT_Load_Char(face, i, load_flags)) {
             fprintf(stderr, "ERROR: could not load glyph of a character with code %d\n", i);

I noticed it takes a lot longer to start up -- multiple seconds before you can type -- but it does work.

@jayhawker6
Copy link
Contributor

@eloj This solution seems to work like a charm for me as well, though it does take significantly longer to load. @vultureofficial try those fixes and see if it works for you as well. Perhaps this change should be merged into main? I'm not sure here.

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

No branches or pull requests

3 participants