]> granicus.if.org Git - graphviz/commitdiff
smyrna improvements
authorarif <devnull@localhost>
Wed, 8 Apr 2009 18:55:09 +0000 (18:55 +0000)
committerarif <devnull@localhost>
Wed, 8 Apr 2009 18:55:09 +0000 (18:55 +0000)
lib/glcomp/glcompset.c
lib/glcomp/glcomptext.c

index 5a8d318ce53b1f2519484fcafc0ee90c7150a715..63e725de4de99f50ec2e8314439e37a8fbba9ae8 100644 (file)
@@ -239,14 +239,12 @@ void glCompSetClear(glCompSet * s)
        free(s->panels[ind]);
     }
     free(s->panels);
-    free(s->font);
     free(s);
 }
 
 glCompSet* glCompSetNew()
 {
     glCompSet *s = NEW(glCompSet);
-    s->font = font_init();
     return s;
 }
 
index 4fec751176800b7abb586d6a0a5cf54ba2b5e68a..a47de236b6cac42ddd5fb5ce36dab67fc058e9ef 100644 (file)
@@ -21,7 +21,8 @@ print_bitmap_string(void* font, char* s)
    if (s && strlen(s)) {
       while (*s) {
          glutBitmapCharacter(font, *s);
-         s++;
+//         glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *s);
+               s++;
       }
    }
 }
@@ -98,7 +99,16 @@ glprintf (glCompText* font, GLfloat xpos, GLfloat ypos,
        int maxcharCount;
        char* tempC;
        GLfloat charGap;
-       
+
+       //set the color
+       glColor4f(font->color.R,font->color.G,font->color.B,font->color.A);
+       if (!font)
+               return;
+       if (font->isglut)
+       {
+               glprintfglut (font->glutfont, xpos,ypos,bf);
+               return;
+       }
 
        glGetIntegerv (GL_VIEWPORT, vPort);
 
@@ -166,6 +176,54 @@ static int fontId(fontset_t* fontset,char* fontdesc)
        return -1;
 }
 
+static int glutfontId(fontset_t* fontset,void* glutfont)
+{
+       int ind=0;
+       for (ind=0;ind < fontset->count;ind ++)
+       {
+               if (fontset->fonts[ind]->glutfont=glutfont)
+                       return ind;
+       }
+       return -1;
+}
+
+
+glCompText* glut_font_init()
+{
+    glCompText* font = NEW(glCompText);
+       int idx = 0;
+       font->color.R=1.00;
+       font->color.G=1.00;
+       font->color.B=1.00;
+       font->color.A=1.00;
+
+
+/*     font->fontheight=12;
+       font->tIncX=0.0;
+       font->tIncY=0.0;
+       font->texId=-1;
+       font->fontdesc=(char*)0;
+
+
+
+
+       font->tIncX = (float)pow (C_DPI, -1);
+       font->tIncY = (float)pow (R_DPI, -1);
+
+       
+       for (y = 1 - font->tIncY; y >= 0; y -= font->tIncY)
+       {
+               for (x = 0; x <= 1 - font->tIncX; x += font->tIncX, idx ++)
+               {
+                       font->bmp[idx][0]=x;
+                       font->bmp[idx][1]=y;
+               }
+       }*/
+    return font;
+}
+
+
+
 
 glCompText* font_init()
 {
@@ -187,6 +245,7 @@ glCompText* font_init()
 
 
 
+
        font->tIncX = (float)pow (C_DPI, -1);
        font->tIncY = (float)pow (R_DPI, -1);
 
@@ -262,41 +321,62 @@ fontset_t* fontset_init()
 static char* fontpath = NULL;
 static size_t fontpathsz = 0;
 
-int add_font(fontset_t* fontset,char* fontdesc)
+glCompText* add_glut_font(fontset_t* fontset,void* glutfont)
+{
+       int id;
+       id=glutfontId(fontset,glutfont);
+       if(id==-1)
+       {
+               fontset->fonts = ALLOC(fontset->count+1,fontset->fonts,glCompText*);
+               fontset->fonts[fontset->count] = glut_font_init ();
+               fontset->fonts[fontset->count]->isglut=1;
+               fontset->fonts[fontset->count]->glutfont=glutfont;
+               fontset->count++;
+               return fontset->fonts[fontset->count-1];
+       }
+       else
+               return fontset->fonts[id];
+}
+
+
+glCompText* add_font(fontset_t* fontset,char* fontdesc)
 {
     int id;    
     size_t sz;
     glCompText* tf;
 
     id=fontId(fontset,fontdesc);
-
-    if (id==-1) {
-       sz = strlen(fontset->font_directory)+strlen(fontdesc)+6;
-       if (sz > fontpathsz) {
-           fontpathsz = 2*sz;
-           fontpath = ALLOC (fontpathsz, fontpath, char); 
-        }
-       sprintf(fontpath,"%s/%s.png",fontset->font_directory,fontdesc);
-       if(create_font_file(fontdesc,fontpath,(float)32,(float)32)==0) {
-           fontset->fonts = ALLOC(fontset->count+1,fontset->fonts,glCompText*);
-           fontset->fonts[fontset->count] = tf = font_init ();
-           tf->fontdesc = strdup(fontdesc);
-           glGenTextures (1, &(tf->texId));    //get  opengl texture name
-           if ((tf->texId >= 0) && glCompLoadFontPNG (fontpath, tf->texId)) {
-               fontset->activefont=fontset->count;
-               fontset->count++;
-               return fontset->count;
-           }
-           else
-               return -1;
+       if (id==-1) 
+       {
+               sz = strlen(fontset->font_directory)+strlen(fontdesc)+6;
+               if (sz > fontpathsz) 
+               {
+                       fontpathsz = 2*sz;
+                       fontpath = ALLOC (fontpathsz, fontpath, char); 
+               }
+               sprintf(fontpath,"%s/%s.png",fontset->font_directory,fontdesc);
+               if(create_font_file(fontdesc,fontpath,(float)32,(float)32)==0) 
+               {
+                       fontset->fonts = ALLOC(fontset->count+1,fontset->fonts,glCompText*);
+                       fontset->fonts[fontset->count] = tf = font_init ();
+                       tf->fontdesc = strdup(fontdesc);
+                       fontset->fonts[fontset->count]->isglut=0;
+                       glGenTextures (1, &(tf->texId));        //get  opengl texture name
+                       if ((tf->texId >= 0) && glCompLoadFontPNG (fontpath, tf->texId)) 
+                       {
+                               fontset->activefont=fontset->count;
+                               fontset->count++;
+                               return fontset->fonts[fontset->count-1];
+                       }
+                       else
+                               return NULL;
+               }
+               else
+                       return NULL;
        }
        else
-           return -1;
-    }
-    else
-       return id;
+               return fontset->fonts[id];
 }
-
 void free_font_set(fontset_t* fontset)
 {
     int ind;