78 #ifdef PL_HAVE_FREETYPE
86 #endif // PL_HAVE_FREETYPE
94 #ifdef PL_HAVE_FREETYPE
105 {
"text",
DRV_INT, &
text,
"Use truetype fonts (text=0|1)" },
106 {
"hrshsym",
DRV_INT, &
hrshsym,
"Use Hershey symbol set (hrshsym=0|1)" },
107 {
"replot",
DRV_INT, &
replot,
"Allow replotting to other devices (replot=0|1)" },
119 ( (
int) ( color.
r ) << 24 )
120 + ( (int) ( color.
g ) << 16 )
121 + ( (
int) ( color.
b ) << 8 )
145 gcw_debug(
"<plD_dispatch_init_gcw>\n" );
148 #ifndef ENABLE_DYNDRIVERS
164 gcw_debug(
"</plD_dispatch_init_gcw>\n" );
182 PLINT width, height, tmp;
202 if ( ( dev = g_malloc(
sizeof (
GcwPLdev ) ) ) == NULL )
203 plexit(
"GCW driver <plD_init_gcw>: Cannot create device" );
207 #ifdef PL_HAVE_FREETYPE
216 plD_FreeType_init( pls );
234 dev->
bgcolor.red = (guint16) ( bgcolor.
r / 255. * 65535 );
235 dev->
bgcolor.green = (guint16) ( bgcolor.
b / 255. * 65535 );
236 dev->
bgcolor.blue = (guint16) ( bgcolor.
g / 255. * 65535 );
334 GnomeCanvasPoints * points;
335 GnomeCanvasPoints pts;
336 GnomeCanvasGroup * group;
337 GnomeCanvasItem * item;
338 GnomeCanvas * canvas;
340 GdkPoint * gdkpoints;
351 if ( !GNOME_IS_CANVAS( dev->
canvas ) )
352 plexit(
"GCW driver <plD_polyline_gcw>: Canvas not found" );
363 if ( ( gdkpoints = (GdkPoint *) malloc( npts *
sizeof ( GdkPoint ) ) ) == NULL )
365 plabort(
"GCW driver <plD_polyline_gcw>: Could not create gdkpoints" );
371 for ( i = 0; i < npts; i++ )
373 gdkpoints[i].x = (gint) ( x[i] /
VSCALE );
374 gdkpoints[i].y = (gint) ( dev->
height - y[i] /
VSCALE );
379 for ( i = 0; i < npts; i++ )
381 gdkpoints[i].x = (gint) ( dev->
height - y[i] /
VSCALE );
382 gdkpoints[i].y = (gint) ( dev->
width - x[i] /
VSCALE );
386 gdk_draw_lines( dev->
background, dev->
gc, gdkpoints, npts );
396 if ( ( points = gnome_canvas_points_new( npts ) ) == NULL )
398 plabort(
"GCW driver <plD_polyline_gcw>: Cannot create points" );
403 for ( i = 0; i < npts; i++ )
405 points->coords[2 * i] = (gdouble) ( x[i] /
VSCALE );
406 points->coords[2 * i + 1] = (gdouble) ( -y[i] /
VSCALE );
411 for ( i = 0; i < npts; i++ )
413 points->coords[2 * i] = (gdouble) ( dev->
height - y[i] /
VSCALE );
414 points->coords[2 * i + 1] = (gdouble) ( -x[i] /
VSCALE );
440 pts.coords = points->coords;
442 for ( i = 0; i < npts - 1; i++ )
444 pts.coords = &( points->coords[2 * i] );
446 if ( !GNOME_IS_CANVAS_ITEM(
447 item = gnome_canvas_item_new( group,
448 GNOME_TYPE_CANVAS_LINE,
449 "cap_style", GDK_CAP_ROUND,
450 "join-style", GDK_JOIN_ROUND,
452 "fill-color-rgba", color,
453 "width-units", width,
457 plwarn(
"GCW driver <plD_polyline_gcw>: Canvas item not created." );
462 gnome_canvas_points_free( points );
500 GnomeCanvas * canvas;
503 GnomeCanvasItem * item;
504 GnomeCanvasGroup* group;
514 if ( !GNOME_IS_CANVAS( dev->
canvas ) )
515 plexit(
"GCW driver <plD_eop_gcw>: Canvas not found" );
534 width = *(
PLINT *) g_object_get_data( G_OBJECT( canvas ),
"canvas-width" );
535 height = *(
PLINT *) g_object_get_data( G_OBJECT( canvas ),
"canvas-height" );
540 if ( !GDK_IS_PIXBUF( pixbuf = gdk_pixbuf_get_from_drawable( NULL,
547 plwarn(
"GCW driver <plD_eop_gcw>: Can't draw pixmap into pixbuf." );
552 if ( !GNOME_IS_CANVAS_ITEM(
554 GNOME_TYPE_CANVAS_PIXBUF,
557 "y", (gdouble) ( -height + 1. ),
558 "width", (gdouble) ( width ),
559 "height", (gdouble) ( height ),
563 plwarn(
"GCW driver <plD_eop_gcw>: Canvas item not created." );
567 g_object_unref( pixbuf );
573 if ( !GNOME_IS_CANVAS_ITEM(
574 item = gnome_canvas_item_new(
576 GNOME_TYPE_CANVAS_RECT,
578 "y1", (gdouble) ( -height ),
579 "x2", (gdouble) ( width ),
586 plabort(
"GCW driver <pld_eop_gcw>: Canvas item not created" );
592 gnome_canvas_item_raise_to_top( GNOME_CANVAS_ITEM( dev->
group_persistent ) );
595 if ( GNOME_IS_CANVAS_ITEM( item ) )
596 gnome_canvas_item_lower_to_bottom( item );
599 gnome_canvas_item_show( GNOME_CANVAS_ITEM( dev->
group_hidden ) );
617 canvas->need_update = 1;
618 gnome_canvas_update_now( canvas );
625 save_state = g_object_get_data( G_OBJECT( canvas ),
"plotbuf" );
626 save_state = (
void *)
plbuf_save( pls, save_state );
629 g_object_set_data( G_OBJECT( canvas ),
"plotbuf", (gpointer) save_state );
636 if ( dev->
window != NULL )
662 if ( !GNOME_IS_CANVAS( dev->
canvas ) )
689 if ( !GNOME_IS_CANVAS_ITEM(
690 dev->
group_hidden = GNOME_CANVAS_GROUP( gnome_canvas_item_new(
691 gnome_canvas_root( canvas ),
692 gnome_canvas_clipgroup_get_type(),
698 plexit(
"GCW driver <plD_bop_gcw>: Canvas group cannot be created" );
702 g_object_set( G_OBJECT( dev->
group_hidden ),
"path", NULL, NULL );
705 gnome_canvas_item_hide( GNOME_CANVAS_ITEM( dev->
group_hidden ) );
727 #ifdef PL_HAVE_FREETYPE
730 FT_Data *FT = (FT_Data *) pls->
FT;
732 plD_FreeType_Destroy( pls );
736 if ( dev->
window != NULL )
762 char opname[20], msg[100];
766 strcpy( opname,
"PLSTATE_WIDTH" );
768 strcpy( opname,
"PLSTATE_COLOR0" );
770 strcpy( opname,
"PLSTATE_COLOR1" );
772 strcpy( opname,
"PLSTATE_FILL" );
774 strcpy( opname,
"PLSTATE_CMAP0" );
776 strcpy( opname,
"PLSTATE_CMAP1" );
778 strcpy( opname,
"unknown" );
779 snprintf( msg, 100,
"<plD_state_gcw />: %s\n", opname );
786 if ( GNOME_IS_CANVAS( dev->
canvas ) )
790 gdk_gc_set_line_attributes( dev->
gc, pls->
width,
801 if ( GNOME_IS_CANVAS( dev->
canvas ) )
812 if ( GNOME_IS_CANVAS( dev->
canvas ) )
846 GnomeCanvasPoints* points;
847 GnomeCanvasGroup * group;
848 GnomeCanvasItem * item;
850 GnomeCanvas * canvas;
854 GdkPoint * gdkpoints;
862 if ( !GNOME_IS_CANVAS( dev->
canvas ) )
863 plexit(
"GCW driver <fill_polygon>: Canvas not found" );
874 if ( ( gdkpoints = (GdkPoint *) malloc( pls->
dev_npts * sizeof ( GdkPoint ) ) ) == NULL )
876 plabort(
"GCW driver <fill_polygon>: Could not create gdkpoints" );
882 for ( i = 0; i < pls->
dev_npts; i++ )
884 gdkpoints[i].x = (gint) ( pls->
dev_x[i] /
VSCALE );
890 for ( i = 0; i < pls->
dev_npts; i++ )
906 if ( ( points = gnome_canvas_points_new( pls->
dev_npts ) ) == NULL )
908 plabort(
"GCW driver <fill_polygon>: Could not create points" );
914 for ( i = 0; i < pls->
dev_npts; i++ )
916 points->coords[2 * i] = (gdouble) ( pls->
dev_x[i] /
VSCALE );
917 points->coords[2 * i + 1] = (gdouble) ( -pls->
dev_y[i] /
VSCALE );
922 for ( i = 0; i < pls->
dev_npts; i++ )
925 points->coords[2 * i + 1] = (gdouble) ( -pls->
dev_x[i] /
VSCALE );
929 if ( !GNOME_IS_CANVAS_ITEM(
930 item = gnome_canvas_item_new( group,
931 GNOME_TYPE_CANVAS_POLYGON,
933 "fill-color-rgba", dev->
color,
938 plwarn(
"GCW driver <fill_polygon>: Canvas item not created." );
941 gnome_canvas_points_free( points );
955 #ifdef PL_HAVE_FREETYPE
969 GnomeCanvasGroup* group;
971 GnomeCanvas * canvas;
974 guchar *fontname = NULL;
978 GnomeGlyphList *glyphlist;
981 gdouble affine_baseline[6] = { 0., 0., 0., 0., 0., 0. };
982 gdouble affine_translate[6] = { 0., 0., 0., 0., 0., 0. };
983 gdouble affine_rotate[6] = { 0., 0., 0., 0., 0., 0. };
984 gdouble affine_plplot[6] = { 0., 0., 0., 0., 0., 0. };
986 GnomeCanvasItem * item[200];
987 gdouble width[200], height[200];
988 gdouble up_list[200];
989 gdouble up = 0, scale = 1;
999 gdouble total_width = 0, sum_width = 0;
1008 if ( !GNOME_IS_CANVAS( dev->
canvas ) )
1009 plexit(
"GCW driver <proc_str>: Canvas not found" );
1025 affine_plplot[0] = t[0];
1026 affine_plplot[1] = -t[2];
1027 affine_plplot[2] = -t[1];
1028 affine_plplot[3] = t[3];
1036 if ( fontname == NULL )
1038 plabort(
"GCW driver <proc_str>: FCI inconsistent with TrueTypeLookup" );
1043 face = gnome_font_face_find_from_filename( fontname, 0 );
1062 if ( fontname == NULL )
1064 plabort(
"GCW driver <proc_str>: FCI inconsistent with "
1070 gnome_font_unref( face );
1071 face = gnome_font_face_find_from_filename( fontname, 0 );
1077 if ( text[i] == esc )
1083 plwarn(
"GCW driver <proc_str>: Invalid escape sequence "
1084 "provided in text." );
1100 up -= font_size / 2.;
1110 up += font_size / 2.;
1124 plwarn(
"GCW driver <proc_str>: '+', '-', and 'b' text "
1125 "escape sequences not processed." );
1129 if ( text[i] !=
'#' )
1142 font = gnome_font_face_get_font_default( face, font_size * scale );
1146 glyphlist = gnome_glyphlist_new();
1147 gnome_glyphlist_font( glyphlist, font );
1148 gnome_glyphlist_color( glyphlist, dev->
color );
1149 gnome_glyphlist_advance( glyphlist,
TRUE );
1150 gnome_glyphlist_kerning( glyphlist, 0. );
1151 gnome_glyphlist_letterspace( glyphlist, 0. );
1154 gnome_font_unref( font );
1160 while ( i < Ntext && !( text[i] & PL_FCI_MARK ) )
1163 if ( text[i] == esc )
1165 if ( !( i > 0 && text[i - 1] == esc ) )
1169 gnome_glyphlist_glyph( glyphlist,
1170 gnome_font_lookup_default( font, text[i] ) );
1177 gnome_glyphlist_bbox( glyphlist, NULL, 0, &bbox );
1178 width[
N] = bbox.x1 - bbox.x0;
1179 height[
N] = bbox.y1 - bbox.y0;
1182 total_width += width[
N];
1187 if ( !GNOME_IS_CANVAS_ITEM(
1188 item[N] = gnome_canvas_item_new( group,
1190 "glyphlist", glyphlist,
1191 "fill-color-rgba", dev->
color,
1197 plabort(
"GCW driver <proc_str>: Canvas item not created" );
1202 gnome_glyphlist_unref( glyphlist );
1210 if ( N == 200 && i < Ntext )
1212 plabort(
"GCW driver <proc_str>: too many text segments" );
1220 for ( i = 0; i <
N; i++ )
1223 art_affine_rotate( affine_rotate, 90. * ( pls->
diorot - pls->
portrait ) );
1226 art_affine_translate( affine_baseline,
1227 -total_width * args->
just + sum_width,
1228 height[0] / 2.5 - up_list[i] );
1229 art_affine_translate( affine_translate,
1234 art_affine_translate( affine_baseline,
1235 -total_width * args->
just + sum_width,
1236 height[0] / 2.5 - up_list[i] );
1237 art_affine_translate( affine_translate,
1240 gnome_canvas_item_affine_relative( item[i], affine_translate );
1241 gnome_canvas_item_affine_relative( item[i], affine_rotate );
1242 gnome_canvas_item_affine_relative( item[i], affine_plplot );
1243 gnome_canvas_item_affine_relative( item[i], affine_baseline );
1246 sum_width += width[i];
1255 #endif //PL_HAVE_FREETYPE
1270 char opname[20], msg[100];
1272 strcpy( opname,
"PLESC_DEVINIT" );
1274 strcpy( opname,
"PLESC_CLEAR" );
1276 strcpy( opname,
"PLESC_FILL" );
1278 strcpy( opname,
"PLESC_HAS_TEXT" );
1280 strcpy( opname,
"PLESC_GRAPH" );
1282 strcpy( opname,
"unknown" );
1283 snprintf( msg, 100,
"<plD_esc_gcw />: %s\n", opname );
1301 #ifdef PL_HAVE_FREETYPE