Exemplo n.º 1
0
gl_tex_font_p glf_create_font(const char *file_name, uint16_t font_size)
{
    if(g_ft_library)
    {
        gl_tex_font_p glf = (gl_tex_font_p)malloc(sizeof(gl_tex_font_t));
        glf->ft_face = NULL;

        if(FT_New_Face(g_ft_library, file_name, 0, (FT_Face*)&glf->ft_face))
        {
            free(glf);
            return NULL;
        }

        glf->glyphs_count = ((FT_Face)glf->ft_face)->num_glyphs;
        glf->glyphs = (char_info_p)malloc(glf->glyphs_count * sizeof(char_info_t));

        qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &glf->gl_max_tex_width);
        glf->gl_tex_width = glf->gl_max_tex_width;
        glf->gl_tex_indexes = NULL;
        glf->gl_tex_indexes_count = 0;
        glf->gl_real_tex_indexes_count = 0;
        glf->gl_font_color[0] = 0.0;
        glf->gl_font_color[1] = 0.0;
        glf->gl_font_color[2] = 0.0;
        glf->gl_font_color[3] = 1.0;

        glf_resize(glf, font_size);
        FT_Select_Charmap(glf->ft_face, FT_ENCODING_UNICODE);

        return glf;
    }

    return NULL;
}
Exemplo n.º 2
0
/**
 * Creates gl texture font from true type font;
 * @param ft_library: base font library;
 * @param face_data: pointer to the buffer with font file content; DO NOT FREE that pointer otherway using FT_Face prevets to crash;
 * @param face_data_size: size of buffer with font file content;
 * @param font_size: size of font glyph?
 * @return pointer to the gl_tex_font_s structure;
 */
gl_tex_font_p glf_create_font_mem(void *face_data, size_t face_data_size, uint16_t font_size)
{
    if(g_ft_library)
    {
        gl_tex_font_p glf = (gl_tex_font_p)malloc(sizeof(gl_tex_font_t));
        glf->ft_face = NULL;

        if(FT_New_Memory_Face(g_ft_library, (const FT_Byte*)face_data, face_data_size, 0, (FT_Face*)&glf->ft_face))
        {
            free(glf);
            return NULL;
        }

        glf->glyphs_count = ((FT_Face)glf->ft_face)->num_glyphs;
        glf->glyphs = (char_info_p)malloc(glf->glyphs_count * sizeof(char_info_t));

        qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &glf->gl_max_tex_width);
        glf->gl_tex_width = glf->gl_max_tex_width;
        glf->gl_tex_indexes = NULL;
        glf->gl_tex_indexes_count = 0;
        glf->gl_real_tex_indexes_count = 0;
        glf_resize(glf, font_size);
        FT_Select_Charmap(glf->ft_face, FT_ENCODING_UNICODE);

        return glf;
    }

    return NULL;
}
Exemplo n.º 3
0
/**
 * Creates gl texture font from true type font;
 * @param ft_library: base font library;
 * @param face_data: pointer to the buffer with font file content; DO NOT FREE that pointer otherway using FT_Face prevets to crash;
 * @param face_data_size: size of buffer with font file content;
 * @param font_size: size of font glyph?
 * @return pointer to the gl_tex_font_s structure;
 */
gl_tex_font_p glf_create_font_mem(FT_Library ft_library, void *face_data, size_t face_data_size, uint16_t font_size)
{
    if(ft_library != nullptr)
    {
        gl_tex_font_p glf = static_cast<gl_tex_font_p>(malloc(sizeof(gl_tex_font_t)));
        glf->ft_face = nullptr;

        if(FT_New_Memory_Face(ft_library, static_cast<const FT_Byte*>(face_data), face_data_size, 0, &glf->ft_face))
        {
            free(glf);
            return nullptr;
        }

        glf->glyphs_count = glf->ft_face->num_glyphs;
        glf->glyphs = static_cast<char_info_p>(malloc(glf->glyphs_count * sizeof(char_info_t)));

        glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glf->gl_max_tex_width);
        glf->gl_tex_width = glf->gl_max_tex_width;
        glf->gl_tex_indexes = nullptr;
        glf->gl_tex_indexes_count = 0;
        glf->gl_real_tex_indexes_count = 0;
        glf_resize(glf, font_size);
        FT_Select_Charmap(glf->ft_face, FT_ENCODING_UNICODE);

        return glf;
    }

    return nullptr;
}
Exemplo n.º 4
0
gl_tex_font_p glf_create_font(FT_Library ft_library, const char *file_name, uint16_t font_size)
{
    if(ft_library != nullptr)
    {
        gl_tex_font_p glf = static_cast<gl_tex_font_p>(malloc(sizeof(gl_tex_font_t)));
        glf->ft_face = nullptr;

        if(FT_New_Face(ft_library, file_name, 0, &glf->ft_face))                //T4Larson <*****@*****.**>: fixed font construction and destruction!
        {
            free(glf);
            return nullptr;
        }

        glf->glyphs_count = glf->ft_face->num_glyphs;
        glf->glyphs = static_cast<char_info_p>(malloc(glf->glyphs_count * sizeof(char_info_t)));

        glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glf->gl_max_tex_width);
        glf->gl_tex_width = glf->gl_max_tex_width;
        glf->gl_tex_indexes = nullptr;
        glf->gl_tex_indexes_count = 0;
        glf->gl_real_tex_indexes_count = 0;
        glf->gl_font_color[0] = 0.0;
        glf->gl_font_color[1] = 0.0;
        glf->gl_font_color[2] = 0.0;
        glf->gl_font_color[3] = 1.0;

        glf_resize(glf, font_size);
        FT_Select_Charmap(glf->ft_face, FT_ENCODING_UNICODE);

        return glf;
    }

    return nullptr;
}
Exemplo n.º 5
0
void glf_reface(gl_tex_font_p glf, const char *file_name, uint16_t font_size)
{
    if(FT_New_Face(glf->ft_library, file_name, 0, &glf->ft_face))
    {
        return;
    }
    glf_resize(glf, font_size);
}