Bug 75219

Summary: [C++] Embolden doesn't work in a text
Product: cairo Reporter: guillaume.mercat
Component: freetype font backendAssignee: David Turner <david>
Status: RESOLVED MOVED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: 1.12.14   
Hardware: x86 (IA32)   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description guillaume.mercat 2014-02-19 17:52:47 UTC
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);
}
Comment 1 guillaume.mercat 2014-02-20 07:59:16 UTC
I forgot, i write two text in a loop with the same font (FT_Face). I write the first word in regular font and i want to 'embolden' the second with 'cairo_ft_font_face_set_synthesize'.

The issue is with the second word, it isn't embolden.
Comment 2 GitLab Migration User 2018-08-25 13:28:29 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/22.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.