- if (buf != NULL) {
- render_glyph(face->glyph, xpos, ypos, buf, r, g, b, use_lcd);
- }
+ hb_buffer_set_direction(hbuf, dir);
+ hb_buffer_set_script(hbuf, hb_glib_script_to_script((GUnicodeScript)analysis->script));
+ hb_buffer_set_language(hbuf, hb_language_from_string(pango_language_to_string(analysis->language), -1));
+ hb_buffer_add_utf8(hbuf, utf8str.data(), utf8str.size(), item->offset, item->length);
+
+ // Font-specifics.
+ FT_Face face = *face_it;
+ hb_font_t *font = hb_ft_font_create(face, NULL);
+ hb_shape(font, hbuf, NULL, 0);
+ unsigned glyph_count;
+ hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(hbuf, &glyph_count);
+ hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(hbuf, &glyph_count);
+
+ bool found_all = true;
+ for (unsigned i = 0; i < glyph_count; ++i) {
+ if (glyph_info[i].codepoint == 0) {
+ found_all = false;
+ }
+ break;
+ }
+
+ if (!found_all) {
+ std::string utf8itemstr(&utf8str[item->offset], &utf8str[item->offset + item->length]);
+ if (face_it + 1 == fonts.end()) {
+ std::fprintf(stderr, "Warning: Could not find any font to render item '%s', rendering in last font anyway\n", utf8itemstr.c_str());
+ } else {
+ hb_font_destroy(font);
+ hb_buffer_destroy(hbuf);
+ continue;
+ }
+ }