Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor perfomance when drawing text #17

Open
dlech opened this issue Jul 13, 2020 · 0 comments
Open

Poor perfomance when drawing text #17

dlech opened this issue Jul 13, 2020 · 0 comments

Comments

@dlech
Copy link
Member

dlech commented Jul 13, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant