当前位置: 首页>>代码示例>>C++>>正文


C++ FTFont类代码示例

本文整理汇总了C++中FTFont的典型用法代码示例。如果您正苦于以下问题:C++ FTFont类的具体用法?C++ FTFont怎么用?C++ FTFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FTFont类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RegisterFont

const bool RegisterFont(const String& filename, int pointSize, const String& nickname)
{
	std::map<String,FTFont*>::iterator it = _fontCache.find(nickname);
	if(it != _fontCache.end())
	{
		UnRegisterFont(nickname);
	}
	
	if (theWorld.IsHighResScreen())
	{
		pointSize = pointSize * 2;
	}

	FTFont *font = new FTGLTextureFont(filename.c_str());
	if(font->Error())
	{
		sysLog.Log("Failed to open font " + filename);
		return false;
	}
	if(!font->FaceSize(pointSize))
	{
		sysLog.Log("Failed to set size.");
		return false;
	}
	font->CharMap(FT_ENCODING_NONE);
	font->UseDisplayList(true);

	_fontCache[nickname] = font;
	return true;
}
开发者ID:Gi133,项目名称:NetworkingCoursework,代码行数:30,代码来源:TextRendering.cpp

示例2: glPixelStorei

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;
}
开发者ID:inaes-tic,项目名称:tv-moldeo,代码行数:60,代码来源:moFontManager.cpp

示例3: UIListCell

UIListCell *MainScreen::CellAtIndex(UIList *list, int32 index)
{
    UIListCell *c = list->GetReusableCell("UI info cell"); //try to get cell from the reusable cells store
    if(!c)
    {
        c = new UIListCell(Rect(0.0f, 0.0f, 2*buttonW, cellH), "UI info cell");
    }
    
    c->RemoveAllControls();
    
    WideString keyStr = (selectedControl ? selectedControl->GetSpecificInfoKeyText(index) : L"");
    WideString valueStr = (selectedControl ? selectedControl->GetSpecificInfoValueText(index) : L"");
    
    FTFont* font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf");
    font->SetSize(20.0f);
    font->SetColor(0.8f, 0.8f, 0.8f, 1.0f);
    
    c->SetStateFont(UIControl::STATE_NORMAL, font);
    
    UIStaticText* cellKeyText = new UIStaticText(Rect(0.0f, 0.0f, buttonW, cellH));
    cellKeyText->SetFont(font);
    cellKeyText->SetText(keyStr);
    c->AddControl(cellKeyText);
    
    UIStaticText* cellValueText = new UIStaticText(Rect(buttonW, 0.0f, buttonW, cellH));
    cellValueText->SetFont(font);
    cellValueText->SetText(valueStr);
    c->AddControl(cellValueText);
    
    SafeRelease(font);
    
    return c;//returns cell
}
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:33,代码来源:MainScreen.cpp

示例4: getFTFont

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;
}
开发者ID:AdRiley,项目名称:mapserver,代码行数:28,代码来源:mapoglrenderer.cpp

示例5:

void
moFont::SetSize( MOfloat size ) {

    m_FontSize = size;

    FTFont* FF = (FTFont*) m_pFace;
    if (FF) FF->FaceSize(m_FontSize);

}
开发者ID:inaes-tic,项目名称:tv-moldeo,代码行数:9,代码来源:moFontManager.cpp

示例6: switch

void TextPropertyGridWidget::UpdatePushButtonWidgetWithFont(QPushButton *pushButtonWidget, Font* font)
{
    if (pushButtonWidget != this->ui->fontSelectButton)
    {
        return; //Not font select button
    }
    
    if (font)
    {
        //Set button text
        Font::eFontType fontType = font->GetFontType();
        QString buttonText;
        
        switch (fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = static_cast<FTFont*>(font);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(ftFont->GetFontPath().GetFrameworkPath());
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = static_cast<GraphicsFont*>(font);
                //Put into result string font definition and font sprite path
                Sprite *fontSprite = gFont->GetFontSprite();
                if (!fontSprite) //If no sprite available - quit
                {
                    pushButtonWidget->setText("Graphical font is not available");
                    return;
                }
                //Get font definition and sprite relative path
                QString fontDefinitionName = QString::fromStdString(gFont->GetFontDefinitionName().GetFrameworkPath());
                QString fontSpriteName =QString::fromStdString(fontSprite->GetRelativePathname().GetFrameworkPath());
                //Set push button widget text - for grapics font it contains font definition and sprite names
                buttonText = QString("%1\n%2").arg(fontDefinitionName, fontSpriteName);
                break;
            }
            case Font::TYPE_DISTANCE:
            {
                DFFont *dfFont = static_cast<DFFont*>(font);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(dfFont->GetFontPath().GetFrameworkPath());
                break;
            }
            default:
            {
                //Do nothing if we can't determine font type
                return;
            }
        }
        
        pushButtonWidget->setText(buttonText);
    }
}
开发者ID:galek,项目名称:dava.framework,代码行数:56,代码来源:textpropertygridwidget.cpp

