

def __init__(self, data):
    self.buffer = (ctypes.c_byte * len(data))()
    ctypes.memmove(self.buffer, data, len(data))
    ft_library = ft_get_library()
    self.face = FT_Face()
    r = FT_New_Memory_Face(ft_library, self.buffer, len(self.buffer), 0, self.face)
    if (r != 0):
        raise base.FontException('Could not load font data')
    self.name = self.face.contents.family_name
    self.bold = ((self.face.contents.style_flags & FT_STYLE_FLAG_BOLD) != 0)
    self.italic = ((self.face.contents.style_flags & FT_STYLE_FLAG_ITALIC) != 0)
    if (self.face.contents.face_flags & FT_FACE_FLAG_SFNT):
        name = FT_SfntName()
        for i in range(FT_Get_Sfnt_Name_Count(self.face)):
            result = FT_Get_Sfnt_Name(self.face, i, name)
            if (result != 0):
                continue
            if (not ((name.platform_id == TT_PLATFORM_MICROSOFT) and (name.encoding_id == TT_MS_ID_UNICODE_CS))):
                continue
            if (name.name_id == TT_NAME_ID_FONT_FAMILY):
                string = string_at(name.string, name.string_len)
                self.name = string.decode('utf-16be', 'ignore')

dataset/ETHPy150Open ardekantur/pyglet/pyglet/font/freetype.py FreeTypeMemoryFont.__init__/original