font_system.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 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 **    Mark Page
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_display.h"
00035 #include "font.h"
00036 
00037 #include "../2D/subtexture.h"
00038 #include "../Render/texture.h"
00039 
00040 class CL_FontProvider;
00041 class CL_Font_System_Impl;
00042 class CL_TextureGroup;
00043 
00044 class CL_FontProvider_System;
00045 
00049 typedef struct _CL_Font_System_Position
00050 {
00052         unsigned int glyph;
00053 
00055         int x_pos;
00056 
00058         int y_pos;
00059 
00061         int width;
00062 
00064         int height;
00065 
00067         int x_offset;
00068 
00070         int y_offset;
00071 
00073         int x_increment;
00074 
00076         int y_increment;
00077 } CL_Font_System_Position;
00078 
00082 class CL_Font_TextureGlyph
00083 {
00084 public:
00085         CL_Font_TextureGlyph() : glyph(0), empty_buffer(true), offset(0,0), increment(0,0) { };
00086 
00088         unsigned int glyph;
00089 
00091         bool empty_buffer;
00092 
00094         CL_Subtexture subtexture;
00095 
00097         CL_Rect geometry;
00098 
00100 
00103         CL_Point offset;
00104 
00106 
00109         CL_Point increment;
00110 };
00111 
00112 
00114 
00118 class CL_API_DISPLAY CL_Font_System : public CL_Font
00119 {
00122 
00123 public:
00125         CL_Font_System();
00126 
00132         CL_Font_System( CL_GraphicContext &context, const CL_StringRef &typeface_name, int height);
00133 
00138         CL_Font_System( CL_GraphicContext &context, const CL_FontDescription &desc);
00139 
00140         ~CL_Font_System();
00141 
00145 
00146 public:
00147 
00149         CL_FontProvider_System *get_provider() const;
00150 
00152         CL_Font_TextureGlyph *get_glyph(CL_GraphicContext &gc, int glyph);
00153 
00157 
00158 public:
00159 
00161         void set_texture_group(CL_TextureGroup &new_texture_group);
00162 
00164         void load_font( CL_GraphicContext &context, const CL_FontDescription &desc);
00165 
00167         void free_font();
00168 
00170 
00173         void insert_glyph(CL_GraphicContext &gc, CL_Font_System_Position &position, CL_PixelBuffer &pixel_buffer);
00174 
00176 
00178         void insert_glyph(CL_GraphicContext &gc, const CL_StringRef &text);
00179 
00181         void set_font_metrics(const CL_FontMetrics &metrics);
00182 
00184         static void register_font(const CL_StringRef &font_filename, const CL_StringRef &font_typeface);
00185 
00189 
00190 private:
00192 };
00193