00001 #ifndef OSDL_FIXED_FONT_H_
00002 #define OSDL_FIXED_FONT_H_
00003
00004
00005
00006 #include "OSDLFont.h"
00007
00008 #include "Ceylan.h"
00009
00010 #include <string>
00011
00012
00013
00014
00015
00016 namespace OSDL
00017 {
00018
00019
00020 namespace Video
00021 {
00022
00023
00024
00025 class Surface ;
00026
00027
00028
00029 namespace TwoDimensional
00030 {
00031
00032
00033
00034 namespace Text
00035 {
00036
00037
00039 extern OSDL_DLL const Length BasicFontCharacterWidth ;
00040
00042 extern OSDL_DLL const Length BasicFontCharacterHeight ;
00043
00044
00060 OSDL_DLL bool printBasic( const std::string & text,
00061 Surface & targetSurface, Coordinate x, Coordinate y,
00062 Pixels::ColorElement red, Pixels::ColorElement blue,
00063 Pixels::ColorElement green,
00064 Pixels::ColorElement alpha = Pixels::AlphaOpaque )
00065 throw() ;
00066
00067
00083 OSDL_DLL bool printBasic( const std::string & text,
00084 Surface & targetSurface,
00085 Coordinate x, Coordinate y,
00086 Pixels::ColorDefinition colorDef ) throw() ;
00087
00088
00089
00146 class OSDL_DLL FixedFont : public Font
00147 {
00148
00149
00150 public:
00151
00152
00243 FixedFont(
00244 Length characterWidth,
00245 Length characterHeight,
00246 RenderingStyle renderingStyle = Normal,
00247 bool convertToDisplay = true,
00248 RenderCache cacheSettings = GlyphCached,
00249 AllowedCachePolicy cachePolicy
00250 = DropLessRequestedFirst,
00251 Ceylan::System::Size quota = 0 )
00252 throw( TextException ) ;
00253
00254
00255
00311 explicit FixedFont(
00312 const std::string & fontFilename,
00313 bool convertToDisplay = true,
00314 RenderCache cacheSettings = GlyphCached,
00315 AllowedCachePolicy cachePolicy
00316 = DropLessRequestedFirst,
00317 Ceylan::System::Size quota = 0 )
00318 throw( TextException ) ;
00319
00320
00325 virtual ~FixedFont() throw() ;
00326
00327
00328
00342 virtual Width getWidth() const throw() ;
00343
00344
00361 virtual Width getWidth( Ceylan::Latin1Char character )
00362 const throw() ;
00363
00364
00387 virtual SignedWidth getWidthOffset(
00388 Ceylan::Latin1Char character )
00389 const throw( TextException ) ;
00390
00391
00407 virtual SignedHeight getHeightAboveBaseline(
00408 Ceylan::Latin1Char character )
00409 const throw( TextException ) ;
00410
00411
00424 virtual SignedLength getAdvance() const
00425 throw( TextException ) ;
00426
00427
00445 virtual SignedLength getAdvance(
00446 Ceylan::Latin1Char character )
00447 const throw( TextException ) ;
00448
00449
00462 virtual Width getInterGlyphWidth() const throw() ;
00463
00464
00465
00480 virtual Text::Height getHeight() const throw() ;
00481
00482
00503 virtual SignedHeight getAscent() const throw() ;
00504
00505
00530 virtual SignedHeight getDescent() const throw() ;
00531
00532
00541 virtual Text::Height getLineSkip() const throw() ;
00542
00543
00544
00545
00546
00547
00548
00567 virtual UprightRectangle & getBoundingBox()
00568 const throw( TextException ) ;
00569
00570
00600 virtual UprightRectangle & getBoundingBoxFor(
00601 const std::string & word )
00602 const throw( TextException ) ;
00603
00604
00605
00606
00607
00608
00609
00640 virtual Surface & renderLatin1Glyph(
00641 Ceylan::Latin1Char character,
00642 RenderQuality quality = Solid,
00643 Pixels::ColorDefinition glyphColor
00644 = Pixels::White )
00645 throw( TextException ) ;
00646
00647
00677 virtual void blitLatin1Glyph(
00678 Surface & targetSurface,
00679 Coordinate x, Coordinate y,
00680 Ceylan::Latin1Char character,
00681 RenderQuality quality = Solid,
00682 Pixels::ColorDefinition glyphColor
00683 = Pixels::White )
00684 throw( TextException ) ;
00685
00686
00700 virtual Surface & renderLatin1GlyphAlpha(
00701 Ceylan::Latin1Char character,
00702 RenderQuality quality = Solid,
00703 Pixels::ColorDefinition glyphColor
00704 = Pixels::White )
00705 throw( TextException ) ;
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00728 virtual const std::string toString(
00729 Ceylan::VerbosityLevels level = Ceylan::high )
00730 const throw() ;
00731
00732
00733
00734
00735
00736
00742 static RenderQuality GetObtainedQualityFor(
00743 RenderQuality targetedQuality )
00744 throw() ;
00745
00746
00778 static void SetFontSettings(
00779 const Ceylan::Byte * fontData,
00780 Length characterWidth,
00781 Length characterHeight ) throw() ;
00782
00783
00788 static Ceylan::System::FileLocator
00789 FixedFontFileLocator ;
00790
00791
00793 static std::string FontFileExtension ;
00794
00795
00801 static const Ceylan::Float32 SpaceWidthFactor ;
00802
00803
00804
00805 protected:
00806
00807
00813 static const RenderQuality DefaultQuality = Solid ;
00814
00815
00825 virtual void loadFontFrom(
00826 const std::string & fontFilename )
00827 throw( TextException ) ;
00828
00829
00870 virtual const Surface & submitLatin1GlyphToCache(
00871 Ceylan::Latin1Char character,
00872 Pixels::ColorDefinition glyphColor )
00873 throw( TextException ) ;
00874
00875
00890 virtual Surface & basicRenderLatin1Glyph(
00891 Ceylan::Latin1Char character,
00892 Pixels::ColorDefinition glyphColor )
00893 throw( TextException ) ;
00894
00895
00930 virtual void basicBlitLatin1Glyph(
00931 Surface & targetSurface,
00932 Coordinate x, Coordinate y,
00933 Ceylan::Latin1Char character,
00934 Pixels::ColorDefinition glyphColor )
00935 throw( TextException ) ;
00936
00937
00938
00940 Length _width ;
00941
00943 Length _height ;
00944
00945
00947 char * _fontData ;
00948
00949
00966 static std::string BuildFontFilenameFor(
00967 Length characterWidth,
00968 Length characterHeight,
00969 RenderingStyle renderingStyle )
00970 throw( TextException ) ;
00971
00972
00973
00974
00975
00976
00997 static void GetFontAttributesFrom(
00998 const std::string & filename,
00999 Length & characterWidth,
01000 Length & characterHeight,
01001 RenderingStyle & renderingStyle )
01002 throw( TextException ) ;
01003
01004
01010 static const Ceylan::Uint16 FontCharacterCount ;
01011
01012
01013
01014
01015 private:
01016
01017
01026 FixedFont( const FixedFont & source ) throw() ;
01027
01028
01037 FixedFont & operator = ( const FixedFont & source )
01038 throw() ;
01039
01040
01041
01042 } ;
01043
01044 }
01045
01046 }
01047
01048 }
01049
01050 }
01051
01052
01053 #endif // OSDL_FIXED_FONT_H_
01054