示例#1
0
MOboolean
moFont::Init( moFontType p_Type, moText p_fontname, MOint p_size, MOuint glid ) {

  glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );

	switch( (int)p_Type ) {
		case MO_FONT_OUTLINE://3d
			m_pFace = (FTFont*)new FTGLOutlineFont( p_fontname );
			break;
		case MO_FONT_TRANSLUCENT://2d
            m_pFace = (FTFont*)new FTGLBitmapFont( p_fontname );
			break;
		case MO_FONT_TRANSLUCENTTEXTURE://3d
            m_pFace = (FTFont*)new FTGLTextureFont( p_fontname );
			break;
		case MO_FONT_GRAYSCALE://2d
            m_pFace = (FTFont*)new FTGLPixmapFont( p_fontname );
			break;
		case MO_FONT_MONOCHROME://2d
            m_pFace = (FTFont*)new FTGLPixmapFont( p_fontname );
			break;
		case MO_FONT_SOLID://3d extruded (depth)
            m_pFace = (FTFont*)new FTGLExtrdFont( p_fontname );
			break;
		case MO_FONT_FILLED://3d
            m_pFace = (FTFont*)new FTGLPolygonFont( p_fontname );
			break;
    case MO_FONT_GLBUILD:
            m_FontGLId = glid;
            BuildFont();
			break;
    case MO_FONT_UNDEFINED:
            MODebug2->Error(moText(" FontManager:: UNDEFINED font type"));
            m_pFace = NULL;
            break;

	}


  FTFont* FF = (FTFont*) m_pFace;
  FT_Error FontError;
  if (FF)
    FontError = FF->Error();

	if ( ( p_Type!=MO_FONT_GLBUILD && ( FF == NULL || FontError!=0 ) ) ||
         ( p_Type==MO_FONT_UNDEFINED )  || (p_Type==MO_FONT_GLBUILD && (int)m_FontGLId==-1)) {
        MODebug2->Error(moText("FontManager: Could not construct face from ")+(moText)p_fontname);
        return false;
	} else {
		m_Name = p_fontname;
    if (FF) {
      SetSize(p_size);
      FF->Depth(20);
      //FF->CharMap(ft_encoding_unicode);
    }
		return true;
	}

	return false;
}
示例#2
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; 

        }
    }