FreeType: cannot load font from memory

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
danasap90
Posts: 3
Joined: Fri Jun 19, 2015 1:48 am

FreeType: cannot load font from memory

Post by danasap90 »

Hello, can anyone here explain why when I load some unique font from memory (eg. Helvetica font) it always failed to load, and my machine (and Virtual machine) always hang when reach that line. In my assembler file, I have include my font file using as a binary using "incbin", like this:

global HelveticaFont
HelveticaFont:
incbin "res/font/Helvetica.ttf"

And in my C header file, I've included this:

extern "C" unsigned int HelveticaFont;

Anda in my C source that will use the font, I use this:

print_string("Setting font as Helvetica..");
FT_Library library;
FT_Face face;
FT_Init_FreeType(&library);
FT_New_Memory_Face(library, (char*)&HelveticaFont, HELVETICA_FONT_SIZE, 0, &face);
print_string("OK");

When I test that code, my machine and virtual machine shows text:

Setting font as Helvetica..

But never reach the line that print "OK".

Can anyone here explain how is that happening? What fault that I've done? Is that because of my Newlib? Do I have a bad malloc function? Big thanks for You if you can answer this =D>
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: FreeType: cannot load font from memory

Post by Gigasoft »

We aren't psychic. The only way to find out is to debug the program. For example, add some printouts inside FT_New_Memory_Face so you can see how far it gets.
Post Reply