[cairo] Drawing text
cu
cairouser at yahoo.com
Tue Sep 8 07:18:17 PDT 2009
Dominic Lachowicz wrote:
> On Tue, Sep 8, 2009 at 6:22 AM, ecir hana<ecir.hana at gmail.com> wrote:
>
>> On Mon, Sep 7, 2009 at 5:45 PM, Dominic Lachowicz<domlachowicz at gmail.com> wrote:
>>
>>> You should be able to use Cairo with FreeType loading fonts from
>>> files. See the documentation for
>>> cairo_ft_font_face_create_for_ft_face().
>>>
>> Ok, now that I look at this I'm not sure I understood. That function
>> accepts "pre-opened FreeType face" - what does it mean? I thought I
>> could somehow pass a path to a file font, do I need to first somehow
>> open the font via FreeType and then it can be used in Cairo? Perhaps
>> are there some examples somewhere?
>>
>
> You need to first open the font via freetype. Check the following URL
> for examples.
>
> http://www.freetype.org/freetype2/docs/tutorial/step1.html
>
>
Kinda like this:
------------------------------------------
FT_Init_FreeType(&ft_library);
fopt = cairo_font_options_create();
cairo_matrix_init_identity(&cmt);
FT_New_Face(ft_library, PATH_TO_FONT, INDEX_OF_FONT_IN_FILE, &ft_face);
utf = cairo_ft_font_face_create_for_ft_face(ft_face, 0);
cairo_matrix_init_scale(&mt, DESIRED_SIZE, DESIRED_SIZE);
tf = cairo_scaled_font_create(utf, &mt, &cmt, fopt);
cairo_font_face_destroy(utf);
------------------------------------------
utf is an unscaled font. tf is your scaled font (i.e. font + size) for
use in any Cairo surface (it's size can still be changed later)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20090908/f6847046/attachment.html
More information about the cairo
mailing list