[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How about a Calligraphy-based Font Designer program



The image i have posted uses only a single curve
think of that.

could any one tell me how to use libgnomecanvas
I attached a small C portion that should display a closed region
but it don't
so what's wrong with it
please any one help me to start with gnomecanvas

If I was able to do that the rest is quite simple
#include<gtk/gtk.h>
#include <libgnomecanvas/libgnomecanvas.h>
GtkWidget *win;
GtkWidget *w;
int main(int argc, char **argv)
{

  gtk_init(&argc,&argv);
  win = g_object_new(GTK_TYPE_WINDOW,
	"type",GTK_WINDOW_TOPLEVEL,
	"title","Calligraphy Font Designer",
	/*"icon",icon, */
	"default-width",640,
	"default-height",400,
	"urgency-hint",TRUE,
	NULL
  );
  g_signal_connect (G_OBJECT (win), "destroy", G_CALLBACK (gtk_main_quit), NULL);
  w=gnome_canvas_new ();
  gtk_container_add (GTK_CONTAINER (win), w);
  gnome_canvas_set_pixels_per_unit(w,1.0);
/*
  ArtBpath path[]={
    {ART_MOVETO,10,10,10,10,10,10} ,
    {ART_CURVETO,25,25,75,75,150,150},
    {ART_LINETO,10,10,10,10,10,10} ,
    {ART_END,0,0,0,0,0,0}
  };
  GnomeCanvasPathDef *bpath1=gnome_canvas_path_def_new_from_bpath(path);
*/
  GnomeCanvasPathDef *bpath=gnome_canvas_path_def_new();
  gnome_canvas_path_def_moveto(bpath,10.0, 10.0);
  gnome_canvas_path_def_curveto(bpath,25.0,25.0,75.0,75.0,150.0,150.0);
  gnome_canvas_path_def_lineto(bpath,10.0,10.0);
  gnome_canvas_path_def_closepath (bpath);
  GnomeCanvasGroup* grp=gnome_canvas_root(w);
  GnomeCanvasItem* itm0=gnome_canvas_item_new(grp, GNOME_TYPE_CANVAS_RE,
    "fill_color", "black", "width_units", 5.0, "x1",50.0,"y1",50.0,"x2",80.0,"y2",80.0,NULL);

  GnomeCanvasItem* itm=gnome_canvas_item_new(grp, GNOME_TYPE_CANVAS_BPATH,
    "fill_color", "black", "width_units", 5.0, "bpath",bpath,NULL);

  //gtk_layout_put(w,itm,0,0); //wrong
  //gtk_container_add(w,itm0); //wrong
  //gnome_canvas_update_now(w); //wrong
  gtk_widget_show_all (win);
  gtk_main ();
  return 0;
}