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_TRUETYPE_FONT_H_
00028 #define OSDL_TRUETYPE_FONT_H_
00029
00030
00031
00032 #include "OSDLFont.h"
00033
00034
00035 #include "Ceylan.h"
00036
00037
00038 #include <string>
00039
00040 #if ! defined(OSDL_USES_SDL_TTF) || OSDL_USES_SDL_TTF
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 struct _TTF_Font ;
00054
00055 #endif // OSDL_USES_SDL_TTF
00056
00057
00058
00059
00060
00061 namespace OSDL
00062 {
00063
00064
00065
00066 namespace Video
00067 {
00068
00069
00070
00071
00072 class Surface ;
00073
00074
00075
00076
00077 namespace TwoDimensional
00078 {
00079
00080
00081
00082 namespace Text
00083 {
00084
00085
00086
00087
00088 #if ! defined(OSDL_USES_SDL_TTF) || OSDL_USES_SDL_TTF
00089
00090 typedef ::_TTF_Font LowLevelTTFFont ;
00091
00092 #else // OSDL_USES_SDL_TTF
00093
00094 struct LowLevelTTFFont {} ;
00095
00096 #endif // OSDL_USES_SDL_TTF
00097
00098
00099
00100
00101 class TrueTypeFont ;
00102
00103
00105 typedef Ceylan::CountedPointer<TrueTypeFont>
00106 TrueTypeFontCountedPtr ;
00107
00108
00109
00167 class OSDL_DLL TrueTypeFont : public Font,
00168 public Ceylan::LoadableWithContent<LowLevelTTFFont>
00169 {
00170
00171
00172 public:
00173
00174
00175
00176
00233 TrueTypeFont(
00234 const std::string & fontFilename,
00235 FontIndex index = 0,
00236 bool convertToDisplay = true,
00237 RenderCache cacheSettings = GlyphCached,
00238 bool preload = false ) ;
00239
00240
00241
00246 virtual ~TrueTypeFont() throw() ;
00247
00248
00249
00250
00251
00252
00253
00254
00266 virtual bool load() ;
00267
00268
00269
00281 virtual bool unload() ;
00282
00283
00284
00301 virtual bool load( PointSize newPointSize ) ;
00302
00303
00304
00305
00312 virtual PointSize getPointSize() const ;
00313
00314
00315
00331 virtual void setPointSize( PointSize newPointSize ) ;
00332
00333
00334
00335
00340 virtual RenderingStyle getRenderingStyle() const ;
00341
00342
00343
00364 virtual void setRenderingStyle(
00365 RenderingStyle newStyle ) ;
00366
00367
00368
00369
00370
00371
00372
00373
00389 virtual Width getWidth( Ceylan::Latin1Char character )
00390 const ;
00391
00392
00393
00409 virtual SignedWidth getWidthOffset(
00410 Ceylan::Latin1Char character ) const ;
00411
00412
00413
00425 virtual SignedHeight getHeightAboveBaseline(
00426 Ceylan::Latin1Char character ) const ;
00427
00428
00429
00447 virtual SignedLength getAdvance(
00448 Ceylan::Latin1Char character ) const ;
00449
00450
00451
00452
00453
00454
00455
00456
00473 virtual Height getHeight() const ;
00474
00475
00476
00491 virtual SignedHeight getAscent() const ;
00492
00493
00494
00513 virtual SignedHeight getDescent() const ;
00514
00515
00516
00525 virtual Height getLineSkip() const ;
00526
00527
00528
00540 virtual Ceylan::Uint16 getFacesCount() const ;
00541
00542
00543
00556 virtual bool isFixedWidth() const ;
00557
00558
00559
00564 virtual std::string getFaceFamilyName() const ;
00565
00566
00567
00572 virtual std::string getFaceStyleName() const ;
00573
00574
00575
00576
00577
00578
00579
00580
00581
00614 virtual UprightRectangle & getBoundingBoxFor(
00615 Ceylan::Unicode glyph, SignedLength & advance )
00616 const ;
00617
00618
00619
00646 virtual UprightRectangle & getBoundingBoxFor(
00647 const std::string & text ) const ;
00648
00649
00650
00678 virtual UprightRectangle & getBoundingBoxForUTF8(
00679 const std::string & text ) const ;
00680
00681
00682
00710 virtual UprightRectangle & getBoundingBoxForUnicode(
00711 const Ceylan::Unicode * text ) const ;
00712
00713
00714
00715
00716
00717
00718
00719
00751 virtual Surface & renderLatin1Glyph(
00752 Ceylan::Latin1Char character,
00753 RenderQuality quality = Solid,
00754 Pixels::ColorDefinition glyphColor
00755 = Pixels::White ) ;
00756
00757
00758
00785 virtual void blitLatin1Glyph(
00786 Surface & targetSurface,
00787 Coordinate x, Coordinate y,
00788 Ceylan::Latin1Char character,
00789 RenderQuality quality = Solid,
00790 Pixels::ColorDefinition glyphColor
00791 = Pixels::White ) ;
00792
00793
00794
00825 virtual Surface & renderUnicodeGlyph(
00826 Ceylan::Unicode character,
00827 RenderQuality quality = Solid,
00828 Pixels::ColorDefinition textColor
00829 = Pixels::White ) ;
00830
00831
00832
00860 virtual Surface & renderLatin1Text(
00861 const std::string & text,
00862 RenderQuality quality = Solid,
00863 Pixels::ColorDefinition textColor
00864 = Pixels::White ) ;
00865
00866
00867
00896 virtual Surface & renderUTF8Text(
00897 const std::string & text,
00898 RenderQuality quality = Solid,
00899 Pixels::ColorDefinition textColor
00900 = Pixels::White ) ;
00901
00902
00903
00933 virtual Surface & renderUnicodeText(
00934 const Ceylan::Unicode * text,
00935 RenderQuality quality = Solid,
00936 Pixels::ColorDefinition textColor
00937 = Pixels::Black ) ;
00938
00939
00940
00941
00954 virtual const std::string toString(
00955 Ceylan::VerbosityLevels level = Ceylan::high )
00956 const ;
00957
00958
00959
00960
00961
00962
00963
00964
00965
00971 static RenderQuality GetObtainedQualityFor(
00972 RenderQuality targetedQuality ) ;
00973
00974
00975
00997 void SetUnicodeSwapStatus( bool newStatus ) ;
00998
00999
01000
01006 static std::string DescribeLastError() ;
01007
01008
01009
01031 static std::string FindPathFor(
01032 const std::string & fontFilename ) ;
01033
01034
01043 static PointSize DefaultPointSize ;
01044
01045
01050 static Ceylan::System::FileLocator
01051 TrueTypeFontFileLocator ;
01052
01053
01054
01056 static std::string TrueTypeFontFileExtension ;
01057
01058
01059
01065 static const Ceylan::Float32 SpaceWidthFactor ;
01066
01067
01068
01069
01070
01071 protected:
01072
01073
01074
01095 virtual Surface & basicRenderUnicodeGlyph(
01096 Ceylan::Unicode character,
01097 RenderQuality quality,
01098 Pixels::ColorDefinition glyphColor ) ;
01099
01100
01101
01102
01103
01104
01105
01107 PointSize _pointSize ;
01108
01109
01124 static Ceylan::Uint32 FontCounter ;
01125
01126
01127
01128
01129 private:
01130
01131
01132
01141 TrueTypeFont( const TrueTypeFont & source ) ;
01142
01143
01144
01153 TrueTypeFont & operator = (
01154 const TrueTypeFont & source ) ;
01155
01156
01157 } ;
01158
01159
01160 }
01161
01162 }
01163
01164 }
01165
01166 }
01167
01168
01169
01170 #endif // OSDL_TRUETYPE_FONT_H_