Skip to content

Poor perfomance when drawing text #17

@dlech

Description

@dlech

Glyphs are not cached but rather loaded from disk each time a character is rendered, leading to poor performance.

grx/src/text/drawtext.c

Lines 91 to 117 in 09177aa

for (; (c = g_utf8_get_char(text)) != '\0'; text = g_utf8_next_char(text)) {
index = FT_Get_Char_Index(options->font->face, c);
ret = FT_Load_Glyph(options->font->face, index, FT_LOAD_DEFAULT);
if (ret) {
continue;
}
// ret = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
// if (ret) {
// continue;
// }
if (slot->format != FT_GLYPH_FORMAT_BITMAP) {
continue;
}
if (slot->bitmap.pixel_mode != FT_PIXEL_MODE_MONO) {
continue;
}
mem.plane0 = slot->bitmap.buffer;
grx_context_new_full(GRX_FRAME_MODE_RAM_1BPP, slot->bitmap.pitch * 8,
slot->bitmap.rows, &mem, &ctx);
grx_bit_blt_1bpp(x + slot->bitmap_left - x_offset,
y - slot->bitmap_top + y_offset, &ctx, 0, 0,
slot->bitmap.width, slot->bitmap.rows,
options->fg_color, options->bg_color);
x += slot->advance.x >> 6;
y += slot->advance.y >> 6;
}
}

https://freetype.org/freetype2/docs/reference/ft2-cache_subsystem.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions