[cairo-commit] cairo-demo/cairo_snippets text_align_center.cairo, NONE, 1.1 text_extents.cairo, NONE, 1.1 ChangeLog, 1.14, 1.15 text_centering.cairo, 1.2, NONE

OEyvind Kolaas commit at pdx.freedesktop.org
Wed May 26 14:04:20 PDT 2004


Committed by: pippin

Update of /cvs/cairo/cairo-demo/cairo_snippets
In directory pdx:/tmp/cvs-serv21810

Modified Files:
	ChangeLog 
Added Files:
	text_align_center.cairo text_extents.cairo 
Removed Files:
	text_centering.cairo 
Log Message:
changed the text snippets, better naming, and added right align example


--- NEW FILE: text_align_center.cairo ---
cairo_text_extents_t extents;

const char *utf8 = "cairo";
double x,y;

cairo_select_font (cr, "Sans",
    CAIRO_FONT_SLANT_NORMAL,
    CAIRO_FONT_WEIGHT_NORMAL);

cairo_scale_font (cr, 0.2);
cairo_text_extents (cr, utf8, &extents);
x = 0.5-(extents.width/2 + extents.x_bearing);
y = 0.5-(extents.height/2 + extents.y_bearing);

cairo_move_to (cr, x, y);
cairo_show_text (cr, utf8);

/* draw helping lines */
cairo_set_rgb_color (cr, 1,0.2,0.2);
cairo_set_alpha (cr, 0.6);
cairo_arc (cr, x, y, 0.05, 0, 2*M_PI);
cairo_fill (cr);
cairo_move_to (cr, 0.5, 0);
cairo_rel_line_to (cr, 0, 1);
cairo_move_to (cr, 0, 0.5);
cairo_rel_line_to (cr, 1, 0);
cairo_stroke (cr);


--- NEW FILE: text_extents.cairo ---
cairo_text_extents_t extents;

const char *utf8 = "cairo";
double x,y;

cairo_select_font (cr, "Sans",
    CAIRO_FONT_SLANT_NORMAL,
    CAIRO_FONT_WEIGHT_NORMAL);

cairo_scale_font (cr, 0.4);
cairo_text_extents (cr, utf8, &extents);

x=0.1;
y=0.6;

cairo_move_to (cr, x,y);
cairo_show_text (cr, utf8);

/* draw helping lines */
cairo_set_rgb_color (cr, 1,0.2,0.2);
cairo_set_alpha (cr, 0.6);
cairo_arc (cr, x, y, 0.05, 0, 2*M_PI);
cairo_fill (cr);
cairo_move_to (cr, x,y);
cairo_rel_line_to (cr, 0, -extents.height);
cairo_rel_line_to (cr, extents.width, 0);
cairo_rel_line_to (cr, extents.x_bearing, -extents.y_bearing);
cairo_stroke (cr);


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/ChangeLog,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** a/ChangeLog	21 May 2004 22:37:56 -0000	1.14
--- b/ChangeLog	26 May 2004 21:04:18 -0000	1.15
***************
*** 1,2 ****
--- 1,9 ----
+ 2004-05-26  OEyvind Kolaas <pippin at freedesktop.org>
+ 
+ 	* text_centering.cairo: removed
+ 	* text_align_center.cairo: added
+ 	* text_align_right.cairo: added
+ 	* text_extents: added
+ 	
  2004-05-20  OEyvind Kolaas <pippin at freedesktop.org>
  

--- text_centering.cairo DELETED ---





More information about the cairo-commit mailing list