本文整理汇总了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;
}
示例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;
}
示例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
}
示例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;
}
示例5:
void
moFont::SetSize( MOfloat size ) {
m_FontSize = size;
FTFont* FF = (FTFont*) m_pFace;
if (FF) FF->FaceSize(m_FontSize);
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}
}
}
示例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());
}
}
示例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);
}