OSDLTrueTypeFont.h

Go to the documentation of this file.
00001 #ifndef OSDL_TRUETYPE_FONT_H_
00002 #define OSDL_TRUETYPE_FONT_H_
00003 
00004 
00005 #include "OSDLFont.h"         // for inheritance
00006 
00007 // for font primitives (no TTF_Font forward declaration possible)
00008 #include "SDL_ttf.h"          
00009 
00010 #include <string>
00011 
00012 
00013 
00014 
00015 
00016 namespace OSDL
00017 {
00018 
00019 
00020     namespace Video
00021     {
00022 
00023 
00024         // Fonts are rendered to surfaces.
00025         class Surface ;
00026 
00027 
00028 
00029         namespace TwoDimensional
00030         {
00031             
00032                         
00033             
00034             namespace Text
00035             {   
00036             
00037 
00038 
00096                 class OSDL_DLL TrueTypeFont : public Font
00097                 {
00098                 
00099                 
00100                     public:
00101                     
00102                     
00103                         
00141                         TrueTypeFont( 
00142                             const std::string & fontFilename, 
00143                             PointSize pointSize,
00144                             FontIndex index = 0, 
00145                             bool convertToDisplay = true,
00146                             RenderCache cacheSettings = GlyphCached ) 
00147                                 throw( TextException ) ;
00148                         
00149                         
00154                         virtual ~TrueTypeFont() throw() ;
00155                         
00156                         
00162                         virtual PointSize getPointSize() const throw() ;
00163                         
00164 
00169                         virtual RenderingStyle getRenderingStyle() const 
00170                             throw() ;
00171                         
00172                         
00193                         virtual void setRenderingStyle( 
00194                             RenderingStyle newStyle ) throw( TextException ) ;
00195 
00196 
00197 
00198                         // Glyph-dependent methods.     
00199                         
00200                         
00216                         virtual Width getWidth( Ceylan::Latin1Char character ) 
00217                             const throw( TextException ) ;
00218                                 
00219                                 
00235                         virtual SignedWidth getWidthOffset( 
00236                                 Ceylan::Latin1Char character ) 
00237                             const throw( TextException ) ;
00238                                 
00239                                 
00251                         virtual SignedHeight getHeightAboveBaseline(
00252                                 Ceylan::Latin1Char character ) 
00253                             const throw( TextException ) ;
00254                                 
00255                          
00273                         virtual SignedLength getAdvance( 
00274                                 Ceylan::Latin1Char character ) 
00275                             const throw( TextException ) ;
00276                         
00277                         
00278                         
00279                         // Glyph-independent methods.       
00280                                                 
00281                                                 
00298                         virtual Height getHeight() const throw() ;
00299                                                 
00300                         
00315                         virtual SignedHeight getAscent() const throw() ;
00316                          
00317                          
00336                         virtual SignedHeight getDescent() const throw() ;
00337                          
00338                          
00347                         virtual Height getLineSkip() const throw() ;
00348                         
00349                         
00361                         virtual Ceylan::Uint16 getFacesCount() const throw() ; 
00362                         
00363                         
00376                         virtual bool isFixedWidth() const throw() ;
00377                         
00378                           
00383                         virtual std::string getFaceFamilyName() const throw() ;
00384                         
00385                         
00390                         virtual std::string getFaceStyleName() const throw() ;
00391                         
00392                         
00393                         
00394                         
00395                         // Bounding boxes section.
00396                         
00397                         
00398                         
00431                         virtual UprightRectangle & getBoundingBoxFor(
00432                                 Ceylan::Unicode glyph, SignedLength & advance )
00433                             const throw( TextException ) ;
00434                             
00435                             
00436                          
00463                         virtual UprightRectangle & getBoundingBoxFor( 
00464                                 const std::string & text )
00465                             const throw( TextException ) ;
00466                              
00467                              
00468                              
00496                         virtual UprightRectangle & getBoundingBoxForUTF8( 
00497                                 const std::string & text )
00498                             const throw( TextException ) ;
00499                              
00500                              
00501                              
00529                         virtual UprightRectangle & getBoundingBoxForUnicode( 
00530                                 const Ceylan::Unicode * text ) 
00531                             const throw( TextException ) ;
00532                              
00533                              
00534                              
00535                         
00536                         // Render section.
00537 
00538 
00539 
00571                         virtual Surface & renderLatin1Glyph( 
00572                                 Ceylan::Latin1Char character, 
00573                                 RenderQuality quality = Solid, 
00574                                 Pixels::ColorDefinition glyphColor 
00575                                     = Pixels::White ) 
00576                             throw( TextException ) ;
00577                              
00578                              
00579 
00606                         virtual void blitLatin1Glyph( 
00607                                 Surface & targetSurface,
00608                                 Coordinate x, Coordinate y, 
00609                                 Ceylan::Latin1Char character, 
00610                                 RenderQuality quality = Solid, 
00611                                 Pixels::ColorDefinition glyphColor 
00612                                     = Pixels::White )  
00613                             throw( TextException ) ;
00614                              
00615                              
00616                              
00647                         virtual Surface & renderUnicodeGlyph( 
00648                                 Ceylan::Unicode character, 
00649                                 RenderQuality quality = Solid,
00650                                 Pixels::ColorDefinition textColor 
00651                                     = Pixels::White ) 
00652                             throw( TextException ) ;
00653                         
00654                         
00655                         
00683                         virtual Surface & renderLatin1Text( 
00684                                 const std::string & text, 
00685                                 RenderQuality quality = Solid,
00686                                 Pixels::ColorDefinition textColor 
00687                                     = Pixels::White ) 
00688                             throw( TextException ) ;
00689                             
00690                             
00691                         
00720                         virtual Surface & renderUTF8Text( 
00721                                 const std::string & text, 
00722                                 RenderQuality quality = Solid,
00723                                 Pixels::ColorDefinition textColor 
00724                                     = Pixels::White ) 
00725                             throw( TextException ) ;
00726                             
00727                             
00728                         
00758                         virtual Surface & renderUnicodeText( 
00759                                 const Ceylan::Unicode * text, 
00760                                 RenderQuality quality = Solid,
00761                                 Pixels::ColorDefinition textColor 
00762                                     = Pixels::Black ) 
00763                             throw( TextException ) ;
00764                             
00765                             
00766                                                         
00767                             
00780                         virtual const std::string toString( 
00781                                 Ceylan::VerbosityLevels level = Ceylan::high ) 
00782                             const throw() ;
00783 
00784 
00785 
00786     
00787                         // Static section.
00788                         
00789                         
00795                         static RenderQuality GetObtainedQualityFor(
00796                                 RenderQuality targetedQuality )
00797                             throw() ;
00798 
00799                         
00821                         void SetUnicodeSwapStatus( bool newStatus ) throw() ;
00822                 
00823                 
00824                 
00830                         static std::string DescribeLastError() throw() ;
00831                         
00832     
00837                         static Ceylan::System::FileLocator
00838                             TrueTypeFontFileLocator ;
00839 
00840 
00842                         static std::string TrueTypeFontFileExtension ;
00843                         
00844                         
00850                         static const Ceylan::Float32 SpaceWidthFactor ;
00851                             
00852                                                 
00853                                                 
00854                         
00855                     protected:
00856                     
00857 
00858 
00879                         virtual Surface & basicRenderUnicodeGlyph(
00880                                 Ceylan::Unicode character,
00881                                 RenderQuality quality, 
00882                                 Pixels::ColorDefinition glyphColor )
00883                             throw( TextException ) ;
00884     
00885     
00886                         
00887                         // Font filename is not kept currently.
00888                         
00889                         
00891                         PointSize _pointSize ;
00892                         
00893                         
00895                         TTF_Font * _actualFont ;
00896                         
00897                         
00904                         static Ceylan::Uint32 FontCounter ;
00905                     
00906                     
00907                     
00908                     
00909                     private:
00910                     
00911                 
00912                                     
00921                         TrueTypeFont( const TrueTypeFont & source ) throw() ;
00922             
00923             
00932                         TrueTypeFont & operator = ( 
00933                             const TrueTypeFont & source ) throw() ;
00934                 
00935                                     
00936                 
00937                 } ;
00938                 
00939             } 
00940             
00941         }   
00942             
00943     }
00944     
00945 }       
00946 
00947 
00948 #endif // OSDL_TRUETYPE_FONT_H_
00949 

Generated on Fri Mar 30 14:47:00 2007 for OSDL by  doxygen 1.5.1