[cairo] cairo_ft_font_face_set_synthesize usage

Smith, Glenn K Glenn.Smith at xerox.com
Fri Apr 3 13:23:17 PDT 2015


I've been searching the archives for information on cairo_ft_font_face_set_synthesize but haven't found anything yet.

I'm trying to do something very simple.  I have a TTF font I am using with Cairo that doesn't have bold or italics in it.  I can use the font by creating  new fontface using FreeType and cairo_ft_font_face_create_for_ft_face.  I've set the font data and made the fontface my font in Cairo.  If generate output using Cairo anything that doesn't require bold or italics it works just fine.

However, I've tried doing some tests where call cairo_ft_font_face_set_synthesize with CAIRO_FT_SYNTHESIZE_OBLIQUE and/or CAIRO_FT_SYNTHESIZE_BOLD.  There appears to be no change in the font, so I've come to the conclusion that I'm not doing something correctly.

I'm doing this on Windows, so that may be an issue all by itself.  Anyway, here some basic code I'm using pulled from my code.

void cairoDestroyFontFace(void *data);
void cairoDestroyFontFace(void *data)
{
    FT_Done_Face(static_cast<FT_Face>(data));
}

.
.
.

static FT_Library freetypeLibrary = nullptr;  // FreeType library instance
cairo_font_face_t*  fontFace = nullptr;
FT_Face ftFontFace = FT_Face();

FT_Init_FreeType(&freetypeLibrary);
FT_New_Face(freetypeLibrary, "mytruetypefile.ttf", 0, &ftFontFace);

if (ftFontFace != nullptr)
{
    fontFace = cairo_ft_font_face_create_for_ft_face(ftFontFace, 0);
}

// set the font in cairo
if (fontFace != nullptr && cairo_status(cairoContext) == CAIRO_STATUS_SUCCESS)
{
    cairo_font_face_set_user_data(fontFace, &staticKeyForCairoUserData, ftFontFace, cairoDestroyFontFace);
    cairo_set_font_face(cairoContext, fontFace);
    cairo_ft_font_face_set_synthesize(fontFace, CAIRO_FT_SYNTHESIZE_OBLIQUE);
}

// set the font size in cairo
cairo_set_font_size(cairoContext, 24);

// draw some text
cairo_move_to(cairoContext, 20, 20);
cairo_show_text(cairoContext, "Simulated italic font...");

FT_Done_FreeType(freetypeLibrary);

What I want is this:



What I get is this:




[X]

Glenn K. Smith
Software Developer
GDG - SSTO - Client Platform Development Team

Xerox Corporation
800 Phillips Road, Mail Stop: 111-02A
Webster, NY 14580
Phone: 585-427-1450 (8*707-1450)

"This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient(s) please contact the sender by reply e-mail and destroy all copies of the original message. Finally, the recipient should check that this email is authentic and examine it for the presence of viruses. Xerox does perform virus checks but cannot accept liability for any damage caused by any virus transmitted by this email. Thank you."



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20150403/a028a00c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture (Device Independent Bitmap) 1.jpg
Type: image/jpeg
Size: 631 bytes
Desc: Picture (Device Independent Bitmap) 1.jpg
URL: <http://lists.cairographics.org/archives/cairo/attachments/20150403/a028a00c/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture (Device Independent Bitmap) 2.jpg
Type: image/jpeg
Size: 631 bytes
Desc: Picture (Device Independent Bitmap) 2.jpg
URL: <http://lists.cairographics.org/archives/cairo/attachments/20150403/a028a00c/attachment-0001.jpg>


More information about the cairo mailing list