Breakpoint 1, fruit::FreetypeFontfaceLoader::bitmap (handle=0x5555555c58e0, char_index=65)
at lib/./freetype_fontface_loader.hpp:42
42 FT_Load_Char(handle, char_index, FT_LOAD_RENDER);
(gdb) print *handle
$1 = {num_faces = 1, face_index = 0, face_flags = 2649, style_flags = 0, num_glyphs = 6253,
family_name = 0x5555555c6520 "DejaVu Sans", style_name = 0x5555555c6a30 "Book", num_fixed_sizes = 0,
available_sizes = 0x0, num_charmaps = 5, charmaps = 0x5555555c6a80, generic = {data = 0x0, finalizer = 0x0},
bbox = {xMin = -2090, yMin = -948, xMax = 3673, yMax = 2524}, units_per_EM = 2048, ascender = 1901,
descender = -483, height = 2384, max_advance_width = 3838, max_advance_height = 2384, underline_position = -175,
underline_thickness = 90, glyph = 0x5555555ef830, size = 0x5555555f80b0, charmap = 0x5555555c6980,
driver = 0x5555555b6100, memory = 0x5555555b5f50, stream = 0x5555555c29b0, sizes_list = {head = 0x5555555c2240,
tail = 0x5555555c2240}, autohint = {data = 0x0, finalizer = 0x0}, extensions = 0x0, internal = 0x5555555de5c0}
(gdb) step
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ed7718 in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
==10991== Invalid read of size 4
==10991== at 0x491B718: ??? (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991== by 0x491B857: ??? (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991== by 0x48DBA6F: FT_Get_Char_Index (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991== by 0x48E1444: FT_Load_Char (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991== by 0x10D0E5: fruit::FreetypeFontfaceLoader::bitmap(FT_FaceRec_*, unsigned int) (freetype_fontface_loader.hpp:43)
Calls before:
FT_Face face{};
if(FT_New_Memory_Face(m_handle, reinterpret_cast<FT_Byte const*>(src_buffer.data()), src_buffer.size(), 0, &face) != FT_Err_Ok)
{
throw FreetypeLoadError{};
}
handle = face;
FT_Set_Pixel_Sizes(handle, 0, 16);
Apparently, I am doing something wrong.
Apparently, I missed a detail of the API:
You must not deallocate the memory before calling FT_Done_Face.
Not releasing the buffer solves the problem.