Hi,
When defining a label, using the default font results in a properly
shaped surface: http://esperide.com/label-with-default-font.png whereas
using another (non-default, TTF) font leads to a truncated surface,
apparently not taking into account the actual size of the text:
http://esperide.com/label-with-ttf.png
Unless there is something specific to be done so that labels are resized
accordingly?
(corresponding minimal test code is attached)
Minor typo: in the doc of AG_FetchFont
(http://libagar.org/mdoc.cgi?man=AG_Text.3#AG_TextInfo), the signature
mentions "points", whereas the text uses "size".
By the way, any answer regarding my preceding mail about going to
fullscreen mode?
Thanks for any hint,
Olivier Boudeville.
#include <string>
const std::string & screenName = "DARM Account Screen" ;
/*
* Prototype for the DARM Account Screen.
*
*
*/
#include <agar/core.h>
#include <agar/gui.h>
// For Uint:
#include <agar/core/types.h>
#include <iostream>
using namespace std ;
void agar_error()
{
std::cerr << "Agar error: " << AG_GetError() ;
exit( 5 ) ;
}
void agar_error( const std::string & message)
{
std::cerr << "Agar error " << message << ": " << AG_GetError() ;
exit( 5 ) ;
}
AG_Surface & load_png( const std::string & pngFilename )
{
AG_Surface * surface = AG_SurfaceFromPNG( pngFilename.c_str() ) ;
if ( surface == 0 )
agar_error( "while loading image '" + pngFilename + "'" ) ;
return * surface ;
}
AG_Font & load_font( const std::string & fontFilename )
{
AG_Font * font = AG_FetchFont( /* face */ fontFilename.c_str(),
/* points */ -1, /* flags */ -1 ) ;
if ( font == 0 )
agar_error( "while loading font '" + fontFilename + "'" ) ;
return * font ;
}
AG_Font & load_font( const std::string & fontFilename, int points )
{
AG_Font * font = AG_FetchFont( /* face */ fontFilename.c_str(),
/* points */ points, /* flags */ -1 ) ;
if ( font == 0 )
agar_error( "while loading font '" + fontFilename + "'" ) ;
return * font ;
}
void create_gui()
{
AG_Window * win = AG_WindowNew( 0 ) ;
AG_WindowSetMinSize( win, 800, 600 ) ;
AG_WindowSetCaptionS( win, screenName.c_str() ) ;
AG_Surface & titleSurface = load_png( "DARM-title.png" ) ;
AG_PixmapFromSurface( win, /* flags */ 0, &titleSurface ) ;
AG_SetString( agConfig, "font-path", "." ) ;
//AG_Font & medievalFont = load_font( "medieval.ttf", /* points */ 25 ) ;
// AG_SetDefaultFont( &medievalFont ) ;
AG_Label & useExistingAccountLabel = * AG_LabelNewS( /* parent */ win,
/* flags */ AG_LABEL_FRAME , "Use Existing Account" ) ;
//AG_LabelSizeHint( &useExistingAccountLabel, 0, "Use Existing Account" ) ;
AG_WindowShow( win );
AG_WindowUpdate( win ) ; AG_WindowDraw( win ) ;
}
int main( int argc, char *argv[] )
{
AG_Window * win ;
if ( AG_InitCore( screenName.c_str(), AG_VERBOSE ) == -1 )
agar_error( "while initializing core" ) ;
int w = 1024 ;
int h = 768 ;
int depth = 16 ;
Uint flags = AG_VIDEO_FULLSCREEN | AG_VIDEO_OPENGL | AG_VIDEO_ANYFORMAT ;
//Uint flags = AG_VIDEO_OPENGL | AG_VIDEO_ANYFORMAT ;
if ( AG_InitGraphics( "<OpenGL>" ) == -1 )
agar_error( "while initializing video" ) ;
// if ( AG_InitVideo( w, h, depth, flags ) == -1 )
// agar_error( "while initializing video" ) ;
AG_BindGlobalKey( AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_QuitGUI ) ;
AG_BindGlobalKey( AG_KEY_F8, AG_KEYMOD_ANY, AG_ViewCapture ) ;
create_gui() ;
AG_EventLoop() ;
AG_Destroy() ;
}
_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html