ClanLib  2.3.7
font_system.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Mark Page
27 */
28 
31 
32 #pragma once
33 
34 #include "../api_display.h"
35 #include "font.h"
36 
37 #include "../2D/subtexture.h"
38 #include "../Render/texture.h"
39 
40 class CL_FontProvider;
41 class CL_Font_System_Impl;
42 class CL_TextureGroup;
43 
44 class CL_FontProvider_System;
45 
49 typedef struct _CL_Font_System_Position
50 {
52  unsigned int glyph;
53 
55  int x_pos;
56 
58  int y_pos;
59 
61  int width;
62 
64  int height;
65 
67  int x_offset;
68 
70  int y_offset;
71 
74 
78 
83 {
84 public:
85  CL_Font_TextureGlyph() : glyph(0), empty_buffer(true), offset(0,0), increment(0,0) { };
86 
88  unsigned int glyph;
89 
92 
95 
98 
100 
104 
106 
110 };
111 
112 
114 
119 {
122 
123 public:
125  CL_Font_System();
126 
132  CL_Font_System( CL_GraphicContext &context, const CL_StringRef &typeface_name, int height);
133 
138  CL_Font_System( CL_GraphicContext &context, const CL_FontDescription &desc);
139 
140  ~CL_Font_System();
141 
145 
146 public:
147 
149  CL_FontProvider_System *get_provider() const;
150 
152  CL_Font_TextureGlyph *get_glyph(CL_GraphicContext &gc, int glyph);
153 
157 
158 public:
159 
161  void set_texture_group(CL_TextureGroup &new_texture_group);
162 
164  void load_font( CL_GraphicContext &context, const CL_FontDescription &desc);
165 
167  void free_font();
168 
170 
173  void insert_glyph(CL_GraphicContext &gc, CL_Font_System_Position &position, CL_PixelBuffer &pixel_buffer);
174 
176 
178  void insert_glyph(CL_GraphicContext &gc, const CL_StringRef &text);
179 
181  void set_font_metrics(const CL_FontMetrics &metrics);
182 
184  static void register_font(const CL_StringRef &font_filename, const CL_StringRef &font_typeface);
185 
189 
190 private:
192 };
193