font.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_display.h"
00035 #include "../../Core/System/sharedptr.h"
00036 #include "../Render/graphic_context.h"
00037 #include "../Image/pixel_buffer.h"
00038 #include "font_description.h"
00039 
00040 class CL_FontProvider;
00041 class CL_Font_Impl;
00042 
00046 class CL_API_DISPLAY CL_Font
00047 {
00050 
00051 public:
00053         CL_Font();
00054 
00055         // \brief Constructs standard font - Currently this defaults to CL_Font_System
00056         CL_Font( CL_GraphicContext &context, const CL_StringRef &typeface_name, int height);
00057 
00058         // \brief Constructs standard font - Currently this defaults to CL_Font_System
00059         CL_Font( CL_GraphicContext &context, const CL_FontDescription &desc);
00060 
00064         CL_Font(CL_FontProvider *provider);
00065 
00069         CL_Font(const CL_Font &copy);
00070 
00071         virtual ~CL_Font();
00072 
00076 
00077 public:
00078 
00082         bool is_null();
00083 
00085         CL_FontProvider *get_provider() const;
00086 
00090 
00091 public:
00092 
00102         void draw_text(CL_GraphicContext &gc, int x, int y, const CL_StringRef &text, const CL_Colorf &color = CL_Colorf::white);
00103 
00113         void draw_text(CL_GraphicContext &gc, float x, float y, const CL_StringRef &text, const CL_Colorf &color = CL_Colorf::white);
00114 
00123         void draw_text(CL_GraphicContext &gc, const CL_Pointf &position, const CL_StringRef &text, const CL_Colorf &color = CL_Colorf::white);
00124 
00131         CL_Size get_text_size(CL_GraphicContext &gc, const CL_StringRef &text);
00132 
00134         CL_FontMetrics get_font_metrics(CL_GraphicContext &gc);
00135 
00144         int get_character_index(CL_GraphicContext &gc, const CL_String &text, const CL_Point &point);
00145 
00149 
00150 private:
00151         CL_SharedPtr<CL_Font_Impl> impl;
00153 };
00154 
00158 class CL_API_DISPLAY CL_FontPixelBuffer
00159 {
00160 public:
00161         CL_FontPixelBuffer() : glyph(0), empty_buffer(true), offset(0,0), increment(0,0) { };
00162 
00164         unsigned int glyph;
00165 
00167         bool empty_buffer;
00168 
00170         CL_PixelBuffer buffer;
00171 
00173 
00176         CL_Point offset;
00177 
00179 
00182         CL_Point increment;
00183 };
00184 
00186 

Generated on Thu Dec 3 02:39:29 2009 for ClanLib by  doxygen 1.4.6