本文整理汇总了C++中FTFont::FaceSize方法的典型用法代码示例。如果您正苦于以下问题:C++ FTFont::FaceSize方法的具体用法?C++ FTFont::FaceSize怎么用?C++ FTFont::FaceSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTFont
的用法示例。
在下文中一共展示了FTFont::FaceSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup_font
void setup_font()
{
if
(
(cur_font != font_in->get()) ||
(cur_render_type !=render_type->get()) ||
(cur_glyph_size != glyph_size->get())
)
{
vsx::file *fp;
if ((fp = engine_state->filesystem->f_open(font_in->get().c_str())) == NULL)
{
printf("font not found: %s\n",cur_font.c_str());
return;
}
cur_font = font_in->get();
cur_render_type = render_type->get();
cur_glyph_size = glyph_size->get();
if (ftfont) {
delete ftfont;
ftfont = 0;
}
if (ftfont2) {
delete ftfont2;
ftfont2 = 0;
}
unsigned long size = engine_state->filesystem->f_get_size(fp);
char* fdata = (char*)malloc(size);
unsigned long bread = engine_state->filesystem->f_read((void*)fdata, size, fp);
if (bread == size)
{
switch (cur_render_type)
{
case 0:
ftfont = new FTGLTextureFont((unsigned char*)fdata, size);
break;
case 1:
ftfont = new FTGLPolygonFont((unsigned char*)fdata, size);
ftfont2 = new FTGLOutlineFont((unsigned char*)fdata, size);
break;
}
ftfont->FaceSize((unsigned int)round(cur_glyph_size));
ftfont->CharMap(ft_encoding_unicode);
if (ftfont2) {
ftfont2->FaceSize((unsigned int)round(cur_glyph_size));
ftfont2->CharMap(ft_encoding_unicode);
}
loading_done = true;
}
engine_state->filesystem->f_close(fp);
}
}
示例2: 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;
}
示例3: draw_text
int draw_text(int corner_x, int corner_y, int size, string text, int color){
if((size > 4 || size < 1) && size < 10 ){
cerr << "FutureGL Error: FutureGL only supports 4 core font sizes\nPlease adapt your code. Sorry.\n";
return -1;
}
colors(1, color);
glTranslated(corner_x, corner_y, 0);
// Create a texture font from a TrueType file.
FTFont *font;
bool font_loaded = false;
for(int i = 0; i < num_fonts; i++){
font = new FTTextureFont(fonts[i].c_str());
if(!(font->Error())){
font_loaded = true;
break;
}
}
if(!font_loaded){
cerr << "FutureGL Error: Font not found\nTried:\n";
for(int i = 0; i < num_fonts; i++) cerr << "\t" << fonts[i] << "\n";
return -1;
}
// Set the font size and render a small text.
if(size == 1) font->FaceSize(60);
else if(size == 2) font->FaceSize(29);
else if(size == 3) font->FaceSize(10);
else if(size == 4) font->FaceSize(10);
else font->FaceSize(size);
font->Render(text.c_str());
delete(font);
glTranslated(-corner_x, -corner_y, 0);
return 0;
}
示例4:
void
moFont::SetSize( MOfloat size ) {
m_FontSize = size;
FTFont* FF = (FTFont*) m_pFace;
if (FF) FF->FaceSize(m_FontSize);
}
示例5: create
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;
}
示例6: AddFont
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;
}
示例7: AudicleFTGLFont
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;
}
}
示例8: FTGLPixmapFont
// ----------------------------------------------------------------------------
FTFont*
GSystemGL::SetupFont( const char * inPath, int inFontSize ) const
{
FTFont * font = 0;
char faceName2[40];
strcpy(faceName2, inPath);
#ifdef WIN32
if( !strcmp(inPath,"Times") )
strcpy(faceName2, "times.ttf");
#endif
switch (fFontType) {
case kPixmapFont:
// font = new FTGLPixmapFont(inPath);
font = new FTGLPixmapFont((const char*)faceName2);
break;
case kBitmapFont:
font = new FTGLBitmapFont((const char*)faceName2);
break;
case kOutlineFont:
font = new FTGLOutlineFont((const char*)faceName2);
break;
case kPolygonFont:
font = new FTGLPolygonFont((const char*)faceName2);
glEnable( GL_TEXTURE_2D);
// glBindTexture(GL_TEXTURE_2D, textureID);
glDisable( GL_BLEND);
break;
case kExtrudeFont:
font = new FTGLExtrdFont((const char*)faceName2);
break;
case kTextureFont:
font = new FTGLTextureFont((const char*)faceName2);
glEnable( GL_TEXTURE_2D);
glDisable( GL_DEPTH_TEST);
break;
}
if( !font || font->Error()) {
cerr << "Failed to open font " << inPath << endl;
delete font;
return 0;
}
else {
// font->Depth(20); // extrusion distance for the font. Only for FTGLExtrdFont
int cmc = font->CharMapCount();
FT_Encoding encoding = ft_encoding_none;
FT_Encoding* cml = font->CharMapList();
for (int i=0; i<cmc; i++) {
if (i==0) encoding = cml[i];
if (cml[i] == ft_encoding_apple_roman) {
encoding = ft_encoding_apple_roman;
break;
}
}
font->CharMap(encoding);
font->FaceSize(inFontSize);
}
return font;
}