[cairo] Newbie questions on fonts

Fred Clare fred at ucar.edu
Fri Oct 12 14:03:58 PDT 2007

I have just started using cairo.  I have followed the thread
in the cairo archives of late December 2006 on "Problems
compiling Cairo..doesn't detect fontconfig/freetype
installation" and, in particular, I installed into a
private directory (say /home/myhome/cairo) on a Mac OS X machine:


I have put /home/myhome/cairo/lib on my DYLD_LIBRARY_PATH and
/home/myhome/cairo/lib/pkgconfig on my PKG_CONFIG_PATH as well as
putting /home/myhome/cairo/bin on my PATH.

Some questions:

   1.)  Just what are the "toy" fonts?  What font database is
        being used for those?  When I execute:

          cairo_select_font_face (cr, "serif",
          cairo_show_text (cr, "Text");

        I do not get an Italic font, but just the normal font.

   2.)  Installing fontconfig creates an /etc/fonts directory (I wish
        the documentation of fontconfig was specific about that) and
        lists some font directories in the fonts.conf file in
        that directory.  There are some fonts in /Library/fonts
        that I would like to access and the directory
        /Library/fonts is not listed in fonts.conf.  The directive
        in fonts.conf says not to edit that file but put local
        changes in a 'local.conf' file which I did by inserting:


        in an xml file created using the fonts.conf file as a template.
        I was hoping that this would then give me access to the
        fonts in /Library/Fonts using the font name in a
        cairo_select_font_face call with the font name as the second
        argument.  But a subsequent call to cairo_show_text
        just gives me the default serif font.

        Should the above work?  Is my assumption correct that cairo
        is looking at the files in /etc/fonts to find its fonts?
        Since the above did not work, I put the line


        in fonts.conf, but that did not work either.

   3.)  Since the above did not work, I tried accessing the fonts
        directly using the calls:

            error = FT_Init_FreeType( &library );
            error = FT_New_Face( library,
                      "/Library/Fonts/ArialHBBold.ttf", 0, &face );
            font_face = cairo_ft_font_face_create_for_ft_face(face,0);
            cairo_set_font_face(cr, font_face);

        I did not get any error returns, but a show_text call just
        produces rectangles.

Any help will be appreciated.

Fred Clare

More information about the cairo mailing list