pantherb / setBfree

DSP tonewheel organ
http://setbfree.org
GNU General Public License v2.0
194 stars 35 forks source link

`make FONTFILE=verabd.h ...` embeds the font correctly, but loading fails #56

Open jmaibaum opened 6 years ago

jmaibaum commented 6 years ago

Hi @x42

I read your comment to #54 that setting FONTFILE=verabd.h should include the font into the GUI applications.

However, this doesn't hold true for the main GUI application, which even in case of FONTFILE=verabd.h tries to load the font from the default path given in common.mak.

This is a problem if, like on ArchLinux, the standard font path is different from the standard Debian path that is given in common.mak.

Would it be possible to allow embedding the font in every GUI application with FONTFILE=verabd.h? Or else, could you suggest the "right way" how to both embed the font in the LV2 plugin and use another path to your system font?

x42 commented 6 years ago

Oh dear. I just noticed that it needs a -DBUILTINFONT and a patch to ftgl to expose the function to load fonts from memory:

index b23e787..03ee840 100644
--- a/src/FTFont/FTFontGlue.cpp
+++ b/src/FTFont/FTFontGlue.cpp
@@ -57,6 +57,9 @@ C_TOR(ftglCreateBitmapFont, (const char *fontname),
 C_TOR(ftglCreateBufferFont, (const char *fontname),
       FTBufferFont, (fontname), FONT_BUFFER);

+C_TOR(ftglCreateBufferFontMem, (const unsigned char *pBufferBytes, size_t bufferSizeInBytes),
+      FTBufferFont, (pBufferBytes,bufferSizeInBytes), FONT_BUFFER);
+
 // FTExtrudeFont::FTExtrudeFont();
 C_TOR(ftglCreateExtrudeFont, (const char *fontname),
       FTExtrudeFont, (fontname), FONT_EXTRUDE);
diff --git a/src/FTGL/FTBufferFont.h b/src/FTGL/FTBufferFont.h
index 15d358d..b3d40ab 100644
--- a/src/FTGL/FTBufferFont.h
+++ b/src/FTGL/FTBufferFont.h
@@ -92,6 +92,7 @@ FTGL_BEGIN_C_DECLS
  * @see  FTGLfont
  */
 FTGL_EXPORT FTGLfont *ftglCreateBufferFont(const char *file);
+FTGL_EXPORT FTGLfont *ftglCreateBufferFontMem(const unsigned char *pBufferBytes, size_t bufferSizeInBytes);

 FTGL_END_C_DECLS

It's probably not viable to do this for distros.

jmaibaum commented 6 years ago

So, without a patched ftgl, embedding the font (or rather loading the embedded font) does also not work in the LV2 plugin?

I had not yet tested to run the LV2 plugin, but only noticed the missing font while running setBfreeUI after having compiled with FONTFILE=verabd.h.

x42 commented 6 years ago

So, without a patched ftgl, embedding the font (or rather loading the embedded font) does also not work in the LV2 plugin?

That is correct. Also note that setBfreeUI is just the plugin with a small jack-wrapper/LV2 host.

You can verify what font-file is opened via strace -e trace=open jalv.gtk http://gareus.org/oss/lv2/b_synth and/or strace -e trace=open ./ui/setBfreeUI

(press '?' to show the help-text for example, or "shift +L" .. and see if there's any rendered text)

I guess for GNU/Linux distributions it is easiest to use a system-wide font-file for the given distro.

jmaibaum commented 6 years ago

Alright, thanks for the information.

Yep, it always tries to load from the provided system path, which is wrong if I set FONTFILE=verabd.h at build time and thus the font fails to load, and which works correctly if I provide the standard Arch Linux path in FONTFILE.

From my point of view this ticket might then be closed as upstream bug, if the root cause is the missing visibility of ftglCreateBufferFontMem() in the ftgl toolkit? But I will leave the final decision up to you as the project maintainer.

I'll update the issue title accordingly.