@ -191,8 +191,13 @@ Context2d::~Context2d() {
void
void
Context2d : : save ( ) {
Context2d : : save ( ) {
cairo_save ( _context ) ;
if ( stateno < CANVAS_MAX_STATES ) {
saveState ( ) ;
cairo_save ( _context ) ;
states [ + + stateno ] = ( canvas_state_t * ) malloc ( sizeof ( canvas_state_t ) ) ;
memcpy ( states [ stateno ] , state , sizeof ( canvas_state_t ) ) ;
states [ stateno ] - > fontDescription = pango_font_description_copy ( states [ stateno - 1 ] - > fontDescription ) ;
state = states [ stateno ] ;
}
}
}
/*
/*
@ -201,35 +206,14 @@ Context2d::save() {
void
void
Context2d : : restore ( ) {
Context2d : : restore ( ) {
cairo_restore ( _context ) ;
if ( stateno > 0 ) {
restoreState ( ) ;
cairo_restore ( _context ) ;
}
pango_font_description_free ( states [ stateno ] - > fontDescription ) ;
free ( states [ stateno ] ) ;
/*
states [ stateno ] = NULL ;
* Save the current state .
state = states [ - - stateno ] ;
*/
pango_layout_set_font_description ( _layout , state - > fontDescription ) ;
}
void
Context2d : : saveState ( ) {
if ( stateno = = CANVAS_MAX_STATES ) return ;
states [ + + stateno ] = ( canvas_state_t * ) malloc ( sizeof ( canvas_state_t ) ) ;
memcpy ( states [ stateno ] , state , sizeof ( canvas_state_t ) ) ;
states [ stateno ] - > fontDescription = pango_font_description_copy ( states [ stateno - 1 ] - > fontDescription ) ;
state = states [ stateno ] ;
}
/*
* Restore state .
*/
void
Context2d : : restoreState ( ) {
if ( 0 = = stateno ) return ;
pango_font_description_free ( states [ stateno ] - > fontDescription ) ;
free ( states [ stateno ] ) ;
states [ stateno ] = NULL ;
state = states [ - - stateno ] ;
pango_layout_set_font_description ( _layout , state - > fontDescription ) ;
}
}
/*
/*