开罗字体渲染中消失的字符
我使用 cairo 将简单的文本渲染到 cairo 表面上。我使用 freetype 字体(Vera.ttf,如果重要的话)。它有效,但有时字符会从输出中消失。事实上只是数字。我画了一个文本“Demostream 1..”,有时“1”从输出中消失,我完全不知道为什么。该数字绝对是字符串的一部分。也不存在记忆损坏或类似的情况。这是绘制文本的代码:
font = cairo_ft_font_face_create_for_ft_face(ftFace, 0);
cr = cairo_create(surface);
/* set the foreground color */
cairo_set_source_rgba(cr, ...);
/* render the text */
cairo_set_antialias(cr, CAIRO_ANTIALIAS_GRAY);
cairo_set_font_face(cr, font);
cairo_set_font_size(cr, size);
cairo_move_to(cr, x, y);
cairo_show_text(cr, text);
cairo_destroy(cr);
cairo_font_face_destroy(font);
ftFace 是加载的 freetype 字体。
我也会使用 pango 来渲染文本,但我没有可用的字体缓存 - 所以我不知道如何将字体加载到 pango 中,因为它显然只支持字体缓存,不支持直接字体加载。
欢迎任何输入..
I use cairo to render a simple text onto a cairo surface. I use a freetype font for that (Vera.ttf if that matters). It works, but sometimes characters disappear from the output. In fact only the numbers. I drew a text 'Demostream 1..' and sometimes the '1' disappears from the output and I have absolutely no idea why. The number is defitivly part of the string. There's also no memory corrpution or anything like that. This is the code that draws the text:
font = cairo_ft_font_face_create_for_ft_face(ftFace, 0);
cr = cairo_create(surface);
/* set the foreground color */
cairo_set_source_rgba(cr, ...);
/* render the text */
cairo_set_antialias(cr, CAIRO_ANTIALIAS_GRAY);
cairo_set_font_face(cr, font);
cairo_set_font_size(cr, size);
cairo_move_to(cr, x, y);
cairo_show_text(cr, text);
cairo_destroy(cr);
cairo_font_face_destroy(font);
ftFace is a loaded freetype font face.
I also would use pango to render the text, but I don't have fontcache available - so I have no idea howto load the Font into pango since it obviously only supports fontcache and no direct font loading.
Any input is welcome..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我删除了开罗支持 - 问题不再相关。
i removed cairo support - the problem is not longer relevant.