[C++] Embolden doesn't work in a text
Submitted by gui..@..ez.com
Assigned to David Turner
Description
I use Cairo with freetype to write texts in my software. I have a font without "bold" and i want to use "Synthesize Bold". But my word isn't Embolden.
When i debug in cairo, i see, in 'cairo_scaled_font_create' (in file cairo_scaled-font.c), the scaled_font is found in font_map (scaled_font = font_map->mru_scaled_font) and _cairo_scaled_font_matches return true. So when i draw text, cairo find scaled_glyph in the 'hash_table->cache' (in function '_cairo_scaled_glyph_lookup') but this scaled_glyph isn't init with flag "Synthesize Bold" and so it isn't embolden.
I think the issue is around the 'mru_scaled_font' usage where it matches with font_face in cairo_scaled_font_create.
I do : [...] FT_Face FTFace = GetFreetypeFace (); cairo_t* pContext = NULL; cairo_font_face_t* pCairoFontFace = NULL; cairo_user_data_key_t Key; cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); if(pSurface) { pContext = cairo_create(pSurface); pCairoFontFace = cairo_ft_font_face_create_for_ft_face (FTFace,0); cairo_font_face_set_user_data (pCairoFontFace, &Key, FTFace, NULL); cairo_ft_font_face_set_synthesize(pCairoFontFace, CAIRO_FT_SYNTHESIZE_BOLD); cairo_set_font_face(pContext, pCairoFontFace); cairo_text_path (pContext, TextBuffer.GetData()); cairo_fill(pContext); if(cairo_status(apContext) == CAIRO_STATUS_SUCCESS) { cairo_font_face_set_user_data (pCairoFontFace, &Key, NULL, NULL); cairo_font_face_destroy(pCairoFontFace); } if(NULL != pContext) { cairo_destroy(pContext); } cairo_surface_destroy(pSurface); }
Version: 1.12.14