示例7: GetStringSize

	void Font::GetStringSize(const String &text, Vector2D *result) {
		if (mID < 0) {
			*result = kFastVector2DZero;
			return;
		}
		FTFont *tf =
			(FTFont*)GetCollection()->GetResource(mID)->GetFTFont();
		result->mX = tf->Advance(text.GetWString().mData);
		result->mY = tf->LineHeight();
	}
开发者ID:JSandrew4,项目名称:FastGdk,代码行数:10,代码来源:Font.cpp

示例8: blocker

void UITextFieldPropertyGridWidget::UpdatePushButtonWidgetWithPropertyValue(QPushButton *pushButtonWidget, const QMetaProperty &curProperty)
{
    
    if (pushButtonWidget != this->ui->fontSelectButton)
    {
        return; //Not font select button
    }
    
    bool isPropertyValueDiffers = false;
    Font *fontPropertyValue = PropertiesHelper::GetPropertyValue<Font *>(this->activeMetadata,
                                                                         curProperty.name(), isPropertyValueDiffers);
    if (fontPropertyValue)
    {
        //Set button text
        WidgetSignalsBlocker blocker(pushButtonWidget);
        Font::eFontType fontType = fontPropertyValue->GetFontType();
        QString buttonText;
        
        switch (fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = dynamic_cast<FTFont*>(fontPropertyValue);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(ftFont->GetFontPath().GetFrameworkPath());
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = dynamic_cast<GraphicsFont*>(fontPropertyValue);
                //Put into result string font definition and font sprite path
                Sprite *fontSprite = gFont->GetFontSprite();
                if (!fontSprite) //If no sprite available - quit
                {
                    pushButtonWidget->setText("Graphical font is not available");
                    return;
                }
                //Get font definition and sprite relative path
                QString fontDefinitionName = QString::fromStdString(gFont->GetFontDefinitionName().GetFrameworkPath());
                QString fontSpriteName =QString::fromStdString(fontSprite->GetRelativePathname().GetFrameworkPath());
                //Set push button widget text - for grapics font it contains font definition and sprite names
                buttonText = QString("%1\n%2").arg(fontDefinitionName, fontSpriteName);
                break;
            }
            default:
            {
                //Do nothing if we can't determine font type
                return;
            }
        }
        
        pushButtonWidget->setText(buttonText);
    }
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:54,代码来源:uitextfieldpropertygridwidget.cpp

示例9: FTTextureFont

FTFont* FXFontManager::create(std::string font_file, int size) {

    FTFont* ft = new  FTTextureFont(font_file.c_str());

    if(ft->Error() || !ft->FaceSize(size)) {
        delete ft;
        throw FXFontException(font_file);
    }

    return ft;
}
开发者ID:ArondeParon,项目名称:Logstalgia,代码行数:11,代码来源:fxfont.cpp

示例10: getFont

Action::ResultE FTGLText::drawPrimitives(DrawActionBase *action )
{
    FTGLFontPtr font = getFont();
    
    if(font == NullFC)
    {
        FWARNING(("FTGLText::drawPrimitives: no font set!\n"));
        return Action::Continue;
    }
   
    action->getWindow()->validateGLObject(font->getGLId());
    
    FTFont *ftf = font->_fonts[action->getWindow()];
    
    if(ftf == NULL)
    {
        FWARNING(("FTGLText::drawPrimitives: invalid font set!\n"));
        return Action::Continue;        
    }

    switch(font->getDrawType())
    {
    case FTGLFont::Texture:   
    case FTGLFont::Polygon:   
    case FTGLFont::Extrude:   
    case FTGLFont::Outline: glPushMatrix();
                            glTranslatef(getPosition()[0], 
                                         getPosition()[1], 
                                         getPosition()[2]);
                            glNormal3f(0,0,1);
                            break;
    case FTGLFont::Pixmap:   
    case FTGLFont::Bitmap:  glRasterPos3f(getPosition()[0], 
                                          getPosition()[1], 
                                          getPosition()[2]);
                            break;
    }
   
    ftf->Render(getText().c_str());
    
    switch(font->getDrawType())
    {
    case FTGLFont::Texture:   
    case FTGLFont::Polygon:   
    case FTGLFont::Extrude:   
    case FTGLFont::Outline: glPopMatrix();
                            break;
    case FTGLFont::Pixmap:   
    case FTGLFont::Bitmap:  break;
    }

    return Action::Continue;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:53,代码来源:OSGFTGLText.cpp

示例11: FTTextureFont

void Writter::AddFont(string iname, string fontfile, int fontsize){

	FTFont* nfont = new FTTextureFont(fontfile.c_str());

	if(nfont->Error())
    {
        fprintf(stderr, "Failed to open font %s", fontfile);
        exit(1);
    }
	nfont->FaceSize(fontsize);
	
	m_font_list[iname] = nfont;
}
开发者ID:renatocron,项目名称:sdl-midian-game,代码行数:13,代码来源:Writter.cpp

示例12: UIStaticText

UIStaticText * PropertyPanel::AddHeader(const WideString & string, float32 fontSize)
{
    FTFont * font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf");
    font->SetSize(fontSize);
    font->SetColor(Color(0.2f, 0.2f, 0.2f, 1.0f));

    UIStaticText * text = new UIStaticText(Rect(10, 0, GetRect().dx - 20, 20));
    text->SetAlign(ALIGN_LEFT | ALIGN_VCENTER);
    text->SetFont(font);
    text->SetText(string);
    SafeRelease(font);
    AddPropertyControl(text);
    text->Release();
    return text;
}
开发者ID:dheerendra1,项目名称:dava.framework,代码行数:15,代码来源:PropertyPanel.cpp

示例13: SetSize

void
moFont::Draw( MOfloat x, MOfloat y, moText& text, moFontSize p_fontsize, MOint set, MOfloat sx, MOfloat sy, MOfloat rt ) {

    FTFont* FF = (FTFont*) m_pFace;
    if (FF) {
        SetSize(p_fontsize);
        FF->Render( text, text.Length(), FTPoint(x,y) );
    }

    else {
      if (m_FontGLId>=0) {
          this->glPrint( (int)x, (int)y, text, set, sx, sy, rt );
      }
    }
}
开发者ID:inaes-tic,项目名称:tv-moldeo,代码行数:15,代码来源:moFontManager.cpp

示例14: Draw

void Writter::Draw(string iname, string str, float x, float y, float mangle){
	FTFont* nfont = m_font_list[iname];

	if (nfont != NULL){
		glPushMatrix();

		glTranslatef(x, -y - nfont->LineHeight(), 0);
		glRotatef(mangle, 0.0, 0.0, 1);
		
		nfont->Render(str.c_str());

		glPopMatrix();

	}else{
		fprintf(stderr, "Failed to draw using name '%s': %s\n", iname.c_str(), str.c_str());
	}
}
开发者ID:renatocron,项目名称:sdl-midian-game,代码行数:17,代码来源:Writter.cpp

示例15: switch

EditorFontManager::DefaultFontPath EditorFontManager::GetDefaultFontPath()
{
	FilePath defFontPath;
	FilePath defFontSpritePath;

	if (defaultFont)
	{
		Font::eFontType fontType = defaultFont->GetFontType();		
        switch (fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = dynamic_cast<FTFont*>(defaultFont);
				FilePath ftFontPath = ftFont->GetFontPath();
				// Don't save standart default font
				if (ftFontPath.GetAbsolutePathname().find(DEFAULT_FONT_NAME) == String::npos)
				{
					// Set font path
					defFontPath = ftFontPath;
				}
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = dynamic_cast<GraphicsFont*>(defaultFont);
                // Try to get font sprite
                Sprite *fontSprite = gFont->GetFontSprite();
				// Save font only if sprite is available
                if (fontSprite)
                {
					// Set font definition and sprite relative path
					defFontPath = gFont->GetFontDefinitionName();
					defFontSpritePath = fontSprite->GetRelativePathname();
                }
				break;
            }
        }	
	}
	
	return DefaultFontPath(defFontPath, defFontSpritePath);
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:41,代码来源:EditorFontManager.cpp


注:本文中的FTFont类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。