示例#1
0
bool OglRenderer::getStringBBox(char *font, double size, char *string, rectObj *rect, double** advances)
{
  FTFont* face = getFTFont(font, size);
  if (!face) {
    msSetError(MS_OGLERR, "Failed to load font (%s).", "OglRenderer::getStringBBox()", font);
    return false;
  }

  float llx =0.0f, lly=0.0f, llz=0.0f, urx=0.0f, ury=0.0f, urz=0.0f;
  glPushAttrib( GL_ALL_ATTRIB_BITS );
  FTBBox boundingBox = face->BBox(string);
  glPopAttrib();

  rect->minx = boundingBox.Lower().X();
  rect->maxx = boundingBox.Upper().X();
  rect->miny = -boundingBox.Upper().Y();
  rect->maxy = -boundingBox.Lower().Y();

  if (advances) {
    int length = strlen(string);
    *advances = new double[length];
    for (int i = 0; i < length; ++i) {
      (*advances)[i] = face->Advance(&string[i], 1);
    }
  }

  return true;
}
示例#2
0
 int process_lines()
 {
   if (!ftfont) return 0;
   vsx_string<>deli = "\n";
   vsx_nw_vector< vsx_string<> > t_lines;
   vsx_string_helper::explode(text_in->get(), deli, t_lines);
   lines.clear();
   for (unsigned long i = 0; i < t_lines.size(); ++i)
   {
     float x1, y1, z1, x2, y2, z2;
     lines[i].string = t_lines[i];
     ftfont->BBox(t_lines[i].c_str(), x1, y1, z1, x2, y2, z2);
     lines[i].size_x = x2 - x1;
     lines[i].size_y = y2 - y1;
   }
   return 1;
 }
示例#3
0
    AudicleFTGLFont( char * name ) { 
        
        glEnable ( GL_TEXTURE_2D );
        
        char fontlocation[512];
        strncpy ( fontlocation, fontpath, 512 );
        strncat ( fontlocation, name, 512 - strlen ( fontlocation ) );
        
        m_font = new FTGLTextureFont ( fontlocation );
        
        if ( m_font->Error() ) { 
            fprintf(stderr, "AudicleFTGLFont: font load error %d - exiting\n", m_font->Error() );
            exit(1);
        }
        else { 
            
        if ( !m_font->FaceSize(18) ) { 
            fprintf(stderr, "AudicleFTGLFont: font size error  %d - exiting\n", m_font->Error() );
            exit(1);
        }

        m_name = name;
        m_font->Depth(2);
        m_font->CharMap(ft_encoding_unicode);
    
        glDisable ( GL_TEXTURE_2D );
        
        float x1, y1, z1, x2, y2, z2;
        
        m_font->BBox( samplestring , x1, y1, z1, x2, y2, z2);
        m_height = y2;
        m_line_height = m_font->LineHeight();
        
        m_height_unit_scale = 1.0 / m_height ;
        m_line_unit_scale = 1.0 / m_line_height ;
        m_mono_width = m_height; 

        }
    }
示例#4
0
void FTGLText::adjustVolume(Volume & volume)
{
    FTGLFontPtr font = getFont();
    
    if(font == NullFC)
    {
        FWARNING(("FTGLText::adjustVolume: no font set!\n"));
        return;
    }

    FTFont *f = font->_fonts[NULL];
    if(f == NULL)
    {
        font->handleGL(NULL, Window::reinitialize);
        f = font->_fonts[NULL];
    }
    
    volume.setValid();
    volume.setEmpty();

    volume.extendBy(getPosition());
    
    float x1, y1, z1, x2, y2, z2, px, py, pz;
    f->BBox(getText().c_str(), x1, y1, z1, x2, y2, z2);

    px = getPosition()[0];
    py = getPosition()[1];
    pz = getPosition()[2];
    
    volume.extendBy(Pnt3f(px + x1, py + y1, pz + z1));
    volume.extendBy(Pnt3f(px + x2, py + y1, pz + z1));
    volume.extendBy(Pnt3f(px + x1, py + y2, pz + z1));
    volume.extendBy(Pnt3f(px + x2, py + y2, pz + z1));
    volume.extendBy(Pnt3f(px + x1, py + y1, pz + z2));
    volume.extendBy(Pnt3f(px + x2, py + y1, pz + z2));
    volume.extendBy(Pnt3f(px + x1, py + y2, pz + z2));
    volume.extendBy(Pnt3f(px + x2, py + y2, pz + z2));
}