Search code examples
c++freetypefreetype2

Get name of .bdf font using Freetype


I tried to receive the font name of a .bdf font. I am already using Freetype with bdf to render, so this works fine. However, I need to know the font name of the currently used FT_Face.

What I tried:

BDF_Property bdfProp;
FT_Get_BDF_Property(m_face, "FONT",bdfProp);
std::cout << "BDF Prop Type: " << bdfProp->type << std::endl;

This only returns "0", so it doesn't recognize the name tag inside the bdf-file (which is declared as FONT inside the bdf).


Solution

  • I got the solution:

    BDF_PropertyRec rec;
    FT_Get_BDF_Property(m_face, "FAMILY", &rec);
    

    The problem was BDF_Property, because this actually is a pointer not object. So I had a pointer with datatype before, which didn't have any memory allocated. Now I just do a call-by-reference to the PropertyRec-object itself. Works like it should ;)