[cairo] Cairo and freetype

Techie Help techieinfo at yahoo.co.uk
Thu Nov 8 02:51:23 PST 2012


Hi Jutsin,
 
I did it the way you suggested:
Here's what I did:
 
 
cairo_device_t *  cairo_device=cairo_gcm_device_create(1024*1024*10, 1024*1024*15, 1024*1024*20);
        cairo_surface_t * surface = cairo_gcm_surface_create_for_texture(cairo_device, 1500, 1500);
     
   /* Init freetype */
  int error;
  FT_Library ft_library;
  error = FT_Init_FreeType(&ft_library);
  if (error)
  {
   printf("ERROR CODE: %d, filename: %s, line no. : %d\n", error, __FILE__, __LINE__);
  }
  //Load our fonts 
  FT_Face ft_face = NULL;
        error = FT_New_Face(ft_library, "/app_home/FreeMonoBold.ttf", 0, &ft_face);
  if (error)
  {
   printf("ERROR CODE: %d, filename: %s, line no. : %d\n", error, __FILE__, __LINE__);
  }
   
  cairo_font_face_t *myfont_face;
  myfont_face =  cairo_ft_font_face_create_for_ft_face(ft_face,0);
  
  cairo_matrix_t mxSize;
  cairo_matrix_t mxIdent;
  cairo_matrix_init_scale(&mxSize, 16, 16); // sizing..
  cairo_matrix_init_identity(&mxIdent);
  cairo_scaled_font_t* cairoFont = cairo_scaled_font_create(myfont_face, &mxSize, &mxIdent, 0);
  cairo_t *cr = cairo_create (surface);
  
  cairo_set_scaled_font(cr, cairoFont);
  cairo_set_font_size(cr, 16);
  cairo_new_path(cr);
  cairo_move_to(cr, 200, 200);
  
  cairo_text_path(cr, "Print Something");
  cairo_set_source_rgb(cr, 1, 0, 0);
  cairo_fill(cr);
  cairo_set_source_surface(cr, surface, 0, 0);
  cairo_paint(cr); 
sys_timer_usleep(20 *1000000);
 
I added sleep in the end, so that if there is any text I can see it before application exits.
But I still don't see anything.
 
Sorry, I am totally new to all this. You mentioned that it will be better if I use 
freetype library and glyph/font rendering already available in the SDK(yes, my platform is PS3)
but I am not sure how to find what is available in SDK and how to use it?
 
Please if you can provide any more guidance it would be of great help.
Thanks
 

________________________________
 From: Techie Help <techieinfo at yahoo.co.uk>
To: "cairo at cairographics.org" <cairo at cairographics.org> 
Sent: Wednesday, 7 November 2012, 21:28
Subject: Cairo and freetype
  

Hi,

I am new to Graphics, so new to cairo as well.
I am trying to render some text using Cairo and freetype.
The backend that I am using is gcm, and it does not support any glyphs etc.
Can anyone please provide me with an example how to do this.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20121108/6baddd0e/attachment.html>


More information about the cairo mailing list