Crazy Eddies GUI System: CEGUIFont.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIFont.h

    00001 /***********************************************************************
    00002     filename:   CEGUIFont.h
    00003     created:    21/2/2004
    00004     author:     Paul D Turner <paul@cegui.org.uk>
    00005 *************************************************************************/
    00006 /***************************************************************************
    00007  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
    00008  *
    00009  *   Permission is hereby granted, free of charge, to any person obtaining
    00010  *   a copy of this software and associated documentation files (the
    00011  *   "Software"), to deal in the Software without restriction, including
    00012  *   without limitation the rights to use, copy, modify, merge, publish,
    00013  *   distribute, sublicense, and/or sell copies of the Software, and to
    00014  *   permit persons to whom the Software is furnished to do so, subject to
    00015  *   the following conditions:
    00016  *
    00017  *   The above copyright notice and this permission notice shall be
    00018  *   included in all copies or substantial portions of the Software.
    00019  *
    00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    00026  *   OTHER DEALINGS IN THE SOFTWARE.
    00027  ***************************************************************************/
    00028 #ifndef _CEGUIFont_h_
    00029 #define _CEGUIFont_h_
    00030
    00031 #include "CEGUIBase.h"
    00032 #include "CEGUIPropertySet.h"
    00033 #include "CEGUIString.h"
    00034 #include "CEGUIXMLSerializer.h"
    00035 #include "CEGUIFontGlyph.h"
    00036
    00037 #include <map>
    00038
    00039 #if defined(_MSC_VER)
    00040 #   pragma warning(push)
    00041 #   pragma warning(disable : 4251)
    00042 #endif
    00043
    00044 // Start of CEGUI namespace section
    00045 namespace CEGUI
    00046 {
    00058 class CEGUIEXPORT Font : public PropertySet
    00059 {
    00060 public:
    00062     static const argb_t DefaultColour;
    00063
    00065     virtual ~Font();
    00066
    00068     const String& getName() const;
    00069
    00071     const String& getTypeName() const;
    00072
    00084     bool isCodepointAvailable(utf32 cp) const
    00085     { return (d_cp_map.find(cp) != d_cp_map.end()); }
    00086
    00124     void drawText(GeometryBuffer& buffer, const String& text,
    00125                   const Vector2& position, const Rect* clip_rect,
    00126                   const ColourRect& colours, const float space_extra = 0.0f,
    00127                   const float x_scale = 1.0f, const float y_scale = 1.0f);
    00128
    00136     void setNativeResolution(const Size& size);
    00137
    00146     Size getNativeResolution() const;
    00147
    00156     void setAutoScaled(const bool auto_scaled);
    00157
    00166     bool isAutoScaled() const;
    00167
    00175     virtual void notifyDisplaySizeChanged(const Size& size);
    00176
    00189     float getLineSpacing(float y_scale = 1.0f) const
    00190     { return d_height * y_scale; }
    00191
    00204     float getFontHeight(float y_scale = 1.0f) const
    00205     { return (d_ascender - d_descender) * y_scale; }
    00206
    00219     float getBaseline(float y_scale = 1.0f) const
    00220     { return d_ascender * y_scale; }
    00221
    00239     float getTextExtent(const String& text, float x_scale = 1.0f) const;
    00240
    00264     size_t getCharAtPixel(const String& text, float pixel,
    00265                           float x_scale = 1.0f) const
    00266     { return getCharAtPixel(text, 0, pixel, x_scale); }
    00267
    00296     size_t getCharAtPixel(const String& text, size_t start_char, float pixel,
    00297                           float x_scale = 1.0f) const;
    00298
    00309     static void setDefaultResourceGroup(const String& resourceGroup)
    00310     { d_defaultResourceGroup = resourceGroup; }
    00311
    00320     static const String& getDefaultResourceGroup()
    00321     { return d_defaultResourceGroup; }
    00322
    00333     void writeXMLToStream(XMLSerializer& xml_stream) const;
    00334
    00347     const FontGlyph* getGlyphData(utf32 codepoint) const;
    00348
    00349 protected:
    00351     Font(const String& name, const String& type_name, const String& filename,
    00352          const String& resource_group, const bool auto_scaled,
    00353          const float native_horz_res, const float native_vert_res);
    00354
    00369     virtual void rasterise(utf32 start_codepoint, utf32 end_codepoint) const;
    00370
    00372     virtual void updateFont() = 0;
    00373
    00375     virtual void writeXMLToStream_impl(XMLSerializer& xml_stream) const = 0;
    00376
    00378     void addFontProperties();
    00379
    00385     void setMaxCodepoint(utf32 codepoint);
    00386
    00388     String d_name;
    00390     String d_type;
    00392     String d_filename;
    00394     String d_resourceGroup;
    00396     static String d_defaultResourceGroup;
    00397
    00399     float d_ascender;
    00401     float d_descender;
    00403     float d_height;
    00404
    00406     bool d_autoScale;
    00408     float d_nativeHorzRes;
    00410     float d_nativeVertRes;
    00412     float d_horzScaling;
    00414     float d_vertScaling;
    00415
    00417     utf32 d_maxCodepoint;
    00418
    00432     uint* d_glyphPageLoaded;
    00433
    00435     typedef std::map<utf32, FontGlyph> CodepointMap;
    00437     CodepointMap d_cp_map;
    00438 };
    00439
    00440 } // End of  CEGUI namespace section
    00441
    00442 #if defined(_MSC_VER)
    00443 #   pragma warning(pop)
    00444 #endif
    00445
    00446
    00447 #endif  // end of guard _CEGUIFont_h_