[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cairo
Subject:    [cairo] cairo_ft_font_face_set_synthesize usage
From:       "Smith, Glenn K" <Glenn.Smith () xerox ! com>
Date:       2015-04-03 20:23:17
Message-ID: 79AD35215D1360439DD28BB57BF6CD0E0C86E6F0 () USA7109MB014 ! na ! xerox ! net
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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."


[Attachment #5 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 \
2px solid; } --></style> </head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>I&#8217;ve been searching the archives for information on \
cairo_ft_font_face_set_synthesize but haven&#8217;t found anything yet.</div> \
<div>&nbsp;</div> <div>I&#8217;m trying to do something very simple.&nbsp; I have a \
TTF font I am using with Cairo that doesn&#8217;t have bold or italics in it.&nbsp; I \
can use the font by creating&nbsp; new fontface using FreeType and \
cairo_ft_font_face_create_for_ft_face.&nbsp; I&#8217;ve set the font data and made \
the fontface my font in Cairo.&nbsp; If generate output using Cairo anything that \
doesn&#8217;t require bold or italics it works just fine.</div> <div>&nbsp;</div>
<div>However, I&#8217;ve tried doing some tests where call \
cairo_ft_font_face_set_synthesize with CAIRO_FT_SYNTHESIZE_OBLIQUE and/or \
CAIRO_FT_SYNTHESIZE_BOLD.&nbsp; There appears to be no change in the font, so \
I&#8217;ve come to the conclusion that I&#8217;m not doing something correctly.</div>
<div>&nbsp;</div>
<div>I&#8217;m doing this on Windows, so that may be an issue all by itself.&nbsp; \
Anyway, here some basic code I&#8217;m using pulled from my code.</div> \
<div>&nbsp;</div> <div>void cairoDestroyFontFace(void *data);</div>
<div>void cairoDestroyFontFace(void *data)</div>
<div>{</div>
<div>&nbsp;&nbsp;&nbsp; FT_Done_Face(static_cast&lt;FT_Face&gt;(data));</div>
<div>}</div>
<div>&nbsp;</div>
<div>.</div>
<div>.</div>
<div>.</div>
<div>&nbsp;</div>
<div>static FT_Library freetypeLibrary = nullptr;&nbsp; // FreeType library \
instance</div> <div>cairo_font_face_t*&nbsp; fontFace = nullptr;</div>
<div>FT_Face ftFontFace = FT_Face();</div>
<div>&nbsp;</div>
<div>FT_Init_FreeType(&amp;freetypeLibrary);</div>
<div>FT_New_Face(freetypeLibrary, &quot;mytruetypefile.ttf&quot;, 0, \
&amp;ftFontFace);</div> <div>&nbsp;</div>
<div>if (ftFontFace != nullptr)</div>
<div>{</div>
<div>&nbsp;&nbsp;&nbsp; fontFace = cairo_ft_font_face_create_for_ft_face(ftFontFace, \
0);</div> <div>}</div>
<div>&nbsp;</div>
<div>// set the font in cairo</div>
<div>if (fontFace != nullptr &amp;&amp; cairo_status(cairoContext) == \
CAIRO_STATUS_SUCCESS)</div> <div>{</div>
<div>&nbsp;&nbsp;&nbsp; cairo_font_face_set_user_data(fontFace, \
&amp;staticKeyForCairoUserData, ftFontFace, cairoDestroyFontFace);</div> \
<div>&nbsp;&nbsp;&nbsp; cairo_set_font_face(cairoContext, fontFace);</div> \
<div>&nbsp;&nbsp;&nbsp; cairo_ft_font_face_set_synthesize(fontFace, \
CAIRO_FT_SYNTHESIZE_OBLIQUE);</div> <div>}</div>
<div>&nbsp;</div>
<div>// set the font size in cairo</div>
<div>cairo_set_font_size(cairoContext, 24);</div>
<div>&nbsp;</div>
<div>// draw some text</div>
<div>cairo_move_to(cairoContext, 20, 20); </div>
<div>cairo_show_text(cairoContext, &quot;Simulated italic font...&quot;);</div>
<div>&nbsp;</div>
<div>FT_Done_FreeType(freetypeLibrary);</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</div> <div>What I want is this:</div>
<div>&nbsp;</div>
<div><img src="cid:3B3E46705FD6D94C917086C645BB9235@xerox.com"> </div>
<div>&nbsp;</div>
<div>What I get is this:</div>
<div>&nbsp;</div>
<div><img src="cid:6232A654BD69FF459E30A0CAC4E24EB5@xerox.com"> </div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div align="center" style="text-align:center;"><font color="#943634"><img width="83" \
height="41" src="rtfimage://"></font></div> <div>&nbsp;</div>
<div><font face="Xerox Sans" size="2"><span style="font-size:10pt;"><b>Glenn K. \
Smith</b> <br>

<b>Software Developer</b></span></font></div>
<div><font face="Arial" size="1"><span style="font-size:8pt;">GDG - SSTO - Client \
Platform Development Team</span></font></div> <div><br>

<font face="Xerox Sans" size="2"><span style="font-size:10pt;">Xerox Corporation <br>

800 Phillips Road, Mail Stop: 111-02A <br>

Webster, NY 14580<br>

Phone: 585-427-1450 (8*707-1450)</span></font></div>
<div style="margin-top:5pt;margin-bottom:5pt;"><font face="Xerox Sans" size="1" \
color="silver"><span style="font-size:7.5pt;">&quot;This e-mail message, including \
any attachments, is for the sole use of the intended recipient(s) and may contain \
confidential information.<font face="Calibri">&nbsp;</font> Any unauthorized review, \
use, disclosure or distribution is prohibited.<font face="Calibri">&nbsp;</font> 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.&quot;</span></font></div> <div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
</span></font>
</body>
</html>


["Picture (Device Independent Bitmap) 1.jpg" (image/jpeg)]
["Picture (Device Independent Bitmap) 2.jpg" (image/jpeg)]
[Attachment #8 (unknown)]

-- 
cairo mailing list
cairo@cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic