00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OSDL_FIXED_FONT_H_
00028 #define OSDL_FIXED_FONT_H_
00029
00030
00031
00032 #include "OSDLFont.h"
00033
00034 #include "Ceylan.h"
00035
00036 #include <string>
00037
00038
00039
00040
00041
00042 namespace OSDL
00043 {
00044
00045
00046
00047 namespace Video
00048 {
00049
00050
00051
00052
00053 class Surface ;
00054
00055
00056
00057
00058 namespace TwoDimensional
00059 {
00060
00061
00062
00063 namespace Text
00064 {
00065
00066
00067
00069 extern OSDL_DLL const Length BasicFontCharacterWidth ;
00070
00071
00073 extern OSDL_DLL const Length BasicFontCharacterHeight ;
00074
00075
00076
00094 OSDL_DLL bool printBasic(
00095 const std::string & text,
00096 Surface & targetSurface, Coordinate x, Coordinate y,
00097 Pixels::ColorElement red, Pixels::ColorElement blue,
00098 Pixels::ColorElement green,
00099 Pixels::ColorElement alpha = Pixels::AlphaOpaque ) ;
00100
00101
00102
00120 OSDL_DLL bool printBasic(
00121 const std::string & text,
00122 Surface & targetSurface,
00123 Coordinate x, Coordinate y,
00124 Pixels::ColorDefinition colorDef ) ;
00125
00126
00127
00128
00185 class OSDL_DLL FixedFont: public Font
00186 {
00187
00188
00189
00190 public:
00191
00192
00193
00194
00285 FixedFont(
00286 Length characterWidth,
00287 Length characterHeight,
00288 RenderingStyle renderingStyle = Normal,
00289 bool convertToDisplay = true,
00290 RenderCache cacheSettings = GlyphCached,
00291 AllowedCachePolicy cachePolicy
00292 = DropLessRequestedFirst,
00293 Ceylan::System::Size quota = 0 ) ;
00294
00295
00296
00352 explicit FixedFont(
00353 const std::string & fontFilename,
00354 bool convertToDisplay = true,
00355 RenderCache cacheSettings = GlyphCached,
00356 AllowedCachePolicy cachePolicy
00357 = DropLessRequestedFirst,
00358 Ceylan::System::Size quota = 0 ) ;
00359
00360
00361
00366 virtual ~FixedFont() throw() ;
00367
00368
00369
00383 virtual Width getWidth() const ;
00384
00385
00386
00403 virtual Width getWidth( Ceylan::Latin1Char character )
00404 const ;
00405
00406
00407
00430 virtual SignedWidth getWidthOffset(
00431 Ceylan::Latin1Char character ) const ;
00432
00433
00434
00450 virtual SignedHeight getHeightAboveBaseline(
00451 Ceylan::Latin1Char character ) const ;
00452
00453
00454
00467 virtual SignedLength getAdvance() const ;
00468
00469
00470
00488 virtual SignedLength getAdvance(
00489 Ceylan::Latin1Char character ) const ;
00490
00491
00492
00505 virtual Width getInterGlyphWidth() const ;
00506
00507
00508
00523 virtual Text::Height getHeight() const ;
00524
00525
00526
00547 virtual SignedHeight getAscent() const ;
00548
00549
00550
00575 virtual SignedHeight getDescent() const ;
00576
00577
00578
00587 virtual Text::Height getLineSkip() const ;
00588
00589
00590
00591
00592
00593
00594
00595
00614 virtual UprightRectangle & getBoundingBox() const ;
00615
00616
00617
00647 virtual UprightRectangle & getBoundingBoxFor(
00648 const std::string & word ) const ;
00649
00650
00651
00652
00653
00654
00655
00656
00687 virtual Surface & renderLatin1Glyph(
00688 Ceylan::Latin1Char character,
00689 RenderQuality quality = Solid,
00690 Pixels::ColorDefinition glyphColor = Pixels::White
00691 ) ;
00692
00693
00694
00724 virtual void blitLatin1Glyph(
00725 Surface & targetSurface,
00726 Coordinate x, Coordinate y,
00727 Ceylan::Latin1Char character,
00728 RenderQuality quality = Solid,
00729 Pixels::ColorDefinition glyphColor = Pixels::White
00730 ) ;
00731
00732
00733
00747 virtual Surface & renderLatin1GlyphAlpha(
00748 Ceylan::Latin1Char character,
00749 RenderQuality quality = Solid,
00750 Pixels::ColorDefinition glyphColor = Pixels::White
00751 ) ;
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00775 virtual const std::string toString(
00776 Ceylan::VerbosityLevels level = Ceylan::high )
00777 const ;
00778
00779
00780
00781
00782
00783
00784
00785
00791 static RenderQuality GetObtainedQualityFor(
00792 RenderQuality targetedQuality ) ;
00793
00794
00795
00830 static void SetFontSettings(
00831 const Ceylan::Byte * fontData,
00832 Length characterWidth,
00833 Length characterHeight ) ;
00834
00835
00836
00841 static Ceylan::System::FileLocator
00842 FixedFontFileLocator ;
00843
00844
00845
00847 static std::string FontFileExtension ;
00848
00849
00850
00856 static const Ceylan::Float32 SpaceWidthFactor ;
00857
00858
00859
00860
00861 protected:
00862
00863
00864
00870 static const RenderQuality DefaultQuality = Solid ;
00871
00872
00873
00883 virtual void loadFontFrom(
00884 const std::string & fontFilename ) ;
00885
00886
00887
00928 virtual const Surface & submitLatin1GlyphToCache(
00929 Ceylan::Latin1Char character,
00930 Pixels::ColorDefinition glyphColor ) ;
00931
00932
00933
00948 virtual Surface & basicRenderLatin1Glyph(
00949 Ceylan::Latin1Char character,
00950 Pixels::ColorDefinition glyphColor ) ;
00951
00952
00953
00988 virtual void basicBlitLatin1Glyph(
00989 Surface & targetSurface,
00990 Coordinate x, Coordinate y,
00991 Ceylan::Latin1Char character,
00992 Pixels::ColorDefinition glyphColor ) ;
00993
00994
00995
00996
00998 Length _width ;
00999
01000
01001
01003 Length _height ;
01004
01005
01006
01008 char * _fontData ;
01009
01010
01011
01028 static std::string BuildFontFilenameFor(
01029 Length characterWidth,
01030 Length characterHeight,
01031 RenderingStyle renderingStyle ) ;
01032
01033
01034
01035
01036
01037
01038
01039
01060 static void GetFontAttributesFrom(
01061 const std::string & filename,
01062 Length & characterWidth,
01063 Length & characterHeight,
01064 RenderingStyle & renderingStyle ) ;
01065
01066
01067
01073 static const Ceylan::Uint16 FontCharacterCount ;
01074
01075
01076
01077
01078 private:
01079
01080
01081
01090 FixedFont( const FixedFont & source ) ;
01091
01092
01093
01102 FixedFont & operator = ( const FixedFont & source ) ;
01103
01104
01105
01106 } ;
01107
01108
01109 }
01110
01111 }
01112
01113 }
01114
01115 }
01116
01117
01118
01119 #endif // OSDL_FIXED_FONT_H_
01120